@atproto/lex-schema 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/$type.d.ts +4 -0
- package/dist/core/$type.d.ts.map +1 -0
- package/dist/core/$type.js +7 -0
- package/dist/core/$type.js.map +1 -0
- package/dist/core/record-key.d.ts +4 -0
- package/dist/core/record-key.d.ts.map +1 -0
- package/dist/core/record-key.js +16 -0
- package/dist/core/record-key.js.map +1 -0
- package/dist/core/result.d.ts +57 -0
- package/dist/core/result.d.ts.map +1 -0
- package/dist/core/result.js +74 -0
- package/dist/core/result.js.map +1 -0
- package/dist/core/string-format.d.ts +31 -0
- package/dist/core/string-format.d.ts.map +1 -0
- package/dist/core/string-format.js +81 -0
- package/dist/core/string-format.js.map +1 -0
- package/dist/core/types.d.ts +19 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +3 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core.d.ts +6 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +9 -0
- package/dist/core.js.map +1 -0
- package/dist/external.d.ts +86 -0
- package/dist/external.d.ts.map +1 -0
- package/dist/external.js +171 -0
- package/dist/external.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/schema/_parameters.d.ts +17 -0
- package/dist/schema/_parameters.d.ts.map +1 -0
- package/dist/schema/_parameters.js +20 -0
- package/dist/schema/_parameters.js.map +1 -0
- package/dist/schema/array.d.ts +13 -0
- package/dist/schema/array.d.ts.map +1 -0
- package/dist/schema/array.js +40 -0
- package/dist/schema/array.js.map +1 -0
- package/dist/schema/blob.d.ts +32 -0
- package/dist/schema/blob.d.ts.map +1 -0
- package/dist/schema/blob.js +40 -0
- package/dist/schema/blob.js.map +1 -0
- package/dist/schema/boolean.d.ts +11 -0
- package/dist/schema/boolean.d.ts.map +1 -0
- package/dist/schema/boolean.js +20 -0
- package/dist/schema/boolean.js.map +1 -0
- package/dist/schema/bytes.d.ts +12 -0
- package/dist/schema/bytes.d.ts.map +1 -0
- package/dist/schema/bytes.js +31 -0
- package/dist/schema/bytes.js.map +1 -0
- package/dist/schema/cid.d.ts +13 -0
- package/dist/schema/cid.d.ts.map +1 -0
- package/dist/schema/cid.js +22 -0
- package/dist/schema/cid.js.map +1 -0
- package/dist/schema/custom.d.ts +15 -0
- package/dist/schema/custom.d.ts.map +1 -0
- package/dist/schema/custom.js +22 -0
- package/dist/schema/custom.js.map +1 -0
- package/dist/schema/dict.d.ts +18 -0
- package/dist/schema/dict.d.ts.map +1 -0
- package/dist/schema/dict.js +48 -0
- package/dist/schema/dict.js.map +1 -0
- package/dist/schema/discriminated-union.d.ts +34 -0
- package/dist/schema/discriminated-union.d.ts.map +1 -0
- package/dist/schema/discriminated-union.js +93 -0
- package/dist/schema/discriminated-union.js.map +1 -0
- package/dist/schema/enum.d.ts +7 -0
- package/dist/schema/enum.d.ts.map +1 -0
- package/dist/schema/enum.js +19 -0
- package/dist/schema/enum.js.map +1 -0
- package/dist/schema/integer.d.ts +13 -0
- package/dist/schema/integer.d.ts.map +1 -0
- package/dist/schema/integer.js +32 -0
- package/dist/schema/integer.js.map +1 -0
- package/dist/schema/intersection.d.ts +16 -0
- package/dist/schema/intersection.d.ts.map +1 -0
- package/dist/schema/intersection.js +33 -0
- package/dist/schema/intersection.js.map +1 -0
- package/dist/schema/literal.d.ts +7 -0
- package/dist/schema/literal.d.ts.map +1 -0
- package/dist/schema/literal.js +19 -0
- package/dist/schema/literal.js.map +1 -0
- package/dist/schema/never.d.ts +5 -0
- package/dist/schema/never.d.ts.map +1 -0
- package/dist/schema/never.js +11 -0
- package/dist/schema/never.js.map +1 -0
- package/dist/schema/null.d.ts +7 -0
- package/dist/schema/null.d.ts.map +1 -0
- package/dist/schema/null.js +18 -0
- package/dist/schema/null.js.map +1 -0
- package/dist/schema/object.d.ts +47 -0
- package/dist/schema/object.d.ts.map +1 -0
- package/dist/schema/object.js +89 -0
- package/dist/schema/object.js.map +1 -0
- package/dist/schema/params.d.ts +22 -0
- package/dist/schema/params.d.ts.map +1 -0
- package/dist/schema/params.js +115 -0
- package/dist/schema/params.js.map +1 -0
- package/dist/schema/payload.d.ts +19 -0
- package/dist/schema/payload.d.ts.map +1 -0
- package/dist/schema/payload.js +16 -0
- package/dist/schema/payload.js.map +1 -0
- package/dist/schema/permission-set.d.ts +15 -0
- package/dist/schema/permission-set.d.ts.map +1 -0
- package/dist/schema/permission-set.js +16 -0
- package/dist/schema/permission-set.js.map +1 -0
- package/dist/schema/permission.d.ts +9 -0
- package/dist/schema/permission.d.ts.map +1 -0
- package/dist/schema/permission.js +14 -0
- package/dist/schema/permission.js.map +1 -0
- package/dist/schema/procedure.d.ts +17 -0
- package/dist/schema/procedure.d.ts.map +1 -0
- package/dist/schema/procedure.js +20 -0
- package/dist/schema/procedure.js.map +1 -0
- package/dist/schema/query.d.ts +15 -0
- package/dist/schema/query.d.ts.map +1 -0
- package/dist/schema/query.js +18 -0
- package/dist/schema/query.js.map +1 -0
- package/dist/schema/record.d.ts +37 -0
- package/dist/schema/record.d.ts.map +1 -0
- package/dist/schema/record.js +64 -0
- package/dist/schema/record.js.map +1 -0
- package/dist/schema/ref.d.ts +10 -0
- package/dist/schema/ref.d.ts.map +1 -0
- package/dist/schema/ref.js +36 -0
- package/dist/schema/ref.js.map +1 -0
- package/dist/schema/string.d.ts +24 -0
- package/dist/schema/string.d.ts.map +1 -0
- package/dist/schema/string.js +107 -0
- package/dist/schema/string.js.map +1 -0
- package/dist/schema/subscription.d.ts +16 -0
- package/dist/schema/subscription.d.ts.map +1 -0
- package/dist/schema/subscription.js +18 -0
- package/dist/schema/subscription.js.map +1 -0
- package/dist/schema/token.d.ts +10 -0
- package/dist/schema/token.d.ts.map +1 -0
- package/dist/schema/token.js +36 -0
- package/dist/schema/token.js.map +1 -0
- package/dist/schema/typed-object.d.ts +32 -0
- package/dist/schema/typed-object.d.ts.map +1 -0
- package/dist/schema/typed-object.js +40 -0
- package/dist/schema/typed-object.js.map +1 -0
- package/dist/schema/typed-ref.d.ts +30 -0
- package/dist/schema/typed-ref.d.ts.map +1 -0
- package/dist/schema/typed-ref.js +44 -0
- package/dist/schema/typed-ref.js.map +1 -0
- package/dist/schema/typed-union.d.ts +26 -0
- package/dist/schema/typed-union.d.ts.map +1 -0
- package/dist/schema/typed-union.js +54 -0
- package/dist/schema/typed-union.js.map +1 -0
- package/dist/schema/union.d.ts +9 -0
- package/dist/schema/union.d.ts.map +1 -0
- package/dist/schema/union.js +29 -0
- package/dist/schema/union.js.map +1 -0
- package/dist/schema/unknown-object.d.ts +9 -0
- package/dist/schema/unknown-object.d.ts.map +1 -0
- package/dist/schema/unknown-object.js +16 -0
- package/dist/schema/unknown-object.js.map +1 -0
- package/dist/schema/unknown.d.ts +5 -0
- package/dist/schema/unknown.d.ts.map +1 -0
- package/dist/schema/unknown.js +11 -0
- package/dist/schema/unknown.js.map +1 -0
- package/dist/schema.d.ts +34 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +41 -0
- package/dist/schema.js.map +1 -0
- package/dist/util/array-agg.d.ts +20 -0
- package/dist/util/array-agg.d.ts.map +1 -0
- package/dist/util/array-agg.js +42 -0
- package/dist/util/array-agg.js.map +1 -0
- package/dist/validation/property-key.d.ts +2 -0
- package/dist/validation/property-key.d.ts.map +1 -0
- package/dist/validation/property-key.js +3 -0
- package/dist/validation/property-key.js.map +1 -0
- package/dist/validation/validation-error.d.ts +9 -0
- package/dist/validation/validation-error.d.ts.map +1 -0
- package/dist/validation/validation-error.js +27 -0
- package/dist/validation/validation-error.js.map +1 -0
- package/dist/validation/validation-issue.d.ts +45 -0
- package/dist/validation/validation-issue.d.ts.map +1 -0
- package/dist/validation/validation-issue.js +167 -0
- package/dist/validation/validation-issue.js.map +1 -0
- package/dist/validation/validator.d.ts +113 -0
- package/dist/validation/validator.d.ts.map +1 -0
- package/dist/validation/validator.js +209 -0
- package/dist/validation/validator.js.map +1 -0
- package/dist/validation.d.ts +5 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +8 -0
- package/dist/validation.js.map +1 -0
- package/package.json +45 -0
- package/src/core/$type.ts +19 -0
- package/src/core/record-key.ts +15 -0
- package/src/core/result.ts +73 -0
- package/src/core/string-format.ts +124 -0
- package/src/core/types.ts +22 -0
- package/src/core.ts +5 -0
- package/src/external.ts +365 -0
- package/src/index.ts +3 -0
- package/src/schema/_parameters.ts +26 -0
- package/src/schema/array.ts +51 -0
- package/src/schema/blob.ts +82 -0
- package/src/schema/boolean.ts +24 -0
- package/src/schema/bytes.ts +38 -0
- package/src/schema/cid.ts +27 -0
- package/src/schema/custom.ts +36 -0
- package/src/schema/dict.ts +69 -0
- package/src/schema/discriminated-union.ts +144 -0
- package/src/schema/enum.ts +20 -0
- package/src/schema/integer.ts +41 -0
- package/src/schema/intersection.ts +57 -0
- package/src/schema/literal.ts +20 -0
- package/src/schema/never.ts +14 -0
- package/src/schema/null.ts +20 -0
- package/src/schema/object.test.ts +138 -0
- package/src/schema/object.ts +180 -0
- package/src/schema/params.ts +157 -0
- package/src/schema/payload.ts +53 -0
- package/src/schema/permission-set.ts +22 -0
- package/src/schema/permission.ts +15 -0
- package/src/schema/procedure.ts +35 -0
- package/src/schema/query.ts +28 -0
- package/src/schema/record.ts +106 -0
- package/src/schema/ref.ts +47 -0
- package/src/schema/string.ts +139 -0
- package/src/schema/subscription.ts +35 -0
- package/src/schema/token.ts +41 -0
- package/src/schema/typed-object.ts +64 -0
- package/src/schema/typed-ref.ts +68 -0
- package/src/schema/typed-union.ts +106 -0
- package/src/schema/union.ts +40 -0
- package/src/schema/unknown-object.ts +20 -0
- package/src/schema/unknown.ts +10 -0
- package/src/schema.ts +40 -0
- package/src/util/array-agg.test.ts +41 -0
- package/src/util/array-agg.ts +43 -0
- package/src/validation/property-key.ts +1 -0
- package/src/validation/validation-error.ts +32 -0
- package/src/validation/validation-issue.ts +231 -0
- package/src/validation/validator.ts +361 -0
- package/src/validation.ts +4 -0
package/dist/external.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.never = never;
|
|
4
|
+
exports.unknown = unknown;
|
|
5
|
+
exports._null = _null;
|
|
6
|
+
exports.null = _null;
|
|
7
|
+
exports.literal = literal;
|
|
8
|
+
exports._enum = _enum;
|
|
9
|
+
exports.enum = _enum;
|
|
10
|
+
exports.boolean = boolean;
|
|
11
|
+
exports.integer = integer;
|
|
12
|
+
exports.cidLink = cidLink;
|
|
13
|
+
exports.bytes = bytes;
|
|
14
|
+
exports.blob = blob;
|
|
15
|
+
exports.string = string;
|
|
16
|
+
exports.array = array;
|
|
17
|
+
exports.object = object;
|
|
18
|
+
exports.dict = dict;
|
|
19
|
+
exports.unknownObject = unknownObject;
|
|
20
|
+
exports.ref = ref;
|
|
21
|
+
exports.custom = custom;
|
|
22
|
+
exports.union = union;
|
|
23
|
+
exports.intersection = intersection;
|
|
24
|
+
exports.discriminatedUnion = discriminatedUnion;
|
|
25
|
+
exports.token = token;
|
|
26
|
+
exports.typedRef = typedRef;
|
|
27
|
+
exports.typedUnion = typedUnion;
|
|
28
|
+
exports.typedObject = typedObject;
|
|
29
|
+
exports.record = record;
|
|
30
|
+
exports.params = params;
|
|
31
|
+
exports.payload = payload;
|
|
32
|
+
exports.query = query;
|
|
33
|
+
exports.procedure = procedure;
|
|
34
|
+
exports.subscription = subscription;
|
|
35
|
+
exports.permission = permission;
|
|
36
|
+
exports.permissionSet = permissionSet;
|
|
37
|
+
const tslib_1 = require("tslib");
|
|
38
|
+
const core_js_1 = require("./core.js");
|
|
39
|
+
const schema_js_1 = require("./schema.js");
|
|
40
|
+
tslib_1.__exportStar(require("./core.js"), exports);
|
|
41
|
+
tslib_1.__exportStar(require("./schema.js"), exports);
|
|
42
|
+
tslib_1.__exportStar(require("./validation.js"), exports);
|
|
43
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
44
|
+
function never() {
|
|
45
|
+
return new schema_js_1.NeverSchema();
|
|
46
|
+
}
|
|
47
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
48
|
+
function unknown() {
|
|
49
|
+
return new schema_js_1.UnknownSchema();
|
|
50
|
+
}
|
|
51
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
52
|
+
function _null() {
|
|
53
|
+
return new schema_js_1.NullSchema();
|
|
54
|
+
}
|
|
55
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
56
|
+
function literal(value) {
|
|
57
|
+
return new schema_js_1.LiteralSchema(value);
|
|
58
|
+
}
|
|
59
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
60
|
+
function _enum(value) {
|
|
61
|
+
return new schema_js_1.EnumSchema(value);
|
|
62
|
+
}
|
|
63
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
64
|
+
function boolean(options = {}) {
|
|
65
|
+
return new schema_js_1.BooleanSchema(options);
|
|
66
|
+
}
|
|
67
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
68
|
+
function integer(options = {}) {
|
|
69
|
+
return new schema_js_1.IntegerSchema(options);
|
|
70
|
+
}
|
|
71
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
72
|
+
function cidLink() {
|
|
73
|
+
return new schema_js_1.CidSchema();
|
|
74
|
+
}
|
|
75
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
76
|
+
function bytes(options = {}) {
|
|
77
|
+
return new schema_js_1.BytesSchema(options);
|
|
78
|
+
}
|
|
79
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
80
|
+
function blob(options = {}) {
|
|
81
|
+
return new schema_js_1.BlobSchema(options);
|
|
82
|
+
}
|
|
83
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
84
|
+
function string(options = {}) {
|
|
85
|
+
return new schema_js_1.StringSchema(options);
|
|
86
|
+
}
|
|
87
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
88
|
+
function array(items, options = {}) {
|
|
89
|
+
return new schema_js_1.ArraySchema(items, options);
|
|
90
|
+
}
|
|
91
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
92
|
+
function object(properties, options = {}) {
|
|
93
|
+
return new schema_js_1.ObjectSchema(properties, options);
|
|
94
|
+
}
|
|
95
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
96
|
+
function dict(key, value) {
|
|
97
|
+
return new schema_js_1.DictSchema(key, value);
|
|
98
|
+
}
|
|
99
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
100
|
+
function unknownObject() {
|
|
101
|
+
return new schema_js_1.UnknownObjectSchema();
|
|
102
|
+
}
|
|
103
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
104
|
+
function ref(get) {
|
|
105
|
+
return new schema_js_1.RefSchema(get);
|
|
106
|
+
}
|
|
107
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
108
|
+
function custom(assertion, message, path) {
|
|
109
|
+
return new schema_js_1.CustomSchema(assertion, message, path);
|
|
110
|
+
}
|
|
111
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
112
|
+
function union(validators) {
|
|
113
|
+
return new schema_js_1.UnionSchema(validators);
|
|
114
|
+
}
|
|
115
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
116
|
+
function intersection(validators) {
|
|
117
|
+
return new schema_js_1.IntersectionSchema(validators);
|
|
118
|
+
}
|
|
119
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
120
|
+
function discriminatedUnion(discriminator, variants) {
|
|
121
|
+
return new schema_js_1.DiscriminatedUnionSchema(discriminator, variants);
|
|
122
|
+
}
|
|
123
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
124
|
+
function token(nsid, hash) {
|
|
125
|
+
return new schema_js_1.TokenSchema((0, core_js_1.$type)(nsid, hash));
|
|
126
|
+
}
|
|
127
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
128
|
+
function typedRef(get) {
|
|
129
|
+
return new schema_js_1.TypedRefSchema(get);
|
|
130
|
+
}
|
|
131
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
132
|
+
function typedUnion(refs, closed) {
|
|
133
|
+
return new schema_js_1.TypedUnionSchema(refs, closed);
|
|
134
|
+
}
|
|
135
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
136
|
+
function typedObject(nsid, hash, schema) {
|
|
137
|
+
return new schema_js_1.TypedObjectSchema((0, core_js_1.$type)(nsid, hash), schema);
|
|
138
|
+
}
|
|
139
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
140
|
+
function record(key, type, schema) {
|
|
141
|
+
return new schema_js_1.RecordSchema(key, type, schema);
|
|
142
|
+
}
|
|
143
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
144
|
+
function params(properties = {}, options = {}) {
|
|
145
|
+
return new schema_js_1.ParamsSchema(properties, options);
|
|
146
|
+
}
|
|
147
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
148
|
+
function payload(encoding = undefined, schema = undefined) {
|
|
149
|
+
return new schema_js_1.Payload(encoding, schema);
|
|
150
|
+
}
|
|
151
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
152
|
+
function query(nsid, parameters, output, errors = undefined) {
|
|
153
|
+
return new schema_js_1.Query(nsid, parameters, output, errors);
|
|
154
|
+
}
|
|
155
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
156
|
+
function procedure(nsid, parameters, input, output, errors = undefined) {
|
|
157
|
+
return new schema_js_1.Procedure(nsid, parameters, input, output, errors);
|
|
158
|
+
}
|
|
159
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
160
|
+
function subscription(nsid, parameters, message, errors = undefined) {
|
|
161
|
+
return new schema_js_1.Subscription(nsid, parameters, message, errors);
|
|
162
|
+
}
|
|
163
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
164
|
+
function permission(resource, options = {}) {
|
|
165
|
+
return new schema_js_1.Permission(resource, options);
|
|
166
|
+
}
|
|
167
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
168
|
+
function permissionSet(nsid, permissions, options = {}) {
|
|
169
|
+
return new schema_js_1.PermissionSet(nsid, permissions, options);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=external.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"external.js","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":";;AA8DA,sBAEC;AAGD,0BAEC;AAGD,sBAEC;AAEiB,qBAAI;AAGtB,0BAIC;AAGD,sBAIC;AAGiB,qBAAI;AAGtB,0BAEC;AAGD,0BAEC;AAGD,0BAEC;AAGD,sBAEC;AAGD,oBAEC;AAGD,wBAIC;AAGD,sBAKC;AAGD,wBAQC;AAGD,oBAKC;AAMD,sCAEC;AAGD,kBAEC;AAGD,wBAMC;AAGD,sBAEC;AAGD,oCAIC;AAGD,gDAQC;AAGD,sBAKC;AAGD,4BAIC;AAGD,gCAKC;AAgCD,kCAMC;AAoCD,wBAMC;AAGD,wBAKC;AAGD,0BAKC;AAGD,sBAOC;AAGD,8BAQC;AAGD,oCAOC;AAGD,gCAKC;AAGD,sCAMC;;AA5WD,uCAAyD;AACzD,2CAqDoB;AAGpB,oDAAyB;AACzB,sDAA2B;AAC3B,0DAA+B;AAE/B,wBAAwB;AACxB,SAAgB,KAAK;IACnB,OAAO,IAAI,uBAAW,EAAE,CAAA;AAC1B,CAAC;AAED,wBAAwB;AACxB,SAAgB,OAAO;IACrB,OAAO,IAAI,yBAAa,EAAE,CAAA;AAC5B,CAAC;AAED,wBAAwB;AACxB,SAAgB,KAAK;IACnB,OAAO,IAAI,sBAAU,EAAE,CAAA;AACzB,CAAC;AAID,wBAAwB;AACxB,SAAgB,OAAO,CACrB,KAAQ;IAER,OAAO,IAAI,yBAAa,CAAI,KAAK,CAAC,CAAA;AACpC,CAAC;AAED,wBAAwB;AACxB,SAAgB,KAAK,CACnB,KAAmB;IAEnB,OAAO,I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W,EAAE,OAAO,CAAC,CAAA;AAC/D,CAAC","sourcesContent":["import { $Type, $type, Nsid, RecordKey } from './core.js'\nimport {\n ArraySchema,\n ArraySchemaOptions,\n BlobSchema,\n BlobSchemaOptions,\n BooleanSchema,\n BooleanSchemaOptions,\n BytesSchema,\n BytesSchemaOptions,\n CidSchema,\n CustomAssertion,\n CustomSchema,\n DictSchema,\n DiscriminatedUnionSchema,\n DiscriminatedUnionSchemaVariants,\n EnumSchema,\n IntegerSchema,\n IntegerSchemaOptions,\n IntersectionSchema,\n IntersectionSchemaValidators,\n LiteralSchema,\n NeverSchema,\n NullSchema,\n ObjectSchema,\n ObjectSchemaOptions,\n ObjectSchemaProperties,\n ParamsSchema,\n ParamsSchemaOptions,\n ParamsSchemaProperties,\n Payload,\n PayloadBody,\n Permission,\n PermissionOptions,\n PermissionSet,\n PermissionSetOptions,\n Procedure,\n Query,\n RecordSchema,\n RefSchema,\n RefSchemaGetter,\n StringSchema,\n StringSchemaOptions,\n Subscription,\n TokenSchema,\n TypedObjectSchema,\n TypedRefGetter,\n TypedRefSchema,\n TypedUnionSchema,\n UnionSchema,\n UnionSchemaValidators,\n UnknownObjectOutput,\n UnknownObjectSchema,\n UnknownSchema,\n} from './schema.js'\nimport { Infer, PropertyKey, Validator } from './validation.js'\n\nexport * from './core.js'\nexport * from './schema.js'\nexport * from './validation.js'\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function never() {\n return new NeverSchema()\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function unknown() {\n return new UnknownSchema()\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function _null() {\n return new NullSchema()\n}\n\nexport { _null as null }\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function literal<const V extends null | string | number | boolean>(\n value: V,\n) {\n return new LiteralSchema<V>(value)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function _enum<const V extends null | string | number | boolean>(\n value: readonly V[],\n) {\n return new EnumSchema<V>(value)\n}\n\n// @NOTE \"enum\" is a reserved keyword in JS/TS\nexport { _enum as enum }\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function boolean(options: BooleanSchemaOptions = {}) {\n return new BooleanSchema(options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function integer(options: IntegerSchemaOptions = {}) {\n return new IntegerSchema(options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function cidLink() {\n return new CidSchema()\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function bytes(options: BytesSchemaOptions = {}) {\n return new BytesSchema(options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function blob(options: BlobSchemaOptions = {}) {\n return new BlobSchema(options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function string<\n const O extends StringSchemaOptions = NonNullable<unknown>,\n>(options: StringSchemaOptions & O = {} as O) {\n return new StringSchema<O>(options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function array<const T>(\n items: Validator<T>,\n options: ArraySchemaOptions = {},\n) {\n return new ArraySchema(items, options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function object<\n const P extends ObjectSchemaProperties,\n const O extends ObjectSchemaOptions = NonNullable<unknown>,\n>(\n properties: ObjectSchemaProperties & P,\n options: ObjectSchemaOptions & O = {} as O,\n) {\n return new ObjectSchema<P, O>(properties, options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function dict<const K extends Validator, const V extends Validator>(\n key: K,\n value: V,\n) {\n return new DictSchema<K, V>(key, value)\n}\n\n// Utility\nexport type { UnknownObjectOutput as UnknownObject }\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function unknownObject() {\n return new UnknownObjectSchema()\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function ref<T>(get: RefSchemaGetter<T>) {\n return new RefSchema<T>(get)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function custom<T>(\n assertion: CustomAssertion<T>,\n message: string,\n path?: PropertyKey | readonly PropertyKey[],\n) {\n return new CustomSchema<T>(assertion, message, path)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function union<const V extends UnionSchemaValidators>(validators: V) {\n return new UnionSchema<V>(validators)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function intersection<const V extends IntersectionSchemaValidators>(\n validators: V,\n) {\n return new IntersectionSchema<V>(validators)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function discriminatedUnion<\n const Discriminator extends string,\n const Options extends DiscriminatedUnionSchemaVariants<Discriminator>,\n>(discriminator: Discriminator, variants: Options) {\n return new DiscriminatedUnionSchema<Discriminator, Options>(\n discriminator,\n variants,\n )\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function token<const N extends Nsid, const H extends string>(\n nsid: N,\n hash: H,\n) {\n return new TokenSchema($type(nsid, hash))\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function typedRef<const V extends { $type?: string }>(\n get: TypedRefGetter<V>,\n) {\n return new TypedRefSchema<V>(get)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function typedUnion<\n const R extends readonly TypedRefSchema[],\n const C extends boolean,\n>(refs: R, closed: C) {\n return new TypedUnionSchema<R, C>(refs, closed)\n}\n\n/**\n * This function offers two overloads:\n * - One that allows creating a {@link TypedObjectSchema}, and infer the output\n * type from the provided arguments, without requiring to specify any of the\n * generics. This is useful when you want to define a record without\n * explicitly defining its interface. This version does not support circular\n * references, as TypeScript cannot infer types in such cases.\n * - One allows creating a {@link TypedObjectSchema} with an explicitly defined\n * interface. This will typically be used by codegen (`lex build`) to generate\n * schemas that work even if they contain circular references.\n */\nexport function typedObject<\n const N extends Nsid,\n const H extends string,\n const Schema extends Validator<{ [_ in string]?: unknown }>,\n>(nsid: N, hash: H, schema: Schema): TypedObjectSchema<$Type<N, H>, Schema>\nexport function typedObject<const V extends { $type?: $Type }>(\n nsid: V extends { $type?: infer T extends string }\n ? T extends `${infer N}#${string}`\n ? N\n : T // (T is a \"main\" type, so already an NSID)\n : never,\n hash: V extends { $type?: infer T extends string }\n ? T extends `${string}#${infer H}`\n ? H\n : 'main'\n : never,\n schema: Validator<Omit<V, '$type'>>,\n): TypedObjectSchema<NonNullable<V['$type']>, typeof schema, V>\n/*@__NO_SIDE_EFFECTS__*/\nexport function typedObject<\n const N extends Nsid,\n const H extends string,\n const Schema extends Validator<{ [_ in string]?: unknown }>,\n>(nsid: N, hash: H, schema: Schema) {\n return new TypedObjectSchema<$Type<N, H>, Schema>($type(nsid, hash), schema)\n}\n\n/**\n * Ensures that a `$type` used in a record is a valid NSID (i.e. no fragment).\n */\ntype AsNsid<T> = T extends `${string}#${string}` ? never : T\n\n/**\n * This function offers two overloads:\n * - One that allows creating a {@link RecordSchema}, and infer the output type\n * from the provided arguments, without requiring to specify any of the\n * generics. This is useful when you want to define a record without\n * explicitly defining its interface. This version does not support circular\n * references, as TypeScript cannot infer types in such cases.\n * - One allows creating a {@link RecordSchema} with an explicitly defined\n * interface. This will typically be used by codegen (`lex build`) to generate\n * schemas that work even if they contain circular references.\n */\nexport function record<\n const K extends RecordKey,\n const T extends Nsid,\n const S extends Validator<{ [_ in string]?: unknown }>,\n>(\n key: K,\n type: AsNsid<T>,\n schema: S,\n): RecordSchema<K, T, S, Infer<S> & { $type: T }>\nexport function record<\n const K extends RecordKey,\n const V extends { $type: Nsid },\n>(\n key: K,\n type: AsNsid<V['$type']>,\n schema: Validator<Omit<V, '$type'>>,\n): RecordSchema<K, V['$type'], typeof schema, V>\n/*@__NO_SIDE_EFFECTS__*/\nexport function record<\n const K extends RecordKey,\n const T extends Nsid,\n const S extends Validator<{ [_ in string]?: unknown }>,\n>(key: K, type: T, schema: S) {\n return new RecordSchema<K, T, S, Infer<S> & { $type: T }>(key, type, schema)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function params<\n const P extends ParamsSchemaProperties = NonNullable<unknown>,\n const O extends ParamsSchemaOptions = ParamsSchemaOptions,\n>(properties: P = {} as P, options: ParamsSchemaOptions & O = {} as O) {\n return new ParamsSchema<P, O>(properties, options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function payload<\n const E extends string | undefined = undefined,\n const S extends PayloadBody<E> = undefined,\n>(encoding: E = undefined as E, schema: S = undefined as S) {\n return new Payload<E, S>(encoding, schema)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function query<\n const N extends Nsid,\n const P extends ParamsSchema,\n const O extends Payload,\n const E extends undefined | readonly string[] = undefined,\n>(nsid: N, parameters: P, output: O, errors: E = undefined as E) {\n return new Query<N, P, O, E>(nsid, parameters, output, errors)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function procedure<\n const N extends Nsid,\n const P extends ParamsSchema,\n const I extends Payload,\n const O extends Payload,\n const E extends undefined | readonly string[] = undefined,\n>(nsid: N, parameters: P, input: I, output: O, errors: E = undefined as E) {\n return new Procedure<N, P, I, O, E>(nsid, parameters, input, output, errors)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function subscription<\n const N extends string,\n const P extends ParamsSchema,\n const M extends undefined | RefSchema | TypedUnionSchema | ObjectSchema,\n const E extends undefined | readonly string[] = undefined,\n>(nsid: N, parameters: P, message: M, errors: E = undefined as E) {\n return new Subscription<N, P, M, E>(nsid, parameters, message, errors)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function permission<\n const R extends string,\n const O extends PermissionOptions,\n>(resource: R, options: PermissionOptions & O = {} as O) {\n return new Permission<R, O>(resource, options)\n}\n\n/*@__NO_SIDE_EFFECTS__*/\nexport function permissionSet<\n const N extends string,\n const P extends readonly Permission[],\n const O extends PermissionSetOptions,\n>(nsid: N, permissions: P, options: PermissionSetOptions & O = {} as O) {\n return new PermissionSet<N, P, O>(nsid, permissions, options)\n}\n"]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAA;AAClC,cAAc,eAAe,CAAA;AAC7B,OAAO,EAAE,CAAC,EAAE,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.l = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const l = tslib_1.__importStar(require("./external.js"));
|
|
6
|
+
exports.l = l;
|
|
7
|
+
tslib_1.__exportStar(require("./external.js"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,yDAAkC;AAEzB,cAAC;AADV,wDAA6B","sourcesContent":["import * as l from './external.js'\nexport * from './external.js'\nexport { l }\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Infer } from '../validation.js';
|
|
2
|
+
import { ArraySchema } from './array.js';
|
|
3
|
+
import { BooleanSchema } from './boolean.js';
|
|
4
|
+
import { DictSchema } from './dict.js';
|
|
5
|
+
import { IntegerSchema } from './integer.js';
|
|
6
|
+
import { StringSchema } from './string.js';
|
|
7
|
+
import { UnionSchema } from './union.js';
|
|
8
|
+
export type ParamScalar = Infer<typeof paramScalarSchema>;
|
|
9
|
+
declare const paramScalarSchema: UnionSchema<[BooleanSchema, IntegerSchema, StringSchema<{}>]>;
|
|
10
|
+
export type Param = Infer<typeof paramSchema>;
|
|
11
|
+
export declare const paramSchema: UnionSchema<[UnionSchema<[BooleanSchema, IntegerSchema, StringSchema<{}>]>, ArraySchema<string | number | boolean>]>;
|
|
12
|
+
export type Params = {
|
|
13
|
+
[_: string]: undefined | Param;
|
|
14
|
+
};
|
|
15
|
+
export declare const paramsSchema: DictSchema<StringSchema<{}>, UnionSchema<[UnionSchema<[BooleanSchema, IntegerSchema, StringSchema<{}>]>, ArraySchema<string | number | boolean>]>>;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=_parameters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_parameters.d.ts","sourceRoot":"","sources":["../../src/schema/_parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAa,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAExC,MAAM,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;AACzD,QAAA,MAAM,iBAAiB,+DAIrB,CAAA;AAEF,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,WAAW,CAAC,CAAA;AAC7C,eAAO,MAAM,WAAW,sHAGtB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,CAAA;CAAE,CAAA;AACvD,eAAO,MAAM,YAAY,oJAGI,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paramsSchema = exports.paramSchema = void 0;
|
|
4
|
+
const array_js_1 = require("./array.js");
|
|
5
|
+
const boolean_js_1 = require("./boolean.js");
|
|
6
|
+
const dict_js_1 = require("./dict.js");
|
|
7
|
+
const integer_js_1 = require("./integer.js");
|
|
8
|
+
const string_js_1 = require("./string.js");
|
|
9
|
+
const union_js_1 = require("./union.js");
|
|
10
|
+
const paramScalarSchema = new union_js_1.UnionSchema([
|
|
11
|
+
new boolean_js_1.BooleanSchema({}),
|
|
12
|
+
new integer_js_1.IntegerSchema({}),
|
|
13
|
+
new string_js_1.StringSchema({}),
|
|
14
|
+
]);
|
|
15
|
+
exports.paramSchema = new union_js_1.UnionSchema([
|
|
16
|
+
paramScalarSchema,
|
|
17
|
+
new array_js_1.ArraySchema(paramScalarSchema, {}),
|
|
18
|
+
]);
|
|
19
|
+
exports.paramsSchema = new dict_js_1.DictSchema(new string_js_1.StringSchema({}), exports.paramSchema);
|
|
20
|
+
//# sourceMappingURL=_parameters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_parameters.js","sourceRoot":"","sources":["../../src/schema/_parameters.ts"],"names":[],"mappings":";;;AACA,yCAAwC;AACxC,6CAA4C;AAC5C,uCAAsC;AACtC,6CAA4C;AAC5C,2CAA0C;AAC1C,yCAAwC;AAGxC,MAAM,iBAAiB,GAAG,IAAI,sBAAW,CAAC;IACxC,IAAI,0BAAa,CAAC,EAAE,CAAC;IACrB,IAAI,0BAAa,CAAC,EAAE,CAAC;IACrB,IAAI,wBAAY,CAAC,EAAE,CAAC;CACrB,CAAC,CAAA;AAGW,QAAA,WAAW,GAAG,IAAI,sBAAW,CAAC;IACzC,iBAAiB;IACjB,IAAI,sBAAW,CAAC,iBAAiB,EAAE,EAAE,CAAC;CACvC,CAAC,CAAA;AAGW,QAAA,YAAY,GAAG,IAAI,oBAAU,CACxC,IAAI,wBAAY,CAAC,EAAE,CAAC,EACpB,mBAAW,CACgB,CAAA","sourcesContent":["import { Infer, Validator } from '../validation.js'\nimport { ArraySchema } from './array.js'\nimport { BooleanSchema } from './boolean.js'\nimport { DictSchema } from './dict.js'\nimport { IntegerSchema } from './integer.js'\nimport { StringSchema } from './string.js'\nimport { UnionSchema } from './union.js'\n\nexport type ParamScalar = Infer<typeof paramScalarSchema>\nconst paramScalarSchema = new UnionSchema([\n new BooleanSchema({}),\n new IntegerSchema({}),\n new StringSchema({}),\n])\n\nexport type Param = Infer<typeof paramSchema>\nexport const paramSchema = new UnionSchema([\n paramScalarSchema,\n new ArraySchema(paramScalarSchema, {}),\n])\n\nexport type Params = { [_: string]: undefined | Param }\nexport const paramsSchema = new DictSchema(\n new StringSchema({}),\n paramSchema,\n) satisfies Validator<Params>\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ValidationResult, Validator, ValidatorContext } from '../validation.js';
|
|
2
|
+
export type ArraySchemaOptions = {
|
|
3
|
+
minLength?: number;
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare class ArraySchema<Item = any> extends Validator<Array<Item>> {
|
|
7
|
+
readonly items: Validator<Item>;
|
|
8
|
+
readonly options: ArraySchemaOptions;
|
|
9
|
+
readonly lexiconType: "array";
|
|
10
|
+
constructor(items: Validator<Item>, options: ArraySchemaOptions);
|
|
11
|
+
validateInContext(input: unknown, ctx: ValidatorContext): ValidationResult<Array<Item>>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/schema/array.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,qBAAa,WAAW,CAAC,IAAI,GAAG,GAAG,CAAE,SAAQ,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAI/D,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,kBAAkB;IAJtC,QAAQ,CAAC,WAAW,EAAG,OAAO,CAAS;gBAG5B,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC,EACtB,OAAO,EAAE,kBAAkB;IAK7B,iBAAiB,CACxB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;CA8BjC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ArraySchema = void 0;
|
|
4
|
+
const validation_js_1 = require("../validation.js");
|
|
5
|
+
class ArraySchema extends validation_js_1.Validator {
|
|
6
|
+
items;
|
|
7
|
+
options;
|
|
8
|
+
lexiconType = 'array';
|
|
9
|
+
constructor(items, options) {
|
|
10
|
+
super();
|
|
11
|
+
this.items = items;
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
validateInContext(input, ctx) {
|
|
15
|
+
if (!Array.isArray(input)) {
|
|
16
|
+
return ctx.issueInvalidType(input, 'array');
|
|
17
|
+
}
|
|
18
|
+
const { minLength, maxLength } = this.options;
|
|
19
|
+
if (minLength != null && input.length < minLength) {
|
|
20
|
+
return ctx.issueTooSmall(input, 'array', minLength, input.length);
|
|
21
|
+
}
|
|
22
|
+
if (maxLength != null && input.length > maxLength) {
|
|
23
|
+
return ctx.issueTooBig(input, 'array', maxLength, input.length);
|
|
24
|
+
}
|
|
25
|
+
let copy;
|
|
26
|
+
for (let i = 0; i < input.length; i++) {
|
|
27
|
+
const result = ctx.validateChild(input, i, this.items);
|
|
28
|
+
if (!result.success)
|
|
29
|
+
return result;
|
|
30
|
+
if (result.value !== input[i]) {
|
|
31
|
+
// Copy on write (but only if we did not already make a copy)
|
|
32
|
+
copy ??= Array.from(input);
|
|
33
|
+
copy[i] = result.value;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return ctx.success(copy ?? input);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.ArraySchema = ArraySchema;
|
|
40
|
+
//# sourceMappingURL=array.js.map
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AAO;gBAAE,OAAO,MAAM,CAAA;YAElC,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC9B,6DAA6D;gBAC7D,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;gBAC1B,IAAI,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK,CAAA;YACxB,CAAC;QACH,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,KAAK,CAAkC,CAAA;IACpE,CAAC;CACF;AA3CD,kCA2CC","sourcesContent":["import { ValidationResult, Validator, ValidatorContext } from '../validation.js'\n\nexport type ArraySchemaOptions = {\n minLength?: number\n maxLength?: number\n}\n\nexport class ArraySchema<Item = any> extends Validator<Array<Item>> {\n readonly lexiconType = 'array' as const\n\n constructor(\n readonly items: Validator<Item>,\n readonly options: ArraySchemaOptions,\n ) {\n super()\n }\n\n override validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<Array<Item>> {\n if (!Array.isArray(input)) {\n return ctx.issueInvalidType(input, 'array')\n }\n\n const { minLength, maxLength } = this.options\n\n if (minLength != null && input.length < minLength) {\n return ctx.issueTooSmall(input, 'array', minLength, input.length)\n }\n\n if (maxLength != null && input.length > maxLength) {\n return ctx.issueTooBig(input, 'array', maxLength, input.length)\n }\n\n let copy: undefined | Array<Item>\n\n for (let i = 0; i < input.length; i++) {\n const result = ctx.validateChild(input, i, this.items)\n if (!result.success) return result\n\n if (result.value !== input[i]) {\n // Copy on write (but only if we did not already make a copy)\n copy ??= Array.from(input)\n copy[i] = result.value\n }\n }\n\n return ctx.success(copy ?? input) as ValidationResult<Array<Item>>\n }\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { BlobRef, LegacyBlobRef } from '@atproto/lex-data';
|
|
2
|
+
import { ValidationResult, Validator, ValidatorContext } from '../validation.js';
|
|
3
|
+
export type BlobSchemaOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to allow legacy blob references format
|
|
6
|
+
* @see {@link LegacyBlobRef}
|
|
7
|
+
*/
|
|
8
|
+
allowLegacy?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether to enforce strict validation on the blob reference (CID version, codec, hash function)
|
|
11
|
+
*/
|
|
12
|
+
strict?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* List of accepted mime types
|
|
15
|
+
*/
|
|
16
|
+
accept?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Maximum size in bytes
|
|
19
|
+
*/
|
|
20
|
+
maxSize?: number;
|
|
21
|
+
};
|
|
22
|
+
export type { BlobRef, LegacyBlobRef };
|
|
23
|
+
export type BlobSchemaOutput<Options> = Options extends {
|
|
24
|
+
allowLegacy: true;
|
|
25
|
+
} ? BlobRef | LegacyBlobRef : BlobRef;
|
|
26
|
+
export declare class BlobSchema<O extends BlobSchemaOptions> extends Validator<BlobSchemaOutput<O>> {
|
|
27
|
+
readonly options: O;
|
|
28
|
+
readonly lexiconType: "blob";
|
|
29
|
+
constructor(options: O);
|
|
30
|
+
validateInContext(input: unknown, ctx: ValidatorContext): ValidationResult<BlobSchemaOutput<O>>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=blob.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.d.ts","sourceRoot":"","sources":["../../src/schema/blob.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,aAAa,EAGd,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhF,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,YAAY,EAAE,OAAO,EAAE,aAAa,EAAE,CAAA;AAEtC,MAAM,MAAM,gBAAgB,CAAC,OAAO,IAAI,OAAO,SAAS;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GACzE,OAAO,GAAG,aAAa,GACvB,OAAO,CAAA;AAEX,qBAAa,UAAU,CAAC,CAAC,SAAS,iBAAiB,CAAE,SAAQ,SAAS,CACpE,gBAAgB,CAAC,CAAC,CAAC,CACpB;IAGa,QAAQ,CAAC,OAAO,EAAE,CAAC;IAF/B,QAAQ,CAAC,WAAW,EAAG,MAAM,CAAS;gBAEjB,OAAO,EAAE,CAAC;IAItB,iBAAiB,CACxB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;CAoBzC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlobSchema = void 0;
|
|
4
|
+
const lex_data_1 = require("@atproto/lex-data");
|
|
5
|
+
const validation_js_1 = require("../validation.js");
|
|
6
|
+
class BlobSchema extends validation_js_1.Validator {
|
|
7
|
+
options;
|
|
8
|
+
lexiconType = 'blob';
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super();
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
validateInContext(input, ctx) {
|
|
14
|
+
if (!isBlob(input, this.options)) {
|
|
15
|
+
return ctx.issueInvalidType(input, 'blob');
|
|
16
|
+
}
|
|
17
|
+
// @NOTE Historically, we did not enforce constraints on blob references
|
|
18
|
+
// https://github.com/bluesky-social/atproto/blob/4c15fb47cec26060bff2e710e95869a90c9d7fdd/packages/lexicon/src/validators/blob.ts#L5-L19
|
|
19
|
+
// const { accept } = this.options
|
|
20
|
+
// if (accept && !accept.includes(input.mimeType)) {
|
|
21
|
+
// return ctx.issueInvalidValue(input, accept)
|
|
22
|
+
// }
|
|
23
|
+
// const { maxSize } = this.options
|
|
24
|
+
// if (maxSize != null && input.size != -1 && input.size > maxSize) {
|
|
25
|
+
// return ctx.issueTooBig(input, 'blob', maxSize, input.size)
|
|
26
|
+
// }
|
|
27
|
+
return ctx.success(input);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.BlobSchema = BlobSchema;
|
|
31
|
+
function isBlob(input, options) {
|
|
32
|
+
if (input?.$type !== undefined) {
|
|
33
|
+
return (0, lex_data_1.isBlobRef)(input, options);
|
|
34
|
+
}
|
|
35
|
+
if (options.allowLegacy === true) {
|
|
36
|
+
return (0, lex_data_1.isLegacyBlobRef)(input);
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=blob.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blob.js","sourceRoot":"","sources":["../../src/schema/blob.ts"],"names":[],"mappings":";;;AAAA,gDAK0B;AAC1B,oDAAgF;AA4BhF,MAAa,UAAwC,SAAQ,yBAE5D;IAGsB;IAFZ,WAAW,GAAG,MAAe,CAAA;IAEtC,YAAqB,OAAU;QAC7B,KAAK,EAAE,CAAA;QADY,YAAO,GAAP,OAAO,CAAG;IAE/B,CAAC;IAEQ,iBAAiB,CACxB,KAAc,EACd,GAAqB;QAErB,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YACjC,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAC5C,CAAC;QAED,wEAAwE;QACxE,yIAAyI;QAEzI,kCAAkC;QAClC,oDAAoD;QACpD,gDAAgD;QAChD,IAAI;QAEJ,mCAAmC;QACnC,qEAAqE;QACrE,+DAA+D;QAC/D,IAAI;QAEJ,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAhCD,gCAgCC;AAED,SAAS,MAAM,CACb,KAAc,EACd,OAAU;IAEV,IAAK,KAAa,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;QACxC,OAAO,IAAA,oBAAS,EAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,OAAO,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,IAAA,0BAAe,EAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {\n BlobRef,\n LegacyBlobRef,\n isBlobRef,\n isLegacyBlobRef,\n} from '@atproto/lex-data'\nimport { ValidationResult, Validator, ValidatorContext } from '../validation.js'\n\nexport type BlobSchemaOptions = {\n /**\n * Whether to allow legacy blob references format\n * @see {@link LegacyBlobRef}\n */\n allowLegacy?: boolean\n /**\n * Whether to enforce strict validation on the blob reference (CID version, codec, hash function)\n */\n strict?: boolean\n /**\n * List of accepted mime types\n */\n accept?: string[]\n /**\n * Maximum size in bytes\n */\n maxSize?: number\n}\n\nexport type { BlobRef, LegacyBlobRef }\n\nexport type BlobSchemaOutput<Options> = Options extends { allowLegacy: true }\n ? BlobRef | LegacyBlobRef\n : BlobRef\n\nexport class BlobSchema<O extends BlobSchemaOptions> extends Validator<\n BlobSchemaOutput<O>\n> {\n readonly lexiconType = 'blob' as const\n\n constructor(readonly options: O) {\n super()\n }\n\n override validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<BlobSchemaOutput<O>> {\n if (!isBlob(input, this.options)) {\n return ctx.issueInvalidType(input, 'blob')\n }\n\n // @NOTE Historically, we did not enforce constraints on blob references\n // https://github.com/bluesky-social/atproto/blob/4c15fb47cec26060bff2e710e95869a90c9d7fdd/packages/lexicon/src/validators/blob.ts#L5-L19\n\n // const { accept } = this.options\n // if (accept && !accept.includes(input.mimeType)) {\n // return ctx.issueInvalidValue(input, accept)\n // }\n\n // const { maxSize } = this.options\n // if (maxSize != null && input.size != -1 && input.size > maxSize) {\n // return ctx.issueTooBig(input, 'blob', maxSize, input.size)\n // }\n\n return ctx.success(input)\n }\n}\n\nfunction isBlob<O extends BlobSchemaOptions>(\n input: unknown,\n options: O,\n): input is BlobSchemaOutput<O> {\n if ((input as any)?.$type !== undefined) {\n return isBlobRef(input, options)\n }\n\n if (options.allowLegacy === true) {\n return isLegacyBlobRef(input)\n }\n\n return false\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ValidationResult, Validator, ValidatorContext } from '../validation.js';
|
|
2
|
+
export type BooleanSchemaOptions = {
|
|
3
|
+
default?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare class BooleanSchema extends Validator<boolean> {
|
|
6
|
+
readonly options: BooleanSchemaOptions;
|
|
7
|
+
readonly lexiconType: "boolean";
|
|
8
|
+
constructor(options: BooleanSchemaOptions);
|
|
9
|
+
validateInContext(input: unknown | undefined, ctx: ValidatorContext): ValidationResult<boolean>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../src/schema/boolean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,qBAAa,aAAc,SAAQ,SAAS,CAAC,OAAO,CAAC;IAGvC,QAAQ,CAAC,OAAO,EAAE,oBAAoB;IAFlD,QAAQ,CAAC,WAAW,EAAG,SAAS,CAAS;gBAEpB,OAAO,EAAE,oBAAoB;IAIzC,iBAAiB,CACxB,KAAK,EAAE,OAAO,YAAuB,EACrC,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,OAAO,CAAC;CAO7B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanSchema = void 0;
|
|
4
|
+
const validation_js_1 = require("../validation.js");
|
|
5
|
+
class BooleanSchema extends validation_js_1.Validator {
|
|
6
|
+
options;
|
|
7
|
+
lexiconType = 'boolean';
|
|
8
|
+
constructor(options) {
|
|
9
|
+
super();
|
|
10
|
+
this.options = options;
|
|
11
|
+
}
|
|
12
|
+
validateInContext(input = this.options.default, ctx) {
|
|
13
|
+
if (typeof input === 'boolean') {
|
|
14
|
+
return ctx.success(input);
|
|
15
|
+
}
|
|
16
|
+
return ctx.issueInvalidType(input, 'boolean');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.BooleanSchema = BooleanSchema;
|
|
20
|
+
//# sourceMappingURL=boolean.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.js","sourceRoot":"","sources":["../../src/schema/boolean.ts"],"names":[],"mappings":";;;AAAA,oDAAgF;AAMhF,MAAa,aAAc,SAAQ,yBAAkB;IAG9B;IAFZ,WAAW,GAAG,SAAkB,CAAA;IAEzC,YAAqB,OAA6B;QAChD,KAAK,EAAE,CAAA;QADY,YAAO,GAAP,OAAO,CAAsB;IAElD,CAAC;IAEQ,iBAAiB,CACxB,QAAiB,IAAI,CAAC,OAAO,CAAC,OAAO,EACrC,GAAqB;QAErB,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC3B,CAAC;QAED,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IAC/C,CAAC;CACF;AAjBD,sCAiBC","sourcesContent":["import { ValidationResult, Validator, ValidatorContext } from '../validation.js'\n\nexport type BooleanSchemaOptions = {\n default?: boolean\n}\n\nexport class BooleanSchema extends Validator<boolean> {\n readonly lexiconType = 'boolean' as const\n\n constructor(readonly options: BooleanSchemaOptions) {\n super()\n }\n\n override validateInContext(\n input: unknown = this.options.default,\n ctx: ValidatorContext,\n ): ValidationResult<boolean> {\n if (typeof input === 'boolean') {\n return ctx.success(input)\n }\n\n return ctx.issueInvalidType(input, 'boolean')\n }\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ValidationResult, Validator, ValidatorContext } from '../validation.js';
|
|
2
|
+
export type BytesSchemaOptions = {
|
|
3
|
+
minLength?: number;
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare class BytesSchema extends Validator<Uint8Array> {
|
|
7
|
+
readonly options: BytesSchemaOptions;
|
|
8
|
+
readonly lexiconType: "bytes";
|
|
9
|
+
constructor(options: BytesSchemaOptions);
|
|
10
|
+
validateInContext(input: unknown, ctx: ValidatorContext): ValidationResult<Uint8Array>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=bytes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../src/schema/bytes.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAED,qBAAa,WAAY,SAAQ,SAAS,CAAC,UAAU,CAAC;IAGxC,QAAQ,CAAC,OAAO,EAAE,kBAAkB;IAFhD,QAAQ,CAAC,WAAW,EAAG,OAAO,CAAS;gBAElB,OAAO,EAAE,kBAAkB;IAIvC,iBAAiB,CACxB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,UAAU,CAAC;CAmBhC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BytesSchema = void 0;
|
|
4
|
+
const lex_data_1 = require("@atproto/lex-data");
|
|
5
|
+
const validation_js_1 = require("../validation.js");
|
|
6
|
+
class BytesSchema extends validation_js_1.Validator {
|
|
7
|
+
options;
|
|
8
|
+
lexiconType = 'bytes';
|
|
9
|
+
constructor(options) {
|
|
10
|
+
super();
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
validateInContext(input, ctx) {
|
|
14
|
+
// Coerce different binary formats into Uint8Array
|
|
15
|
+
const bytes = (0, lex_data_1.asUint8Array)(input);
|
|
16
|
+
if (!bytes) {
|
|
17
|
+
return ctx.issueInvalidType(input, 'bytes');
|
|
18
|
+
}
|
|
19
|
+
const { minLength } = this.options;
|
|
20
|
+
if (minLength != null && bytes.length < minLength) {
|
|
21
|
+
return ctx.issueTooSmall(bytes, 'bytes', minLength, bytes.length);
|
|
22
|
+
}
|
|
23
|
+
const { maxLength } = this.options;
|
|
24
|
+
if (maxLength != null && bytes.length > maxLength) {
|
|
25
|
+
return ctx.issueTooBig(bytes, 'bytes', maxLength, bytes.length);
|
|
26
|
+
}
|
|
27
|
+
return ctx.success(bytes);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.BytesSchema = BytesSchema;
|
|
31
|
+
//# sourceMappingURL=bytes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bytes.js","sourceRoot":"","sources":["../../src/schema/bytes.ts"],"names":[],"mappings":";;;AAAA,gDAAgD;AAChD,oDAAgF;AAOhF,MAAa,WAAY,SAAQ,yBAAqB;IAG/B;IAFZ,WAAW,GAAG,OAAgB,CAAA;IAEvC,YAAqB,OAA2B;QAC9C,KAAK,EAAE,CAAA;QADY,YAAO,GAAP,OAAO,CAAoB;IAEhD,CAAC;IAEQ,iBAAiB,CACxB,KAAc,EACd,GAAqB;QAErB,kDAAkD;QAClD,MAAM,KAAK,GAAG,IAAA,uBAAY,EAAC,KAAK,CAAC,CAAA;QACjC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC7C,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;QAClC,IAAI,SAAS,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;YAClD,OAAO,GAAG,CAAC,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QACnE,CAAC;QAED,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,OAAO,CAAA;QAClC,IAAI,SAAS,IAAI,IAAI,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;YAClD,OAAO,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;QACjE,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AA7BD,kCA6BC","sourcesContent":["import { asUint8Array } from '@atproto/lex-data'\nimport { ValidationResult, Validator, ValidatorContext } from '../validation.js'\n\nexport type BytesSchemaOptions = {\n minLength?: number\n maxLength?: number\n}\n\nexport class BytesSchema extends Validator<Uint8Array> {\n readonly lexiconType = 'bytes' as const\n\n constructor(readonly options: BytesSchemaOptions) {\n super()\n }\n\n override validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<Uint8Array> {\n // Coerce different binary formats into Uint8Array\n const bytes = asUint8Array(input)\n if (!bytes) {\n return ctx.issueInvalidType(input, 'bytes')\n }\n\n const { minLength } = this.options\n if (minLength != null && bytes.length < minLength) {\n return ctx.issueTooSmall(bytes, 'bytes', minLength, bytes.length)\n }\n\n const { maxLength } = this.options\n if (maxLength != null && bytes.length > maxLength) {\n return ctx.issueTooBig(bytes, 'bytes', maxLength, bytes.length)\n }\n\n return ctx.success(bytes)\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CID } from '@atproto/lex-data';
|
|
2
|
+
import { ValidationResult, Validator, ValidatorContext } from '../validation.js';
|
|
3
|
+
export { CID };
|
|
4
|
+
export type CidSchemaOptions = {
|
|
5
|
+
strict?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare class CidSchema extends Validator<CID> {
|
|
8
|
+
readonly options: CidSchemaOptions;
|
|
9
|
+
readonly lexiconType: "cid-link";
|
|
10
|
+
constructor(options?: CidSchemaOptions);
|
|
11
|
+
validateInContext(input: unknown, ctx: ValidatorContext): ValidationResult<CID>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=cid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.d.ts","sourceRoot":"","sources":["../../src/schema/cid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAS,MAAM,mBAAmB,CAAA;AAC9C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAEhF,OAAO,EAAE,GAAG,EAAE,CAAA;AAEd,MAAM,MAAM,gBAAgB,GAAG;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,qBAAa,SAAU,SAAQ,SAAS,CAAC,GAAG,CAAC;IAG/B,QAAQ,CAAC,OAAO,EAAE,gBAAgB;IAF9C,QAAQ,CAAC,WAAW,EAAG,UAAU,CAAS;gBAErB,OAAO,GAAE,gBAAqB;IAI1C,iBAAiB,CACxB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,GAAG,CAAC;CAOzB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CidSchema = exports.CID = void 0;
|
|
4
|
+
const lex_data_1 = require("@atproto/lex-data");
|
|
5
|
+
Object.defineProperty(exports, "CID", { enumerable: true, get: function () { return lex_data_1.CID; } });
|
|
6
|
+
const validation_js_1 = require("../validation.js");
|
|
7
|
+
class CidSchema extends validation_js_1.Validator {
|
|
8
|
+
options;
|
|
9
|
+
lexiconType = 'cid-link';
|
|
10
|
+
constructor(options = {}) {
|
|
11
|
+
super();
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
validateInContext(input, ctx) {
|
|
15
|
+
if (!(0, lex_data_1.isCid)(input, this.options)) {
|
|
16
|
+
return ctx.issueInvalidType(input, 'cid');
|
|
17
|
+
}
|
|
18
|
+
return ctx.success(input);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CidSchema = CidSchema;
|
|
22
|
+
//# sourceMappingURL=cid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cid.js","sourceRoot":"","sources":["../../src/schema/cid.ts"],"names":[],"mappings":";;;AAAA,gDAA8C;AAGrC,oFAHA,cAAG,OAGA;AAFZ,oDAAgF;AAQhF,MAAa,SAAU,SAAQ,yBAAc;IAGtB;IAFZ,WAAW,GAAG,UAAmB,CAAA;IAE1C,YAAqB,UAA4B,EAAE;QACjD,KAAK,EAAE,CAAA;QADY,YAAO,GAAP,OAAO,CAAuB;IAEnD,CAAC;IAEQ,iBAAiB,CACxB,KAAc,EACd,GAAqB;QAErB,IAAI,CAAC,IAAA,gBAAK,EAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,OAAO,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAC3C,CAAC;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC3B,CAAC;CACF;AAjBD,8BAiBC","sourcesContent":["import { CID, isCid } from '@atproto/lex-data'\nimport { ValidationResult, Validator, ValidatorContext } from '../validation.js'\n\nexport { CID }\n\nexport type CidSchemaOptions = {\n strict?: boolean\n}\n\nexport class CidSchema extends Validator<CID> {\n readonly lexiconType = 'cid-link' as const\n\n constructor(readonly options: CidSchemaOptions = {}) {\n super()\n }\n\n override validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<CID> {\n if (!isCid(input, this.options)) {\n return ctx.issueInvalidType(input, 'cid')\n }\n\n return ctx.success(input)\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropertyKey } from '../validation/property-key.js';
|
|
2
|
+
import { ContextualIssue, ValidationResult, Validator, ValidatorContext } from '../validation/validator.js';
|
|
3
|
+
export type CustomAssertionContext = {
|
|
4
|
+
path: PropertyKey[];
|
|
5
|
+
addIssue(issue: ContextualIssue): void;
|
|
6
|
+
};
|
|
7
|
+
export type CustomAssertion<T = any> = (this: null, input: unknown, ctx: CustomAssertionContext) => input is T;
|
|
8
|
+
export declare class CustomSchema<T = unknown> extends Validator<T> {
|
|
9
|
+
private readonly assertion;
|
|
10
|
+
private readonly message;
|
|
11
|
+
private readonly path?;
|
|
12
|
+
constructor(assertion: CustomAssertion<T>, message: string, path?: (PropertyKey | readonly PropertyKey[]) | undefined);
|
|
13
|
+
validateInContext(input: unknown, ctx: ValidatorContext): ValidationResult<T>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=custom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/schema/custom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC3D,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EACjB,MAAM,4BAA4B,CAAA;AAEnC,MAAM,MAAM,sBAAsB,GAAG;IACnC,IAAI,EAAE,WAAW,EAAE,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,CAAC,GAAG,GAAG,IAAI,CACrC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,sBAAsB,KACxB,KAAK,IAAI,CAAC,CAAA;AAEf,qBAAa,YAAY,CAAC,CAAC,GAAG,OAAO,CAAE,SAAQ,SAAS,CAAC,CAAC,CAAC;IAEvD,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAFL,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,EAC7B,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,GAAE,WAAW,GAAG,SAAS,WAAW,EAAE,aAAA;IAKrD,iBAAiB,CACxB,KAAK,EAAE,OAAO,EACd,GAAG,EAAE,gBAAgB,GACpB,gBAAgB,CAAC,CAAC,CAAC;CAIvB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CustomSchema = void 0;
|
|
4
|
+
const validator_js_1 = require("../validation/validator.js");
|
|
5
|
+
class CustomSchema extends validator_js_1.Validator {
|
|
6
|
+
assertion;
|
|
7
|
+
message;
|
|
8
|
+
path;
|
|
9
|
+
constructor(assertion, message, path) {
|
|
10
|
+
super();
|
|
11
|
+
this.assertion = assertion;
|
|
12
|
+
this.message = message;
|
|
13
|
+
this.path = path;
|
|
14
|
+
}
|
|
15
|
+
validateInContext(input, ctx) {
|
|
16
|
+
if (this.assertion.call(null, input, ctx))
|
|
17
|
+
return ctx.success(input);
|
|
18
|
+
return ctx.custom(input, this.message, this.path);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.CustomSchema = CustomSchema;
|
|
22
|
+
//# sourceMappingURL=custom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom.js","sourceRoot":"","sources":["../../src/schema/custom.ts"],"names":[],"mappings":";;;AACA,6DAKmC;AAanC,MAAa,YAA0B,SAAQ,wBAAY;IAEtC;IACA;IACA;IAHnB,YACmB,SAA6B,EAC7B,OAAe,EACf,IAA2C;QAE5D,KAAK,EAAE,CAAA;QAJU,cAAS,GAAT,SAAS,CAAoB;QAC7B,YAAO,GAAP,OAAO,CAAQ;QACf,SAAI,GAAJ,IAAI,CAAuC;IAG9D,CAAC;IAEQ,iBAAiB,CACxB,KAAc,EACd,GAAqB;QAErB,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC,OAAO,CAAC,KAAU,CAAC,CAAA;QACzE,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;IACnD,CAAC;CACF;AAhBD,oCAgBC","sourcesContent":["import { PropertyKey } from '../validation/property-key.js'\nimport {\n ContextualIssue,\n ValidationResult,\n Validator,\n ValidatorContext,\n} from '../validation/validator.js'\n\nexport type CustomAssertionContext = {\n path: PropertyKey[]\n addIssue(issue: ContextualIssue): void\n}\n\nexport type CustomAssertion<T = any> = (\n this: null,\n input: unknown,\n ctx: CustomAssertionContext,\n) => input is T\n\nexport class CustomSchema<T = unknown> extends Validator<T> {\n constructor(\n private readonly assertion: CustomAssertion<T>,\n private readonly message: string,\n private readonly path?: PropertyKey | readonly PropertyKey[],\n ) {\n super()\n }\n\n override validateInContext(\n input: unknown,\n ctx: ValidatorContext,\n ): ValidationResult<T> {\n if (this.assertion.call(null, input, ctx)) return ctx.success(input as T)\n return ctx.custom(input, this.message, this.path)\n }\n}\n"]}
|