@atcute/lex-cli 2.0.0 → 2.0.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/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/codegen.d.ts +1 -1
- package/dist/codegen.js +41 -14
- package/dist/codegen.js.map +1 -1
- package/package.json +5 -4
- package/src/cli.ts +3 -1
- package/src/codegen.ts +53 -15
- package/dist/schema.d.ts +0 -2561
- package/dist/schema.js +0 -233
- package/dist/schema.js.map +0 -1
- package/src/schema.ts +0 -531
package/src/schema.ts
DELETED
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
import * as v from '@badrap/valita';
|
|
2
|
-
|
|
3
|
-
// tsc dislikes this schema with the amount of type expansion that happens here.
|
|
4
|
-
// the interface declaration allows tsc to just reference it instead of
|
|
5
|
-
// expanding on every type reference.
|
|
6
|
-
|
|
7
|
-
const _integer = v
|
|
8
|
-
.number()
|
|
9
|
-
.assert((input) => input >= 0 && Number.isSafeInteger(input), `expected non-negative integer`);
|
|
10
|
-
|
|
11
|
-
const integer = _integer as integer.$schema;
|
|
12
|
-
declare namespace integer {
|
|
13
|
-
export {};
|
|
14
|
-
|
|
15
|
-
type $schematype = typeof _integer;
|
|
16
|
-
export interface $schema extends $schematype {}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const _lexBoolean = v.object({
|
|
20
|
-
type: v.literal('boolean'),
|
|
21
|
-
description: v.string().optional(),
|
|
22
|
-
default: v.boolean().optional(),
|
|
23
|
-
const: v.boolean().optional(),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
export const lexBoolean = _lexBoolean as lexBoolean.$schema;
|
|
27
|
-
export interface LexBoolean extends v.Infer<typeof lexBoolean> {}
|
|
28
|
-
export declare namespace lexBoolean {
|
|
29
|
-
export {};
|
|
30
|
-
|
|
31
|
-
type $schematype = typeof _lexBoolean;
|
|
32
|
-
export interface $schema extends $schematype {}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const _lexInteger = v.object({
|
|
36
|
-
type: v.literal('integer'),
|
|
37
|
-
description: v.string().optional(),
|
|
38
|
-
default: integer.optional(),
|
|
39
|
-
minimum: integer.optional(),
|
|
40
|
-
maximum: integer.optional(),
|
|
41
|
-
enum: v.array(integer).optional(),
|
|
42
|
-
const: integer.optional(),
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
export const lexInteger = _lexInteger as lexInteger.$schema;
|
|
46
|
-
export interface LexInteger extends v.Infer<typeof lexInteger> {}
|
|
47
|
-
export declare namespace lexInteger {
|
|
48
|
-
export {};
|
|
49
|
-
|
|
50
|
-
type $schematype = typeof _lexInteger;
|
|
51
|
-
export interface $schema extends $schematype {}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const _lexStringFormat = v.union(
|
|
55
|
-
v.literal('datetime'),
|
|
56
|
-
v.literal('uri'),
|
|
57
|
-
v.literal('at-uri'),
|
|
58
|
-
v.literal('did'),
|
|
59
|
-
v.literal('handle'),
|
|
60
|
-
v.literal('at-identifier'),
|
|
61
|
-
v.literal('nsid'),
|
|
62
|
-
v.literal('cid'),
|
|
63
|
-
v.literal('language'),
|
|
64
|
-
v.literal('tid'),
|
|
65
|
-
v.literal('record-key'),
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
export const lexStringFormat = _lexStringFormat as lexStringFormat.$schema;
|
|
69
|
-
export type LexStringFormat = v.Infer<typeof lexStringFormat>;
|
|
70
|
-
export declare namespace lexStringFormat {
|
|
71
|
-
export {};
|
|
72
|
-
|
|
73
|
-
type $schematype = typeof _lexStringFormat;
|
|
74
|
-
export interface $schema extends $schematype {}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const _lexString = v.object({
|
|
78
|
-
type: v.literal('string'),
|
|
79
|
-
format: lexStringFormat.optional(),
|
|
80
|
-
description: v.string().optional(),
|
|
81
|
-
default: v.string().optional(),
|
|
82
|
-
minLength: integer.optional(),
|
|
83
|
-
maxLength: integer.optional(),
|
|
84
|
-
minGraphemes: integer.optional(),
|
|
85
|
-
maxGraphemes: integer.optional(),
|
|
86
|
-
enum: v.array(v.string()).optional(),
|
|
87
|
-
const: v.string().optional(),
|
|
88
|
-
knownValues: v.array(v.string()).optional(),
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
export const lexString = _lexString as lexString.$schema;
|
|
92
|
-
export interface LexString extends v.Infer<typeof lexString> {}
|
|
93
|
-
export declare namespace lexString {
|
|
94
|
-
export {};
|
|
95
|
-
|
|
96
|
-
type $schematype = typeof _lexString;
|
|
97
|
-
export interface $schema extends $schematype {}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const _lexUnknown = v.object({
|
|
101
|
-
type: v.literal('unknown'),
|
|
102
|
-
description: v.string().optional(),
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
export const lexUnknown = _lexUnknown as lexUnknown.$schema;
|
|
106
|
-
export interface LexUnknown extends v.Infer<typeof lexUnknown> {}
|
|
107
|
-
export declare namespace lexUnknown {
|
|
108
|
-
export {};
|
|
109
|
-
|
|
110
|
-
type $schematype = typeof _lexUnknown;
|
|
111
|
-
export interface $schema extends $schematype {}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const _lexPrimitive = v.union(lexBoolean, lexInteger, lexString, lexUnknown);
|
|
115
|
-
|
|
116
|
-
export const lexPrimitive = _lexPrimitive as lexPrimitive.$schema;
|
|
117
|
-
export type LexPrimitive = v.Infer<typeof lexPrimitive>;
|
|
118
|
-
export declare namespace lexPrimitive {
|
|
119
|
-
export {};
|
|
120
|
-
|
|
121
|
-
type $schematype = typeof _lexPrimitive;
|
|
122
|
-
export interface $schema extends $schematype {}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const _lexBytes = v.object({
|
|
126
|
-
type: v.literal('bytes'),
|
|
127
|
-
description: v.string().optional(),
|
|
128
|
-
minLength: integer.optional(),
|
|
129
|
-
maxLength: integer.optional(),
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
export const lexBytes = _lexBytes as lexBytes.$schema;
|
|
133
|
-
export interface LexBytes extends v.Infer<typeof lexBytes> {}
|
|
134
|
-
export declare namespace lexBytes {
|
|
135
|
-
export {};
|
|
136
|
-
|
|
137
|
-
type $schematype = typeof _lexBytes;
|
|
138
|
-
export interface $schema extends $schematype {}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const _lexCidLink = v.object({
|
|
142
|
-
type: v.literal('cid-link'),
|
|
143
|
-
description: v.string().optional(),
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
export const lexCidLink = _lexCidLink as lexCidLink.$schema;
|
|
147
|
-
export interface LexCidLink extends v.Infer<typeof lexCidLink> {}
|
|
148
|
-
export declare namespace lexCidLink {
|
|
149
|
-
export {};
|
|
150
|
-
|
|
151
|
-
type $schematype = typeof _lexCidLink;
|
|
152
|
-
export interface $schema extends $schematype {}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const _lexIpldType = v.union(lexBytes, lexCidLink);
|
|
156
|
-
|
|
157
|
-
export const lexIpldType = _lexIpldType as lexIpldType.$schema;
|
|
158
|
-
export type LexIpldType = v.Infer<typeof lexIpldType>;
|
|
159
|
-
export declare namespace lexIpldType {
|
|
160
|
-
export {};
|
|
161
|
-
|
|
162
|
-
type $schematype = typeof _lexIpldType;
|
|
163
|
-
export interface $schema extends $schematype {}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const REF_RE =
|
|
167
|
-
/^(?=.)(?:[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+\.[a-zA-Z][a-zA-Z0-9]{0,62}?)?(?:#[a-zA-Z][a-zA-Z0-9_]{0,62}?)?$/;
|
|
168
|
-
|
|
169
|
-
const refString = v.string().assert((input) => REF_RE.test(input));
|
|
170
|
-
|
|
171
|
-
const _lexRef = v.object({
|
|
172
|
-
type: v.literal('ref'),
|
|
173
|
-
description: v.string().optional(),
|
|
174
|
-
ref: refString,
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
export const lexRef = _lexRef as lexRef.$schema;
|
|
178
|
-
export interface LexRef extends v.Infer<typeof lexRef> {}
|
|
179
|
-
export declare namespace lexRef {
|
|
180
|
-
export {};
|
|
181
|
-
|
|
182
|
-
type $schematype = typeof _lexRef;
|
|
183
|
-
export interface $schema extends $schematype {}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const _lexRefUnion = v.object({
|
|
187
|
-
type: v.literal('union'),
|
|
188
|
-
description: v.string().optional(),
|
|
189
|
-
refs: v.array(refString),
|
|
190
|
-
closed: v.boolean().optional(() => false),
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
export const lexRefUnion = _lexRefUnion as lexRefUnion.$schema;
|
|
194
|
-
export interface LexRefUnion extends v.Infer<typeof lexRefUnion> {}
|
|
195
|
-
export declare namespace lexRefUnion {
|
|
196
|
-
export {};
|
|
197
|
-
|
|
198
|
-
type $schematype = typeof _lexRefUnion;
|
|
199
|
-
export interface $schema extends $schematype {}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const _lexRefVariant = v.union(lexRef, lexRefUnion);
|
|
203
|
-
|
|
204
|
-
export const lexRefVariant = _lexRefVariant as lexRefVariant.$schema;
|
|
205
|
-
export type LexRefVariant = v.Infer<typeof lexRefVariant>;
|
|
206
|
-
export declare namespace lexRefVariant {
|
|
207
|
-
export {};
|
|
208
|
-
|
|
209
|
-
type $schematype = typeof _lexRefVariant;
|
|
210
|
-
export interface $schema extends $schematype {}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const _lexBlob = v.object({
|
|
214
|
-
type: v.literal('blob'),
|
|
215
|
-
description: v.string().optional(),
|
|
216
|
-
accept: v.array(v.string()).optional(),
|
|
217
|
-
maxSize: integer.optional(),
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
export const lexBlob = _lexBlob as lexBlob.$schema;
|
|
221
|
-
export interface LexBlob extends v.Infer<typeof lexBlob> {}
|
|
222
|
-
export declare namespace lexBlob {
|
|
223
|
-
export {};
|
|
224
|
-
|
|
225
|
-
type $schematype = typeof _lexBlob;
|
|
226
|
-
export interface $schema extends $schematype {}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const _lexArray = v.object({
|
|
230
|
-
type: v.literal('array'),
|
|
231
|
-
description: v.string().optional(),
|
|
232
|
-
items: v.union(lexPrimitive, lexIpldType, lexRefVariant, lexBlob),
|
|
233
|
-
minLength: integer.optional(),
|
|
234
|
-
maxLength: integer.optional(),
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
export const lexArray = _lexArray as lexArray.$schema;
|
|
238
|
-
export interface LexArray extends v.Infer<typeof lexArray> {}
|
|
239
|
-
export declare namespace lexArray {
|
|
240
|
-
export {};
|
|
241
|
-
|
|
242
|
-
type $schematype = typeof _lexArray;
|
|
243
|
-
export interface $schema extends $schematype {}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const _lexPrimitiveArray = lexArray.extend({
|
|
247
|
-
items: lexPrimitive,
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
export const lexPrimitiveArray = _lexPrimitiveArray as lexPrimitiveArray.$schema;
|
|
251
|
-
export interface LexPrimitiveArray extends v.Infer<typeof lexPrimitiveArray> {}
|
|
252
|
-
export declare namespace lexPrimitiveArray {
|
|
253
|
-
export {};
|
|
254
|
-
|
|
255
|
-
type $schematype = typeof _lexPrimitiveArray;
|
|
256
|
-
export interface $schema extends $schematype {}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const _lexToken = v.object({
|
|
260
|
-
type: v.literal('token'),
|
|
261
|
-
description: v.string().optional(),
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
export const lexToken = _lexToken as lexToken.$schema;
|
|
265
|
-
export interface LexToken extends v.Infer<typeof lexToken> {}
|
|
266
|
-
export declare namespace lexToken {
|
|
267
|
-
export {};
|
|
268
|
-
|
|
269
|
-
type $schematype = typeof _lexToken;
|
|
270
|
-
export interface $schema extends $schematype {}
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const KEY_RE = /^[a-zA-Z][a-zA-Z0-9_]{0,62}?$/;
|
|
274
|
-
|
|
275
|
-
const refineObjectProperties = <T extends { required?: string[]; properties?: Record<string, unknown> }>(
|
|
276
|
-
input: T,
|
|
277
|
-
): v.ValitaResult<T> => {
|
|
278
|
-
const { required = [], properties } = input;
|
|
279
|
-
|
|
280
|
-
for (const key in properties) {
|
|
281
|
-
if (!KEY_RE.test(key)) {
|
|
282
|
-
return v.err({
|
|
283
|
-
message: `invalid property key`,
|
|
284
|
-
path: ['properties', key],
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
if (required.length > 0) {
|
|
290
|
-
if (properties === undefined) {
|
|
291
|
-
return v.err({
|
|
292
|
-
message: `required fields specified but no properties defined`,
|
|
293
|
-
path: ['properties'],
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
for (const key of required) {
|
|
298
|
-
if (properties[key] === undefined) {
|
|
299
|
-
return v.err({
|
|
300
|
-
message: `required fields not defined`,
|
|
301
|
-
path: ['properties', key],
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
return v.ok(input);
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
const _lexObject = v
|
|
311
|
-
.object({
|
|
312
|
-
type: v.literal('object'),
|
|
313
|
-
description: v.string().optional(),
|
|
314
|
-
required: v.array(v.string()).optional(),
|
|
315
|
-
nullable: v.array(v.string()).optional(),
|
|
316
|
-
properties: v.record(v.union(lexArray, lexPrimitive, lexIpldType, lexRefVariant, lexBlob)).optional(),
|
|
317
|
-
})
|
|
318
|
-
.chain(refineObjectProperties);
|
|
319
|
-
|
|
320
|
-
export const lexObject = _lexObject as lexObject.$schema;
|
|
321
|
-
export interface LexObject extends v.Infer<typeof lexObject> {}
|
|
322
|
-
export declare namespace lexObject {
|
|
323
|
-
export {};
|
|
324
|
-
|
|
325
|
-
type $schematype = typeof _lexObject;
|
|
326
|
-
export interface $schema extends $schematype {}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
const _lexXrpcParameters = v
|
|
330
|
-
.object({
|
|
331
|
-
type: v.literal('params'),
|
|
332
|
-
description: v.string().optional(),
|
|
333
|
-
required: v.array(v.string()).optional(),
|
|
334
|
-
properties: v.record(v.union(lexPrimitive, lexPrimitiveArray)).optional(),
|
|
335
|
-
})
|
|
336
|
-
.chain(refineObjectProperties);
|
|
337
|
-
|
|
338
|
-
export const lexXrpcParameters = _lexXrpcParameters as lexXrpcParameters.$schema;
|
|
339
|
-
export interface LexXrpcParameters extends v.Infer<typeof lexXrpcParameters> {}
|
|
340
|
-
export declare namespace lexXrpcParameters {
|
|
341
|
-
export {};
|
|
342
|
-
|
|
343
|
-
type $schematype = typeof _lexXrpcParameters;
|
|
344
|
-
export interface $schema extends $schematype {}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
const _lexXrpcBody = v.object({
|
|
348
|
-
description: v.string().optional(),
|
|
349
|
-
encoding: v.string(),
|
|
350
|
-
schema: v.union(lexRefVariant, lexObject).optional(),
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
export const lexXrpcBody = _lexXrpcBody as lexXrpcBody.$schema;
|
|
354
|
-
export interface LexXrpcBody extends v.Infer<typeof lexXrpcBody> {}
|
|
355
|
-
export declare namespace lexXrpcBody {
|
|
356
|
-
export {};
|
|
357
|
-
|
|
358
|
-
type $schematype = typeof _lexXrpcBody;
|
|
359
|
-
export interface $schema extends $schematype {}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
const _lexXrpcSubscriptionMessage = v.object({
|
|
363
|
-
description: v.string().optional(),
|
|
364
|
-
schema: v.union(lexRefVariant, lexObject).optional(),
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
export const lexXrpcSubscriptionMessage = _lexXrpcSubscriptionMessage as lexXrpcSubscriptionMessage.$schema;
|
|
368
|
-
export interface LexXrpcSubscriptionMessage extends v.Infer<typeof lexXrpcSubscriptionMessage> {}
|
|
369
|
-
export declare namespace lexXrpcSubscriptionMessage {
|
|
370
|
-
export {};
|
|
371
|
-
|
|
372
|
-
type $schematype = typeof _lexXrpcSubscriptionMessage;
|
|
373
|
-
export interface $schema extends $schematype {}
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
const _lexXrpcError = v.object({
|
|
377
|
-
name: v.string(),
|
|
378
|
-
description: v.string().optional(),
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
export const lexXrpcError = _lexXrpcError as lexXrpcError.$schema;
|
|
382
|
-
export interface LexXrpcError extends v.Infer<typeof lexXrpcError> {}
|
|
383
|
-
export declare namespace lexXrpcError {
|
|
384
|
-
export {};
|
|
385
|
-
|
|
386
|
-
type $schematype = typeof _lexXrpcError;
|
|
387
|
-
export interface $schema extends $schematype {}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
const _lexXrpcQuery = v.object({
|
|
391
|
-
type: v.literal('query'),
|
|
392
|
-
description: v.string().optional(),
|
|
393
|
-
parameters: lexXrpcParameters.optional(),
|
|
394
|
-
output: lexXrpcBody.optional(),
|
|
395
|
-
errors: v.array(lexXrpcError).optional(),
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
export const lexXrpcQuery = _lexXrpcQuery as lexXrpcQuery.$schema;
|
|
399
|
-
export interface LexXrpcQuery extends v.Infer<typeof lexXrpcQuery> {}
|
|
400
|
-
export declare namespace lexXrpcQuery {
|
|
401
|
-
export {};
|
|
402
|
-
|
|
403
|
-
type $schematype = typeof _lexXrpcQuery;
|
|
404
|
-
export interface $schema extends $schematype {}
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
const _lexXrpcProcedure = v.object({
|
|
408
|
-
type: v.literal('procedure'),
|
|
409
|
-
description: v.string().optional(),
|
|
410
|
-
parameters: lexXrpcParameters.optional(),
|
|
411
|
-
input: lexXrpcBody.optional(),
|
|
412
|
-
output: lexXrpcBody.optional(),
|
|
413
|
-
errors: v.array(lexXrpcError).optional(),
|
|
414
|
-
});
|
|
415
|
-
|
|
416
|
-
export const lexXrpcProcedure = _lexXrpcProcedure as lexXrpcProcedure.$schema;
|
|
417
|
-
export interface LexXrpcProcedure extends v.Infer<typeof lexXrpcProcedure> {}
|
|
418
|
-
export declare namespace lexXrpcProcedure {
|
|
419
|
-
export {};
|
|
420
|
-
|
|
421
|
-
type $schematype = typeof _lexXrpcProcedure;
|
|
422
|
-
export interface $schema extends $schematype {}
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
const _lexXrpcSubscription = v.object({
|
|
426
|
-
type: v.literal('subscription'),
|
|
427
|
-
description: v.string().optional(),
|
|
428
|
-
parameters: lexXrpcParameters.optional(),
|
|
429
|
-
message: lexXrpcSubscriptionMessage.optional(),
|
|
430
|
-
errors: v.array(lexXrpcError).optional(),
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
export const lexXrpcSubscription = _lexXrpcSubscription as lexXrpcSubscription.$schema;
|
|
434
|
-
export interface LexXrpcSubscription extends v.Infer<typeof lexXrpcSubscription> {}
|
|
435
|
-
export declare namespace lexXrpcSubscription {
|
|
436
|
-
export {};
|
|
437
|
-
|
|
438
|
-
type $schematype = typeof _lexXrpcSubscription;
|
|
439
|
-
export interface $schema extends $schematype {}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
const LITERAL_KEY_RE = /^literal:(.+)$/;
|
|
443
|
-
|
|
444
|
-
const _lexRecord = v.object({
|
|
445
|
-
type: v.literal('record'),
|
|
446
|
-
description: v.string().optional(),
|
|
447
|
-
key: v
|
|
448
|
-
.union(
|
|
449
|
-
v.literal('tid'),
|
|
450
|
-
v.literal('nsid'),
|
|
451
|
-
v.literal('any'),
|
|
452
|
-
v.string().assert<`literal:${string}`>((input) => LITERAL_KEY_RE.test(input)),
|
|
453
|
-
)
|
|
454
|
-
.optional(() => 'any'),
|
|
455
|
-
record: lexObject,
|
|
456
|
-
});
|
|
457
|
-
|
|
458
|
-
export const lexRecord = _lexRecord as lexRecord.$schema;
|
|
459
|
-
export interface LexRecord extends v.Infer<typeof lexRecord> {}
|
|
460
|
-
export declare namespace lexRecord {
|
|
461
|
-
export {};
|
|
462
|
-
|
|
463
|
-
type $schematype = typeof _lexRecord;
|
|
464
|
-
export interface $schema extends $schematype {}
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const _lexUserType = v.union(
|
|
468
|
-
lexRecord,
|
|
469
|
-
lexXrpcQuery,
|
|
470
|
-
lexXrpcProcedure,
|
|
471
|
-
lexXrpcSubscription,
|
|
472
|
-
lexObject,
|
|
473
|
-
lexArray,
|
|
474
|
-
lexToken,
|
|
475
|
-
lexIpldType,
|
|
476
|
-
lexBlob,
|
|
477
|
-
lexPrimitive,
|
|
478
|
-
);
|
|
479
|
-
|
|
480
|
-
export const lexUserType = _lexUserType as lexUserType.$schema;
|
|
481
|
-
export type LexUserType = v.Infer<typeof lexUserType>;
|
|
482
|
-
export declare namespace lexUserType {
|
|
483
|
-
export {};
|
|
484
|
-
|
|
485
|
-
type $schematype = typeof _lexUserType;
|
|
486
|
-
export interface $schema extends $schematype {}
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
const NSID_RE =
|
|
490
|
-
/^[a-zA-Z](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?:\.[a-zA-Z](?:[a-zA-Z0-9]{0,62})?)$/;
|
|
491
|
-
|
|
492
|
-
const _lexiconDoc = v
|
|
493
|
-
.object({
|
|
494
|
-
lexicon: v.literal(1),
|
|
495
|
-
id: v.string().assert((input) => NSID_RE.test(input), `must be valid nsid`),
|
|
496
|
-
revision: integer.optional(),
|
|
497
|
-
description: v.string().optional(),
|
|
498
|
-
// defs: v.record(v.pipe(v.string(), v.regex(/^[a-zA-Z][a-zA-Z0-9_]{0,62}?$/)), lexUserType),
|
|
499
|
-
defs: v.record(lexUserType),
|
|
500
|
-
})
|
|
501
|
-
.chain((input) => {
|
|
502
|
-
const { defs } = input;
|
|
503
|
-
|
|
504
|
-
for (const key in defs) {
|
|
505
|
-
const def = defs[key];
|
|
506
|
-
|
|
507
|
-
if (
|
|
508
|
-
key !== 'main' &&
|
|
509
|
-
(def.type === 'record' ||
|
|
510
|
-
def.type === 'procedure' ||
|
|
511
|
-
def.type === 'query' ||
|
|
512
|
-
def.type === 'subscription')
|
|
513
|
-
) {
|
|
514
|
-
return v.err({
|
|
515
|
-
message: `records, procedures, queries and subscriptions must be the main definition`,
|
|
516
|
-
path: ['defs', key],
|
|
517
|
-
});
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
return v.ok(input);
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
export const lexiconDoc = _lexiconDoc as lexiconDoc.$schema;
|
|
525
|
-
export interface LexiconDoc extends v.Infer<typeof lexiconDoc> {}
|
|
526
|
-
export declare namespace lexiconDoc {
|
|
527
|
-
export {};
|
|
528
|
-
|
|
529
|
-
type $schematype = typeof _lexiconDoc;
|
|
530
|
-
export interface $schema extends $schematype {}
|
|
531
|
-
}
|