@elementumai/edk 0.9.11 → 0.9.12

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 (89) hide show
  1. package/README.md +39 -5
  2. package/dist-sdk/src/catalog/factories.d.ts +35 -14
  3. package/dist-sdk/src/catalog/factories.js +64 -13
  4. package/dist-sdk/src/catalog/from-authoring.js +4 -4
  5. package/dist-sdk/src/catalog/index.d.ts +1 -1
  6. package/dist-sdk/src/catalog/org.js +3 -2
  7. package/dist-sdk/src/catalog/token.js +4 -0
  8. package/dist-sdk/src/catalog/types.d.ts +13 -3
  9. package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
  10. package/dist-sdk/src/core/triggers/on-demand.js +2 -4
  11. package/dist-sdk/src/engine/entity.d.ts +2 -0
  12. package/dist-sdk/src/engine/logging.d.ts +90 -0
  13. package/dist-sdk/src/engine/logging.js +124 -0
  14. package/dist-sdk/src/engine/progress.d.ts +119 -0
  15. package/dist-sdk/src/engine/progress.js +647 -0
  16. package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
  17. package/dist-sdk/src/engine/pull/result-output.js +48 -0
  18. package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
  19. package/dist-sdk/src/entities/app/build.d.ts +8 -1
  20. package/dist-sdk/src/entities/app/from-tf.js +4 -4
  21. package/dist-sdk/src/entities/app/to-tf.js +9 -13
  22. package/dist-sdk/src/entities/automation/build.d.ts +11 -16
  23. package/dist-sdk/src/entities/automation/build.js +38 -8
  24. package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
  25. package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
  26. package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
  27. package/dist-sdk/src/entities/automation/deserializer/print-automation.js +239 -34
  28. package/dist-sdk/src/entities/automation/from-tf.js +168 -23
  29. package/dist-sdk/src/entities/automation/index.d.ts +2 -2
  30. package/dist-sdk/src/entities/automation/module.js +2 -2
  31. package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
  32. package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
  33. package/dist-sdk/src/entities/automation/script-code.js +659 -101
  34. package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
  35. package/dist-sdk/src/entities/automation/tasks.js +31 -15
  36. package/dist-sdk/src/entities/automation/to-tf.js +362 -58
  37. package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
  38. package/dist-sdk/src/entities/automation/triggers.js +4 -2
  39. package/dist-sdk/src/entities/chart/build.d.ts +15 -3
  40. package/dist-sdk/src/entities/chart/build.js +6 -1
  41. package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
  42. package/dist-sdk/src/entities/chart/from-tf.js +71 -8
  43. package/dist-sdk/src/entities/chart/index.d.ts +1 -1
  44. package/dist-sdk/src/entities/chart/index.js +1 -1
  45. package/dist-sdk/src/entities/chart/printer.js +27 -7
  46. package/dist-sdk/src/entities/chart/to-tf.js +56 -2
  47. package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
  48. package/dist-sdk/src/entities/element/build.d.ts +6 -5
  49. package/dist-sdk/src/entities/element/from-tf.js +3 -2
  50. package/dist-sdk/src/entities/element/module.js +1 -0
  51. package/dist-sdk/src/entities/element/to-tf.d.ts +3 -0
  52. package/dist-sdk/src/entities/element/to-tf.js +9 -1
  53. package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
  54. package/dist-sdk/src/entities/field/from-tf.js +73 -1
  55. package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
  56. package/dist-sdk/src/entities/field/metadata.js +34 -0
  57. package/dist-sdk/src/entities/relationship/build.d.ts +17 -6
  58. package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
  59. package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
  60. package/dist-sdk/src/entities/relationship/from-tf.js +19 -34
  61. package/dist-sdk/src/entities/relationship/to-tf.js +15 -2
  62. package/dist-sdk/src/entities/shared/context.d.ts +6 -3
  63. package/dist-sdk/src/entities/shared/context.js +19 -1
  64. package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
  65. package/dist-sdk/src/entities/shared/filters/index.js +28 -0
  66. package/dist-sdk/src/entities/shared/filters/print.js +2 -0
  67. package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
  68. package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
  69. package/dist-sdk/src/entities/shared/filters/types.d.ts +1 -1
  70. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
  71. package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -23
  72. package/dist-sdk/src/entities/skill/module.js +1 -0
  73. package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
  74. package/dist-sdk/src/entities/skill/to-tf.js +17 -0
  75. package/dist-sdk/src/entities/skill/tools.d.ts +38 -12
  76. package/dist-sdk/src/entities/skill/tools.js +2 -1
  77. package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +8 -12
  78. package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -44
  79. package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
  80. package/dist-sdk/src/entities/skill-tool/to-tf.js +45 -7
  81. package/dist-sdk/src/entities/table/build.js +10 -2
  82. package/dist-sdk/src/entities/view/to-tf.js +5 -7
  83. package/dist-sdk/src/entities/widget/build.d.ts +26 -0
  84. package/dist-sdk/src/entities/widget/from-tf.js +30 -5
  85. package/dist-sdk/src/entities/widget/to-tf.js +111 -7
  86. package/dist-sdk/src/graph/types.d.ts +5 -0
  87. package/package.json +1 -1
  88. package/dist-sdk/src/core/types/platform.d.ts +0 -2
  89. package/dist-sdk/src/core/types/platform.js +0 -1
