Repository navigation
Expand file tree
/
Copy pathreference-objects.mjs
More file actions
161 lines (157 loc) · 6.61 KB
/
Copy pathreference-objects.mjs
File metadata and controls
161 lines (157 loc) · 6.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// @ts-check
/**
* Shared between the markdown theme and extract-methods.mjs.
* `page.url` values are relative to TypeDoc `out` (e.g. `.typedoc/temp-docs`).
*/
/**
* Reference object page: MDX path → TypeDoc symbol + optional source hint.
*
* Keys **must** match `custom-router.mjs` (`ClerkRouter`): for each symbol, `shared/<kebab(symbol)>/<kebab(symbol)>.mdx`
* (e.g. `SessionResource` → `shared/session-resource/session-resource.mdx`). If the path drifts, TypeDoc writes one folder while `extract-methods.mjs` strips/writes under another.
*
* `declarationHint` is a substring of `packages/shared/src/**` file paths (used by `findInterfaceOrClass()` in `extract-methods.mjs` when multiple reflections share the same interface/class name).
*
* `extract-methods.mjs` reads each file, writes `properties.mdx` with the same Properties table as TypeDoc (no `## Properties` heading), strips Properties from `<object>.mdx`, and writes methods under `methods/`.
*
* Optional **`extraMethodInterfaces`**: extra `interface` / `class` declarations whose callable members (and `@extractMethods` namespaces) are emitted into the same `methods/` folder. Use when the documented resource type and the API surface live on different types (e.g. `APIKeyResource` vs `APIKeysNamespace` on `Clerk.apiKeys`).
*/
export const REFERENCE_OBJECT_CONFIG = {
'shared/clerk/clerk.mdx': {
symbol: 'Clerk',
declarationHint: 'types/clerk',
},
'shared/client-resource/client-resource.mdx': {
symbol: 'ClientResource',
declarationHint: 'types/client',
},
'shared/session-resource/session-resource.mdx': {
symbol: 'SessionResource',
declarationHint: 'types/session',
},
'shared/user-resource/user-resource.mdx': {
symbol: 'UserResource',
declarationHint: 'types/user',
},
'shared/sign-in-future-resource/sign-in-future-resource.mdx': {
symbol: 'SignInFutureResource',
declarationHint: 'types/signInFuture',
},
'shared/sign-up-future-resource/sign-up-future-resource.mdx': {
symbol: 'SignUpFutureResource',
declarationHint: 'types/signUpFuture',
},
'shared/organization-resource/organization-resource.mdx': {
symbol: 'OrganizationResource',
declarationHint: 'types/organization',
},
'shared/api-key-resource/api-key-resource.mdx': {
symbol: 'APIKeyResource',
declarationHint: 'types/apiKeys',
extraMethodInterfaces: [{ symbol: 'APIKeysNamespace', declarationHint: 'types/apiKeys' }],
},
'shared/billing-namespace/billing-namespace.mdx': {
symbol: 'BillingNamespace',
declarationHint: 'types/billing',
},
};
/**
* Backend API endpoint pages: identical extraction machinery as {@link REFERENCE_OBJECT_CONFIG}, but each `methods/<name>.mdx` is written in **page format** — no `### foo()` title at the top, and the `Parameters` section uses an `## H2` heading. The reference-object format uses an H3 title + H4 parameters, which suits pages that aggregate many methods on a single resource. Backend API method files are consumed standalone (one method per docs page), so the heading levels need to shift accordingly.
*/
export const BACKEND_API_CONFIG = {
'backend/user-api/user-api.mdx': {
symbol: 'UserAPI',
declarationHint: 'api/endpoints/UserApi',
},
'backend/organization-api/organization-api.mdx': {
symbol: 'OrganizationAPI',
declarationHint: 'api/endpoints/OrganizationApi',
},
'backend/billing-api/billing-api.mdx': {
symbol: 'BillingAPI',
declarationHint: 'api/endpoints/BillingApi',
},
'backend/allowlist-identifier-api/allowlist-identifier-api.mdx': {
symbol: 'AllowlistIdentifierAPI',
declarationHint: 'api/endpoints/AllowlistIdentifierApi',
},
'backend/domain-api/domain-api.mdx': {
symbol: 'DomainAPI',
declarationHint: 'api/endpoints/DomainApi',
},
'backend/session-api/session-api.mdx': {
symbol: 'SessionAPI',
declarationHint: 'api/endpoints/SessionApi',
},
'backend/client-api/client-api.mdx': {
symbol: 'ClientAPI',
declarationHint: 'api/endpoints/ClientApi',
},
'backend/invitation-api/invitation-api.mdx': {
symbol: 'InvitationAPI',
declarationHint: 'api/endpoints/InvitationApi',
},
'backend/redirect-url-api/redirect-url-api.mdx': {
symbol: 'RedirectUrlAPI',
declarationHint: 'api/endpoints/RedirectUrlApi',
},
'backend/email-address-api/email-address-api.mdx': {
symbol: 'EmailAddressAPI',
declarationHint: 'api/endpoints/EmailAddressApi',
},
'backend/phone-number-api/phone-number-api.mdx': {
symbol: 'PhoneNumberAPI',
declarationHint: 'api/endpoints/PhoneNumberApi',
},
'backend/agent-task-api/agent-task-api.mdx': {
symbol: 'AgentTaskAPI',
declarationHint: 'api/endpoints/AgentTaskApi',
},
'backend/sign-in-token-api/sign-in-token-api.mdx': {
symbol: 'SignInTokenAPI',
declarationHint: 'api/endpoints/SignInTokenApi',
},
'backend/enterprise-connection-api/enterprise-connection-api.mdx': {
symbol: 'EnterpriseConnectionAPI',
declarationHint: 'api/endpoints/EnterpriseConnectionApi',
},
'backend/testing-token-api/testing-token-api.mdx': {
symbol: 'TestingTokenAPI',
declarationHint: 'api/endpoints/TestingTokenApi',
},
'backend/waitlist-entry-api/waitlist-entry-api.mdx': {
symbol: 'WaitlistEntryAPI',
declarationHint: 'api/endpoints/WaitlistEntryApi',
},
'backend/machine-api/machine-api.mdx': {
symbol: 'MachineApi',
declarationHint: 'api/endpoints/MachineApi',
},
'backend/m2-m-token-api/m2-m-token-api.mdx': {
symbol: 'M2MTokenApi',
declarationHint: 'api/endpoints/M2MTokenApi',
},
'backend/o-auth-applications-api/o-auth-applications-api.mdx': {
symbol: 'OAuthApplicationsApi',
declarationHint: 'api/endpoints/OAuthApplicationsApi',
},
'backend/api-keys-api/api-keys-api.mdx': {
symbol: 'APIKeysAPI',
declarationHint: 'api/endpoints/APIKeysApi',
},
'backend/instance-api/instance-api.mdx': {
symbol: 'InstanceAPI',
declarationHint: 'api/endpoints/InstanceApi',
},
};
/** Stable iteration order matches key order in {@link REFERENCE_OBJECT_CONFIG} then {@link BACKEND_API_CONFIG}. */
export const REFERENCE_OBJECTS_LIST = [...Object.keys(REFERENCE_OBJECT_CONFIG), ...Object.keys(BACKEND_API_CONFIG)];
/**
* Primary interface/class documented on each reference object page (used to resolve TypeDoc reflections).
* Includes both {@link REFERENCE_OBJECT_CONFIG} and {@link BACKEND_API_CONFIG} so the router applies the same folder-nesting rule to backend API pages.
*/
export const REFERENCE_OBJECT_PAGE_SYMBOLS = Object.fromEntries(
[...Object.entries(REFERENCE_OBJECT_CONFIG), ...Object.entries(BACKEND_API_CONFIG)].map(([url, { symbol }]) => [
url,
symbol,
]),
);