@elementumai/edk 0.9.7 → 0.9.10

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 (152) hide show
  1. package/README.md +3 -2
  2. package/dist-sdk/src/catalog/factories.d.ts +14 -3
  3. package/dist-sdk/src/catalog/factories.js +32 -0
  4. package/dist-sdk/src/catalog/from-authoring.js +27 -33
  5. package/dist-sdk/src/catalog/index.d.ts +2 -2
  6. package/dist-sdk/src/catalog/index.js +2 -2
  7. package/dist-sdk/src/catalog/org.js +67 -29
  8. package/dist-sdk/src/catalog/token.js +10 -0
  9. package/dist-sdk/src/catalog/types.d.ts +20 -2
  10. package/dist-sdk/src/catalog/types.js +5 -0
  11. package/dist-sdk/src/core/index.d.ts +1 -1
  12. package/dist-sdk/src/core/index.js +1 -1
  13. package/dist-sdk/src/core/platform-id.d.ts +2 -0
  14. package/dist-sdk/src/core/platform-id.js +4 -0
  15. package/dist-sdk/src/core/system-fields.d.ts +14 -0
  16. package/dist-sdk/src/core/system-fields.js +6 -0
  17. package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
  18. package/dist-sdk/src/core/triggers/on-demand.js +33 -12
  19. package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
  20. package/dist-sdk/src/core/types/aspect-category.js +1 -0
  21. package/dist-sdk/src/engine/build/context.d.ts +22 -8
  22. package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
  23. package/dist-sdk/src/engine/build/source-context.js +1 -1
  24. package/dist-sdk/src/engine/pull/context.d.ts +9 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +4 -0
  26. package/dist-sdk/src/engine/pull/org.js +17 -2
  27. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
  28. package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
  29. package/dist-sdk/src/engine/tf/expr.js +1 -1
  30. package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
  31. package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
  32. package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
  33. package/dist-sdk/src/engine/workspace/loader.js +328 -0
  34. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.js +10 -2
  36. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +1 -0
  37. package/dist-sdk/src/entities/access-policy/to-tf.js +7 -2
  38. package/dist-sdk/src/entities/agent/build.d.ts +54 -8
  39. package/dist-sdk/src/entities/agent/build.js +36 -1
  40. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +126 -2
  41. package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
  42. package/dist-sdk/src/entities/agent/from-tf.js +176 -5
  43. package/dist-sdk/src/entities/agent/index.d.ts +2 -2
  44. package/dist-sdk/src/entities/agent/index.js +1 -1
  45. package/dist-sdk/src/entities/agent/to-tf.d.ts +4 -4
  46. package/dist-sdk/src/entities/agent/to-tf.js +185 -11
  47. package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
  48. package/dist-sdk/src/entities/agent/tools.js +13 -1
  49. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +7 -0
  50. package/dist-sdk/src/entities/agent-tool/from-tf.js +29 -4
  51. package/dist-sdk/src/entities/agent-tool/to-tf.js +10 -9
  52. package/dist-sdk/src/entities/agent-tool/types.js +1 -0
  53. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  54. package/dist-sdk/src/entities/app/build.js +6 -3
  55. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +5 -0
  56. package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
  57. package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
  58. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
  59. package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
  60. package/dist-sdk/src/entities/app/from-tf.js +9 -7
  61. package/dist-sdk/src/entities/app/to-tf.d.ts +1 -1
  62. package/dist-sdk/src/entities/app/to-tf.js +17 -7
  63. package/dist-sdk/src/entities/automation/build.d.ts +8 -1
  64. package/dist-sdk/src/entities/automation/build.js +36 -5
  65. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +3 -7
  66. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
  67. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +140 -12
  68. package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
  69. package/dist-sdk/src/entities/automation/from-tf.js +803 -62
  70. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  71. package/dist-sdk/src/entities/automation/module.js +13 -3
  72. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +12 -4
  73. package/dist-sdk/src/entities/automation/output-key-wire-name.js +17 -6
  74. package/dist-sdk/src/entities/automation/script-code.d.ts +8 -1
  75. package/dist-sdk/src/entities/automation/script-code.js +32 -14
  76. package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
  77. package/dist-sdk/src/entities/automation/task-label.js +18 -0
  78. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -9
  79. package/dist-sdk/src/entities/automation/tasks.js +16 -4
  80. package/dist-sdk/src/entities/automation/to-tf.d.ts +4 -0
  81. package/dist-sdk/src/entities/automation/to-tf.js +394 -52
  82. package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
  83. package/dist-sdk/src/entities/automation/triggers.js +1 -1
  84. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  85. package/dist-sdk/src/entities/dashboard/to-tf.d.ts +2 -0
  86. package/dist-sdk/src/entities/dashboard/to-tf.js +4 -0
  87. package/dist-sdk/src/entities/datamine/from-tf.js +23 -3
  88. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  89. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
  90. package/dist-sdk/src/entities/element/build.d.ts +30 -7
  91. package/dist-sdk/src/entities/element/build.js +6 -3
  92. package/dist-sdk/src/entities/element/from-tf.js +7 -3
  93. package/dist-sdk/src/entities/element/index.d.ts +1 -1
  94. package/dist-sdk/src/entities/element/index.js +1 -1
  95. package/dist-sdk/src/entities/element/to-tf.js +49 -8
  96. package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
  97. package/dist-sdk/src/entities/field/from-tf.js +12 -0
  98. package/dist-sdk/src/entities/field/module.js +1 -0
  99. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  100. package/dist-sdk/src/entities/field/to-tf.js +19 -5
  101. package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
  102. package/dist-sdk/src/entities/org/category-ref.js +12 -0
  103. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
  104. package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
  105. package/dist-sdk/src/entities/record-create-form/to-tf.js +13 -5
  106. package/dist-sdk/src/entities/relationship/from-tf.js +15 -4
  107. package/dist-sdk/src/entities/role/from-tf.js +10 -4
  108. package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
  109. package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
  110. package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
  111. package/dist-sdk/src/entities/search-table/printer.js +3 -1
  112. package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
  113. package/dist-sdk/src/entities/search-table/types.js +1 -0
  114. package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
  115. package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
  116. package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
  117. package/dist-sdk/src/entities/shared/filters/ast.d.ts +7 -1
  118. package/dist-sdk/src/entities/shared/filters/ast.js +3 -0
  119. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +7 -1
  120. package/dist-sdk/src/entities/shared/filters/tf-codec.js +8 -4
  121. package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
  122. package/dist-sdk/src/entities/shared/handle-description.js +20 -0
  123. package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
  124. package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
  125. package/dist-sdk/src/entities/skill/build.d.ts +51 -2
  126. package/dist-sdk/src/entities/skill/build.js +65 -8
  127. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +35 -3
  128. package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
  129. package/dist-sdk/src/entities/skill/from-tf.js +39 -7
  130. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  131. package/dist-sdk/src/entities/skill/index.js +1 -1
  132. package/dist-sdk/src/entities/skill/input-coverage.d.ts +21 -0
  133. package/dist-sdk/src/entities/skill/input-coverage.js +148 -5
  134. package/dist-sdk/src/entities/skill/to-tf.d.ts +6 -25
  135. package/dist-sdk/src/entities/skill/to-tf.js +22 -38
  136. package/dist-sdk/src/entities/skill/tools.d.ts +2 -1
  137. package/dist-sdk/src/entities/skill/tools.js +3 -1
  138. package/dist-sdk/src/entities/skill-tool/from-tf.js +10 -3
  139. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +5 -5
  140. package/dist-sdk/src/entities/skill-tool/to-tf.js +5 -7
  141. package/dist-sdk/src/entities/table/to-tf.js +3 -4
  142. package/dist-sdk/src/entities/task/to-tf.js +3 -2
  143. package/dist-sdk/src/entities/view/from-tf.js +36 -10
  144. package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
  145. package/dist-sdk/src/entities/view/to-tf.js +44 -30
  146. package/dist-sdk/src/entities/widget/from-tf.js +2 -2
  147. package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
  148. package/dist-sdk/src/entities/widget/to-tf.js +52 -23
  149. package/dist-sdk/src/graph/index.d.ts +19 -1
  150. package/dist-sdk/src/graph/index.js +20 -0
  151. package/dist-sdk/src/graph/types.d.ts +19 -0
  152. package/package.json +10 -5
