@elementumai/edk 0.9.20 → 0.10.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 (147) 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/to-tf.d.ts +6 -0
  49. package/dist-sdk/src/entities/app/to-tf.js +21 -2
  50. package/dist-sdk/src/entities/automation/build.d.ts +10 -2
  51. package/dist-sdk/src/entities/automation/build.js +104 -17
  52. package/dist-sdk/src/entities/automation/calculation-expression.d.ts +7 -7
  53. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +17 -4
  54. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +156 -19
  55. package/dist-sdk/src/entities/automation/from-tf.d.ts +9 -2
  56. package/dist-sdk/src/entities/automation/from-tf.js +366 -86
  57. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  58. package/dist-sdk/src/entities/automation/index.js +1 -1
  59. package/dist-sdk/src/entities/automation/module.d.ts +3 -0
  60. package/dist-sdk/src/entities/automation/module.js +70 -7
  61. package/dist-sdk/src/entities/automation/script-code.d.ts +5 -2
  62. package/dist-sdk/src/entities/automation/script-code.js +23 -5
  63. package/dist-sdk/src/entities/automation/task-output-labels.d.ts +37 -0
  64. package/dist-sdk/src/entities/automation/task-output-labels.js +76 -0
  65. package/dist-sdk/src/entities/automation/tasks.d.ts +92 -20
  66. package/dist-sdk/src/entities/automation/tasks.js +48 -15
  67. package/dist-sdk/src/entities/automation/to-tf.d.ts +20 -3
  68. package/dist-sdk/src/entities/automation/to-tf.js +606 -62
  69. package/dist-sdk/src/entities/automation/triggers.d.ts +8 -4
  70. package/dist-sdk/src/entities/automation/types.d.ts +9 -0
  71. package/dist-sdk/src/entities/automation/types.js +19 -0
  72. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +1 -1
  73. package/dist-sdk/src/entities/automation/value-ref-tf.js +1 -1
  74. package/dist-sdk/src/entities/chart/from-tf.js +9 -1
  75. package/dist-sdk/src/entities/data-lookup/module.js +2 -0
  76. package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
  77. package/dist-sdk/src/entities/dynamic-layout/to-tf.js +7 -5
  78. package/dist-sdk/src/entities/element/build.d.ts +3 -0
  79. package/dist-sdk/src/entities/element/build.js +1 -0
  80. package/dist-sdk/src/entities/element/from-tf.js +4 -0
  81. package/dist-sdk/src/entities/element/to-tf.d.ts +1 -1
  82. package/dist-sdk/src/entities/element/to-tf.js +8 -14
  83. package/dist-sdk/src/entities/field/build.d.ts +3 -2
  84. package/dist-sdk/src/entities/field/calc.d.ts +7 -7
  85. package/dist-sdk/src/entities/field/from-tf.d.ts +4 -4
  86. package/dist-sdk/src/entities/field/from-tf.js +205 -48
  87. package/dist-sdk/src/entities/field/module.js +1 -0
  88. package/dist-sdk/src/entities/field/options.js +6 -1
  89. package/dist-sdk/src/entities/field/to-tf.d.ts +4 -4
  90. package/dist-sdk/src/entities/field/to-tf.js +7 -1
  91. package/dist-sdk/src/entities/field/types.d.ts +2 -0
  92. package/dist-sdk/src/entities/field/types.js +27 -0
  93. package/dist-sdk/src/entities/role/from-tf.js +3 -3
  94. package/dist-sdk/src/entities/role/to-tf.d.ts +2 -0
  95. package/dist-sdk/src/entities/role/to-tf.js +12 -4
  96. package/dist-sdk/src/entities/service-account/from-tf.js +3 -3
  97. package/dist-sdk/src/entities/service-account/workspace-owner.d.ts +16 -0
  98. package/dist-sdk/src/entities/service-account/workspace-owner.js +22 -0
  99. package/dist-sdk/src/entities/shared/filters/ast.d.ts +15 -1
  100. package/dist-sdk/src/entities/shared/filters/ast.js +2 -0
  101. package/dist-sdk/src/entities/shared/filters/index.d.ts +5 -0
  102. package/dist-sdk/src/entities/shared/filters/index.js +5 -0
  103. package/dist-sdk/src/entities/shared/filters/print.js +7 -2
  104. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +5 -0
  105. package/dist-sdk/src/entities/shared/filters/tf-codec.js +42 -7
  106. package/dist-sdk/src/entities/shared/filters/types.d.ts +8 -3
  107. package/dist-sdk/src/entities/shared/ref.d.ts +5 -7
  108. package/dist-sdk/src/entities/shared/ref.js +5 -7
  109. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +9 -0
  110. package/dist-sdk/src/entities/shared/tool-field-ref.js +35 -2
  111. package/dist-sdk/src/entities/shared/types/field-types.d.ts +10 -0
  112. package/dist-sdk/src/entities/shared/types/field-types.js +4 -0
  113. package/dist-sdk/src/entities/skill/access-policy.js +3 -3
  114. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +3 -0
  115. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +12 -5
  116. package/dist-sdk/src/entities/skill/from-tf.js +4 -2
  117. package/dist-sdk/src/entities/skill/module.js +2 -0
  118. package/dist-sdk/src/entities/skill-tool/from-tf.js +41 -8
  119. package/dist-sdk/src/entities/skill-tool/module.js +3 -0
  120. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +0 -6
  121. package/dist-sdk/src/entities/skill-tool/to-tf.js +22 -9
  122. package/dist-sdk/src/entities/task/build.d.ts +8 -0
  123. package/dist-sdk/src/entities/task/build.js +10 -1
  124. package/dist-sdk/src/entities/task/from-tf.d.ts +4 -2
  125. package/dist-sdk/src/entities/task/from-tf.js +7 -2
  126. package/dist-sdk/src/entities/task/module.js +2 -2
  127. package/dist-sdk/src/entities/task/to-tf.d.ts +8 -4
  128. package/dist-sdk/src/entities/task/to-tf.js +28 -1
  129. package/dist-sdk/src/entities/view/from-tf.js +9 -1
  130. package/dist-sdk/src/entities/view/to-tf.d.ts +6 -7
  131. package/dist-sdk/src/entities/view/to-tf.js +19 -8
  132. package/dist-sdk/src/entities/visual-flow/build.d.ts +16 -1
  133. package/dist-sdk/src/entities/visual-flow/build.js +9 -0
  134. package/dist-sdk/src/entities/visual-flow/from-tf.d.ts +14 -0
  135. package/dist-sdk/src/entities/visual-flow/from-tf.js +51 -3
  136. package/dist-sdk/src/entities/visual-flow/index.d.ts +1 -1
  137. package/dist-sdk/src/entities/visual-flow/index.js +1 -1
  138. package/dist-sdk/src/entities/visual-flow/printer.js +19 -0
  139. package/dist-sdk/src/entities/visual-flow/to-tf.js +87 -3
  140. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  141. package/dist-sdk/src/entities/widget/to-tf.d.ts +2 -0
  142. package/dist-sdk/src/entities/widget/to-tf.js +7 -6
  143. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.d.ts +133 -9
  144. package/dist-sdk/src/generated/ragnarok/ragnarok-spec.js +2 -2
  145. package/dist-sdk/src/graph/index.d.ts +1 -0
  146. package/dist-sdk/src/graph/types.d.ts +29 -3
  147. package/package.json +7 -3
@@ -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;