@uipath/solution-tool 1.203.0-preview.203 → 1.204.0-preview.206

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 (76) hide show
  1. package/README.md +2 -2
  2. package/dist/THIRD-PARTY-NOTICES.md +42 -4
  3. package/dist/deploy-delete-service-y9dwehmn.js +22 -0
  4. package/dist/deploy-status-service-nmhnnjmy.js +256 -0
  5. package/dist/deploy.d.ts +11 -4
  6. package/dist/deploy.js +19 -7
  7. package/dist/deployment-search-eb337bjh.js +49 -0
  8. package/dist/{embedded-file-reader-xxqe8vs8.js → embedded-file-reader-rf2g1kfj.js} +2 -2
  9. package/dist/feed-resolver-dmtnswcc.js +27 -0
  10. package/dist/feed-scope-failure-e2yaqfg2.js +18 -0
  11. package/dist/feed-session-sxga31vn.js +17 -0
  12. package/dist/index.js +27 -18
  13. package/dist/init.js +10 -7
  14. package/dist/{list-n0xd5rgn.js → list-rbjqgz6s.js} +9 -6
  15. package/dist/pack.js +14 -11
  16. package/dist/{packager-tool-vas0xg5h.js → packager-tool-2cntqvdv.js} +5 -3
  17. package/dist/{packager-tool-1haahq17.js → packager-tool-3enm2h28.js} +5 -5
  18. package/dist/{packager-tool-2syrt51a.js → packager-tool-3fv6zc86.js} +1062 -825
  19. package/dist/packager-tool-3fyq6wjs.js +5889 -0
  20. package/dist/{packager-tool-k4mskzww.js → packager-tool-5dzjsw5q.js} +3 -3
  21. package/dist/{packager-tool-0f0wt9vh.js → packager-tool-5fjp60dk.js} +3071 -2794
  22. package/dist/{packager-tool-x6gzyxnn.js → packager-tool-752zvh64.js} +756 -359
  23. package/dist/{packager-tool-bkwnetqn.js → packager-tool-83rzavkx.js} +383 -88
  24. package/dist/{packager-tool-7znqtw3f.js → packager-tool-9vvdgbay.js} +8 -6
  25. package/dist/packager-tool-b8pppqbb.js +172 -0
  26. package/dist/packager-tool-bqre28m1.js +43 -0
  27. package/dist/packager-tool-dh0m3ebf.js +173 -0
  28. package/dist/packager-tool-f5gq77m5.js +28 -0
  29. package/dist/{packager-tool-nzghfa48.js → packager-tool-fv7xyzg2.js} +550 -2
  30. package/dist/{packager-tool-3jrq7smt.js → packager-tool-gb35b4qs.js} +206 -289
  31. package/dist/{packager-tool-j2cqgegq.js → packager-tool-he7ak44z.js} +16 -74
  32. package/dist/packager-tool-myn57mc3.js +322 -0
  33. package/dist/{packager-tool-4rzjjv2p.js → packager-tool-n1nzj2b9.js} +1008 -647
  34. package/dist/packager-tool-n6yb6zp9.js +113 -0
  35. package/dist/{packager-tool-h4wn0y42.js → packager-tool-qgaqqq41.js} +320 -151
  36. package/dist/{packager-tool-resolver-fmjr60x8.js → packager-tool-resolver-2cbxyq6k.js} +6 -5
  37. package/dist/{packager-tool-ge4rvy7p.js → packager-tool-t12hj6pd.js} +1022 -1342
  38. package/dist/{packager-tool-znakt6yw.js → packager-tool-vh4ng74p.js} +8 -6
  39. package/dist/packager-tool-vmsxq1pc.js +104 -0
  40. package/dist/packager-tool-w6jr4638.js +166 -0
  41. package/dist/packager-tool-zf3929se.js +237 -0
  42. package/dist/packager-tool-zns6n8zp.js +837 -0
  43. package/dist/packager-tool-zw3036b8.js +37 -0
  44. package/dist/packager-tool.js +2 -2
  45. package/dist/prepare-solution-resources-p3gzdecy.js +25 -0
  46. package/dist/{project-contributions-cvttys34.js → project-contributions-txe8v6sm.js} +12 -9
  47. package/dist/publish.js +12 -7
  48. package/dist/resource.js +9 -6
  49. package/dist/services/activation.d.ts +17 -2
  50. package/dist/services/deploy-activate-service.d.ts +10 -0
  51. package/dist/services/deploy-delete-service.d.ts +82 -0
  52. package/dist/services/deploy-list-service.d.ts +15 -45
  53. package/dist/services/deploy-run-service.d.ts +36 -23
  54. package/dist/services/deploy-upgrade-service.d.ts +198 -39
  55. package/dist/services/deployment-feed-locator.d.ts +50 -12
  56. package/dist/services/deployment-search-client.d.ts +55 -0
  57. package/dist/services/deployment-search.d.ts +87 -34
  58. package/dist/services/deployment-state.d.ts +119 -0
  59. package/dist/services/feed-resolver.d.ts +31 -0
  60. package/dist/services/feed-session.d.ts +70 -0
  61. package/dist/services/folder-helper.d.ts +4 -27
  62. package/dist/services/http-status.d.ts +9 -0
  63. package/dist/services/incomplete-feed-sweep.d.ts +77 -0
  64. package/dist/services/legacy-deployment-search-v3.d.ts +23 -0
  65. package/dist/services/packages-list-service.d.ts +5 -0
  66. package/dist/services/pipeline-deploy-poll.d.ts +69 -0
  67. package/dist/services/publish-service.d.ts +14 -16
  68. package/dist/services/search-failure.d.ts +27 -0
  69. package/dist/templates/AGENTS.md +60 -20
  70. package/dist/tool.js +27 -18
  71. package/dist/utils/deployment-errors.d.ts +57 -0
  72. package/package.json +2 -2
  73. package/dist/packager-tool-07bqr90h.js +0 -51960
  74. package/dist/packager-tool-jz2wbfjz.js +0 -2275
  75. package/dist/prepare-solution-resources-wds3r8bq.js +0 -22
  76. package/dist/services/personal-workspace-deploy.d.ts +0 -49
