@uipath/packager-tool-connector 0.0.18 → 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.
@@ -15,6 +15,18 @@ export declare class ConnectorTool extends ProjectTool {
15
15
  buildAsync(options: IProjectBuildOptions, _cancellationToken?: AbortSignal): Promise<ToolResult>;
16
16
  packAsync(options: IProjectPackOptions, cancellationToken?: AbortSignal): Promise<ToolResult>;
17
17
  dispose(): Promise<void>;
18
+ private createOperateFile;
19
+ /**
20
+ * Anchor the connector's projectId in a source-side project.json so
21
+ * repeated direct packs (no projectStorageId from a solution) reuse
22
+ * the same id. ensureProjectId only persists into files that already
23
+ * exist; connector projects typically have neither operate.json nor
24
+ * project.json, so we scaffold project.json on first pack. The file
25
+ * stays out of the nupkg because the build copies only the `app/`
26
+ * subfolder.
27
+ */
28
+ private resolveConnectorProjectId;
29
+ private createPackageDescriptor;
18
30
  /**
19
31
  * Recursively copy a directory and its contents
20
32
  */
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export { ConnectorToolFactory } from "./connector-tool-factory.js";
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
- // src/index.ts
2
- import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
3
-
4
1
  // src/connector-tool-factory.ts
5
2
  import {
6
- ProjectTypes
3
+ ProjectTypes as ProjectTypes2
7
4
  } from "@uipath/solutionpackager-tool-core";
8
5
 
9
6
  // src/connector-tool.ts
10
7
  import {
8
+ ensureProjectId,
11
9
  NugetConstants,
12
10
  NugetPackager,
13
11
  Path,
14
12
  ProjectTool,
13
+ ProjectTypes,
15
14
  TemporaryStorageService,
16
15
  ToolErrorCodes,
17
- ToolResult
16
+ ToolResult,
17
+ writeOrBackfillOperateProjectId
18
18
  } from "@uipath/solutionpackager-tool-core";
19
19
 
20
20
  class ConnectorTool extends ProjectTool {
@@ -40,6 +40,10 @@ class ConnectorTool extends ProjectTool {
40
40
  try {
41
41
  this.logger.progress("Copying app folder...");
42
42
  await this.copyDirectory(appProjectFolder, destinationFolder);
43
+ this.logger.progress("Creating operate.json file...");
44
+ await this.createOperateFile(options, localBuildFolder);
45
+ this.logger.progress("Creating package-descriptor.json file...");
46
+ await this.createPackageDescriptor(localBuildFolder);
43
47
  return new ToolResult(ToolErrorCodes.Success, "done", [
44
48
  localBuildFolder
45
49
  ]);
@@ -77,6 +81,48 @@ class ConnectorTool extends ProjectTool {
77
81
  await this._temporaryStorage.cleanup();
78
82
  } catch {}
79
83
  }
84
+ async createOperateFile(options, localBuildFolder) {
85
+ const contentFolder = Path.join(localBuildFolder, NugetConstants.ContentFolderName);
86
+ const operateJsonFilePath = Path.join(contentFolder, NugetConstants.OperateFileName);
87
+ const projectId = options.projectStorageId ?? await this.resolveConnectorProjectId(options.projectPath);
88
+ await writeOrBackfillOperateProjectId(operateJsonFilePath, projectId, this.fileSystem, () => this.fileSystem.writeFile(operateJsonFilePath, JSON.stringify({
89
+ $schema: "https://cloud.uipath.com/draft/2024-12/operate",
90
+ contentType: ProjectTypes.Connector,
91
+ projectId,
92
+ main: "",
93
+ targetFramework: "Portable",
94
+ runtimeOptions: {
95
+ isAttended: false,
96
+ requiresUserInteraction: false
97
+ }
98
+ }, null, 2)));
99
+ }
100
+ async resolveConnectorProjectId(projectPath) {
101
+ const operatePath = Path.join(projectPath, "operate.json");
102
+ const projectFilePath = Path.join(projectPath, "project.json");
103
+ const hasAnchor = await this.fileSystem.exists(operatePath) || await this.fileSystem.exists(projectFilePath);
104
+ if (hasAnchor) {
105
+ return ensureProjectId(projectPath, this.fileSystem);
106
+ }
107
+ const id = crypto.randomUUID();
108
+ await this.fileSystem.writeFile(projectFilePath, `${JSON.stringify({ projectId: id }, null, 2)}
109
+ `);
110
+ return id;
111
+ }
112
+ async createPackageDescriptor(localBuildFolder) {
113
+ const packageDescriptorPath = Path.join(localBuildFolder, NugetConstants.ContentFolderName, NugetConstants.PackageDescriptorFileName);
114
+ const exists = await this.fileSystem.exists(packageDescriptorPath);
115
+ if (exists) {
116
+ return;
117
+ }
118
+ const descriptor = {
119
+ $schema: "https://cloud.uipath.com/draft/2024-12/package-descriptor",
120
+ files: {
121
+ [NugetConstants.OperateFileName]: Path.join(NugetConstants.ContentFolderName, NugetConstants.OperateFileName)
122
+ }
123
+ };
124
+ await this.fileSystem.writeFile(packageDescriptorPath, JSON.stringify(descriptor, null, 2));
125
+ }
80
126
  async copyDirectory(sourcePath, destinationPath) {
81
127
  await this.fileSystem.mkdir(destinationPath);
82
128
  const entries = await this.fileSystem.readdir(sourcePath);
@@ -98,11 +144,13 @@ class ConnectorTool extends ProjectTool {
98
144
 
99
145
  // src/connector-tool-factory.ts
100
146
  class ConnectorToolFactory {
101
- supportedTypes = [ProjectTypes.Connector];
147
+ supportedTypes = [ProjectTypes2.Connector];
102
148
  async createAsync(logger, fileSystem) {
103
149
  return new ConnectorTool(fileSystem, logger);
104
150
  }
105
151
  }
152
+ export {
153
+ ConnectorToolFactory
154
+ };
106
155
 
107
- // src/index.ts
108
- toolsFactoryRepository.registerProjectToolFactory(new ConnectorToolFactory);
156
+ //# debugId=1CB272CEF003511564756E2164756E21
package/package.json CHANGED
@@ -1,59 +1,31 @@
1
1
  {
2
- "name": "@uipath/packager-tool-connector",
3
- "version": "0.0.18",
4
- "description": "UiPath Connector tool implementation",
5
- "type": "module",
6
- "exports": {
7
- ".": {
8
- "source": "./src/index.ts",
9
- "default": "./dist/index.js"
10
- }
11
- },
12
- "repository": {
13
- "type": "git",
14
- "url": "https://github.com/UiPath/cli.git",
15
- "directory": "packages/packager/packager-tool-connector"
16
- },
17
- "publishConfig": {
18
- "registry": "https://registry.npmjs.org/"
19
- },
20
- "types": "./dist/index.d.ts",
21
- "scripts": {
22
- "build": "bun build ./src/index.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core && tsc --emitDeclarationOnly --outDir dist",
23
- "dev": "bun build ./src/index.ts --outdir dist --format esm --target browser --external @uipath/solutionpackager-tool-core --watch",
24
- "test": "vitest run",
25
- "test:browser": "vitest run --config=vitest.browser.config.ts",
26
- "test:coverage": "vitest run --coverage",
27
- "test:browser:coverage": "vitest run --config=vitest.browser.config.ts --coverage",
28
- "test:all": "bun run test && bun run test:browser",
29
- "test:all:coverage": "bun run test:coverage && bun run test:browser:coverage",
30
- "prepack": "bun run build",
31
- "publish:dry": "bun publish --dry-run",
32
- "publish:gh": "bun publish",
33
- "version:patch": "bun version patch --no-git-tag-version",
34
- "version:minor": "bun version minor --no-git-tag-version",
35
- "version:major": "bun version major --no-git-tag-version",
36
- "lint": "biome check ."
37
- },
38
- "files": [
39
- "dist",
40
- "!dist/**/*.map",
41
- "src"
42
- ],
43
- "author": "",
44
- "license": "ISC",
45
- "peerDependencies": {
46
- "@uipath/solutionpackager-tool-core": "0.0.33"
47
- },
48
- "devDependencies": {
49
- "@types/node": "^25.5.0",
50
- "@uipath/solutionpackager-tool-core": "0.0.33",
51
- "@vitest/browser": "^4.0.14",
52
- "@vitest/browser-playwright": "^4.0.14",
53
- "@vitest/coverage-v8": "^4.0.14",
54
- "playwright": "^1.57.0",
55
- "typescript": "^5.9.3",
56
- "vitest": "^4.0.14"
57
- },
58
- "gitHead": "3f1b4d8e9f910be81e4cab956537f21dbd5d63ac"
2
+ "name": "@uipath/packager-tool-connector",
3
+ "version": "1.197.0-preview.64",
4
+ "description": "UiPath Connector tool implementation",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "source": "./src/index.ts",
9
+ "default": "./dist/index.js"
10
+ }
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/UiPath/cli.git",
15
+ "directory": "packages/packager/packager-tool-connector"
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "types": "./dist/index.d.ts",
21
+ "files": [
22
+ "dist",
23
+ "src"
24
+ ],
25
+ "author": "",
26
+ "license": "ISC",
27
+ "peerDependencies": {
28
+ "@uipath/solutionpackager-tool-core": "1.197.0"
29
+ },
30
+ "gitHead": "3977b977945bf519336258da69fd271433eaaef4"
59
31
  }
@@ -5,15 +5,18 @@ import type {
5
5
  IProjectValidateOptions,
6
6
  } from "@uipath/solutionpackager-tool-core";
7
7
  import {
8
+ ensureProjectId,
8
9
  type IFileSystem,
9
10
  type IToolLogger,
10
11
  NugetConstants,
11
12
  NugetPackager,
12
13
  Path,
13
14
  ProjectTool,
15
+ ProjectTypes,
14
16
  TemporaryStorageService,
15
17
  ToolErrorCodes,
16
18
  ToolResult,
19
+ writeOrBackfillOperateProjectId,
17
20
  } from "@uipath/solutionpackager-tool-core";
18
21
 
19
22
  /**
@@ -74,6 +77,12 @@ export class ConnectorTool extends ProjectTool {
74
77
  this.logger.progress("Copying app folder...");
75
78
  await this.copyDirectory(appProjectFolder, destinationFolder);
76
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
+
77
86
  return new ToolResult(ToolErrorCodes.Success, "done", [
78
87
  localBuildFolder,
79
88
  ]);
@@ -138,6 +147,112 @@ export class ConnectorTool extends ProjectTool {
138
147
  }
139
148
  }
140
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
+
141
256
  /**
142
257
  * Recursively copy a directory and its contents
143
258
  */
package/src/index.ts CHANGED
@@ -1,5 +1,3 @@
1
- // Self-register Connector tool factory with the singleton repository
2
- import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
3
- import { ConnectorToolFactory } from "./connector-tool-factory.js";
4
-
5
- toolsFactoryRepository.registerProjectToolFactory(new ConnectorToolFactory());
1
+ // Connector tool factory. Consumers register it explicitly via
2
+ // `toolsFactoryRepository.registerProjectToolFactory(new ConnectorToolFactory())`.
3
+ export { ConnectorToolFactory } from "./connector-tool-factory.js";