@atproto/lex-document 0.0.12 → 0.0.13

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.
@@ -1,15 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.lexiconDocumentSchema = exports.lexiconIdentifierSchema = exports.lexiconSubscriptionSchema = exports.lexiconProcedureSchema = exports.lexiconQuerySchema = exports.lexiconError = exports.lexiconPayload = exports.lexiconParameters = exports.lexiconRecordSchema = exports.lexiconRecordKeySchema = exports.lexiconObjectSchema = exports.lexiconArraySchema = exports.lexiconRefUnionSchema = exports.lexiconRefSchema = exports.lexiconTokenSchema = exports.lexiconUnknownSchema = exports.lexiconBlobSchema = exports.lexiconCidLinkSchema = exports.lexiconBytesSchema = exports.lexiconStringSchema = exports.lexiconIntegerSchema = exports.lexiconBooleanSchema = void 0;
3
+ exports.lexiconDocumentSchema = exports.lexiconIdentifierSchema = exports.lexiconPermissionSetSchema = exports.lexiconPermissionSchema = exports.lexiconLanguageDict = exports.lexiconLanguageSchema = exports.lexiconSubscriptionSchema = exports.lexiconProcedureSchema = exports.lexiconQuerySchema = exports.lexiconError = exports.lexiconPayload = exports.lexiconParameters = exports.lexiconRecordSchema = exports.lexiconRecordKeySchema = exports.lexiconObjectSchema = exports.lexiconArraySchema = exports.lexiconRefUnionSchema = exports.lexiconRefSchema = exports.lexiconTokenSchema = exports.lexiconUnknownSchema = exports.lexiconBlobSchema = exports.lexiconCidLinkSchema = exports.lexiconBytesSchema = exports.lexiconStringSchema = exports.lexiconIntegerSchema = exports.lexiconBooleanSchema = void 0;
4
4
  const lex_schema_1 = require("@atproto/lex-schema");
5
5
  // https://atproto.com/specs/lexicon
6
6
  // "Concrete" Types
7
+ /**
8
+ * Schema for validating Lexicon boolean type definitions.
9
+ *
10
+ * Validates boolean field definitions that may include a default value,
11
+ * a constant value, and an optional description.
12
+ */
7
13
  exports.lexiconBooleanSchema = lex_schema_1.l.object({
8
14
  type: lex_schema_1.l.literal('boolean'),
9
15
  default: lex_schema_1.l.optional(lex_schema_1.l.boolean()),
10
16
  const: lex_schema_1.l.optional(lex_schema_1.l.boolean()),
11
17
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
12
18
  });
