@elementumai/edk 0.10.3 → 0.11.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 (155) hide show
  1. package/README.md +11 -7
  2. package/dist-sdk/src/catalog/token.js +2 -1
  3. package/dist-sdk/src/core/wire/ref-serializer.js +26 -1
  4. package/dist-sdk/src/engine/build/context.d.ts +4 -0
  5. package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
  6. package/dist-sdk/src/engine/coverage-gaps.js +3 -0
  7. package/dist-sdk/src/engine/ei/json-stream-reader.d.ts +43 -0
  8. package/dist-sdk/src/engine/ei/json-stream-reader.js +234 -0
  9. package/dist-sdk/src/engine/ei/run.d.ts +22 -0
  10. package/dist-sdk/src/engine/ei/run.js +99 -18
  11. package/dist-sdk/src/engine/ei/saved-plan.d.ts +16 -0
  12. package/dist-sdk/src/engine/ei/saved-plan.js +19 -0
  13. package/dist-sdk/src/engine/ei/state.d.ts +1 -1
  14. package/dist-sdk/src/engine/ei/state.js +17 -4
  15. package/dist-sdk/src/engine/progress.d.ts +3 -1
  16. package/dist-sdk/src/engine/progress.js +7 -3
  17. package/dist-sdk/src/engine/pull/authored-address.d.ts +15 -1
  18. package/dist-sdk/src/engine/pull/authored-address.js +180 -29
  19. package/dist-sdk/src/engine/pull/context.d.ts +52 -7
  20. package/dist-sdk/src/engine/pull/context.js +7 -4
  21. package/dist-sdk/src/engine/tf/index.d.ts +3 -2
  22. package/dist-sdk/src/engine/tf/index.js +3 -2
  23. package/dist-sdk/src/engine/tf/labels.d.ts +22 -0
  24. package/dist-sdk/src/engine/tf/labels.js +50 -0
  25. package/dist-sdk/src/engine/tf/model.d.ts +2 -0
  26. package/dist-sdk/src/engine/tf/model.js +26 -0
  27. package/dist-sdk/src/engine/tf/scan.d.ts +22 -0
  28. package/dist-sdk/src/engine/tf/scan.js +123 -0
  29. package/dist-sdk/src/engine/validation.d.ts +2 -0
  30. package/dist-sdk/src/engine/workspace/loader.d.ts +8 -0
  31. package/dist-sdk/src/engine/workspace/loader.js +20 -0
  32. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +17 -0
  33. package/dist-sdk/src/entities/access-policy/from-tf.js +52 -24
  34. package/dist-sdk/src/entities/access-policy/member-list.d.ts +32 -0
  35. package/dist-sdk/src/entities/access-policy/member-list.js +57 -0
  36. package/dist-sdk/src/entities/access-policy/module.js +5 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +4 -3
  38. package/dist-sdk/src/entities/access-policy/to-tf.js +21 -12
  39. package/dist-sdk/src/entities/agent/build.js +7 -5
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +2 -0
  41. package/dist-sdk/src/entities/agent/from-tf.js +13 -3
  42. package/dist-sdk/src/entities/agent/to-tf.d.ts +13 -11
  43. package/dist-sdk/src/entities/agent/to-tf.js +28 -17
  44. package/dist-sdk/src/entities/agent/tools.d.ts +8 -0
  45. package/dist-sdk/src/entities/agent/tools.js +6 -2
  46. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +2 -0
  47. package/dist-sdk/src/entities/agent-tool/from-tf.js +2 -2
  48. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +29 -0
  49. package/dist-sdk/src/entities/agent-tool/to-tf.js +65 -3
  50. package/dist-sdk/src/entities/agent-tool/types.d.ts +12 -8
  51. package/dist-sdk/src/entities/agent-tool/types.js +13 -9
  52. package/dist-sdk/src/entities/app/build.d.ts +11 -0
  53. package/dist-sdk/src/entities/app/build.js +1 -0
  54. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +11 -7
  55. package/dist-sdk/src/entities/app/from-tf.js +19 -9
  56. package/dist-sdk/src/entities/app/to-tf.js +6 -4
  57. package/dist-sdk/src/entities/automation/build.d.ts +2 -7
  58. package/dist-sdk/src/entities/automation/build.js +55 -16
  59. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +7 -4
  60. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +7 -11
  61. package/dist-sdk/src/entities/automation/from-tf.d.ts +23 -1
  62. package/dist-sdk/src/entities/automation/from-tf.js +456 -34
  63. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  64. package/dist-sdk/src/entities/automation/module.d.ts +22 -2
  65. package/dist-sdk/src/entities/automation/module.js +273 -58
  66. package/dist-sdk/src/entities/automation/output-field-types.d.ts +8 -0
  67. package/dist-sdk/src/entities/automation/output-field-types.js +20 -0
  68. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +24 -2
  69. package/dist-sdk/src/entities/automation/output-key-wire-name.js +72 -3
  70. package/dist-sdk/src/entities/automation/run-target.d.ts +59 -0
  71. package/dist-sdk/src/entities/automation/run-target.js +99 -0
  72. package/dist-sdk/src/entities/automation/script-code.d.ts +9 -0
  73. package/dist-sdk/src/entities/automation/script-code.js +24 -3
  74. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +16 -0
  75. package/dist-sdk/src/entities/automation/task-output-labels.js +49 -0
  76. package/dist-sdk/src/entities/automation/tasks.d.ts +20 -8
  77. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -3
  78. package/dist-sdk/src/entities/automation/to-tf.js +171 -58
  79. package/dist-sdk/src/entities/automation/triggers.d.ts +22 -3
  80. package/dist-sdk/src/entities/automation/triggers.js +40 -0
  81. package/dist-sdk/src/entities/automation/types.d.ts +21 -0
  82. package/dist-sdk/src/entities/automation/types.js +26 -0
  83. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +11 -1
  84. package/dist-sdk/src/entities/dashboard/from-tf.js +57 -7
  85. package/dist-sdk/src/entities/dashboard/to-tf.js +13 -0
  86. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +7 -2
  87. package/dist-sdk/src/entities/dynamic-layout/from-tf.d.ts +3 -0
  88. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +65 -19
  89. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +4 -2
  90. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +341 -32
  91. package/dist-sdk/src/entities/element/build.d.ts +10 -0
  92. package/dist-sdk/src/entities/element/build.js +1 -0
  93. package/dist-sdk/src/entities/element/from-tf.js +16 -9
  94. package/dist-sdk/src/entities/element/to-tf.js +6 -4
  95. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  96. package/dist-sdk/src/entities/field/from-tf.js +79 -1
  97. package/dist-sdk/src/entities/field/module.js +7 -0
  98. package/dist-sdk/src/entities/field/to-tf.d.ts +30 -1
  99. package/dist-sdk/src/entities/field/to-tf.js +51 -0
  100. package/dist-sdk/src/entities/file-reader/module.js +3 -3
  101. package/dist-sdk/src/entities/file-reader/to-tf.js +3 -3
  102. package/dist-sdk/src/entities/file-reader/types.d.ts +4 -16
  103. package/dist-sdk/src/entities/file-reader/types.js +7 -0
  104. package/dist-sdk/src/entities/org/group.d.ts +1 -0
  105. package/dist-sdk/src/entities/org/group.js +2 -1
  106. package/dist-sdk/src/entities/record-create-form/from-tf.d.ts +8 -0
  107. package/dist-sdk/src/entities/record-create-form/from-tf.js +10 -2
  108. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +2 -1
  109. package/dist-sdk/src/entities/record-create-form/to-tf.js +14 -2
  110. package/dist-sdk/src/entities/relationship/from-tf.d.ts +8 -0
  111. package/dist-sdk/src/entities/relationship/from-tf.js +88 -10
  112. package/dist-sdk/src/entities/relationship/to-tf.d.ts +3 -2
  113. package/dist-sdk/src/entities/relationship/to-tf.js +79 -8
  114. package/dist-sdk/src/entities/role/from-tf.js +24 -7
  115. package/dist-sdk/src/entities/role/to-tf.js +25 -7
  116. package/dist-sdk/src/entities/service-account/from-tf.js +2 -1
  117. package/dist-sdk/src/entities/service-account/module.js +15 -0
  118. package/dist-sdk/src/entities/service-account/to-tf.js +12 -4
  119. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  120. package/dist-sdk/src/entities/shared/filters/tf-codec.js +12 -7
  121. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -2
  122. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +8 -1
  123. package/dist-sdk/src/entities/skill/from-tf.js +10 -3
  124. package/dist-sdk/src/entities/skill/module.js +44 -2
  125. package/dist-sdk/src/entities/skill/to-tf.d.ts +8 -1
  126. package/dist-sdk/src/entities/skill/to-tf.js +23 -14
  127. package/dist-sdk/src/entities/skill/tools.d.ts +8 -0
  128. package/dist-sdk/src/entities/skill/tools.js +6 -2
  129. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +2 -0
  130. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  131. package/dist-sdk/src/entities/skill-tool/to-tf.js +6 -2
  132. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.d.ts +10 -2
  133. package/dist-sdk/src/entities/view/agent-view-layout-from-tf.js +18 -4
  134. package/dist-sdk/src/entities/view/custom-view-validate.js +6 -5
  135. package/dist-sdk/src/entities/view/from-tf.d.ts +68 -0
  136. package/dist-sdk/src/entities/view/from-tf.js +503 -25
  137. package/dist-sdk/src/entities/view/module.js +15 -0
  138. package/dist-sdk/src/entities/view/portable.d.ts +11 -0
  139. package/dist-sdk/src/entities/view/portable.js +47 -0
  140. package/dist-sdk/src/entities/view/to-tf.d.ts +4 -1
  141. package/dist-sdk/src/entities/view/to-tf.js +25 -7
  142. package/dist-sdk/src/entities/view/types.js +1 -1
  143. package/dist-sdk/src/entities/widget/build.d.ts +4 -3
  144. package/dist-sdk/src/entities/widget/from-tf.d.ts +3 -0
  145. package/dist-sdk/src/entities/widget/from-tf.js +100 -3
  146. package/dist-sdk/src/entities/widget/to-tf.d.ts +16 -1
  147. package/dist-sdk/src/entities/widget/to-tf.js +77 -14
  148. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +27 -8
  149. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  150. package/dist-sdk/src/graph/field-resource-types.d.ts +2 -0
  151. package/dist-sdk/src/graph/field-resource-types.js +11 -0
  152. package/dist-sdk/src/graph/index.d.ts +28 -3
  153. package/dist-sdk/src/graph/index.js +12 -2
  154. package/dist-sdk/src/graph/types.d.ts +164 -5
  155. package/package.json +1 -1
