@upstash/workflow 0.1.0 → 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-JDMP6KKR.mjs → chunk-BPN5JBNG.mjs} +96 -11
- package/cloudflare.d.mts +1 -1
- package/cloudflare.d.ts +1 -1
- package/cloudflare.js +77 -2
- package/cloudflare.mjs +1 -1
- package/h3.d.mts +1 -1
- package/h3.d.ts +1 -1
- package/h3.js +77 -2
- package/h3.mjs +1 -1
- package/hono.d.mts +1 -1
- package/hono.d.ts +1 -1
- package/hono.js +77 -2
- package/hono.mjs +1 -1
- package/index.d.mts +14 -6
- package/index.d.ts +14 -6
- package/index.js +96 -11
- package/index.mjs +1 -1
- package/nextjs.d.mts +1 -1
- package/nextjs.d.ts +1 -1
- package/nextjs.js +77 -2
- package/nextjs.mjs +1 -1
- package/package.json +1 -99
- package/solidjs.d.mts +1 -1
- package/solidjs.d.ts +1 -1
- package/solidjs.js +77 -2
- package/solidjs.mjs +1 -1
- package/svelte.d.mts +1 -1
- package/svelte.d.ts +1 -1
- package/svelte.js +77 -2
- package/svelte.mjs +1 -1
- package/{types-CfN1Epuj.d.mts → types-CoXaNrxX.d.mts} +57 -8
- package/{types-CfN1Epuj.d.ts → types-CoXaNrxX.d.ts} +57 -8
|
@@ -375,7 +375,40 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
375
375
|
* @returns call result (parsed as JSON if possible)
|
|
376
376
|
*/
|
|
377
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
|
+
*/
|
|
378
410
|
waitForEvent(stepName: string, eventId: string, timeout: string | number): Promise<WaitStepResponse>;
|
|
411
|
+
notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
|
|
379
412
|
/**
|
|
380
413
|
* Adds steps to the executor. Needed so that it can be overwritten in
|
|
381
414
|
* DisabledWorkflowContext.
|
|
@@ -428,7 +461,7 @@ type WaitFields = {
|
|
|
428
461
|
};
|
|
429
462
|
type NotifyFields = {
|
|
430
463
|
notifyEventId?: string;
|
|
431
|
-
|
|
464
|
+
eventData?: string;
|
|
432
465
|
};
|
|
433
466
|
type Step<TResult = unknown, TBody = unknown> = {
|
|
434
467
|
/**
|
|
@@ -582,10 +615,6 @@ type FailureFunctionPayload = {
|
|
|
582
615
|
* Makes all fields except the ones selected required
|
|
583
616
|
*/
|
|
584
617
|
type RequiredExceptFields<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
585
|
-
type WaitResult<TResult = unknown> = {
|
|
586
|
-
result: TResult;
|
|
587
|
-
timeout: boolean;
|
|
588
|
-
};
|
|
589
618
|
type Waiter = {
|
|
590
619
|
url: string;
|
|
591
620
|
deadline: number;
|
|
@@ -597,7 +626,6 @@ type Waiter = {
|
|
|
597
626
|
type NotifyResponse = {
|
|
598
627
|
waiter: Waiter;
|
|
599
628
|
messageId: string;
|
|
600
|
-
deduplicated: boolean;
|
|
601
629
|
error: string;
|
|
602
630
|
};
|
|
603
631
|
type WaitRequest = {
|
|
@@ -609,8 +637,29 @@ type WaitRequest = {
|
|
|
609
637
|
step: Step;
|
|
610
638
|
};
|
|
611
639
|
type WaitStepResponse = {
|
|
640
|
+
/**
|
|
641
|
+
* whether the wait for event step timed out. false if
|
|
642
|
+
* the step is notified
|
|
643
|
+
*/
|
|
612
644
|
timeout: boolean;
|
|
613
|
-
|
|
645
|
+
/**
|
|
646
|
+
* body passed in notify request
|
|
647
|
+
*/
|
|
648
|
+
eventData: unknown;
|
|
649
|
+
};
|
|
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[];
|
|
614
663
|
};
|
|
615
664
|
|
|
616
|
-
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,
|
|
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 };
|
|
@@ -375,7 +375,40 @@ declare class WorkflowContext<TInitialPayload = unknown> {
|
|
|
375
375
|
* @returns call result (parsed as JSON if possible)
|
|
376
376
|
*/
|
|
377
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
|
+
*/
|
|
378
410
|
waitForEvent(stepName: string, eventId: string, timeout: string | number): Promise<WaitStepResponse>;
|
|
411
|
+
notify(stepName: string, eventId: string, eventData: unknown): Promise<NotifyStepResponse>;
|
|
379
412
|
/**
|
|
380
413
|
* Adds steps to the executor. Needed so that it can be overwritten in
|
|
381
414
|
* DisabledWorkflowContext.
|
|
@@ -428,7 +461,7 @@ type WaitFields = {
|
|
|
428
461
|
};
|
|
429
462
|
type NotifyFields = {
|
|
430
463
|
notifyEventId?: string;
|
|
431
|
-
|
|
464
|
+
eventData?: string;
|
|
432
465
|
};
|
|
433
466
|
type Step<TResult = unknown, TBody = unknown> = {
|
|
434
467
|
/**
|
|
@@ -582,10 +615,6 @@ type FailureFunctionPayload = {
|
|
|
582
615
|
* Makes all fields except the ones selected required
|
|
583
616
|
*/
|
|
584
617
|
type RequiredExceptFields<T, K extends keyof T> = Omit<Required<T>, K> & Partial<Pick<T, K>>;
|
|
585
|
-
type WaitResult<TResult = unknown> = {
|
|
586
|
-
result: TResult;
|
|
587
|
-
timeout: boolean;
|
|
588
|
-
};
|
|
589
618
|
type Waiter = {
|
|
590
619
|
url: string;
|
|
591
620
|
deadline: number;
|
|
@@ -597,7 +626,6 @@ type Waiter = {
|
|
|
597
626
|
type NotifyResponse = {
|
|
598
627
|
waiter: Waiter;
|
|
599
628
|
messageId: string;
|
|
600
|
-
deduplicated: boolean;
|
|
601
629
|
error: string;
|
|
602
630
|
};
|
|
603
631
|
type WaitRequest = {
|
|
@@ -609,8 +637,29 @@ type WaitRequest = {
|
|
|
609
637
|
step: Step;
|
|
610
638
|
};
|
|
611
639
|
type WaitStepResponse = {
|
|
640
|
+
/**
|
|
641
|
+
* whether the wait for event step timed out. false if
|
|
642
|
+
* the step is notified
|
|
643
|
+
*/
|
|
612
644
|
timeout: boolean;
|
|
613
|
-
|
|
645
|
+
/**
|
|
646
|
+
* body passed in notify request
|
|
647
|
+
*/
|
|
648
|
+
eventData: unknown;
|
|
649
|
+
};
|
|
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[];
|
|
614
663
|
};
|
|
615
664
|
|
|
616
|
-
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,
|
|
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 };
|