@powerlines/engine 0.9.5 → 0.10.0

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.
@@ -7,6 +7,7 @@ let _stryke_type_checks_is_set_object = require("@stryke/type-checks/is-set-obje
7
7
  let _powerlines_core_context_execution_context = require("@powerlines/core/context/execution-context");
8
8
  let _powerlines_core_lib_context_helpers = require("@powerlines/core/lib/context-helpers");
9
9
  let _stryke_string_format_title_case = require("@stryke/string-format/title-case");
10
+ let _stryke_type_checks_is_function = require("@stryke/type-checks/is-function");
10
11
  let defu = require("defu");
11
12
 
12
13
  //#region src/helpers/create-execution-host.ts
@@ -39,7 +40,7 @@ function createExecutionHost(methods, inlineConfig = {}) {
39
40
  const context = await _powerlines_core_context_execution_context.PowerlinesExecutionContext.from({
40
41
  ...options,
41
42
  logFn
42
- }, (0, defu.defu)(inlineConfig, params.inlineConfig ?? {}), { rpc });
43
+ }, (0, _stryke_type_checks_is_function.isFunction)(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : (0, defu.defu)(inlineConfig, params.inlineConfig ?? {}), { rpc });
43
44
  context.logger.info(`Starting ${(0, _stryke_string_format_title_case.titleCase)(options.framework?.name) || "Powerlines"} - ${(0, _stryke_string_format_title_case.titleCase)(method)} execution (${options.executionId})`);
44
45
  await (0, _powerlines_core_lib_context_helpers.resolvePluginConfig)(context);
45
46
  await fn(context);
@@ -2,7 +2,7 @@ import { r as EngineResolvedConfig } from "../config-D6xUniHh.cjs";
2
2
  import { r as EngineSystemContext } from "../context-epL7NPvL.cjs";
3
3
  import { r as ExecutionHostParams } from "../api-6w4hZL6n.cjs";
4
4
  import { InlineConfig } from "@powerlines/core";
5
- import { DeepPartial } from "@stryke/types/base";
5
+ import { DeepPartial, MaybePromise } from "@stryke/types/base";
6
6
  import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
7
7
 
8
8
  //#region src/helpers/create-execution-host.d.ts
@@ -13,7 +13,7 @@ import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-c
13
13
  * @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each method.
14
14
  * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
15
15
  */
16
- declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig>): {
16
+ declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): {
17
17
  [k: string]: (params: ExecutionHostParams) => Promise<void>;
18
18
  };
19
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"create-execution-host.d.cts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;;AAwCA;;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CAErD,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAC/C,YAAA,GAAc,WAAA,CAAY,YAAA;EAAA,sBAKP,mBAAA,KAAmB,OAAA;AAAA"}
1
+ {"version":3,"file":"create-execution-host.d.cts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;;AAyCA;;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CAErD,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAC/C,YAAA,GACI,WAAA,CAAY,YAAA,MACV,IAAA,EAAM,YAAA,KAAiB,YAAA,CAAa,YAAA;EAAA,sBAKvB,mBAAA,KAAmB,OAAA;AAAA"}
@@ -3,7 +3,7 @@ import { r as EngineSystemContext } from "../context-DzgsMSWr.mjs";
3
3
  import { r as ExecutionHostParams } from "../api-Cdw4v0W4.mjs";
4
4
  import { InlineConfig } from "@powerlines/core";
5
5
  import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
6
- import { DeepPartial } from "@stryke/types/base";
6
+ import { DeepPartial, MaybePromise } from "@stryke/types/base";
7
7
 
8
8
  //#region src/helpers/create-execution-host.d.ts
9
9
  /**
@@ -13,7 +13,7 @@ import { DeepPartial } from "@stryke/types/base";
13
13
  * @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each method.
14
14
  * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.
15
15
  */
