@uipath/solution-packager 0.0.34 → 1.197.0-preview.64

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 (26) hide show
  1. package/dist/index.js +239 -95
  2. package/dist/node.js +239 -41
  3. package/dist/src/browser-solution-packager-factory.d.ts +11 -4
  4. package/dist/src/i18n/locales/en.d.ts +3 -0
  5. package/dist/src/node-solution-packager-factory.d.ts +0 -1
  6. package/dist/src/services/options-builder.d.ts +6 -1
  7. package/dist/src/services/solution-loader.d.ts +1 -1
  8. package/dist/src/services/solution-pack-service.d.ts +24 -12
  9. package/dist/src/services/solution-packager.d.ts +15 -12
  10. package/dist/src/services/solution-restore-service.d.ts +23 -0
  11. package/dist/src/services/tool-result-helpers.d.ts +10 -0
  12. package/dist/src/telemetry-names.d.ts +2 -0
  13. package/dist/tests/solution-validate-options-validator.spec.d.ts +1 -0
  14. package/dist/tests/solution-validate-service.spec.d.ts +1 -0
  15. package/dist/tests/zip-temp-storage.integration.test.d.ts +1 -0
  16. package/package.json +35 -74
  17. package/dist/tests/solution-packager-e2e.test.d.ts +0 -9
  18. /package/dist/tests/{browser.test.d.ts → browser.spec.d.ts} +0 -0
  19. /package/dist/tests/{common.test.d.ts → common.spec.d.ts} +0 -0
  20. /package/dist/tests/{node.test.d.ts → node.spec.d.ts} +0 -0
  21. /package/dist/tests/{solution-pack-service.test.d.ts → options-builder.spec.d.ts} +0 -0
  22. /package/dist/tests/{solution-loader.test.d.ts → solution-loader.spec.d.ts} +0 -0
  23. /package/dist/tests/{solution-validate-options-validator.test.d.ts → solution-pack-service.spec.d.ts} +0 -0
  24. /package/dist/tests/{solution-validate-service.test.d.ts → solution-packager.e2e.test.d.ts} +0 -0
  25. /package/dist/tests/{solution-packager.test.d.ts → solution-packager.spec.d.ts} +0 -0
  26. /package/dist/tests/{zip-temp-storage-integration.test.d.ts → solution-restore-service.spec.d.ts} +0 -0
package/dist/index.js CHANGED
@@ -8,6 +8,9 @@ var de_default = {
8
8
  pathRequired: "Solution directory path is required",
9
9
  fileNotFound: "Solution file not found: {path}",
10
10
  invalidSolution: "Invalid solution file: {path}",
11
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
12
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
13
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
11
14
  noSolutionFile: "No .uipx solution file found in directory: {path}",
12
15
  invalidStorageFile: "Invalid {fileName} file"
13
16
  }
@@ -30,6 +33,9 @@ var en = {
30
33
  pathRequired: "Solution directory path is required",
31
34
  fileNotFound: "Solution file not found: {path}",
32
35
  invalidSolution: "Invalid solution file: {path}",
36
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
37
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
38
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
33
39
  noSolutionFile: "No .uipx solution file found in directory: {path}",
34
40
  invalidStorageFile: "Invalid {fileName} file"
35
41
  }
@@ -51,6 +57,9 @@ var es_default = {
51
57
  pathRequired: "Solution directory path is required",
52
58
  fileNotFound: "Solution file not found: {path}",
53
59
  invalidSolution: "Invalid solution file: {path}",
60
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
61
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
62
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
54
63
  noSolutionFile: "No .uipx solution file found in directory: {path}",
55
64
  invalidStorageFile: "Invalid {fileName} file"
56
65
  }
@@ -72,6 +81,9 @@ var es_MX_default = {
72
81
  pathRequired: "Solution directory path is required",
73
82
  fileNotFound: "Solution file not found: {path}",
74
83
  invalidSolution: "Invalid solution file: {path}",
84
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
85
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
86
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
75
87
  noSolutionFile: "No .uipx solution file found in directory: {path}",
76
88
  invalidStorageFile: "Invalid {fileName} file"
77
89
  }
