@powerlines/engine 0.49.34 → 0.49.35
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/{engine-BKEDCOCb.cjs → _internal/execution-api-worker.cjs} +4 -277
- package/dist/_internal/execution-api-worker.d.cts +64 -0
- package/dist/_internal/execution-api-worker.d.cts.map +1 -0
- package/dist/_internal/execution-api-worker.d.mts +64 -0
- package/dist/_internal/execution-api-worker.d.mts.map +1 -0
- package/dist/{engine-DRAFIm5M.mjs → _internal/execution-api-worker.mjs} +3 -258
- package/dist/_internal/execution-api-worker.mjs.map +1 -0
- package/dist/{chunk-C_NdSu1c.cjs → _virtual/_rolldown/runtime.cjs} +1 -6
- package/dist/api/build.cjs +4 -4
- package/dist/api/build.d.cts +2 -2
- package/dist/api/build.d.cts.map +1 -1
- package/dist/api/build.d.mts +2 -2
- package/dist/api/build.d.mts.map +1 -1
- package/dist/api/build.mjs +2 -2
- package/dist/api/build.mjs.map +1 -1
- package/dist/api/clean.d.cts +2 -2
- package/dist/api/clean.d.mts +2 -2
- package/dist/api/create.cjs +2 -2
- package/dist/api/create.d.cts +2 -2
- package/dist/api/create.d.mts +2 -2
- package/dist/api/deploy.d.cts +2 -2
- package/dist/api/deploy.d.mts +2 -2
- package/dist/api/docs.d.cts +2 -2
- package/dist/api/docs.d.mts +2 -2
- package/dist/api/lint.d.cts +2 -2
- package/dist/api/lint.d.mts +2 -2
- package/dist/api/prepare.d.cts +2 -2
- package/dist/api/prepare.d.mts +2 -2
- package/dist/api/test.d.cts +2 -2
- package/dist/api/test.d.mts +2 -2
- package/dist/api/types.d.cts +2 -2
- package/dist/api/types.d.mts +2 -2
- package/dist/api.d.cts +1 -1
- package/dist/api.d.mts +1 -1
- package/dist/context/engine-context.cjs +2 -2
- package/dist/context/engine-context.d.cts +53 -2
- package/dist/context/engine-context.d.cts.map +1 -0
- package/dist/context/engine-context.d.mts +53 -2
- package/dist/context/engine-context.d.mts.map +1 -0
- package/dist/context/index.d.cts +1 -1
- package/dist/context/index.d.mts +1 -1
- package/dist/engine.cjs +261 -4
- package/dist/engine.d.cts +143 -2
- package/dist/engine.d.cts.map +1 -0
- package/dist/engine.d.mts +143 -2
- package/dist/engine.d.mts.map +1 -0
- package/dist/engine.mjs +258 -2
- package/dist/engine.mjs.map +1 -0
- package/dist/helpers/create-api.d.cts +18 -2
- package/dist/helpers/create-api.d.cts.map +1 -0
- package/dist/helpers/create-api.d.mts +18 -2
- package/dist/helpers/create-api.d.mts.map +1 -0
- package/dist/helpers/finalize.d.cts +12 -2
- package/dist/helpers/finalize.d.cts.map +1 -0
- package/dist/helpers/finalize.d.mts +12 -2
- package/dist/helpers/finalize.d.mts.map +1 -0
- package/dist/helpers/index.d.cts +5 -4
- package/dist/helpers/index.d.mts +5 -4
- package/dist/helpers/rpc.d.cts +8 -2
- package/dist/helpers/rpc.d.cts.map +1 -0
- package/dist/helpers/rpc.d.mts +8 -2
- package/dist/helpers/rpc.d.mts.map +1 -0
- package/dist/helpers/stream.d.cts +45 -2
- package/dist/helpers/stream.d.cts.map +1 -0
- package/dist/helpers/stream.d.mts +45 -2
- package/dist/helpers/stream.d.mts.map +1 -0
- package/dist/helpers/type-checks.d.cts +19 -2
- package/dist/helpers/type-checks.d.cts.map +1 -0
- package/dist/helpers/type-checks.d.mts +19 -2
- package/dist/helpers/type-checks.d.mts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +6 -5
- package/dist/index.d.mts +6 -5
- package/dist/index.mjs +1 -1
- package/dist/{index-CBobV6Wm.d.mts → types/api.d.cts} +5 -31
- package/dist/types/api.d.cts.map +1 -0
- package/dist/{index-QuLZgb8w.d.cts → types/api.d.mts} +5 -31
- package/dist/types/api.d.mts.map +1 -0
- package/dist/types/config.d.cts +72 -0
- package/dist/types/config.d.cts.map +1 -0
- package/dist/types/config.d.mts +72 -0
- package/dist/types/config.d.mts.map +1 -0
- package/dist/{context-C71mv_aw.d.mts → types/context.d.cts} +4 -3
- package/dist/types/context.d.cts.map +1 -0
- package/dist/{context-ZbJRDGpl.d.cts → types/context.d.mts} +4 -3
- package/dist/types/context.d.mts.map +1 -0
- package/dist/types/index.d.cts +4 -0
- package/dist/types/index.d.mts +4 -0
- package/dist/{config-B6udgcnD.d.cts → types/rpc.d.cts} +7 -70
- package/dist/types/rpc.d.cts.map +1 -0
- package/dist/{config-DXxu0y4t.d.mts → types/rpc.d.mts} +7 -70
- package/dist/types/rpc.d.mts.map +1 -0
- package/package.json +7 -7
- package/dist/config-B6udgcnD.d.cts.map +0 -1
- package/dist/config-DXxu0y4t.d.mts.map +0 -1
- package/dist/context-C71mv_aw.d.mts.map +0 -1
- package/dist/context-ZbJRDGpl.d.cts.map +0 -1
- package/dist/engine-B5pbfMyg.d.cts +0 -199
- package/dist/engine-B5pbfMyg.d.cts.map +0 -1
- package/dist/engine-CeWEM0TT.d.mts +0 -199
- package/dist/engine-CeWEM0TT.d.mts.map +0 -1
- package/dist/engine-DRAFIm5M.mjs.map +0 -1
- package/dist/engine-context-CaPJFek0.d.mts +0 -53
- package/dist/engine-context-CaPJFek0.d.mts.map +0 -1
- package/dist/engine-context-DDbpdZHC.d.cts +0 -53
- package/dist/engine-context-DDbpdZHC.d.cts.map +0 -1
- package/dist/finalize-CuV0r3jg.d.cts +0 -12
- package/dist/finalize-CuV0r3jg.d.cts.map +0 -1
- package/dist/finalize-CuV0r3jg.d.mts +0 -12
- package/dist/finalize-CuV0r3jg.d.mts.map +0 -1
- package/dist/index-CBobV6Wm.d.mts.map +0 -1
- package/dist/index-QuLZgb8w.d.cts.map +0 -1
- package/dist/rpc-5MpqPBPa.d.cts +0 -7
- package/dist/rpc-5MpqPBPa.d.cts.map +0 -1
- package/dist/rpc-BvVZXS5K.d.mts +0 -7
- package/dist/rpc-BvVZXS5K.d.mts.map +0 -1
- package/dist/stream-B9jffNbk.d.cts +0 -45
- package/dist/stream-B9jffNbk.d.cts.map +0 -1
- package/dist/stream-B9jffNbk.d.mts +0 -45
- package/dist/stream-B9jffNbk.d.mts.map +0 -1
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
const
|
|
2
|
-
const require_helpers_stream = require('
|
|
3
|
-
const require_context_engine_context = require('./context/engine-context.cjs');
|
|
1
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_helpers_stream = require('../helpers/stream.cjs');
|
|
4
3
|
let _stryke_path_append = require("@stryke/path/append");
|
|
5
4
|
let _stryke_type_checks_is_number = require("@stryke/type-checks/is-number");
|
|
6
5
|
let _stryke_type_checks_is_set = require("@stryke/type-checks/is-set");
|
|
7
|
-
let node_events = require("node:events");
|
|
8
6
|
let node_stream = require("node:stream");
|
|
9
|
-
let devframe_node = require("devframe/node");
|
|
10
|
-
let get_port_please = require("get-port-please");
|
|
11
|
-
let h3 = require("h3");
|
|
12
|
-
let sirv = require("sirv");
|
|
13
|
-
sirv = require_chunk.__toESM(sirv, 1);
|
|
14
7
|
let _powerlines_core_lib_config = require("@powerlines/core/lib/config");
|
|
15
8
|
let _stryke_env_environment_checks = require("@stryke/env/environment-checks");
|
|
16
9
|
let _stryke_fs_resolve = require("@stryke/fs/resolve");
|
|
@@ -20,7 +13,7 @@ let date_fns_formatDuration = require("date-fns/formatDuration");
|
|
|
20
13
|
let node_util = require("node:util");
|
|
21
14
|
let node_worker_threads = require("node:worker_threads");
|
|
22
15
|
let tinypool = require("tinypool");
|
|
23
|
-
tinypool =
|
|
16
|
+
tinypool = require_runtime.__toESM(tinypool, 1);
|
|
24
17
|
|
|
25
18
|
//#region src/_internal/execution-api-worker.ts
|
|
26
19
|
const RESTARTED = Symbol("powerlines-worker:restarted");
|
|
@@ -317,270 +310,4 @@ var ExecutionApiWorker = class ExecutionApiWorker {
|
|
|
317
310
|
};
|
|
318
311
|
|
|
319
312
|
//#endregion
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* The Powerlines process' orchestration and coordination API.
|
|
323
|
-
*
|
|
324
|
-
* @public
|
|
325
|
-
*/
|
|
326
|
-
var PowerlinesEngine = class {
|
|
327
|
-
/**
|
|
328
|
-
* The Powerlines context
|
|
329
|
-
*/
|
|
330
|
-
#context;
|
|
331
|
-
/**
|
|
332
|
-
* 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.
|
|
333
|
-
*/
|
|
334
|
-
#api;
|
|
335
|
-
/**
|
|
336
|
-
* The Powerlines context
|
|
337
|
-
*/
|
|
338
|
-
get context() {
|
|
339
|
-
return this.#context;
|
|
340
|
-
}
|
|
341
|
-
/**
|
|
342
|
-
* 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.
|
|
343
|
-
*/
|
|
344
|
-
get api() {
|
|
345
|
-
return this.#api;
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Create a new Powerlines Engine instance
|
|
349
|
-
*
|
|
350
|
-
* @param context - The Powerlines context
|
|
351
|
-
* @param api - The API host for the execution workers
|
|
352
|
-
* @returns A new instance of the Powerlines Engine
|
|
353
|
-
*/
|
|
354
|
-
constructor(context, api) {
|
|
355
|
-
this.#context = context;
|
|
356
|
-
this.#api = api;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Create a new Powerlines project
|
|
360
|
-
*
|
|
361
|
-
* @remarks
|
|
362
|
-
* This method will create a new Powerlines project in the current directory.
|
|
363
|
-
*
|
|
364
|
-
* @param inlineConfig - The inline configuration for the create command
|
|
365
|
-
* @returns A promise that resolves when the project has been created
|
|
366
|
-
*/
|
|
367
|
-
async create(inlineConfig) {
|
|
368
|
-
const timer = this.context.timer("Create");
|
|
369
|
-
this.context.info("🆕 Creating a new project");
|
|
370
|
-
await this.execute("create", inlineConfig);
|
|
371
|
-
this.context.debug("✔ Create command completed successfully");
|
|
372
|
-
timer();
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Generate the Powerlines typescript declaration file
|
|
376
|
-
*
|
|
377
|
-
* @remarks
|
|
378
|
-
* 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.
|
|
379
|
-
*
|
|
380
|
-
* @param inlineConfig - The inline configuration for the types command
|
|
381
|
-
*/
|
|
382
|
-
async types(inlineConfig) {
|
|
383
|
-
const timer = this.context.timer("Types");
|
|
384
|
-
this.context.info("🏗️ Generating typescript declarations for the project");
|
|
385
|
-
await this.execute("types", inlineConfig);
|
|
386
|
-
this.context.debug("✔ Types generation has completed successfully");
|
|
387
|
-
timer();
|
|
388
|
-
}
|
|
389
|
-
/**
|
|
390
|
-
* Prepare the Powerlines API
|
|
391
|
-
*
|
|
392
|
-
* @remarks
|
|
393
|
-
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
394
|
-
*
|
|
395
|
-
* @param inlineConfig - The inline configuration for the prepare command
|
|
396
|
-
*/
|
|
397
|
-
async prepare(inlineConfig) {
|
|
398
|
-
const timer = this.context.timer("Prepare");
|
|
399
|
-
this.context.info("🏗️ Preparing the project");
|
|
400
|
-
await this.execute("prepare", inlineConfig);
|
|
401
|
-
this.context.debug("✔ Preparation has completed successfully");
|
|
402
|
-
timer();
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Clean any previously prepared artifacts
|
|
406
|
-
*
|
|
407
|
-
* @remarks
|
|
408
|
-
* This method will remove the previous Powerlines artifacts from the project.
|
|
409
|
-
*
|
|
410
|
-
* @param inlineConfig - The inline configuration for the clean command
|
|
411
|
-
* @returns A promise that resolves when the clean command has completed
|
|
412
|
-
*/
|
|
413
|
-
async clean(inlineConfig) {
|
|
414
|
-
const timer = this.context.timer("Clean");
|
|
415
|
-
this.context.info("🧹 Cleaning the previous artifacts");
|
|
416
|
-
await this.execute("clean", inlineConfig);
|
|
417
|
-
this.context.debug("✔ Cleaning completed successfully");
|
|
418
|
-
timer();
|
|
419
|
-
}
|
|
420
|
-
/**
|
|
421
|
-
* Lint the project
|
|
422
|
-
*
|
|
423
|
-
* @param inlineConfig - The inline configuration for the lint command
|
|
424
|
-
* @returns A promise that resolves when the lint command has completed
|
|
425
|
-
*/
|
|
426
|
-
async lint(inlineConfig) {
|
|
427
|
-
const timer = this.context.timer("Lint");
|
|
428
|
-
this.context.info("📝 Linting the project");
|
|
429
|
-
await this.execute("lint", inlineConfig);
|
|
430
|
-
this.context.debug("✔ Linting completed successfully");
|
|
431
|
-
timer();
|
|
432
|
-
}
|
|
433
|
-
/**
|
|
434
|
-
* Test the project
|
|
435
|
-
*
|
|
436
|
-
* @remarks
|
|
437
|
-
* This method will run the tests for the Powerlines project.
|
|
438
|
-
*
|
|
439
|
-
* @param inlineConfig - The inline configuration for the test command
|
|
440
|
-
* @returns A promise that resolves when the test command has completed
|
|
441
|
-
*/
|
|
442
|
-
async test(inlineConfig) {
|
|
443
|
-
const timer = this.context.timer("Test");
|
|
444
|
-
this.context.info("🧪 Running tests for the project");
|
|
445
|
-
await this.execute("test", inlineConfig);
|
|
446
|
-
this.context.debug("✔ Testing completed successfully");
|
|
447
|
-
timer();
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Build the project
|
|
451
|
-
*
|
|
452
|
-
* @remarks
|
|
453
|
-
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
454
|
-
*
|
|
455
|
-
* @param inlineConfig - The inline configuration for the build command
|
|
456
|
-
* @returns A promise that resolves when the build command has completed
|
|
457
|
-
*/
|
|
458
|
-
async build(inlineConfig) {
|
|
459
|
-
const timer = this.context.timer("Build");
|
|
460
|
-
this.context.info("📦 Building the project");
|
|
461
|
-
await this.execute("build", inlineConfig);
|
|
462
|
-
this.context.debug("✔ Build completed successfully");
|
|
463
|
-
timer();
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Prepare the documentation for the project
|
|
467
|
-
*
|
|
468
|
-
* @param inlineConfig - The inline configuration for the docs command
|
|
469
|
-
* @returns A promise that resolves when the documentation generation has completed
|
|
470
|
-
*/
|
|
471
|
-
async docs(inlineConfig) {
|
|
472
|
-
const timer = this.context.timer("Docs");
|
|
473
|
-
this.context.info("📓 Generating documentation for the project");
|
|
474
|
-
await this.execute("docs", inlineConfig);
|
|
475
|
-
this.context.debug("✔ Documentation generation completed successfully");
|
|
476
|
-
timer();
|
|
477
|
-
}
|
|
478
|
-
/**
|
|
479
|
-
* Deploy the project source code
|
|
480
|
-
*
|
|
481
|
-
* @remarks
|
|
482
|
-
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
483
|
-
*
|
|
484
|
-
* @param inlineConfig - The inline configuration for the deploy command
|
|
485
|
-
* @returns A promise that resolves when the deploy command has completed
|
|
486
|
-
*/
|
|
487
|
-
async deploy(inlineConfig) {
|
|
488
|
-
const timer = this.context.timer("Deploy");
|
|
489
|
-
this.context.info("🚀 Deploying the project");
|
|
490
|
-
await this.execute("deploy", inlineConfig);
|
|
491
|
-
this.context.debug("✔ Deployment completed successfully");
|
|
492
|
-
timer();
|
|
493
|
-
}
|
|
494
|
-
/**
|
|
495
|
-
* Finalization/cleanup processing for the Powerlines API
|
|
496
|
-
*
|
|
497
|
-
* @remarks
|
|
498
|
-
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
499
|
-
*
|
|
500
|
-
* @returns A promise that resolves when the finalization process has completed
|
|
501
|
-
*/
|
|
502
|
-
async finalize() {
|
|
503
|
-
const timer = this.context.timer("Finalize");
|
|
504
|
-
this.context.info("🏁 Finalization processes started");
|
|
505
|
-
await this.api.finalize();
|
|
506
|
-
this.context.debug("✔ Finalization completed successfully");
|
|
507
|
-
timer();
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
|
|
511
|
-
*/
|
|
512
|
-
async [Symbol.asyncDispose]() {
|
|
513
|
-
return this.finalize();
|
|
514
|
-
}
|
|
515
|
-
/**
|
|
516
|
-
* Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
|
|
517
|
-
*
|
|
518
|
-
* @remarks
|
|
519
|
-
* 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.
|
|
520
|
-
*
|
|
521
|
-
* @param command - The path to the execution configuration to load and run, which can be used to specify different execution configurations for different commands or scenarios.
|
|
522
|
-
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
523
|
-
* @returns A promise that resolves when all executions for the specified command have completed
|
|
524
|
-
*/
|
|
525
|
-
async execute(command, inlineConfig) {
|
|
526
|
-
await Promise.all((await this.context.loadExecutions(command, inlineConfig)).map(async (execution) => {
|
|
527
|
-
try {
|
|
528
|
-
await this.api.execute(command, execution.options, inlineConfig);
|
|
529
|
-
} catch (error) {
|
|
530
|
-
this.context.error(`Execution of method "${command}" 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)}`);
|
|
531
|
-
throw error;
|
|
532
|
-
} finally {
|
|
533
|
-
this.context.completeExecution(execution.invocationId, execution.options.executionId);
|
|
534
|
-
}
|
|
535
|
-
}));
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
async function createContext(options) {
|
|
539
|
-
const port = options.port ?? await (0, get_port_please.getPort)({
|
|
540
|
-
host: options.host || "localhost",
|
|
541
|
-
random: true
|
|
542
|
-
});
|
|
543
|
-
const app = (0, h3.createApp)();
|
|
544
|
-
const host = (0, devframe_node.createH3DevToolsHost)({
|
|
545
|
-
appName: options.framework?.name || "powerlines",
|
|
546
|
-
origin: `http://${options.host || "localhost"}:${port}`,
|
|
547
|
-
mount: (base, dir) => {
|
|
548
|
-
app.use(base, (0, h3.fromNodeMiddleware)((0, sirv.default)(dir, {
|
|
549
|
-
dev: true,
|
|
550
|
-
single: true
|
|
551
|
-
})));
|
|
552
|
-
}
|
|
553
|
-
});
|
|
554
|
-
return require_context_engine_context.PowerlinesEngineContext.from(options, host, {
|
|
555
|
-
backend: "websocket",
|
|
556
|
-
websocket: port
|
|
557
|
-
});
|
|
558
|
-
}
|
|
559
|
-
async function createEngine(options, apiPath = "@powerlines/engine/api") {
|
|
560
|
-
node_events.EventEmitter.setMaxListeners(Infinity);
|
|
561
|
-
const context = await createContext(options);
|
|
562
|
-
return new PowerlinesEngine(context, await ExecutionApiWorker.from(apiPath, {
|
|
563
|
-
root: options.root,
|
|
564
|
-
context
|
|
565
|
-
}));
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
//#endregion
|
|
569
|
-
Object.defineProperty(exports, 'PowerlinesEngine', {
|
|
570
|
-
enumerable: true,
|
|
571
|
-
get: function () {
|
|
572
|
-
return PowerlinesEngine;
|
|
573
|
-
}
|
|
574
|
-
});
|
|
575
|
-
Object.defineProperty(exports, 'createContext', {
|
|
576
|
-
enumerable: true,
|
|
577
|
-
get: function () {
|
|
578
|
-
return createContext;
|
|
579
|
-
}
|
|
580
|
-
});
|
|
581
|
-
Object.defineProperty(exports, 'createEngine', {
|
|
582
|
-
enumerable: true,
|
|
583
|
-
get: function () {
|
|
584
|
-
return createEngine;
|
|
585
|
-
}
|
|
586
|
-
});
|
|
313
|
+
exports.ExecutionApiWorker = ExecutionApiWorker;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { EngineExecutionOptions } from "../types/config.cjs";
|
|
2
|
+
import { EngineContext } from "../types/context.cjs";
|
|
3
|
+
import { ExecutionApiWorkerInterface } from "../types/api.cjs";
|
|
4
|
+
import { InlineConfig, Mode } from "@powerlines/core";
|
|
5
|
+
|
|
6
|
+
//#region src/_internal/execution-api-worker.d.ts
|
|
7
|
+
declare const RESTARTED: unique symbol;
|
|
8
|
+
interface ExecutionApiWorkerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The maximum time in milliseconds a worker can run before being terminated.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue 900000 (15 minutes)
|
|
13
|
+
*/
|
|
14
|
+
timeout?: number;
|
|
15
|
+
/**
|
|
16
|
+
* True if `--max-old-space-size` should not be forwarded to the worker.
|
|
17
|
+
*/
|
|
18
|
+
isolatedMemory?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The mode to run the worker in, which can affect how the worker is initialized and how it behaves. This is determined based on the resolved configuration of the engine, and can be used to optimize the worker for different environments (e.g., development, production, etc.).
|
|
21
|
+
*/
|
|
22
|
+
mode?: Mode;
|
|
23
|
+
/**
|
|
24
|
+
* An optional root to resolve the execution host path from, which can be used to specify a custom root directory for the worker to use when resolving paths and loading configuration files. If this option is not provided, the worker will use the current working directory as the root directory by default.
|
|
25
|
+
*/
|
|
26
|
+
root?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The context of the {@link @powerlines/engine#Engine | Engine instance}, which can be used to access the engine's state and services within the worker.
|
|
29
|
+
*/
|
|
30
|
+
context: EngineContext;
|
|
31
|
+
}
|
|
32
|
+
declare class ExecutionApiWorker implements ExecutionApiWorkerInterface {
|
|
33
|
+
#private;
|
|
34
|
+
protected executionApiPath: string;
|
|
35
|
+
protected options: ExecutionApiWorkerOptions;
|
|
36
|
+
protected get restartPromise(): Promise<typeof RESTARTED>;
|
|
37
|
+
protected resolveRestartPromise(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new instance of the Execution API Worker 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.
|
|
40
|
+
*
|
|
41
|
+
* @param apiPath - The path to the Execution API file.
|
|
42
|
+
* @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.
|
|
43
|
+
* @returns A promise that resolves to an instance of the ExecutionApiWorker class.
|
|
44
|
+
*/
|
|
45
|
+
static from(apiPath: string, options: ExecutionApiWorkerOptions): Promise<ExecutionApiWorker>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new API worker instance.
|
|
48
|
+
*
|
|
49
|
+
* @param executionApiPath - The path to the worker file.
|
|
50
|
+
* @param options - The options for the worker, including exposed commands, timeout, and hooks for activity and restart.
|
|
51
|
+
*/
|
|
52
|
+
protected constructor(executionApiPath: string, options: ExecutionApiWorkerOptions);
|
|
53
|
+
execute(command: string, options: Omit<EngineExecutionOptions, "channel">, inlineConfig: InlineConfig): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* 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.
|
|
56
|
+
*/
|
|
57
|
+
finalize(): Promise<void>;
|
|
58
|
+
protected onHanging(): void;
|
|
59
|
+
protected onActivity(): void;
|
|
60
|
+
protected innerExecute(command: string, options: Omit<EngineExecutionOptions, "channel">, inlineConfig: InlineConfig): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { ExecutionApiWorker };
|
|
64
|
+
//# sourceMappingURL=execution-api-worker.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-api-worker.d.cts","names":[],"sources":["../../src/_internal/execution-api-worker.ts"],"mappings":";;;;;;cAwCM,SAAA;AAAA,UA8DW,yBAAA;EA9DX;;;;AAAiD;EA8ErD,OAAA;EAhBwC;;;EAqBxC,cAAA;EAAA;;;EAKA,IAAA,GAAO,IAAA;EAUP;;;EALA,IAAA;EAQW;;;EAHX,OAAA,EAAS,aAAa;AAAA;AAAA,cAGX,kBAAA,YAA8B,2BAAA;EAAA;YAsE7B,gBAAA;EAAA,UACA,OAAA,EAAS,yBAAA;EAAA,cAxDP,cAAA,IAAc,OAAA,QAAA,SAAA;EAAA,UASlB,qBAAA;EAuWC;;;;;;;EAAA,OAxVS,IAAA,CAClB,OAAA,UACA,OAAA,EAAS,yBAAA,GAAyB,OAAA,CAAA,kBAAA;EAzCK;;;;;;EAAA,UAqEhC,WAAA,CACG,gBAAA,UACA,OAAA,EAAS,yBAAA;EAsTR,OAAA,CACX,OAAA,UACA,OAAA,EAAS,IAAA,CAAK,sBAAA,cACd,YAAA,EAAc,YAAA,GAAY,OAAA;EAjXd;;;EAoZD,QAAA,IAAY,OAAA;EAAA,UAUf,SAAA;EAAA,UAoBA,UAAA;EAAA,UAUM,YAAA,CACd,OAAA,UACA,OAAA,EAAS,IAAA,CAAK,sBAAA,cACd,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { EngineExecutionOptions } from "../types/config.mjs";
|
|
2
|
+
import { EngineContext } from "../types/context.mjs";
|
|
3
|
+
import { ExecutionApiWorkerInterface } from "../types/api.mjs";
|
|
4
|
+
import { InlineConfig, Mode } from "@powerlines/core";
|
|
5
|
+
|
|
6
|
+
//#region src/_internal/execution-api-worker.d.ts
|
|
7
|
+
declare const RESTARTED: unique symbol;
|
|
8
|
+
interface ExecutionApiWorkerOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The maximum time in milliseconds a worker can run before being terminated.
|
|
11
|
+
*
|
|
12
|
+
* @defaultValue 900000 (15 minutes)
|
|
13
|
+
*/
|
|
14
|
+
timeout?: number;
|
|
15
|
+
/**
|
|
16
|
+
* True if `--max-old-space-size` should not be forwarded to the worker.
|
|
17
|
+
*/
|
|
18
|
+
isolatedMemory?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The mode to run the worker in, which can affect how the worker is initialized and how it behaves. This is determined based on the resolved configuration of the engine, and can be used to optimize the worker for different environments (e.g., development, production, etc.).
|
|
21
|
+
*/
|
|
22
|
+
mode?: Mode;
|
|
23
|
+
/**
|
|
24
|
+
* An optional root to resolve the execution host path from, which can be used to specify a custom root directory for the worker to use when resolving paths and loading configuration files. If this option is not provided, the worker will use the current working directory as the root directory by default.
|
|
25
|
+
*/
|
|
26
|
+
root?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The context of the {@link @powerlines/engine#Engine | Engine instance}, which can be used to access the engine's state and services within the worker.
|
|
29
|
+
*/
|
|
30
|
+
context: EngineContext;
|
|
31
|
+
}
|
|
32
|
+
declare class ExecutionApiWorker implements ExecutionApiWorkerInterface {
|
|
33
|
+
#private;
|
|
34
|
+
protected executionApiPath: string;
|
|
35
|
+
protected options: ExecutionApiWorkerOptions;
|
|
36
|
+
protected get restartPromise(): Promise<typeof RESTARTED>;
|
|
37
|
+
protected resolveRestartPromise(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Creates a new instance of the Execution API Worker 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.
|
|
40
|
+
*
|
|
41
|
+
* @param apiPath - The path to the Execution API file.
|
|
42
|
+
* @param options - The options for configuring the worker, including the execution context, exposed methods, timeout, and mode.
|
|
43
|
+
* @returns A promise that resolves to an instance of the ExecutionApiWorker class.
|
|
44
|
+
*/
|
|
45
|
+
static from(apiPath: string, options: ExecutionApiWorkerOptions): Promise<ExecutionApiWorker>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a new API worker instance.
|
|
48
|
+
*
|
|
49
|
+
* @param executionApiPath - The path to the worker file.
|
|
50
|
+
* @param options - The options for the worker, including exposed commands, timeout, and hooks for activity and restart.
|
|
51
|
+
*/
|
|
52
|
+
protected constructor(executionApiPath: string, options: ExecutionApiWorkerOptions);
|
|
53
|
+
execute(command: string, options: Omit<EngineExecutionOptions, "channel">, inlineConfig: InlineConfig): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* 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.
|
|
56
|
+
*/
|
|
57
|
+
finalize(): Promise<void>;
|
|
58
|
+
protected onHanging(): void;
|
|
59
|
+
protected onActivity(): void;
|
|
60
|
+
protected innerExecute(command: string, options: Omit<EngineExecutionOptions, "channel">, inlineConfig: InlineConfig): Promise<void>;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { ExecutionApiWorker };
|
|
64
|
+
//# sourceMappingURL=execution-api-worker.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-api-worker.d.mts","names":[],"sources":["../../src/_internal/execution-api-worker.ts"],"mappings":";;;;;;cAwCM,SAAA;AAAA,UA8DW,yBAAA;EA9DX;;;;AAAiD;EA8ErD,OAAA;EAhBwC;;;EAqBxC,cAAA;EAAA;;;EAKA,IAAA,GAAO,IAAA;EAUP;;;EALA,IAAA;EAQW;;;EAHX,OAAA,EAAS,aAAa;AAAA;AAAA,cAGX,kBAAA,YAA8B,2BAAA;EAAA;YAsE7B,gBAAA;EAAA,UACA,OAAA,EAAS,yBAAA;EAAA,cAxDP,cAAA,IAAc,OAAA,QAAA,SAAA;EAAA,UASlB,qBAAA;EAuWC;;;;;;;EAAA,OAxVS,IAAA,CAClB,OAAA,UACA,OAAA,EAAS,yBAAA,GAAyB,OAAA,CAAA,kBAAA;EAzCK;;;;;;EAAA,UAqEhC,WAAA,CACG,gBAAA,UACA,OAAA,EAAS,yBAAA;EAsTR,OAAA,CACX,OAAA,UACA,OAAA,EAAS,IAAA,CAAK,sBAAA,cACd,YAAA,EAAc,YAAA,GAAY,OAAA;EAjXd;;;EAoZD,QAAA,IAAY,OAAA;EAAA,UAUf,SAAA;EAAA,UAoBA,UAAA;EAAA,UAUM,YAAA,CACd,OAAA,UACA,OAAA,EAAS,IAAA,CAAK,sBAAA,cACd,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA"}
|