@transai/connector-runtime-sdk 0.9.1 → 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.
package/index.cjs CHANGED
@@ -1,2 +1,2 @@
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});
1
+ var d=Object.create;var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var b=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var P=(t,r)=>{for(var e in r)i(t,e,{get:r[e],enumerable:!0})},m=(t,r,e,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of I(r))!x.call(t,o)&&o!==e&&i(t,o,{get:()=>r[o],enumerable:!(n=l(r,o))||n.enumerable});return t};var C=(t,r,e)=>(e=t!=null?d(b(t)):{},m(r||!t||!t.__esModule?i(e,"default",{value:t,enumerable:!0}):e,t)),v=t=>m(i({},"__esModule",{value:!0}),t);var A={};P(A,{ConnectorOrigin:()=>f,ConnectorRuntimeSDK:()=>s,DEFAULT_TIMEOUT_SECONDS:()=>y,NullLogger:()=>c});module.exports=v(A);var f=(e=>(e.from_template="from_template",e.manual="manual",e))(f||{});var a=C(require("node:process")),s=class{constructor(r,e){this.#r="connector-runtime";this.init=()=>Promise.resolve();this.start=()=>Promise.resolve();this.stop=()=>Promise.resolve();this.#e=e,a.default.on?a.default.on("message",n=>{n.cmd===this.#r&&e.logger.verbose(`${a.default.pid} Received message from parent process:`,n)}):e.logger.warn("IPC channel is not available. process.on is undefined."),a.default.send||e.logger.warn("IPC channel is not available. process.send is undefined."),r.actions?.forEach(n=>{if(n.config.templates===void 0)return;let o={};Object.entries(n.config.templates).forEach(([p,u])=>{try{o[p]=e.templating.compile(u)}catch(g){e.logger.error(`Error compiling template ${p} for action ${n.identifier}`,g)}}),n.config.parsedTemplates=o})}#r;#e;set callbackFunction(r){this.connectorSDK.receiver.registerCallback(this.#t(r))}get connectorSDK(){return this.#e}#t(r){return async e=>{let n=await this.#e.receiver.getActionConfig(e);return n?r(e,n):this.#e.receiver.responses.badRequest("Action not found")(e)}}};var y=600;var c=class{info(){}debug(){}error(){}warn(){}verbose(){}};0&&(module.exports={ConnectorOrigin,ConnectorRuntimeSDK,DEFAULT_TIMEOUT_SECONDS,NullLogger});
2
2
  //# sourceMappingURL=index.cjs.map
package/index.cjs.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 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 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"]
3
+ "sources": ["../../../libs/connector-runtime-sdk/src/index.ts", "../../../libs/connector-runtime-sdk/src/lib/types/action.ts", "../../../libs/connector-runtime-sdk/src/lib/connector-runtime.ts", "../../../libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts", "../../../libs/connector-runtime-sdk/src/lib/support/null-logger.ts"],
4
+ "sourcesContent": ["export * from './lib/types';\nexport * from './lib/connector-runtime';\nexport * from './lib/connector-runtime.interface';\nexport * from './lib/sdk';\nexport * from './lib/support';\n", "export enum ConnectorOrigin {\n from_template = 'from_template',\n manual = 'manual',\n}\n\nexport interface LegacyOutputParameterInterface {\n [key: string]: string;\n}\n\nexport type SupportedOutputTypes =\n | 'string'\n | 'number'\n | 'boolean'\n | 'array'\n | 'null';\n\nexport interface OutputItemParameterInterface {\n type: SupportedOutputTypes | Array<SupportedOutputTypes>;\n description?: string;\n required?: boolean;\n}\n\nexport interface ArrayOutputParameterInterface extends OutputItemParameterInterface {\n type: 'array';\n items: OutputParameterInterface;\n}\n\nexport interface NumberOutputParameterInterface extends OutputItemParameterInterface {\n type: 'number' | Array<'number' | 'null'>;\n minimum?: number;\n maximum?: number;\n}\n\nexport interface OutputParameterInterface {\n [key: string]:\n | OutputItemParameterInterface\n | ArrayOutputParameterInterface\n | NumberOutputParameterInterface;\n}\n\nexport interface InputParameterInterface {\n name: string;\n description?: string;\n type: 'string' | 'number' | 'boolean' | 'array';\n required?: boolean;\n items?: Array<InputParameterInterface>;\n}\n\nexport interface ActionInterface {\n identifier: string;\n version: string;\n tenantIdentifier: string;\n name: string;\n description?: string;\n connectorIdentifier: string;\n config: {\n [key: string]: { [key: string]: string | object } | string | object;\n };\n inputParameters: Array<InputParameterInterface>;\n outputParameters: LegacyOutputParameterInterface | OutputParameterInterface;\n mode?: ConnectorOrigin;\n createdAt: Date;\n}\n", "import process from 'node:process';\n\nimport { ConnectorRuntimeInterface } from './connector-runtime.interface';\nimport { CompileDelegate, ConnectorSDKInterface } from './sdk';\nimport {\n ActionInterface,\n BaseConnectorConfig,\n ConnectorInterface,\n KafkaCallbackResponse,\n XodJobType,\n} from './types';\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", "/** The default timeout is 10 minutes */\nexport const DEFAULT_TIMEOUT_SECONDS = 10 * 60;\n\nexport interface IntervalHandler {\n name?: string;\n onInit?: () => Promise<void> | void;\n onRun: () => Promise<void> | void;\n onStop?: () => Promise<void> | void;\n}\n\n/**\n * Options for configuring an interval registered via {@link ProcessingSDKInterface.registerInterval}.\n */\nexport type RegisterIntervalOptions = {\n /**\n * If true, the handler will be invoked immediately once on registration,\n * in addition to subsequent scheduled executions.\n */\n immediate?: boolean;\n\n /**\n * Optional timeout, in seconds, for the interval.\n *\n * This value should be a positive number representing the maximum time,\n * in seconds, that the interval is allowed to run before being considered\n * timed out. Callers should not pass 0 or negative values.\n */\n timeout?: number;\n};\n\nexport interface ProcessingSDKInterface {\n registerInterval(\n intervalSeconds: number,\n handler: IntervalHandler,\n options?: RegisterIntervalOptions,\n ): Promise<string>;\n\n stopInterval(name: string): Promise<void>;\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,qBAAAE,EAAA,wBAAAC,EAAA,4BAAAC,EAAA,eAAAC,IAAA,eAAAC,EAAAN,GCAO,IAAKO,OACVA,EAAA,cAAgB,gBAChBA,EAAA,OAAS,SAFCA,OAAA,ICAZ,IAAAC,EAAoB,2BAiBEC,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,EAA0B,ICChC,IAAMC,EAAN,KAA+C,CACpD,MAAa,CAEb,CAEA,OAAc,CAEd,CAEA,OAAc,CAEd,CAEA,MAAa,CAEb,CAEA,SAAgB,CAEhB,CACF",
6
+ "names": ["index_exports", "__export", "ConnectorOrigin", "ConnectorRuntimeSDK", "DEFAULT_TIMEOUT_SECONDS", "NullLogger", "__toCommonJS", "ConnectorOrigin", "import_node_process", "ConnectorRuntimeSDK", "connector", "connectorSDK", "#IPC_CHANNEL", "#connectorSDK", "process", "message", "action", "containers", "key", "value", "error", "callback", "#enrichWithActionConfig", "callbackFunction", "DEFAULT_TIMEOUT_SECONDS", "NullLogger"]
7
7
  }
package/index.js CHANGED
@@ -1,2 +1,2 @@
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};
1
+ var f=(e=>(e.from_template="from_template",e.manual="manual",e))(f||{});import n from"node:process";var i=class{constructor(t,e){this.#r="connector-runtime";this.init=()=>Promise.resolve();this.start=()=>Promise.resolve();this.stop=()=>Promise.resolve();this.#e=e,n.on?n.on("message",r=>{r.cmd===this.#r&&e.logger.verbose(`${n.pid} Received message from parent process:`,r)}):e.logger.warn("IPC channel is not available. process.on is undefined."),n.send||e.logger.warn("IPC channel is not available. process.send is undefined."),t.actions?.forEach(r=>{if(r.config.templates===void 0)return;let o={};Object.entries(r.config.templates).forEach(([a,p])=>{try{o[a]=e.templating.compile(p)}catch(m){e.logger.error(`Error compiling template ${a} for action ${r.identifier}`,m)}}),r.config.parsedTemplates=o})}#r;#e;set callbackFunction(t){this.connectorSDK.receiver.registerCallback(this.#t(t))}get connectorSDK(){return this.#e}#t(t){return async e=>{let r=await this.#e.receiver.getActionConfig(e);return r?t(e,r):this.#e.receiver.responses.badRequest("Action not found")(e)}}};var x=600;var s=class{info(){}debug(){}error(){}warn(){}verbose(){}};export{f as ConnectorOrigin,i as ConnectorRuntimeSDK,x as DEFAULT_TIMEOUT_SECONDS,s as NullLogger};
2
2
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 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 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
- "names": ["process", "ConnectorRuntimeSDK", "connector", "connectorSDK", "#IPC_CHANNEL", "#connectorSDK", "message", "action", "containers", "key", "value", "error", "callback", "#enrichWithActionConfig", "callbackFunction", "NullLogger"]
3
+ "sources": ["../../../libs/connector-runtime-sdk/src/lib/types/action.ts", "../../../libs/connector-runtime-sdk/src/lib/connector-runtime.ts", "../../../libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts", "../../../libs/connector-runtime-sdk/src/lib/support/null-logger.ts"],
4
+ "sourcesContent": ["export enum ConnectorOrigin {\n from_template = 'from_template',\n manual = 'manual',\n}\n\nexport interface LegacyOutputParameterInterface {\n [key: string]: string;\n}\n\nexport type SupportedOutputTypes =\n | 'string'\n | 'number'\n | 'boolean'\n | 'array'\n | 'null';\n\nexport interface OutputItemParameterInterface {\n type: SupportedOutputTypes | Array<SupportedOutputTypes>;\n description?: string;\n required?: boolean;\n}\n\nexport interface ArrayOutputParameterInterface extends OutputItemParameterInterface {\n type: 'array';\n items: OutputParameterInterface;\n}\n\nexport interface NumberOutputParameterInterface extends OutputItemParameterInterface {\n type: 'number' | Array<'number' | 'null'>;\n minimum?: number;\n maximum?: number;\n}\n\nexport interface OutputParameterInterface {\n [key: string]:\n | OutputItemParameterInterface\n | ArrayOutputParameterInterface\n | NumberOutputParameterInterface;\n}\n\nexport interface InputParameterInterface {\n name: string;\n description?: string;\n type: 'string' | 'number' | 'boolean' | 'array';\n required?: boolean;\n items?: Array<InputParameterInterface>;\n}\n\nexport interface ActionInterface {\n identifier: string;\n version: string;\n tenantIdentifier: string;\n name: string;\n description?: string;\n connectorIdentifier: string;\n config: {\n [key: string]: { [key: string]: string | object } | string | object;\n };\n inputParameters: Array<InputParameterInterface>;\n outputParameters: LegacyOutputParameterInterface | OutputParameterInterface;\n mode?: ConnectorOrigin;\n createdAt: Date;\n}\n", "import process from 'node:process';\n\nimport { ConnectorRuntimeInterface } from './connector-runtime.interface';\nimport { CompileDelegate, ConnectorSDKInterface } from './sdk';\nimport {\n ActionInterface,\n BaseConnectorConfig,\n ConnectorInterface,\n KafkaCallbackResponse,\n XodJobType,\n} from './types';\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", "/** The default timeout is 10 minutes */\nexport const DEFAULT_TIMEOUT_SECONDS = 10 * 60;\n\nexport interface IntervalHandler {\n name?: string;\n onInit?: () => Promise<void> | void;\n onRun: () => Promise<void> | void;\n onStop?: () => Promise<void> | void;\n}\n\n/**\n * Options for configuring an interval registered via {@link ProcessingSDKInterface.registerInterval}.\n */\nexport type RegisterIntervalOptions = {\n /**\n * If true, the handler will be invoked immediately once on registration,\n * in addition to subsequent scheduled executions.\n */\n immediate?: boolean;\n\n /**\n * Optional timeout, in seconds, for the interval.\n *\n * This value should be a positive number representing the maximum time,\n * in seconds, that the interval is allowed to run before being considered\n * timed out. Callers should not pass 0 or negative values.\n */\n timeout?: number;\n};\n\nexport interface ProcessingSDKInterface {\n registerInterval(\n intervalSeconds: number,\n handler: IntervalHandler,\n options?: RegisterIntervalOptions,\n ): Promise<string>;\n\n stopInterval(name: string): Promise<void>;\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": "AAAO,IAAKA,OACVA,EAAA,cAAgB,gBAChBA,EAAA,OAAS,SAFCA,OAAA,ICAZ,OAAOC,MAAa,eAiBb,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,EAA0B,ICChC,IAAMC,EAAN,KAA+C,CACpD,MAAa,CAEb,CAEA,OAAc,CAEd,CAEA,OAAc,CAEd,CAEA,MAAa,CAEb,CAEA,SAAgB,CAEhB,CACF",
6
+ "names": ["ConnectorOrigin", "process", "ConnectorRuntimeSDK", "connector", "connectorSDK", "#IPC_CHANNEL", "#connectorSDK", "message", "action", "containers", "key", "value", "error", "callback", "#enrichWithActionConfig", "callbackFunction", "DEFAULT_TIMEOUT_SECONDS", "NullLogger"]
7
7
  }
package/meta.cjs.json CHANGED
@@ -1,15 +1,46 @@
1
1
  {
2
2
  "inputs": {
3
- "libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
4
- "bytes": 3301,
3
+ "libs/connector-runtime-sdk/src/lib/types/action.ts": {
4
+ "bytes": 1556,
5
+ "imports": [],
6
+ "format": "esm"
7
+ },
8
+ "libs/connector-runtime-sdk/src/lib/types/kafka.ts": {
9
+ "bytes": 1115,
10
+ "imports": [],
11
+ "format": "esm"
12
+ },
13
+ "libs/connector-runtime-sdk/src/lib/types.ts": {
14
+ "bytes": 709,
5
15
  "imports": [
6
16
  {
7
- "path": "node:process",
17
+ "path": "./types/action",
8
18
  "kind": "import-statement",
9
19
  "external": true
10
20
  },
11
21
  {
12
- "path": "@xip-online-data/types",
22
+ "path": "./types/kafka",
23
+ "kind": "import-statement",
24
+ "external": true
25
+ },
26
+ {
27
+ "path": "libs/connector-runtime-sdk/src/lib/types/action.ts",
28
+ "kind": "import-statement",
29
+ "original": "./types/action"
30
+ },
31
+ {
32
+ "path": "libs/connector-runtime-sdk/src/lib/types/kafka.ts",
33
+ "kind": "import-statement",
34
+ "original": "./types/kafka"
35
+ }
36
+ ],
37
+ "format": "esm"
38
+ },
39
+ "libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
40
+ "bytes": 3285,
41
+ "imports": [
42
+ {
43
+ "path": "node:process",
13
44
  "kind": "import-statement",
14
45
  "external": true
15
46
  },
@@ -22,6 +53,11 @@
22
53
  "path": "./sdk",
23
54
  "kind": "import-statement",
24
55
  "external": true
56
+ },
57
+ {
58
+ "path": "./types",
59
+ "kind": "import-statement",
60
+ "external": true
25
61
  }
26
62
  ],
27
63
  "format": "esm"
@@ -32,10 +68,10 @@
32
68
  "format": "esm"
33
69
  },
34
70
  "libs/connector-runtime-sdk/src/lib/sdk/sdk.interface.ts": {
35
- "bytes": 1511,
71
+ "bytes": 1497,
36
72
  "imports": [
37
73
  {
38
- "path": "@xip-online-data/types",
74
+ "path": "../types",
39
75
  "kind": "import-statement",
40
76
  "external": true
41
77
  },
@@ -98,20 +134,20 @@
98
134
  "format": "esm"
99
135
  },
100
136
  "libs/connector-runtime-sdk/src/lib/sdk/offset-store.sdk.interface.ts": {
101
- "bytes": 359,
137
+ "bytes": 386,
102
138
  "imports": [],
103
139
  "format": "esm"
104
140
  },
105
141
  "libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
106
- "bytes": 467,
142
+ "bytes": 1114,
107
143
  "imports": [],
108
144
  "format": "esm"
109
145
  },
110
146
  "libs/connector-runtime-sdk/src/lib/sdk/receiver.sdk.interface.ts": {
111
- "bytes": 954,
147
+ "bytes": 940,
112
148
  "imports": [
113
149
  {
114
- "path": "@xip-online-data/types",
150
+ "path": "../types",
115
151
  "kind": "import-statement",
116
152
  "external": true
117
153
  }
@@ -217,8 +253,13 @@
217
253
  "format": "esm"
218
254
  },
219
255
  "libs/connector-runtime-sdk/src/index.ts": {
220
- "bytes": 150,
256
+ "bytes": 179,
221
257
  "imports": [
258
+ {
259
+ "path": "libs/connector-runtime-sdk/src/lib/types.ts",
260
+ "kind": "import-statement",
261
+ "original": "./lib/types"
262
+ },
222
263
  {
223
264
  "path": "libs/connector-runtime-sdk/src/lib/connector-runtime.ts",
224
265
  "kind": "import-statement",
@@ -248,7 +289,7 @@
248
289
  "imports": [],
249
290
  "exports": [],
250
291
  "inputs": {},
251
- "bytes": 5772
292
+ "bytes": 8898
252
293
  },
253
294
  "dist/libs/connector-runtime-sdk/index.cjs": {
254
295
  "imports": [
@@ -262,7 +303,13 @@
262
303
  "entryPoint": "libs/connector-runtime-sdk/src/index.ts",
263
304
  "inputs": {
264
305
  "libs/connector-runtime-sdk/src/index.ts": {
265
- "bytesInOutput": 79
306
+ "bytesInOutput": 131
307
+ },
308
+ "libs/connector-runtime-sdk/src/lib/types/action.ts": {
309
+ "bytesInOutput": 72
310
+ },
311
+ "libs/connector-runtime-sdk/src/lib/types.ts": {
312
+ "bytesInOutput": 0
266
313
  },
267
314
  "libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
268
315
  "bytesInOutput": 1036
@@ -270,6 +317,9 @@
270
317
  "libs/connector-runtime-sdk/src/lib/sdk/index.ts": {
271
318
  "bytesInOutput": 0
272
319
  },
320
+ "libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
321
+ "bytesInOutput": 10
322
+ },
273
323
  "libs/connector-runtime-sdk/src/lib/support/null-logger.ts": {
274
324
  "bytesInOutput": 59
275
325
  },
@@ -277,7 +327,7 @@
277
327
  "bytesInOutput": 0
278
328
  }
279
329
  },
280
- "bytes": 1820
330
+ "bytes": 1994
281
331
  }
282
332
  }
283
333
  }
package/meta.esm.json CHANGED
@@ -1,15 +1,46 @@
1
1
  {
2
2
  "inputs": {
3
- "libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
4
- "bytes": 3301,
3
+ "libs/connector-runtime-sdk/src/lib/types/action.ts": {
4
+ "bytes": 1556,
5
+ "imports": [],
6
+ "format": "esm"
7
+ },
8
+ "libs/connector-runtime-sdk/src/lib/types/kafka.ts": {
9
+ "bytes": 1115,
10
+ "imports": [],
11
+ "format": "esm"
12
+ },
13
+ "libs/connector-runtime-sdk/src/lib/types.ts": {
14
+ "bytes": 709,
5
15
  "imports": [
6
16
  {
7
- "path": "node:process",
17
+ "path": "./types/action",
8
18
  "kind": "import-statement",
9
19
  "external": true
10
20
  },
11
21
  {
12
- "path": "@xip-online-data/types",
22
+ "path": "./types/kafka",
23
+ "kind": "import-statement",
24
+ "external": true
25
+ },
26
+ {
27
+ "path": "libs/connector-runtime-sdk/src/lib/types/action.ts",
28
+ "kind": "import-statement",
29
+ "original": "./types/action"
30
+ },
31
+ {
32
+ "path": "libs/connector-runtime-sdk/src/lib/types/kafka.ts",
33
+ "kind": "import-statement",
34
+ "original": "./types/kafka"
35
+ }
36
+ ],
37
+ "format": "esm"
38
+ },
39
+ "libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
40
+ "bytes": 3285,
41
+ "imports": [
42
+ {
43
+ "path": "node:process",
13
44
  "kind": "import-statement",
14
45
  "external": true
15
46
  },
@@ -22,6 +53,11 @@
22
53
  "path": "./sdk",
23
54
  "kind": "import-statement",
24
55
  "external": true
56
+ },
57
+ {
58
+ "path": "./types",
59
+ "kind": "import-statement",
60
+ "external": true
25
61
  }
26
62
  ],
27
63
  "format": "esm"
@@ -32,10 +68,10 @@
32
68
  "format": "esm"
33
69
  },
34
70
  "libs/connector-runtime-sdk/src/lib/sdk/sdk.interface.ts": {
35
- "bytes": 1511,
71
+ "bytes": 1497,
36
72
  "imports": [
37
73
  {
38
- "path": "@xip-online-data/types",
74
+ "path": "../types",
39
75
  "kind": "import-statement",
40
76
  "external": true
41
77
  },
@@ -98,20 +134,20 @@
98
134
  "format": "esm"
99
135
  },
100
136
  "libs/connector-runtime-sdk/src/lib/sdk/offset-store.sdk.interface.ts": {
101
- "bytes": 359,
137
+ "bytes": 386,
102
138
  "imports": [],
103
139
  "format": "esm"
104
140
  },
105
141
  "libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
106
- "bytes": 467,
142
+ "bytes": 1114,
107
143
  "imports": [],
108
144
  "format": "esm"
109
145
  },
110
146
  "libs/connector-runtime-sdk/src/lib/sdk/receiver.sdk.interface.ts": {
111
- "bytes": 954,
147
+ "bytes": 940,
112
148
  "imports": [
113
149
  {
114
- "path": "@xip-online-data/types",
150
+ "path": "../types",
115
151
  "kind": "import-statement",
116
152
  "external": true
117
153
  }
@@ -217,8 +253,13 @@
217
253
  "format": "esm"
218
254
  },
219
255
  "libs/connector-runtime-sdk/src/index.ts": {
220
- "bytes": 150,
256
+ "bytes": 179,
221
257
  "imports": [
258
+ {
259
+ "path": "libs/connector-runtime-sdk/src/lib/types.ts",
260
+ "kind": "import-statement",
261
+ "original": "./lib/types"
262
+ },
222
263
  {
223
264
  "path": "libs/connector-runtime-sdk/src/lib/connector-runtime.ts",
224
265
  "kind": "import-statement",
@@ -248,7 +289,7 @@
248
289
  "imports": [],
249
290
  "exports": [],
250
291
  "inputs": {},
251
- "bytes": 5370
292
+ "bytes": 8396
252
293
  },
253
294
  "dist/libs/connector-runtime-sdk/index.js": {
254
295
  "imports": [
@@ -259,20 +300,31 @@
259
300
  }
260
301
  ],
261
302
  "exports": [
303
+ "ConnectorOrigin",
262
304
  "ConnectorRuntimeSDK",
305
+ "DEFAULT_TIMEOUT_SECONDS",
263
306
  "NullLogger"
264
307
  ],
265
308
  "entryPoint": "libs/connector-runtime-sdk/src/index.ts",
266
309
  "inputs": {
267
- "libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
268
- "bytesInOutput": 1003
310
+ "libs/connector-runtime-sdk/src/lib/types/action.ts": {
311
+ "bytesInOutput": 72
312
+ },
313
+ "libs/connector-runtime-sdk/src/lib/types.ts": {
314
+ "bytesInOutput": 0
269
315
  },
270
316
  "libs/connector-runtime-sdk/src/index.ts": {
271
317
  "bytesInOutput": 0
272
318
  },
319
+ "libs/connector-runtime-sdk/src/lib/connector-runtime.ts": {
320
+ "bytesInOutput": 1003
321
+ },
273
322
  "libs/connector-runtime-sdk/src/lib/sdk/index.ts": {
274
323
  "bytesInOutput": 0
275
324
  },
325
+ "libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
326
+ "bytesInOutput": 10
327
+ },
276
328
  "libs/connector-runtime-sdk/src/lib/support/null-logger.ts": {
277
329
  "bytesInOutput": 59
278
330
  },
@@ -280,7 +332,7 @@
280
332
  "bytesInOutput": 0
281
333
  }
282
334
  },
283
- "bytes": 1146
335
+ "bytes": 1278
284
336
  }
285
337
  }
286
338
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@transai/connector-runtime-sdk",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,5 +12,5 @@
12
12
  },
13
13
  "type": "commonjs",
14
14
  "main": "./index.cjs",
15
- "typings": "./index.d.ts"
16
- }
15
+ "typings": "./src/index.d.ts"
16
+ }
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './lib/types';
1
2
  export * from './lib/connector-runtime';
