Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tson-schema

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tson-schema - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

12

dist/any-of.d.ts

@@ -1,11 +0,3 @@

import { TypedSchema } from './common';
declare function anyOf<T1>(schemas: [TypedSchema<T1>]): TypedSchema<T1>;
declare function anyOf<T1, T2>(schemas: [TypedSchema<T1>, TypedSchema<T2>]): TypedSchema<T1 | T2>;
declare function anyOf<T1, T2, T3>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>]): TypedSchema<T1 | T2 | T3>;
declare function anyOf<T1, T2, T3, T4>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>]): TypedSchema<T1 | T2 | T3 | T4>;
declare function anyOf<T1, T2, T3, T4, T5>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>]): TypedSchema<T1 | T2 | T3 | T4 | T5>;
declare function anyOf<T1, T2, T3, T4, T5, T6>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6>;
declare function anyOf<T1, T2, T3, T4, T5, T6, T7>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
declare function anyOf<T1, T2, T3, T4, T5, T6, T7, T8>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>, TypedSchema<T8>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
declare function anyOf<T1, T2, T3, T4, T5, T6, T7, T8, T9>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>, TypedSchema<T8>, TypedSchema<T9>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
import { TypedSchema, UnwrapTypedSchema } from './common';
declare function anyOf<OptionsType extends TypedSchema<any>[] | [TypedSchema<any>]>(schemas: OptionsType): TypedSchema<UnwrapTypedSchema<OptionsType[keyof OptionsType]>>;
export { anyOf };

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

import { BaseSchemaDefinition, TypedSchema } from './common';
import { BaseSchemaDefinition, TypedSchema, UnwrapTypedSchema } from './common';
interface BaseArrayDefinition extends BaseSchemaDefinition {

@@ -12,41 +12,8 @@ minItems?: number;

declare function arrayType<T>(schema?: ListSchemaDefinition<T>): TypedSchema<T[]>;
export interface Tuple1SchemaDefinition<T1> extends BaseArrayDefinition {
items: [TypedSchema<T1>];
export interface TupleSchemaDefinition<ElementsType extends TypedSchema<any>[] | [TypedSchema<any>]> extends BaseArrayDefinition {
items: ElementsType;
}
export interface Tuple2SchemaDefinition<T1, T2> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>];
}
export interface Tuple3SchemaDefinition<T1, T2, T3> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>];
}
export interface Tuple4SchemaDefinition<T1, T2, T3, T4> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>];
}
export interface Tuple5SchemaDefinition<T1, T2, T3, T4, T5> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>];
}
export interface Tuple6SchemaDefinition<T1, T2, T3, T4, T5, T6> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>];
}
export interface Tuple7SchemaDefinition<T1, T2, T3, T4, T5, T6, T7> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>];
}
export interface Tuple8SchemaDefinition<T1, T2, T3, T4, T5, T6, T7, T8> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>, TypedSchema<T8>];
}
export interface Tuple9SchemaDefinition<T1, T2, T3, T4, T5, T6, T7, T8, T9> extends BaseArrayDefinition {
items: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>, TypedSchema<T8>, TypedSchema<T9>];
}
export interface TupleAnySchemaDefinition extends BaseArrayDefinition {
items: TypedSchema<any>[];
}
declare function tupleType<T1>(schema: Tuple1SchemaDefinition<T1>): TypedSchema<[T1]>;
declare function tupleType<T1, T2>(schema: Tuple2SchemaDefinition<T1, T2>): TypedSchema<[T1, T2]>;
declare function tupleType<T1, T2, T3>(schema: Tuple3SchemaDefinition<T1, T2, T3>): TypedSchema<[T1, T2, T3]>;
declare function tupleType<T1, T2, T3, T4>(schema: Tuple4SchemaDefinition<T1, T2, T3, T4>): TypedSchema<[T1, T2, T3, T4]>;
declare function tupleType<T1, T2, T3, T4, T5>(schema: Tuple5SchemaDefinition<T1, T2, T3, T4, T5>): TypedSchema<[T1, T2, T3, T4, T5]>;
declare function tupleType<T1, T2, T3, T4, T5, T6>(schema: Tuple6SchemaDefinition<T1, T2, T3, T4, T5, T6>): TypedSchema<[T1, T2, T3, T4, T5, T6]>;
declare function tupleType<T1, T2, T3, T4, T5, T6, T7>(schema: Tuple7SchemaDefinition<T1, T2, T3, T4, T5, T6, T7>): TypedSchema<[T1, T2, T3, T4, T5, T6, T7]>;
declare function tupleType<T1, T2, T3, T4, T5, T6, T7, T8>(schema: Tuple8SchemaDefinition<T1, T2, T3, T4, T5, T6, T7, T8>): TypedSchema<[T1, T2, T3, T4, T5, T6, T7, T8]>;
declare function tupleType<T1, T2, T3, T4, T5, T6, T7, T8, T9>(schema: Tuple9SchemaDefinition<T1, T2, T3, T4, T5, T6, T7, T8, T9>): TypedSchema<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
declare function tupleType<ElementsType extends TypedSchema<any>[] | [TypedSchema<any>]>(schema: TupleSchemaDefinition<ElementsType>): TypedSchema<{
[K in keyof ElementsType]: UnwrapTypedSchema<ElementsType[K]>;
}>;
export { arrayType as array, tupleType as tuple };