@@ -0,0 +1,98 @@
1
+ /** Default name for the implicit group synthesized below — the provider's
2
+ * own Create() validation rejects a `type: "group"` section with an empty
3
+ * `name` (required, not merely cosmetic), so this can never be `""`. */
4
+ const IMPLICIT_GROUP_NAME = "Details";
5
+ function isRecord(value) {
6
+ return typeof value === "object" && value !== null;
7
+ }
8
+ /** The `properties.type` discriminator `serializeBlock` writes: "FIELD" | "GROUP" | "WIDGET" | "COMMENTS". */
9
+ function serializedBlockType(block) {
10
+ const props = block["properties"];
11
+ return isRecord(props) && typeof props["type"] === "string" ? props["type"] : undefined;
12
+ }
13
+ /**
14
+ * Maps serialized `displayBlocks` (the `Record<string, unknown>[]` shape
15
+ * `serializeDisplayBlocks` produces) into `elementum_layout` group sections.
16
+ *
17
+ * - A top-level `GROUP` block → one section (`name`/`icon`/`color`/
18
+ * `maxColumns` carried over, `fields` from its direct `FIELD` children).
19
+ * - Top-level `FIELD` blocks with no enclosing group are collected into one
20
+ * implicit group section named `"Details"` (the target shape requires a
21
+ * non-empty section name — see `IMPLICIT_GROUP_NAME`).
22
+ * Intentionally always appended LAST, after every named `GROUP` section,
23
+ * regardless of where the bare fields appeared relative to groups in the
24
+ * authored list — e.g. `[field, group]` renders as
25
+ * `[group, implicit-field-group]`. A single implicit group has no natural
26
+ * authored position of its own (it isn't one authored block, it's the
27
+ * union of every bare field), so a fixed, deterministic position was
28
+ * chosen over trying to infer one from interleaving.
29
+ * - `WIDGET`/`COMMENTS` blocks (top-level or nested) and nested `GROUP`
30
+ * blocks are diagnosed and dropped individually; everything else mappable
31
+ * in the same payload still lands. A block with no recognizable shape at
32
+ * all (not a record, or missing/malformed `properties.type`) is likewise
33
+ * diagnosed and dropped rather than silently ignored.
34
+ */
35
+ export function displayBlocksToLayoutSections(blocks, where, diagnostics) {
36
+ const sections = [];
37
+ const implicitFields = [];
38
+ for (const raw of blocks) {
39
+ if (!isRecord(raw)) {
40
+ diagnostics.push(`${where}: a block has an unrecognized shape; dropped`);
41
+ continue;
42
+ }
43
+ const kind = serializedBlockType(raw);
44
+ if (kind === "GROUP") {
45
+ sections.push(groupBlockToSection(raw, where, diagnostics));
46
+ }
47
+ else if (kind === "FIELD") {
48
+ implicitFields.push(raw["fieldId"]);
49
+ }
50
+ else if (kind === undefined) {
51
+ diagnostics.push(`${where}: a block has an unrecognized shape; dropped`);
52
+ }
53
+ else {
54
+ diagnostics.push(`${where}: "${kind.toLowerCase()}" blocks have no terraform layout equivalent; dropped`);
55
+ }
56
+ }
57
+ if (implicitFields.length > 0) {
58
+ sections.push({ type: "group", name: IMPLICIT_GROUP_NAME, fields: implicitFields });
59
+ }
60
+ return sections;
61
+ }
62
+ function groupBlockToSection(block, where, diagnostics) {
63
+ const props = isRecord(block["properties"]) ? block["properties"] : {};
64
+ const children = Array.isArray(block["children"]) ? block["children"] : [];
65
+ const fields = [];
66
+ for (const child of children) {
67
+ if (!isRecord(child)) {
68
+ diagnostics.push(`${where}: a nested block has an unrecognized shape; dropped`);
69
+ continue;
70
+ }
71
+ const childKind = serializedBlockType(child);
72
+ if (childKind === "FIELD") {
73
+ fields.push(child["fieldId"]);
74
+ }
75
+ else if (childKind === "GROUP") {
76
+ diagnostics.push(`${where}: nested group blocks have no terraform layout equivalent; dropped`);
77
+ }
78
+ else if (childKind === undefined) {
79
+ diagnostics.push(`${where}: a nested block has an unrecognized shape; dropped`);
80
+ }
81
+ else {
82
+ diagnostics.push(`${where}: "${childKind.toLowerCase()}" blocks have no terraform layout equivalent; dropped`);
83
+ }
84
+ }
85
+ return {
86
+ type: "group",
87
+ // A group block's own name comes from authored `DisplayBlock.group.name`
88
+ // (a required string on the authoring type — see display-blocks.ts) —
89
+ // this fallback only guards against a malformed/missing properties.name
90
+ // in the serialized shape, which "shouldn't happen" but must still never
91
+ // produce the empty string the provider rejects.
92
+ name: typeof props["name"] === "string" && props["name"] !== "" ? props["name"] : IMPLICIT_GROUP_NAME,
93
+ icon: typeof props["icon"] === "string" ? props["icon"] : undefined,
94
+ color: typeof props["color"] === "string" ? props["color"] : undefined,
95
+ maxColumns: typeof props["maxColumns"] === "number" ? props["maxColumns"] : undefined,
96
+ fields,
97
+ };
98
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Compose→terraform bridge for `recordCreateDisplayBlocks` (CREATE surface).
3
+ * `serializeDisplayBlocks` (`display-blocks.ts`) turns the authored
4
+ * `DisplayBlock[]` into the GraphQL-compose wire shape consumed by `to-tf`
5
+ * payloads — this module maps THAT wire shape into
6
+ * `RecordCreateFormSectionWire[]`, the shape `recordCreateFormToTf`
7
+ * (`entities/record-create-form/to-tf.ts`) already knows how to emit as
8
+ * `elementum_record_create_form`.
9
+ *
10
+ * Only `field`/`group` blocks have a `elementum_record_create_form`
11
+ * equivalent — the provider's `sections` schema has no `widget`/`comments`
12
+ * section type, same restriction `display-blocks-to-layout.ts` documents for
13
+ * the LAYOUT surface. `widget`/`comments` blocks are diagnosed and dropped
14
+ * individually rather than killing the whole payload. Record-create-form
15
+ * sections are flat (`fields` only) — a `group` nested inside a `group` is
16
+ * diagnosed and dropped (its own contents only; the outer group keeps its
17
+ * direct fields), since there is no nested-section shape to target.
18
+ *
19
+ * Unlike `AppLayoutSectionWire`, `RecordCreateFormSectionWire` carries no
20
+ * section-type discriminator at all (no `type: "group"` to set) — otherwise
21
+ * the mapping is identical, so this is intentionally a near-duplicate of
22
+ * `displayBlocksToLayoutSections` rather than a shared generic: the two
23
+ * target wire shapes are close enough to invite one, but diverge exactly at
24
+ * the field this module must NOT set.
25
+ *
26
+ * This is a pure, entity-agnostic transform (it knows nothing about apps or
27
+ * elements) — kept alongside `display-blocks.ts` rather than under
28
+ * `entities/element/`.
29
+ */
30
+ import type { RecordCreateFormSectionWire } from "../record-create-form/to-tf.js";
31
+ /**
32
+ * Maps serialized `recordCreateDisplayBlocks` (the `Record<string,
33
+ * unknown>[]` shape `serializeDisplayBlocks` produces) into
34
+ * `elementum_record_create_form` sections.
35
+ *
36
+ * - A top-level `GROUP` block → one section (`name`/`icon`/`color`/
37
+ * `maxColumns` carried over, `fields` from its direct `FIELD` children).
38
+ * `displayOrder`/`displayLocation`/`sideNavItem`/`hidden`/`agent` are not
39
+ * authorable through `DisplayBlock` — `recordCreateFormToTf` defaults them
40
+ * (index-based `display_order`, `"CENTER"`, `true`, `false`) the same way
41
+ * it does for a directly-authored `recordCreateForm` section that omits
42
+ * them.
43
+ * - Top-level `FIELD` blocks with no enclosing group are collected into one
44
+ * implicit group section named `"Details"` (the target shape requires a
45
+ * non-empty section name — see `IMPLICIT_GROUP_NAME`). Intentionally
46
+ * always appended LAST, after every named `GROUP` section — see
47
+ * `displayBlocksToLayoutSections`'s doc comment for why a fixed,
48
+ * deterministic position was chosen over inferring one from interleaving.
49
+ * - `WIDGET`/`COMMENTS` blocks (top-level or nested) and nested `GROUP`
50
+ * blocks are diagnosed and dropped individually; everything else mappable
51
+ * in the same payload still lands. A block with no recognizable shape at
52
+ * all (not a record, or missing/malformed `properties.type`) is likewise
53
+ * diagnosed and dropped rather than silently ignored.
54
+ */
55
+ export declare function displayBlocksToRecordCreateFormSections(blocks: readonly unknown[], where: string, diagnostics: string[]): RecordCreateFormSectionWire[];
@@ -0,0 +1,99 @@
1
+ /** Default name for the implicit group synthesized below — the provider's
2
+ * own Create() validation rejects a section with an empty `name` (required,
3
+ * not merely cosmetic), so this can never be `""`. */
4
+ const IMPLICIT_GROUP_NAME = "Details";
5
+ function isRecord(value) {
6
+ return typeof value === "object" && value !== null;
7
+ }
8
+ /** The `properties.type` discriminator `serializeBlock` writes: "FIELD" | "GROUP" | "WIDGET" | "COMMENTS". */
9
+ function serializedBlockType(block) {
10
+ const props = block["properties"];
11
+ return isRecord(props) && typeof props["type"] === "string" ? props["type"] : undefined;
12
+ }
13
+ /**
14
+ * Maps serialized `recordCreateDisplayBlocks` (the `Record<string,
15
+ * unknown>[]` shape `serializeDisplayBlocks` produces) into
16
+ * `elementum_record_create_form` sections.
17
+ *
18
+ * - A top-level `GROUP` block → one section (`name`/`icon`/`color`/
19
+ * `maxColumns` carried over, `fields` from its direct `FIELD` children).
20
+ * `displayOrder`/`displayLocation`/`sideNavItem`/`hidden`/`agent` are not
21
+ * authorable through `DisplayBlock` — `recordCreateFormToTf` defaults them
22
+ * (index-based `display_order`, `"CENTER"`, `true`, `false`) the same way
23
+ * it does for a directly-authored `recordCreateForm` section that omits
24
+ * them.
25
+ * - Top-level `FIELD` blocks with no enclosing group are collected into one
26
+ * implicit group section named `"Details"` (the target shape requires a
27
+ * non-empty section name — see `IMPLICIT_GROUP_NAME`). Intentionally
28
+ * always appended LAST, after every named `GROUP` section — see
29
+ * `displayBlocksToLayoutSections`'s doc comment for why a fixed,
30
+ * deterministic position was chosen over inferring one from interleaving.
31
+ * - `WIDGET`/`COMMENTS` blocks (top-level or nested) and nested `GROUP`
32
+ * blocks are diagnosed and dropped individually; everything else mappable
33
+ * in the same payload still lands. A block with no recognizable shape at
34
+ * all (not a record, or missing/malformed `properties.type`) is likewise
35
+ * diagnosed and dropped rather than silently ignored.
36
+ */
37
+ export function displayBlocksToRecordCreateFormSections(blocks, where, diagnostics) {
38
+ const sections = [];
39
+ const implicitFields = [];
40
+ for (const raw of blocks) {
41
+ if (!isRecord(raw)) {
42
+ diagnostics.push(`${where}: a block has an unrecognized shape; dropped`);
43
+ continue;
44
+ }
45
+ const kind = serializedBlockType(raw);
46
+ if (kind === "GROUP") {
47
+ sections.push(groupBlockToSection(raw, where, diagnostics));
48
+ }
49
+ else if (kind === "FIELD") {
50
+ implicitFields.push(raw["fieldId"]);
51
+ }
52
+ else if (kind === undefined) {
53
+ diagnostics.push(`${where}: a block has an unrecognized shape; dropped`);
54
+ }
55
+ else {
56
+ diagnostics.push(`${where}: "${kind.toLowerCase()}" blocks have no terraform record create form equivalent; dropped`);
57
+ }
58
+ }
59
+ if (implicitFields.length > 0) {
60
+ sections.push({ name: IMPLICIT_GROUP_NAME, fields: implicitFields });
61
+ }
62
+ return sections;
63
+ }
64
+ function groupBlockToSection(block, where, diagnostics) {
65
+ const props = isRecord(block["properties"]) ? block["properties"] : {};
66
+ const children = Array.isArray(block["children"]) ? block["children"] : [];
67
+ const fields = [];
68
+ for (const child of children) {
69
+ if (!isRecord(child)) {
70
+ diagnostics.push(`${where}: a nested block has an unrecognized shape; dropped`);
71
+ continue;
72
+ }
73
+ const childKind = serializedBlockType(child);
74
+ if (childKind === "FIELD") {
75
+ fields.push(child["fieldId"]);
76
+ }
77
+ else if (childKind === "GROUP") {
78
+ diagnostics.push(`${where}: nested group blocks have no terraform record create form equivalent; dropped`);
79
+ }
80
+ else if (childKind === undefined) {
81
+ diagnostics.push(`${where}: a nested block has an unrecognized shape; dropped`);
82
+ }
83
+ else {
84
+ diagnostics.push(`${where}: "${childKind.toLowerCase()}" blocks have no terraform record create form equivalent; dropped`);
85
+ }
86
+ }
87
+ return {
88
+ // A group block's own name comes from authored `DisplayBlock.group.name`
89
+ // (a required string on the authoring type — see display-blocks.ts) —
90
+ // this fallback only guards against a malformed/missing properties.name
91
+ // in the serialized shape, which "shouldn't happen" but must still never
92
+ // produce the empty string the provider rejects.
93
+ name: typeof props["name"] === "string" && props["name"] !== "" ? props["name"] : IMPLICIT_GROUP_NAME,
94
+ icon: typeof props["icon"] === "string" ? props["icon"] : undefined,
95
+ color: typeof props["color"] === "string" ? props["color"] : undefined,
96
+ maxColumns: typeof props["maxColumns"] === "number" ? props["maxColumns"] : undefined,
97
+ fields,
98
+ };
99
+ }
@@ -138,6 +138,12 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
138
138
  }
