@uipath/project-executor 1.200.0 → 1.201.0-preview.123

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/dist/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  // src/models/run-options.ts
2
2
  var RunTarget;
3
3
  ((RunTarget2) => {
4
- RunTarget2["Online"] = "Online";
5
4
  RunTarget2["Local"] = "Local";
6
5
  })(RunTarget ||= {});
7
6
  // src/models/run-status.ts
@@ -92,17 +91,23 @@ class RunResult {
92
91
  return Object.assign(new RunResult("Faulted" /* Faulted */, errorCode, message), init);
93
92
  }
94
93
  }
95
- // src/services/executor-logger.ts
96
- var noopExecutorLogger = {
97
- info: () => {},
98
- warn: () => {},
99
- error: () => {}
100
- };
94
+ // src/services/executor-tool-import.ts
95
+ async function importExecutorToolModule(specifier) {
96
+ try {
97
+ return { module: await import(specifier) };
98
+ } catch (error) {
99
+ return {
100
+ error: error instanceof Error ? error : new Error(String(error))
101
+ };
102
+ }
103
+ }
104
+
101
105
  // src/services/executor-tool-module.ts
102
106
  var EXECUTOR_FACTORY_EXPORT = "createExecutorFactory";
103
107
  function isExecutorFactoryModule(module) {
104
108
  return typeof module === "object" && module !== null && typeof module[EXECUTOR_FACTORY_EXPORT] === "function";
105
109
  }
110
+
106
111
  // src/services/executors-factory-repository.ts
