@uipath/case-tool 0.1.9 → 0.1.11
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 +107 -0
- package/dist/packager-tool.js +168 -0
- package/dist/tool.js +15642 -11495
- package/package.json +13 -15
package/README.md
CHANGED
|
@@ -87,6 +87,113 @@ If no cache exists, the command automatically fetches live data from the platfor
|
|
|
87
87
|
|
|
88
88
|
---
|
|
89
89
|
|
|
90
|
+
### `validate`
|
|
91
|
+
|
|
92
|
+
Validate a case management definition JSON file against all case management rules (structure, stages, edges, conditions).
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uip case validate <file>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Returns a list of errors and warnings. Exits with code `1` if any errors are found.
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
### `cases`
|
|
103
|
+
|
|
104
|
+
Manage local case management definition JSON files.
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
uip case cases <action>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
| Subcommand | Description |
|
|
111
|
+
| :--- | :--- |
|
|
112
|
+
| `add` | Create a new case management definition JSON file |
|
|
113
|
+
| `edit <file>` | Edit root-level properties of an existing definition |
|
|
114
|
+
| `validate <file>` | Validate a definition file (alias for `uip case validate`) |
|
|
115
|
+
|
|
116
|
+
**`cases add` options:**
|
|
117
|
+
|
|
118
|
+
| Option | Description |
|
|
119
|
+
| :--- | :--- |
|
|
120
|
+
| `-n, --name <name>` | Name of the case management definition *(required)* |
|
|
121
|
+
| `-f, --file <path>` | Output path for the new JSON file *(required)* |
|
|
122
|
+
| `--case-identifier <id>` | Case identifier string (defaults to name) |
|
|
123
|
+
| `--identifier-type <type>` | `constant` or `external` (default: `constant`) |
|
|
124
|
+
| `--case-app-enabled` | Enable the case app for this definition |
|
|
125
|
+
|
|
126
|
+
**`cases edit` options:**
|
|
127
|
+
|
|
128
|
+
| Option | Description |
|
|
129
|
+
| :--- | :--- |
|
|
130
|
+
| `-n, --name <name>` | New name |
|
|
131
|
+
| `--case-identifier <id>` | New case identifier |
|
|
132
|
+
| `--identifier-type <type>` | New identifier type |
|
|
133
|
+
| `--case-app-enabled` | Enable the case app |
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
### `stages`
|
|
138
|
+
|
|
139
|
+
Manage stage nodes within a case management definition JSON file.
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
uip case stages <action> <file> [stage-id]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
| Subcommand | Description |
|
|
146
|
+
| :--- | :--- |
|
|
147
|
+
| `add <file>` | Add a new stage node |
|
|
148
|
+
| `edit <file> <stage-id>` | Edit an existing stage's label |
|
|
149
|
+
| `get <file> <stage-id>` | Print a stage and its connected edges |
|
|
150
|
+
| `remove <file> <stage-id>` | Remove a stage and its connected edges |
|
|
151
|
+
|
|
152
|
+
**`stages add` options:**
|
|
153
|
+
|
|
154
|
+
| Option | Description |
|
|
155
|
+
| :--- | :--- |
|
|
156
|
+
| `-l, --label <label>` | Display label for the stage |
|
|
157
|
+
| `-t, --type <type>` | `stage`, `exception`, or `trigger` (default: `stage`) |
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### `edges`
|
|
162
|
+
|
|
163
|
+
Manage edges within a case management definition JSON file.
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
uip case edges <action> <file> [edge-id]
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
| Subcommand | Description |
|
|
170
|
+
| :--- | :--- |
|
|
171
|
+
| `add <file>` | Add a new edge between two nodes |
|
|
172
|
+
| `edit <file> <edge-id>` | Edit an existing edge |
|
|
173
|
+
| `get <file> <edge-id>` | Print an edge |
|
|
174
|
+
| `remove <file> <edge-id>` | Remove an edge |
|
|
175
|
+
| `validate <file> <edge-id>` | Validate a single edge in context |
|
|
176
|
+
| `list <file>` | List all edges in a definition |
|
|
177
|
+
|
|
178
|
+
**`edges add` options:**
|
|
179
|
+
|
|
180
|
+
| Option | Description |
|
|
181
|
+
| :--- | :--- |
|
|
182
|
+
| `-s, --source <id>` | Source stage or trigger ID *(required)* |
|
|
183
|
+
| `-t, --target <id>` | Target stage ID *(required)* |
|
|
184
|
+
| `-l, --label <label>` | Display label |
|
|
185
|
+
| `--source-handle <dir>` | `right`, `left`, `top`, `bottom` (default: `right`) |
|
|
186
|
+
| `--target-handle <dir>` | `right`, `left`, `top`, `bottom` (default: `left`) |
|
|
187
|
+
| `--z-index <number>` | Z-index layer for rendering order |
|
|
188
|
+
|
|
189
|
+
Edge type is inferred from the source node: Trigger → `TriggerEdge`, Stage → `Edge`.
|
|
190
|
+
|
|
191
|
+
**`edges validate` checks:**
|
|
192
|
+
- Source and target nodes exist
|
|
193
|
+
- No duplicate conditions on edges from the same source node
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
90
197
|
## Local Cache
|
|
91
198
|
|
|
92
199
|
Resources are stored in `~/.uipcli/case-resources/` as JSON files:
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// ../packager/packager-tool-case/src/index.ts
|
|
2
|
+
import { toolsFactoryRepository } from "@uipath/solutionpackager-tool-core";
|
|
3
|
+
|
|
4
|
+
// ../packager/packager-tool-case/src/case-tool-factory.ts
|
|
5
|
+
import {
|
|
6
|
+
ProjectTypes as ProjectTypes2
|
|
7
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
8
|
+
|
|
9
|
+
// ../packager/packager-tool-case/src/case-tool.ts
|
|
10
|
+
import {
|
|
11
|
+
NugetConstants,
|
|
12
|
+
NugetPackager,
|
|
13
|
+
Path,
|
|
14
|
+
ProjectTool,
|
|
15
|
+
ProjectTypes,
|
|
16
|
+
TemporaryStorageService,
|
|
17
|
+
ToolErrorCodes,
|
|
18
|
+
ToolResult
|
|
19
|
+
} from "@uipath/solutionpackager-tool-core";
|
|
20
|
+
var CaseConstants = {
|
|
21
|
+
EntryPointsFileName: "entry-points.json",
|
|
22
|
+
BindingsV2FileName: "bindings_v2.json"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
class CaseTool extends ProjectTool {
|
|
26
|
+
_temporaryStorage;
|
|
27
|
+
constructor(fileSystem, logger) {
|
|
28
|
+
super(fileSystem, logger);
|
|
29
|
+
this._temporaryStorage = new TemporaryStorageService(fileSystem);
|
|
30
|
+
}
|
|
31
|
+
async restoreAsync(_options, _cancellationToken) {
|
|
32
|
+
this.logger.info("Restore operation is not required for Case Management projects");
|
|
33
|
+
return ToolResult.success();
|
|
34
|
+
}
|
|
35
|
+
async validateAsync(_options, _cancellationToken) {
|
|
36
|
+
this.logger.info("Validate operation is not required for Case Management projects");
|
|
37
|
+
return ToolResult.success();
|
|
38
|
+
}
|
|
39
|
+
async buildAsync(options, _cancellationToken) {
|
|
40
|
+
const tempFolder = await this._temporaryStorage.getTempFolderPath();
|
|
41
|
+
const localBuildFolder = Path.join(tempFolder, NugetConstants.OutputFolderName);
|
|
42
|
+
const contentFolder = Path.join(localBuildFolder, NugetConstants.ContentFolderName);
|
|
43
|
+
try {
|
|
44
|
+
this.logger.progress("Copying files...");
|
|
45
|
+
await this.copyFiles(options.projectPath, contentFolder);
|
|
46
|
+
this.logger.progress("Creating operate.json file...");
|
|
47
|
+
await this.createOperateFile(options, contentFolder);
|
|
48
|
+
this.logger.progress("Creating package-descriptor.json file...");
|
|
49
|
+
await this.createPackageDescriptor(localBuildFolder, contentFolder);
|
|
50
|
+
return new ToolResult(ToolErrorCodes.Success, "done", [
|
|
51
|
+
localBuildFolder
|
|
52
|
+
]);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const errorMessage = error instanceof Error ? error.toString() : String(error);
|
|
55
|
+
this.logger.error(errorMessage);
|
|
56
|
+
return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while building Case Management project files");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
async packAsync(options, cancellationToken) {
|
|
60
|
+
const buildResult = await this.buildAsync(options, cancellationToken);
|
|
61
|
+
if (!buildResult.isSuccess) {
|
|
62
|
+
return buildResult;
|
|
63
|
+
}
|
|
64
|
+
const localBuildFolder = buildResult.packages[0];
|
|
65
|
+
try {
|
|
66
|
+
this.logger.progress("Creating NuGet package...");
|
|
67
|
+
const nupkgFileName = `${options.package.id}.${options.package.version}.nupkg`;
|
|
68
|
+
const nupkgPath = Path.join(options.outputPath, nupkgFileName);
|
|
69
|
+
const packager = new NugetPackager(this.fileSystem);
|
|
70
|
+
const result = await packager.packAsync(localBuildFolder, options.package, nupkgPath);
|
|
71
|
+
this.logger.progress("Package created successfully");
|
|
72
|
+
return new ToolResult(ToolErrorCodes.Success, "done", [
|
|
73
|
+
result.outputPath
|
|
74
|
+
]);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
const errorMessage = error instanceof Error ? error.toString() : String(error);
|
|
77
|
+
this.logger.error(errorMessage);
|
|
78
|
+
return ToolResult.error(ToolErrorCodes.InternalError, "An error occurred while packing Case Management project");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async dispose() {
|
|
82
|
+
this.logger.info("Disposing Case Management Tool");
|
|
83
|
+
try {
|
|
84
|
+
await this._temporaryStorage.cleanup();
|
|
85
|
+
} catch {}
|
|
86
|
+
}
|
|
87
|
+
async copyFiles(sourcePath, contentFolder) {
|
|
88
|
+
await this.fileSystem.mkdir(contentFolder);
|
|
89
|
+
const files = await this.fileSystem.readdir(sourcePath);
|
|
90
|
+
for (const file of files) {
|
|
91
|
+
const sourceFile = Path.join(sourcePath, file);
|
|
92
|
+
const stat = await this.fileSystem.stat(sourceFile);
|
|
93
|
+
if (stat?.isFile()) {
|
|
94
|
+
const content = await this.fileSystem.readFile(sourceFile);
|
|
95
|
+
if (content) {
|
|
96
|
+
const destinationFile = Path.join(contentFolder, file);
|
|
97
|
+
await this.fileSystem.writeFile(destinationFile, content);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async createOperateFile(options, contentFolder) {
|
|
103
|
+
const operateJsonFilePath = Path.join(contentFolder, NugetConstants.OperateFileName);
|
|
104
|
+
const exists = await this.fileSystem.exists(operateJsonFilePath);
|
|
105
|
+
if (!exists) {
|
|
106
|
+
await this.createOperateJsonFile(contentFolder, options.projectStorageId ?? "", operateJsonFilePath);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async createOperateJsonFile(projectPath, projectId, filePath) {
|
|
110
|
+
const entryPointsFilePath = Path.join(projectPath, CaseConstants.EntryPointsFileName);
|
|
111
|
+
let mainPath = "";
|
|
112
|
+
const entryPointsExists = await this.fileSystem.exists(entryPointsFilePath);
|
|
113
|
+
if (entryPointsExists) {
|
|
114
|
+
const entryPointsContent = await this.fileSystem.readFile(entryPointsFilePath);
|
|
115
|
+
if (entryPointsContent) {
|
|
116
|
+
try {
|
|
117
|
+
const entryPointsText = new TextDecoder().decode(entryPointsContent);
|
|
118
|
+
const entryPoints = JSON.parse(entryPointsText);
|
|
119
|
+
mainPath = entryPoints.entryPoints?.[0]?.filePath ?? "";
|
|
120
|
+
} catch {}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const operateFileModel = {
|
|
124
|
+
$schema: "https://cloud.uipath.com/draft/2024-12/operate",
|
|
125
|
+
contentType: ProjectTypes.CaseManagement,
|
|
126
|
+
projectId,
|
|
127
|
+
main: mainPath,
|
|
128
|
+
targetFramework: "Portable",
|
|
129
|
+
runtimeOptions: {
|
|
130
|
+
isAttended: false,
|
|
131
|
+
requiresUserInteraction: false
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const operateJsonString = JSON.stringify(operateFileModel, null, 2);
|
|
135
|
+
await this.fileSystem.writeFile(filePath, operateJsonString);
|
|
136
|
+
}
|
|
137
|
+
async createPackageDescriptor(localBuildFolder, contentFolder) {
|
|
138
|
+
const descriptorFiles = {};
|
|
139
|
+
descriptorFiles[NugetConstants.OperateFileName] = Path.join(NugetConstants.ContentFolderName, NugetConstants.OperateFileName);
|
|
140
|
+
descriptorFiles[CaseConstants.EntryPointsFileName] = Path.join(NugetConstants.ContentFolderName, CaseConstants.EntryPointsFileName);
|
|
141
|
+
descriptorFiles[NugetConstants.BindingsFileId] = Path.join(NugetConstants.ContentFolderName, CaseConstants.BindingsV2FileName);
|
|
142
|
+
const contentFiles = await this.fileSystem.readdir(contentFolder);
|
|
143
|
+
for (const file of contentFiles) {
|
|
144
|
+
if (file.endsWith(".bpmn")) {
|
|
145
|
+
descriptorFiles[file] = Path.join(NugetConstants.ContentFolderName, file);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
const packageDescriptorPath = Path.join(localBuildFolder, NugetConstants.ContentFolderName, NugetConstants.PackageDescriptorFileName);
|
|
149
|
+
const packageDescriptorJson = JSON.stringify({
|
|
150
|
+
$schema: "https://cloud.uipath.com/draft/2024-12/package-descriptor",
|
|
151
|
+
files: descriptorFiles
|
|
152
|
+
}, null, 2);
|
|
153
|
+
await this.fileSystem.writeFile(packageDescriptorPath, packageDescriptorJson);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ../packager/packager-tool-case/src/case-tool-factory.ts
|
|
158
|
+
class CaseToolFactory {
|
|
159
|
+
supportedTypes = [
|
|
160
|
+
ProjectTypes2.CaseManagement
|
|
161
|
+
];
|
|
162
|
+
async createAsync(logger, fileSystem) {
|
|
163
|
+
return new CaseTool(fileSystem, logger);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// ../packager/packager-tool-case/src/index.ts
|
|
168
|
+
toolsFactoryRepository.registerProjectToolFactory(new CaseToolFactory);
|