pema 0.9.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/private/index.d.ts +108 -2
- package/lib/private/index.js +92 -90
- package/package.json +1 -1
package/lib/private/index.d.ts
CHANGED
|
@@ -149,7 +149,113 @@ declare namespace schema {
|
|
|
149
149
|
export { loose };
|
|
150
150
|
export { strict };
|
|
151
151
|
}
|
|
152
|
-
declare
|
|
153
|
-
|
|
152
|
+
declare const loose: (<const S extends Schema>(s: S) => NormalizeSchema<S>) & {
|
|
153
|
+
array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>, true>;
|
|
154
|
+
bigint: import("./BigIntType.js").default<"i64", true>;
|
|
155
|
+
biguint: import("./BigUintType.js").default<"u64", true>;
|
|
156
|
+
blob: import("#BlobType").default;
|
|
157
|
+
boolean: import("#BooleanType").default<true>;
|
|
158
|
+
constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
|
|
159
|
+
date: import("#DateType").default<true>;
|
|
160
|
+
dict: {
|
|
161
|
+
(): import("#RecordType").default<import("#StringType").default, import("#StringType").default, true>;
|
|
162
|
+
<const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value, true>;
|
|
163
|
+
};
|
|
164
|
+
enum: <const V extends import("@rcompat/type").Dict<number>>(values: V) => import("#EnumType").Enum<V, true>;
|
|
165
|
+
f32: import("#NumberType").default<"f32", true>;
|
|
166
|
+
f64: import("#NumberType").default<"f64", true>;
|
|
167
|
+
file: import("./FileType.js").default;
|
|
168
|
+
function: import("#FunctionType").default;
|
|
169
|
+
i128: import("./BigIntType.js").default<"i128", true>;
|
|
170
|
+
i16: import("./IntType.js").default<"i16", true>;
|
|
171
|
+
i32: import("./IntType.js").default<"i32", true>;
|
|
172
|
+
i64: import("./BigIntType.js").default<"i64", true>;
|
|
173
|
+
i8: import("./IntType.js").default<"i8", true>;
|
|
174
|
+
int: import("./IntType.js").default<"i32", true>;
|
|
175
|
+
is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
|
|
176
|
+
json: {
|
|
177
|
+
(): import("#JSONType").default<undefined>;
|
|
178
|
+
<S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
|
|
179
|
+
};
|
|
180
|
+
literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, true>;
|
|
181
|
+
null: import("#NullType").default;
|
|
182
|
+
number: import("#NumberType").default<"f64", true>;
|
|
183
|
+
object: <P extends import("@rcompat/type").Dict<Schema> = import("@rcompat/type").Dict<Schema>>(properties: P) => import("#ObjectType").default<keyof P extends never ? {} : { [K in keyof P]: NormalizeSchema<P[K]>; }, true>;
|
|
184
|
+
omit: <P extends import("@rcompat/type").Dict<import("#Parsed").default<unknown>>, K extends keyof P>(type: import("#ObjectType").default<P>, ...keys: K[]) => import("./OmitType.js").default<P, K, true>;
|
|
185
|
+
record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value, true>;
|
|
186
|
+
partial: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }, true>;
|
|
187
|
+
pure: <T>() => import("#PureType").default<T, "PureType">;
|
|
188
|
+
string: import("#StringType").default;
|
|
189
|
+
symbol: import("./SymbolType.js").default;
|
|
190
|
+
tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, true>;
|
|
191
|
+
u128: import("./BigUintType.js").default<"u128", true>;
|
|
192
|
+
u16: import("#UintType").default<"u16", true>;
|
|
193
|
+
u32: import("#UintType").default<"u32", true>;
|
|
194
|
+
u64: import("./BigUintType.js").default<"u64", true>;
|
|
195
|
+
u8: import("#UintType").default<"u8", true>;
|
|
196
|
+
uint: import("#UintType").default<"u32", true>;
|
|
197
|
+
undefined: import("#UndefinedType").default;
|
|
198
|
+
union: {
|
|
199
|
+
(): import("#UnionType").default<[], true>;
|
|
200
|
+
<const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, true>;
|
|
201
|
+
};
|
|
202
|
+
unknown: import("#UnknownType").default;
|
|
203
|
+
url: import("#URLType").default<true>;
|
|
204
|
+
uuid: import("#UUIDType").default;
|
|
205
|
+
};
|
|
206
|
+
declare const strict: (<const S extends Schema>(s: S) => NormalizeSchema<S>) & {
|
|
207
|
+
array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>, false>;
|
|
208
|
+
bigint: import("./BigIntType.js").default<"i64", false>;
|
|
209
|
+
biguint: import("./BigUintType.js").default<"u64", false>;
|
|
210
|
+
blob: import("#BlobType").default;
|
|
211
|
+
boolean: import("#BooleanType").default<false>;
|
|
212
|
+
constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
|
|
213
|
+
date: import("#DateType").default<false>;
|
|
214
|
+
dict: {
|
|
215
|
+
(): import("#RecordType").default<import("#StringType").default, import("#StringType").default, false>;
|
|
216
|
+
<const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value, false>;
|
|
217
|
+
};
|
|
218
|
+
enum: <const V extends import("@rcompat/type").Dict<number>>(values: V) => import("#EnumType").Enum<V, false>;
|
|
219
|
+
f32: import("#NumberType").default<"f32", false>;
|
|
220
|
+
f64: import("#NumberType").default<"f64", false>;
|
|
221
|
+
file: import("./FileType.js").default;
|
|
222
|
+
function: import("#FunctionType").default;
|
|
223
|
+
i128: import("./BigIntType.js").default<"i128", false>;
|
|
224
|
+
i16: import("./IntType.js").default<"i16", false>;
|
|
225
|
+
i32: import("./IntType.js").default<"i32", false>;
|
|
226
|
+
i64: import("./BigIntType.js").default<"i64", false>;
|
|
227
|
+
i8: import("./IntType.js").default<"i8", false>;
|
|
228
|
+
int: import("./IntType.js").default<"i32", false>;
|
|
229
|
+
is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
|
|
230
|
+
json: {
|
|
231
|
+
(): import("#JSONType").default<undefined>;
|
|
232
|
+
<S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
|
|
233
|
+
};
|
|
234
|
+
literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, false>;
|
|
235
|
+
null: import("#NullType").default;
|
|
236
|
+
number: import("#NumberType").default<"f64", false>;
|
|
237
|
+
object: <P extends import("@rcompat/type").Dict<Schema> = import("@rcompat/type").Dict<Schema>>(properties: P) => import("#ObjectType").default<keyof P extends never ? {} : { [K in keyof P]: NormalizeSchema<P[K]>; }, false>;
|
|
238
|
+
omit: <P extends import("@rcompat/type").Dict<import("#Parsed").default<unknown>>, K extends keyof P>(type: import("#ObjectType").default<P>, ...keys: K[]) => import("./OmitType.js").default<P, K, false>;
|
|
239
|
+
record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value, false>;
|
|
240
|
+
partial: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }, false>;
|
|
241
|
+
pure: <T>() => import("#PureType").default<T, "PureType">;
|
|
242
|
+
string: import("#StringType").default;
|
|
243
|
+
symbol: import("./SymbolType.js").default;
|
|
244
|
+
tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, false>;
|
|
245
|
+
u128: import("./BigUintType.js").default<"u128", false>;
|
|
246
|
+
u16: import("#UintType").default<"u16", false>;
|
|
247
|
+
u32: import("#UintType").default<"u32", false>;
|
|
248
|
+
u64: import("./BigUintType.js").default<"u64", false>;
|
|
249
|
+
u8: import("#UintType").default<"u8", false>;
|
|
250
|
+
uint: import("#UintType").default<"u32", false>;
|
|
251
|
+
undefined: import("#UndefinedType").default;
|
|
252
|
+
union: {
|
|
253
|
+
(): import("#UnionType").default<[], false>;
|
|
254
|
+
<const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, false>;
|
|
255
|
+
};
|
|
256
|
+
unknown: import("#UnknownType").default;
|
|
257
|
+
url: import("#URLType").default<false>;
|
|
258
|
+
uuid: import("#UUIDType").default;
|
|
259
|
+
};
|
|
154
260
|
export default schema;
|
|
155
261
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/private/index.js
CHANGED
|
@@ -51,16 +51,104 @@ import uuid from "#uuid";
|
|
|
51
51
|
function schema(s) {
|
|
52
52
|
return normalize(s);
|
|
53
53
|
}
|
|
54
|
-
function loose(s) {
|
|
54
|
+
const loose = Object.assign(function loose(s) {
|
|
55
55
|
const i = normalize(s);
|
|
56
56
|
i[Loose] = true;
|
|
57
57
|
return i;
|
|
58
|
-
}
|
|
59
|
-
|
|
58
|
+
}, {
|
|
59
|
+
array: array.loose,
|
|
60
|
+
bigint: bigint.loose,
|
|
61
|
+
biguint: biguint.loose,
|
|
62
|
+
blob: blob.loose,
|
|
63
|
+
boolean: boolean.loose,
|
|
64
|
+
constructor: constructor.loose,
|
|
65
|
+
date: date.loose,
|
|
66
|
+
dict: dict.loose,
|
|
67
|
+
enum: enum$.loose,
|
|
68
|
+
f32: f32.loose,
|
|
69
|
+
f64: f64.loose,
|
|
70
|
+
file: file.loose,
|
|
71
|
+
function: function$.loose,
|
|
72
|
+
i128: i128.loose,
|
|
73
|
+
i16: i16.loose,
|
|
74
|
+
i32: i32.loose,
|
|
75
|
+
i64: i64.loose,
|
|
76
|
+
i8: i8.loose,
|
|
77
|
+
int: int.loose,
|
|
78
|
+
is: is.loose,
|
|
79
|
+
json: json.loose,
|
|
80
|
+
literal: literal.loose,
|
|
81
|
+
null: null$.loose,
|
|
82
|
+
number: number.loose,
|
|
83
|
+
object: object.loose,
|
|
84
|
+
omit: omit.loose,
|
|
85
|
+
record: record.loose,
|
|
86
|
+
partial: partial.loose,
|
|
87
|
+
pure: pure.loose,
|
|
88
|
+
string: string.loose,
|
|
89
|
+
symbol: symbol.loose,
|
|
90
|
+
tuple: tuple.loose,
|
|
91
|
+
u128: u128.loose,
|
|
92
|
+
u16: u16.loose,
|
|
93
|
+
u32: u32.loose,
|
|
94
|
+
u64: u64.loose,
|
|
95
|
+
u8: u8.loose,
|
|
96
|
+
uint: uint.loose,
|
|
97
|
+
undefined: undefined$.loose,
|
|
98
|
+
union: union.loose,
|
|
99
|
+
unknown: unknown.loose,
|
|
100
|
+
url: url.loose,
|
|
101
|
+
uuid: uuid.loose,
|
|
102
|
+
});
|
|
103
|
+
const strict = Object.assign(function strict(s) {
|
|
60
104
|
const i = normalize(s);
|
|
61
105
|
i[Loose] = false;
|
|
62
106
|
return i;
|
|
63
|
-
}
|
|
107
|
+
}, {
|
|
108
|
+
array: array.strict,
|
|
109
|
+
bigint: bigint.strict,
|
|
110
|
+
biguint: biguint.strict,
|
|
111
|
+
blob: blob.strict,
|
|
112
|
+
boolean: boolean.strict,
|
|
113
|
+
constructor: constructor.strict,
|
|
114
|
+
date: date.strict,
|
|
115
|
+
dict: dict.strict,
|
|
116
|
+
enum: enum$.strict,
|
|
117
|
+
f32: f32.strict,
|
|
118
|
+
f64: f64.strict,
|
|
119
|
+
file: file.strict,
|
|
120
|
+
function: function$.strict,
|
|
121
|
+
i128: i128.strict,
|
|
122
|
+
i16: i16.strict,
|
|
123
|
+
i32: i32.strict,
|
|
124
|
+
i64: i64.strict,
|
|
125
|
+
i8: i8.strict,
|
|
126
|
+
int: int.strict,
|
|
127
|
+
is: is.strict,
|
|
128
|
+
json: json.strict,
|
|
129
|
+
literal: literal.strict,
|
|
130
|
+
null: null$.strict,
|
|
131
|
+
number: number.strict,
|
|
132
|
+
object: object.strict,
|
|
133
|
+
omit: omit.strict,
|
|
134
|
+
record: record.strict,
|
|
135
|
+
partial: partial.strict,
|
|
136
|
+
pure: pure.strict,
|
|
137
|
+
string: string.strict,
|
|
138
|
+
symbol: symbol.strict,
|
|
139
|
+
tuple: tuple.strict,
|
|
140
|
+
u128: u128.strict,
|
|
141
|
+
u16: u16.strict,
|
|
142
|
+
u32: u32.strict,
|
|
143
|
+
u64: u64.strict,
|
|
144
|
+
u8: u8.strict,
|
|
145
|
+
uint: uint.strict,
|
|
146
|
+
undefined: undefined$.strict,
|
|
147
|
+
union: union.strict,
|
|
148
|
+
unknown: unknown.strict,
|
|
149
|
+
url: url.strict,
|
|
150
|
+
uuid: uuid.strict,
|
|
151
|
+
});
|
|
64
152
|
schema.array = array.vanilla;
|
|
65
153
|
schema.async = async_schema;
|
|
66
154
|
schema.bigint = bigint.vanilla;
|
|
@@ -106,92 +194,6 @@ schema.unknown = unknown.vanilla;
|
|
|
106
194
|
schema.url = url.vanilla;
|
|
107
195
|
schema.uuid = uuid.vanilla;
|
|
108
196
|
schema.error = E.field;
|
|
109
|
-
loose.array = array.loose;
|
|
110
|
-
loose.bigint = bigint.loose;
|
|
111
|
-
loose.biguint = biguint.loose;
|
|
112
|
-
loose.blob = blob.loose;
|
|
113
|
-
loose.boolean = boolean.loose;
|
|
114
|
-
loose.constructor = constructor.loose;
|
|
115
|
-
loose.date = date.loose;
|
|
116
|
-
loose.dict = dict.loose;
|
|
117
|
-
loose.enum = enum$.loose;
|
|
118
|
-
loose.f32 = f32.loose;
|
|
119
|
-
loose.f64 = f64.loose;
|
|
120
|
-
loose.file = file.loose;
|
|
121
|
-
loose.function = function$.loose;
|
|
122
|
-
loose.i128 = i128.loose;
|
|
123
|
-
loose.i16 = i16.loose;
|
|
124
|
-
loose.i32 = i32.loose;
|
|
125
|
-
loose.i64 = i64.loose;
|
|
126
|
-
loose.i8 = i8.loose;
|
|
127
|
-
loose.int = int.loose;
|
|
128
|
-
loose.is = is.loose;
|
|
129
|
-
loose.json = json.loose;
|
|
130
|
-
loose.literal = literal.loose;
|
|
131
|
-
loose.null = null$.loose;
|
|
132
|
-
loose.number = number.loose;
|
|
133
|
-
loose.object = object.loose;
|
|
134
|
-
loose.omit = omit.loose;
|
|
135
|
-
loose.record = record.loose;
|
|
136
|
-
loose.partial = partial.loose;
|
|
137
|
-
loose.pure = pure.loose;
|
|
138
|
-
loose.string = string.loose;
|
|
139
|
-
loose.symbol = symbol.loose;
|
|
140
|
-
loose.tuple = tuple.loose;
|
|
141
|
-
loose.u128 = u128.loose;
|
|
142
|
-
loose.u16 = u16.loose;
|
|
143
|
-
loose.u32 = u32.loose;
|
|
144
|
-
loose.u64 = u64.loose;
|
|
145
|
-
loose.u8 = u8.loose;
|
|
146
|
-
loose.uint = uint.loose;
|
|
147
|
-
loose.undefined = undefined$.loose;
|
|
148
|
-
loose.union = union.loose;
|
|
149
|
-
loose.unknown = unknown.loose;
|
|
150
|
-
loose.url = url.loose;
|
|
151
|
-
loose.uuid = uuid.loose;
|
|
152
|
-
strict.array = array.strict;
|
|
153
|
-
strict.bigint = bigint.strict;
|
|
154
|
-
strict.biguint = biguint.strict;
|
|
155
|
-
strict.blob = blob.strict;
|
|
156
|
-
strict.boolean = boolean.strict;
|
|
157
|
-
strict.constructor = constructor.strict;
|
|
158
|
-
strict.date = date.strict;
|
|
159
|
-
strict.dict = dict.strict;
|
|
160
|
-
strict.enum = enum$.strict;
|
|
161
|
-
strict.f32 = f32.strict;
|
|
162
|
-
strict.f64 = f64.strict;
|
|
163
|
-
strict.file = file.strict;
|
|
164
|
-
strict.function = function$.strict;
|
|
165
|
-
strict.i128 = i128.strict;
|
|
166
|
-
strict.i16 = i16.strict;
|
|
167
|
-
strict.i32 = i32.strict;
|
|
168
|
-
strict.i64 = i64.strict;
|
|
169
|
-
strict.i8 = i8.strict;
|
|
170
|
-
strict.int = int.strict;
|
|
171
|
-
strict.is = is.strict;
|
|
172
|
-
strict.json = json.strict;
|
|
173
|
-
strict.literal = literal.strict;
|
|
174
|
-
strict.null = null$.strict;
|
|
175
|
-
strict.number = number.strict;
|
|
176
|
-
strict.object = object.strict;
|
|
177
|
-
strict.omit = omit.strict;
|
|
178
|
-
strict.record = record.strict;
|
|
179
|
-
strict.partial = partial.strict;
|
|
180
|
-
strict.pure = pure.strict;
|
|
181
|
-
strict.string = string.strict;
|
|
182
|
-
strict.symbol = symbol.strict;
|
|
183
|
-
strict.tuple = tuple.strict;
|
|
184
|
-
strict.u128 = u128.strict;
|
|
185
|
-
strict.u16 = u16.strict;
|
|
186
|
-
strict.u32 = u32.strict;
|
|
187
|
-
strict.u64 = u64.strict;
|
|
188
|
-
strict.u8 = u8.strict;
|
|
189
|
-
strict.uint = uint.strict;
|
|
190
|
-
strict.undefined = undefined$.strict;
|
|
191
|
-
strict.union = union.strict;
|
|
192
|
-
strict.unknown = unknown.strict;
|
|
193
|
-
strict.url = url.strict;
|
|
194
|
-
strict.uuid = uuid.strict;
|
|
195
197
|
schema.loose = loose;
|
|
196
198
|
schema.strict = strict;
|
|
197
199
|
export default schema;
|