oak-domain 2.6.2 → 2.6.3
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/base-app-domain/Modi/Storage.js +2 -4
- package/lib/base-app-domain/User/Storage.js +2 -4
- package/lib/compiler/schemalBuilder.js +74 -77
- package/lib/store/CascadeStore.js +39 -33
- package/lib/store/checker.d.ts +2 -2
- package/lib/store/checker.js +387 -151
- package/lib/store/filter.js +7 -15
- package/lib/types/Auth.d.ts +10 -10
- package/lib/types/Exception.d.ts +6 -0
- package/lib/types/Exception.js +25 -1
- package/lib/types/Polyfill.d.ts +1 -0
- package/lib/types/Storage.d.ts +1 -0
- package/lib/utils/validator.d.ts +3 -2
- package/package.json +1 -1
|
@@ -160,6 +160,13 @@ function checkActionDefNameConsistent(filename, actionDefNode) {
|
|
|
160
160
|
var sName = stateNode.typeName.text.slice(0, stateNode.typeName.text.length - 5);
|
|
161
161
|
(0, assert_1.default)(adfName === aName && aName === sName, "\u6587\u4EF6".concat(filename, "\u4E2D\u7684ActionDef").concat(name.text, "\u4E2DActionDef, Action\u548CState\u7684\u547D\u540D\u89C4\u5219\u4E0D\u4E00\u81F4"));
|
|
162
162
|
}
|
|
163
|
+
function checkStringLiteralLegal(filename, obj, text, ele) {
|
|
164
|
+
(0, assert_1.default)(ts.isLiteralTypeNode(ele) && ts.isStringLiteral(ele.literal), "".concat(filename, "\u4E2D\u5F15\u7528\u7684").concat(obj, " ").concat(text, "\u4E2D\u5B58\u5728\u4E0D\u662Fstringliteral\u7684\u7C7B\u578B"));
|
|
165
|
+
(0, assert_1.default)(!ele.literal.text.includes('$'), "".concat(filename, "\u4E2D\u5F15\u7528\u7684action").concat(text, "\u4E2D\u7684").concat(obj, "\u300C").concat(ele.literal.text, "\u300D\u5305\u542B\u975E\u6CD5\u5B57\u7B26$"));
|
|
166
|
+
(0, assert_1.default)(ele.literal.text.length > 0, "".concat(filename, "\u4E2D\u5F15\u7528\u7684action").concat(text, "\u4E2D\u7684").concat(obj, "\u300C").concat(ele.literal.text, "\u300D\u957F\u5EA6\u975E\u6CD5"));
|
|
167
|
+
(0, assert_1.default)(ele.literal.text.length < env_1.STRING_LITERAL_MAX_LENGTH, "".concat(filename, "\u4E2D\u5F15\u7528\u7684").concat(obj, " ").concat(text, "\u4E2D\u7684\u300C").concat(ele.literal.text, "\u300D\u957F\u5EA6\u8FC7\u957F"));
|
|
168
|
+
return ele.literal.text;
|
|
169
|
+
}
|
|
163
170
|
function addActionSource(moduleName, name, node) {
|
|
164
171
|
var _a;
|
|
165
172
|
var ast = ActionAsts[moduleName];
|
|
@@ -199,20 +206,13 @@ function getStringTextFromUnionStringLiterals(moduleName, filename, node, progra
|
|
|
199
206
|
_a[name.text] = 'local',
|
|
200
207
|
_a));
|
|
201
208
|
}
|
|
202
|
-
var getStringLiteral = function (ele) {
|
|
203
|
-
(0, assert_1.default)(ts.isLiteralTypeNode(ele) && ts.isStringLiteral(ele.literal), "".concat(filename, "\u4E2D\u5F15\u7528\u7684action").concat(name.text, "\u4E2D\u5B58\u5728\u4E0D\u662Fstringliteral\u7684\u7C7B\u578B"));
|
|
204
|
-
(0, assert_1.default)(!ele.literal.text.includes('$'), "".concat(filename, "\u4E2D\u5F15\u7528\u7684action").concat(name.text, "\u4E2D\u7684action\u300C").concat(ele.literal.text, "\u300D\u5305\u542B\u975E\u6CD5\u5B57\u7B26$"));
|
|
205
|
-
(0, assert_1.default)(ele.literal.text.length > 0, "".concat(filename, "\u4E2D\u5F15\u7528\u7684action").concat(name.text, "\u4E2D\u7684action\u300C").concat(ele.literal.text, "\u300D\u957F\u5EA6\u975E\u6CD5"));
|
|
206
|
-
(0, assert_1.default)(ele.literal.text.length < env_1.STRING_LITERAL_MAX_LENGTH, "".concat(filename, "\u4E2D\u5F15\u7528\u7684action").concat(name.text, "\u4E2D\u7684action\u300C").concat(ele.literal.text, "\u300D\u957F\u5EA6\u8FC7\u957F"));
|
|
207
|
-
return ele.literal.text;
|
|
208
|
-
};
|
|
209
209
|
if (ts.isUnionTypeNode(type)) {
|
|
210
|
-
var actions = type.types.map(function (ele) { return
|
|
210
|
+
var actions = type.types.map(function (ele) { return checkStringLiteralLegal(filename, 'action', name.text, ele); });
|
|
211
211
|
return actions;
|
|
212
212
|
}
|
|
213
213
|
else {
|
|
214
214
|
(0, assert_1.default)(ts.isLiteralTypeNode(type), "".concat(filename, "\u4E2D\u5F15\u7528\u7684action\u300C").concat(name.text, "\u300D\u7684\u5B9A\u4E49\u4E0D\u662Funion\u548CstringLiteral\u7C7B\u578B"));
|
|
215
|
-
var action =
|
|
215
|
+
var action = checkStringLiteralLegal(filename, 'action', name.text, type);
|
|
216
216
|
return [action];
|
|
217
217
|
}
|
|
218
218
|
}
|
|
@@ -325,6 +325,25 @@ function checkLocaleExpressionPropertyExists(root, attr, exists, filename) {
|
|
|
325
325
|
}
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
|
+
function getStringEnumValues(filename, program, obj, node) {
|
|
329
|
+
var _a;
|
|
330
|
+
var checker = program.getTypeChecker();
|
|
331
|
+
var symbol = checker.getSymbolAtLocation(node.typeName);
|
|
332
|
+
var declaration = symbol === null || symbol === void 0 ? void 0 : symbol.getDeclarations()[0];
|
|
333
|
+
if (ts.isImportSpecifier(declaration)) {
|
|
334
|
+
var typee = checker.getDeclaredTypeOfSymbol(symbol);
|
|
335
|
+
declaration = (_a = typee.aliasSymbol) === null || _a === void 0 ? void 0 : _a.getDeclarations()[0];
|
|
336
|
+
}
|
|
337
|
+
if (declaration && ts.isTypeAliasDeclaration(declaration)) {
|
|
338
|
+
if (ts.isUnionTypeNode(declaration.type) && ts.isLiteralTypeNode(declaration.type.types[0])) {
|
|
339
|
+
return declaration.type.types.map(function (ele) { return checkStringLiteralLegal(filename, obj, declaration.name.text, ele); });
|
|
340
|
+
}
|
|
341
|
+
if (ts.isLiteralTypeNode(declaration.type)) {
|
|
342
|
+
var value = checkStringLiteralLegal(filename, obj, declaration.name.text, declaration.type);
|
|
343
|
+
return [value];
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
328
347
|
function analyzeEntity(filename, path, program, relativePath) {
|
|
329
348
|
var _a;
|
|
330
349
|
var fullPath = "".concat(path, "/").concat(filename);
|
|
@@ -347,9 +366,7 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
347
366
|
var toModi = false;
|
|
348
367
|
var actionType = 'crud';
|
|
349
368
|
var _static = false;
|
|
350
|
-
var
|
|
351
|
-
var states = [];
|
|
352
|
-
var localEnumStringTypes = [];
|
|
369
|
+
var enumAttributes = {};
|
|
353
370
|
var additionalImports = [];
|
|
354
371
|
var localeDef = undefined;
|
|
355
372
|
// let relationHierarchy: ts.ObjectLiteralExpression | undefined = undefined;
|
|
@@ -419,8 +436,9 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
419
436
|
}
|
|
420
437
|
else {
|
|
421
438
|
schemaAttrs.push(attrNode);
|
|
422
|
-
|
|
423
|
-
|
|
439
|
+
var enumStringValues = getStringEnumValues(filename, program, '属性', type);
|
|
440
|
+
if (enumStringValues) {
|
|
441
|
+
enumAttributes[attrName] = enumStringValues;
|
|
424
442
|
}
|
|
425
443
|
}
|
|
426
444
|
}
|
|
@@ -447,15 +465,19 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
447
465
|
}
|
|
448
466
|
else {
|
|
449
467
|
schemaAttrs.push(attrNode);
|
|
450
|
-
if (ts.isUnionTypeNode(type)) {
|
|
468
|
+
if (ts.isUnionTypeNode(type) && ts.isLiteralTypeNode(type.types[0]) && ts.isStringLiteral(type.types[0].literal)) {
|
|
469
|
+
(0, assert_1.default)(ts.isIdentifier(name));
|
|
451
470
|
var types = type.types;
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
471
|
+
var enumValues = types.map(function (ele) { return checkStringLiteralLegal(filename, '属性', name.text, ele); });
|
|
472
|
+
enumAttributes[name.text] = enumValues;
|
|
473
|
+
}
|
|
474
|
+
else if (ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal)) {
|
|
475
|
+
// 单个字符串的情形,目前应该没有,没测试过,先写着 by Xc 20230221
|
|
476
|
+
(0, assert_1.default)(ts.isIdentifier(name));
|
|
477
|
+
var enumValues = [
|
|
478
|
+
checkStringLiteralLegal(filename, '属性', name.text, type)
|
|
479
|
+
];
|
|
480
|
+
enumAttributes[name.text] = enumValues;
|
|
459
481
|
}
|
|
460
482
|
}
|
|
461
483
|
if (attrName === 'entity') {
|
|
@@ -547,16 +569,19 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
547
569
|
(0, assert_1.default)(!hasActionDef, "\u3010".concat(filename, "\u3011action\u5B9A\u4E49\u987B\u5728Relation\u4E4B\u540E"));
|
|
548
570
|
(0, assert_1.default)(!localeDef, "\u3010".concat(filename, "\u3011locale\u5B9A\u4E49\u987B\u5728Relation\u4E4B\u540E"));
|
|
549
571
|
// 增加userXXX对象的描述
|
|
572
|
+
var relationValues = [];
|
|
550
573
|
if (ts.isLiteralTypeNode(node.type)) {
|
|
551
574
|
(0, assert_1.default)(ts.isStringLiteral(node.type.literal));
|
|
552
575
|
(0, assert_1.default)(node.type.literal.text.length < env_1.STRING_LITERAL_MAX_LENGTH, "Relation\u5B9A\u4E49\u7684\u5B57\u7B26\u4E32\u957F\u5EA6\u4E0D\u957F\u4E8E".concat(env_1.STRING_LITERAL_MAX_LENGTH, "\uFF08").concat(filename, "\uFF0C").concat(node.type.literal.text, "\uFF09"));
|
|
576
|
+
relationValues.push(node.type.literal.text);
|
|
553
577
|
}
|
|
554
578
|
else {
|
|
555
579
|
(0, assert_1.default)(ts.isUnionTypeNode(node.type), "Relation\u7684\u5B9A\u4E49\u53EA\u80FD\u662Fstring\u7C7B\u578B\uFF08".concat(filename, "\uFF09"));
|
|
556
|
-
node.type.types.
|
|
580
|
+
relationValues.push.apply(relationValues, tslib_1.__spreadArray([], tslib_1.__read(node.type.types.map(function (ele) {
|
|
557
581
|
(0, assert_1.default)(ts.isLiteralTypeNode(ele) && ts.isStringLiteral(ele.literal), "Relation\u7684\u5B9A\u4E49\u53EA\u80FD\u662Fstring\u7C7B\u578B\uFF08".concat(filename, "\uFF09"));
|
|
558
582
|
(0, assert_1.default)(ele.literal.text.length < env_1.STRING_LITERAL_MAX_LENGTH, "Relation\u5B9A\u4E49\u7684\u5B57\u7B26\u4E32\u957F\u5EA6\u4E0D\u957F\u4E8E".concat(env_1.STRING_LITERAL_MAX_LENGTH, "\uFF08").concat(filename, "\uFF0C").concat(ele.literal.text, "\uFF09"));
|
|
559
|
-
|
|
583
|
+
return ele.literal.text;
|
|
584
|
+
})), false));
|
|
560
585
|
}
|
|
561
586
|
var entityLc = (0, string_1.firstLetterLowerCase)(moduleName);
|
|
562
587
|
var relationEntityName = "User".concat(moduleName);
|
|
@@ -569,7 +594,9 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
569
594
|
_d[relationEntityName] = {
|
|
570
595
|
schemaAttrs: relationSchemaAttrs,
|
|
571
596
|
sourceFile: sourceFile,
|
|
572
|
-
|
|
597
|
+
enumAttributes: {
|
|
598
|
+
relation: relationValues,
|
|
599
|
+
},
|
|
573
600
|
actionType: 'excludeUpdate',
|
|
574
601
|
additionalImports: [
|
|
575
602
|
factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("Relation"))])), factory.createStringLiteral("../".concat(moduleName, "/Schema")), undefined)
|
|
@@ -611,58 +638,27 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
611
638
|
else if (beforeSchema) {
|
|
612
639
|
// 本地规定的一些形状定义,直接使用
|
|
613
640
|
pushStatementIntoSchemaAst(moduleName, node, sourceFile);
|
|
614
|
-
if (ts.isUnionTypeNode(node.type) && ts.isLiteralTypeNode(node.type.types[0]) && ts.isStringLiteral(node.type.types[0].literal)) {
|
|
615
|
-
// 本文件内定义的枚举类型
|
|
616
|
-
localEnumStringTypes.push(node.name.text);
|
|
617
|
-
node.type.types.forEach(function (ele) {
|
|
618
|
-
(0, assert_1.default)(ts.isLiteralTypeNode(ele) && ts.isStringLiteral(ele.literal), "\u300C".concat(filename, "\u300D\u4E0D\u652F\u6301\u6DF7\u5408\u578B\u7684\u5E38\u91CF\u5B9A\u4E49\u300C").concat(node.name.text, "\u300D"));
|
|
619
|
-
(0, assert_1.default)(ele.literal.text.length < env_1.STRING_LITERAL_MAX_LENGTH, "\u300C".concat(filename, "\u300D\u4E2D\u5B9A\u4E49\u7684\u5E38\u91CF\u679A\u4E3E\u300C").concat(node.name.text, "\u300D\u7684\u5B57\u7B26\u4E32\u957F\u5EA6\u5E94\u5C0F\u4E8E").concat(env_1.STRING_LITERAL_MAX_LENGTH));
|
|
620
|
-
});
|
|
621
|
-
}
|
|
622
641
|
}
|
|
623
642
|
}
|
|
624
643
|
if (ts.isVariableStatement(node)) {
|
|
625
644
|
var declarations = node.declarationList.declarations;
|
|
626
645
|
declarations.forEach(function (declaration) {
|
|
627
|
-
if (ts.isIdentifier(declaration.
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
if (declaration2_1.getSourceFile() === sourceFile) {
|
|
638
|
-
// pushStatementIntoActionAst(moduleName, <ts.TypeAliasDeclaration>declaration2, sourceFile);
|
|
639
|
-
}
|
|
640
|
-
symbol = checker.getSymbolAtLocation(stateNode.typeName);
|
|
641
|
-
declaration2_1 = symbol.getDeclarations()[0];
|
|
642
|
-
if (declaration2_1.getSourceFile() === sourceFile) {
|
|
643
|
-
// 检查state的定义合法
|
|
644
|
-
(0, assert_1.default)(ts.isTypeAliasDeclaration(declaration2_1) && ts.isUnionTypeNode(declaration2_1.type), "\u300C".concat(filename, "\u300DState\u300C").concat(declaration2_1.name, "\u300D\u7684\u5B9A\u4E49\u53EA\u80FD\u662F\u6216\u7ED3\u70B9"));
|
|
645
|
-
declaration2_1.type.types.forEach(function (type) {
|
|
646
|
-
(0, assert_1.default)(ts.isLiteralTypeNode(type) && ts.isStringLiteral(type.literal), "\u300C".concat(filename, "\u300DState\u300C").concat(declaration2_1.name, "\u300D\u7684\u5B9A\u4E49\u53EA\u80FD\u662F\u5B57\u7B26\u4E32"));
|
|
647
|
-
(0, assert_1.default)(type.literal.text.length < env_1.STRING_LITERAL_MAX_LENGTH, "\u300C".concat(filename, "\u300DState\u300C").concat(type.literal.text, "\u300D\u7684\u957F\u5EA6\u5927\u4E8E\u300C").concat(env_1.STRING_LITERAL_MAX_LENGTH, "\u300D"));
|
|
648
|
-
});
|
|
649
|
-
/* pushStatementIntoActionAst(moduleName,
|
|
650
|
-
factory.updateTypeAliasDeclaration(
|
|
651
|
-
declaration2,
|
|
652
|
-
declaration2.decorators,
|
|
653
|
-
[factory.createModifier(ts.SyntaxKind.ExportKeyword)],
|
|
654
|
-
declaration2.name,
|
|
655
|
-
declaration2.typeParameters,
|
|
656
|
-
declaration2.type
|
|
657
|
-
),
|
|
658
|
-
sourceFile); */
|
|
659
|
-
}
|
|
660
|
-
}
|
|
646
|
+
if (declaration.type && ts.isTypeReferenceNode(declaration.type) && ts.isIdentifier(declaration.type.typeName) && declaration.type.typeName.text === 'ActionDef') {
|
|
647
|
+
checkActionDefNameConsistent(filename, declaration);
|
|
648
|
+
var typeArguments = declaration.type.typeArguments;
|
|
649
|
+
(0, assert_1.default)(typeArguments.length === 2);
|
|
650
|
+
var _a = tslib_1.__read(typeArguments, 2), actionNode = _a[0], stateNode = _a[1];
|
|
651
|
+
(0, assert_1.default)(ts.isTypeReferenceNode(actionNode));
|
|
652
|
+
(0, assert_1.default)(ts.isTypeReferenceNode(stateNode));
|
|
653
|
+
(0, assert_1.default)(getStringEnumValues(filename, program, 'action', actionNode), "\u6587\u4EF6".concat(filename, "\u4E2D\u7684action").concat(actionNode.typeName.text, "\u5B9A\u4E49\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B"));
|
|
654
|
+
var enumStateValues = getStringEnumValues(filename, program, 'state', stateNode);
|
|
655
|
+
(0, assert_1.default)(enumStateValues, "\u6587\u4EF6".concat(filename, "\u4E2D\u7684state").concat(stateNode.typeName.text, "\u5B9A\u4E49\u4E0D\u662F\u5B57\u7B26\u4E32\u7C7B\u578B"));
|
|
661
656
|
pushStatementIntoActionAst(moduleName, node, sourceFile);
|
|
657
|
+
(0, assert_1.default)(ts.isIdentifier(declaration.name));
|
|
662
658
|
var adName = declaration.name.text.slice(0, declaration.name.text.length - 9);
|
|
663
659
|
var attr = adName.concat('State');
|
|
664
|
-
schemaAttrs.push(factory.createPropertySignature(undefined,
|
|
665
|
-
|
|
660
|
+
schemaAttrs.push(factory.createPropertySignature(undefined, (0, string_1.firstLetterLowerCase)(attr), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(attr)));
|
|
661
|
+
enumAttributes[(0, string_1.firstLetterLowerCase)(attr)] = enumStateValues;
|
|
666
662
|
}
|
|
667
663
|
else if (declaration.type && (ts.isArrayTypeNode(declaration.type)
|
|
668
664
|
&& ts.isTypeReferenceNode(declaration.type.elementType)
|
|
@@ -783,13 +779,13 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
783
779
|
});
|
|
784
780
|
indexes = declaration.initializer;
|
|
785
781
|
}
|
|
786
|
-
else if (ts.isTypeReferenceNode(declaration.type) && ts.isIdentifier(declaration.type.typeName) && declaration.type.typeName.text === 'LocaleDef') {
|
|
782
|
+
else if (declaration.type && ts.isTypeReferenceNode(declaration.type) && ts.isIdentifier(declaration.type.typeName) && declaration.type.typeName.text === 'LocaleDef') {
|
|
787
783
|
// locale定义
|
|
788
784
|
var type = declaration.type, initializer = declaration.initializer;
|
|
789
785
|
(0, assert_1.default)(ts.isObjectLiteralExpression(initializer));
|
|
790
786
|
var properties = initializer.properties;
|
|
791
787
|
(0, assert_1.default)(properties.length > 0, "".concat(filename, "\u81F3\u5C11\u9700\u8981\u6709\u4E00\u79CDlocale\u5B9A\u4E49"));
|
|
792
|
-
var allEnumStringAttrs =
|
|
788
|
+
var allEnumStringAttrs = Object.keys(enumAttributes);
|
|
793
789
|
var typeArguments = type.typeArguments;
|
|
794
790
|
(0, assert_1.default)(typeArguments &&
|
|
795
791
|
ts.isTypeReferenceNode(typeArguments[0])
|
|
@@ -831,7 +827,7 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
831
827
|
}
|
|
832
828
|
localeDef = initializer;
|
|
833
829
|
}
|
|
834
|
-
else if (ts.isTypeReferenceNode(declaration.type) && ts.isIdentifier(declaration.type.typeName) && declaration.type.typeName.text === 'Configuration') {
|
|
830
|
+
else if (declaration.type && ts.isTypeReferenceNode(declaration.type) && ts.isIdentifier(declaration.type.typeName) && declaration.type.typeName.text === 'Configuration') {
|
|
835
831
|
(0, assert_1.default)(!hasActionDef, "".concat(moduleName, "\u4E2D\u7684Configuration\u5B9A\u4E49\u5728Action\u4E4B\u540E"));
|
|
836
832
|
(0, assert_1.default)(ts.isObjectLiteralExpression(declaration.initializer));
|
|
837
833
|
var properties = declaration.initializer.properties;
|
|
@@ -878,7 +874,7 @@ function analyzeEntity(filename, path, program, relativePath) {
|
|
|
878
874
|
actionType: actionType,
|
|
879
875
|
static: _static,
|
|
880
876
|
hasRelationDef: hasRelationDef,
|
|
881
|
-
|
|
877
|
+
enumAttributes: enumAttributes,
|
|
882
878
|
additionalImports: additionalImports,
|
|
883
879
|
};
|
|
884
880
|
if (hasFulltextIndex) {
|
|
@@ -2898,7 +2894,7 @@ function outputAction(outputDir, printer) {
|
|
|
2898
2894
|
(0, fs_1.writeFileSync)(fileName, result, { flag: 'w' });
|
|
2899
2895
|
}
|
|
2900
2896
|
function constructAttributes(entity) {
|
|
2901
|
-
var _a = Schema[entity], schemaAttrs = _a.schemaAttrs,
|
|
2897
|
+
var _a = Schema[entity], schemaAttrs = _a.schemaAttrs, enumAttributes = _a.enumAttributes;
|
|
2902
2898
|
var _b = ManyToOne, _c = entity, manyToOneSet = _b[_c];
|
|
2903
2899
|
var result = [];
|
|
2904
2900
|
schemaAttrs.forEach(function (attr) {
|
|
@@ -2983,8 +2979,8 @@ function constructAttributes(entity) {
|
|
|
2983
2979
|
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("ref")), factory.createPropertyAssignment(factory.createIdentifier("ref"), factory.createStringLiteral((0, string_1.firstLetterLowerCase)(text2_6))));
|
|
2984
2980
|
}
|
|
2985
2981
|
else {
|
|
2986
|
-
if (
|
|
2987
|
-
attrAssignments.push(factory.createPropertyAssignment(
|
|
2982
|
+
if (enumAttributes && enumAttributes[name.text]) {
|
|
2983
|
+
attrAssignments.push(factory.createPropertyAssignment('type', factory.createStringLiteral("enum")), factory.createPropertyAssignment('enumeration', factory.createArrayLiteralExpression(enumAttributes[name.text].map(function (ele) { return factory.createStringLiteral(ele); }))));
|
|
2988
2984
|
}
|
|
2989
2985
|
else {
|
|
2990
2986
|
// todo 引用的非string定义,目前没有处理int类型的引用,等遇到了再处理
|
|
@@ -3002,7 +2998,8 @@ function constructAttributes(entity) {
|
|
|
3002
2998
|
if (ts.isUnionTypeNode(type)) {
|
|
3003
2999
|
if (ts.isLiteralTypeNode(type.types[0])) {
|
|
3004
3000
|
if (ts.isStringLiteral(type.types[0].literal)) {
|
|
3005
|
-
|
|
3001
|
+
(0, assert_1.default)(enumAttributes && enumAttributes[name.text]);
|
|
3002
|
+
attrAssignments.push(factory.createPropertyAssignment('type', factory.createStringLiteral("enum")), factory.createPropertyAssignment('enumeration', factory.createArrayLiteralExpression(enumAttributes[name.text].map(function (ele) { return factory.createStringLiteral(ele); }))));
|
|
3006
3003
|
}
|
|
3007
3004
|
else {
|
|
3008
3005
|
(0, assert_1.default)(ts.isNumericLiteral(type.types[0].literal));
|
|
@@ -583,29 +583,32 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
583
583
|
else {
|
|
584
584
|
// 这里优化一下,如果filter上有id,直接更新成根据entityId来过滤
|
|
585
585
|
// 除了性能原因之外,还因为会制造出user: { id: xxx }这样的查询,general中不允许这样查询的出现
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
586
|
+
// 暂时先封掉user上的相关更新条件,会制造出连接表上的update
|
|
587
|
+
if (entity !== 'user') {
|
|
588
|
+
if (filter) {
|
|
589
|
+
if (filter.id && Object.keys(filter).length === 1) {
|
|
590
|
+
Object.assign(otm, {
|
|
591
|
+
filter: (0, filter_1.addFilterSegment)({
|
|
592
|
+
entity: entity,
|
|
593
|
+
entityId: filter.id,
|
|
594
|
+
}, filterOtm),
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
else {
|
|
598
|
+
Object.assign(otm, {
|
|
599
|
+
filter: (0, filter_1.addFilterSegment)((_a = {},
|
|
600
|
+
_a[entity] = filter,
|
|
601
|
+
_a), filterOtm),
|
|
602
|
+
});
|
|
603
|
+
}
|
|
594
604
|
}
|
|
595
|
-
|
|
596
|
-
Object.assign(
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
_a), filterOtm),
|
|
605
|
+
if (action === 'remove' && actionOtm === 'update') {
|
|
606
|
+
Object.assign(dataOtm, {
|
|
607
|
+
entity: null,
|
|
608
|
+
entityId: null,
|
|
600
609
|
});
|
|
601
610
|
}
|
|
602
611
|
}
|
|
603
|
-
if (action === 'remove' && actionOtm === 'update') {
|
|
604
|
-
Object.assign(dataOtm, {
|
|
605
|
-
entity: null,
|
|
606
|
-
entityId: null,
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
614
|
else {
|
|
@@ -649,20 +652,23 @@ var CascadeStore = /** @class */ (function (_super) {
|
|
|
649
652
|
// 这里优化一下,如果filter上有id,直接更新成根据entityId来过滤
|
|
650
653
|
// 除了性能原因之外,还因为会制造出user: { id: xxx }这样的查询,general中不允许这样查询的出现
|
|
651
654
|
// 绝大多数情况都是id,但也有可能update可能出现上层filter不是根据id的(userEntityGrant的过期触发的wechatQrCode的过期,见general中的userEntityGrant的trigger)
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
655
|
+
// 暂时先封掉user上的连接,以避免生成连接表更新
|
|
656
|
+
if (entity !== 'user') {
|
|
657
|
+
if (filter) {
|
|
658
|
+
if (filter.id && Object.keys(filter).length === 1) {
|
|
659
|
+
Object.assign(otm, {
|
|
660
|
+
filter: (0, filter_1.addFilterSegment)((_d = {},
|
|
661
|
+
_d[foreignKey_2] = filter.id,
|
|
662
|
+
_d), filterOtm),
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
else {
|
|
666
|
+
Object.assign(otm, {
|
|
667
|
+
filter: (0, filter_1.addFilterSegment)((_e = {},
|
|
668
|
+
_e[foreignKey_2.slice(0, foreignKey_2.length - 2)] = filter,
|
|
669
|
+
_e), filterOtm),
|
|
670
|
+
});
|
|
671
|
+
}
|
|
666
672
|
}
|
|
667
673
|
}
|
|
668
674
|
if (action === 'remove' && actionOtm === 'update') {
|
package/lib/store/checker.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { AuthDefDict, Checker, EntityDict, OperateOption, SelectOption, StorageS
|
|
|
2
2
|
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
3
|
import { AsyncContext } from "./AsyncRowStore";
|
|
4
4
|
import { SyncContext } from './SyncRowStore';
|
|
5
|
-
export declare function translateCheckerInAsyncContext<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>>(checker: Checker<ED,
|
|
6
|
-
fn: Trigger<ED,
|
|
5
|
+
export declare function translateCheckerInAsyncContext<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends AsyncContext<ED>>(checker: Checker<ED, T, Cxt>): {
|
|
6
|
+
fn: Trigger<ED, T, Cxt>['fn'];
|
|
7
7
|
when: 'before' | 'after';
|
|
8
8
|
};
|
|
9
9
|
export declare function translateCheckerInSyncContext<ED extends EntityDict & BaseEntityDict, T extends keyof ED, Cxt extends SyncContext<ED>>(checker: Checker<ED, T, Cxt>): {
|