@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.
Files changed (224) hide show
  1. package/README.md +8 -2
  2. package/dist-sdk/src/catalog/factories.d.ts +7 -1
  3. package/dist-sdk/src/catalog/factories.js +10 -2
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +1 -1
  6. package/dist-sdk/src/catalog/org.js +79 -34
  7. package/dist-sdk/src/catalog/token.js +5 -0
  8. package/dist-sdk/src/catalog/types.d.ts +12 -1
  9. package/dist-sdk/src/catalog/types.js +3 -0
  10. package/dist-sdk/src/core/system-fields.d.ts +1 -1
  11. package/dist-sdk/src/core/system-fields.js +1 -1
  12. package/dist-sdk/src/core/types/app.d.ts +6 -0
  13. package/dist-sdk/src/engine/build/context.d.ts +3 -0
  14. package/dist-sdk/src/engine/coverage-gaps.d.ts +2 -0
  15. package/dist-sdk/src/engine/coverage-gaps.js +4 -0
  16. package/dist-sdk/src/engine/ei/run.d.ts +8 -0
  17. package/dist-sdk/src/engine/ei/run.js +46 -7
  18. package/dist-sdk/src/engine/pull/authored-address.js +42 -6
  19. package/dist-sdk/src/engine/pull/authored-root.d.ts +88 -0
  20. package/dist-sdk/src/engine/pull/authored-root.js +306 -0
  21. package/dist-sdk/src/engine/pull/context.d.ts +34 -0
  22. package/dist-sdk/src/engine/pull/field-refs-registry.d.ts +114 -0
  23. package/dist-sdk/src/engine/pull/field-refs-registry.js +501 -0
  24. package/dist-sdk/src/engine/pull/org.d.ts +1 -0
  25. package/dist-sdk/src/engine/pull/org.js +2 -0
  26. package/dist-sdk/src/engine/pull/partition.d.ts +8 -0
  27. package/dist-sdk/src/engine/pull/partition.js +43 -0
  28. package/dist-sdk/src/engine/pull/pulled-roots.d.ts +89 -0
  29. package/dist-sdk/src/engine/pull/pulled-roots.js +203 -0
  30. package/dist-sdk/src/engine/pull/ref-only.d.ts +4 -0
  31. package/dist-sdk/src/engine/pull/ref-only.js +7 -1
  32. package/dist-sdk/src/engine/pull/source-resources.d.ts +39 -0
  33. package/dist-sdk/src/engine/pull/source-resources.js +110 -0
  34. package/dist-sdk/src/engine/pull/stream-root.d.ts +159 -0
  35. package/dist-sdk/src/engine/pull/stream-root.js +579 -0
  36. package/dist-sdk/src/engine/workspace/authoring-layout.js +16 -2
  37. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.d.ts +47 -0
  38. package/dist-sdk/src/engine/workspace/reserved-catalog-keys.js +115 -0
  39. package/dist-sdk/src/entities/access-policy/build.d.ts +2 -1
  40. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +7 -0
  41. package/dist-sdk/src/entities/access-policy/from-tf.js +17 -5
  42. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +19 -0
  43. package/dist-sdk/src/entities/access-policy/to-tf.js +65 -8
  44. package/dist-sdk/src/entities/agent/build.d.ts +52 -1
  45. package/dist-sdk/src/entities/agent/build.js +34 -0
  46. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +70 -1
  47. package/dist-sdk/src/entities/agent/from-tf.d.ts +36 -1
  48. package/dist-sdk/src/entities/agent/from-tf.js +289 -2
  49. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  50. package/dist-sdk/src/entities/agent/module.js +1 -0
  51. package/dist-sdk/src/entities/agent/to-tf.d.ts +11 -11
  52. package/dist-sdk/src/entities/agent/to-tf.js +179 -17
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +6 -0
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -2
  56. package/dist-sdk/src/entities/app/build.d.ts +33 -13
  57. package/dist-sdk/src/entities/app/build.js +14 -12
  58. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -0
  59. package/dist-sdk/src/entities/app/from-tf.js +7 -9
  60. package/dist-sdk/src/entities/app/index.d.ts +1 -0
  61. package/dist-sdk/src/entities/app/index.js +1 -0
  62. package/dist-sdk/src/entities/app/module.js +3 -0
  63. package/dist-sdk/src/entities/app/stage-keys.d.ts +2 -2
  64. package/dist-sdk/src/entities/app/stage-keys.js +3 -3
  65. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  66. package/dist-sdk/src/entities/approval-chain/build.d.ts +46 -11
  67. package/dist-sdk/src/entities/approval-chain/build.js +120 -8
  68. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +24 -2
  69. package/dist-sdk/src/entities/approval-chain/from-tf.js +148 -6
  70. package/dist-sdk/src/entities/approval-chain/index.d.ts +4 -1
  71. package/dist-sdk/src/entities/approval-chain/index.js +4 -1
  72. package/dist-sdk/src/entities/approval-chain/module.js +23 -5
  73. package/dist-sdk/src/entities/approval-chain/printer.d.ts +1 -1
  74. package/dist-sdk/src/entities/approval-chain/printer.js +91 -5
  75. package/dist-sdk/src/entities/approval-chain/steps-tf.d.ts +77 -0
  76. package/dist-sdk/src/entities/approval-chain/steps-tf.js +255 -0
  77. package/dist-sdk/src/entities/approval-chain/steps.d.ts +71 -0
  78. package/dist-sdk/src/entities/approval-chain/steps.js +83 -0
  79. package/dist-sdk/src/entities/approval-chain/to-tf.d.ts +16 -6
  80. package/dist-sdk/src/entities/approval-chain/to-tf.js +37 -4
  81. package/dist-sdk/src/entities/automation/build.d.ts +10 -1
  82. package/dist-sdk/src/entities/automation/build.js +70 -27
  83. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +21 -5
  84. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -5
  85. package/dist-sdk/src/entities/automation/from-tf.js +665 -112
  86. package/dist-sdk/src/entities/automation/index.d.ts +2 -1
  87. package/dist-sdk/src/entities/automation/index.js +1 -0
  88. package/dist-sdk/src/entities/automation/module.d.ts +4 -3
  89. package/dist-sdk/src/entities/automation/module.js +45 -12
  90. package/dist-sdk/src/entities/automation/refs-read.d.ts +19 -0
  91. package/dist-sdk/src/entities/automation/refs-read.js +48 -0
  92. package/dist-sdk/src/entities/automation/slack-message-refs.d.ts +9 -0
  93. package/dist-sdk/src/entities/automation/slack-message-refs.js +75 -0
  94. package/dist-sdk/src/entities/automation/system-ref-name.d.ts +23 -3
  95. package/dist-sdk/src/entities/automation/system-ref-name.js +86 -4
  96. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +11 -0
  97. package/dist-sdk/src/entities/automation/task-output-labels.js +23 -0
  98. package/dist-sdk/src/entities/automation/tasks.d.ts +29 -4
  99. package/dist-sdk/src/entities/automation/tasks.js +34 -11
  100. package/dist-sdk/src/entities/automation/to-tf.d.ts +8 -1
  101. package/dist-sdk/src/entities/automation/to-tf.js +563 -103
  102. package/dist-sdk/src/entities/automation/triggers.d.ts +0 -8
  103. package/dist-sdk/src/entities/automation/triggers.js +26 -11
  104. package/dist-sdk/src/entities/automation/unsafe-script-output.d.ts +50 -0
  105. package/dist-sdk/src/entities/automation/unsafe-script-output.js +92 -0
  106. package/dist-sdk/src/entities/chart/build.d.ts +9 -1
  107. package/dist-sdk/src/entities/chart/from-tf.js +3 -0
  108. package/dist-sdk/src/entities/chart/to-tf.js +19 -2
  109. package/dist-sdk/src/entities/dashboard/from-tf.d.ts +3 -1
  110. package/dist-sdk/src/entities/dashboard/from-tf.js +42 -2
  111. package/dist-sdk/src/entities/dashboard/to-tf.js +9 -1
  112. package/dist-sdk/src/entities/dashboard-widget-order/module.d.ts +10 -0
  113. package/dist-sdk/src/entities/dashboard-widget-order/module.js +25 -0
  114. package/dist-sdk/src/entities/dashboard-widget-order/order.d.ts +31 -0
  115. package/dist-sdk/src/entities/dashboard-widget-order/order.js +102 -0
  116. package/dist-sdk/src/entities/dynamic-layout/build.d.ts +2 -0
  117. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +44 -5
  118. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +46 -12
  119. package/dist-sdk/src/entities/element/audit-field-guard.d.ts +9 -0
  120. package/dist-sdk/src/entities/element/audit-field-guard.js +88 -0
  121. package/dist-sdk/src/entities/element/build.js +2 -1
  122. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -0
  123. package/dist-sdk/src/entities/element/from-tf.js +4 -7
  124. package/dist-sdk/src/entities/element/module.js +5 -0
  125. package/dist-sdk/src/entities/element/system-fields.d.ts +13 -0
  126. package/dist-sdk/src/entities/element/system-fields.js +23 -0
  127. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  128. package/dist-sdk/src/entities/field/build.d.ts +9 -0
  129. package/dist-sdk/src/entities/field/from-tf.d.ts +52 -1
  130. package/dist-sdk/src/entities/field/from-tf.js +212 -14
  131. package/dist-sdk/src/entities/field/module.js +4 -0
  132. package/dist-sdk/src/entities/field/to-tf.d.ts +5 -1
  133. package/dist-sdk/src/entities/field/to-tf.js +33 -12
  134. package/dist-sdk/src/entities/org/category.js +1 -0
  135. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  136. package/dist-sdk/src/entities/org/index.js +1 -0
  137. package/dist-sdk/src/entities/org/voice-auth.d.ts +5 -0
  138. package/dist-sdk/src/entities/org/voice-auth.js +33 -0
  139. package/dist-sdk/src/entities/organization/build.d.ts +3 -0
  140. package/dist-sdk/src/entities/organization/build.js +2 -0
  141. package/dist-sdk/src/entities/organization/index.d.ts +1 -0
  142. package/dist-sdk/src/entities/organization/index.js +1 -0
  143. package/dist-sdk/src/entities/organization/to-tf.d.ts +2 -0
  144. package/dist-sdk/src/entities/organization/to-tf.js +59 -1
  145. package/dist-sdk/src/entities/organization/voice-auth.d.ts +60 -0
  146. package/dist-sdk/src/entities/organization/voice-auth.js +60 -0
  147. package/dist-sdk/src/entities/phone-service/build.d.ts +9 -1
  148. package/dist-sdk/src/entities/phone-service/build.js +1 -0
  149. package/dist-sdk/src/entities/phone-service/deserializer/print-phone-service.js +3 -0
  150. package/dist-sdk/src/entities/phone-service/from-tf.d.ts +1 -0
  151. package/dist-sdk/src/entities/phone-service/from-tf.js +8 -1
  152. package/dist-sdk/src/entities/phone-service/to-tf.js +16 -0
  153. package/dist-sdk/src/entities/record-create-form/from-tf.js +2 -2
  154. package/dist-sdk/src/entities/relationship/from-tf.js +9 -4
  155. package/dist-sdk/src/entities/relationship/module.js +2 -2
  156. package/dist-sdk/src/entities/relationship/pair-check.d.ts +6 -2
  157. package/dist-sdk/src/entities/relationship/pair-check.js +105 -18
  158. package/dist-sdk/src/entities/relationship/to-tf.js +5 -2
  159. package/dist-sdk/src/entities/role/build.d.ts +3 -4
  160. package/dist-sdk/src/entities/role/permission-levels.d.ts +7 -0
  161. package/dist-sdk/src/entities/role/permission-levels.js +78 -0
  162. package/dist-sdk/src/entities/role/to-tf.js +32 -2
  163. package/dist-sdk/src/entities/search-table/build.d.ts +9 -3
  164. package/dist-sdk/src/entities/search-table/build.js +4 -4
  165. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  166. package/dist-sdk/src/entities/search-table/to-tf.js +20 -2
  167. package/dist-sdk/src/entities/service-account/module.d.ts +2 -1
  168. package/dist-sdk/src/entities/service-account/module.js +4 -1
  169. package/dist-sdk/src/entities/service-account/resource-type.d.ts +2 -0
  170. package/dist-sdk/src/entities/service-account/resource-type.js +2 -0
  171. package/dist-sdk/src/entities/service-account/role-membership-check.d.ts +20 -0
  172. package/dist-sdk/src/entities/service-account/role-membership-check.js +80 -0
  173. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +15 -0
  174. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +36 -0
  175. package/dist-sdk/src/entities/shared/context.d.ts +14 -1
  176. package/dist-sdk/src/entities/shared/filters/ast.d.ts +2 -0
  177. package/dist-sdk/src/entities/shared/filters/index.d.ts +97 -15
  178. package/dist-sdk/src/entities/shared/filters/index.js +30 -7
  179. package/dist-sdk/src/entities/shared/filters/option-lookups.d.ts +57 -0
  180. package/dist-sdk/src/entities/shared/filters/option-lookups.js +108 -0
  181. package/dist-sdk/src/entities/shared/filters/print.d.ts +2 -0
  182. package/dist-sdk/src/entities/shared/filters/print.js +19 -6
  183. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +16 -7
  184. package/dist-sdk/src/entities/shared/filters/tf-codec.js +25 -5
  185. package/dist-sdk/src/entities/shared/filters/types.d.ts +4 -0
  186. package/dist-sdk/src/entities/shared/raw-option-id.d.ts +30 -0
  187. package/dist-sdk/src/entities/shared/raw-option-id.js +41 -0
  188. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  189. package/dist-sdk/src/entities/shared/tool-field-ref.js +3 -2
  190. package/dist-sdk/src/entities/skill/input-coverage.js +5 -2
  191. package/dist-sdk/src/entities/sla/build.d.ts +96 -0
  192. package/dist-sdk/src/entities/sla/build.js +124 -0
  193. package/dist-sdk/src/entities/sla/from-tf.d.ts +40 -0
  194. package/dist-sdk/src/entities/sla/from-tf.js +164 -0
  195. package/dist-sdk/src/entities/sla/index.d.ts +1 -0
  196. package/dist-sdk/src/entities/sla/index.js +1 -0
  197. package/dist-sdk/src/entities/sla/module.d.ts +4 -0
  198. package/dist-sdk/src/entities/sla/module.js +73 -0
  199. package/dist-sdk/src/entities/sla/printer.d.ts +2 -0
  200. package/dist-sdk/src/entities/sla/printer.js +84 -0
  201. package/dist-sdk/src/entities/sla/to-tf.d.ts +12 -0
  202. package/dist-sdk/src/entities/sla/to-tf.js +81 -0
  203. package/dist-sdk/src/entities/table/build.d.ts +7 -2
  204. package/dist-sdk/src/entities/table/build.js +22 -1
  205. package/dist-sdk/src/entities/table/deserializer/normalize.d.ts +4 -1
  206. package/dist-sdk/src/entities/table/from-tf.js +89 -14
  207. package/dist-sdk/src/entities/table/index.d.ts +1 -1
  208. package/dist-sdk/src/entities/table/to-tf.js +41 -2
  209. package/dist-sdk/src/entities/task/from-tf.js +3 -2
  210. package/dist-sdk/src/entities/view/custom-view-validate.d.ts +6 -4
  211. package/dist-sdk/src/entities/view/custom-view-validate.js +36 -18
  212. package/dist-sdk/src/entities/view/from-tf.js +16 -4
  213. package/dist-sdk/src/entities/view/to-tf.js +66 -47
  214. package/dist-sdk/src/entities/visual-flow/module.js +52 -1
  215. package/dist-sdk/src/entities/widget/from-tf.js +19 -8
  216. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +49 -4
  217. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  218. package/dist-sdk/src/graph/index.d.ts +9 -0
  219. package/dist-sdk/src/graph/index.js +8 -0
  220. package/dist-sdk/src/graph/modules.js +13 -1
  221. package/dist-sdk/src/graph/resource-types.d.ts +47 -0
  222. package/dist-sdk/src/graph/resource-types.js +62 -0
  223. package/dist-sdk/src/graph/types.d.ts +113 -6
  224. package/package.json +7 -4
