@upstash/qstash 2.9.1-rc.1 → 2.9.1

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.
@@ -103,7 +103,7 @@ type LogPayload = Omit<Log, "urlGroup"> & {
103
103
  topicName: string;
104
104
  };
105
105
  /**
106
- * Deprecated. Use the `LogPayload` type instead.
106
+ * Deprecated. Use the `EventPayload` type instead.
107
107
  *
108
108
  * @deprecated
109
109
  */
@@ -464,7 +464,7 @@ type UpstashRequest = {
464
464
  * A string to set request's method.
465
465
  */
466
466
  method?: HTTPMethods;
467
- query?: Record<string, string | number | boolean | Date | string[] | undefined>;
467
+ query?: Record<string, string | number | boolean | undefined>;
468
468
  /**
469
469
  * if enabled, call `res.json()`
470
470
  *
@@ -505,81 +505,6 @@ type RetryConfig = false | {
505
505
  backoff?: (retryCount: number) => number;
506
506
  };
507
507
 
508
- type NeverAll<T> = {
509
- [K in keyof T]?: never;
510
- };
511
- type RequireAtLeastOne<T> = {
512
- [K in keyof T]-?: Required<Pick<T, K>>;
513
- }[keyof T];
514
- /**
515
- * Three-way exclusive union: at-least-one-filter OR `{ all: true }` OR IDs.
516
- * Exactly one branch can be satisfied at a time.
517
- *
518
- * The filter and all branches intentionally omit `NeverAll<Ids>` so that
519
- * TypeScript's `"key" in request` narrowing correctly isolates the IDs branch.
520
- * Excess-property checks on object literals still prevent mixing ID keys with filters.
521
- */
522
- type FilterAllOrIds<F extends Record<string, unknown>, Ids extends Record<string, unknown>> = (F & RequireAtLeastOne<F> & {
523
- all?: never;
524
- }) | ({
525
- all: true;
526
- } & NeverAll<F>) | (Ids & NeverAll<F> & {
527
- all?: never;
528
- });
529
- /** Shared filter fields accepted by every qstash & workflow endpoint. */
530
- type UniversalFilterFields = {
531
- /**
532
- * aslkdjasd
533
- */
534
- fromDate?: Date | number;
535
- toDate?: Date | number;
536
- callerIp?: string;
537
- label?: string;
538
- flowControlKey?: string;
539
- };
540
- /** QStash-specific identity filters (DLQ + message endpoints). */
541
- type QStashIdentityFields = {
542
- messageId?: string;
543
- url?: string;
544
- urlGroup?: string;
545
- scheduleId?: string;
546
- queueName?: string;
547
- };
548
- /** DLQ-specific response filter. */
549
- type DLQResponseFields = {
550
- responseStatus?: number;
551
- };
552
- /** Logs-specific filter fields exclusive to log endpoints. */
553
- type LogsFilterFields = {
554
- state?: State;
555
- messageIds?: string[];
556
- };
557
- /**
558
- * Doesn't allow a single messageId because this is a bulk action
559
- */
560
- type MessageCancelFilters = FilterAllOrIds<UniversalFilterFields & Omit<QStashIdentityFields, "messageId">, {
561
- messageIds: string[];
562
- }>;
563
- type DLQBulkActionFilters = FilterAllOrIds<UniversalFilterFields & QStashIdentityFields & DLQResponseFields, {
564
- dlqIds: string | string[];
565
- }>;
566
- type DLQListFilters = UniversalFilterFields & QStashIdentityFields & DLQResponseFields;
567
- type LogsListFilters = UniversalFilterFields & QStashIdentityFields & LogsFilterFields & {
568
- /**
569
- * @deprecated use `urlGroup` instead
570
- */
571
- topicName?: string;
572
- /**
573
- * @deprecated use `count` option in the root instead of the `filter` object
574
- *
575
- * Example:
576
- * ```ts
577
- * await client.logs({ count: 50 })
578
- * ```
579
- */
580
- count?: number;
581
- };
582
-
583
508
  type Message = {
584
509
  /**
585
510
  * A unique identifier for this message.
@@ -702,33 +627,10 @@ declare class Messages {
702
627
  */
703
628
  get(messageId: string): Promise<Message>;
704
629
  /**
705
- * Cancel messages.
706
- *
707
- * Can be called with:
708
- * - A single messageId: `cancel("id")`
709
- * - An array of messageIds: `cancel(["id1", "id2"])`
710
- * - A filter object: `cancel({ flowControlKey: "key", label: "label" })`
711
- * - All messages: `cancel({ all: true })`
712
- */
713
- cancel(request: string | string[] | MessageCancelFilters): Promise<{
714
- cancelled: number;
715
- }>;
716
- /**
717
- * Delete a message.
718
- *
719
- * @deprecated Use `cancel(messageId: string)` instead
630
+ * Cancel a message
720
631
  */
721
632
  delete(messageId: string): Promise<void>;
722
- /**
723
- * Cancel multiple messages by their messageIds.
724
- *
725
- * @deprecated Use `cancel(messageIds: string[])` instead
726
- */
727
633
  deleteMany(messageIds: string[]): Promise<number>;
728
- /**
729
- * Cancel all messages
730
- * @deprecated Use `cancel({all: true})` to cancel all
731
- */
732
634
  deleteAll(): Promise<number>;
733
635
  }
734
636
 
@@ -756,6 +658,52 @@ type DlqMessage = Message & {
756
658
  */
757
659
  responseBodyBase64?: string;
758
660
  };
661
+ type DLQFilter = {
662
+ /**
663
+ * Filter DLQ entries by message id
664
+ */
665
+ messageId?: string;
666
+ /**
667
+ * Filter DLQ entries by url
668
+ */
669
+ url?: string;
670
+ /**
671
+ * Filter DLQ entries by url group name
672
+ */
673
+ urlGroup?: string;
674
+ /**
675
+ * Filter DLQ entries by api name
676
+ */
677
+ api?: string;
678
+ /**
679
+ * Filter DLQ entries by queue name
680
+ */
681
+ queueName?: string;
682
+ /**
683
+ * Filter DLQ entries by schedule id
684
+ */
685
+ scheduleId?: string;
686
+ /**
687
+ * Filter DLQ entries by starting time, in milliseconds
688
+ */
689
+ fromDate?: number;
690
+ /**
691
+ * Filter DLQ entries by ending time, in milliseconds
692
+ */
693
+ toDate?: number;
694
+ /**
695
+ * Filter DLQ entries by label
696
+ */
697
+ label?: string;
698
+ /**
699
+ * Filter DLQ entries by HTTP status of the response
700
+ */
701
+ responseStatus?: number;
702
+ /**
703
+ * Filter DLQ entries by IP address of the publisher of the message
704
+ */
705
+ callerIp?: string;
706
+ };
759
707
  declare class DLQ {
760
708
  private readonly http;
761
709
  constructor(http: Requester);
@@ -765,59 +713,148 @@ declare class DLQ {
765
713
  listMessages(options?: {
766
714
  cursor?: string;
767
715
  count?: number;
768
- /** Defaults to `latestFirst` */
769
- order?: "earliestFirst" | "latestFirst";
770
- trimBody?: number;
771
- filter?: DLQListFilters;
716
+ filter?: DLQFilter;
772
717
  }): Promise<{
773
718
  messages: DlqMessage[];
774
719
  cursor?: string;
775
720
  }>;
776
721
  /**
777
- * Remove messages from the dlq.
778
- *
779
- * Can be called with:
780
- * - A single dlqId: `delete("id")`
781
- * - An array of dlqIds: `delete(["id1", "id2"])`
782
- * - An object with dlqIds: `delete({ dlqIds: ["id1", "id2"] })`
783
- * - A filter object: `delete({ url: "https://example.com", label: "label" })`
784
- * - All messages: `delete({ all: true })`
785
- *
786
- * Note: passing an empty array returns `{ deleted: 0 }` without making a request.
722
+ * Remove a message from the dlq using it's `dlqId`
787
723
  */
788
- delete(request: string | string[] | DLQBulkActionFilters): Promise<{
789
- deleted: number;
790
- cursor?: string;
791
- }>;
724
+ delete(dlqMessageId: string): Promise<void>;
792
725
  /**
793
726
  * Remove multiple messages from the dlq using their `dlqId`s
794
- *
795
- * @deprecated Use `delete` instead
796
727
  */
797
728
  deleteMany(request: {
798
729
  dlqIds: string[];
799
730
  }): Promise<{
800
731
  deleted: number;
801
- cursor?: string;
802
732
  }>;
733
+ }
734
+
735
+ type FlowControlInfo = {
736
+ /**
737
+ * The flow control key.
738
+ */
739
+ flowControlKey: string;
803
740
  /**
804
- * Retry messages from the dlq.
741
+ * The number of messages waiting in the wait list.
742
+ */
743
+ waitListSize: number;
744
+ /**
745
+ * The maximum parallelism configured for this flow control key.
746
+ */
747
+ parallelismMax: number;
748
+ /**
749
+ * The current number of active requests for this flow control key.
750
+ */
751
+ parallelismCount: number;
752
+ /**
753
+ * The maximum rate configured for this flow control key.
754
+ */
755
+ rateMax: number;
756
+ /**
757
+ * The current number of requests consumed in the current period.
758
+ */
759
+ rateCount: number;
760
+ /**
761
+ * The rate period in seconds.
762
+ */
763
+ ratePeriod: number;
764
+ /**
765
+ * The start time of the current rate period as a unix timestamp.
766
+ */
767
+ ratePeriodStart: number;
768
+ /**
769
+ * Whether message delivery is paused for this flow control key.
770
+ */
771
+ isPaused: boolean;
772
+ /**
773
+ * Whether the parallelism configuration is pinned.
774
+ */
775
+ isPinnedParallelism: boolean;
776
+ /**
777
+ * Whether the rate configuration is pinned.
778
+ */
779
+ isPinnedRate: boolean;
780
+ };
781
+ type GlobalParallelismInfo = {
782
+ /**
783
+ * The maximum global parallelism.
784
+ */
785
+ parallelismMax: number;
786
+ /**
787
+ * The current number of active requests globally.
788
+ */
789
+ parallelismCount: number;
790
+ };
791
+ type PinFlowControlOptions = {
792
+ /**
793
+ * The parallelism value to apply to the flow-control key.
794
+ */
795
+ parallelism?: number;
796
+ /**
797
+ * The rate value to apply to the flow-control key.
798
+ */
799
+ rate?: number;
800
+ /**
801
+ * The period value to apply to the flow-control key, in seconds.
802
+ */
803
+ period?: number;
804
+ };
805
+ type UnpinFlowControlOptions = {
806
+ /**
807
+ * Whether to unpin the parallelism configuration.
808
+ */
809
+ parallelism?: boolean;
810
+ /**
811
+ * Whether to unpin the rate configuration.
812
+ */
813
+ rate?: boolean;
814
+ };
815
+ declare class FlowControlApi {
816
+ private readonly http;
817
+ constructor(http: Requester);
818
+ /**
819
+ * Get a single flow control by key.
820
+ */
821
+ get(flowControlKey: string): Promise<FlowControlInfo>;
822
+ /**
823
+ * Get the global parallelism info.
824
+ */
825
+ getGlobalParallelism(): Promise<GlobalParallelismInfo>;
826
+ /**
827
+ * Pause message delivery for a flow-control key.
805
828
  *
806
- * Can be called with:
807
- * - A single dlqId: `retry("id")`
808
- * - An array of dlqIds: `retry(["id1", "id2"])`
809
- * - An object with dlqIds: `retry({ dlqIds: ["id1", "id2"] })`
810
- * - A filter object: `retry({ url: "https://example.com", label: "label" })`
811
- * - All messages: `retry({ all: true })`
829
+ * Messages already in the waitlist will remain there.
830
+ * New incoming messages will be added directly to the waitlist.
831
+ */
832
+ pause(flowControlKey: string): Promise<void>;
833
+ /**
834
+ * Resume message delivery for a flow-control key.
835
+ */
836
+ resume(flowControlKey: string): Promise<void>;
837
+ /**
838
+ * Pin a processing configuration for a flow-control key.
812
839
  *
813
- * Note: passing an empty array returns `{ responses: [] }` without making a request.
840
+ * While pinned, the system ignores configurations provided by incoming
841
+ * messages and uses the pinned configuration instead.
814
842
  */
815
- retry(request: string | string[] | DLQBulkActionFilters): Promise<{
816
- cursor?: string;
817
- responses: {
818
- messageId: string;
819
- }[];
820
- }>;
843
+ pin(flowControlKey: string, options: PinFlowControlOptions): Promise<void>;
844
+ /**
845
+ * Remove the pinned configuration for a flow-control key.
846
+ *
847
+ * After unpinning, the system resumes updating the configuration
848
+ * based on incoming messages.
849
+ */
850
+ unpin(flowControlKey: string, options: UnpinFlowControlOptions): Promise<void>;
851
+ /**
852
+ * Reset the rate configuration state for a flow-control key.
853
+ *
854
+ * Clears the current rate count and immediately ends the current period.
855
+ * The current timestamp becomes the start of the new rate period.
856
+ */
857
+ resetRate(flowControlKey: string): Promise<void>;
821
858
  }
822
859
 
823
860
  declare class Chat {
@@ -2122,12 +2159,7 @@ type PublishJsonRequest = Omit<PublishRequest, "body"> & {
2122
2159
  };
2123
2160
  type LogsRequest = {
2124
2161
  cursor?: string | number;
2125
- /** Max 1000. Defaults to 10 when `groupBy` is used. */
2126
- count?: number;
2127
- /** Defaults to `latestFirst` */
2128
- order?: "earliestFirst" | "latestFirst";
2129
- trimBody?: number;
2130
- filter?: LogsListFilters;
2162
+ filter?: LogsRequestFilter;
2131
2163
  };
2132
2164
  /**
2133
2165
  * Deprecated. Use `LogsRequest` instead.
@@ -2135,6 +2167,20 @@ type LogsRequest = {
2135
2167
  * @deprecated
2136
2168
  */
2137
2169
  type EventsRequest = LogsRequest;
2170
+ type LogsRequestFilter = {
2171
+ messageId?: string;
2172
+ state?: State;
2173
+ url?: string;
2174
+ urlGroup?: string;
2175
+ topicName?: string;
2176
+ api?: string;
2177
+ scheduleId?: string;
2178
+ queueName?: string;
2179
+ fromDate?: number;
2180
+ toDate?: number;
2181
+ count?: number;
2182
+ label?: string;
2183
+ };
2138
2184
  type GetLogsResponse = {
2139
2185
  cursor?: string;
2140
2186
  logs: Log[];
@@ -2190,6 +2236,12 @@ declare class Client {
2190
2236
  * Create, read or delete schedules.
2191
2237
  */
2192
2238
  get schedules(): Schedules;
2239
+ /**
2240
+ * Access the flow control API.
2241
+ *
2242
+ * List, get, or reset flow controls.
2243
+ */
2244
+ get flowControl(): FlowControlApi;
2193
2245
  /**
2194
2246
  * Access the workflow API.
2195
2247
  *
@@ -2285,4 +2337,4 @@ type PublishResponse<TRequest> = TRequest extends {
2285
2337
  urlGroup: string;
2286
2338
  } ? PublishToUrlGroupsResponse : PublishToApiResponse;
2287
2339
 
2288
- export { type ChatCompletionChunk as $, type AddEndpointsRequest as A, BaseProvider as B, type ChatRateLimit as C, type LogPayload as D, type EmailOwner as E, type FailureFunctionPayload as F, type GetLogsResponse as G, type HTTPMethods as H, type EventPayload as I, type GetLogsPayload as J, type GetEventsPayload as K, type LLMOwner as L, type Message as M, type BodyInit as N, type HeadersInit as O, type ProviderInfo as P, type QueueRequest as Q, type RateLimit as R, type Step as S, type RequestOptions as T, type UniversalFilterFields as U, type VerifyRequest as V, type WithCursor as W, type FlowControl as X, Chat as Y, type ChatCompletionMessage as Z, type ChatCompletion as _, type ReceiverConfig as a, type StreamEnabled as a0, type StreamDisabled as a1, type StreamParameter as a2, type OpenAIChatModel as a3, type PromptChatRequest as a4, type ChatRequest as a5, upstash as a6, openai as a7, anthropic as a8, custom as a9, type RouteFunction as aa, type WorkflowServeOptions as ab, Workflow as ac, processOptions as ad, serve as ae, WorkflowContext as af, DisabledWorkflowContext as ag, type WorkflowClient as ah, type WorkflowReceiver as ai, StepTypes as aj, type StepType as ak, type RawStep as al, type SyncStepFunction as am, type AsyncStepFunction as an, type StepFunction as ao, type ParallelCallState as ap, type FinishCondition as aq, type RequiredExceptFields as ar, type LogLevel as as, type WorkflowLoggerOptions as at, WorkflowLogger as au, SignatureError as b, Receiver as c, type PublishBatchRequest as d, type PublishRequest as e, type PublishJsonRequest as f, type LogsRequest as g, type EventsRequest as h, type GetEventsResponse as i, Client as j, type PublishToApiResponse as k, type PublishToUrlResponse as l, type PublishToUrlGroupsResponse as m, type PublishResponse as n, type MessagePayload as o, Messages as p, type Schedule as q, type CreateScheduleRequest as r, Schedules as s, type Endpoint as t, type RemoveEndpointsRequest as u, type UrlGroup as v, UrlGroups as w, type State as x, type Log as y, type Event as z };
2340
+ export { type FlowControl as $, type AddEndpointsRequest as A, BaseProvider as B, type ChatRateLimit as C, UrlGroups as D, type EmailOwner as E, type FailureFunctionPayload as F, type GetLogsResponse as G, type State as H, type HTTPMethods as I, type Log as J, type Event as K, type LLMOwner as L, type Message as M, type LogPayload as N, type EventPayload as O, type ProviderInfo as P, type QueueRequest as Q, type RateLimit as R, type Step as S, type GetLogsPayload as T, type UnpinFlowControlOptions as U, type VerifyRequest as V, type GetEventsPayload as W, type WithCursor as X, type BodyInit as Y, type HeadersInit as Z, type RequestOptions as _, type ReceiverConfig as a, Chat as a0, type ChatCompletionMessage as a1, type ChatCompletion as a2, type ChatCompletionChunk as a3, type StreamEnabled as a4, type StreamDisabled as a5, type StreamParameter as a6, type OpenAIChatModel as a7, type PromptChatRequest as a8, type ChatRequest as a9, upstash as aa, openai as ab, anthropic as ac, custom as ad, type RouteFunction as ae, type WorkflowServeOptions as af, Workflow as ag, processOptions as ah, serve as ai, WorkflowContext as aj, DisabledWorkflowContext as ak, type WorkflowClient as al, type WorkflowReceiver as am, StepTypes as an, type StepType as ao, type RawStep as ap, type SyncStepFunction as aq, type AsyncStepFunction as ar, type StepFunction as as, type ParallelCallState as at, type FinishCondition as au, type RequiredExceptFields as av, type LogLevel as aw, type WorkflowLoggerOptions as ax, WorkflowLogger as ay, SignatureError as b, Receiver as c, type PublishBatchRequest as d, type PublishRequest as e, type PublishJsonRequest as f, type LogsRequest as g, type EventsRequest as h, type GetEventsResponse as i, Client as j, type PublishToApiResponse as k, type PublishToUrlResponse as l, type PublishToUrlGroupsResponse as m, type PublishResponse as n, type FlowControlInfo as o, type GlobalParallelismInfo as p, type PinFlowControlOptions as q, FlowControlApi as r, type MessagePayload as s, Messages as t, type Schedule as u, type CreateScheduleRequest as v, Schedules as w, type Endpoint as x, type RemoveEndpointsRequest as y, type UrlGroup as z };
package/cloudflare.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { aa as RouteFunction, ab as WorkflowServeOptions } from './client-Gv4WRTxB.mjs';
1
+ import { ae as RouteFunction, af as WorkflowServeOptions } from './client-jh_SomWB.mjs';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {
package/cloudflare.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { aa as RouteFunction, ab as WorkflowServeOptions } from './client-Gv4WRTxB.js';
1
+ import { ae as RouteFunction, af as WorkflowServeOptions } from './client-jh_SomWB.js';
2
2
  import 'neverthrow';
3
3
 
4
4
  type WorkflowBindings = {