tsbuffer-schema
Advanced tools
Comparing version 1.6.0 to 1.6.1
196
index.d.ts
@@ -0,16 +1,15 @@ | ||
/*! | ||
* TSBuffer Schema v1.6.1 | ||
* ----------------------------------------- | ||
* Apache 2.0 LICENSE | ||
* KingWorks (C) Copyright 2021 | ||
* https://github.com/k8w/tsbuffer-schema | ||
*/ | ||
/** 任意类型 */ | ||
interface AnyTypeSchema { | ||
export declare interface AnyTypeSchema { | ||
type: 'Any'; | ||
} | ||
/** TypeScript NonNullable<T> */ | ||
interface NonNullableTypeSchema { | ||
type: 'NonNullable'; | ||
/** 引用目标的SchemaID */ | ||
target: string; | ||
} | ||
declare type TSBufferSchema = BooleanTypeSchema | NumberTypeSchema | StringTypeSchema | ArrayTypeSchema | TupleTypeSchema | EnumTypeSchema | AnyTypeSchema | LiteralTypeSchema | NonPrimitiveTypeSchema | InterfaceTypeSchema | BufferTypeSchema | IndexedAccessTypeSchema | ReferenceTypeSchema | UnionTypeSchema | IntersectionTypeSchema | PickTypeSchema | PartialTypeSchema | OmitTypeSchema | OverwriteTypeSchema | NonNullableTypeSchema | DateTypeSchema; | ||
interface ArrayTypeSchema { | ||
export declare interface ArrayTypeSchema { | ||
type: 'Array'; | ||
@@ -20,7 +19,7 @@ elementType: TSBufferSchema; | ||
interface BooleanTypeSchema { | ||
export declare interface BooleanTypeSchema { | ||
type: 'Boolean'; | ||
} | ||
interface BufferTypeSchema { | ||
export declare interface BufferTypeSchema { | ||
type: 'Buffer'; | ||
@@ -34,7 +33,7 @@ /** | ||
/** JavaScript Date */ | ||
interface DateTypeSchema { | ||
export declare interface DateTypeSchema { | ||
type: 'Date'; | ||
} | ||
interface EnumTypeSchema { | ||
export declare interface EnumTypeSchema { | ||
type: 'Enum'; | ||
@@ -48,3 +47,16 @@ members: { | ||
interface InterfaceTypeSchema { | ||
/** | ||
* Reference like XXX['XX']['XX'] | ||
* 注意 A['b' | 'c']不是IndexedAccessType,它们应该作为一个 UnionType被识别 | ||
* 应该等价于 A['b'] | A['c'] | ||
*/ | ||
export declare interface IndexedAccessTypeSchema { | ||
type: 'IndexedAccess'; | ||
objectType: InterfaceTypeSchema | InterfaceReference; | ||
index: string; | ||
} | ||
export declare type InterfaceReference = TypeReference | PickTypeSchema | PartialTypeSchema | OverwriteTypeSchema | OmitTypeSchema; | ||
export declare interface InterfaceTypeSchema { | ||
type: 'Interface'; | ||
@@ -74,3 +86,3 @@ /** 继承自哪个interface */ | ||
interface IntersectionTypeSchema { | ||
export declare interface IntersectionTypeSchema { | ||
type: 'Intersection'; | ||
@@ -83,24 +95,43 @@ members: { | ||
interface UnionTypeSchema { | ||
type: 'Union'; | ||
members: { | ||
/** 对应条件MASK第几位 */ | ||
id: number; | ||
type: TSBufferSchema; | ||
}[]; | ||
/** | ||
* Include never type | ||
*/ | ||
export declare interface LiteralTypeSchema { | ||
type: 'Literal'; | ||
literal?: string | number | boolean | null | undefined; | ||
} | ||
interface PickTypeSchema { | ||
type: 'Pick'; | ||
target: InterfaceTypeSchema | InterfaceReference | UnionTypeSchema | IntersectionTypeSchema; | ||
keys: string[]; | ||
/** TypeScript NonNullable<T> */ | ||
export declare interface NonNullableTypeSchema { | ||
type: 'NonNullable'; | ||
/** 引用目标的SchemaID */ | ||
target: string; | ||
} | ||
interface PartialTypeSchema { | ||
type: 'Partial'; | ||
/** | ||
* let a: object; | ||
*/ | ||
export declare interface NonPrimitiveTypeSchema { | ||
type: 'NonPrimitive'; | ||
} | ||
export declare interface NumberTypeSchema { | ||
type: 'Number'; | ||
/** | ||
* 默认为float64 | ||
* bigint 默认对应uint64 | ||
* 只有 x64 允许bigint | ||
*/ | ||
scalarType?: 'int' | 'uint' | 'bigint' | 'bigint64' | 'biguint64' | 'double'; | ||
} | ||
/** equivalent to PickType */ | ||
export declare interface OmitTypeSchema { | ||
type: 'Omit'; | ||
target: InterfaceTypeSchema | InterfaceReference | UnionTypeSchema | IntersectionTypeSchema; | ||
keys: string[]; | ||
} | ||
/** equivalent to pick & overwrite */ | ||
interface OverwriteTypeSchema { | ||
export declare interface OverwriteTypeSchema { | ||
type: 'Overwrite'; | ||
@@ -111,6 +142,10 @@ target: InterfaceTypeSchema | InterfaceReference; | ||
/** equivalent to PickType */ | ||
interface OmitTypeSchema { | ||
type: 'Omit'; | ||
export declare interface PartialTypeSchema { | ||
type: 'Partial'; | ||
target: InterfaceTypeSchema | InterfaceReference | UnionTypeSchema | IntersectionTypeSchema; | ||
} | ||
export declare interface PickTypeSchema { | ||
type: 'Pick'; | ||
target: InterfaceTypeSchema | InterfaceReference | UnionTypeSchema | IntersectionTypeSchema; | ||
keys: string[]; | ||
@@ -131,3 +166,3 @@ } | ||
*/ | ||
interface ReferenceTypeSchema { | ||
export declare interface ReferenceTypeSchema { | ||
type: 'Reference'; | ||
@@ -138,53 +173,3 @@ /** 引用目标的SchemaID */ | ||
declare type TypeReference = ReferenceTypeSchema | IndexedAccessTypeSchema; | ||
declare type InterfaceReference = TypeReference | PickTypeSchema | PartialTypeSchema | OverwriteTypeSchema | OmitTypeSchema; | ||
/** | ||
* Reference like XXX['XX']['XX'] | ||
* 注意 A['b' | 'c']不是IndexedAccessType,它们应该作为一个 UnionType被识别 | ||
* 应该等价于 A['b'] | A['c'] | ||
*/ | ||
interface IndexedAccessTypeSchema { | ||
type: 'IndexedAccess'; | ||
objectType: InterfaceTypeSchema | InterfaceReference; | ||
index: string; | ||
} | ||
/** | ||
* Include never type | ||
*/ | ||
interface LiteralTypeSchema { | ||
type: 'Literal'; | ||
literal?: string | number | boolean | null | undefined; | ||
} | ||
/** | ||
* let a: object; | ||
*/ | ||
interface NonPrimitiveTypeSchema { | ||
type: 'NonPrimitive'; | ||
} | ||
interface NumberTypeSchema { | ||
type: 'Number'; | ||
/** | ||
* 默认为float64 | ||
* bigint 默认对应uint64 | ||
* 只有 x64 允许bigint | ||
*/ | ||
scalarType?: 'int' | 'uint' | 'bigint' | 'bigint64' | 'biguint64' | 'double'; | ||
} | ||
interface StringTypeSchema { | ||
type: 'String'; | ||
} | ||
interface TupleTypeSchema { | ||
type: 'Tuple'; | ||
elementTypes: TSBufferSchema[]; | ||
optionalStartIndex?: number; | ||
} | ||
declare enum SchemaType { | ||
export declare enum SchemaType { | ||
Boolean = "Boolean", | ||
@@ -213,3 +198,7 @@ Number = "Number", | ||
interface TSBufferProto { | ||
export declare interface StringTypeSchema { | ||
type: 'String'; | ||
} | ||
export declare interface TSBufferProto { | ||
/** | ||
@@ -226,2 +215,33 @@ * 于baseDir的文件的相对路径 不带扩展名的 | ||
export { AnyTypeSchema, ArrayTypeSchema, BooleanTypeSchema, BufferTypeSchema, DateTypeSchema, EnumTypeSchema, IndexedAccessTypeSchema, InterfaceReference, InterfaceTypeSchema, IntersectionTypeSchema, LiteralTypeSchema, NonNullableTypeSchema, NonPrimitiveTypeSchema, NumberTypeSchema, OmitTypeSchema, OverwriteTypeSchema, PartialTypeSchema, PickTypeSchema, ReferenceTypeSchema, SchemaType, StringTypeSchema, TSBufferProto, TSBufferSchema, TupleTypeSchema, TypeReference, UnionTypeSchema }; | ||
export declare type TSBufferSchema = BooleanTypeSchema | NumberTypeSchema | StringTypeSchema | ArrayTypeSchema | TupleTypeSchema | EnumTypeSchema | AnyTypeSchema | LiteralTypeSchema | NonPrimitiveTypeSchema | InterfaceTypeSchema | BufferTypeSchema | IndexedAccessTypeSchema | ReferenceTypeSchema | UnionTypeSchema | IntersectionTypeSchema | PickTypeSchema | PartialTypeSchema | OmitTypeSchema | OverwriteTypeSchema | NonNullableTypeSchema | DateTypeSchema; | ||
export declare interface TupleTypeSchema { | ||
type: 'Tuple'; | ||
elementTypes: TSBufferSchema[]; | ||
optionalStartIndex?: number; | ||
} | ||
export declare type TypeReference = ReferenceTypeSchema | IndexedAccessTypeSchema; | ||
export declare interface UnionTypeSchema { | ||
type: 'Union'; | ||
members: { | ||
/** 对应条件MASK第几位 */ | ||
id: number; | ||
type: TSBufferSchema; | ||
}[]; | ||
} | ||
export { } | ||
declare global{ | ||
// Scalar Types | ||
// Varint Encoding | ||
export type int = number; | ||
export type uint = number; | ||
// Fixed Length (64bits) Encoding | ||
export type double = number; | ||
export type bigint64 = bigint; | ||
export type biguint64 = bigint; | ||
} |
{ | ||
"name": "tsbuffer-schema", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "TSBuffer schema declarations", | ||
@@ -14,3 +14,6 @@ "main": "index.cjs", | ||
"bp": "tsc --noEmit && npm version patch && npm run build && cd dist && npm publish && cd ..", | ||
"build": "rm -rf dist && npx rollup -c && cp package.json README.md LICENSE dist/" | ||
"build": "npm run build:js && npm run build:dts && npm run build:doc && cp package.json LICENSE README.md dist/", | ||
"build:js": "rm -rf dist && npx rollup -c", | ||
"build:dts": "rm -rf lib && npx tsc && npx api-extractor run --local --verbose && node scripts/removePrivate.js && rm -rf lib", | ||
"build:doc": "rm -rf docs/references && npx api-documenter markdown --input temp --output docs/references" | ||
}, | ||
@@ -44,3 +47,4 @@ "repository": { | ||
"rollup": "^2.42.3", | ||
"rollup-plugin-dts": "^3.0.1", | ||
"@microsoft/api-documenter": "^7.12.14", | ||
"@microsoft/api-extractor": "^7.13.2", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
@@ -47,0 +51,0 @@ "typescript": "^4.2.3" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22267
281
5