pema 0.8.2 → 0.9.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.
Files changed (46) hide show
  1. package/lib/private/ArrayType.d.ts +1 -1
  2. package/lib/private/ArrayType.js +7 -7
  3. package/lib/private/AsyncType.d.ts +18 -0
  4. package/lib/private/AsyncType.js +28 -0
  5. package/lib/private/EnumType.d.ts +13 -10
  6. package/lib/private/EnumType.js +31 -13
  7. package/lib/private/InferInputSchema.d.ts +1 -1
  8. package/lib/private/JSONType.js +3 -4
  9. package/lib/private/LiteralType.d.ts +1 -1
  10. package/lib/private/NumericType.d.ts +1 -1
  11. package/lib/private/NumericType.js +5 -5
  12. package/lib/private/ObjectType.js +2 -2
  13. package/lib/private/OmitType.js +3 -4
  14. package/lib/private/Parsed.d.ts +1 -0
  15. package/lib/private/Parsed.js +21 -0
  16. package/lib/private/PartialType.js +2 -2
  17. package/lib/private/PrimitiveType.d.ts +1 -1
  18. package/lib/private/PrimitiveType.js +3 -2
  19. package/lib/private/Serialized.d.ts +2 -1
  20. package/lib/private/StoreType.js +1 -1
  21. package/lib/private/StringType.js +8 -8
  22. package/lib/private/TupleType.js +1 -1
  23. package/lib/private/UintType.js +1 -1
  24. package/lib/private/array.d.ts +9 -3
  25. package/lib/private/async.d.ts +8 -0
  26. package/lib/private/async.js +7 -0
  27. package/lib/private/coerce/date.js +3 -5
  28. package/lib/private/constructor.d.ts +9 -3
  29. package/lib/private/enum.d.ts +6 -5
  30. package/lib/private/enum.js +5 -4
  31. package/lib/private/index.d.ts +97 -250
  32. package/lib/private/index.js +2 -0
  33. package/lib/private/is.d.ts +6 -3
  34. package/lib/private/normalize.js +2 -2
  35. package/lib/private/optional.d.ts +1 -1
  36. package/lib/private/path/next.d.ts +2 -1
  37. package/lib/private/path/next.js +4 -2
  38. package/lib/private/record.d.ts +9 -3
  39. package/lib/private/schema-errors.d.ts +1 -0
  40. package/lib/private/schema-errors.js +1 -0
  41. package/lib/private/spec/bigint.d.ts +3 -3
  42. package/lib/private/spec/biguint.d.ts +3 -3
  43. package/lib/private/spec/int.d.ts +3 -3
  44. package/lib/private/spec/uint.d.ts +3 -3
  45. package/lib/private/test.js +4 -3
  46. package/package.json +8 -8
@@ -1,4 +1,5 @@
1
1
  export type { default as ArrayType } from "#ArrayType";
2
+ export type { default as AsyncType } from "#AsyncType";
2
3
  export type { default as BlobType } from "#BlobType";
3
4
  export type { default as BooleanType } from "#BooleanType";
4
5
  export type { default as ConstructorType } from "#ConstructorType";
@@ -6,7 +7,7 @@ export type { default as DataKey } from "#DataKey";
6
7
  export type { default as DataType } from "#DataType";
7
8
  export type { default as DateType } from "#DateType";
8
9
  export type { default as DefaultType } from "#DefaultType";
9
- export type { default as EnumType } from "#EnumType";
10
+ export type { Enum, default as EnumType } from "#EnumType";
10
11
  export type { default as FunctionType } from "#FunctionType";
11
12
  export type { default as Id } from "#Id";
12
13
  export type { default as InferStore } from "#InferStore";
@@ -16,7 +17,7 @@ export type { default as IsType } from "#IsType";
16
17
  export type { default as JSONPayload } from "#json/JSONPayload";
17
18
  export type { default as JSONType } from "#JSONType";
18
19
  export type { default as LiteralType } from "#LiteralType";
19
- export type { default as NormalizeSchema, NormalizeSchemaObject, } from "#NormalizeSchema";
20
+ export type { default as NormalizeSchema, NormalizeSchemaObject } from "#NormalizeSchema";
20
21
  export type { default as NullType } from "#NullType";
21
22
  export type { default as NumberType } from "#NumberType";
22
23
  export type { default as ObjectType } from "#ObjectType";
