@atproto/lex-cli 0.9.9 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/bin.js +9 -0
- package/dist/codegen/client.d.ts +1 -1
- package/dist/codegen/client.d.ts.map +1 -1
- package/dist/codegen/client.js +44 -47
- package/dist/codegen/client.js.map +1 -1
- package/dist/codegen/common.d.ts +1 -1
- package/dist/codegen/common.d.ts.map +1 -1
- package/dist/codegen/common.js +14 -20
- package/dist/codegen/common.js.map +1 -1
- package/dist/codegen/lex-gen.js +40 -59
- package/dist/codegen/lex-gen.js.map +1 -1
- package/dist/codegen/server.d.ts +1 -1
- package/dist/codegen/server.d.ts.map +1 -1
- package/dist/codegen/server.js +32 -35
- package/dist/codegen/server.js.map +1 -1
- package/dist/codegen/util.js +8 -15
- package/dist/codegen/util.js.map +1 -1
- package/dist/index.js +24 -62
- package/dist/index.js.map +1 -1
- package/dist/mdgen/index.js +5 -11
- package/dist/mdgen/index.js.map +1 -1
- package/dist/types.js +1 -2
- package/dist/util.d.ts +1 -1
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +31 -42
- package/dist/util.js.map +1 -1
- package/package.json +13 -8
- package/src/codegen/client.ts +4 -4
- package/src/codegen/common.ts +3 -3
- package/src/codegen/lex-gen.ts +4 -4
- package/src/codegen/server.ts +4 -4
- package/src/index.ts +4 -4
- package/src/mdgen/index.ts +1 -1
- package/src/util.ts +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atproto/lex-cli
|
|
2
2
|
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Drop support for Node.js 18 and 20. Node.js 22 is now the minimum supported version. Docker images now use Node.js 24.
|
|
8
|
+
|
|
9
|
+
- [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Convert to pure ESM. All packages now ship `"type": "module"` with ES module output and Node16 module resolution.
|
|
10
|
+
|
|
11
|
+
Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
|
|
12
|
+
|
|
13
|
+
- [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9) Thanks [@devinivy](https://github.com/devinivy)! - **BREAKING:** Generated lexicon code now uses `.js` extensions on relative imports (e.g. `from '../lexicons.js'` instead of `from '../lexicons'`), enabling compatibility with Node16/NodeNext module resolution under ESM. Consumers using classic `node` or `bundler` resolution should be unaffected.
|
|
14
|
+
|
|
15
|
+
- [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705) Thanks [@devinivy](https://github.com/devinivy)! - Build with TypeScript 6.0.
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`f01c59f`](https://github.com/bluesky-social/atproto/commit/f01c59f5bd3f75fb8b47a9eecd4858b84033fb7c), [`c459153`](https://github.com/bluesky-social/atproto/commit/c459153395a30ce89e050892c8fab7dc98e019b9), [`908bece`](https://github.com/bluesky-social/atproto/commit/908bece169258bff5ad121e5eec157d6ded6f705)]:
|
|
20
|
+
- @atproto/lexicon@0.7.0
|
|
21
|
+
- @atproto/syntax@0.6.0
|
|
22
|
+
|
|
3
23
|
## 0.9.9
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/bin.js
ADDED
package/dist/codegen/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type LexiconDoc } from '@atproto/lexicon';
|
|
2
|
-
import { type GeneratedAPI } from '../types';
|
|
2
|
+
import { type GeneratedAPI } from '../types.js';
|
|
3
3
|
export declare function genClientApi(lexiconDocs: LexiconDoc[]): Promise<GeneratedAPI>;
|
|
4
4
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/codegen/client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAkB,KAAK,UAAU,EAAY,MAAM,kBAAkB,CAAA;AAE5E,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/codegen/client.ts"],"names":[],"mappings":"AAMA,OAAO,EAAkB,KAAK,UAAU,EAAY,MAAM,kBAAkB,CAAA;AAE5E,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AA4B/C,wBAAsB,YAAY,CAChC,WAAW,EAAE,UAAU,EAAE,GACxB,OAAO,CAAC,YAAY,CAAC,CAgBvB"}
|
package/dist/codegen/client.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const common_1 = require("./common");
|
|
8
|
-
const lex_gen_1 = require("./lex-gen");
|
|
9
|
-
const util_1 = require("./util");
|
|
1
|
+
import { IndentationText, Project, VariableDeclarationKind, } from 'ts-morph';
|
|
2
|
+
import { Lexicons } from '@atproto/lexicon';
|
|
3
|
+
import { NSID } from '@atproto/syntax';
|
|
4
|
+
import { gen, lexiconsTs, utilTs } from './common.js';
|
|
5
|
+
import { genCommonImports, genImports, genRecord, genUserType, genXrpcInput, genXrpcOutput, genXrpcParams, } from './lex-gen.js';
|
|
6
|
+
import { lexiconsToDefTree, schemasToNsidTokens, toCamelCase, toScreamingSnakeCase, toTitleCase, } from './util.js';
|
|
10
7
|
const ATP_METHODS = {
|
|
11
8
|
list: 'com.atproto.repo.listRecords',
|
|
12
9
|
get: 'com.atproto.repo.getRecord',
|
|
@@ -14,24 +11,24 @@ const ATP_METHODS = {
|
|
|
14
11
|
put: 'com.atproto.repo.putRecord',
|
|
15
12
|
delete: 'com.atproto.repo.deleteRecord',
|
|
16
13
|
};
|
|
17
|
-
async function genClientApi(lexiconDocs) {
|
|
18
|
-
const project = new
|
|
14
|
+
export async function genClientApi(lexiconDocs) {
|
|
15
|
+
const project = new Project({
|
|
19
16
|
useInMemoryFileSystem: true,
|
|
20
|
-
manipulationSettings: { indentationText:
|
|
17
|
+
manipulationSettings: { indentationText: IndentationText.TwoSpaces },
|
|
21
18
|
});
|
|
22
19
|
const api = { files: [] };
|
|
23
|
-
const lexicons = new
|
|
24
|
-
const nsidTree =
|
|
25
|
-
const nsidTokens =
|
|
20
|
+
const lexicons = new Lexicons(lexiconDocs);
|
|
21
|
+
const nsidTree = lexiconsToDefTree(lexiconDocs);
|
|
22
|
+
const nsidTokens = schemasToNsidTokens(lexiconDocs);
|
|
26
23
|
for (const lexiconDoc of lexiconDocs) {
|
|
27
24
|
api.files.push(await lexiconTs(project, lexicons, lexiconDoc));
|
|
28
25
|
}
|
|
29
|
-
api.files.push(await
|
|
30
|
-
api.files.push(await
|
|
26
|
+
api.files.push(await utilTs(project));
|
|
27
|
+
api.files.push(await lexiconsTs(project, lexiconDocs));
|
|
31
28
|
api.files.push(await indexTs(project, lexiconDocs, nsidTree, nsidTokens));
|
|
32
29
|
return api;
|
|
33
30
|
}
|
|
34
|
-
const indexTs = (project, lexiconDocs, nsidTree, nsidTokens) =>
|
|
31
|
+
const indexTs = (project, lexiconDocs, nsidTree, nsidTokens) => gen(project, '/index.ts', async (file) => {
|
|
35
32
|
//= import { XrpcClient, type FetchHandler, type FetchHandlerOptions } from '@atproto/xrpc'
|
|
36
33
|
const xrpcImport = file.addImportDeclaration({
|
|
37
34
|
moduleSpecifier: '@atproto/xrpc',
|
|
@@ -63,10 +60,10 @@ const indexTs = (project, lexiconDocs, nsidTree, nsidTokens) => (0, common_1.gen
|
|
|
63
60
|
const moduleSpecifier = `./types/${lexicon.id.split('.').join('/')}.js`;
|
|
64
61
|
file
|
|
65
62
|
.addImportDeclaration({ moduleSpecifier })
|
|
66
|
-
.setNamespaceImport(
|
|
63
|
+
.setNamespaceImport(toTitleCase(lexicon.id));
|
|
67
64
|
file
|
|
68
65
|
.addExportDeclaration({ moduleSpecifier })
|
|
69
|
-
.setNamespaceExport(
|
|
66
|
+
.setNamespaceExport(toTitleCase(lexicon.id));
|
|
70
67
|
}
|
|
71
68
|
// generate token enums
|
|
72
69
|
for (const nsidAuthority in nsidTokens) {
|
|
@@ -75,13 +72,13 @@ const indexTs = (project, lexiconDocs, nsidTree, nsidTokens) => (0, common_1.gen
|
|
|
75
72
|
// }
|
|
76
73
|
file.addVariableStatement({
|
|
77
74
|
isExported: true,
|
|
78
|
-
declarationKind:
|
|
75
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
79
76
|
declarations: [
|
|
80
77
|
{
|
|
81
|
-
name:
|
|
78
|
+
name: toScreamingSnakeCase(nsidAuthority),
|
|
82
79
|
initializer: [
|
|
83
80
|
'{',
|
|
84
|
-
...nsidTokens[nsidAuthority].map((nsidName) => `${
|
|
81
|
+
...nsidTokens[nsidAuthority].map((nsidName) => `${toTitleCase(nsidName)}: "${nsidAuthority}.${nsidName}",`),
|
|
85
82
|
'}',
|
|
86
83
|
].join('\n'),
|
|
87
84
|
},
|
|
@@ -146,10 +143,10 @@ function genNamespaceCls(file, ns) {
|
|
|
146
143
|
continue;
|
|
147
144
|
}
|
|
148
145
|
//= type: TypeRecord
|
|
149
|
-
const name =
|
|
146
|
+
const name = NSID.parse(userType.nsid).name || '';
|
|
150
147
|
cls.addProperty({
|
|
151
|
-
name:
|
|
152
|
-
type: `${
|
|
148
|
+
name: toCamelCase(name),
|
|
149
|
+
type: `${toTitleCase(userType.nsid)}Record`,
|
|
153
150
|
});
|
|
154
151
|
}
|
|
155
152
|
for (const child of ns.children) {
|
|
@@ -179,8 +176,8 @@ function genNamespaceCls(file, ns) {
|
|
|
179
176
|
...ns.userTypes
|
|
180
177
|
.filter((ut) => ut.def.type === 'record')
|
|
181
178
|
.map((ut) => {
|
|
182
|
-
const name =
|
|
183
|
-
return `this.${
|
|
179
|
+
const name = NSID.parse(ut.nsid).name || '';
|
|
180
|
+
return `this.${toCamelCase(name)} = new ${toTitleCase(ut.nsid)}Record(client)`;
|
|
184
181
|
}),
|
|
185
182
|
],
|
|
186
183
|
});
|
|
@@ -190,8 +187,8 @@ function genNamespaceCls(file, ns) {
|
|
|
190
187
|
continue;
|
|
191
188
|
}
|
|
192
189
|
const isGetReq = userType.def.type === 'query';
|
|
193
|
-
const moduleName =
|
|
194
|
-
const name =
|
|
190
|
+
const moduleName = toTitleCase(userType.nsid);
|
|
191
|
+
const name = toCamelCase(NSID.parse(userType.nsid).name || '');
|
|
195
192
|
const method = cls.addMethod({
|
|
196
193
|
name,
|
|
197
194
|
returnType: `Promise<${moduleName}.Response>`,
|
|
@@ -234,7 +231,7 @@ function genNamespaceCls(file, ns) {
|
|
|
234
231
|
function genRecordCls(file, nsid, lexRecord) {
|
|
235
232
|
//= export class {type}Record {...}
|
|
236
233
|
const cls = file.addClass({
|
|
237
|
-
name: `${
|
|
234
|
+
name: `${toTitleCase(nsid)}Record`,
|
|
238
235
|
isExported: true,
|
|
239
236
|
});
|
|
240
237
|
//= _client: XrpcClient
|
|
@@ -252,7 +249,7 @@ function genRecordCls(file, nsid, lexRecord) {
|
|
|
252
249
|
});
|
|
253
250
|
cons.setBodyText(`this._client = client`);
|
|
254
251
|
// methods
|
|
255
|
-
const typeModule =
|
|
252
|
+
const typeModule = toTitleCase(nsid);
|
|
256
253
|
{
|
|
257
254
|
//= list()
|
|
258
255
|
const method = cls.addMethod({
|
|
@@ -262,7 +259,7 @@ function genRecordCls(file, nsid, lexRecord) {
|
|
|
262
259
|
});
|
|
263
260
|
method.addParameter({
|
|
264
261
|
name: 'params',
|
|
265
|
-
type: `OmitKey<${
|
|
262
|
+
type: `OmitKey<${toTitleCase(ATP_METHODS.list)}.QueryParams, "collection">`,
|
|
266
263
|
});
|
|
267
264
|
method.setBodyText([
|
|
268
265
|
`const res = await this._client.call('${ATP_METHODS.list}', { collection: '${nsid}', ...params })`,
|
|
@@ -278,7 +275,7 @@ function genRecordCls(file, nsid, lexRecord) {
|
|
|
278
275
|
});
|
|
279
276
|
method.addParameter({
|
|
280
277
|
name: 'params',
|
|
281
|
-
type: `OmitKey<${
|
|
278
|
+
type: `OmitKey<${toTitleCase(ATP_METHODS.get)}.QueryParams, "collection">`,
|
|
282
279
|
});
|
|
283
280
|
method.setBodyText([
|
|
284
281
|
`const res = await this._client.call('${ATP_METHODS.get}', { collection: '${nsid}', ...params })`,
|
|
@@ -294,7 +291,7 @@ function genRecordCls(file, nsid, lexRecord) {
|
|
|
294
291
|
});
|
|
295
292
|
method.addParameter({
|
|
296
293
|
name: 'params',
|
|
297
|
-
type: `OmitKey<${
|
|
294
|
+
type: `OmitKey<${toTitleCase(ATP_METHODS.create)}.InputSchema, "collection" | "record">`,
|
|
298
295
|
});
|
|
299
296
|
method.addParameter({
|
|
300
297
|
name: 'record',
|
|
@@ -322,7 +319,7 @@ function genRecordCls(file, nsid, lexRecord) {
|
|
|
322
319
|
});
|
|
323
320
|
method.addParameter({
|
|
324
321
|
name: 'params',
|
|
325
|
-
type: `OmitKey<${
|
|
322
|
+
type: `OmitKey<${toTitleCase(ATP_METHODS.put)}.InputSchema, "collection" | "record">`,
|
|
326
323
|
});
|
|
327
324
|
method.addParameter({
|
|
328
325
|
name: 'record',
|
|
@@ -347,7 +344,7 @@ function genRecordCls(file, nsid, lexRecord) {
|
|
|
347
344
|
});
|
|
348
345
|
method.addParameter({
|
|
349
346
|
name: 'params',
|
|
350
|
-
type: `OmitKey<${
|
|
347
|
+
type: `OmitKey<${toTitleCase(ATP_METHODS.delete)}.InputSchema, "collection">`,
|
|
351
348
|
});
|
|
352
349
|
method.addParameter({
|
|
353
350
|
name: 'headers?',
|
|
@@ -358,7 +355,7 @@ function genRecordCls(file, nsid, lexRecord) {
|
|
|
358
355
|
].join('\n'));
|
|
359
356
|
}
|
|
360
357
|
}
|
|
361
|
-
const lexiconTs = (project, lexicons, lexiconDoc) =>
|
|
358
|
+
const lexiconTs = (project, lexicons, lexiconDoc) => gen(project, `/types/${lexiconDoc.id.split('.').join('/')}.ts`, async (file) => {
|
|
362
359
|
const main = lexiconDoc.defs.main;
|
|
363
360
|
if (main?.type === 'query' ||
|
|
364
361
|
main?.type === 'subscription' ||
|
|
@@ -372,33 +369,33 @@ const lexiconTs = (project, lexicons, lexiconDoc) => (0, common_1.gen)(project,
|
|
|
372
369
|
{ name: 'XRPCError' },
|
|
373
370
|
]);
|
|
374
371
|
}
|
|
375
|
-
|
|
372
|
+
genCommonImports(file, lexiconDoc.id);
|
|
376
373
|
const imports = new Set();
|
|
377
374
|
for (const defId in lexiconDoc.defs) {
|
|
378
375
|
const def = lexiconDoc.defs[defId];
|
|
379
376
|
const lexUri = `${lexiconDoc.id}#${defId}`;
|
|
380
377
|
if (defId === 'main') {
|
|
381
378
|
if (def.type === 'query' || def.type === 'procedure') {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
379
|
+
genXrpcParams(file, lexicons, lexUri, false);
|
|
380
|
+
genXrpcInput(file, imports, lexicons, lexUri, false);
|
|
381
|
+
genXrpcOutput(file, imports, lexicons, lexUri);
|
|
385
382
|
genClientXrpcCommon(file, lexicons, lexUri);
|
|
386
383
|
}
|
|
387
384
|
else if (def.type === 'subscription') {
|
|
388
385
|
continue;
|
|
389
386
|
}
|
|
390
387
|
else if (def.type === 'record') {
|
|
391
|
-
|
|
388
|
+
genRecord(file, imports, lexicons, lexUri);
|
|
392
389
|
}
|
|
393
390
|
else {
|
|
394
|
-
|
|
391
|
+
genUserType(file, imports, lexicons, lexUri);
|
|
395
392
|
}
|
|
396
393
|
}
|
|
397
394
|
else {
|
|
398
|
-
|
|
395
|
+
genUserType(file, imports, lexicons, lexUri);
|
|
399
396
|
}
|
|
400
397
|
}
|
|
401
|
-
|
|
398
|
+
genImports(file, imports, lexiconDoc.id);
|
|
402
399
|
});
|
|
403
400
|
function genClientXrpcCommon(file, lexicons, lexUri) {
|
|
404
401
|
const def = lexicons.getDefOrThrow(lexUri, ['query', 'procedure']);
|
|
@@ -446,7 +443,7 @@ function genClientXrpcCommon(file, lexicons, lexUri) {
|
|
|
446
443
|
// export class {errcode}Error {...}
|
|
447
444
|
const customErrors = [];
|
|
448
445
|
for (const error of def.errors || []) {
|
|
449
|
-
let name =
|
|
446
|
+
let name = toTitleCase(error.name);
|
|
450
447
|
if (!name.endsWith('Error'))
|
|
451
448
|
name += 'Error';
|
|
452
449
|
const errCls = file.addClass({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/codegen/client.ts"],"names":[],"mappings":";;AAoCA,oCAkBC;AAtDD,uCAKiB;AACjB,8CAA4E;AAC5E,4CAAsC;AAEtC,qCAAkD;AAClD,uCAQkB;AAClB,iCAOe;AAEf,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,8BAA8B;IACpC,GAAG,EAAE,4BAA4B;IACjC,MAAM,EAAE,+BAA+B;IACvC,GAAG,EAAE,4BAA4B;IACjC,MAAM,EAAE,+BAA+B;CACxC,CAAA;AAEM,KAAK,UAAU,YAAY,CAChC,WAAyB;IAEzB,MAAM,OAAO,GAAG,IAAI,kBAAO,CAAC;QAC1B,qBAAqB,EAAE,IAAI;QAC3B,oBAAoB,EAAE,EAAE,eAAe,EAAE,0BAAe,CAAC,SAAS,EAAE;KACrE,CAAC,CAAA;IACF,MAAM,GAAG,GAAiB,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IACvC,MAAM,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BAA+B;gBAC/B,GAAG,YAAY,CAAC,GAAG,CACjB,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,GAAG,CAAC,IAAI,iBAAiB,GAAG,CAAC,GAAG,KAAK,CACnE;gBACD,GAAG;gBACH,UAAU;aACX;YACH,CAAC,CAAC,CAAC,UAAU,CAAC;KACjB,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n IndentationText,\n Project,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph'\nimport { type LexRecord, type LexiconDoc, Lexicons } from '@atproto/lexicon'\nimport { NSID } from '@atproto/syntax'\nimport { type GeneratedAPI } from '../types'\nimport { gen, lexiconsTs, utilTs } from './common'\nimport {\n genCommonImports,\n genImports,\n genRecord,\n genUserType,\n genXrpcInput,\n genXrpcOutput,\n genXrpcParams,\n} from './lex-gen'\nimport {\n type DefTreeNode,\n lexiconsToDefTree,\n schemasToNsidTokens,\n toCamelCase,\n toScreamingSnakeCase,\n toTitleCase,\n} from './util'\n\nconst ATP_METHODS = {\n list: 'com.atproto.repo.listRecords',\n get: 'com.atproto.repo.getRecord',\n create: 'com.atproto.repo.createRecord',\n put: 'com.atproto.repo.putRecord',\n delete: 'com.atproto.repo.deleteRecord',\n}\n\nexport async function genClientApi(\n lexiconDocs: LexiconDoc[],\n): Promise<GeneratedAPI> {\n const project = new Project({\n useInMemoryFileSystem: true,\n manipulationSettings: { indentationText: IndentationText.TwoSpaces },\n })\n const api: GeneratedAPI = { files: [] }\n const lexicons = new Lexicons(lexiconDocs)\n const nsidTree = lexiconsToDefTree(lexiconDocs)\n const nsidTokens = schemasToNsidTokens(lexiconDocs)\n for (const lexiconDoc of lexiconDocs) {\n api.files.push(await lexiconTs(project, lexicons, lexiconDoc))\n }\n api.files.push(await utilTs(project))\n api.files.push(await lexiconsTs(project, lexiconDocs))\n api.files.push(await indexTs(project, lexiconDocs, nsidTree, nsidTokens))\n return api\n}\n\nconst indexTs = (\n project: Project,\n lexiconDocs: LexiconDoc[],\n nsidTree: DefTreeNode[],\n nsidTokens: Record<string, string[]>,\n) =>\n gen(project, '/index.ts', async (file) => {\n //= import { XrpcClient, type FetchHandler, type FetchHandlerOptions } from '@atproto/xrpc'\n const xrpcImport = file.addImportDeclaration({\n moduleSpecifier: '@atproto/xrpc',\n })\n xrpcImport.addNamedImports([\n { name: 'XrpcClient' },\n { name: 'FetchHandler', isTypeOnly: true },\n { name: 'FetchHandlerOptions', isTypeOnly: true },\n ])\n //= import {schemas} from './lexicons.js'\n file\n .addImportDeclaration({ moduleSpecifier: './lexicons.js' })\n .addNamedImports([{ name: 'schemas' }])\n //= import {CID} from 'multiformats/cid'\n file\n .addImportDeclaration({\n moduleSpecifier: 'multiformats/cid',\n })\n .addNamedImports([{ name: 'CID' }])\n\n //= import { type OmitKey, type Un$Typed } from './util.js'\n file\n .addImportDeclaration({ moduleSpecifier: `./util.js` })\n .addNamedImports([\n { name: 'OmitKey', isTypeOnly: true },\n { name: 'Un$Typed', isTypeOnly: true },\n ])\n\n // generate type imports and re-exports\n for (const lexicon of lexiconDocs) {\n const moduleSpecifier = `./types/${lexicon.id.split('.').join('/')}.js`\n file\n .addImportDeclaration({ moduleSpecifier })\n .setNamespaceImport(toTitleCase(lexicon.id))\n file\n .addExportDeclaration({ moduleSpecifier })\n .setNamespaceExport(toTitleCase(lexicon.id))\n }\n\n // generate token enums\n for (const nsidAuthority in nsidTokens) {\n // export const {THE_AUTHORITY} = {\n // {Name}: \"{authority.the.name}\"\n // }\n file.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: toScreamingSnakeCase(nsidAuthority),\n initializer: [\n '{',\n ...nsidTokens[nsidAuthority].map(\n (nsidName) =>\n `${toTitleCase(nsidName)}: \"${nsidAuthority}.${nsidName}\",`,\n ),\n '}',\n ].join('\\n'),\n },\n ],\n })\n }\n\n //= export class AtpBaseClient {...}\n const clientCls = file.addClass({\n name: 'AtpBaseClient',\n isExported: true,\n extends: 'XrpcClient',\n })\n\n for (const ns of nsidTree) {\n //= ns: NS\n clientCls.addProperty({\n name: ns.propName,\n type: ns.className,\n })\n }\n\n //= constructor (options: FetchHandler | FetchHandlerOptions) {\n //= super(options, schemas)\n //= {namespace declarations}\n //= }\n clientCls.addConstructor({\n parameters: [\n { name: 'options', type: 'FetchHandler | FetchHandlerOptions' },\n ],\n statements: [\n 'super(options, schemas)',\n ...nsidTree.map(\n (ns) => `this.${ns.propName} = new ${ns.className}(this)`,\n ),\n ],\n })\n\n //= /** @deprecated use `this` instead */\n //= get xrpc(): XrpcClient {\n //= return this\n //= }\n clientCls\n .addGetAccessor({\n name: 'xrpc',\n returnType: 'XrpcClient',\n statements: ['return this'],\n })\n .addJsDoc('@deprecated use `this` instead')\n\n // generate classes for the schemas\n for (const ns of nsidTree) {\n genNamespaceCls(file, ns)\n }\n })\n\nfunction genNamespaceCls(file: SourceFile, ns: DefTreeNode) {\n //= export class {ns}NS {...}\n const cls = file.addClass({\n name: ns.className,\n isExported: true,\n })\n //= _client: XrpcClient\n cls.addProperty({\n name: '_client',\n type: 'XrpcClient',\n })\n\n for (const userType of ns.userTypes) {\n if (userType.def.type !== 'record') {\n continue\n }\n //= type: TypeRecord\n const name = NSID.parse(userType.nsid).name || ''\n cls.addProperty({\n name: toCamelCase(name),\n type: `${toTitleCase(userType.nsid)}Record`,\n })\n }\n\n for (const child of ns.children) {\n //= child: ChildNS\n cls.addProperty({\n name: child.propName,\n type: child.className,\n })\n\n // recurse\n genNamespaceCls(file, child)\n }\n\n //= constructor(public client: XrpcClient) {\n //= this._client = client\n //= {child namespace prop declarations}\n //= {record prop declarations}\n //= }\n cls.addConstructor({\n parameters: [\n {\n name: 'client',\n type: 'XrpcClient',\n },\n ],\n statements: [\n `this._client = client`,\n ...ns.children.map(\n (ns) => `this.${ns.propName} = new ${ns.className}(client)`,\n ),\n ...ns.userTypes\n .filter((ut) => ut.def.type === 'record')\n .map((ut) => {\n const name = NSID.parse(ut.nsid).name || ''\n return `this.${toCamelCase(name)} = new ${toTitleCase(\n ut.nsid,\n )}Record(client)`\n }),\n ],\n })\n\n // methods\n for (const userType of ns.userTypes) {\n if (userType.def.type !== 'query' && userType.def.type !== 'procedure') {\n continue\n }\n const isGetReq = userType.def.type === 'query'\n const moduleName = toTitleCase(userType.nsid)\n const name = toCamelCase(NSID.parse(userType.nsid).name || '')\n const method = cls.addMethod({\n name,\n returnType: `Promise<${moduleName}.Response>`,\n })\n if (isGetReq) {\n method.addParameter({\n name: 'params?',\n type: `${moduleName}.QueryParams`,\n })\n } else if (userType.def.type === 'procedure') {\n method.addParameter({\n name: 'data?',\n type: `${moduleName}.InputSchema`,\n })\n }\n method.addParameter({\n name: 'opts?',\n type: `${moduleName}.CallOptions`,\n })\n method.setBodyText(\n [\n `return this._client`,\n isGetReq\n ? `.call('${userType.nsid}', params, undefined, opts)`\n : `.call('${userType.nsid}', opts?.qp, data, opts)`,\n userType.def.errors?.length\n ? // Only add a catch block if there are custom errors\n ` .catch((e) => { throw ${moduleName}.toKnownErr(e) })`\n : '',\n ].join('\\n'),\n )\n }\n\n // record api classes\n for (const userType of ns.userTypes) {\n if (userType.def.type !== 'record') {\n continue\n }\n genRecordCls(file, userType.nsid, userType.def)\n }\n}\n\nfunction genRecordCls(file: SourceFile, nsid: string, lexRecord: LexRecord) {\n //= export class {type}Record {...}\n const cls = file.addClass({\n name: `${toTitleCase(nsid)}Record`,\n isExported: true,\n })\n //= _client: XrpcClient\n cls.addProperty({\n name: '_client',\n type: 'XrpcClient',\n })\n\n //= constructor(client: XrpcClient) {\n //= this._client = client\n //= }\n const cons = cls.addConstructor()\n cons.addParameter({\n name: 'client',\n type: 'XrpcClient',\n })\n cons.setBodyText(`this._client = client`)\n\n // methods\n const typeModule = toTitleCase(nsid)\n {\n //= list()\n const method = cls.addMethod({\n isAsync: true,\n name: 'list',\n returnType: `Promise<{cursor?: string, records: ({uri: string, value: ${typeModule}.Record})[]}>`,\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(ATP_METHODS.list)}.QueryParams, \"collection\">`,\n })\n method.setBodyText(\n [\n `const res = await this._client.call('${ATP_METHODS.list}', { collection: '${nsid}', ...params })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= get()\n const method = cls.addMethod({\n isAsync: true,\n name: 'get',\n returnType: `Promise<{uri: string, cid: string, value: ${typeModule}.Record}>`,\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(ATP_METHODS.get)}.QueryParams, \"collection\">`,\n })\n method.setBodyText(\n [\n `const res = await this._client.call('${ATP_METHODS.get}', { collection: '${nsid}', ...params })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= create()\n const method = cls.addMethod({\n isAsync: true,\n name: 'create',\n returnType: 'Promise<{uri: string, cid: string}>',\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(\n ATP_METHODS.create,\n )}.InputSchema, \"collection\" | \"record\">`,\n })\n method.addParameter({\n name: 'record',\n type: `Un$Typed<${typeModule}.Record>`,\n })\n method.addParameter({\n name: 'headers?',\n type: `Record<string, string>`,\n })\n const maybeRkeyPart = lexRecord.key?.startsWith('literal:')\n ? `rkey: '${lexRecord.key.replace('literal:', '')}', `\n : ''\n method.setBodyText(\n [\n `const collection = '${nsid}'`,\n `const res = await this._client.call('${ATP_METHODS.create}', undefined, { collection, ${maybeRkeyPart}...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= put()\n const method = cls.addMethod({\n isAsync: true,\n name: 'put',\n returnType: 'Promise<{uri: string, cid: string}>',\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(ATP_METHODS.put)}.InputSchema, \"collection\" | \"record\">`,\n })\n method.addParameter({\n name: 'record',\n type: `Un$Typed<${typeModule}.Record>`,\n })\n method.addParameter({\n name: 'headers?',\n type: `Record<string, string>`,\n })\n method.setBodyText(\n [\n `const collection = '${nsid}'`,\n `const res = await this._client.call('${ATP_METHODS.put}', undefined, { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= delete()\n const method = cls.addMethod({\n isAsync: true,\n name: 'delete',\n returnType: 'Promise<void>',\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(\n ATP_METHODS.delete,\n )}.InputSchema, \"collection\">`,\n })\n method.addParameter({\n name: 'headers?',\n type: `Record<string, string>`,\n })\n\n method.setBodyText(\n [\n `await this._client.call('${ATP_METHODS.delete}', undefined, { collection: '${nsid}', ...params }, { headers })`,\n ].join('\\n'),\n )\n }\n}\n\nconst lexiconTs = (project, lexicons: Lexicons, lexiconDoc: LexiconDoc) =>\n gen(\n project,\n `/types/${lexiconDoc.id.split('.').join('/')}.ts`,\n async (file) => {\n const main = lexiconDoc.defs.main\n if (\n main?.type === 'query' ||\n main?.type === 'subscription' ||\n main?.type === 'procedure'\n ) {\n //= import {HeadersMap, XRPCError} from '@atproto/xrpc'\n const xrpcImport = file.addImportDeclaration({\n moduleSpecifier: '@atproto/xrpc',\n })\n xrpcImport.addNamedImports([\n { name: 'HeadersMap' },\n { name: 'XRPCError' },\n ])\n }\n\n genCommonImports(file, lexiconDoc.id)\n\n const imports: Set<string> = new Set()\n for (const defId in lexiconDoc.defs) {\n const def = lexiconDoc.defs[defId]\n const lexUri = `${lexiconDoc.id}#${defId}`\n if (defId === 'main') {\n if (def.type === 'query' || def.type === 'procedure') {\n genXrpcParams(file, lexicons, lexUri, false)\n genXrpcInput(file, imports, lexicons, lexUri, false)\n genXrpcOutput(file, imports, lexicons, lexUri)\n genClientXrpcCommon(file, lexicons, lexUri)\n } else if (def.type === 'subscription') {\n continue\n } else if (def.type === 'record') {\n genRecord(file, imports, lexicons, lexUri)\n } else {\n genUserType(file, imports, lexicons, lexUri)\n }\n } else {\n genUserType(file, imports, lexicons, lexUri)\n }\n }\n genImports(file, imports, lexiconDoc.id)\n },\n )\n\nfunction genClientXrpcCommon(\n file: SourceFile,\n lexicons: Lexicons,\n lexUri: string,\n) {\n const def = lexicons.getDefOrThrow(lexUri, ['query', 'procedure'])\n\n //= export interface CallOptions {...}\n const opts = file.addInterface({\n name: 'CallOptions',\n isExported: true,\n })\n opts.addProperty({ name: 'signal?', type: 'AbortSignal' })\n opts.addProperty({ name: 'headers?', type: 'HeadersMap' })\n if (def.type === 'procedure') {\n opts.addProperty({ name: 'qp?', type: 'QueryParams' })\n }\n if (def.type === 'procedure' && def.input) {\n let encodingType = 'string'\n if (def.input.encoding !== '*/*') {\n encodingType = def.input.encoding\n .split(',')\n .map((v) => `'${v.trim()}'`)\n .join(' | ')\n }\n opts.addProperty({\n name: 'encoding?',\n type: encodingType,\n })\n }\n\n // export interface Response {...}\n const res = file.addInterface({\n name: 'Response',\n isExported: true,\n })\n res.addProperty({ name: 'success', type: 'boolean' })\n res.addProperty({ name: 'headers', type: 'HeadersMap' })\n if (def.output?.schema) {\n if (def.output.encoding?.includes(',')) {\n res.addProperty({ name: 'data', type: 'OutputSchema | Uint8Array' })\n } else {\n res.addProperty({ name: 'data', type: 'OutputSchema' })\n }\n } else if (def.output?.encoding) {\n res.addProperty({ name: 'data', type: 'Uint8Array' })\n }\n\n // export class {errcode}Error {...}\n const customErrors: { name: string; cls: string }[] = []\n for (const error of def.errors || []) {\n let name = toTitleCase(error.name)\n if (!name.endsWith('Error')) name += 'Error'\n const errCls = file.addClass({\n name,\n extends: 'XRPCError',\n isExported: true,\n })\n errCls.addConstructor({\n parameters: [{ name: 'src', type: 'XRPCError' }],\n statements: [\n 'super(src.status, src.error, src.message, src.headers, { cause: src })',\n ],\n })\n\n customErrors.push({ name: error.name, cls: name })\n }\n\n // export function toKnownErr(err: any) {...}\n file.addFunction({\n name: 'toKnownErr',\n isExported: true,\n parameters: [{ name: 'e', type: 'any' }],\n statements: customErrors.length\n ? [\n 'if (e instanceof XRPCError) {',\n ...customErrors.map(\n (err) => `if (e.error === '${err.name}') return new ${err.cls}(e)`,\n ),\n '}',\n 'return e',\n ]\n : ['return e'],\n })\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/codegen/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,OAAO,EAEP,uBAAuB,GACxB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAmC,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,WAAW,EACX,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,cAAc,CAAA;AACrB,OAAO,EAEL,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,WAAW,GACZ,MAAM,WAAW,CAAA;AAElB,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,8BAA8B;IACpC,GAAG,EAAE,4BAA4B;IACjC,MAAM,EAAE,+BAA+B;IACvC,GAAG,EAAE,4BAA4B;IACjC,MAAM,EAAE,+BAA+B;CACxC,CAAA;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,WAAyB;IAEzB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC;QAC1B,qBAAqB,EAAE,IAAI;QAC3B,oBAAoB,EAAE,EAAE,eAAe,EAAE,eAAe,CAAC,SAAS,EAAE;KACrE,CAAC,CAAA;IACF,MAAM,GAAG,GAAiB,EAAE,KAAK,EAAE,EAAE,EAAE,CAAA;IACvC,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAA;IAC1C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAA;IAC/C,MAAM,UAAU,GAAG,mBAAmB,CAAC,WAAW,CAAC,CAAA;IACnD,K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,IAAI,EAAE,EAAE,CAAC;QACrC,IAAI,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QAClC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC;YAAE,IAAI,IAAI,OAAO,CAAA;QAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC3B,IAAI;YACJ,OAAO,EAAE,WAAW;YACpB,UAAU,EAAE,IAAI;SACjB,CAAC,CAAA;QACF,MAAM,CAAC,cAAc,CAAC;YACpB,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC;YAChD,UAAU,EAAE;gBACV,wEAAwE;aACzE;SACF,CAAC,CAAA;QAEF,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAA;IACpD,CAAC;IAED,6CAA6C;IAC7C,IAAI,CAAC,WAAW,CAAC;QACf,IAAI,EAAE,YAAY;QAClB,UAAU,EAAE,IAAI;QAChB,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;QACxC,UAAU,EAAE,YAAY,CAAC,MAAM;YAC7B,CAAC,CAAC;gBACE,+BAA+B;gBAC/B,GAAG,YAAY,CAAC,GAAG,CACjB,CAAC,GAAG,EAAE,EAAE,CAAC,oBAAoB,GAAG,CAAC,IAAI,iBAAiB,GAAG,CAAC,GAAG,KAAK,CACnE;gBACD,GAAG;gBACH,UAAU;aACX;YACH,CAAC,CAAC,CAAC,UAAU,CAAC;KACjB,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import {\n IndentationText,\n Project,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph'\nimport { type LexRecord, type LexiconDoc, Lexicons } from '@atproto/lexicon'\nimport { NSID } from '@atproto/syntax'\nimport { type GeneratedAPI } from '../types.js'\nimport { gen, lexiconsTs, utilTs } from './common.js'\nimport {\n genCommonImports,\n genImports,\n genRecord,\n genUserType,\n genXrpcInput,\n genXrpcOutput,\n genXrpcParams,\n} from './lex-gen.js'\nimport {\n type DefTreeNode,\n lexiconsToDefTree,\n schemasToNsidTokens,\n toCamelCase,\n toScreamingSnakeCase,\n toTitleCase,\n} from './util.js'\n\nconst ATP_METHODS = {\n list: 'com.atproto.repo.listRecords',\n get: 'com.atproto.repo.getRecord',\n create: 'com.atproto.repo.createRecord',\n put: 'com.atproto.repo.putRecord',\n delete: 'com.atproto.repo.deleteRecord',\n}\n\nexport async function genClientApi(\n lexiconDocs: LexiconDoc[],\n): Promise<GeneratedAPI> {\n const project = new Project({\n useInMemoryFileSystem: true,\n manipulationSettings: { indentationText: IndentationText.TwoSpaces },\n })\n const api: GeneratedAPI = { files: [] }\n const lexicons = new Lexicons(lexiconDocs)\n const nsidTree = lexiconsToDefTree(lexiconDocs)\n const nsidTokens = schemasToNsidTokens(lexiconDocs)\n for (const lexiconDoc of lexiconDocs) {\n api.files.push(await lexiconTs(project, lexicons, lexiconDoc))\n }\n api.files.push(await utilTs(project))\n api.files.push(await lexiconsTs(project, lexiconDocs))\n api.files.push(await indexTs(project, lexiconDocs, nsidTree, nsidTokens))\n return api\n}\n\nconst indexTs = (\n project: Project,\n lexiconDocs: LexiconDoc[],\n nsidTree: DefTreeNode[],\n nsidTokens: Record<string, string[]>,\n) =>\n gen(project, '/index.ts', async (file) => {\n //= import { XrpcClient, type FetchHandler, type FetchHandlerOptions } from '@atproto/xrpc'\n const xrpcImport = file.addImportDeclaration({\n moduleSpecifier: '@atproto/xrpc',\n })\n xrpcImport.addNamedImports([\n { name: 'XrpcClient' },\n { name: 'FetchHandler', isTypeOnly: true },\n { name: 'FetchHandlerOptions', isTypeOnly: true },\n ])\n //= import {schemas} from './lexicons.js'\n file\n .addImportDeclaration({ moduleSpecifier: './lexicons.js' })\n .addNamedImports([{ name: 'schemas' }])\n //= import {CID} from 'multiformats/cid'\n file\n .addImportDeclaration({\n moduleSpecifier: 'multiformats/cid',\n })\n .addNamedImports([{ name: 'CID' }])\n\n //= import { type OmitKey, type Un$Typed } from './util.js'\n file\n .addImportDeclaration({ moduleSpecifier: `./util.js` })\n .addNamedImports([\n { name: 'OmitKey', isTypeOnly: true },\n { name: 'Un$Typed', isTypeOnly: true },\n ])\n\n // generate type imports and re-exports\n for (const lexicon of lexiconDocs) {\n const moduleSpecifier = `./types/${lexicon.id.split('.').join('/')}.js`\n file\n .addImportDeclaration({ moduleSpecifier })\n .setNamespaceImport(toTitleCase(lexicon.id))\n file\n .addExportDeclaration({ moduleSpecifier })\n .setNamespaceExport(toTitleCase(lexicon.id))\n }\n\n // generate token enums\n for (const nsidAuthority in nsidTokens) {\n // export const {THE_AUTHORITY} = {\n // {Name}: \"{authority.the.name}\"\n // }\n file.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: toScreamingSnakeCase(nsidAuthority),\n initializer: [\n '{',\n ...nsidTokens[nsidAuthority].map(\n (nsidName) =>\n `${toTitleCase(nsidName)}: \"${nsidAuthority}.${nsidName}\",`,\n ),\n '}',\n ].join('\\n'),\n },\n ],\n })\n }\n\n //= export class AtpBaseClient {...}\n const clientCls = file.addClass({\n name: 'AtpBaseClient',\n isExported: true,\n extends: 'XrpcClient',\n })\n\n for (const ns of nsidTree) {\n //= ns: NS\n clientCls.addProperty({\n name: ns.propName,\n type: ns.className,\n })\n }\n\n //= constructor (options: FetchHandler | FetchHandlerOptions) {\n //= super(options, schemas)\n //= {namespace declarations}\n //= }\n clientCls.addConstructor({\n parameters: [\n { name: 'options', type: 'FetchHandler | FetchHandlerOptions' },\n ],\n statements: [\n 'super(options, schemas)',\n ...nsidTree.map(\n (ns) => `this.${ns.propName} = new ${ns.className}(this)`,\n ),\n ],\n })\n\n //= /** @deprecated use `this` instead */\n //= get xrpc(): XrpcClient {\n //= return this\n //= }\n clientCls\n .addGetAccessor({\n name: 'xrpc',\n returnType: 'XrpcClient',\n statements: ['return this'],\n })\n .addJsDoc('@deprecated use `this` instead')\n\n // generate classes for the schemas\n for (const ns of nsidTree) {\n genNamespaceCls(file, ns)\n }\n })\n\nfunction genNamespaceCls(file: SourceFile, ns: DefTreeNode) {\n //= export class {ns}NS {...}\n const cls = file.addClass({\n name: ns.className,\n isExported: true,\n })\n //= _client: XrpcClient\n cls.addProperty({\n name: '_client',\n type: 'XrpcClient',\n })\n\n for (const userType of ns.userTypes) {\n if (userType.def.type !== 'record') {\n continue\n }\n //= type: TypeRecord\n const name = NSID.parse(userType.nsid).name || ''\n cls.addProperty({\n name: toCamelCase(name),\n type: `${toTitleCase(userType.nsid)}Record`,\n })\n }\n\n for (const child of ns.children) {\n //= child: ChildNS\n cls.addProperty({\n name: child.propName,\n type: child.className,\n })\n\n // recurse\n genNamespaceCls(file, child)\n }\n\n //= constructor(public client: XrpcClient) {\n //= this._client = client\n //= {child namespace prop declarations}\n //= {record prop declarations}\n //= }\n cls.addConstructor({\n parameters: [\n {\n name: 'client',\n type: 'XrpcClient',\n },\n ],\n statements: [\n `this._client = client`,\n ...ns.children.map(\n (ns) => `this.${ns.propName} = new ${ns.className}(client)`,\n ),\n ...ns.userTypes\n .filter((ut) => ut.def.type === 'record')\n .map((ut) => {\n const name = NSID.parse(ut.nsid).name || ''\n return `this.${toCamelCase(name)} = new ${toTitleCase(\n ut.nsid,\n )}Record(client)`\n }),\n ],\n })\n\n // methods\n for (const userType of ns.userTypes) {\n if (userType.def.type !== 'query' && userType.def.type !== 'procedure') {\n continue\n }\n const isGetReq = userType.def.type === 'query'\n const moduleName = toTitleCase(userType.nsid)\n const name = toCamelCase(NSID.parse(userType.nsid).name || '')\n const method = cls.addMethod({\n name,\n returnType: `Promise<${moduleName}.Response>`,\n })\n if (isGetReq) {\n method.addParameter({\n name: 'params?',\n type: `${moduleName}.QueryParams`,\n })\n } else if (userType.def.type === 'procedure') {\n method.addParameter({\n name: 'data?',\n type: `${moduleName}.InputSchema`,\n })\n }\n method.addParameter({\n name: 'opts?',\n type: `${moduleName}.CallOptions`,\n })\n method.setBodyText(\n [\n `return this._client`,\n isGetReq\n ? `.call('${userType.nsid}', params, undefined, opts)`\n : `.call('${userType.nsid}', opts?.qp, data, opts)`,\n userType.def.errors?.length\n ? // Only add a catch block if there are custom errors\n ` .catch((e) => { throw ${moduleName}.toKnownErr(e) })`\n : '',\n ].join('\\n'),\n )\n }\n\n // record api classes\n for (const userType of ns.userTypes) {\n if (userType.def.type !== 'record') {\n continue\n }\n genRecordCls(file, userType.nsid, userType.def)\n }\n}\n\nfunction genRecordCls(file: SourceFile, nsid: string, lexRecord: LexRecord) {\n //= export class {type}Record {...}\n const cls = file.addClass({\n name: `${toTitleCase(nsid)}Record`,\n isExported: true,\n })\n //= _client: XrpcClient\n cls.addProperty({\n name: '_client',\n type: 'XrpcClient',\n })\n\n //= constructor(client: XrpcClient) {\n //= this._client = client\n //= }\n const cons = cls.addConstructor()\n cons.addParameter({\n name: 'client',\n type: 'XrpcClient',\n })\n cons.setBodyText(`this._client = client`)\n\n // methods\n const typeModule = toTitleCase(nsid)\n {\n //= list()\n const method = cls.addMethod({\n isAsync: true,\n name: 'list',\n returnType: `Promise<{cursor?: string, records: ({uri: string, value: ${typeModule}.Record})[]}>`,\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(ATP_METHODS.list)}.QueryParams, \"collection\">`,\n })\n method.setBodyText(\n [\n `const res = await this._client.call('${ATP_METHODS.list}', { collection: '${nsid}', ...params })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= get()\n const method = cls.addMethod({\n isAsync: true,\n name: 'get',\n returnType: `Promise<{uri: string, cid: string, value: ${typeModule}.Record}>`,\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(ATP_METHODS.get)}.QueryParams, \"collection\">`,\n })\n method.setBodyText(\n [\n `const res = await this._client.call('${ATP_METHODS.get}', { collection: '${nsid}', ...params })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= create()\n const method = cls.addMethod({\n isAsync: true,\n name: 'create',\n returnType: 'Promise<{uri: string, cid: string}>',\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(\n ATP_METHODS.create,\n )}.InputSchema, \"collection\" | \"record\">`,\n })\n method.addParameter({\n name: 'record',\n type: `Un$Typed<${typeModule}.Record>`,\n })\n method.addParameter({\n name: 'headers?',\n type: `Record<string, string>`,\n })\n const maybeRkeyPart = lexRecord.key?.startsWith('literal:')\n ? `rkey: '${lexRecord.key.replace('literal:', '')}', `\n : ''\n method.setBodyText(\n [\n `const collection = '${nsid}'`,\n `const res = await this._client.call('${ATP_METHODS.create}', undefined, { collection, ${maybeRkeyPart}...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= put()\n const method = cls.addMethod({\n isAsync: true,\n name: 'put',\n returnType: 'Promise<{uri: string, cid: string}>',\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(ATP_METHODS.put)}.InputSchema, \"collection\" | \"record\">`,\n })\n method.addParameter({\n name: 'record',\n type: `Un$Typed<${typeModule}.Record>`,\n })\n method.addParameter({\n name: 'headers?',\n type: `Record<string, string>`,\n })\n method.setBodyText(\n [\n `const collection = '${nsid}'`,\n `const res = await this._client.call('${ATP_METHODS.put}', undefined, { collection, ...params, record: { ...record, $type: collection } }, { encoding: 'application/json', headers })`,\n `return res.data`,\n ].join('\\n'),\n )\n }\n {\n //= delete()\n const method = cls.addMethod({\n isAsync: true,\n name: 'delete',\n returnType: 'Promise<void>',\n })\n method.addParameter({\n name: 'params',\n type: `OmitKey<${toTitleCase(\n ATP_METHODS.delete,\n )}.InputSchema, \"collection\">`,\n })\n method.addParameter({\n name: 'headers?',\n type: `Record<string, string>`,\n })\n\n method.setBodyText(\n [\n `await this._client.call('${ATP_METHODS.delete}', undefined, { collection: '${nsid}', ...params }, { headers })`,\n ].join('\\n'),\n )\n }\n}\n\nconst lexiconTs = (project, lexicons: Lexicons, lexiconDoc: LexiconDoc) =>\n gen(\n project,\n `/types/${lexiconDoc.id.split('.').join('/')}.ts`,\n async (file) => {\n const main = lexiconDoc.defs.main\n if (\n main?.type === 'query' ||\n main?.type === 'subscription' ||\n main?.type === 'procedure'\n ) {\n //= import {HeadersMap, XRPCError} from '@atproto/xrpc'\n const xrpcImport = file.addImportDeclaration({\n moduleSpecifier: '@atproto/xrpc',\n })\n xrpcImport.addNamedImports([\n { name: 'HeadersMap' },\n { name: 'XRPCError' },\n ])\n }\n\n genCommonImports(file, lexiconDoc.id)\n\n const imports: Set<string> = new Set()\n for (const defId in lexiconDoc.defs) {\n const def = lexiconDoc.defs[defId]\n const lexUri = `${lexiconDoc.id}#${defId}`\n if (defId === 'main') {\n if (def.type === 'query' || def.type === 'procedure') {\n genXrpcParams(file, lexicons, lexUri, false)\n genXrpcInput(file, imports, lexicons, lexUri, false)\n genXrpcOutput(file, imports, lexicons, lexUri)\n genClientXrpcCommon(file, lexicons, lexUri)\n } else if (def.type === 'subscription') {\n continue\n } else if (def.type === 'record') {\n genRecord(file, imports, lexicons, lexUri)\n } else {\n genUserType(file, imports, lexicons, lexUri)\n }\n } else {\n genUserType(file, imports, lexicons, lexUri)\n }\n }\n genImports(file, imports, lexiconDoc.id)\n },\n )\n\nfunction genClientXrpcCommon(\n file: SourceFile,\n lexicons: Lexicons,\n lexUri: string,\n) {\n const def = lexicons.getDefOrThrow(lexUri, ['query', 'procedure'])\n\n //= export interface CallOptions {...}\n const opts = file.addInterface({\n name: 'CallOptions',\n isExported: true,\n })\n opts.addProperty({ name: 'signal?', type: 'AbortSignal' })\n opts.addProperty({ name: 'headers?', type: 'HeadersMap' })\n if (def.type === 'procedure') {\n opts.addProperty({ name: 'qp?', type: 'QueryParams' })\n }\n if (def.type === 'procedure' && def.input) {\n let encodingType = 'string'\n if (def.input.encoding !== '*/*') {\n encodingType = def.input.encoding\n .split(',')\n .map((v) => `'${v.trim()}'`)\n .join(' | ')\n }\n opts.addProperty({\n name: 'encoding?',\n type: encodingType,\n })\n }\n\n // export interface Response {...}\n const res = file.addInterface({\n name: 'Response',\n isExported: true,\n })\n res.addProperty({ name: 'success', type: 'boolean' })\n res.addProperty({ name: 'headers', type: 'HeadersMap' })\n if (def.output?.schema) {\n if (def.output.encoding?.includes(',')) {\n res.addProperty({ name: 'data', type: 'OutputSchema | Uint8Array' })\n } else {\n res.addProperty({ name: 'data', type: 'OutputSchema' })\n }\n } else if (def.output?.encoding) {\n res.addProperty({ name: 'data', type: 'Uint8Array' })\n }\n\n // export class {errcode}Error {...}\n const customErrors: { name: string; cls: string }[] = []\n for (const error of def.errors || []) {\n let name = toTitleCase(error.name)\n if (!name.endsWith('Error')) name += 'Error'\n const errCls = file.addClass({\n name,\n extends: 'XRPCError',\n isExported: true,\n })\n errCls.addConstructor({\n parameters: [{ name: 'src', type: 'XRPCError' }],\n statements: [\n 'super(src.status, src.error, src.message, src.headers, { cause: src })',\n ],\n })\n\n customErrors.push({ name: error.name, cls: name })\n }\n\n // export function toKnownErr(err: any) {...}\n file.addFunction({\n name: 'toKnownErr',\n isExported: true,\n parameters: [{ name: 'e', type: 'any' }],\n statements: customErrors.length\n ? [\n 'if (e instanceof XRPCError) {',\n ...customErrors.map(\n (err) => `if (e.error === '${err.name}') return new ${err.cls}(e)`,\n ),\n '}',\n 'return e',\n ]\n : ['return e'],\n })\n}\n"]}
|
package/dist/codegen/common.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Project, SourceFile } from 'ts-morph';
|
|
2
2
|
import { type LexiconDoc } from '@atproto/lexicon';
|
|
3
|
-
import { type GeneratedFile } from '../types';
|
|
3
|
+
import { type GeneratedFile } from '../types.js';
|
|
4
4
|
export declare const utilTs: (project: any) => Promise<GeneratedFile>;
|
|
5
5
|
export declare const lexiconsTs: (project: any, lexicons: LexiconDoc[]) => Promise<GeneratedFile>;
|
|
6
6
|
export declare function gen(project: Project, path: string, gen: (file: SourceFile) => Promise<void>): Promise<GeneratedFile>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/codegen/common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAA2B,MAAM,UAAU,CAAA;AACvE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/codegen/common.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,UAAU,EAA2B,MAAM,UAAU,CAAA;AACvE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAA;AAWhD,eAAO,MAAM,MAAM,GAAI,YAAO,2BAuH1B,CAAA;AAEJ,eAAO,MAAM,UAAU,GAAI,YAAO,EAAE,UAAU,UAAU,EAAE,2BA8HtD,CAAA;AAEJ,wBAAsB,GAAG,CACvB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,GACvC,OAAO,CAAC,aAAa,CAAC,CAQxB"}
|
package/dist/codegen/common.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.gen = gen;
|
|
5
|
-
const prettier_1 = require("prettier");
|
|
6
|
-
const ts_morph_1 = require("ts-morph");
|
|
7
|
-
const util_1 = require("./util");
|
|
1
|
+
import { format } from 'prettier';
|
|
2
|
+
import { VariableDeclarationKind } from 'ts-morph';
|
|
3
|
+
import { toTitleCase } from './util.js';
|
|
8
4
|
const PRETTIER_OPTS = {
|
|
9
5
|
parser: 'typescript',
|
|
10
6
|
tabWidth: 2,
|
|
@@ -12,7 +8,7 @@ const PRETTIER_OPTS = {
|
|
|
12
8
|
singleQuote: true,
|
|
13
9
|
trailingComma: 'all',
|
|
14
10
|
};
|
|
15
|
-
const utilTs = (project) => gen(project, '/util.ts', async (file) => {
|
|
11
|
+
export const utilTs = (project) => gen(project, '/util.ts', async (file) => {
|
|
16
12
|
file.replaceWithText(`
|
|
17
13
|
import { type ValidationResult } from '@atproto/lexicon'
|
|
18
14
|
|
|
@@ -130,8 +126,7 @@ export function asPredicate<V extends Validator>(validate: V) {
|
|
|
130
126
|
}
|
|
131
127
|
`);
|
|
132
128
|
});
|
|
133
|
-
|
|
134
|
-
const lexiconsTs = (project, lexicons) => gen(project, '/lexicons.ts', async (file) => {
|
|
129
|
+
export const lexiconsTs = (project, lexicons) => gen(project, '/lexicons.ts', async (file) => {
|
|
135
130
|
//= import { type LexiconDoc, Lexicons } from '@atproto/lexicon'
|
|
136
131
|
file
|
|
137
132
|
.addImportDeclaration({
|
|
@@ -143,7 +138,7 @@ const lexiconsTs = (project, lexicons) => gen(project, '/lexicons.ts', async (fi
|
|
|
143
138
|
{ name: 'ValidationError' },
|
|
144
139
|
{ name: 'ValidationResult', isTypeOnly: true },
|
|
145
140
|
]);
|
|
146
|
-
//= import { is$typed, maybe$typed, type $Typed } from './util'
|
|
141
|
+
//= import { is$typed, maybe$typed, type $Typed } from './util.js'
|
|
147
142
|
file
|
|
148
143
|
.addImportDeclaration({
|
|
149
144
|
moduleSpecifier: './util.js',
|
|
@@ -156,13 +151,13 @@ const lexiconsTs = (project, lexicons) => gen(project, '/lexicons.ts', async (fi
|
|
|
156
151
|
//= export const schemaDict = {...} as const satisfies Record<string, LexiconDoc>
|
|
157
152
|
file.addVariableStatement({
|
|
158
153
|
isExported: true,
|
|
159
|
-
declarationKind:
|
|
154
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
160
155
|
declarations: [
|
|
161
156
|
{
|
|
162
157
|
name: 'schemaDict',
|
|
163
158
|
initializer: JSON.stringify(lexicons.reduce((acc, cur) => ({
|
|
164
159
|
...acc,
|
|
165
|
-
[
|
|
160
|
+
[toTitleCase(cur.id)]: cur,
|
|
166
161
|
}), {}), null, 2) + ' as const satisfies Record<string, LexiconDoc>',
|
|
167
162
|
},
|
|
168
163
|
],
|
|
@@ -170,7 +165,7 @@ const lexiconsTs = (project, lexicons) => gen(project, '/lexicons.ts', async (fi
|
|
|
170
165
|
//= export const schemas = Object.values(schemaDict) satisfies LexiconDoc[]
|
|
171
166
|
file.addVariableStatement({
|
|
172
167
|
isExported: true,
|
|
173
|
-
declarationKind:
|
|
168
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
174
169
|
declarations: [
|
|
175
170
|
{
|
|
176
171
|
name: 'schemas',
|
|
@@ -181,7 +176,7 @@ const lexiconsTs = (project, lexicons) => gen(project, '/lexicons.ts', async (fi
|
|
|
181
176
|
//= export const lexicons: Lexicons = new Lexicons(schemas)
|
|
182
177
|
file.addVariableStatement({
|
|
183
178
|
isExported: true,
|
|
184
|
-
declarationKind:
|
|
179
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
185
180
|
declarations: [
|
|
186
181
|
{
|
|
187
182
|
name: 'lexicons',
|
|
@@ -230,24 +225,23 @@ const lexiconsTs = (project, lexicons) => gen(project, '/lexicons.ts', async (fi
|
|
|
230
225
|
//= export const ids = {...}
|
|
231
226
|
file.addVariableStatement({
|
|
232
227
|
isExported: true,
|
|
233
|
-
declarationKind:
|
|
228
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
234
229
|
declarations: [
|
|
235
230
|
{
|
|
236
231
|
name: 'ids',
|
|
237
232
|
initializer: `{${lexicons
|
|
238
|
-
.map((lex) => `\n ${
|
|
233
|
+
.map((lex) => `\n ${toTitleCase(lex.id)}: ${JSON.stringify(lex.id)},`)
|
|
239
234
|
.join('')}\n} as const`,
|
|
240
235
|
},
|
|
241
236
|
],
|
|
242
237
|
});
|
|
243
238
|
});
|
|
244
|
-
|
|
245
|
-
async function gen(project, path, gen) {
|
|
239
|
+
export async function gen(project, path, gen) {
|
|
246
240
|
const file = project.createSourceFile(path);
|
|
247
241
|
await gen(file);
|
|
248
242
|
await file.save(); // Save in the "in memory" file system
|
|
249
243
|
const src = `${banner()}${file.getFullText()}`;
|
|
250
|
-
const content = await
|
|
244
|
+
const content = await format(src, PRETTIER_OPTS);
|
|
251
245
|
return { path, content };
|
|
252
246
|
}
|
|
253
247
|
function banner() {
|