@elementumai/edk 0.9.20 → 0.10.2

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 (159) hide show
  1. package/README.md +19 -7
  2. package/dist-sdk/src/catalog/factories.d.ts +10 -2
  3. package/dist-sdk/src/catalog/factories.js +10 -1
  4. package/dist-sdk/src/catalog/index.d.ts +2 -2
  5. package/dist-sdk/src/catalog/index.js +1 -1
  6. package/dist-sdk/src/catalog/token.js +4 -0
  7. package/dist-sdk/src/catalog/types.d.ts +7 -1
  8. package/dist-sdk/src/catalog/types.js +1 -0
  9. package/dist-sdk/src/core/triggers/on-demand.d.ts +2 -2
  10. package/dist-sdk/src/core/triggers/on-demand.js +7 -0
  11. package/dist-sdk/src/core/types/app.d.ts +2 -2
  12. package/dist-sdk/src/engine/coverage-gaps.d.ts +86 -0
  13. package/dist-sdk/src/engine/coverage-gaps.js +156 -0
  14. package/dist-sdk/src/engine/ei/run.d.ts +21 -1
  15. package/dist-sdk/src/engine/ei/run.js +89 -2
  16. package/dist-sdk/src/engine/pull/catalog-ref.d.ts +16 -0
  17. package/dist-sdk/src/engine/pull/catalog-ref.js +24 -0
  18. package/dist-sdk/src/engine/pull/context.d.ts +68 -6
  19. package/dist-sdk/src/engine/pull/context.js +40 -1
  20. package/dist-sdk/src/engine/pull/procedure-refs.d.ts +8 -0
  21. package/dist-sdk/src/engine/pull/procedure-refs.js +28 -0
  22. package/dist-sdk/src/engine/pull/result-output.js +27 -1
  23. package/dist-sdk/src/engine/tf/index.d.ts +1 -1
  24. package/dist-sdk/src/engine/tf/index.js +1 -1
  25. package/dist-sdk/src/engine/tf/labels.d.ts +22 -5
  26. package/dist-sdk/src/engine/tf/labels.js +45 -3
  27. package/dist-sdk/src/engine/tf/parse.js +3 -2
  28. package/dist-sdk/src/engine/validation.d.ts +5 -0
  29. package/dist-sdk/src/engine/validation.js +12 -2
  30. package/dist-sdk/src/entities/access-policy/from-tf.js +38 -1
  31. package/dist-sdk/src/entities/access-policy/principal.d.ts +2 -0
  32. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +3 -0
  33. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +42 -19
  34. package/dist-sdk/src/entities/agent/from-tf.js +11 -3
  35. package/dist-sdk/src/entities/agent/module.js +2 -0
  36. package/dist-sdk/src/entities/agent/to-tf.js +14 -3
  37. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +8 -1
  38. package/dist-sdk/src/entities/agent-tool/from-tf.js +11 -5
  39. package/dist-sdk/src/entities/agent-tool/module.js +3 -0
  40. package/dist-sdk/src/entities/app/auto-share.d.ts +38 -0
  41. package/dist-sdk/src/entities/app/auto-share.js +49 -0
  42. package/dist-sdk/src/entities/app/build.d.ts +17 -3
  43. package/dist-sdk/src/entities/app/build.js +56 -4
  44. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +6 -1
  45. package/dist-sdk/src/entities/app/from-tf.js +4 -0
  46. package/dist-sdk/src/entities/app/index.d.ts +2 -1
  47. package/dist-sdk/src/entities/app/index.js +1 -8
  48. package/dist-sdk/src/entities/app/module.js +2 -1
  49. package/dist-sdk/src/entities/app/to-tf.d.ts +6 -0
  50. package/dist-sdk/src/entities/app/to-tf.js +25 -2
  51. package/dist-sdk/src/entities/automation/build.d.ts +12 -2
  52. package/dist-sdk/src/entities/automation/build.js +105 -17
  53. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
  54. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
  55. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +187 -27
  56. package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
  57. package/dist-sdk/src/entities/automation/from-tf.js +397 -89
  58. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  59. package/dist-sdk/src/entities/automation/index.js +1 -1
  60. package/dist-sdk/src/entities/automation/module.d.ts +3 -0
  61. package/dist-sdk/src/entities/automation/module.js +70 -7
  62. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +21 -0
  63. package/dist-sdk/src/entities/automation/output-key-wire-name.js +38 -0
  64. package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
  65. package/dist-sdk/src/entities/automation/script-code.js +23 -5
  66. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
  67. package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
  68. package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
  69. package/dist-sdk/src/entities/automation/tasks.js +48 -15
  70. package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
  71. package/dist-sdk/src/entities/automation/to-tf.js +656 -65
  72. package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
  73. package/dist-sdk/src/entities/automation/types.d.ts +9 -0
  74. package/dist-sdk/src/entities/automation/types.js +19 -0
  75. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
  76. package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
  77. package/dist-sdk/src/entities/chart/from-tf.js +9 -1
  78. package/dist-sdk/src/entities/data-lookup/module.js +2 -0
  79. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  80. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
  81. package/dist-sdk/src/entities/element/build.d.ts +3 -0
  82. package/dist-sdk/src/entities/element/build.js +1 -0
  83. package/dist-sdk/src/entities/element/from-tf.js +4 -0
  84. package/dist-sdk/src/entities/element/module.js +2 -1
  85. package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
  86. package/dist-sdk/src/entities/element/to-tf.js +12 -14
  87. package/dist-sdk/src/entities/field/build.d.ts +3 -2
  88. package/dist-sdk/src/entities/field/calc.d.ts +7 -7
  89. package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
  90. package/dist-sdk/src/entities/field/from-tf.js +255 -80
  91. package/dist-sdk/src/entities/field/module.d.ts +6 -0
  92. package/dist-sdk/src/entities/field/module.js +23 -2
  93. package/dist-sdk/src/entities/field/options.js +6 -1
  94. package/dist-sdk/src/entities/field/order.d.ts +16 -0
  95. package/dist-sdk/src/entities/field/order.js +41 -0
  96. package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
  97. package/dist-sdk/src/entities/field/to-tf.js +7 -1
  98. package/dist-sdk/src/entities/field/types.d.ts +7 -0
  99. package/dist-sdk/src/entities/field/types.js +32 -0
  100. package/dist-sdk/src/entities/role/from-tf.js +3 -3
  101. package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
  102. package/dist-sdk/src/entities/role/to-tf.js +12 -4
  103. package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
  104. package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
  105. package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
  106. package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
  107. package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
  108. package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
  109. package/dist-sdk/src/entities/shared/filters/index.js +5 -0
  110. package/dist-sdk/src/entities/shared/filters/print.js +7 -2
  111. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
  112. package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
  113. package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
  114. package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
  115. package/dist-sdk/src/entities/shared/ref.js +5 -7
  116. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
  117. package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
  118. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
  119. package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
  120. package/dist-sdk/src/entities/skill/access-policy.js +3 -3
  121. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
  122. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
  123. package/dist-sdk/src/entities/skill/from-tf.js +4 -2
  124. package/dist-sdk/src/entities/skill/module.js +2 -0
  125. package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
  126. package/dist-sdk/src/entities/skill-tool/module.js +3 -0
  127. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
  128. package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
  129. package/dist-sdk/src/entities/task/build.d.ts +8 -0
  130. package/dist-sdk/src/entities/task/build.js +10 -1
  131. package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
  132. package/dist-sdk/src/entities/task/from-tf.js +7 -2
  133. package/dist-sdk/src/entities/task/module.js +3 -2
  134. package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
  135. package/dist-sdk/src/entities/task/to-tf.js +32 -1
  136. package/dist-sdk/src/entities/view/from-tf.js +9 -1
  137. package/dist-sdk/src/entities/view/module.js +4 -1
  138. package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
  139. package/dist-sdk/src/entities/view/to-tf.js +30 -11
  140. package/dist-sdk/src/entities/view/types.d.ts +6 -0
  141. package/dist-sdk/src/entities/view/types.js +6 -0
  142. package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
  143. package/dist-sdk/src/entities/visual-flow/build.js +9 -0
  144. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
  145. package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
  146. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  147. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  148. package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
  149. package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
  150. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  151. package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
  152. package/dist-sdk/src/entities/widget/to-tf.js +7 -6
  153. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
  154. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  155. package/dist-sdk/src/graph/index.d.ts +4 -2
  156. package/dist-sdk/src/graph/index.js +3 -0
  157. package/dist-sdk/src/graph/modules.js +2 -1
  158. package/dist-sdk/src/graph/types.d.ts +41 -3
  159. package/package.json +7 -3
