将user加到了base-domain里面

This commit is contained in:
Xu Chang 2022-08-22 17:32:20 +08:00
parent a4a83dd01f
commit 930211d468
52 changed files with 580 additions and 1013 deletions

View File

@ -1,159 +0,0 @@
import { String, Datetime, PrimaryKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { GenericAction } from "../../actions/action";
import * as Update from "../Update/Schema";
export declare type OpSchema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity?: ("update" | string) | null;
entityId?: String<64> | null;
filter?: Object | null;
extra?: Object | null;
operatorId: String<32>;
operatorInfo?: Object | null;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity?: ("update" | string) | null;
entityId?: String<64> | null;
filter?: Object | null;
extra?: Object | null;
operatorId: String<32>;
operatorInfo?: Object | null;
update?: Update.Schema;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter<E> = {
id: Q_StringValue | SubQuery.ActionIdSubQuery;
$$createAt$$: Q_DateValue;
$$updateAt$$: Q_DateValue;
action: Q_StringValue;
entity: E;
entityId: Q_StringValue;
operatorId: Q_StringValue;
};
export declare type Filter<E = Q_EnumValue<"update" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
id: 1;
$$createAt$$?: 1;
$$updateAt$$?: 1;
action?: 1;
data?: 1;
entity?: 1;
entityId?: 1;
filter?: 1;
extra?: 1;
operatorId?: 1;
operatorInfo?: 1;
update?: Update.Projection;
} & Partial<ExprOp<OpAttr>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
id?: string;
$$createAt$$?: string;
$$updateAt$$?: string;
action?: string;
data?: string;
entity?: string;
entityId?: string;
filter?: string;
extra?: string;
operatorId?: string;
operatorInfo?: string;
update?: Update.ExportProjection;
} & Partial<ExprOp<OpAttr>>;
declare type ActionIdProjection = OneOf<{
id: 1;
}>;
declare type UpdateIdProjection = OneOf<{
entityId: 1;
}>;
export declare type SortAttr = OneOf<{
id: 1;
$$createAt$$: 1;
$$updateAt$$: 1;
action: 1;
entity: 1;
entityId: 1;
operatorId: 1;
update: Update.SortAttr;
[k: string]: any;
} & ExprOp<OpAttr>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export declare type Sorter = SortNode[];
export declare type SelectOperation<P = Projection> = OakOperation<"select", P, Filter, Sorter>;
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entityId" | "entity" | "entityId">> & ({
entity?: never;
entityId?: never;
update: Update.CreateSingleOperation;
} | {
entity: "update";
entityId: String<64>;
update?: Update.UpdateOperation;
} | {
[K: string]: any;
}) & {
[k: string]: any;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entityId" | "entity" | "entityId">> & ({
update?: Update.CreateSingleOperation | Update.UpdateOperation | Update.RemoveOperation;
entityId?: undefined;
entity?: undefined;
} | {
entity?: ("update" | string) | null;
entityId?: String<64> | null;
}) & {
[k: string]: any;
};
export declare type UpdateOperation = OakOperation<"update", UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & ({
update?: Update.UpdateOperation;
} | {
update?: Update.RemoveOperation;
} | {
[k: string]: any;
});
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type UpdateIdSubQuery = Selection<UpdateIdProjection>;
export declare type ActionIdSubQuery = Selection<ActionIdProjection>;
export declare type NativeAttr = OpAttr | `entity.${Update.NativeAttr}`;
export declare type FullAttr = NativeAttr;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: GenericAction;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
};
export {};

View File

@ -1,43 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.desc = void 0;
exports.desc = {
attributes: {
action: {
type: "varchar",
params: {
length: 16
}
},
data: {
type: "object"
},
entity: {
type: "varchar",
params: {
length: 32
}
},
entityId: {
type: "varchar",
params: {
length: 64
}
},
filter: {
type: "object"
},
extra: {
type: "object"
},
operatorId: {
type: "varchar",
params: {
length: 32
}
},
operatorInfo: {
type: "object"
}
}
};

View File

@ -2,9 +2,11 @@ import { EntityDef as Modi } from "./Modi/Schema";
import { EntityDef as ModiEntity } from "./ModiEntity/Schema";
import { EntityDef as Oper } from "./Oper/Schema";
import { EntityDef as OperEntity } from "./OperEntity/Schema";
import { EntityDef as User } from "./User/Schema";
export declare type EntityDict = {
modi: Modi;
modiEntity: ModiEntity;
oper: Oper;
operEntity: OperEntity;
user: User;
};

View File

