@axinom/mosaic-cli 0.54.0-rc.2 → 0.54.0-rc.21

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 (109) hide show
  1. package/dist/cli/index.js +6 -6
  2. package/dist/cli/index.js.map +1 -1
  3. package/dist/commands/apply-templates/apply-templates.js +12 -11
  4. package/dist/commands/apply-templates/apply-templates.js.map +1 -1
  5. package/dist/commands/apply-templates/bitwarden-vault.js.map +1 -1
  6. package/dist/commands/create/command.js +26 -11
  7. package/dist/commands/create/command.js.map +1 -1
  8. package/dist/commands/create/createSolution.js +31 -31
  9. package/dist/commands/create/createSolution.js.map +1 -1
  10. package/dist/commands/create/helpers/git.d.ts +1 -1
  11. package/dist/commands/create/helpers/git.js +8 -9
  12. package/dist/commands/create/helpers/git.js.map +1 -1
  13. package/dist/commands/create/helpers/logger.js +8 -7
  14. package/dist/commands/create/helpers/logger.js.map +1 -1
  15. package/dist/commands/create/runQuestionaire.js +18 -18
  16. package/dist/commands/create/runQuestionaire.js.map +1 -1
  17. package/dist/commands/create-extension-config/create-extension-config.js +14 -14
  18. package/dist/commands/create-extension-config/create-extension-config.js.map +1 -1
  19. package/dist/commands/create-extension-config/index.js +2 -1
  20. package/dist/commands/create-extension-config/index.js.map +1 -1
  21. package/dist/commands/get-access-token/get-dev-access-token.js +3 -4
  22. package/dist/commands/get-access-token/get-dev-access-token.js.map +1 -1
  23. package/dist/commands/get-access-token/index.js +6 -6
  24. package/dist/commands/get-access-token/index.js.map +1 -1
  25. package/dist/commands/graphql-diff.js +44 -46
  26. package/dist/commands/graphql-diff.js.map +1 -1
  27. package/dist/commands/hosting/manifest/manifest-commands.js +3 -4
  28. package/dist/commands/hosting/manifest/manifest-commands.js.map +1 -1
  29. package/dist/commands/hosting/manifest/upload-manifest.js +7 -7
  30. package/dist/commands/hosting/manifest/upload-manifest.js.map +1 -1
  31. package/dist/commands/hosting/pilet/pilet-commands.js +3 -4
  32. package/dist/commands/hosting/pilet/pilet-commands.js.map +1 -1
  33. package/dist/commands/hosting/pilet/register-pilet.js +13 -10
  34. package/dist/commands/hosting/pilet/register-pilet.js.map +1 -1
  35. package/dist/commands/hosting/service/deploy/service-deploy-command.js +3 -4
  36. package/dist/commands/hosting/service/deploy/service-deploy-command.js.map +1 -1
  37. package/dist/commands/hosting/service/deploy/service-deploy.js +14 -14
  38. package/dist/commands/hosting/service/deploy/service-deploy.js.map +1 -1
  39. package/dist/commands/hosting/service/undeploy/service-undeploy-command.js +3 -4
  40. package/dist/commands/hosting/service/undeploy/service-undeploy-command.js.map +1 -1
  41. package/dist/commands/hosting/service/undeploy/service-undeploy.js +11 -11
  42. package/dist/commands/hosting/service/undeploy/service-undeploy.js.map +1 -1
  43. package/dist/commands/msg-codegen/codegen.js +298 -322
  44. package/dist/commands/msg-codegen/codegen.js.map +1 -1
  45. package/dist/commands/msg-codegen/index.js +4 -5
  46. package/dist/commands/msg-codegen/index.js.map +1 -1
  47. package/dist/commands/msg-codegen/lint.js +55 -60
  48. package/dist/commands/msg-codegen/lint.js.map +1 -1
  49. package/dist/commands/msg-codegen/presets.js +2 -1
  50. package/dist/commands/msg-codegen/presets.js.map +1 -1
  51. package/dist/commands/msg-codegen/utils.js +25 -25
  52. package/dist/commands/msg-codegen/utils.js.map +1 -1
  53. package/dist/commands/msg-diff/git-checkout-tmp.js +7 -6
  54. package/dist/commands/msg-diff/git-checkout-tmp.js.map +1 -1
  55. package/dist/commands/msg-diff/index.js +4 -4
  56. package/dist/commands/msg-diff/index.js.map +1 -1
  57. package/dist/commands/msg-diff/msg-diff.js +188 -198
  58. package/dist/commands/msg-diff/msg-diff.js.map +1 -1
  59. package/dist/commands/pg-dump/generate.js +5 -4
  60. package/dist/commands/pg-dump/generate.js.map +1 -1
  61. package/dist/commands/publish-schema-to-db/content-entity-model.js.map +1 -1
  62. package/dist/commands/publish-schema-to-db/generate.js +45 -45
  63. package/dist/commands/publish-schema-to-db/generate.js.map +1 -1
  64. package/dist/commands/publish-schema-to-db/index.js +3 -4
  65. package/dist/commands/publish-schema-to-db/index.js.map +1 -1
  66. package/dist/commands/publish-schema-to-db/pg-models/columns/pk-column.js.map +1 -1
  67. package/dist/commands/publish-schema-to-db/pg-models/columns/primitive-column.js.map +1 -1
  68. package/dist/commands/publish-schema-to-db/pg-models/json-schema-parse-utils.js +18 -22
  69. package/dist/commands/publish-schema-to-db/pg-models/json-schema-parse-utils.js.map +1 -1
  70. package/dist/commands/publish-schema-to-db/pg-models/pg-sql-gen-utils.js +26 -29
  71. package/dist/commands/publish-schema-to-db/pg-models/pg-sql-gen-utils.js.map +1 -1
  72. package/dist/commands/publish-schema-to-db/pg-models/pgl-utils.js +11 -11
  73. package/dist/commands/publish-schema-to-db/pg-models/pgl-utils.js.map +1 -1
  74. package/dist/commands/publish-schema-to-db/pg-models/tables/content-entity-table.js.map +1 -1
  75. package/dist/commands/publish-schema-to-db/pg-models/tables/object-property-table.js.map +1 -1
  76. package/dist/commands/publish-schema-to-db/pg-models/tables/relations-table.js.map +1 -1
  77. package/dist/commands/publish-schema-to-db/postprocessors/postprocessing-utils.js +2 -3
  78. package/dist/commands/publish-schema-to-db/postprocessors/postprocessing-utils.js.map +1 -1
  79. package/dist/commands/service/purge-permissions/purge-permissions-command.js +3 -4
  80. package/dist/commands/service/purge-permissions/purge-permissions-command.js.map +1 -1
  81. package/dist/commands/service/purge-permissions/purge-permissions.js +4 -5
  82. package/dist/commands/service/purge-permissions/purge-permissions.js.map +1 -1
  83. package/dist/commands/service/sync-permissions/sync-permission-command.js +3 -4
  84. package/dist/commands/service/sync-permissions/sync-permission-command.js.map +1 -1
  85. package/dist/commands/service/sync-permissions/sync-permissions.js +5 -5
  86. package/dist/commands/service/sync-permissions/sync-permissions.js.map +1 -1
  87. package/dist/commands/unpublish-pilet/index.js +7 -7
  88. package/dist/commands/unpublish-pilet/index.js.map +1 -1
  89. package/dist/commands/unpublish-pilet/unpublish-pilet.js +4 -4
  90. package/dist/commands/unpublish-pilet/unpublish-pilet.js.map +1 -1
  91. package/package.json +15 -10
  92. package/src/commands/apply-templates/apply-templates.spec.ts +20 -11
  93. package/src/commands/apply-templates/apply-templates.ts +1 -1
  94. package/src/commands/create/helpers/logger.ts +1 -1
  95. package/src/commands/create-extension-config/create-extension-config.ts +1 -1
  96. package/src/commands/get-access-token/index.ts +1 -1
  97. package/src/commands/hosting/pilet/register-pilet.ts +1 -1
  98. package/src/commands/msg-diff/msg-diff.spec.ts +6 -9
  99. package/src/commands/pg-dump/generate.ts +1 -1
  100. package/src/commands/publish-schema-to-db/pg-models/columns/fk-column.spec.ts +18 -14
  101. package/src/commands/publish-schema-to-db/pg-models/columns/pk-column.spec.ts +11 -7
  102. package/src/commands/publish-schema-to-db/pg-models/columns/primitive-column.spec.ts +1 -0
  103. package/src/commands/publish-schema-to-db/pg-models/columns/virtual-fk-column.spec.ts +1 -0
  104. package/src/commands/publish-schema-to-db/pg-models/json-schema-parse-utils.spec.ts +2 -1
  105. package/src/commands/publish-schema-to-db/pg-models/pg-sql-gen-utils.spec.ts +1 -0
  106. package/src/commands/publish-schema-to-db/pg-models/pgl-utils.spec.ts +1 -0
  107. package/src/commands/unpublish-pilet/index.ts +1 -1
  108. package/src/types/find-nearest-file.d.ts +11 -0
  109. package/src/commands/publish-schema-to-db/jest.config.js +0 -9
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Codegen = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const modelina_1 = require("@asyncapi/modelina");
7
- const parser_1 = require("@asyncapi/parser");
8
- const endent_1 = require("endent");
9
- const fs = require("fs");
10
- const path = require("path");
7
+ const parser_1 = tslib_1.__importStar(require("@asyncapi/parser"));
8
+ const endent_1 = tslib_1.__importDefault(require("endent"));
9
+ const fs = tslib_1.__importStar(require("fs"));
10
+ const path = tslib_1.__importStar(require("path"));
11
11
  const common_1 = require("../../common");
