@uipath/packager-tool-workflowcompiler-browser 0.0.29

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.
@@ -0,0 +1,34 @@
1
+ {
2
+ "toolWorkflowCompilerBrowser": {
3
+ "info": {
4
+ "startingRemotePackAgent": "Starting remote pack agent for {count} project(s): {paths}",
5
+ "connectingToHub": "Connecting to SignalR hub: {url}",
6
+ "remoteAgentStartedExecution": "Remote agent started execution",
7
+ "downloadingArchive": "Downloading pack result archive from bucket {bucketId}",
8
+ "extractingArchive": "Extracting archive ({size} bytes) to {path}",
9
+ "distributingPackages": "Distributing packages for {count} project(s)",
10
+ "cleaningUpTempDir": "Cleaning up temporary directory {path}",
11
+ "deletingBucket": "Deleting temporary storage bucket {bucketId}",
12
+ "copyingFiles": "Copying {count} file(s) for project {designId} to {path}"
13
+ },
14
+ "errors": {
15
+ "missingConnectionInfo": "Missing connection info (cloudUrl, accessToken, or folderId)",
16
+ "signalRConnectionFailed": "Failed to connect to SignalR hub",
17
+ "hubConnectionFailed": "Failed to connect to SignalR hub at {url}: {message}",
18
+ "packSucceededNoBucket": "Pack succeeded but no BucketId was returned",
19
+ "packAgentFailed": "Pack agent failed with status {status} (code {errorCode})",
20
+ "noResultForProject": "No result for project",
21
+ "beginSessionFailed": "BeginSession failed ({status}): {errorText}",
22
+ "hubConnectionClosed": "Hub connection closed unexpectedly",
23
+ "packAgentDisconnected": "Pack agent disconnected unexpectedly",
24
+ "deleteBucketFailed": "Unable to delete temporary storage bucket on Orchestrator: {statusText}",
25
+ "cleanupBucketFailed": "Unable to cleanup remote bucket {bucketId}: {message}",
26
+ "getBucketUriFailed": "Failed to get bucket read URI ({status}): {errorText}",
27
+ "downloadArchiveFailed": "Failed to download archive from bucket ({status}): {statusText}",
28
+ "noMatchingProject": "No matching project found for path: {projectPath}",
29
+ "noOutputForProject": "No output found for project {designId}",
30
+ "distributePackagesFailed": "Failed to distribute packages for {designId}: {message}",
31
+ "sessionTimeout": "Session timed out waiting for projects: received {received} of {expected} expected projects"
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "toolWorkflowCompilerBrowser": {
3
+ "info": {
4
+ "startingRemotePackAgent": "Starting remote pack agent for {count} project(s): {paths}",
5
+ "connectingToHub": "Connecting to SignalR hub: {url}",
6
+ "remoteAgentStartedExecution": "Remote agent started execution",
7
+ "downloadingArchive": "Downloading pack result archive from bucket {bucketId}",
8
+ "extractingArchive": "Extracting archive ({size} bytes) to {path}",
9
+ "distributingPackages": "Distributing packages for {count} project(s)",
10
+ "cleaningUpTempDir": "Cleaning up temporary directory {path}",
11
+ "deletingBucket": "Deleting temporary storage bucket {bucketId}",
12
+ "copyingFiles": "Copying {count} file(s) for project {designId} to {path}"
13
+ },
14
+ "errors": {
15
+ "missingConnectionInfo": "Missing connection info (cloudUrl, accessToken, or folderId)",
16
+ "signalRConnectionFailed": "Failed to connect to SignalR hub",
17
+ "hubConnectionFailed": "Failed to connect to SignalR hub at {url}: {message}",
18
+ "packSucceededNoBucket": "Pack succeeded but no BucketId was returned",
19
+ "packAgentFailed": "Pack agent failed with status {status} (code {errorCode})",
20
+ "noResultForProject": "No result for project",
21
+ "beginSessionFailed": "BeginSession failed ({status}): {errorText}",
22
+ "hubConnectionClosed": "Hub connection closed unexpectedly",
23
+ "packAgentDisconnected": "Pack agent disconnected unexpectedly",
24
+ "deleteBucketFailed": "Unable to delete temporary storage bucket on Orchestrator: {statusText}",
25
+ "cleanupBucketFailed": "Unable to cleanup remote bucket {bucketId}: {message}",
26
+ "getBucketUriFailed": "Failed to get bucket read URI ({status}): {errorText}",
27
+ "downloadArchiveFailed": "Failed to download archive from bucket ({status}): {statusText}",
28
+ "noMatchingProject": "No matching project found for path: {projectPath}",
29
+ "noOutputForProject": "No output found for project {designId}",
30
+ "distributePackagesFailed": "Failed to distribute packages for {designId}: {message}",
31
+ "sessionTimeout": "Session timed out waiting for projects: received {received} of {expected} expected projects"
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "toolWorkflowCompilerBrowser": {
3
+ "info": {
4
+ "startingRemotePackAgent": "Starting remote pack agent for {count} project(s): {paths}",
5
+ "connectingToHub": "Connecting to SignalR hub: {url}",
6
+ "remoteAgentStartedExecution": "Remote agent started execution",
7
+ "downloadingArchive": "Downloading pack result archive from bucket {bucketId}",
8
+ "extractingArchive": "Extracting archive ({size} bytes) to {path}",
9
+ "distributingPackages": "Distributing packages for {count} project(s)",
10
+ "cleaningUpTempDir": "Cleaning up temporary directory {path}",
11
+ "deletingBucket": "Deleting temporary storage bucket {bucketId}",
12
+ "copyingFiles": "Copying {count} file(s) for project {designId} to {path}"
13
+ },
14
+ "errors": {
15
+ "missingConnectionInfo": "Missing connection info (cloudUrl, accessToken, or folderId)",
16
+ "signalRConnectionFailed": "Failed to connect to SignalR hub",
17
+ "hubConnectionFailed": "Failed to connect to SignalR hub at {url}: {message}",
18
+ "packSucceededNoBucket": "Pack succeeded but no BucketId was returned",
19
+ "packAgentFailed": "Pack agent failed with status {status} (code {errorCode})",
20
+ "noResultForProject": "No result for project",
21
+ "beginSessionFailed": "BeginSession failed ({status}): {errorText}",
22
+ "hubConnectionClosed": "Hub connection closed unexpectedly",
23
+ "packAgentDisconnected": "Pack agent disconnected unexpectedly",
24
+ "deleteBucketFailed": "Unable to delete temporary storage bucket on Orchestrator: {statusText}",
25
+ "cleanupBucketFailed": "Unable to cleanup remote bucket {bucketId}: {message}",
26
+ "getBucketUriFailed": "Failed to get bucket read URI ({status}): {errorText}",
27
+ "downloadArchiveFailed": "Failed to download archive from bucket ({status}): {statusText}",
28
+ "noMatchingProject": "No matching project found for path: {projectPath}",
29
+ "noOutputForProject": "No output found for project {designId}",
30
+ "distributePackagesFailed": "Failed to distribute packages for {designId}: {message}",
31
+ "sessionTimeout": "Session timed out waiting for projects: received {received} of {expected} expected projects"
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,34 @@
1
+ {
2
+ "toolWorkflowCompilerBrowser": {
3
+ "info": {
4
+ "startingRemotePackAgent": "Starting remote pack agent for {count} project(s): {paths}",
5
+ "connectingToHub": "Connecting to SignalR hub: {url}",
6
+ "remoteAgentStartedExecution": "Remote agent started execution",
7
+ "downloadingArchive": "Downloading pack result archive from bucket {bucketId}",
8
+ "extractingArchive": "Extracting archive ({size} bytes) to {path}",
9
+ "distributingPackages": "Distributing packages for {count} project(s)",
10
+ "cleaningUpTempDir": "Cleaning up temporary directory {path}",
11
+ "deletingBucket": "Deleting temporary storage bucket {bucketId}",
12
+ "copyingFiles": "Copying {count} file(s) for project {designId} to {path}"
13
+ },
14
+ "errors": {
15
+ "missingConnectionInfo": "Missing connection info (cloudUrl, accessToken, or folderId)",
16
+ "signalRConnectionFailed": "Failed to connect to SignalR hub",
17
+ "hubConnectionFailed": "Failed to connect to SignalR hub at {url}: {message}",
18
+ "packSucceededNoBucket": "Pack succeeded but no BucketId was returned",
19
+ "packAgentFailed": "Pack agent failed with status {status} (code {errorCode})",
20
+ "noResultForProject": "No result for project",
21
+ "beginSessionFailed": "BeginSession failed ({status}): {errorText}",
22
+ "hubConnectionClosed": "Hub connection closed unexpectedly",
23
+ "packAgentDisconnected": "Pack agent disconnected unexpectedly",
24
+ "deleteBucketFailed": "Unable to delete temporary storage bucket on Orchestrator: {statusText}",
25
+ "cleanupBucketFailed": "Unable to cleanup remote bucket {bucketId}: {message}",
26
+ "getBucketUriFailed": "Failed to get bucket read URI ({status}): {errorText}",
27
+ "downloadArchiveFailed": "Failed to download archive from bucket ({status}): {statusText}",
28
+ "noMatchingProject": "No matching project found for path: {projectPath}",
29
+ "noOutputForProject": "No output found for project {designId}",
30
+ "distributePackagesFailed": "Failed to distribute packages for {designId}: {message}",
31
+ "sessionTimeout": "Session timed out waiting for projects: received {received} of {expected} expected projects"
32
+ }
33
+ }
34
+ }
package/src/index.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
2
+ import "./i18n/index.js";
3
+ import { WorkflowCompilerToolFactory } from "./workflow-compiler-tool-factory.js";
4
+
5
+ toolsFactoryRepository.registerProjectToolFactory(
6
+ new WorkflowCompilerToolFactory(),
7
+ );
@@ -0,0 +1,309 @@
1
+ import {
2
+ type ConnectionInfo,
3
+ type IFileSystem,
4
+ type IProjectPackOptions,
5
+ type IToolLogger,
6
+ type ProjectOperationContext,
7
+ ToolErrorCodes,
8
+ ToolResult,
9
+ toRelativeUrl,
10
+ translate,
11
+ ZipService,
12
+ } from "@uipath/solutionpackager-tool-core";
13
+
14
+ interface BlobFileAccessDto {
15
+ Uri: string;
16
+ Verb: string;
17
+ Headers: Record<string, string>;
18
+ }
19
+
20
+ interface ProjectResultEntry {
21
+ options: IProjectPackOptions;
22
+ }
23
+
24
+ export class PackResultProcessor {
25
+ private readonly zipService: ZipService;
26
+
27
+ constructor(
28
+ private readonly fileSystem: IFileSystem,
29
+ private readonly logger?: IToolLogger,
30
+ ) {
31
+ this.zipService = new ZipService(fileSystem);
32
+ }
33
+
34
+ async processAsync(
35
+ bucketId: number,
36
+ projects: Map<string, ProjectResultEntry>,
37
+ context: ProjectOperationContext,
38
+ ): Promise<Map<string, ToolResult>> {
39
+ const connection = context.connection!;
40
+ const results = new Map<string, ToolResult>();
41
+ const tempDir = await this.fileSystem.getTempDir();
42
+ const extractPath = `${tempDir}/pack-result-${context.id}`;
43
+
44
+ try {
45
+ this.logger?.info(
46
+ translate.t(
47
+ "toolWorkflowCompilerBrowser.info.downloadingArchive",
48
+ { bucketId },
49
+ ),
50
+ );
51
+ const zipData = await this.downloadArchiveAsync(
52
+ bucketId,
53
+ connection,
54
+ );
55
+ this.logger?.info(
56
+ translate.t(
57
+ "toolWorkflowCompilerBrowser.info.extractingArchive",
58
+ { size: zipData.length, path: extractPath },
59
+ ),
60
+ );
61
+ await this.zipService.extractAsync(zipData, extractPath);
62
+ this.logger?.info(
63
+ translate.t(
64
+ "toolWorkflowCompilerBrowser.info.distributingPackages",
65
+ { count: projects.size },
66
+ ),
67
+ );
68
+ await this.distributePackages(
69
+ extractPath,
70
+ projects,
71
+ context,
72
+ results,
73
+ );
74
+ } catch (error) {
75
+ const message =
76
+ error instanceof Error ? error.message : String(error);
77
+ for (const [projectPath] of projects) {
78
+ if (!results.has(projectPath)) {
79
+ results.set(
80
+ projectPath,
81
+ ToolResult.error("PackResultError", message),
82
+ );
83
+ }
84
+ }
85
+ } finally {
86
+ this.logger?.info(
87
+ translate.t(
88
+ "toolWorkflowCompilerBrowser.info.cleaningUpTempDir",
89
+ { path: extractPath },
90
+ ),
91
+ );
92
+ await this.fileSystem.rm(extractPath).catch(() => {});
93
+ await this.deleteBucketAsync(bucketId, connection);
94
+ }
95
+
96
+ return results;
97
+ }
98
+
99
+ private async downloadArchiveAsync(
100
+ bucketId: number,
101
+ connection: ConnectionInfo,
102
+ ): Promise<Uint8Array> {
103
+ const blobAccess = await this.getReadUriAsync(bucketId, connection);
104
+ return await this.downloadBlobAsync(blobAccess);
105
+ }
106
+
107
+ private async deleteBucketAsync(
108
+ bucketId: number,
109
+ connection: ConnectionInfo,
110
+ ): Promise<void> {
111
+ try {
112
+ if (!bucketId) {
113
+ return;
114
+ }
115
+
116
+ const baseUrl = toRelativeUrl(connection.cloudUrl!);
117
+ const url = `${baseUrl}/orchestrator_/odata/Buckets(${bucketId})`;
118
+
119
+ this.logger?.info(
120
+ translate.t("toolWorkflowCompilerBrowser.info.deletingBucket", {
121
+ bucketId,
122
+ }),
123
+ );
124
+
125
+ const response = await fetch(url, {
126
+ method: "DELETE",
127
+ headers: {
128
+ Authorization: `Bearer ${connection.accessToken}`,
129
+ "X-UIPATH-OrganizationUnitId": connection.folderId ?? "",
130
+ },
131
+ });
132
+
133
+ if (!response.ok) {
134
+ throw new Error(
135
+ translate.t(
136
+ "toolWorkflowCompilerBrowser.errors.deleteBucketFailed",
137
+ { statusText: response.statusText },
138
+ ),
139
+ );
140
+ }
141
+ } catch (error) {
142
+ const message =
143
+ error instanceof Error ? error.message : String(error);
144
+ this.logger?.warn(
145
+ translate.t(
146
+ "toolWorkflowCompilerBrowser.errors.cleanupBucketFailed",
147
+ { bucketId, message },
148
+ ),
149
+ );
150
+ }
151
+ }
152
+
153
+ private async getReadUriAsync(
154
+ bucketId: number,
155
+ connection: ConnectionInfo,
156
+ ): Promise<BlobFileAccessDto> {
157
+ const baseUrl = toRelativeUrl(connection.cloudUrl!);
158
+ const url =
159
+ `${baseUrl}/orchestrator_/odata/Buckets(${bucketId})` +
160
+ `/UiPath.Server.Configuration.OData.GetReadUri` +
161
+ `?path=rpa-packages.zip&expiryInMinutes=0`;
162
+
163
+ const response = await fetch(url, {
164
+ method: "GET",
165
+ headers: {
166
+ Authorization: `Bearer ${connection.accessToken}`,
167
+ "X-UIPATH-OrganizationUnitId": connection.folderId ?? "",
168
+ },
169
+ });
170
+
171
+ if (!response.ok) {
172
+ const errorText = await response.text();
173
+ throw new Error(
174
+ translate.t(
175
+ "toolWorkflowCompilerBrowser.errors.getBucketUriFailed",
176
+ { status: response.status, errorText },
177
+ ),
178
+ );
179
+ }
180
+
181
+ return (await response.json()) as BlobFileAccessDto;
182
+ }
183
+
184
+ private async downloadBlobAsync(
185
+ blobAccess: BlobFileAccessDto,
186
+ ): Promise<Uint8Array> {
187
+ const headers: Record<string, string> = {};
188
+ if (blobAccess.Headers) {
189
+ for (const [key, value] of Object.entries(blobAccess.Headers)) {
190
+ headers[key] = value;
191
+ }
192
+ }
193
+
194
+ const response = await fetch(blobAccess.Uri, {
195
+ method: blobAccess.Verb || "GET",
196
+ headers,
197
+ });
198
+
199
+ if (!response.ok) {
200
+ throw new Error(
201
+ translate.t(
202
+ "toolWorkflowCompilerBrowser.errors.downloadArchiveFailed",
203
+ {
204
+ status: response.status,
205
+ statusText: response.statusText,
206
+ },
207
+ ),
208
+ );
209
+ }
210
+
211
+ const buffer = await response.arrayBuffer();
212
+ return new Uint8Array(buffer);
213
+ }
214
+
215
+ private async distributePackages(
216
+ extractPath: string,
217
+ projects: Map<string, ProjectResultEntry>,
218
+ context: ProjectOperationContext,
219
+ results: Map<string, ToolResult>,
220
+ ): Promise<void> {
221
+ for (const [projectPath, entry] of projects) {
222
+ const project = context.solution.Projects.find(
223
+ (p) => p.ProjectPath === projectPath,
224
+ );
225
+
226
+ if (!project) {
227
+ results.set(
228
+ projectPath,
229
+ ToolResult.error(
230
+ "PackResultError",
231
+ translate.t(
232
+ "toolWorkflowCompilerBrowser.errors.noMatchingProject",
233
+ { projectPath },
234
+ ),
235
+ ),
236
+ );
237
+ continue;
238
+ }
239
+
240
+ const designId = project.Id;
241
+ const projectFilesDir = `${extractPath}/${designId}`;
242
+ const outputPath = entry.options.outputPath;
243
+
244
+ try {
245
+ const exists = await this.fileSystem.exists(projectFilesDir);
246
+ if (!exists) {
247
+ results.set(
248
+ projectPath,
249
+ ToolResult.error(
250
+ "PackResultError",
251
+ translate.t(
252
+ "toolWorkflowCompilerBrowser.errors.noOutputForProject",
253
+ { designId },
254
+ ),
255
+ ),
256
+ );
257
+ continue;
258
+ }
259
+
260
+ const files = await this.fileSystem.readdir(projectFilesDir);
261
+ const outputFiles: string[] = [];
262
+
263
+ await this.fileSystem.mkdir(outputPath);
264
+ this.logger?.info(
265
+ translate.t(
266
+ "toolWorkflowCompilerBrowser.info.copyingFiles",
267
+ {
268
+ count: files.length,
269
+ designId,
270
+ path: outputPath,
271
+ },
272
+ ),
273
+ );
274
+
275
+ for (const fileName of files) {
276
+ const srcFile = `${projectFilesDir}/${fileName}`;
277
+ const destFile = `${outputPath}/${fileName}`;
278
+ const data = await this.fileSystem.readFile(srcFile);
279
+ if (data) {
280
+ await this.fileSystem.writeFile(destFile, data);
281
+ outputFiles.push(destFile);
282
+ }
283
+ }
284
+
285
+ results.set(
286
+ projectPath,
287
+ new ToolResult(
288
+ ToolErrorCodes.Success,
289
+ undefined,
290
+ outputFiles,
291
+ ),
292
+ );
293
+ } catch (error) {
294
+ const message =
295
+ error instanceof Error ? error.message : String(error);
296
+ results.set(
297
+ projectPath,
298
+ ToolResult.error(
299
+ "PackResultError",
300
+ translate.t(
301
+ "toolWorkflowCompilerBrowser.errors.distributePackagesFailed",
302
+ { designId, message },
303
+ ),
304
+ ),
305
+ );
306
+ }
307
+ }
308
+ }
309
+ }