@sinclair/typebox 0.32.35 → 0.33.1
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/cjs/index.d.ts +1 -0
- package/build/cjs/index.js +1 -0
- package/build/cjs/system/policy.d.ts +9 -1
- package/build/cjs/system/policy.js +13 -2
- package/build/cjs/type/any/any.js +4 -3
- package/build/cjs/type/array/array.d.ts +1 -1
- package/build/cjs/type/array/array.js +3 -8
- package/build/cjs/type/async-iterator/async-iterator.js +3 -8
- package/build/cjs/type/awaited/awaited.js +3 -3
- package/build/cjs/type/bigint/bigint.js +3 -6
- package/build/cjs/type/boolean/boolean.js +3 -6
- package/build/cjs/type/clone/type.d.ts +1 -1
- package/build/cjs/type/clone/type.js +2 -2
- package/build/cjs/type/composite/composite.js +1 -1
- package/build/cjs/type/const/const.js +3 -3
- package/build/cjs/type/constructor/constructor.js +2 -8
- package/build/cjs/type/constructor-parameters/constructor-parameters.js +2 -3
- package/build/cjs/type/create/immutable.d.ts +2 -0
- package/build/cjs/type/create/immutable.js +41 -0
- package/build/cjs/type/create/index.d.ts +1 -0
- package/build/cjs/type/create/index.js +18 -0
- package/build/cjs/type/create/type.d.ts +3 -0
- package/build/cjs/type/create/type.js +19 -0
- package/build/cjs/type/date/date.js +3 -6
- package/build/cjs/type/discard/discard.d.ts +1 -0
- package/build/cjs/type/discard/discard.js +1 -0
- package/build/cjs/type/enum/enum.js +1 -1
- package/build/cjs/type/exclude/exclude.js +4 -4
- package/build/cjs/type/extends/extends-from-mapped-key.d.ts +1 -1
- package/build/cjs/type/extends/extends-from-mapped-key.js +2 -1
- package/build/cjs/type/extends/extends-from-mapped-result.d.ts +1 -1
- package/build/cjs/type/extends/extends-from-mapped-result.js +2 -1
- package/build/cjs/type/extends/extends.js +4 -4
- package/build/cjs/type/extract/extract.js +5 -5
- package/build/cjs/type/function/function.js +2 -8
- package/build/cjs/type/guard/value.js +3 -0
- package/build/cjs/type/indexed/indexed-from-mapped-key.d.ts +1 -1
- package/build/cjs/type/indexed/indexed-from-mapped-key.js +2 -1
- package/build/cjs/type/indexed/indexed-from-mapped-result.d.ts +1 -1
- package/build/cjs/type/indexed/indexed.js +10 -6
- package/build/cjs/type/instance-type/instance-type.js +3 -3
- package/build/cjs/type/integer/integer.js +3 -6
- package/build/cjs/type/intersect/intersect-create.d.ts +1 -1
- package/build/cjs/type/intersect/intersect-create.js +6 -6
- package/build/cjs/type/intersect/intersect-evaluated.js +2 -2
- package/build/cjs/type/intersect/intersect.js +3 -3
- package/build/cjs/type/intrinsic/intrinsic-from-mapped-key.js +4 -2
- package/build/cjs/type/intrinsic/intrinsic.js +4 -2
- package/build/cjs/type/iterator/iterator.js +3 -8
- package/build/cjs/type/keyof/keyof-from-mapped-result.d.ts +1 -1
- package/build/cjs/type/keyof/keyof-from-mapped-result.js +2 -1
- package/build/cjs/type/keyof/keyof.js +3 -3
- package/build/cjs/type/literal/literal.js +4 -4
- package/build/cjs/type/mapped/mapped-key.js +3 -2
- package/build/cjs/type/mapped/mapped-result.js +3 -2
- package/build/cjs/type/mapped/mapped.js +2 -3
- package/build/cjs/type/never/never.js +3 -6
- package/build/cjs/type/not/not.d.ts +1 -1
- package/build/cjs/type/not/not.js +3 -7
- package/build/cjs/type/null/null.js +3 -6
- package/build/cjs/type/number/number.js +3 -6
- package/build/cjs/type/object/object.js +13 -12
- package/build/cjs/type/omit/omit-from-mapped-key.d.ts +1 -1
- package/build/cjs/type/omit/omit-from-mapped-key.js +2 -1
- package/build/cjs/type/omit/omit-from-mapped-result.d.ts +1 -1
- package/build/cjs/type/omit/omit-from-mapped-result.js +2 -1
- package/build/cjs/type/omit/omit.js +4 -4
- package/build/cjs/type/optional/optional.js +3 -3
- package/build/cjs/type/parameters/parameters.js +2 -3
- package/build/cjs/type/partial/partial-from-mapped-result.d.ts +1 -1
- package/build/cjs/type/partial/partial-from-mapped-result.js +2 -1
- package/build/cjs/type/partial/partial.js +4 -4
- package/build/cjs/type/pick/pick-from-mapped-key.d.ts +1 -1
- package/build/cjs/type/pick/pick-from-mapped-key.js +2 -1
- package/build/cjs/type/pick/pick-from-mapped-result.d.ts +1 -1
- package/build/cjs/type/pick/pick-from-mapped-result.js +2 -1
- package/build/cjs/type/pick/pick.js +4 -4
- package/build/cjs/type/promise/promise.js +3 -8
- package/build/cjs/type/readonly/readonly.js +3 -3
- package/build/cjs/type/record/record.js +5 -6
- package/build/cjs/type/recursive/recursive.js +3 -2
- package/build/cjs/type/ref/ref.js +4 -7
- package/build/cjs/type/regexp/regexp.js +3 -2
- package/build/cjs/type/required/required-from-mapped-result.d.ts +1 -1
- package/build/cjs/type/required/required.js +4 -4
- package/build/cjs/type/rest/rest.d.ts +1 -1
- package/build/cjs/type/rest/rest.js +4 -5
- package/build/cjs/type/return-type/return-type.js +3 -3
- package/build/cjs/type/string/string.js +3 -2
- package/build/cjs/type/symbol/symbol.js +2 -1
- package/build/cjs/type/template-literal/template-literal.js +3 -2
- package/build/cjs/type/transform/transform.js +1 -3
- package/build/cjs/type/tuple/tuple.js +5 -7
- package/build/cjs/type/type/javascript.js +13 -13
- package/build/cjs/type/type/json.js +35 -35
- package/build/cjs/type/uint8array/uint8array.js +3 -2
- package/build/cjs/type/undefined/undefined.js +3 -2
- package/build/cjs/type/union/union-create.d.ts +1 -1
- package/build/cjs/type/union/union-create.js +2 -2
- package/build/cjs/type/union/union-evaluated.js +3 -3
- package/build/cjs/type/union/union.js +3 -3
- package/build/cjs/type/unknown/unknown.js +3 -5
- package/build/cjs/type/unsafe/unsafe.js +2 -4
- package/build/cjs/type/void/void.js +3 -6
- package/build/esm/index.d.mts +1 -0
- package/build/esm/index.mjs +1 -0
- package/build/esm/system/policy.d.mts +9 -1
- package/build/esm/system/policy.mjs +13 -2
- package/build/esm/type/any/any.mjs +3 -2
- package/build/esm/type/array/array.d.mts +1 -1
- package/build/esm/type/array/array.mjs +3 -8
- package/build/esm/type/async-iterator/async-iterator.mjs +3 -8
- package/build/esm/type/awaited/awaited.mjs +3 -3
- package/build/esm/type/bigint/bigint.mjs +3 -6
- package/build/esm/type/boolean/boolean.mjs +3 -6
- package/build/esm/type/clone/type.d.mts +1 -1
- package/build/esm/type/clone/type.mjs +2 -2
- package/build/esm/type/composite/composite.mjs +1 -1
- package/build/esm/type/const/const.mjs +3 -3
- package/build/esm/type/constructor/constructor.mjs +2 -8
- package/build/esm/type/constructor-parameters/constructor-parameters.mjs +2 -3
- package/build/esm/type/create/immutable.d.mts +2 -0
- package/build/esm/type/create/immutable.mjs +37 -0
- package/build/esm/type/create/index.d.mts +1 -0
- package/build/esm/type/create/index.mjs +1 -0
- package/build/esm/type/create/type.d.mts +3 -0
- package/build/esm/type/create/type.mjs +15 -0
- package/build/esm/type/date/date.mjs +3 -6
- package/build/esm/type/discard/discard.d.mts +1 -0
- package/build/esm/type/discard/discard.mjs +1 -0
- package/build/esm/type/enum/enum.mjs +1 -1
- package/build/esm/type/exclude/exclude.mjs +4 -4
- package/build/esm/type/extends/extends-from-mapped-key.d.mts +1 -1
- package/build/esm/type/extends/extends-from-mapped-key.mjs +2 -1
- package/build/esm/type/extends/extends-from-mapped-result.d.mts +1 -1
- package/build/esm/type/extends/extends-from-mapped-result.mjs +2 -1
- package/build/esm/type/extends/extends.mjs +4 -4
- package/build/esm/type/extract/extract.mjs +5 -5
- package/build/esm/type/function/function.mjs +2 -8
- package/build/esm/type/guard/value.mjs +3 -0
- package/build/esm/type/indexed/indexed-from-mapped-key.d.mts +1 -1
- package/build/esm/type/indexed/indexed-from-mapped-key.mjs +2 -1
- package/build/esm/type/indexed/indexed-from-mapped-result.d.mts +1 -1
- package/build/esm/type/indexed/indexed.mjs +10 -6
- package/build/esm/type/instance-type/instance-type.mjs +3 -3
- package/build/esm/type/integer/integer.mjs +3 -6
- package/build/esm/type/intersect/intersect-create.d.mts +1 -1
- package/build/esm/type/intersect/intersect-create.mjs +6 -6
- package/build/esm/type/intersect/intersect-evaluated.mjs +2 -2
- package/build/esm/type/intersect/intersect.mjs +3 -3
- package/build/esm/type/intrinsic/intrinsic-from-mapped-key.mjs +4 -2
- package/build/esm/type/intrinsic/intrinsic.mjs +4 -2
- package/build/esm/type/iterator/iterator.mjs +3 -8
- package/build/esm/type/keyof/keyof-from-mapped-result.d.mts +1 -1
- package/build/esm/type/keyof/keyof-from-mapped-result.mjs +2 -1
- package/build/esm/type/keyof/keyof.mjs +3 -3
- package/build/esm/type/literal/literal.mjs +4 -4
- package/build/esm/type/mapped/mapped-key.mjs +3 -2
- package/build/esm/type/mapped/mapped-result.mjs +3 -2
- package/build/esm/type/mapped/mapped.mjs +2 -3
- package/build/esm/type/never/never.mjs +3 -6
- package/build/esm/type/not/not.d.mts +1 -1
- package/build/esm/type/not/not.mjs +3 -7
- package/build/esm/type/null/null.mjs +3 -6
- package/build/esm/type/number/number.mjs +3 -6
- package/build/esm/type/object/object.mjs +14 -13
- package/build/esm/type/omit/omit-from-mapped-key.d.mts +1 -1
- package/build/esm/type/omit/omit-from-mapped-key.mjs +2 -1
- package/build/esm/type/omit/omit-from-mapped-result.d.mts +1 -1
- package/build/esm/type/omit/omit-from-mapped-result.mjs +2 -1
- package/build/esm/type/omit/omit.mjs +4 -4
- package/build/esm/type/optional/optional.mjs +3 -3
- package/build/esm/type/parameters/parameters.mjs +2 -3
- package/build/esm/type/partial/partial-from-mapped-result.d.mts +1 -1
- package/build/esm/type/partial/partial-from-mapped-result.mjs +2 -1
- package/build/esm/type/partial/partial.mjs +4 -4
- package/build/esm/type/pick/pick-from-mapped-key.d.mts +1 -1
- package/build/esm/type/pick/pick-from-mapped-key.mjs +2 -1
- package/build/esm/type/pick/pick-from-mapped-result.d.mts +1 -1
- package/build/esm/type/pick/pick-from-mapped-result.mjs +2 -1
- package/build/esm/type/pick/pick.mjs +4 -4
- package/build/esm/type/promise/promise.mjs +3 -8
- package/build/esm/type/readonly/readonly.mjs +3 -3
- package/build/esm/type/record/record.mjs +5 -6
- package/build/esm/type/recursive/recursive.mjs +3 -2
- package/build/esm/type/ref/ref.mjs +4 -7
- package/build/esm/type/regexp/regexp.mjs +3 -2
- package/build/esm/type/required/required-from-mapped-result.d.mts +1 -1
- package/build/esm/type/required/required.mjs +4 -4
- package/build/esm/type/rest/rest.d.mts +1 -1
- package/build/esm/type/rest/rest.mjs +4 -5
- package/build/esm/type/return-type/return-type.mjs +3 -3
- package/build/esm/type/string/string.mjs +3 -2
- package/build/esm/type/symbol/symbol.mjs +2 -1
- package/build/esm/type/template-literal/template-literal.mjs +3 -2
- package/build/esm/type/transform/transform.mjs +1 -3
- package/build/esm/type/tuple/tuple.mjs +5 -7
- package/build/esm/type/type/javascript.mjs +13 -13
- package/build/esm/type/type/json.mjs +35 -35
- package/build/esm/type/uint8array/uint8array.mjs +3 -2
- package/build/esm/type/undefined/undefined.mjs +3 -2
- package/build/esm/type/union/union-create.d.mts +1 -1
- package/build/esm/type/union/union-create.mjs +2 -2
- package/build/esm/type/union/union-evaluated.mjs +3 -3
- package/build/esm/type/union/union.mjs +3 -3
- package/build/esm/type/unknown/unknown.mjs +3 -5
- package/build/esm/type/unsafe/unsafe.mjs +2 -4
- package/build/esm/type/void/void.mjs +3 -6
- package/package.json +1 -1
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Integer = Integer;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
7
|
/** `[Json]` Creates an Integer type */
|
|
7
|
-
function Integer(options
|
|
8
|
-
return {
|
|
9
|
-
...options,
|
|
10
|
-
[index_1.Kind]: 'Integer',
|
|
11
|
-
type: 'integer',
|
|
12
|
-
};
|
|
8
|
+
function Integer(options) {
|
|
9
|
+
return (0, type_1.CreateType)({ [index_1.Kind]: 'Integer', type: 'integer' }, options);
|
|
13
10
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { TSchema } from '../schema/index';
|
|
2
2
|
import type { TIntersect, IntersectOptions } from './intersect-type';
|
|
3
|
-
export declare function IntersectCreate<T extends TSchema[]>(T: [...T], options
|
|
3
|
+
export declare function IntersectCreate<T extends TSchema[]>(T: [...T], options?: IntersectOptions): TIntersect<T>;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.IntersectCreate = IntersectCreate;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
|
-
const type_1 = require("../clone/type");
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// TypeGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
@@ -12,12 +12,12 @@ const kind_1 = require("../guard/kind");
|
|
|
12
12
|
// IntersectCreate
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
14
|
// prettier-ignore
|
|
15
|
-
function IntersectCreate(T, options) {
|
|
15
|
+
function IntersectCreate(T, options = {}) {
|
|
16
16
|
const allObjects = T.every((schema) => (0, kind_1.IsObject)(schema));
|
|
17
17
|
const clonedUnevaluatedProperties = (0, kind_1.IsSchema)(options.unevaluatedProperties)
|
|
18
|
-
? { unevaluatedProperties:
|
|
18
|
+
? { unevaluatedProperties: options.unevaluatedProperties }
|
|
19
19
|
: {};
|
|
20
|
-
return ((options.unevaluatedProperties === false || (0, kind_1.IsSchema)(options.unevaluatedProperties) || allObjects
|
|
21
|
-
? { ...
|
|
22
|
-
: { ...
|
|
20
|
+
return (0, type_1.CreateType)((options.unevaluatedProperties === false || (0, kind_1.IsSchema)(options.unevaluatedProperties) || allObjects
|
|
21
|
+
? { ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', type: 'object', allOf: T }
|
|
22
|
+
: { ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', allOf: T }), options);
|
|
23
23
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.IntersectEvaluated = IntersectEvaluated;
|
|
5
5
|
const index_1 = require("../symbols/index");
|
|
6
|
-
const type_1 = require("../
|
|
6
|
+
const type_1 = require("../create/type");
|
|
7
7
|
const index_2 = require("../discard/index");
|
|
8
8
|
const index_3 = require("../never/index");
|
|
9
9
|
const index_4 = require("../optional/index");
|
|
@@ -35,7 +35,7 @@ function IntersectEvaluated(T, options = {}) {
|
|
|
35
35
|
if (T.length === 0)
|
|
36
36
|
return (0, index_3.Never)(options);
|
|
37
37
|
if (T.length === 1)
|
|
38
|
-
return (0, type_1.
|
|
38
|
+
return (0, type_1.CreateType)(T[0], options);
|
|
39
39
|
if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
|
|
40
40
|
throw new Error('Cannot intersect transform types');
|
|
41
41
|
return ResolveIntersect(T, options);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Intersect = Intersect;
|
|
5
|
-
const type_1 = require("../
|
|
5
|
+
const type_1 = require("../create/type");
|
|
6
6
|
const index_1 = require("../never/index");
|
|
7
7
|
const intersect_create_1 = require("./intersect-create");
|
|
8
8
|
// ------------------------------------------------------------------
|
|
@@ -10,11 +10,11 @@ const intersect_create_1 = require("./intersect-create");
|
|
|
10
10
|
// ------------------------------------------------------------------
|
|
11
11
|
const kind_1 = require("../guard/kind");
|
|
12
12
|
/** `[Json]` Creates an evaluated Intersect type */
|
|
13
|
-
function Intersect(T, options
|
|
13
|
+
function Intersect(T, options) {
|
|
14
14
|
if (T.length === 0)
|
|
15
15
|
return (0, index_1.Never)(options);
|
|
16
16
|
if (T.length === 1)
|
|
17
|
-
return (0, type_1.
|
|
17
|
+
return (0, type_1.CreateType)(T[0], options);
|
|
18
18
|
if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
|
|
19
19
|
throw new Error('Cannot intersect transform types');
|
|
20
20
|
return (0, intersect_create_1.IntersectCreate)(T, options);
|
|
@@ -5,17 +5,19 @@ exports.IntrinsicFromMappedKey = IntrinsicFromMappedKey;
|
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const intrinsic_1 = require("./intrinsic");
|
|
7
7
|
const index_2 = require("../literal/index");
|
|
8
|
+
const value_1 = require("../clone/value");
|
|
8
9
|
// prettier-ignore
|
|
9
10
|
function MappedIntrinsicPropertyKey(K, M, options) {
|
|
10
11
|
return {
|
|
11
|
-
[K]: (0, intrinsic_1.Intrinsic)((0, index_2.Literal)(K), M, options)
|
|
12
|
+
[K]: (0, intrinsic_1.Intrinsic)((0, index_2.Literal)(K), M, (0, value_1.Clone)(options))
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
// prettier-ignore
|
|
15
16
|
function MappedIntrinsicPropertyKeys(K, M, options) {
|
|
16
|
-
|
|
17
|
+
const result = K.reduce((Acc, L) => {
|
|
17
18
|
return { ...Acc, ...MappedIntrinsicPropertyKey(L, M, options) };
|
|
18
19
|
}, {});
|
|
20
|
+
return result;
|
|
19
21
|
}
|
|
20
22
|
// prettier-ignore
|
|
21
23
|
function MappedIntrinsicProperties(T, M, options) {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Intrinsic = Intrinsic;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../template-literal/index");
|
|
6
7
|
const intrinsic_from_mapped_key_1 = require("./intrinsic-from-mapped-key");
|
|
7
8
|
const index_2 = require("../literal/index");
|
|
@@ -59,8 +60,9 @@ function Intrinsic(schema, mode, options = {}) {
|
|
|
59
60
|
// Intrinsic-Mapped-Inference
|
|
60
61
|
(0, kind_1.IsMappedKey)(schema) ? (0, intrinsic_from_mapped_key_1.IntrinsicFromMappedKey)(schema, mode, options) :
|
|
61
62
|
// Standard-Inference
|
|
62
|
-
(0, kind_1.IsTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode,
|
|
63
|
+
(0, kind_1.IsTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode, options) :
|
|
63
64
|
(0, kind_1.IsUnion)(schema) ? (0, index_3.Union)(FromRest(schema.anyOf, mode), options) :
|
|
64
65
|
(0, kind_1.IsLiteral)(schema) ? (0, index_2.Literal)(FromLiteralValue(schema.const, mode), options) :
|
|
65
|
-
|
|
66
|
+
// Default Type
|
|
67
|
+
(0, type_1.CreateType)(schema, options));
|
|
66
68
|
}
|
|
@@ -2,14 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Iterator = Iterator;
|
|
5
|
-
const type_1 = require("../
|
|
5
|
+
const type_1 = require("../create/type");
|
|
6
6
|
const index_1 = require("../symbols/index");
|
|
7
7
|
/** `[JavaScript]` Creates an Iterator type */
|
|
8
|
-
function Iterator(items, options
|
|
9
|
-
return {
|
|
10
|
-
...options,
|
|
11
|
-
[index_1.Kind]: 'Iterator',
|
|
12
|
-
type: 'Iterator',
|
|
13
|
-
items: (0, type_1.CloneType)(items),
|
|
14
|
-
};
|
|
8
|
+
function Iterator(items, options) {
|
|
9
|
+
return (0, type_1.CreateType)({ [index_1.Kind]: 'Iterator', type: 'Iterator', items }, options);
|
|
15
10
|
}
|
|
@@ -8,5 +8,5 @@ type TFromProperties<K extends TProperties> = ({
|
|
|
8
8
|
});
|
|
9
9
|
type TFromMappedResult<R extends TMappedResult> = (Evaluate<TFromProperties<R['properties']>>);
|
|
10
10
|
export type TKeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (Ensure<TMappedResult<P>>);
|
|
11
|
-
export declare function KeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options
|
|
11
|
+
export declare function KeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options?: SchemaOptions): TMappedResult<P>;
|
|
12
12
|
export {};
|
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.KeyOfFromMappedResult = KeyOfFromMappedResult;
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const keyof_1 = require("./keyof");
|
|
7
|
+
const value_1 = require("../clone/value");
|
|
7
8
|
// prettier-ignore
|
|
8
9
|
function FromProperties(K, options) {
|
|
9
10
|
const Acc = {};
|
|
10
11
|
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
11
|
-
Acc[K2] = (0, keyof_1.KeyOf)(K[K2], options);
|
|
12
|
+
Acc[K2] = (0, keyof_1.KeyOf)(K[K2], (0, value_1.Clone)(options));
|
|
12
13
|
return Acc;
|
|
13
14
|
}
|
|
14
15
|
// prettier-ignore
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.KeyOfPropertyKeysToRest = KeyOfPropertyKeysToRest;
|
|
5
5
|
exports.KeyOf = KeyOf;
|
|
6
|
+
const type_1 = require("../create/type");
|
|
6
7
|
const index_1 = require("../literal/index");
|
|
7
8
|
const index_2 = require("../number/index");
|
|
8
9
|
const keyof_property_keys_1 = require("./keyof-property-keys");
|
|
9
10
|
const index_3 = require("../union/index");
|
|
10
|
-
const type_1 = require("../clone/type");
|
|
11
11
|
const keyof_from_mapped_result_1 = require("./keyof-from-mapped-result");
|
|
12
12
|
// ------------------------------------------------------------------
|
|
13
13
|
// TypeGuard
|
|
@@ -18,7 +18,7 @@ function KeyOfPropertyKeysToRest(T) {
|
|
|
18
18
|
return T.map(L => L === '[number]' ? (0, index_2.Number)() : (0, index_1.Literal)(L));
|
|
19
19
|
}
|
|
20
20
|
/** `[Json]` Creates a KeyOf type */
|
|
21
|
-
function KeyOf(T, options
|
|
21
|
+
function KeyOf(T, options) {
|
|
22
22
|
if ((0, kind_1.IsMappedResult)(T)) {
|
|
23
23
|
return (0, keyof_from_mapped_result_1.KeyOfFromMappedResult)(T, options);
|
|
24
24
|
}
|
|
@@ -26,6 +26,6 @@ function KeyOf(T, options = {}) {
|
|
|
26
26
|
const K = (0, keyof_property_keys_1.KeyOfPropertyKeys)(T);
|
|
27
27
|
const S = KeyOfPropertyKeysToRest(K);
|
|
28
28
|
const U = (0, index_3.UnionEvaluated)(S);
|
|
29
|
-
return (0, type_1.
|
|
29
|
+
return (0, type_1.CreateType)(U, options);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Literal = Literal;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
7
|
/** `[Json]` Creates a Literal type */
|
|
7
|
-
function Literal(value, options
|
|
8
|
-
return {
|
|
9
|
-
...options,
|
|
8
|
+
function Literal(value, options) {
|
|
9
|
+
return (0, type_1.CreateType)({
|
|
10
10
|
[index_1.Kind]: 'Literal',
|
|
11
11
|
const: value,
|
|
12
12
|
type: typeof value,
|
|
13
|
-
};
|
|
13
|
+
}, options);
|
|
14
14
|
}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MappedKey = MappedKey;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
7
|
// prettier-ignore
|
|
7
8
|
function MappedKey(T) {
|
|
8
|
-
return {
|
|
9
|
+
return (0, type_1.CreateType)({
|
|
9
10
|
[index_1.Kind]: 'MappedKey',
|
|
10
11
|
keys: T
|
|
11
|
-
};
|
|
12
|
+
});
|
|
12
13
|
}
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.MappedResult = MappedResult;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
7
|
// prettier-ignore
|
|
7
8
|
function MappedResult(properties) {
|
|
8
|
-
return {
|
|
9
|
+
return (0, type_1.CreateType)({
|
|
9
10
|
[index_1.Kind]: 'MappedResult',
|
|
10
11
|
properties
|
|
11
|
-
};
|
|
12
|
+
});
|
|
12
13
|
}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.MappedFunctionReturnType = MappedFunctionReturnType;
|
|
5
5
|
exports.Mapped = Mapped;
|
|
6
6
|
const index_1 = require("../symbols/index");
|
|
7
|
-
const type_1 = require("../clone/type");
|
|
8
7
|
const index_2 = require("../discard/index");
|
|
9
8
|
// evaluation types
|
|
10
9
|
const index_3 = require("../array/index");
|
|
@@ -98,9 +97,9 @@ function MappedFunctionReturnType(K, T) {
|
|
|
98
97
|
return Acc;
|
|
99
98
|
}
|
|
100
99
|
/** `[Json]` Creates a Mapped object type */
|
|
101
|
-
function Mapped(key, map, options
|
|
100
|
+
function Mapped(key, map, options) {
|
|
102
101
|
const K = (0, kind_1.IsSchema)(key) ? (0, index_7.IndexPropertyKeys)(key) : key;
|
|
103
102
|
const RT = map({ [index_1.Kind]: 'MappedKey', keys: K });
|
|
104
103
|
const R = MappedFunctionReturnType(K, RT);
|
|
105
|
-
return (0,
|
|
104
|
+
return (0, index_11.Object)(R, options);
|
|
106
105
|
}
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Never = Never;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
7
|
/** `[Json]` Creates a Never type */
|
|
7
|
-
function Never(options
|
|
8
|
-
return {
|
|
9
|
-
...options,
|
|
10
|
-
[index_1.Kind]: 'Never',
|
|
11
|
-
not: {},
|
|
12
|
-
};
|
|
8
|
+
function Never(options) {
|
|
9
|
+
return (0, type_1.CreateType)({ [index_1.Kind]: 'Never', not: {} }, options);
|
|
13
10
|
}
|
|
@@ -7,4 +7,4 @@ export interface TNot<T extends TSchema = TSchema> extends TSchema {
|
|
|
7
7
|
not: T;
|
|
8
8
|
}
|
|
9
9
|
/** `[Json]` Creates a Not type */
|
|
10
|
-
export declare function Not<T extends TSchema>(
|
|
10
|
+
export declare function Not<T extends TSchema>(not: T, options?: SchemaOptions): TNot<T>;
|
|
@@ -2,13 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Not = Not;
|
|
5
|
-
const type_1 = require("../
|
|
5
|
+
const type_1 = require("../create/type");
|
|
6
6
|
const index_1 = require("../symbols/index");
|
|
7
7
|
/** `[Json]` Creates a Not type */
|
|
8
|
-
function Not(
|
|
9
|
-
return {
|
|
10
|
-
...options,
|
|
11
|
-
[index_1.Kind]: 'Not',
|
|
12
|
-
not: (0, type_1.CloneType)(schema),
|
|
13
|
-
};
|
|
8
|
+
function Not(not, options) {
|
|
9
|
+
return (0, type_1.CreateType)({ [index_1.Kind]: 'Not', not }, options);
|
|
14
10
|
}
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Null = Null;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
7
|
/** `[Json]` Creates a Null type */
|
|
7
|
-
function Null(options
|
|
8
|
-
return {
|
|
9
|
-
...options,
|
|
10
|
-
[index_1.Kind]: 'Null',
|
|
11
|
-
type: 'null',
|
|
12
|
-
};
|
|
8
|
+
function Null(options) {
|
|
9
|
+
return (0, type_1.CreateType)({ [index_1.Kind]: 'Null', type: 'null' }, options);
|
|
13
10
|
}
|
|
@@ -2,12 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Number = Number;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
7
|
/** `[Json]` Creates a Number type */
|
|
7
|
-
function Number(options
|
|
8
|
-
return {
|
|
9
|
-
...options,
|
|
10
|
-
[index_1.Kind]: 'Number',
|
|
11
|
-
type: 'number',
|
|
12
|
-
};
|
|
8
|
+
function Number(options) {
|
|
9
|
+
return (0, type_1.CreateType)({ [index_1.Kind]: 'Number', type: 'number' }, options);
|
|
13
10
|
}
|
|
@@ -2,24 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Object = void 0;
|
|
5
|
-
const type_1 = require("../
|
|
5
|
+
const type_1 = require("../create/type");
|
|
6
6
|
const index_1 = require("../symbols/index");
|
|
7
7
|
// ------------------------------------------------------------------
|
|
8
8
|
// TypeGuard
|
|
9
9
|
// ------------------------------------------------------------------
|
|
10
10
|
const kind_1 = require("../guard/kind");
|
|
11
|
+
function RequiredKeys(properties) {
|
|
12
|
+
const keys = [];
|
|
13
|
+
for (let key in properties) {
|
|
14
|
+
if (!(0, kind_1.IsOptional)(properties[key]))
|
|
15
|
+
keys.push(key);
|
|
16
|
+
}
|
|
17
|
+
return keys;
|
|
18
|
+
}
|
|
11
19
|
/** `[Json]` Creates an Object type */
|
|
12
|
-
function _Object(properties, options
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const clonedAdditionalProperties = (0, kind_1.IsSchema)(options.additionalProperties) ? { additionalProperties: (0, type_1.CloneType)(options.additionalProperties) } : {};
|
|
17
|
-
const clonedProperties = {};
|
|
18
|
-
for (const key of propertyKeys)
|
|
19
|
-
clonedProperties[key] = (0, type_1.CloneType)(properties[key]);
|
|
20
|
-
return (requiredKeys.length > 0
|
|
21
|
-
? { ...options, ...clonedAdditionalProperties, [index_1.Kind]: 'Object', type: 'object', properties: clonedProperties, required: requiredKeys }
|
|
22
|
-
: { ...options, ...clonedAdditionalProperties, [index_1.Kind]: 'Object', type: 'object', properties: clonedProperties });
|
|
20
|
+
function _Object(properties, options) {
|
|
21
|
+
const required = RequiredKeys(properties);
|
|
22
|
+
const schematic = required.length > 0 ? { [index_1.Kind]: 'Object', type: 'object', properties, required } : { [index_1.Kind]: 'Object', type: 'object', properties };
|
|
23
|
+
return (0, type_1.CreateType)(schematic, options);
|
|
23
24
|
}
|
|
24
25
|
/** `[Json]` Creates an Object type */
|
|
25
26
|
exports.Object = _Object;
|
|
@@ -8,5 +8,5 @@ type TFromPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
|
8
8
|
type TFromPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TProperties = {}> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? TFromPropertyKeys<T, RK, Acc & TFromPropertyKey<T, LK>> : Acc);
|
|
9
9
|
type TFromMappedKey<T extends TSchema, K extends TMappedKey> = (TFromPropertyKeys<T, K['keys']>);
|
|
10
10
|
export type TOmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>> = (TMappedResult<P>);
|
|
11
|
-
export declare function OmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>>(T: T, K: K, options
|
|
11
|
+
export declare function OmitFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>>(T: T, K: K, options?: SchemaOptions): TMappedResult<P>;
|
|
12
12
|
export {};
|
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.OmitFromMappedKey = OmitFromMappedKey;
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const omit_1 = require("./omit");
|
|
7
|
+
const value_1 = require("../clone/value");
|
|
7
8
|
// prettier-ignore
|
|
8
9
|
function FromPropertyKey(T, K, options) {
|
|
9
10
|
return {
|
|
10
|
-
[K]: (0, omit_1.Omit)(T, [K], options)
|
|
11
|
+
[K]: (0, omit_1.Omit)(T, [K], (0, value_1.Clone)(options))
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
// prettier-ignore
|
|
@@ -8,5 +8,5 @@ type TFromProperties<P extends TProperties, K extends PropertyKey[]> = ({
|
|
|
8
8
|
});
|
|
9
9
|
type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (Evaluate<TFromProperties<R['properties'], K>>);
|
|
10
10
|
export type TOmitFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (Ensure<TMappedResult<P>>);
|
|
11
|
-
export declare function OmitFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options
|
|
11
|
+
export declare function OmitFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options?: SchemaOptions): TMappedResult<P>;
|
|
12
12
|
export {};
|
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.OmitFromMappedResult = OmitFromMappedResult;
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const omit_1 = require("./omit");
|
|
7
|
+
const value_1 = require("../clone/value");
|
|
7
8
|
// prettier-ignore
|
|
8
9
|
function FromProperties(P, K, options) {
|
|
9
10
|
const Acc = {};
|
|
10
11
|
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
11
|
-
Acc[K2] = (0, omit_1.Omit)(P[K2], K, options);
|
|
12
|
+
Acc[K2] = (0, omit_1.Omit)(P[K2], K, (0, value_1.Clone)(options));
|
|
12
13
|
return Acc;
|
|
13
14
|
}
|
|
14
15
|
// prettier-ignore
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Omit = Omit;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../intersect/index");
|
|
6
7
|
const index_2 = require("../union/index");
|
|
7
8
|
const index_3 = require("../object/index");
|
|
8
9
|
const index_4 = require("../indexed/index");
|
|
9
10
|
const index_5 = require("../discard/index");
|
|
10
11
|
const index_6 = require("../symbols/index");
|
|
11
|
-
const type_1 = require("../clone/type");
|
|
12
12
|
const omit_from_mapped_key_1 = require("./omit-from-mapped-key");
|
|
13
13
|
const omit_from_mapped_result_1 = require("./omit-from-mapped-result");
|
|
14
14
|
// ------------------------------------------------------------------
|
|
@@ -45,7 +45,7 @@ function OmitResolve(T, K) {
|
|
|
45
45
|
(0, kind_1.IsObject)(T) ? (0, index_3.Object)(FromProperties(T.properties, K)) :
|
|
46
46
|
(0, index_3.Object)({}));
|
|
47
47
|
}
|
|
48
|
-
function Omit(T, K, options
|
|
48
|
+
function Omit(T, K, options) {
|
|
49
49
|
// mapped
|
|
50
50
|
if ((0, kind_1.IsMappedKey)(K))
|
|
51
51
|
return (0, omit_from_mapped_key_1.OmitFromMappedKey)(T, K, options);
|
|
@@ -54,6 +54,6 @@ function Omit(T, K, options = {}) {
|
|
|
54
54
|
// non-mapped
|
|
55
55
|
const I = (0, kind_1.IsSchema)(K) ? (0, index_4.IndexPropertyKeys)(K) : K;
|
|
56
56
|
const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);
|
|
57
|
-
const R =
|
|
58
|
-
return { ...D, ...R };
|
|
57
|
+
const R = OmitResolve(T, I);
|
|
58
|
+
return (0, type_1.CreateType)({ ...D, ...R }, options);
|
|
59
59
|
}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Optional = Optional;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../symbols/index");
|
|
6
|
-
const type_1 = require("../clone/type");
|
|
7
7
|
const index_2 = require("../discard/index");
|
|
8
8
|
const optional_from_mapped_result_1 = require("./optional-from-mapped-result");
|
|
9
9
|
const kind_1 = require("../guard/kind");
|
|
10
10
|
function RemoveOptional(schema) {
|
|
11
|
-
return (0,
|
|
11
|
+
return (0, type_1.CreateType)((0, index_2.Discard)(schema, [index_1.OptionalKind]));
|
|
12
12
|
}
|
|
13
13
|
function AddOptional(schema) {
|
|
14
|
-
return
|
|
14
|
+
return (0, type_1.CreateType)({ ...schema, [index_1.OptionalKind]: 'Optional' });
|
|
15
15
|
}
|
|
16
16
|
// prettier-ignore
|
|
17
17
|
function OptionalWithFlag(schema, F) {
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Parameters = Parameters;
|
|
5
5
|
const index_1 = require("../tuple/index");
|
|
6
|
-
const type_1 = require("../clone/type");
|
|
7
6
|
/** `[JavaScript]` Extracts the Parameters from the given Function type */
|
|
8
|
-
function Parameters(schema, options
|
|
9
|
-
return (0, index_1.Tuple)(
|
|
7
|
+
function Parameters(schema, options) {
|
|
8
|
+
return (0, index_1.Tuple)(schema.parameters, options);
|
|
10
9
|
}
|
|
@@ -8,5 +8,5 @@ type TFromProperties<P extends TProperties> = ({
|
|
|
8
8
|
});
|
|
9
9
|
type TFromMappedResult<R extends TMappedResult> = (Evaluate<TFromProperties<R['properties']>>);
|
|
10
10
|
export type TPartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (Ensure<TMappedResult<P>>);
|
|
11
|
-
export declare function PartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options
|
|
11
|
+
export declare function PartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options?: SchemaOptions): TMappedResult<P>;
|
|
12
12
|
export {};
|
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.PartialFromMappedResult = PartialFromMappedResult;
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const partial_1 = require("./partial");
|
|
7
|
+
const value_1 = require("../clone/value");
|
|
7
8
|
// prettier-ignore
|
|
8
9
|
function FromProperties(K, options) {
|
|
9
10
|
const Acc = {};
|
|
10
11
|
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
|
|
11
|
-
Acc[K2] = (0, partial_1.Partial)(K[K2], options);
|
|
12
|
+
Acc[K2] = (0, partial_1.Partial)(K[K2], (0, value_1.Clone)(options));
|
|
12
13
|
return Acc;
|
|
13
14
|
}
|
|
14
15
|
// prettier-ignore
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.Partial = Partial;
|
|
5
|
+
const type_1 = require("../create/type");
|
|
5
6
|
const index_1 = require("../optional/index");
|
|
6
7
|
const index_2 = require("../object/index");
|
|
7
8
|
const index_3 = require("../intersect/index");
|
|
8
9
|
const index_4 = require("../union/index");
|
|
9
10
|
const index_5 = require("../discard/index");
|
|
10
11
|
const index_6 = require("../symbols/index");
|
|
11
|
-
const type_1 = require("../clone/type");
|
|
12
12
|
const partial_from_mapped_result_1 = require("./partial-from-mapped-result");
|
|
13
13
|
// ------------------------------------------------------------------
|
|
14
14
|
// TypeGuard
|
|
@@ -36,10 +36,10 @@ function PartialResolve(T) {
|
|
|
36
36
|
(0, index_2.Object)({}));
|
|
37
37
|
}
|
|
38
38
|
/** `[Json]` Constructs a type where all properties are optional */
|
|
39
|
-
function Partial(T, options
|
|
39
|
+
function Partial(T, options) {
|
|
40
40
|
if ((0, kind_1.IsMappedResult)(T))
|
|
41
41
|
return (0, partial_from_mapped_result_1.PartialFromMappedResult)(T, options);
|
|
42
42
|
const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);
|
|
43
|
-
const R =
|
|
44
|
-
return { ...D, ...R };
|
|
43
|
+
const R = PartialResolve(T);
|
|
44
|
+
return (0, type_1.CreateType)({ ...options, ...D, ...R });
|
|
45
45
|
}
|
|
@@ -8,5 +8,5 @@ type TFromPropertyKey<T extends TSchema, K extends PropertyKey> = {
|
|
|
8
8
|
type TFromPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TProperties = {}> = (K extends [infer LK extends PropertyKey, ...infer RK extends PropertyKey[]] ? TFromPropertyKeys<T, RK, Acc & TFromPropertyKey<T, LK>> : Acc);
|
|
9
9
|
type TFromMappedKey<T extends TSchema, K extends TMappedKey> = (TFromPropertyKeys<T, K['keys']>);
|
|
10
10
|
export type TPickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>> = (TMappedResult<P>);
|
|
11
|
-
export declare function PickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>>(T: T, K: K, options
|
|
11
|
+
export declare function PickFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TFromMappedKey<T, K>>(T: T, K: K, options?: SchemaOptions): TMappedResult<P>;
|
|
12
12
|
export {};
|
|
@@ -4,10 +4,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.PickFromMappedKey = PickFromMappedKey;
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const pick_1 = require("./pick");
|
|
7
|
+
const value_1 = require("../clone/value");
|
|
7
8
|
// prettier-ignore
|
|
8
9
|
function FromPropertyKey(T, K, options) {
|
|
9
10
|
return {
|
|
10
|
-
[K]: (0, pick_1.Pick)(T, [K], options)
|
|
11
|
+
[K]: (0, pick_1.Pick)(T, [K], (0, value_1.Clone)(options))
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
// prettier-ignore
|
|
@@ -8,5 +8,5 @@ type TFromProperties<P extends TProperties, K extends PropertyKey[]> = ({
|
|
|
8
8
|
});
|
|
9
9
|
type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (Evaluate<TFromProperties<R['properties'], K>>);
|
|
10
10
|
export type TPickFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (Ensure<TMappedResult<P>>);
|
|
11
|
-
export declare function PickFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options
|
|
11
|
+
export declare function PickFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options?: SchemaOptions): TMappedResult<P>;
|
|
12
12
|
export {};
|
|
@@ -4,11 +4,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.PickFromMappedResult = PickFromMappedResult;
|
|
5
5
|
const index_1 = require("../mapped/index");
|
|
6
6
|
const pick_1 = require("./pick");
|
|
7
|
+
const value_1 = require("../clone/value");
|
|
7
8
|
// prettier-ignore
|
|
8
9
|
function FromProperties(P, K, options) {
|
|
9
10
|
const Acc = {};
|
|
10
11
|
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
|
|
11
|
-
Acc[K2] = (0, pick_1.Pick)(P[K2], K, options);
|
|
12
|
+
Acc[K2] = (0, pick_1.Pick)(P[K2], K, (0, value_1.Clone)(options));
|
|
12
13
|
return Acc;
|
|
13
14
|
}
|
|
14
15
|
// prettier-ignore
|