@elementumai/edk 0.8.0-preview.11 → 0.8.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 (165) hide show
  1. package/README.md +378 -324
  2. package/dist-sdk/src/catalog/ai-provider-models.d.ts +30 -0
  3. package/dist-sdk/src/catalog/ai-provider-models.js +63 -0
  4. package/dist-sdk/src/catalog/factories.d.ts +56 -3
  5. package/dist-sdk/src/catalog/factories.js +65 -2
  6. package/dist-sdk/src/catalog/from-authoring.js +6 -1
  7. package/dist-sdk/src/catalog/index.d.ts +3 -2
  8. package/dist-sdk/src/catalog/index.js +3 -2
  9. package/dist-sdk/src/catalog/org.d.ts +1 -1
  10. package/dist-sdk/src/catalog/org.js +83 -6
  11. package/dist-sdk/src/catalog/render.d.ts +13 -1
  12. package/dist-sdk/src/catalog/render.js +21 -4
  13. package/dist-sdk/src/catalog/token.js +14 -0
  14. package/dist-sdk/src/catalog/types.d.ts +60 -3
  15. package/dist-sdk/src/catalog/types.js +3 -0
  16. package/dist-sdk/src/core/system-fields.d.ts +2 -0
  17. package/dist-sdk/src/core/system-fields.js +2 -0
  18. package/dist-sdk/src/core/types/ai-provider.d.ts +10 -23
  19. package/dist-sdk/src/core/types/ai-provider.js +1 -25
  20. package/dist-sdk/src/core/types/app.d.ts +20 -1
  21. package/dist-sdk/src/engine/build/context.d.ts +18 -0
  22. package/dist-sdk/src/engine/build/source-context.d.ts +45 -0
  23. package/dist-sdk/src/engine/build/source-context.js +23 -0
  24. package/dist-sdk/src/engine/pull/context.d.ts +15 -0
  25. package/dist-sdk/src/engine/pull/org.d.ts +10 -0
  26. package/dist-sdk/src/engine/pull/org.js +34 -4
  27. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  28. package/dist-sdk/src/engine/tf/index.js +1 -1
  29. package/dist-sdk/src/engine/tf/labels.d.ts +45 -0
  30. package/dist-sdk/src/engine/tf/labels.js +71 -0
  31. package/dist-sdk/src/entities/access-policy/build.d.ts +26 -0
  32. package/dist-sdk/src/entities/access-policy/build.js +7 -0
  33. package/dist-sdk/src/entities/access-policy/filter.d.ts +61 -0
  34. package/dist-sdk/src/entities/access-policy/filter.js +83 -0
  35. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +48 -0
  36. package/dist-sdk/src/entities/access-policy/from-tf.js +189 -0
  37. package/dist-sdk/src/entities/access-policy/module.d.ts +3 -0
  38. package/dist-sdk/src/entities/access-policy/module.js +17 -0
  39. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +36 -0
  40. package/dist-sdk/src/entities/access-policy/to-tf.js +149 -0
  41. package/dist-sdk/src/entities/access-policy/types.d.ts +4 -0
  42. package/dist-sdk/src/entities/access-policy/types.js +10 -0
  43. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +38 -3
  44. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +199 -32
  45. package/dist-sdk/src/entities/agent/from-tf.d.ts +18 -3
  46. package/dist-sdk/src/entities/agent/from-tf.js +135 -15
  47. package/dist-sdk/src/entities/agent/index.d.ts +1 -1
  48. package/dist-sdk/src/entities/agent/module.js +8 -2
  49. package/dist-sdk/src/entities/agent/to-tf.js +62 -10
  50. package/dist-sdk/src/entities/agent/tools.d.ts +88 -9
  51. package/dist-sdk/src/entities/agent/tools.js +46 -7
  52. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +51 -4
  53. package/dist-sdk/src/entities/agent-tool/from-tf.js +131 -35
  54. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +4 -2
  55. package/dist-sdk/src/entities/agent-tool/to-tf.js +103 -17
  56. package/dist-sdk/src/entities/agent-tool/types.d.ts +5 -4
  57. package/dist-sdk/src/entities/agent-tool/types.js +38 -6
  58. package/dist-sdk/src/entities/app/build.d.ts +63 -13
  59. package/dist-sdk/src/entities/app/build.js +48 -1
  60. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +3 -0
  61. package/dist-sdk/src/entities/app/from-tf.d.ts +1 -1
  62. package/dist-sdk/src/entities/app/from-tf.js +32 -15
  63. package/dist-sdk/src/entities/app/index.d.ts +4 -1
  64. package/dist-sdk/src/entities/app/index.js +2 -1
  65. package/dist-sdk/src/entities/app/module.js +9 -2
  66. package/dist-sdk/src/entities/app/to-tf.d.ts +5 -0
  67. package/dist-sdk/src/entities/app/to-tf.js +33 -4
  68. package/dist-sdk/src/entities/automation/build.d.ts +57 -13
  69. package/dist-sdk/src/entities/automation/build.js +48 -36
  70. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +25 -8
  71. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +16 -1
  72. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +179 -43
  73. package/dist-sdk/src/entities/automation/filter.d.ts +15 -3
  74. package/dist-sdk/src/entities/automation/filter.js +12 -2
  75. package/dist-sdk/src/entities/automation/from-tf.d.ts +26 -27
  76. package/dist-sdk/src/entities/automation/from-tf.js +1229 -223
  77. package/dist-sdk/src/entities/automation/index.d.ts +4 -0
  78. package/dist-sdk/src/entities/automation/index.js +4 -0
  79. package/dist-sdk/src/entities/automation/module.js +29 -32
  80. package/dist-sdk/src/entities/automation/operators.d.ts +29 -2
  81. package/dist-sdk/src/entities/automation/operators.js +27 -1
  82. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +19 -0
  83. package/dist-sdk/src/entities/automation/output-key-wire-name.js +24 -0
  84. package/dist-sdk/src/entities/automation/script-code.d.ts +10 -21
  85. package/dist-sdk/src/entities/automation/script-code.js +272 -5
  86. package/dist-sdk/src/entities/automation/tasks.d.ts +125 -19
  87. package/dist-sdk/src/entities/automation/tasks.js +83 -15
  88. package/dist-sdk/src/entities/automation/to-tf.d.ts +10 -29
  89. package/dist-sdk/src/entities/automation/to-tf.js +1134 -231
  90. package/dist-sdk/src/entities/automation/triggers.d.ts +9 -1
  91. package/dist-sdk/src/entities/automation/types.d.ts +29 -4
  92. package/dist-sdk/src/entities/automation/types.js +76 -46
  93. package/dist-sdk/src/entities/element/build.d.ts +23 -10
  94. package/dist-sdk/src/entities/element/build.js +1 -0
  95. package/dist-sdk/src/entities/element/from-tf.d.ts +1 -1
  96. package/dist-sdk/src/entities/element/from-tf.js +18 -3
  97. package/dist-sdk/src/entities/element/index.d.ts +4 -1
  98. package/dist-sdk/src/entities/element/index.js +2 -1
  99. package/dist-sdk/src/entities/element/module.js +3 -1
  100. package/dist-sdk/src/entities/element/to-tf.js +21 -3
  101. package/dist-sdk/src/entities/field/build.d.ts +56 -13
  102. package/dist-sdk/src/entities/field/build.js +10 -0
  103. package/dist-sdk/src/entities/field/calc/runtime.js +4 -0
  104. package/dist-sdk/src/entities/field/from-tf.d.ts +5 -3
  105. package/dist-sdk/src/entities/field/from-tf.js +118 -7
  106. package/dist-sdk/src/entities/field/module.js +3 -2
  107. package/dist-sdk/src/entities/field/to-tf.d.ts +27 -9
  108. package/dist-sdk/src/entities/field/to-tf.js +62 -17
  109. package/dist-sdk/src/entities/field/types.d.ts +26 -0
  110. package/dist-sdk/src/entities/field/types.js +34 -12
  111. package/dist-sdk/src/entities/file-reader/build.d.ts +108 -50
  112. package/dist-sdk/src/entities/file-reader/build.js +23 -23
  113. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.d.ts +6 -0
  114. package/dist-sdk/src/entities/file-reader/deserializer/print-file-reader.js +109 -0
  115. package/dist-sdk/src/entities/file-reader/from-tf.d.ts +13 -0
  116. package/dist-sdk/src/entities/file-reader/from-tf.js +172 -0
  117. package/dist-sdk/src/entities/file-reader/index.d.ts +8 -3
  118. package/dist-sdk/src/entities/file-reader/index.js +7 -2
  119. package/dist-sdk/src/entities/file-reader/module.d.ts +3 -0
  120. package/dist-sdk/src/entities/file-reader/module.js +115 -0
  121. package/dist-sdk/src/entities/file-reader/to-tf.d.ts +14 -0
  122. package/dist-sdk/src/entities/file-reader/to-tf.js +84 -0
  123. package/dist-sdk/src/entities/file-reader/types.d.ts +32 -0
  124. package/dist-sdk/src/entities/file-reader/types.js +30 -0
  125. package/dist-sdk/src/entities/org/ai-provider.d.ts +13 -0
  126. package/dist-sdk/src/entities/org/ai-provider.js +46 -0
  127. package/dist-sdk/src/entities/org/connector.d.ts +8 -1
  128. package/dist-sdk/src/entities/org/connector.js +12 -14
  129. package/dist-sdk/src/entities/org/group.js +10 -1
  130. package/dist-sdk/src/entities/org/index.d.ts +1 -0
  131. package/dist-sdk/src/entities/org/index.js +1 -0
  132. package/dist-sdk/src/entities/org/user.js +10 -1
  133. package/dist-sdk/src/entities/shared/filters/ast.d.ts +44 -9
  134. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  135. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +17 -0
  136. package/dist-sdk/src/entities/shared/tool-field-ref.js +31 -0
  137. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -1
  138. package/dist-sdk/src/entities/shared/types/field-types.js +9 -0
  139. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +19 -0
  140. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -8
  141. package/dist-sdk/src/entities/skill/from-tf.js +4 -3
  142. package/dist-sdk/src/entities/skill/index.d.ts +1 -1
  143. package/dist-sdk/src/entities/skill/module.js +6 -1
  144. package/dist-sdk/src/entities/skill/to-tf.js +3 -2
  145. package/dist-sdk/src/entities/skill/tools.d.ts +25 -3
  146. package/dist-sdk/src/entities/skill/tools.js +17 -0
  147. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +15 -2
  148. package/dist-sdk/src/entities/skill-tool/from-tf.js +32 -11
  149. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +2 -0
  150. package/dist-sdk/src/entities/skill-tool/to-tf.js +32 -9
  151. package/dist-sdk/src/entities/view/from-tf.d.ts +6 -2
  152. package/dist-sdk/src/entities/view/from-tf.js +11 -9
  153. package/dist-sdk/src/entities/view/to-tf.d.ts +9 -7
  154. package/dist-sdk/src/entities/view/to-tf.js +33 -18
  155. package/dist-sdk/src/entities/view/types.d.ts +1 -1
  156. package/dist-sdk/src/entities/view/types.js +1 -1
  157. package/dist-sdk/src/graph/deferred-catalog-render.d.ts +0 -5
  158. package/dist-sdk/src/graph/deferred-catalog-render.js +1 -20
  159. package/dist-sdk/src/graph/index.d.ts +8 -0
  160. package/dist-sdk/src/graph/index.js +13 -9
  161. package/dist-sdk/src/graph/modules.js +6 -1
  162. package/dist-sdk/src/graph/types.d.ts +77 -3
  163. package/package.json +42 -14
  164. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +0 -76
  165. package/dist-sdk/src/entities/automation/value-ref-tf.js +0 -190
