@sinclair/typebox 0.32.0-dev-11 → 0.32.0-dev-13
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/compiler/compiler.mjs +3 -3
- package/build/import/errors/errors.mjs +3 -3
- package/build/import/index.d.mts +6 -6
- package/build/import/index.mjs +4 -4
- package/build/import/type/composite/composite.d.mts +2 -2
- package/build/import/type/composite/composite.mjs +2 -2
- package/build/import/type/extends/extends-mapped-result-from-result.d.mts +13 -0
- package/build/import/type/extends/extends-mapped-result-from-result.mjs +14 -0
- package/build/import/type/extends/extends-mapped-result.d.mts +17 -0
- package/build/import/type/extends/extends-mapped-result.mjs +21 -0
- package/build/import/type/extends/extends.d.mts +8 -2
- package/build/import/type/extends/extends.mjs +7 -3
- package/build/import/type/extends/index.d.mts +2 -0
- package/build/import/type/extends/index.mjs +2 -0
- package/build/import/type/guard/type.d.mts +5 -1
- package/build/import/type/guard/type.mjs +18 -2
- package/build/import/type/indexed/index.d.mts +3 -2
- package/build/import/type/indexed/index.mjs +3 -2
- package/build/import/type/indexed/indexed-mapped-result.d.mts +16 -0
- package/build/import/type/indexed/indexed-mapped-result.mjs +18 -0
- package/build/import/type/indexed/{indexed-key.d.mts → indexed-property-keys.d.mts} +3 -3
- package/build/import/type/indexed/{indexed-key.mjs → indexed-property-keys.mjs} +2 -2
- package/build/import/type/indexed/{indexed-type.d.mts → indexed-result.d.mts} +2 -2
- package/build/import/type/indexed/{indexed-type.mjs → indexed-result.mjs} +1 -1
- package/build/import/type/indexed/indexed.d.mts +7 -4
- package/build/import/type/indexed/indexed.mjs +7 -6
- package/build/import/type/intrinsic/capitalize.d.mts +4 -0
- package/build/import/type/intrinsic/capitalize.mjs +5 -0
- package/build/import/type/intrinsic/index.d.mts +5 -0
- package/build/import/type/intrinsic/index.mjs +5 -0
- package/build/import/type/intrinsic/intrinsic-mapped-result.d.mts +15 -0
- package/build/import/type/intrinsic/intrinsic-mapped-result.mjs +21 -0
- package/build/import/type/intrinsic/intrinsic.d.mts +9 -14
- package/build/import/type/intrinsic/intrinsic.mjs +10 -21
- package/build/import/type/intrinsic/lowercase.d.mts +4 -0
- package/build/import/type/intrinsic/lowercase.mjs +5 -0
- package/build/import/type/intrinsic/uncapitalize.d.mts +4 -0
- package/build/import/type/intrinsic/uncapitalize.mjs +5 -0
- package/build/import/type/intrinsic/uppercase.d.mts +4 -0
- package/build/import/type/intrinsic/uppercase.mjs +5 -0
- package/build/import/type/keyof/index.d.mts +1 -2
- package/build/import/type/keyof/index.mjs +1 -2
- package/build/import/type/keyof/{keyof-string.d.mts → keyof-property-keys.d.mts} +4 -4
- package/build/import/type/keyof/{keyof-string.mjs → keyof-property-keys.mjs} +4 -4
- package/build/import/type/keyof/keyof.d.mts +12 -4
- package/build/import/type/keyof/keyof.mjs +14 -3
- package/build/import/type/mapped/index.d.mts +2 -0
- package/build/import/type/mapped/index.mjs +2 -0
- package/build/import/type/mapped/mapped-key.d.mts +8 -0
- package/build/import/type/mapped/mapped-key.mjs +7 -0
- package/build/import/type/mapped/mapped-result.d.mts +9 -0
- package/build/import/type/mapped/mapped-result.mjs +7 -0
- package/build/import/type/mapped/mapped.d.mts +39 -23
- package/build/import/type/mapped/mapped.mjs +65 -11
- package/build/import/type/omit/index.d.mts +1 -0
- package/build/import/type/omit/index.mjs +1 -0
- package/build/import/type/omit/omit-mapped-result.d.mts +15 -0
- package/build/import/type/omit/omit-mapped-result.mjs +20 -0
- package/build/import/type/omit/omit.d.mts +5 -2
- package/build/import/type/omit/omit.mjs +12 -6
- package/build/import/type/pick/index.d.mts +1 -0
- package/build/import/type/pick/index.mjs +1 -0
- package/build/import/type/pick/pick-mapped-result.d.mts +15 -0
- package/build/import/type/pick/pick-mapped-result.mjs +20 -0
- package/build/import/type/pick/pick.d.mts +5 -2
- package/build/import/type/pick/pick.mjs +12 -6
- package/build/import/type/record/record.mjs +4 -4
- package/build/import/type/type/json.d.mts +17 -8
- package/build/import/type/type/json.mjs +6 -2
- package/build/import/value/check/check.mjs +3 -3
- package/build/import/value/clean/clean.mjs +2 -2
- package/build/import/value/transform/decode.mjs +5 -5
- package/build/import/value/transform/encode.mjs +5 -5
- package/build/require/compiler/compiler.js +2 -2
- package/build/require/errors/errors.js +2 -2
- package/build/require/index.d.ts +6 -6
- package/build/require/index.js +9 -8
- package/build/require/type/composite/composite.d.ts +2 -2
- package/build/require/type/composite/composite.js +1 -1
- package/build/require/type/extends/extends-mapped-result-from-result.d.ts +13 -0
- package/build/require/type/extends/extends-mapped-result-from-result.js +18 -0
- package/build/require/type/extends/extends-mapped-result.d.ts +17 -0
- package/build/require/type/extends/extends-mapped-result.js +25 -0
- package/build/require/type/extends/extends.d.ts +8 -2
- package/build/require/type/extends/extends.js +8 -5
- package/build/require/type/extends/index.d.ts +2 -0
- package/build/require/type/extends/index.js +2 -0
- package/build/require/type/guard/type.d.ts +5 -1
- package/build/require/type/guard/type.js +53 -34
- package/build/require/type/indexed/index.d.ts +3 -2
- package/build/require/type/indexed/index.js +3 -2
- package/build/require/type/indexed/indexed-mapped-result.d.ts +16 -0
- package/build/require/type/indexed/indexed-mapped-result.js +22 -0
- package/build/require/type/indexed/{indexed-key.d.ts → indexed-property-keys.d.ts} +3 -3
- package/build/require/type/indexed/{indexed-key.js → indexed-property-keys.js} +4 -4
- package/build/require/type/indexed/{indexed-type.d.ts → indexed-result.d.ts} +2 -2
- package/build/require/type/indexed/{indexed-type.js → indexed-result.js} +3 -3
- package/build/require/type/indexed/indexed.d.ts +7 -4
- package/build/require/type/indexed/indexed.js +8 -7
- package/build/require/type/intrinsic/capitalize.d.ts +4 -0
- package/build/require/type/intrinsic/capitalize.js +9 -0
- package/build/require/type/intrinsic/index.d.ts +5 -0
- package/build/require/type/intrinsic/index.js +5 -0
- package/build/require/type/intrinsic/intrinsic-mapped-result.d.ts +15 -0
- package/build/require/type/intrinsic/intrinsic-mapped-result.js +25 -0
- package/build/require/type/intrinsic/intrinsic.d.ts +9 -14
- package/build/require/type/intrinsic/intrinsic.js +10 -25
- package/build/require/type/intrinsic/lowercase.d.ts +4 -0
- package/build/require/type/intrinsic/lowercase.js +9 -0
- package/build/require/type/intrinsic/uncapitalize.d.ts +4 -0
- package/build/require/type/intrinsic/uncapitalize.js +9 -0
- package/build/require/type/intrinsic/uppercase.d.ts +4 -0
- package/build/require/type/intrinsic/uppercase.js +9 -0
- package/build/require/type/keyof/index.d.ts +1 -2
- package/build/require/type/keyof/index.js +1 -2
- package/build/require/type/keyof/{keyof-string.d.ts → keyof-property-keys.d.ts} +4 -4
- package/build/require/type/keyof/{keyof-string.js → keyof-property-keys.js} +7 -7
- package/build/require/type/keyof/keyof.d.ts +12 -4
- package/build/require/type/keyof/keyof.js +14 -3
- package/build/require/type/mapped/index.d.ts +2 -0
- package/build/require/type/mapped/index.js +2 -0
- package/build/require/type/mapped/mapped-key.d.ts +8 -0
- package/build/require/type/mapped/mapped-key.js +11 -0
- package/build/require/type/mapped/mapped-result.d.ts +9 -0
- package/build/require/type/mapped/mapped-result.js +11 -0
- package/build/require/type/mapped/mapped.d.ts +39 -23
- package/build/require/type/mapped/mapped.js +65 -11
- package/build/require/type/omit/index.d.ts +1 -0
- package/build/require/type/omit/index.js +1 -0
- package/build/require/type/omit/omit-mapped-result.d.ts +15 -0
- package/build/require/type/omit/omit-mapped-result.js +24 -0
- package/build/require/type/omit/omit.d.ts +5 -2
- package/build/require/type/omit/omit.js +10 -4
- package/build/require/type/pick/index.d.ts +1 -0
- package/build/require/type/pick/index.js +1 -0
- package/build/require/type/pick/pick-mapped-result.d.ts +15 -0
- package/build/require/type/pick/pick-mapped-result.js +24 -0
- package/build/require/type/pick/pick.d.ts +5 -2
- package/build/require/type/pick/pick.js +10 -4
- package/build/require/type/record/record.js +2 -2
- package/build/require/type/type/json.d.ts +17 -8
- package/build/require/type/type/json.js +54 -50
- package/build/require/value/check/check.js +2 -2
- package/build/require/value/clean/clean.js +15 -15
- package/build/require/value/transform/decode.js +3 -3
- package/build/require/value/transform/encode.js +3 -3
- package/package.json +1 -1
- package/readme.md +115 -47
- package/build/import/type/keyof/keyof-type.d.mts +0 -11
- package/build/import/type/keyof/keyof-type.mjs +0 -15
- package/build/require/type/keyof/keyof-type.d.ts +0 -11
- package/build/require/type/keyof/keyof-type.js +0 -19
|
@@ -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.TLiteral = exports.TLiteralBoolean = exports.TLiteralNumber = exports.TLiteralString = exports.TKindOf = exports.TIterator = exports.TIntersect = 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.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 {
|
|
@@ -20,6 +20,8 @@ const KnownTypes = [
|
|
|
20
20
|
'Intersect',
|
|
21
21
|
'Iterator',
|
|
22
22
|
'Literal',
|
|
23
|
+
'MappedKey',
|
|
24
|
+
'MappedResult',
|
|
23
25
|
'Not',
|
|
24
26
|
'Null',
|
|
25
27
|
'Number',
|
|
@@ -172,6 +174,11 @@ function TInteger(schema) {
|
|
|
172
174
|
IsOptionalNumber(schema.multipleOf));
|
|
173
175
|
}
|
|
174
176
|
exports.TInteger = TInteger;
|
|
177
|
+
function TProperties(schema) {
|
|
178
|
+
return (ValueGuard.IsObject(schema) &&
|
|
179
|
+
Object.entries(schema).every(([key, schema]) => IsControlCharacterFree(key) && (0, index_2.TSchema)(schema)));
|
|
180
|
+
}
|
|
181
|
+
exports.TProperties = TProperties;
|
|
175
182
|
function TIntersect(schema) {
|
|
176
183
|
return (TKindOf(schema, 'Intersect') &&
|
|
177
184
|
(ValueGuard.IsString(schema.type) && schema.type !== 'object' ? false : true) &&
|
|
@@ -212,6 +219,17 @@ function TLiteral(schema) {
|
|
|
212
219
|
ValueGuard.IsString(schema.const)));
|
|
213
220
|
}
|
|
214
221
|
exports.TLiteral = TLiteral;
|
|
222
|
+
function TMappedKey(schema) {
|
|
223
|
+
return (TKindOf(schema, 'MappedKey') &&
|
|
224
|
+
ValueGuard.IsArray(schema.keys) &&
|
|
225
|
+
schema.keys.every(key => ValueGuard.IsNumber(key) || ValueGuard.IsString(key)));
|
|
226
|
+
}
|
|
227
|
+
exports.TMappedKey = TMappedKey;
|
|
228
|
+
function TMappedResult(schema) {
|
|
229
|
+
return (TKindOf(schema, 'MappedResult') &&
|
|
230
|
+
(0, index_4.TProperties)(schema.properties));
|
|
231
|
+
}
|
|
232
|
+
exports.TMappedResult = TMappedResult;
|
|
215
233
|
function TNever(schema) {
|
|
216
234
|
return (TKindOf(schema, 'Never') &&
|
|
217
235
|
ValueGuard.IsObject(schema.not) &&
|
|
@@ -244,8 +262,7 @@ function TObject(schema) {
|
|
|
244
262
|
return (TKindOf(schema, 'Object') &&
|
|
245
263
|
schema.type === 'object' &&
|
|
246
264
|
IsOptionalString(schema.$id) &&
|
|
247
|
-
|
|
248
|
-
Object.entries(schema.properties).every(([key, schema]) => IsControlCharacterFree(key) && (0, index_2.TSchema)(schema)) &&
|
|
265
|
+
(0, index_4.TProperties)(schema.properties) &&
|
|
249
266
|
IsAdditionalProperties(schema.additionalProperties) &&
|
|
250
267
|
IsOptionalNumber(schema.minProperties) &&
|
|
251
268
|
IsOptionalNumber(schema.maxProperties));
|
|
@@ -337,7 +354,7 @@ function TUndefined(schema) {
|
|
|
337
354
|
}
|
|
338
355
|
exports.TUndefined = TUndefined;
|
|
339
356
|
function TUnionLiteral(schema) {
|
|
340
|
-
return (0,
|
|
357
|
+
return (0, index_5.TUnion)(schema) && schema.anyOf.every((schema) => TLiteralString(schema) || TLiteralNumber(schema));
|
|
341
358
|
}
|
|
342
359
|
exports.TUnionLiteral = TUnionLiteral;
|
|
343
360
|
function TUnion(schema) {
|
|
@@ -376,37 +393,39 @@ function TKind(schema) {
|
|
|
376
393
|
}
|
|
377
394
|
exports.TKind = TKind;
|
|
378
395
|
function TSchema(schema) {
|
|
379
|
-
return (ValueGuard.IsObject(schema)) && ((0,
|
|
380
|
-
(0,
|
|
381
|
-
(0,
|
|
382
|
-
(0,
|
|
383
|
-
(0,
|
|
384
|
-
(0,
|
|
385
|
-
(0,
|
|
386
|
-
(0,
|
|
387
|
-
(0,
|
|
388
|
-
(0,
|
|
389
|
-
(0,
|
|
396
|
+
return (ValueGuard.IsObject(schema)) && ((0, index_6.TAny)(schema) ||
|
|
397
|
+
(0, index_7.TArray)(schema) ||
|
|
398
|
+
(0, index_8.TBoolean)(schema) ||
|
|
399
|
+
(0, index_9.TBigInt)(schema) ||
|
|
400
|
+
(0, index_10.TAsyncIterator)(schema) ||
|
|
401
|
+
(0, index_11.TConstructor)(schema) ||
|
|
402
|
+
(0, index_12.TDate)(schema) ||
|
|
403
|
+
(0, index_13.TFunction)(schema) ||
|
|
404
|
+
(0, index_14.TInteger)(schema) ||
|
|
405
|
+
(0, index_15.TIntersect)(schema) ||
|
|
406
|
+
(0, index_16.TIterator)(schema) ||
|
|
390
407
|
(0, index_3.TLiteral)(schema) ||
|
|
391
|
-
(0,
|
|
392
|
-
(0, index_17.
|
|
393
|
-
(0, index_18.
|
|
394
|
-
(0, index_19.
|
|
395
|
-
(0, index_20.
|
|
396
|
-
(0, index_21.
|
|
397
|
-
(0,
|
|
398
|
-
(0,
|
|
399
|
-
(0,
|
|
400
|
-
(0,
|
|
401
|
-
(0,
|
|
402
|
-
(0,
|
|
403
|
-
(0,
|
|
404
|
-
(0,
|
|
405
|
-
(0,
|
|
406
|
-
(0, index_30.
|
|
407
|
-
(0,
|
|
408
|
-
(0,
|
|
409
|
-
(0,
|
|
408
|
+
(0, index_17.TMappedKey)(schema) ||
|
|
409
|
+
(0, index_17.TMappedResult)(schema) ||
|
|
410
|
+
(0, index_18.TNever)(schema) ||
|
|
411
|
+
(0, index_19.TNot)(schema) ||
|
|
412
|
+
(0, index_20.TNull)(schema) ||
|
|
413
|
+
(0, index_21.TNumber)(schema) ||
|
|
414
|
+
(0, index_4.TObject)(schema) ||
|
|
415
|
+
(0, index_22.TPromise)(schema) ||
|
|
416
|
+
(0, index_23.TRecord)(schema) ||
|
|
417
|
+
(0, index_24.TRef)(schema) ||
|
|
418
|
+
(0, index_25.TString)(schema) ||
|
|
419
|
+
(0, index_26.TSymbol)(schema) ||
|
|
420
|
+
(0, index_27.TTemplateLiteral)(schema) ||
|
|
421
|
+
(0, index_28.TThis)(schema) ||
|
|
422
|
+
(0, index_29.TTuple)(schema) ||
|
|
423
|
+
(0, index_30.TUndefined)(schema) ||
|
|
424
|
+
(0, index_5.TUnion)(schema) ||
|
|
425
|
+
(0, index_31.TUint8Array)(schema) ||
|
|
426
|
+
(0, index_32.TUnknown)(schema) ||
|
|
427
|
+
(0, index_33.TUnsafe)(schema) ||
|
|
428
|
+
(0, index_34.TVoid)(schema) ||
|
|
410
429
|
TKind(schema));
|
|
411
430
|
}
|
|
412
431
|
exports.TSchema = TSchema;
|
|
@@ -14,6 +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-
|
|
18
|
-
__exportStar(require("./indexed-
|
|
17
|
+
__exportStar(require("./indexed-mapped-result"), exports);
|
|
18
|
+
__exportStar(require("./indexed-property-keys"), exports);
|
|
19
|
+
__exportStar(require("./indexed-result"), exports);
|
|
19
20
|
__exportStar(require("./indexed"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type TSchema } from '../schema/index';
|
|
2
|
+
import { type TProperties } from '../object/index';
|
|
3
|
+
import { type TIndexResult } from './indexed-result';
|
|
4
|
+
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
5
|
+
import { Evaluate } from '../helpers/index';
|
|
6
|
+
type MappedIndexPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
7
|
+
[_ in K]: TIndexResult<T, [K]>;
|
|
8
|
+
};
|
|
9
|
+
declare function MappedIndexPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): MappedIndexPropertyKey<T, K>;
|
|
10
|
+
type MappedIndexPropertyKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? MappedIndexPropertyKey<T, L> & MappedIndexPropertyKeys<T, R> : {});
|
|
11
|
+
declare function MappedIndexPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): MappedIndexPropertyKeys<T, K>;
|
|
12
|
+
type MappedIndexProperties<T extends TSchema, K extends TMappedKey> = Evaluate<MappedIndexPropertyKeys<T, K['keys']>>;
|
|
13
|
+
declare function MappedIndexProperties<T extends TSchema, K extends TMappedKey>(T: T, K: K): MappedIndexProperties<T, K>;
|
|
14
|
+
export type TIndexMappedResult<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedIndexProperties<T, K>> = (TMappedResult<P>);
|
|
15
|
+
export declare function IndexMappedResult<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedIndexProperties<T, K>>(T: T, K: K): TMappedResult<P>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexMappedResult = void 0;
|
|
4
|
+
const indexed_result_1 = require("./indexed-result");
|
|
5
|
+
const index_1 = require("../mapped/index");
|
|
6
|
+
function MappedIndexPropertyKey(T, K) {
|
|
7
|
+
return { [K]: (0, indexed_result_1.IndexResult)(T, [K]) };
|
|
8
|
+
}
|
|
9
|
+
function MappedIndexPropertyKeys(T, K) {
|
|
10
|
+
const [L, ...R] = K;
|
|
11
|
+
return (K.length > 0
|
|
12
|
+
? { ...MappedIndexPropertyKey(T, L), ...MappedIndexPropertyKeys(T, R) }
|
|
13
|
+
: {});
|
|
14
|
+
}
|
|
15
|
+
function MappedIndexProperties(T, K) {
|
|
16
|
+
return MappedIndexPropertyKeys(T, K.keys);
|
|
17
|
+
}
|
|
18
|
+
function IndexMappedResult(T, K) {
|
|
19
|
+
const P = MappedIndexProperties(T, K);
|
|
20
|
+
return (0, index_1.MappedResult)(P);
|
|
21
|
+
}
|
|
22
|
+
exports.IndexMappedResult = IndexMappedResult;
|
|
@@ -6,11 +6,11 @@ import { type TSchema } from '../schema/index';
|
|
|
6
6
|
import { type TUnion } from '../union/index';
|
|
7
7
|
type FromTemplateLiteral<T extends TTemplateLiteral, F = IsTemplateLiteralFinite<T>> = (F extends true ? TemplateLiteralGenerate<T> extends infer R extends string[] ? R : [] : []);
|
|
8
8
|
declare function FromTemplateLiteral<T extends TTemplateLiteral>(T: T): FromTemplateLiteral<T>;
|
|
9
|
-
type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [...
|
|
9
|
+
type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [...TIndexPropertyKeys<L>, ...FromUnion<R>] : []);
|
|
10
10
|
declare function FromUnion<T extends TSchema[]>(T: T): FromUnion<T>;
|
|
11
11
|
type FromLiteral<T extends TLiteralValue> = (T extends PropertyKey ? [`${T}`] : []);
|
|
12
12
|
declare function FromLiteral<T extends TLiteralValue>(T: T): FromLiteral<T>;
|
|
13
|
-
export type
|
|
13
|
+
export type TIndexPropertyKeys<T extends TSchema> = (T extends TTemplateLiteral ? FromTemplateLiteral<T> : T extends TUnion<infer S> ? FromUnion<S> : T extends TLiteral<infer S> ? FromLiteral<S> : T extends TNumber ? ['[number]'] : T extends TInteger ? ['[number]'] : [
|
|
14
14
|
]);
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function IndexPropertyKeys<T extends TSchema>(T: T): TIndexPropertyKeys<T>;
|
|
16
16
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IndexPropertyKeys = void 0;
|
|
4
4
|
const index_1 = require("../template-literal/index");
|
|
5
5
|
const type_1 = require("../guard/type");
|
|
6
6
|
function FromTemplateLiteral(T) {
|
|
@@ -16,13 +16,13 @@ function FromTemplateLiteral(T) {
|
|
|
16
16
|
function FromUnion(T) {
|
|
17
17
|
const [L, ...R] = T;
|
|
18
18
|
return (T.length > 0
|
|
19
|
-
? [...
|
|
19
|
+
? [...IndexPropertyKeys(L), ...FromUnion(R)]
|
|
20
20
|
: []);
|
|
21
21
|
}
|
|
22
22
|
function FromLiteral(T) {
|
|
23
23
|
return ([T.toString()]);
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function IndexPropertyKeys(T) {
|
|
26
26
|
return [...new Set(((0, type_1.TTemplateLiteral)(T) ? FromTemplateLiteral(T) :
|
|
27
27
|
(0, type_1.TUnion)(T) ? FromUnion(T.anyOf) :
|
|
28
28
|
(0, type_1.TLiteral)(T) ? FromLiteral(T.const) :
|
|
@@ -30,4 +30,4 @@ function IndexedKeyResolve(T) {
|
|
|
30
30
|
(0, type_1.TInteger)(T) ? ['[number]'] :
|
|
31
31
|
[]))];
|
|
32
32
|
}
|
|
33
|
-
exports.
|
|
33
|
+
exports.IndexPropertyKeys = IndexPropertyKeys;
|
|
@@ -28,6 +28,6 @@ type FromKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<i
|
|
|
28
28
|
declare function FromKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): FromKey<T, K>;
|
|
29
29
|
type FromKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? [FromKey<T, L>, ...FromKeys<T, R>] : []);
|
|
30
30
|
declare function FromKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromKeys<T, K>;
|
|
31
|
-
export type
|
|
32
|
-
export declare function
|
|
31
|
+
export type TIndexResult<T extends TSchema, K extends PropertyKey[]> = (UnionResolve<FromKeys<T, K>>);
|
|
32
|
+
export declare function IndexResult<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): TIndexResult<T, K>;
|
|
33
33
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.IndexResult = void 0;
|
|
4
4
|
const index_1 = require("../never/index");
|
|
5
5
|
const index_2 = require("../intersect/index");
|
|
6
6
|
const index_3 = require("../union/index");
|
|
@@ -62,7 +62,7 @@ function FromKeys(T, K) {
|
|
|
62
62
|
? [FromKey(T, L), ...FromKeys(T, R)]
|
|
63
63
|
: []);
|
|
64
64
|
}
|
|
65
|
-
function
|
|
65
|
+
function IndexResult(T, K) {
|
|
66
66
|
return ((0, index_3.UnionResolve)(FromKeys(T, K)));
|
|
67
67
|
}
|
|
68
|
-
exports.
|
|
68
|
+
exports.IndexResult = IndexResult;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { type TIndexResult } from './indexed-result';
|
|
3
|
+
import { type TIndexPropertyKeys } from './indexed-property-keys';
|
|
4
|
+
import { type TIndexMappedResult } from './indexed-mapped-result';
|
|
5
|
+
import { TMappedKey } from '../mapped/index';
|
|
6
|
+
export type TIndex<T extends TSchema, K extends PropertyKey[]> = TIndexResult<T, K>;
|
|
7
|
+
export declare function Index<T extends TSchema, K extends TMappedKey>(T: T, K: K): TIndexMappedResult<T, K>;
|
|
8
|
+
export declare function Index<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TIndex<T, I>;
|
|
6
9
|
export declare function Index<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TIndex<T, K>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Index = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const type_1 = require("../guard/type");
|
|
5
|
+
const indexed_result_1 = require("./indexed-result");
|
|
6
|
+
const indexed_property_keys_1 = require("./indexed-property-keys");
|
|
7
|
+
const indexed_mapped_result_1 = require("./indexed-mapped-result");
|
|
8
|
+
const type_2 = require("../clone/type");
|
|
8
9
|
function Index(T, K, options = {}) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
return ((0, type_1.TMappedKey)(K) ? (0, type_2.CloneType)((0, indexed_mapped_result_1.IndexMappedResult)(T, K), options) :
|
|
11
|
+
(0, type_1.TSchema)(K) ? (0, type_2.CloneType)((0, indexed_result_1.IndexResult)(T, (0, indexed_property_keys_1.IndexPropertyKeys)(K)), options) :
|
|
12
|
+
(0, type_2.CloneType)((0, indexed_result_1.IndexResult)(T, K), options));
|
|
12
13
|
}
|
|
13
14
|
exports.Index = Index;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { TIntrinsic } from './intrinsic';
|
|
3
|
+
export type TCapitalize<T extends TSchema> = TIntrinsic<T, 'Capitalize'>;
|
|
4
|
+
export declare function Capitalize<T extends TSchema>(T: T, options?: SchemaOptions): TCapitalize<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Capitalize = void 0;
|
|
4
|
+
const intrinsic_1 = require("./intrinsic");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
function Capitalize(T, options = {}) {
|
|
7
|
+
return (0, type_1.CloneType)((0, intrinsic_1.Intrinsic)(T, 'Capitalize'), options);
|
|
8
|
+
}
|
|
9
|
+
exports.Capitalize = Capitalize;
|
|
@@ -14,4 +14,9 @@ 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("./capitalize"), exports);
|
|
18
|
+
__exportStar(require("./intrinsic-mapped-result"), exports);
|
|
17
19
|
__exportStar(require("./intrinsic"), exports);
|
|
20
|
+
__exportStar(require("./lowercase"), exports);
|
|
21
|
+
__exportStar(require("./uncapitalize"), exports);
|
|
22
|
+
__exportStar(require("./uppercase"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TProperties } from '../object/index';
|
|
2
|
+
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
3
|
+
import { type TIntrinsic, type IntrinsicMode } from './intrinsic';
|
|
4
|
+
import { TLiteral, TLiteralValue } from '../literal/index';
|
|
5
|
+
type MappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode, P extends TLiteralValue = K extends TLiteralValue ? K : never> = {
|
|
6
|
+
[_ in K]: TIntrinsic<TLiteral<P>, M>;
|
|
7
|
+
};
|
|
8
|
+
declare function MappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode>(K: K, M: M): MappedIntrinsicPropertyKey<K, M>;
|
|
9
|
+
type MappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? MappedIntrinsicPropertyKey<L, M> & MappedIntrinsicPropertyKeys<R, M> : {});
|
|
10
|
+
declare function MappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode>(K: [...K], M: M): MappedIntrinsicPropertyKeys<K, M>;
|
|
11
|
+
type MappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode> = (MappedIntrinsicPropertyKeys<K['keys'], M>);
|
|
12
|
+
declare function MappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode>(T: K, M: M): MappedIntrinsicProperties<K, M>;
|
|
13
|
+
export type TIntrinsicMappedResult<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>> = (TMappedResult<P>);
|
|
14
|
+
export declare function IntrinsicMappedResult<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>>(T: K, M: M): TMappedResult<P>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntrinsicMappedResult = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const intrinsic_1 = require("./intrinsic");
|
|
6
|
+
const index_2 = require("../literal/index");
|
|
7
|
+
function MappedIntrinsicPropertyKey(K, M) {
|
|
8
|
+
return {
|
|
9
|
+
[K]: (0, intrinsic_1.Intrinsic)((0, index_2.Literal)(K), M)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function MappedIntrinsicPropertyKeys(K, M) {
|
|
13
|
+
const [L, ...R] = K;
|
|
14
|
+
return (K.length > 0
|
|
15
|
+
? { ...MappedIntrinsicPropertyKey(L, M), ...MappedIntrinsicPropertyKeys(R, M) }
|
|
16
|
+
: {});
|
|
17
|
+
}
|
|
18
|
+
function MappedIntrinsicProperties(T, M) {
|
|
19
|
+
return MappedIntrinsicPropertyKeys(T['keys'], M);
|
|
20
|
+
}
|
|
21
|
+
function IntrinsicMappedResult(T, M) {
|
|
22
|
+
const P = MappedIntrinsicProperties(T, M);
|
|
23
|
+
return (0, index_1.MappedResult)(P);
|
|
24
|
+
}
|
|
25
|
+
exports.IntrinsicMappedResult = IntrinsicMappedResult;
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import type { TSchema
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
2
2
|
import { type TTemplateLiteral, type TTemplateLiteralKind } from '../template-literal/index';
|
|
3
|
+
import { type TIntrinsicMappedResult } from './intrinsic-mapped-result';
|
|
3
4
|
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
4
5
|
import { type TUnion } from '../union/index';
|
|
5
|
-
|
|
6
|
-
type
|
|
6
|
+
import { type TMappedKey } from '../mapped/index';
|
|
7
|
+
export type IntrinsicMode = 'Uppercase' | 'Lowercase' | 'Capitalize' | 'Uncapitalize';
|
|
8
|
+
type FromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode> = M extends IntrinsicMode ? T extends [infer L extends TTemplateLiteralKind, ...infer R extends TTemplateLiteralKind[]] ? [TIntrinsic<L, M>, ...FromTemplateLiteral<R, M>] : T : T;
|
|
7
9
|
declare function FromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode>(schema: TTemplateLiteral, mode: IntrinsicMode): FromTemplateLiteral<T, M>;
|
|
8
10
|
type FromLiteralValue<T, M extends IntrinsicMode> = (T extends string ? M extends 'Uncapitalize' ? Uncapitalize<T> : M extends 'Capitalize' ? Capitalize<T> : M extends 'Uppercase' ? Uppercase<T> : M extends 'Lowercase' ? Lowercase<T> : string : T);
|
|
9
11
|
declare function FromLiteralValue(value: TLiteralValue, mode: IntrinsicMode): string;
|
|
10
|
-
type FromRest<T extends TSchema[], M extends IntrinsicMode> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [
|
|
12
|
+
type FromRest<T extends TSchema[], M extends IntrinsicMode> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [TIntrinsic<L, M>, ...FromRest<R, M>] : [];
|
|
11
13
|
declare function FromRest<T extends TSchema[], M extends IntrinsicMode>(T: [...T], mode: M): FromRest<T, M>;
|
|
12
|
-
export type
|
|
13
|
-
export declare function
|
|
14
|
-
export
|
|
15
|
-
export declare function Uncapitalize<T extends TSchema>(T: T, options?: SchemaOptions): TUncapitalize<T>;
|
|
16
|
-
export type TUppercase<T extends TSchema> = IntrinsicResolve<T, 'Uppercase'>;
|
|
17
|
-
export declare function Uppercase<T extends TSchema>(T: T, options?: SchemaOptions): TUppercase<T>;
|
|
18
|
-
export type TLowercase<T extends TSchema> = IntrinsicResolve<T, 'Lowercase'>;
|
|
19
|
-
export declare function Lowercase<T extends TSchema>(T: T, options?: SchemaOptions): TLowercase<T>;
|
|
20
|
-
export type TCapitalize<T extends TSchema> = IntrinsicResolve<T, 'Capitalize'>;
|
|
21
|
-
export declare function Capitalize<T extends TSchema>(T: T, options?: SchemaOptions): TCapitalize<T>;
|
|
14
|
+
export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicMappedResult<T, M> : T extends TTemplateLiteral<infer S> ? TTemplateLiteral<FromTemplateLiteral<S, M>> : T extends TUnion<infer S> ? TUnion<FromRest<S, M>> : T extends TLiteral<infer S> ? TLiteral<FromLiteralValue<S, M>> : T;
|
|
15
|
+
export declare function Intrinsic<T extends TMappedKey, M extends IntrinsicMode>(schema: T, mode: M): TIntrinsicMappedResult<T, M>;
|
|
16
|
+
export declare function Intrinsic<T extends TSchema, M extends IntrinsicMode>(schema: T, mode: M): TIntrinsic<T, M>;
|
|
22
17
|
export {};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.Intrinsic = void 0;
|
|
4
4
|
const index_1 = require("../template-literal/index");
|
|
5
|
+
const intrinsic_mapped_result_1 = require("./intrinsic-mapped-result");
|
|
5
6
|
const index_2 = require("../literal/index");
|
|
6
7
|
const index_3 = require("../union/index");
|
|
7
8
|
const type_1 = require("../guard/type");
|
|
8
|
-
const type_2 = require("../clone/type");
|
|
9
9
|
function ApplyUncapitalize(value) {
|
|
10
10
|
const [first, rest] = [value.slice(0, 1), value.slice(1)];
|
|
11
11
|
return [first.toLowerCase(), rest].join('');
|
|
@@ -40,28 +40,13 @@ function FromLiteralValue(value, mode) {
|
|
|
40
40
|
}
|
|
41
41
|
function FromRest(T, mode) {
|
|
42
42
|
const [L, ...R] = T;
|
|
43
|
-
return (T.length > 0 ? [
|
|
43
|
+
return (T.length > 0 ? [Intrinsic(L, mode), ...FromRest(R, mode)] : []);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
return ((0, type_1.
|
|
47
|
-
(0, type_1.
|
|
48
|
-
(0, type_1.
|
|
49
|
-
schema)
|
|
45
|
+
function Intrinsic(schema, mode) {
|
|
46
|
+
return ((0, type_1.TMappedKey)(schema) ? (0, intrinsic_mapped_result_1.IntrinsicMappedResult)(schema, mode) :
|
|
47
|
+
(0, type_1.TTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode) :
|
|
48
|
+
(0, type_1.TUnion)(schema) ? (0, index_3.Union)(FromRest(schema.anyOf, mode)) :
|
|
49
|
+
(0, type_1.TLiteral)(schema) ? (0, index_2.Literal)(FromLiteralValue(schema.const, mode)) :
|
|
50
|
+
schema);
|
|
50
51
|
}
|
|
51
|
-
exports.
|
|
52
|
-
function Uncapitalize(T, options = {}) {
|
|
53
|
-
return (0, type_2.CloneType)(IntrinsicResolve(T, 'Uncapitalize'), options);
|
|
54
|
-
}
|
|
55
|
-
exports.Uncapitalize = Uncapitalize;
|
|
56
|
-
function Uppercase(T, options = {}) {
|
|
57
|
-
return (0, type_2.CloneType)(IntrinsicResolve(T, 'Uppercase'), options);
|
|
58
|
-
}
|
|
59
|
-
exports.Uppercase = Uppercase;
|
|
60
|
-
function Lowercase(T, options = {}) {
|
|
61
|
-
return (0, type_2.CloneType)(IntrinsicResolve(T, 'Lowercase'), options);
|
|
62
|
-
}
|
|
63
|
-
exports.Lowercase = Lowercase;
|
|
64
|
-
function Capitalize(T, options = {}) {
|
|
65
|
-
return (0, type_2.CloneType)(IntrinsicResolve(T, 'Capitalize'), options);
|
|
66
|
-
}
|
|
67
|
-
exports.Capitalize = Capitalize;
|
|
52
|
+
exports.Intrinsic = Intrinsic;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { TIntrinsic } from './intrinsic';
|
|
3
|
+
export type TLowercase<T extends TSchema> = TIntrinsic<T, 'Lowercase'>;
|
|
4
|
+
export declare function Lowercase<T extends TSchema>(T: T, options?: SchemaOptions): TLowercase<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Lowercase = void 0;
|
|
4
|
+
const intrinsic_1 = require("./intrinsic");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
function Lowercase(T, options = {}) {
|
|
7
|
+
return (0, type_1.CloneType)((0, intrinsic_1.Intrinsic)(T, 'Lowercase'), options);
|
|
8
|
+
}
|
|
9
|
+
exports.Lowercase = Lowercase;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { TIntrinsic } from './intrinsic';
|
|
3
|
+
export type TUncapitalize<T extends TSchema> = TIntrinsic<T, 'Uncapitalize'>;
|
|
4
|
+
export declare function Uncapitalize<T extends TSchema>(T: T, options?: SchemaOptions): TUncapitalize<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Uncapitalize = void 0;
|
|
4
|
+
const intrinsic_1 = require("./intrinsic");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
function Uncapitalize(T, options = {}) {
|
|
7
|
+
return (0, type_1.CloneType)((0, intrinsic_1.Intrinsic)(T, 'Uncapitalize'), options);
|
|
8
|
+
}
|
|
9
|
+
exports.Uncapitalize = Uncapitalize;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import { TIntrinsic } from './intrinsic';
|
|
3
|
+
export type TUppercase<T extends TSchema> = TIntrinsic<T, 'Uppercase'>;
|
|
4
|
+
export declare function Uppercase<T extends TSchema>(T: T, options?: SchemaOptions): TUppercase<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Uppercase = void 0;
|
|
4
|
+
const intrinsic_1 = require("./intrinsic");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
function Uppercase(T, options = {}) {
|
|
7
|
+
return (0, type_1.CloneType)((0, intrinsic_1.Intrinsic)(T, 'Uppercase'), options);
|
|
8
|
+
}
|
|
9
|
+
exports.Uppercase = Uppercase;
|
|
@@ -14,6 +14,5 @@ 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("./keyof-
|
|
18
|
-
__exportStar(require("./keyof-type"), exports);
|
|
17
|
+
__exportStar(require("./keyof-property-keys"), exports);
|
|
19
18
|
__exportStar(require("./keyof"), exports);
|
|
@@ -7,7 +7,7 @@ import type { TTuple } from '../tuple/index';
|
|
|
7
7
|
import type { TArray } from '../array/index';
|
|
8
8
|
import type { TObject, TProperties } from '../object/index';
|
|
9
9
|
import { OperatorUnionMany, OperatorIntersectMany } from '../operators/index';
|
|
10
|
-
type FromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [
|
|
10
|
+
type FromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [KeyOfPropertyKeys<L>, ...FromRest<R>] : []);
|
|
11
11
|
declare function FromRest<T extends TSchema[]>(T: [...T]): FromRest<T>;
|
|
12
12
|
type FromIntersect<T extends TSchema[], C extends PropertyKey[][] = FromRest<T>> = (OperatorUnionMany<C>);
|
|
13
13
|
declare function FromIntersect<T extends TSchema[]>(T: [...T], C?: FromRest<T>): FromIntersect<T>;
|
|
@@ -21,8 +21,8 @@ type FromArray<_ extends TSchema> = ([
|
|
|
21
21
|
declare function FromArray<_ extends TSchema>(_: _): FromArray<_>;
|
|
22
22
|
type FromProperties<T extends TProperties> = (UnionToTuple<keyof T>);
|
|
23
23
|
declare function FromProperties<T extends TProperties>(T: T): FromProperties<T>;
|
|
24
|
-
export type
|
|
24
|
+
export type KeyOfPropertyKeys<T extends TSchema> = (T extends TRecursive<infer S> ? KeyOfPropertyKeys<S> : T extends TIntersect<infer S> ? FromIntersect<S> : T extends TUnion<infer S> ? FromUnion<S> : T extends TTuple<infer S> ? FromTuple<S> : T extends TArray<infer S> ? FromArray<S> : T extends TObject<infer S> ? FromProperties<S> : [
|
|
25
25
|
]);
|
|
26
|
-
export declare function
|
|
27
|
-
export declare function
|
|
26
|
+
export declare function KeyOfPropertyKeys<T extends TSchema>(T: T): KeyOfPropertyKeys<T>;
|
|
27
|
+
export declare function KeyOfPattern(schema: TSchema): string;
|
|
28
28
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.KeyOfPattern = exports.KeyOfPropertyKeys = void 0;
|
|
4
4
|
const index_1 = require("../helpers/index");
|
|
5
5
|
const index_2 = require("../operators/index");
|
|
6
6
|
const type_1 = require("../guard/type");
|
|
7
7
|
function FromRest(T) {
|
|
8
8
|
const [L, ...R] = T;
|
|
9
9
|
return (T.length > 0
|
|
10
|
-
? [
|
|
10
|
+
? [KeyOfPropertyKeys(L), ...FromRest(R)]
|
|
11
11
|
: []);
|
|
12
12
|
}
|
|
13
13
|
function FromIntersect(T, C = FromRest(T)) {
|
|
@@ -39,7 +39,7 @@ function FromPatternProperties(patternProperties) {
|
|
|
39
39
|
: key;
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
function
|
|
42
|
+
function KeyOfPropertyKeys(T) {
|
|
43
43
|
return ((0, type_1.TIntersect)(T) ? FromIntersect(T.allOf) :
|
|
44
44
|
(0, type_1.TUnion)(T) ? FromUnion(T.anyOf) :
|
|
45
45
|
(0, type_1.TTuple)(T) ? FromTuple(T.items ?? []) :
|
|
@@ -48,13 +48,13 @@ function KeyOfStringResolve(T) {
|
|
|
48
48
|
(0, type_1.TRecord)(T) ? FromPatternProperties(T.patternProperties) :
|
|
49
49
|
[]);
|
|
50
50
|
}
|
|
51
|
-
exports.
|
|
51
|
+
exports.KeyOfPropertyKeys = KeyOfPropertyKeys;
|
|
52
52
|
let includePatternProperties = false;
|
|
53
|
-
function
|
|
53
|
+
function KeyOfPattern(schema) {
|
|
54
54
|
includePatternProperties = true;
|
|
55
|
-
const keys =
|
|
55
|
+
const keys = KeyOfPropertyKeys(schema);
|
|
56
56
|
includePatternProperties = false;
|
|
57
57
|
const pattern = keys.map((key) => `(${key})`);
|
|
58
58
|
return `^(${pattern.join('|')})$`;
|
|
59
59
|
}
|
|
60
|
-
exports.
|
|
60
|
+
exports.KeyOfPattern = KeyOfPattern;
|