UNPKG

@lcap/nasl

Version:

NetEase Application Specific Language

252 lines (216 loc) 10.4 kB
type BooleanAlias = Boolean; type StringAlias = String; declare namespace nasl.core { export type Any = any; export class Boolean extends globalThis.Boolean { } export class BooleanTrue extends Boolean { _value: true; } export class BooleanFalse extends Boolean { _value: false; } // export type Boolean = BooleanTrue | BooleanFalse; export class StringLiteral<T> extends String { _value: T; } export class NumberLiteral<T> extends nasl.core.Decimal { _value: T; } export class Decimal { accept: 'Decimal' | 'Long'; constructor(num?: number); } export class Long { accept: 'Long'; constructor(num?: number); } export class String extends globalThis.String { // @ts-ignore length: nasl.core.Long; } export class Text extends String { } export class Binary { accept: 'Binary'; } export class Date { accept: 'Date'; } export class Time { accept: 'Time'; } export class DateTime { accept: 'DateTime'; } // export class Email extends String { // subAccept: 'Email'; // } export class Union { accept: 'Union'; } export type Primitive = Long | Decimal | String | Boolean | Date | Time | DateTime; // && export function and(left: Boolean, right: Boolean): Boolean; // || export function or(left: Boolean, right: Boolean): Boolean; export function add(left: Long, right: Long): Long; export function add(left: Decimal, right: Decimal): Decimal; export function add(left: String, right: Any): String; export function add(left: Any, right: String): String; export function add(left: Long, right: Long): Long; // 为了让提示到整数上,最后补一个重载 export function minus(left: Long, right: Long): Long; export function minus(left: Decimal, right: Decimal): Decimal; export function minus(left: Long, right: Long): Long; export function multiply(left: Long, right: Long): Long; export function multiply(left: Decimal, right: Decimal): Decimal; export function multiply(left: Long, right: Long): Long; export function divide(left: Long, right: Long): Decimal; export function divide(left: Decimal, right: Decimal): Decimal; export function divide(left: Long, right: Long): Decimal; export function remainder(left: Long, right: Long): Long; export function remainder(left: Decimal, right: Decimal): Decimal; export function remainder(left: Long, right: Long): Long; export function equal<T>(left: T, right: T): Boolean; export function isEqual<T>(left: T, right: T): Boolean; export function notEqual<T>(left: T, right: T): Boolean; export function isNotEqual<T>(left: T, right: T): Boolean; export function greaterThan(left: Long, right: Long): Boolean; export function greaterThan(left: String, right: String): Boolean; export function greaterThan(left: Date, right: Date): Boolean; export function greaterThan(left: Time, right: Time): Boolean; export function greaterThan(left: DateTime, right: DateTime): Boolean; export function greaterThan(left: Decimal, right: Decimal): Boolean; export function greaterThan(left: Long, right: Long): Boolean; export function greaterThanEnums(left: Enums, right: Enums): Boolean; // 数据查询 join 支持枚举类型对比 export const joinGreaterThan: typeof greaterThan & typeof greaterThanEnums export function lessThan(left: Long, right: Long): Boolean; export function lessThan(left: String, right: String): Boolean; export function lessThan(left: Date, right: Date): Boolean; export function lessThan(left: Time, right: Time): Boolean; export function lessThan(left: DateTime, right: DateTime): Boolean; export function lessThan(left: Decimal, right: Decimal): Boolean; export function lessThan(left: Long, right: Long): Boolean; export function lessThanEnums(left: Enums, right: Enums): Boolean; // 数据查询 join 支持枚举类型对比 export const joinLessThan: typeof lessThan & typeof lessThanEnums export function greaterThanOrEqual(left: Long, right: Long): Boolean; export function greaterThanOrEqual(left: String, right: String): Boolean; export function greaterThanOrEqual(left: Date, right: Date): Boolean; export function greaterThanOrEqual(left: Time, right: Time): Boolean; export function greaterThanOrEqual(left: DateTime, right: DateTime): Boolean; export function greaterThanOrEqual(left: Decimal, right: Decimal): Boolean; export function greaterThanOrEqual(left: Long, right: Long): Boolean; export function greaterThanOrEqualEnums(left: Enums, right: Enums): Boolean; // 数据查询 join 支持枚举类型对比 export const joinGreaterThanOrEqual: typeof greaterThanOrEqual & typeof greaterThanOrEqualEnums export function lessThanOrEqual(left: Long, right: Long): Boolean; export function lessThanOrEqual(left: String, right: String): Boolean; export function lessThanOrEqual(left: Date, right: Date): Boolean; export function lessThanOrEqual(left: Time, right: Time): Boolean; export function lessThanOrEqual(left: DateTime, right: DateTime): Boolean; export function lessThanOrEqual(left: Decimal, right: Decimal): Boolean; export function lessThanOrEqual(left: Long, right: Long): Boolean; export function lessThanOrEqualEnums(left: Enums, right: Enums): Boolean; // 数据查询 join 支持枚举类型对比 export const joinLessThanOrEqual: typeof lessThanOrEqual & typeof lessThanOrEqualEnums export function ensureBoolean(value: Boolean): Boolean; export function ensureVoid<T>(value: IsVoid<T>): Boolean export function isUnionType<T, S extends T>(obj: T): obj is S; // 代替原来的赋值语句,就只校验左右类型是不是可以赋值,但是不会改变原始类型 export function assign<T1, T2 extends T1>(left: T1, right: T2): T1; export let universalVariable: nasl.core.Any; // new 组件对比类型 export function compareNew(left: Date, right: Date): Boolean; export function compareNew(left: Time, right: Time): Boolean; export function compareNew(left: DateTime, right: DateTime): Boolean; export function compareNew(left: Long, right: Long): Boolean; export function compareNew(left: Long, right: Decimal): Boolean; export function compareNew(left: Decimal, right: Long): Boolean; export function compareNew(left: String, right: String): Boolean; export function compareNew(left: Decimal, right: Decimal): Boolean; export function compareNew<T>(left: T, right: T): Boolean; // OQL 临时补救 export function compare2(left: Date, right: String): Boolean; export function compare2(left: DateTime, right: String): Boolean; export function compare2(left: String, right: Date): Boolean; export function compare2(left: String, right: DateTime): Boolean; export function compare2(left: String, right: Time): Boolean; export function compare2(left: Date, right: Date): Boolean; export function compare2(left: Time, right: Time): Boolean; export function compare2(left: DateTime, right: DateTime): Boolean; export function compare2(left: String, right: String): Boolean; export function compare2(left: Long, right: Long): Boolean; export function compare2(left: Long, right: Decimal): Boolean; export function compare2(left: Decimal, right: Long): Boolean; export function compare2(left: Decimal, right: Decimal): Boolean; export function compare2<T>(left: T, right: T): Boolean; // 包括 + export function add2(left: Long, right: Long): Long; export function add2(left: Decimal, right: Decimal): Decimal; export function add2(left: Long, right: Long): Long; export function add2(left: Long, right: Decimal): Decimal; export function add2(left: Decimal, right: Long): Decimal; export function add2(left: String, right: Any): String; export function add2(left: Any, right: String): String; export function add2(left: Long, right: Long): Long; // 为了让提示到整数上,最后补一个重载 // 包括 - * % export function arith2(left: Long, right: Long): Long; export function arith2(left: Decimal, right: Decimal): Decimal; export function arith2(left: Long, right: Decimal): Decimal; export function arith2(left: Decimal, right: Long): Decimal; export function arith2(left: Long, right: Long): Long; // 为了让提示到整数上,最后补一个重载 // 包括 / export function divided2(left: Long, right: Long): Decimal; export function divided2(left: Decimal, right: Decimal): Decimal; export function divided2(left: Long, right: Decimal): Decimal; export function divided2(left: Decimal, right: Long): Decimal; export function divided2(left: Long, right: Long): Decimal; // 为了让提示到整数上,最后补一个重载 export class Enums< in out T1 extends Long | String> { accept: 'Enums'; internal?: T1; } export class None { accept: 'None'; } export type Incompatible<A, B> = A extends B ? never : A export type IsVoid<T> = T extends void ? never : T export type IfAny<T, Y, N> = 0 extends (1 & T) ? Y : N; export type IsAny<T> = IfAny<T, true, false>; export class Function extends globalThis.Function { } export type _AStructure<in out T> = { [K in keyof T]: T[K]; }; export type AStructure<in out T> = _AStructure<T & { __name: 'AStructure' }>; export function makeAStructure<T>(value: T): MakeAStructure<T>; export type MakeAStructure<T> = IsAny<T> extends true ? any : T extends nasl.ui.CurrentDynamic<infer A, infer B> ? nasl.ui.CurrentDynamic<MakeAStructure<A>, MakeAStructure<B>> : T extends nasl.ui.Current<infer A> ? nasl.ui.Current<MakeAStructure<A>> : T extends nasl.collection.List<infer F> ? nasl.collection.List<MakeAStructure<F>> : T extends nasl.core.Primitive ? T : T extends { __name: string } ? T : AStructure<T>; export type DelAStructure<T> = T extends AStructure<infer E & { __name: string }> ? DelAStructure<E> : T extends nasl.collection.List<infer F> ? nasl.collection.List<DelAStructure<F>> : T extends nasl.collection.Map<infer K, infer V> ? nasl.collection.Map<DelAStructure<K>, DelAStructure<V>> : T extends (...args: any[]) => any ? T : T extends Primitive ? T : T extends { __name: string } ? T : { [K in keyof T]: DelAStructure<T[K]>; }; }