@@ -93,6 +105,9 @@ var fr_default = {
93
105
  pathRequired: "Solution directory path is required",
94
106
  fileNotFound: "Solution file not found: {path}",
95
107
  invalidSolution: "Invalid solution file: {path}",
108
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
109
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
110
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
96
111
  noSolutionFile: "No .uipx solution file found in directory: {path}",
97
112
  invalidStorageFile: "Invalid {fileName} file"
98
113
  }
@@ -114,6 +129,9 @@ var ja_default = {
114
129
  pathRequired: "Solution directory path is required",
115
130
  fileNotFound: "Solution file not found: {path}",
116
131
  invalidSolution: "Invalid solution file: {path}",
132
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
133
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
134
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
117
135
  noSolutionFile: "No .uipx solution file found in directory: {path}",
118
136
  invalidStorageFile: "Invalid {fileName} file"
119
137
  }
@@ -135,6 +153,9 @@ var ko_default = {
135
153
  pathRequired: "Solution directory path is required",
136
154
  fileNotFound: "Solution file not found: {path}",
137
155
  invalidSolution: "Invalid solution file: {path}",
156
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
157
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
158
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
138
159
  noSolutionFile: "No .uipx solution file found in directory: {path}",
139
160
  invalidStorageFile: "Invalid {fileName} file"
140
161
  }
@@ -156,6 +177,9 @@ var pt_default = {
156
177
  pathRequired: "Solution directory path is required",
157
178
  fileNotFound: "Solution file not found: {path}",
158
179
  invalidSolution: "Invalid solution file: {path}",
180
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
181
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
182
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
159
183
  noSolutionFile: "No .uipx solution file found in directory: {path}",
160
184
  invalidStorageFile: "Invalid {fileName} file"
161
185
  }
@@ -177,6 +201,9 @@ var pt_BR_default = {
177
201
  pathRequired: "Solution directory path is required",
178
202
  fileNotFound: "Solution file not found: {path}",
179
203
  invalidSolution: "Invalid solution file: {path}",
204
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
205
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
206
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
180
207
  noSolutionFile: "No .uipx solution file found in directory: {path}",
181
208
  invalidStorageFile: "Invalid {fileName} file"
182
209
  }
@@ -198,6 +225,9 @@ var ro_default = {
198
225
  pathRequired: "Solution directory path is required",
199
226
  fileNotFound: "Solution file not found: {path}",
200
227
  invalidSolution: "Invalid solution file: {path}",
228
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
229
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
230
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
201
231
  noSolutionFile: "No .uipx solution file found in directory: {path}",
202
232
  invalidStorageFile: "Invalid {fileName} file"
203
233
  }
@@ -219,6 +249,9 @@ var ru_default = {
219
249
  pathRequired: "Solution directory path is required",
220
250
  fileNotFound: "Solution file not found: {path}",
221
251
  invalidSolution: "Invalid solution file: {path}",
252
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
253
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
254
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
222
255
  noSolutionFile: "No .uipx solution file found in directory: {path}",
223
256
  invalidStorageFile: "Invalid {fileName} file"
224
257
  }
@@ -240,6 +273,9 @@ var tr_default = {
240
273
  pathRequired: "Solution directory path is required",
241
274
  fileNotFound: "Solution file not found: {path}",
242
275
  invalidSolution: "Invalid solution file: {path}",
276
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
277
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
278
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
243
279
  noSolutionFile: "No .uipx solution file found in directory: {path}",
244
280
  invalidStorageFile: "Invalid {fileName} file"
245
281
  }
@@ -261,6 +297,9 @@ var zh_CN_default = {
261
297
  pathRequired: "Solution directory path is required",
262
298
  fileNotFound: "Solution file not found: {path}",
263
299
  invalidSolution: "Invalid solution file: {path}",
300
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
301
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
302
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
264
303
  noSolutionFile: "No .uipx solution file found in directory: {path}",
265
304
  invalidStorageFile: "Invalid {fileName} file"
266
305
  }
@@ -282,6 +321,9 @@ var zh_TW_default = {
282
321
  pathRequired: "Solution directory path is required",
283
322
  fileNotFound: "Solution file not found: {path}",
284
323
  invalidSolution: "Invalid solution file: {path}",
324
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
325
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
326
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
285
327
  noSolutionFile: "No .uipx solution file found in directory: {path}",
286
328
  invalidStorageFile: "Invalid {fileName} file"
287
329
  }