@@ -40,6 +41,7 @@ export type { default as URLType } from "#URLType";
40
41
  export type { default as UUIDType } from "#UUIDType";
41
42
  export type { default as UUIDV4Type } from "#UUIDV4Type";
42
43
  export type { default as UUIDV7Type } from "#UUIDV7Type";
44
+ import async_schema from "#async";
43
45
  import type NormalizeSchema from "#NormalizeSchema";
44
46
  import type Schema from "#Schema";
45
47
  /**
@@ -47,262 +49,107 @@ import type Schema from "#Schema";
47
49
  */
48
50
  declare function schema<const S extends Schema>(s: S): NormalizeSchema<S>;
49
51
  declare namespace schema {
50
- var array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>>;
51
- }
52
- declare namespace schema {
53
- var bigint: import("./BigIntType.js").default<"i64", undefined>;
54
- }
55
- declare namespace schema {
56
- var biguint: import("./BigUintType.js").default<"u64", undefined>;
57
- }
58
- declare namespace schema {
59
- var blob: import("#BlobType").default;
60
- }
61
- declare namespace schema {
62
- var boolean: import("#BooleanType").default<undefined>;
63
- }
64
- declare namespace schema {
65
- var constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
66
- }
67
- declare namespace schema {
68
- var date: import("#DateType").default<undefined>;
69
- }
70
- declare namespace schema {
71
- var dict: {
52
+ var _a: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>>;
53
+ export { _a as array };
54
+ export { async_schema as async };
55
+ export var _b: import("./BigIntType.js").default<"i64", undefined>;
56
+ export { _b as bigint };
57
+ export var _c: import("./BigUintType.js").default<"u64", undefined>;
58
+ export { _c as biguint };
59
+ export var _d: import("#BlobType").default;
60
+ export { _d as blob };
61
+ export var _e: import("#BooleanType").default<undefined>;
62
+ export { _e as boolean };
63
+ export var _f: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
64
+ export { _f as constructor };
65
+ export var _g: import("#DateType").default<undefined>;
66
+ export { _g as date };
67
+ export var _h: {
72
68
  (): import("#RecordType").default<import("#StringType").default, import("#StringType").default>;
73
69
  <const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value>;
74
70
  };
75
- }
76
- declare namespace schema {
77
- var _a: <T extends readonly string[]>(values: T) => import("#EnumType").default<T>;
78
- export { _a as enum };
79
- }
80
- declare namespace schema {
81
- var f32: import("#NumberType").default<"f32", undefined>;
82
- }
83
- declare namespace schema {
84
- var f64: import("#NumberType").default<"f64", undefined>;
85
- }
86
- declare namespace schema {
87
- var file: import("./FileType.js").default;
88
- }
89
- declare namespace schema {
90
- var _b: import("#FunctionType").default;
91
- export { _b as function };
92
- }
93
- declare namespace schema {
94
- var i128: import("./BigIntType.js").default<"i128", undefined>;
95
- }
96
- declare namespace schema {
97
- var i16: import("./IntType.js").default<"i16", undefined>;
98
- }
99
- declare namespace schema {
100
- var i32: import("./IntType.js").default<"i32", undefined>;
101
- }
102
- declare namespace schema {
103
- var i64: import("./BigIntType.js").default<"i64", undefined>;
104
- }
105
- declare namespace schema {
106
- var i8: import("./IntType.js").default<"i8", undefined>;
107
- }
108
- declare namespace schema {
109
- var int: import("./IntType.js").default<"i32", undefined>;
110
- }
111
- declare namespace schema {
112
- var is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
113
- }
114
- declare namespace schema {
115
- var json: {
71
+ export { _h as dict };
72
+ export var _j: <const V extends import("@rcompat/type").Dict<number>>(values: V) => import("#EnumType").Enum<V, undefined>;
73
+ export { _j as enum };
74
+ export var _k: import("#NumberType").default<"f32", undefined>;
75
+ export { _k as f32 };
76
+ export var _l: import("#NumberType").default<"f64", undefined>;
77
+ export { _l as f64 };
78
+ export var _m: import("./FileType.js").default;
79
+ export { _m as file };
80
+ export var _o: import("#FunctionType").default;
81
+ export { _o as function };
82
+ export var _p: import("./BigIntType.js").default<"i128", undefined>;
83
+ export { _p as i128 };
84
+ export var _q: import("./IntType.js").default<"i16", undefined>;
85
+ export { _q as i16 };
86
+ export var _r: import("./IntType.js").default<"i32", undefined>;
87
+ export { _r as i32 };
88
+ export var _s: import("./BigIntType.js").default<"i64", undefined>;
89
+ export { _s as i64 };
90
+ export var _t: import("./IntType.js").default<"i8", undefined>;
91
+ export { _t as i8 };
92
+ export var _u: import("./IntType.js").default<"i32", undefined>;
93
+ export { _u as int };
94
+ export var _v: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
95
+ export { _v as is };
96
+ export var _w: {
116
97
  (): import("#JSONType").default<undefined>;
117
98
  <S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
118
99
  };
119
- }
120
- declare namespace schema {
121
- var literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, undefined>;
122
- }
123
- declare namespace schema {
124
- var _c: import("#NullType").default;
125
- export { _c as null };
126
- }
127
- declare namespace schema {
128
- var number: import("#NumberType").default<"f64", undefined>;
129
- }
130
- declare namespace schema {
131
- var 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]>; }>;
132
- }
133
- declare namespace schema {
134
- var 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>;
135
- }
136
- declare namespace schema {
137
- var record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value, undefined>;
138
- }
139
- declare namespace schema {
140
- var partial: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }>;
141
- }
142
- declare namespace schema {
143
- var pure: <T>() => import("#PureType").default<T, "PureType">;
144
- }
145
- declare namespace schema {
146
- var string: import("#StringType").default;
147
- }
148
- declare namespace schema {
149
- var symbol: import("./SymbolType.js").default;
150
- }
151
- declare namespace schema {
152
- var tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }>;
153
- }
154
- declare namespace schema {
155
- var u128: import("./BigUintType.js").default<"u128", undefined>;
156
- }
157
- declare namespace schema {
158
- var u16: import("#UintType").default<"u16", undefined>;
159
- }
160
- declare namespace schema {
161
- var u32: import("#UintType").default<"u32", undefined>;
162
- }
163
- declare namespace schema {
164
- var u64: import("./BigUintType.js").default<"u64", undefined>;
165
- }
166
- declare namespace schema {
167
- var u8: import("#UintType").default<"u8", undefined>;
168
- }
169
- declare namespace schema {
170
- var uint: import("#UintType").default<"u32", undefined>;
171
- }
172
- declare namespace schema {
173
- var undefined: import("#UndefinedType").default;
174
- }
175
- declare namespace schema {
176
- var union: {
100
+ export { _w as json };
101
+ export var _x: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, undefined>;
102
+ export { _x as literal };
103
+ export var _y: import("#NullType").default;
104
+ export { _y as null };
105
+ export var _z: import("#NumberType").default<"f64", undefined>;
106
+ export { _z as number };
107
+ export var _0: <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]>; }>;
108
+ export { _0 as object };
109
+ export var _1: <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>;
110
+ export { _1 as omit };
111
+ export var _2: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value, undefined>;
112
+ export { _2 as record };
113
+ export var _3: <const D extends import("./Partialable.js").default>(input: D | import("#ObjectType").default<D>) => import("#PartialType").default<{ -readonly [K in keyof D]: D[K]; }>;
114
+ export { _3 as partial };
115
+ export var _4: <T>() => import("#PureType").default<T, "PureType">;
116
+ export { _4 as pure };
117
+ export var _5: import("#StringType").default;
118
+ export { _5 as string };
119
+ export var _6: import("./SymbolType.js").default;
120
+ export { _6 as symbol };
121
+ export var _7: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }>;
122
+ export { _7 as tuple };
123
+ export var _8: import("./BigUintType.js").default<"u128", undefined>;
124
+ export { _8 as u128 };
125
+ export var _9: import("#UintType").default<"u16", undefined>;
126
+ export { _9 as u16 };
127
+ export var _10: import("#UintType").default<"u32", undefined>;
128
+ export { _10 as u32 };
129
+ export var _11: import("./BigUintType.js").default<"u64", undefined>;
130
+ export { _11 as u64 };
131
+ export var _12: import("#UintType").default<"u8", undefined>;
132
+ export { _12 as u8 };
133
+ export var _13: import("#UintType").default<"u32", undefined>;
134
+ export { _13 as uint };
135
+ export var _14: import("#UndefinedType").default;
136
+ export { _14 as undefined };
137
+ export var _15: {
177
138
  (): import("#UnionType").default<[]>;
178
139
  <const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }>;
