Socket
Socket
Sign inDemoInstall

@sinclair/typebox

Package Overview
Dependencies
0
Maintainers
1
Versions
309
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.32.24 to 0.32.25

build/import/type/guard/kind.d.mts

8

build/require/type/awaited/awaited.js

@@ -11,3 +11,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -34,5 +34,5 @@ function FromRest(T) {

function AwaitedResolve(T) {
return ((0, type_2.IsIntersect)(T) ? FromIntersect(T.allOf) :
(0, type_2.IsUnion)(T) ? FromUnion(T.anyOf) :
(0, type_2.IsPromise)(T) ? FromPromise(T.item) :
return ((0, kind_1.IsIntersect)(T) ? FromIntersect(T.allOf) :
(0, kind_1.IsUnion)(T) ? FromUnion(T.anyOf) :
(0, kind_1.IsPromise)(T) ? FromPromise(T.item) :
T);

@@ -39,0 +39,0 @@ }

@@ -19,5 +19,10 @@ "use strict";

function ObjectType(value) {
const clonedProperties = Object.getOwnPropertyNames(value).reduce((acc, key) => ({ ...acc, [key]: Visit(value[key]) }), {});
const clonedSymbols = Object.getOwnPropertySymbols(value).reduce((acc, key) => ({ ...acc, [key]: Visit(value[key]) }), {});
return { ...clonedProperties, ...clonedSymbols };
const result = {};
for (const key of Object.getOwnPropertyNames(value)) {
result[key] = Visit(value[key]);
}
for (const key of Object.getOwnPropertySymbols(value)) {
result[key] = Visit(value[key]);
}
return result;
}

@@ -24,0 +29,0 @@ // prettier-ignore

@@ -13,24 +13,28 @@ "use strict";

// ------------------------------------------------------------------
const type_1 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore
function CompositeKeys(T) {
return (0, index_5.SetDistinct)(T.reduce((Acc, L) => {
return ([...Acc, ...(0, index_3.KeyOfPropertyKeys)(L)]);
}, []));
const Acc = [];
for (const L of T)
Acc.push(...(0, index_3.KeyOfPropertyKeys)(L));
return (0, index_5.SetDistinct)(Acc);
}
// prettier-ignore
function FilterNever(T) {
return T.filter(L => !(0, type_1.IsNever)(L));
return T.filter(L => !(0, kind_1.IsNever)(L));
}
// prettier-ignore
function CompositeProperty(T, K) {
return FilterNever(T.reduce((Acc, L) => {
return [...Acc, ...(0, index_2.IndexFromPropertyKeys)(L, [K])];
}, []));
const Acc = [];
for (const L of T)
Acc.push(...(0, index_2.IndexFromPropertyKeys)(L, [K]));
return FilterNever(Acc);
}
// prettier-ignore
function CompositeProperties(T, K) {
return K.reduce((Acc, L) => {
return { ...Acc, [L]: (0, index_1.IntersectEvaluated)(CompositeProperty(T, L)) };
}, {});
const Acc = {};
for (const L of K) {
Acc[L] = (0, index_1.IntersectEvaluated)(CompositeProperty(T, L));
}
return Acc;
}

@@ -37,0 +41,0 @@ // prettier-ignore

@@ -29,5 +29,6 @@ "use strict";

function FromProperties(value) {
return globalThis.Object.getOwnPropertyNames(value).reduce((acc, key) => {
return { ...acc, [key]: (0, index_10.Readonly)(FromValue(value[key], false)) };
}, {});
const Acc = {};
for (const K of globalThis.Object.getOwnPropertyNames(value))
Acc[K] = (0, index_10.Readonly)(FromValue(value[K], false));
return Acc;
}

@@ -34,0 +35,0 @@ function ConditionalReadonly(T, root) {

@@ -18,3 +18,3 @@ import type { TSchema } from '../schema/index';

}>;
declare function FromProperties(properties: TProperties, references: TSchema[]): TProperties;
declare function FromProperties(properties: TProperties, references: TSchema[]): never;
export type TDeref<T extends TSchema> = T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<S>, TDeref<R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<S>, TDeref<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<TFromRest<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<TFromRest<S>> : T extends TObject<infer S extends TProperties> ? TObject<FromProperties<S>> : T extends TArray<infer S extends TSchema> ? TArray<TDeref<S>> : T extends TPromise<infer S extends TSchema> ? TPromise<TDeref<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<TDeref<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<TDeref<S>> : T extends TRef<infer S extends TSchema> ? TDeref<S> : T;

@@ -21,0 +21,0 @@ /** `[Json]` Creates a dereferenced type */

@@ -11,3 +11,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
function FromRest(schema, references) {

@@ -18,5 +18,7 @@ return schema.map((schema) => Deref(schema, references));

function FromProperties(properties, references) {
return globalThis.Object.getOwnPropertyNames(properties).reduce((acc, key) => {
return { ...acc, [key]: Deref(properties[key], references) };
}, {});
const Acc = {};
for (const K of globalThis.Object.getOwnPropertyNames(properties)) {
Acc[K] = Deref(properties[K], references);
}
return Acc;
}

@@ -87,13 +89,13 @@ // prettier-ignore

function DerefResolve(schema, references) {
return ((0, type_2.IsConstructor)(schema) ? FromConstructor(schema, references) :
(0, type_2.IsFunction)(schema) ? FromFunction(schema, references) :
(0, type_2.IsIntersect)(schema) ? FromIntersect(schema, references) :
(0, type_2.IsUnion)(schema) ? FromUnion(schema, references) :
(0, type_2.IsTuple)(schema) ? FromTuple(schema, references) :
(0, type_2.IsArray)(schema) ? FromArray(schema, references) :
(0, type_2.IsObject)(schema) ? FromObject(schema, references) :
(0, type_2.IsPromise)(schema) ? FromPromise(schema, references) :
(0, type_2.IsAsyncIterator)(schema) ? FromAsyncIterator(schema, references) :
(0, type_2.IsIterator)(schema) ? FromIterator(schema, references) :
(0, type_2.IsRef)(schema) ? FromRef(schema, references) :
return ((0, kind_1.IsConstructor)(schema) ? FromConstructor(schema, references) :
(0, kind_1.IsFunction)(schema) ? FromFunction(schema, references) :
(0, kind_1.IsIntersect)(schema) ? FromIntersect(schema, references) :
(0, kind_1.IsUnion)(schema) ? FromUnion(schema, references) :
(0, kind_1.IsTuple)(schema) ? FromTuple(schema, references) :
(0, kind_1.IsArray)(schema) ? FromArray(schema, references) :
(0, kind_1.IsObject)(schema) ? FromObject(schema, references) :
(0, kind_1.IsPromise)(schema) ? FromPromise(schema, references) :
(0, kind_1.IsAsyncIterator)(schema) ? FromAsyncIterator(schema, references) :
(0, kind_1.IsIterator)(schema) ? FromIterator(schema, references) :
(0, kind_1.IsRef)(schema) ? FromRef(schema, references) :
schema);

@@ -100,0 +102,0 @@ }

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(P, U) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, exclude_1.Exclude)(P[K2], U) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
Acc[K2] = (0, exclude_1.Exclude)(P[K2], U);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -14,3 +14,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
function ExcludeRest(L, R) {

@@ -23,10 +23,10 @@ const excluded = L.filter((inner) => (0, index_3.ExtendsCheck)(inner, R) === index_3.ExtendsResult.False);

// overloads
if ((0, type_2.IsTemplateLiteral)(L))
if ((0, kind_1.IsTemplateLiteral)(L))
return (0, type_1.CloneType)((0, exclude_from_template_literal_1.ExcludeFromTemplateLiteral)(L, R), options);
if ((0, type_2.IsMappedResult)(L))
if ((0, kind_1.IsMappedResult)(L))
return (0, type_1.CloneType)((0, exclude_from_mapped_result_1.ExcludeFromMappedResult)(L, R), options);
// prettier-ignore
return (0, type_1.CloneType)((0, type_2.IsUnion)(L) ? ExcludeRest(L.anyOf, R) :
return (0, type_1.CloneType)((0, kind_1.IsUnion)(L) ? ExcludeRest(L.anyOf, R) :
(0, index_3.ExtendsCheck)(L, R) !== index_3.ExtendsResult.False ? (0, index_2.Never)() : L, options);
}
exports.Exclude = Exclude;

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(P, Right, True, False, options) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, extends_1.Extends)(P[K2], Right, True, False, options) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
Acc[K2] = (0, extends_1.Extends)(P[K2], Right, True, False, options);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -13,3 +13,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -25,6 +25,6 @@ function ExtendsResolve(left, right, trueType, falseType) {

// prettier-ignore
return ((0, type_2.IsMappedResult)(L) ? (0, extends_from_mapped_result_1.ExtendsFromMappedResult)(L, R, T, F, options) :
(0, type_2.IsMappedKey)(L) ? (0, type_1.CloneType)((0, extends_from_mapped_key_1.ExtendsFromMappedKey)(L, R, T, F, options)) :
return ((0, kind_1.IsMappedResult)(L) ? (0, extends_from_mapped_result_1.ExtendsFromMappedResult)(L, R, T, F, options) :
(0, kind_1.IsMappedKey)(L) ? (0, type_1.CloneType)((0, extends_from_mapped_key_1.ExtendsFromMappedKey)(L, R, T, F, options)) :
(0, type_1.CloneType)(ExtendsResolve(L, R, T, F), options));
}
exports.Extends = Extends;

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(P, T) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, extract_1.Extract)(P[K2], T) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
Acc[K2] = (0, extract_1.Extract)(P[K2], T);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -14,3 +14,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
function ExtractRest(L, R) {

@@ -23,10 +23,10 @@ const extracted = L.filter((inner) => (0, index_3.ExtendsCheck)(inner, R) !== index_3.ExtendsResult.False);

// overloads
if ((0, type_2.IsTemplateLiteral)(L))
if ((0, kind_1.IsTemplateLiteral)(L))
return (0, type_1.CloneType)((0, extract_from_template_literal_1.ExtractFromTemplateLiteral)(L, R), options);
if ((0, type_2.IsMappedResult)(L))
if ((0, kind_1.IsMappedResult)(L))
return (0, type_1.CloneType)((0, extract_from_mapped_result_1.ExtractFromMappedResult)(L, R), options);
// prettier-ignore
return (0, type_1.CloneType)((0, type_2.IsUnion)(L) ? ExtractRest(L.anyOf, R) :
return (0, type_1.CloneType)((0, kind_1.IsUnion)(L) ? ExtractRest(L.anyOf, R) :
(0, index_3.ExtendsCheck)(L, R) !== index_3.ExtendsResult.False ? L : (0, index_2.Never)(), options);
}
exports.Extract = Extract;

@@ -0,2 +1,3 @@

export * as KindGuard from './kind';
export * as TypeGuard from './type';
export * as ValueGuard from './value';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ValueGuard = exports.TypeGuard = void 0;
exports.ValueGuard = exports.TypeGuard = exports.KindGuard = void 0;
exports.KindGuard = require("./kind");
exports.TypeGuard = require("./type");
exports.ValueGuard = require("./value");
import { Kind, Hint, TransformKind } from '../symbols/index';
import { TypeBoxError } from '../error/index';
import { TransformOptions } from '../transform/index';
import { TTemplateLiteral, TTemplateLiteralKind } from '../template-literal/index';
import { TTemplateLiteral } from '../template-literal/index';
import { TArray } from '../array/index';

@@ -115,3 +115,3 @@ import { TBoolean } from '../boolean/index';

/** Returns true if the given value is TTemplateLiteral */
export declare function IsTemplateLiteral(value: unknown): value is TTemplateLiteral<TTemplateLiteralKind[]>;
export declare function IsTemplateLiteral(value: unknown): value is TTemplateLiteral;
/** Returns true if the given value is TThis */

@@ -118,0 +118,0 @@ export declare function IsThis(value: unknown): value is TThis;

@@ -10,5 +10,7 @@ "use strict";

function FromProperties(T, P, options) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, index_2.Index)(T, (0, indexed_property_keys_1.IndexPropertyKeys)(P[K2]), options) };
}, {});
const Acc = {};
for (const K2 of Object.getOwnPropertyNames(P)) {
Acc[K2] = (0, index_2.Index)(T, (0, indexed_property_keys_1.IndexPropertyKeys)(P[K2]), options);
}
return Acc;
}