@ -2,7 +2,7 @@ import { String, Datetime, PrimaryKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
import { Action, ParticularAction, IState } from "./Action";
import * as ModiEntity from "../ModiEntity/Schema";
import * as OperEntity from "../OperEntity/Schema";
@ -40,7 +40,7 @@ declare type AttrFilter = {
action: Q_StringValue;
iState: Q_EnumValue<IState>;
};
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr>>;
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
@ -58,7 +58,7 @@ export declare type Projection = {
operEntity$entity?: OperEntity.Selection & {
$entity: "operEntity";
};
} & Partial<ExprOp<OpAttr>>;
} & Partial<ExprOp<OpAttr | string>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
@ -76,7 +76,7 @@ export declare type ExportProjection = {
operEntity$entity?: OperEntity.Exportation & {
$entity: "operEntity";
};
} & Partial<ExprOp<OpAttr>>;
} & Partial<ExprOp<OpAttr | string>>;
declare type ModiIdProjection = OneOf<{
id: 1;
}>;
@ -92,7 +92,7 @@ export declare type SortAttr = {
iState: 1;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr>>;
} | OneOf<ExprOp<OpAttr | string>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
@ -103,8 +103,8 @@ export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<OpSchema> & {
[k: string]: any;
modiEntity$modi?: OakOperation<"update", Omit<ModiEntity.UpdateOperationData, "modi" | "modiId">, ModiEntity.Filter> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "modi" | "modiId"> | Omit<ModiEntity.CreateOperationData, "modi" | "modiId">[]> | OakOperation<"update", Omit<ModiEntity.UpdateOperationData, "modi" | "modiId">, ModiEntity.Filter>>;
operEntity$entity?: OakOperation<"update", Omit<OperEntity.UpdateOperationData, "entity" | "entityId">, OperEntity.Filter> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId"> | Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | OakOperation<"update", Omit<OperEntity.UpdateOperationData, "entity" | "entityId">, OperEntity.Filter>>;
modiEntity$modi?: OakOperation<ModiEntity.UpdateOperation["action"], Omit<ModiEntity.UpdateOperationData, "modi" | "modiId">, ModiEntity.Filter> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "modi" | "modiId"> | Omit<ModiEntity.CreateOperationData, "modi" | "modiId">[]> | OakOperation<ModiEntity.UpdateOperation["action"], Omit<ModiEntity.UpdateOperationData, "modi" | "modiId">, ModiEntity.Filter>>;
operEntity$entity?: OakOperation<OperEntity.UpdateOperation["action"], Omit<OperEntity.UpdateOperationData, "entity" | "entityId">, OperEntity.Filter> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId"> | Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | OakOperation<OperEntity.UpdateOperation["action"], Omit<OperEntity.UpdateOperationData, "entity" | "entityId">, OperEntity.Filter>>;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
@ -114,7 +114,7 @@ export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
modiEntitys$modi?: ModiEntity.UpdateOperation | ModiEntity.RemoveOperation | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "modi" | "modiId"> | Omit<ModiEntity.CreateOperationData, "modi" | "modiId">[]> | ModiEntity.UpdateOperation | ModiEntity.RemoveOperation>;
operEntitys$entity?: OperEntity.UpdateOperation | OperEntity.RemoveOperation | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId"> | Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | OperEntity.UpdateOperation | OperEntity.RemoveOperation>;
};
export declare type UpdateOperation = OakOperation<ParticularAction | "update", UpdateOperationData, Filter, Sorter>;
export declare type UpdateOperation = OakOperation<ParticularAction | "update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {};
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
@ -124,7 +124,7 @@ export declare type FullAttr = NativeAttr | `modiEntitys$${number}.${ModiEntity.
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: Action;
Action: OakMakeAction<Action | string>;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;

View File

@ -1,17 +1,18 @@
import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, 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 * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
import { GenericAction } from "../../actions/action";
import * as Modi from "../Modi/Schema";
import * as User from "../User/Schema";
export declare type OpSchema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
modiId: ForeignKey<"modi">;
entity: String<32>;
entity: "user" | string;
entityId: String<64>;
};
export declare type OpAttr = keyof OpSchema;
@ -21,22 +22,23 @@ export declare type Schema = {
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
modiId: ForeignKey<"modi">;
entity: String<32>;
entity: "user" | string;
entityId: String<64>;
modi: Modi.Schema;
user?: User.Schema;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter = {
declare type AttrFilter<E> = {
id: Q_StringValue | SubQuery.ModiEntityIdSubQuery;
$$createAt$$: Q_DateValue;
$$updateAt$$: Q_DateValue;
modiId: Q_StringValue | SubQuery.ModiIdSubQuery;
modi: Modi.Filter;
entity: Q_StringValue;
entity: E;
entityId: Q_StringValue;
};
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr>>;
export declare type Filter<E = Q_EnumValue<"user" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
@ -47,7 +49,8 @@ export declare type Projection = {
modi?: Modi.Projection;
entity?: 1;
entityId?: 1;
} & Partial<ExprOp<OpAttr>>;
user?: User.Projection;
} & Partial<ExprOp<OpAttr | string>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
@ -58,13 +61,17 @@ export declare type ExportProjection = {
modi?: Modi.ExportProjection;
entity?: string;
entityId?: string;
} & Partial<ExprOp<OpAttr>>;
user?: User.ExportProjection;
} & Partial<ExprOp<OpAttr | string>>;
declare type ModiEntityIdProjection = OneOf<{
id: 1;
}>;
declare type ModiIdProjection = OneOf<{
modiId: 1;
}>;
declare type UserIdProjection = OneOf<{
entityId: 1;
}>;
export declare type SortAttr = {
id: 1;
} | {
@ -79,9 +86,11 @@ export declare type SortAttr = {
entity: 1;
} | {
entityId: 1;
} | {
user: User.SortAttr;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr>>;
} | OneOf<ExprOp<OpAttr | string>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
@ -90,43 +99,67 @@ export declare type Sorter = SortNode[];
export declare type SelectOperation<P = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "modiId" | "entity" | "entityId">> & (({
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "modiId" | "entityId" | "entity">> & (({
modiId?: never | null;
modi: Modi.CreateSingleOperation;
} | {
modiId: String<64>;
modi?: Modi.UpdateOperation;
})) & {
})) & ({
entity?: never;
entityId?: never;
user: User.CreateSingleOperation;
} | {
entity: "user";
entityId: String<64>;
user?: User.UpdateOperation;
} | {
[K: string]: any;
}) & {
[k: string]: any;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "modiId">> & (({
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "modiId" | "entityId" | "entity">> & (({
modi?: Modi.CreateSingleOperation | Modi.UpdateOperation | Modi.RemoveOperation;
modiId?: undefined;
} | {
modi?: undefined;
modiId?: String<64> | null;
})) & {
})) & ({
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
entityId?: undefined;
entity?: undefined;
} | {
entity?: ("user" | string) | null;
entityId?: String<64> | null;
}) & {
[k: string]: any;
};
export declare type UpdateOperation = OakOperation<"update", UpdateOperationData, Filter, Sorter>;
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & (({
modi?: Modi.UpdateOperation;
} | {
modi?: Modi.RemoveOperation;
}));
})) & ({
user?: User.UpdateOperation;
} | {
user?: User.RemoveOperation;
} | {
[k: string]: any;
});
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type ModiIdSubQuery = Selection<ModiIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type ModiEntityIdSubQuery = Selection<ModiEntityIdProjection>;
export declare type NativeAttr = OpAttr | `modi.${Modi.NativeAttr}`;
export declare type NativeAttr = OpAttr | `modi.${Modi.NativeAttr}` | `entity.${User.NativeAttr}`;
export declare type FullAttr = NativeAttr;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: GenericAction;
Action: OakMakeAction<GenericAction | string>;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;

View File

@ -1,159 +0,0 @@
import { String, Datetime, PrimaryKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { GenericAction } from "../../actions/action";
import * as Uupdate from "../Uupdate/Schema";
export declare type OpSchema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity?: ("uupdate" | string) | null;
entityId?: String<64> | null;
filter?: Object | null;
extra?: Object | null;
operatorId: String<32>;
operatorInfo?: Object | null;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity?: ("uupdate" | string) | null;
entityId?: String<64> | null;
filter?: Object | null;
extra?: Object | null;
operatorId: String<32>;
operatorInfo?: Object | null;
uupdate?: Uupdate.Schema;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter<E> = {
id: Q_StringValue | SubQuery.OoperationIdSubQuery;
$$createAt$$: Q_DateValue;
$$updateAt$$: Q_DateValue;
action: Q_StringValue;
entity: E;
entityId: Q_StringValue;
operatorId: Q_StringValue;
};
export declare type Filter<E = Q_EnumValue<"uupdate" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
id: 1;
$$createAt$$?: 1;
$$updateAt$$?: 1;
action?: 1;
data?: 1;
entity?: 1;
entityId?: 1;
filter?: 1;
extra?: 1;
operatorId?: 1;
operatorInfo?: 1;
uupdate?: Uupdate.Projection;
} & Partial<ExprOp<OpAttr>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
id?: string;
$$createAt$$?: string;
$$updateAt$$?: string;
action?: string;
data?: string;
entity?: string;
entityId?: string;
filter?: string;
extra?: string;
operatorId?: string;
operatorInfo?: string;
uupdate?: Uupdate.ExportProjection;
} & Partial<ExprOp<OpAttr>>;
declare type OoperationIdProjection = OneOf<{
id: 1;
}>;
declare type UupdateIdProjection = OneOf<{
entityId: 1;
}>;
export declare type SortAttr = OneOf<{
id: 1;
$$createAt$$: 1;
$$updateAt$$: 1;
action: 1;
entity: 1;
entityId: 1;
operatorId: 1;
uupdate: Uupdate.SortAttr;
[k: string]: any;
} & ExprOp<OpAttr>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export declare type Sorter = SortNode[];
export declare type SelectOperation<P = Projection> = OakOperation<"select", P, Filter, Sorter>;
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "entityId" | "entity" | "entityId">> & ({
entity?: never;
entityId?: never;
uupdate: Uupdate.CreateSingleOperation;
} | {
entity: "uupdate";
entityId: String<64>;
uupdate?: Uupdate.UpdateOperation;
} | {
[K: string]: any;
}) & {
[k: string]: any;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "entityId" | "entity" | "entityId">> & ({
uupdate?: Uupdate.CreateSingleOperation | Uupdate.UpdateOperation | Uupdate.RemoveOperation;
entityId?: undefined;
entity?: undefined;
} | {
entity?: ("uupdate" | string) | null;
entityId?: String<64> | null;
}) & {
[k: string]: any;
};
export declare type UpdateOperation = OakOperation<"update", UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & ({
uupdate?: Uupdate.UpdateOperation;
} | {
uupdate?: Uupdate.RemoveOperation;
} | {
[k: string]: any;
});
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type UupdateIdSubQuery = Selection<UupdateIdProjection>;
export declare type OoperationIdSubQuery = Selection<OoperationIdProjection>;
export declare type NativeAttr = OpAttr | `entity.${Uupdate.NativeAttr}`;
export declare type FullAttr = NativeAttr;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: GenericAction;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
};
export {};

View File

@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -1,3 +0,0 @@
import { StorageDesc } from "../../types/Storage";
import { OpSchema } from "./Schema";
export declare const desc: StorageDesc<OpSchema>;

View File

@ -1,43 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.desc = void 0;
exports.desc = {
attributes: {
action: {
type: "varchar",
params: {
length: 16
}
},
data: {
type: "object"
},
entity: {
type: "varchar",
params: {
length: 32
}
},
entityId: {
type: "varchar",
params: {
length: 64
}
},
filter: {
type: "object"
},
extra: {
type: "object"
},
operatorId: {
type: "varchar",
params: {
length: 32
}
},
operatorInfo: {
type: "object"
}
}
};

View File

@ -1,9 +1,10 @@
import { String, Datetime, PrimaryKey } from "../../types/DataType";
import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
import { GenericAction } from "../../actions/action";
import * as User from "../User/Schema";
import * as OperEntity from "../OperEntity/Schema";
export declare type OpSchema = {
id: PrimaryKey;
@ -14,6 +15,7 @@ export declare type OpSchema = {
data: Object;
filter?: Object | null;
extra?: Object | null;
operatorId?: ForeignKey<"user"> | null;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = {
@ -25,6 +27,8 @@ export declare type Schema = {
data: Object;
filter?: Object | null;
extra?: Object | null;
operatorId?: ForeignKey<"user"> | null;
operator?: User.Schema | null;
operEntity$oper?: Array<OperEntity.Schema>;
} & {
[A in ExpressionKey]?: any;
@ -34,8 +38,10 @@ declare type AttrFilter = {
$$createAt$$: Q_DateValue;
$$updateAt$$: Q_DateValue;
action: Q_StringValue;
operatorId: Q_StringValue | SubQuery.UserIdSubQuery;
operator: User.Filter;
};
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr>>;
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
@ -46,10 +52,12 @@ export declare type Projection = {
data?: 1;
filter?: 1;
extra?: 1;
operatorId?: 1;
operator?: User.Projection;
operEntity$oper?: OperEntity.Selection & {
$entity: "operEntity";
};
} & Partial<ExprOp<OpAttr>>;
} & Partial<ExprOp<OpAttr | string>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
@ -60,13 +68,18 @@ export declare type ExportProjection = {
data?: string;
filter?: string;
extra?: string;
operatorId?: string;
operator?: User.ExportProjection;
operEntity$oper?: OperEntity.Exportation & {
$entity: "operEntity";
};
} & Partial<ExprOp<OpAttr>>;
} & Partial<ExprOp<OpAttr | string>>;
declare type OperIdProjection = OneOf<{
id: 1;
}>;
declare type UserIdProjection = OneOf<{
operatorId: 1;
}>;
export declare type SortAttr = {
id: 1;
} | {
@ -75,9 +88,13 @@ export declare type SortAttr = {
$$updateAt$$: 1;
} | {
action: 1;
} | {
operatorId: 1;
} | {
operator: User.SortAttr;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr>>;
} | OneOf<ExprOp<OpAttr | string>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
@ -86,28 +103,45 @@ export declare type Sorter = SortNode[];
export declare type SelectOperation<P = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<OpSchema> & {
export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "operatorId">> & (({
operatorId?: never | null;
operator?: User.CreateSingleOperation;
} | {
operatorId?: String<64>;
operator?: User.UpdateOperation;
})) & {
[k: string]: any;
operEntity$oper?: OakOperation<"update", Omit<OperEntity.UpdateOperationData, "oper" | "operId">, OperEntity.Filter> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "oper" | "operId"> | Omit<OperEntity.CreateOperationData, "oper" | "operId">[]> | OakOperation<"update", Omit<OperEntity.UpdateOperationData, "oper" | "operId">, OperEntity.Filter>>;
operEntity$oper?: OakOperation<OperEntity.UpdateOperation["action"], Omit<OperEntity.UpdateOperationData, "oper" | "operId">, OperEntity.Filter> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "oper" | "operId"> | Omit<OperEntity.CreateOperationData, "oper" | "operId">[]> | OakOperation<OperEntity.UpdateOperation["action"], Omit<OperEntity.UpdateOperationData, "oper" | "operId">, OperEntity.Filter>>;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "operatorId">> & (({
operator?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
operatorId?: undefined;
} | {
operator?: undefined;
operatorId?: String<64> | null;
})) & {
[k: string]: any;
operEntitys$oper?: OperEntity.UpdateOperation | OperEntity.RemoveOperation | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "oper" | "operId"> | Omit<OperEntity.CreateOperationData, "oper" | "operId">[]> | OperEntity.UpdateOperation | OperEntity.RemoveOperation>;
};
export declare type UpdateOperation = OakOperation<"update", UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {};
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & (({
operator?: User.UpdateOperation;
} | {
operator?: User.RemoveOperation;
}));
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type OperIdSubQuery = Selection<OperIdProjection>;
export declare type NativeAttr = OpAttr;
export declare type NativeAttr = OpAttr | `operator.${User.NativeAttr}`;
export declare type FullAttr = NativeAttr | `operEntitys$${number}.${OperEntity.NativeAttr}`;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: GenericAction;
Action: OakMakeAction<GenericAction | string>;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;

View File

@ -17,6 +17,10 @@ exports.desc = {
},
extra: {
type: "object"
},
operatorId: {
type: "ref",
ref: "user"
}
}
};

View File

@ -2,17 +2,18 @@ import { String, Datetime, PrimaryKey, ForeignKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
import { GenericAction } from "../../actions/action";
import * as Oper from "../Oper/Schema";
import * as Modi from "../Modi/Schema";
import * as User from "../User/Schema";
export declare type OpSchema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
operId: ForeignKey<"oper">;
entity: "modi" | string;
entity: "modi" | "user" | string;
entityId: String<64>;
};
export declare type OpAttr = keyof OpSchema;
@ -22,10 +23,11 @@ export declare type Schema = {
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
operId: ForeignKey<"oper">;
entity: "modi" | string;
entity: "modi" | "user" | string;
entityId: String<64>;
oper: Oper.Schema;
modi?: Modi.Schema;
user?: User.Schema;
} & {
[A in ExpressionKey]?: any;
};
@ -38,7 +40,7 @@ declare type AttrFilter<E> = {
entity: E;
entityId: Q_StringValue;
};
export declare type Filter<E = Q_EnumValue<"modi" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr>>;
export declare type Filter<E = Q_EnumValue<"modi" | "user" | string>> = MakeFilter<AttrFilter<E> & ExprOp<OpAttr | string>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
@ -50,7 +52,8 @@ export declare type Projection = {
entity?: 1;
entityId?: 1;
modi?: Modi.Projection;
} & Partial<ExprOp<OpAttr>>;
user?: User.Projection;
} & Partial<ExprOp<OpAttr | string>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
@ -62,7 +65,8 @@ export declare type ExportProjection = {
entity?: string;
entityId?: string;
modi?: Modi.ExportProjection;
} & Partial<ExprOp<OpAttr>>;
user?: User.ExportProjection;
} & Partial<ExprOp<OpAttr | string>>;
declare type OperEntityIdProjection = OneOf<{
id: 1;
}>;
@ -72,6 +76,9 @@ declare type OperIdProjection = OneOf<{
declare type ModiIdProjection = OneOf<{
entityId: 1;
}>;
declare type UserIdProjection = OneOf<{
entityId: 1;
}>;
export declare type SortAttr = {
id: 1;
} | {
@ -88,9 +95,11 @@ export declare type SortAttr = {
entityId: 1;
} | {
modi: Modi.SortAttr;
} | {
user: User.SortAttr;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr>>;
} | OneOf<ExprOp<OpAttr | string>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
@ -113,6 +122,14 @@ export declare type CreateOperationData = FormCreateData<Omit<OpSchema, "operId"
entity: "modi";
entityId: String<64>;
modi?: Modi.UpdateOperation;
} | {
entity?: never;
entityId?: never;
user: User.CreateSingleOperation;
} | {
entity: "user";
entityId: String<64>;
user?: User.UpdateOperation;
} | {
[K: string]: any;
}) & {
@ -132,12 +149,16 @@ export declare type UpdateOperationData = FormUpdateData<Omit<OpSchema, "operId"
entityId?: undefined;
entity?: undefined;
} | {
entity?: ("modi" | string) | null;
user?: User.CreateSingleOperation | User.UpdateOperation | User.RemoveOperation;
entityId?: undefined;
entity?: undefined;
} | {
entity?: ("modi" | "user" | string) | null;
entityId?: String<64> | null;
}) & {
[k: string]: any;
};
export declare type UpdateOperation = OakOperation<"update", UpdateOperationData, Filter, Sorter>;
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {} & (({
oper?: Oper.UpdateOperation;
} | {
@ -146,6 +167,10 @@ export declare type RemoveOperationData = {} & (({
modi?: Modi.UpdateOperation;
} | {
modi?: Modi.RemoveOperation;
} | {
user?: User.UpdateOperation;
} | {
user?: User.RemoveOperation;
} | {
[k: string]: any;
});
@ -153,13 +178,14 @@ export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type OperIdSubQuery = Selection<OperIdProjection>;
export declare type ModiIdSubQuery = Selection<ModiIdProjection>;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type OperEntityIdSubQuery = Selection<OperEntityIdProjection>;
export declare type NativeAttr = OpAttr | `oper.${Oper.NativeAttr}` | `entity.${Modi.NativeAttr}`;
export declare type NativeAttr = OpAttr | `oper.${Oper.NativeAttr}` | `entity.${Modi.NativeAttr}` | `entity.${User.NativeAttr}`;
export declare type FullAttr = NativeAttr;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: GenericAction;
Action: OakMakeAction<GenericAction | string>;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;

View File

@ -5,9 +5,11 @@ var Storage_1 = require("./Modi/Storage");
var Storage_2 = require("./ModiEntity/Storage");
var Storage_3 = require("./Oper/Storage");
var Storage_4 = require("./OperEntity/Storage");
var Storage_5 = require("./User/Storage");
exports.storageSchema = {
modi: Storage_1.desc,
modiEntity: Storage_2.desc,
oper: Storage_3.desc,
operEntity: Storage_4.desc
operEntity: Storage_4.desc,
user: Storage_5.desc
};

View File

@ -1,9 +0,0 @@
import { ActionDef } from "../../types/Action";
import { GenericAction } from "../../actions/action";
export declare type IState = 'active' | 'applied' | 'abandoned';
export declare type IAction = 'apply' | 'abandon';
export declare type ParticularAction = IAction;
export declare type Action = GenericAction | ParticularAction;
export declare const ActionDefDict: {
iState: ActionDef<IAction, IState>;
};

View File

@ -1,13 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionDefDict = void 0;
var IActionDef = {
stm: {
apply: ['active', 'applied'],
abandon: ['active', 'abandoned']
},
is: 'active'
};
exports.ActionDefDict = {
iState: IActionDef
};

View File

@ -1,129 +0,0 @@
import { String, Datetime, PrimaryKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { Action, ParticularAction, IState } from "./Action";
export declare type OpSchema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity: String<32>;
entityId: String<64>;
extra?: Object | null;
operatorId: String<32>;
operatorInfo?: Object | null;
iState?: IState | null;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity: String<32>;
entityId: String<64>;
extra?: Object | null;
operatorId: String<32>;
operatorInfo?: Object | null;
iState?: IState | null;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter = {
id: Q_StringValue | SubQuery.UpdateIdSubQuery;
$$createAt$$: Q_DateValue;
$$updateAt$$: Q_DateValue;
action: Q_StringValue;
entity: Q_StringValue;
entityId: Q_StringValue;
operatorId: Q_StringValue;
iState: Q_EnumValue<IState>;
};
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
id: 1;
$$createAt$$?: 1;
$$updateAt$$?: 1;
action?: 1;
data?: 1;
entity?: 1;
entityId?: 1;
extra?: 1;
operatorId?: 1;
operatorInfo?: 1;
iState?: 1;
} & Partial<ExprOp<OpAttr>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
id?: string;
$$createAt$$?: string;
$$updateAt$$?: string;
action?: string;
data?: string;
entity?: string;
entityId?: string;
extra?: string;
operatorId?: string;
operatorInfo?: string;
iState?: string;
} & Partial<ExprOp<OpAttr>>;
declare type UpdateIdProjection = OneOf<{
id: 1;
}>;
export declare type SortAttr = OneOf<{
id: 1;
$$createAt$$: 1;
$$updateAt$$: 1;
action: 1;
entity: 1;
entityId: 1;
operatorId: 1;
iState: 1;
} & ExprOp<OpAttr>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export declare type Sorter = SortNode[];
export declare type SelectOperation<P = Projection> = OakOperation<"select", P, Filter, Sorter>;
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<OpSchema> & {
[k: string]: any;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
[k: string]: any;
};
export declare type UpdateOperation = OakOperation<ParticularAction | "update", UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {};
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type UpdateIdSubQuery = Selection<UpdateIdProjection>;
export declare type NativeAttr = OpAttr;
export declare type FullAttr = NativeAttr;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: Action;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
ParticularAction: ParticularAction;
};
export {};

View File

@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -1,3 +0,0 @@
import { StorageDesc } from "../../types/Storage";
import { OpSchema } from "./Schema";
export declare const desc: StorageDesc<OpSchema>;

View File

@ -1,48 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.desc = void 0;
exports.desc = {
attributes: {
action: {
type: "varchar",
params: {
length: 16
}
},
data: {
type: "object"
},
entity: {
type: "varchar",
params: {
length: 32
}
},
entityId: {
type: "varchar",
params: {
length: 64
}
},
extra: {
type: "object"
},
iState: {
type: "varchar",
params: {
length: 16
}
}
},
indexes: [
{
name: 'index_state',
attributes: [
{
name: 'iState',
direction: 'ASC'
}
]
}
]
};

141
lib/base-app-domain/User/Schema.d.ts vendored Normal file
View File

@ -0,0 +1,141 @@
import { String, Text, Datetime, PrimaryKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation, MakeAction as OakMakeAction } from "../../types/Entity";
import { GenericAction } from "../../actions/action";
import * as Oper from "../Oper/Schema";
import * as OperEntity from "../OperEntity/Schema";
import * as ModiEntity from "../ModiEntity/Schema";
export declare type OpSchema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
name?: String<16> | null;
nickname?: String<64> | null;
password?: Text | null;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
name?: String<16> | null;
nickname?: String<64> | null;
password?: Text | null;
oper$operator?: Array<Oper.Schema>;
operEntity$entity?: Array<OperEntity.Schema>;
modiEntity$entity?: Array<ModiEntity.Schema>;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter = {
id: Q_StringValue | SubQuery.UserIdSubQuery;
$$createAt$$: Q_DateValue;
$$updateAt$$: Q_DateValue;
name: Q_StringValue;
nickname: Q_StringValue;
password: Q_StringValue;
};
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr | string>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
id: 1;
$$createAt$$?: 1;
$$updateAt$$?: 1;
name?: 1;
nickname?: 1;
password?: 1;
oper$operator?: Oper.Selection & {
$entity: "oper";
};
operEntity$entity?: OperEntity.Selection & {
$entity: "operEntity";
};
modiEntity$entity?: ModiEntity.Selection & {
$entity: "modiEntity";
};
} & Partial<ExprOp<OpAttr | string>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
id?: string;
$$createAt$$?: string;
$$updateAt$$?: string;
name?: string;
nickname?: string;
password?: string;
oper$operator?: Oper.Exportation & {
$entity: "oper";
};
operEntity$entity?: OperEntity.Exportation & {
$entity: "operEntity";
};
modiEntity$entity?: ModiEntity.Exportation & {
$entity: "modiEntity";
};
} & Partial<ExprOp<OpAttr | string>>;
declare type UserIdProjection = OneOf<{
id: 1;
}>;
export declare type SortAttr = {
id: 1;
} | {
$$createAt$$: 1;
} | {
$$updateAt$$: 1;
} | {
name: 1;
} | {
nickname: 1;
} | {
password: 1;
} | {
[k: string]: any;
} | OneOf<ExprOp<OpAttr | string>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export declare type Sorter = SortNode[];
export declare type SelectOperation<P = Projection> = Omit<OakOperation<"select", P, Filter, Sorter>, "id">;
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<OpSchema> & {
[k: string]: any;
oper$operator?: OakOperation<Oper.UpdateOperation["action"], Omit<Oper.UpdateOperationData, "operator" | "operatorId">, Oper.Filter> | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId"> | Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | OakOperation<Oper.UpdateOperation["action"], Omit<Oper.UpdateOperationData, "operator" | "operatorId">, Oper.Filter>>;
operEntity$entity?: OakOperation<OperEntity.UpdateOperation["action"], Omit<OperEntity.UpdateOperationData, "entity" | "entityId">, OperEntity.Filter> | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId"> | Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | OakOperation<OperEntity.UpdateOperation["action"], Omit<OperEntity.UpdateOperationData, "entity" | "entityId">, OperEntity.Filter>>;
modiEntity$entity?: OakOperation<ModiEntity.UpdateOperation["action"], Omit<ModiEntity.UpdateOperationData, "entity" | "entityId">, ModiEntity.Filter> | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId"> | Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | OakOperation<ModiEntity.UpdateOperation["action"], Omit<ModiEntity.UpdateOperationData, "entity" | "entityId">, ModiEntity.Filter>>;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
[k: string]: any;
opers$operator?: Oper.UpdateOperation | Oper.RemoveOperation | Array<OakOperation<"create", Omit<Oper.CreateOperationData, "operator" | "operatorId"> | Omit<Oper.CreateOperationData, "operator" | "operatorId">[]> | Oper.UpdateOperation | Oper.RemoveOperation>;
operEntitys$entity?: OperEntity.UpdateOperation | OperEntity.RemoveOperation | Array<OakOperation<"create", Omit<OperEntity.CreateOperationData, "entity" | "entityId"> | Omit<OperEntity.CreateOperationData, "entity" | "entityId">[]> | OperEntity.UpdateOperation | OperEntity.RemoveOperation>;
modiEntitys$entity?: ModiEntity.UpdateOperation | ModiEntity.RemoveOperation | Array<OakOperation<"create", Omit<ModiEntity.CreateOperationData, "entity" | "entityId"> | Omit<ModiEntity.CreateOperationData, "entity" | "entityId">[]> | ModiEntity.UpdateOperation | ModiEntity.RemoveOperation>;
};
export declare type UpdateOperation = OakOperation<"update" | string, UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {};
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type UserIdSubQuery = Selection<UserIdProjection>;
export declare type NativeAttr = OpAttr;
export declare type FullAttr = NativeAttr | `opers$${number}.${Oper.NativeAttr}` | `operEntitys$${number}.${OperEntity.NativeAttr}` | `modiEntitys$${number}.${ModiEntity.NativeAttr}`;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: OakMakeAction<GenericAction | string>;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
};
export {};

View File

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.desc = void 0;
exports.desc = {
attributes: {
name: {
type: "varchar",
params: {
length: 16
}
},
nickname: {
type: "varchar",
params: {
length: 64
}
},
password: {
type: "text"
}
}
};

View File

@ -1,9 +0,0 @@
import { ActionDef } from "../../types/Action";
import { GenericAction } from "../../actions/action";
export declare type IState = 'active' | 'applied' | 'abandoned';
export declare type IAction = 'apply' | 'abandon';
export declare type ParticularAction = IAction;
export declare type Action = GenericAction | ParticularAction;
export declare const ActionDefDict: {
iState: ActionDef<IAction, IState>;
};

View File

@ -1,13 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionDefDict = void 0;
var IActionDef = {
stm: {
apply: ['active', 'applied'],
abandon: ['active', 'abandoned']
},
is: 'active'
};
exports.ActionDefDict = {
iState: IActionDef
};

View File

@ -1,129 +0,0 @@
import { String, Datetime, PrimaryKey } from "../../types/DataType";
import { Q_DateValue, Q_StringValue, Q_EnumValue, NodeId, MakeFilter, ExprOp, ExpressionKey } from "../../types/Demand";
import { OneOf } from "../../types/Polyfill";
import * as SubQuery from "../_SubQuery";
import { FormCreateData, FormUpdateData, Operation as OakOperation } from "../../types/Entity";
import { Action, ParticularAction, IState } from "./Action";
import * as Ooperation from "../Ooperation/Schema";
export declare type OpSchema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity: String<32>;
entityId: String<64>;
extra?: Object | null;
iState?: IState | null;
};
export declare type OpAttr = keyof OpSchema;
export declare type Schema = {
id: PrimaryKey;
$$createAt$$: Datetime;
$$updateAt$$: Datetime;
$$deleteAt$$?: Datetime | null;
action: String<16>;
data: Object;
entity: String<32>;
entityId: String<64>;
extra?: Object | null;
iState?: IState | null;
ooperation$entity?: Array<Ooperation.Schema>;
} & {
[A in ExpressionKey]?: any;
};
declare type AttrFilter = {
id: Q_StringValue | SubQuery.UupdateIdSubQuery;
$$createAt$$: Q_DateValue;
$$updateAt$$: Q_DateValue;
action: Q_StringValue;
entity: Q_StringValue;
entityId: Q_StringValue;
iState: Q_EnumValue<IState>;
};
export declare type Filter = MakeFilter<AttrFilter & ExprOp<OpAttr>>;
export declare type Projection = {
"#id"?: NodeId;
[k: string]: any;
id: 1;
$$createAt$$?: 1;
$$updateAt$$?: 1;
action?: 1;
data?: 1;
entity?: 1;
entityId?: 1;
extra?: 1;
iState?: 1;
ooperation$entity?: Ooperation.Selection & {
$entity: "ooperation";
};
} & Partial<ExprOp<OpAttr>>;
export declare type ExportProjection = {
"#id"?: NodeId;
[k: string]: any;
id?: string;
$$createAt$$?: string;
$$updateAt$$?: string;
action?: string;
data?: string;
entity?: string;
entityId?: string;
extra?: string;
iState?: string;
ooperation$entity?: Ooperation.Exportation & {
$entity: "ooperation";
};
} & Partial<ExprOp<OpAttr>>;
declare type UupdateIdProjection = OneOf<{
id: 1;
}>;
export declare type SortAttr = OneOf<{
id: 1;
$$createAt$$: 1;
$$updateAt$$: 1;
action: 1;
entity: 1;
entityId: 1;
iState: 1;
} & ExprOp<OpAttr>>;
export declare type SortNode = {
$attr: SortAttr;
$direction?: "asc" | "desc";
};
export declare type Sorter = SortNode[];
export declare type SelectOperation<P = Projection> = OakOperation<"select", P, Filter, Sorter>;
export declare type Selection<P = Projection> = Omit<SelectOperation<P>, "action">;
export declare type Exportation = OakOperation<"export", ExportProjection, Filter, Sorter>;
export declare type CreateOperationData = FormCreateData<OpSchema> & {
[k: string]: any;
ooperation$entity?: OakOperation<"update", Omit<Ooperation.UpdateOperationData, "entity" | "entityId">, Ooperation.Filter> | Array<OakOperation<"create", Omit<Ooperation.CreateOperationData, "entity" | "entityId"> | Omit<Ooperation.CreateOperationData, "entity" | "entityId">[]> | OakOperation<"update", Omit<Ooperation.UpdateOperationData, "entity" | "entityId">, Ooperation.Filter>>;
};
export declare type CreateSingleOperation = OakOperation<"create", CreateOperationData>;
export declare type CreateMultipleOperation = OakOperation<"create", Array<CreateOperationData>>;
export declare type CreateOperation = CreateSingleOperation | CreateMultipleOperation;
export declare type UpdateOperationData = FormUpdateData<OpSchema> & {
[k: string]: any;
ooperations$entity?: Ooperation.UpdateOperation | Ooperation.RemoveOperation | Array<OakOperation<"create", Omit<Ooperation.CreateOperationData, "entity" | "entityId"> | Omit<Ooperation.CreateOperationData, "entity" | "entityId">[]> | Ooperation.UpdateOperation | Ooperation.RemoveOperation>;
};
export declare type UpdateOperation = OakOperation<ParticularAction | "update", UpdateOperationData, Filter, Sorter>;
export declare type RemoveOperationData = {};
export declare type RemoveOperation = OakOperation<"remove", RemoveOperationData, Filter, Sorter>;
export declare type Operation = CreateOperation | UpdateOperation | RemoveOperation | SelectOperation;
export declare type UupdateIdSubQuery = Selection<UupdateIdProjection>;
export declare type NativeAttr = OpAttr;
export declare type FullAttr = NativeAttr | `ooperations$${number}.${Ooperation.NativeAttr}`;
export declare type EntityDef = {
Schema: Schema;
OpSchema: OpSchema;
Action: Action;
Selection: Selection;
Operation: Operation;
Create: CreateOperation;
Update: UpdateOperation;
Remove: RemoveOperation;
CreateSingle: CreateSingleOperation;
CreateMulti: CreateMultipleOperation;
ParticularAction: ParticularAction;
};
export {};

View File

@ -1,2 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });

View File

@ -1,3 +0,0 @@
import { StorageDesc } from "../../types/Storage";
import { OpSchema } from "./Schema";
export declare const desc: StorageDesc<OpSchema>;

View File

@ -1,48 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.desc = void 0;
exports.desc = {
attributes: {
action: {
type: "varchar",
params: {
length: 16
}
},
data: {
type: "object"
},
entity: {
type: "varchar",
params: {
length: 32
}
},
entityId: {
type: "varchar",
params: {
length: 64
}
},
extra: {
type: "object"
},
iState: {
type: "varchar",
params: {
length: 16
}
}
},
indexes: [
{
name: 'index_state',
attributes: [
{
name: 'iState',
direction: 'ASC'
}
]
}
]
};

View File

@ -2,6 +2,7 @@ import * as Modi from "./Modi/Schema";
import * as ModiEntity from "./ModiEntity/Schema";
import * as Oper from "./Oper/Schema";
import * as OperEntity from "./OperEntity/Schema";
import * as User from "./User/Schema";
export declare type ModiIdSubQuery = {
[K in "$in" | "$nin"]?: (ModiEntity.ModiIdSubQuery & {
entity: "modiEntity";
@ -26,3 +27,10 @@ export declare type OperEntityIdSubQuery = {
entity: "operEntity";
}) | any;
};
export declare type UserIdSubQuery = {
[K in "$in" | "$nin"]?: (Oper.UserIdSubQuery & {
entity: "oper";
}) | (User.UserIdSubQuery & {
entity: "user";
}) | any;
};

View File

@ -233,6 +233,7 @@ function dealWithActions(moduleName, filename, node, program) {
actionTexts.forEach(function (action) {
var _a;
(0, assert_1.default)(action.length <= env_1.STRING_LITERAL_MAX_LENGTH, "".concat(filename, "\u4E2D\u7684Action\u300C").concat(action, "\u300D\u547D\u540D\u957F\u5EA6\u5927\u4E8E").concat(env_1.STRING_LITERAL_MAX_LENGTH));
(0, assert_1.default)(/^[a-z][a-z|A-Z]+$/.test(action), "".concat(filename, "\u4E2D\u7684Action\u300C").concat(action, "\u300D\u547D\u540D\u4E0D\u5408\u6CD5\uFF0C\u5FC5\u987B\u4EE5\u5C0F\u5B57\u5B57\u6BCD\u5F00\u5934\u4E14\u53EA\u80FD\u5305\u542B\u5B57\u6BCD"));
if (ActionDict.hasOwnProperty(action)) {
throw new Error("\u6587\u4EF6".concat(filename, "\u4E2D\uFF0CAction\u5B9A\u4E49\u4E0A\u7684\u3010").concat(action, "\u3011\u52A8\u4F5C\u5B58\u5728\u540C\u540D"));
}
@ -298,7 +299,9 @@ function analyzeEntity(filename, path, program) {
var sourceFile = program.getSourceFile(fullPath);
var moduleName = filename.split('.')[0];
if (Schema.hasOwnProperty(moduleName)) {
throw new Error("\u51FA\u73B0\u4E86\u540C\u540D\u7684Entity\u5B9A\u4E49\u300C".concat(moduleName, "\u300D\uFF0C\u8BF7\u6CE8\u610F\u4E0D\u8981\u548C\u7CFB\u7EDF\u4FDD\u7559\u7684Entity\u91CD\u540D\u3002"));
if (!path.includes('oak-general-business')) {
console.log("\u51FA\u73B0\u4E86\u540C\u540D\u7684Entity\u5B9A\u4E49\u300C".concat(moduleName, "\u300D\uFF0C\u5C06\u4F7F\u7528\u60A8\u6240\u5B9A\u4E49\u7684\u5BF9\u8C61\u7ED3\u6784\u53D6\u4EE3\u6389\u9ED8\u8BA4\u5BF9\u8C61\uFF0C\u8BF7\u786E\u8BA4"));
}
}
var referencedSchemas = [];
var schemaAttrs = [];
@ -416,7 +419,7 @@ function analyzeEntity(filename, path, program) {
beforeSchema = false;
// 对于不是Oper的对象全部建立和Oper的反指关系
if (!['Oper', 'OperEntity', 'ModiEntity'].includes(moduleName)) {
if (ReversePointerRelations['OperEntity']) {
if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) {
ReversePointerRelations['OperEntity'].push(moduleName);
}
else {
@ -426,7 +429,7 @@ function analyzeEntity(filename, path, program) {
}
// 对于不是Modi的对象全部建立和Modi的反指关系
if (!['Modi'].includes(moduleName)) {
if (ReversePointerRelations['ModiEntity']) {
if (ReversePointerRelations['ModiEntity'] && !ReversePointerRelations['ModiEntity'].includes(moduleName)) {
ReversePointerRelations['ModiEntity'].push(moduleName);
}
else {
@ -456,7 +459,7 @@ function analyzeEntity(filename, path, program) {
dealWithActions(moduleName, filename, node.type, program);
}
else if (node.name.text === 'Relation') {
(0, assert_1.default)(!localeDef, "\u3010".concat(filename, "\u3011locale\u5B9A\u4E49\u987B\u5728Action\u4E4B\u540E"));
(0, assert_1.default)(!localeDef, "\u3010".concat(filename, "\u3011locale\u5B9A\u4E49\u987B\u5728Relation\u4E4B\u540E"));
// 增加userXXX对象的描述
if (ts.isLiteralTypeNode(node.type)) {
(0, assert_1.default)(ts.isStringLiteral(node.type.literal));
@ -896,49 +899,6 @@ function constructSchema(statements, entity) {
if (SchemaAsts[entity]) {
statements.push.apply(statements, tslib_1.__spreadArray([], tslib_1.__read(SchemaAsts[entity].statements), false));
}
// if (keys(foreignKeySet).length > 0) {
// for (const fkItem in foreignKeySet) {
// const entityLc = fkItem.slice(0, 1).toLowerCase().concat(fkItem.slice(1));
// const foreignKeys = [];
// /* statements.push(
// factory.createTypeAliasDeclaration(
// undefined,
// undefined,
// factory.createIdentifier(`${fkItem}s`),
// undefined,
// factory.createTemplateLiteralType(
// factory.createTemplateHead(
// `${entityLc}s$`,
// `${entityLc}s$`
// ),
// [factory.createTemplateLiteralTypeSpan(
// factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
// factory.createTemplateTail(
// "",
// ""
// )
// )]
// )
// )
// ); */
// for (let iter = 1; iter < 11; iter++) {
// foreignKeys.push(`${entityLc}s$${iter}`);
// }
// statements.push(
// factory.createTypeAliasDeclaration(
// undefined,
// undefined,
// factory.createIdentifier(`${fkItem}s`),
// undefined,
// factory.createUnionTypeNode(
// foreignKeys.map(
// ele => factory.createLiteralTypeNode(factory.createStringLiteral(ele))
// )
// )
// )
// );
// }
// }
statements.push(factory.createTypeAliasDeclaration(undefined, [
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))));
@ -1081,7 +1041,12 @@ function constructFilter(statements, entity) {
var types = [
factory.createTypeReferenceNode(factory.createIdentifier("AttrFilter"), ReversePointerRelations[entity] ? [factory.createTypeReferenceNode('E')] : undefined),
factory.createTypeReferenceNode(factory.createIdentifier("ExprOp"), [
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr'))
process.env.COMPLING_AS_LIB ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr')),
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
]) :
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr'))
]),
];
// 如果还有其它类型的查询如全文则加在types数组中
@ -1253,7 +1218,12 @@ function constructProjection(statements, entity) {
}
var exprNode = factory.createTypeReferenceNode(factory.createIdentifier("Partial"), [
factory.createTypeReferenceNode(factory.createIdentifier("ExprOp"), [
factory.createTypeReferenceNode(factory.createIdentifier("OpAttr"), undefined)
process.env.COMPLING_AS_LIB ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr')),
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
]) :
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr'))
])
]);
var MetaPropertySignaturs = [
@ -1499,7 +1469,14 @@ function constructSorter(statements, entity) {
if (process.env.COMPLING_AS_LIB) {
members.push(factory.createTypeLiteralNode([factory.createIndexSignature(undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, factory.createIdentifier("k"), undefined, factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword), undefined)], factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword))]));
}
members.push(factory.createTypeReferenceNode(factory.createIdentifier("OneOf"), [factory.createTypeReferenceNode(factory.createIdentifier("ExprOp"), [factory.createTypeReferenceNode(factory.createIdentifier("OpAttr"), undefined)])]));
members.push(factory.createTypeReferenceNode(factory.createIdentifier("OneOf"), [factory.createTypeReferenceNode(factory.createIdentifier("ExprOp"), [
process.env.COMPLING_AS_LIB ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr')),
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
]) :
factory.createTypeReferenceNode(factory.createIdentifier('OpAttr'))
])]));
/**
*
export type SortAttr = {
@ -1811,7 +1788,7 @@ function constructActions(statements, entity) {
])
]);
var otmUpdateOperationNode = factory.createTypeReferenceNode(factory.createIdentifier("OakOperation"), [
factory.createLiteralTypeNode(factory.createStringLiteral("update")),
factory.createIndexedAccessTypeNode(factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'UpdateOperation'), undefined), factory.createLiteralTypeNode(factory.createStringLiteral("action"))),
factory.createTypeReferenceNode(factory.createIdentifier("Omit"), [
factory.createTypeReferenceNode(createForeignRef(entity, entityName, 'UpdateOperationData'), undefined),
factory.createUnionTypeNode(foreignKey === 'entity' ? [
@ -2014,13 +1991,17 @@ function constructActions(statements, entity) {
}
statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("UpdateOperationData"), undefined, factory.createIntersectionTypeNode(adNodes)));
// UpdateOperation
var actionTypeNodes = ActionAsts[entity] ? [
factory.createTypeReferenceNode('ParticularAction'),
factory.createLiteralTypeNode(factory.createStringLiteral("update"))
] : [
factory.createLiteralTypeNode(factory.createStringLiteral("update"))
];
if (process.env.COMPLING_AS_LIB) {
actionTypeNodes.push(factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
}
statements.push(factory.createTypeAliasDeclaration(undefined, [factory.createModifier(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("UpdateOperation"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("OakOperation"), [
ActionAsts[entity] ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode('ParticularAction'),
factory.createLiteralTypeNode(factory.createStringLiteral("update"))
]) :
factory.createLiteralTypeNode(factory.createStringLiteral("update")),
factory.createUnionTypeNode(actionTypeNodes),
factory.createTypeReferenceNode(factory.createIdentifier("UpdateOperationData")),
factory.createTypeReferenceNode(factory.createIdentifier("Filter"), undefined),
factory.createTypeReferenceNode(factory.createIdentifier("Sorter"), undefined)
@ -2221,7 +2202,8 @@ var initialStatements = function () { return [
factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
factory.createImportSpecifier(false, undefined, factory.createIdentifier("FormCreateData")),
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.createStringLiteral("".concat((0, env_1.TYPE_PATH_IN_OAK_DOMAIN)(), "Entity")), undefined)
]; };
function outputSubQuery(outputDir, printer) {
@ -2323,10 +2305,16 @@ function outputSchema(outputDir, printer) {
constructActions(statements, entity);
constructQuery(statements, entity);
constructFullAttrs(statements, entity);
var actionTypeNodes = ActionAsts[entity] ? [factory.createTypeReferenceNode('Action')] : [factory.createTypeReferenceNode('GenericAction')];
if (process.env.COMPLING_AS_LIB) {
actionTypeNodes.push(factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword));
}
var EntityDefAttrs = [
factory.createPropertySignature(undefined, factory.createIdentifier("Schema"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Schema"), undefined)),
factory.createPropertySignature(undefined, factory.createIdentifier("OpSchema"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("OpSchema"), undefined)),
factory.createPropertySignature(undefined, factory.createIdentifier("Action"), undefined, factory.createTypeReferenceNode(factory.createIdentifier(ActionAsts[entity] ? 'Action' : 'GenericAction'), undefined)),
factory.createPropertySignature(undefined, factory.createIdentifier("Action"), undefined, factory.createTypeReferenceNode(factory.createIdentifier('OakMakeAction'), [
factory.createUnionTypeNode(actionTypeNodes)
])),
factory.createPropertySignature(undefined, factory.createIdentifier("Selection"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Selection"), undefined)),
factory.createPropertySignature(undefined, factory.createIdentifier("Operation"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("Operation"), undefined)),
factory.createPropertySignature(undefined, factory.createIdentifier("Create"), undefined, factory.createTypeReferenceNode(factory.createIdentifier("CreateOperation"), undefined)),

View File

@ -1,8 +1,10 @@
import { String } from '../types/DataType';
import { EntityShape } from '../types/Entity';
import { Schema as User } from './User';
export interface Schema extends EntityShape {
action: String<16>;
data: Object;
filter?: Object;
extra?: Object;
operator?: User;
}

View File

@ -8,6 +8,7 @@ var locale = {
data: '数据',
filter: '选择条件',
extra: '其它',
operator: '操作者',
},
},
};

7
lib/entities/User.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import { String, Text } from '../types/DataType';
import { EntityShape } from '../types/Entity';
export interface Schema extends EntityShape {
name?: String<16>;
nickname?: String<64>;
password?: Text;
}

12
lib/entities/User.js Normal file
View File

@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
;
var locale = {
zh_CN: {
attr: {
name: '姓名',
nickname: '昵称',
password: '密码',
},
},
};

View File

@ -23,4 +23,5 @@ export declare abstract class UniversalContext<ED extends EntityDict> implements
rollback(): Promise<void>;
getCurrentTxnId(): string | undefined;
abstract toString(): Promise<string>;
abstract getCurrentUserId(): Promise<string | undefined>;
}

6
lib/store/action.d.ts vendored Normal file
View File

@ -0,0 +1,6 @@
/**
* action是不是延时性操作
* @param action
* @returns
*/
export declare function isLaterAction(action: string): string | undefined;

14
lib/store/action.js Normal file
View File

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLaterAction = void 0;
/**
* 判断一个action是不是延时性操作如果是则返回动作本身
* @param action
* @returns
*/
function isLaterAction(action) {
if (action.endsWith('-l')) {
return action.slice(0, action.length - 2);
}
}
exports.isLaterAction = isLaterAction;

View File

@ -11,4 +11,5 @@ export interface Context<ED extends EntityDict> {
toString(): Promise<string>;
getScene(): string | undefined;
setScene(scene?: string): void;
getCurrentUserId(): Promise<string | undefined>;
}

View File

@ -21,6 +21,7 @@ export declare type SelectOption = {
};
export declare type OperateOption = {
dontCollect?: boolean;
parentModiId?: string;
dummy?: 1;
};
export declare type FormUpdateData<SH extends GeneralEntityShape> = Partial<{
@ -48,6 +49,7 @@ export interface FileCarrierEntityShape extends EntityShape {
interface GeneralEntityShape extends EntityShape {
[K: string]: any;
}
export declare type MakeAction<A extends string> = A | `${A}-l`;
export interface EntityDef {
Schema: GeneralEntityShape;
OpSchema: GeneralEntityShape;

View File

@ -36,6 +36,12 @@ export declare class OakInputIllegalException extends OakUserException {
*/
export declare class OakUserUnpermittedException extends OakUserException {
}
/**
*
*/
export declare class OakUnloggedInException extends OakUserException {
constructor(message?: string);
}
/**
*
*/

View File

@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeException = exports.OakCongruentRowExists = exports.OakUserUnpermittedException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakOperExistedException = exports.OakDataException = exports.OakException = void 0;
exports.makeException = exports.OakCongruentRowExists = exports.OakUnloggedInException = exports.OakUserUnpermittedException = exports.OakInputIllegalException = exports.OakRowInconsistencyException = exports.OakUserException = exports.OakExternalException = exports.OakOperExistedException = exports.OakDataException = exports.OakException = void 0;
var tslib_1 = require("tslib");
var OakException = /** @class */ (function (_super) {
tslib_1.__extends(OakException, _super);
@ -126,6 +126,18 @@ var OakUserUnpermittedException = /** @class */ (function (_super) {
}(OakUserException));
exports.OakUserUnpermittedException = OakUserUnpermittedException;
;
/**
* 用户未登录抛的异常
*/
var OakUnloggedInException = /** @class */ (function (_super) {
tslib_1.__extends(OakUnloggedInException, _super);
function OakUnloggedInException(message) {
return _super.call(this, message || '您尚未登录') || this;
}
return OakUnloggedInException;
}(OakUserException));
exports.OakUnloggedInException = OakUnloggedInException;
;
/**
* 要插入行时发现已经有相同的行数据
*/
@ -170,6 +182,9 @@ function makeException(data) {
case OakUserUnpermittedException.name: {
return new OakUserUnpermittedException(data.message);
}
case OakUnloggedInException.name: {
return new OakUnloggedInException(data.message);
}
case OakCongruentRowExists.name: {
return new OakCongruentRowExists(data.data, data.message);
}

View File

@ -329,6 +329,7 @@ function dealWithActions(moduleName: string, filename: string, node: ts.TypeNode
actionTexts.forEach(
(action) => {
assert(action.length <= STRING_LITERAL_MAX_LENGTH, `${filename}中的Action「${action}」命名长度大于${STRING_LITERAL_MAX_LENGTH}`);
assert(/^[a-z][a-z|A-Z]+$/.test(action), `${filename}中的Action「${action}」命名不合法,必须以小字字母开头且只能包含字母`)
if (ActionDict.hasOwnProperty(action)) {
throw new Error(`文件${filename}Action定义上的【${action}】动作存在同名`);
}
@ -410,7 +411,9 @@ function analyzeEntity(filename: string, path: string, program: ts.Program) {
const moduleName = filename.split('.')[0];
if (Schema.hasOwnProperty(moduleName)) {
throw new Error(`出现了同名的Entity定义「${moduleName}请注意不要和系统保留的Entity重名。`);
if (!path.includes('oak-general-business')) {
console.log(`出现了同名的Entity定义「${moduleName}」,将使用您所定义的对象结构取代掉默认对象,请确认`);
}
}
const referencedSchemas: string[] = [];
const schemaAttrs: ts.TypeElement[] = [];
@ -533,7 +536,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program) {
// 对于不是Oper的对象全部建立和Oper的反指关系
if (!['Oper', 'OperEntity', 'ModiEntity'].includes(moduleName)) {
if (ReversePointerRelations['OperEntity']) {
if (ReversePointerRelations['OperEntity'] && !ReversePointerRelations['OperEntity'].includes(moduleName)) {
ReversePointerRelations['OperEntity'].push(moduleName);
}
else {
@ -544,7 +547,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program) {
// 对于不是Modi的对象全部建立和Modi的反指关系
if (!['Modi'].includes(moduleName)) {
if (ReversePointerRelations['ModiEntity']) {
if (ReversePointerRelations['ModiEntity'] && !ReversePointerRelations['ModiEntity'].includes(moduleName)) {
ReversePointerRelations['ModiEntity'].push(moduleName);
}
else {
@ -602,7 +605,7 @@ function analyzeEntity(filename: string, path: string, program: ts.Program) {
dealWithActions(moduleName, filename, node.type, program);
}
else if (node.name.text === 'Relation') {
assert(!localeDef, `${filename}】locale定义须在Action之后`);
assert(!localeDef, `${filename}】locale定义须在Relation之后`);
// 增加userXXX对象的描述
if (ts.isLiteralTypeNode(node.type)) {
assert(ts.isStringLiteral(node.type.literal));
@ -1236,51 +1239,7 @@ function constructSchema(statements: Array<ts.Statement>, entity: string) {
statements.push(...SchemaAsts[entity].statements);
}
// if (keys(foreignKeySet).length > 0) {
// for (const fkItem in foreignKeySet) {
// const entityLc = fkItem.slice(0, 1).toLowerCase().concat(fkItem.slice(1));
// const foreignKeys = [];
// /* statements.push(
// factory.createTypeAliasDeclaration(
// undefined,
// undefined,
// factory.createIdentifier(`${fkItem}s`),
// undefined,
// factory.createTemplateLiteralType(
// factory.createTemplateHead(
// `${entityLc}s$`,
// `${entityLc}s$`
// ),
// [factory.createTemplateLiteralTypeSpan(
// factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
// factory.createTemplateTail(
// "",
// ""
// )
// )]
// )
// )
// ); */
// for (let iter = 1; iter < 11; iter++) {
// foreignKeys.push(`${entityLc}s$${iter}`);
// }
// statements.push(
// factory.createTypeAliasDeclaration(
// undefined,
// undefined,
// factory.createIdentifier(`${fkItem}s`),
// undefined,
// factory.createUnionTypeNode(
// foreignKeys.map(
// ele => factory.createLiteralTypeNode(factory.createStringLiteral(ele))
// )
// )
// )
// );
// }
// }
statements.push(
factory.createTypeAliasDeclaration(
undefined,
@ -1557,9 +1516,16 @@ function constructFilter(statements: Array<ts.Statement>, entity: string) {
factory.createTypeReferenceNode(
factory.createIdentifier("ExprOp"),
[
factory.createTypeReferenceNode(
factory.createIdentifier('OpAttr')
)
process.env.COMPLING_AS_LIB ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode(
factory.createIdentifier('OpAttr')
),
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
]) :
factory.createTypeReferenceNode(
factory.createIdentifier('OpAttr')
)
]
),
];
@ -1784,10 +1750,16 @@ function constructProjection(statements: Array<ts.Statement>, entity: string) {
factory.createTypeReferenceNode(
factory.createIdentifier("ExprOp"),
[
factory.createTypeReferenceNode(
factory.createIdentifier("OpAttr"),
undefined
)
process.env.COMPLING_AS_LIB ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode(
factory.createIdentifier('OpAttr')
),
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
]) :
factory.createTypeReferenceNode(
factory.createIdentifier('OpAttr')
)
]
)
]
@ -2186,7 +2158,7 @@ function constructSorter(statements: Array<ts.Statement>, entity: string) {
members.push(
factory.createTypeLiteralNode(
[factory.createPropertySignature(
undefined,
undefined,
firstLetterLowerCase(one),
undefined,
factory.createTypeReferenceNode(
@ -2205,30 +2177,38 @@ function constructSorter(statements: Array<ts.Statement>, entity: string) {
undefined,
undefined,
[factory.createParameterDeclaration(
undefined,
undefined,
undefined,
factory.createIdentifier("k"),
undefined,
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
undefined
undefined,
undefined,
undefined,
factory.createIdentifier("k"),
undefined,
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
undefined
)],
factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword)
)])
)])
);
}
members.push(
factory.createTypeReferenceNode(
factory.createIdentifier("OneOf"),
[factory.createTypeReferenceNode(
factory.createIdentifier("ExprOp"),
[factory.createTypeReferenceNode(
factory.createIdentifier("OpAttr"),
undefined
)]
factory.createIdentifier("ExprOp"),
[
process.env.COMPLING_AS_LIB ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode(
factory.createIdentifier('OpAttr')
),
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
]) :
factory.createTypeReferenceNode(
factory.createIdentifier('OpAttr')
)
]
)]
)
)
);
/**
*
@ -2924,7 +2904,13 @@ function constructActions(statements: Array<ts.Statement>, entity: string) {
const otmUpdateOperationNode = factory.createTypeReferenceNode(
factory.createIdentifier("OakOperation"),
[
factory.createLiteralTypeNode(factory.createStringLiteral("update")),
factory.createIndexedAccessTypeNode(
factory.createTypeReferenceNode(
createForeignRef(entity, entityName, 'UpdateOperation'),
undefined
),
factory.createLiteralTypeNode(factory.createStringLiteral("action"))
),
factory.createTypeReferenceNode(
factory.createIdentifier("Omit"),
[
@ -3059,7 +3045,7 @@ function constructActions(statements: Array<ts.Statement>, entity: string) {
factory.createTypeReferenceNode(
factory.createIdentifier("OpSchema"),
undefined
),
),
factory.createUnionTypeNode(uniq(foreignKeyAttr).map(
ele => factory.createLiteralTypeNode(factory.createStringLiteral(ele))
))
@ -3344,6 +3330,17 @@ function constructActions(statements: Array<ts.Statement>, entity: string) {
);
// UpdateOperation
const actionTypeNodes: ts.TypeNode[] = ActionAsts[entity] ? [
factory.createTypeReferenceNode('ParticularAction'),
factory.createLiteralTypeNode(factory.createStringLiteral("update"))
] : [
factory.createLiteralTypeNode(factory.createStringLiteral("update"))
];
if (process.env.COMPLING_AS_LIB) {
actionTypeNodes.push(
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
);
}
statements.push(
factory.createTypeAliasDeclaration(
undefined,
@ -3353,12 +3350,7 @@ function constructActions(statements: Array<ts.Statement>, entity: string) {
factory.createTypeReferenceNode(
factory.createIdentifier("OakOperation"),
[
ActionAsts[entity] ?
factory.createUnionTypeNode([
factory.createTypeReferenceNode('ParticularAction'),
factory.createLiteralTypeNode(factory.createStringLiteral("update"))
]) :
factory.createLiteralTypeNode(factory.createStringLiteral("update")),
factory.createUnionTypeNode(actionTypeNodes),
factory.createTypeReferenceNode(
factory.createIdentifier("UpdateOperationData")
),
@ -3834,6 +3826,11 @@ const initialStatements = () => [
false,
factory.createIdentifier("Operation"),
factory.createIdentifier("OakOperation")
),
factory.createImportSpecifier(
false,
factory.createIdentifier("MakeAction"),
factory.createIdentifier("OakMakeAction")
)
])
),
@ -4150,6 +4147,13 @@ function outputSchema(outputDir: string, printer: ts.Printer) {
constructActions(statements, entity);
constructQuery(statements, entity);
constructFullAttrs(statements, entity);
const actionTypeNodes: ts.TypeNode[] = ActionAsts[entity] ? [factory.createTypeReferenceNode('Action')] : [factory.createTypeReferenceNode('GenericAction')];
if (process.env.COMPLING_AS_LIB) {
actionTypeNodes.push(
factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword)
);
}
const EntityDefAttrs = [
factory.createPropertySignature(
undefined,
@ -4174,8 +4178,10 @@ function outputSchema(outputDir: string, printer: ts.Printer) {
factory.createIdentifier("Action"),
undefined,
factory.createTypeReferenceNode(
factory.createIdentifier(ActionAsts[entity] ? 'Action' : 'GenericAction'),
undefined
factory.createIdentifier('OakMakeAction'),
[
factory.createUnionTypeNode(actionTypeNodes)
]
)
),
factory.createPropertySignature(

View File

@ -1,5 +1,5 @@
import { ActionDef } from '../types/Action';
import { String, Int, Datetime, Image, Boolean, Text } from '../types/DataType';
import { String } from '../types/DataType';
import { EntityShape } from '../types/Entity';
import { LocaleDef } from '../types/Locale';
import { Index } from '../types/Storage';

View File

@ -1,12 +1,14 @@
import { String, Int, Datetime, Image, Boolean, Text } from '../types/DataType';
import { EntityShape } from '../types/Entity';
import { LocaleDef } from '../types/Locale';
import { Schema as User } from './User';
export interface Schema extends EntityShape {
action: String<16>;
data: Object;
filter?: Object;
extra?: Object;
operator?: User;
};
const locale: LocaleDef<Schema, '', '', {}> = {
@ -16,6 +18,7 @@ const locale: LocaleDef<Schema, '', '', {}> = {
data: '数据',
filter: '选择条件',
extra: '其它',
operator: '操作者',
},
},
};

20
src/entities/User.ts Normal file
View File

@ -0,0 +1,20 @@
import { String, Int, Text, Image, Datetime } from '../types/DataType';
import { LocaleDef } from '../types/Locale';
import { EntityShape } from '../types/Entity';
export interface Schema extends EntityShape {
name?: String<16>;
nickname?: String<64>;
password?: Text;
};
const locale: LocaleDef<Schema, '', '', {}> = {
zh_CN: {
attr: {
name: '姓名',
nickname: '昵称',
password: '密码',
},
},
};

View File

@ -84,4 +84,6 @@ export abstract class UniversalContext<ED extends EntityDict> implements Context
}
abstract toString(): Promise<string>;
abstract getCurrentUserId(): Promise<string | undefined>;
}

10
src/store/action.ts Normal file
View File

@ -0,0 +1,10 @@
/**
* action是不是延时性操作
* @param action
* @returns
*/
export function isLaterAction(action: string) {
if (action.endsWith('-l')) {
return action.slice(0, action.length -2);
}
}

View File

@ -13,5 +13,6 @@ export interface Context<ED extends EntityDict>{
toString(): Promise<string>;
getScene(): string | undefined;
setScene(scene?: string): void;
getCurrentUserId(): Promise<string | undefined>;
};

View File

@ -26,6 +26,7 @@ export type SelectOption = {
export type OperateOption = {
dontCollect?: boolean;
parentModiId?: string; // 如果是延时更新所有的相关modi要关联到一个父亲上统一应用
dummy?: 1; // 无用为了继承Option通过编译
};
@ -64,6 +65,8 @@ interface GeneralEntityShape extends EntityShape {
[K: string]: any;
}
export type MakeAction<A extends string> = A | `${A}-l`;
export interface EntityDef {
// Name: E;
Schema: GeneralEntityShape;

View File

@ -99,6 +99,15 @@ export class OakUserUnpermittedException extends OakUserException {
};
/**
*
*/
export class OakUnloggedInException extends OakUserException {
constructor(message?: string) {
super(message || '您尚未登录');
}
};
/**
*
*/
@ -147,6 +156,9 @@ export function makeException(data: {
case OakUserUnpermittedException.name: {
return new OakUserUnpermittedException(data.message);
}
case OakUnloggedInException.name: {
return new OakUnloggedInException(data.message);
}
case OakCongruentRowExists.name: {
return new OakCongruentRowExists(data.data, data.message);
}

View File

@ -1,7 +1,7 @@
import { SelectOption, SelectRowShape } from ".";
import { GenericAction } from "../actions/action";
import { DeduceCreateOperation, DeduceRemoveOperation, DeduceSelection, DeduceUpdateOperation, EntityDict, OperateOption } from "../types/Entity";
import { EntityDef, EntityShape, OperationResult, SelectionResult, TriggerDataAttribute, TriggerTimestampAttribute } from "../types/Entity";
import { EntityDict, OperateOption } from "../types/Entity";
import { EntityShape, TriggerDataAttribute, TriggerTimestampAttribute } from "../types/Entity";
import { Context } from "./Context";
export type CheckerType = 'user' | 'row' | 'data';