@elementumai/edk 0.13.1 → 0.13.3
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/context.d.ts +10 -4
- package/dist-sdk/src/engine/pull/context.js +2 -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 +3 -1
- package/dist-sdk/src/engine/pull/stream-root.js +3 -0
- 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/deserializer/print-automation.js +8 -0
- package/dist-sdk/src/entities/automation/module.js +29 -7
- package/dist-sdk/src/entities/automation/omitted-ref.d.ts +12 -0
- package/dist-sdk/src/entities/automation/omitted-ref.js +21 -0
- package/dist-sdk/src/entities/automation/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/automation/to-tf.js +101 -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/build.d.ts +12 -7
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +37 -21
- 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 +11 -3
- 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/dist-sdk/src/entities/widget/from-tf.js +8 -4
- package/dist-sdk/src/graph/index.d.ts +1 -1
- package/dist-sdk/src/graph/types.d.ts +13 -0
- package/package.json +1 -1
|
@@ -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
|
});
|
|
@@ -2043,6 +2051,13 @@ function findRelatedRecordsAppTitleWireKey(name, taskRefKey, refs) {
|
|
|
2043
2051
|
return names?.get("id") ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.id;
|
|
2044
2052
|
}
|
|
2045
2053
|
function taskWireRefName(name, taskRefKey, refs) {
|
|
2054
|
+
// A Run Automation task's refs are keyed by the called automation's published
|
|
2055
|
+
// output names, exactly as written (#3026). None of the record/trigger
|
|
2056
|
+
// display-name rewrites below apply: an output named `status`, `id`, `title`
|
|
2057
|
+
// or `record` is not a record field, and rewriting it to "Status"/"ID"/…
|
|
2058
|
+
// indexes a key the refs map does not contain (Invalid index at plan).
|
|
2059
|
+
if (refs.tasks.get(taskRefKey)?.type === TASK_RESOURCES.runAutomation)
|
|
2060
|
+
return name;
|
|
2046
2061
|
assertFindRelatedRecordsHasNoCountRef(refs.tasks.get(taskRefKey)?.type, name, taskRefKey);
|
|
2047
2062
|
const handleKey = findRelatedRecordsAppTitleWireKey(name, taskRefKey, refs);
|
|
2048
2063
|
if (handleKey !== undefined)
|
|
@@ -2245,9 +2260,38 @@ function assertElementCreateSetsTitle(target, fields) {
|
|
|
2245
2260
|
}
|
|
2246
2261
|
}
|
|
2247
2262
|
/**
|
|
2248
|
-
*
|
|
2249
|
-
* workflow,
|
|
2250
|
-
*
|
|
2263
|
+
* An output must read a task of this automation, and (for new source) a task
|
|
2264
|
+
* at the top level of the workflow, not one inside a switch case, for-each
|
|
2265
|
+
* loop or fork/join branch.
|
|
2266
|
+
*
|
|
2267
|
+
* Evidence (mobius, 2026-11-18; ironman live test on the same day):
|
|
2268
|
+
* - The publish the provider uses, `workflowValidate(publishOnSuccess: true)`
|
|
2269
|
+
* (also the web app's v3 Publish button), checks each output against the
|
|
2270
|
+
* references available after the last top-level task
|
|
2271
|
+
* (`WorkflowValidationService.validateOutputReferences` and
|
|
2272
|
+
* `getOutputPropertyValidationResults`; the last task comes from
|
|
2273
|
+
* `WorkflowTaskRepository.findLastTaskIdByWorkflowIdAndVersion`, which
|
|
2274
|
+
* follows top-level tasks only, and `ValueReferenceService.getTaskChain`
|
|
2275
|
+
* walks back from it). A task inside a switch case, for-each loop or
|
|
2276
|
+
* fork/join branch is not among them, so the publish fails: "Output 'X' has
|
|
2277
|
+
* a value reference that is no longer valid." Saving such an output
|
|
2278
|
+
* succeeds; it reads back with `valid: false`. A fork/join in that chain
|
|
2279
|
+
* adds only the branch outputs its own output mappings promote
|
|
2280
|
+
* (`TaskChainValueRefCollector.collectForkJoinOutput`,
|
|
2281
|
+
* `TaskValueReferenceUtil.getForkJoinBranchGroups`). `elementum_fork_join_task`
|
|
2282
|
+
* carries no output mappings, so a fork/join built from source promotes none.
|
|
2283
|
+
* - The legacy admin automation page publishes with
|
|
2284
|
+
* `workflowUpdate(status: ACTIVE)`, which skips that check
|
|
2285
|
+
* (`WorkflowService.updateWorkflow`). Live automations with such outputs
|
|
2286
|
+
* exist that way (Sanofi Dev's luma app has 12). At run time a switch case's
|
|
2287
|
+
* task outputs are promoted past the switch and resolve; a for-each body's
|
|
2288
|
+
* are not, so that output is left out (`SwitchCaseNodeRunner`,
|
|
2289
|
+
* `EngineValueStore`).
|
|
2290
|
+
*
|
|
2291
|
+
* So pull prints such an output and records it, and build keeps it only
|
|
2292
|
+
* while the revision record lists it (#2283); a new one fails here. An apply
|
|
2293
|
+
* that republishes a recorded one still fails at the platform's publish
|
|
2294
|
+
* check until the output reads a top-level task.
|
|
2251
2295
|
*/
|
|
2252
2296
|
function assertPublishableOutputTask(outputName, value, topLevelTasks, refs) {
|
|
2253
2297
|
while (isObject(value) && "value" in value && Object.keys(value).length === 1) {
|
|
@@ -2259,10 +2303,11 @@ function assertPublishableOutputTask(outputName, value, topLevelTasks, refs) {
|
|
|
2259
2303
|
if (!refs.tasks.has(taskRefKey)) {
|
|
2260
2304
|
throw new EntityTfError(`automation output "${outputName}" references task "${taskRefKey}", which is not in this automation`);
|
|
2261
2305
|
}
|
|
2262
|
-
if (
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2306
|
+
if (topLevelTasks.some((task) => task.refKey === taskRefKey))
|
|
2307
|
+
return;
|
|
2308
|
+
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; ` +
|
|
2309
|
+
"the platform's publish check accepts outputs only from top-level tasks, so an apply that publishes this automation fails. " +
|
|
2310
|
+
"Copy the value into a variable at the top level and output that.", "this output");
|
|
2266
2311
|
}
|
|
2267
2312
|
/**
|
|
2268
2313
|
* workflow_publish outputs must match provider Read / ei export: a typed
|
|
@@ -2286,8 +2331,14 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2286
2331
|
}
|
|
2287
2332
|
return valueToTf(value, refs);
|
|
2288
2333
|
}
|
|
2334
|
+
/** Tasks whose `record.<field>` outputs the platform stores by field id. */
|
|
2335
|
+
const RECORD_FIELD_ID_OUTPUT_TASK_TYPES = new Set([
|
|
2336
|
+
"elementum_create_record_task",
|
|
2337
|
+
"elementum_record_search_task",
|
|
2338
|
+
]);
|
|
2289
2339
|
/**
|
|
2290
|
-
* A field of the record a `createRecord` task made
|
|
2340
|
+
* A field of the record a `createRecord` task made or a `recordSearch` task
|
|
2341
|
+
* found, in any app or element,
|
|
2291
2342
|
* embedded as a LIVE field `.id` reference instead of a resolved display name.
|
|
2292
2343
|
* Confirmed live (demoapptwo, #1066): the platform stores this specific
|
|
2293
2344
|
* reference shape as `"record.<field-platform-id>.<suffix>"` — the SAME raw
|
|
@@ -2311,12 +2362,19 @@ function workflowPublishOutputValueToTf(value, refs) {
|
|
|
2311
2362
|
* target's custom field resource, its `<owner>_<key>_field_id` system-field
|
|
2312
2363
|
* local, or a `data.elementum_field` lookup for an app/element outside this
|
|
2313
2364
|
* build. A field it can't resolve returns `undefined` and keeps the
|
|
2314
|
-
* display-name path.
|
|
2315
|
-
*
|
|
2316
|
-
*
|
|
2365
|
+
* display-name path.
|
|
2366
|
+
*
|
|
2367
|
+
* A recordSearch output reading a field of the record it found is stored the
|
|
2368
|
+
* same way (edk#3006): Sanofi Luma's `VC: Network ID Test` reads the found
|
|
2369
|
+
* record's Title as `record.<Title field id>`, and its iLearn automations
|
|
2370
|
+
* read the found user's title field (`USER_NAME`) the same way. The display
|
|
2371
|
+
* name ("Title", "USER_NAME") republished those automations on every plan
|
|
2372
|
+
* after a pull, and on ironman the platform rejects it at publish ("Output
|
|
2373
|
+
* ... has a value reference that is no longer valid"). findRelatedRecords
|
|
2374
|
+
* field access isn't confirmed for outputs and stays on the display-name path.
|
|
2317
2375
|
*/
|
|
2318
|
-
function
|
|
2319
|
-
if (target
|
|
2376
|
+
function recordFieldIdOutputRefTfValue(target, name, taskRefKey, refs) {
|
|
2377
|
+
if (target === undefined || !RECORD_FIELD_ID_OUTPUT_TASK_TYPES.has(target.type))
|
|
2320
2378
|
return undefined;
|
|
2321
2379
|
const parts = foundRecordFieldReferenceName(target.type, name, taskRefKey, refs);
|
|
2322
2380
|
return parts === undefined ? undefined : expr.template(parts);
|
|
@@ -2352,8 +2410,8 @@ function taskReferenceEnvelope(value, refs) {
|
|
|
2352
2410
|
// canonical output is ever spelled `record.<field>` (the contract has
|
|
2353
2411
|
// record/records/recordId), so that dotted prefix uniquely marks it.
|
|
2354
2412
|
const isRecordFieldRef = canonicalName.startsWith("record.");
|
|
2355
|
-
const
|
|
2356
|
-
const platformRefName =
|
|
2413
|
+
const recordFieldIdRef = recordFieldIdOutputRefTfValue(target, canonicalName, taskRef.taskRefKey, refs);
|
|
2414
|
+
const platformRefName = recordFieldIdRef
|
|
2357
2415
|
?? (isFileReaderTask
|
|
2358
2416
|
? canonicalName
|
|
2359
2417
|
: isRecordFieldRef
|
|
@@ -3748,11 +3806,16 @@ function filterToTf(value, refs) {
|
|
|
3748
3806
|
});
|
|
3749
3807
|
}
|
|
3750
3808
|
/**
|
|
3751
|
-
*
|
|
3752
|
-
*
|
|
3753
|
-
*
|
|
3809
|
+
* The platform-managed system fields (the platform marks them `system: true`;
|
|
3810
|
+
* Title, Status and Stage are not). A record trigger can list them in
|
|
3811
|
+
* changed_fields: the platform stores and publishes that. But it never fires on
|
|
3812
|
+
* one (edk#2989): ultron sends a system field's change in the event's
|
|
3813
|
+
* `systemChanges`, and mobius matches changed_fields only against `changes`
|
|
3814
|
+
* (`AspectRecordFilterService.filter` → `FieldsEntityEvent.getChanges()`).
|
|
3815
|
+
* Build keeps them as authored, since dropping one changes what the trigger
|
|
3816
|
+
* watches (an emptied list fires on every change), and warns instead.
|
|
3754
3817
|
*/
|
|
3755
|
-
const
|
|
3818
|
+
const NEVER_FIRING_SYSTEM_FIELD_KEYS = new Set(["id", "createdAt", "createdBy", "updatedAt", "updatedBy", "closedAt", "closedBy"]);
|
|
3756
3819
|
function isRunAutomationValueReference(raw) {
|
|
3757
3820
|
if (!isObject(raw))
|
|
3758
3821
|
return false;
|
|
@@ -4116,21 +4179,26 @@ function configAttrs(kind, config, refs) {
|
|
|
4116
4179
|
continue;
|
|
4117
4180
|
}
|
|
4118
4181
|
if (key === "changedFieldIds" && Array.isArray(raw)) {
|
|
4119
|
-
|
|
4182
|
+
// edk#2989: every listed field is kept, system fields included. Dropping
|
|
4183
|
+
// one changes what the trigger watches, and an emptied changed_fields
|
|
4184
|
+
// fires on every field change.
|
|
4185
|
+
const neverFiring = raw.flatMap((field) => {
|
|
4120
4186
|
const fieldToken = token(field);
|
|
4121
|
-
|
|
4122
|
-
|
|
4123
|
-
refs.owner.fieldAddresses.has(fieldToken.refName)
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
return false;
|
|
4187
|
+
return fieldToken?.__kind === "field" &&
|
|
4188
|
+
NEVER_FIRING_SYSTEM_FIELD_KEYS.has(fieldToken.refName) &&
|
|
4189
|
+
!refs.owner.fieldAddresses.has(fieldToken.refName)
|
|
4190
|
+
? [`"${fieldToken.name ?? fieldToken.refName}"`]
|
|
4191
|
+
: [];
|
|
4127
4192
|
});
|
|
4128
|
-
|
|
4129
|
-
|
|
4130
|
-
|
|
4131
|
-
|
|
4193
|
+
if (neverFiring.length > 0) {
|
|
4194
|
+
refs.owner.diagnostics.push(`automation ${refs.owner.automationTfLabel}: changedFields lists system field${neverFiring.length > 1 ? "s" : ""} ${neverFiring.join(", ")}; ` +
|
|
4195
|
+
"the platform never fires a record trigger on a system field's change" +
|
|
4196
|
+
(neverFiring.length === raw.length
|
|
4197
|
+
? ", so this trigger never fires. "
|
|
4198
|
+
: ", so only the other listed fields fire it. ") +
|
|
4199
|
+
"Kept as listed: removing a field would change what the trigger watches (with none left, it fires on every change)");
|
|
4132
4200
|
}
|
|
4133
|
-
attrs.changed_fields = valueToTf(
|
|
4201
|
+
attrs.changed_fields = valueToTf(raw, refs);
|
|
4134
4202
|
continue;
|
|
4135
4203
|
}
|
|
4136
4204
|
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",
|
|
@@ -94,6 +94,15 @@ interface DynamicLayoutComponentCommon<ComponentKey extends string = string, Con
|
|
|
94
94
|
readonly saveGroup?: SaveGroupKey;
|
|
95
95
|
readonly blockId?: string;
|
|
96
96
|
}
|
|
97
|
+
interface DynamicLayoutActionButton {
|
|
98
|
+
readonly label?: string;
|
|
99
|
+
readonly variant?: "default" | "outline" | "ghost";
|
|
100
|
+
readonly icon?: string;
|
|
101
|
+
readonly color?: string;
|
|
102
|
+
readonly fullWidth?: boolean;
|
|
103
|
+
/** Display widget on the layout's owner that the layout editor tied to the button. */
|
|
104
|
+
readonly widget?: WidgetRef;
|
|
105
|
+
}
|
|
97
106
|
/** @internal Public component variants used to keep the HCL dialect table exhaustive. */
|
|
98
107
|
export interface DynamicLayoutComponentVariantMap {
|
|
99
108
|
readonly container: {
|
|
@@ -167,15 +176,11 @@ export interface DynamicLayoutComponentVariantMap {
|
|
|
167
176
|
/** Run-automation widget the button executes through; omit to have build derive one. */
|
|
168
177
|
readonly widget?: WidgetRef;
|
|
169
178
|
};
|
|
170
|
-
readonly createButton: {
|
|
179
|
+
readonly createButton: DynamicLayoutActionButton & {
|
|
171
180
|
readonly target: AppOrElementRef;
|
|
172
|
-
readonly label?: string;
|
|
173
|
-
readonly variant?: "default" | "outline" | "ghost";
|
|
174
181
|
};
|
|
175
|
-
readonly relateButton: {
|
|
176
|
-
readonly
|
|
177
|
-
readonly variant?: "default" | "outline" | "ghost";
|
|
178
|
-
readonly icon?: string;
|
|
182
|
+
readonly relateButton: DynamicLayoutActionButton & {
|
|
183
|
+
readonly target?: AppOrElementRef;
|
|
179
184
|
};
|
|
180
185
|
readonly updateBlock: DynamicLayoutBlockCommon & {
|
|
181
186
|
readonly fields?: readonly AppViewFieldRef[];
|
|
@@ -3,6 +3,7 @@ import { dataRefLabel, optionalString, plainObject, reportAuthoringBlocker, reso
|
|
|
3
3
|
import { isTfExpr, isUuid, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
4
4
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
5
5
|
import { elementAuditFieldReference, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
6
|
+
import { omittedAutomationKey } from "../automation/omitted-ref.js";
|
|
6
7
|
import { filterOwnerForAspect } from "../relationship/from-tf.js";
|
|
7
8
|
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
8
9
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
@@ -206,11 +207,13 @@ function componentMap(values, layoutKey, owner, ctx, where) {
|
|
|
206
207
|
const automationId = automation["automationId"];
|
|
207
208
|
if (automation["automationId"] !== undefined) {
|
|
208
209
|
const label = resourceRefLabel(automation["automationId"], "elementum_automation");
|
|
209
|
-
|
|
210
|
+
const ref = label !== undefined
|
|
210
211
|
// The display name lets build look the automation up when pull
|
|
211
212
|
// leaves it platform-managed, so it is not in source (edk#2693).
|
|
212
|
-
|
|
213
|
-
|
|
213
|
+
? pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, label, "app"), owner.ownerRefName, exportedAutomationName(label, ctx))
|
|
214
|
+
: omittedButtonAutomation(automation["automationId"], owner, ctx);
|
|
215
|
+
if (ref !== undefined)
|
|
216
|
+
automation["automation"] = ref;
|
|
214
217
|
else
|
|
215
218
|
ctx.diagnostics.push(`${where}.components.${id}.automationButton: automation_id is not a managed automation ref; dropped`);
|
|
216
219
|
delete automation["automationId"];
|
|
@@ -264,15 +267,8 @@ function componentMap(values, layoutKey, owner, ctx, where) {
|
|
|
264
267
|
const related = plainUnknownObject(component["relatedItemsBlock"]);
|
|
265
268
|
if (related !== undefined)
|
|
266
269
|
relatedItemsBlock(related, owner, ctx, `${where}.components.${id}.relatedItemsBlock`);
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const ref = aspectRef(create["targetAspectId"], owner, ctx);
|
|
270
|
-
if (ref !== undefined)
|
|
271
|
-
create["target"] = ref;
|
|
272
|
-
else
|
|
273
|
-
ctx.diagnostics.push(`${where}.components.${id}.createButton: target_aspect_id is not resolvable; dropped`);
|
|
274
|
-
delete create["targetAspectId"];
|
|
275
|
-
}
|
|
270
|
+
buttonTarget(plainUnknownObject(component["createButton"]), owner, ctx, `${where}.components.${id}.createButton`);
|
|
271
|
+
buttonTarget(plainUnknownObject(component["relateButton"]), owner, ctx, `${where}.components.${id}.relateButton`);
|
|
276
272
|
out[id] = component;
|
|
277
273
|
}
|
|
278
274
|
return out;
|
|
@@ -303,6 +299,10 @@ function managedParameter(parameter, ctx) {
|
|
|
303
299
|
const automationLabel = automationId === undefined ? undefined : resourceRefLabel(automationId, "elementum_automation");
|
|
304
300
|
return automationLabel === undefined ? undefined : { automationLabel, name };
|
|
305
301
|
}
|
|
302
|
+
function omittedButtonAutomation(value, owner, ctx) {
|
|
303
|
+
const omitted = typeof value === "string" ? omittedAutomationKey(value, owner.ownerTfLabel, ctx) : undefined;
|
|
304
|
+
return omitted === undefined ? undefined : pulledRef("automation", omitted.key, owner.ownerRefName, omitted.name);
|
|
305
|
+
}
|
|
306
306
|
/** Display name of an exported `elementum_automation`, when the stream has one. */
|
|
307
307
|
function exportedAutomationName(label, ctx) {
|
|
308
308
|
const exportedName = ctx.resourceByAddress?.(`elementum_automation.${label}`)?.attrs["name"];
|
|
@@ -331,15 +331,7 @@ function relatedItemsBlock(block, owner, ctx, where) {
|
|
|
331
331
|
else
|
|
332
332
|
ctx.diagnostics.push(`${where}: related_aspect_id is not resolvable; dropped`);
|
|
333
333
|
}
|
|
334
|
-
|
|
335
|
-
delete block["widgetId"];
|
|
336
|
-
if (widgetId !== undefined) {
|
|
337
|
-
const label = resourceRefLabel(widgetId, WIDGET_RESOURCE_TYPE);
|
|
338
|
-
if (label !== undefined)
|
|
339
|
-
block["widget"] = pulledRef("widget", scopedLabelToBagKey(owner.label, label, scopeOf(owner)), owner.ownerRefName);
|
|
340
|
-
else
|
|
341
|
-
ctx.diagnostics.push(`${where}: widget_id is not a managed widget ref; dropped`);
|
|
342
|
-
}
|
|
334
|
+
widgetRef(block, owner, ctx, where);
|
|
343
335
|
const raw = block["filter"];
|
|
344
336
|
delete block["filter"];
|
|
345
337
|
if (raw === undefined)
|
|
@@ -533,6 +525,30 @@ function stageIndex(value, owner) {
|
|
|
533
525
|
}
|
|
534
526
|
return undefined;
|
|
535
527
|
}
|
|
528
|
+
function buttonTarget(button, owner, ctx, where) {
|
|
529
|
+
if (button === undefined)
|
|
530
|
+
return;
|
|
531
|
+
widgetRef(button, owner, ctx, where);
|
|
532
|
+
if (button["targetAspectId"] === undefined)
|
|
533
|
+
return;
|
|
534
|
+
const ref = aspectRef(button["targetAspectId"], owner, ctx);
|
|
535
|
+
if (ref !== undefined)
|
|
536
|
+
button["target"] = ref;
|
|
537
|
+
else
|
|
538
|
+
ctx.diagnostics.push(`${where}: target_aspect_id is not resolvable; dropped`);
|
|
539
|
+
delete button["targetAspectId"];
|
|
540
|
+
}
|
|
541
|
+
function widgetRef(rec, owner, ctx, where) {
|
|
542
|
+
const widgetId = rec["widgetId"];
|
|
543
|
+
delete rec["widgetId"];
|
|
544
|
+
if (widgetId === undefined)
|
|
545
|
+
return;
|
|
546
|
+
const label = resourceRefLabel(widgetId, WIDGET_RESOURCE_TYPE);
|
|
547
|
+
if (label !== undefined)
|
|
548
|
+
rec["widget"] = pulledRef("widget", scopedLabelToBagKey(owner.label, label, scopeOf(owner)), owner.ownerRefName);
|
|
549
|
+
else
|
|
550
|
+
ctx.diagnostics.push(`${where}: widget_id is not a managed widget ref; dropped`);
|
|
551
|
+
}
|
|
536
552
|
function aspectRef(value, owner, ctx) {
|
|
537
553
|
if (resourceRefLabel(value, owner.type) === owner.label)
|
|
538
554
|
return pulledRef(scopeOf(owner), owner.ownerRefName);
|
|
@@ -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);
|
|
@@ -539,14 +541,20 @@ function componentMap(components, layoutKey, layoutLabel, where, opts) {
|
|
|
539
541
|
if (automation !== undefined)
|
|
540
542
|
attrs["automation_button"] = button;
|
|
541
543
|
}
|
|
542
|
-
else if (key === "createButton") {
|
|
544
|
+
else if (key === "createButton" || key === "relateButton") {
|
|
543
545
|
const rec = object(value);
|
|
544
546
|
const button = snakeObject(rec, where, opts);
|
|
545
547
|
delete button["target"];
|
|
546
|
-
|
|
548
|
+
delete button["widget"];
|
|
549
|
+
const target = resolveAspect(rec["target"], `${where}.components.${componentId}.${key}`, opts);
|
|
547
550
|
if (target !== undefined)
|
|
548
551
|
button["target_aspect_id"] = target;
|
|
549
|
-
|
|
552
|
+
if (rec["widget"] !== undefined) {
|
|
553
|
+
const widget = resolveWidget(rec["widget"], `${where}.components.${componentId}.${key}.widget`, opts);
|
|
554
|
+
if (widget !== undefined)
|
|
555
|
+
button["widget_id"] = widget;
|
|
556
|
+
}
|
|
557
|
+
attrs[key === "createButton" ? "create_button" : "relate_button"] = button;
|
|
550
558
|
}
|
|
551
559
|
else if (key === "relatedItemsBlock") {
|
|
552
560
|
attrs["related_items_block"] = relatedItemsBlock(object(value), `${where}.components.${componentId}.relatedItemsBlock`, 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
|
};
|