@elementumai/edk 0.12.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 +8 -2
- package/dist-sdk/src/catalog/factories.d.ts +7 -1
- package/dist-sdk/src/catalog/factories.js +10 -2
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/org.js +79 -34
- package/dist-sdk/src/catalog/token.js +5 -0
- package/dist-sdk/src/catalog/types.d.ts +12 -1
- package/dist-sdk/src/catalog/types.js +3 -0
- package/dist-sdk/src/core/system-fields.d.ts +1 -1
- package/dist-sdk/src/core/system-fields.js +1 -1
- package/dist-sdk/src/core/types/app.d.ts +6 -0
- package/dist-sdk/src/engine/build/context.d.ts +3 -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/authored-address.js +42 -6
- package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
- package/dist-sdk/src/engine/pull/authored-root.js +306 -0
- package/dist-sdk/src/engine/pull/context.d.ts +34 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
- package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
- package/dist-sdk/src/engine/pull/org.d.ts +1 -0
- package/dist-sdk/src/engine/pull/org.js +2 -0
- package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
- package/dist-sdk/src/engine/pull/partition.js +43 -0
- package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
- package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
- package/dist-sdk/src/engine/pull/ref-only.js +7 -1
- package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
- package/dist-sdk/src/engine/pull/source-resources.js +110 -0
- package/dist-sdk/src/engine/pull/stream-root.d.ts +159 -0
- package/dist-sdk/src/engine/pull/stream-root.js +579 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
- package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
- package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +17 -5
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
- package/dist-sdk/src/entities/agent/build.d.ts +52 -1
- package/dist-sdk/src/entities/agent/build.js +34 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +70 -1
- package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
- package/dist-sdk/src/entities/agent/from-tf.js +289 -2
- package/dist-sdk/src/entities/agent/index.d.ts +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
- package/dist-sdk/src/entities/agent/to-tf.js +179 -17
- package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
- package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +33 -13
- package/dist-sdk/src/entities/app/build.js +14 -12
- package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/app/from-tf.js +7 -9
- package/dist-sdk/src/entities/app/index.d.ts +1 -0
- package/dist-sdk/src/entities/app/index.js +1 -0
- package/dist-sdk/src/entities/app/module.js +3 -0
- package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
- package/dist-sdk/src/entities/app/stage-keys.js +3 -3
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
- package/dist-sdk/src/entities/approval-chain/build.js +120 -8
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
- package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
- package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
- package/dist-sdk/src/entities/approval-chain/index.js +4 -1
- package/dist-sdk/src/entities/approval-chain/module.js +23 -5
- package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
- package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
- package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
- package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
- package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
- package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
- package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
- package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
- package/dist-sdk/src/entities/automation/build.d.ts +10 -1
- package/dist-sdk/src/entities/automation/build.js +70 -27
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
- package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
- package/dist-sdk/src/entities/automation/from-tf.js +665 -112
- package/dist-sdk/src/entities/automation/index.d.ts +2 -1
- package/dist-sdk/src/entities/automation/index.js +1 -0
- package/dist-sdk/src/entities/automation/module.d.ts +4 -3
- package/dist-sdk/src/entities/automation/module.js +45 -12
- package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
- package/dist-sdk/src/entities/automation/refs-read.js +48 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
- package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -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/task-output-labels.d.ts +11 -0
- package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
- package/dist-sdk/src/entities/automation/tasks.js +34 -11
- package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -1
- package/dist-sdk/src/entities/automation/to-tf.js +563 -103
- package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
- package/dist-sdk/src/entities/automation/triggers.js +26 -11
- package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
- package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
- package/dist-sdk/src/entities/chart/build.d.ts +9 -1
- package/dist-sdk/src/entities/chart/from-tf.js +3 -0
- package/dist-sdk/src/entities/chart/to-tf.js +19 -2
- package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
- package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
- package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
- package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
- package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
- package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
- package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
- package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
- package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
- package/dist-sdk/src/entities/element/build.js +2 -1
- package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/element/from-tf.js +4 -7
- package/dist-sdk/src/entities/element/module.js +5 -0
- package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
- package/dist-sdk/src/entities/element/system-fields.js +23 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +9 -0
- package/dist-sdk/src/entities/field/from-tf.d.ts +52 -1
- package/dist-sdk/src/entities/field/from-tf.js +212 -14
- package/dist-sdk/src/entities/field/module.js +4 -0
- package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
- package/dist-sdk/src/entities/field/to-tf.js +33 -12
- package/dist-sdk/src/entities/org/category.js +1 -0
- package/dist-sdk/src/entities/org/index.d.ts +1 -0
- package/dist-sdk/src/entities/org/index.js +1 -0
- package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
- package/dist-sdk/src/entities/org/voice-auth.js +33 -0
- package/dist-sdk/src/entities/organization/build.d.ts +3 -0
- package/dist-sdk/src/entities/organization/build.js +2 -0
- package/dist-sdk/src/entities/organization/index.d.ts +1 -0
- package/dist-sdk/src/entities/organization/index.js +1 -0
- package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/organization/to-tf.js +59 -1
- package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
- package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
- package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
- package/dist-sdk/src/entities/phone-service/build.js +1 -0
- package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
- package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
- package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +9 -4
- package/dist-sdk/src/entities/relationship/module.js +2 -2
- package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
- package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
- package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
- package/dist-sdk/src/entities/role/build.d.ts +3 -4
- package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
- package/dist-sdk/src/entities/role/permission-levels.js +78 -0
- package/dist-sdk/src/entities/role/to-tf.js +32 -2
- 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/service-account/module.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/module.js +4 -1
- package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
- package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
- package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
- package/dist-sdk/src/entities/shared/context.d.ts +14 -1
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
- package/dist-sdk/src/entities/shared/filters/index.js +30 -7
- package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
- package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
- package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
- package/dist-sdk/src/entities/shared/filters/print.js +19 -6
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
- package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
- package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
- package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -2
- package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
- package/dist-sdk/src/entities/sla/build.d.ts +96 -0
- package/dist-sdk/src/entities/sla/build.js +124 -0
- package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
- package/dist-sdk/src/entities/sla/from-tf.js +164 -0
- package/dist-sdk/src/entities/sla/index.d.ts +1 -0
- package/dist-sdk/src/entities/sla/index.js +1 -0
- package/dist-sdk/src/entities/sla/module.d.ts +4 -0
- package/dist-sdk/src/entities/sla/module.js +73 -0
- package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
- package/dist-sdk/src/entities/sla/printer.js +84 -0
- package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
- package/dist-sdk/src/entities/sla/to-tf.js +81 -0
- package/dist-sdk/src/entities/table/build.d.ts +7 -2
- package/dist-sdk/src/entities/table/build.js +22 -1
- package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
- package/dist-sdk/src/entities/table/from-tf.js +89 -14
- package/dist-sdk/src/entities/table/index.d.ts +1 -1
- package/dist-sdk/src/entities/table/to-tf.js +41 -2
- package/dist-sdk/src/entities/task/from-tf.js +3 -2
- 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 +16 -4
- 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 +19 -8
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
- package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
- package/dist-sdk/src/graph/index.d.ts +9 -0
- package/dist-sdk/src/graph/index.js +8 -0
- package/dist-sdk/src/graph/modules.js +13 -1
- package/dist-sdk/src/graph/resource-types.d.ts +47 -0
- package/dist-sdk/src/graph/resource-types.js +62 -0
- package/dist-sdk/src/graph/types.d.ts +113 -6
- package/package.json +7 -4
|
@@ -2,7 +2,7 @@ import { unsafePlatformId } from "../../core/platform-id.js";
|
|
|
2
2
|
import { dataRefLabel, optionalString, plainObject, reportAuthoringBlocker, resourceRefLabel } from "../../engine/pull/context.js";
|
|
3
3
|
import { isTfExpr, isUuid, scopedLabelToBagKey, tfLabelToTsLabel, } from "../../engine/tf/index.js";
|
|
4
4
|
import { filterFromTf } from "../access-policy/from-tf.js";
|
|
5
|
-
import { fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
5
|
+
import { elementAuditFieldReference, fieldKeyFromTfValue } from "../field/from-tf.js";
|
|
6
6
|
import { filterOwnerForAspect } from "../relationship/from-tf.js";
|
|
7
7
|
import { filterWireToTf } from "../shared/filters/tf-codec.js";
|
|
8
8
|
import { resolveDataAspectTarget } from "../shared/aspect-target-from-tf.js";
|
|
@@ -207,7 +207,9 @@ function componentMap(values, layoutKey, owner, ctx, where) {
|
|
|
207
207
|
if (automation["automationId"] !== undefined) {
|
|
208
208
|
const label = resourceRefLabel(automation["automationId"], "elementum_automation");
|
|
209
209
|
if (label !== undefined) {
|
|
210
|
-
|
|
210
|
+
// The display name lets build look the automation up when pull
|
|
211
|
+
// leaves it platform-managed, so it is not in source (edk#2693).
|
|
212
|
+
automation["automation"] = pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, label, "app"), owner.ownerRefName, exportedAutomationName(label, ctx));
|
|
211
213
|
}
|
|
212
214
|
else
|
|
213
215
|
ctx.diagnostics.push(`${where}.components.${id}.automationButton: automation_id is not a managed automation ref; dropped`);
|
|
@@ -235,8 +237,11 @@ function componentMap(values, layoutKey, owner, ctx, where) {
|
|
|
235
237
|
return [];
|
|
236
238
|
}
|
|
237
239
|
input["parameterName"] = managed.name;
|
|
240
|
+
// The same automation, reached through its on-demand trigger,
|
|
241
|
+
// stays on the button. A different one needs its own display
|
|
242
|
+
// name so build can look it up when it is not in source.
|
|
238
243
|
if (managed.automationLabel !== automationLabel) {
|
|
239
|
-
input["automation"] = pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, managed.automationLabel, "app"), owner.ownerRefName);
|
|
244
|
+
input["automation"] = pulledRef("automation", scopedLabelToBagKey(owner.ownerTfLabel, managed.automationLabel, "app"), owner.ownerRefName, exportedAutomationName(managed.automationLabel, ctx));
|
|
240
245
|
}
|
|
241
246
|
delete input["parameterId"];
|
|
242
247
|
}
|
|
@@ -284,7 +289,13 @@ function managedParameter(parameter, ctx) {
|
|
|
284
289
|
if (parameter.path.length !== 2 || parameter.path[0] !== "parameter_ids" || typeof name !== "string")
|
|
285
290
|
return undefined;
|
|
286
291
|
if (parameter.$expr === "resource-attr") {
|
|
287
|
-
|
|
292
|
+
if (parameter.type !== "elementum_on_demand_trigger")
|
|
293
|
+
return undefined;
|
|
294
|
+
// A single trigger shares the automation's label. A later trigger is
|
|
295
|
+
// `<auto>_<type>_<index>`, so the trigger label is not the automation.
|
|
296
|
+
// Follow the trigger's own `automation` attribute back to the owner.
|
|
297
|
+
const owning = owningAutomationLabel(parameter.label, ctx);
|
|
298
|
+
return { automationLabel: owning ?? parameter.label, name };
|
|
288
299
|
}
|
|
289
300
|
if (parameter.type !== "elementum_automation")
|
|
290
301
|
return undefined;
|
|
@@ -292,6 +303,24 @@ function managedParameter(parameter, ctx) {
|
|
|
292
303
|
const automationLabel = automationId === undefined ? undefined : resourceRefLabel(automationId, "elementum_automation");
|
|
293
304
|
return automationLabel === undefined ? undefined : { automationLabel, name };
|
|
294
305
|
}
|
|
306
|
+
/** Display name of an exported `elementum_automation`, when the stream has one. */
|
|
307
|
+
function exportedAutomationName(label, ctx) {
|
|
308
|
+
const exportedName = ctx.resourceByAddress?.(`elementum_automation.${label}`)?.attrs["name"];
|
|
309
|
+
return typeof exportedName === "string" && exportedName !== "" ? exportedName : undefined;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* The automation an on-demand trigger belongs to. Export writes
|
|
313
|
+
* `automation = elementum_automation.<label>` with no `.id`.
|
|
314
|
+
*/
|
|
315
|
+
function owningAutomationLabel(triggerLabel, ctx) {
|
|
316
|
+
const automation = ctx.resourceByAddress?.(`elementum_on_demand_trigger.${triggerLabel}`)?.attrs["automation"];
|
|
317
|
+
if (automation === undefined || !isTfExpr(automation) || automation.$expr !== "resource-attr" || automation.type !== "elementum_automation") {
|
|
318
|
+
return undefined;
|
|
319
|
+
}
|
|
320
|
+
if (automation.path.length === 0 || (automation.path.length === 1 && automation.path[0] === "id"))
|
|
321
|
+
return automation.label;
|
|
322
|
+
return undefined;
|
|
323
|
+
}
|
|
295
324
|
function relatedItemsBlock(block, owner, ctx, where) {
|
|
296
325
|
const aspectId = block["relatedAspectId"];
|
|
297
326
|
delete block["relatedAspectId"];
|
|
@@ -302,6 +331,15 @@ function relatedItemsBlock(block, owner, ctx, where) {
|
|
|
302
331
|
else
|
|
303
332
|
ctx.diagnostics.push(`${where}: related_aspect_id is not resolvable; dropped`);
|
|
304
333
|
}
|
|
334
|
+
const widgetId = block["widgetId"];
|
|
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
|
+
}
|
|
305
343
|
const raw = block["filter"];
|
|
306
344
|
delete block["filter"];
|
|
307
345
|
if (raw === undefined)
|
|
@@ -438,7 +476,8 @@ function fieldKey(value, owner, ctx, where, site = where) {
|
|
|
438
476
|
// A field pull did not extract keeps its platform id: its key would print
|
|
439
477
|
// as nothing and build would drop the entry (#1966). With no id the pull
|
|
440
478
|
// fails, naming the entry (#1978).
|
|
441
|
-
const
|
|
479
|
+
const kept = owner.unextracted === undefined ? resolved : unextractedFieldRefId(value, resolved, owner.unextracted, ctx, site);
|
|
480
|
+
const key = kept === undefined || kept !== resolved ? kept : elementAuditFieldReference(value, kept, { ...owner, scope: scopeOf(owner) }, ctx);
|
|
442
481
|
if (key === undefined) {
|
|
443
482
|
ctx.diagnostics.push(`${where}: field reference ${JSON.stringify(value)} is not resolvable; dropped`);
|
|
444
483
|
}
|
|
@@ -569,17 +569,22 @@ function automationButtonInput(rec, inputs, where, opts) {
|
|
|
569
569
|
token: rec["automation"],
|
|
570
570
|
value: resolveAutomation(rec["automation"], `${where}.automation`, opts),
|
|
571
571
|
};
|
|
572
|
-
const
|
|
573
|
-
? target.value.label
|
|
574
|
-
: undefined;
|
|
572
|
+
const value = target?.value;
|
|
575
573
|
const name = rec["parameterName"];
|
|
576
|
-
|
|
574
|
+
const ref = value !== undefined && isTfExpr(value) && (value.$expr === "resource-attr" || value.$expr === "data-attr") && value.type === AUTOMATION_RESOURCE_TYPE
|
|
575
|
+
? value
|
|
576
|
+
: undefined;
|
|
577
|
+
if (ref === undefined || typeof name !== "string") {
|
|
577
578
|
opts.diagnostics.push(`${where}: parameterName needs a managed button automation to bind to; dropped`);
|
|
578
579
|
return [];
|
|
579
580
|
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
581
|
+
const label = ref.label;
|
|
582
|
+
// A platform-managed automation is already a lookup of its published workflow.
|
|
583
|
+
out["parameter_id"] = ref.$expr === "data-attr"
|
|
584
|
+
? expr.dataAttr(AUTOMATION_RESOURCE_TYPE, label, ["parameter_ids", { index: name }])
|
|
585
|
+
: isActiveAutomation(target?.token.refName ?? "", opts)
|
|
586
|
+
? expr.dataAttr(AUTOMATION_RESOURCE_TYPE, publishedAutomationLookup(label, inputs), ["parameter_ids", { index: name }])
|
|
587
|
+
: expr.resourceAttr("elementum_on_demand_trigger", label, ["parameter_ids", { index: name }]);
|
|
583
588
|
}
|
|
584
589
|
if (Array.isArray(rec["fieldRefParams"])) {
|
|
585
590
|
out["field_ref_params"] = rec["fieldRefParams"].flatMap((param, index) => {
|
|
@@ -593,6 +598,7 @@ function automationButtonInput(rec, inputs, where, opts) {
|
|
|
593
598
|
function relatedItemsBlock(rec, where, opts) {
|
|
594
599
|
const out = snakeObject(rec, where, opts);
|
|
595
600
|
delete out["related"];
|
|
601
|
+
delete out["widget"];
|
|
596
602
|
delete out["filter"];
|
|
597
603
|
const related = rec["related"];
|
|
598
604
|
if (related !== undefined) {
|
|
@@ -600,6 +606,11 @@ function relatedItemsBlock(rec, where, opts) {
|
|
|
600
606
|
if (aspect !== undefined)
|
|
601
607
|
out["related_aspect_id"] = aspect;
|
|
602
608
|
}
|
|
609
|
+
if (rec["widget"] !== undefined) {
|
|
610
|
+
const widget = resolveWidget(rec["widget"], `${where}.widget`, opts);
|
|
611
|
+
if (widget !== undefined)
|
|
612
|
+
out["widget_id"] = widget;
|
|
613
|
+
}
|
|
603
614
|
if (rec["filter"] !== undefined) {
|
|
604
615
|
const foreignField = related === undefined
|
|
605
616
|
? undefined
|
|
@@ -722,7 +733,7 @@ function resolveField(value, where, opts) {
|
|
|
722
733
|
opts.diagnostics.push(`${where}: field "${refName}" targets a different ${scopeOf(opts)}; dropped`);
|
|
723
734
|
return undefined;
|
|
724
735
|
}
|
|
725
|
-
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel, scopeOf(opts), opts.fieldAddresses);
|
|
736
|
+
const resolved = fieldRefToTfValue(token?.fieldType ?? "", refName, opts.ownerTfLabel, scopeOf(opts), opts.fieldAddresses, token?.resourceKey);
|
|
726
737
|
if (resolved === undefined)
|
|
727
738
|
opts.diagnostics.push(`${where}: field "${refName}" has no Terraform mapping; dropped`);
|
|
728
739
|
return resolved;
|
|
@@ -731,11 +742,12 @@ function typedValue(value, fieldValue, opts) {
|
|
|
731
742
|
const rec = object(value);
|
|
732
743
|
const token = fieldValue;
|
|
733
744
|
if (typeof rec["string"] === "string" && token?.options?.includes(rec["string"])) {
|
|
745
|
+
const childPart = tsLabelToTfLabel(token.resourceKey ?? token.refName ?? "");
|
|
734
746
|
const localName = token.tags?.includes("STATUS")
|
|
735
747
|
? `${opts.ownerTfLabel}_status_options_by_label`
|
|
736
748
|
: token.tags?.includes("STAGE")
|
|
737
749
|
? `${opts.ownerTfLabel}_stage_options_by_label`
|
|
738
|
-
: `${scopedResourceLabel(opts.ownerTfLabel,
|
|
750
|
+
: `${scopedResourceLabel(opts.ownerTfLabel, childPart, scopeOf(opts))}_options_by_label`;
|
|
739
751
|
return { string: expr.local(localName, [{ index: rec["string"] }]) };
|
|
740
752
|
}
|
|
741
753
|
return snakeObject(rec, "dynamic layout typed value", opts);
|
|
@@ -748,13 +760,29 @@ function buttonAutomationProblem(token, opts) {
|
|
|
748
760
|
}
|
|
749
761
|
if (!isCanonicalTsLabel(refName))
|
|
750
762
|
return `its automation key ${JSON.stringify(refName)} is not a canonical tsLabel`;
|
|
751
|
-
const authored = opts.workspaceAspects?.get(workspaceAspectKey(scopeOf(opts), opts.ownerRefName))?.automationRefNames;
|
|
752
763
|
// A reference to an automation build never declares would fail plan with
|
|
753
764
|
// `Reference to undeclared resource` (#1877).
|
|
754
|
-
if (
|
|
755
|
-
return `its automation ${JSON.stringify(refName)} is not in source`;
|
|
765
|
+
if (!automationInSource(refName, opts) && platformAutomationName(token, opts) === undefined) {
|
|
766
|
+
return `its automation ${JSON.stringify(refName)} is not in source, and the reference has no display name to look the live automation up by`;
|
|
767
|
+
}
|
|
756
768
|
return undefined;
|
|
757
769
|
}
|
|
770
|
+
function automationInSource(refName, opts) {
|
|
771
|
+
const authored = opts.workspaceAspects?.get(workspaceAspectKey(scopeOf(opts), opts.ownerRefName))?.automationRefNames;
|
|
772
|
+
return authored === undefined || authored.has(refName);
|
|
773
|
+
}
|
|
774
|
+
/**
|
|
775
|
+
* The display name of an automation pull left platform-managed, so build can
|
|
776
|
+
* look the live one up as a run-automation widget does (edk#2693). A pull
|
|
777
|
+
* that could not read the display name prints the key as the name.
|
|
778
|
+
*/
|
|
779
|
+
function platformAutomationName(token, opts) {
|
|
780
|
+
const refName = token?.refName ?? "";
|
|
781
|
+
if (automationInSource(refName, opts))
|
|
782
|
+
return undefined;
|
|
783
|
+
const name = token?.name;
|
|
784
|
+
return typeof name === "string" && name !== "" && name !== refName ? name : undefined;
|
|
785
|
+
}
|
|
758
786
|
function resolveAutomation(token, where, opts) {
|
|
759
787
|
const problem = buttonAutomationProblem(token, opts);
|
|
760
788
|
if (problem !== undefined) {
|
|
@@ -762,6 +790,12 @@ function resolveAutomation(token, where, opts) {
|
|
|
762
790
|
return undefined;
|
|
763
791
|
}
|
|
764
792
|
const refName = token?.refName ?? "";
|
|
793
|
+
const platformName = platformAutomationName(token, opts);
|
|
794
|
+
if (platformName !== undefined) {
|
|
795
|
+
const label = `${opts.ownerTfLabel}_${tsLabelToTfLabel(refName)}`;
|
|
796
|
+
opts.orgRefs.rawLookup(AUTOMATION_RESOURCE_TYPE, label, platformName, { app_id: opts.objectId });
|
|
797
|
+
return expr.dataAttr(AUTOMATION_RESOURCE_TYPE, label, ["id"]);
|
|
798
|
+
}
|
|
765
799
|
return expr.resourceAttr(AUTOMATION_RESOURCE_TYPE, automationResourceLabel(opts.ownerTfLabel, refName, scopeOf(opts), scopeOf(opts) === "element" ? opts.ownerHandle : undefined), ["id"]);
|
|
766
800
|
}
|
|
767
801
|
function isActiveAutomation(refName, opts) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { BuiltRoot } from "../../graph/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The build error for audit-field references, across the rendered files, on
|
|
4
|
+
* elements built without audit fields; empty when there are none. Each
|
|
5
|
+
* problem names the file, the resource and attribute that hold the
|
|
6
|
+
* reference, and, when the element authors its own field under that key,
|
|
7
|
+
* that field's ref.
|
|
8
|
+
*/
|
|
9
|
+
export declare function missingElementAuditFieldErrors(files: ReadonlyMap<string, string>, roots: readonly BuiltRoot[]): readonly string[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The build guard for audit-field references on elements that don't have
|
|
3
|
+
* those fields (#2513). An element's audit-field ids are null unless the
|
|
4
|
+
* platform gave it those fields, and EDK cannot create them; a reference
|
|
5
|
+
* would reach the platform as a null field id (a column that vanishes, a
|
|
6
|
+
* filter that fails). Every field resolver addresses an element audit field
|
|
7
|
+
* through its `<ns>_<key>_field_id` local, so a scan of the rendered files
|
|
8
|
+
* sees string keys and FieldRefs alike. Trigger outputs are refused by the
|
|
9
|
+
* automation resolver.
|
|
10
|
+
*/
|
|
11
|
+
const AUDIT_FIELD_LOCAL = /\blocal\.([a-z0-9_]+?)_((?:created|updated)_(?:at|by))_field_id\b/g;
|
|
12
|
+
const AUDIT_FIELD_KEY_BY_ATTR = {
|
|
13
|
+
created_at: "createdAt",
|
|
14
|
+
created_by: "createdBy",
|
|
15
|
+
updated_at: "updatedAt",
|
|
16
|
+
updated_by: "updatedBy",
|
|
17
|
+
};
|
|
18
|
+
const BLOCK_HEADER = /^(?:resource|data) "([^"]+)" "([^"]+)" \{$/gm;
|
|
19
|
+
const NAMED_LINE = /^\s*([a-z0-9_]+)\s*(?:=|(?:"[^"]*"\s*)*\{)/;
|
|
20
|
+
/**
|
|
21
|
+
* `<type>.<label>.<attribute path>: ` for the reference at `index` in
|
|
22
|
+
* rendered HCL: the enclosing block and every attribute or nested block that
|
|
23
|
+
* holds it (`elementum_layout.x_layout.sections.field_ids`). Empty when the
|
|
24
|
+
* text has no enclosing block.
|
|
25
|
+
*/
|
|
26
|
+
function auditReferenceSite(content, index) {
|
|
27
|
+
const before = content.slice(0, index);
|
|
28
|
+
const block = [...before.matchAll(BLOCK_HEADER)].at(-1);
|
|
29
|
+
if (block === undefined)
|
|
30
|
+
return "";
|
|
31
|
+
const lines = before.slice(block.index + block[0].length + 1).split("\n");
|
|
32
|
+
const path = [];
|
|
33
|
+
let depth = 1;
|
|
34
|
+
for (const [i, line] of lines.entries()) {
|
|
35
|
+
const text = line.replace(/"(?:[^"\\]|\\.)*"/g, '""');
|
|
36
|
+
const name = NAMED_LINE.exec(text)?.[1];
|
|
37
|
+
if (name !== undefined) {
|
|
38
|
+
while (path.length > 0 && path.at(-1).depth >= depth)
|
|
39
|
+
path.pop();
|
|
40
|
+
path.push({ name, depth });
|
|
41
|
+
}
|
|
42
|
+
if (i === lines.length - 1)
|
|
43
|
+
break;
|
|
44
|
+
depth += (text.match(/[{[(]/g)?.length ?? 0) - (text.match(/[}\])]/g)?.length ?? 0);
|
|
45
|
+
while (path.length > 0 && path.at(-1).depth >= depth)
|
|
46
|
+
path.pop();
|
|
47
|
+
}
|
|
48
|
+
return `${[block[1], block[2], ...path.map((entry) => entry.name)].join(".")}: `;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The build error for audit-field references, across the rendered files, on
|
|
52
|
+
* elements built without audit fields; empty when there are none. Each
|
|
53
|
+
* problem names the file, the resource and attribute that hold the
|
|
54
|
+
* reference, and, when the element authors its own field under that key,
|
|
55
|
+
* that field's ref.
|
|
56
|
+
*/
|
|
57
|
+
export function missingElementAuditFieldErrors(files, roots) {
|
|
58
|
+
const elementsWithoutAuditFields = new Map(roots
|
|
59
|
+
.filter((root) => root.kind === "element" && root.payload?.auditFields !== true)
|
|
60
|
+
.map((root) => [root.tfLabel, root]));
|
|
61
|
+
if (elementsWithoutAuditFields.size === 0)
|
|
62
|
+
return [];
|
|
63
|
+
const problems = [];
|
|
64
|
+
for (const [file, content] of files) {
|
|
65
|
+
if (file === "locals.tf")
|
|
66
|
+
continue;
|
|
67
|
+
const seen = new Set();
|
|
68
|
+
for (const match of content.matchAll(AUDIT_FIELD_LOCAL)) {
|
|
69
|
+
const element = elementsWithoutAuditFields.get(match[1]);
|
|
70
|
+
const key = AUDIT_FIELD_KEY_BY_ATTR[match[2]];
|
|
71
|
+
if (element === undefined || key === undefined)
|
|
72
|
+
continue;
|
|
73
|
+
const own = element.fieldKeys.has(key)
|
|
74
|
+
? ` (a bare "${key}" names the platform audit field; for this element's own field use its field ref, fields.${key})`
|
|
75
|
+
: "";
|
|
76
|
+
const problem = `${file}: ${auditReferenceSite(content, match.index)}element "${element.refName}" field "${key}"${own}`;
|
|
77
|
+
if (seen.has(problem))
|
|
78
|
+
continue;
|
|
79
|
+
seen.add(problem);
|
|
80
|
+
problems.push(problem);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (problems.length === 0)
|
|
84
|
+
return [];
|
|
85
|
+
return [`audit fields referenced on elements that do not have them:\n ${problems.join("\n ")}\n` +
|
|
86
|
+
"The platform adds Created on/by and Updated on/by to apps but only to some elements, and EDK cannot create them. " +
|
|
87
|
+
"Remove the reference, or set systemFields: { audit: true } on an element the platform did give them to."];
|
|
88
|
+
}
|
|
@@ -69,6 +69,7 @@ export function element(opts) {
|
|
|
69
69
|
...("dynamicSource" in field && field.dynamicSource === true ? { dynamicSource: true } : {}),
|
|
70
70
|
...(field.options !== undefined ? { options: picklistOptionLabels(field.options) } : {}),
|
|
71
71
|
...(field.tags !== undefined ? { tags: field.tags } : {}),
|
|
72
|
+
...(field.resourceKey !== undefined ? { resourceKey: field.resourceKey } : {}),
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
if (opts.readonlyFields !== undefined) {
|
|
@@ -109,7 +110,7 @@ export function element(opts) {
|
|
|
109
110
|
};
|
|
110
111
|
},
|
|
111
112
|
def(refName) {
|
|
112
|
-
assertNoSystemKeyCollision("element", opts.name, opts.fields,
|
|
113
|
+
assertNoSystemKeyCollision("element", opts.name, opts.fields, new Set(ELEMENT_SYSTEM_FIELD_KEYS));
|
|
113
114
|
const displayBlocks = serializeDisplayBlocks(opts.displayBlocks, "LAYOUT");
|
|
114
115
|
const recordCreateDisplayBlocks = serializeDisplayBlocks(opts.recordCreateDisplayBlocks, "CREATE");
|
|
115
116
|
const payload = {
|
|
@@ -24,6 +24,7 @@ export interface ElementFromTfViewBlocks {
|
|
|
24
24
|
readonly relationshipBlocks: readonly TfBlock[];
|
|
25
25
|
readonly dashboardBlocks: readonly TfBlock[];
|
|
26
26
|
readonly dashboardWidgetBlocks: readonly TfBlock[];
|
|
27
|
+
readonly dashboardWidgetOrderBlocks?: readonly TfBlock[];
|
|
27
28
|
readonly widgetBlocks: readonly TfBlock[];
|
|
28
29
|
}
|
|
29
30
|
export declare function elementFromTf(elementBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: ElementFromTfViewBlocks, accessPolicyBlocks?: readonly TfBlock[], roleBlocks?: readonly TfBlock[]): ElementFromTfResult;
|
|
@@ -11,7 +11,7 @@ import { tfLabelToTsLabel } from "../../engine/tf/index.js";
|
|
|
11
11
|
import { accessPolicyBlocksInLabelOrder, accessPolicyFromTf } from "../access-policy/from-tf.js";
|
|
12
12
|
import { dashboardsFromTf } from "../dashboard/from-tf.js";
|
|
13
13
|
import { dynamicLayoutCompanionWidgetLabels, dynamicLayoutsFromTf } from "../dynamic-layout/from-tf.js";
|
|
14
|
-
import {
|
|
14
|
+
import { fieldsFromTf } from "../field/from-tf.js";
|
|
15
15
|
import { recordCreateFormFromTf } from "../record-create-form/from-tf.js";
|
|
16
16
|
import { relationshipsFromTf } from "../relationship/from-tf.js";
|
|
17
17
|
import { rolesFromTf } from "../role/from-tf.js";
|
|
@@ -139,11 +139,8 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
139
139
|
fields.push(systemEntry("id", idName ?? DEPLOY_DEFAULT_SYSTEM_FIELD_NAMES.id, "TEXT", "HANDLE", idFieldDescription));
|
|
140
140
|
}
|
|
141
141
|
const owner = { type: ELEMENT_RESOURCE_TYPE, label, scope: "element", refName };
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
if (entry !== undefined)
|
|
145
|
-
fields.push(entry);
|
|
146
|
-
}
|
|
142
|
+
// Custom fields in the live field order, keys claimed two-pass (#1871 B1, edk#2920).
|
|
143
|
+
fields.push(...fieldsFromTf(fieldBlocks, owner, ctx));
|
|
147
144
|
const elementId = ctx.importId(`${ELEMENT_RESOURCE_TYPE}.${label}`);
|
|
148
145
|
if (elementId === undefined) {
|
|
149
146
|
ctx.diagnostics.push(`element "${label}": no import block in the stream — adoption has no identity to bind`);
|
|
@@ -151,7 +148,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
|
|
|
151
148
|
const unextractedFieldIds = new Set();
|
|
152
149
|
const fieldKeys = new Set(fields.map((field) => field.key));
|
|
153
150
|
const fieldKeysByName = fieldKeysByDisplayName(fields);
|
|
154
|
-
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "element", ownerType: "ELEMENT_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx);
|
|
151
|
+
const dashboards = dashboardsFromTf(viewBlocks.dashboardBlocks, viewBlocks.dashboardWidgetBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, ownerRefName: refName, scope: "element", ownerType: "ELEMENT_ASPECT", fieldKeys, fieldKeysByName, unextractedFieldIds }, ctx, viewBlocks.dashboardWidgetOrderBlocks);
|
|
155
152
|
// Every field reference pull writes keeps an unextracted field as its platform id (#1736, #1966).
|
|
156
153
|
const unextracted = { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: label, scope: "element", fieldKeys, fieldKeysByName, unextractedFieldIds };
|
|
157
154
|
const { layouts, listViews, calendarViews, kanbanViews, dashboardViews, customViews, viewOrder, deleteDefaultListView } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.calendarViewBlocks, viewBlocks.kanbanViewBlocks, viewBlocks.dashboardViewBlocks, [], viewBlocks.managedViewOrderBlocks, unextracted, ctx, viewBlocks.customViewBlocks);
|
|
@@ -8,6 +8,7 @@ import { NO_CATALOG, } from "../../graph/types.js";
|
|
|
8
8
|
import { appendFieldLocals } from "../field/locals.js";
|
|
9
9
|
import { CALENDAR_VIEW_RESOURCE_TYPE, CUSTOM_VIEW_RESOURCE_TYPE, DASHBOARD_VIEW_RESOURCE_TYPE, KANBAN_VIEW_RESOURCE_TYPE, LAYOUT_RESOURCE_TYPE, LIST_VIEW_RESOURCE_TYPE } from "../view/types.js";
|
|
10
10
|
import { elementAuditFieldIds, elementFromTf, referencesElementAuditFields } from "./from-tf.js";
|
|
11
|
+
import { missingElementAuditFieldErrors } from "./audit-field-guard.js";
|
|
11
12
|
import { appendElementLocals } from "./locals.js";
|
|
12
13
|
import { elementToTf } from "./to-tf.js";
|
|
13
14
|
export const ELEMENT_RESOURCE_TYPE = "elementum_element";
|
|
@@ -31,6 +32,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
31
32
|
const relationshipBlocks = stream.byKind.get("relationship") ?? [];
|
|
32
33
|
const dashboardBlocks = stream.byKind.get("dashboard") ?? [];
|
|
33
34
|
const dashboardWidgetBlocks = stream.byKind.get("dashboard-widget") ?? [];
|
|
35
|
+
const dashboardWidgetOrderBlocks = stream.byKind.get("dashboard-widget-order") ?? [];
|
|
34
36
|
const widgetBlocks = stream.byKind.get("widget") ?? [];
|
|
35
37
|
const accessPolicyBlocks = stream.byKind.get("access-policy") ?? [];
|
|
36
38
|
const roleBlocks = stream.byKind.get("role") ?? [];
|
|
@@ -47,6 +49,7 @@ function extractElementStreamRoot(stream, ctx) {
|
|
|
47
49
|
relationshipBlocks,
|
|
48
50
|
dashboardBlocks,
|
|
49
51
|
dashboardWidgetBlocks,
|
|
52
|
+
dashboardWidgetOrderBlocks,
|
|
50
53
|
widgetBlocks,
|
|
51
54
|
}, accessPolicyBlocks, roleBlocks);
|
|
52
55
|
// Automations are extracted separately, but their trigger outputs are the
|
|
@@ -79,6 +82,7 @@ export const elementModule = {
|
|
|
79
82
|
diagnostics: ctx.diagnostics,
|
|
80
83
|
workspaceAspects: ctx.workspaceAspects,
|
|
81
84
|
...(ctx.outOfScopeApps !== undefined && { outOfScopeApps: ctx.outOfScopeApps }),
|
|
85
|
+
...(ctx.optionIds !== undefined && { optionIds: ctx.optionIds }),
|
|
82
86
|
});
|
|
83
87
|
return {
|
|
84
88
|
blocks: result.blocks,
|
|
@@ -95,4 +99,5 @@ export const elementModule = {
|
|
|
95
99
|
},
|
|
96
100
|
},
|
|
97
101
|
catalog: NO_CATALOG,
|
|
102
|
+
buildChecks: { validateRenderedFiles: missingElementAuditFieldErrors },
|
|
98
103
|
};
|
|
@@ -2,3 +2,16 @@
|
|
|
2
2
|
export declare const ELEMENT_AUDIT_SYSTEM_FIELD_KEYS: readonly ["createdAt", "createdBy", "updatedAt", "updatedBy"];
|
|
3
3
|
export declare const ELEMENT_SYSTEM_FIELD_KEYS: readonly ["id", "title", "createdAt", "createdBy", "updatedAt", "updatedBy"];
|
|
4
4
|
export type ElementSystemFieldKey = typeof ELEMENT_SYSTEM_FIELD_KEYS[number];
|
|
5
|
+
/**
|
|
6
|
+
* What pull extracts for a reference to an element's platform audit field
|
|
7
|
+
* when the element also authors its own field under that key (#2513). Print
|
|
8
|
+
* writes it as the bare key, and the own field's references stay the key and
|
|
9
|
+
* print as its field ref. It only exists between extract and print: a colon
|
|
10
|
+
* can't appear in a field key or a platform id.
|
|
11
|
+
*/
|
|
12
|
+
export declare function platformAuditFieldToken(key: string): string;
|
|
13
|
+
/** The system-field key a {@link platformAuditFieldToken} names; undefined for anything else.
|
|
14
|
+
* Element audit keys and app system keys (status/closedAt/…) both use this token when
|
|
15
|
+
* a same-keyed custom field would otherwise retarget the platform reference (#1871 / #2513).
|
|
16
|
+
*/
|
|
17
|
+
export declare function platformAuditFieldTokenKey(value: string): string | undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SYSTEM_FIELD_KEYS } from "../../core/system-fields.js";
|
|
1
2
|
/** System-field roles EDK can reference when those tagged fields exist on an element. */
|
|
2
3
|
export const ELEMENT_AUDIT_SYSTEM_FIELD_KEYS = [
|
|
3
4
|
"createdAt",
|
|
@@ -10,3 +11,25 @@ export const ELEMENT_SYSTEM_FIELD_KEYS = [
|
|
|
10
11
|
"title",
|
|
11
12
|
...ELEMENT_AUDIT_SYSTEM_FIELD_KEYS,
|
|
12
13
|
];
|
|
14
|
+
/**
|
|
15
|
+
* What pull extracts for a reference to an element's platform audit field
|
|
16
|
+
* when the element also authors its own field under that key (#2513). Print
|
|
17
|
+
* writes it as the bare key, and the own field's references stay the key and
|
|
18
|
+
* print as its field ref. It only exists between extract and print: a colon
|
|
19
|
+
* can't appear in a field key or a platform id.
|
|
20
|
+
*/
|
|
21
|
+
export function platformAuditFieldToken(key) {
|
|
22
|
+
return `platformAuditField:${key}`;
|
|
23
|
+
}
|
|
24
|
+
/** The system-field key a {@link platformAuditFieldToken} names; undefined for anything else.
|
|
25
|
+
* Element audit keys and app system keys (status/closedAt/…) both use this token when
|
|
26
|
+
* a same-keyed custom field would otherwise retarget the platform reference (#1871 / #2513).
|
|
27
|
+
*/
|
|
28
|
+
export function platformAuditFieldTokenKey(value) {
|
|
29
|
+
const key = value.startsWith("platformAuditField:") ? value.slice("platformAuditField:".length) : undefined;
|
|
30
|
+
if (key === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (ELEMENT_AUDIT_SYSTEM_FIELD_KEYS.includes(key))
|
|
33
|
+
return key;
|
|
34
|
+
return SYSTEM_FIELD_KEYS.includes(key) ? key : undefined;
|
|
35
|
+
}
|
|
@@ -301,6 +301,7 @@ export function elementToTf(entity, ctx) {
|
|
|
301
301
|
objectId,
|
|
302
302
|
orgRefs: ctx.orgRefs,
|
|
303
303
|
diagnostics: ctx.diagnostics,
|
|
304
|
+
...(ctx.optionIds !== undefined && { optionIds: ctx.optionIds }),
|
|
304
305
|
fieldAddresses,
|
|
305
306
|
// An element has no service accounts of its own. Hand the sibling app's
|
|
306
307
|
// authored bag to the shared resolver so a managed account becomes a
|
|
@@ -41,6 +41,15 @@ export interface BaseFieldOptions {
|
|
|
41
41
|
readonly defaultValue?: unknown;
|
|
42
42
|
/** Platform semantic role tags for system fields (e.g. `["STATUS"]`). */
|
|
43
43
|
readonly tags?: readonly string[];
|
|
44
|
+
/**
|
|
45
|
+
* Natural bag key when this field was re-keyed off a reserved system key
|
|
46
|
+
* (#1871). When renaming an already-applied field (for example `closedAt`
|
|
47
|
+
* → `closedAtCustom`), set this to the original key
|
|
48
|
+
* (`resourceKey: "closedAt"`) so the terraform address stays put. A
|
|
49
|
+
* brand-new field needs no `resourceKey`. Omitting it addresses the field
|
|
50
|
+
* from the bag key. Pull stamps this automatically when it re-keys.
|
|
51
|
+
*/
|
|
52
|
+
readonly resourceKey?: string;
|
|
44
53
|
}
|
|
45
54
|
type ScalarExpression<T extends ExprType> = Expr<T, "single", ExprContext>;
|
|
46
55
|
type WithExpression<T extends ExprType> = {
|
|
@@ -8,6 +8,33 @@
|
|
|
8
8
|
import { type FromTfContext } from "../../engine/pull/context.js";
|
|
9
9
|
import { type FieldOwnerScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
|
|
10
10
|
import type { NormalizedField } from "../app/deserializer/normalize.js";
|
|
11
|
+
type ClaimContext = Pick<FromTfContext, "resourcesOfType">;
|
|
12
|
+
/**
|
|
13
|
+
* Bag key of an owner's custom field, by its Terraform label, as pull keys it
|
|
14
|
+
* (#1871, edk#2933). Every same-owner reference to a field (dropdown parents,
|
|
15
|
+
* dynamic configs, views, layouts, relationships, widgets, approval chains,
|
|
16
|
+
* access policies, tools) resolves through this, so a reference names the
|
|
17
|
+
* key the field itself was printed under. Without a context that lists the
|
|
18
|
+
* stream, a reserved natural falls back to `<key>Custom`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function pulledFieldBagKey(ownerTfLabel: string, fieldLabel: string, scope: FieldOwnerScope, ctx?: ClaimContext): string;
|
|
21
|
+
/**
|
|
22
|
+
* Bag key for a pulled custom field resource. A key that matches a reserved
|
|
23
|
+
* system-field key is rewritten to `<key>Custom` so pulled source builds
|
|
24
|
+
* under #1871 Q1 A (reject at build). When `usedKeys` is provided, the
|
|
25
|
+
* assignment is collision-safe: non-reserved naturals claim first, and a
|
|
26
|
+
* reserved key takes `<key>Custom`, then `<key>Custom2`, … with a warning.
|
|
27
|
+
* Terraform addresses stay on the natural key via the stamped `resourceKey` / {@link tfChildPartForFieldBagKey}.
|
|
28
|
+
*/
|
|
29
|
+
export declare function bagKeyForPulledCustomField(ownerTfLabel: string, fieldLabel: string, scope: FieldOwnerScope, reservedKeys: ReadonlySet<string>, usedKeys?: Set<string>, diagnostics?: string[]): string;
|
|
30
|
+
/**
|
|
31
|
+
* Terraform child-part for a field bag key. Only a key that pull actually
|
|
32
|
+
* re-keyed from a reserved natural — carried as `resourceKey` / wire
|
|
33
|
+
* `__resourceKey` — keeps the address on that natural. A field whose own
|
|
34
|
+
* label is already `closed_at_custom` (bag key `closedAtCustom`) is not
|
|
35
|
+
* remapped, so Custom and Custom2 never share an address (Review B1).
|
|
36
|
+
*/
|
|
37
|
+
export declare function tfChildPartForFieldBagKey(bagKey: string, resourceKey?: string): string;
|
|
11
38
|
/** Whether one of the owner's own field resources is keyed `fieldKey`; true when the stream can't be listed. */
|
|
12
39
|
export declare function ownerMayHaveCustomField(owner: FieldOwner, fieldKey: string, ctx: FromTfContext): boolean;
|
|
13
40
|
export interface FieldOwner {
|
|
@@ -42,6 +69,18 @@ export type FieldBlockOwner = "own" | "foreign" | "unresolved";
|
|
|
42
69
|
* literal string, or absent from the owner's block.
|
|
43
70
|
*/
|
|
44
71
|
export declare function fieldBlockOwner(objectId: TfValue | undefined, owner: Pick<FieldOwner, "type" | "label">, ctx: FromTfContext, ownerId: string | undefined): FieldBlockOwner;
|
|
72
|
+
/**
|
|
73
|
+
* An owner's field blocks → their normalized entries, in the blocks' (live
|
|
74
|
+
* field) order. Keys are claimed up front over every field the owner owns
|
|
75
|
+
* (two passes, #1871 B1; see {@link claimFieldBagKeys}) and recorded on the
|
|
76
|
+
* context before any field is extracted, so a reference from one field to
|
|
77
|
+
* another (a dependent dropdown's parent, a dynamic config) and every later
|
|
78
|
+
* same-owner reference resolve to the key the field prints under. Fields
|
|
79
|
+
* print in the live order, not the claim order: a re-keyed field moved last
|
|
80
|
+
* would reorder the live fields on the next apply (edk#2920). Apps, elements
|
|
81
|
+
* and standalone tasks all extract fields here (edk#2933).
|
|
82
|
+
*/
|
|
83
|
+
export declare function fieldsFromTf(fieldBlocks: readonly TfBlock[], owner: FieldOwner, ctx: FromTfContext): NormalizedField[];
|
|
45
84
|
/**
|
|
46
85
|
* One field block → its normalized entry; undefined = skipped with a
|
|
47
86
|
* diagnostic (unknown resource type, or a field belonging to a different
|
|
@@ -54,13 +93,24 @@ export declare function fieldFromTf(block: TfBlock, owner: FieldOwner, ctx: From
|
|
|
54
93
|
* fields, view field_ids/columns). Undefined for any other shape or an
|
|
55
94
|
* unknown resource type.
|
|
56
95
|
*/
|
|
57
|
-
export declare function fieldKeyFromTfRef(v: TfValue, ownerTfLabel?: string, scope?: FieldOwnerScope): string | undefined;
|
|
96
|
+
export declare function fieldKeyFromTfRef(v: TfValue, ownerTfLabel?: string, scope?: FieldOwnerScope, ctx?: ClaimContext): string | undefined;
|
|
58
97
|
/**
|
|
59
98
|
* Resolve either a normal Terraform field reference or a raw platform field
|
|
60
99
|
* ID recovered from post-adoption state. The owner check prevents a UUID from
|
|
61
100
|
* one app or element from becoming a same-owner field token accidentally.
|
|
62
101
|
*/
|
|
63
102
|
export declare function fieldKeyFromTfValue(v: TfValue, ownerRefName: string, ownerTfLabel: string, scope: FieldOwnerScope, ctx: FromTfContext): string | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* The key a view, layout or form entry prints from, when the owner also
|
|
105
|
+
* authors its own field under a system key (#2513 elements, #1871 apps). Pull
|
|
106
|
+
* resolves the platform system field and the own field to the same key, so
|
|
107
|
+
* this keeps them apart per reference: the platform field's local or data
|
|
108
|
+
* source becomes {@link platformAuditFieldToken} (printed as the bare key),
|
|
109
|
+
* the own field's resource stays the key (printed as its field ref), and a
|
|
110
|
+
* raw platform id stays raw, since pull can't tell whose it is (as
|
|
111
|
+
* `selfSystemField` does). Any other reference returns `key` unchanged.
|
|
112
|
+
*/
|
|
113
|
+
export declare function elementAuditFieldReference(v: TfValue, key: string, owner: FieldOwner, ctx: FromTfContext): string;
|
|
64
114
|
export interface DecodedForeignDataField {
|
|
65
115
|
readonly key: string;
|
|
66
116
|
readonly name: string;
|
|
@@ -86,3 +136,4 @@ export declare function fieldKeyFromForeignDataLabel(dataLabel: string, target:
|
|
|
86
136
|
readonly kind?: string;
|
|
87
137
|
readonly ownerDataLabel?: string;
|
|
88
138
|
}): string | undefined;
|
|
139
|
+
export {};
|