runlater-js 0.2.0 → 0.4.0

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/dist/index.d.mts CHANGED
@@ -11,6 +11,8 @@ interface SendOptions {
11
11
  queue?: string;
12
12
  callback?: string;
13
13
  idempotencyKey?: string;
14
+ on_failure_url?: string;
15
+ on_recovery_url?: string;
14
16
  }
15
17
  interface DelayOptions extends SendOptions {
16
18
  delay: string | number;
@@ -29,6 +31,8 @@ interface CronOptions {
29
31
  queue?: string;
30
32
  callback?: string;
31
33
  enabled?: boolean;
34
+ on_failure_url?: string;
35
+ on_recovery_url?: string;
32
36
  }
33
37
  interface TaskResponse {
34
38
  task_id: string;
@@ -64,6 +68,8 @@ interface Task {
64
68
  queue: string | null;
65
69
  notify_on_failure: boolean | null;
66
70
  notify_on_recovery: boolean | null;
71
+ on_failure_url: string | null;
72
+ on_recovery_url: string | null;
67
73
  next_run_at: string | null;
68
74
  inserted_at: string;
69
75
  updated_at: string;
@@ -108,11 +114,33 @@ interface Monitor {
108
114
  enabled: boolean;
109
115
  notify_on_failure: boolean | null;
110
116
  notify_on_recovery: boolean | null;
117
+ on_failure_url: string | null;
118
+ on_recovery_url: string | null;
111
119
  last_ping_at: string | null;
112
120
  next_expected_at: string | null;
113
121
  inserted_at: string;
114
122
  updated_at: string;
115
123
  }
124
+ interface BatchOptions {
125
+ url: string;
126
+ queue: string;
127
+ items: unknown[];
128
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
129
+ headers?: Record<string, string>;
130
+ run_at?: string | Date;
131
+ delay?: string | number;
132
+ timeout?: number;
133
+ retries?: number;
134
+ callback?: string;
135
+ }
136
+ interface BatchResponse {
137
+ queue: string;
138
+ created: number;
139
+ scheduled_for: string;
140
+ }
141
+ interface CancelQueueResponse {
142
+ cancelled: number;
143
+ }
116
144
  interface UpdateTaskOptions {
117
145
  name?: string;
118
146
  url?: string;
@@ -128,6 +156,8 @@ interface UpdateTaskOptions {
128
156
  enabled?: boolean;
129
157
  notify_on_failure?: boolean | null;
130
158
  notify_on_recovery?: boolean | null;
159
+ on_failure_url?: string;
160
+ on_recovery_url?: string;
131
161
  expected_status_codes?: string;
132
162
  expected_body_pattern?: string;
133
163
  }
@@ -137,6 +167,8 @@ interface CreateMonitorOptions {
137
167
  interval?: number;
138
168
  grace?: number;
139
169
  enabled?: boolean;
170
+ on_failure_url?: string;
171
+ on_recovery_url?: string;
140
172
  }
141
173
  interface UpdateMonitorOptions {
142
174
  name?: string;
@@ -147,6 +179,8 @@ interface UpdateMonitorOptions {
147
179
  enabled?: boolean;
148
180
  notify_on_failure?: boolean | null;
149
181
  notify_on_recovery?: boolean | null;
182
+ on_failure_url?: string;
183
+ on_recovery_url?: string;
150
184
  }
151
185
  interface Ping {
152
186
  id: string;
@@ -267,6 +301,37 @@ declare class Tasks {
267
301
  trigger(id: string): Promise<TriggerResponse>;
268
302
  update(id: string, options: UpdateTaskOptions): Promise<Task>;
269
303
  executions(id: string, limit?: number): Promise<Execution[]>;
304
+ /**
305
+ * Create many tasks at once with shared configuration.
306
+ *
307
+ * Each item in the array becomes the request body for one task.
308
+ * All tasks share the same URL, method, headers, timing, and queue.
309
+ * Use the queue name with `cancelQueue()` to cancel them as a group.
310
+ *
311
+ * ```js
312
+ * await rl.tasks.batch({
313
+ * url: "https://myapp.com/api/send-email",
314
+ * queue: "march-newsletter",
315
+ * run_at: "2026-03-01T09:00:00Z",
316
+ * items: [
317
+ * { to: "user1@example.com", name: "Alice" },
318
+ * { to: "user2@example.com", name: "Bob" },
319
+ * ]
320
+ * })
321
+ * ```
322
+ */
323
+ batch(options: BatchOptions): Promise<BatchResponse>;
324
+ /**
325
+ * Cancel all tasks in a queue.
326
+ *
327
+ * Soft-deletes every task in the queue and removes their pending executions.
328
+ *
329
+ * ```js
330
+ * const { cancelled } = await rl.tasks.cancelQueue("march-newsletter")
331
+ * console.log(`Cancelled ${cancelled} tasks`)
332
+ * ```
333
+ */
334
+ cancelQueue(queue: string): Promise<CancelQueueResponse>;
270
335
  }
271
336
  declare class Monitors {
272
337
  private client;
@@ -280,4 +345,4 @@ declare class Monitors {
280
345
  ping(token: string): Promise<PingResponse>;
281
346
  }
282
347
 
283
- export { type CreateMonitorOptions, type CronOptions, type CronResponse, type DelayOptions, type Execution, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateMonitorOptions, type UpdateTaskOptions };
348
+ export { type BatchOptions, type BatchResponse, type CancelQueueResponse, type CreateMonitorOptions, type CronOptions, type CronResponse, type DelayOptions, type Execution, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateMonitorOptions, type UpdateTaskOptions };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,8 @@ interface SendOptions {
11
11
  queue?: string;
12
12
  callback?: string;
13
13
  idempotencyKey?: string;
14
+ on_failure_url?: string;
15
+ on_recovery_url?: string;
14
16
  }
15
17
  interface DelayOptions extends SendOptions {
16
18
  delay: string | number;
@@ -29,6 +31,8 @@ interface CronOptions {
29
31
  queue?: string;
30
32
  callback?: string;
31
33
  enabled?: boolean;
34
+ on_failure_url?: string;
35
+ on_recovery_url?: string;
32
36
  }
33
37
  interface TaskResponse {
34
38
  task_id: string;
@@ -64,6 +68,8 @@ interface Task {
64
68
  queue: string | null;
65
69
  notify_on_failure: boolean | null;
66
70
  notify_on_recovery: boolean | null;
71
+ on_failure_url: string | null;
72
+ on_recovery_url: string | null;
67
73
  next_run_at: string | null;
68
74
  inserted_at: string;
69
75
  updated_at: string;
@@ -108,11 +114,33 @@ interface Monitor {
108
114
  enabled: boolean;
109
115
  notify_on_failure: boolean | null;
110
116
  notify_on_recovery: boolean | null;
117
+ on_failure_url: string | null;
118
+ on_recovery_url: string | null;
111
119
  last_ping_at: string | null;
112
120
  next_expected_at: string | null;
113
121
  inserted_at: string;
114
122
  updated_at: string;
115
123
  }
124
+ interface BatchOptions {
125
+ url: string;
126
+ queue: string;
127
+ items: unknown[];
128
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
129
+ headers?: Record<string, string>;
130
+ run_at?: string | Date;
131
+ delay?: string | number;
132
+ timeout?: number;
133
+ retries?: number;
134
+ callback?: string;
135
+ }
136
+ interface BatchResponse {
137
+ queue: string;
138
+ created: number;
139
+ scheduled_for: string;
140
+ }
141
+ interface CancelQueueResponse {
142
+ cancelled: number;
143
+ }
116
144
  interface UpdateTaskOptions {
117
145
  name?: string;
118
146
  url?: string;
@@ -128,6 +156,8 @@ interface UpdateTaskOptions {
128
156
  enabled?: boolean;
129
157
  notify_on_failure?: boolean | null;
130
158
  notify_on_recovery?: boolean | null;
159
+ on_failure_url?: string;
160
+ on_recovery_url?: string;
131
161
  expected_status_codes?: string;
132
162
  expected_body_pattern?: string;
133
163
  }
@@ -137,6 +167,8 @@ interface CreateMonitorOptions {
137
167
  interval?: number;
138
168
  grace?: number;
139
169
  enabled?: boolean;
170
+ on_failure_url?: string;
171
+ on_recovery_url?: string;
140
172
  }
141
173
  interface UpdateMonitorOptions {
142
174
  name?: string;
@@ -147,6 +179,8 @@ interface UpdateMonitorOptions {
147
179
  enabled?: boolean;
148
180
  notify_on_failure?: boolean | null;
149
181
  notify_on_recovery?: boolean | null;
182
+ on_failure_url?: string;
183
+ on_recovery_url?: string;
150
184
  }
151
185
  interface Ping {
152
186
  id: string;
@@ -267,6 +301,37 @@ declare class Tasks {
267
301
  trigger(id: string): Promise<TriggerResponse>;
268
302
  update(id: string, options: UpdateTaskOptions): Promise<Task>;
269
303
  executions(id: string, limit?: number): Promise<Execution[]>;
304
+ /**
305
+ * Create many tasks at once with shared configuration.
306
+ *
307
+ * Each item in the array becomes the request body for one task.
308
+ * All tasks share the same URL, method, headers, timing, and queue.
309
+ * Use the queue name with `cancelQueue()` to cancel them as a group.
310
+ *
311
+ * ```js
312
+ * await rl.tasks.batch({
313
+ * url: "https://myapp.com/api/send-email",
314
+ * queue: "march-newsletter",
315
+ * run_at: "2026-03-01T09:00:00Z",
316
+ * items: [
317
+ * { to: "user1@example.com", name: "Alice" },
318
+ * { to: "user2@example.com", name: "Bob" },
319
+ * ]
320
+ * })
321
+ * ```
322
+ */
323
+ batch(options: BatchOptions): Promise<BatchResponse>;
324
+ /**
325
+ * Cancel all tasks in a queue.
326
+ *
327
+ * Soft-deletes every task in the queue and removes their pending executions.
328
+ *
329
+ * ```js
330
+ * const { cancelled } = await rl.tasks.cancelQueue("march-newsletter")
331
+ * console.log(`Cancelled ${cancelled} tasks`)
332
+ * ```
333
+ */
334
+ cancelQueue(queue: string): Promise<CancelQueueResponse>;
270
335
  }
271
336
  declare class Monitors {
272
337
  private client;
@@ -280,4 +345,4 @@ declare class Monitors {
280
345
  ping(token: string): Promise<PingResponse>;
281
346
  }
282
347
 
283
- export { type CreateMonitorOptions, type CronOptions, type CronResponse, type DelayOptions, type Execution, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateMonitorOptions, type UpdateTaskOptions };
348
+ export { type BatchOptions, type BatchResponse, type CancelQueueResponse, type CreateMonitorOptions, type CronOptions, type CronResponse, type DelayOptions, type Execution, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateMonitorOptions, type UpdateTaskOptions };
package/dist/index.js CHANGED
@@ -278,6 +278,64 @@ var Tasks = class {
278
278
  );
279
279
  return res.data;
280
280
  }
281
+ /**
282
+ * Create many tasks at once with shared configuration.
283
+ *
284
+ * Each item in the array becomes the request body for one task.
285
+ * All tasks share the same URL, method, headers, timing, and queue.
286
+ * Use the queue name with `cancelQueue()` to cancel them as a group.
287
+ *
288
+ * ```js
289
+ * await rl.tasks.batch({
290
+ * url: "https://myapp.com/api/send-email",
291
+ * queue: "march-newsletter",
292
+ * run_at: "2026-03-01T09:00:00Z",
293
+ * items: [
294
+ * { to: "user1@example.com", name: "Alice" },
295
+ * { to: "user2@example.com", name: "Bob" },
296
+ * ]
297
+ * })
298
+ * ```
299
+ */
300
+ async batch(options) {
301
+ const body = {
302
+ url: options.url,
303
+ queue: options.queue,
304
+ items: options.items,
305
+ method: options.method ?? "POST",
306
+ headers: options.headers,
307
+ timeout_ms: options.timeout,
308
+ retry_attempts: options.retries,
309
+ callback_url: options.callback
310
+ };
311
+ if (options.run_at != null) {
312
+ body.run_at = options.run_at instanceof Date ? options.run_at.toISOString() : options.run_at;
313
+ }
314
+ if (options.delay != null) {
315
+ body.delay = formatDelay(options.delay);
316
+ }
317
+ const res = await this.client.request("POST", "/tasks/batch", {
318
+ body
319
+ });
320
+ return res.data;
321
+ }
322
+ /**
323
+ * Cancel all tasks in a queue.
324
+ *
325
+ * Soft-deletes every task in the queue and removes their pending executions.
326
+ *
327
+ * ```js
328
+ * const { cancelled } = await rl.tasks.cancelQueue("march-newsletter")
329
+ * console.log(`Cancelled ${cancelled} tasks`)
330
+ * ```
331
+ */
332
+ async cancelQueue(queue) {
333
+ const res = await this.client.request(
334
+ "DELETE",
335
+ `/tasks?queue=${encodeURIComponent(queue)}`
336
+ );
337
+ return res.data;
338
+ }
281
339
  };
282
340
  var Monitors = class {
283
341
  constructor(client) {
package/dist/index.mjs CHANGED
@@ -251,6 +251,64 @@ var Tasks = class {
251
251
  );
252
252
  return res.data;
253
253
  }
254
+ /**
255
+ * Create many tasks at once with shared configuration.
256
+ *
257
+ * Each item in the array becomes the request body for one task.
258
+ * All tasks share the same URL, method, headers, timing, and queue.
259
+ * Use the queue name with `cancelQueue()` to cancel them as a group.
260
+ *
261
+ * ```js
262
+ * await rl.tasks.batch({
263
+ * url: "https://myapp.com/api/send-email",
264
+ * queue: "march-newsletter",
265
+ * run_at: "2026-03-01T09:00:00Z",
266
+ * items: [
267
+ * { to: "user1@example.com", name: "Alice" },
268
+ * { to: "user2@example.com", name: "Bob" },
269
+ * ]
270
+ * })
271
+ * ```
272
+ */
273
+ async batch(options) {
274
+ const body = {
275
+ url: options.url,
276
+ queue: options.queue,
277
+ items: options.items,
278
+ method: options.method ?? "POST",
279
+ headers: options.headers,
280
+ timeout_ms: options.timeout,
281
+ retry_attempts: options.retries,
282
+ callback_url: options.callback
283
+ };
284
+ if (options.run_at != null) {
285
+ body.run_at = options.run_at instanceof Date ? options.run_at.toISOString() : options.run_at;
286
+ }
287
+ if (options.delay != null) {
288
+ body.delay = formatDelay(options.delay);
289
+ }
290
+ const res = await this.client.request("POST", "/tasks/batch", {
291
+ body
292
+ });
293
+ return res.data;
294
+ }
295
+ /**
296
+ * Cancel all tasks in a queue.
297
+ *
298
+ * Soft-deletes every task in the queue and removes their pending executions.
299
+ *
300
+ * ```js
301
+ * const { cancelled } = await rl.tasks.cancelQueue("march-newsletter")
302
+ * console.log(`Cancelled ${cancelled} tasks`)
303
+ * ```
304
+ */
305
+ async cancelQueue(queue) {
306
+ const res = await this.client.request(
307
+ "DELETE",
308
+ `/tasks?queue=${encodeURIComponent(queue)}`
309
+ );
310
+ return res.data;
311
+ }
254
312
  };
255
313
  var Monitors = class {
256
314
  constructor(client) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runlater-js",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Delayed tasks, cron jobs, and reliable webhooks. No infrastructure required.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",