@elementumai/edk 0.9.6 → 0.9.9
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 +34 -3
- package/dist-sdk/src/catalog/factories.d.ts +26 -6
- package/dist-sdk/src/catalog/factories.js +41 -6
- package/dist-sdk/src/catalog/from-authoring.js +27 -33
- package/dist-sdk/src/catalog/index.d.ts +2 -2
- package/dist-sdk/src/catalog/index.js +2 -2
- package/dist-sdk/src/catalog/org.js +93 -42
- package/dist-sdk/src/catalog/token.js +10 -0
- package/dist-sdk/src/catalog/types.d.ts +42 -3
- package/dist-sdk/src/catalog/types.js +5 -0
- package/dist-sdk/src/core/index.d.ts +2 -2
- package/dist-sdk/src/core/index.js +1 -1
- package/dist-sdk/src/core/platform-id.d.ts +2 -0
- package/dist-sdk/src/core/platform-id.js +4 -0
- package/dist-sdk/src/core/system-fields.d.ts +18 -0
- package/dist-sdk/src/core/system-fields.js +21 -0
- package/dist-sdk/src/core/triggers/on-demand.d.ts +27 -24
- package/dist-sdk/src/core/triggers/on-demand.js +33 -12
- package/dist-sdk/src/core/types/app.d.ts +14 -9
- package/dist-sdk/src/core/types/aspect-category.d.ts +1 -0
- package/dist-sdk/src/core/types/aspect-category.js +1 -0
- package/dist-sdk/src/core/types/platform.d.ts +1 -1
- package/dist-sdk/src/engine/build/context.d.ts +24 -8
- package/dist-sdk/src/engine/build/source-context.d.ts +14 -17
- package/dist-sdk/src/engine/build/source-context.js +1 -1
- package/dist-sdk/src/engine/pull/context.d.ts +18 -0
- package/dist-sdk/src/engine/pull/org.d.ts +4 -0
- package/dist-sdk/src/engine/pull/org.js +17 -2
- package/dist-sdk/src/engine/pull/procedure-refs.d.ts +16 -0
- package/dist-sdk/src/engine/pull/procedure-refs.js +69 -0
- package/dist-sdk/src/engine/pull/ref-only.d.ts +14 -0
- package/dist-sdk/src/engine/pull/ref-only.js +35 -2
- package/dist-sdk/src/engine/tf/expr.js +1 -1
- package/dist-sdk/src/engine/workspace/authoring-layout.d.ts +15 -0
- package/dist-sdk/src/engine/workspace/authoring-layout.js +33 -1
- package/dist-sdk/src/engine/workspace/loader.d.ts +40 -0
- package/dist-sdk/src/engine/workspace/loader.js +328 -0
- package/dist-sdk/src/entities/access-policy/from-tf.d.ts +4 -0
- package/dist-sdk/src/entities/access-policy/from-tf.js +24 -4
- package/dist-sdk/src/entities/access-policy/to-tf.d.ts +7 -0
- package/dist-sdk/src/entities/access-policy/to-tf.js +11 -3
- package/dist-sdk/src/entities/agent/build.d.ts +54 -8
- package/dist-sdk/src/entities/agent/build.js +36 -1
- package/dist-sdk/src/entities/agent/deserializer/print-agent-v2.js +144 -3
- package/dist-sdk/src/entities/agent/from-tf.d.ts +7 -6
- package/dist-sdk/src/entities/agent/from-tf.js +176 -5
- package/dist-sdk/src/entities/agent/index.d.ts +2 -2
- package/dist-sdk/src/entities/agent/index.js +1 -1
- package/dist-sdk/src/entities/agent/module.js +1 -0
- package/dist-sdk/src/entities/agent/to-tf.d.ts +5 -4
- package/dist-sdk/src/entities/agent/to-tf.js +186 -11
- package/dist-sdk/src/entities/agent/tools.d.ts +16 -5
- package/dist-sdk/src/entities/agent/tools.js +13 -1
- package/dist-sdk/src/entities/agent-tool/from-tf.d.ts +16 -0
- package/dist-sdk/src/entities/agent-tool/from-tf.js +39 -6
- package/dist-sdk/src/entities/agent-tool/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/agent-tool/to-tf.js +12 -12
- package/dist-sdk/src/entities/agent-tool/types.js +1 -0
- package/dist-sdk/src/entities/app/build.d.ts +44 -24
- package/dist-sdk/src/entities/app/build.js +18 -8
- package/dist-sdk/src/entities/app/deserializer/normalize.d.ts +15 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.d.ts +45 -0
- package/dist-sdk/src/entities/app/display-blocks-to-layout.js +98 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.d.ts +55 -0
- package/dist-sdk/src/entities/app/display-blocks-to-record-create-form.js +99 -0
- package/dist-sdk/src/entities/app/from-tf.js +79 -14
- package/dist-sdk/src/entities/app/index.d.ts +3 -2
- package/dist-sdk/src/entities/app/index.js +2 -1
- package/dist-sdk/src/entities/app/to-tf.js +30 -6
- package/dist-sdk/src/entities/automation/build.d.ts +37 -18
- package/dist-sdk/src/entities/automation/build.js +121 -12
- package/dist-sdk/src/entities/automation/catalog-render.js +5 -2
- package/dist-sdk/src/entities/automation/deserializer/ast.d.ts +8 -10
- package/dist-sdk/src/entities/automation/deserializer/print-automation.d.ts +2 -0
- package/dist-sdk/src/entities/automation/deserializer/print-automation.js +103 -20
- package/dist-sdk/src/entities/automation/from-tf.d.ts +10 -1
- package/dist-sdk/src/entities/automation/from-tf.js +1165 -91
- package/dist-sdk/src/entities/automation/index.d.ts +1 -1
- package/dist-sdk/src/entities/automation/module.js +15 -5
- package/dist-sdk/src/entities/automation/operators.d.ts +2 -2
- package/dist-sdk/src/entities/automation/operators.js +1 -0
- package/dist-sdk/src/entities/automation/output-field-types.d.ts +17 -0
- package/dist-sdk/src/entities/automation/output-field-types.js +45 -0
- package/dist-sdk/src/entities/automation/output-key-wire-name.d.ts +20 -4
- package/dist-sdk/src/entities/automation/output-key-wire-name.js +33 -6
- package/dist-sdk/src/entities/automation/script-code.d.ts +1 -1
- package/dist-sdk/src/entities/automation/script-code.js +168 -36
- package/dist-sdk/src/entities/automation/task-label.d.ts +2 -0
- package/dist-sdk/src/entities/automation/task-label.js +18 -0
- package/dist-sdk/src/entities/automation/tasks.d.ts +159 -45
- package/dist-sdk/src/entities/automation/tasks.js +60 -47
- package/dist-sdk/src/entities/automation/to-tf.d.ts +7 -1
- package/dist-sdk/src/entities/automation/to-tf.js +816 -87
- package/dist-sdk/src/entities/automation/triggers.d.ts +14 -5
- package/dist-sdk/src/entities/automation/triggers.js +1 -1
- package/dist-sdk/src/entities/automation/value-ref-tf.d.ts +78 -0
- package/dist-sdk/src/entities/automation/value-ref-tf.js +193 -0
- package/dist-sdk/src/entities/dashboard/from-tf.js +1 -1
- package/dist-sdk/src/entities/dynamic-layout/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/dynamic-layout/to-tf.js +1 -1
- package/dist-sdk/src/entities/element/build.d.ts +30 -7
- package/dist-sdk/src/entities/element/build.js +7 -3
- package/dist-sdk/src/entities/element/from-tf.js +7 -3
- package/dist-sdk/src/entities/element/index.d.ts +3 -2
- package/dist-sdk/src/entities/element/index.js +3 -2
- package/dist-sdk/src/entities/element/to-tf.js +49 -8
- package/dist-sdk/src/entities/field/build.d.ts +94 -3
- package/dist-sdk/src/entities/field/build.js +82 -3
- package/dist-sdk/src/entities/field/from-tf.d.ts +6 -0
- package/dist-sdk/src/entities/field/from-tf.js +104 -1
- package/dist-sdk/src/entities/field/locals.js +6 -7
- package/dist-sdk/src/entities/field/module.js +1 -0
- package/dist-sdk/src/entities/field/options.d.ts +2 -0
- package/dist-sdk/src/entities/field/options.js +12 -2
- package/dist-sdk/src/entities/field/record-shape.d.ts +12 -15
- package/dist-sdk/src/entities/field/to-tf.d.ts +13 -3
- package/dist-sdk/src/entities/field/to-tf.js +191 -56
- package/dist-sdk/src/entities/field/types.js +2 -0
- package/dist-sdk/src/entities/org/category-ref.d.ts +5 -0
- package/dist-sdk/src/entities/org/category-ref.js +12 -0
- package/dist-sdk/src/entities/record-create-form/from-tf.js +3 -3
- package/dist-sdk/src/entities/record-create-form/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/record-create-form/to-tf.js +18 -13
- package/dist-sdk/src/entities/relationship/from-tf.js +100 -7
- package/dist-sdk/src/entities/role/from-tf.js +10 -4
- package/dist-sdk/src/entities/search-table/build.d.ts +1 -1
- package/dist-sdk/src/entities/search-table/from-tf.d.ts +1 -0
- package/dist-sdk/src/entities/search-table/from-tf.js +6 -0
- package/dist-sdk/src/entities/search-table/printer.js +3 -1
- package/dist-sdk/src/entities/search-table/to-tf.js +3 -3
- package/dist-sdk/src/entities/search-table/types.js +1 -0
- package/dist-sdk/src/entities/service-account/from-tf.js +10 -4
- package/dist-sdk/src/entities/service-account/to-tf.d.ts +2 -1
- package/dist-sdk/src/entities/service-account/to-tf.js +7 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.d.ts +9 -0
- package/dist-sdk/src/entities/shared/aspect-target-from-tf.js +39 -0
- package/dist-sdk/src/entities/shared/filters/ast.d.ts +24 -1
- package/dist-sdk/src/entities/shared/filters/ast.js +4 -0
- package/dist-sdk/src/entities/shared/filters/tf-codec.d.ts +13 -2
- package/dist-sdk/src/entities/shared/filters/tf-codec.js +14 -8
- package/dist-sdk/src/entities/shared/handle-description.d.ts +12 -0
- package/dist-sdk/src/entities/shared/handle-description.js +20 -0
- package/dist-sdk/src/entities/shared/tool-field-ref.d.ts +5 -3
- package/dist-sdk/src/entities/shared/tool-field-ref.js +11 -16
- package/dist-sdk/src/entities/shared/types/common.d.ts +7 -5
- package/dist-sdk/src/entities/shared/types/field-types.d.ts +6 -1
- package/dist-sdk/src/entities/shared/types/field-types.js +5 -8
- package/dist-sdk/src/entities/shared/types/platform.d.ts +15 -2
- package/dist-sdk/src/entities/skill/build.d.ts +51 -2
- package/dist-sdk/src/entities/skill/build.js +65 -8
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.d.ts +1 -1
- package/dist-sdk/src/entities/skill/deserializer/print-skill-v2.js +79 -18
- package/dist-sdk/src/entities/skill/from-tf.d.ts +11 -0
- package/dist-sdk/src/entities/skill/from-tf.js +47 -5
- package/dist-sdk/src/entities/skill/index.d.ts +1 -1
- package/dist-sdk/src/entities/skill/index.js +1 -1
- package/dist-sdk/src/entities/skill/input-coverage.d.ts +89 -0
- package/dist-sdk/src/entities/skill/input-coverage.js +327 -0
- package/dist-sdk/src/entities/skill/module.js +2 -0
- package/dist-sdk/src/entities/skill/to-tf.d.ts +9 -25
- package/dist-sdk/src/entities/skill/to-tf.js +29 -40
- package/dist-sdk/src/entities/skill/tools.d.ts +12 -2
- package/dist-sdk/src/entities/skill/tools.js +3 -6
- package/dist-sdk/src/entities/skill-tool/from-tf.d.ts +19 -0
- package/dist-sdk/src/entities/skill-tool/from-tf.js +50 -14
- package/dist-sdk/src/entities/skill-tool/to-tf.d.ts +9 -7
- package/dist-sdk/src/entities/skill-tool/to-tf.js +29 -23
- package/dist-sdk/src/entities/table/to-tf.js +21 -5
- package/dist-sdk/src/entities/task/to-tf.js +3 -2
- package/dist-sdk/src/entities/view/from-tf.js +36 -10
- package/dist-sdk/src/entities/view/to-tf.d.ts +2 -0
- package/dist-sdk/src/entities/view/to-tf.js +49 -30
- package/dist-sdk/src/entities/visual-flow/from-tf.js +6 -2
- package/dist-sdk/src/entities/widget/from-tf.js +2 -2
- package/dist-sdk/src/entities/widget/to-tf.d.ts +1 -0
- package/dist-sdk/src/entities/widget/to-tf.js +52 -23
- package/dist-sdk/src/graph/index.d.ts +19 -1
- package/dist-sdk/src/graph/index.js +20 -0
- package/dist-sdk/src/graph/types.d.ts +22 -0
- package/package.json +11 -5
|
@@ -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 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 NotificationOptions, type PostCommentOptions, type PostTeamsMessageOptions, type ProcedureOptions, type ReadFileDataSource, type ReadFileOptions, type RecordFieldLockingOptions, type RecordId, type RecordReference, type RecordSearchOptions, type RecordSearchOutput, type RelateRecordsOptions, type RunAutomationInput, type RunAutomationOptions, type SaveAttachmentOptions, type SendEmailOptions, type SendSurveyOptions, type SetVariableOptions, type TableRecordsSearchOptions, type TableRecordsSearchOutput, type UnzipOptions, type UpdateFieldOptions, type UserSearchOptions, type VariableAssign, type VariableDecl } from "./tasks.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
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";
|
|
@@ -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 { printAutomationV2 } from "./deserializer/print-automation.js";
|
|
4
|
+
import { preserveAuthoredAutomationRevision, 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";
|
|
@@ -103,6 +103,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
103
103
|
const items = [];
|
|
104
104
|
const skipped = [];
|
|
105
105
|
const diagnostics = [];
|
|
106
|
+
const adoptionAddressAliases = [];
|
|
106
107
|
for (const autoBlock of ownBlocks) {
|
|
107
108
|
const autoLabel = autoBlock.label ?? "";
|
|
108
109
|
const doc = { blocks: [...stream.allBlocks] };
|
|
@@ -111,12 +112,13 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
111
112
|
// (one owned-address walk) relative to from-tf.
|
|
112
113
|
registerForeignObjectIdDeps(doc, autoLabel, ctx);
|
|
113
114
|
try {
|
|
114
|
-
const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames);
|
|
115
|
+
const extracted = automationFromTf(doc, autoLabel, ctx.appRefName, ctx.foreignFieldRefsById, ctx.foreignFieldRefsByDataAddress, ctx.foreignTableRefsById, ctx.picklistOptionLabelById, ctx.fieldNamesByOwnerRefName, ctx.foreignAppRefNames, ctx.foreignElementRefNames, ctx.procedureKeysByDiscriminator);
|
|
115
116
|
// Keep automationFromTf's label-derived refName — agent/skill tools store
|
|
116
117
|
// the same scopedLabelToBagKey as automationKey. Pushing bare AST (name
|
|
117
118
|
// only) made missing-automation diagnostics false-positive on every real
|
|
118
119
|
// extract (issue #395 / PR #417 review).
|
|
119
120
|
items.push({ ...extracted.ast, refName: extracted.refName });
|
|
121
|
+
adoptionAddressAliases.push(...extracted.adoptionAddressAliases);
|
|
120
122
|
}
|
|
121
123
|
catch (err) {
|
|
122
124
|
// Report the automation's FULL graph (trigger/tasks/branches/publish),
|
|
@@ -128,7 +130,7 @@ function extractAutomations(ownBlocks, stream, ctx) {
|
|
|
128
130
|
diagnostics.push(`${autoLabel}: ${err instanceof Error ? err.message : String(err)}`);
|
|
129
131
|
}
|
|
130
132
|
}
|
|
131
|
-
return { items, skipped, diagnostics };
|
|
133
|
+
return { items, skipped, diagnostics, adoptionAddressAliases };
|
|
132
134
|
}
|
|
133
135
|
export const automationModule = {
|
|
134
136
|
kind: "automation",
|
|
@@ -155,7 +157,7 @@ export const automationModule = {
|
|
|
155
157
|
participates: true,
|
|
156
158
|
resourceType: AUTOMATION_RESOURCE_TYPE,
|
|
157
159
|
lookupAttr: "name",
|
|
158
|
-
referencedByBuild:
|
|
160
|
+
referencedByBuild: true,
|
|
159
161
|
referenceLookups: [
|
|
160
162
|
{ strategy: "owned", ownerKinds: ["app", "element"], memberAttr: "name" },
|
|
161
163
|
{ strategy: "nameOnlyMetadata", ownerKind: "automation" },
|
|
@@ -192,6 +194,7 @@ export const automationModule = {
|
|
|
192
194
|
}),
|
|
193
195
|
};
|
|
194
196
|
},
|
|
197
|
+
mergePulledSource: preserveAuthoredAutomationRevision,
|
|
195
198
|
toTf: (entity, ctx) => automationToTf(entity, {
|
|
196
199
|
appRefName: ctx.appRefName,
|
|
197
200
|
appTfLabel: ctx.appTfLabel,
|
|
@@ -201,14 +204,21 @@ export const automationModule = {
|
|
|
201
204
|
fieldNames: ctx.fieldNames ?? new Map(),
|
|
202
205
|
fieldMetadata: ctx.fieldMetadata ?? new Map(),
|
|
203
206
|
...(ctx.fieldNamesByAppRefName !== undefined ? { fieldNamesByAppRefName: ctx.fieldNamesByAppRefName } : {}),
|
|
207
|
+
...(ctx.allowUnknownPicklistOptions === true ? { allowUnknownPicklistOptions: true } : {}),
|
|
204
208
|
orgRefs: ctx.orgRefs,
|
|
205
209
|
workspaceAspects: ctx.workspaceAspects,
|
|
206
210
|
localsAttrs: ctx.localsAttrs,
|
|
207
211
|
serviceAccounts: ctx.streamRootEntity?.payload?.serviceAccounts,
|
|
208
|
-
activeAutomationRefNames: new Set((ctx.siblingEntities ?? [])
|
|
212
|
+
activeAutomationRefNames: ctx.activeAutomationRefNames ?? new Set((ctx.siblingEntities ?? [])
|
|
209
213
|
.filter((sibling) => sibling.kind === "automation" &&
|
|
210
214
|
sibling.payload?.status === "ACTIVE")
|
|
211
215
|
.map((sibling) => sibling.refName)),
|
|
216
|
+
automationNamesByRefName: new Map((ctx.siblingEntities ?? [])
|
|
217
|
+
.filter((sibling) => sibling.kind === "automation")
|
|
218
|
+
.flatMap((sibling) => {
|
|
219
|
+
const name = sibling.payload?.name;
|
|
220
|
+
return typeof name === "string" && name !== "" ? [[sibling.refName, name]] : [];
|
|
221
|
+
})),
|
|
212
222
|
}),
|
|
213
223
|
},
|
|
214
224
|
catalog: {
|
|
@@ -26,7 +26,7 @@ export interface ForEachConfig<TTrigger, TActions extends Record<string, unknown
|
|
|
26
26
|
}
|
|
27
27
|
export declare function forEach<TTrigger, TActions extends Record<string, unknown>, TItem, TVars extends Record<string, unknown> = NoVariables>(_ctx: Context<TTrigger, TActions, TVars>, config: ForEachConfig<TTrigger, TActions, TItem, TVars>): ActionDef<Empty>;
|
|
28
28
|
export interface SwitchCase<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = NoVariables> {
|
|
29
|
-
readonly label
|
|
29
|
+
readonly label?: string;
|
|
30
30
|
/**
|
|
31
31
|
* Condition for this case, built with the `filter.*` DSL
|
|
32
32
|
* (`@elementumai/edk/automations`). Omit for a condition-free fallthrough
|
|
@@ -66,7 +66,7 @@ export interface SwitchConfig<TTrigger, TActions extends Record<string, unknown>
|
|
|
66
66
|
}
|
|
67
67
|
export declare function switchAction<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = NoVariables>(_ctx: Context<TTrigger, TActions, TVars>, config: SwitchConfig<TTrigger, TActions, TVars>): ActionDef<Empty>;
|
|
68
68
|
export interface ForkJoinBranch<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = NoVariables> {
|
|
69
|
-
readonly label
|
|
69
|
+
readonly label?: string;
|
|
70
70
|
readonly actions: (innerCtx: Context<TTrigger, TActions, TVars>) => readonly NestedActionEntry[];
|
|
71
71
|
}
|
|
72
72
|
export interface ForkJoinConfig<TTrigger, TActions extends Record<string, unknown>, TVars extends Record<string, unknown> = NoVariables> {
|
|
@@ -25,6 +25,7 @@ export function switchAction(_ctx, config) {
|
|
|
25
25
|
const defaultFilterMode = isPlainFn ? undefined : config.defaultActions.defaultFilterMode;
|
|
26
26
|
operatorChildren.push({
|
|
27
27
|
label: null,
|
|
28
|
+
isDefault: true,
|
|
28
29
|
...(defaultLabel !== undefined ? { defaultLabel } : {}),
|
|
29
30
|
...(defaultFilterMode !== undefined ? { defaultFilterMode } : {}),
|
|
30
31
|
tasks: actionsFn(innerCtx),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map an executeScript task's `output_schema` (the platform's tagged
|
|
3
|
+
* `{ object: { properties: [{ bool: { name } }, ...] } }` shape) to the
|
|
4
|
+
* workflow field type each declared property resolves to.
|
|
5
|
+
*
|
|
6
|
+
* Used by `to-tf.ts` (forward: building the `elementum_workflow_publish`
|
|
7
|
+
* outputs' `fieldType` envelope) and `build.ts` (authoring-time: stamping
|
|
8
|
+
* `OutputPropertyRef.valueType` on the catalog ref) — kept dependency-free
|
|
9
|
+
* like `output-key-wire-name.ts` so importing it from either side can never
|
|
10
|
+
* introduce a cycle.
|
|
11
|
+
*/
|
|
12
|
+
/** Map executeScript output_schema properties to refs keys (`result.<name>`). */
|
|
13
|
+
export declare function outputFieldTypesFromScriptSchema(schema: unknown): Map<string, {
|
|
14
|
+
fieldType: string;
|
|
15
|
+
multiple: boolean;
|
|
16
|
+
kind: string;
|
|
17
|
+
}> | undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map an executeScript task's `output_schema` (the platform's tagged
|
|
3
|
+
* `{ object: { properties: [{ bool: { name } }, ...] } }` shape) to the
|
|
4
|
+
* workflow field type each declared property resolves to.
|
|
5
|
+
*
|
|
6
|
+
* Used by `to-tf.ts` (forward: building the `elementum_workflow_publish`
|
|
7
|
+
* outputs' `fieldType` envelope) and `build.ts` (authoring-time: stamping
|
|
8
|
+
* `OutputPropertyRef.valueType` on the catalog ref) — kept dependency-free
|
|
9
|
+
* like `output-key-wire-name.ts` so importing it from either side can never
|
|
10
|
+
* introduce a cycle.
|
|
11
|
+
*/
|
|
12
|
+
function isObject(value) {
|
|
13
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
/** Map executeScript output_schema properties to refs keys (`result.<name>`). */
|
|
16
|
+
export function outputFieldTypesFromScriptSchema(schema) {
|
|
17
|
+
if (!isObject(schema))
|
|
18
|
+
return undefined;
|
|
19
|
+
const objectNode = isObject(schema.object) ? schema.object : schema;
|
|
20
|
+
const properties = objectNode.properties;
|
|
21
|
+
if (!Array.isArray(properties))
|
|
22
|
+
return undefined;
|
|
23
|
+
const out = new Map();
|
|
24
|
+
for (const property of properties) {
|
|
25
|
+
if (!isObject(property))
|
|
26
|
+
continue;
|
|
27
|
+
for (const [kind, body] of Object.entries(property)) {
|
|
28
|
+
if (!isObject(body) || typeof body.name !== "string")
|
|
29
|
+
continue;
|
|
30
|
+
const fieldType = kind === "bool" ? "BOOLEAN"
|
|
31
|
+
// Platform publish/ref envelopes use NUMBER for whole numbers, not INTEGER
|
|
32
|
+
// (Sanofi demoClassifyHacat: authored "integer" → state fieldType NUMBER).
|
|
33
|
+
: kind === "integer" ? "NUMBER"
|
|
34
|
+
: kind === "number" ? "DECIMAL"
|
|
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 });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return out.size > 0 ? out : undefined;
|
|
45
|
+
}
|
|
@@ -7,13 +7,29 @@
|
|
|
7
7
|
* directly against a live-deployed task's own `refs` map (Preston High
|
|
8
8
|
* integration run, item 235) — that map is Title-Case (`Reason`, `Response`,
|
|
9
9
|
* `Success`), so the wire name here must match that casing exactly, not the
|
|
10
|
-
* lowercase property name.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* casing is UNVERIFIED and may have the same bug.
|
|
10
|
+
* lowercase property name. aiSummarize/aiTransform share the same Title-Case
|
|
11
|
+
* refs map (`Response`, `Success`) — confirmed live via apply failures when
|
|
12
|
+
* downstream tasks referenced `.output` with the old lowercase wire name.
|
|
14
13
|
*
|
|
15
14
|
* Used by `build.ts` (forward: `output` → wire name) and `from-tf.ts`
|
|
16
15
|
* (inverse: wire name → `output`) — kept dependency-free so importing it from
|
|
17
16
|
* either side can never introduce a cycle.
|
|
18
17
|
*/
|
|
19
18
|
export declare const OUTPUT_KEY_WIRE_NAME: Readonly<Record<string, string>>;
|
|
19
|
+
/**
|
|
20
|
+
* apiRequest task outputs in authoring use camelCase segments (`statusCode`,
|
|
21
|
+
* `file.content`, …) but the provider refs map uses display labels — confirmed
|
|
22
|
+
* live on Sanofi saveAttachment (FILE) and Deloitte demoapptwo (CUSTOM).
|
|
23
|
+
*/
|
|
24
|
+
export declare const API_TASK_REF_WIRE_NAMES: Readonly<Record<string, string>>;
|
|
25
|
+
/** Inverse of {@link API_TASK_REF_WIRE_NAMES} for export jsonencode envelopes. */
|
|
26
|
+
export declare const API_TASK_REF_AUTHORING_NAMES: Readonly<Record<string, string>>;
|
|
27
|
+
/**
|
|
28
|
+
* Resolve a single `elementum_api_task` refs[] wire label (e.g. "File",
|
|
29
|
+
* "Content Type") to its authoring path segments (e.g. ["file"], ["file",
|
|
30
|
+
* "contentType"]) via {@link API_TASK_REF_AUTHORING_NAMES} — some authoring
|
|
31
|
+
* names are dotted (`file.content`) since they nest under the `file` output.
|
|
32
|
+
* Returns undefined for a wire label with no known authoring counterpart so
|
|
33
|
+
* callers can fall back to the generic segment mapping.
|
|
34
|
+
*/
|
|
35
|
+
export declare function apiTaskRefAuthoringPath(wireSegment: string): string[] | undefined;
|
|
@@ -7,18 +7,45 @@
|
|
|
7
7
|
* directly against a live-deployed task's own `refs` map (Preston High
|
|
8
8
|
* integration run, item 235) — that map is Title-Case (`Reason`, `Response`,
|
|
9
9
|
* `Success`), so the wire name here must match that casing exactly, not the
|
|
10
|
-
* lowercase property name.
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* casing is UNVERIFIED and may have the same bug.
|
|
10
|
+
* lowercase property name. aiSummarize/aiTransform share the same Title-Case
|
|
11
|
+
* refs map (`Response`, `Success`) — confirmed live via apply failures when
|
|
12
|
+
* downstream tasks referenced `.output` with the old lowercase wire name.
|
|
14
13
|
*
|
|
15
14
|
* Used by `build.ts` (forward: `output` → wire name) and `from-tf.ts`
|
|
16
15
|
* (inverse: wire name → `output`) — kept dependency-free so importing it from
|
|
17
16
|
* either side can never introduce a cycle.
|
|
18
17
|
*/
|
|
19
18
|
export const OUTPUT_KEY_WIRE_NAME = {
|
|
20
|
-
aiSummarize: "
|
|
21
|
-
aiTransform: "
|
|
19
|
+
aiSummarize: "Response",
|
|
20
|
+
aiTransform: "Response",
|
|
22
21
|
aiClassify: "Response",
|
|
23
22
|
documentModel: "text",
|
|
24
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* apiRequest task outputs in authoring use camelCase segments (`statusCode`,
|
|
26
|
+
* `file.content`, …) but the provider refs map uses display labels — confirmed
|
|
27
|
+
* live on Sanofi saveAttachment (FILE) and Deloitte demoapptwo (CUSTOM).
|
|
28
|
+
*/
|
|
29
|
+
export const API_TASK_REF_WIRE_NAMES = {
|
|
30
|
+
statusCode: "API Response Status Code",
|
|
31
|
+
textResponse: "API Response (text)",
|
|
32
|
+
response: "Response",
|
|
33
|
+
file: "File",
|
|
34
|
+
"file.content": "Content",
|
|
35
|
+
"file.contentType": "Content Type",
|
|
36
|
+
"file.name": "Name",
|
|
37
|
+
};
|
|
38
|
+
/** Inverse of {@link API_TASK_REF_WIRE_NAMES} for export jsonencode envelopes. */
|
|
39
|
+
export const API_TASK_REF_AUTHORING_NAMES = Object.fromEntries(Object.entries(API_TASK_REF_WIRE_NAMES).map(([authoring, wire]) => [wire, authoring]));
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a single `elementum_api_task` refs[] wire label (e.g. "File",
|
|
42
|
+
* "Content Type") to its authoring path segments (e.g. ["file"], ["file",
|
|
43
|
+
* "contentType"]) via {@link API_TASK_REF_AUTHORING_NAMES} — some authoring
|
|
44
|
+
* names are dotted (`file.content`) since they nest under the `file` output.
|
|
45
|
+
* Returns undefined for a wire label with no known authoring counterpart so
|
|
46
|
+
* callers can fall back to the generic segment mapping.
|
|
47
|
+
*/
|
|
48
|
+
export function apiTaskRefAuthoringPath(wireSegment) {
|
|
49
|
+
const authoring = API_TASK_REF_AUTHORING_NAMES[wireSegment];
|
|
50
|
+
return authoring !== undefined ? authoring.split(".") : undefined;
|
|
51
|
+
}
|
|
@@ -42,7 +42,7 @@ export declare function freeIdentifiers(body: string, params: ReadonlySet<string
|
|
|
42
42
|
/**
|
|
43
43
|
* Look up task `name`'s `code:` body verbatim from the automation file
|
|
44
44
|
* `elementum build` is currently importing (tracked engine-side by
|
|
45
|
-
* `withSourceText` around each own-file-child's
|
|
45
|
+
* `withSourceText` around each own-file-child's import —
|
|
46
46
|
* `src/engine/build/build.ts`/`source-context.ts`), or `undefined` if
|
|
47
47
|
* there's no tracked source (not running under `elementum build`, e.g. an
|
|
48
48
|
* automation constructed directly in a test) or the name/shape wasn't found
|
|
@@ -17,24 +17,22 @@
|
|
|
17
17
|
* reference, not the value — on the platform `x` is undefined. A best-effort
|
|
18
18
|
* free-identifier scan throws at def() time on obvious captures (per the
|
|
19
19
|
* tranche decision: best effort, not a guarantee).
|
|
20
|
-
* - WHAT YOU AUTHOR IS
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* PULLED script it's lossy: the platform's exact text stops matching after
|
|
27
|
-
* one `edk build`, producing a spurious plan diff forever.
|
|
20
|
+
* - WHAT YOU AUTHOR IS TYPE-STRIPPED FIRST: Node erases type annotations by
|
|
21
|
+
* overwriting them with spaces, so `Function.prototype.toString()` returns
|
|
22
|
+
* the original spacing but blanks wherever a type used to be. For a
|
|
23
|
+
* HAND-authored script that is usually harmless. For a PULLED script it is
|
|
24
|
+
* lossy: the platform's exact text stops matching after one `edk build`,
|
|
25
|
+
* producing a spurious plan diff forever.
|
|
28
26
|
*
|
|
29
27
|
* `elementum build` avoids that loss for pulled scripts WITHOUT relying on
|
|
30
28
|
* `toString()` at all: `src/engine/build/build.ts` wraps each automation
|
|
31
|
-
* file's
|
|
29
|
+
* file's import with that file's own on-disk text (engine-side,
|
|
32
30
|
* entity-agnostic — `source-context.ts`), and `tryExtractFromCurrentSource`
|
|
33
31
|
* here locates the matching `.executeScript("name", { code: (input) => {...}
|
|
34
32
|
* })` call at any fluent-chain depth by a
|
|
35
33
|
* lightweight source scan — the same string/comment-aware tokenizing already
|
|
36
34
|
* used by {@link inferOutputSchema} — and slices the body's ORIGINAL text directly out
|
|
37
|
-
* of the file, never touching the
|
|
35
|
+
* of the file, never touching the loaded function. `extractScriptBody`
|
|
38
36
|
* (the `toString()` path) remains the fallback for contexts with no tracked
|
|
39
37
|
* source (tests constructing automations directly).
|
|
40
38
|
*/
|
|
@@ -211,6 +209,59 @@ function skipNonCode(src, i) {
|
|
|
211
209
|
}
|
|
212
210
|
return i;
|
|
213
211
|
}
|
|
212
|
+
/**
|
|
213
|
+
* Characters a `/` may follow and still begin a regex literal rather than a
|
|
214
|
+
* division. After an identifier, number, `)` or `]` — or a closing quote — the
|
|
215
|
+
* slash divides.
|
|
216
|
+
*/
|
|
217
|
+
const REGEX_MAY_START_AFTER = /[({[=,:;!?&|+\-*%^~<>]/;
|
|
218
|
+
/**
|
|
219
|
+
* True when the `/` at `i` opens a regex literal, judged by the nearest
|
|
220
|
+
* preceding significant character. Looks BACKWARD so the balancing scans below
|
|
221
|
+
* need not each thread a "previous token" through their branches; it reaches
|
|
222
|
+
* the same verdicts as {@link maskNonCodeForIdentifierScan}'s forward state.
|
|
223
|
+
*/
|
|
224
|
+
function startsRegexLiteralAt(src, i) {
|
|
225
|
+
let k = i - 1;
|
|
226
|
+
while (k >= 0 && /\s/.test(src[k]))
|
|
227
|
+
k -= 1;
|
|
228
|
+
const previous = src[k];
|
|
229
|
+
return previous === undefined || REGEX_MAY_START_AFTER.test(previous);
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Skip a regex literal starting at `src[i] === "/"`; returns the index just
|
|
233
|
+
* past its closing delimiter and flags.
|
|
234
|
+
*
|
|
235
|
+
* Every delimiter inside is pattern text, not code, so the balancing scans
|
|
236
|
+
* must not count it: a pulled body's `.replace(/\([^)]*\)/g, " ")` reads as
|
|
237
|
+
* `(`, `[`, `)`, `]`, `)` and left the `.executeScript(...)` call looking
|
|
238
|
+
* unbalanced — the byte-exact extraction then either missed the call entirely
|
|
239
|
+
* or ran past the function's closing brace and swallowed the following
|
|
240
|
+
* options (live: Sanofi getSuppliers_1's "Shape Final Output").
|
|
241
|
+
*/
|
|
242
|
+
function skipRegexLiteral(src, i) {
|
|
243
|
+
let j = i + 1;
|
|
244
|
+
let inClass = false;
|
|
245
|
+
while (j < src.length) {
|
|
246
|
+
const c = src[j];
|
|
247
|
+
if (c === "\\") {
|
|
248
|
+
j += 2;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
if (c === "[")
|
|
252
|
+
inClass = true;
|
|
253
|
+
else if (c === "]")
|
|
254
|
+
inClass = false;
|
|
255
|
+
else if (c === "/" && !inClass) {
|
|
256
|
+
j += 1;
|
|
257
|
+
while (/[A-Za-z]/.test(src[j] ?? ""))
|
|
258
|
+
j += 1;
|
|
259
|
+
return j;
|
|
260
|
+
}
|
|
261
|
+
j += 1;
|
|
262
|
+
}
|
|
263
|
+
return j;
|
|
264
|
+
}
|
|
214
265
|
/** Skip a string/template starting at `i` (which must be a quote char); returns the index after it. */
|
|
215
266
|
function skipString(src, i) {
|
|
216
267
|
const quote = src[i];
|
|
@@ -346,15 +397,23 @@ function dedent(body) {
|
|
|
346
397
|
export function freeIdentifiers(body, params) {
|
|
347
398
|
const stripped = maskNonCodeForIdentifierScan(body);
|
|
348
399
|
const declared = new Set(params);
|
|
349
|
-
|
|
350
|
-
for (const
|
|
400
|
+
collectLexicalDeclarations(stripped, declared);
|
|
401
|
+
// catch (e) / for (const x of ...) already covered by const/let/var; arrow params inside:
|
|
402
|
+
for (const m of stripped.matchAll(/\(([^)]*)\)\s*=>/g)) {
|
|
351
403
|
for (const id of (m[1] ?? "").matchAll(/[A-Za-z_$][\w$]*/g))
|
|
352
404
|
declared.add(id[0]);
|
|
353
405
|
}
|
|
406
|
+
// Arrow functions may omit parentheses for a single parameter (`row => …`).
|
|
407
|
+
// Without this pass, common callbacks such as `items.map(row => row.value)`
|
|
408
|
+
// are incorrectly reported as closure captures.
|
|
409
|
+
for (const m of stripped.matchAll(/(?:\basync\s+)?([A-Za-z_$][\w$]*)\s*=>/g)) {
|
|
410
|
+
declared.add(m[1]);
|
|
411
|
+
}
|
|
412
|
+
// function / class names AND their formal parameters (nested helpers in
|
|
413
|
+
// pulled scripts are common — Sanofi getSuppliers_1's levenshtein helpers).
|
|
354
414
|
for (const m of stripped.matchAll(/\b(?:function|class)\s+([A-Za-z_$][\w$]*)/g))
|
|
355
415
|
declared.add(m[1]);
|
|
356
|
-
|
|
357
|
-
for (const m of stripped.matchAll(/\(([^)]*)\)\s*=>/g)) {
|
|
416
|
+
for (const m of stripped.matchAll(/\bfunction(?:\s+[A-Za-z_$][\w$]*)?\s*\(([^)]*)\)/g)) {
|
|
358
417
|
for (const id of (m[1] ?? "").matchAll(/[A-Za-z_$][\w$]*/g))
|
|
359
418
|
declared.add(id[0]);
|
|
360
419
|
}
|
|
@@ -379,6 +438,77 @@ export function freeIdentifiers(body, params) {
|
|
|
379
438
|
}
|
|
380
439
|
return [...unknown].sort();
|
|
381
440
|
}
|
|
441
|
+
/**
|
|
442
|
+
* Collect binding names from `const`/`let`/`var` statements, including every
|
|
443
|
+
* declarator in a comma list (`var prev = [], cur = [], i, j`). The previous
|
|
444
|
+
* `[^=;]+` regex stopped at the first `=` and only recorded the leading
|
|
445
|
+
* name — false-positive "closure captures" on every later declarator.
|
|
446
|
+
*
|
|
447
|
+
* Initializers can contain commas (arrays, calls, objects), so this walks
|
|
448
|
+
* depth-aware from the keyword to the terminating `;` (or EOF).
|
|
449
|
+
*/
|
|
450
|
+
function collectLexicalDeclarations(source, declared) {
|
|
451
|
+
const keywordRe = /\b(?:const|let|var)\b/g;
|
|
452
|
+
let km;
|
|
453
|
+
while ((km = keywordRe.exec(source)) !== null) {
|
|
454
|
+
let i = km.index + km[0].length;
|
|
455
|
+
while (i < source.length) {
|
|
456
|
+
while (i < source.length && /\s/.test(source[i]))
|
|
457
|
+
i += 1;
|
|
458
|
+
if (i >= source.length || source[i] === ";")
|
|
459
|
+
break;
|
|
460
|
+
// Binding pattern: identifier, or a destructuring list whose identifiers
|
|
461
|
+
// we collect wholesale (same best-effort as before).
|
|
462
|
+
if (source[i] === "{" || source[i] === "[") {
|
|
463
|
+
const open = source[i];
|
|
464
|
+
const close = open === "{" ? "}" : "]";
|
|
465
|
+
let depth = 1;
|
|
466
|
+
const start = i;
|
|
467
|
+
i += 1;
|
|
468
|
+
while (i < source.length && depth > 0) {
|
|
469
|
+
const c = source[i];
|
|
470
|
+
if (c === open)
|
|
471
|
+
depth += 1;
|
|
472
|
+
else if (c === close)
|
|
473
|
+
depth -= 1;
|
|
474
|
+
i += 1;
|
|
475
|
+
}
|
|
476
|
+
for (const id of source.slice(start, i).matchAll(/[A-Za-z_$][\w$]*/g))
|
|
477
|
+
declared.add(id[0]);
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
const m = /^[A-Za-z_$][\w$]*/.exec(source.slice(i));
|
|
481
|
+
if (m === null)
|
|
482
|
+
break;
|
|
483
|
+
declared.add(m[0]);
|
|
484
|
+
i += m[0].length;
|
|
485
|
+
}
|
|
486
|
+
while (i < source.length && /\s/.test(source[i]))
|
|
487
|
+
i += 1;
|
|
488
|
+
if (source[i] === "=") {
|
|
489
|
+
i += 1;
|
|
490
|
+
let depth = 0;
|
|
491
|
+
while (i < source.length) {
|
|
492
|
+
const c = source[i];
|
|
493
|
+
if (c === "(" || c === "[" || c === "{")
|
|
494
|
+
depth += 1;
|
|
495
|
+
else if (c === ")" || c === "]" || c === "}")
|
|
496
|
+
depth -= 1;
|
|
497
|
+
else if ((c === "," || c === ";") && depth <= 0)
|
|
498
|
+
break;
|
|
499
|
+
i += 1;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
while (i < source.length && /\s/.test(source[i]))
|
|
503
|
+
i += 1;
|
|
504
|
+
if (source[i] === ",") {
|
|
505
|
+
i += 1;
|
|
506
|
+
continue;
|
|
507
|
+
}
|
|
508
|
+
break; // `;` or unexpected — end of this declaration statement
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}
|
|
382
512
|
/**
|
|
383
513
|
* Replace comments, strings, template literals, and regex literals with
|
|
384
514
|
* spaces while preserving line breaks and character offsets. A regex-only
|
|
@@ -397,7 +527,6 @@ function maskNonCodeForIdentifierScan(source) {
|
|
|
397
527
|
if (chars[i] !== "\n" && chars[i] !== "\r")
|
|
398
528
|
chars[i] = " ";
|
|
399
529
|
};
|
|
400
|
-
const canStartRegexAfter = /[({[=,:;!?&|+\-*%^~<>]/;
|
|
401
530
|
let i = 0;
|
|
402
531
|
let previousSignificant = "";
|
|
403
532
|
while (i < source.length) {
|
|
@@ -442,27 +571,10 @@ function maskNonCodeForIdentifierScan(source) {
|
|
|
442
571
|
previousSignificant = '"';
|
|
443
572
|
continue;
|
|
444
573
|
}
|
|
445
|
-
const regexContext = previousSignificant === "" ||
|
|
574
|
+
const regexContext = previousSignificant === "" || REGEX_MAY_START_AFTER.test(previousSignificant);
|
|
446
575
|
if (c === "/" && next !== "/" && next !== "*" && regexContext) {
|
|
447
|
-
const start = i
|
|
448
|
-
|
|
449
|
-
while (i < source.length) {
|
|
450
|
-
if (source[i] === "\\") {
|
|
451
|
-
i += 2;
|
|
452
|
-
continue;
|
|
453
|
-
}
|
|
454
|
-
if (source[i] === "[")
|
|
455
|
-
inClass = true;
|
|
456
|
-
else if (source[i] === "]")
|
|
457
|
-
inClass = false;
|
|
458
|
-
else if (source[i] === "/" && !inClass) {
|
|
459
|
-
i += 1;
|
|
460
|
-
while (/[A-Za-z]/.test(source[i] ?? ""))
|
|
461
|
-
i += 1;
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
i += 1;
|
|
465
|
-
}
|
|
576
|
+
const start = i;
|
|
577
|
+
i = skipRegexLiteral(source, i);
|
|
466
578
|
mask(start, i);
|
|
467
579
|
previousSignificant = "/";
|
|
468
580
|
continue;
|
|
@@ -480,7 +592,7 @@ const scanCache = new WeakMap();
|
|
|
480
592
|
/**
|
|
481
593
|
* Look up task `name`'s `code:` body verbatim from the automation file
|
|
482
594
|
* `elementum build` is currently importing (tracked engine-side by
|
|
483
|
-
* `withSourceText` around each own-file-child's
|
|
595
|
+
* `withSourceText` around each own-file-child's import —
|
|
484
596
|
* `src/engine/build/build.ts`/`source-context.ts`), or `undefined` if
|
|
485
597
|
* there's no tracked source (not running under `elementum build`, e.g. an
|
|
486
598
|
* automation constructed directly in a test) or the name/shape wasn't found
|
|
@@ -520,6 +632,10 @@ function scanExecuteScriptBodies(src) {
|
|
|
520
632
|
i = skipString(src, i);
|
|
521
633
|
continue;
|
|
522
634
|
}
|
|
635
|
+
if (c === "/" && startsRegexLiteralAt(src, i)) {
|
|
636
|
+
i = skipRegexLiteral(src, i);
|
|
637
|
+
continue;
|
|
638
|
+
}
|
|
523
639
|
if (isIdentifierBoundaryMatch(src, i, "executeScript")) {
|
|
524
640
|
const openParen = skipWs(src, i + "executeScript".length);
|
|
525
641
|
if (src[openParen] === "(") {
|
|
@@ -561,6 +677,10 @@ function scanCallArgs(src, open) {
|
|
|
561
677
|
i = skipString(src, i);
|
|
562
678
|
continue;
|
|
563
679
|
}
|
|
680
|
+
if (c === "/" && startsRegexLiteralAt(src, i)) {
|
|
681
|
+
i = skipRegexLiteral(src, i);
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
564
684
|
if (c === "(" || c === "[" || c === "{") {
|
|
565
685
|
depth += 1;
|
|
566
686
|
i += 1;
|
|
@@ -617,6 +737,10 @@ function extractCodeBody(optsText) {
|
|
|
617
737
|
i = skipString(optsText, i);
|
|
618
738
|
continue;
|
|
619
739
|
}
|
|
740
|
+
if (c === "/" && startsRegexLiteralAt(optsText, i)) {
|
|
741
|
+
i = skipRegexLiteral(optsText, i);
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
620
744
|
if (c === "{" || c === "(" || c === "[") {
|
|
621
745
|
depth += 1;
|
|
622
746
|
i += 1;
|
|
@@ -658,6 +782,10 @@ function extractFunctionBlockBodyAt(text, start) {
|
|
|
658
782
|
i = skipString(text, i);
|
|
659
783
|
continue;
|
|
660
784
|
}
|
|
785
|
+
if (c === "/" && startsRegexLiteralAt(text, i)) {
|
|
786
|
+
i = skipRegexLiteral(text, i);
|
|
787
|
+
continue;
|
|
788
|
+
}
|
|
661
789
|
if (text.startsWith("=>", i)) {
|
|
662
790
|
sawArrow = true;
|
|
663
791
|
const bodyStart = skipWs(text, i + 2);
|
|
@@ -696,6 +824,10 @@ function extractFunctionBlockBodyAt(text, start) {
|
|
|
696
824
|
k = skipString(text, k);
|
|
697
825
|
continue;
|
|
698
826
|
}
|
|
827
|
+
if (cc === "/" && startsRegexLiteralAt(text, k)) {
|
|
828
|
+
k = skipRegexLiteral(text, k);
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
699
831
|
if (cc === "{")
|
|
700
832
|
blockDepth += 1;
|
|
701
833
|
else if (cc === "}")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { isCanonicalTsLabel, sanitizeName, tsLabelToTfLabel } from "../../engine/tf/index.js";
|
|
2
|
+
/** Canonical Terraform label for an authored automation task ref key. */
|
|
3
|
+
export function taskTfLabel(automationLabel, refKey) {
|
|
4
|
+
// ei's task label is `<auto>_<sanitizeName(task name)>` for display-name
|
|
5
|
+
// stems. Pulled refKeys that are already canonical camelCase (e.g.
|
|
6
|
+
// `commodityBHit_1`) must use the lossless `tsLabelToTfLabel` bijection —
|
|
7
|
+
// `sanitizeName` lowercases before splitCamelCase and collapses
|
|
8
|
+
// single-letter camel segments (`commodityBHit` → `commodityb_hit`), which
|
|
9
|
+
// plans destroy+create against export's `commodity_b_hit_1`.
|
|
10
|
+
//
|
|
11
|
+
// ALLCAPS / SCREAMING_SNAKE refKeys (`GREETING`) also round-trip the
|
|
12
|
+
// bijection (via ugly `_g_r_e_e_t_i_n_g`), but ei's SanitizeName yields
|
|
13
|
+
// `greeting` — require a lowercase letter before preferring the bijection.
|
|
14
|
+
const normalized = isCanonicalTsLabel(refKey) && /[a-z]/.test(refKey)
|
|
15
|
+
? tsLabelToTfLabel(refKey)
|
|
16
|
+
: sanitizeName(refKey);
|
|
17
|
+
return normalized.startsWith(`${automationLabel}_`) ? normalized : `${automationLabel}_${normalized}`;
|
|
18
|
+
}
|