@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
package/build/require/type/indexed/{indexed-mapped-result.d.ts → indexed-from-mapped-key.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import { type TProperties } from '../object/index';
|
|
3
3
|
import { type TIndexResult } from './indexed-result';
|
|
4
4
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
@@ -6,11 +6,11 @@ import { Evaluate } from '../helpers/index';
|
|
|
6
6
|
type MappedIndexPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
7
7
|
[_ in K]: TIndexResult<T, [K]>;
|
|
8
8
|
};
|
|
9
|
-
declare function MappedIndexPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): MappedIndexPropertyKey<T, K>;
|
|
9
|
+
declare function MappedIndexPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K, options: SchemaOptions): MappedIndexPropertyKey<T, K>;
|
|
10
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>;
|
|
11
|
+
declare function MappedIndexPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K], options: SchemaOptions): MappedIndexPropertyKeys<T, K>;
|
|
12
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
|
|
15
|
-
export declare function
|
|
13
|
+
declare function MappedIndexProperties<T extends TSchema, K extends TMappedKey>(T: T, K: K, options: SchemaOptions): MappedIndexProperties<T, K>;
|
|
14
|
+
export type TIndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedIndexProperties<T, K>> = (TMappedResult<P>);
|
|
15
|
+
export declare function IndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = MappedIndexProperties<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
|
|
16
16
|
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexFromMappedKey = void 0;
|
|
4
|
+
const indexed_result_1 = require("./indexed-result");
|
|
5
|
+
const index_1 = require("../mapped/index");
|
|
6
|
+
function MappedIndexPropertyKey(T, K, options) {
|
|
7
|
+
return { [K]: (0, indexed_result_1.IndexResult)(T, [K], options) };
|
|
8
|
+
}
|
|
9
|
+
function MappedIndexPropertyKeys(T, K, options) {
|
|
10
|
+
const [L, ...R] = K;
|
|
11
|
+
return (K.length > 0
|
|
12
|
+
? { ...MappedIndexPropertyKey(T, L, options), ...MappedIndexPropertyKeys(T, R, options) }
|
|
13
|
+
: {});
|
|
14
|
+
}
|
|
15
|
+
function MappedIndexProperties(T, K, options) {
|
|
16
|
+
return MappedIndexPropertyKeys(T, K.keys, options);
|
|
17
|
+
}
|
|
18
|
+
function IndexFromMappedKey(T, K, options) {
|
|
19
|
+
const P = MappedIndexProperties(T, K, options);
|
|
20
|
+
return (0, index_1.MappedResult)(P);
|
|
21
|
+
}
|
|
22
|
+
exports.IndexFromMappedKey = IndexFromMappedKey;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TSchema } from '../schema/index';
|
|
1
|
+
import { type TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import { type TObject, type TProperties } from '../object/index';
|
|
3
3
|
import { type TNever } from '../never/index';
|
|
4
4
|
import { type TRecursive } from '../recursive/index';
|
|
@@ -29,5 +29,5 @@ declare function FromKey<T extends TSchema, K extends PropertyKey>(T: T, K: 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
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>;
|
|
32
|
+
export declare function IndexResult<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K], options: SchemaOptions): TIndexResult<T, K>;
|
|
33
33
|
export {};
|
|
@@ -4,7 +4,8 @@ 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");
|
|
7
|
-
const type_1 = require("../
|
|
7
|
+
const type_1 = require("../clone/type");
|
|
8
|
+
const type_2 = require("../guard/type");
|
|
8
9
|
function FromRest(T, K) {
|
|
9
10
|
const [L, ...R] = T;
|
|
10
11
|
return (T.length > 0
|
|
@@ -14,7 +15,7 @@ function FromRest(T, K) {
|
|
|
14
15
|
function FromIntersectRest(T) {
|
|
15
16
|
const [L, ...R] = T;
|
|
16
17
|
return (T.length > 0
|
|
17
|
-
? (0,
|
|
18
|
+
? (0, type_2.TNever)(L)
|
|
18
19
|
? [...FromIntersectRest(R)]
|
|
19
20
|
: [L, ...FromIntersectRest(R)]
|
|
20
21
|
: []);
|
|
@@ -25,7 +26,7 @@ function FromIntersect(T, K) {
|
|
|
25
26
|
function FromUnionRest(T, S = T) {
|
|
26
27
|
const [L, ...R] = T;
|
|
27
28
|
return (T.length > 0
|
|
28
|
-
? (0,
|
|
29
|
+
? (0, type_2.TNever)(L)
|
|
29
30
|
? []
|
|
30
31
|
: FromUnionRest(R, S)
|
|
31
32
|
: S);
|
|
@@ -49,11 +50,11 @@ function FromProperty(T, K) {
|
|
|
49
50
|
: (0, index_1.Never)());
|
|
50
51
|
}
|
|
51
52
|
function FromKey(T, K) {
|
|
52
|
-
return ((0,
|
|
53
|
-
(0,
|
|
54
|
-
(0,
|
|
55
|
-
(0,
|
|
56
|
-
(0,
|
|
53
|
+
return ((0, type_2.TIntersect)(T) ? FromIntersect(T.allOf, K) :
|
|
54
|
+
(0, type_2.TUnion)(T) ? FromUnion(T.anyOf, K) :
|
|
55
|
+
(0, type_2.TTuple)(T) ? FromTuple(T.items ?? [], K) :
|
|
56
|
+
(0, type_2.TArray)(T) ? FromArray(T.items, K) :
|
|
57
|
+
(0, type_2.TObject)(T) ? FromProperty(T.properties, K) :
|
|
57
58
|
(0, index_1.Never)());
|
|
58
59
|
}
|
|
59
60
|
function FromKeys(T, K) {
|
|
@@ -62,7 +63,7 @@ function FromKeys(T, K) {
|
|
|
62
63
|
? [FromKey(T, L), ...FromKeys(T, R)]
|
|
63
64
|
: []);
|
|
64
65
|
}
|
|
65
|
-
function IndexResult(T, K) {
|
|
66
|
-
return ((0, index_3.UnionResolve)(FromKeys(T, K)));
|
|
66
|
+
function IndexResult(T, K, options) {
|
|
67
|
+
return ((0, type_1.CloneType)((0, index_3.UnionResolve)(FromKeys(T, K)), options));
|
|
67
68
|
}
|
|
68
69
|
exports.IndexResult = IndexResult;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import { type TIndexResult } from './indexed-result';
|
|
3
3
|
import { type TIndexPropertyKeys } from './indexed-property-keys';
|
|
4
|
-
import { type
|
|
4
|
+
import { type TIndexFromMappedKey } from './indexed-from-mapped-key';
|
|
5
5
|
import { TMappedKey } from '../mapped/index';
|
|
6
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):
|
|
7
|
+
export declare function Index<T extends TSchema, K extends TMappedKey>(T: T, K: K, options?: SchemaOptions): TIndexFromMappedKey<T, K>;
|
|
8
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>;
|
|
9
9
|
export declare function Index<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TIndex<T, K>;
|
|
@@ -4,11 +4,11 @@ exports.Index = void 0;
|
|
|
4
4
|
const type_1 = require("../guard/type");
|
|
5
5
|
const indexed_result_1 = require("./indexed-result");
|
|
6
6
|
const indexed_property_keys_1 = require("./indexed-property-keys");
|
|
7
|
-
const
|
|
7
|
+
const indexed_from_mapped_key_1 = require("./indexed-from-mapped-key");
|
|
8
8
|
const type_2 = require("../clone/type");
|
|
9
9
|
function Index(T, K, options = {}) {
|
|
10
|
-
return ((0, type_1.TMappedKey)(K) ? (0, type_2.CloneType)((0,
|
|
11
|
-
(0, type_1.TSchema)(K) ? (0,
|
|
12
|
-
(0,
|
|
10
|
+
return ((0, type_1.TMappedKey)(K) ? (0, type_2.CloneType)((0, indexed_from_mapped_key_1.IndexFromMappedKey)(T, K, options)) :
|
|
11
|
+
(0, type_1.TSchema)(K) ? (0, indexed_result_1.IndexResult)(T, (0, indexed_property_keys_1.IndexPropertyKeys)(K), options) :
|
|
12
|
+
(0, indexed_result_1.IndexResult)(T, K, options));
|
|
13
13
|
}
|
|
14
14
|
exports.Index = Index;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Capitalize = void 0;
|
|
4
4
|
const intrinsic_1 = require("./intrinsic");
|
|
5
|
-
const type_1 = require("../clone/type");
|
|
6
5
|
function Capitalize(T, options = {}) {
|
|
7
|
-
return (0,
|
|
6
|
+
return (0, intrinsic_1.Intrinsic)(T, 'Capitalize', options);
|
|
8
7
|
}
|
|
9
8
|
exports.Capitalize = Capitalize;
|
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./capitalize"), exports);
|
|
18
|
-
__exportStar(require("./intrinsic-mapped-
|
|
18
|
+
__exportStar(require("./intrinsic-from-mapped-key"), exports);
|
|
19
19
|
__exportStar(require("./intrinsic"), exports);
|
|
20
20
|
__exportStar(require("./lowercase"), exports);
|
|
21
21
|
__exportStar(require("./uncapitalize"), exports);
|
package/build/require/type/intrinsic/{intrinsic-mapped-result.d.ts → intrinsic-from-mapped-key.d.ts}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SchemaOptions } from '../schema/index';
|
|
1
2
|
import type { TProperties } from '../object/index';
|
|
2
3
|
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
3
4
|
import { type TIntrinsic, type IntrinsicMode } from './intrinsic';
|
|
@@ -5,11 +6,11 @@ import { TLiteral, TLiteralValue } from '../literal/index';
|
|
|
5
6
|
type MappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode, P extends TLiteralValue = K extends TLiteralValue ? K : never> = {
|
|
6
7
|
[_ in K]: TIntrinsic<TLiteral<P>, M>;
|
|
7
8
|
};
|
|
8
|
-
declare function MappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode>(K: K, M: M): MappedIntrinsicPropertyKey<K, M>;
|
|
9
|
+
declare function MappedIntrinsicPropertyKey<K extends PropertyKey, M extends IntrinsicMode>(K: K, M: M, options: SchemaOptions): MappedIntrinsicPropertyKey<K, M>;
|
|
9
10
|
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
|
+
declare function MappedIntrinsicPropertyKeys<K extends PropertyKey[], M extends IntrinsicMode>(K: [...K], M: M, options: SchemaOptions): MappedIntrinsicPropertyKeys<K, M>;
|
|
11
12
|
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
|
|
14
|
-
export declare function
|
|
13
|
+
declare function MappedIntrinsicProperties<K extends TMappedKey, M extends IntrinsicMode>(T: K, M: M, options: SchemaOptions): MappedIntrinsicProperties<K, M>;
|
|
14
|
+
export type TIntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>> = (TMappedResult<P>);
|
|
15
|
+
export declare function IntrinsicFromMappedKey<K extends TMappedKey, M extends IntrinsicMode, P extends TProperties = MappedIntrinsicProperties<K, M>>(T: K, M: M, options: SchemaOptions): TMappedResult<P>;
|
|
15
16
|
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntrinsicFromMappedKey = 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, options) {
|
|
8
|
+
return {
|
|
9
|
+
[K]: (0, intrinsic_1.Intrinsic)((0, index_2.Literal)(K), M, options)
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function MappedIntrinsicPropertyKeys(K, M, options) {
|
|
13
|
+
const [L, ...R] = K;
|
|
14
|
+
return (K.length > 0
|
|
15
|
+
? { ...MappedIntrinsicPropertyKey(L, M, options), ...MappedIntrinsicPropertyKeys(R, M, options) }
|
|
16
|
+
: {});
|
|
17
|
+
}
|
|
18
|
+
function MappedIntrinsicProperties(T, M, options) {
|
|
19
|
+
return MappedIntrinsicPropertyKeys(T['keys'], M, options);
|
|
20
|
+
}
|
|
21
|
+
function IntrinsicFromMappedKey(T, M, options) {
|
|
22
|
+
const P = MappedIntrinsicProperties(T, M, options);
|
|
23
|
+
return (0, index_1.MappedResult)(P);
|
|
24
|
+
}
|
|
25
|
+
exports.IntrinsicFromMappedKey = IntrinsicFromMappedKey;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { TSchema } from '../schema/index';
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import { type TTemplateLiteral, type TTemplateLiteralKind } from '../template-literal/index';
|
|
3
|
-
import { type
|
|
3
|
+
import { type TIntrinsicFromMappedKey } from './intrinsic-from-mapped-key';
|
|
4
4
|
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
5
5
|
import { type TUnion } from '../union/index';
|
|
6
6
|
import { type TMappedKey } from '../mapped/index';
|
|
7
7
|
export type IntrinsicMode = 'Uppercase' | 'Lowercase' | 'Capitalize' | 'Uncapitalize';
|
|
8
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;
|
|
9
|
-
declare function FromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode>(schema: TTemplateLiteral, mode: IntrinsicMode): FromTemplateLiteral<T, M>;
|
|
9
|
+
declare function FromTemplateLiteral<T extends TTemplateLiteralKind[], M extends IntrinsicMode>(schema: TTemplateLiteral, mode: IntrinsicMode, options: SchemaOptions): FromTemplateLiteral<T, M>;
|
|
10
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);
|
|
11
11
|
declare function FromLiteralValue(value: TLiteralValue, mode: IntrinsicMode): string;
|
|
12
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>] : [];
|
|
13
13
|
declare function FromRest<T extends TSchema[], M extends IntrinsicMode>(T: [...T], mode: M): FromRest<T, M>;
|
|
14
|
-
export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ?
|
|
15
|
-
export declare function Intrinsic<T extends TMappedKey, M extends IntrinsicMode>(schema: T, mode: M):
|
|
16
|
-
export declare function Intrinsic<T extends TSchema, M extends IntrinsicMode>(schema: T, mode: M): TIntrinsic<T, M>;
|
|
14
|
+
export type TIntrinsic<T extends TSchema, M extends IntrinsicMode> = T extends TMappedKey ? TIntrinsicFromMappedKey<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, options?: SchemaOptions): TIntrinsicFromMappedKey<T, M>;
|
|
16
|
+
export declare function Intrinsic<T extends TSchema, M extends IntrinsicMode>(schema: T, mode: M, options?: SchemaOptions): TIntrinsic<T, M>;
|
|
17
17
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Intrinsic = void 0;
|
|
4
4
|
const index_1 = require("../template-literal/index");
|
|
5
|
-
const
|
|
5
|
+
const intrinsic_from_mapped_key_1 = require("./intrinsic-from-mapped-key");
|
|
6
6
|
const index_2 = require("../literal/index");
|
|
7
7
|
const index_3 = require("../union/index");
|
|
8
8
|
const type_1 = require("../guard/type");
|
|
@@ -20,7 +20,7 @@ function ApplyUppercase(value) {
|
|
|
20
20
|
function ApplyLowercase(value) {
|
|
21
21
|
return value.toLowerCase();
|
|
22
22
|
}
|
|
23
|
-
function FromTemplateLiteral(schema, mode) {
|
|
23
|
+
function FromTemplateLiteral(schema, mode, options) {
|
|
24
24
|
const expression = (0, index_1.TemplateLiteralParseExact)(schema.pattern);
|
|
25
25
|
const finite = (0, index_1.IsTemplateLiteralFinite)(expression);
|
|
26
26
|
if (!finite)
|
|
@@ -29,7 +29,7 @@ function FromTemplateLiteral(schema, mode) {
|
|
|
29
29
|
const literals = strings.map((value) => (0, index_2.Literal)(value));
|
|
30
30
|
const mapped = FromRest(literals, mode);
|
|
31
31
|
const union = (0, index_3.Union)(mapped);
|
|
32
|
-
return (0, index_1.TemplateLiteral)([union]);
|
|
32
|
+
return (0, index_1.TemplateLiteral)([union], options);
|
|
33
33
|
}
|
|
34
34
|
function FromLiteralValue(value, mode) {
|
|
35
35
|
return (typeof value === 'string' ? (mode === 'Uncapitalize' ? ApplyUncapitalize(value) :
|
|
@@ -42,11 +42,11 @@ function FromRest(T, mode) {
|
|
|
42
42
|
const [L, ...R] = T;
|
|
43
43
|
return (T.length > 0 ? [Intrinsic(L, mode), ...FromRest(R, mode)] : []);
|
|
44
44
|
}
|
|
45
|
-
function Intrinsic(schema, mode) {
|
|
46
|
-
return ((0, type_1.TMappedKey)(schema) ? (0,
|
|
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)) :
|
|
45
|
+
function Intrinsic(schema, mode, options = {}) {
|
|
46
|
+
return ((0, type_1.TMappedKey)(schema) ? (0, intrinsic_from_mapped_key_1.IntrinsicFromMappedKey)(schema, mode, options) :
|
|
47
|
+
(0, type_1.TTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode, schema) :
|
|
48
|
+
(0, type_1.TUnion)(schema) ? (0, index_3.Union)(FromRest(schema.anyOf, mode), options) :
|
|
49
|
+
(0, type_1.TLiteral)(schema) ? (0, index_2.Literal)(FromLiteralValue(schema.const, mode), options) :
|
|
50
50
|
schema);
|
|
51
51
|
}
|
|
52
52
|
exports.Intrinsic = Intrinsic;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Lowercase = void 0;
|
|
4
4
|
const intrinsic_1 = require("./intrinsic");
|
|
5
|
-
const type_1 = require("../clone/type");
|
|
6
5
|
function Lowercase(T, options = {}) {
|
|
7
|
-
return (0,
|
|
6
|
+
return (0, intrinsic_1.Intrinsic)(T, 'Lowercase', options);
|
|
8
7
|
}
|
|
9
8
|
exports.Lowercase = Lowercase;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Uncapitalize = void 0;
|
|
4
4
|
const intrinsic_1 = require("./intrinsic");
|
|
5
|
-
const type_1 = require("../clone/type");
|
|
6
5
|
function Uncapitalize(T, options = {}) {
|
|
7
|
-
return (0,
|
|
6
|
+
return (0, intrinsic_1.Intrinsic)(T, 'Uncapitalize', options);
|
|
8
7
|
}
|
|
9
8
|
exports.Uncapitalize = Uncapitalize;
|
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Uppercase = void 0;
|
|
4
4
|
const intrinsic_1 = require("./intrinsic");
|
|
5
|
-
const type_1 = require("../clone/type");
|
|
6
5
|
function Uppercase(T, options = {}) {
|
|
7
|
-
return (0,
|
|
6
|
+
return (0, intrinsic_1.Intrinsic)(T, 'Uppercase', options);
|
|
8
7
|
}
|
|
9
8
|
exports.Uppercase = Uppercase;
|
|
@@ -14,5 +14,6 @@ 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-from-mapped-result"), exports);
|
|
17
18
|
__exportStar(require("./keyof-property-keys"), exports);
|
|
18
19
|
__exportStar(require("./keyof"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { SchemaOptions } from '../schema/index';
|
|
2
|
+
import type { TProperties } from '../object/index';
|
|
3
|
+
import { type TMappedResult } from '../mapped/index';
|
|
4
|
+
import { type TKeyOf } from './keyof';
|
|
5
|
+
type FromProperties<K extends TProperties> = ({
|
|
6
|
+
[K2 in keyof K]: TKeyOf<K[K2]>;
|
|
7
|
+
});
|
|
8
|
+
declare function FromProperties<K extends TProperties>(K: K, options: SchemaOptions): FromProperties<K>;
|
|
9
|
+
type FromMappedResult<K extends TMappedResult> = (FromProperties<K['properties']>);
|
|
10
|
+
declare function FromMappedResult<K extends TMappedResult>(K: K, options: SchemaOptions): FromMappedResult<K>;
|
|
11
|
+
export type TKeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
|
|
12
|
+
export declare function KeyOfFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>>(T: T, options: SchemaOptions): TMappedResult<P>;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KeyOfFromMappedResult = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const keyof_1 = require("./keyof");
|
|
6
|
+
function FromProperties(K, options) {
|
|
7
|
+
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
8
|
+
return { ...Acc, [K2]: (0, keyof_1.KeyOf)(K[K2], options) };
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
function FromMappedResult(K, options) {
|
|
12
|
+
return FromProperties(K.properties, options);
|
|
13
|
+
}
|
|
14
|
+
function KeyOfFromMappedResult(T, options) {
|
|
15
|
+
const P = FromMappedResult(T, options);
|
|
16
|
+
return (0, index_1.MappedResult)(P);
|
|
17
|
+
}
|
|
18
|
+
exports.KeyOfFromMappedResult = KeyOfFromMappedResult;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index';
|
|
2
2
|
import type { Ensure } from '../helpers/index';
|
|
3
|
+
import type { TMappedResult } from '../mapped/index';
|
|
3
4
|
import { type TLiteral, TLiteralValue } from '../literal/index';
|
|
4
5
|
import { type TNumber } from '../number/index';
|
|
5
6
|
import { type SchemaOptions } from '../schema/index';
|
|
6
7
|
import { KeyOfPropertyKeys } from './keyof-property-keys';
|
|
7
8
|
import { UnionResolve } from '../union/index';
|
|
9
|
+
import { type TKeyOfFromMappedResult } from './keyof-from-mapped-result';
|
|
8
10
|
type FromLiterals<T extends TLiteralValue[]> = (T extends [infer L extends TLiteralValue, ...infer R extends TLiteralValue[]] ? L extends '[number]' ? [TNumber, ...FromLiterals<R>] : [TLiteral<L>, ...FromLiterals<R>] : []);
|
|
9
11
|
declare function FromLiterals<T extends TLiteralValue[]>(T: [...T]): FromLiterals<T>;
|
|
10
12
|
export type TKeyOf<T extends TSchema> = (Ensure<UnionResolve<FromLiterals<KeyOfPropertyKeys<T>>>>);
|
|
13
|
+
export declare function KeyOf<T extends TMappedResult>(T: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;
|
|
11
14
|
export declare function KeyOf<T extends TSchema>(T: T, options?: SchemaOptions): TKeyOf<T>;
|
|
12
15
|
export {};
|
|
@@ -6,6 +6,8 @@ const index_2 = require("../number/index");
|
|
|
6
6
|
const keyof_property_keys_1 = require("./keyof-property-keys");
|
|
7
7
|
const index_3 = require("../union/index");
|
|
8
8
|
const type_1 = require("../clone/type");
|
|
9
|
+
const keyof_from_mapped_result_1 = require("./keyof-from-mapped-result");
|
|
10
|
+
const type_2 = require("../guard/type");
|
|
9
11
|
function FromLiterals(T) {
|
|
10
12
|
const [L, ...R] = T;
|
|
11
13
|
return (T.length > 0
|
|
@@ -15,7 +17,12 @@ function FromLiterals(T) {
|
|
|
15
17
|
: []);
|
|
16
18
|
}
|
|
17
19
|
function KeyOf(T, options = {}) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
if ((0, type_2.TMappedResult)(T)) {
|
|
21
|
+
return (0, keyof_from_mapped_result_1.KeyOfFromMappedResult)(T, options);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const K = (0, index_3.UnionResolve)(FromLiterals((0, keyof_property_keys_1.KeyOfPropertyKeys)(T)));
|
|
25
|
+
return (0, type_1.CloneType)(K, options);
|
|
26
|
+
}
|
|
20
27
|
}
|
|
21
28
|
exports.KeyOf = KeyOf;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index';
|
|
2
|
-
import type { Ensure, Evaluate } from '../helpers/index';
|
|
2
|
+
import type { Ensure, Evaluate, Assert } from '../helpers/index';
|
|
3
3
|
import { type TArray } from '../array/index';
|
|
4
4
|
import { type TAsyncIterator } from '../async-iterator/index';
|
|
5
5
|
import { type TConstructor } from '../constructor/index';
|
|
@@ -8,19 +8,22 @@ import { type TIndexPropertyKeys } from '../indexed/index';
|
|
|
8
8
|
import { type TIntersect } from '../intersect/index';
|
|
9
9
|
import { type TIterator } from '../iterator/index';
|
|
10
10
|
import { type TLiteral, type TLiteralValue } from '../literal/index';
|
|
11
|
-
import { type TNever } from '../never/index';
|
|
12
11
|
import { type TObject, type TProperties, type ObjectOptions } from '../object/index';
|
|
13
12
|
import { type TOptional } from '../optional/index';
|
|
14
13
|
import { type TPromise } from '../promise/index';
|
|
15
14
|
import { type TReadonly } from '../readonly/index';
|
|
16
15
|
import { type TTuple } from '../tuple/index';
|
|
17
16
|
import { type TUnion } from '../union/index';
|
|
18
|
-
import type
|
|
17
|
+
import { type TMappedResult } from './mapped-result';
|
|
19
18
|
import type { TMappedKey } from './mapped-key';
|
|
20
|
-
type FromMappedResult<K extends PropertyKey, P extends TProperties> = (K extends keyof P ? FromSchemaType<K, P[K]> :
|
|
19
|
+
type FromMappedResult<K extends PropertyKey, P extends TProperties> = (K extends keyof P ? FromSchemaType<K, P[K]> : TMappedResult<P>);
|
|
21
20
|
declare function FromMappedResult<K extends PropertyKey, P extends TProperties>(K: K, P: P): FromMappedResult<K, P>;
|
|
22
|
-
type
|
|
23
|
-
|
|
21
|
+
type MappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[]> = (P extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? {
|
|
22
|
+
[_ in L]: TLiteral<Assert<L, TLiteralValue>>;
|
|
23
|
+
} & MappedKeyToMappedResultProperties<K, R> : {});
|
|
24
|
+
declare function MappedKeyToMappedResultProperties<K extends PropertyKey, P extends PropertyKey[]>(K: K, P: [...P]): MappedKeyToMappedResultProperties<K, P>;
|
|
25
|
+
type FromMappedKey<K extends PropertyKey, P extends PropertyKey[], R extends TProperties = MappedKeyToMappedResultProperties<K, P>> = (FromMappedResult<K, R>);
|
|
26
|
+
declare function FromMappedKey<K extends PropertyKey, P extends PropertyKey[]>(K: K, P: [...P]): FromMappedResult<K, MappedKeyToMappedResultProperties<K, P>>;
|
|
24
27
|
type FromRest<K extends PropertyKey, T extends TSchema[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [FromSchemaType<K, L>, ...FromRest<K, R>] : [];
|
|
25
28
|
declare function FromRest<K extends PropertyKey, T extends TSchema[]>(K: K, T: [...T]): FromRest<K, T>;
|
|
26
29
|
type FromProperties<K extends PropertyKey, T extends TProperties, R extends TProperties = Evaluate<{
|
|
@@ -13,21 +13,28 @@ const index_7 = require("../indexed/index");
|
|
|
13
13
|
const index_8 = require("../intersect/index");
|
|
14
14
|
const index_9 = require("../iterator/index");
|
|
15
15
|
const index_10 = require("../literal/index");
|
|
16
|
-
const index_11 = require("../
|
|
17
|
-
const index_12 = require("../
|
|
18
|
-
const index_13 = require("../
|
|
19
|
-
const index_14 = require("../
|
|
20
|
-
const index_15 = require("../
|
|
21
|
-
const index_16 = require("../
|
|
22
|
-
const
|
|
16
|
+
const index_11 = require("../object/index");
|
|
17
|
+
const index_12 = require("../optional/index");
|
|
18
|
+
const index_13 = require("../promise/index");
|
|
19
|
+
const index_14 = require("../readonly/index");
|
|
20
|
+
const index_15 = require("../tuple/index");
|
|
21
|
+
const index_16 = require("../union/index");
|
|
22
|
+
const mapped_result_1 = require("./mapped-result");
|
|
23
23
|
const type_3 = require("../guard/type");
|
|
24
24
|
function FromMappedResult(K, P) {
|
|
25
25
|
return (K in P
|
|
26
26
|
? FromSchemaType(K, P[K])
|
|
27
|
-
: (0,
|
|
27
|
+
: (0, mapped_result_1.MappedResult)(P));
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
|
|
29
|
+
function MappedKeyToMappedResultProperties(K, P) {
|
|
30
|
+
const [L, ...R] = P;
|
|
31
|
+
return (P.length > 0
|
|
32
|
+
? { [L]: (0, index_10.Literal)(L), ...MappedKeyToMappedResultProperties(K, R) }
|
|
33
|
+
: {});
|
|
34
|
+
}
|
|
35
|
+
function FromMappedKey(K, P) {
|
|
36
|
+
const R = MappedKeyToMappedResultProperties(K, P);
|
|
37
|
+
return FromMappedResult(K, R);
|
|
31
38
|
}
|
|
32
39
|
function FromRest(K, T) {
|
|
33
40
|
const [L, ...R] = T;
|
|
@@ -41,8 +48,8 @@ function FromProperties(K, T) {
|
|
|
41
48
|
}, {});
|
|
42
49
|
}
|
|
43
50
|
function FromSchemaType(K, T) {
|
|
44
|
-
return ((0, type_3.TOptional)(T) ? (0,
|
|
45
|
-
(0, type_3.TReadonly)(T) ? (0,
|
|
51
|
+
return ((0, type_3.TOptional)(T) ? (0, index_12.Optional)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.OptionalKind]))) :
|
|
52
|
+
(0, type_3.TReadonly)(T) ? (0, index_14.Readonly)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.ReadonlyKind]))) :
|
|
46
53
|
(0, type_3.TMappedResult)(T) ? FromMappedResult(K, T.properties) :
|
|
47
54
|
(0, type_3.TMappedKey)(T) ? FromMappedKey(K, T.keys) :
|
|
48
55
|
(0, type_3.TConstructor)(T) ? (0, index_5.Constructor)(FromRest(K, T.parameters), FromSchemaType(K, T.returns)) :
|
|
@@ -50,11 +57,11 @@ function FromSchemaType(K, T) {
|
|
|
50
57
|
(0, type_3.TAsyncIterator)(T) ? (0, index_4.AsyncIterator)(FromSchemaType(K, T.items)) :
|
|
51
58
|
(0, type_3.TIterator)(T) ? (0, index_9.Iterator)(FromSchemaType(K, T.items)) :
|
|
52
59
|
(0, type_3.TIntersect)(T) ? (0, index_8.Intersect)(FromRest(K, T.allOf)) :
|
|
53
|
-
(0, type_3.TUnion)(T) ? (0,
|
|
54
|
-
(0, type_3.TTuple)(T) ? (0,
|
|
55
|
-
(0, type_3.TObject)(T) ? (0,
|
|
60
|
+
(0, type_3.TUnion)(T) ? (0, index_16.Union)(FromRest(K, T.anyOf)) :
|
|
61
|
+
(0, type_3.TTuple)(T) ? (0, index_15.Tuple)(FromRest(K, T.items ?? [])) :
|
|
62
|
+
(0, type_3.TObject)(T) ? (0, index_11.Object)(FromProperties(K, T.properties)) :
|
|
56
63
|
(0, type_3.TArray)(T) ? (0, index_3.Array)(FromSchemaType(K, T.items)) :
|
|
57
|
-
(0, type_3.TPromise)(T) ? (0,
|
|
64
|
+
(0, type_3.TPromise)(T) ? (0, index_13.Promise)(FromSchemaType(K, T.item)) :
|
|
58
65
|
T);
|
|
59
66
|
}
|
|
60
67
|
function FromMappedFunctionReturnType(K, T) {
|
|
@@ -67,6 +74,6 @@ function Mapped(key, map, options = {}) {
|
|
|
67
74
|
const K = (0, type_1.TSchema)(key) ? (0, index_7.IndexPropertyKeys)(key) : key;
|
|
68
75
|
const RT = map({ [index_1.Kind]: 'MappedKey', keys: K });
|
|
69
76
|
const R = FromMappedFunctionReturnType(K, RT);
|
|
70
|
-
return (0, type_2.CloneType)((0,
|
|
77
|
+
return (0, type_2.CloneType)((0, index_11.Object)(R), options);
|
|
71
78
|
}
|
|
72
79
|
exports.Mapped = Mapped;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './omit-mapped-
|
|
1
|
+
export * from './omit-from-mapped-key';
|
|
2
2
|
export * from './omit';
|
|
@@ -14,5 +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("./omit-mapped-
|
|
17
|
+
__exportStar(require("./omit-from-mapped-key"), exports);
|
|
18
18
|
__exportStar(require("./omit"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import type { TProperties } from '../object/index';
|
|
3
|
+
import { type TMappedResult, type TMappedKey } from '../mapped/index';
|
|
4
|
+
import { type TOmit } from './omit';
|
|
5
|
+
type FromPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
6
|
+
[_ in K]: TOmit<T, [K]>;
|
|
7
|
+
};
|
|
8
|
+
declare function FromPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K, options: SchemaOptions): FromPropertyKey<T, K>;
|
|
9
|
+
type FromPropertyKeys<T extends TSchema, K extends PropertyKey[]> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? FromPropertyKey<T, LK> & FromPropertyKeys<T, RK> : {});
|
|
10
|
+
declare function FromPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K], options: SchemaOptions): FromPropertyKeys<T, K>;
|
|
11
|
+
type FromMappedKey<T extends TSchema, K extends TMappedKey> = (FromPropertyKeys<T, K['keys']>);
|
|
12
|
+
declare function FromMappedKey<T extends TSchema, K extends TMappedKey>(T: T, K: K, options: SchemaOptions): FromMappedKey<T, K>;
|
|
13
|
+
export type TOmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>> = (TMappedResult<P>);
|
|
14
|
+
export declare function OmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmitFromMappedKey = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const omit_1 = require("./omit");
|
|
6
|
+
function FromPropertyKey(T, K, options) {
|
|
7
|
+
return {
|
|
8
|
+
[K]: (0, omit_1.Omit)(T, [K], options)
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function FromPropertyKeys(T, K, options) {
|
|
12
|
+
const [LK, ...RK] = K;
|
|
13
|
+
return (K.length > 0
|
|
14
|
+
? { ...FromPropertyKey(T, LK, options), ...FromPropertyKeys(T, RK, options) }
|
|
15
|
+
: {});
|
|
16
|
+
}
|
|
17
|
+
function FromMappedKey(T, K, options) {
|
|
18
|
+
return FromPropertyKeys(T, K.keys, options);
|
|
19
|
+
}
|
|
20
|
+
function OmitFromMappedKey(T, K, options) {
|
|
21
|
+
const P = FromMappedKey(T, K, options);
|
|
22
|
+
return (0, index_1.MappedResult)(P);
|
|
23
|
+
}
|
|
24
|
+
exports.OmitFromMappedKey = OmitFromMappedKey;
|
|
@@ -6,7 +6,7 @@ import { type TUnion } from '../union/index';
|
|
|
6
6
|
import { type TObject, type TProperties } from '../object/index';
|
|
7
7
|
import { type TIndexPropertyKeys } from '../indexed/index';
|
|
8
8
|
import { TMappedKey } from '../mapped/index';
|
|
9
|
-
import { type
|
|
9
|
+
import { type TOmitFromMappedKey } from './omit-from-mapped-key';
|
|
10
10
|
type FromIntersect<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [OmitResolve<L, K>, ...FromIntersect<R, K>] : [];
|
|
11
11
|
declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K>;
|
|
12
12
|
type FromUnion<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [OmitResolve<L, K>, ...FromUnion<R, K>] : [];
|
|
@@ -16,7 +16,7 @@ declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(
|
|
|
16
16
|
export type OmitResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<OmitResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<FromUnion<S, K>> : T extends TObject<infer S> ? TObject<FromProperties<S, K>> : TObject<{}>;
|
|
17
17
|
export declare function OmitResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): OmitResolve<T, K>;
|
|
18
18
|
export type TOmit<T extends TSchema, K extends PropertyKey[]> = OmitResolve<T, K>;
|
|
19
|
-
export declare function Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
19
|
+
export declare function Omit<T extends TSchema, K extends TMappedKey>(T: T, K: K): TOmitFromMappedKey<T, K>;
|
|
20
20
|
export declare function Omit<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TOmit<T, I>;
|
|
21
21
|
export declare function Omit<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TOmit<T, K>;
|
|
22
22
|
export {};
|