Skip to content

Commit aea517c

Browse files
committed
.
1 parent c1ed746 commit aea517c

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

packages/swc-plugin-workflow/transform/src/lib.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5467,9 +5467,14 @@ impl VisitMut for StepTransform {
54675467
}
54685468
TransformMode::Workflow => {
54695469
// Replace with proxy reference
5470+
// Use current_parent_function_name to match step mode's ID generation
54705471
let step_fn_name =
5471-
if let Some(parent) = &self.current_workflow_function_name {
5472-
format!("{}/{}", parent, name)
5472+
if let Some(parent) = &self.current_parent_function_name {
5473+
if !parent.is_empty() {
5474+
format!("{}/{}", parent, name)
5475+
} else {
5476+
name.clone()
5477+
}
54735478
} else {
54745479
name.clone()
54755480
};
@@ -5588,9 +5593,14 @@ impl VisitMut for StepTransform {
55885593
}
55895594
TransformMode::Workflow => {
55905595
// Replace with proxy reference
5596+
// Use current_parent_function_name to match step mode's ID generation
55915597
let step_fn_name =
5592-
if let Some(parent) = &self.current_workflow_function_name {
5593-
format!("{}/{}", parent, name)
5598+
if let Some(parent) = &self.current_parent_function_name {
5599+
if !parent.is_empty() {
5600+
format!("{}/{}", parent, name)
5601+
} else {
5602+
name.clone()
5603+
}
55945604
} else {
55955605
name.clone()
55965606
};

packages/swc-plugin-workflow/transform/tests/fixture/default-parameter-usage/output-step.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ async function convertToLanguageModelPrompt({ prompt, supportedUrls, download =
1515
};
1616
}
1717
export async function myWorkflow(input) {
18-
'use workflow';
19-
const result = await convertToLanguageModelPrompt({
20-
prompt: input.prompt,
21-
supportedUrls: {},
22-
download: undefined
23-
});
24-
return result;
18+
throw new Error("You attempted to execute workflow myWorkflow function directly. To start a workflow, use start(myWorkflow) from workflow/api");
2519
}
20+
myWorkflow.workflowId = "workflow//input.js//myWorkflow";

packages/swc-plugin-workflow/transform/tests/fixture/nested-step-with-closure/output-workflow.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ function stepWrapperReturnArrowFunctionVar(a, b, c) {
99
return fn;
1010
}
1111
function stepWrapperReturnNamedFunction(a, b, c) {
12-
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//f", ()=>({
12+
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//stepWrapperReturnNamedFunction/f", ()=>({
1313
a,
1414
b,
1515
c
1616
}));
1717
}
1818
function stepWrapperReturnArrowFunction(a, b, c) {
19-
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//_anonymousStep0", ()=>({
19+
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//stepWrapperReturnArrowFunction/_anonymousStep0", ()=>({
2020
a,
2121
b,
2222
c
@@ -39,14 +39,14 @@ const arrowWrapperReturnArrowFunctionVar = (a, b, c)=>{
3939
return fn;
4040
};
4141
const arrowWrapperReturnNamedFunction = (a, b, c)=>{
42-
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//f", ()=>({
42+
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//arrowWrapperReturnNamedFunction/f", ()=>({
4343
a,
4444
b,
4545
c
4646
}));
4747
};
4848
const arrowWrapperReturnArrowFunction = (a, b, c)=>{
49-
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//_anonymousStep1", ()=>({
49+
return globalThis[Symbol.for("WORKFLOW_USE_STEP")]("step//input.js//arrowWrapperReturnArrowFunction/_anonymousStep1", ()=>({
5050
a,
5151
b,
5252
c

0 commit comments

Comments
 (0)