@sinclair/typebox 0.32.0-dev-13 → 0.32.0-dev-15
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/build/import/index.d.mts +10 -10
- package/build/import/index.mjs +3 -3
- package/build/import/type/exclude/exclude-from-mapped-result.d.mts +13 -0
- package/build/import/type/exclude/exclude-from-mapped-result.mjs +14 -0
- package/build/import/type/exclude/exclude.d.mts +4 -1
- package/build/import/type/exclude/exclude.mjs +10 -4
- package/build/import/type/exclude/index.d.mts +1 -0
- package/build/import/type/exclude/index.mjs +1 -0
- package/build/import/type/extends/extends-from-mapped-key.d.mts +17 -0
- package/build/import/type/extends/extends-from-mapped-key.mjs +21 -0
- package/build/import/type/extends/extends-from-mapped-result.d.mts +13 -0
- package/build/import/type/extends/extends-from-mapped-result.mjs +14 -0
- package/build/import/type/extends/extends.d.mts +4 -4
- package/build/import/type/extends/extends.mjs +4 -4
- package/build/import/type/extends/index.d.mts +2 -2
- package/build/import/type/extends/index.mjs +2 -2
- package/build/import/type/extract/extract-from-mapped-result.d.mts +13 -0
- package/build/import/type/extract/extract-from-mapped-result.mjs +14 -0
- package/build/import/type/extract/extract.d.mts +3 -0
- package/build/import/type/extract/extract.mjs +9 -3
- package/build/import/type/extract/index.d.mts +1 -0
- package/build/import/type/extract/index.mjs +1 -0
- package/build/import/type/guard/type.d.mts +47 -46
- package/build/import/type/guard/type.mjs +294 -293
- package/build/import/type/indexed/index.d.mts +1 -1
- package/build/import/type/indexed/index.mjs +1 -1
- package/build/import/type/indexed/{indexed-mapped-result.d.mts → indexed-from-mapped-key.d.mts} +6 -6
- package/build/import/type/indexed/indexed-from-mapped-key.mjs +18 -0
- package/build/import/type/indexed/indexed-result.d.mts +2 -2
- package/build/import/type/indexed/indexed-result.mjs +3 -2
- package/build/import/type/indexed/indexed.d.mts +2 -2
- package/build/import/type/indexed/indexed.mjs +4 -4
- package/build/import/type/intrinsic/capitalize.mjs +1 -2
- package/build/import/type/intrinsic/index.d.mts +1 -1
- package/build/import/type/intrinsic/index.mjs +1 -1
- package/build/import/type/intrinsic/{intrinsic-mapped-result.d.mts → intrinsic-from-mapped-key.d.mts} +6 -5
- package/build/import/type/intrinsic/intrinsic-from-mapped-key.mjs +21 -0
- package/build/import/type/intrinsic/intrinsic.d.mts +6 -6
- package/build/import/type/intrinsic/intrinsic.mjs +8 -8
- package/build/import/type/intrinsic/lowercase.mjs +1 -2
- package/build/import/type/intrinsic/uncapitalize.mjs +1 -2
- package/build/import/type/intrinsic/uppercase.mjs +1 -2
- package/build/import/type/keyof/index.d.mts +1 -0
- package/build/import/type/keyof/index.mjs +1 -0
- package/build/import/type/keyof/keyof-from-mapped-result.d.mts +13 -0
- package/build/import/type/keyof/keyof-from-mapped-result.mjs +14 -0
- package/build/import/type/keyof/keyof.d.mts +3 -0
- package/build/import/type/keyof/keyof.mjs +9 -2
- package/build/import/type/mapped/mapped.d.mts +9 -6
- package/build/import/type/mapped/mapped.mjs +11 -4
- package/build/import/type/omit/index.d.mts +1 -1
- package/build/import/type/omit/index.mjs +1 -1
- package/build/import/type/omit/omit-from-mapped-key.d.mts +15 -0
- package/build/import/type/omit/omit-from-mapped-key.mjs +20 -0
- package/build/import/type/omit/omit.d.mts +2 -2
- package/build/import/type/omit/omit.mjs +2 -2
- package/build/import/type/partial/index.d.mts +1 -0
- package/build/import/type/partial/index.mjs +1 -0
- package/build/import/type/partial/partial-from-mapped-result.d.mts +13 -0
- package/build/import/type/partial/partial-from-mapped-result.mjs +14 -0
- package/build/import/type/partial/partial.d.mts +5 -2
- package/build/import/type/partial/partial.mjs +11 -5
- package/build/import/type/pick/index.d.mts +1 -1
- package/build/import/type/pick/index.mjs +1 -1
- package/build/import/type/pick/pick-from-mapped-key.d.mts +15 -0
- package/build/import/type/pick/pick-from-mapped-key.mjs +20 -0
- package/build/import/type/pick/pick.d.mts +2 -2
- package/build/import/type/pick/pick.mjs +2 -2
- package/build/import/type/required/index.d.mts +1 -0
- package/build/import/type/required/index.mjs +1 -0
- package/build/import/type/required/required-from-mapped-result.d.mts +13 -0
- package/build/import/type/required/required-from-mapped-result.mjs +14 -0
- package/build/import/type/required/required.d.mts +5 -2
- package/build/import/type/required/required.mjs +11 -5
- package/build/import/type/type/json.d.mts +21 -16
- package/build/import/type/type/json.mjs +3 -3
- package/build/require/index.d.ts +10 -10
- package/build/require/index.js +5 -3
- package/build/require/type/exclude/exclude-from-mapped-result.d.ts +13 -0
- package/build/require/type/exclude/exclude-from-mapped-result.js +18 -0
- package/build/require/type/exclude/exclude.d.ts +4 -1
- package/build/require/type/exclude/exclude.js +9 -4
- package/build/require/type/exclude/index.d.ts +1 -0
- package/build/require/type/exclude/index.js +1 -0
- package/build/require/type/extends/extends-from-mapped-key.d.ts +17 -0
- package/build/require/type/extends/extends-from-mapped-key.js +25 -0
- package/build/require/type/extends/extends-from-mapped-result.d.ts +13 -0
- package/build/require/type/extends/extends-from-mapped-result.js +18 -0
- package/build/require/type/extends/extends.d.ts +4 -4
- package/build/require/type/extends/extends.js +4 -4
- package/build/require/type/extends/index.d.ts +2 -2
- package/build/require/type/extends/index.js +2 -2
- package/build/require/type/extract/extract-from-mapped-result.d.ts +13 -0
- package/build/require/type/extract/extract-from-mapped-result.js +18 -0
- package/build/require/type/extract/extract.d.ts +3 -0
- package/build/require/type/extract/extract.js +8 -2
- package/build/require/type/extract/index.d.ts +1 -0
- package/build/require/type/extract/index.js +1 -0
- package/build/require/type/guard/type.d.ts +47 -46
- package/build/require/type/guard/type.js +252 -250
- package/build/require/type/indexed/index.d.ts +1 -1
- package/build/require/type/indexed/index.js +1 -1
- package/build/require/type/indexed/{indexed-mapped-result.d.ts → indexed-from-mapped-key.d.ts} +6 -6
- package/build/require/type/indexed/indexed-from-mapped-key.js +22 -0
- package/build/require/type/indexed/indexed-result.d.ts +2 -2
- package/build/require/type/indexed/indexed-result.js +11 -10
- package/build/require/type/indexed/indexed.d.ts +2 -2
- package/build/require/type/indexed/indexed.js +4 -4
- package/build/require/type/intrinsic/capitalize.js +1 -2
- package/build/require/type/intrinsic/index.d.ts +1 -1
- package/build/require/type/intrinsic/index.js +1 -1
- package/build/require/type/intrinsic/{intrinsic-mapped-result.d.ts → intrinsic-from-mapped-key.d.ts} +6 -5
- package/build/require/type/intrinsic/intrinsic-from-mapped-key.js +25 -0
- package/build/require/type/intrinsic/intrinsic.d.ts +6 -6
- package/build/require/type/intrinsic/intrinsic.js +8 -8
- package/build/require/type/intrinsic/lowercase.js +1 -2
- package/build/require/type/intrinsic/uncapitalize.js +1 -2
- package/build/require/type/intrinsic/uppercase.js +1 -2
- package/build/require/type/keyof/index.d.ts +1 -0
- package/build/require/type/keyof/index.js +1 -0
- package/build/require/type/keyof/keyof-from-mapped-result.d.ts +13 -0
- package/build/require/type/keyof/keyof-from-mapped-result.js +18 -0
- package/build/require/type/keyof/keyof.d.ts +3 -0
- package/build/require/type/keyof/keyof.js +9 -2
- package/build/require/type/mapped/mapped.d.ts +9 -6
- package/build/require/type/mapped/mapped.js +24 -17
- package/build/require/type/omit/index.d.ts +1 -1
- package/build/require/type/omit/index.js +1 -1
- package/build/require/type/omit/omit-from-mapped-key.d.ts +15 -0
- package/build/require/type/omit/omit-from-mapped-key.js +24 -0
- package/build/require/type/omit/omit.d.ts +2 -2
- package/build/require/type/omit/omit.js +2 -2
- package/build/require/type/partial/index.d.ts +1 -0
- package/build/require/type/partial/index.js +1 -0
- package/build/require/type/partial/partial-from-mapped-result.d.ts +13 -0
- package/build/require/type/partial/partial-from-mapped-result.js +18 -0
- package/build/require/type/partial/partial.d.ts +5 -2
- package/build/require/type/partial/partial.js +10 -5
- package/build/require/type/pick/index.d.ts +1 -1
- package/build/require/type/pick/index.js +1 -1
- package/build/require/type/pick/pick-from-mapped-key.d.ts +15 -0
- package/build/require/type/pick/pick-from-mapped-key.js +24 -0
- package/build/require/type/pick/pick.d.ts +2 -2
- package/build/require/type/pick/pick.js +2 -2
- package/build/require/type/required/index.d.ts +1 -0
- package/build/require/type/required/index.js +1 -0
- package/build/require/type/required/required-from-mapped-result.d.ts +13 -0
- package/build/require/type/required/required-from-mapped-result.js +18 -0
- package/build/require/type/required/required.d.ts +5 -2
- package/build/require/type/required/required.js +10 -5
- package/build/require/type/type/json.d.ts +21 -16
- package/build/require/type/type/json.js +3 -3
- package/package.json +1 -1
- package/readme.md +79 -91
- package/build/import/type/extends/extends-mapped-result-from-result.d.mts +0 -13
- package/build/import/type/extends/extends-mapped-result-from-result.mjs +0 -14
- package/build/import/type/extends/extends-mapped-result.d.mts +0 -17
- package/build/import/type/extends/extends-mapped-result.mjs +0 -21
- package/build/import/type/indexed/indexed-mapped-result.mjs +0 -18
- package/build/import/type/intrinsic/intrinsic-mapped-result.mjs +0 -21
- package/build/import/type/omit/omit-mapped-result.d.mts +0 -15
- package/build/import/type/omit/omit-mapped-result.mjs +0 -20
- package/build/import/type/pick/pick-mapped-result.d.mts +0 -15
- package/build/import/type/pick/pick-mapped-result.mjs +0 -20
- package/build/require/type/extends/extends-mapped-result-from-result.d.ts +0 -13
- package/build/require/type/extends/extends-mapped-result-from-result.js +0 -18
- package/build/require/type/extends/extends-mapped-result.d.ts +0 -17
- package/build/require/type/extends/extends-mapped-result.js +0 -25
- package/build/require/type/indexed/indexed-mapped-result.js +0 -22
- package/build/require/type/intrinsic/intrinsic-mapped-result.js +0 -25
- package/build/require/type/omit/omit-mapped-result.d.ts +0 -15
- package/build/require/type/omit/omit-mapped-result.js +0 -24
- package/build/require/type/pick/pick-mapped-result.d.ts +0 -15
- package/build/require/type/pick/pick-mapped-result.js +0 -24
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TSchema = exports.TKind = exports.TVoid = exports.TUnsafe = exports.TUnknown = exports.TUint8Array = exports.TUnion = exports.TUnionLiteral = exports.TUndefined = exports.TTuple = exports.TTransform = exports.TThis = exports.TTemplateLiteral = exports.TSymbol = exports.TString = exports.TRef = exports.TRecursive = exports.TRecord = exports.TPromise = exports.TObject = exports.TNumber = exports.TNull = exports.TNot = exports.TNever = exports.TMappedResult = exports.TMappedKey = exports.TLiteral = exports.TLiteralBoolean = exports.TLiteralNumber = exports.TLiteralString = exports.TKindOf = exports.TIterator = exports.TIntersect = exports.TProperties = exports.TInteger = exports.TFunction = exports.TDate = exports.TConstructor = exports.TBoolean = exports.TBigInt = exports.TAsyncIterator = exports.TArray = exports.TAny = exports.TOptional = exports.TReadonly = exports.TypeGuardUnknownTypeError = void 0;
|
|
3
|
+
exports.TSchema = exports.TKind = exports.TVoid = exports.TUnsafe = exports.TUnknown = exports.TUint8Array = exports.TUnion = exports.TUnionLiteral = exports.TUndefined = exports.TTuple = exports.TTransform = exports.TThis = exports.TTemplateLiteral = exports.TSymbol = exports.TString = exports.TRef = exports.TRecursive = exports.TRecord = exports.TPromise = exports.TObject = exports.TNumber = exports.TNull = exports.TNot = exports.TNever = exports.TMappedResult = exports.TMappedKey = exports.TLiteralValue = exports.TLiteral = exports.TLiteralBoolean = exports.TLiteralNumber = exports.TLiteralString = exports.TKindOf = exports.TIterator = exports.TIntersect = exports.TProperties = exports.TInteger = exports.TFunction = exports.TDate = exports.TConstructor = exports.TBoolean = exports.TBigInt = exports.TAsyncIterator = exports.TArray = exports.TAny = exports.TOptional = exports.TReadonly = exports.TypeGuardUnknownTypeError = void 0;
|
|
4
4
|
const ValueGuard = require("./value");
|
|
5
5
|
const index_1 = require("../symbols/index");
|
|
6
6
|
class TypeGuardUnknownTypeError extends Error {
|
|
@@ -84,348 +84,350 @@ function IsOptionalFormat(value) {
|
|
|
84
84
|
function IsOptionalSchema(value) {
|
|
85
85
|
return ValueGuard.IsUndefined(value) || (0, index_2.TSchema)(value);
|
|
86
86
|
}
|
|
87
|
-
function TReadonly(
|
|
88
|
-
return ValueGuard.IsObject(
|
|
87
|
+
function TReadonly(value) {
|
|
88
|
+
return ValueGuard.IsObject(value) && value[index_1.ReadonlyKind] === 'Readonly';
|
|
89
89
|
}
|
|
90
90
|
exports.TReadonly = TReadonly;
|
|
91
|
-
function TOptional(
|
|
92
|
-
return ValueGuard.IsObject(
|
|
91
|
+
function TOptional(value) {
|
|
92
|
+
return ValueGuard.IsObject(value) && value[index_1.OptionalKind] === 'Optional';
|
|
93
93
|
}
|
|
94
94
|
exports.TOptional = TOptional;
|
|
95
|
-
function TAny(
|
|
96
|
-
return (TKindOf(
|
|
97
|
-
IsOptionalString(
|
|
95
|
+
function TAny(value) {
|
|
96
|
+
return (TKindOf(value, 'Any') &&
|
|
97
|
+
IsOptionalString(value.$id));
|
|
98
98
|
}
|
|
99
99
|
exports.TAny = TAny;
|
|
100
|
-
function TArray(
|
|
101
|
-
return (TKindOf(
|
|
102
|
-
|
|
103
|
-
IsOptionalString(
|
|
104
|
-
(0, index_2.TSchema)(
|
|
105
|
-
IsOptionalNumber(
|
|
106
|
-
IsOptionalNumber(
|
|
107
|
-
IsOptionalBoolean(
|
|
108
|
-
IsOptionalSchema(
|
|
109
|
-
IsOptionalNumber(
|
|
110
|
-
IsOptionalNumber(
|
|
100
|
+
function TArray(value) {
|
|
101
|
+
return (TKindOf(value, 'Array') &&
|
|
102
|
+
value.type === 'array' &&
|
|
103
|
+
IsOptionalString(value.$id) &&
|
|
104
|
+
(0, index_2.TSchema)(value.items) &&
|
|
105
|
+
IsOptionalNumber(value.minItems) &&
|
|
106
|
+
IsOptionalNumber(value.maxItems) &&
|
|
107
|
+
IsOptionalBoolean(value.uniqueItems) &&
|
|
108
|
+
IsOptionalSchema(value.contains) &&
|
|
109
|
+
IsOptionalNumber(value.minContains) &&
|
|
110
|
+
IsOptionalNumber(value.maxContains));
|
|
111
111
|
}
|
|
112
112
|
exports.TArray = TArray;
|
|
113
|
-
function TAsyncIterator(
|
|
114
|
-
return (TKindOf(
|
|
115
|
-
|
|
116
|
-
IsOptionalString(
|
|
117
|
-
(0, index_2.TSchema)(
|
|
113
|
+
function TAsyncIterator(value) {
|
|
114
|
+
return (TKindOf(value, 'AsyncIterator') &&
|
|
115
|
+
value.type === 'AsyncIterator' &&
|
|
116
|
+
IsOptionalString(value.$id) &&
|
|
117
|
+
(0, index_2.TSchema)(value.items));
|
|
118
118
|
}
|
|
119
119
|
exports.TAsyncIterator = TAsyncIterator;
|
|
120
|
-
function TBigInt(
|
|
121
|
-
return (TKindOf(
|
|
122
|
-
|
|
123
|
-
IsOptionalString(
|
|
124
|
-
IsOptionalBigInt(
|
|
125
|
-
IsOptionalBigInt(
|
|
126
|
-
IsOptionalBigInt(
|
|
127
|
-
IsOptionalBigInt(
|
|
128
|
-
IsOptionalBigInt(
|
|
120
|
+
function TBigInt(value) {
|
|
121
|
+
return (TKindOf(value, 'BigInt') &&
|
|
122
|
+
value.type === 'bigint' &&
|
|
123
|
+
IsOptionalString(value.$id) &&
|
|
124
|
+
IsOptionalBigInt(value.exclusiveMaximum) &&
|
|
125
|
+
IsOptionalBigInt(value.exclusiveMinimum) &&
|
|
126
|
+
IsOptionalBigInt(value.maximum) &&
|
|
127
|
+
IsOptionalBigInt(value.minimum) &&
|
|
128
|
+
IsOptionalBigInt(value.multipleOf));
|
|
129
129
|
}
|
|
130
130
|
exports.TBigInt = TBigInt;
|
|
131
|
-
function TBoolean(
|
|
132
|
-
return (TKindOf(
|
|
133
|
-
|
|
134
|
-
IsOptionalString(
|
|
131
|
+
function TBoolean(value) {
|
|
132
|
+
return (TKindOf(value, 'Boolean') &&
|
|
133
|
+
value.type === 'boolean' &&
|
|
134
|
+
IsOptionalString(value.$id));
|
|
135
135
|
}
|
|
136
136
|
exports.TBoolean = TBoolean;
|
|
137
|
-
function TConstructor(
|
|
138
|
-
return (TKindOf(
|
|
139
|
-
|
|
140
|
-
IsOptionalString(
|
|
141
|
-
ValueGuard.IsArray(
|
|
142
|
-
|
|
143
|
-
(0, index_2.TSchema)(
|
|
137
|
+
function TConstructor(value) {
|
|
138
|
+
return (TKindOf(value, 'Constructor') &&
|
|
139
|
+
value.type === 'Constructor' &&
|
|
140
|
+
IsOptionalString(value.$id) &&
|
|
141
|
+
ValueGuard.IsArray(value.parameters) &&
|
|
142
|
+
value.parameters.every(schema => (0, index_2.TSchema)(schema)) &&
|
|
143
|
+
(0, index_2.TSchema)(value.returns));
|
|
144
144
|
}
|
|
145
145
|
exports.TConstructor = TConstructor;
|
|
146
|
-
function TDate(
|
|
147
|
-
return (TKindOf(
|
|
148
|
-
|
|
149
|
-
IsOptionalString(
|
|
150
|
-
IsOptionalNumber(
|
|
151
|
-
IsOptionalNumber(
|
|
152
|
-
IsOptionalNumber(
|
|
153
|
-
IsOptionalNumber(
|
|
154
|
-
IsOptionalNumber(
|
|
146
|
+
function TDate(value) {
|
|
147
|
+
return (TKindOf(value, 'Date') &&
|
|
148
|
+
value.type === 'Date' &&
|
|
149
|
+
IsOptionalString(value.$id) &&
|
|
150
|
+
IsOptionalNumber(value.exclusiveMaximumTimestamp) &&
|
|
151
|
+
IsOptionalNumber(value.exclusiveMinimumTimestamp) &&
|
|
152
|
+
IsOptionalNumber(value.maximumTimestamp) &&
|
|
153
|
+
IsOptionalNumber(value.minimumTimestamp) &&
|
|
154
|
+
IsOptionalNumber(value.multipleOfTimestamp));
|
|
155
155
|
}
|
|
156
156
|
exports.TDate = TDate;
|
|
157
|
-
function TFunction(
|
|
158
|
-
return (TKindOf(
|
|
159
|
-
|
|
160
|
-
IsOptionalString(
|
|
161
|
-
ValueGuard.IsArray(
|
|
162
|
-
|
|
163
|
-
(0, index_2.TSchema)(
|
|
157
|
+
function TFunction(value) {
|
|
158
|
+
return (TKindOf(value, 'Function') &&
|
|
159
|
+
value.type === 'Function' &&
|
|
160
|
+
IsOptionalString(value.$id) &&
|
|
161
|
+
ValueGuard.IsArray(value.parameters) &&
|
|
162
|
+
value.parameters.every(schema => (0, index_2.TSchema)(schema)) &&
|
|
163
|
+
(0, index_2.TSchema)(value.returns));
|
|
164
164
|
}
|
|
165
165
|
exports.TFunction = TFunction;
|
|
166
|
-
function TInteger(
|
|
167
|
-
return (TKindOf(
|
|
168
|
-
|
|
169
|
-
IsOptionalString(
|
|
170
|
-
IsOptionalNumber(
|
|
171
|
-
IsOptionalNumber(
|
|
172
|
-
IsOptionalNumber(
|
|
173
|
-
IsOptionalNumber(
|
|
174
|
-
IsOptionalNumber(
|
|
166
|
+
function TInteger(value) {
|
|
167
|
+
return (TKindOf(value, 'Integer') &&
|
|
168
|
+
value.type === 'integer' &&
|
|
169
|
+
IsOptionalString(value.$id) &&
|
|
170
|
+
IsOptionalNumber(value.exclusiveMaximum) &&
|
|
171
|
+
IsOptionalNumber(value.exclusiveMinimum) &&
|
|
172
|
+
IsOptionalNumber(value.maximum) &&
|
|
173
|
+
IsOptionalNumber(value.minimum) &&
|
|
174
|
+
IsOptionalNumber(value.multipleOf));
|
|
175
175
|
}
|
|
176
176
|
exports.TInteger = TInteger;
|
|
177
|
-
function TProperties(
|
|
178
|
-
return (ValueGuard.IsObject(
|
|
179
|
-
Object.entries(
|
|
177
|
+
function TProperties(value) {
|
|
178
|
+
return (ValueGuard.IsObject(value) &&
|
|
179
|
+
Object.entries(value).every(([key, schema]) => IsControlCharacterFree(key) && (0, index_2.TSchema)(schema)));
|
|
180
180
|
}
|
|
181
181
|
exports.TProperties = TProperties;
|
|
182
|
-
function TIntersect(
|
|
183
|
-
return (TKindOf(
|
|
184
|
-
(ValueGuard.IsString(
|
|
185
|
-
ValueGuard.IsArray(
|
|
186
|
-
|
|
187
|
-
IsOptionalString(
|
|
188
|
-
(IsOptionalBoolean(
|
|
189
|
-
IsOptionalString(
|
|
182
|
+
function TIntersect(value) {
|
|
183
|
+
return (TKindOf(value, 'Intersect') &&
|
|
184
|
+
(ValueGuard.IsString(value.type) && value.type !== 'object' ? false : true) &&
|
|
185
|
+
ValueGuard.IsArray(value.allOf) &&
|
|
186
|
+
value.allOf.every(schema => (0, index_2.TSchema)(schema) && !TTransform(schema)) &&
|
|
187
|
+
IsOptionalString(value.type) &&
|
|
188
|
+
(IsOptionalBoolean(value.unevaluatedProperties) || IsOptionalSchema(value.unevaluatedProperties)) &&
|
|
189
|
+
IsOptionalString(value.$id));
|
|
190
190
|
}
|
|
191
191
|
exports.TIntersect = TIntersect;
|
|
192
|
-
function TIterator(
|
|
193
|
-
return (TKindOf(
|
|
194
|
-
|
|
195
|
-
IsOptionalString(
|
|
196
|
-
(0, index_2.TSchema)(
|
|
192
|
+
function TIterator(value) {
|
|
193
|
+
return (TKindOf(value, 'Iterator') &&
|
|
194
|
+
value.type === 'Iterator' &&
|
|
195
|
+
IsOptionalString(value.$id) &&
|
|
196
|
+
(0, index_2.TSchema)(value.items));
|
|
197
197
|
}
|
|
198
198
|
exports.TIterator = TIterator;
|
|
199
|
-
function TKindOf(
|
|
200
|
-
return ValueGuard.IsObject(
|
|
199
|
+
function TKindOf(value, kind) {
|
|
200
|
+
return ValueGuard.IsObject(value) && index_1.Kind in value && value[index_1.Kind] === kind;
|
|
201
201
|
}
|
|
202
202
|
exports.TKindOf = TKindOf;
|
|
203
|
-
function TLiteralString(
|
|
204
|
-
return (0, index_3.TLiteral)(
|
|
203
|
+
function TLiteralString(value) {
|
|
204
|
+
return (0, index_3.TLiteral)(value) && ValueGuard.IsString(value.const);
|
|
205
205
|
}
|
|
206
206
|
exports.TLiteralString = TLiteralString;
|
|
207
|
-
function TLiteralNumber(
|
|
208
|
-
return (0, index_3.TLiteral)(
|
|
207
|
+
function TLiteralNumber(value) {
|
|
208
|
+
return (0, index_3.TLiteral)(value) && ValueGuard.IsNumber(value.const);
|
|
209
209
|
}
|
|
210
210
|
exports.TLiteralNumber = TLiteralNumber;
|
|
211
|
-
function TLiteralBoolean(
|
|
212
|
-
return (0, index_3.TLiteral)(
|
|
211
|
+
function TLiteralBoolean(value) {
|
|
212
|
+
return (0, index_3.TLiteral)(value) && ValueGuard.IsBoolean(value.const);
|
|
213
213
|
}
|
|
214
214
|
exports.TLiteralBoolean = TLiteralBoolean;
|
|
215
|
-
function TLiteral(
|
|
216
|
-
return (TKindOf(
|
|
217
|
-
IsOptionalString(
|
|
218
|
-
ValueGuard.IsNumber(schema.const) ||
|
|
219
|
-
ValueGuard.IsString(schema.const)));
|
|
215
|
+
function TLiteral(value) {
|
|
216
|
+
return (TKindOf(value, 'Literal') &&
|
|
217
|
+
IsOptionalString(value.$id) && (0, index_3.TLiteralValue)(value.const));
|
|
220
218
|
}
|
|
221
219
|
exports.TLiteral = TLiteral;
|
|
222
|
-
function
|
|
223
|
-
return (
|
|
224
|
-
|
|
225
|
-
|
|
220
|
+
function TLiteralValue(value) {
|
|
221
|
+
return ValueGuard.IsBoolean(value) || ValueGuard.IsNumber(value) || ValueGuard.IsString(value);
|
|
222
|
+
}
|
|
223
|
+
exports.TLiteralValue = TLiteralValue;
|
|
224
|
+
function TMappedKey(value) {
|
|
225
|
+
return (TKindOf(value, 'MappedKey') &&
|
|
226
|
+
ValueGuard.IsArray(value.keys) &&
|
|
227
|
+
value.keys.every(key => ValueGuard.IsNumber(key) || ValueGuard.IsString(key)));
|
|
226
228
|
}
|
|
227
229
|
exports.TMappedKey = TMappedKey;
|
|
228
|
-
function TMappedResult(
|
|
229
|
-
return (TKindOf(
|
|
230
|
-
(0, index_4.TProperties)(
|
|
230
|
+
function TMappedResult(value) {
|
|
231
|
+
return (TKindOf(value, 'MappedResult') &&
|
|
232
|
+
(0, index_4.TProperties)(value.properties));
|
|
231
233
|
}
|
|
232
234
|
exports.TMappedResult = TMappedResult;
|
|
233
|
-
function TNever(
|
|
234
|
-
return (TKindOf(
|
|
235
|
-
ValueGuard.IsObject(
|
|
236
|
-
Object.getOwnPropertyNames(
|
|
235
|
+
function TNever(value) {
|
|
236
|
+
return (TKindOf(value, 'Never') &&
|
|
237
|
+
ValueGuard.IsObject(value.not) &&
|
|
238
|
+
Object.getOwnPropertyNames(value.not).length === 0);
|
|
237
239
|
}
|
|
238
240
|
exports.TNever = TNever;
|
|
239
|
-
function TNot(
|
|
240
|
-
return (TKindOf(
|
|
241
|
-
(0, index_2.TSchema)(
|
|
241
|
+
function TNot(value) {
|
|
242
|
+
return (TKindOf(value, 'Not') &&
|
|
243
|
+
(0, index_2.TSchema)(value.not));
|
|
242
244
|
}
|
|
243
245
|
exports.TNot = TNot;
|
|
244
|
-
function TNull(
|
|
245
|
-
return (TKindOf(
|
|
246
|
-
|
|
247
|
-
IsOptionalString(
|
|
246
|
+
function TNull(value) {
|
|
247
|
+
return (TKindOf(value, 'Null') &&
|
|
248
|
+
value.type === 'null' &&
|
|
249
|
+
IsOptionalString(value.$id));
|
|
248
250
|
}
|
|
249
251
|
exports.TNull = TNull;
|
|
250
|
-
function TNumber(
|
|
251
|
-
return (TKindOf(
|
|
252
|
-
|
|
253
|
-
IsOptionalString(
|
|
254
|
-
IsOptionalNumber(
|
|
255
|
-
IsOptionalNumber(
|
|
256
|
-
IsOptionalNumber(
|
|
257
|
-
IsOptionalNumber(
|
|
258
|
-
IsOptionalNumber(
|
|
252
|
+
function TNumber(value) {
|
|
253
|
+
return (TKindOf(value, 'Number') &&
|
|
254
|
+
value.type === 'number' &&
|
|
255
|
+
IsOptionalString(value.$id) &&
|
|
256
|
+
IsOptionalNumber(value.exclusiveMaximum) &&
|
|
257
|
+
IsOptionalNumber(value.exclusiveMinimum) &&
|
|
258
|
+
IsOptionalNumber(value.maximum) &&
|
|
259
|
+
IsOptionalNumber(value.minimum) &&
|
|
260
|
+
IsOptionalNumber(value.multipleOf));
|
|
259
261
|
}
|
|
260
262
|
exports.TNumber = TNumber;
|
|
261
|
-
function TObject(
|
|
262
|
-
return (TKindOf(
|
|
263
|
-
|
|
264
|
-
IsOptionalString(
|
|
265
|
-
(0, index_4.TProperties)(
|
|
266
|
-
IsAdditionalProperties(
|
|
267
|
-
IsOptionalNumber(
|
|
268
|
-
IsOptionalNumber(
|
|
263
|
+
function TObject(value) {
|
|
264
|
+
return (TKindOf(value, 'Object') &&
|
|
265
|
+
value.type === 'object' &&
|
|
266
|
+
IsOptionalString(value.$id) &&
|
|
267
|
+
(0, index_4.TProperties)(value.properties) &&
|
|
268
|
+
IsAdditionalProperties(value.additionalProperties) &&
|
|
269
|
+
IsOptionalNumber(value.minProperties) &&
|
|
270
|
+
IsOptionalNumber(value.maxProperties));
|
|
269
271
|
}
|
|
270
272
|
exports.TObject = TObject;
|
|
271
|
-
function TPromise(
|
|
272
|
-
return (TKindOf(
|
|
273
|
-
|
|
274
|
-
IsOptionalString(
|
|
275
|
-
(0, index_2.TSchema)(
|
|
273
|
+
function TPromise(value) {
|
|
274
|
+
return (TKindOf(value, 'Promise') &&
|
|
275
|
+
value.type === 'Promise' &&
|
|
276
|
+
IsOptionalString(value.$id) &&
|
|
277
|
+
(0, index_2.TSchema)(value.item));
|
|
276
278
|
}
|
|
277
279
|
exports.TPromise = TPromise;
|
|
278
|
-
function TRecord(
|
|
279
|
-
return (TKindOf(
|
|
280
|
-
|
|
281
|
-
IsOptionalString(
|
|
282
|
-
IsAdditionalProperties(
|
|
283
|
-
ValueGuard.IsObject(
|
|
280
|
+
function TRecord(value) {
|
|
281
|
+
return (TKindOf(value, 'Record') &&
|
|
282
|
+
value.type === 'object' &&
|
|
283
|
+
IsOptionalString(value.$id) &&
|
|
284
|
+
IsAdditionalProperties(value.additionalProperties) &&
|
|
285
|
+
ValueGuard.IsObject(value.patternProperties) &&
|
|
284
286
|
((schema) => {
|
|
285
287
|
const keys = Object.getOwnPropertyNames(schema.patternProperties);
|
|
286
288
|
return (keys.length === 1 &&
|
|
287
289
|
IsPattern(keys[0]) &&
|
|
288
290
|
ValueGuard.IsObject(schema.patternProperties) &&
|
|
289
291
|
(0, index_2.TSchema)(schema.patternProperties[keys[0]]));
|
|
290
|
-
})(
|
|
292
|
+
})(value));
|
|
291
293
|
}
|
|
292
294
|
exports.TRecord = TRecord;
|
|
293
|
-
function TRecursive(
|
|
294
|
-
return ValueGuard.IsObject(
|
|
295
|
+
function TRecursive(value) {
|
|
296
|
+
return ValueGuard.IsObject(value) && index_1.Hint in value && value[index_1.Hint] === 'Recursive';
|
|
295
297
|
}
|
|
296
298
|
exports.TRecursive = TRecursive;
|
|
297
|
-
function TRef(
|
|
298
|
-
return (TKindOf(
|
|
299
|
-
IsOptionalString(
|
|
300
|
-
ValueGuard.IsString(
|
|
299
|
+
function TRef(value) {
|
|
300
|
+
return (TKindOf(value, 'Ref') &&
|
|
301
|
+
IsOptionalString(value.$id) &&
|
|
302
|
+
ValueGuard.IsString(value.$ref));
|
|
301
303
|
}
|
|
302
304
|
exports.TRef = TRef;
|
|
303
|
-
function TString(
|
|
304
|
-
return (TKindOf(
|
|
305
|
-
|
|
306
|
-
IsOptionalString(
|
|
307
|
-
IsOptionalNumber(
|
|
308
|
-
IsOptionalNumber(
|
|
309
|
-
IsOptionalPattern(
|
|
310
|
-
IsOptionalFormat(
|
|
305
|
+
function TString(value) {
|
|
306
|
+
return (TKindOf(value, 'String') &&
|
|
307
|
+
value.type === 'string' &&
|
|
308
|
+
IsOptionalString(value.$id) &&
|
|
309
|
+
IsOptionalNumber(value.minLength) &&
|
|
310
|
+
IsOptionalNumber(value.maxLength) &&
|
|
311
|
+
IsOptionalPattern(value.pattern) &&
|
|
312
|
+
IsOptionalFormat(value.format));
|
|
311
313
|
}
|
|
312
314
|
exports.TString = TString;
|
|
313
|
-
function TSymbol(
|
|
314
|
-
return (TKindOf(
|
|
315
|
-
|
|
316
|
-
IsOptionalString(
|
|
315
|
+
function TSymbol(value) {
|
|
316
|
+
return (TKindOf(value, 'Symbol') &&
|
|
317
|
+
value.type === 'symbol' &&
|
|
318
|
+
IsOptionalString(value.$id));
|
|
317
319
|
}
|
|
318
320
|
exports.TSymbol = TSymbol;
|
|
319
|
-
function TTemplateLiteral(
|
|
320
|
-
return (TKindOf(
|
|
321
|
-
|
|
322
|
-
ValueGuard.IsString(
|
|
323
|
-
|
|
324
|
-
|
|
321
|
+
function TTemplateLiteral(value) {
|
|
322
|
+
return (TKindOf(value, 'TemplateLiteral') &&
|
|
323
|
+
value.type === 'string' &&
|
|
324
|
+
ValueGuard.IsString(value.pattern) &&
|
|
325
|
+
value.pattern[0] === '^' &&
|
|
326
|
+
value.pattern[value.pattern.length - 1] === '$');
|
|
325
327
|
}
|
|
326
328
|
exports.TTemplateLiteral = TTemplateLiteral;
|
|
327
|
-
function TThis(
|
|
328
|
-
return (TKindOf(
|
|
329
|
-
IsOptionalString(
|
|
330
|
-
ValueGuard.IsString(
|
|
329
|
+
function TThis(value) {
|
|
330
|
+
return (TKindOf(value, 'This') &&
|
|
331
|
+
IsOptionalString(value.$id) &&
|
|
332
|
+
ValueGuard.IsString(value.$ref));
|
|
331
333
|
}
|
|
332
334
|
exports.TThis = TThis;
|
|
333
|
-
function TTransform(
|
|
334
|
-
return ValueGuard.IsObject(
|
|
335
|
+
function TTransform(value) {
|
|
336
|
+
return ValueGuard.IsObject(value) && index_1.TransformKind in value;
|
|
335
337
|
}
|
|
336
338
|
exports.TTransform = TTransform;
|
|
337
|
-
function TTuple(
|
|
338
|
-
return (TKindOf(
|
|
339
|
-
|
|
340
|
-
IsOptionalString(
|
|
341
|
-
ValueGuard.IsNumber(
|
|
342
|
-
ValueGuard.IsNumber(
|
|
343
|
-
|
|
344
|
-
((ValueGuard.IsUndefined(
|
|
345
|
-
ValueGuard.IsUndefined(
|
|
346
|
-
|
|
347
|
-
|
|
339
|
+
function TTuple(value) {
|
|
340
|
+
return (TKindOf(value, 'Tuple') &&
|
|
341
|
+
value.type === 'array' &&
|
|
342
|
+
IsOptionalString(value.$id) &&
|
|
343
|
+
ValueGuard.IsNumber(value.minItems) &&
|
|
344
|
+
ValueGuard.IsNumber(value.maxItems) &&
|
|
345
|
+
value.minItems === value.maxItems &&
|
|
346
|
+
((ValueGuard.IsUndefined(value.items) &&
|
|
347
|
+
ValueGuard.IsUndefined(value.additionalItems) &&
|
|
348
|
+
value.minItems === 0) || (ValueGuard.IsArray(value.items) &&
|
|
349
|
+
value.items.every(schema => (0, index_2.TSchema)(schema)))));
|
|
348
350
|
}
|
|
349
351
|
exports.TTuple = TTuple;
|
|
350
|
-
function TUndefined(
|
|
351
|
-
return (TKindOf(
|
|
352
|
-
|
|
353
|
-
IsOptionalString(
|
|
352
|
+
function TUndefined(value) {
|
|
353
|
+
return (TKindOf(value, 'Undefined') &&
|
|
354
|
+
value.type === 'undefined' &&
|
|
355
|
+
IsOptionalString(value.$id));
|
|
354
356
|
}
|
|
355
357
|
exports.TUndefined = TUndefined;
|
|
356
|
-
function TUnionLiteral(
|
|
357
|
-
return (0, index_5.TUnion)(
|
|
358
|
+
function TUnionLiteral(value) {
|
|
359
|
+
return (0, index_5.TUnion)(value) && value.anyOf.every((schema) => TLiteralString(schema) || TLiteralNumber(schema));
|
|
358
360
|
}
|
|
359
361
|
exports.TUnionLiteral = TUnionLiteral;
|
|
360
|
-
function TUnion(
|
|
361
|
-
return (TKindOf(
|
|
362
|
-
IsOptionalString(
|
|
363
|
-
ValueGuard.IsObject(
|
|
364
|
-
ValueGuard.IsArray(
|
|
365
|
-
|
|
362
|
+
function TUnion(value) {
|
|
363
|
+
return (TKindOf(value, 'Union') &&
|
|
364
|
+
IsOptionalString(value.$id) &&
|
|
365
|
+
ValueGuard.IsObject(value) &&
|
|
366
|
+
ValueGuard.IsArray(value.anyOf) &&
|
|
367
|
+
value.anyOf.every(schema => (0, index_2.TSchema)(schema)));
|
|
366
368
|
}
|
|
367
369
|
exports.TUnion = TUnion;
|
|
368
|
-
function TUint8Array(
|
|
369
|
-
return (TKindOf(
|
|
370
|
-
|
|
371
|
-
IsOptionalString(
|
|
372
|
-
IsOptionalNumber(
|
|
373
|
-
IsOptionalNumber(
|
|
370
|
+
function TUint8Array(value) {
|
|
371
|
+
return (TKindOf(value, 'Uint8Array') &&
|
|
372
|
+
value.type === 'Uint8Array' &&
|
|
373
|
+
IsOptionalString(value.$id) &&
|
|
374
|
+
IsOptionalNumber(value.minByteLength) &&
|
|
375
|
+
IsOptionalNumber(value.maxByteLength));
|
|
374
376
|
}
|
|
375
377
|
exports.TUint8Array = TUint8Array;
|
|
376
|
-
function TUnknown(
|
|
377
|
-
return (TKindOf(
|
|
378
|
-
IsOptionalString(
|
|
378
|
+
function TUnknown(value) {
|
|
379
|
+
return (TKindOf(value, 'Unknown') &&
|
|
380
|
+
IsOptionalString(value.$id));
|
|
379
381
|
}
|
|
380
382
|
exports.TUnknown = TUnknown;
|
|
381
|
-
function TUnsafe(
|
|
382
|
-
return TKindOf(
|
|
383
|
+
function TUnsafe(value) {
|
|
384
|
+
return TKindOf(value, 'Unsafe');
|
|
383
385
|
}
|
|
384
386
|
exports.TUnsafe = TUnsafe;
|
|
385
|
-
function TVoid(
|
|
386
|
-
return (TKindOf(
|
|
387
|
-
|
|
388
|
-
IsOptionalString(
|
|
387
|
+
function TVoid(value) {
|
|
388
|
+
return (TKindOf(value, 'Void') &&
|
|
389
|
+
value.type === 'void' &&
|
|
390
|
+
IsOptionalString(value.$id));
|
|
389
391
|
}
|
|
390
392
|
exports.TVoid = TVoid;
|
|
391
|
-
function TKind(
|
|
392
|
-
return ValueGuard.IsObject(
|
|
393
|
+
function TKind(value) {
|
|
394
|
+
return ValueGuard.IsObject(value) && index_1.Kind in value && ValueGuard.IsString(value[index_1.Kind]) && !KnownTypes.includes(value[index_1.Kind]);
|
|
393
395
|
}
|
|
394
396
|
exports.TKind = TKind;
|
|
395
|
-
function TSchema(
|
|
396
|
-
return (ValueGuard.IsObject(
|
|
397
|
-
(0, index_7.TArray)(
|
|
398
|
-
(0, index_8.TBoolean)(
|
|
399
|
-
(0, index_9.TBigInt)(
|
|
400
|
-
(0, index_10.TAsyncIterator)(
|
|
401
|
-
(0, index_11.TConstructor)(
|
|
402
|
-
(0, index_12.TDate)(
|
|
403
|
-
(0, index_13.TFunction)(
|
|
404
|
-
(0, index_14.TInteger)(
|
|
405
|
-
(0, index_15.TIntersect)(
|
|
406
|
-
(0, index_16.TIterator)(
|
|
407
|
-
(0, index_3.TLiteral)(
|
|
408
|
-
(0, index_17.TMappedKey)(
|
|
409
|
-
(0, index_17.TMappedResult)(
|
|
410
|
-
(0, index_18.TNever)(
|
|
411
|
-
(0, index_19.TNot)(
|
|
412
|
-
(0, index_20.TNull)(
|
|
413
|
-
(0, index_21.TNumber)(
|
|
414
|
-
(0, index_4.TObject)(
|
|
415
|
-
(0, index_22.TPromise)(
|
|
416
|
-
(0, index_23.TRecord)(
|
|
417
|
-
(0, index_24.TRef)(
|
|
418
|
-
(0, index_25.TString)(
|
|
419
|
-
(0, index_26.TSymbol)(
|
|
420
|
-
(0, index_27.TTemplateLiteral)(
|
|
421
|
-
(0, index_28.TThis)(
|
|
422
|
-
(0, index_29.TTuple)(
|
|
423
|
-
(0, index_30.TUndefined)(
|
|
424
|
-
(0, index_5.TUnion)(
|
|
425
|
-
(0, index_31.TUint8Array)(
|
|
426
|
-
(0, index_32.TUnknown)(
|
|
427
|
-
(0, index_33.TUnsafe)(
|
|
428
|
-
(0, index_34.TVoid)(
|
|
429
|
-
TKind(
|
|
397
|
+
function TSchema(value) {
|
|
398
|
+
return (ValueGuard.IsObject(value)) && ((0, index_6.TAny)(value) ||
|
|
399
|
+
(0, index_7.TArray)(value) ||
|
|
400
|
+
(0, index_8.TBoolean)(value) ||
|
|
401
|
+
(0, index_9.TBigInt)(value) ||
|
|
402
|
+
(0, index_10.TAsyncIterator)(value) ||
|
|
403
|
+
(0, index_11.TConstructor)(value) ||
|
|
404
|
+
(0, index_12.TDate)(value) ||
|
|
405
|
+
(0, index_13.TFunction)(value) ||
|
|
406
|
+
(0, index_14.TInteger)(value) ||
|
|
407
|
+
(0, index_15.TIntersect)(value) ||
|
|
408
|
+
(0, index_16.TIterator)(value) ||
|
|
409
|
+
(0, index_3.TLiteral)(value) ||
|
|
410
|
+
(0, index_17.TMappedKey)(value) ||
|
|
411
|
+
(0, index_17.TMappedResult)(value) ||
|
|
412
|
+
(0, index_18.TNever)(value) ||
|
|
413
|
+
(0, index_19.TNot)(value) ||
|
|
414
|
+
(0, index_20.TNull)(value) ||
|
|
415
|
+
(0, index_21.TNumber)(value) ||
|
|
416
|
+
(0, index_4.TObject)(value) ||
|
|
417
|
+
(0, index_22.TPromise)(value) ||
|
|
418
|
+
(0, index_23.TRecord)(value) ||
|
|
419
|
+
(0, index_24.TRef)(value) ||
|
|
420
|
+
(0, index_25.TString)(value) ||
|
|
421
|
+
(0, index_26.TSymbol)(value) ||
|
|
422
|
+
(0, index_27.TTemplateLiteral)(value) ||
|
|
423
|
+
(0, index_28.TThis)(value) ||
|
|
424
|
+
(0, index_29.TTuple)(value) ||
|
|
425
|
+
(0, index_30.TUndefined)(value) ||
|
|
426
|
+
(0, index_5.TUnion)(value) ||
|
|
427
|
+
(0, index_31.TUint8Array)(value) ||
|
|
428
|
+
(0, index_32.TUnknown)(value) ||
|
|
429
|
+
(0, index_33.TUnsafe)(value) ||
|
|
430
|
+
(0, index_34.TVoid)(value) ||
|
|
431
|
+
TKind(value));
|
|
430
432
|
}
|
|
431
433
|
exports.TSchema = TSchema;
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./indexed-mapped-
|
|
17
|
+
__exportStar(require("./indexed-from-mapped-key"), exports);
|
|
18
18
|
__exportStar(require("./indexed-property-keys"), exports);
|
|
19
19
|
__exportStar(require("./indexed-result"), exports);
|
|
20
20
|
__exportStar(require("./indexed"), exports);
|