12
12
  const presets_1 = require("./presets");
13
13
  const utils_1 = require("./utils");
@@ -36,60 +36,56 @@ class Codegen {
36
36
  this.schemasOutputRoot = path.join(this.outputRoot, 'schemas');
37
37
  this.messagingSettingsOutputRoot = path.join(this.outputRoot, 'config');
38
38
  }
39
- run() {
40
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
41
- console.log('Running message codegen.');
42
- console.log(`* schema root: ${this.schemaRoot}`);
43
- console.log(`* output root: ${this.outputRoot}`);
44
- try {
45
- yield this.walk(this.schemaRoot);
46
- yield this.barrelExportTs([], [
47
- this.typesOutputRoot,
48
- this.schemasOutputRoot,
49
- this.messagingSettingsOutputRoot,
50
- ], path.join(this.outputRoot, 'index.ts'));
51
- }
52
- catch (e) {
53
- console.log(e);
54
- process.exit(common_1.exitCode);
55
- }
56
- });
39
+ async run() {
40
+ console.log('Running message codegen.');
41
+ console.log(`* schema root: ${this.schemaRoot}`);
42
+ console.log(`* output root: ${this.outputRoot}`);
43
+ try {
44
+ await this.walk(this.schemaRoot);
45
+ await this.barrelExportTs([], [
46
+ this.typesOutputRoot,
47
+ this.schemasOutputRoot,
48
+ this.messagingSettingsOutputRoot,
49
+ ], path.join(this.outputRoot, 'index.ts'));
50
+ }
51
+ catch (e) {
52
+ console.log(e);
53
+ process.exit(common_1.exitCode);
54
+ }
57
55
  }
58
56
  /**
59
57
  * Recursively walks a schemas directory and generates TS + bundled JSON schema files.
60
58
  * @param dir - Directory to walk.
61
59
  */
