@elementumai/edk 0.9.14 → 0.9.16

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 (124) hide show
  1. package/dist-sdk/pull/util.d.ts +0 -15
  2. package/dist-sdk/pull/util.js +44 -5
  3. package/dist-sdk/src/catalog/factories.d.ts +4 -2
  4. package/dist-sdk/src/catalog/factories.js +4 -0
  5. package/dist-sdk/src/catalog/from-authoring.js +5 -1
  6. package/dist-sdk/src/catalog/index.d.ts +2 -2
  7. package/dist-sdk/src/catalog/index.js +1 -1
  8. package/dist-sdk/src/catalog/token.js +2 -2
  9. package/dist-sdk/src/catalog/types.d.ts +7 -2
  10. package/dist-sdk/src/core/types/app.d.ts +4 -4
  11. package/dist-sdk/src/engine/build/context.d.ts +5 -4
  12. package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
  13. package/dist-sdk/src/engine/build/source-context.js +16 -0
  14. package/dist-sdk/src/engine/progress.d.ts +19 -1
  15. package/dist-sdk/src/engine/progress.js +33 -5
  16. package/dist-sdk/src/engine/pull/context.d.ts +9 -1
  17. package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -2
  18. package/dist-sdk/src/engine/pull/ref-only.js +14 -3
  19. package/dist-sdk/src/engine/workspace/loader.js +23 -2
  20. package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
  21. package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
  22. package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
  23. package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
  24. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
  25. package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +50 -4
  26. package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
  27. package/dist-sdk/src/entities/agent/from-tf.js +18 -3
  28. package/dist-sdk/src/entities/agent/module.js +1 -0
  29. package/dist-sdk/src/entities/agent/to-tf.js +15 -0
  30. package/dist-sdk/src/entities/agent/tools.d.ts +98 -5
  31. package/dist-sdk/src/entities/agent/tools.js +12 -3
  32. package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +15 -0
  33. package/dist-sdk/src/entities/agent-tool/from-tf.js +47 -4
  34. package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +9 -0
  35. package/dist-sdk/src/entities/agent-tool/to-tf.js +82 -25
  36. package/dist-sdk/src/entities/app/build.d.ts +2 -2
  37. package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
  38. package/dist-sdk/src/entities/app/module.js +8 -0
  39. package/dist-sdk/src/entities/app/to-tf.js +1 -0
  40. package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
  41. package/dist-sdk/src/entities/approval-chain/build.js +3 -0
  42. package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
  43. package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
  44. package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
  45. package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
  46. package/dist-sdk/src/entities/automation/build.d.ts +19 -12
  47. package/dist-sdk/src/entities/automation/build.js +36 -13
  48. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
  49. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
  50. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +222 -65
  51. package/dist-sdk/src/entities/automation/from-tf.d.ts +86 -6
  52. package/dist-sdk/src/entities/automation/from-tf.js +360 -63
  53. package/dist-sdk/src/entities/automation/index.d.ts +3 -2
  54. package/dist-sdk/src/entities/automation/index.js +3 -2
  55. package/dist-sdk/src/entities/automation/module.js +21 -16
  56. package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
  57. package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
  58. package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
  59. package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
  60. package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
  61. package/dist-sdk/src/entities/automation/script-code.js +72 -5
  62. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -24
  63. package/dist-sdk/src/entities/automation/tasks.js +33 -14
  64. package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
  65. package/dist-sdk/src/entities/automation/to-tf.js +123 -46
  66. package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
  67. package/dist-sdk/src/entities/automation/types.d.ts +2 -0
  68. package/dist-sdk/src/entities/automation/types.js +5 -0
  69. package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
  70. package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
  71. package/dist-sdk/src/entities/chart/build.d.ts +3 -3
  72. package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
  73. package/dist-sdk/src/entities/chart/from-tf.js +20 -13
  74. package/dist-sdk/src/entities/chart/to-tf.js +7 -5
  75. package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
  76. package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
  77. package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
  78. package/dist-sdk/src/entities/element/build.d.ts +11 -8
  79. package/dist-sdk/src/entities/element/build.js +14 -5
  80. package/dist-sdk/src/entities/element/locals.d.ts +2 -2
  81. package/dist-sdk/src/entities/element/locals.js +6 -2
  82. package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
  83. package/dist-sdk/src/entities/element/system-fields.js +12 -0
  84. package/dist-sdk/src/entities/element/to-tf.js +1 -0
  85. package/dist-sdk/src/entities/field/build.d.ts +2 -2
  86. package/dist-sdk/src/entities/field/from-tf.js +82 -4
  87. package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
  88. package/dist-sdk/src/entities/field/to-tf.js +11 -4
  89. package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
  90. package/dist-sdk/src/entities/relationship/from-tf.js +8 -5
  91. package/dist-sdk/src/entities/relationship/to-tf.js +13 -3
  92. package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
  93. package/dist-sdk/src/entities/search-table/module.js +2 -2
  94. package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
  95. package/dist-sdk/src/entities/search-table/types.js +1 -0
  96. package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
  97. package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
  98. package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -2
  99. package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
  100. package/dist-sdk/src/entities/shared/filters/index.js +17 -1
  101. package/dist-sdk/src/entities/shared/filters/print.js +25 -11
  102. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
  103. package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
  104. package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
  105. package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
  106. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
  107. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +47 -18
  108. package/dist-sdk/src/entities/skill/module.js +10 -0
  109. package/dist-sdk/src/entities/skill/to-tf.js +19 -0
  110. package/dist-sdk/src/entities/skill/tools.d.ts +29 -7
  111. package/dist-sdk/src/entities/skill/tools.js +6 -2
  112. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +18 -0
  113. package/dist-sdk/src/entities/skill-tool/from-tf.js +77 -4
  114. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
  115. package/dist-sdk/src/entities/skill-tool/to-tf.js +90 -46
  116. package/dist-sdk/src/entities/task/module.js +1 -1
  117. package/dist-sdk/src/entities/view/from-tf.js +30 -9
  118. package/dist-sdk/src/entities/view/to-tf.js +18 -10
  119. package/dist-sdk/src/entities/widget/from-tf.js +3 -3
  120. package/dist-sdk/src/entities/widget/to-tf.js +1 -0
  121. package/dist-sdk/src/graph/index.d.ts +15 -0
  122. package/dist-sdk/src/graph/index.js +19 -0
  123. package/dist-sdk/src/graph/types.d.ts +37 -1
  124. package/package.json +2 -1
