@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,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
|
-
import {
|
|
8
|
+
import { UnionEvaluated } 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
|
-
export type TKeyOf<T extends TSchema> = (Ensure<
|
|
12
|
+
export type TKeyOf<T extends TSchema> = (Ensure<UnionEvaluated<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.UnionEvaluated)(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,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Mapped = void 0;
|
|
4
|
-
const type_1 = require("../guard/type");
|
|
5
4
|
const index_1 = require("../symbols/index");
|
|
6
|
-
const
|
|
5
|
+
const type_1 = require("../clone/type");
|
|
7
6
|
const index_2 = require("../discard/index");
|
|
8
7
|
const index_3 = require("../array/index");
|
|
9
8
|
const index_4 = require("../async-iterator/index");
|
|
@@ -20,7 +19,7 @@ const index_14 = require("../readonly/index");
|
|
|
20
19
|
const index_15 = require("../tuple/index");
|
|
21
20
|
const index_16 = require("../union/index");
|
|
22
21
|
const mapped_result_1 = require("./mapped-result");
|
|
23
|
-
const
|
|
22
|
+
const type_2 = require("../guard/type");
|
|
24
23
|
function FromMappedResult(K, P) {
|
|
25
24
|
return (K in P
|
|
26
25
|
? FromSchemaType(K, P[K])
|
|
@@ -48,20 +47,20 @@ function FromProperties(K, T) {
|
|
|
48
47
|
}, {});
|
|
49
48
|
}
|
|
50
49
|
function FromSchemaType(K, T) {
|
|
51
|
-
return ((0,
|
|
52
|
-
(0,
|
|
53
|
-
(0,
|
|
54
|
-
(0,
|
|
55
|
-
(0,
|
|
56
|
-
(0,
|
|
57
|
-
(0,
|
|
58
|
-
(0,
|
|
59
|
-
(0,
|
|
60
|
-
(0,
|
|
61
|
-
(0,
|
|
62
|
-
(0,
|
|
63
|
-
(0,
|
|
64
|
-
(0,
|
|
50
|
+
return ((0, type_2.TOptional)(T) ? (0, index_12.Optional)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.OptionalKind]))) :
|
|
51
|
+
(0, type_2.TReadonly)(T) ? (0, index_14.Readonly)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.ReadonlyKind]))) :
|
|
52
|
+
(0, type_2.TMappedResult)(T) ? FromMappedResult(K, T.properties) :
|
|
53
|
+
(0, type_2.TMappedKey)(T) ? FromMappedKey(K, T.keys) :
|
|
54
|
+
(0, type_2.TConstructor)(T) ? (0, index_5.Constructor)(FromRest(K, T.parameters), FromSchemaType(K, T.returns)) :
|
|
55
|
+
(0, type_2.TFunction)(T) ? (0, index_6.Function)(FromRest(K, T.parameters), FromSchemaType(K, T.returns)) :
|
|
56
|
+
(0, type_2.TAsyncIterator)(T) ? (0, index_4.AsyncIterator)(FromSchemaType(K, T.items)) :
|
|
57
|
+
(0, type_2.TIterator)(T) ? (0, index_9.Iterator)(FromSchemaType(K, T.items)) :
|
|
58
|
+
(0, type_2.TIntersect)(T) ? (0, index_8.Intersect)(FromRest(K, T.allOf)) :
|
|
59
|
+
(0, type_2.TUnion)(T) ? (0, index_16.Union)(FromRest(K, T.anyOf)) :
|
|
60
|
+
(0, type_2.TTuple)(T) ? (0, index_15.Tuple)(FromRest(K, T.items ?? [])) :
|
|
61
|
+
(0, type_2.TObject)(T) ? (0, index_11.Object)(FromProperties(K, T.properties)) :
|
|
62
|
+
(0, type_2.TArray)(T) ? (0, index_3.Array)(FromSchemaType(K, T.items)) :
|
|
63
|
+
(0, type_2.TPromise)(T) ? (0, index_13.Promise)(FromSchemaType(K, T.item)) :
|
|
65
64
|
T);
|
|
66
65
|
}
|
|
67
66
|
function FromMappedFunctionReturnType(K, T) {
|
|
@@ -71,9 +70,9 @@ function FromMappedFunctionReturnType(K, T) {
|
|
|
71
70
|
: {});
|
|
72
71
|
}
|
|
73
72
|
function Mapped(key, map, options = {}) {
|
|
74
|
-
const K = (0,
|
|
73
|
+
const K = (0, type_2.TSchema)(key) ? (0, index_7.IndexPropertyKeys)(key) : key;
|
|
75
74
|
const RT = map({ [index_1.Kind]: 'MappedKey', keys: K });
|
|
76
75
|
const R = FromMappedFunctionReturnType(K, RT);
|
|
77
|
-
return (0,
|
|
76
|
+
return (0, type_1.CloneType)((0, index_11.Object)(R), options);
|
|
78
77
|
}
|
|
79
78
|
exports.Mapped = Mapped;
|
|
@@ -4,8 +4,6 @@ import type { Evaluate } from '../helpers/index';
|
|
|
4
4
|
import type { TReadonly } from '../readonly/index';
|
|
5
5
|
import type { TOptional } from '../optional/index';
|
|
6
6
|
import { Kind } from '../symbols/index';
|
|
7
|
-
export type TPropertyKey = string | number;
|
|
8
|
-
export type TProperties = Record<TPropertyKey, TSchema>;
|
|
9
7
|
type ReadonlyOptionalPropertyKeys<T extends TProperties> = {
|
|
10
8
|
[K in keyof T]: T[K] extends TReadonly<TSchema> ? (T[K] extends TOptional<T[K]> ? K : never) : never;
|
|
11
9
|
}[keyof T];
|
|
@@ -16,10 +14,12 @@ type OptionalPropertyKeys<T extends TProperties> = {
|
|
|
16
14
|
[K in keyof T]: T[K] extends TOptional<TSchema> ? (T[K] extends TReadonly<T[K]> ? never : K) : never;
|
|
17
15
|
}[keyof T];
|
|
18
16
|
type RequiredPropertyKeys<T extends TProperties> = keyof Omit<T, ReadonlyOptionalPropertyKeys<T> | ReadonlyPropertyKeys<T> | OptionalPropertyKeys<T>>;
|
|
19
|
-
type
|
|
20
|
-
export type
|
|
17
|
+
type ObjectStaticProperties<T extends TProperties, R extends Record<keyof any, unknown>> = Evaluate<(Readonly<Partial<Pick<R, ReadonlyOptionalPropertyKeys<T>>>> & Readonly<Pick<R, ReadonlyPropertyKeys<T>>> & Partial<Pick<R, OptionalPropertyKeys<T>>> & Required<Pick<R, RequiredPropertyKeys<T>>>)>;
|
|
18
|
+
export type ObjectStatic<T extends TProperties, P extends unknown[]> = ObjectStaticProperties<T, {
|
|
21
19
|
[K in keyof T]: Static<T[K], P>;
|
|
22
20
|
}>;
|
|
21
|
+
export type TPropertyKey = string | number;
|
|
22
|
+
export type TProperties = Record<TPropertyKey, TSchema>;
|
|
23
23
|
export type TAdditionalProperties = undefined | TSchema | boolean;
|
|
24
24
|
export interface ObjectOptions extends SchemaOptions {
|
|
25
25
|
additionalProperties?: TAdditionalProperties;
|
|
@@ -28,7 +28,7 @@ export interface ObjectOptions extends SchemaOptions {
|
|
|
28
28
|
}
|
|
29
29
|
export interface TObject<T extends TProperties = TProperties> extends TSchema, ObjectOptions {
|
|
30
30
|
[Kind]: 'Object';
|
|
31
|
-
static:
|
|
31
|
+
static: ObjectStatic<T, this['params']>;
|
|
32
32
|
additionalProperties?: TAdditionalProperties;
|
|
33
33
|
type: 'object';
|
|
34
34
|
properties: T;
|
|
@@ -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 {};
|
|
@@ -8,7 +8,7 @@ const index_4 = require("../indexed/index");
|
|
|
8
8
|
const index_5 = require("../discard/index");
|
|
9
9
|
const index_6 = require("../symbols/index");
|
|
10
10
|
const type_1 = require("../clone/type");
|
|
11
|
-
const
|
|
11
|
+
const omit_from_mapped_key_1 = require("./omit-from-mapped-key");
|
|
12
12
|
const type_2 = require("../guard/type");
|
|
13
13
|
function FromIntersect(T, K) {
|
|
14
14
|
return T.map((T) => OmitResolve(T, K));
|
|
@@ -34,7 +34,7 @@ function OmitResolve(T, K) {
|
|
|
34
34
|
exports.OmitResolve = OmitResolve;
|
|
35
35
|
function Omit(T, K, options = {}) {
|
|
36
36
|
if ((0, type_2.TMappedKey)(K)) {
|
|
37
|
-
return (0,
|
|
37
|
+
return (0, omit_from_mapped_key_1.OmitFromMappedKey)(T, K, options);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
40
|
const I = (0, type_2.TSchema)(K) ? (0, index_4.IndexPropertyKeys)(K) : K;
|
|
@@ -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("./partial-from-mapped-result"), exports);
|
|
17
18
|
__exportStar(require("./partial"), 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 TPartial } from './partial';
|
|
5
|
+
type FromProperties<K extends TProperties> = ({
|
|
6
|
+
[K2 in keyof K]: TPartial<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 TPartialFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
|
|
12
|
+
export declare function PartialFromMappedResult<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.PartialFromMappedResult = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const partial_1 = require("./partial");
|
|
6
|
+
function FromProperties(K, options) {
|
|
7
|
+
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
8
|
+
return { ...Acc, [K2]: (0, partial_1.Partial)(K[K2], options) };
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
function FromMappedResult(K, options) {
|
|
12
|
+
return FromProperties(K.properties, options);
|
|
13
|
+
}
|
|
14
|
+
function PartialFromMappedResult(T, options) {
|
|
15
|
+
const P = FromMappedResult(T, options);
|
|
16
|
+
return (0, index_1.MappedResult)(P);
|
|
17
|
+
}
|
|
18
|
+
exports.PartialFromMappedResult = PartialFromMappedResult;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { Evaluate } from '../helpers/index';
|
|
3
|
+
import type { TMappedResult } from '../mapped/index';
|
|
3
4
|
import { type TReadonlyOptional } from '../readonly-optional/index';
|
|
4
5
|
import { type TOptional } from '../optional/index';
|
|
5
6
|
import { type TReadonly } from '../readonly/index';
|
|
@@ -7,6 +8,7 @@ import { type TRecursive } from '../recursive/index';
|
|
|
7
8
|
import { type TObject, type TProperties } from '../object/index';
|
|
8
9
|
import { type TIntersect } from '../intersect/index';
|
|
9
10
|
import { type TUnion } from '../union/index';
|
|
11
|
+
import { type TPartialFromMappedResult } from './partial-from-mapped-result';
|
|
10
12
|
type FromIntersect<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PartialResolve<L>, ...FromIntersect<R>] : []);
|
|
11
13
|
declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
|
|
12
14
|
type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PartialResolve<L>, ...FromUnion<R>] : []);
|
|
@@ -15,8 +17,9 @@ type FromProperties<T extends TProperties> = Evaluate<{
|
|
|
15
17
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonlyOptional<S> : T[K] extends (TReadonly<infer S>) ? TReadonlyOptional<S> : T[K] extends (TOptional<infer S>) ? TOptional<S> : TOptional<T[K]>;
|
|
16
18
|
}>;
|
|
17
19
|
declare function FromProperties<T extends TProperties>(T: T): TProperties;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
type PartialResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<PartialResolve<S>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S>> : T extends TUnion<infer S> ? TUnion<FromUnion<S>> : T extends TObject<infer S> ? TObject<FromProperties<S>> : TObject<{}>);
|
|
21
|
+
declare function PartialResolve<T extends TSchema>(T: T): PartialResolve<T>;
|
|
20
22
|
export type TPartial<T extends TSchema> = PartialResolve<T>;
|
|
23
|
+
export declare function Partial<T extends TMappedResult>(T: T, options?: SchemaOptions): TPartialFromMappedResult<T>;
|
|
21
24
|
export declare function Partial<T extends TSchema>(T: T, options?: SchemaOptions): TPartial<T>;
|
|
22
25
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Partial =
|
|
3
|
+
exports.Partial = void 0;
|
|
4
4
|
const index_1 = require("../optional/index");
|
|
5
5
|
const index_2 = require("../object/index");
|
|
6
6
|
const index_3 = require("../intersect/index");
|
|
@@ -8,6 +8,7 @@ const index_4 = require("../union/index");
|
|
|
8
8
|
const index_5 = require("../discard/index");
|
|
9
9
|
const index_6 = require("../symbols/index");
|
|
10
10
|
const type_1 = require("../clone/type");
|
|
11
|
+
const partial_from_mapped_result_1 = require("./partial-from-mapped-result");
|
|
11
12
|
const type_2 = require("../guard/type");
|
|
12
13
|
function FromIntersect(T) {
|
|
13
14
|
const [L, ...R] = T;
|
|
@@ -32,10 +33,14 @@ function PartialResolve(T) {
|
|
|
32
33
|
(0, type_2.TObject)(T) ? (0, index_2.Object)(FromProperties(T.properties)) :
|
|
33
34
|
(0, index_2.Object)({}));
|
|
34
35
|
}
|
|
35
|
-
exports.PartialResolve = PartialResolve;
|
|
36
36
|
function Partial(T, options = {}) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
if ((0, type_2.TMappedResult)(T)) {
|
|
38
|
+
return (0, partial_from_mapped_result_1.PartialFromMappedResult)(T, options);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);
|
|
42
|
+
const R = (0, type_1.CloneType)(PartialResolve(T), options);
|
|
43
|
+
return { ...D, ...R };
|
|
44
|
+
}
|
|
40
45
|
}
|
|
41
46
|
exports.Partial = Partial;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './pick-mapped-
|
|
1
|
+
export * from './pick-from-mapped-key';
|
|
2
2
|
export * from './pick';
|
|
@@ -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("./pick-mapped-
|
|
17
|
+
__exportStar(require("./pick-from-mapped-key"), exports);
|
|
18
18
|
__exportStar(require("./pick"), 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 TPick } from './pick';
|
|
5
|
+
type FromPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
6
|
+
[_ in K]: TPick<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 TPickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = FromMappedKey<T, K>> = (TMappedResult<P>);
|
|
14
|
+
export declare function PickFromMappedKey<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.PickFromMappedKey = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const pick_1 = require("./pick");
|
|
6
|
+
function FromPropertyKey(T, K, options) {
|
|
7
|
+
return {
|
|
8
|
+
[K]: (0, pick_1.Pick)(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 PickFromMappedKey(T, K, options) {
|
|
21
|
+
const P = FromMappedKey(T, K, options);
|
|
22
|
+
return (0, index_1.MappedResult)(P);
|
|
23
|
+
}
|
|
24
|
+
exports.PickFromMappedKey = PickFromMappedKey;
|
|
@@ -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 TPickFromMappedKey } from './pick-from-mapped-key';
|
|
10
10
|
type FromIntersect<T extends TSchema[], K extends PropertyKey[]> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [PickResolve<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[]] ? [PickResolve<L, K>, ...FromUnion<R, K>] : [];
|
|
@@ -16,7 +16,7 @@ declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(
|
|
|
16
16
|
export type PickResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<PickResolve<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 PickResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): PickResolve<T, K>;
|
|
18
18
|
export type TPick<T extends TSchema, K extends PropertyKey[]> = PickResolve<T, K>;
|
|
19
|
-
export declare function Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K):
|
|
19
|
+
export declare function Pick<T extends TSchema, K extends TMappedKey>(T: T, K: K): TPickFromMappedKey<T, K>;
|
|
20
20
|
export declare function Pick<T extends TSchema, K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>>(T: T, K: K, options?: SchemaOptions): TPick<T, I>;
|
|
21
21
|
export declare function Pick<T extends TSchema, K extends PropertyKey[]>(T: T, K: readonly [...K], options?: SchemaOptions): TPick<T, K>;
|
|
22
22
|
export {};
|
|
@@ -8,7 +8,7 @@ const index_4 = require("../indexed/index");
|
|
|
8
8
|
const index_5 = require("../discard/index");
|
|
9
9
|
const index_6 = require("../symbols/index");
|
|
10
10
|
const type_1 = require("../clone/type");
|
|
11
|
-
const
|
|
11
|
+
const pick_from_mapped_key_1 = require("./pick-from-mapped-key");
|
|
12
12
|
const type_2 = require("../guard/type");
|
|
13
13
|
function FromIntersect(T, K) {
|
|
14
14
|
return T.map((T) => PickResolve(T, K));
|
|
@@ -30,7 +30,7 @@ function PickResolve(T, K) {
|
|
|
30
30
|
exports.PickResolve = PickResolve;
|
|
31
31
|
function Pick(T, K, options = {}) {
|
|
32
32
|
if ((0, type_2.TMappedKey)(K)) {
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, pick_from_mapped_key_1.PickFromMappedKey)(T, K, options);
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
36
|
const I = (0, type_2.TSchema)(K) ? (0, index_4.IndexPropertyKeys)(K) : K;
|
|
@@ -40,7 +40,6 @@ declare function FromIntegerKey<K extends TInteger, T extends TSchema>(_: K, T:
|
|
|
40
40
|
type FromNumberKey<_ extends TSchema, T extends TSchema> = (Ensure<TRecord<TNumber, T>>);
|
|
41
41
|
declare function FromNumberKey<K extends TNumber, T extends TSchema>(_: K, T: T): FromIntegerKey<K, T>;
|
|
42
42
|
export type RecordResolve<K extends TSchema, T extends TSchema> = K extends TEnum<infer S> ? FromEnumKey<S, T> : K extends TUnion<infer S> ? FromUnionKey<S, T> : K extends TTemplateLiteral ? FromTemplateLiteralKey<K, T> : K extends TLiteral<infer S> ? FromLiteralKey<S, T> : K extends TInteger ? FromIntegerKey<K, T> : K extends TNumber ? FromNumberKey<K, T> : K extends TString ? FromStringKey<K, T> : TNever;
|
|
43
|
-
export declare function RecordResolve<K extends TSchema, T extends TSchema>(K: K, T: T): RecordResolve<K, T>;
|
|
44
43
|
export interface TRecord<K extends TSchema = TSchema, T extends TSchema = TSchema> extends TSchema {
|
|
45
44
|
[Kind]: 'Record';
|
|
46
45
|
static: Record<Assert<Static<K>, string | number>, Static<T, this['params']>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Record =
|
|
3
|
+
exports.Record = void 0;
|
|
4
4
|
const index_1 = require("../object/index");
|
|
5
5
|
const index_2 = require("../never/index");
|
|
6
6
|
const index_3 = require("../union/index");
|
|
@@ -49,7 +49,6 @@ function RecordResolve(K, T) {
|
|
|
49
49
|
(0, type_2.TNumber)(K) ? FromNumberKey(K, T) :
|
|
50
50
|
(0, index_2.Never)());
|
|
51
51
|
}
|
|
52
|
-
exports.RecordResolve = RecordResolve;
|
|
53
52
|
function Record(K, T, options = {}) {
|
|
54
53
|
return (0, type_1.CloneType)(RecordResolve(K, T), options);
|
|
55
54
|
}
|
|
@@ -6,9 +6,10 @@ export interface TThis extends TSchema {
|
|
|
6
6
|
static: this['params'][0];
|
|
7
7
|
$ref: string;
|
|
8
8
|
}
|
|
9
|
-
|
|
9
|
+
type RecursiveStatic<T extends TSchema> = Static<T, [RecursiveStatic<T>]>;
|
|
10
10
|
export interface TRecursive<T extends TSchema> extends TSchema {
|
|
11
11
|
[Hint]: 'Recursive';
|
|
12
|
-
static:
|
|
12
|
+
static: RecursiveStatic<T>;
|
|
13
13
|
}
|
|
14
14
|
export declare function Recursive<T extends TSchema>(callback: (thisType: TThis) => T, options?: SchemaOptions): TRecursive<T>;
|
|
15
|
+
export {};
|
|
@@ -10,10 +10,6 @@ function Recursive(callback, options = {}) {
|
|
|
10
10
|
options.$id = `T${Ordinal++}`;
|
|
11
11
|
const thisType = callback({ [index_1.Kind]: 'This', $ref: `${options.$id}` });
|
|
12
12
|
thisType.$id = options.$id;
|
|
13
|
-
return (0, type_1.CloneType)({
|
|
14
|
-
...options,
|
|
15
|
-
[index_1.Hint]: 'Recursive',
|
|
16
|
-
...thisType,
|
|
17
|
-
});
|
|
13
|
+
return (0, type_1.CloneType)({ ...options, [index_1.Hint]: 'Recursive', ...thisType });
|
|
18
14
|
}
|
|
19
15
|
exports.Recursive = Recursive;
|
|
@@ -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("./required-from-mapped-result"), exports);
|
|
17
18
|
__exportStar(require("./required"), 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 TRequired } from './required';
|
|
5
|
+
type FromProperties<K extends TProperties> = ({
|
|
6
|
+
[K2 in keyof K]: TRequired<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 TRequiredFromMappedResult<T extends TMappedResult, P extends TProperties = FromMappedResult<T>> = (TMappedResult<P>);
|
|
12
|
+
export declare function RequiredFromMappedResult<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.RequiredFromMappedResult = void 0;
|
|
4
|
+
const index_1 = require("../mapped/index");
|
|
5
|
+
const required_1 = require("./required");
|
|
6
|
+
function FromProperties(K, options) {
|
|
7
|
+
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
|
|
8
|
+
return { ...Acc, [K2]: (0, required_1.Required)(K[K2], options) };
|
|
9
|
+
}, {});
|
|
10
|
+
}
|
|
11
|
+
function FromMappedResult(K, options) {
|
|
12
|
+
return FromProperties(K.properties, options);
|
|
13
|
+
}
|
|
14
|
+
function RequiredFromMappedResult(T, options) {
|
|
15
|
+
const P = FromMappedResult(T, options);
|
|
16
|
+
return (0, index_1.MappedResult)(P);
|
|
17
|
+
}
|
|
18
|
+
exports.RequiredFromMappedResult = RequiredFromMappedResult;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { TSchema, SchemaOptions } from '../schema/index';
|
|
2
2
|
import type { Evaluate } from '../helpers/index';
|
|
3
|
+
import type { TMappedResult } from '../mapped/index';
|
|
3
4
|
import { type TReadonlyOptional } from '../readonly-optional/index';
|
|
4
5
|
import { type TOptional } from '../optional/index';
|
|
5
6
|
import { type TReadonly } from '../readonly/index';
|
|
@@ -7,6 +8,7 @@ import { type TRecursive } from '../recursive/index';
|
|
|
7
8
|
import { type TIntersect } from '../intersect/index';
|
|
8
9
|
import { type TUnion } from '../union/index';
|
|
9
10
|
import { type TObject, type TProperties } from '../object/index';
|
|
11
|
+
import { type TRequiredFromMappedResult } from './required-from-mapped-result';
|
|
10
12
|
type FromIntersect<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [RequiredResolve<L>, ...FromIntersect<R>] : []);
|
|
11
13
|
declare function FromIntersect<T extends TSchema[]>(T: [...T]): FromIntersect<T>;
|
|
12
14
|
type FromUnion<T extends TSchema[]> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? [RequiredResolve<L>, ...FromUnion<R>] : []);
|
|
@@ -15,8 +17,9 @@ type FromProperties<T extends TProperties> = Evaluate<{
|
|
|
15
17
|
[K in keyof T]: T[K] extends (TReadonlyOptional<infer S>) ? TReadonly<S> : T[K] extends (TReadonly<infer S>) ? TReadonly<S> : T[K] extends (TOptional<infer S>) ? S : T[K];
|
|
16
18
|
}>;
|
|
17
19
|
declare function FromProperties<T extends TProperties>(T: T): TProperties;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
+
type RequiredResolve<T extends TSchema> = (T extends TRecursive<infer S> ? TRecursive<RequiredResolve<S>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S>> : T extends TUnion<infer S> ? TUnion<FromUnion<S>> : T extends TObject<infer S> ? TObject<FromProperties<S>> : TObject<{}>);
|
|
21
|
+
declare function RequiredResolve<T extends TSchema>(T: T): RequiredResolve<T>;
|
|
20
22
|
export type TRequired<T extends TSchema> = RequiredResolve<T>;
|
|
23
|
+
export declare function Required<T extends TMappedResult>(T: T, options?: SchemaOptions): TRequiredFromMappedResult<T>;
|
|
21
24
|
export declare function Required<T extends TSchema>(T: T, options?: SchemaOptions): TRequired<T>;
|
|
22
25
|
export {};
|