@upstash/qstash 2.1.9 → 2.1.11

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.
@@ -109,4 +109,3 @@ var Receiver = class {
109
109
 
110
110
 
111
111
  exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__async = __async; exports.__forAwait = __forAwait; exports.SignatureError = SignatureError; exports.Receiver = Receiver;
112
- //# sourceMappingURL=chunk-EQTYEU4U.js.map
@@ -109,4 +109,3 @@ export {
109
109
  SignatureError,
110
110
  Receiver
111
111
  };
112
- //# sourceMappingURL=chunk-G4FL5XMG.mjs.map
package/dist/index.d.mts CHANGED
@@ -113,73 +113,6 @@ type RetryConfig = false | {
113
113
  backoff?: (retryCount: number) => number;
114
114
  };
115
115
 
116
- type Endpoint = {
117
- /**
118
- * The name of the endpoint (optional)
119
- */
120
- name?: string;
121
- /**
122
- * The url of the endpoint
123
- */
124
- url: string;
125
- };
126
- type AddEndpointsRequest = {
127
- /**
128
- * The name of the topic.
129
- * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
130
- */
131
- name: string;
132
- endpoints: Endpoint[];
133
- };
134
- type RemoveEndpointsRequest = {
135
- /**
136
- * The name of the topic.
137
- * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
138
- */
139
- name: string;
140
- endpoints: ({
141
- name: string;
142
- url?: string;
143
- } | {
144
- name?: string;
145
- url: string;
146
- })[];
147
- };
148
- type Topic = {
149
- /**
150
- * The name of this topic.
151
- */
152
- name: string;
153
- /**
154
- * A list of all subscribed endpoints
155
- */
156
- endpoints: Endpoint[];
157
- };
158
- declare class Topics {
159
- private readonly http;
160
- constructor(http: Requester);
161
- /**
162
- * Create a new topic with the given name and endpoints
163
- */
164
- addEndpoints(req: AddEndpointsRequest): Promise<void>;
165
- /**
166
- * Remove endpoints from a topic.
167
- */
168
- removeEndpoints(req: RemoveEndpointsRequest): Promise<void>;
169
- /**
170
- * Get a list of all topics.
171
- */
172
- list(): Promise<Topic[]>;
173
- /**
174
- * Get a single topic
175
- */
176
- get(name: string): Promise<Topic>;
177
- /**
178
- * Delete a topic
179
- */
180
- delete(name: string): Promise<void>;
181
- }
182
-
183
116
  type Message = {
184
117
  /**
185
118
  * A unique identifier for this message.
@@ -214,13 +147,17 @@ type Message = {
214
147
  */
215
148
  notBefore?: number;
216
149
  /**
217
- * A unix timestamp (milliseconds) when this messages was crated.
150
+ * A unix timestamp (milliseconds) when this messages was created.
218
151
  */
219
152
  createdAt: number;
220
153
  /**
221
154
  * The callback url if configured.
222
155
  */
223
156
  callback?: string;
157
+ /**
158
+ * The failure callback url if configured.
159
+ */
160
+ failureCallback?: string;
224
161
  };
225
162
  declare class Messages {
226
163
  private readonly http;
@@ -235,6 +172,27 @@ declare class Messages {
235
172
  delete(messageId: string): Promise<void>;
236
173
  }
237
174
 
175
+ type DlqMessage = Message & {
176
+ dlqId: string;
177
+ };
178
+ declare class DLQ {
179
+ private readonly http;
180
+ constructor(http: Requester);
181
+ /**
182
+ * List messages in the dlq
183
+ */
184
+ listMessages(opts?: {
185
+ cursor?: string;
186
+ }): Promise<{
187
+ messages: DlqMessage[];
188
+ cursor?: string;
189
+ }>;
190
+ /**
191
+ * Remove a message from the dlq using it's `dlqId`
192
+ */
193
+ delete(dlqMessageId: string): Promise<void>;
194
+ }
195
+
238
196
  type Schedule = {
239
197
  scheduleId: string;
240
198
  cron: string;
@@ -246,6 +204,7 @@ type Schedule = {
246
204
  retries: number;
247
205
  delay?: number;
248
206
  callback?: string;
207
+ failureCallback?: string;
249
208
  };
250
209
  type CreateScheduleRequest = {
251
210
  /**
@@ -277,7 +236,7 @@ type CreateScheduleRequest = {
277
236
  */
278
237
  delay?: number;
279
238
  /**
280
- * In case your destination server is unavaialble or returns a status code outside of the 200-299
239
+ * In case your destination server is unavailable or returns a status code outside of the 200-299
281
240
  * range, we will retry the request after a certain amount of time.
282
241
  *
283
242
  * Configure how many times you would like the delivery to be retried
@@ -293,6 +252,14 @@ type CreateScheduleRequest = {
293
252
  * @default undefined
294
253
  */
295
254
  callback?: string;
255
+ /**
256
+ * Use a failure callback url to handle messages that could not be delivered.
257
+ *
258
+ * The failure callback url must be publicly accessible
259
+ *
260
+ * @default undefined
261
+ */
262
+ failureCallback?: string;
296
263
  /**
297
264
  * The method to use when sending a request to your API
298
265
  *
@@ -327,6 +294,73 @@ declare class Schedules {
327
294
  delete(scheduleId: string): Promise<void>;
328
295
  }
329
296
 
297
+ type Endpoint = {
298
+ /**
299
+ * The name of the endpoint (optional)
300
+ */
301
+ name?: string;
302
+ /**
303
+ * The url of the endpoint
304
+ */
305
+ url: string;
306
+ };
307
+ type AddEndpointsRequest = {
308
+ /**
309
+ * The name of the topic.
310
+ * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
311
+ */
312
+ name: string;
313
+ endpoints: Endpoint[];
314
+ };
315
+ type RemoveEndpointsRequest = {
316
+ /**
317
+ * The name of the topic.
318
+ * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
319
+ */
320
+ name: string;
321
+ endpoints: ({
322
+ name: string;
323
+ url?: string;
324
+ } | {
325
+ name?: string;
326
+ url: string;
327
+ })[];
328
+ };
329
+ type Topic = {
330
+ /**
331
+ * The name of this topic.
332
+ */
333
+ name: string;
334
+ /**
335
+ * A list of all subscribed endpoints
336
+ */
337
+ endpoints: Endpoint[];
338
+ };
339
+ declare class Topics {
340
+ private readonly http;
341
+ constructor(http: Requester);
342
+ /**
343
+ * Create a new topic with the given name and endpoints
344
+ */
345
+ addEndpoints(req: AddEndpointsRequest): Promise<void>;
346
+ /**
347
+ * Remove endpoints from a topic.
348
+ */
349
+ removeEndpoints(req: RemoveEndpointsRequest): Promise<void>;
350
+ /**
351
+ * Get a list of all topics.
352
+ */
353
+ list(): Promise<Topic[]>;
354
+ /**
355
+ * Get a single topic
356
+ */
357
+ get(name: string): Promise<Topic>;
358
+ /**
359
+ * Delete a topic
360
+ */
361
+ delete(name: string): Promise<void>;
362
+ }
363
+
330
364
  type State = "CREATED" | "ACTIVE" | "DELIVERED" | "ERROR" | "RETRY" | "FAILED";
331
365
  type Event = {
332
366
  time: number;
@@ -342,27 +376,6 @@ type WithCursor<T> = T & {
342
376
  cursor?: number;
343
377
  };
344
378
 
345
- type DlqMessage = Message & {
346
- dlqId: string;
347
- };
348
- declare class DLQ {
349
- private readonly http;
350
- constructor(http: Requester);
351
- /**
352
- * List messages in the dlq
353
- */
354
- listMessages(opts?: {
355
- cursor?: string;
356
- }): Promise<{
357
- messages: DlqMessage[];
358
- cursor?: string;
359
- }>;
360
- /**
361
- * Remove a message from the dlq using it's `dlqId`
362
- */
363
- delete(dlqMessageId: string): Promise<void>;
364
- }
365
-
366
379
  type ClientConfig = {
367
380
  /**
368
381
  * Url of the qstash api server.
@@ -461,6 +474,14 @@ type PublishRequest<TBody = BodyInit> = {
461
474
  * @default undefined
462
475
  */
463
476
  callback?: string;
477
+ /**
478
+ * Use a failure callback url to handle messages that could not be delivered.
479
+ *
480
+ * The failure callback url must be publicly accessible
481
+ *
482
+ * @default undefined
483
+ */
484
+ failureCallback?: string;
464
485
  /**
465
486
  * The method to use when sending a request to your API
466
487
  *
package/dist/index.d.ts CHANGED
@@ -113,73 +113,6 @@ type RetryConfig = false | {
113
113
  backoff?: (retryCount: number) => number;
114
114
  };
115
115
 
116
- type Endpoint = {
117
- /**
118
- * The name of the endpoint (optional)
119
- */
120
- name?: string;
121
- /**
122
- * The url of the endpoint
123
- */
124
- url: string;
125
- };
126
- type AddEndpointsRequest = {
127
- /**
128
- * The name of the topic.
129
- * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
130
- */
131
- name: string;
132
- endpoints: Endpoint[];
133
- };
134
- type RemoveEndpointsRequest = {
135
- /**
136
- * The name of the topic.
137
- * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
138
- */
139
- name: string;
140
- endpoints: ({
141
- name: string;
142
- url?: string;
143
- } | {
144
- name?: string;
145
- url: string;
146
- })[];
147
- };
148
- type Topic = {
149
- /**
150
- * The name of this topic.
151
- */
152
- name: string;
153
- /**
154
- * A list of all subscribed endpoints
155
- */
156
- endpoints: Endpoint[];
157
- };
158
- declare class Topics {
159
- private readonly http;
160
- constructor(http: Requester);
161
- /**
162
- * Create a new topic with the given name and endpoints
163
- */
164
- addEndpoints(req: AddEndpointsRequest): Promise<void>;
165
- /**
166
- * Remove endpoints from a topic.
167
- */
168
- removeEndpoints(req: RemoveEndpointsRequest): Promise<void>;
169
- /**
170
- * Get a list of all topics.
171
- */
172
- list(): Promise<Topic[]>;
173
- /**
174
- * Get a single topic
175
- */
176
- get(name: string): Promise<Topic>;
177
- /**
178
- * Delete a topic
179
- */
180
- delete(name: string): Promise<void>;
181
- }
182
-
183
116
  type Message = {
184
117
  /**
185
118
  * A unique identifier for this message.
@@ -214,13 +147,17 @@ type Message = {
214
147
  */
215
148
  notBefore?: number;
216
149
  /**
217
- * A unix timestamp (milliseconds) when this messages was crated.
150
+ * A unix timestamp (milliseconds) when this messages was created.
218
151
  */
219
152
  createdAt: number;
220
153
  /**
221
154
  * The callback url if configured.
222
155
  */
223
156
  callback?: string;
157
+ /**
158
+ * The failure callback url if configured.
159
+ */
160
+ failureCallback?: string;
224
161
  };
225
162
  declare class Messages {
226
163
  private readonly http;
@@ -235,6 +172,27 @@ declare class Messages {
235
172
  delete(messageId: string): Promise<void>;
236
173
  }
237
174
 
175
+ type DlqMessage = Message & {
176
+ dlqId: string;
177
+ };
178
+ declare class DLQ {
179
+ private readonly http;
180
+ constructor(http: Requester);
181
+ /**
182
+ * List messages in the dlq
183
+ */
184
+ listMessages(opts?: {
185
+ cursor?: string;
186
+ }): Promise<{
187
+ messages: DlqMessage[];
188
+ cursor?: string;
189
+ }>;
190
+ /**
191
+ * Remove a message from the dlq using it's `dlqId`
192
+ */
193
+ delete(dlqMessageId: string): Promise<void>;
194
+ }
195
+
238
196
  type Schedule = {
239
197
  scheduleId: string;
240
198
  cron: string;
@@ -246,6 +204,7 @@ type Schedule = {
246
204
  retries: number;
247
205
  delay?: number;
248
206
  callback?: string;
207
+ failureCallback?: string;
249
208
  };
250
209
  type CreateScheduleRequest = {
251
210
  /**
@@ -277,7 +236,7 @@ type CreateScheduleRequest = {
277
236
  */
278
237
  delay?: number;
279
238
  /**
280
- * In case your destination server is unavaialble or returns a status code outside of the 200-299
239
+ * In case your destination server is unavailable or returns a status code outside of the 200-299
281
240
  * range, we will retry the request after a certain amount of time.
282
241
  *
283
242
  * Configure how many times you would like the delivery to be retried
@@ -293,6 +252,14 @@ type CreateScheduleRequest = {
293
252
  * @default undefined
294
253
  */
295
254
  callback?: string;
255
+ /**
256
+ * Use a failure callback url to handle messages that could not be delivered.
257
+ *
258
+ * The failure callback url must be publicly accessible
259
+ *
260
+ * @default undefined
261
+ */
262
+ failureCallback?: string;
296
263
  /**
297
264
  * The method to use when sending a request to your API
298
265
  *
@@ -327,6 +294,73 @@ declare class Schedules {
327
294
  delete(scheduleId: string): Promise<void>;
328
295
  }
329
296
 
297
+ type Endpoint = {
298
+ /**
299
+ * The name of the endpoint (optional)
300
+ */
301
+ name?: string;
302
+ /**
303
+ * The url of the endpoint
304
+ */
305
+ url: string;
306
+ };
307
+ type AddEndpointsRequest = {
308
+ /**
309
+ * The name of the topic.
310
+ * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
311
+ */
312
+ name: string;
313
+ endpoints: Endpoint[];
314
+ };
315
+ type RemoveEndpointsRequest = {
316
+ /**
317
+ * The name of the topic.
318
+ * Must be unique and only contain alphanumeric, hyphen, underscore and periods.
319
+ */
320
+ name: string;
321
+ endpoints: ({
322
+ name: string;
323
+ url?: string;
324
+ } | {
325
+ name?: string;
326
+ url: string;
327
+ })[];
328
+ };
329
+ type Topic = {
330
+ /**
331
+ * The name of this topic.
332
+ */
333
+ name: string;
334
+ /**
335
+ * A list of all subscribed endpoints
336
+ */
337
+ endpoints: Endpoint[];
338
+ };
339
+ declare class Topics {
340
+ private readonly http;
341
+ constructor(http: Requester);
342
+ /**
343
+ * Create a new topic with the given name and endpoints
344
+ */
345
+ addEndpoints(req: AddEndpointsRequest): Promise<void>;
346
+ /**
347
+ * Remove endpoints from a topic.
348
+ */
349
+ removeEndpoints(req: RemoveEndpointsRequest): Promise<void>;
350
+ /**
351
+ * Get a list of all topics.
352
+ */
353
+ list(): Promise<Topic[]>;
354
+ /**
355
+ * Get a single topic
356
+ */
357
+ get(name: string): Promise<Topic>;
358
+ /**
359
+ * Delete a topic
360
+ */
361
+ delete(name: string): Promise<void>;
362
+ }
363
+
330
364
  type State = "CREATED" | "ACTIVE" | "DELIVERED" | "ERROR" | "RETRY" | "FAILED";
331
365
  type Event = {
332
366
  time: number;
@@ -342,27 +376,6 @@ type WithCursor<T> = T & {
342
376
  cursor?: number;
343
377
  };
344
378
 
345
- type DlqMessage = Message & {
346
- dlqId: string;
347
- };
348
- declare class DLQ {
349
- private readonly http;
350
- constructor(http: Requester);
351
- /**
352
- * List messages in the dlq
353
- */
354
- listMessages(opts?: {
355
- cursor?: string;
356
- }): Promise<{
357
- messages: DlqMessage[];
358
- cursor?: string;
359
- }>;
360
- /**
361
- * Remove a message from the dlq using it's `dlqId`
362
- */
363
- delete(dlqMessageId: string): Promise<void>;
364
- }
365
-
366
379
  type ClientConfig = {
367
380
  /**
368
381
  * Url of the qstash api server.
@@ -461,6 +474,14 @@ type PublishRequest<TBody = BodyInit> = {
461
474
  * @default undefined
462
475
  */
463
476
  callback?: string;
477
+ /**
478
+ * Use a failure callback url to handle messages that could not be delivered.
479
+ *
480
+ * The failure callback url must be publicly accessible
481
+ *
482
+ * @default undefined
483
+ */
484
+ failureCallback?: string;
464
485
  /**
465
486
  * The method to use when sending a request to your API
466
487
  *