@@ -69,7 +69,7 @@ type NormalizeSpec<S extends TriggerInputSchemaSpec> = {
69
69
  type: S[K];
70
70
  } : Extract<S[K], TriggerInputFieldDef>;
71
71
  };
72
- export declare function onDemand<S extends TriggerInputSchemaSpec, Options extends OnDemandTriggerOptions = {}>(schema: S, options?: Options): TriggerChain<InferTriggerType<NormalizeSpec<S> & TriggerInputSchema, Options>>;
72
+ export declare function onDemand<S extends TriggerInputSchemaSpec, Options extends OnDemandTriggerOptions = Record<string, never>>(schema: S, options?: Options): TriggerChain<InferTriggerType<NormalizeSpec<S> & TriggerInputSchema, Options>>;
73
73
  export interface WebhookTriggerOptions {
74
74
  readonly authenticated?: boolean;
75
75
  /** Pre-built wire custom-response envelope. */
@@ -183,6 +183,14 @@ export interface SlackMessageTriggerOutput {
183
183
  readonly content: string;
184
184
  readonly messageId: string;
185
185
  readonly meta: Record<string, unknown>;
186
+ /** Compatibility aliases retained for existing automations. */
187
+ readonly slackThreadId: string;
188
+ readonly slackChannelId: string;
189
+ readonly messageAuthorEmail: string;
190
+ readonly messageAuthorId: string;
191
+ readonly messageAuthorName: string;
192
+ readonly messageContent: string;
193
+ readonly messageMetadata: Record<string, unknown>;
186
194
  }
187
195
  /** Fires when a Slack message is received. */
188
196
  export declare function slackMessage(): TriggerChain<SlackMessageTriggerOutput>;
@@ -31,12 +31,17 @@ export declare const WORKFLOW_PUBLISH_RESOURCE_TYPE = "elementum_workflow_publis
31
31
  /** Trigger kinds. One trigger per automation. Phase 1: onDemand only. */
32
32
  export declare const TRIGGER_SUB_TYPES: readonly AutomationSubType[];
33
33
  /**
34
- * Task kinds. Implemented: `executeScript` and `variable` (setVariable's
35
- * create form — the tf dialect carries ONE variable per task as
36
- * variable_name/variable_type/value, and the provider's variable_id is
37
- * COMPUTED, so the compose-path client UUID never reaches HCL).
34
+ * Task kinds. All rows are implemented as of `aiFileAnalysis` (the last
35
+ * holdout — it needs its `elementum_ai_file_reader` target to also round-trip,
36
+ * see `entities/file-reader/types.ts`). `variable` (setVariable's create
37
+ * form) is the one worth calling out: the tf dialect carries ONE variable per
38
+ * task as variable_name/variable_type/value, and the provider's variable_id
39
+ * is COMPUTED, so the compose-path client UUID never reaches HCL. A future
40
+ * new task kind lands here declared-only first (see the doc comment on
41
+ * {@link ALL_AUTOMATION_TASK_TYPE_SET} below) until its row flips implemented.
38
42
  */
39
43
  export declare const TASK_SUB_TYPES: readonly AutomationSubType[];
44
+ export declare const BRANCH_SUB_TYPES: readonly AutomationSubType[];
40
45
  export declare const ALL_AUTOMATION_SUB_TYPES: readonly AutomationSubType[];
41
46
  export declare const AUTOMATION_SUB_TYPE_BY_TYPE_KEY: ReadonlyMap<string, AutomationSubType>;
42
47
  export declare const AUTOMATION_SUB_TYPE_BY_RESOURCE: ReadonlyMap<string, AutomationSubType>;
@@ -51,3 +56,23 @@ export declare const IMPLEMENTED_TASK_RESOURCE_TYPES: readonly string[];
51
56
  export declare const IMPLEMENTED_AUTOMATION_RESOURCE_TYPES: readonly string[];
52
57
  /** Every declared automation-family resource type — the partition recognizes these by name. */
53
58
  export declare const ALL_AUTOMATION_RESOURCE_TYPES: readonly string[];
59
+ export declare const AUTOMATION_RESOURCE_TYPES: readonly string[];
60
+ export declare const AUTOMATION_TRIGGER_TYPES: readonly string[];
61
+ export declare const AUTOMATION_TASK_TYPES: readonly string[];
62
+ export declare const AUTOMATION_BRANCH_TYPES: string[];
63
+ export declare const AUTOMATION_TRIGGER_TYPE_SET: ReadonlySet<string>;
64
+ export declare const AUTOMATION_TASK_TYPE_SET: ReadonlySet<string>;
65
+ /**
66
+ * Every DECLARED task resource type, implemented or not — for from-tf's graph
67
+ * walk (which task blocks belong to this automation's tree) and its
68
+ * dependency-recognition checks. Deliberately broader than
69
+ * {@link AUTOMATION_TASK_TYPE_SET} (implemented-only, the adoption/build-vs-export
70
+ * scope): a declared-but-unimplemented type (none currently declared — a
71
+ * future new task kind lands here first, before its row flips implemented)
72
+ * must still be walked into the task graph so from-tf's own dedicated
73
+ * diagnostic for it fires, rather than the block silently falling out of the
74
+ * graph and surfacing as an unrelated "unresolved parent"/"orphaned task"
75
+ * error.
76
+ */
77
+ export declare const ALL_AUTOMATION_TASK_TYPE_SET: ReadonlySet<string>;
78
+ export declare const AUTOMATION_BRANCH_TYPE_SET: ReadonlySet<string>;
@@ -23,60 +23,69 @@ export const WORKFLOW_PUBLISH_RESOURCE_TYPE = "elementum_workflow_publish";
23
23
  /** Trigger kinds. One trigger per automation. Phase 1: onDemand only. */
24
24
  export const TRIGGER_SUB_TYPES = [
25
25
  { typeKey: "onDemand", resourceType: "elementum_on_demand_trigger", implemented: true },
26
- { typeKey: "createRecord", resourceType: "elementum_record_created_trigger" },
27
- { typeKey: "updateRecord", resourceType: "elementum_record_updated_trigger" },
28
- { typeKey: "webhook", resourceType: "elementum_webhook_trigger" },
29
- { typeKey: "approvalChain", resourceType: "elementum_approval_chain_trigger" },
30
- { typeKey: "attachment", resourceType: "elementum_attachment_added_trigger" },
31
- { typeKey: "datamine", resourceType: "elementum_datamine_trigger" },
32
- { typeKey: "emailReceived", resourceType: "elementum_email_ingestion_trigger" },
33
- { typeKey: "commentAdded", resourceType: "elementum_comment_added_trigger" },
34
- { typeKey: "conversationEnd", resourceType: "elementum_agent_conversation_ended_trigger" },
35
- { typeKey: "slackMessage", resourceType: "elementum_slack_message_trigger" },
26
+ { typeKey: "createRecord", resourceType: "elementum_record_created_trigger", implemented: true },
27
+ { typeKey: "updateRecord", resourceType: "elementum_record_updated_trigger", implemented: true },
28
+ { typeKey: "webhook", resourceType: "elementum_webhook_trigger", implemented: true },
29
+ { typeKey: "approvalChain", resourceType: "elementum_approval_chain_trigger", implemented: true },
30
+ { typeKey: "attachment", resourceType: "elementum_attachment_added_trigger", implemented: true },
31
+ { typeKey: "datamine", resourceType: "elementum_datamine_trigger", implemented: true },
32
+ { typeKey: "emailReceived", resourceType: "elementum_email_ingestion_trigger", implemented: true },
33
+ { typeKey: "commentAdded", resourceType: "elementum_comment_added_trigger", implemented: true },
34
+ { typeKey: "conversationEnd", resourceType: "elementum_agent_conversation_ended_trigger", implemented: true },
35
+ { typeKey: "slackMessage", resourceType: "elementum_slack_message_trigger", implemented: true },
36
+ { typeKey: "survey", resourceType: "elementum_survey_trigger", implemented: true },
36
37
  ];
37
38
  /**
38
- * Task kinds. Implemented: `executeScript` and `variable` (setVariable's
39
- * create form — the tf dialect carries ONE variable per task as
40
- * variable_name/variable_type/value, and the provider's variable_id is
41
- * COMPUTED, so the compose-path client UUID never reaches HCL).
39
+ * Task kinds. All rows are implemented as of `aiFileAnalysis` (the last
40
+ * holdout — it needs its `elementum_ai_file_reader` target to also round-trip,
41
+ * see `entities/file-reader/types.ts`). `variable` (setVariable's create
42
+ * form) is the one worth calling out: the tf dialect carries ONE variable per
43
+ * task as variable_name/variable_type/value, and the provider's variable_id
44
+ * is COMPUTED, so the compose-path client UUID never reaches HCL. A future
45
+ * new task kind lands here declared-only first (see the doc comment on
46
+ * {@link ALL_AUTOMATION_TASK_TYPE_SET} below) until its row flips implemented.
42
47
  */
43
48
  export const TASK_SUB_TYPES = [
44
49
  { typeKey: "executeScript", resourceType: "elementum_execute_script_task", implemented: true },
45
50
  { typeKey: "variable", resourceType: "elementum_variable_task", implemented: true },
46
- // Declared-only (stream-reported until their rows flip implemented):
47
- { typeKey: "updateVariable", resourceType: "elementum_update_variable_task" },
48
- { typeKey: "updateField", resourceType: "elementum_update_field_task" },
49
- { typeKey: "recordSearch", resourceType: "elementum_record_search_task" },
50
- { typeKey: "tableRecordsSearch", resourceType: "elementum_table_records_search_task" },
51
- { typeKey: "createRecord", resourceType: "elementum_create_record_task" },
52
- { typeKey: "findRelatedRecords", resourceType: "elementum_find_related_records_task" },
53
- { typeKey: "relateRecords", resourceType: "elementum_relate_records_task" },
54
- { typeKey: "sendEmail", resourceType: "elementum_send_email_task" },
55
- { typeKey: "message", resourceType: "elementum_message_task" },
56
- { typeKey: "notification", resourceType: "elementum_notification_task" },
57
- { typeKey: "aiAgent", resourceType: "elementum_ai_agent_task" },
58
- { typeKey: "aiClassify", resourceType: "elementum_ai_classify_task" },
59
- { typeKey: "aiSummarize", resourceType: "elementum_ai_summarize_task" },
60
- { typeKey: "aiTransform", resourceType: "elementum_ai_transform_task" },
61
- { typeKey: "aiSearchTable", resourceType: "elementum_ai_search_table_task" },
62
- { typeKey: "aiFileAnalysis", resourceType: "elementum_ai_file_read_task" },
63
- { typeKey: "apiRequest", resourceType: "elementum_api_task" },
64
- { typeKey: "calculation", resourceType: "elementum_calculation_task" },
65
- { typeKey: "procedure", resourceType: "elementum_procedure_task" },
66
- { typeKey: "runAutomation", resourceType: "elementum_run_automation_task" },
67
- { typeKey: "fileReader", resourceType: "elementum_file_reader_task" },
68
- { typeKey: "approvalChain", resourceType: "elementum_approval_chain_task" },
69
- { typeKey: "approvalStatusUpdate", resourceType: "elementum_approval_status_update_task" },
70
- { typeKey: "addWatcher", resourceType: "elementum_add_watcher_task" },
71
- { typeKey: "saveAttachment", resourceType: "elementum_save_attachment_task" },
72
- { typeKey: "userSearch", resourceType: "elementum_user_search_task" },
73
- { typeKey: "recordFieldLocking", resourceType: "elementum_aspect_record_field_locking_task" },
51
+ { typeKey: "updateVariable", resourceType: "elementum_update_variable_task", implemented: true },
52
+ { typeKey: "updateField", resourceType: "elementum_update_field_task", implemented: true },
53
+ { typeKey: "recordSearch", resourceType: "elementum_record_search_task", implemented: true },
54
+ { typeKey: "tableRecordsSearch", resourceType: "elementum_table_records_search_task", implemented: true },
55
+ { typeKey: "createRecord", resourceType: "elementum_create_record_task", implemented: true },
56
+ { typeKey: "findRelatedRecords", resourceType: "elementum_find_related_records_task", implemented: true },
57
+ { typeKey: "relateRecords", resourceType: "elementum_relate_records_task", implemented: true },
58
+ { typeKey: "sendEmail", resourceType: "elementum_send_email_task", implemented: true },
59
+ { typeKey: "message", resourceType: "elementum_message_task", implemented: true },
60
+ { typeKey: "notification", resourceType: "elementum_notification_task", implemented: true },
61
+ { typeKey: "aiAgent", resourceType: "elementum_ai_agent_task", implemented: true },
62
+ { typeKey: "aiClassify", resourceType: "elementum_ai_classify_task", implemented: true },
63
+ { typeKey: "aiSummarize", resourceType: "elementum_ai_summarize_task", implemented: true },
64
+ { typeKey: "aiTransform", resourceType: "elementum_ai_transform_task", implemented: true },
65
+ { typeKey: "aiSearchTable", resourceType: "elementum_ai_search_table_task", implemented: true },
66
+ { typeKey: "aiFileAnalysis", resourceType: "elementum_ai_file_read_task", implemented: true },
67
+ { typeKey: "api", resourceType: "elementum_api_task", implemented: true },
68
+ { typeKey: "calculation", resourceType: "elementum_calculation_task", implemented: true },
69
+ { typeKey: "procedure", resourceType: "elementum_procedure_task", implemented: true },
70
+ { typeKey: "runAutomation", resourceType: "elementum_run_automation_task", implemented: true },
71
+ { typeKey: "documentModel", resourceType: "elementum_file_reader_task", implemented: true },
72
+ { typeKey: "approvalChain", resourceType: "elementum_approval_chain_task", implemented: true },
73
+ { typeKey: "approvalStatusUpdate", resourceType: "elementum_approval_status_update_task", implemented: true },
74
+ { typeKey: "addWatcher", resourceType: "elementum_add_watcher_task", implemented: true },
75
+ { typeKey: "saveAttachment", resourceType: "elementum_save_attachment_task", implemented: true },
76
+ { typeKey: "userSearch", resourceType: "elementum_user_search_task", implemented: true },
77
+ { typeKey: "aspectRecordFieldLocking", resourceType: "elementum_aspect_record_field_locking_task", implemented: true },
78
+ { typeKey: "initiateCall", resourceType: "elementum_initiate_call_task", implemented: true },
74
79
  // Operators (branching) — later phases:
75
- { typeKey: "forEach", resourceType: "elementum_for_each_task" },
76
- { typeKey: "forkJoin", resourceType: "elementum_fork_join_task" },
77
- { typeKey: "switch", resourceType: "elementum_switch_task" },
80
+ { typeKey: "forEach", resourceType: "elementum_for_each_task", implemented: true },
81
+ { typeKey: "forkJoin", resourceType: "elementum_fork_join_task", implemented: true },
82
+ { typeKey: "switch", resourceType: "elementum_switch_task", implemented: true },
78
83
  ];
79
- export const ALL_AUTOMATION_SUB_TYPES = [...TRIGGER_SUB_TYPES, ...TASK_SUB_TYPES];
84
+ export const BRANCH_SUB_TYPES = [
85
+ { typeKey: "switchCase", resourceType: "elementum_switch_case", implemented: true },
86
+ { typeKey: "forkJoinBranch", resourceType: "elementum_fork_join_branch", implemented: true },
87
+ ];
88
+ export const ALL_AUTOMATION_SUB_TYPES = [...TRIGGER_SUB_TYPES, ...TASK_SUB_TYPES, ...BRANCH_SUB_TYPES];
80
89
  export const AUTOMATION_SUB_TYPE_BY_TYPE_KEY = new Map(ALL_AUTOMATION_SUB_TYPES.map((t) => [t.typeKey, t]));
81
90
  export const AUTOMATION_SUB_TYPE_BY_RESOURCE = new Map(ALL_AUTOMATION_SUB_TYPES.map((t) => [t.resourceType, t]));
82
91
  /** Trigger/task resource types the terraform path round-trips today. */
@@ -92,6 +101,7 @@ export const IMPLEMENTED_AUTOMATION_RESOURCE_TYPES = [
92
101
  WORKFLOW_PUBLISH_RESOURCE_TYPE,
93
102
  ...IMPLEMENTED_TRIGGER_RESOURCE_TYPES,
94
103
  ...IMPLEMENTED_TASK_RESOURCE_TYPES,
104
+ ...BRANCH_SUB_TYPES.map((t) => t.resourceType),
95
105
  ];
96
106
  /** Every declared automation-family resource type — the partition recognizes these by name. */
97
107
  export const ALL_AUTOMATION_RESOURCE_TYPES = [
@@ -99,3 +109,23 @@ export const ALL_AUTOMATION_RESOURCE_TYPES = [
99
109
  WORKFLOW_PUBLISH_RESOURCE_TYPE,
100
110
  ...ALL_AUTOMATION_SUB_TYPES.map((t) => t.resourceType),
101
111
  ];
112
+ export const AUTOMATION_RESOURCE_TYPES = IMPLEMENTED_AUTOMATION_RESOURCE_TYPES;
113
+ export const AUTOMATION_TRIGGER_TYPES = IMPLEMENTED_TRIGGER_RESOURCE_TYPES;
114
+ export const AUTOMATION_TASK_TYPES = IMPLEMENTED_TASK_RESOURCE_TYPES;
115
+ export const AUTOMATION_BRANCH_TYPES = BRANCH_SUB_TYPES.map((t) => t.resourceType);
116
+ export const AUTOMATION_TRIGGER_TYPE_SET = new Set(AUTOMATION_TRIGGER_TYPES);
117
+ export const AUTOMATION_TASK_TYPE_SET = new Set(AUTOMATION_TASK_TYPES);
118
+ /**
119
+ * Every DECLARED task resource type, implemented or not — for from-tf's graph
120
+ * walk (which task blocks belong to this automation's tree) and its
121
+ * dependency-recognition checks. Deliberately broader than
122
+ * {@link AUTOMATION_TASK_TYPE_SET} (implemented-only, the adoption/build-vs-export
123
+ * scope): a declared-but-unimplemented type (none currently declared — a
124
+ * future new task kind lands here first, before its row flips implemented)
125
+ * must still be walked into the task graph so from-tf's own dedicated
126
+ * diagnostic for it fires, rather than the block silently falling out of the
127
+ * graph and surfacing as an unrelated "unresolved parent"/"orphaned task"
128
+ * error.
129
+ */
130
+ export const ALL_AUTOMATION_TASK_TYPE_SET = new Set(TASK_SUB_TYPES.map((t) => t.resourceType));
131
+ export const AUTOMATION_BRANCH_TYPE_SET = new Set(AUTOMATION_BRANCH_TYPES);
@@ -24,8 +24,9 @@
24
24
  */
25
25
  import { type AspectRef, type CloudLinkRef, type FieldRef } from "../../catalog/index.js";
26
26
  import type { DeployableEntity, EntityDeployOptions } from "../../engine/entity.js";
27
+ import type { AccessPolicyOptions } from "../access-policy/build.js";
27
28
  import { type DisplayBlock } from "../app/display-blocks.js";
28
- import { type AppCategory, type AppCloudOptions, type AppField, type AppLayout, type AppListView } from "../app/build.js";
29
+ import { type AppCategory, type AppCloudOptions, type AppField, type AppFieldRefs, type AppLayout, type AppListView } from "../app/build.js";
29
30
  export type { AppCategory, AppField, AppLayout, AppListView, PicklistOption } from "../app/build.js";
30
31
  /**
31
32
  * The source table a LINKED element maps to — an existing table in the
@@ -47,7 +48,7 @@ export interface ElementCloudConnection {
47
48
  /** The record-id source column on the mapped table. */
48
49
  readonly idColumnName?: string;
49
50
  }
50
- export interface ElementV2Options extends EntityDeployOptions {
51
+ export interface ElementV2Options<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> extends EntityDeployOptions {
51
52
  /** The platform's aspect handle (business acronym, e.g. "PRD") — distinct from the refName. Omit to let the platform assign one. */
52
53
  readonly handle?: string;
53
54
  readonly name: string;
@@ -69,13 +70,13 @@ export interface ElementV2Options extends EntityDeployOptions {
69
70
  /** Whether the comments display block is enabled. Omit to leave the platform's current value alone. */
70
71
  readonly commentsEnabled?: boolean;
71
72
  /** Fields keyed by ref name. At least one required by the compose API. */
72
- readonly fields: Record<string, AppField>;
73
+ readonly fields: F;
73
74
  /**
74
75
  * Platform-managed (system) fields that exist on every element but are not authored here — e.g.
75
76
  * ID, Created on. These flow into `ref().fields` so other entities can reference them by typed
76
77
  * handle, but are **never included in the deploy payload** (the platform owns them).
77
78
  */
78
- readonly readonlyFields?: Record<string, FieldRef>;
79
+ readonly readonlyFields?: R;
79
80
  /** Record-view (LAYOUT surface) display blocks. */
80
81
  readonly displayBlocks?: readonly DisplayBlock[];
81
82
  /** New-record form (CREATE surface) display blocks. */
@@ -89,10 +90,22 @@ export interface ElementV2Options extends EntityDeployOptions {
89
90
  readonly listViews?: Readonly<Record<string, AppListView>>;
90
91
  /** Display order of `listViews` (by key). Defaults to declaration order. */
91
92
  readonly viewOrder?: readonly string[];
93
+ /** Element-level sharing & row-level-security policies (`elementum_access_policy`), in declaration order. */
94
+ readonly accessPolicies?: readonly AccessPolicyOptions[];
92
95
  }
93
- /** An element's reference surface: identity plus its fields (the only bag other entities may point at). */
94
- export type ElementRef = AspectRef & {
95
- readonly fields: Record<string, FieldRef>;
96
+ /**
97
+ * An element's reference surface: identity plus its fields (the only bag
98
+ * other entities may point at). Generic over the authored `fields:` bag
99
+ * (`F`) and `readonlyFields:` bag (`R`) — see `AppRef` in
100
+ * `entities/app/build.ts` for the full rationale, including why `R`'s
101
+ * default is `Record<never, never>` rather than a wide `Record<string,
102
+ * FieldRef>` (a `string`-keyed index signature anywhere here poisons
103
+ * `DeepRef`'s downstream re-mapping for `ctx.trigger.record`/`ctx.tasks.<t>.
104
+ * record`). Elements have no synthesized system fields the way apps do, so
105
+ * unlike `AppRef` there's no `Record<SystemFieldKey, FieldRef>` term here.
106
+ */
107
+ export type ElementRef<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> = AspectRef & {
108
+ readonly fields: AppFieldRefs<F> & R;
96
109
  };
97
110
  /**
98
111
  * The configured result of `defineElement` — its reference surface (`ref()`)
@@ -100,9 +113,9 @@ export type ElementRef = AspectRef & {
100
113
  * argument**, not a constructor option — see `AppConfigured` in
101
114
  * `src/aspects/build.ts` for the full rationale (identical here).
102
115
  */
103
- export interface ElementConfigured {
104
- ref(refName: string): ElementRef;
116
+ export interface ElementConfigured<F extends Record<string, AppField> = Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>> {
117
+ ref(refName: string): ElementRef<F, R>;
105
118
  def(refName: string): DeployableEntity;
106
119
  }
107
120
  /** Build a v2 element entity: org-owned, compose-body payload. Exposes `.ref(refName)` and `.def(refName)`. */
108
- export declare function defineElement(opts: ElementV2Options): ElementConfigured;
121
+ export declare function defineElement<F extends Record<string, AppField>, R extends Record<string, FieldRef> = Record<never, never>>(opts: ElementV2Options<F, R>): ElementConfigured<F, R>;
@@ -96,6 +96,7 @@ export function defineElement(opts) {
96
96
  ...(opts.layouts !== undefined ? { layouts: opts.layouts } : {}),
97
97
  ...(opts.listViews !== undefined ? { listViews: opts.listViews } : {}),
98
98
  ...(opts.viewOrder !== undefined ? { viewOrder: opts.viewOrder } : {}),
99
+ ...(opts.accessPolicies !== undefined ? { accessPolicies: opts.accessPolicies } : {}),
99
100
  };
100
101
  return {
101
102
  kind: "element",
@@ -16,4 +16,4 @@ export interface ElementFromTfViewBlocks {
16
16
  readonly listViewBlocks: readonly TfBlock[];
17
17
  readonly managedViewOrderBlocks: readonly TfBlock[];
18
18
  }
19
- export declare function elementFromTf(elementBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: ElementFromTfViewBlocks): ElementFromTfResult;
19
+ export declare function elementFromTf(elementBlock: TfBlock, fieldBlocks: readonly TfBlock[], ctx: FromTfContext, viewBlocks?: ElementFromTfViewBlocks, accessPolicyBlocks?: readonly TfBlock[]): ElementFromTfResult;
@@ -6,6 +6,7 @@
6
6
  import { EntityTfError } from "../../engine/entity.js";
7
7
  import { dataRefLabel, optionalBoolean, optionalString } from "../../engine/pull/context.js";
8
8
  import { tfLabelToTsLabel } from "../../engine/tf/index.js";
9
+ import { accessPolicyFromTf } from "../access-policy/from-tf.js";
9
10
  import { fieldFromTf } from "../field/from-tf.js";
10
11
  import { viewsFromTf } from "../view/from-tf.js";
11
12
  import { ELEMENT_RESOURCE_TYPE } from "./module.js";
@@ -35,7 +36,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
35
36
  layoutBlocks: [],
36
37
  listViewBlocks: [],
37
38
  managedViewOrderBlocks: [],
38
- }) {
39
+ }, accessPolicyBlocks = []) {
39
40
  const label = elementBlock.label;
40
41
  if (label === undefined || label === "") {
41
42
  throw new EntityTfError("elementum_element block is missing its label");
@@ -117,7 +118,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
117
118
  const idName = optionalString(attrs, "id_field_name", `element "${label}"`, ctx);
118
119
  if (idName !== undefined)
119
120
  fields.push(systemEntry("id", idName, "TEXT", "HANDLE"));
120
- const owner = { type: ELEMENT_RESOURCE_TYPE, label };
121
+ const owner = { type: ELEMENT_RESOURCE_TYPE, label, scope: "element" };
121
122
  for (const block of fieldBlocks) {
122
123
  const entry = fieldFromTf(block, owner, ctx);
123
124
  if (entry !== undefined)
@@ -127,7 +128,20 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
127
128
  if (elementId === undefined) {
128
129
  ctx.diagnostics.push(`element "${label}": no import block in the stream — adoption has no identity to bind`);
129
130
  }
130
- const { layouts, listViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label }, ctx);
131
+ const { layouts, listViews, viewOrder } = viewsFromTf(viewBlocks.layoutBlocks, viewBlocks.listViewBlocks, viewBlocks.managedViewOrderBlocks, { type: ELEMENT_RESOURCE_TYPE, label, ownerTfLabel: refName, scope: "element" }, ctx);
132
+ const accessPolicyOwner = {
133
+ type: ELEMENT_RESOURCE_TYPE,
134
+ label,
135
+ ownerRefName: refName,
136
+ ownerTfLabel: label,
137
+ scope: "element",
138
+ };
139
+ const accessPolicies = [];
140
+ for (const block of accessPolicyBlocks) {
141
+ const entry = accessPolicyFromTf(block, accessPolicyOwner, ctx);
142
+ if (entry !== undefined)
143
+ accessPolicies.push(entry);
144
+ }
131
145
  const element = {
132
146
  id: elementId ?? "",
133
147
  name,
@@ -147,6 +161,7 @@ export function elementFromTf(elementBlock, fieldBlocks, ctx, viewBlocks = {
147
161
  ...(layouts.length > 0 && { layouts }),
148
162
  ...(listViews.length > 0 && { listViews }),
149
163
  ...(viewOrder !== undefined && { viewOrder }),
164
+ ...(accessPolicies.length > 0 && { accessPolicies }),
150
165
  };
151
166
  return { element, ...(cloudLinkHandle !== undefined && { cloudLinkHandle }) };
152
167
  }
@@ -6,4 +6,7 @@
6
6
  * field/print internals genuinely shared between both aspect kinds).
7
7
  */
8
8
  export { defineElement, type ElementCloudConnection, type ElementConfigured, type ElementRef, type ElementV2Options, } from "./build.js";
9
- export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, textField, userField, type BaseFieldOptions, type NumericFieldOptions, type PicklistFieldOptions, type TextFieldOptions, } from "../field/build.js";
9
+ export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, relationField, textField, userField, type BaseFieldOptions, type NumericFieldOptions, type PicklistFieldOptions, type RelationFieldOptions, type TextFieldOptions, } from "../field/build.js";
10
+ export { type AccessPolicyGroupRef, type AccessPolicyOptions, type AccessPolicyUserRef } from "../access-policy/build.js";
11
+ export * as accessPolicyFilter from "../access-policy/filter.js";
12
+ export { type AccessPolicyFilter, type AccessPolicyFilterValue, type CurrentUserFilterValue } from "../access-policy/filter.js";
@@ -6,4 +6,5 @@
6
6
  * field/print internals genuinely shared between both aspect kinds).
7
7
  */
8
8
  export { defineElement, } from "./build.js";
9
- export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, textField, userField, } from "../field/build.js";
9
+ export { attachmentField, booleanField, dateField, dateTimeField, decimalField, groupField, htmlField, jsonField, multiPicklistField, numberField, picklistField, relationField, textField, userField, } from "../field/build.js";
10
+ export * as accessPolicyFilter from "../access-policy/filter.js";
@@ -21,11 +21,12 @@ function extractElementStreamRoot(stream, ctx) {
21
21
  const layoutBlocks = viewBlocks.filter((b) => b.type === LAYOUT_RESOURCE_TYPE);
22
22
  const listViewBlocks = viewBlocks.filter((b) => b.type === LIST_VIEW_RESOURCE_TYPE);
23
23
  const managedViewOrderBlocks = stream.byKind.get("managed-view-order") ?? [];
24
+ const accessPolicyBlocks = stream.byKind.get("access-policy") ?? [];
24
25
  const { element, cloudLinkHandle } = elementFromTf(elementBlocks[0], fieldBlocks, ctx, {
25
26
  layoutBlocks,
26
27
  listViewBlocks,
27
28
  managedViewOrderBlocks,
28
- });
29
+ }, accessPolicyBlocks);
29
30
  return {
30
31
  instance: element,
31
32
  ...(cloudLinkHandle !== undefined && { cloudLinkHandle }),
@@ -46,6 +47,7 @@ export const elementModule = {
46
47
  extractStreamRoot: extractElementStreamRoot,
47
48
  toTf: (entity, ctx) => {
48
49
  const result = elementToTf(entity, {
50
+ appRefName: ctx.appRefName,
49
51
  appTfLabel: ctx.appTfLabel,
50
52
  orgRefs: ctx.orgRefs,
51
53
  diagnostics: ctx.diagnostics,
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { EntityTfError } from "../../engine/entity.js";
7
7
  import { expr } from "../../engine/tf/index.js";
8
+ import { accessPolicyToTf } from "../access-policy/to-tf.js";
8
9
  import { fieldToTf } from "../field/to-tf.js";
9
10
  import { CATEGORY_ORG_BAG } from "../org/category.js";
10
11
  import { CLOUD_LINK_ORG_BAG } from "../org/cloud-link.js";
@@ -128,19 +129,36 @@ export function elementToTf(entity, ctx) {
128
129
  }
129
130
  continue;
130
131
  }
131
- const field = fieldToTf(typeKey, inner, { objectId, diagnostics: ctx.diagnostics });
132
+ const field = fieldToTf(typeKey, inner, {
133
+ ownerTfLabel: ctx.appTfLabel,
134
+ scope: "element",
135
+ objectId,
136
+ diagnostics: ctx.diagnostics,
137
+ orgRefs: ctx.orgRefs,
138
+ });
132
139
  if (field === undefined)
133
140
  continue;
134
141
  blocks.push(field.block);
135
142
  fieldAddresses.set(field.bagKey, field.address);
136
143
  }
137
144
  const { blocks: viewBlocks } = viewToTf(payload.layouts, payload.listViews, payload.viewOrder, {
138
- appTfLabel: ctx.appTfLabel,
139
- appName: payload.name ?? "",
145
+ ownerTfLabel: ctx.appTfLabel,
146
+ scope: "element",
147
+ aspectName: payload.name ?? "",
140
148
  objectId,
141
149
  diagnostics: ctx.diagnostics,
142
150
  });
143
151
  blocks.push(...viewBlocks);
152
+ for (const [index, entry] of (payload.accessPolicies ?? []).entries()) {
153
+ const { block } = accessPolicyToTf(entry, index, {
154
+ ownerTfLabel: ctx.appTfLabel,
155
+ scope: "element",
156
+ objectId,
157
+ orgRefs: ctx.orgRefs,
158
+ diagnostics: ctx.diagnostics,
159
+ });
160
+ blocks.push(block);
161
+ }
144
162
  blocks.unshift({
145
163
  kind: "resource",
146
164
  type: ELEMENT_RESOURCE_TYPE,
@@ -47,23 +47,66 @@ export interface PicklistFieldOptions extends BaseFieldOptions {
47
47
  /** Extra options for the numeric kinds (`numberField` / `decimalField`). */
48
48
  export interface NumericFieldOptions extends BaseFieldOptions {
49
49
  readonly numericFormat?: Record<string, unknown>;
50
+ /** `decimalField` only — display/storage precision. */
51
+ readonly decimalPlaces?: number;
50
52
  }
51
53
  /** Extra options for `textField`. */
52
54
  export interface TextFieldOptions extends BaseFieldOptions {
53
55
  readonly qrFormat?: Record<string, unknown>;
54
56
  }
55
- export declare function textField(opts: TextFieldOptions): AppField;
56
- export declare function htmlField(opts: BaseFieldOptions): AppField;
57
- export declare function numberField(opts: NumericFieldOptions): AppField;
58
- export declare function decimalField(opts: NumericFieldOptions): AppField;
59
- export declare function booleanField(opts: BaseFieldOptions): AppField;
60
- export declare function dateField(opts: BaseFieldOptions): AppField;
61
- export declare function dateTimeField(opts: BaseFieldOptions): AppField;
62
- export declare function userField(opts: BaseFieldOptions): AppField;
63
- export declare function groupField(opts: BaseFieldOptions): AppField;
64
- export declare function attachmentField(opts: BaseFieldOptions): AppField;
65
- export declare function jsonField(opts: BaseFieldOptions): AppField;
66
- export declare function picklistField(opts: PicklistFieldOptions): AppField;
67
- export declare function multiPicklistField(opts: PicklistFieldOptions): AppField;
57
+ /**
58
+ * Options for `relationField` — a dynamic dropdown sourced from another
59
+ * App/Element/Task's records (`elementum_relation_field`), distinct from a
60
+ * static `picklistField`. `relatedAspectId`/`relatedLabelFieldId` are raw
61
+ * platform ids (see {@link RelationAppField}), not catalog tokens.
62
+ */
63
+ export interface RelationFieldOptions extends BaseFieldOptions {
64
+ readonly relatedAspectId: string;
65
+ readonly relatedLabelFieldId: string;
66
+ /** Defaults to `true` on the platform. */
67
+ readonly autoRelate?: boolean;
68
+ }
69
+ export declare function textField(opts: TextFieldOptions): AppField & {
70
+ readonly type: "TEXT";
71
+ };
72
+ export declare function htmlField(opts: BaseFieldOptions): AppField & {
73
+ readonly type: "HTML";
74
+ };
75
+ export declare function numberField(opts: NumericFieldOptions): AppField & {
76
+ readonly type: "NUMBER";
77
+ };
78
+ export declare function decimalField(opts: NumericFieldOptions): AppField & {
79
+ readonly type: "DECIMAL";
80
+ };
81
+ export declare function booleanField(opts: BaseFieldOptions): AppField & {
82
+ readonly type: "BOOLEAN";
83
+ };
84
+ export declare function dateField(opts: BaseFieldOptions): AppField & {
85
+ readonly type: "DATE";
86
+ };
87
+ export declare function dateTimeField(opts: BaseFieldOptions): AppField & {
88
+ readonly type: "DATETIME";
89
+ };
90
+ export declare function userField(opts: BaseFieldOptions): AppField & {
91
+ readonly type: "USER";
92
+ };
93
+ export declare function groupField(opts: BaseFieldOptions): AppField & {
94
+ readonly type: "GROUP";
95
+ };
96
+ export declare function attachmentField(opts: BaseFieldOptions): AppField & {
97
+ readonly type: "ATTACHMENT";
98
+ };
99
+ export declare function jsonField(opts: BaseFieldOptions): AppField & {
100
+ readonly type: "JSON";
101
+ };
102
+ export declare function picklistField(opts: PicklistFieldOptions): AppField & {
103
+ readonly type: "PICKLIST";
104
+ };
105
+ export declare function multiPicklistField(opts: PicklistFieldOptions): AppField & {
106
+ readonly type: "MULTI_PICKLIST";
107
+ };
108
+ export declare function relationField(opts: RelationFieldOptions): AppField & {
109
+ readonly type: "RELATION";
110
+ };
68
111
  /** Authoring field type → its factory's exported name (the printer's emission table). */
69
112
  export declare const FIELD_FACTORY_BY_TYPE: ReadonlyMap<string, string>;
@@ -14,6 +14,12 @@
14
14
  * literal form (`{ name, type: "TEXT" }`) remains valid where ever an
15
15
  * AppField is accepted.
16
16
  */
17
+ // Generic over the literal type discriminator so a field factory's return
18
+ // type carries e.g. `type: "PICKLIST"`, not the widened `WorkflowFieldType`
19
+ // union — required for the live catalog path (`defineApp`'s `.ref()`) to
20
+ // preserve per-field literal typing all the way to `RecordShape`
21
+ // (`entities/field/record-shape.ts`), the same way the old baked
22
+ // `fieldRef({ fieldType: "PICKLIST" })` literal did.
17
23
  function field(type, opts) {
18
24
  return { ...opts, type };
19
25
  }
@@ -56,6 +62,9 @@ export function picklistField(opts) {
56
62
  export function multiPicklistField(opts) {
57
63
  return field("MULTI_PICKLIST", opts);
58
64
  }
65
+ export function relationField(opts) {
66
+ return field("RELATION", opts);
67
+ }
59
68
  /** Authoring field type → its factory's exported name (the printer's emission table). */
60
69
  export const FIELD_FACTORY_BY_TYPE = new Map([
61
70
  ["TEXT", "textField"],
@@ -71,4 +80,5 @@ export const FIELD_FACTORY_BY_TYPE = new Map([
71
80
  ["JSON", "jsonField"],
72
81
  ["PICKLIST", "picklistField"],
73
82
  ["MULTI_PICKLIST", "multiPicklistField"],
83
+ ["RELATION", "relationField"],
74
84
  ]);
@@ -107,6 +107,10 @@ function appFieldExprType(field) {
107
107
  `calculation — referring to a calculated field's value needs the server ` +
108
108
  `to infer its output type, which the EDK doesn't replicate locally. ` +
109
109
  `Inline the upstream expression or split the work across automation tasks.`);
110
+ case "RELATION":
111
+ throw new Error(`calc: cannot reference relation field "${field.name}" in a calculation — ` +
112
+ `it has no scalar/comparable value of its own (relatedAspectId/relatedLabelFieldId ` +
113
+ `are raw platform ids, not an expression-typed value).`);
110
114
  default: {
111
115
  const _exhaustive = field;
112
116
  void _exhaustive;
@@ -6,13 +6,15 @@
6
6
  * import blocks and stay data-side.
7
7
  */
8
8
  import { type FromTfContext } from "../../engine/pull/context.js";
9
- import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
9
+ import { type ChildResourceScope, type TfBlock, type TfValue } from "../../engine/tf/index.js";
10
10
  import type { NormalizedField } from "../app/deserializer/normalize.js";
11
11
  export interface FieldOwner {
12
12
  /** The owner's resource type ("elementum_app") — what `object_id` must reference. */
13
13
  readonly type: string;
14
- /** The owner's tfLabel. */
14
+ /** The owner's tfLabel (namespace). */
15
15
  readonly label: string;
16
+ /** Scope for stripping child label prefixes (defaults to app). */
17
+ readonly scope?: ChildResourceScope;
16
18
  }
17
19
  /**
18
20
  * One field block → its normalized entry; undefined = skipped with a
@@ -26,4 +28,4 @@ export declare function fieldFromTf(block: TfBlock, owner: FieldOwner, ctx: From
26
28
  * fields, view field_ids/columns). Undefined for any other shape or an
27
29
  * unknown resource type.
28
30
  */
29
- export declare function fieldKeyFromTfRef(v: TfValue): string | undefined;
31
+ export declare function fieldKeyFromTfRef(v: TfValue, ownerTfLabel?: string, scope?: ChildResourceScope): string | undefined;