@elementumai/edk 0.13.3 → 0.14.0

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.
Files changed (140) hide show
  1. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  2. package/dist-sdk/src/catalog/factories.js +3 -1
  3. package/dist-sdk/src/catalog/from-authoring.d.ts +8 -3
  4. package/dist-sdk/src/catalog/from-authoring.js +21 -8
  5. package/dist-sdk/src/engine/build/context.d.ts +17 -0
  6. package/dist-sdk/src/engine/coverage-gaps.d.ts +13 -0
  7. package/dist-sdk/src/engine/coverage-gaps.js +21 -0
  8. package/dist-sdk/src/engine/pull/context.d.ts +57 -1
  9. package/dist-sdk/src/engine/pull/context.js +9 -1
  10. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +14 -1
  11. package/dist-sdk/src/engine/pull/pulled-roots.js +23 -3
  12. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -1
  13. package/dist-sdk/src/engine/pull/ref-only.js +4 -1
  14. package/dist-sdk/src/engine/pull/stream-root.d.ts +17 -1
  15. package/dist-sdk/src/engine/pull/stream-root.js +57 -4
  16. package/dist-sdk/src/engine/tf/index.d.ts +1 -0
  17. package/dist-sdk/src/engine/tf/index.js +1 -0
  18. package/dist-sdk/src/engine/tf/jsonencode.d.ts +19 -0
  19. package/dist-sdk/src/engine/tf/jsonencode.js +49 -0
  20. package/dist-sdk/src/engine/validation.d.ts +36 -1
  21. package/dist-sdk/src/engine/validation.js +56 -2
  22. package/dist-sdk/src/engine/workspace/loader.d.ts +6 -0
  23. package/dist-sdk/src/engine/workspace/loader.js +87 -2
  24. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  25. package/dist-sdk/src/entities/access-policy/from-tf.js +58 -17
  26. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +3 -1
  27. package/dist-sdk/src/entities/access-policy/to-tf.js +1 -1
  28. package/dist-sdk/src/entities/agent/build.d.ts +15 -0
  29. package/dist-sdk/src/entities/agent/build.js +139 -16
  30. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -3
  31. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +39 -25
  32. package/dist-sdk/src/entities/agent/module.js +95 -3
  33. package/dist-sdk/src/entities/agent/to-tf.js +6 -4
  34. package/dist-sdk/src/entities/agent-evaluation/from-tf.d.ts +7 -0
  35. package/dist-sdk/src/entities/agent-evaluation/from-tf.js +14 -5
  36. package/dist-sdk/src/entities/agent-evaluation/module.js +4 -2
  37. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +11 -2
  38. package/dist-sdk/src/entities/agent-tool/from-tf.js +38 -40
  39. package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -5
  40. package/dist-sdk/src/entities/app/build.d.ts +1 -1
  41. package/dist-sdk/src/entities/app/index.d.ts +1 -1
  42. package/dist-sdk/src/entities/automation/approval-trigger-refs.d.ts +20 -0
  43. package/dist-sdk/src/entities/automation/approval-trigger-refs.js +83 -0
  44. package/dist-sdk/src/entities/automation/build.d.ts +75 -42
  45. package/dist-sdk/src/entities/automation/build.js +18 -8
  46. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +14 -2
  47. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +9 -0
  48. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +64 -12
  49. package/dist-sdk/src/entities/automation/from-tf.d.ts +53 -0
  50. package/dist-sdk/src/entities/automation/from-tf.js +579 -106
  51. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  52. package/dist-sdk/src/entities/automation/index.js +1 -1
  53. package/dist-sdk/src/entities/automation/lookup-owner.d.ts +23 -0
  54. package/dist-sdk/src/entities/automation/lookup-owner.js +27 -0
  55. package/dist-sdk/src/entities/automation/module.js +265 -26
  56. package/dist-sdk/src/entities/automation/operators.d.ts +6 -2
  57. package/dist-sdk/src/entities/automation/operators.js +0 -2
  58. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +8 -0
  59. package/dist-sdk/src/entities/automation/task-output-labels.js +11 -0
  60. package/dist-sdk/src/entities/automation/tasks.d.ts +37 -2
  61. package/dist-sdk/src/entities/automation/tasks.js +38 -1
  62. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -0
  63. package/dist-sdk/src/entities/automation/to-tf.js +576 -52
  64. package/dist-sdk/src/entities/automation/triggers.d.ts +47 -1
  65. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +10 -5
  66. package/dist-sdk/src/entities/automation/unsafe-script-output.js +10 -5
  67. package/dist-sdk/src/entities/chart/to-tf.js +18 -5
  68. package/dist-sdk/src/entities/dashboard/from-tf.js +45 -11
  69. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +5 -3
  70. package/dist-sdk/src/entities/dashboard-widget-order/order.js +6 -4
  71. package/dist-sdk/src/entities/datamine/from-tf.js +10 -3
  72. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +38 -11
  73. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +35 -7
  74. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +101 -9
  75. package/dist-sdk/src/entities/element/build.d.ts +4 -1
  76. package/dist-sdk/src/entities/element/build.js +3 -4
  77. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  78. package/dist-sdk/src/entities/field/from-tf.js +8 -1
  79. package/dist-sdk/src/entities/field/to-tf.d.ts +29 -2
  80. package/dist-sdk/src/entities/field/to-tf.js +106 -7
  81. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +7 -0
  82. package/dist-sdk/src/entities/phone-service/from-tf.js +15 -7
  83. package/dist-sdk/src/entities/phone-service/module.js +4 -2
  84. package/dist-sdk/src/entities/portal/to-tf.d.ts +1 -1
  85. package/dist-sdk/src/entities/portal/to-tf.js +61 -2
  86. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -1
  87. package/dist-sdk/src/entities/relationship/from-tf.js +34 -4
  88. package/dist-sdk/src/entities/relationship/to-tf.js +24 -6
  89. package/dist-sdk/src/entities/role/from-tf.js +3 -1
  90. package/dist-sdk/src/entities/search-table/from-tf.d.ts +3 -1
  91. package/dist-sdk/src/entities/search-table/from-tf.js +6 -3
  92. package/dist-sdk/src/entities/search-table/module.js +18 -2
  93. package/dist-sdk/src/entities/search-table/to-tf.js +10 -16
  94. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +6 -1
  95. package/dist-sdk/src/entities/shared/filters/ast.d.ts +6 -0
  96. package/dist-sdk/src/entities/shared/filters/index.d.ts +21 -4
  97. package/dist-sdk/src/entities/shared/filters/index.js +27 -3
  98. package/dist-sdk/src/entities/shared/filters/print.js +23 -7
  99. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +24 -0
  100. package/dist-sdk/src/entities/shared/filters/tf-codec.js +98 -3
  101. package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -1
  102. package/dist-sdk/src/entities/shared/run-automation-requirement.d.ts +15 -0
  103. package/dist-sdk/src/entities/shared/run-automation-requirement.js +28 -0
  104. package/dist-sdk/src/entities/shared/search-table-address.d.ts +17 -0
  105. package/dist-sdk/src/entities/shared/search-table-address.js +24 -0
  106. package/dist-sdk/src/entities/shared/skip-release.d.ts +49 -0
  107. package/dist-sdk/src/entities/shared/skip-release.js +74 -0
  108. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -3
  109. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +11 -5
  110. package/dist-sdk/src/entities/skill/module.js +3 -25
  111. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +4 -2
  112. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -27
  113. package/dist-sdk/src/entities/skill-tool/to-tf.js +12 -5
  114. package/dist-sdk/src/entities/skill-tool/types.d.ts +1 -0
  115. package/dist-sdk/src/entities/skill-tool/types.js +2 -1
  116. package/dist-sdk/src/entities/table/catalog.d.ts +16 -0
  117. package/dist-sdk/src/entities/table/catalog.js +44 -2
  118. package/dist-sdk/src/entities/table/from-tf.js +30 -4
  119. package/dist-sdk/src/entities/table/keys.d.ts +27 -0
  120. package/dist-sdk/src/entities/table/keys.js +46 -0
  121. package/dist-sdk/src/entities/table/to-tf.js +2 -2
  122. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +12 -1
  123. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +9 -4
  124. package/dist-sdk/src/entities/view/agent-view-layout-to-tf.js +215 -10
  125. package/dist-sdk/src/entities/view/agent-view-layout.d.ts +10 -4
  126. package/dist-sdk/src/entities/view/custom-view-runtime-rules.d.ts +43 -0
  127. package/dist-sdk/src/entities/view/custom-view-runtime-rules.js +285 -0
  128. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +3 -1
  129. package/dist-sdk/src/entities/view/custom-view-validate.js +24 -5
  130. package/dist-sdk/src/entities/view/from-tf.js +14 -1
  131. package/dist-sdk/src/entities/widget/from-tf.js +14 -7
  132. package/dist-sdk/src/entities/widget/to-tf.js +9 -6
  133. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +4 -2
  134. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  135. package/dist-sdk/src/graph/index.d.ts +14 -1
  136. package/dist-sdk/src/graph/index.js +2 -0
  137. package/dist-sdk/src/graph/resource-types.d.ts +2 -0
  138. package/dist-sdk/src/graph/resource-types.js +3 -0
  139. package/dist-sdk/src/graph/types.d.ts +105 -0
  140. package/package.json +1 -1
