oak-domain 5.0.2 → 5.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/compiler/dependencyBuilder.js +1 -1
- package/lib/compiler/schemalBuilder.js +11 -1
- package/lib/store/AsyncRowStore.d.ts +1 -0
- package/lib/store/AsyncRowStore.js +4 -7
- package/lib/store/TriggerExecutor.js +1 -1
- package/lib/utils/lodash.d.ts +1 -1
- package/lib/utils/lodash.js +3 -0
- package/package.json +1 -1
|
@@ -199,7 +199,7 @@ function outputDependentExceptions(dependencies, briefNames, sourceFile, printer
|
|
|
199
199
|
const { name, initializer } = vd;
|
|
200
200
|
(0, assert_1.default)(ts.isIdentifier(name) && name.text === 'e');
|
|
201
201
|
(0, assert_1.default)(ts.isCallExpression(initializer));
|
|
202
|
-
const callExpressions = briefNames.map(ele => factory.createCallExpression(factory.createIdentifier(`make${(0, string_1.firstLetterUpperCase)(ele)}Exception`), [factory.createTypeReferenceNode(factory.createIdentifier("
|
|
202
|
+
const callExpressions = briefNames.map(ele => factory.createCallExpression(factory.createIdentifier(`make${(0, string_1.firstLetterUpperCase)(ele)}Exception`), [factory.createTypeReferenceNode(factory.createIdentifier("ED"), undefined)], [factory.createIdentifier("data")]));
|
|
203
203
|
const rightExpression = callExpressions.length === 1 ? callExpressions[0] :
|
|
204
204
|
callExpressions.length === 2 ? factory.createBinaryExpression(callExpressions[0], factory.createToken(ts.SyntaxKind.BarBarToken), callExpressions[1]) : callExpressions.slice(2).reduce((prev, next) => factory.createBinaryExpression(prev, factory.createToken(ts.SyntaxKind.BarBarToken), next), factory.createBinaryExpression(callExpressions[0], factory.createToken(ts.SyntaxKind.BarBarToken), callExpressions[1]));
|
|
205
205
|
Object.assign(vd, {
|
|
@@ -289,7 +289,17 @@ function tryGetStringLiteralValues(moduleName, filename, obj, node, program) {
|
|
|
289
289
|
// 本地定义的type
|
|
290
290
|
const { name, type } = declaration;
|
|
291
291
|
if (ts.isUnionTypeNode(type)) {
|
|
292
|
-
values.push(...type.types.map(ele =>
|
|
292
|
+
values.push(...(type.types.map(ele => {
|
|
293
|
+
if (ts.isLiteralTypeNode(ele)) {
|
|
294
|
+
return checkStringLiteralLegal(filename, obj, name.text, ele);
|
|
295
|
+
}
|
|
296
|
+
else if (ts.isTypeReferenceNode(ele)) {
|
|
297
|
+
return tryGetStringLiteralValues(moduleName, filename, obj, ele, program);
|
|
298
|
+
}
|
|
299
|
+
else {
|
|
300
|
+
throw new Error(`暂时不能处理的type${ele.getText()}`);
|
|
301
|
+
}
|
|
302
|
+
})).flat());
|
|
293
303
|
}
|
|
294
304
|
else if (ts.isLiteralTypeNode(type)) {
|
|
295
305
|
const action = checkStringLiteralLegal(filename, obj, name.text, type);
|
|
@@ -50,6 +50,7 @@ export declare abstract class AsyncContext<ED extends EntityDict> implements Con
|
|
|
50
50
|
abstract getCurrentUserId(allowUnloggedIn?: boolean): string | undefined;
|
|
51
51
|
abstract setCurrentUserId(userId: string | undefined): void;
|
|
52
52
|
abstract toString(): Promise<string>;
|
|
53
|
+
protected abstract getSerializedData(): Promise<object>;
|
|
53
54
|
abstract initialize(data?: any, later?: boolean): Promise<void>;
|
|
54
55
|
abstract allowUserUpdate(): boolean;
|
|
55
56
|
abstract openRootMode(): () => void;
|
|
@@ -28,19 +28,16 @@ class AsyncContext {
|
|
|
28
28
|
}
|
|
29
29
|
// 使一个上下文重新开始事务执行,清除历史数据(定时器中使用)
|
|
30
30
|
async restartToExecute(routine) {
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
console.warn('restartToExecute跑出了非重用当前context的情况,请仔细调试');
|
|
36
|
-
}
|
|
31
|
+
const data = await this.getSerializedData();
|
|
32
|
+
const newContext = (new (Object.getPrototypeOf(this).constructor)(this.rowStore));
|
|
33
|
+
await newContext.begin();
|
|
34
|
+
await newContext.initialize(data, true);
|
|
37
35
|
newContext.opRecords = [];
|
|
38
36
|
newContext.events = {
|
|
39
37
|
commit: [],
|
|
40
38
|
rollback: [],
|
|
41
39
|
};
|
|
42
40
|
newContext.opResult = {};
|
|
43
|
-
await newContext.begin();
|
|
44
41
|
try {
|
|
45
42
|
await routine(newContext);
|
|
46
43
|
await newContext.commit();
|
|
@@ -43,7 +43,7 @@ class TriggerExecutor {
|
|
|
43
43
|
if (!context.getCurrentTxnId()) {
|
|
44
44
|
await context.begin();
|
|
45
45
|
}
|
|
46
|
-
await context.initialize(JSON.parse(cxtStr));
|
|
46
|
+
await context.initialize(JSON.parse(cxtStr), true);
|
|
47
47
|
try {
|
|
48
48
|
await this.execVolatileTrigger(entity, trigger.name, ids, context, option);
|
|
49
49
|
await context.commit();
|
package/lib/utils/lodash.d.ts
CHANGED
|
@@ -29,5 +29,5 @@ import pullAll from 'lodash/pullAll';
|
|
|
29
29
|
* @returns
|
|
30
30
|
*/
|
|
31
31
|
declare function mergeConcatArray(object: any, source: any): any;
|
|
32
|
-
declare function mergeConcatMany<T>(array: Array<T>): T;
|
|
32
|
+
declare function mergeConcatMany<T>(array: Array<T>): T | undefined;
|
|
33
33
|
export { unset, pull, uniq, uniqBy, get, set, intersection, intersectionBy, omit, merge, mergeWith, mergeConcatArray, mergeConcatMany, cloneDeep, pick, isEqual, union, difference, differenceBy, groupBy, unionBy, pullAll, };
|
package/lib/utils/lodash.js
CHANGED
|
@@ -67,6 +67,9 @@ function mergeConcatArray(object, source) {
|
|
|
67
67
|
}
|
|
68
68
|
exports.mergeConcatArray = mergeConcatArray;
|
|
69
69
|
function mergeConcatMany(array) {
|
|
70
|
+
if (array.length === 0) {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
70
73
|
return array.reduce((prev, current) => mergeConcatArray(prev, current));
|
|
71
74
|
}
|
|
72
75
|
exports.mergeConcatMany = mergeConcatMany;
|