@uipath/solution-tool 1.204.0-preview.255 → 1.205.0-preview.256

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 (122) hide show
  1. package/README.md +3 -3
  2. package/dist/THIRD-PARTY-NOTICES.md +2 -2
  3. package/dist/archive-extract-x35t9ktj.js +120 -0
  4. package/dist/cleanup-command-service-n4e7vxnw.js +149 -0
  5. package/dist/deploy-delete-service-cag0q8yx.js +25 -0
  6. package/dist/deploy-run-service-f0h8wb9w.js +25 -0
  7. package/dist/{deploy-status-service-6svq7c6w.js → deploy-status-service-yh6xn6e0.js} +41 -33
  8. package/dist/deploy.js +23 -17
  9. package/dist/{deployment-search-v2qtz23x.js → deployment-search-mnywd9nc.js} +16 -10
  10. package/dist/{embedded-file-reader-rf2g1kfj.js → embedded-file-reader-z4becc02.js} +2 -2
  11. package/dist/{feed-resolver-xz3akamf.js → feed-resolver-fve33dxq.js} +10 -9
  12. package/dist/feed-scope-failure-jmg4t1r1.js +19 -0
  13. package/dist/{feed-session-sxga31vn.js → feed-session-7xqphdrg.js} +3 -3
  14. package/dist/governance-options-4vxz7ekn.js +32 -0
  15. package/dist/index-g8c8nf1c.js +667 -0
  16. package/dist/index-prm27bvm.js +138 -0
  17. package/dist/index.js +27 -29
  18. package/dist/init.js +11 -10
  19. package/dist/{list-tjetkspc.js → list-50mepbed.js} +10 -8
  20. package/dist/models/pack-command-types.d.ts +15 -0
  21. package/dist/node-7jm7ksqa.js +86 -0
  22. package/dist/pack-command-service-dewf5vsq.js +35 -0
  23. package/dist/pack-project-xwd1rbaa.js +97 -0
  24. package/dist/pack.js +24 -14
  25. package/dist/package-id-1wr3cy9c.js +13 -0
  26. package/dist/packager-tool-09swr9cp.js +171 -0
  27. package/dist/{packager-tool-a9jx8gf4.js → packager-tool-2vmsh5pt.js} +196 -1519
  28. package/dist/{packager-tool-px1j9kre.js → packager-tool-3bwnkjdq.js} +2 -2
  29. package/dist/{packager-tool-gb35b4qs.js → packager-tool-43ahv5mn.js} +192 -96
  30. package/dist/{packager-tool-9ha2z8h5.js → packager-tool-47by487p.js} +6 -4
  31. package/dist/packager-tool-47wzvqw0.js +86 -0
  32. package/dist/{packager-tool-zns6n8zp.js → packager-tool-5ddtwzva.js} +1 -1
  33. package/dist/packager-tool-5edvzz80.js +543 -0
  34. package/dist/{packager-tool-jq9zw82w.js → packager-tool-5n6jsn41.js} +104 -14
  35. package/dist/packager-tool-60af1hw2.js +26 -0
  36. package/dist/{packager-tool-f5gq77m5.js → packager-tool-61pwb567.js} +2 -2
  37. package/dist/{packager-tool-yrz4mwfn.js → packager-tool-6kz1pv9f.js} +1373 -486
  38. package/dist/packager-tool-6ybywxxn.js +1809 -0
  39. package/dist/packager-tool-8ptbmmmp.js +2132 -0
  40. package/dist/{packager-tool-7gr2nphb.js → packager-tool-97rcgwvv.js} +224 -6
  41. package/dist/{packager-tool-83m6ns0r.js → packager-tool-9t26kde1.js} +3556 -1646
  42. package/dist/packager-tool-act5r386.js +239 -0
  43. package/dist/packager-tool-amhyxzz6.js +125 -0
  44. package/dist/packager-tool-b03rva43.js +188 -0
  45. package/dist/{packager-tool-e2rtr49j.js → packager-tool-b2nhscfk.js} +15 -31
  46. package/dist/{packager-tool-tv9c1e80.js → packager-tool-d6rrfd46.js} +149 -53
  47. package/dist/packager-tool-frr2xmkr.js +445 -0
  48. package/dist/{packager-tool-v8bkkqdb.js → packager-tool-gmwva4yv.js} +5 -5
  49. package/dist/packager-tool-gs3f3tf7.js +103 -0
  50. package/dist/packager-tool-jg692f13.js +517 -0
  51. package/dist/packager-tool-jmpb786m.js +109 -0
  52. package/dist/{packager-tool-5sex4a1h.js → packager-tool-kds8ytzw.js} +74 -23
  53. package/dist/packager-tool-kkfb5kgn.js +182 -0
  54. package/dist/packager-tool-kvcxg0zv.js +1510 -0
  55. package/dist/packager-tool-n3jfjn5r.js +42 -0
  56. package/dist/{packager-tool-fjsn5h8s.js → packager-tool-n5d5dx5j.js} +2196 -3455
  57. package/dist/{packager-tool-yfpcvdpm.js → packager-tool-nsya65z1.js} +357 -1370
  58. package/dist/{packager-tool-fv7xyzg2.js → packager-tool-pbmqk39a.js} +126 -128
  59. package/dist/{packager-tool-bqre28m1.js → packager-tool-qw47eyw7.js} +1 -1
  60. package/dist/{packager-tool-9qgmwy21.js → packager-tool-rc3hwn4b.js} +25 -4
  61. package/dist/packager-tool-resolver-994z3jkj.js +23 -0
  62. package/dist/{packager-tool-tgw5x6vx.js → packager-tool-rvt68c1t.js} +17 -8
  63. package/dist/{packager-tool-gab9y5ct.js → packager-tool-t8gh825q.js} +37 -13
  64. package/dist/{packager-tool-kswwd3hp.js → packager-tool-tx834spe.js} +2376 -4077
  65. package/dist/{packager-tool-zf3929se.js → packager-tool-v1f5e8t9.js} +11 -1
  66. package/dist/{packager-tool-ssq2kzqm.js → packager-tool-w77d72a7.js} +13 -11
  67. package/dist/{packager-tool-1rzssy0x.js → packager-tool-wy4fx250.js} +19 -18
  68. package/dist/packager-tool-wz34ma3s.js +1333 -0
  69. package/dist/packager-tool-zq16e1xv.js +68 -0
  70. package/dist/packager-tool.js +2 -2
  71. package/dist/prepare-solution-resources-m1djfj62.js +29 -0
  72. package/dist/project-command-utils-t6pmpvq3.js +90 -0
  73. package/dist/project-contributions-79ndycrx.js +32 -0
  74. package/dist/publish.js +13 -12
  75. package/dist/resource-mutations-c3krjqze.js +36 -0
  76. package/dist/resource-version-lookup-0e3e2j58.js +99 -0
  77. package/dist/resource.js +10 -9
  78. package/dist/restore-command-service-5v0b9363.js +155 -0
  79. package/dist/run-service-tg6b67wp.js +428 -0
  80. package/dist/services/deploy-activate-service.d.ts +10 -5
  81. package/dist/services/deploy-delete-service.d.ts +8 -4
  82. package/dist/services/deploy-run-service.d.ts +34 -1
  83. package/dist/services/deploy-uninstall-service.d.ts +21 -3
  84. package/dist/services/deploy-upgrade-service.d.ts +35 -1
  85. package/dist/services/deployment-feed-locator.d.ts +15 -4
  86. package/dist/services/deployment-search-client.d.ts +5 -53
  87. package/dist/services/deployment-search.d.ts +58 -3
  88. package/dist/services/deployment-state.d.ts +84 -24
  89. package/dist/services/deployment-validation.d.ts +5 -0
  90. package/dist/services/emit-runtime-dependencies.d.ts +2 -1
  91. package/dist/services/feed-resolver.d.ts +6 -4
  92. package/dist/services/feed-selection.d.ts +47 -0
  93. package/dist/services/http-status.d.ts +2 -7
  94. package/dist/services/pack-command-service.d.ts +9 -0
  95. package/dist/services/pack-project-selection.d.ts +51 -0
  96. package/dist/services/pack-project.d.ts +26 -0
  97. package/dist/services/pack-service.d.ts +7 -3
  98. package/dist/services/package-search-client.d.ts +7 -0
  99. package/dist/services/packager-tool-resolver.d.ts +7 -1
  100. package/dist/services/packages-list-service.d.ts +1 -1
  101. package/dist/services/permanent-deletion-consent.d.ts +110 -0
  102. package/dist/services/pipeline-deploy-poll.d.ts +7 -0
  103. package/dist/services/prepare-solution-resources.d.ts +12 -2
  104. package/dist/services/project-contributions.d.ts +5 -4
  105. package/dist/services/search-failure.d.ts +9 -13
  106. package/dist/services/solution-packager-helpers.d.ts +5 -2
  107. package/dist/services/solution-path.d.ts +1 -1
  108. package/dist/services/uninstall-consent.d.ts +82 -0
  109. package/dist/ship-telemetry-myes7ak5.js +21 -0
  110. package/dist/solution-auth-aead70sw.js +11 -0
  111. package/dist/templates/AGENTS.md +125 -12
  112. package/dist/tool.js +27 -29
  113. package/dist/utils/deployment-errors.d.ts +9 -1
  114. package/package.json +2 -2
  115. package/dist/deploy-delete-service-w3e8x1kq.js +0 -22
  116. package/dist/feed-scope-failure-0j5byccb.js +0 -18
  117. package/dist/packager-tool-f2e9rzxk.js +0 -104
  118. package/dist/packager-tool-resolver-6zwhec62.js +0 -20
  119. package/dist/packager-tool-zdfn32bc.js +0 -4465
  120. package/dist/prepare-solution-resources-jpb5as2s.js +0 -25
  121. package/dist/project-contributions-6wpff2hm.js +0 -30
  122. package/dist/services/legacy-deployment-search-v3.d.ts +0 -23
