@powerlines/engine 0.49.33 → 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 +16 -16
- 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
package/dist/engine.d.mts
CHANGED
|
@@ -1,2 +1,143 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EngineOptions } from "./types/config.mjs";
|
|
2
|
+
import { EngineContext } from "./types/context.mjs";
|
|
3
|
+
import { Engine } from "./types/api.mjs";
|
|
4
|
+
import { PowerlinesEngineContext } from "./context/engine-context.mjs";
|
|
5
|
+
import { ExecutionApiWorker } from "./_internal/execution-api-worker.mjs";
|
|
6
|
+
import { BuildInlineConfig, CleanInlineConfig, CreateInlineConfig, DeployInlineConfig, DocsInlineConfig, InlineConfig, LintInlineConfig, PrepareInlineConfig, TestInlineConfig, TypesInlineConfig } from "@powerlines/core";
|
|
7
|
+
|
|
8
|
+
//#region src/engine.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* The Powerlines process' orchestration and coordination API.
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
13
|
+
*/
|
|
14
|
+
declare class PowerlinesEngine implements Engine, AsyncDisposable {
|
|
15
|
+
#private;
|
|
16
|
+
/**
|
|
17
|
+
* The Powerlines context
|
|
18
|
+
*/
|
|
19
|
+
get context(): EngineContext;
|
|
20
|
+
/**
|
|
21
|
+
* 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.
|
|
22
|
+
*/
|
|
23
|
+
get api(): ExecutionApiWorker;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new Powerlines Engine instance
|
|
26
|
+
*
|
|
27
|
+
* @param context - The Powerlines context
|
|
28
|
+
* @param api - The API host for the execution workers
|
|
29
|
+
* @returns A new instance of the Powerlines Engine
|
|
30
|
+
*/
|
|
31
|
+
constructor(context: EngineContext, api: ExecutionApiWorker);
|
|
32
|
+
/**
|
|
33
|
+
* Create a new Powerlines project
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* This method will create a new Powerlines project in the current directory.
|
|
37
|
+
*
|
|
38
|
+
* @param inlineConfig - The inline configuration for the create command
|
|
39
|
+
* @returns A promise that resolves when the project has been created
|
|
40
|
+
*/
|
|
41
|
+
create(inlineConfig: CreateInlineConfig): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Generate the Powerlines typescript declaration file
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* 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.
|
|
47
|
+
*
|
|
48
|
+
* @param inlineConfig - The inline configuration for the types command
|
|
49
|
+
*/
|
|
50
|
+
types(inlineConfig: TypesInlineConfig): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Prepare the Powerlines API
|
|
53
|
+
*
|
|
54
|
+
* @remarks
|
|
55
|
+
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
56
|
+
*
|
|
57
|
+
* @param inlineConfig - The inline configuration for the prepare command
|
|
58
|
+
*/
|
|
59
|
+
prepare(inlineConfig: PrepareInlineConfig): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Clean any previously prepared artifacts
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* This method will remove the previous Powerlines artifacts from the project.
|
|
65
|
+
*
|
|
66
|
+
* @param inlineConfig - The inline configuration for the clean command
|
|
67
|
+
* @returns A promise that resolves when the clean command has completed
|
|
68
|
+
*/
|
|
69
|
+
clean(inlineConfig: CleanInlineConfig): Promise<void>;
|
|
70
|
+
/**
|
|
71
|
+
* Lint the project
|
|
72
|
+
*
|
|
73
|
+
* @param inlineConfig - The inline configuration for the lint command
|
|
74
|
+
* @returns A promise that resolves when the lint command has completed
|
|
75
|
+
*/
|
|
76
|
+
lint(inlineConfig: LintInlineConfig): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Test the project
|
|
79
|
+
*
|
|
80
|
+
* @remarks
|
|
81
|
+
* This method will run the tests for the Powerlines project.
|
|
82
|
+
*
|
|
83
|
+
* @param inlineConfig - The inline configuration for the test command
|
|
84
|
+
* @returns A promise that resolves when the test command has completed
|
|
85
|
+
*/
|
|
86
|
+
test(inlineConfig: TestInlineConfig): Promise<void>;
|
|
87
|
+
/**
|
|
88
|
+
* Build the project
|
|
89
|
+
*
|
|
90
|
+
* @remarks
|
|
91
|
+
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
92
|
+
*
|
|
93
|
+
* @param inlineConfig - The inline configuration for the build command
|
|
94
|
+
* @returns A promise that resolves when the build command has completed
|
|
95
|
+
*/
|
|
96
|
+
build(inlineConfig: BuildInlineConfig): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Prepare the documentation for the project
|
|
99
|
+
*
|
|
100
|
+
* @param inlineConfig - The inline configuration for the docs command
|
|
101
|
+
* @returns A promise that resolves when the documentation generation has completed
|
|
102
|
+
*/
|
|
103
|
+
docs(inlineConfig: DocsInlineConfig): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Deploy the project source code
|
|
106
|
+
*
|
|
107
|
+
* @remarks
|
|
108
|
+
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
109
|
+
*
|
|
110
|
+
* @param inlineConfig - The inline configuration for the deploy command
|
|
111
|
+
* @returns A promise that resolves when the deploy command has completed
|
|
112
|
+
*/
|
|
113
|
+
deploy(inlineConfig: DeployInlineConfig): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Finalization/cleanup processing for the Powerlines API
|
|
116
|
+
*
|
|
117
|
+
* @remarks
|
|
118
|
+
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
119
|
+
*
|
|
120
|
+
* @returns A promise that resolves when the finalization process has completed
|
|
121
|
+
*/
|
|
122
|
+
finalize(): Promise<void>;
|
|
123
|
+
/**
|
|
124
|
+
* Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
|
|
125
|
+
*/
|
|
126
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* 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.
|
|
132
|
+
*
|
|
133
|
+
* @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.
|
|
134
|
+
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
135
|
+
* @returns A promise that resolves when all executions for the specified command have completed
|
|
136
|
+
*/
|
|
137
|
+
protected execute(command: string, inlineConfig: InlineConfig): Promise<void>;
|
|
138
|
+
}
|
|
139
|
+
declare function createContext(options: EngineOptions): Promise<PowerlinesEngineContext<unknown>>;
|
|
140
|
+
declare function createEngine(options: EngineOptions, apiPath?: string): Promise<PowerlinesEngine>;
|
|
141
|
+
//#endregion
|
|
142
|
+
export { PowerlinesEngine, createContext, createEngine };
|
|
143
|
+
//# sourceMappingURL=engine.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.mts","names":[],"sources":["../src/engine.ts"],"mappings":";;;;;;;;;;AA8CA;;;cAAa,gBAAA,YAA4B,MAAA,EAAQ,eAAA;EAAA;EAgCnB;;;EAAA,IAlBjB,OAAA,IAAW,aAAA;EAkDW;;;EAAA,IA3CtB,GAAA,IAAO,kBAAA;EAgFe;;;;;;;cArEd,OAAA,EAAS,aAAA,EAAe,GAAA,EAAK,kBAAA;EA2IhB;;;;;;;;;EA7HnB,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA9CL;;;;;;;;EAgElC,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EA3ChC;;;;;;;;EA6DL,OAAA,CAAQ,YAAA,EAAc,mBAAA,GAAmB,OAAA;EApCF;;;;;;;;;EAuDvC,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAAjB;;;;;;EAgBpB,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAmBnC;;;;;;;;;EAAA,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAmC9B;;;;;;;;;EAhBL,KAAA,CAAM,YAAA,EAAc,iBAAA,GAAiB,OAAA;EAkEhB;;;;;;EAlDrB,IAAA,CAAK,YAAA,EAAc,gBAAA,GAAgB,OAAA;EAgEmB;AA8BrE;;;;;;;;EA3Ee,MAAA,CAAO,YAAA,EAAc,kBAAA,GAAkB,OAAA;EA2ElB;;;;AAAsB;AAuB1D;;;EAhFe,QAAA,IAAQ,OAAA;EAkFa;;;EAAA,CArEpB,MAAA,CAAO,YAAA,KAAa,OAAA;EAoEzB;;;;;;AACyB;;;;EADzB,UAtDO,OAAA,CAAQ,OAAA,UAAiB,YAAA,EAAc,YAAA,GAAY,OAAA;AAAA;AAAA,iBA8B/C,aAAA,CAAc,OAAA,EAAS,aAAA,GAAa,OAAA,CAAA,uBAAA;AAAA,iBAuBpC,YAAA,CACpB,OAAA,EAAS,aAAA,EACT,OAAA,YAAkC,OAAA,CAAA,gBAAA"}
|
package/dist/engine.mjs
CHANGED
|
@@ -1,3 +1,259 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExecutionApiWorker } from "./_internal/execution-api-worker.mjs";
|
|
2
|
+
import { PowerlinesEngineContext } from "./context/engine-context.mjs";
|
|
3
|
+
import { EventEmitter } from "node:events";
|
|
4
|
+
import { createH3DevToolsHost } from "devframe/node";
|
|
5
|
+
import { getPort } from "get-port-please";
|
|
6
|
+
import { createApp, fromNodeMiddleware } from "h3";
|
|
7
|
+
import sirv from "sirv";
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
//#region src/engine.ts
|
|
10
|
+
/**
|
|
11
|
+
* The Powerlines process' orchestration and coordination API.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
var PowerlinesEngine = class {
|
|
16
|
+
/**
|
|
17
|
+
* The Powerlines context
|
|
18
|
+
*/
|
|
19
|
+
#context;
|
|
20
|
+
/**
|
|
21
|
+
* 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.
|
|
22
|
+
*/
|
|
23
|
+
#api;
|
|
24
|
+
/**
|
|
25
|
+
* The Powerlines context
|
|
26
|
+
*/
|
|
27
|
+
get context() {
|
|
28
|
+
return this.#context;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 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.
|
|
32
|
+
*/
|
|
33
|
+
get api() {
|
|
34
|
+
return this.#api;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Create a new Powerlines Engine instance
|
|
38
|
+
*
|
|
39
|
+
* @param context - The Powerlines context
|
|
40
|
+
* @param api - The API host for the execution workers
|
|
41
|
+
* @returns A new instance of the Powerlines Engine
|
|
42
|
+
*/
|
|
43
|
+
constructor(context, api) {
|
|
44
|
+
this.#context = context;
|
|
45
|
+
this.#api = api;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a new Powerlines project
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* This method will create a new Powerlines project in the current directory.
|
|
52
|
+
*
|
|
53
|
+
* @param inlineConfig - The inline configuration for the create command
|
|
54
|
+
* @returns A promise that resolves when the project has been created
|
|
55
|
+
*/
|
|
56
|
+
async create(inlineConfig) {
|
|
57
|
+
const timer = this.context.timer("Create");
|
|
58
|
+
this.context.info("🆕 Creating a new project");
|
|
59
|
+
await this.execute("create", inlineConfig);
|
|
60
|
+
this.context.debug("✔ Create command completed successfully");
|
|
61
|
+
timer();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Generate the Powerlines typescript declaration file
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* 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.
|
|
68
|
+
*
|
|
69
|
+
* @param inlineConfig - The inline configuration for the types command
|
|
70
|
+
*/
|
|
71
|
+
async types(inlineConfig) {
|
|
72
|
+
const timer = this.context.timer("Types");
|
|
73
|
+
this.context.info("🏗️ Generating typescript declarations for the project");
|
|
74
|
+
await this.execute("types", inlineConfig);
|
|
75
|
+
this.context.debug("✔ Types generation has completed successfully");
|
|
76
|
+
timer();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Prepare the Powerlines API
|
|
80
|
+
*
|
|
81
|
+
* @remarks
|
|
82
|
+
* This method will prepare the Powerlines API for use, initializing any necessary resources.
|
|
83
|
+
*
|
|
84
|
+
* @param inlineConfig - The inline configuration for the prepare command
|
|
85
|
+
*/
|
|
86
|
+
async prepare(inlineConfig) {
|
|
87
|
+
const timer = this.context.timer("Prepare");
|
|
88
|
+
this.context.info("🏗️ Preparing the project");
|
|
89
|
+
await this.execute("prepare", inlineConfig);
|
|
90
|
+
this.context.debug("✔ Preparation has completed successfully");
|
|
91
|
+
timer();
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Clean any previously prepared artifacts
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* This method will remove the previous Powerlines artifacts from the project.
|
|
98
|
+
*
|
|
99
|
+
* @param inlineConfig - The inline configuration for the clean command
|
|
100
|
+
* @returns A promise that resolves when the clean command has completed
|
|
101
|
+
*/
|
|
102
|
+
async clean(inlineConfig) {
|
|
103
|
+
const timer = this.context.timer("Clean");
|
|
104
|
+
this.context.info("🧹 Cleaning the previous artifacts");
|
|
105
|
+
await this.execute("clean", inlineConfig);
|
|
106
|
+
this.context.debug("✔ Cleaning completed successfully");
|
|
107
|
+
timer();
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Lint the project
|
|
111
|
+
*
|
|
112
|
+
* @param inlineConfig - The inline configuration for the lint command
|
|
113
|
+
* @returns A promise that resolves when the lint command has completed
|
|
114
|
+
*/
|
|
115
|
+
async lint(inlineConfig) {
|
|
116
|
+
const timer = this.context.timer("Lint");
|
|
117
|
+
this.context.info("📝 Linting the project");
|
|
118
|
+
await this.execute("lint", inlineConfig);
|
|
119
|
+
this.context.debug("✔ Linting completed successfully");
|
|
120
|
+
timer();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Test the project
|
|
124
|
+
*
|
|
125
|
+
* @remarks
|
|
126
|
+
* This method will run the tests for the Powerlines project.
|
|
127
|
+
*
|
|
128
|
+
* @param inlineConfig - The inline configuration for the test command
|
|
129
|
+
* @returns A promise that resolves when the test command has completed
|
|
130
|
+
*/
|
|
131
|
+
async test(inlineConfig) {
|
|
132
|
+
const timer = this.context.timer("Test");
|
|
133
|
+
this.context.info("🧪 Running tests for the project");
|
|
134
|
+
await this.execute("test", inlineConfig);
|
|
135
|
+
this.context.debug("✔ Testing completed successfully");
|
|
136
|
+
timer();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Build the project
|
|
140
|
+
*
|
|
141
|
+
* @remarks
|
|
142
|
+
* This method will build the Powerlines project, generating the necessary artifacts.
|
|
143
|
+
*
|
|
144
|
+
* @param inlineConfig - The inline configuration for the build command
|
|
145
|
+
* @returns A promise that resolves when the build command has completed
|
|
146
|
+
*/
|
|
147
|
+
async build(inlineConfig) {
|
|
148
|
+
const timer = this.context.timer("Build");
|
|
149
|
+
this.context.info("📦 Building the project");
|
|
150
|
+
await this.execute("build", inlineConfig);
|
|
151
|
+
this.context.debug("✔ Build completed successfully");
|
|
152
|
+
timer();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Prepare the documentation for the project
|
|
156
|
+
*
|
|
157
|
+
* @param inlineConfig - The inline configuration for the docs command
|
|
158
|
+
* @returns A promise that resolves when the documentation generation has completed
|
|
159
|
+
*/
|
|
160
|
+
async docs(inlineConfig) {
|
|
161
|
+
const timer = this.context.timer("Docs");
|
|
162
|
+
this.context.info("📓 Generating documentation for the project");
|
|
163
|
+
await this.execute("docs", inlineConfig);
|
|
164
|
+
this.context.debug("✔ Documentation generation completed successfully");
|
|
165
|
+
timer();
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Deploy the project source code
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.
|
|
172
|
+
*
|
|
173
|
+
* @param inlineConfig - The inline configuration for the deploy command
|
|
174
|
+
* @returns A promise that resolves when the deploy command has completed
|
|
175
|
+
*/
|
|
176
|
+
async deploy(inlineConfig) {
|
|
177
|
+
const timer = this.context.timer("Deploy");
|
|
178
|
+
this.context.info("🚀 Deploying the project");
|
|
179
|
+
await this.execute("deploy", inlineConfig);
|
|
180
|
+
this.context.debug("✔ Deployment completed successfully");
|
|
181
|
+
timer();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Finalization/cleanup processing for the Powerlines API
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.
|
|
188
|
+
*
|
|
189
|
+
* @returns A promise that resolves when the finalization process has completed
|
|
190
|
+
*/
|
|
191
|
+
async finalize() {
|
|
192
|
+
const timer = this.context.timer("Finalize");
|
|
193
|
+
this.context.info("🏁 Finalization processes started");
|
|
194
|
+
await this.api.finalize();
|
|
195
|
+
this.context.debug("✔ Finalization completed successfully");
|
|
196
|
+
timer();
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.
|
|
200
|
+
*/
|
|
201
|
+
async [Symbol.asyncDispose]() {
|
|
202
|
+
return this.finalize();
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.
|
|
206
|
+
*
|
|
207
|
+
* @remarks
|
|
208
|
+
* 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.
|
|
209
|
+
*
|
|
210
|
+
* @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.
|
|
211
|
+
* @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.
|
|
212
|
+
* @returns A promise that resolves when all executions for the specified command have completed
|
|
213
|
+
*/
|
|
214
|
+
async execute(command, inlineConfig) {
|
|
215
|
+
await Promise.all((await this.context.loadExecutions(command, inlineConfig)).map(async (execution) => {
|
|
216
|
+
try {
|
|
217
|
+
await this.api.execute(command, execution.options, inlineConfig);
|
|
218
|
+
} catch (error) {
|
|
219
|
+
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)}`);
|
|
220
|
+
throw error;
|
|
221
|
+
} finally {
|
|
222
|
+
this.context.completeExecution(execution.invocationId, execution.options.executionId);
|
|
223
|
+
}
|
|
224
|
+
}));
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
async function createContext(options) {
|
|
228
|
+
const port = options.port ?? await getPort({
|
|
229
|
+
host: options.host || "localhost",
|
|
230
|
+
random: true
|
|
231
|
+
});
|
|
232
|
+
const app = createApp();
|
|
233
|
+
const host = createH3DevToolsHost({
|
|
234
|
+
appName: options.framework?.name || "powerlines",
|
|
235
|
+
origin: `http://${options.host || "localhost"}:${port}`,
|
|
236
|
+
mount: (base, dir) => {
|
|
237
|
+
app.use(base, fromNodeMiddleware(sirv(dir, {
|
|
238
|
+
dev: true,
|
|
239
|
+
single: true
|
|
240
|
+
})));
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return PowerlinesEngineContext.from(options, host, {
|
|
244
|
+
backend: "websocket",
|
|
245
|
+
websocket: port
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
async function createEngine(options, apiPath = "@powerlines/engine/api") {
|
|
249
|
+
EventEmitter.setMaxListeners(Infinity);
|
|
250
|
+
const context = await createContext(options);
|
|
251
|
+
return new PowerlinesEngine(context, await ExecutionApiWorker.from(apiPath, {
|
|
252
|
+
root: options.root,
|
|
253
|
+
context
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
//#endregion
|
|
258
|
+
export { PowerlinesEngine, createContext, createEngine };
|
|
259
|
+
//# sourceMappingURL=engine.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.mjs","names":["#context","#api"],"sources":["../src/engine.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type {\n BuildInlineConfig,\n CleanInlineConfig,\n CreateInlineConfig,\n DeployInlineConfig,\n DocsInlineConfig,\n InlineConfig,\n LintInlineConfig,\n PrepareInlineConfig,\n TestInlineConfig,\n TypesInlineConfig\n} from \"@powerlines/core\";\nimport { createH3DevToolsHost } from \"devframe/node\";\nimport { getPort } from \"get-port-please\";\nimport { createApp, fromNodeMiddleware } from \"h3\";\nimport { EventEmitter } from \"node:events\";\nimport sirv from \"sirv\";\nimport { ExecutionApiWorker } from \"./_internal/execution-api-worker\";\nimport { PowerlinesEngineContext } from \"./context/engine-context\";\nimport { Engine } from \"./types/api\";\nimport { EngineOptions } from \"./types/config\";\nimport { EngineContext } from \"./types/context\";\n\n/**\n * The Powerlines process' orchestration and coordination API.\n *\n * @public\n */\nexport class PowerlinesEngine implements Engine, AsyncDisposable {\n /**\n * The Powerlines context\n */\n #context: EngineContext;\n\n /**\n * 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.\n */\n #api: ExecutionApiWorker;\n\n /**\n * The Powerlines context\n */\n public get context(): EngineContext {\n return this.#context;\n }\n\n /**\n * 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.\n */\n public get api(): ExecutionApiWorker {\n return this.#api;\n }\n\n /**\n * Create a new Powerlines Engine instance\n *\n * @param context - The Powerlines context\n * @param api - The API host for the execution workers\n * @returns A new instance of the Powerlines Engine\n */\n public constructor(context: EngineContext, api: ExecutionApiWorker) {\n this.#context = context;\n this.#api = api;\n }\n\n /**\n * Create a new Powerlines project\n *\n * @remarks\n * This method will create a new Powerlines project in the current directory.\n *\n * @param inlineConfig - The inline configuration for the create command\n * @returns A promise that resolves when the project has been created\n */\n public async create(inlineConfig: CreateInlineConfig) {\n const timer = this.context.timer(\"Create\");\n this.context.info(\"🆕 Creating a new project\");\n\n await this.execute(\"create\", inlineConfig);\n\n this.context.debug(\"✔ Create command completed successfully\");\n timer();\n }\n\n /**\n * Generate the Powerlines typescript declaration file\n *\n * @remarks\n * 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.\n *\n * @param inlineConfig - The inline configuration for the types command\n */\n public async types(inlineConfig: TypesInlineConfig) {\n const timer = this.context.timer(\"Types\");\n this.context.info(\"🏗️ Generating typescript declarations for the project\");\n\n await this.execute(\"types\", inlineConfig);\n\n this.context.debug(\"✔ Types generation has completed successfully\");\n timer();\n }\n\n /**\n * Prepare the Powerlines API\n *\n * @remarks\n * This method will prepare the Powerlines API for use, initializing any necessary resources.\n *\n * @param inlineConfig - The inline configuration for the prepare command\n */\n public async prepare(inlineConfig: PrepareInlineConfig) {\n const timer = this.context.timer(\"Prepare\");\n this.context.info(\"🏗️ Preparing the project\");\n\n await this.execute(\"prepare\", inlineConfig);\n\n this.context.debug(\"✔ Preparation has completed successfully\");\n timer();\n }\n\n /**\n * Clean any previously prepared artifacts\n *\n * @remarks\n * This method will remove the previous Powerlines artifacts from the project.\n *\n * @param inlineConfig - The inline configuration for the clean command\n * @returns A promise that resolves when the clean command has completed\n */\n public async clean(inlineConfig: CleanInlineConfig) {\n const timer = this.context.timer(\"Clean\");\n this.context.info(\"🧹 Cleaning the previous artifacts\");\n\n await this.execute(\"clean\", inlineConfig);\n\n this.context.debug(\"✔ Cleaning completed successfully\");\n timer();\n }\n\n /**\n * Lint the project\n *\n * @param inlineConfig - The inline configuration for the lint command\n * @returns A promise that resolves when the lint command has completed\n */\n public async lint(inlineConfig: LintInlineConfig) {\n const timer = this.context.timer(\"Lint\");\n this.context.info(\"📝 Linting the project\");\n\n await this.execute(\"lint\", inlineConfig);\n\n this.context.debug(\"✔ Linting completed successfully\");\n timer();\n }\n\n /**\n * Test the project\n *\n * @remarks\n * This method will run the tests for the Powerlines project.\n *\n * @param inlineConfig - The inline configuration for the test command\n * @returns A promise that resolves when the test command has completed\n */\n public async test(inlineConfig: TestInlineConfig) {\n const timer = this.context.timer(\"Test\");\n this.context.info(\"🧪 Running tests for the project\");\n\n await this.execute(\"test\", inlineConfig);\n\n this.context.debug(\"✔ Testing completed successfully\");\n timer();\n }\n\n /**\n * Build the project\n *\n * @remarks\n * This method will build the Powerlines project, generating the necessary artifacts.\n *\n * @param inlineConfig - The inline configuration for the build command\n * @returns A promise that resolves when the build command has completed\n */\n public async build(inlineConfig: BuildInlineConfig) {\n const timer = this.context.timer(\"Build\");\n this.context.info(\"📦 Building the project\");\n\n await this.execute(\"build\", inlineConfig);\n\n this.context.debug(\"✔ Build completed successfully\");\n timer();\n }\n\n /**\n * Prepare the documentation for the project\n *\n * @param inlineConfig - The inline configuration for the docs command\n * @returns A promise that resolves when the documentation generation has completed\n */\n public async docs(inlineConfig: DocsInlineConfig) {\n const timer = this.context.timer(\"Docs\");\n this.context.info(\"📓 Generating documentation for the project\");\n\n await this.execute(\"docs\", inlineConfig);\n\n this.context.debug(\"✔ Documentation generation completed successfully\");\n timer();\n }\n\n /**\n * Deploy the project source code\n *\n * @remarks\n * This method will prepare and build the Powerlines project, generating the necessary artifacts for the deployment.\n *\n * @param inlineConfig - The inline configuration for the deploy command\n * @returns A promise that resolves when the deploy command has completed\n */\n public async deploy(inlineConfig: DeployInlineConfig) {\n const timer = this.context.timer(\"Deploy\");\n this.context.info(\"🚀 Deploying the project\");\n\n await this.execute(\"deploy\", inlineConfig);\n\n this.context.debug(\"✔ Deployment completed successfully\");\n timer();\n }\n\n /**\n * Finalization/cleanup processing for the Powerlines API\n *\n * @remarks\n * This step includes any final processes or clean up required by Powerlines. It will be run after each Powerlines command.\n *\n * @returns A promise that resolves when the finalization process has completed\n */\n public async finalize() {\n const timer = this.context.timer(\"Finalize\");\n this.context.info(\"🏁 Finalization processes started\");\n\n await this.api.finalize();\n\n this.context.debug(\"✔ Finalization completed successfully\");\n timer();\n }\n\n /**\n * Asynchronous disposal method for the Powerlines Engine, which will call the finalize method to perform any necessary cleanup when the engine is disposed of.\n */\n public async [Symbol.asyncDispose]() {\n return this.finalize();\n }\n\n /**\n * Execute a Powerlines command based on the provided execution path and inline configuration, loading the necessary executions from the context and managing their lifecycle.\n *\n * @remarks\n * 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.\n *\n * @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.\n * @param inlineConfig - Additional configuration options provided at runtime, which can override or supplement the options defined in the user configuration file.\n * @returns A promise that resolves when all executions for the specified command have completed\n */\n protected async execute(command: string, inlineConfig: InlineConfig) {\n await Promise.all(\n (await this.context.loadExecutions(command, inlineConfig)).map(\n async execution => {\n try {\n await this.api.execute(command, execution.options, inlineConfig);\n } catch (error) {\n this.context.error(\n `Execution of method \"${command}\" failed for execution with invocation ID \"${\n execution.invocationId\n }\" and execution ID \"${execution.options.executionId}\": \\n\\n${\n error instanceof Error\n ? error.stack || error.message\n : String(error)\n }`\n );\n\n throw error;\n } finally {\n this.context.completeExecution(\n execution.invocationId,\n execution.options.executionId!\n );\n }\n }\n )\n );\n }\n}\n\nexport async function createContext(options: EngineOptions) {\n const port =\n options.port ??\n (await getPort({\n host: options.host || \"localhost\",\n random: true\n }));\n\n const app = createApp();\n const host = createH3DevToolsHost({\n appName: options.framework?.name || \"powerlines\",\n origin: `http://${options.host || \"localhost\"}:${port}`,\n mount: (base, dir) => {\n app.use(base, fromNodeMiddleware(sirv(dir, { dev: true, single: true })));\n }\n });\n\n return PowerlinesEngineContext.from(options, host, {\n backend: \"websocket\",\n websocket: port\n });\n}\n\nexport async function createEngine(\n options: EngineOptions,\n apiPath = \"@powerlines/engine/api\"\n) {\n EventEmitter.setMaxListeners(Infinity);\n\n const context = await createContext(options);\n const host = await ExecutionApiWorker.from(apiPath, {\n root: options.root,\n context\n });\n\n return new PowerlinesEngine(context, host);\n}\n"],"mappings":"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"}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EngineResolvedConfig } from "../types/config.cjs";
|
|
2
|
+
import { EngineSystemContext } from "../types/context.cjs";
|
|
3
|
+
import { ExecutionApiParams } from "../types/api.cjs";
|
|
4
|
+
import { ExecutionContext, ExecutionOptions, InlineConfig } from "@powerlines/core";
|
|
5
|
+
import { DeepPartial, MaybePromise } from "@stryke/types/base";
|
|
6
|
+
|
|
7
|
+
//#region src/helpers/create-api.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Creates an execution API with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
|
|
10
|
+
*
|
|
11
|
+
* @param handlers - An object where keys are command names and values are functions that take an execution context and return a promise.
|
|
12
|
+
* @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each command.
|
|
13
|
+
* @returns A function that can be used as an execution API handler, which takes execution parameters and invokes the appropriate command handler with a properly constructed execution context.
|
|
14
|
+
*/
|
|
15
|
+
declare function createApi<TContext extends ExecutionContext<EngineResolvedConfig, EngineSystemContext> = ExecutionContext<EngineResolvedConfig, EngineSystemContext>, TOptions extends ExecutionOptions = ExecutionOptions, THandlers extends Record<string, (context: TContext) => Promise<void>> = Record<string, (context: TContext) => Promise<void>>>(handlers: THandlers, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): (params: ExecutionApiParams<TOptions, keyof THandlers & string>) => Promise<void>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createApi };
|
|
18
|
+
//# sourceMappingURL=create-api.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-api.d.cts","names":[],"sources":["../../src/helpers/create-api.ts"],"mappings":";;;;;;;;;AAoDA;;;;;iBAAgB,SAAA,kBACG,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,IACtD,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,oBACxB,gBAAA,GAAmB,gBAAA,oBAClB,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,UACtD,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAExC,QAAA,EAAU,SAAA,EACV,YAAA,GACI,WAAA,CAAY,YAAA,MACV,IAAA,EAAM,YAAA,KAAiB,YAAA,CAAa,YAAA,MAE1C,MAAA,EAAQ,kBAAA,CAAmB,QAAA,QAAgB,SAAA,eACxC,OAAA"}
|
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { EngineResolvedConfig } from "../types/config.mjs";
|
|
2
|
+
import { EngineSystemContext } from "../types/context.mjs";
|
|
3
|
+
import { ExecutionApiParams } from "../types/api.mjs";
|
|
4
|
+
import { ExecutionContext, ExecutionOptions, InlineConfig } from "@powerlines/core";
|
|
5
|
+
import { DeepPartial, MaybePromise } from "@stryke/types/base";
|
|
6
|
+
|
|
7
|
+
//#region src/helpers/create-api.d.ts
|
|
8
|
+
/**
|
|
9
|
+
* Creates an execution API with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.
|
|
10
|
+
*
|
|
11
|
+
* @param handlers - An object where keys are command names and values are functions that take an execution context and return a promise.
|
|
12
|
+
* @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each command.
|
|
13
|
+
* @returns A function that can be used as an execution API handler, which takes execution parameters and invokes the appropriate command handler with a properly constructed execution context.
|
|
14
|
+
*/
|
|
15
|
+
declare function createApi<TContext extends ExecutionContext<EngineResolvedConfig, EngineSystemContext> = ExecutionContext<EngineResolvedConfig, EngineSystemContext>, TOptions extends ExecutionOptions = ExecutionOptions, THandlers extends Record<string, (context: TContext) => Promise<void>> = Record<string, (context: TContext) => Promise<void>>>(handlers: THandlers, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): (params: ExecutionApiParams<TOptions, keyof THandlers & string>) => Promise<void>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { createApi };
|
|
18
|
+
//# sourceMappingURL=create-api.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-api.d.mts","names":[],"sources":["../../src/helpers/create-api.ts"],"mappings":";;;;;;;;;AAoDA;;;;;iBAAgB,SAAA,kBACG,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,IACtD,gBAAA,CAAiB,oBAAA,EAAsB,mBAAA,oBACxB,gBAAA,GAAmB,gBAAA,oBAClB,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,UACtD,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAExC,QAAA,EAAU,SAAA,EACV,YAAA,GACI,WAAA,CAAY,YAAA,MACV,IAAA,EAAM,YAAA,KAAiB,YAAA,CAAa,YAAA,MAE1C,MAAA,EAAQ,kBAAA,CAAmB,QAAA,QAAgB,SAAA,eACxC,OAAA"}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ExecutionContext, ResolvedConfig } from "@powerlines/core";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/finalize.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Finalize the execution context by disposing resources and cleaning up.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The execution context to finalize
|
|
8
|
+
*/
|
|
9
|
+
declare function finalize<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(context: ExecutionContext<TResolvedConfig>): Promise<void>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { finalize };
|
|
12
|
+
//# sourceMappingURL=finalize.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize.d.cts","names":[],"sources":["../../src/helpers/finalize.ts"],"mappings":";;;;;AA+BA;;;iBAAsB,QAAA,yBACI,cAAA,GAAiB,cAAA,EACzC,OAAA,EAAS,gBAAA,CAAiB,eAAA,IAAgB,OAAA"}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ExecutionContext, ResolvedConfig } from "@powerlines/core";
|
|
2
|
+
|
|
3
|
+
//#region src/helpers/finalize.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Finalize the execution context by disposing resources and cleaning up.
|
|
6
|
+
*
|
|
7
|
+
* @param context - The execution context to finalize
|
|
8
|
+
*/
|
|
9
|
+
declare function finalize<TResolvedConfig extends ResolvedConfig = ResolvedConfig>(context: ExecutionContext<TResolvedConfig>): Promise<void>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { finalize };
|
|
12
|
+
//# sourceMappingURL=finalize.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"finalize.d.mts","names":[],"sources":["../../src/helpers/finalize.ts"],"mappings":";;;;;AA+BA;;;iBAAsB,QAAA,yBACI,cAAA,GAAiB,cAAA,EACzC,OAAA,EAAS,gBAAA,CAAiB,eAAA,IAAgB,OAAA"}
|
package/dist/helpers/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { createApi } from "./create-api.cjs";
|
|
2
|
+
import { finalize } from "./finalize.cjs";
|
|
3
|
+
import { createRpcClient } from "./rpc.cjs";
|
|
4
|
+
import { MessagePortDuplex, MessagePortDuplexOptions, MessagePortReadable, MessagePortWritable } from "./stream.cjs";
|
|
5
|
+
import { isApiExecutionOptions, isEngineExecutionOptions } from "./type-checks.cjs";
|
|
5
6
|
export { MessagePortDuplex, MessagePortDuplexOptions, MessagePortReadable, MessagePortWritable, createApi, createRpcClient, finalize, isApiExecutionOptions, isEngineExecutionOptions };
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { createApi } from "./create-api.mjs";
|
|
2
|
+
import { finalize } from "./finalize.mjs";
|
|
3
|
+
import { createRpcClient } from "./rpc.mjs";
|
|
4
|
+
import { MessagePortDuplex, MessagePortDuplexOptions, MessagePortReadable, MessagePortWritable } from "./stream.mjs";
|
|
5
|
+
import { isApiExecutionOptions, isEngineExecutionOptions } from "./type-checks.mjs";
|
|
5
6
|
export { MessagePortDuplex, MessagePortDuplexOptions, MessagePortReadable, MessagePortWritable, createApi, createRpcClient, finalize, isApiExecutionOptions, isEngineExecutionOptions };
|
package/dist/helpers/rpc.d.cts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RpcClient } from "../types/rpc.cjs";
|
|
2
|
+
import { RpcClientOptions } from "../types/config.cjs";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/rpc.d.ts
|
|
5
|
+
declare function createRpcClient(options: RpcClientOptions): RpcClient;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createRpcClient };
|
|
8
|
+
//# sourceMappingURL=rpc.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.cts","names":[],"sources":["../../src/helpers/rpc.ts"],"mappings":";;;;iBA0LgB,eAAA,CAAgB,OAAA,EAAS,gBAAA,GAAgB,SAAA"}
|
package/dist/helpers/rpc.d.mts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { RpcClient } from "../types/rpc.mjs";
|
|
2
|
+
import { RpcClientOptions } from "../types/config.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/rpc.d.ts
|
|
5
|
+
declare function createRpcClient(options: RpcClientOptions): RpcClient;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createRpcClient };
|
|
8
|
+
//# sourceMappingURL=rpc.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.mts","names":[],"sources":["../../src/helpers/rpc.ts"],"mappings":";;;;iBA0LgB,eAAA,CAAgB,OAAA,EAAS,gBAAA,GAAgB,SAAA"}
|
|
@@ -1,2 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Duplex, DuplexOptions, Readable, ReadableOptions, Writable, WritableOptions } from "node:stream";
|
|
2
|
+
import { MessagePort } from "node:worker_threads";
|
|
3
|
+
|
|
4
|
+
//#region src/helpers/stream.d.ts
|
|
5
|
+
declare const kPort: unique symbol;
|
|
6
|
+
interface WritevChunk {
|
|
7
|
+
chunk: unknown;
|
|
8
|
+
encoding: BufferEncoding;
|
|
9
|
+
}
|
|
10
|
+
declare class MessagePortWritable extends Writable {
|
|
11
|
+
private [kPort];
|
|
12
|
+
constructor(port: MessagePort, options?: WritableOptions);
|
|
13
|
+
_write(chunk: unknown, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
14
|
+
_writev(data: WritevChunk[], callback: (error?: Error | null) => void): void;
|
|
15
|
+
_final(callback: (error?: Error | null) => void): void;
|
|
16
|
+
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
17
|
+
unref(): this;
|
|
18
|
+
ref(): this;
|
|
19
|
+
}
|
|
20
|
+
declare class MessagePortReadable extends Readable {
|
|
21
|
+
private [kPort];
|
|
22
|
+
constructor(port: MessagePort, options?: ReadableOptions);
|
|
23
|
+
_read(_size: number): void;
|
|
24
|
+
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
25
|
+
unref(): this;
|
|
26
|
+
ref(): this;
|
|
27
|
+
}
|
|
28
|
+
interface MessagePortDuplexOptions extends DuplexOptions {
|
|
29
|
+
onActivityAbort?: () => void;
|
|
30
|
+
}
|
|
31
|
+
declare class MessagePortDuplex extends Duplex {
|
|
32
|
+
private [kPort];
|
|
33
|
+
private _activityAbortHandler?;
|
|
34
|
+
constructor(port: MessagePort, options?: MessagePortDuplexOptions);
|
|
35
|
+
_read(_size: number): void;
|
|
36
|
+
_write(chunk: unknown, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
37
|
+
_writev(data: WritevChunk[], callback: (error?: Error | null) => void): void;
|
|
38
|
+
_final(callback: (error?: Error | null) => void): void;
|
|
39
|
+
_destroy(error: Error | null, callback: (error?: Error | null) => void): void;
|
|
40
|
+
unref(): this;
|
|
41
|
+
ref(): this;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { MessagePortDuplex, MessagePortDuplexOptions, MessagePortReadable, MessagePortWritable };
|
|
45
|
+
//# sourceMappingURL=stream.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.d.cts","names":[],"sources":["../../src/helpers/stream.ts"],"mappings":";;;;cA0BM,KAAA;AAAA,UAMI,WAAA;EACR,KAAA;EACA,QAAA,EAAU,cAAc;AAAA;AAAA,cAeb,mBAAA,SAA4B,QAAA;EAAA,SAC9B,KAAA;cAEU,IAAA,EAAM,WAAA,EAAa,OAAA,GAAU,eAAA;EAKhC,MAAA,CACd,KAAA,WACA,SAAA,EAAW,cAAA,EACX,QAAA,GAAW,KAAA,GAAQ,KAAA;EAOL,OAAA,CACd,IAAA,EAAM,WAAA,IACN,QAAA,GAAW,KAAA,GAAQ,KAAA;EAWL,MAAA,CAAO,QAAA,GAAW,KAAA,GAAQ,KAAA;EAK1B,QAAA,CACd,KAAA,EAAO,KAAA,SACP,QAAA,GAAW,KAAA,GAAQ,KAAA;EAKd,KAAA;EAKA,GAAA;AAAA;AAAA,cAMI,mBAAA,SAA4B,QAAA;EAAA,SAC9B,KAAA;cAEU,IAAA,EAAM,WAAA,EAAa,OAAA,GAAU,eAAA;EAQhC,KAAA,CAAM,KAAA;EAIN,QAAA,CACd,KAAA,EAAO,KAAA,SACP,QAAA,GAAW,KAAA,GAAQ,KAAA;EAQd,KAAA;EAKA,GAAA;AAAA;AAAA,UAMQ,wBAAA,SAAiC,aAAa;EAC7D,eAAe;AAAA;AAAA,cAGJ,iBAAA,SAA0B,MAAA;EAAA,SAC5B,KAAA;EAAA,QAED,qBAAA;cAEW,IAAA,EAAM,WAAA,EAAa,OAAA,GAAU,wBAAA;EAUhC,KAAA,CAAM,KAAA;EAIN,MAAA,CACd,KAAA,WACA,SAAA,EAAW,cAAA,EACX,QAAA,GAAW,KAAA,GAAQ,KAAA;EAUL,OAAA,CACd,IAAA,EAAM,WAAA,IACN,QAAA,GAAW,KAAA,GAAQ,KAAA;EAWL,MAAA,CAAO,QAAA,GAAW,KAAA,GAAQ,KAAA;EAK1B,QAAA,CACd,KAAA,EAAO,KAAA,SACP,QAAA,GAAW,KAAA,GAAQ,KAAA;EAQd,KAAA;EAKA,GAAA;AAAA"}
|