@@ -1593,14 +1593,12 @@ export function allHandlersFinished(): boolean {
1593
1593
}
1594
1594
1595
1595
/**
1596
- * Can be used to alter or define workflow functions with certain options specified at definition
1597
- * time. In order to ensure that workflows are loaded properly by their name, you typically will not
1598
- * need to use the return value of this function.
1596
+ * Can be used to alter workflow functions with certain options specified at definition time.
1599
1597
*
1600
1598
* @example
1601
1599
* For example:
1602
1600
* ```ts
1603
- * defineWorkflowWithOptions ({ versioningBehavior: 'pinned ' }, myWorkflow);
1601
+ * setWorkflowOptions ({ versioningBehavior: 'PINNED ' }, myWorkflow);
1604
1602
* export async function myWorkflow(): Promise<string> {
1605
1603
* // Workflow code here
1606
1604
* return "hi";
@@ -1610,29 +1608,25 @@ export function allHandlersFinished(): boolean {
1610
1608
* @example
1611
1609
* To annotate a default or dynamic workflow:
1612
1610
* ```ts
1613
- * export default defineWorkflowWithOptions({ versioningBehavior: 'pinned' }, myDefaultWorkflow);
1614
- * async function myDefaultWorkflow(): Promise<string> {
1611
+ * export default async function (): Promise<string> {
1615
1612
* // Workflow code here
1616
1613
* return "hi";
1617
1614
* }
1615
+ * setWorkflowOptions({ versioningBehavior: 'PINNED' }, module.exports.default);
1618
1616
* ```
1619
1617
*
1620
1618
* @param options Options for the workflow defintion, or a function that returns options. If a
1621
1619
* function is provided, it will be called once just before the workflow function is called for the
1622
- * first time.
1620
+ * first time. It is safe to call { @link workflowInfo} inside such a function.
1623
1621
* @param fn The workflow function.
1624
- * @returns The same passed in workflow function, with the specified options applied. You can export
1625
- * this function to make it available as a workflow function.
1626
1622
*/
1627
- export function defineWorkflowWithOptions < A extends any [ ] , RT > (
1623
+ export function setWorkflowOptions < A extends any [ ] , RT > (
1628
1624
options : WorkflowDefinitionOptionsOrGetter ,
1629
1625
fn : ( ...args : A ) => Promise < RT >
1630
- ) : WorkflowFunctionWithOptions < A , RT > {
1631
- const wrappedFn = Object . assign ( fn , {
1632
- options,
1633
- __temporal_is_workflow_function_with_options : true as const ,
1626
+ ) {
1627
+ Object . assign ( fn , {
1628
+ workflowDefinitionOptions : options ,
1634
1629
} ) ;
1635
- return wrappedFn ;
1636
1630
}
1637
1631
1638
1632
export const stackTraceQuery = defineQuery < string > ( '__stack_trace' ) ;
0 commit comments