@uipath/packager-tool-connector 1.202.0-preview.140 → 1.202.0-preview.142

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.
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "@uipath/packager-tool-connector",
3
- "version": "1.202.0-preview.140",
3
+ "version": "1.202.0-preview.142",
4
4
  "description": "UiPath Connector tool implementation",
5
5
  "type": "module",
6
6
  "exports": {
7
- ".": {
8
- "source": "./src/index.ts",
9
- "default": "./dist/index.js"
10
- }
7
+ ".": "./dist/index.js"
11
8
  },
12
9
  "repository": {
13
10
  "type": "git",
@@ -19,13 +16,12 @@
19
16
  },
20
17
  "types": "./dist/index.d.ts",
21
18
  "files": [
22
- "dist",
23
- "src"
19
+ "dist"
24
20
  ],
25
21
  "author": "",
26
22
  "license": "ISC",
27
23
  "peerDependencies": {
28
24
  "@uipath/solutionpackager-tool-core": "1.202.0"
29
25
  },
30
- "gitHead": "1861498d8a158a710a718c04614523ba59c93781"
26
+ "gitHead": "2f7204440851d62ecc9f2d2e202c863293821d90"
31
27
  }
@@ -1,23 +0,0 @@
1
- import {
2
- type IFileSystem,
3
- type IProjectToolFactory,
4
- type IToolLogger,
5
- type ProjectTool,
6
- type ProjectType,
7
- ProjectTypes,
8
- } from "@uipath/solutionpackager-tool-core";
9
- import { ConnectorTool } from "./connector-tool.js";
10
-
11
- /**
12
- * Factory for creating Connector project tools
13
- */
14
- export class ConnectorToolFactory implements IProjectToolFactory {
15
- readonly supportedTypes: readonly ProjectType[] = [ProjectTypes.Connector];
16
-
17
- async createAsync(
18
- logger: IToolLogger,
19
- fileSystem: IFileSystem,
20
- ): Promise<ProjectTool> {
21
- return new ConnectorTool(fileSystem, logger);
22
- }
23
- }
@@ -1,284 +0,0 @@
1
- import type {
2
- IProjectBuildOptions,
3
- IProjectPackOptions,
4
- IProjectRestoreOptions,
5
- IProjectValidateOptions,
6
- } from "@uipath/solutionpackager-tool-core";
7
- import {
8
- ensureProjectId,
9
- type IFileSystem,
10
- type IToolLogger,
11
- NugetConstants,
12
- NugetPackager,
13
- Path,
14
- ProjectTool,
15
- ProjectTypes,
16
- TemporaryStorageService,
17
- ToolErrorCodes,
18
- ToolResult,
19
- writeOrBackfillOperateProjectId,
20
- } from "@uipath/solutionpackager-tool-core";
21
-
22
- /**
23
- * Connector project tool implementation
24
- *
25
- * Handles build and pack operations for Connector projects.
26
- * Build copies the 'app' folder to the output content folder.
27
- */
28
- export class ConnectorTool extends ProjectTool {
29
- private static readonly AppFolderName = "app";
30
- private readonly _temporaryStorage: TemporaryStorageService;
31
-
32
- constructor(fileSystem: IFileSystem, logger: IToolLogger) {
33
- super(fileSystem, logger);
34
- this._temporaryStorage = new TemporaryStorageService(fileSystem);
35
- }
36
-
37
- override async restoreAsync(
38
- _options: IProjectRestoreOptions,
39
- _cancellationToken?: AbortSignal,
40
- ): Promise<ToolResult> {
41
- this.logger.info(
42
- "Restore operation is not required for Connector projects",
43
- );
44
- return ToolResult.success();
45
- }
46
-
47
- override async validateAsync(
48
- _options: IProjectValidateOptions,
49
- _cancellationToken?: AbortSignal,
50
- ): Promise<ToolResult> {
51
- this.logger.info(
52
- "Validate operation is not required for Connector projects",
53
- );
54
- return ToolResult.success();
55
- }
56
-
57
- override async buildAsync(
58
- options: IProjectBuildOptions,
59
- _cancellationToken?: AbortSignal,
60
- ): Promise<ToolResult> {
61
- const tempFolder = await this._temporaryStorage.getTempFolderPath();
62
- const localBuildFolder = Path.join(
63
- tempFolder,
64
- NugetConstants.OutputFolderName,
65
- );
66
- const appProjectFolder = Path.join(
67
- options.projectPath,
68
- ConnectorTool.AppFolderName,
69
- );
70
- const destinationFolder = Path.join(
71
- localBuildFolder,
72
- NugetConstants.ContentFolderName,
73
- ConnectorTool.AppFolderName,
74
- );
75
-
76
- try {
77
- this.logger.progress("Copying app folder...");
78
- await this.copyDirectory(appProjectFolder, destinationFolder);
79
-
80
- this.logger.progress("Creating operate.json file...");
81
- await this.createOperateFile(options, localBuildFolder);
82
-
83
- this.logger.progress("Creating package-descriptor.json file...");
84
- await this.createPackageDescriptor(localBuildFolder);
85
-
86
- return new ToolResult(ToolErrorCodes.Success, "done", [
87
- localBuildFolder,
88
- ]);
89
- } catch (error) {
90
- const errorMessage =
91
- error instanceof Error ? error.toString() : String(error);
92
- this.logger.error(errorMessage);
93
- return ToolResult.error(
94
- ToolErrorCodes.InternalError,
95
- "An error occurred while building Connector project",
96
- );
97
- }
98
- }
99
-
100
- override async packAsync(
101
- options: IProjectPackOptions,
102
- cancellationToken?: AbortSignal,
103
- ): Promise<ToolResult> {
104
- // First, run the build step to prepare the bundle content
105
- const buildResult = await this.buildAsync(options, cancellationToken);
106
- if (!buildResult.isSuccess) {
107
- return buildResult;
108
- }
109
-
110
- const localBuildFolder = buildResult.packages[0];
111
-
112
- try {
113
- // Create the NuGet package
114
- this.logger.progress("Creating NuGet package...");
115
-
116
- const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
117
- const nupkgPath = Path.join(options.outputPath, nupkgFileName);
118
-
119
- const packager = new NugetPackager(this.fileSystem);
120
- const result = await packager.packAsync(
121
- localBuildFolder,
122
- options.package,
123
- nupkgPath,
124
- );
125
-
126
- this.logger.progress("Package created successfully");
127
- return new ToolResult(ToolErrorCodes.Success, "done", [
128
- result.outputPath,
129
- ]);
130
- } catch (error) {
131
- const errorMessage =
132
- error instanceof Error ? error.toString() : String(error);
133
- this.logger.error(errorMessage);
134
- return ToolResult.error(
135
- ToolErrorCodes.InternalError,
136
- "An error occurred while packing Connector project",
137
- );
138
- }
139
- }
140
-
141
- override async dispose(): Promise<void> {
142
- this.logger.info("Disposing Connector Tool");
143
- try {
144
- await this._temporaryStorage.cleanup();
145
- } catch {
146
- // Ignore errors during cleanup
147
- }
148
- }
149
-
150
- private async createOperateFile(
151
- options: IProjectBuildOptions,
152
- localBuildFolder: string,
153
- ): Promise<void> {
154
- const contentFolder = Path.join(
155
- localBuildFolder,
156
- NugetConstants.ContentFolderName,
157
- );
158
- const operateJsonFilePath = Path.join(
159
- contentFolder,
160
- NugetConstants.OperateFileName,
161
- );
162
-
163
- const projectId =
164
- options.projectStorageId ??
165
- (await this.resolveConnectorProjectId(options.projectPath));
166
-
167
- await writeOrBackfillOperateProjectId(
168
- operateJsonFilePath,
169
- projectId,
170
- this.fileSystem,
171
- // Connector packages bundle content/app/ as the unit; no single
172
- // entry file, so main is intentionally empty.
173
- () =>
174
- this.fileSystem.writeFile(
175
- operateJsonFilePath,
176
- JSON.stringify(
177
- {
178
- $schema:
179
- "https://cloud.uipath.com/draft/2024-12/operate",
180
- contentType: ProjectTypes.Connector,
181
- projectId,
182
- main: "",
183
- targetFramework: "Portable",
184
- runtimeOptions: {
185
- isAttended: false,
186
- requiresUserInteraction: false,
187
- },
188
- },
189
- null,
190
- 2,
191
- ),
192
- ),
193
- );
194
- }
195
-
196
- /**
197
- * Anchor the connector's projectId in a source-side project.json so
198
- * repeated direct packs (no projectStorageId from a solution) reuse
199
- * the same id. ensureProjectId only persists into files that already
200
- * exist; connector projects typically have neither operate.json nor
201
- * project.json, so we scaffold project.json on first pack. The file
202
- * stays out of the nupkg because the build copies only the `app/`
203
- * subfolder.
204
- */
205
- private async resolveConnectorProjectId(
206
- projectPath: string,
207
- ): Promise<string> {
208
- const operatePath = Path.join(projectPath, "operate.json");
209
- const projectFilePath = Path.join(projectPath, "project.json");
210
- const hasAnchor =
211
- (await this.fileSystem.exists(operatePath)) ||
212
- (await this.fileSystem.exists(projectFilePath));
213
- if (hasAnchor) {
214
- return ensureProjectId(projectPath, this.fileSystem);
215
- }
216
-
217
- const id = crypto.randomUUID();
218
- await this.fileSystem.writeFile(
219
- projectFilePath,
220
- `${JSON.stringify({ projectId: id }, null, 2)}\n`,
221
- );
222
- return id;
223
- }
224
-
225
- private async createPackageDescriptor(
226
- localBuildFolder: string,
227
- ): Promise<void> {
228
- const packageDescriptorPath = Path.join(
229
- localBuildFolder,
230
- NugetConstants.ContentFolderName,
231
- NugetConstants.PackageDescriptorFileName,
232
- );
233
-
234
- const exists = await this.fileSystem.exists(packageDescriptorPath);
235
- if (exists) {
236
- return;
237
- }
238
-
239
- const descriptor = {
240
- $schema:
241
- "https://cloud.uipath.com/draft/2024-12/package-descriptor",
242
- files: {
243
- [NugetConstants.OperateFileName]: Path.join(
244
- NugetConstants.ContentFolderName,
245
- NugetConstants.OperateFileName,
246
- ),
247
- },
248
- };
249
-
250
- await this.fileSystem.writeFile(
251
- packageDescriptorPath,
252
- JSON.stringify(descriptor, null, 2),
253
- );
254
- }
255
-
256
- /**
257
- * Recursively copy a directory and its contents
258
- */
259
- private async copyDirectory(
260
- sourcePath: string,
261
- destinationPath: string,
262
- ): Promise<void> {
263
- await this.fileSystem.mkdir(destinationPath);
264
-
265
- const entries = await this.fileSystem.readdir(sourcePath);
266
-
267
- for (const entry of entries) {
268
- const sourceEntry = Path.join(sourcePath, entry);
269
- const destinationEntry = Path.join(destinationPath, entry);
270
-
271
- const stat = await this.fileSystem.stat(sourceEntry);
272
- if (stat?.isDirectory()) {
273
- // Recursively copy subdirectories
274
- await this.copyDirectory(sourceEntry, destinationEntry);
275
- } else if (stat?.isFile()) {
276
- // Copy file
277
- const content = await this.fileSystem.readFile(sourceEntry);
278
- if (content) {
279
- await this.fileSystem.writeFile(destinationEntry, content);
280
- }
281
- }
282
- }
283
- }
284
- }
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- // Connector tool factory. Consumers register it explicitly via
2
- // `toolsFactoryRepository.registerProjectToolFactory(new ConnectorToolFactory())`.
3
- export { ConnectorToolFactory } from "./connector-tool-factory.js";