oak-domain 3.0.2 → 3.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.
Files changed (157) hide show
  1. package/lib/actions/action.d.ts +8 -8
  2. package/lib/actions/action.js +2 -2
  3. package/lib/actions/relation.d.ts +1 -1
  4. package/lib/actions/relation.js +9 -22
  5. package/lib/base-app-domain/ActionAuth/Schema.d.ts +68 -42
  6. package/lib/base-app-domain/ActionAuth/Storage.js +12 -15
  7. package/lib/base-app-domain/ActionDefDict.d.ts +2 -3
  8. package/lib/base-app-domain/ActionDefDict.js +3 -5
  9. package/lib/base-app-domain/EntityDict.d.ts +5 -1
  10. package/lib/base-app-domain/I18n/Schema.d.ts +24 -24
  11. package/lib/base-app-domain/I18n/Storage.js +5 -5
  12. package/lib/base-app-domain/Modi/Action.d.ts +4 -4
  13. package/lib/base-app-domain/Modi/Action.js +3 -3
  14. package/lib/base-app-domain/Modi/Schema.d.ts +24 -24
  15. package/lib/base-app-domain/Modi/Storage.js +3 -3
  16. package/lib/base-app-domain/ModiEntity/Schema.d.ts +128 -55
  17. package/lib/base-app-domain/ModiEntity/Storage.js +2 -2
  18. package/lib/base-app-domain/Oper/Schema.d.ts +30 -29
  19. package/lib/base-app-domain/Oper/Storage.js +1 -1
  20. package/lib/base-app-domain/OperEntity/Schema.d.ts +126 -53
  21. package/lib/base-app-domain/OperEntity/Storage.js +2 -2
  22. package/lib/base-app-domain/Path/Schema.d.ts +149 -0
  23. package/lib/base-app-domain/Path/Schema.js +2 -0
  24. package/lib/base-app-domain/Path/Storage.d.ts +3 -0
  25. package/lib/base-app-domain/Path/Storage.js +54 -0
  26. package/lib/base-app-domain/Relation/Schema.d.ts +34 -34
  27. package/lib/base-app-domain/Relation/Storage.js +6 -6
  28. package/lib/base-app-domain/Relation.d.ts +0 -8
  29. package/lib/base-app-domain/Relation.js +1 -7
  30. package/lib/base-app-domain/RelationAuth/Schema.d.ts +74 -40
  31. package/lib/base-app-domain/RelationAuth/Storage.js +9 -11
  32. package/lib/base-app-domain/Storage.js +20 -16
  33. package/lib/base-app-domain/User/Action.d.ts +4 -4
  34. package/lib/base-app-domain/User/Action.js +3 -3
  35. package/lib/base-app-domain/User/Schema.d.ts +40 -27
  36. package/lib/base-app-domain/User/Storage.js +1 -1
  37. package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +264 -0
  38. package/lib/base-app-domain/UserEntityClaim/Schema.js +2 -0
  39. package/lib/base-app-domain/UserEntityClaim/Storage.d.ts +3 -0
  40. package/lib/base-app-domain/UserEntityClaim/Storage.js +37 -0
  41. package/lib/base-app-domain/UserEntityGrant/Action.d.ts +2 -2
  42. package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +55 -81
  43. package/lib/base-app-domain/UserEntityGrant/Storage.js +7 -11
  44. package/lib/base-app-domain/UserRelation/Schema.d.ts +50 -36
  45. package/lib/base-app-domain/UserRelation/Storage.js +7 -7
  46. package/lib/base-app-domain/_SubQuery.d.ts +45 -15
  47. package/lib/base-app-domain/index.js +1 -1
  48. package/lib/checkers/index.js +6 -7
  49. package/lib/compiler/env.js +16 -18
  50. package/lib/compiler/localeBuilder.js +83 -79
  51. package/lib/compiler/schemalBuilder.d.ts +16 -0
  52. package/lib/compiler/schemalBuilder.js +1160 -1378
  53. package/lib/entities/ActionAuth.d.ts +3 -5
  54. package/lib/entities/ActionAuth.js +9 -7
  55. package/lib/entities/I18n.js +1 -1
  56. package/lib/entities/Modi.js +2 -2
  57. package/lib/entities/ModiEntity.js +1 -1
  58. package/lib/entities/Oper.js +1 -1
  59. package/lib/entities/OperEntity.js +1 -1
  60. package/lib/entities/Path.d.ts +8 -0
  61. package/lib/entities/Path.js +35 -0
  62. package/lib/entities/Relation.js +1 -1
  63. package/lib/entities/RelationAuth.d.ts +2 -2
  64. package/lib/entities/RelationAuth.js +1 -1
  65. package/lib/entities/User.js +2 -2
  66. package/lib/entities/UserEntityClaim.d.ts +13 -0
  67. package/lib/entities/UserEntityClaim.js +17 -0
  68. package/lib/entities/UserEntityGrant.d.ts +5 -4
  69. package/lib/entities/UserEntityGrant.js +4 -7
  70. package/lib/entities/UserRelation.js +1 -1
  71. package/lib/index.d.ts +23 -0
  72. package/lib/index.js +37 -0
  73. package/lib/store/AsyncRowStore.d.ts +2 -1
  74. package/lib/store/AsyncRowStore.js +75 -149
  75. package/lib/store/CascadeStore.js +968 -1341
  76. package/lib/store/RelationAuth.d.ts +9 -16
  77. package/lib/store/RelationAuth.js +752 -910
  78. package/lib/store/SyncRowStore.d.ts +1 -1
  79. package/lib/store/SyncRowStore.js +27 -26
  80. package/lib/store/TriggerExecutor.d.ts +17 -10
  81. package/lib/store/TriggerExecutor.js +350 -423
  82. package/lib/store/actionAuth.js +13 -28
  83. package/lib/store/actionDef.js +142 -215
  84. package/lib/store/checker.js +225 -361
  85. package/lib/store/filter.d.ts +2 -3
  86. package/lib/store/filter.js +451 -589
  87. package/lib/store/modi.js +116 -177
  88. package/lib/store/relation.js +17 -17
  89. package/lib/timers/oper.d.ts +1 -1
  90. package/lib/timers/oper.js +44 -47
  91. package/lib/timers/vaccum.d.ts +2 -2
  92. package/lib/timers/vaccum.js +100 -165
  93. package/lib/triggers/index.js +1 -1
  94. package/lib/types/Action.d.ts +7 -7
  95. package/lib/types/AppLoader.d.ts +8 -2
  96. package/lib/types/AppLoader.js +4 -4
  97. package/lib/types/Auth.d.ts +15 -19
  98. package/lib/types/Connector.d.ts +19 -14
  99. package/lib/types/Connector.js +0 -7
  100. package/lib/types/DataType.d.ts +19 -18
  101. package/lib/types/DataType.js +1 -1
  102. package/lib/types/Demand.d.ts +25 -25
  103. package/lib/types/Endpoint.d.ts +1 -1
  104. package/lib/types/Entity.d.ts +62 -53
  105. package/lib/types/Entity.js +4 -3
  106. package/lib/types/EntityDesc.d.ts +2 -1
  107. package/lib/types/Environment.d.ts +4 -4
  108. package/lib/types/Exception.d.ts +34 -2
  109. package/lib/types/Exception.js +214 -197
  110. package/lib/types/Expression.d.ts +14 -14
  111. package/lib/types/Expression.js +54 -87
  112. package/lib/types/Geo.d.ts +6 -6
  113. package/lib/types/Locale.d.ts +5 -5
  114. package/lib/types/Polyfill.d.ts +9 -9
  115. package/lib/types/Port.d.ts +4 -4
  116. package/lib/types/RowStore.d.ts +3 -3
  117. package/lib/types/RowStore.js +18 -19
  118. package/lib/types/Storage.d.ts +5 -4
  119. package/lib/types/Style.d.ts +2 -2
  120. package/lib/types/Timer.d.ts +3 -3
  121. package/lib/types/Trigger.d.ts +30 -14
  122. package/lib/types/Trigger.js +6 -2
  123. package/lib/types/Watcher.d.ts +2 -2
  124. package/lib/types/index.d.ts +1 -0
  125. package/lib/types/index.js +2 -1
  126. package/lib/types/schema/DataTypes.d.ts +7 -7
  127. package/lib/utils/SimpleConnector.d.ts +26 -10
  128. package/lib/utils/SimpleConnector.js +167 -141
  129. package/lib/utils/assert.js +2 -2
  130. package/lib/utils/concurrent.d.ts +1 -1
  131. package/lib/utils/concurrent.js +31 -57
  132. package/lib/utils/date.js +2 -2
  133. package/lib/utils/geo.js +8 -8
  134. package/lib/utils/lodash.d.ts +3 -1
  135. package/lib/utils/lodash.js +21 -34
  136. package/lib/utils/mask.js +12 -13
  137. package/lib/utils/money.d.ts +1 -1
  138. package/lib/utils/money.js +22 -11
  139. package/lib/utils/projection.d.ts +4 -0
  140. package/lib/utils/projection.js +15 -0
  141. package/lib/utils/random/random.js +11 -16
  142. package/lib/utils/random/random.mp.js +7 -18
  143. package/lib/utils/random/random.web.js +6 -12
  144. package/lib/utils/string.d.ts +4 -4
  145. package/lib/utils/string.js +19 -32
  146. package/lib/utils/url.js +5 -4
  147. package/lib/utils/uuid.d.ts +1 -1
  148. package/lib/utils/uuid.js +46 -85
  149. package/lib/utils/validator.d.ts +4 -3
  150. package/lib/utils/validator.js +35 -32
  151. package/lib/utils/version.js +6 -6
  152. package/package.json +7 -7
  153. package/src/entities/ActionAuth.ts +10 -10
  154. package/src/entities/Path.ts +43 -0
  155. package/src/entities/RelationAuth.ts +2 -1
  156. package/src/entities/UserEntityClaim.ts +30 -0
  157. package/src/entities/UserEntityGrant.ts +9 -12
