UNPKG

@chevre/domain

Version:

Chevre Domain Library for Node.js

52 lines (51 loc) 2.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createInformTasks = createInformTasks; const factory = require("../../../factory"); function createInformTasks(order, // settings: Settings, setting) { var _a; const taskRunsAt = new Date(); const informOrder = (_a = setting === null || setting === void 0 ? void 0 : setting.onOrderStatusChanged) === null || _a === void 0 ? void 0 : _a.informOrder; const informTasks = []; const order4inform = creteOrder4inform(order); if (Array.isArray(informOrder) && informOrder.length > 0) { const recipientId = ''; informOrder.forEach((informOrderParams) => { var _a, _b; if (typeof ((_a = informOrderParams.recipient) === null || _a === void 0 ? void 0 : _a.url) === 'string') { const informActionAttributes = { about: { orderNumber: order4inform.orderNumber, typeOf: factory.order.OrderType.Order }, object: order4inform, recipient: { // url: informOrderParams.recipient.url, // discontinue(2025-02-13~) id: recipientId, name: (_b = informOrderParams.recipient) === null || _b === void 0 ? void 0 : _b.name, typeOf: factory.creativeWorkType.WebApplication }, target: { httpMethod: 'POST', encodingType: factory.encodingFormat.Application.json, typeOf: 'EntryPoint', urlTemplate: informOrderParams.recipient.url } }; informTasks.push({ project: order.project, name: factory.taskName.TriggerWebhook, status: factory.taskStatus.Ready, runsAt: taskRunsAt, remainingNumberOfTries: 10, numberOfTried: 0, executionResults: [], data: informActionAttributes }); } }); } return informTasks; } function creteOrder4inform(order) { return order; }