@@ -0,0 +1,84 @@
1
+ import { sdkPackageSpecifier } from "../../internal/sdk-package.js";
2
+ import { printFilter } from "../shared/filters/print.js";
3
+ import { safeIdentifier } from "../../internal/safe-identifier.js";
4
+ import { slaTimeUnit, slaWeekDay } from "./build.js";
5
+ import { scopedLabelToBagKey, tsLabelToTfLabel } from "../../engine/tf/index.js";
6
+ const safeKey = (value) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(value) ? value : JSON.stringify(value);
7
+ const timeUnitKey = new Map(Object.entries(slaTimeUnit).map(([key, value]) => [value, key]));
8
+ const weekDayKey = new Map(Object.entries(slaWeekDay).map(([key, value]) => [value, key]));
9
+ const weekDayOrder = Object.values(slaWeekDay);
10
+ /**
11
+ * A value the public constants do not cover prints as an explicit TODO that
12
+ * fails to type-check, so it is never silently replaced with a guess.
13
+ */
14
+ function constant(name, keys, value) {
15
+ const key = keys.get(value);
16
+ return key !== undefined ? `${name}.${key}` : `${JSON.stringify(value)} /* TODO: unsupported ${name} value */`;
17
+ }
18
+ export function printSla(sla, appRefName) {
19
+ const identifier = safeIdentifier(sla.refName, "sla");
20
+ const approvalOwned = sla.approvalProcessTfLabel !== undefined;
21
+ const lines = [
22
+ "/**",
23
+ " * Auto-generated by EDK (v2 pull). Hand-edit freely; the generator is a",
24
+ " * one-shot starting point, not a live-binding view.",
25
+ " */",
26
+ "",
27
+ `import { sla, slaTimeUnit, slaWeekDay${sla.targets.some((target) => target.filter !== undefined) ? ", filter" : ""} } from ${JSON.stringify(sdkPackageSpecifier("app"))};`,
28
+ 'import catalog from "@catalog";',
29
+ "",
30
+ `const ${identifier} = sla({`,
31
+ ...(approvalOwned
32
+ ? [` approvalProcess: catalog.${safeKey(appRefName)}.approvalChains.${safeKey(scopedLabelToBagKey(tsLabelToTfLabel(appRefName), sla.approvalProcessTfLabel, "app"))},`]
33
+ : [` app: catalog.${safeKey(appRefName)},`]),
34
+ ` name: ${JSON.stringify(sla.name)},`,
35
+ ...(sla.description !== undefined ? [` description: ${JSON.stringify(sla.description)},`] : []),
36
+ ...(sla.active ? [] : [" active: false,"]),
37
+ ...(approvalOwned ? [] : [` stages: [${sla.stages.map((stage) => JSON.stringify(stage)).join(", ")}],`]),
38
+ ];
39
+ lines.push(" targets: [");
40
+ for (const target of sla.targets) {
41
+ const days = [...target.workingWeekDays]
42
+ .sort((a, b) => {
43
+ const ai = weekDayOrder.indexOf(a);
44
+ const bi = weekDayOrder.indexOf(b);
45
+ return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi) || a.localeCompare(b);
46
+ })
47
+ .map((day) => constant("slaWeekDay", weekDayKey, day));
48
+ lines.push(" {", ` name: ${JSON.stringify(target.name)},`, ` time: { amount: ${target.timePeriod}, unit: ${constant("slaTimeUnit", timeUnitKey, target.timeUnit)} },`, " workingHours: {", ` days: [${days.join(", ")}],`, ` start: ${JSON.stringify(target.workingStartTime)},`, ` end: ${JSON.stringify(target.workingEndTime)},`, ...(target.workingTimezone !== undefined ? [` timezone: ${JSON.stringify(target.workingTimezone)},`] : []), " },", ...(target.filter !== undefined ? [` filter: ${printSlaFilter(target.filter, appRefName)},`] : []), ...(target.approval !== undefined ? [printApproval(target.approval)] : []), " },");
49
+ }
50
+ lines.push(" ],");
51
+ lines.push("});", "", `export default ${identifier};`, "");
52
+ return lines.join("\n");
53
+ }
54
+ function printSlaFilterField(left, appRefName) {
55
+ if (left.kind === "field") {
56
+ if (left.appHandle === appRefName || left.foreign === undefined) {
57
+ return `catalog.${appRefName}.fields.${left.fieldKey}`;
58
+ }
59
+ return `catalog.${left.appHandle}.fields.${left.fieldKey}`;
60
+ }
61
+ if (left.kind === "unresolved") {
62
+ return `/* TODO: unresolved filter field ${JSON.stringify(left.uuid)} */ undefined as any`;
63
+ }
64
+ return `/* TODO: unexpected filter left-hand side kind ${JSON.stringify(left.kind)} */ undefined as any`;
65
+ }
66
+ function printSlaFilter(filter, appRefName) {
67
+ return printFilter(filter, {
68
+ field: (field) => printSlaFilterField(field, appRefName),
69
+ reference: (reference) => printSlaFilterField(reference, appRefName),
70
+ });
71
+ }
72
+ function printApproval(approval) {
73
+ // entityId must never reach here: from-tf leaves those SLAs unmanaged
74
+ // (raw platform ids are not typed approver/conditional refs yet).
75
+ if (approval.entityId !== undefined) {
76
+ throw new Error("sla printer: approval.entityId is a raw platform id; the SLA should have been left unmanaged");
77
+ }
78
+ const parts = [];
79
+ if (approval.entityType !== undefined)
80
+ parts.push(`entityType: ${JSON.stringify(approval.entityType)}`);
81
+ if (parts.length === 0)
82
+ return " approval: {},";
83
+ return ` approval: { ${parts.join(", ")} },`;
84
+ }
@@ -0,0 +1,12 @@
1
+ import { type DeployableEntity } from "../../engine/entity.js";
2
+ import { type TfBlock } from "../../engine/tf/index.js";
3
+ export declare function slaToTf(entity: DeployableEntity, ctx: {
4
+ readonly appRefName: string;
5
+ readonly appTfLabel: string;
6
+ readonly stageKeyByTfLabel?: ReadonlyMap<string, string>;
7
+ readonly diagnostics?: string[];
8
+ readonly fieldAddresses?: ReadonlyMap<string, string>;
9
+ }): {
10
+ readonly blocks: readonly TfBlock[];
11
+ readonly address: string;
12
+ };
@@ -0,0 +1,81 @@
1
+ import { EntityTfError } from "../../engine/entity.js";
2
+ import { filterToTf } from "../access-policy/to-tf.js";
3
+ import { appScopedResourceLabel, expr, tsLabelToTfLabel } from "../../engine/tf/index.js";
4
+ import { APP_RESOURCE_TYPE } from "../app/module.js";
5
+ import { APPROVAL_PROCESS_RESOURCE_TYPE } from "../approval-chain/module.js";
6
+ import { SLA_RESOURCE_TYPE } from "./module.js";
7
+ export function slaToTf(entity, ctx) {
8
+ if (entity.kind !== "sla")
9
+ throw new EntityTfError(`slaToTf expects kind "sla"; got "${entity.kind}"`);
10
+ const payload = entity.payload;
11
+ if (payload === null)
12
+ throw new EntityTfError(`sla "${entity.refName}" has no payload`);
13
+ const approvalOwned = payload.approvalProcess !== undefined;
14
+ if (approvalOwned) {
15
+ if (payload.approvalProcess?.parent !== ctx.appRefName) {
16
+ throw new EntityTfError(`sla "${entity.refName}" approval process is not under owning app "${ctx.appRefName}"`);
17
+ }
18
+ }
19
+ else if (payload.app?.refName !== ctx.appRefName) {
20
+ throw new EntityTfError(`sla "${entity.refName}" does not reference owning app "${ctx.appRefName}"`);
21
+ }
22
+ const label = appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(entity.refName));
23
+ const attrs = {
24
+ name: payload.name ?? "",
25
+ ...(payload.description !== undefined ? { description: payload.description } : {}),
26
+ active: payload.active ?? true,
27
+ targets: (payload.targets ?? []).map((target, index) => {
28
+ const base = {
29
+ name: target.name ?? "",
30
+ time_period: target.timePeriod ?? 0,
31
+ time_unit: target.timeUnit ?? "",
32
+ working_start_time: target.workingStartTime ?? "",
33
+ working_end_time: target.workingEndTime ?? "",
34
+ ...(target.workingTimezone !== undefined ? { working_timezone: target.workingTimezone } : {}),
35
+ working_week_days: [...(target.workingWeekDays ?? [])],
36
+ };
37
+ if (target.filter !== undefined) {
38
+ base["filter"] = filterToTf(target.filter, `elementum_sla.${label}.targets[${index}].filter`, {
39
+ ownerTfLabel: ctx.appTfLabel,
40
+ appRefName: ctx.appRefName,
41
+ ownerRefName: ctx.appRefName,
42
+ scope: "app",
43
+ objectId: expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]),
44
+ diagnostics: ctx.diagnostics ?? [],
45
+ resolvePicklistLiterals: false,
46
+ ...(ctx.fieldAddresses !== undefined ? { fieldAddresses: ctx.fieldAddresses } : {}),
47
+ });
48
+ }
49
+ if (target.approval !== undefined) {
50
+ const approval = {};
51
+ if (target.approval.entityType !== undefined)
52
+ approval["entity_type"] = target.approval.entityType;
53
+ if (Object.keys(approval).length > 0)
54
+ base["approval"] = approval;
55
+ }
56
+ return base;
57
+ }),
58
+ };
59
+ if (approvalOwned) {
60
+ const processTfLabel = appScopedResourceLabel(ctx.appTfLabel, tsLabelToTfLabel(payload.approvalProcess.refName ?? ""));
61
+ attrs["approval_process_id"] = expr.resourceAttr(APPROVAL_PROCESS_RESOURCE_TYPE, processTfLabel, ["id"]);
62
+ }
63
+ else {
64
+ attrs["app_id"] = expr.resourceAttr(APP_RESOURCE_TYPE, ctx.appTfLabel, ["id"]);
65
+ attrs["stage_ids"] = (payload.stages ?? []).map((stage) => expr.local(`${ctx.appTfLabel}_stage_ids_by_key`, [{ index: stageIndex(entity.refName, stage, ctx.stageKeyByTfLabel) }]));
66
+ }
67
+ const block = { kind: "resource", type: SLA_RESOURCE_TYPE, label, attrs };
68
+ return { blocks: [block], address: `${SLA_RESOURCE_TYPE}.${label}` };
69
+ }
70
+ function stageIndex(refName, stage, stageKeyByTfLabel) {
71
+ const tfLabel = tsLabelToTfLabel(stage);
72
+ if (stageKeyByTfLabel === undefined)
73
+ return tfLabel;
74
+ const key = stageKeyByTfLabel.get(tfLabel);
75
+ if (key !== undefined)
76
+ return key;
77
+ if ([...stageKeyByTfLabel.values()].includes(stage))
78
+ return stage;
79
+ const known = [...new Set(stageKeyByTfLabel.keys())].sort().join(", ");
80
+ throw new EntityTfError(`sla "${refName}": stage "${stage}" is not a stage of the owning app (stages: ${known})`);
81
+ }
@@ -42,6 +42,11 @@ export declare function databricksTableMapping(opts: {
42
42
  readonly schema: string;
43
43
  readonly table: string;
44
44
  }): CloudMapping;
