Socket
Socket
Sign inDemoInstall

@sinclair/typebox

Package Overview
Dependencies
Maintainers
1
Versions
324
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sinclair/typebox - npm Package Compare versions

Comparing version 0.32.5 to 0.32.6

14

build/require/index.d.ts

@@ -21,7 +21,7 @@ export { Kind, Hint, ReadonlyKind, OptionalKind, TransformKind } from './type/symbols/index';

export { Exclude, type TExclude, type TExcludeFromMappedResult } from './type/exclude/index';
export { Extends, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck } from './type/extends/index';
export { Extends, ExtendsCheck, ExtendsResult, ExtendsUndefinedCheck, type TExtends, type ExtendsFromMappedResult, type ExtendsFromMappedKey } from './type/extends/index';
export { Extract, type TExtract, type TExtractFromMappedResult } from './type/extract/index';
export { Function, type TFunction } from './type/function/index';
export { Increment, type Assert, type AssertType, type AssertRest, type AssertProperties, type Ensure, type Evaluate, type TupleToIntersect, type TupleToUnion, type UnionToTuple } from './type/helpers/index';
export { Index, IndexPropertyKeys, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromMappedKey, type TIndexFromMappedResult } from './type/indexed/index';
export { Index, IndexPropertyKeys, IndexFromPropertyKeys, IndexFromPropertyKey, IndexFromMappedKey, IndexFromMappedResult, type TIndex, type TIndexPropertyKeys, type TIndexFromPropertyKeys, type TIndexFromPropertyKey, type TIndexFromMappedKey, type TIndexFromMappedResult, } from './type/indexed/index';
export { InstanceType, type TInstanceType } from './type/instance-type/index';

@@ -32,5 +32,5 @@ export { Integer, type TInteger, type IntegerOptions } from './type/integer/index';

export { Intrinsic, IntrinsicFromMappedKey, type TIntrinsic, Capitalize, type TCapitalize, Lowercase, type TLowercase, Uncapitalize, type TUncapitalize, Uppercase, type TUppercase } from './type/intrinsic/index';
export { KeyOf, type TKeyOf, type KeyOfFromMappedResult, KeyOfPropertyKeys, KeyOfPattern } from './type/keyof/index';
export { KeyOf, KeyOfPropertyKeys, KeyOfPropertyKeysToRest, KeyOfFromMappedResult, KeyOfPattern, type TKeyOf, type TKeyOfPropertyKeys, type TKeyOfPropertyKeysToRest, type TKeyOfFromMappedResult } from './type/keyof/index';
export { Literal, type TLiteral, type TLiteralValue } from './type/literal/index';
export { Mapped, MappedKey, MappedResult, type TMapped, type TMappedKey, type TMappedResult, type TMappedFunction } from './type/mapped/index';
export { Mapped, MappedKey, MappedResult, MappedFunctionReturnType, type TMapped, type TMappedKey, type TMappedResult, type TMappedFunction, type TMappedFunctionReturnType } from './type/mapped/index';
export { Never, type TNever } from './type/never/index';

@@ -49,3 +49,3 @@ export { Not, type TNot } from './type/not/index';

export { ReadonlyOptional, type TReadonlyOptional } from './type/readonly-optional/index';
export { Record, type TRecord } from './type/record/index';
export { Record, type TRecord, type TRecordOrObject } from './type/record/index';
export { Recursive, type TRecursive, type TThis } from './type/recursive/index';

@@ -58,7 +58,7 @@ export { Ref, type TRef } from './type/ref/index';

export { type TSchema, type TKind, type SchemaOptions, type TAnySchema } from './type/schema/index';
export { type Static, type StaticDecode, type StaticEncode } from './type/static/index';
export { type Static, type StaticDecode, type StaticEncode, type TDecodeType, type TDecodeRest, type TDecodeProperties } from './type/static/index';
export { Strict } from './type/strict/index';
export { String, type TString, type StringOptions, type StringFormatOption, type StringContentEncodingOption } from './type/string/index';
export { Symbol, type TSymbol, type TSymbolValue as SymbolValue } from './type/symbol/index';
export { TemplateLiteral, IsTemplateLiteralFinite, IsTemplateLiteralExpressionFinite, TemplateLiteralParse, TemplateLiteralParseExact, TemplateLiteralGenerate, TemplateLiteralExpressionGenerate, type TTemplateLiteral, type TIsTemplateLiteralFinite, type TTemplateLiteralGenerate, type TTemplateLiteralKind, } from './type/template-literal/index';
export { TemplateLiteral, TemplateLiteralSyntax, TemplateLiteralGenerate, TemplateLiteralParse, TemplateLiteralParseExact, IsTemplateLiteralFinite, TemplateLiteralExpressionGenerate, IsTemplateLiteralExpressionFinite, type TTemplateLiteral, type TTemplateLiteralSyntax, type TTemplateLiteralGenerate, type TTemplateLiteralKind, type TIsTemplateLiteralFinite, } from './type/template-literal/index';
export { Transform, TransformDecodeBuilder, TransformEncodeBuilder, type TTransform, type TransformOptions, type TransformFunction } from './type/transform/index';