@@ -15,0 +17,0 @@ // prettier-ignore

@@ -9,3 +9,3 @@ "use strict";

// ------------------------------------------------------------------
const type_1 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -18,5 +18,6 @@ function FromTemplateLiteral(T) {

function FromUnion(T) {
return T.reduce((Acc, L) => {
return [...Acc, ...IndexPropertyKeys(L)];
}, []);
const Acc = [];
for (const L of T)
Acc.push(...IndexPropertyKeys(L));
return Acc;
}

@@ -31,9 +32,9 @@ // prettier-ignore

function IndexPropertyKeys(T) {
return [...new Set(((0, type_1.IsTemplateLiteral)(T) ? FromTemplateLiteral(T) :
(0, type_1.IsUnion)(T) ? FromUnion(T.anyOf) :
(0, type_1.IsLiteral)(T) ? FromLiteral(T.const) :
(0, type_1.IsNumber)(T) ? ['[number]'] :
(0, type_1.IsInteger)(T) ? ['[number]'] :
return [...new Set(((0, kind_1.IsTemplateLiteral)(T) ? FromTemplateLiteral(T) :
(0, kind_1.IsUnion)(T) ? FromUnion(T.anyOf) :
(0, kind_1.IsLiteral)(T) ? FromLiteral(T.const) :
(0, kind_1.IsNumber)(T) ? ['[number]'] :
(0, kind_1.IsInteger)(T) ? ['[number]'] :
[]))];
}
exports.IndexPropertyKeys = IndexPropertyKeys;

@@ -15,3 +15,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -23,3 +23,3 @@ function FromRest(T, K) {

function FromIntersectRest(T) {
return T.filter(L => !(0, type_2.IsNever)(L));
return T.filter(L => !(0, kind_1.IsNever)(L));
}

@@ -32,3 +32,3 @@ // prettier-ignore

function FromUnionRest(T) {
return (T.some(L => (0, type_2.IsNever)(L))
return (T.some(L => (0, kind_1.IsNever)(L))
? []

@@ -59,7 +59,7 @@ : T);

function IndexFromPropertyKey(T, K) {
return ((0, type_2.IsIntersect)(T) ? FromIntersect(T.allOf, K) :
(0, type_2.IsUnion)(T) ? FromUnion(T.anyOf, K) :
(0, type_2.IsTuple)(T) ? FromTuple(T.items ?? [], K) :
(0, type_2.IsArray)(T) ? FromArray(T.items, K) :
(0, type_2.IsObject)(T) ? FromProperty(T.properties, K) :
return ((0, kind_1.IsIntersect)(T) ? FromIntersect(T.allOf, K) :
(0, kind_1.IsUnion)(T) ? FromUnion(T.anyOf, K) :
(0, kind_1.IsTuple)(T) ? FromTuple(T.items ?? [], K) :
(0, kind_1.IsArray)(T) ? FromArray(T.items, K) :
(0, kind_1.IsObject)(T) ? FromProperty(T.properties, K) :
(0, index_1.Never)());

@@ -80,7 +80,7 @@ }

// prettier-ignore
return ((0, type_2.IsMappedResult)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_result_1.IndexFromMappedResult)(T, K, options)) :
(0, type_2.IsMappedKey)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_key_1.IndexFromMappedKey)(T, K, options)) :
(0, type_2.IsSchema)(K) ? (0, type_1.CloneType)(FromSchema(T, (0, indexed_property_keys_1.IndexPropertyKeys)(K)), options) :
return ((0, kind_1.IsMappedResult)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_result_1.IndexFromMappedResult)(T, K, options)) :
(0, kind_1.IsMappedKey)(K) ? (0, type_1.CloneType)((0, indexed_from_mapped_key_1.IndexFromMappedKey)(T, K, options)) :
(0, kind_1.IsSchema)(K) ? (0, type_1.CloneType)(FromSchema(T, (0, indexed_property_keys_1.IndexPropertyKeys)(K)), options) :
(0, type_1.CloneType)(FromSchema(T, K), options));
}
exports.Index = Index;

@@ -10,3 +10,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// ------------------------------------------------------------------

@@ -17,7 +17,7 @@ // IntersectCreate

function IntersectCreate(T, options) {
const allObjects = T.every((schema) => (0, type_2.IsObject)(schema));
const clonedUnevaluatedProperties = (0, type_2.IsSchema)(options.unevaluatedProperties)
const allObjects = T.every((schema) => (0, kind_1.IsObject)(schema));
const clonedUnevaluatedProperties = (0, kind_1.IsSchema)(options.unevaluatedProperties)
? { unevaluatedProperties: (0, type_1.CloneType)(options.unevaluatedProperties) }
: {};
return ((options.unevaluatedProperties === false || (0, type_2.IsSchema)(options.unevaluatedProperties) || allObjects
return ((options.unevaluatedProperties === false || (0, kind_1.IsSchema)(options.unevaluatedProperties) || allObjects
? { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', type: 'object', allOf: (0, type_1.CloneRest)(T) }

@@ -24,0 +24,0 @@ : { ...options, ...clonedUnevaluatedProperties, [index_1.Kind]: 'Intersect', allOf: (0, type_1.CloneRest)(T) }));

@@ -14,7 +14,6 @@ "use strict";

// ------------------------------------------------------------------
const kind_1 = require("../guard/kind");
// prettier-ignore
const type_2 = require("../guard/type");
// prettier-ignore
function IsIntersectOptional(T) {
return T.every(L => (0, type_2.IsOptional)(L));
return T.every(L => (0, kind_1.IsOptional)(L));
}

@@ -27,3 +26,3 @@ // prettier-ignore

function RemoveOptionalFromRest(T) {
return T.map(L => (0, type_2.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
return T.map(L => (0, kind_1.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
}

@@ -42,3 +41,3 @@ // prettier-ignore

return (0, type_1.CloneType)(T[0], options);
if (T.some((schema) => (0, type_2.IsTransform)(schema)))
if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
throw new Error('Cannot intersect transform types');

@@ -45,0 +44,0 @@ return ResolveIntersect(T, options);

@@ -11,3 +11,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
/** `[Json]` Creates an evaluated Intersect type */

@@ -19,3 +19,3 @@ function Intersect(T, options = {}) {

return (0, type_1.CloneType)(T[0], options);
if (T.some((schema) => (0, type_2.IsTransform)(schema)))
if (T.some((schema) => (0, kind_1.IsTransform)(schema)))
throw new Error('Cannot intersect transform types');

@@ -22,0 +22,0 @@ return (0, intersect_create_1.IntersectCreate)(T, options);

@@ -12,3 +12,3 @@ "use strict";

// ------------------------------------------------------------------
const type_1 = require("../guard/type");
const kind_1 = require("../guard/kind");
// ------------------------------------------------------------------

@@ -61,9 +61,9 @@ // Apply

// Intrinsic-Mapped-Inference
(0, type_1.IsMappedKey)(schema) ? (0, intrinsic_from_mapped_key_1.IntrinsicFromMappedKey)(schema, mode, options) :
(0, kind_1.IsMappedKey)(schema) ? (0, intrinsic_from_mapped_key_1.IntrinsicFromMappedKey)(schema, mode, options) :
// Standard-Inference
(0, type_1.IsTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode, schema) :
(0, type_1.IsUnion)(schema) ? (0, index_3.Union)(FromRest(schema.anyOf, mode), options) :
(0, type_1.IsLiteral)(schema) ? (0, index_2.Literal)(FromLiteralValue(schema.const, mode), options) :
(0, kind_1.IsTemplateLiteral)(schema) ? FromTemplateLiteral(schema, mode, schema) :
(0, kind_1.IsUnion)(schema) ? (0, index_3.Union)(FromRest(schema.anyOf, mode), options) :
(0, kind_1.IsLiteral)(schema) ? (0, index_2.Literal)(FromLiteralValue(schema.const, mode), options) :
schema);
}
exports.Intrinsic = Intrinsic;

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(K, options) {
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, keyof_1.KeyOf)(K[K2], options) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
Acc[K2] = (0, keyof_1.KeyOf)(K[K2], options);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -9,8 +9,9 @@ "use strict";

// ------------------------------------------------------------------
const type_1 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore
function FromRest(T) {
return T.reduce((Acc, L) => {
return [...Acc, KeyOfPropertyKeys(L)];
}, []);
const Acc = [];
for (const L of T)
Acc.push(KeyOfPropertyKeys(L));
return Acc;
}

@@ -58,8 +59,8 @@ // prettier-ignore

function KeyOfPropertyKeys(T) {
return ((0, type_1.IsIntersect)(T) ? FromIntersect(T.allOf) :
(0, type_1.IsUnion)(T) ? FromUnion(T.anyOf) :
(0, type_1.IsTuple)(T) ? FromTuple(T.items ?? []) :
(0, type_1.IsArray)(T) ? FromArray(T.items) :
(0, type_1.IsObject)(T) ? FromProperties(T.properties) :
(0, type_1.IsRecord)(T) ? FromPatternProperties(T.patternProperties) :
return ((0, kind_1.IsIntersect)(T) ? FromIntersect(T.allOf) :
(0, kind_1.IsUnion)(T) ? FromUnion(T.anyOf) :
(0, kind_1.IsTuple)(T) ? FromTuple(T.items ?? []) :
(0, kind_1.IsArray)(T) ? FromArray(T.items) :
(0, kind_1.IsObject)(T) ? FromProperties(T.properties) :
(0, kind_1.IsRecord)(T) ? FromPatternProperties(T.patternProperties) :
[]);

@@ -66,0 +67,0 @@ }

@@ -14,3 +14,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -23,3 +23,3 @@ function KeyOfPropertyKeysToRest(T) {

function KeyOf(T, options = {}) {
if ((0, type_2.IsMappedResult)(T)) {
if ((0, kind_1.IsMappedResult)(T)) {
return (0, keyof_from_mapped_result_1.KeyOfFromMappedResult)(T, options);

@@ -26,0 +26,0 @@ }

@@ -39,3 +39,3 @@ import type { TSchema } from '../schema/index';

}> : Acc);
export declare function MappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T, Acc?: TProperties): TMappedFunctionReturnType<K, T>;
export declare function MappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T): TMappedFunctionReturnType<K, T>;
export type TMappedFunction<K extends PropertyKey[], I = TMappedKey<K>> = (T: I) => TSchema;

@@ -42,0 +42,0 @@ export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<TMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;

@@ -30,5 +30,4 @@ "use strict";

// ------------------------------------------------------------------
const kind_1 = require("../guard/kind");
// prettier-ignore
const type_2 = require("../guard/type");
// prettier-ignore
function FromMappedResult(K, P) {

@@ -45,5 +44,6 @@ return (K in P

function MappedKeyToUnknownMappedResultProperties(P) {
return P.reduce((Acc, L) => {
return { ...Acc, [L]: (0, index_10.Literal)(L) };
}, {});
const Acc = {};
for (const L of P)
Acc[L] = (0, index_10.Literal)(L);
return Acc;
}

@@ -67,5 +67,6 @@ // prettier-ignore

function FromProperties(K, T) {
return globalThis.Object.getOwnPropertyNames(T).reduce((Acc, K2) => {
return { ...Acc, [K2]: FromSchemaType(K, T[K2]) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(T))
Acc[K2] = FromSchemaType(K, T[K2]);
return Acc;
}

@@ -76,25 +77,26 @@ // prettier-ignore

// unevaluated modifier types
(0, type_2.IsOptional)(T) ? (0, index_12.Optional)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.OptionalKind]))) :
(0, type_2.IsReadonly)(T) ? (0, index_14.Readonly)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.ReadonlyKind]))) :
(0, kind_1.IsOptional)(T) ? (0, index_12.Optional)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.OptionalKind]))) :
(0, kind_1.IsReadonly)(T) ? (0, index_14.Readonly)(FromSchemaType(K, (0, index_2.Discard)(T, [index_1.ReadonlyKind]))) :
// unevaluated mapped types
(0, type_2.IsMappedResult)(T) ? FromMappedResult(K, T.properties) :
(0, type_2.IsMappedKey)(T) ? FromMappedKey(K, T.keys) :
(0, kind_1.IsMappedResult)(T) ? FromMappedResult(K, T.properties) :
(0, kind_1.IsMappedKey)(T) ? FromMappedKey(K, T.keys) :
// unevaluated types
(0, type_2.IsConstructor)(T) ? (0, index_5.Constructor)(FromRest(K, T.parameters), FromSchemaType(K, T.returns)) :
(0, type_2.IsFunction)(T) ? (0, index_6.Function)(FromRest(K, T.parameters), FromSchemaType(K, T.returns)) :
(0, type_2.IsAsyncIterator)(T) ? (0, index_4.AsyncIterator)(FromSchemaType(K, T.items)) :
(0, type_2.IsIterator)(T) ? (0, index_9.Iterator)(FromSchemaType(K, T.items)) :
(0, type_2.IsIntersect)(T) ? (0, index_8.Intersect)(FromRest(K, T.allOf)) :
(0, type_2.IsUnion)(T) ? (0, index_16.Union)(FromRest(K, T.anyOf)) :
(0, type_2.IsTuple)(T) ? (0, index_15.Tuple)(FromRest(K, T.items ?? [])) :
(0, type_2.IsObject)(T) ? (0, index_11.Object)(FromProperties(K, T.properties)) :
(0, type_2.IsArray)(T) ? (0, index_3.Array)(FromSchemaType(K, T.items)) :
(0, type_2.IsPromise)(T) ? (0, index_13.Promise)(FromSchemaType(K, T.item)) :
(0, kind_1.IsConstructor)(T) ? (0, index_5.Constructor)(FromRest(K, T.parameters), FromSchemaType(K, T.returns)) :
(0, kind_1.IsFunction)(T) ? (0, index_6.Function)(FromRest(K, T.parameters), FromSchemaType(K, T.returns)) :
(0, kind_1.IsAsyncIterator)(T) ? (0, index_4.AsyncIterator)(FromSchemaType(K, T.items)) :
(0, kind_1.IsIterator)(T) ? (0, index_9.Iterator)(FromSchemaType(K, T.items)) :
(0, kind_1.IsIntersect)(T) ? (0, index_8.Intersect)(FromRest(K, T.allOf)) :
(0, kind_1.IsUnion)(T) ? (0, index_16.Union)(FromRest(K, T.anyOf)) :
(0, kind_1.IsTuple)(T) ? (0, index_15.Tuple)(FromRest(K, T.items ?? [])) :
(0, kind_1.IsObject)(T) ? (0, index_11.Object)(FromProperties(K, T.properties)) :
(0, kind_1.IsArray)(T) ? (0, index_3.Array)(FromSchemaType(K, T.items)) :
(0, kind_1.IsPromise)(T) ? (0, index_13.Promise)(FromSchemaType(K, T.item)) :
T);
}
// prettier-ignore
function MappedFunctionReturnType(K, T, Acc = {}) {
return K.reduce((Acc, L) => {
return { ...Acc, [L]: FromSchemaType(L, T) };
}, {});
function MappedFunctionReturnType(K, T) {
const Acc = {};
for (const L of K)
Acc[L] = FromSchemaType(L, T);
return Acc;
}

@@ -104,3 +106,3 @@ exports.MappedFunctionReturnType = MappedFunctionReturnType;

function Mapped(key, map, options = {}) {
const K = (0, type_2.IsSchema)(key) ? (0, index_7.IndexPropertyKeys)(key) : key;
const K = (0, kind_1.IsSchema)(key) ? (0, index_7.IndexPropertyKeys)(key) : key;
const RT = map({ [index_1.Kind]: 'MappedKey', keys: K });

@@ -107,0 +109,0 @@ const R = MappedFunctionReturnType(K, RT);

@@ -10,10 +10,12 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
/** `[Json]` Creates an Object type */
function _Object(properties, options = {}) {
const propertyKeys = globalThis.Object.getOwnPropertyNames(properties);
const optionalKeys = propertyKeys.filter((key) => (0, type_2.IsOptional)(properties[key]));
const optionalKeys = propertyKeys.filter((key) => (0, kind_1.IsOptional)(properties[key]));
const requiredKeys = propertyKeys.filter((name) => !optionalKeys.includes(name));
const clonedAdditionalProperties = (0, type_2.IsSchema)(options.additionalProperties) ? { additionalProperties: (0, type_1.CloneType)(options.additionalProperties) } : {};
const clonedProperties = propertyKeys.reduce((acc, key) => ({ ...acc, [key]: (0, type_1.CloneType)(properties[key]) }), {});
const clonedAdditionalProperties = (0, kind_1.IsSchema)(options.additionalProperties) ? { additionalProperties: (0, type_1.CloneType)(options.additionalProperties) } : {};
const clonedProperties = {};
for (const key of propertyKeys)
clonedProperties[key] = (0, type_1.CloneType)(properties[key]);
return (requiredKeys.length > 0

@@ -20,0 +22,0 @@ ? { ...options, ...clonedAdditionalProperties, [index_1.Kind]: 'Object', type: 'object', properties: clonedProperties, required: requiredKeys }

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(P, K, options) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, omit_1.Omit)(P[K2], K, options) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
Acc[K2] = (0, omit_1.Omit)(P[K2], K, options);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -17,3 +17,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -37,5 +37,3 @@ function FromIntersect(T, K) {

function FromProperties(T, K) {
return K.reduce((T, K2) => {
return FromProperty(T, K2);
}, T);
return K.reduce((T, K2) => FromProperty(T, K2), T);
}

@@ -47,5 +45,5 @@ // ------------------------------------------------------------------

function OmitResolve(T, K) {
return ((0, type_2.IsIntersect)(T) ? (0, index_1.Intersect)(FromIntersect(T.allOf, K)) :
(0, type_2.IsUnion)(T) ? (0, index_2.Union)(FromUnion(T.anyOf, K)) :
(0, type_2.IsObject)(T) ? (0, index_3.Object)(FromProperties(T.properties, K)) :
return ((0, kind_1.IsIntersect)(T) ? (0, index_1.Intersect)(FromIntersect(T.allOf, K)) :
(0, kind_1.IsUnion)(T) ? (0, index_2.Union)(FromUnion(T.anyOf, K)) :
(0, kind_1.IsObject)(T) ? (0, index_3.Object)(FromProperties(T.properties, K)) :
(0, index_3.Object)({}));

@@ -55,8 +53,8 @@ }

// mapped
if ((0, type_2.IsMappedKey)(K))
if ((0, kind_1.IsMappedKey)(K))
return (0, omit_from_mapped_key_1.OmitFromMappedKey)(T, K, options);
if ((0, type_2.IsMappedResult)(T))
if ((0, kind_1.IsMappedResult)(T))
return (0, omit_from_mapped_result_1.OmitFromMappedResult)(T, K, options);
// non-mapped
const I = (0, type_2.IsSchema)(K) ? (0, index_4.IndexPropertyKeys)(K) : K;
const I = (0, kind_1.IsSchema)(K) ? (0, index_4.IndexPropertyKeys)(K) : K;
const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);

@@ -63,0 +61,0 @@ const R = (0, type_1.CloneType)(OmitResolve(T, I), options);

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(P, F) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, optional_1.Optional)(P[K2], F) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
Acc[K2] = (0, optional_1.Optional)(P[K2], F);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -9,3 +9,3 @@ "use strict";

const optional_from_mapped_result_1 = require("./optional-from-mapped-result");
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
function RemoveOptional(schema) {

@@ -26,4 +26,4 @@ return (0, index_2.Discard)((0, type_1.CloneType)(schema), [index_1.OptionalKind]);

const F = enable ?? true;
return (0, type_2.IsMappedResult)(schema) ? (0, optional_from_mapped_result_1.OptionalFromMappedResult)(schema, F) : OptionalWithFlag(schema, F);
return (0, kind_1.IsMappedResult)(schema) ? (0, optional_from_mapped_result_1.OptionalFromMappedResult)(schema, F) : OptionalWithFlag(schema, F);
}
exports.Optional = Optional;

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(K, options) {
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, partial_1.Partial)(K[K2], options) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
Acc[K2] = (0, partial_1.Partial)(K[K2], options);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -16,3 +16,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -24,5 +24,6 @@ function FromRest(T) {

function FromProperties(T) {
return globalThis.Object.getOwnPropertyNames(T).reduce((Acc, K) => {
return { ...Acc, [K]: (0, index_1.Optional)(T[K]) };
}, {});
const Acc = {};
for (const K of globalThis.Object.getOwnPropertyNames(T))
Acc[K] = (0, index_1.Optional)(T[K]);
return Acc;
}

@@ -34,5 +35,5 @@ // ------------------------------------------------------------------

function PartialResolve(T) {
return ((0, type_2.IsIntersect)(T) ? (0, index_3.Intersect)(FromRest(T.allOf)) :
(0, type_2.IsUnion)(T) ? (0, index_4.Union)(FromRest(T.anyOf)) :
(0, type_2.IsObject)(T) ? (0, index_2.Object)(FromProperties(T.properties)) :
return ((0, kind_1.IsIntersect)(T) ? (0, index_3.Intersect)(FromRest(T.allOf)) :
(0, kind_1.IsUnion)(T) ? (0, index_4.Union)(FromRest(T.anyOf)) :
(0, kind_1.IsObject)(T) ? (0, index_2.Object)(FromProperties(T.properties)) :
(0, index_2.Object)({}));

@@ -42,3 +43,3 @@ }

function Partial(T, options = {}) {
if ((0, type_2.IsMappedResult)(T))
if ((0, kind_1.IsMappedResult)(T))
return (0, partial_from_mapped_result_1.PartialFromMappedResult)(T, options);

@@ -45,0 +46,0 @@ const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(P, K, options) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, pick_1.Pick)(P[K2], K, options) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
Acc[K2] = (0, pick_1.Pick)(P[K2], K, options);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -16,3 +16,3 @@ import type { TSchema, SchemaOptions } from '../schema/index';

type FromProperties<T extends TProperties, K extends PropertyKey[], I extends PropertyKey = TupleToUnion<K>> = Evaluate<Pick<T, I & keyof T>>;
declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(T: T, K: K): {};
declare function FromProperties<T extends TProperties, K extends PropertyKey[]>(T: T, K: K): never;
export type TPick<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<TPick<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<{}>;

@@ -19,0 +19,0 @@ /** `[Json]` Constructs a type whose keys are picked from the given type */

@@ -17,3 +17,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
function FromIntersect(T, K) {

@@ -28,5 +28,7 @@ return T.map((T) => PickResolve(T, K));

function FromProperties(T, K) {
return K.reduce((Acc, K) => {
return K in T ? { ...Acc, [K]: T[K] } : Acc;
}, {});
const Acc = {};
for (const K2 of K)
if (K2 in T)
Acc[K2] = T[K2];
return Acc;
}

@@ -38,5 +40,5 @@ // ------------------------------------------------------------------

function PickResolve(T, K) {
return ((0, type_2.IsIntersect)(T) ? (0, index_1.Intersect)(FromIntersect(T.allOf, K)) :
(0, type_2.IsUnion)(T) ? (0, index_2.Union)(FromUnion(T.anyOf, K)) :
(0, type_2.IsObject)(T) ? (0, index_3.Object)(FromProperties(T.properties, K)) :
return ((0, kind_1.IsIntersect)(T) ? (0, index_1.Intersect)(FromIntersect(T.allOf, K)) :
(0, kind_1.IsUnion)(T) ? (0, index_2.Union)(FromUnion(T.anyOf, K)) :
(0, kind_1.IsObject)(T) ? (0, index_3.Object)(FromProperties(T.properties, K)) :
(0, index_3.Object)({}));

@@ -46,8 +48,8 @@ }

// mapped
if ((0, type_2.IsMappedKey)(K))
if ((0, kind_1.IsMappedKey)(K))
return (0, pick_from_mapped_key_1.PickFromMappedKey)(T, K, options);
if ((0, type_2.IsMappedResult)(T))
if ((0, kind_1.IsMappedResult)(T))
return (0, pick_from_mapped_result_1.PickFromMappedResult)(T, K, options);
// non-mapped
const I = (0, type_2.IsSchema)(K) ? (0, index_4.IndexPropertyKeys)(K) : K;
const I = (0, kind_1.IsSchema)(K) ? (0, index_4.IndexPropertyKeys)(K) : K;
const D = (0, index_5.Discard)(T, [index_6.TransformKind, '$id', 'required']);

@@ -54,0 +56,0 @@ const R = (0, type_1.CloneType)(PickResolve(T, I), options);

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(K, F) {
return globalThis.Object.getOwnPropertyNames(K).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, readonly_1.Readonly)(K[K2], F) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(K))
Acc[K2] = (0, readonly_1.Readonly)(K[K2], F);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -9,3 +9,3 @@ "use strict";

const readonly_from_mapped_result_1 = require("./readonly-from-mapped-result");
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
function RemoveReadonly(schema) {

@@ -26,4 +26,4 @@ return (0, index_2.Discard)((0, type_1.CloneType)(schema), [index_1.ReadonlyKind]);

const F = enable ?? true;
return (0, type_2.IsMappedResult)(schema) ? (0, readonly_from_mapped_result_1.ReadonlyFromMappedResult)(schema, F) : ReadonlyWithFlag(schema, F);
return (0, kind_1.IsMappedResult)(schema) ? (0, readonly_from_mapped_result_1.ReadonlyFromMappedResult)(schema, F) : ReadonlyWithFlag(schema, F);
}
exports.Readonly = Readonly;

@@ -20,3 +20,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// ------------------------------------------------------------------

@@ -39,4 +39,6 @@ // RecordCreateFromPattern

function RecordCreateFromKeys(K, T, options) {
const P = K.reduce((Acc, K) => ({ ...Acc, [K]: (0, type_1.CloneType)(T) }), {});
return (0, index_1.Object)(P, { ...options, [index_7.Hint]: 'Record' });
const Acc = {};
for (const K2 of K)
Acc[K2] = (0, type_1.CloneType)(T);
return (0, index_1.Object)(Acc, { ...options, [index_7.Hint]: 'Record' });
}

@@ -80,11 +82,11 @@ // prettier-ignore

// prettier-ignore
return ((0, type_2.IsUnion)(K) ? FromUnionKey(K.anyOf, T, options) :
(0, type_2.IsTemplateLiteral)(K) ? FromTemplateLiteralKey(K, T, options) :
(0, type_2.IsLiteral)(K) ? FromLiteralKey(K.const, T, options) :
(0, type_2.IsInteger)(K) ? FromIntegerKey(K, T, options) :
(0, type_2.IsNumber)(K) ? FromNumberKey(K, T, options) :
(0, type_2.IsRegExp)(K) ? FromRegExpKey(K, T, options) :
(0, type_2.IsString)(K) ? FromStringKey(K, T, options) :
return ((0, kind_1.IsUnion)(K) ? FromUnionKey(K.anyOf, T, options) :
(0, kind_1.IsTemplateLiteral)(K) ? FromTemplateLiteralKey(K, T, options) :
(0, kind_1.IsLiteral)(K) ? FromLiteralKey(K.const, T, options) :
(0, kind_1.IsInteger)(K) ? FromIntegerKey(K, T, options) :
(0, kind_1.IsNumber)(K) ? FromNumberKey(K, T, options) :
(0, kind_1.IsRegExp)(K) ? FromRegExpKey(K, T, options) :
(0, kind_1.IsString)(K) ? FromStringKey(K, T, options) :
(0, index_2.Never)(options));
}
exports.Record = Record;

@@ -9,5 +9,6 @@ "use strict";

function FromProperties(P, options) {
return globalThis.Object.getOwnPropertyNames(P).reduce((Acc, K2) => {
return { ...Acc, [K2]: (0, required_1.Required)(P[K2], options) };
}, {});
const Acc = {};
for (const K2 of globalThis.Object.getOwnPropertyNames(P))
Acc[K2] = (0, required_1.Required)(P[K2], options);
return Acc;
}

@@ -14,0 +15,0 @@ // prettier-ignore

@@ -15,3 +15,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore

@@ -23,5 +23,6 @@ function FromRest(T) {

function FromProperties(T) {
return globalThis.Object.getOwnPropertyNames(T).reduce((Acc, K) => {
return { ...Acc, [K]: (0, index_5.Discard)(T[K], [index_4.OptionalKind]) };
}, {});
const Acc = {};
for (const K of globalThis.Object.getOwnPropertyNames(T))
Acc[K] = (0, index_5.Discard)(T[K], [index_4.OptionalKind]);
return Acc;
}

@@ -33,5 +34,5 @@ // ------------------------------------------------------------------

function RequiredResolve(T) {
return ((0, type_2.IsIntersect)(T) ? (0, index_1.Intersect)(FromRest(T.allOf)) :
(0, type_2.IsUnion)(T) ? (0, index_2.Union)(FromRest(T.anyOf)) :
(0, type_2.IsObject)(T) ? (0, index_3.Object)(FromProperties(T.properties)) :
return ((0, kind_1.IsIntersect)(T) ? (0, index_1.Intersect)(FromRest(T.allOf)) :
(0, kind_1.IsUnion)(T) ? (0, index_2.Union)(FromRest(T.anyOf)) :
(0, kind_1.IsObject)(T) ? (0, index_3.Object)(FromProperties(T.properties)) :
(0, index_3.Object)({}));

@@ -41,3 +42,3 @@ }

function Required(T, options = {}) {
if ((0, type_2.IsMappedResult)(T)) {
if ((0, kind_1.IsMappedResult)(T)) {
return (0, required_from_mapped_result_1.RequiredFromMappedResult)(T, options);

@@ -44,0 +45,0 @@ }

@@ -9,8 +9,8 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore
function RestResolve(T) {
return ((0, type_2.IsIntersect)(T) ? [...T.allOf] :
(0, type_2.IsUnion)(T) ? [...T.anyOf] :
(0, type_2.IsTuple)(T) ? [...(T.items ?? [])] :
return ((0, kind_1.IsIntersect)(T) ? (0, type_1.CloneRest)(T.allOf) :
(0, kind_1.IsUnion)(T) ? (0, type_1.CloneRest)(T.anyOf) :
(0, kind_1.IsTuple)(T) ? (0, type_1.CloneRest)(T.items ?? []) :
[]);

@@ -17,0 +17,0 @@ }

@@ -55,4 +55,7 @@ "use strict";

function SetUnionMany(T) {
return T.reduce((Acc, L) => [...Acc, ...L], []);
const Acc = [];
for (const L of T)
Acc.push(...L);
return Acc;
}
exports.SetUnionMany = SetUnionMany;

@@ -11,4 +11,3 @@ "use strict";

// ------------------------------------------------------------------
// prettier-ignore
const type_1 = require("../guard/type");
const kind_1 = require("../guard/kind");
// ------------------------------------------------------------------

@@ -28,10 +27,10 @@ // TemplateLiteralPatternError

function Visit(schema, acc) {
return ((0, type_1.IsTemplateLiteral)(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) :
(0, type_1.IsUnion)(schema) ? `(${schema.anyOf.map((schema) => Visit(schema, acc)).join('|')})` :
(0, type_1.IsNumber)(schema) ? `${acc}${index_1.PatternNumber}` :
(0, type_1.IsInteger)(schema) ? `${acc}${index_1.PatternNumber}` :
(0, type_1.IsBigInt)(schema) ? `${acc}${index_1.PatternNumber}` :
(0, type_1.IsString)(schema) ? `${acc}${index_1.PatternString}` :
(0, type_1.IsLiteral)(schema) ? `${acc}${Escape(schema.const.toString())}` :
(0, type_1.IsBoolean)(schema) ? `${acc}${index_1.PatternBoolean}` :
return ((0, kind_1.IsTemplateLiteral)(schema) ? schema.pattern.slice(1, schema.pattern.length - 1) :
(0, kind_1.IsUnion)(schema) ? `(${schema.anyOf.map((schema) => Visit(schema, acc)).join('|')})` :
(0, kind_1.IsNumber)(schema) ? `${acc}${index_1.PatternNumber}` :
(0, kind_1.IsInteger)(schema) ? `${acc}${index_1.PatternNumber}` :
(0, kind_1.IsBigInt)(schema) ? `${acc}${index_1.PatternNumber}` :
(0, kind_1.IsString)(schema) ? `${acc}${index_1.PatternString}` :
(0, kind_1.IsLiteral)(schema) ? `${acc}${Escape(schema.const.toString())}` :
(0, kind_1.IsBoolean)(schema) ? `${acc}${index_1.PatternBoolean}` :
(() => { throw new TemplateLiteralPatternError(`Unexpected Kind '${schema[index_2.Kind]}'`); })());

@@ -38,0 +37,0 @@ }

@@ -10,3 +10,3 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// ------------------------------------------------------------------

@@ -42,3 +42,3 @@ // TransformBuilders

const schema = (0, type_1.CloneType)(this.schema);
return ((0, type_2.IsTransform)(schema) ? this.EncodeTransform(encode, schema) : this.EncodeSchema(encode, schema));
return ((0, kind_1.IsTransform)(schema) ? this.EncodeTransform(encode, schema) : this.EncodeSchema(encode, schema));
}

@@ -45,0 +45,0 @@ }

@@ -14,10 +14,10 @@ "use strict";

// ------------------------------------------------------------------
const type_2 = require("../guard/type");
const kind_1 = require("../guard/kind");
// prettier-ignore
function IsUnionOptional(T) {
return T.some(L => (0, type_2.IsOptional)(L));
return T.some(L => (0, kind_1.IsOptional)(L));
}
// prettier-ignore
function RemoveOptionalFromRest(T) {
return T.map(L => (0, type_2.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
return T.map(L => (0, kind_1.IsOptional)(L) ? RemoveOptionalFromType(L) : L);
}

@@ -24,0 +24,0 @@ // prettier-ignore

@@ -71,3 +71,3 @@ "use strict";

const additionalProperties = schema.additionalProperties;
const propertyKeys = Object.keys(value);
const propertyKeys = Object.getOwnPropertyNames(value);
const [propertyKey, propertySchema] = Object.entries(schema.patternProperties)[0];

@@ -74,0 +74,0 @@ const propertyKeyTest = new RegExp(propertyKey);

@@ -13,4 +13,10 @@ "use strict";

function ObjectType(value) {
const keys = [...Object.getOwnPropertyNames(value), ...Object.getOwnPropertySymbols(value)];
return keys.reduce((acc, key) => ({ ...acc, [key]: Clone(value[key]) }), {});
const Acc = {};
for (const key of Object.getOwnPropertyNames(value)) {
Acc[key] = Clone(value[key]);
}
for (const key of Object.getOwnPropertySymbols(value)) {
Acc[key] = Clone(value[key]);
}
return Acc;
}

@@ -17,0 +23,0 @@ function ArrayType(value) {

@@ -214,6 +214,9 @@ "use strict";

const required = new Set(schema.required);
return (FromDefault(schema.default) ||
Object.entries(schema.properties).reduce((acc, [key, schema]) => {
return required.has(key) ? { ...acc, [key]: Visit(schema, references) } : { ...acc };
}, {}));
const Acc = {};
for (const [key, subschema] of Object.entries(schema.properties)) {
if (!required.has(key))
continue;
Acc[key] = Visit(subschema, references);
}
return Acc;
}

@@ -236,5 +239,6 @@ }

const propertyKeys = keyPattern.slice(1, keyPattern.length - 1).split('|');
return propertyKeys.reduce((acc, key) => {
return { ...acc, [key]: Visit(valueSchema, references) };
}, {});
const Acc = {};
for (const key of propertyKeys)
Acc[key] = Visit(valueSchema, references);
return Acc;
}

@@ -241,0 +245,0 @@ else {

@@ -88,3 +88,3 @@ "use strict";

FNV1A64(ByteMarker.Object);
for (const key of globalThis.Object.keys(value).sort()) {
for (const key of globalThis.Object.getOwnPropertyNames(value).sort()) {
Visit(key);

@@ -91,0 +91,0 @@ Visit(value[key]);

@@ -23,4 +23,4 @@ "use strict";

else {
const currentKeys = Object.keys(current);
const nextKeys = Object.keys(next);
const currentKeys = Object.getOwnPropertyNames(current);
const nextKeys = Object.getOwnPropertyNames(next);
for (const currentKey of currentKeys) {

@@ -27,0 +27,0 @@ if (!nextKeys.includes(currentKey)) {

@@ -67,7 +67,7 @@ "use strict";

const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
const knownProperties = knownKeys.reduce((value, key) => {
return (key in value)
? { ...value, [key]: Visit((0, index_4.Index)(schema, [key]), references, `${path}/${key}`, value[key]) }
: value;
}, value);
const knownProperties = { ...value };
for (const key of knownKeys)
if (key in knownProperties) {
knownProperties[key] = Visit((0, index_4.Index)(schema, [key]), references, `${path}/${key}`, knownProperties[key]);
}
if (!(0, type_1.IsTransform)(schema.unevaluatedProperties)) {

@@ -78,7 +78,7 @@ return Default(schema, path, knownProperties);

const unevaluatedProperties = schema.unevaluatedProperties;
const unknownProperties = unknownKeys.reduce((value, key) => {
return !knownKeys.includes(key)
? { ...value, [key]: Default(unevaluatedProperties, `${path}/${key}`, value[key]) }
: value;
}, knownProperties);
const unknownProperties = { ...knownProperties };
for (const key of unknownKeys)
if (!knownKeys.includes(key)) {
unknownProperties[key] = Default(unevaluatedProperties, `${path}/${key}`, unknownProperties[key]);
}
return Default(schema, path, unknownProperties);

@@ -94,7 +94,7 @@ }

const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
const knownProperties = knownKeys.reduce((value, key) => {
return (key in value)
? { ...value, [key]: Visit(schema.properties[key], references, `${path}/${key}`, value[key]) }
: value;
}, value);
const knownProperties = { ...value };
for (const key of knownKeys)
if (key in knownProperties) {
knownProperties[key] = Visit(schema.properties[key], references, `${path}/${key}`, knownProperties[key]);
}
if (!(0, type_1.IsSchema)(schema.additionalProperties)) {

@@ -105,7 +105,7 @@ return Default(schema, path, knownProperties);

const additionalProperties = schema.additionalProperties;
const unknownProperties = unknownKeys.reduce((value, key) => {
return !knownKeys.includes(key)
? { ...value, [key]: Default(additionalProperties, `${path}/${key}`, value[key]) }
: value;
}, knownProperties);
const unknownProperties = { ...knownProperties };
for (const key of unknownKeys)
if (!knownKeys.includes(key)) {
unknownProperties[key] = Default(additionalProperties, `${path}/${key}`, unknownProperties[key]);
}
return Default(schema, path, unknownProperties);

@@ -119,7 +119,7 @@ }

const knownKeys = new RegExp(pattern);
const knownProperties = Object.getOwnPropertyNames(value).reduce((value, key) => {
return knownKeys.test(key)
? { ...value, [key]: Visit(schema.patternProperties[pattern], references, `${path}/${key}`, value[key]) }
: value;
}, value);
const knownProperties = { ...value };
for (const key of Object.getOwnPropertyNames(value))
if (knownKeys.test(key)) {
knownProperties[key] = Visit(schema.patternProperties[pattern], references, `${path}/${key}`, knownProperties[key]);
}
if (!(0, type_1.IsSchema)(schema.additionalProperties)) {

@@ -130,7 +130,7 @@ return Default(schema, path, knownProperties);

const additionalProperties = schema.additionalProperties;
const unknownProperties = unknownKeys.reduce((value, key) => {
return !knownKeys.test(key)
? { ...value, [key]: Default(additionalProperties, `${path}/${key}`, value[key]) }
: value;
}, knownProperties);
const unknownProperties = { ...knownProperties };
for (const key of unknownKeys)
if (!knownKeys.test(key)) {
unknownProperties[key] = Default(additionalProperties, `${path}/${key}`, unknownProperties[key]);
}
return Default(schema, path, unknownProperties);

@@ -137,0 +137,0 @@ }

@@ -68,7 +68,7 @@ "use strict";

const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
const knownProperties = knownKeys.reduce((value, key) => {
return key in defaulted
? { ...value, [key]: Visit((0, index_4.Index)(schema, [key]), references, `${path}/${key}`, value[key]) }
: value;
}, defaulted);
const knownProperties = { ...defaulted };
for (const key of knownKeys)
if (key in knownProperties) {
knownProperties[key] = Visit((0, index_4.Index)(schema, [key]), references, `${path}/${key}`, knownProperties[key]);
}
if (!(0, type_1.IsTransform)(schema.unevaluatedProperties)) {

@@ -79,7 +79,8 @@ return Default(schema, path, knownProperties);

const unevaluatedProperties = schema.unevaluatedProperties;
return unknownKeys.reduce((value, key) => {
return !knownKeys.includes(key)
? { ...value, [key]: Default(unevaluatedProperties, `${path}/${key}`, value[key]) }
: value;
}, knownProperties);
const properties = { ...knownProperties };
for (const key of unknownKeys)
if (!knownKeys.includes(key)) {
properties[key] = Default(unevaluatedProperties, `${path}/${key}`, properties[key]);
}
return properties;
}

@@ -96,7 +97,7 @@ // prettier-ignore

const knownKeys = (0, index_3.KeyOfPropertyKeys)(schema);
const knownProperties = knownKeys.reduce((value, key) => {
return key in value
? { ...value, [key]: Visit(schema.properties[key], references, `${path}/${key}`, value[key]) }
: value;
}, defaulted);
const knownProperties = { ...defaulted };
for (const key of knownKeys)
if (key in value) {
knownProperties[key] = Visit(schema.properties[key], references, `${path}/${key}`, knownProperties[key]);
}
if (!(0, type_1.IsSchema)(schema.additionalProperties)) {

@@ -107,7 +108,8 @@ return knownProperties;

const additionalProperties = schema.additionalProperties;
return unknownKeys.reduce((value, key) => {
return !knownKeys.includes(key)
? { ...value, [key]: Default(additionalProperties, `${path}/${key}`, value[key]) }
: value;
}, knownProperties);
const properties = { ...knownProperties };
for (const key of unknownKeys)
if (!knownKeys.includes(key)) {
properties[key] = Default(additionalProperties, `${path}/${key}`, properties[key]);
}
return properties;
}

@@ -121,7 +123,7 @@ // prettier-ignore

const knownKeys = new RegExp(pattern);
const knownProperties = Object.getOwnPropertyNames(value).reduce((value, key) => {
return knownKeys.test(key)
? { ...value, [key]: Visit(schema.patternProperties[pattern], references, `${path}/${key}`, value[key]) }
: value;
}, defaulted);
const knownProperties = { ...defaulted };
for (const key of Object.getOwnPropertyNames(value))
if (knownKeys.test(key)) {
knownProperties[key] = Visit(schema.patternProperties[pattern], references, `${path}/${key}`, knownProperties[key]);
}
if (!(0, type_1.IsSchema)(schema.additionalProperties)) {

@@ -132,7 +134,8 @@ return Default(schema, path, knownProperties);

const additionalProperties = schema.additionalProperties;
return unknownKeys.reduce((value, key) => {
return !knownKeys.test(key)
? { ...value, [key]: Default(additionalProperties, `${path}/${key}`, value[key]) }
: value;
}, knownProperties);
const properties = { ...knownProperties };
for (const key of unknownKeys)
if (!knownKeys.test(key)) {
properties[key] = Default(additionalProperties, `${path}/${key}`, properties[key]);
}
return properties;
}

@@ -139,0 +142,0 @@ // prettier-ignore

{
"name": "@sinclair/typebox",
"version": "0.32.24",
"version": "0.32.25",
"description": "Json Schema Type Builder with Static Type Resolution for TypeScript",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc