New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sinclair/typebox

Package Overview
Dependencies
Maintainers
1
Versions
362
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.34.20 to 0.34.21

8

build/cjs/type/module/compute.d.ts

@@ -21,3 +21,3 @@ import { Ensure, Evaluate } from '../helpers/index';

import { type TReadonly } from '../readonly/index';
import { type TRecordOrObject } from '../record/index';
import { type TRecordOrObject, type TRecord } from '../record/index';
import { type TRef } from '../ref/index';

@@ -35,8 +35,8 @@ import { TRequired } from '../required/index';

type TFromPick<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TPick<T0, T1> : never);
type TFromRecord<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema, infer T1 extends TSchema] ? TRecordOrObject<T0, T1> : never);
type TFromRequired<Parameters extends TSchema[]> = (Parameters extends [infer T0 extends TSchema] ? TRequired<T0> : never);
type TFromComputed<ModuleProperties extends TProperties, Target extends string, Parameters extends TSchema[], Dereferenced extends TSchema[] = TDerefParameters<ModuleProperties, Parameters>> = (Target extends 'Awaited' ? TFromAwaited<Dereferenced> : Target extends 'Index' ? TFromIndex<Dereferenced> : Target extends 'KeyOf' ? TFromKeyOf<Dereferenced> : Target extends 'Partial' ? TFromPartial<Dereferenced> : Target extends 'Omit' ? TFromOmit<Dereferenced> : Target extends 'Pick' ? TFromPick<Dereferenced> : Target extends 'Record' ? TFromRecord<Dereferenced> : Target extends 'Required' ? TFromRequired<Dereferenced> : TNever);
type TFromComputed<ModuleProperties extends TProperties, Target extends string, Parameters extends TSchema[], Dereferenced extends TSchema[] = TDerefParameters<ModuleProperties, Parameters>> = (Target extends 'Awaited' ? TFromAwaited<Dereferenced> : Target extends 'Index' ? TFromIndex<Dereferenced> : Target extends 'KeyOf' ? TFromKeyOf<Dereferenced> : Target extends 'Partial' ? TFromPartial<Dereferenced> : Target extends 'Omit' ? TFromOmit<Dereferenced> : Target extends 'Pick' ? TFromPick<Dereferenced> : Target extends 'Required' ? TFromRequired<Dereferenced> : TNever);
type TFromObject<ModuleProperties extends TProperties, Properties extends TProperties> = Ensure<TObject<Evaluate<{
[Key in keyof Properties]: TFromType<ModuleProperties, Properties[Key]>;
}>>>;
type TFromRecord<ModuleProperties extends TProperties, Key extends TSchema, Value extends TSchema, Result extends TSchema = TRecordOrObject<Key, TFromType<ModuleProperties, Value>>> = Result;
type TFromConstructor<ModuleProperties extends TProperties, Parameters extends TSchema[], InstanceType extends TSchema> = (TConstructor<TFromRest<ModuleProperties, Parameters>, TFromType<ModuleProperties, InstanceType>>);

@@ -51,3 +51,3 @@ type TFromFunction<ModuleProperties extends TProperties, Parameters extends TSchema[], ReturnType extends TSchema> = Ensure<Ensure<TFunction<TFromRest<ModuleProperties, Parameters>, TFromType<ModuleProperties, ReturnType>>>>;

