oak-domain 5.0.11 → 5.0.13
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/Path/Schema.d.ts +6 -0
- package/lib/base-app-domain/Path/Storage.js +6 -0
- package/lib/compiler/dependencyBuilder.js +31 -57
- package/lib/compiler/routerBuilder.js +1 -1
- package/lib/entities/Path.d.ts +1 -0
- package/lib/entities/Path.js +3 -2
- package/lib/store/IntrinsicCheckers.js +4 -4
- package/lib/store/checker.js +6 -6
- package/lib/store/filter.js +8 -1
- package/lib/utils/assert.d.ts +0 -1
- package/lib/utils/relationPath.js +1 -1
- package/lib/utils/row.d.ts +12 -0
- package/lib/utils/row.js +67 -0
- package/package.json +1 -1
- package/src/entities/ModiEntity.ts +26 -26
- package/src/entities/OperEntity.ts +27 -27
- package/src/entities/Path.ts +4 -2
- package/src/entities/Relation.ts +43 -43
- package/src/entities/UserEntityClaim.ts +29 -29
- package/src/entities/UserEntityGrant.ts +24 -24
- package/src/entities/UserRelation.ts +50 -50
|
@@ -12,6 +12,7 @@ export type OpSchema = EntityShape & {
|
|
|
12
12
|
value: String<256>;
|
|
13
13
|
recursive: Boolean;
|
|
14
14
|
sourceEntity: String<32>;
|
|
15
|
+
desc?: String<256> | null;
|
|
15
16
|
};
|
|
16
17
|
export type OpAttr = keyof OpSchema;
|
|
17
18
|
export type Schema = EntityShape & {
|
|
@@ -19,6 +20,7 @@ export type Schema = EntityShape & {
|
|
|
19
20
|
value: String<256>;
|
|
20
21
|
recursive: Boolean;
|
|
21
22
|
sourceEntity: String<32>;
|
|
23
|
+
desc?: String<256> | null;
|
|
22
24
|
actionAuth$path?: Array<ActionAuth.Schema>;
|
|
23
25
|
actionAuth$path$$aggr?: AggregationResult<ActionAuth.Schema>;
|
|
24
26
|
relationAuth$path?: Array<RelationAuth.Schema>;
|
|
@@ -39,6 +41,7 @@ type AttrFilter = {
|
|
|
39
41
|
value: Q_StringValue;
|
|
40
42
|
recursive: Q_BooleanValue;
|
|
41
43
|
sourceEntity: Q_StringValue;
|
|
44
|
+
desc: Q_StringValue;
|
|
42
45
|
actionAuth$path: ActionAuth.Filter & SubQueryPredicateMetadata;
|
|
43
46
|
relationAuth$path: RelationAuth.Filter & SubQueryPredicateMetadata;
|
|
44
47
|
modiEntity$entity: ModiEntity.Filter & SubQueryPredicateMetadata;
|
|
@@ -56,6 +59,7 @@ export type Projection = {
|
|
|
56
59
|
value?: number;
|
|
57
60
|
recursive?: number;
|
|
58
61
|
sourceEntity?: number;
|
|
62
|
+
desc?: number;
|
|
59
63
|
actionAuth$path?: ActionAuth.Selection & {
|
|
60
64
|
$entity: "actionAuth";
|
|
61
65
|
};
|
|
@@ -100,6 +104,8 @@ export type SortAttr = {
|
|
|
100
104
|
recursive: number;
|
|
101
105
|
} | {
|
|
102
106
|
sourceEntity: number;
|
|
107
|
+
} | {
|
|
108
|
+
desc: number;
|
|
103
109
|
} | {
|
|
104
110
|
[k: string]: any;
|
|
105
111
|
} | OneOf<ExprOp<OpAttr | string>>;
|
|
@@ -96,11 +96,13 @@ function destructVariableDeclaration(vd) {
|
|
|
96
96
|
(0, assert_1.default)(ts.isIdentifier(vd.name));
|
|
97
97
|
(0, assert_1.default)(vd.name.text.startsWith('total'));
|
|
98
98
|
const on = (0, string_1.firstLetterLowerCase)(vd.name.text.slice(5));
|
|
99
|
-
const { initializer } = vd;
|
|
100
|
-
(0, assert_1.default)(ts.
|
|
101
|
-
|
|
102
|
-
(0, assert_1.default)(
|
|
103
|
-
|
|
99
|
+
const { initializer: nonNullExpression } = vd;
|
|
100
|
+
(0, assert_1.default)(ts.isNonNullExpression(nonNullExpression));
|
|
101
|
+
const { expression: callExpression } = nonNullExpression;
|
|
102
|
+
(0, assert_1.default)(ts.isCallExpression(callExpression));
|
|
103
|
+
(0, assert_1.default)(ts.isIdentifier(callExpression.expression) && callExpression.expression.text === 'mergeConcatMany');
|
|
104
|
+
(0, assert_1.default)(callExpression.arguments.length === 1);
|
|
105
|
+
const [arg] = callExpression.arguments;
|
|
104
106
|
(0, assert_1.default)(ts.isAsExpression(arg));
|
|
105
107
|
const { expression } = arg;
|
|
106
108
|
(0, assert_1.default)(ts.isArrayLiteralExpression(expression));
|
|
@@ -276,17 +278,17 @@ function outputRuntimeCxt(dependencies, briefNames, sourceFile, printer, filenam
|
|
|
276
278
|
(0, fs_1.writeFileSync)(filename, result, { flag: 'w' });
|
|
277
279
|
console.log(`构建${filename}文件成功`);
|
|
278
280
|
}
|
|
279
|
-
function
|
|
281
|
+
function outputContext(depGraph, sourceFile, printer, filename) {
|
|
280
282
|
// 目前只支持单向依赖,未来可以利用mixin来实现多类的继承
|
|
281
283
|
// assert(depGraph.roots.length <= 1);
|
|
282
284
|
let root = depGraph.ascOrder.length > 0 ? depGraph.ascOrder[depGraph.ascOrder.length - 1] : 'oak-frontend-base';
|
|
283
|
-
const statements =
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
285
|
+
const { statements } = sourceFile;
|
|
286
|
+
const isBackend = filename.includes('BackendRuntimeContext');
|
|
287
|
+
const statements2 = [
|
|
288
|
+
factory.createImportDeclaration(undefined, factory.createImportClause(false, factory.createIdentifier(isBackend ? "BaseBackendRuntimeContext" : "BaseFrontendRuntimeContext"), undefined), factory.createStringLiteral(`${root}/es/context/${isBackend ? 'BackendRuntimeContext' : 'FrontendRuntimeContext'}`), undefined),
|
|
289
|
+
...statements
|
|
288
290
|
];
|
|
289
|
-
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(
|
|
291
|
+
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
290
292
|
(0, fs_1.writeFileSync)(filename, result, { flag: 'w' });
|
|
291
293
|
console.log(`构建${filename}文件成功`);
|
|
292
294
|
}
|
|
@@ -480,17 +482,6 @@ function outputIntializeDev(cwd, dependencies, briefNames, sourceFile, printer,
|
|
|
480
482
|
objectDict.common = [variableName];
|
|
481
483
|
}
|
|
482
484
|
}
|
|
483
|
-
// render
|
|
484
|
-
if ((0, fs_1.existsSync)(join(destDir, 'configuration', 'render.js'))) {
|
|
485
|
-
const variableName = `${briefNames[idx]}Render`;
|
|
486
|
-
importStatements.push(factory.createImportDeclaration(undefined, factory.createImportClause(false, factory.createIdentifier(variableName), undefined), factory.createStringLiteral(join(dep, destDirName, 'configuration', 'render')), undefined));
|
|
487
|
-
if (objectDict.render) {
|
|
488
|
-
objectDict.render.push(variableName);
|
|
489
|
-
}
|
|
490
|
-
else {
|
|
491
|
-
objectDict.render = [variableName];
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
485
|
// features
|
|
495
486
|
if ((0, fs_1.existsSync)(join(destDir, 'features'))) {
|
|
496
487
|
importStatements.push(factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([
|
|
@@ -689,20 +680,6 @@ function outputIntializeFeatures(cwd, dependencies, briefNames, sourceFile, prin
|
|
|
689
680
|
factory.createTypeReferenceNode('EntityDict')
|
|
690
681
|
])))
|
|
691
682
|
});
|
|
692
|
-
Object.assign(funcStmt.body, {
|
|
693
|
-
statements: [
|
|
694
|
-
...features.map((ele, idx) => {
|
|
695
|
-
const args = [
|
|
696
|
-
factory.createIdentifier("features"),
|
|
697
|
-
];
|
|
698
|
-
if (dependencies[idx] === 'oak-general-business') {
|
|
699
|
-
args.push(factory.createIdentifier("accessConfiguration"));
|
|
700
|
-
}
|
|
701
|
-
return factory.createExpressionStatement(factory.createAwaitExpression(factory.createCallExpression(factory.createIdentifier(`initialize${(0, string_1.firstLetterUpperCase)(ele)}Features`), undefined, args)));
|
|
702
|
-
}).flat(),
|
|
703
|
-
...funcStmt.body.statements,
|
|
704
|
-
]
|
|
705
|
-
});
|
|
706
683
|
}
|
|
707
684
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(statements2), sourceFile);
|
|
708
685
|
(0, fs_1.writeFileSync)(filename, result, { flag: 'w' });
|
|
@@ -778,18 +755,6 @@ function tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer) {
|
|
|
778
755
|
const moduleDir = join(cwd, 'node_modules', dep);
|
|
779
756
|
const moduleTemplateDir = join(moduleDir, 'template');
|
|
780
757
|
if ((0, fs_1.existsSync)(moduleTemplateDir)) {
|
|
781
|
-
const entitiesDir = join(moduleTemplateDir, 'entities');
|
|
782
|
-
if ((0, fs_1.existsSync)(entitiesDir)) {
|
|
783
|
-
// entities目录下的定义直接拷贝过去(如果尚不存在的话)
|
|
784
|
-
const prjEntitiesDir = join(cwd, 'src', 'entities');
|
|
785
|
-
const result = (0, fs_1.readdirSync)(entitiesDir);
|
|
786
|
-
result.forEach((filename) => {
|
|
787
|
-
if (!(0, fs_1.existsSync)(join(prjEntitiesDir, filename))) {
|
|
788
|
-
console.log(`拷贝${join(entitiesDir, filename)}到${prjEntitiesDir}目录下`);
|
|
789
|
-
(0, fs_extra_1.copySync)(join(entitiesDir, filename), join(prjEntitiesDir, filename));
|
|
790
|
-
}
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
758
|
// data.ts中规定的初始化数据,拷贝到data目录下,并注入到data/index.ts
|
|
794
759
|
const dataFile = join(moduleTemplateDir, 'data', 'data.ts');
|
|
795
760
|
if ((0, fs_1.existsSync)(dataFile)) {
|
|
@@ -868,7 +833,9 @@ function buildDependency(rebuild) {
|
|
|
868
833
|
join(cwd, 'node_modules', env_1.OAK_CLI_MODULE_NAME, 'templateFiles', 'RuntimeCxt.ts'),
|
|
869
834
|
join(cwd, 'node_modules', env_1.OAK_CLI_MODULE_NAME, 'templateFiles', 'DependentExceptions.ts'),
|
|
870
835
|
join(cwd, 'node_modules', env_1.OAK_CLI_MODULE_NAME, 'templateFiles', 'polyfill.d.ts'),
|
|
871
|
-
join(cwd, 'node_modules', env_1.OAK_CLI_MODULE_NAME, 'templateFiles', 'features/index.ts')
|
|
836
|
+
join(cwd, 'node_modules', env_1.OAK_CLI_MODULE_NAME, 'templateFiles', 'features/index.ts'),
|
|
837
|
+
join(cwd, 'node_modules', env_1.OAK_CLI_MODULE_NAME, 'templateFiles', 'BackendRuntimeContext.ts'),
|
|
838
|
+
join(cwd, 'node_modules', env_1.OAK_CLI_MODULE_NAME, 'templateFiles', 'FrontendRuntimeContext.ts')
|
|
872
839
|
];
|
|
873
840
|
const program = ts.createProgram(templateFileList, {});
|
|
874
841
|
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
|
@@ -895,13 +862,6 @@ function buildDependency(rebuild) {
|
|
|
895
862
|
outputIntializeFeatures(cwd, dependencies, briefNames, program.getSourceFile(templateFileList[2]), printer, initFeaturesFile);
|
|
896
863
|
}
|
|
897
864
|
}
|
|
898
|
-
const dependentContextFile = join(cwd, 'src', 'context', 'DependentContext.ts');
|
|
899
|
-
if ((0, fs_1.existsSync)(dependentContextFile) && !rebuild) {
|
|
900
|
-
console.log(`[${dependentContextFile}]文件已经存在,无需构建启动文件`);
|
|
901
|
-
}
|
|
902
|
-
else {
|
|
903
|
-
outputDependentContext(depGraph, printer, dependentContextFile);
|
|
904
|
-
}
|
|
905
865
|
const runtimeCxtFile = join(cwd, 'src', 'types', 'RuntimeCxt.ts');
|
|
906
866
|
if ((0, fs_1.existsSync)(runtimeCxtFile) && !rebuild) {
|
|
907
867
|
console.log(`[${runtimeCxtFile}]文件已经存在,无需构建启动文件`);
|
|
@@ -930,6 +890,20 @@ function buildDependency(rebuild) {
|
|
|
930
890
|
else {
|
|
931
891
|
outputFeatureIndex(dependencies, briefNames, program.getSourceFile(templateFileList[6]), printer, featureIndexFile, isModule);
|
|
932
892
|
}
|
|
893
|
+
let contextFile = join(cwd, 'src', 'context', 'BackendRuntimeContext.ts');
|
|
894
|
+
if ((0, fs_1.existsSync)(contextFile) && !rebuild) {
|
|
895
|
+
console.log(`[${contextFile}]文件已经存在,无需构建启动文件`);
|
|
896
|
+
}
|
|
897
|
+
else {
|
|
898
|
+
outputContext(depGraph, program.getSourceFile(templateFileList[7]), printer, contextFile);
|
|
899
|
+
}
|
|
900
|
+
contextFile = join(cwd, 'src', 'context', 'FrontendRuntimeContext.ts');
|
|
901
|
+
if ((0, fs_1.existsSync)(contextFile) && !rebuild) {
|
|
902
|
+
console.log(`[${contextFile}]文件已经存在,无需构建启动文件`);
|
|
903
|
+
}
|
|
904
|
+
else {
|
|
905
|
+
outputContext(depGraph, program.getSourceFile(templateFileList[8]), printer, contextFile);
|
|
906
|
+
}
|
|
933
907
|
// 把各个依赖项目的一些初始化的文件拷贝过去
|
|
934
908
|
if (!isModule) {
|
|
935
909
|
tryCopyModuleTemplateFiles(cwd, dependencies, briefNames, printer);
|
|
@@ -119,7 +119,7 @@ function makeWebAllRouters(namespaceDir, projectDir, routerFileDir) {
|
|
|
119
119
|
const children = Object.values(pages).filter((ele) => ele.hasWeb).map(({ path, oakDisablePulldownRefresh }) => {
|
|
120
120
|
const properties = [
|
|
121
121
|
factory.createPropertyAssignment('path', factory.createStringLiteral(path)),
|
|
122
|
-
factory.createPropertyAssignment('namespace', factory.createStringLiteral(
|
|
122
|
+
factory.createPropertyAssignment('namespace', factory.createStringLiteral(ns)),
|
|
123
123
|
factory.createPropertyAssignment('meta', factory.createObjectLiteralExpression([
|
|
124
124
|
factory.createPropertyAssignment('oakDisablePulldownRefresh', oakDisablePulldownRefresh ? factory.createTrue() : factory.createFalse())
|
|
125
125
|
])),
|
package/lib/entities/Path.d.ts
CHANGED
package/lib/entities/Path.js
CHANGED
|
@@ -79,7 +79,7 @@ function createUniqueCheckers(schema) {
|
|
|
79
79
|
entity,
|
|
80
80
|
action: 'create',
|
|
81
81
|
type: 'logicalData',
|
|
82
|
-
priority: types_1.CHECKER_MAX_PRIORITY,
|
|
82
|
+
priority: types_1.CHECKER_MAX_PRIORITY,
|
|
83
83
|
checker: (operation, context) => {
|
|
84
84
|
const { data } = operation;
|
|
85
85
|
if (data instanceof Array) {
|
|
@@ -95,9 +95,9 @@ function createUniqueCheckers(schema) {
|
|
|
95
95
|
}
|
|
96
96
|
}, {
|
|
97
97
|
entity,
|
|
98
|
-
action: 'update',
|
|
98
|
+
action: 'update',
|
|
99
99
|
type: 'logicalData',
|
|
100
|
-
priority: types_1.CHECKER_MAX_PRIORITY,
|
|
100
|
+
priority: types_1.CHECKER_MAX_PRIORITY,
|
|
101
101
|
checker: (operation, context) => {
|
|
102
102
|
const { data, filter: operationFilter } = operation;
|
|
103
103
|
if (data) {
|
|
@@ -227,7 +227,7 @@ function createActionTransformerCheckers(actionDefDict) {
|
|
|
227
227
|
action: 'create',
|
|
228
228
|
type: 'logical',
|
|
229
229
|
entity,
|
|
230
|
-
priority: 10,
|
|
230
|
+
priority: 10,
|
|
231
231
|
checker: (operation) => {
|
|
232
232
|
const { data } = operation;
|
|
233
233
|
if (data instanceof Array) {
|
package/lib/store/checker.js
CHANGED
|
@@ -352,11 +352,11 @@ function checkAttributeLegal(schema, entity, data) {
|
|
|
352
352
|
case 'char':
|
|
353
353
|
case 'varchar': {
|
|
354
354
|
if (typeof data[attr] !== 'string') {
|
|
355
|
-
throw new Exception_1.OakInputIllegalException(entity, [attr], 'not a string
|
|
355
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], `${entity}: ${attr}'s value "${data[attr]}" is not a string`);
|
|
356
356
|
}
|
|
357
357
|
const { length } = params;
|
|
358
358
|
if (length && data[attr].length > length) {
|
|
359
|
-
throw new Exception_1.OakInputIllegalException(entity, [attr], 'too long
|
|
359
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], `${entity}: ${attr}'s value "${data[attr]}" is too long`);
|
|
360
360
|
}
|
|
361
361
|
break;
|
|
362
362
|
}
|
|
@@ -367,21 +367,21 @@ function checkAttributeLegal(schema, entity, data) {
|
|
|
367
367
|
case 'decimal':
|
|
368
368
|
case 'money': {
|
|
369
369
|
if (typeof data[attr] !== 'number') {
|
|
370
|
-
throw new Exception_1.OakInputIllegalException(entity, [attr], 'not a number
|
|
370
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], `${entity}: ${attr}'s value "${data[attr]}" is not a number`);
|
|
371
371
|
}
|
|
372
372
|
const { min, max } = params || {};
|
|
373
373
|
if (typeof min === 'number' && data[attr] < min) {
|
|
374
|
-
throw new Exception_1.OakInputIllegalException(entity, [attr], 'too small
|
|
374
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], `${entity}: ${attr}'s value "${data[attr]}" is too small`);
|
|
375
375
|
}
|
|
376
376
|
if (typeof max === 'number' && data[attr] > max) {
|
|
377
|
-
throw new Exception_1.OakInputIllegalException(entity, [attr], 'too big
|
|
377
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], `${entity}: ${attr}'s value "${data[attr]}" is too big`);
|
|
378
378
|
}
|
|
379
379
|
break;
|
|
380
380
|
}
|
|
381
381
|
case 'enum': {
|
|
382
382
|
(0, assert_1.default)(enumeration);
|
|
383
383
|
if (!enumeration.includes(data[attr])) {
|
|
384
|
-
throw new Exception_1.OakInputIllegalException(entity, [attr], 'not in enumeration
|
|
384
|
+
throw new Exception_1.OakInputIllegalException(entity, [attr], `${entity}: ${attr}'s value "${data[attr]}" is not in enumeration`);
|
|
385
385
|
}
|
|
386
386
|
break;
|
|
387
387
|
}
|
package/lib/store/filter.js
CHANGED
|
@@ -22,7 +22,14 @@ function translateCreateDataToFilter(schema, entity, data, allowUnrecoganized) {
|
|
|
22
22
|
'array',
|
|
23
23
|
'object'
|
|
24
24
|
].includes(schema[entity].attributes[attr]?.type)) {
|
|
25
|
-
|
|
25
|
+
if (data[attr] === null) {
|
|
26
|
+
data2[attr] = {
|
|
27
|
+
$exists: false,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
data2[attr] = data[attr];
|
|
32
|
+
}
|
|
26
33
|
}
|
|
27
34
|
}
|
|
28
35
|
}
|
package/lib/utils/assert.d.ts
CHANGED
|
@@ -60,7 +60,7 @@ function destructRelationPath(schema, entity, path, relationFilter, recursive) {
|
|
|
60
60
|
},
|
|
61
61
|
filter: relationFilter,
|
|
62
62
|
} // as ED['userRelation']['Selection']
|
|
63
|
-
},
|
|
63
|
+
},
|
|
64
64
|
getData: (d) => {
|
|
65
65
|
return d.userRelation$entity;
|
|
66
66
|
},
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { EntityDict } from '../types/Entity';
|
|
2
|
+
import { EntityDict as BaseEntityDict } from '../base-app-domain';
|
|
3
|
+
import { StorageSchema } from '../types';
|
|
4
|
+
export declare function compareRow<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(schema: StorageSchema<ED>, entity: T, row1: Partial<ED[T]['Schema']>, row2: Partial<ED[T]['Schema']>): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* 比较两行数据是否完全相等
|
|
7
|
+
* @param entity
|
|
8
|
+
* @param schema
|
|
9
|
+
* @param row1
|
|
10
|
+
* @param row2
|
|
11
|
+
*/
|
|
12
|
+
export declare function compareRows<ED extends EntityDict & BaseEntityDict, T extends keyof ED>(schema: StorageSchema<ED>, entity: T, rows1: Partial<ED[T]['Schema']>[], rows2: Partial<ED[T]['Schema']>[]): boolean;
|
package/lib/utils/row.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareRows = exports.compareRow = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const lodash_1 = require("./lodash");
|
|
6
|
+
const relation_1 = require("../store/relation");
|
|
7
|
+
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
8
|
+
function compareRow(schema, entity, row1, row2) {
|
|
9
|
+
const attrs1 = Object.keys(row1).filter(ele => !ele.startsWith('$$'));
|
|
10
|
+
const attrs2 = Object.keys(row2).filter(ele => !ele.startsWith('$$'));
|
|
11
|
+
if ((0, lodash_1.difference)(attrs1, attrs2).length > 0) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
for (const attr of attrs1) {
|
|
15
|
+
const rel = (0, relation_1.judgeRelation)(schema, entity, attr);
|
|
16
|
+
if (rel === 0) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
else if (rel === 1) {
|
|
20
|
+
if (row1[attr] !== row2[attr]) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (rel === 2) {
|
|
25
|
+
if (!compareRow(schema, attr, row1[attr], row2[attr])) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else if (typeof rel === 'string') {
|
|
30
|
+
if (!compareRow(schema, rel, row1[attr], row2[attr])) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
(0, assert_1.default)(rel instanceof Array);
|
|
36
|
+
// 如果两组对象一样但顺序不一样怎么办?暂时应该不用考虑这种情况,因为只有前台runningTree使用(by Xc)
|
|
37
|
+
if (!compareRows(schema, rel[0], row1[attr], row2[attr])) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
exports.compareRow = compareRow;
|
|
45
|
+
/**
|
|
46
|
+
* 比较两行数据是否完全相等
|
|
47
|
+
* @param entity
|
|
48
|
+
* @param schema
|
|
49
|
+
* @param row1
|
|
50
|
+
* @param row2
|
|
51
|
+
*/
|
|
52
|
+
function compareRows(schema, entity, rows1, rows2) {
|
|
53
|
+
if (rows1.length !== rows2.length) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
let idx = 0;
|
|
57
|
+
while (idx < rows1.length) {
|
|
58
|
+
const row1 = rows1[idx];
|
|
59
|
+
const row2 = rows2[idx];
|
|
60
|
+
if (!compareRow(schema, entity, row1, row2)) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
idx++;
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
exports.compareRows = compareRows;
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { Schema as Modi } from './Modi';
|
|
4
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
5
|
-
|
|
6
|
-
export interface Schema extends EntityShape {
|
|
7
|
-
modi: Modi,
|
|
8
|
-
entity: String<32>;
|
|
9
|
-
entityId: String<64>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
-
locales: {
|
|
14
|
-
zh_CN: {
|
|
15
|
-
name: '更新对象连接',
|
|
16
|
-
attr: {
|
|
17
|
-
modi: '更新',
|
|
18
|
-
entity: '关联对象',
|
|
19
|
-
entityId: '关联对象id',
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
configuration: {
|
|
24
|
-
actionType: 'appendOnly',
|
|
25
|
-
}
|
|
26
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { Schema as Modi } from './Modi';
|
|
4
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
5
|
+
|
|
6
|
+
export interface Schema extends EntityShape {
|
|
7
|
+
modi: Modi,
|
|
8
|
+
entity: String<32>;
|
|
9
|
+
entityId: String<64>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
+
locales: {
|
|
14
|
+
zh_CN: {
|
|
15
|
+
name: '更新对象连接',
|
|
16
|
+
attr: {
|
|
17
|
+
modi: '更新',
|
|
18
|
+
entity: '关联对象',
|
|
19
|
+
entityId: '关联对象id',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
configuration: {
|
|
24
|
+
actionType: 'appendOnly',
|
|
25
|
+
}
|
|
26
|
+
};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape, Configuration } from '../types/Entity';
|
|
3
|
-
import { LocaleDef } from '../types/Locale';
|
|
4
|
-
import { Schema as Oper } from './Oper';
|
|
5
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
6
|
-
|
|
7
|
-
export interface Schema extends EntityShape {
|
|
8
|
-
oper: Oper,
|
|
9
|
-
entity: String<32>;
|
|
10
|
-
entityId: String<64>;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
14
|
-
locales: {
|
|
15
|
-
zh_CN: {
|
|
16
|
-
name: '操作对象连接',
|
|
17
|
-
attr: {
|
|
18
|
-
oper: '操作',
|
|
19
|
-
entity: '关联对象',
|
|
20
|
-
entityId: '关联对象id',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
configuration: {
|
|
25
|
-
actionType: 'appendOnly',
|
|
26
|
-
}
|
|
27
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape, Configuration } from '../types/Entity';
|
|
3
|
+
import { LocaleDef } from '../types/Locale';
|
|
4
|
+
import { Schema as Oper } from './Oper';
|
|
5
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
6
|
+
|
|
7
|
+
export interface Schema extends EntityShape {
|
|
8
|
+
oper: Oper,
|
|
9
|
+
entity: String<32>;
|
|
10
|
+
entityId: String<64>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
14
|
+
locales: {
|
|
15
|
+
zh_CN: {
|
|
16
|
+
name: '操作对象连接',
|
|
17
|
+
attr: {
|
|
18
|
+
oper: '操作',
|
|
19
|
+
entity: '关联对象',
|
|
20
|
+
entityId: '关联对象id',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
configuration: {
|
|
25
|
+
actionType: 'appendOnly',
|
|
26
|
+
}
|
|
27
|
+
};
|
package/src/entities/Path.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface Schema extends EntityShape {
|
|
|
7
7
|
value: String<256>;
|
|
8
8
|
recursive: Boolean;
|
|
9
9
|
sourceEntity: String<32>;
|
|
10
|
+
desc?: String<256>;
|
|
10
11
|
};
|
|
11
12
|
|
|
12
13
|
const entityDesc: EntityDesc<Schema> = {
|
|
@@ -34,9 +35,10 @@ const entityDesc: EntityDesc<Schema> = {
|
|
|
34
35
|
name: '关系路径',
|
|
35
36
|
attr: {
|
|
36
37
|
sourceEntity: '源对象',
|
|
37
|
-
value: '
|
|
38
|
+
value: '路径',
|
|
38
39
|
destEntity: '目标对象',
|
|
39
|
-
recursive: '
|
|
40
|
+
recursive: '是否递归',
|
|
41
|
+
desc: '描述',
|
|
40
42
|
},
|
|
41
43
|
},
|
|
42
44
|
},
|
package/src/entities/Relation.ts
CHANGED
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
-
|
|
5
|
-
export interface Schema extends EntityShape {
|
|
6
|
-
entity: String<32>;
|
|
7
|
-
entityId?: String<64>; // 可以为空
|
|
8
|
-
name?: String<32>;
|
|
9
|
-
display?: String<32>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
-
locales: {
|
|
14
|
-
zh_CN: {
|
|
15
|
-
name: '用户授权',
|
|
16
|
-
attr: {
|
|
17
|
-
name: '关系',
|
|
18
|
-
entity: '目标对象',
|
|
19
|
-
entityId: '目标对象id',
|
|
20
|
-
display: '显示值',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
indexes: [
|
|
25
|
-
{
|
|
26
|
-
name: 'index_targetEntity_entityId_name',
|
|
27
|
-
attributes: [
|
|
28
|
-
{
|
|
29
|
-
name: 'entity',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
name: 'entityId',
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: 'name',
|
|
36
|
-
}
|
|
37
|
-
],
|
|
38
|
-
config: {
|
|
39
|
-
unique: true,
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
]
|
|
43
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
+
|
|
5
|
+
export interface Schema extends EntityShape {
|
|
6
|
+
entity: String<32>;
|
|
7
|
+
entityId?: String<64>; // 可以为空
|
|
8
|
+
name?: String<32>;
|
|
9
|
+
display?: String<32>;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
13
|
+
locales: {
|
|
14
|
+
zh_CN: {
|
|
15
|
+
name: '用户授权',
|
|
16
|
+
attr: {
|
|
17
|
+
name: '关系',
|
|
18
|
+
entity: '目标对象',
|
|
19
|
+
entityId: '目标对象id',
|
|
20
|
+
display: '显示值',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
indexes: [
|
|
25
|
+
{
|
|
26
|
+
name: 'index_targetEntity_entityId_name',
|
|
27
|
+
attributes: [
|
|
28
|
+
{
|
|
29
|
+
name: 'entity',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'entityId',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'name',
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
config: {
|
|
39
|
+
unique: true,
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
]
|
|
43
|
+
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
-
import { Schema as UserEntityGrant } from './UserEntityGrant';
|
|
5
|
-
import { Schema as User } from './User';
|
|
6
|
-
import { Schema as Relation } from './Relation';
|
|
7
|
-
import { Schema as UserRelation } from './UserRelation';
|
|
8
|
-
|
|
9
|
-
export interface Schema extends EntityShape {
|
|
10
|
-
ueg: UserEntityGrant;
|
|
11
|
-
user: User;
|
|
12
|
-
relation: Relation;
|
|
13
|
-
claimEntityId: String<64>;
|
|
14
|
-
userRelation: UserRelation;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const entityDesc: EntityDesc<Schema, ''> = {
|
|
18
|
-
locales: {
|
|
19
|
-
zh_CN: {
|
|
20
|
-
name: '用户授权领取',
|
|
21
|
-
attr: {
|
|
22
|
-
ueg: '授权',
|
|
23
|
-
user: '用户',
|
|
24
|
-
relation: '关系',
|
|
25
|
-
claimEntityId: '对象Id',
|
|
26
|
-
userRelation: '用户关系',
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
},
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
+
import { Schema as UserEntityGrant } from './UserEntityGrant';
|
|
5
|
+
import { Schema as User } from './User';
|
|
6
|
+
import { Schema as Relation } from './Relation';
|
|
7
|
+
import { Schema as UserRelation } from './UserRelation';
|
|
8
|
+
|
|
9
|
+
export interface Schema extends EntityShape {
|
|
10
|
+
ueg: UserEntityGrant;
|
|
11
|
+
user: User;
|
|
12
|
+
relation: Relation;
|
|
13
|
+
claimEntityId: String<64>;
|
|
14
|
+
userRelation: UserRelation;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const entityDesc: EntityDesc<Schema, ''> = {
|
|
18
|
+
locales: {
|
|
19
|
+
zh_CN: {
|
|
20
|
+
name: '用户授权领取',
|
|
21
|
+
attr: {
|
|
22
|
+
ueg: '授权',
|
|
23
|
+
user: '用户',
|
|
24
|
+
relation: '关系',
|
|
25
|
+
claimEntityId: '对象Id',
|
|
26
|
+
userRelation: '用户关系',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
30
|
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { EntityShape } from '../types/Entity';
|
|
3
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
-
|
|
5
|
-
type RelationIds = string[];
|
|
6
|
-
|
|
7
|
-
export interface Schema extends EntityShape {
|
|
8
|
-
relationEntity: String<32>;
|
|
9
|
-
relationEntityFilter: Object;
|
|
10
|
-
relationIds: RelationIds;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const entityDesc: EntityDesc<Schema, ''> = {
|
|
14
|
-
locales: {
|
|
15
|
-
zh_CN: {
|
|
16
|
-
name: '用户授权',
|
|
17
|
-
attr: {
|
|
18
|
-
relationIds: '关系',
|
|
19
|
-
relationEntity: '关联对象',
|
|
20
|
-
relationEntityFilter: '对象限定条件',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { EntityShape } from '../types/Entity';
|
|
3
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
4
|
+
|
|
5
|
+
type RelationIds = string[];
|
|
6
|
+
|
|
7
|
+
export interface Schema extends EntityShape {
|
|
8
|
+
relationEntity: String<32>;
|
|
9
|
+
relationEntityFilter: Object;
|
|
10
|
+
relationIds: RelationIds;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const entityDesc: EntityDesc<Schema, ''> = {
|
|
14
|
+
locales: {
|
|
15
|
+
zh_CN: {
|
|
16
|
+
name: '用户授权',
|
|
17
|
+
attr: {
|
|
18
|
+
relationIds: '关系',
|
|
19
|
+
relationEntity: '关联对象',
|
|
20
|
+
relationEntityFilter: '对象限定条件',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import { String } from '../types/DataType';
|
|
2
|
-
import { LocaleDef } from '../types/Locale';
|
|
3
|
-
import { EntityShape } from '../types/Entity';
|
|
4
|
-
import { Index } from '../types/Storage';
|
|
5
|
-
import { Schema as User } from './User';
|
|
6
|
-
import { Schema as Relation } from './Relation';
|
|
7
|
-
import { EntityDesc } from '../types/EntityDesc';
|
|
8
|
-
|
|
9
|
-
export interface Schema extends EntityShape {
|
|
10
|
-
user: User;
|
|
11
|
-
relation: Relation;
|
|
12
|
-
entity: String<32>;
|
|
13
|
-
entityId: String<64>;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
const entityDesc: EntityDesc<Schema> = {
|
|
17
|
-
locales: {
|
|
18
|
-
zh_CN: {
|
|
19
|
-
name: '用户对象关系',
|
|
20
|
-
attr: {
|
|
21
|
-
user: '关系',
|
|
22
|
-
relation: '目标关系',
|
|
23
|
-
entity: '目标对象',
|
|
24
|
-
entityId: '目标对象ID',
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
indexes: [
|
|
29
|
-
{
|
|
30
|
-
name: 'index_user_entity_entityId_relation',
|
|
31
|
-
attributes: [
|
|
32
|
-
{
|
|
33
|
-
name: 'user',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
name: 'entity',
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
name: 'entityId',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'relation',
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
config: {
|
|
46
|
-
unique: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
]
|
|
50
|
-
};
|
|
1
|
+
import { String } from '../types/DataType';
|
|
2
|
+
import { LocaleDef } from '../types/Locale';
|
|
3
|
+
import { EntityShape } from '../types/Entity';
|
|
4
|
+
import { Index } from '../types/Storage';
|
|
5
|
+
import { Schema as User } from './User';
|
|
6
|
+
import { Schema as Relation } from './Relation';
|
|
7
|
+
import { EntityDesc } from '../types/EntityDesc';
|
|
8
|
+
|
|
9
|
+
export interface Schema extends EntityShape {
|
|
10
|
+
user: User;
|
|
11
|
+
relation: Relation;
|
|
12
|
+
entity: String<32>;
|
|
13
|
+
entityId: String<64>;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const entityDesc: EntityDesc<Schema> = {
|
|
17
|
+
locales: {
|
|
18
|
+
zh_CN: {
|
|
19
|
+
name: '用户对象关系',
|
|
20
|
+
attr: {
|
|
21
|
+
user: '关系',
|
|
22
|
+
relation: '目标关系',
|
|
23
|
+
entity: '目标对象',
|
|
24
|
+
entityId: '目标对象ID',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
indexes: [
|
|
29
|
+
{
|
|
30
|
+
name: 'index_user_entity_entityId_relation',
|
|
31
|
+
attributes: [
|
|
32
|
+
{
|
|
33
|
+
name: 'user',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
name: 'entity',
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: 'entityId',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: 'relation',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
config: {
|
|
46
|
+
unique: true,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
]
|
|
50
|
+
};
|