mulesoft-anypoint-cli-agent-fabric-plugin 1.0.5

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 (114) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +321 -0
  3. package/bin/run +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/dist/commands/agent-network/project/build.d.ts +26 -0
  6. package/dist/commands/agent-network/project/build.js +192 -0
  7. package/dist/commands/agent-network/project/build.js.map +1 -0
  8. package/dist/commands/agent-network/project/create.d.ts +28 -0
  9. package/dist/commands/agent-network/project/create.js +101 -0
  10. package/dist/commands/agent-network/project/create.js.map +1 -0
  11. package/dist/commands/agent-network/project/deploy.d.ts +67 -0
  12. package/dist/commands/agent-network/project/deploy.js +580 -0
  13. package/dist/commands/agent-network/project/deploy.js.map +1 -0
  14. package/dist/commands/agent-network/project/publish.d.ts +27 -0
  15. package/dist/commands/agent-network/project/publish.js +159 -0
  16. package/dist/commands/agent-network/project/publish.js.map +1 -0
  17. package/dist/commands/agent-network/setup/dependencies.d.ts +12 -0
  18. package/dist/commands/agent-network/setup/dependencies.js +65 -0
  19. package/dist/commands/agent-network/setup/dependencies.js.map +1 -0
  20. package/dist/commands/agent-network/setup/gateways.d.ts +31 -0
  21. package/dist/commands/agent-network/setup/gateways.js +175 -0
  22. package/dist/commands/agent-network/setup/gateways.js.map +1 -0
  23. package/dist/errors/base-error.d.ts +8 -0
  24. package/dist/errors/base-error.js +81 -0
  25. package/dist/errors/base-error.js.map +1 -0
  26. package/dist/errors/error-factory.d.ts +71 -0
  27. package/dist/errors/error-factory.js +362 -0
  28. package/dist/errors/error-factory.js.map +1 -0
  29. package/dist/helpers/dependency-manager.d.ts +30 -0
  30. package/dist/helpers/dependency-manager.js +366 -0
  31. package/dist/helpers/dependency-manager.js.map +1 -0
  32. package/dist/helpers/entitlement-utils.d.ts +4 -0
  33. package/dist/helpers/entitlement-utils.js +20 -0
  34. package/dist/helpers/entitlement-utils.js.map +1 -0
  35. package/dist/helpers/policy-helper.d.ts +21 -0
  36. package/dist/helpers/policy-helper.js +96 -0
  37. package/dist/helpers/policy-helper.js.map +1 -0
  38. package/dist/helpers/project/api-project-dependency-fetcher.d.ts +10 -0
  39. package/dist/helpers/project/api-project-dependency-fetcher.js +213 -0
  40. package/dist/helpers/project/api-project-dependency-fetcher.js.map +1 -0
  41. package/dist/helpers/project/constants.d.ts +52 -0
  42. package/dist/helpers/project/constants.js +52 -0
  43. package/dist/helpers/project/constants.js.map +1 -0
  44. package/dist/helpers/project/debug-messages.d.ts +4 -0
  45. package/dist/helpers/project/debug-messages.js +8 -0
  46. package/dist/helpers/project/debug-messages.js.map +1 -0
  47. package/dist/helpers/project/templates.d.ts +1 -0
  48. package/dist/helpers/project/templates.js +6 -0
  49. package/dist/helpers/project/templates.js.map +1 -0
  50. package/dist/helpers/project/uris.d.ts +2 -0
  51. package/dist/helpers/project/uris.js +8 -0
  52. package/dist/helpers/project/uris.js.map +1 -0
  53. package/dist/helpers/project/validation-commons.d.ts +6 -0
  54. package/dist/helpers/project/validation-commons.js +50 -0
  55. package/dist/helpers/project/validation-commons.js.map +1 -0
  56. package/dist/helpers/types.d.ts +54 -0
  57. package/dist/helpers/types.js +10 -0
  58. package/dist/helpers/types.js.map +1 -0
  59. package/dist/helpers/utils.d.ts +68 -0
  60. package/dist/helpers/utils.js +374 -0
  61. package/dist/helpers/utils.js.map +1 -0
  62. package/dist/index.d.ts +5 -0
  63. package/dist/index.js +17 -0
  64. package/dist/index.js.map +1 -0
  65. package/dist/resources/mule-generation-dependencies.json +1 -0
  66. package/dist/resources/runtime-dependencies.json +13 -0
  67. package/dist/resources/schemas/mule-generation-dependencies-schema.json +52 -0
  68. package/dist/resources/schemas/runtime-dependencies-schema.json +57 -0
  69. package/dist/types/agent-network.d.ts +214 -0
  70. package/dist/types/agent-network.js +13 -0
  71. package/dist/types/agent-network.js.map +1 -0
  72. package/dist/types/types.d.ts +296 -0
  73. package/dist/types/types.js +3 -0
  74. package/dist/types/types.js.map +1 -0
  75. package/dist/utils/access-management.d.ts +5 -0
  76. package/dist/utils/access-management.js +14 -0
  77. package/dist/utils/access-management.js.map +1 -0
  78. package/dist/utils/api-instance-builder.d.ts +28 -0
  79. package/dist/utils/api-instance-builder.js +450 -0
  80. package/dist/utils/api-instance-builder.js.map +1 -0
  81. package/dist/utils/asset-builder.d.ts +28 -0
  82. package/dist/utils/asset-builder.js +248 -0
  83. package/dist/utils/asset-builder.js.map +1 -0
  84. package/dist/utils/constants.d.ts +73 -0
  85. package/dist/utils/constants.js +87 -0
  86. package/dist/utils/constants.js.map +1 -0
  87. package/dist/utils/exchange.d.ts +4 -0
  88. package/dist/utils/exchange.js +26 -0
  89. package/dist/utils/exchange.js.map +1 -0
  90. package/dist/utils/files.d.ts +63 -0
  91. package/dist/utils/files.js +300 -0
  92. package/dist/utils/files.js.map +1 -0
  93. package/dist/utils/gateway.d.ts +12 -0
  94. package/dist/utils/gateway.js +83 -0
  95. package/dist/utils/gateway.js.map +1 -0
  96. package/dist/utils/naming.d.ts +1 -0
  97. package/dist/utils/naming.js +17 -0
  98. package/dist/utils/naming.js.map +1 -0
  99. package/dist/utils/report/junit-report.d.ts +2 -0
  100. package/dist/utils/report/junit-report.js +19 -0
  101. package/dist/utils/report/junit-report.js.map +1 -0
  102. package/dist/utils/report/validation-report.d.ts +27 -0
  103. package/dist/utils/report/validation-report.js +16 -0
  104. package/dist/utils/report/validation-report.js.map +1 -0
  105. package/dist/utils/uris.d.ts +26 -0
  106. package/dist/utils/uris.js +41 -0
  107. package/dist/utils/uris.js.map +1 -0
  108. package/dist/utils/variables.d.ts +6 -0
  109. package/dist/utils/variables.js +22 -0
  110. package/dist/utils/variables.js.map +1 -0
  111. package/package.json +100 -0
  112. package/scripts/post-install.js +102 -0
  113. package/templates/agent-network.yaml.template +89 -0
  114. package/templates/exchange.json.template +36 -0
