runlater-js 0.10.0 → 0.11.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
@@ -184,10 +184,16 @@ interface Monitor {
184
184
  inserted_at: string;
185
185
  updated_at: string;
186
186
  }
187
- interface BatchOptions {
187
+ interface BatchTask {
188
188
  url: string;
189
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
190
+ headers?: Record<string, string>;
191
+ body?: unknown;
192
+ name?: string;
193
+ }
194
+ interface BatchOptions {
189
195
  queue: string;
190
- items: unknown[];
196
+ tasks: BatchTask[];
191
197
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
192
198
  headers?: Record<string, string>;
193
199
  run_at?: string | Date;
@@ -423,20 +429,20 @@ declare class Tasks {
423
429
  update(id: string, options: UpdateTaskOptions): Promise<Task>;
424
430
  executions(id: string, limit?: number): Promise<Execution[]>;
425
431
  /**
426
- * Create many tasks at once with shared configuration.
432
+ * Create many tasks at once. Each task defines its own URL and can
433
+ * optionally override method, headers, body, and name. Top-level
434
+ * settings serve as defaults.
427
435
  *
428
- * Each item in the array becomes the request body for one task.
429
- * All tasks share the same URL, method, headers, timing, and queue.
430
436
  * Use the queue name with `cancelQueue()` to cancel them as a group.
431
437
  *
432
438
  * ```js
433
439
  * await rl.tasks.batch({
434
- * url: "https://myapp.com/api/send-email",
435
440
  * queue: "march-newsletter",
441
+ * method: "POST",
436
442
  * run_at: "2026-03-01T09:00:00Z",
437
- * items: [
438
- * { to: "user1@example.com", name: "Alice" },
439
- * { to: "user2@example.com", name: "Bob" },
443
+ * tasks: [
444
+ * { url: "https://myapp.com/api/send-email", body: { to: "alice@example.com" } },
445
+ * { url: "https://myapp.com/api/send-sms", body: { to: "+1234567890" } },
440
446
  * ]
441
447
  * })
442
448
  * ```
@@ -490,4 +496,4 @@ declare class Endpoints {
490
496
  resume(id: string): Promise<Endpoint>;
491
497
  }
492
498
 
493
- export { type BatchOptions, type BatchResponse, type CancelQueueResponse, type CreateEndpointOptions, type CreateMonitorOptions, type CreateScheduleOptions, type CronOptions, type CronResponse, type DelayOptions, type Endpoint, type Execution, type InboundEvent, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type Schedule, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateEndpointOptions, type UpdateMonitorOptions, type UpdateScheduleOptions, type UpdateTaskOptions };
499
+ export { type BatchOptions, type BatchResponse, type BatchTask, type CancelQueueResponse, type CreateEndpointOptions, type CreateMonitorOptions, type CreateScheduleOptions, type CronOptions, type CronResponse, type DelayOptions, type Endpoint, type Execution, type InboundEvent, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type Schedule, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateEndpointOptions, type UpdateMonitorOptions, type UpdateScheduleOptions, type UpdateTaskOptions };
package/dist/index.d.ts CHANGED
@@ -184,10 +184,16 @@ interface Monitor {
184
184
  inserted_at: string;
185
185
  updated_at: string;
186
186
  }
187
- interface BatchOptions {
187
+ interface BatchTask {
188
188
  url: string;
189
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
190
+ headers?: Record<string, string>;
191
+ body?: unknown;
192
+ name?: string;
193
+ }
194
+ interface BatchOptions {
189
195
  queue: string;
190
- items: unknown[];
196
+ tasks: BatchTask[];
191
197
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
192
198
  headers?: Record<string, string>;
193
199
  run_at?: string | Date;
@@ -423,20 +429,20 @@ declare class Tasks {
423
429
  update(id: string, options: UpdateTaskOptions): Promise<Task>;
424
430
  executions(id: string, limit?: number): Promise<Execution[]>;
425
431
  /**
426
- * Create many tasks at once with shared configuration.
432
+ * Create many tasks at once. Each task defines its own URL and can
433
+ * optionally override method, headers, body, and name. Top-level
434
+ * settings serve as defaults.
427
435
  *
428
- * Each item in the array becomes the request body for one task.
429
- * All tasks share the same URL, method, headers, timing, and queue.
430
436
  * Use the queue name with `cancelQueue()` to cancel them as a group.
431
437
  *
432
438
  * ```js
433
439
  * await rl.tasks.batch({
434
- * url: "https://myapp.com/api/send-email",
435
440
  * queue: "march-newsletter",
441
+ * method: "POST",
436
442
  * run_at: "2026-03-01T09:00:00Z",
437
- * items: [
438
- * { to: "user1@example.com", name: "Alice" },
439
- * { to: "user2@example.com", name: "Bob" },
443
+ * tasks: [
444
+ * { url: "https://myapp.com/api/send-email", body: { to: "alice@example.com" } },
445
+ * { url: "https://myapp.com/api/send-sms", body: { to: "+1234567890" } },
440
446
  * ]
441
447
  * })
442
448
  * ```
@@ -490,4 +496,4 @@ declare class Endpoints {
490
496
  resume(id: string): Promise<Endpoint>;
491
497
  }
492
498
 
493
- export { type BatchOptions, type BatchResponse, type CancelQueueResponse, type CreateEndpointOptions, type CreateMonitorOptions, type CreateScheduleOptions, type CronOptions, type CronResponse, type DelayOptions, type Endpoint, type Execution, type InboundEvent, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type Schedule, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateEndpointOptions, type UpdateMonitorOptions, type UpdateScheduleOptions, type UpdateTaskOptions };
499
+ export { type BatchOptions, type BatchResponse, type BatchTask, type CancelQueueResponse, type CreateEndpointOptions, type CreateMonitorOptions, type CreateScheduleOptions, type CronOptions, type CronResponse, type DelayOptions, type Endpoint, type Execution, type InboundEvent, type ListOptions, type ListResponse, type Monitor, type Ping, type PingResponse, Runlater, RunlaterError, type RunlaterOptions, type Schedule, type ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateEndpointOptions, type UpdateMonitorOptions, type UpdateScheduleOptions, type UpdateTaskOptions };
package/dist/index.js CHANGED
@@ -222,7 +222,7 @@ var Runlater = class {
222
222
  const headers = {
223
223
  Authorization: `Bearer ${this.apiKey}`,
224
224
  "Content-Type": "application/json",
225
- "User-Agent": "runlater-js/0.1.0"
225
+ "User-Agent": "runlater-js/0.11.0"
226
226
  };
227
227
  if (options.idempotencyKey) {
228
228
  headers["Idempotency-Key"] = options.idempotencyKey;
@@ -287,29 +287,34 @@ var Tasks = class {
287
287
  return res.data;
288
288
  }
289
289
  /**
290
- * Create many tasks at once with shared configuration.
290
+ * Create many tasks at once. Each task defines its own URL and can
291
+ * optionally override method, headers, body, and name. Top-level
292
+ * settings serve as defaults.
291
293
  *
292
- * Each item in the array becomes the request body for one task.
293
- * All tasks share the same URL, method, headers, timing, and queue.
294
294
  * Use the queue name with `cancelQueue()` to cancel them as a group.
295
295
  *
296
296
  * ```js
297
297
  * await rl.tasks.batch({
298
- * url: "https://myapp.com/api/send-email",
299
298
  * queue: "march-newsletter",
299
+ * method: "POST",
300
300
  * run_at: "2026-03-01T09:00:00Z",
301
- * items: [
302
- * { to: "user1@example.com", name: "Alice" },
303
- * { to: "user2@example.com", name: "Bob" },
301
+ * tasks: [
302
+ * { url: "https://myapp.com/api/send-email", body: { to: "alice@example.com" } },
303
+ * { url: "https://myapp.com/api/send-sms", body: { to: "+1234567890" } },
304
304
  * ]
305
305
  * })
306
306
  * ```
307
307
  */
308
308
  async batch(options) {
309
309
  const body = {
310
- url: options.url,
311
310
  queue: options.queue,
312
- items: options.items,
311
+ tasks: options.tasks.map((t) => ({
312
+ url: t.url,
313
+ method: t.method,
314
+ headers: t.headers,
315
+ body: t.body != null ? typeof t.body === "string" ? t.body : JSON.stringify(t.body) : void 0,
316
+ name: t.name
317
+ })),
313
318
  method: options.method ?? "POST",
314
319
  headers: options.headers,
315
320
  timeout_ms: options.timeout,
package/dist/index.mjs CHANGED
@@ -195,7 +195,7 @@ var Runlater = class {
195
195
  const headers = {
196
196
  Authorization: `Bearer ${this.apiKey}`,
197
197
  "Content-Type": "application/json",
198
- "User-Agent": "runlater-js/0.1.0"
198
+ "User-Agent": "runlater-js/0.11.0"
199
199
  };
200
200
  if (options.idempotencyKey) {
201
201
  headers["Idempotency-Key"] = options.idempotencyKey;
@@ -260,29 +260,34 @@ var Tasks = class {
260
260
  return res.data;
261
261
  }
262
262
  /**
263
- * Create many tasks at once with shared configuration.
263
+ * Create many tasks at once. Each task defines its own URL and can
264
+ * optionally override method, headers, body, and name. Top-level
265
+ * settings serve as defaults.
264
266
  *
265
- * Each item in the array becomes the request body for one task.
266
- * All tasks share the same URL, method, headers, timing, and queue.
267
267
  * Use the queue name with `cancelQueue()` to cancel them as a group.
268
268
  *
269
269
  * ```js
270
270
  * await rl.tasks.batch({
271
- * url: "https://myapp.com/api/send-email",
272
271
  * queue: "march-newsletter",
272
+ * method: "POST",
273
273
  * run_at: "2026-03-01T09:00:00Z",
274
- * items: [
275
- * { to: "user1@example.com", name: "Alice" },
276
- * { to: "user2@example.com", name: "Bob" },
274
+ * tasks: [
275
+ * { url: "https://myapp.com/api/send-email", body: { to: "alice@example.com" } },
276
+ * { url: "https://myapp.com/api/send-sms", body: { to: "+1234567890" } },
277
277
  * ]
278
278
  * })
279
279
  * ```
280
280
  */
281
281
  async batch(options) {
282
282
  const body = {
283
- url: options.url,
284
283
  queue: options.queue,
285
- items: options.items,
284
+ tasks: options.tasks.map((t) => ({
285
+ url: t.url,
286
+ method: t.method,
287
+ headers: t.headers,
288
+ body: t.body != null ? typeof t.body === "string" ? t.body : JSON.stringify(t.body) : void 0,
289
+ name: t.name
290
+ })),
286
291
  method: options.method ?? "POST",
287
292
  headers: options.headers,
288
293
  timeout_ms: options.timeout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runlater-js",
3
- "version": "0.10.0",
3
+ "version": "0.11.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",