@@ -65,0 +65,0 @@ export { Tuple, type TTuple } from './type/tuple/index';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IntrinsicFromMappedKey = exports.Intrinsic = exports.Iterator = exports.IntersectEvaluated = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedResult = exports.IndexFromMappedKey = exports.IndexPropertyKeys = exports.Index = exports.Increment = exports.Function = exports.Extract = exports.ExtendsUndefinedCheck = exports.ExtendsResult = exports.ExtendsCheck = exports.Extends = exports.Exclude = exports.Enum = exports.Deref = exports.Date = exports.ConstructorParameters = exports.Constructor = exports.Const = exports.Composite = exports.Boolean = exports.BigInt = exports.Awaited = exports.AsyncIterator = exports.Array = exports.Any = exports.TypeBoxError = exports.CloneRest = exports.CloneType = exports.ValueGuard = exports.TypeGuard = exports.FormatRegistry = exports.TypeRegistry = exports.PatternStringExact = exports.PatternString = exports.PatternNumberExact = exports.PatternNumber = exports.PatternBooleanExact = exports.PatternBoolean = exports.TransformKind = exports.OptionalKind = exports.ReadonlyKind = exports.Hint = exports.Kind = void 0;
exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = exports.TemplateLiteralExpressionGenerate = exports.TemplateLiteralGenerate = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.IsTemplateLiteralExpressionFinite = exports.IsTemplateLiteralFinite = exports.TemplateLiteral = exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.ReadonlyFromMappedResult = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.OptionalFromMappedResult = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = exports.Uncapitalize = exports.Lowercase = exports.Capitalize = void 0;
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.UnionEvaluated = exports.Union = void 0;
exports.Iterator = exports.IntersectEvaluated = exports.Intersect = exports.Integer = exports.InstanceType = exports.IndexFromMappedResult = exports.IndexFromMappedKey = exports.IndexFromPropertyKey = exports.IndexFromPropertyKeys = exports.IndexPropertyKeys = exports.Index = exports.Increment = exports.Function = exports.Extract = exports.ExtendsUndefinedCheck = exports.ExtendsResult = exports.ExtendsCheck = exports.Extends = exports.Exclude = exports.Enum = exports.Deref = exports.Date = exports.ConstructorParameters = exports.Constructor = exports.Const = exports.Composite = exports.Boolean = exports.BigInt = exports.Awaited = exports.AsyncIterator = exports.Array = exports.Any = exports.TypeBoxError = exports.CloneRest = exports.CloneType = exports.ValueGuard = exports.TypeGuard = exports.FormatRegistry = exports.TypeRegistry = exports.PatternStringExact = exports.PatternString = exports.PatternNumberExact = exports.PatternNumber = exports.PatternBooleanExact = exports.PatternBoolean = exports.TransformKind = exports.OptionalKind = exports.ReadonlyKind = exports.Hint = exports.Kind = void 0;
exports.IsTemplateLiteralExpressionFinite = exports.TemplateLiteralExpressionGenerate = exports.IsTemplateLiteralFinite = exports.TemplateLiteralParseExact = exports.TemplateLiteralParse = exports.TemplateLiteralGenerate = exports.TemplateLiteralSyntax = exports.TemplateLiteral = exports.Symbol = exports.String = exports.Strict = exports.ReturnType = exports.Rest = exports.Required = exports.RegExp = exports.Ref = exports.Recursive = exports.Record = exports.ReadonlyOptional = exports.ReadonlyFromMappedResult = exports.Readonly = exports.Promise = exports.Pick = exports.PartialFromMappedResult = exports.Partial = exports.Parameters = exports.OptionalFromMappedResult = exports.Optional = exports.Omit = exports.Object = exports.Number = exports.Null = exports.Not = exports.Never = exports.MappedFunctionReturnType = exports.MappedResult = exports.MappedKey = exports.Mapped = exports.Literal = exports.KeyOfPattern = exports.KeyOfFromMappedResult = exports.KeyOfPropertyKeysToRest = exports.KeyOfPropertyKeys = exports.KeyOf = exports.Uppercase = exports.Uncapitalize = exports.Lowercase = exports.Capitalize = exports.IntrinsicFromMappedKey = exports.Intrinsic = void 0;
exports.JavaScriptTypeBuilder = exports.JsonTypeBuilder = exports.Type = exports.Void = exports.Unsafe = exports.Unknown = exports.UnionEvaluated = exports.Union = exports.Undefined = exports.Uint8Array = exports.Tuple = exports.TransformEncodeBuilder = exports.TransformDecodeBuilder = exports.Transform = void 0;
// ------------------------------------------------------------------

@@ -79,2 +79,4 @@ // Infrastructure

Object.defineProperty(exports, "IndexPropertyKeys", { enumerable: true, get: function () { return index_24.IndexPropertyKeys; } });
Object.defineProperty(exports, "IndexFromPropertyKeys", { enumerable: true, get: function () { return index_24.IndexFromPropertyKeys; } });
Object.defineProperty(exports, "IndexFromPropertyKey", { enumerable: true, get: function () { return index_24.IndexFromPropertyKey; } });
Object.defineProperty(exports, "IndexFromMappedKey", { enumerable: true, get: function () { return index_24.IndexFromMappedKey; } });

@@ -101,2 +103,4 @@ Object.defineProperty(exports, "IndexFromMappedResult", { enumerable: true, get: function () { return index_24.IndexFromMappedResult; } });

Object.defineProperty(exports, "KeyOfPropertyKeys", { enumerable: true, get: function () { return index_30.KeyOfPropertyKeys; } });
Object.defineProperty(exports, "KeyOfPropertyKeysToRest", { enumerable: true, get: function () { return index_30.KeyOfPropertyKeysToRest; } });
Object.defineProperty(exports, "KeyOfFromMappedResult", { enumerable: true, get: function () { return index_30.KeyOfFromMappedResult; } });
Object.defineProperty(exports, "KeyOfPattern", { enumerable: true, get: function () { return index_30.KeyOfPattern; } });

@@ -109,2 +113,3 @@ var index_31 = require("./type/literal/index");

Object.defineProperty(exports, "MappedResult", { enumerable: true, get: function () { return index_32.MappedResult; } });
Object.defineProperty(exports, "MappedFunctionReturnType", { enumerable: true, get: function () { return index_32.MappedFunctionReturnType; } });
var index_33 = require("./type/never/index");

@@ -161,8 +166,9 @@ Object.defineProperty(exports, "Never", { enumerable: true, get: function () { return index_33.Never; } });

