@uipath/solutionpackager-sdk 1.0.10
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/README.md +308 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +57310 -0
- package/dist/index.js.LICENSE.txt +7 -0
- package/dist/index.js.map +1 -0
- package/dist/node.d.ts +10 -0
- package/dist/node.js +41773 -0
- package/dist/node.js.map +1 -0
- package/package.json +60 -0
package/README.md
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
# Solution Packager
|
|
2
|
+
|
|
3
|
+
A Module Federation Enterprise (MFE) orchestrator for UiPath solution packaging. This tool provides a framework for registering and executing project-specific packaging tools with cross-platform filesystem support.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Solution Packager is a dummy tool framework designed to:
|
|
8
|
+
|
|
9
|
+
- Register project-type-specific packaging tools
|
|
10
|
+
- Orchestrate execution across multiple projects in a solution
|
|
11
|
+
- Provide unified filesystem access (Node.js and Browser environments)
|
|
12
|
+
- Track execution time and results for each tool
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### WorkflowCompiler Prerequisite
|
|
21
|
+
|
|
22
|
+
The Node.js implementation of the WorkflowCompiler tool (used for Process, Library, WebApp, and Tests projects) requires the UiPath WorkflowCompiler to be installed locally. From the packager root directory, run:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Windows (default)
|
|
26
|
+
npm run download:workflowcompiler
|
|
27
|
+
|
|
28
|
+
# Linux
|
|
29
|
+
npm run download:workflowcompiler:core
|
|
30
|
+
|
|
31
|
+
# macOS
|
|
32
|
+
npm run download:workflowcompiler:macos
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Requirements:** Azure CLI must be installed and authenticated (`az login`) with access to the UiPath Azure DevOps organization. The tool will be installed to `packager/tools/workflowcompiler/`. The browser implementation does not require local installation as it delegates to a remote agent.
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Registering a Tool
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { registerTool } from "solutionpackager";
|
|
43
|
+
|
|
44
|
+
registerTool({
|
|
45
|
+
name: "MyTool",
|
|
46
|
+
projectType: "myproject",
|
|
47
|
+
execute: async (path, params, fs) => {
|
|
48
|
+
// Use the filesystem abstraction
|
|
49
|
+
await fs.writeFile("/output.txt", "Hello World");
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
success: true,
|
|
53
|
+
logs: ["Tool executed successfully"],
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Running a Solution
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { runSolution } from "solutionpackager";
|
|
63
|
+
|
|
64
|
+
// Node.js environment (no lazy loading)
|
|
65
|
+
const results = await runSolution("path/to/solution.sln", { param: "value" });
|
|
66
|
+
|
|
67
|
+
// Browser environment (with lazy loading support)
|
|
68
|
+
const results = await runSolution(
|
|
69
|
+
"path/to/solution.sln",
|
|
70
|
+
{ param: "value" },
|
|
71
|
+
{
|
|
72
|
+
lazyLoad: async (path: string) => {
|
|
73
|
+
// Fetch file content from remote server
|
|
74
|
+
const response = await fetch(`/api/files${path}`);
|
|
75
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Development
|
|
82
|
+
|
|
83
|
+
### Build
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm run build
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Builds the project using `rslib` and generates:
|
|
90
|
+
|
|
91
|
+
- ES module output in `dist/`
|
|
92
|
+
- TypeScript declarations
|
|
93
|
+
- Module Federation remote entry point
|
|
94
|
+
|
|
95
|
+
### Testing
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
# Run all tests (Node.js environment)
|
|
99
|
+
npm test
|
|
100
|
+
|
|
101
|
+
# Run browser tests
|
|
102
|
+
npm run test:browser
|
|
103
|
+
|
|
104
|
+
# Run with coverage
|
|
105
|
+
npm run test:coverage
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### End-to-End Testing
|
|
109
|
+
|
|
110
|
+
The e2e tests pack a complete UiPath solution and verify the output structure:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Run e2e tests
|
|
114
|
+
npm test solution-packager-e2e
|
|
115
|
+
|
|
116
|
+
# Run e2e tests in watch mode
|
|
117
|
+
npx vitest solution-packager-e2e
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**What the e2e test does:**
|
|
121
|
+
|
|
122
|
+
1. Loads the test solution from `tests/test-data/Blueprints/SupportedProjectsSolution.uis`
|
|
123
|
+
2. Extracts and packs the solution using the solution packager
|
|
124
|
+
3. Creates a packaged archive (`.zip`) in a temporary directory
|
|
125
|
+
4. Verifies the output structure contains:
|
|
126
|
+
- A `files/` directory with project outputs
|
|
127
|
+
- `.nupkg` files for each project in the solution
|
|
128
|
+
|
|
129
|
+
**Inspecting the output:**
|
|
130
|
+
|
|
131
|
+
The test creates output in a temporary directory (OS temp folder). To keep the output for inspection, modify the test to use a known directory or add a breakpoint after packing completes. The output archive structure looks like:
|
|
132
|
+
|
|
133
|
+
```text
|
|
134
|
+
SupportedProjectsSolution_<version>.zip
|
|
135
|
+
└── files/
|
|
136
|
+
├── <project-id-1>/
|
|
137
|
+
│ └── <project-name>.nupkg
|
|
138
|
+
├── <project-id-2>/
|
|
139
|
+
│ └── <project-name>.nupkg
|
|
140
|
+
└── ...
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Each `.nupkg` file contains the packaged RPA project with all dependencies and metadata.
|
|
144
|
+
|
|
145
|
+
#### Test Coverage
|
|
146
|
+
|
|
147
|
+
- **Node.js Tests**: Validates platform detection and ensures lazy loading is rejected in Node.js environment
|
|
148
|
+
- **Browser Tests**: Tests tool registration, execution, filesystem operations, and lazy loading functionality
|
|
149
|
+
- **E2E Tests**: Complete solution packing workflow with real UiPath projects
|
|
150
|
+
|
|
151
|
+
## Architecture
|
|
152
|
+
|
|
153
|
+
### Core Components
|
|
154
|
+
|
|
155
|
+
- **`registry.ts`**: Tool registration and lookup system
|
|
156
|
+
- **`orchestrator.ts`**: Solution parsing and tool execution coordinator
|
|
157
|
+
- **`types.ts`**: TypeScript interfaces for tools, projects, and solutions
|
|
158
|
+
|
|
159
|
+
### Dependencies
|
|
160
|
+
|
|
161
|
+
- **`uipath-solutionpackager-tool-core`**: Cross-platform filesystem abstraction
|
|
162
|
+
|
|
163
|
+
## Tool Package Requirements
|
|
164
|
+
|
|
165
|
+
Tool packages consumed by the SDK must follow these conventions to ensure correct bundling and compatibility.
|
|
166
|
+
|
|
167
|
+
### package.json
|
|
168
|
+
|
|
169
|
+
- **`type`**: Must be `"module"` (ESM)
|
|
170
|
+
- **`exports`**: Must include both `source` and `default` conditions:
|
|
171
|
+
```json
|
|
172
|
+
"exports": {
|
|
173
|
+
".": {
|
|
174
|
+
"source": "./src/index.ts",
|
|
175
|
+
"default": "./dist/index.js"
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
The `source` condition allows the SDK bundler to resolve directly from TypeScript source (via `conditionNames: ["source", "import", "default"]`), enabling better tree-shaking and avoiding double-bundling.
|
|
180
|
+
- **`files`**: Must include both `dist` and `src`:
|
|
181
|
+
```json
|
|
182
|
+
"files": ["dist", "src"]
|
|
183
|
+
```
|
|
184
|
+
- **`types`**: Must point to `"./dist/index.d.ts"`
|
|
185
|
+
- **`peerDependencies`**: `@uipath/solutionpackager-tool-core` should be a peer dependency (not a regular dependency)
|
|
186
|
+
|
|
187
|
+
### rslib.config.ts
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
import { defineConfig } from '@rslib/core';
|
|
191
|
+
|
|
192
|
+
export default defineConfig({
|
|
193
|
+
source: {
|
|
194
|
+
entry: {
|
|
195
|
+
index: './src/index.ts',
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
lib: [
|
|
199
|
+
{
|
|
200
|
+
bundle: true,
|
|
201
|
+
format: 'esm',
|
|
202
|
+
syntax: 'es2021',
|
|
203
|
+
dts: true,
|
|
204
|
+
autoExternal: true,
|
|
205
|
+
},
|
|
206
|
+
],
|
|
207
|
+
output: {
|
|
208
|
+
target: 'web',
|
|
209
|
+
},
|
|
210
|
+
tools: {
|
|
211
|
+
rspack: {
|
|
212
|
+
devtool: 'source-map',
|
|
213
|
+
output: {
|
|
214
|
+
devtoolModuleFilenameTemplate: 'webpack://<tool-name>/[resource-path]',
|
|
215
|
+
},
|
|
216
|
+
resolve: {
|
|
217
|
+
fallback: {
|
|
218
|
+
'fs/promises': false,
|
|
219
|
+
fs: false,
|
|
220
|
+
path: false,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
Key settings:
|
|
229
|
+
- **`autoExternal: true`**: Keeps dependencies external. The SDK (`autoExternal: false`, `all-in-one`) handles bundling everything into a standalone output.
|
|
230
|
+
- **`target: "web"`**: Tools must work in both browser and Node.js. This ensures no Node.js built-ins leak into the bundle.
|
|
231
|
+
- **`fallback`**: Silences bundler errors for Node.js module imports from `solutionpackager-tool-core` or transitive dependencies.
|
|
232
|
+
- **`devtool: "source-map"`**: Enables debugging with properly namespaced source maps.
|
|
233
|
+
|
|
234
|
+
## Platform Support
|
|
235
|
+
|
|
236
|
+
- **Node.js**: Uses native `fs` module, lazy loading not supported
|
|
237
|
+
- **Browser**: Uses ZenFS with IndexedDB backend, supports lazy loading for on-demand file fetching
|
|
238
|
+
|
|
239
|
+
## Current Status
|
|
240
|
+
|
|
241
|
+
The framework is **fully functional** for:
|
|
242
|
+
|
|
243
|
+
- **Module Federation**: Dynamic loading of external tool packages (`apiworkflow`, `connector`) at runtime.
|
|
244
|
+
- **Cross-Platform Filesystem**: Seamless file operations in both Node.js and Browser (via ZenFS).
|
|
245
|
+
- **Tool Orchestration**: Registration and execution flow is complete.
|
|
246
|
+
|
|
247
|
+
For a live demonstration of the browser capabilities, see the [Test Browser](../test-browser/README.md) project.
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
### Console Interception with LogInterceptor
|
|
252
|
+
|
|
253
|
+
The `solutionpackager` package provides a `logInterceptor` singleton that intercepts console methods and allows you to register callbacks to process log messages. This is useful for capturing logs during execution and forwarding them to external logging services, displaying them in UI, or storing them for analysis.
|
|
254
|
+
|
|
255
|
+
#### Complete Example: Intercepting Build Logs
|
|
256
|
+
|
|
257
|
+
```typescript
|
|
258
|
+
import { logInterceptor, LogLevel, LogMessage } from 'solutionpackager';
|
|
259
|
+
|
|
260
|
+
// Storage for captured logs
|
|
261
|
+
const capturedLogs: LogMessage[] = [];
|
|
262
|
+
|
|
263
|
+
// Define callback to capture logs
|
|
264
|
+
const captureCallback = (logMessage: LogMessage) => {
|
|
265
|
+
capturedLogs.push(logMessage);
|
|
266
|
+
|
|
267
|
+
// Forward errors to monitoring service
|
|
268
|
+
if (logMessage.logLevel === LogLevel.Error) {
|
|
269
|
+
notifyErrorMonitoring(logMessage);
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// Start interception
|
|
274
|
+
logInterceptor.registerCallback(captureCallback);
|
|
275
|
+
logInterceptor.startIntercepting(LogLevel.Info);
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
// Execute your functionality - all console logs will be captured
|
|
279
|
+
await buildSolution('path/to/solution.sln');
|
|
280
|
+
|
|
281
|
+
// Can also log structured messages
|
|
282
|
+
console.log(new LogMessage('Build completed successfully', LogLevel.Info, {
|
|
283
|
+
source: 'build',
|
|
284
|
+
progress: 100,
|
|
285
|
+
}));
|
|
286
|
+
|
|
287
|
+
} finally {
|
|
288
|
+
// Clean up
|
|
289
|
+
logInterceptor.unregisterCallback(captureCallback);
|
|
290
|
+
logInterceptor.stopIntercepting();
|
|
291
|
+
|
|
292
|
+
// Process captured logs
|
|
293
|
+
console.log(`Captured ${capturedLogs.length} log messages`);
|
|
294
|
+
const errors = capturedLogs.filter(log => log.logLevel === LogLevel.Error);
|
|
295
|
+
console.log(`Found ${errors.length} errors`);
|
|
296
|
+
}```
|
|
297
|
+
|
|
298
|
+
#### Important Notes
|
|
299
|
+
|
|
300
|
+
- Callbacks are invoked **synchronously** for each log message
|
|
301
|
+
- Logs from within callbacks are **not** re-intercepted (recursion prevention)
|
|
302
|
+
- All intercepted logs are still written to the original console
|
|
303
|
+
- LogMessage instances passed to console methods are automatically detected and formatted
|
|
304
|
+
- Regular console arguments are converted to LogMessage instances with the appropriate level
|
|
305
|
+
|
|
306
|
+
## License
|
|
307
|
+
|
|
308
|
+
Internal UiPath project
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "@uipath/tool-connector";
|
|
2
|
+
import "@uipath/tool-workflowcompiler";
|
|
3
|
+
import "@uipath/tool-apiworkflow";
|
|
4
|
+
import "@uipath/tool-bpmn";
|
|
5
|
+
import "@uipath/tool-flow";
|
|
6
|
+
import "@uipath/tool-case";
|
|
7
|
+
import "@uipath/tool-agent";
|
|
8
|
+
import "@uipath/tool-webapp";
|
|
9
|
+
import "@uipath/resource-builder-tool";
|
|
10
|
+
export * from "@uipath/solution-packager";
|