@atproto/lex-schema 0.0.4 → 0.0.6
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/CHANGELOG.md +58 -0
- package/dist/core/$type.d.ts +7 -0
- package/dist/core/$type.d.ts.map +1 -1
- package/dist/core/$type.js.map +1 -1
- package/dist/core/property-key.d.ts.map +1 -0
- package/dist/core/property-key.js.map +1 -0
- package/dist/core/result.d.ts +7 -6
- package/dist/core/result.d.ts.map +1 -1
- package/dist/core/result.js +9 -8
- package/dist/core/result.js.map +1 -1
- package/dist/{validation → core}/schema.d.ts +21 -2
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/{validation → core}/schema.js +25 -2
- package/dist/core/schema.js.map +1 -0
- package/dist/core/string-format.d.ts +37 -26
- package/dist/core/string-format.d.ts.map +1 -1
- package/dist/core/string-format.js +66 -59
- package/dist/core/string-format.js.map +1 -1
- package/dist/core/types.d.ts +3 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/core/validation-error.d.ts +19 -0
- package/dist/core/validation-error.d.ts.map +1 -0
- package/dist/{validation → core}/validation-error.js +13 -6
- package/dist/core/validation-error.js.map +1 -0
- package/dist/{validation → core}/validation-issue.d.ts +43 -0
- package/dist/core/validation-issue.d.ts.map +1 -0
- package/dist/{validation → core}/validation-issue.js +55 -2
- package/dist/core/validation-issue.js.map +1 -0
- package/dist/{validation → core}/validator.d.ts +5 -4
- package/dist/core/validator.d.ts.map +1 -0
- package/dist/{validation → core}/validator.js +16 -13
- package/dist/core/validator.js.map +1 -0
- package/dist/core.d.ts +5 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/core.js +5 -0
- package/dist/core.js.map +1 -1
- package/dist/external.d.ts +21 -21
- package/dist/external.d.ts.map +1 -1
- package/dist/external.js +39 -55
- package/dist/external.js.map +1 -1
- package/dist/helpers.d.ts +41 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +13 -0
- package/dist/helpers.js.map +1 -0
- package/dist/schema/_parameters.d.ts +1 -1
- package/dist/schema/_parameters.d.ts.map +1 -1
- package/dist/schema/_parameters.js.map +1 -1
- package/dist/schema/array.d.ts +1 -1
- package/dist/schema/array.d.ts.map +1 -1
- package/dist/schema/array.js +2 -2
- package/dist/schema/array.js.map +1 -1
- package/dist/schema/blob.d.ts +2 -1
- package/dist/schema/blob.d.ts.map +1 -1
- package/dist/schema/blob.js +34 -20
- package/dist/schema/blob.js.map +1 -1
- package/dist/schema/boolean.d.ts +1 -1
- package/dist/schema/boolean.d.ts.map +1 -1
- package/dist/schema/boolean.js +2 -2
- package/dist/schema/boolean.js.map +1 -1
- package/dist/schema/bytes.d.ts +1 -1
- package/dist/schema/bytes.d.ts.map +1 -1
- package/dist/schema/bytes.js +2 -2
- package/dist/schema/bytes.js.map +1 -1
- package/dist/schema/cid.d.ts +1 -1
- package/dist/schema/cid.d.ts.map +1 -1
- package/dist/schema/cid.js +2 -2
- package/dist/schema/cid.js.map +1 -1
- package/dist/schema/custom.d.ts +1 -1
- package/dist/schema/custom.d.ts.map +1 -1
- package/dist/schema/custom.js +3 -3
- package/dist/schema/custom.js.map +1 -1
- package/dist/schema/dict.d.ts +1 -1
- package/dist/schema/dict.d.ts.map +1 -1
- package/dist/schema/dict.js +2 -2
- package/dist/schema/dict.js.map +1 -1
- package/dist/schema/discriminated-union.d.ts +1 -1
- package/dist/schema/discriminated-union.d.ts.map +1 -1
- package/dist/schema/discriminated-union.js +2 -2
- package/dist/schema/discriminated-union.js.map +1 -1
- package/dist/schema/enum.d.ts +1 -1
- package/dist/schema/enum.d.ts.map +1 -1
- package/dist/schema/enum.js +2 -2
- package/dist/schema/enum.js.map +1 -1
- package/dist/schema/integer.d.ts +1 -1
- package/dist/schema/integer.d.ts.map +1 -1
- package/dist/schema/integer.js +4 -4
- package/dist/schema/integer.js.map +1 -1
- package/dist/schema/intersection.d.ts +1 -2
- package/dist/schema/intersection.d.ts.map +1 -1
- package/dist/schema/intersection.js +2 -2
- package/dist/schema/intersection.js.map +1 -1
- package/dist/schema/literal.d.ts +1 -1
- package/dist/schema/literal.d.ts.map +1 -1
- package/dist/schema/literal.js +2 -2
- package/dist/schema/literal.js.map +1 -1
- package/dist/schema/never.d.ts +1 -1
- package/dist/schema/never.d.ts.map +1 -1
- package/dist/schema/never.js +2 -2
- package/dist/schema/never.js.map +1 -1
- package/dist/schema/null.d.ts +1 -1
- package/dist/schema/null.d.ts.map +1 -1
- package/dist/schema/null.js +2 -2
- package/dist/schema/null.js.map +1 -1
- package/dist/schema/nullable.d.ts +1 -1
- package/dist/schema/nullable.d.ts.map +1 -1
- package/dist/schema/nullable.js +2 -2
- package/dist/schema/nullable.js.map +1 -1
- package/dist/schema/object.d.ts +1 -2
- package/dist/schema/object.d.ts.map +1 -1
- package/dist/schema/object.js +2 -2
- package/dist/schema/object.js.map +1 -1
- package/dist/schema/optional.d.ts +1 -1
- package/dist/schema/optional.d.ts.map +1 -1
- package/dist/schema/optional.js +2 -2
- package/dist/schema/optional.js.map +1 -1
- package/dist/schema/params.d.ts +1 -3
- package/dist/schema/params.d.ts.map +1 -1
- package/dist/schema/params.js +2 -2
- package/dist/schema/params.js.map +1 -1
- package/dist/schema/payload.d.ts +17 -15
- package/dist/schema/payload.d.ts.map +1 -1
- package/dist/schema/payload.js +28 -0
- package/dist/schema/payload.js.map +1 -1
- package/dist/schema/procedure.d.ts +3 -6
- package/dist/schema/procedure.d.ts.map +1 -1
- package/dist/schema/procedure.js +1 -0
- package/dist/schema/procedure.js.map +1 -1
- package/dist/schema/query.d.ts +3 -5
- package/dist/schema/query.d.ts.map +1 -1
- package/dist/schema/query.js +1 -0
- package/dist/schema/query.js.map +1 -1
- package/dist/schema/record.d.ts +14 -14
- package/dist/schema/record.d.ts.map +1 -1
- package/dist/schema/record.js +2 -2
- package/dist/schema/record.js.map +1 -1
- package/dist/schema/ref.d.ts +1 -1
- package/dist/schema/ref.d.ts.map +1 -1
- package/dist/schema/ref.js +2 -2
- package/dist/schema/ref.js.map +1 -1
- package/dist/schema/refine.d.ts +18 -1
- package/dist/schema/refine.d.ts.map +1 -1
- package/dist/schema/refine.js +2 -2
- package/dist/schema/refine.js.map +1 -1
- package/dist/schema/regexp.d.ts +1 -1
- package/dist/schema/regexp.d.ts.map +1 -1
- package/dist/schema/regexp.js +2 -2
- package/dist/schema/regexp.js.map +1 -1
- package/dist/schema/string.d.ts +1 -2
- package/dist/schema/string.d.ts.map +1 -1
- package/dist/schema/string.js +1 -2
- package/dist/schema/string.js.map +1 -1
- package/dist/schema/subscription.d.ts +4 -8
- package/dist/schema/subscription.d.ts.map +1 -1
- package/dist/schema/subscription.js.map +1 -1
- package/dist/schema/token.d.ts +1 -1
- package/dist/schema/token.d.ts.map +1 -1
- package/dist/schema/token.js +2 -2
- package/dist/schema/token.js.map +1 -1
- package/dist/schema/typed-object.d.ts +8 -8
- package/dist/schema/typed-object.d.ts.map +1 -1
- package/dist/schema/typed-object.js +2 -2
- package/dist/schema/typed-object.js.map +1 -1
- package/dist/schema/typed-ref.d.ts +1 -1
- package/dist/schema/typed-ref.d.ts.map +1 -1
- package/dist/schema/typed-ref.js +2 -2
- package/dist/schema/typed-ref.js.map +1 -1
- package/dist/schema/typed-union.d.ts +2 -3
- package/dist/schema/typed-union.d.ts.map +1 -1
- package/dist/schema/typed-union.js +2 -2
- package/dist/schema/typed-union.js.map +1 -1
- package/dist/schema/union.d.ts +1 -1
- package/dist/schema/union.d.ts.map +1 -1
- package/dist/schema/union.js +3 -6
- package/dist/schema/union.js.map +1 -1
- package/dist/schema/unknown-object.d.ts +1 -2
- package/dist/schema/unknown-object.d.ts.map +1 -1
- package/dist/schema/unknown-object.js +2 -2
- package/dist/schema/unknown-object.js.map +1 -1
- package/dist/schema/unknown.d.ts +1 -1
- package/dist/schema/unknown.d.ts.map +1 -1
- package/dist/schema/unknown.js +2 -2
- package/dist/schema/unknown.js.map +1 -1
- package/dist/util/assertion-util.d.ts +8 -0
- package/dist/util/assertion-util.d.ts.map +1 -0
- package/dist/util/assertion-util.js +31 -0
- package/dist/util/assertion-util.js.map +1 -0
- package/dist/util/memoize.d.ts +3 -0
- package/dist/util/memoize.d.ts.map +1 -0
- package/dist/util/memoize.js +52 -0
- package/dist/util/memoize.js.map +1 -0
- package/package.json +6 -6
- package/src/core/$type.ts +4 -0
- package/src/core/result.ts +9 -8
- package/src/{validation → core}/schema.ts +29 -4
- package/src/core/string-format.ts +88 -68
- package/src/core/types.ts +4 -0
- package/src/{validation → core}/validation-error.ts +14 -6
- package/src/{validation → core}/validation-issue.ts +64 -2
- package/src/{validation → core}/validator.ts +17 -13
- package/src/core.ts +5 -0
- package/src/external.ts +75 -55
- package/src/helpers.test.ts +487 -0
- package/src/helpers.ts +75 -0
- package/src/schema/_parameters.test.ts +1 -0
- package/src/schema/_parameters.ts +1 -1
- package/src/schema/array.test.ts +1 -0
- package/src/schema/array.ts +1 -1
- package/src/schema/blob.test.ts +3 -4
- package/src/schema/blob.ts +32 -24
- package/src/schema/boolean.test.ts +1 -0
- package/src/schema/boolean.ts +1 -1
- package/src/schema/bytes.test.ts +1 -0
- package/src/schema/bytes.ts +1 -1
- package/src/schema/cid.test.ts +1 -0
- package/src/schema/cid.ts +1 -1
- package/src/schema/custom.test.ts +8 -7
- package/src/schema/custom.ts +2 -2
- package/src/schema/dict.test.ts +1 -0
- package/src/schema/dict.ts +1 -1
- package/src/schema/discriminated-union.test.ts +1 -0
- package/src/schema/discriminated-union.ts +1 -1
- package/src/schema/enum.test.ts +1 -0
- package/src/schema/enum.ts +1 -1
- package/src/schema/integer.test.ts +1 -0
- package/src/schema/integer.ts +3 -3
- package/src/schema/intersection.test.ts +1 -0
- package/src/schema/intersection.ts +2 -2
- package/src/schema/literal.test.ts +1 -0
- package/src/schema/literal.ts +1 -1
- package/src/schema/never.test.ts +1 -0
- package/src/schema/never.ts +1 -1
- package/src/schema/null.test.ts +1 -0
- package/src/schema/null.ts +1 -1
- package/src/schema/nullable.test.ts +1 -0
- package/src/schema/nullable.ts +1 -1
- package/src/schema/object.test.ts +1 -0
- package/src/schema/object.ts +3 -3
- package/src/schema/optional.test.ts +1 -0
- package/src/schema/optional.ts +1 -1
- package/src/schema/params.test.ts +1 -0
- package/src/schema/params.ts +3 -10
- package/src/schema/payload.test.ts +1 -0
- package/src/schema/payload.ts +67 -34
- package/src/schema/permission-set.test.ts +37 -36
- package/src/schema/permission.test.ts +1 -0
- package/src/schema/procedure.test.ts +2 -62
- package/src/schema/procedure.ts +8 -20
- package/src/schema/query.test.ts +23 -69
- package/src/schema/query.ts +7 -14
- package/src/schema/record.test.ts +1 -0
- package/src/schema/record.ts +13 -6
- package/src/schema/ref.test.ts +2 -1
- package/src/schema/ref.ts +1 -1
- package/src/schema/refine.test.ts +1 -0
- package/src/schema/refine.ts +19 -2
- package/src/schema/regexp.test.ts +1 -0
- package/src/schema/regexp.ts +1 -1
- package/src/schema/string.test.ts +1 -0
- package/src/schema/string.ts +8 -2
- package/src/schema/subscription.test.ts +31 -93
- package/src/schema/subscription.ts +11 -25
- package/src/schema/token.test.ts +1 -0
- package/src/schema/token.ts +1 -1
- package/src/schema/typed-object.test.ts +1 -0
- package/src/schema/typed-object.ts +10 -5
- package/src/schema/typed-ref.test.ts +1 -0
- package/src/schema/typed-ref.ts +1 -1
- package/src/schema/typed-union.test.ts +1 -0
- package/src/schema/typed-union.ts +4 -4
- package/src/schema/union.test.ts +1 -0
- package/src/schema/union.ts +2 -5
- package/src/schema/unknown-object.test.ts +1 -0
- package/src/schema/unknown-object.ts +1 -2
- package/src/schema/unknown.test.ts +1 -0
- package/src/schema/unknown.ts +1 -1
- package/src/util/array-agg.test.ts +1 -0
- package/src/util/assertion-util.ts +40 -0
- package/src/util/memoize.ts +57 -0
- package/tsconfig.tests.json +2 -2
- package/dist/validation/property-key.d.ts.map +0 -1
- package/dist/validation/property-key.js.map +0 -1
- package/dist/validation/schema.d.ts.map +0 -1
- package/dist/validation/schema.js.map +0 -1
- package/dist/validation/validation-error.d.ts +0 -9
- package/dist/validation/validation-error.d.ts.map +0 -1
- package/dist/validation/validation-error.js.map +0 -1
- package/dist/validation/validation-issue.d.ts.map +0 -1
- package/dist/validation/validation-issue.js.map +0 -1
- package/dist/validation/validator.d.ts.map +0 -1
- package/dist/validation/validator.js.map +0 -1
- package/dist/validation.d.ts +0 -6
- package/dist/validation.d.ts.map +0 -1
- package/dist/validation.js +0 -9
- package/dist/validation.js.map +0 -1
- package/src/validation.ts +0 -5
- /package/dist/{validation → core}/property-key.d.ts +0 -0
- /package/dist/{validation → core}/property-key.js +0 -0
- /package/src/{validation → core}/property-key.ts +0 -0
package/src/core.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export * from './core/$type.js'
|
|
2
|
+
export * from './core/property-key.js'
|
|
2
3
|
export * from './core/record-key.js'
|
|
3
4
|
export * from './core/result.js'
|
|
5
|
+
export * from './core/schema.js'
|
|
4
6
|
export * from './core/string-format.js'
|
|
5
7
|
export * from './core/types.js'
|
|
8
|
+
export * from './core/validation-error.js'
|
|
9
|
+
export * from './core/validation-issue.js'
|
|
10
|
+
export * from './core/validator.js'
|
package/src/external.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
$Type,
|
|
3
|
+
$TypeOf,
|
|
4
|
+
$type,
|
|
5
|
+
Infer,
|
|
6
|
+
LexiconRecordKey,
|
|
7
|
+
NsidString,
|
|
8
|
+
PropertyKey,
|
|
9
|
+
Schema,
|
|
10
|
+
Validator,
|
|
11
|
+
} from './core.js'
|
|
2
12
|
import {
|
|
3
13
|
ArraySchema,
|
|
4
14
|
ArraySchemaOptions,
|
|
@@ -31,7 +41,7 @@ import {
|
|
|
31
41
|
ParamsSchema,
|
|
32
42
|
ParamsSchemaShape,
|
|
33
43
|
Payload,
|
|
34
|
-
|
|
44
|
+
PayloadSchema,
|
|
35
45
|
Permission,
|
|
36
46
|
PermissionOptions,
|
|
37
47
|
PermissionSet,
|
|
@@ -57,28 +67,25 @@ import {
|
|
|
57
67
|
UnknownSchema,
|
|
58
68
|
refine,
|
|
59
69
|
} from './schema.js'
|
|
60
|
-
import {
|
|
70
|
+
import { memoizedOptions, memoizedTransformer } from './util/memoize.js'
|
|
61
71
|
|
|
62
72
|
export * from './core.js'
|
|
73
|
+
export * from './helpers.js'
|
|
63
74
|
export * from './schema.js'
|
|
64
|
-
export * from './validation.js'
|
|
65
75
|
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
export { _null as null }
|
|
77
|
+
|
|
78
|
+
export const never = /*#__PURE__*/ memoizedOptions(function () {
|
|
68
79
|
return new NeverSchema()
|
|
69
|
-
}
|
|
80
|
+
})
|
|
70
81
|
|
|
71
|
-
|
|
72
|
-
export function unknown() {
|
|
82
|
+
export const unknown = /*#__PURE__*/ memoizedOptions(function () {
|
|
73
83
|
return new UnknownSchema()
|
|
74
|
-
}
|
|
84
|
+
})
|
|
75
85
|
|
|
76
|
-
|
|
77
|
-
export function _null() {
|
|
86
|
+
const _null = /*#__PURE__*/ memoizedOptions(function () {
|
|
78
87
|
return new NullSchema()
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export { _null as null }
|
|
88
|
+
})
|
|
82
89
|
|
|
83
90
|
/*@__NO_SIDE_EFFECTS__*/
|
|
84
91
|
export function literal<const V extends null | string | number | boolean>(
|
|
@@ -99,39 +106,45 @@ export function _enum<const V extends null | string | number | boolean>(
|
|
|
99
106
|
// @NOTE "enum" is a reserved keyword in JS/TS
|
|
100
107
|
export { _enum as enum }
|
|
101
108
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
+
export const boolean = /*#__PURE__*/ memoizedOptions(
|
|
110
|
+
function (options?: BooleanSchemaOptions) {
|
|
111
|
+
return new BooleanSchema(options)
|
|
112
|
+
},
|
|
113
|
+
(options) => {
|
|
114
|
+
const keys = Object.keys(options)
|
|
115
|
+
if (keys.length === 1 && keys[0] === 'default') return options.default!
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
export const integer = /*#__PURE__*/ memoizedOptions(function (
|
|
120
|
+
options?: IntegerSchemaOptions,
|
|
121
|
+
) {
|
|
109
122
|
return new IntegerSchema(options)
|
|
110
|
-
}
|
|
123
|
+
})
|
|
111
124
|
|
|
112
|
-
|
|
113
|
-
|
|
125
|
+
export const cidLink = /*#__PURE__*/ memoizedOptions(function (
|
|
126
|
+
options?: CidSchemaOptions,
|
|
127
|
+
) {
|
|
114
128
|
return new CidSchema(options)
|
|
115
|
-
}
|
|
129
|
+
})
|
|
116
130
|
|
|
117
|
-
|
|
118
|
-
|
|
131
|
+
export const bytes = /*#__PURE__*/ memoizedOptions(function (
|
|
132
|
+
options?: BytesSchemaOptions,
|
|
133
|
+
) {
|
|
119
134
|
return new BytesSchema(options)
|
|
120
|
-
}
|
|
135
|
+
})
|
|
121
136
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
) {
|
|
137
|
+
export const blob = /*#__PURE__*/ memoizedOptions(function <
|
|
138
|
+
O extends BlobSchemaOptions = NonNullable<unknown>,
|
|
139
|
+
>(options: O = {} as O) {
|
|
126
140
|
return new BlobSchema(options)
|
|
127
|
-
}
|
|
141
|
+
})
|
|
128
142
|
|
|
129
|
-
|
|
130
|
-
export function string<
|
|
143
|
+
export const string = /*#__PURE__*/ memoizedOptions(function <
|
|
131
144
|
const O extends StringSchemaOptions = NonNullable<unknown>,
|
|
132
145
|
>(options: StringSchemaOptions & O = {} as O) {
|
|
133
146
|
return new StringSchema<O>(options)
|
|
134
|
-
}
|
|
147
|
+
})
|
|
135
148
|
|
|
136
149
|
/*@__NO_SIDE_EFFECTS__*/
|
|
137
150
|
export function regexp<T extends string = string>(pattern: RegExp) {
|
|
@@ -170,10 +183,9 @@ export function dict<
|
|
|
170
183
|
// Utility
|
|
171
184
|
export type { UnknownObjectOutput as UnknownObject }
|
|
172
185
|
|
|
173
|
-
|
|
174
|
-
export function unknownObject() {
|
|
186
|
+
export const unknownObject = /*#__PURE__*/ memoizedOptions(function () {
|
|
175
187
|
return new UnknownObjectSchema()
|
|
176
|
-
}
|
|
188
|
+
})
|
|
177
189
|
|
|
178
190
|
/*@__NO_SIDE_EFFECTS__*/
|
|
179
191
|
export function ref<T>(get: RefSchemaGetter<T>) {
|
|
@@ -189,15 +201,17 @@ export function custom<T>(
|
|
|
189
201
|
return new CustomSchema<T>(assertion, message, path)
|
|
190
202
|
}
|
|
191
203
|
|
|
192
|
-
|
|
193
|
-
|
|
204
|
+
export const nullable = /*#__PURE__*/ memoizedTransformer(function <
|
|
205
|
+
const S extends Validator,
|
|
206
|
+
>(schema: S) {
|
|
194
207
|
return new NullableSchema<Infer<S>>(schema)
|
|
195
|
-
}
|
|
208
|
+
})
|
|
196
209
|
|
|
197
|
-
|
|
198
|
-
|
|
210
|
+
export const optional = /*#__PURE__*/ memoizedTransformer(function <
|
|
211
|
+
const S extends Validator,
|
|
212
|
+
>(schema: S) {
|
|
199
213
|
return new OptionalSchema<Infer<S>>(schema)
|
|
200
|
-
}
|
|
214
|
+
})
|
|
201
215
|
|
|
202
216
|
/*@__NO_SIDE_EFFECTS__*/
|
|
203
217
|
export function union<const V extends UnionSchemaValidators>(validators: V) {
|
|
@@ -262,7 +276,7 @@ export function typedUnion<
|
|
|
262
276
|
export function typedObject<
|
|
263
277
|
const N extends NsidString,
|
|
264
278
|
const H extends string,
|
|
265
|
-
const S extends Validator<{ [
|
|
279
|
+
const S extends Validator<{ [k: string]: unknown }>,
|
|
266
280
|
>(nsid: N, hash: H, schema: S): TypedObjectSchema<$Type<N, H>, S>
|
|
267
281
|
export function typedObject<V extends { $type?: $Type }>(
|
|
268
282
|
nsid: V extends { $type?: infer T extends string }
|
|
@@ -281,7 +295,7 @@ export function typedObject<V extends { $type?: $Type }>(
|
|
|
281
295
|
export function typedObject<
|
|
282
296
|
const N extends NsidString,
|
|
283
297
|
const H extends string,
|
|
284
|
-
const S extends Validator<{ [
|
|
298
|
+
const S extends Validator<{ [k: string]: unknown }>,
|
|
285
299
|
>(nsid: N, hash: H, schema: S) {
|
|
286
300
|
return new TypedObjectSchema<$Type<N, H>, S>($type(nsid, hash), schema)
|
|
287
301
|
}
|
|
@@ -305,7 +319,7 @@ type AsNsid<T> = T extends `${string}#${string}` ? never : T
|
|
|
305
319
|
export function record<
|
|
306
320
|
const K extends LexiconRecordKey,
|
|
307
321
|
const T extends NsidString,
|
|
308
|
-
const S extends Validator<{ [
|
|
322
|
+
const S extends Validator<{ [k: string]: unknown }>,
|
|
309
323
|
>(key: K, type: AsNsid<T>, schema: S): RecordSchema<K, T, S>
|
|
310
324
|
export function record<
|
|
311
325
|
const K extends LexiconRecordKey,
|
|
@@ -319,26 +333,32 @@ export function record<
|
|
|
319
333
|
export function record<
|
|
320
334
|
const K extends LexiconRecordKey,
|
|
321
335
|
const T extends NsidString,
|
|
322
|
-
const S extends Validator<{ [
|
|
336
|
+
const S extends Validator<{ [k: string]: unknown }>,
|
|
323
337
|
>(key: K, type: T, schema: S) {
|
|
324
338
|
return new RecordSchema<K, T, S>(key, type, schema)
|
|
325
339
|
}
|
|
326
340
|
|
|
327
|
-
|
|
328
|
-
export function params<
|
|
341
|
+
export const params = /*#__PURE__*/ memoizedOptions(function <
|
|
329
342
|
const P extends ParamsSchemaShape = NonNullable<unknown>,
|
|
330
343
|
>(properties: P = {} as P) {
|
|
331
344
|
return new ParamsSchema<P>(properties)
|
|
332
|
-
}
|
|
345
|
+
})
|
|
333
346
|
|
|
334
347
|
/*@__NO_SIDE_EFFECTS__*/
|
|
335
348
|
export function payload<
|
|
336
349
|
const E extends string | undefined = undefined,
|
|
337
|
-
const S extends
|
|
350
|
+
const S extends PayloadSchema<E> = undefined,
|
|
338
351
|
>(encoding: E = undefined as E, schema: S = undefined as S) {
|
|
339
352
|
return new Payload<E, S>(encoding, schema)
|
|
340
353
|
}
|
|
341
354
|
|
|
355
|
+
/*@__NO_SIDE_EFFECTS__*/
|
|
356
|
+
export function jsonPayload<const P extends ObjectSchemaShape>(
|
|
357
|
+
properties: P,
|
|
358
|
+
): Payload<'application/json', ObjectSchema<P>> {
|
|
359
|
+
return payload('application/json', object(properties))
|
|
360
|
+
}
|
|
361
|
+
|
|
342
362
|
/*@__NO_SIDE_EFFECTS__*/
|
|
343
363
|
export function query<
|
|
344
364
|
const N extends NsidString,
|
|
@@ -364,7 +384,7 @@ export function procedure<
|
|
|
364
384
|
export function subscription<
|
|
365
385
|
const N extends NsidString,
|
|
366
386
|
const P extends ParamsSchema,
|
|
367
|
-
const M extends
|
|
387
|
+
const M extends Schema,
|
|
368
388
|
const E extends undefined | readonly string[] = undefined,
|
|
369
389
|
>(nsid: N, parameters: P, message: M, errors: E = undefined as E) {
|
|
370
390
|
return new Subscription<N, P, M, E>(nsid, parameters, message, errors)
|