@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
@@ -11,7 +11,7 @@
11
11
  * accept a literal or a `ctx` `Ref` and are pre-serialized to the platform's
12
12
  * `ValueReference` JSON via the shared, agnostic `serializeValueOrRef`.
13
13
  */
14
- import type { AgentRef, AspectRef, AutomationRef, ConnectorRef, FileReaderCatalogRef, DocumentModelFieldRef, FieldRef, SearchTableRef } from "../../catalog/index.js";
14
+ import type { AgentRef, AspectRef, AutomationRef, CloudLinkRef, ConnectorRef, FileReaderCatalogRef, DocumentModelFieldRef, FieldRef, SearchTableRef } from "../../catalog/index.js";
15
15
  import type { RecordShape } from "../field/record-shape.js";
16
16
  import type { ValueOrRef } from "../shared/ref.js";
17
17
  import type { TaskDef } from "./build.js";
@@ -125,8 +125,8 @@ export interface SendEmailOptions {
125
125
  export declare function sendEmail(opts: SendEmailOptions): TaskDef<Record<string, never>>;
126
126
  export interface PostCommentOptions {
127
127
  readonly contents: ValueOrRef<unknown>;
128
- /** Conversation tags — at least one required. */
129
- readonly tags: readonly string[];
128
+ /** Conversation tags. Omit for an untagged comment — the provider's message task has no tags of its own. */
129
+ readonly tags?: readonly string[];
130
130
  /** The record to comment on (required). */
131
131
  readonly record: ValueOrRef<unknown>;
132
132
  }
@@ -180,32 +180,130 @@ export interface SetVariableOptions {
180
180
  readonly update?: readonly VariableAssign[];
181
181
  }
182
182
  export declare function setVariable(opts: SetVariableOptions): TaskDef<Record<string, never>>;
183
- export interface ExecuteScriptOptions {
183
+ type ExecuteScriptFieldValue<T extends string> = Uppercase<T> extends "INTEGER" | "NUMBER" | "DECIMAL" ? number : Uppercase<T> extends "BOOLEAN" ? boolean : string;
184
+ type ExecuteScriptOutput<O extends Record<string, string> | undefined> = {
185
+ readonly result: O extends Record<string, string> ? {
186
+ readonly [K in keyof O]: ExecuteScriptFieldValue<O[K]>;
187
+ } : Record<string, unknown>;
188
+ };
189
+ export interface ExecuteScriptOptions<O extends Record<string, string> | undefined = undefined> {
184
190
  /**
185
- * The script body as a string, or a FUNCTION whose body ships as the script
186
- * (v3): `(input) => { const { X } = input.parameters; return { OUT: X }; }`.
187
- * The function form matches the platform's real contract (`input.parameters.
188
- * <name>`, mandatory plain-object return) and is serialized to TEXT — it must
189
- * not close over outer variables (a best-effort scan throws on captures).
191
+ * A FUNCTION whose body ships as the platform script (v3):
192
+ * `(input) => { const { X } = input.parameters; return { OUT: X }; }`.
193
+ * Matches the platform contract (`input.parameters.<name>`, mandatory
194
+ * plain-object return) and is serialized to TEXT — it must not close over
195
+ * outer variables (a best-effort scan throws on captures).
196
+ *
197
+ * Top-level workflows should use fluent `.executeScript(name, {…})` instead
198
+ * of `.task(name, () => executeScript(…))`. This factory remains for nested
199
+ * `childTask(…, executeScript(…))` (operators have no fluent surface).
190
200
  */
191
- readonly code: string | ScriptCodeFn<Record<string, unknown>, Record<string, unknown>>;
201
+ readonly code: ScriptCodeFn<Record<string, unknown>, Record<string, unknown>>;
192
202
  readonly inputs?: Record<string, ValueOrRef<unknown>>;
193
203
  /** Output schema: property name → `"text" | "integer" | "number" | "decimal" | "boolean"`. */
194
- readonly outputs?: Record<string, string>;
204
+ readonly outputs?: O;
195
205
  }
196
- export declare function executeScript(opts: ExecuteScriptOptions): TaskDef<Record<string, unknown>>;
206
+ /**
207
+ * Build the executeScript `TaskDef` from an ALREADY-RESOLVED body string.
208
+ * Shared by the public `executeScript()` factory below (which resolves the
209
+ * body via `extractScriptBody`'s `toString()` path) and the fluent
210
+ * `WorkflowBuilder.executeScript()` in `build.ts` (which resolves it via
211
+ * `tryExtractFromCurrentSource` first, for byte-exact pulled-source fidelity,
212
+ * falling back to `extractScriptBody` only when there's no tracked source) —
213
+ * so the body is computed exactly once, not re-derived by each layer.
214
+ */
215
+ export declare function executeScriptTaskDefWithBody<O extends Record<string, string> | undefined = undefined>(body: string, opts: Pick<ExecuteScriptOptions<O>, "inputs" | "outputs">): TaskDef<ExecuteScriptOutput<O>> & {
216
+ readonly key: "executeScript";
217
+ };
218
+ export declare function executeScript<const O extends Record<string, string> | undefined = undefined>(opts: ExecuteScriptOptions<O>): TaskDef<ExecuteScriptOutput<O>> & {
219
+ readonly key: "executeScript";
220
+ };
197
221
  export interface ApiRequestHeader {
198
222
  readonly name: string;
199
223
  readonly value: ValueOrRef<unknown>;
200
224
  }
225
+ export interface ApiRequestBasicAuth {
226
+ readonly username: ValueOrRef<unknown>;
227
+ /**
228
+ * elementum_api_task's `basic_auth.reference_password` - a dynamic
229
+ * password pulled from another task's refs at runtime. Mutually exclusive
230
+ * with a static password, which is NOT modeled: the provider schema
231
+ * treats it as write-only (confirmed against api_task_resource.go's
232
+ * reconstructAPITaskBasicAuth - the API never returns the real value, so
233
+ * it's always copied forward from whatever was already in state), so a
234
+ * plan rebuilt from a fresh pull could never reproduce it.
235
+ */
236
+ readonly referencePassword?: ValueOrRef<unknown>;
237
+ }
238
+ /**
239
+ * elementum_api_task's `bearer_auth` block. `token` is a plain static
240
+ * string only (no template/ref support on the wire, and - like basic_auth's
241
+ * password - write-only on read, so it always round-trips from authored
242
+ * source rather than a pull); `referenceToken` is the round-trippable
243
+ * dynamic alternative. Mutually exclusive with each other, and with
244
+ * `basicAuth`/`oauth` at the task level.
245
+ */
246
+ export interface ApiRequestBearerAuth {
247
+ readonly token?: string;
248
+ readonly referenceToken?: ValueOrRef<unknown>;
249
+ }
250
+ /**
251
+ * elementum_api_task's `oauth` block (client-credentials grant). `clientId`/
252
+ * `clientSecret` are plain static strings, write-only on read like
253
+ * bearer_auth.token - always resent from authored source, never
254
+ * reconstructed from a pull. Mutually exclusive with `basicAuth`/
255
+ * `bearerAuth`.
256
+ */
257
+ export interface ApiRequestOAuth {
258
+ readonly url?: ValueOrRef<unknown>;
259
+ readonly clientId?: string;
260
+ readonly clientSecret?: string;
261
+ readonly requestType: "BASIC" | "FORM";
262
+ readonly headers?: readonly ApiRequestHeader[];
263
+ }
264
+ export interface ApiRequestFormValue {
265
+ readonly key: string;
266
+ readonly value: ValueOrRef<unknown>;
267
+ }
268
+ /** elementum_api_task's `custom_body` block - arbitrary content type + body text (XML, CSV, SOAP, ...). */
269
+ export interface ApiRequestCustomBody {
270
+ readonly contentType: string;
271
+ readonly content: ValueOrRef<unknown>;
272
+ }
273
+ /**
274
+ * One part of a `multipart_body`. Exactly one of `value` (a plain text
275
+ * field - templated like other body content), `attachment`, `attachmentId`,
276
+ * or `file` (value references) should be set; the provider validates the
277
+ * mutual exclusivity server-side.
278
+ */
279
+ export interface ApiRequestMultipartPart {
280
+ readonly name: string;
281
+ readonly value?: ValueOrRef<unknown>;
282
+ readonly attachment?: ValueOrRef<unknown>;
283
+ readonly attachmentId?: ValueOrRef<unknown>;
284
+ readonly file?: ValueOrRef<unknown>;
285
+ }
286
+ export interface ApiRequestMultipartBody {
287
+ readonly parts: readonly ApiRequestMultipartPart[];
288
+ }
201
289
  export interface ApiRequestOptions {
202
290
  readonly url: ValueOrRef<unknown>;
203
291
  readonly method: string;
204
292
  readonly headers?: readonly ApiRequestHeader[];
205
- /** Pre-built wire authorization envelope (auth DSL finalized later). */
206
- readonly authorization?: Record<string, unknown>;
207
- /** Pre-built wire body envelope (body DSL finalized later). */
208
- readonly body?: Record<string, unknown>;
293
+ /** elementum_api_task's `basic_auth` block. Mutually exclusive with `bearerAuth`/`oauth`. */
294
+ readonly basicAuth?: ApiRequestBasicAuth;
295
+ /** elementum_api_task's `bearer_auth` block. Mutually exclusive with `basicAuth`/`oauth`. */
296
+ readonly bearerAuth?: ApiRequestBearerAuth;
297
+ /** elementum_api_task's `oauth` block. Mutually exclusive with `basicAuth`/`bearerAuth`. */
298
+ readonly oauth?: ApiRequestOAuth;
299
+ /** elementum_api_task's `json_body` attribute. Mutually exclusive with `formBody`/`customBody`/`multipartBody`. */
300
+ readonly jsonBody?: ValueOrRef<unknown>;
301
+ /** elementum_api_task's `form_body` attribute. Mutually exclusive with `jsonBody`/`customBody`/`multipartBody`. */
302
+ readonly formBody?: readonly ApiRequestFormValue[];
303
+ /** elementum_api_task's `custom_body` block. Mutually exclusive with `jsonBody`/`formBody`/`multipartBody`. */
304
+ readonly customBody?: ApiRequestCustomBody;
305
+ /** elementum_api_task's `multipart_body` block (file uploads). Mutually exclusive with `jsonBody`/`formBody`/`customBody`. */
306
+ readonly multipartBody?: ApiRequestMultipartBody;
209
307
  readonly responseType?: string;
210
308
  readonly continueOnError?: boolean;
211
309
  }
@@ -250,7 +348,14 @@ export interface AiFileAnalysisOptions {
250
348
  readonly attachmentId: ValueOrRef<unknown>;
251
349
  /** Required — the document model to analyze the file against. */
252
350
  readonly documentModel: FileReaderCatalogRef;
253
- readonly connector?: ConnectorRef;
351
+ /**
352
+ * Required — unlike aiSummarize/aiClassify/aiTransform's `connector`
353
+ * (optional there; the provider falls back to the org default),
354
+ * elementum_ai_file_read_task's ai_provider_connector_id is Required in
355
+ * the provider's own schema (ai_file_read_task_resource.go). Omitting it
356
+ * here would build clean but fail at `plan`/`apply`.
357
+ */
358
+ readonly connector: ConnectorRef;
254
359
  }
255
360
  export declare function aiFileAnalysis(opts: AiFileAnalysisOptions): TaskDef<{
256
361
  output: unknown;
@@ -362,7 +467,8 @@ export interface AssignmentEngineOptions {
362
467
  export declare function assignmentEngine(opts: AssignmentEngineOptions): TaskDef<Empty>;
363
468
  export interface ProcedureOptions {
364
469
  readonly procedureId: string;
365
- readonly cloudLinkId: string;
470
+ /** A raw cloud link id, or a `catalog.cloudLinks.<handle>` reference. */
471
+ readonly cloudLinkId: string | CloudLinkRef;
366
472
  /** Positional arguments (index == position). */
367
473
  readonly parameters?: readonly ValueOrRef<unknown>[];
368
474
  }
@@ -391,7 +497,7 @@ export interface CalculationEntry {
391
497
  * concatenation) and rejects the request as malformed. Mirrors
392
498
  * {@link VariableDecl.type}'s loose string typing.
393
499
  */
394
- readonly outputType: string;
500
+ readonly outputType?: string;
395
501
  readonly record?: ValueOrRef<unknown>;
396
502
  }
397
503
  export interface CalculationOptions {
@@ -79,9 +79,9 @@ export function relateRecords(opts) {
79
79
  return {
80
80
  key: "relateRecords",
81
81
  config: {
82
- sourceRecordIds: opts.sources.length === 1
83
- ? serializeValueOrRef(opts.sources[0])
84
- : opts.sources.map((s) => serializeValueOrRef(s)),
82
+ // Always an array in wire — matches DSL `sources: [...]` and round-trips
83
+ // single-source HCL (scalar source_record_ids) via from-tf normalization.
84
+ sourceRecordIds: opts.sources.map((s) => serializeValueOrRef(s)),
85
85
  targetRecordId: serializeValueOrRef(opts.target),
86
86
  },
87
87
  };
@@ -113,12 +113,12 @@ export function sendEmail(opts) {
113
113
  };
114
114
  }
115
115
  export function postComment(opts) {
116
- if (opts.tags.length === 0)
117
- throw new Error("postComment requires a non-empty tags array.");
116
+ if (opts.tags !== undefined && opts.tags.length === 0)
117
+ throw new Error("postComment's tags, when given, must be non-empty.");
118
118
  return {
119
119
  key: "message",
120
120
  config: {
121
- tags: opts.tags,
121
+ ...(opts.tags !== undefined ? { tags: opts.tags } : {}),
122
122
  contentsReference: serializeValueOrRef(opts.contents),
123
123
  recordReference: serializeValueOrRef(opts.record),
124
124
  },
@@ -190,7 +190,16 @@ function outputSchema(outputs) {
190
190
  // against both (adoption zero-change gate + build-vs-export).
191
191
  return { object: { properties } };
192
192
  }
193
- export function executeScript(opts) {
193
+ /**
194
+ * Build the executeScript `TaskDef` from an ALREADY-RESOLVED body string.
195
+ * Shared by the public `executeScript()` factory below (which resolves the
196
+ * body via `extractScriptBody`'s `toString()` path) and the fluent
197
+ * `WorkflowBuilder.executeScript()` in `build.ts` (which resolves it via
198
+ * `tryExtractFromCurrentSource` first, for byte-exact pulled-source fidelity,
199
+ * falling back to `extractScriptBody` only when there's no tracked source) —
200
+ * so the body is computed exactly once, not re-derived by each layer.
201
+ */
202
+ export function executeScriptTaskDefWithBody(body, opts) {
194
203
  const inputs = Object.entries(opts.inputs ?? {}).map(([name, value]) => ({
195
204
  name,
196
205
  value: serializeValueOrRef(value),
@@ -199,23 +208,82 @@ export function executeScript(opts) {
199
208
  key: "executeScript",
200
209
  config: {
201
210
  inputs,
202
- code: typeof opts.code === "function" ? extractScriptBody(opts.code) : opts.code,
211
+ code: body,
203
212
  ...(opts.outputs !== undefined ? { outputSchema: outputSchema(opts.outputs) } : {}),
204
213
  },
205
214
  };
206
215
  }
216
+ export function executeScript(opts) {
217
+ return executeScriptTaskDefWithBody(extractScriptBody(opts.code), opts);
218
+ }
219
+ function apiRequestHeaders(headers) {
220
+ return (headers ?? []).map((h) => ({ name: h.name, value: serializeValueOrRef(h.value) }));
221
+ }
222
+ const API_AUTH_KEYS = ["basicAuth", "bearerAuth", "oauth"];
223
+ const API_BODY_KEYS = ["jsonBody", "formBody", "customBody", "multipartBody"];
207
224
  export function apiRequest(opts) {
225
+ const setAuthKeys = API_AUTH_KEYS.filter((k) => opts[k] !== undefined);
226
+ if (setAuthKeys.length > 1) {
227
+ throw new Error(`apiRequest: at most one of basicAuth/bearerAuth/oauth may be set (got ${setAuthKeys.join(", ")}).`);
228
+ }
229
+ const setBodyKeys = API_BODY_KEYS.filter((k) => opts[k] !== undefined);
230
+ if (setBodyKeys.length > 1) {
231
+ throw new Error(`apiRequest: at most one of jsonBody/formBody/customBody/multipartBody may be set (got ${setBodyKeys.join(", ")}).`);
232
+ }
208
233
  return {
209
234
  key: "api",
210
235
  config: {
211
236
  urlReference: serializeValueOrRef(opts.url),
212
237
  method: opts.method,
213
- headers: (opts.headers ?? []).map((h) => ({
214
- header: h.name,
215
- value: serializeValueOrRef(h.value),
216
- })),
217
- ...(opts.authorization !== undefined ? { authorization: opts.authorization } : {}),
218
- ...(opts.body !== undefined ? { body: opts.body } : {}),
238
+ // elementum_api_task's real attribute is `headers[].name` (confirmed
239
+ // against api_task_resource.go's schema) - not "header". Omit when
240
+ // unset rather than defaulting to `[]` - the platform leaves `headers`
241
+ // absent (not an empty list) on a task with none configured, so an
242
+ // unconditional `[]` here permanently diffed against state.
243
+ ...(opts.headers !== undefined ? { headers: apiRequestHeaders(opts.headers) } : {}),
244
+ ...(opts.basicAuth !== undefined ? {
245
+ basicAuth: {
246
+ username: serializeValueOrRef(opts.basicAuth.username),
247
+ ...(opts.basicAuth.referencePassword !== undefined
248
+ ? { referencePassword: serializeValueOrRef(opts.basicAuth.referencePassword) }
249
+ : {}),
250
+ },
251
+ } : {}),
252
+ ...(opts.bearerAuth !== undefined ? {
253
+ bearerAuth: {
254
+ ...(opts.bearerAuth.token !== undefined ? { token: opts.bearerAuth.token } : {}),
255
+ ...(opts.bearerAuth.referenceToken !== undefined
256
+ ? { referenceToken: serializeValueOrRef(opts.bearerAuth.referenceToken) }
257
+ : {}),
258
+ },
259
+ } : {}),
260
+ ...(opts.oauth !== undefined ? {
261
+ oauth: {
262
+ requestType: opts.oauth.requestType,
263
+ ...(opts.oauth.url !== undefined ? { url: serializeValueOrRef(opts.oauth.url) } : {}),
264
+ ...(opts.oauth.clientId !== undefined ? { clientId: opts.oauth.clientId } : {}),
265
+ ...(opts.oauth.clientSecret !== undefined ? { clientSecret: opts.oauth.clientSecret } : {}),
266
+ ...(opts.oauth.headers !== undefined ? { headers: apiRequestHeaders(opts.oauth.headers) } : {}),
267
+ },
268
+ } : {}),
269
+ ...(opts.jsonBody !== undefined ? { jsonBody: serializeValueOrRef(opts.jsonBody) } : {}),
270
+ ...(opts.formBody !== undefined ? {
271
+ formBody: opts.formBody.map((v) => ({ key: v.key, value: serializeValueOrRef(v.value) })),
272
+ } : {}),
273
+ ...(opts.customBody !== undefined ? {
274
+ customBody: { contentType: opts.customBody.contentType, content: serializeValueOrRef(opts.customBody.content) },
275
+ } : {}),
276
+ ...(opts.multipartBody !== undefined ? {
277
+ multipartBody: {
278
+ parts: opts.multipartBody.parts.map((part) => ({
279
+ name: part.name,
280
+ ...(part.value !== undefined ? { value: serializeValueOrRef(part.value) } : {}),
281
+ ...(part.attachment !== undefined ? { attachment: serializeValueOrRef(part.attachment) } : {}),
282
+ ...(part.attachmentId !== undefined ? { attachmentId: serializeValueOrRef(part.attachmentId) } : {}),
283
+ ...(part.file !== undefined ? { file: serializeValueOrRef(part.file) } : {}),
284
+ })),
285
+ },
286
+ } : {}),
219
287
  responseType: opts.responseType ?? "JSON",
220
288
  continueOnError: opts.continueOnError ?? false,
221
289
  },
@@ -277,7 +345,7 @@ export function aiFileAnalysis(opts) {
277
345
  config: {
278
346
  attachmentId: serializeValueOrRef(opts.attachmentId),
279
347
  documentModelId: opts.documentModel,
280
- ...connectorSlot(opts.connector),
348
+ aiProviderConnectorId: opts.connector,
281
349
  },
282
350
  };
283
351
  }
@@ -1,38 +1,19 @@
1
- /**
2
- * Automation emission (Phase 1). `automationToTf` consumes the discovered
3
- * `DeployableEntity` (the `defineAutomation` def() payload) and emits the
4
- * COMPOSITE ei dialect:
5
- *
6
- * elementum_automation.<autoLabel> — identity (app_id, name, ...)
7
- * elementum_<trigger>_trigger.<autoLabel> — the one trigger (automation ref)
8
- * elementum_<task>_task.<autoLabel>_<task> — one per task, parent-chained
9
- * elementum_workflow_publish.<autoLabel> — version + depends_on(all tasks)
10
- *
11
- * Labels follow ei's export: the automation label is `sanitizeName(name)` and a
12
- * task label is `<autoLabel>_<sanitizeName(taskName)>` — so build output matches
13
- * ei's addresses for adoption/build-vs-export. Ordering is encoded exactly as ei does it:
14
- * each task's `parent` points at the previous task (or the trigger, for the
15
- * first). References are BARE resource refs (`elementum_automation.x`, no `.id`),
16
- * matching the capture.
17
- *
18
- * Phase 1 carries the onDemand trigger and the executeScript + setVariable
19
- * (create form → elementum_variable_task) tasks. Any other trigger/task kind, or
20
- * an operator (forEach/forkJoin/switch), degrades through `diagnostics` —
21
- * reported, never silently dropped (plan §6). Task BODY attributes beyond the
22
- * Phase-1 set are reconciled against a fresh live capture (see the tranche plan).
23
- */
24
- import { type DeployableEntity } from "../../engine/entity.js";
1
+ import type { DeployableEntity } from "../../engine/entity.js";
25
2
  import { type TfBlock } from "../../engine/tf/index.js";
3
+ import type { OrgRefLookup } from "../../engine/build/context.js";
4
+ import type { BuildFieldMetadata } from "../../graph/types.js";
26
5
  export interface AutomationToTfContext {
27
- /** The owning app's tfLabel — app_id references this resource. */
6
+ readonly appRefName?: string;
28
7
  readonly appTfLabel: string;
29
- /** Degradations land here — reported by the caller, never silent. */
30
- readonly diagnostics: string[];
8
+ readonly fieldAddresses?: ReadonlyMap<string, string>;
9
+ readonly fieldNames?: ReadonlyMap<string, string>;
10
+ readonly fieldMetadata?: ReadonlyMap<string, BuildFieldMetadata>;
11
+ readonly orgRefs?: OrgRefLookup;
12
+ readonly diagnostics?: string[];
31
13
  }
32
14
  export interface AutomationToTfResult {
33
15
  readonly blocks: readonly TfBlock[];
34
- /** The automation's terraform address. */
35
16
  readonly address: string;
36
17
  }
37
- /** The composite ei dialect for one automation. */
18
+ /** App-owned `defineAutomation` entity → provider HCL blocks. */
38
19
  export declare function automationToTf(entity: DeployableEntity, ctx: AutomationToTfContext): AutomationToTfResult;