19
+ /**
20
+ * Schema for validating Lexicon integer type definitions.
21
+ *
22
+ * Validates integer field definitions with support for default values,
23
+ * minimum/maximum constraints, enumerated values, and constant values.
24
+ */
13
25
  exports.lexiconIntegerSchema = lex_schema_1.l.object({
14
26
  type: lex_schema_1.l.literal('integer'),
15
27
  default: lex_schema_1.l.optional(lex_schema_1.l.integer()),
@@ -19,6 +31,13 @@ exports.lexiconIntegerSchema = lex_schema_1.l.object({
19
31
  const: lex_schema_1.l.optional(lex_schema_1.l.integer()),
20
32
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
21
33
  });
34
+ /**
35
+ * Schema for validating Lexicon string type definitions.
36
+ *
37
+ * Validates string field definitions with support for format validation,
38
+ * length constraints (both character and grapheme-based), enumerated values,
39
+ * known values, and constant values.
40
+ */
22
41
  exports.lexiconStringSchema = lex_schema_1.l.object({
23
42
  type: lex_schema_1.l.literal('string'),
24
43
  format: lex_schema_1.l.optional(lex_schema_1.l.enum(lex_schema_1.l.STRING_FORMATS)),
@@ -32,22 +51,44 @@ exports.lexiconStringSchema = lex_schema_1.l.object({
32
51
  knownValues: lex_schema_1.l.optional(lex_schema_1.l.array(lex_schema_1.l.string())),
33
52
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
34
53
  });
54
+ /**
55
+ * Schema for validating Lexicon bytes type definitions.
56
+ *
57
+ * Validates binary data field definitions with optional length constraints.
58
+ * Used for raw byte arrays in DAG-CBOR encoding.
59
+ */
35
60
  exports.lexiconBytesSchema = lex_schema_1.l.object({
36
61
  type: lex_schema_1.l.literal('bytes'),
37
62
  maxLength: lex_schema_1.l.optional(lex_schema_1.l.integer()),
38
63
  minLength: lex_schema_1.l.optional(lex_schema_1.l.integer()),
39
64
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
40
65
  });
66
+ /**
67
+ * Schema for validating Lexicon CID link type definitions.
68
+ *
69
+ * Validates Content Identifier (CID) link field definitions.
70
+ * CIDs are used to reference content-addressed data in IPFS/IPLD.
71
+ */
41
72
  exports.lexiconCidLinkSchema = lex_schema_1.l.object({
42
73
  type: lex_schema_1.l.literal('cid-link'),
43
74
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
44
75
  });
76
+ /**
77
+ * Schema for validating Lexicon blob type definitions.
78
+ *
79
+ * Validates blob field definitions with optional MIME type acceptance list
80
+ * and maximum size constraints. Blobs represent uploaded file references.
81
+ */
45
82
  exports.lexiconBlobSchema = lex_schema_1.l.object({
46
83
  type: lex_schema_1.l.literal('blob'),
47
84
  accept: lex_schema_1.l.optional(lex_schema_1.l.array(lex_schema_1.l.string())),
48
85
  maxSize: lex_schema_1.l.optional(lex_schema_1.l.integer()),
49
86
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
50
87
  });
88
+ /**
89
+ * Array of all concrete (primitive) Lexicon type schemas.
90
+ * Includes boolean, integer, string, bytes, cid-link, and blob types.
91
+ */
51
92
  const CONCRETE_TYPES = [
52
93
  exports.lexiconBooleanSchema,
53
94
  exports.lexiconIntegerSchema,
@@ -59,19 +100,46 @@ const CONCRETE_TYPES = [
59
100
  exports.lexiconBlobSchema,
60
101
  ];
61
102
  // Meta types
103
+ /**
104
+ * Schema for validating Lexicon unknown type definitions.
105
+ *
106
+ * Validates unknown field definitions which accept any valid data.
107
+ * Used when the schema cannot determine the type ahead of time.
108
+ */
62
109
  exports.lexiconUnknownSchema = lex_schema_1.l.object({
63
110
  type: lex_schema_1.l.literal('unknown'),
64
111
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
65
112
  });
113
+ /**
114
+ * Schema for validating Lexicon token type definitions.
115
+ *
116
+ * Validates token definitions which represent symbolic constants.
117
+ * Tokens are used to define enumeration-like values that can be
118
+ * referenced across different lexicons.
119
+ */
66
120
  exports.lexiconTokenSchema = lex_schema_1.l.object({
67
121
  type: lex_schema_1.l.literal('token'),
68
122
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
69
123
  });
124
+ /**
125
+ * Schema for validating Lexicon reference type definitions.
126
+ *
127
+ * Validates reference definitions which point to other type definitions
128
+ * within the same or different Lexicon documents. References use the
129
+ * format "nsid#defName" for cross-document refs or "#defName" for local refs.
130
+ */
70
131
  exports.lexiconRefSchema = lex_schema_1.l.object({
71
132
  type: lex_schema_1.l.literal('ref'),
72
133
  ref: lex_schema_1.l.string(),
73
134
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
74
135
  });
136
+ /**
137
+ * Schema for validating Lexicon union reference type definitions.
138
+ *
139
+ * Validates union definitions which can reference multiple possible types.
140
+ * The union can be closed (only listed types allowed) or open (allows
141
+ * additional unlisted types).
142
+ */
75
143
  exports.lexiconRefUnionSchema = lex_schema_1.l.object({
76
144
  type: lex_schema_1.l.literal('union'),
77
145
  refs: lex_schema_1.l.array(lex_schema_1.l.string()),
@@ -86,6 +154,12 @@ const ARRAY_ITEMS_SCHEMAS = [
86
154
  exports.lexiconRefSchema,
87
155
  exports.lexiconRefUnionSchema,
88
156
  ];
157
+ /**
158
+ * Schema for validating Lexicon array type definitions.
159
+ *
160
+ * Validates array field definitions with specified item type and
161
+ * optional length constraints.
162
+ */
89
163
  exports.lexiconArraySchema = lex_schema_1.l.object({
90
164
  type: lex_schema_1.l.literal('array'),
91
165
  items: lex_schema_1.l.discriminatedUnion('type', ARRAY_ITEMS_SCHEMAS),
@@ -98,6 +172,13 @@ const requirePropertiesRefinement = {
98
172
  message: 'All required parameters must be defined in properties',
99
173
  path: 'required',
100
174
  };
175
+ /**
176
+ * Schema for validating Lexicon object type definitions.
177
+ *
178
+ * Validates object definitions with named properties, required field lists,
179
+ * and nullable field lists. Includes refinement to ensure all required
180
+ * properties are defined in the properties map.
181
+ */
101
182
  exports.lexiconObjectSchema = lex_schema_1.l.refine(lex_schema_1.l.object({
102
183
  type: lex_schema_1.l.literal('object'),
103
184
  properties: lex_schema_1.l.dict(lex_schema_1.l.string(), lex_schema_1.l.discriminatedUnion('type', [
@@ -109,7 +190,23 @@ exports.lexiconObjectSchema = lex_schema_1.l.refine(lex_schema_1.l.object({
109
190
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
110
191
  }), requirePropertiesRefinement);
111
192
  // Records
193
+ /**
194
+ * Schema for validating Lexicon record key definitions.
195
+ *
196
+ * Validates record key type specifications. Valid values are:
197
+ * - "any": Any valid record key
198
+ * - "nsid": Namespaced identifier
199
+ * - "tid": Timestamp identifier
200
+ * - "literal:<string>": A specific literal string value
201
+ */
112
202
  exports.lexiconRecordKeySchema = lex_schema_1.l.custom(lex_schema_1.l.isLexiconRecordKey, 'Invalid record key definition (must be "any", "nsid", "tid", or "literal:<string>")');
203
+ /**
204
+ * Schema for validating Lexicon record type definitions.
205
+ *
206
+ * Validates record definitions which define the structure of data
207
+ * stored in AT Protocol repositories. Records have a key type
208
+ * and an object schema defining the record's data structure.
209
+ */
113
210
  exports.lexiconRecordSchema = lex_schema_1.l.object({
114
211
  type: lex_schema_1.l.literal('record'),
115
212
  record: exports.lexiconObjectSchema,
@@ -117,6 +214,13 @@ exports.lexiconRecordSchema = lex_schema_1.l.object({
117
214
  key: exports.lexiconRecordKeySchema,
118
215
  });
119
216
  // XRPC Methods
217
+ /**
218
+ * Schema for validating Lexicon XRPC method parameters.
219
+ *
220
+ * Validates the parameters definition for query and procedure methods.
221
+ * Parameters can only be primitive types (boolean, integer, string)
222
+ * or arrays of primitives.
223
+ */
120
224
  exports.lexiconParameters = lex_schema_1.l.refine(lex_schema_1.l.object({
121
225
  type: lex_schema_1.l.literal('params'),
122
226
  properties: lex_schema_1.l.dict(lex_schema_1.l.string(), lex_schema_1.l.discriminatedUnion('type', [
@@ -138,6 +242,13 @@ exports.lexiconParameters = lex_schema_1.l.refine(lex_schema_1.l.object({
138
242
  required: lex_schema_1.l.optional(lex_schema_1.l.array(lex_schema_1.l.string())),
139
243
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
140
244
  }), requirePropertiesRefinement);
245
+ /**
246
+ * Schema for validating Lexicon XRPC method payloads.
247
+ *
248
+ * Validates input/output payload definitions for procedures and queries.
249
+ * Payloads specify the encoding (MIME type) and optional schema for
250
+ * the request or response body.
251
+ */
141
252
  exports.lexiconPayload = lex_schema_1.l.object({
142
253
  encoding: lex_schema_1.l.string(),
143
254
  schema: lex_schema_1.l.optional(lex_schema_1.l.discriminatedUnion('type', [
@@ -147,10 +258,23 @@ exports.lexiconPayload = lex_schema_1.l.object({
147
258
  ])),
148
259
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
149
260
  });
261
+ /**
262
+ * Schema for validating Lexicon XRPC error definitions.
263
+ *
264
+ * Validates error definitions that can be returned by XRPC methods.
265
+ * Each error has a name and optional description.
266
+ */
150
267
  exports.lexiconError = lex_schema_1.l.object({
151
268
  name: lex_schema_1.l.string({ minLength: 1 }),
152
269
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
153
270
  });
271
+ /**
272
+ * Schema for validating Lexicon query (GET) method definitions.
273
+ *
274
+ * Validates query method definitions which represent read-only HTTP GET
275
+ * operations. Queries can have parameters, an output payload, and
276
+ * defined error types.
277
+ */
154
278
  exports.lexiconQuerySchema = lex_schema_1.l.object({
155
279
  type: lex_schema_1.l.literal('query'),
156
280
  parameters: lex_schema_1.l.optional(exports.lexiconParameters),
@@ -158,6 +282,13 @@ exports.lexiconQuerySchema = lex_schema_1.l.object({
158
282
  errors: lex_schema_1.l.optional(lex_schema_1.l.array(exports.lexiconError)),
159
283
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
160
284
  });
285
+ /**
286
+ * Schema for validating Lexicon procedure (POST) method definitions.
287
+ *
288
+ * Validates procedure method definitions which represent HTTP POST
289
+ * operations that may modify state. Procedures can have parameters,
290
+ * input payload, output payload, and defined error types.
291
+ */
161
292
  exports.lexiconProcedureSchema = lex_schema_1.l.object({
162
293
  type: lex_schema_1.l.literal('procedure'),
163
294
  parameters: lex_schema_1.l.optional(exports.lexiconParameters),
@@ -166,6 +297,13 @@ exports.lexiconProcedureSchema = lex_schema_1.l.object({
166
297
  errors: lex_schema_1.l.optional(lex_schema_1.l.array(exports.lexiconError)),
167
298
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
168
299
  });
300
+ /**
301
+ * Schema for validating Lexicon subscription (WebSocket) method definitions.
302
+ *
303
+ * Validates subscription method definitions which represent real-time
304
+ * streaming connections over WebSocket. Subscriptions have parameters,
305
+ * a message schema defining the streamed data format, and error types.
306
+ */
169
307
  exports.lexiconSubscriptionSchema = lex_schema_1.l.object({
170
308
  type: lex_schema_1.l.literal('subscription'),
171
309
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
@@ -177,38 +315,91 @@ exports.lexiconSubscriptionSchema = lex_schema_1.l.object({
177
315
  errors: lex_schema_1.l.optional(lex_schema_1.l.array(exports.lexiconError)),
178
316
  });
179
317
  // Permissions
180
- const lexiconLanguageSchema = lex_schema_1.l.string({ format: 'language' });
181
- const lexiconLanguageDict = lex_schema_1.l.dict(lexiconLanguageSchema, lex_schema_1.l.string());
182
- const lexiconPermissionSchema = lex_schema_1.l.intersection(lex_schema_1.l.object({
318
+ /**
319
+ * Schema for validating language codes in Lexicon permission definitions.
320
+ */
321
+ exports.lexiconLanguageSchema = lex_schema_1.l.string({ format: 'language' });
322
+ /**
323
+ * Schema for validating language-keyed string dictionaries.
324
+ * Used for localized text in permission definitions.
325
+ */
326
+ exports.lexiconLanguageDict = lex_schema_1.l.dict(exports.lexiconLanguageSchema, lex_schema_1.l.string());
327
+ /**
328
+ * Schema for validating individual Lexicon permission definitions.
329
+ */
330
+ exports.lexiconPermissionSchema = lex_schema_1.l.intersection(lex_schema_1.l.object({
183
331
  type: lex_schema_1.l.literal('permission'),
184
332
  resource: lex_schema_1.l.string({ minLength: 1 }),
185
333
  }), lex_schema_1.l.dict(lex_schema_1.l.string(), lex_schema_1.l.paramSchema));
186
- const lexiconPermissionSetSchema = lex_schema_1.l.object({
334
+ /**
335
+ * Schema for validating Lexicon permission set definitions.
336
+ */
337
+ exports.lexiconPermissionSetSchema = lex_schema_1.l.object({
187
338
  type: lex_schema_1.l.literal('permission-set'),
188
- permissions: lex_schema_1.l.array(lexiconPermissionSchema),
339
+ permissions: lex_schema_1.l.array(exports.lexiconPermissionSchema),
189
340
  title: lex_schema_1.l.optional(lex_schema_1.l.string()),
190
- 'title:lang': lex_schema_1.l.optional(lexiconLanguageDict),
341
+ 'title:lang': lex_schema_1.l.optional(exports.lexiconLanguageDict),
191
342
  detail: lex_schema_1.l.optional(lex_schema_1.l.string()),
192
- 'detail:lang': lex_schema_1.l.optional(lexiconLanguageDict),
343
+ 'detail:lang': lex_schema_1.l.optional(exports.lexiconLanguageDict),
193
344
  description: lex_schema_1.l.optional(lex_schema_1.l.string()),
194
345
  });
195
- // Schemas that can appear anywhere in the defs
196
346
  const NAMED_LEXICON_SCHEMAS = [
197
347
  ...CONCRETE_TYPES,
198
348
  exports.lexiconArraySchema,
199
349
  exports.lexiconObjectSchema,
200
350
  exports.lexiconTokenSchema,
201
351
  ];
202
- // Schemas that can only appear as "main" def
203
352
  const MAIN_LEXICON_SCHEMAS = [
204
- lexiconPermissionSetSchema,
353
+ exports.lexiconPermissionSetSchema,
205
354
  exports.lexiconProcedureSchema,
206
355
  exports.lexiconQuerySchema,
207
356
  exports.lexiconRecordSchema,
208
357
  exports.lexiconSubscriptionSchema,
209
358
  ...NAMED_LEXICON_SCHEMAS,
210
359
  ];
360
+ /**
361
+ * Schema for validating Lexicon document identifiers (NSIDs).
362
+ *
363
+ * Validates that the identifier follows the Namespaced Identifier format
364
+ * (e.g., "com.atproto.repo.createRecord").
365
+ */
211
366
  exports.lexiconIdentifierSchema = lex_schema_1.l.string({ format: 'nsid' });
367
+ /**
368
+ * Schema for validating complete Lexicon document structures.
369
+ *
370
+ * Validates the top-level structure of a Lexicon document, including:
371
+ * - `lexicon`: Must be 1 (the current Lexicon version)
372
+ * - `id`: The document's NSID
373
+ * - `revision`: Optional version number
374
+ * - `description`: Optional document description
375
+ * - `defs`: Map of definition names to their schemas
376
+ *
377
+ * The "main" definition (if present) can be any main-only type,
378
+ * while other definitions are limited to named types.
379
+ *
380
+ * @example
381
+ * ```ts
382
+ * const result = lexiconDocumentSchema.parse({
383
+ * lexicon: 1,
384
+ * id: 'com.example.getProfile',
385
+ * defs: {
386
+ * main: {
387
+ * type: 'query',
388
+ * output: {
389
+ * encoding: 'application/json',
390
+ * schema: { type: 'ref', ref: '#profile' }
391
+ * }
392
+ * },
393
+ * profile: {
394
+ * type: 'object',
395
+ * properties: {
396
+ * name: { type: 'string' }
397
+ * }
398
+ * }
399
+ * }
400
+ * })
401
+ * ```
402
+ */
212
403
  exports.lexiconDocumentSchema = lex_schema_1.l.object({
213
404
  lexicon: lex_schema_1.l.literal(1),
214
405
  id: exports.lexiconIdentifierSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-document.js","sourceRoot":"","sources":["../src/lexicon-document.ts"],"names":[],"mappings":";;;AAAA,oDAAuC;AAEvC,oCAAoC;AAEpC,mBAAmB;AAEN,QAAA,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;AAGW,QAAA,oBAAoB,GAAG,cAAC,CAAC,MAAM,CAAC;IAC3C,IAAI,EAAE,cAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,cAAC,CAAC,QAAQ,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AAE,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\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})\nexport type LexiconBoolean = l.Infer<typeof lexiconBooleanSchema>\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})\nexport type LexiconInteger = l.Infer<typeof lexiconIntegerSchema>\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})\nexport type LexiconString = l.Infer<typeof lexiconStringSchema>\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})\nexport type LexiconBytes = l.Infer<typeof lexiconBytesSchema>\n\nexport const lexiconCidLinkSchema = l.object({\n type: l.literal('cid-link'),\n description: l.optional(l.string()),\n})\nexport type LexiconCid = l.Infer<typeof lexiconCidLinkSchema>\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})\nexport type LexiconBlob = l.Infer<typeof lexiconBlobSchema>\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\nexport const lexiconUnknownSchema = l.object({\n type: l.literal('unknown'),\n description: l.optional(l.string()),\n})\nexport type LexiconUnknown = l.Infer<typeof lexiconUnknownSchema>\n\nexport const lexiconTokenSchema = l.object({\n type: l.literal('token'),\n description: l.optional(l.string()),\n})\nexport type LexiconToken = l.Infer<typeof lexiconTokenSchema>\n\nexport const lexiconRefSchema = l.object({\n type: l.literal('ref'),\n ref: l.string(),\n description: l.optional(l.string()),\n})\nexport type LexiconRef = l.Infer<typeof lexiconRefSchema>\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})\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\nexport type LexiconArrayItems = l.Infer<(typeof ARRAY_ITEMS_SCHEMAS)[number]>\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})\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\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)\nexport type LexiconObject = l.Infer<typeof lexiconObjectSchema>\n\n// Records\n\nexport const lexiconRecordKeySchema = l.custom(\n l.isLexiconRecordKey,\n 'Invalid record key definition (must be \"any\", \"nsid\", \"tid\", or \"literal:<string>\")',\n)\n\nexport type LexiconRecordKey = l.LexiconRecordKey\n\nexport const lexiconRecordSchema = l.object({\n type: l.literal('record'),\n record: lexiconObjectSchema,\n description: l.optional(l.string()),\n key: lexiconRecordKeySchema,\n})\nexport type LexiconRecord = l.Infer<typeof lexiconRecordSchema>\n\n// XRPC Methods\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)\nexport type LexiconParameters = l.Infer<typeof lexiconParameters>\n\nexport const lexiconPayload = l.object({\n encoding: l.string(),\n schema: l.optional(\n l.discriminatedUnion('type', [\n lexiconRefSchema,\n lexiconRefUnionSchema,\n lexiconObjectSchema,\n ]),\n ),\n description: l.optional(l.string()),\n})\nexport type LexiconPayload = l.Infer<typeof lexiconPayload>\n\nexport const lexiconError = l.object({\n name: l.string({ minLength: 1 }),\n description: l.optional(l.string()),\n})\nexport type LexiconError = l.Infer<typeof lexiconError>\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})\nexport type LexiconQuery = l.Infer<typeof lexiconQuerySchema>\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})\nexport type LexiconProcedure = l.Infer<typeof lexiconProcedureSchema>\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\nexport type LexiconSubscription = l.Infer<typeof lexiconSubscriptionSchema>\n\n// Permissions\n\nconst lexiconLanguageSchema = l.string({ format: 'language' })\n\nexport type LexiconLanguage = l.Infer<typeof lexiconLanguageSchema>\n\nconst lexiconLanguageDict = l.dict(lexiconLanguageSchema, l.string())\n\nexport type LexiconLanguageDict = l.Infer<typeof lexiconLanguageDict>\n\nconst 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\nexport type LexiconPermission = l.Infer<typeof lexiconPermissionSchema>\n\nconst 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\nexport type LexiconPermissionSet = l.Infer<typeof lexiconPermissionSetSchema>\n\n// Schemas that can appear anywhere in the defs\nconst NAMED_LEXICON_SCHEMAS = [\n ...CONCRETE_TYPES,\n lexiconArraySchema,\n lexiconObjectSchema,\n lexiconTokenSchema,\n] as const\n\nexport type NamedLexiconDefinition = l.Infer<\n (typeof NAMED_LEXICON_SCHEMAS)[number]\n>\n\n// Schemas that can only appear as \"main\" def\nconst MAIN_LEXICON_SCHEMAS = [\n lexiconPermissionSetSchema,\n lexiconProcedureSchema,\n lexiconQuerySchema,\n lexiconRecordSchema,\n lexiconSubscriptionSchema,\n ...NAMED_LEXICON_SCHEMAS,\n] as const\n\nexport type MainLexiconDefinition = l.Infer<\n (typeof MAIN_LEXICON_SCHEMAS)[number]\n>\n\nexport const lexiconIdentifierSchema = l.string({ format: 'nsid' })\nexport type LexiconIdentifier = l.Infer<typeof lexiconIdentifierSchema>\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})\nexport type LexiconDocument = l.Infer<typeof lexiconDocumentSchema>\n"]}
1
+ {"version":3,"file":"lexicon-document.js","sourceRoot":"","sources":["../src/lexicon-document.ts"],"names":[],"mappings":";;;AAAA,oDAAuC;AAEvC,oCAAoC;AAEpC,mBAAmB;AAEnB;;;;;GAKG;AACU,QAAA,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,cAA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AAkB;CACV,CAAA;AAYV,MAAM,oBAAoB,GAAG;IAC3B,kCAA0B;IAC1B,8BAAsB;IACtB,0BAAkB;IAClB,2BAAmB;IACnB,iCAAyB;IACzB,GAAG,qBAAqB;CAChB,CAAA;AAYV;;;;;GAKG;AACU,QAAA,uBAAuB,GAAG,cAAC,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAA;AAWnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACU,QAAA,qBAAqB,GAAG,cAAC,CAAC,MAAM,CAAC;IAC5C,OAAO,EAAE,cAAC,CAAC,OAAO,CAAC,CAAC,CAAC;IACrB,EAAE,EAAE,+BAAuB;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.string(),\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,7 +1,58 @@
1
1
  import { LexiconDocument } from './lexicon-document.js';
2
+ /**
3
+ * Interface for indexing and retrieving Lexicon documents by their NSID.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * // Using a custom indexer implementation
8
+ * const networkIndexer: LexiconIndexer = {
9
+ * async get(nsid: string) {
10
+ * const doc = await resolveLexicon(nsid)
11
+ * return doc
12
+ * }
13
+ * }
14
+ *
15
+ * const validator = await LexiconSchemaBuilder.build(networkIndexer, 'com.example.post#main')
16
+ * ```
17
+ */
2
18
  export interface LexiconIndexer {
19
+ /**
20
+ * Retrieves a Lexicon document by its NSID.
21
+ *
22
+ * @param nsid - The Namespaced Identifier of the Lexicon document to retrieve
23
+ * @returns A promise that resolves to the Lexicon document
24
+ * @throws When the document with the given NSID cannot be found
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const doc = await indexer.get('com.atproto.repo.createRecord')
29
+ * console.log(doc.defs.main?.type) // 'procedure'
30
+ * ```
31
+ */
3
32
  get(nsid: string): Promise<LexiconDocument>;
33
+ /**
34
+ * Optional async disposal method for cleanup.
35
+ *
36
+ * When implemented, allows the indexer to be used with `await using`
37
+ * syntax for automatic resource cleanup.
38
+ *
39
+ * @returns A promise that resolves when disposal is complete
40
+ */
4
41
  [Symbol.asyncDispose]?: () => Promise<void>;
42
+ /**
43
+ * Optional async iterator for iterating over all available Lexicon documents.
44
+ *
45
+ * @returns An async iterator yielding Lexicon documents
46
+ *
47
+ * @example
48
+ * ```ts
49
+ * if (Symbol.asyncIterator in indexer) {
50
+ * for await (const doc of indexer) {
51
+ * console.log(doc.id)
52
+ * }
53
+ * }
54
+ * ```
55
+ */
5
56
  [Symbol.asyncIterator]?: () => AsyncIterator<LexiconDocument, void, unknown>;
6
57
  }
7
58
  //# sourceMappingURL=lexicon-indexer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-indexer.d.ts","sourceRoot":"","sources":["../src/lexicon-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAE3C,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3C,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,aAAa,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;CAC7E"}
1
+ {"version":3,"file":"lexicon-indexer.d.ts","sourceRoot":"","sources":["../src/lexicon-indexer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;;;;;;;OAYG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;IAE3C;;;;;;;OAOG;IACH,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAE3C;;;;;;;;;;;;;OAaG;IACH,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,aAAa,CAAC,eAAe,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;CAC7E"}
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-indexer.js","sourceRoot":"","sources":["../src/lexicon-indexer.ts"],"names":[],"mappings":"","sourcesContent":["import { LexiconDocument } from './lexicon-document.js'\n\nexport interface LexiconIndexer {\n get(nsid: string): Promise<LexiconDocument>\n\n [Symbol.asyncDispose]?: () => Promise<void>\n [Symbol.asyncIterator]?: () => AsyncIterator<LexiconDocument, void, unknown>\n}\n"]}
1
+ {"version":3,"file":"lexicon-indexer.js","sourceRoot":"","sources":["../src/lexicon-indexer.ts"],"names":[],"mappings":"","sourcesContent":["import { LexiconDocument } from './lexicon-document.js'\n\n/**\n * Interface for indexing and retrieving Lexicon documents by their NSID.\n *\n * @example\n * ```ts\n * // Using a custom indexer implementation\n * const networkIndexer: LexiconIndexer = {\n * async get(nsid: string) {\n * const doc = await resolveLexicon(nsid)\n * return doc\n * }\n * }\n *\n * const validator = await LexiconSchemaBuilder.build(networkIndexer, 'com.example.post#main')\n * ```\n */\nexport interface LexiconIndexer {\n /**\n * Retrieves a Lexicon document by its NSID.\n *\n * @param nsid - The Namespaced Identifier of the Lexicon document to retrieve\n * @returns A promise that resolves to the Lexicon document\n * @throws When the document with the given NSID cannot be found\n *\n * @example\n * ```ts\n * const doc = await indexer.get('com.atproto.repo.createRecord')\n * console.log(doc.defs.main?.type) // 'procedure'\n * ```\n */\n get(nsid: string): Promise<LexiconDocument>\n\n /**\n * Optional async disposal method for cleanup.\n *\n * When implemented, allows the indexer to be used with `await using`\n * syntax for automatic resource cleanup.\n *\n * @returns A promise that resolves when disposal is complete\n */\n [Symbol.asyncDispose]?: () => Promise<void>\n\n /**\n * Optional async iterator for iterating over all available Lexicon documents.\n *\n * @returns An async iterator yielding Lexicon documents\n *\n * @example\n * ```ts\n * if (Symbol.asyncIterator in indexer) {\n * for await (const doc of indexer) {\n * console.log(doc.id)\n * }\n * }\n * ```\n */\n [Symbol.asyncIterator]?: () => AsyncIterator<LexiconDocument, void, unknown>\n}\n"]}
@@ -1,12 +1,62 @@
1
1
  import { LexiconDocument } from './lexicon-document.js';
2
2
  import { LexiconIndexer } from './lexicon-indexer.js';
3
3
  /**
4
- * (Lazily) indexes lexicon documents from an iterable source.
4
+ * Lazily indexes Lexicon documents from an iterable source.
5
+ *
6
+ * This class implements `LexiconIndexer` by consuming documents from an
7
+ * iterable (sync or async) and caching them for efficient retrieval.
8
+ * Documents are indexed on-demand as they are requested or iterated over.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * // From an array of documents
13
+ * const docs = [lexiconDoc1, lexiconDoc2, lexiconDoc3]
14
+ * const indexer = new LexiconIterableIndexer(docs)
15
+ *
16
+ * // Documents are indexed lazily as requested
17
+ * const doc = await indexer.get('com.example.post')
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // From an async generator (e.g., reading from files)
23
+ * async function* loadLexicons() {
24
+ * for (const file of lexiconFiles) {
25
+ * yield JSON.parse(await fs.readFile(file, 'utf8'))
26
+ * }
27
+ * }
28
+ *
29
+ * await using indexer = new LexiconIterableIndexer(loadLexicons())
30
+ * const schemas = await LexiconSchemaBuilder.buildAll(indexer)
31
+ * ```
5
32
  */
6
33
  export declare class LexiconIterableIndexer implements LexiconIndexer, AsyncDisposable {
7
34
  #private;
8
35
  readonly source: AsyncIterable<LexiconDocument> | Iterable<LexiconDocument>;
36
+ /**
37
+ * Creates a new {@link LexiconIterableIndexer} from an iterable source.
38
+ *
39
+ * @param source - An iterable or async iterable of Lexicon documents.
40
+ * The iterator is consumed lazily as documents are requested.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * // Sync iterable (array, Set, Map.values(), etc.)
45
+ * const indexer = new LexiconIterableIndexer(lexiconDocuments)
46
+ *
47
+ * // Async iterable (async generator, ReadableStream, etc.)
48
+ * const indexer = new LexiconIterableIndexer(asyncLexiconStream)
49
+ * ```
50
+ */
9
51
  constructor(source: AsyncIterable<LexiconDocument> | Iterable<LexiconDocument>);
52
+ /**
53
+ * Retrieves a Lexicon document by its NSID.
54
+ *
55
+ * If the document has already been indexed, it is returned from cache.
56
+ * Otherwise, the source iterator is consumed until the document is found.
57
+ *
58
+ * @see {@link LexiconIndexer.get}
59
+ */
10
60
  get(id: string): Promise<LexiconDocument>;
11
61
  [Symbol.asyncIterator](): AsyncIterator<LexiconDocument, void, undefined>;
12
62
  [Symbol.asyncDispose](): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"lexicon-iterable-indexer.d.ts","sourceRoot":"","sources":["../src/lexicon-iterable-indexer.ts"],"names":[],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