oak-domain 5.1.10 → 5.1.11

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.
@@ -0,0 +1 @@
1
+ export declare namespace RelationId { }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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
- entityRelations.push([(0, string_1.firstLetterLowerCase)(entity), relations]);
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
- const stmts = [
4230
- factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, undefined, factory.createIdentifier("EntityDict"))])), factory.createStringLiteral("./EntityDict"), undefined),
4231
- factory.createImportDeclaration(undefined, factory.createImportClause(false, undefined, factory.createNamedImports([factory.createImportSpecifier(false, factory.createIdentifier("CreateOperationData"), factory.createIdentifier("Relation"))])), factory.createStringLiteral("./Relation/Schema"), undefined),
4232
- 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((0, lodash_1.flatten)(entityRelations.map(([entity, relations]) => relations.map((relation) => factory.createObjectLiteralExpression([
4233
- factory.createPropertyAssignment(factory.createIdentifier("id"), factory.createStringLiteral((0, uuid_1.formUuid)(entity, relation))),
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文件
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oak-domain",
3
- "version": "5.1.10",
3
+ "version": "5.1.11",
4
4
  "author": {
5
5
  "name": "XuChang"
6
6
  },