@@ -48,7 +48,7 @@ type UpdateModeForField<F extends FieldRef | UnsafePlatformId> = [F] extends [Mu
48
48
  type UpdateValueForField<F extends FieldRef | UnsafePlatformId> = IsAny<F> extends true ? {
49
49
  readonly value: ValueOrRef<unknown>;
50
50
  } : [F] extends [MultiSelectFieldRef] ? {
51
- readonly value: readonly string[] | Ref<readonly DropdownValue[], string>;
51
+ readonly value: readonly string[] | Ref<readonly string[], string> | Ref<readonly DropdownValue[], string>;
52
52
  } : {
53
53
  readonly value: ValueOrRef<unknown>;
54
54
  };
@@ -103,8 +103,12 @@ export interface CreateRecordOptions<A extends AppOrElementRef = AppOrElementRef
103
103
  readonly fields: readonly FieldAssignment[];
104
104
  /** Relate the new record to `record` (the triggering/source record). */
105
105
  readonly relateToRecord?: boolean;
106
- /** A record reference to relate to, when `relateToRecord` is set. */
107
- readonly record?: RecordReference<A>;
106
+ /**
107
+ * A record reference to relate to, when `relateToRecord` is set. This is
108
+ * typically the TRIGGERING record, which belongs to a DIFFERENT app/element
109
+ * than the one being created here (`app: A`) - deliberately not tied to `A`.
110
+ */
111
+ readonly record?: RecordReference;
108
112
  }
109
113
  export declare function createRecord<A extends AppOrElementRef>(opts: CreateRecordOptions<A>): ActionDef<CreateRecordOutput<A>>;
110
114
  type ValidatedUpdateFieldAssignments<Fields extends readonly FieldAssignment[]> = {
@@ -116,18 +120,32 @@ export interface UpdateFieldOptions<A extends AppOrElementRef = AppOrElementRef,
116
120
  readonly record: RecordReference<A>;
117
121
  readonly fields: Fields & ValidatedUpdateFieldAssignments<NoInfer<Fields>>;
118
122
  }
123
+ /** Update fields on an existing record. `value: ""` or `value: null` clears a nullable field (including Dropdown). */
119
124
  export declare function updateField<A extends AppOrElementRef, const Fields extends readonly FieldAssignment[]>(opts: UpdateFieldOptions<A, Fields>): ActionDef<{
120
125
  record: RecordShape<A>;
121
126
  }>;
122
127
  export interface FindRelatedRecordsOptions<A extends AppOrElementRef = AppOrElementRef> {
123
128
  readonly relatedApp: A;
124
- /** The record whose related records to find. */
125
- readonly record: RecordReference<A>;
129
+ /**
130
+ * The record whose related records to find. Belongs to the app/element the
131
+ * relation starts from, not to `relatedApp` (`A`), so it is not tied to `A`.
132
+ */
133
+ readonly record: RecordReference;
126
134
  readonly filter?: Filter;
127
135
  readonly sort?: Record<string, unknown>;
128
136
  readonly limit?: number;
129
137
  }