@@ -11,12 +11,12 @@
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, AppOrElementOrTaskRef, AppOrElementRef, ApprovalProcessRef, AutomationCatalogRef, CloudLinkRef, ConnectorRef, DocumentModelFieldRef, FieldRef, FileReaderCatalogRef, OutputPropertyRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, SearchTableRef, TableRef } from "../../catalog/index.js";
14
+ import type { AgentRef, AppOrElementOrTaskRef, AppOrElementRef, ApprovalProcessRef, AutomationCatalogRef, CloudLinkRef, ConnectorRef, DocumentModelFieldRef, FieldRef, FileReaderCatalogRef, GroupRef, OutputPropertyRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, SearchTableRef, TableRef } from "../../catalog/index.js";
15
15
  import type { UnsafePlatformId } from "../../core/platform-id.js";
16
16
  import type { CalculationInclude, Expr, ExprCardinality, ExprContext, ExprType } from "../field/calc/types.js";
17
17
  import type { RecordId, RecordShape } from "../field/record-shape.js";
18
18
  import type { RoleUserRef } from "../role/build.js";
19
- import type { Ref, ValueOrRef } from "../shared/ref.js";
19
+ import { type Ref, type ValueOrRef } from "../shared/ref.js";
20
20
  import type { DropdownValue } from "../shared/types/platform.js";