107
112
  class ExecutorsFactoryRepository {
108
113
  factoryMap = new Map;
@@ -145,6 +150,46 @@ if (!_global[REGISTRY_KEY]) {
145
150
  _global[REGISTRY_KEY] = new ExecutorsFactoryRepository;
146
151
  }
147
152
  var executorsFactoryRepository = _global[REGISTRY_KEY];
153
+
154
+ // src/services/executor-factory-provider.ts
155
+ var PROVIDER_KEY = Symbol.for("@uipath/project-executor/executorFactoryProvider");
156
+ var _global2 = globalThis;
157
+ function setExecutorFactoryProvider(provider) {
158
+ _global2[PROVIDER_KEY] = provider;
159
+ }
160
+ function clearExecutorFactoryProvider() {
161
+ _global2[PROVIDER_KEY] = undefined;
162
+ }
163
+ function registerExecutorFactoryFromModule(module, source) {
164
+ if (!isExecutorFactoryModule(module)) {
165
+ throw new Error(`${source} does not export ${EXECUTOR_FACTORY_EXPORT}().`);
166
+ }
167
+ const factory = module.createExecutorFactory();
168
+ executorsFactoryRepository.registerProjectExecutorFactory(factory);
169
+ return factory;
170
+ }
171
+ async function ensureExecutorFactory(verb, packageName) {
172
+ const provider = _global2[PROVIDER_KEY];
173
+ if (provider) {
174
+ await provider(verb);
175
+ return;
176
+ }
177
+ if (!packageName) {
178
+ throw new Error(`Running this project type needs the executor factory for '${verb}', and no package provides it.`);
179
+ }
180
+ const specifier = `${packageName}/executor-tool`;
181
+ const { module, error } = await importExecutorToolModule(specifier);
182
+ if (error) {
183
+ throw new Error(`Running this project type needs '${packageName}'. Install it.`, { cause: error });
184
+ }
185
+ registerExecutorFactoryFromModule(module, specifier);
186
+ }
187
+ // src/services/executor-logger.ts
188
+ var noopExecutorLogger = {
189
+ info: () => {},
190
+ warn: () => {},
191
+ error: () => {}
192
+ };
148
193
  // src/services/project-executor.ts
149
194
  class ProjectExecutor {
150
195
  fileSystem;
@@ -233,11 +278,15 @@ function messageOf(error) {
233
278
  return error instanceof Error ? error.message : String(error);
234
279
  }
235
280
  export {
281
+ setExecutorFactoryProvider,
282
+ registerExecutorFactoryFromModule,
236
283
  noopExecutorLogger,
237
284
  mapRunStatus,
238
285
  isTerminalRunStatus,
239
286
  isExecutorFactoryModule,
240
287
  executorsFactoryRepository,
288
+ ensureExecutorFactory,
289
+ clearExecutorFactoryProvider,
241
290
  TERMINAL_RUN_STATUSES,
242
291
  RunTarget,
243
292
  RunStatus,
@@ -249,4 +298,4 @@ export {
249
298
  EXECUTOR_FACTORY_EXPORT
250
299
  };
251
300
 
252
- //# debugId=F5B1472AD9D0537464756E2164756E21
301
+ //# debugId=18288E109C30117964756E2164756E21
@@ -5,6 +5,8 @@ export type { RunStep } from "./models/run-result";
5
5
  export { RunErrorCode, RunResult } from "./models/run-result";
6
6
  export { isTerminalRunStatus, mapRunStatus, RunStatus, TERMINAL_RUN_STATUSES, } from "./models/run-status";
7
7
  export type { IProjectExecutorFactory } from "./services/executor-factory";
8
+ export type { ExecutorFactoryProvider } from "./services/executor-factory-provider";
9
+ export { clearExecutorFactoryProvider, ensureExecutorFactory, registerExecutorFactoryFromModule, setExecutorFactoryProvider, } from "./services/executor-factory-provider";
8
10
  export type { IExecutorLogger } from "./services/executor-logger";
9
11
  export { noopExecutorLogger } from "./services/executor-logger";
10
12
  export type { ExecutorFactoryModule } from "./services/executor-tool-module";
@@ -2,15 +2,21 @@ import type { ProjectType } from "./project-type";
2
2
  import type { RunStep } from "./run-result";
3
3
  import type { RunStatus } from "./run-status";
4
4
  /**
5
- * Where the run executes. Only `Online` is implemented today; the meeting
6
- * decision was online (serverless) first, with local/hybrid later, so the
7
- * enum exists to keep that choice explicit at the call site rather than
8
- * implied.
5
+ * Where the run executes.
6
+ *
7
+ * Legacy, and on its way out. Where a project runs is not a caller's choice but
8
+ * a fact about the project type — RPA drives the Studio on this machine, a
9
+ * low-code agent starts a serverless job because that is the only runtime that
10
+ * executes `agent.json` — so no caller has anything to decide here and
11
+ * `uip solution run` offers no flag for it.
12
+ *
13
+ * The field survives because the published RPA executor validates it, so callers
14
+ * still pass `Local` and it still means something to exactly one implementation.
15
+ * A newer executor ignores it. It becomes optional once no shipped executor
16
+ * checks it.
9
17
  */
10
18
  export declare enum RunTarget {
11
- /** Serverless execution in the cloud. */
12
- Online = "Online",
13
- /** Local execution on the developer machine. Not implemented yet. */
19
+ /** Local execution on the developer machine. */
14
20
  Local = "Local"
15
21
  }
16
22
  /** Auth/tenant coordinates a project type needs to reach the backends. */
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Cross-module bridge for executor factory resolution.
3
+ *
4
+ * Mirrors `ensurePackagerFactory` in `@uipath/common`, and exists here rather
5
+ * than there for two reasons: `@uipath/common` has no dependencies by design,
6
+ * and registering an executor factory needs this package's registry and module
7
+ * guard. Everything about executors stays in the executor package.
8
+ */
9
+ import type { IProjectExecutorFactory } from "./executor-factory";
10
+ /**
11
+ * Makes the factory for a tool verb available, installing the tool if need be.
12
+ * The CLI registers one; a library caller has none.
13
+ */
14
+ export type ExecutorFactoryProvider = (verb: string) => Promise<void>;
15
+ export declare function setExecutorFactoryProvider(provider: ExecutorFactoryProvider): void;
16
+ /** Clear the provider. Tests only. */
17
+ export declare function clearExecutorFactoryProvider(): void;
18
+ /**
19
+ * Narrow a dynamically imported `executor-tool` module and register the factory
20
+ * it supplies into the shared registry.
21
+ *
22
+ * This is the host half of the contract's split — a tool supplies a factory, the
23
+ * host decides what is registered — so it lives here where every host can reach
24
+ * it instead of being reimplemented per caller.
25
+ *
26
+ * @param source Where the module came from, named in the error when the export
27
+ * is missing so the failure points at a file rather than a type.
28
+ */
29
+ export declare function registerExecutorFactoryFromModule(module: unknown, source: string): IProjectExecutorFactory;
30
+ /**
31
+ * Ensure the executor factory for a tool verb is registered.
32
+ *
33
+ * Prefers the registered provider (installed by the CLI, which can also install
34
+ * the tool package). With no provider — a library caller — falls back to
35
+ * importing the tool package's own `executor-tool` entry point and registering
36
+ * what it supplies.
37
+ *
38
+ * @param verb CLI tool verb that owns the factory (e.g. `"rpa"`).
39
+ * @param packageName npm package behind that verb. Drives the fallback import
40
+ * and is the one thing the error asks for. Omit when unknown; there is then no
41
+ * fallback and no package to name.
42
+ */
43
+ export declare function ensureExecutorFactory(verb: string, packageName?: string): Promise<void>;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Dynamic import of a tool's `executor-tool` entry point.
3
+ *
4
+ * Its own module so tests can stand in for it, for the same reason
5
+ * `packager-tool-import.ts` is separate in `@uipath/common`: the real entry
6
+ * points are multi-megabyte tool bundles, and loading one takes seconds and
7
+ * blocks the event loop while it evaluates.
8
+ *
9
+ * Unlike the packager equivalent this is *not* a side-effect import. An
10
+ * `executor-tool` module registers nothing; it exports a factory supplier, so
11
+ * the caller gets the module back and decides what to register.
12
+ */
13
+ /**
14
+ * Import `specifier` and hand back the module. Returns the failure instead of
15
+ * throwing so the caller can decide what to say.
16
+ */
17
+ export declare function importExecutorToolModule(specifier: string): Promise<{
18
+ module?: unknown;
19
+ error?: Error;
20
+ }>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/project-executor",
3
3
  "license": "MIT",
4
- "version": "1.200.0",
4
+ "version": "1.201.0-preview.123",
5
5
  "description": "Common run contract implemented by every UiPath project type - the shared ProjectExecutor interface behind 'uip solution run'.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "dist"
31
31
  ],
32
32
  "dependencies": {
33
- "@uipath/filesystem": "1.200.0"
33
+ "@uipath/filesystem": "1.201.0"
34
34
  },
35
- "gitHead": "173ad4b4930bd3e17a493b32e9f1c3c616ea1c10"
35
+ "gitHead": "0b5e086775b5974d9df45fc98f96f868bb3dda61"
36
36
  }