@@ -15,8 +15,9 @@
15
15
  import { DATA_FACET_BY_TYPE, ENTITY_KIND_BY_ID, ownFileChildrenOf, } from "../../graph/index.js";
16
16
  import { isTfExpr } from "../tf/index.js";
17
17
  import { typedCoverageGap } from "../coverage-gaps.js";
18
- import { authoringBlockedMessage } from "./context.js";
18
+ import { authoringBlockedMessage, ownFileArchiveConsequence } from "./context.js";
19
19
  import { partitionStream } from "./partition.js";
20
+ import { readRefOnlyMetadata } from "./ref-only.js";
20
21
  import { resourcesInSource } from "./source-resources.js";
21
22
  /**
22
23
  * EDK-only export local listing live bindings the EDK cannot represent, keyed
@@ -192,6 +193,20 @@ export function importIdsFromDocument(doc) {
192
193
  }
193
194
  return importIds;
194
195
  }
196
+ /** The ref-only task roots of `doc`, by display name and by namespace (edk#3146). */
197
+ function refOnlyTaskIdentities(doc) {
198
+ const names = new Map();
199
+ const namespaces = new Map();
200
+ for (const root of readRefOnlyMetadata(doc).roots) {
201
+ if (root.kind !== "task")
202
+ continue;
203
+ if (!names.has(root.name))
204
+ names.set(root.name, root.refName);
205
+ if (root.namespace !== undefined && root.namespace !== "" && !namespaces.has(root.namespace))
206
+ namespaces.set(root.namespace, root.refName);
207
+ }
208
+ return names.size === 0 ? {} : { refOnlyTaskRefNames: names, refOnlyTaskRefNamespaces: namespaces };
209
+ }
195
210
  export function extractStreamRoot(doc, kindId, opts = {}) {
196
211
  const skipped = [];
197
212
  const releaseIfManaged = [];
@@ -391,6 +406,7 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
391
406
  foreignAppRefNamespaces: opts.appRefNamespaces,
392
407
  foreignElementRefNamespaces: opts.elementRefNamespaces,
393
408
  foreignTaskRefNamespaces: opts.taskRefNamespaces,
409
+ ...refOnlyTaskIdentities(doc),
394
410
  ...(opts.selfAspectRef !== undefined ? { selfAspectRef: opts.selfAspectRef } : {}),
395
411
  ...(opts.cloning !== undefined ? { cloning: opts.cloning } : {}),
396
412
  foreignFieldRefsById: opts.foreignFieldRefsById,
@@ -399,11 +415,14 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
399
415
  foreignSkillRefsByOwnerName: opts.foreignSkillRefsByOwnerName,
400
416
  foreignSkillRefsByOwnerNamespace: opts.foreignSkillRefsByOwnerNamespace,
401
417
  fieldNamesByOwnerRefName: opts.fieldNamesByOwnerRefName,
418
+ ...(opts.renamedSystemFieldKeysByOwnerRefName !== undefined && { renamedSystemFieldKeysByOwnerRefName: opts.renamedSystemFieldKeysByOwnerRefName }),
402
419
  // Root and own-file extractors both print group refs (edk#1412).
403
420
  groupKeysByName: opts.groupKeysByName,
404
421
  ...(opts.serviceAccountsById !== undefined && { serviceAccountsById: opts.serviceAccountsById }),
405
422
  ...(opts.omittedAutomationsById !== undefined && { omittedAutomationsById: opts.omittedAutomationsById }),
423
+ ...(opts.workspaceAutomationKeys !== undefined && { workspaceAutomationKeys: opts.workspaceAutomationKeys }),
406
424
  ...(opts.platformCreatorPolicyIds !== undefined && { platformCreatorPolicyIds: opts.platformCreatorPolicyIds }),
425
+ ...(opts.unloadableOwnFiles !== undefined && { unloadableOwnFiles: opts.unloadableOwnFiles }),
407
426
  unresolvedForeignRefs: { apps: unresolvedForeignApps, elements: unresolvedForeignElements },
408
427
  importedResource: (id) => {
409
428
  // Clone dropped the import blocks; the source export's still name the id (#1991).
@@ -447,6 +466,9 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
447
466
  const ownFileByKind = new Map();
448
467
  const adoptionAddressAliases = [];
449
468
  const unmanagedLookups = [];
469
+ const skippedReports = [];
470
+ const triggerReferenceRepairs = [];
471
+ const reimportForLive = [];
450
472
  const quarantineOwnFiles = [];
451
473
  const validationFailures = [];
452
474
  const settles = [];
@@ -464,6 +486,9 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
464
486
  validationFailures.push(...(result.validations ?? []));
465
487
  adoptionAddressAliases.push(...(result.adoptionAddressAliases ?? []));
466
488
  unmanagedLookups.push(...(result.unmanagedLookups ?? []));
489
+ skippedReports.push(...(result.skippedReports ?? []).map((report) => ({ ...report, kind: child.kind })));
490
+ triggerReferenceRepairs.push(...(result.triggerReferenceRepairs ?? []));
491
+ reimportForLive.push(...(result.reimportForLive ?? []));
467
492
  quarantineOwnFiles.push(...(result.quarantineOwnFiles ?? []));
468
493
  if (result.settleAfterExtract !== undefined)
469
494
  settles.push(result.settleAfterExtract);
@@ -472,7 +497,8 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
472
497
  skippedOwners.set(address, { kind: child.kind, refName });
473
498
  }
474
499
  }
