UNPKG

@villedemontreal/workit-stepfunction-client

Version:

Camunda BPM client for WorkIt that works with Camunda platform powered by TypeScript

50 lines 1.96 kB
"use strict"; /* * Copyright (c) 2025 Ville de Montreal. All rights reserved. * Licensed under the MIT license. * See LICENSE file in the project root for full license information. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.SfnMessage = void 0; const sfnSqsMapperProperties_1 = require("./sfnSqsMapperProperties"); const datetime_1 = require("./utils/datetime"); const params_1 = require("./config/constants/params"); class SfnMessage { static wrap(payload, repo) { const { Body } = payload; const msg = (!params_1.DISABLE_DATETIME_REVIVER ? JSON.parse(Body || '{}', datetime_1.dateTimeReviver) : JSON.parse(Body || '{}')) || Object.create(null); const properties = sfnSqsMapperProperties_1.SfnSqsMapperProperties.map({ ...payload, Body: msg }); const messageWithoutSpan = { body: msg.body, properties }; return [ messageWithoutSpan, { hasBeenThreated: false, /** * Acknowledge the message to Step functions platform */ async ack(message) { if (this.hasBeenThreated) { return Promise.resolve(); } await repo.sendTaskSuccess(message); this.hasBeenThreated = true; }, /** * Un acknowledge the message to Step functions platform * This will handle failure. */ async nack(error) { if (this.hasBeenThreated) { return Promise.resolve(); } await repo.sendTaskFailure(error, messageWithoutSpan); this.hasBeenThreated = true; }, }, ]; } } exports.SfnMessage = SfnMessage; //# sourceMappingURL=sfnMessage.js.map