@powerlines/engine 0.47.4 → 0.49.1
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/api/build.cjs +66 -0
- package/dist/api/build.d.cts +14 -0
- package/dist/api/build.d.cts.map +1 -0
- package/dist/api/build.d.mts +14 -0
- package/dist/api/build.d.mts.map +1 -0
- package/dist/api/build.mjs +64 -0
- package/dist/api/build.mjs.map +1 -0
- package/dist/api/clean.cjs +28 -0
- package/dist/api/clean.d.cts +14 -0
- package/dist/api/clean.d.cts.map +1 -0
- package/dist/api/clean.d.mts +14 -0
- package/dist/api/clean.d.mts.map +1 -0
- package/dist/api/clean.mjs +28 -0
- package/dist/api/clean.mjs.map +1 -0
- package/dist/api/create.cjs +59 -0
- package/dist/api/create.d.cts +14 -0
- package/dist/api/create.d.cts.map +1 -0
- package/dist/api/create.d.mts +14 -0
- package/dist/api/create.d.mts.map +1 -0
- package/dist/api/create.mjs +57 -0
- package/dist/api/create.mjs.map +1 -0
- package/dist/api/deploy.cjs +24 -0
- package/dist/api/deploy.d.cts +17 -0
- package/dist/api/deploy.d.cts.map +1 -0
- package/dist/api/deploy.d.mts +17 -0
- package/dist/api/deploy.d.mts.map +1 -0
- package/dist/api/deploy.mjs +24 -0
- package/dist/api/deploy.mjs.map +1 -0
- package/dist/api/docs.cjs +24 -0
- package/dist/api/docs.d.cts +17 -0
- package/dist/api/docs.d.cts.map +1 -0
- package/dist/api/docs.d.mts +17 -0
- package/dist/api/docs.d.mts.map +1 -0
- package/dist/api/docs.mjs +24 -0
- package/dist/api/docs.mjs.map +1 -0
- package/dist/api/lint.cjs +27 -0
- package/dist/api/lint.d.cts +17 -0
- package/dist/api/lint.d.cts.map +1 -0
- package/dist/api/lint.d.mts +17 -0
- package/dist/api/lint.d.mts.map +1 -0
- package/dist/api/lint.mjs +27 -0
- package/dist/api/lint.mjs.map +1 -0
- package/dist/api/prepare.cjs +68 -0
- package/dist/api/prepare.d.cts +14 -0
- package/dist/api/prepare.d.cts.map +1 -0
- package/dist/api/prepare.d.mts +14 -0
- package/dist/api/prepare.d.mts.map +1 -0
- package/dist/api/prepare.mjs +68 -0
- package/dist/api/prepare.mjs.map +1 -0
- package/dist/api/test.cjs +27 -0
- package/dist/api/test.d.cts +17 -0
- package/dist/api/test.d.cts.map +1 -0
- package/dist/api/test.d.mts +17 -0
- package/dist/api/test.d.mts.map +1 -0
- package/dist/api/test.mjs +27 -0
- package/dist/api/test.mjs.map +1 -0
- package/dist/api/types.cjs +70 -0
- package/dist/api/types.d.cts +17 -0
- package/dist/api/types.d.cts.map +1 -0
- package/dist/api/types.d.mts +17 -0
- package/dist/api/types.d.mts.map +1 -0
- package/dist/api/types.mjs +70 -0
- package/dist/api/types.mjs.map +1 -0
- package/dist/api-BgyEi2hF.d.mts +138 -0
- package/dist/api-BgyEi2hF.d.mts.map +1 -0
- package/dist/api-DcHfCjQK.d.cts +138 -0
- package/dist/api-DcHfCjQK.d.cts.map +1 -0
- package/dist/api.cjs +39 -1268
- package/dist/api.d.cts +11 -300
- package/dist/api.d.cts.map +1 -1
- package/dist/api.d.mts +11 -300
- package/dist/api.d.mts.map +1 -1
- package/dist/api.mjs +31 -1264
- package/dist/api.mjs.map +1 -1
- package/dist/config-ByLyzMI0.d.mts +204 -0
- package/dist/config-ByLyzMI0.d.mts.map +1 -0
- package/dist/config-DKEmqMrh.d.cts +204 -0
- package/dist/config-DKEmqMrh.d.cts.map +1 -0
- package/dist/context/engine-context.cjs +177 -0
- package/dist/context/engine-context.d.cts +2 -0
- package/dist/context/engine-context.d.mts +2 -0
- package/dist/context/engine-context.mjs +175 -0
- package/dist/context/engine-context.mjs.map +1 -0
- package/dist/context/index.cjs +2 -9
- package/dist/context/index.d.cts +2 -150
- package/dist/context/index.d.mts +2 -150
- package/dist/context/index.mjs +2 -4
- package/dist/context-D0_a0kRO.d.cts +149 -0
- package/dist/context-D0_a0kRO.d.cts.map +1 -0
- package/dist/context-DcXV6_GL.d.mts +149 -0
- package/dist/context-DcXV6_GL.d.mts.map +1 -0
- package/dist/engine-Dz6BvkFY.cjs +590 -0
- package/dist/engine-context-B8K6Jtkk.d.cts +53 -0
- package/dist/engine-context-B8K6Jtkk.d.cts.map +1 -0
- package/dist/engine-context-DKlA5Pgu.d.mts +53 -0
- package/dist/engine-context-DKlA5Pgu.d.mts.map +1 -0
- package/dist/engine-q6YKXXcB.mjs +571 -0
- package/dist/engine-q6YKXXcB.mjs.map +1 -0
- package/dist/engine.cjs +6 -0
- package/dist/engine.d.cts +143 -0
- package/dist/engine.d.cts.map +1 -0
- package/dist/engine.d.mts +143 -0
- package/dist/engine.d.mts.map +1 -0
- package/dist/engine.mjs +3 -0
- package/dist/helpers/create-execution-host.cjs +57 -0
- package/dist/helpers/create-execution-host.d.cts +20 -0
- package/dist/helpers/create-execution-host.d.cts.map +1 -0
- package/dist/helpers/create-execution-host.d.mts +20 -0
- package/dist/helpers/create-execution-host.d.mts.map +1 -0
- package/dist/helpers/create-execution-host.mjs +57 -0
- package/dist/helpers/create-execution-host.mjs.map +1 -0
- package/dist/helpers/finalize.cjs +26 -0
- package/dist/helpers/finalize.d.cts +12 -0
- package/dist/helpers/finalize.d.cts.map +1 -0
- package/dist/helpers/finalize.d.mts +12 -0
- package/dist/helpers/finalize.d.mts.map +1 -0
- package/dist/helpers/finalize.mjs +26 -0
- package/dist/helpers/finalize.mjs.map +1 -0
- package/dist/helpers/index.cjs +12 -0
- package/dist/helpers/index.d.cts +5 -0
- package/dist/helpers/index.d.mts +5 -0
- package/dist/helpers/index.mjs +6 -0
- package/dist/helpers/rpc.cjs +139 -0
- package/dist/helpers/rpc.d.cts +7 -0
- package/dist/helpers/rpc.d.cts.map +1 -0
- package/dist/helpers/rpc.d.mts +7 -0
- package/dist/helpers/rpc.d.mts.map +1 -0
- package/dist/helpers/rpc.mjs +139 -0
- package/dist/helpers/rpc.mjs.map +1 -0
- package/dist/helpers/stream.cjs +119 -0
- package/dist/helpers/stream.d.cts +45 -0
- package/dist/helpers/stream.d.cts.map +1 -0
- package/dist/helpers/stream.d.mts +45 -0
- package/dist/helpers/stream.d.mts.map +1 -0
- package/dist/helpers/stream.mjs +117 -0
- package/dist/helpers/stream.mjs.map +1 -0
- package/dist/index-BVVgDSdq.d.cts +1 -0
- package/dist/index-BVVgDSdq.d.mts +1 -0
- package/dist/index.cjs +8 -748
- package/dist/index.d.cts +6 -140
- package/dist/index.d.mts +6 -140
- package/dist/index.mjs +4 -747
- package/package.json +102 -132
- package/dist/_internal/worker.cjs +0 -5192
- package/dist/_internal/worker.d.cts +0 -46
- package/dist/_internal/worker.d.cts.map +0 -1
- package/dist/_internal/worker.d.mts +0 -46
- package/dist/_internal/worker.d.mts.map +0 -1
- package/dist/_internal/worker.mjs +0 -5153
- package/dist/_internal/worker.mjs.map +0 -1
- package/dist/base-context-DLemGRbd.cjs +0 -322
- package/dist/base-context-DUha4Lz-.mjs +0 -315
- package/dist/base-context-DUha4Lz-.mjs.map +0 -1
- package/dist/context/index.d.cts.map +0 -1
- package/dist/context/index.d.mts.map +0 -1
- package/dist/engine-context-BfFiKN53.mjs +0 -86
- package/dist/engine-context-BfFiKN53.mjs.map +0 -1
- package/dist/engine-context-D0y88i_J.cjs +0 -91
- package/dist/execution-context-CE5H90Um.mjs +0 -2845
- package/dist/execution-context-CE5H90Um.mjs.map +0 -1
- package/dist/execution-context-CnyaM3Ul.cjs +0 -2889
- package/dist/execution-context-NyDjVZ6T.d.cts +0 -647
- package/dist/execution-context-NyDjVZ6T.d.cts.map +0 -1
- package/dist/execution-context-YrjFeD9k.d.mts +0 -647
- package/dist/execution-context-YrjFeD9k.d.mts.map +0 -1
- package/dist/fs-CeEdzPKE.cjs +0 -262
- package/dist/fs-Dcle8lUp.mjs +0 -226
- package/dist/fs-Dcle8lUp.mjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/rpc/client.cjs +0 -74
- package/dist/rpc/client.d.cts +0 -31
- package/dist/rpc/client.d.cts.map +0 -1
- package/dist/rpc/client.d.mts +0 -31
- package/dist/rpc/client.d.mts.map +0 -1
- package/dist/rpc/client.mjs +0 -71
- package/dist/rpc/client.mjs.map +0 -1
- package/dist/rpc/serialization.cjs +0 -82
- package/dist/rpc/serialization.d.cts +0 -46
- package/dist/rpc/serialization.d.cts.map +0 -1
- package/dist/rpc/serialization.d.mts +0 -46
- package/dist/rpc/serialization.d.mts.map +0 -1
- package/dist/rpc/serialization.mjs +0 -76
- package/dist/rpc/serialization.mjs.map +0 -1
- package/dist/rpc/server.cjs +0 -69
- package/dist/rpc/server.d.cts +0 -29
- package/dist/rpc/server.d.cts.map +0 -1
- package/dist/rpc/server.d.mts +0 -29
- package/dist/rpc/server.d.mts.map +0 -1
- package/dist/rpc/server.mjs +0 -66
- package/dist/rpc/server.mjs.map +0 -1
- package/dist/rpc/types.cjs +0 -0
- package/dist/rpc/types.d.cts +0 -70
- package/dist/rpc/types.d.cts.map +0 -1
- package/dist/rpc/types.d.mts +0 -70
- package/dist/rpc/types.d.mts.map +0 -1
- package/dist/rpc/types.mjs +0 -1
- package/dist/schemas.cjs +0 -9
- package/dist/schemas.d.cts +0 -127
- package/dist/schemas.d.cts.map +0 -1
- package/dist/schemas.d.mts +0 -127
- package/dist/schemas.d.mts.map +0 -1
- package/dist/schemas.mjs +0 -3
- package/dist/storage/base.cjs +0 -216
- package/dist/storage/base.d.cts +0 -199
- package/dist/storage/base.d.cts.map +0 -1
- package/dist/storage/base.d.mts +0 -199
- package/dist/storage/base.d.mts.map +0 -1
- package/dist/storage/base.mjs +0 -215
- package/dist/storage/base.mjs.map +0 -1
- package/dist/storage/file-system.cjs +0 -180
- package/dist/storage/file-system.d.cts +0 -127
- package/dist/storage/file-system.d.cts.map +0 -1
- package/dist/storage/file-system.d.mts +0 -127
- package/dist/storage/file-system.d.mts.map +0 -1
- package/dist/storage/file-system.mjs +0 -179
- package/dist/storage/file-system.mjs.map +0 -1
- package/dist/storage/helpers.cjs +0 -37
- package/dist/storage/helpers.d.cts +0 -25
- package/dist/storage/helpers.d.cts.map +0 -1
- package/dist/storage/helpers.d.mts +0 -25
- package/dist/storage/helpers.d.mts.map +0 -1
- package/dist/storage/helpers.mjs +0 -34
- package/dist/storage/helpers.mjs.map +0 -1
- package/dist/storage/index.cjs +0 -12
- package/dist/storage/index.d.cts +0 -5
- package/dist/storage/index.d.mts +0 -5
- package/dist/storage/index.mjs +0 -6
- package/dist/storage/virtual.cjs +0 -98
- package/dist/storage/virtual.d.cts +0 -80
- package/dist/storage/virtual.d.cts.map +0 -1
- package/dist/storage/virtual.d.mts +0 -80
- package/dist/storage/virtual.d.mts.map +0 -1
- package/dist/storage/virtual.mjs +0 -97
- package/dist/storage/virtual.mjs.map +0 -1
- package/dist/ts-morph-BbM83PT9.cjs +0 -114
- package/dist/ts-morph-C6YBNc46.mjs +0 -102
- package/dist/ts-morph-C6YBNc46.mjs.map +0 -1
- package/dist/tsconfig-DeKMGasE.cjs +0 -198
- package/dist/tsconfig-HzJsMUrr.mjs +0 -155
- package/dist/tsconfig-HzJsMUrr.mjs.map +0 -1
- package/dist/typescript/index.cjs +0 -13
- package/dist/typescript/index.d.cts +0 -106
- package/dist/typescript/index.d.cts.map +0 -1
- package/dist/typescript/index.d.mts +0 -106
- package/dist/typescript/index.d.mts.map +0 -1
- package/dist/typescript/index.mjs +0 -4
- /package/dist/{chunk-C0xms8kb.cjs → chunk-C_NdSu1c.cjs} +0 -0
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-C_NdSu1c.cjs');
|
|
2
|
+
const require_helpers_stream = require('./helpers/stream.cjs');
|
|
3
|
+
const require_context_engine_context = require('./context/engine-context.cjs');
|
|
4
|
+
let _stryke_path_append = require("@stryke/path/append");
|
|
5
|
+
let _stryke_convert_to_array = require("@stryke/convert/to-array");
|
|
6
|
+
let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-object");
|
|
7
|
+
let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
|
|
8
|
+
let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
9
|
+
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
10
|
+
let node_events = require("node:events");
|
|
11
|
+
let node_stream = require("node:stream");
|
|
12
|
+
let devframe_node = require("devframe/node");
|
|
13
|
+
let get_port_please = require("get-port-please");
|
|
14
|
+
let h3 = require("h3");
|
|
15
|
+
let sirv = require("sirv");
|
|
16
|
+
sirv = require_chunk.__toESM(sirv, 1);
|
|
17
|
+
let _powerlines_core_lib_config = require("@powerlines/core/lib/config");
|
|
18
|
+
let _stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
19
|
+
let _stryke_type_checks_is_set_string = require("@stryke/type-checks/is-set-string");
|
|
20
|
+
let _stryke_type_checks_is_string = require("@stryke/type-checks/is-string");
|
|
21
|
+
let date_fns_formatDuration = require("date-fns/formatDuration");
|
|
22
|
+
let jiti = require("jiti");
|
|
23
|
+
let node_util = require("node:util");
|
|
24
|
+
let node_worker_threads = require("node:worker_threads");
|
|
25
|
+
let piscina = require("piscina");
|
|
26
|
+
piscina = require_chunk.__toESM(piscina, 1);
|
|
27
|
+
|
|
28
|
+
//#region src/_internal/execution-host-worker.ts
|
|
29
|
+
const RESTARTED = Symbol("powerlines-worker:restarted");
|
|
30
|
+
/**
|
|
31
|
+
* Formats the debug address into a string.
|
|
32
|
+
*/
|
|
33
|
+
const formatDebugAddress = ({ host, port }) => {
|
|
34
|
+
return host ? `${host}:${port}` : `${port}`;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Get's the debug address from the `NODE_OPTIONS` environment variable. If the
|
|
38
|
+
* address is not found, it returns the default host (`undefined`) and port
|
|
39
|
+
* (`9229`).
|
|
40
|
+
*
|
|
41
|
+
* @returns An object with the host and port of the debug address.
|
|
42
|
+
*/
|
|
43
|
+
const getParsedDebugAddress = (address) => {
|
|
44
|
+
if (!address || !(0, _stryke_type_checks_is_string.isString)(address)) return {
|
|
45
|
+
host: void 0,
|
|
46
|
+
port: 9229
|
|
47
|
+
};
|
|
48
|
+
if (address.includes(":")) {
|
|
49
|
+
const [host, port] = address.split(":");
|
|
50
|
+
if (!host || !port) throw new Error(`Invalid debug address: ${address}`);
|
|
51
|
+
return {
|
|
52
|
+
host,
|
|
53
|
+
port: Number.parseInt(port, 10)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
host: void 0,
|
|
58
|
+
port: Number.parseInt(address, 10)
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Get the debug type from the `NODE_OPTIONS` environment variable.
|
|
63
|
+
*/
|
|
64
|
+
function getNodeDebugType(nodeOptions) {
|
|
65
|
+
if (nodeOptions.inspect) return "inspect";
|
|
66
|
+
if (nodeOptions["inspect-brk"] || nodeOptions.inspect_brk) return "inspect-brk";
|
|
67
|
+
}
|
|
68
|
+
var ExecutionHostWorker = class ExecutionHostWorker {
|
|
69
|
+
executionHostPath;
|
|
70
|
+
exposedMethods;
|
|
71
|
+
options;
|
|
72
|
+
#worker;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a new instance of the ExecutionHostWorker class, which manages a worker process for executing tasks related to the Powerlines Engine. The worker is initialized with the specified options and can be used to run tasks in an isolated environment, with support for automatic restarts and activity monitoring.
|
|
75
|
+
*
|
|
76
|
+
* @param apiPath - The path to the Execution Host file.
|
|
77
|
+
* @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.
|
|
78
|
+
* @returns A promise that resolves to an instance of the ExecutionHostWorker class.
|
|
79
|
+
*/
|
|
80
|
+
static async from(apiPath, options) {
|
|
81
|
+
const mode = await (0, _powerlines_core_lib_config.getDefaultMode)(options.context.cwd);
|
|
82
|
+
const resolvedPath = await (0, _stryke_fs_resolve.resolve)(apiPath, { paths: [options.context.cwd, options.root ? (0, _stryke_path_append.appendPath)(options.root, options.context.cwd) : void 0].filter(Boolean) });
|
|
83
|
+
if (!resolvedPath) throw new Error(`Could not resolve the provided Execution Host path: \`${apiPath}\`.`);
|
|
84
|
+
let exposedMethods = (0, _stryke_convert_to_array.toArray)(options.apiMethods ?? []);
|
|
85
|
+
if (exposedMethods.length === 0) {
|
|
86
|
+
const jiti$1 = (0, jiti.createJiti)(require("url").pathToFileURL(__filename).href, {
|
|
87
|
+
cache: false,
|
|
88
|
+
interopDefault: true,
|
|
89
|
+
tsconfigPaths: true
|
|
90
|
+
});
|
|
91
|
+
const mod = await jiti$1.import(jiti$1.esmResolve(resolvedPath));
|
|
92
|
+
if ((0, _stryke_type_checks_is_function.isFunction)(mod)) exposedMethods.push(...exposedMethods, "default");
|
|
93
|
+
else if ((0, _stryke_type_checks_is_set_object.isSetObject)(mod)) exposedMethods = Object.keys(mod).filter((name) => (0, _stryke_type_checks_is_function.isFunction)(mod[name]));
|
|
94
|
+
}
|
|
95
|
+
return new ExecutionHostWorker(resolvedPath, exposedMethods, {
|
|
96
|
+
mode,
|
|
97
|
+
...options
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Create a new worker instance.
|
|
102
|
+
*
|
|
103
|
+
* @param executionHostPath - The path to the worker file.
|
|
104
|
+
* @param exposedMethods - An array of method names that the worker exposes.
|
|
105
|
+
* @param options - The options for the worker, including exposed methods, timeout, and hooks for activity and restart.
|
|
106
|
+
*/
|
|
107
|
+
constructor(executionHostPath, exposedMethods, options) {
|
|
108
|
+
this.executionHostPath = executionHostPath;
|
|
109
|
+
this.exposedMethods = exposedMethods;
|
|
110
|
+
this.options = options;
|
|
111
|
+
const { timeout = 9e5, isolatedMemory = false, mode = "production", context } = this.options;
|
|
112
|
+
const logger = context.extendLogger({ category: "communication" });
|
|
113
|
+
let restartPromise;
|
|
114
|
+
let resolveRestartPromise;
|
|
115
|
+
let activeTasks = 0;
|
|
116
|
+
this.#worker = void 0;
|
|
117
|
+
process.on("exit", () => {
|
|
118
|
+
this.finalize();
|
|
119
|
+
});
|
|
120
|
+
let nodeOptions = {};
|
|
121
|
+
const args = [...process.execArgv];
|
|
122
|
+
if (process.env.NODE_OPTIONS) {
|
|
123
|
+
let isInString = false;
|
|
124
|
+
let willStartNewArg = true;
|
|
125
|
+
const stringifiedNodeOptions = process.env.NODE_OPTIONS.split(" ").filter((part) => (part.startsWith("\"") && part.endsWith("\"") || part.startsWith("'") && part.endsWith("'")) && part.replace(/^['"]|['"]$/g, "").split(" ").filter(_stryke_type_checks_is_set_string.isSetString).length > 0 && part.replace(/^['"]|['"]$/g, "").split(" ").filter(_stryke_type_checks_is_set_string.isSetString).every((p) => p.startsWith("--")));
|
|
126
|
+
args.push(...stringifiedNodeOptions.map((part) => part.replace(/^['"]|['"]$/g, "")));
|
|
127
|
+
const inputNodeModules = stringifiedNodeOptions.reduce((acc, part) => {
|
|
128
|
+
return acc.replace(part, "").trim();
|
|
129
|
+
}, process.env.NODE_OPTIONS);
|
|
130
|
+
for (let i = 0; i < inputNodeModules.length; i++) {
|
|
131
|
+
let char = inputNodeModules[i];
|
|
132
|
+
if (char) {
|
|
133
|
+
if (char === "\\" && isInString) {
|
|
134
|
+
if (inputNodeModules.length === i + 1) throw new Error("Invalid escape character at the end.");
|
|
135
|
+
char = inputNodeModules[++i];
|
|
136
|
+
if (!char) continue;
|
|
137
|
+
} else if (char === " " && !isInString) {
|
|
138
|
+
willStartNewArg = true;
|
|
139
|
+
continue;
|
|
140
|
+
} else if (char === "\"") {
|
|
141
|
+
isInString = !isInString;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (willStartNewArg) {
|
|
145
|
+
args.push(char);
|
|
146
|
+
willStartNewArg = false;
|
|
147
|
+
} else args[args.length - 1] += char;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (isInString) throw new Error("Unterminated string");
|
|
151
|
+
}
|
|
152
|
+
if (args.length > 0) {
|
|
153
|
+
const { values, tokens } = (0, node_util.parseArgs)({
|
|
154
|
+
args,
|
|
155
|
+
strict: false,
|
|
156
|
+
tokens: true
|
|
157
|
+
});
|
|
158
|
+
nodeOptions = values;
|
|
159
|
+
let orphan = null;
|
|
160
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
161
|
+
const token = tokens[i];
|
|
162
|
+
if (!token) continue;
|
|
163
|
+
if (token.kind === "option-terminator") break;
|
|
164
|
+
if (token.kind === "option") {
|
|
165
|
+
orphan = !(0, _stryke_type_checks_is_set.isSet)(token.value) ? token : null;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (token.kind !== "positional") {
|
|
169
|
+
orphan = null;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (!orphan) continue;
|
|
173
|
+
if (orphan.name in nodeOptions && (0, _stryke_type_checks_is_string.isString)(nodeOptions[orphan.name])) nodeOptions[orphan.name] += ` ${token.value}`;
|
|
174
|
+
else nodeOptions[orphan.name] = token.value;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const originalOptions = { ...nodeOptions };
|
|
178
|
+
delete nodeOptions.inspect;
|
|
179
|
+
delete nodeOptions["inspect-brk"];
|
|
180
|
+
delete nodeOptions.inspect_brk;
|
|
181
|
+
if (mode === "development") {
|
|
182
|
+
const nodeDebugType = getNodeDebugType(originalOptions);
|
|
183
|
+
if (nodeDebugType) {
|
|
184
|
+
const debuggerAddress = getParsedDebugAddress(originalOptions[nodeDebugType]);
|
|
185
|
+
const address = {
|
|
186
|
+
host: debuggerAddress.host,
|
|
187
|
+
port: debuggerAddress.port === 0 ? 0 : debuggerAddress.port + 1 + 1
|
|
188
|
+
};
|
|
189
|
+
nodeOptions[nodeDebugType] = formatDebugAddress(address);
|
|
190
|
+
}
|
|
191
|
+
nodeOptions["enable-source-maps"] = true;
|
|
192
|
+
}
|
|
193
|
+
if (isolatedMemory) {
|
|
194
|
+
delete nodeOptions["max-old-space-size"];
|
|
195
|
+
delete nodeOptions.max_old_space_size;
|
|
196
|
+
}
|
|
197
|
+
const execArgv = [];
|
|
198
|
+
const nodeOptionsParts = [];
|
|
199
|
+
for (const [key, value] of Object.entries(nodeOptions)) {
|
|
200
|
+
let formatted = null;
|
|
201
|
+
if (value === true) formatted = `--${key}`;
|
|
202
|
+
else if (value) formatted = `--${key}=${value.includes(" ") && !value.startsWith("\"") ? JSON.stringify(value) : value}`;
|
|
203
|
+
if (formatted === null) continue;
|
|
204
|
+
if ([
|
|
205
|
+
"experimental-network-inspection",
|
|
206
|
+
"experimental-storage-inspection",
|
|
207
|
+
"experimental-worker-inspection",
|
|
208
|
+
"experimental-inspector-network-resource"
|
|
209
|
+
].includes(key)) execArgv.push(formatted);
|
|
210
|
+
else nodeOptionsParts.push(formatted);
|
|
211
|
+
}
|
|
212
|
+
const onHanging = () => {
|
|
213
|
+
if (!this.#worker) return;
|
|
214
|
+
const resolve = resolveRestartPromise;
|
|
215
|
+
createWorker();
|
|
216
|
+
logger.warn(`Sending SIGTERM signal to worker due to timeout${timeout ? ` of ${(0, date_fns_formatDuration.formatDuration)({ seconds: timeout / 1e3 })}` : ""}. Subsequent errors may be a result of the worker exiting.`);
|
|
217
|
+
this.finalize().then(() => {
|
|
218
|
+
resolve(RESTARTED);
|
|
219
|
+
});
|
|
220
|
+
};
|
|
221
|
+
let hangingTimer = false;
|
|
222
|
+
const onActivity = () => {
|
|
223
|
+
if (hangingTimer) clearTimeout(hangingTimer);
|
|
224
|
+
hangingTimer = activeTasks > 0 && setTimeout(onHanging, timeout);
|
|
225
|
+
};
|
|
226
|
+
const createWorker = () => {
|
|
227
|
+
const env = {
|
|
228
|
+
...process.env,
|
|
229
|
+
NODE_ENV: mode,
|
|
230
|
+
NODE_OPTIONS: nodeOptionsParts.join(" "),
|
|
231
|
+
POWERLINES_EXECUTION_HOST_WORKER: "true"
|
|
232
|
+
};
|
|
233
|
+
if (env.FORCE_COLOR === void 0) {
|
|
234
|
+
if (!env.NO_COLOR && !env.CI && env.TERM !== "dumb" && (process.stdout.isTTY || process.stderr?.isTTY)) env.FORCE_COLOR = "1";
|
|
235
|
+
}
|
|
236
|
+
this.#worker = new piscina.default({
|
|
237
|
+
filename: executionHostPath,
|
|
238
|
+
execArgv,
|
|
239
|
+
env
|
|
240
|
+
});
|
|
241
|
+
restartPromise = new Promise((resolve) => {
|
|
242
|
+
resolveRestartPromise = resolve;
|
|
243
|
+
});
|
|
244
|
+
this.#worker.on("exit", (code, signal) => {
|
|
245
|
+
logger.debug(`Worker process exited with code ${code} and signal ${signal}`);
|
|
246
|
+
if ((code || signal && signal !== "SIGINT") && this.#worker) {
|
|
247
|
+
const error = /* @__PURE__ */ new Error(`Execution Host Worker exited unexpectedly with code ${code} and signal ${signal}`);
|
|
248
|
+
logger.error(error);
|
|
249
|
+
this.finalize().then(() => {
|
|
250
|
+
throw error;
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
this.#worker.on("error", (error) => {
|
|
255
|
+
logger.error({
|
|
256
|
+
meta: { category: "communication" },
|
|
257
|
+
message: `Worker process emitted an error: ${error.message}`,
|
|
258
|
+
error
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
this.#worker.on("message", (data) => {
|
|
262
|
+
onActivity();
|
|
263
|
+
if (Array.isArray(data) && data.length > 1 && (0, _stryke_type_checks_is_number.isNumber)(data[0])) if (data[0] === 0) logger.trace(`Received message from worker: ${JSON.stringify(data.slice(1), null, 2)}`);
|
|
264
|
+
else logger.debug(`Received error message from worker: ${JSON.stringify(data.slice(1), null, 2)}`);
|
|
265
|
+
logger.trace(`Received message from worker: ${JSON.stringify(data, null, 2)}`);
|
|
266
|
+
});
|
|
267
|
+
};
|
|
268
|
+
createWorker();
|
|
269
|
+
for (const method of this.exposedMethods) {
|
|
270
|
+
if (method.startsWith("_")) continue;
|
|
271
|
+
const callWorker = async (options, inlineConfig) => {
|
|
272
|
+
if (!this.#worker) throw new Error("Execution Host Worker is not initialized");
|
|
273
|
+
const { port1, port2 } = new node_worker_threads.MessageChannel();
|
|
274
|
+
const promise = this.#worker.run({
|
|
275
|
+
options,
|
|
276
|
+
inlineConfig,
|
|
277
|
+
port: port2
|
|
278
|
+
}, {
|
|
279
|
+
name: method,
|
|
280
|
+
transferList: [port2]
|
|
281
|
+
});
|
|
282
|
+
let aborted = false;
|
|
283
|
+
const onActivityAbort = () => {
|
|
284
|
+
if (!aborted) aborted = true;
|
|
285
|
+
};
|
|
286
|
+
(0, node_stream.pipeline)(new require_helpers_stream.MessagePortDuplex(port1, { onActivityAbort }), process.stdout, (err) => {
|
|
287
|
+
if (err) {
|
|
288
|
+
logger.debug(`Received exception message from worker: ${JSON.stringify(err, null, 2)}`);
|
|
289
|
+
throw err;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
await promise;
|
|
293
|
+
};
|
|
294
|
+
this[method] = timeout ? async (options, inlineConfig) => {
|
|
295
|
+
activeTasks++;
|
|
296
|
+
try {
|
|
297
|
+
let attempts = 0;
|
|
298
|
+
for (;;) {
|
|
299
|
+
onActivity();
|
|
300
|
+
const result = await Promise.race([callWorker(options, inlineConfig), restartPromise]);
|
|
301
|
+
if (result !== RESTARTED) return result;
|
|
302
|
+
logger.warn(`Execution Host Worker was restarted while calling method "${method}" (attempt ${attempts++}). Retrying the call...`);
|
|
303
|
+
}
|
|
304
|
+
} finally {
|
|
305
|
+
activeTasks--;
|
|
306
|
+
onActivity();
|
|
307
|
+
}
|
|
308
|
+
} : callWorker.bind(this);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Closes the worker process, terminating it if it's still running. This method should be called when the worker is no longer needed, to free up system resources and ensure a clean shutdown. If the worker has already been terminated, this method will have no effect.
|
|
313
|
+
*/
|
|
314
|
+
async finalize() {
|
|
315
|
+
const worker = this.#worker;
|
|
316
|
+
if (!worker) return;
|
|
317
|
+
await worker.close({ force: true });
|
|
318
|
+
this.#worker = void 0;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
//#endregion
|
|
323
|
+
//#region src/engine.ts
|
|
324
|
+
/**
|
|
325
|
+
* The Powerlines process' orchestration and coordination API.
|
|
326
|
+
*
|
|
327
|
+
* @public
|
|
328
|
+
*/
|
|
329
|
+
var PowerlinesEngine = class {
|
|
330
|
+
/**
|
|
331
|
+
* The Powerlines context
|
|
332
|
+
*/
|
|
333
|
+
#context;
|
|
334
|
+
/**
|
|
335
|
+
* The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.
|
|
336
|
+
*/
|
|
337
|
+
#host;
|
|
338
|
+
/**
|
|
339
|
+
* The Powerlines context
|
|
340
|
+
*/
|
|
341
|
+
get context() {
|
|
342
|
+
return this.#context;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* The execution host, which provides methods to call the execution API functions from the engine context. This allows the engine to invoke commands and other API functions during the execution of Powerlines commands, enabling communication between the engine and the execution contexts.
|
|
346
|
+
*/
|
|
347
|
+
get host() {
|
|
348
|
+
return this.#host;
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Create a new Powerlines Engine instance
|
|
352
|
+
*
|
|
353
|
+
* @param context - The Powerlines context
|
|
354
|
+
* @param host - The API host for the execution workers
|
|
355
|
+
* @returns A new instance of the Powerlines Engine
|
|
356
|
+
*/
|
|
357
|
+
constructor(context, host) {
|
|
358
|
+
this.#context = context;
|
|
359
|
+
this.#host = host;
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Create a new Powerlines project
|
|
363
|
+
*
|
|
364
|
+
* @remarks
|
|
365
|
+
* This method will create a new Powerlines project in the current directory.
|
|
366
|
+
*
|
|
367
|
+
* @param inlineConfig - The inline configuration for the create command
|
|
368
|
+
* @returns A promise that resolves when the project has been created
|
|
369
|
+
*/
|
|
370
|
+
async create(inlineConfig) {
|
|
371
|
+
const timer = this.context.timer("Create");
|
|
372
|
+
this.context.info("🆕 Creating a new project");
|
|
373
|
+
await this.execute("create", inlineConfig);
|
|
374
|
+
this.context.debug("✔ Create command completed successfully");
|
|
375
|
+
timer();
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Generate the Powerlines typescript declaration file
|
|
379
|
+
*
|
|
380
|
+
* @remarks
|
|
381
|
+
* This method will only generate the typescript declaration file for the Powerlines project. It is generally recommended to run the full `prepare` command, which will run this method as part of its process.
|
|
382
|
+
*
|
|
383
|
+
* @param inlineConfig - The inline configuration for the types command
|
|
384
|
+
*/
|
|
385
|
+
async types(inlineConfig) {
|
|
386
|
+
const timer = this.context.timer("Types");
|
|
387
|
+
this.context.info("🏗️ Generating typescript declarations for the project");
|
|
388
|
+
await this.execute("types", inlineConfig);
|
|
389
|
+
this.context.debug("✔ Types generation has completed successfully");
|
|
390
|
+
timer();
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Prepare the Powerlines API
|
|
394
|
+
*
|
|
395
|
+
* @remarks
|
|
396
|
+
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
397
|
+
*
|
|
398
|
+
* @param inlineConfig - The inline configuration for the prepare command
|
|
399
|
+
*/
|
|
400
|
+
async prepare(inlineConfig) {
|
|
401
|
+
const timer = this.context.timer("Prepare");
|
|
402
|
+
this.context.info("🏗️ Preparing the project");
|
|
403
|
+
await this.execute("prepare", inlineConfig);
|
|
404
|
+
this.context.debug("✔ Preparation has completed successfully");
|
|
405
|
+
timer();
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Clean any previously prepared artifacts
|
|
409
|
+
*
|
|
410
|
+
* @remarks
|
|
411
|
+
* This method will remove the previous Powerlines artifacts from the project.
|
|
412
|
+
*
|
|
413
|
+
* @param inlineConfig - The inline configuration for the clean command
|
|
414
|
+
* @returns A promise that resolves when the clean command has completed
|
|
415
|
+
*/
|
|
416
|
+
async clean(inlineConfig) {
|
|
417
|
+
const timer = this.context.timer("Clean");
|
|
418
|
+
this.context.info("🧹 Cleaning the previous artifacts");
|
|
419
|
+
await this.execute("clean", inlineConfig);
|
|
420
|
+
this.context.debug("✔ Cleaning completed successfully");
|
|
421
|
+
timer();
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Lint the project
|
|
425
|
+
*
|
|
426
|
+
* @param inlineConfig - The inline configuration for the lint command
|
|
427
|
+
* @returns A promise that resolves when the lint command has completed
|
|
428
|
+
*/
|
|
429
|
+
async lint(inlineConfig) {
|
|
430
|
+
const timer = this.context.timer("Lint");
|
|
431
|
+
this.context.info("📝 Linting the project");
|
|
432
|
+
await this.execute("lint", inlineConfig);
|
|
433
|
+
this.context.debug("✔ Linting completed successfully");
|
|
434
|
+
timer();
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Test the project
|
|
438
|
+
*
|
|
439
|
+
* @remarks
|
|
440
|
+
* This method will run the tests for the Powerlines project.
|
|
441
|
+
*
|
|
442
|
+
* @param inlineConfig - The inline configuration for the test command
|
|
443
|
+
* @returns A promise that resolves when the test command has completed
|
|
444
|
+
*/
|
|
445
|
+
async test(inlineConfig) {
|
|
446
|
+
const timer = this.context.timer("Test");
|
|
447
|
+
this.context.info("🧪 Running tests for the project");
|
|
448
|
+
await this.execute("test", inlineConfig);
|
|
449
|
+
this.context.debug("✔ Testing completed successfully");
|
|
450
|
+
timer();
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* Build the project
|
|
454
|
+
*
|
|
455
|
+
* @remarks
|
|
456
|
+
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
457
|
+
*
|
|
458
|
+
* @param inlineConfig - The inline configuration for the build command
|
|
459
|
+
* @returns A promise that resolves when the build command has completed
|
|
460
|
+
*/
|
|
461
|
+
async build(inlineConfig) {
|
|
462
|
+
const timer = this.context.timer("Build");
|
|
463
|
+
this.context.info("📦 Building the project");
|
|
464
|
+
await this.execute("build", inlineConfig);
|
|
465
|
+
this.context.debug("✔ Build completed successfully");
|
|
466
|
+
timer();
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Prepare the documentation for the project
|
|
470
|
+
*
|
|
471
|
+
* @param inlineConfig - The inline configuration for the docs command
|
|
472
|
+
* @returns A promise that resolves when the documentation generation has completed
|
|
473
|
+
*/
|
|
474
|
+
async docs(inlineConfig) {
|
|
475
|
+
const timer = this.context.timer("Docs");
|
|
476
|
+
this.context.info("📓 Generating documentation for the project");
|
|
477
|
+
await this.execute("docs", inlineConfig);
|
|
478
|
+
this.context.debug("✔ Documentation generation completed successfully");
|
|
479
|
+
timer();
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Deploy the project source code
|
|
483
|
+
*
|
|
484
|
+
* @remarks
|
|
485
|
+
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
486
|
+
*
|
|
487
|
+
* @param inlineConfig - The inline configuration for the deploy command
|
|
488
|
+
* @returns A promise that resolves when the deploy command has completed
|
|
489
|
+
*/
|
|
490
|
+
async deploy(inlineConfig) {
|
|
491
|
+
const timer = this.context.timer("Deploy");
|
|
492
|
+
this.context.info("🚀 Deploying the project");
|
|
493
|
+
await this.execute("deploy", inlineConfig);
|
|
494
|
+
this.context.debug("✔ Deployment completed successfully");
|
|
495
|
+
timer();
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Finalization/cleanup processing for the Powerlines API
|
|
499
|
+
*
|
|
500
|
+
* @remarks
|
|
501
|
+
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
502
|
+
*
|
|
503
|
+
* @returns A promise that resolves when the finalization process has completed
|
|
504
|
+
*/
|
|
505
|
+
async finalize() {
|
|
506
|
+
const timer = this.context.timer("Finalize");
|
|
507
|
+
this.context.info("🏁 Finalization processes started");
|
|
508
|
+
await this.host.finalize();
|
|
509
|
+
this.context.debug("✔ Finalization completed successfully");
|
|
510
|
+
timer();
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
|
|
514
|
+
*/
|
|
515
|
+
async [Symbol.asyncDispose]() {
|
|
516
|
+
return this.finalize();
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
|
|
520
|
+
*
|
|
521
|
+
* @remarks
|
|
522
|
+
* This method will load the executions for the specified command and inline configuration, then execute each one while managing their lifecycle, including handling their completion and any errors that may occur during execution.
|
|
523
|
+
*
|
|
524
|
+
* @param method - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.
|
|
525
|
+
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
526
|
+
* @returns A promise that resolves when all executions for the specified command have completed
|
|
527
|
+
*/
|
|
528
|
+
async execute(method, inlineConfig) {
|
|
529
|
+
await Promise.all((await this.context.loadExecutions(method, inlineConfig)).map(async (execution) => {
|
|
530
|
+
try {
|
|
531
|
+
await this.host[method](execution.options, inlineConfig);
|
|
532
|
+
} catch (error) {
|
|
533
|
+
this.context.error(`Execution of method "${method}" failed for execution with invocation ID "${execution.invocationId}" and execution ID "${execution.options.executionId}": \n\n${error instanceof Error ? error.stack || error.message : String(error)}`);
|
|
534
|
+
throw error;
|
|
535
|
+
} finally {
|
|
536
|
+
this.context.completeExecution(execution.invocationId, execution.options.executionId);
|
|
537
|
+
}
|
|
538
|
+
}));
|
|
539
|
+
}
|
|
540
|
+
};
|
|
541
|
+
async function createContext(options) {
|
|
542
|
+
const port = options.port ?? await (0, get_port_please.getPort)({
|
|
543
|
+
host: options.host || "localhost",
|
|
544
|
+
random: true
|
|
545
|
+
});
|
|
546
|
+
const app = (0, h3.createApp)();
|
|
547
|
+
const host = (0, devframe_node.createH3DevToolsHost)({
|
|
548
|
+
appName: options.framework?.name || "powerlines",
|
|
549
|
+
origin: `http://${options.host || "localhost"}:${port}`,
|
|
550
|
+
mount: (base, dir) => {
|
|
551
|
+
app.use(base, (0, h3.fromNodeMiddleware)((0, sirv.default)(dir, {
|
|
552
|
+
dev: true,
|
|
553
|
+
single: true
|
|
554
|
+
})));
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
return require_context_engine_context.PowerlinesEngineContext.from(options, host, {
|
|
558
|
+
backend: "websocket",
|
|
559
|
+
websocket: port
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
async function createEngine(options, apiPath = "@powerlines/engine/api", apiMethods) {
|
|
563
|
+
node_events.EventEmitter.setMaxListeners(Infinity);
|
|
564
|
+
const context = await createContext(options);
|
|
565
|
+
return new PowerlinesEngine(context, await ExecutionHostWorker.from(apiPath, {
|
|
566
|
+
root: options.root,
|
|
567
|
+
context,
|
|
568
|
+
apiMethods
|
|
569
|
+
}));
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
//#endregion
|
|
573
|
+
Object.defineProperty(exports, 'PowerlinesEngine', {
|
|
574
|
+
enumerable: true,
|
|
575
|
+
get: function () {
|
|
576
|
+
return PowerlinesEngine;
|
|
577
|
+
}
|
|
578
|
+
});
|
|
579
|
+
Object.defineProperty(exports, 'createContext', {
|
|
580
|
+
enumerable: true,
|
|
581
|
+
get: function () {
|
|
582
|
+
return createContext;
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
Object.defineProperty(exports, 'createEngine', {
|
|
586
|
+
enumerable: true,
|
|
587
|
+
get: function () {
|
|
588
|
+
return createEngine;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { n as EngineOptions } from "./config-DKEmqMrh.cjs";
|
|
2
|
+
import { n as EngineExecutionItem, t as EngineContext } from "./context-D0_a0kRO.cjs";
|
|
3
|
+
import { FrameworkOptions, InlineConfig, LogFn, LoggerOptions } from "@powerlines/core";
|
|
4
|
+
import { ConnectionMeta, DevToolsHost, DevToolsNodeContext } from "devframe/types";
|
|
5
|
+
import { PowerlinesBaseContext } from "@powerlines/core/context/base-context";
|
|
6
|
+
import { EnvPaths } from "@stryke/env/get-env-paths";
|
|
7
|
+
|
|
8
|
+
//#region src/context/engine-context.d.ts
|
|
9
|
+
declare class PowerlinesEngineContext<TSystemContext = unknown> extends PowerlinesBaseContext<TSystemContext> implements EngineContext<TSystemContext> {
|
|
10
|
+
#private;
|
|
11
|
+
options: EngineOptions;
|
|
12
|
+
connection: ConnectionMeta;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a new instance of the PowerlinesEngineContext class.
|
|
15
|
+
*
|
|
16
|
+
* @param options - The options to initialize the context with.
|
|
17
|
+
* @returns A promise that resolves to an instance of the PowerlinesEngineContext class.
|
|
18
|
+
*/
|
|
19
|
+
static from<TSystemContext = unknown>(options: EngineOptions, host: DevToolsHost, connection: ConnectionMeta): Promise<PowerlinesEngineContext<TSystemContext>>;
|
|
20
|
+
createLogger(options?: LoggerOptions, logFn?: LogFn): import("@powerlines/core").Logger;
|
|
21
|
+
get executions(): EngineExecutionItem[];
|
|
22
|
+
get devtools(): DevToolsNodeContext;
|
|
23
|
+
get envPaths(): EnvPaths;
|
|
24
|
+
get framework(): FrameworkOptions;
|
|
25
|
+
get orgId(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new Context instance.
|
|
28
|
+
*
|
|
29
|
+
* @param options - The options to use for creating the context, including the resolved configuration and workspace settings.
|
|
30
|
+
* @param connection - The connection metadata for the dev server.
|
|
31
|
+
*/
|
|
32
|
+
protected constructor(options: EngineOptions, connection: ConnectionMeta);
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the context with the provided configuration options
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* This method will set up the resolver and load the user configuration file based on the provided options. It is called during the construction of the context and can also be called when cloning the context to ensure that the new context has the same configuration and resolver setup.
|
|
38
|
+
*
|
|
39
|
+
* @param method - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.
|
|
40
|
+
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
41
|
+
*/
|
|
42
|
+
loadExecutions(method: string, inlineConfig: InlineConfig): Promise<EngineExecutionItem[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Complete an execution by removing it from the list of active executions based on the provided invocation ID and execution ID. This method is typically called when an execution has finished or has been terminated, allowing the context to clean up any resources associated with that execution and update its internal state accordingly.
|
|
45
|
+
*
|
|
46
|
+
* @param invocationId - The unique identifier for the invocation of the execution to be completed.
|
|
47
|
+
* @param executionId - The unique identifier for the specific execution to be completed.
|
|
48
|
+
*/
|
|
49
|
+
completeExecution(invocationId: string, executionId: string): void;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { PowerlinesEngineContext as t };
|
|
53
|
+
//# sourceMappingURL=engine-context-B8K6Jtkk.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine-context-B8K6Jtkk.d.cts","names":[],"sources":["../src/context/engine-context.ts"],"mappings":";;;;;;;;cAmDa,uBAAA,mCACH,qBAAA,CAAsB,cAAA,aACnB,aAAA,CAAc,cAAA;EAAA;EAkIP,OAAA,EAAS,aAAA;EAClB,UAAA,EAAY,cAAA;EArIa;;;;;;EAAA,OAgBd,IAAA,0BAAA,CAClB,OAAA,EAAS,aAAA,EACT,IAAA,EAAM,YAAA,EACN,UAAA,EAAY,cAAA,GACX,OAAA,CAAQ,uBAAA,CAAwB,cAAA;EA8DnB,YAAA,CAAa,OAAA,GAAS,aAAA,EAAoB,KAAA,GAAQ,KAAA,8BAAK,MAAA;EAAA,IAe5D,UAAA,CAAA,GAAc,mBAAA;EAAA,IAId,QAAA,CAAA,GAAY,mBAAA;EAAA,IAIZ,QAAA,CAAA,GAAY,QAAA;EAAA,IAQZ,SAAA,CAAA,GAAa,gBAAA;EAAA,IAQb,KAAA,CAAA;EAxBc;;;;;;EAAA,UAkChB,WAAA,CACS,OAAA,EAAS,aAAA,EAClB,UAAA,EAAY,cAAA;EAiBV;;;;;;;;;EAHE,cAAA,CACX,MAAA,UACA,YAAA,EAAc,YAAA,GACb,OAAA,CAAQ,mBAAA;EApJc;;;;;;EAwNlB,iBAAA,CAAkB,YAAA,UAAsB,WAAA;AAAA"}
|