@@ -32,13 +32,14 @@ import { buildContext, createForEachItemProxy } from "../shared/context.js";
32
32
  import { outputFieldTypesFromScriptSchema } from "./output-field-types.js";
33
33
  import { isRef } from "../shared/ref.js";
34
34
  import { API_TASK_REF_WIRE_NAMES, OUTPUT_KEY_WIRE_NAME } from "./output-key-wire-name.js";
35
- import { extractScriptBody, inferOutputSchema, tryExtractFromCurrentSource } from "./script-code.js";
35
+ import { extractScriptBody, inferOutputSchema, isScriptFile, readScriptFile, tryExtractFromCurrentSource } from "./script-code.js";
36
36
  import { serializeNode } from "./serialize.js";
37
37
  // Runtime factory imports stay below the public action-native surface. Their
38
38
  // ActionDef return values are an internal serialization detail; authored
39
39
  // automations call the direct fluent methods declared on ActionBuilder.
40
40
  import * as operatorFactories from "./operators.js";
41
41
  import * as actionFactories from "./tasks.js";
42
+ import { isWorkflowOutputDeclaration, workflowOutputFieldType, } from "./workflow-output.js";
42
43
  /** Placeholder `forEachTaskRefKey` the forEach item proxy emits; replaced with the real refKey. */