@@ -1,35 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OAK_EXTERNAL_LIBS_FILEPATH = exports.SYSTEM_RESERVE_ENTITIES = exports.INT_LITERL_DEFAULT_WIDTH = exports.NUMERICAL_LITERL_DEFAULT_SCALE = exports.NUMERICAL_LITERL_DEFAULT_PRECISION = exports.STRING_LITERAL_MAX_LENGTH = exports.ENTITY_NAME_MAX_LENGTH = exports.RESERVED_ENTITY_NAMES = exports.ACTION_CONSTANT_IN_OAK_DOMAIN = exports.TYPE_PATH_IN_OAK_DOMAIN = exports.ENTITY_PATH_IN_OAK_DOMAIN = exports.ENTITY_PATH_IN_OAK_GENERAL_BUSINESS = exports.LIB_PATH = exports.LIB_OAK_DOMAIN = void 0;
4
- var tslib_1 = require("tslib");
5
- var path_1 = tslib_1.__importDefault(require("path"));
4
+ const tslib_1 = require("tslib");
5
+ const path_1 = tslib_1.__importDefault(require("path"));
6
6
  exports.LIB_OAK_DOMAIN = 'oak-domain';
7
- var LIB_OAK_GENERAL_BUSINESS = 'oak-general-business';
8
- var LIB_PATH = function () { return 'lib'; };
7
+ const LIB_OAK_GENERAL_BUSINESS = 'oak-general-business';
8
+ const LIB_PATH = () => 'lib';
9
9
  exports.LIB_PATH = LIB_PATH;
