oak-domain 2.6.2 → 2.6.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/base-app-domain/Modi/Storage.js +2 -4
- package/lib/base-app-domain/User/Storage.js +2 -4
- package/lib/compiler/schemalBuilder.js +92 -89
- package/lib/entities/Modi.js +1 -0
- package/lib/entities/ModiEntity.js +1 -0
- package/lib/entities/Oper.js +1 -0
- package/lib/entities/OperEntity.js +1 -0
- package/lib/entities/User.js +1 -0
- package/lib/entities/UserEntityGrant.js +1 -0
- package/lib/store/AsyncRowStore.js +40 -42
- package/lib/store/CascadeStore.js +39 -33
- package/lib/store/checker.d.ts +2 -2
- package/lib/store/checker.js +516 -136
- package/lib/store/filter.js +7 -15
- package/lib/types/Auth.d.ts +10 -10
- package/lib/types/DataType.d.ts +4 -1
- package/lib/types/DataType.js +2 -1
- package/lib/types/Exception.d.ts +6 -0
- package/lib/types/Exception.js +25 -1
- package/lib/types/Locale.d.ts +1 -0
- package/lib/types/Polyfill.d.ts +1 -0
- package/lib/types/Storage.d.ts +1 -0
- package/lib/types/Style.d.ts +11 -0
- package/lib/types/Style.js +2 -0
- package/lib/types/Timer.d.ts +3 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/lib/types/schema/DataTypes.d.ts +2 -0
- package/lib/utils/SimpleConnector.js +6 -5
- package/lib/utils/mask.d.ts +5 -0
- package/lib/utils/mask.js +35 -0
- package/lib/utils/money.d.ts +5 -0
- package/lib/utils/money.js +24 -0
- package/lib/utils/validator.d.ts +4 -2
- package/lib/utils/validator.js +8 -3
- package/package.json +3 -2
- package/src/entities/Modi.ts +1 -0
- package/src/entities/ModiEntity.ts +1 -0
- package/src/entities/Oper.ts +1 -0
- package/src/entities/OperEntity.ts +1 -0
- package/src/entities/User.ts +1 -0
- package/src/entities/UserEntityGrant.ts +1 -0
- package/lib/utils/cron.d.ts +0 -1
- package/lib/utils/cron.js +0 -18
|
@@ -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) {
|
|
@@ -1127,7 +1123,8 @@ function constructFilter(statements, entity) {
|
|
|
1127
1123
|
case 'Int':
|
|
1128
1124
|
case 'Uint':
|
|
1129
1125
|
case 'Float':
|
|
1130
|
-
case 'Double':
|
|
1126
|
+
case 'Double':
|
|
1127
|
+
case 'Price': {
|
|
1131
1128
|
type2 = factory.createTypeReferenceNode(factory.createIdentifier('Q_NumberValue'));
|
|
1132
1129
|
break;
|
|
1133
1130
|
}
|
|
@@ -1280,7 +1277,8 @@ function constructProjection(statements, entity) {
|
|
|
1280
1277
|
case 'File':
|
|
1281
1278
|
case 'SingleGeo':
|
|
1282
1279
|
case 'Geo':
|
|
1283
|
-
case 'Object':
|
|
1280
|
+
case 'Object':
|
|
1281
|
+
case 'Price': {
|
|
1284
1282
|
properties.push([name_4, false]);
|
|
1285
1283
|
break;
|
|
1286
1284
|
}
|
|
@@ -1643,7 +1641,8 @@ function constructSorter(statements, entity) {
|
|
|
1643
1641
|
case 'Boolean':
|
|
1644
1642
|
case 'Datetime':
|
|
1645
1643
|
case 'Image':
|
|
1646
|
-
case 'File':
|
|
1644
|
+
case 'File':
|
|
1645
|
+
case 'Price': {
|
|
1647
1646
|
type2 = factory.createKeywordTypeNode(ts.SyntaxKind.NumberKeyword);
|
|
1648
1647
|
break;
|
|
1649
1648
|
}
|
|
@@ -2662,6 +2661,7 @@ var initialStatements = function () { return [
|
|
|
2662
2661
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Text')),
|
|
2663
2662
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Datetime')),
|
|
2664
2663
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('File')),
|
|
2664
|
+
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Price')),
|
|
2665
2665
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('Image')),
|
|
2666
2666
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('PrimaryKey')),
|
|
2667
2667
|
factory.createImportSpecifier(false, undefined, factory.createIdentifier('ForeignKey')),
|
|
@@ -2898,7 +2898,7 @@ function outputAction(outputDir, printer) {
|
|
|
2898
2898
|
(0, fs_1.writeFileSync)(fileName, result, { flag: 'w' });
|
|
2899
2899
|
}
|
|
2900
2900
|
function constructAttributes(entity) {
|
|
2901
|
-
var _a = Schema[entity], schemaAttrs = _a.schemaAttrs,
|
|
2901
|
+
var _a = Schema[entity], schemaAttrs = _a.schemaAttrs, enumAttributes = _a.enumAttributes;
|
|
2902
2902
|
var _b = ManyToOne, _c = entity, manyToOneSet = _b[_c];
|
|
2903
2903
|
var result = [];
|
|
2904
2904
|
schemaAttrs.forEach(function (attr) {
|
|
@@ -2938,15 +2938,13 @@ function constructAttributes(entity) {
|
|
|
2938
2938
|
], true)));
|
|
2939
2939
|
break;
|
|
2940
2940
|
}
|
|
2941
|
-
case '
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
case 'Double': {
|
|
2949
|
-
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("double")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([
|
|
2941
|
+
case 'Double':
|
|
2942
|
+
case 'Float':
|
|
2943
|
+
case 'Decimal': {
|
|
2944
|
+
if (['Double', 'Float'].includes(text)) {
|
|
2945
|
+
console.warn("".concat(entity, "\u5BF9\u8C61\u4E2D\u8FD8\u6709").concat(text, "\u7C7B\u578B\u5B9A\u4E49\uFF0C\u73B0\u5728\u7EDF\u4E00\u7528Decimal\u8FDB\u884C\u5B58\u50A8"));
|
|
2946
|
+
}
|
|
2947
|
+
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("decimal")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([
|
|
2950
2948
|
factory.createPropertyAssignment(factory.createIdentifier("precision"), factory.createNumericLiteral(typeArguments[0].literal.text)),
|
|
2951
2949
|
factory.createPropertyAssignment(factory.createIdentifier("scale"), factory.createNumericLiteral(typeArguments[1].literal.text))
|
|
2952
2950
|
], true)));
|
|
@@ -2956,6 +2954,10 @@ function constructAttributes(entity) {
|
|
|
2956
2954
|
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("boolean")));
|
|
2957
2955
|
break;
|
|
2958
2956
|
}
|
|
2957
|
+
case 'Price': {
|
|
2958
|
+
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("money")));
|
|
2959
|
+
break;
|
|
2960
|
+
}
|
|
2959
2961
|
case 'Datetime': {
|
|
2960
2962
|
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("datetime")));
|
|
2961
2963
|
break;
|
|
@@ -2983,8 +2985,8 @@ function constructAttributes(entity) {
|
|
|
2983
2985
|
attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("ref")), factory.createPropertyAssignment(factory.createIdentifier("ref"), factory.createStringLiteral((0, string_1.firstLetterLowerCase)(text2_6))));
|
|
2984
2986
|
}
|
|
2985
2987
|
else {
|
|
2986
|
-
if (
|
|
2987
|
-
attrAssignments.push(factory.createPropertyAssignment(
|
|
2988
|
+
if (enumAttributes && enumAttributes[name.text]) {
|
|
2989
|
+
attrAssignments.push(factory.createPropertyAssignment('type', factory.createStringLiteral("enum")), factory.createPropertyAssignment('enumeration', factory.createArrayLiteralExpression(enumAttributes[name.text].map(function (ele) { return factory.createStringLiteral(ele); }))));
|
|
2988
2990
|
}
|
|
2989
2991
|
else {
|
|
2990
2992
|
// todo 引用的非string定义,目前没有处理int类型的引用,等遇到了再处理
|
|
@@ -3002,7 +3004,8 @@ function constructAttributes(entity) {
|
|
|
3002
3004
|
if (ts.isUnionTypeNode(type)) {
|
|
3003
3005
|
if (ts.isLiteralTypeNode(type.types[0])) {
|
|
3004
3006
|
if (ts.isStringLiteral(type.types[0].literal)) {
|
|
3005
|
-
|
|
3007
|
+
(0, assert_1.default)(enumAttributes && enumAttributes[name.text]);
|
|
3008
|
+
attrAssignments.push(factory.createPropertyAssignment('type', factory.createStringLiteral("enum")), factory.createPropertyAssignment('enumeration', factory.createArrayLiteralExpression(enumAttributes[name.text].map(function (ele) { return factory.createStringLiteral(ele); }))));
|
|
3006
3009
|
}
|
|
3007
3010
|
else {
|
|
3008
3011
|
(0, assert_1.default)(ts.isNumericLiteral(type.types[0].literal));
|
package/lib/entities/Modi.js
CHANGED
package/lib/entities/Oper.js
CHANGED
package/lib/entities/User.js
CHANGED
|
@@ -64,93 +64,91 @@ var AsyncContext = /** @class */ (function () {
|
|
|
64
64
|
};
|
|
65
65
|
AsyncContext.prototype.commit = function () {
|
|
66
66
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
67
|
-
var
|
|
68
|
-
var e_1,
|
|
69
|
-
return tslib_1.__generator(this, function (
|
|
70
|
-
switch (
|
|
67
|
+
var commitEvents, commitEvents_1, commitEvents_1_1, e, e_1_1;
|
|
68
|
+
var e_1, _a;
|
|
69
|
+
return tslib_1.__generator(this, function (_b) {
|
|
70
|
+
switch (_b.label) {
|
|
71
71
|
case 0:
|
|
72
|
-
if (!this.uuid) return [3 /*break*/,
|
|
72
|
+
if (!this.uuid) return [3 /*break*/, 9];
|
|
73
73
|
return [4 /*yield*/, this.rowStore.commit(this.uuid)];
|
|
74
74
|
case 1:
|
|
75
|
-
|
|
75
|
+
_b.sent();
|
|
76
76
|
this.uuid = undefined;
|
|
77
|
-
|
|
77
|
+
commitEvents = this.events.commit;
|
|
78
|
+
this.resetEvents();
|
|
79
|
+
_b.label = 2;
|
|
78
80
|
case 2:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
82
|
+
commitEvents_1 = tslib_1.__values(commitEvents), commitEvents_1_1 = commitEvents_1.next();
|
|
83
|
+
_b.label = 3;
|
|
82
84
|
case 3:
|
|
83
|
-
if (!!
|
|
84
|
-
e =
|
|
85
|
+
if (!!commitEvents_1_1.done) return [3 /*break*/, 6];
|
|
86
|
+
e = commitEvents_1_1.value;
|
|
85
87
|
return [4 /*yield*/, e()];
|
|
86
88
|
case 4:
|
|
87
|
-
|
|
88
|
-
|
|
89
|
+
_b.sent();
|
|
90
|
+
_b.label = 5;
|
|
89
91
|
case 5:
|
|
90
|
-
|
|
92
|
+
commitEvents_1_1 = commitEvents_1.next();
|
|
91
93
|
return [3 /*break*/, 3];
|
|
92
94
|
case 6: return [3 /*break*/, 9];
|
|
93
95
|
case 7:
|
|
94
|
-
e_1_1 =
|
|
96
|
+
e_1_1 = _b.sent();
|
|
95
97
|
e_1 = { error: e_1_1 };
|
|
96
98
|
return [3 /*break*/, 9];
|
|
97
99
|
case 8:
|
|
98
100
|
try {
|
|
99
|
-
if (
|
|
101
|
+
if (commitEvents_1_1 && !commitEvents_1_1.done && (_a = commitEvents_1.return)) _a.call(commitEvents_1);
|
|
100
102
|
}
|
|
101
103
|
finally { if (e_1) throw e_1.error; }
|
|
102
104
|
return [7 /*endfinally*/];
|
|
103
|
-
case 9:
|
|
104
|
-
this.resetEvents();
|
|
105
|
-
_d.label = 10;
|
|
106
|
-
case 10: return [2 /*return*/];
|
|
105
|
+
case 9: return [2 /*return*/];
|
|
107
106
|
}
|
|
108
107
|
});
|
|
109
108
|
});
|
|
110
109
|
};
|
|
111
110
|
AsyncContext.prototype.rollback = function () {
|
|
112
111
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
113
|
-
var
|
|
114
|
-
var e_2,
|
|
115
|
-
return tslib_1.__generator(this, function (
|
|
116
|
-
switch (
|
|
112
|
+
var rollbackEvents, rollbackEvents_1, rollbackEvents_1_1, e, e_2_1;
|
|
113
|
+
var e_2, _a;
|
|
114
|
+
return tslib_1.__generator(this, function (_b) {
|
|
115
|
+
switch (_b.label) {
|
|
117
116
|
case 0:
|
|
118
|
-
if (!this.uuid) return [3 /*break*/,
|
|
117
|
+
if (!this.uuid) return [3 /*break*/, 9];
|
|
119
118
|
return [4 /*yield*/, this.rowStore.rollback(this.uuid)];
|
|
120
119
|
case 1:
|
|
121
|
-
|
|
120
|
+
_b.sent();
|
|
122
121
|
// console.log('rollback', this.uuid);
|
|
123
122
|
this.uuid = undefined;
|
|
124
|
-
|
|
123
|
+
rollbackEvents = this.events.rollback;
|
|
124
|
+
this.resetEvents();
|
|
125
|
+
_b.label = 2;
|
|
125
126
|
case 2:
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
_b.trys.push([2, 7, 8, 9]);
|
|
128
|
+
rollbackEvents_1 = tslib_1.__values(rollbackEvents), rollbackEvents_1_1 = rollbackEvents_1.next();
|
|
129
|
+
_b.label = 3;
|
|
129
130
|
case 3:
|
|
130
|
-
if (!!
|
|
131
|
-
e =
|
|
131
|
+
if (!!rollbackEvents_1_1.done) return [3 /*break*/, 6];
|
|
132
|
+
e = rollbackEvents_1_1.value;
|
|
132
133
|
return [4 /*yield*/, e()];
|
|
133
134
|
case 4:
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
_b.sent();
|
|
136
|
+
_b.label = 5;
|
|
136
137
|
case 5:
|
|
137
|
-
|
|
138
|
+
rollbackEvents_1_1 = rollbackEvents_1.next();
|
|
138
139
|
return [3 /*break*/, 3];
|
|
139
140
|
case 6: return [3 /*break*/, 9];
|
|
140
141
|
case 7:
|
|
141
|
-
e_2_1 =
|
|
142
|
+
e_2_1 = _b.sent();
|
|
142
143
|
e_2 = { error: e_2_1 };
|
|
143
144
|
return [3 /*break*/, 9];
|
|
144
145
|
case 8:
|
|
145
146
|
try {
|
|
146
|
-
if (
|
|
147
|
+
if (rollbackEvents_1_1 && !rollbackEvents_1_1.done && (_a = rollbackEvents_1.return)) _a.call(rollbackEvents_1);
|
|
147
148
|
}
|
|
148
149
|
finally { if (e_2) throw e_2.error; }
|
|
149
150
|
return [7 /*endfinally*/];
|
|
150
|
-
case 9:
|
|
151
|
-
this.resetEvents();
|
|
152
|
-
_d.label = 10;
|
|
153
|
-
case 10: return [2 /*return*/];
|
|
151
|
+
case 9: return [2 /*return*/];
|
|
154
152
|
}
|
|
155
153
|
});
|
|
156
154
|
});
|