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.
Files changed (44) hide show
  1. package/lib/base-app-domain/Modi/Storage.js +2 -4
  2. package/lib/base-app-domain/User/Storage.js +2 -4
  3. package/lib/compiler/schemalBuilder.js +92 -89
  4. package/lib/entities/Modi.js +1 -0
  5. package/lib/entities/ModiEntity.js +1 -0
  6. package/lib/entities/Oper.js +1 -0
  7. package/lib/entities/OperEntity.js +1 -0
  8. package/lib/entities/User.js +1 -0
  9. package/lib/entities/UserEntityGrant.js +1 -0
  10. package/lib/store/AsyncRowStore.js +40 -42
  11. package/lib/store/CascadeStore.js +39 -33
  12. package/lib/store/checker.d.ts +2 -2
  13. package/lib/store/checker.js +516 -136
  14. package/lib/store/filter.js +7 -15
  15. package/lib/types/Auth.d.ts +10 -10
  16. package/lib/types/DataType.d.ts +4 -1
  17. package/lib/types/DataType.js +2 -1
  18. package/lib/types/Exception.d.ts +6 -0
  19. package/lib/types/Exception.js +25 -1
  20. package/lib/types/Locale.d.ts +1 -0
  21. package/lib/types/Polyfill.d.ts +1 -0
  22. package/lib/types/Storage.d.ts +1 -0
  23. package/lib/types/Style.d.ts +11 -0
  24. package/lib/types/Style.js +2 -0
  25. package/lib/types/Timer.d.ts +3 -2
  26. package/lib/types/index.d.ts +1 -0
  27. package/lib/types/index.js +1 -0
  28. package/lib/types/schema/DataTypes.d.ts +2 -0
  29. package/lib/utils/SimpleConnector.js +6 -5
  30. package/lib/utils/mask.d.ts +5 -0
  31. package/lib/utils/mask.js +35 -0
  32. package/lib/utils/money.d.ts +5 -0
  33. package/lib/utils/money.js +24 -0
  34. package/lib/utils/validator.d.ts +4 -2
  35. package/lib/utils/validator.js +8 -3
  36. package/package.json +3 -2
  37. package/src/entities/Modi.ts +1 -0
  38. package/src/entities/ModiEntity.ts +1 -0
  39. package/src/entities/Oper.ts +1 -0
  40. package/src/entities/OperEntity.ts +1 -0
  41. package/src/entities/User.ts +1 -0
  42. package/src/entities/UserEntityGrant.ts +1 -0
  43. package/lib/utils/cron.d.ts +0 -1
  44. package/lib/utils/cron.js +0 -18
@@ -38,10 +38,8 @@ exports.desc = {
38
38
  type: "object"
39
39
  },
40
40
  iState: {
41
- type: "varchar",
42
- params: {
43
- length: 24
44
- }
41
+ type: "enum",
42
+ enumeration: ["active", "applied", "abandoned"]
45
43
  }
46
44
  },
47
45
  actionType: "crud",
@@ -25,10 +25,8 @@ exports.desc = {
25
25
  ref: "user"
26
26
  },
27
27
  userState: {
28
- type: "varchar",
29
- params: {
30
- length: 24
31
- }
28
+ type: "enum",
29
+ enumeration: ["normal", "merged"]
32
30
  }
33
31
  },
34
32
  actionType: "crud",
@@ -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 getStringLiteral(ele); });
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 = getStringLiteral(type);
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 enumStringAttrs = [];
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
- if (localEnumStringTypes.includes(type.typeName.text)) {
423
- enumStringAttrs.push(name.text);
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
- if (ts.isLiteralTypeNode(types[0]) && ts.isStringLiteral(types[0].literal)) {
453
- enumStringAttrs.push(name.text);
454
- types.forEach(function (ele) {
455
- (0, assert_1.default)(ts.isLiteralTypeNode(ele) && ts.isStringLiteral(ele.literal), "\u300C".concat(filename, "\u300D\u4E0D\u652F\u6301\u6DF7\u5408\u578B\u7684\u679A\u4E3E\u5C5E\u6027\u5B9A\u4E49\u300C").concat(attrName, "\u300D"));
456
- (0, assert_1.default)(ele.literal.text.length < env_1.STRING_LITERAL_MAX_LENGTH, "\u300C".concat(filename, "\u300D\u4E2D\u5B9A\u4E49\u7684\u5C5E\u6027\u679A\u4E3E\u300C").concat(attrName, "\u300D\u7684\u5B57\u7B26\u4E32\u957F\u5EA6\u5E94\u5C0F\u4E8E").concat(env_1.STRING_LITERAL_MAX_LENGTH));
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.forEach(function (ele) {
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
- enumStringAttrs: ['relation'],
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.name) && declaration.name.text.endsWith('ActionDef')) {
628
- if (declaration.type && ts.isTypeReferenceNode(declaration.type) && ts.isIdentifier(declaration.type.typeName) && declaration.type.typeName.text === 'ActionDef') {
629
- // 是显示的actionDef定义
630
- checkActionDefNameConsistent(filename, declaration);
631
- var typeArguments = declaration.type.typeArguments;
632
- (0, assert_1.default)(typeArguments.length === 2);
633
- var _a = tslib_1.__read(typeArguments, 2), actionNode = _a[0], stateNode = _a[1];
634
- var checker = program.getTypeChecker();
635
- var symbol = checker.getSymbolAtLocation(actionNode.typeName);
636
- var declaration2_1 = symbol.getDeclarations()[0];
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, factory.createIdentifier((0, string_1.firstLetterLowerCase)(attr)), factory.createToken(ts.SyntaxKind.QuestionToken), factory.createTypeReferenceNode(factory.createIdentifier(attr))));
665
- states.push((0, string_1.firstLetterLowerCase)(attr));
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 = enumStringAttrs.concat(states);
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
- enumStringAttrs: enumStringAttrs.concat(states),
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, enumStringAttrs = _a.enumStringAttrs;
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 'Float': {
2942
- attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("float")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([
2943
- factory.createPropertyAssignment(factory.createIdentifier("precision"), factory.createNumericLiteral(typeArguments[0].literal.text)),
2944
- factory.createPropertyAssignment(factory.createIdentifier("scale"), factory.createNumericLiteral(typeArguments[1].literal.text))
2945
- ], true)));
2946
- break;
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 (enumStringAttrs && enumStringAttrs.includes(name.text)) {
2987
- attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("varchar")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([factory.createPropertyAssignment(factory.createIdentifier("length"), factory.createNumericLiteral(env_1.STRING_LITERAL_MAX_LENGTH))], true)));
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
- attrAssignments.push(factory.createPropertyAssignment(factory.createIdentifier("type"), factory.createStringLiteral("varchar")), factory.createPropertyAssignment(factory.createIdentifier("params"), factory.createObjectLiteralExpression([factory.createPropertyAssignment(factory.createIdentifier("length"), factory.createNumericLiteral(env_1.STRING_LITERAL_MAX_LENGTH))], true)));
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));
@@ -21,6 +21,7 @@ var indexes = [
21
21
  ];
