@upstash/qstash 2.6.4-workflow-alpha.2 → 2.6.4

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.
@@ -1,1454 +0,0 @@
1
- /**
2
- * Necessary to verify the signature of a request.
3
- */
4
- type ReceiverConfig = {
5
- /**
6
- * The current signing key. Get it from `https://console.upstash.com/qstash
7
- */
8
- currentSigningKey: string;
9
- /**
10
- * The next signing key. Get it from `https://console.upstash.com/qstash
11
- */
12
- nextSigningKey: string;
13
- };
14
- type VerifyRequest = {
15
- /**
16
- * The signature from the `upstash-signature` header.
17
- */
18
- signature: string;
19
- /**
20
- * The raw request body.
21
- */
22
- body: string;
23
- /**
24
- * URL of the endpoint where the request was sent to.
25
- *
26
- * Omit empty to disable checking the url.
27
- */
28
- url?: string;
29
- /**
30
- * Number of seconds to tolerate when checking `nbf` and `exp` claims, to deal with small clock differences among different servers
31
- *
32
- * @default 0
33
- */
34
- clockTolerance?: number;
35
- };
36
- declare class SignatureError extends Error {
37
- constructor(message: string);
38
- }
39
- /**
40
- * Receiver offers a simple way to verify the signature of a request.
41
- */
42
- declare class Receiver {
43
- private readonly currentSigningKey;
44
- private readonly nextSigningKey;
45
- constructor(config: ReceiverConfig);
46
- /**
47
- * Verify the signature of a request.
48
- *
49
- * Tries to verify the signature with the current signing key.
50
- * If that fails, maybe because you have rotated the keys recently, it will
51
- * try to verify the signature with the next signing key.
52
- *
53
- * If that fails, the signature is invalid and a `SignatureError` is thrown.
54
- */
55
- verify(request: VerifyRequest): Promise<boolean>;
56
- /**
57
- * Verify signature with a specific signing key
58
- */
59
- private verifyWithKey;
60
- }
61
-
62
- type State = "CREATED" | "ACTIVE" | "DELIVERED" | "ERROR" | "RETRY" | "FAILED";
63
- type HTTPMethods = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
64
- type Event = {
65
- time: number;
66
- state: State;
67
- messageId: string;
68
- nextDeliveryTime?: number;
69
- error?: string;
70
- url: string;
71
- urlGroup?: string;
72
- topicName?: string;
73
- endpointName?: string;
74
- header?: Record<string, string>;
75
- body?: string;
76
- };
77
- type EventPayload = Omit<Event, "urlGroup"> & {
78
- topicName: string;
79
- };
80
- type GetEventsPayload = {
81
- cursor?: number;
82
- events: EventPayload[];
83
- };
84
- type WithCursor<T> = T & {
85
- cursor?: number;
86
- };
87
- type BodyInit = Blob | FormData | URLSearchParams | ReadableStream<Uint8Array> | string;
88
- type HeadersInit = Headers | Record<string, string> | [string, string][] | IterableIterator<[string, string]>;
89
- type RequestOptions = RequestInit & {
90
- backend?: string;
91
- };
92
- type ChatRateLimit = {
93
- "limit-requests": string | null;
94
- "limit-tokens": string | null;
95
- "remaining-requests": string | null;
96
- "remaining-tokens": string | null;
97
- "reset-requests": string | null;
98
- "reset-tokens": string | null;
99
- };
100
- type RateLimit = {
101
- limit: string | null;
102
- remaining: string | null;
103
- reset: string | null;
104
- };
105
-
106
- type ProviderReturnType = {
107
- owner: "upstash" | "openai" | "custom";
108
- baseUrl: string;
109
- token: string;
110
- };
111
- declare const upstash: () => {
112
- owner: "upstash";
113
- baseUrl: "https://qstash.upstash.io/llm";
114
- token: string;
115
- };
116
- declare const openai: ({ token, }: {
117
- token: string;
118
- }) => {
119
- owner: "openai";
120
- baseUrl: "https://api.openai.com";
121
- token: string;
122
- };
123
- declare const custom: ({ baseUrl, token, }: {
124
- token: string;
125
- baseUrl: string;
126
- }) => {
127
- owner: "custom";
128
- baseUrl: string;
129
- token: string;
130
- };
131
-
132
- type ChatCompletionMessage = {
133
- role: "system" | "assistant" | "user";
134
- content: string;
135
- };
136
- type ChatModel = "meta-llama/Meta-Llama-3-8B-Instruct" | "mistralai/Mistral-7B-Instruct-v0.2";
137
- type ChatResponseFormat = {
138
- type: "text" | "json_object";
139
- };
140
- type TopLogprob = {
141
- token: string;
142
- bytes: number[];
143
- logprob: number;
144
- };
145
- type ChatCompletionTokenLogprob = {
146
- token: string;
147
- bytes: number[];
148
- logprob: number;
149
- top_logprobs: TopLogprob[];
150
- };
151
- type ChoiceLogprobs = {
152
- content: ChatCompletionTokenLogprob[];
153
- };
154
- type Choice = {
155
- finish_reason: "stop" | "length";
156
- index: number;
157
- logprobs: ChoiceLogprobs;
158
- message: ChatCompletionMessage;
159
- };
160
- type CompletionUsage = {
161
- completion_tokens: number;
162
- prompt_tokens: number;
163
- total_tokens: number;
164
- };
165
- type ChatCompletion = {
166
- id: string;
167
- choices: Choice[];
168
- created: number;
169
- model: string;
170
- object: "chat.completion";
171
- system_fingerprint: string;
172
- usage: CompletionUsage;
173
- };
174
- type ChunkChoice = {
175
- delta: ChatCompletionMessage;
176
- finish_reason: "stop" | "length";
177
- index: number;
178
- logprobs: ChoiceLogprobs;
179
- };
180
- type ChatCompletionChunk = {
181
- id: string;
182
- choices: ChunkChoice[];
183
- created: number;
184
- model: string;
185
- object: "chat.completion.chunk";
186
- system_fingerprint: string;
187
- usage: CompletionUsage;
188
- };
189
- type StreamEnabled = {
190
- stream: true;
191
- };
192
- type StreamDisabled = {
193
- stream: false;
194
- } | object;
195
- type StreamParameter = StreamEnabled | StreamDisabled;
196
- type OpenAIChatModel = "gpt-4-turbo" | "gpt-4-turbo-2024-04-09" | "gpt-4-0125-preview" | "gpt-4-turbo-preview" | "gpt-4-1106-preview" | "gpt-4-vision-preview" | "gpt-4" | "gpt-4-0314" | "gpt-4-0613" | "gpt-4-32k" | "gpt-4-32k-0314" | "gpt-4-32k-0613" | "gpt-3.5-turbo" | "gpt-3.5-turbo-16k" | "gpt-3.5-turbo-0301" | "gpt-3.5-turbo-0613" | "gpt-3.5-turbo-1106" | "gpt-3.5-turbo-0125" | "gpt-3.5-turbo-16k-0613";
197
- type ChatRequestCommonFields = {
198
- frequency_penalty?: number;
199
- logit_bias?: Record<string, number>;
200
- logprobs?: boolean;
201
- top_logprobs?: number;
202
- max_tokens?: number;
203
- n?: number;
204
- presence_penalty?: number;
205
- response_format?: ChatResponseFormat;
206
- seed?: number;
207
- stop?: string | string[];
208
- temperature?: number;
209
- top_p?: number;
210
- };
211
- type PromptChatRequestFields = ChatRequestCommonFields & {
212
- system: string;
213
- user: string;
214
- };
215
- type ChatRequestFields = ChatRequestCommonFields & {
216
- messages: ChatCompletionMessage[];
217
- };
218
- type ChatRequestProviders = {
219
- provider: ProviderReturnType;
220
- model: OpenAIChatModel;
221
- } | {
222
- provider: ProviderReturnType;
223
- model: string;
224
- } | {
225
- provider: ProviderReturnType;
226
- model: ChatModel;
227
- };
228
- type PromptChatRequest<TStream extends StreamParameter> = ChatRequestProviders & PromptChatRequestFields & TStream;
229
- type ChatRequest<TStream extends StreamParameter> = ChatRequestProviders & ChatRequestFields & TStream;
230
-
231
- type UpstashRequest = {
232
- /**
233
- * The path to the resource.
234
- */
235
- path: string[];
236
- /**
237
- * A BodyInit object or null to set request's body.
238
- */
239
- body?: BodyInit | null;
240
- /**
241
- * A Headers object, an object literal, or an array of two-item arrays to set
242
- * request's headers.
243
- */
244
- headers?: HeadersInit;
245
- /**
246
- * A boolean to set request's keepalive.
247
- */
248
- keepalive?: boolean;
249
- /**
250
- * A string to set request's method.
251
- */
252
- method?: HTTPMethods;
253
- query?: Record<string, string | number | boolean | undefined>;
254
- /**
255
- * if enabled, call `res.json()`
256
- *
257
- * @default true
258
- */
259
- parseResponseAsJson?: boolean;
260
- baseUrl?: string;
261
- };
262
- type UpstashResponse<TResult> = TResult & {
263
- error?: string;
264
- };
265
- type Requester = {
266
- request: <TResult = unknown>(request: UpstashRequest) => Promise<UpstashResponse<TResult>>;
267
- requestStream: (request: UpstashRequest) => AsyncIterable<ChatCompletionChunk>;
268
- };
269
- type RetryConfig = false | {
270
- /**
271
- * The number of retries to attempt before giving up.
272
- *
273
- * @default 5
274
- */
275
- retries?: number;
276
- /**
277
- * A backoff function receives the current retry cound and returns a number in milliseconds to wait before retrying.
278
- *
279
- * @default
280
- * ```ts
281
- * Math.exp(retryCount) * 50
282
- * ```
283
- */
284
- backoff?: (retryCount: number) => number;
285
- };
286
-
287
- type Message = {
288
- /**
289
- * A unique identifier for this message.
290
- */
291
- messageId: string;
292
- /**
293
- * The url group name if this message was sent to a urlGroup.
294
- */
295
- urlGroup?: string;
296
- /**
297
- * Deprecated. The topic name if this message was sent to a urlGroup. Use urlGroup instead
298
- */
299
- topicName?: string;
300
- /**
301
- * The url where this message is sent to.
302
- */
303
- url: string;
304
- /**
305
- * The endpoint name of the message if the endpoint is given a
306
- * name within the url group.
307
- */
308
- endpointName?: string;
309
- /**
310
- * The api name if this message was sent to an api
311
- */
312
- api?: string;
313
- /**
314
- * The http method used to deliver the message
315
- */
316
- method?: HTTPMethods;
317
- /**
318
- * The http headers sent along with the message to your API.
319
- */
320
- header?: Record<string, string[]>;
321
- /**
322
- * The http body sent to your API
323
- */
324
- body?: string;
325
- /**
326
- * The base64 encoded body if the body contains non-UTF-8 characters,
327
- * `None` otherwise.
328
- */
329
- bodyBase64?: string;
330
- /**
331
- * Maxmimum number of retries.
332
- */
333
- maxRetries?: number;
334
- /**
335
- * A unix timestamp (milliseconds) after which this message may get delivered.
336
- */
337
- notBefore?: number;
338
- /**
339
- * A unix timestamp (milliseconds) when this messages was created.
340
- */
341
- createdAt: number;
342
- /**
343
- * The callback url if configured.
344
- */
345
- callback?: string;
346
- /**
347
- * The failure callback url if configured.
348
- */
349
- failureCallback?: string;
350
- /**
351
- * The queue name if this message was sent to a queue.
352
- */
353
- queueName?: string;
354
- /**
355
- * The scheduleId of the message if the message is triggered by a schedule
356
- */
357
- scheduleId?: string;
358
- /**
359
- * IP address of the publisher of this message
360
- */
361
- callerIp?: string;
362
- };
363
- type MessagePayload = Omit<Message, "urlGroup"> & {
364
- topicName: string;
365
- };
366
- declare class Messages {
367
- private readonly http;
368
- constructor(http: Requester);
369
- /**
370
- * Get a message
371
- */
372
- get(messageId: string): Promise<Message>;
373
- /**
374
- * Cancel a message
375
- */
376
- delete(messageId: string): Promise<void>;
377
- deleteMany(messageIds: string[]): Promise<number>;
378
- deleteAll(): Promise<number>;
379
- }
380
-
381
- type DlqMessage = Message & {
382
- /**
383
- * The unique id within the DLQ
384
- */
385
- dlqId: string;
386
- /**
387
- * The HTTP status code of the last failed delivery attempt
388
- */
389
- responseStatus?: number;
390
- /**
391
- * The response headers of the last failed delivery attempt
392
- */
393
- responseHeader?: Record<string, string[]>;
394
- /**
395
- * The response body of the last failed delivery attempt if it is
396
- * composed of UTF-8 characters only, `None` otherwise.
397
- */
398
- responseBody?: string;
399
- /**
400
- * The base64 encoded response body of the last failed delivery attempt
401
- * if the response body contains non-UTF-8 characters, `None` otherwise.
402
- */
403
- responseBodyBase64?: string;
404
- };
405
- type DLQFilter = {
406
- /**
407
- * Filter DLQ entries by message id
408
- */
409
- messageId?: string;
410
- /**
411
- * Filter DLQ entries by url
412
- */
413
- url?: string;
414
- /**
415
- * Filter DLQ entries by url group name
416
- */
417
- urlGroup?: string;
418
- /**
419
- * Filter DLQ entries by api name
420
- */
421
- api?: string;
422
- /**
423
- * Filter DLQ entries by queue name
424
- */
425
- queueName?: string;
426
- /**
427
- * Filter DLQ entries by schedule id
428
- */
429
- scheduleId?: string;
430
- /**
431
- * Filter DLQ entries by starting time, in milliseconds
432
- */
433
- fromDate?: number;
434
- /**
435
- * Filter DLQ entries by ending time, in milliseconds
436
- */
437
- toDate?: number;
438
- /**
439
- * Filter DLQ entries by HTTP status of the response
440
- */
441
- responseStatus?: number;
442
- /**
443
- * Filter DLQ entries by IP address of the publisher of the message
444
- */
445
- callerIp?: string;
446
- };
447
- declare class DLQ {
448
- private readonly http;
449
- constructor(http: Requester);
450
- /**
451
- * List messages in the dlq
452
- */
453
- listMessages(options?: {
454
- cursor?: string;
455
- count?: number;
456
- filter?: DLQFilter;
457
- }): Promise<{
458
- messages: DlqMessage[];
459
- cursor?: string;
460
- }>;
461
- /**
462
- * Remove a message from the dlq using it's `dlqId`
463
- */
464
- delete(dlqMessageId: string): Promise<void>;
465
- /**
466
- * Remove multiple messages from the dlq using their `dlqId`s
467
- */
468
- deleteMany(request: {
469
- dlqIds: string[];
470
- }): Promise<{
471
- deleted: number;
472
- }>;
473
- }
474
-
475
- declare class Chat {
476
- private http;
477
- private token;
478
- constructor(http: Requester, token: string);
479
- private static toChatRequest;
480
- /**
481
- * Calls the Upstash completions api given a ChatRequest.
482
- *
483
- * Returns a ChatCompletion or a stream of ChatCompletionChunks
484
- * if stream is enabled.
485
- *
486
- * @param request ChatRequest with messages
487
- * @returns Chat completion or stream
488
- */
489
- create: <TStream extends StreamParameter>(request: ChatRequest<TStream>) => Promise<TStream extends StreamEnabled ? AsyncIterable<ChatCompletionChunk> : ChatCompletion>;
490
- /**
491
- * Calls the Upstash completions api given a ChatRequest.
492
- *
493
- * Returns a ChatCompletion or a stream of ChatCompletionChunks
494
- * if stream is enabled.
495
- *
496
- * @param request ChatRequest with messages
497
- * @returns Chat completion or stream
498
- */
499
- private createThirdParty;
500
- /**
501
- * Calls the Upstash completions api given a PromptRequest.
502
- *
503
- * Returns a ChatCompletion or a stream of ChatCompletionChunks
504
- * if stream is enabled.
505
- *
506
- * @param request PromptRequest with system and user messages.
507
- * Note that system parameter shouldn't be passed in the case of
508
- * mistralai/Mistral-7B-Instruct-v0.2 model.
509
- * @returns Chat completion or stream
510
- */
511
- prompt: <TStream extends StreamParameter>(request: PromptChatRequest<TStream>) => Promise<TStream extends StreamEnabled ? AsyncIterable<ChatCompletionChunk> : ChatCompletion>;
512
- }
513
-
514
- type QueueResponse = {
515
- createdAt: number;
516
- updatedAt: number;
517
- name: string;
518
- parallelism: number;
519
- lag: number;
520
- paused: boolean;
521
- };
522
- type UpsertQueueRequest = {
523
- /**
524
- * The number of parallel consumers consuming from the queue.
525
- *
526
- * @default 1
527
- */
528
- parallelism?: number;
529
- /**
530
- * Whether to pause the queue or not. A paused queue will not
531
- * deliver new messages until it is resumed.
532
- *
533
- * @default false
534
- */
535
- paused?: boolean;
536
- };
537
- declare class Queue {
538
- private readonly http;
539
- private readonly queueName;
540
- constructor(http: Requester, queueName?: string);
541
- /**
542
- * Create or update the queue
543
- */
544
- upsert(request: UpsertQueueRequest): Promise<void>;
545
- /**
546
- * Get the queue details
547
- */
548
- get(): Promise<QueueResponse>;
549
- /**
550
- * List queues
551
- */
552
- list(): Promise<QueueResponse[]>;
553
- /**
554
- * Delete the queue
555
- */
556
- delete(): Promise<void>;
557
- /**
558
- * Enqueue a message to a queue.
559
- */
560
- enqueue<TRequest extends PublishRequest>(request: TRequest): Promise<PublishResponse<TRequest>>;
561
- /**
562
- * Enqueue a message to a queue, serializing the body to JSON.
563
- */
564
- enqueueJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(request: TRequest): Promise<PublishResponse<TRequest>>;
565
- /**
566
- * Pauses the queue.
567
- *
568
- * A paused queue will not deliver messages until
569
- * it is resumed.
570
- */
571
- pause(): Promise<void>;
572
- /**
573
- * Resumes the queue.
574
- */
575
- resume(): Promise<void>;
576
- }
577
-
578
- type Schedule = {
579
- scheduleId: string;
580
- cron: string;
581
- createdAt: number;
582
- destination: string;
583
- method: string;
584
- header?: Record<string, string[]>;
585
- body?: string;
586
- bodyBase64?: string;
587
- retries: number;
588
- delay?: number;
589
- callback?: string;
590
- failureCallback?: string;
591
- callerIp?: string;
592
- isPaused: boolean;
593
- };
594
- type CreateScheduleRequest = {
595
- /**
596
- * Either a URL or urlGroup name
597
- */
598
- destination: string;
599
- /**
600
- * The message to send.
601
- *
602
- * This can be anything, but please set the `Content-Type` header accordingly.
603
- *
604
- * You can leave this empty if you want to send a message with no body.
605
- */
606
- body?: BodyInit;
607
- /**
608
- * Optionally send along headers with the message.
609
- * These headers will be sent to your destination.
610
- *
611
- * We highly recommend sending a `Content-Type` header along, as this will help your destination
612
- * server to understand the content of the message.
613
- */
614
- headers?: HeadersInit;
615
- /**
616
- * Optionally delay the delivery of this message.
617
- *
618
- * In seconds.
619
- *
620
- * @default undefined
621
- */
622
- delay?: number;
623
- /**
624
- * In case your destination server is unavailable or returns a status code outside of the 200-299
625
- * range, we will retry the request after a certain amount of time.
626
- *
627
- * Configure how many times you would like the delivery to be retried
628
- *
629
- * @default The maximum retry quota associated with your account.
630
- */
631
- retries?: number;
632
- /**
633
- * Use a callback url to forward the response of your destination server to your callback url.
634
- *
635
- * The callback url must be publicly accessible
636
- *
637
- * @default undefined
638
- */
639
- callback?: string;
640
- /**
641
- * Use a failure callback url to handle messages that could not be delivered.
642
- *
643
- * The failure callback url must be publicly accessible
644
- *
645
- * @default undefined
646
- */
647
- failureCallback?: string;
648
- /**
649
- * The method to use when sending a request to your API
650
- *
651
- * @default `POST`
652
- */
653
- method?: HTTPMethods;
654
- /**
655
- * Specify a cron expression to repeatedly send this message to the destination.
656
- */
657
- cron: string;
658
- /**
659
- * The HTTP timeout value to use while calling the destination URL.
660
- * When a timeout is specified, it will be used instead of the maximum timeout
661
- * value permitted by the QStash plan. It is useful in scenarios, where a message
662
- * should be delivered with a shorter timeout.
663
- *
664
- * In seconds.
665
- *
666
- * @default undefined
667
- */
668
- timeout?: number;
669
- };
670
- declare class Schedules {
671
- private readonly http;
672
- constructor(http: Requester);
673
- /**
674
- * Create a schedule
675
- */
676
- create(request: CreateScheduleRequest): Promise<{
677
- scheduleId: string;
678
- }>;
679
- /**
680
- * Get a schedule
681
- */
682
- get(scheduleId: string): Promise<Schedule>;
683
- /**
684
- * List your schedules
685
- */
686
- list(): Promise<Schedule[]>;
687
- /**
688
- * Delete a schedule
689
- */
690
- delete(scheduleId: string): Promise<void>;
691
- /**
692
- * Pauses the schedule.
693
- *
694
- * A paused schedule will not deliver messages until
695
- * it is resumed.
696
- */
697
- pause({ schedule }: {
698
- schedule: string;
699
- }): Promise<void>;
700
- /**
701
- * Resumes the schedule.
702
- */
703
- resume({ schedule }: {
704
- schedule: string;
705
- }): Promise<void>;
706
- }
707
-
708
- type Endpoint = {
709
- /**
710
- * The name of the endpoint (optional)
711
- */
712
- name?: string;
713
- /**
714
- * The url of the endpoint
715
- */
716
- url: string;
717
- };
718
- type AddEndpointsRequest = {
719
- /**
720
- * The name of the url group.
721
- * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
722
- */
723
- name: string;
724
- endpoints: Endpoint[];
725
- };
726
- type RemoveEndpointsRequest = {
727
- /**
728
- * The name of the url group.
729
- * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
730
- */
731
- name: string;
732
- endpoints: ({
733
- name: string;
734
- url?: string;
735
- } | {
736
- name?: string;
737
- url: string;
738
- })[];
739
- };
740
- type UrlGroup = {
741
- /**
742
- * A unix timestamp (milliseconds)
743
- */
744
- createdAt: number;
745
- /**
746
- * A unix timestamp (milliseconds)
747
- */
748
- updatedAt: number;
749
- /**
750
- * The name of this url group.
751
- */
752
- name: string;
753
- /**
754
- * A list of all subscribed endpoints
755
- */
756
- endpoints: Endpoint[];
757
- };
758
- declare class UrlGroups {
759
- private readonly http;
760
- constructor(http: Requester);
761
- /**
762
- * Create a new url group with the given name and endpoints
763
- */
764
- addEndpoints(request: AddEndpointsRequest): Promise<void>;
765
- /**
766
- * Remove endpoints from a url group.
767
- */
768
- removeEndpoints(request: RemoveEndpointsRequest): Promise<void>;
769
- /**
770
- * Get a list of all url groups.
771
- */
772
- list(): Promise<UrlGroup[]>;
773
- /**
774
- * Get a single url group
775
- */
776
- get(name: string): Promise<UrlGroup>;
777
- /**
778
- * Delete a url group
779
- */
780
- delete(name: string): Promise<void>;
781
- }
782
-
783
- type ClientConfig = {
784
- /**
785
- * Url of the qstash api server.
786
- *
787
- * This is only used for testing.
788
- *
789
- * @default "https://qstash.upstash.io"
790
- */
791
- baseUrl?: string;
792
- /**
793
- * The authorization token from the upstash console.
794
- */
795
- token: string;
796
- /**
797
- * Configure how the client should retry requests.
798
- */
799
- retry?: RetryConfig;
800
- };
801
- type PublishBatchRequest<TBody = BodyInit> = PublishRequest<TBody> & {
802
- queueName?: string;
803
- };
804
- type PublishRequest<TBody = BodyInit> = {
805
- /**
806
- * The message to send.
807
- *
808
- * This can be anything, but please set the `Content-Type` header accordingly.
809
- *
810
- * You can leave this empty if you want to send a message with no body.
811
- */
812
- body?: TBody;
813
- /**
814
- * Optionally send along headers with the message.
815
- * These headers will be sent to your destination.
816
- *
817
- * We highly recommend sending a `Content-Type` header along, as this will help your destination
818
- * server to understand the content of the message.
819
- */
820
- headers?: HeadersInit;
821
- /**
822
- * Optionally delay the delivery of this message.
823
- *
824
- * In seconds.
825
- *
826
- * @default undefined
827
- */
828
- delay?: number;
829
- /**
830
- * Optionally set the absolute delay of this message.
831
- * This will override the delay option.
832
- * The message will not delivered until the specified time.
833
- *
834
- * Unix timestamp in seconds.
835
- *
836
- * @default undefined
837
- */
838
- notBefore?: number;
839
- /**
840
- * Provide a unique id for deduplication. This id will be used to detect duplicate messages.
841
- * If a duplicate message is detected, the request will be accepted but not enqueued.
842
- *
843
- * We store deduplication ids for 90 days. Afterwards it is possible that the message with the
844
- * same deduplication id is delivered again.
845
- *
846
- * When scheduling a message, the deduplication happens before the schedule is created.
847
- *
848
- * @default undefined
849
- */
850
- deduplicationId?: string;
851
- /**
852
- * If true, the message content will get hashed and used as deduplication id.
853
- * If a duplicate message is detected, the request will be accepted but not enqueued.
854
- *
855
- * The content based hash includes the following values:
856
- * - All headers, except Upstash-Authorization, this includes all headers you are sending.
857
- * - The entire raw request body The destination from the url path
858
- *
859
- * We store deduplication ids for 90 days. Afterwards it is possible that the message with the
860
- * same deduplication id is delivered again.
861
- *
862
- * When scheduling a message, the deduplication happens before the schedule is created.
863
- *
864
- * @default false
865
- */
866
- contentBasedDeduplication?: boolean;
867
- /**
868
- * In case your destination server is unavaialble or returns a status code outside of the 200-299
869
- * range, we will retry the request after a certain amount of time.
870
- *
871
- * Configure how many times you would like the delivery to be retried up to the maxRetries limit
872
- * defined in your plan.
873
- *
874
- * @default 3
875
- */
876
- retries?: number;
877
- /**
878
- * Use a failure callback url to handle messages that could not be delivered.
879
- *
880
- * The failure callback url must be publicly accessible
881
- *
882
- * @default undefined
883
- */
884
- failureCallback?: string;
885
- /**
886
- * The method to use when sending a request to your API
887
- *
888
- * @default `POST`
889
- */
890
- method?: HTTPMethods;
891
- /**
892
- * The HTTP timeout value to use while calling the destination URL.
893
- * When a timeout is specified, it will be used instead of the maximum timeout
894
- * value permitted by the QStash plan. It is useful in scenarios, where a message
895
- * should be delivered with a shorter timeout.
896
- *
897
- * In seconds.
898
- *
899
- * @default undefined
900
- */
901
- timeout?: number;
902
- } & ({
903
- /**
904
- * The url where the message should be sent to.
905
- */
906
- url: string;
907
- urlGroup?: never;
908
- api?: never;
909
- topic?: never;
910
- /**
911
- * Use a callback url to forward the response of your destination server to your callback url.
912
- *
913
- * The callback url must be publicly accessible
914
- *
915
- * @default undefined
916
- */
917
- callback?: string;
918
- } | {
919
- url?: never;
920
- /**
921
- * The url group the message should be sent to.
922
- */
923
- urlGroup: string;
924
- api?: never;
925
- topic?: never;
926
- /**
927
- * Use a callback url to forward the response of your destination server to your callback url.
928
- *
929
- * The callback url must be publicly accessible
930
- *
931
- * @default undefined
932
- */
933
- callback?: string;
934
- } | {
935
- url?: string;
936
- urlGroup?: never;
937
- /**
938
- * The api endpoint the request should be sent to.
939
- */
940
- api: {
941
- name: "llm";
942
- provider?: ProviderReturnType;
943
- };
944
- /**
945
- * Use a callback url to forward the response of your destination server to your callback url.
946
- *
947
- * The callback url must be publicly accessible
948
- *
949
- * @default undefined
950
- */
951
- callback: string;
952
- topic?: never;
953
- } | {
954
- url?: never;
955
- urlGroup?: never;
956
- api: never;
957
- /**
958
- * Deprecated. The topic the message should be sent to. Same as urlGroup
959
- */
960
- topic?: string;
961
- /**
962
- * Use a callback url to forward the response of your destination server to your callback url.
963
- *
964
- * The callback url must be publicly accessible
965
- *
966
- * @default undefined
967
- */
968
- callback?: string;
969
- });
970
- type PublishJsonRequest = Omit<PublishRequest, "body"> & {
971
- /**
972
- * The message to send.
973
- * This can be anything as long as it can be serialized to JSON.
974
- */
975
- body: unknown;
976
- };
977
- type EventsRequest = {
978
- cursor?: number;
979
- filter?: EventsRequestFilter;
980
- };
981
- type EventsRequestFilter = {
982
- messageId?: string;
983
- state?: State;
984
- url?: string;
985
- urlGroup?: string;
986
- topicName?: string;
987
- api?: string;
988
- scheduleId?: string;
989
- queueName?: string;
990
- fromDate?: number;
991
- toDate?: number;
992
- count?: number;
993
- };
994
- type GetEventsResponse = {
995
- cursor?: number;
996
- events: Event[];
997
- };
998
- type QueueRequest = {
999
- queueName?: string;
1000
- };
1001
- declare class Client {
1002
- http: Requester;
1003
- private token;
1004
- constructor(config: ClientConfig);
1005
- /**
1006
- * Access the urlGroup API.
1007
- *
1008
- * Create, read, update or delete urlGroups.
1009
- */
1010
- get urlGroups(): UrlGroups;
1011
- /**
1012
- * Deprecated. Use urlGroups instead.
1013
- *
1014
- * Access the topic API.
1015
- *
1016
- * Create, read, update or delete topics.
1017
- */
1018
- get topics(): UrlGroups;
1019
- /**
1020
- * Access the dlq API.
1021
- *
1022
- * List or remove messages from the DLQ.
1023
- */
1024
- get dlq(): DLQ;
1025
- /**
1026
- * Access the message API.
1027
- *
1028
- * Read or cancel messages.
1029
- */
1030
- get messages(): Messages;
1031
- /**
1032
- * Access the schedule API.
1033
- *
1034
- * Create, read or delete schedules.
1035
- */
1036
- get schedules(): Schedules;
1037
- /**
1038
- * Access the queue API.
1039
- *
1040
- * Create, read, update or delete queues.
1041
- */
1042
- queue(request?: QueueRequest): Queue;
1043
- /**
1044
- * Access the Chat API
1045
- *
1046
- * Call the create or prompt methods
1047
- */
1048
- chat(): Chat;
1049
- publish<TRequest extends PublishRequest>(request: TRequest): Promise<PublishResponse<TRequest>>;
1050
- /**
1051
- * publishJSON is a utility wrapper around `publish` that automatically serializes the body
1052
- * and sets the `Content-Type` header to `application/json`.
1053
- */
1054
- publishJSON<TBody = unknown, TRequest extends PublishRequest<TBody> = PublishRequest<TBody>>(request: TRequest): Promise<PublishResponse<TRequest>>;
1055
- /**
1056
- * Batch publish messages to QStash.
1057
- */
1058
- batch(request: PublishBatchRequest[]): Promise<PublishResponse<PublishRequest>[]>;
1059
- /**
1060
- * Batch publish messages to QStash, serializing each body to JSON.
1061
- */
1062
- batchJSON<TBody = unknown, TRequest extends PublishBatchRequest<TBody> = PublishBatchRequest<TBody>>(request: TRequest[]): Promise<PublishResponse<TRequest>[]>;
1063
- /**
1064
- * Retrieve your logs.
1065
- *
1066
- * The logs endpoint is paginated and returns only 100 logs at a time.
1067
- * If you want to receive more logs, you can use the cursor to paginate.
1068
- *
1069
- * The cursor is a unix timestamp with millisecond precision
1070
- *
1071
- * @example
1072
- * ```ts
1073
- * let cursor = Date.now()
1074
- * const logs: Log[] = []
1075
- * while (cursor > 0) {
1076
- * const res = await qstash.logs({ cursor })
1077
- * logs.push(...res.logs)
1078
- * cursor = res.cursor ?? 0
1079
- * }
1080
- * ```
1081
- */
1082
- events(request?: EventsRequest): Promise<GetEventsResponse>;
1083
- }
1084
- type PublishToApiResponse = {
1085
- messageId: string;
1086
- };
1087
- type PublishToUrlResponse = PublishToApiResponse & {
1088
- url: string;
1089
- deduplicated?: boolean;
1090
- };
1091
- type PublishToUrlGroupsResponse = PublishToUrlResponse[];
1092
- type PublishResponse<TRequest> = TRequest extends {
1093
- url: string;
1094
- } ? PublishToUrlResponse : TRequest extends {
1095
- urlGroup: string;
1096
- } ? PublishToUrlGroupsResponse : PublishToApiResponse;
1097
-
1098
- /**
1099
- * Base class outlining steps. Basically, each step kind (run/sleep/sleepUntil)
1100
- * should have two methods: getPlanStep & getResultStep.
1101
- *
1102
- * getPlanStep works the same way for all so it's implemented here.
1103
- * The different step types will implement their own getResultStep method.
1104
- */
1105
- declare abstract class BaseLazyStep<TResult = unknown> {
1106
- readonly stepName: string;
1107
- abstract readonly stepType: StepType;
1108
- constructor(stepName: string);
1109
- /**
1110
- * plan step to submit when step will run parallel with other
1111
- * steps (parallel call state `first`)
1112
- *
1113
- * @param concurrent number of steps running parallel
1114
- * @param targetStep target step id corresponding to this step
1115
- * @returns
1116
- */
1117
- abstract getPlanStep(concurrent: number, targetStep: number): Step<undefined>;
1118
- /**
1119
- * result step to submit after the step executes. Used in single step executions
1120
- * and when a plan step executes in parallel executions (parallel call state `partial`).
1121
- *
1122
- * @param stepId
1123
- */
1124
- abstract getResultStep(stepId: number, singleStep: boolean): Promise<Step<TResult>>;
1125
- }
1126
-
1127
- declare const LOG_LEVELS: readonly ["DEBUG", "INFO", "SUBMIT", "WARN", "ERROR"];
1128
- type LogLevel = (typeof LOG_LEVELS)[number];
1129
- type ChatLogEntry = {
1130
- timestamp: number;
1131
- logLevel: LogLevel;
1132
- eventType: "ENDPOINT_START" | "SUBMIT_THIRD_PARTY_RESULT" | "CREATE_CONTEXT" | "SUBMIT_FIRST_INVOCATION" | "RUN_SINGLE" | "RUN_PARALLEL" | "SUBMIT_STEP" | "SUBMIT_CLEANUP" | "RESPONSE_WORKFLOW" | "RESPONSE_DEFAULT" | "ERROR";
1133
- details: unknown;
1134
- };
1135
- type WorkflowLoggerOptions = {
1136
- logLevel: LogLevel;
1137
- logOutput: "console";
1138
- };
1139
- declare class WorkflowLogger {
1140
- private logs;
1141
- private options;
1142
- constructor(options: WorkflowLoggerOptions);
1143
- log(level: LogLevel, eventType: ChatLogEntry["eventType"], details?: unknown): Promise<void>;
1144
- private writeToConsole;
1145
- private shouldLog;
1146
- static getLogger(verbose: boolean | WorkflowLogger): WorkflowLogger | undefined;
1147
- }
1148
-
1149
- declare class AutoExecutor {
1150
- private context;
1151
- private promises;
1152
- private activeLazyStepList?;
1153
- private debug?;
1154
- private indexInCurrentList;
1155
- stepCount: number;
1156
- planStepCount: number;
1157
- protected executingStep: string | false;
1158
- constructor(context: WorkflowContext, debug?: WorkflowLogger);
1159
- /**
1160
- * Adds the step function to the list of step functions to run in
1161
- * parallel. After adding the function, defers the execution, so
1162
- * that if there is another step function to be added, it's also
1163
- * added.
1164
- *
1165
- * After all functions are added, list of functions are executed.
1166
- * If there is a single function, it's executed by itself. If there
1167
- * are multiple, they are run in parallel.
1168
- *
1169
- * If a function is already executing (this.executingStep), this
1170
- * means that there is a nested step which is not allowed. In this
1171
- * case, addStep throws QstashWorkflowError.
1172
- *
1173
- * @param stepInfo step plan to add
1174
- * @returns result of the step function
1175
- */
1176
- addStep<TResult>(stepInfo: BaseLazyStep<TResult>): Promise<TResult>;
1177
- /**
1178
- * Wraps a step function to set this.executingStep to step name
1179
- * before running and set this.executingStep to False after execution
1180
- * ends.
1181
- *
1182
- * this.executingStep allows us to detect nested steps which are not
1183
- * allowed.
1184
- *
1185
- * @param stepName name of the step being wrapped
1186
- * @param stepFunction step function to wrap
1187
- * @returns wrapped step function
1188
- */
1189
- wrapStep<TResult = unknown>(stepName: string, stepFunction: AsyncStepFunction<TResult>): Promise<TResult>;
1190
- /**
1191
- * Executes a step:
1192
- * - If the step result is available in the steps, returns the result
1193
- * - If the result is not avaiable, runs the function
1194
- * - Sends the result to QStash
1195
- *
1196
- * @param lazyStep lazy step to execute
1197
- * @returns step result
1198
- */
1199
- protected runSingle<TResult>(lazyStep: BaseLazyStep<TResult>): Promise<TResult>;
1200
- /**
1201
- * Runs steps in parallel.
1202
- *
1203
- * @param stepName parallel step name
1204
- * @param stepFunctions list of async functions to run in parallel
1205
- * @returns results of the functions run in parallel
1206
- */
1207
- protected runParallel<TResults extends unknown[]>(parallelSteps: {
1208
- [K in keyof TResults]: BaseLazyStep<TResults[K]>;
1209
- }): Promise<TResults>;
1210
- /**
1211
- * Determines the parallel call state
1212
- *
1213
- * First filters the steps to get the steps which are after `initialStepCount` parameter.
1214
- *
1215
- * Depending on the remaining steps, decides the parallel state:
1216
- * - "first": If there are no steps
1217
- * - "last" If there are equal to or more than `2 * parallelStepCount`. We multiply by two
1218
- * because each step in a parallel execution will have 2 steps: a plan step and a result
1219
- * step.
1220
- * - "partial": If the last step is a plan step
1221
- * - "discard": If the last step is not a plan step. This means that the parallel execution
1222
- * is in progress (there are still steps to run) and one step has finished and submitted
1223
- * its result to QStash
1224
- *
1225
- * @param parallelStepCount number of steps to run in parallel
1226
- * @param initialStepCount steps after the parallel invocation
1227
- * @returns parallel call state
1228
- */
1229
- protected getParallelCallState(parallelStepCount: number, initialStepCount: number): ParallelCallState;
1230
- /**
1231
- * sends the steps to QStash as batch
1232
- *
1233
- * @param steps steps to send
1234
- */
1235
- private submitStepsToQstash;
1236
- /**
1237
- * Get the promise by executing the lazt steps list. If there is a single
1238
- * step, we call `runSingle`. Otherwise `runParallel` is called.
1239
- *
1240
- * @param lazyStepList steps list to execute
1241
- * @returns promise corresponding to the execution
1242
- */
1243
- private getExecutionPromise;
1244
- /**
1245
- * @param lazyStepList steps we executed
1246
- * @param result result of the promise from `getExecutionPromise`
1247
- * @param index index of the current step
1248
- * @returns result[index] if lazyStepList > 1, otherwise result
1249
- */
1250
- private static getResult;
1251
- private deferExecution;
1252
- }
1253
-
1254
- declare class WorkflowContext<TInitialPayload = unknown> {
1255
- protected readonly executor: AutoExecutor;
1256
- readonly client: Client;
1257
- readonly workflowRunId: string;
1258
- readonly steps: Step[];
1259
- readonly nonPlanStepCount: number;
1260
- readonly url: string;
1261
- readonly requestPayload: TInitialPayload;
1262
- readonly headers: Headers;
1263
- constructor({ client, workflowRunId, initialPayload, headers, steps, url, debug, }: {
1264
- client: Client;
1265
- workflowRunId: string;
1266
- initialPayload: TInitialPayload;
1267
- headers: Headers;
1268
- steps: Step[];
1269
- url: string;
1270
- debug?: WorkflowLogger;
1271
- });
1272
- /**
1273
- * Executes a workflow step
1274
- *
1275
- * ```typescript
1276
- * const result = await context.run("step 1", async () => {
1277
- * return await Promise.resolve("result")
1278
- * })
1279
- * ```
1280
- *
1281
- * Can also be called in parallel and the steps will be executed
1282
- * simulatenously:
1283
- *
1284
- * ```typescript
1285
- * const [result1, result2] = await Promise.all([
1286
- * context.run("step 1", async () => {
1287
- * return await Promise.resolve("result1")
1288
- * })
1289
- * context.run("step 2", async () => {
1290
- * return await Promise.resolve("result2")
1291
- * })
1292
- * ])
1293
- * ```
1294
- *
1295
- * @param stepName name of the step
1296
- * @param stepFunction step function to be executed
1297
- * @returns result of the step function
1298
- */
1299
- run<TResult>(stepName: string, stepFunction: AsyncStepFunction<TResult>): Promise<TResult>;
1300
- /**
1301
- * Stops the execution for the duration provided.
1302
- *
1303
- * @param stepName
1304
- * @param duration sleep duration in seconds
1305
- * @returns
1306
- */
1307
- sleep(stepName: string, duration: number): Promise<void>;
1308
- /**
1309
- * Stops the execution until the date time provided.
1310
- *
1311
- * @param stepName
1312
- * @param datetime time to sleep until. Can be provided as a number (in unix seconds),
1313
- * as a Date object or a string (passed to `new Date(datetimeString)`)
1314
- * @returns
1315
- */
1316
- sleepUntil(stepName: string, datetime: Date | string | number): Promise<void>;
1317
- call<TResult = unknown, TBody = unknown>(stepName: string, url: string, method: HTTPMethods, body?: TBody, headers?: Record<string, string>): Promise<TResult>;
1318
- }
1319
-
1320
- declare const StepTypes: readonly ["Initial", "Run", "SleepFor", "SleepUntil", "Call"];
1321
- type StepType = (typeof StepTypes)[number];
1322
- type ThirdPartyCallFields<TBody = unknown> = {
1323
- /**
1324
- * Third party call URL. Set when context.call is used.
1325
- */
1326
- callUrl: string;
1327
- /**
1328
- * Third party call method. Set when context.call is used.
1329
- */
1330
- callMethod: HTTPMethods;
1331
- /**
1332
- * Third party call body. Set when context.call is used.
1333
- */
1334
- callBody: TBody;
1335
- /**
1336
- * Third party call headers. Set when context.call is used.
1337
- */
1338
- callHeaders: Record<string, string>;
1339
- };
1340
- type Step<TResult = unknown, TBody = unknown> = {
1341
- /**
1342
- * index of the step
1343
- */
1344
- stepId: number;
1345
- /**
1346
- * name of the step
1347
- */
1348
- stepName: string;
1349
- /**
1350
- * type of the step (Initial/Run/SleepFor/SleepUntil/Call)
1351
- */
1352
- stepType: StepType;
1353
- /**
1354
- * step result. Set if context.run or context.call are used.
1355
- */
1356
- out?: TResult;
1357
- /**
1358
- * sleep duration in seconds. Set when context.sleep is used.
1359
- */
1360
- sleepFor?: number;
1361
- /**
1362
- * unix timestamp (in seconds) to wait until. Set when context.sleepUntil is used.
1363
- */
1364
- sleepUntil?: number;
1365
- /**
1366
- * number of steps running concurrently if the step is in a parallel run.
1367
- * Set to 1 if step is not parallel.
1368
- */
1369
- concurrent: number;
1370
- /**
1371
- * target step of a plan step. In other words, the step to assign the
1372
- * result of a plan step.
1373
- *
1374
- * Set to 0 if the step is not a plan step (of a parallel run). Otherwise,
1375
- * set to the target step.
1376
- */
1377
- targetStep: number;
1378
- } & (ThirdPartyCallFields<TBody> | {
1379
- [P in keyof ThirdPartyCallFields]?: never;
1380
- });
1381
- type RawStep = {
1382
- messageId: string;
1383
- body: string;
1384
- callType: "step" | "toCallback" | "fromCallback";
1385
- };
1386
- type SyncStepFunction<TResult> = () => TResult;
1387
- type AsyncStepFunction<TResult> = () => Promise<TResult>;
1388
- type StepFunction<TResult> = AsyncStepFunction<TResult> | SyncStepFunction<TResult>;
1389
- type ParallelCallState = "first" | "partial" | "discard" | "last";
1390
- type WorkflowServeParameters<TInitialPayload, TResponse = Response> = {
1391
- routeFunction: (context: WorkflowContext<TInitialPayload>) => Promise<void>;
1392
- options?: WorkflowServeOptions<TResponse, TInitialPayload>;
1393
- };
1394
- type ReceiverOption = Receiver | false;
1395
- /**
1396
- * Not all frameworks use env variables like nextjs does. In this case, we need
1397
- * to be able to get the client and receiver explicitly.
1398
- *
1399
- * In this case, we extend the WorkflowServeParameters by requiring an explicit
1400
- * client & receiever parameters and removing client & receiever from options.
1401
- */
1402
- type WorkflowServeParametersExtended<TInitialPayload = unknown, TResponse = Response> = Pick<WorkflowServeParameters<TInitialPayload, TResponse>, "routeFunction"> & {
1403
- client: Client;
1404
- receiver: ReceiverOption;
1405
- options?: Omit<WorkflowServeOptions<TResponse, TInitialPayload>, "client" | "receiver">;
1406
- };
1407
- /**
1408
- * Function parsing initial payload from string to an object
1409
- */
1410
- type InitialPayloadParser<TInitialPayload = unknown> = (initialPayload: string) => TInitialPayload;
1411
- type WorkflowServeOptions<TResponse = Response, TInitialPayload = unknown> = {
1412
- /**
1413
- * QStash client
1414
- */
1415
- client?: Client;
1416
- /**
1417
- * Function called to return a response after each step execution
1418
- *
1419
- * @param workflowRunId
1420
- * @returns response
1421
- */
1422
- onStepFinish?: (workflowRunId: string) => TResponse;
1423
- /**
1424
- * Function to parse the initial payload passed by the user
1425
- */
1426
- initialPayloadParser?: InitialPayloadParser<TInitialPayload>;
1427
- /**
1428
- * Url of the endpoint where the workflow is set up.
1429
- *
1430
- * If not set, url will be inferred from the request.
1431
- */
1432
- url?: string;
1433
- /**
1434
- * Verbose mode
1435
- *
1436
- * Disabled if set to false. If set to true, a logger is created automatically.
1437
- *
1438
- * Alternatively, a WorkflowLogger can be passed.
1439
- *
1440
- * Disabled by default
1441
- */
1442
- verbose?: WorkflowLogger | boolean;
1443
- /**
1444
- * Receiver to verify requests coming from QStash
1445
- *
1446
- * All requests except the first invocation are verified.
1447
- *
1448
- * Enabled by default. A receiver is created from the env variables
1449
- * QSTASH_CURRENT_SIGNING_KEY and QSTASH_NEXT_SIGNING_KEY.
1450
- */
1451
- receiver?: ReceiverOption;
1452
- };
1453
-
1454
- export { WorkflowContext as $, type AddEndpointsRequest as A, type BodyInit as B, type ChatRateLimit as C, type ChatCompletion as D, type EventsRequest as E, type ChatCompletionChunk as F, type GetEventsResponse as G, type HTTPMethods as H, type StreamEnabled as I, type StreamDisabled as J, type StreamParameter as K, type PromptChatRequest as L, type Message as M, type ChatRequest as N, type OpenAIChatModel as O, type PublishBatchRequest as P, type QueueRequest as Q, type RateLimit as R, type Step as S, custom as T, type UrlGroup as U, type VerifyRequest as V, type WithCursor as W, openai as X, upstash as Y, type ProviderReturnType as Z, type WorkflowServeParameters as _, type ReceiverConfig as a, StepTypes as a0, type StepType as a1, type RawStep as a2, type SyncStepFunction as a3, type AsyncStepFunction as a4, type StepFunction as a5, type ParallelCallState as a6, type WorkflowServeParametersExtended as a7, type InitialPayloadParser as a8, type WorkflowServeOptions as a9, type LogLevel as aa, type WorkflowLoggerOptions as ab, WorkflowLogger as ac, SignatureError as b, Receiver as c, type PublishRequest as d, type PublishJsonRequest as e, Client as f, type PublishToApiResponse as g, type PublishToUrlResponse as h, type PublishToUrlGroupsResponse as i, type PublishResponse as j, type MessagePayload as k, Messages as l, type Schedule as m, type CreateScheduleRequest as n, Schedules as o, type Endpoint as p, type RemoveEndpointsRequest as q, UrlGroups as r, type State as s, type Event as t, type EventPayload as u, type GetEventsPayload as v, type HeadersInit as w, type RequestOptions as x, Chat as y, type ChatCompletionMessage as z };