@elementumai/edk 0.13.0 → 0.13.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist-sdk/src/catalog/factories.js +8 -2
- package/dist-sdk/src/catalog/types.d.ts +5 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +12 -0
- package/dist-sdk/src/engine/coverage-gaps.js +23 -0
- package/dist-sdk/src/engine/ei/run.d.ts +8 -0
- package/dist-sdk/src/engine/ei/run.js +46 -7
- package/dist-sdk/src/engine/progress.d.ts +1 -0
- package/dist-sdk/src/engine/progress.js +6 -0
- package/dist-sdk/src/engine/pull/context.d.ts +24 -0
- package/dist-sdk/src/engine/pull/result-output.d.ts +2 -0
- package/dist-sdk/src/engine/pull/result-output.js +1 -1
- package/dist-sdk/src/engine/pull/stream-root.d.ts +11 -0
- package/dist-sdk/src/engine/pull/stream-root.js +22 -6
- package/dist-sdk/src/engine/tf/escape.d.ts +8 -3
- package/dist-sdk/src/engine/tf/escape.js +17 -4
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +4 -7
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +28 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/to-tf.js +21 -3
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +6 -23
- package/dist-sdk/src/entities/app/index.d.ts +1 -1
- package/dist-sdk/src/entities/app/module.js +2 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.js +2 -2
- package/dist-sdk/src/entities/automation/build.d.ts +10 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +1 -0
- package/dist-sdk/src/entities/automation/from-tf.js +72 -11
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +12 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
- package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/automation/to-tf.js +312 -51
- package/dist-sdk/src/entities/automation/triggers.d.ts +5 -1
- package/dist-sdk/src/entities/automation/workflow-output.d.ts +7 -0
- package/dist-sdk/src/entities/automation/workflow-output.js +8 -0
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- package/dist-sdk/src/entities/dynamic-layout/lint.d.ts +7 -0
- package/dist-sdk/src/entities/dynamic-layout/lint.js +48 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +2 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +5 -21
- package/dist-sdk/src/entities/element/index.d.ts +1 -1
- package/dist-sdk/src/entities/element/module.js +2 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +25 -2
- package/dist-sdk/src/entities/field/from-tf.js +119 -14
- package/dist-sdk/src/entities/relationship/from-tf.js +2 -2
- package/dist-sdk/src/entities/role/build.d.ts +3 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
- package/dist-sdk/src/entities/search-table/build.js +4 -4
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
- package/dist-sdk/src/entities/shared/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +24 -13
- package/dist-sdk/src/entities/shared/filters/index.js +12 -1
- package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +15 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +4 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +16 -0
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +2 -5
- package/dist-sdk/src/entities/task/from-tf.js +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +6 -4
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.d.ts +4 -2
- package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +6 -1
- package/dist-sdk/src/entities/view/agent-view-layout.d.ts +14 -2
- package/dist-sdk/src/entities/view/custom-view-references.d.ts +33 -0
- package/dist-sdk/src/entities/view/custom-view-references.js +140 -0
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +16 -9
- package/dist-sdk/src/entities/view/custom-view-validate.js +38 -18
- package/dist-sdk/src/entities/view/from-tf.js +9 -0
- package/dist-sdk/src/entities/view/layout-lint.d.ts +26 -0
- package/dist-sdk/src/entities/view/layout-lint.js +50 -0
- package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/to-tf.js +69 -47
- package/dist-sdk/src/entities/visual-flow/build.d.ts +8 -1
- package/dist-sdk/src/entities/visual-flow/from-tf.js +16 -0
- package/dist-sdk/src/entities/visual-flow/initiate.d.ts +12 -0
- package/dist-sdk/src/entities/visual-flow/initiate.js +12 -0
- package/dist-sdk/src/entities/visual-flow/module.js +52 -1
- package/dist-sdk/src/entities/visual-flow/to-tf.js +16 -2
- package/dist-sdk/src/entities/widget/from-tf.js +6 -6
- package/dist-sdk/src/graph/index.d.ts +4 -0
- package/dist-sdk/src/graph/index.js +1 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +36 -1
- package/package.json +2 -2
|
@@ -289,6 +289,190 @@ function onlyEntry(value, subject) {
|
|
|
289
289
|
}
|
|
290
290
|
return entries[0];
|
|
291
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* Record fields whose value is an object the platform writes into a field only
|
|
294
|
+
* by id (edk#2283, edk#2284). Its run-time converter takes a user id or email,
|
|
295
|
+
* a group id or name, or an option id or label. A whole user, group or option
|
|
296
|
+
* object fails the run, and a Multi-Select has no reference to its option ids.
|
|
297
|
+
*/
|
|
298
|
+
const OBJECT_VALUED_FIELD_KINDS = {
|
|
299
|
+
elementum_user_field: "user",
|
|
300
|
+
elementum_group_field: "group",
|
|
301
|
+
elementum_dropdown_field: "Dropdown",
|
|
302
|
+
elementum_multiselect_field: "Multi-Select",
|
|
303
|
+
};
|
|
304
|
+
const OBJECT_VALUED_TARGET_FIELD_TYPES = new Set([
|
|
305
|
+
"USER", "USER_ID", "GROUP", "GROUP_ID", "PICKLIST", "PICKLIST_ID", "MULTI_PICKLIST", "MULTI_PICKLIST_ID",
|
|
306
|
+
]);
|
|
307
|
+
/** The same kinds by catalog field type, for an owner known only from its generated catalog. */
|
|
308
|
+
const OBJECT_VALUED_CATALOG_FIELD_KINDS = {
|
|
309
|
+
USER: "user",
|
|
310
|
+
USER_ID: "user",
|
|
311
|
+
GROUP: "group",
|
|
312
|
+
GROUP_ID: "group",
|
|
313
|
+
PICKLIST: "Dropdown",
|
|
314
|
+
MULTI_PICKLIST: "Multi-Select",
|
|
315
|
+
};
|
|
316
|
+
/** System fields whose value is such an object. They have no field resource to read the type from. */
|
|
317
|
+
const OBJECT_VALUED_SYSTEM_FIELD_KINDS = {
|
|
318
|
+
createdBy: "user",
|
|
319
|
+
updatedBy: "user",
|
|
320
|
+
closedBy: "user",
|
|
321
|
+
status: "Dropdown",
|
|
322
|
+
stage: "Dropdown",
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* Fails a user, group, Dropdown or Multi-Select field assignment that reads a
|
|
326
|
+
* found or trigger record's whole user, group or option object, or any part
|
|
327
|
+
* of a Multi-Select. Build and plan pass those and the run fails. Pull keeps
|
|
328
|
+
* printing the live shape and only warns, as for a record-id field mapping.
|
|
329
|
+
*/
|
|
330
|
+
function assertRecordFieldValueIsWritable(reference, fieldToken, refs) {
|
|
331
|
+
const problem = recordFieldValueProblem(reference, fieldToken, refs);
|
|
332
|
+
if (problem === undefined)
|
|
333
|
+
return;
|
|
334
|
+
adviseWhileRecorded(refs, problem.finding, problem.message, "this assignment");
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* A finding the platform may already run: pull prints the live shape and
|
|
338
|
+
* warns; build and plan accept it only while the automation's revision record
|
|
339
|
+
* lists this exact finding from a pull or apply, and fail it otherwise
|
|
340
|
+
* (#2283). `subject` names the finding in that failure ("this assignment").
|
|
341
|
+
*/
|
|
342
|
+
function adviseWhileRecorded(refs, finding, message, subject) {
|
|
343
|
+
if (currentValidationMode() === "pull") {
|
|
344
|
+
// Pull prints the live shape and warns. Build writes the finding into the
|
|
345
|
+
// compiled file, so the pull's revision record keeps it as one the
|
|
346
|
+
// platform already runs (#2283).
|
|
347
|
+
refs.owner.advisoriesWhileRecorded?.push({ finding, advisory: message, error: message });
|
|
348
|
+
recordValidations([{
|
|
349
|
+
severity: "warning",
|
|
350
|
+
address: `${AUTOMATION_RESOURCE_TYPE}.${refs.owner.automationTfLabel}`,
|
|
351
|
+
name: refs.owner.automationTfLabel,
|
|
352
|
+
ownerKind: "automation",
|
|
353
|
+
message,
|
|
354
|
+
}]);
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
// An automation the platform already runs this way stays plannable while
|
|
358
|
+
// its revision record lists this exact finding from a pull or apply. Build
|
|
359
|
+
// decides that (it holds the record) and fails any finding the record
|
|
360
|
+
// doesn't list. Without the list there is no record to match, so fail.
|
|
361
|
+
if (!refs.owner.pulledLive || refs.owner.advisoriesWhileRecorded === undefined)
|
|
362
|
+
throw new EntityTfError(message);
|
|
363
|
+
refs.owner.advisoriesWhileRecorded.push({
|
|
364
|
+
finding,
|
|
365
|
+
advisory: `automation ${refs.owner.automationTfLabel}: ${message}`,
|
|
366
|
+
error: `${message} applied-automation-revisions.json doesn't record ${subject} from a pull or apply of this automation ` +
|
|
367
|
+
"(it is new, or the record predates EDK recording these), so build stops it. If the platform already runs it, " +
|
|
368
|
+
"pull the app or element again to record it.",
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
function recordFieldValueProblem(reference, fieldToken, refs) {
|
|
372
|
+
if (fieldToken?.fieldType === undefined || !OBJECT_VALUED_TARGET_FIELD_TYPES.has(fieldToken.fieldType))
|
|
373
|
+
return undefined;
|
|
374
|
+
const source = recordFieldSource(reference, refs);
|
|
375
|
+
if (source === undefined)
|
|
376
|
+
return undefined;
|
|
377
|
+
// An authored owner's field resources decide the kind. An owner known only
|
|
378
|
+
// from its generated catalog has none, so its catalog field types decide.
|
|
379
|
+
const address = source.addresses?.get(source.fieldKey);
|
|
380
|
+
const sourceType = address === undefined ? undefined : address.slice(0, address.indexOf("."));
|
|
381
|
+
const catalogTypes = source.addresses === undefined && source.ownerRefName !== undefined
|
|
382
|
+
? fieldNamesForAppRefName(refs.owner.catalogFieldTypesByAppRefName, source.ownerRefName)
|
|
383
|
+
: undefined;
|
|
384
|
+
const catalogType = catalogTypes?.get(source.fieldKey);
|
|
385
|
+
const kind = sourceType !== undefined ? OBJECT_VALUED_FIELD_KINDS[sourceType]
|
|
386
|
+
: catalogType !== undefined ? OBJECT_VALUED_CATALOG_FIELD_KINDS[catalogType]
|
|
387
|
+
: source.addresses !== undefined || catalogTypes !== undefined ? OBJECT_VALUED_SYSTEM_FIELD_KINDS[source.fieldKey]
|
|
388
|
+
: undefined;
|
|
389
|
+
const multiSelect = kind === "Multi-Select";
|
|
390
|
+
if (kind === undefined)
|
|
391
|
+
return undefined;
|
|
392
|
+
const target = fieldToken.name ?? fieldToken.refName;
|
|
393
|
+
// What the revision record keeps: the target field key and the source path as authored.
|
|
394
|
+
const finding = `${fieldToken.refName ?? target} <- ${source.path}`;
|
|
395
|
+
if (multiSelect) {
|
|
396
|
+
return { finding, message: `field "${target}" is set from ${source.path}, a Multi-Select. The platform has no reference to a Multi-Select's option ids, ` +
|
|
397
|
+
`so the run fails with "Unable to validate". Build a JSON list of the option ids (or, for another Multi-Select field, the labels) ` +
|
|
398
|
+
"in an executeScript, store it with setVariable, and set the field from that variable." };
|
|
399
|
+
}
|
|
400
|
+
if (source.rest.length > 0)
|
|
401
|
+
return undefined;
|
|
402
|
+
if (kind === "Dropdown") {
|
|
403
|
+
return { finding, message: `field "${target}" is set from ${source.path}, a whole Dropdown option. The platform writes a Dropdown only from an option id or label, ` +
|
|
404
|
+
`so the run fails. Set it from ${source.path}.id when it is the same field, or ${source.path}.label for another Dropdown, ` +
|
|
405
|
+
"since option ids belong to one field." };
|
|
406
|
+
}
|
|
407
|
+
return { finding, message: `field "${target}" is set from ${source.path}, a whole ${kind} object. The platform writes a ${kind} into a field only by id, ` +
|
|
408
|
+
`so the run fails. Set it from ${source.path}.id instead.` };
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* The record field a task, trigger, on-demand record parameter or record
|
|
412
|
+
* loop item reference reads, with the field addresses of the record's owner.
|
|
413
|
+
*/
|
|
414
|
+
function recordFieldSource(reference, refs) {
|
|
415
|
+
if (!isObject(reference))
|
|
416
|
+
return undefined;
|
|
417
|
+
const taskOwner = (taskRefKey) => {
|
|
418
|
+
const owner = refs.recordFieldContext?.taskAppRefNameByRefKey?.[taskRefKey] ?? refs.tasks.get(taskRefKey)?.recordTarget?.refName;
|
|
419
|
+
if (owner === undefined)
|
|
420
|
+
return { addresses: undefined };
|
|
421
|
+
if (owner === refs.owner.appRefName)
|
|
422
|
+
return { addresses: refs.owner.fieldAddresses };
|
|
423
|
+
return { addresses: fieldNamesForAppRefName(refs.owner.fieldAddressesByAppRefName, owner), ownerRefName: owner };
|
|
424
|
+
};
|
|
425
|
+
if (isObject(reference.taskReference) && typeof reference.taskReference.taskRefKey === "string" && typeof reference.taskReference.name === "string") {
|
|
426
|
+
const [head, fieldKey, ...rest] = normalizeIndexedRecordsFieldPath(reference.taskReference.name).split(".");
|
|
427
|
+
if (head !== "record" || fieldKey === undefined)
|
|
428
|
+
return undefined;
|
|
429
|
+
const taskRefKey = reference.taskReference.taskRefKey;
|
|
430
|
+
return {
|
|
431
|
+
path: `ctx.actions${sourceKeyAccessor(taskRefKey)}.${reference.taskReference.name.replace(/^records\.(\d+)\./, "records[$1].")}`,
|
|
432
|
+
fieldKey,
|
|
433
|
+
rest,
|
|
434
|
+
...taskOwner(taskRefKey),
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
if (isObject(reference.triggerReference) && typeof reference.triggerReference.name === "string") {
|
|
438
|
+
const name = reference.triggerReference.name;
|
|
439
|
+
const [head, fieldKey, ...rest] = name.split(".");
|
|
440
|
+
if (head === "record" && fieldKey !== undefined) {
|
|
441
|
+
return { path: `ctx.trigger.${name}`, fieldKey, rest, addresses: refs.owner.fieldAddresses };
|
|
442
|
+
}
|
|
443
|
+
const param = onDemandRecordFieldPath(name, refs);
|
|
444
|
+
if (param === undefined)
|
|
445
|
+
return undefined;
|
|
446
|
+
return {
|
|
447
|
+
path: `ctx.trigger${sourceKeyAccessor(param.paramName)}.${name.slice(param.paramName.length + 1)}`,
|
|
448
|
+
fieldKey: param.fieldKey,
|
|
449
|
+
rest: param.suffix === "" ? [] : param.suffix.split("."),
|
|
450
|
+
...(param.isOwner
|
|
451
|
+
? { addresses: refs.owner.fieldAddresses }
|
|
452
|
+
: { addresses: fieldNamesForAppRefName(refs.owner.fieldAddressesByAppRefName, param.target.refName), ownerRefName: param.target.refName }),
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
if (isObject(reference.forEachReference) && typeof reference.forEachReference.forEachTaskRefKey === "string" && typeof reference.forEachReference.name === "string") {
|
|
456
|
+
const loop = reference.forEachReference.forEachTaskRefKey;
|
|
457
|
+
const sourceTask = refs.recordItemForEachSourceByRefKey.get(loop);
|
|
458
|
+
if (sourceTask === undefined)
|
|
459
|
+
return undefined;
|
|
460
|
+
const [fieldKey, ...rest] = reference.forEachReference.name.split(".");
|
|
461
|
+
if (fieldKey === undefined || fieldKey === "")
|
|
462
|
+
return undefined;
|
|
463
|
+
return {
|
|
464
|
+
path: `ctx.loops${sourceKeyAccessor(loop)}.item.${reference.forEachReference.name}`,
|
|
465
|
+
fieldKey,
|
|
466
|
+
rest,
|
|
467
|
+
...taskOwner(sourceTask),
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
/** `.key`, or `["key"]` for a task or loop key that isn't an identifier, as pulled source writes it. */
|
|
473
|
+
function sourceKeyAccessor(key) {
|
|
474
|
+
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`;
|
|
475
|
+
}
|
|
292
476
|
/**
|
|
293
477
|
* Tasks whose refs carry every field of the record they search (edk#2280)
|
|
294
478
|
* or create (edk#2406), including system fields via object_fields /
|
|
@@ -1734,12 +1918,29 @@ const RECORD_COLLECTION_TASK_WIRE_TYPES = new Set([
|
|
|
1734
1918
|
const TS_FOR_EACH_GENERIC_SEGMENT_TO_WIRE = {
|
|
1735
1919
|
iteration: "Iteration",
|
|
1736
1920
|
};
|
|
1921
|
+
/**
|
|
1922
|
+
* A forEach item's loop metadata (`ctx.item.metadata.<name>`, every
|
|
1923
|
+
* collection kind) is not an item field. Filters spell it
|
|
1924
|
+
* `for_each.<id>.metadata.<name>`; the loop's refs map keys it by display
|
|
1925
|
+
* name (live availableReferences, #2922).
|
|
1926
|
+
*/
|
|
1927
|
+
const FOR_EACH_LOOP_METADATA_TO_WIRE = {
|
|
1928
|
+
"metadata.first": "Is First Item",
|
|
1929
|
+
"metadata.last": "Is Last Item",
|
|
1930
|
+
"metadata.iteration": "Iteration",
|
|
1931
|
+
"metadata.size": "Total Size",
|
|
1932
|
+
};
|
|
1933
|
+
function isForEachLoopMetadata(name) {
|
|
1934
|
+
return Object.hasOwn(FOR_EACH_LOOP_METADATA_TO_WIRE, name);
|
|
1935
|
+
}
|
|
1737
1936
|
function forEachWireRefName(name, ctx, isRecordCollection) {
|
|
1738
1937
|
// A recordSearch collection's whole item and branded record identity both
|
|
1739
1938
|
// point at the loop's ASPECT_RECORD_ID reference. Live provider state
|
|
1740
1939
|
// exposes that reference under "Record"; "ID" is a distinct TEXT handle.
|
|
1741
1940
|
if (name === "item" || name === "recordId")
|
|
1742
1941
|
return "Record";
|
|
1942
|
+
if (isForEachLoopMetadata(name))
|
|
1943
|
+
return FOR_EACH_LOOP_METADATA_TO_WIRE[name];
|
|
1743
1944
|
// Record fields are keyed by their platform display names, not their typed
|
|
1744
1945
|
// catalog handles. Reuse the same field/suffix mapping as trigger record
|
|
1745
1946
|
// paths.
|
|
@@ -1992,8 +2193,8 @@ function assertLiteralFitsFieldType(value, field) {
|
|
|
1992
2193
|
return;
|
|
1993
2194
|
const fieldType = field.fieldType;
|
|
1994
2195
|
const accepts = {
|
|
1995
|
-
USER: { test: (text) => UUID_PATTERN.test(text), expected: "a user id, or a user reference such as ctx.trigger.record.<userField
|
|
1996
|
-
GROUP: { test: (text) => UUID_PATTERN.test(text), expected: "a group id, or a group reference" },
|
|
2196
|
+
USER: { test: (text) => UUID_PATTERN.test(text), expected: "a user id, or a user id reference such as ctx.trigger.record.<userField>.id" },
|
|
2197
|
+
GROUP: { test: (text) => UUID_PATTERN.test(text), expected: "a group id, or a group id reference such as ctx.trigger.record.<groupField>.id" },
|
|
1997
2198
|
DATE: { test: (text) => ISO_DATE_PATTERN.test(text) && !Number.isNaN(Date.parse(text)), expected: "an ISO date (YYYY-MM-DD) or a date reference" },
|
|
1998
2199
|
DATETIME: {
|
|
1999
2200
|
test: (text) => ISO_DATETIME_PATTERN.test(text) && !Number.isNaN(Date.parse(text)),
|
|
@@ -2052,9 +2253,38 @@ function assertElementCreateSetsTitle(target, fields) {
|
|
|
2052
2253
|
}
|
|
2053
2254
|
}
|
|
2054
2255
|
/**
|
|
2055
|
-
*
|
|
2056
|
-
* workflow,
|
|
2057
|
-
*
|
|
2256
|
+
* An output must read a task of this automation, and (for new source) a task
|
|
2257
|
+
* at the top level of the workflow, not one inside a switch case, for-each
|
|
2258
|
+
* loop or fork/join branch.
|
|
2259
|
+
*
|
|
2260
|
+
* Evidence (mobius, 2026-11-18; ironman live test on the same day):
|
|
2261
|
+
* - The publish the provider uses, `workflowValidate(publishOnSuccess: true)`
|
|
2262
|
+
* (also the web app's v3 Publish button), checks each output against the
|
|
2263
|
+
* references available after the last top-level task
|
|
2264
|
+
* (`WorkflowValidationService.validateOutputReferences` and
|
|
2265
|
+
* `getOutputPropertyValidationResults`; the last task comes from
|
|
2266
|
+
* `WorkflowTaskRepository.findLastTaskIdByWorkflowIdAndVersion`, which
|
|
2267
|
+
* follows top-level tasks only, and `ValueReferenceService.getTaskChain`
|
|
2268
|
+
* walks back from it). A task inside a switch case, for-each loop or
|
|
2269
|
+
* fork/join branch is not among them, so the publish fails: "Output 'X' has
|
|
2270
|
+
* a value reference that is no longer valid." Saving such an output
|
|
2271
|
+
* succeeds; it reads back with `valid: false`. A fork/join in that chain
|
|
2272
|
+
* adds only the branch outputs its own output mappings promote
|
|
2273
|
+
* (`TaskChainValueRefCollector.collectForkJoinOutput`,
|
|
2274
|
+
* `TaskValueReferenceUtil.getForkJoinBranchGroups`). `elementum_fork_join_task`
|
|
2275
|
+
* carries no output mappings, so a fork/join built from source promotes none.
|
|
2276
|
+
* - The legacy admin automation page publishes with
|
|
2277
|
+
* `workflowUpdate(status: ACTIVE)`, which skips that check
|
|
2278
|
+
* (`WorkflowService.updateWorkflow`). Live automations with such outputs
|
|
2279
|
+
* exist that way (Sanofi Dev's luma app has 12). At run time a switch case's
|
|
2280
|
+
* task outputs are promoted past the switch and resolve; a for-each body's
|
|
2281
|
+
* are not, so that output is left out (`SwitchCaseNodeRunner`,
|
|
2282
|
+
* `EngineValueStore`).
|
|
2283
|
+
*
|
|
2284
|
+
* So pull prints such an output and records it, and build keeps it only
|
|
2285
|
+
* while the revision record lists it (#2283); a new one fails here. An apply
|
|
2286
|
+
* that republishes a recorded one still fails at the platform's publish
|
|
2287
|
+
* check until the output reads a top-level task.
|
|
2058
2288
|
*/
|
|
2059
2289
|
function assertPublishableOutputTask(outputName, value, topLevelTasks, refs) {
|
|
2060
2290
|
while (isObject(value) && "value" in value && Object.keys(value).length === 1) {
|
|
@@ -2066,10 +2296,11 @@ function assertPublishableOutputTask(outputName, value, topLevelTasks, refs) {
|
|
|
2066
2296
|
if (!refs.tasks.has(taskRefKey)) {
|
|
2067
2297
|
throw new EntityTfError(`automation output "${outputName}" references task "${taskRefKey}", which is not in this automation`);
|
|
2068
2298
|
}
|
|
2069
|
-
if (
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2299
|
+
if (topLevelTasks.some((task) => task.refKey === taskRefKey))
|
|
2300
|
+
return;
|
|
2301
|
+
adviseWhileRecorded(refs, `output ${JSON.stringify(outputName)} <- nested task ${JSON.stringify(taskRefKey)}`, `automation output "${outputName}" references task "${taskRefKey}" inside a switch case, for-each loop or fork/join branch; ` +
|
|
2302
|
+
"the platform's publish check accepts outputs only from top-level tasks, so an apply that publishes this automation fails. " +
|
|
2303
|
+
"Copy the value into a variable at the top level and output that.", "this output");
|
|
2073
2304
|
}
|
|
2074
2305
|
/**
|
|
2075
2306
|
* workflow_publish outputs must match provider Read / ei export: a typed
|
|
@@ -2093,9 +2324,15 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2093
2324
|
}
|
|
2094
2325
|
return valueToTf(value, refs);
|
|
2095
2326
|
}
|
|
2327
|
+
/** Tasks whose `record.<field>` outputs the platform stores by field id. */
|
|
2328
|
+
const RECORD_FIELD_ID_OUTPUT_TASK_TYPES = new Set([
|
|
2329
|
+
"elementum_create_record_task",
|
|
2330
|
+
"elementum_record_search_task",
|
|
2331
|
+
]);
|
|
2096
2332
|
/**
|
|
2097
|
-
* A `createRecord` task
|
|
2098
|
-
*
|
|
2333
|
+
* A field of the record a `createRecord` task made or a `recordSearch` task
|
|
2334
|
+
* found, in any app or element,
|
|
2335
|
+
* embedded as a LIVE field `.id` reference instead of a resolved display name.
|
|
2099
2336
|
* Confirmed live (demoapptwo, #1066): the platform stores this specific
|
|
2100
2337
|
* reference shape as `"record.<field-platform-id>.<suffix>"` — the SAME raw
|
|
2101
2338
|
* form the unresolved-field escape hatch above already reproduces for a
|
|
@@ -2110,26 +2347,30 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2110
2347
|
* pattern as `taskId`/`variableReference.name` just below), so this stays
|
|
2111
2348
|
* correct even across a field id change, unlike a literal string would.
|
|
2112
2349
|
*
|
|
2113
|
-
*
|
|
2114
|
-
*
|
|
2115
|
-
*
|
|
2116
|
-
*
|
|
2117
|
-
*
|
|
2350
|
+
* The suffix is optional and the field may be a system field of the created
|
|
2351
|
+
* record's own app or element: Under Armour's `TOOL_Create_Engagement_Record`
|
|
2352
|
+
* output `.record.id`, on a record of the Engagements element, exports as
|
|
2353
|
+
* `record.<Engagements ID field id>` (edk#2924). The field id resolves like a
|
|
2354
|
+
* filter value's found-record field (`foundRecordFieldReferenceName`): the
|
|
2355
|
+
* target's custom field resource, its `<owner>_<key>_field_id` system-field
|
|
2356
|
+
* local, or a `data.elementum_field` lookup for an app/element outside this
|
|
2357
|
+
* build. A field it can't resolve returns `undefined` and keeps the
|
|
2358
|
+
* display-name path.
|
|
2359
|
+
*
|
|
2360
|
+
* A recordSearch output reading a field of the record it found is stored the
|
|
2361
|
+
* same way (edk#3006): Sanofi Luma's `VC: Network ID Test` reads the found
|
|
2362
|
+
* record's Title as `record.<Title field id>`, and its iLearn automations
|
|
2363
|
+
* read the found user's title field (`USER_NAME`) the same way. The display
|
|
2364
|
+
* name ("Title", "USER_NAME") republished those automations on every plan
|
|
2365
|
+
* after a pull, and on ironman the platform rejects it at publish ("Output
|
|
2366
|
+
* ... has a value reference that is no longer valid"). findRelatedRecords
|
|
2367
|
+
* field access isn't confirmed for outputs and stays on the display-name path.
|
|
2118
2368
|
*/
|
|
2119
|
-
function
|
|
2120
|
-
if (target
|
|
2121
|
-
return undefined;
|
|
2122
|
-
const match = /^record\.([^.]+)\.(.+)$/.exec(name);
|
|
2123
|
-
if (match === null)
|
|
2124
|
-
return undefined;
|
|
2125
|
-
const [, fieldKey, suffix] = match;
|
|
2126
|
-
const fieldType = refs.owner.fieldMetadata.get(fieldKey)?.fieldType;
|
|
2127
|
-
if (fieldType === undefined)
|
|
2369
|
+
function recordFieldIdOutputRefTfValue(target, name, taskRefKey, refs) {
|
|
2370
|
+
if (target === undefined || !RECORD_FIELD_ID_OUTPUT_TASK_TYPES.has(target.type))
|
|
2128
2371
|
return undefined;
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2131
|
-
return undefined;
|
|
2132
|
-
return expr.template(["record.", fieldId, `.${suffix}`]);
|
|
2372
|
+
const parts = foundRecordFieldReferenceName(target.type, name, taskRefKey, refs);
|
|
2373
|
+
return parts === undefined ? undefined : expr.template(parts);
|
|
2133
2374
|
}
|
|
2134
2375
|
/**
|
|
2135
2376
|
* The canonical reference envelope for a workflow-OUTPUT task reference —
|
|
@@ -2140,7 +2381,7 @@ function createRecordOwnFieldRefTfValue(target, name, refs) {
|
|
|
2140
2381
|
* against that name (edk#835), so EDK emits it directly instead of the refs-map
|
|
2141
2382
|
* display label. The exceptions keep their existing resolution, since they
|
|
2142
2383
|
* reference FIELDS / declared values by EDK-owned names, not the mobius
|
|
2143
|
-
* display-label drift class: a task's
|
|
2384
|
+
* display-label drift class: a field of the task's record (`record.<field>`),
|
|
2144
2385
|
* aiAgent (platform-nested via {@link aiAgentPlatformRefName}), and file-reader
|
|
2145
2386
|
* (arbitrary schema field names). `fieldType`/`multiple` come from the generated
|
|
2146
2387
|
* service_tasks contract (via {@link publishOutputType}). Returns undefined when
|
|
@@ -2157,16 +2398,16 @@ function taskReferenceEnvelope(value, refs) {
|
|
|
2157
2398
|
const canonicalName = taskRef.name;
|
|
2158
2399
|
const isFileReaderTask = target.type === "elementum_ai_file_read_task" || target.type === "elementum_file_reader_task";
|
|
2159
2400
|
const isAiAgentTask = target.type === "elementum_ai_agent_task";
|
|
2160
|
-
// A task's
|
|
2401
|
+
// A field of the task's created/found record (`record.<field>`) is not a
|
|
2161
2402
|
// task-output name — it resolves by the field's own id/display name. No
|
|
2162
2403
|
// canonical output is ever spelled `record.<field>` (the contract has
|
|
2163
2404
|
// record/records/recordId), so that dotted prefix uniquely marks it.
|
|
2164
|
-
const
|
|
2165
|
-
const
|
|
2166
|
-
const platformRefName =
|
|
2405
|
+
const isRecordFieldRef = canonicalName.startsWith("record.");
|
|
2406
|
+
const recordFieldIdRef = recordFieldIdOutputRefTfValue(target, canonicalName, taskRef.taskRefKey, refs);
|
|
2407
|
+
const platformRefName = recordFieldIdRef
|
|
2167
2408
|
?? (isFileReaderTask
|
|
2168
2409
|
? canonicalName
|
|
2169
|
-
:
|
|
2410
|
+
: isRecordFieldRef
|
|
2170
2411
|
? taskWireRefName(canonicalName, taskRef.taskRefKey, refs)
|
|
2171
2412
|
: isAiAgentTask
|
|
2172
2413
|
? aiAgentPlatformRefName(canonicalName)
|
|
@@ -3171,6 +3412,11 @@ function filterReferenceToTf(value, refs, role = "value", realType, operator) {
|
|
|
3171
3412
|
const name = value.name === "recordId" ? "item" : value.name === "item" ? "" : value.name;
|
|
3172
3413
|
return expr.template(["for_each.", expr.resourceAttr(task.type, task.label, ["id"]), `.${name}`]);
|
|
3173
3414
|
}
|
|
3415
|
+
// The loop's own metadata is not a field of the iterated records:
|
|
3416
|
+
// export spells it `for_each.<id>.metadata.<name>` (#2922).
|
|
3417
|
+
if (isForEachLoopMetadata(value.name)) {
|
|
3418
|
+
return expr.template(["for_each.", expr.resourceAttr(task.type, task.label, ["id"]), `.${value.name}`]);
|
|
3419
|
+
}
|
|
3174
3420
|
// Filter export uses a compact field-ID path, not inner.refs (the
|
|
3175
3421
|
// script-input spelling) or the TypeScript property name. Resolve
|
|
3176
3422
|
// the collection's actual owner and preserve that export dialect.
|
|
@@ -3498,6 +3744,8 @@ function filterToTf(value, refs) {
|
|
|
3498
3744
|
return serializeFilterToTf(value, {
|
|
3499
3745
|
...(refs.allowUnknownPicklistOptions === true && { keepUnresolvedOptions: true }),
|
|
3500
3746
|
field: (field) => valueToTf(field, refs),
|
|
3747
|
+
// `userRef(email)` compares as the user's id, through the same user lookup a task value uses (#2891).
|
|
3748
|
+
user: (email) => valueToTf({ __kind: "user", email }, refs),
|
|
3501
3749
|
fieldFromLeftValue: (left) => fieldFromFilterLeftValue(left, refs),
|
|
3502
3750
|
reference: (reference, role, realType, operator) => filterReferenceToTf(reference, refs, role ?? "value", realType, operator),
|
|
3503
3751
|
referenceRealType: (reference, role, authored) => {
|
|
@@ -3551,11 +3799,16 @@ function filterToTf(value, refs) {
|
|
|
3551
3799
|
});
|
|
3552
3800
|
}
|
|
3553
3801
|
/**
|
|
3554
|
-
*
|
|
3555
|
-
*
|
|
3556
|
-
*
|
|
3802
|
+
* The platform-managed system fields (the platform marks them `system: true`;
|
|
3803
|
+
* Title, Status and Stage are not). A record trigger can list them in
|
|
3804
|
+
* changed_fields: the platform stores and publishes that. But it never fires on
|
|
3805
|
+
* one (edk#2989): ultron sends a system field's change in the event's
|
|
3806
|
+
* `systemChanges`, and mobius matches changed_fields only against `changes`
|
|
3807
|
+
* (`AspectRecordFilterService.filter` → `FieldsEntityEvent.getChanges()`).
|
|
3808
|
+
* Build keeps them as authored, since dropping one changes what the trigger
|
|
3809
|
+
* watches (an emptied list fires on every change), and warns instead.
|
|
3557
3810
|
*/
|
|
3558
|
-
const
|
|
3811
|
+
const NEVER_FIRING_SYSTEM_FIELD_KEYS = new Set(["id", "createdAt", "createdBy", "updatedAt", "updatedBy", "closedAt", "closedBy"]);
|
|
3559
3812
|
function isRunAutomationValueReference(raw) {
|
|
3560
3813
|
if (!isObject(raw))
|
|
3561
3814
|
return false;
|
|
@@ -3919,21 +4172,26 @@ function configAttrs(kind, config, refs) {
|
|
|
3919
4172
|
continue;
|
|
3920
4173
|
}
|
|
3921
4174
|
if (key === "changedFieldIds" && Array.isArray(raw)) {
|
|
3922
|
-
|
|
4175
|
+
// edk#2989: every listed field is kept, system fields included. Dropping
|
|
4176
|
+
// one changes what the trigger watches, and an emptied changed_fields
|
|
4177
|
+
// fires on every field change.
|
|
4178
|
+
const neverFiring = raw.flatMap((field) => {
|
|
3923
4179
|
const fieldToken = token(field);
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
refs.owner.fieldAddresses.has(fieldToken.refName)
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
return false;
|
|
4180
|
+
return fieldToken?.__kind === "field" &&
|
|
4181
|
+
NEVER_FIRING_SYSTEM_FIELD_KEYS.has(fieldToken.refName) &&
|
|
4182
|
+
!refs.owner.fieldAddresses.has(fieldToken.refName)
|
|
4183
|
+
? [`"${fieldToken.name ?? fieldToken.refName}"`]
|
|
4184
|
+
: [];
|
|
3930
4185
|
});
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
4186
|
+
if (neverFiring.length > 0) {
|
|
4187
|
+
refs.owner.diagnostics.push(`automation ${refs.owner.automationTfLabel}: changedFields lists system field${neverFiring.length > 1 ? "s" : ""} ${neverFiring.join(", ")}; ` +
|
|
4188
|
+
"the platform never fires a record trigger on a system field's change" +
|
|
4189
|
+
(neverFiring.length === raw.length
|
|
4190
|
+
? ", so this trigger never fires. "
|
|
4191
|
+
: ", so only the other listed fields fire it. ") +
|
|
4192
|
+
"Kept as listed: removing a field would change what the trigger watches (with none left, it fires on every change)");
|
|
3935
4193
|
}
|
|
3936
|
-
attrs.changed_fields = valueToTf(
|
|
4194
|
+
attrs.changed_fields = valueToTf(raw, refs);
|
|
3937
4195
|
continue;
|
|
3938
4196
|
}
|
|
3939
4197
|
if (key === "inputs" && kind === "elementum_on_demand_trigger") {
|
|
@@ -4014,6 +4272,7 @@ function configAttrs(kind, config, refs) {
|
|
|
4014
4272
|
? picklistAssignmentValueToTf(staticValue, fieldToken, refs)
|
|
4015
4273
|
: undefined;
|
|
4016
4274
|
let reference = field.valueReference;
|
|
4275
|
+
assertRecordFieldValueIsWritable(reference, fieldToken, refs);
|
|
4017
4276
|
if (typeof reference === "string") {
|
|
4018
4277
|
reference = normalizeTriggerRecordIdEnvelopeString(reference, refs);
|
|
4019
4278
|
}
|
|
@@ -4251,6 +4510,8 @@ export function automationToTf(entity, ctx) {
|
|
|
4251
4510
|
activeAutomationRefNames: ctx.activeAutomationRefNames,
|
|
4252
4511
|
...(ctx.elementsWithoutAuditFields !== undefined ? { elementsWithoutAuditFields: ctx.elementsWithoutAuditFields } : {}),
|
|
4253
4512
|
...(ctx.fieldAddressesByAppRefName !== undefined ? { fieldAddressesByAppRefName: ctx.fieldAddressesByAppRefName } : {}),
|
|
4513
|
+
...(ctx.catalogFieldTypesByAppRefName !== undefined ? { catalogFieldTypesByAppRefName: ctx.catalogFieldTypesByAppRefName } : {}),
|
|
4514
|
+
...(ctx.advisoriesWhileRecorded !== undefined ? { advisoriesWhileRecorded: ctx.advisoriesWhileRecorded } : {}),
|
|
4254
4515
|
...(ctx.authoredAspectKeys !== undefined ? { authoredAspectKeys: ctx.authoredAspectKeys } : {}),
|
|
4255
4516
|
recordLacksAuditFields: ctx.parentScope === "element" && ctx.ownerAuditFields !== true,
|
|
4256
4517
|
};
|
|
@@ -28,7 +28,11 @@ export interface RecordTriggerOutput<A extends AppOrElementRef = AppOrElementRef
|
|
|
28
28
|
}
|
|
29
29
|
export interface RecordTriggerOptions<A extends AppOrElementRef = AppOrElementRef> {
|
|
30
30
|
readonly app: A;
|
|
31
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Restrict to fire only when one of these fields changes. The platform never
|
|
33
|
+
* fires on a change to a platform-managed system field (ID, Created/Updated/
|
|
34
|
+
* Closed At and By); build keeps one you list and warns.
|
|
35
|
+
*/
|
|
32
36
|
readonly changedFields?: readonly FieldRef[];
|
|
33
37
|
readonly thinkUi?: boolean;
|
|
34
38
|
/**
|
|
@@ -8,6 +8,13 @@ export declare const workflowOutputType: {
|
|
|
8
8
|
readonly date: "date";
|
|
9
9
|
readonly datetime: "datetime";
|
|
10
10
|
readonly json: "json";
|
|
11
|
+
/**
|
|
12
|
+
* The type Elementum reports for a record's JSON field. Plan compares an
|
|
13
|
+
* output with the type of the field it reads, so an output that reads a
|
|
14
|
+
* JSON field needs this type, not `json` (a structured value such as an
|
|
15
|
+
* API response) (#3007).
|
|
16
|
+
*/
|
|
17
|
+
readonly jsonText: "jsonText";
|
|
11
18
|
readonly object: "object";
|
|
12
19
|
readonly record: "record";
|
|
13
20
|
readonly tableRecord: "tableRecord";
|
|
@@ -7,6 +7,13 @@ export const workflowOutputType = {
|
|
|
7
7
|
date: "date",
|
|
8
8
|
datetime: "datetime",
|
|
9
9
|
json: "json",
|
|
10
|
+
/**
|
|
11
|
+
* The type Elementum reports for a record's JSON field. Plan compares an
|
|
12
|
+
* output with the type of the field it reads, so an output that reads a
|
|
13
|
+
* JSON field needs this type, not `json` (a structured value such as an
|
|
14
|
+
* API response) (#3007).
|
|
15
|
+
*/
|
|
16
|
+
jsonText: "jsonText",
|
|
10
17
|
object: "object",
|
|
11
18
|
record: "record",
|
|
12
19
|
tableRecord: "tableRecord",
|
|
@@ -37,6 +44,7 @@ const WORKFLOW_OUTPUT_FIELD_TYPE = {
|
|
|
37
44
|
date: "DATE",
|
|
38
45
|
datetime: "DATETIME",
|
|
39
46
|
json: "JSON",
|
|
47
|
+
jsonText: "JSON_TEXT",
|
|
40
48
|
object: "OBJECT",
|
|
41
49
|
record: "ASPECT_RECORD_ID",
|
|
42
50
|
tableRecord: "TABLE_RECORD",
|
|
@@ -19,4 +19,6 @@ export interface DashboardOwner {
|
|
|
19
19
|
readonly fieldKeysByName?: ReadonlyMap<string, string | null>;
|
|
20
20
|
readonly unextractedFieldIds?: Set<string>;
|
|
21
21
|
}
|
|
22
|
-
export declare function dashboardsFromTf(blocks: readonly TfBlock[], widgetBlocks: readonly TfBlock[], owner: DashboardOwner, ctx: FromTfContext
|
|
22
|
+
export declare function dashboardsFromTf(blocks: readonly TfBlock[], widgetBlocks: readonly TfBlock[], owner: DashboardOwner, ctx: FromTfContext,
|
|
23
|
+
/** `elementum_dashboard_widget_order` blocks; each orders its dashboard's widgets. */
|
|
24
|
+
orderBlocks?: readonly TfBlock[]): NormalizedDashboard[];
|
|
@@ -5,6 +5,7 @@ import { filterFromTf } from "../access-policy/from-tf.js";
|
|
|
5
5
|
import { filterOwnerForAspect } from "../relationship/from-tf.js";
|
|
6
6
|
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
7
7
|
import { DASHBOARD_WIDGET_RESOURCE_TYPE } from "../dashboard-widget/module.js";
|
|
8
|
+
import { DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE, KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS, dashboardWidgetOrderFor, inDashboardWidgetOrder } from "../dashboard-widget-order/order.js";
|
|
8
9
|
import { DASHBOARD_RESOURCE_TYPE } from "./module.js";
|
|
9
10
|
import { CHART_RESOURCE_TYPE } from "../chart/types.js";
|
|
10
11
|
import { chartRefNameFromTfLabel } from "../chart/from-tf.js";
|
|
@@ -12,7 +13,9 @@ import { dashboardWidgetSize } from "./build.js";
|
|
|
12
13
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
13
14
|
import { managedViewSortFromTf } from "../view/from-tf.js";
|
|
14
15
|
const KNOWN_DASHBOARD_ATTRS = new Set(["name", "owner_id", "owner_type", "favorite", "tags"]);
|
|
15
|
-
export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx
|
|
16
|
+
export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx,
|
|
17
|
+
/** `elementum_dashboard_widget_order` blocks; each orders its dashboard's widgets. */
|
|
18
|
+
orderBlocks = []) {
|
|
16
19
|
const dashboards = [];
|
|
17
20
|
for (const block of blocks) {
|
|
18
21
|
const label = block.label;
|
|
@@ -32,7 +35,21 @@ export function dashboardsFromTf(blocks, widgetBlocks, owner, ctx) {
|
|
|
32
35
|
}
|
|
33
36
|
const tags = stringList(block.attrs, "tags", where, ctx);
|
|
34
37
|
const key = scopedLabelToBagKey(owner.ownerTfLabel, label, owner.scope);
|
|
35
|
-
const
|
|
38
|
+
const order = dashboardWidgetOrderFor(orderBlocks, DASHBOARD_RESOURCE_TYPE, label);
|
|
39
|
+
if (order !== undefined) {
|
|
40
|
+
const orderWhere = `${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE}.${order.label ?? "?"}`;
|
|
41
|
+
reportUnknownAttrs(order.attrs, KNOWN_DASHBOARD_WIDGET_ORDER_ATTRS, orderWhere, "dashboardsFromTf", ctx);
|
|
42
|
+
if (resourceRefLabel(order.attrs["owner_id"], owner.type) !== owner.label) {
|
|
43
|
+
ctx.diagnostics.push(`${orderWhere}: owner_id does not reference ${owner.type}.${owner.label}; widgets keep the export's order`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const ownedWidgets = widgetBlocks.filter((widget) => resourceRefLabel(widget.attrs["dashboard_id"], DASHBOARD_RESOURCE_TYPE) === label);
|
|
47
|
+
const orderedWidgets = order !== undefined && resourceRefLabel(order.attrs["owner_id"], owner.type) === owner.label
|
|
48
|
+
? inDashboardWidgetOrder(ownedWidgets, order)
|
|
49
|
+
: ownedWidgets;
|
|
50
|
+
const widgets = dashboardWidgetsFromTf(orderedWidgets, label, key, owner, ctx);
|
|
51
|
+
if (order !== undefined)
|
|
52
|
+
requireEveryWidget(order, ownedWidgets, widgets, label, ctx);
|
|
36
53
|
dashboards.push({
|
|
37
54
|
key,
|
|
38
55
|
name: optionalString(block.attrs, "name", where, ctx) ?? "",
|
|
@@ -122,6 +139,29 @@ function dashboardWidgetsFromTf(blocks, dashboardLabel, dashboardKey, owner, ctx
|
|
|
122
139
|
}];
|
|
123
140
|
});
|
|
124
141
|
}
|
|
142
|
+
/**
|
|
143
|
+
* The order's import lists every chart and records widget of the dashboard,
|
|
144
|
+
* but build lists only the widgets source holds. A widget this pull leaves out
|
|
145
|
+
* would therefore plan a reorder no source edit asked for, so the order is
|
|
146
|
+
* skipped and released with it. It runs after the widgets' own requirements,
|
|
147
|
+
* so a chart widget skipped for its chart takes the order along. The next
|
|
148
|
+
* plan imports the order for the widgets source holds (the kind's
|
|
149
|
+
* stateAdoption), so it plans no change.
|
|
150
|
+
*/
|
|
151
|
+
function requireEveryWidget(order, widgetBlocks, written, dashboardLabel, ctx) {
|
|
152
|
+
if (ctx.requiresExtracted === undefined)
|
|
153
|
+
return;
|
|
154
|
+
const address = `${DASHBOARD_WIDGET_ORDER_RESOURCE_TYPE}.${order.label ?? ""}`;
|
|
155
|
+
const writtenKeys = new Set(written.map((widget) => widget.key));
|
|
156
|
+
for (const block of widgetBlocks) {
|
|
157
|
+
const label = block.label ?? "";
|
|
158
|
+
const key = tfLabelToTsLabel(label.startsWith(`${dashboardLabel}_`) ? label.slice(dashboardLabel.length + 1) : label);
|
|
159
|
+
const requires = `${DASHBOARD_WIDGET_RESOURCE_TYPE}.${label}`;
|
|
160
|
+
ctx.requiresExtracted.push(writtenKeys.has(key)
|
|
161
|
+
? { address, requires, prune: (root) => root }
|
|
162
|
+
: { address, requires, unresolved: true, prune: (root) => root });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
125
165
|
/**
|
|
126
166
|
* The filter ranges over the target's records, so its fields may belong to
|
|
127
167
|
* the target rather than to the dashboard's owner. A raw field id decodes
|