type TFromRest<ModuleProperties extends TProperties, Types extends TSchema[], Result extends TSchema[] = []> = (Types extends [infer Left extends TSchema, ...infer Right extends TSchema[]] ? TFromRest<ModuleProperties, Right, [...Result, TFromType<ModuleProperties, Left>]> : Result);
export type TFromType<ModuleProperties extends TProperties, Type extends TSchema> = (Type extends TOptional<infer Type extends TSchema> ? TOptional<TFromType<ModuleProperties, Type>> : Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TFromType<ModuleProperties, Type>> : Type extends TArray<infer Type extends TSchema> ? TFromArray<ModuleProperties, Type> : Type extends TAsyncIterator<infer Type extends TSchema> ? TFromAsyncIterator<ModuleProperties, Type> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<ModuleProperties, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromConstructor<ModuleProperties, Parameters, InstanceType> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromFunction<ModuleProperties, Parameters, ReturnType> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<ModuleProperties, Types> : Type extends TIterator<infer Type extends TSchema> ? TFromIterator<ModuleProperties, Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<ModuleProperties, Properties> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<ModuleProperties, Types> : Type extends TEnum<infer _ extends TEnumRecord> ? Type : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion<ModuleProperties, Types> : Type);
export type TFromType<ModuleProperties extends TProperties, Type extends TSchema> = (Type extends TOptional<infer Type extends TSchema> ? TOptional<TFromType<ModuleProperties, Type>> : Type extends TReadonly<infer Type extends TSchema> ? TReadonly<TFromType<ModuleProperties, Type>> : Type extends TArray<infer Type extends TSchema> ? TFromArray<ModuleProperties, Type> : Type extends TAsyncIterator<infer Type extends TSchema> ? TFromAsyncIterator<ModuleProperties, Type> : Type extends TComputed<infer Target extends string, infer Parameters extends TSchema[]> ? TFromComputed<ModuleProperties, Target, Parameters> : Type extends TConstructor<infer Parameters extends TSchema[], infer InstanceType extends TSchema> ? TFromConstructor<ModuleProperties, Parameters, InstanceType> : Type extends TFunction<infer Parameters extends TSchema[], infer ReturnType extends TSchema> ? TFromFunction<ModuleProperties, Parameters, ReturnType> : Type extends TIntersect<infer Types extends TSchema[]> ? TFromIntersect<ModuleProperties, Types> : Type extends TIterator<infer Type extends TSchema> ? TFromIterator<ModuleProperties, Type> : Type extends TObject<infer Properties extends TProperties> ? TFromObject<ModuleProperties, Properties> : Type extends TRecord<infer Key extends TSchema, infer Value extends TSchema> ? TFromRecord<ModuleProperties, Key, Value> : Type extends TTuple<infer Types extends TSchema[]> ? TFromTuple<ModuleProperties, Types> : Type extends TEnum<infer _ extends TEnumRecord> ? Type : Type extends TUnion<infer Types extends TSchema[]> ? TFromUnion<ModuleProperties, Types> : Type);
export declare function FromType<ModuleProperties extends TProperties, Type extends TSchema>(moduleProperties: ModuleProperties, type: Type): TFromType<ModuleProperties, Type>;

@@ -54,0 +54,0 @@ export type TComputeType<ModuleProperties extends TProperties, Key extends PropertyKey> = (Key extends keyof ModuleProperties ? TFromType<ModuleProperties, ModuleProperties[Key]> : TNever);

@@ -8,22 +8,23 @@ "use strict";

const index_1 = require("../create/index");
const index_2 = require("../discard/index");
const index_3 = require("../array/index");
const index_4 = require("../awaited/index");
const index_5 = require("../async-iterator/index");
const index_6 = require("../constructor/index");
const index_7 = require("../indexed/index");
const index_8 = require("../function/index");
const index_9 = require("../intersect/index");
const index_10 = require("../iterator/index");
const index_11 = require("../keyof/index");
const index_12 = require("../object/index");
const index_13 = require("../omit/index");
const index_14 = require("../pick/index");
const index_15 = require("../never/index");
const index_16 = require("../partial/index");
const index_17 = require("../record/index");
const index_18 = require("../required/index");
const index_19 = require("../tuple/index");
const index_20 = require("../union/index");
const index_21 = require("../symbols/index");
const index_2 = require("../clone/index");
const index_3 = require("../discard/index");
const index_4 = require("../array/index");
const index_5 = require("../awaited/index");
const index_6 = require("../async-iterator/index");
const index_7 = require("../constructor/index");
const index_8 = require("../indexed/index");
const index_9 = require("../function/index");
const index_10 = require("../intersect/index");
const index_11 = require("../iterator/index");
const index_12 = require("../keyof/index");
const index_13 = require("../object/index");
const index_14 = require("../omit/index");
const index_15 = require("../pick/index");
const index_16 = require("../never/index");
const index_17 = require("../partial/index");
const index_18 = require("../record/index");
const index_19 = require("../required/index");
const index_20 = require("../tuple/index");
const index_21 = require("../union/index");
const index_22 = require("../symbols/index");
// ------------------------------------------------------------------

