@atproto/lex-builder 0.1.0-next.0 → 0.1.1
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 +13 -9
- package/dist/lex-def-builder.d.ts.map +1 -1
- package/dist/lex-def-builder.js +31 -48
- package/dist/lex-def-builder.js.map +1 -1
- package/package.json +3 -3
- package/src/lex-def-builder.ts +41 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
# @atproto/lex-builder
|
|
2
2
|
|
|
3
|
-
## 0.1.
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4972](https://github.com/bluesky-social/atproto/pull/4972) [`fb1b403`](https://github.com/bluesky-social/atproto/commit/fb1b40350d46f3c49e512b7e24b071b03902e3b8) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Fix XRPC methods being non tree-shakable
|
|
8
|
+
|
|
9
|
+
## 0.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
6
12
|
|
|
7
|
-
- [#4929](https://github.com/bluesky-social/atproto/pull/4929) [`
|
|
13
|
+
- [#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
14
|
|
|
9
|
-
- [#4943](https://github.com/bluesky-social/atproto/pull/4943) [`
|
|
15
|
+
- [#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
16
|
|
|
11
17
|
Node.js 22's `require()` compatibility layer can still load these packages in CommonJS code.
|
|
12
18
|
|
|
13
|
-
- [#4930](https://github.com/bluesky-social/atproto/pull/4930) [`
|
|
14
|
-
|
|
15
|
-
Internal: tsconfig `moduleResolution: "node"` is silenced via `ignoreDeprecations: "6.0"` for now; the proper migration to `node16`/`bundler` resolution is deferred.
|
|
19
|
+
- [#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
20
|
|
|
17
21
|
### Patch Changes
|
|
18
22
|
|
|
19
|
-
- Updated dependencies [[`
|
|
20
|
-
- @atproto/lex-document@0.1.0
|
|
21
|
-
- @atproto/lex-schema@0.1.0
|
|
23
|
+
- 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)]:
|
|
24
|
+
- @atproto/lex-document@0.1.0
|
|
25
|
+
- @atproto/lex-schema@0.1.0
|
|
22
26
|
|
|
23
27
|
## 0.0.23
|
|
24
28
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lex-def-builder.d.ts","sourceRoot":"","sources":["../src/lex-def-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EAEX,MAAM,UAAU,CAAA;AACjB,OAAO,EAOL,eAAe,EAEf,cAAc,EAMd,gBAAgB,EAChB,YAAY,EAKZ,mBAAmB,EAGpB,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAEL,kBAAkB,EAClB,WAAW,EAEZ,MAAM,mBAAmB,CAAA;AAG1B;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,GAAG;I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,EAAE,eAAe,EACrC,OAAO,EAAE,cAAc;IAKzB,OAAO,CAAC,IAAI;IAIN,KAAK;IAyBX,OAAO,CAAC,QAAQ;YAYF,MAAM;YA8BN,gBAAgB;YAsBhB,YAAY;YA2BZ,QAAQ;YAsBR,eAAe;IAsB7B,kBAAkB,CAChB,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,gBAAgB,GAAG,YAAY,GAAG,mBAAmB;YAmD9C,SAAS;YAsBT,SAAS;YAiBT,QAAQ;YAQR,QAAQ;YAuBR,SAAS;YA2FT,cAAc;YAkBd,iBAAiB;YAQjB,mBAAmB;YAWnB,aAAa;YAKb,mBAAmB;YAKnB,wBAAwB;YAsBxB,sBAAsB;YAYtB,0BAA0B;YAuB1B,wBAAwB;YAoBxB,sBAAsB;YA8BtB,oBAAoB;YA8BpB,kBAAkB;YASlB,gBAAgB;YAIhB,oBAAoB;YAIpB,kBAAkB;IAIhC,OAAO,CAAC,WAAW;YAQL,oBAAoB;YAYpB,kBAAkB;YAKlB,oBAAoB;YA0BpB,kBAAkB;YAOlB,mBAAmB;YA+CnB,iBAAiB;YA2CjB,kBAAkB;YAQlB,gBAAgB;YAIhB,iBAAiB;YAQjB,eAAe;YAIf,oBAAoB;YAIpB,kBAAkB;YAIlB,gBAAgB;YAOhB,cAAc;YAKd,qBAAqB;YAmBrB,mBAAmB;YAWnB,kBAAkB;YAYlB,gBAAgB;YAShB,iBAAiB;YAgBjB,eAAe;CAK9B"}
|
package/dist/lex-def-builder.js
CHANGED
|
@@ -47,15 +47,13 @@ export class LexDefBuilder {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
addUtils(definitions) {
|
|
50
|
-
const
|
|
51
|
-
|
|
50
|
+
for (const [name, initializer] of Object.entries(definitions)) {
|
|
51
|
+
if (initializer == null)
|
|
52
|
+
continue;
|
|
52
53
|
this.file.addVariableStatement({
|
|
53
54
|
isExported: true,
|
|
54
55
|
declarationKind: VariableDeclarationKind.Const,
|
|
55
|
-
declarations:
|
|
56
|
-
name,
|
|
57
|
-
initializer,
|
|
58
|
-
})),
|
|
56
|
+
declarations: [{ name, initializer }],
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
59
|
}
|
|
@@ -108,68 +106,50 @@ export class LexDefBuilder {
|
|
|
108
106
|
throw new Error(`Definition ${hash} cannot be of type ${def.type}`);
|
|
109
107
|
}
|
|
110
108
|
// @TODO Build the types instead of using an inferred type.
|
|
109
|
+
// Declare each piece of the method as its own top-level exported const
|
|
110
|
+
// *before* `main`, so consumers that import a single helper (e.g.
|
|
111
|
+
// `$lxm`) only pull in that subtree rather than the whole procedure.
|
|
112
|
+
// `main.parameters` etc. would otherwise pin `main` in the module graph.
|
|
113
|
+
this.addUtils({
|
|
114
|
+
$lxm: '$nsid',
|
|
115
|
+
$params: await this.compileParamsSchema(def.parameters),
|
|
116
|
+
$input: await this.compilePayload(def.input),
|
|
117
|
+
$output: await this.compilePayload(def.output),
|
|
118
|
+
});
|
|
111
119
|
const ref = await this.addSchema(hash, def, {
|
|
112
|
-
schema: this.pure(`
|
|
113
|
-
l.procedure(
|
|
114
|
-
$nsid,
|
|
115
|
-
${await this.compileParamsSchema(def.parameters)},
|
|
116
|
-
${await this.compilePayload(def.input)},
|
|
117
|
-
${await this.compilePayload(def.output)},
|
|
118
|
-
${await this.compileErrors(def.errors)}
|
|
119
|
-
)
|
|
120
|
-
`),
|
|
120
|
+
schema: this.pure(`l.procedure($nsid, $params, $input, $output${formatErrorsArg(await this.compileErrors(def.errors))})`),
|
|
121
121
|
});
|
|
122
122
|
this.addMethodTypeUtils(ref, def);
|
|
123
|
-
this.addUtils({
|
|
124
|
-
$lxm: this.pure(`${ref.varName}.nsid`),
|
|
125
|
-
$params: this.pure(`${ref.varName}.parameters`),
|
|
126
|
-
$input: this.pure(`${ref.varName}.input`),
|
|
127
|
-
$output: this.pure(`${ref.varName}.output`),
|
|
128
|
-
});
|
|
129
123
|
}
|
|
130
124
|
async addQuery(hash, def) {
|
|
131
125
|
if (hash !== 'main') {
|
|
132
126
|
throw new Error(`Definition ${hash} cannot be of type ${def.type}`);
|
|
133
127
|
}
|
|
134
128
|
// @TODO Build the types instead of using an inferred type.
|
|
129
|
+
this.addUtils({
|
|
130
|
+
$lxm: '$nsid',
|
|
131
|
+
$params: await this.compileParamsSchema(def.parameters),
|
|
132
|
+
$output: await this.compilePayload(def.output),
|
|
133
|
+
});
|
|
135
134
|
const ref = await this.addSchema(hash, def, {
|
|
136
|
-
schema: this.pure(`
|
|
137
|
-
l.query(
|
|
138
|
-
$nsid,
|
|
139
|
-
${await this.compileParamsSchema(def.parameters)},
|
|
140
|
-
${await this.compilePayload(def.output)},
|
|
141
|
-
${await this.compileErrors(def.errors)}
|
|
142
|
-
)
|
|
143
|
-
`),
|
|
135
|
+
schema: this.pure(`l.query($nsid, $params, $output${formatErrorsArg(await this.compileErrors(def.errors))})`),
|
|
144
136
|
});
|
|
145
137
|
this.addMethodTypeUtils(ref, def);
|
|
146
|
-
this.addUtils({
|
|
147
|
-
$lxm: this.pure(`${ref.varName}.nsid`),
|
|
148
|
-
$params: `${ref.varName}.parameters`,
|
|
149
|
-
$output: `${ref.varName}.output`,
|
|
150
|
-
});
|
|
151
138
|
}
|
|
152
139
|
async addSubscription(hash, def) {
|
|
153
140
|
if (hash !== 'main') {
|
|
154
141
|
throw new Error(`Definition ${hash} cannot be of type ${def.type}`);
|
|
155
142
|
}
|
|
156
143
|
// @TODO Build the types instead of using an inferred type.
|
|
144
|
+
this.addUtils({
|
|
145
|
+
$lxm: '$nsid',
|
|
146
|
+
$params: await this.compileParamsSchema(def.parameters),
|
|
147
|
+
$message: await this.compileBodySchema(def.message?.schema),
|
|
148
|
+
});
|
|
157
149
|
const ref = await this.addSchema(hash, def, {
|
|
158
|
-
schema: this.pure(`
|
|
159
|
-
l.subscription(
|
|
160
|
-
$nsid,
|
|
161
|
-
${await this.compileParamsSchema(def.parameters)},
|
|
162
|
-
${await this.compileBodySchema(def.message?.schema)},
|
|
163
|
-
${await this.compileErrors(def.errors)}
|
|
164
|
-
)
|
|
165
|
-
`),
|
|
150
|
+
schema: this.pure(`l.subscription($nsid, $params, $message${formatErrorsArg(await this.compileErrors(def.errors))})`),
|
|
166
151
|
});
|
|
167
152
|
this.addMethodTypeUtils(ref, def);
|
|
168
|
-
this.addUtils({
|
|
169
|
-
$lxm: this.pure(`${ref.varName}.nsid`),
|
|
170
|
-
$params: `${ref.varName}.parameters`,
|
|
171
|
-
$message: `${ref.varName}.message`,
|
|
172
|
-
});
|
|
173
153
|
}
|
|
174
154
|
addMethodTypeUtils(ref, def) {
|
|
175
155
|
this.file.addTypeAlias({
|
|
@@ -312,7 +292,7 @@ export class LexDefBuilder {
|
|
|
312
292
|
this.addUtils({
|
|
313
293
|
$isTypeOf: markPure(`${ref.varName}.isTypeOf.bind(${ref.varName})`),
|
|
314
294
|
$build: markPure(`${ref.varName}.build.bind(${ref.varName})`),
|
|
315
|
-
$type:
|
|
295
|
+
$type: `${ref.varName}.$type`,
|
|
316
296
|
});
|
|
317
297
|
}
|
|
318
298
|
if (hash === 'main' && validationUtils) {
|
|
@@ -742,4 +722,7 @@ function hasEnum(def) {
|
|
|
742
722
|
function markPure(v) {
|
|
743
723
|
return `/*#__PURE__*/ ${v}`;
|
|
744
724
|
}
|
|
725
|
+
function formatErrorsArg(errors) {
|
|
726
|
+
return errors ? `, ${errors}` : '';
|
|
727
|
+
}
|
|
745
728
|
//# sourceMappingURL=lex-def-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lex-def-builder.js","sourceRoot":"","sources":["../src/lex-def-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,uBAAuB,GACxB,MAAM,UAAU,CAAA;AA0BjB,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,EACL,WAAW,EAGX,oBAAoB,GACrB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cA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vB,GAAM,EACN,OAAqB,EACrB,OAAqB;IAErB,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CACzC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CACpE,CAAA;IACD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAC5E,CAAC;AAED,SAAS,QAAQ,CACf,GAAM;IAEN,OAAO,GAAG,CAAC,KAAK,IAAI,IAAI,CAAA;AAC1B,CAAC;AAED,SAAS,OAAO,CACd,GAAM;IAEN,OAAO,GAAG,CAAC,IAAI,IAAI,IAAI,CAAA;AACzB,CAAC;AAED,SAAS,QAAQ,CAAmB,CAAI;IACtC,OAAO,iBAAiB,CAAC,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {\n JSDocStructure,\n OptionalKind,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph'\nimport {\n LexiconArray,\n LexiconArrayItems,\n LexiconBlob,\n LexiconBoolean,\n LexiconBytes,\n LexiconCid,\n LexiconDocument,\n LexiconError,\n LexiconIndexer,\n LexiconInteger,\n LexiconObject,\n LexiconParameters,\n LexiconPayload,\n LexiconPermissionSet,\n LexiconProcedure,\n LexiconQuery,\n LexiconRecord,\n LexiconRef,\n LexiconRefUnion,\n LexiconString,\n LexiconSubscription,\n LexiconToken,\n LexiconUnknown,\n} from '@atproto/lex-document'\nimport { l } from '@atproto/lex-schema'\nimport {\n RefResolver,\n RefResolverOptions,\n ResolvedRef,\n getPublicIdentifiers,\n} from './ref-resolver.js'\nimport { asNamespaceExport } from './ts-lang.js'\n\n/**\n * Configuration options for the {@link LexDefBuilder} class.\n *\n * @see {@link RefResolverOptions} for reference resolution options\n */\nexport type LexDefBuilderOptions = RefResolverOptions & {\n /**\n * The module specifier to use for importing the lexicon schema library.\n *\n * @default '@atproto/lex-schema'\n */\n lib?: string\n /**\n * Whether to add `#__PURE__` annotations to function calls.\n *\n * These annotations help bundlers with tree-shaking by marking\n * side-effect-free function calls.\n *\n * @default false\n */\n pureAnnotations?: boolean\n}\n\n/**\n * Builds TypeScript type definitions and runtime schemas from a single\n * Lexicon document.\n *\n * This class is responsible for generating the `.defs.ts` files that contain:\n * - Type aliases for each lexicon definition\n * - Runtime schema validators using `@atproto/lex-schema`\n * - Utility functions for type checking and validation\n * - Proper import statements for cross-references\n *\n * Each lexicon definition type (record, object, query, procedure, etc.)\n * is handled with specialized code generation logic.\n */\nexport class LexDefBuilder {\n private readonly refResolver: RefResolver\n\n constructor(\n private readonly options: LexDefBuilderOptions,\n private readonly file: SourceFile,\n private readonly doc: LexiconDocument,\n indexer: LexiconIndexer,\n ) {\n this.refResolver = new RefResolver(doc, file, indexer, options)\n }\n\n private pure(code: string) {\n return this.options.pureAnnotations ? markPure(code) : code\n }\n\n async build() {\n this.file.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n { name: '$nsid', initializer: JSON.stringify(this.doc.id) },\n ],\n })\n\n this.file.addExportDeclaration({\n namedExports: [{ name: '$nsid' }],\n })\n\n const defs = Object.keys(this.doc.defs)\n if (defs.length) {\n const moduleSpecifier = this.options?.lib ?? '@atproto/lex-schema'\n this.file\n .addImportDeclaration({ moduleSpecifier })\n .addNamedImports([{ name: 'l' }])\n\n for (const hash of defs) {\n await this.addDef(hash)\n }\n }\n }\n\n private addUtils(definitions: Record<string, undefined | string>) {\n const entries = Object.entries(definitions).filter(\n (e): e is [(typeof e)[0], NonNullable<(typeof e)[1]>] => e[1] != null,\n )\n if (entries.length) {\n this.file.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: entries.map(([name, initializer]) => ({\n name,\n initializer,\n })),\n })\n }\n }\n\n private async addDef(hash: string) {\n const def = Object.hasOwn(this.doc.defs, hash) ? this.doc.defs[hash] : null\n if (def == null) return\n\n switch (def.type) {\n case 'permission-set':\n return this.addPermissionSet(hash, def)\n case 'procedure':\n return this.addProcedure(hash, def)\n case 'query':\n return this.addQuery(hash, def)\n case 'subscription':\n return this.addSubscription(hash, def)\n case 'record':\n return this.addRecord(hash, def)\n case 'token':\n return this.addToken(hash, def)\n case 'object':\n return this.addObject(hash, def)\n case 'array':\n return this.addArray(hash, def)\n default:\n await this.addSchema(hash, def, {\n type: await this.compileContainedType(def),\n schema: await this.compileContainedSchema(def),\n validationUtils: true,\n })\n }\n }\n\n private async addPermissionSet(hash: string, def: LexiconPermissionSet) {\n const permission = def.permissions.map((def) => {\n const options = stringifyOptions(def, undefined, ['resource', 'type'])\n return this.pure(\n `l.permission(${JSON.stringify(def.resource)}, ${options})`,\n )\n })\n\n const options = stringifyOptions(def, [\n 'title',\n 'title:lang',\n 'detail',\n 'detail:lang',\n ] satisfies (keyof l.PermissionSetOptions)[])\n\n await this.addSchema(hash, def, {\n schema: this.pure(\n `l.permissionSet($nsid, [${permission.join(',')}], ${options})`,\n ),\n })\n }\n\n private async addProcedure(hash: string, def: LexiconProcedure) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n // @TODO Build the types instead of using an inferred type.\n\n const ref = await this.addSchema(hash, def, {\n schema: this.pure(`\n l.procedure(\n $nsid,\n ${await this.compileParamsSchema(def.parameters)},\n ${await this.compilePayload(def.input)},\n ${await this.compilePayload(def.output)},\n ${await this.compileErrors(def.errors)}\n )\n `),\n })\n\n this.addMethodTypeUtils(ref, def)\n this.addUtils({\n $lxm: this.pure(`${ref.varName}.nsid`),\n $params: this.pure(`${ref.varName}.parameters`),\n $input: this.pure(`${ref.varName}.input`),\n $output: this.pure(`${ref.varName}.output`),\n })\n }\n\n private async addQuery(hash: string, def: LexiconQuery) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n // @TODO Build the types instead of using an inferred type.\n\n const ref = await this.addSchema(hash, def, {\n schema: this.pure(`\n l.query(\n $nsid,\n ${await this.compileParamsSchema(def.parameters)},\n ${await this.compilePayload(def.output)},\n ${await this.compileErrors(def.errors)}\n )\n `),\n })\n\n this.addMethodTypeUtils(ref, def)\n this.addUtils({\n $lxm: this.pure(`${ref.varName}.nsid`),\n $params: `${ref.varName}.parameters`,\n $output: `${ref.varName}.output`,\n })\n }\n\n private async addSubscription(hash: string, def: LexiconSubscription) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n // @TODO Build the types instead of using an inferred type.\n\n const ref = await this.addSchema(hash, def, {\n schema: this.pure(`\n l.subscription(\n $nsid,\n ${await this.compileParamsSchema(def.parameters)},\n ${await this.compileBodySchema(def.message?.schema)},\n ${await this.compileErrors(def.errors)}\n )\n `),\n })\n\n this.addMethodTypeUtils(ref, def)\n this.addUtils({\n $lxm: this.pure(`${ref.varName}.nsid`),\n $params: `${ref.varName}.parameters`,\n $message: `${ref.varName}.message`,\n })\n }\n\n addMethodTypeUtils(\n ref: ResolvedRef,\n def: LexiconProcedure | LexiconQuery | LexiconSubscription,\n ) {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Params',\n type: `l.InferMethodParams<typeof ${ref.varName}>`,\n docs: compileDocs(def.parameters?.description),\n })\n\n if (def.type === 'procedure') {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Input<B = l.BinaryData>',\n type: `l.InferMethodInput<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.input?.description),\n })\n\n this.file.addTypeAlias({\n isExported: true,\n name: '$InputBody<B = l.BinaryData>',\n type: `l.InferMethodInputBody<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.input?.description),\n })\n }\n\n if (def.type === 'procedure' || def.type === 'query') {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Output<B = l.BinaryData>',\n type: `l.InferMethodOutput<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.output?.description),\n })\n\n this.file.addTypeAlias({\n isExported: true,\n name: '$OutputBody<B = l.BinaryData>',\n type: `l.InferMethodOutputBody<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.output?.description),\n })\n }\n\n if (def.type === 'subscription') {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Message',\n type: `l.InferSubscriptionMessage<typeof ${ref.varName}>`,\n docs: compileDocs(def.message?.description),\n })\n }\n }\n\n private async addRecord(hash: string, def: LexiconRecord) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n const key = JSON.stringify(def.key ?? 'any')\n const objectSchema = await this.compileObjectSchema(def.record)\n\n const properties = await this.compilePropertiesTypes(def.record)\n properties.unshift(`$type: ${JSON.stringify(l.$type(this.doc.id, hash))}`)\n\n await this.addSchema(hash, def, {\n type: `{ ${properties.join(';')} }`,\n schema: (ref) =>\n this.pure(\n `l.record<${key}, ${ref.typeName}>(${key}, $nsid, ${objectSchema})`,\n ),\n objectUtils: true,\n validationUtils: true,\n })\n }\n\n private async addObject(hash: string, def: LexiconObject) {\n const objectSchema = await this.compileObjectSchema(def)\n\n const properties = await this.compilePropertiesTypes(def)\n properties.unshift(`$type?: ${JSON.stringify(l.$type(this.doc.id, hash))}`)\n\n await this.addSchema(hash, def, {\n type: `{ ${properties.join(';')} }`,\n schema: (ref) =>\n this.pure(\n `l.typedObject<${ref.typeName}>($nsid, ${JSON.stringify(hash)}, ${objectSchema})`,\n ),\n objectUtils: true,\n validationUtils: true,\n })\n }\n\n private async addToken(hash: string, def: LexiconToken) {\n await this.addSchema(hash, def, {\n schema: this.pure(`l.token($nsid, ${JSON.stringify(hash)})`),\n type: JSON.stringify(l.$type(this.doc.id, hash)),\n validationUtils: true,\n })\n }\n\n private async addArray(hash: string, def: LexiconArray) {\n // @TODO It could be nice to expose the array item type as a separate type.\n // This was not done (yet) as there is no easy way to name it to avoid\n // collisions.\n\n const itemSchema = await this.compileContainedSchema(def.items)\n const options = stringifyOptions(def, [\n 'minLength',\n 'maxLength',\n ] satisfies (keyof l.ArraySchemaOptions)[])\n\n await this.addSchema(hash, def, {\n type: `(${await this.compileContainedType(def.items)})[]`,\n // @NOTE Not using compileArraySchema to allow specifying the generic\n // parameter to l.array<>.\n schema: (ref) =>\n this.pure(\n `l.array<${ref.typeName}[number]>(${itemSchema}, ${options})`,\n ),\n validationUtils: true,\n })\n }\n\n private async addSchema(\n hash: string,\n def: { description?: string },\n {\n type,\n schema,\n objectUtils,\n validationUtils,\n }: {\n type?: string | ((ref: ResolvedRef) => string)\n schema?: string | ((ref: ResolvedRef) => string)\n objectUtils?: boolean\n validationUtils?: boolean\n },\n ): Promise<ResolvedRef> {\n const ref = await this.refResolver.resolveLocal(hash)\n const pub = getPublicIdentifiers(hash)\n\n if (type) {\n this.file.addTypeAlias({\n name: ref.typeName,\n type: typeof type === 'function' ? type(ref) : type,\n docs: compileDocs(def.description),\n })\n\n this.file.addExportDeclaration({\n isTypeOnly: true,\n namedExports: [\n {\n name: ref.typeName,\n alias:\n ref.typeName === pub.typeName\n ? undefined\n : asNamespaceExport(pub.typeName),\n },\n ],\n })\n }\n\n if (schema) {\n this.file.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: ref.varName,\n initializer: typeof schema === 'function' ? schema(ref) : schema,\n },\n ],\n docs: compileDocs(def.description),\n })\n\n this.file.addExportDeclaration({\n namedExports: [\n {\n name: ref.varName,\n alias:\n ref.varName === pub.varName\n ? undefined\n : asNamespaceExport(pub.varName),\n },\n ],\n })\n }\n\n if (hash === 'main' && objectUtils) {\n this.addUtils({\n $isTypeOf: markPure(`${ref.varName}.isTypeOf.bind(${ref.varName})`),\n $build: markPure(`${ref.varName}.build.bind(${ref.varName})`),\n $type: markPure(`${ref.varName}.$type`),\n })\n }\n\n if (hash === 'main' && validationUtils) {\n this.addUtils({\n $assert: markPure(`${ref.varName}.assert.bind(${ref.varName})`),\n $check: markPure(`${ref.varName}.check.bind(${ref.varName})`),\n $cast: markPure(`${ref.varName}.cast.bind(${ref.varName})`),\n $ifMatches: markPure(`${ref.varName}.ifMatches.bind(${ref.varName})`),\n $matches: markPure(`${ref.varName}.matches.bind(${ref.varName})`),\n $parse: markPure(`${ref.varName}.parse.bind(${ref.varName})`),\n $safeParse: markPure(`${ref.varName}.safeParse.bind(${ref.varName})`),\n $validate: markPure(`${ref.varName}.validate.bind(${ref.varName})`),\n $safeValidate: markPure(\n `${ref.varName}.safeValidate.bind(${ref.varName})`,\n ),\n })\n }\n\n return ref\n }\n\n private async compilePayload(def: LexiconPayload | undefined) {\n if (!def) return this.pure(`l.payload()`)\n\n // Special case for JSON object payloads\n if (def.encoding === 'application/json' && def.schema?.type === 'object') {\n const properties = await this.compilePropertiesSchemas(def.schema)\n return this.pure(`l.jsonPayload({${properties.join(',')}})`)\n }\n\n const encodedEncoding = JSON.stringify(def.encoding)\n if (def.schema) {\n const bodySchema = await this.compileBodySchema(def.schema)\n return this.pure(`l.payload(${encodedEncoding}, ${bodySchema})`)\n } else {\n return this.pure(`l.payload(${encodedEncoding})`)\n }\n }\n\n private async compileBodySchema(\n def?: LexiconRef | LexiconRefUnion | LexiconObject,\n ): Promise<string> {\n if (!def) return 'undefined'\n if (def.type === 'object') return this.compileObjectSchema(def)\n return this.compileContainedSchema(def)\n }\n\n private async compileParamsSchema(def: undefined | LexiconParameters) {\n if (!def) return this.pure(`l.params()`)\n\n const properties = await this.compilePropertiesSchemas(def)\n return this.pure(\n properties.length === 0\n ? `l.params()`\n : `l.params({${properties.join(',')}})`,\n )\n }\n\n private async compileErrors(defs?: readonly LexiconError[]) {\n if (!defs?.length) return ''\n return JSON.stringify(defs.map((d) => d.name))\n }\n\n private async compileObjectSchema(def: LexiconObject): Promise<string> {\n const properties = await this.compilePropertiesSchemas(def)\n return this.pure(`l.object({${properties.join(',')}})`)\n }\n\n private async compilePropertiesSchemas(options: {\n properties: Record<string, LexiconArray | LexiconArrayItems>\n required?: readonly string[]\n nullable?: readonly string[]\n }): Promise<string[]> {\n for (const opt of ['required', 'nullable'] as const) {\n if (options[opt]) {\n for (const prop of options[opt]) {\n if (!Object.hasOwn(options.properties, prop)) {\n throw new Error(`No schema found for ${opt} property \"${prop}\"`)\n }\n }\n }\n }\n\n return Promise.all(\n Object.entries(options.properties).map((entry) => {\n return this.compilePropertyEntrySchema(entry, options)\n }),\n )\n }\n\n private async compilePropertiesTypes(options: {\n properties: Record<string, LexiconArray | LexiconArrayItems>\n required?: readonly string[]\n nullable?: readonly string[]\n }) {\n return Promise.all(\n Object.entries(options.properties).map((entry) => {\n return this.compilePropertyEntryType(entry, options)\n }),\n )\n }\n\n private async compilePropertyEntrySchema(\n [key, def]: [string, LexiconArray | LexiconArrayItems],\n options: {\n required?: readonly string[]\n nullable?: readonly string[]\n },\n ) {\n const isNullable = options.nullable?.includes(key)\n const isRequired = options.required?.includes(key)\n\n let schema = await this.compileContainedSchema(def)\n\n if (isNullable) {\n schema = this.pure(`l.nullable(${schema})`)\n }\n\n if (!isRequired) {\n schema = this.pure(`l.optional(${schema})`)\n }\n\n return `${JSON.stringify(key)}:${schema}`\n }\n\n private async compilePropertyEntryType(\n [key, def]: [string, LexiconArray | LexiconArrayItems],\n options: {\n required?: readonly string[]\n nullable?: readonly string[]\n },\n ) {\n const isNullable = options.nullable?.includes(key)\n const isRequired = options.required?.includes(key)\n\n const optional = isRequired ? '' : '?'\n const append = isNullable ? ' | null' : ''\n\n const jsDoc = compileLeadingTrivia(def.description) || ''\n const name = JSON.stringify(key)\n const type = await this.compileContainedType(def)\n\n return `${jsDoc}${name}${optional}:${type}${append}`\n }\n\n private async compileContainedSchema(\n def: LexiconArray | LexiconArrayItems,\n ): Promise<string> {\n switch (def.type) {\n case 'unknown':\n return this.compileUnknownSchema(def)\n case 'boolean':\n return this.compileBooleanSchema(def)\n case 'integer':\n return this.compileIntegerSchema(def)\n case 'string':\n return this.compileStringSchema(def)\n case 'bytes':\n return this.compileBytesSchema(def)\n case 'blob':\n return this.compileBlobSchema(def)\n case 'cid-link':\n return this.compileCidLinkSchema(def)\n case 'ref':\n return this.compileRefSchema(def)\n case 'union':\n return this.compileRefUnionSchema(def)\n case 'array':\n return this.compileArraySchema(def)\n default:\n // @ts-expect-error\n throw new Error(`Unsupported def type: ${def.type}`)\n }\n }\n\n private async compileContainedType(\n def: LexiconArray | LexiconArrayItems,\n ): Promise<string> {\n switch (def.type) {\n case 'unknown':\n return this.compileUnknownType(def)\n case 'boolean':\n return this.compileBooleanType(def)\n case 'integer':\n return this.compileIntegerType(def)\n case 'string':\n return this.compileStringType(def)\n case 'bytes':\n return this.compileBytesType(def)\n case 'blob':\n return this.compileBlobType(def)\n case 'cid-link':\n return this.compileCidLinkType(def)\n case 'ref':\n return this.compileRefType(def)\n case 'union':\n return this.compileRefUnionType(def)\n case 'array':\n return this.compileArrayType(def)\n default:\n // @ts-expect-error\n throw new Error(`Unsupported def type: ${def.type}`)\n }\n }\n\n private async compileArraySchema(def: LexiconArray): Promise<string> {\n const itemSchema = await this.compileContainedSchema(def.items)\n const options = stringifyOptions(def, [\n 'minLength',\n 'maxLength',\n ] satisfies (keyof l.ArraySchemaOptions)[])\n return this.pure(`l.array(${itemSchema}, ${options})`)\n }\n\n private async compileArrayType(def: LexiconArray): Promise<string> {\n return `(${await this.compileContainedType(def.items)})[]`\n }\n\n private async compileUnknownSchema(_def: LexiconUnknown): Promise<string> {\n return this.pure(`l.lexMap()`)\n }\n\n private async compileUnknownType(_def: LexiconUnknown): Promise<string> {\n return `l.LexMap`\n }\n\n private withDefault(schema: string, defaultValue: unknown) {\n if (defaultValue === undefined) return schema\n\n return this.pure(\n `l.withDefault(${schema}, ${JSON.stringify(defaultValue)})`,\n )\n }\n\n private async compileBooleanSchema(def: LexiconBoolean): Promise<string> {\n const schema = l.boolean()\n\n if (def.default !== undefined) {\n schema.check(def.default)\n }\n\n if (hasConst(def)) return this.compileConstSchema(def)\n\n return this.withDefault(this.pure(`l.boolean()`), def.default)\n }\n\n private async compileBooleanType(def: LexiconBoolean): Promise<string> {\n if (hasConst(def)) return this.compileConstType(def)\n return 'boolean'\n }\n\n private async compileIntegerSchema(def: LexiconInteger): Promise<string> {\n const schema = l.integer(def)\n\n if (hasConst(def)) {\n schema.check(def.const)\n }\n\n if (hasEnum(def)) {\n for (const val of def.enum) schema.check(val)\n }\n\n if (def.default !== undefined) {\n schema.check(def.default)\n }\n\n if (hasConst(def)) return this.compileConstSchema(def)\n if (hasEnum(def)) return this.compileEnumSchema(def)\n\n const options = stringifyOptions(def, [\n 'maximum',\n 'minimum',\n ] satisfies (keyof l.IntegerSchemaOptions)[])\n\n return this.withDefault(this.pure(`l.integer(${options})`), def.default)\n }\n\n private async compileIntegerType(def: LexiconInteger): Promise<string> {\n if (hasConst(def)) return this.compileConstType(def)\n if (hasEnum(def)) return this.compileEnumType(def)\n\n return 'number'\n }\n\n private async compileStringSchema(def: LexiconString): Promise<string> {\n const schema = l.string(def)\n\n if (hasConst(def)) {\n schema.check(def.const)\n }\n\n if (hasEnum(def)) {\n for (const val of def.enum) schema.check(val)\n }\n\n if (def.default !== undefined) {\n schema.check(def.default)\n }\n\n if (hasConst(def)) return this.compileConstSchema(def)\n if (hasEnum(def)) return this.compileEnumSchema(def)\n\n const runtimeOptions = [\n 'format',\n 'maxGraphemes',\n 'minGraphemes',\n 'maxLength',\n 'minLength',\n // We don't want to include knownValues in the schema options **at\n // runtime** as it has no effect and only causes bloat:\n // \"knownValues\",\n ] as const satisfies (keyof l.StringSchemaOptions)[]\n\n const options = stringifyOptions(def, runtimeOptions)\n\n // We *do* however need knownValues for the inferred type, so we include it\n // as the generic parameter. We only do this if the def has knownValues,\n // otherwise we let TypeScript infer the options generic by not defining it.\n const generic = def.knownValues\n ? stringifyOptions(def, [\n ...runtimeOptions,\n 'knownValues',\n ] satisfies (keyof l.StringSchemaOptions)[])\n : undefined\n\n return this.withDefault(\n this.pure(`l.string${generic ? `<${generic}>` : ''}(${options})`),\n def.default,\n )\n }\n\n private async compileStringType(def: LexiconString): Promise<string> {\n if (hasConst(def)) return this.compileConstType(def)\n if (hasEnum(def)) return this.compileEnumType(def)\n\n switch (def.format) {\n case undefined:\n break\n case 'datetime':\n return 'l.DatetimeString'\n case 'uri':\n return 'l.UriString'\n case 'at-uri':\n return 'l.AtUriString'\n case 'did':\n return 'l.DidString'\n case 'handle':\n return 'l.HandleString'\n case 'at-identifier':\n return 'l.AtIdentifierString'\n case 'nsid':\n return 'l.NsidString'\n case 'tid':\n return 'l.TidString'\n case 'cid':\n return 'l.CidString'\n case 'language':\n return 'l.LanguageString'\n case 'record-key':\n return 'l.RecordKeyString'\n default:\n throw new Error(`Unknown string format: ${def.format}`)\n }\n\n if (def.knownValues?.length) {\n return (\n def.knownValues.map((v) => JSON.stringify(v)).join(' | ') +\n ' | l.UnknownString'\n )\n }\n\n return 'string'\n }\n\n private async compileBytesSchema(def: LexiconBytes): Promise<string> {\n const options = stringifyOptions(def, [\n 'minLength',\n 'maxLength',\n ] satisfies (keyof l.BytesSchemaOptions)[])\n return this.pure(`l.bytes(${options})`)\n }\n\n private async compileBytesType(_def: LexiconBytes): Promise<string> {\n return 'Uint8Array'\n }\n\n private async compileBlobSchema(def: LexiconBlob): Promise<string> {\n const options = stringifyOptions(def, [\n 'maxSize',\n 'accept',\n ] satisfies (keyof l.BlobSchemaOptions)[])\n return this.pure(`l.blob(${options})`)\n }\n\n private async compileBlobType(_def: LexiconBlob): Promise<string> {\n return 'l.BlobRef'\n }\n\n private async compileCidLinkSchema(_def: LexiconCid): Promise<string> {\n return this.pure(`l.cid()`)\n }\n\n private async compileCidLinkType(_def: LexiconCid): Promise<string> {\n return 'l.Cid'\n }\n\n private async compileRefSchema(def: LexiconRef): Promise<string> {\n const { varName, typeName } = await this.refResolver.resolve(def.ref)\n // @NOTE \"as any\" is needed in schemas with circular refs as TypeScript\n // cannot infer the type of a value that depends on its initializer type\n return this.pure(`l.ref<${typeName}>((() => ${varName}) as any)`)\n }\n\n private async compileRefType(def: LexiconRef): Promise<string> {\n const ref = await this.refResolver.resolve(def.ref)\n return ref.typeName\n }\n\n private async compileRefUnionSchema(def: LexiconRefUnion): Promise<string> {\n if (def.refs.length === 0 && def.closed) {\n return this.pure(`l.never()`)\n }\n\n const refs = await Promise.all(\n def.refs.map(async (ref: string) => {\n const { varName, typeName } = await this.refResolver.resolve(ref)\n // @NOTE \"as any\" is needed in schemas with circular refs as TypeScript\n // cannot infer the type of a value that depends on its initializer type\n return this.pure(`l.typedRef<${typeName}>((() => ${varName}) as any)`)\n }),\n )\n\n return this.pure(\n `l.typedUnion([${refs.join(',')}], ${def.closed ?? false})`,\n )\n }\n\n private async compileRefUnionType(def: LexiconRefUnion): Promise<string> {\n const types = await Promise.all(\n def.refs.map(async (ref) => {\n const { typeName } = await this.refResolver.resolve(ref)\n return `l.$Typed<${typeName}>`\n }),\n )\n if (!def.closed) types.push('l.Unknown$TypedObject')\n return types.join(' | ') || 'never'\n }\n\n private async compileConstSchema<\n T extends null | number | string | boolean,\n >(def: { const: T; enum?: readonly T[]; default?: T }): Promise<string> {\n if (hasEnum(def) && !def.enum.includes(def.const)) {\n return this.pure(`l.never()`)\n }\n\n const result = this.pure(`l.literal(${JSON.stringify(def.const)})`)\n\n return this.withDefault(result, def.default)\n }\n\n private async compileConstType<\n T extends null | number | string | boolean,\n >(def: { const: T; enum?: readonly T[] }): Promise<string> {\n if (hasEnum(def) && !def.enum.includes(def.const)) {\n return 'never'\n }\n return JSON.stringify(def.const)\n }\n\n private async compileEnumSchema<T extends null | number | string>(def: {\n enum: readonly T[]\n default?: T\n }): Promise<string> {\n if (def.enum.length === 0) {\n return this.pure(`l.never()`)\n }\n\n const result =\n def.enum.length === 1\n ? this.pure(`l.literal(${JSON.stringify(def.enum[0])})`)\n : this.pure(`l.enum(${JSON.stringify(def.enum)})`)\n\n return this.withDefault(result, def.default)\n }\n\n private async compileEnumType<T extends null | number | string>(def: {\n enum: readonly T[]\n }): Promise<string> {\n return def.enum.map((v) => JSON.stringify(v)).join(' | ') || 'never'\n }\n}\n\ntype ParsedDescription = OptionalKind<JSDocStructure> & {\n description?: string\n tags?: { tagName: string; text?: string }[]\n}\n\nfunction parseDescription(description: string): ParsedDescription {\n if (/deprecated/i.test(description)) {\n const deprecationMatch = description.match(\n /(\\s*deprecated\\s*(?:--?|:)?\\s*([^-]*)(?:-+)?)/i,\n )\n if (deprecationMatch) {\n const { 1: match, 2: deprecationNotice } = deprecationMatch\n return {\n description: description.replace(match, '').trim() || undefined,\n tags: [{ tagName: 'deprecated', text: deprecationNotice?.trim() }],\n }\n } else {\n return {\n description: description.trim() || undefined,\n tags: [{ tagName: 'deprecated' }],\n }\n }\n }\n\n return {\n description: description.trim() || undefined,\n }\n}\n\nfunction compileLeadingTrivia(description?: string) {\n if (!description) return undefined\n const parsed = parseDescription(description)\n if (!parsed.description && !parsed.tags?.length) return undefined\n const tags = parsed.tags\n ?.map(({ tagName, text }) => (text ? `@${tagName} ${text}` : `@${tagName}`))\n ?.join('\\n')\n const text = `\\n${[parsed.description, tags].filter(Boolean).join('\\n\\n')}`\n return `\\n\\n/**${text.replaceAll('\\n', '\\n * ')}\\n */\\n`\n}\n\nfunction compileDocs(description?: string) {\n if (!description) return undefined\n return [parseDescription(description)]\n}\n\nfunction stringifyOptions<O extends Record<string, unknown>>(\n obj: O,\n include?: (keyof O)[],\n exclude?: (keyof O)[],\n) {\n const filtered = Object.entries(obj).filter(\n ([k]) => (!include || include.includes(k)) && !exclude?.includes(k),\n )\n return filtered.length ? JSON.stringify(Object.fromEntries(filtered)) : ''\n}\n\nfunction hasConst<T extends { const?: unknown }>(\n def: T,\n): def is T & { const: NonNullable<T['const']> } {\n return def.const != null\n}\n\nfunction hasEnum<T extends { enum?: readonly unknown[] }>(\n def: T,\n): def is T & { enum: unknown[] } {\n return def.enum != null\n}\n\nfunction markPure<T extends string>(v: T): `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AC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,CACpE,CAAA;IACD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;AAC5E,CAAC;AAED,SAAS,QAAQ,CACf,GAAM;IAEN,OAAO,GAAG,CAAC,KAAK,IAAI,IAAI,CAAA;AAC1B,CAAC;AAED,SAAS,OAAO,CACd,GAAM;IAEN,OAAO,GAAG,CAAC,IAAI,IAAI,IAAI,CAAA;AACzB,CAAC;AAED,SAAS,QAAQ,CAAmB,CAAI;IACtC,OAAO,iBAAiB,CAAC,EAAE,CAAA;AAC7B,CAAC;AAED,SAAS,eAAe,CAAC,MAAc;IACrC,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;AACpC,CAAC","sourcesContent":["import {\n JSDocStructure,\n OptionalKind,\n SourceFile,\n VariableDeclarationKind,\n} from 'ts-morph'\nimport {\n LexiconArray,\n LexiconArrayItems,\n LexiconBlob,\n LexiconBoolean,\n LexiconBytes,\n LexiconCid,\n LexiconDocument,\n LexiconError,\n LexiconIndexer,\n LexiconInteger,\n LexiconObject,\n LexiconParameters,\n LexiconPayload,\n LexiconPermissionSet,\n LexiconProcedure,\n LexiconQuery,\n LexiconRecord,\n LexiconRef,\n LexiconRefUnion,\n LexiconString,\n LexiconSubscription,\n LexiconToken,\n LexiconUnknown,\n} from '@atproto/lex-document'\nimport { l } from '@atproto/lex-schema'\nimport {\n RefResolver,\n RefResolverOptions,\n ResolvedRef,\n getPublicIdentifiers,\n} from './ref-resolver.js'\nimport { asNamespaceExport } from './ts-lang.js'\n\n/**\n * Configuration options for the {@link LexDefBuilder} class.\n *\n * @see {@link RefResolverOptions} for reference resolution options\n */\nexport type LexDefBuilderOptions = RefResolverOptions & {\n /**\n * The module specifier to use for importing the lexicon schema library.\n *\n * @default '@atproto/lex-schema'\n */\n lib?: string\n /**\n * Whether to add `#__PURE__` annotations to function calls.\n *\n * These annotations help bundlers with tree-shaking by marking\n * side-effect-free function calls.\n *\n * @default false\n */\n pureAnnotations?: boolean\n}\n\n/**\n * Builds TypeScript type definitions and runtime schemas from a single\n * Lexicon document.\n *\n * This class is responsible for generating the `.defs.ts` files that contain:\n * - Type aliases for each lexicon definition\n * - Runtime schema validators using `@atproto/lex-schema`\n * - Utility functions for type checking and validation\n * - Proper import statements for cross-references\n *\n * Each lexicon definition type (record, object, query, procedure, etc.)\n * is handled with specialized code generation logic.\n */\nexport class LexDefBuilder {\n private readonly refResolver: RefResolver\n\n constructor(\n private readonly options: LexDefBuilderOptions,\n private readonly file: SourceFile,\n private readonly doc: LexiconDocument,\n indexer: LexiconIndexer,\n ) {\n this.refResolver = new RefResolver(doc, file, indexer, options)\n }\n\n private pure(code: string) {\n return this.options.pureAnnotations ? markPure(code) : code\n }\n\n async build() {\n this.file.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n { name: '$nsid', initializer: JSON.stringify(this.doc.id) },\n ],\n })\n\n this.file.addExportDeclaration({\n namedExports: [{ name: '$nsid' }],\n })\n\n const defs = Object.keys(this.doc.defs)\n if (defs.length) {\n const moduleSpecifier = this.options?.lib ?? '@atproto/lex-schema'\n this.file\n .addImportDeclaration({ moduleSpecifier })\n .addNamedImports([{ name: 'l' }])\n\n for (const hash of defs) {\n await this.addDef(hash)\n }\n }\n }\n\n private addUtils(definitions: Record<string, undefined | string>) {\n for (const [name, initializer] of Object.entries(definitions)) {\n if (initializer == null) continue\n\n this.file.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [{ name, initializer }],\n })\n }\n }\n\n private async addDef(hash: string) {\n const def = Object.hasOwn(this.doc.defs, hash) ? this.doc.defs[hash] : null\n if (def == null) return\n\n switch (def.type) {\n case 'permission-set':\n return this.addPermissionSet(hash, def)\n case 'procedure':\n return this.addProcedure(hash, def)\n case 'query':\n return this.addQuery(hash, def)\n case 'subscription':\n return this.addSubscription(hash, def)\n case 'record':\n return this.addRecord(hash, def)\n case 'token':\n return this.addToken(hash, def)\n case 'object':\n return this.addObject(hash, def)\n case 'array':\n return this.addArray(hash, def)\n default:\n await this.addSchema(hash, def, {\n type: await this.compileContainedType(def),\n schema: await this.compileContainedSchema(def),\n validationUtils: true,\n })\n }\n }\n\n private async addPermissionSet(hash: string, def: LexiconPermissionSet) {\n const permission = def.permissions.map((def) => {\n const options = stringifyOptions(def, undefined, ['resource', 'type'])\n return this.pure(\n `l.permission(${JSON.stringify(def.resource)}, ${options})`,\n )\n })\n\n const options = stringifyOptions(def, [\n 'title',\n 'title:lang',\n 'detail',\n 'detail:lang',\n ] satisfies (keyof l.PermissionSetOptions)[])\n\n await this.addSchema(hash, def, {\n schema: this.pure(\n `l.permissionSet($nsid, [${permission.join(',')}], ${options})`,\n ),\n })\n }\n\n private async addProcedure(hash: string, def: LexiconProcedure) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n // @TODO Build the types instead of using an inferred type.\n\n // Declare each piece of the method as its own top-level exported const\n // *before* `main`, so consumers that import a single helper (e.g.\n // `$lxm`) only pull in that subtree rather than the whole procedure.\n // `main.parameters` etc. would otherwise pin `main` in the module graph.\n this.addUtils({\n $lxm: '$nsid',\n $params: await this.compileParamsSchema(def.parameters),\n $input: await this.compilePayload(def.input),\n $output: await this.compilePayload(def.output),\n })\n\n const ref = await this.addSchema(hash, def, {\n schema: this.pure(\n `l.procedure($nsid, $params, $input, $output${formatErrorsArg(await this.compileErrors(def.errors))})`,\n ),\n })\n\n this.addMethodTypeUtils(ref, def)\n }\n\n private async addQuery(hash: string, def: LexiconQuery) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n // @TODO Build the types instead of using an inferred type.\n\n this.addUtils({\n $lxm: '$nsid',\n $params: await this.compileParamsSchema(def.parameters),\n $output: await this.compilePayload(def.output),\n })\n\n const ref = await this.addSchema(hash, def, {\n schema: this.pure(\n `l.query($nsid, $params, $output${formatErrorsArg(await this.compileErrors(def.errors))})`,\n ),\n })\n\n this.addMethodTypeUtils(ref, def)\n }\n\n private async addSubscription(hash: string, def: LexiconSubscription) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n // @TODO Build the types instead of using an inferred type.\n\n this.addUtils({\n $lxm: '$nsid',\n $params: await this.compileParamsSchema(def.parameters),\n $message: await this.compileBodySchema(def.message?.schema),\n })\n\n const ref = await this.addSchema(hash, def, {\n schema: this.pure(\n `l.subscription($nsid, $params, $message${formatErrorsArg(await this.compileErrors(def.errors))})`,\n ),\n })\n\n this.addMethodTypeUtils(ref, def)\n }\n\n addMethodTypeUtils(\n ref: ResolvedRef,\n def: LexiconProcedure | LexiconQuery | LexiconSubscription,\n ) {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Params',\n type: `l.InferMethodParams<typeof ${ref.varName}>`,\n docs: compileDocs(def.parameters?.description),\n })\n\n if (def.type === 'procedure') {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Input<B = l.BinaryData>',\n type: `l.InferMethodInput<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.input?.description),\n })\n\n this.file.addTypeAlias({\n isExported: true,\n name: '$InputBody<B = l.BinaryData>',\n type: `l.InferMethodInputBody<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.input?.description),\n })\n }\n\n if (def.type === 'procedure' || def.type === 'query') {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Output<B = l.BinaryData>',\n type: `l.InferMethodOutput<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.output?.description),\n })\n\n this.file.addTypeAlias({\n isExported: true,\n name: '$OutputBody<B = l.BinaryData>',\n type: `l.InferMethodOutputBody<typeof ${ref.varName}, B>`,\n docs: compileDocs(def.output?.description),\n })\n }\n\n if (def.type === 'subscription') {\n this.file.addTypeAlias({\n isExported: true,\n name: '$Message',\n type: `l.InferSubscriptionMessage<typeof ${ref.varName}>`,\n docs: compileDocs(def.message?.description),\n })\n }\n }\n\n private async addRecord(hash: string, def: LexiconRecord) {\n if (hash !== 'main') {\n throw new Error(`Definition ${hash} cannot be of type ${def.type}`)\n }\n\n const key = JSON.stringify(def.key ?? 'any')\n const objectSchema = await this.compileObjectSchema(def.record)\n\n const properties = await this.compilePropertiesTypes(def.record)\n properties.unshift(`$type: ${JSON.stringify(l.$type(this.doc.id, hash))}`)\n\n await this.addSchema(hash, def, {\n type: `{ ${properties.join(';')} }`,\n schema: (ref) =>\n this.pure(\n `l.record<${key}, ${ref.typeName}>(${key}, $nsid, ${objectSchema})`,\n ),\n objectUtils: true,\n validationUtils: true,\n })\n }\n\n private async addObject(hash: string, def: LexiconObject) {\n const objectSchema = await this.compileObjectSchema(def)\n\n const properties = await this.compilePropertiesTypes(def)\n properties.unshift(`$type?: ${JSON.stringify(l.$type(this.doc.id, hash))}`)\n\n await this.addSchema(hash, def, {\n type: `{ ${properties.join(';')} }`,\n schema: (ref) =>\n this.pure(\n `l.typedObject<${ref.typeName}>($nsid, ${JSON.stringify(hash)}, ${objectSchema})`,\n ),\n objectUtils: true,\n validationUtils: true,\n })\n }\n\n private async addToken(hash: string, def: LexiconToken) {\n await this.addSchema(hash, def, {\n schema: this.pure(`l.token($nsid, ${JSON.stringify(hash)})`),\n type: JSON.stringify(l.$type(this.doc.id, hash)),\n validationUtils: true,\n })\n }\n\n private async addArray(hash: string, def: LexiconArray) {\n // @TODO It could be nice to expose the array item type as a separate type.\n // This was not done (yet) as there is no easy way to name it to avoid\n // collisions.\n\n const itemSchema = await this.compileContainedSchema(def.items)\n const options = stringifyOptions(def, [\n 'minLength',\n 'maxLength',\n ] satisfies (keyof l.ArraySchemaOptions)[])\n\n await this.addSchema(hash, def, {\n type: `(${await this.compileContainedType(def.items)})[]`,\n // @NOTE Not using compileArraySchema to allow specifying the generic\n // parameter to l.array<>.\n schema: (ref) =>\n this.pure(\n `l.array<${ref.typeName}[number]>(${itemSchema}, ${options})`,\n ),\n validationUtils: true,\n })\n }\n\n private async addSchema(\n hash: string,\n def: { description?: string },\n {\n type,\n schema,\n objectUtils,\n validationUtils,\n }: {\n type?: string | ((ref: ResolvedRef) => string)\n schema?: string | ((ref: ResolvedRef) => string)\n objectUtils?: boolean\n validationUtils?: boolean\n },\n ): Promise<ResolvedRef> {\n const ref = await this.refResolver.resolveLocal(hash)\n const pub = getPublicIdentifiers(hash)\n\n if (type) {\n this.file.addTypeAlias({\n name: ref.typeName,\n type: typeof type === 'function' ? type(ref) : type,\n docs: compileDocs(def.description),\n })\n\n this.file.addExportDeclaration({\n isTypeOnly: true,\n namedExports: [\n {\n name: ref.typeName,\n alias:\n ref.typeName === pub.typeName\n ? undefined\n : asNamespaceExport(pub.typeName),\n },\n ],\n })\n }\n\n if (schema) {\n this.file.addVariableStatement({\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: ref.varName,\n initializer: typeof schema === 'function' ? schema(ref) : schema,\n },\n ],\n docs: compileDocs(def.description),\n })\n\n this.file.addExportDeclaration({\n namedExports: [\n {\n name: ref.varName,\n alias:\n ref.varName === pub.varName\n ? undefined\n : asNamespaceExport(pub.varName),\n },\n ],\n })\n }\n\n if (hash === 'main' && objectUtils) {\n this.addUtils({\n $isTypeOf: markPure(`${ref.varName}.isTypeOf.bind(${ref.varName})`),\n $build: markPure(`${ref.varName}.build.bind(${ref.varName})`),\n $type: `${ref.varName}.$type`,\n })\n }\n\n if (hash === 'main' && validationUtils) {\n this.addUtils({\n $assert: markPure(`${ref.varName}.assert.bind(${ref.varName})`),\n $check: markPure(`${ref.varName}.check.bind(${ref.varName})`),\n $cast: markPure(`${ref.varName}.cast.bind(${ref.varName})`),\n $ifMatches: markPure(`${ref.varName}.ifMatches.bind(${ref.varName})`),\n $matches: markPure(`${ref.varName}.matches.bind(${ref.varName})`),\n $parse: markPure(`${ref.varName}.parse.bind(${ref.varName})`),\n $safeParse: markPure(`${ref.varName}.safeParse.bind(${ref.varName})`),\n $validate: markPure(`${ref.varName}.validate.bind(${ref.varName})`),\n $safeValidate: markPure(\n `${ref.varName}.safeValidate.bind(${ref.varName})`,\n ),\n })\n }\n\n return ref\n }\n\n private async compilePayload(def: LexiconPayload | undefined) {\n if (!def) return this.pure(`l.payload()`)\n\n // Special case for JSON object payloads\n if (def.encoding === 'application/json' && def.schema?.type === 'object') {\n const properties = await this.compilePropertiesSchemas(def.schema)\n return this.pure(`l.jsonPayload({${properties.join(',')}})`)\n }\n\n const encodedEncoding = JSON.stringify(def.encoding)\n if (def.schema) {\n const bodySchema = await this.compileBodySchema(def.schema)\n return this.pure(`l.payload(${encodedEncoding}, ${bodySchema})`)\n } else {\n return this.pure(`l.payload(${encodedEncoding})`)\n }\n }\n\n private async compileBodySchema(\n def?: LexiconRef | LexiconRefUnion | LexiconObject,\n ): Promise<string> {\n if (!def) return 'undefined'\n if (def.type === 'object') return this.compileObjectSchema(def)\n return this.compileContainedSchema(def)\n }\n\n private async compileParamsSchema(def: undefined | LexiconParameters) {\n if (!def) return this.pure(`l.params()`)\n\n const properties = await this.compilePropertiesSchemas(def)\n return this.pure(\n properties.length === 0\n ? `l.params()`\n : `l.params({${properties.join(',')}})`,\n )\n }\n\n private async compileErrors(defs?: readonly LexiconError[]) {\n if (!defs?.length) return ''\n return JSON.stringify(defs.map((d) => d.name))\n }\n\n private async compileObjectSchema(def: LexiconObject): Promise<string> {\n const properties = await this.compilePropertiesSchemas(def)\n return this.pure(`l.object({${properties.join(',')}})`)\n }\n\n private async compilePropertiesSchemas(options: {\n properties: Record<string, LexiconArray | LexiconArrayItems>\n required?: readonly string[]\n nullable?: readonly string[]\n }): Promise<string[]> {\n for (const opt of ['required', 'nullable'] as const) {\n if (options[opt]) {\n for (const prop of options[opt]) {\n if (!Object.hasOwn(options.properties, prop)) {\n throw new Error(`No schema found for ${opt} property \"${prop}\"`)\n }\n }\n }\n }\n\n return Promise.all(\n Object.entries(options.properties).map((entry) => {\n return this.compilePropertyEntrySchema(entry, options)\n }),\n )\n }\n\n private async compilePropertiesTypes(options: {\n properties: Record<string, LexiconArray | LexiconArrayItems>\n required?: readonly string[]\n nullable?: readonly string[]\n }) {\n return Promise.all(\n Object.entries(options.properties).map((entry) => {\n return this.compilePropertyEntryType(entry, options)\n }),\n )\n }\n\n private async compilePropertyEntrySchema(\n [key, def]: [string, LexiconArray | LexiconArrayItems],\n options: {\n required?: readonly string[]\n nullable?: readonly string[]\n },\n ) {\n const isNullable = options.nullable?.includes(key)\n const isRequired = options.required?.includes(key)\n\n let schema = await this.compileContainedSchema(def)\n\n if (isNullable) {\n schema = this.pure(`l.nullable(${schema})`)\n }\n\n if (!isRequired) {\n schema = this.pure(`l.optional(${schema})`)\n }\n\n return `${JSON.stringify(key)}:${schema}`\n }\n\n private async compilePropertyEntryType(\n [key, def]: [string, LexiconArray | LexiconArrayItems],\n options: {\n required?: readonly string[]\n nullable?: readonly string[]\n },\n ) {\n const isNullable = options.nullable?.includes(key)\n const isRequired = options.required?.includes(key)\n\n const optional = isRequired ? '' : '?'\n const append = isNullable ? ' | null' : ''\n\n const jsDoc = compileLeadingTrivia(def.description) || ''\n const name = JSON.stringify(key)\n const type = await this.compileContainedType(def)\n\n return `${jsDoc}${name}${optional}:${type}${append}`\n }\n\n private async compileContainedSchema(\n def: LexiconArray | LexiconArrayItems,\n ): Promise<string> {\n switch (def.type) {\n case 'unknown':\n return this.compileUnknownSchema(def)\n case 'boolean':\n return this.compileBooleanSchema(def)\n case 'integer':\n return this.compileIntegerSchema(def)\n case 'string':\n return this.compileStringSchema(def)\n case 'bytes':\n return this.compileBytesSchema(def)\n case 'blob':\n return this.compileBlobSchema(def)\n case 'cid-link':\n return this.compileCidLinkSchema(def)\n case 'ref':\n return this.compileRefSchema(def)\n case 'union':\n return this.compileRefUnionSchema(def)\n case 'array':\n return this.compileArraySchema(def)\n default:\n // @ts-expect-error\n throw new Error(`Unsupported def type: ${def.type}`)\n }\n }\n\n private async compileContainedType(\n def: LexiconArray | LexiconArrayItems,\n ): Promise<string> {\n switch (def.type) {\n case 'unknown':\n return this.compileUnknownType(def)\n case 'boolean':\n return this.compileBooleanType(def)\n case 'integer':\n return this.compileIntegerType(def)\n case 'string':\n return this.compileStringType(def)\n case 'bytes':\n return this.compileBytesType(def)\n case 'blob':\n return this.compileBlobType(def)\n case 'cid-link':\n return this.compileCidLinkType(def)\n case 'ref':\n return this.compileRefType(def)\n case 'union':\n return this.compileRefUnionType(def)\n case 'array':\n return this.compileArrayType(def)\n default:\n // @ts-expect-error\n throw new Error(`Unsupported def type: ${def.type}`)\n }\n }\n\n private async compileArraySchema(def: LexiconArray): Promise<string> {\n const itemSchema = await this.compileContainedSchema(def.items)\n const options = stringifyOptions(def, [\n 'minLength',\n 'maxLength',\n ] satisfies (keyof l.ArraySchemaOptions)[])\n return this.pure(`l.array(${itemSchema}, ${options})`)\n }\n\n private async compileArrayType(def: LexiconArray): Promise<string> {\n return `(${await this.compileContainedType(def.items)})[]`\n }\n\n private async compileUnknownSchema(_def: LexiconUnknown): Promise<string> {\n return this.pure(`l.lexMap()`)\n }\n\n private async compileUnknownType(_def: LexiconUnknown): Promise<string> {\n return `l.LexMap`\n }\n\n private withDefault(schema: string, defaultValue: unknown) {\n if (defaultValue === undefined) return schema\n\n return this.pure(\n `l.withDefault(${schema}, ${JSON.stringify(defaultValue)})`,\n )\n }\n\n private async compileBooleanSchema(def: LexiconBoolean): Promise<string> {\n const schema = l.boolean()\n\n if (def.default !== undefined) {\n schema.check(def.default)\n }\n\n if (hasConst(def)) return this.compileConstSchema(def)\n\n return this.withDefault(this.pure(`l.boolean()`), def.default)\n }\n\n private async compileBooleanType(def: LexiconBoolean): Promise<string> {\n if (hasConst(def)) return this.compileConstType(def)\n return 'boolean'\n }\n\n private async compileIntegerSchema(def: LexiconInteger): Promise<string> {\n const schema = l.integer(def)\n\n if (hasConst(def)) {\n schema.check(def.const)\n }\n\n if (hasEnum(def)) {\n for (const val of def.enum) schema.check(val)\n }\n\n if (def.default !== undefined) {\n schema.check(def.default)\n }\n\n if (hasConst(def)) return this.compileConstSchema(def)\n if (hasEnum(def)) return this.compileEnumSchema(def)\n\n const options = stringifyOptions(def, [\n 'maximum',\n 'minimum',\n ] satisfies (keyof l.IntegerSchemaOptions)[])\n\n return this.withDefault(this.pure(`l.integer(${options})`), def.default)\n }\n\n private async compileIntegerType(def: LexiconInteger): Promise<string> {\n if (hasConst(def)) return this.compileConstType(def)\n if (hasEnum(def)) return this.compileEnumType(def)\n\n return 'number'\n }\n\n private async compileStringSchema(def: LexiconString): Promise<string> {\n const schema = l.string(def)\n\n if (hasConst(def)) {\n schema.check(def.const)\n }\n\n if (hasEnum(def)) {\n for (const val of def.enum) schema.check(val)\n }\n\n if (def.default !== undefined) {\n schema.check(def.default)\n }\n\n if (hasConst(def)) return this.compileConstSchema(def)\n if (hasEnum(def)) return this.compileEnumSchema(def)\n\n const runtimeOptions = [\n 'format',\n 'maxGraphemes',\n 'minGraphemes',\n 'maxLength',\n 'minLength',\n // We don't want to include knownValues in the schema options **at\n // runtime** as it has no effect and only causes bloat:\n // \"knownValues\",\n ] as const satisfies (keyof l.StringSchemaOptions)[]\n\n const options = stringifyOptions(def, runtimeOptions)\n\n // We *do* however need knownValues for the inferred type, so we include it\n // as the generic parameter. We only do this if the def has knownValues,\n // otherwise we let TypeScript infer the options generic by not defining it.\n const generic = def.knownValues\n ? stringifyOptions(def, [\n ...runtimeOptions,\n 'knownValues',\n ] satisfies (keyof l.StringSchemaOptions)[])\n : undefined\n\n return this.withDefault(\n this.pure(`l.string${generic ? `<${generic}>` : ''}(${options})`),\n def.default,\n )\n }\n\n private async compileStringType(def: LexiconString): Promise<string> {\n if (hasConst(def)) return this.compileConstType(def)\n if (hasEnum(def)) return this.compileEnumType(def)\n\n switch (def.format) {\n case undefined:\n break\n case 'datetime':\n return 'l.DatetimeString'\n case 'uri':\n return 'l.UriString'\n case 'at-uri':\n return 'l.AtUriString'\n case 'did':\n return 'l.DidString'\n case 'handle':\n return 'l.HandleString'\n case 'at-identifier':\n return 'l.AtIdentifierString'\n case 'nsid':\n return 'l.NsidString'\n case 'tid':\n return 'l.TidString'\n case 'cid':\n return 'l.CidString'\n case 'language':\n return 'l.LanguageString'\n case 'record-key':\n return 'l.RecordKeyString'\n default:\n throw new Error(`Unknown string format: ${def.format}`)\n }\n\n if (def.knownValues?.length) {\n return (\n def.knownValues.map((v) => JSON.stringify(v)).join(' | ') +\n ' | l.UnknownString'\n )\n }\n\n return 'string'\n }\n\n private async compileBytesSchema(def: LexiconBytes): Promise<string> {\n const options = stringifyOptions(def, [\n 'minLength',\n 'maxLength',\n ] satisfies (keyof l.BytesSchemaOptions)[])\n return this.pure(`l.bytes(${options})`)\n }\n\n private async compileBytesType(_def: LexiconBytes): Promise<string> {\n return 'Uint8Array'\n }\n\n private async compileBlobSchema(def: LexiconBlob): Promise<string> {\n const options = stringifyOptions(def, [\n 'maxSize',\n 'accept',\n ] satisfies (keyof l.BlobSchemaOptions)[])\n return this.pure(`l.blob(${options})`)\n }\n\n private async compileBlobType(_def: LexiconBlob): Promise<string> {\n return 'l.BlobRef'\n }\n\n private async compileCidLinkSchema(_def: LexiconCid): Promise<string> {\n return this.pure(`l.cid()`)\n }\n\n private async compileCidLinkType(_def: LexiconCid): Promise<string> {\n return 'l.Cid'\n }\n\n private async compileRefSchema(def: LexiconRef): Promise<string> {\n const { varName, typeName } = await this.refResolver.resolve(def.ref)\n // @NOTE \"as any\" is needed in schemas with circular refs as TypeScript\n // cannot infer the type of a value that depends on its initializer type\n return this.pure(`l.ref<${typeName}>((() => ${varName}) as any)`)\n }\n\n private async compileRefType(def: LexiconRef): Promise<string> {\n const ref = await this.refResolver.resolve(def.ref)\n return ref.typeName\n }\n\n private async compileRefUnionSchema(def: LexiconRefUnion): Promise<string> {\n if (def.refs.length === 0 && def.closed) {\n return this.pure(`l.never()`)\n }\n\n const refs = await Promise.all(\n def.refs.map(async (ref: string) => {\n const { varName, typeName } = await this.refResolver.resolve(ref)\n // @NOTE \"as any\" is needed in schemas with circular refs as TypeScript\n // cannot infer the type of a value that depends on its initializer type\n return this.pure(`l.typedRef<${typeName}>((() => ${varName}) as any)`)\n }),\n )\n\n return this.pure(\n `l.typedUnion([${refs.join(',')}], ${def.closed ?? false})`,\n )\n }\n\n private async compileRefUnionType(def: LexiconRefUnion): Promise<string> {\n const types = await Promise.all(\n def.refs.map(async (ref) => {\n const { typeName } = await this.refResolver.resolve(ref)\n return `l.$Typed<${typeName}>`\n }),\n )\n if (!def.closed) types.push('l.Unknown$TypedObject')\n return types.join(' | ') || 'never'\n }\n\n private async compileConstSchema<\n T extends null | number | string | boolean,\n >(def: { const: T; enum?: readonly T[]; default?: T }): Promise<string> {\n if (hasEnum(def) && !def.enum.includes(def.const)) {\n return this.pure(`l.never()`)\n }\n\n const result = this.pure(`l.literal(${JSON.stringify(def.const)})`)\n\n return this.withDefault(result, def.default)\n }\n\n private async compileConstType<\n T extends null | number | string | boolean,\n >(def: { const: T; enum?: readonly T[] }): Promise<string> {\n if (hasEnum(def) && !def.enum.includes(def.const)) {\n return 'never'\n }\n return JSON.stringify(def.const)\n }\n\n private async compileEnumSchema<T extends null | number | string>(def: {\n enum: readonly T[]\n default?: T\n }): Promise<string> {\n if (def.enum.length === 0) {\n return this.pure(`l.never()`)\n }\n\n const result =\n def.enum.length === 1\n ? this.pure(`l.literal(${JSON.stringify(def.enum[0])})`)\n : this.pure(`l.enum(${JSON.stringify(def.enum)})`)\n\n return this.withDefault(result, def.default)\n }\n\n private async compileEnumType<T extends null | number | string>(def: {\n enum: readonly T[]\n }): Promise<string> {\n return def.enum.map((v) => JSON.stringify(v)).join(' | ') || 'never'\n }\n}\n\ntype ParsedDescription = OptionalKind<JSDocStructure> & {\n description?: string\n tags?: { tagName: string; text?: string }[]\n}\n\nfunction parseDescription(description: string): ParsedDescription {\n if (/deprecated/i.test(description)) {\n const deprecationMatch = description.match(\n /(\\s*deprecated\\s*(?:--?|:)?\\s*([^-]*)(?:-+)?)/i,\n )\n if (deprecationMatch) {\n const { 1: match, 2: deprecationNotice } = deprecationMatch\n return {\n description: description.replace(match, '').trim() || undefined,\n tags: [{ tagName: 'deprecated', text: deprecationNotice?.trim() }],\n }\n } else {\n return {\n description: description.trim() || undefined,\n tags: [{ tagName: 'deprecated' }],\n }\n }\n }\n\n return {\n description: description.trim() || undefined,\n }\n}\n\nfunction compileLeadingTrivia(description?: string) {\n if (!description) return undefined\n const parsed = parseDescription(description)\n if (!parsed.description && !parsed.tags?.length) return undefined\n const tags = parsed.tags\n ?.map(({ tagName, text }) => (text ? `@${tagName} ${text}` : `@${tagName}`))\n ?.join('\\n')\n const text = `\\n${[parsed.description, tags].filter(Boolean).join('\\n\\n')}`\n return `\\n\\n/**${text.replaceAll('\\n', '\\n * ')}\\n */\\n`\n}\n\nfunction compileDocs(description?: string) {\n if (!description) return undefined\n return [parseDescription(description)]\n}\n\nfunction stringifyOptions<O extends Record<string, unknown>>(\n obj: O,\n include?: (keyof O)[],\n exclude?: (keyof O)[],\n) {\n const filtered = Object.entries(obj).filter(\n ([k]) => (!include || include.includes(k)) && !exclude?.includes(k),\n )\n return filtered.length ? JSON.stringify(Object.fromEntries(filtered)) : ''\n}\n\nfunction hasConst<T extends { const?: unknown }>(\n def: T,\n): def is T & { const: NonNullable<T['const']> } {\n return def.const != null\n}\n\nfunction hasEnum<T extends { enum?: readonly unknown[] }>(\n def: T,\n): def is T & { enum: unknown[] } {\n return def.enum != null\n}\n\nfunction markPure<T extends string>(v: T): `/*#__PURE__*/ ${T}` {\n return `/*#__PURE__*/ ${v}`\n}\n\nfunction formatErrorsArg(errors: string) {\n return errors ? `, ${errors}` : ''\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atproto/lex-builder",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=22"
|
|
6
6
|
},
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"prettier": "^3.2.5",
|
|
39
39
|
"ts-morph": "^27.0.0",
|
|
40
40
|
"tslib": "^2.8.1",
|
|
41
|
-
"@atproto/lex-
|
|
42
|
-
"@atproto/lex-
|
|
41
|
+
"@atproto/lex-document": "^0.1.0",
|
|
42
|
+
"@atproto/lex-schema": "^0.1.1"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@ts-morph/common": "^0.28.0",
|
package/src/lex-def-builder.ts
CHANGED
|
@@ -116,17 +116,13 @@ export class LexDefBuilder {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
private addUtils(definitions: Record<string, undefined | string>) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (entries.length) {
|
|
119
|
+
for (const [name, initializer] of Object.entries(definitions)) {
|
|
120
|
+
if (initializer == null) continue
|
|
121
|
+
|
|
123
122
|
this.file.addVariableStatement({
|
|
124
123
|
isExported: true,
|
|
125
124
|
declarationKind: VariableDeclarationKind.Const,
|
|
126
|
-
declarations:
|
|
127
|
-
name,
|
|
128
|
-
initializer,
|
|
129
|
-
})),
|
|
125
|
+
declarations: [{ name, initializer }],
|
|
130
126
|
})
|
|
131
127
|
}
|
|
132
128
|
}
|
|
@@ -190,25 +186,24 @@ export class LexDefBuilder {
|
|
|
190
186
|
|
|
191
187
|
// @TODO Build the types instead of using an inferred type.
|
|
192
188
|
|
|
189
|
+
// Declare each piece of the method as its own top-level exported const
|
|
190
|
+
// *before* `main`, so consumers that import a single helper (e.g.
|
|
191
|
+
// `$lxm`) only pull in that subtree rather than the whole procedure.
|
|
192
|
+
// `main.parameters` etc. would otherwise pin `main` in the module graph.
|
|
193
|
+
this.addUtils({
|
|
194
|
+
$lxm: '$nsid',
|
|
195
|
+
$params: await this.compileParamsSchema(def.parameters),
|
|
196
|
+
$input: await this.compilePayload(def.input),
|
|
197
|
+
$output: await this.compilePayload(def.output),
|
|
198
|
+
})
|
|
199
|
+
|
|
193
200
|
const ref = await this.addSchema(hash, def, {
|
|
194
|
-
schema: this.pure(
|
|
195
|
-
l.procedure(
|
|
196
|
-
|
|
197
|
-
${await this.compileParamsSchema(def.parameters)},
|
|
198
|
-
${await this.compilePayload(def.input)},
|
|
199
|
-
${await this.compilePayload(def.output)},
|
|
200
|
-
${await this.compileErrors(def.errors)}
|
|
201
|
-
)
|
|
202
|
-
`),
|
|
201
|
+
schema: this.pure(
|
|
202
|
+
`l.procedure($nsid, $params, $input, $output${formatErrorsArg(await this.compileErrors(def.errors))})`,
|
|
203
|
+
),
|
|
203
204
|
})
|
|
204
205
|
|
|
205
206
|
this.addMethodTypeUtils(ref, def)
|
|
206
|
-
this.addUtils({
|
|
207
|
-
$lxm: this.pure(`${ref.varName}.nsid`),
|
|
208
|
-
$params: this.pure(`${ref.varName}.parameters`),
|
|
209
|
-
$input: this.pure(`${ref.varName}.input`),
|
|
210
|
-
$output: this.pure(`${ref.varName}.output`),
|
|
211
|
-
})
|
|
212
207
|
}
|
|
213
208
|
|
|
214
209
|
private async addQuery(hash: string, def: LexiconQuery) {
|
|
@@ -218,23 +213,19 @@ export class LexDefBuilder {
|
|
|
218
213
|
|
|
219
214
|
// @TODO Build the types instead of using an inferred type.
|
|
220
215
|
|
|
216
|
+
this.addUtils({
|
|
217
|
+
$lxm: '$nsid',
|
|
218
|
+
$params: await this.compileParamsSchema(def.parameters),
|
|
219
|
+
$output: await this.compilePayload(def.output),
|
|
220
|
+
})
|
|
221
|
+
|
|
221
222
|
const ref = await this.addSchema(hash, def, {
|
|
222
|
-
schema: this.pure(
|
|
223
|
-
l.query(
|
|
224
|
-
|
|
225
|
-
${await this.compileParamsSchema(def.parameters)},
|
|
226
|
-
${await this.compilePayload(def.output)},
|
|
227
|
-
${await this.compileErrors(def.errors)}
|
|
228
|
-
)
|
|
229
|
-
`),
|
|
223
|
+
schema: this.pure(
|
|
224
|
+
`l.query($nsid, $params, $output${formatErrorsArg(await this.compileErrors(def.errors))})`,
|
|
225
|
+
),
|
|
230
226
|
})
|
|
231
227
|
|
|
232
228
|
this.addMethodTypeUtils(ref, def)
|
|
233
|
-
this.addUtils({
|
|
234
|
-
$lxm: this.pure(`${ref.varName}.nsid`),
|
|
235
|
-
$params: `${ref.varName}.parameters`,
|
|
236
|
-
$output: `${ref.varName}.output`,
|
|
237
|
-
})
|
|
238
229
|
}
|
|
239
230
|
|
|
240
231
|
private async addSubscription(hash: string, def: LexiconSubscription) {
|
|
@@ -244,23 +235,19 @@ export class LexDefBuilder {
|
|
|
244
235
|
|
|
245
236
|
// @TODO Build the types instead of using an inferred type.
|
|
246
237
|
|
|
238
|
+
this.addUtils({
|
|
239
|
+
$lxm: '$nsid',
|
|
240
|
+
$params: await this.compileParamsSchema(def.parameters),
|
|
241
|
+
$message: await this.compileBodySchema(def.message?.schema),
|
|
242
|
+
})
|
|
243
|
+
|
|
247
244
|
const ref = await this.addSchema(hash, def, {
|
|
248
|
-
schema: this.pure(
|
|
249
|
-
l.subscription(
|
|
250
|
-
|
|
251
|
-
${await this.compileParamsSchema(def.parameters)},
|
|
252
|
-
${await this.compileBodySchema(def.message?.schema)},
|
|
253
|
-
${await this.compileErrors(def.errors)}
|
|
254
|
-
)
|
|
255
|
-
`),
|
|
245
|
+
schema: this.pure(
|
|
246
|
+
`l.subscription($nsid, $params, $message${formatErrorsArg(await this.compileErrors(def.errors))})`,
|
|
247
|
+
),
|
|
256
248
|
})
|
|
257
249
|
|
|
258
250
|
this.addMethodTypeUtils(ref, def)
|
|
259
|
-
this.addUtils({
|
|
260
|
-
$lxm: this.pure(`${ref.varName}.nsid`),
|
|
261
|
-
$params: `${ref.varName}.parameters`,
|
|
262
|
-
$message: `${ref.varName}.message`,
|
|
263
|
-
})
|
|
264
251
|
}
|
|
265
252
|
|
|
266
253
|
addMethodTypeUtils(
|
|
@@ -454,7 +441,7 @@ export class LexDefBuilder {
|
|
|
454
441
|
this.addUtils({
|
|
455
442
|
$isTypeOf: markPure(`${ref.varName}.isTypeOf.bind(${ref.varName})`),
|
|
456
443
|
$build: markPure(`${ref.varName}.build.bind(${ref.varName})`),
|
|
457
|
-
$type:
|
|
444
|
+
$type: `${ref.varName}.$type`,
|
|
458
445
|
})
|
|
459
446
|
}
|
|
460
447
|
|
|
@@ -1019,3 +1006,7 @@ function hasEnum<T extends { enum?: readonly unknown[] }>(
|
|
|
1019
1006
|
function markPure<T extends string>(v: T): `/*#__PURE__*/ ${T}` {
|
|
1020
1007
|
return `/*#__PURE__*/ ${v}`
|
|
1021
1008
|
}
|
|
1009
|
+
|
|
1010
|
+
function formatErrorsArg(errors: string) {
|
|
1011
|
+
return errors ? `, ${errors}` : ''
|
|
1012
|
+
}
|