22
22
  var locale = {
23
23
  zh_CN: {
24
+ name: '更新',
24
25
  attr: {
25
26
  targetEntity: '目标对象',
26
27
  entity: '关联对象',
@@ -6,6 +6,7 @@ var config = {
6
6
  };
7
7
  var locale = {
8
8
  zh_CN: {
9
+ name: '更新对象连接',
9
10
  attr: {
10
11
  modi: '更新',
11
12
  entity: '关联对象',
@@ -6,6 +6,7 @@ var configuration = {
6
6
  };
7
7
  var locale = {
8
8
  zh_CN: {
9
+ name: '操作',
9
10
  attr: {
10
11
  action: '动作',
11
12
  data: '数据',
@@ -6,6 +6,7 @@ var config = {
6
6
  };
7
7
  var locale = {
8
8
  zh_CN: {
9
+ name: '操作对象连接',
9
10
  attr: {
10
11
  oper: '操作',
11
12
  entity: '关联对象',
@@ -8,6 +8,7 @@ var UserActionDef = {
8
8
  };
9
9
  var locale = {
10
10
  zh_CN: {
11
+ name: '用户',
11
12
  attr: {
12
13
  name: '姓名',
13
14
  nickname: '昵称',
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  ;
4
4
  var locale = {
5
5
  zh_CN: {
6
+ name: '用户授权',
6
7
  attr: {
7
8
  relation: '关系',
8
9
  entity: '关联对象',
@@ -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 _a, _b, e, e_1_1;
68
- var e_1, _c;
69
- return tslib_1.__generator(this, function (_d) {
70
- switch (_d.label) {
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*/, 10];
72
+ if (!this.uuid) return [3 /*break*/, 9];
73
73
  return [4 /*yield*/, this.rowStore.commit(this.uuid)];
74
74
  case 1:
75
- _d.sent();
75
+ _b.sent();
76
76
  this.uuid = undefined;
77
- _d.label = 2;
77
+ commitEvents = this.events.commit;
78
+ this.resetEvents();
79
+ _b.label = 2;
78
80
  case 2:
79
- _d.trys.push([2, 7, 8, 9]);
80
- _a = tslib_1.__values(this.events.commit), _b = _a.next();
81
- _d.label = 3;
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 (!!_b.done) return [3 /*break*/, 6];
84
- e = _b.value;
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
- _d.sent();
88
- _d.label = 5;
89
+ _b.sent();
90
+ _b.label = 5;
89
91
  case 5:
90
- _b = _a.next();
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 = _d.sent();
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 (_b && !_b.done && (_c = _a.return)) _c.call(_a);
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 _a, _b, e, e_2_1;
114
- var e_2, _c;
115
- return tslib_1.__generator(this, function (_d) {
116
- switch (_d.label) {
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*/, 10];
117
+ if (!this.uuid) return [3 /*break*/, 9];
119
118
  return [4 /*yield*/, this.rowStore.rollback(this.uuid)];
120
119
  case 1:
121
- _d.sent();
120
+ _b.sent();
122
121
  // console.log('rollback', this.uuid);
123
122
  this.uuid = undefined;
124
- _d.label = 2;
123
+ rollbackEvents = this.events.rollback;
124
+ this.resetEvents();
125
+ _b.label = 2;
125
126
  case 2:
126
- _d.trys.push([2, 7, 8, 9]);
127
- _a = tslib_1.__values(this.events.rollback), _b = _a.next();
128
- _d.label = 3;
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 (!!_b.done) return [3 /*break*/, 6];
131
- e = _b.value;
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
- _d.sent();
135
- _d.label = 5;
135
+ _b.sent();
136
+ _b.label = 5;
136
137
  case 5:
137
- _b = _a.next();
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 = _d.sent();
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 (_b && !_b.done && (_c = _a.return)) _c.call(_a);
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
  });