45
+ /** A table row window. The platform Limit scalar is `{ count, offset }`. */
46
+ export interface TableLimit {
47
+ readonly count: number;
48
+ readonly offset?: number;
49
+ }
45
50
  export declare function snowflakeTableView(opts: {
46
51
  readonly database: string;
47
52
  readonly schema: string;
@@ -68,7 +73,7 @@ export interface DefineTableV2Options<Columns extends Readonly<Record<string, Ta
68
73
  readonly color?: string;
69
74
  readonly cloudMapping?: CloudMapping;
70
75
  readonly filter?: Filter;
71
- readonly limit?: unknown;
76
+ readonly limit?: TableLimit;
72
77
  readonly orderBy?: unknown;
73
78
  }
74
79
  export interface TableAuthoringPayload {
@@ -85,7 +90,7 @@ export interface TableAuthoringPayload {
85
90
  readonly color?: string;
86
91
  readonly cloudMapping?: Record<string, unknown>;
87
92
  readonly filter?: Filter;
88
- readonly limit?: unknown;
93
+ readonly limit?: TableLimit;
89
94
  readonly orderBy?: unknown;
90
95
  }
91
96
  type TableColumnRefs<Columns extends Readonly<Record<string, TableColumn>>, Parent extends string> = {
@@ -19,6 +19,27 @@ export function bigQueryTableMapping(opts) {
19
19
  export function databricksTableMapping(opts) {
20
20
  return { cloudLink: opts.cloudLink, databricks: { databaseName: opts.database, schemaName: opts.schema, tableName: opts.table } };
21
21
  }
22
+ function nonNegativeInteger(value) {
23
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
24
+ }
25
+ /** Rejects a bare number and any shape other than `{ count, offset? }`. */
26
+ function tableLimitFromAuthoring(value, where) {
27
+ if (value === null || typeof value !== "object" || Array.isArray(value)) {
28
+ throw new EdkValidationError(`${where} must be { count, offset? } with a non-negative integer count.`);
29
+ }
30
+ const rec = value;
31
+ const extra = Object.keys(rec).filter((key) => key !== "count" && key !== "offset");
32
+ if (extra.length > 0) {
33
+ throw new EdkValidationError(`${where} only carries count and offset.`);
34
+ }
35
+ if (!nonNegativeInteger(rec.count)) {
36
+ throw new EdkValidationError(`${where}.count must be a non-negative integer.`);
37
+ }
38
+ if (rec.offset !== undefined && !nonNegativeInteger(rec.offset)) {
39
+ throw new EdkValidationError(`${where}.offset must be a non-negative integer.`);
40
+ }
41
+ return { count: rec.count, ...(rec.offset !== undefined ? { offset: rec.offset } : {}) };
42
+ }
22
43
  export function snowflakeTableView(opts) {
23
44
  return { snowflake: { databaseName: opts.database, schemaName: opts.schema, name: opts.name } };
24
45
  }
@@ -60,7 +81,7 @@ function payloadFor(opts, refName) {
60
81
  ...(joins != null && joins.length > 0 ? { joins } : {}),
61
82
  ...(opts.view !== undefined ? { views: [opts.view] } : {}),
62
83
  ...(opts.filter !== undefined ? { filter: opts.filter } : {}),
63
- ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
84
+ ...(opts.limit !== undefined ? { limit: tableLimitFromAuthoring(opts.limit, "table limit") } : {}),
64
85
  ...(opts.orderBy !== undefined ? { orderBy: opts.orderBy } : {}),
65
86
  });
66
87
  }
@@ -37,7 +37,10 @@ export interface NormalizedTable {
37
37
  readonly description?: string;
38
38
  readonly icon?: string;
39
39
  readonly color?: string;
40
- readonly limit?: number;
40
+ readonly limit?: {
41
+ readonly count: number;
42
+ readonly offset?: number;
43
+ };
41
44
  readonly orderBy?: unknown;
42
45
  readonly filter?: Filter<NormalizedTableFilterField, TfValue>;
43
46
  readonly joins: readonly NormalizedJoin[];
@@ -3,7 +3,29 @@ import { isTfExpr, sanitizeName, snakeSlug, tfLabelToTsLabel, tsLabelToTfLabel }
3
3
  import { tableDataminesFromTf } from "../datamine/from-tf.js";
4
4
  import { TABLE_RESOURCE_TYPE } from "./module.js";
5
5
  import { EntityTfError } from "../../engine/entity.js";
6
+ import { catalogRefForAspectOwner } from "../shared/aspect-target-from-tf.js";
6
7
  import { filterFromTf } from "../shared/filters/tf-codec.js";
8
+ import { optionLookupDecode } from "../shared/filters/option-lookups.js";
9
+ function nonNegativeInteger(value) {
10
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
11
+ }
12
+ /** A present limit that is not {count, offset} fails the pull. Dropping it would clear the live limit on the next apply (#2679). */
13
+ function tableLimitFromAttr(value, where) {
14
+ const rec = plainObject(value);
15
+ if (rec === undefined)
16
+ throw new EntityTfError(`${where} must be { count, offset }`);
17
+ const extra = Object.keys(rec).filter((key) => key !== "count" && key !== "offset");
18
+ if (extra.length > 0)
19
+ throw new EntityTfError(`${where} only carries count and offset`);
20
+ const count = rec["count"];
21
+ const offset = rec["offset"];
22
+ if (!nonNegativeInteger(count))
23
+ throw new EntityTfError(`${where}.count must be a non-negative integer`);
24
+ if (offset !== undefined && offset !== null && !nonNegativeInteger(offset)) {
25
+ throw new EntityTfError(`${where}.offset must be a non-negative integer`);
26
+ }
27
+ return { count, ...(nonNegativeInteger(offset) ? { offset } : {}) };
28
+ }
7
29
  function str(obj, key) {
8
30
  return typeof obj[key] === "string" ? obj[key] : undefined;
9
31
  }
@@ -12,18 +34,65 @@ function stringList(value) {
12
34
  return undefined;
13
35
  return value;
14
36
  }
15
- function sourceRef(value) {
16
- for (const [kind, type] of [
17
- ["app", "elementum_app"],
18
- ["element", "elementum_element"],
19
- ["table", "elementum_table"],
20
- ]) {
21
- const label = dataRefLabel(value, type) ?? resourceRefLabel(value, type);
22
- if (label !== undefined)
23
- return { kind, refName: tfLabelToTsLabel(label) };
37
+ const SOURCE_TYPES = [
38
+ ["app", "elementum_app"],
39
+ ["element", "elementum_element"],
40
+ ["table", "elementum_table"],
41
+ ];
42
+ function ownerLabel(value) {
43
+ for (const [kind, type] of SOURCE_TYPES) {
44
+ const dataLabel = dataRefLabel(value, type);
45
+ if (dataLabel !== undefined)
46
+ return { kind, type, label: dataLabel, data: true };
47
+ const resourceLabel = resourceRefLabel(value, type);
48
+ if (resourceLabel !== undefined)
49
+ return { kind, type, label: resourceLabel, data: false };
24
50
  }
25
51
  return undefined;
26
52
  }
53
+ function stringAttr(attrs, key) {
54
+ const value = attrs?.[key];
55
+ return typeof value === "string" && value !== "" ? value : undefined;
56
+ }
57
+ /**
58
+ * Catalog key for an app or element source. The export labels the resource
59
+ * by sanitized namespace, which is not the workspace refName when the two
60
+ * differ (#2667). The field-label prefix stays the export label; only the
61
+ * catalog key is remapped.
62
+ */
63
+ function aspectOwnerRefName(ctx, owner) {
64
+ const attrs = owner.data
65
+ ? ctx.dataAttrs?.(owner.type, owner.label)
66
+ : ctx.resourceByAddress?.(`${owner.type}.${owner.label}`)?.attrs;
67
+ const namespace = stringAttr(attrs, "namespace");
68
+ const name = owner.data
69
+ ? ctx.dataName(owner.type, owner.label) ?? stringAttr(attrs, "name")
70
+ : stringAttr(attrs, "name");
71
+ return catalogRefForAspectOwner({
72
+ ...(namespace !== undefined && { namespace }),
73
+ ...(name !== undefined && { name }),
74
+ tfLabel: owner.label,
75
+ refNamesByNamespace: owner.kind === "app" ? ctx.foreignAppRefNamespaces : ctx.foreignElementRefNamespaces,
76
+ refNamesByName: owner.kind === "app" ? ctx.foreignAppRefNames : ctx.foreignElementRefNames,
77
+ }) ?? tfLabelToTsLabel(owner.label);
78
+ }
79
+ function sourceRef(value, ctx) {
80
+ const owner = ownerLabel(value);
81
+ if (owner === undefined)
82
+ return undefined;
83
+ if (owner.kind !== "app" && owner.kind !== "element") {
84
+ return { kind: "table", refName: tfLabelToTsLabel(owner.label) };
85
+ }
86
+ return {
87
+ kind: owner.kind,
88
+ refName: aspectOwnerRefName(ctx, {
89
+ kind: owner.kind,
90
+ type: owner.type,
91
+ label: owner.label,
92
+ data: owner.data,
93
+ }),
94
+ };
95
+ }
27
96
  function rawRef(value) {
28
97
  if (typeof value === "string")
29
98
  return value;
@@ -44,10 +113,14 @@ function fieldSourceRef(value, ctx) {
44
113
  if (fieldLabel === undefined)
45
114
  return undefined;
46
115
  const attrs = ctx.dataAttrs?.("elementum_field", fieldLabel);
47
- const owner = sourceRef(attrs?.["object_id"]);
116
+ const ownerValue = attrs?.["object_id"];
117
+ const owner = sourceRef(ownerValue, ctx);
48
118
  if (owner === undefined)
49
119
  return undefined;
50
- const prefix = `${owner.refName}_`;
120
+ // Column labels are prefixed with the export label (the sanitized
121
+ // namespace), not the workspace refName the catalog is keyed by.
122
+ const prefixLabel = ownerLabel(ownerValue)?.label;
123
+ const prefix = `${prefixLabel === undefined ? owner.refName : tfLabelToTsLabel(prefixLabel)}_`;
51
124
  const fieldPart = fieldLabel.startsWith(prefix) ? fieldLabel.slice(prefix.length) : fieldLabel;
52
125
  if (owner.kind === "table")
53
126
  return { kind: "tableColumn", parentRefName: owner.refName, refName: tfLabelToTsLabel(fieldPart) };
@@ -108,6 +181,8 @@ function tableFilterFromTf(value, tableTfLabel, columnKeyByName, ctx, where) {
108
181
  return filterFromTf(value, {
109
182
  field: (field) => tableFilterFieldFromTf(field, tableTfLabel, columnKeyByName, ctx, where),
110
183
  reference: () => { throw new EntityTfError("table filters do not support reference values"); },
184
+ // #2582: a stored option lookup prints as filter.textOption(label).
185
+ ...optionLookupDecode,
111
186
  });
112
187
  }
113
188
  function tableFilterFieldFromTf(value, tableTfLabel, columnKeyByName, ctx, where) {
@@ -212,7 +287,7 @@ export function tableFromTf(block, ctx, datamineBlocks = []) {
212
287
  const join = plainObject(item);
213
288
  if (join === undefined)
214
289
  return [];
215
- const joinedSource = sourceRef(join["source_id"]);
290
+ const joinedSource = sourceRef(join["source_id"], ctx);
216
291
  return [{
217
292
  type: (str(join, "type") ?? "LEFT"),
218
293
  ...(joinedSource !== undefined && { sourceRef: joinedSource }),
@@ -228,7 +303,7 @@ export function tableFromTf(block, ctx, datamineBlocks = []) {
228
303
  }];
229
304
  });
230
305
  const categoryLabel = dataRefLabel(attrs["category_id"], "elementum_category");
231
- const source = sourceRef(attrs["source_id"]);
306
+ const source = sourceRef(attrs["source_id"], ctx);
232
307
  const sourceID = typeof attrs["source_id"] === "string" ? attrs["source_id"] : undefined;
233
308
  const view = dataView(attrs);
234
309
  const datamines = tableDataminesFromTf(datamineBlocks, tableTfLabel, columnKeyByName, ctx, new Map(columns.flatMap((column) => [column.state.id, column.sourceFieldId]
@@ -246,7 +321,7 @@ export function tableFromTf(block, ctx, datamineBlocks = []) {
246
321
  ...(optionalString(attrs, "description", `table ${block.label}`, ctx) !== undefined && { description: optionalString(attrs, "description", `table ${block.label}`, ctx) }),
247
322
  ...(optionalString(attrs, "icon", `table ${block.label}`, ctx) !== undefined && { icon: optionalString(attrs, "icon", `table ${block.label}`, ctx) }),
248
323
  ...(optionalString(attrs, "color", `table ${block.label}`, ctx) !== undefined && { color: optionalString(attrs, "color", `table ${block.label}`, ctx) }),
249
- ...(typeof attrs["limit"] === "number" && { limit: attrs["limit"] }),
324
+ ...(attrs["limit"] !== undefined && attrs["limit"] !== null && { limit: tableLimitFromAttr(attrs["limit"], `elementum_table.${block.label}.limit`) }),
250
325
  ...(attrs["order_by"] !== undefined && { orderBy: orderBy(attrs["order_by"]) }),
251
326
  ...(attrs["filter"] !== undefined && {
252
327
  filter: tableFilterFromTf(attrs["filter"], tableTfLabel, columnKeyByName, ctx, `elementum_table.${tableTfLabel}.filter`),
@@ -2,7 +2,7 @@
2
2
  * v2 table authoring — `table`. Org-owned top-level entity.
3
3
  * Standalone from v1's `src/tables`.
4
4
  */
5
- export { table, bigQueryTableMapping, databricksTableMapping, snowflakeTableMapping, snowflakeTableView, tablePayloadToCreateRequest, tablePayloadToReadOnlyUpdateRequest, tablePayloadToUpdateRequest, type DefineTableV2Options, type TableAuthoringPayload, type TableConfigured, type TableView, } from "./build.js";
5
+ export { table, bigQueryTableMapping, databricksTableMapping, snowflakeTableMapping, snowflakeTableView, tablePayloadToCreateRequest, tablePayloadToReadOnlyUpdateRequest, tablePayloadToUpdateRequest, type DefineTableV2Options, type TableAuthoringPayload, type TableLimit, type TableConfigured, type TableView, } from "./build.js";
6
6
  export { type TableDatamine, type DatamineSchedule, type DatamineTimeUnit } from "../datamine/build.js";
7
7
  export { calculationColumn, bigQueryColumn, serializeTableField, snowflakeColumn, sourceColumn, tableAggregation, tableColumnTag, tableColumnType, tableExpansion, type CalculationColumnOptions, type SourceColumnOptions, type TableAggregation, type TableColumn, type TableColumnTag, type TableColumnType, type TableCalculationField, type TableCloudField, type TableField, type TableExpansion, type TableReferenceField, } from "./fields.js";
8
8
  export { serializeJoin, tableJoin, tableJoinType, type TableJoinFieldPair, type TableJoin, type TableJoinOptions, type TableJoinType, } from "./joins.js";
@@ -8,7 +8,29 @@ import { tableDataminesToTf, } from "../datamine/to-tf.js";
8
8
  import { authoredFieldKeysFromPayload, fieldRefToTfValue } from "../field/to-tf.js";
9
9
  import { foreignFieldDataLabel, resolveForeignRef } from "../shared/foreign-ref.js";
10
10
  import { filterToTf as serializeFilterToTf } from "../shared/filters/tf-codec.js";
11
+ import { optionSelectionLiteral, optionsLocalName } from "../shared/filters/option-lookups.js";
11
12
  import { TABLE_RESOURCE_TYPE } from "./module.js";
13
+ function nonNegativeInteger(value) {
14
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
15
+ }
16
+ /**
17
+ * The platform's Limit scalar is {count, offset}; offset is written even when
18
+ * it is the default 0 so build matches what export writes (#2679).
19
+ */
20
+ function tableLimitToTf(limit, where) {
21
+ if (limit === null || typeof limit !== "object" || Array.isArray(limit)) {
22
+ throw new EntityTfError(`${where} must be { count, offset? }`);
23
+ }
24
+ const extra = Object.keys(limit).filter((key) => key !== "count" && key !== "offset");
25
+ if (extra.length > 0)
26
+ throw new EntityTfError(`${where} only carries count and offset`);
27
+ if (!nonNegativeInteger(limit.count))
28
+ throw new EntityTfError(`${where}.count must be a non-negative integer`);
29
+ if (limit.offset !== undefined && !nonNegativeInteger(limit.offset)) {
30
+ throw new EntityTfError(`${where}.offset must be a non-negative integer`);
31
+ }
32
+ return { count: limit.count, offset: limit.offset ?? 0 };
33
+ }
12
34
  function tableColumnName(column) {
13
35
  for (const kind of ["cloud", "calculation", "reference"]) {
14
36
  const value = column[kind];
@@ -108,6 +130,23 @@ function tableFilterToTf(filter, orgRefs, ownRef, ownLabel, ownColumnNames, work
108
130
  field: (field) => fieldId(field, orgRefs, ownRef, ownLabel, ownColumnNames, workspaceAspects, diagnostics),
109
131
  aspect: (aspect) => aspectId(aspect, orgRefs, workspaceAspects, diagnostics, "table filter aspect"),
110
132
  reference: () => { throw new EntityTfError("table filters do not support reference values"); },
133
+ // #2582: a Dropdown option is selected with filter.textOption(label).
134
+ literal: optionSelectionLiteral({
135
+ where: `table ${ownRef} filter`,
136
+ address: `${TABLE_RESOURCE_TYPE}.${ownLabel}`,
137
+ name: ownRef,
138
+ ownerKind: "table",
139
+ optionsLocal: (field) => {
140
+ const ref = field;
141
+ if (ref.__kind !== "field")
142
+ return undefined;
143
+ const kind = ref.parentKind ?? "app";
144
+ if (kind !== "app" && kind !== "element")
145
+ return undefined;
146
+ const local = workspaceAspects?.get(workspaceAspectKey(kind, ref.parent ?? ""));
147
+ return local === undefined ? undefined : optionsLocalName(local.tfLabel, kind, field);
148
+ },
149
+ }),
111
150
  });
112
151
  }
113
152
  export function tableToTf(entity, ctx) {
@@ -208,8 +247,8 @@ export function tableToTf(entity, ctx) {
208
247
  if (p.filter !== undefined) {
209
248
  attrs["filter"] = tableFilterToTf(p.filter, ctx.orgRefs, entity.refName, label, columnNames, ctx.workspaceAspects, ctx.diagnostics);
210
249
  }
211
- if (typeof p.limit === "number")
212
- attrs["limit"] = p.limit;
250
+ if (p.limit !== undefined)
251
+ attrs["limit"] = tableLimitToTf(p.limit, `table ${entity.refName} limit`);
213
252
  if (p.orderBy !== undefined)
214
253
  attrs["order_by"] =
215
254
  typeof p.orderBy === "string"
@@ -1,6 +1,6 @@
1
1
  import { dataRefLabel, optionalBoolean, optionalString, plainObject } from "../../engine/pull/context.js";
2
2
  import { tfLabelToTsLabel } from "../../engine/tf/index.js";
3
- import { fieldFromTf } from "../field/from-tf.js";
3
+ import { fieldsFromTf } from "../field/from-tf.js";
4
4
  import { TASK_RESOURCE_TYPE } from "./module.js";
5
5
  const KNOWN = new Set(["id", "name", "handle", "namespace", "category_id", "cloud_link_id", "description", "icon", "color", "title_field_name", "title_field_description", "id_field_name", "id_field_description", "status_field_name", "status_field_description", "status_options", "status_option_ids_by_label", "title_field_id", "id_field_id", "status_field_id", "comments_enabled", "comments_display_block_id"]);
6
6
  export function taskFromTf(block, ctx, fieldBlocks = []) {
@@ -28,7 +28,8 @@ export function taskFromTf(block, ctx, fieldBlocks = []) {
28
28
  const statusDescription = optionalString(block.attrs, "status_field_description", `task ${block.label}`, ctx);
29
29
  const refName = tfLabelToTsLabel(block.label);
30
30
  const owner = { type: TASK_RESOURCE_TYPE, label: block.label, scope: "task", refName };
31
- const fields = fieldBlocks.flatMap((fieldBlock) => fieldFromTf(fieldBlock, owner, ctx) ?? []);
31
+ // Keys claimed two-pass like apps and elements, printed in the live field order (#1871 B1, edk#2933).
32
+ const fields = fieldsFromTf(fieldBlocks, owner, ctx);
32
33
  return { refName, name, handle, namespace,
33
34
  ...(fields.length > 0 && { fields }),
34
35
  ...(categoryLabel !== undefined && { categoryRef: tfLabelToTsLabel(categoryLabel) }),
@@ -1,10 +1,12 @@
1
1
  /**
2
2
  * check.mjs-parity structure checks for Custom managed views (#1771 / #1758).
3
3
  * Hard structural failures (missing root/type, cycles, broken filters) fail the
4
- * build as EntityTfError. Reachability and live-list selection gaps match
5
- * check.mjs `warn` — they push to diagnostics so a pulled live layout still
6
- * builds and plans clean (Blueprint Supplier Workspace has both). Agent views
7
- * keep the softer diagnostics in checkStructure / reportStructureProblems.
4
+ * build as EntityTfError. Reachability, live-list selection gaps and bindings
5
+ * to a path missing from spec.state are warnings — they push to diagnostics so
6
+ * a pulled live layout still builds and plans clean (Blueprint Supplier
7
+ * Workspace has the first two; Under Armour Activity the third, edk#2923: the
8
+ * page reads a missing path as undefined). Agent views keep the softer
9
+ * diagnostics in checkStructure / reportStructureProblems.
8
10
  *
9
11
  * Layer 3 catalog checks (calc field names, option ids, tag helpers against
10
12
  * the live App) need aspect-aware resolution; typed field refs already fail
@@ -15,6 +15,18 @@ function isObj(v) {
15
15
  function isBinding(v) {
16
16
  return isObj(v) && ("$state" in v || "$bindState" in v || "$item" in v || "$index" in v);
17
17
  }
18
+ /**
19
+ * A $state / $bindState binding's state path, exactly as the Go provider's
20
+ * bindingTarget: a string $state wins, else a string $bindState; "" is no target.
21
+ */
22
+ function bindingTarget(v) {
23
+ if (!isObj(v))
24
+ return undefined;
25
+ const state = v["$state"];
26
+ const bind = v["$bindState"];
27
+ const target = typeof state === "string" ? state : typeof bind === "string" ? bind : undefined;
28
+ return target === "" ? undefined : target;
29
+ }
18
30
  /** Selection props must be $state / $bindState — $item / $index do not drive the details pane. */
19
31
  function isStateBinding(v) {
20
32
  return isObj(v) && ("$state" in v || "$bindState" in v);
@@ -156,9 +168,25 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
156
168
  return { found: true, value: node };
157
169
  };
158
170
  const walkedState = new Set();
159
- const walkFilter = (node, filterWhere) => {
171
+ const walkFilter = (node, filterWhere, fromState = false) => {
160
172
  if (node == null)
161
173
  return;
174
+ // In element props, a binding stands for the filter held in state, at the top
175
+ // of filterJson or as a child of an AND/OR group (edk#2923): the page resolves
176
+ // prop bindings. Check its initial value once, at its state path; a missing
177
+ // path is the binding scan's warning. Nothing shows the page resolving a
178
+ // binding inside a state value, so there it stays a filter node missing "type".
179
+ if (!fromState && isBinding(node)) {
180
+ const target = bindingTarget(node);
181
+ if (typeof target !== "string" || walkedState.has(target))
182
+ return;
183
+ const initial = readState(target);
184
+ if (initial.found && initial.value != null) {
185
+ walkedState.add(target);
186
+ walkFilter(initial.value, `${where}.state${target.replaceAll("/", ".")}`, true);
187
+ }
188
+ return;
189
+ }
162
190
  if (!isObj(node)) {
163
191
  note(filterWhere, "a filter must be an object");
164
192
  return;
@@ -174,7 +202,7 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
174
202
  note(filterWhere, `${node["type"]} needs a "children" list`);
175
203
  return;
176
204
  }
177
- node["children"].forEach((c, i) => walkFilter(c, `${filterWhere}.children[${i}]`));
205
+ node["children"].forEach((c, i) => walkFilter(c, `${filterWhere}.children[${i}]`, fromState));
178
206
  return;
179
207
  }
180
208
  if (typeof node["type"] !== "string") {
@@ -190,9 +218,11 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
190
218
  const type = raw["type"];
191
219
  const scan = (value, path) => {
192
220
  if (isBinding(value)) {
193
- const target = value["$state"] ?? value["$bindState"];
221
+ const target = bindingTarget(value);
194
222
  if (typeof target === "string" && !target.startsWith("/host/") && !readState(target).found) {
195
- note(`${elWhere}.${path}`, `binds to "${target}", which is not in spec.state. Add an initial value there.`);
223
+ // Warn, not fail (edk#2923): the page reads a missing path as undefined,
224
+ // and pulled live layouts rely on that, so failing would block the build.
225
+ warn(`${elWhere}.${path}`, `binds to "${target}", which is not in spec.state, so it starts undefined. Add an initial value there to set its default.`);
196
226
  }
197
227
  return;
198
228
  }
@@ -204,20 +234,8 @@ export function validateCustomViewLayout(spec, where, opts = {}) {
204
234
  };
205
235
  for (const [key, value] of Object.entries(props))
206
236
  scan(value, key);
207
- if (props["filterJson"] !== undefined) {
208
- if (isBinding(props["filterJson"])) {
209
- const target = props["filterJson"]["$bindState"]
210
- ?? props["filterJson"]["$state"];
211
- const initial = typeof target === "string" ? readState(target) : { found: false };
212
- if (initial.found && initial.value != null && typeof target === "string" && !walkedState.has(target)) {
213
- walkedState.add(target);
214
- walkFilter(initial.value, `${where}.state${target.replaceAll("/", ".")}`);
215
- }
216
- }
217
- else {
218
- walkFilter(props["filterJson"], `${elWhere}.filterJson`);
219
- }
220
- }
237
+ if (props["filterJson"] !== undefined)
238
+ walkFilter(props["filterJson"], `${elWhere}.filterJson`);
221
239
  if (typeof props["calc"] === "string") {
222
240
  const calc = props["calc"];
223
241
  if (AVG_CALL.test(calc))