@wuapi/essential
Version:
Essential definition of WU-API
374 lines (373 loc) • 9.76 kB
TypeScript
/**
* Parent of classes that have comment.
*/
export declare class $Commentable {
/**
* The comment
*/
comment: string;
/**
* The configuration map of this field.
*/
config: {
[key: string]: string;
} | null;
}
export declare enum $ReqMethod {
GET = 0,
HEAD = 1,
POST = 2,
PUT = 3,
DELETE = 4,
CONNECT = 5,
OPTIONS = 6,
TRACE = 7,
PATCH = 8,
SOCKET = 9,
MQTT = 10
}
/**
* A class to represent an element (entity or enumeration) path
* inside a project.
*/
export declare class $ElementPath {
module: string | null;
name: string | null;
/**
* Constructor of ElementPath
* @param module The module name
* @param name The element name
*/
constructor(module: string | null, name: string | null);
/**
* Compare with another ElementPath object
* @param another Another ElementPath object.
* @returns true if the other is identitcal to this ElementPath, false otherwise.
*/
equals(another: $ElementPath | null | undefined): boolean;
/**
* Returns the entity in the project, designated by the path.
* @param project The project where to find the Entity.
* @returns The entity found.
*/
asEntityOf(project: $Project | null | undefined): $Entity | null;
/**
* Returns the enumeration in the project, designated by the path.
* @param project The project where to find the Entity.
* @returns The enumeration found.
*/
asEnumOf(project: $Project | null | undefined): $Enum | null;
/**
* Create $ElementPath instance from json data.
* @param data Json data
* @returns The $ElementPath instance
*/
static load(data: any): $ElementPath;
}
/**
* Item of enumeration entity.
*/
export declare class $EnumItem extends $Commentable {
value: number;
/**
* The real (json) name may differ from the display name.
* For example, the json name may violet forbidden key rules.
*/
realname: string | null;
/**
* The constructor of enumeration item.
* @param value The number id of the item.
*/
constructor(value: number);
/**
* Create $EnumItem instance from json data.
* @param data Json data
* @returns The $EnumItem instance
*/
static load(data: any): $EnumItem | null;
}
/**
* Enumeration entity.
*/
export declare class $Enum extends $Commentable {
/**
* Map of string names to enum items.
*/
enumMap: {
[key: string]: $EnumItem;
};
/**
* Get the first item.
* @returns The first item (by number value) of this Enumeration
*/
first(): $EnumItem | null;
/**
* Get the name of the first item.
* @returns The name of the first (by number value) item of this Enumeration.
*/
firstName(): string | null;
/**
* Flat an enumeration's items.
* @returns List of name, item. Order is not defined.
*/
flat(): {
name: string;
item: $EnumItem;
}[];
/**
* Create $Enum instance from json data.
* @param data Json data
* @returns The $Enum instance
*/
static load(data: any): $Enum | null;
}
/**
* The entity field type.
*/
export declare class $FieldType {
type: string;
/**
* Constructor of FieldType
* @param type The name of this type
*/
constructor(type: string);
/**
* Check if this type equals with another.
* @param another Another type, or null
* @returns true if this type is the same with another type
*/
equals(another: $FieldType | null | undefined): boolean;
/**
* Check if this type equals with another.
* If the other field type is list, check it's member.
*
* @param another Another type, or null
* @returns true if this type is the same with another type
*/
equalsEvenInList(another: $FieldType | null | undefined): boolean;
/**
* Create $FieldType instance from json data.
* @param data Json data
* @returns The $FieldType instance
*/
static load(data: any): $FieldType | null;
}
export declare class $TObject extends $FieldType {
entity: $ElementPath;
constructor(entity: $ElementPath);
}
export declare class $TEnum extends $FieldType {
enu: $ElementPath;
constructor(enu: $ElementPath);
}
export declare class $TList extends $FieldType {
member: $FieldType;
constructor(member: $FieldType);
}
export declare class $TUnknown extends $FieldType {
unknown: string;
constructor(unknown: string);
}
export declare class $TInteger extends $FieldType {
constructor();
}
export declare class $TLong extends $FieldType {
constructor();
}
export declare class $TDouble extends $FieldType {
constructor();
}
export declare class $TID extends $FieldType {
constructor();
}
export declare class $TURL extends $FieldType {
constructor();
}
export declare class $TDateTime extends $FieldType {
constructor();
}
export declare class $TBoolean extends $FieldType {
constructor();
}
export declare class $TString extends $FieldType {
constructor();
}
export declare class $TSSMap extends $FieldType {
constructor();
}
/**
* The entity field.
*/
export declare class $Field extends $Commentable {
type: $FieldType;
/**
* The real (json) name may differ from the display name.
* For example, the json name may violet forbidden key rules.
*/
realname: string | null;
/**
* True if this field is optional
*/
isOptional: boolean;
/**
* True if this field would appear inside path.
*/
isPathParameter: boolean;
/**
* The optional fixed value of this field.
*/
fixedValue: any | null;
/**
* Constructor of Entity Field.
* @param type The type of this field
*/
constructor(type: $FieldType);
/**
* Create $Field instance from json data.
* @param data Json data
* @returns The $Field instance
*/
static load(data: any): $Field | null;
}
/**
* Type of entities.
*/
export declare enum $EntityType {
OBJECT = 0,
REQUEST = 1,
RESPONSE = 2
}
/**
* Entity
*/
export declare class $Entity extends $Commentable {
type: $EntityType;
/**
* True if this entity is abstract (shall not instantiate)
*/
isAbstract: boolean;
/**
* The path of the parent entity, optional.
*/
parent: $ElementPath | null;
/**
* The path of corresponding response entity, if this entity is a request.
*/
response: $ElementPath | null;
/**
* The URL path, if this entity is a request.
*/
path: string | null;
/**
* The Request method, if this entity is a request.
*/
method: $ReqMethod | null;
/**
* List of fields defined inside current entity.
* (no field from parent)
*/
fieldsLocal: {
[key: string]: $Field;
};
/**
* List of generic parameters defined inside current entity.
* (no generic from parent)
*/
getGenericLocal(): string[];
/**
* The map of definitions of generic parameters, till this entity.
*/
genericMap: {
[key: string]: $Field;
};
/**
* Return a list of names of generics that are unsolved until this entity.
* @param project The project, from where to get generic unsolved.
* @returns A list of names of unsolved generics.
*/
getGenericUnsolved(project: $Project | null | undefined): string[];
/**
* Traverse from the eldest ancestor all down to this entity.
* @param project The project from where to traverse.
* @param block The callback function
*/
fromAncestorToMe(project: $Project, block: (entity: $Entity) => void): void;
/**
* Constructor of Entity class.
* @param type The type of this entity
*/
constructor(type?: $EntityType);
/**
* Create $Entity instance from json data.
* @param data Json data
* @returns The $Entity instance
*/
static load(data: any): $Entity | null;
}
/**
* The module object
*/
export declare class $Module {
/**
* The map of entities inside this module.
*/
entities: {
[key: string]: $Entity;
};
/**
* The map of enumerations inside this module.
*/
enums: {
[key: string]: $Enum;
};
/**
* Create $Module instance from json data.
* @param data Json data
* @returns The $Module instance
*/
static load(data: any): $Module | null;
}
/**
* The project object
*/
export declare class $Project {
name: string;
version: string;
targetPackage: string;
/**
* The map of modules.
*/
modules: {
[key: string]: $Module;
};
/**
* The constructor of entity project.
* @param name The name of the project
* @param version The version of the project
* @param targetPackage The package (for Java & Kotlin) into which the entities
* will be generated
*/
constructor(name: string, version: string, targetPackage: string);
/**
* Flat the project into list of entities.
* @returns list of path, entity. Order is not defined!
*/
flatEntities(): {
path: $ElementPath;
entity: $Entity;
}[];
/**
* Flat the project into list of enumerations.
* @returns list of path, enumerations. Order is not defined!
*/
flatEnums(): {
path: $ElementPath;
enu: $Enum;
}[];
/**
* Create $Project instance from json data.
* @param data Json object
* @returns Generated $Project instance.
*/
static load(data: any): $Project | null;
}