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.1.3 to 0.2.0

dist/all-of.d.ts

4

dist/common.d.ts

@@ -5,5 +5,3 @@ export interface TypedSchema<T> {

}
export interface JSONSchema {
type?: string;
}
export declare type JSONSchema = boolean | number | object | string;
export interface BaseSchemaDefinition {

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

@@ -1,38 +0,22 @@

import { BaseSchemaDefinition, TypedSchema } from './common';
declare type EnumValue = string | number | boolean;
interface EnumSchemaDefinition1<V1 extends EnumValue> extends BaseSchemaDefinition {
/**
* A fixed set of allowed values
*/
enum: [V1];
}
interface EnumSchemaDefinition2<V1 extends EnumValue, V2 extends EnumValue> extends BaseSchemaDefinition {
/**
* A fixed set of allowed values
*/
enum: [V1, V2];
}
interface EnumSchemaDefinition3<V1 extends EnumValue, V2 extends EnumValue, V3 extends EnumValue> extends BaseSchemaDefinition {
/**
* A fixed set of allowed values
*/
enum: [V1, V2, V3];
}
interface EnumSchemaDefinition4<V1 extends EnumValue, V2 extends EnumValue, V3 extends EnumValue, V4 extends EnumValue> extends BaseSchemaDefinition {
/**
* A fixed set of allowed values
*/
enum: [V1, V2, V3, V4];
}
interface EnumSchemaDefinition5<V1 extends EnumValue, V2 extends EnumValue, V3 extends EnumValue, V4 extends EnumValue, V5 extends EnumValue> extends BaseSchemaDefinition {
/**
* A fixed set of allowed values
*/
enum: [V1, V2, V3, V4, V5];
}
declare function enumType<V1 extends EnumValue>(schema: EnumSchemaDefinition1<V1>): TypedSchema<V1>;
declare function enumType<V1 extends EnumValue, V2 extends EnumValue>(schema: EnumSchemaDefinition2<V1, V2>): TypedSchema<V1 | V2>;
declare function enumType<V1 extends EnumValue, V2 extends EnumValue, V3 extends EnumValue>(schema: EnumSchemaDefinition3<V1, V2, V3>): TypedSchema<V1 | V2 | V3>;
declare function enumType<V1 extends EnumValue, V2 extends EnumValue, V3 extends EnumValue, V4 extends EnumValue>(schema: EnumSchemaDefinition4<V1, V2, V3, V4>): TypedSchema<V1 | V2 | V3 | V4>;
declare function enumType<V1 extends EnumValue, V2 extends EnumValue, V3 extends EnumValue, V4 extends EnumValue, V5 extends EnumValue>(schema: EnumSchemaDefinition5<V1, V2, V3, V4, V5>): TypedSchema<V1 | V2 | V3 | V4 | V5>;
export { enumType as enum };
import { TypedSchema } from './common';
declare type LiteralValue = string | number | boolean | null;
declare type Enum1<V1 extends LiteralValue> = [V1];
declare type Enum2<V1 extends LiteralValue, V2 extends LiteralValue> = [V1, V2];
declare type Enum3<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue> = [V1, V2, V3];
declare type Enum4<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue> = [V1, V2, V3, V4];
declare type Enum5<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue> = [V1, V2, V3, V4, V5];
declare type Enum6<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue> = [V1, V2, V3, V4, V5, V6];
declare type Enum7<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue, V7 extends LiteralValue> = [V1, V2, V3, V4, V5, V6, V7];
declare type Enum8<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue, V7 extends LiteralValue, V8 extends LiteralValue> = [V1, V2, V3, V4, V5, V6, V7, V8];
declare type Enum9<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue, V7 extends LiteralValue, V8 extends LiteralValue, V9 extends LiteralValue> = [V1, V2, V3, V4, V5, V6, V7, V8, V9];
declare function enumType<V1 extends LiteralValue>(values: Enum1<V1>): TypedSchema<V1>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue>(values: Enum2<V1, V2>): TypedSchema<V1 | V2>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue>(values: Enum3<V1, V2, V3>): TypedSchema<V1 | V2 | V3>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue>(values: Enum4<V1, V2, V3, V4>): TypedSchema<V1 | V2 | V3 | V4>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue>(values: Enum5<V1, V2, V3, V4, V5>): TypedSchema<V1 | V2 | V3 | V4 | V5>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue>(values: Enum6<V1, V2, V3, V4, V5, V6>): TypedSchema<V1 | V2 | V3 | V4 | V5 | V6>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue, V7 extends LiteralValue>(values: Enum7<V1, V2, V3, V4, V5, V6, V7>): TypedSchema<V1 | V2 | V3 | V4 | V5 | V6 | V7>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue, V7 extends LiteralValue, V8 extends LiteralValue>(values: Enum8<V1, V2, V3, V4, V5, V6, V7, V8>): TypedSchema<V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8>;
declare function enumType<V1 extends LiteralValue, V2 extends LiteralValue, V3 extends LiteralValue, V4 extends LiteralValue, V5 extends LiteralValue, V6 extends LiteralValue, V7 extends LiteralValue, V8 extends LiteralValue, V9 extends LiteralValue>(values: Enum9<V1, V2, V3, V4, V5, V6, V7, V8, V9>): TypedSchema<V1 | V2 | V3 | V4 | V5 | V6 | V7 | V8 | V9>;
declare function constType<Value extends LiteralValue>(value: Value): TypedSchema<Value>;
export { constType as const, enumType as enum };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function enumType(schema) {
function enumType(values) {
return {
getSchema: function () { return Object.assign({}, schema); },
getSchema: function () { return Object.assign({}, { enum: values }); },
type: 'ENUM_VALUE',

@@ -10,2 +10,9 @@ };

exports.enum = enumType;
function constType(value) {
return {
getSchema: function () { return ({ const: value }); },
type: 'CONST_VALUE',
};
}
exports.const = constType;
//# sourceMappingURL=enum.js.map

@@ -44,2 +44,26 @@ import { BaseSchemaDefinition, TypedSchema } from './common';

}
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>>;

@@ -61,2 +85,14 @@ declare function objectType<T, R1 extends keyof T>(schema: ObjectDefinition1<T, R1>): TypedSchema<Partial<T> & {

}>;
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 };

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

export * from './enum';
export * from './any-of';
export * from './all-of';

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

__export(require("./enum"));
__export(require("./any-of"));
__export(require("./all-of"));
//# sourceMappingURL=tson-schema.js.map
{
"name": "tson-schema",
"version": "0.1.3",
"version": "0.2.0",
"description": "A TypeScript API to create JSON-Schemas and TypeScript types",

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

@@ -7,8 +7,11 @@ # tson-schema

- `enum` functionality
- `array.additionalItems`
- `object.additionalProperties`
- `$ref`
- JSON-Schema `anyOf`/`oneOf`
- JSON-Schema conditional schemas (`if`/`else`)
- Limited TypeScript support for big tuples and objects with lots of required properties
- Limited TypeScript support for:
- big tuples
- objects with lots of required properties
- big enums

@@ -15,0 +18,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

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