Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 3x 3x 122x 122x 179x 122x 3x | const { WORKFLOW_SYSTEM_KEYS } = require('./workflow-transitions')
/**
* Item attributes the server maintains: never taken from a client's `data`,
* on create as on update — otherwise a client could, for instance, write an
* item into another flow by sending its `flowId`.
*/
const ITEM_RESERVED_KEYS = [
'entityId',
'id',
'flowId',
'createdBy',
'createdAt',
'updatedAt',
...WORKFLOW_SYSTEM_KEYS
]
/**
* A copy of a client's item `data` without the reserved keys.
*
* @param {object} data
* @returns {object}
*/
function withoutReservedKeys(data) {
const filtered = {}
for (const [key, value] of Object.entries(data || {})) {
if (!ITEM_RESERVED_KEYS.includes(key)) filtered[key] = value
}
return filtered
}
module.exports = { ITEM_RESERVED_KEYS, withoutReservedKeys }
|