@msom/http
Version:
@msom/http
97 lines • 3.42 kB
TypeScript
import { ObjectId } from "mongodb";
export type Promiseable<T> = T | Promise<T>;
export declare enum RelationType {
ONE = "One",
MANY = "Many"
}
export declare enum ConditionType {
COMP = "comp",
AND = "and",
OR = "or"
}
export interface PropertyMeta {
type: string;
desc: string;
}
export type RelationName = string;
export type PropertyName = string;
export interface RelationMeta {
type: RelationType;
correspondingModel: string;
desc: string;
}
export interface ModelMeta {
modelName: string;
modelDesc: string;
properties: Record<PropertyName, PropertyMeta>;
relations: Record<RelationName, RelationMeta>;
relating: Record<RelationName, WeakMap<ObjectId, ObjectId[]>>;
}
export interface QueryCondition {
type: ConditionType;
filter: <T extends object>(model: T) => boolean;
clone(): QueryCondition;
}
export type CompPropValue = string | number | null | "undefined" | ObjectId;
export type CompConditionType = "=" | ">=" | "<=" | "<" | ">" | "!=" | "in" | "nin" | "exist";
export declare class CompCondition implements QueryCondition {
static is(condition: QueryCondition): condition is CompCondition;
static CompHandle: {
readonly "!=": (modelValue: unknown, targetValue: unknown) => boolean;
readonly "=": (modelValue: unknown, targetValue: unknown) => boolean;
readonly ">": (modelValue: any, targetValue: any) => boolean;
readonly "<": (modelValue: any, targetValue: any) => boolean;
readonly "<=": (modelValue: any, targetValue: any) => boolean;
readonly ">=": (modelValue: any, targetValue: any) => boolean;
readonly in: (modelValue: unknown, targetValue: ReadonlyArray<unknown>) => boolean;
readonly nin: (modelValue: unknown, targetValue: ReadonlyArray<unknown>) => boolean;
readonly exist: (model: object, propKey: string) => boolean;
};
type: ConditionType.COMP;
compType: CompConditionType;
propKey: string;
value: CompPropValue | ReadonlyArray<CompPropValue>;
constructor(compType: CompConditionType, propKey: string, value: CompPropValue | ReadonlyArray<CompPropValue>);
clone(): CompCondition;
filter<T extends object>(model: T): boolean;
}
export declare class AndCondition implements QueryCondition {
static is(condition: QueryCondition): condition is AndCondition;
type: ConditionType.AND;
conditions: QueryCondition[];
constructor(conditions: QueryCondition[]);
clone(): AndCondition;
filter<T extends object>(model: T): boolean;
}
export declare class OrCondition implements QueryCondition {
static is(condition: QueryCondition): condition is OrCondition;
type: ConditionType.OR;
conditions: QueryCondition[];
constructor(conditions: QueryCondition[]);
clone(): OrCondition;
filter<T extends object>(model: T): boolean;
}
export interface QueryResultItem {
_id: ObjectId;
model: Record<string, any>;
relates: Record<string, QueryResultItem[]>;
children?: QueryResultItem[];
}
export interface HealthCheckResponse {
status: string;
timestamp: string;
uptime: number;
dbStatus: string;
}
export interface ErrorResponse<T = any> {
code: 1;
error: string;
details?: T;
}
export interface SuccessResponse<T = any> {
code: 0;
success: true;
message?: string;
data: T;
}
//# sourceMappingURL=interfaces.d.ts.map