runlater-js 0.1.2 → 0.3.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 +60 -5
- package/dist/index.d.ts +60 -5
- package/dist/index.js +58 -0
- package/dist/index.mjs +58 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -58,11 +58,12 @@ interface Task {
|
|
|
58
58
|
cron_expression: string | null;
|
|
59
59
|
scheduled_at: string | null;
|
|
60
60
|
enabled: boolean;
|
|
61
|
-
muted: boolean;
|
|
62
61
|
timeout_ms: number;
|
|
63
62
|
retry_attempts: number;
|
|
64
63
|
callback_url: string | null;
|
|
65
64
|
queue: string | null;
|
|
65
|
+
notify_on_failure: boolean | null;
|
|
66
|
+
notify_on_recovery: boolean | null;
|
|
66
67
|
next_run_at: string | null;
|
|
67
68
|
inserted_at: string;
|
|
68
69
|
updated_at: string;
|
|
@@ -105,12 +106,33 @@ interface Monitor {
|
|
|
105
106
|
grace_period_seconds: number;
|
|
106
107
|
status: "new" | "up" | "down" | "paused";
|
|
107
108
|
enabled: boolean;
|
|
108
|
-
|
|
109
|
+
notify_on_failure: boolean | null;
|
|
110
|
+
notify_on_recovery: boolean | null;
|
|
109
111
|
last_ping_at: string | null;
|
|
110
112
|
next_expected_at: string | null;
|
|
111
113
|
inserted_at: string;
|
|
112
114
|
updated_at: string;
|
|
113
115
|
}
|
|
116
|
+
interface BatchOptions {
|
|
117
|
+
url: string;
|
|
118
|
+
queue: string;
|
|
119
|
+
items: unknown[];
|
|
120
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
121
|
+
headers?: Record<string, string>;
|
|
122
|
+
run_at?: string | Date;
|
|
123
|
+
delay?: string | number;
|
|
124
|
+
timeout?: number;
|
|
125
|
+
retries?: number;
|
|
126
|
+
callback?: string;
|
|
127
|
+
}
|
|
128
|
+
interface BatchResponse {
|
|
129
|
+
queue: string;
|
|
130
|
+
created: number;
|
|
131
|
+
scheduled_for: string;
|
|
132
|
+
}
|
|
133
|
+
interface CancelQueueResponse {
|
|
134
|
+
cancelled: number;
|
|
135
|
+
}
|
|
114
136
|
interface UpdateTaskOptions {
|
|
115
137
|
name?: string;
|
|
116
138
|
url?: string;
|
|
@@ -124,7 +146,8 @@ interface UpdateTaskOptions {
|
|
|
124
146
|
callback_url?: string;
|
|
125
147
|
queue?: string;
|
|
126
148
|
enabled?: boolean;
|
|
127
|
-
|
|
149
|
+
notify_on_failure?: boolean | null;
|
|
150
|
+
notify_on_recovery?: boolean | null;
|
|
128
151
|
expected_status_codes?: string;
|
|
129
152
|
expected_body_pattern?: string;
|
|
130
153
|
}
|
|
@@ -142,7 +165,8 @@ interface UpdateMonitorOptions {
|
|
|
142
165
|
interval_seconds?: number;
|
|
143
166
|
grace_period_seconds?: number;
|
|
144
167
|
enabled?: boolean;
|
|
145
|
-
|
|
168
|
+
notify_on_failure?: boolean | null;
|
|
169
|
+
notify_on_recovery?: boolean | null;
|
|
146
170
|
}
|
|
147
171
|
interface Ping {
|
|
148
172
|
id: string;
|
|
@@ -263,6 +287,37 @@ declare class Tasks {
|
|
|
263
287
|
trigger(id: string): Promise<TriggerResponse>;
|
|
264
288
|
update(id: string, options: UpdateTaskOptions): Promise<Task>;
|
|
265
289
|
executions(id: string, limit?: number): Promise<Execution[]>;
|
|
290
|
+
/**
|
|
291
|
+
* Create many tasks at once with shared configuration.
|
|
292
|
+
*
|
|
293
|
+
* Each item in the array becomes the request body for one task.
|
|
294
|
+
* All tasks share the same URL, method, headers, timing, and queue.
|
|
295
|
+
* Use the queue name with `cancelQueue()` to cancel them as a group.
|
|
296
|
+
*
|
|
297
|
+
* ```js
|
|
298
|
+
* await rl.tasks.batch({
|
|
299
|
+
* url: "https://myapp.com/api/send-email",
|
|
300
|
+
* queue: "march-newsletter",
|
|
301
|
+
* run_at: "2026-03-01T09:00:00Z",
|
|
302
|
+
* items: [
|
|
303
|
+
* { to: "user1@example.com", name: "Alice" },
|
|
304
|
+
* { to: "user2@example.com", name: "Bob" },
|
|
305
|
+
* ]
|
|
306
|
+
* })
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
batch(options: BatchOptions): Promise<BatchResponse>;
|
|
310
|
+
/**
|
|
311
|
+
* Cancel all tasks in a queue.
|
|
312
|
+
*
|
|
313
|
+
* Soft-deletes every task in the queue and removes their pending executions.
|
|
314
|
+
*
|
|
315
|
+
* ```js
|
|
316
|
+
* const { cancelled } = await rl.tasks.cancelQueue("march-newsletter")
|
|
317
|
+
* console.log(`Cancelled ${cancelled} tasks`)
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
cancelQueue(queue: string): Promise<CancelQueueResponse>;
|
|
266
321
|
}
|
|
267
322
|
declare class Monitors {
|
|
268
323
|
private client;
|
|
@@ -276,4 +331,4 @@ declare class Monitors {
|
|
|
276
331
|
ping(token: string): Promise<PingResponse>;
|
|
277
332
|
}
|
|
278
333
|
|
|
279
|
-
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 };
|
|
334
|
+
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
|
@@ -58,11 +58,12 @@ interface Task {
|
|
|
58
58
|
cron_expression: string | null;
|
|
59
59
|
scheduled_at: string | null;
|
|
60
60
|
enabled: boolean;
|
|
61
|
-
muted: boolean;
|
|
62
61
|
timeout_ms: number;
|
|
63
62
|
retry_attempts: number;
|
|
64
63
|
callback_url: string | null;
|
|
65
64
|
queue: string | null;
|
|
65
|
+
notify_on_failure: boolean | null;
|
|
66
|
+
notify_on_recovery: boolean | null;
|
|
66
67
|
next_run_at: string | null;
|
|
67
68
|
inserted_at: string;
|
|
68
69
|
updated_at: string;
|
|
@@ -105,12 +106,33 @@ interface Monitor {
|
|
|
105
106
|
grace_period_seconds: number;
|
|
106
107
|
status: "new" | "up" | "down" | "paused";
|
|
107
108
|
enabled: boolean;
|
|
108
|
-
|
|
109
|
+
notify_on_failure: boolean | null;
|
|
110
|
+
notify_on_recovery: boolean | null;
|
|
109
111
|
last_ping_at: string | null;
|
|
110
112
|
next_expected_at: string | null;
|
|
111
113
|
inserted_at: string;
|
|
112
114
|
updated_at: string;
|
|
113
115
|
}
|
|
116
|
+
interface BatchOptions {
|
|
117
|
+
url: string;
|
|
118
|
+
queue: string;
|
|
119
|
+
items: unknown[];
|
|
120
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
121
|
+
headers?: Record<string, string>;
|
|
122
|
+
run_at?: string | Date;
|
|
123
|
+
delay?: string | number;
|
|
124
|
+
timeout?: number;
|
|
125
|
+
retries?: number;
|
|
126
|
+
callback?: string;
|
|
127
|
+
}
|
|
128
|
+
interface BatchResponse {
|
|
129
|
+
queue: string;
|
|
130
|
+
created: number;
|
|
131
|
+
scheduled_for: string;
|
|
132
|
+
}
|
|
133
|
+
interface CancelQueueResponse {
|
|
134
|
+
cancelled: number;
|
|
135
|
+
}
|
|
114
136
|
interface UpdateTaskOptions {
|
|
115
137
|
name?: string;
|
|
116
138
|
url?: string;
|
|
@@ -124,7 +146,8 @@ interface UpdateTaskOptions {
|
|
|
124
146
|
callback_url?: string;
|
|
125
147
|
queue?: string;
|
|
126
148
|
enabled?: boolean;
|
|
127
|
-
|
|
149
|
+
notify_on_failure?: boolean | null;
|
|
150
|
+
notify_on_recovery?: boolean | null;
|
|
128
151
|
expected_status_codes?: string;
|
|
129
152
|
expected_body_pattern?: string;
|
|
130
153
|
}
|
|
@@ -142,7 +165,8 @@ interface UpdateMonitorOptions {
|
|
|
142
165
|
interval_seconds?: number;
|
|
143
166
|
grace_period_seconds?: number;
|
|
144
167
|
enabled?: boolean;
|
|
145
|
-
|
|
168
|
+
notify_on_failure?: boolean | null;
|
|
169
|
+
notify_on_recovery?: boolean | null;
|
|
146
170
|
}
|
|
147
171
|
interface Ping {
|
|
148
172
|
id: string;
|
|
@@ -263,6 +287,37 @@ declare class Tasks {
|
|
|
263
287
|
trigger(id: string): Promise<TriggerResponse>;
|
|
264
288
|
update(id: string, options: UpdateTaskOptions): Promise<Task>;
|
|
265
289
|
executions(id: string, limit?: number): Promise<Execution[]>;
|
|
290
|
+
/**
|
|
291
|
+
* Create many tasks at once with shared configuration.
|
|
292
|
+
*
|
|
293
|
+
* Each item in the array becomes the request body for one task.
|
|
294
|
+
* All tasks share the same URL, method, headers, timing, and queue.
|
|
295
|
+
* Use the queue name with `cancelQueue()` to cancel them as a group.
|
|
296
|
+
*
|
|
297
|
+
* ```js
|
|
298
|
+
* await rl.tasks.batch({
|
|
299
|
+
* url: "https://myapp.com/api/send-email",
|
|
300
|
+
* queue: "march-newsletter",
|
|
301
|
+
* run_at: "2026-03-01T09:00:00Z",
|
|
302
|
+
* items: [
|
|
303
|
+
* { to: "user1@example.com", name: "Alice" },
|
|
304
|
+
* { to: "user2@example.com", name: "Bob" },
|
|
305
|
+
* ]
|
|
306
|
+
* })
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
batch(options: BatchOptions): Promise<BatchResponse>;
|
|
310
|
+
/**
|
|
311
|
+
* Cancel all tasks in a queue.
|
|
312
|
+
*
|
|
313
|
+
* Soft-deletes every task in the queue and removes their pending executions.
|
|
314
|
+
*
|
|
315
|
+
* ```js
|
|
316
|
+
* const { cancelled } = await rl.tasks.cancelQueue("march-newsletter")
|
|
317
|
+
* console.log(`Cancelled ${cancelled} tasks`)
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
cancelQueue(queue: string): Promise<CancelQueueResponse>;
|
|
266
321
|
}
|
|
267
322
|
declare class Monitors {
|
|
268
323
|
private client;
|
|
@@ -276,4 +331,4 @@ declare class Monitors {
|
|
|
276
331
|
ping(token: string): Promise<PingResponse>;
|
|
277
332
|
}
|
|
278
333
|
|
|
279
|
-
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 };
|
|
334
|
+
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) {
|