16
- declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig>): {
16
+ declare function createExecutionHost<TContext extends PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext> = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>>(methods: Record<string, (context: TContext) => Promise<void>>, inlineConfig?: DeepPartial<InlineConfig> | ((prev: InlineConfig) => MaybePromise<InlineConfig>)): {
17
17
  [k: string]: (params: ExecutionHostParams) => Promise<void>;
18
18
  };
19
19
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"create-execution-host.d.mts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;;AAwCA;;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CAErD,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAC/C,YAAA,GAAc,WAAA,CAAY,YAAA;EAAA,sBAKP,mBAAA,KAAmB,OAAA;AAAA"}
1
+ {"version":3,"file":"create-execution-host.d.mts","names":[],"sources":["../../src/helpers/create-execution-host.ts"],"mappings":";;;;;;;;;;AAyCA;;;;;iBAAgB,mBAAA,kBACG,0BAAA,CACf,oBAAA,EACA,mBAAA,IACE,0BAAA,CAA2B,oBAAA,EAAsB,mBAAA,EAAA,CAErD,OAAA,EAAS,MAAA,UAAgB,OAAA,EAAS,QAAA,KAAa,OAAA,SAC/C,YAAA,GACI,WAAA,CAAY,YAAA,MACV,IAAA,EAAM,YAAA,KAAiB,YAAA,CAAa,YAAA;EAAA,sBAKvB,mBAAA,KAAmB,OAAA;AAAA"}
@@ -5,6 +5,7 @@ import { isSetObject } from "@stryke/type-checks/is-set-object";
5
5
  import { PowerlinesExecutionContext } from "@powerlines/core/context/execution-context";
6
6
  import { resolvePluginConfig } from "@powerlines/core/lib/context-helpers";
7
7
  import { titleCase } from "@stryke/string-format/title-case";
8
+ import { isFunction } from "@stryke/type-checks/is-function";
8
9
  import { defu } from "defu";
9
10
 
10
11
  //#region src/helpers/create-execution-host.ts
@@ -37,7 +38,7 @@ function createExecutionHost(methods, inlineConfig = {}) {
37
38
  const context = await PowerlinesExecutionContext.from({
38
39
  ...options,
39
40
  logFn
40
- }, defu(inlineConfig, params.inlineConfig ?? {}), { rpc });
41
+ }, isFunction(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : defu(inlineConfig, params.inlineConfig ?? {}), { rpc });
41
42
  context.logger.info(`Starting ${titleCase(options.framework?.name) || "Powerlines"} - ${titleCase(method)} execution (${options.executionId})`);
42
43
  await resolvePluginConfig(context);
43
44
  await fn(context);