139
139
  // --- System-field attributes/config → tagged NormalizedField entries.
140
140
  const fields = [];
141
+ const owner = { type: APP_RESOURCE_TYPE, label, scope: "app" };
142
+ const customFields = fieldBlocks.flatMap((block) => {
143
+ const entry = fieldFromTf(block, owner, ctx);
144
+ return entry === undefined ? [] : [entry];
145
+ });
146
+ const hasCustomStatusField = customFields.some((field) => field.key === "status");
141
147
  const systemConfig = systemFieldConfigFromTf(attrs["system_field_config"], `app "${label}"`, ctx);
142
148
  const titleName = optionalString(attrs, "title_field_name", `app "${label}"`, ctx);
143
149
  if (titleName !== undefined || titleFieldDescription !== undefined || systemConfig.has("title")) {
@@ -149,7 +155,8 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
149
155
  }
150
156
  const statusName = optionalString(attrs, "status_field_name", `app "${label}"`, ctx) ?? "Status";
151
157
  const statusOptions = optionsFromTf(attrs["status_options"], `app "${label}" status_options`, ctx);
152
- if (statusName !== "Status" || statusOptions !== undefined || statusFieldDescription !== undefined || systemConfig.has("status")) {
158
+ if (!hasCustomStatusField
159
+ && (statusName !== "Status" || statusOptions !== undefined || statusFieldDescription !== undefined || systemConfig.has("status"))) {
153
160
  const flags = systemConfig.get("status");
154
161
  fields.push({
155
162
  key: "status",
@@ -197,12 +204,7 @@ export function appFromTf(appBlock, fieldBlocks, ctx, viewBlocks = { layoutBlock
197
204
  ctx.diagnostics.push(`app "${label}": stages is not a list; dropped`);
198
205
  }
199
206
  // --- Custom field resources (entities/field).
200
- const owner = { type: APP_RESOURCE_TYPE, label, scope: "app" };
201
- for (const block of fieldBlocks) {
202
- const entry = fieldFromTf(block, owner, ctx);
203
- if (entry !== undefined)
204
- fields.push(entry);
205
- }
207
+ fields.push(...customFields);
206
208
  const appId = ctx.importId(`${APP_RESOURCE_TYPE}.${label}`);
207
209
  if (appId === undefined) {
208
210
  ctx.diagnostics.push(`app "${label}": no import block in the stream — adoption has no identity to bind`);
@@ -14,7 +14,7 @@
14
14
  * Unsupported authoring shapes degrade through `diagnostics` — reported,
15
15
  * never silent, never thrown (plan §4.3).
16
16
  */
17
- import type { ToTfContext } from "../../engine/build/context.js";
17
+ import { type ToTfContext } from "../../engine/build/context.js";
18
18
  import type { BuildFieldMetadata } from "../../graph/types.js";
19
19
  import { type DeployableEntity } from "../../engine/entity.js";
20
20
  import { type TfBlock } from "../../engine/tf/index.js";
@@ -14,7 +14,8 @@
14
14
  * Unsupported authoring shapes degrade through `diagnostics` — reported,
15
15
  * never silent, never thrown (plan §4.3).
16
16
  */
17
- import { SYSTEM_FIELD_HCL_KEY_BY_KEY, SYSTEM_FIELD_KEY_BY_TAG } from "../../core/system-fields.js";
17
+ import { workspaceAspectKey } from "../../engine/build/context.js";
18
+ import { DEPLOY_DEFAULT_STATUS_OPTION_VALUES, SYSTEM_FIELD_HCL_KEY_BY_KEY, SYSTEM_FIELD_KEY_BY_TAG } from "../../core/system-fields.js";
18
19
  import { EntityTfError } from "../../engine/entity.js";
19
20
  import { expr, snakeSlug } from "../../engine/tf/index.js";
20
21
  import { accessPolicyToTf } from "../access-policy/to-tf.js";
@@ -24,6 +25,7 @@ import { dynamicLayoutsToTf } from "../dynamic-layout/to-tf.js";
24
25
  import { fieldToTf } from "../field/to-tf.js";
25
26
  import { SUB_TYPE_BY_TYPE_KEY } from "../field/types.js";
26
27
  import { CATEGORY_ORG_BAG } from "../org/category.js";
28
+ import { categoryIdExpr, missingCategoryDiagnostic } from "../org/category-ref.js";
27
29
  import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
28
30
  import { recordCreateFormToTf } from "../record-create-form/to-tf.js";
29
31
  import { relationshipsToTf } from "../relationship/to-tf.js";
@@ -82,10 +84,10 @@ export function appToTf(entity, ctx) {
82
84
  if (categoryName !== undefined && categoryName !== "") {
83
85
  const category = ctx.orgRefs.byName(CATEGORY_ORG_BAG, categoryName);
84
86
  if (category === undefined) {
85
- ctx.diagnostics.push(`category "${categoryName}" is not in the org catalog — re-run \`elementum pull org --data-only\` (categories must already exist in the org)`);
87
+ ctx.diagnostics.push(missingCategoryDiagnostic(categoryName));
86
88
  }
87
89
  else {
88
- appAttrs["category_id"] = expr.dataAttr("elementum_category", category.tfLabel, ["id"]);
90
+ appAttrs["category_id"] = categoryIdExpr(category);
89
91
  }
90
92
  }
91
93
  const cloudLink = payload.cloudLinkId;
@@ -218,10 +220,12 @@ export function appToTf(entity, ctx) {
218
220
  if (Object.keys(systemFieldConfig).length > 0) {
219
221
  appAttrs["system_field_config"] = systemFieldConfig;
220
222
  }
221
- // For an empty authored create, render the two platform-required defaults
222
- // directly into HCL. plan/apply rejects the same empty authoring when the
223
- // app is already present in state; after create, apply regenerates source.
224
- appAttrs["status_options"] = statusOptions ?? [];
223
+ // Render platform defaults explicitly when no status override is authored.
224
+ // The platform creates these values for an empty list, but returning them
225
+ // after apply would violate Terraform's configured list length.
226
+ appAttrs["status_options"] = statusOptions === undefined || statusOptions.length === 0
227
+ ? DEPLOY_DEFAULT_STATUS_OPTION_VALUES.map((option) => ({ ...option, tags: [...option.tags] }))
228
+ : statusOptions;
225
229
  if (stages === undefined || stages.length === 0) {
226
230
  appAttrs["stages"] = [
227
231
  { key: "stage_1", name: "Stage 1" },
@@ -243,6 +247,7 @@ export function appToTf(entity, ctx) {
243
247
  ownerResourceType: APP_RESOURCE_TYPE,
244
248
  orgRefs: ctx.orgRefs,
245
249
  workspaceAspects: ctx.workspaceAspects,
250
+ availableChartRefNames: ctx.workspaceAspects?.get(workspaceAspectKey("app", ctx.appRefName))?.managedChildRefNames?.get("chart"),
246
251
  diagnostics: ctx.diagnostics,
247
252
  }));
248
253
  blocks.push(...widgetsToTf(payload.widgets, {
@@ -254,6 +259,7 @@ export function appToTf(entity, ctx) {
254
259
  orgRefs: ctx.orgRefs,
255
260
  workspaceAspects: ctx.workspaceAspects,
256
261
  diagnostics: ctx.diagnostics,
262
+ fieldAddresses,
257
263
  }));
258
264
  const { blocks: viewBlocks } = viewToTf(payload.layouts, payload.listViews, payload.calendarViews, payload.kanbanViews, payload.dashboardViews, payload.agentViews, payload.viewOrder, {
259
265
  ownerRefName: ctx.appRefName,
@@ -264,6 +270,7 @@ export function appToTf(entity, ctx) {
264
270
  dashboardKeys: new Set(Object.keys(payload.dashboards ?? {})),
265
271
  orgRefs: ctx.orgRefs,
266
272
  diagnostics: ctx.diagnostics,
273
+ fieldAddresses,
267
274
  });
268
275
  blocks.push(...viewBlocks);
269
276
  const recordCreateForm = recordCreateFormToTf(payload.recordCreateForm, {
@@ -272,6 +279,7 @@ export function appToTf(entity, ctx) {
272
279
  scope: "app",
273
280
  objectId,
274
281
  diagnostics: ctx.diagnostics,
282
+ fieldAddresses,
275
283
  });
276
284
  if (recordCreateForm !== undefined)
277
285
  blocks.push(recordCreateForm);
@@ -282,6 +290,7 @@ export function appToTf(entity, ctx) {
282
290
  diagnostics: ctx.diagnostics,
283
291
  orgRefs: ctx.orgRefs,
284
292
  workspaceAspects: ctx.workspaceAspects,
293
+ fieldAddresses,
285
294
  }));
286
295
  blocks.push(...relationshipsToTf(payload.relationships, {
287
296
  ownerRefName: ctx.appRefName,
@@ -306,6 +315,7 @@ export function appToTf(entity, ctx) {
306
315
  diagnostics: ctx.diagnostics,
307
316
  appRefName: ctx.appRefName,
308
317
  serviceAccounts: payload.serviceAccounts,
318
+ fieldAddresses,
309
319
  });
310
320
  blocks.push(block);
311
321
  }
@@ -228,10 +228,16 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
228
228
  }>;
229
229
  apiRequest<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ApiRequestOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
230
230
  response: unknown;
231
+ file?: unknown;
232
+ statusCode?: unknown;
233
+ textResponse?: unknown;
231
234
  }>;
232
235
  calculation<TName extends string, const Values extends import("./tasks.js").CalculationValues>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").CalculationOptions<Values>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").CalculationValueOutputs<Values>>;
233
236
  calculation<TName extends string, const Entries extends readonly import("./tasks.js").CalculationEntry[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").LegacyCalculationOptions<Entries>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").CalculationOutputs<Entries>>;
234
- procedure<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").ProcedureOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
237
+ procedure<TName extends string, const Parameters extends readonly import("../../catalog/types.js").ProcedureParameterType[]>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").TypedProcedureOptions<Parameters>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
238
+ output: unknown;
239
+ }>;
240
+ procedure<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").LegacyProcedureOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, {
235
241
  output: unknown;
236
242
  }>;
237
243
  runAutomation<TName extends string, const A extends AutomationCatalogRef>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").RunAutomationOptions<A>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").RunAutomationOutput<A>>;
@@ -245,6 +251,7 @@ interface ActionMethods<TTrigger, TActions extends Record<string, unknown>, TVar
245
251
  userSearch<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").UserSearchOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, import("./tasks.js").RecordSearchOutput>;
246
252
  initiateCall<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").InitiateCallOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
247
253
  recordFieldLocking<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").RecordFieldLockingOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
254
+ unimplementedTask<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, import("./tasks.js").UnimplementedTaskOptions>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
248
255
  forEach<TName extends string, TForEachItem>(name: TName, opts: ForEachConfig<TTrigger, TActions, TVars, TItem, TForEachItem>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
249
256
  switch<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, SwitchConfig<TTrigger, TActions, TVars, TItem>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
250
257
  forkJoin<TName extends string>(name: TName, opts: BuilderActionOptions<TTrigger, TActions, TVars, TItem, ForkJoinConfig<TTrigger, TActions, TVars, TItem>>, displayName?: string, hclParent?: "trigger" | string): WithAction<TMode, TItem, TTrigger, TActions, TVars, TName, EmptyObject>;
@@ -27,6 +27,7 @@
27
27
  import { randomUUID } from "crypto";
28
28
  import { valid as validSemver } from "semver";
29
29
  import { EntityTfError } from "../../engine/entity.js";
30
+ import { isOnDemandRecordType } from "../shared/types/field-types.js";
30
31
  import { buildContext, createForEachItemProxy } from "../shared/context.js";
31
32
  import { outputFieldTypesFromScriptSchema } from "./output-field-types.js";
32
33
  import { isRef } from "../shared/ref.js";
@@ -195,8 +196,11 @@ const RECORD_BEARING_TASK_KEYS = new Set(["recordSearch", "createRecord", "findR
195
196
  * - tableRecordsSearch interpolations map `records` → `All matching table
196
197
  * rows` in to-tf (`valueToTf`); do **not** rewrite the name here — ei
197
198
  * publish envelopes keep the authored key `records`.
198
- * - aiAgent: `result` / `result.<field>` → the platform's
199
- * `ai_agent_task_response` (text) / `ai_agent_task_structured_output.<field>` (json).
199
+ * - aiAgent: `result` / `result.<field>` → the provider refs-map key
200
+ * `Action Response` (text) / the authored schema field name (json).
201
+ * The JSON value stored under that key carries the separate platform
202
+ * taskReference.name (`ai_agent_task_response` /
203
+ * `ai_agent_task_structured_output.<normalized-field>`).
200
204
  * - record-bearing tasks: the read path reinjects a `.record` hop on the id
201
205
  * accessor; collapse it back to the platform's flat wire key on write
202
206
  * (recordSearch: `First found record id`; createRecord/findRelatedRecords:
@@ -223,8 +227,8 @@ function rewriteForwardTaskRefName(taskKey, name) {
223
227
  if (segs[0] !== "result")
224
228
  return name;
225
229
  if (segs.length === 1)
226
- return "ai_agent_task_response";
227
- return ["ai_agent_task_structured_output", ...segs.slice(1).map((s) => s.toLowerCase())].join(".");
230
+ return "Action Response";
231
+ return segs.slice(1).join(".");
228
232
  }
229
233
  if (taskKey === "recordSearch" && name === "record.recordId") {
230
234
  return "First found record id";
@@ -367,6 +371,7 @@ function makeActionBuilder(state, mode = "root", item) {
367
371
  userSearch: actionFactories.userSearch,
368
372
  initiateCall: actionFactories.initiateCall,
369
373
  recordFieldLocking: actionFactories.recordFieldLocking,
374
+ unimplementedTask: actionFactories.unimplementedTask,
370
375
  };
371
376
  const directMethods = Object.fromEntries(Object.entries(leafFactories).map(([method, factory]) => [
372
377
  method,
@@ -585,6 +590,7 @@ export function automation(opts) {
585
590
  },
586
591
  def(refName) {
587
592
  const sequence = opts.actions.__finalize();
593
+ const recordFieldContext = mergeOnDemandRecordFieldContext(sequence.recordFieldContext, sequence.trigger);
588
594
  // `recordFieldContext` is a structural extension, not a declared `DeployableEntity`
589
595
  // property (see `RecordFieldContext`'s doc comment) — assigning to `entity`
590
596
  // first (rather than returning the literal directly) avoids an excess-property
@@ -606,9 +612,34 @@ export function automation(opts) {
606
612
  ...(sequence.outputProperties ? { outputProperties: sequence.outputProperties } : {}),
607
613
  },
608
614
  ...(opts.enabled !== undefined ? { enabled: opts.enabled } : {}),
609
- ...(sequence.recordFieldContext !== undefined ? { recordFieldContext: sequence.recordFieldContext } : {}),
615
+ ...(recordFieldContext !== undefined ? { recordFieldContext } : {}),
610
616
  };
611
617
  return entity;
612
618
  },
613
619
  };
614
620
  }
621
+ function mergeOnDemandRecordFieldContext(existing, trigger) {
622
+ const targetRefName = soleOnDemandRecordTargetRefName(trigger);
623
+ if (targetRefName === undefined)
624
+ return existing;
625
+ return {
626
+ ...existing,
627
+ triggerAppRefName: existing?.triggerAppRefName ?? targetRefName,
628
+ };
629
+ }
630
+ function soleOnDemandRecordTargetRefName(trigger) {
631
+ if (typeof trigger !== "object" || trigger === null || !("onDemand" in trigger))
632
+ return undefined;
633
+ const onDemand = trigger.onDemand;
634
+ if (typeof onDemand !== "object" || onDemand === null || !Array.isArray(onDemand.inputs))
635
+ return undefined;
636
+ const targets = onDemand.inputs.flatMap((input) => {
637
+ if (typeof input !== "object" || input === null)
638
+ return [];
639
+ const recordInput = input;
640
+ return isOnDemandRecordType(recordInput.type) && typeof recordInput.app?.refName === "string"
641
+ ? [recordInput.app.refName]
642
+ : [];
643
+ });
644
+ return targets.length === 1 ? targets[0] : undefined;
645
+ }
@@ -65,6 +65,8 @@ export type TriggerAst = {
65
65
  inputs: Array<{
66
66
  name: string;
67
67
  type: string;
68
+ /** Required target for a record input; reconstructed from default_value. */
69
+ app?: AppRefAst | UnresolvedRefAst;
68
70
  required?: boolean;
69
71
  multiple?: boolean;
70
72
  defaultValue?: unknown;
@@ -72,12 +74,6 @@ export type TriggerAst = {
72
74
  }>;
73
75
  /** Round-tripped from the wire's `onDemand.showTriggeredBy` flag. */
74
76
  showTriggeredBy?: boolean;
75
- /**
76
- * Set when a task in this workflow references `ctx.trigger.record` —
77
- * i.e. this on-demand automation is invoked against a specific record.
78
- * Not carried on the wire; inferred by scanning the deserialized tasks.
79
- */
80
- hasRecord?: boolean;
81
77
  } | {
82
78
  kind: "recordCreate" | "recordUpdate" | "attachment";
83
79
  /** The owning app — `{kind: "unresolved", ...}` when the aspect never made it into the pull's catalog. */
@@ -121,7 +117,7 @@ export type TriggerAst = {
121
117
  } | {
122
118
  kind: "approvalProcessStatusUpdated";
123
119
  app: AppRefAst | UnresolvedRefAst;
124
- approvalChain: string | ApprovalChainRefAst;
120
+ approvalChain?: string | ApprovalChainRefAst;
125
121
  status: "ACTIVE" | "STEP_APPROVED" | "CANCELLED" | "DENIED" | "APPROVED";
126
122
  } | {
127
123
  kind: "schedule";
@@ -32,6 +32,8 @@
32
32
  */
33
33
  import type { AutomationAst } from "./ast.js";
34
34
  import type { UnresolvedReferenceDiagnostic } from "../../../graph/types.js";
35
+ /** Keep the authored publish token across pull; live workflow versions are not author intent. */
36
+ export declare function preserveAuthoredAutomationRevision(freshSource: string, existingSource: string): string;
35
37
  export interface PrintAutomationV2Options {
36
38
  readonly refName?: string;
37
39
  /**