475
- rootInstance = dropDependentsOfSkipped(rootInstance, ownFileByKind, requiresExtracted, new Set(resources.keys()), skipped, releaseIfManaged, diagnostics, reports, opts.keptOwnFile, quarantineOwnFiles);
500
+ const trimmedLists = [];
501
+ rootInstance = dropDependentsOfSkipped(rootInstance, ownFileByKind, requiresExtracted, new Set(resources.keys()), skipped, releaseIfManaged, diagnostics, reports, opts.keptOwnFile, quarantineOwnFiles, trimmedLists);
476
502
  if (settles.length > 0) {
477
503
  const settledRoot = rootInstance;
478
504
  const inSource = resourcesInSource({
@@ -486,6 +512,9 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
486
512
  }
487
513
  }
488
514
  const taskAddresses = taskAddressByLabel(resources, automationTaskResourceTypes);
515
+ // A resource skipped after extraction is neither in source nor adopted, so the plan leaves it alone.
516
+ const skippedSet = new Set(skipped);
517
+ const plannedRepairs = triggerReferenceRepairs.filter((repair) => !skippedSet.has(repair.automationAddress) && !skippedSet.has(repair.address));
489
518
  return {
490
519
  root: rootInstance,
491
520
  ownFileByKind,
@@ -500,6 +529,10 @@ export function extractStreamRoot(doc, kindId, opts = {}) {
500
529
  importIds,
501
530
  adoptionAddressAliases,
502
531
  ...(unmanagedLookups.length > 0 && { unmanagedLookups }),
532
+ ...(trimmedLists.length > 0 && { trimmedLists }),
533
+ ...(reimportForLive.length > 0 && { reimportForLive: [...new Set(reimportForLive)].sort() }),
534
+ ...(skippedReports.length > 0 && { skippedReports }),
535
+ ...(plannedRepairs.length > 0 && { triggerReferenceRepairs: plannedRepairs }),
503
536
  dependsOn,
504
537
  unresolvedForeignRefs: { apps: [...unresolvedForeignApps], elements: [...unresolvedForeignElements] },
505
538
  authoringBlockers: [
@@ -527,11 +560,13 @@ export function extractApp(doc, opts = {}) {
527
560
  * adoption keeps managing it (SF3). That outcome is reported on the
528
561
  * informational `reports` channel, not as a coverage gap: nothing is lost.
529
562
  */
530
- function dropDependentsOfSkipped(root, ownFileByKind, requirements, streamAddresses, skipped, releaseIfManaged, diagnostics, reports, keptOwnFile, quarantineOwnFiles = []) {
563
+ function dropDependentsOfSkipped(root, ownFileByKind, requirements, streamAddresses, skipped, releaseIfManaged, diagnostics, reports, keptOwnFile, quarantineOwnFiles = [], trimmedLists = []) {
531
564
  const skippedSet = new Set(skipped);
532
565
  // A released requirement's authored file is archived after adoption, so it
533
566
  // can't keep its dependent buildable (#2892).
534
567
  const releasedSet = new Set(releaseIfManaged);
568
+ // List entries left out so far, by dependent (see ExtractRequirement.listEntry).
569
+ const leftOutEntries = new Map();
535
570
  let pruned = root;
536
571
  for (const requirement of requirements) {
537
572
  if (skippedSet.has(requirement.address))
@@ -539,6 +574,15 @@ function dropDependentsOfSkipped(root, ownFileByKind, requirements, streamAddres
539
574
  const reason = unbuildableReason(requirement, root, streamAddresses, skippedSet, releasedSet, keptOwnFile, reports);
540
575
  if (reason === undefined)
541
576
  continue;
577
+ if (requirement.listEntry !== undefined) {
578
+ const entry = leftOutEntries.get(requirement.address) ?? { listEntry: requirement.listEntry, leftOut: new Set() };
579
+ entry.leftOut.add(requirement.requires);
580
+ leftOutEntries.set(requirement.address, entry);
581
+ if (requirement.listEntry.trackedWithout(entry.leftOut) !== undefined)
582
+ continue;
583
+ // No entry is left: build emits no such resource, so it is skipped below.
584
+ leftOutEntries.delete(requirement.address);
585
+ }
542
586
  pruned = requirement.prune(pruned);
543
587
  const ownFile = requirement.pruneOwnFile;
544
588
  if (ownFile !== undefined) {
@@ -557,10 +601,19 @@ function dropDependentsOfSkipped(root, ownFileByKind, requirements, streamAddres
557
601
  detail: `left out of the pull, skipped: ${reason}`,
558
602
  consequence: "it is not written to source or adopted, and adoption releases it if state already manages it; it keeps running on the platform unmanaged until a later pull extracts what it needs, which writes it back to source and adopts it again" +
559
603
  (requirement.pruneOwnFile?.archiveRefName !== undefined
560
- ? `. Its file from an earlier pull (${requirement.pruneOwnFile.kind} ${requirement.pruneOwnFile.archiveRefName}) is archived once adoption releases it; with --no-adopt, or if adoption fails first, that file stays until a pull that adopts`
604
+ ? ownFileArchiveConsequence(requirement.pruneOwnFile.kind, requirement.pruneOwnFile.archiveRefName)
561
605
  : ""),
562
606
  }));
563
607
  }
608
+ for (const [address, { listEntry, leftOut }] of leftOutEntries) {
609
+ if (skippedSet.has(address))
610
+ continue;
611
+ const tracked = listEntry.trackedWithout(leftOut);
612
+ if (tracked === undefined)
613
+ continue;
614
+ trimmedLists.push({ address, leftOut: [...leftOut].sort(), importId: tracked.importId, attribute: listEntry.attribute, keptIds: tracked.keptIds });
615
+ reports.push(`${address}: kept in source and adoption without ${[...leftOut].sort().join(", ")}, which this pull left out; it tracks only the entries source holds`);
616
+ }
564
617
  return pruned;
565
618
  }
566
619
  /** Why build will not emit `requirement`'s dependent, or undefined when it will. */
@@ -7,6 +7,7 @@ export type { PathSeg, TfBlock, TfBlockKind, TfDocument, TfExpr, TfLifecycle, Tf
7
7
  export { expr, forEachExpr, isTfExpr } from "./model.js";
8
8
  export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./escape.js";
9
9
  export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
10
+ export { renderJsonencode } from "./jsonencode.js";
10
11
  export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, parseHclDocuments, TfParseError, type BackendHclInspection, } from "./parse.js";
11
12
  export { renderBlock, renderDocument } from "./render.js";
12
13
  export { hclCodeLines, hclDepthDelta, hclStatementEnd, type HclCodeLine } from "./scan.js";
@@ -6,6 +6,7 @@
6
6
  export { expr, forEachExpr, isTfExpr } from "./model.js";
7
7
  export { decodeTemplateEscapes, encodeTemplateEscapes, quoteHclString } from "./escape.js";
8
8
  export { parseExpression, parseStringValue, TfExprError } from "./expr.js";
9
+ export { renderJsonencode } from "./jsonencode.js";
9
10
  export { assertNoUnsafeIntegers, inspectBackendHcl, parseHcl, parseHclDocuments, TfParseError, } from "./parse.js";
10
11
  export { renderBlock, renderDocument } from "./render.js";
11
12
  export { hclCodeLines, hclDepthDelta, hclStatementEnd } from "./scan.js";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * OpenTofu's `jsonencode` text for a literal value, shared by pull's
3
+ * round-trip check and automation extraction (#3050).
4
+ */
5
+ import { type TfValue } from "./model.js";
6
+ /**
7
+ * The string OpenTofu's `jsonencode` renders for a literal value: object keys
8
+ * in byte order, `<`, `>`, `&`, U+2028 and U+2029 escaped (as Go's
9
+ * encoding/json does), no whitespace. Undefined for an
10
+ * expression, or a value whose rendering this does not reproduce exactly
11
+ * (a non-integer or unsafe number, `-0`, a lone surrogate).
12
+ *
13
+ * It sees parsed numbers, not their source text: a decimal literal that
14
+ * parses to a safe integer (`1.0000000000000001`) renders as that integer,
15
+ * while OpenTofu keeps the decimal. Neither side can write such a literal
16
+ * today: the build prints JS numbers in their shortest form, and the export
17
+ * writes Go float64s the same way.
18
+ */
19
+ export declare function renderJsonencode(value: TfValue): string | undefined;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * OpenTofu's `jsonencode` text for a literal value, shared by pull's
3
+ * round-trip check and automation extraction (#3050).
4
+ */
5
+ import { isTfExpr } from "./model.js";
6
+ const LONE_SURROGATE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;
7
+ function utf8Order(left, right) {
8
+ return Buffer.compare(Buffer.from(left, "utf8"), Buffer.from(right, "utf8"));
9
+ }
10
+ /**
11
+ * The string OpenTofu's `jsonencode` renders for a literal value: object keys
12
+ * in byte order, `<`, `>`, `&`, U+2028 and U+2029 escaped (as Go's
13
+ * encoding/json does), no whitespace. Undefined for an
14
+ * expression, or a value whose rendering this does not reproduce exactly
15
+ * (a non-integer or unsafe number, `-0`, a lone surrogate).
16
+ *
17
+ * It sees parsed numbers, not their source text: a decimal literal that
18
+ * parses to a safe integer (`1.0000000000000001`) renders as that integer,
19
+ * while OpenTofu keeps the decimal. Neither side can write such a literal
20
+ * today: the build prints JS numbers in their shortest form, and the export
21
+ * writes Go float64s the same way.
22
+ */
23
+ export function renderJsonencode(value) {
24
+ if (value === null || typeof value === "boolean")
25
+ return JSON.stringify(value);
26
+ if (typeof value === "number") {
27
+ return Number.isSafeInteger(value) && !Object.is(value, -0) ? String(value) : undefined;
28
+ }
29
+ if (typeof value === "string") {
30
+ if (LONE_SURROGATE.test(value))
31
+ return undefined;
32
+ return JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (char) => `\\u${char.charCodeAt(0).toString(16).padStart(4, "0")}`);
33
+ }
34
+ if (Array.isArray(value)) {
35
+ const items = value.map(renderJsonencode);
36
+ return items.every((item) => item !== undefined) ? `[${items.join(",")}]` : undefined;
37
+ }
38
+ if (isTfExpr(value))
39
+ return undefined;
40
+ const entries = [];
41
+ for (const key of Object.keys(value).sort(utf8Order)) {
42
+ const rendered = renderJsonencode(value[key]);
43
+ const renderedKey = renderJsonencode(key);
44
+ if (rendered === undefined || renderedKey === undefined)
45
+ return undefined;
46
+ entries.push(`${renderedKey}:${rendered}`);
47
+ }
48
+ return `{${entries.join(",")}}`;
49
+ }
@@ -11,12 +11,31 @@ export interface ValidationFailure {
11
11
  /**
12
12
  * A reference the live config no longer satisfies (for example a run-automation
13
13
  * tool that does not map a newly required trigger parameter). Pull downgrades
14
- * these to warnings; build/plan/apply keep them fatal.
14
+ * these to warnings; build/plan/apply keep them fatal unless `stateCheck`
15
+ * finds the resource unchanged in state.
15
16
  */
16
17
  readonly staleReference?: boolean;
18
+ /**
19
+ * For a stale reference: decides from state whether the resource is
20
+ * unchanged since adoption. The owning entity defines "unchanged"; the
21
+ * engine only supplies the lookup. Not serialized (a function).
22
+ */
23
+ readonly stateCheck?: StaleReferenceStateCheck;
17
24
  /** What kind of finding this is, when a caller has to treat it specially. */
18
25
  readonly code?: "unresolved-task-filter-ref";
19
26
  }
27
+ /** A managed root-module resource's state attributes, by `type.label` address. */
28
+ export type StateAttributesLookup = (address: string) => Readonly<Record<string, unknown>> | undefined;
29
+ /**
30
+ * The answer of a stale reference's state check: `unchanged` keeps it a
31
+ * warning, otherwise it stays fatal. `note` says why, in the user's terms,
32
+ * and is appended to the message either way.
33
+ */
34
+ export interface StaleReferenceStateVerdict {
35
+ readonly unchanged: boolean;
36
+ readonly note: string;
37
+ }
38
+ export type StaleReferenceStateCheck = (lookup: StateAttributesLookup) => StaleReferenceStateVerdict;
20
39
  export declare function formatValidationFailure(failure: ValidationFailure): string;
21
40
  export declare class ValidationFailureError extends Error {
22
41
  readonly failures: readonly ValidationFailure[];
@@ -43,4 +62,20 @@ export declare function setValidationScope(scope: {
43
62
  export declare function sessionValidationFailures(): readonly ValidationFailure[];
44
63
  /** Record failures into the active session. No-op when nothing is collecting. */
45
64
  export declare function recordValidations(incoming: readonly ValidationFailure[]): void;
65
+ /** True when the session holds a fatal stale reference that state could settle. */
66
+ export declare function hasStateCheckedStaleReferences(): boolean;
67
+ /**
68
+ * Settle the session's fatal stale references against state (edk#3230,
69
+ * #3231). A finding whose check reports its resource unchanged since
70
+ * adoption becomes a warning, so a freshly pulled workspace plans; any other
71
+ * stays fatal. Each message gains the check's note. With no state (`lookup`
72
+ * undefined), every such finding stays fatal with `unreadable` as its note.
73
+ */
74
+ export declare function resolveStaleReferences(lookup: StateAttributesLookup | undefined, unreadable: string): void;
75
+ /**
76
+ * Keep the session's fatal stale references as warnings without reading
77
+ * state, for a build whose state is in transit (a backend or provider-source
78
+ * migration). `note` says when they are checked.
79
+ */
80
+ export declare function deferStaleReferences(note: string): void;
46
81
  export declare function hasFatalValidation(failures: readonly ValidationFailure[]): boolean;
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Collects validation failures across a pull or build instead of stopping at
3
- * the first one. A stale reference is fatal while authoring (build/plan/apply)
4
- * and a warning on pull, which is a read of live configuration.
3
+ * the first one. A stale reference is a warning on pull, which is a read of
4
+ * live configuration. On build/plan/apply it is fatal, unless the finding
5
+ * carries a state check and the state shows the resource unchanged since it
6
+ * was adopted (edk#3230, #3231): see {@link resolveStaleReferences}.
5
7
  */
6
8
  import { AsyncLocalStorage } from "node:async_hooks";
7
9
  export function formatValidationFailure(failure) {
@@ -90,6 +92,58 @@ export function recordValidations(incoming) {
90
92
  session.failures.push(recorded);
91
93
  }
92
94
  }
95
+ /** True when the session holds a fatal stale reference that state could settle. */
96
+ export function hasStateCheckedStaleReferences() {
97
+ return (storage().getStore()?.failures ?? []).some(isStateCheckedStaleFatal);
98
+ }
99
+ function isStateCheckedStaleFatal(failure) {
100
+ return failure.severity === "fatal" && failure.staleReference === true && failure.stateCheck !== undefined;
101
+ }
102
+ /**
103
+ * Settle the session's fatal stale references against state (edk#3230,
104
+ * #3231). A finding whose check reports its resource unchanged since
105
+ * adoption becomes a warning, so a freshly pulled workspace plans; any other
106
+ * stays fatal. Each message gains the check's note. With no state (`lookup`
107
+ * undefined), every such finding stays fatal with `unreadable` as its note.
108
+ */
109
+ export function resolveStaleReferences(lookup, unreadable) {
110
+ const session = storage().getStore();
111
+ if (session === undefined || session.mode === "pull")
112
+ return;
113
+ for (const [index, failure] of session.failures.entries()) {
114
+ if (!isStateCheckedStaleFatal(failure))
115
+ continue;
116
+ const verdict = lookup === undefined
117
+ ? { unchanged: false, note: unreadable }
118
+ : failure.stateCheck(lookup);
119
+ const resolved = {
120
+ ...failure,
121
+ severity: verdict.unchanged ? "warning" : "fatal",
122
+ message: `${failure.message} (${verdict.note})`,
123
+ };
124
+ session.seen.delete(`${failure.severity}\0${failure.address}\0${failure.message}`);
125
+ session.seen.add(`${resolved.severity}\0${resolved.address}\0${resolved.message}`);
126
+ session.failures[index] = resolved;
127
+ }
128
+ }
129
+ /**
130
+ * Keep the session's fatal stale references as warnings without reading
131
+ * state, for a build whose state is in transit (a backend or provider-source
132
+ * migration). `note` says when they are checked.
133
+ */
134
+ export function deferStaleReferences(note) {
135
+ const session = storage().getStore();
136
+ if (session === undefined || session.mode === "pull")
137
+ return;
138
+ for (const [index, failure] of session.failures.entries()) {
139
+ if (!isStateCheckedStaleFatal(failure))
140
+ continue;
141
+ const resolved = { ...failure, severity: "warning", message: `${failure.message} (${note})` };
142
+ session.seen.delete(`${failure.severity}\0${failure.address}\0${failure.message}`);
143
+ session.seen.add(`${resolved.severity}\0${resolved.address}\0${resolved.message}`);
144
+ session.failures[index] = resolved;
145
+ }
146
+ }
93
147
  export function hasFatalValidation(failures) {
94
148
  return failures.some((failure) => failure.severity === "fatal");
95
149
  }
@@ -11,6 +11,12 @@
11
11
  * CommonJS export to the SDK.
12
12
  */
13
13
  export declare function findInstalledSdkSubpath(root: string, subpath: string): string | undefined;
14
+ /**
15
+ * An import of an `@elementumai/edk/<subpath>` the package doesn't export
16
+ * (e.g. `/portal` for `/portals`, edk#3210): add the closest exported subpath
17
+ * to the error, or the list of subpaths when none is close.
18
+ */
19
+ export declare function withSdkSubpathHint(err: unknown, root: string): unknown;
14
20
  /**
15
21
  * Upgrade the short-lived #730 barrel shape before Bun/jiti evaluates it.
16
22
  * Generated catalogs are CLI-owned, and this writes exactly the lazy-require
@@ -159,6 +159,81 @@ export function findInstalledSdkSubpath(root, subpath) {
159
159
  current = parent;
160
160
  }
161
161
  }
162
+ /**
163
+ * The nearest installed `@elementumai/edk` package's root and `exports` map,
164
+ * for the subpath hint only. {@link findInstalledSdkSubpath} keeps its own
165
+ * walk, which goes on past a nearer package that doesn't export the subpath.
166
+ */
167
+ function installedSdkExports(root) {
168
+ let current = root;
169
+ while (true) {
170
+ const packageRoot = join(current, "node_modules", "@elementumai", "edk");
171
+ const packageJson = join(packageRoot, "package.json");
172
+ if (existsSync(packageJson)) {
173
+ try {
174
+ const parsed = JSON.parse(readFileSync(packageJson, "utf8"));
175
+ if (parsed.exports !== null && typeof parsed.exports === "object") {
176
+ return { packageRoot, exports: parsed.exports };
177
+ }
178
+ }
179
+ catch {
180
+ // Keep looking higher up.
181
+ }
182
+ }
183
+ const parent = dirname(current);
184
+ if (parent === current)
185
+ return undefined;
186
+ current = parent;
187
+ }
188
+ }
189
+ /** The `@elementumai/edk` subpaths the nearest installed package exports. */
190
+ function installedSdkSubpaths(root) {
191
+ return Object.keys(installedSdkExports(root)?.exports ?? {})
192
+ .filter((key) => key.startsWith("./") && !key.includes("*") && key !== "./package.json")
193
+ .map((key) => key.slice(2));
194
+ }
195
+ function editDistance(a, b) {
196
+ const row = Array.from({ length: b.length + 1 }, (_, j) => j);
197
+ for (let i = 1; i <= a.length; i++) {
198
+ let diagonal = row[0];
199
+ row[0] = i;
200
+ for (let j = 1; j <= b.length; j++) {
201
+ const above = row[j];
202
+ row[j] = Math.min(above + 1, row[j - 1] + 1, diagonal + (a[i - 1] === b[j - 1] ? 0 : 1));
203
+ diagonal = above;
204
+ }
205
+ }
206
+ return row[b.length];
207
+ }
208
+ const UNEXPORTED_SDK_SUBPATH = /(?:Package subpath '\.\/([^']+)' is not defined by "exports" in [^\n]*@elementumai[\\/]edk[\\/]package\.json|Cannot find module '@elementumai\/edk\/([^']+)')/;
209
+ /**
210
+ * An import of an `@elementumai/edk/<subpath>` the package doesn't export
211
+ * (e.g. `/portal` for `/portals`, edk#3210): add the closest exported subpath
212
+ * to the error, or the list of subpaths when none is close.
213
+ */
214
+ export function withSdkSubpathHint(err, root) {
215
+ // Bun's resolve error (the compiled binary's jiti path) is not an Error
216
+ // instance, and String() ignores a changed message, so read any object's
217
+ // message and return a new Error that keeps the original as its cause.
218
+ const message = typeof err === "object" && err !== null && typeof err.message === "string"
219
+ ? err.message
220
+ : undefined;
221
+ if (message === undefined)
222
+ return err;
223
+ const match = UNEXPORTED_SDK_SUBPATH.exec(message);
224
+ const subpath = match?.[1] ?? match?.[2];
225
+ if (subpath === undefined)
226
+ return err;
227
+ const exported = installedSdkSubpaths(root);
228
+ // An exported subpath that failed to resolve for another reason gets no hint.
229
+ if (exported.length === 0 || exported.includes(subpath))
230
+ return err;
231
+ const [closest] = [...exported].sort((a, b) => editDistance(subpath, a) - editDistance(subpath, b));
232
+ const hint = closest !== undefined && editDistance(subpath, closest) <= Math.max(2, Math.floor(subpath.length / 3))
233
+ ? `did you mean "@elementumai/edk/${closest}"?`
234
+ : `the package exports ${exported.map((name) => `"@elementumai/edk/${name}"`).join(", ")}`;
235
+ return new Error(`${message} (${hint})`, { cause: err });
236
+ }
162
237
  /**
163
238
  * Upgrade the short-lived #730 barrel shape before Bun/jiti evaluates it.
164
239
  * Generated catalogs are CLI-owned, and this writes exactly the lazy-require
@@ -348,7 +423,12 @@ function createJitiLoader(root) {
348
423
  });
349
424
  });
350
425
  const jiti = await pending;
351
- return (await withImportingFile(resolve(file), () => jiti.import(resolve(file))));
426
+ try {
427
+ return (await withImportingFile(resolve(file), () => jiti.import(resolve(file))));
428
+ }
429
+ catch (err) {
430
+ throw withSdkSubpathHint(err, root);
431
+ }
352
432
  },
353
433
  };
354
434
  }
@@ -399,7 +479,12 @@ export function createWorkspaceLoader(orgRoot) {
399
479
  const url = pathToFileURL(resolve(file)).href;
400
480
  // Set inside the serialized section so overlapping imports cannot
401
481
  // see each other's file.
402
- return await withImportingFile(resolve(file), () => nativeImport(`${url}?${GENERATION_KEY}=${generation}`));
482
+ try {
483
+ return await withImportingFile(resolve(file), () => nativeImport(`${url}?${GENERATION_KEY}=${generation}`));
484
+ }
485
+ catch (err) {
486
+ throw withSdkSubpathHint(err, root);
487
+ }
403
488
  });
404
489
  },
405
490
  };
@@ -54,6 +54,13 @@ export interface FilterFromTfOptions {
54
54
  }
55
55
  /** Decode one `filter` attribute through the shared exhaustive codec. */
56
56
  export declare function filterFromTf(value: TfValue, owner: AccessPolicyOwner, where: string, ctx?: FromTfContext, options?: FilterFromTfOptions): Filter<RefExpr, RefExpr>;
57
+ /**
58
+ * Decode a filter whose fields may belong to any of `owners`, each field and
59
+ * option lookup taken as the first owner's it belongs to: a relationship
60
+ * condition comparing a field of one side with a field of the other (#3144).
61
+ * With one owner it is {@link filterFromTf}.
62
+ */
63
+ export declare function filterFromTfOfOwners(value: TfValue, owners: readonly [AccessPolicyOwner, ...AccessPolicyOwner[]], where: string, ctx?: FromTfContext, options?: FilterFromTfOptions): Filter<RefExpr, RefExpr>;
57
64
  /**
58
65
  * The EDK ref of the app that owns a service-account block, read from the
59
66
  * block's `app_id`: the owner itself when that is the app the ref points at,
@@ -14,11 +14,27 @@ import { EntityTfError } from "../../engine/entity.js";
14
14
  import { dataRefLabel, groupCatalogKey, resourceRefLabel } from "../../engine/pull/context.js";
15
15
  import { appResourceLabelPrefix, elementResourceLabelPrefix, isTfExpr, scopedResourceLabel, tfLabelToTsLabel, } from "../../engine/tf/index.js";
16
16
  import { pulledFieldBagKey } from "../field/from-tf.js";
17
- import { filterFromTf as deserializeFilterFromTf } from "../shared/filters/tf-codec.js";
17
+ import { filterFromTf as deserializeFilterFromTf, UnauthorableFilterValueError } from "../shared/filters/tf-codec.js";
18
18
  import { groupId, userId, } from "./principal.js";
19
19
  import { KNOWN_ACCESS_POLICY_ATTRS } from "./types.js";
20
20
  import { finishPulledMemberList } from "./member-list.js";
21
- function fieldRef(value, owner, where, ctx) {
21
+ /**
22
+ * The first of `owners` that `value` names a field of. A raw id no owner's
23
+ * state names stays unresolved, as for one owner; anything else no owner
24
+ * claims fails naming `where`.
25
+ */
26
+ function fieldRefOfOwners(value, owners, where, ctx) {
27
+ for (const owner of owners) {
28
+ const ref = ownedFieldRef(value, owner, ctx);
29
+ if (ref !== undefined)
30
+ return ref;
31
+ }
32
+ if (typeof value === "string")
33
+ return { kind: "unresolved", uuid: value, hint: "field" };
34
+ throw new EntityTfError(`${where}: field reference cannot be reconstructed`);
35
+ }
36
+ /** `value` as a field of `owner`, or undefined when it names no field of that owner. */
37
+ function ownedFieldRef(value, owner, ctx) {
22
38
  if (isTfExpr(value) && value.$expr === "resource-attr" && value.type.endsWith("_field") && value.path[0] === "id") {
23
39
  // scopedLabelToBagKey's stripping is a documented no-op when the label
24
40
  // isn't actually prefixed for this owner (src/engine/tf/labels.ts) - it
@@ -26,9 +42,10 @@ function fieldRef(value, owner, where, ctx) {
26
42
  // appHandle for a field that belongs to a DIFFERENT aspect than `owner`
27
43
  // (e.g. a relationship's filter referencing the TARGET's own field, not
28
44
  // the relationship's owner - edk#650 review). Only take this branch when
29
- // the label actually belongs to `owner`; otherwise fall through so a
30
- // caller's owner-then-target retry (relationship/from-tf.ts) or the
31
- // final throw below can handle it instead of a silent wrong answer.
45
+ // the label actually belongs to `owner`; otherwise return nothing so
46
+ // another owner (relationship/from-tf.ts tries the owner, the target,
47
+ // then both, #3144) or fieldRefOfOwners's throw handles it instead of a
48
+ // silent wrong answer.
32
49
  const prefix = owner.scope === "element" ? elementResourceLabelPrefix(owner.ownerTfLabel) : appResourceLabelPrefix(owner.ownerTfLabel);
33
50
  if (value.label.startsWith(prefix)) {
34
51
  return { kind: "field", appHandle: owner.ownerRefName, fieldKey: pulledFieldBagKey(owner.ownerTfLabel, value.label, owner.scope, ctx) };
@@ -47,16 +64,12 @@ function fieldRef(value, owner, where, ctx) {
47
64
  }
48
65
  if (typeof value === "string") {
49
66
  const stateRef = owner.foreignFieldRefsById?.get(value);
50
- if (stateRef?.ownerRefName === owner.ownerRefName) {
51
- return { kind: "field", appHandle: owner.ownerRefName, fieldKey: stateRef.fieldKey };
52
- }
53
- return { kind: "unresolved", uuid: value, hint: "field" };
67
+ return stateRef?.ownerRefName === owner.ownerRefName
68
+ ? { kind: "field", appHandle: owner.ownerRefName, fieldKey: stateRef.fieldKey }
69
+ : undefined;
54
70
  }
55
71
  const dataLabel = owner.dataField === undefined ? undefined : dataRefLabel(value, "elementum_field");
56
- const dataField = dataLabel === undefined ? undefined : owner.dataField?.(dataLabel);
57
- if (dataField !== undefined)
58
- return dataField;
59
- throw new EntityTfError(`${where}: field reference cannot be reconstructed`);
72
+ return dataLabel === undefined ? undefined : owner.dataField?.(dataLabel);
60
73
  }
61
74
  /**
62
75
  * A picklist-typed literal filter value ("Open") emits as a
@@ -83,20 +96,48 @@ function picklistOptionLabel(value, owner) {
83
96
  }
84
97
  /** Decode one `filter` attribute through the shared exhaustive codec. */
85
98
  export function filterFromTf(value, owner, where, ctx, options) {
99
+ return filterFromTfOfOwners(value, [owner], where, ctx, options);
100
+ }
101
+ /**
102
+ * Decode a filter whose fields may belong to any of `owners`, each field and
103
+ * option lookup taken as the first owner's it belongs to: a relationship
104
+ * condition comparing a field of one side with a field of the other (#3144).
105
+ * With one owner it is {@link filterFromTf}.
106
+ */
107
+ export function filterFromTfOfOwners(value, owners, where, ctx, options) {
108
+ const optionLabel = (literal) => {
109
+ for (const owner of owners) {
110
+ const label = picklistOptionLabel(literal, owner);
111
+ if (label !== undefined)
112
+ return label;
113
+ }
114
+ return undefined;
115
+ };
116
+ const stage = (literal) => {
117
+ for (const owner of owners) {
118
+ const name = stageName(literal, owner, ctx);
119
+ if (name !== undefined)
120
+ return name;
121
+ }
122
+ return undefined;
123
+ };
86
124
  try {
87
125
  return deserializeFilterFromTf(value, {
88
- field: (fieldValue) => fieldRef(fieldValue, owner, where, ctx),
126
+ field: (fieldValue) => fieldRefOfOwners(fieldValue, owners, where, ctx),
89
127
  reference: () => { throw new EntityTfError(`${where}: access-policy reference values are not supported`); },
90
- literal: (literal) => picklistOptionLabel(literal, owner) ?? stageName(literal, owner, ctx) ?? literal,
128
+ literal: (literal) => optionLabel(literal) ?? stage(literal) ?? literal,
91
129
  ...(options?.optionLookupsAreIdentities === true && { optionLookupsAreIdentities: true }),
92
130
  ...(options?.optionLookupsAsTextOption === true && {
93
- optionLookupsAreIdentities: (stored) => picklistOptionLabel(stored, owner) !== undefined,
131
+ optionLookupsAreIdentities: (stored) => optionLabel(stored) !== undefined,
94
132
  }),
95
133
  });
96
134
  }
97
135
  catch (error) {
98
136
  if (error instanceof EntityTfError && !error.message.startsWith(where)) {
99
- throw new EntityTfError(`${where}: ${error.message}`);
137
+ // Keep an unauthorable value's class, so a caller that drops other
138
+ // undecodable filters can fail on this one instead (#3144).
139
+ const message = `${where}: ${error.message}`;
140
+ throw error instanceof UnauthorableFilterValueError ? new UnauthorableFilterValueError(message) : new EntityTfError(message);
100
141
  }
101
142
  throw error;
102
143
  }
@@ -20,6 +20,7 @@
20
20
  import type { OrgRefLookup } from "../../engine/build/context.js";
21
21
  import type { OptionIdIndex } from "../../engine/pull/field-refs-registry.js";
22
22
  import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
23
+ import { type FieldOwnership } from "../field/to-tf.js";
23
24
  import type { Filter } from "../shared/filters/types.js";
24
25
  import type { AppServiceAccount } from "../service-account/build.js";
25
26
  import type { AccessPolicyGroupRef, AccessPolicyServiceAccountRef, AccessPolicyUserRef } from "./principal.js";
@@ -41,7 +42,8 @@ export interface AccessPolicyToTfContext {
41
42
  */
42
43
  readonly appRefName?: string;
43
44
  readonly serviceAccounts?: Readonly<Record<string, AppServiceAccount>>;
44
- readonly fieldAddresses?: ReadonlyMap<string, string>;
45
+ /** The owner's field addresses (or a sibling's, #3088), keyed by bag key. */
46
+ readonly fieldAddresses?: FieldOwnership;
45
47
  /** Option ids known offline, so a raw id's warning can name its label (#1733). */
46
48
  readonly optionIds?: OptionIdIndex;
47
49
  /**