153 lines
6.2 KiB
TypeScript
153 lines
6.2 KiB
TypeScript
import { ForeignKey } from "oak-domain/lib/types/DataType";
|
|
import { Q_DateValue, Q_NumberValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey, SubQueryPredicateMetadata } from "oak-domain/lib/types/Demand";
|
|
import { OneOf } from "oak-domain/lib/types/Polyfill";
|
|
import { FormCreateData, FormUpdateData, DeduceAggregation, Operation as OakOperation, Selection as OakSelection, MakeAction as OakMakeAction, AggregationResult, EntityShape } from "oak-domain/lib/types/Entity";
|
|
import { GenericAction } from "oak-domain/lib/actions/action";
|
|
import { String, Int } from "oak-domain/lib/types/DataType";
|
|
import * as System from "../System/Schema";
|
|
import * as Application from "../Application/Schema";
|
|
export type OpSchema = EntityShape & {
|
|
url: String<64>;
|
|
apiPath?: String<32> | null;
|
|
protocol: "http" | "https";
|
|
port: Int<2>;
|
|
systemId: ForeignKey<"system">;
|
|
};
|
|
export type OpAttr = keyof OpSchema;
|
|
export type Schema = EntityShape & {
|
|
url: String<64>;
|
|
apiPath?: String<32> | null;
|
|
protocol: "http" | "https";
|
|
port: Int<2>;
|
|
systemId: ForeignKey<"system">;
|
|
system: System.Schema;
|
|
application$domain?: Array<Application.Schema>;
|
|
application$domain$$aggr?: AggregationResult<Application.Schema>;
|
|
} & {
|
|
[A in ExpressionKey]?: any;
|
|
};
|
|
type AttrFilter = {
|
|
id: Q_StringValue;
|
|
$$createAt$$: Q_DateValue;
|
|
$$seq$$: Q_NumberValue;
|
|
$$updateAt$$: Q_DateValue;
|
|
url: Q_StringValue;
|
|
apiPath: Q_StringValue;
|
|
protocol: Q_EnumValue<"http" | "https">;
|
|
port: Q_NumberValue;
|
|
systemId: Q_StringValue;
|
|
system: System.Filter;
|
|
application$domain: Application.Filter & SubQueryPredicateMetadata;
|
|
};
|
|
export type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
|
|
export type Projection = {
|
|
"#id"?: NodeId;
|
|
[k: string]: any;
|
|
id?: number;
|
|
$$createAt$$?: number;
|
|
$$updateAt$$?: number;
|
|
$$seq$$?: number;
|
|
url?: number;
|
|
apiPath?: number;
|
|
protocol?: number;
|
|
port?: number;
|
|
systemId?: number;
|
|
system?: System.Projection;
|
|
application$domain?: Application.Selection & {
|
|
$entity: "application";
|
|
};
|
|
application$domain$$aggr?: Application.Aggregation & {
|
|
$entity: "application";
|
|
};
|
|
} & Partial<ExprOp<OpAttr | string>>;
|
|
type DomainIdProjection = OneOf<{
|
|
id: number;
|
|
}>;
|
|
type SystemIdProjection = OneOf<{
|
|
systemId: number;
|
|
}>;
|
|
export type SortAttr = {
|
|
id: number;
|
|
} | {
|
|
$$createAt$$: number;
|
|
} | {
|
|
$$seq$$: number;
|
|
} | {
|
|
$$updateAt$$: number;
|
|
} | {
|
|
url: number;
|
|
} | {
|
|
apiPath: number;
|
|
} | {
|
|
protocol: number;
|
|
} | {
|
|
port: number;
|
|
} | {
|
|
systemId: number;
|
|
} | {
|
|
system: System.SortAttr;
|
|
} | {
|
|
[k: string]: any;
|
|
} | OneOf<ExprOp<OpAttr | string>>;
|
|
export type SortNode = {
|
|
$attr: SortAttr;
|
|
$direction?: "asc" | "desc";
|
|
};
|
|
export type Sorter = SortNode[];
|
|
export type SelectOperation<P extends Object = Projection> = OakSelection<"select", P, Filter, Sorter>;
|
|
export type Selection<P extends Object = Projection> = SelectOperation<P>;
|
|
export type Aggregation = DeduceAggregation<Projection, Filter, Sorter>;
|
|
export type CreateOperationData = FormCreateData<Omit<OpSchema, "systemId">> & (({
|
|
systemId?: never;
|
|
system: System.CreateSingleOperation;
|
|
} | {
|
|
systemId: ForeignKey<"system">;
|
|
system?: System.UpdateOperation;
|
|
} | {
|
|
system?: never;
|
|
systemId: ForeignKey<"system">;
|
|
})) & {
|
|
application$domain?: OakOperation<Application.UpdateOperation["action"], Omit<Application.UpdateOperationData, "domain" | "domainId">, Omit<Application.Filter, "domain" | "domainId">> | OakOperation<"create", Omit<Application.CreateOperationData, "domain" | "domainId">[]> | Array<OakOperation<"create", Omit<Application.CreateOperationData, "domain" | "domainId">> | OakOperation<Application.UpdateOperation["action"], Omit<Application.UpdateOperationData, "domain" | "domainId">, Omit<Application.Filter, "domain" | "domainId">>>;
|
|
};
|
|
export type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
|
|
export type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
|
|
export type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
|
|
export type UpdateOperationData = FormUpdateData<Omit<OpSchema, "systemId">> & (({
|
|
system?: System.CreateSingleOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system?: System.UpdateOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system?: System.RemoveOperation;
|
|
systemId?: never;
|
|
} | {
|
|
system?: never;
|
|
systemId?: ForeignKey<"system">;
|
|
})) & {
|
|
[k: string]: any;
|
|
application$domain?: OakOperation<Application.UpdateOperation["action"], Omit<Application.UpdateOperationData, "domain" | "domainId">, Omit<Application.Filter, "domain" | "domainId">> | OakOperation<Application.RemoveOperation["action"], Omit<Application.RemoveOperationData, "domain" | "domainId">, Omit<Application.Filter, "domain" | "domainId">> | OakOperation<"create", Omit<Application.CreateOperationData, "domain" | "domainId">[]> | Array<OakOperation<"create", Omit<Application.CreateOperationData, "domain" | "domainId">> | OakOperation<Application.UpdateOperation["action"], Omit<Application.UpdateOperationData, "domain" | "domainId">, Omit<Application.Filter, "domain" | "domainId">> | OakOperation<Application.RemoveOperation["action"], Omit<Application.RemoveOperationData, "domain" | "domainId">, Omit<Application.Filter, "domain" | "domainId">>>;
|
|
};
|
|
export type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
|
|
export type RemoveOperationData = {} & (({
|
|
system?: System.UpdateOperation | System.RemoveOperation;
|
|
}));
|
|
export type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
|
|
export type Operation = CreateOperation | UpdateOperation | RemoveOperation;
|
|
export type SystemIdSubQuery = Selection<SystemIdProjection>;
|
|
export type DomainIdSubQuery = Selection<DomainIdProjection>;
|
|
export type EntityDef = {
|
|
Schema: Schema;
|
|
OpSchema: OpSchema;
|
|
Action: OakMakeAction<GenericAction> | string;
|
|
Selection: Selection;
|
|
Aggregation: Aggregation;
|
|
Operation: Operation;
|
|
Create: CreateOperation;
|
|
Update: UpdateOperation;
|
|
Remove: RemoveOperation;
|
|
CreateSingle: CreateSingleOperation;
|
|
CreateMulti: CreateMultipleOperation;
|
|
};
|
|
export {};
|