@atproto/lex-document 0.1.0 → 0.1.2

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atproto/lex-document
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#5151](https://github.com/bluesky-social/atproto/pull/5151) [`a51c45d`](https://github.com/bluesky-social/atproto/commit/a51c45d38f6bd7b8765f640e564cf921d52162e7) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Update dependencies
8
+
9
+ - Updated dependencies [[`a51c45d`](https://github.com/bluesky-social/atproto/commit/a51c45d38f6bd7b8765f640e564cf921d52162e7)]:
10
+ - @atproto/lex-schema@0.1.5
11
+
12
+ ## 0.1.1
13
+
14
+ ### Patch Changes
15
+
16
+ - [#4967](https://github.com/bluesky-social/atproto/pull/4967) [`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Use TypeScript 7 to build package
17
+
18
+ - Updated dependencies [[`9fc720c`](https://github.com/bluesky-social/atproto/commit/9fc720ce75f3ee88a5e48a9be919b07c7647f6f5)]:
19
+ - @atproto/lex-schema@0.1.4
20
+
3
21
  ## 0.1.0
4
22
 
5
23
  ### Minor Changes
@@ -1414,6 +1414,16 @@ export declare const lexiconProcedureSchema: l.ObjectSchema<{
1414
1414
  * @see {@link lexiconProcedureSchema} for the schema definition
1415
1415
  */
1416
1416
  export type LexiconProcedure = l.Infer<typeof lexiconProcedureSchema>;
1417
+ export declare const lexiconMessageSchema: l.ObjectSchema<{
1418
+ readonly description: l.OptionalSchema<l.StringSchema<{}>>;
1419
+ readonly schema: l.ObjectSchema<{
1420
+ readonly type: l.LiteralSchema<"union">;
1421
+ readonly refs: l.ArraySchema<l.StringSchema<{}>>;
1422
+ readonly closed: l.OptionalSchema<l.BooleanSchema>;
1423
+ readonly description: l.OptionalSchema<l.StringSchema<{}>>;
1424
+ }>;
1425
+ }>;
1426
+ export type LexiconMessage = l.Infer<typeof lexiconMessageSchema>;
1417
1427
  /**
1418
1428
  * Schema for validating Lexicon subscription (WebSocket) method definitions.
1419
1429
  *
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-document.d.ts","sourceRoot":"","sources":["../src/lexicon-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAMvC;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;EAK/B,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;EAQ/B,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;EAY9B,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB;;;;;EAK7B,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB;;;EAG/B,CAAA;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAE7D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB;;;;;EAK5B,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAchC,CAAA;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAA"}
@@ -297,6 +297,10 @@ export const lexiconProcedureSchema = l.object({
297
297
  errors: l.optional(l.array(lexiconError)),
298
298
  description: l.optional(l.string()),
299
299
  });
300
+ export const lexiconMessageSchema = l.object({
301
+ description: l.optional(l.string()),
302
+ schema: lexiconRefUnionSchema,
303
+ });
300
304
  /**
301
305
  * Schema for validating Lexicon subscription (WebSocket) method definitions.
302
306
  *
@@ -308,10 +312,7 @@ export const lexiconSubscriptionSchema = l.object({
308
312
  type: l.literal('subscription'),
309
313
  description: l.optional(l.string()),
310
314
  parameters: l.optional(lexiconParameters),
311
- message: l.object({
312
- description: l.optional(l.string()),
313
- schema: lexiconRefUnionSchema,
314
- }),
315
+ message: lexiconMessageSchema,
315
316
  errors: l.optional(l.array(lexiconError)),
316
317
  });
317
318
  // Permissions
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-document.js","sourceRoot":"","sources":["../src/lexicon-document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAEvC,oCAAoC;AAEpC,mBAAmB;AAEnB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9B,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACpC,CAAC,CAAA;AAYF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAChC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;IACtC,KAAK,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9B,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC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B,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAWnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,EAAE,EAAE,uBAAuB;IAC3B,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,YAAY,CAClB,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;KACrE,CAAC,EACF,CAAC,CAAC,IAAI,CACJ,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAC1B,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CACpD,CACF;CACF,CAAC,CAAA","sourcesContent":["import { l } from '@atproto/lex-schema'\n\n// https://atproto.com/specs/lexicon\n\n// \"Concrete\" Types\n\n/**\n * Schema for validating Lexicon boolean type definitions.\n *\n * Validates boolean field definitions that may include a default value,\n * a constant value, and an optional description.\n */\nexport const lexiconBooleanSchema = l.object({\n type: l.literal('boolean'),\n default: l.optional(l.boolean()),\n const: l.optional(l.boolean()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon boolean definition.\n *\n * Represents the structure of a boolean field in a Lexicon document,\n * including optional default, const, and description properties.\n *\n * @see {@link lexiconBooleanSchema} for the schema definition\n */\nexport type LexiconBoolean = l.Infer<typeof lexiconBooleanSchema>\n\n/**\n * Schema for validating Lexicon integer type definitions.\n *\n * Validates integer field definitions with support for default values,\n * minimum/maximum constraints, enumerated values, and constant values.\n */\nexport const lexiconIntegerSchema = l.object({\n type: l.literal('integer'),\n default: l.optional(l.integer()),\n minimum: l.optional(l.integer()),\n maximum: l.optional(l.integer()),\n enum: l.optional(l.array(l.integer())),\n const: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon integer definition.\n *\n * Represents the structure of an integer field in a Lexicon document,\n * including optional constraints like minimum, maximum, enum, and const.\n *\n * @see {@link lexiconIntegerSchema} for the schema definition\n */\nexport type LexiconInteger = l.Infer<typeof lexiconIntegerSchema>\n\n/**\n * Schema for validating Lexicon string type definitions.\n *\n * Validates string field definitions with support for format validation,\n * length constraints (both character and grapheme-based), enumerated values,\n * known values, and constant values.\n */\nexport const lexiconStringSchema = l.object({\n type: l.literal('string'),\n format: l.optional(l.enum<l.StringFormat>(l.STRING_FORMATS)),\n default: l.optional(l.string()),\n minLength: l.optional(l.integer()),\n maxLength: l.optional(l.integer()),\n minGraphemes: l.optional(l.integer()),\n maxGraphemes: l.optional(l.integer()),\n enum: l.optional(l.array(l.string())),\n const: l.optional(l.string()),\n knownValues: l.optional(l.array(l.string())),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon string definition.\n *\n * Represents the structure of a string field in a Lexicon document,\n * including optional format, length constraints, enum, const, and knownValues.\n *\n * @see {@link lexiconStringSchema} for the schema definition\n */\nexport type LexiconString = l.Infer<typeof lexiconStringSchema>\n\n/**\n * Schema for validating Lexicon bytes type definitions.\n *\n * Validates binary data field definitions with optional length constraints.\n * Used for raw byte arrays in DAG-CBOR encoding.\n */\nexport const lexiconBytesSchema = l.object({\n type: l.literal('bytes'),\n maxLength: l.optional(l.integer()),\n minLength: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon bytes definition.\n *\n * Represents the structure of a binary data field in a Lexicon document,\n * including optional minLength and maxLength constraints.\n *\n * @see {@link lexiconBytesSchema} for the schema definition\n */\nexport type LexiconBytes = l.Infer<typeof lexiconBytesSchema>\n\n/**\n * Schema for validating Lexicon CID link type definitions.\n *\n * Validates Content Identifier (CID) link field definitions.\n * CIDs are used to reference content-addressed data in IPFS/IPLD.\n */\nexport const lexiconCidLinkSchema = l.object({\n type: l.literal('cid-link'),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon CID link definition.\n *\n * Represents the structure of a CID link field in a Lexicon document.\n *\n * @see {@link lexiconCidLinkSchema} for the schema definition\n */\nexport type LexiconCid = l.Infer<typeof lexiconCidLinkSchema>\n\n/**\n * Schema for validating Lexicon blob type definitions.\n *\n * Validates blob field definitions with optional MIME type acceptance list\n * and maximum size constraints. Blobs represent uploaded file references.\n */\nexport const lexiconBlobSchema = l.object({\n type: l.literal('blob'),\n accept: l.optional(l.array(l.string())),\n maxSize: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon blob definition.\n *\n * Represents the structure of a blob field in a Lexicon document,\n * including optional accept list and maxSize constraints.\n *\n * @see {@link lexiconBlobSchema} for the schema definition\n */\nexport type LexiconBlob = l.Infer<typeof lexiconBlobSchema>\n\n/**\n * Array of all concrete (primitive) Lexicon type schemas.\n * Includes boolean, integer, string, bytes, cid-link, and blob types.\n */\nconst CONCRETE_TYPES = [\n lexiconBooleanSchema,\n lexiconIntegerSchema,\n lexiconStringSchema,\n // Lexicon (DAG-CBOR)\n lexiconBytesSchema,\n lexiconCidLinkSchema,\n // Lexicon Specific\n lexiconBlobSchema,\n] as const\n\n// Meta types\n\n/**\n * Schema for validating Lexicon unknown type definitions.\n *\n * Validates unknown field definitions which accept any valid data.\n * Used when the schema cannot determine the type ahead of time.\n */\nexport const lexiconUnknownSchema = l.object({\n type: l.literal('unknown'),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon unknown definition.\n *\n * Represents the structure of an unknown field in a Lexicon document.\n *\n * @see {@link lexiconUnknownSchema} for the schema definition\n */\nexport type LexiconUnknown = l.Infer<typeof lexiconUnknownSchema>\n\n/**\n * Schema for validating Lexicon token type definitions.\n *\n * Validates token definitions which represent symbolic constants.\n * Tokens are used to define enumeration-like values that can be\n * referenced across different lexicons.\n */\nexport const lexiconTokenSchema = l.object({\n type: l.literal('token'),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon token definition.\n *\n * Represents the structure of a token in a Lexicon document.\n *\n * @see {@link lexiconTokenSchema} for the schema definition\n */\nexport type LexiconToken = l.Infer<typeof lexiconTokenSchema>\n\n/**\n * Schema for validating Lexicon reference type definitions.\n *\n * Validates reference definitions which point to other type definitions\n * within the same or different Lexicon documents. References use the\n * format \"nsid#defName\" for cross-document refs or \"#defName\" for local refs.\n */\nexport const lexiconRefSchema = l.object({\n type: l.literal('ref'),\n ref: l.string(),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon reference definition.\n *\n * Represents the structure of a reference field in a Lexicon document,\n * including the ref string pointing to another definition.\n *\n * @see {@link lexiconRefSchema} for the schema definition\n */\nexport type LexiconRef = l.Infer<typeof lexiconRefSchema>\n\n/**\n * Schema for validating Lexicon union reference type definitions.\n *\n * Validates union definitions which can reference multiple possible types.\n * The union can be closed (only listed types allowed) or open (allows\n * additional unlisted types).\n */\nexport const lexiconRefUnionSchema = l.object({\n type: l.literal('union'),\n refs: l.array(l.string()),\n closed: l.optional(l.boolean()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon union reference definition.\n *\n * Represents the structure of a union field in a Lexicon document,\n * including an array of reference strings and optional closed flag.\n *\n * @see {@link lexiconRefUnionSchema} for the schema definition\n */\nexport type LexiconRefUnion = l.Infer<typeof lexiconRefUnionSchema>\n\n// Complex Types\n\nconst ARRAY_ITEMS_SCHEMAS = [\n ...CONCRETE_TYPES,\n // Meta\n lexiconUnknownSchema,\n lexiconRefSchema,\n lexiconRefUnionSchema,\n] as const\n\n/**\n * TypeScript type representing valid item types for Lexicon arrays.\n *\n * Union of all types that can appear as items within a Lexicon array definition.\n */\nexport type LexiconArrayItems = l.Infer<(typeof ARRAY_ITEMS_SCHEMAS)[number]>\n\n/**\n * Schema for validating Lexicon array type definitions.\n *\n * Validates array field definitions with specified item type and\n * optional length constraints.\n */\nexport const lexiconArraySchema = l.object({\n type: l.literal('array'),\n items: l.discriminatedUnion('type', ARRAY_ITEMS_SCHEMAS),\n minLength: l.optional(l.integer()),\n maxLength: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon array definition.\n *\n * Represents the structure of an array field in a Lexicon document,\n * including the items schema and optional length constraints.\n *\n * @see {@link lexiconArraySchema} for the schema definition\n */\nexport type LexiconArray = l.Infer<typeof lexiconArraySchema>\n\nconst requirePropertiesRefinement: l.RefinementCheck<{\n required?: string[]\n properties: Record<string, unknown>\n}> = {\n check: (v) => !v.required || v.required.every((k) => k in v.properties),\n message: 'All required parameters must be defined in properties',\n path: 'required',\n}\n\n/**\n * Schema for validating Lexicon object type definitions.\n *\n * Validates object definitions with named properties, required field lists,\n * and nullable field lists. Includes refinement to ensure all required\n * properties are defined in the properties map.\n */\nexport const lexiconObjectSchema = l.refine(\n l.object({\n type: l.literal('object'),\n properties: l.dict(\n l.string(),\n l.discriminatedUnion('type', [\n ...ARRAY_ITEMS_SCHEMAS,\n lexiconArraySchema,\n ]),\n ),\n required: l.optional(l.array(l.string())),\n nullable: l.optional(l.array(l.string())),\n description: l.optional(l.string()),\n }),\n requirePropertiesRefinement,\n)\n\n/**\n * TypeScript type for a Lexicon object definition.\n *\n * Represents the structure of an object type in a Lexicon document,\n * including properties map, required array, and nullable array.\n *\n * @see {@link lexiconObjectSchema} for the schema definition\n */\nexport type LexiconObject = l.Infer<typeof lexiconObjectSchema>\n\n// Records\n\n/**\n * Schema for validating Lexicon record key definitions.\n *\n * Validates record key type specifications. Valid values are:\n * - \"any\": Any valid record key\n * - \"nsid\": Namespaced identifier\n * - \"tid\": Timestamp identifier\n * - \"literal:<string>\": A specific literal string value\n */\nexport const lexiconRecordKeySchema = l.custom(\n l.isLexiconRecordKey,\n 'Invalid record key definition (must be \"any\", \"nsid\", \"tid\", or \"literal:<string>\")',\n)\n\n/**\n * TypeScript type for valid Lexicon record key values.\n *\n * Can be \"any\", \"nsid\", \"tid\", or \"literal:<string>\".\n *\n * @see {@link lexiconRecordKeySchema} for the schema definition\n */\nexport type LexiconRecordKey = l.LexiconRecordKey\n\n/**\n * Schema for validating Lexicon record type definitions.\n *\n * Validates record definitions which define the structure of data\n * stored in AT Protocol repositories. Records have a key type\n * and an object schema defining the record's data structure.\n */\nexport const lexiconRecordSchema = l.object({\n type: l.literal('record'),\n record: lexiconObjectSchema,\n description: l.optional(l.string()),\n key: lexiconRecordKeySchema,\n})\n\n/**\n * TypeScript type for a Lexicon record definition.\n *\n * Represents the structure of a record type in a Lexicon document,\n * including the key type and the object schema for the record data.\n *\n * @see {@link lexiconRecordSchema} for the schema definition\n */\nexport type LexiconRecord = l.Infer<typeof lexiconRecordSchema>\n\n// XRPC Methods\n\n/**\n * Schema for validating Lexicon XRPC method parameters.\n *\n * Validates the parameters definition for query and procedure methods.\n * Parameters can only be primitive types (boolean, integer, string)\n * or arrays of primitives.\n */\nexport const lexiconParameters = l.refine(\n l.object({\n type: l.literal('params'),\n properties: l.dict(\n l.string(),\n l.discriminatedUnion('type', [\n lexiconBooleanSchema,\n lexiconIntegerSchema,\n lexiconStringSchema,\n l.object({\n type: l.literal('array'),\n items: l.discriminatedUnion('type', [\n lexiconBooleanSchema,\n lexiconIntegerSchema,\n lexiconStringSchema,\n ]),\n minLength: l.optional(l.integer()),\n maxLength: l.optional(l.integer()),\n description: l.optional(l.string()),\n }),\n ]),\n ),\n required: l.optional(l.array(l.string())),\n description: l.optional(l.string()),\n }),\n requirePropertiesRefinement,\n)\n\n/**\n * TypeScript type for Lexicon XRPC method parameters.\n *\n * Represents the structure of parameters for query and procedure methods.\n *\n * @see {@link lexiconParameters} for the schema definition\n */\nexport type LexiconParameters = l.Infer<typeof lexiconParameters>\n\n/**\n * Schema for validating Lexicon XRPC method payloads.\n *\n * Validates input/output payload definitions for procedures and queries.\n * Payloads specify the encoding (MIME type) and optional schema for\n * the request or response body.\n */\nexport const lexiconPayload = l.object({\n encoding: l.refine(l.string(), {\n check: (v) => !v.includes(',') && !v.includes(';') && !v.includes(' '),\n message:\n 'Invalid encoding string (must be a single MIME type without parameters)',\n }),\n schema: l.optional(\n l.discriminatedUnion('type', [\n lexiconRefSchema,\n lexiconRefUnionSchema,\n lexiconObjectSchema,\n ]),\n ),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon XRPC payload definition.\n *\n * Represents the structure of an input or output payload,\n * including encoding type and optional schema.\n *\n * @see {@link lexiconPayload} for the schema definition\n */\nexport type LexiconPayload = l.Infer<typeof lexiconPayload>\n\n/**\n * Schema for validating Lexicon XRPC error definitions.\n *\n * Validates error definitions that can be returned by XRPC methods.\n * Each error has a name and optional description.\n */\nexport const lexiconError = l.object({\n name: l.string({ minLength: 1 }),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon XRPC error definition.\n *\n * Represents an error that can be returned by an XRPC method.\n *\n * @see {@link lexiconError} for the schema definition\n */\nexport type LexiconError = l.Infer<typeof lexiconError>\n\n/**\n * Schema for validating Lexicon query (GET) method definitions.\n *\n * Validates query method definitions which represent read-only HTTP GET\n * operations. Queries can have parameters, an output payload, and\n * defined error types.\n */\nexport const lexiconQuerySchema = l.object({\n type: l.literal('query'),\n parameters: l.optional(lexiconParameters),\n output: l.optional(lexiconPayload),\n errors: l.optional(l.array(lexiconError)),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon query method definition.\n *\n * Represents the structure of an XRPC query (GET) method.\n *\n * @see {@link lexiconQuerySchema} for the schema definition\n */\nexport type LexiconQuery = l.Infer<typeof lexiconQuerySchema>\n\n/**\n * Schema for validating Lexicon procedure (POST) method definitions.\n *\n * Validates procedure method definitions which represent HTTP POST\n * operations that may modify state. Procedures can have parameters,\n * input payload, output payload, and defined error types.\n */\nexport const lexiconProcedureSchema = l.object({\n type: l.literal('procedure'),\n parameters: l.optional(lexiconParameters),\n input: l.optional(lexiconPayload),\n output: l.optional(lexiconPayload),\n errors: l.optional(l.array(lexiconError)),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon procedure method definition.\n *\n * Represents the structure of an XRPC procedure (POST) method.\n *\n * @see {@link lexiconProcedureSchema} for the schema definition\n */\nexport type LexiconProcedure = l.Infer<typeof lexiconProcedureSchema>\n\n/**\n * Schema for validating Lexicon subscription (WebSocket) method definitions.\n *\n * Validates subscription method definitions which represent real-time\n * streaming connections over WebSocket. Subscriptions have parameters,\n * a message schema defining the streamed data format, and error types.\n */\nexport const lexiconSubscriptionSchema = l.object({\n type: l.literal('subscription'),\n description: l.optional(l.string()),\n parameters: l.optional(lexiconParameters),\n message: l.object({\n description: l.optional(l.string()),\n schema: lexiconRefUnionSchema,\n }),\n errors: l.optional(l.array(lexiconError)),\n})\n\n/**\n * TypeScript type for a Lexicon subscription method definition.\n *\n * Represents the structure of an XRPC subscription (WebSocket) method.\n *\n * @see {@link lexiconSubscriptionSchema} for the schema definition\n */\nexport type LexiconSubscription = l.Infer<typeof lexiconSubscriptionSchema>\n\n// Permissions\n\n/**\n * Schema for validating language codes in Lexicon permission definitions.\n */\nexport const lexiconLanguageSchema = l.string({ format: 'language' })\n\n/**\n * TypeScript type for a BCP 47 language code string.\n *\n * @see {@link lexiconLanguageSchema} for the schema definition\n */\nexport type LexiconLanguage = l.Infer<typeof lexiconLanguageSchema>\n\n/**\n * Schema for validating language-keyed string dictionaries.\n * Used for localized text in permission definitions.\n */\nexport const lexiconLanguageDict = l.dict(lexiconLanguageSchema, l.string())\n\n/**\n * TypeScript type for a language-keyed dictionary of localized strings.\n *\n * @see {@link lexiconLanguageDict} for the schema definition\n */\nexport type LexiconLanguageDict = l.Infer<typeof lexiconLanguageDict>\n\n/**\n * Schema for validating individual Lexicon permission definitions.\n */\nexport const lexiconPermissionSchema = l.intersection(\n l.object({\n type: l.literal('permission'),\n resource: l.string({ minLength: 1 }),\n }),\n l.dict(l.string(), l.paramSchema),\n)\n\n/**\n * TypeScript type for a Lexicon permission definition.\n *\n * Represents a single permission with a resource identifier\n * and optional additional parameters.\n *\n * @see {@link lexiconPermissionSchema} for the schema definition\n */\nexport type LexiconPermission = l.Infer<typeof lexiconPermissionSchema>\n\n/**\n * Schema for validating Lexicon permission set definitions.\n */\nexport const lexiconPermissionSetSchema = l.object({\n type: l.literal('permission-set'),\n permissions: l.array(lexiconPermissionSchema),\n title: l.optional(l.string()),\n 'title:lang': l.optional(lexiconLanguageDict),\n detail: l.optional(l.string()),\n 'detail:lang': l.optional(lexiconLanguageDict),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon permission set definition.\n *\n * Represents a collection of permissions with optional\n * localized title and detail text.\n *\n * @see {@link lexiconPermissionSetSchema} for the schema definition\n */\nexport type LexiconPermissionSet = l.Infer<typeof lexiconPermissionSetSchema>\n\nconst NAMED_LEXICON_SCHEMAS = [\n ...CONCRETE_TYPES,\n lexiconArraySchema,\n lexiconObjectSchema,\n lexiconTokenSchema,\n] as const\n\n/**\n * TypeScript type for any named Lexicon definition.\n *\n * Union of all definition types that can appear in the defs section\n * of a Lexicon document (excluding main-only types).\n */\nexport type NamedLexiconDefinition = l.Infer<\n (typeof NAMED_LEXICON_SCHEMAS)[number]\n>\n\nconst MAIN_LEXICON_SCHEMAS = [\n lexiconPermissionSetSchema,\n lexiconProcedureSchema,\n lexiconQuerySchema,\n lexiconRecordSchema,\n lexiconSubscriptionSchema,\n ...NAMED_LEXICON_SCHEMAS,\n] as const\n\n/**\n * TypeScript type for main Lexicon definitions.\n *\n * Union of all definition types that can appear as the \"main\" entry\n * in a Lexicon document's defs section.\n */\nexport type MainLexiconDefinition = l.Infer<\n (typeof MAIN_LEXICON_SCHEMAS)[number]\n>\n\n/**\n * Schema for validating Lexicon document identifiers (NSIDs).\n *\n * Validates that the identifier follows the Namespaced Identifier format\n * (e.g., \"com.atproto.repo.createRecord\").\n */\nexport const lexiconIdentifierSchema = l.string({ format: 'nsid' })\n\n/**\n * TypeScript type for a Lexicon document identifier.\n *\n * A Namespaced Identifier (NSID) string in reverse-domain format.\n *\n * @see {@link lexiconIdentifierSchema} for the schema definition\n */\nexport type LexiconIdentifier = l.Infer<typeof lexiconIdentifierSchema>\n\n/**\n * Schema for validating complete Lexicon document structures.\n *\n * Validates the top-level structure of a Lexicon document, including:\n * - `lexicon`: Must be 1 (the current Lexicon version)\n * - `id`: The document's NSID\n * - `revision`: Optional version number\n * - `description`: Optional document description\n * - `defs`: Map of definition names to their schemas\n *\n * The \"main\" definition (if present) can be any main-only type,\n * while other definitions are limited to named types.\n *\n * @example\n * ```ts\n * const result = lexiconDocumentSchema.parse({\n * lexicon: 1,\n * id: 'com.example.getProfile',\n * defs: {\n * main: {\n * type: 'query',\n * output: {\n * encoding: 'application/json',\n * schema: { type: 'ref', ref: '#profile' }\n * }\n * },\n * profile: {\n * type: 'object',\n * properties: {\n * name: { type: 'string' }\n * }\n * }\n * }\n * })\n * ```\n */\nexport const lexiconDocumentSchema = l.object({\n lexicon: l.literal(1),\n id: lexiconIdentifierSchema,\n revision: l.optional(l.integer()),\n description: l.optional(l.string()),\n defs: l.intersection(\n l.object({\n main: l.optional(l.discriminatedUnion('type', MAIN_LEXICON_SCHEMAS)),\n }),\n l.dict(\n l.string({ minLength: 1 }),\n l.discriminatedUnion('type', NAMED_LEXICON_SCHEMAS),\n ),\n ),\n})\n\n/**\n * TypeScript type for a complete Lexicon document.\n *\n * Represents the full structure of a Lexicon JSON document,\n * including the version, identifier, and all type definitions.\n *\n * @see {@link lexiconDocumentSchema} for the schema definition\n */\nexport type LexiconDocument = l.Infer<typeof lexiconDocumentSchema>\n"]}
1
+ {"version":3,"file":"lexicon-document.js","sourceRoot":"","sources":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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,EAAE,EAAE,uBAAuB;IAC3B,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;IACjC,WAAW,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IACnC,IAAI,EAAE,CAAC,CAAC,YAAY,CAClB,CAAC,CAAC,MAAM,CAAC;QACP,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;KACrE,CAAC,EACF,CAAC,CAAC,IAAI,CACJ,CAAC,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAC1B,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,qBAAqB,CAAC,CACpD,CACF;CACF,CAAC,CAAA","sourcesContent":["import { l } from '@atproto/lex-schema'\n\n// https://atproto.com/specs/lexicon\n\n// \"Concrete\" Types\n\n/**\n * Schema for validating Lexicon boolean type definitions.\n *\n * Validates boolean field definitions that may include a default value,\n * a constant value, and an optional description.\n */\nexport const lexiconBooleanSchema = l.object({\n type: l.literal('boolean'),\n default: l.optional(l.boolean()),\n const: l.optional(l.boolean()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon boolean definition.\n *\n * Represents the structure of a boolean field in a Lexicon document,\n * including optional default, const, and description properties.\n *\n * @see {@link lexiconBooleanSchema} for the schema definition\n */\nexport type LexiconBoolean = l.Infer<typeof lexiconBooleanSchema>\n\n/**\n * Schema for validating Lexicon integer type definitions.\n *\n * Validates integer field definitions with support for default values,\n * minimum/maximum constraints, enumerated values, and constant values.\n */\nexport const lexiconIntegerSchema = l.object({\n type: l.literal('integer'),\n default: l.optional(l.integer()),\n minimum: l.optional(l.integer()),\n maximum: l.optional(l.integer()),\n enum: l.optional(l.array(l.integer())),\n const: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon integer definition.\n *\n * Represents the structure of an integer field in a Lexicon document,\n * including optional constraints like minimum, maximum, enum, and const.\n *\n * @see {@link lexiconIntegerSchema} for the schema definition\n */\nexport type LexiconInteger = l.Infer<typeof lexiconIntegerSchema>\n\n/**\n * Schema for validating Lexicon string type definitions.\n *\n * Validates string field definitions with support for format validation,\n * length constraints (both character and grapheme-based), enumerated values,\n * known values, and constant values.\n */\nexport const lexiconStringSchema = l.object({\n type: l.literal('string'),\n format: l.optional(l.enum<l.StringFormat>(l.STRING_FORMATS)),\n default: l.optional(l.string()),\n minLength: l.optional(l.integer()),\n maxLength: l.optional(l.integer()),\n minGraphemes: l.optional(l.integer()),\n maxGraphemes: l.optional(l.integer()),\n enum: l.optional(l.array(l.string())),\n const: l.optional(l.string()),\n knownValues: l.optional(l.array(l.string())),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon string definition.\n *\n * Represents the structure of a string field in a Lexicon document,\n * including optional format, length constraints, enum, const, and knownValues.\n *\n * @see {@link lexiconStringSchema} for the schema definition\n */\nexport type LexiconString = l.Infer<typeof lexiconStringSchema>\n\n/**\n * Schema for validating Lexicon bytes type definitions.\n *\n * Validates binary data field definitions with optional length constraints.\n * Used for raw byte arrays in DAG-CBOR encoding.\n */\nexport const lexiconBytesSchema = l.object({\n type: l.literal('bytes'),\n maxLength: l.optional(l.integer()),\n minLength: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon bytes definition.\n *\n * Represents the structure of a binary data field in a Lexicon document,\n * including optional minLength and maxLength constraints.\n *\n * @see {@link lexiconBytesSchema} for the schema definition\n */\nexport type LexiconBytes = l.Infer<typeof lexiconBytesSchema>\n\n/**\n * Schema for validating Lexicon CID link type definitions.\n *\n * Validates Content Identifier (CID) link field definitions.\n * CIDs are used to reference content-addressed data in IPFS/IPLD.\n */\nexport const lexiconCidLinkSchema = l.object({\n type: l.literal('cid-link'),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon CID link definition.\n *\n * Represents the structure of a CID link field in a Lexicon document.\n *\n * @see {@link lexiconCidLinkSchema} for the schema definition\n */\nexport type LexiconCid = l.Infer<typeof lexiconCidLinkSchema>\n\n/**\n * Schema for validating Lexicon blob type definitions.\n *\n * Validates blob field definitions with optional MIME type acceptance list\n * and maximum size constraints. Blobs represent uploaded file references.\n */\nexport const lexiconBlobSchema = l.object({\n type: l.literal('blob'),\n accept: l.optional(l.array(l.string())),\n maxSize: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon blob definition.\n *\n * Represents the structure of a blob field in a Lexicon document,\n * including optional accept list and maxSize constraints.\n *\n * @see {@link lexiconBlobSchema} for the schema definition\n */\nexport type LexiconBlob = l.Infer<typeof lexiconBlobSchema>\n\n/**\n * Array of all concrete (primitive) Lexicon type schemas.\n * Includes boolean, integer, string, bytes, cid-link, and blob types.\n */\nconst CONCRETE_TYPES = [\n lexiconBooleanSchema,\n lexiconIntegerSchema,\n lexiconStringSchema,\n // Lexicon (DAG-CBOR)\n lexiconBytesSchema,\n lexiconCidLinkSchema,\n // Lexicon Specific\n lexiconBlobSchema,\n] as const\n\n// Meta types\n\n/**\n * Schema for validating Lexicon unknown type definitions.\n *\n * Validates unknown field definitions which accept any valid data.\n * Used when the schema cannot determine the type ahead of time.\n */\nexport const lexiconUnknownSchema = l.object({\n type: l.literal('unknown'),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon unknown definition.\n *\n * Represents the structure of an unknown field in a Lexicon document.\n *\n * @see {@link lexiconUnknownSchema} for the schema definition\n */\nexport type LexiconUnknown = l.Infer<typeof lexiconUnknownSchema>\n\n/**\n * Schema for validating Lexicon token type definitions.\n *\n * Validates token definitions which represent symbolic constants.\n * Tokens are used to define enumeration-like values that can be\n * referenced across different lexicons.\n */\nexport const lexiconTokenSchema = l.object({\n type: l.literal('token'),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon token definition.\n *\n * Represents the structure of a token in a Lexicon document.\n *\n * @see {@link lexiconTokenSchema} for the schema definition\n */\nexport type LexiconToken = l.Infer<typeof lexiconTokenSchema>\n\n/**\n * Schema for validating Lexicon reference type definitions.\n *\n * Validates reference definitions which point to other type definitions\n * within the same or different Lexicon documents. References use the\n * format \"nsid#defName\" for cross-document refs or \"#defName\" for local refs.\n */\nexport const lexiconRefSchema = l.object({\n type: l.literal('ref'),\n ref: l.string(),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon reference definition.\n *\n * Represents the structure of a reference field in a Lexicon document,\n * including the ref string pointing to another definition.\n *\n * @see {@link lexiconRefSchema} for the schema definition\n */\nexport type LexiconRef = l.Infer<typeof lexiconRefSchema>\n\n/**\n * Schema for validating Lexicon union reference type definitions.\n *\n * Validates union definitions which can reference multiple possible types.\n * The union can be closed (only listed types allowed) or open (allows\n * additional unlisted types).\n */\nexport const lexiconRefUnionSchema = l.object({\n type: l.literal('union'),\n refs: l.array(l.string()),\n closed: l.optional(l.boolean()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon union reference definition.\n *\n * Represents the structure of a union field in a Lexicon document,\n * including an array of reference strings and optional closed flag.\n *\n * @see {@link lexiconRefUnionSchema} for the schema definition\n */\nexport type LexiconRefUnion = l.Infer<typeof lexiconRefUnionSchema>\n\n// Complex Types\n\nconst ARRAY_ITEMS_SCHEMAS = [\n ...CONCRETE_TYPES,\n // Meta\n lexiconUnknownSchema,\n lexiconRefSchema,\n lexiconRefUnionSchema,\n] as const\n\n/**\n * TypeScript type representing valid item types for Lexicon arrays.\n *\n * Union of all types that can appear as items within a Lexicon array definition.\n */\nexport type LexiconArrayItems = l.Infer<(typeof ARRAY_ITEMS_SCHEMAS)[number]>\n\n/**\n * Schema for validating Lexicon array type definitions.\n *\n * Validates array field definitions with specified item type and\n * optional length constraints.\n */\nexport const lexiconArraySchema = l.object({\n type: l.literal('array'),\n items: l.discriminatedUnion('type', ARRAY_ITEMS_SCHEMAS),\n minLength: l.optional(l.integer()),\n maxLength: l.optional(l.integer()),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon array definition.\n *\n * Represents the structure of an array field in a Lexicon document,\n * including the items schema and optional length constraints.\n *\n * @see {@link lexiconArraySchema} for the schema definition\n */\nexport type LexiconArray = l.Infer<typeof lexiconArraySchema>\n\nconst requirePropertiesRefinement: l.RefinementCheck<{\n required?: string[]\n properties: Record<string, unknown>\n}> = {\n check: (v) => !v.required || v.required.every((k) => k in v.properties),\n message: 'All required parameters must be defined in properties',\n path: 'required',\n}\n\n/**\n * Schema for validating Lexicon object type definitions.\n *\n * Validates object definitions with named properties, required field lists,\n * and nullable field lists. Includes refinement to ensure all required\n * properties are defined in the properties map.\n */\nexport const lexiconObjectSchema = l.refine(\n l.object({\n type: l.literal('object'),\n properties: l.dict(\n l.string(),\n l.discriminatedUnion('type', [\n ...ARRAY_ITEMS_SCHEMAS,\n lexiconArraySchema,\n ]),\n ),\n required: l.optional(l.array(l.string())),\n nullable: l.optional(l.array(l.string())),\n description: l.optional(l.string()),\n }),\n requirePropertiesRefinement,\n)\n\n/**\n * TypeScript type for a Lexicon object definition.\n *\n * Represents the structure of an object type in a Lexicon document,\n * including properties map, required array, and nullable array.\n *\n * @see {@link lexiconObjectSchema} for the schema definition\n */\nexport type LexiconObject = l.Infer<typeof lexiconObjectSchema>\n\n// Records\n\n/**\n * Schema for validating Lexicon record key definitions.\n *\n * Validates record key type specifications. Valid values are:\n * - \"any\": Any valid record key\n * - \"nsid\": Namespaced identifier\n * - \"tid\": Timestamp identifier\n * - \"literal:<string>\": A specific literal string value\n */\nexport const lexiconRecordKeySchema = l.custom(\n l.isLexiconRecordKey,\n 'Invalid record key definition (must be \"any\", \"nsid\", \"tid\", or \"literal:<string>\")',\n)\n\n/**\n * TypeScript type for valid Lexicon record key values.\n *\n * Can be \"any\", \"nsid\", \"tid\", or \"literal:<string>\".\n *\n * @see {@link lexiconRecordKeySchema} for the schema definition\n */\nexport type LexiconRecordKey = l.LexiconRecordKey\n\n/**\n * Schema for validating Lexicon record type definitions.\n *\n * Validates record definitions which define the structure of data\n * stored in AT Protocol repositories. Records have a key type\n * and an object schema defining the record's data structure.\n */\nexport const lexiconRecordSchema = l.object({\n type: l.literal('record'),\n record: lexiconObjectSchema,\n description: l.optional(l.string()),\n key: lexiconRecordKeySchema,\n})\n\n/**\n * TypeScript type for a Lexicon record definition.\n *\n * Represents the structure of a record type in a Lexicon document,\n * including the key type and the object schema for the record data.\n *\n * @see {@link lexiconRecordSchema} for the schema definition\n */\nexport type LexiconRecord = l.Infer<typeof lexiconRecordSchema>\n\n// XRPC Methods\n\n/**\n * Schema for validating Lexicon XRPC method parameters.\n *\n * Validates the parameters definition for query and procedure methods.\n * Parameters can only be primitive types (boolean, integer, string)\n * or arrays of primitives.\n */\nexport const lexiconParameters = l.refine(\n l.object({\n type: l.literal('params'),\n properties: l.dict(\n l.string(),\n l.discriminatedUnion('type', [\n lexiconBooleanSchema,\n lexiconIntegerSchema,\n lexiconStringSchema,\n l.object({\n type: l.literal('array'),\n items: l.discriminatedUnion('type', [\n lexiconBooleanSchema,\n lexiconIntegerSchema,\n lexiconStringSchema,\n ]),\n minLength: l.optional(l.integer()),\n maxLength: l.optional(l.integer()),\n description: l.optional(l.string()),\n }),\n ]),\n ),\n required: l.optional(l.array(l.string())),\n description: l.optional(l.string()),\n }),\n requirePropertiesRefinement,\n)\n\n/**\n * TypeScript type for Lexicon XRPC method parameters.\n *\n * Represents the structure of parameters for query and procedure methods.\n *\n * @see {@link lexiconParameters} for the schema definition\n */\nexport type LexiconParameters = l.Infer<typeof lexiconParameters>\n\n/**\n * Schema for validating Lexicon XRPC method payloads.\n *\n * Validates input/output payload definitions for procedures and queries.\n * Payloads specify the encoding (MIME type) and optional schema for\n * the request or response body.\n */\nexport const lexiconPayload = l.object({\n encoding: l.refine(l.string(), {\n check: (v) => !v.includes(',') && !v.includes(';') && !v.includes(' '),\n message:\n 'Invalid encoding string (must be a single MIME type without parameters)',\n }),\n schema: l.optional(\n l.discriminatedUnion('type', [\n lexiconRefSchema,\n lexiconRefUnionSchema,\n lexiconObjectSchema,\n ]),\n ),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon XRPC payload definition.\n *\n * Represents the structure of an input or output payload,\n * including encoding type and optional schema.\n *\n * @see {@link lexiconPayload} for the schema definition\n */\nexport type LexiconPayload = l.Infer<typeof lexiconPayload>\n\n/**\n * Schema for validating Lexicon XRPC error definitions.\n *\n * Validates error definitions that can be returned by XRPC methods.\n * Each error has a name and optional description.\n */\nexport const lexiconError = l.object({\n name: l.string({ minLength: 1 }),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon XRPC error definition.\n *\n * Represents an error that can be returned by an XRPC method.\n *\n * @see {@link lexiconError} for the schema definition\n */\nexport type LexiconError = l.Infer<typeof lexiconError>\n\n/**\n * Schema for validating Lexicon query (GET) method definitions.\n *\n * Validates query method definitions which represent read-only HTTP GET\n * operations. Queries can have parameters, an output payload, and\n * defined error types.\n */\nexport const lexiconQuerySchema = l.object({\n type: l.literal('query'),\n parameters: l.optional(lexiconParameters),\n output: l.optional(lexiconPayload),\n errors: l.optional(l.array(lexiconError)),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon query method definition.\n *\n * Represents the structure of an XRPC query (GET) method.\n *\n * @see {@link lexiconQuerySchema} for the schema definition\n */\nexport type LexiconQuery = l.Infer<typeof lexiconQuerySchema>\n\n/**\n * Schema for validating Lexicon procedure (POST) method definitions.\n *\n * Validates procedure method definitions which represent HTTP POST\n * operations that may modify state. Procedures can have parameters,\n * input payload, output payload, and defined error types.\n */\nexport const lexiconProcedureSchema = l.object({\n type: l.literal('procedure'),\n parameters: l.optional(lexiconParameters),\n input: l.optional(lexiconPayload),\n output: l.optional(lexiconPayload),\n errors: l.optional(l.array(lexiconError)),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon procedure method definition.\n *\n * Represents the structure of an XRPC procedure (POST) method.\n *\n * @see {@link lexiconProcedureSchema} for the schema definition\n */\nexport type LexiconProcedure = l.Infer<typeof lexiconProcedureSchema>\n\nexport const lexiconMessageSchema = l.object({\n description: l.optional(l.string()),\n schema: lexiconRefUnionSchema,\n})\n\nexport type LexiconMessage = l.Infer<typeof lexiconMessageSchema>\n\n/**\n * Schema for validating Lexicon subscription (WebSocket) method definitions.\n *\n * Validates subscription method definitions which represent real-time\n * streaming connections over WebSocket. Subscriptions have parameters,\n * a message schema defining the streamed data format, and error types.\n */\nexport const lexiconSubscriptionSchema = l.object({\n type: l.literal('subscription'),\n description: l.optional(l.string()),\n parameters: l.optional(lexiconParameters),\n message: lexiconMessageSchema,\n errors: l.optional(l.array(lexiconError)),\n})\n\n/**\n * TypeScript type for a Lexicon subscription method definition.\n *\n * Represents the structure of an XRPC subscription (WebSocket) method.\n *\n * @see {@link lexiconSubscriptionSchema} for the schema definition\n */\nexport type LexiconSubscription = l.Infer<typeof lexiconSubscriptionSchema>\n\n// Permissions\n\n/**\n * Schema for validating language codes in Lexicon permission definitions.\n */\nexport const lexiconLanguageSchema = l.string({ format: 'language' })\n\n/**\n * TypeScript type for a BCP 47 language code string.\n *\n * @see {@link lexiconLanguageSchema} for the schema definition\n */\nexport type LexiconLanguage = l.Infer<typeof lexiconLanguageSchema>\n\n/**\n * Schema for validating language-keyed string dictionaries.\n * Used for localized text in permission definitions.\n */\nexport const lexiconLanguageDict = l.dict(lexiconLanguageSchema, l.string())\n\n/**\n * TypeScript type for a language-keyed dictionary of localized strings.\n *\n * @see {@link lexiconLanguageDict} for the schema definition\n */\nexport type LexiconLanguageDict = l.Infer<typeof lexiconLanguageDict>\n\n/**\n * Schema for validating individual Lexicon permission definitions.\n */\nexport const lexiconPermissionSchema = l.intersection(\n l.object({\n type: l.literal('permission'),\n resource: l.string({ minLength: 1 }),\n }),\n l.dict(l.string(), l.paramSchema),\n)\n\n/**\n * TypeScript type for a Lexicon permission definition.\n *\n * Represents a single permission with a resource identifier\n * and optional additional parameters.\n *\n * @see {@link lexiconPermissionSchema} for the schema definition\n */\nexport type LexiconPermission = l.Infer<typeof lexiconPermissionSchema>\n\n/**\n * Schema for validating Lexicon permission set definitions.\n */\nexport const lexiconPermissionSetSchema = l.object({\n type: l.literal('permission-set'),\n permissions: l.array(lexiconPermissionSchema),\n title: l.optional(l.string()),\n 'title:lang': l.optional(lexiconLanguageDict),\n detail: l.optional(l.string()),\n 'detail:lang': l.optional(lexiconLanguageDict),\n description: l.optional(l.string()),\n})\n\n/**\n * TypeScript type for a Lexicon permission set definition.\n *\n * Represents a collection of permissions with optional\n * localized title and detail text.\n *\n * @see {@link lexiconPermissionSetSchema} for the schema definition\n */\nexport type LexiconPermissionSet = l.Infer<typeof lexiconPermissionSetSchema>\n\nconst NAMED_LEXICON_SCHEMAS = [\n ...CONCRETE_TYPES,\n lexiconArraySchema,\n lexiconObjectSchema,\n lexiconTokenSchema,\n] as const\n\n/**\n * TypeScript type for any named Lexicon definition.\n *\n * Union of all definition types that can appear in the defs section\n * of a Lexicon document (excluding main-only types).\n */\nexport type NamedLexiconDefinition = l.Infer<\n (typeof NAMED_LEXICON_SCHEMAS)[number]\n>\n\nconst MAIN_LEXICON_SCHEMAS = [\n lexiconPermissionSetSchema,\n lexiconProcedureSchema,\n lexiconQuerySchema,\n lexiconRecordSchema,\n lexiconSubscriptionSchema,\n ...NAMED_LEXICON_SCHEMAS,\n] as const\n\n/**\n * TypeScript type for main Lexicon definitions.\n *\n * Union of all definition types that can appear as the \"main\" entry\n * in a Lexicon document's defs section.\n */\nexport type MainLexiconDefinition = l.Infer<\n (typeof MAIN_LEXICON_SCHEMAS)[number]\n>\n\n/**\n * Schema for validating Lexicon document identifiers (NSIDs).\n *\n * Validates that the identifier follows the Namespaced Identifier format\n * (e.g., \"com.atproto.repo.createRecord\").\n */\nexport const lexiconIdentifierSchema = l.string({ format: 'nsid' })\n\n/**\n * TypeScript type for a Lexicon document identifier.\n *\n * A Namespaced Identifier (NSID) string in reverse-domain format.\n *\n * @see {@link lexiconIdentifierSchema} for the schema definition\n */\nexport type LexiconIdentifier = l.Infer<typeof lexiconIdentifierSchema>\n\n/**\n * Schema for validating complete Lexicon document structures.\n *\n * Validates the top-level structure of a Lexicon document, including:\n * - `lexicon`: Must be 1 (the current Lexicon version)\n * - `id`: The document's NSID\n * - `revision`: Optional version number\n * - `description`: Optional document description\n * - `defs`: Map of definition names to their schemas\n *\n * The \"main\" definition (if present) can be any main-only type,\n * while other definitions are limited to named types.\n *\n * @example\n * ```ts\n * const result = lexiconDocumentSchema.parse({\n * lexicon: 1,\n * id: 'com.example.getProfile',\n * defs: {\n * main: {\n * type: 'query',\n * output: {\n * encoding: 'application/json',\n * schema: { type: 'ref', ref: '#profile' }\n * }\n * },\n * profile: {\n * type: 'object',\n * properties: {\n * name: { type: 'string' }\n * }\n * }\n * }\n * })\n * ```\n */\nexport const lexiconDocumentSchema = l.object({\n lexicon: l.literal(1),\n id: lexiconIdentifierSchema,\n revision: l.optional(l.integer()),\n description: l.optional(l.string()),\n defs: l.intersection(\n l.object({\n main: l.optional(l.discriminatedUnion('type', MAIN_LEXICON_SCHEMAS)),\n }),\n l.dict(\n l.string({ minLength: 1 }),\n l.discriminatedUnion('type', NAMED_LEXICON_SCHEMAS),\n ),\n ),\n})\n\n/**\n * TypeScript type for a complete Lexicon document.\n *\n * Represents the full structure of a Lexicon JSON document,\n * including the version, identifier, and all type definitions.\n *\n * @see {@link lexiconDocumentSchema} for the schema definition\n */\nexport type LexiconDocument = l.Infer<typeof lexiconDocumentSchema>\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-iterable-indexer.d.ts","sourceRoot":"","sources":["../src/lexicon-iterable-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,sBAAuB,YAAW,cAAc,EAAE,eAAe;;IAsB1E,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;IAhB7E;;;;;;;;;;;;;;OAcG;gBAEQ,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;IAQ7E;;;;;;;OAOG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAaxC,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAC5C,eAAe,EACf,IAAI,EACJ,SAAS,CACV;IAwCK,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7C"}
1
+ {"version":3,"file":"lexicon-iterable-indexer.d.ts","sourceRoot":"","sources":["../src/lexicon-iterable-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,sBAAuB,YAAW,cAAc,EAAE,eAAe;;IAsB1E,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;IAhB7E;;;;;;;;;;;;;;OAcG;IACH,YACW,MAAM,EAAE,aAAa,CAAC,eAAe,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC,EAM5E;IAED;;;;;;;OAOG;IACG,GAAG,CAAC,EAAE,EAA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CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAA;IACjC,CAAC;CACF","sourcesContent":["import { LexiconDocument } from './lexicon-document.js'\nimport { LexiconIndexer } from './lexicon-indexer.js'\n\n/**\n * Lazily indexes Lexicon documents from an iterable source.\n *\n * This class implements `LexiconIndexer` by consuming documents from an\n * iterable (sync or async) and caching them for efficient retrieval.\n * Documents are indexed on-demand as they are requested or iterated over.\n *\n * @example\n * ```ts\n * // From an array of documents\n * const docs = [lexiconDoc1, lexiconDoc2, lexiconDoc3]\n * const indexer = new LexiconIterableIndexer(docs)\n *\n * // Documents are indexed lazily as requested\n * const doc = await indexer.get('com.example.post')\n * ```\n *\n * @example\n * ```ts\n * // From an async generator (e.g., reading from files)\n * async function* loadLexicons() {\n * for (const file of lexiconFiles) {\n * yield JSON.parse(await fs.readFile(file, 'utf8'))\n * }\n * }\n *\n * await using indexer = new LexiconIterableIndexer(loadLexicons())\n * const schemas = await LexiconSchemaBuilder.buildAll(indexer)\n * ```\n */\nexport class LexiconIterableIndexer implements LexiconIndexer, AsyncDisposable {\n readonly #lexicons: Map<string, LexiconDocument> = new Map()\n readonly #iterator:\n | AsyncIterator<LexiconDocument, void, unknown>\n | Iterator<LexiconDocument, void, unknown>\n\n /**\n * Creates a new {@link LexiconIterableIndexer} from an iterable source.\n *\n * @param source - An iterable or async iterable of Lexicon documents.\n * The iterator is consumed lazily as documents are requested.\n *\n * @example\n * ```ts\n * // Sync iterable (array, Set, Map.values(), etc.)\n * const indexer = new LexiconIterableIndexer(lexiconDocuments)\n *\n * // Async iterable (async generator, ReadableStream, etc.)\n * const indexer = new LexiconIterableIndexer(asyncLexiconStream)\n * ```\n */\n constructor(\n readonly source: AsyncIterable<LexiconDocument> | Iterable<LexiconDocument>,\n ) {\n this.#iterator =\n Symbol.asyncIterator in source\n ? source[Symbol.asyncIterator]()\n : source[Symbol.iterator]()\n }\n\n /**\n * Retrieves a Lexicon document by its NSID.\n *\n * If the document has already been indexed, it is returned from cache.\n * Otherwise, the source iterator is consumed until the document is found.\n *\n * @see {@link LexiconIndexer.get}\n */\n async get(id: string): Promise<LexiconDocument> {\n const cached = this.#lexicons.get(id)\n if (cached) return cached\n\n for await (const doc of this) {\n if (doc.id === id) return doc\n }\n\n throw Object.assign(new Error(`Lexicon ${id} not found`), {\n code: 'ENOENT',\n })\n }\n\n async *[Symbol.asyncIterator](): AsyncIterator<\n LexiconDocument,\n void,\n undefined\n > {\n const returned = new Set<string>()\n\n for (const doc of this.#lexicons.values()) {\n returned.add(doc.id)\n yield doc\n }\n\n do {\n const { value, done } = await this.#iterator.next()\n\n if (done) break\n\n if (returned.has(value.id)) {\n const err = new Error(`Duplicate lexicon document id: ${value.id}`)\n await this.#iterator.throw?.(err)\n throw err // In case iterator.throw does not exist or does not throw\n }\n\n this.#lexicons.set(value.id, value)\n returned.add(value.id)\n yield value\n } while (true)\n\n // At this point, the underlying iterator is done. However, there may have\n // been requests (.get()) for documents that caused the iterator to yield\n // those documents during concurrent execution of this loop. If that was the\n // case, new documents may have been added to `#lexicons` that have not yet\n // been yielded. We need to yield those as well. Since we yield control back\n // to the caller, we need to repeat this process until no new documents\n // appear sunce we don't know what happens.\n\n for (const doc of this.#lexicons.values()) {\n if (!returned.has(doc.id)) {\n returned.add(doc.id)\n yield doc\n }\n }\n }\n\n async [Symbol.asyncDispose](): Promise<void> {\n await this.#iterator.return?.()\n }\n}\n"]}
1
+ {"version":3,"file":"lexicon-iterable-indexer.js","sourceRoot":"","sources":["../src/lexicon-iterable-indexer.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,OAAO,sBAAsB;IACxB,SAAS,GAAiC,IAAI,GAAG,EAAE,CAAA;IACnD,SAAS,CAE0B;IAE5C;;;;;;;;;;;;;;OAcG;IACH,YACW,MAAkE;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,EAAE,EAAE,CAAC,CAAA;gBACnE,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAA;gBACjC,MAAM,GAAG,CAAA,CAAC,0DAA0D;YACtE,CAAC;YAED,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;YACnC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;YACtB,MAAM,KAAK,CAAA;QACb,CAAC,QAAQ,IAAI,EAAC;QAEd,0EAA0E;QAC1E,yEAAyE;QACzE,4EAA4E;QAC5E,2EAA2E;QAC3E,4EAA4E;QAC5E,uEAAuE;QACvE,2CAA2C;QAE3C,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC1B,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;gBACpB,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAA;IACjC,CAAC;CACF","sourcesContent":["import { LexiconDocument } from './lexicon-document.js'\nimport { LexiconIndexer } from './lexicon-indexer.js'\n\n/**\n * Lazily indexes Lexicon documents from an iterable source.\n *\n * This class implements `LexiconIndexer` by consuming documents from an\n * iterable (sync or async) and caching them for efficient retrieval.\n * Documents are indexed on-demand as they are requested or iterated over.\n *\n * @example\n * ```ts\n * // From an array of documents\n * const docs = [lexiconDoc1, lexiconDoc2, lexiconDoc3]\n * const indexer = new LexiconIterableIndexer(docs)\n *\n * // Documents are indexed lazily as requested\n * const doc = await indexer.get('com.example.post')\n * ```\n *\n * @example\n * ```ts\n * // From an async generator (e.g., reading from files)\n * async function* loadLexicons() {\n * for (const file of lexiconFiles) {\n * yield JSON.parse(await fs.readFile(file, 'utf8'))\n * }\n * }\n *\n * await using indexer = new LexiconIterableIndexer(loadLexicons())\n * const schemas = await LexiconSchemaBuilder.buildAll(indexer)\n * ```\n */\nexport class LexiconIterableIndexer implements LexiconIndexer, AsyncDisposable {\n readonly #lexicons: Map<string, LexiconDocument> = new Map()\n readonly #iterator:\n | AsyncIterator<LexiconDocument, void, unknown>\n | Iterator<LexiconDocument, void, unknown>\n\n /**\n * Creates a new {@link LexiconIterableIndexer} from an iterable source.\n *\n * @param source - An iterable or async iterable of Lexicon documents.\n * The iterator is consumed lazily as documents are requested.\n *\n * @example\n * ```ts\n * // Sync iterable (array, Set, Map.values(), etc.)\n * const indexer = new LexiconIterableIndexer(lexiconDocuments)\n *\n * // Async iterable (async generator, ReadableStream, etc.)\n * const indexer = new LexiconIterableIndexer(asyncLexiconStream)\n * ```\n */\n constructor(\n readonly source: AsyncIterable<LexiconDocument> | Iterable<LexiconDocument>,\n ) {\n this.#iterator =\n Symbol.asyncIterator in source\n ? source[Symbol.asyncIterator]()\n : source[Symbol.iterator]()\n }\n\n /**\n * Retrieves a Lexicon document by its NSID.\n *\n * If the document has already been indexed, it is returned from cache.\n * Otherwise, the source iterator is consumed until the document is found.\n *\n * @see {@link LexiconIndexer.get}\n */\n async get(id: string): Promise<LexiconDocument> {\n const cached = this.#lexicons.get(id)\n if (cached) return cached\n\n for await (const doc of this) {\n if (doc.id === id) return doc\n }\n\n throw Object.assign(new Error(`Lexicon ${id} not found`), {\n code: 'ENOENT',\n })\n }\n\n async *[Symbol.asyncIterator](): AsyncIterator<\n LexiconDocument,\n void,\n undefined\n > {\n const returned = new Set<string>()\n\n for (const doc of this.#lexicons.values()) {\n returned.add(doc.id)\n yield doc\n }\n\n do {\n const { value, done } = await this.#iterator.next()\n\n if (done) break\n\n if (returned.has(value.id)) {\n const err = new Error(`Duplicate lexicon document id: ${value.id}`)\n await this.#iterator.throw?.(err)\n throw err // In case iterator.throw does not exist or does not throw\n }\n\n this.#lexicons.set(value.id, value)\n returned.add(value.id)\n yield value\n } while (true)\n\n // At this point, the underlying iterator is done. However, there may have\n // been requests (.get()) for documents that caused the iterator to yield\n // those documents during concurrent execution of this loop. If that was the\n // case, new documents may have been added to `#lexicons` that have not yet\n // been yielded. We need to yield those as well. Since we yield control back\n // to the caller, we need to repeat this process until no new documents\n // appear sunce we don't know what happens.\n\n for (const doc of this.#lexicons.values()) {\n if (!returned.has(doc.id)) {\n returned.add(doc.id)\n yield doc\n }\n }\n }\n\n async [Symbol.asyncDispose](): Promise<void> {\n await this.#iterator.return?.()\n }\n}\n"]}
@@ -84,7 +84,7 @@ export declare class LexiconSchemaBuilder implements AsyncDisposable {
84
84
  * }
85
85
  * ```
86
86
  */
87
- static buildAll(indexer: LexiconIndexer): Promise<Map<string, l.Schema<LexValue, LexValue> | l.Query<`${string}.${string}.${string}`, l.ParamsSchema<l.ParamsShape>, l.Payload<string | undefined, l.Schema<LexValue, LexValue> | undefined>, readonly string[] | undefined> | l.Subscription<`${string}.${string}.${string}`, l.ParamsSchema<l.ParamsShape>, l.Schema<LexValue, LexValue>, readonly string[] | undefined> | l.Procedure<`${string}.${string}.${string}`, l.ParamsSchema<l.ParamsShape>, l.Payload<string | undefined, l.Schema<LexValue, LexValue> | undefined>, l.Payload<string | undefined, l.Schema<LexValue, LexValue> | undefined>, readonly string[] | undefined> | l.PermissionSet<any, any>>>;
87
+ static buildAll(indexer: LexiconIndexer): Promise<Map<string, l.PermissionSet<any, any> | l.Procedure<`${string}.${string}.${string}`, l.ParamsSchema<l.ParamsShape>, l.Payload<string | undefined, l.Schema<LexValue, LexValue> | undefined>, l.Payload<string | undefined, l.Schema<LexValue, LexValue> | undefined>, readonly string[] | undefined> | l.Query<`${string}.${string}.${string}`, l.ParamsSchema<l.ParamsShape>, l.Payload<string | undefined, l.Schema<LexValue, LexValue> | undefined>, readonly string[] | undefined> | l.Schema<LexValue, LexValue> | l.Subscription<`${string}.${string}.${string}`, l.ParamsSchema<l.ParamsShape>, l.Schema<LexValue, LexValue>, readonly string[] | undefined>>>;
88
88
  /**
89
89
  * Creates a new LexiconSchemaBuilder instance.
90
90
  *
@@ -115,14 +115,14 @@ export declare class LexiconSchemaBuilder implements AsyncDisposable {
115
115
  * @param fullRef - The full reference in format "nsid#defName"
116
116
  * @returns A promise resolving to the built schema or method definition
117
117
  */
118
- buildFullRef: (fullRef: string) => Promise<l.Schema<LexValue, LexValue> | l.PermissionSet<`${string}.${string}.${string}`, l.Permission<string, {
119
- [x: string]: string | number | boolean | number[] | string[] | boolean[];
120
- }>[]> | l.Procedure<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Query<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Subscription<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Schema<LexValue, LexValue>, string[]>>;
118
+ buildFullRef: (fullRef: string) => Promise<l.PermissionSet<`${string}.${string}.${string}`, l.Permission<string, {
119
+ [x: string]: string | number | boolean | string[] | number[] | boolean[];
120
+ }>[]> | l.Procedure<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Query<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Schema<LexValue, LexValue> | l.Subscription<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Schema<LexValue, LexValue>, string[]>>;
121
121
  protected buildRefGetter(fullRef: string): () => l.Schema<LexValue>;
122
122
  protected buildTypedRefGetter(fullRef: string): () => l.TypedObjectSchema | l.RecordSchema;
123
- protected compileDef(doc: LexiconDocument, hash: string): l.Schema<LexValue, LexValue> | l.PermissionSet<`${string}.${string}.${string}`, l.Permission<string, {
124
- [x: string]: string | number | boolean | number[] | string[] | boolean[];
125
- }>[]> | l.Procedure<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Query<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Subscription<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Schema<LexValue, LexValue>, string[]>;
123
+ protected compileDef(doc: LexiconDocument, hash: string): l.PermissionSet<`${string}.${string}.${string}`, l.Permission<string, {
124
+ [x: string]: string | number | boolean | string[] | number[] | boolean[];
125
+ }>[]> | l.Procedure<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Query<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Payload<string, l.Schema<LexValue, LexValue>>, string[]> | l.Schema<LexValue, LexValue> | l.Subscription<`${string}.${string}.${string}`, l.ParamsSchema<{}>, l.Schema<LexValue, LexValue>, string[]>;
126
126
  protected compileLeaf(doc: LexiconDocument, def: LexiconArray | LexiconArrayItems): l.Schema<LexValue>;
127
127
  protected compileRef(doc: LexiconDocument, def: LexiconRef | LexiconRefUnion): l.Schema<LexValue>;
128
128
  protected compileObject(doc: LexiconDocument, def: LexiconObject): l.ObjectSchema<Record<string, l.Schema<LexValue | undefined, LexValue | undefined>>>;
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-schema-builder.d.ts","sourceRoot":"","sources":["../src/lexicon-schema-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AACvC,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,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C,KAAK,UAAU,CAChD,CAAA;AACH,CAAC","sourcesContent":["import { LexValue } from '@atproto/lex-data'\nimport { l } from '@atproto/lex-schema'\nimport {\n LexiconArray,\n LexiconArrayItems,\n LexiconDocument,\n LexiconError,\n LexiconObject,\n LexiconParameters,\n LexiconPayload,\n LexiconRef,\n LexiconRefUnion,\n} from './lexicon-document.js'\nimport { LexiconIndexer } from './lexicon-indexer.js'\n\n/**\n * Builds validators for Lexicon documents.\n *\n * This class converts Lexicon type definitions into runtime validators\n * that can validate data against the schema. It handles reference resolution,\n * supporting both local (`#defName`) and cross-document (`nsid#defName`) refs.\n *\n * @example\n * ```ts\n * import { LexiconSchemaBuilder, LexiconIterableIndexer } from '@atproto/lex-document'\n *\n * // Build a single validator\n * const indexer = new LexiconIterableIndexer(lexiconDocs)\n * const validator = await LexiconSchemaBuilder.build(indexer, 'com.example.post#main')\n *\n * // Validate data\n * const result = validator.safeParse(myPostData)\n * if (result.success) {\n * console.log('Valid:', result.value)\n * } else {\n * console.log('Invalid:', result.error)\n * }\n * ```\n *\n * @example\n * ```ts\n * // Build all validators from an iterable indexer\n * const indexer = new LexiconIterableIndexer(lexiconDocs)\n * const allSchemas = await LexiconSchemaBuilder.buildAll(indexer)\n *\n * for (const [ref, schema] of allSchemas) {\n * console.log(`Built validator for ${ref}`)\n * }\n * ```\n */\nexport class LexiconSchemaBuilder implements AsyncDisposable {\n /**\n * Builds a validator for a single Lexicon definition reference.\n *\n * @param indexer - The Lexicon indexer to resolve documents from\n * @param fullRef - The full reference to build, in format \"nsid#defName\"\n * @returns A promise resolving to a validator for the referenced definition\n * @throws Error if the reference does not point to a schema type\n *\n * @example\n * ```ts\n * const validator = await LexiconSchemaBuilder.build(\n * indexer,\n * 'app.bsky.feed.post#main'\n * )\n *\n * validator.parse(postRecord) // Throws if invalid\n * ```\n */\n static async build(\n indexer: LexiconIndexer,\n fullRef: string,\n ): Promise<l.Schema<LexValue>> {\n const ctx = new LexiconSchemaBuilder(indexer)\n try {\n const result = await ctx.buildFullRef(fullRef)\n if (!(result instanceof l.Schema)) {\n throw new Error(`Ref ${fullRef} is not a schema type`)\n }\n return result\n } finally {\n await ctx.done()\n }\n }\n\n /**\n * Builds validators for all definitions in all documents from an iterable indexer.\n *\n * This method iterates over all Lexicon documents available in the indexer\n * and builds validators for every definition in each document.\n *\n * @param indexer - An iterable Lexicon indexer (must implement `Symbol.asyncIterator`)\n * @returns A promise resolving to a Map of full references to their validators.\n * The map values can be validators, Query, Subscription, Procedure, or PermissionSet.\n * @throws Error if the indexer does not support iteration\n *\n * @example\n * ```ts\n * const indexer = new LexiconIterableIndexer(allLexiconDocs)\n * const schemas = await LexiconSchemaBuilder.buildAll(indexer)\n *\n * // Access a specific schema\n * const postSchema = schemas.get('app.bsky.feed.post#main')\n *\n * // Iterate all schemas\n * for (const [ref, schema] of schemas) {\n * console.log(ref, schema)\n * }\n * ```\n */\n static async buildAll(indexer: LexiconIndexer) {\n const builder = new LexiconSchemaBuilder(indexer)\n const schemas = new Map<\n string,\n | l.Schema<LexValue>\n | l.Query\n | l.Subscription\n | l.Procedure\n | l.PermissionSet\n >()\n if (!isAsyncIterableObject(indexer)) {\n throw new Error('An iterable indexer is required to build all schemas')\n }\n try {\n for await (const doc of indexer) {\n for (const hash of Object.keys(doc.defs)) {\n const fullRef = `${doc.id}#${hash}`\n const schema = await builder.buildFullRef(fullRef)\n schemas.set(fullRef, schema)\n }\n }\n return schemas\n } finally {\n await builder.done()\n }\n }\n\n #asyncTasks = new AsyncTasks()\n\n /**\n * Creates a new LexiconSchemaBuilder instance.\n *\n * Note: For most use cases, prefer using the static `build()` or `buildAll()`\n * methods instead of instantiating directly.\n *\n * @param indexer - The Lexicon indexer to resolve documents from\n */\n constructor(protected indexer: LexiconIndexer) {}\n\n /**\n * Waits for all pending reference resolution tasks to complete.\n *\n * When building schemas with cross-references, the builder schedules\n * async tasks to resolve those references. This method must be called\n * to ensure all references are fully resolved before using the validators.\n *\n * @returns A promise that resolves when all pending tasks are complete\n * @throws Rethrows any errors from failed reference resolution\n */\n async done(): Promise<void> {\n await this.#asyncTasks.done()\n }\n\n async [Symbol.asyncDispose]() {\n await this.done()\n }\n\n /**\n * Builds a validator for a full reference (memoized).\n *\n * Results are cached, so calling with the same reference returns\n * the same promise/result.\n *\n * @param fullRef - The full reference in format \"nsid#defName\"\n * @returns A promise resolving to the built schema or method definition\n */\n buildFullRef = memoize(async (fullRef: string) => {\n const { nsid, hash } = parseRef(fullRef)\n\n const doc = await this.indexer.get(nsid)\n\n return this.compileDef(doc, hash)\n })\n\n protected buildRefGetter(fullRef: string): () => l.Schema<LexValue> {\n let schema: l.Schema<LexValue>\n\n this.#asyncTasks.add(\n this.buildFullRef(fullRef).then((v) => {\n if (!(v instanceof l.Schema)) {\n throw new Error(`Only refs to schema types are allowed`)\n }\n schema = v\n }),\n )\n\n return () => {\n if (schema) return schema\n throw new Error('Validator not yet built. Did you await done()?')\n }\n }\n\n protected buildTypedRefGetter(\n fullRef: string,\n ): () => l.TypedObjectSchema | l.RecordSchema {\n let validator: l.TypedObjectSchema | l.RecordSchema\n\n this.#asyncTasks.add(\n this.buildFullRef(fullRef).then((v) => {\n if (v instanceof l.TypedObjectSchema || v instanceof l.RecordSchema) {\n validator = v\n } else {\n throw new Error(\n 'Only refs to records and object definitions are allowed',\n )\n }\n }),\n )\n\n return () => {\n if (validator) return validator\n throw new Error('Validator not yet built. Did you await done()?')\n }\n }\n\n protected compileDef(doc: LexiconDocument, hash: string) {\n const def = Object.hasOwn(doc.defs, hash) ? doc.defs[hash] : null\n if (!def) {\n throw new Error(\n `No definition found for hash \"${JSON.stringify(hash)}\" in ${doc.id}`,\n )\n }\n switch (def.type) {\n case 'permission-set':\n return l.permissionSet(\n doc.id,\n def.permissions.map(({ resource, type, ...p }) =>\n l.permission(resource, p),\n ),\n def,\n )\n case 'procedure':\n return l.procedure(\n doc.id,\n this.compileParams(doc, def.parameters),\n this.compilePayload(doc, def.input),\n this.compilePayload(doc, def.output),\n this.compileErrors(doc, def.errors),\n )\n case 'query':\n return l.query(\n doc.id,\n this.compileParams(doc, def.parameters),\n this.compilePayload(doc, def.output),\n this.compileErrors(doc, def.errors),\n )\n case 'subscription':\n return l.subscription(\n doc.id,\n this.compileParams(doc, def.parameters),\n this.compilePayloadSchema(doc, def.message.schema),\n this.compileErrors(doc, def.errors),\n )\n case 'token':\n return l.token(doc.id, hash)\n case 'record':\n return l.record(def.key, doc.id, this.compileObject(doc, def.record))\n case 'object':\n return l.typedObject(doc.id, hash, this.compileObject(doc, def))\n default:\n return this.compileLeaf(doc, def)\n }\n }\n\n protected compileLeaf(\n doc: LexiconDocument,\n def: LexiconArray | LexiconArrayItems,\n ): l.Schema<LexValue> {\n if (\n 'const' in def &&\n 'enum' in def &&\n def.enum != null &&\n def.const !== undefined &&\n !(def.enum as readonly unknown[]).includes(def.const)\n ) {\n return l.never()\n }\n\n switch (def.type) {\n case 'string': {\n const schema = l.string(def)\n if (def.default != null) schema.check(def.default)\n if (def.const != null) schema.check(def.const)\n if (def.enum != null) for (const v of def.enum) schema.check(v)\n\n const result =\n def.const != null\n ? l.literal(def.const)\n : def.enum != null\n ? l.enum(def.enum)\n : schema\n\n return def.default != null ? l.withDefault(result, def.default) : result\n }\n case 'integer': {\n const schema = l.integer(def)\n if (def.default != null) schema.check(def.default)\n if (def.const != null) schema.check(def.const)\n if (def.enum != null) for (const v of def.enum) schema.check(v)\n\n const result =\n def.const != null\n ? l.literal(def.const)\n : def.enum != null\n ? l.enum(def.enum)\n : schema\n\n return def.default != null ? l.withDefault(result, def.default) : result\n }\n case 'boolean': {\n const result = def.const != null ? l.literal(def.const) : l.boolean()\n\n return def.default != null ? l.withDefault(result, def.default) : result\n }\n case 'blob':\n return l.blob(def)\n case 'cid-link':\n return l.cid()\n case 'bytes':\n return l.bytes(def)\n case 'unknown':\n return l.lexMap()\n case 'array':\n return l.array(this.compileLeaf(doc, def.items), def)\n default:\n return this.compileRef(doc, def)\n }\n }\n\n protected compileRef(\n doc: LexiconDocument,\n def: LexiconRef | LexiconRefUnion,\n ): l.Schema<LexValue> {\n switch (def.type) {\n case 'ref':\n return l.ref(this.buildRefGetter(buildFullRef(doc, def.ref)))\n case 'union':\n return l.typedUnion(\n def.refs.map((r) =>\n l.typedRef(this.buildTypedRefGetter(buildFullRef(doc, r))),\n ),\n def.closed ?? false,\n )\n default:\n // @ts-expect-error\n throw new Error(`Unknown lexicon type: ${def.type}`)\n }\n }\n\n protected compileObject(doc: LexiconDocument, def: LexiconObject) {\n const props: Record<string, l.Schema<undefined | LexValue>> = {}\n for (const [key, propDef] of Object.entries(def.properties)) {\n if (propDef === undefined) continue\n\n const isNullable = def.nullable?.includes(key)\n const isRequired = def.required?.includes(key)\n\n let schema: l.Schema<undefined | LexValue> = this.compileLeaf(\n doc,\n propDef,\n )\n\n if (isNullable) {\n schema = l.nullable(schema)\n }\n\n if (!isRequired) {\n schema = l.optional(schema)\n }\n\n props[key] = schema\n }\n return l.object(props)\n }\n\n protected compilePayload(\n doc: LexiconDocument,\n def: LexiconPayload | undefined,\n ) {\n return l.payload(\n def?.encoding,\n def?.schema ? this.compilePayloadSchema(doc, def.schema) : undefined,\n )\n }\n\n protected compileErrors(\n _doc: LexiconDocument,\n errors?: readonly LexiconError[],\n ): undefined | string[] {\n return errors?.map((e) => e.name)\n }\n\n protected compilePayloadSchema(\n doc: LexiconDocument,\n def: LexiconObject | LexiconRef | LexiconRefUnion,\n ): l.Schema<LexValue, LexValue> {\n switch (def.type) {\n case 'object':\n return this.compileObject(doc, def)\n default:\n return this.compileRef(doc, def)\n }\n }\n\n protected compileParams(doc: LexiconDocument, def?: LexiconParameters) {\n if (!def) return l.params()\n\n const shape: l.ParamsShape = {}\n for (const [paramName, paramDef] of Object.entries(def.properties)) {\n if (paramDef === undefined) continue\n\n const isRequired = def.required?.includes(paramName)\n\n const propSchema = this.compileLeaf(doc, paramDef) as\n | l.StringSchema\n | l.BooleanSchema\n | l.IntegerSchema\n | l.ArraySchema<l.StringSchema>\n | l.ArraySchema<l.BooleanSchema>\n | l.ArraySchema<l.IntegerSchema>\n\n shape[paramName] = isRequired ? propSchema : l.optional(propSchema)\n }\n\n return l.params(shape)\n }\n}\n\nclass AsyncTasks {\n /**\n * A set that, eventually, contains only rejected promises.\n */\n #promises = new Set<Promise<void>>()\n\n async done(): Promise<void> {\n do {\n // @NOTE this is going to throw on the first rejected promise (which is\n // what we want)\n for (const p of this.#promises) await p\n // At this point, all settled promises should have been removed. If\n // this.#promises is not empty, it means new promises were added during\n // the awaiting process, so we loop again.\n } while (this.#promises.size > 0)\n }\n\n add(p: Promise<void>) {\n const promise = Promise.resolve(p).then(() => {\n // No need to keep the promise any longer\n this.#promises.delete(promise)\n })\n\n void promise.catch((_err) => {\n // ignore errors here, they should be caught though done()\n })\n\n this.#promises.add(promise)\n }\n}\n\nfunction parseRef(fullRef: string) {\n const { length, 0: nsid, 1: hash } = fullRef.split('#')\n if (length !== 2) throw new Error('Uri can only have one hash segment')\n if (!nsid || !hash) throw new Error('Invalid ref, missing hash')\n return { nsid, hash }\n}\n\nfunction buildFullRef(from: LexiconDocument, ref: string) {\n if (ref.startsWith('#')) return `${from.id}${ref}`\n return ref\n}\n\nexport function memoize<Fn extends (arg: string) => unknown>(fn: Fn): Fn {\n const cache = new Map<string, ReturnType<Fn>>()\n return ((arg: string) => {\n if (cache.has(arg)) return cache.get(arg)!\n const result = fn(arg) as ReturnType<Fn>\n cache.set(arg, result)\n return result\n }) as Fn\n}\n\nfunction isAsyncIterableObject<T>(\n obj: T,\n): obj is T & object & AsyncIterable<unknown> {\n return (\n obj != null &&\n typeof obj === 'object' &&\n Symbol.asyncIterator in obj &&\n typeof obj[Symbol.asyncIterator] === 'function'\n )\n}\n"]}
1
+ {"version":3,"file":"lexicon-schema-builder.js","sourceRoot":"","sources":["../src/lexicon-schema-builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAA;AAcvC;;;;;;;;;;;;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A;AACZ,CAAC;AAED,MAAM,UAAU,OAAO,CAAsC,EAAM;IACjE,MAAM,KAAK,GAAG,IAAI,GAAG,EAA0B,CAAA;IAC/C,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;QACtB,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAE,CAAA;QAC1C,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAmB,CAAA;QACxC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;QACtB,OAAO,MAAM,CAAA;IACf,CAAC,CAAO,CAAA;AACV,CAAC;AAED,SAAS,qBAAqB,CAC5B,GAAM;IAEN,OAAO,CACL,GAAG,IAAI,IAAI;QACX,OAAO,GAAG,KAAK,QAAQ;QACvB,MAAM,CAAC,aAAa,IAAI,GAAG;QAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,CAChD,CAAA;AACH,CAAC","sourcesContent":["import { LexValue } from '@atproto/lex-data'\nimport { l } from '@atproto/lex-schema'\nimport {\n LexiconArray,\n LexiconArrayItems,\n LexiconDocument,\n LexiconError,\n LexiconObject,\n LexiconParameters,\n LexiconPayload,\n LexiconRef,\n LexiconRefUnion,\n} from './lexicon-document.js'\nimport { LexiconIndexer } from './lexicon-indexer.js'\n\n/**\n * Builds validators for Lexicon documents.\n *\n * This class converts Lexicon type definitions into runtime validators\n * that can validate data against the schema. It handles reference resolution,\n * supporting both local (`#defName`) and cross-document (`nsid#defName`) refs.\n *\n * @example\n * ```ts\n * import { LexiconSchemaBuilder, LexiconIterableIndexer } from '@atproto/lex-document'\n *\n * // Build a single validator\n * const indexer = new LexiconIterableIndexer(lexiconDocs)\n * const validator = await LexiconSchemaBuilder.build(indexer, 'com.example.post#main')\n *\n * // Validate data\n * const result = validator.safeParse(myPostData)\n * if (result.success) {\n * console.log('Valid:', result.value)\n * } else {\n * console.log('Invalid:', result.error)\n * }\n * ```\n *\n * @example\n * ```ts\n * // Build all validators from an iterable indexer\n * const indexer = new LexiconIterableIndexer(lexiconDocs)\n * const allSchemas = await LexiconSchemaBuilder.buildAll(indexer)\n *\n * for (const [ref, schema] of allSchemas) {\n * console.log(`Built validator for ${ref}`)\n * }\n * ```\n */\nexport class LexiconSchemaBuilder implements AsyncDisposable {\n /**\n * Builds a validator for a single Lexicon definition reference.\n *\n * @param indexer - The Lexicon indexer to resolve documents from\n * @param fullRef - The full reference to build, in format \"nsid#defName\"\n * @returns A promise resolving to a validator for the referenced definition\n * @throws Error if the reference does not point to a schema type\n *\n * @example\n * ```ts\n * const validator = await LexiconSchemaBuilder.build(\n * indexer,\n * 'app.bsky.feed.post#main'\n * )\n *\n * validator.parse(postRecord) // Throws if invalid\n * ```\n */\n static async build(\n indexer: LexiconIndexer,\n fullRef: string,\n ): Promise<l.Schema<LexValue>> {\n const ctx = new LexiconSchemaBuilder(indexer)\n try {\n const result = await ctx.buildFullRef(fullRef)\n if (!(result instanceof l.Schema)) {\n throw new Error(`Ref ${fullRef} is not a schema type`)\n }\n return result\n } finally {\n await ctx.done()\n }\n }\n\n /**\n * Builds validators for all definitions in all documents from an iterable indexer.\n *\n * This method iterates over all Lexicon documents available in the indexer\n * and builds validators for every definition in each document.\n *\n * @param indexer - An iterable Lexicon indexer (must implement `Symbol.asyncIterator`)\n * @returns A promise resolving to a Map of full references to their validators.\n * The map values can be validators, Query, Subscription, Procedure, or PermissionSet.\n * @throws Error if the indexer does not support iteration\n *\n * @example\n * ```ts\n * const indexer = new LexiconIterableIndexer(allLexiconDocs)\n * const schemas = await LexiconSchemaBuilder.buildAll(indexer)\n *\n * // Access a specific schema\n * const postSchema = schemas.get('app.bsky.feed.post#main')\n *\n * // Iterate all schemas\n * for (const [ref, schema] of schemas) {\n * console.log(ref, schema)\n * }\n * ```\n */\n static async buildAll(indexer: LexiconIndexer) {\n const builder = new LexiconSchemaBuilder(indexer)\n const schemas = new Map<\n string,\n | l.Schema<LexValue>\n | l.Query\n | l.Subscription\n | l.Procedure\n | l.PermissionSet\n >()\n if (!isAsyncIterableObject(indexer)) {\n throw new Error('An iterable indexer is required to build all schemas')\n }\n try {\n for await (const doc of indexer) {\n for (const hash of Object.keys(doc.defs)) {\n const fullRef = `${doc.id}#${hash}`\n const schema = await builder.buildFullRef(fullRef)\n schemas.set(fullRef, schema)\n }\n }\n return schemas\n } finally {\n await builder.done()\n }\n }\n\n #asyncTasks = new AsyncTasks()\n\n /**\n * Creates a new LexiconSchemaBuilder instance.\n *\n * Note: For most use cases, prefer using the static `build()` or `buildAll()`\n * methods instead of instantiating directly.\n *\n * @param indexer - The Lexicon indexer to resolve documents from\n */\n constructor(protected indexer: LexiconIndexer) {}\n\n /**\n * Waits for all pending reference resolution tasks to complete.\n *\n * When building schemas with cross-references, the builder schedules\n * async tasks to resolve those references. This method must be called\n * to ensure all references are fully resolved before using the validators.\n *\n * @returns A promise that resolves when all pending tasks are complete\n * @throws Rethrows any errors from failed reference resolution\n */\n async done(): Promise<void> {\n await this.#asyncTasks.done()\n }\n\n async [Symbol.asyncDispose]() {\n await this.done()\n }\n\n /**\n * Builds a validator for a full reference (memoized).\n *\n * Results are cached, so calling with the same reference returns\n * the same promise/result.\n *\n * @param fullRef - The full reference in format \"nsid#defName\"\n * @returns A promise resolving to the built schema or method definition\n */\n buildFullRef = memoize(async (fullRef: string) => {\n const { nsid, hash } = parseRef(fullRef)\n\n const doc = await this.indexer.get(nsid)\n\n return this.compileDef(doc, hash)\n })\n\n protected buildRefGetter(fullRef: string): () => l.Schema<LexValue> {\n let schema: l.Schema<LexValue>\n\n this.#asyncTasks.add(\n this.buildFullRef(fullRef).then((v) => {\n if (!(v instanceof l.Schema)) {\n throw new Error(`Only refs to schema types are allowed`)\n }\n schema = v\n }),\n )\n\n return () => {\n if (schema) return schema\n throw new Error('Validator not yet built. Did you await done()?')\n }\n }\n\n protected buildTypedRefGetter(\n fullRef: string,\n ): () => l.TypedObjectSchema | l.RecordSchema {\n let validator: l.TypedObjectSchema | l.RecordSchema\n\n this.#asyncTasks.add(\n this.buildFullRef(fullRef).then((v) => {\n if (v instanceof l.TypedObjectSchema || v instanceof l.RecordSchema) {\n validator = v\n } else {\n throw new Error(\n 'Only refs to records and object definitions are allowed',\n )\n }\n }),\n )\n\n return () => {\n if (validator) return validator\n throw new Error('Validator not yet built. Did you await done()?')\n }\n }\n\n protected compileDef(doc: LexiconDocument, hash: string) {\n const def = Object.hasOwn(doc.defs, hash) ? doc.defs[hash] : null\n if (!def) {\n throw new Error(\n `No definition found for hash \"${JSON.stringify(hash)}\" in ${doc.id}`,\n )\n }\n switch (def.type) {\n case 'permission-set':\n return l.permissionSet(\n doc.id,\n def.permissions.map(({ resource, type, ...p }) =>\n l.permission(resource, p),\n ),\n def,\n )\n case 'procedure':\n return l.procedure(\n doc.id,\n this.compileParams(doc, def.parameters),\n this.compilePayload(doc, def.input),\n this.compilePayload(doc, def.output),\n this.compileErrors(doc, def.errors),\n )\n case 'query':\n return l.query(\n doc.id,\n this.compileParams(doc, def.parameters),\n this.compilePayload(doc, def.output),\n this.compileErrors(doc, def.errors),\n )\n case 'subscription':\n return l.subscription(\n doc.id,\n this.compileParams(doc, def.parameters),\n this.compilePayloadSchema(doc, def.message.schema),\n this.compileErrors(doc, def.errors),\n )\n case 'token':\n return l.token(doc.id, hash)\n case 'record':\n return l.record(def.key, doc.id, this.compileObject(doc, def.record))\n case 'object':\n return l.typedObject(doc.id, hash, this.compileObject(doc, def))\n default:\n return this.compileLeaf(doc, def)\n }\n }\n\n protected compileLeaf(\n doc: LexiconDocument,\n def: LexiconArray | LexiconArrayItems,\n ): l.Schema<LexValue> {\n if (\n 'const' in def &&\n 'enum' in def &&\n def.enum != null &&\n def.const !== undefined &&\n !(def.enum as readonly unknown[]).includes(def.const)\n ) {\n return l.never()\n }\n\n switch (def.type) {\n case 'string': {\n const schema = l.string(def)\n if (def.default != null) schema.check(def.default)\n if (def.const != null) schema.check(def.const)\n if (def.enum != null) for (const v of def.enum) schema.check(v)\n\n const result =\n def.const != null\n ? l.literal(def.const)\n : def.enum != null\n ? l.enum(def.enum)\n : schema\n\n return def.default != null ? l.withDefault(result, def.default) : result\n }\n case 'integer': {\n const schema = l.integer(def)\n if (def.default != null) schema.check(def.default)\n if (def.const != null) schema.check(def.const)\n if (def.enum != null) for (const v of def.enum) schema.check(v)\n\n const result =\n def.const != null\n ? l.literal(def.const)\n : def.enum != null\n ? l.enum(def.enum)\n : schema\n\n return def.default != null ? l.withDefault(result, def.default) : result\n }\n case 'boolean': {\n const result = def.const != null ? l.literal(def.const) : l.boolean()\n\n return def.default != null ? l.withDefault(result, def.default) : result\n }\n case 'blob':\n return l.blob(def)\n case 'cid-link':\n return l.cid()\n case 'bytes':\n return l.bytes(def)\n case 'unknown':\n return l.lexMap()\n case 'array':\n return l.array(this.compileLeaf(doc, def.items), def)\n default:\n return this.compileRef(doc, def)\n }\n }\n\n protected compileRef(\n doc: LexiconDocument,\n def: LexiconRef | LexiconRefUnion,\n ): l.Schema<LexValue> {\n switch (def.type) {\n case 'ref':\n return l.ref(this.buildRefGetter(buildFullRef(doc, def.ref)))\n case 'union':\n return l.typedUnion(\n def.refs.map((r) =>\n l.typedRef(this.buildTypedRefGetter(buildFullRef(doc, r))),\n ),\n def.closed ?? false,\n )\n default:\n // @ts-expect-error\n throw new Error(`Unknown lexicon type: ${def.type}`)\n }\n }\n\n protected compileObject(doc: LexiconDocument, def: LexiconObject) {\n const props: Record<string, l.Schema<undefined | LexValue>> = {}\n for (const [key, propDef] of Object.entries(def.properties)) {\n if (propDef === undefined) continue\n\n const isNullable = def.nullable?.includes(key)\n const isRequired = def.required?.includes(key)\n\n let schema: l.Schema<undefined | LexValue> = this.compileLeaf(\n doc,\n propDef,\n )\n\n if (isNullable) {\n schema = l.nullable(schema)\n }\n\n if (!isRequired) {\n schema = l.optional(schema)\n }\n\n props[key] = schema\n }\n return l.object(props)\n }\n\n protected compilePayload(\n doc: LexiconDocument,\n def: LexiconPayload | undefined,\n ) {\n return l.payload(\n def?.encoding,\n def?.schema ? this.compilePayloadSchema(doc, def.schema) : undefined,\n )\n }\n\n protected compileErrors(\n _doc: LexiconDocument,\n errors?: readonly LexiconError[],\n ): undefined | string[] {\n return errors?.map((e) => e.name)\n }\n\n protected compilePayloadSchema(\n doc: LexiconDocument,\n def: LexiconObject | LexiconRef | LexiconRefUnion,\n ): l.Schema<LexValue, LexValue> {\n switch (def.type) {\n case 'object':\n return this.compileObject(doc, def)\n default:\n return this.compileRef(doc, def)\n }\n }\n\n protected compileParams(doc: LexiconDocument, def?: LexiconParameters) {\n if (!def) return l.params()\n\n const shape: l.ParamsShape = {}\n for (const [paramName, paramDef] of Object.entries(def.properties)) {\n if (paramDef === undefined) continue\n\n const isRequired = def.required?.includes(paramName)\n\n const propSchema = this.compileLeaf(doc, paramDef) as\n | l.StringSchema\n | l.BooleanSchema\n | l.IntegerSchema\n | l.ArraySchema<l.StringSchema>\n | l.ArraySchema<l.BooleanSchema>\n | l.ArraySchema<l.IntegerSchema>\n\n shape[paramName] = isRequired ? propSchema : l.optional(propSchema)\n }\n\n return l.params(shape)\n }\n}\n\nclass AsyncTasks {\n /**\n * A set that, eventually, contains only rejected promises.\n */\n #promises = new Set<Promise<void>>()\n\n async done(): Promise<void> {\n do {\n // @NOTE this is going to throw on the first rejected promise (which is\n // what we want)\n for (const p of this.#promises) await p\n // At this point, all settled promises should have been removed. If\n // this.#promises is not empty, it means new promises were added during\n // the awaiting process, so we loop again.\n } while (this.#promises.size > 0)\n }\n\n add(p: Promise<void>) {\n const promise = Promise.resolve(p).then(() => {\n // No need to keep the promise any longer\n this.#promises.delete(promise)\n })\n\n void promise.catch((_err) => {\n // ignore errors here, they should be caught though done()\n })\n\n this.#promises.add(promise)\n }\n}\n\nfunction parseRef(fullRef: string) {\n const { length, 0: nsid, 1: hash } = fullRef.split('#')\n if (length !== 2) throw new Error('Uri can only have one hash segment')\n if (!nsid || !hash) throw new Error('Invalid ref, missing hash')\n return { nsid, hash }\n}\n\nfunction buildFullRef(from: LexiconDocument, ref: string) {\n if (ref.startsWith('#')) return `${from.id}${ref}`\n return ref\n}\n\nexport function memoize<Fn extends (arg: string) => unknown>(fn: Fn): Fn {\n const cache = new Map<string, ReturnType<Fn>>()\n return ((arg: string) => {\n if (cache.has(arg)) return cache.get(arg)!\n const result = fn(arg) as ReturnType<Fn>\n cache.set(arg, result)\n return result\n }) as Fn\n}\n\nfunction isAsyncIterableObject<T>(\n obj: T,\n): obj is T & object & AsyncIterable<unknown> {\n return (\n obj != null &&\n typeof obj === 'object' &&\n Symbol.asyncIterator in obj &&\n typeof obj[Symbol.asyncIterator] === 'function'\n )\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/lex-document",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "engines": {
5
5
  "node": ">=22"
6
6
  },
@@ -37,14 +37,14 @@
37
37
  "dependencies": {
38
38
  "core-js": "^3",
39
39
  "tslib": "^2.8.1",
40
- "@atproto/lex-schema": "^0.1.0"
40
+ "@atproto/lex-schema": "^0.1.5"
41
41
  },
42
42
  "devDependencies": {
43
43
  "vitest": "^4.0.16",
44
- "@atproto/lex-data": "^0.1.0"
44
+ "@atproto/lex-data": "^0.1.3"
45
45
  },
46
46
  "scripts": {
47
- "build": "tsc --build tsconfig.build.json",
47
+ "build": "tsgo --build tsconfig.build.json",
48
48
  "test": "vitest run"
49
49
  }
50
50
  }
@@ -536,6 +536,13 @@ export const lexiconProcedureSchema = l.object({
536
536
  */
537
537
  export type LexiconProcedure = l.Infer<typeof lexiconProcedureSchema>
538
538
 
539
+ export const lexiconMessageSchema = l.object({
540
+ description: l.optional(l.string()),
541
+ schema: lexiconRefUnionSchema,
542
+ })
543
+
544
+ export type LexiconMessage = l.Infer<typeof lexiconMessageSchema>
545
+
539
546
  /**
540
547
  * Schema for validating Lexicon subscription (WebSocket) method definitions.
541
548
  *
@@ -547,10 +554,7 @@ export const lexiconSubscriptionSchema = l.object({
547
554
  type: l.literal('subscription'),
548
555
  description: l.optional(l.string()),
549
556
  parameters: l.optional(lexiconParameters),
550
- message: l.object({
551
- description: l.optional(l.string()),
552
- schema: lexiconRefUnionSchema,
553
- }),
557
+ message: lexiconMessageSchema,
554
558
  errors: l.optional(l.array(lexiconError)),
555
559
  })
556
560
 
@@ -7,6 +7,6 @@
7
7
  "importHelpers": true,
8
8
  "target": "ES2023",
9
9
  "rootDir": "./src",
10
- "outDir": "./dist"
11
- }
10
+ "outDir": "./dist",
11
+ },
12
12
  }
package/tsconfig.json CHANGED
@@ -2,6 +2,6 @@
2
2
  "include": [],
3
3
  "references": [
4
4
  { "path": "./tsconfig.build.json" },
5
- { "path": "./tsconfig.tests.json" }
6
- ]
5
+ { "path": "./tsconfig.tests.json" },
6
+ ],
7
7
  }
@@ -4,6 +4,5 @@
4
4
  "compilerOptions": {
5
5
  "noImplicitAny": true,
6
6
  "rootDir": "./",
7
- "baseUrl": "./"
8
- }
7
+ },
9
8
  }