oak-domain 5.1.10 → 5.1.12
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/RelationId.d.ts +1 -0
- package/lib/base-app-domain/RelationId.js +2 -0
- package/lib/compiler/dependencyBuilder.js +1 -36
- package/lib/compiler/schemalBuilder.js +28 -10
- package/lib/types/Configuration.d.ts +10 -1
- package/lib/utils/SimpleConnector.js +7 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare namespace RelationId { }
|
|
@@ -596,9 +596,7 @@ function outputFeatureIndex(dependencies, briefNames, sourceFile, printer, filen
|
|
|
596
596
|
adNames.push(adName);
|
|
597
597
|
});
|
|
598
598
|
// 导入自己的AspectDict:import { AspectDict } from '../aspects/AspectDict';
|
|
599
|
-
importStatements.push(factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, factory.createIdentifier("AspectDict"), factory.createIdentifier("ProjectAspectDict"))])), factory.createStringLiteral("../aspects/AspectDict"), undefined)
|
|
600
|
-
// import { createService } from 'oak-frontend-base/es/aspects/AspectService';
|
|
601
|
-
factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("createService"))])), factory.createStringLiteral("oak-frontend-base/es/aspects/AspectService"), undefined));
|
|
599
|
+
importStatements.push(factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, factory.createIdentifier("AspectDict"), factory.createIdentifier("ProjectAspectDict"))])), factory.createStringLiteral("../aspects/AspectDict"), undefined));
|
|
602
600
|
// 创建一个这样的type: type MergeAspectDict = ProjectAspectDict & GenernalAspectDict<EntityDict>;
|
|
603
601
|
// 除了ProjectAspectDict,还有其他的AspectDict,需要<EntityDict>参数
|
|
604
602
|
const adTypeDeclaration = factory.createTypeAliasDeclaration(undefined, factory.createIdentifier("MergeAspectDict"), undefined, factory.createIntersectionTypeNode([
|
|
@@ -630,39 +628,6 @@ function outputFeatureIndex(dependencies, briefNames, sourceFile, printer, filen
|
|
|
630
628
|
]))
|
|
631
629
|
])
|
|
632
630
|
});
|
|
633
|
-
const functionBlock = stmt4.body;
|
|
634
|
-
(0, assert_1.default)(functionBlock && ts.isBlock(functionBlock));
|
|
635
|
-
let returnI = 0;
|
|
636
|
-
while (true) {
|
|
637
|
-
const stmt = functionBlock.statements[returnI];
|
|
638
|
-
if (ts.isReturnStatement(stmt)) {
|
|
639
|
-
break;
|
|
640
|
-
}
|
|
641
|
-
returnI++;
|
|
642
|
-
}
|
|
643
|
-
// 在return之前,插入const aspect = createService<EntityDict, MergeAspectDict>(cache);
|
|
644
|
-
const aspectDeclaration = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier("aspect"), undefined, undefined, factory.createCallExpression(factory.createIdentifier("createService"), [
|
|
645
|
-
factory.createTypeReferenceNode(factory.createIdentifier("EntityDict"), undefined),
|
|
646
|
-
factory.createTypeReferenceNode(factory.createIdentifier("MergeAspectDict"), undefined)
|
|
647
|
-
], [factory.createIdentifier("cache")]))], ts.NodeFlags.Const));
|
|
648
|
-
const returnStmt = functionBlock.statements[returnI];
|
|
649
|
-
(0, assert_1.default)(returnStmt.expression && ts.isObjectLiteralExpression(returnStmt.expression));
|
|
650
|
-
// 在里面添加aspect
|
|
651
|
-
const { properties } = returnStmt.expression;
|
|
652
|
-
Object.assign(returnStmt.expression, {
|
|
653
|
-
properties: [
|
|
654
|
-
...properties,
|
|
655
|
-
factory.createShorthandPropertyAssignment(factory.createIdentifier("aspect"))
|
|
656
|
-
]
|
|
657
|
-
});
|
|
658
|
-
// 把aspectDeclaration 插入到return之前
|
|
659
|
-
const newFunctionStatements = [
|
|
660
|
-
...functionBlock.statements.slice(0, returnI),
|
|
661
|
-
aspectDeclaration,
|
|
662
|
-
...functionBlock.statements.slice(returnI)
|
|
663
|
-
];
|
|
664
|
-
const newBlock = factory.createBlock(newFunctionStatements);
|
|
665
|
-
Object.assign(functionBlock, newBlock);
|
|
666
631
|
statements2 = [
|
|
667
632
|
...statements.slice(0, i),
|
|
668
633
|
...importStatements,
|
|
@@ -4220,24 +4220,42 @@ exports.registerDeducedRelationMap = registerDeducedRelationMap;
|
|
|
4220
4220
|
*/
|
|
4221
4221
|
function outputRelation2(outputDir, printer) {
|
|
4222
4222
|
const entityRelations = [];
|
|
4223
|
+
const stmts = [
|
|
4224
|
+
factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("EntityDict"))])), factory.createStringLiteral("./EntityDict"), undefined),
|
|
4225
|
+
factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, factory.createIdentifier("CreateOperationData"), factory.createIdentifier("Relation"))])), factory.createStringLiteral("./Relation/Schema"), undefined),
|
|
4226
|
+
];
|
|
4227
|
+
const enumDelarations = [];
|
|
4223
4228
|
for (const entity in Schema) {
|
|
4224
4229
|
const { relations } = Schema[entity];
|
|
4225
4230
|
if (relations) {
|
|
4226
|
-
|
|
4231
|
+
const entity2 = (0, string_1.firstLetterLowerCase)(entity);
|
|
4232
|
+
const enumMembers = [];
|
|
4233
|
+
relations.forEach((relation) => {
|
|
4234
|
+
const id = (0, uuid_1.formUuid)(entity2, relation);
|
|
4235
|
+
entityRelations.push([entity2, relation, id]);
|
|
4236
|
+
enumMembers.push(factory.createEnumMember((0, string_1.firstLetterUpperCase)(relation), factory.createStringLiteral(id)));
|
|
4237
|
+
});
|
|
4238
|
+
enumDelarations.push(factory.createEnumDeclaration([
|
|
4239
|
+
factory.createToken(ts.SyntaxKind.ExportKeyword),
|
|
4240
|
+
factory.createToken(ts.SyntaxKind.ConstKeyword)
|
|
4241
|
+
], factory.createIdentifier(entity), enumMembers));
|
|
4227
4242
|
}
|
|
4228
4243
|
}
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
|
-
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
factory.createPropertyAssignment(factory.createIdentifier("entity"), factory.createStringLiteral(entity)),
|
|
4235
|
-
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(relation))
|
|
4236
|
-
], true)))), true))], ts.NodeFlags.Const))
|
|
4237
|
-
];
|
|
4244
|
+
stmts.push(factory.createVariableStatement([factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createVariableDeclarationList([factory.createVariableDeclaration(factory.createIdentifier("relations"), undefined, factory.createArrayTypeNode(factory.createTypeReferenceNode(factory.createIdentifier("Relation"), undefined)), factory.createArrayLiteralExpression(entityRelations.map(([entity, relation, id]) => factory.createObjectLiteralExpression([
|
|
4245
|
+
factory.createPropertyAssignment(factory.createIdentifier("id"), factory.createStringLiteral(id)),
|
|
4246
|
+
factory.createPropertyAssignment(factory.createIdentifier("entity"), factory.createStringLiteral(entity)),
|
|
4247
|
+
factory.createPropertyAssignment(factory.createIdentifier("name"), factory.createStringLiteral(relation))
|
|
4248
|
+
], true)), true))], ts.NodeFlags.Const)));
|
|
4238
4249
|
const result = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(stmts), ts.createSourceFile("someFileName.ts", "", ts.ScriptTarget.Latest, /*setParentNodes*/ false, ts.ScriptKind.TS));
|
|
4239
4250
|
const filename = path_1.default.join(outputDir, 'Relation.ts');
|
|
4240
4251
|
(0, fs_1.writeFileSync)(filename, result, { flag: 'w' });
|
|
4252
|
+
// 输出RelationIds.ts
|
|
4253
|
+
const stmts2 = [
|
|
4254
|
+
factory.createModuleDeclaration([factory.createToken(ts.SyntaxKind.ExportKeyword)], factory.createIdentifier("RelationId"), factory.createModuleBlock(enumDelarations), ts.NodeFlags.Namespace),
|
|
4255
|
+
];
|
|
4256
|
+
const result2 = printer.printList(ts.ListFormat.SourceFileStatements, factory.createNodeArray(stmts2), ts.createSourceFile("someFileName.ts", "", ts.ScriptTarget.Latest, /*setParentNodes*/ false, ts.ScriptKind.TS));
|
|
4257
|
+
const filename2 = path_1.default.join(outputDir, 'RelationId.ts');
|
|
4258
|
+
(0, fs_1.writeFileSync)(filename2, result2, { flag: 'w' });
|
|
4241
4259
|
}
|
|
4242
4260
|
/**
|
|
4243
4261
|
* 输出oak-app-domain中的StyleDict.ts文件
|
|
@@ -35,7 +35,16 @@ export type ServerConfiguration = {
|
|
|
35
35
|
};
|
|
36
36
|
internalExceptionMask?: string;
|
|
37
37
|
koaBody?: {
|
|
38
|
-
|
|
38
|
+
multipart?: boolean;
|
|
39
|
+
formidable?: {
|
|
40
|
+
maxFileSize?: number;
|
|
41
|
+
maxFields?: number;
|
|
42
|
+
maxFieldsSize?: number;
|
|
43
|
+
uploadDir?: string;
|
|
44
|
+
keepExtensions?: boolean;
|
|
45
|
+
hashAlgorithm?: string;
|
|
46
|
+
multiples?: boolean;
|
|
47
|
+
};
|
|
39
48
|
};
|
|
40
49
|
};
|
|
41
50
|
/**
|
|
@@ -118,6 +118,9 @@ class SimpleConnector {
|
|
|
118
118
|
}
|
|
119
119
|
catch (err) {
|
|
120
120
|
// fetch返回异常一定是网络异常
|
|
121
|
+
if (err instanceof types_1.OakRequestTimeoutException) {
|
|
122
|
+
throw new types_1.OakNetworkException(`接口请求超时`);
|
|
123
|
+
}
|
|
121
124
|
throw new types_1.OakNetworkException(`接口请求时发生网络异常`);
|
|
122
125
|
}
|
|
123
126
|
return this.parseAspectResult(response);
|
|
@@ -140,7 +143,10 @@ class SimpleConnector {
|
|
|
140
143
|
response = await this.fetchWithTimeout(this.serverSubscribePointUrl, {}, this.timeout);
|
|
141
144
|
}
|
|
142
145
|
catch (err) {
|
|
143
|
-
|
|
146
|
+
if (err instanceof types_1.OakRequestTimeoutException) {
|
|
147
|
+
throw new types_1.OakNetworkException(`接口请求超时`);
|
|
148
|
+
}
|
|
149
|
+
throw new types_1.OakNetworkException(`接口请求时发生网络异常`);
|
|
144
150
|
}
|
|
145
151
|
if (response.status > 299) {
|
|
146
152
|
const err = new types_1.OakServerProxyException(`网络请求返回status是${response.status}`);
|