@uipath/codedapp-tool 1.206.0-preview.301 → 1.207.0-preview.305

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.
@@ -4,11 +4,12 @@ import {
4
4
  NugetConstants,
5
5
  ToolResult,
6
6
  NugetPackager,
7
+ MAX_IDENTITY_FILE_BYTES,
7
8
  ProjectTool
8
- } from "./packager-tool-5t7c439j.js";
9
+ } from "./packager-tool-tjb9qmzj.js";
9
10
  import {
10
11
  catchError
11
- } from "./packager-tool-z73h4t8a.js";
12
+ } from "./packager-tool-511nvmp8.js";
12
13
 
13
14
  // ../packager/packager-tool-webapp/src/models/webapp-manifest.ts
14
15
  var WebAppVariantType;
@@ -18,6 +19,58 @@ var WebAppVariantType;
18
19
  })(WebAppVariantType ||= {});
19
20
  var WEBAPP_MANIFEST_FILE_NAME = "webAppManifest.json";
20
21
 
22
+ // ../packager/packager-tool-webapp/src/utils/manifest-loader.ts
23
+ async function loadWebAppManifest(fileSystem, projectPath) {
24
+ const manifestPath = Path.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
25
+ const exists = await fileSystem.exists(manifestPath);
26
+ if (!exists) {
27
+ return null;
28
+ }
29
+ const content = await fileSystem.readFile(manifestPath);
30
+ if (!content) {
31
+ return null;
32
+ }
33
+ try {
34
+ const text = new TextDecoder().decode(content);
35
+ const manifest = JSON.parse(text);
36
+ return manifest;
37
+ } catch (error) {
38
+ throw new Error(`Failed to parse ${WEBAPP_MANIFEST_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
39
+ }
40
+ }
41
+ async function ensureWebAppProjectId(fileSystem, projectPath) {
42
+ const manifest = await loadWebAppManifest(fileSystem, projectPath);
43
+ if (manifest && typeof manifest.projectId === "string" && manifest.projectId.length > 0) {
44
+ return manifest.projectId;
45
+ }
46
+ const id = crypto.randomUUID();
47
+ if (manifest) {
48
+ const updated = { ...manifest, projectId: id };
49
+ const manifestPath = Path.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
50
+ await fileSystem.writeFile(manifestPath, `${JSON.stringify(updated, null, 2)}
51
+ `);
52
+ }
53
+ return id;
54
+ }
55
+
56
+ // ../packager/packager-tool-webapp/src/project-identity.ts
57
+ var readProjectIdentity = async (target, fs) => {
58
+ const projectDirectory = fs.path.resolve(target);
59
+ const base = { projectDirectory, projectType: "AppV2" /* AppV2 */ };
60
+ let manifest;
61
+ try {
62
+ const stat = await fs.stat(fs.path.join(projectDirectory, WEBAPP_MANIFEST_FILE_NAME));
63
+ if (stat && stat.size > MAX_IDENTITY_FILE_BYTES) {
64
+ return { ...base, status: "invalid" };
65
+ }
66
+ manifest = await loadWebAppManifest(fs, projectDirectory);
67
+ } catch {
68
+ return { ...base, status: "invalid" };
69
+ }
70
+ const id = manifest?.projectId;
71
+ return typeof id === "string" && id.length > 0 ? { ...base, id, status: "resolved" } : { ...base, status: "missing" };
72
+ };
73
+
21
74
  // ../packager/packager-tool-webapp/src/utils/bundle-path.ts
22
75
  function normalizeBundlePath(path) {
23
76
  return path.replace(/\\/g, "/");
@@ -97,6 +150,146 @@ var ERROR_MESSAGES = {
97
150
  OUTPUT_PATH_REQUIRED: "Output path is required"
98
151
  };
99
152
 
153
+ // ../packager/packager-tool-webapp/src/strategies/coded-app-build.ts
154
+ var LOCKFILE_INSTALLS = [
155
+ { lockfile: "package-lock.json", manager: "npm", install: ["ci"] },
156
+ { lockfile: "npm-shrinkwrap.json", manager: "npm", install: ["ci"] },
157
+ {
158
+ lockfile: "pnpm-lock.yaml",
159
+ manager: "pnpm",
160
+ install: ["install", "--frozen-lockfile"]
161
+ },
162
+ {
163
+ lockfile: "yarn.lock",
164
+ manager: "yarn",
165
+ install: ["install", "--frozen-lockfile"]
166
+ },
167
+ {
168
+ lockfile: "bun.lock",
169
+ manager: "bun",
170
+ install: ["install", "--frozen-lockfile"]
171
+ },
172
+ {
173
+ lockfile: "bun.lockb",
174
+ manager: "bun",
175
+ install: ["install", "--frozen-lockfile"]
176
+ }
177
+ ];
178
+ var OUTPUT_TAIL_LINES = 20;
179
+
180
+ class CodedAppNotPackableError extends Error {
181
+ instructions;
182
+ errorCode;
183
+ constructor(message, instructions, errorCode = "INVALID_PROJECT" /* InvalidProject */) {
184
+ super(message);
185
+ this.instructions = instructions;
186
+ this.errorCode = errorCode;
187
+ this.name = "CodedAppNotPackableError";
188
+ }
189
+ }
190
+ function bundleProblemInstructions(bundleFolder, source) {
191
+ const repoint = "point config.bundlePath in webAppManifest.json at the folder the app builds to";
192
+ switch (source) {
193
+ case "built":
194
+ return `The app's build ran but did not leave a usable app (with its HTML entry point) in ${bundleFolder}: make the build write there, or ${repoint}. Then pack again.`;
195
+ case "current":
196
+ return `${bundleFolder} is up to date with the app's sources, so pack did not build it, and it holds no usable app (with its HTML entry point). Delete ${bundleFolder} so pack builds it again, or ${repoint}. Then pack again.`;
197
+ case "no-build-script":
198
+ return `Add a "build" script to the app's package.json that writes ${bundleFolder}, so pack can build it, or ${repoint}. Then pack again.`;
199
+ case "not-building":
200
+ return `Build the app so its output lands in ${bundleFolder}, or ${repoint}. Then pack again.`;
201
+ }
202
+ }
203
+ async function planCodedAppBuildAsync(fileSystem, projectPath, bundlePath) {
204
+ const folder = await findPackageFolderAsync(fileSystem, projectPath, bundlePath);
205
+ if (folder === null)
206
+ return null;
207
+ const packageJsonPath = Path.join(folder, "package.json");
208
+ const content = await fileSystem.readFile(packageJsonPath);
209
+ let packageJson;
210
+ try {
211
+ packageJson = JSON.parse(new TextDecoder().decode(content ?? new Uint8Array));
212
+ } catch (error) {
213
+ throw new CodedAppNotPackableError(`${packageJsonPath} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`, `Fix ${packageJsonPath}, then pack again.`);
214
+ }
215
+ if (!hasBuildScript(packageJson))
216
+ return null;
217
+ for (const candidate of LOCKFILE_INSTALLS) {
218
+ if (await fileSystem.exists(Path.join(folder, candidate.lockfile))) {
219
+ return {
220
+ folder,
221
+ manager: candidate.manager,
222
+ lockfile: candidate.lockfile,
223
+ installArgs: candidate.install
224
+ };
225
+ }
226
+ }
227
+ return { folder, manager: "npm", installArgs: ["install"] };
228
+ }
229
+ async function runCodedAppBuildAsync(args) {
230
+ const { fileSystem, runner, plan, logger, signal } = args;
231
+ if (!await fileSystem.exists(Path.join(plan.folder, "node_modules"))) {
232
+ logger?.progress(`Installing coded app dependencies: ${plan.manager} ${plan.installArgs.join(" ")} (in ${plan.folder})`);
233
+ await runStepAsync(runner, plan, "install", plan.installArgs, signal);
234
+ }
235
+ logger?.progress(`Building coded app: ${plan.manager} run build (in ${plan.folder})`);
236
+ await runStepAsync(runner, plan, "build", ["run", "build"], signal);
237
+ }
238
+ async function runStepAsync(runner, plan, step, stepArgs, signal) {
239
+ const command = [plan.manager, ...stepArgs].join(" ");
240
+ const result = await runner.runAsync(plan.manager, stepArgs, {
241
+ cwd: plan.folder,
242
+ signal
243
+ });
244
+ signal?.throwIfAborted();
245
+ if (result.startError !== undefined) {
246
+ throw new CodedAppNotPackableError(`Could not start '${plan.manager}' to build the coded app in ${plan.folder}: ${result.startError}`, plan.lockfile === undefined || plan.manager === "npm" ? "Install Node.js (it ships npm) and make sure npm is on PATH, then pack again." : `Install ${plan.manager} (the app's ${plan.lockfile} asks for it) and make sure it is on PATH, then pack again.`);
247
+ }
248
+ if (result.exitCode !== 0) {
249
+ const tail = outputTail(result.output);
250
+ const shownTail = tail ? `
251
+ ${tail}` : "";
252
+ const exitCode = result.exitCode ?? "none (the process was killed)";
253
+ if (step === "install") {
254
+ throw new CodedAppNotPackableError(`Installing the coded app's dependencies in ${plan.folder} failed: '${command}' ended with exit code ${exitCode}.${shownTail}`, `If the output shows the package registry could not be reached, pack again once it can. Otherwise run '${command}' in ${plan.folder} and fix what it reports, then pack again.`, "DEPENDENCY_INSTALL_FAILED" /* DependencyInstallFailed */);
255
+ }
256
+ throw new CodedAppNotPackableError(`Building the coded app in ${plan.folder} failed: '${command}' ended with exit code ${exitCode}.${shownTail}`, `Run '${command}' in ${plan.folder} and fix what it reports, then pack again.`);
257
+ }
258
+ }
259
+ async function findPackageFolderAsync(fileSystem, projectPath, bundlePath) {
260
+ const root = trimTrailingSlashes(Path.normalize(projectPath));
261
+ let folder = isBundleRelativePath(bundlePath) ? Path.dirname(Path.join(root, normalizeBundlePath(bundlePath))) : root;
262
+ if (folder !== root && !folder.startsWith(`${root}/`))
263
+ folder = root;
264
+ for (;; ) {
265
+ if (await fileSystem.exists(Path.join(folder, "package.json"))) {
266
+ return folder;
267
+ }
268
+ if (folder === root)
269
+ return null;
270
+ folder = Path.dirname(folder);
271
+ }
272
+ }
273
+ function trimTrailingSlashes(path) {
274
+ let end = path.length;
275
+ while (end > 0 && path[end - 1] === "/")
276
+ end -= 1;
277
+ return path.slice(0, end);
278
+ }
279
+ function hasBuildScript(packageJson) {
280
+ if (typeof packageJson !== "object" || packageJson === null)
281
+ return false;
282
+ const scripts = packageJson.scripts;
283
+ if (typeof scripts !== "object" || scripts === null)
284
+ return false;
285
+ const build = scripts.build;
286
+ return typeof build === "string" && build.trim() !== "";
287
+ }
288
+ function outputTail(output) {
289
+ return output.trimEnd().split(/\r?\n/).slice(-OUTPUT_TAIL_LINES).join(`
290
+ `);
291
+ }
292
+
100
293
  // ../packager/packager-tool-webapp/src/utils/fs-helpers.ts
101
294
  async function copyDirectoryAsync(fileSystem, sourcePath, destinationPath) {
102
295
  await fileSystem.mkdir(destinationPath);
@@ -116,45 +309,86 @@ async function copyDirectoryAsync(fileSystem, sourcePath, destinationPath) {
116
309
  }
117
310
  }
118
311
 
119
- // ../packager/packager-tool-webapp/src/utils/manifest-loader.ts
120
- async function loadWebAppManifest(fileSystem, projectPath) {
121
- const manifestPath = Path.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
122
- const exists = await fileSystem.exists(manifestPath);
123
- if (!exists) {
124
- return null;
125
- }
126
- const content = await fileSystem.readFile(manifestPath);
127
- if (!content) {
312
+ // ../packager/packager-tool-webapp/src/strategies/coded-app-build-stamp.ts
313
+ var BUILD_STAMP_FILE_NAME = ".uipath-build.json";
314
+ var SKIPPED_DIRECTORY_NAMES = new Set([
315
+ "node_modules",
316
+ ".git"
317
+ ]);
318
+ async function isBuildCurrentAsync(fileSystem, plan, bundleFolder) {
319
+ const stamped = await readStampAsync(fileSystem, plan.folder);
320
+ if (stamped === null)
321
+ return false;
322
+ return stamped === await fingerprintAsync(fileSystem, plan, bundleFolder) && await fileSystem.exists(bundleFolder);
323
+ }
324
+ async function writeBuildStampAsync(fileSystem, plan, bundleFolder) {
325
+ const fingerprint = await fingerprintAsync(fileSystem, plan, bundleFolder);
326
+ await fileSystem.writeFile(Path.join(plan.folder, BUILD_STAMP_FILE_NAME), JSON.stringify({ fingerprint }, null, 4));
327
+ }
328
+ async function readStampAsync(fileSystem, folder) {
329
+ const content = await fileSystem.readFile(Path.join(folder, BUILD_STAMP_FILE_NAME), "utf-8");
330
+ if (content === null)
128
331
  return null;
129
- }
130
332
  try {
131
- const text = new TextDecoder().decode(content);
132
- const manifest = JSON.parse(text);
133
- return manifest;
134
- } catch (error) {
135
- throw new Error(`Failed to parse ${WEBAPP_MANIFEST_FILE_NAME}: ${error instanceof Error ? error.message : String(error)}`);
333
+ const stamp = JSON.parse(content);
334
+ const fingerprint = typeof stamp === "object" && stamp !== null ? stamp.fingerprint : undefined;
335
+ return typeof fingerprint === "string" ? fingerprint : null;
336
+ } catch {
337
+ return null;
136
338
  }
137
339
  }
138
- async function ensureWebAppProjectId(fileSystem, projectPath) {
139
- const manifest = await loadWebAppManifest(fileSystem, projectPath);
140
- if (manifest && typeof manifest.projectId === "string" && manifest.projectId.length > 0) {
141
- return manifest.projectId;
142
- }
143
- const id = crypto.randomUUID();
144
- if (manifest) {
145
- const updated = { ...manifest, projectId: id };
146
- const manifestPath = Path.join(projectPath, WEBAPP_MANIFEST_FILE_NAME);
147
- await fileSystem.writeFile(manifestPath, `${JSON.stringify(updated, null, 2)}
148
- `);
149
- }
150
- return id;
340
+ async function fingerprintAsync(fileSystem, plan, bundleFolder) {
341
+ const root = Path.normalize(plan.folder);
342
+ const bundle = Path.normalize(bundleFolder);
343
+ const files = await listAppFilesAsync(fileSystem, root, bundle);
344
+ const digests = [];
345
+ for (const relativePath of files) {
346
+ const content = await fileSystem.readFile(Path.join(root, relativePath)) ?? new Uint8Array;
347
+ digests.push(`${relativePath} ${await sha256Hex(content)}`);
348
+ }
349
+ return sha256Hex(new TextEncoder().encode(digests.join(`
350
+ `)));
351
+ }
352
+ async function listAppFilesAsync(fileSystem, root, bundleFolder) {
353
+ const files = [];
354
+ const visit = async (directory, prefix) => {
355
+ for (const name of await fileSystem.readdir(directory)) {
356
+ const path = Path.join(directory, name);
357
+ const relativePath = prefix === "" ? name : `${prefix}/${name}`;
358
+ if (path === bundleFolder)
359
+ continue;
360
+ if (relativePath === BUILD_STAMP_FILE_NAME)
361
+ continue;
362
+ const stats = await fileSystem.stat(path);
363
+ if (stats?.isDirectory()) {
364
+ if (SKIPPED_DIRECTORY_NAMES.has(name))
365
+ continue;
366
+ await visit(path, relativePath);
367
+ } else {
368
+ files.push(relativePath);
369
+ }
370
+ }
371
+ };
372
+ await visit(root, "");
373
+ return files.sort(compareCodeUnits);
374
+ }
375
+ function compareCodeUnits(a, b) {
376
+ if (a < b)
377
+ return -1;
378
+ return a > b ? 1 : 0;
379
+ }
380
+ async function sha256Hex(bytes) {
381
+ const digest = await crypto.subtle.digest("SHA-256", new Uint8Array(bytes));
382
+ return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
151
383
  }
152
384
 
153
385
  // ../packager/packager-tool-webapp/src/strategies/coded-app-strategy.ts
154
386
  class CodedAppStrategy {
155
387
  fileSystem;
156
- constructor(fileSystem) {
388
+ commandRunner;
389
+ constructor(fileSystem, commandRunner) {
157
390
  this.fileSystem = fileSystem;
391
+ this.commandRunner = commandRunner;
158
392
  }
159
393
  async validateAsync(args) {
160
394
  const { projectPath, manifest, logger } = args;
@@ -164,8 +398,12 @@ class CodedAppStrategy {
164
398
  bundlePath = DEFAULT_BUNDLE_PATH;
165
399
  }
166
400
  const isCompiled = typed.config?.isCompiled ?? true;
167
- if (isCompiled) {
168
- const fullBundlePath = Path.join(projectPath, bundlePath);
401
+ if (!isCompiled)
402
+ return;
403
+ const fullBundlePath = Path.join(projectPath, bundlePath);
404
+ const plan = this.commandRunner === undefined ? null : await planCodedAppBuildAsync(this.fileSystem, projectPath, bundlePath);
405
+ const packWillBuild = plan !== null && !await isBuildCurrentAsync(this.fileSystem, plan, fullBundlePath);
406
+ if (!packWillBuild) {
169
407
  const message = await this.describeBundleProblemAsync(fullBundlePath, typed.config?.mainFile);
170
408
  if (message) {
171
409
  const warnable = logger;
@@ -191,19 +429,8 @@ class CodedAppStrategy {
191
429
  throw new Error(ERROR_MESSAGES.BUNDLE_OUTSIDE_PROJECT(bundlePath));
192
430
  }
193
431
  if (isCompiled) {
194
- logger?.progress("Validating compiled bundle...");
195
- const bundleExists = await this.fileSystem.exists(fullBundlePath);
196
- if (!bundleExists) {
197
- throw new Error(ERROR_MESSAGES.BUNDLE_NOT_FOUND(fullBundlePath));
198
- }
199
- const bundleStat = await this.fileSystem.stat(fullBundlePath);
200
- if (!bundleStat?.isDirectory()) {
201
- throw new Error(ERROR_MESSAGES.BUNDLE_NOT_DIRECTORY(fullBundlePath));
202
- }
203
- const problem = await this.describeBundleEntryProblemAsync(fullBundlePath, declaredMainFile);
204
- if (problem) {
205
- throw new Error(problem);
206
- }
432
+ const bundleSource = await this.prepareBundleAsync(args, bundlePath, fullBundlePath);
433
+ await this.assertBundlePackableAsync(fullBundlePath, declaredMainFile, bundleSource, logger);
207
434
  } else {
208
435
  logger?.info("Build mode (isCompiled=false) is not yet implemented in v1.");
209
436
  throw new Error(ERROR_MESSAGES.BUILD_NOT_SUPPORTED);
@@ -231,6 +458,42 @@ class CodedAppStrategy {
231
458
  }
232
459
  }
233
460
  }
461
+ async prepareBundleAsync(args, bundlePath, fullBundlePath) {
462
+ const runner = args.buildApp ? this.commandRunner : undefined;
463
+ if (runner === undefined)
464
+ return "not-building";
465
+ const plan = await planCodedAppBuildAsync(this.fileSystem, args.projectPath, bundlePath);
466
+ if (plan === null)
467
+ return "no-build-script";
468
+ if (await isBuildCurrentAsync(this.fileSystem, plan, fullBundlePath)) {
469
+ args.logger?.info(`Skipping build: ${bundlePath} was built from the app's current sources`);
470
+ return "current";
471
+ }
472
+ await runCodedAppBuildAsync({
473
+ fileSystem: this.fileSystem,
474
+ runner,
475
+ plan,
476
+ logger: args.logger,
477
+ signal: args.signal
478
+ });
479
+ await writeBuildStampAsync(this.fileSystem, plan, fullBundlePath);
480
+ return "built";
481
+ }
482
+ async assertBundlePackableAsync(fullBundlePath, declaredMainFile, bundleSource, logger) {
483
+ logger?.progress("Validating compiled bundle...");
484
+ const bundleExists = await this.fileSystem.exists(fullBundlePath);
485
+ if (!bundleExists) {
486
+ throw new CodedAppNotPackableError(ERROR_MESSAGES.BUNDLE_NOT_FOUND(fullBundlePath), bundleProblemInstructions(fullBundlePath, bundleSource));
487
+ }
488
+ const bundleStat = await this.fileSystem.stat(fullBundlePath);
489
+ if (!bundleStat?.isDirectory()) {
490
+ throw new CodedAppNotPackableError(ERROR_MESSAGES.BUNDLE_NOT_DIRECTORY(fullBundlePath), bundleProblemInstructions(fullBundlePath, bundleSource));
491
+ }
492
+ const problem = await this.describeBundleEntryProblemAsync(fullBundlePath, declaredMainFile);
493
+ if (problem) {
494
+ throw new CodedAppNotPackableError(problem, bundleProblemInstructions(fullBundlePath, bundleSource));
495
+ }
496
+ }
234
497
  async prepareMetadataFiles(_localBuildFolder, contentFolder, _packageInfo, manifest, projectPath, sourceBundlePath) {
235
498
  const declaredMainFile = manifest.config?.mainFile;
236
499
  const mainFile = await this.resolveMainFileAsync(contentFolder, declaredMainFile);
@@ -610,11 +873,11 @@ class JsAppsStrategy {
610
873
 
611
874
  // ../packager/packager-tool-webapp/src/strategies/variant-strategy-factory.ts
612
875
  class VariantStrategyFactory {
613
- static createStrategy(manifest, fileSystem) {
876
+ static createStrategy(manifest, fileSystem, commandRunner) {
614
877
  const variant = manifest.type;
615
878
  switch (variant) {
616
879
  case "Coded" /* Coded */:
617
- return new CodedAppStrategy(fileSystem);
880
+ return new CodedAppStrategy(fileSystem, commandRunner);
618
881
  case "JS" /* JS */:
619
882
  return new JsAppsStrategy(fileSystem);
620
883
  default:
@@ -625,10 +888,12 @@ class VariantStrategyFactory {
625
888
 
626
889
  // ../packager/packager-tool-webapp/src/webapp-tool.ts
627
890
  class WebAppTool extends ProjectTool {
891
+ commandRunner;
628
892
  _temporaryStorage;
629
893
  _tempBuildFolder = null;
630
- constructor(fileSystem, logger) {
894
+ constructor(fileSystem, logger, commandRunner) {
631
895
  super(fileSystem, logger);
896
+ this.commandRunner = commandRunner;
632
897
  this._temporaryStorage = new TemporaryStorageService(fileSystem);
633
898
  }
634
899
  async restoreAsync(_options, _cancellationToken) {
@@ -672,7 +937,7 @@ class WebAppTool extends ProjectTool {
672
937
  this.logger.info("Build operation for WebApp is lightweight (metadata preparation only)");
673
938
  return ToolResult.success();
674
939
  }
675
- async packAsync(options, _cancellationToken) {
940
+ async packAsync(options, cancellationToken) {
676
941
  if (!options.projectPath) {
677
942
  return this.handleError(new Error(ERROR_MESSAGES.PROJECT_PATH_REQUIRED), "Packing");
678
943
  }
@@ -702,11 +967,16 @@ class WebAppTool extends ProjectTool {
702
967
  manifest,
703
968
  outputPath: options.outputPath,
704
969
  packageInfo: options.package,
970
+ buildApp: options.codedBundle === undefined && options.skipBuild !== true,
971
+ signal: cancellationToken,
705
972
  logger: this.createStrategyLogger()
706
973
  });
707
974
  this.logger.info(`WebApp package created successfully: ${nupkgPath}`);
708
975
  return new ToolResult("SUCCESS" /* Success */, "done", [nupkgPath]);
709
976
  } catch (error) {
977
+ if (cancellationToken?.aborted) {
978
+ return ToolResult.error("CANCELED" /* Canceled */, ERROR_MESSAGES.PACKING_FAILED("the pack was canceled"));
979
+ }
710
980
  return this.handleError(error, `Packing WebApp project '${options.package.id}'`);
711
981
  }
712
982
  }
@@ -747,7 +1017,7 @@ class WebAppTool extends ProjectTool {
747
1017
  config: { ...manifest.config, ...codedBundle }
748
1018
  };
749
1019
  }
750
- const strategy = VariantStrategyFactory.createStrategy(manifest, this.fileSystem);
1020
+ const strategy = VariantStrategyFactory.createStrategy(manifest, this.fileSystem, this.commandRunner);
751
1021
  return { manifest, strategy };
752
1022
  }
753
1023
  handleError(error, context) {
@@ -761,6 +1031,9 @@ class WebAppTool extends ProjectTool {
761
1031
  } else {
762
1032
  userMessage = errorMessage;
763
1033
  }
1034
+ if (error instanceof CodedAppNotPackableError) {
1035
+ return ToolResult.error(error.errorCode, userMessage, error.instructions);
1036
+ }
764
1037
  return ToolResult.error("INTERNAL_ERROR" /* InternalError */, userMessage);
765
1038
  }
766
1039
  createStrategyLogger() {
@@ -775,9 +1048,14 @@ class WebAppTool extends ProjectTool {
775
1048
 
776
1049
  // ../packager/packager-tool-webapp/src/webapp-tool-factory.ts
777
1050
  class WebAppToolFactory {
1051
+ commandRunner;
1052
+ readProjectIdentityAsync = readProjectIdentity;
778
1053
  supportedTypes = ["AppV2" /* AppV2 */];
1054
+ constructor(commandRunner) {
1055
+ this.commandRunner = commandRunner;
1056
+ }
779
1057
  async createAsync(logger, fileSystem) {
780
- return new WebAppTool(fileSystem, logger);
1058
+ return new WebAppTool(fileSystem, logger, this.commandRunner);
781
1059
  }
782
1060
  }
783
1061
 
@@ -6635,6 +6913,228 @@ class WebAppContributingToolFactory extends WebAppToolFactory {
6635
6913
  return describeActionApp(projectDir, fs);
6636
6914
  }
6637
6915
  }
6638
- export { WEBAPP_MANIFEST_FILE_NAME, ACTION_SCHEMA_FILE_NAME, isActionApp, readProjectName, parseActionSchema, validateActionSchema, normalizeBundlePath, isBundleRelativePath, isCanonicalBundleChild, isHtmlEntryPointPath, resolveHtmlEntryPoint, HTML_ENTRY_POINT_CANDIDATES, ERROR_MESSAGES, WebAppToolFactory, WebAppContributingToolFactory };
6916
+ // ../packager/packager-tool-webapp/src/action-schema/duplicate-property-names.ts
6917
+ var ROOT_SECTIONS = [
6918
+ "inputs",
6919
+ "outputs",
6920
+ "inOuts",
6921
+ "outcomes"
6922
+ ];
6923
+ function findDuplicateActionPropertyNames(raw) {
6924
+ const schema = JsonActionSchemaValidator.parse(JSON.parse(raw));
6925
+ const sectionsByName = new Map;
6926
+ for (const section of ROOT_SECTIONS) {
6927
+ for (const name of Object.keys(schema[section].properties)) {
6928
+ const sections = sectionsByName.get(name) ?? [];
6929
+ sections.push(section);
6930
+ sectionsByName.set(name, sections);
6931
+ }
6932
+ }
6933
+ return [...sectionsByName].filter(([, sections]) => sections.length > 1).map(([name, sections]) => ({ name, sections }));
6934
+ }
6935
+ function describeDuplicateActionPropertyNames(duplicates) {
6936
+ return duplicates.map(({ name, sections }) => `'${name}' in ${joinWithAnd(sections)}`).join(", ");
6937
+ }
6938
+ function joinWithAnd(items) {
6939
+ return `${items.slice(0, -1).join(", ")} and ${items[items.length - 1]}`;
6940
+ }
6941
+ // src/constants/auth.ts
6942
+ var AUTH_CONSTANTS = {
6943
+ FILES: {
6944
+ UIPATH_DIR: ".uipath",
6945
+ APP_CONFIG: "app.config.json",
6946
+ AUTH_FILE: ".auth.json",
6947
+ ENV_FILE: ".env",
6948
+ METADATA_FILE: "metadata.json",
6949
+ SDK_CONFIG: "uipath.json"
6950
+ },
6951
+ DOMAINS: {
6952
+ CLOUD: "cloud",
6953
+ ALPHA: "alpha",
6954
+ STAGING: "staging"
6955
+ },
6956
+ TIMEOUTS: {
6957
+ SERVER_SHUTDOWN_DELAY: 1000,
6958
+ AUTH_TIMEOUT: 5 * 60 * 1000
6959
+ },
6960
+ CONVERSION: {
6961
+ SECONDS_TO_MS: 1000
6962
+ },
6963
+ HTTP_STATUS: {
6964
+ OK: 200,
6965
+ NO_CONTENT: 204,
6966
+ BAD_REQUEST: 400,
6967
+ UNAUTHORIZED: 401,
6968
+ CONFLICT: 409
6969
+ },
6970
+ ERROR_CODES: {
6971
+ PACKAGE_ALREADY_EXISTS: 1004
6972
+ },
6973
+ CONTENT_TYPES: {
6974
+ JSON: "application/json",
6975
+ OCTET_STREAM: "application/octet-stream",
6976
+ FORM_URLENCODED: "application/x-www-form-urlencoded",
6977
+ TEXT_HTML: "text/html"
6978
+ },
6979
+ ROUTES: {
6980
+ OIDC_LOGIN: "/oidc/login",
6981
+ TOKEN: "/token",
6982
+ ERROR: "/error",
6983
+ HEALTH: "/health"
6984
+ },
6985
+ ERRORS: {
6986
+ EADDRINUSE: "EADDRINUSE"
6987
+ },
6988
+ CRYPTO: {
6989
+ RANDOM_BYTES_LENGTH: 32
6990
+ },
6991
+ JWT: {
6992
+ PARTS_COUNT: 3
6993
+ },
6994
+ UI: {
6995
+ SKIP_SELECTION: "__skip__",
6996
+ SKIP_LABEL: "⏭ Skip folder selection",
6997
+ PAGE_SIZE: 10
6998
+ },
6999
+ ENV_CONFIG: {
7000
+ BASE_URL: {
7001
+ envVar: "UIPATH_BASE_URL",
7002
+ altEnvVar: "UIPATH_URL",
7003
+ configKey: "baseUrl",
7004
+ flag: "--baseUrl",
7005
+ example: "'https://cloud.uipath.com'"
7006
+ },
7007
+ ORG_ID: {
7008
+ envVar: "UIPATH_ORG_ID",
7009
+ altEnvVar: "UIPATH_ORGANIZATION_ID",
7010
+ configKey: "orgId",
7011
+ flag: "--orgId",
7012
+ example: "'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
7013
+ },
7014
+ TENANT_ID: {
7015
+ envVar: "UIPATH_TENANT_ID",
7016
+ configKey: "tenantId",
7017
+ flag: "--tenantId",
7018
+ example: "'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
7019
+ },
7020
+ TENANT_NAME: {
7021
+ envVar: "UIPATH_TENANT_NAME",
7022
+ configKey: "tenantName",
7023
+ flag: "--tenantName",
7024
+ example: "'YourTenantName'"
7025
+ },
7026
+ FOLDER_KEY: {
7027
+ envVar: "UIPATH_FOLDER_KEY",
7028
+ configKey: "folderKey",
7029
+ flag: "--folderKey",
7030
+ example: "'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'"
7031
+ },
7032
+ ACCESS_TOKEN: {
7033
+ envVar: "UIPATH_ACCESS_TOKEN",
7034
+ configKey: "accessToken",
7035
+ flag: "--accessToken",
7036
+ example: "'your-access-token'"
7037
+ },
7038
+ ORG_NAME: {
7039
+ envVar: "UIPATH_ORG_NAME",
7040
+ configKey: "orgName",
7041
+ flag: "--orgName",
7042
+ example: "'YourOrgName'"
7043
+ }
7044
+ },
7045
+ REQUIRED_ENV_VARS: {
7046
+ PUBLISH: [
7047
+ "UIPATH_BASE_URL",
7048
+ "UIPATH_ORG_ID",
7049
+ "UIPATH_TENANT_ID",
7050
+ "UIPATH_TENANT_NAME",
7051
+ "UIPATH_ACCESS_TOKEN"
7052
+ ],
7053
+ DEPLOY: [
7054
+ "UIPATH_BASE_URL",
7055
+ "UIPATH_ORG_ID",
7056
+ "UIPATH_ORG_NAME",
7057
+ "UIPATH_TENANT_ID",
7058
+ "UIPATH_FOLDER_KEY",
7059
+ "UIPATH_ACCESS_TOKEN"
7060
+ ],
7061
+ PACK: [
7062
+ "UIPATH_BASE_URL",
7063
+ "UIPATH_ORG_ID",
7064
+ "UIPATH_TENANT_ID",
7065
+ "UIPATH_ACCESS_TOKEN"
7066
+ ],
7067
+ PUSH: [
7068
+ "UIPATH_BASE_URL",
7069
+ "UIPATH_ORG_ID",
7070
+ "UIPATH_TENANT_ID",
7071
+ "UIPATH_ACCESS_TOKEN"
7072
+ ],
7073
+ PULL: [
7074
+ "UIPATH_BASE_URL",
7075
+ "UIPATH_ORG_ID",
7076
+ "UIPATH_TENANT_ID",
7077
+ "UIPATH_ACCESS_TOKEN"
7078
+ ],
7079
+ PATH_NAME_CHECK: [
7080
+ "UIPATH_BASE_URL",
7081
+ "UIPATH_ORG_ID",
7082
+ "UIPATH_ACCESS_TOKEN"
7083
+ ],
7084
+ DELETE: [
7085
+ "UIPATH_BASE_URL",
7086
+ "UIPATH_ORG_ID",
7087
+ "UIPATH_TENANT_ID",
7088
+ "UIPATH_FOLDER_KEY",
7089
+ "UIPATH_ACCESS_TOKEN"
7090
+ ]
7091
+ },
7092
+ API_ENDPOINTS: {
7093
+ FOLDERS_NAVIGATION: "/Folders/GetAllForCurrentUser",
7094
+ TENANTS_AND_ORG: "/filtering/leftnav/tenantsAndOrganizationInfo"
7095
+ },
7096
+ IDENTITY_ENDPOINTS: {
7097
+ AUTHORIZE: "/identity_/connect/authorize",
7098
+ TOKEN: "/identity_/connect/token"
7099
+ },
7100
+ SERVICE_PATHS: {
7101
+ PORTAL_API: "/portal_/api",
7102
+ ORCHESTRATOR_API: "/orchestrator_/api"
7103
+ },
7104
+ DEFAULT_PORT: 8104,
7105
+ ALTERNATIVE_PORTS: [8104, 8055, 42042],
7106
+ PORT_CHECK_HOSTS: ["localhost", "127.0.0.1", "::1"],
7107
+ RATE_LIMIT: {
7108
+ WINDOW_MS: 60 * 1000,
7109
+ AUTH_MAX_REQUESTS: 10,
7110
+ TOKEN_MAX_REQUESTS: 5,
7111
+ ERROR_MAX_REQUESTS: 20
7112
+ },
7113
+ CORS: {
7114
+ HEADERS: {
7115
+ ALLOW_ORIGIN: "Access-Control-Allow-Origin",
7116
+ ALLOW_METHODS: "Access-Control-Allow-Methods",
7117
+ ALLOW_HEADERS: "Access-Control-Allow-Headers"
7118
+ },
7119
+ VALUES: {
7120
+ ORIGIN: "null",
7121
+ METHODS: "GET, POST, OPTIONS",
7122
+ HEADERS: "Content-Type"
7123
+ },
7124
+ ALLOWED_ORIGINS: [
7125
+ "http://localhost",
7126
+ "http://127.0.0.1",
7127
+ "https://localhost",
7128
+ "https://127.0.0.1"
7129
+ ]
7130
+ }
7131
+ };
7132
+ var BASE_URLS = {
7133
+ alpha: "https://alpha.uipath.com",
7134
+ cloud: "https://cloud.uipath.com",
7135
+ staging: "https://staging.uipath.com"
7136
+ };
7137
+
7138
+ export { WEBAPP_MANIFEST_FILE_NAME, ACTION_SCHEMA_FILE_NAME, isActionApp, readProjectName, parseActionSchema, validateActionSchema, findDuplicateActionPropertyNames, describeDuplicateActionPropertyNames, readProjectIdentity, normalizeBundlePath, isBundleRelativePath, isCanonicalBundleChild, isHtmlEntryPointPath, resolveHtmlEntryPoint, HTML_ENTRY_POINT_CANDIDATES, ERROR_MESSAGES, WebAppToolFactory, WebAppContributingToolFactory, AUTH_CONSTANTS, BASE_URLS };
6639
7139
 
6640
- //# debugId=48C3608764F5C28964756E2164756E21
7140
+ //# debugId=F026AA06FF4255E764756E2164756E21