@@ -14,9 +14,11 @@
14
14
  */
15
15
  import { workspaceAspectKey } from "../../engine/build/context.js";
16
16
  import { EntityTfError } from "../../engine/entity.js";
17
- import { appScopedResourceLabel, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
17
+ import { appScopedResourceLabel, collisionLabelSuffixes, expr, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
18
18
  import { resolveForeignRef } from "../shared/foreign-ref.js";
19
+ import { assertUniqueToolAddresses, toolName } from "../agent-tool/to-tf.js";
19
20
  import { skillToolToTf } from "../skill-tool/to-tf.js";
21
+ import { SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY } from "../skill-tool/types.js";
20
22
  import { APP_RESOURCE_TYPE } from "../app/module.js";
21
23
  import { SERVICE_ACCOUNT_RESOURCE_TYPE } from "../service-account/module.js";
22
24
  import { analyzeSkillInputCoverage, coverageToolsFromWire, skillCoverageGapDiagnostics, skillCoverageReportLines, } from "./input-coverage.js";
@@ -47,22 +49,25 @@ function toSortableSkills(entities) {
47
49
  }
48
50
  return out;
49
51
  }
50
- /** Return deterministic suffixes for duplicate tool names within one skill. */
52
+ /**
53
+ * `_N` suffixes for each skill's tools whose labels collide, keyed
54
+ * `<refName>#<index>`, one counter per skill across tool kinds, as ei's
55
+ * export (`generateAppSkillImportBlocks`) counts known tool kinds. A tool with
56
+ * `labelSuffix` keeps that `_N`; the others take the lowest free count in tool
57
+ * order (`collisionLabelSuffixes`). Pull pins every tool ei suffixed
58
+ * (skillFromTf), so a pulled skill rebuilds its exported labels.
59
+ */
51
60
  export function computeToolLabelSuffixes(siblingSkills) {
52
- const counts = new Map();
53
61
  const suffixes = new Map();
54
62
  for (const skill of toSortableSkills(siblingSkills)) {
55
- skill.tools.forEach((entry, index) => {
63
+ const perTool = collisionLabelSuffixes(skill.tools.map((entry) => {
56
64
  const typeKey = Object.keys(entry)[0];
57
- if (typeKey === undefined)
58
- return;
65
+ if (typeKey === undefined || !SKILL_TOOL_SUB_TYPE_BY_TYPE_KEY.has(typeKey))
66
+ return undefined;
59
67
  const inner = entry[typeKey];
60
- const base = sanitizeName(inner?.name ?? "");
61
- const key = `${skill.refName}\0${base}`;
62
- const count = counts.get(key) ?? 0;
63
- counts.set(key, count + 1);
64
- suffixes.set(`${skill.refName}#${index}`, count > 0 ? `_${count}` : "");
65
- });
68
+ return { base: sanitizeName(inner?.name ?? ""), ...(inner?.labelSuffix !== undefined && { pinned: inner.labelSuffix }) };
69
+ }));
70
+ perTool.forEach((suffix, index) => suffixes.set(`${skill.refName}#${index}`, suffix));
66
71
  }
67
72
  return suffixes;
68
73
  }
@@ -115,6 +120,7 @@ export function skillToTf(entity, ctx) {
115
120
  if (discovery?.negativeKeywords !== undefined)
116
121
  attrs["negative_keywords"] = [...discovery.negativeKeywords];
117
122
  const toolLabelSuffixes = computeToolLabelSuffixes(ctx.siblingEntities ?? [entity]);
123
+ const toolAddresses = [];
118
124
  const blocks = [{ kind: "resource", type: SKILL_RESOURCE_TYPE, label: tfLabel, attrs }];
119
125
  (payload.tools ?? []).forEach((entry, index) => {
120
126
  const tool = skillToolToTf(entry, {
@@ -173,8 +179,11 @@ export function skillToTf(entity, ctx) {
173
179
  },
174
180
  diagnostics: ctx.diagnostics,
175
181
  });
176
- if (tool !== undefined)
177
- blocks.push(tool.block);
182
+ if (tool === undefined)
183
+ return;
184
+ toolAddresses.push({ name: toolName(entry), address: tool.address });
185
+ blocks.push(tool.block);
178
186
  });
187
+ assertUniqueToolAddresses(`skill "${name}" (${SKILL_RESOURCE_TYPE}.${tfLabel})`, toolAddresses);
179
188
  return { blocks, address: `${SKILL_RESOURCE_TYPE}.${tfLabel}` };
180
189
  }
@@ -92,6 +92,14 @@ interface CommonToolOptions {
92
92
  readonly status?: SkillToolStatus;
93
93
  readonly startMessage?: string;
94
94
  readonly runAs?: AgentToolRunAs;
95
+ /**
96
+ * Pins the `_N` on this tool's terraform label, for a tool whose name shares
97
+ * a label with others (`a-b`, `a_b`, `aB`). Pull writes it when ei's export
98
+ * gave the tool a suffix; keep it, or the tool's address changes. Without
99
+ * it, a colliding tool takes the lowest free `_N` in tool order. Never sent
100
+ * to the platform. A whole number from 1 to `Number.MAX_SAFE_INTEGER`.
101
+ */
102
+ readonly labelSuffix?: number;
95
103
  }
96
104
  export type SkillAutomationInputs<T> = [keyof T] extends [never] ? {
97
105
  readonly [key: string]: never;
@@ -27,11 +27,15 @@ function common(opts) {
27
27
  // every tool factory routes through here, so this is the single
28
28
  // enforcement point; the tf passes never re-check.
29
29
  if (!isValidToolName(opts.name)) {
30
- throw new Error(`skill tool name "${opts.name}" must be 1–64 characters of letters, digits, and ` +
31
- `underscores (A–Z, a–z, 0–9, _) with no consecutive underscores — no hyphens or spaces.`);
30
+ throw new Error(`skill tool name "${opts.name}" must be 1–64 characters of letters, digits, underscores, ` +
31
+ `and hyphens (A–Z, a–z, 0–9, _, -) with no consecutive underscores — no spaces.`);
32
+ }
33
+ if (opts.labelSuffix !== undefined && (!Number.isSafeInteger(opts.labelSuffix) || opts.labelSuffix < 1)) {
34
+ throw new Error(`skill tool "${opts.name}" labelSuffix must be a whole number from 1 to Number.MAX_SAFE_INTEGER; got ${String(opts.labelSuffix)}.`);
32
35
  }
33
36
  return {
34
37
  name: opts.name,
38
+ ...(opts.labelSuffix !== undefined ? { labelSuffix: opts.labelSuffix } : {}),
35
39
  description: opts.description,
36
40
  status: opts.status ?? "ACTIVE",
37
41
  ...(opts.startMessage !== undefined ? { startMessage: opts.startMessage } : {}),
@@ -70,6 +70,8 @@ export interface NormalizedSkillTool {
70
70
  /** Present only when it differs from the default ("ACTIVE"). */
71
71
  readonly status?: "INACTIVE";
72
72
  readonly startMessage?: string;
73
+ /** The `_N` ei gave this tool's label (edk#1987); see the builders' `labelSuffix`. */
74
+ readonly labelSuffix?: number;
73
75
  readonly target?: NormalizedSkillToolTarget;
74
76
  readonly fields?: readonly NormalizedSkillToolField[];
75
77
  readonly filterVariables?: readonly NormalizedFilterVariable[];
@@ -59,4 +59,12 @@ export interface SkillToolToTfResult {
59
59
  /** `<resourceType>.<tfLabel>` — bookkeeping for the skill catalog. */
60
60
  readonly address: string;
61
61
  }
62
+ /**
63
+ * One authored tool entry (`{ createRecord: {...} }`) → its resource block;
64
+ * undefined = degraded with a diagnostic (unimplemented sub-type, missing
65
+ * target). Tool-name validity is enforced in the authoring builders
66
+ * (entities/skill/tools.ts), not here.
67
+ */
68
+ /** A skill tool's bare label: `<skill>_<sanitizeName(tool name)>` plus its collision suffix. */
69
+ export declare function skillToolBareLabel(skillBareTfLabel: string, toolName: string, labelSuffix: string): string;
62
70
  export declare function skillToolToTf(entry: Record<string, unknown>, ctx: SkillToolToTfContext): SkillToolToTfResult | undefined;
@@ -8,7 +8,7 @@
8
8
  */
9
9
  import { typedCoverageGap } from "../../engine/coverage-gaps.js";
10
10
  import { workspaceAspectKey } from "../../engine/build/context.js";
11
- import { automationRunTargetResourceAttr } from "../automation/to-tf.js";
11
+ import { automationRunTargetResourceAttr } from "../automation/run-target.js";
12
12
  import { appScopedResourceLabel, childPartFromScopedLabel, expr, sanitizeName, scopedResourceLabel, stableIdSuffix, tsLabelToTfLabel } from "../../engine/tf/index.js";
13
13
  import { authoredFieldKeysFromPayload, fieldRefToTfValue, } from "../field/to-tf.js";
14
14
  import { foreignFieldDataLabel } from "../shared/foreign-ref.js";
@@ -146,6 +146,10 @@ function fieldRefValue(token, where, ctx, target) {
146
146
  * target). Tool-name validity is enforced in the authoring builders
147
147
  * (entities/skill/tools.ts), not here.
148
148
  */
149
+ /** A skill tool's bare label: `<skill>_<sanitizeName(tool name)>` plus its collision suffix. */
150
+ export function skillToolBareLabel(skillBareTfLabel, toolName, labelSuffix) {
151
+ return `${skillBareTfLabel}_${sanitizeName(toolName)}${labelSuffix}`;
152
+ }
149
153
  /**
150
154
  * A whole skill tool the build cannot emit (edk#1480): the site states the
151
155
  * consequence itself instead of leaving it to the generic "dropped" wording.
@@ -179,7 +183,7 @@ export function skillToolToTf(entry, ctx) {
179
183
  }
180
184
  const where = `skill tool "${name}"`;
181
185
  const skillBareTfLabel = ctx.skillBareTfLabel ?? childPartFromScopedLabel(ctx.appTfLabel, ctx.skillTfLabel, "app");
182
- const tfLabel = appScopedResourceLabel(ctx.appTfLabel, `${skillBareTfLabel}_${sanitizeName(name)}${ctx.labelSuffix ?? ""}`);
186
+ const tfLabel = appScopedResourceLabel(ctx.appTfLabel, skillToolBareLabel(skillBareTfLabel, name, ctx.labelSuffix ?? ""));
183
187
  const attrs = {
184
188
  skill_id: expr.resourceAttr("elementum_agentic_skill", ctx.skillTfLabel, ["id"]),
185
189
  app_id: expr.resourceAttr("elementum_app", ctx.appTfLabel, ["id"]),
@@ -3,8 +3,9 @@
3
3
  * `elementum_agent_view.layout` → `agentViews.<key>.layout`;
4
4
  * `elementum_custom_view.layout` → `customViews.<key>.layout` (see
5
5
  * `viewBlocksFromTf`). References become typed markers at the per-block id
6
- * positions, inside nested filters and inside actions; raw platform ids there
7
- * become `unsafePlatformId(...)`. A layout this cannot represent makes the
6
+ * positions, inside nested filters and inside actions; a raw platform id there
7
+ * becomes the owner's field ref when it names one of its fields (#2155), else
8
+ * `unsafePlatformId(...)`. A layout this cannot represent makes the
8
9
  * whole view unmanaged (skipped), never silently dropped: the code owns the
9
10
  * layout, so a dropped detail would be cleared on the next apply.
10
11
  */
@@ -61,6 +62,13 @@ export interface AgentViewLayoutFromTfOptions {
61
62
  readonly isOwnApp: (value: TfValue) => boolean;
62
63
  /** Resolves a field reference to its bag key, a system field key, or a raw id. */
63
64
  readonly fieldKey: (value: TfValue) => string | undefined;
65
+ /**
66
+ * The key of the owner's own extracted field (or, with `systemKeys`, system
67
+ * field) a raw platform id names (#2155). Undefined for any other id.
68
+ */
69
+ readonly ownFieldKey?: (id: string, systemKeys: boolean) => string | undefined;
70
+ /** Sees a raw platform id in a field position, which pulls as is (#1736 records the ones naming unextracted fields). */
71
+ readonly noteRawFieldId?: (id: string) => void;
64
72
  /** Resolves another app's or element's data lookup. */
65
73
  readonly foreignSource?: (value: TfValue) => ViewBlocksSourceMarker | undefined;
66
74
  /** Resolves the data lookup of another app's or element's field. */
@@ -3,8 +3,9 @@
3
3
  * `elementum_agent_view.layout` → `agentViews.<key>.layout`;
4
4
  * `elementum_custom_view.layout` → `customViews.<key>.layout` (see
5
5
  * `viewBlocksFromTf`). References become typed markers at the per-block id
6
- * positions, inside nested filters and inside actions; raw platform ids there
7
- * become `unsafePlatformId(...)`. A layout this cannot represent makes the
6
+ * positions, inside nested filters and inside actions; a raw platform id there
7
+ * becomes the owner's field ref when it names one of its fields (#2155), else
8
+ * `unsafePlatformId(...)`. A layout this cannot represent makes the
8
9
  * whole view unmanaged (skipped), never silently dropped: the code owns the
9
10
  * layout, so a dropped detail would be cleared on the next apply.
10
11
  */
@@ -152,8 +153,9 @@ function deepRefs(value, where, opts) {
152
153
  if (isTfExpr(value)) {
153
154
  return sourceRef(value, opts) ?? fieldMarker(value, where, opts);
154
155
  }
156
+ // A system key here would build as a plain string, not the field's id.
155
157
  if (isPlatformId(value))
156
- return unsafe(value);
158
+ return rawFieldIdMarker(value, false, opts);
157
159
  if (Array.isArray(value))
158
160
  return value.map((item, i) => deepRefs(item, `${where}[${i}]`, opts));
159
161
  const rec = plain(value);
@@ -202,7 +204,7 @@ function sourceRef(value, opts) {
202
204
  }
203
205
  function fieldMarker(value, where, opts) {
204
206
  if (typeof value === "string")
205
- return unsafe(value);
207
+ return rawFieldIdMarker(value, true, opts);
206
208
  // Checked first: the owner's resolver reports a foreign lookup as unknown.
207
209
  const foreign = opts.foreignField?.(value);
208
210
  if (foreign !== undefined)
@@ -212,6 +214,18 @@ function fieldMarker(value, where, opts) {
212
214
  throw new Unrepresentable(`${where} references a field the EDK cannot represent here`);
213
215
  return PLATFORM_ID.test(key) ? unsafe(key) : { __specRef: "field", key };
214
216
  }
217
+ /**
218
+ * A raw id at a field position: the owner's own field's ref when the id names
219
+ * one (#2155), else unsafePlatformId(...). The export keeps a system field's
220
+ * id raw, and an own field's whenever it can't name its resource.
221
+ */
222
+ function rawFieldIdMarker(id, systemKeys, opts) {
223
+ const key = opts.ownFieldKey?.(id, systemKeys);
224
+ if (key !== undefined)
225
+ return { __specRef: "field", key };
226
+ opts.noteRawFieldId?.(id);
227
+ return unsafe(id);
228
+ }
215
229
  /** Plain JSON outside the id positions: any reference here is unrepresentable. */
216
230
  function literal(value, where) {
217
231
  if (isTfExpr(value))
@@ -65,11 +65,12 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
65
65
  const rootType = isObj(rootEl) && typeof rootEl["type"] === "string" ? rootEl["type"] : "";
66
66
  // check.mjs warns on any non-PanesBlock root. We error only when a live list
67
67
  // needs the details pane — chart/StackBlock dashboards without lists stay valid.
68
+ // A null aspectId (or repeat, below) counts as absent, as in the Go provider (#1784).
68
69
  const hasLiveList = Object.values(elements).some((raw) => {
69
70
  if (!isObj(raw) || !isObj(raw["props"]))
70
71
  return false;
71
72
  const t = raw["type"];
72
- return typeof t === "string" && LIST_BLOCKS.has(t) && raw["props"]["aspectId"] !== undefined;
73
+ return typeof t === "string" && LIST_BLOCKS.has(t) && raw["props"]["aspectId"] != null;
73
74
  });
74
75
  if (hasLiveList && rootType !== "PanesBlock") {
75
76
  note(`${where}.root`, `"${root}" must be a PanesBlock (got ${rootType === "" ? "no type" : `"${rootType}"`}); a live list needs a panes root so rows can open the details panel`);
@@ -101,7 +102,7 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
101
102
  if (children.length > 0 && !CONTAINERS.has(raw["type"])) {
102
103
  note(elWhere, `${raw["type"]} does not render children; only ${[...CONTAINERS].join(", ")} do`);
103
104
  }
104
- if (raw["repeat"] !== undefined && children.length === 0) {
105
+ if (raw["repeat"] != null && children.length === 0) {
105
106
  note(`${elWhere}.repeat`, "a repeated element needs a child element as its template; the page will fail to render this custom view");
106
107
  }
107
108
  for (const child of children) {
@@ -114,7 +115,7 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
114
115
  }
115
116
  }
116
117
  }
117
- else if (raw["repeat"] !== undefined) {
118
+ else if (raw["repeat"] != null) {
118
119
  note(`${elWhere}.repeat`, "a repeated element needs a child element as its template; the page will fail to render this custom view");
119
120
  }
120
121
  }
@@ -239,7 +240,7 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
239
240
  // Live lists on a custom view need all three selection bindings as $state /
240
241
  // $bindState so the details pane opens. $item / $index do not count.
241
242
  // Warn-only: pulled Blueprint layouts omit these and must still build.
242
- if (LIST_BLOCKS.has(type) && props["aspectId"] !== undefined) {
243
+ if (LIST_BLOCKS.has(type) && props["aspectId"] != null) {
243
244
  const missing = SELECTION_KEYS.filter((key) => !isStateBinding(props[key]));
244
245
  if (missing.length > 0) {
245
246
  warn(elWhere, `live list without selectedId/selectedAspectId/selectedHandle bindings; rows will not open the details pane (missing or not $state/$bindState: ${missing.join(", ")})`);
@@ -257,7 +258,7 @@ function throwIf(problems) {
257
258
  export function reportStructureProblems(_root, elements, where, diagnostics) {
258
259
  for (const [id, raw] of Object.entries(elements)) {
259
260
  const children = isObj(raw) ? raw["children"] : undefined;
260
- if (isObj(raw) && raw["repeat"] !== undefined && (!Array.isArray(children) || children.length === 0)) {
261
+ if (isObj(raw) && raw["repeat"] != null && (!Array.isArray(children) || children.length === 0)) {
261
262
  diagnostics.push(`${where}.elements.${id}.repeat: a repeated element needs a child element as its template; the page will fail to render this custom view`);
262
263
  }
263
264
  if (!Array.isArray(children))
@@ -23,7 +23,27 @@ export interface ViewOwner {
23
23
  readonly stageKeys?: ReadonlySet<string>;
24
24
  /** The owning app's stage handles → real stage keys (see `stageKeyByHandle`, #1136). */
25
25
  readonly stageKeyByHandle?: ReadonlyMap<string, string>;
26
+ /**
27
+ * Keys of the fields pull extracted for this owner. A field reference whose
28
+ * field is not among them keeps its platform id instead of a key that
29
+ * builds as nothing (#1736). Undefined when the caller does not know.
30
+ */
31
+ readonly fieldKeys?: ReadonlySet<string>;
32
+ /**
33
+ * The extracted fields' keys by display name (lower case); null for a name
34
+ * two fields share. A data source names its field by display name, so
35
+ * this is how an own-app `data.elementum_field` resolves (#1991).
36
+ */
37
+ readonly fieldKeysByName?: ReadonlyMap<string, string | null>;
38
+ /** Collects the platform ids kept for unextracted fields, so print can say they are intentional. */
39
+ readonly unextractedFieldIds?: Set<string>;
26
40
  }
41
+ /**
42
+ * What the #1736 unextracted-field fallback reads from an owner. Record create
43
+ * forms, relationships, dynamic layouts and widgets pass one of these too, so
44
+ * their field references keep the same platform id (#1966).
45
+ */
46
+ export type UnextractedFieldOwner = Pick<ViewOwner, "type" | "label" | "ownerTfLabel" | "scope" | "fieldKeys" | "fieldKeysByName" | "unextractedFieldIds">;
27
47
  export interface ViewsFromTfResult {
28
48
  readonly layouts: readonly NormalizedLayout[];
29
49
  readonly listViews: readonly NormalizedListView[];
@@ -33,7 +53,55 @@ export interface ViewsFromTfResult {
33
53
  readonly agentViews: readonly NormalizedAgentView[];
34
54
  readonly customViews: readonly NormalizedCustomView[];
35
55
  readonly viewOrder?: readonly string[];
56
+ readonly deleteDefaultListView?: boolean;
36
57
  }
37
58
  /** All three view resource kinds → the normalized shapes the app printer consumes. */
38
59
  export declare function viewsFromTf(layoutBlocks: readonly TfBlock[], listViewBlocks: readonly TfBlock[], calendarViewBlocks: readonly TfBlock[], kanbanViewBlocks: readonly TfBlock[], dashboardViewBlocks: readonly TfBlock[], agentViewBlocks: readonly TfBlock[], managedViewOrderBlocks: readonly TfBlock[], owner: ViewOwner, ctx: FromTfContext, customViewBlocks?: readonly TfBlock[]): ViewsFromTfResult;
60
+ /**
61
+ * `ViewOwner.fieldKeysByName` from the extracted fields: lower-cased display
62
+ * name → key, or null for a name two fields share (it names neither).
63
+ */
64
+ export declare function fieldKeysByDisplayName(fields: readonly {
65
+ readonly key: string;
66
+ readonly field: {
67
+ readonly name: string;
68
+ };
69
+ }[]): ReadonlyMap<string, string | null>;
70
+ /**
71
+ * `ownDataFieldRef` for a caller outside this module (a widget column, a
72
+ * relationship's related field on its own app): the key to author, or
73
+ * "failedClosed" once the blocker naming `site` is recorded. Undefined when
74
+ * `v` is not an own-app data source lookup; the caller's handling stands.
75
+ */
76
+ export declare function resolveOwnDataFieldRef(v: TfValue | undefined, owner: UnextractedFieldOwner, ctx: FromTfContext, site: string): {
77
+ readonly key: string;
78
+ } | "failedClosed" | undefined;
79
+ /**
80
+ * The value to author for a field reference outside views (#1966):
81
+ * `fieldKey` is what the caller resolved the reference to, if anything. A
82
+ * field pull did not extract keeps its platform id; otherwise the caller's
83
+ * key stands. Undefined when nothing resolves, or when this reference failed
84
+ * closed: no id is known, which fails the pull with an authoring blocker
85
+ * naming `site`, which must start with the holding resource's address (#1978).
86
+ * The result never depends on another reference's blocker at the same site.
87
+ * Clone drops import blocks, so it keeps the export's dropped id only for
88
+ * another owner's field and fails the same way for any other (#1990). A kept
89
+ * id is reported once per field, naming every site.
90
+ */
91
+ export declare function unextractedFieldRefId(v: TfValue, fieldKey: string | undefined, owner: UnextractedFieldOwner, ctx: FromTfContext, site: string): string | undefined;
92
+ /**
93
+ * A bare platform-id field reference on another owner's side: a widget column
94
+ * whose target is another app or element, or a relationship's related field
95
+ * (#1991). `foreignOwner` names that owner when it is not this one, so the id
96
+ * is its field and keeps its platform id (Dax, 11:45). An id the export
97
+ * imports is checked through its field block instead: in a clone, a field of
98
+ * the source app fails and another owner's keeps its id (#1990); in pull, it
99
+ * is the platform's own and stays as is. With no foreign owner and no import,
100
+ * it fails like `bareFieldIdRef`, naming `site` and the id.
101
+ */
102
+ export declare function bareForeignFieldIdRef(v: string, owner: UnextractedFieldOwner, ctx: FromTfContext, site: string, foreignOwner: string | undefined): string | undefined;
103
+ /** Whether `v` is a bare platform id, the shape an export writes for a field it can't name (#1991). */
104
+ export declare function isBarePlatformId(v: string): boolean;
105
+ /** Whether `fieldKey` names a field of this owner that pull did not extract (system keys never count). */
106
+ export declare function isUnextractedFieldKey(fieldKey: string, owner: UnextractedFieldOwner): boolean;
39
107
  export declare function managedViewSortFromTf(value: TfValue | undefined, owner: ViewOwner, where: string, ctx: FromTfContext): NormalizedManagedViewSort | undefined;