10
- var LEVEL_PREFIX = ['.', '..', '../..', '../../..', '../../../..'];
11
- var ENTITY_PATH_IN_OAK_GENERAL_BUSINESS = function () {
12
- return "".concat(LIB_OAK_GENERAL_BUSINESS, "/").concat((0, exports.LIB_PATH)(), "/entities/");
10
+ const LEVEL_PREFIX = ['.', '..', '../..', '../../..', '../../../..'];
11
+ const ENTITY_PATH_IN_OAK_GENERAL_BUSINESS = () => {
12
+ return `${LIB_OAK_GENERAL_BUSINESS}/${(0, exports.LIB_PATH)()}/entities/`;
13
13
  };
14
14
  exports.ENTITY_PATH_IN_OAK_GENERAL_BUSINESS = ENTITY_PATH_IN_OAK_GENERAL_BUSINESS;
15
- var ENTITY_PATH_IN_OAK_DOMAIN = function () {
16
- return "".concat(exports.LIB_OAK_DOMAIN, "/").concat((0, exports.LIB_PATH)(), "/entities/");
15
+ const ENTITY_PATH_IN_OAK_DOMAIN = () => {
16
+ return `${exports.LIB_OAK_DOMAIN}/${(0, exports.LIB_PATH)()}/entities/`;
17
17
  };
18
18
  exports.ENTITY_PATH_IN_OAK_DOMAIN = ENTITY_PATH_IN_OAK_DOMAIN;
19
- var TYPE_PATH_IN_OAK_DOMAIN = function (level) {
20
- if (level === void 0) { level = 2; }
19
+ const TYPE_PATH_IN_OAK_DOMAIN = (level = 2) => {
21
20
  if (process.env.COMPLING_IN_DOMAIN) {
22
- return "".concat(LEVEL_PREFIX[level], "/types/");
21
+ return `${LEVEL_PREFIX[level]}/types/`;
23
22
  }
24
- return "".concat(exports.LIB_OAK_DOMAIN, "/").concat((0, exports.LIB_PATH)(), "/types/");
23
+ return `${exports.LIB_OAK_DOMAIN}/${(0, exports.LIB_PATH)()}/types/`;
25
24
  };
26
25
  exports.TYPE_PATH_IN_OAK_DOMAIN = TYPE_PATH_IN_OAK_DOMAIN;
27
- var ACTION_CONSTANT_IN_OAK_DOMAIN = function (level) {
28
- if (level === void 0) { level = 2; }
26
+ const ACTION_CONSTANT_IN_OAK_DOMAIN = (level = 2) => {
29
27
  if (process.env.COMPLING_IN_DOMAIN) {
30
- return "".concat(LEVEL_PREFIX[level], "/actions/action");
28
+ return `${LEVEL_PREFIX[level]}/actions/action`;
31
29
  }
32
- return "".concat(exports.LIB_OAK_DOMAIN, "/").concat((0, exports.LIB_PATH)(), "/actions/action");
30
+ return `${exports.LIB_OAK_DOMAIN}/${(0, exports.LIB_PATH)()}/actions/action`;
33
31
  };
34
32
  exports.ACTION_CONSTANT_IN_OAK_DOMAIN = ACTION_CONSTANT_IN_OAK_DOMAIN;
35
33
  // export const OUTPUT_PATH = 'app-domain/entities';
@@ -44,7 +42,7 @@ exports.INT_LITERL_DEFAULT_WIDTH = 4;
44
42
  exports.SYSTEM_RESERVE_ENTITIES = ['user', 'relation', 'oper', 'operEntity', 'modi', 'modiEntity',
45
43
  'userRelation', 'actionAuth', 'relationAuth', 'relation', 'userEntityGrant', 'i18n'];
46
44
  // 项目依赖的第三方oak lib配置文件所在的固定路径
47
- var OAK_EXTERNAL_LIBS_FILEPATH = function (path) {
45
+ const OAK_EXTERNAL_LIBS_FILEPATH = (path) => {
48
46
  return path_1.default.join(path, 'config/oakExternalLib.json');
49
47
  };
50
48
  exports.OAK_EXTERNAL_LIBS_FILEPATH = OAK_EXTERNAL_LIBS_FILEPATH;
@@ -1,21 +1,21 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var tslib_1 = require("tslib");
4
- var assert_1 = tslib_1.__importDefault(require("assert"));
5
- var ts = tslib_1.__importStar(require("typescript"));
6
- var factory = ts.factory;
7
- var path_1 = require("path");
8
- var crypto_1 = require("crypto");
9
- var fs_1 = tslib_1.__importDefault(require("fs"));
10
- var env_1 = require("./env");
11
- var string_1 = require("../utils/string");
3
+ const tslib_1 = require("tslib");
4
+ const assert_1 = tslib_1.__importDefault(require("assert"));
5
+ const ts = tslib_1.__importStar(require("typescript"));
6
+ const { factory } = ts;
7
+ const path_1 = require("path");
8
+ const crypto_1 = require("crypto");
9
+ const fs_1 = tslib_1.__importDefault(require("fs"));
10
+ const env_1 = require("./env");
11
+ const string_1 = require("../utils/string");
12
12
  /**
13
13
  * 将一个object展开编译为一棵语法树,只有string和object两种键值对象
14
14
  * @param data
15
15
  */
16
16
  function transferObjectToObjectLiteral(data) {
17
- return factory.createObjectLiteralExpression(Object.keys(data).map(function (k) {
18
- var type = typeof data[k];
17
+ return factory.createObjectLiteralExpression(Object.keys(data).map((k) => {
18
+ const type = typeof data[k];
19
19
  if (type === 'string') {
20
20
  return factory.createPropertyAssignment(factory.createStringLiteral(k), factory.createStringLiteral(data[k]));
21
21
  }
@@ -26,12 +26,17 @@ function transferObjectToObjectLiteral(data) {
26
26
  /**
27
27
  * 这个类的作用是把项目和所有相关的模块下的locales编译成为src/data/i18n中的数据
28
28
  */
29
- var LocaleBuilder = /** @class */ (function () {
30
- function LocaleBuilder(asLib) {
31
- var pwd = process.cwd();
29
+ class LocaleBuilder {
30
+ asLib;
31
+ dependencies;
32
+ pwd;
33
+ locales; // key: namespace, value: [module, position, language, data]
34
+ hash;
35
+ constructor(asLib) {
36
+ const pwd = process.cwd();
32
37
  this.pwd = pwd;
33
38
  this.asLib = !!asLib;
34
- var dependencyFile = (0, env_1.OAK_EXTERNAL_LIBS_FILEPATH)((0, path_1.join)(pwd, 'src'));
39
+ const dependencyFile = (0, env_1.OAK_EXTERNAL_LIBS_FILEPATH)((0, path_1.join)(pwd, 'src'));
35
40
  if (fs_1.default.existsSync(dependencyFile)) {
36
41
  this.dependencies = require(dependencyFile);
37
42
  }
@@ -45,20 +50,19 @@ var LocaleBuilder = /** @class */ (function () {
45
50
  * 将locales输出成为data/i18n.ts中的数据
46
51
  * 如果有Dependency需要引出来
47
52
  */
48
- LocaleBuilder.prototype.outputDataFile = function () {
49
- var _this = this;
50
- var statements = [
51
- factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, factory.createIdentifier("CreateOperationData"), factory.createIdentifier("I18n"))])), factory.createStringLiteral("../oak-app-domain/I18n/Schema"), undefined)
53
+ outputDataFile() {
54
+ const statements = [
55
+ factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, factory.createIdentifier("CreateOperationData"), factory.createIdentifier("I18n"))])), factory.createStringLiteral("../oak-app-domain/I18n/Schema"), undefined)
52
56
  ];
53
57
  if (this.dependencies) {
54
- this.dependencies.forEach(function (ele, idx) { return statements.push(factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, factory.createIdentifier("i18ns".concat(idx)), undefined), factory.createStringLiteral("".concat(ele, "/lib/data/i18n")), undefined)); });
58
+ this.dependencies.forEach((ele, idx) => statements.push(factory.createImportDeclaration(undefined, factory.createImportClause(false, factory.createIdentifier(`i18ns${idx}`), undefined), factory.createStringLiteral(`${ele}/lib/data/i18n`), undefined)));
55
59
  }
56
- statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier("i18ns"), undefined, factory.createArrayTypeNode(factory.createTypeReferenceNode(factory.createIdentifier("I18n"), undefined)), factory.createArrayLiteralExpression(Object.keys(this.locales).map(function (k) {
57
- var _a = tslib_1.__read(_this.locales[k], 4), module = _a[0], position = _a[1], language = _a[2], data = _a[3];
60
+ statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier("i18ns"), undefined, factory.createArrayTypeNode(factory.createTypeReferenceNode(factory.createIdentifier("I18n"), undefined)), factory.createArrayLiteralExpression(Object.keys(this.locales).map((k) => {
61
+ const [module, position, language, data] = this.locales[k];
58
62
  // 用哈希计算来保证id唯一性
59
- var h = _this.hash.copy();
60
- h.update("".concat(k, "-").concat(language));
61
- var id = h.digest('hex');
63
+ const h = this.hash.copy();
64
+ h.update(`${k}-${language}`);
65
+ const id = h.digest('hex');
62
66
  (0, assert_1.default)(id.length <= 36);
63
67
  return factory.createObjectLiteralExpression([
64
68
  factory.createPropertyAssignment(factory.createIdentifier("id"), factory.createStringLiteral(id)),
@@ -70,83 +74,84 @@ var LocaleBuilder = /** @class */ (function () {
70
74
  ], true);
71
75
  }), true))], ts.NodeFlags.Const)));
72
76
  if (this.dependencies.length > 0) {
73
- statements.push(factory.createExportAssignment(undefined, undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("i18ns"), factory.createIdentifier("concat")), undefined, this.dependencies.map(function (ele, idx) { return factory.createIdentifier("i18ns".concat(idx)); }))));
77
+ statements.push(factory.createExportAssignment(undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("i18ns"), factory.createIdentifier("concat")), undefined, this.dependencies.map((ele, idx) => factory.createIdentifier(`i18ns${idx}`)))));
74
78
  }
75
79
  else {
76
- statements.push(factory.createExportAssignment(undefined, undefined, undefined, factory.createIdentifier("i18ns")));
80
+ statements.push(factory.createExportAssignment(undefined, undefined, factory.createIdentifier("i18ns")));
77
81
  }
78
- var printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
79
- var result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements), ts.createSourceFile("someFileName.ts", "", ts.ScriptTarget.Latest, false, ts.ScriptKind.TS));
80
- var filename = (0, path_1.join)(this.pwd, 'src', 'data', 'i18n.ts');
81
- var result2 = (0, string_1.unescapeUnicode)("// \u672C\u6587\u4EF6\u4E3A\u81EA\u52A8\u7F16\u8BD1\u4EA7\u751F\uFF0C\u8BF7\u52FF\u76F4\u63A5\u4FEE\u6539\n\n".concat(result));
82
+ const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
83
+ const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements), ts.createSourceFile("someFileName.ts", "", ts.ScriptTarget.Latest, false, ts.ScriptKind.TS));
84
+ const filename = (0, path_1.join)(this.pwd, 'src', 'data', 'i18n.ts');
85
+ const result2 = (0, string_1.unescapeUnicode)(`// 本文件为自动编译产生,请勿直接修改\n\n${result}`);
82
86
  fs_1.default.writeFileSync(filename, result2, { flag: 'w' });
83
- };
84
- LocaleBuilder.prototype.parseFile = function (module, namespace, position, filename, filepath, watch) {
85
- var _this = this;
86
- var language = (filename.split('.')[0]).replace('_', '-'); // 历史原因,会命名成zh_CN.json
87
- var data = require(filepath);
88
- var ns = module ? "".concat(module, "-").concat(namespace) : (0, string_1.firstLetterLowerCase)(namespace);
87
+ }
88
+ parseFile(module, namespace, position, filename, filepath, watch) {
89
+ const language = (filename.split('.')[0]).replace('_', '-'); // 历史原因,会命名成zh_CN.json
90
+ const data = require(filepath);
91
+ const ns = module ? `${module}-${namespace}` : (0, string_1.firstLetterLowerCase)(namespace);
89
92
  this.locales[ns] = [module, position.replace(/\\/g, '/'), language, data];
90
93
  if (watch) {
91
- fs_1.default.watch(filepath, function () {
92
- var data = require(filepath);
93
- _this.locales[ns] = [module, position.replace(/\\/g, '/'), language, data];
94
- _this.outputDataFile();
94
+ fs_1.default.watch(filepath, () => {
95
+ const data = require(filepath);
96
+ this.locales[ns] = [module, position.replace(/\\/g, '/'), language, data];
97
+ this.outputDataFile();
95
98
  });
96
99
  }
97
- };
98
- LocaleBuilder.prototype.traverse = function (module, nsPrefix, position, dirPath, inLocale, localeFolderName, watch) {
99
- var _this = this;
100
- var files = fs_1.default.readdirSync(dirPath);
101
- files.forEach(function (file) {
102
- var filepath = (0, path_1.join)(dirPath, file);
103
- var stat = fs_1.default.statSync(filepath);
100
+ }
101
+ traverse(module, nsPrefix, position, dirPath, inLocale, localeFolderName, watch) {
102
+ const files = fs_1.default.readdirSync(dirPath);
103
+ files.forEach((file) => {
104
+ const filepath = (0, path_1.join)(dirPath, file);
105
+ const stat = fs_1.default.statSync(filepath);
104
106
  if (stat.isFile() && inLocale && file.endsWith('.json')) {
105
- _this.parseFile(module, nsPrefix, position, file, filepath, watch);
107
+ this.parseFile(module, nsPrefix, position, file, filepath, watch);
106
108
  }
107
109
  else if (stat.isDirectory() && !inLocale) {
108
- var nsPrefix2 = nsPrefix ? "".concat(nsPrefix, "-").concat(file) : file;
109
- var isLocaleFolder = file === localeFolderName;
110
- _this.traverse(module, isLocaleFolder ? nsPrefix : nsPrefix2, isLocaleFolder ? position : (0, path_1.join)(position, file), (0, path_1.join)(dirPath, file), isLocaleFolder, localeFolderName, watch);
110
+ const nsPrefix2 = nsPrefix ? `${nsPrefix}-${file}` : file;
111
+ const isLocaleFolder = file === localeFolderName;
112
+ this.traverse(module, isLocaleFolder ? nsPrefix : nsPrefix2, isLocaleFolder ? position : (0, path_1.join)(position, file), (0, path_1.join)(dirPath, file), isLocaleFolder, localeFolderName, watch);
111
113
  }
112
114
  });
113
- };
114
- LocaleBuilder.prototype.buildproject = function (root, src, watch) {
115
- var _this = this;
116
- var packageJson = (0, path_1.join)(root, 'package.json');
117
- var name = require(packageJson).name;
118
- var pagePath = (0, path_1.join)(src ? 'src' : 'lib', 'pages');
119
- this.traverse(name, 'p', pagePath, (0, path_1.join)(root, pagePath), false, 'locales', watch);
120
- var componentPath = (0, path_1.join)(src ? 'src' : 'lib', 'components');
121
- this.traverse(name, 'c', componentPath, (0, path_1.join)(root, componentPath), false, 'locales', watch);
122
- var localePath = (0, path_1.join)(root, src ? 'src' : 'lib', 'locales');
115
+ }
116
+ buildproject(root, src, watch) {
117
+ const packageJson = (0, path_1.join)(root, 'package.json');
118
+ const { name } = require(packageJson);
119
+ const pagePath = (0, path_1.join)(src ? 'src' : 'lib', 'pages');
120
+ if (fs_1.default.existsSync(pagePath)) {
121
+ this.traverse(name, 'p', pagePath, (0, path_1.join)(root, pagePath), false, 'locales', watch);
122
+ }
123
+ const componentPath = (0, path_1.join)(src ? 'src' : 'lib', 'components');
124
+ if (fs_1.default.existsSync(componentPath)) {
125
+ this.traverse(name, 'c', componentPath, (0, path_1.join)(root, componentPath), false, 'locales', watch);
126
+ }
127
+ const localePath = (0, path_1.join)(root, src ? 'src' : 'lib', 'locales');
123
128
  if (fs_1.default.existsSync(localePath)) {
124
- var files = fs_1.default.readdirSync(localePath);
125
- files.forEach(function (file) {
126
- var filepath = (0, path_1.join)(localePath, file);
127
- var stat = fs_1.default.statSync(filepath);
129
+ const files = fs_1.default.readdirSync(localePath);
130
+ files.forEach((file) => {
131
+ const filepath = (0, path_1.join)(localePath, file);
132
+ const stat = fs_1.default.statSync(filepath);
128
133
  if (stat.isDirectory()) {
129
- _this.traverse(name, "l-".concat(file), (0, path_1.join)('locales', file), (0, path_1.join)(localePath, file), true, file, watch);
134
+ this.traverse(name, `l-${file}`, (0, path_1.join)('locales', file), (0, path_1.join)(localePath, file), true, file, watch);
130
135
  }
131
136
  });
132
137
  }
133
138
  if (!this.asLib && src) {
134
139
  // 不是lib的话将oak-app-domain中的对象的locale也收集起来
135
- var domainPath = (0, path_1.join)(root, 'src', 'oak-app-domain');
140
+ const domainPath = (0, path_1.join)(root, 'src', 'oak-app-domain');
136
141
  if (fs_1.default.existsSync(domainPath)) {
137
142
  this.traverse('', '', 'oak-app-domain', domainPath, false, 'locales', watch);
138
143
  }
139
144
  // 还有web和wechatMp的目录
140
- var webSrcPath = (0, path_1.join)('web', 'src');
145
+ const webSrcPath = (0, path_1.join)('web', 'src');
141
146
  this.traverse(name, 'w', webSrcPath, (0, path_1.join)(root, webSrcPath), false, 'locales', watch);
142
147
  // 小程序可能有多于一个,按规范用wechatMp, wechatMp2这样命名
143
- var wechatMpSrcPath = (0, path_1.join)('wechatMp', 'src');
148
+ const wechatMpSrcPath = (0, path_1.join)('wechatMp', 'src');
144
149
  this.traverse(name, 'wmp', wechatMpSrcPath, (0, path_1.join)(root, webSrcPath), false, 'locales', watch);
145
- var iter = 1;
150
+ let iter = 1;
146
151
  while (true) {
147
- var mpSrcPath = "".concat(wechatMpSrcPath).concat(iter);
152
+ const mpSrcPath = `${wechatMpSrcPath}${iter}`;
148
153
  if (fs_1.default.existsSync((0, path_1.join)(root, mpSrcPath))) {
149
- this.traverse(name, "wmp".concat(iter), mpSrcPath, (0, path_1.join)(root, mpSrcPath), false, 'locales', watch);
154
+ this.traverse(name, `wmp${iter}`, mpSrcPath, (0, path_1.join)(root, mpSrcPath), false, 'locales', watch);
150
155
  iter++;
151
156
  }
152
157
  else {
@@ -154,16 +159,15 @@ var LocaleBuilder = /** @class */ (function () {
154
159
  }
155
160
  }
156
161
  }
157
- };
158
- LocaleBuilder.prototype.build = function (watch) {
162
+ }
163
+ build(watch) {
159
164
  this.buildproject(this.pwd, true, watch);
160
165
  if (!this.asLib) {
161
166
  // 如果不是lib,把front里的数据也处理掉
162
- var fbPath = (0, path_1.join)(this.pwd, 'node_modules', 'oak-frontend-base');
167
+ const fbPath = (0, path_1.join)(this.pwd, 'node_modules', 'oak-frontend-base');
163
168
  this.buildproject(fbPath, false, watch);
164
169
  }
165
170
  this.outputDataFile();
166
- };
167
- return LocaleBuilder;
168
- }());
171
+ }
172
+ }
169
173
  exports.default = LocaleBuilder;
@@ -1,11 +1,27 @@
1
+ /**
2
+ * 此函数不再使用
3
+ * @param map
4
+ */
1
5
  export declare function registerIgnoredForeignKeyMap(map: Record<string, string[]>): void;
6
+ /**
7
+ * 此函数不再使用
8
+ * @param map
9
+ */
2
10
  export declare function registerFreeEntities(selectFreeEntities?: string[], createFreeEntities?: string[], updateFreeEntities?: string[]): void;
11
+ /**
12
+ * 此函数不再使用
13
+ * @param map
14
+ */
3
15
  export declare function registerIgnoredRelationPathMap(map: Record<string, string[]>): void;
4
16
  /**
5
17
  * 很多路径虽然最后指向同一对象,但不能封掉,封了会导致查询的时候找不到对应的路径path
6
18
  * @param map
7
19
  */
8
20
  export declare function registerFixedDestinationPathMap(map: Record<string, string[]>): void;
21
+ /**
22
+ * 此函数不再使用
23
+ * @param map
24
+ */
9
25
  export declare function registerDeducedRelationMap(map: Record<string, string>): void;
10
26
  export declare function analyzeEntities(inputDir: string, relativePath?: string): void;
11
27
  export declare function buildSchema(outputDir: string): void;