@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.
- package/dist-sdk/pull/util.d.ts +0 -15
- package/dist-sdk/pull/util.js +44 -5
- package/dist-sdk/src/catalog/factories.d.ts +4 -2
- package/dist-sdk/src/catalog/factories.js +4 -0
- package/dist-sdk/src/catalog/from-authoring.js +5 -1
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +1 -1
- package/dist-sdk/src/catalog/token.js +2 -2
- package/dist-sdk/src/catalog/types.d.ts +7 -2
- package/dist-sdk/src/core/types/app.d.ts +4 -4
- package/dist-sdk/src/engine/build/context.d.ts +5 -4
- package/dist-sdk/src/engine/build/source-context.d.ts +2 -0
- package/dist-sdk/src/engine/build/source-context.js +16 -0
- package/dist-sdk/src/engine/progress.d.ts +19 -1
- package/dist-sdk/src/engine/progress.js +33 -5
- package/dist-sdk/src/engine/pull/context.d.ts +9 -1
- package/dist-sdk/src/engine/pull/ref-only.d.ts +6 -2
- package/dist-sdk/src/engine/pull/ref-only.js +14 -3
- package/dist-sdk/src/engine/workspace/loader.js +23 -2
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +1 -1
- package/dist-sdk/src/entities/access-policy/from-tf.js +47 -12
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +5 -3
- package/dist-sdk/src/entities/access-policy/to-tf.js +23 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.d.ts +6 -0
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +50 -4
- package/dist-sdk/src/entities/agent/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/agent/from-tf.js +18 -3
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.js +15 -0
- package/dist-sdk/src/entities/agent/tools.d.ts +98 -5
- package/dist-sdk/src/entities/agent/tools.js +12 -3
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +15 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +47 -4
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +9 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +82 -25
- package/dist-sdk/src/entities/app/build.d.ts +2 -2
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +4 -4
- package/dist-sdk/src/entities/app/module.js +8 -0
- package/dist-sdk/src/entities/app/to-tf.js +1 -0
- package/dist-sdk/src/entities/approval-chain/build.d.ts +8 -1
- package/dist-sdk/src/entities/approval-chain/build.js +3 -0
- package/dist-sdk/src/entities/approval-chain/from-tf.d.ts +2 -1
- package/dist-sdk/src/entities/approval-chain/from-tf.js +20 -7
- package/dist-sdk/src/entities/approval-chain/printer.js +13 -2
- package/dist-sdk/src/entities/approval-chain/to-tf.js +3 -0
- package/dist-sdk/src/entities/automation/build.d.ts +19 -12
- package/dist-sdk/src/entities/automation/build.js +36 -13
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +4 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +19 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +222 -65
- package/dist-sdk/src/entities/automation/from-tf.d.ts +86 -6
- package/dist-sdk/src/entities/automation/from-tf.js +360 -63
- package/dist-sdk/src/entities/automation/index.d.ts +3 -2
- package/dist-sdk/src/entities/automation/index.js +3 -2
- package/dist-sdk/src/entities/automation/module.js +21 -16
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +5 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +12 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +22 -0
- package/dist-sdk/src/entities/automation/script-code.d.ts +32 -0
- package/dist-sdk/src/entities/automation/script-code.js +72 -5
- package/dist-sdk/src/entities/automation/tasks.d.ts +60 -24
- package/dist-sdk/src/entities/automation/tasks.js +33 -14
- package/dist-sdk/src/entities/automation/to-tf.d.ts +0 -2
- package/dist-sdk/src/entities/automation/to-tf.js +123 -46
- package/dist-sdk/src/entities/automation/triggers.d.ts +5 -2
- package/dist-sdk/src/entities/automation/types.d.ts +2 -0
- package/dist-sdk/src/entities/automation/types.js +5 -0
- package/dist-sdk/src/entities/automation/workflow-output.d.ts +35 -0
- package/dist-sdk/src/entities/automation/workflow-output.js +53 -0
- package/dist-sdk/src/entities/chart/build.d.ts +3 -3
- package/dist-sdk/src/entities/chart/from-tf.d.ts +2 -2
- package/dist-sdk/src/entities/chart/from-tf.js +20 -13
- package/dist-sdk/src/entities/chart/to-tf.js +7 -5
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dashboard/to-tf.js +1 -0
- package/dist-sdk/src/entities/dynamic-layout/from-tf.js +3 -2
- package/dist-sdk/src/entities/element/build.d.ts +11 -8
- package/dist-sdk/src/entities/element/build.js +14 -5
- package/dist-sdk/src/entities/element/locals.d.ts +2 -2
- package/dist-sdk/src/entities/element/locals.js +6 -2
- package/dist-sdk/src/entities/element/system-fields.d.ts +4 -0
- package/dist-sdk/src/entities/element/system-fields.js +12 -0
- package/dist-sdk/src/entities/element/to-tf.js +1 -0
- package/dist-sdk/src/entities/field/build.d.ts +2 -2
- package/dist-sdk/src/entities/field/from-tf.js +82 -4
- package/dist-sdk/src/entities/field/to-tf.d.ts +1 -1
- package/dist-sdk/src/entities/field/to-tf.js +11 -4
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -2
- package/dist-sdk/src/entities/relationship/from-tf.js +8 -5
- package/dist-sdk/src/entities/relationship/to-tf.js +13 -3
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -6
- package/dist-sdk/src/entities/search-table/module.js +2 -2
- package/dist-sdk/src/entities/search-table/types.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +3 -3
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +10 -6
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +4 -2
- package/dist-sdk/src/entities/shared/filters/index.d.ts +12 -2
- package/dist-sdk/src/entities/shared/filters/index.js +17 -1
- package/dist-sdk/src/entities/shared/filters/print.js +25 -11
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +1 -1
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +39 -7
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +1 -1
- package/dist-sdk/src/entities/shared/tool-field-ref.js +6 -2
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +6 -0
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +47 -18
- package/dist-sdk/src/entities/skill/module.js +10 -0
- package/dist-sdk/src/entities/skill/to-tf.js +19 -0
- package/dist-sdk/src/entities/skill/tools.d.ts +29 -7
- package/dist-sdk/src/entities/skill/tools.js +6 -2
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +18 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +77 -4
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +8 -0
- package/dist-sdk/src/entities/skill-tool/to-tf.js +90 -46
- package/dist-sdk/src/entities/task/module.js +1 -1
- package/dist-sdk/src/entities/view/from-tf.js +30 -9
- package/dist-sdk/src/entities/view/to-tf.js +18 -10
- package/dist-sdk/src/entities/widget/from-tf.js +3 -3
- package/dist-sdk/src/entities/widget/to-tf.js +1 -0
- package/dist-sdk/src/graph/index.d.ts +15 -0
- package/dist-sdk/src/graph/index.js +19 -0
- package/dist-sdk/src/graph/types.d.ts +37 -1
- package/package.json +2 -1
|
@@ -16,6 +16,7 @@ export { AUTOMATION_RESOURCE_TYPES, AUTOMATION_TASK_TYPES, AUTOMATION_TRIGGER_TY
|
|
|
16
16
|
*/
|
|
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
|
-
export { ScriptCodeError, type ScriptCodeFn, type ScriptInput } from "./script-code.js";
|
|
20
|
-
export {
|
|
19
|
+
export { ScriptCodeError, scriptFile, type ScriptCodeFn, type ScriptFile, type ScriptInput } from "./script-code.js";
|
|
20
|
+
export { workflowOutput, workflowOutputType, type WorkflowOutputDeclaration, type WorkflowOutputType, } from "./workflow-output.js";
|
|
21
|
+
export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings, 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 ExecuteScriptFieldMapping, type ExecuteScriptOptions, type FieldAssignment, 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
22
|
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";
|
|
@@ -16,8 +16,9 @@ export { AUTOMATION_RESOURCE_TYPES, AUTOMATION_TASK_TYPES, AUTOMATION_TRIGGER_TY
|
|
|
16
16
|
*/
|
|
17
17
|
export * as filter from "../shared/filters/index.js";
|
|
18
18
|
export { automationStatus, chainableTrigger, actions, automation } from "./build.js";
|
|
19
|
-
export { ScriptCodeError } from "./script-code.js";
|
|
20
|
-
export {
|
|
19
|
+
export { ScriptCodeError, scriptFile } from "./script-code.js";
|
|
20
|
+
export { workflowOutput, workflowOutputType, } from "./workflow-output.js";
|
|
21
|
+
export { addWatcher, aiAgent, aiClassify, aiEmailAnalysis, aiFileAnalysis, aiSearchTable, aiSummarize, aiTransform, apiRequest, approvalChain, approvalChainTemplate, approvalStatusUpdate, assignGroup, assignUser, assignmentEngine, bulkExcel, calculation, createRecord, executeScript, findRelatedRecords, generateReport, initiateCall, initiateEmailConversation, notification, postComment, postTeamsMessage, procedure, readFile, recordFieldLocking, recordSearch, relateRecords, runAutomation, saveAttachment, sendEmail, sendSurvey, setVariable, tableRecordsSearch, unzip, updateField, userGroupSearch, userSearch, withFieldMappings } from "./tasks.js";
|
|
21
22
|
export { approvalProcessStatusUpdated, attachment, commentAdded, conversationEnd, dataMine, emailReceived, onDemand, recordCreated, recordUpdated, schedule, slackMessage, surveyResponseCreate, temporal, webHook, webhook } from "./triggers.js";
|
|
22
23
|
// Pull a deployed automation back as editable v2 source. `automation`
|
|
23
24
|
// is a plain factory returning a builder-chain object (not an Object.assign-able
|
|
@@ -1,8 +1,9 @@
|
|
|
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 { preserveAuthoredAutomationPullMeta,
|
|
5
|
-
import { automationFromTf, automationOwnedAddresses } from "./from-tf.js";
|
|
4
|
+
import { preserveAuthoredAutomationPullMeta, printAutomationV2WithScriptFiles, SCRIPT_FILES_DIR } from "./deserializer/print-automation.js";
|
|
5
|
+
import { automationFromTf, automationOwnedAddresses, UnsupportedMultiTriggerError } from "./from-tf.js";
|
|
6
|
+
import { scriptFileRefs } from "./script-code.js";
|
|
6
7
|
import { automationToTf } from "./to-tf.js";
|
|
7
8
|
import { ALL_AUTOMATION_SUB_TYPES, AUTOMATION_RESOURCE_TYPE, WORKFLOW_PUBLISH_RESOURCE_TYPE, } from "./types.js";
|
|
8
9
|
function isConfigured(value) {
|
|
@@ -112,15 +113,20 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
112
113
|
// (one owned-address walk) relative to from-tf.
|
|
113
114
|
registerForeignObjectIdDeps(doc, autoLabel, ctx);
|
|
114
115
|
try {
|
|
115
|
-
const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator);
|
|
116
|
+
const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator, ctx.foreignTaskRefNames);
|
|
116
117
|
// Keep automationFromTf's label-derived refName — agent/skill tools store
|
|
117
118
|
// the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
|
|
118
119
|
// only) made missing-automation diagnostics false-positive on every real
|
|
119
120
|
// extract (issue #395 / PR #417 review).
|
|
120
121
|
items.push({ ...extracted.ast, refName: extracted.refName });
|
|
121
122
|
adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
|
|
123
|
+
diagnostics.push(...(extracted.diagnostics ?? []).map((diagnostic) => `${autoLabel}: ${diagnostic}`));
|
|
122
124
|
}
|
|
123
125
|
catch (err) {
|
|
126
|
+
// Multi-trigger is unsupported, not an extract gap. Skipping it would
|
|
127
|
+
// let `pull app` / `pull element` succeed without the automation.
|
|
128
|
+
if (err instanceof UnsupportedMultiTriggerError)
|
|
129
|
+
throw err;
|
|
124
130
|
// Report the automation's FULL graph (trigger/tasks/branches/publish),
|
|
125
131
|
// not just its root - otherwise those children's otherwise-adoptable
|
|
126
132
|
// resource TYPES get imported into state anyway, and build (which
|
|
@@ -176,6 +182,8 @@ export const automationModule = {
|
|
|
176
182
|
lifecycle: {
|
|
177
183
|
participates: true,
|
|
178
184
|
extractOwnFile: extractAutomations,
|
|
185
|
+
companionDirs: [SCRIPT_FILES_DIR],
|
|
186
|
+
companionRefs: scriptFileRefs,
|
|
179
187
|
printOwnFile: (item, opts) => {
|
|
180
188
|
const automation = item;
|
|
181
189
|
// Prefer the extract-time bag key (matches tool automationKey). Fall
|
|
@@ -183,15 +191,18 @@ export const automationModule = {
|
|
|
183
191
|
const refName = typeof automation.refName === "string" && automation.refName !== ""
|
|
184
192
|
? automation.refName
|
|
185
193
|
: tfLabelToTsLabel(sanitizeName(automation.name));
|
|
194
|
+
const printed = printAutomationV2WithScriptFiles(automation, {
|
|
195
|
+
refName,
|
|
196
|
+
appRefName: opts.appRefName,
|
|
197
|
+
...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
|
|
198
|
+
...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
|
|
199
|
+
...(opts.foreignTaskRefNames !== undefined && { foreignTaskRefNames: opts.foreignTaskRefNames }),
|
|
200
|
+
...(opts.unresolvedReferences !== undefined && { unresolvedReferences: opts.unresolvedReferences }),
|
|
201
|
+
});
|
|
186
202
|
return {
|
|
187
203
|
refName,
|
|
188
|
-
source:
|
|
189
|
-
|
|
190
|
-
appRefName: opts.appRefName,
|
|
191
|
-
...(opts.foreignAppRefNames !== undefined && { foreignAppRefNames: opts.foreignAppRefNames }),
|
|
192
|
-
...(opts.foreignElementRefNames !== undefined && { foreignElementRefNames: opts.foreignElementRefNames }),
|
|
193
|
-
...(opts.unresolvedReferences !== undefined && { unresolvedReferences: opts.unresolvedReferences }),
|
|
194
|
-
}),
|
|
204
|
+
source: printed.source,
|
|
205
|
+
...(printed.scriptFiles.length > 0 && { companionFiles: printed.scriptFiles }),
|
|
195
206
|
};
|
|
196
207
|
},
|
|
197
208
|
mergePulledSource: preserveAuthoredAutomationPullMeta,
|
|
@@ -214,12 +225,6 @@ export const automationModule = {
|
|
|
214
225
|
.filter((sibling) => sibling.kind === "automation" &&
|
|
215
226
|
sibling.payload?.status === "ACTIVE")
|
|
216
227
|
.map((sibling) => sibling.refName)),
|
|
217
|
-
automationNamesByRefName: new Map((ctx.siblingEntities ?? [])
|
|
218
|
-
.filter((sibling) => sibling.kind === "automation")
|
|
219
|
-
.flatMap((sibling) => {
|
|
220
|
-
const name = sibling.payload?.name;
|
|
221
|
-
return typeof name === "string" && name !== "" ? [[sibling.refName, name]] : [];
|
|
222
|
-
})),
|
|
223
228
|
}),
|
|
224
229
|
},
|
|
225
230
|
catalog: {
|
|
@@ -15,3 +15,8 @@ export declare function outputFieldTypesFromScriptSchema(schema: unknown): Map<s
|
|
|
15
15
|
multiple: boolean;
|
|
16
16
|
kind: string;
|
|
17
17
|
}> | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A nested result path belongs to its declared top-level object even when the
|
|
20
|
+
* current schema projection does not yet model that object's item properties.
|
|
21
|
+
*/
|
|
22
|
+
export declare function scriptOutputReferenceIsDeclared(outputTypes: ReadonlyMap<string, unknown> | undefined, name: string): boolean;
|
|
@@ -55,3 +55,15 @@ export function outputFieldTypesFromScriptSchema(schema) {
|
|
|
55
55
|
}
|
|
56
56
|
return out.size > 0 ? out : undefined;
|
|
57
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A nested result path belongs to its declared top-level object even when the
|
|
60
|
+
* current schema projection does not yet model that object's item properties.
|
|
61
|
+
*/
|
|
62
|
+
export function scriptOutputReferenceIsDeclared(outputTypes, name) {
|
|
63
|
+
if (outputTypes?.has(name) === true)
|
|
64
|
+
return true;
|
|
65
|
+
if (!name.startsWith("result."))
|
|
66
|
+
return false;
|
|
67
|
+
const root = `result.${name.slice("result.".length).split(".")[0]}`;
|
|
68
|
+
return outputTypes?.has(root) === true;
|
|
69
|
+
}
|
|
@@ -16,6 +16,26 @@
|
|
|
16
16
|
* either side can never introduce a cycle.
|
|
17
17
|
*/
|
|
18
18
|
export declare const OUTPUT_KEY_WIRE_NAME: Readonly<Record<string, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* Compares a raw wire segment against an {@link OUTPUT_KEY_WIRE_NAME} value.
|
|
21
|
+
* The Title-Case wire name above is confirmed against each task's own
|
|
22
|
+
* `refs` map (a stable, schema-derived attribute), but a `taskReference.name`
|
|
23
|
+
* embedded in a filter/formula envelope is a SEPARATE serialization the
|
|
24
|
+
* platform lowercases (live-confirmed on conciergeforfield, sanofi/us: the
|
|
25
|
+
* same aiTransform task's `refs` map has `Response`, but every
|
|
26
|
+
* `taskReference.name` pointing at it says `response`). A case-sensitive
|
|
27
|
+
* compare silently missed the envelope form and fell through to the raw
|
|
28
|
+
* segment, printing an unmapped `.response`/`.refs["response"]` accessor
|
|
29
|
+
* that doesn't exist ("Invalid index" on every plan).
|
|
30
|
+
*
|
|
31
|
+
* Accepts the exact wire key OR that key fully lowercased - not a full
|
|
32
|
+
* case-fold on both sides. `documentModel`'s wire key is already `"text"`,
|
|
33
|
+
* and a file-reader task's schema can declare its own field named `Text`
|
|
34
|
+
* (an arbitrary user-chosen schema name, not this table's business) -
|
|
35
|
+
* folding both sides to lowercase would alias that unrelated `Text` field
|
|
36
|
+
* onto `.output` too and rebuild it as `refs["text"]`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function matchesOutputWireKey(segment: string, wireKey: string): boolean;
|
|
19
39
|
/**
|
|
20
40
|
* apiRequest task outputs in authoring use camelCase segments (`statusCode`,
|
|
21
41
|
* `file.content`, …) but the provider refs map uses display labels — confirmed
|
|
@@ -21,6 +21,28 @@ export const OUTPUT_KEY_WIRE_NAME = {
|
|
|
21
21
|
aiClassify: "Response",
|
|
22
22
|
documentModel: "text",
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Compares a raw wire segment against an {@link OUTPUT_KEY_WIRE_NAME} value.
|
|
26
|
+
* The Title-Case wire name above is confirmed against each task's own
|
|
27
|
+
* `refs` map (a stable, schema-derived attribute), but a `taskReference.name`
|
|
28
|
+
* embedded in a filter/formula envelope is a SEPARATE serialization the
|
|
29
|
+
* platform lowercases (live-confirmed on conciergeforfield, sanofi/us: the
|
|
30
|
+
* same aiTransform task's `refs` map has `Response`, but every
|
|
31
|
+
* `taskReference.name` pointing at it says `response`). A case-sensitive
|
|
32
|
+
* compare silently missed the envelope form and fell through to the raw
|
|
33
|
+
* segment, printing an unmapped `.response`/`.refs["response"]` accessor
|
|
34
|
+
* that doesn't exist ("Invalid index" on every plan).
|
|
35
|
+
*
|
|
36
|
+
* Accepts the exact wire key OR that key fully lowercased - not a full
|
|
37
|
+
* case-fold on both sides. `documentModel`'s wire key is already `"text"`,
|
|
38
|
+
* and a file-reader task's schema can declare its own field named `Text`
|
|
39
|
+
* (an arbitrary user-chosen schema name, not this table's business) -
|
|
40
|
+
* folding both sides to lowercase would alias that unrelated `Text` field
|
|
41
|
+
* onto `.output` too and rebuild it as `refs["text"]`.
|
|
42
|
+
*/
|
|
43
|
+
export function matchesOutputWireKey(segment, wireKey) {
|
|
44
|
+
return segment === wireKey || segment === wireKey.toLowerCase();
|
|
45
|
+
}
|
|
24
46
|
/**
|
|
25
47
|
* apiRequest task outputs in authoring use camelCase segments (`statusCode`,
|
|
26
48
|
* `file.content`, …) but the provider refs map uses display labels — confirmed
|
|
@@ -4,6 +4,38 @@ export interface ScriptInput<I extends Record<string, unknown> = Record<string,
|
|
|
4
4
|
readonly parameters: I;
|
|
5
5
|
}
|
|
6
6
|
export type ScriptCodeFn<I extends Record<string, unknown> = Record<string, unknown>, R = Record<string, unknown>> = (input: ScriptInput<I>) => R;
|
|
7
|
+
/**
|
|
8
|
+
* A reference to a plain-JavaScript script file, used as `executeScript`'s
|
|
9
|
+
* `code:` instead of an inline function. The file holds the platform script
|
|
10
|
+
* body VERBATIM (top-level `return`, `input` in scope), so it is never
|
|
11
|
+
* type-checked or type-stripped and reaches the platform byte for byte.
|
|
12
|
+
*/
|
|
13
|
+
export interface ScriptFile {
|
|
14
|
+
readonly __kind: "scriptFile";
|
|
15
|
+
/** Path to the `.js` file, relative to the automation file (or absolute). */
|
|
16
|
+
readonly path: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reference a plain-JavaScript script file for `executeScript`'s `code:`.
|
|
20
|
+
* The path is relative to the automation file that calls it.
|
|
21
|
+
*
|
|
22
|
+
* .executeScript("score", { code: scriptFile("./scripts/lead.score.js") })
|
|
23
|
+
*/
|
|
24
|
+
export declare function scriptFile(path: string): ScriptFile;
|
|
25
|
+
export declare function isScriptFile(value: unknown): value is ScriptFile;
|
|
26
|
+
/** Paths of every `scriptFile("...")` call in an automation file's source, as written. */
|
|
27
|
+
export declare function scriptFileRefs(source: string): string[];
|
|
28
|
+
/** Printed script files end with exactly one newline, which reading strips again. */
|
|
29
|
+
export declare function scriptFileText(body: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Read a {@link ScriptFile}'s body. Relative paths resolve against the
|
|
32
|
+
* automation file the workspace loader is importing (build, canvas and
|
|
33
|
+
* catalog regeneration alike); outside the loader only an absolute path can
|
|
34
|
+
* resolve. One trailing newline is dropped (the printer adds it so editors
|
|
35
|
+
* do not introduce a diff); nothing else is touched, so the platform text
|
|
36
|
+
* round-trips byte for byte.
|
|
37
|
+
*/
|
|
38
|
+
export declare function readScriptFile(ref: ScriptFile): string;
|
|
7
39
|
export declare class ScriptCodeError extends Error {
|
|
8
40
|
constructor(message: string);
|
|
9
41
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
|
-
import {
|
|
3
|
+
import { dirname, isAbsolute, resolve } from "node:path";
|
|
4
|
+
import { currentImportingFile, currentSourceText } from "../../engine/build/source-context.js";
|
|
3
5
|
let tsModule;
|
|
4
6
|
function getTs() {
|
|
5
7
|
if (tsModule === undefined) {
|
|
@@ -12,6 +14,62 @@ function getTs() {
|
|
|
12
14
|
}
|
|
13
15
|
return tsModule ?? undefined;
|
|
14
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Reference a plain-JavaScript script file for `executeScript`'s `code:`.
|
|
19
|
+
* The path is relative to the automation file that calls it.
|
|
20
|
+
*
|
|
21
|
+
* .executeScript("score", { code: scriptFile("./scripts/lead.score.js") })
|
|
22
|
+
*/
|
|
23
|
+
export function scriptFile(path) {
|
|
24
|
+
if (typeof path !== "string" || path === "") {
|
|
25
|
+
throw new ScriptCodeError("scriptFile(path): path must be a non-empty string.");
|
|
26
|
+
}
|
|
27
|
+
if (!path.endsWith(".js")) {
|
|
28
|
+
throw new ScriptCodeError(`scriptFile("${path}"): script files must be plain JavaScript (.js).`);
|
|
29
|
+
}
|
|
30
|
+
return { __kind: "scriptFile", path };
|
|
31
|
+
}
|
|
32
|
+
export function isScriptFile(value) {
|
|
33
|
+
return (typeof value === "object" &&
|
|
34
|
+
value !== null &&
|
|
35
|
+
value.__kind === "scriptFile" &&
|
|
36
|
+
typeof value.path === "string");
|
|
37
|
+
}
|
|
38
|
+
/** Paths of every `scriptFile("...")` call in an automation file's source, as written. */
|
|
39
|
+
export function scriptFileRefs(source) {
|
|
40
|
+
return [...source.matchAll(/\bscriptFile\(\s*(["'`])([^"'`\n]+)\1\s*\)/g)].map((match) => match[2]);
|
|
41
|
+
}
|
|
42
|
+
/** Printed script files end with exactly one newline, which reading strips again. */
|
|
43
|
+
export function scriptFileText(body) {
|
|
44
|
+
return `${body}\n`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Read a {@link ScriptFile}'s body. Relative paths resolve against the
|
|
48
|
+
* automation file the workspace loader is importing (build, canvas and
|
|
49
|
+
* catalog regeneration alike); outside the loader only an absolute path can
|
|
50
|
+
* resolve. One trailing newline is dropped (the printer adds it so editors
|
|
51
|
+
* do not introduce a diff); nothing else is touched, so the platform text
|
|
52
|
+
* round-trips byte for byte.
|
|
53
|
+
*/
|
|
54
|
+
export function readScriptFile(ref) {
|
|
55
|
+
let file = ref.path;
|
|
56
|
+
if (!isAbsolute(file)) {
|
|
57
|
+
const importing = currentSourceText()?.filePath ?? currentImportingFile();
|
|
58
|
+
if (importing === undefined) {
|
|
59
|
+
throw new ScriptCodeError(`scriptFile("${ref.path}") is relative to the automation file, but no automation file is being loaded. ` +
|
|
60
|
+
"Use an absolute path when building an automation outside `elementum build`.");
|
|
61
|
+
}
|
|
62
|
+
file = resolve(dirname(importing), ref.path);
|
|
63
|
+
}
|
|
64
|
+
let text;
|
|
65
|
+
try {
|
|
66
|
+
text = readFileSync(file, "utf8");
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
throw new ScriptCodeError(`scriptFile("${ref.path}"): cannot read ${file}: ${error.message}`);
|
|
70
|
+
}
|
|
71
|
+
return text.endsWith("\r\n") ? text.slice(0, -2) : text.endsWith("\n") ? text.slice(0, -1) : text;
|
|
72
|
+
}
|
|
15
73
|
/** Globals a script body may legitimately reference on the platform runtime. */
|
|
16
74
|
const SCRIPT_GLOBALS = new Set([
|
|
17
75
|
"input",
|
|
@@ -99,7 +157,7 @@ export function stripTsIgnoreLines(code) {
|
|
|
99
157
|
.join("\n");
|
|
100
158
|
}
|
|
101
159
|
function finishBody(rawBody, rawParams, fullSrc) {
|
|
102
|
-
const body = dedent(stripTsIgnoreLines(rawBody).replace(/^\n+/, "").replace(/\
|
|
160
|
+
const body = dedent(stripTsIgnoreLines(rawBody).replace(/^\n+/, "").replace(/\n[ \t]*$/, ""));
|
|
103
161
|
const params = collectParamNames(rawParams);
|
|
104
162
|
const unknown = freeIdentifiers(body, params);
|
|
105
163
|
if (unknown.length > 0) {
|
|
@@ -455,12 +513,21 @@ function splitTopLevelExpressions(value) {
|
|
|
455
513
|
parts.push(value.slice(start).trim());
|
|
456
514
|
return parts.filter((part) => part.length > 0);
|
|
457
515
|
}
|
|
458
|
-
/**
|
|
516
|
+
/**
|
|
517
|
+
* Strip the common leading indentation (the flush-left fixed point survives
|
|
518
|
+
* ei's heredoc round trip). A blank line is sliced the same as any other
|
|
519
|
+
* line, not force-replaced with "" - the printer (annotateScriptLines) pads
|
|
520
|
+
* a blank line's own original content (e.g. accidental trailing whitespace
|
|
521
|
+
* an editor left in the deployed script - live-confirmed on
|
|
522
|
+
* conciergeforfield, sanofi/us) with the SAME indent every real line gets,
|
|
523
|
+
* specifically so this slice lands back on that original content instead
|
|
524
|
+
* of discarding it.
|
|
525
|
+
*/
|
|
459
526
|
function dedent(body) {
|
|
460
527
|
const lines = body.split("\n");
|
|
461
528
|
const indents = lines.filter((l) => l.trim() !== "").map((l) => /^\s*/.exec(l)[0].length);
|
|
462
529
|
const min = indents.length > 0 ? Math.min(...indents) : 0;
|
|
463
|
-
return lines.map((l) =>
|
|
530
|
+
return lines.map((l) => l.slice(min)).join("\n");
|
|
464
531
|
}
|
|
465
532
|
/**
|
|
466
533
|
* AST-based free-identifier scan using the real TypeScript compiler parser.
|
|
@@ -1216,7 +1283,7 @@ function scanExecuteScriptBodies(src) {
|
|
|
1216
1283
|
if (name !== undefined) {
|
|
1217
1284
|
const body = extractCodeBody(call.args[1]);
|
|
1218
1285
|
if (body !== undefined) {
|
|
1219
|
-
result.set(name, dedent(stripTsIgnoreLines(body).replace(/^\n+/, "").replace(/\
|
|
1286
|
+
result.set(name, dedent(stripTsIgnoreLines(body).replace(/^\n+/, "").replace(/\n[ \t]*$/, "")));
|
|
1220
1287
|
}
|
|
1221
1288
|
}
|
|
1222
1289
|
}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* accept a literal or a `ctx` `Ref` and are pre-serialized to the platform's
|
|
12
12
|
* `ValueReference` JSON via the shared, agnostic `serializeValueOrRef`.
|
|
13
13
|
*/
|
|
14
|
-
import type { AgentRef, AppOrElementRef, ApprovalProcessRef, AutomationCatalogRef, CloudLinkRef, ConnectorRef, DocumentModelFieldRef, FieldRef, FileReaderCatalogRef, OutputPropertyRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, SearchTableRef, TableRef } from "../../catalog/index.js";
|
|
14
|
+
import type { AgentRef, AppOrElementOrTaskRef, AppOrElementRef, ApprovalProcessRef, AutomationCatalogRef, CloudLinkRef, ConnectorRef, DocumentModelFieldRef, FieldRef, FileReaderCatalogRef, OutputPropertyRef, PhoneServiceRef, ProcedureParameterType, ProcedureRef, SearchTableRef, TableRef } from "../../catalog/index.js";
|
|
15
15
|
import type { UnsafePlatformId } from "../../core/platform-id.js";
|
|
16
16
|
import type { CalculationInclude, Expr, ExprCardinality, ExprContext, ExprType } from "../field/calc/types.js";
|
|
17
17
|
import type { RecordId, RecordShape } from "../field/record-shape.js";
|
|
@@ -21,7 +21,7 @@ import type { DropdownValue } from "../shared/types/platform.js";
|
|
|
21
21
|
import type { ActionDef } from "./build.js";
|
|
22
22
|
import { type CalculationValue } from "./calculation-expression.js";
|
|
23
23
|
import type { Filter } from "./filter.js";
|
|
24
|
-
import { type ScriptCodeFn } from "./script-code.js";
|
|
24
|
+
import { type ScriptCodeFn, type ScriptFile } from "./script-code.js";
|
|
25
25
|
export type { CalculationInclude } from "../field/calc/types.js";
|
|
26
26
|
export type { RecordId };
|
|
27
27
|
/**
|
|
@@ -29,7 +29,7 @@ export type { RecordId };
|
|
|
29
29
|
* `refs["Record"]`) or its branded `.recordId`. TEXT `.id` (`refs["ID"]`) is
|
|
30
30
|
* not assignable (edk#295).
|
|
31
31
|
*/
|
|
32
|
-
export type RecordReference<A extends
|
|
32
|
+
export type RecordReference<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> = Ref<RecordShape<A>> | ValueOrRef<RecordId> | UnsafePlatformId;
|
|
33
33
|
/** A field assignment: which field, and the value (literal or `ctx` ref). */
|
|
34
34
|
export interface FieldAssignment<F extends FieldRef | UnsafePlatformId = FieldRef | UnsafePlatformId> {
|
|
35
35
|
/** Prefer a typed catalog field; pulled source uses an explicit escape hatch when a non-recursive export only exposes the platform id. */
|
|
@@ -57,19 +57,19 @@ type UpdateValueForField<F extends FieldRef | UnsafePlatformId> = IsAny<F> exten
|
|
|
57
57
|
* choose replace/add behavior; every other field rejects updateMode.
|
|
58
58
|
*/
|
|
59
59
|
export type UpdateFieldAssignment<F extends FieldRef | UnsafePlatformId = FieldRef | UnsafePlatformId> = Omit<FieldAssignment<F>, "value"> & UpdateValueForField<F> & UpdateModeForField<F>;
|
|
60
|
-
export interface RecordSearchOutput<A extends
|
|
60
|
+
export interface RecordSearchOutput<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> {
|
|
61
61
|
readonly records: readonly RecordShape<A>[];
|
|
62
62
|
readonly record: RecordShape<A>;
|
|
63
63
|
readonly totalCount: number;
|
|
64
64
|
}
|
|
65
|
-
export interface RecordSearchOptions<A extends
|
|
65
|
+
export interface RecordSearchOptions<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> {
|
|
66
66
|
readonly app: A;
|
|
67
67
|
/** Required — the platform rejects a record search with no filter (use `filter.whereTrue()` for all). */
|
|
68
68
|
readonly filter: Filter;
|
|
69
69
|
readonly sort?: Record<string, unknown>;
|
|
70
70
|
readonly limit?: number;
|
|
71
71
|
}
|
|
72
|
-
export declare function recordSearch<A extends
|
|
72
|
+
export declare function recordSearch<A extends AppOrElementOrTaskRef>(opts: RecordSearchOptions<A>): ActionDef<RecordSearchOutput<A>>;
|
|
73
73
|
export interface TableRecordsSearchOutput<A extends AppOrElementRef = AppOrElementRef> {
|
|
74
74
|
readonly records: readonly RecordShape<A>[];
|
|
75
75
|
readonly record: RecordShape<A>;
|
|
@@ -95,10 +95,10 @@ export interface TableRecordsSearchOptions<A extends AppOrElementRef = AppOrElem
|
|
|
95
95
|
readonly limit?: number;
|
|
96
96
|
}
|
|
97
97
|
export declare function tableRecordsSearch<A extends AppOrElementRef = AppOrElementRef>(opts: TableRecordsSearchOptions<A>): ActionDef<TableRecordsSearchOutput<A>>;
|
|
98
|
-
export interface CreateRecordOutput<A extends
|
|
98
|
+
export interface CreateRecordOutput<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> {
|
|
99
99
|
readonly record: RecordShape<A>;
|
|
100
100
|
}
|
|
101
|
-
export interface CreateRecordOptions<A extends
|
|
101
|
+
export interface CreateRecordOptions<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> {
|
|
102
102
|
readonly app: A;
|
|
103
103
|
readonly fields: readonly FieldAssignment[];
|
|
104
104
|
/** Relate the new record to `record` (the triggering/source record). */
|
|
@@ -110,21 +110,21 @@ export interface CreateRecordOptions<A extends AppOrElementRef = AppOrElementRef
|
|
|
110
110
|
*/
|
|
111
111
|
readonly record?: RecordReference;
|
|
112
112
|
}
|
|
113
|
-
export declare function createRecord<A extends
|
|
113
|
+
export declare function createRecord<A extends AppOrElementOrTaskRef>(opts: CreateRecordOptions<A>): ActionDef<CreateRecordOutput<A>>;
|
|
114
114
|
type ValidatedUpdateFieldAssignments<Fields extends readonly FieldAssignment[]> = {
|
|
115
115
|
readonly [Index in keyof Fields]: Fields[Index] extends FieldAssignment<infer F> ? Fields[Index] & UpdateValueForField<F> & UpdateModeForField<F> : never;
|
|
116
116
|
};
|
|
117
|
-
export interface UpdateFieldOptions<A extends
|
|
117
|
+
export interface UpdateFieldOptions<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef, Fields extends readonly FieldAssignment[] = readonly FieldAssignment[]> {
|
|
118
118
|
readonly app: A;
|
|
119
119
|
/** The record to update (e.g. `ctx.trigger.record` or `.record.recordId`). */
|
|
120
120
|
readonly record: RecordReference<A>;
|
|
121
121
|
readonly fields: Fields & ValidatedUpdateFieldAssignments<NoInfer<Fields>>;
|
|
122
122
|
}
|
|
123
123
|
/** Update fields on an existing record. `value: ""` or `value: null` clears a nullable field (including Dropdown). */
|
|
124
|
-
export declare function updateField<A extends
|
|
124
|
+
export declare function updateField<A extends AppOrElementOrTaskRef, const Fields extends readonly FieldAssignment[]>(opts: UpdateFieldOptions<A, Fields>): ActionDef<{
|
|
125
125
|
record: RecordShape<A>;
|
|
126
126
|
}>;
|
|
127
|
-
export interface FindRelatedRecordsOptions<A extends
|
|
127
|
+
export interface FindRelatedRecordsOptions<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> {
|
|
128
128
|
readonly relatedApp: A;
|
|
129
129
|
/**
|
|
130
130
|
* The record whose related records to find. Belongs to the app/element the
|
|
@@ -141,11 +141,11 @@ export interface FindRelatedRecordsOptions<A extends AppOrElementRef = AppOrElem
|
|
|
141
141
|
* include `Record` and `All found records`, but not recordSearch's
|
|
142
142
|
* `Records Size` (`totalCount`). Do not invent a count ref.
|
|
143
143
|
*/
|
|
144
|
-
export interface FindRelatedRecordsOutput<A extends
|
|
144
|
+
export interface FindRelatedRecordsOutput<A extends AppOrElementOrTaskRef = AppOrElementOrTaskRef> {
|
|
145
145
|
readonly records: readonly RecordShape<A>[];
|
|
146
146
|
readonly record: RecordShape<A>;
|
|
147
147
|
}
|
|
148
|
-
export declare function findRelatedRecords<A extends
|
|
148
|
+
export declare function findRelatedRecords<A extends AppOrElementOrTaskRef>(opts: FindRelatedRecordsOptions<A>): ActionDef<FindRelatedRecordsOutput<A>>;
|
|
149
149
|
export interface RelateRecordsOptions {
|
|
150
150
|
/** One or more source record references. */
|
|
151
151
|
readonly sources: readonly ValueOrRef<unknown>[];
|
|
@@ -236,6 +236,8 @@ export type ScriptOutputScalarType = "text" | "string" | "integer" | "number" |
|
|
|
236
236
|
export type ScriptOutputType = ScriptOutputScalarType | {
|
|
237
237
|
readonly type: "array";
|
|
238
238
|
readonly items: ScriptOutputType;
|
|
239
|
+
/** Name stored on the array's item schema node, distinct from the array property's own name. */
|
|
240
|
+
readonly itemName?: string;
|
|
239
241
|
} | {
|
|
240
242
|
readonly type: "object";
|
|
241
243
|
readonly properties?: ScriptOutputProperties;
|
|
@@ -283,6 +285,36 @@ type ExecuteScriptOutput<O extends ScriptOutputs | undefined> = {
|
|
|
283
285
|
readonly [K in keyof ScriptOutputPropertiesOf<O>]: ExecuteScriptFieldValue<Extract<ScriptOutputPropertiesOf<O>[K], ScriptOutputType>>;
|
|
284
286
|
} : Record<string, unknown>;
|
|
285
287
|
};
|
|
288
|
+
/**
|
|
289
|
+
* One field an executeScript list-valued input exposes to the script, and
|
|
290
|
+
* what to call it there. `alias` is the script-facing property name
|
|
291
|
+
* (`item.<alias>` inside the script body); `field` is the platform field
|
|
292
|
+
* read from each item of the referenced list.
|
|
293
|
+
*/
|
|
294
|
+
export interface ExecuteScriptFieldMapping {
|
|
295
|
+
readonly alias: string;
|
|
296
|
+
/**
|
|
297
|
+
* `UnsafePlatformId` is a pull-fidelity fallback for a mapping export
|
|
298
|
+
* couldn't resolve to a portable field reference - preserved as-is rather
|
|
299
|
+
* than dropped, mirroring the same escape hatch used for a field
|
|
300
|
+
* assignment export can't reconstruct.
|
|
301
|
+
*/
|
|
302
|
+
readonly field: FieldRef | UnsafePlatformId;
|
|
303
|
+
}
|
|
304
|
+
declare const EXECUTE_SCRIPT_LIST_INPUT_MARKER: "__edkExecuteScriptListInput";
|
|
305
|
+
/** @internal — used by build.ts's fluent `.executeScript()` typing; not part of the public surface. */
|
|
306
|
+
export interface ExecuteScriptListInputToken {
|
|
307
|
+
readonly [EXECUTE_SCRIPT_LIST_INPUT_MARKER]: true;
|
|
308
|
+
readonly value: ValueOrRef<unknown>;
|
|
309
|
+
readonly fields: readonly ExecuteScriptFieldMapping[];
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Wrap a list-valued executeScript input (e.g. a prior task's `.records`)
|
|
313
|
+
* with the field mappings the script can read off each item - which fields,
|
|
314
|
+
* and under what alias. Only meaningful for a list-shaped input; a scalar
|
|
315
|
+
* input has no per-item fields to map.
|
|
316
|
+
*/
|
|
317
|
+
export declare function withFieldMappings(value: ValueOrRef<unknown>, fields: readonly ExecuteScriptFieldMapping[]): ExecuteScriptListInputToken;
|
|
286
318
|
export interface ExecuteScriptOptions<O extends ScriptOutputs | undefined = undefined> {
|
|
287
319
|
/**
|
|
288
320
|
* A FUNCTION whose body ships as the platform script (v3):
|
|
@@ -294,9 +326,17 @@ export interface ExecuteScriptOptions<O extends ScriptOutputs | undefined = unde
|
|
|
294
326
|
* Automation authoring uses fluent `.executeScript(name, {…})` at both the
|
|
295
327
|
* top level and inside operator-body builders. This low-level factory remains
|
|
296
328
|
* an internal wire helper.
|
|
329
|
+
*
|
|
330
|
+
* Instead of a function, `scriptFile("./scripts/x.js")` references a plain
|
|
331
|
+
* JavaScript file holding the script body verbatim (pulled automations
|
|
332
|
+
* print this form).
|
|
333
|
+
*/
|
|
334
|
+
readonly code: ScriptCodeFn<Record<string, unknown>, Record<string, unknown>> | ScriptFile;
|
|
335
|
+
/**
|
|
336
|
+
* A list-valued input can carry {@link withFieldMappings} to declare which
|
|
337
|
+
* fields of each list item the script can read, and under what alias.
|
|
297
338
|
*/
|
|
298
|
-
readonly
|
|
299
|
-
readonly inputs?: Record<string, ValueOrRef<unknown>>;
|
|
339
|
+
readonly inputs?: Record<string, ValueOrRef<unknown> | ExecuteScriptListInputToken>;
|
|
300
340
|
/**
|
|
301
341
|
* Output schema: property name → `"text" | "integer" | "number" |
|
|
302
342
|
* "decimal" | "boolean" | "object"`, or `{ name, properties }` when the
|
|
@@ -511,10 +551,6 @@ export interface NotificationOptions {
|
|
|
511
551
|
readonly notifyWatchers?: boolean;
|
|
512
552
|
}
|
|
513
553
|
export declare function notification(opts: NotificationOptions): ActionDef<Empty>;
|
|
514
|
-
export interface FilterActionOptions {
|
|
515
|
-
readonly condition: Filter;
|
|
516
|
-
}
|
|
517
|
-
export declare function filterAction(opts: FilterActionOptions): ActionDef<Empty>;
|
|
518
554
|
export interface AssignUserOptions {
|
|
519
555
|
readonly field: FieldRef;
|
|
520
556
|
readonly userId: string;
|
|
@@ -637,8 +673,8 @@ export type CalculationExpression = string | Ref<unknown> | Expr<ExprType, ExprC
|
|
|
637
673
|
/** Relationship rows included when a calculation traverses related records. */
|
|
638
674
|
export interface CalculationValueOptions<Expression extends CalculationExpression = CalculationExpression> {
|
|
639
675
|
readonly expression: Expression;
|
|
640
|
-
/**
|
|
641
|
-
readonly id?:
|
|
676
|
+
/** Platform-managed; calculation entry IDs cannot be authored. */
|
|
677
|
+
readonly id?: never;
|
|
642
678
|
/** Override the task-level record context for this value. */
|
|
643
679
|
readonly record?: ValueOrRef<string>;
|
|
644
680
|
/** Override the task-level relationship inclusion for this value. */
|
|
@@ -647,8 +683,8 @@ export interface CalculationValueOptions<Expression extends CalculationExpressio
|
|
|
647
683
|
export type CalculationValueInput = CalculationExpression | CalculationValueOptions;
|
|
648
684
|
export type CalculationValues = Readonly<Record<string, CalculationValueInput>>;
|
|
649
685
|
export interface CalculationEntry<Name extends string = string, Expression extends CalculationExpression = CalculationExpression> {
|
|
650
|
-
/**
|
|
651
|
-
readonly id?:
|
|
686
|
+
/** Platform-managed; calculation entry IDs cannot be authored. */
|
|
687
|
+
readonly id?: never;
|
|
652
688
|
readonly name: Name;
|
|
653
689
|
/**
|
|
654
690
|
* Prefer a typed calc expression. Raw strings and refs remain supported for
|