@elementumai/edk 0.9.5 → 0.9.7

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 (97) hide show
  1. package/README.md +31 -1
  2. package/dist-sdk/src/catalog/factories.d.ts +12 -3
  3. package/dist-sdk/src/catalog/factories.js +9 -6
  4. package/dist-sdk/src/catalog/org.js +26 -13
  5. package/dist-sdk/src/catalog/types.d.ts +22 -1
  6. package/dist-sdk/src/core/index.d.ts +1 -1
  7. package/dist-sdk/src/core/system-fields.d.ts +4 -0
  8. package/dist-sdk/src/core/system-fields.js +15 -0
  9. package/dist-sdk/src/core/types/app.d.ts +14 -9
  10. package/dist-sdk/src/core/types/platform.d.ts +1 -1
  11. package/dist-sdk/src/engine/build/context.d.ts +4 -0
  12. package/dist-sdk/src/engine/pull/context.d.ts +9 -0
  13. package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
  14. package/dist-sdk/src/engine/pull/ref-only.js +35 -2
  15. package/dist-sdk/src/entities/access-policy/from-tf.js +14 -2
  16. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +6 -0
  17. package/dist-sdk/src/entities/access-policy/to-tf.js +4 -1
  18. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +18 -1
  19. package/dist-sdk/src/entities/agent/module.js +1 -0
  20. package/dist-sdk/src/entities/agent/to-tf.d.ts +1 -0
  21. package/dist-sdk/src/entities/agent/to-tf.js +1 -0
  22. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +9 -0
  23. package/dist-sdk/src/entities/agent-tool/from-tf.js +10 -2
  24. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
  25. package/dist-sdk/src/entities/agent-tool/to-tf.js +2 -3
  26. package/dist-sdk/src/entities/app/build.d.ts +42 -22
  27. package/dist-sdk/src/entities/app/build.js +12 -5
  28. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +10 -0
  29. package/dist-sdk/src/entities/app/from-tf.js +71 -8
  30. package/dist-sdk/src/entities/app/index.d.ts +3 -2
  31. package/dist-sdk/src/entities/app/index.js +2 -1
  32. package/dist-sdk/src/entities/app/to-tf.js +16 -0
  33. package/dist-sdk/src/entities/automation/build.d.ts +31 -19
  34. package/dist-sdk/src/entities/automation/build.js +85 -7
  35. package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
  36. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +5 -3
  37. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +26 -12
  38. package/dist-sdk/src/entities/automation/from-tf.js +364 -31
  39. package/dist-sdk/src/entities/automation/index.d.ts +1 -1
  40. package/dist-sdk/src/entities/automation/module.js +2 -2
  41. package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
  42. package/dist-sdk/src/entities/automation/operators.js +1 -0
  43. package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
  44. package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
  45. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +8 -0
  46. package/dist-sdk/src/entities/automation/output-key-wire-name.js +16 -0
  47. package/dist-sdk/src/entities/automation/script-code.js +153 -25
  48. package/dist-sdk/src/entities/automation/tasks.d.ts +100 -37
  49. package/dist-sdk/src/entities/automation/tasks.js +44 -43
  50. package/dist-sdk/src/entities/automation/to-tf.d.ts +3 -1
  51. package/dist-sdk/src/entities/automation/to-tf.js +454 -58
  52. package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
  53. package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
  54. package/dist-sdk/src/entities/element/build.js +1 -0
  55. package/dist-sdk/src/entities/element/index.d.ts +2 -1
  56. package/dist-sdk/src/entities/element/index.js +2 -1
  57. package/dist-sdk/src/entities/field/build.d.ts +94 -3
  58. package/dist-sdk/src/entities/field/build.js +82 -3
  59. package/dist-sdk/src/entities/field/from-tf.js +92 -1
  60. package/dist-sdk/src/entities/field/locals.js +6 -7
  61. package/dist-sdk/src/entities/field/options.d.ts +2 -0
  62. package/dist-sdk/src/entities/field/options.js +12 -2
  63. package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
  64. package/dist-sdk/src/entities/field/to-tf.d.ts +12 -2
  65. package/dist-sdk/src/entities/field/to-tf.js +172 -51
  66. package/dist-sdk/src/entities/field/types.js +2 -0
  67. package/dist-sdk/src/entities/record-create-form/to-tf.js +5 -8
  68. package/dist-sdk/src/entities/relationship/from-tf.js +91 -9
  69. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
  70. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
  71. package/dist-sdk/src/entities/shared/filters/ast.d.ts +18 -1
  72. package/dist-sdk/src/entities/shared/filters/ast.js +1 -0
  73. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +6 -1
  74. package/dist-sdk/src/entities/shared/filters/tf-codec.js +6 -4
  75. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
  76. package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
  77. package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
  78. package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
  79. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
  80. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +44 -15
  81. package/dist-sdk/src/entities/skill/from-tf.js +11 -1
  82. package/dist-sdk/src/entities/skill/input-coverage.d.ts +68 -0
  83. package/dist-sdk/src/entities/skill/input-coverage.js +184 -0
  84. package/dist-sdk/src/entities/skill/module.js +2 -0
  85. package/dist-sdk/src/entities/skill/to-tf.d.ts +3 -0
  86. package/dist-sdk/src/entities/skill/to-tf.js +7 -2
  87. package/dist-sdk/src/entities/skill/tools.d.ts +10 -1
  88. package/dist-sdk/src/entities/skill/tools.js +0 -5
  89. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
  90. package/dist-sdk/src/entities/skill-tool/from-tf.js +40 -11
  91. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -2
  92. package/dist-sdk/src/entities/skill-tool/to-tf.js +24 -16
  93. package/dist-sdk/src/entities/table/to-tf.js +18 -1
  94. package/dist-sdk/src/entities/view/to-tf.js +8 -3
  95. package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
  96. package/dist-sdk/src/graph/types.d.ts +3 -0
  97. package/package.json +2 -1