179
140
  };
180
- }
181
- declare namespace schema {
182
- var unknown: import("#UnknownType").default;
183
- }
184
- declare namespace schema {
185
- var url: import("#URLType").default<undefined>;
186
- }
187
- declare namespace schema {
188
- var uuid: import("#UUIDType").default;
189
- }
190
- declare namespace schema {
191
- var error: (path: string, message: string) => import("./ParseError.js").default;
192
- }
193
- declare namespace schema {
194
- var loose: {
195
- <const S extends Schema>(s: S): NormalizeSchema<S>;
196
- array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>, true>;
197
- bigint: import("./BigIntType.js").default<"i64", true>;
198
- biguint: import("./BigUintType.js").default<"u64", true>;
199
- blob: import("#BlobType").default;
200
- boolean: import("#BooleanType").default<true>;
201
- constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
202
- date: import("#DateType").default<true>;
203
- dict: {
204
- (): import("#RecordType").default<import("#StringType").default, import("#StringType").default, true>;
205
- <const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value, true>;
206
- };
207
- enum: <T extends readonly string[]>(values: T) => import("#EnumType").default<T>;
208
- f32: import("#NumberType").default<"f32", true>;
209
- f64: import("#NumberType").default<"f64", true>;
210
- file: import("./FileType.js").default;
211
- function: import("#FunctionType").default;
212
- i128: import("./BigIntType.js").default<"i128", true>;
213
- i16: import("./IntType.js").default<"i16", true>;
214
- i32: import("./IntType.js").default<"i32", true>;
215
- i64: import("./BigIntType.js").default<"i64", true>;
216
- i8: import("./IntType.js").default<"i8", true>;
217
- int: import("./IntType.js").default<"i32", true>;
218
- is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
219
- json: {
220
- (): import("#JSONType").default<undefined>;
221
- <S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
222
- };
223
- literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, true>;
224
- null: import("#NullType").default;
225
- number: import("#NumberType").default<"f64", true>;
226
- 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>;
227
- 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>;
228
- 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>;
229
- 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>;
230
- pure: <T>() => import("#PureType").default<T, "PureType">;
231
- string: import("#StringType").default;
232
- symbol: import("./SymbolType.js").default;
233
- tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, true>;
234
- u128: import("./BigUintType.js").default<"u128", true>;
235
- u16: import("#UintType").default<"u16", true>;
236
- u32: import("#UintType").default<"u32", true>;
237
- u64: import("./BigUintType.js").default<"u64", true>;
238
- u8: import("#UintType").default<"u8", true>;
239
- uint: import("#UintType").default<"u32", true>;
240
- undefined: import("#UndefinedType").default;
241
- union: {
242
- (): import("#UnionType").default<[], true>;
243
- <const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, true>;
244
- };
245
- unknown: import("#UnknownType").default;
246
- url: import("#URLType").default<true>;
247
- uuid: import("#UUIDType").default;
248
- };
249
- }
250
- declare namespace schema {
251
- var strict: {
252
- <const S extends Schema>(s: S): NormalizeSchema<S>;
253
- array: <const S extends Schema>(of: S) => import("#ArrayType").default<NormalizeSchema<S>, false>;
254
- bigint: import("./BigIntType.js").default<"i64", false>;
255
- biguint: import("./BigUintType.js").default<"u64", false>;
256
- blob: import("#BlobType").default;
257
- boolean: import("#BooleanType").default<false>;
258
- constructor: <const C extends import("@rcompat/type").AbstractNewable>(c: C) => import("#ConstructorType").default<C>;
259
- date: import("#DateType").default<false>;
260
- dict: {
261
- (): import("#RecordType").default<import("#StringType").default, import("#StringType").default, false>;
262
- <const Value extends import("#Parsed").default<unknown>>(of: Value): import("#RecordType").default<import("#StringType").default, Value, false>;
263
- };
264
- enum: <T extends readonly string[]>(values: T) => import("#EnumType").default<T>;
265
- f32: import("#NumberType").default<"f32", false>;
266
- f64: import("#NumberType").default<"f64", false>;
267
- file: import("./FileType.js").default;
268
- function: import("#FunctionType").default;
269
- i128: import("./BigIntType.js").default<"i128", false>;
270
- i16: import("./IntType.js").default<"i16", false>;
271
- i32: import("./IntType.js").default<"i32", false>;
272
- i64: import("./BigIntType.js").default<"i64", false>;
273
- i8: import("./IntType.js").default<"i8", false>;
274
- int: import("./IntType.js").default<"i32", false>;
275
- is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
276
- json: {
277
- (): import("#JSONType").default<undefined>;
278
- <S extends import("#JSONType").ParsedJSON>(inner: S): import("#JSONType").default<S>;
279
- };
280
- literal: <T extends string | number | boolean>(literal: T) => import("#LiteralType").default<T, false>;
281
- null: import("#NullType").default;
282
- number: import("#NumberType").default<"f64", false>;
283
- 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>;
284
- 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>;
285
- 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>;
286
- 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>;
287
- pure: <T>() => import("#PureType").default<T, "PureType">;
288
- string: import("#StringType").default;
289
- symbol: import("./SymbolType.js").default;
290
- tuple: <const T extends Schema[]>(...items: T) => import("#TupleType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, false>;
291
- u128: import("./BigUintType.js").default<"u128", false>;
292
- u16: import("#UintType").default<"u16", false>;
293
- u32: import("#UintType").default<"u32", false>;
294
- u64: import("./BigUintType.js").default<"u64", false>;
295
- u8: import("#UintType").default<"u8", false>;
296
- uint: import("#UintType").default<"u32", false>;
297
- undefined: import("#UndefinedType").default;
298
- union: {
299
- (): import("#UnionType").default<[], false>;
300
- <const T extends Schema[]>(...types: T): import("#UnionType").default<{ [K in keyof T]: NormalizeSchema<T[K]>; }, false>;
301
- };
302
- unknown: import("#UnknownType").default;
303
- url: import("#URLType").default<false>;
304
- uuid: import("#UUIDType").default;
305
- };
306
- }
141
+ export { _15 as union };
142
+ export var _16: import("#UnknownType").default;
143
+ export { _16 as unknown };
144
+ export var _17: import("#URLType").default<undefined>;
145
+ export { _17 as url };
146
+ export var _18: import("#UUIDType").default;
147
+ export { _18 as uuid };
148
+ export var error: (path: string, message: string) => import("./ParseError.js").default;
149
+ export { loose };
150
+ export { strict };
151
+ }
152
+ declare function loose<const S extends Schema>(s: S): NormalizeSchema<S>;
153
+ declare function strict<const S extends Schema>(s: S): NormalizeSchema<S>;
307
154
  export default schema;