@@ -303,6 +345,9 @@ var zu_default = {
303
345
  pathRequired: "Solution directory path is required",
304
346
  fileNotFound: "Solution file not found: {path}",
305
347
  invalidSolution: "Invalid solution file: {path}",
348
+ projectMustBeObject: "Invalid solution file: {path}. Projects[{index}] must be an object.",
349
+ projectMissingProjectRelativePath: `Invalid solution file: {path}. Projects[{index}] is missing ProjectRelativePath.{pathHint} Use 'uip solution project add' to add projects, or set ProjectRelativePath to the project file path, for example "Foo/project.uiproj".`,
350
+ projectRelativePathPathHint: " Found Path, but .uipx uses ProjectRelativePath.",
306
351
  noSolutionFile: "No .uipx solution file found in directory: {path}",
307
352
  invalidStorageFile: "Invalid {fileName} file"
308
353
  }
@@ -342,17 +387,8 @@ import {
342
387
  } from "@uipath/solutionpackager-tool-core";
343
388
 
344
389
  // src/browser-solution-packager-factory.ts
345
- import {
346
- BrowserContextStorage,
347
- ConsoleTelemetryProvider,
348
- TelemetryService
349
- } from "@uipath/common/telemetry";
350
- import { BrowserFileSystem } from "@uipath/filesystem/browser";
351
- import {
352
- setGlobalLogHandler,
353
- ToolLogger as ToolLogger2
354
- } from "@uipath/project-packager";
355
- import { translate as translate4 } from "@uipath/solutionpackager-tool-core";
390
+ import { ToolLogger as ToolLogger2 } from "@uipath/project-packager";
391
+ import { BaseBrowserPackagerFactory } from "@uipath/project-packager/browser";
356
392
 
357
393
  // src/services/solution-packager.ts
358
394
  import {
@@ -366,8 +402,8 @@ import {
366
402
  Path as Path4,
367
403
  TargetFramework,
368
404
  TemporaryStorageService,
369
- ToolErrorCodes as ToolErrorCodes3,
370
- ToolResult as ToolResult3,
405
+ ToolErrorCodes as ToolErrorCodes4,
406
+ ToolResult as ToolResult4,
371
407
  toolsFactoryRepository,
372
408
  translate as translate3,
373
409
  ZipService
@@ -457,6 +493,18 @@ class OptionsBuilder {
457
493
  policyFileType: solutionOptions.validateOptions.governanceFileType
458
494
  };
459
495
  }
496
+ async buildProjectRestoreOptions(solutionOptions, project) {
497
+ if (!solutionOptions.outputPath) {
498
+ throw new Error(translate.t("solutionpackager.optionsBuilder.errors.outputPathRequired"));
499
+ }
500
+ return {
501
+ projectPath: this.resolveProjectPath(solutionOptions, project),
502
+ excludeConfiguredSources: solutionOptions.excludeConfiguredSources ?? false,
503
+ nuGetSourcesConfigPath: solutionOptions.nuGetSourcesConfigPath,
504
+ logLevel: solutionOptions.logLevel,
505
+ outputPath: await this.buildProjectOutputPath(solutionOptions.outputPath, project)
506
+ };
507
+ }
460
508
  resolveProjectPath(solutionOptions, project) {
461
509
  return Path.join(solutionOptions.inputPath, Path.dirname(project.ProjectRelativePath));
462
510
  }
@@ -631,7 +679,7 @@ import { Path as Path3, translate as translate2 } from "@uipath/solutionpackager
631
679
 
632
680
  class SolutionLoader {
633
681
  fileSystem;
634
- static SolutionStorageFileName = ".storage";
682
+ static SolutionStorageFileName = "SolutionStorage.json";
635
683
  constructor(fileSystem) {
636
684
  this.fileSystem = fileSystem;
637
685
  }
@@ -647,12 +695,8 @@ class SolutionLoader {
647
695
  }));
648
696
  }
649
697
  const json = typeof fileContent === "string" ? fileContent : new TextDecoder("utf-8").decode(fileContent);
