@transai/connector-runtime-sdk 0.8.0 → 0.9.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.
- package/index.cjs +1 -1
- package/index.cjs.map +3 -3
- package/index.js +1 -1
- package/index.js.map +2 -2
- package/meta.cjs.json +4 -4
- package/meta.esm.json +4 -4
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var d=Object.create;var
|
|
1
|
+
var d=Object.create;var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var v=(r,o)=>{for(var e in o)s(r,e,{get:o[e],enumerable:!0})},p=(r,o,e,t)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of C(o))!I.call(r,n)&&n!==e&&s(r,n,{get:()=>o[n],enumerable:!(t=g(o,n))||t.enumerable});return r};var x=(r,o,e)=>(e=r!=null?d(b(r)):{},p(o||!r||!r.__esModule?s(e,"default",{value:r,enumerable:!0}):e,r)),u=r=>p(s({},"__esModule",{value:!0}),r);var h={};v(h,{ConnectorRuntimeSDK:()=>a,NullLogger:()=>c});module.exports=u(h);var i=x(require("node:process")),a=class{constructor(o,e){this.#o="connector-runtime";this.init=()=>Promise.resolve();this.start=()=>Promise.resolve();this.stop=()=>Promise.resolve();this.#e=e,i.default.on?i.default.on("message",t=>{t.cmd===this.#o&&e.logger.verbose(`${i.default.pid} Received message from parent process:`,t)}):e.logger.warn("IPC channel is not available. process.on is undefined."),i.default.send||e.logger.warn("IPC channel is not available. process.send is undefined."),o.actions?.forEach(t=>{if(t.config.templates===void 0)return;let n={};Object.entries(t.config.templates).forEach(([f,m])=>{try{n[f]=e.templating.compile(m)}catch(l){e.logger.error(`Error compiling template ${f} for action ${t.identifier}`,l)}}),t.config.parsedTemplates=n})}#o;#e;set callbackFunction(o){this.connectorSDK.receiver.registerCallback(this.#r(o))}get connectorSDK(){return this.#e}#r(o){return async e=>{let t=await this.#e.receiver.getActionConfig(e);return t?o(e,t):this.#e.receiver.responses.badRequest("Action not found")(e)}}};var c=class{info(){}debug(){}error(){}warn(){}verbose(){}};0&&(module.exports={ConnectorRuntimeSDK,NullLogger});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/index.cjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../libs/connector-runtime-sdk/src/index.ts", "../../../libs/connector-runtime-sdk/src/lib/connector-runtime.ts", "../../../libs/connector-runtime-sdk/src/lib/support/null-logger.ts"],
|
|
4
|
-
"sourcesContent": ["export * from './lib/connector-runtime';\nexport * from './lib/connector-runtime.interface';\nexport * from './lib/sdk';\nexport * from './lib/support';\n", "import
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,eAAAC,IAAA,eAAAC,EAAAJ,GCAA,IAAAK,
|
|
6
|
-
"names": ["index_exports", "__export", "ConnectorRuntimeSDK", "NullLogger", "__toCommonJS", "
|
|
4
|
+
"sourcesContent": ["export * from './lib/connector-runtime';\nexport * from './lib/connector-runtime.interface';\nexport * from './lib/sdk';\nexport * from './lib/support';\n", "import process from 'node:process';\n\nimport {\n KafkaCallbackResponse,\n BaseConnectorConfig,\n ActionInterface,\n ConnectorInterface,\n XodJobType,\n} from '@xip-online-data/types';\n\nimport { ConnectorRuntimeInterface } from './connector-runtime.interface';\nimport { CompileDelegate, ConnectorSDKInterface } from './sdk';\n\nexport interface IpcMessage {\n cmd: string;\n message: string;\n}\n\nexport abstract class ConnectorRuntimeSDK<\n T extends BaseConnectorConfig = BaseConnectorConfig,\n> implements ConnectorRuntimeInterface {\n readonly #IPC_CHANNEL = 'connector-runtime';\n\n readonly #connectorSDK: ConnectorSDKInterface<T>;\n\n constructor(\n connector: ConnectorInterface,\n connectorSDK: ConnectorSDKInterface,\n ) {\n this.#connectorSDK = connectorSDK as ConnectorSDKInterface<T>;\n\n if (process.on) {\n process.on('message', (message: IpcMessage) => {\n if (message.cmd === this.#IPC_CHANNEL) {\n connectorSDK.logger.verbose(\n `${process.pid} Received message from parent process:`,\n message,\n );\n }\n });\n } else {\n connectorSDK.logger.warn(\n 'IPC channel is not available. process.on is undefined.',\n );\n }\n\n if (!process.send) {\n // Check if process.send is available\n connectorSDK.logger.warn(\n 'IPC channel is not available. process.send is undefined.',\n );\n }\n\n // eslint-disable-next-line no-restricted-syntax\n connector.actions?.forEach((action: ActionInterface) => {\n if (action.config['templates'] === undefined) {\n return;\n }\n\n const containers: {\n [key: string]: CompileDelegate;\n } = {};\n\n Object.entries(action.config['templates']).forEach(([key, value]) => {\n try {\n // eslint-disable-next-line security/detect-object-injection\n containers[key] = connectorSDK.templating.compile(value);\n } catch (error: unknown) {\n connectorSDK.logger.error(\n `Error compiling template ${key} for action ${action.identifier}`,\n error,\n );\n }\n });\n\n // eslint-disable-next-line no-param-reassign\n action.config['parsedTemplates'] = containers;\n });\n }\n\n public init: () => Promise<void> = () => Promise.resolve();\n\n public start: () => Promise<void> = () => Promise.resolve();\n\n public stop: () => Promise<void> = () => Promise.resolve();\n\n set callbackFunction(\n callback: (\n message: XodJobType,\n action: ActionInterface,\n ) => Promise<KafkaCallbackResponse>,\n ) {\n this.connectorSDK.receiver.registerCallback(\n this.#enrichWithActionConfig(callback),\n );\n }\n\n protected get connectorSDK(): ConnectorSDKInterface<T> {\n return this.#connectorSDK;\n }\n\n #enrichWithActionConfig(\n callbackFunction: (\n message: XodJobType,\n action: ActionInterface,\n ) => Promise<KafkaCallbackResponse>,\n ): (message: XodJobType) => Promise<KafkaCallbackResponse> {\n return async (message: XodJobType) => {\n const action = await this.#connectorSDK.receiver.getActionConfig(message);\n if (!action) {\n return this.#connectorSDK.receiver.responses.badRequest(\n 'Action not found',\n )(message);\n }\n return callbackFunction(message, action);\n };\n }\n}\n", "import { LoggerSDKInterface } from '../sdk';\n\nexport class NullLogger implements LoggerSDKInterface {\n info(): void {\n // Do nothing\n }\n\n debug(): void {\n // Do nothing\n }\n\n error(): void {\n // Do nothing\n }\n\n warn(): void {\n // Do nothing\n }\n\n verbose(): void {\n // Do nothing\n }\n}\n"],
|
|
5
|
+
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,EAAA,eAAAC,IAAA,eAAAC,EAAAJ,GCAA,IAAAK,EAAoB,2BAkBEC,EAAf,KAEgC,CAKrC,YACEC,EACAC,EACA,CAPF,KAASC,GAAe,oBA2DxB,KAAO,KAA4B,IAAM,QAAQ,QAAQ,EAEzD,KAAO,MAA6B,IAAM,QAAQ,QAAQ,EAE1D,KAAO,KAA4B,IAAM,QAAQ,QAAQ,EAvDvD,KAAKC,GAAgBF,EAEjB,EAAAG,QAAQ,GACV,EAAAA,QAAQ,GAAG,UAAYC,GAAwB,CACzCA,EAAQ,MAAQ,KAAKH,IACvBD,EAAa,OAAO,QAClB,GAAG,EAAAG,QAAQ,GAAG,yCACdC,CACF,CAEJ,CAAC,EAEDJ,EAAa,OAAO,KAClB,wDACF,EAGG,EAAAG,QAAQ,MAEXH,EAAa,OAAO,KAClB,0DACF,EAIFD,EAAU,SAAS,QAASM,GAA4B,CACtD,GAAIA,EAAO,OAAO,YAAiB,OACjC,OAGF,IAAMC,EAEF,CAAC,EAEL,OAAO,QAAQD,EAAO,OAAO,SAAY,EAAE,QAAQ,CAAC,CAACE,EAAKC,CAAK,IAAM,CACnE,GAAI,CAEFF,EAAWC,CAAG,EAAIP,EAAa,WAAW,QAAQQ,CAAK,CACzD,OAASC,EAAgB,CACvBT,EAAa,OAAO,MAClB,4BAA4BO,CAAG,eAAeF,EAAO,UAAU,GAC/DI,CACF,CACF,CACF,CAAC,EAGDJ,EAAO,OAAO,gBAAqBC,CACrC,CAAC,CACH,CAzDSL,GAEAC,GA+DT,IAAI,iBACFQ,EAIA,CACA,KAAK,aAAa,SAAS,iBACzB,KAAKC,GAAwBD,CAAQ,CACvC,CACF,CAEA,IAAc,cAAyC,CACrD,OAAO,KAAKR,EACd,CAEAS,GACEC,EAIyD,CACzD,MAAO,OAAOR,GAAwB,CACpC,IAAMC,EAAS,MAAM,KAAKH,GAAc,SAAS,gBAAgBE,CAAO,EACxE,OAAKC,EAKEO,EAAiBR,EAASC,CAAM,EAJ9B,KAAKH,GAAc,SAAS,UAAU,WAC3C,kBACF,EAAEE,CAAO,CAGb,CACF,CACF,ECnHO,IAAMS,EAAN,KAA+C,CACpD,MAAa,CAEb,CAEA,OAAc,CAEd,CAEA,OAAc,CAEd,CAEA,MAAa,CAEb,CAEA,SAAgB,CAEhB,CACF",
|
|
6
|
+
"names": ["index_exports", "__export", "ConnectorRuntimeSDK", "NullLogger", "__toCommonJS", "import_node_process", "ConnectorRuntimeSDK", "connector", "connectorSDK", "#IPC_CHANNEL", "#connectorSDK", "process", "message", "action", "containers", "key", "value", "error", "callback", "#enrichWithActionConfig", "callbackFunction", "NullLogger"]
|
|
7
7
|
}
|
package/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from"node:process";var s=class{constructor(r,e){this.#o="connector-runtime";this.init=()=>Promise.resolve();this.start=()=>Promise.resolve();this.stop=()=>Promise.resolve();this.#e=e,t.on?t.on("message",o=>{o.cmd===this.#o&&e.logger.verbose(`${t.pid} Received message from parent process:`,o)}):e.logger.warn("IPC channel is not available. process.on is undefined."),t.send||e.logger.warn("IPC channel is not available. process.send is undefined."),r.actions?.forEach(o=>{if(o.config.templates===void 0)return;let n={};Object.entries(o.config.templates).forEach(([i,f])=>{try{n[i]=e.templating.compile(f)}catch(p){e.logger.error(`Error compiling template ${i} for action ${o.identifier}`,p)}}),o.config.parsedTemplates=n})}#o;#e;set callbackFunction(r){this.connectorSDK.receiver.registerCallback(this.#r(r))}get connectorSDK(){return this.#e}#r(r){return async e=>{let o=await this.#e.receiver.getActionConfig(e);return o?r(e,o):this.#e.receiver.responses.badRequest("Action not found")(e)}}};var a=class{info(){}debug(){}error(){}warn(){}verbose(){}};export{s as ConnectorRuntimeSDK,a as NullLogger};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../libs/connector-runtime-sdk/src/lib/connector-runtime.ts", "../../../libs/connector-runtime-sdk/src/lib/support/null-logger.ts"],
|
|
4
|
-
"sourcesContent": ["import
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["import process from 'node:process';\n\nimport {\n KafkaCallbackResponse,\n BaseConnectorConfig,\n ActionInterface,\n ConnectorInterface,\n XodJobType,\n} from '@xip-online-data/types';\n\nimport { ConnectorRuntimeInterface } from './connector-runtime.interface';\nimport { CompileDelegate, ConnectorSDKInterface } from './sdk';\n\nexport interface IpcMessage {\n cmd: string;\n message: string;\n}\n\nexport abstract class ConnectorRuntimeSDK<\n T extends BaseConnectorConfig = BaseConnectorConfig,\n> implements ConnectorRuntimeInterface {\n readonly #IPC_CHANNEL = 'connector-runtime';\n\n readonly #connectorSDK: ConnectorSDKInterface<T>;\n\n constructor(\n connector: ConnectorInterface,\n connectorSDK: ConnectorSDKInterface,\n ) {\n this.#connectorSDK = connectorSDK as ConnectorSDKInterface<T>;\n\n if (process.on) {\n process.on('message', (message: IpcMessage) => {\n if (message.cmd === this.#IPC_CHANNEL) {\n connectorSDK.logger.verbose(\n `${process.pid} Received message from parent process:`,\n message,\n );\n }\n });\n } else {\n connectorSDK.logger.warn(\n 'IPC channel is not available. process.on is undefined.',\n );\n }\n\n if (!process.send) {\n // Check if process.send is available\n connectorSDK.logger.warn(\n 'IPC channel is not available. process.send is undefined.',\n );\n }\n\n // eslint-disable-next-line no-restricted-syntax\n connector.actions?.forEach((action: ActionInterface) => {\n if (action.config['templates'] === undefined) {\n return;\n }\n\n const containers: {\n [key: string]: CompileDelegate;\n } = {};\n\n Object.entries(action.config['templates']).forEach(([key, value]) => {\n try {\n // eslint-disable-next-line security/detect-object-injection\n containers[key] = connectorSDK.templating.compile(value);\n } catch (error: unknown) {\n connectorSDK.logger.error(\n `Error compiling template ${key} for action ${action.identifier}`,\n error,\n );\n }\n });\n\n // eslint-disable-next-line no-param-reassign\n action.config['parsedTemplates'] = containers;\n });\n }\n\n public init: () => Promise<void> = () => Promise.resolve();\n\n public start: () => Promise<void> = () => Promise.resolve();\n\n public stop: () => Promise<void> = () => Promise.resolve();\n\n set callbackFunction(\n callback: (\n message: XodJobType,\n action: ActionInterface,\n ) => Promise<KafkaCallbackResponse>,\n ) {\n this.connectorSDK.receiver.registerCallback(\n this.#enrichWithActionConfig(callback),\n );\n }\n\n protected get connectorSDK(): ConnectorSDKInterface<T> {\n return this.#connectorSDK;\n }\n\n #enrichWithActionConfig(\n callbackFunction: (\n message: XodJobType,\n action: ActionInterface,\n ) => Promise<KafkaCallbackResponse>,\n ): (message: XodJobType) => Promise<KafkaCallbackResponse> {\n return async (message: XodJobType) => {\n const action = await this.#connectorSDK.receiver.getActionConfig(message);\n if (!action) {\n return this.#connectorSDK.receiver.responses.badRequest(\n 'Action not found',\n )(message);\n }\n return callbackFunction(message, action);\n };\n }\n}\n", "import { LoggerSDKInterface } from '../sdk';\n\nexport class NullLogger implements LoggerSDKInterface {\n info(): void {\n // Do nothing\n }\n\n debug(): void {\n // Do nothing\n }\n\n error(): void {\n // Do nothing\n }\n\n warn(): void {\n // Do nothing\n }\n\n verbose(): void {\n // Do nothing\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAOA,MAAa,eAkBb,IAAeC,EAAf,KAEgC,CAKrC,YACEC,EACAC,EACA,CAPF,KAASC,GAAe,oBA2DxB,KAAO,KAA4B,IAAM,QAAQ,QAAQ,EAEzD,KAAO,MAA6B,IAAM,QAAQ,QAAQ,EAE1D,KAAO,KAA4B,IAAM,QAAQ,QAAQ,EAvDvD,KAAKC,GAAgBF,EAEjBH,EAAQ,GACVA,EAAQ,GAAG,UAAYM,GAAwB,CACzCA,EAAQ,MAAQ,KAAKF,IACvBD,EAAa,OAAO,QAClB,GAAGH,EAAQ,GAAG,yCACdM,CACF,CAEJ,CAAC,EAEDH,EAAa,OAAO,KAClB,wDACF,EAGGH,EAAQ,MAEXG,EAAa,OAAO,KAClB,0DACF,EAIFD,EAAU,SAAS,QAASK,GAA4B,CACtD,GAAIA,EAAO,OAAO,YAAiB,OACjC,OAGF,IAAMC,EAEF,CAAC,EAEL,OAAO,QAAQD,EAAO,OAAO,SAAY,EAAE,QAAQ,CAAC,CAACE,EAAKC,CAAK,IAAM,CACnE,GAAI,CAEFF,EAAWC,CAAG,EAAIN,EAAa,WAAW,QAAQO,CAAK,CACzD,OAASC,EAAgB,CACvBR,EAAa,OAAO,MAClB,4BAA4BM,CAAG,eAAeF,EAAO,UAAU,GAC/DI,CACF,CACF,CACF,CAAC,EAGDJ,EAAO,OAAO,gBAAqBC,CACrC,CAAC,CACH,CAzDSJ,GAEAC,GA+DT,IAAI,iBACFO,EAIA,CACA,KAAK,aAAa,SAAS,iBACzB,KAAKC,GAAwBD,CAAQ,CACvC,CACF,CAEA,IAAc,cAAyC,CACrD,OAAO,KAAKP,EACd,CAEAQ,GACEC,EAIyD,CACzD,MAAO,OAAOR,GAAwB,CACpC,IAAMC,EAAS,MAAM,KAAKF,GAAc,SAAS,gBAAgBC,CAAO,EACxE,OAAKC,EAKEO,EAAiBR,EAASC,CAAM,EAJ9B,KAAKF,GAAc,SAAS,UAAU,WAC3C,kBACF,EAAEC,CAAO,CAGb,CACF,CACF,ECnHO,IAAMS,EAAN,KAA+C,CACpD,MAAa,CAEb,CAEA,OAAc,CAEd,CAEA,OAAc,CAEd,CAEA,MAAa,CAEb,CAEA,SAAgB,CAEhB,CACF",
|
|
6
6
|
"names": ["process", "ConnectorRuntimeSDK", "connector", "connectorSDK", "#IPC_CHANNEL", "#connectorSDK", "message", "action", "containers", "key", "value", "error", "callback", "#enrichWithActionConfig", "callbackFunction", "NullLogger"]
|
|
7
7
|
}
|
package/meta.cjs.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 3301,
|
|
5
5
|
"imports": [
|
|
6
6
|
{
|
|
7
7
|
"path": "node:process",
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
"imports": [],
|
|
249
249
|
"exports": [],
|
|
250
250
|
"inputs": {},
|
|
251
|
-
"bytes":
|
|
251
|
+
"bytes": 5772
|
|
252
252
|
},
|
|
253
253
|
"dist/libs/connector-runtime-sdk/index.cjs": {
|
|
254
254
|
"imports": [
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
"bytesInOutput": 79
|
|
266
266
|
},
|
|
267
267
|
"libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
|
|
268
|
-
"bytesInOutput":
|
|
268
|
+
"bytesInOutput": 1036
|
|
269
269
|
},
|
|
270
270
|
"libs/connector-runtime-sdk/src/lib/sdk/index.ts": {
|
|
271
271
|
"bytesInOutput": 0
|
|
@@ -277,7 +277,7 @@
|
|
|
277
277
|
"bytesInOutput": 0
|
|
278
278
|
}
|
|
279
279
|
},
|
|
280
|
-
"bytes":
|
|
280
|
+
"bytes": 1820
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
}
|
package/meta.esm.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 3301,
|
|
5
5
|
"imports": [
|
|
6
6
|
{
|
|
7
7
|
"path": "node:process",
|
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
"imports": [],
|
|
249
249
|
"exports": [],
|
|
250
250
|
"inputs": {},
|
|
251
|
-
"bytes":
|
|
251
|
+
"bytes": 5370
|
|
252
252
|
},
|
|
253
253
|
"dist/libs/connector-runtime-sdk/index.js": {
|
|
254
254
|
"imports": [
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
"entryPoint": "libs/connector-runtime-sdk/src/index.ts",
|
|
266
266
|
"inputs": {
|
|
267
267
|
"libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
|
|
268
|
-
"bytesInOutput":
|
|
268
|
+
"bytesInOutput": 1003
|
|
269
269
|
},
|
|
270
270
|
"libs/connector-runtime-sdk/src/index.ts": {
|
|
271
271
|
"bytesInOutput": 0
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
"bytesInOutput": 0
|
|
281
281
|
}
|
|
282
282
|
},
|
|
283
|
-
"bytes":
|
|
283
|
+
"bytes": 1146
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
}
|