Object.defineProperty(exports, "TemplateLiteral", { enumerable: true, get: function () { return index_56.TemplateLiteral; } });
Object.defineProperty(exports, "IsTemplateLiteralFinite", { enumerable: true, get: function () { return index_56.IsTemplateLiteralFinite; } });
Object.defineProperty(exports, "IsTemplateLiteralExpressionFinite", { enumerable: true, get: function () { return index_56.IsTemplateLiteralExpressionFinite; } });
Object.defineProperty(exports, "TemplateLiteralSyntax", { enumerable: true, get: function () { return index_56.TemplateLiteralSyntax; } });
Object.defineProperty(exports, "TemplateLiteralGenerate", { enumerable: true, get: function () { return index_56.TemplateLiteralGenerate; } });
Object.defineProperty(exports, "TemplateLiteralParse", { enumerable: true, get: function () { return index_56.TemplateLiteralParse; } });
Object.defineProperty(exports, "TemplateLiteralParseExact", { enumerable: true, get: function () { return index_56.TemplateLiteralParseExact; } });
Object.defineProperty(exports, "TemplateLiteralGenerate", { enumerable: true, get: function () { return index_56.TemplateLiteralGenerate; } });
Object.defineProperty(exports, "IsTemplateLiteralFinite", { enumerable: true, get: function () { return index_56.IsTemplateLiteralFinite; } });
Object.defineProperty(exports, "TemplateLiteralExpressionGenerate", { enumerable: true, get: function () { return index_56.TemplateLiteralExpressionGenerate; } });
Object.defineProperty(exports, "IsTemplateLiteralExpressionFinite", { enumerable: true, get: function () { return index_56.IsTemplateLiteralExpressionFinite; } });
var index_57 = require("./type/transform/index");

@@ -169,0 +175,0 @@ Object.defineProperty(exports, "Transform", { enumerable: true, get: function () { return index_57.Transform; } });

@@ -5,7 +5,6 @@ import type { TSchema, SchemaOptions } from '../schema/index';

import { type TPromise } from '../promise/index';
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TFromSchema<L>]> : Acc;
type TFromSchema<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TPromise<infer S> ? TFromSchema<S> : T;
export type TAwaited<T extends TSchema> = (TFromSchema<T>);
type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TAwaited<L>]> : Acc;
export type TAwaited<T extends TSchema> = T extends TIntersect<infer S> ? TIntersect<TFromRest<S>> : T extends TUnion<infer S> ? TUnion<TFromRest<S>> : T extends TPromise<infer S> ? TAwaited<S> : T;
/** `[JavaScript]` Constructs a type by recursively unwrapping Promise types */
export declare function Awaited<T extends TSchema>(T: T, options?: SchemaOptions): TFromSchema<T>;
export declare function Awaited<T extends TSchema>(T: T, options?: SchemaOptions): TAwaited<T>;
export {};

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

function FromRest(T) {
return T.map(L => FromSchema(L));
return T.map(L => AwaitedResolve(L));
}

@@ -27,6 +27,9 @@ // prettier-ignore

function FromPromise(T) {
return FromSchema(T);
return AwaitedResolve(T);
}
// ----------------------------------------------------------------
// AwaitedResolve
// ----------------------------------------------------------------
// prettier-ignore
function FromSchema(T) {
function AwaitedResolve(T) {
return ((0, type_2.IsIntersect)(T) ? FromIntersect(T.allOf) :

@@ -39,4 +42,4 @@ (0, type_2.IsUnion)(T) ? FromUnion(T.anyOf) :

function Awaited(T, options = {}) {
return (0, type_1.CloneType)(FromSchema(T), options);
return (0, type_1.CloneType)(AwaitedResolve(T), options);
}
exports.Awaited = Awaited;

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

import type { UnionToTuple, Assert, Evaluate } from '../helpers/index';
import type { UnionToTuple, Assert, Ensure, Evaluate } from '../helpers/index';
import { type TObject, type TProperties, type ObjectOptions } from '../object/index';

@@ -10,6 +10,5 @@ import { type TIntersect } from '../intersect/index';

type TCompositeReduce<T extends TObject[]> = UnionToTuple<TCompositeKeys<T>> extends infer K ? Evaluate<TCompositeIndex<TIntersect<T>, Assert<K, string[]>>> : {};
type TCompositeResolve<T extends TObject[]> = TIntersect<T> extends TIntersect ? TObject<TCompositeReduce<T>> : TObject<{}>;
export type TComposite<T extends TObject[]> = TCompositeResolve<T>;
export type TComposite<T extends TObject[]> = TIntersect<T> extends TIntersect ? Ensure<TObject<TCompositeReduce<T>>> : Ensure<TObject<{}>>;
/** `[Json]` Creates a Composite object type */
export declare function Composite<T extends TObject[]>(T: [...T], options?: ObjectOptions): TComposite<T>;
export {};

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

const index_4 = require("../keyof/index");
const type_1 = require("../clone/type");
function CompositeResolve(T) {
/** `[Json]` Creates a Composite object type */
function Composite(T, options) {
const intersect = (0, index_2.Intersect)(T, {});
const keys = (0, index_4.KeyOfPropertyKeys)(intersect);
const properties = keys.reduce((acc, key) => ({ ...acc, [key]: (0, index_3.Index)(intersect, [key]) }), {});
return (0, index_1.Object)(properties);
return (0, index_1.Object)(properties, options);
}
/** `[Json]` Creates a Composite object type */
function Composite(T, options) {
return (0, type_1.CloneType)(CompositeResolve(T), options);
}
exports.Composite = Composite;

@@ -14,12 +14,10 @@ import type { TSchema } from '../schema/index';

import type { TObject, TProperties } from '../object/index';
export type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, DerefResolve<L>]> : Acc);
export type TFromRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, [...Acc, TDeref<L>]> : Acc);
type FromProperties<T extends TProperties> = Evaluate<{
[K in keyof T]: DerefResolve<T[K]>;
[K in keyof T]: TDeref<T[K]>;
}>;
declare function FromProperties(properties: TProperties, references: TSchema[]): TProperties;
export type DerefResolve<T extends TSchema> = T extends TConstructor<infer S extends TSchema[], infer R extends TSchema> ? TConstructor<TFromRest<S>, DerefResolve<R>> : T extends TFunction<infer S extends TSchema[], infer R extends TSchema> ? TFunction<TFromRest<S>, DerefResolve<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<DerefResolve<S>> : T extends TPromise<infer S extends TSchema> ? TPromise<DerefResolve<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<DerefResolve<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<DerefResolve<S>> : T extends TRef<infer S extends TSchema> ? DerefResolve<S> : T;
export declare function DerefResolve<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
export type TDeref<T extends TSchema> = DerefResolve<T>;
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;
/** `[Json]` Creates a dereferenced type */
export declare function Deref<T extends TSchema>(schema: T, references: TSchema[]): TDeref<T>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Deref = exports.DerefResolve = void 0;
exports.Deref = void 0;
const type_1 = require("../clone/type");

@@ -98,3 +98,5 @@ const index_1 = require("../discard/index");

}
exports.DerefResolve = DerefResolve;
// ------------------------------------------------------------------
// TDeref
// ------------------------------------------------------------------
/** `[Json]` Creates a dereferenced type */