650
- const solution = JSON.parse(json);
651
- if (!solution?.Projects) {
652
- throw new Error(translate2.t("solutionpackager.solutionLoader.errors.invalidSolution", {
653
- path: solutionFilePath
654
- }));
655
- }
698
+ const parsed = JSON.parse(json);
699
+ const solution = validateSolutionFile(parsed, solutionFilePath);
656
700
  const loadedSolution = {
657
701
  ...solution,
658
702
  Name: GetSolutionName(),
@@ -704,6 +748,38 @@ class SolutionLoader {
704
748
  }
705
749
  }
706
750
  }
751
+ function validateSolutionFile(parsed, solutionFilePath) {
752
+ if (!isRecord(parsed)) {
753
+ throw new Error(translate2.t("solutionpackager.solutionLoader.errors.invalidSolution", {
754
+ path: solutionFilePath
755
+ }));
756
+ }
757
+ if (!Array.isArray(parsed.Projects)) {
758
+ throw new Error(translate2.t("solutionpackager.solutionLoader.errors.invalidSolution", {
759
+ path: solutionFilePath
760
+ }));
761
+ }
762
+ for (const [index, project] of parsed.Projects.entries()) {
763
+ if (!isRecord(project)) {
764
+ throw new Error(translate2.t("solutionpackager.solutionLoader.errors.projectMustBeObject", {
765
+ path: solutionFilePath,
766
+ index
767
+ }));
768
+ }
769
+ if (typeof project.ProjectRelativePath !== "string" || !project.ProjectRelativePath.trim()) {
770
+ const pathHint = typeof project.Path === "string" ? translate2.t("solutionpackager.solutionLoader.errors.projectRelativePathPathHint") : "";
771
+ throw new Error(translate2.t("solutionpackager.solutionLoader.errors.projectMissingProjectRelativePath", {
772
+ path: solutionFilePath,
773
+ index,
774
+ pathHint
775
+ }));
776
+ }
777
+ }
778
+ return parsed;
779
+ }
780
+ function isRecord(value) {
781
+ return typeof value === "object" && value !== null && !Array.isArray(value);
782
+ }
707
783
 
708
784
  // src/services/solution-pack-options-validator.ts
