@uipath/rules-tool 0.0.0-stage → 1.204.0-preview.250

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 (49) hide show
  1. package/LICENSE.txt +3 -0
  2. package/README.md +80 -2
  3. package/dist/DmnFactory-VWZOSZHH-jkpbxz3n.js +42 -0
  4. package/dist/DmnModelTypes-ATR7FVKZ-jp35cecy.js +18 -0
  5. package/dist/KieDmnMarshaller-6TTUU5B4-47q50gk4.js +20 -0
  6. package/dist/THIRD-PARTY-NOTICES.md +1054 -0
  7. package/dist/business-rules-bnr581tz.js +26 -0
  8. package/dist/constants-9pa118cj.js +29 -0
  9. package/dist/embedded-file-reader-rf2g1kfj.js +114 -0
  10. package/dist/first-party-service-sd8yaf73.js +27 -0
  11. package/dist/hitPolicyResult-4WDHTX4A-gk103w84.js +33 -0
  12. package/dist/index-2hzp9b97.js +116 -0
  13. package/dist/index-34pj9f36.js +48 -0
  14. package/dist/index-4c4exdzw.js +3035 -0
  15. package/dist/index-dqa169gp.js +25 -0
  16. package/dist/index-fs1nd5ap.js +200 -0
  17. package/dist/index-sby22td6.js +634 -0
  18. package/dist/index-t4mx1a5e.js +17 -0
  19. package/dist/index.js +17 -0
  20. package/dist/jmespath-231m3hyn.js +1485 -0
  21. package/dist/js-yaml-88tdqrtd.js +3153 -0
  22. package/dist/rule-catalog-5gzpe93c.js +46 -0
  23. package/dist/rules-command-error-20gp2dv9.js +14 -0
  24. package/dist/rules-debug-service-cmgmbhyh.js +193 -0
  25. package/dist/rules-init-service-b74thek5.js +104 -0
  26. package/dist/rules-refresh-service-jgk2kq9d.js +66 -0
  27. package/dist/rules-validate-service-mr2fk58k.js +63 -0
  28. package/dist/tool-19b4ect0.js +754 -0
  29. package/dist/tool-1de529jm.js +39 -0
  30. package/dist/tool-2cky8jwp.js +17878 -0
  31. package/dist/tool-4dfpdepw.js +55 -0
  32. package/dist/tool-53w8skv5.js +262 -0
  33. package/dist/tool-7haj67tr.js +19 -0
  34. package/dist/tool-8h4er38s.js +11063 -0
  35. package/dist/tool-8qy8pkp4.js +40 -0
  36. package/dist/tool-av4mmsef.js +73 -0
  37. package/dist/tool-eymjx05p.js +6396 -0
  38. package/dist/tool-gdtpsdn7.js +342 -0
  39. package/dist/tool-jd313s2x.js +10 -0
  40. package/dist/tool-jxvk6306.js +574 -0
  41. package/dist/tool-m41px07w.js +49 -0
  42. package/dist/tool-mkn83w88.js +111 -0
  43. package/dist/tool-pm3ewdxc.js +1115 -0
  44. package/dist/tool-qgqscsjc.js +46 -0
  45. package/dist/tool-tkcx6png.js +6558 -0
  46. package/dist/tool-wmh645tm.js +4022 -0
  47. package/dist/tool-x0z7hxqr.js +916 -0
  48. package/dist/tool.js +12 -0
  49. package/package.json +30 -5