@@ -101,0 +103,0 @@ function Deref(schema, references) {

@@ -14,12 +14,9 @@ import type { TSchema, SchemaOptions } from '../schema/index';

}[T]>>>;
type TExcludeTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = (Exclude<Static<T>, Static<U>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never);
type TExcludeArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? never : T[K];
type TExcludeTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = (Exclude<Static<L>, Static<R>> extends infer S ? TExcludeTemplateLiteralResult<Assert<S, string>> : never);
type TExcludeRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
[K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? never : L[K];
}[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
type TExcludeResolve<T extends TSchema, U extends TSchema> = T extends TTemplateLiteral ? TExcludeTemplateLiteral<T, U> : T extends TUnion<infer S> ? TExcludeArray<S, U> : T extends U ? TNever : T;
export type TExclude<T extends TSchema, U extends TSchema> = TExcludeResolve<T, U>;
export type TExclude<L extends TSchema, R extends TSchema> = (L extends TMappedResult<L> ? TExcludeFromMappedResult<L, R> : L extends TTemplateLiteral ? TExcludeTemplateLiteral<L, R> : L extends TUnion<infer S> ? TExcludeRest<S, R> : L extends R ? TNever : L);
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
export declare function Exclude<L extends TMappedResult, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExcludeFromMappedResult<L, R>;
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
export declare function Exclude<L extends TSchema, R extends TSchema>(unionType: L, excludedMembers: R, options?: SchemaOptions): TExclude<L, R>;
export declare function Exclude<L extends TSchema, R extends TSchema>(L: L, R: R, options?: SchemaOptions): TExclude<L, R>;
export {};

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

const type_2 = require("../guard/type");
// prettier-ignore
function ExcludeResolve(L, R) {
return ((0, type_2.IsTemplateLiteral)(L) ? ExcludeResolve((0, index_1.TemplateLiteralToUnion)(L), R) :
(0, type_2.IsTemplateLiteral)(R) ? ExcludeResolve(L, (0, index_1.TemplateLiteralToUnion)(R)) :
(0, type_2.IsUnion)(L) ? (() => {
const narrowed = L.anyOf.filter((inner) => (0, index_4.ExtendsCheck)(inner, R) === index_4.ExtendsResult.False);
return (narrowed.length === 1 ? narrowed[0] : (0, index_2.Union)(narrowed));
})() :
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? (0, index_3.Never)() :
L);
function ExcludeRest(L, R) {
const excluded = L.filter((inner) => (0, index_4.ExtendsCheck)(inner, R) === index_4.ExtendsResult.False);
return excluded.length === 1 ? excluded[0] : (0, index_2.Union)(excluded);
}
/** `[Json]` Constructs a type by excluding from unionType all union members that are assignable to excludedMembers */
function Exclude(unionType, excludedMembers, options = {}) {
if ((0, type_2.IsMappedResult)(unionType)) {
return (0, exclude_from_mapped_result_1.ExcludeFromMappedResult)(unionType, excludedMembers, options);
}
else {
const E = ExcludeResolve(unionType, excludedMembers);
return (0, type_1.CloneType)(E, options);
}
function Exclude(L, R, options = {}) {
// prettier-ignore
return (0, type_1.CloneType)(((0, type_2.IsMappedResult)(L) ? (0, exclude_from_mapped_result_1.ExcludeFromMappedResult)(L, R, options) :
(0, type_2.IsTemplateLiteral)(L) ? Exclude((0, index_1.TemplateLiteralToUnion)(L), R) :
(0, type_2.IsTemplateLiteral)(R) ? Exclude(L, (0, index_1.TemplateLiteralToUnion)(R)) :
(0, type_2.IsUnion)(L) ? ExcludeRest(L.anyOf, R) :
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? (0, index_3.Never)() : L), options);
}
exports.Exclude = Exclude;

@@ -8,17 +8,15 @@ import type { TSchema, SchemaOptions } from '../schema/index';

import { type Static } from '../static/index';
import { type TNever } from '../never/index';
import { type TUnionEvaluated } from '../union/index';
import { type TExtractFromMappedResult } from './extract-from-mapped-result';
type TFromTemplateLiteralResult<T extends string> = TUnionEvaluated<AssertRest<UnionToTuple<{
type TExtractTemplateLiteralResult<T extends string> = TUnionEvaluated<AssertRest<UnionToTuple<{
[K in T]: TLiteral<K>;
}[T]>>>;
type TFromTemplateLiteral<T extends TTemplateLiteral, U extends TSchema> = Extract<Static<T>, Static<U>> extends infer S ? TFromTemplateLiteralResult<Assert<S, string>> : never;
type TFromArray<T extends TSchema[], U extends TSchema> = AssertRest<UnionToTuple<{
[K in keyof T]: Static<AssertType<T[K]>> extends Static<U> ? T[K] : never;
type TExtractTemplateLiteral<L extends TTemplateLiteral, R extends TSchema> = Extract<Static<L>, Static<R>> extends infer S ? TExtractTemplateLiteralResult<Assert<S, string>> : never;
type TExtractRest<L extends TSchema[], R extends TSchema> = AssertRest<UnionToTuple<{
[K in keyof L]: Static<AssertType<L[K]>> extends Static<R> ? L[K] : never;
}[number]>> extends infer R extends TSchema[] ? TUnionEvaluated<R> : never;
type TExtractResolve<T extends TSchema, U extends TSchema> = (T extends TTemplateLiteral ? TFromTemplateLiteral<T, U> : T extends TUnion<infer S> ? TFromArray<S, U> : T);
export type TExtract<T extends TSchema, U extends TSchema> = TExtractResolve<T, U>;
export type TExtract<L extends TSchema, U extends TSchema> = (L extends TMappedResult ? TExtractFromMappedResult<L, U> : L extends TTemplateLiteral ? TExtractTemplateLiteral<L, U> : L extends TUnion<infer S> ? TExtractRest<S, U> : L extends U ? L : TNever);
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
export declare function Extract<L extends TMappedResult, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtractFromMappedResult<L, R>;
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
export declare function Extract<L extends TSchema, R extends TSchema>(type: L, union: R, options?: SchemaOptions): TExtract<L, R>;
export declare function Extract<L extends TSchema, R extends TSchema>(L: L, R: R, options?: SchemaOptions): TExtract<L, R>;
export {};

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

const type_2 = require("../guard/type");
// prettier-ignore
function ExtractResolve(L, R) {
return ((0, type_2.IsTemplateLiteral)(L) ? ExtractResolve((0, index_1.TemplateLiteralToUnion)(L), R) :
(0, type_2.IsTemplateLiteral)(R) ? ExtractResolve(L, (0, index_1.TemplateLiteralToUnion)(R)) :
(0, type_2.IsUnion)(L) ? (() => {
const narrowed = L.anyOf.filter((inner) => (0, index_4.ExtendsCheck)(inner, R) !== index_4.ExtendsResult.False);
return (narrowed.length === 1 ? narrowed[0] : (0, index_2.Union)(narrowed));
})() :
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? L :
(0, index_3.Never)());
function ExtractRest(L, R) {
const extracted = L.filter((inner) => (0, index_4.ExtendsCheck)(inner, R) !== index_4.ExtendsResult.False);
return extracted.length === 1 ? extracted[0] : (0, index_2.Union)(extracted);
}
/** `[Json]` Constructs a type by extracting from type all union members that are assignable to union */
function Extract(type, union, options = {}) {
if ((0, type_2.IsMappedResult)(type)) {
return (0, extract_from_mapped_result_1.ExtractFromMappedResult)(type, union, options);
}
else {
const E = ExtractResolve(type, union);
return (0, type_1.CloneType)(E, options);
}
function Extract(L, R, options = {}) {
// prettier-ignore
return (0, type_1.CloneType)(((0, type_2.IsMappedResult)(L) ? (0, extract_from_mapped_result_1.ExtractFromMappedResult)(L, R, options) :
(0, type_2.IsTemplateLiteral)(L) ? Extract((0, index_1.TemplateLiteralToUnion)(L), R) :
(0, type_2.IsTemplateLiteral)(R) ? Extract(L, (0, index_1.TemplateLiteralToUnion)(R)) :
(0, type_2.IsUnion)(L) ? ExtractRest(L.anyOf, R) :
(0, index_4.ExtendsCheck)(L, R) !== index_4.ExtendsResult.False ? L : (0, index_3.Never)()), options);
}
exports.Extract = Extract;
import type { TSchema, SchemaOptions } from '../schema/index';
import type { Evaluate } from '../helpers/index';
import type { Ensure, Evaluate } from '../helpers/index';
import type { TProperties } from '../object/index';

@@ -11,4 +11,4 @@ import { type TIndex } from './indexed';

type TMappedIndexProperties<T extends TSchema, K extends TMappedKey> = Evaluate<TMappedIndexPropertyKeys<T, K['keys']>>;
export type TIndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>> = (TMappedResult<P>);
export type TIndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>> = (Ensure<TMappedResult<P>>);
export declare function IndexFromMappedKey<T extends TSchema, K extends TMappedKey, P extends TProperties = TMappedIndexProperties<T, K>>(T: T, K: K, options: SchemaOptions): TMappedResult<P>;
export {};

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

import { type TIndexFromMappedResult } from './indexed-from-mapped-result';
type TFromRest<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, K, [...Acc, Assert<TFromKey<L, K>, TSchema>]> : Acc);
type TFromRest<T extends TSchema[], K extends PropertyKey, Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromRest<R, K, [...Acc, Assert<TIndexFromPropertyKey<L, K>, TSchema>]> : Acc);
type TFromIntersectRest<T extends TSchema[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? L extends TNever ? TFromIntersectRest<R, [...Acc]> : TFromIntersectRest<R, [...Acc, L]> : Acc);

@@ -26,5 +26,7 @@ type TFromIntersect<T extends TSchema[], K extends PropertyKey> = (TIntersectEvaluated<TFromIntersectRest<TFromRest<T, K>>>);

type TFromProperty<T extends TProperties, K extends PropertyKey> = (K extends keyof T ? T[K] : `${AssertPropertyKey<K>}` extends `${AssertPropertyKey<keyof T>}` ? T[AssertPropertyKey<K>] : TNever);
type TFromKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<infer S> ? TFromKey<S, K> : T extends TIntersect<infer S> ? TFromIntersect<S, K> : T extends TUnion<infer S> ? TFromUnion<S, K> : T extends TTuple<infer S> ? TFromTuple<S, K> : T extends TArray<infer S> ? TFromArray<S, K> : T extends TObject<infer S> ? TFromProperty<S, K> : TNever);
type TFromKeys<T extends TSchema, K extends PropertyKey[], Acc extends TSchema[] = []> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TFromKeys<T, R, [...Acc, Assert<TFromKey<T, L>, TSchema>]> : Acc);
type FromSchema<T extends TSchema, K extends PropertyKey[]> = (TUnionEvaluated<TFromKeys<T, K>>);
export type TIndexFromPropertyKey<T extends TSchema, K extends PropertyKey> = (T extends TRecursive<infer S> ? TIndexFromPropertyKey<S, K> : T extends TIntersect<infer S> ? TFromIntersect<S, K> : T extends TUnion<infer S> ? TFromUnion<S, K> : T extends TTuple<infer S> ? TFromTuple<S, K> : T extends TArray<infer S> ? TFromArray<S, K> : T extends TObject<infer S> ? TFromProperty<S, K> : TNever);
export declare function IndexFromPropertyKey<T extends TSchema, K extends PropertyKey>(T: T, K: K): TIndexFromPropertyKey<T, K>;
export type TIndexFromPropertyKeys<T extends TSchema, K extends PropertyKey[], Acc extends TSchema[] = []> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TIndexFromPropertyKeys<T, R, [...Acc, Assert<TIndexFromPropertyKey<T, L>, TSchema>]> : Acc);
export declare function IndexFromPropertyKeys<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): TIndexFromPropertyKeys<T, K>;
type FromSchema<T extends TSchema, K extends PropertyKey[]> = (TUnionEvaluated<TIndexFromPropertyKeys<T, K>>);
declare function FromSchema<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): FromSchema<T, K>;

