对seq的处理
This commit is contained in:
parent
6cd11aabd8
commit
bdae4ef294
|
|
@ -1,16 +1,12 @@
|
||||||
import { String, Datetime, PrimaryKey } from "../../types/DataType";
|
import { String } from "../../types/DataType";
|
||||||
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||||
import { OneOf } from "../../types/Polyfill";
|
import { OneOf } from "../../types/Polyfill";
|
||||||
import * as SubQuery from "../_SubQuery";
|
import * as SubQuery from "../_SubQuery";
|
||||||
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||||
import { Action, ParticularAction, IState } from "./Action";
|
import { Action, ParticularAction, IState } from "./Action";
|
||||||
import * as ModiEntity from "../ModiEntity/Schema";
|
import * as ModiEntity from "../ModiEntity/Schema";
|
||||||
import * as OperEntity from "../OperEntity/Schema";
|
import * as OperEntity from "../OperEntity/Schema";
|
||||||
export declare type OpSchema = {
|
export declare type OpSchema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
targetEntity: String<32>;
|
targetEntity: String<32>;
|
||||||
entity: String<32>;
|
entity: String<32>;
|
||||||
entityId: String<64>;
|
entityId: String<64>;
|
||||||
|
|
@ -21,11 +17,7 @@ export declare type OpSchema = {
|
||||||
iState?: IState | null;
|
iState?: IState | null;
|
||||||
};
|
};
|
||||||
export declare type OpAttr = keyof OpSchema;
|
export declare type OpAttr = keyof OpSchema;
|
||||||
export declare type Schema = {
|
export declare type Schema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
targetEntity: String<32>;
|
targetEntity: String<32>;
|
||||||
entity: String<32>;
|
entity: String<32>;
|
||||||
entityId: String<64>;
|
entityId: String<64>;
|
||||||
|
|
@ -42,6 +34,7 @@ export declare type Schema = {
|
||||||
declare type AttrFilter = {
|
declare type AttrFilter = {
|
||||||
id: Q_StringValue | SubQuery.ModiIdSubQuery;
|
id: Q_StringValue | SubQuery.ModiIdSubQuery;
|
||||||
$$createAt$$: Q_DateValue;
|
$$createAt$$: Q_DateValue;
|
||||||
|
$$seq$$: Q_StringValue;
|
||||||
$$updateAt$$: Q_DateValue;
|
$$updateAt$$: Q_DateValue;
|
||||||
targetEntity: Q_StringValue;
|
targetEntity: Q_StringValue;
|
||||||
entity: Q_StringValue;
|
entity: Q_StringValue;
|
||||||
|
|
@ -59,6 +52,7 @@ export declare type Projection = {
|
||||||
id: 1;
|
id: 1;
|
||||||
$$createAt$$?: 1;
|
$$createAt$$?: 1;
|
||||||
$$updateAt$$?: 1;
|
$$updateAt$$?: 1;
|
||||||
|
$$seq$$?: 1;
|
||||||
targetEntity?: 1;
|
targetEntity?: 1;
|
||||||
entity?: 1;
|
entity?: 1;
|
||||||
entityId?: 1;
|
entityId?: 1;
|
||||||
|
|
@ -80,6 +74,7 @@ export declare type ExportProjection = {
|
||||||
id?: string;
|
id?: string;
|
||||||
$$createAt$$?: string;
|
$$createAt$$?: string;
|
||||||
$$updateAt$$?: string;
|
$$updateAt$$?: string;
|
||||||
|
$$seq$$?: string;
|
||||||
targetEntity?: string;
|
targetEntity?: string;
|
||||||
entity?: string;
|
entity?: string;
|
||||||
entityId?: string;
|
entityId?: string;
|
||||||
|
|
@ -102,6 +97,8 @@ export declare type SortAttr = {
|
||||||
id: 1;
|
id: 1;
|
||||||
} | {
|
} | {
|
||||||
$$createAt$$: 1;
|
$$createAt$$: 1;
|
||||||
|
} | {
|
||||||
|
$$seq$$: 1;
|
||||||
} | {
|
} | {
|
||||||
$$updateAt$$: 1;
|
$$updateAt$$: 1;
|
||||||
} | {
|
} | {
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,18 @@
|
||||||
import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
|
import { String, ForeignKey } from "../../types/DataType";
|
||||||
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||||
import { OneOf } from "../../types/Polyfill";
|
import { OneOf } from "../../types/Polyfill";
|
||||||
import * as SubQuery from "../_SubQuery";
|
import * as SubQuery from "../_SubQuery";
|
||||||
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||||
import { AppendOnlyAction } from "../../actions/action";
|
import { AppendOnlyAction } from "../../actions/action";
|
||||||
import * as Modi from "../Modi/Schema";
|
import * as Modi from "../Modi/Schema";
|
||||||
import * as User from "../User/Schema";
|
import * as User from "../User/Schema";
|
||||||
export declare type OpSchema = {
|
export declare type OpSchema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
modiId: ForeignKey<"modi">;
|
modiId: ForeignKey<"modi">;
|
||||||
entity: "user" | string;
|
entity: "user" | string;
|
||||||
entityId: String<64>;
|
entityId: String<64>;
|
||||||
};
|
};
|
||||||
export declare type OpAttr = keyof OpSchema;
|
export declare type OpAttr = keyof OpSchema;
|
||||||
export declare type Schema = {
|
export declare type Schema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
modiId: ForeignKey<"modi">;
|
modiId: ForeignKey<"modi">;
|
||||||
entity: "user" | string;
|
entity: "user" | string;
|
||||||
entityId: String<64>;
|
entityId: String<64>;
|
||||||
|
|
@ -32,6 +24,7 @@ export declare type Schema = {
|
||||||
declare type AttrFilter<E> = {
|
declare type AttrFilter<E> = {
|
||||||
id: Q_StringValue | SubQuery.ModiEntityIdSubQuery;
|
id: Q_StringValue | SubQuery.ModiEntityIdSubQuery;
|
||||||
$$createAt$$: Q_DateValue;
|
$$createAt$$: Q_DateValue;
|
||||||
|
$$seq$$: Q_StringValue;
|
||||||
$$updateAt$$: Q_DateValue;
|
$$updateAt$$: Q_DateValue;
|
||||||
modiId: Q_StringValue | SubQuery.ModiIdSubQuery;
|
modiId: Q_StringValue | SubQuery.ModiIdSubQuery;
|
||||||
modi: Modi.Filter;
|
modi: Modi.Filter;
|
||||||
|
|
@ -46,6 +39,7 @@ export declare type Projection = {
|
||||||
id: 1;
|
id: 1;
|
||||||
$$createAt$$?: 1;
|
$$createAt$$?: 1;
|
||||||
$$updateAt$$?: 1;
|
$$updateAt$$?: 1;
|
||||||
|
$$seq$$?: 1;
|
||||||
modiId?: 1;
|
modiId?: 1;
|
||||||
modi?: Modi.Projection;
|
modi?: Modi.Projection;
|
||||||
entity?: 1;
|
entity?: 1;
|
||||||
|
|
@ -58,6 +52,7 @@ export declare type ExportProjection = {
|
||||||
id?: string;
|
id?: string;
|
||||||
$$createAt$$?: string;
|
$$createAt$$?: string;
|
||||||
$$updateAt$$?: string;
|
$$updateAt$$?: string;
|
||||||
|
$$seq$$?: string;
|
||||||
modiId?: string;
|
modiId?: string;
|
||||||
modi?: Modi.ExportProjection;
|
modi?: Modi.ExportProjection;
|
||||||
entity?: string;
|
entity?: string;
|
||||||
|
|
@ -77,6 +72,8 @@ export declare type SortAttr = {
|
||||||
id: 1;
|
id: 1;
|
||||||
} | {
|
} | {
|
||||||
$$createAt$$: 1;
|
$$createAt$$: 1;
|
||||||
|
} | {
|
||||||
|
$$seq$$: 1;
|
||||||
} | {
|
} | {
|
||||||
$$updateAt$$: 1;
|
$$updateAt$$: 1;
|
||||||
} | {
|
} | {
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,12 @@
|
||||||
import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
|
import { String, ForeignKey } from "../../types/DataType";
|
||||||
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||||
import { OneOf } from "../../types/Polyfill";
|
import { OneOf } from "../../types/Polyfill";
|
||||||
import * as SubQuery from "../_SubQuery";
|
import * as SubQuery from "../_SubQuery";
|
||||||
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||||
import { AppendOnlyAction } from "../../actions/action";
|
import { AppendOnlyAction } from "../../actions/action";
|
||||||
import * as User from "../User/Schema";
|
import * as User from "../User/Schema";
|
||||||
import * as OperEntity from "../OperEntity/Schema";
|
import * as OperEntity from "../OperEntity/Schema";
|
||||||
export declare type OpSchema = {
|
export declare type OpSchema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
action: String<16>;
|
action: String<16>;
|
||||||
data: Object;
|
data: Object;
|
||||||
filter?: Object | null;
|
filter?: Object | null;
|
||||||
|
|
@ -18,11 +14,7 @@ export declare type OpSchema = {
|
||||||
operatorId?: ForeignKey<"user"> | null;
|
operatorId?: ForeignKey<"user"> | null;
|
||||||
};
|
};
|
||||||
export declare type OpAttr = keyof OpSchema;
|
export declare type OpAttr = keyof OpSchema;
|
||||||
export declare type Schema = {
|
export declare type Schema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
action: String<16>;
|
action: String<16>;
|
||||||
data: Object;
|
data: Object;
|
||||||
filter?: Object | null;
|
filter?: Object | null;
|
||||||
|
|
@ -36,6 +28,7 @@ export declare type Schema = {
|
||||||
declare type AttrFilter = {
|
declare type AttrFilter = {
|
||||||
id: Q_StringValue | SubQuery.OperIdSubQuery;
|
id: Q_StringValue | SubQuery.OperIdSubQuery;
|
||||||
$$createAt$$: Q_DateValue;
|
$$createAt$$: Q_DateValue;
|
||||||
|
$$seq$$: Q_StringValue;
|
||||||
$$updateAt$$: Q_DateValue;
|
$$updateAt$$: Q_DateValue;
|
||||||
action: Q_StringValue;
|
action: Q_StringValue;
|
||||||
data: Object;
|
data: Object;
|
||||||
|
|
@ -51,6 +44,7 @@ export declare type Projection = {
|
||||||
id: 1;
|
id: 1;
|
||||||
$$createAt$$?: 1;
|
$$createAt$$?: 1;
|
||||||
$$updateAt$$?: 1;
|
$$updateAt$$?: 1;
|
||||||
|
$$seq$$?: 1;
|
||||||
action?: 1;
|
action?: 1;
|
||||||
data?: 1;
|
data?: 1;
|
||||||
filter?: 1;
|
filter?: 1;
|
||||||
|
|
@ -67,6 +61,7 @@ export declare type ExportProjection = {
|
||||||
id?: string;
|
id?: string;
|
||||||
$$createAt$$?: string;
|
$$createAt$$?: string;
|
||||||
$$updateAt$$?: string;
|
$$updateAt$$?: string;
|
||||||
|
$$seq$$?: string;
|
||||||
action?: string;
|
action?: string;
|
||||||
data?: string;
|
data?: string;
|
||||||
filter?: string;
|
filter?: string;
|
||||||
|
|
@ -87,6 +82,8 @@ export declare type SortAttr = {
|
||||||
id: 1;
|
id: 1;
|
||||||
} | {
|
} | {
|
||||||
$$createAt$$: 1;
|
$$createAt$$: 1;
|
||||||
|
} | {
|
||||||
|
$$seq$$: 1;
|
||||||
} | {
|
} | {
|
||||||
$$updateAt$$: 1;
|
$$updateAt$$: 1;
|
||||||
} | {
|
} | {
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,19 @@
|
||||||
import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
|
import { String, ForeignKey } from "../../types/DataType";
|
||||||
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||||
import { OneOf } from "../../types/Polyfill";
|
import { OneOf } from "../../types/Polyfill";
|
||||||
import * as SubQuery from "../_SubQuery";
|
import * as SubQuery from "../_SubQuery";
|
||||||
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||||
import { AppendOnlyAction } from "../../actions/action";
|
import { AppendOnlyAction } from "../../actions/action";
|
||||||
import * as Oper from "../Oper/Schema";
|
import * as Oper from "../Oper/Schema";
|
||||||
import * as Modi from "../Modi/Schema";
|
import * as Modi from "../Modi/Schema";
|
||||||
import * as User from "../User/Schema";
|
import * as User from "../User/Schema";
|
||||||
export declare type OpSchema = {
|
export declare type OpSchema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
operId: ForeignKey<"oper">;
|
operId: ForeignKey<"oper">;
|
||||||
entity: "modi" | "user" | string;
|
entity: "modi" | "user" | string;
|
||||||
entityId: String<64>;
|
entityId: String<64>;
|
||||||
};
|
};
|
||||||
export declare type OpAttr = keyof OpSchema;
|
export declare type OpAttr = keyof OpSchema;
|
||||||
export declare type Schema = {
|
export declare type Schema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
operId: ForeignKey<"oper">;
|
operId: ForeignKey<"oper">;
|
||||||
entity: "modi" | "user" | string;
|
entity: "modi" | "user" | string;
|
||||||
entityId: String<64>;
|
entityId: String<64>;
|
||||||
|
|
@ -34,6 +26,7 @@ export declare type Schema = {
|
||||||
declare type AttrFilter<E> = {
|
declare type AttrFilter<E> = {
|
||||||
id: Q_StringValue | SubQuery.OperEntityIdSubQuery;
|
id: Q_StringValue | SubQuery.OperEntityIdSubQuery;
|
||||||
$$createAt$$: Q_DateValue;
|
$$createAt$$: Q_DateValue;
|
||||||
|
$$seq$$: Q_StringValue;
|
||||||
$$updateAt$$: Q_DateValue;
|
$$updateAt$$: Q_DateValue;
|
||||||
operId: Q_StringValue | SubQuery.OperIdSubQuery;
|
operId: Q_StringValue | SubQuery.OperIdSubQuery;
|
||||||
oper: Oper.Filter;
|
oper: Oper.Filter;
|
||||||
|
|
@ -49,6 +42,7 @@ export declare type Projection = {
|
||||||
id: 1;
|
id: 1;
|
||||||
$$createAt$$?: 1;
|
$$createAt$$?: 1;
|
||||||
$$updateAt$$?: 1;
|
$$updateAt$$?: 1;
|
||||||
|
$$seq$$?: 1;
|
||||||
operId?: 1;
|
operId?: 1;
|
||||||
oper?: Oper.Projection;
|
oper?: Oper.Projection;
|
||||||
entity?: 1;
|
entity?: 1;
|
||||||
|
|
@ -62,6 +56,7 @@ export declare type ExportProjection = {
|
||||||
id?: string;
|
id?: string;
|
||||||
$$createAt$$?: string;
|
$$createAt$$?: string;
|
||||||
$$updateAt$$?: string;
|
$$updateAt$$?: string;
|
||||||
|
$$seq$$?: string;
|
||||||
operId?: string;
|
operId?: string;
|
||||||
oper?: Oper.ExportProjection;
|
oper?: Oper.ExportProjection;
|
||||||
entity?: string;
|
entity?: string;
|
||||||
|
|
@ -85,6 +80,8 @@ export declare type SortAttr = {
|
||||||
id: 1;
|
id: 1;
|
||||||
} | {
|
} | {
|
||||||
$$createAt$$: 1;
|
$$createAt$$: 1;
|
||||||
|
} | {
|
||||||
|
$$seq$$: 1;
|
||||||
} | {
|
} | {
|
||||||
$$updateAt$$: 1;
|
$$updateAt$$: 1;
|
||||||
} | {
|
} | {
|
||||||
|
|
|
||||||
|
|
@ -1,27 +1,19 @@
|
||||||
import { String, Text, Datetime, PrimaryKey } from "../../types/DataType";
|
import { String, Text } from "../../types/DataType";
|
||||||
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
|
||||||
import { OneOf } from "../../types/Polyfill";
|
import { OneOf } from "../../types/Polyfill";
|
||||||
import * as SubQuery from "../_SubQuery";
|
import * as SubQuery from "../_SubQuery";
|
||||||
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
|
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction, EntityShape } from "../../types/Entity";
|
||||||
import { GenericAction, RelationAction } from "../../actions/action";
|
import { GenericAction, RelationAction } from "../../actions/action";
|
||||||
import * as Oper from "../Oper/Schema";
|
import * as Oper from "../Oper/Schema";
|
||||||
import * as OperEntity from "../OperEntity/Schema";
|
import * as OperEntity from "../OperEntity/Schema";
|
||||||
import * as ModiEntity from "../ModiEntity/Schema";
|
import * as ModiEntity from "../ModiEntity/Schema";
|
||||||
export declare type OpSchema = {
|
export declare type OpSchema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
name?: String<16> | null;
|
name?: String<16> | null;
|
||||||
nickname?: String<64> | null;
|
nickname?: String<64> | null;
|
||||||
password?: Text | null;
|
password?: Text | null;
|
||||||
};
|
};
|
||||||
export declare type OpAttr = keyof OpSchema;
|
export declare type OpAttr = keyof OpSchema;
|
||||||
export declare type Schema = {
|
export declare type Schema = EntityShape & {
|
||||||
id: PrimaryKey;
|
|
||||||
$$createAt$$: Datetime;
|
|
||||||
$$updateAt$$: Datetime;
|
|
||||||
$$deleteAt$$?: Datetime | null;
|
|
||||||
name?: String<16> | null;
|
name?: String<16> | null;
|
||||||
nickname?: String<64> | null;
|
nickname?: String<64> | null;
|
||||||
password?: Text | null;
|
password?: Text | null;
|
||||||
|
|
@ -34,6 +26,7 @@ export declare type Schema = {
|
||||||
declare type AttrFilter = {
|
declare type AttrFilter = {
|
||||||
id: Q_StringValue | SubQuery.UserIdSubQuery;
|
id: Q_StringValue | SubQuery.UserIdSubQuery;
|
||||||
$$createAt$$: Q_DateValue;
|
$$createAt$$: Q_DateValue;
|
||||||
|
$$seq$$: Q_StringValue;
|
||||||
$$updateAt$$: Q_DateValue;
|
$$updateAt$$: Q_DateValue;
|
||||||
name: Q_StringValue;
|
name: Q_StringValue;
|
||||||
nickname: Q_StringValue;
|
nickname: Q_StringValue;
|
||||||
|
|
@ -46,6 +39,7 @@ export declare type Projection = {
|
||||||
id: 1;
|
id: 1;
|
||||||
$$createAt$$?: 1;
|
$$createAt$$?: 1;
|
||||||
$$updateAt$$?: 1;
|
$$updateAt$$?: 1;
|
||||||
|
$$seq$$?: 1;
|
||||||
name?: 1;
|
name?: 1;
|
||||||
nickname?: 1;
|
nickname?: 1;
|
||||||
password?: 1;
|
password?: 1;
|
||||||
|
|
@ -65,6 +59,7 @@ export declare type ExportProjection = {
|
||||||
id?: string;
|
id?: string;
|
||||||
$$createAt$$?: string;
|
$$createAt$$?: string;
|
||||||
$$updateAt$$?: string;
|
$$updateAt$$?: string;
|
||||||
|
$$seq$$?: string;
|
||||||
name?: string;
|
name?: string;
|
||||||
nickname?: string;
|
nickname?: string;
|
||||||
password?: string;
|
password?: string;
|
||||||
|
|
@ -85,6 +80,8 @@ export declare type SortAttr = {
|
||||||
id: 1;
|
id: 1;
|
||||||
} | {
|
} | {
|
||||||
$$createAt$$: 1;
|
$$createAt$$: 1;
|
||||||
|
} | {
|
||||||
|
$$seq$$: 1;
|
||||||
} | {
|
} | {
|
||||||
$$updateAt$$: 1;
|
$$updateAt$$: 1;
|
||||||
} | {
|
} | {
|
||||||
|
|
|
||||||
|
|
@ -850,19 +850,7 @@ function analyzeEntity(filename, path, program, relativePath) {
|
||||||
function constructSchema(statements, entity) {
|
function constructSchema(statements, entity) {
|
||||||
var e_1, _a, e_2, _b;
|
var e_1, _a, e_2, _b;
|
||||||
var schemaAttrs = Schema[entity].schemaAttrs;
|
var schemaAttrs = Schema[entity].schemaAttrs;
|
||||||
var members = [
|
var members = [];
|
||||||
// id: String<64>
|
|
||||||
factory.createPropertySignature(undefined, factory.createIdentifier('id'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('PrimaryKey'))),
|
|
||||||
// $$createAt$$: Datetime
|
|
||||||
factory.createPropertySignature(undefined, factory.createIdentifier('$$createAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Datetime'))),
|
|
||||||
// $$updateAt$$: Datetime
|
|
||||||
factory.createPropertySignature(undefined, factory.createIdentifier('$$updateAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Datetime'))),
|
|
||||||
// $$updateAt$$: Datetime
|
|
||||||
factory.createPropertySignature(undefined, factory.createIdentifier('$$deleteAt$$'), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createUnionTypeNode([
|
|
||||||
factory.createTypeReferenceNode(factory.createIdentifier('Datetime')),
|
|
||||||
factory.createLiteralTypeNode(factory.createNull())
|
|
||||||
]))
|
|
||||||
];
|
|
||||||
var members2 = [];
|
var members2 = [];
|
||||||
var _c = ManyToOne, _d = entity, manyToOneSet = _c[_d];
|
var _c = ManyToOne, _d = entity, manyToOneSet = _c[_d];
|
||||||
var _e = OneToMany, _f = entity, oneToManySet = _e[_f];
|
var _e = OneToMany, _f = entity, oneToManySet = _e[_f];
|
||||||
|
|
@ -997,10 +985,14 @@ function constructSchema(statements, entity) {
|
||||||
}
|
}
|
||||||
statements.push(factory.createTypeAliasDeclaration(undefined, [
|
statements.push(factory.createTypeAliasDeclaration(undefined, [
|
||||||
factory.createModifier(ts.SyntaxKind.ExportKeyword)
|
factory.createModifier(ts.SyntaxKind.ExportKeyword)
|
||||||
], factory.createIdentifier('OpSchema'), undefined, factory.createTypeLiteralNode(members)), factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("OpAttr"), undefined, factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeReferenceNode(factory.createIdentifier("OpSchema"), undefined))));
|
], factory.createIdentifier('OpSchema'), undefined, factory.createIntersectionTypeNode([
|
||||||
|
factory.createTypeReferenceNode('EntityShape'),
|
||||||
|
factory.createTypeLiteralNode(members)
|
||||||
|
])), factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("OpAttr"), undefined, factory.createTypeOperatorNode(ts.SyntaxKind.KeyOfKeyword, factory.createTypeReferenceNode(factory.createIdentifier("OpSchema"), undefined))));
|
||||||
statements.push(factory.createTypeAliasDeclaration(undefined, [
|
statements.push(factory.createTypeAliasDeclaration(undefined, [
|
||||||
factory.createModifier(ts.SyntaxKind.ExportKeyword)
|
factory.createModifier(ts.SyntaxKind.ExportKeyword)
|
||||||
], factory.createIdentifier('Schema'), undefined, factory.createIntersectionTypeNode([
|
], factory.createIdentifier('Schema'), undefined, factory.createIntersectionTypeNode([
|
||||||
|
factory.createTypeReferenceNode('EntityShape'),
|
||||||
factory.createTypeLiteralNode(members.concat(members2)),
|
factory.createTypeLiteralNode(members.concat(members2)),
|
||||||
factory.createMappedTypeNode(undefined, factory.createTypeParameterDeclaration(undefined, factory.createIdentifier("A"), factory.createTypeReferenceNode(factory.createIdentifier("ExpressionKey"), undefined), undefined), undefined, factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), undefined)
|
factory.createMappedTypeNode(undefined, factory.createTypeParameterDeclaration(undefined, factory.createIdentifier("A"), factory.createTypeReferenceNode(factory.createIdentifier("ExpressionKey"), undefined), undefined), undefined, factory.createToken(ts.SyntaxKind.QuestionToken), factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword), undefined)
|
||||||
])));
|
])));
|
||||||
|
|
@ -1022,6 +1014,8 @@ function constructFilter(statements, entity) {
|
||||||
])),
|
])),
|
||||||
// $$createAt$$: Q_DateValue
|
// $$createAt$$: Q_DateValue
|
||||||
factory.createPropertySignature(undefined, factory.createIdentifier('$$createAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue'))),
|
factory.createPropertySignature(undefined, factory.createIdentifier('$$createAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue'))),
|
||||||
|
// $$seq$$: Q_StringValue
|
||||||
|
factory.createPropertySignature(undefined, factory.createIdentifier('$$seq$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_StringValue'))),
|
||||||
// $$updateAt$$: Q_DateValue
|
// $$updateAt$$: Q_DateValue
|
||||||
factory.createPropertySignature(undefined, factory.createIdentifier('$$updateAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue')))
|
factory.createPropertySignature(undefined, factory.createIdentifier('$$updateAt$$'), undefined, factory.createTypeReferenceNode(factory.createIdentifier('Q_DateValue')))
|
||||||
];
|
];
|
||||||
|
|
@ -1176,6 +1170,7 @@ function constructProjection(statements, entity) {
|
||||||
['id', true],
|
['id', true],
|
||||||
['$$createAt$$', false],
|
['$$createAt$$', false],
|
||||||
['$$updateAt$$', false],
|
['$$updateAt$$', false],
|
||||||
|
['$$seq$$', false],
|
||||||
];
|
];
|
||||||
var foreignKeyProperties = (_a = {},
|
var foreignKeyProperties = (_a = {},
|
||||||
_a[entity] = [''],
|
_a[entity] = [''],
|
||||||
|
|
@ -1501,6 +1496,8 @@ function constructSorter(statements, entity) {
|
||||||
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("id"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("id"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
||||||
// $$createAt$$: 1
|
// $$createAt$$: 1
|
||||||
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$createAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$createAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
||||||
|
// $$seq$$: 1
|
||||||
|
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$seq$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
||||||
// $$updateAt$$: 1
|
// $$updateAt$$: 1
|
||||||
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$updateAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
factory.createTypeLiteralNode([factory.createPropertySignature(undefined, factory.createIdentifier("$$updateAt$$"), undefined, factory.createLiteralTypeNode(factory.createNumericLiteral("1")))]),
|
||||||
];
|
];
|
||||||
|
|
@ -2549,7 +2546,8 @@ var initialStatements = function () { return [
|
||||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormCreateData")),
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormCreateData")),
|
||||||
factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormUpdateData")),
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormUpdateData")),
|
||||||
factory.createImportSpecifier(false, factory.createIdentifier("Operation"), factory.createIdentifier("OakOperation")),
|
factory.createImportSpecifier(false, factory.createIdentifier("Operation"), factory.createIdentifier("OakOperation")),
|
||||||
factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction"))
|
factory.createImportSpecifier(false, factory.createIdentifier("MakeAction"), factory.createIdentifier("OakMakeAction")),
|
||||||
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier("EntityShape")),
|
||||||
])), factory.createStringLiteral("".concat((0, env_1.TYPE_PATH_IN_OAK_DOMAIN)(), "Entity")), undefined)
|
])), factory.createStringLiteral("".concat((0, env_1.TYPE_PATH_IN_OAK_DOMAIN)(), "Entity")), undefined)
|
||||||
]; };
|
]; };
|
||||||
function outputSubQuery(outputDir, printer) {
|
function outputSubQuery(outputDir, printer) {
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ export declare type Datetime = number | Date;
|
||||||
export declare type Boolean = boolean;
|
export declare type Boolean = boolean;
|
||||||
export declare type PrimaryKey = string;
|
export declare type PrimaryKey = string;
|
||||||
export declare type ForeignKey<E extends string> = string;
|
export declare type ForeignKey<E extends string> = string;
|
||||||
|
export declare type Sequence = string;
|
||||||
export { Geo, SingleGeo } from './Geo';
|
export { Geo, SingleGeo } from './Geo';
|
||||||
export declare type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
|
export declare type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
|
||||||
export declare const types: string[];
|
export declare const types: string[];
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
import { GenericAction } from '../actions/action';
|
import { GenericAction } from '../actions/action';
|
||||||
import { ExpressionKey, ExprOp, MakeFilter, NodeId } from './Demand';
|
import { ExpressionKey, ExprOp, MakeFilter, NodeId } from './Demand';
|
||||||
import { OneOf, OptionalKeys } from './Polyfill';
|
import { OneOf, OptionalKeys } from './Polyfill';
|
||||||
|
import { PrimaryKey, Sequence } from './DataType';
|
||||||
export declare type TriggerDataAttribute = '$$triggerData$$';
|
export declare type TriggerDataAttribute = '$$triggerData$$';
|
||||||
export declare type TriggerTimestampAttribute = '$$triggerTimestamp$$';
|
export declare type TriggerTimestampAttribute = '$$triggerTimestamp$$';
|
||||||
declare type PrimaryKeyAttribute = 'id';
|
declare type PrimaryKeyAttribute = 'id';
|
||||||
export declare type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute;
|
export declare type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute | '$$seq$$';
|
||||||
export declare const initinctiveAttributes: string[];
|
export declare const initinctiveAttributes: string[];
|
||||||
export declare type Filter<A extends string, F extends Object | undefined = undefined> = {
|
export declare type Filter<A extends string, F extends Object | undefined = undefined> = {
|
||||||
filter?: A extends 'create' ? undefined : F;
|
filter?: A extends 'create' ? undefined : F;
|
||||||
|
|
@ -42,7 +43,8 @@ export declare type Operation<A extends GenericAction | string, DATA extends Obj
|
||||||
} & Filter<A, FILTER>;
|
} & Filter<A, FILTER>;
|
||||||
export declare type Selection<DATA extends Object, FILTER extends Object | undefined = undefined, SORT extends Object | undefined = undefined> = Omit<Operation<'select', DATA, FILTER, SORT>, 'id'>;
|
export declare type Selection<DATA extends Object, FILTER extends Object | undefined = undefined, SORT extends Object | undefined = undefined> = Omit<Operation<'select', DATA, FILTER, SORT>, 'id'>;
|
||||||
export interface EntityShape {
|
export interface EntityShape {
|
||||||
id: string;
|
id: PrimaryKey;
|
||||||
|
$$seq$$: Sequence;
|
||||||
$$createAt$$: number | Date;
|
$$createAt$$: number | Date;
|
||||||
$$updateAt$$: number | Date;
|
$$updateAt$$: number | Date;
|
||||||
$$deleteAt$$?: number | Date | null;
|
$$deleteAt$$?: number | Date | null;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.initinctiveAttributes = void 0;
|
exports.initinctiveAttributes = void 0;
|
||||||
exports.initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$'];
|
exports.initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$', '$$seq$$'];
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ export interface Attribute {
|
||||||
default?: string | number | boolean;
|
default?: string | number | boolean;
|
||||||
notNull?: boolean;
|
notNull?: boolean;
|
||||||
unique?: boolean;
|
unique?: boolean;
|
||||||
|
sequenceStart?: number;
|
||||||
}
|
}
|
||||||
export declare type Attributes<SH extends EntityShape> = Omit<{
|
export declare type Attributes<SH extends EntityShape> = Omit<{
|
||||||
[attrName in keyof SH]: Attribute;
|
[attrName in keyof SH]: Attribute;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export declare type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" |
|
||||||
/**
|
/**
|
||||||
* All other regular column types.
|
* All other regular column types.
|
||||||
*/
|
*/
|
||||||
export declare type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree" | "object" | "array" | "function";
|
export declare type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree" | "object" | "array" | "function" | "sequence";
|
||||||
/**
|
/**
|
||||||
* Any column type column can be.
|
* Any column type column can be.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1165,45 +1165,6 @@ function analyzeEntity(filename: string, path: string, program: ts.Program, rela
|
||||||
function constructSchema(statements: Array<ts.Statement>, entity: string) {
|
function constructSchema(statements: Array<ts.Statement>, entity: string) {
|
||||||
const { schemaAttrs } = Schema[entity];
|
const { schemaAttrs } = Schema[entity];
|
||||||
const members: Array<ts.TypeElement> = [
|
const members: Array<ts.TypeElement> = [
|
||||||
// id: String<64>
|
|
||||||
factory.createPropertySignature(
|
|
||||||
undefined,
|
|
||||||
factory.createIdentifier('id'),
|
|
||||||
undefined,
|
|
||||||
factory.createTypeReferenceNode(
|
|
||||||
factory.createIdentifier('PrimaryKey'),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
// $$createAt$$: Datetime
|
|
||||||
factory.createPropertySignature(
|
|
||||||
undefined,
|
|
||||||
factory.createIdentifier('$$createAt$$'),
|
|
||||||
undefined,
|
|
||||||
factory.createTypeReferenceNode(
|
|
||||||
factory.createIdentifier('Datetime'),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
// $$updateAt$$: Datetime
|
|
||||||
factory.createPropertySignature(
|
|
||||||
undefined,
|
|
||||||
factory.createIdentifier('$$updateAt$$'),
|
|
||||||
undefined,
|
|
||||||
factory.createTypeReferenceNode(
|
|
||||||
factory.createIdentifier('Datetime'),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
// $$updateAt$$: Datetime
|
|
||||||
factory.createPropertySignature(
|
|
||||||
undefined,
|
|
||||||
factory.createIdentifier('$$deleteAt$$'),
|
|
||||||
factory.createToken(ts.SyntaxKind.QuestionToken),
|
|
||||||
factory.createUnionTypeNode([
|
|
||||||
factory.createTypeReferenceNode(
|
|
||||||
factory.createIdentifier('Datetime'),
|
|
||||||
),
|
|
||||||
factory.createLiteralTypeNode(factory.createNull())
|
|
||||||
])
|
|
||||||
)
|
|
||||||
];
|
];
|
||||||
const members2: Array<ts.TypeElement> = [];
|
const members2: Array<ts.TypeElement> = [];
|
||||||
|
|
||||||
|
|
@ -1425,7 +1386,10 @@ function constructSchema(statements: Array<ts.Statement>, entity: string) {
|
||||||
],
|
],
|
||||||
factory.createIdentifier('OpSchema'),
|
factory.createIdentifier('OpSchema'),
|
||||||
undefined,
|
undefined,
|
||||||
|
factory.createIntersectionTypeNode([
|
||||||
|
factory.createTypeReferenceNode('EntityShape'),
|
||||||
factory.createTypeLiteralNode(members)
|
factory.createTypeLiteralNode(members)
|
||||||
|
])
|
||||||
),
|
),
|
||||||
factory.createTypeAliasDeclaration(
|
factory.createTypeAliasDeclaration(
|
||||||
undefined,
|
undefined,
|
||||||
|
|
@ -1452,6 +1416,7 @@ function constructSchema(statements: Array<ts.Statement>, entity: string) {
|
||||||
undefined,
|
undefined,
|
||||||
factory.createIntersectionTypeNode(
|
factory.createIntersectionTypeNode(
|
||||||
[
|
[
|
||||||
|
factory.createTypeReferenceNode('EntityShape'),
|
||||||
factory.createTypeLiteralNode(members.concat(members2)),
|
factory.createTypeLiteralNode(members.concat(members2)),
|
||||||
factory.createMappedTypeNode(
|
factory.createMappedTypeNode(
|
||||||
undefined,
|
undefined,
|
||||||
|
|
@ -1510,6 +1475,15 @@ function constructFilter(statements: Array<ts.Statement>, entity: string) {
|
||||||
factory.createIdentifier('Q_DateValue'),
|
factory.createIdentifier('Q_DateValue'),
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
// $$seq$$: Q_StringValue
|
||||||
|
factory.createPropertySignature(
|
||||||
|
undefined,
|
||||||
|
factory.createIdentifier('$$seq$$'),
|
||||||
|
undefined,
|
||||||
|
factory.createTypeReferenceNode(
|
||||||
|
factory.createIdentifier('Q_StringValue'),
|
||||||
|
)
|
||||||
|
),
|
||||||
// $$updateAt$$: Q_DateValue
|
// $$updateAt$$: Q_DateValue
|
||||||
factory.createPropertySignature(
|
factory.createPropertySignature(
|
||||||
undefined,
|
undefined,
|
||||||
|
|
@ -1774,6 +1748,7 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
|
||||||
['id', true],
|
['id', true],
|
||||||
['$$createAt$$', false],
|
['$$createAt$$', false],
|
||||||
['$$updateAt$$', false],
|
['$$updateAt$$', false],
|
||||||
|
['$$seq$$', false],
|
||||||
];
|
];
|
||||||
const foreignKeyProperties: {
|
const foreignKeyProperties: {
|
||||||
[k: string]: [string]
|
[k: string]: [string]
|
||||||
|
|
@ -2259,6 +2234,15 @@ function constructSorter(statements: Array<ts.Statement>, entity: string) {
|
||||||
factory.createLiteralTypeNode(factory.createNumericLiteral("1"))
|
factory.createLiteralTypeNode(factory.createNumericLiteral("1"))
|
||||||
)]
|
)]
|
||||||
),
|
),
|
||||||
|
// $$seq$$: 1
|
||||||
|
factory.createTypeLiteralNode(
|
||||||
|
[factory.createPropertySignature(
|
||||||
|
undefined,
|
||||||
|
factory.createIdentifier("$$seq$$"),
|
||||||
|
undefined,
|
||||||
|
factory.createLiteralTypeNode(factory.createNumericLiteral("1"))
|
||||||
|
)]
|
||||||
|
),
|
||||||
// $$updateAt$$: 1
|
// $$updateAt$$: 1
|
||||||
factory.createTypeLiteralNode(
|
factory.createTypeLiteralNode(
|
||||||
[factory.createPropertySignature(
|
[factory.createPropertySignature(
|
||||||
|
|
@ -4427,7 +4411,12 @@ const initialStatements = () => [
|
||||||
false,
|
false,
|
||||||
factory.createIdentifier("MakeAction"),
|
factory.createIdentifier("MakeAction"),
|
||||||
factory.createIdentifier("OakMakeAction")
|
factory.createIdentifier("OakMakeAction")
|
||||||
)
|
),
|
||||||
|
factory.createImportSpecifier(
|
||||||
|
false,
|
||||||
|
undefined,
|
||||||
|
factory.createIdentifier("EntityShape")
|
||||||
|
),
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
factory.createStringLiteral(`${TYPE_PATH_IN_OAK_DOMAIN()}Entity`),
|
factory.createStringLiteral(`${TYPE_PATH_IN_OAK_DOMAIN()}Entity`),
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import { EntityDict } from "./Entity";
|
|
||||||
export declare type Action = string;
|
|
||||||
export declare type State = string;
|
|
||||||
export declare type ActionDef<A extends Action, S extends State> = {
|
|
||||||
stm: {
|
|
||||||
[a in A]: [p: S | S[], n: S];
|
|
||||||
};
|
|
||||||
is?: S;
|
|
||||||
};
|
|
||||||
export declare type ActionDictOfEntityDict<E extends EntityDict> = {
|
|
||||||
[T in keyof E]?: {
|
|
||||||
[A in keyof E[T]['OpSchema']]?: ActionDef<string, string>;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
import { Context, RowStore } from ".";
|
|
||||||
import { EntityDict } from "./Entity";
|
|
||||||
export declare abstract class AppLoader<ED extends EntityDict, Cxt extends Context<ED>> {
|
|
||||||
protected path: string;
|
|
||||||
constructor(path: string);
|
|
||||||
abstract goAspect(name: string, context: Cxt, params?: any): Promise<any>;
|
|
||||||
abstract initialize(dropIfExists?: boolean): Promise<void>;
|
|
||||||
abstract mount(): Promise<void>;
|
|
||||||
abstract unmount(): Promise<void>;
|
|
||||||
abstract getStore(): RowStore<ED, Cxt>;
|
|
||||||
}
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import { EntityDict } from "./Entity";
|
|
||||||
import { Context } from './Context';
|
|
||||||
import { OpRecord } from "./Entity";
|
|
||||||
export interface Aspect<ED extends EntityDict, Cxt extends Context<ED>> {
|
|
||||||
(params: any, context: Cxt): Promise<any>;
|
|
||||||
}
|
|
||||||
export interface AspectWrapper<ED extends EntityDict, Cxt extends Context<ED>, AD extends Record<string, Aspect<ED, Cxt>>> {
|
|
||||||
exec: <T extends keyof AD>(name: T, params: Parameters<AD[T]>[0]) => Promise<{
|
|
||||||
result: Awaited<ReturnType<AD[T]>>;
|
|
||||||
opRecords: OpRecord<ED>[];
|
|
||||||
}>;
|
|
||||||
}
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
import { EntityDict } from "../types/Entity";
|
|
||||||
import { Context } from "./Context";
|
|
||||||
import { CreateTriggerBase, RemoveTriggerBase, UpdateTriggerBase, CheckerType, SelectTriggerBefore } from "./Trigger";
|
|
||||||
export declare type CreateChecker<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = {
|
|
||||||
type: CheckerType;
|
|
||||||
action: 'create';
|
|
||||||
entity: T;
|
|
||||||
checker: CreateTriggerBase<ED, T, Cxt>['fn'];
|
|
||||||
};
|
|
||||||
export declare type UpdateChecker<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = {
|
|
||||||
type: CheckerType;
|
|
||||||
action: UpdateTriggerBase<ED, T, Cxt>['action'];
|
|
||||||
entity: T;
|
|
||||||
checker: UpdateTriggerBase<ED, T, Cxt>['fn'];
|
|
||||||
};
|
|
||||||
export declare type RemoveChecker<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = {
|
|
||||||
type: CheckerType;
|
|
||||||
action: 'remove';
|
|
||||||
entity: T;
|
|
||||||
checker: RemoveTriggerBase<ED, T, Cxt>['fn'];
|
|
||||||
};
|
|
||||||
export declare type SelectChecker<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = {
|
|
||||||
type: CheckerType;
|
|
||||||
action: 'select';
|
|
||||||
entity: T;
|
|
||||||
checker: SelectTriggerBefore<ED, T, Cxt>['fn'];
|
|
||||||
};
|
|
||||||
export declare type Checker<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = CreateChecker<ED, T, Cxt> | UpdateChecker<ED, T, Cxt> | RemoveChecker<ED, T, Cxt> | SelectChecker<ED, T, Cxt>;
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import { EntityDict, OpRecord } from './Entity';
|
|
||||||
import { RowStore } from './RowStore';
|
|
||||||
export interface Context<ED extends EntityDict> {
|
|
||||||
opRecords: OpRecord<ED>[];
|
|
||||||
rowStore: RowStore<ED, this>;
|
|
||||||
begin(options?: object): Promise<void>;
|
|
||||||
commit(): Promise<void>;
|
|
||||||
rollback(): Promise<void>;
|
|
||||||
getCurrentTxnId(): string | undefined;
|
|
||||||
on(event: 'commit' | 'rollback', callback: () => Promise<void>): void;
|
|
||||||
toString(): Promise<string>;
|
|
||||||
getScene(): string | undefined;
|
|
||||||
setScene(scene?: string): void;
|
|
||||||
}
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import { Geo, SingleGeo } from "./Geo";
|
|
||||||
export declare type Int<L extends 1 | 2 | 4 | 8> = number;
|
|
||||||
export declare type Uint<L extends 1 | 2 | 4 | 8> = number;
|
|
||||||
export declare type Double<P extends number, S extends number> = number;
|
|
||||||
export declare type Float<P extends number, S extends number> = number;
|
|
||||||
export declare type String<L extends number> = string;
|
|
||||||
export declare type Text = string;
|
|
||||||
export declare type Image = string;
|
|
||||||
export declare type File = string;
|
|
||||||
export declare type Datetime = number | Date;
|
|
||||||
export declare type Boolean = boolean;
|
|
||||||
export declare type PrimaryKey = string;
|
|
||||||
export declare type ForeignKey<E extends string> = string;
|
|
||||||
export { Geo, SingleGeo } from './Geo';
|
|
||||||
export declare type DataTypes = number | string | Datetime | Geo | object | SingleGeo;
|
|
||||||
export declare const types: string[];
|
|
||||||
export declare const unIndexedTypes: string[];
|
|
||||||
|
|
@ -12,6 +12,7 @@ export type Datetime = number | Date;
|
||||||
export type Boolean = boolean;
|
export type Boolean = boolean;
|
||||||
export type PrimaryKey = string;
|
export type PrimaryKey = string;
|
||||||
export type ForeignKey<E extends string> = string;
|
export type ForeignKey<E extends string> = string;
|
||||||
|
export type Sequence = string; // 自增长序列,为了让人阅读方便,为了支持分布式这里用string,底层实现可自定义
|
||||||
export { Geo, SingleGeo } from './Geo';
|
export { Geo, SingleGeo } from './Geo';
|
||||||
|
|
||||||
export type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
|
export type DataTypes = number | string | Datetime | Geo | Object | SingleGeo;
|
||||||
|
|
|
||||||
|
|
@ -1,77 +0,0 @@
|
||||||
import { RefOrExpression } from "./Expression";
|
|
||||||
import { OneOf } from "./Polyfill";
|
|
||||||
export declare const EXPRESSION_PREFIX = "$expr";
|
|
||||||
export declare type NodeId = `node-${number}`;
|
|
||||||
export declare type ExpressionKey = '$expr' | '$expr1' | '$expr2' | '$expr3' | '$expr4' | '$expr5' | '$expr6' | '$expr7' | '$expr8' | '$expr9' | '$expr10' | '$expr11' | '$expr12' | '$expr13' | '$expr14' | '$expr15' | '$expr16' | '$expr17' | '$expr18' | '$expr19' | '$expr20';
|
|
||||||
export declare type ExprOp<A> = {
|
|
||||||
[K in ExpressionKey]: RefOrExpression<A>;
|
|
||||||
};
|
|
||||||
export declare type Q_NumberComparisonValue = number | OneOf<{
|
|
||||||
$gt: number;
|
|
||||||
$lt: number;
|
|
||||||
$gte: number;
|
|
||||||
$lte: number;
|
|
||||||
$eq: number;
|
|
||||||
$ne: number;
|
|
||||||
$in: number[];
|
|
||||||
$nin: number[];
|
|
||||||
$between: [number, number];
|
|
||||||
}>;
|
|
||||||
export declare type Q_StringComparisonValue = string | OneOf<{
|
|
||||||
$gt: string;
|
|
||||||
$lt: string;
|
|
||||||
$gte: string;
|
|
||||||
$lte: string;
|
|
||||||
$eq: string;
|
|
||||||
$ne: string;
|
|
||||||
$startsWith: string;
|
|
||||||
$endsWith: string;
|
|
||||||
$includes: string;
|
|
||||||
$in: string[];
|
|
||||||
$nin: string[];
|
|
||||||
}>;
|
|
||||||
export declare type Q_BooleanComparisonValue = boolean;
|
|
||||||
export declare type Q_DateComparisonValue = Q_NumberComparisonValue;
|
|
||||||
export declare type Q_EnumComparisonValue<E> = E | OneOf<{
|
|
||||||
$in: E[];
|
|
||||||
$nin: E[];
|
|
||||||
}>;
|
|
||||||
export declare type Q_ExistsValue = {
|
|
||||||
$exists: boolean;
|
|
||||||
};
|
|
||||||
export declare type Q_NumberValue = Q_NumberComparisonValue | Q_ExistsValue;
|
|
||||||
export declare type Q_StringValue = Q_StringComparisonValue | Q_ExistsValue;
|
|
||||||
export declare type Q_BooleanValue = Q_BooleanComparisonValue | Q_ExistsValue;
|
|
||||||
export declare type Q_DateValue = Q_DateComparisonValue | Q_ExistsValue;
|
|
||||||
export declare type Q_EnumValue<E> = Q_EnumComparisonValue<E> | Q_ExistsValue;
|
|
||||||
export declare type Q_State<S> = S | {
|
|
||||||
$in: S[];
|
|
||||||
} | {
|
|
||||||
$nin: S[];
|
|
||||||
} | Q_ExistsValue;
|
|
||||||
export declare type Q_FullTextValue = {
|
|
||||||
$search: string;
|
|
||||||
$language?: 'zh_CN' | 'en_US';
|
|
||||||
};
|
|
||||||
export declare type Q_FullTextKey = '$text';
|
|
||||||
export declare type FulltextFilter = {
|
|
||||||
[F in Q_FullTextKey]?: Q_FullTextValue;
|
|
||||||
};
|
|
||||||
declare type Q_LogicKey = '$and' | '$or';
|
|
||||||
declare type Q_LinearLogicKey = '$not';
|
|
||||||
export declare type MakeFilterWrapper<F extends Object> = {
|
|
||||||
[Q in Q_LogicKey]?: Array<MakeFilterWrapper<F>>;
|
|
||||||
} & {
|
|
||||||
[Q in Q_LinearLogicKey]?: MakeFilterWrapper<F>;
|
|
||||||
} & Partial<F>;
|
|
||||||
export declare type MakeFilter<F extends Object> = {
|
|
||||||
'#id'?: NodeId;
|
|
||||||
} & MakeFilterWrapper<F>;
|
|
||||||
export declare type RefAttr<A> = {
|
|
||||||
'#attr': A;
|
|
||||||
} | {
|
|
||||||
'#refId': NodeId;
|
|
||||||
'#refAttr': string;
|
|
||||||
};
|
|
||||||
export declare function isRefAttrNode<A>(node: any): node is RefAttr<A>;
|
|
||||||
export {};
|
|
||||||
|
|
@ -1,155 +0,0 @@
|
||||||
import { GenericAction } from '../actions/action';
|
|
||||||
import { ExpressionKey, ExprOp, MakeFilter, NodeId } from './Demand';
|
|
||||||
import { OneOf, OptionalKeys } from './Polyfill';
|
|
||||||
export declare type TriggerDataAttribute = '$$triggerData$$';
|
|
||||||
export declare type TriggerTimestampAttribute = '$$triggerTimestamp$$';
|
|
||||||
declare type PrimaryKeyAttribute = 'id';
|
|
||||||
export declare type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute;
|
|
||||||
export declare const initinctiveAttributes: string[];
|
|
||||||
declare type MySqlHintIndex = {
|
|
||||||
for?: 'join' | 'orderBy' | 'groupBy';
|
|
||||||
names: string[];
|
|
||||||
};
|
|
||||||
declare type MySqlSelectionHint = {
|
|
||||||
forUpdate?: boolean;
|
|
||||||
useIndex?: MySqlHintIndex;
|
|
||||||
forceIndex?: MySqlHintIndex;
|
|
||||||
ignoreIndex?: MySqlHintIndex;
|
|
||||||
};
|
|
||||||
export declare type SelectionHint = {
|
|
||||||
ignoreTrigger?: boolean;
|
|
||||||
includeDeleted?: boolean;
|
|
||||||
mysql?: MySqlSelectionHint;
|
|
||||||
};
|
|
||||||
export declare type Filter<A extends string, F extends Object | undefined = undefined> = {
|
|
||||||
filter?: A extends 'create' ? undefined : F;
|
|
||||||
indexFrom?: A extends 'create' ? undefined : number;
|
|
||||||
count?: A extends 'create' ? undefined : number;
|
|
||||||
};
|
|
||||||
declare type SelectOption = {
|
|
||||||
forUpdate?: true;
|
|
||||||
usingIndex?: 'todo';
|
|
||||||
};
|
|
||||||
export declare type OperateParams = {
|
|
||||||
notCollect?: boolean;
|
|
||||||
obscure?: boolean;
|
|
||||||
};
|
|
||||||
export declare type FormUpdateData<SH extends GeneralEntityShape> = Partial<Omit<SH, InstinctiveAttributes>>;
|
|
||||||
export declare type FormCreateData<SH extends GeneralEntityShape> = Omit<SH, InstinctiveAttributes> & {
|
|
||||||
id: string;
|
|
||||||
};
|
|
||||||
export declare type Operation<A extends GenericAction | string, DATA extends Object, FILTER extends Object | undefined = undefined, SORTER extends Object | undefined = undefined> = {
|
|
||||||
action: A;
|
|
||||||
data: DATA;
|
|
||||||
sorter?: SORTER;
|
|
||||||
option?: A extends 'select' ? SelectOption : undefined;
|
|
||||||
} & Filter<A, FILTER>;
|
|
||||||
export declare type Selection<DATA extends Object, FILTER extends Object | undefined = undefined, SORT extends Object | undefined = undefined> = Operation<'select', DATA, FILTER, SORT>;
|
|
||||||
export interface EntityShape {
|
|
||||||
id: string;
|
|
||||||
$$createAt$$: number | Date;
|
|
||||||
$$updateAt$$: number | Date;
|
|
||||||
$$deleteAt$$?: number | Date | null;
|
|
||||||
}
|
|
||||||
export interface FileCarrierEntityShape extends EntityShape {
|
|
||||||
}
|
|
||||||
interface GeneralEntityShape extends EntityShape {
|
|
||||||
[K: string]: any;
|
|
||||||
}
|
|
||||||
export interface EntityDef {
|
|
||||||
Schema: GeneralEntityShape;
|
|
||||||
OpSchema: GeneralEntityShape;
|
|
||||||
Action: string;
|
|
||||||
ParticularAction?: string;
|
|
||||||
Selection: Omit<DeduceSelection<this['Schema']>, 'action'> & {
|
|
||||||
hint?: SelectionHint;
|
|
||||||
};
|
|
||||||
Operation: DeduceOperation<this['Schema']>;
|
|
||||||
Create: DeduceCreateOperation<this['Schema']>;
|
|
||||||
CreateSingle: DeduceCreateSingleOperation<this['Schema']>;
|
|
||||||
CreateMulti: DeduceCreateMultipleOperation<this['Schema']>;
|
|
||||||
Update: DeduceUpdateOperation<this['Schema']> & {
|
|
||||||
hint?: SelectionHint;
|
|
||||||
};
|
|
||||||
Remove: DeduceRemoveOperation<this['Schema']> & {
|
|
||||||
hint?: SelectionHint;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export interface EntityDict {
|
|
||||||
[E: string]: EntityDef;
|
|
||||||
}
|
|
||||||
export interface OtmSubProjection extends Omit<DeduceSelection<any>, 'action'> {
|
|
||||||
$entity: string;
|
|
||||||
}
|
|
||||||
declare type DeduceProjection<SH extends GeneralEntityShape> = Partial<{
|
|
||||||
'#id': NodeId;
|
|
||||||
} & {
|
|
||||||
[K in keyof SH]: 1 | OtmSubProjection | any;
|
|
||||||
} & ExprOp<keyof SH>>;
|
|
||||||
export declare type AttrFilter<SH extends GeneralEntityShape> = {
|
|
||||||
[K in keyof SH]: any;
|
|
||||||
};
|
|
||||||
export declare type DeduceFilter<SH extends GeneralEntityShape> = MakeFilter<AttrFilter<SH> & ExprOp<keyof SH>>;
|
|
||||||
export declare type DeduceSorterAttr<SH extends GeneralEntityShape> = OneOf<{
|
|
||||||
[K: string]: 1 | object | undefined;
|
|
||||||
} & ExprOp<keyof SH>>;
|
|
||||||
export declare type DeduceSorterItem<SH extends GeneralEntityShape> = {
|
|
||||||
$attr: DeduceSorterAttr<SH>;
|
|
||||||
$direction?: "asc" | "desc";
|
|
||||||
};
|
|
||||||
export declare type DeduceSorter<SH extends GeneralEntityShape> = Array<DeduceSorterItem<SH>>;
|
|
||||||
export declare type DeduceSelection<SH extends GeneralEntityShape> = Selection<DeduceProjection<SH>, DeduceFilter<SH>, DeduceSorter<SH>>;
|
|
||||||
export declare type DeduceCreateOperationData<SH extends GeneralEntityShape> = FormCreateData<SH> & {
|
|
||||||
[k: string]: any;
|
|
||||||
};
|
|
||||||
export declare type DeduceCreateSingleOperation<SH extends GeneralEntityShape> = Operation<'create', DeduceCreateOperationData<SH>>;
|
|
||||||
export declare type DeduceCreateMultipleOperation<SH extends GeneralEntityShape> = Operation<'create', Array<DeduceCreateOperationData<SH>>>;
|
|
||||||
export declare type DeduceCreateOperation<SH extends GeneralEntityShape> = DeduceCreateSingleOperation<SH> | DeduceCreateMultipleOperation<SH>;
|
|
||||||
export declare type DeduceUpdateOperationData<SH extends GeneralEntityShape> = FormUpdateData<SH> & {
|
|
||||||
[k: string]: any;
|
|
||||||
};
|
|
||||||
export declare type DeduceUpdateOperation<SH extends GeneralEntityShape> = Operation<'update' | string, DeduceUpdateOperationData<SH>, DeduceFilter<SH>, DeduceSorter<SH>>;
|
|
||||||
export declare type DeduceRemoveOperationData<SH extends GeneralEntityShape> = {
|
|
||||||
[A in keyof SH]?: any;
|
|
||||||
} & {
|
|
||||||
[A: string]: any;
|
|
||||||
};
|
|
||||||
export declare type DeduceRemoveOperation<SH extends GeneralEntityShape> = Operation<'remove', DeduceRemoveOperationData<SH>, DeduceFilter<SH>, DeduceSorter<SH>>;
|
|
||||||
export declare type DeduceOperation<SH extends GeneralEntityShape> = DeduceCreateOperation<SH> | DeduceUpdateOperation<SH> | DeduceRemoveOperation<SH> | DeduceSelection<SH>;
|
|
||||||
export declare type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
||||||
a: 'c';
|
|
||||||
e: T;
|
|
||||||
d: ED[T]['OpSchema'] | ED[T]['OpSchema'][];
|
|
||||||
};
|
|
||||||
export declare type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
||||||
a: 'u';
|
|
||||||
e: T;
|
|
||||||
d: FormUpdateData<ED[T]['OpSchema']>;
|
|
||||||
f?: DeduceFilter<ED[T]['Schema']>;
|
|
||||||
};
|
|
||||||
export declare type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|
||||||
a: 'r';
|
|
||||||
e: T;
|
|
||||||
f?: DeduceFilter<ED[T]['Schema']>;
|
|
||||||
};
|
|
||||||
export declare type SelectOpResult<ED extends EntityDict> = {
|
|
||||||
a: 's';
|
|
||||||
d: {
|
|
||||||
[T in keyof ED]?: {
|
|
||||||
[ID: string]: ED[T]['OpSchema'];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
export declare type OpRecord<ED extends EntityDict> = CreateOpResult<ED, keyof ED> | UpdateOpResult<ED, keyof ED> | RemoveOpResult<ED, keyof ED> | SelectOpResult<ED>;
|
|
||||||
export declare type OperationResult<ED extends EntityDict> = {
|
|
||||||
[K in keyof ED]?: {
|
|
||||||
[A in ED[K]['Action']]?: number;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
export declare type SelectRowShape<E extends GeneralEntityShape, P extends DeduceProjection<GeneralEntityShape>> = {
|
|
||||||
[K in keyof P]: K extends ExpressionKey ? any : (K extends keyof E ? (P[K] extends 1 | undefined ? E[K] : (P[K] extends OtmSubProjection ? SelectRowShape<Required<E>[K][0], P[K]['data']>[] | Array<never> : (K extends OptionalKeys<E> ? SelectRowShape<NonNullable<Required<E>[K]>, P[K]> | null : SelectRowShape<NonNullable<Required<E>[K]>, P[K]>))) : never);
|
|
||||||
};
|
|
||||||
export declare type SelectionResult<E extends GeneralEntityShape, P extends DeduceProjection<GeneralEntityShape>> = {
|
|
||||||
result: Array<SelectRowShape<E, P>>;
|
|
||||||
};
|
|
||||||
export {};
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
import { GenericAction } from '../actions/action';
|
import { GenericAction } from '../actions/action';
|
||||||
import { ExpressionKey, ExprOp, FulltextFilter, MakeFilter, NodeId, Q_BooleanValue, Q_NumberValue, Q_StringValue } from './Demand';
|
import { ExpressionKey, ExprOp, FulltextFilter, MakeFilter, NodeId, Q_BooleanValue, Q_NumberValue, Q_StringValue } from './Demand';
|
||||||
import { OneOf, OptionalKeys } from './Polyfill';
|
import { OneOf, OptionalKeys } from './Polyfill';
|
||||||
|
import { PrimaryKey, Sequence } from './DataType';
|
||||||
|
|
||||||
export type TriggerDataAttribute = '$$triggerData$$';
|
export type TriggerDataAttribute = '$$triggerData$$';
|
||||||
export type TriggerTimestampAttribute = '$$triggerTimestamp$$';
|
export type TriggerTimestampAttribute = '$$triggerTimestamp$$';
|
||||||
|
|
||||||
type PrimaryKeyAttribute = 'id';
|
type PrimaryKeyAttribute = 'id';
|
||||||
export type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute;
|
export type InstinctiveAttributes = PrimaryKeyAttribute | '$$createAt$$' | '$$updateAt$$' | '$$deleteAt$$' | TriggerDataAttribute | TriggerTimestampAttribute | '$$seq$$';
|
||||||
export const initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$'];
|
export const initinctiveAttributes = ['id', '$$createAt$$', '$$updateAt$$', '$$deleteAt$$', '$$triggerData$$', '$$triggerTimestamp$$', '$$seq$$'];
|
||||||
|
|
||||||
export type Filter<A extends string, F extends Object | undefined = undefined> = {
|
export type Filter<A extends string, F extends Object | undefined = undefined> = {
|
||||||
filter?: A extends 'create' ? undefined : F;
|
filter?: A extends 'create' ? undefined : F;
|
||||||
|
|
@ -55,7 +56,8 @@ export type Selection<DATA extends Object,
|
||||||
SORT extends Object | undefined = undefined> = Omit<Operation<'select', DATA, FILTER, SORT>, 'id'>;
|
SORT extends Object | undefined = undefined> = Omit<Operation<'select', DATA, FILTER, SORT>, 'id'>;
|
||||||
|
|
||||||
export interface EntityShape {
|
export interface EntityShape {
|
||||||
id: string;
|
id: PrimaryKey;
|
||||||
|
$$seq$$: Sequence;
|
||||||
$$createAt$$: number | Date;
|
$$createAt$$: number | Date;
|
||||||
$$updateAt$$: number | Date;
|
$$updateAt$$: number | Date;
|
||||||
$$deleteAt$$?: number | Date | null;
|
$$deleteAt$$?: number | Date | null;
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import { EntityDict, OpRecord } from "./Entity";
|
|
||||||
export declare class OakException extends Error {
|
|
||||||
}
|
|
||||||
export declare class OakUserException extends OakException {
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 数据不一致异常,系统认为现有的数据不允许相应的动作时抛此异常
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export declare class OakRowInconsistencyException<ED extends EntityDict> extends OakUserException {
|
|
||||||
private data?;
|
|
||||||
constructor(data?: OpRecord<ED>, message?: string);
|
|
||||||
getData(): OpRecord<ED> | undefined;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 当输入的数据非法时抛此异常,attributes表示非法的属性
|
|
||||||
*/
|
|
||||||
export declare class OakInputIllegalException extends OakUserException {
|
|
||||||
private attributes;
|
|
||||||
constructor(attributes: string[], message?: string);
|
|
||||||
getAttributes(): string[];
|
|
||||||
addAttributesPrefix(prefix: string): void;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 用户权限不够时抛的异常
|
|
||||||
*/
|
|
||||||
export declare class OakUserUnpermittedException extends OakUserException {
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 要插入行时,发现已经有相同的行数据
|
|
||||||
*/
|
|
||||||
export declare class OakCongruentRowExists<ED extends EntityDict, T extends keyof ED> extends OakUserException {
|
|
||||||
private data;
|
|
||||||
constructor(data: ED[T]['OpSchema'], message?: string);
|
|
||||||
getData(): ED[T]["OpSchema"];
|
|
||||||
}
|
|
||||||
|
|
@ -1,131 +0,0 @@
|
||||||
import { RefAttr } from "./Demand";
|
|
||||||
import { Geo } from "./Geo";
|
|
||||||
export declare type RefOrExpression<A> = RefAttr<A> | Expression<A>;
|
|
||||||
declare type MathType<A> = RefOrExpression<A> | number;
|
|
||||||
interface Add<A> {
|
|
||||||
$add: [MathType<A>, MathType<A>];
|
|
||||||
}
|
|
||||||
interface Subtract<A> {
|
|
||||||
$subtract: [MathType<A>, MathType<A>];
|
|
||||||
}
|
|
||||||
interface Multiply<A> {
|
|
||||||
$multiply: [MathType<A>, MathType<A>];
|
|
||||||
}
|
|
||||||
interface Divide<A> {
|
|
||||||
$divide: [MathType<A>, MathType<A>];
|
|
||||||
}
|
|
||||||
interface Abs<A> {
|
|
||||||
$abs: MathType<A>;
|
|
||||||
}
|
|
||||||
interface Round<A> {
|
|
||||||
$round: [MathType<A>, MathType<A>];
|
|
||||||
}
|
|
||||||
interface Floor<A> {
|
|
||||||
$floor: MathType<A>;
|
|
||||||
}
|
|
||||||
interface Ceil<A> {
|
|
||||||
$ceil: MathType<A>;
|
|
||||||
}
|
|
||||||
interface Pow<A> {
|
|
||||||
$pow: [MathType<A>, MathType<A>];
|
|
||||||
}
|
|
||||||
declare type MathExpression<A> = Add<A> | Subtract<A> | Multiply<A> | Divide<A> | Abs<A> | Round<A> | Floor<A> | Ceil<A> | Pow<A>;
|
|
||||||
declare type CmpType<A> = RefOrExpression<A> | string | number;
|
|
||||||
interface Gt<A> {
|
|
||||||
$gt: [CmpType<A>, CmpType<A>];
|
|
||||||
}
|
|
||||||
interface Lt<A> {
|
|
||||||
$lt: [CmpType<A>, CmpType<A>];
|
|
||||||
}
|
|
||||||
interface Eq<A> {
|
|
||||||
$eq: [CmpType<A>, CmpType<A>];
|
|
||||||
}
|
|
||||||
interface Gte<A> {
|
|
||||||
$gte: [CmpType<A>, CmpType<A>];
|
|
||||||
}
|
|
||||||
interface Lte<A> {
|
|
||||||
$lte: [CmpType<A>, CmpType<A>];
|
|
||||||
}
|
|
||||||
interface Ne<A> {
|
|
||||||
$ne: [CmpType<A>, CmpType<A>];
|
|
||||||
}
|
|
||||||
interface StartsWith<A> {
|
|
||||||
$startsWith: [RefOrExpression<A> | string, RefOrExpression<A> | string];
|
|
||||||
}
|
|
||||||
interface EndsWith<A> {
|
|
||||||
$endsWith: [RefOrExpression<A> | string, RefOrExpression<A> | string];
|
|
||||||
}
|
|
||||||
interface Includes<A> {
|
|
||||||
$includes: [RefOrExpression<A> | string, RefOrExpression<A> | string];
|
|
||||||
}
|
|
||||||
declare type CompareExpression<A> = Lt<A> | Gt<A> | Lte<A> | Gte<A> | Eq<A> | Ne<A> | StartsWith<A> | EndsWith<A> | Includes<A>;
|
|
||||||
interface BoolTrue<A> {
|
|
||||||
$true: Expression<A>;
|
|
||||||
}
|
|
||||||
interface BoolFalse<A> {
|
|
||||||
$false: Expression<A>;
|
|
||||||
}
|
|
||||||
declare type BoolExpression<A> = BoolTrue<A> | BoolFalse<A>;
|
|
||||||
interface LogicAnd<A> {
|
|
||||||
$and: Expression<A>[];
|
|
||||||
}
|
|
||||||
interface LogicOr<A> {
|
|
||||||
$or: Expression<A>[];
|
|
||||||
}
|
|
||||||
interface LogicNot<A> {
|
|
||||||
$not: Expression<A>;
|
|
||||||
}
|
|
||||||
declare type LogicExpression<A> = LogicAnd<A> | LogicOr<A> | LogicNot<A>;
|
|
||||||
interface DateYear<A> {
|
|
||||||
$year: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateMonth<A> {
|
|
||||||
$month: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateWeekday<A> {
|
|
||||||
$weekday: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateWeekOfYear<A> {
|
|
||||||
$weekOfYear: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateDay<A> {
|
|
||||||
$day: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateDayOfMonth<A> {
|
|
||||||
$dayOfMonth: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateDayOfWeek<A> {
|
|
||||||
$dayOfWeek: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateDayOfYear<A> {
|
|
||||||
$dayOfYear: RefOrExpression<A> | Date | number;
|
|
||||||
}
|
|
||||||
interface DateDiff<A> {
|
|
||||||
$dateDiff: [RefOrExpression<A> | Date | number, RefOrExpression<A> | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's'];
|
|
||||||
}
|
|
||||||
interface DateCeiling<A> {
|
|
||||||
$dateCeil: [RefOrExpression<A> | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's'];
|
|
||||||
}
|
|
||||||
interface DateFloor<A> {
|
|
||||||
$dateFloor: [RefOrExpression<A> | Date | number, 'y' | 'M' | 'd' | 'h' | 'm' | 's'];
|
|
||||||
}
|
|
||||||
declare type DateExpression<A> = DateYear<A> | DateMonth<A> | DateWeekday<A> | DateWeekOfYear<A> | DateDay<A> | DateDayOfYear<A> | DateDayOfMonth<A> | DateDayOfWeek<A> | DateDiff<A> | DateCeiling<A> | DateFloor<A>;
|
|
||||||
interface GeoContains<A> {
|
|
||||||
$contains: [RefOrExpression<A> | Geo, RefOrExpression<A> | Geo];
|
|
||||||
}
|
|
||||||
interface GeoDistance<A> {
|
|
||||||
$distance: [RefOrExpression<A> | Geo, RefOrExpression<A> | Geo];
|
|
||||||
}
|
|
||||||
declare type GeoExpression<A> = GeoContains<A> | GeoDistance<A>;
|
|
||||||
export declare type Expression<A> = GeoExpression<A> | DateExpression<A> | LogicExpression<A> | BoolExpression<A> | CompareExpression<A> | MathExpression<A>;
|
|
||||||
export declare type ExpressionConstant = Geo | number | Date | string | boolean;
|
|
||||||
export declare function isGeoExpression<A>(expression: any): expression is GeoExpression<A>;
|
|
||||||
export declare function isDateExpression<A>(expression: any): expression is DateExpression<A>;
|
|
||||||
export declare function isLogicExpression<A>(expression: any): expression is LogicExpression<A>;
|
|
||||||
export declare function isBoolExpression<A>(expression: any): expression is BoolExpression<A>;
|
|
||||||
export declare function isCompareExpression<A>(expression: any): expression is CompareExpression<A>;
|
|
||||||
export declare function isMathExpression<A>(expression: any): expression is MathExpression<A>;
|
|
||||||
export declare function isExpression<A>(expression: any): expression is Expression<A>;
|
|
||||||
export declare function opMultipleParams(op: string): boolean;
|
|
||||||
export declare function execOp(op: string, params: any, obscure?: boolean): ExpressionConstant;
|
|
||||||
export {};
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
export declare type Point = [number, number];
|
|
||||||
export declare type Path = Array<Point>;
|
|
||||||
export declare type Polygon = Array<Path>;
|
|
||||||
export declare type Circle = [Point, number];
|
|
||||||
export declare type SingleGeo = {
|
|
||||||
type: 'point';
|
|
||||||
coordinate: Point;
|
|
||||||
} | {
|
|
||||||
type: 'path';
|
|
||||||
coordinate: Path;
|
|
||||||
} | {
|
|
||||||
type: 'polygon';
|
|
||||||
coordinate: Polygon;
|
|
||||||
} | {
|
|
||||||
type: 'circle';
|
|
||||||
coordinate: Circle;
|
|
||||||
};
|
|
||||||
export declare type Geo = SingleGeo | SingleGeo[];
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
export interface Logger {
|
|
||||||
error(...data: any[]): void;
|
|
||||||
info(...data: any[]): void;
|
|
||||||
log(...data: any[]): void;
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
export declare type OmitInferKey<T, R> = {
|
|
||||||
[K in keyof T as T extends R ? never : K]: T[K];
|
|
||||||
};
|
|
||||||
export declare type OmitInferValue<T, R> = {
|
|
||||||
[K in keyof T as T extends R ? never : K]: T[K];
|
|
||||||
};
|
|
||||||
export declare type ValueOf<Obj> = Obj[keyof Obj];
|
|
||||||
export declare type OneOnly<Obj, Key extends keyof Obj> = {
|
|
||||||
[key in Exclude<keyof Obj, Key>]?: undefined;
|
|
||||||
} & Pick<Obj, Key>;
|
|
||||||
export declare type OneOfByKey<Obj> = {
|
|
||||||
[key in keyof Obj]: OneOnly<Obj, key>;
|
|
||||||
};
|
|
||||||
export declare type OneOf<Obj> = ValueOf<OneOfByKey<Obj>>;
|
|
||||||
declare type IsOptional<T, K extends keyof T> = {
|
|
||||||
[K1 in Exclude<keyof T, K>]: T[K1];
|
|
||||||
} & {
|
|
||||||
K?: T[K];
|
|
||||||
} extends T ? K : never;
|
|
||||||
export declare type OptionalKeys<T> = {
|
|
||||||
[K in keyof T]: IsOptional<T, K>;
|
|
||||||
}[keyof T];
|
|
||||||
export {};
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import { OperationResult, OperateParams, EntityDict, SelectionResult } from './Entity';
|
|
||||||
import { Context } from './Context';
|
|
||||||
import { StorageSchema } from './Storage';
|
|
||||||
import { OakErrorDefDict } from '../OakError';
|
|
||||||
export declare type TxnOption = {
|
|
||||||
isolationLevel: 'repeatable read' | 'serializable';
|
|
||||||
};
|
|
||||||
export declare abstract class RowStore<ED extends EntityDict, Cxt extends Context<ED>> {
|
|
||||||
static $$LEVEL: string;
|
|
||||||
static $$CODES: OakErrorDefDict;
|
|
||||||
protected storageSchema: StorageSchema<ED>;
|
|
||||||
abstract operate<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, params?: OperateParams): Promise<OperationResult<ED>>;
|
|
||||||
abstract select<T extends keyof ED, S extends ED[T]['Selection']>(entity: T, selection: S, context: Cxt, params?: Object): Promise<SelectionResult<ED[T]['Schema'], S['data']>>;
|
|
||||||
abstract count<T extends keyof ED>(entity: T, selection: Omit<ED[T]['Selection'], 'data' | 'sorter' | 'action'>, context: Cxt, params?: Object): Promise<number>;
|
|
||||||
constructor(storageSchema: StorageSchema<ED>);
|
|
||||||
abstract begin(option?: TxnOption): Promise<string>;
|
|
||||||
abstract commit(txnId: string): Promise<void>;
|
|
||||||
abstract rollback(txnId: string): Promise<void>;
|
|
||||||
getSchema(): StorageSchema<ED>;
|
|
||||||
mergeOperationResult(result: OperationResult<ED>, toBeMerged: OperationResult<ED>): void;
|
|
||||||
}
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
import { EntityDict, EntityShape, InstinctiveAttributes } from './Entity';
|
|
||||||
import { DataType, DataTypeParams } from './schema/DataTypes';
|
|
||||||
export declare type Ref = 'ref';
|
|
||||||
export interface Column<SH extends EntityShape> {
|
|
||||||
name: keyof SH | `${string}State`;
|
|
||||||
size?: number;
|
|
||||||
direction?: 'ASC' | 'DESC';
|
|
||||||
}
|
|
||||||
export interface IndexConfig {
|
|
||||||
unique?: boolean;
|
|
||||||
type?: 'fulltext' | 'btree' | 'hash' | 'spatial';
|
|
||||||
parser?: 'ngram';
|
|
||||||
}
|
|
||||||
export interface Index<SH extends EntityShape> {
|
|
||||||
name: string;
|
|
||||||
attributes: Column<SH>[];
|
|
||||||
config?: IndexConfig;
|
|
||||||
}
|
|
||||||
export interface Attribute {
|
|
||||||
type: DataType | Ref;
|
|
||||||
params?: DataTypeParams;
|
|
||||||
ref?: string;
|
|
||||||
onRefDelete?: 'delete' | 'setNull' | 'ignore';
|
|
||||||
default?: string | number | boolean;
|
|
||||||
notNull?: boolean;
|
|
||||||
unique?: boolean;
|
|
||||||
}
|
|
||||||
export declare type Attributes<SH extends EntityShape> = Omit<{
|
|
||||||
[attrName in keyof SH]: Attribute;
|
|
||||||
}, InstinctiveAttributes>;
|
|
||||||
export interface EntityConfig {
|
|
||||||
}
|
|
||||||
export declare type UniqConstraint<SH extends EntityShape> = {
|
|
||||||
attributes: Array<keyof SH>;
|
|
||||||
type?: string;
|
|
||||||
};
|
|
||||||
export interface StorageDesc<SH extends EntityShape> {
|
|
||||||
storageName?: string;
|
|
||||||
comment?: string;
|
|
||||||
attributes: Attributes<SH>;
|
|
||||||
uniqueConstraints?: UniqConstraint<SH>[];
|
|
||||||
indexes?: Index<SH>[];
|
|
||||||
config?: EntityConfig;
|
|
||||||
view?: true;
|
|
||||||
}
|
|
||||||
export declare type StorageSchema<ED extends EntityDict> = {
|
|
||||||
[K in keyof ED]: StorageDesc<ED[K]['OpSchema']>;
|
|
||||||
};
|
|
||||||
|
|
@ -32,6 +32,7 @@ export interface Attribute {
|
||||||
default?: string | number | boolean;
|
default?: string | number | boolean;
|
||||||
notNull?: boolean;
|
notNull?: boolean;
|
||||||
unique?: boolean;
|
unique?: boolean;
|
||||||
|
sequenceStart?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Attributes<SH extends EntityShape> = Omit<{
|
export type Attributes<SH extends EntityShape> = Omit<{
|
||||||
|
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
||||||
import { SelectRowShape } from ".";
|
|
||||||
import { GenericAction } from "../actions/action";
|
|
||||||
import { DeduceCreateOperation, DeduceRemoveOperation, DeduceSelection, DeduceUpdateOperation, EntityDict, OperateParams } from "../types/Entity";
|
|
||||||
import { EntityShape, TriggerDataAttribute, TriggerTimestampAttribute } from "../types/Entity";
|
|
||||||
import { Context } from "./Context";
|
|
||||||
export declare type CheckerType = 'user' | 'row' | 'data';
|
|
||||||
export interface CreateTriggerBase<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> {
|
|
||||||
checkerType?: CheckerType;
|
|
||||||
entity: T;
|
|
||||||
name: string;
|
|
||||||
action: 'create';
|
|
||||||
check?: (operation: DeduceCreateOperation<ED[T]['OpSchema']>) => boolean;
|
|
||||||
fn: (event: {
|
|
||||||
operation: DeduceCreateOperation<ED[T]['OpSchema']>;
|
|
||||||
}, context: Cxt, params?: OperateParams) => Promise<number>;
|
|
||||||
}
|
|
||||||
export interface CreateTriggerInTxn<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends CreateTriggerBase<ED, T, Cxt> {
|
|
||||||
when: 'before' | 'after';
|
|
||||||
}
|
|
||||||
export interface CreateTriggerCrossTxn<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends CreateTriggerBase<ED, T, Cxt> {
|
|
||||||
when: 'commit';
|
|
||||||
strict?: 'takeEasy' | 'makeSure';
|
|
||||||
}
|
|
||||||
export declare type CreateTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = CreateTriggerInTxn<ED, T, Cxt> | CreateTriggerCrossTxn<ED, T, Cxt>;
|
|
||||||
export interface UpdateTriggerBase<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> {
|
|
||||||
checkerType?: CheckerType;
|
|
||||||
entity: T;
|
|
||||||
name: string;
|
|
||||||
action: Exclude<ED[T]['Action'], GenericAction> | 'update' | Array<Exclude<ED[T]['Action'], GenericAction> | 'update'>;
|
|
||||||
attributes?: keyof ED[T]['OpSchema'] | Array<keyof ED[T]['OpSchema']>;
|
|
||||||
check?: (operation: DeduceUpdateOperation<ED[T]['OpSchema']>) => boolean;
|
|
||||||
fn: (event: {
|
|
||||||
operation: DeduceUpdateOperation<ED[T]['OpSchema']>;
|
|
||||||
}, context: Cxt, params?: OperateParams) => Promise<number>;
|
|
||||||
}
|
|
||||||
export interface UpdateTriggerInTxn<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends UpdateTriggerBase<ED, T, Cxt> {
|
|
||||||
when: 'before' | 'after';
|
|
||||||
}
|
|
||||||
export interface UpdateTriggerCrossTxn<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends UpdateTriggerBase<ED, T, Cxt> {
|
|
||||||
when: 'commit';
|
|
||||||
strict?: 'takeEasy' | 'makeSure';
|
|
||||||
}
|
|
||||||
export declare type UpdateTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = UpdateTriggerInTxn<ED, T, Cxt> | UpdateTriggerCrossTxn<ED, T, Cxt>;
|
|
||||||
export interface RemoveTriggerBase<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> {
|
|
||||||
checkerType?: CheckerType;
|
|
||||||
entity: T;
|
|
||||||
name: string;
|
|
||||||
action: 'remove';
|
|
||||||
check?: (operation: DeduceRemoveOperation<ED[T]['OpSchema']>) => boolean;
|
|
||||||
fn: (event: {
|
|
||||||
operation: DeduceRemoveOperation<ED[T]['OpSchema']>;
|
|
||||||
}, context: Cxt, params?: OperateParams) => Promise<number>;
|
|
||||||
}
|
|
||||||
export interface RemoveTriggerInTxn<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends RemoveTriggerBase<ED, T, Cxt> {
|
|
||||||
when: 'before' | 'after';
|
|
||||||
}
|
|
||||||
export interface RemoveTriggerCrossTxn<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends RemoveTriggerBase<ED, T, Cxt> {
|
|
||||||
when: 'commit';
|
|
||||||
strict?: 'takeEasy' | 'makeSure';
|
|
||||||
}
|
|
||||||
export declare type RemoveTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = RemoveTriggerInTxn<ED, T, Cxt> | RemoveTriggerCrossTxn<ED, T, Cxt>;
|
|
||||||
export interface SelectTriggerBase<ED extends EntityDict, T extends keyof ED> {
|
|
||||||
checkerType?: undefined;
|
|
||||||
entity: T;
|
|
||||||
name: string;
|
|
||||||
action: 'select';
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* selection似乎不需要支持跨事务?没想清楚
|
|
||||||
* todo by Xc
|
|
||||||
*/
|
|
||||||
export interface SelectTriggerBefore<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends SelectTriggerBase<ED, T> {
|
|
||||||
when: 'before';
|
|
||||||
fn: (event: {
|
|
||||||
operation: DeduceSelection<ED[T]['Schema']>;
|
|
||||||
}, context: Cxt, params?: OperateParams) => Promise<number>;
|
|
||||||
}
|
|
||||||
export interface SelectTriggerAfter<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> extends SelectTriggerBase<ED, T> {
|
|
||||||
when: 'after';
|
|
||||||
fn: (event: {
|
|
||||||
operation: ED[T]['Selection'];
|
|
||||||
result: SelectRowShape<ED[T]['Schema'], ED[T]['Selection']['data']>[];
|
|
||||||
}, context: Cxt, params?: Object) => Promise<number>;
|
|
||||||
}
|
|
||||||
export declare type SelectTrigger<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = SelectTriggerBefore<ED, T, Cxt> | SelectTriggerAfter<ED, T, Cxt>;
|
|
||||||
export declare type Trigger<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = CreateTrigger<ED, T, Cxt> | UpdateTrigger<ED, T, Cxt> | RemoveTrigger<ED, T, Cxt> | SelectTrigger<ED, T, Cxt>;
|
|
||||||
export interface TriggerEntityShape extends EntityShape {
|
|
||||||
$$triggerData$$?: {
|
|
||||||
name: string;
|
|
||||||
operation: object;
|
|
||||||
};
|
|
||||||
$$triggerTimestamp$$?: number;
|
|
||||||
}
|
|
||||||
export declare abstract class Executor<ED extends EntityDict, Cxt extends Context<ED>> {
|
|
||||||
static dataAttr: TriggerDataAttribute;
|
|
||||||
static timestampAttr: TriggerTimestampAttribute;
|
|
||||||
abstract registerTrigger<T extends keyof ED>(trigger: Trigger<ED, T, Cxt>): void;
|
|
||||||
abstract preOperation<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, params?: OperateParams): Promise<void>;
|
|
||||||
abstract postOperation<T extends keyof ED>(entity: T, operation: ED[T]['Operation'], context: Cxt, params?: OperateParams): Promise<void>;
|
|
||||||
abstract checkpoint(context: Cxt, timestamp: number): Promise<number>;
|
|
||||||
}
|
|
||||||
|
|
@ -1,19 +0,0 @@
|
||||||
import { Context } from "./Context";
|
|
||||||
import { EntityDict, OperationResult, SelectionResult } from "./Entity";
|
|
||||||
declare type ActionData<ED extends EntityDict, T extends keyof ED> = ED[T]['Update']['data'] | ED[T]['Remove']['data'];
|
|
||||||
export interface BBWatcher<ED extends EntityDict, T extends keyof ED> {
|
|
||||||
name: string;
|
|
||||||
entity: T;
|
|
||||||
filter: ED[T]['Selection']['filter'] | (() => Promise<ED[T]['Selection']['filter']>);
|
|
||||||
action: ED[T]['Operation']['action'];
|
|
||||||
actionData: ActionData<ED, T> | (() => Promise<ActionData<ED, T>>);
|
|
||||||
}
|
|
||||||
export interface WBWatcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> {
|
|
||||||
name: string;
|
|
||||||
entity: T;
|
|
||||||
filter: ED[T]['Selection']['filter'] | (() => Promise<ED[T]['Selection']['filter']>);
|
|
||||||
projection: ED[T]['Selection']['data'] | (() => Promise<ED[T]['Selection']['data']>);
|
|
||||||
fn: (context: Cxt, data: SelectionResult<ED[T]['Schema'], Required<this['projection']>>['result']) => Promise<OperationResult<ED>>;
|
|
||||||
}
|
|
||||||
export declare type Watcher<ED extends EntityDict, T extends keyof ED, Cxt extends Context<ED>> = BBWatcher<ED, T> | WBWatcher<ED, T, Cxt>;
|
|
||||||
export {};
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
export * from './Action';
|
|
||||||
export * from './Aspect';
|
|
||||||
export * from './Auth';
|
|
||||||
export * from './Context';
|
|
||||||
export * from './DataType';
|
|
||||||
export * from './Demand';
|
|
||||||
export * from './Entity';
|
|
||||||
export * from './Expression';
|
|
||||||
export * from './Geo';
|
|
||||||
export * from './Logger';
|
|
||||||
export * from './Polyfill';
|
|
||||||
export * from './RowStore';
|
|
||||||
export * from './Storage';
|
|
||||||
export * from './Trigger';
|
|
||||||
export * from './Exception';
|
|
||||||
export * from './Watcher';
|
|
||||||
export * from './AppLoader';
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/**
|
|
||||||
* Column types used for @PrimaryGeneratedColumn() decorator.
|
|
||||||
*/
|
|
||||||
export declare type PrimaryGeneratedColumnType = "int" | "int2" | "int4" | "int8" | "integer" | "tinyint" | "smallint" | "mediumint" | "bigint" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "number";
|
|
||||||
/**
|
|
||||||
* Column types where spatial properties are used.
|
|
||||||
*/
|
|
||||||
export declare type SpatialColumnType = "geometry" | "geography" | "st_geometry" | "st_point";
|
|
||||||
/**
|
|
||||||
* Column types where precision and scale properties are used.
|
|
||||||
*/
|
|
||||||
export declare type WithPrecisionColumnType = "float" | "double" | "dec" | "decimal" | "smalldecimal" | "fixed" | "numeric" | "real" | "double precision" | "number" | "datetime" | "datetime2" | "datetimeoffset" | "time" | "time with time zone" | "time without time zone" | "timestamp" | "timestamp without time zone" | "timestamp with time zone" | "timestamp with local time zone";
|
|
||||||
/**
|
|
||||||
* Column types where column length is used.
|
|
||||||
*/
|
|
||||||
export declare type WithLengthColumnType = "character varying" | "varying character" | "char varying" | "nvarchar" | "national varchar" | "character" | "native character" | "varchar" | "char" | "nchar" | "national char" | "varchar2" | "nvarchar2" | "alphanum" | "shorttext" | "raw" | "binary" | "varbinary" | "string";
|
|
||||||
export declare type WithWidthColumnType = "tinyint" | "smallint" | "mediumint" | "int" | "bigint";
|
|
||||||
/**
|
|
||||||
* All other regular column types.
|
|
||||||
*/
|
|
||||||
export declare type SimpleColumnType = "simple-array" | "simple-json" | "simple-enum" | "int2" | "integer" | "int4" | "int8" | "int64" | "unsigned big int" | "float" | "float4" | "float8" | "smallmoney" | "money" | "boolean" | "bool" | "tinyblob" | "tinytext" | "mediumblob" | "mediumtext" | "blob" | "text" | "ntext" | "citext" | "hstore" | "longblob" | "longtext" | "alphanum" | "shorttext" | "bytes" | "bytea" | "long" | "raw" | "long raw" | "bfile" | "clob" | "nclob" | "image" | "timetz" | "timestamptz" | "timestamp with local time zone" | "smalldatetime" | "date" | "interval year to month" | "interval day to second" | "interval" | "year" | "seconddate" | "point" | "line" | "lseg" | "box" | "circle" | "path" | "polygon" | "geography" | "geometry" | "linestring" | "multipoint" | "multilinestring" | "multipolygon" | "geometrycollection" | "st_geometry" | "st_point" | "int4range" | "int8range" | "numrange" | "tsrange" | "tstzrange" | "daterange" | "enum" | "set" | "cidr" | "inet" | "macaddr" | "bit" | "bit varying" | "varbit" | "tsvector" | "tsquery" | "uuid" | "xml" | "json" | "jsonb" | "varbinary" | "hierarchyid" | "sql_variant" | "rowid" | "urowid" | "uniqueidentifier" | "rowversion" | "array" | "cube" | "ltree" | "object" | "array" | "function";
|
|
||||||
/**
|
|
||||||
* Any column type column can be.
|
|
||||||
*/
|
|
||||||
export declare type DataType = WithPrecisionColumnType | WithLengthColumnType | WithWidthColumnType | SpatialColumnType | SimpleColumnType;
|
|
||||||
export interface DataTypeParams {
|
|
||||||
length?: number;
|
|
||||||
width?: number;
|
|
||||||
precision?: number;
|
|
||||||
scale?: number;
|
|
||||||
signed?: boolean;
|
|
||||||
}
|
|
||||||
|
|
@ -197,7 +197,8 @@ export type SimpleColumnType =
|
||||||
|
|
||||||
| "object" // 增加的json类型别名
|
| "object" // 增加的json类型别名
|
||||||
| "array" // 增加的json类型别名
|
| "array" // 增加的json类型别名
|
||||||
| "function"; // 增加的function类型
|
| "function" // 增加的function类型
|
||||||
|
| "sequence"; // 自增长类型别名
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue