@elementumai/edk 0.9.11 → 0.9.13
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.
- package/README.md +39 -5
- package/dist-sdk/src/catalog/factories.d.ts +35 -14
- package/dist-sdk/src/catalog/factories.js +64 -13
- package/dist-sdk/src/catalog/from-authoring.js +4 -4
- package/dist-sdk/src/catalog/index.d.ts +1 -1
- package/dist-sdk/src/catalog/org.js +3 -2
- package/dist-sdk/src/catalog/token.js +4 -0
- package/dist-sdk/src/catalog/types.d.ts +13 -3
- package/dist-sdk/src/core/triggers/on-demand.d.ts +4 -28
- package/dist-sdk/src/core/triggers/on-demand.js +2 -4
- package/dist-sdk/src/engine/entity.d.ts +2 -0
- package/dist-sdk/src/engine/logging.d.ts +90 -0
- package/dist-sdk/src/engine/logging.js +124 -0
- package/dist-sdk/src/engine/progress.d.ts +122 -0
- package/dist-sdk/src/engine/progress.js +685 -0
- package/dist-sdk/src/engine/pull/result-output.d.ts +24 -0
- package/dist-sdk/src/engine/pull/result-output.js +59 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +2 -2
- package/dist-sdk/src/entities/app/build.d.ts +8 -1
- package/dist-sdk/src/entities/app/from-tf.js +4 -4
- package/dist-sdk/src/entities/app/to-tf.js +9 -13
- package/dist-sdk/src/entities/automation/build.d.ts +11 -16
- package/dist-sdk/src/entities/automation/build.js +60 -16
- package/dist-sdk/src/entities/automation/catalog-render.js +1 -1
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +1 -2
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +23 -5
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +247 -35
- package/dist-sdk/src/entities/automation/from-tf.js +181 -24
- package/dist-sdk/src/entities/automation/index.d.ts +2 -2
- package/dist-sdk/src/entities/automation/module.js +2 -2
- package/dist-sdk/src/entities/automation/output-field-types.js +25 -13
- package/dist-sdk/src/entities/automation/script-code.d.ts +12 -4
- package/dist-sdk/src/entities/automation/script-code.js +659 -101
- package/dist-sdk/src/entities/automation/task-label.js +25 -2
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -28
- package/dist-sdk/src/entities/automation/tasks.js +31 -15
- package/dist-sdk/src/entities/automation/to-tf.js +443 -64
- package/dist-sdk/src/entities/automation/triggers.d.ts +15 -9
- package/dist-sdk/src/entities/automation/triggers.js +4 -2
- package/dist-sdk/src/entities/chart/build.d.ts +15 -3
- package/dist-sdk/src/entities/chart/build.js +6 -1
- package/dist-sdk/src/entities/chart/from-tf.d.ts +8 -2
- package/dist-sdk/src/entities/chart/from-tf.js +71 -8
- package/dist-sdk/src/entities/chart/index.d.ts +1 -1
- package/dist-sdk/src/entities/chart/index.js +1 -1
- package/dist-sdk/src/entities/chart/printer.js +27 -7
- package/dist-sdk/src/entities/chart/to-tf.js +56 -2
- package/dist-sdk/src/entities/datamine/from-tf.js +11 -1
- package/dist-sdk/src/entities/element/build.d.ts +6 -5
- package/dist-sdk/src/entities/element/from-tf.js +3 -2
- package/dist-sdk/src/entities/element/module.js +1 -0
- package/dist-sdk/src/entities/element/to-tf.d.ts +3 -0
- package/dist-sdk/src/entities/element/to-tf.js +9 -1
- package/dist-sdk/src/entities/field/from-tf.d.ts +24 -0
- package/dist-sdk/src/entities/field/from-tf.js +73 -1
- package/dist-sdk/src/entities/field/metadata.d.ts +18 -0
- package/dist-sdk/src/entities/field/metadata.js +34 -0
- package/dist-sdk/src/entities/relationship/build.d.ts +17 -6
- package/dist-sdk/src/entities/relationship/column-contract.d.ts +24 -0
- package/dist-sdk/src/entities/relationship/column-contract.js +41 -0
- package/dist-sdk/src/entities/relationship/from-tf.js +19 -34
- package/dist-sdk/src/entities/relationship/to-tf.js +15 -2
- package/dist-sdk/src/entities/shared/context.d.ts +6 -3
- package/dist-sdk/src/entities/shared/context.js +19 -1
- package/dist-sdk/src/entities/shared/filters/index.d.ts +7 -0
- package/dist-sdk/src/entities/shared/filters/index.js +36 -1
- package/dist-sdk/src/entities/shared/filters/print.js +2 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +8 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +10 -6
- package/dist-sdk/src/entities/shared/filters/types.d.ts +2 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +5 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +36 -23
- package/dist-sdk/src/entities/skill/module.js +1 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/skill/to-tf.js +17 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +38 -12
- package/dist-sdk/src/entities/skill/tools.js +2 -1
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +8 -12
- package/dist-sdk/src/entities/skill-tool/from-tf.js +28 -44
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +4 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +45 -7
- package/dist-sdk/src/entities/table/build.js +10 -2
- package/dist-sdk/src/entities/view/to-tf.js +5 -7
- package/dist-sdk/src/entities/widget/build.d.ts +26 -0
- package/dist-sdk/src/entities/widget/from-tf.js +30 -5
- package/dist-sdk/src/entities/widget/to-tf.js +111 -7
- package/dist-sdk/src/graph/types.d.ts +5 -0
- package/package.json +1 -1
- package/dist-sdk/src/core/types/platform.d.ts +0 -2
- package/dist-sdk/src/core/types/platform.js +0 -1
|
@@ -98,6 +98,7 @@ const ATTR_TO_ARG = {
|
|
|
98
98
|
text_to_classify: "text",
|
|
99
99
|
field_type: "fieldType",
|
|
100
100
|
category_source: "categorySource",
|
|
101
|
+
dynamic_category_source: "categorySource",
|
|
101
102
|
user_ids: "userIds",
|
|
102
103
|
group_ids: "groupIds",
|
|
103
104
|
notify_watchers: "notifyWatchers",
|
|
@@ -230,7 +231,7 @@ function assertAllowed(block, allowed) {
|
|
|
230
231
|
}
|
|
231
232
|
const TRIGGER_ATTRIBUTES = new Set([
|
|
232
233
|
"automation", "filter", "changed_fields", "think_ui", "conversation_type",
|
|
233
|
-
"authenticated", "custom_response", "
|
|
234
|
+
"authenticated", "custom_response", "parameters",
|
|
234
235
|
"approval_chain_template_id", "status", "datamine_id", "fire_on_alert",
|
|
235
236
|
"fire_on_recovery", "email_alias_id", "survey_template_id",
|
|
236
237
|
"frequency", "interval", "timezone", "start_at", "weekdays", "day_of_month",
|
|
@@ -246,7 +247,7 @@ const TASK_ATTRIBUTES = new Set([
|
|
|
246
247
|
"from_personal", "external_emails", "users", "groups", "attachments", "contents",
|
|
247
248
|
"agent_id", "prompt", "output_type", "json_fields", "ai_provider_connector_id",
|
|
248
249
|
"url", "response_type", "continue_on_error", "search_table_id",
|
|
249
|
-
"text_to_summarize", "text_to_classify", "field_type", "category_source",
|
|
250
|
+
"text_to_summarize", "text_to_classify", "field_type", "category_source", "dynamic_category_source",
|
|
250
251
|
"title", "user_ids", "group_ids", "notify_watchers", "field_id", "user_id", "group_id",
|
|
251
252
|
"fields_to_lock", "fields_to_unlock", "file", "file_id", "attachment", "attachment_id", "view_state", "target_automation_id",
|
|
252
253
|
"target_automation_ref", "input_mappings", "dynamic_input_mappings",
|
|
@@ -523,6 +524,36 @@ function aspectRefFromObjectId(objectId, ctx) {
|
|
|
523
524
|
name: identity,
|
|
524
525
|
};
|
|
525
526
|
}
|
|
527
|
+
function aspectKindFromObjectId(objectId) {
|
|
528
|
+
if (!isTfExpr(objectId) || (objectId.$expr !== "resource-attr" && objectId.$expr !== "data-attr")) {
|
|
529
|
+
return undefined;
|
|
530
|
+
}
|
|
531
|
+
if (objectId.type === "elementum_app")
|
|
532
|
+
return "app";
|
|
533
|
+
if (objectId.type === "elementum_element")
|
|
534
|
+
return "element";
|
|
535
|
+
return undefined;
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* findRelatedRecords field outputs. App-related FIND_PARENT no longer
|
|
539
|
+
* exposes system Title — live refs use HANDLE (`"ID"`). A stale export
|
|
540
|
+
* `refs["Title"]` (or live `refs["ID"]`) targeting an app decodes as
|
|
541
|
+
* `.record.id` so rebuild stamps the handle. Element-related Title stays
|
|
542
|
+
* `.record.title`.
|
|
543
|
+
*/
|
|
544
|
+
function findRelatedRecordsFieldPath(wireName, taskAddress, ctx) {
|
|
545
|
+
const ownerRefName = taskAddress !== undefined
|
|
546
|
+
? ctx.taskTargetOwnerRefNameByAddress?.get(taskAddress) ?? ctx.appRefName
|
|
547
|
+
: ctx.appRefName;
|
|
548
|
+
const kind = taskAddress !== undefined
|
|
549
|
+
? ctx.taskTargetOwnerKindByAddress?.get(taskAddress)
|
|
550
|
+
: undefined;
|
|
551
|
+
const lower = wireName.toLowerCase();
|
|
552
|
+
if (kind === "app" && (lower === "title" || lower === "id")) {
|
|
553
|
+
return ["record", "id"];
|
|
554
|
+
}
|
|
555
|
+
return recordFieldRefPath(wireName, ctx, ownerRefName);
|
|
556
|
+
}
|
|
526
557
|
function lookupFieldKeyByDisplayName(ownerRefName, displayName, ctx) {
|
|
527
558
|
const lower = displayName.toLowerCase();
|
|
528
559
|
const foreign = ctx.fieldNamesByOwnerRefName?.get(ownerRefName)?.get(lower);
|
|
@@ -707,18 +738,29 @@ function triggerRefPath(path, ctx) {
|
|
|
707
738
|
if (wireName === "Attachment Id")
|
|
708
739
|
return ["attachment", "id"];
|
|
709
740
|
}
|
|
741
|
+
// emailReceived's own trigger-output field names (EmailReceivedTriggerOutput,
|
|
742
|
+
// triggers.ts) use snake_case matching the platform's field identifiers,
|
|
743
|
+
// not the human display labels the platform emits in triggerReference.name
|
|
744
|
+
// (live-confirmed: "Sender's Email Address", "Sender's Name",
|
|
745
|
+
// "Body (Plain Text)", "Body (Rich Text)") - live-confirmed spellings only;
|
|
746
|
+
// an unmapped label falls through to the raw-string default below rather
|
|
747
|
+
// than guessing (#929).
|
|
748
|
+
if (ctx.trigger.type === "elementum_email_ingestion_trigger") {
|
|
749
|
+
if (wireName === "Sender's Email Address")
|
|
750
|
+
return ["sender_email"];
|
|
751
|
+
if (wireName === "Sender's Name")
|
|
752
|
+
return ["sender_name"];
|
|
753
|
+
if (wireName === "Body (Plain Text)")
|
|
754
|
+
return ["body"];
|
|
755
|
+
if (wireName === "Body (Rich Text)")
|
|
756
|
+
return ["body_html"];
|
|
757
|
+
}
|
|
710
758
|
if (ctx.trigger.type === "elementum_webhook_trigger") {
|
|
711
759
|
const webhookMatch = WEBHOOK_REF_PATTERN.exec(wireName);
|
|
712
760
|
if (webhookMatch)
|
|
713
761
|
return [webhookMatch[1].toLowerCase(), webhookMatch[2]];
|
|
714
762
|
}
|
|
715
763
|
if (ctx.trigger.type === "elementum_on_demand_trigger") {
|
|
716
|
-
if (wireName === "Triggered By's Id")
|
|
717
|
-
return ["triggeredBy", "id"];
|
|
718
|
-
if (wireName === "Triggered By's Name")
|
|
719
|
-
return ["triggeredBy", "name"];
|
|
720
|
-
if (wireName === "Triggered By's Email")
|
|
721
|
-
return ["triggeredBy", "email"];
|
|
722
764
|
const recordPath = prefixedOnDemandRecordRefPath(wireName, ctx);
|
|
723
765
|
if (recordPath !== undefined)
|
|
724
766
|
return recordPath;
|
|
@@ -921,6 +963,12 @@ function decodeTaskReferenceFromString(taskIdOrKey, pathSegments, ctx) {
|
|
|
921
963
|
return { kind: "taskRef", task: refKey, path: recordPath };
|
|
922
964
|
}
|
|
923
965
|
}
|
|
966
|
+
if (block.type === "elementum_find_related_records_task" && pathSegments.length === 1) {
|
|
967
|
+
const recordPath = findRelatedRecordsFieldPath(head, block.label !== undefined ? `${block.type}.${block.label}` : undefined, ctx);
|
|
968
|
+
if (recordPath !== undefined) {
|
|
969
|
+
return { kind: "taskRef", task: refKey, path: recordPath };
|
|
970
|
+
}
|
|
971
|
+
}
|
|
924
972
|
}
|
|
925
973
|
if (block?.type === "elementum_api_task" && pathSegments.length === 1) {
|
|
926
974
|
const apiPath = apiTaskRefAuthoringPath(pathSegments[0]);
|
|
@@ -1057,6 +1105,19 @@ function fieldKeyFromTriggerFieldIdExpr(fieldPart, ctx) {
|
|
|
1057
1105
|
return tfLabelToTsLabel(fieldPart.name.slice(prefix.length, -9));
|
|
1058
1106
|
}
|
|
1059
1107
|
}
|
|
1108
|
+
if ((fieldPart.$expr === "data-attr" || fieldPart.$expr === "resource-attr") &&
|
|
1109
|
+
fieldPart.type === TABLE_RESOURCE_TYPE &&
|
|
1110
|
+
fieldPart.path[0] === "field_ids") {
|
|
1111
|
+
const index = fieldPart.path[1];
|
|
1112
|
+
const name = typeof index === "string"
|
|
1113
|
+
? index
|
|
1114
|
+
: typeof index === "object" && index !== null && "index" in index && typeof index.index === "string"
|
|
1115
|
+
? index.index
|
|
1116
|
+
: undefined;
|
|
1117
|
+
if (name !== undefined) {
|
|
1118
|
+
return tfLabelToTsLabel(sanitizeName(name));
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1060
1121
|
return undefined;
|
|
1061
1122
|
}
|
|
1062
1123
|
/** Same provider/model derivation as `agentFromTf` and `renderAiProvidersBag`, read off the stream's own data blocks. */
|
|
@@ -1234,6 +1295,12 @@ function decodeValue(value, ctx) {
|
|
|
1234
1295
|
return { kind: "taskRef", task: task.refKey, path: recordPath };
|
|
1235
1296
|
}
|
|
1236
1297
|
}
|
|
1298
|
+
if (task.block.type === "elementum_find_related_records_task" && rawSegments.length === 1) {
|
|
1299
|
+
const recordPath = findRelatedRecordsFieldPath(rawSegments[0], `${task.block.type}.${task.block.label}`, ctx);
|
|
1300
|
+
if (recordPath !== undefined) {
|
|
1301
|
+
return { kind: "taskRef", task: task.refKey, path: recordPath };
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1237
1304
|
if (task.block.type === "elementum_record_search_task" && rawSegments.length >= 1) {
|
|
1238
1305
|
const recordSearchName = RECORD_SEARCH_TASK_REF_SEGMENT_TO_TS[rawSegments[0]];
|
|
1239
1306
|
if (recordSearchName !== undefined) {
|
|
@@ -1281,8 +1348,9 @@ function decodeValue(value, ctx) {
|
|
|
1281
1348
|
: keyPath;
|
|
1282
1349
|
return { kind: "taskRef", task: task.refKey, path: outputKeyPath };
|
|
1283
1350
|
}
|
|
1284
|
-
if (value.type === "elementum_app"
|
|
1285
|
-
return appRef(ctx.appRefName);
|
|
1351
|
+
if ((value.type === "elementum_app" || value.type === "elementum_element") && value.path[0] === "id") {
|
|
1352
|
+
return appRef(value.label === ctx.appTfLabel ? ctx.appRefName : tfLabelToTsLabel(value.label));
|
|
1353
|
+
}
|
|
1286
1354
|
if (value.type.endsWith("_field") && value.path[0] === "id") {
|
|
1287
1355
|
return {
|
|
1288
1356
|
kind: "field",
|
|
@@ -1346,12 +1414,14 @@ function decodeValue(value, ctx) {
|
|
|
1346
1414
|
};
|
|
1347
1415
|
}
|
|
1348
1416
|
if (value.type === "elementum_approval_process" && value.path[0] === "id") {
|
|
1349
|
-
|
|
1417
|
+
// Managed resource-attr references already carry type+label — rebuild
|
|
1418
|
+
// elementum_approval_process.<label>.id on to-tf. unresolvedId is only
|
|
1419
|
+
// for raw UUID / unresolvable refs (see ApprovalChainRef); stamping the
|
|
1420
|
+
// import id here made print/to-tf prefer the UUID and rewrite live pulls.
|
|
1350
1421
|
return {
|
|
1351
1422
|
kind: "approvalChain",
|
|
1352
1423
|
appHandle: ctx.appRefName,
|
|
1353
1424
|
approvalChainKey: scopedLabelToBagKey(ctx.appTfLabel, value.label),
|
|
1354
|
-
...(unresolvedId !== undefined ? { unresolvedId } : {}),
|
|
1355
1425
|
};
|
|
1356
1426
|
}
|
|
1357
1427
|
if ((value.type === SEARCH_TABLE_RESOURCE_TYPES.snowflake ||
|
|
@@ -1452,7 +1522,9 @@ function decodeValue(value, ctx) {
|
|
|
1452
1522
|
: value.label.startsWith(`${ownerLabel}_`)
|
|
1453
1523
|
? value.label.slice(ownerLabel.length + 1)
|
|
1454
1524
|
: value.label;
|
|
1455
|
-
const
|
|
1525
|
+
const ownerBlock = ctx.dataBlocks.get(`${objectId.type}.${objectId.label}`);
|
|
1526
|
+
const ownerName = ownerBlock?.attrs["name"];
|
|
1527
|
+
const ownerNamespace = ownerBlock?.attrs["namespace"];
|
|
1456
1528
|
const fieldName = fieldBlock?.attrs["name"];
|
|
1457
1529
|
return {
|
|
1458
1530
|
kind: "field",
|
|
@@ -1460,7 +1532,17 @@ function decodeValue(value, ctx) {
|
|
|
1460
1532
|
fieldKey: tfLabelToTsLabel(bareLabel),
|
|
1461
1533
|
foreign: {
|
|
1462
1534
|
entityType,
|
|
1535
|
+
// ei's owner data block can carry ONLY `namespace` (no `name`) —
|
|
1536
|
+
// confirmed live: `data.elementum_element.x { namespace = "..." }`
|
|
1537
|
+
// with no name attr at all. A tfLabel->tsLabel guess is a real
|
|
1538
|
+
// platform NAME only by luck; printing it as one, and then having
|
|
1539
|
+
// build key a `data.elementum_element` lookup on `name`, produces
|
|
1540
|
+
// a request the platform can never satisfy ("Element Not Found").
|
|
1541
|
+
// Carry the real namespace through instead, when that's all ei
|
|
1542
|
+
// gave us — `foreignRootLookup`/`resolveForeignRef` already prefer
|
|
1543
|
+
// `namespace` over `name` for exactly this reason.
|
|
1463
1544
|
name: typeof ownerName === "string" ? ownerName : tfLabelToTsLabel(ownerLabel),
|
|
1545
|
+
...(typeof ownerName !== "string" && typeof ownerNamespace === "string" ? { namespace: ownerNamespace } : {}),
|
|
1464
1546
|
...(typeof fieldName === "string" ? { fieldName } : {}),
|
|
1465
1547
|
},
|
|
1466
1548
|
};
|
|
@@ -1850,11 +1932,12 @@ function resolveVariableReference(rawId, rawName, outputName, ctx) {
|
|
|
1850
1932
|
return { kind: "variableParamRef", varTask: byOutput.refKey, name: byOutput.varName };
|
|
1851
1933
|
}
|
|
1852
1934
|
}
|
|
1853
|
-
// 4. The variable's real platform id
|
|
1854
|
-
//
|
|
1855
|
-
//
|
|
1856
|
-
//
|
|
1857
|
-
// "variable|<uuid>" placeholder,
|
|
1935
|
+
// 4. The variable's real platform id is Computed on the provider, so the
|
|
1936
|
+
// static `variable_task` block does not carry `variable_id`. Export puts it
|
|
1937
|
+
// in an EDK-only `edk_variable_id_<label>` local (hydrated onto the block
|
|
1938
|
+
// before this resolver runs). Without that, a workflow OUTPUT's
|
|
1939
|
+
// `variableReference.name` is the synthetic "variable|<uuid>" placeholder,
|
|
1940
|
+
// and #2/#3's name-based matches routinely
|
|
1858
1941
|
// miss on casing/spacing (output "Output Message" vs. variable "Output
|
|
1859
1942
|
// message" - live-confirmed on purchaseorder/eu-sanofi's Authorization
|
|
1860
1943
|
// Check automation). With exactly one variable task in the whole
|
|
@@ -2002,7 +2085,7 @@ function triggerFromBlock(block, ctx) {
|
|
|
2002
2085
|
...(!record && parameter.default_value !== undefined ? { defaultValue: parameter.default_value } : {}),
|
|
2003
2086
|
...(typeof parameter.description === "string" ? { description: parameter.description } : {}),
|
|
2004
2087
|
};
|
|
2005
|
-
})
|
|
2088
|
+
})
|
|
2006
2089
|
};
|
|
2007
2090
|
}
|
|
2008
2091
|
case "recordCreate":
|
|
@@ -2016,7 +2099,7 @@ function triggerFromBlock(block, ctx) {
|
|
|
2016
2099
|
case "conversationEnd":
|
|
2017
2100
|
if (typeof block.attrs.conversation_type !== "string")
|
|
2018
2101
|
throw new EntityTfError("conversation trigger requires conversation_type");
|
|
2019
|
-
return { kind, app, conversationType: block.attrs.conversation_type };
|
|
2102
|
+
return { kind, app, conversationType: block.attrs.conversation_type, ...(filter ? { filter } : {}) };
|
|
2020
2103
|
case "webhook":
|
|
2021
2104
|
// ei's export only reliably emits `authenticated` when it can (see
|
|
2022
2105
|
// cmd/elementum/export/hcl_trigger.go) - a real captured stream can
|
|
@@ -2149,13 +2232,36 @@ function taskArgs(block, factory, ctx) {
|
|
|
2149
2232
|
const raw = isTfExpr(value) && value.$expr === "jsonencode" ? value.value : value;
|
|
2150
2233
|
const root = isObject(raw) && isObject(raw.object) ? raw.object : undefined;
|
|
2151
2234
|
const props = Array.isArray(root?.properties) ? root.properties : [];
|
|
2235
|
+
const decodeNode = (node) => {
|
|
2236
|
+
if (!isObject(node))
|
|
2237
|
+
throw new EntityTfError("invalid script output schema node");
|
|
2238
|
+
const [type, definition] = Object.entries(node)[0] ?? [];
|
|
2239
|
+
if (type === undefined || !isObject(definition))
|
|
2240
|
+
throw new EntityTfError("invalid script output property");
|
|
2241
|
+
if (type === "array") {
|
|
2242
|
+
return { type: "array", items: decodeNode(definition.item) };
|
|
2243
|
+
}
|
|
2244
|
+
if (type === "object" && Array.isArray(definition.properties)) {
|
|
2245
|
+
const properties = Object.fromEntries(definition.properties.map((child) => {
|
|
2246
|
+
if (!isObject(child))
|
|
2247
|
+
throw new EntityTfError("invalid nested script output property");
|
|
2248
|
+
const childDefinition = Object.values(child)[0];
|
|
2249
|
+
if (!isObject(childDefinition) || typeof childDefinition.name !== "string") {
|
|
2250
|
+
throw new EntityTfError("nested script output property requires a name");
|
|
2251
|
+
}
|
|
2252
|
+
return [childDefinition.name, decodeNode(child)];
|
|
2253
|
+
}));
|
|
2254
|
+
return { type: "object", properties };
|
|
2255
|
+
}
|
|
2256
|
+
return type === "bool" ? "boolean" : type;
|
|
2257
|
+
};
|
|
2152
2258
|
const properties = Object.fromEntries(props.map((property) => {
|
|
2153
2259
|
if (!isObject(property))
|
|
2154
2260
|
throw new EntityTfError("invalid script output schema");
|
|
2155
|
-
const
|
|
2156
|
-
if (
|
|
2261
|
+
const definition = Object.values(property)[0];
|
|
2262
|
+
if (!isObject(definition) || typeof definition.name !== "string")
|
|
2157
2263
|
throw new EntityTfError("invalid script output property");
|
|
2158
|
-
return [definition.name,
|
|
2264
|
+
return [definition.name, decodeNode(property)];
|
|
2159
2265
|
}));
|
|
2160
2266
|
// The root object's own name is inert to the platform but real stored
|
|
2161
2267
|
// data, so carry it through rather than rebuilding a schema that
|
|
@@ -2266,6 +2372,24 @@ function taskArgs(block, factory, ctx) {
|
|
|
2266
2372
|
};
|
|
2267
2373
|
continue;
|
|
2268
2374
|
}
|
|
2375
|
+
if (attr === "dynamic_category_source" && factory === "aiClassify") {
|
|
2376
|
+
if (!isObject(value))
|
|
2377
|
+
throw new EntityTfError("dynamic_category_source must be an object");
|
|
2378
|
+
if (value.object_id === undefined || value.label_field_id === undefined) {
|
|
2379
|
+
throw new EntityTfError("dynamic_category_source requires object_id and label_field_id");
|
|
2380
|
+
}
|
|
2381
|
+
args.categorySource = {
|
|
2382
|
+
type: "dynamic",
|
|
2383
|
+
app: aspectRefFromObjectId(value.object_id, ctx) ?? decodeValue(value.object_id, ctx),
|
|
2384
|
+
labelField: fieldRef(value.label_field_id, ctx),
|
|
2385
|
+
...(value.description_field_id !== undefined
|
|
2386
|
+
? { descriptionField: fieldRef(value.description_field_id, ctx) }
|
|
2387
|
+
: {}),
|
|
2388
|
+
...(value.filter !== undefined ? { filter: decodeFilter(value.filter, ctx) } : {}),
|
|
2389
|
+
...(typeof value.limit === "number" ? { limit: value.limit } : {}),
|
|
2390
|
+
};
|
|
2391
|
+
continue;
|
|
2392
|
+
}
|
|
2269
2393
|
if (attr === "table_id" && factory === "tableRecordsSearch") {
|
|
2270
2394
|
const foreign = typeof value === "string" ? ctx.foreignTableRefsById?.get(value) : undefined;
|
|
2271
2395
|
args.table = foreign !== undefined
|
|
@@ -2665,6 +2789,31 @@ export function automationOwnedAddresses(doc, automationLabel) {
|
|
|
2665
2789
|
}
|
|
2666
2790
|
return [...owned];
|
|
2667
2791
|
}
|
|
2792
|
+
const EDK_VARIABLE_ID_LOCAL_PREFIX = "edk_variable_id_";
|
|
2793
|
+
/** Pull-only: computed variable_id cannot live on the resource schema. */
|
|
2794
|
+
function exportedVariableIdsByTaskLabel(doc) {
|
|
2795
|
+
const ids = new Map();
|
|
2796
|
+
for (const block of doc.blocks) {
|
|
2797
|
+
if (block.kind !== "locals")
|
|
2798
|
+
continue;
|
|
2799
|
+
for (const [key, value] of Object.entries(block.attrs)) {
|
|
2800
|
+
if (key.startsWith(EDK_VARIABLE_ID_LOCAL_PREFIX) && typeof value === "string" && value !== "") {
|
|
2801
|
+
ids.set(key.slice(EDK_VARIABLE_ID_LOCAL_PREFIX.length), value);
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2805
|
+
return ids;
|
|
2806
|
+
}
|
|
2807
|
+
function withExportedVariableId(block, ids) {
|
|
2808
|
+
if (block.type !== "elementum_variable_task" || block.label === undefined)
|
|
2809
|
+
return block;
|
|
2810
|
+
if (typeof block.attrs.variable_id === "string" && block.attrs.variable_id !== "")
|
|
2811
|
+
return block;
|
|
2812
|
+
const exported = ids.get(block.label);
|
|
2813
|
+
if (exported === undefined)
|
|
2814
|
+
return block;
|
|
2815
|
+
return { ...block, attrs: { ...block.attrs, variable_id: exported } };
|
|
2816
|
+
}
|
|
2668
2817
|
/** Bridge metadata for required values that GraphQL could not reconstruct. */
|
|
2669
2818
|
function unresolvedAuthoringValues(doc) {
|
|
2670
2819
|
const values = [];
|
|
@@ -2749,7 +2898,10 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
2749
2898
|
}
|
|
2750
2899
|
}
|
|
2751
2900
|
}
|
|
2752
|
-
const
|
|
2901
|
+
const exportedVariableIds = exportedVariableIdsByTaskLabel(doc);
|
|
2902
|
+
const tasks = taskCandidates
|
|
2903
|
+
.filter((block) => owned.has(`${block.type}.${block.label}`))
|
|
2904
|
+
.map((block) => withExportedVariableId(block, exportedVariableIds));
|
|
2753
2905
|
const ownedBranches = branches.filter((block) => owned.has(`${block.type}.${block.label}`));
|
|
2754
2906
|
// A required value that the bridge could not reconstruct is not a literal
|
|
2755
2907
|
// empty string. Exclude the whole automation graph from authoring/adoption,
|
|
@@ -2819,10 +2971,14 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
2819
2971
|
return to === from ? [] : [{ from, to }];
|
|
2820
2972
|
});
|
|
2821
2973
|
const taskTargetOwnerRefNameByAddress = new Map();
|
|
2974
|
+
const taskTargetOwnerKindByAddress = new Map();
|
|
2822
2975
|
for (const [address, { block }] of taskByAddress) {
|
|
2823
2976
|
const ownerRefName = aspectOwnerRefNameFromObjectId(block.attrs.object_id, appRefName, appTfLabel, dataBlocks, foreignAppRefNames, foreignElementRefNames);
|
|
2824
2977
|
if (ownerRefName !== undefined)
|
|
2825
2978
|
taskTargetOwnerRefNameByAddress.set(address, ownerRefName);
|
|
2979
|
+
const ownerKind = aspectKindFromObjectId(block.attrs.object_id);
|
|
2980
|
+
if (ownerKind !== undefined)
|
|
2981
|
+
taskTargetOwnerKindByAddress.set(address, ownerKind);
|
|
2826
2982
|
}
|
|
2827
2983
|
const resourceImportIds = new Map();
|
|
2828
2984
|
for (const block of doc.blocks) {
|
|
@@ -2870,6 +3026,7 @@ function automationFromTfDocument(doc, automationLabel, appRefName, foreignField
|
|
|
2870
3026
|
...(picklistOptionLabelById !== undefined && { picklistOptionLabelById }),
|
|
2871
3027
|
...(fieldNamesByOwnerRefName !== undefined && { fieldNamesByOwnerRefName }),
|
|
2872
3028
|
...(taskTargetOwnerRefNameByAddress.size > 0 && { taskTargetOwnerRefNameByAddress }),
|
|
3029
|
+
...(taskTargetOwnerKindByAddress.size > 0 && { taskTargetOwnerKindByAddress }),
|
|
2873
3030
|
...(foreignAppRefNames !== undefined && { foreignAppRefNames }),
|
|
2874
3031
|
...(foreignElementRefNames !== undefined && { foreignElementRefNames }),
|
|
2875
3032
|
...(procedureKeysByDiscriminator !== undefined && { procedureKeysByDiscriminator }),
|
|
@@ -17,5 +17,5 @@ export { AUTOMATION_RESOURCE_TYPES, AUTOMATION_TASK_TYPES, AUTOMATION_TRIGGER_TY
|
|
|
17
17
|
export * as filter from "../shared/filters/index.js";
|
|
18
18
|
export { automationStatus, chainableTrigger, actions, automation, type ActionBuilder, type ActionChain, type ActionDef, type ActionOptions, type ActionSequenceDef, type ActionsStarted, type AutomationConfigured, type AutomationOptions, type AutomationStatus, type ForkJoinBranch, type ForkJoinBranchBuilder, type ForkJoinConfig, type ForEachBuilder, type ForEachConfig, type NestedActionBuilder, type NestedActionChain, type NestedActionContext, type OperatorChild, type SwitchCase, type SwitchCaseBuilder, type SwitchConfig, type TriggerChain, type TriggerDef, type TriggerParamMeta } from "./build.js";
|
|
19
19
|
export { ScriptCodeError, type ScriptCodeFn, type ScriptInput } from "./script-code.js";
|
|
20
|
-
export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, filterAction, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, type AddWatcherOptions, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApprovalChainOptions, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptOptions, type FieldAssignment, type FilterActionOptions, type FindRelatedRecordsOptions, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
|
|
21
|
-
export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook, type AttachmentTriggerOptions, type AttachmentTriggerOutput, type CommentAddedTriggerOptions, type CommentAddedTriggerOutput, type ConversationEndConversationType, type ConversationEndTriggerOptions, type ConversationEndTriggerOutput, type DataMineTriggerOptions, type EmailReceivedTriggerOptions, type EmailReceivedTriggerOutput, type RecordTriggerOptions, type RecordTriggerOutput, type ScheduleFrequency, type ScheduleTriggerOptions, type ScheduleTriggerOutput, type SlackMessageTriggerOutput, type SurveyResponseCreateTriggerOptions, type SurveyResponseCreateTriggerOutput, type TemporalTriggerOptions, type TemporalUnit, type WebhookTriggerOptions, type WebhookTriggerOutput, type Weekday, type approvalProcessStatusUpdatedStatus, type approvalProcessStatusUpdatedTriggerOptions } from "./triggers.js";
|
|
20
|
+
export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, filterAction, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, type AddWatcherOptions, type AiAgentOptions, type AiAgentOutput, type AiAgentOutputField, type AiAgentOutputFieldType, type AiClassifyCategorySource, type AiClassifyOptions, type AiClassifyStaticCategory, type AiEmailAnalysisOptions, type AiFileAnalysisOptions, type AiSearchTableOptions, type AiSearchTableOutput, type AiSummarizeOptions, type AiTransformOptions, type ApiRequestHeader, type ApiRequestOptions, type ApprovalChainOptions, type ApprovalChainTemplateOptions, type ApprovalStatusUpdateOptions, type ApprovalStatusUpdateStatus, type AssignGroupOptions, type AssignUserOptions, type AssignmentEngineOptions, type BulkExcelFieldMapping, type BulkExcelFieldSource, type BulkExcelOptions, type CalculationEntry, type CalculationExpression, type CalculationInclude, type CalculationOptions, type CalculationOutputs, type CalculationValueInput, type CalculationValueOptions, type CalculationValueOutputs, type CalculationValues, type CreateRecordOptions, type CreateRecordOutput, type EmailAttachment, type ExecuteScriptOptions, type FieldAssignment, type FilterActionOptions, type FindRelatedRecordsOptions, type FindRelatedRecordsOutput, type GenerateReportOptions, type InitiateCallOptions, type InitiateEmailConversationOptions, type InitiateEmailFirstEmail, type LegacyCalculationOptions, type MultiSelectUpdateMode, type NotificationOptions, type PostCommentOptions, type PostTeamsMessageOptions, type LegacyProcedureOptions, type ProcedureOptions, type TypedProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationOptions, type SaveAttachmentOptions, type ScriptOutputProperties, type ScriptOutputScalarType, type ScriptOutputType, type ScriptOutputs, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldAssignment, type UpdateFieldOptions, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.js";
|
|
21
|
+
export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook, type AttachmentTriggerOptions, type AttachmentTriggerOutput, type CommentAddedTriggerOptions, type CommentAddedTriggerOutput, type ConversationEndConversationType, type ConversationEndTriggerOptions, type ConversationEndTriggerOutput, type DataMineTriggerOptions, type DataMineTriggerOutput, type EmailReceivedTriggerOptions, type EmailReceivedTriggerOutput, type RecordTriggerOptions, type RecordTriggerOutput, type ScheduleFrequency, type ScheduleTriggerOptions, type ScheduleTriggerOutput, type SlackMessageTriggerOutput, type SurveyResponseCreateTriggerOptions, type SurveyResponseCreateTriggerOutput, type TemporalTriggerOptions, type TemporalUnit, type WebhookTriggerOptions, type WebhookTriggerOutput, type Weekday, type approvalProcessStatusUpdatedStatus, type approvalProcessStatusUpdatedTriggerOptions } from "./triggers.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** The automation entity's registry entry (see src/graph/). */
|
|
2
2
|
import { sanitizeName, tfLabelToTsLabel, isTfExpr } from "../../engine/tf/index.js";
|
|
3
3
|
import { renderAutomationCatalogEntry } from "./catalog-render.js";
|
|
4
|
-
import {
|
|
4
|
+
import { preserveAuthoredAutomationPullMeta, printAutomationV2 } from "./deserializer/print-automation.js";
|
|
5
5
|
import { automationFromTf, automationOwnedAddresses } from "./from-tf.js";
|
|
6
6
|
import { automationToTf } from "./to-tf.js";
|
|
7
7
|
import { ALL_AUTOMATION_SUB_TYPES, AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
@@ -194,7 +194,7 @@ export const automationModule = {
|
|
|
194
194
|
}),
|
|
195
195
|
};
|
|
196
196
|
},
|
|
197
|
-
mergePulledSource:
|
|
197
|
+
mergePulledSource: preserveAuthoredAutomationPullMeta,
|
|
198
198
|
toTf: (entity, ctx) => automationToTf(entity, {
|
|
199
199
|
appRefName: ctx.appRefName,
|
|
200
200
|
appTfLabel: ctx.appTfLabel,
|
|
@@ -21,24 +21,36 @@ export function outputFieldTypesFromScriptSchema(schema) {
|
|
|
21
21
|
if (!Array.isArray(properties))
|
|
22
22
|
return undefined;
|
|
23
23
|
const out = new Map();
|
|
24
|
+
const nodeType = (node) => {
|
|
25
|
+
if (!isObject(node))
|
|
26
|
+
return undefined;
|
|
27
|
+
const [kind, body] = Object.entries(node)[0] ?? [];
|
|
28
|
+
if (!isObject(body) || typeof kind !== "string")
|
|
29
|
+
return undefined;
|
|
30
|
+
if (kind === "array") {
|
|
31
|
+
const item = nodeType(body.item);
|
|
32
|
+
return item === undefined ? undefined : { ...item, multiple: true, kind: "array" };
|
|
33
|
+
}
|
|
34
|
+
if (kind === "object")
|
|
35
|
+
return { fieldType: "TEXT", multiple: false, kind };
|
|
36
|
+
const fieldType = kind === "bool" ? "BOOLEAN"
|
|
37
|
+
: kind === "integer" ? "NUMBER"
|
|
38
|
+
: kind === "number" ? "DECIMAL"
|
|
39
|
+
: kind === "string" ? "TEXT"
|
|
40
|
+
: undefined;
|
|
41
|
+
return fieldType === undefined ? undefined : { fieldType, multiple: false, kind };
|
|
42
|
+
};
|
|
24
43
|
for (const property of properties) {
|
|
25
44
|
if (!isObject(property))
|
|
26
45
|
continue;
|
|
27
|
-
for (const
|
|
46
|
+
for (const body of Object.values(property)) {
|
|
28
47
|
if (!isObject(body) || typeof body.name !== "string")
|
|
29
48
|
continue;
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// "string" is a real, confirmed-text kind; anything else (e.g. "object")
|
|
36
|
-
// is an unmodeled schema kind falling back to the platform's own TEXT
|
|
37
|
-
// default — real for the wire, but callers that need to know whether
|
|
38
|
-
// this was an ACTUAL text kind (not a guess) should check `kind` too.
|
|
39
|
-
: "TEXT";
|
|
40
|
-
out.set(`result.${body.name}`, { fieldType, multiple: false, kind });
|
|
41
|
-
out.set(body.name, { fieldType, multiple: false, kind });
|
|
49
|
+
const resolved = nodeType(property);
|
|
50
|
+
if (resolved === undefined)
|
|
51
|
+
continue;
|
|
52
|
+
out.set(`result.${body.name}`, resolved);
|
|
53
|
+
out.set(body.name, resolved);
|
|
42
54
|
}
|
|
43
55
|
}
|
|
44
56
|
return out.size > 0 ? out : undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ScriptOutputType } from "./tasks.js";
|
|
1
2
|
/** The shape the platform passes to a script: inputs under `parameters`. */
|
|
2
3
|
export interface ScriptInput<I extends Record<string, unknown> = Record<string, unknown>> {
|
|
3
4
|
readonly parameters: I;
|
|
@@ -39,13 +40,20 @@ export declare function stripTsIgnoreLines(code: string): string;
|
|
|
39
40
|
* The scan is context-aware (skips comments, strings, and template literals
|
|
40
41
|
* with `${}` nesting) so braces inside them don't derail the literal walk.
|
|
41
42
|
*/
|
|
42
|
-
export declare function inferOutputSchema(body: string): Record<string,
|
|
43
|
+
export declare function inferOutputSchema(body: string): Record<string, ScriptOutputType> | undefined;
|
|
43
44
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* Free-identifier scan: uses the TypeScript compiler parser when available
|
|
46
|
+
* for full AST-level grammar fidelity, falling back to a tokenizing lexer when
|
|
47
|
+
* typescript is not present in the runtime environment.
|
|
47
48
|
*/
|
|
48
49
|
export declare function freeIdentifiers(body: string, params: ReadonlySet<string>): string[];
|
|
50
|
+
/**
|
|
51
|
+
* Best-effort fallback tokenizing scan: strip comments/strings/templates, collect
|
|
52
|
+
* identifier tokens that are not property accesses, object keys, declarations,
|
|
53
|
+
* params, keywords, or known script globals. Scope-aware for nested methods,
|
|
54
|
+
* functions, catch clauses, and arrow function parameter blocks.
|
|
55
|
+
*/
|
|
56
|
+
export declare function freeIdentifiersLexer(body: string, params: ReadonlySet<string>): string[];
|
|
49
57
|
/**
|
|
50
58
|
* Look up task `name`'s `code:` body verbatim from the automation file
|
|
51
59
|
* `elementum build` is currently importing (tracked engine-side by
|