@@ -31,0 +33,0 @@ export type TIndex<T extends TSchema, K extends PropertyKey[]> = (FromSchema<T, K>);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Index = void 0;
exports.Index = exports.IndexFromPropertyKeys = exports.IndexFromPropertyKey = void 0;
const index_1 = require("../never/index");

@@ -18,3 +18,3 @@ const index_2 = require("../intersect/index");

function FromRest(T, K) {
return T.map(L => FromKey(L, K));
return T.map(L => IndexFromPropertyKey(L, K));
}

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

// prettier-ignore
function FromKey(T, K) {
function IndexFromPropertyKey(T, K) {
return ((0, type_2.IsIntersect)(T) ? FromIntersect(T.allOf, K) :

@@ -63,9 +63,11 @@ (0, type_2.IsUnion)(T) ? FromUnion(T.anyOf, K) :

}
exports.IndexFromPropertyKey = IndexFromPropertyKey;
// prettier-ignore
function FromKeys(T, K) {
return K.map(L => FromKey(T, L));
function IndexFromPropertyKeys(T, K) {
return K.map(L => IndexFromPropertyKey(T, L));
}
exports.IndexFromPropertyKeys = IndexFromPropertyKeys;
// prettier-ignore
function FromSchema(T, K) {
return ((0, index_3.UnionEvaluated)(FromKeys(T, K)));
return ((0, index_3.UnionEvaluated)(IndexFromPropertyKeys(T, K)));
}

@@ -72,0 +74,0 @@ /** `[Json]` Returns an Indexed property type for the given keys */

import type { SchemaOptions } from '../schema/index';
import type { Ensure, Evaluate } from '../helpers/index';
import type { TProperties } from '../object/index';

@@ -8,5 +9,5 @@ import { type TMappedResult } from '../mapped/index';

});
type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
export type TKeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
type TFromMappedResult<R extends TMappedResult> = (Evaluate<TFromProperties<R['properties']>>);
export type TKeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (Ensure<TMappedResult<P>>);
export declare function KeyOfFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
export {};

@@ -10,4 +10,5 @@ import type { TSchema } from '../schema/index';

import { type TKeyOfFromMappedResult } from './keyof-from-mapped-result';
type TFromPropertyKeys<T extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? L extends '[number]' ? TFromPropertyKeys<R, [...Acc, TNumber]> : TFromPropertyKeys<R, [...Acc, TLiteral<Assert<L, TLiteralValue>>]> : Acc);
export type TKeyOf<T extends TSchema, K extends PropertyKey[] = TKeyOfPropertyKeys<T>, S extends TSchema[] = TFromPropertyKeys<K>, U = TUnionEvaluated<S>> = (Ensure<U>);
export type TKeyOfPropertyKeysToRest<T extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? L extends '[number]' ? TKeyOfPropertyKeysToRest<R, [...Acc, TNumber]> : TKeyOfPropertyKeysToRest<R, [...Acc, TLiteral<Assert<L, TLiteralValue>>]> : Acc);
export declare function KeyOfPropertyKeysToRest<T extends PropertyKey[]>(T: [...T]): TKeyOfPropertyKeysToRest<T>;
export type TKeyOf<T extends TSchema, K extends PropertyKey[] = TKeyOfPropertyKeys<T>, S extends TSchema[] = TKeyOfPropertyKeysToRest<K>, U = TUnionEvaluated<S>> = (Ensure<U>);
/** `[Json]` Creates a KeyOf type */