43
44
  export const FOR_EACH_PLACEHOLDER = "__forEach__";
44
45
  /**
@@ -128,23 +129,24 @@ function collectExecuteScriptOutputSchemas(tasks) {
128
129
  visit(tasks);
129
130
  return out;
130
131
  }
131
- /**
132
- * Schema kinds `outputFieldTypesFromScriptSchema` maps to an EXACT field
133
- * type — as opposed to its own catch-all default (`"TEXT"` for anything
134
- * unrecognized, including `"object"`), which is real for the wire's own
135
- * default but would be a wrong guess if promoted to `OutputPropertyRef.valueType`.
136
- */
137
132
  /**
138
133
  * Resolve an automation-level output's `valueType` from its (already
139
- * serialized) value: only when it's a plain ref to an executeScript task's
140
- * `result.<prop>` whose declared schema has an EXACT (not catch-all-guessed)
141
- * kind for that property. Anything else — a literal, a trigger/variable ref,
142
- * a non-executeScript task, or an unmodeled schema kind (e.g. `object`) —
143
- * returns `undefined` (unknown, not a guess).
134
+ * serialized) value. Explicit workflowOutput metadata wins. Otherwise, infer
135
+ * only a plain executeScript `result.<prop>` whose declared schema has an
136
+ * exact kind; the schema reader's catch-all TEXT default is not enough to
137
+ * stamp a catalog type. Anything else returns `undefined` (unknown, not a
138
+ * guess).
144
139
  */
