@powerlines/engine 0.49.1 → 0.49.3

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.
@@ -49,6 +49,7 @@ function createExecutionHost(methods, inlineConfig = {}) {
49
49
  }, (0, _stryke_type_checks_is_function.isFunction)(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : (0, defu.defu)(inlineConfig, params.inlineConfig ?? {}), { rpc });
50
50
  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})`);
51
51
  await (0, _powerlines_core_lib_context_helpers.resolvePluginConfig)(context);
52
+ if (!context.config.input) throw new Error(`No input defined in configuration for ${method} execution. Please ensure that the configuration file defines an input for this execution, or provide an inline configuration with the necessary input.`);
52
53
  await fn(context);
53
54
  }]));
54
55
  }
@@ -48,6 +48,7 @@ function createExecutionHost(methods, inlineConfig = {}) {
48
48
  }, isFunction(inlineConfig) ? await Promise.resolve(inlineConfig(params.inlineConfig ?? {})) : defu(inlineConfig, params.inlineConfig ?? {}), { rpc });
49
49
  context.logger.info(`Starting ${titleCase(options.framework?.name) || "Powerlines"} - ${titleCase(method)} execution (${options.executionId})`);
50
50
  await resolvePluginConfig(context);
51
+ if (!context.config.input) throw new Error(`No input defined in configuration for ${method} execution. Please ensure that the configuration file defines an input for this execution, or provide an inline configuration with the necessary input.`);
51
52
  await fn(context);
52
53
  }]));
53
54
  }
@@ -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 type {\n ExecutionContext,\n InlineConfig,\n LogFnMeta\n} 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 type { DeepPartial, MaybePromise } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { defu } from \"defu\";\nimport type { RpcClient } from \"../types\";\nimport type { ExecutionHostParams } from \"../types/api\";\nimport type { EngineResolvedConfig } from \"../types/config\";\nimport type { EngineSystemContext } from \"../types/context\";\nimport { createRpcClient } from \"./rpc\";\nimport { MessagePortDuplex } from \"./stream\";\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 ExecutionContext<EngineResolvedConfig, EngineSystemContext> =\n ExecutionContext<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, port } = params;\n\n const duplex = new MessagePortDuplex(port);\n duplex.setEncoding(\"utf8\");\n duplex.on(\"data\", (chunk: string) => duplex.write(chunk.toUpperCase()));\n duplex.on(\"end\", () => {\n duplex.end();\n });\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<EngineResolvedConfig, EngineSystemContext>(\n context\n );\n await fn(context);\n }\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,oBAId,SACA,eAE2D,CAAC,GAC5D;CACA,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAC5C,QACA,OAAO,WAAgC;EACrC,MAAM,EAAE,SAAS,SAAS;EAE1B,MAAM,SAAS,IAAI,kBAAkB,IAAI;EACzC,OAAO,YAAY,MAAM;EACzB,OAAO,GAAG,SAAS,UAAkB,OAAO,MAAM,MAAM,YAAY,CAAC,CAAC;EACtE,OAAO,GAAG,aAAa;GACrB,OAAO,IAAI;EACb,CAAC;EAED,IAAI;EACJ,IAAI,QAAQ,WAAW,QAAQ,YAC7B,MAAM,gBAAgB,OAAO;OAE7B,MAAM,IAAI,MACR,uDACE,CAAC,QAAQ,UACL,UAAU,QAAQ,aAAa,gCAAgC,OAC/D,aACL,4BACH;EAGF,MAAM,SAAS,MAAiB,YAAoB;GAClD,cAAc,MAAM,OAAO;GAC3B,IAAI,KACF,AAAK,IAAI,UAAU,kBAAkB;IACnC,MAAM;KACJ,UAAU;KACV,GAAG;KACH,GAAI,YAAY,IAAI,IAAI,OAAO,EAAE,MAAM,KAAK;KAC5C,OAAO,KAAK;KACZ,WAAW,KAAK,IAAI;IACtB;IACA;GACF,CAAC;EAEL;EAEA,MAAM,UAAW,MAAM,2BAA2B,KAIhD;GAAE,GAAG;GAAS;EAAM,GACpB,WAAW,YAAY,IACnB,MAAM,QAAQ,QAAQ,aAAa,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAC5D,KAAK,cAAc,OAAO,gBAAgB,CAAC,CAAC,GACjD,EACE,IACF,CACF;EAEA,QAAQ,OAAO,KACb,YACE,UAAU,QAAQ,WAAW,IAAI,KAAK,aACvC,KAAK,UAAU,MAAM,EAAE,cAAc,QAAQ,YAAY,EAC5D;EAEA,MAAM,oBACJ,OACF;EACA,MAAM,GAAG,OAAO;CAClB,CACF,CAAC,CACH;AACF"}
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 type {\n ExecutionContext,\n InlineConfig,\n LogFnMeta\n} 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 type { DeepPartial, MaybePromise } from \"@stryke/types/base\";\nimport { uuid } from \"@stryke/unique-id/uuid\";\nimport { defu } from \"defu\";\nimport type { RpcClient } from \"../types\";\nimport type { ExecutionHostParams } from \"../types/api\";\nimport type { EngineResolvedConfig } from \"../types/config\";\nimport type { EngineSystemContext } from \"../types/context\";\nimport { createRpcClient } from \"./rpc\";\nimport { MessagePortDuplex } from \"./stream\";\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 ExecutionContext<EngineResolvedConfig, EngineSystemContext> =\n ExecutionContext<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, port } = params;\n\n const duplex = new MessagePortDuplex(port);\n duplex.setEncoding(\"utf8\");\n duplex.on(\"data\", (chunk: string) => duplex.write(chunk.toUpperCase()));\n duplex.on(\"end\", () => {\n duplex.end();\n });\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<EngineResolvedConfig, EngineSystemContext>(\n context\n );\n\n if (!context.config.input) {\n throw new Error(\n `No input defined in configuration for ${\n method\n } execution. Please ensure that the configuration file defines an input for this execution, or provide an inline configuration with the necessary input.`\n );\n }\n\n await fn(context);\n }\n ])\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,SAAgB,oBAId,SACA,eAE2D,CAAC,GAC5D;CACA,OAAO,OAAO,YACZ,OAAO,QAAQ,OAAO,EAAE,KAAK,CAAC,QAAQ,QAAQ,CAC5C,QACA,OAAO,WAAgC;EACrC,MAAM,EAAE,SAAS,SAAS;EAE1B,MAAM,SAAS,IAAI,kBAAkB,IAAI;EACzC,OAAO,YAAY,MAAM;EACzB,OAAO,GAAG,SAAS,UAAkB,OAAO,MAAM,MAAM,YAAY,CAAC,CAAC;EACtE,OAAO,GAAG,aAAa;GACrB,OAAO,IAAI;EACb,CAAC;EAED,IAAI;EACJ,IAAI,QAAQ,WAAW,QAAQ,YAC7B,MAAM,gBAAgB,OAAO;OAE7B,MAAM,IAAI,MACR,uDACE,CAAC,QAAQ,UACL,UAAU,QAAQ,aAAa,gCAAgC,OAC/D,aACL,4BACH;EAGF,MAAM,SAAS,MAAiB,YAAoB;GAClD,cAAc,MAAM,OAAO;GAC3B,IAAI,KACF,AAAK,IAAI,UAAU,kBAAkB;IACnC,MAAM;KACJ,UAAU;KACV,GAAG;KACH,GAAI,YAAY,IAAI,IAAI,OAAO,EAAE,MAAM,KAAK;KAC5C,OAAO,KAAK;KACZ,WAAW,KAAK,IAAI;IACtB;IACA;GACF,CAAC;EAEL;EAEA,MAAM,UAAW,MAAM,2BAA2B,KAIhD;GAAE,GAAG;GAAS;EAAM,GACpB,WAAW,YAAY,IACnB,MAAM,QAAQ,QAAQ,aAAa,OAAO,gBAAgB,CAAC,CAAC,CAAC,IAC5D,KAAK,cAAc,OAAO,gBAAgB,CAAC,CAAC,GACjD,EACE,IACF,CACF;EAEA,QAAQ,OAAO,KACb,YACE,UAAU,QAAQ,WAAW,IAAI,KAAK,aACvC,KAAK,UAAU,MAAM,EAAE,cAAc,QAAQ,YAAY,EAC5D;EAEA,MAAM,oBACJ,OACF;EAEA,IAAI,CAAC,QAAQ,OAAO,OAClB,MAAM,IAAI,MACR,yCACE,OACD,wJACH;EAGF,MAAM,GAAG,OAAO;CAClB,CACF,CAAC,CACH;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/engine",
3
- "version": "0.49.1",
3
+ "version": "0.49.3",
4
4
  "private": false,
5
5
  "description": "An internal package containing the core engine modules for Powerlines.",
6
6
  "homepage": "https://stormsoftware.com",
@@ -116,7 +116,7 @@
116
116
  "types": "./dist/index.d.cts",
117
117
  "files": ["dist"],
118
118
  "dependencies": {
119
- "@powerlines/core": "^0.48.1",
119
+ "@powerlines/core": "^0.48.3",
120
120
  "@storm-software/config": "^1.137.58",
121
121
  "@storm-software/config-tools": "^1.190.26",
122
122
  "@stryke/async": "^0.1.5",
@@ -153,5 +153,5 @@
153
153
  "@types/node": "^25.9.1",
154
154
  "typescript": "^6.0.3"
155
155
  },
156
- "gitHead": "75742ad041aeb54cee4e6f8d1f2daa413b4d9787"
156
+ "gitHead": "d2b122a9360cec3146a163b8de0d1192d1d78b6b"
157
157
  }