@elementumai/edk 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist-sdk/src/catalog/factories.js +8 -2
- package/dist-sdk/src/catalog/types.d.ts +5 -0
- package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
- package/dist-sdk/src/engine/coverage-gaps.js +4 -0
- package/dist-sdk/src/engine/ei/run.d.ts +8 -0
- package/dist-sdk/src/engine/ei/run.js +46 -7
- package/dist-sdk/src/engine/pull/context.d.ts +24 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +11 -0
- package/dist-sdk/src/engine/pull/stream-root.js +22 -6
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- package/dist-sdk/src/entities/access-policy/from-tf.js +4 -7
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent/from-tf.js +28 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +3 -1
- package/dist-sdk/src/entities/agent/to-tf.js +21 -3
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +6 -23
- package/dist-sdk/src/entities/app/module.js +2 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.js +2 -2
- package/dist-sdk/src/entities/automation/build.d.ts +10 -1
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +1 -0
- package/dist-sdk/src/entities/automation/from-tf.js +72 -11
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +12 -0
- package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
- package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
- package/dist-sdk/src/entities/automation/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/automation/to-tf.js +227 -27
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +5 -21
- package/dist-sdk/src/entities/element/module.js +2 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +25 -2
- package/dist-sdk/src/entities/field/from-tf.js +119 -14
- package/dist-sdk/src/entities/relationship/from-tf.js +2 -2
- package/dist-sdk/src/entities/role/build.d.ts +3 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
- package/dist-sdk/src/entities/search-table/build.js +4 -4
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
- package/dist-sdk/src/entities/shared/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +24 -13
- package/dist-sdk/src/entities/shared/filters/index.js +12 -1
- package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +15 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +4 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +16 -0
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +2 -5
- package/dist-sdk/src/entities/task/from-tf.js +3 -3
- package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
- package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
- package/dist-sdk/src/entities/view/from-tf.js +9 -0
- package/dist-sdk/src/entities/view/to-tf.js +66 -47
- package/dist-sdk/src/entities/visual-flow/module.js +52 -1
- package/dist-sdk/src/entities/widget/from-tf.js +6 -6
- package/dist-sdk/src/graph/index.d.ts +4 -0
- package/dist-sdk/src/graph/index.js +1 -0
- package/dist-sdk/src/graph/modules.js +2 -0
- package/dist-sdk/src/graph/types.d.ts +36 -1
- package/package.json +2 -2
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
* import blocks and stay data-side — they never reach printed source.
|
|
9
9
|
*/
|
|
10
10
|
import { autoShareFromTf } from "./auto-share.js";
|
|
11
|
-
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS,
|
|
11
|
+
import { DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, SYSTEM_FIELD_KEYS, SYSTEM_FIELD_KEY_BY_HCL_KEY, SYSTEM_FIELD_TAG_BY_KEY, } from "../../core/system-fields.js";
|
|
12
12
|
import { EntityTfError } from "../../engine/entity.js";
|
|
13
13
|
import { dataRefLabel, optionalString, plainObject } from "../../engine/pull/context.js";
|
|
14
|
-
import {
|
|
14
|
+
import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
15
15
|
import { accessPolicyBlocksInLabelOrder, accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
16
16
|
import { dynamicLayoutCompanionWidgetLabels, dynamicLayoutsFromTf, } from "../dynamic-layout/from-tf.js";
|
|
17
17
|
import { dashboardsFromTf } from "../dashboard/from-tf.js";
|
|
18
|
-
import {
|
|
18
|
+
import { fieldsFromTf } from "../field/from-tf.js";
|
|
19
19
|
import { optionsFromTf } from "../field/options.js";
|
|
20
20
|
import { recordCreateFormFromTf } from "../record-create-form/from-tf.js";
|
|
21
21
|
import { relationshipsFromTf } from "../relationship/from-tf.js";
|
|
@@ -145,25 +145,8 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
145
145
|
// --- System-field attributes/config → tagged NormalizedField entries.
|
|
146
146
|
const fields = [];
|
|
147
147
|
const owner = { type: APP_RESOURCE_TYPE, label, scope: "app", refName };
|
|
148
|
-
//
|
|
149
|
-
|
|
150
|
-
const usedFieldKeys = new Set();
|
|
151
|
-
const nonReservedBlocks = [];
|
|
152
|
-
const reservedBlocks = [];
|
|
153
|
-
for (const block of fieldBlocks) {
|
|
154
|
-
if (block.label === undefined) {
|
|
155
|
-
nonReservedBlocks.push(block);
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
const natural = scopedLabelToBagKey(label, block.label, "app");
|
|
159
|
-
(SYSTEM_FIELD_KEY_SET.has(natural) ? reservedBlocks : nonReservedBlocks).push(block);
|
|
160
|
-
}
|
|
161
|
-
const customFields = [];
|
|
162
|
-
for (const block of [...nonReservedBlocks, ...reservedBlocks]) {
|
|
163
|
-
const entry = fieldFromTf(block, owner, ctx, usedFieldKeys);
|
|
164
|
-
if (entry !== undefined)
|
|
165
|
-
customFields.push(entry);
|
|
166
|
-
}
|
|
148
|
+
// Custom fields in the live field order, keys claimed two-pass (#1871 B1, edk#2920).
|
|
149
|
+
const customFields = fieldsFromTf(fieldBlocks, owner, ctx);
|
|
167
150
|
const systemConfig = systemFieldConfigFromTf(attrs["system_field_config"], `app "${label}"`, ctx);
|
|
168
151
|
const titleName = optionalString(attrs, "title_field_name", `app "${label}"`, ctx);
|
|
169
152
|
if (titleName !== undefined || titleFieldDescription !== undefined || systemConfig.has("title")) {
|
|
@@ -234,7 +217,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
|
|
|
234
217
|
const fieldKeys = new Set(fields.map((field) => field.key));
|
|
235
218
|
// Every field reference pull writes keeps an unextracted field as its platform id (#1736, #1966).
|
|
236
219
|
const fieldKeysByName = fieldKeysByDisplayName(fields);
|
|
237
|
-
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "app", ownerType: "APP_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx);
|
|
220
|
+
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "app", ownerType: "APP_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx, viewBlocks.dashboardWidgetOrderBlocks);
|
|
238
221
|
const unextracted = { type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app", fieldKeys, fieldKeysByName, unextractedFieldIds };
|
|
239
222
|
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, agentViews, customViews, viewOrder, deleteDefaultListView } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, viewBlocks.agentViewBlocks, viewBlocks.managedViewOrderBlocks, {
|
|
240
223
|
type: APP_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "app",
|
|
@@ -28,6 +28,7 @@ function extractAppStreamRoot(stream, ctx) {
|
|
|
28
28
|
const relationshipBlocks = stream.byKind.get("relationship") ?? [];
|
|
29
29
|
const dashboardBlocks = stream.byKind.get("dashboard") ?? [];
|
|
30
30
|
const dashboardWidgetBlocks = stream.byKind.get("dashboard-widget") ?? [];
|
|
31
|
+
const dashboardWidgetOrderBlocks = stream.byKind.get("dashboard-widget-order") ?? [];
|
|
31
32
|
const widgetBlocks = stream.byKind.get("widget") ?? [];
|
|
32
33
|
const accessPolicyBlocks = stream.byKind.get("access-policy") ?? [];
|
|
33
34
|
const roleBlocks = stream.byKind.get("role") ?? [];
|
|
@@ -49,6 +50,7 @@ function extractAppStreamRoot(stream, ctx) {
|
|
|
49
50
|
relationshipBlocks,
|
|
50
51
|
dashboardBlocks,
|
|
51
52
|
dashboardWidgetBlocks,
|
|
53
|
+
dashboardWidgetOrderBlocks,
|
|
52
54
|
widgetBlocks,
|
|
53
55
|
}, accessPolicyBlocks, roleBlocks, serviceAccountBlocks);
|
|
54
56
|
return {
|
|
@@ -83,7 +83,7 @@ export function approvalChainFromTf(block, appTfLabel, ctx, stageHandles, scope
|
|
|
83
83
|
// Keep literal IDs literal even when state can identify the corresponding
|
|
84
84
|
// system field. Export deliberately avoids the owning app's computed
|
|
85
85
|
// `*_field_id` locals because they can be null during fresh import.
|
|
86
|
-
const key = fieldKeyFromTfRef(value, appTfLabel, scope);
|
|
86
|
+
const key = fieldKeyFromTfRef(value, appTfLabel, scope, ctx);
|
|
87
87
|
if (key !== undefined) {
|
|
88
88
|
lockedFields.push(key);
|
|
89
89
|
continue;
|
|
@@ -125,7 +125,7 @@ export function approvalChainFromTf(block, appTfLabel, ctx, stageHandles, scope
|
|
|
125
125
|
// unsafePlatformId" when the list is kept; otherwise the all-or-nothing
|
|
126
126
|
// unmanaged warning alone is accurate.
|
|
127
127
|
for (const value of rawFilters) {
|
|
128
|
-
const key = fieldKeyFromTfRef(value, appTfLabel, scope);
|
|
128
|
+
const key = fieldKeyFromTfRef(value, appTfLabel, scope, ctx);
|
|
129
129
|
if (key !== undefined) {
|
|
130
130
|
entries.push({ key });
|
|
131
131
|
continue;
|
|
@@ -321,7 +321,7 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
|
|
|
321
321
|
initiateCall<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").InitiateCallOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
322
322
|
recordFieldLocking<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").RecordFieldLockingOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
323
323
|
unimplementedTask<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").UnimplementedTaskOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
324
|
-
forEach<TName extends string, TForEachItem>(name: TName, opts: ForEachConfig<TTrigger, TActions, TVars, TItem, TForEachItem, TName>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName,
|
|
324
|
+
forEach<TName extends string, TForEachItem>(name: TName, opts: ForEachConfig<TTrigger, TActions, TVars, TItem, TForEachItem, TName>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, ForEachOutput>;
|
|
325
325
|
switch<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, SwitchConfig<TTrigger, TActions, TVars, TItem>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
326
326
|
forkJoin<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, ForkJoinConfig<TTrigger, TActions, TVars, TItem>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
|
|
327
327
|
}
|
|
@@ -343,6 +343,15 @@ export type ForEachBuilder<TTrigger, TActions extends Record<string, unknown>, T
|
|
|
343
343
|
export type SwitchCaseBuilder<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown>, TItem = never> = NestedActionBuilder<TTrigger, TActions, TVars, TItem>;
|
|
344
344
|
/** A forkJoin branch body builder. */
|
|
345
345
|
export type ForkJoinBranchBuilder<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown>, TItem = never> = NestedActionBuilder<TTrigger, TActions, TVars, TItem>;
|
|
346
|
+
/**
|
|
347
|
+
* A forEach task's own output, readable only after the loop
|
|
348
|
+
* (`ctx.actions.<loop>.iteration`): its last iteration number. Inside the
|
|
349
|
+
* body, use `ctx.item.metadata.iteration` instead; the platform rejects the
|
|
350
|
+
* loop's own output there (#2943).
|
|
351
|
+
*/
|
|
352
|
+
export interface ForEachOutput {
|
|
353
|
+
readonly iteration: number;
|
|
354
|
+
}
|
|
346
355
|
export interface ForEachConfig<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown>, TEnclosingItem, TItem, TName extends string = string> {
|
|
347
356
|
readonly collection: Ref<readonly TItem[]> | ((ctx: NestedActionContext<TTrigger, TActions, TVars, TEnclosingItem>) => Ref<readonly TItem[]>);
|
|
348
357
|
/** The loop body. Its context adds `ctx.item` and this loop as `ctx.loops.<name>`. */
|
|
@@ -1951,6 +1951,7 @@ function printFilter(filter, state, refCtx = DEFAULT_CTX) {
|
|
|
1951
1951
|
reference: (reference) => printFilterReference(reference, state, refCtx),
|
|
1952
1952
|
quote,
|
|
1953
1953
|
used: (helper) => state.imports.filterOps.add(helper),
|
|
1954
|
+
user: (email) => `${trackFactory("userRef", state)}(${quote(email)})`,
|
|
1954
1955
|
});
|
|
1955
1956
|
}
|
|
1956
1957
|
/**
|
|
@@ -17,7 +17,7 @@ import { SEARCH_TABLE_RESOURCE_TYPES } from "../search-table/types.js";
|
|
|
17
17
|
import { outputFieldTypesFromScriptSchema, repeatedScriptOutputNames, scriptOutputReferenceIsDeclared } from "./output-field-types.js";
|
|
18
18
|
import { apiTaskRefAuthoringPath, executeScriptAuthoringPath, matchesOutputWireKey, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
|
|
19
19
|
import { RESOURCE_TYPE_TO_EXECUTOR, TASK_OUTPUT_CONTRACTS } from "./generated/task-output-contracts.js";
|
|
20
|
-
import { systemRefNameRoundTrips } from "./system-ref-name.js";
|
|
20
|
+
import { auditRefNeedsProviderAlias, systemRefNameRoundTrips } from "./system-ref-name.js";
|
|
21
21
|
import { taskTfLabel } from "./task-label.js";
|
|
22
22
|
import { parseTriggerAttachmentPayloadRefJson, parseTriggerWholeRecordRefJson, TASK_OUTPUT_REFERENCE_NAMES, TRIGGER_WHOLE_RECORD_REF_NAME } from "./task-output-labels.js";
|
|
23
23
|
import { workflowOutputTypeFromFieldType } from "./workflow-output.js";
|
|
@@ -445,7 +445,7 @@ function recordFieldRefPath(wireName, ctx, ownerRefName = ctx.appRefName, rootNa
|
|
|
445
445
|
return [rootName, fieldKey, ...suffixPath];
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
const systemPath = systemFieldRefPath(wireName);
|
|
448
|
+
const systemPath = systemFieldRefPath(wireName, customFieldNamed(ownerRefName, ctx));
|
|
449
449
|
if (systemPath === undefined)
|
|
450
450
|
return undefined;
|
|
451
451
|
// A leftover default wire name after a Title/Handle/Status rename must not
|
|
@@ -501,9 +501,16 @@ function renamableSystemFieldKeyByDisplayName(displayNameLower, ctx) {
|
|
|
501
501
|
}
|
|
502
502
|
return undefined;
|
|
503
503
|
}
|
|
504
|
+
/**
|
|
505
|
+
* A display-name match to a system key decodes here only when the build
|
|
506
|
+
* emits the same key; a platform audit spelling that needs the provider's
|
|
507
|
+
* alias goes through systemFieldRefPath, which checks the owner first.
|
|
508
|
+
*/
|
|
504
509
|
function systemFieldPathRoundTrips(fieldKey, wireSuffix, wireName) {
|
|
505
|
-
|
|
506
|
-
|
|
510
|
+
if (!SYSTEM_FIELD_KEY_SET.has(fieldKey))
|
|
511
|
+
return true;
|
|
512
|
+
const key = fieldKey;
|
|
513
|
+
return systemRefNameRoundTrips(key, wireSuffix, wireName) && !auditRefNeedsProviderAlias(key, wireSuffix, wireName);
|
|
507
514
|
}
|
|
508
515
|
/**
|
|
509
516
|
* System fields have no `*_field` resource block, so they never appear in
|
|
@@ -511,18 +518,44 @@ function systemFieldPathRoundTrips(fieldKey, wireSuffix, wireName) {
|
|
|
511
518
|
* when a rebuild of the typed path emits the same refs key; otherwise the
|
|
512
519
|
* caller keeps the org's exact label.
|
|
513
520
|
*/
|
|
514
|
-
function systemFieldRefPath(wireName) {
|
|
521
|
+
function systemFieldRefPath(wireName, deployDefaultTaken) {
|
|
515
522
|
const wireNameLower = wireName.toLowerCase();
|
|
516
523
|
for (const key of SYSTEM_FIELD_KEYS) {
|
|
517
524
|
const defaultName = DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key];
|
|
518
525
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
526
|
+
// A platform-named audit field ("Created on", edk#2936) rebuilds under
|
|
527
|
+
// the deploy default, which the provider publishes as its alias. Not
|
|
528
|
+
// when a custom field may hold that name: the alias would not be added
|
|
529
|
+
// and the rebuilt key would read the custom field.
|
|
530
|
+
const viaAlias = auditRefNeedsProviderAlias(key, suffix, wireName);
|
|
531
|
+
if (!viaAlias && wireNameLower !== `${defaultName}${suffix}`.toLowerCase())
|
|
532
|
+
continue;
|
|
533
|
+
if (!systemRefNameRoundTrips(key, suffix, wireName))
|
|
534
|
+
continue;
|
|
535
|
+
if (viaAlias && deployDefaultTaken(defaultName))
|
|
536
|
+
continue;
|
|
537
|
+
return [key, ...suffixPath];
|
|
522
538
|
}
|
|
523
539
|
}
|
|
524
540
|
return undefined;
|
|
525
541
|
}
|
|
542
|
+
/**
|
|
543
|
+
* Whether the owner may have a custom (non-system) field with this display
|
|
544
|
+
* name. An owner whose fields this pull doesn't know (an unknown loop item
|
|
545
|
+
* owner, an aspect never pulled) counts as having one, so a platform-named
|
|
546
|
+
* audit ref stays a raw key there: the build-vs-export check reads both
|
|
547
|
+
* spellings as one key (mapKeyAliases) and would not catch a wrong decode.
|
|
548
|
+
*/
|
|
549
|
+
function customFieldNamed(ownerRefName, ctx) {
|
|
550
|
+
const known = ownerRefName !== undefined &&
|
|
551
|
+
(ownerRefName === ctx.appRefName || ctx.fieldNamesByOwnerRefName?.has(ownerRefName) === true);
|
|
552
|
+
if (!known)
|
|
553
|
+
return () => true;
|
|
554
|
+
return (displayName) => {
|
|
555
|
+
const key = lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx);
|
|
556
|
+
return key !== undefined && !SYSTEM_FIELD_KEY_SET.has(key);
|
|
557
|
+
};
|
|
558
|
+
}
|
|
526
559
|
const RECORD_BEARING_TRIGGER_TYPES = new Set([
|
|
527
560
|
"elementum_record_created_trigger",
|
|
528
561
|
"elementum_record_updated_trigger",
|
|
@@ -864,12 +897,16 @@ function taskRecordSearchFieldPath(taskAddress, wireName, ctx) {
|
|
|
864
897
|
for (const [suffix, suffixPath] of FIELD_REF_SUFFIX_FROM_WIRE) {
|
|
865
898
|
for (const base of suffix === "" ? [wireName] : wireName.endsWith(suffix) ? [wireName.slice(0, -suffix.length)] : []) {
|
|
866
899
|
const fieldKey = lookupFieldKeyByDisplayName(ownerRefName, base, ctx);
|
|
867
|
-
if (fieldKey !== undefined &&
|
|
900
|
+
if (fieldKey !== undefined &&
|
|
901
|
+
(suffix === "" || wireNameLower === `${base}${suffix}`.toLowerCase()) &&
|
|
902
|
+
systemFieldPathRoundTrips(fieldKey, suffix, wireName)) {
|
|
868
903
|
return ["record", fieldKey, ...suffixPath];
|
|
869
904
|
}
|
|
870
905
|
}
|
|
871
906
|
}
|
|
872
|
-
|
|
907
|
+
// A platform-named audit field ("Created on") decodes like any found
|
|
908
|
+
// record's (#2936): only when its rebuild resolves to the same refs value.
|
|
909
|
+
return recordFieldRefPath(wireName, ctx, ownerRefName);
|
|
873
910
|
}
|
|
874
911
|
/**
|
|
875
912
|
* Sentinel returned by {@link approverReferenceFieldAuthoringType} for a
|
|
@@ -1398,6 +1435,17 @@ function forEachItemFieldKey(fieldPart, loop, ctx) {
|
|
|
1398
1435
|
}
|
|
1399
1436
|
return fieldKeyFromTriggerFieldIdExpr(fieldPart, ctx);
|
|
1400
1437
|
}
|
|
1438
|
+
/**
|
|
1439
|
+
* A loop's refs-map keys for its own metadata (every collection kind) print
|
|
1440
|
+
* as the typed `ctx.item.metadata.<name>`; filters already carry
|
|
1441
|
+
* `for_each.<id>.metadata.<name>` (#2922).
|
|
1442
|
+
*/
|
|
1443
|
+
const FOR_EACH_LOOP_METADATA_FROM_WIRE = {
|
|
1444
|
+
"Is First Item": "first",
|
|
1445
|
+
"Is Last Item": "last",
|
|
1446
|
+
"Iteration": "iteration",
|
|
1447
|
+
"Total Size": "size",
|
|
1448
|
+
};
|
|
1401
1449
|
function forEachItemRefPath(path, ctx, loop) {
|
|
1402
1450
|
const names = pathNames(path);
|
|
1403
1451
|
const itemOwner = forEachItemOwnerRefName(loop, ctx);
|
|
@@ -1440,7 +1488,13 @@ function forEachItemRefPath(path, ctx, loop) {
|
|
|
1440
1488
|
if (recordPath !== undefined)
|
|
1441
1489
|
return recordPath.slice(1);
|
|
1442
1490
|
}
|
|
1443
|
-
|
|
1491
|
+
// pathNames already turned "Iteration" into "iteration"; match the raw key.
|
|
1492
|
+
const rawName = typeof path[0] === "string" ? path[0] : path[0]?.index;
|
|
1493
|
+
if (rawName !== undefined && Object.hasOwn(FOR_EACH_LOOP_METADATA_FROM_WIRE, rawName)) {
|
|
1494
|
+
return ["metadata", FOR_EACH_LOOP_METADATA_FROM_WIRE[rawName]];
|
|
1495
|
+
}
|
|
1496
|
+
return systemFieldRefPath(wireName, customFieldNamed(itemOwner, ctx)) ??
|
|
1497
|
+
names.flatMap((segment) => segment.split("."));
|
|
1444
1498
|
}
|
|
1445
1499
|
function resolveTaskRefKey(taskIdOrKey, ctx) {
|
|
1446
1500
|
if (/^[a-f0-9-]{36}$/.test(taskIdOrKey)) {
|
|
@@ -3506,6 +3560,13 @@ function decodeFilter(value, ctx, fieldScope = "app") {
|
|
|
3506
3560
|
},
|
|
3507
3561
|
reference: (reference, role) => filterReference(reference, ctx, role),
|
|
3508
3562
|
referenceType: (reference, fallback) => filterReferenceType(reference, fallback, ctx),
|
|
3563
|
+
// The exporter turns a user id it knows into a user lookup; that prints as `userRef(email)` (#2891).
|
|
3564
|
+
user: (value) => {
|
|
3565
|
+
if (!isTfExpr(value) || value.$expr !== "data-attr" || value.type !== "elementum_user" || value.path[0] !== "id")
|
|
3566
|
+
return undefined;
|
|
3567
|
+
const decoded = decodeValue(value, ctx);
|
|
3568
|
+
return decoded.kind === "user" && typeof decoded.email === "string" ? decoded.email : undefined;
|
|
3569
|
+
},
|
|
3509
3570
|
literal: (literal, _valueType, field) => picklistOptionLabel(literal) ?? stageFilterName(literal, ctx) ?? filterOptionLabel(literal, field, ctx) ?? literal,
|
|
3510
3571
|
// A plain string builds as literal text, so a stored option id must print
|
|
3511
3572
|
// as `filter.textOption(label)` to build back to that id (#1733).
|
|
@@ -15,7 +15,7 @@ export { AUTOMATION_RESOURCE_TYPES, AUTOMATION_TASK_TYPES, AUTOMATION_TRIGGER_TY
|
|
|
15
15
|
* from v1's deploy-wired builder.
|
|
16
16
|
*/
|
|
17
17
|
export * as filter from "../shared/filters/index.js";
|
|
18
|
-
export { automationStatus, chainableTrigger, actions, automation, type ActionBuilder, type ActionChain, type ActionDef, type ActionOptions, type ActionSequenceDef, type ActionsStarted, type AutomationConfigured, type AutomationOptions, type AutomationStatus, type ForkJoinBranch, type ForkJoinBranchBuilder, type ForkJoinConfig, type ForEachBuilder, type ForEachConfig, type ForEachScope, type LoopScope, type NestedActionBuilder, type NestedActionChain, type NestedActionContext, type OperatorChild, type SwitchCase, type SwitchCaseBuilder, type SwitchConfig, type TriggerChain, type TriggerDef, type TriggerParamMeta } from "./build.js";
|
|
18
|
+
export { automationStatus, chainableTrigger, actions, automation, type ActionBuilder, type ActionChain, type ActionDef, type ActionOptions, type ActionSequenceDef, type ActionsStarted, type AutomationConfigured, type AutomationOptions, type AutomationStatus, type ForkJoinBranch, type ForkJoinBranchBuilder, type ForkJoinConfig, type ForEachBuilder, type ForEachConfig, type ForEachOutput, type ForEachScope, type LoopScope, type NestedActionBuilder, type NestedActionChain, type NestedActionContext, type OperatorChild, type SwitchCase, type SwitchCaseBuilder, type SwitchConfig, type TriggerChain, type TriggerDef, type TriggerParamMeta } from "./build.js";
|
|
19
19
|
export { ScriptCodeError, scriptFile, type ScriptCodeFn, type ScriptFile, type ScriptInput } from "./script-code.js";
|
|
20
20
|
export { unsafeScriptOutput } from "./unsafe-script-output.js";
|
|
21
21
|
export { workflowOutput, workflowOutputType, type WorkflowOutputDeclaration, type WorkflowOutputType, } from "./workflow-output.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/** The automation entity's registry entry (see src/graph/). */
|
|
2
|
+
import { canonicalAuditRefKey } from "./system-ref-name.js";
|
|
2
3
|
import { appScopedResourceLabel, sanitizeName, scopedLabelToBagKey, tfLabelToTsLabel, isTfExpr } from "../../engine/tf/index.js";
|
|
3
4
|
function elementOwnerHandle(payload) {
|
|
4
5
|
if (payload === null || typeof payload !== "object" || !("handle" in payload))
|
|
@@ -585,11 +586,13 @@ export const automationModule = {
|
|
|
585
586
|
: {}),
|
|
586
587
|
...(ctx.elementsWithoutAuditFields !== undefined ? { elementsWithoutAuditFields: ctx.elementsWithoutAuditFields } : {}),
|
|
587
588
|
diagnostics: ctx.diagnostics,
|
|
589
|
+
...(ctx.advisoriesWhileRecorded !== undefined ? { advisoriesWhileRecorded: ctx.advisoriesWhileRecorded } : {}),
|
|
588
590
|
fieldAddresses: ctx.fieldAddresses ?? new Map(),
|
|
589
591
|
fieldNames: ctx.fieldNames ?? new Map(),
|
|
590
592
|
fieldMetadata: ctx.fieldMetadata ?? new Map(),
|
|
591
593
|
...(ctx.fieldNamesByAppRefName !== undefined ? { fieldNamesByAppRefName: ctx.fieldNamesByAppRefName } : {}),
|
|
592
594
|
...(ctx.fieldAddressesByAppRefName !== undefined ? { fieldAddressesByAppRefName: ctx.fieldAddressesByAppRefName } : {}),
|
|
595
|
+
...(ctx.catalogFieldTypesByAppRefName !== undefined ? { catalogFieldTypesByAppRefName: ctx.catalogFieldTypesByAppRefName } : {}),
|
|
593
596
|
...(ctx.authoredAspectKeys !== undefined ? { authoredAspectKeys: ctx.authoredAspectKeys } : {}),
|
|
594
597
|
...(ctx.allowUnknownPicklistOptions === true ? { allowUnknownPicklistOptions: true } : {}),
|
|
595
598
|
...(ctx.optionIds !== undefined ? { optionIds: ctx.optionIds } : {}),
|
|
@@ -647,6 +650,15 @@ export const automationModule = {
|
|
|
647
650
|
{ resourceType: "elementum_create_record_task", attribute: "fields" },
|
|
648
651
|
],
|
|
649
652
|
recordFieldOutputKeys: [{ nameAttribute: "name", ownerAttribute: "object_id" }],
|
|
653
|
+
// A platform-named audit ref ("Created on", or "<input> - Created on")
|
|
654
|
+
// and the provider's alias of it ("Created At"), which a build reads
|
|
655
|
+
// (#2936). The provider skips the alias when the owner has its own
|
|
656
|
+
// "Created At" field, and this check can't see that. It relies on pull:
|
|
657
|
+
// a platform spelling decodes to the typed accessor only for an owner
|
|
658
|
+
// whose fields pull knows and that has no field of the provider's name
|
|
659
|
+
// (customFieldNamed in from-tf.ts); otherwise it stays a raw key on both
|
|
660
|
+
// sides, which this rewrite leaves equal.
|
|
661
|
+
mapKeyAliases: [{ attribute: "refs", canonicalKey: canonicalAuditRefKey }],
|
|
650
662
|
computedReferenceMaps: [{
|
|
651
663
|
resourceType: "elementum_on_demand_trigger",
|
|
652
664
|
attribute: "filter_refs",
|
|
@@ -4,13 +4,33 @@ import { type SystemFieldKey } from "../../core/system-fields.js";
|
|
|
4
4
|
* from DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES, whatever the app authored.
|
|
5
5
|
*/
|
|
6
6
|
export declare const PROVIDER_FIXED_SYSTEM_FIELD_KEYS: ReadonlySet<SystemFieldKey>;
|
|
7
|
+
/**
|
|
8
|
+
* The display names, other than its deploy default, under which a refs map
|
|
9
|
+
* can list an audit field that the provider republishes under the default.
|
|
10
|
+
*/
|
|
11
|
+
export declare function platformAuditRefSpellings(key: SystemFieldKey): readonly string[];
|
|
7
12
|
/** The refs-map key a build emits for a record field display name plus wire suffix. */
|
|
8
13
|
export declare function recordFieldWireRefName(fieldName: string, wireSuffix: string): string;
|
|
9
14
|
/**
|
|
10
15
|
* Whether decoding `wireName` as `<key><wireSuffix>` is lossless: a build of
|
|
11
16
|
* the typed path must emit a key the live refs map resolves identically.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
17
|
+
* Platform-composed apps name audit fields "Closed by" / "Created on"; the
|
|
18
|
+
* typed key rebuilds as "Closed By" / "Created At", which the provider
|
|
19
|
+
* publishes as an alias of the platform-named key (edk#2936). A "Field ID"
|
|
20
|
+
* read is not aliased, so it keeps the org's exact label.
|
|
15
21
|
*/
|
|
16
22
|
export declare function systemRefNameRoundTrips(key: SystemFieldKey, wireSuffix: string, wireName: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Whether `wireName` is a platform spelling of `<key><wireSuffix>` that a
|
|
25
|
+
* build reaches only through the provider's alias ("Created on" for
|
|
26
|
+
* "Created At"). The provider adds no alias when the owner has a field of the
|
|
27
|
+
* provider's name, so a decode must first rule that out.
|
|
28
|
+
*/
|
|
29
|
+
export declare function auditRefNeedsProviderAlias(key: SystemFieldKey, wireSuffix: string, wireName: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The refs key a build emits for an audit ref the provider publishes under
|
|
32
|
+
* several spellings ("Created on", "Created At"; "Created By Email",
|
|
33
|
+
* "Created by Email"), or undefined for any other key. The pull's
|
|
34
|
+
* build-vs-export check reads both spellings as this one.
|
|
35
|
+
*/
|
|
36
|
+
export declare function canonicalAuditRefKey(key: string): string | undefined;
|
|
@@ -23,6 +23,40 @@ const PROVIDER_ALIASED_REF_NAMES = new Map([
|
|
|
23
23
|
["Updated by Manager Email", "Updated By Manager Email"],
|
|
24
24
|
["Updated By Manager Email", "Updated by Manager Email"],
|
|
25
25
|
]);
|
|
26
|
+
/**
|
|
27
|
+
* The names the platform gives an audit field when it composes an app
|
|
28
|
+
* ("Created on") or element ("Created On"); the provider creates them as
|
|
29
|
+
* DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES ("Created At"). Refs keys follow the live
|
|
30
|
+
* display name, so the provider also publishes each platform-named audit ref
|
|
31
|
+
* under the provider's name (addAuditFieldRefAliases in
|
|
32
|
+
* provider/internal/provider/trigger_common.go; keep the two tables in step).
|
|
33
|
+
* A build therefore always emits the provider's name (edk#2936).
|
|
34
|
+
*/
|
|
35
|
+
const PLATFORM_AUDIT_REF_SPELLINGS = {
|
|
36
|
+
createdAt: ["Created on", "Created On"],
|
|
37
|
+
createdBy: ["Created by"],
|
|
38
|
+
updatedAt: ["Updated on", "Updated On"],
|
|
39
|
+
updatedBy: ["Updated by"],
|
|
40
|
+
closedAt: ["Closed on", "Closed On"],
|
|
41
|
+
closedBy: ["Closed by"],
|
|
42
|
+
};
|
|
43
|
+
/** Refs-key suffixes the provider aliases for audit fields (no " Field ID"). */
|
|
44
|
+
const AUDIT_REF_ALIAS_SUFFIXES = new Set([
|
|
45
|
+
"",
|
|
46
|
+
" ID",
|
|
47
|
+
" Email",
|
|
48
|
+
" Name",
|
|
49
|
+
" Manager",
|
|
50
|
+
" Manager Email",
|
|
51
|
+
" Manager Name",
|
|
52
|
+
]);
|
|
53
|
+
/**
|
|
54
|
+
* The display names, other than its deploy default, under which a refs map
|
|
55
|
+
* can list an audit field that the provider republishes under the default.
|
|
56
|
+
*/
|
|
57
|
+
export function platformAuditRefSpellings(key) {
|
|
58
|
+
return PLATFORM_AUDIT_REF_SPELLINGS[key] ?? [];
|
|
59
|
+
}
|
|
26
60
|
/** The refs-map key a build emits for a record field display name plus wire suffix. */
|
|
27
61
|
export function recordFieldWireRefName(fieldName, wireSuffix) {
|
|
28
62
|
const refName = `${fieldName}${wireSuffix}`;
|
|
@@ -36,13 +70,61 @@ export function recordFieldWireRefName(fieldName, wireSuffix) {
|
|
|
36
70
|
/**
|
|
37
71
|
* Whether decoding `wireName` as `<key><wireSuffix>` is lossless: a build of
|
|
38
72
|
* the typed path must emit a key the live refs map resolves identically.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
73
|
+
* Platform-composed apps name audit fields "Closed by" / "Created on"; the
|
|
74
|
+
* typed key rebuilds as "Closed By" / "Created At", which the provider
|
|
75
|
+
* publishes as an alias of the platform-named key (edk#2936). A "Field ID"
|
|
76
|
+
* read is not aliased, so it keeps the org's exact label.
|
|
42
77
|
*/
|
|
43
78
|
export function systemRefNameRoundTrips(key, wireSuffix, wireName) {
|
|
44
79
|
if (!PROVIDER_FIXED_SYSTEM_FIELD_KEYS.has(key))
|
|
45
80
|
return true;
|
|
46
81
|
const emitted = recordFieldWireRefName(DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key], wireSuffix);
|
|
47
|
-
return emitted === wireName || PROVIDER_ALIASED_REF_NAMES.get(emitted) === wireName
|
|
82
|
+
return emitted === wireName || PROVIDER_ALIASED_REF_NAMES.get(emitted) === wireName ||
|
|
83
|
+
auditRefNeedsProviderAlias(key, wireSuffix, wireName);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Whether `wireName` is a platform spelling of `<key><wireSuffix>` that a
|
|
87
|
+
* build reaches only through the provider's alias ("Created on" for
|
|
88
|
+
* "Created At"). The provider adds no alias when the owner has a field of the
|
|
89
|
+
* provider's name, so a decode must first rule that out.
|
|
90
|
+
*/
|
|
91
|
+
export function auditRefNeedsProviderAlias(key, wireSuffix, wireName) {
|
|
92
|
+
if (!PROVIDER_FIXED_SYSTEM_FIELD_KEYS.has(key) || !AUDIT_REF_ALIAS_SUFFIXES.has(wireSuffix))
|
|
93
|
+
return false;
|
|
94
|
+
const emitted = recordFieldWireRefName(DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[key], wireSuffix);
|
|
95
|
+
if (emitted === wireName || PROVIDER_ALIASED_REF_NAMES.get(emitted) === wireName)
|
|
96
|
+
return false;
|
|
97
|
+
return platformAuditRefSpellings(key).some((spelling) => `${spelling}${wireSuffix}` === wireName);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The refs key a build emits for an audit ref the provider publishes under
|
|
101
|
+
* several spellings ("Created on", "Created At"; "Created By Email",
|
|
102
|
+
* "Created by Email"), or undefined for any other key. The pull's
|
|
103
|
+
* build-vs-export check reads both spellings as this one.
|
|
104
|
+
*/
|
|
105
|
+
export function canonicalAuditRefKey(key) {
|
|
106
|
+
// An on-demand trigger with two or more record inputs keys their refs
|
|
107
|
+
// "<input> - <field>"; the provider aliases under that prefix too.
|
|
108
|
+
for (let at = key.indexOf(" - "); at >= 0; at = key.indexOf(" - ", at + 3)) {
|
|
109
|
+
const canonical = unprefixedCanonicalAuditRefKey(key.slice(at + 3));
|
|
110
|
+
if (canonical !== undefined)
|
|
111
|
+
return `${key.slice(0, at + 3)}${canonical}`;
|
|
112
|
+
}
|
|
113
|
+
return unprefixedCanonicalAuditRefKey(key);
|
|
114
|
+
}
|
|
115
|
+
function unprefixedCanonicalAuditRefKey(key) {
|
|
116
|
+
for (const fieldKey of PROVIDER_FIXED_SYSTEM_FIELD_KEYS) {
|
|
117
|
+
const defaultName = DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES[fieldKey];
|
|
118
|
+
for (const suffix of AUDIT_REF_ALIAS_SUFFIXES) {
|
|
119
|
+
const emitted = recordFieldWireRefName(defaultName, suffix);
|
|
120
|
+
if (key === emitted)
|
|
121
|
+
return undefined;
|
|
122
|
+
if (key === `${defaultName}${suffix}` ||
|
|
123
|
+
PROVIDER_ALIASED_REF_NAMES.get(emitted) === key ||
|
|
124
|
+
platformAuditRefSpellings(fieldKey).some((spelling) => key === `${spelling}${suffix}`)) {
|
|
125
|
+
return emitted;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return undefined;
|
|
48
130
|
}
|
|
@@ -2,7 +2,7 @@ import type { DeployableEntity } from "../../engine/entity.js";
|
|
|
2
2
|
import { type ValidationFailure } from "../../engine/validation.js";
|
|
3
3
|
import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
4
4
|
import { type ForeignRootIdentity, type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
|
|
5
|
-
import type { BuildFieldMetadata } from "../../graph/types.js";
|
|
5
|
+
import type { AdvisoryWhileRecorded, BuildFieldMetadata } from "../../graph/types.js";
|
|
6
6
|
import type { AppServiceAccount } from "../service-account/build.js";
|
|
7
7
|
import type { OptionIdIndex } from "../../engine/pull/field-refs-registry.js";
|
|
8
8
|
export interface AutomationToTfContext {
|
|
@@ -34,6 +34,10 @@ export interface AutomationToTfContext {
|
|
|
34
34
|
* searched aspect's own `<resource>.<label>.id` to interpolate.
|
|
35
35
|
*/
|
|
36
36
|
readonly fieldAddressesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
37
|
+
/** Org catalog field types for every app/element it lists, keyed by refName and then field key. */
|
|
38
|
+
readonly catalogFieldTypesByAppRefName?: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
39
|
+
/** Whole-object findings, advisories only while the revision record lists them (#2283). */
|
|
40
|
+
readonly advisoriesWhileRecorded?: AdvisoryWhileRecorded[];
|
|
37
41
|
/**
|
|
38
42
|
* Every app/element authored in the workspace, keyed by
|
|
39
43
|
* `workspaceAspectKey`, including those this build leaves out (pull builds
|