@@ -1 +1 @@
1
- {"version":3,"file":"create-execution-host.mjs","names":[],"sources":["../../src/helpers/create-execution-host.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 { InlineConfig, LogFnMeta } from \"@powerlines/core\";\nimport { PowerlinesExecutionContext } from \"@powerlines/core/context/execution-context\";\nimport { resolvePluginConfig } from \"@powerlines/core/lib/context-helpers\";\nimport { consoleLogger } from \"@powerlines/core/plugin-utils\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { DeepPartial } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { defu } from \"defu\";\nimport { RpcClient } from \"../types\";\nimport { ExecutionHostParams } from \"../types/api\";\nimport { EngineResolvedConfig } from \"../types/config\";\nimport { EngineSystemContext } from \"../types/context\";\nimport { createRpcClient } from \"./rpc\";\n\n/**\n * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.\n *\n * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.\n * @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each method.\n * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.\n */\nexport function createExecutionHost<\n TContext extends PowerlinesExecutionContext<\n EngineResolvedConfig,\n EngineSystemContext\n > = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>\n>(\n methods: Record<string, (context: TContext) => Promise<void>>,\n inlineConfig: DeepPartial<InlineConfig> = {}\n) {\n return Object.fromEntries(\n Object.entries(methods).map(([method, fn]) => [\n method,\n async (params: ExecutionHostParams) => {\n const { options } = params;\n\n let rpc!: RpcClient;\n if (options.baseURL && options.connection) {\n rpc = createRpcClient(options);\n } else {\n throw new Error(\n `Execution RPC client could not be created - Missing ${\n !options.baseURL\n ? `baseURL${options.connection ? ` and connection information` : \"\"}`\n : \"connection\"\n } or connection information.`\n );\n }\n\n const logFn = (meta: LogFnMeta, message: string) => {\n consoleLogger(meta, message);\n if (rpc) {\n void rpc.callEvent(\"powerlines:log\", {\n meta: {\n category: \"general\",\n ...options,\n ...(isSetObject(meta) ? meta : { type: meta }),\n logId: uuid(),\n timestamp: Date.now()\n },\n message\n });\n }\n };\n\n const context = (await PowerlinesExecutionContext.from<\n EngineResolvedConfig,\n EngineSystemContext\n >(\n { ...options, logFn },\n defu(inlineConfig, params.inlineConfig ?? {}) as InlineConfig,\n {\n rpc\n }\n )) as TContext;\n\n context.logger.info(\n `Starting ${\n titleCase(options.framework?.name) || \"Powerlines\"\n } - ${titleCase(method)} execution (${options.executionId})`\n );\n\n await resolvePluginConfig(context as PowerlinesExecutionContext<any>);\n\n await fn(context);\n }\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAwCA,SAAgB,oBAMd,SACA,eAA0C,EAAE,EAC5C;AACA,QAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAC5C,QACA,OAAO,WAAgC;EACrC,MAAM,EAAE,YAAY;EAEpB,IAAI;AACJ,MAAI,QAAQ,WAAW,QAAQ,WAC7B,OAAM,gBAAgB,QAAQ;MAE9B,OAAM,IAAI,MACR,uDACE,CAAC,QAAQ,UACL,UAAU,QAAQ,aAAa,gCAAgC,OAC/D,aACL,6BACF;EAGH,MAAM,SAAS,MAAiB,YAAoB;AAClD,iBAAc,MAAM,QAAQ;AAC5B,OAAI,IACF,CAAK,IAAI,UAAU,kBAAkB;IACnC,MAAM;KACJ,UAAU;KACV,GAAG;KACH,GAAI,YAAY,KAAK,GAAG,OAAO,EAAE,MAAM,MAAM;KAC7C,OAAO,MAAM;KACb,WAAW,KAAK,KAAK;KACtB;IACD;IACD,CAAC;;EAIN,MAAM,UAAW,MAAM,2BAA2B,KAIhD;GAAE,GAAG;GAAS;GAAO,EACrB,KAAK,cAAc,OAAO,gBAAgB,EAAE,CAAC,EAC7C,EACE,KACD,CACF;AAED,UAAQ,OAAO,KACb,YACE,UAAU,QAAQ,WAAW,KAAK,IAAI,aACvC,KAAK,UAAU,OAAO,CAAC,cAAc,QAAQ,YAAY,GAC3D;AAED,QAAM,oBAAoB,QAA2C;AAErE,QAAM,GAAG,QAAQ;GAEpB,CAAC,CACH"}
1
+ {"version":3,"file":"create-execution-host.mjs","names":[],"sources":["../../src/helpers/create-execution-host.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 { InlineConfig, LogFnMeta } from \"@powerlines/core\";\nimport { PowerlinesExecutionContext } from \"@powerlines/core/context/execution-context\";\nimport { resolvePluginConfig } from \"@powerlines/core/lib/context-helpers\";\nimport { consoleLogger } from \"@powerlines/core/plugin-utils\";\nimport { titleCase } from \"@stryke/string-format/title-case\";\nimport { isFunction } from \"@stryke/type-checks/is-function\";\nimport { isSetObject } from \"@stryke/type-checks/is-set-object\";\nimport { DeepPartial, MaybePromise } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { defu } from \"defu\";\nimport { RpcClient } from \"../types\";\nimport { ExecutionHostParams } from \"../types/api\";\nimport { EngineResolvedConfig } from \"../types/config\";\nimport { EngineSystemContext } from \"../types/context\";\nimport { createRpcClient } from \"./rpc\";\n\n/**\n * Creates an execution host with the provided methods. Each method will be wrapped to create an execution context and handle errors appropriately.\n *\n * @param methods - An object where keys are method names and values are functions that take an execution context and return a promise.\n * @param inlineConfig - An optional partial inline configuration object that will be merged with the context's options when creating the execution context for each method.\n * @returns An object with the same keys as the input methods, but each function is wrapped to create an execution context and handle errors.\n */\nexport function createExecutionHost<\n TContext extends PowerlinesExecutionContext<\n EngineResolvedConfig,\n EngineSystemContext\n > = PowerlinesExecutionContext<EngineResolvedConfig, EngineSystemContext>\n>(\n methods: Record<string, (context: TContext) => Promise<void>>,\n inlineConfig:\n | DeepPartial<InlineConfig>\n | ((prev: InlineConfig) => MaybePromise<InlineConfig>) = {}\n) {\n return Object.fromEntries(\n Object.entries(methods).map(([method, fn]) => [\n method,\n async (params: ExecutionHostParams) => {\n const { options } = params;\n\n let rpc!: RpcClient;\n if (options.baseURL && options.connection) {\n rpc = createRpcClient(options);\n } else {\n throw new Error(\n `Execution RPC client could not be created - Missing ${\n !options.baseURL\n ? `baseURL${options.connection ? ` and connection information` : \"\"}`\n : \"connection\"\n } or connection information.`\n );\n }\n\n const logFn = (meta: LogFnMeta, message: string) => {\n consoleLogger(meta, message);\n if (rpc) {\n void rpc.callEvent(\"powerlines:log\", {\n meta: {\n category: \"general\",\n ...options,\n ...(isSetObject(meta) ? meta : { type: meta }),\n logId: uuid(),\n timestamp: Date.now()\n },\n message\n });\n }\n };\n\n const context = (await PowerlinesExecutionContext.from<\n EngineResolvedConfig,\n EngineSystemContext\n >(\n { ...options, logFn },\n isFunction(inlineConfig)\n ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {}))\n : (defu(inlineConfig, params.inlineConfig ?? {}) as InlineConfig),\n {\n rpc\n }\n )) as TContext;\n\n context.logger.info(\n `Starting ${\n titleCase(options.framework?.name) || \"Powerlines\"\n } - ${titleCase(method)} execution (${options.executionId})`\n );\n\n await resolvePluginConfig(context as PowerlinesExecutionContext<any>);\n\n await fn(context);\n }\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyCA,SAAgB,oBAMd,SACA,eAE2D,EAAE,EAC7D;AACA,QAAO,OAAO,YACZ,OAAO,QAAQ,QAAQ,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAC5C,QACA,OAAO,WAAgC;EACrC,MAAM,EAAE,YAAY;EAEpB,IAAI;AACJ,MAAI,QAAQ,WAAW,QAAQ,WAC7B,OAAM,gBAAgB,QAAQ;MAE9B,OAAM,IAAI,MACR,uDACE,CAAC,QAAQ,UACL,UAAU,QAAQ,aAAa,gCAAgC,OAC/D,aACL,6BACF;EAGH,MAAM,SAAS,MAAiB,YAAoB;AAClD,iBAAc,MAAM,QAAQ;AAC5B,OAAI,IACF,CAAK,IAAI,UAAU,kBAAkB;IACnC,MAAM;KACJ,UAAU;KACV,GAAG;KACH,GAAI,YAAY,KAAK,GAAG,OAAO,EAAE,MAAM,MAAM;KAC7C,OAAO,MAAM;KACb,WAAW,KAAK,KAAK;KACtB;IACD;IACD,CAAC;;EAIN,MAAM,UAAW,MAAM,2BAA2B,KAIhD;GAAE,GAAG;GAAS;GAAO,EACrB,WAAW,aAAa,GACpB,MAAM,QAAQ,QAAQ,aAAa,OAAO,gBAAgB,EAAE,CAAC,CAAC,GAC7D,KAAK,cAAc,OAAO,gBAAgB,EAAE,CAAC,EAClD,EACE,KACD,CACF;AAED,UAAQ,OAAO,KACb,YACE,UAAU,QAAQ,WAAW,KAAK,IAAI,aACvC,KAAK,UAAU,OAAO,CAAC,cAAc,QAAQ,YAAY,GAC3D;AAED,QAAM,oBAAoB,QAA2C;AAErE,QAAM,GAAG,QAAQ;GAEpB,CAAC,CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/engine",
3
- "version": "0.9.5",
3
+ "version": "0.10.0",
4
4
  "private": false,
5
5
  "description": "An internal package containing the core engine modules for Powerlines.",
6
6
  "homepage": "https://stormsoftware.com",
@@ -115,7 +115,7 @@
115
115
  "types": "./dist/index.d.cts",
116
116
  "files": ["dist"],
117
117
  "dependencies": {
118
- "@powerlines/core": "^0.9.5",
118
+ "@powerlines/core": "^0.10.0",
119
119
  "@storm-software/config": "^1.137.35",
120
120
  "@storm-software/config-tools": "^1.190.2",
121
121
  "@stryke/async": "^0.1.4",
@@ -151,5 +151,5 @@
151
151
  "@types/node": "^25.7.0",
152
152
  "typescript": "^6.0.3"
153
153
  },
154
- "gitHead": "7fbe7d8d2ab955afc2df5f04ed03a0d101af1b57"
154
+ "gitHead": "b5295d4093708060dda7987bee13eec141765a93"
155
155
  }