145
140
  function resolveOutputValueType(value, scriptSchemas) {
146
141
  if (value === null || typeof value !== "object")
147
142
  return undefined;
143
+ const explicitFieldType = value.fieldType;
144
+ if (typeof explicitFieldType === "string") {
145
+ return {
146
+ fieldType: explicitFieldType,
147
+ multiple: value.multiple === true,
148
+ };
149
+ }
148
150
  const ref = value.taskReference;
149
151
  if (ref === null || typeof ref !== "object")
150
152
  return undefined;
@@ -372,6 +374,23 @@ function resolveVariableParamMarkers(node, idMap) {
372
374
  resolveVariableParamMarkers(v, idMap);
373
375
  }
374
376
  function serializeOutputValue(value) {
377
+ if (isWorkflowOutputDeclaration(value)) {
378
+ if (!isRef(value.value)) {
379
+ throw new EntityTfError("workflowOutput value must be a typed automation reference");
380
+ }
381
+ const serialized = serializeNode(value.value);
382
+ if (serialized === null || typeof serialized !== "object" || Array.isArray(serialized)) {
383
+ throw new EntityTfError("workflowOutput reference did not serialize to an object");
384
+ }
385
+ if (!("taskReference" in serialized) && !("triggerReference" in serialized)) {
386
+ throw new EntityTfError("workflowOutput explicit metadata is supported only for task and trigger references");
387
+ }
388
+ return {
389
+ ...serialized,
390
+ fieldType: workflowOutputFieldType(value.type),
391
+ multiple: value.multiple,
392
+ };
393
+ }
375
394
  return isRef(value) ? serializeNode(value) : { value };
376
395
  }
377
396
  function makeActionBuilder(state, mode = "root", item) {
@@ -430,7 +449,11 @@ function makeActionBuilder(state, mode = "root", item) {
430
449
  // and suppresses inference (pulled sources with no platform
431
450
  // output_schema print this, so adopted no-schema scripts do not
432
451
  // drift); omitting `outputs` entirely infers from the body.
433
- const body = tryExtractFromCurrentSource(name) ?? extractScriptBody(opts.code);
452
+ // A `scriptFile(...)` reference IS the exact text (no source scan, no
453
+ // toString(), no closure hazard: it is never a JS closure).
454
+ const body = isScriptFile(opts.code)
455
+ ? readScriptFile(opts.code)
456
+ : tryExtractFromCurrentSource(name) ?? extractScriptBody(opts.code);
434
457
  const outputs = opts.outputs === undefined ? inferOutputSchema(body) : (opts.outputs ?? undefined);
435
458
  const def = actionFactories.executeScriptActionDefWithBody(body, {
436
459
  ...(opts.inputs !== undefined ? { inputs: opts.inputs(context()) } : {}),
@@ -13,6 +13,7 @@
13
13
  import type { RefExpr, SortAst, ApprovalChainRefAst, DatamineRefAst, TableRefAst, AppRefAst, FieldRefAst, UserFieldRefAst, UnresolvedRefAst } from "../../shared/filters/ast.js";
14
14
  import type { Filter } from "../../shared/filters/types.js";
15
15
  import type { AutomationStatus } from "../build.js";
16
+ import type { WorkflowOutputType } from "../workflow-output.js";
16
17
  export type { RefExpr, SortAst, AppRefAst, ApprovalChainRefAst, DatamineRefAst, TableRefAst, FieldRefAst, UserFieldRefAst, UnresolvedRefAst, };
17
18
  /**
18
19
  * A TaskCall represents one call to a task factory like `executeScript({...})`.
@@ -154,5 +155,8 @@ export interface AutomationAst {
154
155
  readonly outputs?: readonly {
155
156
  name: string;
156
157
  value: unknown;
158
+ /** Present only when bare-reference inference cannot reproduce live metadata. */
159
+ explicitType?: WorkflowOutputType;
160
+ explicitMultiple?: boolean;
157
161
  }[];
158
162
  }
@@ -53,6 +53,13 @@ export declare function extractAuthoredAutomationDescription(source: string): st
53
53
  export declare function preserveAuthoredAutomationDescription(freshSource: string, existingSource: string): string;
54
54
  /** Pull merge: preserve authored revision + description across live reprint. */
55
55
  export declare function preserveAuthoredAutomationPullMeta(freshSource: string, existingSource: string): string;
56
+ /** A plain-JS script file printed beside the automation, relative to the automations folder. */
57
+ export interface PrintedScriptFile {
58
+ readonly path: string;
59
+ readonly content: string;
60
+ }
61
+ /** Folder (inside the automations folder) that holds printed script files. */
62
+ export declare const SCRIPT_FILES_DIR = "scripts";
56
63
  export interface PrintAutomationV2Options {
57
64
  readonly refName?: string;
58
65
  /**
@@ -69,6 +76,7 @@ export interface PrintAutomationV2Options {
69
76
  */
70
77
  readonly foreignAppRefNames?: ReadonlyMap<string, string>;
71
78
  readonly foreignElementRefNames?: ReadonlyMap<string, string>;
79
+ readonly foreignTaskRefNames?: ReadonlyMap<string, string>;
72
80
  /** Diagnostics emitted by the bridge for raw UUIDs retained in this pull. */
73
81
  readonly unresolvedReferences?: readonly UnresolvedReferenceDiagnostic[];
74
82
  }
@@ -77,3 +85,14 @@ export interface PrintAutomationV2Options {
77
85
  * printer's `printAutomationFinalized` convention.
78
86
  */
79
87
  export declare function printAutomationV2(ast: AutomationAst, opts?: PrintAutomationV2Options): string;
88
+ /**
89
+ * Like {@link printAutomationV2}, but `executeScript` bodies print as
90
+ * `scriptFile("./scripts/<automation>.<task>.js")` references and the bodies
91
+ * come back as files to write beside the automation (relative to the
92
+ * automations folder). The bodies never enter the TypeScript source, so they
93
+ * are never type-checked, annotated or type-stripped.
94
+ */
95
+ export declare function printAutomationV2WithScriptFiles(ast: AutomationAst, opts?: PrintAutomationV2Options): {
96
+ readonly source: string;
97
+ readonly scriptFiles: readonly PrintedScriptFile[];
98
+ };