@@ -0,0 +1,517 @@
1
+ import {
2
+ prepareSolutionResources
3
+ } from "./packager-tool-t8gh825q.js";
4
+ import {
5
+ resolveGovernanceFileTypeAsync,
6
+ validateGovernanceOptions
7
+ } from "./packager-tool-47wzvqw0.js";
8
+ import {
9
+ SOLUTION_PATH_INSTRUCTIONS,
10
+ applyAuthConnection,
11
+ checkSolutionPathAsync,
12
+ createSolutionPackager,
13
+ readSolutionFileAsUint8Array,
14
+ resolveSdkLogLevel
15
+ } from "./packager-tool-jmpb786m.js";
16
+ import {
17
+ ensurePackagerTools,
18
+ isUnpackableProjectTypeError
19
+ } from "./packager-tool-b2nhscfk.js";
20
+ import {
21
+ INVALID_PACKAGE_ID,
22
+ SolutionPackOptions
23
+ } from "./packager-tool-wz34ma3s.js";
24
+ import {
25
+ PackProjectError,
26
+ validatePackProjectOptions
27
+ } from "./packager-tool-gs3f3tf7.js";
28
+ import {
29
+ ToolResult
30
+ } from "./packager-tool-pbmqk39a.js";
31
+ import {
32
+ OutputFormatter,
33
+ RESULTS,
34
+ carriedErrorCode,
35
+ carriedRetry,
36
+ logger
37
+ } from "./packager-tool-tx834spe.js";
38
+ import {
39
+ carriedInstructions,
40
+ catchError
41
+ } from "./packager-tool-6ybywxxn.js";
42
+ import {
43
+ getFileSystem
44
+ } from "./packager-tool-v1f5e8t9.js";
45
+ import {
46
+ __require
47
+ } from "./packager-tool-1de529jm.js";
48
+
49
+ // src/services/pack-command-service.ts
50
+ class PackCommandService {
51
+ packager = null;
52
+ fs;
53
+ constructor() {
54
+ this.fs = getFileSystem();
55
+ }
56
+ reportPackThrow(error, dryRun) {
57
+ const msg = error instanceof Error ? error.message : String(error);
58
+ const errorCode = carriedErrorCode(error) ?? (isUnpackableProjectTypeError(error) ? "invalid_argument" : undefined);
59
+ const contributionCode = error?.contributionCode;
60
+ const retry = carriedRetry(error);
61
+ const dryRunHint = "Inspect the reported error, fix the underlying issue in the solution, then rerun: uip solution pack <solution-path> --dry-run";
62
+ OutputFormatter.error({
63
+ Result: RESULTS.Failure,
64
+ ...errorCode ? { ErrorCode: errorCode } : {},
65
+ ...retry ? { Retry: retry } : {},
66
+ ...typeof contributionCode === "string" ? { Context: { errorCode: contributionCode } } : {},
67
+ Message: msg,
68
+ Instructions: carriedInstructions(error) ?? (dryRun ? dryRunHint : msg)
69
+ });
70
+ if (errorCode || !(error instanceof Error) || !error.stack) {
71
+ return;
72
+ }
73
+ logger.error("Stack trace:");
74
+ logger.error(error.stack);
75
+ }
76
+ async execute(solutionPath, options, context) {
77
+ const check = await checkSolutionPathAsync(this.fs, solutionPath);
78
+ if (!check.ok) {
79
+ OutputFormatter.error({
80
+ Result: RESULTS.Failure,
81
+ Message: check.message,
82
+ Instructions: options.dryRun || check.kind === "wrong-type" ? SOLUTION_PATH_INSTRUCTIONS : check.message,
83
+ ErrorCode: check.errorCode
84
+ });
85
+ if (check.statError?.stack) {
86
+ logger.error("Stack trace:");
87
+ logger.error(check.statError.stack);
88
+ }
89
+ context.exit(1);
90
+ return;
91
+ }
92
+ const { absoluteSolutionPath, isUisFile, stats } = check;
93
+ const packageName = this.resolvePackageName(absoluteSolutionPath, isUisFile, options);
94
+ let resolvedOutput;
95
+ let tempDir;
96
+ if (options.dryRun) {
97
+ const [tempDirError, allocated] = await catchError(this.fs.getTempDir());
98
+ if (tempDirError || !allocated) {
99
+ OutputFormatter.error({
100
+ Result: RESULTS.Failure,
101
+ Message: tempDirError?.message ?? "Failed to allocate a temporary directory for dry-run validation.",
102
+ Instructions: "Ensure the OS temp directory is writable and try again."
103
+ });
104
+ context.exit(1);
105
+ return;
106
+ }
107
+ tempDir = allocated;
108
+ resolvedOutput = allocated;
109
+ } else if (options.output === undefined) {
110
+ OutputFormatter.error({
111
+ Result: RESULTS.Failure,
112
+ Message: "Missing required argument: outputPath.",
113
+ Instructions: "Provide an output directory, or pass --dry-run to validate without packing."
114
+ });
115
+ context.exit(1);
116
+ return;
117
+ } else {
118
+ resolvedOutput = this.fs.path.resolve(options.output);
119
+ if (stats.isDirectory()) {
120
+ const projectDir = await this.findMemberProjectCollision(absoluteSolutionPath, resolvedOutput);
121
+ if (projectDir) {
122
+ OutputFormatter.error({
123
+ Result: RESULTS.Failure,
124
+ Message: `Output path ${resolvedOutput} is inside member project "${this.fs.path.basename(projectDir)}" (${projectDir}). Anything written there gets packed into that project's package on the next pack.`,
125
+ Instructions: "Choose an output path outside the solution's project directories, e.g. ./out at the solution root or a directory outside the solution."
126
+ });
127
+ context.exit(1);
128
+ return;
129
+ }
130
+ }
131
+ }
132
+ if (options.dryRun) {
133
+ logger.info(`
134
+ Validating solution (dry-run)...
135
+ `);
136
+ logger.info("Details:");
137
+ logger.info(` Solution: ${absoluteSolutionPath}`);
138
+ logger.info("");
139
+ } else if (options.project === undefined) {
140
+ logger.info(`
141
+ Packing solution...
142
+ `);
143
+ logger.info("Details:");
144
+ logger.info(` Solution: ${absoluteSolutionPath}`);
145
+ logger.info(` Package: ${packageName}@${options.version}`);
146
+ logger.info(` Output: ${resolvedOutput}`);
147
+ logger.info("");
148
+ } else {
149
+ logger.info(`
150
+ Packing project...
151
+ `);
152
+ logger.info("Details:");
153
+ logger.info(` Solution: ${absoluteSolutionPath}`);
154
+ logger.info(` Project: ${options.project}`);
155
+ if (options.packageId !== undefined) {
156
+ logger.info(` Package: ${options.packageId}@${options.version}`);
157
+ }
158
+ logger.info(` Output: ${resolvedOutput}`);
159
+ logger.info("");
160
+ }
161
+ let governanceFileType = options.governanceFileType;
162
+ if (options.governanceFilePath !== undefined) {
163
+ const resolved = await resolveGovernanceFileTypeAsync(this.fs, options.governanceFilePath);
164
+ if (!resolved.ok) {
165
+ OutputFormatter.error({
166
+ Result: RESULTS.Failure,
167
+ Message: resolved.message,
168
+ Instructions: resolved.instructions
169
+ });
170
+ context.exit(1);
171
+ return;
172
+ }
173
+ governanceFileType = resolved.fileType;
174
+ }
175
+ try {
176
+ const [error, result] = await catchError(this.executeAsync(solutionPath, {
177
+ ...options,
178
+ output: resolvedOutput,
179
+ governanceFileType
180
+ }));
181
+ if (error) {
182
+ this.reportPackThrow(error, options.dryRun === true);
183
+ context.exit(1);
184
+ return;
185
+ }
186
+ if (result.errorCode !== "SUCCESS" /* Success */) {
187
+ OutputFormatter.error(packFailureEnvelope(result, options.dryRun === true));
188
+ context.exit(1);
189
+ return;
190
+ }
191
+ if (options.dryRun) {
192
+ OutputFormatter.success({
193
+ Result: RESULTS.Success,
194
+ Code: "SolutionPack",
195
+ Data: {
196
+ Package: `${packedPackageName(result, packageName)}@${options.version}`,
197
+ DryRun: true,
198
+ Status: "Valid"
199
+ }
200
+ });
201
+ } else {
202
+ OutputFormatter.success({
203
+ Result: RESULTS.Success,
204
+ Code: "SolutionPack",
205
+ Data: {
206
+ Package: `${packedPackageName(result, packageName)}@${options.version}`,
207
+ Packages: result.packages.join(",")
208
+ }
209
+ });
210
+ }
211
+ } finally {
212
+ if (tempDir) {
213
+ const [rmError] = await catchError(this.fs.rm(tempDir));
214
+ if (rmError) {
215
+ logger.debug(`Failed to clean up dry-run temp directory ${tempDir}: ${rmError.message}`);
216
+ }
217
+ }
218
+ }
219
+ }
220
+ async checkPackInputs(solutionPath, options) {
221
+ if (options.output === undefined) {
222
+ return {
223
+ failure: new ToolResult("INTERNAL_ERROR" /* InternalError */, "Output path is required when invoking executeAsync directly.", [])
224
+ };
225
+ }
226
+ const projectError = validatePackProjectOptions(options);
227
+ if (projectError) {
228
+ return {
229
+ failure: new ToolResult("INTERNAL_ERROR" /* InternalError */, projectError, [])
230
+ };
231
+ }
232
+ const governanceError = validateGovernanceOptions(options);
233
+ if (governanceError) {
234
+ return {
235
+ failure: new ToolResult("INTERNAL_ERROR" /* InternalError */, governanceError, [])
236
+ };
237
+ }
238
+ let resolvedOptions = options;
239
+ if (options.governanceFilePath !== undefined && options.governanceFileType === undefined) {
240
+ const resolved = await resolveGovernanceFileTypeAsync(this.fs, options.governanceFilePath);
241
+ if (!resolved.ok) {
242
+ return {
243
+ failure: new ToolResult("INTERNAL_ERROR" /* InternalError */, `${resolved.message} ${resolved.instructions}`, [])
244
+ };
245
+ }
246
+ resolvedOptions = {
247
+ ...options,
248
+ governanceFileType: resolved.fileType
249
+ };
250
+ }
251
+ const check = await checkSolutionPathAsync(this.fs, solutionPath);
252
+ if (!check.ok) {
253
+ return {
254
+ failure: new ToolResult("INTERNAL_ERROR" /* InternalError */, check.message, [])
255
+ };
256
+ }
257
+ return {
258
+ absoluteOutputPath: this.fs.path.resolve(options.output),
259
+ resolvedOptions,
260
+ check
261
+ };
262
+ }
263
+ async executeAsync(solutionPath, options) {
264
+ const inputs = await this.checkPackInputs(solutionPath, options);
265
+ if (inputs.failure) {
266
+ return inputs.failure;
267
+ }
268
+ const { absoluteOutputPath, resolvedOptions, check } = inputs;
269
+ const { absoluteSolutionPath, isUisFile, stats } = check;
270
+ const isDirectory = stats.isDirectory();
271
+ const packageName = this.resolvePackageName(absoluteSolutionPath, isUisFile, options);
272
+ logger.debug(`Processing: ${absoluteSolutionPath}`);
273
+ logger.debug(`Package: ${packageName}@${options.version}`);
274
+ logger.debug(`Output: ${absoluteOutputPath}`);
275
+ const [copyError, copy] = await catchError(this.copyDirectoryForDryRun(absoluteSolutionPath, isDirectory && options.dryRun === true));
276
+ if (copyError) {
277
+ return new ToolResult("INTERNAL_ERROR" /* InternalError */, `Failed to prepare a temporary copy for the dry run: ${copyError.message}`, []);
278
+ }
279
+ const solutionRoot = copy?.solutionRoot ?? absoluteSolutionPath;
280
+ try {
281
+ if (resolvedOptions.project !== undefined) {
282
+ return await this.packProjectAsync(isUisFile, solutionRoot, absoluteOutputPath, resolvedOptions.project, resolvedOptions);
283
+ }
284
+ if (isDirectory) {
285
+ const [prepareError] = await catchError(this.prepareSolutionDirectoryForPack(solutionRoot));
286
+ if (prepareError) {
287
+ return toPackFailure(prepareError);
288
+ }
289
+ }
290
+ const [error, result] = await catchError(async () => {
291
+ await this.fs.mkdir(absoluteOutputPath);
292
+ const packager = await this.ensurePackagerAsync();
293
+ let inputPath;
294
+ if (isUisFile) {
295
+ const uint8Array = await readSolutionFileAsUint8Array(this.fs, absoluteSolutionPath);
296
+ inputPath = await packager.setupAsync(uint8Array);
297
+ await this.prepareSolutionDirectoryForPack(inputPath);
298
+ } else {
299
+ inputPath = await packager.setupAsync(solutionRoot);
300
+ }
301
+ await ensurePackagerTools(inputPath, this.fs);
302
+ const packOptions = await this.createPackOptions(inputPath, absoluteOutputPath, absoluteSolutionPath, isUisFile, resolvedOptions);
303
+ return packager.packSolutionAsync(packOptions);
304
+ });
305
+ return error ? toPackFailure(error) : result;
306
+ } finally {
307
+ if (copy) {
308
+ await this.discardDryRunCopy(copy.tempDir);
309
+ }
310
+ }
311
+ }
312
+ async packProjectAsync(isUisFile, solutionDir, outputPath, selector, options) {
313
+ if (isUisFile) {
314
+ throw new PackProjectError("--project packs a project out of a solution folder, not out of a .uis file.", "Pass the solution folder instead: uip solution pack <solution-folder> <output-path> --project <id-or-path>.");
315
+ }
316
+ const [error, result] = await catchError(async () => {
317
+ const { prepareSolutionProjectAsync, packSolutionProjectAsync } = await import("./pack-project-xwd1rbaa.js");
318
+ const { project, packageId } = await prepareSolutionProjectAsync(this.fs, solutionDir, selector, options.packageId);
319
+ await this.fs.mkdir(outputPath);
320
+ const packOptions = await this.createProjectPackOptions(project, packageId, outputPath, options);
321
+ return packSolutionProjectAsync(this.fs, project, packOptions);
322
+ });
323
+ return error ? toPackFailure(error) : result;
324
+ }
325
+ async copyDirectoryForDryRun(solutionDir, needed) {
326
+ if (!needed) {
327
+ return;
328
+ }
329
+ const tempDir = await this.fs.getTempDir();
330
+ const solutionRoot = this.fs.path.join(tempDir, this.fs.path.basename(solutionDir));
331
+ const [copyError] = await catchError(this.fs.copyDirectory(solutionDir, solutionRoot));
332
+ if (copyError) {
333
+ await this.discardDryRunCopy(tempDir);
334
+ throw copyError;
335
+ }
336
+ logger.debug(`Dry run works on a copy of the solution: ${solutionRoot}`);
337
+ return { tempDir, solutionRoot };
338
+ }
339
+ async discardDryRunCopy(tempDir) {
340
+ const [rmError] = await catchError(this.fs.rm(tempDir));
341
+ if (rmError) {
342
+ logger.debug(`Failed to clean up dry-run solution copy ${tempDir}: ${rmError.message}`);
343
+ }
344
+ }
345
+ async findMemberProjectCollision(solutionDir, outputPath) {
346
+ const projectDirs = await this.readMemberProjectDirs(solutionDir);
347
+ return projectDirs.find((projectDir) => this.isPathEqualOrInside(outputPath, projectDir));
348
+ }
349
+ isPathEqualOrInside(target, parent) {
350
+ const relative = this.fs.path.relative(parent, target);
351
+ if (relative === "") {
352
+ return true;
353
+ }
354
+ if (this.fs.path.isAbsolute(relative)) {
355
+ return false;
356
+ }
357
+ return relative !== ".." && !relative.startsWith("../") && !relative.startsWith("..\\");
358
+ }
359
+ async readMemberProjectDirs(solutionDir) {
360
+ const [listError, entries] = await catchError(this.fs.readdir(solutionDir));
361
+ const uipxFile = entries?.find((entry) => entry.endsWith(".uipx"));
362
+ if (listError || !uipxFile) {
363
+ return [];
364
+ }
365
+ const [readError, content] = await catchError(this.fs.readFile(this.fs.path.join(solutionDir, uipxFile), "utf-8"));
366
+ if (readError || !content) {
367
+ return [];
368
+ }
369
+ const [parseError, manifest] = catchError(() => JSON.parse(content));
370
+ const projects = manifest?.Projects;
371
+ if (parseError || !Array.isArray(projects)) {
372
+ return [];
373
+ }
374
+ const dirs = [];
375
+ for (const project of projects) {
376
+ if (typeof project !== "object" || project === null) {
377
+ continue;
378
+ }
379
+ const relativePath = project.ProjectRelativePath;
380
+ if (typeof relativePath === "string" && relativePath.trim()) {
381
+ dirs.push(this.fs.path.resolve(solutionDir, this.fs.path.dirname(relativePath)));
382
+ }
383
+ }
384
+ return dirs;
385
+ }
386
+ async prepareSolutionDirectoryForPack(solutionDir) {
387
+ await prepareSolutionResources(solutionDir, this.fs, { gate: true });
388
+ }
389
+ async ensurePackagerAsync() {
390
+ if (!this.packager) {
391
+ this.packager = await createSolutionPackager();
392
+ }
393
+ return this.packager;
394
+ }
395
+ resolvePackageName(absoluteSolutionPath, isUisFile, options) {
396
+ return options.name || (isUisFile ? this.fs.path.basename(absoluteSolutionPath, ".uis") : this.fs.path.basename(absoluteSolutionPath));
397
+ }
398
+ async createPackOptions(inputPath, outputPath, absoluteSolutionPath, isUisFile, options) {
399
+ const packOptions = new SolutionPackOptions;
400
+ packOptions.inputPath = inputPath;
401
+ packOptions.destinationPath = outputPath;
402
+ packOptions.configuration = "Release" /* Release */;
403
+ const packageName = this.resolvePackageName(absoluteSolutionPath, isUisFile, options);
404
+ packOptions.package = { id: packageName, ...packageMetadata(options) };
405
+ packOptions.solutionType = options.solutionType;
406
+ await applySharedPackOptions(packOptions, options);
407
+ return packOptions;
408
+ }
409
+ async createProjectPackOptions(project, packageId, outputPath, options) {
410
+ const projectPackager = await import("./node-7jm7ksqa.js");
411
+ const packOptions = new projectPackager.ProjectPackOptions;
412
+ packOptions.inputPath = project.ProjectPath ?? "";
413
+ packOptions.destinationPath = outputPath;
414
+ packOptions.package = { id: packageId, ...packageMetadata(options) };
415
+ await applySharedPackOptions(packOptions, options);
416
+ return packOptions;
417
+ }
418
+ }
419
+ function packageMetadata(options) {
420
+ return {
421
+ version: options.version || "1.0.0",
422
+ author: options.author?.trim() || undefined,
423
+ description: options.description?.trim() || undefined,
424
+ releaseNotes: options.releaseNotes,
425
+ projectUrl: options.projectUrl,
426
+ repositoryType: options.repositoryType,
427
+ repositoryUrl: options.repositoryUrl,
428
+ repositoryBranch: options.repositoryBranch,
429
+ repositoryCommit: options.repositoryCommit
430
+ };
431
+ }
432
+ async function applySharedPackOptions(packOptions, options) {
433
+ if (options.signingCertificatePath) {
434
+ packOptions.signingInfo = {
435
+ certificatePath: options.signingCertificatePath,
436
+ certificatePassword: options.signingCertificatePassword,
437
+ timestampServer: options.signingTimestampServer
438
+ };
439
+ }
440
+ packOptions.logLevel = resolveSdkLogLevel();
441
+ packOptions.excludeConfiguredSources = options.excludeConfiguredSources ?? false;
442
+ packOptions.nuGetSourcesConfigPath = options.nugetSourcesConfigPath;
443
+ packOptions.feedFolder = options.feedFolder;
444
+ packOptions.validateOptions = {
445
+ skipAnalyze: options.skipAnalyze ?? false,
446
+ skipValidate: false,
447
+ ignoredRules: options.ignoredRules,
448
+ governanceFileType: options.governanceFileType ?? resolveGovernanceFileType(options),
449
+ governanceFilePath: options.governanceFilePath,
450
+ profileKey: resolveGovernanceProduct(options)
451
+ };
452
+ const session = await applyAuthConnection(packOptions, options.loginValidity);
453
+ packOptions.validateOptions.sessionIdentityType = session.identity?.type;
454
+ }
455
+ function toPackFailure(error) {
456
+ if (isUnpackableProjectTypeError(error) || carriedErrorCode(error) !== undefined) {
457
+ throw error;
458
+ }
459
+ const message = error instanceof Error ? error.message : String(error);
460
+ const instructions = carriedInstructions(error);
461
+ return new ToolResult("INTERNAL_ERROR" /* InternalError */, instructions ? `${message} ${instructions}` : message, []);
462
+ }
463
+ function packedPackageName(result, solutionPackageName) {
464
+ const ids = result.details?.packageIds;
465
+ return Array.isArray(ids) && ids.length > 0 ? ids.join(",") : solutionPackageName;
466
+ }
467
+ var DEFAULT_AUTOMATION_OPS_PRODUCT = "StudioWeb";
468
+ function resolveGovernanceFileType(options) {
469
+ if (options.governanceFilePath !== undefined) {
470
+ return "Studio" /* Studio */;
471
+ }
472
+ return resolveGovernanceProduct(options) !== undefined ? "AutomationOps" /* AutomationOps */ : "Default" /* Default */;
473
+ }
474
+ function packFailureEnvelope(result, dryRun) {
475
+ const message = result.message ?? "Pack failed";
476
+ if (result.errorCode === INVALID_PACKAGE_ID) {
477
+ const rerun = dryRun ? "uip solution pack <solution-path> --dry-run" : "uip solution pack <solution-path> <output-path>";
478
+ return {
479
+ Result: RESULTS.Failure,
480
+ Message: message,
481
+ Instructions: `A member's package id is composed as '<solution>.<project-type>.<member-folder>', capped at 100 characters, and has to be unique across the solution — spaces and dots both collapse to a single dot, and NuGet ids are case-insensitive. The '<solution>' part is the '.uipx' file's own name; '--name' renames the archive only and cannot shorten a member id. Rename the member folder named in the message, or the '.uipx', then rerun ${rerun}.`,
482
+ ErrorCode: "invalid_argument",
483
+ Retry: "RetryWillNotFix"
484
+ };
485
+ }
486
+ return {
487
+ Result: RESULTS.Failure,
488
+ Message: `Error code: ${result.errorCode} : ${message}`,
489
+ Instructions: result.instructions ?? formatPackFailureInstructions(result.message, dryRun),
490
+ ...packFailureData(result)
491
+ };
492
+ }
493
+ function packFailureData(result) {
494
+ const projects = result.details?.projects;
495
+ return Array.isArray(projects) && projects.length > 0 ? { Data: { Projects: projects } } : {};
496
+ }
497
+ function resolveGovernanceProduct(options) {
498
+ const named = options.governanceProduct ?? options.automationOpsProfile;
499
+ if (named !== undefined) {
500
+ return named;
501
+ }
502
+ return options.governanceFilePath !== undefined || (options.ignoredRules?.length ?? 0) > 0 ? DEFAULT_AUTOMATION_OPS_PRODUCT : undefined;
503
+ }
504
+ function formatPackFailureInstructions(message, dryRun) {
505
+ const packMessage = message ?? "Pack failed";
506
+ const noPackagerMatch = /Cannot pack project type '([^']+)'/.exec(packMessage);
507
+ if (noPackagerMatch) {
508
+ const projectType = noPackagerMatch[1];
509
+ const rerunCommand = dryRun ? "uip solution pack <solution-path> --dry-run" : "uip solution pack <solution-path> <output-path>";
510
+ return `Install the tool that packs project type '${projectType}': run 'uip tools search' to find it, then 'uip tools install <tool>'. If '${projectType}' is a new project type, run 'uip update' first. Then rerun ${rerunCommand}.`;
511
+ }
512
+ return dryRun ? `${packMessage}. Resolve the reported issue (resource bindings, variable references, mapping targets, or runtime dependencies) and rerun: uip solution pack <solution-path> --dry-run` : packMessage;
513
+ }
514
+
515
+ export { PackCommandService, packFailureEnvelope };
516
+
517
+ //# debugId=878D6966283DBC2164756E2164756E21
@@ -0,0 +1,109 @@
1
+ import {
2
+ createNodeSolutionPackager
3
+ } from "./packager-tool-wz34ma3s.js";
4
+ import {
5
+ getLoginStatusAsync
6
+ } from "./packager-tool-43ahv5mn.js";
7
+ import {
8
+ logger,
9
+ telemetry
10
+ } from "./packager-tool-tx834spe.js";
11
+ import {
12
+ catchError
13
+ } from "./packager-tool-6ybywxxn.js";
14
+
15
+ // src/services/solution-packager-helpers.ts
16
+ async function createSolutionPackager() {
17
+ return createNodeSolutionPackager({
18
+ logHandler: logger.handleLog,
19
+ telemetryService: telemetry
20
+ });
21
+ }
22
+ async function readSolutionFileAsUint8Array(fs, filePath) {
23
+ const fileData = await fs.readFile(filePath);
24
+ if (fileData === null) {
25
+ throw new Error(`File not found: ${filePath}`);
26
+ }
27
+ return fileData instanceof Uint8Array ? fileData : new Uint8Array(fileData);
28
+ }
29
+ function resolveSdkLogLevel() {
30
+ const sdkLogLevelMap = {
31
+ [0 /* DEBUG */]: "Debug" /* Debug */,
32
+ [1 /* INFO */]: "Information" /* Info */,
33
+ [2 /* WARN */]: "Warning" /* Warn */,
34
+ [3 /* ERROR */]: "Error" /* Error */
35
+ };
36
+ return sdkLogLevelMap[logger.getLevel()] ?? "Error" /* Error */;
37
+ }
38
+ async function applyAuthConnection(options, loginValidity) {
39
+ const loginStatus = await getLoginStatusAsync({
40
+ ensureTokenValidityMinutes: loginValidity
41
+ });
42
+ if (loginStatus.loginStatus) {
43
+ options.connection = {
44
+ accessToken: loginStatus.accessToken,
45
+ cloudUrl: orchestratorBaseUrl(loginStatus),
46
+ organizationId: loginStatus.organizationId,
47
+ tenantId: loginStatus.tenantId
48
+ };
49
+ }
50
+ return loginStatus;
51
+ }
52
+ function orchestratorBaseUrl(loginStatus) {
53
+ const { baseUrl, organizationId, tenantName } = loginStatus;
54
+ if (!baseUrl) {
55
+ return baseUrl;
56
+ }
57
+ let base = baseUrl;
58
+ while (base.endsWith("/")) {
59
+ base = base.slice(0, -1);
60
+ }
61
+ const segments = [];
62
+ if (organizationId) {
63
+ segments.push(organizationId);
64
+ if (tenantName) {
65
+ segments.push(tenantName);
66
+ }
67
+ }
68
+ return segments.length ? `${base}/${segments.join("/")}` : base;
69
+ }
70
+
71
+ // src/services/solution-path.ts
72
+ var SOLUTION_PATH_INSTRUCTIONS = "Ensure the solution path exists and points to a solution directory (containing .uipx) or a .uis file.";
73
+ async function checkSolutionPathAsync(fs, solutionPath) {
74
+ const absoluteSolutionPath = fs.path.resolve(solutionPath);
75
+ const [statError, stats] = await catchError(fs.stat(absoluteSolutionPath));
76
+ if (statError) {
77
+ return {
78
+ ok: false,
79
+ absoluteSolutionPath,
80
+ kind: "unreadable",
81
+ message: statError.message,
82
+ statError
83
+ };
84
+ }
85
+ if (!stats) {
86
+ return {
87
+ ok: false,
88
+ absoluteSolutionPath,
89
+ kind: "missing",
90
+ message: `Solution path does not exist: ${absoluteSolutionPath}`,
91
+ errorCode: "not_found"
92
+ };
93
+ }
94
+ const isUisFile = stats.isFile() && absoluteSolutionPath.endsWith(".uis");
95
+ if (!stats.isDirectory() && !isUisFile) {
96
+ return {
97
+ ok: false,
98
+ absoluteSolutionPath,
99
+ kind: "wrong-type",
100
+ message: `Solution path must be a directory or a .uis file: ${absoluteSolutionPath}`,
101
+ errorCode: "invalid_argument"
102
+ };
103
+ }
104
+ return { ok: true, absoluteSolutionPath, isUisFile, stats };
105
+ }
106
+
107
+ export { createSolutionPackager, readSolutionFileAsUint8Array, resolveSdkLogLevel, applyAuthConnection, SOLUTION_PATH_INSTRUCTIONS, checkSolutionPathAsync };
108
+
109
+ //# debugId=E4EA1C14BCE5DE7C64756E2164756E21