@@ -0,0 +1,916 @@
1
+ import {
2
+ zipSync
3
+ } from "./tool-pm3ewdxc.js";
4
+ import {
5
+ addSdkUserAgentHeader,
6
+ catchError,
7
+ getSdkUserAgentToken,
8
+ installSdkUserAgentHeader,
9
+ logger
10
+ } from "./tool-tkcx6png.js";
11
+
12
+ // ../solution-sdk/src/studio-web-compat.ts
13
+ var API_PROJECT_TYPES = new Set(["api", "apiautomation"]);
14
+
15
+ // ../solution-sdk/src/zip-utils.ts
16
+ var DEFAULT_EXCLUDED_DIR_NAMES = new Set([
17
+ ".venv",
18
+ "node_modules",
19
+ "__pycache__",
20
+ ".git",
21
+ ".local",
22
+ ".flow-sdk"
23
+ ]);
24
+ var DEFAULT_EXCLUDED_FILE_PATTERNS = [
25
+ /^\.env($|\..+)/
26
+ ];
27
+ function isDefaultExcludedFileName(name) {
28
+ for (const pattern of DEFAULT_EXCLUDED_FILE_PATTERNS) {
29
+ if (pattern.test(name)) {
30
+ return true;
31
+ }
32
+ }
33
+ return false;
34
+ }
35
+ async function collectTree(fs, dir, options = {}) {
36
+ const files = [];
37
+ const emptyDirs = [];
38
+ const excluded = new Set(DEFAULT_EXCLUDED_DIR_NAMES);
39
+ if (options.additionalExcludeDirs) {
40
+ for (const name of options.additionalExcludeDirs) {
41
+ excluded.add(name);
42
+ }
43
+ }
44
+ async function walk(current, isRoot) {
45
+ const entries = await fs.readdir(current);
46
+ if (entries.length === 0) {
47
+ if (!isRoot) {
48
+ emptyDirs.push(current);
49
+ }
50
+ return;
51
+ }
52
+ for (const entryName of entries) {
53
+ const fullPath = fs.path.join(current, entryName);
54
+ const entryStat = await fs.stat(fullPath);
55
+ if (entryStat?.isDirectory()) {
56
+ if (excluded.has(entryName)) {
57
+ continue;
58
+ }
59
+ await walk(fullPath, false);
60
+ } else if (entryStat?.isFile()) {
61
+ if (isDefaultExcludedFileName(entryName)) {
62
+ continue;
63
+ }
64
+ files.push(fullPath);
65
+ }
66
+ }
67
+ }
68
+ await walk(dir, true);
69
+ return { files, emptyDirs };
70
+ }
71
+ async function createZipFromDir(fs, dir, options = {}) {
72
+ const { files, emptyDirs } = await collectTree(fs, dir, options);
73
+ const zippable = {};
74
+ for (const filePath of files) {
75
+ const relPath = fs.path.relative(dir, filePath).replace(/\\/g, "/");
76
+ const data = await fs.readFile(filePath);
77
+ if (data) {
78
+ zippable[relPath] = new Uint8Array(data);
79
+ }
80
+ }
81
+ for (const emptyDir of emptyDirs) {
82
+ const relPath = fs.path.relative(dir, emptyDir).replace(/\\/g, "/");
83
+ if (!relPath) {
84
+ continue;
85
+ }
86
+ zippable[`${relPath}/`] = new Uint8Array(0);
87
+ }
88
+ return finalizeZip64(zipSync(zippable, { level: 6 }));
89
+ }
90
+ var EOCD_SIZE = 22;
91
+ var EOCD_SIGNATURE = 101010256;
92
+ var CD_HEADER_SIGNATURE = 33639248;
93
+ var ZIP64_EOCD_SIGNATURE = 101075792;
94
+ var ZIP64_EOCD_SIZE = 56;
95
+ var ZIP64_LOCATOR_SIGNATURE = 117853008;
96
+ var ZIP64_LOCATOR_SIZE = 20;
97
+ var MAX_ZIP32_ENTRIES = 65535;
98
+ var MAX_ZIP32_OFFSET = 4294967295;
99
+ function finalizeZip64(zip) {
100
+ const view = new DataView(zip.buffer, zip.byteOffset, zip.byteLength);
101
+ const eocdStart = zip.byteLength - EOCD_SIZE;
102
+ if (eocdStart < 0 || view.getUint32(eocdStart, true) !== EOCD_SIGNATURE) {
103
+ throw new Error("Cannot finalize the solution archive: it does not end with an end-of-central-directory record.");
104
+ }
105
+ const cdSize = view.getUint32(eocdStart + 12, true);
106
+ const cdOffset = view.getUint32(eocdStart + 16, true);
107
+ const entryCount = countCentralDirectoryEntries(view, cdOffset, cdSize);
108
+ if (entryCount <= MAX_ZIP32_ENTRIES) {
109
+ return zip;
110
+ }
111
+ if (cdOffset >= MAX_ZIP32_OFFSET || zip.byteLength >= MAX_ZIP32_OFFSET) {
112
+ throw new Error(`The solution archive is ${zip.byteLength} bytes, past the 4 GB limit this packer supports. Exclude large directories from the solution with a .uipignore file.`);
113
+ }
114
+ const tail = new Uint8Array(ZIP64_EOCD_SIZE + ZIP64_LOCATOR_SIZE + EOCD_SIZE);
115
+ const tailView = new DataView(tail.buffer);
116
+ const count = BigInt(entryCount);
117
+ tailView.setUint32(0, ZIP64_EOCD_SIGNATURE, true);
118
+ tailView.setBigUint64(4, BigInt(ZIP64_EOCD_SIZE - 12), true);
119
+ tailView.setUint16(12, 45, true);
120
+ tailView.setUint16(14, 45, true);
121
+ tailView.setUint32(16, 0, true);
122
+ tailView.setUint32(20, 0, true);
123
+ tailView.setBigUint64(24, count, true);
124
+ tailView.setBigUint64(32, count, true);
125
+ tailView.setBigUint64(40, BigInt(cdSize), true);
126
+ tailView.setBigUint64(48, BigInt(cdOffset), true);
127
+ const locator = ZIP64_EOCD_SIZE;
128
+ tailView.setUint32(locator, ZIP64_LOCATOR_SIGNATURE, true);
129
+ tailView.setUint32(locator + 4, 0, true);
130
+ tailView.setBigUint64(locator + 8, BigInt(eocdStart), true);
131
+ tailView.setUint32(locator + 16, 1, true);
132
+ const eocd = ZIP64_EOCD_SIZE + ZIP64_LOCATOR_SIZE;
133
+ tailView.setUint32(eocd, EOCD_SIGNATURE, true);
134
+ tailView.setUint16(eocd + 4, 0, true);
135
+ tailView.setUint16(eocd + 6, 0, true);
136
+ tailView.setUint16(eocd + 8, MAX_ZIP32_ENTRIES, true);
137
+ tailView.setUint16(eocd + 10, MAX_ZIP32_ENTRIES, true);
138
+ tailView.setUint32(eocd + 12, cdSize, true);
139
+ tailView.setUint32(eocd + 16, cdOffset, true);
140
+ tailView.setUint16(eocd + 20, 0, true);
141
+ const out = new Uint8Array(eocdStart + tail.byteLength);
142
+ out.set(zip.subarray(0, eocdStart), 0);
143
+ out.set(tail, eocdStart);
144
+ return out;
145
+ }
146
+ function countCentralDirectoryEntries(view, cdOffset, cdSize) {
147
+ const end = cdOffset + cdSize;
148
+ let position = cdOffset;
149
+ let count = 0;
150
+ while (position + 46 <= end && view.getUint32(position, true) === CD_HEADER_SIGNATURE) {
151
+ const nameLength = view.getUint16(position + 28, true);
152
+ const extraLength = view.getUint16(position + 30, true);
153
+ const commentLength = view.getUint16(position + 32, true);
154
+ position += 46 + nameLength + extraLength + commentLength;
155
+ count++;
156
+ }
157
+ return count;
158
+ }
159
+ // ../solution-sdk/src/bundle-service.ts
160
+ async function mirrorTree(fs, srcDir, relativeBase, destBaseDir, additionalExcludeDirs) {
161
+ const { files, emptyDirs } = await collectTree(fs, srcDir, {
162
+ additionalExcludeDirs
163
+ });
164
+ if (files.length === 0 && emptyDirs.length === 0) {
165
+ const rootRel = fs.path.relative(relativeBase, srcDir);
166
+ if (rootRel) {
167
+ await fs.mkdir(fs.path.join(destBaseDir, rootRel));
168
+ }
169
+ return;
170
+ }
171
+ for (const f of files) {
172
+ const relPath = fs.path.relative(relativeBase, f);
173
+ const destPath = fs.path.join(destBaseDir, relPath);
174
+ const data = await fs.readFile(f);
175
+ if (data) {
176
+ await fs.writeFile(destPath, data);
177
+ } else {
178
+ logger.warn(`Skipping empty or unreadable file: ${f}`);
179
+ }
180
+ }
181
+ for (const dir of emptyDirs) {
182
+ const relPath = fs.path.relative(relativeBase, dir);
183
+ if (!relPath) {
184
+ continue;
185
+ }
186
+ await fs.mkdir(fs.path.join(destBaseDir, relPath));
187
+ }
188
+ }
189
+ async function buildSolutionPackageFromDir(fs, solutionDir) {
190
+ const absoluteSolutionDir = fs.path.resolve(solutionDir);
191
+ const solutionName = fs.path.basename(absoluteSolutionDir) || "Solution";
192
+ const tmpDir = fs.env.tmpdir();
193
+ const stagingDir = fs.path.join(tmpDir, `.debug-solution-${Date.now()}`);
194
+ await fs.mkdir(stagingDir);
195
+ try {
196
+ await mirrorTree(fs, absoluteSolutionDir, absoluteSolutionDir, stagingDir);
197
+ const storagePath = fs.path.join(stagingDir, "SolutionStorage.json");
198
+ const uipxFiles = (await fs.readdir(stagingDir)).filter((f) => f.endsWith(".uipx"));
199
+ if (uipxFiles.length > 0) {
200
+ const uipxFile = uipxFiles[0];
201
+ const uipxContent = await fs.readFile(fs.path.join(stagingDir, uipxFile), "utf-8");
202
+ if (!uipxContent) {
203
+ throw new Error(`Could not read ${uipxFile}; unable to create SolutionStorage.json.`);
204
+ }
205
+ const [parseError, uipx] = catchError(() => JSON.parse(uipxContent));
206
+ if (parseError) {
207
+ throw new Error(`Could not parse ${uipxFile}; unable to create SolutionStorage.json: ${parseError.message}`);
208
+ }
209
+ const storageJson = {
210
+ SolutionId: uipx.SolutionId ?? crypto.randomUUID(),
211
+ Projects: (uipx.Projects ?? []).map((p) => ({
212
+ ProjectId: p.Id ?? crypto.randomUUID(),
213
+ ProjectRelativePath: p.ProjectRelativePath ?? ""
214
+ }))
215
+ };
216
+ await fs.writeFile(storagePath, JSON.stringify(storageJson));
217
+ } else if (!await fs.exists(storagePath)) {
218
+ throw new Error(`SolutionStorage.json is missing and no .uipx file was found in ${absoluteSolutionDir}. Run 'uip solution init' and add/import the project into a solution, or include a valid SolutionStorage.json before uploading or debugging.`);
219
+ }
220
+ const uisPath = fs.path.join(tmpDir, `${solutionName}-${Date.now()}.uis`);
221
+ const zipData = await createZipFromDir(fs, stagingDir);
222
+ await fs.writeFile(uisPath, zipData);
223
+ return uisPath;
224
+ } finally {
225
+ await fs.rm(stagingDir).catch(() => {});
226
+ }
227
+ }
228
+
229
+ // ../studioweb-sdk/generated/src/runtime.ts
230
+ var BASE_PATH = "https://alpha.uipath.com/studio_/backend".replace(/\/+$/, "");
231
+
232
+ class Configuration {
233
+ configuration;
234
+ constructor(configuration = {}) {
235
+ this.configuration = configuration;
236
+ }
237
+ set config(configuration) {
238
+ this.configuration = configuration;
239
+ }
240
+ get basePath() {
241
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
242
+ }
243
+ get fetchApi() {
244
+ return this.configuration.fetchApi;
245
+ }
246
+ get middleware() {
247
+ return this.configuration.middleware || [];
248
+ }
249
+ get queryParamsStringify() {
250
+ return this.configuration.queryParamsStringify || querystring;
251
+ }
252
+ get username() {
253
+ return this.configuration.username;
254
+ }
255
+ get password() {
256
+ return this.configuration.password;
257
+ }
258
+ get apiKey() {
259
+ const apiKey = this.configuration.apiKey;
260
+ if (apiKey) {
261
+ return typeof apiKey === "function" ? apiKey : () => apiKey;
262
+ }
263
+ return;
264
+ }
265
+ get accessToken() {
266
+ const accessToken = this.configuration.accessToken;
267
+ if (accessToken) {
268
+ return typeof accessToken === "function" ? accessToken : async () => accessToken;
269
+ }
270
+ return;
271
+ }
272
+ get headers() {
273
+ return this.configuration.headers;
274
+ }
275
+ get credentials() {
276
+ return this.configuration.credentials;
277
+ }
278
+ }
279
+ var DefaultConfig = new Configuration;
280
+
281
+ class BaseAPI {
282
+ configuration;
283
+ static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
284
+ middleware;
285
+ constructor(configuration = DefaultConfig) {
286
+ this.configuration = configuration;
287
+ this.middleware = configuration.middleware;
288
+ }
289
+ withMiddleware(...middlewares) {
290
+ const next = this.clone();
291
+ next.middleware = next.middleware.concat(...middlewares);
292
+ return next;
293
+ }
294
+ withPreMiddleware(...preMiddlewares) {
295
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
296
+ return this.withMiddleware(...middlewares);
297
+ }
298
+ withPostMiddleware(...postMiddlewares) {
299
+ const middlewares = postMiddlewares.map((post) => ({ post }));
300
+ return this.withMiddleware(...middlewares);
301
+ }
302
+ isJsonMime(mime) {
303
+ if (!mime) {
304
+ return false;
305
+ }
306
+ return BaseAPI.jsonRegex.test(mime);
307
+ }
308
+ async request(context, initOverrides) {
309
+ const { url, init } = await this.createFetchParams(context, initOverrides);
310
+ const response = await this.fetchApi(url, init);
311
+ if (response && (response.status >= 200 && response.status < 300)) {
312
+ return response;
313
+ }
314
+ throw new ResponseError(response, "Response returned an error code");
315
+ }
316
+ async createFetchParams(context, initOverrides) {
317
+ let url = this.configuration.basePath + context.path;
318
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
319
+ url += "?" + this.configuration.queryParamsStringify(context.query);
320
+ }
321
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
322
+ Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
323
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
324
+ const initParams = {
325
+ method: context.method,
326
+ headers,
327
+ body: context.body,
328
+ credentials: this.configuration.credentials
329
+ };
330
+ const overriddenInit = {
331
+ ...initParams,
332
+ ...await initOverrideFn({
333
+ init: initParams,
334
+ context
335
+ })
336
+ };
337
+ let body;
338
+ if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
339
+ body = overriddenInit.body;
340
+ } else if (this.isJsonMime(headers["Content-Type"])) {
341
+ body = JSON.stringify(overriddenInit.body);
342
+ } else {
343
+ body = overriddenInit.body;
344
+ }
345
+ const init = {
346
+ ...overriddenInit,
347
+ body
348
+ };
349
+ return { url, init };
350
+ }
351
+ fetchApi = async (url, init) => {
352
+ let fetchParams = { url, init };
353
+ for (const middleware of this.middleware) {
354
+ if (middleware.pre) {
355
+ fetchParams = await middleware.pre({
356
+ fetch: this.fetchApi,
357
+ ...fetchParams
358
+ }) || fetchParams;
359
+ }
360
+ }
361
+ let response = undefined;
362
+ try {
363
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
364
+ } catch (e) {
365
+ for (const middleware of this.middleware) {
366
+ if (middleware.onError) {
367
+ response = await middleware.onError({
368
+ fetch: this.fetchApi,
369
+ url: fetchParams.url,
370
+ init: fetchParams.init,
371
+ error: e,
372
+ response: response ? response.clone() : undefined
373
+ }) || response;
374
+ }
375
+ }
376
+ if (response === undefined) {
377
+ if (e instanceof Error) {
378
+ throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
379
+ } else {
380
+ throw e;
381
+ }
382
+ }
383
+ }
384
+ for (const middleware of this.middleware) {
385
+ if (middleware.post) {
386
+ response = await middleware.post({
387
+ fetch: this.fetchApi,
388
+ url: fetchParams.url,
389
+ init: fetchParams.init,
390
+ response: response.clone()
391
+ }) || response;
392
+ }
393
+ }
394
+ return response;
395
+ };
396
+ clone() {
397
+ const constructor = this.constructor;
398
+ const next = new constructor(this.configuration);
399
+ next.middleware = this.middleware.slice();
400
+ return next;
401
+ }
402
+ }
403
+ function isBlob(value) {
404
+ return typeof Blob !== "undefined" && value instanceof Blob;
405
+ }
406
+ function isFormData(value) {
407
+ return typeof FormData !== "undefined" && value instanceof FormData;
408
+ }
409
+
410
+ class ResponseError extends Error {
411
+ response;
412
+ name = "ResponseError";
413
+ constructor(response, msg) {
414
+ super(msg);
415
+ this.response = response;
416
+ }
417
+ }
418
+
419
+ class FetchError extends Error {
420
+ cause;
421
+ name = "FetchError";
422
+ constructor(cause, msg) {
423
+ super(msg);
424
+ this.cause = cause;
425
+ }
426
+ }
427
+ function querystring(params, prefix = "") {
428
+ return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
429
+ }
430
+ function querystringSingleKey(key, value, keyPrefix = "") {
431
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
432
+ if (value instanceof Array) {
433
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
434
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
435
+ }
436
+ if (value instanceof Set) {
437
+ const valueAsArray = Array.from(value);
438
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
439
+ }
440
+ if (value instanceof Date) {
441
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
442
+ }
443
+ if (value instanceof Object) {
444
+ return querystring(value, fullKey);
445
+ }
446
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
447
+ }
448
+ // ../solution-sdk/generated/src/runtime.ts
449
+ var BASE_PATH2 = "https://alpha.uipath.com/uipattycyrhx/abizon_1/automationsolutions_".replace(/\/+$/, "");
450
+
451
+ class Configuration2 {
452
+ configuration;
453
+ constructor(configuration = {}) {
454
+ this.configuration = configuration;
455
+ }
456
+ set config(configuration) {
457
+ this.configuration = configuration;
458
+ }
459
+ get basePath() {
460
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH2;
461
+ }
462
+ get fetchApi() {
463
+ return this.configuration.fetchApi;
464
+ }
465
+ get middleware() {
466
+ return this.configuration.middleware || [];
467
+ }
468
+ get queryParamsStringify() {
469
+ return this.configuration.queryParamsStringify || querystring2;
470
+ }
471
+ get username() {
472
+ return this.configuration.username;
473
+ }
474
+ get password() {
475
+ return this.configuration.password;
476
+ }
477
+ get apiKey() {
478
+ const apiKey = this.configuration.apiKey;
479
+ if (apiKey) {
480
+ return typeof apiKey === "function" ? apiKey : () => apiKey;
481
+ }
482
+ return;
483
+ }
484
+ get accessToken() {
485
+ const accessToken = this.configuration.accessToken;
486
+ if (accessToken) {
487
+ return typeof accessToken === "function" ? accessToken : async () => accessToken;
488
+ }
489
+ return;
490
+ }
491
+ get headers() {
492
+ return this.configuration.headers;
493
+ }
494
+ get credentials() {
495
+ return this.configuration.credentials;
496
+ }
497
+ }
498
+ var DefaultConfig2 = new Configuration2;
499
+
500
+ class BaseAPI2 {
501
+ configuration;
502
+ static jsonRegex = new RegExp("^(:?application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$", "i");
503
+ middleware;
504
+ constructor(configuration = DefaultConfig2) {
505
+ this.configuration = configuration;
506
+ this.middleware = configuration.middleware;
507
+ }
508
+ withMiddleware(...middlewares) {
509
+ const next = this.clone();
510
+ next.middleware = next.middleware.concat(...middlewares);
511
+ return next;
512
+ }
513
+ withPreMiddleware(...preMiddlewares) {
514
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
515
+ return this.withMiddleware(...middlewares);
516
+ }
517
+ withPostMiddleware(...postMiddlewares) {
518
+ const middlewares = postMiddlewares.map((post) => ({ post }));
519
+ return this.withMiddleware(...middlewares);
520
+ }
521
+ isJsonMime(mime) {
522
+ if (!mime) {
523
+ return false;
524
+ }
525
+ return BaseAPI2.jsonRegex.test(mime);
526
+ }
527
+ async request(context, initOverrides) {
528
+ const { url, init } = await this.createFetchParams(context, initOverrides);
529
+ const response = await this.fetchApi(url, init);
530
+ if (response && (response.status >= 200 && response.status < 300)) {
531
+ return response;
532
+ }
533
+ throw new ResponseError2(response, "Response returned an error code");
534
+ }
535
+ async createFetchParams(context, initOverrides) {
536
+ let url = this.configuration.basePath + context.path;
537
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
538
+ url += "?" + this.configuration.queryParamsStringify(context.query);
539
+ }
540
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
541
+ Object.keys(headers).forEach((key) => headers[key] === undefined ? delete headers[key] : {});
542
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
543
+ const initParams = {
544
+ method: context.method,
545
+ headers,
546
+ body: context.body,
547
+ credentials: this.configuration.credentials
548
+ };
549
+ const overriddenInit = {
550
+ ...initParams,
551
+ ...await initOverrideFn({
552
+ init: initParams,
553
+ context
554
+ })
555
+ };
556
+ let body;
557
+ if (isFormData2(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob2(overriddenInit.body)) {
558
+ body = overriddenInit.body;
559
+ } else if (this.isJsonMime(headers["Content-Type"])) {
560
+ body = JSON.stringify(overriddenInit.body);
561
+ } else {
562
+ body = overriddenInit.body;
563
+ }
564
+ const init = {
565
+ ...overriddenInit,
566
+ body
567
+ };
568
+ return { url, init };
569
+ }
570
+ fetchApi = async (url, init) => {
571
+ let fetchParams = { url, init };
572
+ for (const middleware of this.middleware) {
573
+ if (middleware.pre) {
574
+ fetchParams = await middleware.pre({
575
+ fetch: this.fetchApi,
576
+ ...fetchParams
577
+ }) || fetchParams;
578
+ }
579
+ }
580
+ let response = undefined;
581
+ try {
582
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
583
+ } catch (e) {
584
+ for (const middleware of this.middleware) {
585
+ if (middleware.onError) {
586
+ response = await middleware.onError({
587
+ fetch: this.fetchApi,
588
+ url: fetchParams.url,
589
+ init: fetchParams.init,
590
+ error: e,
591
+ response: response ? response.clone() : undefined
592
+ }) || response;
593
+ }
594
+ }
595
+ if (response === undefined) {
596
+ if (e instanceof Error) {
597
+ throw new FetchError2(e, "The request failed and the interceptors did not return an alternative response");
598
+ } else {
599
+ throw e;
600
+ }
601
+ }
602
+ }
603
+ for (const middleware of this.middleware) {
604
+ if (middleware.post) {
605
+ response = await middleware.post({
606
+ fetch: this.fetchApi,
607
+ url: fetchParams.url,
608
+ init: fetchParams.init,
609
+ response: response.clone()
610
+ }) || response;
611
+ }
612
+ }
613
+ return response;
614
+ };
615
+ clone() {
616
+ const constructor = this.constructor;
617
+ const next = new constructor(this.configuration);
618
+ next.middleware = this.middleware.slice();
619
+ return next;
620
+ }
621
+ }
622
+ function isBlob2(value) {
623
+ return typeof Blob !== "undefined" && value instanceof Blob;
624
+ }
625
+ function isFormData2(value) {
626
+ return typeof FormData !== "undefined" && value instanceof FormData;
627
+ }
628
+
629
+ class ResponseError2 extends Error {
630
+ response;
631
+ name = "ResponseError";
632
+ constructor(response, msg) {
633
+ super(msg);
634
+ this.response = response;
635
+ }
636
+ }
637
+
638
+ class FetchError2 extends Error {
639
+ cause;
640
+ name = "FetchError";
641
+ constructor(cause, msg) {
642
+ super(msg);
643
+ this.cause = cause;
644
+ }
645
+ }
646
+ function querystring2(params, prefix = "") {
647
+ return Object.keys(params).map((key) => querystringSingleKey2(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
648
+ }
649
+ function querystringSingleKey2(key, value, keyPrefix = "") {
650
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
651
+ if (value instanceof Array) {
652
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
653
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
654
+ }
655
+ if (value instanceof Set) {
656
+ const valueAsArray = Array.from(value);
657
+ return querystringSingleKey2(key, valueAsArray, keyPrefix);
658
+ }
659
+ if (value instanceof Date) {
660
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
661
+ }
662
+ if (value instanceof Object) {
663
+ return querystring2(value, fullKey);
664
+ }
665
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
666
+ }
667
+ // ../solution-sdk/package.json
668
+ var package_default = {
669
+ name: "@uipath/solution-sdk",
670
+ author: "UiPath",
671
+ license: "SEE LICENSE IN LICENSE.txt",
672
+ version: "1.204.0-preview.250",
673
+ repository: {
674
+ type: "git",
675
+ url: "https://github.com/UiPath/cli.git",
676
+ directory: "packages/solution-sdk"
677
+ },
678
+ publishConfig: {
679
+ registry: "https://npm.pkg.github.com/@uipath"
680
+ },
681
+ keywords: [
682
+ "uipath",
683
+ "solution",
684
+ "sdk"
685
+ ],
686
+ type: "module",
687
+ main: "./dist/index.js",
688
+ types: "./dist/src/index.d.ts",
689
+ exports: {
690
+ ".": {
691
+ types: "./dist/src/index.d.ts",
692
+ default: "./dist/index.js"
693
+ },
694
+ "./resources": {
695
+ types: "./dist/src/resources/index.d.ts",
696
+ default: "./dist/resources/index.js"
697
+ },
698
+ "./auth": {
699
+ types: "./dist/src/solution-auth.d.ts",
700
+ default: "./dist/solution-auth.js"
701
+ }
702
+ },
703
+ bin: {
704
+ "generate-sdk": "./dist/scripts/generate-sdk.js"
705
+ },
706
+ files: [
707
+ "dist"
708
+ ],
709
+ private: false,
710
+ scripts: {
711
+ build: "bun build ./src/index.ts ./src/resources/index.ts ./src/solution-auth.ts --outdir dist --format esm --target node --splitting --sourcemap=linked && bun build ./src/scripts/generate-sdk.ts --outdir dist/scripts --format esm --target node --sourcemap=linked && tsc -p tsconfig.build.json --noCheck",
712
+ generate: "bun run src/scripts/generate-sdk.ts",
713
+ lint: "biome check .",
714
+ test: "vitest run",
715
+ "test:coverage": "vitest run --coverage"
716
+ },
717
+ devDependencies: {
718
+ "@openapitools/openapi-generator-cli": "^2.31.1",
719
+ "@uipath/auth": "workspace:*",
720
+ "@uipath/common": "workspace:*",
721
+ "@uipath/filesystem": "workspace:*",
722
+ "@uipath/orchestrator-sdk": "workspace:*",
723
+ "@uipath/resource-builder-sdk": "2025.11.0-alpha6004-4107",
724
+ "@uipath/solutionpackager-tool-core": "workspace:*",
725
+ "@uipath/studioweb-sdk": "workspace:*",
726
+ "@types/node": "^25.5.2",
727
+ fflate: "^0.8.2",
728
+ typescript: "^7.0.2"
729
+ }
730
+ };
731
+
732
+ // ../solution-sdk/src/user-agent.ts
733
+ var SDK_USER_AGENT = getSdkUserAgentToken(package_default);
734
+ installSdkUserAgentHeader(BaseAPI2, SDK_USER_AGENT);
735
+
736
+ // ../solution-sdk/src/upload-service.ts
737
+ class SolutionUploadHttpError extends Error {
738
+ status;
739
+ operation;
740
+ method;
741
+ endpoint;
742
+ url;
743
+ body;
744
+ solutionId;
745
+ parsedErrorCode;
746
+ parsedErrorMessage;
747
+ authChallenge;
748
+ constructor(details) {
749
+ super(details.message);
750
+ this.name = "SolutionUploadHttpError";
751
+ this.status = details.status;
752
+ this.operation = details.operation;
753
+ this.method = details.method;
754
+ this.endpoint = details.endpoint;
755
+ this.url = details.url;
756
+ this.body = details.body;
757
+ if (details.operation === "overwrite") {
758
+ this.solutionId = details.solutionId;
759
+ }
760
+ this.authChallenge = details.authChallenge;
761
+ const parsed = parseUploadErrorBody(details.body);
762
+ this.parsedErrorCode = parsed.code;
763
+ this.parsedErrorMessage = parsed.message;
764
+ }
765
+ }
766
+ function parseUploadErrorBody(body) {
767
+ const [, parsed] = catchError(() => JSON.parse(body));
768
+ if (!parsed || typeof parsed !== "object")
769
+ return {};
770
+ const rawCode = parsed.code ?? parsed.Code;
771
+ const rawMessage = parsed.message ?? parsed.Message;
772
+ return {
773
+ code: typeof rawCode === "string" || typeof rawCode === "number" ? String(rawCode) : undefined,
774
+ message: typeof rawMessage === "string" && rawMessage.trim() ? rawMessage : undefined
775
+ };
776
+ }
777
+ function isSolutionUploadHttpError(error) {
778
+ return error instanceof Error && error.name === "SolutionUploadHttpError" && "operation" in error && (error.operation === "import" || error.operation === "overwrite") && "status" in error && typeof error.status === "number" && "body" in error && typeof error.body === "string";
779
+ }
780
+ function requestPath(url) {
781
+ const [, parsed] = catchError(() => new URL(url));
782
+ return parsed ? `${parsed.pathname}${parsed.search}` : url;
783
+ }
784
+ var DEFAULT_UPLOAD_TIMEOUT_MS = 120000;
785
+ function resolveUploadTimeoutMs() {
786
+ const raw = Number(process.env?.UIPATH_SOLUTION_UPLOAD_TIMEOUT_MS);
787
+ return Number.isFinite(raw) && raw > 0 ? raw : DEFAULT_UPLOAD_TIMEOUT_MS;
788
+ }
789
+ function formatTimeout(timeoutMs) {
790
+ return timeoutMs < 1000 ? `${Math.round(timeoutMs)}ms` : `${Math.round(timeoutMs / 1000)}s`;
791
+ }
792
+ function timeoutMessage(what, timeoutMs) {
793
+ return `${what} timed out after ${formatTimeout(timeoutMs)} — the connection ` + `stalled with no response from Studio Web. Retry the command; if it keeps ` + `timing out, check connectivity (VPN/proxy) to the tenant, or raise the ` + `ceiling with UIPATH_SOLUTION_UPLOAD_TIMEOUT_MS.`;
794
+ }
795
+ function isTimeoutError(error) {
796
+ let current = error;
797
+ for (let depth = 0;depth < 5 && current instanceof Error; depth += 1) {
798
+ if (current.name === "TimeoutError")
799
+ return true;
800
+ current = current.cause;
801
+ }
802
+ return false;
803
+ }
804
+ async function fetchWithUploadTimeout(url, init, what) {
805
+ const timeoutMs = resolveUploadTimeoutMs();
806
+ const [error, response] = await catchError(fetch(url, { ...init, signal: AbortSignal.timeout(timeoutMs) }));
807
+ if (error) {
808
+ if (isTimeoutError(error)) {
809
+ throw new Error(timeoutMessage(what, timeoutMs));
810
+ }
811
+ throw error;
812
+ }
813
+ return response;
814
+ }
815
+ async function importSolution(config, organizationName, fileBuffer, fileName) {
816
+ const importUrl = `${config.baseUrl}/${encodeURIComponent(organizationName)}/studio_/backend/api/Solution/Import?desktopJit=true&useFileRest=true&enableUnifiedBuild=true`;
817
+ const formData = new FormData;
818
+ const fileBlob = new Blob([fileBuffer], {
819
+ type: "application/octet-stream"
820
+ });
821
+ formData.append("uploadFile", fileBlob, fileName);
822
+ formData.append("telemetryData", JSON.stringify({ FirstRun: false }));
823
+ const headers = addSdkUserAgentHeader({
824
+ Authorization: `Bearer ${config.authToken}`
825
+ }, SDK_USER_AGENT);
826
+ if (config.tenantId) {
827
+ headers["x-uipath-tenantid"] = config.tenantId;
828
+ }
829
+ const response = await fetchWithUploadTimeout(importUrl, { method: "POST", headers, body: formData }, "Studio Web solution import");
830
+ if (!response.ok) {
831
+ const text = await response.text().catch(() => "");
832
+ throw new SolutionUploadHttpError({
833
+ operation: "import",
834
+ status: response.status,
835
+ method: "POST",
836
+ endpoint: requestPath(importUrl),
837
+ url: importUrl,
838
+ body: text,
839
+ authChallenge: response.headers?.get("www-authenticate") ?? undefined,
840
+ message: `Import failed (${response.status}): ${text}`
841
+ });
842
+ }
843
+ return await response.json();
844
+ }
845
+ async function overwriteSolution(config, organizationName, fileBuffer, fileName, solutionId, createSnapshot = false) {
846
+ const overwriteUrl = `${config.baseUrl}/${encodeURIComponent(organizationName)}/studio_/backend/api/Solution/${encodeURIComponent(solutionId)}/Overwrite`;
847
+ const formData = new FormData;
848
+ const fileBlob = new Blob([fileBuffer], {
849
+ type: "application/octet-stream"
850
+ });
851
+ formData.append("UploadFile", fileBlob, fileName);
852
+ if (createSnapshot) {
853
+ formData.append("createSnapshot", "true");
854
+ }
855
+ const headers = addSdkUserAgentHeader({
856
+ Authorization: `Bearer ${config.authToken}`
857
+ }, SDK_USER_AGENT);
858
+ if (config.tenantId) {
859
+ headers["x-uipath-tenantid"] = config.tenantId;
860
+ }
861
+ const response = await fetchWithUploadTimeout(overwriteUrl, { method: "POST", headers, body: formData }, "Studio Web solution overwrite");
862
+ if (!response.ok) {
863
+ const text = await response.text().catch(() => "");
864
+ throw new SolutionUploadHttpError({
865
+ operation: "overwrite",
866
+ status: response.status,
867
+ method: "POST",
868
+ endpoint: requestPath(overwriteUrl),
869
+ url: overwriteUrl,
870
+ body: text,
871
+ authChallenge: response.headers?.get("www-authenticate") ?? undefined,
872
+ message: `Overwrite failed (${response.status}): ${text}`,
873
+ solutionId
874
+ });
875
+ }
876
+ return await response.json();
877
+ }
878
+ async function uploadOrOverwriteSolution(config, organizationName, fileBufferOrPath, solutionId, fs) {
879
+ let fileBuffer;
880
+ let fileName;
881
+ if (typeof fileBufferOrPath === "string") {
882
+ if (!fs) {
883
+ throw new Error("IFileSystem is required when passing a file path to uploadOrOverwriteSolution");
884
+ }
885
+ const content = await fs.readFile(fileBufferOrPath);
886
+ if (content === null) {
887
+ throw new Error(`Failed to read file: ${fileBufferOrPath}`);
888
+ }
889
+ fileBuffer = new Uint8Array(content);
890
+ fileName = fs.path.basename(fileBufferOrPath);
891
+ } else {
892
+ fileBuffer = fileBufferOrPath;
893
+ fileName = "solution.uis";
894
+ }
895
+ if (solutionId) {
896
+ logger.info(`Attempting to overwrite existing solution ${solutionId} on Studio Web...`);
897
+ const [overwriteError, overwriteResult] = await catchError(overwriteSolution(config, organizationName, fileBuffer, fileName, solutionId));
898
+ if (!overwriteError) {
899
+ logger.info("Solution overwritten successfully.");
900
+ return overwriteResult;
901
+ }
902
+ if (isSolutionUploadHttpError(overwriteError) && overwriteError.status === 404) {
903
+ logger.info(`Solution ${solutionId} not found on Studio Web. Importing as new solution...`);
904
+ } else {
905
+ throw overwriteError;
906
+ }
907
+ }
908
+ logger.info("Importing new solution to Studio Web...");
909
+ return importSolution(config, organizationName, fileBuffer, fileName);
910
+ }
911
+ // ../solution-sdk/src/project-debug-status.ts
912
+ var SUCCEEDED = "creationsucceeded";
913
+ var TERMINAL = new Set([SUCCEEDED, "creationfailed", "validationfailed"]);
914
+ export { buildSolutionPackageFromDir, uploadOrOverwriteSolution };
915
+
916
+ //# debugId=FC4BCF8EC5544B3364756E2164756E21