feature/IO-3096-GlobalNotifications - Checkpoint
This commit is contained in:
@@ -4474,6 +4474,9 @@
|
||||
- name: event-secret
|
||||
value_from_env: EVENT_SECRET
|
||||
request_transform:
|
||||
body:
|
||||
action: transform
|
||||
template: "{\r\n \"event\": {\r\n \"op\": \"UPDATE\",\r\n \"data\": {\r\n \"old\": {\r\n \"id\": {{$body.event.data.old.id}},\r\n \"ro_number\": {{$body.event.data.old.ro_number}},\r\n \"queued_for_parts\": {{$body.event.data.old.queued_for_parts}},\r\n \"employee_prep\": {{$body.event.data.old.employee_prep}},\r\n \"clm_total\": {{$body.event.data.old.clm_total}},\r\n \"towin\": {{$body.event.data.old.towin}},\r\n \"employee_body\": {{$body.event.data.old.employee_body}},\r\n \"converted\": {{$body.event.data.old.converted}},\r\n \"scheduled_in\": {{$body.event.data.old.scheduled_in}},\r\n \"scheduled_completion\": {{$body.event.data.old.scheduled_completion}},\r\n \"scheduled_delivery\": {{$body.event.data.old.scheduled_delivery}},\r\n \"actual_delivery\": {{$body.event.data.old.actual_delivery}},\r\n \"actual_completion\": {{$body.event.data.old.actual_completion}},\r\n \"alt_transport\": {{$body.event.data.old.alt_transport}},\r\n \"date_exported\": {{$body.event.data.old.date_exported}},\r\n \"status\": {{$body.event.data.old.status}},\r\n \"employee_csr\": {{$body.event.data.old.employee_csr}},\r\n \"actual_in\": {{$body.event.data.old.actual_in}},\r\n \"deliverchecklist\": {{$body.event.data.old.deliverchecklist}},\r\n \"comment\": {{$body.event.data.old.comment}},\r\n \"employee_refinish\": {{$body.event.data.old.employee_refinish}},\r\n \"inproduction\": {{$body.event.data.old.inproduction}},\r\n \"production_vars\": {{$body.event.data.old.production_vars}},\r\n \"intakechecklist\": {{$body.event.data.old.intakechecklist}},\r\n \"cieca_ttl\": {{$body.event.data.old.cieca_ttl}},\r\n \"date_invoiced\": {{$body.event.data.old.date_invoiced}}\r\n },\r\n \"new\": {\r\n \"id\": {{$body.event.data.new.id}},\r\n \"ro_number\": {{$body.event.data.old.ro_number}},\r\n \"queued_for_parts\": {{$body.event.data.new.queued_for_parts}},\r\n \"employee_prep\": {{$body.event.data.new.employee_prep}},\r\n \"clm_total\": {{$body.event.data.new.clm_total}},\r\n \"towin\": {{$body.event.data.new.towin}},\r\n \"employee_body\": {{$body.event.data.new.employee_body}},\r\n \"converted\": {{$body.event.data.new.converted}},\r\n \"scheduled_in\": {{$body.event.data.new.scheduled_in}},\r\n \"scheduled_completion\": {{$body.event.data.new.scheduled_completion}},\r\n \"scheduled_delivery\": {{$body.event.data.new.scheduled_delivery}},\r\n \"actual_delivery\": {{$body.event.data.new.actual_delivery}},\r\n \"actual_completion\": {{$body.event.data.new.actual_completion}},\r\n \"alt_transport\": {{$body.event.data.new.alt_transport}},\r\n \"date_exported\": {{$body.event.data.new.date_exported}},\r\n \"status\": {{$body.event.data.new.status}},\r\n \"employee_csr\": {{$body.event.data.new.employee_csr}},\r\n \"actual_in\": {{$body.event.data.new.actual_in}},\r\n \"deliverchecklist\": {{$body.event.data.new.deliverchecklist}},\r\n \"comment\": {{$body.event.data.new.comment}},\r\n \"employee_refinish\": {{$body.event.data.new.employee_refinish}},\r\n \"inproduction\": {{$body.event.data.new.inproduction}},\r\n \"production_vars\": {{$body.event.data.new.production_vars}},\r\n \"intakechecklist\": {{$body.event.data.new.intakechecklist}},\r\n \"cieca_ttl\": {{$body.event.data.new.cieca_ttl}},\r\n \"date_invoiced\": {{$body.event.data.new.date_invoiced}}\r\n }\r\n }\r\n },\r\n \"trigger\": {\r\n \"name\": \"notifications_jobs\"\r\n },\r\n \"table\": {\r\n \"schema\": \"public\",\r\n \"name\": \"jobs\"\r\n }\r\n}\r\n"
|
||||
method: POST
|
||||
query_params: {}
|
||||
template_engine: Kriti
|
||||
|
||||
@@ -2,9 +2,10 @@ const scenarioParser = require("../utils/scenarioParser");
|
||||
|
||||
const handleJobsChange = async (req, res) => {
|
||||
const { logger } = req;
|
||||
scenarioParser(req, `req.body.event.new.id`).catch((e) =>
|
||||
logger.log("notifications-error", "error", "notifications", null, { error: e?.message })
|
||||
);
|
||||
scenarioParser(req, `req.body.event.new.id`).catch((e) => {
|
||||
console.dir(e);
|
||||
logger.log("notifications-error", "error", "notifications", null, { error: e?.message });
|
||||
});
|
||||
return res.status(200).json({ message: "Job Notifications Event Handled." });
|
||||
};
|
||||
//
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const consoleDir = require("../../utils/consoleDir");
|
||||
|
||||
const jobAssignedToMeBuilder = (data) => {
|
||||
consoleDir(data);
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ const { client: gqlClient } = require("../../graphql-client/graphql-client");
|
||||
const queries = require("../../graphql-client/queries");
|
||||
const { isEmpty, isFunction } = require("lodash");
|
||||
const { getMatchingScenarios } = require("./scenarioMapperr");
|
||||
const { writeFile } = require("node:fs").promises;
|
||||
|
||||
const scenarioParser = async (req, jobIdField) => {
|
||||
// Destructure required fields from the request body
|
||||
@@ -121,23 +122,21 @@ const scenarioParser = async (req, jobIdField) => {
|
||||
if (isEmpty(scenario.scenarioWatchers) || !isFunction(scenario.builder)) {
|
||||
continue;
|
||||
}
|
||||
scenario
|
||||
.builder({
|
||||
trigger: finalScenarioData.trigger.name,
|
||||
bodyShopId: finalScenarioData.bodyShopId,
|
||||
bodyShopName: finalScenarioData.bodyShopName,
|
||||
scenarioKey: scenario.key,
|
||||
scenarioTable: scenario.table,
|
||||
scenarioFields: scenario.fields,
|
||||
scenarioBuilder: scenario.builder,
|
||||
scenarioWatchers: scenario.scenarioWatchers,
|
||||
jobId: finalScenarioData.jobId,
|
||||
isNew: finalScenarioData.isNew,
|
||||
changedFieldNames: finalScenarioData.changedFieldNames,
|
||||
changedFields: finalScenarioData.changedFields,
|
||||
data: finalScenarioData.data
|
||||
})
|
||||
.catch((error) => console.error(`Error in builder for scenario '${scenario.key}':`, error));
|
||||
scenario.builder({
|
||||
trigger: finalScenarioData.trigger.name,
|
||||
bodyShopId: finalScenarioData.bodyShopId,
|
||||
bodyShopName: finalScenarioData.bodyShopName,
|
||||
scenarioKey: scenario.key,
|
||||
scenarioTable: scenario.table,
|
||||
scenarioFields: scenario.fields,
|
||||
scenarioBuilder: scenario.builder,
|
||||
scenarioWatchers: scenario.scenarioWatchers,
|
||||
jobId: finalScenarioData.jobId,
|
||||
isNew: finalScenarioData.isNew,
|
||||
changedFieldNames: finalScenarioData.changedFieldNames,
|
||||
changedFields: finalScenarioData.changedFields,
|
||||
data: finalScenarioData.data
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user