@@ -47,35 +48,31 @@ // KindGuard

: FromType(moduleProperties, moduleProperties[ref])
: (0, index_15.Never)());
: (0, index_16.Never)());
}
// prettier-ignore
function FromAwaited(parameters) {
return (0, index_4.Awaited)(parameters[0]);
return (0, index_5.Awaited)(parameters[0]);
}
// prettier-ignore
function FromIndex(parameters) {
return (0, index_7.Index)(parameters[0], parameters[1]);
return (0, index_8.Index)(parameters[0], parameters[1]);
}
// prettier-ignore
function FromKeyOf(parameters) {
return (0, index_11.KeyOf)(parameters[0]);
return (0, index_12.KeyOf)(parameters[0]);
}
// prettier-ignore
function FromPartial(parameters) {
return (0, index_16.Partial)(parameters[0]);
return (0, index_17.Partial)(parameters[0]);
}
// prettier-ignore
function FromOmit(parameters) {
return (0, index_13.Omit)(parameters[0], parameters[1]);
return (0, index_14.Omit)(parameters[0], parameters[1]);
}
// prettier-ignore
function FromPick(parameters) {
return (0, index_14.Pick)(parameters[0], parameters[1]);
return (0, index_15.Pick)(parameters[0], parameters[1]);
}
// prettier-ignore
function FromRecord(parameters) {
return (0, index_17.Record)(parameters[0], parameters[1]);
}
// prettier-ignore
function FromRequired(parameters) {
return (0, index_18.Required)(parameters[0]);
return (0, index_19.Required)(parameters[0]);
}

@@ -91,8 +88,7 @@ // prettier-ignore