21
21
  import type { ActionDef } from "./build.js";
22
22
  import { type CalculationValue } from "./calculation-expression.js";
@@ -124,6 +124,22 @@ export interface UpdateFieldOptions<A extends AppOrElementOrTaskRef = AppOrEleme
124
124
  export declare function updateField<A extends AppOrElementOrTaskRef, const Fields extends readonly FieldAssignment[]>(opts: UpdateFieldOptions<A, Fields>): ActionDef<{
125
125
  record: RecordShape<A>;
126
126
  }>;
127
+ /** The two scalar outputs a bulk update exposes. */
128
+ export interface BulkUpdateFieldsOutput {
129
+ readonly recordsUpdated: number;
130
+ readonly allMatchingRecordsUpdated: boolean;
131
+ }
132
+ export interface BulkUpdateFieldsOptions<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef, Fields extends readonly FieldAssignment[] = readonly FieldAssignment[]> {
133
+ readonly app: A;
134
+ /** Required — every record matching this filter is updated (use `filter.whereTrue()` for all). */
135
+ readonly filter: Filter;
136
+ readonly fields: Fields & ValidatedUpdateFieldAssignments<NoInfer<Fields>>;
137
+ }
138
+ /**
139
+ * Update fields on every record matching a filter — a filter-scoped mass
140
+ * updateField. No single-record option: the filter selects the set.
141
+ */
142
+ export declare function bulkUpdateFields<A extends AppOrElementOrTaskRef, const Fields extends readonly FieldAssignment[]>(opts: BulkUpdateFieldsOptions<A, Fields>): ActionDef<BulkUpdateFieldsOutput>;
127
143
  export interface FindRelatedRecordsOptions<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> {
128
144
  readonly relatedApp: A;
129
145
  /**
@@ -334,10 +350,15 @@ export interface ExecuteScriptListInputToken {
334
350
  readonly fields: readonly ExecuteScriptFieldMapping[];
335
351
  }
336
352
  /**
337
- * Wrap a list-valued executeScript input (e.g. a prior task's `.records`)
338
- * with the field mappings the script can read off each item - which fields,
339
- * and under what alias. Only meaningful for a list-shaped input; a scalar
340
- * input has no per-item fields to map.
353
+ * Wrap a record-valued executeScript input with the field mappings the script
354
+ * can read - which fields, and under what alias. The value is a whole record
355
+ * or a list of records (a prior task's `.records`, read per item).
356
+ *
357
+ * Inside this wrapper these deploy the whole record: a record trigger's
358
+ * `ctx.trigger.record`, and the `.record` of `recordSearch`, `createRecord`
359
+ * and `updateField`. Elsewhere they are the record ID a `record:` slot takes.
360
+ * An on-demand record parameter and `findRelatedRecords`' `.record` expose
361
+ * only the record ID, so they stay the ID here too.
341
362
  */
342
363
  export declare function withFieldMappings(value: ValueOrRef<unknown>, fields: readonly ExecuteScriptFieldMapping[]): ExecuteScriptListInputToken;
343
364
  export interface ExecuteScriptOptions<O extends ScriptOutputs | undefined = undefined> {
@@ -358,8 +379,9 @@ export interface ExecuteScriptOptions<O extends ScriptOutputs | undefined = unde
358
379
  */
359
380
  readonly code: ScriptCodeFn<Record<string, unknown>, Record<string, unknown>> | ScriptFile;
360
381
  /**
361
- * A list-valued input can carry {@link withFieldMappings} to declare which
362
- * fields of each list item the script can read, and under what alias.
382
+ * A record-valued input (a whole record, or a list of records) can carry
383
+ * {@link withFieldMappings} to declare which fields the script can read, and
384
+ * under what alias.
363
385
  */
364
386
  readonly inputs?: Record<string, ValueOrRef<unknown> | ExecuteScriptListInputToken>;
365
387
  /**
@@ -401,6 +423,13 @@ export interface RequiredSecret {
401
423
  export declare function requiredSecret(variable: string): RequiredSecret;
402
424
  export declare function isRequiredSecret(value: unknown): value is RequiredSecret;
403
425
  export interface ApiRequestBasicAuth {
426
+ /**
427
+ * A static username, a `requiredSecret()` write-only username, or
428
+ * `secret("KEY")` for a username bound to a vault entry. A vault-bound
429
+ * username builds to `basic_auth.reference_username` through a key-only
430
+ * `elementum_vault_entry` lookup, so no vault ID or value lands in source
431
+ * or HCL (edk#1283).
432
+ */
404
433
  readonly username: ValueOrRef<unknown>;
405
434
  /**
406
435
  * elementum_api_task's `basic_auth.reference_password` - a dynamic
@@ -426,16 +455,18 @@ export interface ApiRequestBearerAuth {
426
455
  readonly referenceToken?: ValueOrRef<unknown>;
427
456
  }
428
457
  /**
429
- * elementum_api_task's `oauth` block (client-credentials grant). `clientId`/
430
- * `clientSecret` are plain static strings, write-only on read like
458
+ * elementum_api_task's `oauth` block (client-credentials grant). A plain
459
+ * string `clientId`/`clientSecret` is static and write-only on read like
431
460
  * bearer_auth.token - always resent from authored source, never
432
- * reconstructed from a pull. Mutually exclusive with `basicAuth`/
433
- * `bearerAuth`.
461
+ * reconstructed from a pull. `secret("KEY")` binds either one to a vault
462
+ * entry instead: it builds to `reference_client_id`/`reference_client_secret`
463
+ * through a key-only `elementum_vault_entry` lookup and round-trips through a
464
+ * pull (edk#1283). Mutually exclusive with `basicAuth`/`bearerAuth`.
434
465
  */
435
466
  export interface ApiRequestOAuth {
436
467
  readonly url?: ValueOrRef<unknown>;
437
- readonly clientId?: string;
438
- readonly clientSecret?: string;
468
+ readonly clientId?: string | Ref<string>;
469
+ readonly clientSecret?: string | Ref<string>;
439
470
  readonly requestType: "BASIC" | "FORM";
440
471
  readonly headers?: readonly ApiRequestHeader[];
441
472
  }
@@ -583,13 +614,19 @@ export declare function aiClassify(opts: AiClassifyOptions): ActionDef<{
583
614
  output: unknown;
584
615
  }>;
585
616
  type Empty = Record<string, never>;
617
+ /** A user recipient picked by identity rather than mapped from a record. */
618
+ export type StaticUserRecipient = RoleUserRef | string;
619
+ /** A group recipient picked by identity rather than mapped from a record. */
620
+ export type StaticGroupRecipient = GroupRef | string;
586
621
  export interface NotificationOptions {
587
622
  readonly title: ValueOrRef<string>;
588
623
  readonly message: ValueOrRef<string>;
589
624
  /** Description shown in the notification's metadata. Supports templates with value references. */
590
625
  readonly description?: ValueOrRef<string>;
591
- readonly userIds?: readonly string[];
592
- readonly groupIds?: readonly string[];
626
+ /** Users picked directly as recipients: `userRef(email)`, or a platform id. */
627
+ readonly userIds?: readonly StaticUserRecipient[];
628
+ /** Groups picked directly as recipients: an `org.groups.<key>` token, or a platform id. */
629
+ readonly groupIds?: readonly StaticGroupRecipient[];
593
630
  readonly userRefs?: readonly ValueOrRef<string>[];
594
631
  readonly groupRefs?: readonly ValueOrRef<string>[];
595
632
  /** Also notify the record's watchers. */
@@ -607,8 +644,8 @@ export interface AssignGroupOptions {
607
644
  }
608
645
  export declare function assignGroup(opts: AssignGroupOptions): ActionDef<Empty>;
609
646
  export interface AddWatcherOptions {
610
- readonly userIds?: readonly string[];
611
- readonly groupIds?: readonly string[];
647
+ readonly userIds?: readonly StaticUserRecipient[];
648
+ readonly groupIds?: readonly StaticGroupRecipient[];
612
649
  readonly record?: ValueOrRef<unknown>;
613
650
  }
614
651
  export declare function addWatcher(opts: AddWatcherOptions): ActionDef<Empty>;
@@ -844,7 +881,8 @@ type WorkflowOutputValue<T extends string | undefined, Multiple extends boolean
844
881
  export type RunAutomationOutput<A extends AutomationCatalogRef> = A["outputs"] extends Record<string, OutputPropertyRef> ? {
845
882
  readonly [K in keyof A["outputs"]]: WorkflowOutputValue<A["outputs"][K]["valueType"], A["outputs"][K]["multiple"]>;
846
883
  } : Record<string, unknown>;
847
- export interface RunAutomationOptions<A extends AutomationCatalogRef = AutomationCatalogRef> {
884
+ /** The UI's "Select Automation" mode: a known automation chosen at build time. */
885
+ export interface RunAutomationStaticOptions<A extends AutomationCatalogRef = AutomationCatalogRef> {
848
886
  readonly automation: A;
849
887
  readonly synchronous?: boolean;
850
888
  /**
@@ -860,7 +898,41 @@ export interface RunAutomationOptions<A extends AutomationCatalogRef = Automatio
860
898
  */
861
899
  readonly outputs?: readonly string[];
862
900
  }
863
- export declare function runAutomation<const A extends AutomationCatalogRef>(opts: RunAutomationOptions<A>): ActionDef<RunAutomationOutput<A>>;
901
+ /**
902
+ * The UI's "Dynamic Reference" mode: the automation to run is a value
903
+ * resolved at runtime, such as a trigger parameter or an earlier step's
904
+ * output holding an automation ID. The platform always waits for a dynamic
905
+ * target, so `synchronous` must be `true`.
906
+ */
907
+ export interface RunAutomationDynamicReferenceOptions<Outputs extends readonly string[] | undefined = undefined> {
908
+ readonly automation: Ref<string>;
909
+ readonly synchronous: true;
910
+ /** Input mappings by the target's on-demand trigger parameter **name**. */
911
+ readonly inputs?: readonly RunAutomationInput[];
912
+ /**
913
+ * Output names to capture from whichever automation runs. The target is
914
+ * unknown at build time, so each captured name is `unknown`. Omitting
915
+ * `outputs` exposes nothing on the step result.
916
+ */
917
+ readonly outputs?: Outputs;
918
+ }
919
+ /** Keys of a Dynamic Reference `runAutomation` step. Empty when `outputs` is omitted. */
920
+ export type RunAutomationDynamicResult<Outputs extends readonly string[] | undefined> = [
921
+ Outputs
922
+ ] extends [readonly string[]] ? {
923
+ readonly [K in Outputs[number]]: unknown;
924
+ } : Record<never, never>;
925
+ /** Step result for one `runAutomation` options object, static or Dynamic Reference. */
926
+ export type RunAutomationStepResult<O> = O extends {
927
+ readonly automation: Ref<string>;
928
+ } ? RunAutomationDynamicResult<O extends {
929
+ readonly outputs?: infer Out extends readonly string[] | undefined;
930
+ } ? Out : undefined> : O extends {
931
+ readonly automation: infer A extends AutomationCatalogRef;
932
+ } ? RunAutomationOutput<A> : Record<string, unknown>;
933
+ export type RunAutomationOptions<A extends AutomationCatalogRef = AutomationCatalogRef> = RunAutomationStaticOptions<A> | RunAutomationDynamicReferenceOptions;
934
+ export declare function runAutomation<const A extends AutomationCatalogRef>(opts: RunAutomationStaticOptions<A>): ActionDef<RunAutomationOutput<A>>;
935
+ export declare function runAutomation<const Outputs extends readonly string[] | undefined = undefined>(opts: RunAutomationDynamicReferenceOptions<Outputs>): ActionDef<RunAutomationDynamicResult<Outputs>>;
864
936
  export type ReadFileDataSource = {
865
937
  readonly type: "attachmentId";
866
938
  readonly value: ValueOrRef<unknown>;
@@ -1,9 +1,16 @@
1
1
  import { serializeValueOrRef } from "../../core/wire/ref-serializer.js";
2
2
  import { isExpr } from "../field/calc/runtime.js";
3
+ import { isRef } from "../shared/ref.js";
3
4
  import { renderCalculationExpression, } from "./calculation-expression.js";
4
5
  import { extractScriptBody, isScriptFile, readScriptFile, toPlatformScriptBody } from "./script-code.js";
5
6
  function workflowFields(fields) {
6
- return fields.map((f) => {
7
+ return fields.map((f, index) => {
8
+ if (typeof f.field !== "object" || f.field === null) {
9
+ // `app.fields.someKey` evaluates to undefined when the key is not in the
10
+ // bag (renamed or removed, e.g. by a re-pull, #1579).
11
+ throw new Error(`updateField: fields[${index}].field is ${String(f.field)}; the field key it reads does not exist on its app/element ` +
12
+ "(renamed or removed?). Check the app's fields bag for the current key.");
13
+ }
7
14
  const updateMode = "updateMode" in f ? f.updateMode : undefined;
8
15
  const fieldType = "fieldType" in f.field ? f.field.fieldType : undefined;
9
16
  if (updateMode !== undefined && fieldType !== "MULTI_PICKLIST" && fieldType !== "MULTI_PICKLIST_ID") {
@@ -76,6 +83,24 @@ export function updateField(opts) {
76
83
  ...recordKindOf(opts.app),
77
84
  };
78
85
  }
86
+ /**
87
+ * Update fields on every record matching a filter — a filter-scoped mass
88
+ * updateField. No single-record option: the filter selects the set.
89
+ */
90
+ export function bulkUpdateFields(opts) {
91
+ if (opts.fields.length === 0)
92
+ throw new Error("bulkUpdateFields requires at least one field.");
93
+ return {
94
+ key: "bulkUpdateFields",
95
+ config: {
96
+ aspectId: opts.app,
97
+ filter: opts.filter,
98
+ workflowFields: workflowFields(opts.fields),
99
+ },
100
+ __recordApp: opts.app.refName,
101
+ ...recordKindOf(opts.app),
102
+ };
103
+ }
79
104
  export function findRelatedRecords(opts) {
80
105
  return {
81
106
  key: "findRelatedRecords",
@@ -281,10 +306,15 @@ function outputSchema(outputs) {
281
306
  }
282
307
  const EXECUTE_SCRIPT_LIST_INPUT_MARKER = "__edkExecuteScriptListInput";
283
308
  /**
284
- * Wrap a list-valued executeScript input (e.g. a prior task's `.records`)
285
- * with the field mappings the script can read off each item - which fields,
286
- * and under what alias. Only meaningful for a list-shaped input; a scalar
287
- * input has no per-item fields to map.
309
+ * Wrap a record-valued executeScript input with the field mappings the script
310
+ * can read - which fields, and under what alias. The value is a whole record
311
+ * or a list of records (a prior task's `.records`, read per item).
312
+ *
313
+ * Inside this wrapper these deploy the whole record: a record trigger's
314
+ * `ctx.trigger.record`, and the `.record` of `recordSearch`, `createRecord`
315
+ * and `updateField`. Elsewhere they are the record ID a `record:` slot takes.
316
+ * An on-demand record parameter and `findRelatedRecords`' `.record` expose
317
+ * only the record ID, so they stay the ID here too.
288
318
  */
289
319
  export function withFieldMappings(value, fields) {
290
320
  return { [EXECUTE_SCRIPT_LIST_INPUT_MARKER]: true, value, fields };
@@ -384,8 +414,12 @@ export function apiRequest(opts) {
384
414
  oauth: {
385
415
  requestType: opts.oauth.requestType,
386
416
  ...(opts.oauth.url !== undefined ? { url: serializeValueOrRef(opts.oauth.url) } : {}),
387
- ...(opts.oauth.clientId !== undefined ? { clientId: opts.oauth.clientId } : {}),
388
- ...(opts.oauth.clientSecret !== undefined ? { clientSecret: opts.oauth.clientSecret } : {}),
417
+ ...(opts.oauth.clientId !== undefined
418
+ ? { clientId: typeof opts.oauth.clientId === "string" ? opts.oauth.clientId : serializeValueOrRef(opts.oauth.clientId) }
419
+ : {}),
420
+ ...(opts.oauth.clientSecret !== undefined
421
+ ? { clientSecret: typeof opts.oauth.clientSecret === "string" ? opts.oauth.clientSecret : serializeValueOrRef(opts.oauth.clientSecret) }
422
+ : {}),
389
423
  ...(opts.oauth.headers !== undefined ? { headers: apiRequestHeaders(opts.oauth.headers) } : {}),
390
424
  },
391
425
  } : {}),
@@ -523,13 +557,6 @@ export function aiClassify(opts) {
523
557
  };
524
558
  }
525
559
  export function notification(opts) {
526
- if (!opts.userIds?.length &&
527
- !opts.groupIds?.length &&
528
- !opts.userRefs?.length &&
529
- !opts.groupRefs?.length &&
530
- !opts.notifyWatchers) {
531
- throw new Error("notification requires at least one recipient (userIds, groupIds, userRefs, groupRefs, or notifyWatchers).");
532
- }
533
560
  return {
534
561
  key: "notification",
535
562
  config: {
@@ -814,10 +841,16 @@ export function approvalStatusUpdate(opts) {
814
841
  export function runAutomation(opts) {
815
842
  const inputs = opts.inputs ?? [];
816
843
  const outputs = opts.outputs ?? [];
844
+ const dynamic = isRef(opts.automation);
845
+ if (dynamic && opts.synchronous !== true) {
846
+ throw new Error("runAutomation: a Dynamic Reference target requires synchronous: true");
847
+ }
817
848
  return {
818
849
  key: "runAutomation",
819
850
  config: {
820
- targetAutomationId: opts.automation,
851
+ ...(dynamic
852
+ ? { targetAutomationRef: serializeValueOrRef(opts.automation) }
853
+ : { targetAutomationId: opts.automation }),
821
854
  synchronous: opts.synchronous ?? false,
822
855
  ...(inputs.length > 0
823
856
  ? { inputMappings: inputs.map((input) => ({ name: input.name, value: serializeValueOrRef(input.value) })) }
@@ -1,5 +1,6 @@
1
1
  import type { DeployableEntity } from "../../engine/entity.js";
2
- import { type TfBlock, type TfExpr, type TfValue } from "../../engine/tf/index.js";
2
+ import { type ValidationFailure } from "../../engine/validation.js";
3
+ import { type ChildResourceScope, type TfBlock, type TfExpr, type TfValue } from "../../engine/tf/index.js";
3
4
  import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
4
5
  import type { BuildFieldMetadata } from "../../graph/types.js";
5
6
  import type { AppServiceAccount } from "../service-account/build.js";
@@ -8,6 +9,8 @@ export interface AutomationToTfContext {
8
9
  readonly appRefName?: string;
9
10
  /** The product owner kind; defaults to app for direct legacy callers. */
10
11
  readonly parentScope?: "app" | "element";
12
+ /** Element handle. ei prefixes element automation labels with SanitizeName(handle). */
13
+ readonly ownerHandle?: string;
11
14
  /** Element owners only: the element declares `systemFields.audit`. */
12
15
  readonly ownerAuditFields?: boolean;
13
16
  /** RefNames of the workspace's elements without `systemFields.audit`. */
@@ -66,11 +69,25 @@ export interface AutomationToTfContext {
66
69
  */
67
70
  readonly localsAttrs?: Record<string, TfValue>;
68
71
  }
72
+ /**
73
+ * Terraform data label for a vault key. Keep this in lockstep with the
74
+ * exporter's VaultEntryLabel: readable for conventional uppercase keys and
75
+ * hash-suffixed whenever normalization could collide.
76
+ */
77
+ export declare function vaultEntryLabel(key: string): string;
69
78
  export interface AutomationToTfResult {
70
79
  readonly blocks: readonly TfBlock[];
71
80
  readonly address: string;
72
81
  }
73
82
  /** Run-automation targets reference publish for ACTIVE automations, automation for draft/inactive. */
74
- export declare function automationRunTargetResourceAttr(appTfLabel: string, automationRefName: string, activeAutomationRefNames: ReadonlySet<string> | undefined): TfExpr;
75
- /** App- or element-owned `automation` entity → provider HCL blocks. */
83
+ export declare function automationRunTargetResourceAttr(appTfLabel: string, automationRefName: string, activeAutomationRefNames: ReadonlySet<string> | undefined, scope?: ChildResourceScope, handle?: string): TfExpr;
84
+ /**
85
+ * edk#1499: script-input field mappings read fields off a whole record. A
86
+ * value that exposes only a record ID (an onDemand record parameter, or
87
+ * findRelatedRecords' `.record`) deploys refs["Record"] (ASPECT_RECORD_ID)
88
+ * plus field mappings, and the script receives `{}` at runtime. Record
89
+ * triggers' `ctx.trigger.record` and the `.record` of recordSearch,
90
+ * createRecord and updateField carry the whole record (#1284, #1489).
91
+ */
92
+ export declare function recordIdFieldMappingFailures(entity: DeployableEntity, payload: object, address: string): ValidationFailure[];
76
93
  export declare function automationToTf(entity: DeployableEntity, ctx: AutomationToTfContext): AutomationToTfResult;