@@ -17,2 +18,1 @@ export declare function KeyOf<T extends TMappedResult>(T: T, options?: SchemaOptions): TKeyOfFromMappedResult<T>;

export declare function KeyOf<T extends TSchema>(T: T, options?: SchemaOptions): TKeyOf<T>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyOf = void 0;
exports.KeyOf = exports.KeyOfPropertyKeysToRest = void 0;
const index_1 = require("../literal/index");

@@ -16,5 +16,6 @@ const index_2 = require("../number/index");

// prettier-ignore
function FromPropertyKeys(T) {
function KeyOfPropertyKeysToRest(T) {
return T.map(L => L === '[number]' ? (0, index_2.Number)() : (0, index_1.Literal)(L));
}
exports.KeyOfPropertyKeysToRest = KeyOfPropertyKeysToRest;
/** `[Json]` Creates a KeyOf type */

@@ -27,3 +28,3 @@ function KeyOf(T, options = {}) {

const K = (0, keyof_property_keys_1.KeyOfPropertyKeys)(T);
const S = FromPropertyKeys(K);
const S = KeyOfPropertyKeysToRest(K);
const U = (0, index_3.UnionEvaluated)(S);

@@ -30,0 +31,0 @@ return (0, type_1.CloneType)(U, options);

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

declare function FromSchemaType<K extends PropertyKey, T extends TSchema>(K: K, T: T): FromSchemaType<K, T>;
type FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? FromMappedFunctionReturnType<R, T, Acc & {
export type TMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema, Acc extends TProperties = {}> = (K extends [infer L extends PropertyKey, ...infer R extends PropertyKey[]] ? TMappedFunctionReturnType<R, T, Acc & {
[_ in L]: FromSchemaType<L, T>;
}> : Acc);
declare function FromMappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T, Acc?: TProperties): FromMappedFunctionReturnType<K, T>;
export declare function MappedFunctionReturnType<K extends PropertyKey[], T extends TSchema>(K: [...K], T: T, Acc?: TProperties): TMappedFunctionReturnType<K, T>;
export type TMappedFunction<K extends PropertyKey[], I = TMappedKey<K>> = (T: I) => TSchema;
export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<FromMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;
export type TMapped<K extends PropertyKey[], F extends TMappedFunction<K>, R extends TProperties = Evaluate<TMappedFunctionReturnType<K, ReturnType<F>>>> = Ensure<TObject<R>>;
/** `[Json]` Creates a Mapped object type */

@@ -44,0 +44,0 @@ export declare function Mapped<K extends TSchema, I extends PropertyKey[] = TIndexPropertyKeys<K>, F extends TMappedFunction<I> = TMappedFunction<I>, R extends TMapped<I, F> = TMapped<I, F>>(key: K, map: F, options?: ObjectOptions): R;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mapped = void 0;
exports.Mapped = exports.MappedFunctionReturnType = void 0;
const index_1 = require("../symbols/index");

@@ -92,3 +92,3 @@ const type_1 = require("../clone/type");

// prettier-ignore
function FromMappedFunctionReturnType(K, T, Acc = {}) {
function MappedFunctionReturnType(K, T, Acc = {}) {
return K.reduce((Acc, L) => {

@@ -98,2 +98,3 @@ return { ...Acc, [L]: FromSchemaType(L, T) };

}
exports.MappedFunctionReturnType = MappedFunctionReturnType;
/** `[Json]` Creates a Mapped object type */

@@ -103,5 +104,5 @@ function Mapped(key, map, options = {}) {

const RT = map({ [index_1.Kind]: 'MappedKey', keys: K });
const R = FromMappedFunctionReturnType(K, RT);
const R = MappedFunctionReturnType(K, RT);
return (0, type_1.CloneType)((0, index_11.Object)(R), options);
}
exports.Mapped = Mapped;
import type { SchemaOptions } from '../schema/index';
import type { Ensure, Evaluate } from '../helpers/index';
import type { TProperties } from '../object/index';

@@ -8,5 +9,5 @@ import { type TMappedResult } from '../mapped/index';

});
type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (TFromProperties<R['properties'], K>);
export type TOmitFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (TMappedResult<P>);
type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (Evaluate<TFromProperties<R['properties'], K>>);
export type TOmitFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (Ensure<TMappedResult<P>>);
export declare function OmitFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options: SchemaOptions): TMappedResult<P>;
export {};

@@ -11,8 +11,6 @@ import type { TSchema, SchemaOptions } from '../schema/index';

import { type TOmitFromMappedResult } from './omit-from-mapped-result';
type TFromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, K, [...Acc, TOmitResolve<L, K>]> : Acc);
type TFromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, K, [...Acc, TOmitResolve<L, K>]> : Acc);
type TFromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromIntersect<R, K, [...Acc, TOmit<L, K>]> : Acc);
type TFromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = (T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TFromUnion<R, K, [...Acc, TOmit<L, K>]> : Acc);
type TFromProperties<T extends TProperties, K extends PropertyKey[], I extends PropertyKey = TupleToUnion<K>> = Evaluate<Omit<T, I>>;
export type TOmitResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<TOmitResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S, K>> : T extends TObject<infer S> ? TObject<TFromProperties<S, K>> : TObject<{}>;
export declare function OmitResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): TOmitResolve<T, K>;
export type TOmit<T extends TSchema, K extends PropertyKey[]> = TOmitResolve<T, K>;
export type TOmit<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<TOmit<S, K>> : T extends TIntersect<infer S> ? TIntersect<TFromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<TFromUnion<S, K>> : T extends TObject<infer S> ? TObject<TFromProperties<S, K>> : TObject<{}>;
/** `[Json]` Constructs a type whose keys are omitted from the given type */