62
- walk(dir) {
63
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
64
- const items = yield fs.promises.readdir(dir);
65
- const fullPathItems = items.map((i) => path.join(dir, i));
66
- const dirs = fullPathItems.filter((i) => fs.statSync(i).isDirectory());
67
- const files = fullPathItems.filter((i) => fs.statSync(i).isFile() && this.filePattern.test(i));
68
- if ([...files, ...dirs].length === 0) {
69
- return;
70
- }
71
- for (const asyncApiFile of files) {
72
- console.log(`Processing ${asyncApiFile}.`);
73
- yield this.processAsyncAPIDocument(asyncApiFile);
74
- }
75
- for (const directory of dirs) {
76
- yield this.walk(directory);
77
- }
78
- if (files.length === 0) {
79
- //Calculate correct TS output related directories for barrel exports.
80
- const tsDirs = dirs.map((d) => path.join(this.typesOutputRoot, path.relative(this.schemaRoot, d)));
81
- const tsIndexOutPath = path.join(this.typesOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, dir), 'index.ts');
82
- yield this.barrelExportTs([], tsDirs, tsIndexOutPath);
83
- // Calculate correct JSON schema output related directories for barrel exports.
84
- const schemaDirs = dirs.map((d) => path.join(this.schemasOutputRoot, path.relative(this.schemaRoot, d)));
85
- const schemaIndexOutPath = path.join(this.schemasOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, dir), 'index.ts');
86
- yield this.barrelExportSchema([], schemaDirs, schemaIndexOutPath);
87
- // Calculate correct Message Settings output related directories for barrel exports.
88
- const settingsDirs = dirs.map((d) => path.join(this.messagingSettingsOutputRoot, path.relative(this.schemaRoot, d)));
89
- const messagingIndexOutPath = path.join(this.messagingSettingsOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, dir), 'index.ts');
90
- yield this.barrelExportSettings([], settingsDirs, messagingIndexOutPath);
91
- }
92
- });
60
+ async walk(dir) {
61
+ const items = await fs.promises.readdir(dir);
62
+ const fullPathItems = items.map((i) => path.join(dir, i));
63
+ const dirs = fullPathItems.filter((i) => fs.statSync(i).isDirectory());
64
+ const files = fullPathItems.filter((i) => fs.statSync(i).isFile() && this.filePattern.test(i));
65
+ if ([...files, ...dirs].length === 0) {
66
+ return;
67
+ }
68
+ for (const asyncApiFile of files) {
69
+ console.log(`Processing ${asyncApiFile}.`);
70
+ await this.processAsyncAPIDocument(asyncApiFile);
71
+ }
72
+ for (const directory of dirs) {
73
+ await this.walk(directory);
74
+ }
75
+ if (files.length === 0) {
76
+ //Calculate correct TS output related directories for barrel exports.
77
+ const tsDirs = dirs.map((d) => path.join(this.typesOutputRoot, path.relative(this.schemaRoot, d)));
78
+ const tsIndexOutPath = path.join(this.typesOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, dir), 'index.ts');
79
+ await this.barrelExportTs([], tsDirs, tsIndexOutPath);
80
+ // Calculate correct JSON schema output related directories for barrel exports.
81
+ const schemaDirs = dirs.map((d) => path.join(this.schemasOutputRoot, path.relative(this.schemaRoot, d)));
82
+ const schemaIndexOutPath = path.join(this.schemasOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, dir), 'index.ts');
83
+ await this.barrelExportSchema([], schemaDirs, schemaIndexOutPath);
84
+ // Calculate correct Message Settings output related directories for barrel exports.
85
+ const settingsDirs = dirs.map((d) => path.join(this.messagingSettingsOutputRoot, path.relative(this.schemaRoot, d)));
86
+ const messagingIndexOutPath = path.join(this.messagingSettingsOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, dir), 'index.ts');
87
+ await this.barrelExportSettings([], settingsDirs, messagingIndexOutPath);
88
+ }
93
89
  }
94
90
  /**
95
91
  * Builds a path for the generated TS file from an input JSON schema path, retains directory structure.
@@ -111,170 +107,162 @@ class Codegen {
111
107
  * Generates TS interfaces and JSON schemas from AsyncAPI schema.
112
108
  * @param asyncApiFile - path to AsyncAPI document
113
109
  */
114
- processAsyncAPIDocument(asyncApiFile) {
115
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
116
- const parser = new parser_1.default();
117
- const { document, diagnostics } = yield (0, parser_1.fromFile)(parser, asyncApiFile).parse();
118
- if (document === undefined) {
119
- console.error(`Failed to parse ${asyncApiFile}.`);
120
- console.error(diagnostics);
121
- process.exit(1);
122
- }
123
- //export Typescript models
124
- const tsModelsOutputPath = path.join(this.typesOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, asyncApiFile));
125
- yield this.exportTsModels(document, tsModelsOutputPath);
126
- //export JSON Schemas
127
- const schemasOutputPath = path.join(this.schemasOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, asyncApiFile));
128
- yield this.exportSchemas(document, schemasOutputPath);
129
- //export message settings
130
- const messagingSettingsOutputPath = path.join(this.messagingSettingsOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, asyncApiFile));
131
- yield this.exportSettings(document, messagingSettingsOutputPath);
132
- });
110
+ async processAsyncAPIDocument(asyncApiFile) {
111
+ const parser = new parser_1.default();
112
+ const { document, diagnostics } = await (0, parser_1.fromFile)(parser, asyncApiFile).parse();
113
+ if (document === undefined) {
114
+ console.error(`Failed to parse ${asyncApiFile}.`);
115
+ console.error(diagnostics);
116
+ process.exit(1);
117
+ }
118
+ //export Typescript models
119
+ const tsModelsOutputPath = path.join(this.typesOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, asyncApiFile));
120
+ await this.exportTsModels(document, tsModelsOutputPath);
121
+ //export JSON Schemas
122
+ const schemasOutputPath = path.join(this.schemasOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, asyncApiFile));
123
+ await this.exportSchemas(document, schemasOutputPath);
124
+ //export message settings
125
+ const messagingSettingsOutputPath = path.join(this.messagingSettingsOutputRoot, (0, utils_1.getRelativeDir)(this.schemaRoot, asyncApiFile));
126
+ await this.exportSettings(document, messagingSettingsOutputPath);
133
127
  }
134
128
  /**
135
129
  * Export all TS models from AsyncAPI document
136
130
  * @param asyncAPIDocument - AsyncAPI Document object
137
131
  * @param outputPath - output path for generated files
138
132
  */