308
155
  //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import E from "#errors";
2
2
  import array from "#array";
3
+ import async_schema from "#async";
3
4
  import bigint from "#bigint";
4
5
  import biguint from "#biguint";
5
6
  import blob from "#blob";
@@ -61,6 +62,7 @@ function strict(s) {
61
62
  return i;
62
63
  }
63
64
  schema.array = array.vanilla;
65
+ schema.async = async_schema;
64
66
  schema.bigint = bigint.vanilla;
65
67
  schema.biguint = biguint.vanilla;
66
68
  schema.blob = blob.vanilla;
@@ -1,8 +1,11 @@
1
1
  import IsType from "#IsType";
2
+ declare const vanilla: <T>(predicate: (x: unknown) => x is T) => IsType<T>;
3
+ declare const loose: <T>(predicate: (x: unknown) => x is T) => IsType<T>;
4
+ declare const strict: <T>(predicate: (x: unknown) => x is T) => IsType<T>;
2
5
  declare const is: {
3
- vanilla: <T>(predicate: (x: unknown) => x is T) => IsType<T>;
4
- loose: <T>(predicate: (x: unknown) => x is T) => IsType<T>;
5
- strict: <T>(predicate: (x: unknown) => x is T) => IsType<T>;
6
+ vanilla: typeof vanilla;
7
+ loose: typeof loose;
8
+ strict: typeof strict;
6
9
  };
