UNPKG

zeebe-node

Version:

The Node.js client library for the Zeebe Workflow Automation Engine.

64 lines 2.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.decodeCreateZBWorkerSig = void 0; function isConfig(config) { return typeof config === 'object'; } const cleanEmpty = obj => Object.entries(obj) .map(([k, v]) => [ k, v && typeof v === 'object' ? !Array.isArray(v) ? cleanEmpty(v) : v : v, ]) .reduce((a, [k, v]) => (v == null ? a : { ...a, [k]: v }), {}); function decodeCreateZBWorkerSig(config) { const coerceConf = config.idOrTaskTypeOrConfig; const conf = isConfig(coerceConf) ? coerceConf : undefined; if (conf) { return cleanEmpty({ id: conf.id, onConnectionError: conf.onConnectionError, onReady: conf.onReady, options: { ...conf, onReady: undefined, taskHandler: undefined, taskType: undefined, }, taskHandler: conf.taskHandler, taskType: conf.taskType, }); } const isShorthandSig = typeof config.taskTypeOrTaskHandler === 'function'; const taskHandler = isShorthandSig ? config.taskTypeOrTaskHandler : config.taskHandlerOrOptions; const id = isShorthandSig ? config.idOrTaskTypeOrConfig : null; const taskType = isShorthandSig ? config.idOrTaskTypeOrConfig : config.taskTypeOrTaskHandler; const options = (isShorthandSig ? config.taskHandlerOrOptions : config.optionsOrOnConnectionError) || {}; const onConnectionError = isShorthandSig ? config.optionsOrOnConnectionError : config.onConnectionError || options.onConnectionError || config.onConnectionError; const onReady = options.onReady; return cleanEmpty({ id, onConnectionError, onReady, options, taskHandler, taskType, }); } exports.decodeCreateZBWorkerSig = decodeCreateZBWorkerSig; //# sourceMappingURL=ZBWorkerSignature.js.map