target === 'Pick' ? FromPick(dereferenced) :
target === 'Record' ? FromRecord(dereferenced) :
target === 'Required' ? FromRequired(dereferenced) :
(0, index_15.Never)());
target === 'Required' ? FromRequired(dereferenced) :
(0, index_16.Never)());
}
function FromObject(moduleProperties, properties) {
return (0, index_12.Object)(globalThis.Object.keys(properties).reduce((result, key) => {
return (0, index_13.Object)(globalThis.Object.keys(properties).reduce((result, key) => {
return { ...result, [key]: FromType(moduleProperties, properties[key]) };

@@ -102,26 +98,33 @@ }, {}));

// prettier-ignore
function FromRecord(moduleProperties, type) {
const [value, pattern] = [FromType(moduleProperties, (0, index_18.RecordValue)(type)), (0, index_18.RecordPattern)(type)];
const result = (0, index_2.CloneType)(type);
result.patternProperties[pattern] = value;
return result;
}
// prettier-ignore
function FromConstructor(moduleProperties, parameters, instanceType) {
return (0, index_6.Constructor)(FromRest(moduleProperties, parameters), FromType(moduleProperties, instanceType));
return (0, index_7.Constructor)(FromRest(moduleProperties, parameters), FromType(moduleProperties, instanceType));
}
// prettier-ignore
function FromFunction(moduleProperties, parameters, returnType) {
return (0, index_8.Function)(FromRest(moduleProperties, parameters), FromType(moduleProperties, returnType));
return (0, index_9.Function)(FromRest(moduleProperties, parameters), FromType(moduleProperties, returnType));
}
function FromTuple(moduleProperties, types) {
return (0, index_19.Tuple)(FromRest(moduleProperties, types));
return (0, index_20.Tuple)(FromRest(moduleProperties, types));
}
function FromIntersect(moduleProperties, types) {
return (0, index_9.Intersect)(FromRest(moduleProperties, types));
return (0, index_10.Intersect)(FromRest(moduleProperties, types));
}
function FromUnion(moduleProperties, types) {
return (0, index_20.Union)(FromRest(moduleProperties, types));
return (0, index_21.Union)(FromRest(moduleProperties, types));
}
function FromArray(moduleProperties, type) {
return (0, index_3.Array)(FromType(moduleProperties, type));
return (0, index_4.Array)(FromType(moduleProperties, type));
}
function FromAsyncIterator(moduleProperties, type) {
return (0, index_5.AsyncIterator)(FromType(moduleProperties, type));
return (0, index_6.AsyncIterator)(FromType(moduleProperties, type));
}
function FromIterator(moduleProperties, type) {
return (0, index_10.Iterator)(FromType(moduleProperties, type));
return (0, index_11.Iterator)(FromType(moduleProperties, type));
}

@@ -135,4 +138,4 @@ function FromRest(moduleProperties, types) {

// Modifier Unwrap - Reapplied via CreateType Options
KindGuard.IsOptional(type) ? (0, index_1.CreateType)(FromType(moduleProperties, (0, index_2.Discard)(type, [index_21.OptionalKind])), type) :
KindGuard.IsReadonly(type) ? (0, index_1.CreateType)(FromType(moduleProperties, (0, index_2.Discard)(type, [index_21.ReadonlyKind])), type) :
KindGuard.IsOptional(type) ? (0, index_1.CreateType)(FromType(moduleProperties, (0, index_3.Discard)(type, [index_22.OptionalKind])), type) :
KindGuard.IsReadonly(type) ? (0, index_1.CreateType)(FromType(moduleProperties, (0, index_3.Discard)(type, [index_22.ReadonlyKind])), type) :
// Traveral

@@ -147,5 +150,6 @@ KindGuard.IsArray(type) ? (0, index_1.CreateType)(FromArray(moduleProperties, type.items), type) :

KindGuard.IsObject(type) ? (0, index_1.CreateType)(FromObject(moduleProperties, type.properties), type) :
KindGuard.IsTuple(type) ? (0, index_1.CreateType)(FromTuple(moduleProperties, type.items || []), type) :
KindGuard.IsUnion(type) ? (0, index_1.CreateType)(FromUnion(moduleProperties, type.anyOf), type) :
type);
KindGuard.IsRecord(type) ? (0, index_1.CreateType)(FromRecord(moduleProperties, type)) :
KindGuard.IsTuple(type) ? (0, index_1.CreateType)(FromTuple(moduleProperties, type.items || []), type) :
KindGuard.IsUnion(type) ? (0, index_1.CreateType)(FromUnion(moduleProperties, type.anyOf), type) :
type);
}

@@ -156,3 +160,3 @@ // prettier-ignore

? FromType(moduleProperties, moduleProperties[key])
: (0, index_15.Never)());
: (0, index_16.Never)());
}

@@ -159,0 +163,0 @@ // prettier-ignore

@@ -64,9 +64,9 @@ import { Kind } from '../symbols/index';

/** Gets the Records Key Type */
export type TRecordKey<Type extends TRecord> = (Type extends TRecord<infer Key extends TSchema, TSchema> ? (Key extends TNumber ? TNumber : Key extends TString ? TString : TString) : TString);
export type TRecordKey<Type extends TRecord, Result extends TSchema = Type extends TRecord<infer Key extends TSchema, TSchema> ? (Key extends TNumber ? TNumber : Key extends TString ? TString : TString) : TString> = Result;
/** Gets the Records Key Type */
export declare function RecordKey<Type extends TRecord>(type: Type): TRecordKey<Type>;
/** Gets a Record Value Type */
export type TRecordValue<Type extends TRecord> = (Type extends TRecord<TSchema, infer Value extends TSchema> ? Value : TNever);
export type TRecordValue<Type extends TRecord, Result extends TSchema = (Type extends TRecord<TSchema, infer Value extends TSchema> ? Value : TNever)> = Result;
/** Gets a Record Value Type */
export declare function RecordValue<Type extends TRecord>(type: Type): TRecordValue<Type>;
export {};
{
"name": "@sinclair/typebox",
"version": "0.34.20",
"version": "0.34.21",
"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

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