@@ -1,2275 +0,0 @@
1
- import {
2
- toolsFactoryRepository
3
- } from "./packager-tool-nzghfa48.js";
4
- import {
5
- unzipSync,
6
- zipSync
7
- } from "./packager-tool-dfrk01gn.js";
8
-
9
- // ../packager/packager-core/dist/index.js
10
- class Path {
11
- static normalize(path) {
12
- return path.replace(/\\/g, "/").replace(/\/+/g, "/");
13
- }
14
- static join(...segments) {
15
- return Path.normalize(segments.filter((s) => s.length > 0).join("/"));
16
- }
17
- static dirname(path) {
18
- const normalized = Path.normalize(path).replace(/\/$/, "");
19
- if (normalized === "")
20
- return ".";
21
- const lastSlash = normalized.lastIndexOf("/");
22
- if (lastSlash === -1)
23
- return ".";
24
- if (lastSlash === 0)
25
- return "/";
26
- return normalized.substring(0, lastSlash);
27
- }
28
- static basename(path) {
29
- const normalized = Path.normalize(path).replace(/\/$/, "");
30
- if (normalized === "")
31
- return "";
32
- const lastSlash = normalized.lastIndexOf("/");
33
- return lastSlash >= 0 ? normalized.substring(lastSlash + 1) : normalized;
34
- }
35
- static extname(path) {
36
- const base = Path.basename(path);
37
- const lastDot = base.lastIndexOf(".");
38
- if (lastDot === -1 || lastDot === 0 || lastDot === base.length - 1) {
39
- return "";
40
- }
41
- return base.substring(lastDot);
42
- }
43
- static async walkDirectory(fs, rootPath, currentRelativePath = "") {
44
- const entries = [];
45
- const absolutePath = currentRelativePath ? Path.join(rootPath, currentRelativePath) : rootPath;
46
- const items = await fs.readdir(absolutePath);
47
- for (const item of items) {
48
- const itemRelativePath = currentRelativePath ? Path.join(currentRelativePath, item) : item;
49
- const itemAbsolutePath = Path.join(rootPath, itemRelativePath);
50
- const stat = await fs.stat(itemAbsolutePath);
51
- if (stat?.isDirectory()) {
52
- const subEntries = await Path.walkDirectory(fs, rootPath, itemRelativePath);
53
- entries.push(...subEntries);
54
- } else if (stat?.isFile()) {
55
- entries.push({
56
- relativePath: Path.normalize(itemRelativePath),
57
- absolutePath: Path.normalize(itemAbsolutePath)
58
- });
59
- }
60
- }
61
- return entries;
62
- }
63
- }
64
-
65
- class TemporaryStorageService {
66
- fileSystem;
67
- _tempFolderPath = null;
68
- constructor(fileSystem) {
69
- this.fileSystem = fileSystem;
70
- }
71
- async getTempFolderPath() {
72
- if (!this._tempFolderPath) {
73
- const systemTempDir = await this.fileSystem.getTempDir();
74
- const uniqueFolderName = this.generateUniqueFolderName();
75
- this._tempFolderPath = Path.join(systemTempDir, uniqueFolderName);
76
- await this.fileSystem.mkdir(this._tempFolderPath);
77
- }
78
- return this._tempFolderPath;
79
- }
80
- generateUniqueFolderName() {
81
- const timestamp = Date.now();
82
- const random = Math.random().toString(36).substring(2, 10);
83
- return `tool-temp-${timestamp}-${random}`;
84
- }
85
- async getTempSubfolderPathAsync(subfolder) {
86
- const tempFolderPath = await this.getTempFolderPath();
87
- const inputPath = Path.join(tempFolderPath, subfolder);
88
- await this.fileSystem.mkdir(inputPath);
89
- return inputPath;
90
- }
91
- async cleanup() {
92
- try {
93
- if (!this._tempFolderPath) {
94
- return;
95
- }
96
- try {
97
- const stats = await this.fileSystem.stat(this._tempFolderPath);
98
- if (!stats) {
99
- return;
100
- }
101
- } catch {
102
- return;
103
- }
104
- const _pathToCleanup = this._tempFolderPath;
105
- await this.fileSystem.rm(this._tempFolderPath);
106
- this._tempFolderPath = null;
107
- } catch {}
108
- }
109
- }
110
-
111
- class ZipService {
112
- fileSystem;
113
- constructor(fileSystem) {
114
- this.fileSystem = fileSystem;
115
- }
116
- async extractAsync(zipData, targetPath) {
117
- const normalizedTarget = targetPath.replace(/\/$/, "");
118
- const files = unzipSync(zipData);
119
- const dirsToCreate = new Set([normalizedTarget]);
120
- const filesToWrite = [];
121
- const extractedPaths = [];
122
- for (const [relativePath, data] of Object.entries(files)) {
123
- if (relativePath.endsWith("/") || data.length === 0) {
124
- const dirPath = `${normalizedTarget}/${relativePath.replace(/\/$/, "")}`;
125
- if (!dirPath.startsWith(`${normalizedTarget}/`)) {
126
- throw new Error(`Zip-slip detected: entry "${relativePath}" escapes extraction directory`);
127
- }
128
- dirsToCreate.add(dirPath);
129
- continue;
130
- }
131
- const fullPath = `${normalizedTarget}/${relativePath}`;
132
- if (!fullPath.startsWith(`${normalizedTarget}/`)) {
133
- throw new Error(`Zip-slip detected: entry "${relativePath}" escapes extraction directory`);
134
- }
135
- const parentDir = fullPath.split("/").slice(0, -1).join("/");
136
- if (parentDir) {
137
- dirsToCreate.add(parentDir);
138
- }
139
- filesToWrite.push({ path: fullPath, data });
140
- extractedPaths.push(fullPath);
141
- }
142
- await Promise.all(Array.from(dirsToCreate, (dir) => this.fileSystem.mkdir(dir)));
143
- await Promise.all(filesToWrite.map(({ path, data }) => this.fileSystem.writeFile(path, data)));
144
- return extractedPaths;
145
- }
146
- async compressAsync(sourcePath) {
147
- const normalizedSource = sourcePath.replace(/\/$/, "");
148
- const entries = await Path.walkDirectory(this.fileSystem, normalizedSource);
149
- const fileContents = await Promise.all(entries.map(async (entry) => ({
150
- relativePath: entry.relativePath,
151
- data: await this.fileSystem.readFile(entry.absolutePath)
152
- })));
153
- const zippable = {};
154
- for (const { relativePath, data } of fileContents) {
155
- if (data) {
156
- zippable[relativePath] = data;
157
- }
158
- }
159
- const zipData = zipSync(zippable, {
160
- level: 6
161
- });
162
- return zipData;
163
- }
164
- compressEntries(entries) {
165
- return zipSync(entries, { level: 6 });
166
- }
167
- }
168
- function isPluralForm(value) {
169
- return typeof value === "object" && value !== null && "other" in value;
170
- }
171
- function selectPluralForm(forms, count) {
172
- if (count === 0 && forms.zero !== undefined) {
173
- return forms.zero;
174
- }
175
- if (count === 1 && forms.one !== undefined) {
176
- return forms.one;
177
- }
178
- if (count === 2 && forms.two !== undefined) {
179
- return forms.two;
180
- }
181
- if (forms.few !== undefined) {
182
- const mod10 = count % 10;
183
- const mod100 = count % 100;
184
- if (mod10 >= 2 && mod10 <= 4 && (mod100 < 10 || mod100 >= 20)) {
185
- return forms.few;
186
- }
187
- }
188
- if (forms.many !== undefined) {
189
- const mod10 = count % 10;
190
- const mod100 = count % 100;
191
- if (count === 0 || mod10 === 0 && mod100 !== 0 || mod10 >= 5 && mod10 <= 9 || mod100 >= 11 && mod100 <= 14) {
192
- return forms.many;
193
- }
194
- }
195
- return forms.other;
196
- }
197
-
198
- class I18nManager {
199
- static translations = {};
200
- static currentLocale = "en";
201
- static fallbackLocale = "en";
202
- static registerTranslations(locale, catalog) {
203
- if (!I18nManager.translations[locale]) {
204
- I18nManager.translations[locale] = {};
205
- }
206
- I18nManager.translations[locale] = I18nManager.deepMerge(I18nManager.translations[locale], catalog);
207
- }
208
- static setLocale(locale) {
209
- const normalized = I18nManager.normalizeLocale(locale);
210
- if (I18nManager.translations[normalized]) {
211
- I18nManager.currentLocale = normalized;
212
- return normalized;
213
- }
214
- const baseLocale = normalized.split("-")[0];
215
- if (baseLocale !== normalized && I18nManager.translations[baseLocale]) {
216
- I18nManager.currentLocale = baseLocale;
217
- return baseLocale;
218
- }
219
- return I18nManager.currentLocale;
220
- }
221
- static getLocale() {
222
- return I18nManager.currentLocale;
223
- }
224
- static setFallbackLocale(locale) {
225
- I18nManager.fallbackLocale = I18nManager.normalizeLocale(locale);
226
- }
227
- static t(key, params, locale) {
228
- const targetLocale = locale ? I18nManager.normalizeLocale(locale) : I18nManager.currentLocale;
229
- let value = I18nManager.getTranslationValue(key, targetLocale);
230
- if (value === undefined && targetLocale !== I18nManager.fallbackLocale) {
231
- value = I18nManager.getTranslationValue(key, I18nManager.fallbackLocale);
232
- }
233
- if (value === undefined) {
234
- return key;
235
- }
236
- if (isPluralForm(value) && params && "count" in params) {
237
- const count = typeof params.count === "number" ? params.count : Number(params.count);
238
- value = selectPluralForm(value, count);
239
- } else if (isPluralForm(value)) {
240
- value = value.other;
241
- }
242
- if (typeof value !== "string") {
243
- return key;
244
- }
245
- return params ? I18nManager.interpolate(value, params) : value;
246
- }
247
- static has(key, locale) {
248
- const targetLocale = locale ? I18nManager.normalizeLocale(locale) : I18nManager.currentLocale;
249
- const value = I18nManager.getTranslationValue(key, targetLocale);
250
- if (value !== undefined) {
251
- return true;
252
- }
253
- if (targetLocale !== I18nManager.fallbackLocale) {
254
- return I18nManager.getTranslationValue(key, I18nManager.fallbackLocale) !== undefined;
255
- }
256
- return false;
257
- }
258
- static getAvailableLocales() {
259
- return Object.keys(I18nManager.translations);
260
- }
261
- static clearTranslations() {
262
- I18nManager.translations = {};
263
- I18nManager.currentLocale = "en";
264
- }
265
- static getTranslationValue(key, locale) {
266
- const catalog = I18nManager.translations[locale];
267
- if (!catalog) {
268
- return;
269
- }
270
- const keys = key.split(".");
271
- let value = catalog;
272
- for (const k of keys) {
273
- if (value && typeof value === "object" && k in value) {
274
- value = value[k];
275
- } else {
276
- return;
277
- }
278
- }
279
- return value;
280
- }
281
- static interpolate(template, params) {
282
- return template.replace(/\{(\w+)\}/g, (_, key) => {
283
- const value = params[key];
284
- return value !== undefined ? String(value) : `{${key}}`;
285
- });
286
- }
287
- static normalizeLocale(locale) {
288
- const normalized = locale.toLowerCase().replace(/_/g, "-");
289
- const specialLocales = ["es-mx", "pt-br", "zh-cn", "zh-tw"];
290
- if (specialLocales.includes(normalized)) {
291
- return normalized;
292
- }
293
- return normalized.split("-")[0];
294
- }
295
- static deepMerge(target, source) {
296
- const result = { ...target };
297
- for (const key of Object.keys(source)) {
298
- const sourceValue = source[key];
299
- const targetValue = result[key];
300
- if (sourceValue && typeof sourceValue === "object" && !Array.isArray(sourceValue) && targetValue && typeof targetValue === "object" && !Array.isArray(targetValue)) {
301
- result[key] = I18nManager.deepMerge(targetValue, sourceValue);
302
- } else {
303
- result[key] = sourceValue;
304
- }
305
- }
306
- return result;
307
- }
308
- }
309
- var de = {
310
- toolCore: {
311
- errors: {
312
- internal: "Internal error: {message}",
313
- fileNotFound: "File not found: {path}",
314
- fileReadFailed: "Failed to read file: {path}",
315
- fileWriteFailed: "Failed to write file: {path}",
316
- directoryNotFound: "Directory not found: {path}",
317
- invalidPath: "{path} is not a valid path",
318
- operationCanceled: "Operation was canceled",
319
- invalidParameter: "Invalid parameter: {parameter}"
320
- },
321
- progress: {
322
- copying: "Copying files...",
323
- building: "Building project...",
324
- packaging: "Creating package...",
325
- validating: "Validating...",
326
- analyzing: "Analyzing...",
327
- restoring: "Restoring dependencies..."
328
- },
329
- validation: {
330
- requiredField: "{field} is required",
331
- invalidValue: "Invalid value for {field}",
332
- pathNotFound: "Path not found: {path}",
333
- fileRequired: "File is required: {path}",
334
- directoryRequired: "Directory is required: {path}"
335
- },
336
- warnings: {
337
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
338
- },
339
- info: {
340
- operationComplete: "Operation completed successfully",
341
- filesProcessed: {
342
- zero: "No files processed",
343
- one: "{count} file processed",
344
- other: "{count} files processed"
345
- }
346
- }
347
- }
348
- };
349
- var en = {
350
- toolCore: {
351
- errors: {
352
- internal: "Internal error: {message}",
353
- fileNotFound: "File not found: {path}",
354
- fileReadFailed: "Failed to read file: {path}",
355
- fileWriteFailed: "Failed to write file: {path}",
356
- directoryNotFound: "Directory not found: {path}",
357
- invalidPath: "{path} is not a valid path",
358
- operationCanceled: "Operation was canceled",
359
- invalidParameter: "Invalid parameter: {parameter}"
360
- },
361
- progress: {
362
- copying: "Copying files...",
363
- building: "Building project...",
364
- packaging: "Creating package...",
365
- validating: "Validating...",
366
- analyzing: "Analyzing...",
367
- restoring: "Restoring dependencies..."
368
- },
369
- validation: {
370
- requiredField: "{field} is required",
371
- invalidValue: "Invalid value for {field}",
372
- pathNotFound: "Path not found: {path}",
373
- fileRequired: "File is required: {path}",
374
- directoryRequired: "Directory is required: {path}"
375
- },
376
- warnings: {
377
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
378
- },
379
- info: {
380
- operationComplete: "Operation completed successfully",
381
- filesProcessed: {
382
- zero: "No files processed",
383
- one: "{count} file processed",
384
- other: "{count} files processed"
385
- }
386
- }
387
- }
388
- };
389
- var es = {
390
- toolCore: {
391
- errors: {
392
- internal: "Internal error: {message}",
393
- fileNotFound: "File not found: {path}",
394
- fileReadFailed: "Failed to read file: {path}",
395
- fileWriteFailed: "Failed to write file: {path}",
396
- directoryNotFound: "Directory not found: {path}",
397
- invalidPath: "{path} is not a valid path",
398
- operationCanceled: "Operation was canceled",
399
- invalidParameter: "Invalid parameter: {parameter}"
400
- },
401
- progress: {
402
- copying: "Copying files...",
403
- building: "Building project...",
404
- packaging: "Creating package...",
405
- validating: "Validating...",
406
- analyzing: "Analyzing...",
407
- restoring: "Restoring dependencies..."
408
- },
409
- validation: {
410
- requiredField: "{field} is required",
411
- invalidValue: "Invalid value for {field}",
412
- pathNotFound: "Path not found: {path}",
413
- fileRequired: "File is required: {path}",
414
- directoryRequired: "Directory is required: {path}"
415
- },
416
- warnings: {
417
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
418
- },
419
- info: {
420
- operationComplete: "Operation completed successfully",
421
- filesProcessed: {
422
- zero: "No files processed",
423
- one: "{count} file processed",
424
- other: "{count} files processed"
425
- }
426
- }
427
- }
428
- };
429
- var es_MX = {
430
- toolCore: {
431
- errors: {
432
- internal: "Internal error: {message}",
433
- fileNotFound: "File not found: {path}",
434
- fileReadFailed: "Failed to read file: {path}",
435
- fileWriteFailed: "Failed to write file: {path}",
436
- directoryNotFound: "Directory not found: {path}",
437
- invalidPath: "{path} is not a valid path",
438
- operationCanceled: "Operation was canceled",
439
- invalidParameter: "Invalid parameter: {parameter}"
440
- },
441
- progress: {
442
- copying: "Copying files...",
443
- building: "Building project...",
444
- packaging: "Creating package...",
445
- validating: "Validating...",
446
- analyzing: "Analyzing...",
447
- restoring: "Restoring dependencies..."
448
- },
449
- validation: {
450
- requiredField: "{field} is required",
451
- invalidValue: "Invalid value for {field}",
452
- pathNotFound: "Path not found: {path}",
453
- fileRequired: "File is required: {path}",
454
- directoryRequired: "Directory is required: {path}"
455
- },
456
- warnings: {
457
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
458
- },
459
- info: {
460
- operationComplete: "Operation completed successfully",
461
- filesProcessed: {
462
- zero: "No files processed",
463
- one: "{count} file processed",
464
- other: "{count} files processed"
465
- }
466
- }
467
- }
468
- };
469
- var fr = {
470
- toolCore: {
471
- errors: {
472
- internal: "Internal error: {message}",
473
- fileNotFound: "File not found: {path}",
474
- fileReadFailed: "Failed to read file: {path}",
475
- fileWriteFailed: "Failed to write file: {path}",
476
- directoryNotFound: "Directory not found: {path}",
477
- invalidPath: "{path} is not a valid path",
478
- operationCanceled: "Operation was canceled",
479
- invalidParameter: "Invalid parameter: {parameter}"
480
- },
481
- progress: {
482
- copying: "Copying files...",
483
- building: "Building project...",
484
- packaging: "Creating package...",
485
- validating: "Validating...",
486
- analyzing: "Analyzing...",
487
- restoring: "Restoring dependencies..."
488
- },
489
- validation: {
490
- requiredField: "{field} is required",
491
- invalidValue: "Invalid value for {field}",
492
- pathNotFound: "Path not found: {path}",
493
- fileRequired: "File is required: {path}",
494
- directoryRequired: "Directory is required: {path}"
495
- },
496
- warnings: {
497
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
498
- },
499
- info: {
500
- operationComplete: "Operation completed successfully",
501
- filesProcessed: {
502
- zero: "No files processed",
503
- one: "{count} file processed",
504
- other: "{count} files processed"
505
- }
506
- }
507
- }
508
- };
509
- var ja = {
510
- toolCore: {
511
- errors: {
512
- internal: "Internal error: {message}",
513
- fileNotFound: "File not found: {path}",
514
- fileReadFailed: "Failed to read file: {path}",
515
- fileWriteFailed: "Failed to write file: {path}",
516
- directoryNotFound: "Directory not found: {path}",
517
- invalidPath: "{path} is not a valid path",
518
- operationCanceled: "Operation was canceled",
519
- invalidParameter: "Invalid parameter: {parameter}"
520
- },
521
- progress: {
522
- copying: "Copying files...",
523
- building: "Building project...",
524
- packaging: "Creating package...",
525
- validating: "Validating...",
526
- analyzing: "Analyzing...",
527
- restoring: "Restoring dependencies..."
528
- },
529
- validation: {
530
- requiredField: "{field} is required",
531
- invalidValue: "Invalid value for {field}",
532
- pathNotFound: "Path not found: {path}",
533
- fileRequired: "File is required: {path}",
534
- directoryRequired: "Directory is required: {path}"
535
- },
536
- warnings: {
537
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
538
- },
539
- info: {
540
- operationComplete: "Operation completed successfully",
541
- filesProcessed: {
542
- zero: "No files processed",
543
- one: "{count} file processed",
544
- other: "{count} files processed"
545
- }
546
- }
547
- }
548
- };
549
- var ko = {
550
- toolCore: {
551
- errors: {
552
- internal: "Internal error: {message}",
553
- fileNotFound: "File not found: {path}",
554
- fileReadFailed: "Failed to read file: {path}",
555
- fileWriteFailed: "Failed to write file: {path}",
556
- directoryNotFound: "Directory not found: {path}",
557
- invalidPath: "{path} is not a valid path",
558
- operationCanceled: "Operation was canceled",
559
- invalidParameter: "Invalid parameter: {parameter}"
560
- },
561
- progress: {
562
- copying: "Copying files...",
563
- building: "Building project...",
564
- packaging: "Creating package...",
565
- validating: "Validating...",
566
- analyzing: "Analyzing...",
567
- restoring: "Restoring dependencies..."
568
- },
569
- validation: {
570
- requiredField: "{field} is required",
571
- invalidValue: "Invalid value for {field}",
572
- pathNotFound: "Path not found: {path}",
573
- fileRequired: "File is required: {path}",
574
- directoryRequired: "Directory is required: {path}"
575
- },
576
- warnings: {
577
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
578
- },
579
- info: {
580
- operationComplete: "Operation completed successfully",
581
- filesProcessed: {
582
- zero: "No files processed",
583
- one: "{count} file processed",
584
- other: "{count} files processed"
585
- }
586
- }
587
- }
588
- };
589
- var pt = {
590
- toolCore: {
591
- errors: {
592
- internal: "Internal error: {message}",
593
- fileNotFound: "File not found: {path}",
594
- fileReadFailed: "Failed to read file: {path}",
595
- fileWriteFailed: "Failed to write file: {path}",
596
- directoryNotFound: "Directory not found: {path}",
597
- invalidPath: "{path} is not a valid path",
598
- operationCanceled: "Operation was canceled",
599
- invalidParameter: "Invalid parameter: {parameter}"
600
- },
601
- progress: {
602
- copying: "Copying files...",
603
- building: "Building project...",
604
- packaging: "Creating package...",
605
- validating: "Validating...",
606
- analyzing: "Analyzing...",
607
- restoring: "Restoring dependencies..."
608
- },
609
- validation: {
610
- requiredField: "{field} is required",
611
- invalidValue: "Invalid value for {field}",
612
- pathNotFound: "Path not found: {path}",
613
- fileRequired: "File is required: {path}",
614
- directoryRequired: "Directory is required: {path}"
615
- },
616
- warnings: {
617
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
618
- },
619
- info: {
620
- operationComplete: "Operation completed successfully",
621
- filesProcessed: {
622
- zero: "No files processed",
623
- one: "{count} file processed",
624
- other: "{count} files processed"
625
- }
626
- }
627
- }
628
- };
629
- var pt_BR = {
630
- toolCore: {
631
- errors: {
632
- internal: "Internal error: {message}",
633
- fileNotFound: "File not found: {path}",
634
- fileReadFailed: "Failed to read file: {path}",
635
- fileWriteFailed: "Failed to write file: {path}",
636
- directoryNotFound: "Directory not found: {path}",
637
- invalidPath: "{path} is not a valid path",
638
- operationCanceled: "Operation was canceled",
639
- invalidParameter: "Invalid parameter: {parameter}"
640
- },
641
- progress: {
642
- copying: "Copying files...",
643
- building: "Building project...",
644
- packaging: "Creating package...",
645
- validating: "Validating...",
646
- analyzing: "Analyzing...",
647
- restoring: "Restoring dependencies..."
648
- },
649
- validation: {
650
- requiredField: "{field} is required",
651
- invalidValue: "Invalid value for {field}",
652
- pathNotFound: "Path not found: {path}",
653
- fileRequired: "File is required: {path}",
654
- directoryRequired: "Directory is required: {path}"
655
- },
656
- warnings: {
657
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
658
- },
659
- info: {
660
- operationComplete: "Operation completed successfully",
661
- filesProcessed: {
662
- zero: "No files processed",
663
- one: "{count} file processed",
664
- other: "{count} files processed"
665
- }
666
- }
667
- }
668
- };
669
- var ro = {
670
- toolCore: {
671
- errors: {
672
- internal: "Internal error: {message}",
673
- fileNotFound: "File not found: {path}",
674
- fileReadFailed: "Failed to read file: {path}",
675
- fileWriteFailed: "Failed to write file: {path}",
676
- directoryNotFound: "Directory not found: {path}",
677
- invalidPath: "{path} is not a valid path",
678
- operationCanceled: "Operation was canceled",
679
- invalidParameter: "Invalid parameter: {parameter}"
680
- },
681
- progress: {
682
- copying: "Copying files...",
683
- building: "Building project...",
684
- packaging: "Creating package...",
685
- validating: "Validating...",
686
- analyzing: "Analyzing...",
687
- restoring: "Restoring dependencies..."
688
- },
689
- validation: {
690
- requiredField: "{field} is required",
691
- invalidValue: "Invalid value for {field}",
692
- pathNotFound: "Path not found: {path}",
693
- fileRequired: "File is required: {path}",
694
- directoryRequired: "Directory is required: {path}"
695
- },
696
- warnings: {
697
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
698
- },
699
- info: {
700
- operationComplete: "Operation completed successfully",
701
- filesProcessed: {
702
- zero: "No files processed",
703
- one: "{count} file processed",
704
- other: "{count} files processed"
705
- }
706
- }
707
- }
708
- };
709
- var ru = {
710
- toolCore: {
711
- errors: {
712
- internal: "Internal error: {message}",
713
- fileNotFound: "File not found: {path}",
714
- fileReadFailed: "Failed to read file: {path}",
715
- fileWriteFailed: "Failed to write file: {path}",
716
- directoryNotFound: "Directory not found: {path}",
717
- invalidPath: "{path} is not a valid path",
718
- operationCanceled: "Operation was canceled",
719
- invalidParameter: "Invalid parameter: {parameter}"
720
- },
721
- progress: {
722
- copying: "Copying files...",
723
- building: "Building project...",
724
- packaging: "Creating package...",
725
- validating: "Validating...",
726
- analyzing: "Analyzing...",
727
- restoring: "Restoring dependencies..."
728
- },
729
- validation: {
730
- requiredField: "{field} is required",
731
- invalidValue: "Invalid value for {field}",
732
- pathNotFound: "Path not found: {path}",
733
- fileRequired: "File is required: {path}",
734
- directoryRequired: "Directory is required: {path}"
735
- },
736
- warnings: {
737
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
738
- },
739
- info: {
740
- operationComplete: "Operation completed successfully",
741
- filesProcessed: {
742
- zero: "No files processed",
743
- one: "{count} file processed",
744
- other: "{count} files processed"
745
- }
746
- }
747
- }
748
- };
749
- var tr = {
750
- toolCore: {
751
- errors: {
752
- internal: "Internal error: {message}",
753
- fileNotFound: "File not found: {path}",
754
- fileReadFailed: "Failed to read file: {path}",
755
- fileWriteFailed: "Failed to write file: {path}",
756
- directoryNotFound: "Directory not found: {path}",
757
- invalidPath: "{path} is not a valid path",
758
- operationCanceled: "Operation was canceled",
759
- invalidParameter: "Invalid parameter: {parameter}"
760
- },
761
- progress: {
762
- copying: "Copying files...",
763
- building: "Building project...",
764
- packaging: "Creating package...",
765
- validating: "Validating...",
766
- analyzing: "Analyzing...",
767
- restoring: "Restoring dependencies..."
768
- },
769
- validation: {
770
- requiredField: "{field} is required",
771
- invalidValue: "Invalid value for {field}",
772
- pathNotFound: "Path not found: {path}",
773
- fileRequired: "File is required: {path}",
774
- directoryRequired: "Directory is required: {path}"
775
- },
776
- warnings: {
777
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
778
- },
779
- info: {
780
- operationComplete: "Operation completed successfully",
781
- filesProcessed: {
782
- zero: "No files processed",
783
- one: "{count} file processed",
784
- other: "{count} files processed"
785
- }
786
- }
787
- }
788
- };
789
- var zh_CN = {
790
- toolCore: {
791
- errors: {
792
- internal: "Internal error: {message}",
793
- fileNotFound: "File not found: {path}",
794
- fileReadFailed: "Failed to read file: {path}",
795
- fileWriteFailed: "Failed to write file: {path}",
796
- directoryNotFound: "Directory not found: {path}",
797
- invalidPath: "{path} is not a valid path",
798
- operationCanceled: "Operation was canceled",
799
- invalidParameter: "Invalid parameter: {parameter}"
800
- },
801
- progress: {
802
- copying: "Copying files...",
803
- building: "Building project...",
804
- packaging: "Creating package...",
805
- validating: "Validating...",
806
- analyzing: "Analyzing...",
807
- restoring: "Restoring dependencies..."
808
- },
809
- validation: {
810
- requiredField: "{field} is required",
811
- invalidValue: "Invalid value for {field}",
812
- pathNotFound: "Path not found: {path}",
813
- fileRequired: "File is required: {path}",
814
- directoryRequired: "Directory is required: {path}"
815
- },
816
- warnings: {
817
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
818
- },
819
- info: {
820
- operationComplete: "Operation completed successfully",
821
- filesProcessed: {
822
- zero: "No files processed",
823
- one: "{count} file processed",
824
- other: "{count} files processed"
825
- }
826
- }
827
- }
828
- };
829
- var zh_TW = {
830
- toolCore: {
831
- errors: {
832
- internal: "Internal error: {message}",
833
- fileNotFound: "File not found: {path}",
834
- fileReadFailed: "Failed to read file: {path}",
835
- fileWriteFailed: "Failed to write file: {path}",
836
- directoryNotFound: "Directory not found: {path}",
837
- invalidPath: "{path} is not a valid path",
838
- operationCanceled: "Operation was canceled",
839
- invalidParameter: "Invalid parameter: {parameter}"
840
- },
841
- progress: {
842
- copying: "Copying files...",
843
- building: "Building project...",
844
- packaging: "Creating package...",
845
- validating: "Validating...",
846
- analyzing: "Analyzing...",
847
- restoring: "Restoring dependencies..."
848
- },
849
- validation: {
850
- requiredField: "{field} is required",
851
- invalidValue: "Invalid value for {field}",
852
- pathNotFound: "Path not found: {path}",
853
- fileRequired: "File is required: {path}",
854
- directoryRequired: "Directory is required: {path}"
855
- },
856
- warnings: {
857
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
858
- },
859
- info: {
860
- operationComplete: "Operation completed successfully",
861
- filesProcessed: {
862
- zero: "No files processed",
863
- one: "{count} file processed",
864
- other: "{count} files processed"
865
- }
866
- }
867
- }
868
- };
869
- var zu = {
870
- toolCore: {
871
- errors: {
872
- internal: "Internal error: {message}",
873
- fileNotFound: "File not found: {path}",
874
- fileReadFailed: "Failed to read file: {path}",
875
- fileWriteFailed: "Failed to write file: {path}",
876
- directoryNotFound: "Directory not found: {path}",
877
- invalidPath: "{path} is not a valid path",
878
- operationCanceled: "Operation was canceled",
879
- invalidParameter: "Invalid parameter: {parameter}"
880
- },
881
- progress: {
882
- copying: "Copying files...",
883
- building: "Building project...",
884
- packaging: "Creating package...",
885
- validating: "Validating...",
886
- analyzing: "Analyzing...",
887
- restoring: "Restoring dependencies..."
888
- },
889
- validation: {
890
- requiredField: "{field} is required",
891
- invalidValue: "Invalid value for {field}",
892
- pathNotFound: "Path not found: {path}",
893
- fileRequired: "File is required: {path}",
894
- directoryRequired: "Directory is required: {path}"
895
- },
896
- warnings: {
897
- factoryAlreadyRegistered: "A factory is already registered for project type '{type}'. Skipping duplicate registration."
898
- },
899
- info: {
900
- operationComplete: "Operation completed successfully",
901
- filesProcessed: {
902
- zero: "No files processed",
903
- one: "{count} file processed",
904
- other: "{count} files processed"
905
- }
906
- }
907
- }
908
- };
909
-
910
- class TranslationService {
911
- static instance;
912
- currentLocale = "en";
913
- constructor() {}
914
- static getInstance() {
915
- if (!TranslationService.instance) {
916
- TranslationService.instance = new TranslationService;
917
- }
918
- return TranslationService.instance;
919
- }
920
- setLocale(locale) {
921
- this.currentLocale = I18nManager.setLocale(locale);
922
- }
923
- getLocale() {
924
- return this.currentLocale;
925
- }
926
- t(key, params) {
927
- return I18nManager.t(key, params, this.currentLocale);
928
- }
929
- tLocale(key, locale, params) {
930
- return I18nManager.t(key, params, locale);
931
- }
932
- has(key) {
933
- return I18nManager.has(key, this.currentLocale);
934
- }
935
- getAvailableLocales() {
936
- return I18nManager.getAvailableLocales();
937
- }
938
- }
939
- var translate = TranslationService.getInstance();
940
- I18nManager.registerTranslations("en", en);
941
- I18nManager.registerTranslations("de", de);
942
- I18nManager.registerTranslations("es", es);
943
- I18nManager.registerTranslations("es-mx", es_MX);
944
- I18nManager.registerTranslations("fr", fr);
945
- I18nManager.registerTranslations("ja", ja);
946
- I18nManager.registerTranslations("ko", ko);
947
- I18nManager.registerTranslations("pt", pt);
948
- I18nManager.registerTranslations("pt-br", pt_BR);
949
- I18nManager.registerTranslations("ro", ro);
950
- I18nManager.registerTranslations("ru", ru);
951
- I18nManager.registerTranslations("tr", tr);
952
- I18nManager.registerTranslations("zh-cn", zh_CN);
953
- I18nManager.registerTranslations("zh-tw", zh_TW);
954
- I18nManager.registerTranslations("zu", zu);
955
- I18nManager.setLocale("en");
956
- var BuildConfiguration;
957
- ((BuildConfiguration2) => {
958
- BuildConfiguration2["Debug"] = "Debug";
959
- BuildConfiguration2["Release"] = "Release";
960
- })(BuildConfiguration ||= {});
961
- var LogLevel;
962
- ((LogLevel2) => {
963
- LogLevel2["Debug"] = "Debug";
964
- LogLevel2["Info"] = "Information";
965
- LogLevel2["Warn"] = "Warning";
966
- LogLevel2["Error"] = "Error";
967
- })(LogLevel ||= {});
968
-
969
- class LogMessage {
970
- message;
971
- logLevel;
972
- source;
973
- sourceTarget;
974
- progress;
975
- code;
976
- filePath;
977
- line;
978
- id;
979
- timestamp;
980
- constructor(message, logLevel, options, timestamp) {
981
- this.message = message;
982
- this.logLevel = LogMessage.toLogLevel(logLevel);
983
- this.source = options?.source;
984
- this.sourceTarget = options?.sourceTarget;
985
- this.progress = options?.progress;
986
- this.code = options?.code;
987
- this.filePath = options?.filePath;
988
- this.line = options?.line;
989
- this.id = options?.id;
990
- this.timestamp = LogMessage.resolveTimestamp(timestamp);
991
- }
992
- static resolveTimestamp(timestamp) {
993
- if (timestamp instanceof Date) {
994
- return timestamp;
995
- }
996
- if (timestamp === undefined || timestamp === null) {
997
- return new Date;
998
- }
999
- const parsed = new Date(timestamp);
1000
- if (Number.isNaN(parsed.getTime())) {
1001
- console.error(`[LogMessage] invalid timestamp "${timestamp}", defaulting to now`);
1002
- return new Date;
1003
- }
1004
- return parsed;
1005
- }
1006
- static toLogLevel(level) {
1007
- switch (level) {
1008
- case "Verbose":
1009
- case "Trace":
1010
- case "Debug":
1011
- return "Debug";
1012
- case "Warn":
1013
- case "Warning":
1014
- return "Warning";
1015
- case "Error":
1016
- case "Critical":
1017
- return "Error";
1018
- default:
1019
- return "Information";
1020
- }
1021
- }
1022
- toFormattedString() {
1023
- const parts = [];
1024
- parts.push(`[${this.timestamp.toISOString()}]`);
1025
- parts.push(`[${String(this.logLevel).toUpperCase()}]`);
1026
- if (this.source) {
1027
- parts.push(`[${this.source}]`);
1028
- }
1029
- if (this.sourceTarget) {
1030
- parts.push(`[${this.sourceTarget}]`);
1031
- }
1032
- const locationParts = [];
1033
- if (this.filePath) {
1034
- locationParts.push(this.filePath);
1035
- }
1036
- if (this.line) {
1037
- locationParts.push(`Line:${this.line}`);
1038
- }
1039
- if (this.id) {
1040
- locationParts.push(`Id:${this.id}`);
1041
- }
1042
- if (locationParts.length > 0) {
1043
- parts.push(`(${locationParts.join("")})`);
1044
- }
1045
- if (this.code) {
1046
- parts.push(`[${this.code}]`);
1047
- }
1048
- if (this.progress || this.progress === 0) {
1049
- parts.push(`${this.progress}%`);
1050
- }
1051
- parts.push(this.message);
1052
- return parts.join(" ");
1053
- }
1054
- }
1055
- var NugetConstants = {
1056
- OutputFolderName: "bundle",
1057
- ContentFolderName: "content",
1058
- OperateFileName: "operate.json",
1059
- EntryPointsFileName: "entry-points.json",
1060
- PackageDescriptorFileName: "package-descriptor.json",
1061
- BindingsV2FileName: "bindings_v2.json",
1062
- BindingsFileId: "bindings.json"
1063
- };
1064
- var PackJobTargetKind;
1065
- ((PackJobTargetKind2) => {
1066
- PackJobTargetKind2["Serverless"] = "Serverless";
1067
- PackJobTargetKind2["LocalRobot"] = "LocalRobot";
1068
- })(PackJobTargetKind ||= {});
1069
- var ProjectTypes;
1070
- ((ProjectTypes2) => {
1071
- ProjectTypes2["Agent"] = "Agent";
1072
- ProjectTypes2["Api"] = "Api";
1073
- ProjectTypes2["BusinessRules"] = "BusinessRules";
1074
- ProjectTypes2["Connector"] = "Connector";
1075
- ProjectTypes2["CaseManagement"] = "CaseManagement";
1076
- ProjectTypes2["Flow"] = "Flow";
1077
- ProjectTypes2["Function"] = "Function";
1078
- ProjectTypes2["ProcessOrchestration"] = "ProcessOrchestration";
1079
- ProjectTypes2["Process"] = "Process";
1080
- ProjectTypes2["Library"] = "Library";
1081
- ProjectTypes2["WebApp"] = "WebApp";
1082
- ProjectTypes2["Tests"] = "Tests";
1083
- ProjectTypes2["AppV2"] = "AppV2";
1084
- })(ProjectTypes ||= {});
1085
- var TargetFramework;
1086
- ((TargetFramework2) => {
1087
- TargetFramework2["Portable"] = "Portable";
1088
- TargetFramework2["Windows"] = "Windows";
1089
- })(TargetFramework ||= {});
1090
- var ToolErrorCodes;
1091
- ((ToolErrorCodes2) => {
1092
- ToolErrorCodes2["Success"] = "SUCCESS";
1093
- ToolErrorCodes2["InternalError"] = "INTERNAL_ERROR";
1094
- ToolErrorCodes2["Canceled"] = "CANCELED";
1095
- })(ToolErrorCodes ||= {});
1096
-
1097
- class ToolResult {
1098
- errorCode;
1099
- message;
1100
- packages;
1101
- details;
1102
- instructions;
1103
- constructor(errorCode, message, packages = [], instructions) {
1104
- this.errorCode = errorCode;
1105
- this.message = message;
1106
- this.packages = packages;
1107
- this.instructions = instructions;
1108
- }
1109
- get isSuccess() {
1110
- return this.errorCode === "SUCCESS";
1111
- }
1112
- static success() {
1113
- return new ToolResult("SUCCESS");
1114
- }
1115
- static error(errorCode, message, instructions) {
1116
- return new ToolResult(errorCode, message, [], instructions);
1117
- }
1118
- }
1119
- var OPERATE_FILE = "operate.json";
1120
- var PROJECT_FILE = "project.json";
1121
- function isNonEmptyString(value) {
1122
- return typeof value === "string" && value.length > 0;
1123
- }
1124
- async function readJsonObject(fs, filePath) {
1125
- let content;
1126
- try {
1127
- content = await fs.readFile(filePath, "utf-8");
1128
- } catch {
1129
- return;
1130
- }
1131
- if (content === null) {
1132
- return;
1133
- }
1134
- try {
1135
- const parsed = JSON.parse(content);
1136
- if (parsed === null || typeof parsed !== "object") {
1137
- return;
1138
- }
1139
- return parsed;
1140
- } catch {
1141
- return;
1142
- }
1143
- }
1144
- async function writeJsonObject(fs, filePath, data) {
1145
- await fs.writeFile(filePath, `${JSON.stringify(data, null, 2)}
1146
- `);
1147
- }
1148
- async function ensureProjectId(projectPath, fs) {
1149
- const operatePath = Path.join(projectPath, OPERATE_FILE);
1150
- const operateExists = await fs.exists(operatePath);
1151
- if (operateExists) {
1152
- const operate = await readJsonObject(fs, operatePath);
1153
- if (operate && isNonEmptyString(operate.projectId)) {
1154
- return operate.projectId;
1155
- }
1156
- if (operate) {
1157
- const id = crypto.randomUUID();
1158
- await writeJsonObject(fs, operatePath, {
1159
- ...operate,
1160
- projectId: id
1161
- });
1162
- return id;
1163
- }
1164
- return crypto.randomUUID();
1165
- }
1166
- const projectFilePath = Path.join(projectPath, PROJECT_FILE);
1167
- const projectFileExists = await fs.exists(projectFilePath);
1168
- if (projectFileExists) {
1169
- const projectFile = await readJsonObject(fs, projectFilePath);
1170
- if (projectFile && isNonEmptyString(projectFile.projectId)) {
1171
- return projectFile.projectId;
1172
- }
1173
- if (projectFile) {
1174
- const id = crypto.randomUUID();
1175
- await writeJsonObject(fs, projectFilePath, {
1176
- ...projectFile,
1177
- projectId: id
1178
- });
1179
- return id;
1180
- }
1181
- return crypto.randomUUID();
1182
- }
1183
- return crypto.randomUUID();
1184
- }
1185
- async function ensureProjectIdInOperateFile(operateFilePath, fallbackProjectId, fs) {
1186
- if (!await fs.exists(operateFilePath)) {
1187
- return;
1188
- }
1189
- const parsed = await readJsonObject(fs, operateFilePath);
1190
- if (!parsed) {
1191
- return;
1192
- }
1193
- if (isNonEmptyString(parsed.projectId)) {
1194
- return;
1195
- }
1196
- await writeJsonObject(fs, operateFilePath, {
1197
- ...parsed,
1198
- projectId: fallbackProjectId
1199
- });
1200
- }
1201
- async function writeOrBackfillOperateProjectId(operateFilePath, projectId, fs, createIfMissing) {
1202
- if (await fs.exists(operateFilePath)) {
1203
- await ensureProjectIdInOperateFile(operateFilePath, projectId, fs);
1204
- return;
1205
- }
1206
- await createIfMissing();
1207
- }
1208
- function escapeXml(str) {
1209
- if (str === null || str === undefined) {
1210
- return "";
1211
- }
1212
- return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
1213
- }
1214
- function optionalElement(name, value) {
1215
- if (value === undefined || value === "")
1216
- return "";
1217
- return ` <${name}>${escapeXml(value)}</${name}>
1218
- `;
1219
- }
1220
- function generateDependenciesXml(dependencies) {
1221
- if (!dependencies || dependencies.length === 0)
1222
- return "";
1223
- const deps = dependencies.map((d) => ` <dependency id="${escapeXml(d.id)}" version="${escapeXml(d.version)}" />`).join(`
1224
- `);
1225
- return ` <dependencies>
1226
- ${deps}
1227
- </dependencies>
1228
- `;
1229
- }
1230
- function generateRepositoryXml(packageInfo) {
1231
- if (!packageInfo.repositoryType || !packageInfo.repositoryUrl)
1232
- return "";
1233
- let repoXml = ` <repository type="${escapeXml(packageInfo.repositoryType)}" url="${escapeXml(packageInfo.repositoryUrl)}"`;
1234
- if (packageInfo.repositoryBranch) {
1235
- repoXml += ` branch="${escapeXml(packageInfo.repositoryBranch)}"`;
1236
- }
1237
- if (packageInfo.repositoryCommit) {
1238
- repoXml += ` commit="${escapeXml(packageInfo.repositoryCommit)}"`;
1239
- }
1240
- repoXml += ` />
1241
- `;
1242
- return repoXml;
1243
- }
1244
- function generateNuspecXml(packageInfo) {
1245
- const author = packageInfo.author?.trim() || "UiPath";
1246
- const description = packageInfo.description?.trim() || "Created by UiPath";
1247
- const title = packageInfo.title?.trim() || packageInfo.id;
1248
- const requireLicenseAcceptance = packageInfo.requireLicenseAcceptance === true ? "true" : "false";
1249
- const releaseNotes = packageInfo.releaseNotes ?? "";
1250
- const xml = `\uFEFF<?xml version="1.0" encoding="utf-8"?>
1251
- <package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
1252
- <metadata>
1253
- <id>${escapeXml(packageInfo.id)}</id>
1254
- <version>${escapeXml(packageInfo.version)}</version>
1255
- <title>${escapeXml(title)}</title>
1256
- <authors>${escapeXml(author)}</authors>
1257
- <requireLicenseAcceptance>${requireLicenseAcceptance}</requireLicenseAcceptance>
1258
- <description>${escapeXml(description)}</description>
1259
- <releaseNotes>${escapeXml(releaseNotes)}</releaseNotes>
1260
- ${optionalElement("tags", packageInfo.tags)}${optionalElement("iconUrl", packageInfo.iconUrl)}${optionalElement("projectUrl", packageInfo.projectUrl)}${optionalElement("licenseUrl", packageInfo.licenseUrl)}${optionalElement("copyright", packageInfo.copyright)}${generateRepositoryXml(packageInfo)}${generateDependenciesXml(packageInfo.dependencies)} </metadata>
1261
- </package>
1262
- `;
1263
- return xml;
1264
- }
1265
- function generatePsmdcpXml(packageInfo) {
1266
- const author = packageInfo.author?.trim() || "UiPath";
1267
- const description = packageInfo.description?.trim() || "Created by UiPath";
1268
- return `<?xml version="1.0" encoding="utf-8"?>
1269
- <coreProperties xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.openxmlformats.org/package/2006/metadata/core-properties">
1270
- <dc:creator>${escapeXml(author)}</dc:creator>
1271
- <dc:description>${escapeXml(description)}</dc:description>
1272
- <dc:identifier>${escapeXml(packageInfo.id)}</dc:identifier>
1273
- <version>${escapeXml(packageInfo.version)}</version>
1274
- <keywords></keywords>
1275
- <lastModifiedBy>NuGet.Packaging, Version=6.12.1.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35;.NET 5.0</lastModifiedBy>
1276
- </coreProperties>`;
1277
- }
1278
-
1279
- class NugetPackager {
1280
- fileSystem;
1281
- constructor(fileSystem) {
1282
- this.fileSystem = fileSystem;
1283
- }
1284
- async packAsync(rootPath, packageInfo, outputPath) {
1285
- const normalizedOutputPath = Path.normalize(outputPath);
1286
- const nuspecXml = generateNuspecXml(packageInfo);
1287
- const nuspecFileName = `${packageInfo.id}.nuspec`;
1288
- const fileEntries = await Path.walkDirectory(this.fileSystem, rootPath);
1289
- const zipContents = {};
1290
- const encoder = new TextEncoder;
1291
- const psmdcpId = Array.from({ length: 4 }, () => Math.floor(Math.random() * 4294967296).toString(16).padStart(8, "0")).join("");
1292
- const psmdcpFileName = `${psmdcpId}.psmdcp`;
1293
- const psmdcpPath = `package/services/metadata/core-properties/${psmdcpFileName}`;
1294
- const contentTypesXml = `<?xml version="1.0" encoding="utf-8"?>
1295
- <Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
1296
- <Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
1297
- <Default Extension="psmdcp" ContentType="application/vnd.openxmlformats-package.core-properties+xml" />
1298
- <Default Extension="uiproj" ContentType="application/octet" />
1299
- <Default Extension="json" ContentType="application/octet" />
1300
- <Default Extension="nuspec" ContentType="application/octet" />
1301
- </Types>`;
1302
- zipContents["[Content_Types].xml"] = encoder.encode(contentTypesXml);
1303
- const manifestRelId = `R${Date.now().toString(16).toUpperCase()}`;
1304
- const corePropsRelId = `R${(Date.now() + 1).toString(16).toUpperCase()}`;
1305
- const relsXml = `<?xml version="1.0" encoding="utf-8"?>
1306
- <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
1307
- <Relationship Type="http://schemas.microsoft.com/packaging/2010/07/manifest" Target="/${nuspecFileName}" Id="${manifestRelId}" />
1308
- <Relationship Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="/${psmdcpPath}" Id="${corePropsRelId}" />
1309
- </Relationships>`;
1310
- zipContents["_rels/.rels"] = encoder.encode(relsXml);
1311
- zipContents[psmdcpPath] = encoder.encode(generatePsmdcpXml(packageInfo));
1312
- zipContents[nuspecFileName] = encoder.encode(nuspecXml);
1313
- for (const entry of fileEntries) {
1314
- const content = await this.fileSystem.readFile(entry.absolutePath);
1315
- if (content !== null) {
1316
- zipContents[entry.relativePath] = content;
1317
- }
1318
- }
1319
- const zippedData = zipSync(zipContents);
1320
- await this.fileSystem.writeFile(normalizedOutputPath, zippedData);
1321
- return {
1322
- outputPath: normalizedOutputPath
1323
- };
1324
- }
1325
- }
1326
-
1327
- class ProjectTool {
1328
- fileSystem;
1329
- logger;
1330
- static ProjectFileName = "project.uiproj";
1331
- constructor(fileSystem, logger) {
1332
- this.fileSystem = fileSystem;
1333
- this.logger = logger;
1334
- }
1335
- async restoreAsync(_options, _cancellationToken) {
1336
- this.logger.info("Restore operation is a noop");
1337
- return ToolResult.success();
1338
- }
1339
- async validateAsync(_options, _cancellationToken) {
1340
- this.logger.info("Validate operation is a noop");
1341
- return ToolResult.success();
1342
- }
1343
- async buildAsync(_options, _cancellationToken) {
1344
- this.logger.info("Build operation is a noop");
1345
- return ToolResult.success();
1346
- }
1347
- async packAsync(_options, _cancellationToken) {
1348
- this.logger.info("Pack operation is a noop");
1349
- return ToolResult.success();
1350
- }
1351
- async cleanupAsync(_options, _cancellationToken) {
1352
- this.logger.info("Cleanup operation is a noop");
1353
- return ToolResult.success();
1354
- }
1355
- async getUiProjectAsync(projectPath) {
1356
- const filePath = Path.join(projectPath, ProjectTool.ProjectFileName);
1357
- if (!await this.fileSystem.exists(filePath)) {
1358
- return;
1359
- }
1360
- const raw = await this.fileSystem.readFile(filePath);
1361
- if (!raw) {
1362
- return;
1363
- }
1364
- const json = typeof raw === "string" ? raw : new TextDecoder("utf-8").decode(raw);
1365
- return JSON.parse(json);
1366
- }
1367
- async dispose() {}
1368
- }
1369
-
1370
- class SolutionTool {
1371
- fileSystem;
1372
- logger;
1373
- constructor(fileSystem, logger) {
1374
- this.fileSystem = fileSystem;
1375
- this.logger = logger;
1376
- }
1377
- async restoreAsync(_options, _cancellationToken) {
1378
- this.logger.info("Restore operation is a noop");
1379
- return ToolResult.success();
1380
- }
1381
- async validateAsync(_options, _cancellationToken) {
1382
- this.logger.info("Validate operation is a noop");
1383
- return ToolResult.success();
1384
- }
1385
- async buildAsync(_options, _cancellationToken) {
1386
- this.logger.info("Build operation is a noop");
1387
- return ToolResult.success();
1388
- }
1389
- async packAsync(_options, _cancellationToken) {
1390
- this.logger.info("Pack operation is a noop");
1391
- return ToolResult.success();
1392
- }
1393
- dispose() {}
1394
- }
1395
-
1396
- class ToolsFactoryRepository {
1397
- projectFactoryMap = new Map;
1398
- solutionFactory = null;
1399
- registerProjectToolFactory(factory) {
1400
- for (const type of factory.supportedTypes) {
1401
- const existing = this.projectFactoryMap.get(type);
1402
- if (existing) {
1403
- if (existing.constructor?.name !== factory.constructor?.name) {
1404
- console.warn(`Tool factory conflict for project type '${type}': ` + `'${existing.constructor?.name}' already registered, ` + `ignoring '${factory.constructor?.name}'.`);
1405
- }
1406
- continue;
1407
- }
1408
- this.projectFactoryMap.set(type, factory);
1409
- }
1410
- }
1411
- registerSolutionToolFactory(factory) {
1412
- this.solutionFactory = factory;
1413
- }
1414
- getSolutionToolFactory() {
1415
- if (!this.solutionFactory) {
1416
- throw new Error("No solution tool factory is registered");
1417
- }
1418
- return this.solutionFactory;
1419
- }
1420
- canHandleProject(projectType) {
1421
- return this.projectFactoryMap.has(projectType);
1422
- }
1423
- getProjectToolFactory(projectType) {
1424
- const factory = this.projectFactoryMap.get(projectType);
1425
- if (!factory) {
1426
- throw new Error(`Cannot pack project type '${projectType}': no packager is installed for it.`);
1427
- }
1428
- return factory;
1429
- }
1430
- reset() {
1431
- this.projectFactoryMap.clear();
1432
- this.solutionFactory = null;
1433
- }
1434
- }
1435
- var REGISTRY_KEY = Symbol.for("@uipath/solutionpackager-tool-core/toolsFactoryRepository");
1436
- var _global = globalThis;
1437
- if (!_global[REGISTRY_KEY]) {
1438
- _global[REGISTRY_KEY] = new ToolsFactoryRepository;
1439
- }
1440
- var toolsFactoryRepository2 = _global[REGISTRY_KEY];
1441
-
1442
- // ../packager/packager-tool-connector/src/connector-tool.ts
1443
- class ConnectorTool extends ProjectTool {
1444
- static AppFolderName = "app";
1445
- _temporaryStorage;
1446
- constructor(fileSystem, logger) {
1447
- super(fileSystem, logger);
1448
- this._temporaryStorage = new TemporaryStorageService(fileSystem);
1449
- }
1450
- async restoreAsync(_options, _cancellationToken) {
1451
- this.logger.info("Restore operation is not required for Connector projects");
1452
- return ToolResult.success();
1453
- }
1454
- async validateAsync(_options, _cancellationToken) {
1455
- this.logger.info("Validate operation is not required for Connector projects");
1456
- return ToolResult.success();
1457
- }
1458
- async buildAsync(options, _cancellationToken) {
1459
- const tempFolder = await this._temporaryStorage.getTempFolderPath();
1460
- const localBuildFolder = Path.join(tempFolder, NugetConstants.OutputFolderName);
1461
- const appProjectFolder = Path.join(options.projectPath, ConnectorTool.AppFolderName);
1462
- const destinationFolder = Path.join(localBuildFolder, NugetConstants.ContentFolderName, ConnectorTool.AppFolderName);
1463
- try {
1464
- this.logger.progress("Copying app folder...");
1465
- await this.copyDirectory(appProjectFolder, destinationFolder);
1466
- this.logger.progress("Creating operate.json file...");
1467
- await this.createOperateFile(options, localBuildFolder);
1468
- this.logger.progress("Creating package-descriptor.json file...");
1469
- await this.createPackageDescriptor(localBuildFolder);
1470
- return new ToolResult(ToolErrorCodes.Success, "done", [
1471
- localBuildFolder
1472
- ]);
1473
- } catch (error) {
1474
- const errorMessage = error instanceof Error ? error.toString() : String(error);
1475
- this.logger.error(errorMessage);
1476
- return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while building Connector project");
1477
- }
1478
- }
1479
- async packAsync(options, cancellationToken) {
1480
- const buildResult = await this.buildAsync(options, cancellationToken);
1481
- if (!buildResult.isSuccess) {
1482
- return buildResult;
1483
- }
1484
- const localBuildFolder = buildResult.packages[0];
1485
- try {
1486
- this.logger.progress("Creating NuGet package...");
1487
- const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
1488
- const nupkgPath = Path.join(options.outputPath, nupkgFileName);
1489
- const packager = new NugetPackager(this.fileSystem);
1490
- const result = await packager.packAsync(localBuildFolder, options.package, nupkgPath);
1491
- this.logger.progress("Package created successfully");
1492
- return new ToolResult(ToolErrorCodes.Success, "done", [
1493
- result.outputPath
1494
- ]);
1495
- } catch (error) {
1496
- const errorMessage = error instanceof Error ? error.toString() : String(error);
1497
- this.logger.error(errorMessage);
1498
- return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while packing Connector project");
1499
- }
1500
- }
1501
- async dispose() {
1502
- this.logger.info("Disposing Connector Tool");
1503
- try {
1504
- await this._temporaryStorage.cleanup();
1505
- } catch {}
1506
- }
1507
- async createOperateFile(options, localBuildFolder) {
1508
- const contentFolder = Path.join(localBuildFolder, NugetConstants.ContentFolderName);
1509
- const operateJsonFilePath = Path.join(contentFolder, NugetConstants.OperateFileName);
1510
- const projectId = options.projectStorageId ?? await this.resolveConnectorProjectId(options.projectPath);
1511
- await writeOrBackfillOperateProjectId(operateJsonFilePath, projectId, this.fileSystem, () => this.fileSystem.writeFile(operateJsonFilePath, JSON.stringify({
1512
- $schema: "https://cloud.uipath.com/draft/2024-12/operate",
1513
- contentType: ProjectTypes.Connector,
1514
- projectId,
1515
- main: "",
1516
- targetFramework: "Portable",
1517
- runtimeOptions: {
1518
- isAttended: false,
1519
- requiresUserInteraction: false
1520
- }
1521
- }, null, 2)));
1522
- }
1523
- async resolveConnectorProjectId(projectPath) {
1524
- const operatePath = Path.join(projectPath, "operate.json");
1525
- const projectFilePath = Path.join(projectPath, "project.json");
1526
- const hasAnchor = await this.fileSystem.exists(operatePath) || await this.fileSystem.exists(projectFilePath);
1527
- if (hasAnchor) {
1528
- return ensureProjectId(projectPath, this.fileSystem);
1529
- }
1530
- const id = crypto.randomUUID();
1531
- await this.fileSystem.writeFile(projectFilePath, `${JSON.stringify({ projectId: id }, null, 2)}
1532
- `);
1533
- return id;
1534
- }
1535
- async createPackageDescriptor(localBuildFolder) {
1536
- const packageDescriptorPath = Path.join(localBuildFolder, NugetConstants.ContentFolderName, NugetConstants.PackageDescriptorFileName);
1537
- const exists = await this.fileSystem.exists(packageDescriptorPath);
1538
- if (exists) {
1539
- return;
1540
- }
1541
- const descriptor = {
1542
- $schema: "https://cloud.uipath.com/draft/2024-12/package-descriptor",
1543
- files: {
1544
- [NugetConstants.OperateFileName]: Path.join(NugetConstants.ContentFolderName, NugetConstants.OperateFileName)
1545
- }
1546
- };
1547
- await this.fileSystem.writeFile(packageDescriptorPath, JSON.stringify(descriptor, null, 2));
1548
- }
1549
- async copyDirectory(sourcePath, destinationPath) {
1550
- await this.fileSystem.mkdir(destinationPath);
1551
- const entries = await this.fileSystem.readdir(sourcePath);
1552
- for (const entry of entries) {
1553
- const sourceEntry = Path.join(sourcePath, entry);
1554
- const destinationEntry = Path.join(destinationPath, entry);
1555
- const stat = await this.fileSystem.stat(sourceEntry);
1556
- if (stat?.isDirectory()) {
1557
- await this.copyDirectory(sourceEntry, destinationEntry);
1558
- } else if (stat?.isFile()) {
1559
- const content = await this.fileSystem.readFile(sourceEntry);
1560
- if (content) {
1561
- await this.fileSystem.writeFile(destinationEntry, content);
1562
- }
1563
- }
1564
- }
1565
- }
1566
- }
1567
-
1568
- // ../packager/packager-tool-connector/src/connector-tool-factory.ts
1569
- class ConnectorToolFactory {
1570
- supportedTypes = [ProjectTypes.Connector];
1571
- async createAsync(logger, fileSystem) {
1572
- return new ConnectorTool(fileSystem, logger);
1573
- }
1574
- }
1575
- // ../../node_modules/@uipath/resource-builder-tool/dist/index.js
1576
- function _define_property(obj, key, value) {
1577
- if (key in obj)
1578
- Object.defineProperty(obj, key, {
1579
- value,
1580
- enumerable: true,
1581
- configurable: true,
1582
- writable: true
1583
- });
1584
- else
1585
- obj[key] = value;
1586
- return obj;
1587
- }
1588
- var KNOWN_ARCHIVE_FILE_NAMES = {
1589
- packageInfoJsonFileName: "packageInfo.json",
1590
- metadataJsonFileName: "solutionMetadata.json"
1591
- };
1592
- var KNOWN_ARCHIVE_FOLDERS = {
1593
- files: "files",
1594
- resources: "resources"
1595
- };
1596
- var PACKAGE_DEFAULTS = {
1597
- currentVersion: "v1",
1598
- defaultPackageVersion: "1.0.0",
1599
- defaultAuthorName: "UiPath",
1600
- unifiedBuildPackageType: "unified",
1601
- currentDocVersion: "1.0.0",
1602
- rootFolderName: "solution_folder"
1603
- };
1604
- var JWT_CLAIMS = {
1605
- firstName: "first_name",
1606
- lastName: "last_name",
1607
- email: "email",
1608
- userId: "sub",
1609
- partition: "prt_id"
1610
- };
1611
- var RESILIENCE_DEFAULTS = {
1612
- maxRetryAttempts: 3,
1613
- retryIntervalMs: 1000,
1614
- maxRedirectRetries: 10
1615
- };
1616
- var MAX_DOWNLOAD_CONCURRENCY = 8;
1617
- var RETRIABLE_STATUS_CODES = [
1618
- 500,
1619
- 502,
1620
- 503,
1621
- 504
1622
- ];
1623
- var INVALID_FILE_NAME_CHARS = /[<>:"/\\|?*\x00-\x1f\s]/g;
1624
- var MAX_SERVER_MESSAGE_LENGTH = 100;
1625
- var MAX_BUILD_OUTPUT_SIZE_BYTES = 524288000;
1626
-
1627
- class OperationCancelledException extends Error {
1628
- constructor(message) {
1629
- super(message ?? "The operation was cancelled");
1630
- this.name = "OperationCancelledException";
1631
- if (Error.captureStackTrace)
1632
- Error.captureStackTrace(this, OperationCancelledException);
1633
- }
1634
- }
1635
- function mapHttpStatusCodeToReason(status) {
1636
- switch (status) {
1637
- case 404:
1638
- return "NotFound";
1639
- case 401:
1640
- return "Unauthorized";
1641
- case 403:
1642
- return "Forbidden";
1643
- case 400:
1644
- return "BadRequest";
1645
- case 408:
1646
- case 504:
1647
- return "Timeout";
1648
- default:
1649
- if (status >= 500)
1650
- return "ServerError";
1651
- return "Unknown";
1652
- }
1653
- }
1654
- function truncateMessage(message, maxLength) {
1655
- if (!message)
1656
- return message;
1657
- if (message.length <= maxLength)
1658
- return message;
1659
- return message.substring(0, maxLength) + "...";
1660
- }
1661
- function buildFailureMessage(failures) {
1662
- const lines = [
1663
- `Failed to download ${failures.length} file(s):`
1664
- ];
1665
- for (const failure of failures)
1666
- lines.push(` - FileKey: ${failure.fileKey}, Service: ${failure.service}, Url: ${failure.externalUrl}, Reason: ${failure.reason}, Message: ${failure.errorMessage ?? ""}`);
1667
- return lines.join(`
1668
- `);
1669
- }
1670
- function isArtefactResource(resource) {
1671
- return resource.projectKey != null && resource.projectKey.trim() !== "";
1672
- }
1673
- var JSON_INDENT = 2;
1674
- function shouldExcludeValue(value) {
1675
- if (value == null)
1676
- return true;
1677
- if (value === false)
1678
- return true;
1679
- if (value === 0)
1680
- return true;
1681
- if (value === "")
1682
- return true;
1683
- if (Array.isArray(value) && value.length === 0)
1684
- return true;
1685
- return false;
1686
- }
1687
- function serializeJson(obj) {
1688
- return JSON.stringify(obj, (_key, value) => shouldExcludeValue(value) ? undefined : value, JSON_INDENT);
1689
- }
1690
- function decodeJwtPayload(token) {
1691
- try {
1692
- const parts = token.split(".");
1693
- if (parts.length !== 3)
1694
- return null;
1695
- const payload = parts[1];
1696
- const base64 = payload.replace(/-/g, "+").replace(/_/g, "/");
1697
- const padded = base64 + "=".repeat((4 - base64.length % 4) % 4);
1698
- const decoded = atob(padded);
1699
- return JSON.parse(decoded);
1700
- } catch {
1701
- return null;
1702
- }
1703
- }
1704
- function extractDataFromAccessToken(accessToken) {
1705
- if (!accessToken)
1706
- return {};
1707
- const payload = decodeJwtPayload(accessToken);
1708
- if (!payload)
1709
- return {};
1710
- const getString = (key) => {
1711
- const value = payload[key];
1712
- return typeof value == "string" && value.trim() !== "" ? value : undefined;
1713
- };
1714
- return {
1715
- email: getString(JWT_CLAIMS.email),
1716
- firstName: getString(JWT_CLAIMS.firstName),
1717
- lastName: getString(JWT_CLAIMS.lastName),
1718
- userId: getString(JWT_CLAIMS.userId),
1719
- partitionId: getString(JWT_CLAIMS.partition)
1720
- };
1721
- }
1722
- function isRetriableStatusCode(status) {
1723
- return RETRIABLE_STATUS_CODES.includes(status);
1724
- }
1725
- function isRedirectStatusCode(status) {
1726
- return status === 302 || status === 303;
1727
- }
1728
- function isClientError(status) {
1729
- return status >= 400 && status < 500;
1730
- }
1731
- function delay(ms, cancellationToken) {
1732
- return new Promise((resolve, reject) => {
1733
- if (cancellationToken?.aborted)
1734
- return void reject(new OperationCancelledException);
1735
- const timeoutId = setTimeout(resolve, ms);
1736
- cancellationToken?.addEventListener("abort", () => {
1737
- clearTimeout(timeoutId);
1738
- reject(new OperationCancelledException);
1739
- }, {
1740
- once: true
1741
- });
1742
- });
1743
- }
1744
- function throwIfCancelled(cancellationToken) {
1745
- if (cancellationToken?.aborted)
1746
- throw new OperationCancelledException;
1747
- }
1748
-
1749
- class Semaphore {
1750
- async acquire() {
1751
- if (this.permits > 0)
1752
- return void this.permits--;
1753
- return new Promise((resolve) => {
1754
- this.waitQueue.push(resolve);
1755
- });
1756
- }
1757
- release() {
1758
- const next = this.waitQueue.shift();
1759
- if (next)
1760
- next();
1761
- else
1762
- this.permits++;
1763
- }
1764
- constructor(permits) {
1765
- _define_property(this, "permits", undefined);
1766
- _define_property(this, "waitQueue", []);
1767
- this.permits = permits;
1768
- }
1769
- }
1770
-
1771
- class ResourceBuilderTool extends SolutionTool {
1772
- async buildAsync(options, cancellationToken) {
1773
- this.logger.info("Build starting.");
1774
- this.inputPath = Path.dirname(options.solutionFilePath);
1775
- try {
1776
- throwIfCancelled(cancellationToken);
1777
- const accessToken = options.connection?.accessToken;
1778
- const tokenData = extractDataFromAccessToken(accessToken);
1779
- const existingResources = await this.readFromDirectory(KNOWN_ARCHIVE_FOLDERS.resources, cancellationToken);
1780
- this.logger.info(`Read ${existingResources.length} existing resources from ${KNOWN_ARCHIVE_FOLDERS.resources} directory.`);
1781
- if (existingResources && existingResources.length > 0) {
1782
- throwIfCancelled(cancellationToken);
1783
- const filteredResources = this.filterResources(existingResources, options);
1784
- await this.writeResources(filteredResources, options, cancellationToken);
1785
- } else
1786
- throw new Error("No resources found to build.");
1787
- await this.writePackageFiles(options, tokenData, cancellationToken);
1788
- const sizeLimitError = await this.enforceOutputSizeLimit(options.outputPath);
1789
- if (sizeLimitError)
1790
- return sizeLimitError;
1791
- this.logger.info("Build finished.");
1792
- return ToolResult.success();
1793
- } catch (error) {
1794
- const message = error instanceof Error ? error.message : String(error);
1795
- this.logger.error(`Build failed: ${message}`);
1796
- return ToolResult.error(ToolErrorCodes.InternalError, `Build failed: ${message}`);
1797
- }
1798
- }
1799
- async enforceOutputSizeLimit(outputPath) {
1800
- const filesDirectory = Path.join(outputPath, KNOWN_ARCHIVE_FOLDERS.files);
1801
- if (!await this.fileSystem.exists(filesDirectory))
1802
- return null;
1803
- const totalBytes = await this.getTotalDirectorySize(filesDirectory);
1804
- if (totalBytes <= MAX_BUILD_OUTPUT_SIZE_BYTES)
1805
- return null;
1806
- const maxMb = Math.floor(MAX_BUILD_OUTPUT_SIZE_BYTES / 1024 / 1024);
1807
- const currentMb = Math.floor(totalBytes / 1024 / 1024);
1808
- const message = `The built solution exceeds the maximum allowed size of ${maxMb} MB (current size: ${currentMb} MB). Solutions larger than this cannot be uploaded. Reduce the size by removing unused packages, splitting the solution into smaller solutions, or trimming large binary assets.`;
1809
- this.logger.error(`Built solution size ${currentMb} MB exceeds maximum allowed ${maxMb} MB.`);
1810
- return ToolResult.error(ToolErrorCodes.InternalError, message);
1811
- }
1812
- async getTotalDirectorySize(dirPath) {
1813
- let total = 0;
1814
- const stack = [
1815
- dirPath
1816
- ];
1817
- let current = stack.pop();
1818
- while (current !== undefined) {
1819
- const entries = await this.fileSystem.readdir(current);
1820
- for (const entry of entries) {
1821
- const fullPath = Path.join(current, entry);
1822
- const stats = await this.fileSystem.stat(fullPath);
1823
- if (stats) {
1824
- if (stats.isDirectory())
1825
- stack.push(fullPath);
1826
- else if (stats.isFile())
1827
- total += stats.size;
1828
- }
1829
- }
1830
- current = stack.pop();
1831
- }
1832
- return total;
1833
- }
1834
- async restoreAsync(options, cancellationToken) {
1835
- this.logger.info("Restore starting.");
1836
- this.inputPath = Path.dirname(options.solutionFilePath);
1837
- try {
1838
- throwIfCancelled(cancellationToken);
1839
- const existingResources = await this.readFromDirectory(KNOWN_ARCHIVE_FOLDERS.resources, cancellationToken);
1840
- this.logger.info(`Read ${existingResources.length} existing resources from ${KNOWN_ARCHIVE_FOLDERS.resources} directory.`);
1841
- if (existingResources.length === 0) {
1842
- this.logger.error("Solution definition empty or not found.");
1843
- return ToolResult.error(ToolErrorCodes.InternalError, "Solution definition empty or not found.");
1844
- }
1845
- const filteredResources = this.filterResources(existingResources, {
1846
- configuration: options.configuration,
1847
- projectsToBuild: options.projectsToBuild
1848
- });
1849
- const files = this.extractFilesFromResources(filteredResources);
1850
- const filesToDownload = files.filter((f) => f.url != null);
1851
- if (filesToDownload.length === 0) {
1852
- this.logger.info("No files to download.");
1853
- this.logger.info("Restore finished.");
1854
- return ToolResult.success();
1855
- }
1856
- const outputPath = options.outputPath ?? "";
1857
- const downloadTasks = [];
1858
- const semaphore = new Semaphore(MAX_DOWNLOAD_CONCURRENCY);
1859
- for (const file of filesToDownload) {
1860
- throwIfCancelled(cancellationToken);
1861
- this.logger.info(`Downloading file ${file.name} kind ${file.kind} from service url ${file.url}...`);
1862
- const resource = this.findResourceForFile(filteredResources, file);
1863
- if (!resource) {
1864
- this.logger.warn(`File with name '${file.name}', kind '${file.kind}', key '${file.key}' not referenced by any resource.`);
1865
- continue;
1866
- }
1867
- const filePath = Path.join(outputPath, KNOWN_ARCHIVE_FOLDERS.files, file.key, file.name);
1868
- if (await this.fileSystem.exists(filePath)) {
1869
- this.logger.info(`File ${file.name} already exists at ${filePath}, skipping download.`);
1870
- continue;
1871
- }
1872
- const dirPath = Path.dirname(filePath);
1873
- await this.fileSystem.mkdir(dirPath);
1874
- const serviceName = resource.apiVersion ?? "unknown";
1875
- downloadTasks.push(this.downloadFileWithSemaphore(semaphore, file, filePath, serviceName, options, cancellationToken));
1876
- }
1877
- if (downloadTasks.length === 0) {
1878
- this.logger.info("No files to download.");
1879
- this.logger.info("Restore finished.");
1880
- return ToolResult.success();
1881
- }
1882
- const results = await Promise.all(downloadTasks);
1883
- const failures = results.filter((r) => !r.isSuccess && r.failure != null).map((r) => r.failure);
1884
- if (failures.length > 0) {
1885
- for (const failure of failures)
1886
- this.logger.error(`Download failed for file ${failure.fileKey} from service ${failure.service} at ${failure.externalUrl}. Reason: ${failure.reason}. ${failure.errorMessage ?? ""}`);
1887
- const message = buildFailureMessage(failures);
1888
- this.logger.error(message);
1889
- return ToolResult.error(ToolErrorCodes.InternalError, message);
1890
- }
1891
- this.logger.info("Restore finished.");
1892
- return ToolResult.success();
1893
- } catch (error) {
1894
- const message = error instanceof Error ? error.message : String(error);
1895
- this.logger.error(`Restore failed: ${message}`);
1896
- return ToolResult.error(ToolErrorCodes.InternalError, `Restore failed: ${message}`);
1897
- }
1898
- }
1899
- async validateAsync(options, cancellationToken) {
1900
- this.logger.info("Validate starting.");
1901
- if (options.solutionFilePath === undefined)
1902
- throw new Error("Solution file path is undefined.");
1903
- this.inputPath = Path.dirname(options.solutionFilePath);
1904
- try {
1905
- throwIfCancelled(cancellationToken);
1906
- const packageVersion = options.packageVersion;
1907
- if (packageVersion !== undefined && !this.isValidSemanticVersion(packageVersion)) {
1908
- this.logger.error(`Invalid package version ${packageVersion}`);
1909
- return ToolResult.error("VALIDATION_ERROR", `Invalid package version: ${packageVersion}`);
1910
- }
1911
- this.logger.info("Validate finished.");
1912
- return ToolResult.success();
1913
- } catch (error) {
1914
- const message = error instanceof Error ? error.message : String(error);
1915
- this.logger.error(`Validation failed: ${message}`);
1916
- return ToolResult.error(ToolErrorCodes.InternalError, `Validation failed: ${message}`);
1917
- }
1918
- }
1919
- async readFromDirectory(folderName, cancellationToken) {
1920
- const basePath = this.inputPath;
1921
- const folderPath = folderName ? Path.join(basePath, folderName) : basePath;
1922
- const resources = [];
1923
- if (!await this.fileSystem.exists(folderPath))
1924
- return resources;
1925
- throwIfCancelled(cancellationToken);
1926
- const allFiles = await this.readFilesRecursively(folderPath, cancellationToken);
1927
- const jsonFiles = allFiles.filter((f) => f.endsWith(".json"));
1928
- this.logger.info(`Found ${jsonFiles.length} resource JSON files in ${folderName ?? basePath} directory.`);
1929
- const failedFiles = [];
1930
- for (const fileRelativeToFolder of jsonFiles) {
1931
- throwIfCancelled(cancellationToken);
1932
- const normalizedFileRelative = fileRelativeToFolder.replace(/\\/g, "/");
1933
- const relativeToBasePath = folderName ? `${folderName}/${normalizedFileRelative}` : normalizedFileRelative;
1934
- try {
1935
- const fullFilePath = Path.join(basePath, relativeToBasePath);
1936
- const content = await this.fileSystem.readFile(fullFilePath);
1937
- if (!content) {
1938
- this.logger.warn(`Failed to read resource file: ${relativeToBasePath}`);
1939
- continue;
1940
- }
1941
- const jsonContent = new TextDecoder().decode(content);
1942
- const wrapper = JSON.parse(jsonContent);
1943
- if (wrapper?.resource) {
1944
- const rd = wrapper.resource;
1945
- const normalizedPath = fileRelativeToFolder.replace(/\\/g, "/");
1946
- const segments = normalizedPath.split("/").filter((s) => s.length > 0);
1947
- if (segments.length >= 2) {
1948
- const hasType = rd.type != null && rd.type.trim() !== "";
1949
- const folderSegmentCount = hasType ? segments.length - 3 : segments.length - 2;
1950
- if (folderSegmentCount < 1)
1951
- rd.folders = [
1952
- {
1953
- fullyQualifiedName: PACKAGE_DEFAULTS.rootFolderName
1954
- }
1955
- ];
1956
- else {
1957
- const segmentsToUse = segments.slice(0, folderSegmentCount);
1958
- const folderFqn = segmentsToUse.join("/");
1959
- rd.folders = [
1960
- {
1961
- fullyQualifiedName: folderFqn
1962
- }
1963
- ];
1964
- }
1965
- } else
1966
- rd.folders = [
1967
- {
1968
- fullyQualifiedName: PACKAGE_DEFAULTS.rootFolderName
1969
- }
1970
- ];
1971
- resources.push(rd);
1972
- this.logger.info(`Read resource: ${rd.name} kind: ${rd.kind} from ${relativeToBasePath}`);
1973
- }
1974
- } catch (ex) {
1975
- const message = ex instanceof Error ? ex.message : String(ex);
1976
- this.logger.error(`Failed to read resource file ${relativeToBasePath}: ${message}`);
1977
- failedFiles.push(relativeToBasePath);
1978
- }
1979
- }
1980
- if (failedFiles.length > 0)
1981
- throw new Error(`Failed to read resource files: ${failedFiles.join(", ")}`);
1982
- return resources;
1983
- }
1984
- async readFilesRecursively(basePath, cancellationToken) {
1985
- const results = [];
1986
- const processDirectory = async (currentPath, relativePath) => {
1987
- throwIfCancelled(cancellationToken);
1988
- const entries = await this.fileSystem.readdir(currentPath);
1989
- for (const entry of entries) {
1990
- const fullPath = Path.join(currentPath, entry);
1991
- const relPath = relativePath ? `${relativePath}/${entry}` : entry;
1992
- const stats = await this.fileSystem.stat(fullPath);
1993
- if (stats?.isDirectory())
1994
- await processDirectory(fullPath, relPath);
1995
- else if (stats?.isFile())
1996
- results.push(relPath);
1997
- }
1998
- };
1999
- await processDirectory(basePath, "");
2000
- return results;
2001
- }
2002
- filterResources(resources, options) {
2003
- const { projectsToBuild, configuration } = options;
2004
- if (!resources)
2005
- return [];
2006
- if (configuration !== BuildConfiguration.Debug)
2007
- return resources;
2008
- if (!projectsToBuild || projectsToBuild.length === 0)
2009
- return resources;
2010
- const projectsToBuildSet = new Set(projectsToBuild);
2011
- return resources.filter((resource) => {
2012
- if (!isArtefactResource(resource))
2013
- return true;
2014
- const projectKey = resource.projectKey;
2015
- if (!projectKey || !projectsToBuildSet.has(projectKey)) {
2016
- this.logger.info(`Artefact resource skipped: ${resource.key}`);
2017
- return false;
2018
- }
2019
- return true;
2020
- });
2021
- }
2022
- async writeResources(resources, options, cancellationToken) {
2023
- for (const resource of resources) {
2024
- throwIfCancelled(cancellationToken);
2025
- const resourcePath = this.buildResourceRelativePath(resource);
2026
- const fullPath = Path.join(options.outputPath, resourcePath);
2027
- const dirPath = Path.dirname(fullPath);
2028
- await this.fileSystem.mkdir(dirPath);
2029
- const wrapper = {
2030
- docVersion: PACKAGE_DEFAULTS.currentDocVersion,
2031
- resource
2032
- };
2033
- await this.fileSystem.writeFile(fullPath, serializeJson(wrapper));
2034
- this.logger.info(`Writing resource file for resource ${resource.key}`);
2035
- }
2036
- }
2037
- buildResourceRelativePath(resource) {
2038
- const safeName = this.sanitizeFileName(resource.name);
2039
- const folderFqn = resource.folders[0]?.fullyQualifiedName ?? "";
2040
- const parts = [
2041
- KNOWN_ARCHIVE_FOLDERS.resources
2042
- ];
2043
- const folderSegments = folderFqn.split("/").filter((s) => s.length > 0);
2044
- if (folderSegments.length > 0)
2045
- parts.push(...folderSegments);
2046
- else
2047
- parts.push(PACKAGE_DEFAULTS.rootFolderName);
2048
- parts.push(resource.kind);
2049
- if (resource.type && resource.type.trim())
2050
- parts.push(resource.type);
2051
- parts.push(`${safeName}.json`);
2052
- return Path.join(...parts);
2053
- }
2054
- sanitizeFileName(name) {
2055
- return name.replace(INVALID_FILE_NAME_CHARS, "_");
2056
- }
2057
- isValidSemanticVersion(version) {
2058
- const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
2059
- return semverRegex.test(version);
2060
- }
2061
- async writePackageFiles(options, tokenData, cancellationToken) {
2062
- throwIfCancelled(cancellationToken);
2063
- const packageName = options.package.id;
2064
- if (!packageName)
2065
- throw new Error("Package name not found");
2066
- const packageVersion = options.package.version ?? PACKAGE_DEFAULTS.defaultPackageVersion;
2067
- const uipxContentBuffer = await this.fileSystem.readFile(options.solutionFilePath);
2068
- if (!uipxContentBuffer)
2069
- throw new Error(`Failed to read solution file: ${options.solutionFilePath}`);
2070
- const uipxContent = new TextDecoder().decode(uipxContentBuffer);
2071
- const uipxData = JSON.parse(uipxContent);
2072
- if (!uipxData.SolutionId)
2073
- throw new Error(`SolutionId not found in solution file: ${options.solutionFilePath}`);
2074
- const solutionId = uipxData.SolutionId;
2075
- this.logger.info(`Extracted SolutionId from .uipx file: ${solutionId}`);
2076
- let authorName = options.package.author;
2077
- if (!authorName) {
2078
- const nameParts = [
2079
- tokenData.firstName,
2080
- tokenData.lastName
2081
- ].filter((s) => s != null && s.trim() !== "");
2082
- authorName = nameParts.length > 0 ? nameParts.join(" ").trim() : PACKAGE_DEFAULTS.defaultAuthorName;
2083
- }
2084
- const packageVersionKey = options.publishId ?? crypto.randomUUID();
2085
- const metadata = {
2086
- authorEmail: tokenData.email,
2087
- authorName,
2088
- description: options.package.description,
2089
- releaseNotes: options.package.releaseNotes,
2090
- packageName,
2091
- packageVersion,
2092
- projectKey: solutionId,
2093
- packageVersionKey,
2094
- origin: "Studio",
2095
- configuration: options.configuration
2096
- };
2097
- this.logger.info(`Creating solution package with name '${metadata.packageName}' and version '${metadata.packageVersion}'.`);
2098
- await this.writePackageInfo(options.outputPath);
2099
- throwIfCancelled(cancellationToken);
2100
- await this.writeMetadata(options.outputPath, metadata);
2101
- }
2102
- async writePackageInfo(outputPath) {
2103
- const packageInfo = {
2104
- version: PACKAGE_DEFAULTS.currentVersion,
2105
- type: PACKAGE_DEFAULTS.unifiedBuildPackageType
2106
- };
2107
- const packageInfoPath = Path.join(outputPath, KNOWN_ARCHIVE_FILE_NAMES.packageInfoJsonFileName);
2108
- await this.fileSystem.writeFile(packageInfoPath, serializeJson(packageInfo));
2109
- }
2110
- async writeMetadata(outputPath, metadata) {
2111
- const metadataResource = {
2112
- apiVersion: "solutions.uipath.com/v1",
2113
- kind: "Metadata",
2114
- spec: metadata
2115
- };
2116
- const metadataPath = Path.join(outputPath, KNOWN_ARCHIVE_FILE_NAMES.metadataJsonFileName);
2117
- await this.fileSystem.writeFile(metadataPath, serializeJson(metadataResource));
2118
- }
2119
- async downloadFile(file, filePath, serviceName, options, cancellationToken) {
2120
- const maxRetryAttempts = RESILIENCE_DEFAULTS.maxRetryAttempts;
2121
- const retryIntervalMs = RESILIENCE_DEFAULTS.retryIntervalMs;
2122
- const accessToken = options.connection?.accessToken;
2123
- const externalUrl = file.url;
2124
- if (!externalUrl)
2125
- throw new Error("File URL is required for download");
2126
- let currentUrl = externalUrl;
2127
- let redirectCount = 0;
2128
- const createFailure = (reason, errorMessage) => ({
2129
- isSuccess: false,
2130
- failure: {
2131
- fileKey: file.key,
2132
- service: serviceName,
2133
- externalUrl,
2134
- reason,
2135
- errorMessage: truncateMessage(errorMessage, MAX_SERVER_MESSAGE_LENGTH)
2136
- }
2137
- });
2138
- try {
2139
- while (redirectCount < RESILIENCE_DEFAULTS.maxRedirectRetries) {
2140
- const response = await this.fetchWithRetry(currentUrl, accessToken, maxRetryAttempts, retryIntervalMs, file.name, cancellationToken);
2141
- if (isRedirectStatusCode(response.status)) {
2142
- const location = response.headers.get("location");
2143
- if (!location)
2144
- return createFailure("TooManyRedirects", "Redirect response without location header");
2145
- currentUrl = location;
2146
- redirectCount++;
2147
- this.logger.info(`Following redirect for file ${file.name} to ${location}`);
2148
- continue;
2149
- }
2150
- if (isClientError(response.status)) {
2151
- const serverMessage = await this.readResponseTextSafe(response);
2152
- if (accessToken) {
2153
- this.logger.info(`Retrying download of file ${file.name} without access token`);
2154
- const retryResponse = await this.fetchWithRetry(currentUrl, undefined, maxRetryAttempts, retryIntervalMs, file.name, cancellationToken);
2155
- if (retryResponse.ok) {
2156
- const buffer2 = await retryResponse.arrayBuffer();
2157
- await this.fileSystem.writeFile(filePath, Buffer.from(buffer2));
2158
- this.logger.info(`File ${file.name} written to ${filePath}.`);
2159
- return {
2160
- isSuccess: true
2161
- };
2162
- }
2163
- const retryServerMessage = await this.readResponseTextSafe(retryResponse);
2164
- return createFailure(mapHttpStatusCodeToReason(retryResponse.status), retryServerMessage ?? `HTTP ${retryResponse.status}`);
2165
- }
2166
- return createFailure(mapHttpStatusCodeToReason(response.status), serverMessage ?? `HTTP ${response.status}`);
2167
- }
2168
- if (!response.ok) {
2169
- const serverMessage = await this.readResponseTextSafe(response);
2170
- return createFailure(mapHttpStatusCodeToReason(response.status), serverMessage ?? `HTTP ${response.status}: ${response.statusText}`);
2171
- }
2172
- const buffer = await response.arrayBuffer();
2173
- await this.fileSystem.writeFile(filePath, Buffer.from(buffer));
2174
- this.logger.info(`File ${file.name} written to ${filePath}.`);
2175
- return {
2176
- isSuccess: true
2177
- };
2178
- }
2179
- return createFailure("TooManyRedirects", "Too many redirects");
2180
- } catch (error) {
2181
- if (cancellationToken?.aborted)
2182
- return createFailure("Cancelled", "Operation was cancelled");
2183
- const message = error instanceof Error ? error.message : String(error);
2184
- if (message.toLowerCase().includes("timeout") || message.toLowerCase().includes("timed out"))
2185
- return createFailure("Timeout", message);
2186
- if (message.toLowerCase().includes("network") || message.toLowerCase().includes("econnrefused") || message.toLowerCase().includes("enotfound"))
2187
- return createFailure("ConnectionError", message);
2188
- return createFailure("Unknown", message);
2189
- }
2190
- }
2191
- async readResponseTextSafe(response) {
2192
- try {
2193
- const text = await response.text();
2194
- return truncateMessage(text, MAX_SERVER_MESSAGE_LENGTH);
2195
- } catch {
2196
- return;
2197
- }
2198
- }
2199
- extractFilesFromResources(resources) {
2200
- const files = [];
2201
- for (const resource of resources)
2202
- if (resource.files && resource.files.length !== 0)
2203
- for (const file of resource.files)
2204
- files.push({
2205
- name: file.name,
2206
- kind: file.kind,
2207
- key: file.key ?? resource.key ?? "",
2208
- url: file.url
2209
- });
2210
- return files;
2211
- }
2212
- findResourceForFile(resources, file) {
2213
- return resources.find((resource) => {
2214
- if (!resource.files || resource.files.length === 0)
2215
- return false;
2216
- return resource.files.some((rf) => rf.name === file.name && rf.kind === file.kind);
2217
- });
2218
- }
2219
- async downloadFileWithSemaphore(semaphore, file, filePath, serviceName, options, cancellationToken) {
2220
- await semaphore.acquire();
2221
- try {
2222
- return await this.downloadFile(file, filePath, serviceName, options, cancellationToken);
2223
- } finally {
2224
- semaphore.release();
2225
- }
2226
- }
2227
- async fetchWithRetry(url, accessToken, maxRetryAttempts, retryIntervalMs, fileName, cancellationToken) {
2228
- let lastError;
2229
- for (let attempt = 1;attempt <= maxRetryAttempts + 1; attempt++)
2230
- try {
2231
- const response = await fetch(url, {
2232
- signal: cancellationToken,
2233
- headers: accessToken ? {
2234
- Authorization: `Bearer ${accessToken}`
2235
- } : undefined,
2236
- redirect: "manual"
2237
- });
2238
- if (isRetriableStatusCode(response.status) && attempt <= maxRetryAttempts) {
2239
- const delayMs = retryIntervalMs * attempt;
2240
- this.logger.warn(`Retriable error (HTTP ${response.status}) downloading file ${fileName}, attempt ${attempt}/${maxRetryAttempts}. Retrying in ${delayMs}ms...`);
2241
- await delay(delayMs, cancellationToken);
2242
- continue;
2243
- }
2244
- return response;
2245
- } catch (error) {
2246
- lastError = error instanceof Error ? error : new Error(String(error));
2247
- if (attempt <= maxRetryAttempts) {
2248
- const delayMs = retryIntervalMs * attempt;
2249
- this.logger.warn(`Network error downloading file ${fileName}, attempt ${attempt}/${maxRetryAttempts}: ${lastError.message}. Retrying in ${delayMs}ms...`);
2250
- await delay(delayMs, cancellationToken);
2251
- continue;
2252
- }
2253
- }
2254
- throw lastError ?? new Error(`Failed to download file ${fileName} after ${maxRetryAttempts} retries`);
2255
- }
2256
- constructor(fileSystem, logger) {
2257
- super(fileSystem, logger), _define_property(this, "inputPath", "");
2258
- }
2259
- }
2260
-
2261
- class ResourceBuilderToolFactory {
2262
- async createAsync(logger, fileSystem) {
2263
- return new ResourceBuilderTool(fileSystem, logger);
2264
- }
2265
- }
2266
-
2267
- // src/packager-tool.ts
2268
- function registerPackagerFactories() {
2269
- toolsFactoryRepository.registerSolutionToolFactory(new ResourceBuilderToolFactory);
2270
- toolsFactoryRepository.registerProjectToolFactory(new ConnectorToolFactory);
2271
- }
2272
-
2273
- export { Path, TemporaryStorageService, ZipService, I18nManager, translate, BuildConfiguration, LogLevel, LogMessage, ProjectTypes, TargetFramework, ToolErrorCodes, ToolResult, ProjectTool, toolsFactoryRepository2 as toolsFactoryRepository, registerPackagerFactories };
2274
-
2275
- //# debugId=52AD10AAEA66A6BC64756E2164756E21