注释掉了operateOption当中的dontCreateOper和dontCreateModi
This commit is contained in:
parent
e26e6706b5
commit
c2d76f5129
|
|
@ -4,6 +4,7 @@ export type UserAction = 'mergeTo' | string;
|
|||
export type UserState = 'normal' | 'merged' | string;
|
||||
export type ParticularAction = UserAction;
|
||||
export declare const actions: string[];
|
||||
export declare const UserActionDef: ActionDef<UserAction, UserState>;
|
||||
export type Action = GenericAction | ParticularAction | RelationAction | string;
|
||||
export declare const ActionDefDict: {
|
||||
userState: ActionDef<string, string>;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ActionDefDict = exports.actions = void 0;
|
||||
exports.ActionDefDict = exports.UserActionDef = exports.actions = void 0;
|
||||
exports.actions = ["count", "stat", "download", "select", "aggregate", "create", "remove", "update", "grant", "revoke", "mergeTo"];
|
||||
const UserActionDef = {
|
||||
exports.UserActionDef = {
|
||||
stm: {
|
||||
mergeTo: ['normal', 'merged'],
|
||||
},
|
||||
};
|
||||
exports.ActionDefDict = {
|
||||
userState: UserActionDef
|
||||
userState: exports.UserActionDef
|
||||
};
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ function searchImportedPath(path, fileSpecifierPath, filename) {
|
|||
return path_1.default.join(pkgJsonPath, '..', dependentFilePath, ...(fileSpecifierPaths[0] ? fileSpecifierPaths.slice(1) : (fileSpecifierPaths.slice(2))));
|
||||
}
|
||||
else {
|
||||
return path_1.default.join(pkgJsonPath, 'node_modules', fileSpecifierPath);
|
||||
return path_1.default.join(pkgJsonPath, '..', 'node_modules', fileSpecifierPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,18 @@
|
|||
import { String, Text } from '../types/DataType';
|
||||
import { EntityShape } from '../types/Entity';
|
||||
import { ActionDef } from '../types/Action';
|
||||
import { EntityDesc } from '../types/EntityDesc';
|
||||
export interface Schema extends EntityShape {
|
||||
name?: String<16>;
|
||||
nickname?: String<64>;
|
||||
password?: Text;
|
||||
ref?: Schema;
|
||||
}
|
||||
type UserAction = 'mergeTo';
|
||||
type UserState = 'normal' | 'merged';
|
||||
export type Action = UserAction;
|
||||
export declare const UserActionDef: ActionDef<UserAction, UserState>;
|
||||
export declare const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
userState: UserState;
|
||||
}>;
|
||||
export {};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.entityDesc = exports.UserActionDef = void 0;
|
||||
;
|
||||
const UserActionDef = {
|
||||
exports.UserActionDef = {
|
||||
stm: {
|
||||
mergeTo: ['normal', 'merged'],
|
||||
},
|
||||
};
|
||||
const entityDesc = {
|
||||
exports.entityDesc = {
|
||||
locales: {
|
||||
zh_CN: {
|
||||
name: '用户',
|
||||
|
|
|
|||
|
|
@ -680,7 +680,7 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
const opData = {};
|
||||
const beforeFns = [];
|
||||
const afterFns = [];
|
||||
if (modiAttr && action !== 'remove' && !option.dontCreateModi) {
|
||||
if (modiAttr && action !== 'remove') {
|
||||
// create/update具有modi对象的对象,对其子对象的update行为全部是create modi对象(缓存动作)
|
||||
// delete此对象,所有的modi子对象应该通过触发器作废,这个目前先通过系统的trigger来实现
|
||||
(0, assert_1.default)(!option2.modiParentId && !option2.modiParentEntity);
|
||||
|
|
@ -1146,13 +1146,8 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
}
|
||||
if (!option.dontCollect) {
|
||||
context.saveOpRecord(entity, operation);
|
||||
/* context.opRecords.push({
|
||||
a: 'c',
|
||||
e: entity,
|
||||
d: data as ED[T]['OpSchema'] | ED[T]['OpSchema'][],
|
||||
}); */
|
||||
}
|
||||
if (!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity)) {
|
||||
if (!['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity)) {
|
||||
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
||||
(0, assert_1.default)(operId);
|
||||
const operatorId = context.getCurrentUserId(true);
|
||||
|
|
@ -1188,7 +1183,6 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
const closeRootMode = context.openRootMode();
|
||||
await this.cascadeUpdateAsync('oper', createOper, context, {
|
||||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
});
|
||||
closeRootMode();
|
||||
}
|
||||
|
|
@ -1308,7 +1302,7 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
}
|
||||
else {
|
||||
const createOper = async () => {
|
||||
if (!option?.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity) && ids.length > 0) {
|
||||
if (!['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity) && ids.length > 0) {
|
||||
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
||||
(0, assert_1.default)(operId);
|
||||
const createOper = {
|
||||
|
|
@ -1333,7 +1327,6 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
const closeRootMode = context.openRootMode();
|
||||
await this.cascadeUpdateAsync('oper', createOper, context, {
|
||||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
});
|
||||
closeRootMode();
|
||||
}
|
||||
|
|
@ -1350,15 +1343,6 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
}
|
||||
}
|
||||
});
|
||||
/* context.opRecords.push({
|
||||
a: 'r',
|
||||
e: entity,
|
||||
f: {
|
||||
id: {
|
||||
$in: ids,
|
||||
}
|
||||
},
|
||||
}); */
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -1379,16 +1363,6 @@ class CascadeStore extends RowStore_1.RowStore {
|
|||
}
|
||||
},
|
||||
});
|
||||
/* context.opRecords.push({
|
||||
a: 'u',
|
||||
e: entity,
|
||||
d: data as ED[T]['Update']['data'],
|
||||
f: {
|
||||
id: {
|
||||
$in: ids,
|
||||
}
|
||||
},
|
||||
}); */
|
||||
}
|
||||
}
|
||||
else if (action !== 'update') {
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ export type SelectOption = {
|
|||
export type OperateOption = {
|
||||
blockTrigger?: true;
|
||||
dontCollect?: boolean;
|
||||
dontCreateOper?: boolean;
|
||||
dontCreateModi?: boolean;
|
||||
includedDeleted?: true;
|
||||
allowExists?: boolean;
|
||||
modiParentId?: string;
|
||||
|
|
@ -146,20 +144,20 @@ type RemoveOperationData = {
|
|||
export type RemoveOperation = Operation<'remove', RemoveOperationData, Filter, Sorter>;
|
||||
export type CUDOperation = CreateOperation | UpdateOperation | RemoveOperation;
|
||||
export type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
id?: string;
|
||||
id: string;
|
||||
a: 'c';
|
||||
e: T;
|
||||
d: ED[T]['OpSchema'] | ED[T]['OpSchema'][];
|
||||
};
|
||||
export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
id?: string;
|
||||
id: string;
|
||||
a: 'u';
|
||||
e: T;
|
||||
d: UpdateOperationData;
|
||||
f?: Filter;
|
||||
};
|
||||
export type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
id?: string;
|
||||
id: string;
|
||||
a: 'r';
|
||||
e: T;
|
||||
f?: Filter;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
import { StorageSchema } from "..";
|
||||
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
||||
import { EntityDict } from "../types/Entity";
|
||||
export declare function destructRelationPath<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(schema: StorageSchema<ED>, entity: T, path: string, relationFilter?: ED['userRelation']['Selection']['filter'], recursive?: boolean): {
|
||||
projection: ED[T]['Selection']['data'];
|
||||
getData: (d: Partial<ED[T]['Schema']>) => ED['userRelation']['Schema'][];
|
||||
};
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.destructRelationPath = void 0;
|
||||
function destructRelationPath(schema, entity, path, relationFilter, recursive) {
|
||||
throw new Error('method not implemented');
|
||||
}
|
||||
exports.destructRelationPath = destructRelationPath;
|
||||
|
|
@ -787,7 +787,7 @@ function searchImportedPath(path: string, fileSpecifierPath: string, filename: s
|
|||
return PathLib.join(pkgJsonPath, '..', dependentFilePath, ...(fileSpecifierPaths[0] ? fileSpecifierPaths.slice(1) : (fileSpecifierPaths.slice(2))));
|
||||
}
|
||||
else {
|
||||
return PathLib.join(pkgJsonPath, 'node_modules', fileSpecifierPath);
|
||||
return PathLib.join(pkgJsonPath, '..', 'node_modules', fileSpecifierPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,16 +13,16 @@ export interface Schema extends EntityShape {
|
|||
type UserAction = 'mergeTo';
|
||||
type UserState = 'normal' | 'merged';
|
||||
|
||||
type Action = UserAction;
|
||||
export type Action = UserAction;
|
||||
|
||||
|
||||
const UserActionDef: ActionDef<UserAction, UserState> = {
|
||||
export const UserActionDef: ActionDef<UserAction, UserState> = {
|
||||
stm: {
|
||||
mergeTo: ['normal', 'merged'],
|
||||
},
|
||||
};
|
||||
|
||||
const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
export const entityDesc: EntityDesc<Schema, Action, '', {
|
||||
userState: UserState,
|
||||
}> = {
|
||||
locales: {
|
||||
|
|
|
|||
|
|
@ -904,7 +904,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
const opData: Record<string, any> = {};
|
||||
const beforeFns: Array<() => R> = [];
|
||||
const afterFns: Array<() => R> = [];
|
||||
if (modiAttr && action !== 'remove' && !option.dontCreateModi) {
|
||||
if (modiAttr && action !== 'remove') {
|
||||
// create/update具有modi对象的对象,对其子对象的update行为全部是create modi对象(缓存动作)
|
||||
// delete此对象,所有的modi子对象应该通过触发器作废,这个目前先通过系统的trigger来实现
|
||||
assert(!option2.modiParentId && !option2.modiParentEntity);
|
||||
|
|
@ -1414,13 +1414,8 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
|
||||
if (!option.dontCollect) {
|
||||
context.saveOpRecord(entity, operation);
|
||||
/* context.opRecords.push({
|
||||
a: 'c',
|
||||
e: entity,
|
||||
d: data as ED[T]['OpSchema'] | ED[T]['OpSchema'][],
|
||||
}); */
|
||||
}
|
||||
if (!option.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity as string)) {
|
||||
if (!['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity as string)) {
|
||||
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
||||
assert(operId);
|
||||
const operatorId = context.getCurrentUserId(true);
|
||||
|
|
@ -1460,7 +1455,6 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
const closeRootMode = context.openRootMode();
|
||||
await this.cascadeUpdateAsync('oper', createOper, context, {
|
||||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
});
|
||||
closeRootMode();
|
||||
}
|
||||
|
|
@ -1585,7 +1579,7 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
}
|
||||
else {
|
||||
const createOper = async () => {
|
||||
if (!option?.dontCreateOper && !['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity as string) && ids.length > 0) {
|
||||
if (!['oper', 'operEntity', 'modiEntity', 'modi'].includes(entity as string) && ids.length > 0) {
|
||||
// 按照框架要求生成Oper和OperEntity这两个内置的对象
|
||||
assert(operId);
|
||||
const createOper: CreateSingleOperOperation = {
|
||||
|
|
@ -1614,7 +1608,6 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
const closeRootMode = context.openRootMode();
|
||||
await this.cascadeUpdateAsync('oper', createOper, context, {
|
||||
dontCollect: true,
|
||||
dontCreateOper: true,
|
||||
});
|
||||
closeRootMode();
|
||||
}
|
||||
|
|
@ -1631,15 +1624,6 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
}
|
||||
}
|
||||
});
|
||||
/* context.opRecords.push({
|
||||
a: 'r',
|
||||
e: entity,
|
||||
f: {
|
||||
id: {
|
||||
$in: ids,
|
||||
}
|
||||
},
|
||||
}); */
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -1660,16 +1644,6 @@ export abstract class CascadeStore<ED extends EntityDict & BaseEntityDict> exten
|
|||
}
|
||||
},
|
||||
});
|
||||
/* context.opRecords.push({
|
||||
a: 'u',
|
||||
e: entity,
|
||||
d: data as ED[T]['Update']['data'],
|
||||
f: {
|
||||
id: {
|
||||
$in: ids,
|
||||
}
|
||||
},
|
||||
}); */
|
||||
}
|
||||
}
|
||||
else if (action !== 'update') {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@ export type SelectOption = {
|
|||
export type OperateOption = {
|
||||
blockTrigger?: true;
|
||||
dontCollect?: boolean;
|
||||
dontCreateOper?: boolean;
|
||||
dontCreateModi?: boolean;
|
||||
includedDeleted?: true; // 是否更新已删除行
|
||||
allowExists?: boolean; // 插入时允许已经存在唯一键值的行了,即insert / update逻辑
|
||||
modiParentId?: string; // 如果是延时更新,相关modi要关联到一个父亲上统一应用
|
||||
|
|
@ -190,14 +188,14 @@ export type RemoveOperation = Operation<'remove', RemoveOperationData, Filter, S
|
|||
export type CUDOperation = CreateOperation | UpdateOperation | RemoveOperation;
|
||||
|
||||
export type CreateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
id?: string;
|
||||
id: string;
|
||||
a: 'c';
|
||||
e: T;
|
||||
d: ED[T]['OpSchema'] | ED[T]['OpSchema'][];
|
||||
};
|
||||
|
||||
export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
id?: string;
|
||||
id: string;
|
||||
a: 'u',
|
||||
e: T;
|
||||
d: UpdateOperationData;
|
||||
|
|
@ -205,7 +203,7 @@ export type UpdateOpResult<ED extends EntityDict, T extends keyof ED> = {
|
|||
};
|
||||
|
||||
export type RemoveOpResult<ED extends EntityDict, T extends keyof ED> = {
|
||||
id?: string;
|
||||
id: string;
|
||||
a: 'r',
|
||||
e: T;
|
||||
f?: Filter;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { StorageSchema } from "..";
|
||||
import { EntityDict as BaseEntityDict } from "../base-app-domain";
|
||||
import { EntityDict } from "../types/Entity";
|
||||
|
||||
export function destructRelationPath<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(
|
||||
schema: StorageSchema<ED>,
|
||||
entity: T,
|
||||
path: string,
|
||||
relationFilter?: ED['userRelation']['Selection']['filter'],
|
||||
recursive?: boolean
|
||||
): {
|
||||
projection: ED[T]['Selection']['data'];
|
||||
getData: (d: Partial<ED[T]['Schema']>) => ED['userRelation']['Schema'][];
|
||||
} {
|
||||
throw new Error('method not implemented');
|
||||
}
|
||||
Loading…
Reference in New Issue