139
- exportTsModels(asyncAPIDocument, outputPath) {
140
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
141
- const generator = new modelina_1.TypeScriptGenerator({
142
- modelType: 'interface',
143
- enumType: 'union',
144
- mapType: 'indexedObject',
145
- constraints: {
146
- propertyKey: (0, modelina_1.typeScriptDefaultPropertyKeyConstraints)({
147
- NAMING_FORMATTER: (name) => modelina_1.FormatHelpers.toSnakeCase(name),
148
- NO_RESERVED_KEYWORDS: (0, utils_1.createDummyReservedKeywordsChecker)(),
149
- }),
150
- modelName: (0, modelina_1.typeScriptDefaultModelNameConstraints)({
151
- NO_RESERVED_KEYWORDS: (0, utils_1.createDummyReservedKeywordsChecker)(),
152
- }),
153
- },
154
- // Order of presets matters!
155
- presets: [
156
- presets_1.NULLABLE_PROPERTY_TO_UNION_PRESET,
157
- presets_1.ANY_TO_UNKNOWN_PRESET,
158
- presets_1.ADDITIONAL_PROPERTIES_PRESET,
159
- presets_1.EXPORT_TYPES_PRESET,
160
- modelina_1.TS_DESCRIPTION_PRESET,
161
- presets_1.IMPORTS_PRESET,
162
- ],
163
- });
164
- let outputModels = yield generator.generate(asyncAPIDocument);
165
- for (const schema of asyncAPIDocument.components().schemas()) {
166
- const referencedModels = yield generator.generate(schema.json());
167
- outputModels = outputModels.map((om) => referencedModels.find((rm) => om.modelName === rm.modelName) || om);
133
+ async exportTsModels(asyncAPIDocument, outputPath) {
134
+ const generator = new modelina_1.TypeScriptGenerator({
135
+ modelType: 'interface',
136
+ enumType: 'union',
137
+ mapType: 'indexedObject',
138
+ constraints: {
139
+ propertyKey: (0, modelina_1.typeScriptDefaultPropertyKeyConstraints)({
140
+ NAMING_FORMATTER: (name) => modelina_1.FormatHelpers.toSnakeCase(name),
141
+ NO_RESERVED_KEYWORDS: (0, utils_1.createDummyReservedKeywordsChecker)(),
142
+ }),
143
+ modelName: (0, modelina_1.typeScriptDefaultModelNameConstraints)({
144
+ NO_RESERVED_KEYWORDS: (0, utils_1.createDummyReservedKeywordsChecker)(),
145
+ }),
146
+ },
147
+ // Order of presets matters!
148
+ presets: [
149
+ presets_1.NULLABLE_PROPERTY_TO_UNION_PRESET,
150
+ presets_1.ANY_TO_UNKNOWN_PRESET,
151
+ presets_1.ADDITIONAL_PROPERTIES_PRESET,
152
+ presets_1.EXPORT_TYPES_PRESET,
153
+ modelina_1.TS_DESCRIPTION_PRESET,
154
+ presets_1.IMPORTS_PRESET,
155
+ ],
156
+ });
157
+ let outputModels = await generator.generate(asyncAPIDocument);
158
+ for (const schema of asyncAPIDocument.components().schemas()) {
159
+ const referencedModels = await generator.generate(schema.json());
160
+ outputModels = outputModels.map((om) => referencedModels.find((rm) => om.modelName === rm.modelName) || om);
161
+ }
162
+ const groupedModels = {};
163
+ outputModels.map((outModel) => {
164
+ const modelPathPrefix = (0, utils_1.getModelPathPrefix)(outModel.modelName);
165
+ if (groupedModels[modelPathPrefix] === undefined) {
166
+ groupedModels[modelPathPrefix] = [];
168
167
  }
169
- const groupedModels = {};
170
- outputModels.map((outModel) => {
171
- const modelPathPrefix = (0, utils_1.getModelPathPrefix)(outModel.modelName);
172
- if (groupedModels[modelPathPrefix] === undefined) {
173
- groupedModels[modelPathPrefix] = [];
174
- }
175
- groupedModels[modelPathPrefix].push(outModel);
176
- });
177
- const tsDirs = [];
178
- for (const pathPrefix in groupedModels) {
179
- const models = groupedModels[pathPrefix];
180
- const groupOutPutPath = path.join(outputPath, pathPrefix);
181
- if (pathPrefix) {
182
- tsDirs.push(groupOutPutPath);
183
- }
184
- yield fs.promises.mkdir(groupOutPutPath, {
185
- recursive: true,
186
- });
187
- const tsFiles = [];
188
- for (const outputModel of models) {
189
- const outputFilePath = this.buildTsOutPath(groupOutPutPath, outputModel.modelName);
190
- yield fs.promises.writeFile(outputFilePath, outputModel.result);
191
- tsFiles.push(outputFilePath);
192
- }
193
- //generate barrel export for all model in AsyncAPI document
194
- const tsIndexOutPath = path.join(groupOutPutPath, 'index.ts');
195
- yield this.barrelExportTs(tsFiles, [], tsIndexOutPath);
168
+ groupedModels[modelPathPrefix].push(outModel);
169
+ });
170
+ const tsDirs = [];
171
+ for (const pathPrefix in groupedModels) {
172
+ const models = groupedModels[pathPrefix];
173
+ const groupOutPutPath = path.join(outputPath, pathPrefix);
174
+ if (pathPrefix) {
175
+ tsDirs.push(groupOutPutPath);
196
176
  }
197
- if (tsDirs.length > 0) {
198
- const tsIndexOutPath = path.join(outputPath, 'index.ts');
199
- yield this.barrelExportTs([], tsDirs, tsIndexOutPath);
177
+ await fs.promises.mkdir(groupOutPutPath, {
178
+ recursive: true,
179
+ });
180
+ const tsFiles = [];
181
+ for (const outputModel of models) {
182
+ const outputFilePath = this.buildTsOutPath(groupOutPutPath, outputModel.modelName);
183
+ await fs.promises.writeFile(outputFilePath, outputModel.result);
184
+ tsFiles.push(outputFilePath);
200
185
  }
201
- });
186
+ //generate barrel export for all model in AsyncAPI document
187
+ const tsIndexOutPath = path.join(groupOutPutPath, 'index.ts');
188
+ await this.barrelExportTs(tsFiles, [], tsIndexOutPath);
189
+ }
190
+ if (tsDirs.length > 0) {
191
+ const tsIndexOutPath = path.join(outputPath, 'index.ts');
192
+ await this.barrelExportTs([], tsDirs, tsIndexOutPath);
193
+ }
202
194
  }
203
195
  /**
204
196
  * Export all JSON Schemas from AsyncAPI document
205
197
  * @param asyncAPIDocument - AsyncAPI Document object
206
198
  * @param outputPath - output path for generated files
207
199
  */
208
- exportSchemas(asyncAPIDocument, outputPath) {
209
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
210
- const groupedSchemas = {};
211
- for (const message of asyncAPIDocument.allMessages()) {
212
- const schemaPathPrefix = (0, utils_1.getModelPathPrefix)((0, utils_1.getMessageTitle)(message));
213
- if (groupedSchemas[schemaPathPrefix] === undefined) {
214
- groupedSchemas[schemaPathPrefix] = [];
215
- }
216
- groupedSchemas[schemaPathPrefix].push(message);
200
+ async exportSchemas(asyncAPIDocument, outputPath) {
201
+ const groupedSchemas = {};
202
+ for (const message of asyncAPIDocument.allMessages()) {
203
+ const schemaPathPrefix = (0, utils_1.getModelPathPrefix)((0, utils_1.getMessageTitle)(message));
204
+ if (groupedSchemas[schemaPathPrefix] === undefined) {
205
+ groupedSchemas[schemaPathPrefix] = [];
217
206
  }
218
- const schemaDirs = [];
219
- for (const pathPrefix in groupedSchemas) {
220
- const messages = groupedSchemas[pathPrefix];
221
- const schemaFiles = [];
222
- const groupOutPutPath = path.join(outputPath, pathPrefix);
223
- if (pathPrefix) {
224
- schemaDirs.push(groupOutPutPath);
225
- }
226
- yield fs.promises.mkdir(groupOutPutPath, {
227
- recursive: true,
228
- });
229
- for (const msg of messages) {
230
- const payload = msg.payload();
231
- if (payload !== undefined && payload.json() !== undefined) {
232
- const filteredPayload = (0, utils_1.removeXParserProperties)(payload.json());
233
- const outputSchemaPath = this.buildSchemaOutPath(groupOutPutPath, (0, utils_1.getMessageTitle)(msg));
234
- yield this.bundleSchema(filteredPayload, outputSchemaPath);
235
- schemaFiles.push(outputSchemaPath);
236
- }
207
+ groupedSchemas[schemaPathPrefix].push(message);
208
+ }
209
+ const schemaDirs = [];
210
+ for (const pathPrefix in groupedSchemas) {
211
+ const messages = groupedSchemas[pathPrefix];
212
+ const schemaFiles = [];
213
+ const groupOutPutPath = path.join(outputPath, pathPrefix);
214
+ if (pathPrefix) {
215
+ schemaDirs.push(groupOutPutPath);
216
+ }
217
+ await fs.promises.mkdir(groupOutPutPath, {
218
+ recursive: true,
219
+ });
220
+ for (const msg of messages) {
221
+ const payload = msg.payload();
222
+ if (payload !== undefined && payload.json() !== undefined) {
223
+ const filteredPayload = (0, utils_1.removeXParserProperties)(payload.json());
224
+ const outputSchemaPath = this.buildSchemaOutPath(groupOutPutPath, (0, utils_1.getMessageTitle)(msg));
225
+ await this.bundleSchema(filteredPayload, outputSchemaPath);
226
+ schemaFiles.push(outputSchemaPath);
237
227
  }
238
- //generate barrel export for all model in AsyncAPI document
239
- const schemasIndexOutPath = path.join(groupOutPutPath, 'index.ts');
240
- yield this.barrelExportSchema(schemaFiles, [], schemasIndexOutPath);
241
228
  }
242
- const schemaIndexOutPath = path.join(outputPath, 'index.ts');
243
- yield this.barrelExportSchema([], schemaDirs, schemaIndexOutPath);
244
- });
229
+ //generate barrel export for all model in AsyncAPI document
230
+ const schemasIndexOutPath = path.join(groupOutPutPath, 'index.ts');
231
+ await this.barrelExportSchema(schemaFiles, [], schemasIndexOutPath);
232
+ }
233
+ const schemaIndexOutPath = path.join(outputPath, 'index.ts');
234
+ await this.barrelExportSchema([], schemaDirs, schemaIndexOutPath);
245
235
  }
246
236
  /**
247
237
  * Export all AsyncAPI document channels to Messaging Settings
248
238
  * @param asyncAPIDocument - AsyncAPI Document object
249
239
  * @param outputPath - output path for generated files
250
240
  */
251
- exportSettings(asyncAPIDocument, outputPath) {
241
+ async exportSettings(asyncAPIDocument, outputPath) {
252
242
  var _a, _b;
253
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
254
- const serviceTitle = (0, utils_1.getServiceTitle)(asyncAPIDocument);
255
- const serviceId = (0, utils_1.getServiceId)(asyncAPIDocument);
256
- const channelsData = [];
257
- for (const channel of asyncAPIDocument.channels()) {
258
- const queueName = (_a = channel.bindings().get('amqp')) === null || _a === void 0 ? void 0 : _a.value().queue.name;
259
- if (queueName !== undefined) {
260
- const routingKey = channel.address();
261
- const action = (0, utils_1.getChannelAction)(channel);
262
- const payloadName = (_b = (0, utils_1.getPayloadTitle)(channel)) !== null && _b !== void 0 ? _b : 'undefined';
263
- const aggregateType = (0, utils_1.getChannelAggregateType)(channel);
264
- const aggregateIdField = (0, utils_1.getChannelAggregateIdField)(channel);
265
- channelsData.push({
266
- routingKey,
267
- queueName,
268
- payloadName,
269
- acceptedAction: action,
270
- isMultiTenant: routingKey.includes('*.*'),
271
- aggregateType,
272
- aggregateIdField,
273
- });
274
- }
243
+ const serviceTitle = (0, utils_1.getServiceTitle)(asyncAPIDocument);
244
+ const serviceId = (0, utils_1.getServiceId)(asyncAPIDocument);
245
+ const channelsData = [];
246
+ for (const channel of asyncAPIDocument.channels()) {
247
+ const queueName = (_a = channel.bindings().get('amqp')) === null || _a === void 0 ? void 0 : _a.value().queue.name;
248
+ if (queueName !== undefined) {
249
+ const routingKey = channel.address();
250
+ const action = (0, utils_1.getChannelAction)(channel);
251
+ const payloadName = (_b = (0, utils_1.getPayloadTitle)(channel)) !== null && _b !== void 0 ? _b : 'undefined';
252
+ const aggregateType = (0, utils_1.getChannelAggregateType)(channel);
253
+ const aggregateIdField = (0, utils_1.getChannelAggregateIdField)(channel);
254
+ channelsData.push({
255
+ routingKey,
256
+ queueName,
257
+ payloadName,
258
+ acceptedAction: action,
259
+ isMultiTenant: routingKey.includes('*.*'),
260
+ aggregateType,
261
+ aggregateIdField,
262
+ });
275
263
  }
276
- yield this.generateMessagingSettings(serviceId, serviceTitle, channelsData, outputPath);
277
- });
264
+ }
265
+ await this.generateMessagingSettings(serviceId, serviceTitle, channelsData, outputPath);
278
266
  }
279
267
  /**
280
268
  * Generate Messaging Settings based on Channels data.
@@ -283,15 +271,13 @@ class Codegen {
283
271
  * @param channelsData - AsyncAPI channels information
284
272
  * @param outputPath - output path for generated files
285
273
  */
286
- generateMessagingSettings(serviceId, serviceTitle, channelsData, outputPath) {
287
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
288
- const messagingSettingFiles = [];
289
- messagingSettingFiles.push(yield this.createMessagingSettingFile(true, serviceId, serviceTitle, channelsData.filter((data) => data.isMultiTenant === true), outputPath));
290
- messagingSettingFiles.push(yield this.createMessagingSettingFile(false, serviceId, serviceTitle, channelsData.filter((data) => data.isMultiTenant === false), outputPath));
291
- //barrel export for messaging settings
292
- const schemaIndexOutPath = path.join(outputPath, 'index.ts');
293
- yield this.barrelExportSettings(messagingSettingFiles.filter((f) => f), [], schemaIndexOutPath);
294
- });
274
+ async generateMessagingSettings(serviceId, serviceTitle, channelsData, outputPath) {
275
+ const messagingSettingFiles = [];
276
+ messagingSettingFiles.push(await this.createMessagingSettingFile(true, serviceId, serviceTitle, channelsData.filter((data) => data.isMultiTenant === true), outputPath));
277
+ messagingSettingFiles.push(await this.createMessagingSettingFile(false, serviceId, serviceTitle, channelsData.filter((data) => data.isMultiTenant === false), outputPath));
278
+ //barrel export for messaging settings
279
+ const schemaIndexOutPath = path.join(outputPath, 'index.ts');
280
+ await this.barrelExportSettings(messagingSettingFiles.filter((f) => f), [], schemaIndexOutPath);
295
281
  }
296
282
  /**
297
283
  * Create new Messaging Settings file.
@@ -301,20 +287,19 @@ class Codegen {
301
287
  * @param channelsData - AsyncAPI channels information
302
288
  * @param outputPath - output path for generated files
303
289
  */
304
- createMessagingSettingFile(isMultiTenant, serviceId, serviceTitle, channelsData, outputPath) {
305
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
306
- if (channelsData.length === 0) {
307
- return ``;
308
- }
309
- const baseClass = isMultiTenant
310
- ? `MultiTenantMessagingSettings`
311
- : `MessagingSettings`;
312
- const className = `${modelina_1.FormatHelpers.toPascalCase(serviceTitle)}${baseClass}`;
313
- const action = isMultiTenant ? 'extends' : 'implements';
314
- const visibility = isMultiTenant ? '' : 'public readonly ';
315
- const toStringOverride = isMultiTenant ? ' override' : '';
316
- const constructor = serviceId === AX_COMMON_SERVICE_ID
317
- ? (0, endent_1.default) `private constructor(
290
+ async createMessagingSettingFile(isMultiTenant, serviceId, serviceTitle, channelsData, outputPath) {
291
+ if (channelsData.length === 0) {
292
+ return ``;
293
+ }
294
+ const baseClass = isMultiTenant
295
+ ? `MultiTenantMessagingSettings`
296
+ : `MessagingSettings`;
297
+ const className = `${modelina_1.FormatHelpers.toPascalCase(serviceTitle)}${baseClass}`;
298
+ const action = isMultiTenant ? 'extends' : 'implements';
299
+ const visibility = isMultiTenant ? '' : 'public readonly ';
300
+ const toStringOverride = isMultiTenant ? ' override' : '';
301
+ const constructor = serviceId === AX_COMMON_SERVICE_ID
302
+ ? (0, endent_1.default) `private constructor(
318
303
  ${visibility}serviceId: string,
319
304
  ${visibility}messageType: string,
320
305
  ${visibility}queue: string,
@@ -323,10 +308,10 @@ class Codegen {
323
308
  ${visibility}aggregateType: string,
324
309
  ) {
325
310
  ${isMultiTenant
326
- ? `super(serviceId, messageType, queue, routingKey, action, aggregateType);`
327
- : ''}
311
+ ? `super(serviceId, messageType, queue, routingKey, action, aggregateType);`
312
+ : ''}
328
313
  }`
329
- : (0, endent_1.default) `private constructor(
314
+ : (0, endent_1.default) `private constructor(
330
315
  ${visibility}messageType: string,
331
316
  ${visibility}queue: string,
332
317
  ${visibility}routingKey: string,
@@ -334,30 +319,29 @@ class Codegen {
334
319
  ${visibility}aggregateType: string,
335
320
  ) {
336
321
  ${isMultiTenant
337
- ? `super('${serviceId}', messageType, queue, routingKey, action, aggregateType);`
338
- : ''}
322
+ ? `super('${serviceId}', messageType, queue, routingKey, action, aggregateType);`
323
+ : ''}
339
324
  }`;
340
- const properties = channelsData.map((data) => this.createMessagingSettingProperty(data, className, serviceId === AX_COMMON_SERVICE_ID));
341
- const content = (0, endent_1.default) `import { ${baseClass} } from '@axinom/mosaic-message-bus-abstractions';
325
+ const properties = channelsData.map((data) => this.createMessagingSettingProperty(data, className, serviceId === AX_COMMON_SERVICE_ID));
326
+ const content = (0, endent_1.default) `import { ${baseClass} } from '@axinom/mosaic-message-bus-abstractions';
342
327
 
343
328
  export class ${className} ${action} ${baseClass} {
344
329
  ${properties.join(`\n`)}
345
330
  ${isMultiTenant || serviceId === AX_COMMON_SERVICE_ID
346
- ? ``
347
- : `\npublic readonly serviceId = '${serviceId}';\n`}
331
+ ? ``
332
+ : `\npublic readonly serviceId = '${serviceId}';\n`}
348
333
  ${constructor}
349
334
 
350
335
  public${toStringOverride} toString = (): string => {
351
336
  return this.messageType;
352
337
  };
353
338
  }`;
354
- const filePath = path.join(outputPath, `${modelina_1.FormatHelpers.toParamCase(className)}.ts`);
355
- yield fs.promises.mkdir(path.dirname(filePath), {
356
- recursive: true,
357
- });
358
- yield fs.promises.writeFile(filePath, content);
359
- return filePath;
339
+ const filePath = path.join(outputPath, `${modelina_1.FormatHelpers.toParamCase(className)}.ts`);
340
+ await fs.promises.mkdir(path.dirname(filePath), {
341
+ recursive: true,
360
342
  });
343
+ await fs.promises.writeFile(filePath, content);
344
+ return filePath;
361
345
  }
362
346
  /**
363
347
  * Create Messaging Settings property from Channel Data.
@@ -420,11 +404,9 @@ class Codegen {
420
404
  * @param jsonSchema - Schema object.
421
405
  * @param outPath - Output JSON schema path.
422
406
  */
423
- bundleSchema(jsonSchema, outPath) {
424
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
425
- yield fs.promises.mkdir(path.dirname(outPath), { recursive: true });
426
- yield fs.promises.writeFile(outPath, JSON.stringify(jsonSchema, null, 2));
427
- });
407
+ async bundleSchema(jsonSchema, outPath) {
408
+ await fs.promises.mkdir(path.dirname(outPath), { recursive: true });
409
+ await fs.promises.writeFile(outPath, JSON.stringify(jsonSchema, null, 2));
428
410
  }
429
411
  // TODO: Consider doing named exports based on message groups to not just put all messages in one namespace.
430
412
  // TODO: Maybe some templating engine would be better than just building strings.
@@ -435,65 +417,63 @@ class Codegen {
435
417
  * @param dirs - Directories to roll up.
436
418
  * @param outPath - Path where to write `index.ts`.
437
419
  */
438
- barrelExportTs(files, dirs, outPath) {
439
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
440
- console.log(`Rolling up TS exports to ${outPath}.`);
441
- const items = [
442
- ...files.map((f) => path.basename(f, '.ts')),
443
- ...dirs.filter((d) => fs.existsSync(d)).map((d) => path.basename(d)),
444
- ];
445
- if (items.length < 1) {
446
- return;
447
- }
448
- const exports = `${items
449
- .sort()
450
- .map((p) => `export * from './${p}';`)
451
- .join('\n')}`;
452
- let schemaEnum = '';
453
- let typeNamesEnum = '';
454
- // TODO: Break this up into smaller pieces.
455
- // TODO: Consider adding docstring to generated enums.
456
- if (files.length > 0) {
457
- const sortedFiles = files.sort();
458
- // TODO: Message envelope is handled separately, we could remove this entirely.
459
- // If message-envelope requires some special handling.
460
- if (files.length === 1 && files[0].endsWith('message-envelope.ts')) {
461
- const file = files[0];
462
- schemaEnum = (0, endent_1.default) `
420
+ async barrelExportTs(files, dirs, outPath) {
421
+ console.log(`Rolling up TS exports to ${outPath}.`);
422
+ const items = [
423
+ ...files.map((f) => path.basename(f, '.ts')),
424
+ ...dirs.filter((d) => fs.existsSync(d)).map((d) => path.basename(d)),
425
+ ];
426
+ if (items.length < 1) {
427
+ return;
428
+ }
429
+ const exports = `${items
430
+ .sort()
431
+ .map((p) => `export * from './${p}';`)
432
+ .join('\n')}`;
433
+ let schemaEnum = '';
434
+ let typeNamesEnum = '';
435
+ // TODO: Break this up into smaller pieces.
436
+ // TODO: Consider adding docstring to generated enums.
437
+ if (files.length > 0) {
438
+ const sortedFiles = files.sort();
439
+ // TODO: Message envelope is handled separately, we could remove this entirely.
440
+ // If message-envelope requires some special handling.
441
+ if (files.length === 1 && files[0].endsWith('message-envelope.ts')) {
442
+ const file = files[0];
443
+ schemaEnum = (0, endent_1.default) `
463
444
  export enum MessageEnvelopeSchema {
464
445
  MessageEnvelope = '${(0, utils_1.toPosixPath)(this.tsPathToSchemaPath(file))}'
465
446
  }
466
447
  `;
467
- }
468
- else {
469
- let enumNameBase = modelina_1.FormatHelpers.toPascalCase((0, utils_1.getRelativeDir)(this.typesOutputRoot, path.dirname(outPath)));
470
- if (!enumNameBase.includes('Types')) {
471
- enumNameBase = enumNameBase.replace('Payloads', ''); // Remove the Payloads prefix to reduce noise
472
- schemaEnum = (0, endent_1.default) `
448
+ }
449
+ else {
450
+ let enumNameBase = modelina_1.FormatHelpers.toPascalCase((0, utils_1.getRelativeDir)(this.typesOutputRoot, path.dirname(outPath)));
451
+ if (!enumNameBase.includes('Types')) {
452
+ enumNameBase = enumNameBase.replace('Payloads', ''); // Remove the Payloads prefix to reduce noise
453
+ schemaEnum = (0, endent_1.default) `
473
454
  export enum ${enumNameBase}Schemas {
474
455
  ${sortedFiles
475
- .map((f) => `${modelina_1.FormatHelpers.toPascalCase(path.basename(f, '.ts'))} = '${(0, utils_1.toPosixPath)(this.tsPathToSchemaPath(f))}'`)
476
- .join(',\n')}
456
+ .map((f) => `${modelina_1.FormatHelpers.toPascalCase(path.basename(f, '.ts'))} = '${(0, utils_1.toPosixPath)(this.tsPathToSchemaPath(f))}'`)
457
+ .join(',\n')}
477
458
  }`;
478
- typeNamesEnum = (0, endent_1.default) `
459
+ typeNamesEnum = (0, endent_1.default) `
479
460
  export enum ${enumNameBase}Types {
480
461
  ${sortedFiles
481
- .sort()
482
- .map((f) => `${modelina_1.FormatHelpers.toPascalCase(path.basename(f, '.ts'))} = '${modelina_1.FormatHelpers.toPascalCase(path.basename(f, '.ts'))}'`)
483
- .join(',\n')}
462
+ .sort()
463
+ .map((f) => `${modelina_1.FormatHelpers.toPascalCase(path.basename(f, '.ts'))} = '${modelina_1.FormatHelpers.toPascalCase(path.basename(f, '.ts'))}'`)
464
+ .join(',\n')}
484
465
  }`;
485
- }
486
466
  }
487
467
  }
488
- const contents = (0, endent_1.default) `
468
+ }
469
+ const contents = (0, endent_1.default) `
489
470
  ${exports}
490
471
 
491
472
  ${schemaEnum}
492
473
 
493
474
  ${typeNamesEnum}
494
475
  `;
495
- yield fs.promises.writeFile(outPath, contents);
496
- });
476
+ await fs.promises.writeFile(outPath, contents);
497
477
  }
498
478
  /**
499
479
  * Generates a barrel index.ts for all Messaging Settings inside `outPath`.
@@ -501,32 +481,30 @@ class Codegen {
501
481
  * @param dirs - Directories to roll up.
502
482
  * @param outPath - Path where to write `index.ts`.
503
483
  */
504
- barrelExportSettings(files, dirs, outPath) {
505
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
506
- console.log(`Rolling up Messaging Settings exports to ${outPath}.`);
507
- const items = [
508
- ...files.map((f) => path.basename(f, '.ts')),
509
- ...dirs.filter((d) => fs.existsSync(d)).map((d) => path.basename(d)),
510
- ];
511
- const dirExports = dirs
512
- .sort()
513
- .filter((d) => fs.existsSync(d))
514
- .map((d) => path.basename(d));
515
- if (items.length < 1) {
516
- return;
517
- }
518
- let contents = '';
519
- if (files.length > 0) {
520
- const baseNames = files.map((f) => path.basename(f, '.ts')).sort();
521
- const messagingImports = baseNames.map((n) => `export * from './${n}';`);
522
- contents = (0, endent_1.default) `
484
+ async barrelExportSettings(files, dirs, outPath) {
485
+ console.log(`Rolling up Messaging Settings exports to ${outPath}.`);
486
+ const items = [
487
+ ...files.map((f) => path.basename(f, '.ts')),
488
+ ...dirs.filter((d) => fs.existsSync(d)).map((d) => path.basename(d)),
489
+ ];
490
+ const dirExports = dirs
491
+ .sort()
492
+ .filter((d) => fs.existsSync(d))
493
+ .map((d) => path.basename(d));
494
+ if (items.length < 1) {
495
+ return;
496
+ }
497
+ let contents = '';
498
+ if (files.length > 0) {
499
+ const baseNames = files.map((f) => path.basename(f, '.ts')).sort();
500
+ const messagingImports = baseNames.map((n) => `export * from './${n}';`);
501
+ contents = (0, endent_1.default) `
523
502
  ${messagingImports.join('\n')}
524
503
  `;
525
- }
526
- contents += (0, endent_1.default) `\n
504
+ }
505
+ contents += (0, endent_1.default) `\n
527
506
  ${dirExports.map((d) => `export * from './${d}';`).join('\n')}`;
528
- yield fs.promises.writeFile(outPath, contents);
529
- });
507
+ await fs.promises.writeFile(outPath, contents);
530
508
  }
531
509
  /**
532
510
  * Generates a barrel index.ts for all JSON schemas inside `outPath`.
@@ -534,35 +512,33 @@ class Codegen {
534
512
  * @param dirs - Directories to roll up.
535
513
  * @param outPath - Path where to write `index.ts`.
536
514
  */
537
- barrelExportSchema(files, dirs, outPath) {
538
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
539
- console.log(`Rolling up JSON exports to ${outPath}.`);
540
- const items = [
541
- ...files.map((f) => path.basename(f, '.json')),
542
- ...dirs.filter((d) => fs.existsSync(d)).map((d) => path.basename(d)),
543
- ];
544
- const dirExports = dirs
545
- .sort()
546
- .filter((d) => fs.existsSync(d))
547
- .map((d) => path.basename(d));
548
- if (items.length < 1) {
549
- return;
550
- }
551
- let contents = '';
552
- if (files.length > 0) {
553
- const baseNames = files.map((f) => path.basename(f, '.json')).sort();
554
- const schemaImports = baseNames.map((n) => `import * as ${modelina_1.FormatHelpers.toPascalCase(n)} from './${n}.json';`);
555
- const schemaExports = baseNames.map((n) => `export const ${modelina_1.FormatHelpers.toPascalCase(n)}Schema = ${modelina_1.FormatHelpers.toPascalCase(n)};`);
556
- contents = (0, endent_1.default) `
515
+ async barrelExportSchema(files, dirs, outPath) {
516
+ console.log(`Rolling up JSON exports to ${outPath}.`);
517
+ const items = [
518
+ ...files.map((f) => path.basename(f, '.json')),
519
+ ...dirs.filter((d) => fs.existsSync(d)).map((d) => path.basename(d)),
520
+ ];
521
+ const dirExports = dirs
522
+ .sort()
523
+ .filter((d) => fs.existsSync(d))
524
+ .map((d) => path.basename(d));
525
+ if (items.length < 1) {
526
+ return;
527
+ }
528
+ let contents = '';
529
+ if (files.length > 0) {
530
+ const baseNames = files.map((f) => path.basename(f, '.json')).sort();
531
+ const schemaImports = baseNames.map((n) => `import * as ${modelina_1.FormatHelpers.toPascalCase(n)} from './${n}.json';`);
532
+ const schemaExports = baseNames.map((n) => `export const ${modelina_1.FormatHelpers.toPascalCase(n)}Schema = ${modelina_1.FormatHelpers.toPascalCase(n)};`);
533
+ contents = (0, endent_1.default) `
557
534
  ${schemaImports.join('\n')}
558
535
 
559
536
  ${schemaExports.join('\n')}
560
537
  `;
561
- }
562
- contents += (0, endent_1.default) `\n
538
+ }
539
+ contents += (0, endent_1.default) `\n
563
540
  ${dirExports.map((d) => `export * from './${d}';`).join('\n')}`;
564
- yield fs.promises.writeFile(outPath, contents);
565
- });
541
+ await fs.promises.writeFile(outPath, contents);
566
542
  }
567
543
  /**
568
544
  * Converts a generated TS path to a corresponding JSON schema path.