2
3
  export * from './lib/connector-runtime.interface';
3
4
  export * from './lib/sdk';
@@ -1,6 +1,6 @@
1
- import { KafkaCallbackResponse, BaseConnectorConfig, ActionInterface, ConnectorInterface, XodJobType } from '@xip-online-data/types';
2
1
  import { ConnectorRuntimeInterface } from './connector-runtime.interface';
3
2
  import { ConnectorSDKInterface } from './sdk';
3
+ import { ActionInterface, BaseConnectorConfig, ConnectorInterface, KafkaCallbackResponse, XodJobType } from './types';
4
4
  export interface IpcMessage {
5
5
  cmd: string;
6
6
  message: string;
@@ -9,4 +9,5 @@ export interface StoredOffset {
9
9
  export interface OffsetStoreSDKInterface {
10
10
  getOffset(identifier: string): Promise<StoredOffset>;
11
11
  setOffset(offset: StoredOffset, identifier: string): void;
12
+ flush(): Promise<void>;
12
13
  }
@@ -1,11 +1,28 @@
1
+ /** The default timeout is 10 minutes */
2
+ export declare const DEFAULT_TIMEOUT_SECONDS: number;
1
3
  export interface IntervalHandler {
2
4
  name?: string;
3
5
  onInit?: () => Promise<void> | void;
4
6
  onRun: () => Promise<void> | void;
5
7
  onStop?: () => Promise<void> | void;
6
8
  }
9
+ /**
10
+ * Options for configuring an interval registered via {@link ProcessingSDKInterface.registerInterval}.
11
+ */
7
12
  export type RegisterIntervalOptions = {
13
+ /**
14
+ * If true, the handler will be invoked immediately once on registration,
15
+ * in addition to subsequent scheduled executions.
16
+ */
8
17
  immediate?: boolean;
18
+ /**
19
+ * Optional timeout, in seconds, for the interval.
20
+ *
21
+ * This value should be a positive number representing the maximum time,
22
+ * in seconds, that the interval is allowed to run before being considered
23
+ * timed out. Callers should not pass 0 or negative values.
24
+ */
25
+ timeout?: number;
9
26
  };
10
27
  export interface ProcessingSDKInterface {
11
28
  registerInterval(intervalSeconds: number, handler: IntervalHandler, options?: RegisterIntervalOptions): Promise<string>;
@@ -1,4 +1,4 @@
1
- import { ActionInterface, KafkaCallbackResponse, KafkaCallbackResponseType, XodJobType } from '@xip-online-data/types';
1
+ import { ActionInterface, KafkaCallbackResponse, KafkaCallbackResponseType, XodJobType } from '../types';
2
2
  export interface ReceiverSDKInterface {
3
3
  readonly responses: {
4
4
  readonly ok: KafkaCallbackResponseType;
@@ -1,4 +1,4 @@
1
- import { BaseConnectorConfig } from '@xip-online-data/types';
1
+ import { BaseConnectorConfig } from '../types';
2
2
  import { FilesSDKInterface } from './files.sdk.interface';
3
3
  import { HttpClientSDKInterface, HttpConfig } from './http-client.interface';
4
4
  import { LoggerSDKInterface } from './logger.sdk.interface';
@@ -0,0 +1,49 @@
1
+ export declare enum ConnectorOrigin {
2
+ from_template = "from_template",
3
+ manual = "manual"
4
+ }
5
+ export interface LegacyOutputParameterInterface {
6
+ [key: string]: string;
7
+ }
8
+ export type SupportedOutputTypes = 'string' | 'number' | 'boolean' | 'array' | 'null';
9
+ export interface OutputItemParameterInterface {
10
+ type: SupportedOutputTypes | Array<SupportedOutputTypes>;
11
+ description?: string;
12
+ required?: boolean;
13
+ }
14
+ export interface ArrayOutputParameterInterface extends OutputItemParameterInterface {
15
+ type: 'array';
16
+ items: OutputParameterInterface;
17
+ }
18
+ export interface NumberOutputParameterInterface extends OutputItemParameterInterface {
19
+ type: 'number' | Array<'number' | 'null'>;
20
+ minimum?: number;
21
+ maximum?: number;
22
+ }
23
+ export interface OutputParameterInterface {
24
+ [key: string]: OutputItemParameterInterface | ArrayOutputParameterInterface | NumberOutputParameterInterface;
25
+ }
26
+ export interface InputParameterInterface {
27
+ name: string;
28
+ description?: string;
29
+ type: 'string' | 'number' | 'boolean' | 'array';
30
+ required?: boolean;
31
+ items?: Array<InputParameterInterface>;
32
+ }
33
+ export interface ActionInterface {
34
+ identifier: string;
35
+ version: string;
36
+ tenantIdentifier: string;
37
+ name: string;
38
+ description?: string;
39
+ connectorIdentifier: string;
40
+ config: {
41
+ [key: string]: {
42
+ [key: string]: string | object;
43
+ } | string | object;
44
+ };
45
+ inputParameters: Array<InputParameterInterface>;
46
+ outputParameters: LegacyOutputParameterInterface | OutputParameterInterface;
47
+ mode?: ConnectorOrigin;
48
+ createdAt: Date;
49
+ }
@@ -0,0 +1,40 @@
1
+ export interface KafkaBrokerConfig {
2
+ groupId: string;
3
+ clientId: string;
4
+ brokers: Array<string>;
5
+ sasl?: object;
6
+ intervalCheckForNewTopics?: number;
7
+ disableLogs?: boolean;
8
+ autoCommitThreshold?: number;
9
+ autoCommitInterval?: number;
10
+ partitionsConsumedConcurrently?: number;
11
+ useConfluentLibrary?: boolean;
12
+ newConsumerProtocol?: boolean;
13
+ }
14
+ export interface KafkaCallbackResponse<T = unknown> {
15
+ success: boolean;
16
+ statusCode: number;
17
+ message: string;
18
+ payload?: T;
19
+ }
20
+ export type KafkaCallbackResponseType<T = string> = (additionalMessage?: T) => (message: XodBaseMessageType) => Promise<KafkaCallbackResponse>;
21
+ export interface XodBaseMessageType {
22
+ type: 'ACTION' | 'EVENT' | 'SOURCE' | 'JOB';
23
+ eventId: string;
24
+ eventType: string;
25
+ eventTopic?: string;
26
+ created: number;
27
+ payload: object;
28
+ ttl: number;
29
+ tenantIdentifier: string;
30
+ testRun?: boolean;
31
+ meta?: {
32
+ [key: string]: unknown;
33
+ };
34
+ }
35
+ export interface XodJobType extends XodBaseMessageType {
36
+ type: 'JOB';
37
+ actionIdentifier: string;
38
+ actionVersion: string;
39
+ payload: Record<string, unknown>;
40
+ }
@@ -0,0 +1,26 @@
1
+ import { ActionInterface, ConnectorOrigin } from './types/action';
2
+ import { KafkaBrokerConfig } from './types/kafka';
3
+ export * from './types/action';
4
+ export * from './types/kafka';
5
+ export interface BaseConnectorConfig {
6
+ processIdentifier: string;
7
+ tenantIdentifier: string;
8
+ datasourceIdentifier: string;
9
+ kafka: KafkaBrokerConfig;
10
+ action?: {
11
+ timeSensitive: boolean;
12
+ };
13
+ }
14
+ export interface ConnectorInterface<T = Partial<BaseConnectorConfig>> {
15
+ identifier: string;
16
+ connectorType: string;
17
+ tenantIdentifier: string;
18
+ name: string;
19
+ location: string;
20
+ config?: T;
21
+ enabled: boolean;
22
+ actions?: Array<ActionInterface>;
23
+ mode?: ConnectorOrigin;
24
+ createdAt?: Date;
25
+ updatedAt?: Date;
26
+ }