@@ -4,9 +4,16 @@ import { renderCalculationExpression, } from "./calculation-expression.js";
4
4
  import { extractScriptBody } from "./script-code.js";
5
5
  function workflowFields(fields) {
6
6
  return fields.map((f) => {
7
+ const updateMode = "updateMode" in f ? f.updateMode : undefined;
8
+ const fieldType = "fieldType" in f.field ? f.field.fieldType : undefined;
9
+ if (updateMode !== undefined && fieldType !== "MULTI_PICKLIST" && fieldType !== "MULTI_PICKLIST_ID") {
10
+ const fieldName = "name" in f.field ? f.field.name : f.field.value;
11
+ throw new Error(`updateMode is only supported for Multi-Select fields; received ${fieldType ?? "unresolved"} field "${fieldName}".`);
12
+ }
7
13
  return {
8
14
  aspectFieldId: f.field, // token → field id at deploy
9
15
  valueReference: serializeValueOrRef(f.value),
16
+ ...(updateMode === "add" ? { operation: "ADD" } : {}),
10
17
  };
11
18
  });
12
19
  }
@@ -171,10 +178,22 @@ export function setVariable(opts) {
171
178
  },
172
179
  };
173
180
  }
174
- // --- executeScript ----------------------------------------------------------
175
- /** Map an output schema (name → type) to the platform's tagged object shape. */
181
+ /** Split the authored `outputs` option into the root name and the properties. */
182
+ function normalizeScriptOutputs(outputs) {
183
+ const properties = outputs.properties;
184
+ if (typeof properties !== "object" || properties === null || Array.isArray(properties)) {
185
+ return { properties: outputs };
186
+ }
187
+ const name = outputs.name;
188
+ return {
189
+ ...(typeof name === "string" && name !== "" ? { name } : {}),
190
+ properties: properties,
191
+ };
192
+ }
193
+ /** Map an output schema to the platform's tagged object shape. */
176
194
  function outputSchema(outputs) {
177
- const properties = Object.entries(outputs).map(([name, type]) => {
195
+ const { name: rootName, properties: declared } = normalizeScriptOutputs(outputs);
196
+ const properties = Object.entries(declared).map(([name, type]) => {
178
197
  switch (type) {
179
198
  case "integer":
180
199
  return { integer: { name } };
@@ -183,14 +202,13 @@ function outputSchema(outputs) {
183
202
  return { number: { name } };
184
203
  case "boolean":
185
204
  return { bool: { name } };
205
+ case "object":
206
+ return { object: { name } };
186
207
  default:
187
208
  return { string: { name } };
188
209
  }
189
210
  });
190
- // No root name: the canonical provider form omits it, ei's exporter and the
191
- // import read-back both DROP empty names — emitting name:"" would diff
192
- // against both (adoption zero-change gate + build-vs-export).
193
- return { object: { properties } };
211
+ return { object: { ...(rootName !== undefined ? { name: rootName } : {}), properties } };
194
212
  }
195
213
  /**
196
214
  * Build the executeScript `ActionDef` from an ALREADY-RESOLVED body string.
@@ -402,8 +420,8 @@ export function notification(opts) {
402
420
  ...(opts.description !== undefined ? { description: opts.description } : {}),
403
421
  ...(opts.userIds?.length ? { userIds: opts.userIds } : {}),
404
422
  ...(opts.groupIds?.length ? { groupIds: opts.groupIds } : {}),
405
- ...(opts.userRefs !== undefined ? { userValueReferences: refList(opts.userRefs) } : {}),
406
- ...(opts.groupRefs !== undefined ? { groupValueReferences: refList(opts.groupRefs) } : {}),
423
+ ...(opts.userRefs !== undefined ? { users: refList(opts.userRefs) } : {}),
424
+ ...(opts.groupRefs !== undefined ? { groups: refList(opts.groupRefs) } : {}),
407
425
  ...(opts.notifyWatchers !== undefined ? { notifyWatchers: opts.notifyWatchers } : {}),
408
426
  },
409
427
  };
@@ -418,16 +436,14 @@ export function assignGroup(opts) {
418
436
  return { key: "assignGroup", config: { fieldId: opts.field, groupId: opts.groupId } };
419
437
  }
420
438
  export function addWatcher(opts) {
421
- if (!opts.userIds?.length && !opts.groupIds?.length && !opts.userRefs?.length && !opts.groupRefs?.length) {
422
- throw new Error("addWatcher requires at least one of: userIds, groupIds, userRefs, groupRefs.");
439
+ if (!opts.userIds?.length && !opts.groupIds?.length) {
440
+ throw new Error("addWatcher requires at least one of: userIds or groupIds.");
423
441
  }
424
442
  return {
425
443
  key: "addWatcher",
426
444
  config: {
427
445
  ...(opts.userIds?.length ? { userIds: opts.userIds } : {}),
428
446
  ...(opts.groupIds?.length ? { groupIds: opts.groupIds } : {}),
429
- ...(opts.userRefs !== undefined ? { userValueReferences: refList(opts.userRefs) } : {}),
430
- ...(opts.groupRefs !== undefined ? { groupValueReferences: refList(opts.groupRefs) } : {}),
431
447
  ...(opts.record !== undefined ? { recordReference: serializeValueOrRef(opts.record) } : {}),
432
448
  },
433
449
  };
@@ -672,20 +688,18 @@ export function approvalStatusUpdate(opts) {
672
688
  };
673
689
  }
674
690
  export function runAutomation(opts) {
675
- const hasInputs = (opts.inputs?.length ?? 0) > 0;
676
- const common = {
677
- synchronous: opts.synchronous ?? false,
678
- inputMappings: [],
679
- dynamicInputMappings: hasInputs
680
- ? opts.inputs.map((i) => ({ name: i.name, value: serializeValueOrRef(i.value) }))
681
- : [],
682
- outputMappings: (opts.outputs ?? []).map((name) => ({ name })),
683
- };
691
+ const inputs = opts.inputs ?? [];
692
+ const outputs = opts.outputs ?? [];
684
693
  return {
685
694
  key: "runAutomation",
686
- config: hasInputs
687
- ? { targetAutomationRef: { type: "STATIC", value: opts.automation }, ...common }
688
- : { targetAutomationId: opts.automation, ...common },
695
+ config: {
696
+ targetAutomationId: opts.automation,
697
+ synchronous: opts.synchronous ?? false,
698
+ ...(inputs.length > 0
699
+ ? { inputMappings: inputs.map((input) => ({ name: input.name, value: serializeValueOrRef(input.value) })) }
700
+ : {}),
701
+ ...(outputs.length > 0 ? { outputMappings: outputs.map((name) => ({ name })) } : {}),
702
+ },
689
703
  };
690
704
  }
691
705
  export function readFile(opts) {
@@ -719,33 +733,20 @@ export function bulkExcel(opts) {
719
733
  };
720
734
  }
721
735
  export function approvalChain(opts) {
722
- if (!opts.approverIds?.length && !opts.approvers?.length) {
723
- throw new Error("approvalChain requires at least one approverId or approver.");
724
- }
725
736
  return {
726
737
  key: "approvalChain",
727
738
  config: {
728
- ...(opts.approverIds !== undefined ? { approverIds: opts.approverIds } : {}),
729
- ...(opts.approvers !== undefined ? { approvers: opts.approvers.map((a) => serializeValueOrRef(a)) } : {}),
739
+ approvalProcessId: opts.approvalProcess,
740
+ recordReference: serializeValueOrRef(opts.record),
741
+ requesterReference: serializeValueOrRef(opts.requester),
742
+ ...(opts.approvers !== undefined ? { approverReferences: opts.approvers.map((a) => serializeValueOrRef(a)) } : {}),
730
743
  ...(opts.reason !== undefined ? { reason: serializeValueOrRef(opts.reason) } : {}),
731
744
  ...(opts.summary !== undefined ? { summary: serializeValueOrRef(opts.summary) } : {}),
732
745
  },
733
746
  };
734
747
  }
735
748
  export function approvalChainTemplate(opts) {
736
- return {
737
- key: "approvalChainTemplate",
738
- config: {
739
- approvalChainTemplateId: opts.approvalChainTemplateId,
740
- requesterId: serializeValueOrRef(opts.requester),
741
- recordId: serializeValueOrRef(opts.record),
742
- ...(opts.summary !== undefined ? { summary: serializeValueOrRef(opts.summary) } : {}),
743
- ...(opts.reason !== undefined ? { reason: serializeValueOrRef(opts.reason) } : {}),
744
- ...(opts.relatedRecord !== undefined ? { relatedRecordId: serializeValueOrRef(opts.relatedRecord) } : {}),
745
- ...(opts.tags !== undefined ? { tags: serializeValueOrRef(opts.tags) } : {}),
746
- ...(opts.dynamicApprovers !== undefined ? { dynamicApprovers: opts.dynamicApprovers } : {}),
747
- },
748
- };
749
+ return approvalChain(opts);
749
750
  }
750
751
  export function sendSurvey(opts) {
751
752
  if (!opts.userIds?.length && !opts.groupIds?.length) {
@@ -1,5 +1,5 @@
1
1
  import type { DeployableEntity } from "../../engine/entity.js";
2
- import { type TfBlock, type TfValue } from "../../engine/tf/index.js";
2
+ import { type TfBlock, type TfExpr, type TfValue } from "../../engine/tf/index.js";
3
3
  import { type OrgRefLookup, type WorkspaceAspect } from "../../engine/build/context.js";
4
4
  import type { BuildFieldMetadata } from "../../graph/types.js";
5
5
  import type { AppServiceAccount } from "../service-account/build.js";
@@ -56,5 +56,7 @@ export interface AutomationToTfResult {
56
56
  readonly blocks: readonly TfBlock[];
57
57
  readonly address: string;
58
58
  }
59
+ /** Run-automation targets reference publish for ACTIVE automations, automation for draft/inactive. */
60
+ export declare function automationRunTargetResourceAttr(appTfLabel: string, automationRefName: string, activeAutomationRefNames: ReadonlySet<string> | undefined): TfExpr;
59
61
  /** App- or element-owned `automation` entity → provider HCL blocks. */
60
62
  export declare function automationToTf(entity: DeployableEntity, ctx: AutomationToTfContext): AutomationToTfResult;