@upstash/workflow 0.1.1-canary → 0.1.1-canary-2
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/{chunk-YW5KUHA2.mjs → chunk-BPN5JBNG.mjs} +116 -45
- package/cloudflare.d.mts +2 -4
- package/cloudflare.d.ts +2 -4
- package/cloudflare.js +100 -39
- package/cloudflare.mjs +4 -4
- package/h3.d.mts +5 -7
- package/h3.d.ts +5 -7
- package/h3.js +99 -38
- package/h3.mjs +3 -3
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +98 -37
- package/hono.mjs +2 -2
- package/index.d.mts +15 -9
- package/index.d.ts +15 -9
- package/index.js +116 -45
- package/index.mjs +1 -1
- package/nextjs.d.mts +4 -7
- package/nextjs.d.ts +4 -7
- package/nextjs.js +105 -46
- package/nextjs.mjs +9 -11
- package/package.json +1 -1
- package/solidjs.d.mts +2 -4
- package/solidjs.d.ts +2 -4
- package/solidjs.js +99 -38
- package/solidjs.mjs +3 -3
- package/svelte.d.mts +2 -4
- package/svelte.d.ts +2 -4
- package/svelte.js +100 -39
- package/svelte.mjs +4 -4
- package/{types-D8FBKkto.d.mts → types-CoXaNrxX.d.mts} +57 -18
- package/{types-D8FBKkto.d.ts → types-CoXaNrxX.d.ts} +57 -18
|
@@ -374,13 +374,41 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
374
374
|
* @param headers call headers
|
|
375
375
|
* @returns call result (parsed as JSON if possible)
|
|
376
376
|
*/
|
|
377
|
-
call(stepName: string,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
377
|
+
call<TResult = unknown, TBody = unknown>(stepName: string, url: string, method: HTTPMethods, body?: TBody, headers?: Record<string, string>): Promise<TResult>;
|
|
378
|
+
/**
|
|
379
|
+
* Makes the workflow run wait until a notify request is sent or until the
|
|
380
|
+
* timeout ends
|
|
381
|
+
*
|
|
382
|
+
* ```ts
|
|
383
|
+
* const { eventData, timeout } = await context.waitForEvent(
|
|
384
|
+
* "wait for event step",
|
|
385
|
+
* "my-event-id",
|
|
386
|
+
* 100 // timeout after 100 seconds
|
|
387
|
+
* );
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* To notify a waiting workflow run, you can use the notify method:
|
|
391
|
+
*
|
|
392
|
+
* ```ts
|
|
393
|
+
* import { Client } from "@upstash/workflow";
|
|
394
|
+
*
|
|
395
|
+
* const client = new Client({ token: });
|
|
396
|
+
*
|
|
397
|
+
* await client.notify({
|
|
398
|
+
* eventId: "my-event-id",
|
|
399
|
+
* eventData: "eventData"
|
|
400
|
+
* })
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @param stepName
|
|
404
|
+
* @param eventId event id to wake up the waiting workflow run
|
|
405
|
+
* @param timeout timeout duration in seconds
|
|
406
|
+
* @returns wait response as `{ timeout: boolean, eventData: unknown }`.
|
|
407
|
+
* timeout is true if the wait times out, if notified it is false. eventData
|
|
408
|
+
* is the value passed to `client.notify`.
|
|
409
|
+
*/
|
|
383
410
|
waitForEvent(stepName: string, eventId: string, timeout: string | number): Promise<WaitStepResponse>;
|
|
411
|
+
notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
|
|
384
412
|
/**
|
|
385
413
|
* Adds steps to the executor. Needed so that it can be overwritten in
|
|
386
414
|
* DisabledWorkflowContext.
|
|
@@ -433,7 +461,7 @@ type WaitFields = {
|
|
|
433
461
|
};
|
|
434
462
|
type NotifyFields = {
|
|
435
463
|
notifyEventId?: string;
|
|
436
|
-
|
|
464
|
+
eventData?: string;
|
|
437
465
|
};
|
|
438
466
|
type Step<TResult = unknown, TBody = unknown> = {
|
|
439
467
|
/**
|
|
@@ -587,10 +615,6 @@ type FailureFunctionPayload = {
|
|
|
587
615
|
* Makes all fields except the ones selected required
|
|
588
616
|
*/
|
|
589
617
|
type RequiredExceptFields<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
590
|
-
type WaitResult<TResult = unknown> = {
|
|
591
|
-
result: TResult;
|
|
592
|
-
timeout: boolean;
|
|
593
|
-
};
|
|
594
618
|
type Waiter = {
|
|
595
619
|
url: string;
|
|
596
620
|
deadline: number;
|
|
@@ -602,7 +626,6 @@ type Waiter = {
|
|
|
602
626
|
type NotifyResponse = {
|
|
603
627
|
waiter: Waiter;
|
|
604
628
|
messageId: string;
|
|
605
|
-
deduplicated: boolean;
|
|
606
629
|
error: string;
|
|
607
630
|
};
|
|
608
631
|
type WaitRequest = {
|
|
@@ -614,13 +637,29 @@ type WaitRequest = {
|
|
|
614
637
|
step: Step;
|
|
615
638
|
};
|
|
616
639
|
type WaitStepResponse = {
|
|
640
|
+
/**
|
|
641
|
+
* whether the wait for event step timed out. false if
|
|
642
|
+
* the step is notified
|
|
643
|
+
*/
|
|
617
644
|
timeout: boolean;
|
|
618
|
-
|
|
645
|
+
/**
|
|
646
|
+
* body passed in notify request
|
|
647
|
+
*/
|
|
648
|
+
eventData: unknown;
|
|
619
649
|
};
|
|
620
|
-
type
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
650
|
+
type NotifyStepResponse = {
|
|
651
|
+
/**
|
|
652
|
+
* notified event id
|
|
653
|
+
*/
|
|
654
|
+
eventId: string;
|
|
655
|
+
/**
|
|
656
|
+
* event data sent with notify
|
|
657
|
+
*/
|
|
658
|
+
eventData: unknown;
|
|
659
|
+
/**
|
|
660
|
+
* response from notify
|
|
661
|
+
*/
|
|
662
|
+
notifyResponse: NotifyResponse[];
|
|
624
663
|
};
|
|
625
664
|
|
|
626
|
-
export { type AsyncStepFunction as A, type
|
|
665
|
+
export { type AsyncStepFunction as A, type FinishCondition as F, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type FailureFunctionPayload as j, type RequiredExceptFields as k, type WaitRequest as l, type WaitStepResponse as m, type NotifyStepResponse as n, type WorkflowLoggerOptions as o, WorkflowLogger as p };
|
|
@@ -374,13 +374,41 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
374
374
|
* @param headers call headers
|
|
375
375
|
* @returns call result (parsed as JSON if possible)
|
|
376
376
|
*/
|
|
377
|
-
call(stepName: string,
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
377
|
+
call<TResult = unknown, TBody = unknown>(stepName: string, url: string, method: HTTPMethods, body?: TBody, headers?: Record<string, string>): Promise<TResult>;
|
|
378
|
+
/**
|
|
379
|
+
* Makes the workflow run wait until a notify request is sent or until the
|
|
380
|
+
* timeout ends
|
|
381
|
+
*
|
|
382
|
+
* ```ts
|
|
383
|
+
* const { eventData, timeout } = await context.waitForEvent(
|
|
384
|
+
* "wait for event step",
|
|
385
|
+
* "my-event-id",
|
|
386
|
+
* 100 // timeout after 100 seconds
|
|
387
|
+
* );
|
|
388
|
+
* ```
|
|
389
|
+
*
|
|
390
|
+
* To notify a waiting workflow run, you can use the notify method:
|
|
391
|
+
*
|
|
392
|
+
* ```ts
|
|
393
|
+
* import { Client } from "@upstash/workflow";
|
|
394
|
+
*
|
|
395
|
+
* const client = new Client({ token: });
|
|
396
|
+
*
|
|
397
|
+
* await client.notify({
|
|
398
|
+
* eventId: "my-event-id",
|
|
399
|
+
* eventData: "eventData"
|
|
400
|
+
* })
|
|
401
|
+
* ```
|
|
402
|
+
*
|
|
403
|
+
* @param stepName
|
|
404
|
+
* @param eventId event id to wake up the waiting workflow run
|
|
405
|
+
* @param timeout timeout duration in seconds
|
|
406
|
+
* @returns wait response as `{ timeout: boolean, eventData: unknown }`.
|
|
407
|
+
* timeout is true if the wait times out, if notified it is false. eventData
|
|
408
|
+
* is the value passed to `client.notify`.
|
|
409
|
+
*/
|
|
383
410
|
waitForEvent(stepName: string, eventId: string, timeout: string | number): Promise<WaitStepResponse>;
|
|
411
|
+
notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
|
|
384
412
|
/**
|
|
385
413
|
* Adds steps to the executor. Needed so that it can be overwritten in
|
|
386
414
|
* DisabledWorkflowContext.
|
|
@@ -433,7 +461,7 @@ type WaitFields = {
|
|
|
433
461
|
};
|
|
434
462
|
type NotifyFields = {
|
|
435
463
|
notifyEventId?: string;
|
|
436
|
-
|
|
464
|
+
eventData?: string;
|
|
437
465
|
};
|
|
438
466
|
type Step<TResult = unknown, TBody = unknown> = {
|
|
439
467
|
/**
|
|
@@ -587,10 +615,6 @@ type FailureFunctionPayload = {
|
|
|
587
615
|
* Makes all fields except the ones selected required
|
|
588
616
|
*/
|
|
589
617
|
type RequiredExceptFields<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
590
|
-
type WaitResult<TResult = unknown> = {
|
|
591
|
-
result: TResult;
|
|
592
|
-
timeout: boolean;
|
|
593
|
-
};
|
|
594
618
|
type Waiter = {
|
|
595
619
|
url: string;
|
|
596
620
|
deadline: number;
|
|
@@ -602,7 +626,6 @@ type Waiter = {
|
|
|
602
626
|
type NotifyResponse = {
|
|
603
627
|
waiter: Waiter;
|
|
604
628
|
messageId: string;
|
|
605
|
-
deduplicated: boolean;
|
|
606
629
|
error: string;
|
|
607
630
|
};
|
|
608
631
|
type WaitRequest = {
|
|
@@ -614,13 +637,29 @@ type WaitRequest = {
|
|
|
614
637
|
step: Step;
|
|
615
638
|
};
|
|
616
639
|
type WaitStepResponse = {
|
|
640
|
+
/**
|
|
641
|
+
* whether the wait for event step timed out. false if
|
|
642
|
+
* the step is notified
|
|
643
|
+
*/
|
|
617
644
|
timeout: boolean;
|
|
618
|
-
|
|
645
|
+
/**
|
|
646
|
+
* body passed in notify request
|
|
647
|
+
*/
|
|
648
|
+
eventData: unknown;
|
|
619
649
|
};
|
|
620
|
-
type
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
650
|
+
type NotifyStepResponse = {
|
|
651
|
+
/**
|
|
652
|
+
* notified event id
|
|
653
|
+
*/
|
|
654
|
+
eventId: string;
|
|
655
|
+
/**
|
|
656
|
+
* event data sent with notify
|
|
657
|
+
*/
|
|
658
|
+
eventData: unknown;
|
|
659
|
+
/**
|
|
660
|
+
* response from notify
|
|
661
|
+
*/
|
|
662
|
+
notifyResponse: NotifyResponse[];
|
|
624
663
|
};
|
|
625
664
|
|
|
626
|
-
export { type AsyncStepFunction as A, type
|
|
665
|
+
export { type AsyncStepFunction as A, type FinishCondition as F, type LogLevel as L, type NotifyResponse as N, type ParallelCallState as P, type RouteFunction as R, type Step as S, type WorkflowServeOptions as W, type Waiter as a, WorkflowContext as b, type WorkflowClient as c, type WorkflowReceiver as d, StepTypes as e, type StepType as f, type RawStep as g, type SyncStepFunction as h, type StepFunction as i, type FailureFunctionPayload as j, type RequiredExceptFields as k, type WaitRequest as l, type WaitStepResponse as m, type NotifyStepResponse as n, type WorkflowLoggerOptions as o, WorkflowLogger as p };
|