feature/IO-3096-GlobalNotifications - Checkpoint, Builders

This commit is contained in:
Dave Richer
2025-02-18 12:57:54 -05:00
parent c214ed1dfb
commit adb15a4748
7 changed files with 149 additions and 138 deletions

View File

@@ -1,22 +1,5 @@
/**
* Parses an event by comparing old and new data to determine which fields have changed.
*
* @async
* @function eventParser
* @param {Object} params - The parameters for parsing the event.
* @param {Object} params.oldData - The previous state of the data. If not provided, the data is considered new.
* @param {Object} params.newData - The new state of the data.
* @param {string} params.trigger - The trigger that caused the event.
* @param {string} params.table - The name of the table where the event occurred.
* @param {string} [params.jobIdField] - The field name or key path (e.g., "req.body.event.new.jobid") used to extract the job ID.
* @returns {Promise<Object>} An object containing:
* - {string[]} changedFieldNames - An array of field names that have changed.
* - {Object} changedFields - An object mapping changed field names to an object with `old` and `new` values.
* - {boolean} isNew - Indicates if the event is for new data (i.e., no oldData exists).
* - {Object} data - The new data.
* - {string} trigger - The event trigger.
* - {string} table - The table name.
* - {string|null} jobId - The extracted job ID, if available.
*/
const eventParser = async ({ oldData, newData, trigger, table, jobIdField }) => {
const isNew = !oldData;