@transai/connector-runtime-sdk 0.9.2 → 0.11.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 +4 -4
- package/index.js +1 -1
- package/index.js.map +4 -4
- package/meta.cjs.json +9 -6
- package/meta.esm.json +9 -5
- package/package.json +1 -1
- package/src/lib/sdk/offset-store.sdk.interface.d.ts +1 -0
- package/src/lib/sdk/processing.sdk.interface.d.ts +17 -0
- package/src/lib/types/action.d.ts +17 -3
package/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.create;var i=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var P=Object.getPrototypeOf,x=Object.prototype.hasOwnProperty;var y=(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=d(r,o))||n.enumerable});return t};var b=(t,r,e)=>(e=t!=null?g(P(t)):{},m(r||!t||!t.__esModule?i(e,"default",{value:t,enumerable:!0}):e,t)),C=t=>m(i({},"__esModule",{value:!0}),t);var A={};y(A,{ConnectorOrigin:()=>f,ConnectorRuntimeSDK:()=>s,DEFAULT_TIMEOUT_SECONDS:()=>v,NullLogger:()=>p});module.exports=C(A);var f=(e=>(e.from_template="from_template",e.manual="manual",e))(f||{});var a=b(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(([c,u])=>{try{o[c]=e.templating.compile(u)}catch(l){e.logger.error(`Error compiling template ${c} for action ${n.identifier}`,l)}}),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 v=600;var p=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/types/action.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/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\
|
|
5
|
-
"mappings": "6iBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,wBAAAC,EAAA,eAAAC,IAAA,eAAAC,
|
|
6
|
-
"names": ["index_exports", "__export", "ConnectorOrigin", "ConnectorRuntimeSDK", "NullLogger", "__toCommonJS", "ConnectorOrigin", "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\ninterface BaseInputParameter {\n name: string;\n description?: string;\n required?: boolean;\n}\n\nexport interface ValueInputParameter extends BaseInputParameter {\n type: 'string' | 'number' | 'boolean';\n}\n\nexport interface SimpleArrayInputParameter extends BaseInputParameter {\n type: 'simple-array';\n itemType: 'string' | 'number' | 'boolean';\n}\n\nexport interface ArrayInputParameter extends BaseInputParameter {\n type: 'array';\n items: Array<InputParameterInterface>;\n}\n\nexport interface UnknownInputParameter extends BaseInputParameter {\n type: 'unknown';\n}\n\nexport type InputParameterInterface =\n | ValueInputParameter\n | SimpleArrayInputParameter\n | ArrayInputParameter\n | UnknownInputParameter;\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
|
-
var
|
|
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,c])=>{try{o[a]=e.templating.compile(c)}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/types/action.ts", "../../../libs/connector-runtime-sdk/src/lib/connector-runtime.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\
|
|
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,
|
|
6
|
-
"names": ["ConnectorOrigin", "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\ninterface BaseInputParameter {\n name: string;\n description?: string;\n required?: boolean;\n}\n\nexport interface ValueInputParameter extends BaseInputParameter {\n type: 'string' | 'number' | 'boolean';\n}\n\nexport interface SimpleArrayInputParameter extends BaseInputParameter {\n type: 'simple-array';\n itemType: 'string' | 'number' | 'boolean';\n}\n\nexport interface ArrayInputParameter extends BaseInputParameter {\n type: 'array';\n items: Array<InputParameterInterface>;\n}\n\nexport interface UnknownInputParameter extends BaseInputParameter {\n type: 'unknown';\n}\n\nexport type InputParameterInterface =\n | ValueInputParameter\n | SimpleArrayInputParameter\n | ArrayInputParameter\n | UnknownInputParameter;\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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"libs/connector-runtime-sdk/src/lib/types/action.ts": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 2066,
|
|
5
5
|
"imports": [],
|
|
6
6
|
"format": "esm"
|
|
7
7
|
},
|
|
@@ -134,12 +134,12 @@
|
|
|
134
134
|
"format": "esm"
|
|
135
135
|
},
|
|
136
136
|
"libs/connector-runtime-sdk/src/lib/sdk/offset-store.sdk.interface.ts": {
|
|
137
|
-
"bytes":
|
|
137
|
+
"bytes": 386,
|
|
138
138
|
"imports": [],
|
|
139
139
|
"format": "esm"
|
|
140
140
|
},
|
|
141
141
|
"libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
|
|
142
|
-
"bytes":
|
|
142
|
+
"bytes": 1114,
|
|
143
143
|
"imports": [],
|
|
144
144
|
"format": "esm"
|
|
145
145
|
},
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
"imports": [],
|
|
290
290
|
"exports": [],
|
|
291
291
|
"inputs": {},
|
|
292
|
-
"bytes":
|
|
292
|
+
"bytes": 9430
|
|
293
293
|
},
|
|
294
294
|
"dist/libs/connector-runtime-sdk/index.cjs": {
|
|
295
295
|
"imports": [
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
"entryPoint": "libs/connector-runtime-sdk/src/index.ts",
|
|
304
304
|
"inputs": {
|
|
305
305
|
"libs/connector-runtime-sdk/src/index.ts": {
|
|
306
|
-
"bytesInOutput":
|
|
306
|
+
"bytesInOutput": 131
|
|
307
307
|
},
|
|
308
308
|
"libs/connector-runtime-sdk/src/lib/types/action.ts": {
|
|
309
309
|
"bytesInOutput": 72
|
|
@@ -317,6 +317,9 @@
|
|
|
317
317
|
"libs/connector-runtime-sdk/src/lib/sdk/index.ts": {
|
|
318
318
|
"bytesInOutput": 0
|
|
319
319
|
},
|
|
320
|
+
"libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
|
|
321
|
+
"bytesInOutput": 10
|
|
322
|
+
},
|
|
320
323
|
"libs/connector-runtime-sdk/src/lib/support/null-logger.ts": {
|
|
321
324
|
"bytesInOutput": 59
|
|
322
325
|
},
|
|
@@ -324,7 +327,7 @@
|
|
|
324
327
|
"bytesInOutput": 0
|
|
325
328
|
}
|
|
326
329
|
},
|
|
327
|
-
"bytes":
|
|
330
|
+
"bytes": 1994
|
|
328
331
|
}
|
|
329
332
|
}
|
|
330
333
|
}
|
package/meta.esm.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"inputs": {
|
|
3
3
|
"libs/connector-runtime-sdk/src/lib/types/action.ts": {
|
|
4
|
-
"bytes":
|
|
4
|
+
"bytes": 2066,
|
|
5
5
|
"imports": [],
|
|
6
6
|
"format": "esm"
|
|
7
7
|
},
|
|
@@ -134,12 +134,12 @@
|
|
|
134
134
|
"format": "esm"
|
|
135
135
|
},
|
|
136
136
|
"libs/connector-runtime-sdk/src/lib/sdk/offset-store.sdk.interface.ts": {
|
|
137
|
-
"bytes":
|
|
137
|
+
"bytes": 386,
|
|
138
138
|
"imports": [],
|
|
139
139
|
"format": "esm"
|
|
140
140
|
},
|
|
141
141
|
"libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
|
|
142
|
-
"bytes":
|
|
142
|
+
"bytes": 1114,
|
|
143
143
|
"imports": [],
|
|
144
144
|
"format": "esm"
|
|
145
145
|
},
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
"imports": [],
|
|
290
290
|
"exports": [],
|
|
291
291
|
"inputs": {},
|
|
292
|
-
"bytes":
|
|
292
|
+
"bytes": 8928
|
|
293
293
|
},
|
|
294
294
|
"dist/libs/connector-runtime-sdk/index.js": {
|
|
295
295
|
"imports": [
|
|
@@ -302,6 +302,7 @@
|
|
|
302
302
|
"exports": [
|
|
303
303
|
"ConnectorOrigin",
|
|
304
304
|
"ConnectorRuntimeSDK",
|
|
305
|
+
"DEFAULT_TIMEOUT_SECONDS",
|
|
305
306
|
"NullLogger"
|
|
306
307
|
],
|
|
307
308
|
"entryPoint": "libs/connector-runtime-sdk/src/index.ts",
|
|
@@ -321,6 +322,9 @@
|
|
|
321
322
|
"libs/connector-runtime-sdk/src/lib/sdk/index.ts": {
|
|
322
323
|
"bytesInOutput": 0
|
|
323
324
|
},
|
|
325
|
+
"libs/connector-runtime-sdk/src/lib/sdk/processing.sdk.interface.ts": {
|
|
326
|
+
"bytesInOutput": 10
|
|
327
|
+
},
|
|
324
328
|
"libs/connector-runtime-sdk/src/lib/support/null-logger.ts": {
|
|
325
329
|
"bytesInOutput": 59
|
|
326
330
|
},
|
|
@@ -328,7 +332,7 @@
|
|
|
328
332
|
"bytesInOutput": 0
|
|
329
333
|
}
|
|
330
334
|
},
|
|
331
|
-
"bytes":
|
|
335
|
+
"bytes": 1278
|
|
332
336
|
}
|
|
333
337
|
}
|
|
334
338
|
}
|
package/package.json
CHANGED
|
@@ -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>;
|
|
@@ -23,13 +23,26 @@ export interface NumberOutputParameterInterface extends OutputItemParameterInter
|
|
|
23
23
|
export interface OutputParameterInterface {
|
|
24
24
|
[key: string]: OutputItemParameterInterface | ArrayOutputParameterInterface | NumberOutputParameterInterface;
|
|
25
25
|
}
|
|
26
|
-
|
|
26
|
+
interface BaseInputParameter {
|
|
27
27
|
name: string;
|
|
28
28
|
description?: string;
|
|
29
|
-
type: 'string' | 'number' | 'boolean' | 'array';
|
|
30
29
|
required?: boolean;
|
|
31
|
-
items?: Array<InputParameterInterface>;
|
|
32
30
|
}
|
|
31
|
+
export interface ValueInputParameter extends BaseInputParameter {
|
|
32
|
+
type: 'string' | 'number' | 'boolean';
|
|
33
|
+
}
|
|
34
|
+
export interface SimpleArrayInputParameter extends BaseInputParameter {
|
|
35
|
+
type: 'simple-array';
|
|
36
|
+
itemType: 'string' | 'number' | 'boolean';
|
|
37
|
+
}
|
|
38
|
+
export interface ArrayInputParameter extends BaseInputParameter {
|
|
39
|
+
type: 'array';
|
|
40
|
+
items: Array<InputParameterInterface>;
|
|
41
|
+
}
|
|
42
|
+
export interface UnknownInputParameter extends BaseInputParameter {
|
|
43
|
+
type: 'unknown';
|
|
44
|
+
}
|
|
45
|
+
export type InputParameterInterface = ValueInputParameter | SimpleArrayInputParameter | ArrayInputParameter | UnknownInputParameter;
|
|
33
46
|
export interface ActionInterface {
|
|
34
47
|
identifier: string;
|
|
35
48
|
version: string;
|
|
@@ -47,3 +60,4 @@ export interface ActionInterface {
|
|
|
47
60
|
mode?: ConnectorOrigin;
|
|
48
61
|
createdAt: Date;
|
|
49
62
|
}
|
|
63
|
+
export {};
|