@sinclair/typebox 0.32.0-dev-14 → 0.32.0-dev-16
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 +12 -12
- package/build/import/index.mjs +5 -5
- package/build/import/type/array/array.d.mts +1 -1
- package/build/import/type/constructor/constructor.d.mts +4 -4
- 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 +7 -4
- 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 +5 -5
- 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 +6 -3
- 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/function/function.d.mts +4 -4
- 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 +8 -8
- package/build/import/type/indexed/indexed-result.mjs +9 -8
- package/build/import/type/indexed/indexed.d.mts +2 -2
- package/build/import/type/indexed/indexed.mjs +5 -5
- package/build/import/type/intersect/index.d.mts +2 -0
- package/build/import/type/intersect/index.mjs +2 -0
- package/build/import/type/intersect/intersect-create.d.mts +3 -0
- package/build/import/type/intersect/intersect-create.mjs +12 -0
- package/build/import/type/intersect/intersect-evaluated.d.mts +16 -0
- package/build/import/type/intersect/intersect-evaluated.mjs +35 -0
- package/build/import/type/intersect/intersect-type.d.mts +15 -0
- package/build/import/type/intersect/intersect-type.mjs +1 -0
- package/build/import/type/intersect/intersect.d.mts +4 -20
- package/build/import/type/intersect/intersect.mjs +5 -17
- 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 +5 -2
- package/build/import/type/keyof/keyof.mjs +10 -3
- package/build/import/type/mapped/mapped.mjs +1 -2
- package/build/import/type/object/object.d.mts +5 -5
- 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/record/record.d.mts +0 -1
- package/build/import/type/record/record.mjs +1 -1
- package/build/import/type/recursive/recursive.d.mts +3 -2
- package/build/import/type/recursive/recursive.mjs +1 -5
- 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/template-literal/syntax.d.mts +4 -4
- package/build/import/type/template-literal/template-literal.d.mts +4 -4
- package/build/import/type/transform/transform.d.mts +3 -2
- package/build/import/type/transform/transform.mjs +1 -1
- package/build/import/type/tuple/tuple.d.mts +3 -3
- package/build/import/type/type/json.d.mts +25 -20
- package/build/import/type/type/json.mjs +3 -3
- package/build/import/type/union/index.d.mts +2 -0
- package/build/import/type/union/index.mjs +2 -0
- package/build/import/type/union/union-create.d.mts +3 -0
- package/build/import/type/union/union-create.mjs +5 -0
- package/build/import/type/union/union-evaluated.d.mts +16 -0
- package/build/import/type/union/union-evaluated.mjs +31 -0
- package/build/import/type/union/union-type.d.mts +12 -0
- package/build/import/type/union/union-type.mjs +1 -0
- package/build/import/type/union/union.d.mts +3 -13
- package/build/import/type/union/union.mjs +3 -10
- package/build/import/value/delta/delta.d.mts +1 -1
- package/build/require/index.d.ts +12 -12
- package/build/require/index.js +8 -3
- package/build/require/type/array/array.d.ts +1 -1
- package/build/require/type/constructor/constructor.d.ts +4 -4
- 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 +7 -4
- 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 +7 -7
- 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 +6 -3
- 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/function/function.d.ts +4 -4
- 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 +8 -8
- package/build/require/type/indexed/indexed-result.js +14 -13
- package/build/require/type/indexed/indexed.d.ts +2 -2
- package/build/require/type/indexed/indexed.js +6 -6
- package/build/require/type/intersect/index.d.ts +2 -0
- package/build/require/type/intersect/index.js +2 -0
- package/build/require/type/intersect/intersect-create.d.ts +3 -0
- package/build/require/type/intersect/intersect-create.js +16 -0
- package/build/require/type/intersect/intersect-evaluated.d.ts +16 -0
- package/build/require/type/intersect/intersect-evaluated.js +39 -0
- package/build/require/type/intersect/intersect-type.d.ts +15 -0
- package/build/require/type/intersect/intersect-type.js +3 -0
- package/build/require/type/intersect/intersect.d.ts +4 -20
- package/build/require/type/intersect/intersect.js +5 -18
- 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 +5 -2
- package/build/require/type/keyof/keyof.js +9 -2
- package/build/require/type/mapped/mapped.js +18 -19
- package/build/require/type/object/object.d.ts +5 -5
- 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/record/record.d.ts +0 -1
- package/build/require/type/record/record.js +1 -2
- package/build/require/type/recursive/recursive.d.ts +3 -2
- package/build/require/type/recursive/recursive.js +1 -5
- 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/template-literal/syntax.d.ts +4 -4
- package/build/require/type/template-literal/template-literal.d.ts +4 -4
- package/build/require/type/transform/transform.d.ts +3 -2
- package/build/require/type/transform/transform.js +4 -4
- package/build/require/type/tuple/tuple.d.ts +3 -3
- package/build/require/type/type/json.d.ts +25 -20
- package/build/require/type/type/json.js +3 -3
- package/build/require/type/union/index.d.ts +2 -0
- package/build/require/type/union/index.js +2 -0
- package/build/require/type/union/union-create.d.ts +3 -0
- package/build/require/type/union/union-create.js +9 -0
- package/build/require/type/union/union-evaluated.d.ts +16 -0
- package/build/require/type/union/union-evaluated.js +35 -0
- package/build/require/type/union/union-type.d.ts +12 -0
- package/build/require/type/union/union-type.js +3 -0
- package/build/require/type/union/union.d.ts +3 -13
- package/build/require/type/union/union.js +3 -11
- package/build/require/value/delta/delta.d.ts +1 -1
- package/package.json +1 -1
- package/readme.md +97 -101
- 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
|
@@ -14,4 +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("./extract-from-mapped-result"), exports);
|
|
17
18
|
__exportStar(require("./extract"), exports);
|
|
@@ -2,12 +2,12 @@ import type { TSchema, SchemaOptions } from '../schema/index';
|
|
|
2
2
|
import type { Static } from '../static/index';
|
|
3
3
|
import type { Ensure } from '../helpers/index';
|
|
4
4
|
import { Kind } from '../symbols/index';
|
|
5
|
-
type
|
|
6
|
-
type
|
|
7
|
-
type
|
|
5
|
+
type FunctionStaticReturnType<T extends TSchema, P extends unknown[]> = Static<T, P>;
|
|
6
|
+
type FunctionStaticParameters<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [Static<L, P>, ...FunctionStaticParameters<R, P>] : [];
|
|
7
|
+
type FunctionStatic<T extends TSchema[], U extends TSchema, P extends unknown[]> = (Ensure<(...param: FunctionStaticParameters<T, P>) => FunctionStaticReturnType<U, P>>);
|
|
8
8
|
export interface TFunction<T extends TSchema[] = TSchema[], U extends TSchema = TSchema> extends TSchema {
|
|
9
9
|
[Kind]: 'Function';
|
|
10
|
-
static:
|
|
10
|
+
static: FunctionStatic<T, U, this['params']>;
|
|
11
11
|
type: 'Function';
|
|
12
12
|
parameters: T;
|
|
13
13
|
returns: U;
|
|
@@ -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);
|
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';
|
|
@@ -6,19 +6,19 @@ import { type TIntersect } from '../intersect/index';
|
|
|
6
6
|
import { type TUnion } from '../union/index';
|
|
7
7
|
import { type TTuple } from '../tuple/index';
|
|
8
8
|
import { type TArray } from '../array/index';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { IntersectEvaluated } from '../intersect/index';
|
|
10
|
+
import { UnionEvaluated } from '../union/index';
|
|
11
11
|
type FromRest<T extends TSchema[], K extends PropertyKey> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [FromKey<L, K>, ...FromRest<R, K>] : []);
|
|
12
12
|
declare function FromRest<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromRest<T, K>;
|
|
13
13
|
type FromIntersectRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [...FromIntersectRest<R>] : [L, ...FromIntersectRest<R>] : []);
|
|
14
14
|
declare function FromIntersectRest<T extends TSchema[]>(T: [...T]): FromIntersectRest<T>;
|
|
15
|
-
type FromIntersect<T extends TSchema[], K extends PropertyKey> = (
|
|
15
|
+
type FromIntersect<T extends TSchema[], K extends PropertyKey> = (IntersectEvaluated<FromIntersectRest<FromRest<T, K>>>);
|
|
16
16
|
declare function FromIntersect<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromIntersect<T, K>;
|
|
17
17
|
type FromUnionRest<T extends TSchema[], S = T> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? [] : FromUnionRest<R, S> : S);
|
|
18
18
|
declare function FromUnionRest<T extends TSchema[]>(T: [...T], S?: [...T]): FromUnionRest<T>;
|
|
19
|
-
type FromUnion<T extends TSchema[], K extends PropertyKey> = (
|
|
19
|
+
type FromUnion<T extends TSchema[], K extends PropertyKey> = (UnionEvaluated<FromUnionRest<FromRest<T, K>>>);
|
|
20
20
|
declare function FromUnion<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromUnion<T, K>;
|
|
21
|
-
type FromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ?
|
|
21
|
+
type FromTuple<T extends TSchema[], K extends PropertyKey> = (K extends keyof T ? T[K] : K extends '[number]' ? UnionEvaluated<T> : TNever);
|
|
22
22
|
declare function FromTuple<T extends TSchema[], K extends PropertyKey>(T: [...T], K: K): FromTuple<T, K>;
|
|
23
23
|
type FromArray<T extends TSchema, K extends PropertyKey> = (K extends '[number]' ? T : TNever);
|
|
24
24
|
declare function FromArray<T extends TSchema, K extends PropertyKey>(T: T, K: K): FromArray<T, K>;
|
|
@@ -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 TIndexResult<T extends TSchema, K extends PropertyKey[]> = (
|
|
32
|
-
export declare function IndexResult<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): TIndexResult<T, K>;
|
|
31
|
+
export type TIndexResult<T extends TSchema, K extends PropertyKey[]> = (UnionEvaluated<FromKeys<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,28 +15,28 @@ 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
|
: []);
|
|
21
22
|
}
|
|
22
23
|
function FromIntersect(T, K) {
|
|
23
|
-
return ((0, index_2.
|
|
24
|
+
return ((0, index_2.IntersectEvaluated)(FromIntersectRest(FromRest(T, K))));
|
|
24
25
|
}
|
|
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);
|
|
32
33
|
}
|
|
33
34
|
function FromUnion(T, K) {
|
|
34
|
-
return ((0, index_3.
|
|
35
|
+
return ((0, index_3.UnionEvaluated)(FromUnionRest(FromRest(T, K))));
|
|
35
36
|
}
|
|
36
37
|
function FromTuple(T, K) {
|
|
37
38
|
return (K in T ? T[K] :
|
|
38
|
-
K === '[number]' ? (0, index_3.
|
|
39
|
+
K === '[number]' ? (0, index_3.UnionEvaluated)(T) :
|
|
39
40
|
(0, index_1.Never)());
|
|
40
41
|
}
|
|
41
42
|
function FromArray(T, K) {
|
|
@@ -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.
|
|
66
|
+
function IndexResult(T, K, options) {
|
|
67
|
+
return ((0, type_1.CloneType)((0, index_3.UnionEvaluated)(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>;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Index = void 0;
|
|
4
|
-
const type_1 = require("../guard/type");
|
|
5
4
|
const indexed_result_1 = require("./indexed-result");
|
|
6
5
|
const indexed_property_keys_1 = require("./indexed-property-keys");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const indexed_from_mapped_key_1 = require("./indexed-from-mapped-key");
|
|
7
|
+
const type_1 = require("../clone/type");
|
|
8
|
+
const type_2 = require("../guard/type");
|
|
9
9
|
function Index(T, K, options = {}) {
|
|
10
|
-
return ((0,
|
|
11
|
-
(0,
|
|
12
|
-
(0,
|
|
10
|
+
return ((0, type_2.TMappedKey)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_key_1.IndexFromMappedKey)(T, K, options)) :
|
|
11
|
+
(0, type_2.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;
|
|
@@ -14,4 +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("./intersect-evaluated"), exports);
|
|
18
|
+
__exportStar(require("./intersect-type"), exports);
|
|
17
19
|
__exportStar(require("./intersect"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntersectCreate = void 0;
|
|
4
|
+
const index_1 = require("../symbols/index");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
const type_2 = require("../guard/type");
|
|
7
|
+
function IntersectCreate(T, options) {
|
|
8
|
+
const allObjects = T.every((schema) => (0, type_2.TObject)(schema));
|
|
9
|
+
const clonedUnevaluatedProperties = (0, type_2.TSchema)(options.unevaluatedProperties)
|
|
10
|
+
? { unevaluatedProperties: (0, type_1.CloneType)(options.unevaluatedProperties) }
|
|
11
|
+
: {};
|
|
12
|
+
return ((options.unevaluatedProperties === false || (0, type_2.TSchema)(options.unevaluatedProperties) || allObjects
|
|
13
|
+
? { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', type: 'object', allOf: (0, type_1.CloneRest)(T) }
|
|
14
|
+
: { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', allOf: (0, type_1.CloneRest)(T) }));
|
|
15
|
+
}
|
|
16
|
+
exports.IntersectCreate = IntersectCreate;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SchemaOptions, TSchema } from '../schema/index';
|
|
2
|
+
import { type TNever } from '../never/index';
|
|
3
|
+
import { type TOptional } from '../optional/index';
|
|
4
|
+
import type { TReadonly } from '../readonly/index';
|
|
5
|
+
import { TIntersect, IntersectOptions } from './intersect-type';
|
|
6
|
+
type IsIntersectOptional<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<TSchema> ? IsIntersectOptional<R> : false : true);
|
|
7
|
+
declare function IsIntersectOptional<T extends TSchema[]>(T: T): IsIntersectOptional<T>;
|
|
8
|
+
type RemoveOptionalFromRest<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TOptional<infer S extends TSchema> ? [RemoveOptionalFromType<S>, ...RemoveOptionalFromRest<R>] : [L, ...RemoveOptionalFromRest<R>] : []);
|
|
9
|
+
declare function RemoveOptionalFromRest<T extends TSchema[]>(T: T): RemoveOptionalFromRest<T>;
|
|
10
|
+
type RemoveOptionalFromType<T extends TSchema> = (T extends TReadonly<infer S extends TSchema> ? TReadonly<RemoveOptionalFromType<S>> : T extends TOptional<infer S extends TSchema> ? RemoveOptionalFromType<S> : T);
|
|
11
|
+
declare function RemoveOptionalFromType<T extends TSchema>(T: T): RemoveOptionalFromType<T>;
|
|
12
|
+
type ResolveIntersect<T extends TSchema[]> = (IsIntersectOptional<T> extends true ? TOptional<TIntersect<RemoveOptionalFromRest<T>>> : TIntersect<RemoveOptionalFromRest<T>>);
|
|
13
|
+
declare function ResolveIntersect<T extends TSchema[]>(T: [...T], options: SchemaOptions): ResolveIntersect<T>;
|
|
14
|
+
export type IntersectEvaluated<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : ResolveIntersect<T>);
|
|
15
|
+
export declare function IntersectEvaluated<T extends TSchema[], R = IntersectEvaluated<T>>(T: [...T], options?: IntersectOptions): R;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntersectEvaluated = void 0;
|
|
4
|
+
const index_1 = require("../symbols/index");
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
6
|
+
const index_2 = require("../discard/index");
|
|
7
|
+
const index_3 = require("../never/index");
|
|
8
|
+
const index_4 = require("../optional/index");
|
|
9
|
+
const intersect_create_1 = require("./intersect-create");
|
|
10
|
+
const type_2 = require("../guard/type");
|
|
11
|
+
function IsIntersectOptional(T) {
|
|
12
|
+
const [L, ...R] = T;
|
|
13
|
+
return (T.length > 0
|
|
14
|
+
? (0, type_2.TOptional)(L)
|
|
15
|
+
? IsIntersectOptional(R)
|
|
16
|
+
: false
|
|
17
|
+
: true);
|
|
18
|
+
}
|
|
19
|
+
function RemoveOptionalFromRest(T) {
|
|
20
|
+
return (T.map(T => RemoveOptionalFromType(T)));
|
|
21
|
+
}
|
|
22
|
+
function RemoveOptionalFromType(T) {
|
|
23
|
+
return ((0, index_2.Discard)(T, [index_1.OptionalKind]));
|
|
24
|
+
}
|
|
25
|
+
function ResolveIntersect(T, options) {
|
|
26
|
+
return (IsIntersectOptional(T)
|
|
27
|
+
? (0, index_4.Optional)((0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(T), options))
|
|
28
|
+
: (0, intersect_create_1.IntersectCreate)(RemoveOptionalFromRest(T), options));
|
|
29
|
+
}
|
|
30
|
+
function IntersectEvaluated(T, options = {}) {
|
|
31
|
+
if (T.length === 0)
|
|
32
|
+
return (0, index_3.Never)(options);
|
|
33
|
+
if (T.length === 1)
|
|
34
|
+
return (0, type_1.CloneType)(T[0], options);
|
|
35
|
+
if (T.some((schema) => (0, type_2.TTransform)(schema)))
|
|
36
|
+
throw new Error('Cannot intersect transform types');
|
|
37
|
+
return ResolveIntersect(T, options);
|
|
38
|
+
}
|
|
39
|
+
exports.IntersectEvaluated = IntersectEvaluated;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
|
+
import type { Static } from '../static/index';
|
|
3
|
+
import { Kind } from '../symbols/index';
|
|
4
|
+
type IntersectStatic<T extends TSchema[], P extends unknown[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? Static<L, P> & IntersectStatic<R, P> : unknown;
|
|
5
|
+
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
6
|
+
export interface IntersectOptions extends SchemaOptions {
|
|
7
|
+
unevaluatedProperties?: TUnevaluatedProperties;
|
|
8
|
+
}
|
|
9
|
+
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
10
|
+
[Kind]: 'Intersect';
|
|
11
|
+
static: IntersectStatic<T, this['params']>;
|
|
12
|
+
type?: 'object';
|
|
13
|
+
allOf: [...T];
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
3
|
-
import type { Static } from '../static/index';
|
|
1
|
+
import type { TSchema } from '../schema/index';
|
|
4
2
|
import { type TNever } from '../never/index';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
export declare function IntersectResolve<T extends TSchema[]>(T: T): IntersectResolve<T>;
|
|
9
|
-
export type TUnevaluatedProperties = undefined | TSchema | boolean;
|
|
10
|
-
export interface IntersectOptions extends SchemaOptions {
|
|
11
|
-
unevaluatedProperties?: TUnevaluatedProperties;
|
|
12
|
-
}
|
|
13
|
-
export interface TIntersect<T extends TSchema[] = TSchema[]> extends TSchema, IntersectOptions {
|
|
14
|
-
[Kind]: 'Intersect';
|
|
15
|
-
static: TupleToIntersect<{
|
|
16
|
-
[K in keyof T]: Static<AssertType<T[K]>, this['params']>;
|
|
17
|
-
}>;
|
|
18
|
-
type?: 'object';
|
|
19
|
-
allOf: [...T];
|
|
20
|
-
}
|
|
21
|
-
export declare function Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): IntersectResolve<T>;
|
|
3
|
+
import { TIntersect, IntersectOptions } from './intersect-type';
|
|
4
|
+
export type Intersect<T extends TSchema[]> = (T extends [] ? TNever : T extends [TSchema] ? T[0] : TIntersect<T>);
|
|
5
|
+
export declare function Intersect<T extends TSchema[]>(T: [...T], options?: IntersectOptions): Intersect<T>;
|
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Intersect =
|
|
4
|
-
const index_1 = require("../never/index");
|
|
5
|
-
const index_2 = require("../modifiers/index");
|
|
6
|
-
const index_3 = require("../symbols/index");
|
|
3
|
+
exports.Intersect = void 0;
|
|
7
4
|
const type_1 = require("../clone/type");
|
|
5
|
+
const index_1 = require("../never/index");
|
|
6
|
+
const intersect_create_1 = require("./intersect-create");
|
|
8
7
|
const type_2 = require("../guard/type");
|
|
9
|
-
function IntersectResolve(T) {
|
|
10
|
-
return (T.length === 0
|
|
11
|
-
? (0, index_1.Never)()
|
|
12
|
-
: T.length === 1
|
|
13
|
-
? T[0]
|
|
14
|
-
: (0, index_2.OptionalFromIntersect)(T));
|
|
15
|
-
}
|
|
16
|
-
exports.IntersectResolve = IntersectResolve;
|
|
17
8
|
function Intersect(T, options = {}) {
|
|
18
9
|
if (T.length === 0)
|
|
19
|
-
return (0, index_1.Never)();
|
|
10
|
+
return (0, index_1.Never)(options);
|
|
20
11
|
if (T.length === 1)
|
|
21
12
|
return (0, type_1.CloneType)(T[0], options);
|
|
22
13
|
if (T.some((schema) => (0, type_2.TTransform)(schema)))
|
|
23
14
|
throw new Error('Cannot intersect transform types');
|
|
24
|
-
|
|
25
|
-
const clonedUnevaluatedProperties = (0, type_2.TSchema)(options.unevaluatedProperties) ? { unevaluatedProperties: (0, type_1.CloneType)(options.unevaluatedProperties) } : {};
|
|
26
|
-
return (options.unevaluatedProperties === false || (0, type_2.TSchema)(options.unevaluatedProperties) || allObjects
|
|
27
|
-
? { ...options, ...clonedUnevaluatedProperties, [index_3.Kind]: 'Intersect', type: 'object', allOf: (0, type_1.CloneRest)(T) }
|
|
28
|
-
: { ...options, ...clonedUnevaluatedProperties, [index_3.Kind]: 'Intersect', allOf: (0, type_1.CloneRest)(T) });
|
|
15
|
+
return (0, intersect_create_1.IntersectCreate)(T, options);
|
|
29
16
|
}
|
|
30
17
|
exports.Intersect = Intersect;
|
|
@@ -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;
|