2

dist/common.d.ts

@@ -6,2 +6,4 @@ export interface TypedSchema<T> {

export declare type JSONSchema = object;
export declare type UnwrapTypedSchema<Schema> = Schema extends TypedSchema<infer InnerType> ? InnerType : never;
export declare type TypeOf<Schema extends TypedSchema<any>> = Schema['type'];
export interface BaseSchemaDefinition {

@@ -8,0 +10,0 @@ /**

import { BaseSchemaDefinition, TypedSchema } from './common';
export interface ObjectDefinition<T extends {}> extends BaseSchemaDefinition {
export interface ObjectDefinition<ObjType extends object, RequiredKeysType extends (keyof ObjType)[]> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
[KeyType in keyof ObjType]: TypedSchema<ObjType[KeyType]>;
};
required: (keyof T)[];
required: RequiredKeysType;
}
export interface PartialObjectDefinition<T extends {}> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [];
}
export interface ObjectDefinition1<T extends {}, R1 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1];
}
export interface ObjectDefinition2<T extends {}, R1 extends keyof T, R2 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2];
}
export interface ObjectDefinition3<T extends {}, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2, R3];
}
export interface ObjectDefinition4<T extends {}, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2, R3, R4];
}
export interface ObjectDefinition5<T extends {}, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2, R3, R4, R5];
}
export interface ObjectDefinition6<T extends {}, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2, R3, R4, R5, R6];
}
export interface ObjectDefinition7<T extends {}, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T, R7 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2, R3, R4, R5, R6, R7];
}
export interface ObjectDefinition8<T extends {}, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T, R7 extends keyof T, R8 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2, R3, R4, R5, R6, R7, R8];
}
export interface ObjectDefinition9<T extends {}, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T, R7 extends keyof T, R8 extends keyof T, R9 extends keyof T> extends BaseSchemaDefinition {
properties: {
[Key in keyof T]: TypedSchema<T[Key]>;
};
required: [R1, R2, R3, R4, R5, R6, R7, R8, R9];
}
declare function objectType<T>(schema: PartialObjectDefinition<T>): TypedSchema<Partial<T>>;
declare function objectType<T, R1 extends keyof T>(schema: ObjectDefinition1<T, R1>): TypedSchema<Partial<T> & {
[key in R1]: T[key];
declare function objectType<ObjectType extends object, KeyType extends (keyof ObjectType)[]>(schema: ObjectDefinition<ObjectType, KeyType>): TypedSchema<Partial<ObjectType> & {
[RequiredKey in KeyType[number]]: ObjectType[RequiredKey];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T>(schema: ObjectDefinition2<T, R1, R2>): TypedSchema<Partial<T> & {
[key in R1 | R2]: T[key];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T>(schema: ObjectDefinition3<T, R1, R2, R3>): TypedSchema<Partial<T> & {
[key in R1 | R2 | R3]: T[key];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T>(schema: ObjectDefinition4<T, R1, R2, R3, R4>): TypedSchema<Partial<T> & {
[key in R1 | R2 | R3 | R4]: T[key];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T>(schema: ObjectDefinition5<T, R1, R2, R3, R4, R5>): TypedSchema<Partial<T> & {
[key in R1 | R2 | R3 | R4 | R5]: T[key];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T>(schema: ObjectDefinition6<T, R1, R2, R3, R4, R5, R6>): TypedSchema<Partial<T> & {
[key in R1 | R2 | R3 | R4 | R5 | R6]: T[key];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T, R7 extends keyof T>(schema: ObjectDefinition7<T, R1, R2, R3, R4, R5, R6, R7>): TypedSchema<Partial<T> & {
[key in R1 | R2 | R3 | R4 | R5 | R6 | R7]: T[key];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T, R7 extends keyof T, R8 extends keyof T>(schema: ObjectDefinition8<T, R1, R2, R3, R4, R5, R6, R7, R8>): TypedSchema<Partial<T> & {
[key in R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8]: T[key];
}>;
declare function objectType<T, R1 extends keyof T, R2 extends keyof T, R3 extends keyof T, R4 extends keyof T, R5 extends keyof T, R6 extends keyof T, R7 extends keyof T, R8 extends keyof T, R9 extends keyof T>(schema: ObjectDefinition9<T, R1, R2, R3, R4, R5, R6, R7, R8, R9>): TypedSchema<Partial<T> & {
[key in R1 | R2 | R3 | R4 | R5 | R6 | R7 | R8 | R9]: T[key];
}>;
export { objectType as object };

@@ -1,11 +0,3 @@

import { TypedSchema } from './common';
declare function oneOf<T1>(schemas: [TypedSchema<T1>]): TypedSchema<T1>;
declare function oneOf<T1, T2>(schemas: [TypedSchema<T1>, TypedSchema<T2>]): TypedSchema<T1 | T2>;
declare function oneOf<T1, T2, T3>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>]): TypedSchema<T1 | T2 | T3>;
declare function oneOf<T1, T2, T3, T4>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>]): TypedSchema<T1 | T2 | T3 | T4>;
declare function oneOf<T1, T2, T3, T4, T5>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>]): TypedSchema<T1 | T2 | T3 | T4 | T5>;
declare function oneOf<T1, T2, T3, T4, T5, T6>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6>;
declare function oneOf<T1, T2, T3, T4, T5, T6, T7>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
declare function oneOf<T1, T2, T3, T4, T5, T6, T7, T8>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>, TypedSchema<T8>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
declare function oneOf<T1, T2, T3, T4, T5, T6, T7, T8, T9>(schemas: [TypedSchema<T1>, TypedSchema<T2>, TypedSchema<T3>, TypedSchema<T4>, TypedSchema<T5>, TypedSchema<T6>, TypedSchema<T7>, TypedSchema<T8>, TypedSchema<T9>]): TypedSchema<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
import { TypedSchema, UnwrapTypedSchema } from './common';
declare function oneOf<OptionsType extends TypedSchema<any>[] | [TypedSchema<any>]>(schemas: OptionsType): TypedSchema<UnwrapTypedSchema<OptionsType[keyof OptionsType]>>;
export { oneOf };

@@ -12,1 +12,3 @@ export * from './null';

export * from './any';
import { TypedSchema, TypeOf } from './common';
export { TypedSchema, TypeOf };
{
"name": "tson-schema",
"version": "0.5.0",
"version": "0.6.0",
"description": "A TypeScript API to create JSON-Schemas and TypeScript types",

@@ -24,13 +24,13 @@ "files": [

"@types/tape": "^4.2.33",
"ajv": "^6.10.2",
"nodemon": "^1.19.4",
"prettier": "^1.18.2",
"ajv": "^6.11.0",
"nodemon": "^2.0.2",
"prettier": "^1.19.1",
"tap-spec": "^5.0.0",
"tape": "^4.11.0",
"ts-node": "^8.4.1",
"tslint": "^5.20.0",
"tape": "^4.13.0",
"ts-node": "^8.6.2",
"tslint": "^6.0.0",
"tslint-config-prettier": "^1.18.0",
"tslint-plugin-prettier": "^2.0.1",
"typescript": "^3.6.4"
"tslint-plugin-prettier": "^2.1.0",
"typescript": "^3.7.5"
}
}

@@ -12,5 +12,4 @@ # tson-schema

- Limited TypeScript support for:
- big tuples
- objects with lots of required properties
- big enums
- big enum schemas
- big allOf schemas

@@ -17,0 +16,0 @@ ## Installing

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

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