@@ -19,0 +17,0 @@ export declare function Omit<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TOmitFromMappedResult<T, K>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Omit = exports.OmitResolve = void 0;
exports.Omit = void 0;
const index_1 = require("../intersect/index");

@@ -40,2 +40,5 @@ const index_2 = require("../union/index");

}
// ------------------------------------------------------------------
// OmitResolve
// ------------------------------------------------------------------
// prettier-ignore

@@ -48,3 +51,2 @@ function OmitResolve(T, K) {

}
exports.OmitResolve = OmitResolve;
function Omit(T, K, options = {}) {

@@ -51,0 +53,0 @@ // mapped

import type { SchemaOptions } from '../schema/index';
import type { Ensure, Evaluate } from '../helpers/index';
import type { TProperties } from '../object/index';

@@ -8,5 +9,5 @@ import { type TMappedResult } from '../mapped/index';

});
type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
export type TPartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
type TFromMappedResult<R extends TMappedResult> = (Evaluate<TFromProperties<R['properties']>>);
export type TPartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (Ensure<TMappedResult<P>>);
export declare function PartialFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
export {};
import type { SchemaOptions } from '../schema/index';
import type { Ensure, Evaluate } from '../helpers/index';
import type { TProperties } from '../object/index';

@@ -8,5 +9,5 @@ import { type TMappedResult } from '../mapped/index';

});
type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (TFromProperties<R['properties'], K>);
export type TPickFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (TMappedResult<P>);
type TFromMappedResult<R extends TMappedResult, K extends PropertyKey[]> = (Evaluate<TFromProperties<R['properties'], K>>);
export type TPickFromMappedResult<T extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<T, K>> = (Ensure<TMappedResult<P>>);
export declare function PickFromMappedResult<R extends TMappedResult, K extends PropertyKey[], P extends TProperties = TFromMappedResult<R, K>>(R: R, K: [...K], options: SchemaOptions): TMappedResult<P>;
export {};

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

import { type TPickFromMappedResult } from './pick-from-mapped-result';
type FromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromIntersect<R, K, [...Acc, PickResolve<L, K>]> : Acc;
type FromIntersect<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromIntersect<R, K, [...Acc, TPick<L, K>]> : Acc;
declare function FromIntersect<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromIntersect<T, K, []>;
type FromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromUnion<R, K, [...Acc, PickResolve<L, K>]> : Acc;
type FromUnion<T extends TSchema[], K extends PropertyKey[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? FromUnion<R, K, [...Acc, TPick<L, K>]> : Acc;
declare function FromUnion<T extends TSchema[], K extends PropertyKey[]>(T: T, K: K): FromUnion<T, K, []>;
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): {};
export type PickResolve<T extends TProperties, K extends PropertyKey[]> = T extends TRecursive<infer S> ? TRecursive<PickResolve<S, K>> : T extends TIntersect<infer S> ? TIntersect<FromIntersect<S, K>> : T extends TUnion<infer S> ? TUnion<FromUnion<S, K>> : T extends TObject<infer S> ? TObject<FromProperties<S, K>> : TObject<{}>;
export declare function PickResolve<T extends TSchema, K extends PropertyKey[]>(T: T, K: [...K]): PickResolve<T, K>;
export type TPick<T extends TSchema, K extends PropertyKey[]> = PickResolve<T, K>;
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<{}>;
/** `[Json]` Constructs a type whose keys are picked from the given type */

