@uipath/api-workflow-tool 1.201.0-preview.115 → 1.201.0-preview.121

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.
@@ -5,7 +5,7 @@ import {
5
5
  TelemetryService,
6
6
  ToolLogger,
7
7
  setGlobalLogHandler
8
- } from "./packager-tool-6ph5rsqt.js";
8
+ } from "./packager-tool-2zhkjkmy.js";
9
9
  import {
10
10
  translate
11
11
  } from "./packager-tool-h1tyrbff.js";
@@ -0,0 +1,256 @@
1
+ import {
2
+ WorkflowRunService
3
+ } from "./packager-tool-bprnbg91.js";
4
+ import"./packager-tool-4pvh3k50.js";
5
+ import"./packager-tool-y7hv8v54.js";
6
+ import"./packager-tool-9qecd4wb.js";
7
+ import"./packager-tool-5arsyj36.js";
8
+ import"./packager-tool-wckvcay0.js";
9
+ // ../executor/project-executor/src/models/run-status.ts
10
+ var TERMINAL_RUN_STATUSES = [
11
+ "Succeeded" /* Succeeded */,
12
+ "Faulted" /* Faulted */,
13
+ "Cancelled" /* Cancelled */
14
+ ];
15
+ function isTerminalRunStatus(status) {
16
+ return TERMINAL_RUN_STATUSES.includes(status);
17
+ }
18
+
19
+ // ../executor/project-executor/src/models/run-result.ts
20
+ class RunResult {
21
+ status;
22
+ errorCode;
23
+ rawStatus;
24
+ message;
25
+ jobKey;
26
+ instanceId;
27
+ runId;
28
+ traceId;
29
+ steps;
30
+ output;
31
+ url;
32
+ details;
33
+ constructor(status, errorCode = "None" /* None */, message) {
34
+ this.status = status;
35
+ this.errorCode = errorCode;
36
+ this.message = message;
37
+ }
38
+ get isSuccess() {
39
+ return this.status === "Succeeded" /* Succeeded */ && this.errorCode === "None" /* None */;
40
+ }
41
+ get isTerminal() {
42
+ return isTerminalRunStatus(this.status);
43
+ }
44
+ static succeeded(init = {}) {
45
+ return Object.assign(new RunResult("Succeeded" /* Succeeded */, "None" /* None */), init);
46
+ }
47
+ static failed(errorCode, message, init = {}) {
48
+ return Object.assign(new RunResult("Faulted" /* Faulted */, errorCode, message), init);
49
+ }
50
+ }
51
+ // ../executor/project-executor/src/services/executors-factory-repository.ts
52
+ class ExecutorsFactoryRepository {
53
+ factoryMap = new Map;
54
+ onConflict;
55
+ constructor(onConflict) {
56
+ this.onConflict = onConflict ?? ((message) => console.warn(message));
57
+ }
58
+ registerProjectExecutorFactory(factory) {
59
+ for (const projectType of factory.supportedTypes) {
60
+ const existing = this.factoryMap.get(projectType);
61
+ if (existing) {
62
+ if (existing.constructor?.name !== factory.constructor?.name) {
63
+ this.onConflict(`Executor factory conflict for project type '${projectType}': ` + `'${existing.constructor?.name}' already registered, ` + `ignoring '${factory.constructor?.name}'.`);
64
+ }
65
+ continue;
66
+ }
67
+ this.factoryMap.set(projectType, factory);
68
+ }
69
+ }
70
+ canHandleProject(projectType) {
71
+ return this.factoryMap.has(projectType);
72
+ }
73
+ getProjectExecutorFactory(projectType) {
74
+ const factory = this.factoryMap.get(projectType);
75
+ if (!factory) {
76
+ throw new Error(`No executor is registered for project type '${projectType}'. ` + `Registered types: ${this.registeredTypes.join(", ") || "none"}.`);
77
+ }
78
+ return factory;
79
+ }
80
+ get registeredTypes() {
81
+ return [...this.factoryMap.keys()];
82
+ }
83
+ reset() {
84
+ this.factoryMap.clear();
85
+ }
86
+ }
87
+ var REGISTRY_KEY = Symbol.for("@uipath/project-executor/executorsFactoryRepository");
88
+ var _global = globalThis;
89
+ if (!_global[REGISTRY_KEY]) {
90
+ _global[REGISTRY_KEY] = new ExecutorsFactoryRepository;
91
+ }
92
+ var executorsFactoryRepository = _global[REGISTRY_KEY];
93
+
94
+ // ../executor/project-executor/src/services/executor-factory-provider.ts
95
+ var PROVIDER_KEY = Symbol.for("@uipath/project-executor/executorFactoryProvider");
96
+ // ../executor/project-executor/src/services/project-executor.ts
97
+ class ProjectExecutor {
98
+ fileSystem;
99
+ logger;
100
+ constructor(fileSystem, logger) {
101
+ this.fileSystem = fileSystem;
102
+ this.logger = logger;
103
+ }
104
+ runAsync(_options, _cancellationToken) {
105
+ return Promise.resolve(RunResult.failed("UnsupportedProjectType" /* UnsupportedProjectType */, `${this.constructor.name} does not support run.`));
106
+ }
107
+ async resolveDefaultEntryPoint(projectPath) {
108
+ const entryPointsFile = this.fileSystem.path.join(projectPath, ENTRY_POINTS_FILE_NAME);
109
+ try {
110
+ const raw = await this.fileSystem.readFile(entryPointsFile, "utf-8");
111
+ if (!raw) {
112
+ return;
113
+ }
114
+ const declared = JSON.parse(raw).entryPoints;
115
+ return this.firstDeclaredEntryPoint(declared);
116
+ } catch (error) {
117
+ this.logger.warn(`Could not read the default entry point from ${entryPointsFile}: ${error instanceof Error ? error.message : String(error)}`);
118
+ return;
119
+ }
120
+ }
121
+ asEntryPoint(value) {
122
+ return typeof value === "string" && value.length > 0 ? value : undefined;
123
+ }
124
+ firstDeclaredEntryPoint(entryPoints) {
125
+ if (!Array.isArray(entryPoints)) {
126
+ return;
127
+ }
128
+ for (const entry of entryPoints) {
129
+ const filePath = this.asEntryPoint(entry?.filePath);
130
+ if (filePath) {
131
+ return filePath;
132
+ }
133
+ }
134
+ return;
135
+ }
136
+ dispose() {
137
+ return Promise.resolve();
138
+ }
139
+ }
140
+ var ENTRY_POINTS_FILE_NAME = "entry-points.json";
141
+ // src/executor/api-workflow-project-executor.ts
142
+ var FALLBACK_ENTRY_POINT = "Workflow.json";
143
+ var PACKED_CONTENT_PREFIX = "content/";
144
+ var defaultRunnerFactory = (fileSystem) => new WorkflowRunService(fileSystem);
145
+
146
+ class ApiWorkflowProjectExecutor extends ProjectExecutor {
147
+ createRunner;
148
+ constructor(fileSystem, logger, createRunner = defaultRunnerFactory) {
149
+ super(fileSystem, logger);
150
+ this.createRunner = createRunner;
151
+ }
152
+ async runAsync(options, cancellationToken) {
153
+ const { project } = options;
154
+ if (!project.projectPath) {
155
+ return RunResult.failed("InvalidInput" /* InvalidInput */, "Running an API Workflow requires the project directory.");
156
+ }
157
+ if (cancellationToken?.aborted) {
158
+ return RunResult.failed("Cancelled" /* Cancelled */, "Run cancelled before it started.");
159
+ }
160
+ const entryPoint = options.entryPoint ?? await this.resolveDefaultEntryPoint(project.projectPath) ?? FALLBACK_ENTRY_POINT;
161
+ const workflowPath = this.fileSystem.path.join(project.projectPath, entryPoint);
162
+ this.logger.info(`Running API Workflow '${project.name}' locally: ${entryPoint}`);
163
+ options.callbacks?.onStatusChange?.("Running" /* Running */);
164
+ let outcome;
165
+ try {
166
+ outcome = await this.createRunner(this.fileSystem).run({
167
+ filePath: workflowPath,
168
+ input: options.inputArguments,
169
+ auth: Boolean(options.connection?.accessToken),
170
+ connection: options.connection
171
+ });
172
+ } catch (error) {
173
+ return RunResult.failed("Unknown" /* Unknown */, `Could not run API Workflow '${project.name}': ${messageOf(error)}`, { details: { entryPoint } });
174
+ }
175
+ if (cancellationToken?.aborted) {
176
+ return RunResult.failed("Cancelled" /* Cancelled */, "Run cancelled.");
177
+ }
178
+ return toRunResult(outcome, entryPoint);
179
+ }
180
+ async resolveDefaultEntryPoint(projectPath) {
181
+ const declared = await this.mainFileFromProject(projectPath);
182
+ if (declared) {
183
+ return declared;
184
+ }
185
+ const packed = await super.resolveDefaultEntryPoint(projectPath);
186
+ return packed?.startsWith(PACKED_CONTENT_PREFIX) ? packed.slice(PACKED_CONTENT_PREFIX.length) : packed;
187
+ }
188
+ async mainFileFromProject(projectPath) {
189
+ const projectFile = this.fileSystem.path.join(projectPath, "project.uiproj");
190
+ try {
191
+ const raw = await this.fileSystem.readFile(projectFile, "utf-8");
192
+ if (!raw) {
193
+ return;
194
+ }
195
+ const mainFile = JSON.parse(raw).MainFile;
196
+ return typeof mainFile === "string" && mainFile.length > 0 ? mainFile : undefined;
197
+ } catch (error) {
198
+ this.logger.warn(`Could not read the entry point from ${projectFile}: ${messageOf(error)}`);
199
+ return;
200
+ }
201
+ }
202
+ }
203
+ function toRunResult(outcome, entryPoint) {
204
+ const details = {
205
+ entryPoint,
206
+ workflowPath: outcome.workflowPath
207
+ };
208
+ if (outcome.success) {
209
+ const result2 = RunResult.succeeded({
210
+ output: asOutputArguments(outcome.data),
211
+ details: hasData(outcome.data) ? { ...details, data: outcome.data } : details
212
+ });
213
+ result2.rawStatus = outcome.status;
214
+ return result2;
215
+ }
216
+ const result = RunResult.failed(errorCodeFor(outcome.failedStage), outcome.errorMessage ?? "The workflow run did not succeed.", { details });
217
+ result.rawStatus = outcome.status;
218
+ return result;
219
+ }
220
+ function errorCodeFor(stage) {
221
+ switch (stage) {
222
+ case "load":
223
+ return "InvalidInput" /* InvalidInput */;
224
+ case "auth":
225
+ return "Unauthorized" /* Unauthorized */;
226
+ default:
227
+ return "ExecutionFailed" /* ExecutionFailed */;
228
+ }
229
+ }
230
+ function asOutputArguments(data) {
231
+ return data !== null && typeof data === "object" && !Array.isArray(data) ? data : undefined;
232
+ }
233
+ function hasData(data) {
234
+ return data !== undefined && data !== null;
235
+ }
236
+ function messageOf(error) {
237
+ return error instanceof Error ? error.message : String(error);
238
+ }
239
+
240
+ // src/executor/api-workflow-executor-factory.ts
241
+ var API_WORKFLOW_PROJECT_TYPES = ["Api"];
242
+
243
+ class ApiWorkflowExecutorFactory {
244
+ supportedTypes = API_WORKFLOW_PROJECT_TYPES;
245
+ createAsync(logger, fileSystem) {
246
+ return Promise.resolve(new ApiWorkflowProjectExecutor(fileSystem, logger));
247
+ }
248
+ }
249
+
250
+ // src/executor-tool.ts
251
+ var createExecutorFactory = () => new ApiWorkflowExecutorFactory;
252
+ export {
253
+ createExecutorFactory
254
+ };
255
+
256
+ //# debugId=E512E96D87D7F48D64756E2164756E21
@@ -18,7 +18,7 @@ import {
18
18
  resolveProducedNupkgsAsync,
19
19
  setGlobalLogHandler,
20
20
  signNupkgsAsync
21
- } from "./packager-tool-6ph5rsqt.js";
21
+ } from "./packager-tool-2zhkjkmy.js";
22
22
  import {
23
23
  ToolErrorCodes,
24
24
  ToolResult,
@@ -287,7 +287,7 @@ function addSdkUserAgentHeader(headers, userAgent) {
287
287
  var package_default = {
288
288
  name: "@uipath/project-packager",
289
289
  license: "MIT",
290
- version: "1.201.0-preview.115",
290
+ version: "1.201.0-preview.121",
291
291
  description: "UiPath Project Packager - core library for packing individual UiPath projects",
292
292
  type: "module",
293
293
  main: "./dist/index.js",
@@ -719,4 +719,4 @@ export {
719
719
  BrowserContextStorage
720
720
  };
721
721
 
722
- //# debugId=7B28B6A84040C8FE64756E2164756E21
722
+ //# debugId=1FC1AE2280E19D9064756E2164756E21