7
10
  export default is;
8
11
  //# sourceMappingURL=is.d.ts.map
@@ -10,9 +10,9 @@ import is from "@rcompat/is";
10
10
  export default function normalize(x) {
11
11
  if (is_parsed(x))
12
12
  return x;
13
- if (x === null)
13
+ if (is.null(x))
14
14
  return new NullType();
15
- if (x === undefined)
15
+ if (is.undefined(x))
16
16
  return new UndefinedType();
17
17
  if (is.string(x) || is.number(x) || is.boolean(x))
18
18
  return new LiteralType(x);
@@ -1,5 +1,5 @@
1
1
  import OptionalType from "#OptionalType";
2
2
  import type Parsed from "#Parsed";
3
- declare const _default: <const T extends Parsed<unknown>>(type: T) => OptionalType<T>;
4
3
  export default _default;
4
+ declare function _default<const T extends Parsed<unknown>>(type: T): OptionalType<T>;
5
5
  //# sourceMappingURL=optional.d.ts.map
@@ -1,3 +1,4 @@
1
1
  import type ParseOptions from "#ParseOptions";
2
- export default function next(s: number | string, options?: ParseOptions): ParseOptions;
2
+ declare function next(s: number | string, options?: ParseOptions): ParseOptions;
3
+ export default next;
3
4
  //# sourceMappingURL=next.d.ts.map
@@ -1,9 +1,11 @@
1
1
  import ParsedKey from "#ParsedKey";
2
2
  import join from "#path/join";
3
- export default function next(s, options) {
3
+ import is from "@rcompat/is";
4
+ function next(s, options) {
4
5
  const base = options?.[ParsedKey] ?? "";
5
- return options === undefined
6
+ return is.undefined(options)
6
7
  ? { [ParsedKey]: join("", String(s)) }
7
8
  : { ...options, [ParsedKey]: join(base, String(s)) };
8
9
  }
10
+ export default next;
9
11
  //# sourceMappingURL=next.js.map
@@ -1,10 +1,16 @@
1
1
  import type Parsed from "#Parsed";
2
2
  import RecordType from "#RecordType";
3
3
  import type RecordTypeKey from "#RecordTypeKey";
4
+ /**
5
+ * Value is a record of the given key and value types.
6
+ */
7
+ declare const vanilla: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, undefined>;
8
+ declare const loose: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, true>;
9
+ declare const strict: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, false>;
4
10
  declare const record: {
5
- vanilla: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, undefined>;
6
- loose: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, true>;
7
- strict: <const Key extends RecordTypeKey, const Value extends Parsed<unknown>>(k: Key, v: Value) => RecordType<Key, Value, false>;
11
+ vanilla: typeof vanilla;
12
+ loose: typeof loose;
13
+ strict: typeof strict;
8
14
  };
9
15
  export default record;
10
16
  //# sourceMappingURL=record.d.ts.map
@@ -9,6 +9,7 @@ declare const errors: {
9
9
  max_limit_not_finite: (limit: number) => import("@rcompat/error").TemplateError;
10
10
  extend_key_collision: (key: string) => import("@rcompat/error").TemplateError;
11
11
  union_at_least_two_members: () => import("@rcompat/error").TemplateError;
12
+ enum_invalid_key: (key: string) => import("@rcompat/error").TemplateError;
12
13
  };
13
14
  export type Code = keyof typeof errors;
14
15
  export declare const Code: { [K in Code]: K; };
@@ -11,6 +11,7 @@ const errors = error.coded({
11
11
  max_limit_not_finite: (limit) => t `max: limit ${limit} must be a finite number`,
12
12
  extend_key_collision: (key) => t `extend: key ${key} already exists and cannot be overridden`,
13
13
  union_at_least_two_members: () => t `union type must have at least two members`,
14
+ enum_invalid_key: (key) => t `enum: key ${key} must be SCREAMING_SNAKE_CASE`,
14
15
  });
15
16
  export const Code = Object.fromEntries(Object.keys(errors).map(k => [k, k]));
16
17
  export default errors;
@@ -1,9 +1,9 @@
1
1
  import type BigIntDataType from "#BigIntDataType";
2
2
  import type BigIntType from "#BigIntType";
3
- declare const _default: <T extends BigIntDataType>(t: {
3
+ export default _default;
4
+ declare function _default<T extends BigIntDataType>(t: {
4
5
  vanilla: BigIntType<T>;
5
6
  loose: BigIntType<T, true>;
6
7
  strict: BigIntType<T, false>;
7
- }, min: bigint, max: bigint) => void;
8
- export default _default;
8
+ }, min: bigint, max: bigint): void;
9
9
  //# sourceMappingURL=bigint.d.ts.map
@@ -1,9 +1,9 @@
1
1
  import type BigUintDataType from "#BigUintDataType";
2
2
  import type BigUintType from "#BigUintType";
3
- declare const _default: <T extends BigUintDataType>(t: {
3
+ export default _default;
4
+ declare function _default<T extends BigUintDataType>(t: {
4
5
  vanilla: BigUintType<T>;
5
6
  loose: BigUintType<T, true>;
6
7
  strict: BigUintType<T, false>;
7
- }, min: bigint, max: bigint) => void;
8
- export default _default;
8
+ }, min: bigint, max: bigint): void;
9
9
  //# sourceMappingURL=biguint.d.ts.map
@@ -1,9 +1,9 @@
1
1
  import type IntDataType from "#IntDataType";
2
2
  import type IntType from "#IntType";
3
- declare const _default: <T extends IntDataType>(t: {
3
+ export default _default;
4
+ declare function _default<T extends IntDataType>(t: {
4
5
  vanilla: IntType<T>;
5
6
  loose: IntType<T, true>;
6
7
  strict: IntType<T, false>;
7
- }, min: number, max: number) => void;
8
- export default _default;
8
+ }, min: number, max: number): void;
9
9
  //# sourceMappingURL=int.d.ts.map
@@ -1,9 +1,9 @@
1
1
  import type UintDataType from "#UintDataType";
2
2
  import type UintType from "#UintType";
3
- declare const _default: <T extends UintDataType>(t: {
3
+ export default _default;
4
+ declare function _default<T extends UintDataType>(t: {
4
5
  vanilla: UintType<T>;
5
6
  loose: UintType<T, true>;
6
7
  strict: UintType<T, false>;
7
- }, min: number, max: number) => void;
8
- export default _default;
8
+ }, min: number, max: number): void;
9
9
  //# sourceMappingURL=uint.d.ts.map
@@ -1,4 +1,5 @@
1
1
  import ParseError from "#ParseError";
2
+ import is from "@rcompat/is";
2
3
  import test from "@rcompat/test";
3
4
  const issue_types = [
4
5
  "invalid_type",
@@ -20,7 +21,7 @@ export default test.extend((assert, subject) => {
20
21
  if (ParseError.is(e)) {
21
22
  const issue = e.issues[0];
22
23
  assert(issue.type).equals(type);
23
- if (path !== undefined)
24
+ if (is.defined(path))
24
25
  assert(issue.path).equals(path);
25
26
  }
26
27
  else {
@@ -44,10 +45,10 @@ export default test.extend((assert, subject) => {
44
45
  assert(e.issues.length).equals(matchers.length);
45
46
  for (let i = 0; i < matchers.length; i++) {
46
47
  assert(e.issues[i].type).equals(matchers[i].type);
47
- if (matchers[i].path !== undefined) {
48
+ if (is.defined(matchers[i].path)) {
48
49
  assert(e.issues[i].path).equals(matchers[i].path);
49
50
  }
50
- if (matchers[i].message !== undefined) {
51
+ if (is.defined(matchers[i].message)) {
51
52
  assert(e.issues[i].message).equals(matchers[i].message);
52
53
  }
53
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pema",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Primate schema validation",
5
5
  "homepage": "https://primate.run/docs/validation",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",
@@ -17,14 +17,14 @@
17
17
  "!/**/*.spec.*"
18
18
  ],
19
19
  "dependencies": {
20
- "@rcompat/assert": "^0.13.0",
21
- "@rcompat/cli": "^0.24.0",
22
- "@rcompat/error": "^0.8.0",
23
- "@rcompat/is": "^0.11.0",
24
- "@rcompat/symbol": "^0.2.0"
20
+ "@rcompat/assert": "^0.14.0",
21
+ "@rcompat/cli": "^0.25.0",
22
+ "@rcompat/error": "^0.9.0",
23
+ "@rcompat/is": "^0.12.0",
24
+ "@rcompat/symbol": "^0.3.0"
25
25
  },
26
26
  "devDependencies": {
27
- "@rcompat/type": "^0.17.0"
27
+ "@rcompat/type": "^0.18.0"
28
28
  },
29
29
  "imports": {
30
30
  "#*": {
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "scripts": {
46
- "build": "npm run clean && tsgo",
46
+ "build": "npm run clean && tsc",
47
47
  "clean": "rm -rf ./lib",
48
48
  "lint": "eslint .",
49
49
  "lint:fix": "eslint . --fix",