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 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 217x 1269x 168x 215x 1864x 146x 5x 141x 36x 47x 47x 6x 23x 23x 323x 30x 128x 72x 6x 57x 12x 13x 5x 8x 2x 7x 53x 53x 53x 54x 63x 63x 63x 130x 130x 3x 127x 1x 630x 126x 2x 124x 124x 9x 3x 6x 60x 60x 60x 2x 115x 8x 1x 7x 107x 107x 1x 106x 6x 1x 5x 5x 3x 1x 2x 2x 2x 100x 198x 1x 84x 58x 1x 14x 14x 3x 11x 2x 9x 8x 8x 2x 6x 90x 90x 7x 83x 83x 2x 81x 2x 79x 79x 79x 52x 27x 2x 25x 4x 3x 2x 21x 1x 4x 8x 2x 6x 8x 5x 3x 143x 12x 10x 18x 1x 40x 51x 59x 9x 1x 23x 9x 15x 2x 17x 12x 12x 3x 2x 2x 4x 3x 1x 29x 26x 26x 3x 115x 115x 115x 108x 107x 12x 33x 31x 31x 29x 29x 28x 2x 20x 20x 3x 2x 1x 4x 4x 2x 2x 5x 5x 3x 2x 1x 16x 16x 15x 15x 14x 15x 15x 15x 15x 15x 4x 16x 16x 16x 15x 4x 11x 15x 15x 16x 16x 2x 150x 132x 146x 141x 139x 138x 16x 16x 1x 1x 122x 105x 105x 103x 17x 17x 15x 15x 15x 15x 12x 12x 12x 20x 23x | // @implements UC-WORKFLOW-007.1, UC-WORKFLOW-009.1
/**
* Condition trees of automatic workflow transitions (see
* docs/architecture/AUTOMATION.md "Condition language").
*
* A node is exactly one of:
* { all: [node, ...] } AND
* { any: [node, ...] } OR
* { not: node } NOT
* { field, op, value? } leaf on one of the item's fields
* { via, field, op, value? } leaf on the item linked through the
* `via` single entity_ref field (UC-WORKFLOW-008.1)
* { formula } leaf holding a boolean formula (./formula.js)
*
* Validated against the entity's fields when the entity is saved, evaluated
* by this module when an item is saved — never run as code.
*/
const { isDeletedPlaceholder } = require('../deletedPlaceholder')
const { isValidDateString, normalizeOptionValues } = require('../schemas/item-data-schema')
const {
FormulaError,
EvaluationError,
parse,
typeCheck,
evaluate,
referencedFields,
formulaTypeOfField
} = require('./formula')
const MAX_CONDITION_DEPTH = 5
const MAX_CONDITION_LEAVES = 50
const MAX_VALUE_LIST_LENGTH = 100
const OPERATORS_BY_KIND = {
text: ['eq', 'neq', 'contains', 'startsWith', 'isEmpty', 'isNotEmpty'],
number: ['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'isEmpty', 'isNotEmpty'],
date: ['eq', 'neq', 'lt', 'lte', 'gt', 'gte', 'isEmpty', 'isNotEmpty'],
boolean: ['eq'],
choice: ['eq', 'neq', 'in', 'notIn', 'isEmpty', 'isNotEmpty'],
multiselect: ['contains', 'containsAll', 'containsAny', 'isEmpty', 'isNotEmpty'],
reference: ['eq', 'contains', 'isEmpty', 'isNotEmpty', 'countLt', 'countGt', 'countEq']
}
const NODE_KEYS = ['all', 'any', 'not', 'field', 'formula']
// A date relative to the moment the condition is evaluated: { now: "-3d" }
const RELATIVE_DATE_PATTERN = /^[+-]?\d+[hd]$/
const MS_PER_HOUR = 60 * 60 * 1000
/**
* The item's system dates a condition can use like fields (UC-WORKFLOW-009.1):
* `createdAt`, `updatedAt` and, per workflow field, when it entered its
* current state (`workflowStateEnteredAt.{fieldId}`). Type `datetime`: an ISO
* timestamp, unlike a `date` field's YYYY-MM-DD.
*
* @param {object[]} fields - Entity field definitions
* @returns {object[]}
*/
function systemDateFields(fields) {
return [
{ fieldId: 'createdAt', type: 'datetime' },
{ fieldId: 'updatedAt', type: 'datetime' },
...(fields || [])
.filter((field) => field.type === 'workflow')
.map((field) => ({ fieldId: `workflowStateEnteredAt.${field.fieldId}`, type: 'datetime' }))
]
}
/**
* An entity's fields plus its system dates, by fieldId.
*
* @param {object[]} fields
* @returns {Map<string, object>}
*/
function conditionFieldsById(fields) {
return new Map(
[...(fields || []), ...systemDateFields(fields)].map((field) => [field.fieldId, field])
)
}
/**
* An item's value for a fieldId, system dates included.
*
* @param {object} item
* @param {string} fieldId
* @returns {unknown}
*/
function readItemField(item, fieldId) {
if (typeof fieldId === 'string' && fieldId.startsWith('workflowStateEnteredAt.')) {
return item.workflowStateEnteredAt?.[fieldId.slice('workflowStateEnteredAt.'.length)]
}
return item[fieldId]
}
function isRelativeDate(value) {
return (
!!value &&
typeof value === 'object' &&
Object.keys(value).length === 1 &&
typeof value.now === 'string' &&
RELATIVE_DATE_PATTERN.test(value.now)
)
}
/**
* The offset of a duration such as "3d", "-12h" or "+1d", in ms.
*
* @param {string} duration
* @returns {number}
*/
function durationMs(duration) {
const amount = parseInt(duration.slice(0, -1), 10)
return amount * (duration.endsWith('h') ? MS_PER_HOUR : 24 * MS_PER_HOUR)
}
function dayOf(ms) {
return new Date(ms).toISOString().slice(0, 10)
}
const LEAF_KEYS = ['field', 'op', 'value']
const LINKED_LEAF_KEYS = ['via', ...LEAF_KEYS]
/**
* How a field type behaves in a condition leaf, or null when it can't be used.
*
* @param {string} type - Entity field type
* @returns {keyof OPERATORS_BY_KIND | null}
*/
function leafKind(type) {
switch (type) {
case 'text':
case 'textarea':
case 'email':
return 'text'
case 'number':
return 'number'
case 'date':
case 'datetime':
return 'date'
case 'boolean':
return 'boolean'
case 'select':
case 'workflow':
return 'choice'
case 'multiselect':
return 'multiselect'
case 'user':
case 'entity_ref':
return 'reference'
default:
return null
}
}
/**
* The values a select/multiselect/workflow leaf may compare with.
*
* @param {object} field
* @returns {string[]}
*/
function allowedChoices(field) {
if (field.type === 'workflow') {
return (field.workflowDefinition?.states || []).map((state) => state.id)
}
return normalizeOptionValues(field.options)
}
function invalid(code, message, path, position) {
const error = { code, message, path }
if (position !== undefined) error.position = position
return { valid: false, error }
}
// ---------------------------------------------------------------------------
// Validation
// ---------------------------------------------------------------------------
/**
* Whether an entity_ref field may be used as `via`: a single link (one item
* at most) to an entity. Multiple links are never usable in a condition —
* "the linked item's field" must be one value (decided October 31, 2026).
*
* @param {object | undefined} field
* @returns {boolean}
*/
function isLinkableReference(field) {
return (
field?.type === 'entity_ref' && !!field.reference?.entityId && field.reference.multiple !== true
)
}
/**
* Validates a condition tree against the entity's fields.
*
* `linkedEntities` (entity id → entity) holds the entities targeted by `via`
* rows: a row on a linked entity missing from it is rejected. Without it
* (bundle import, whose targets aren't resolved yet), linked rows are only
* checked for shape; a linked field that doesn't exist then reads as false.
*
* @param {unknown} condition - The `auto.when` value
* @param {object[]} fields - The entity's (new) field definitions
* @param {{ linkedEntities?: Map<string, object> }} [options]
* @returns {{ valid: true } | { valid: false, error: { code: string, message: string, path: string, position?: number } }}
*/
function validateCondition(condition, fields, options = {}) {
const fieldsById = conditionFieldsById(fields)
const state = { leaves: 0, linkedEntities: options.linkedEntities }
return validateNode(condition, fieldsById, '', 1, state)
}
function validateNode(node, fieldsById, path, depth, state) {
const here = path || 'when'
if (!node || typeof node !== 'object' || Array.isArray(node)) {
return invalid('INVALID_CONDITION_NODE', 'A condition must be an object', here)
}
if (depth > MAX_CONDITION_DEPTH) {
return invalid(
'CONDITION_TOO_DEEP',
`Conditions can be nested ${MAX_CONDITION_DEPTH} levels deep at most`,
here
)
}
const kinds = NODE_KEYS.filter((key) => key in node)
if (kinds.length !== 1) {
return invalid(
'INVALID_CONDITION_NODE',
`A condition has exactly one of ${NODE_KEYS.join(', ')}`,
here
)
}
const [kind] = kinds
if (kind === 'all' || kind === 'any') {
if (Object.keys(node).length !== 1 || !Array.isArray(node[kind]) || node[kind].length === 0) {
return invalid('INVALID_CONDITION_NODE', `"${kind}" must be a non-empty list`, here)
}
for (let i = 0; i < node[kind].length; i++) {
const childPath = `${path ? `${path}.` : ''}${kind}[${i}]`
const result = validateNode(node[kind][i], fieldsById, childPath, depth + 1, state)
if (!result.valid) return result
}
return { valid: true }
}
if (kind === 'not') {
if (Object.keys(node).length !== 1) {
return invalid('INVALID_CONDITION_NODE', '"not" has no other key', here)
}
return validateNode(node.not, fieldsById, `${path ? `${path}.` : ''}not`, depth + 1, state)
}
state.leaves++
if (state.leaves > MAX_CONDITION_LEAVES) {
return invalid(
'CONDITION_TOO_MANY_LEAVES',
`A condition has ${MAX_CONDITION_LEAVES} rows at most`,
here
)
}
return kind === 'formula'
? validateFormulaLeaf(node, fieldsById, here)
: validateFieldLeaf(node, fieldsById, here, state.linkedEntities)
}
function validateFormulaLeaf(node, fieldsById, path) {
if (Object.keys(node).length !== 1) {
return invalid('INVALID_CONDITION_NODE', 'A formula row has no other key', path)
}
try {
const type = typeCheck(parse(node.formula), fieldsById)
if (type !== 'boolean') {
return invalid(
'FORMULA_NOT_BOOLEAN',
`A condition formula must be true or false, not ${type}`,
path,
0
)
}
return { valid: true }
} catch (error) {
Eif (error instanceof FormulaError) {
return invalid(error.code, error.message, path, error.position)
}
/* istanbul ignore next -- parse/typeCheck only throw FormulaError */
throw error
}
}
function validateFieldLeaf(node, fieldsById, path, linkedEntities) {
if ('via' in node) return validateLinkedLeaf(node, fieldsById, path, linkedEntities)
if (Object.keys(node).some((key) => !LEAF_KEYS.includes(key))) {
return invalid('INVALID_CONDITION_NODE', `A row only has ${LEAF_KEYS.join(', ')}`, path)
}
return validateRowOn(node, fieldsById, path)
}
// A row on the item linked through `via` (UC-WORKFLOW-008.1), one hop only
function validateLinkedLeaf(node, fieldsById, path, linkedEntities) {
if (Object.keys(node).some((key) => !LINKED_LEAF_KEYS.includes(key))) {
return invalid(
'INVALID_CONDITION_NODE',
`A linked row only has ${LINKED_LEAF_KEYS.join(', ')}`,
path
)
}
const viaField = fieldsById.get(node.via)
if (!viaField || viaField.type !== 'entity_ref' || !viaField.reference?.entityId) {
return invalid('INVALID_LINKED_REFERENCE', `"${node.via}" is not an item link field`, path)
}
if (!isLinkableReference(viaField)) {
return invalid(
'LINKED_REFERENCE_MULTIPLE',
`"${node.via}" allows several items: only a single link can be used in a condition`,
path
)
}
if (!linkedEntities) return { valid: true }
const target = linkedEntities.get(viaField.reference.entityId)
if (!target) {
return invalid('UNKNOWN_LINKED_ENTITY', 'The linked entity no longer exists', path)
}
return validateRowOn(node, conditionFieldsById(target.fields), path)
}
// Checks a row's field, operator and value against the given fields
function validateRowOn(node, fieldsById, path) {
const field = fieldsById.get(node.field)
if (!field) {
return invalid('UNKNOWN_CONDITION_FIELD', `Unknown field "${node.field}"`, path)
}
const kind = leafKind(field.type)
if (!kind) {
return invalid(
'UNSUPPORTED_CONDITION_FIELD',
`A ${field.type} field can't be used in a condition`,
path
)
}
if (!OPERATORS_BY_KIND[kind].includes(node.op)) {
return invalid(
'INVALID_CONDITION_OPERATOR',
`Operator "${node.op}" is not available for a ${field.type} field`,
path
)
}
const message = checkLeafValue(field, kind, node.op, node.value)
return message ? invalid('INVALID_CONDITION_VALUE', message, path) : { valid: true }
}
// Returns an error message, or undefined when the value fits the operator
function checkLeafValue(field, kind, op, value) {
if (op === 'isEmpty' || op === 'isNotEmpty') {
return value === undefined ? undefined : `"${op}" takes no value`
}
if (op === 'countLt' || op === 'countGt' || op === 'countEq') {
return Number.isInteger(value) && value >= 0 ? undefined : 'Expected a whole number'
}
if (op === 'in' || op === 'notIn' || op === 'containsAll' || op === 'containsAny') {
if (!Array.isArray(value) || value.length === 0 || value.length > MAX_VALUE_LIST_LENGTH) {
return `Expected a list of 1 to ${MAX_VALUE_LIST_LENGTH} values`
}
return value.map((entry) => checkChoice(field, entry)).find(Boolean)
}
switch (kind) {
case 'text':
case 'reference':
return typeof value === 'string' && value !== '' ? undefined : 'Expected a text'
case 'number':
return typeof value === 'number' && Number.isFinite(value) ? undefined : 'Expected a number'
case 'date':
return isValidDateString(value) || isRelativeDate(value)
? undefined
: 'Expected a date (YYYY-MM-DD) or { now: "-3d" }'
case 'boolean':
return typeof value === 'boolean' ? undefined : 'Expected true or false'
default:
// choice (eq/neq) and multiselect (contains)
return checkChoice(field, value)
}
}
function checkChoice(field, value) {
if (typeof value !== 'string' || !allowedChoices(field).includes(value)) {
return `"${value}" is not ${field.type === 'workflow' ? 'a state' : 'an option'} of this field`
}
return undefined
}
// ---------------------------------------------------------------------------
// Evaluation
// ---------------------------------------------------------------------------
function isEmptyValue(value) {
return (
value === undefined ||
value === null ||
value === '' ||
isDeletedPlaceholder(value) ||
(Array.isArray(value) && value.length === 0)
)
}
// A text value is a plain string or a multilingual { lang: string } object
function textValues(value) {
if (typeof value === 'string') return value === '' ? [] : [value]
if (value && typeof value === 'object' && !Array.isArray(value)) {
return Object.values(value).filter((v) => typeof v === 'string' && v !== '')
}
return []
}
function referenceValues(value) {
const values = Array.isArray(value) ? value : [value]
return values.filter((v) => !isEmptyValue(v))
}
function compareScalar(op, actual, expected) {
switch (op) {
case 'eq':
return actual === expected
case 'neq':
return actual !== expected
case 'lt':
return actual < expected
case 'lte':
return actual <= expected
case 'gt':
return actual > expected
default:
return actual >= expected
}
}
function evaluateTextLeaf(op, value, expected) {
const values = textValues(value).map((v) => v.toLowerCase())
const target = typeof expected === 'string' ? expected.toLowerCase() : expected
switch (op) {
case 'eq':
return values.includes(target)
case 'neq':
return !values.includes(target)
case 'contains':
return values.some((v) => v.includes(target))
case 'startsWith':
return values.some((v) => v.startsWith(target))
case 'isEmpty':
return values.length === 0
default:
return values.length > 0
}
}
// The two sides of a date comparison: a `date` field compares days
// (YYYY-MM-DD), a system date compares instants against a relative date and
// days against an absolute one.
function dateOperands(field, value, expected, now) {
if (isRelativeDate(expected)) {
const ms = now + durationMs(expected.now)
return field.type === 'date' ? [value, dayOf(ms)] : [Date.parse(value), ms]
}
return [String(value).slice(0, 10), expected]
}
function evaluateFieldLeaf(leaf, item, field, now = Date.now()) {
const value = readItemField(item, leaf.field)
const { op, value: expected } = leaf
if (op === 'isEmpty' && leafKind(field.type) !== 'text') return isEmptyValue(value)
if (op === 'isNotEmpty' && leafKind(field.type) !== 'text') return !isEmptyValue(value)
switch (leafKind(field.type)) {
case 'text':
return evaluateTextLeaf(op, value, expected)
case 'number':
if (isEmptyValue(value)) return op === 'neq'
return compareScalar(op, value, expected)
case 'date': {
if (isEmptyValue(value)) return op === 'neq'
const [actual, target] = dateOperands(field, value, expected, now)
if (Number.isNaN(actual)) return op === 'neq'
return compareScalar(op, actual, target)
}
case 'boolean':
return (value === true) === expected
case 'choice': {
const actual = isEmptyValue(value) ? null : value
if (op === 'eq') return actual === expected
if (op === 'neq') return actual !== expected
if (op === 'in') return expected.includes(actual)
return !expected.includes(actual)
}
case 'multiselect': {
const values = Array.isArray(value) ? value : []
if (op === 'contains') return values.includes(expected)
if (op === 'containsAll') return expected.every((v) => values.includes(v))
return expected.some((v) => values.includes(v))
}
default: {
// reference
const values = referenceValues(value)
if (op === 'eq' || op === 'contains') return values.includes(expected)
if (op === 'countLt') return values.length < expected
if (op === 'countGt') return values.length > expected
return values.length === expected
}
}
}
// A formula reading multilingual text fields is evaluated once per language
// present in them, and holds if it holds in any language — the same "any
// language" rule as text rows.
function evaluateFormulaLeaf(leaf, item, fieldsById, compiled, now) {
let ast = compiled.get(leaf.formula)
if (!ast) {
ast = parse(leaf.formula)
typeCheck(ast, fieldsById)
compiled.set(leaf.formula, ast)
}
const languages = new Set()
for (const fieldId of referencedFields(ast)) {
const value = readItemField(item, fieldId)
const field = fieldsById.get(fieldId)
if (formulaTypeOfField(field) === 'text' && value && typeof value === 'object') {
Eif (!Array.isArray(value)) Object.keys(value).forEach((lang) => languages.add(lang))
}
}
const readField = (lang) => (fieldId) => {
const value = readItemField(item, fieldId)
if (isDeletedPlaceholder(value)) return null
if (lang && value && typeof value === 'object' && !Array.isArray(value)) {
return value[lang] ?? null
}
return value
}
const variants = languages.size > 0 ? [...languages] : [null]
return variants.some((lang) => {
try {
return evaluate(ast, readField(lang), now) === true
} catch (error) {
Eif (error instanceof EvaluationError) return false
throw error
}
})
}
/**
* Evaluates a condition tree on an item. Expects a tree accepted by
* validateCondition() for the same fields; a field deleted since reads as
* empty, and a formula that no longer type-checks makes its row false.
*
* @param {object | undefined} condition - The `auto.when` value (undefined = always true)
* @param {object} item - The item's field values, keyed by fieldId
* @param {object[]} fields - The entity's field definitions
* @param {Map<string, object>} [compiled] - Parsed-formula cache, shared across calls
* @returns {boolean}
*/
function evaluateCondition(
condition,
item,
fields,
compiled = new Map(),
linked = undefined,
now = Date.now()
) {
if (condition === undefined || condition === null) return true
return evaluateNode(condition, {
item,
fieldsById: conditionFieldsById(fields),
compiled,
linked,
now
})
}
function evaluateNode(node, ctx) {
if (Array.isArray(node.all)) return node.all.every((child) => evaluateNode(child, ctx))
if (Array.isArray(node.any)) return node.any.some((child) => evaluateNode(child, ctx))
if (node.not) return !evaluateNode(node.not, ctx)
if (typeof node.formula === 'string') {
try {
return evaluateFormulaLeaf(node, ctx.item, ctx.fieldsById, ctx.compiled, ctx.now)
} catch (error) {
console.error('Condition formula no longer valid:', error.message)
return false
}
}
if (typeof node.via === 'string') return evaluateLinkedLeaf(node, ctx)
const field = ctx.fieldsById.get(node.field)
if (!field || !leafKind(field.type)) return false
return evaluateFieldLeaf(node, ctx.item, field, ctx.now)
}
// No linked item, or one that couldn't be read (deleted, or in another
// flow's non-public entity), reads as an item with every field empty: "is
// empty" holds, "is CDI" doesn't.
function evaluateLinkedLeaf(node, ctx) {
const viaField = ctx.fieldsById.get(node.via)
if (!isLinkableReference(viaField)) return false
const entityId = viaField.reference.entityId
const target = ctx.linked?.entities.get(entityId)
const field = target && conditionFieldsById(target.fields).get(node.field)
if (!field || !leafKind(field.type)) return false
const [id] = referenceValues(ctx.item[node.via])
const linkedItem = (id && ctx.linked.items.get(linkedItemKey(entityId, id))) || {}
return evaluateFieldLeaf(node, linkedItem, field, ctx.now)
}
/**
* The key of a linked item in `linked.items` (see ./linkedItems.js).
*
* @param {string} entityId
* @param {string} itemId
* @returns {string}
*/
function linkedItemKey(entityId, itemId) {
return `${entityId}#${itemId}`
}
module.exports = {
durationMs,
readItemField,
systemDateFields,
isLinkableReference,
linkedItemKey,
referenceValues,
MAX_CONDITION_DEPTH,
MAX_CONDITION_LEAVES,
OPERATORS_BY_KIND,
leafKind,
validateCondition,
evaluateCondition
}
|