@elementumai/edk 0.13.1 → 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/dist-sdk/src/engine/coverage-gaps.d.ts +10 -0
- package/dist-sdk/src/engine/coverage-gaps.js +19 -0
- 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/result-output.d.ts +2 -0
- package/dist-sdk/src/engine/pull/result-output.js +1 -1
- 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/entities/app/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/to-tf.js +94 -33
- 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/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/index.d.ts +1 -1
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- 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 +10 -5
- package/dist-sdk/src/entities/view/custom-view-validate.js +2 -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 +3 -0
- 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/to-tf.js +16 -2
- package/package.json +1 -1
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
* (edk#2250; the mapping is emitted, and the called workflow fails at run time)
|
|
16
16
|
* - a synchronous Dynamic Reference runAutomation inside a forEach (edk#1870;
|
|
17
17
|
* the task is emitted, and the caller never resumes at run time)
|
|
18
|
+
* - a live automation output that reads a task inside a switch case, for-each
|
|
19
|
+
* loop or fork/join branch (edk#2988; the output is emitted, and a republish
|
|
20
|
+
* fails the platform's publish check)
|
|
21
|
+
* - a record trigger's changedFields listing a platform-managed system field
|
|
22
|
+
* (edk#2989; the field is kept, and the platform never fires on its change)
|
|
18
23
|
* - the custom-view non-PanesBlock root hint (check.mjs `warn`; the layout is
|
|
19
24
|
* emitted exactly as authored, edk#1771)
|
|
20
25
|
* - a custom-view binding to a path missing from spec.state (the page reads it
|
|
@@ -22,6 +27,11 @@
|
|
|
22
27
|
* - the executeScript lint for an undeclared input, an output no return sets
|
|
23
28
|
* (edk#2286), or a script with no top-level return (edk#2364); the script is
|
|
24
29
|
* emitted as authored
|
|
30
|
+
* - the record details layout checks (edk#1774): an empty classic group, a
|
|
31
|
+
* group of more than 12 fields or of more than 8 at maxColumns 1, a
|
|
32
|
+
* right-panel section sharing a displayOrder with a main-area one, and in
|
|
33
|
+
* dynamic layouts an empty container or more than 8 stacked fields; the
|
|
34
|
+
* layout is emitted as authored
|
|
25
35
|
*
|
|
26
36
|
* The ~600 emit sites push free-form `"<where>: <what>; dropped"` strings.
|
|
27
37
|
* Rather than rewrite every site, they are classified here, where they leave
|
|
@@ -15,6 +15,11 @@
|
|
|
15
15
|
* (edk#2250; the mapping is emitted, and the called workflow fails at run time)
|
|
16
16
|
* - a synchronous Dynamic Reference runAutomation inside a forEach (edk#1870;
|
|
17
17
|
* the task is emitted, and the caller never resumes at run time)
|
|
18
|
+
* - a live automation output that reads a task inside a switch case, for-each
|
|
19
|
+
* loop or fork/join branch (edk#2988; the output is emitted, and a republish
|
|
20
|
+
* fails the platform's publish check)
|
|
21
|
+
* - a record trigger's changedFields listing a platform-managed system field
|
|
22
|
+
* (edk#2989; the field is kept, and the platform never fires on its change)
|
|
18
23
|
* - the custom-view non-PanesBlock root hint (check.mjs `warn`; the layout is
|
|
19
24
|
* emitted exactly as authored, edk#1771)
|
|
20
25
|
* - a custom-view binding to a path missing from spec.state (the page reads it
|
|
@@ -22,6 +27,11 @@
|
|
|
22
27
|
* - the executeScript lint for an undeclared input, an output no return sets
|
|
23
28
|
* (edk#2286), or a script with no top-level return (edk#2364); the script is
|
|
24
29
|
* emitted as authored
|
|
30
|
+
* - the record details layout checks (edk#1774): an empty classic group, a
|
|
31
|
+
* group of more than 12 fields or of more than 8 at maxColumns 1, a
|
|
32
|
+
* right-panel section sharing a displayOrder with a main-area one, and in
|
|
33
|
+
* dynamic layouts an empty container or more than 8 stacked fields; the
|
|
34
|
+
* layout is emitted as authored
|
|
25
35
|
*
|
|
26
36
|
* The ~600 emit sites push free-form `"<where>: <what>; dropped"` strings.
|
|
27
37
|
* Rather than rewrite every site, they are classified here, where they leave
|
|
@@ -37,10 +47,19 @@ const ADVISORY_DIAGNOSTICS = [
|
|
|
37
47
|
// [\s\S]* and anchor on the fixed rest of the message, end included (the label is a sanitized TF label).
|
|
38
48
|
/^automation \S+: task "[\s\S]*" is a synchronous Dynamic Reference runAutomation inside forEach "[\s\S]*"; the platform never resumes the caller after the called automation finishes, so the steps after it never run and the run stays parked\. Move the call out of the forEach, or call a known automation by its catalog ref \(Select Automation\)$/,
|
|
39
49
|
/^automation \S+: field ".*" is set from .+, a (?:whole|Multi-Select)/,
|
|
50
|
+
// edk#2988. Output and task names are quoted as authored, so match them with [\s\S]*.
|
|
51
|
+
/^automation \S+: automation output "[\s\S]*" references task "[\s\S]*" inside a switch case, for-each loop or fork\/join branch; the platform's publish check accepts outputs only from top-level tasks/,
|
|
52
|
+
// edk#2989. Field names are quoted as authored; anchor on the fixed rest of the message.
|
|
53
|
+
/^automation \S+: changedFields lists system fields? [\s\S]*; the platform never fires a record trigger on a system field's change, so (?:this trigger never fires|only the other listed fields fire it)\. Kept as listed: removing a field would change what the trigger watches \(with none left, it fires on every change\)$/,
|
|
40
54
|
/^automation \S+: executeScript ".*" (?:reads input|declares output|has no top-level return) /,
|
|
41
55
|
/^applied-automation-revisions\.json .*; until then no automation is checked for an edit without a revision bump$/,
|
|
42
56
|
/\.root: "[^"]*" is (?:untyped|a [A-Za-z0-9_]+); the root is usually a PanesBlock \(needed for record lists to open the details pane\)$/,
|
|
43
57
|
/: binds to "[^"]*", which is not in spec\.state, so it starts undefined\. Add an initial value there to set its default\.$/,
|
|
58
|
+
// edk#1774 record details layout checks (src/entities/view/layout-lint.ts, src/entities/dynamic-layout/lint.ts).
|
|
59
|
+
// Section names are quoted as authored, so match them with [\s\S]* and anchor on the fixed rest of the message.
|
|
60
|
+
/\.sections\[\d+\](?: \("[\s\S]*"\))?: group section (?:has no fields, widgets or agent, so the record page shows an empty section; add fields or remove it|holds \d+ fields; split them into labeled groups \(key fields first\) so the record page doesn't read as one long list|stacks \d+ fields in one column \(maxColumns: 1\); use maxColumns: 2 or split it into labeled groups)$/,
|
|
61
|
+
/\.sections\[\d+\](?: \("[\s\S]*"\))?: right-panel section shares displayOrder -?\d+ with main-area [\s\S]+; the platform reads sections back by displayOrder, so plan replaces this layout on every run\. Give each section its own displayOrder, counted across both panels$/,
|
|
62
|
+
/dynamicLayouts\.[\s\S]+\.components\.[\s\S]+: (?:(?:container|section|row|column|grid|card) has no children, so it renders empty; add components or remove it|(?:container|section|column|card) stacks \d+ fields in one column; put them in a grid \(columns: 2\) or split them into titled sections)$/,
|
|
44
63
|
];
|
|
45
64
|
export function isAdvisoryDiagnostic(message) {
|
|
46
65
|
return ADVISORY_DIAGNOSTICS.some((pattern) => pattern.test(message));
|
|
@@ -138,5 +138,6 @@ export declare function liveProgressActive(): boolean;
|
|
|
138
138
|
export declare function applyProgressEvent(event: ProgressEvent): void;
|
|
139
139
|
export declare function renderTextEffects(text: string, effects: readonly TextEffect[] | undefined): string;
|
|
140
140
|
export declare function green(text: string): PullResultSegment;
|
|
141
|
+
export declare function yellow(text: string): PullResultSegment;
|
|
141
142
|
export declare function red(text: string): PullResultSegment;
|
|
142
143
|
export declare function bold(text: string): PullResultSegment;
|
|
@@ -15,6 +15,8 @@ export interface ManagedResultVerdict {
|
|
|
15
15
|
readonly gaps?: number;
|
|
16
16
|
/** Live configuration left out of source on request (e.g. `--skip-unsupported-layouts`). */
|
|
17
17
|
readonly omitted?: number;
|
|
18
|
+
/** Other problems the command reported without failing (e.g. a data-only org pull's failed workspace build). */
|
|
19
|
+
readonly warnings?: number;
|
|
18
20
|
}
|
|
19
21
|
export declare function managedResultStatus(operation: string, verdict: ManagedResultVerdict): ManagedResultStatus;
|
|
20
22
|
/**
|
|
@@ -4,7 +4,7 @@ import { flushRepeatedTechnicalLogs, machineReadableLogsEnabled, renderTextEffec
|
|
|
4
4
|
export function managedResultStatus(operation, verdict) {
|
|
5
5
|
const outcome = verdict.failed === true
|
|
6
6
|
? "failure"
|
|
7
|
-
: (verdict.skipped ?? 0) > 0 || (verdict.gaps ?? 0) > 0 || (verdict.omitted ?? 0) > 0
|
|
7
|
+
: (verdict.skipped ?? 0) > 0 || (verdict.gaps ?? 0) > 0 || (verdict.omitted ?? 0) > 0 || (verdict.warnings ?? 0) > 0
|
|
8
8
|
? "warning"
|
|
9
9
|
: "success";
|
|
10
10
|
return { operation, outcome };
|
|
@@ -15,8 +15,13 @@ export declare function decodeTemplateEscapes(s: string): string;
|
|
|
15
15
|
export declare function encodeTemplateEscapes(s: string): string;
|
|
16
16
|
/**
|
|
17
17
|
* Render a logical string as an HCL2 quoted string literal.
|
|
18
|
-
* JSON string escaping is a subset of HCL2's quoted-string escapes
|
|
19
|
-
* (\n, \t, \", \\, \uXXXX are all valid HCL)
|
|
20
|
-
*
|
|
18
|
+
* JSON string escaping is almost a subset of HCL2's quoted-string escapes
|
|
19
|
+
* (\n, \r, \t, \", \\, \uXXXX are all valid HCL), but JSON also writes
|
|
20
|
+
* U+0008 as `\b` and U+000C as `\f`, which HCL2 rejects ("Invalid escape
|
|
21
|
+
* sequence"). Those two are rewritten as `\u0008` / `\u000c` (#3003): a live
|
|
22
|
+
* script can hold a real backspace where its author meant a regex `\b`.
|
|
23
|
+
* Template introducers are additionally doubled so they stay literal. A lone
|
|
24
|
+
* UTF-16 surrogate (JSON `\ud800`) has no UTF-8 form, so HCL still rejects it;
|
|
25
|
+
* plan fails loudly on that rather than writing something different.
|
|
21
26
|
*/
|
|
22
27
|
export declare function quoteHclString(logical: string): string;
|
|
@@ -19,10 +19,23 @@ export function encodeTemplateEscapes(s) {
|
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Render a logical string as an HCL2 quoted string literal.
|
|
22
|
-
* JSON string escaping is a subset of HCL2's quoted-string escapes
|
|
23
|
-
* (\n, \t, \", \\, \uXXXX are all valid HCL)
|
|
24
|
-
*
|
|
22
|
+
* JSON string escaping is almost a subset of HCL2's quoted-string escapes
|
|
23
|
+
* (\n, \r, \t, \", \\, \uXXXX are all valid HCL), but JSON also writes
|
|
24
|
+
* U+0008 as `\b` and U+000C as `\f`, which HCL2 rejects ("Invalid escape
|
|
25
|
+
* sequence"). Those two are rewritten as `\u0008` / `\u000c` (#3003): a live
|
|
26
|
+
* script can hold a real backspace where its author meant a regex `\b`.
|
|
27
|
+
* Template introducers are additionally doubled so they stay literal. A lone
|
|
28
|
+
* UTF-16 surrogate (JSON `\ud800`) has no UTF-8 form, so HCL still rejects it;
|
|
29
|
+
* plan fails loudly on that rather than writing something different.
|
|
25
30
|
*/
|
|
26
31
|
export function quoteHclString(logical) {
|
|
27
|
-
|
|
32
|
+
// Walk JSON's escape pairs, so an escaped backslash followed by "b" (`\\b`)
|
|
33
|
+
// is never mistaken for a `\b` escape.
|
|
34
|
+
return JSON.stringify(encodeTemplateEscapes(logical)).replace(/\\(u[0-9a-fA-F]{4}|.)/g, (pair, escape) => {
|
|
35
|
+
if (escape === "b")
|
|
36
|
+
return "\\u0008";
|
|
37
|
+
if (escape === "f")
|
|
38
|
+
return "\\u000c";
|
|
39
|
+
return pair;
|
|
40
|
+
});
|
|
28
41
|
}
|
|
@@ -23,7 +23,7 @@ export { preservePulledCalculation } from "./deserializer/pulled-expression.js";
|
|
|
23
23
|
export { groupId, userId, type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyPrincipalRef, type AccessPolicyUserRef, type GroupId, type UserId } from "../access-policy/build.js";
|
|
24
24
|
export { type ManagedViewSharing } from "../view/sharing.js";
|
|
25
25
|
export { type ElementumBlocksElement, type ElementumBlocksSpec } from "../view/ragnarok.js";
|
|
26
|
-
export { agentViewFontFamily, type AgentViewBlock, type AgentViewBranding, type AgentViewCustomView, type AgentViewFontFamily, type AgentViewHexColor, type AgentViewImage, type AgentViewSpecApp, type AgentViewSpecField, type AgentViewSpecFilterRef, type AppAgentViewLayout, type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, } from "../view/agent-view-layout.js";
|
|
26
|
+
export { agentViewFontFamily, type AgentViewBlock, type AgentViewBranding, type AgentViewCustomView, type AgentViewFontFamily, type AgentViewHexColor, type AgentViewImage, type AgentViewSpecApp, type AgentViewSpecField, type AgentViewSpecFilterRef, type AppAgentViewLayout, type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, type ViewBlocksStateValue, } from "../view/agent-view-layout.js";
|
|
27
27
|
export { roleAutoShare, rolePermissionGroup, rolePermissionLevel, userRef, type AppRole, type RoleAutoShare, type RoleGroupRef, type RolePermission, type RolePermissionGroup, type RolePermissionLevel, type RoleUserRef } from "../role/build.js";
|
|
28
28
|
export { serviceAccountRoleRef, serviceAccountStatus, type AppServiceAccount, type ServiceAccountAccessPolicy, type ServiceAccountRole, type ServiceAccountRoleRef, type ServiceAccountStatus } from "../service-account/build.js";
|
|
29
29
|
export { serviceAccountRef, type ServiceAccountRef } from "../service-account/ref.js";
|
|
@@ -36,7 +36,7 @@ export interface AutomationToTfContext {
|
|
|
36
36
|
readonly fieldAddressesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
37
37
|
/** Org catalog field types for every app/element it lists, keyed by refName and then field key. */
|
|
38
38
|
readonly catalogFieldTypesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
39
|
-
/** Whole-object findings, advisories only while the revision record lists them
|
|
39
|
+
/** Whole-object (#2283) and nested-task output (#2988) findings, advisories only while the revision record lists them. */
|
|
40
40
|
readonly advisoriesWhileRecorded?: AdvisoryWhileRecorded[];
|
|
41
41
|
/**
|
|
42
42
|
* Every app/element authored in the workspace, keyed by
|
|
@@ -331,7 +331,15 @@ function assertRecordFieldValueIsWritable(reference, fieldToken, refs) {
|
|
|
331
331
|
const problem = recordFieldValueProblem(reference, fieldToken, refs);
|
|
332
332
|
if (problem === undefined)
|
|
333
333
|
return;
|
|
334
|
-
|
|
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) {
|
|
335
343
|
if (currentValidationMode() === "pull") {
|
|
336
344
|
// Pull prints the live shape and warns. Build writes the finding into the
|
|
337
345
|
// compiled file, so the pull's revision record keeps it as one the
|
|
@@ -355,7 +363,7 @@ function assertRecordFieldValueIsWritable(reference, fieldToken, refs) {
|
|
|
355
363
|
refs.owner.advisoriesWhileRecorded.push({
|
|
356
364
|
finding,
|
|
357
365
|
advisory: `automation ${refs.owner.automationTfLabel}: ${message}`,
|
|
358
|
-
error: `${message} applied-automation-revisions.json doesn't record
|
|
366
|
+
error: `${message} applied-automation-revisions.json doesn't record ${subject} from a pull or apply of this automation ` +
|
|
359
367
|
"(it is new, or the record predates EDK recording these), so build stops it. If the platform already runs it, " +
|
|
360
368
|
"pull the app or element again to record it.",
|
|
361
369
|
});
|
|
@@ -2245,9 +2253,38 @@ function assertElementCreateSetsTitle(target, fields) {
|
|
|
2245
2253
|
}
|
|
2246
2254
|
}
|
|
2247
2255
|
/**
|
|
2248
|
-
*
|
|
2249
|
-
* workflow,
|
|
2250
|
-
*
|
|
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.
|
|
2251
2288
|
*/
|
|
2252
2289
|
function assertPublishableOutputTask(outputName, value, topLevelTasks, refs) {
|
|
2253
2290
|
while (isObject(value) && "value" in value && Object.keys(value).length === 1) {
|
|
@@ -2259,10 +2296,11 @@ function assertPublishableOutputTask(outputName, value, topLevelTasks, refs) {
|
|
|
2259
2296
|
if (!refs.tasks.has(taskRefKey)) {
|
|
2260
2297
|
throw new EntityTfError(`automation output "${outputName}" references task "${taskRefKey}", which is not in this automation`);
|
|
2261
2298
|
}
|
|
2262
|
-
if (
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
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");
|
|
2266
2304
|
}
|
|
2267
2305
|
/**
|
|
2268
2306
|
* workflow_publish outputs must match provider Read / ei export: a typed
|
|
@@ -2286,8 +2324,14 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2286
2324
|
}
|
|
2287
2325
|
return valueToTf(value, refs);
|
|
2288
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
|
+
]);
|
|
2289
2332
|
/**
|
|
2290
|
-
* A field of the record a `createRecord` task made
|
|
2333
|
+
* A field of the record a `createRecord` task made or a `recordSearch` task
|
|
2334
|
+
* found, in any app or element,
|
|
2291
2335
|
* embedded as a LIVE field `.id` reference instead of a resolved display name.
|
|
2292
2336
|
* Confirmed live (demoapptwo, #1066): the platform stores this specific
|
|
2293
2337
|
* reference shape as `"record.<field-platform-id>.<suffix>"` — the SAME raw
|
|
@@ -2311,12 +2355,19 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2311
2355
|
* target's custom field resource, its `<owner>_<key>_field_id` system-field
|
|
2312
2356
|
* local, or a `data.elementum_field` lookup for an app/element outside this
|
|
2313
2357
|
* build. A field it can't resolve returns `undefined` and keeps the
|
|
2314
|
-
* display-name path.
|
|
2315
|
-
*
|
|
2316
|
-
*
|
|
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.
|
|
2317
2368
|
*/
|
|
2318
|
-
function
|
|
2319
|
-
if (target
|
|
2369
|
+
function recordFieldIdOutputRefTfValue(target, name, taskRefKey, refs) {
|
|
2370
|
+
if (target === undefined || !RECORD_FIELD_ID_OUTPUT_TASK_TYPES.has(target.type))
|
|
2320
2371
|
return undefined;
|
|
2321
2372
|
const parts = foundRecordFieldReferenceName(target.type, name, taskRefKey, refs);
|
|
2322
2373
|
return parts === undefined ? undefined : expr.template(parts);
|
|
@@ -2352,8 +2403,8 @@ function taskReferenceEnvelope(value, refs) {
|
|
|
2352
2403
|
// canonical output is ever spelled `record.<field>` (the contract has
|
|
2353
2404
|
// record/records/recordId), so that dotted prefix uniquely marks it.
|
|
2354
2405
|
const isRecordFieldRef = canonicalName.startsWith("record.");
|
|
2355
|
-
const
|
|
2356
|
-
const platformRefName =
|
|
2406
|
+
const recordFieldIdRef = recordFieldIdOutputRefTfValue(target, canonicalName, taskRef.taskRefKey, refs);
|
|
2407
|
+
const platformRefName = recordFieldIdRef
|
|
2357
2408
|
?? (isFileReaderTask
|
|
2358
2409
|
? canonicalName
|
|
2359
2410
|
: isRecordFieldRef
|
|
@@ -3748,11 +3799,16 @@ function filterToTf(value, refs) {
|
|
|
3748
3799
|
});
|
|
3749
3800
|
}
|
|
3750
3801
|
/**
|
|
3751
|
-
*
|
|
3752
|
-
*
|
|
3753
|
-
*
|
|
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.
|
|
3754
3810
|
*/
|
|
3755
|
-
const
|
|
3811
|
+
const NEVER_FIRING_SYSTEM_FIELD_KEYS = new Set(["id", "createdAt", "createdBy", "updatedAt", "updatedBy", "closedAt", "closedBy"]);
|
|
3756
3812
|
function isRunAutomationValueReference(raw) {
|
|
3757
3813
|
if (!isObject(raw))
|
|
3758
3814
|
return false;
|
|
@@ -4116,21 +4172,26 @@ function configAttrs(kind, config, refs) {
|
|
|
4116
4172
|
continue;
|
|
4117
4173
|
}
|
|
4118
4174
|
if (key === "changedFieldIds" && Array.isArray(raw)) {
|
|
4119
|
-
|
|
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) => {
|
|
4120
4179
|
const fieldToken = token(field);
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
refs.owner.fieldAddresses.has(fieldToken.refName)
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
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
|
+
: [];
|
|
4127
4185
|
});
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
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)");
|
|
4132
4193
|
}
|
|
4133
|
-
attrs.changed_fields = valueToTf(
|
|
4194
|
+
attrs.changed_fields = valueToTf(raw, refs);
|
|
4134
4195
|
continue;
|
|
4135
4196
|
}
|
|
4136
4197
|
if (key === "inputs" && kind === "elementum_on_demand_trigger") {
|
|
@@ -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",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type ComponentWire = Readonly<Record<string, unknown>>;
|
|
2
|
+
/**
|
|
3
|
+
* Advisories for one typed dynamic layout's component graph, pushed onto
|
|
4
|
+
* `diagnostics`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function lintDynamicLayout(where: string, components: Readonly<Record<string, ComponentWire>>, diagnostics: string[]): void;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build checks for typed dynamic layouts that read badly (#1774): the
|
|
3
|
+
* dynamic-layout half of `src/entities/view/layout-lint.ts` (empty
|
|
4
|
+
* containers and one long column of fields). Both are advisories
|
|
5
|
+
* (`ADVISORY_DIAGNOSTICS` in `src/engine/coverage-gaps.ts`):
|
|
6
|
+
* `dynamicLayoutsToTf` still emits every component as authored, so they are
|
|
7
|
+
* printed but never counted as coverage gaps. `column.span` is not checked:
|
|
8
|
+
* the provider writes it on every column (`layoutconfig/parse.go`), so
|
|
9
|
+
* nothing about it is dropped.
|
|
10
|
+
*/
|
|
11
|
+
import { LONG_COLUMN_FIELD_COUNT } from "../view/layout-lint.js";
|
|
12
|
+
import { DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS } from "./dialect.js";
|
|
13
|
+
/** Layout variants that only arrange their children. */
|
|
14
|
+
const CONTAINER_VARIANTS = ["container", "section", "row", "column", "grid", "card"];
|
|
15
|
+
function containerVariantOf(component) {
|
|
16
|
+
return component === undefined ? undefined : CONTAINER_VARIANTS.find((variant) => variant in component);
|
|
17
|
+
}
|
|
18
|
+
function childrenOf(component) {
|
|
19
|
+
const children = component?.["children"];
|
|
20
|
+
return Array.isArray(children) ? children.filter((id) => typeof id === "string") : [];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Advisories for one typed dynamic layout's component graph, pushed onto
|
|
24
|
+
* `diagnostics`.
|
|
25
|
+
*/
|
|
26
|
+
export function lintDynamicLayout(where, components, diagnostics) {
|
|
27
|
+
const fieldVariants = DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS;
|
|
28
|
+
for (const [id, component] of Object.entries(components)) {
|
|
29
|
+
const variant = containerVariantOf(component);
|
|
30
|
+
if (variant === undefined)
|
|
31
|
+
continue;
|
|
32
|
+
const at = `${where}.components.${id}`;
|
|
33
|
+
const children = childrenOf(component);
|
|
34
|
+
if (children.length === 0) {
|
|
35
|
+
diagnostics.push(`${at}: ${variant} has no children, so it renders empty; add components or remove it`);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (variant !== "grid" && variant !== "row") {
|
|
39
|
+
const fields = children.filter((child) => {
|
|
40
|
+
const childComponent = components[child];
|
|
41
|
+
return childComponent !== undefined && Object.keys(childComponent).some((key) => fieldVariants.has(key));
|
|
42
|
+
}).length;
|
|
43
|
+
if (fields > LONG_COLUMN_FIELD_COUNT) {
|
|
44
|
+
diagnostics.push(`${at}: ${variant} stacks ${fields} fields in one column; put them in a grid (columns: 2) or split them into titled sections`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -13,6 +13,7 @@ import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
|
13
13
|
import { unbuiltWidgetReferenceNote } from "../widget/to-tf.js";
|
|
14
14
|
import { typedCoverageGap } from "../../engine/coverage-gaps.js";
|
|
15
15
|
import { DYNAMIC_LAYOUT_RESOURCE_TYPE } from "./module.js";
|
|
16
|
+
import { lintDynamicLayout } from "./lint.js";
|
|
16
17
|
import { EntityTfError } from "../../engine/entity.js";
|
|
17
18
|
import { DYNAMIC_LAYOUT_COMPARISON_KEYS, DYNAMIC_LAYOUT_FIELD_COMPONENT_KEYS, dynamicLayoutActionWidgetName, dynamicLayoutCompanionWidgetLabel, dynamicLayoutFieldComponentWireKey, } from "./dialect.js";
|
|
18
19
|
export function dynamicLayoutsToTf(layouts, opts) {
|
|
@@ -25,6 +26,7 @@ export function dynamicLayoutsToTf(layouts, opts) {
|
|
|
25
26
|
}
|
|
26
27
|
const staged = scopeOf(opts) === "element" ? withoutStageConditions(authored, where, opts.diagnostics) : authored;
|
|
27
28
|
const layout = withoutUnbuildableButtons(withoutUnresolvedFieldEntries(staged, where, opts), where, opts);
|
|
29
|
+
lintDynamicLayout(where, layout.components ?? {}, opts.diagnostics);
|
|
28
30
|
const layoutLabel = scopedResourceLabel(opts.ownerTfLabel, tsLabelToTfLabel(key), scopeOf(opts));
|
|
29
31
|
const componentResult = componentMap(layout.components ?? {}, key, layoutLabel, where, opts);
|
|
30
32
|
const identity = requiredLayoutIdentity(layout, where, opts);
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* field/print internals genuinely shared between both aspect kinds).
|
|
7
7
|
*/
|
|
8
8
|
export { element, type ElementCloudConnection, type ElementConfigured, type ElementCustomView, type ElementRef, type ElementSystemFields, type ElementV2Options, } from "./build.js";
|
|
9
|
-
export { type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, } from "../view/agent-view-layout.js";
|
|
9
|
+
export { type ViewBlock, type ViewBlocksField, type ViewBlocksFilterRef, type ViewBlocksLayout, type ViewBlocksSource, type ViewBlocksStateValue, } from "../view/agent-view-layout.js";
|
|
10
10
|
export { type AppRecordCreateForm, type AppRecordCreateFormSection } from "../app/build.js";
|
|
11
11
|
export { listViewDensity, managedViewSortAggregation, managedViewSortDirection, type ListViewDensity, type ManagedViewSort, type ManagedViewSortAggregation, type ManagedViewSortDirection, type ManagedViewSortField, type ManagedViewSortOrder, } from "../view/build.js";
|
|
12
12
|
export { type AppRelationship, type AppRelationshipColumn } from "../relationship/build.js";
|
|
@@ -249,6 +249,7 @@ export function elementToTf(entity, ctx) {
|
|
|
249
249
|
fieldAddresses,
|
|
250
250
|
fieldNames,
|
|
251
251
|
fieldMetadata,
|
|
252
|
+
ownerAuditFields: payload.auditFields === true,
|
|
252
253
|
widgets: widgets.widgets,
|
|
253
254
|
...(payload.deleteDefaultListView !== undefined ? { deleteDefaultListView: payload.deleteDefaultListView } : {}),
|
|
254
255
|
}, payload.customViews);
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* `elementum_agent_view.layout` → `agentViews.<key>.layout`;
|
|
4
4
|
* `elementum_custom_view.layout` → `customViews.<key>.layout` (see
|
|
5
5
|
* `viewBlocksFromTf`). References become typed markers at the per-block id
|
|
6
|
-
* positions, inside nested filters and inside actions; a
|
|
7
|
-
* becomes the owner's field ref when it names one of its
|
|
8
|
-
* `unsafePlatformId(...)`. A layout this cannot represent makes the
|
|
6
|
+
* positions, inside nested filters, inside `spec.state` and inside actions; a
|
|
7
|
+
* raw platform id there becomes the owner's field ref when it names one of its
|
|
8
|
+
* fields (#2155), else `unsafePlatformId(...)`. A layout this cannot represent makes the
|
|
9
9
|
* whole view unmanaged (skipped), never silently dropped: the code owns the
|
|
10
10
|
* layout, so a dropped detail would be cleared on the next apply.
|
|
11
11
|
*/
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* `elementum_agent_view.layout` → `agentViews.<key>.layout`;
|
|
4
4
|
* `elementum_custom_view.layout` → `customViews.<key>.layout` (see
|
|
5
5
|
* `viewBlocksFromTf`). References become typed markers at the per-block id
|
|
6
|
-
* positions, inside nested filters and inside actions; a
|
|
7
|
-
* becomes the owner's field ref when it names one of its
|
|
8
|
-
* `unsafePlatformId(...)`. A layout this cannot represent makes the
|
|
6
|
+
* positions, inside nested filters, inside `spec.state` and inside actions; a
|
|
7
|
+
* raw platform id there becomes the owner's field ref when it names one of its
|
|
8
|
+
* fields (#2155), else `unsafePlatformId(...)`. A layout this cannot represent makes the
|
|
9
9
|
* whole view unmanaged (skipped), never silently dropped: the code owns the
|
|
10
10
|
* layout, so a dropped detail would be cleared on the next apply.
|
|
11
11
|
*/
|
|
@@ -88,7 +88,9 @@ function decodeSpec(value, opts, root = "custom_view") {
|
|
|
88
88
|
const out = {};
|
|
89
89
|
for (const [key, child] of Object.entries(spec)) {
|
|
90
90
|
if (key !== "elements") {
|
|
91
|
-
|
|
91
|
+
// `spec.state` holds the filter trees blocks bind to, so references may
|
|
92
|
+
// sit at any depth there, as inside a filter prop (#1770).
|
|
93
|
+
out[key] = key === "state" ? deepRefs(child, `${root}.${key}`, opts) : literal(child, `${root}.${key}`);
|
|
92
94
|
continue;
|
|
93
95
|
}
|
|
94
96
|
const elements = plain(child);
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* attribute of `elementum_agent_view` (its custom view is a blocks layout);
|
|
4
4
|
* `customViews.<key>.layout` → the `layout` attribute of
|
|
5
5
|
* `elementum_custom_view` (see `viewBlocksToTf`). Platform ids resolve from
|
|
6
|
-
* typed references at the per-block id positions, inside nested filters
|
|
7
|
-
* inside actions; a structurally broken layout fails the build, because
|
|
6
|
+
* typed references at the per-block id positions, inside nested filters,
|
|
7
|
+
* inside `spec.state` and inside actions; a structurally broken layout fails the build, because
|
|
8
8
|
* dropping it would make apply clear the live one.
|
|
9
9
|
*/
|
|
10
10
|
import type { OrgRefLookup, WorkspaceAspect } from "../../engine/build/context.js";
|
|
@@ -14,6 +14,8 @@ export interface AgentViewLayoutToTfOptions {
|
|
|
14
14
|
readonly ownerRefName: string;
|
|
15
15
|
/** The view owner's kind; an agent view's owner is always an app. */
|
|
16
16
|
readonly ownerKind?: "app" | "element";
|
|
17
|
+
/** Element owners only: the element declares `systemFields.audit`. */
|
|
18
|
+
readonly ownerAuditFields?: boolean;
|
|
17
19
|
readonly ownerTfLabel: string;
|
|
18
20
|
readonly scope: ChildResourceScope;
|
|
19
21
|
readonly objectId: TfValue;
|
|
@@ -71,6 +71,9 @@ export function viewBlocksToTf(spec, where, opts, policy) {
|
|
|
71
71
|
throw new EntityTfError(`${where}.elements must have at least one element`);
|
|
72
72
|
if (policy.strictStructure) {
|
|
73
73
|
validateCustomViewLayout(doc, where, {
|
|
74
|
+
ownerRefName: opts.ownerRefName,
|
|
75
|
+
...(opts.ownerKind !== undefined ? { ownerKind: opts.ownerKind } : {}),
|
|
76
|
+
...(opts.ownerAuditFields !== undefined ? { ownerAuditFields: opts.ownerAuditFields } : {}),
|
|
74
77
|
...(opts.fieldNames !== undefined ? { fieldNames: opts.fieldNames } : {}),
|
|
75
78
|
...(opts.fieldMetadata !== undefined ? { fieldMetadata: opts.fieldMetadata } : {}),
|
|
76
79
|
diagnostics: opts.diagnostics,
|
|
@@ -83,7 +86,9 @@ export function viewBlocksToTf(spec, where, opts, policy) {
|
|
|
83
86
|
for (const [key, value] of Object.entries(doc)) {
|
|
84
87
|
if (key === "elements")
|
|
85
88
|
continue;
|
|
86
|
-
|
|
89
|
+
// `spec.state` holds the filter trees blocks bind to (`$bindState`), so
|
|
90
|
+
// references may sit at any depth there, as inside a filter prop (#1770).
|
|
91
|
+
out[key] = key === "state" ? deepRefs(value, `${where}.${key}`, opts) : literal(value, `${where}.${key}`, opts);
|
|
87
92
|
}
|
|
88
93
|
const outElements = {};
|
|
89
94
|
for (const [id, raw] of Object.entries(elements)) {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* A blocks layout is an Elementum Blocks (Ragnarok) spec — the generated
|
|
11
11
|
* `ElementumBlocksSpec` — with platform ids replaced by typed references at
|
|
12
12
|
* the per-block id positions listed in `AGENT_VIEW_SPEC_ID_PROPS`, inside
|
|
13
|
-
* nested filters, and inside actions (`on` events,
|
|
13
|
+
* nested filters, inside `spec.state`, and inside actions (`on` events,
|
|
14
|
+
* button `onPress`).
|
|
14
15
|
*/
|
|
15
16
|
import type { AppCatalogRef, ElementCatalogRef, FieldRef } from "../../catalog/types.js";
|
|
16
17
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
@@ -127,8 +128,19 @@ type MapElement<E> = E extends {
|
|
|
127
128
|
} : E;
|
|
128
129
|
/** One block of a blocks layout. */
|
|
129
130
|
export type ViewBlock = MapElement<ElementumBlocksElement>;
|
|
131
|
+
/**
|
|
132
|
+
* A value held in `spec.state`. Blocks read it through `$state` / `$bindState`
|
|
133
|
+
* bindings, so a section's filter tree lives here (`/sections/s1/filter`).
|
|
134
|
+
* References may sit at any depth, as inside a filter prop (#1770).
|
|
135
|
+
*/
|
|
136
|
+
export type ViewBlocksStateValue = string | number | boolean | null | ViewBlocksFilterRef | ReadonlyArray<ViewBlocksStateValue> | {
|
|
137
|
+
readonly [key: string]: ViewBlocksStateValue;
|
|
138
|
+
};
|
|
130
139
|
/** A blocks layout: an Elementum Blocks spec with typed references. */
|
|
131
|
-
export type ViewBlocksLayout = Omit<ElementumBlocksSpec, "elements"> & {
|
|
140
|
+
export type ViewBlocksLayout = Omit<ElementumBlocksSpec, "elements" | "state"> & {
|
|
141
|
+
readonly state?: {
|
|
142
|
+
readonly [key: string]: ViewBlocksStateValue;
|
|
143
|
+
};
|
|
132
144
|
readonly elements: {
|
|
133
145
|
readonly [key: string]: ViewBlock;
|
|
134
146
|
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* check.mjs Layer 3 at build, from source (#1784 items 1-2, part of #1758):
|
|
3
|
+
*
|
|
4
|
+
* - calc names: every `"Name"` inside a block's `calc` should be a field of
|
|
5
|
+
* the app or element the block reads from. Build knows only the owner's
|
|
6
|
+
* authored fields, and pull can leave some fields unextracted (#1736/#1966),
|
|
7
|
+
* so build warns; plan fails a calc name that is not an exact live field
|
|
8
|
+
* name, including a case difference. A block that reads
|
|
9
|
+
* from another app or a raw id is checked only at plan.
|
|
10
|
+
* - tag-dependent helpers: a preset, sort option or table column that needs a
|
|
11
|
+
* tagged field the owner does not have. Warnings, as in check.mjs. App
|
|
12
|
+
* system tags (STATUS, CREATED_AT, CLOSED_AT, ...) exist on every app, so
|
|
13
|
+
* build skips them for apps; an element has only HANDLE and TITLE, plus the
|
|
14
|
+
* audit tags when it declares `systemFields.audit`. The Open/Closed toggle's
|
|
15
|
+
* STATUS option tagged CLOSED is only checked at plan.
|
|
16
|
+
*
|
|
17
|
+
* Typed field refs already fail the build when they don't resolve, and field
|
|
18
|
+
* and option ids written as unsafePlatformId(...) can only be checked against
|
|
19
|
+
* the live App, so the provider does those at plan.
|
|
20
|
+
*/
|
|
21
|
+
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
22
|
+
export interface CustomViewReferenceOptions {
|
|
23
|
+
/** The view owner's catalog key and kind; blocks reading another source are checked at plan. */
|
|
24
|
+
readonly ownerRefName?: string;
|
|
25
|
+
readonly ownerKind?: "app" | "element";
|
|
26
|
+
/** Element owners only: the element declares `systemFields.audit` (Created/Updated on/by). */
|
|
27
|
+
readonly ownerAuditFields?: boolean;
|
|
28
|
+
/** Field bag key → display name (system keys included when source names them). */
|
|
29
|
+
readonly fieldNames?: ReadonlyMap<string, string>;
|
|
30
|
+
readonly fieldMetadata?: ReadonlyMap<string, BuildFieldMetadata>;
|
|
31
|
+
}
|
|
32
|
+
/** Layer 3 from source. Everything here is a build warning; plan is authoritative against the live App. */
|
|
33
|
+
export declare function checkCustomViewReferences(elements: Readonly<Record<string, unknown>>, where: string, opts: CustomViewReferenceOptions, warn: (at: string, msg: string) => void): void;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { DEFAULT_SYSTEM_FIELD_NAME_BY_TAG, DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS, SYSTEM_FIELD_TAG_BY_KEY, } from "../../core/system-fields.js";
|
|
2
|
+
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
3
|
+
/** check.mjs SYSTEM_KEY_TAG: system keys in sort options and table columns, and the tag each needs. */
|
|
4
|
+
const SYSTEM_KEY_TAG = {
|
|
5
|
+
handle: "HANDLE",
|
|
6
|
+
title: "TITLE",
|
|
7
|
+
status: "STATUS",
|
|
8
|
+
priority: "PRIORITY",
|
|
9
|
+
stage: "STAGE",
|
|
10
|
+
assignee: "ASSIGNEE",
|
|
11
|
+
assignmentGroup: "ASSIGNMENT_GROUP",
|
|
12
|
+
createdBy: "CREATED_BY",
|
|
13
|
+
createdTime: "CREATED_AT",
|
|
14
|
+
updatedAt: "UPDATED_AT",
|
|
15
|
+
};
|
|
16
|
+
/** Tags every app has as a system field; plan checks these against the live App. */
|
|
17
|
+
const APP_SYSTEM_TAGS = new Set(Object.values(SYSTEM_FIELD_TAG_BY_KEY));
|
|
18
|
+
/** The system fields an element has: id and title, plus the audit fields when it declares them. */
|
|
19
|
+
function elementSystemKeys(auditFields) {
|
|
20
|
+
return auditFields ? ELEMENT_SYSTEM_FIELD_KEYS : ["id", "title"];
|
|
21
|
+
}
|
|
22
|
+
function ownerSystemKeys(opts) {
|
|
23
|
+
return opts.ownerKind === "element" ? elementSystemKeys(opts.ownerAuditFields === true) : SYSTEM_FIELD_KEYS;
|
|
24
|
+
}
|
|
25
|
+
const CALC_NAME = /"([^"]+)"/g;
|
|
26
|
+
/** check.mjs PRESET_TAG. */
|
|
27
|
+
function presetTag(preset) {
|
|
28
|
+
if (preset.startsWith("created"))
|
|
29
|
+
return preset === "createdByCurrentUser" ? "CREATED_BY" : "CREATED_AT";
|
|
30
|
+
if (preset.startsWith("closed"))
|
|
31
|
+
return "CLOSED_AT";
|
|
32
|
+
return "ASSIGNEE";
|
|
33
|
+
}
|
|
34
|
+
function isObj(v) {
|
|
35
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Whether a block reads from the view's owner: no source prop, the host
|
|
39
|
+
* binding (`{ $state: "/host/aspectId" }`), or a typed ref to the owner.
|
|
40
|
+
* A raw id or another app's ref is someone else's fields.
|
|
41
|
+
*/
|
|
42
|
+
function readsOwner(props, opts) {
|
|
43
|
+
const source = props["aspectId"] ?? props["filterAspectId"];
|
|
44
|
+
if (source == null)
|
|
45
|
+
return true;
|
|
46
|
+
if (!isObj(source))
|
|
47
|
+
return false;
|
|
48
|
+
if (source["$state"] === "/host/aspectId" || source["$bindState"] === "/host/aspectId")
|
|
49
|
+
return true;
|
|
50
|
+
const kind = source["__kind"];
|
|
51
|
+
return (kind === "app" || kind === "element")
|
|
52
|
+
&& kind === (opts.ownerKind ?? "app")
|
|
53
|
+
&& opts.ownerRefName !== undefined
|
|
54
|
+
&& source["refName"] === opts.ownerRefName;
|
|
55
|
+
}
|
|
56
|
+
/** Every name a field of the owner may carry: authored names, plus defaults for the owner's system fields source leaves unnamed. */
|
|
57
|
+
function ownerFieldNames(opts) {
|
|
58
|
+
const names = new Set(opts.fieldNames?.values() ?? []);
|
|
59
|
+
for (const key of ownerSystemKeys(opts)) {
|
|
60
|
+
if (opts.fieldNames?.has(key) === true)
|
|
61
|
+
continue;
|
|
62
|
+
const tag = SYSTEM_FIELD_TAG_BY_KEY[key];
|
|
63
|
+
// A platform-composed app and an EDK deploy name system fields differently.
|
|
64
|
+
names.add(DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key]);
|
|
65
|
+
const composed = DEFAULT_SYSTEM_FIELD_NAME_BY_TAG[tag];
|
|
66
|
+
if (composed !== undefined)
|
|
67
|
+
names.add(composed);
|
|
68
|
+
}
|
|
69
|
+
return names;
|
|
70
|
+
}
|
|
71
|
+
/** Layer 3 from source. Everything here is a build warning; plan is authoritative against the live App. */
|
|
72
|
+
export function checkCustomViewReferences(elements, where, opts, warn) {
|
|
73
|
+
if (opts.fieldNames === undefined)
|
|
74
|
+
return;
|
|
75
|
+
const owner = opts.ownerKind === "element" ? "this element" : "this app";
|
|
76
|
+
const names = ownerFieldNames(opts);
|
|
77
|
+
const lowerNames = new Map([...names].map((name) => [name.toLowerCase(), name]));
|
|
78
|
+
// Tags the owner has: authored ones, plus its system fields'. Every app has
|
|
79
|
+
// all the system tags, so for an app those are plan's to check.
|
|
80
|
+
const ownerTags = new Set(opts.ownerKind === "element" ? ownerSystemKeys(opts).map((key) => SYSTEM_FIELD_TAG_BY_KEY[key]) : APP_SYSTEM_TAGS);
|
|
81
|
+
for (const meta of opts.fieldMetadata?.values() ?? [])
|
|
82
|
+
for (const tag of meta.tags ?? [])
|
|
83
|
+
ownerTags.add(tag);
|
|
84
|
+
const grouped = new Map();
|
|
85
|
+
const need = (at, tag, what) => {
|
|
86
|
+
if (ownerTags.has(tag))
|
|
87
|
+
return;
|
|
88
|
+
const message = `${what} relies on a field tagged ${tag}, and ${owner} has none, so it will show nothing or do nothing`;
|
|
89
|
+
let places = grouped.get(message);
|
|
90
|
+
if (places === undefined)
|
|
91
|
+
grouped.set(message, (places = new Set()));
|
|
92
|
+
places.add(at);
|
|
93
|
+
};
|
|
94
|
+
for (const [id, raw] of Object.entries(elements)) {
|
|
95
|
+
if (!isObj(raw) || !isObj(raw["props"]))
|
|
96
|
+
continue;
|
|
97
|
+
const props = raw["props"];
|
|
98
|
+
if (!readsOwner(props, opts))
|
|
99
|
+
continue;
|
|
100
|
+
const elWhere = `${where}.elements.${id}`;
|
|
101
|
+
if (typeof props["calc"] === "string") {
|
|
102
|
+
for (const match of props["calc"].matchAll(CALC_NAME)) {
|
|
103
|
+
const name = match[1];
|
|
104
|
+
if (names.has(name))
|
|
105
|
+
continue;
|
|
106
|
+
const loose = lowerNames.get(name.toLowerCase());
|
|
107
|
+
// A warning, not an error: a pulled owner can have live fields pull left
|
|
108
|
+
// unextracted (#1736/#1966). Plan fails a calc name that is not an exact
|
|
109
|
+
// live field name, including a case difference.
|
|
110
|
+
warn(`${elWhere}.calc`, loose !== undefined
|
|
111
|
+
? `no field "${name}"; did you mean "${loose}"? Calc names are field display names and are case-sensitive. Plan fails a calc name that is not an exact live field name, including a case difference`
|
|
112
|
+
: `no field named "${name}" among ${owner}'s authored fields; calc names a field by its display name. Plan fails a calc name that is not an exact live field name, including a case difference`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const presets = [props["filterPreset"]].flat().filter((v) => typeof v === "string");
|
|
116
|
+
for (const preset of presets)
|
|
117
|
+
need(elWhere, presetTag(preset), `preset "${preset}"`);
|
|
118
|
+
if (Array.isArray(props["sortByOptions"])) {
|
|
119
|
+
for (const option of props["sortByOptions"]) {
|
|
120
|
+
const value = isObj(option) ? option["value"] : undefined;
|
|
121
|
+
const tag = typeof value === "string" ? SYSTEM_KEY_TAG[value] : undefined;
|
|
122
|
+
if (tag !== undefined)
|
|
123
|
+
need(elWhere, tag, `sort option "${value}"`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (raw["type"] === "DataTableBlock" && Array.isArray(props["columns"])) {
|
|
127
|
+
for (const column of props["columns"]) {
|
|
128
|
+
const key = typeof column === "string" ? column : isObj(column) ? column["key"] : undefined;
|
|
129
|
+
const tag = typeof key === "string" ? SYSTEM_KEY_TAG[key] : undefined;
|
|
130
|
+
if (tag !== undefined)
|
|
131
|
+
need(elWhere, tag, `column "${key}"`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Group identical problems so a repeated section reports once (check.mjs).
|
|
136
|
+
for (const [message, places] of grouped) {
|
|
137
|
+
const list = [...places];
|
|
138
|
+
warn(list.length > 3 ? `${list.slice(0, 3).join(", ")} and ${list.length - 3} more` : list.join(", "), message);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -8,14 +8,19 @@
|
|
|
8
8
|
* page reads a missing path as undefined). Agent views keep the softer
|
|
9
9
|
* diagnostics in checkStructure / reportStructureProblems.
|
|
10
10
|
*
|
|
11
|
-
* Layer 3
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
11
|
+
* Layer 3 from source (calc names, tag-dependent helpers) is in
|
|
12
|
+
* custom-view-references.ts (#1784); typed field refs already fail via
|
|
13
|
+
* resolveField, and raw ids are checked at plan against the live App.
|
|
14
|
+
* Syntax-only calc rules (AVG / empty COUNT) live here.
|
|
15
15
|
*/
|
|
16
16
|
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
17
17
|
export interface CustomViewValidateOptions {
|
|
18
|
-
/**
|
|
18
|
+
/** The view owner; Layer 3 checks blocks that read from it (#1784). */
|
|
19
|
+
readonly ownerRefName?: string;
|
|
20
|
+
readonly ownerKind?: "app" | "element";
|
|
21
|
+
/** Element owners only: the element declares `systemFields.audit`. */
|
|
22
|
+
readonly ownerAuditFields?: boolean;
|
|
23
|
+
/** Owner field bag key → display name, for calc names (#1784). */
|
|
19
24
|
readonly fieldNames?: ReadonlyMap<string, string>;
|
|
20
25
|
readonly fieldMetadata?: ReadonlyMap<string, BuildFieldMetadata>;
|
|
21
26
|
/** Build warnings (check.mjs `warn`); pushed, never thrown. */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EntityTfError } from "../../engine/entity.js";
|
|
2
|
+
import { checkCustomViewReferences } from "./custom-view-references.js";
|
|
2
3
|
const CONTAINERS = new Set(["PanesBlock", "StackBlock", "RowBlock", "CardBlock"]);
|
|
3
4
|
const LIST_BLOCKS = new Set(["ListCollectionBlock", "DataTableBlock"]);
|
|
4
5
|
const FILTER_GROUPS = new Set(["AND", "OR"]);
|
|
@@ -265,6 +266,7 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
|
|
|
265
266
|
}
|
|
266
267
|
}
|
|
267
268
|
}
|
|
269
|
+
checkCustomViewReferences(elements, where, opts, warn);
|
|
268
270
|
throwIf(problems);
|
|
269
271
|
}
|
|
270
272
|
function throwIf(problems) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build checks for record details layouts that read badly (#1774).
|
|
3
|
+
*
|
|
4
|
+
* Classic `layouts` get the checks below (typed `dynamicLayouts` get theirs
|
|
5
|
+
* in `src/entities/dynamic-layout/lint.ts`), the same ones the generated
|
|
6
|
+
* layout avoids (`src/scripts/lib/record-layout-scaffold.ts`):
|
|
7
|
+
* - a group section that renders empty;
|
|
8
|
+
* - one long column of fields instead of labeled groups;
|
|
9
|
+
* - a right-panel section that shares a `displayOrder` with a main-area
|
|
10
|
+
* section, which the platform reads back in a different order, so plan
|
|
11
|
+
* replaces the layout.
|
|
12
|
+
*
|
|
13
|
+
* Those are advisories (`ADVISORY_DIAGNOSTICS` in
|
|
14
|
+
* `src/engine/coverage-gaps.ts`): the layout is built and applied exactly as
|
|
15
|
+
* authored, so they are printed but never counted as coverage gaps.
|
|
16
|
+
*
|
|
17
|
+
* `maxColumns` on a non-group section is the one real coverage gap here:
|
|
18
|
+
* `layoutToTf` emits `max_columns` only on group sections, so build drops it.
|
|
19
|
+
*/
|
|
20
|
+
import type { AppLayoutWire } from "./to-tf.js";
|
|
21
|
+
/** More fields than this in a one-column stack reads as one long column. */
|
|
22
|
+
export declare const LONG_COLUMN_FIELD_COUNT = 8;
|
|
23
|
+
/** More fields than this in one group should be split into labeled groups. */
|
|
24
|
+
export declare const LONG_GROUP_FIELD_COUNT = 12;
|
|
25
|
+
/** Checks for one stage's classic layout, pushed onto `diagnostics`. */
|
|
26
|
+
export declare function lintClassicLayout(where: string, layout: AppLayoutWire, diagnostics: string[]): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** More fields than this in a one-column stack reads as one long column. */
|
|
2
|
+
export const LONG_COLUMN_FIELD_COUNT = 8;
|
|
3
|
+
/** More fields than this in one group should be split into labeled groups. */
|
|
4
|
+
export const LONG_GROUP_FIELD_COUNT = 12;
|
|
5
|
+
/** Checks for one stage's classic layout, pushed onto `diagnostics`. */
|
|
6
|
+
export function lintClassicLayout(where, layout, diagnostics) {
|
|
7
|
+
const at = (index) => {
|
|
8
|
+
const name = layout.sections[index]?.name;
|
|
9
|
+
return `${where}.sections[${index}]${name ? ` ("${name}")` : ""}`;
|
|
10
|
+
};
|
|
11
|
+
for (const [index, section] of layout.sections.entries()) {
|
|
12
|
+
const type = section.type ?? "group";
|
|
13
|
+
if (type !== "group") {
|
|
14
|
+
if (section.maxColumns !== undefined) {
|
|
15
|
+
diagnostics.push(`${at(index)}: maxColumns only applies to group sections, so build dropped it from this ${type} section; remove it`);
|
|
16
|
+
}
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const fields = section.fields?.length ?? 0;
|
|
20
|
+
const widgets = section.widgets?.length ?? 0;
|
|
21
|
+
if (fields === 0 && widgets === 0 && section.agent === undefined) {
|
|
22
|
+
diagnostics.push(`${at(index)}: group section has no fields, widgets or agent, so the record page shows an empty section; add fields or remove it`);
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (fields > LONG_GROUP_FIELD_COUNT) {
|
|
26
|
+
diagnostics.push(`${at(index)}: group section holds ${fields} fields; split them into labeled groups (key fields first) so the record page doesn't read as one long list`);
|
|
27
|
+
}
|
|
28
|
+
else if (fields > LONG_COLUMN_FIELD_COUNT && section.maxColumns === 1) {
|
|
29
|
+
diagnostics.push(`${at(index)}: group section stacks ${fields} fields in one column (maxColumns: 1); use maxColumns: 2 or split it into labeled groups`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// displayOrder ranks sections across both locations (the provider writes
|
|
33
|
+
// the omitted values as CENTER and 0), and the platform reads the layout
|
|
34
|
+
// back sorted by it, so a tie between the panels can come back reordered.
|
|
35
|
+
const centerByOrder = new Map();
|
|
36
|
+
for (const [index, section] of layout.sections.entries()) {
|
|
37
|
+
const order = section.displayOrder ?? 0;
|
|
38
|
+
if ((section.displayLocation ?? "CENTER") !== "RIGHT" && !centerByOrder.has(order))
|
|
39
|
+
centerByOrder.set(order, index);
|
|
40
|
+
}
|
|
41
|
+
for (const [index, section] of layout.sections.entries()) {
|
|
42
|
+
if (section.displayLocation !== "RIGHT")
|
|
43
|
+
continue;
|
|
44
|
+
const order = section.displayOrder ?? 0;
|
|
45
|
+
const center = centerByOrder.get(order);
|
|
46
|
+
if (center === undefined)
|
|
47
|
+
continue;
|
|
48
|
+
diagnostics.push(`${at(index)}: right-panel section shares displayOrder ${order} with main-area ${at(center)}; the platform reads sections back by displayOrder, so plan replaces this layout on every run. Give each section its own displayOrder, counted across both panels`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -131,6 +131,8 @@ export interface ViewToTfOptions {
|
|
|
131
131
|
readonly fieldAddresses?: ReadonlyMap<string, string>;
|
|
132
132
|
/** Field bag key → display name (custom-view calc checks). */
|
|
133
133
|
readonly fieldNames?: ReadonlyMap<string, string>;
|
|
134
|
+
/** Element owners only: the element declares `systemFields.audit` (custom-view calc and tag checks). */
|
|
135
|
+
readonly ownerAuditFields?: boolean;
|
|
134
136
|
/** Field bag key → metadata (custom-view tag / calc checks). */
|
|
135
137
|
readonly fieldMetadata?: ReadonlyMap<string, import("../../graph/types.js").BuildFieldMetadata>;
|
|
136
138
|
/** Declared sibling widget keys, for typed classic-layout placement. */
|
|
@@ -15,6 +15,7 @@ import { fieldRefToTfValue as customFieldRefToTfValue } from "../field/to-tf.js"
|
|
|
15
15
|
import { ELEMENT_SYSTEM_FIELD_KEYS } from "../element/system-fields.js";
|
|
16
16
|
import { filterToTf, principalListToTf } from "../access-policy/to-tf.js";
|
|
17
17
|
import { EntityTfError } from "../../engine/entity.js";
|
|
18
|
+
import { lintClassicLayout } from "./layout-lint.js";
|
|
18
19
|
import { SUB_TYPE_BY_AUTHORING_TYPE } from "../field/types.js";
|
|
19
20
|
import { DASHBOARD_RESOURCE_TYPE } from "../dashboard/module.js";
|
|
20
21
|
import { WIDGET_RESOURCE_TYPE } from "../widget/module.js";
|
|
@@ -56,6 +57,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
56
57
|
if (opts.stageTfLabels !== undefined && !opts.stageTfLabels.has(stageTfLabel)) {
|
|
57
58
|
throw new EntityTfError(`${ownerRefName}: layouts.${stageKey} matches none of its stages.${validLayoutKeys()}`);
|
|
58
59
|
}
|
|
60
|
+
lintClassicLayout(`layouts.${stageKey}`, layout, diagnostics);
|
|
59
61
|
blocks.push(layoutToTf(stageKey, layout, ownerRefName, ownerTfLabel, scope, objectId, diagnostics, fieldAddresses, opts.widgets, opts.stageKeyByTfLabel?.get(stageTfLabel)));
|
|
60
62
|
}
|
|
61
63
|
if (opts.deleteDefaultListView === true) {
|
|
@@ -281,6 +283,7 @@ export function viewToTf(layouts, listViews, calendarViews, kanbanViews, dashboa
|
|
|
281
283
|
attrs["layout"] = expr.jsonencode(viewBlocksToTf(view.layout, `${where}.layout`, {
|
|
282
284
|
ownerRefName,
|
|
283
285
|
ownerKind: scope === "element" ? "element" : "app",
|
|
286
|
+
...(opts.ownerAuditFields !== undefined ? { ownerAuditFields: opts.ownerAuditFields } : {}),
|
|
284
287
|
ownerTfLabel,
|
|
285
288
|
scope,
|
|
286
289
|
objectId,
|
|
@@ -91,7 +91,14 @@ export interface VisualFlowStage {
|
|
|
91
91
|
export type DefineVisualFlowOptions = EntityDeployOptions & {
|
|
92
92
|
/** The app whose stages host this flow. Elements do not expose stages. */
|
|
93
93
|
readonly app: AppCatalogRef;
|
|
94
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Stable stage keys map directly to the owner's authored stage keys. The key
|
|
96
|
+
* `initiate` is the app's Initiate stage (the first stage the platform
|
|
97
|
+
* creates with every app, which is not one of its authored stages), unless
|
|
98
|
+
* the app authors its own stage keyed `initiate` (or whose name slugs to it).
|
|
99
|
+
* Build always sends the Initiate stage first, as the platform lists it, so
|
|
100
|
+
* it may appear anywhere in this record.
|
|
101
|
+
*/
|
|
95
102
|
readonly stages: Readonly<Record<string, VisualFlowStage>>;
|
|
96
103
|
};
|
|
97
104
|
export interface VisualFlowConfigured {
|
|
@@ -7,6 +7,7 @@ import { DATAMINE_RESOURCE_TYPE } from "../datamine/module.js";
|
|
|
7
7
|
import { RELATIONSHIP_RESOURCE_TYPE } from "../relationship/module.js";
|
|
8
8
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
9
9
|
import { VISUAL_FLOW_RESOURCE_TYPE } from "./module.js";
|
|
10
|
+
import { INITIATE_STAGE_ID_ATTR, INITIATE_STAGE_KEY } from "./initiate.js";
|
|
10
11
|
const KNOWN = new Set(["id", "object_id", "stages"]);
|
|
11
12
|
const symbols = new Set(["SQUARE", "DIAMOND", "CIRCLE"]);
|
|
12
13
|
const positions = new Set(["TOP", "RIGHT", "BOTTOM", "LEFT"]);
|
|
@@ -165,6 +166,21 @@ export function visualFlowFromTf(block, ownerType, ownerLabel, scope, ctx, stage
|
|
|
165
166
|
if (!isTfExpr(stageId) || stageId.$expr !== "resource-attr" || stageId.type !== ownerType || stageId.label !== ownerLabel) {
|
|
166
167
|
throw new EntityTfError(`${block.type}.${block.label}.stages[${index}]: stage_id must reference the owning ${scope} stage map`);
|
|
167
168
|
}
|
|
169
|
+
const rawNodes0 = stage["nodes"];
|
|
170
|
+
// The platform's Initiate stage is named by its own attribute (#2987).
|
|
171
|
+
if (stageId.path.length === 1 && stageId.path[0] === INITIATE_STAGE_ID_ATTR) {
|
|
172
|
+
// Build sends the `initiate` handle to an authored stage that holds it
|
|
173
|
+
// (its key, or a name that slugs to it), so writing these blocks under
|
|
174
|
+
// `initiate` would move them to that stage, or print the key twice.
|
|
175
|
+
// Leave the flow unmanaged instead, like a lost stage handle (#1136).
|
|
176
|
+
const owner = stageHandles?.byHandle.get(INITIATE_STAGE_KEY);
|
|
177
|
+
if (owner !== undefined) {
|
|
178
|
+
throw new LostStageHandleError(`${block.type}.${block.label}.stages[${index}]: the app's Initiate stage has no handle of its own (its handle "${INITIATE_STAGE_KEY}" belongs to the app's stage "${owner}"); the flow is left unmanaged instead of binding it to "${owner}". Rename that stage so neither its key nor its name produces the handle "${INITIATE_STAGE_KEY}", then pull again (#2987)`);
|
|
179
|
+
}
|
|
180
|
+
if (!Array.isArray(rawNodes0))
|
|
181
|
+
throw new EntityTfError(`${block.type}.${block.label}.stages[${index}]: nodes must be a list`);
|
|
182
|
+
return { stage: INITIATE_STAGE_KEY, nodes: Object.fromEntries(rawNodes0.map((node, nodeIndex) => nodeFromTf(node, ownerLabel, scope, ctx, `${block.type}.${block.label}.stages[${index}].nodes[${nodeIndex}]`))) };
|
|
183
|
+
}
|
|
168
184
|
const entry = stageId.path.find((part) => typeof part === "object" && "index" in part);
|
|
169
185
|
if (entry === undefined || typeof entry !== "object")
|
|
170
186
|
throw new EntityTfError(`${block.type}.${block.label}.stages[${index}]: stage_id has no stable key`);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The platform's Initiate stage (#2987). Every app gets one when it is
|
|
3
|
+
* created; it is not one of the app's authored `stages`, so it has no
|
|
4
|
+
* `stage_ids_by_key` entry. A process map names it with this stage key, and
|
|
5
|
+
* build points it at `elementum_app.<app>.initiate_stage_id`, unless the app
|
|
6
|
+
* authors its own stage keyed `initiate`, which then wins.
|
|
7
|
+
*/
|
|
8
|
+
export declare const INITIATE_STAGE_KEY = "initiate";
|
|
9
|
+
/** The platform's display name for the Initiate stage. */
|
|
10
|
+
export declare const INITIATE_STAGE_NAME = "Initiate";
|
|
11
|
+
/** Computed `elementum_app` attribute holding the Initiate stage's id. */
|
|
12
|
+
export declare const INITIATE_STAGE_ID_ATTR = "initiate_stage_id";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The platform's Initiate stage (#2987). Every app gets one when it is
|
|
3
|
+
* created; it is not one of the app's authored `stages`, so it has no
|
|
4
|
+
* `stage_ids_by_key` entry. A process map names it with this stage key, and
|
|
5
|
+
* build points it at `elementum_app.<app>.initiate_stage_id`, unless the app
|
|
6
|
+
* authors its own stage keyed `initiate`, which then wins.
|
|
7
|
+
*/
|
|
8
|
+
export const INITIATE_STAGE_KEY = "initiate";
|
|
9
|
+
/** The platform's display name for the Initiate stage. */
|
|
10
|
+
export const INITIATE_STAGE_NAME = "Initiate";
|
|
11
|
+
/** Computed `elementum_app` attribute holding the Initiate stage's id. */
|
|
12
|
+
export const INITIATE_STAGE_ID_ATTR = "initiate_stage_id";
|
|
@@ -8,6 +8,7 @@ import { DATAMINE_RESOURCE_TYPE } from "../datamine/module.js";
|
|
|
8
8
|
import { RELATIONSHIP_RESOURCE_TYPE } from "../relationship/module.js";
|
|
9
9
|
import { TABLE_RESOURCE_TYPE } from "../table/module.js";
|
|
10
10
|
import { VISUAL_FLOW_RESOURCE_TYPE } from "./module.js";
|
|
11
|
+
import { INITIATE_STAGE_ID_ATTR, INITIATE_STAGE_KEY } from "./initiate.js";
|
|
11
12
|
function ownedResourceRef(ref, expected, ctx) {
|
|
12
13
|
if (ref.__kind !== expected || !ref.refName || ref.parent !== ctx.appRefName) {
|
|
13
14
|
throw new EntityTfError(`visual flow ${expected} must be a typed reference owned by ${ctx.appRefName}`);
|
|
@@ -157,11 +158,24 @@ export function visualFlowToTf(entity, ctx) {
|
|
|
157
158
|
const ownerType = APP_RESOURCE_TYPE;
|
|
158
159
|
const label = appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(entity.refName));
|
|
159
160
|
const dataBlocks = new Map();
|
|
160
|
-
const
|
|
161
|
+
const resolved = (payload.stages ?? []).map((stage) => {
|
|
161
162
|
if (!stage.stage)
|
|
162
163
|
throw new EntityTfError(`visual flow ${entity.refName}: every stage requires a stable key`);
|
|
164
|
+
const stageHandle = tsLabelToTfLabel(stage.stage);
|
|
165
|
+
const appStageKey = ctx.stageKeyByTfLabel?.get(stageHandle);
|
|
166
|
+
// `initiate` names the platform's Initiate stage unless the app authors
|
|
167
|
+
// its own stage with that key (#2987).
|
|
168
|
+
return { stage, stageHandle, appStageKey, onInitiate: appStageKey === undefined && stageHandle === INITIATE_STAGE_KEY };
|
|
169
|
+
});
|
|
170
|
+
// The platform lists the Initiate stage first, and elementum_flow Read keeps
|
|
171
|
+
// platform order with stage_id RequiresReplace: emit it first wherever the
|
|
172
|
+
// source lists it, or every plan after the first apply replaces the flow.
|
|
173
|
+
const ordered = [...resolved.filter((entry) => entry.onInitiate), ...resolved.filter((entry) => !entry.onInitiate)];
|
|
174
|
+
const stages = ordered.map(({ stage, stageHandle, appStageKey, onInitiate }) => {
|
|
163
175
|
return {
|
|
164
|
-
stage_id:
|
|
176
|
+
stage_id: onInitiate
|
|
177
|
+
? expr.resourceAttr(ownerType, ctx.appTfLabel, [INITIATE_STAGE_ID_ATTR])
|
|
178
|
+
: expr.resourceAttr(ownerType, ctx.appTfLabel, ["stage_ids_by_key", { index: appStageKey ?? stageHandle }]),
|
|
165
179
|
nodes: Object.entries(stage.nodes ?? {}).map(([key, node]) => ({
|
|
166
180
|
key,
|
|
167
181
|
...(node.description !== undefined && { description: node.description }),
|
package/package.json
CHANGED