709
785
  import {
@@ -721,10 +797,24 @@ class SolutionPackOptionsValidator extends PackagerParametersValidator {
721
797
  }
722
798
 
723
799
  // src/services/solution-pack-service.ts
800
+ import {
801
+ resolveProducedNupkgsAsync,
802
+ signNupkgsAsync
803
+ } from "@uipath/project-packager";
724
804
  import {
725
805
  ToolErrorCodes,
726
806
  ToolResult
727
807
  } from "@uipath/solutionpackager-tool-core";
808
+
809
+ // src/services/tool-result-helpers.ts
810
+ function hasFailedResults(results) {
811
+ return results.some((result) => !result.isSuccess);
812
+ }
813
+ function getFailedResultsMessage(results) {
814
+ return results.filter((result) => !result.isSuccess).map((r) => r.message || "Unknown error").join(", ");
815
+ }
816
+
817
+ // src/services/solution-pack-service.ts
728
818
  class SolutionPackService {
729
819
  optionsBuilder;
730
820
  toolsFactory;
@@ -732,13 +822,15 @@ class SolutionPackService {
732
822
  zipService;
733
823
  fileSystem;
734
824
  telemetry;
735
- constructor(optionsBuilder, toolsFactory, projectExecutor, zipService, fileSystem, telemetry) {
825
+ packageSignService;
826
+ constructor(optionsBuilder, toolsFactory, projectExecutor, zipService, fileSystem, telemetry, packageSignService) {
736
827
  this.optionsBuilder = optionsBuilder;
737
828
  this.toolsFactory = toolsFactory;
738
829
  this.projectExecutor = projectExecutor;
739
830
  this.zipService = zipService;
740
831
  this.fileSystem = fileSystem;
741
832
  this.telemetry = telemetry;
833
+ this.packageSignService = packageSignService;
742
834
  }
743
835
  async packAsync(parameters, solution, context, cancellationToken) {
744
836
  const solutionOptions = await this.optionsBuilder.buildSolutionPackOptions(parameters, solution);
@@ -753,8 +845,8 @@ class SolutionPackService {
753
845
  restoreResult,
754
846
  ...projectResults
755
847
  ];
756
- if (this.hasFailedResults(restoreAndPackResults)) {
757
- return ToolResult.error(ToolErrorCodes.InternalError, `Solution pack failed: ${this.getFailedResultsMessage(restoreAndPackResults)}`);
848
+ if (hasFailedResults(restoreAndPackResults)) {
849
+ return ToolResult.error(ToolErrorCodes.InternalError, `Solution pack failed: ${getFailedResultsMessage(restoreAndPackResults)}`);
758
850
  }
759
851
  const buildResult = await solutionTool.buildAsync(solutionOptions, cancellationToken);
760
852
  if (!buildResult.isSuccess) {
@@ -763,6 +855,10 @@ class SolutionPackService {
763
855
  if (!solutionOptions.outputPath) {
764
856
  return ToolResult.error(ToolErrorCodes.InternalError, "Solution output path is not defined");
765
857
  }
858
+ const signResult = await this.signProjectPackagesAsync(projectResults, parameters.signingInfo);
859
+ if (!signResult.isSuccess) {
860
+ return signResult;
861
+ }
766
862
  const archivePath = await this.compressSolutionAsync(parameters, solutionOptions.outputPath);
767
863
  return new ToolResult(ToolErrorCodes.Success, undefined, [
768
864
  archivePath
@@ -781,23 +877,33 @@ class SolutionPackService {
781
877
  async packSingleProjectAsync(parameters, project, context, cancellationToken) {
782
878
  try {
783
879
  const projectOptions = await this.optionsBuilder.buildProjectPackOptions(parameters, project);
784
- return await this.projectExecutor.packAsync(projectOptions, project, context, parameters.signingInfo, cancellationToken);
880
+ return await this.projectExecutor.packAsync(projectOptions, project, context, cancellationToken);
785
881
  } catch (error) {
786
882
  const errorMessage = error instanceof Error ? error.message : String(error);
787
883
  return ToolResult.error(ToolErrorCodes.InternalError, errorMessage);
788
884
  }
789
885
  }
790
- hasFailedResults(results) {
791
- return results.some((result) => !result.isSuccess);
792
- }
793
- getFailedResultsMessage(results) {
794
- const failedResults = results.filter((result) => !result.isSuccess);
795
- return failedResults.map((r) => r.message || "Unknown error").join(", ");
886
+ async signProjectPackagesAsync(projectResults, signingInfo) {
887
+ if (!signingInfo?.certificatePath) {
888
+ return ToolResult.success();
889
+ }
890
+ const producedPaths = projectResults.flatMap((result) => result.packages);
891
+ const resolved = await Promise.all(producedPaths.map(async (producedPath) => ({
892
+ producedPath,
893
+ nupkgs: await resolveProducedNupkgsAsync(this.fileSystem, producedPath)
894
+ })));
895
+ const unresolved = resolved.filter((entry) => entry.nupkgs.length === 0).map((entry) => entry.producedPath);
896
+ if (unresolved.length > 0) {
897
+ return ToolResult.error(ToolErrorCodes.InternalError, `Package signing was required but no .nupkg was found to sign for: ${unresolved.join(", ")}.`);
898
+ }
899
+ const nupkgsToSign = resolved.flatMap((entry) => entry.nupkgs);
900
+ return signNupkgsAsync(this.packageSignService, nupkgsToSign, signingInfo);
796
901
  }
797
902
  async compressSolutionAsync(parameters, outputPath) {
798
903
  return await this.telemetry.trackDependencyOperation("SolutionPackager.Solution.Compress" /* SolutionCompress */, "compress", async () => {
799
904
  const packageName = parameters.package.id || "solution";
800
905
  const version = parameters.package.version || "1.0.0";
906
+ await this.writePackageMetadataAsync(parameters, outputPath);
801
907
  const archiveFileName = `${packageName}_${version}.zip`;
802
908
  const archivePath = `${parameters.destinationPath}/${archiveFileName}`;
803
909
  const zipData = await this.zipService.compressAsync(outputPath);
@@ -805,6 +911,71 @@ class SolutionPackService {
805
911
  return archivePath;
806
912
  });
807
913
  }
914
+ async writePackageMetadataAsync(parameters, outputPath) {
915
+ const pkg = parameters.package;
916
+ const metadata = {
917
+ name: pkg.id || "solution",
918
+ version: pkg.version || "1.0.0"
919
+ };
920
+ const optional = {
921
+ releaseNotes: pkg.releaseNotes,
922
+ projectUrl: pkg.projectUrl,
923
+ repositoryType: pkg.repositoryType,
924
+ repositoryUrl: pkg.repositoryUrl,
925
+ repositoryBranch: pkg.repositoryBranch,
926
+ repositoryCommit: pkg.repositoryCommit
927
+ };
928
+ for (const [key, value] of Object.entries(optional)) {
929
+ if (value !== undefined && value !== "") {
930
+ metadata[key] = value;
931
+ }
932
+ }
933
+ const metadataPath = `${outputPath}/package.metadata.json`;
934
+ await this.fileSystem.writeFile(metadataPath, `${JSON.stringify(metadata, null, 2)}
935
+ `);
936
+ }
937
+ }
938
+
939
+ // src/services/solution-restore-service.ts
940
+ import {
941
+ ToolErrorCodes as ToolErrorCodes2,
942
+ ToolResult as ToolResult2
943
+ } from "@uipath/solutionpackager-tool-core";
944
+ class SolutionRestoreService {
945
+ optionsBuilder;
946
+ toolsFactory;
947
+ projectExecutor;
948
+ telemetry;
949
+ constructor(optionsBuilder, toolsFactory, projectExecutor, telemetry) {
950
+ this.optionsBuilder = optionsBuilder;
951
+ this.toolsFactory = toolsFactory;
952
+ this.projectExecutor = projectExecutor;
953
+ this.telemetry = telemetry;
954
+ }
955
+ async restoreAsync(parameters, solution, context, cancellationToken) {
956
+ const solutionOptions = await this.optionsBuilder.buildSolutionPackOptions(parameters, solution);
957
+ const solutionTool = await this.toolsFactory.createSolutionToolAsync(solution.SolutionId);
958
+ try {
959
+ return await this.telemetry.trackDependencyOperation("SolutionPackager.Solution.Restore" /* SolutionRestore */, "restore", async () => {
960
+ const restoreResults = await Promise.all([
961
+ solutionTool.restoreAsync(solutionOptions, cancellationToken),
962
+ ...solution.Projects.map(async (project) => {
963
+ const projectRestoreOptions = await this.optionsBuilder.buildProjectRestoreOptions(parameters, project);
964
+ return this.projectExecutor.restoreAsync(projectRestoreOptions, project, context, cancellationToken);
965
+ })
966
+ ]);
967
+ if (hasFailedResults(restoreResults)) {
968
+ return ToolResult2.error(ToolErrorCodes2.InternalError, `Solution restore failed: ${getFailedResultsMessage(restoreResults)}`);
969
+ }
970
+ return ToolResult2.success();
971
+ }, { solutionId: solution.SolutionId });
972
+ } finally {
973
+ const disposeResult = solutionTool.dispose();
974
+ if (disposeResult instanceof Promise) {
975
+ await disposeResult;
976
+ }
977
+ }
978
+ }
808
979
  }
809
980
 
810
981
  // src/services/solution-validate-options-validator.ts
@@ -820,8 +991,8 @@ class SolutionValidateOptionsValidator extends PackagerParametersValidator2 {
820
991
 
821
992
  // src/services/solution-validate-service.ts
822
993
  import {
823
- ToolErrorCodes as ToolErrorCodes2,
824
- ToolResult as ToolResult2
994
+ ToolErrorCodes as ToolErrorCodes3,
995
+ ToolResult as ToolResult3
825
996
  } from "@uipath/solutionpackager-tool-core";
826
997
  class SolutionValidateService {
827
998
  optionsBuilder;
@@ -836,12 +1007,12 @@ class SolutionValidateService {
836
1007
  return await this.telemetry.trackDependencyOperation("SolutionPackager.Solution.Validate" /* SolutionValidate */, "validate", async () => {
837
1008
  const projectResults = await Promise.all(solution.Projects.map((project) => {
838
1009
  if (project.ProjectPath == null) {
839
- return Promise.resolve(ToolResult2.error(ToolErrorCodes2.InternalError, `Project '${project.Id}' has no ProjectPath; the solution loader must populate it before validation.`));
1010
+ return Promise.resolve(ToolResult3.error(ToolErrorCodes3.InternalError, `Project '${project.Id}' has no ProjectPath; the solution loader must populate it before validation.`));
840
1011
  }
841
1012
  return this.projectExecutor.validateAsync(this.optionsBuilder.buildProjectValidateOptions(parameters, project), project, context, cancellationToken);
842
1013
  }));
843
1014
  const failed = projectResults.find((r) => !r.isSuccess);
844
- return failed ?? ToolResult2.success();
1015
+ return failed ?? ToolResult3.success();
845
1016
  }, { solutionId: solution.SolutionId });
846
1017
  }
847
1018
  }
@@ -860,6 +1031,7 @@ class SolutionPackager {
860
1031
  projectExecutor;
861
1032
  solutionLoader;
862
1033
  solutionPackService;
1034
+ solutionRestoreService;
863
1035
  solutionValidateService;
864
1036
  packOptionsValidator;
865
1037
  validateOptionsValidator;
@@ -878,25 +1050,13 @@ class SolutionPackager {
878
1050
  const packageIdReader = new PackageIdReader(this.fileSystem, packService);
879
1051
  this.optionsBuilder = new OptionsBuilder(packageIdReader, packService, this.fileSystem);
880
1052
  this.toolsFactory = new ToolsFactory(this.repository, this.fileSystem);
881
- this.projectExecutor = new ProjectToolExecutor(this.toolsFactory, this.telemetryService, this.packageSignService);
1053
+ this.projectExecutor = new ProjectToolExecutor(this.toolsFactory, this.telemetryService);
882
1054
  this.solutionLoader = new SolutionLoader(this.fileSystem);
883
1055
  this.governancePolicyService = new GovernancePolicyService(this.fileSystem, this.temporaryStorage);
884
- this.solutionPackService = new SolutionPackService(this.optionsBuilder, this.toolsFactory, this.projectExecutor, this.zipService, this.fileSystem, this.telemetryService);
1056
+ this.solutionPackService = new SolutionPackService(this.optionsBuilder, this.toolsFactory, this.projectExecutor, this.zipService, this.fileSystem, this.telemetryService, this.packageSignService);
1057
+ this.solutionRestoreService = new SolutionRestoreService(this.optionsBuilder, this.toolsFactory, this.projectExecutor, this.telemetryService);
885
1058
  this.solutionValidateService = new SolutionValidateService(this.optionsBuilder, this.projectExecutor, this.telemetryService);
886
1059
  }
887
- async canPackSolutionAsync(solutionPath) {
888
- const solution = await this.solutionLoader.loadSolution(solutionPath);
889
- for (const project of solution.Projects) {
890
- if (!project.ProjectPath) {
891
- return false;
892
- }
893
- const canHandle = this.repository.canHandleProject(project.Type);
894
- if (!canHandle) {
895
- return false;
896
- }
897
- }
898
- return true;
899
- }
900
1060
  async setupAsync(input, operationId) {
901
1061
  this.telemetryService.setOperationId(operationId);
902
1062
  await this.temporaryStorage.cleanup();
@@ -952,7 +1112,7 @@ class SolutionPackager {
952
1112
  } catch (error) {
953
1113
  const errorMessage = error instanceof Error ? error.message : String(error);
954
1114
  this.logger.error(`Processing error: ${errorMessage}`);
955
- return ToolResult3.error(ToolErrorCodes3.InternalError, `Solution pack failed: ${errorMessage}`);
1115
+ return ToolResult4.error(ToolErrorCodes4.InternalError, `Solution pack failed: ${errorMessage}`);
956
1116
  } finally {
957
1117
  await this.temporaryStorage.cleanup();
958
1118
  }
@@ -979,7 +1139,32 @@ class SolutionPackager {
979
1139
  } catch (error) {
980
1140
  const errorMessage = error instanceof Error ? error.message : String(error);
981
1141
  this.logger.error(`Processing error: ${errorMessage}`);
982
- return ToolResult3.error(ToolErrorCodes3.InternalError, `Solution validate failed: ${errorMessage}`);
1142
+ return ToolResult4.error(ToolErrorCodes4.InternalError, `Solution validate failed: ${errorMessage}`);
1143
+ } finally {
1144
+ await this.temporaryStorage.cleanup();
1145
+ }
1146
+ });
1147
+ }
1148
+ async restoreSolutionAsync(options, cancellationToken) {
1149
+ return await this.telemetryService.trackRequest("SolutionPackager.RestoreSolution" /* SolutionPackagerRestoreSolution */, async () => {
1150
+ try {
1151
+ if (!options.outputPath) {
1152
+ options.outputPath = await this.temporaryStorage.getTempSubfolderPathAsync("restore");
1153
+ }
1154
+ const loadedSolution = await this.solutionLoader.loadSolution(options.inputPath);
1155
+ const solution = this.filterSolutionProjects(loadedSolution, options.projectDesignIds);
1156
+ const context = this.createOperationContext(options, solution);
1157
+ const result = await this.solutionRestoreService.restoreAsync(options, solution, context, cancellationToken);
1158
+ if (result.isSuccess) {
1159
+ this.logger.info("Solution restore completed successfully.");
1160
+ } else {
1161
+ this.logger.error(`Solution restore failed with error code ${result.errorCode}: ${result.message}`);
1162
+ }
1163
+ return result;
1164
+ } catch (error) {
1165
+ const errorMessage = error instanceof Error ? error.message : String(error);
1166
+ this.logger.error(`Processing error: ${errorMessage}`);
1167
+ return ToolResult4.error(ToolErrorCodes4.InternalError, `Solution restore failed: ${errorMessage}`);
983
1168
  } finally {
984
1169
  await this.temporaryStorage.cleanup();
985
1170
  }
@@ -1032,10 +1217,7 @@ class SolutionPackager {
1032
1217
  }
1033
1218
 
1034
1219
  // src/browser-solution-packager-factory.ts
1035
- var sharedFileSystem = null;
1036
- var GLOBAL_FS_KEY = "__uipath_sharedFileSystem";
1037
-
1038
- class BrowserSolutionPackagerFactory {
1220
+ class BrowserSolutionPackagerFactory extends BaseBrowserPackagerFactory {
1039
1221
  async createAsync(config) {
1040
1222
  const logger = new ToolLogger2("SolutionPackagerFactory", "Create");
1041
1223
  this.configureLanguage(config);
@@ -1047,46 +1229,6 @@ class BrowserSolutionPackagerFactory {
1047
1229
  logger.info("SolutionPackager created successfully.");
1048
1230
  return solutionPackager;
1049
1231
  }
1050
- async getOrCreateFileSystem(config) {
1051
- if (config?.fileSystem) {
1052
- return config.fileSystem;
1053
- }
1054
- if (!sharedFileSystem) {
1055
- sharedFileSystem = globalThis[GLOBAL_FS_KEY] ?? null;
1056
- }
1057
- if (!sharedFileSystem) {
1058
- const fs = new BrowserFileSystem;
1059
- try {
1060
- await fs.init();
1061
- } catch (error) {
1062
- if (error instanceof Error && error.message.includes("Mount point is already in use")) {
1063
- fs.initialized = true;
1064
- } else {
1065
- throw error;
1066
- }
1067
- }
1068
- sharedFileSystem = fs;
1069
- globalThis[GLOBAL_FS_KEY] = fs;
1070
- }
1071
- return sharedFileSystem;
1072
- }
1073
- getOrCreateTelemetryService(config) {
1074
- if (config?.telemetryService) {
1075
- return config.telemetryService;
1076
- }
1077
- const provider = new ConsoleTelemetryProvider;
1078
- const contextStorage = new BrowserContextStorage;
1079
- return new TelemetryService(provider, contextStorage);
1080
- }
1081
- configureLogHandler(config) {
1082
- if (config?.logHandler) {
1083
- setGlobalLogHandler(config.logHandler);
1084
- }
1085
- }
1086
- configureLanguage(config) {
1087
- const language = config?.language ?? "en";
1088
- translate4.setLocale(language);
1089
- }
1090
1232
  }
1091
1233
  async function createBrowserSolutionPackager(options) {
1092
1234
  const factory = new BrowserSolutionPackagerFactory;
@@ -1123,3 +1265,5 @@ export {
1123
1265
  LogLevel,
1124
1266
  BuildConfiguration2 as BuildConfiguration
1125
1267
  };
1268
+
1269
+ //# debugId=00A5AFB7E48A8EC764756E2164756E21