130
- export declare function findRelatedRecords<A extends AppOrElementRef>(opts: FindRelatedRecordsOptions<A>): ActionDef<RecordSearchOutput<A>>;
138
+ /**
139
+ * findRelatedRecords collection + first-record outputs.
140
+ * Intentionally not `RecordSearchOutput`: the platform's available refs
141
+ * include `Record` and `All found records`, but not recordSearch's
142
+ * `Records Size` (`totalCount`). Do not invent a count ref.
143
+ */
144
+ export interface FindRelatedRecordsOutput<A extends AppOrElementRef = AppOrElementRef> {
145
+ readonly records: readonly RecordShape<A>[];
146
+ readonly record: RecordShape<A>;
147
+ }
148
+ export declare function findRelatedRecords<A extends AppOrElementRef>(opts: FindRelatedRecordsOptions<A>): ActionDef<FindRelatedRecordsOutput<A>>;
131
149
  export interface RelateRecordsOptions {
132
150
  /** One or more source record references. */
133
151
  readonly sources: readonly ValueOrRef<unknown>[];
@@ -212,8 +230,18 @@ export interface SetVariableOptions {
212
230
  readonly update?: readonly VariableAssign[];
213
231
  }
214
232
  export declare function setVariable(opts: SetVariableOptions): ActionDef<Record<string, never>>;
233
+ /** Scalar types supported by an executeScript output schema. */
234
+ export type ScriptOutputScalarType = "text" | "string" | "integer" | "number" | "decimal" | "boolean" | "object";
235
+ /** A recursively typed executeScript output schema node. */
236
+ export type ScriptOutputType = ScriptOutputScalarType | {
237
+ readonly type: "array";
238
+ readonly items: ScriptOutputType;
239
+ } | {
240
+ readonly type: "object";
241
+ readonly properties?: ScriptOutputProperties;
242
+ };
215
243
  /** An output schema's properties: output name → type. */
216
- export type ScriptOutputProperties = Record<string, string>;
244
+ export type ScriptOutputProperties = Record<string, ScriptOutputType>;
217
245
  /**
218
246
  * A script's declared outputs — either the properties alone, or those
219
247
  * properties plus the root object's own `name`.
@@ -226,22 +254,33 @@ export type ScriptOutputProperties = Record<string, string>;
226
254
  * a pull reads back has to survive a rebuild unchanged; a task whose root
227
255
  * carries a name prints the second form.
228
256
  *
229
- * The two forms are distinguished by `properties` holding an object — every
230
- * value in the flat form is a type string, so an output actually named
257
+ * The two forms are distinguished by `properties` holding an object. Flat
258
+ * values may be scalar type strings or recursive `{ type: "array", ... }` /
259
+ * `{ type: "object", ... }` descriptors, so an output actually named
231
260
  * `properties` or `name` stays unambiguous.
232
261
  */
233
262
  export type ScriptOutputs = ScriptOutputProperties | {
234
263
  readonly name?: string;
235
264
  readonly properties: ScriptOutputProperties;
236
265
  };
237
- type ExecuteScriptFieldValue<T extends string> = Uppercase<T> extends "INTEGER" | "NUMBER" | "DECIMAL" ? number : Uppercase<T> extends "BOOLEAN" ? boolean : Uppercase<T> extends "OBJECT" ? Record<string, unknown> : string;
266
+ type ExecuteScriptFieldValue<T extends ScriptOutputType> = T extends {
267
+ readonly type: "array";
268
+ readonly items: infer I extends ScriptOutputType;
269
+ } ? readonly ExecuteScriptFieldValue<I>[] : T extends {
270
+ readonly type: "object";
271
+ readonly properties: infer P extends ScriptOutputProperties;
272
+ } ? {
273
+ readonly [K in keyof P]: ExecuteScriptFieldValue<P[K]>;
274
+ } : T extends {
275
+ readonly type: "object";
276
+ } ? Record<string, unknown> : T extends "integer" | "number" | "decimal" ? number : T extends "boolean" ? boolean : string;
238
277
  /** The properties of an authored `outputs` option, in either accepted form. */
239
278
  type ScriptOutputPropertiesOf<O> = O extends {
240
- readonly properties: Record<string, string>;
241
- } ? O["properties"] : O extends Record<string, string> ? O : undefined;
279
+ readonly properties: ScriptOutputProperties;
280
+ } ? O["properties"] : O extends ScriptOutputProperties ? O : undefined;
242
281
  type ExecuteScriptOutput<O extends ScriptOutputs | undefined> = {
243
- readonly result: ScriptOutputPropertiesOf<O> extends Record<string, string> ? {
244
- readonly [K in keyof ScriptOutputPropertiesOf<O>]: ExecuteScriptFieldValue<Extract<ScriptOutputPropertiesOf<O>[K], string>>;
282
+ readonly result: ScriptOutputPropertiesOf<O> extends ScriptOutputProperties ? {
283
+ readonly [K in keyof ScriptOutputPropertiesOf<O>]: ExecuteScriptFieldValue<Extract<ScriptOutputPropertiesOf<O>[K], ScriptOutputType>>;
245
284
  } : Record<string, unknown>;
246
285
  };
247
286
  export interface ExecuteScriptOptions<O extends ScriptOutputs | undefined = undefined> {
@@ -408,9 +447,7 @@ export interface AiTransformOptions {
408
447
  readonly fieldType: string;
409
448
  readonly connector?: ConnectorRef;
410
449
  }
411
- export declare function aiTransform(opts: AiTransformOptions): ActionDef<{
412
- output: unknown;
413
- }>;
450
+ export declare function aiTransform(opts: AiTransformOptions): ActionDef<Record<string, unknown>>;
414
451
  export interface AiEmailAnalysisOptions {
415
452
  readonly emailBody: ValueOrRef<unknown>;
416
453
  readonly emailSubject: ValueOrRef<unknown>;
@@ -584,12 +621,8 @@ export type TypedProcedureOptions<Parameters extends readonly ProcedureParameter
584
621
  readonly parameters: ProcedureParameterValues<Parameters>;
585
622
  });
586
623
  export type ProcedureOptions = LegacyProcedureOptions | TypedProcedureOptions<readonly ProcedureParameterType[]>;
587
- export declare function procedure<const Parameters extends readonly ProcedureParameterType[]>(opts: TypedProcedureOptions<Parameters>): ActionDef<{
588
- output: unknown;
589
- }>;
590
- export declare function procedure(opts: LegacyProcedureOptions): ActionDef<{
591
- output: unknown;
592
- }>;
624
+ export declare function procedure<const Parameters extends readonly ProcedureParameterType[]>(opts: TypedProcedureOptions<Parameters>): ActionDef<Record<string, unknown>>;
625
+ export declare function procedure(opts: LegacyProcedureOptions): ActionDef<Record<string, unknown>>;
593
626
  export interface InitiateCallOptions {
594
627
  readonly agent: AgentRef;
595
628
  readonly phoneService: PhoneServiceRef;
@@ -690,7 +723,8 @@ export interface RunAutomationInput {
690
723
  * output's source wasn't a typed executeScript result) stays `unknown` —
691
724
  * an honest "we don't know", never a wrong guess.
692
725
  */
693
- type WorkflowOutputValue<T extends string | undefined> = T extends "BOOLEAN" ? boolean : T extends "NUMBER" | "DECIMAL" ? number : T extends "TEXT" ? string : unknown;
726
+ type WorkflowOutputScalar<T extends string | undefined> = T extends "BOOLEAN" ? boolean : T extends "NUMBER" | "DECIMAL" ? number : T extends "TEXT" ? string : unknown;
727
+ type WorkflowOutputValue<T extends string | undefined, Multiple extends boolean | undefined> = Multiple extends true ? readonly WorkflowOutputScalar<T>[] : WorkflowOutputScalar<T>;
694
728
  /**
695
729
  * A `runAutomation` step's result: flat, one property per key the target
696
730
  * automation's `AutomationCatalogRef.outputs` declares — matches the real
@@ -698,7 +732,7 @@ type WorkflowOutputValue<T extends string | undefined> = T extends "BOOLEAN" ? b
698
732
  * confirmed live), not a nested `.output` wrapper.
699
733
  */
700
734
  export type RunAutomationOutput<A extends AutomationCatalogRef> = A["outputs"] extends Record<string, OutputPropertyRef> ? {
701
- readonly [K in keyof A["outputs"]]: WorkflowOutputValue<A["outputs"][K]["valueType"]>;
735
+ readonly [K in keyof A["outputs"]]: WorkflowOutputValue<A["outputs"][K]["valueType"], A["outputs"][K]["multiple"]>;
702
736
  } : Record<string, unknown>;
703
737
  export interface RunAutomationOptions<A extends AutomationCatalogRef = AutomationCatalogRef> {
704
738
  readonly automation: A;
@@ -735,9 +769,7 @@ export interface ReadFileOptions {
735
769
  readonly record?: ValueOrRef<unknown>;
736
770
  readonly dataSource: ReadFileDataSource;
737
771
  }
738
- export declare function readFile(opts: ReadFileOptions): ActionDef<{
739
- output: unknown;
740
- }>;
772
+ export declare function readFile(opts: ReadFileOptions): ActionDef<Record<string, unknown>>;
741
773
  export type BulkExcelFieldSource = {
742
774
  readonly type: "documentModelField";
743
775
  readonly field: DocumentModelFieldRef;
@@ -56,6 +56,7 @@ export function createRecord(opts) {
56
56
  __recordApp: opts.app.refName,
57
57
  };
58
58
  }
59
+ /** Update fields on an existing record. `value: ""` or `value: null` clears a nullable field (including Dropdown). */
59
60
  export function updateField(opts) {
60
61
  if (opts.fields.length === 0)
61
62
  throw new Error("updateField requires at least one field.");
@@ -80,6 +81,7 @@ export function findRelatedRecords(opts) {
80
81
  ...(opts.limit !== undefined ? { limit: opts.limit } : {}),
81
82
  },
82
83
  __recordApp: opts.relatedApp.refName,
84
+ __recordKind: opts.relatedApp.__kind === "element" ? "element" : "app",
83
85
  };
84
86
  }
85
87
  export function relateRecords(opts) {
@@ -191,24 +193,38 @@ function normalizeScriptOutputs(outputs) {
191
193
  properties: properties,
192
194
  };
193
195
  }
194
- /** Map an output schema to the platform's tagged object shape. */
195
- function outputSchema(outputs) {
196
- const { name: rootName, properties: declared } = normalizeScriptOutputs(outputs);
197
- const properties = Object.entries(declared).map(([name, type]) => {
196
+ /** Map one public output-schema node to the platform's tagged union shape. */
197
+ function outputSchemaNode(name, type) {
198
+ if (typeof type === "string") {
199
+ const named = name === undefined ? {} : { name };
198
200
  switch (type) {
199
- case "integer":
200
- return { integer: { name } };
201
+ case "integer": return { integer: named };
201
202
  case "number":
202
- case "decimal":
203
- return { number: { name } };
204
- case "boolean":
205
- return { bool: { name } };
206
- case "object":
207
- return { object: { name } };
208
- default:
209
- return { string: { name } };
203
+ case "decimal": return { number: named };
204
+ case "boolean": return { bool: named };
205
+ case "object": return { object: named };
206
+ case "text":
207
+ case "string":
208
+ default: return { string: named };
210
209
  }
211
- });
210
+ }
211
+ if (type.type === "array") {
212
+ return { array: { ...(name === undefined ? {} : { name }), item: outputSchemaNode(undefined, type.items) } };
213
+ }
214
+ const properties = type.properties === undefined
215
+ ? undefined
216
+ : Object.entries(type.properties).map(([propertyName, propertyType]) => outputSchemaNode(propertyName, propertyType));
217
+ return {
218
+ object: {
219
+ ...(name === undefined ? {} : { name }),
220
+ ...(properties === undefined ? {} : { properties }),
221
+ },
222
+ };
223
+ }
224
+ /** Map an output schema to the platform's tagged object shape. */
225
+ function outputSchema(outputs) {
226
+ const { name: rootName, properties: declared } = normalizeScriptOutputs(outputs);
227
+ const properties = Object.entries(declared).map(([name, type]) => outputSchemaNode(name, type));
212
228
  return { object: { ...(rootName !== undefined ? { name: rootName } : {}), properties } };
213
229
  }
214
230
  /**