@@ -22,0 +20,0 @@ export declare function Pick<T extends TMappedResult, K extends PropertyKey[]>(T: T, K: [...K], options?: SchemaOptions): TPickFromMappedResult<T, K>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pick = exports.PickResolve = void 0;
exports.Pick = void 0;
const index_1 = require("../intersect/index");

@@ -31,2 +31,5 @@ const index_2 = require("../union/index");

}
// ------------------------------------------------------------------
// PickResolve
// ------------------------------------------------------------------
// prettier-ignore

@@ -39,3 +42,2 @@ function PickResolve(T, K) {

}
exports.PickResolve = PickResolve;
function Pick(T, K, options = {}) {

@@ -42,0 +44,0 @@ // mapped

import type { SchemaOptions } from '../schema/index';
import type { Ensure, Evaluate } from '../helpers/index';
import type { TProperties } from '../object/index';

@@ -8,5 +9,5 @@ import { type TMappedResult } from '../mapped/index';

});
type TFromMappedResult<R extends TMappedResult> = (TFromProperties<R['properties']>);
export type TRequiredFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (TMappedResult<P>);
type TFromMappedResult<R extends TMappedResult> = (Evaluate<TFromProperties<R['properties']>>);
export type TRequiredFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>> = (Ensure<TMappedResult<P>>);
export declare function RequiredFromMappedResult<R extends TMappedResult, P extends TProperties = TFromMappedResult<R>>(R: R, options: SchemaOptions): TMappedResult<P>;
export {};

@@ -22,9 +22,9 @@ import type { Evaluate } from '../helpers/index';

import type { TTransform } from '../transform/index';
export type DecodeProperties<T extends TProperties> = {
[K in keyof T]: DecodeType<T[K]>;
export type TDecodeProperties<T extends TProperties> = {
[K in keyof T]: TDecodeType<T[K]>;
};
export type DecodeRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? DecodeRest<R, [...Acc, DecodeType<L>]> : Acc;
export type DecodeType<T extends TSchema> = (T extends TOptional<infer S extends TSchema> ? TOptional<DecodeType<S>> : T extends TReadonly<infer S extends TSchema> ? TReadonly<DecodeType<S>> : T extends TTransform<infer _, infer R> ? TUnsafe<R> : T extends TArray<infer S extends TSchema> ? TArray<DecodeType<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<DecodeType<S>> : T extends TConstructor<infer P extends TSchema[], infer R extends TSchema> ? TConstructor<DecodeRest<P>, DecodeType<R>> : T extends TEnum<infer S> ? TEnum<S> : T extends TFunction<infer P extends TSchema[], infer R extends TSchema> ? TFunction<DecodeRest<P>, DecodeType<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<DecodeRest<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<DecodeType<S>> : T extends TNot<infer S extends TSchema> ? TNot<DecodeType<S>> : T extends TObject<infer S> ? TObject<Evaluate<DecodeProperties<S>>> : T extends TPromise<infer S extends TSchema> ? TPromise<DecodeType<S>> : T extends TRecord<infer K, infer S> ? TRecord<K, DecodeType<S>> : T extends TRecursive<infer S extends TSchema> ? TRecursive<DecodeType<S>> : T extends TRef<infer S extends TSchema> ? TRef<DecodeType<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<DecodeRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<DecodeRest<S>> : T);
export type TDecodeRest<T extends TSchema[], Acc extends TSchema[] = []> = T extends [infer L extends TSchema, ...infer R extends TSchema[]] ? TDecodeRest<R, [...Acc, TDecodeType<L>]> : Acc;
export type TDecodeType<T extends TSchema> = (T extends TOptional<infer S extends TSchema> ? TOptional<TDecodeType<S>> : T extends TReadonly<infer S extends TSchema> ? TReadonly<TDecodeType<S>> : T extends TTransform<infer _, infer R> ? TUnsafe<R> : T extends TArray<infer S extends TSchema> ? TArray<TDecodeType<S>> : T extends TAsyncIterator<infer S extends TSchema> ? TAsyncIterator<TDecodeType<S>> : T extends TConstructor<infer P extends TSchema[], infer R extends TSchema> ? TConstructor<TDecodeRest<P>, TDecodeType<R>> : T extends TEnum<infer S> ? TEnum<S> : T extends TFunction<infer P extends TSchema[], infer R extends TSchema> ? TFunction<TDecodeRest<P>, TDecodeType<R>> : T extends TIntersect<infer S extends TSchema[]> ? TIntersect<TDecodeRest<S>> : T extends TIterator<infer S extends TSchema> ? TIterator<TDecodeType<S>> : T extends TNot<infer S extends TSchema> ? TNot<TDecodeType<S>> : T extends TObject<infer S> ? TObject<Evaluate<TDecodeProperties<S>>> : T extends TPromise<infer S extends TSchema> ? TPromise<TDecodeType<S>> : T extends TRecord<infer K, infer S> ? TRecord<K, TDecodeType<S>> : T extends TRecursive<infer S extends TSchema> ? TRecursive<TDecodeType<S>> : T extends TRef<infer S extends TSchema> ? TRef<TDecodeType<S>> : T extends TTuple<infer S extends TSchema[]> ? TTuple<TDecodeRest<S>> : T extends TUnion<infer S extends TSchema[]> ? TUnion<TDecodeRest<S>> : T);
/** Creates an decoded static type from a TypeBox type */
export type StaticDecode<T extends TSchema, P extends unknown[] = []> = Static<DecodeType<T>, P>;
export type StaticDecode<T extends TSchema, P extends unknown[] = []> = Static<TDecodeType<T>, P>;
/** Creates an encoded static type from a TypeBox type */

@@ -31,0 +31,0 @@ export type StaticEncode<T extends TSchema, P extends unknown[] = []> = Static<T, P>;

{
"name": "@sinclair/typebox",
"version": "0.32.5",
"version": "0.32.6",
"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 too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc