oak-domain 3.0.3 → 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.
- package/lib/actions/action.d.ts +8 -8
- package/lib/actions/action.js +2 -2
- package/lib/actions/relation.d.ts +1 -1
- package/lib/actions/relation.js +9 -22
- package/lib/base-app-domain/ActionAuth/Schema.d.ts +68 -42
- package/lib/base-app-domain/ActionAuth/Storage.js +12 -15
- package/lib/base-app-domain/ActionDefDict.d.ts +2 -3
- package/lib/base-app-domain/ActionDefDict.js +3 -5
- package/lib/base-app-domain/EntityDict.d.ts +5 -1
- package/lib/base-app-domain/I18n/Schema.d.ts +24 -24
- package/lib/base-app-domain/I18n/Storage.js +5 -5
- package/lib/base-app-domain/Modi/Action.d.ts +4 -4
- package/lib/base-app-domain/Modi/Action.js +3 -3
- package/lib/base-app-domain/Modi/Schema.d.ts +24 -24
- package/lib/base-app-domain/Modi/Storage.js +3 -3
- package/lib/base-app-domain/ModiEntity/Schema.d.ts +128 -55
- package/lib/base-app-domain/ModiEntity/Storage.js +2 -2
- package/lib/base-app-domain/Oper/Schema.d.ts +30 -29
- package/lib/base-app-domain/Oper/Storage.js +1 -1
- package/lib/base-app-domain/OperEntity/Schema.d.ts +126 -53
- package/lib/base-app-domain/OperEntity/Storage.js +2 -2
- package/lib/base-app-domain/Path/Schema.d.ts +149 -0
- package/lib/base-app-domain/Path/Schema.js +2 -0
- package/lib/base-app-domain/Path/Storage.d.ts +3 -0
- package/lib/base-app-domain/Path/Storage.js +54 -0
- package/lib/base-app-domain/Relation/Schema.d.ts +34 -34
- package/lib/base-app-domain/Relation/Storage.js +6 -6
- package/lib/base-app-domain/Relation.d.ts +0 -8
- package/lib/base-app-domain/Relation.js +1 -7
- package/lib/base-app-domain/RelationAuth/Schema.d.ts +74 -40
- package/lib/base-app-domain/RelationAuth/Storage.js +9 -11
- package/lib/base-app-domain/Storage.js +20 -16
- package/lib/base-app-domain/User/Action.d.ts +4 -4
- package/lib/base-app-domain/User/Action.js +3 -3
- package/lib/base-app-domain/User/Schema.d.ts +40 -27
- package/lib/base-app-domain/User/Storage.js +1 -1
- package/lib/base-app-domain/UserEntityClaim/Schema.d.ts +264 -0
- package/lib/base-app-domain/UserEntityClaim/Schema.js +2 -0
- package/lib/base-app-domain/UserEntityClaim/Storage.d.ts +3 -0
- package/lib/base-app-domain/UserEntityClaim/Storage.js +37 -0
- package/lib/base-app-domain/UserEntityGrant/Action.d.ts +2 -2
- package/lib/base-app-domain/UserEntityGrant/Schema.d.ts +55 -81
- package/lib/base-app-domain/UserEntityGrant/Storage.js +7 -11
- package/lib/base-app-domain/UserRelation/Schema.d.ts +50 -36
- package/lib/base-app-domain/UserRelation/Storage.js +7 -7
- package/lib/base-app-domain/_SubQuery.d.ts +45 -15
- package/lib/base-app-domain/index.js +1 -1
- package/lib/checkers/index.js +6 -7
- package/lib/compiler/env.js +16 -18
- package/lib/compiler/localeBuilder.js +83 -79
- package/lib/compiler/schemalBuilder.d.ts +16 -0
- package/lib/compiler/schemalBuilder.js +1160 -1378
- package/lib/entities/ActionAuth.d.ts +3 -5
- package/lib/entities/ActionAuth.js +9 -7
- package/lib/entities/I18n.js +1 -1
- package/lib/entities/Modi.js +2 -2
- package/lib/entities/ModiEntity.js +1 -1
- package/lib/entities/Oper.js +1 -1
- package/lib/entities/OperEntity.js +1 -1
- package/lib/entities/Path.d.ts +8 -0
- package/lib/entities/Path.js +35 -0
- package/lib/entities/Relation.js +1 -1
- package/lib/entities/RelationAuth.d.ts +2 -2
- package/lib/entities/RelationAuth.js +1 -1
- package/lib/entities/User.js +2 -2
- package/lib/entities/UserEntityClaim.d.ts +13 -0
- package/lib/entities/UserEntityClaim.js +17 -0
- package/lib/entities/UserEntityGrant.d.ts +5 -4
- package/lib/entities/UserEntityGrant.js +4 -7
- package/lib/entities/UserRelation.js +1 -1
- package/lib/index.d.ts +23 -0
- package/lib/index.js +37 -0
- package/lib/store/AsyncRowStore.d.ts +2 -1
- package/lib/store/AsyncRowStore.js +75 -149
- package/lib/store/CascadeStore.js +917 -1291
- package/lib/store/RelationAuth.d.ts +9 -16
- package/lib/store/RelationAuth.js +750 -908
- package/lib/store/SyncRowStore.d.ts +1 -1
- package/lib/store/SyncRowStore.js +27 -26
- package/lib/store/TriggerExecutor.d.ts +17 -10
- package/lib/store/TriggerExecutor.js +350 -423
- package/lib/store/actionAuth.js +13 -28
- package/lib/store/actionDef.js +118 -193
- package/lib/store/checker.js +225 -361
- package/lib/store/filter.d.ts +2 -3
- package/lib/store/filter.js +451 -589
- package/lib/store/modi.js +116 -177
- package/lib/store/relation.js +17 -17
- package/lib/timers/oper.d.ts +1 -1
- package/lib/timers/oper.js +44 -47
- package/lib/timers/vaccum.d.ts +2 -2
- package/lib/timers/vaccum.js +100 -165
- package/lib/triggers/index.js +1 -1
- package/lib/types/Action.d.ts +7 -7
- package/lib/types/AppLoader.d.ts +8 -2
- package/lib/types/AppLoader.js +4 -4
- package/lib/types/Aspect.d.ts +1 -3
- package/lib/types/Auth.d.ts +15 -19
- package/lib/types/Connector.d.ts +19 -15
- package/lib/types/Connector.js +0 -7
- package/lib/types/DataType.d.ts +19 -18
- package/lib/types/DataType.js +1 -1
- package/lib/types/Demand.d.ts +25 -25
- package/lib/types/Endpoint.d.ts +1 -1
- package/lib/types/Entity.d.ts +57 -53
- package/lib/types/Entity.js +3 -3
- package/lib/types/EntityDesc.d.ts +2 -1
- package/lib/types/Environment.d.ts +4 -4
- package/lib/types/Exception.d.ts +29 -2
- package/lib/types/Exception.js +205 -205
- package/lib/types/Expression.d.ts +14 -14
- package/lib/types/Expression.js +54 -87
- package/lib/types/Geo.d.ts +6 -6
- package/lib/types/Locale.d.ts +5 -5
- package/lib/types/Polyfill.d.ts +9 -9
- package/lib/types/Port.d.ts +4 -4
- package/lib/types/RowStore.d.ts +3 -3
- package/lib/types/RowStore.js +18 -19
- package/lib/types/Storage.d.ts +5 -4
- package/lib/types/Style.d.ts +2 -2
- package/lib/types/Timer.d.ts +3 -3
- package/lib/types/Trigger.d.ts +30 -14
- package/lib/types/Trigger.js +6 -2
- package/lib/types/Watcher.d.ts +2 -2
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -1
- package/lib/types/schema/DataTypes.d.ts +7 -7
- package/lib/utils/SimpleConnector.d.ts +24 -10
- package/lib/utils/SimpleConnector.js +166 -144
- package/lib/utils/assert.js +2 -2
- package/lib/utils/concurrent.d.ts +1 -1
- package/lib/utils/concurrent.js +31 -57
- package/lib/utils/date.js +2 -2
- package/lib/utils/geo.js +8 -8
- package/lib/utils/lodash.d.ts +3 -1
- package/lib/utils/lodash.js +21 -34
- package/lib/utils/mask.js +12 -13
- package/lib/utils/money.d.ts +1 -1
- package/lib/utils/money.js +22 -11
- package/lib/utils/projection.d.ts +4 -0
- package/lib/utils/projection.js +15 -0
- package/lib/utils/random/random.js +11 -16
- package/lib/utils/random/random.mp.js +7 -18
- package/lib/utils/random/random.web.js +6 -12
- package/lib/utils/string.d.ts +4 -4
- package/lib/utils/string.js +19 -32
- package/lib/utils/url.js +5 -4
- package/lib/utils/uuid.d.ts +1 -1
- package/lib/utils/uuid.js +46 -85
- package/lib/utils/validator.d.ts +4 -3
- package/lib/utils/validator.js +35 -32
- package/lib/utils/version.js +6 -6
- package/package.json +7 -7
- package/src/entities/ActionAuth.ts +10 -10
- package/src/entities/Path.ts +43 -0
- package/src/entities/RelationAuth.ts +2 -1
- package/src/entities/UserEntityClaim.ts +30 -0
- package/src/entities/UserEntityGrant.ts +9 -12
package/lib/compiler/env.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
6
6
|
exports.LIB_OAK_DOMAIN = 'oak-domain';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const LIB_OAK_GENERAL_BUSINESS = 'oak-general-business';
|
|
8
|
+
const LIB_PATH = () => 'lib';
|
|
9
9
|
exports.LIB_PATH = LIB_PATH;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
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
|
-
|
|
16
|
-
return
|
|
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
|
-
|
|
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
|
|
21
|
+
return `${LEVEL_PREFIX[level]}/types/`;
|
|
23
22
|
}
|
|
24
|
-
return
|
|
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
|
-
|
|
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
|
|
28
|
+
return `${LEVEL_PREFIX[level]}/actions/action`;
|
|
31
29
|
}
|
|
32
|
-
return
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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(
|
|
18
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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(
|
|
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(
|
|
57
|
-
|
|
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
|
-
|
|
60
|
-
h.update(
|
|
61
|
-
|
|
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,
|
|
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,
|
|
80
|
+
statements.push(factory.createExportAssignment(undefined, undefined, factory.createIdentifier("i18ns")));
|
|
77
81
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
107
|
+
this.parseFile(module, nsPrefix, position, file, filepath, watch);
|
|
106
108
|
}
|
|
107
109
|
else if (stat.isDirectory() && !inLocale) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
125
|
-
files.forEach(
|
|
126
|
-
|
|
127
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
150
|
+
let iter = 1;
|
|
146
151
|
while (true) {
|
|
147
|
-
|
|
152
|
+
const mpSrcPath = `${wechatMpSrcPath}${iter}`;
|
|
148
153
|
if (fs_1.default.existsSync((0, path_1.join)(root, mpSrcPath))) {
|
|
149
|
-
this.traverse(name,
|
|
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
|
-
|
|
162
|
+
}
|
|
163
|
+
build(watch) {
|
|
159
164
|
this.buildproject(this.pwd, true, watch);
|
|
160
165
|
if (!this.asLib) {
|
|
161
166
|
// 如果不是lib,把front里的数据也处理掉
|
|
162
|
-
|
|
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
|
-
|
|
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;
|