@@ -0,0 +1,374 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.safeJsonObjectParse = exports.safeXmlStringParse = exports.safeJsonStringParse = exports.safeJsonFileParse = exports.createAjvCompiler = exports.MULESOFT_ORGS = exports.quoteValue = exports.isAnAxiosError = exports.checkForRuntimeDependencyFiles = exports.getMuleGenerationDependencies = exports.getRuntimeDependencies = exports.muleGenerationDependenciesSchemaFilePath = exports.muleGenerationDependenciesPath = exports.runtimeDependenciesSchemaFilePath = exports.runtimeDependenciesPath = exports.filterBy = exports.normalizeFilters = exports.filterAndSort = exports.showResults = exports.validateOrganizationAccess = exports.runCommandWithTimeout = exports.getAssetVersionFromProjectDependencies = exports.resolveAssetFile = exports.resolveExchangeModuleDir = exports.sleep = exports.executeRequestWithRetry = exports.Fields = exports.Filters = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const anypoint_cli_command_1 = require("anypoint-cli-command");
6
+ const node_readline_1 = tslib_1.__importDefault(require("node:readline"));
7
+ const node_path_1 = tslib_1.__importStar(require("node:path"));
8
+ const core_1 = require("@oclif/core");
9
+ const node_os_1 = require("node:os");
10
+ const constants_1 = require("../utils/constants");
11
+ const node_fs_1 = tslib_1.__importStar(require("node:fs"));
12
+ const junit_report_1 = require("../utils/report/junit-report");
13
+ const error_factory_1 = require("../errors/error-factory");
14
+ const deploy_1 = tslib_1.__importDefault(require("../commands/agent-network/project/deploy"));
15
+ const _2019_1 = tslib_1.__importDefault(require("ajv/dist/2019"));
16
+ const ajv_keywords_1 = tslib_1.__importDefault(require("ajv-keywords"));
17
+ const ajv_formats_1 = tslib_1.__importDefault(require("ajv-formats"));
18
+ const xml2js_1 = require("xml2js");
19
+ var Filters;
20
+ (function (Filters) {
21
+ Filters["CONSTRAINT"] = "Constraint";
22
+ Filters["SEVERITY"] = "Severity";
23
+ Filters["MESSAGE"] = "Message";
24
+ })(Filters = exports.Filters || (exports.Filters = {}));
25
+ exports.Fields = {
26
+ [Filters.CONSTRAINT]: 'validationId',
27
+ [Filters.SEVERITY]: 'severityLevel',
28
+ [Filters.MESSAGE]: 'message',
29
+ };
30
+ /**
31
+ * Executes a request with retry logic. Retries up to 3 times for non-200 responses.
32
+ * @param requestFunction - The request function to execute
33
+ * @param maxRetries - Maximum number of retries (default: 3)
34
+ * @param command - The command for the specific request
35
+ * @param timeout - The Request timeout
36
+ * @param msgError - The specific message Error if applies
37
+ * @returns Promise with the response
38
+ * @throws Error if all retries fail
39
+ */
40
+ async function executeRequestWithRetry(requestFunction, maxRetries = 3, timeout = deploy_1.default.defaultRequestTimeout) {
41
+ var _a, _b;
42
+ let lastError;
43
+ let lastResponse;
44
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
45
+ try {
46
+ anypoint_cli_command_1.Logger.debug(`Performing request with timeout (${timeout})`);
47
+ const response = await requestFunction();
48
+ lastResponse = response;
49
+ // Check if response has a status property and it's not 200
50
+ if (response && typeof response === 'object' && 'status' in response) {
51
+ const status = response.status;
52
+ if (status >= 200 && status < 300) {
53
+ return response;
54
+ }
55
+ }
56
+ else {
57
+ // If no status property, assume success
58
+ return response;
59
+ }
60
+ // If we reach here, the response was not successful
61
+ }
62
+ catch (error) {
63
+ lastError = error;
64
+ // Check if it's an HTTP error with status code
65
+ if (error && typeof error === 'object' && 'response' in error) {
66
+ const httpError = error;
67
+ const status = (_a = httpError.response) === null || _a === void 0 ? void 0 : _a.status;
68
+ if (status >= 200 && status < 300) {
69
+ return httpError.response;
70
+ }
71
+ }
72
+ else if (isRequestTimeoutError(error)) {
73
+ throw error_factory_1.ErrorFactory.requestTimeout('Deploy', timeout);
74
+ }
75
+ }
76
+ // If we reach here, the response was not successful and we need to check if we should throw
77
+ if (attempt === maxRetries) {
78
+ let status;
79
+ // Get status from successful response with bad status code
80
+ if (lastResponse && typeof lastResponse === 'object' && 'status' in lastResponse) {
81
+ status = lastResponse.status;
82
+ }
83
+ // Or get status from error response
84
+ else if (lastError && typeof lastError === 'object' && 'response' in lastError) {
85
+ status = (_b = lastError.response) === null || _b === void 0 ? void 0 : _b.status;
86
+ }
87
+ if (status !== undefined) {
88
+ throw error_factory_1.ErrorFactory.requestFailed(status, maxRetries);
89
+ }
90
+ else {
91
+ throw error_factory_1.ErrorFactory.requestFailedWithError(maxRetries, lastError);
92
+ }
93
+ }
94
+ // Wait before retrying (exponential backoff)
95
+ if (attempt < maxRetries) {
96
+ await sleep(1000 * attempt);
97
+ }
98
+ }
99
+ throw lastError;
100
+ }
101
+ exports.executeRequestWithRetry = executeRequestWithRetry;
102
+ function isRequestTimeoutError(error) {
103
+ return error && typeof error === 'object' && 'code' in error && error.code === 'ECONNABORTED' && error.message.includes('timeout');
104
+ }
105
+ function sleep(ms) {
106
+ return new Promise(resolve => setTimeout(resolve, ms));
107
+ }
108
+ exports.sleep = sleep;
109
+ function resolveExchangeModuleDir() {
110
+ const userHomeDirectory = (0, node_os_1.homedir)();
111
+ return (0, node_path_1.join)(userHomeDirectory, constants_1.EXCHANGE_MODULES_DIR_NAME);
112
+ }
113
+ exports.resolveExchangeModuleDir = resolveExchangeModuleDir;
114
+ function resolveAssetFile(projectPath, assetKind, asset, fileName, exchange) {
115
+ if (asset.groupId === exchange.groupId) {
116
+ const file = (0, node_path_1.join)(projectPath, constants_1.TARGET_DIR, constants_1.ASSETS_DIR, assetKind, asset.assetId, fileName);
117
+ if ((0, node_fs_1.existsSync)(file)) {
118
+ return file;
119
+ }
120
+ }
121
+ const file = (0, node_path_1.join)(resolveExchangeModuleDir(), asset.groupId, asset.assetId, asset.version, fileName);
122
+ if ((0, node_fs_1.existsSync)(file)) {
123
+ return file;
124
+ }
125
+ return null;
126
+ }
127
+ exports.resolveAssetFile = resolveAssetFile;
128
+ function getAssetVersionFromProjectDependencies(projectDescriptor, groupId, assetId) {
129
+ if (!projectDescriptor.dependencies) {
130
+ return undefined;
131
+ }
132
+ const dependency = projectDescriptor.dependencies.find(dep => dep.groupId === groupId && dep.assetId === assetId);
133
+ return dependency === null || dependency === void 0 ? void 0 : dependency.version;
134
+ }
135
+ exports.getAssetVersionFromProjectDependencies = getAssetVersionFromProjectDependencies;
136
+ async function runCommandWithTimeout(promise, timeoutMs, command) {
137
+ return new Promise((resolve, reject) => {
138
+ const timer = setTimeout(() => {
139
+ try {
140
+ reject(error_factory_1.ErrorFactory.commandTimeout(command, timeoutMs));
141
+ }
142
+ catch (error) {
143
+ reject(error);
144
+ }
145
+ }, timeoutMs);
146
+ promise
147
+ .then(result => {
148
+ clearTimeout(timer);
149
+ resolve(result);
150
+ })
151
+ .catch(error => {
152
+ clearTimeout(timer);
153
+ reject(error);
154
+ });
155
+ });
156
+ }
157
+ exports.runCommandWithTimeout = runCommandWithTimeout;
158
+ const validateOrganizationAccess = (account, organizationId) => {
159
+ var _a;
160
+ if (!account || ((_a = account === null || account === void 0 ? void 0 : account.memberOfOrganizations) === null || _a === void 0 ? void 0 : _a.find(membership => membership.id === organizationId))) {
161
+ return true;
162
+ }
163
+ return false;
164
+ };
165
+ exports.validateOrganizationAccess = validateOrganizationAccess;
166
+ const showResults = (response, flags) => {
167
+ const filtro = flags['filter-by'];
168
+ let report = [...response.syntaxValidations, ...response.functionalValidations];
169
+ if (filtro) {
170
+ report = (0, exports.filterAndSort)(report, filtro);
171
+ }
172
+ if (flags.json) {
173
+ anypoint_cli_command_1.Logger.print(JSON.stringify(response, null, 2));
174
+ }
175
+ else {
176
+ showReport(report, flags);
177
+ }
178
+ if (flags.junit && (report === null || report === void 0 ? void 0 : report.length) > 0) {
179
+ (0, junit_report_1.buildJunitReport)(report, flags['junit-loc']);
180
+ }
181
+ };
182
+ exports.showResults = showResults;
183
+ const showReport = async (report, flags) => {
184
+ var _a;
185
+ const projectPath = flags.location;
186
+ let formattedReports = [];
187
+ report.map((lint) => formattedReports = formattedReports.concat(formatLintReport(lint, projectPath).split('\n')));
188
+ const linesPerPage = (_a = flags['page-size']) !== null && _a !== void 0 ? _a : formattedReports.length;
189
+ let currentPage = 0;
190
+ while (currentPage * linesPerPage < formattedReports.length) {
191
+ const page = formattedReports.slice(currentPage * linesPerPage, (currentPage + 1) * linesPerPage);
192
+ for (const line of page) {
193
+ if (line !== '\n') {
194
+ anypoint_cli_command_1.Logger.print(line);
195
+ }
196
+ }
197
+ if ((currentPage + 1) * linesPerPage < formattedReports.length) {
198
+ try {
199
+ // eslint-disable-next-line no-await-in-loop
200
+ await core_1.CliUx.ux.anykey();
201
+ node_readline_1.default.moveCursor(process.stdout, 0, -1);
202
+ node_readline_1.default.clearScreenDown(process.stdout);
203
+ }
204
+ catch {
205
+ break;
206
+ }
207
+ }
208
+ currentPage++;
209
+ }
210
+ };
211
+ const filterAndSort = (reporte, filtro) => {
212
+ if (filtro) {
213
+ const map = new Map();
214
+ for (const f of filtro) {
215
+ const kv = f.split(':');
216
+ const property = (0, exports.normalizeFilters)(kv[0]);
217
+ if (map.has(property)) {
218
+ map.set(property, [...map.get(property) || [], kv[1]]);
219
+ }
220
+ else {
221
+ map.set(property, [kv[1]]);
222
+ }
223
+ }
224
+ return reporte === null || reporte === void 0 ? void 0 : reporte.filter((el) => (0, exports.filterBy)(el, map));
225
+ }
226
+ return reporte;
227
+ };
228
+ exports.filterAndSort = filterAndSort;
229
+ const formatLintReport = (lint, projectPath) => {
230
+ let report = `\tConstraint: ${lint.validationId}\n\tSeverity: ${lint.severityLevel}\n\tMessage: ${lint.message}\n`;
231
+ if (lint.location) {
232
+ const filePath = node_path_1.default.join(projectPath, lint.location.replace('file://', ''));
233
+ report += `\tLocation: ${lint.location}\n\tPosition: ${lint.position}\n\tLink: ${filePath}:${lint.position.lineFrom}:${lint.position.columnFrom}\n`;
234
+ }
235
+ return report;
236
+ };
237
+ const normalizeFilters = (property) => {
238
+ if (Filters.SEVERITY.toLowerCase() === property.toLowerCase()) {
239
+ property = exports.Fields[Filters.SEVERITY];
240
+ }
241
+ if (Filters.MESSAGE.toLowerCase() === property.toLowerCase()) {
242
+ property = exports.Fields[Filters.MESSAGE];
243
+ }
244
+ if (Filters.CONSTRAINT.toLowerCase() === property.toLowerCase()) {
245
+ property = exports.Fields[Filters.CONSTRAINT];
246
+ }
247
+ return property;
248
+ };
249
+ exports.normalizeFilters = normalizeFilters;
250
+ const filterBy = (el, filtro) => {
251
+ var _a;
252
+ for (const k of filtro.keys()) {
253
+ const regex = new RegExp(((_a = filtro === null || filtro === void 0 ? void 0 : filtro.get(k)) === null || _a === void 0 ? void 0 : _a.join('|')) || '*', 'i');
254
+ if (el[k] === undefined || !regex.test(el[k])) {
255
+ return false;
256
+ }
257
+ }
258
+ return true;
259
+ };
260
+ exports.filterBy = filterBy;
261
+ exports.runtimeDependenciesPath = node_path_1.default.join(__dirname, `../resources/${constants_1.RUNTIME_DEPENDENCIES_FILE}`);
262
+ exports.runtimeDependenciesSchemaFilePath = node_path_1.default.join(__dirname, `../resources/schemas/${constants_1.RUNTIME_DEPENDENCIES_SCHEMA_FILE}`);
263
+ exports.muleGenerationDependenciesPath = node_path_1.default.join(__dirname, `../resources/${constants_1.MULE_GENERATION_DEPENDENCIES_FILE}`);
264
+ exports.muleGenerationDependenciesSchemaFilePath = node_path_1.default.join(__dirname, `../resources/schemas/${constants_1.MULE_GENERATION_DEPENDENCIES_SCHEMA_FILE}`);
265
+ const getRuntimeDependencies = () => {
266
+ // Read the runtime-dependencies.json file to get the actual filename
267
+ if (!node_fs_1.default.existsSync(exports.runtimeDependenciesPath)) {
268
+ throw error_factory_1.ErrorFactory.runtimeDependenciesFileNotFound();
269
+ }
270
+ return (0, exports.safeJsonFileParse)(exports.runtimeDependenciesPath, exports.runtimeDependenciesSchemaFilePath).jsonObject;
271
+ };
272
+ exports.getRuntimeDependencies = getRuntimeDependencies;
273
+ const getMuleGenerationDependencies = () => {
274
+ if (!node_fs_1.default.existsSync(exports.muleGenerationDependenciesPath)) {
275
+ return [];
276
+ }
277
+ return (0, exports.safeJsonFileParse)(exports.muleGenerationDependenciesPath, exports.muleGenerationDependenciesSchemaFilePath).jsonObject;
278
+ };
279
+ exports.getMuleGenerationDependencies = getMuleGenerationDependencies;
280
+ const checkForRuntimeDependencyFiles = (cacheDir) => {
281
+ const runtimeDependencies = (0, exports.getRuntimeDependencies)();
282
+ // Check if we have dependencies defined
283
+ if (!runtimeDependencies || runtimeDependencies.length === 0) {
284
+ // nothing to download
285
+ return false;
286
+ }
287
+ // For each dependency, check if the corresponding file exists
288
+ for (const dependency of runtimeDependencies) {
289
+ const fileName = `${dependency['artifact-id']}-${dependency.classifier}.${dependency.packaging}`;
290
+ const depRuntimeFile = node_path_1.default.join(cacheDir, fileName);
291
+ if (!node_fs_1.default.existsSync(depRuntimeFile)) {
292
+ return true;
293
+ }
294
+ }
295
+ return false;
296
+ };
297
+ exports.checkForRuntimeDependencyFiles = checkForRuntimeDependencyFiles;
298
+ // Check if error is an AxiosError and cast it
299
+ const isAnAxiosError = (error) => {
300
+ return error && typeof error === 'object' && !!error.isAxiosError;
301
+ };
302
+ exports.isAnAxiosError = isAnAxiosError;
303
+ const quoteValue = (value) => `"${value}"`;
304
+ exports.quoteValue = quoteValue;
305
+ exports.MULESOFT_ORGS = {
306
+ 'devx.anypoint.mulesoft.com': '68ef9520-24e9-4cf2-b2f5-620025690913',
307
+ 'qax.anypoint.mulesoft.com': '68ef9520-24e9-4cf2-b2f5-620025690913',
308
+ 'stgx.anypoint.mulesoft.com': '68ef9520-24e9-4cf2-b2f5-620025690913',
309
+ 'anypoint.mulesoft.com': '68ef9520-24e9-4cf2-b2f5-620025690913',
310
+ 'eu1.anypoint.mulesoft.com': 'e0b4a150-f59b-46d4-ad25-5d98f9deb24a',
311
+ 'gstg.anypoint.mulesoft.com': '0024cbc0-3ea2-4909-b2ec-d9bd3186b46e',
312
+ 'gov.anypoint.mulesoft.com': 'cc104e51-c616-4ea0-aee3-c5ee907bc13b',
313
+ };
314
+ const createAjvCompiler = () => {
315
+ const ajv = new _2019_1.default({
316
+ addUsedSchema: false,
317
+ allErrors: true,
318
+ strict: true,
319
+ });
320
+ (0, ajv_keywords_1.default)(ajv, 'uniqueItemProperties');
321
+ (0, ajv_formats_1.default)(ajv);
322
+ // Since we are enabling the strict mode we need to add the @context keyword to ajv,
323
+ // but we can't do it with the ajv.addKeyword function because "@" is not supported.
324
+ ajv.RULES.keywords['@context'] = ajv.RULES.all['@context'] = true;
325
+ ajv.addFormat('dataweaveExpression', constants_1.DATAWEAVE_EXPRESSION);
326
+ return ajv;
327
+ };
328
+ exports.createAjvCompiler = createAjvCompiler;
329
+ const safeJsonFileParse = (jsonFilePath, schemaFilePath) => {
330
+ const jsonString = node_fs_1.default.readFileSync(jsonFilePath, constants_1.UTF8);
331
+ const schemaString = schemaFilePath ? node_fs_1.default.readFileSync(schemaFilePath, constants_1.UTF8) : undefined;
332
+ return (0, exports.safeJsonStringParse)(jsonString, schemaString);
333
+ };
334
+ exports.safeJsonFileParse = safeJsonFileParse;
335
+ const safeJsonStringParse = (jsonString, schemaString) => {
336
+ const jsonObject = JSON.parse(jsonString);
337
+ let valid = true;
338
+ let errors = undefined;
339
+ if (schemaString) {
340
+ const schema = JSON.parse(schemaString);
341
+ const validate = (0, exports.createAjvCompiler)().compile(schema);
342
+ valid = validate(jsonObject);
343
+ errors = validate.errors;
344
+ }
345
+ return {
346
+ valid,
347
+ errors,
348
+ jsonObject
349
+ };
350
+ };
351
+ exports.safeJsonStringParse = safeJsonStringParse;
352
+ const safeXmlStringParse = async (xmlString) => {
353
+ const parser = new xml2js_1.Parser({ explicitArray: false });
354
+ try {
355
+ const xmlObject = await parser.parseStringPromise(xmlString);
356
+ return Promise.resolve({ valid: true, xmlObject, error: null });
357
+ }
358
+ catch (error) {
359
+ return Promise.resolve({ valid: false, error });
360
+ }
361
+ };
362
+ exports.safeXmlStringParse = safeXmlStringParse;
363
+ const safeJsonObjectParse = (jsonObject, schemaFilePath) => {
364
+ const schema = JSON.parse(node_fs_1.default.readFileSync(schemaFilePath, constants_1.UTF8));
365
+ const validate = (0, exports.createAjvCompiler)().compile(schema);
366
+ const valid = validate(jsonObject);
367
+ return {
368
+ valid,
369
+ errors: validate.errors,
370
+ jsonObject
371
+ };
372
+ };
373
+ exports.safeJsonObjectParse = safeJsonObjectParse;
374
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/helpers/utils.ts"],"names":[],"mappings":";;;;AAAA,+DAAoD;AACpD,0EAAoC;AACpC,+DAAoC;AACpC,sCAAiC;AACjC,qCAA+B;AAC/B,kDAM2B;AAE3B,2DAAsC;AACtC,+DAA6D;AAC7D,2DAAoD;AACpD,8FAA6D;AAC7D,kEAAoE;AACpE,wEAAsC;AACtC,sEAAoC;AACpC,mCAA6B;AAG7B,IAAY,OAIX;AAJD,WAAY,OAAO;IACjB,oCAAyB,CAAA;IACzB,gCAAqB,CAAA;IACrB,8BAAmB,CAAA;AACrB,CAAC,EAJW,OAAO,GAAP,eAAO,KAAP,eAAO,QAIlB;AAEY,QAAA,MAAM,GAAG;IACpB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,cAAc;IACpC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,eAAe;IACnC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,SAAS;CAC7B,CAAA;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,uBAAuB,CAC3C,eAAiC,EACjC,UAAU,GAAG,CAAC,EACd,OAAO,GAAG,gBAAM,CAAC,qBAAqB;;IAEtC,IAAI,SAAc,CAAA;IAClB,IAAI,YAAiB,CAAA;IAErB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,UAAU,EAAE,OAAO,EAAE,EAAE;QACtD,IAAI;YACF,6BAAM,CAAC,KAAK,CAAC,oCAAoC,OAAO,GAAG,CAAC,CAAA;YAC5D,MAAM,QAAQ,GAAG,MAAM,eAAe,EAAE,CAAA;YACxC,YAAY,GAAG,QAAQ,CAAA;YAEvB,2DAA2D;YAC3D,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,QAAQ,EAAE;gBACpE,MAAM,MAAM,GAA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A8B,EAAE;IAC5F,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAA;IACnD,IAAI;QACF,MAAM,SAAS,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAA;QAC5D,OAAO,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;KAC/D;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,OAAO,CAAC,OAAO,CAAC,EAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAA;KAC9C;AACH,CAAC,CAAA;AARY,QAAA,kBAAkB,sBAQ9B;AAEM,MAAM,mBAAmB,GAAG,CAAC,UAAkB,EAAE,cAAsB,EAAoB,EAAE;IAClG,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,iBAAE,CAAC,YAAY,CAAC,cAAc,EAAE,gBAAI,CAAC,CAAC,CAAA;IAChE,MAAM,QAAQ,GAA0B,IAAA,yBAAiB,GAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC3E,MAAM,KAAK,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAA;IAElC,OAAO;QACL,KAAK;QACL,MAAM,EAAE,QAAQ,CAAC,MAAM;QACvB,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AAVY,QAAA,mBAAmB,uBAU/B"}
@@ -0,0 +1,5 @@
1
+ export { default as Build } from './commands/agent-network/project/build';
2
+ export { default as Create } from './commands/agent-network/project/create';
3
+ export { default as Deploy } from './commands/agent-network/project/deploy';
4
+ export { default as Publish } from './commands/agent-network/project/publish';
5
+ export { default as Gateways } from './commands/agent-network/setup/gateways';
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Gateways = exports.Publish = exports.Deploy = exports.Create = exports.Build = void 0;
7
+ var build_1 = require("./commands/agent-network/project/build");
8
+ Object.defineProperty(exports, "Build", { enumerable: true, get: function () { return __importDefault(build_1).default; } });
9
+ var create_1 = require("./commands/agent-network/project/create");
10
+ Object.defineProperty(exports, "Create", { enumerable: true, get: function () { return __importDefault(create_1).default; } });
11
+ var deploy_1 = require("./commands/agent-network/project/deploy");
12
+ Object.defineProperty(exports, "Deploy", { enumerable: true, get: function () { return __importDefault(deploy_1).default; } });
13
+ var publish_1 = require("./commands/agent-network/project/publish");
14
+ Object.defineProperty(exports, "Publish", { enumerable: true, get: function () { return __importDefault(publish_1).default; } });
15
+ var gateways_1 = require("./commands/agent-network/setup/gateways");
16
+ Object.defineProperty(exports, "Gateways", { enumerable: true, get: function () { return __importDefault(gateways_1).default; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAuE;AAA/D,+GAAA,OAAO,OAAS;AACxB,kEAAyE;AAAjE,iHAAA,OAAO,OAAU;AACzB,kEAAyE;AAAjE,iHAAA,OAAO,OAAU;AACzB,oEAA2E;AAAnE,mHAAA,OAAO,OAAW;AAC1B,oEAA2E;AAAnE,qHAAA,OAAO,OAAY"}
@@ -0,0 +1,13 @@
1
+ [
2
+ {
3
+ "group-id": "com.mulesoft.agents",
4
+ "artifact-id": "agent-fabric-transformation",
5
+ "strategyVersion": {
6
+ "strategy": "LATEST_MINOR",
7
+ "version": "1"
8
+ },
9
+ "classifier": "uber-jar",
10
+ "packaging": "jar",
11
+ "releaseRule": "RELEASE"
12
+ }
13
+ ]
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
3
+ "$id": "https://example.com/mulesoft-agent-schema.json",
4
+ "title": "MuleSoft Agent Fabric Mule Dependencies List",
5
+ "description": "Schema for defining dependencies for Agent Fabric mule generation.",
6
+ "type": "array",
7
+ "minItems": 0,
8
+ "items": {
9
+ "type": "object",
10
+ "properties": {
11
+ "group-id": {
12
+ "type": "string",
13
+ "description": "Maven group ID of the artifact."
14
+ },
15
+ "artifact-id": {
16
+ "type": "string",
17
+ "description": "Maven artifact ID of the artifact."
18
+ },
19
+ "variable": {
20
+ "type": "string",
21
+ "description": "Variable name for the dependency to be injected."
22
+ },
23
+ "strategyVersion": {
24
+ "type": "object",
25
+ "properties": {
26
+ "strategy": {
27
+ "type": "string",
28
+ "enum": ["LATEST", "LATEST_MINOR", "LATEST_PATCH"],
29
+ "description": "Versioning strategy used to resolve the artifact."
30
+ },
31
+ "version": {
32
+ "type": "string",
33
+ "description": "Version number associated with the selected strategy."
34
+ }
35
+ },
36
+ "required": ["strategy", "version"]
37
+ },
38
+ "snapshot": {
39
+ "type": "boolean",
40
+ "description": "Indicates whether the artifact is a snapshot version."
41
+ }
42
+ },
43
+ "required": [
44
+ "group-id",
45
+ "artifact-id",
46
+ "strategyVersion",
47
+ "variable",
48
+ "snapshot"
49
+ ],
50
+ "additionalProperties": false
51
+ }
52
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
3
+ "$id": "https://example.com/mulesoft-agent-schema.json",
4
+ "title": "MuleSoft Agent Artifact List",
5
+ "description": "Schema for defining MuleSoft agent artifact configuration items.",
6
+ "type": "array",
7
+ "minItems": 0,
8
+ "items": {
9
+ "type": "object",
10
+ "properties": {
11
+ "group-id": {
12
+ "type": "string",
13
+ "description": "Maven group ID of the artifact."
14
+ },
15
+ "artifact-id": {
16
+ "type": "string",
17
+ "description": "Maven artifact ID of the artifact."
18
+ },
19
+ "strategyVersion": {
20
+ "type": "object",
21
+ "properties": {
22
+ "strategy": {
23
+ "type": "string",
24
+ "enum": ["LATEST", "LATEST_MINOR", "LATEST_PATCH"],
25
+ "description": "Versioning strategy used to resolve the artifact."
26
+ },
27
+ "version": {
28
+ "type": "string",
29
+ "description": "Version number associated with the selected strategy."
30
+ }
31
+ },
32
+ "required": ["strategy", "version"]
33
+ },
34
+ "classifier": {
35
+ "type": "string",
36
+ "description": "Maven classifier (e.g., 'uber-jar', 'sources')."
37
+ },
38
+ "packaging": {
39
+ "type": "string",
40
+ "description": "Type of packaging for the artifact (e.g., 'jar', 'zip')."
41
+ },
42
+ "snapshot": {
43
+ "type": "boolean",
44
+ "description": "Indicates whether the artifact is a snapshot version."
45
+ }
46
+ },
47
+ "required": [
48
+ "group-id",
49
+ "artifact-id",
50
+ "strategyVersion",
51
+ "classifier",
52
+ "packaging",
53
+ "snapshot"
54
+ ],
55
+ "additionalProperties": false
56
+ }
57
+ }