runlater-js 0.8.0 → 0.10.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
@@ -50,12 +50,68 @@ interface CronResponse {
50
50
  name: string;
51
51
  url: string;
52
52
  method: string;
53
- cron_expression: string;
53
+ cron: string;
54
54
  enabled: boolean;
55
55
  next_run_at: string | null;
56
56
  inserted_at: string;
57
57
  updated_at: string;
58
58
  }
59
+ interface Schedule {
60
+ id: string;
61
+ name: string;
62
+ url: string;
63
+ method: string;
64
+ headers: Record<string, string>;
65
+ body: string | null;
66
+ cron: string;
67
+ enabled: boolean;
68
+ timeout_ms: number;
69
+ callback_url: string | null;
70
+ expected_status_codes: string | null;
71
+ expected_body_pattern: string | null;
72
+ notify_on_failure: boolean | null;
73
+ notify_on_recovery: boolean | null;
74
+ on_failure_url: string | null;
75
+ on_recovery_url: string | null;
76
+ script: string | null;
77
+ next_run_at: string | null;
78
+ inserted_at: string;
79
+ updated_at: string;
80
+ }
81
+ interface CreateScheduleOptions {
82
+ url: string;
83
+ cron: string;
84
+ name?: string;
85
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
86
+ headers?: Record<string, string>;
87
+ body?: unknown;
88
+ timeout?: number;
89
+ callback?: string;
90
+ enabled?: boolean;
91
+ on_failure_url?: string;
92
+ on_recovery_url?: string;
93
+ expected_status_codes?: string;
94
+ expected_body_pattern?: string;
95
+ script?: string;
96
+ }
97
+ interface UpdateScheduleOptions {
98
+ name?: string;
99
+ url?: string;
100
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
101
+ headers?: Record<string, string>;
102
+ body?: string;
103
+ cron?: string;
104
+ timeout_ms?: number;
105
+ callback_url?: string;
106
+ enabled?: boolean;
107
+ notify_on_failure?: boolean | null;
108
+ notify_on_recovery?: boolean | null;
109
+ on_failure_url?: string;
110
+ on_recovery_url?: string;
111
+ expected_status_codes?: string;
112
+ expected_body_pattern?: string;
113
+ script?: string | null;
114
+ }
59
115
  interface Task {
60
116
  id: string;
61
117
  name: string;
@@ -64,8 +120,8 @@ interface Task {
64
120
  headers: Record<string, string>;
65
121
  body: string | null;
66
122
  schedule_type: string;
67
- cron_expression: string | null;
68
- scheduled_at: string | null;
123
+ cron: string | null;
124
+ run_at: string | null;
69
125
  enabled: boolean;
70
126
  timeout_ms: number;
71
127
  retry_attempts: number;
@@ -154,8 +210,8 @@ interface UpdateTaskOptions {
154
210
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
155
211
  headers?: Record<string, string>;
156
212
  body?: string;
157
- cron_expression?: string;
158
- scheduled_at?: string;
213
+ cron?: string;
214
+ run_at?: string;
159
215
  timeout_ms?: number;
160
216
  retry_attempts?: number;
161
217
  callback_url?: string;
@@ -199,12 +255,12 @@ interface PingResponse {
199
255
  monitor: string;
200
256
  }
201
257
  interface SyncOptions {
202
- tasks?: CronOptions[];
258
+ schedules?: CronOptions[];
203
259
  monitors?: CreateMonitorOptions[];
204
260
  deleteRemoved?: boolean;
205
261
  }
206
262
  interface SyncResponse {
207
- tasks: {
263
+ schedules: {
208
264
  created: string[];
209
265
  updated: string[];
210
266
  deleted: string[];
@@ -285,6 +341,7 @@ declare class Runlater {
285
341
  tasks: Tasks;
286
342
  monitors: Monitors;
287
343
  endpoints: Endpoints;
344
+ schedules: Schedules;
288
345
  constructor(options: RunlaterOptions | string);
289
346
  /**
290
347
  * Send a request immediately with reliable delivery and retries.
@@ -339,7 +396,7 @@ declare class Runlater {
339
396
  *
340
397
  * ```js
341
398
  * await rl.sync({
342
- * tasks: [
399
+ * schedules: [
343
400
  * { name: "daily-report", url: "https://...", schedule: "0 9 * * *" }
344
401
  * ],
345
402
  * deleteRemoved: true
@@ -397,6 +454,17 @@ declare class Tasks {
397
454
  */
398
455
  cancelQueue(queue: string): Promise<CancelQueueResponse>;
399
456
  }
457
+ declare class Schedules {
458
+ private client;
459
+ constructor(client: Runlater);
460
+ list(options?: ListOptions): Promise<ListResponse<Schedule>>;
461
+ get(id: string): Promise<Schedule>;
462
+ create(options: CreateScheduleOptions): Promise<Schedule>;
463
+ update(id: string, options: UpdateScheduleOptions): Promise<Schedule>;
464
+ delete(id: string): Promise<void>;
465
+ trigger(id: string): Promise<TriggerResponse>;
466
+ executions(id: string, limit?: number): Promise<Execution[]>;
467
+ }
400
468
  declare class Monitors {
401
469
  private client;
402
470
  constructor(client: Runlater);
@@ -422,4 +490,4 @@ declare class Endpoints {
422
490
  resume(id: string): Promise<Endpoint>;
423
491
  }
424
492
 
425
- export { type BatchOptions, type BatchResponse, type CancelQueueResponse, type CreateEndpointOptions, type CreateMonitorOptions, 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 ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateEndpointOptions, type UpdateMonitorOptions, type UpdateTaskOptions };
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 };
package/dist/index.d.ts CHANGED
@@ -50,12 +50,68 @@ interface CronResponse {
50
50
  name: string;
51
51
  url: string;
52
52
  method: string;
53
- cron_expression: string;
53
+ cron: string;
54
54
  enabled: boolean;
55
55
  next_run_at: string | null;
56
56
  inserted_at: string;
57
57
  updated_at: string;
58
58
  }
59
+ interface Schedule {
60
+ id: string;
61
+ name: string;
62
+ url: string;
63
+ method: string;
64
+ headers: Record<string, string>;
65
+ body: string | null;
66
+ cron: string;
67
+ enabled: boolean;
68
+ timeout_ms: number;
69
+ callback_url: string | null;
70
+ expected_status_codes: string | null;
71
+ expected_body_pattern: string | null;
72
+ notify_on_failure: boolean | null;
73
+ notify_on_recovery: boolean | null;
74
+ on_failure_url: string | null;
75
+ on_recovery_url: string | null;
76
+ script: string | null;
77
+ next_run_at: string | null;
78
+ inserted_at: string;
79
+ updated_at: string;
80
+ }
81
+ interface CreateScheduleOptions {
82
+ url: string;
83
+ cron: string;
84
+ name?: string;
85
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
86
+ headers?: Record<string, string>;
87
+ body?: unknown;
88
+ timeout?: number;
89
+ callback?: string;
90
+ enabled?: boolean;
91
+ on_failure_url?: string;
92
+ on_recovery_url?: string;
93
+ expected_status_codes?: string;
94
+ expected_body_pattern?: string;
95
+ script?: string;
96
+ }
97
+ interface UpdateScheduleOptions {
98
+ name?: string;
99
+ url?: string;
100
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
101
+ headers?: Record<string, string>;
102
+ body?: string;
103
+ cron?: string;
104
+ timeout_ms?: number;
105
+ callback_url?: string;
106
+ enabled?: boolean;
107
+ notify_on_failure?: boolean | null;
108
+ notify_on_recovery?: boolean | null;
109
+ on_failure_url?: string;
110
+ on_recovery_url?: string;
111
+ expected_status_codes?: string;
112
+ expected_body_pattern?: string;
113
+ script?: string | null;
114
+ }
59
115
  interface Task {
60
116
  id: string;
61
117
  name: string;
@@ -64,8 +120,8 @@ interface Task {
64
120
  headers: Record<string, string>;
65
121
  body: string | null;
66
122
  schedule_type: string;
67
- cron_expression: string | null;
68
- scheduled_at: string | null;
123
+ cron: string | null;
124
+ run_at: string | null;
69
125
  enabled: boolean;
70
126
  timeout_ms: number;
71
127
  retry_attempts: number;
@@ -154,8 +210,8 @@ interface UpdateTaskOptions {
154
210
  method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
155
211
  headers?: Record<string, string>;
156
212
  body?: string;
157
- cron_expression?: string;
158
- scheduled_at?: string;
213
+ cron?: string;
214
+ run_at?: string;
159
215
  timeout_ms?: number;
160
216
  retry_attempts?: number;
161
217
  callback_url?: string;
@@ -199,12 +255,12 @@ interface PingResponse {
199
255
  monitor: string;
200
256
  }
201
257
  interface SyncOptions {
202
- tasks?: CronOptions[];
258
+ schedules?: CronOptions[];
203
259
  monitors?: CreateMonitorOptions[];
204
260
  deleteRemoved?: boolean;
205
261
  }
206
262
  interface SyncResponse {
207
- tasks: {
263
+ schedules: {
208
264
  created: string[];
209
265
  updated: string[];
210
266
  deleted: string[];
@@ -285,6 +341,7 @@ declare class Runlater {
285
341
  tasks: Tasks;
286
342
  monitors: Monitors;
287
343
  endpoints: Endpoints;
344
+ schedules: Schedules;
288
345
  constructor(options: RunlaterOptions | string);
289
346
  /**
290
347
  * Send a request immediately with reliable delivery and retries.
@@ -339,7 +396,7 @@ declare class Runlater {
339
396
  *
340
397
  * ```js
341
398
  * await rl.sync({
342
- * tasks: [
399
+ * schedules: [
343
400
  * { name: "daily-report", url: "https://...", schedule: "0 9 * * *" }
344
401
  * ],
345
402
  * deleteRemoved: true
@@ -397,6 +454,17 @@ declare class Tasks {
397
454
  */
398
455
  cancelQueue(queue: string): Promise<CancelQueueResponse>;
399
456
  }
457
+ declare class Schedules {
458
+ private client;
459
+ constructor(client: Runlater);
460
+ list(options?: ListOptions): Promise<ListResponse<Schedule>>;
461
+ get(id: string): Promise<Schedule>;
462
+ create(options: CreateScheduleOptions): Promise<Schedule>;
463
+ update(id: string, options: UpdateScheduleOptions): Promise<Schedule>;
464
+ delete(id: string): Promise<void>;
465
+ trigger(id: string): Promise<TriggerResponse>;
466
+ executions(id: string, limit?: number): Promise<Execution[]>;
467
+ }
400
468
  declare class Monitors {
401
469
  private client;
402
470
  constructor(client: Runlater);
@@ -422,4 +490,4 @@ declare class Endpoints {
422
490
  resume(id: string): Promise<Endpoint>;
423
491
  }
424
492
 
425
- export { type BatchOptions, type BatchResponse, type CancelQueueResponse, type CreateEndpointOptions, type CreateMonitorOptions, 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 ScheduleOptions, type SendOptions, type SyncOptions, type SyncResponse, type Task, type TaskResponse, type TriggerResponse, type UpdateEndpointOptions, type UpdateMonitorOptions, type UpdateTaskOptions };
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 };
package/dist/index.js CHANGED
@@ -45,6 +45,7 @@ var Runlater = class {
45
45
  tasks;
46
46
  monitors;
47
47
  endpoints;
48
+ schedules;
48
49
  constructor(options) {
49
50
  if (typeof options === "string") {
50
51
  this.apiKey = options;
@@ -56,6 +57,7 @@ var Runlater = class {
56
57
  this.tasks = new Tasks(this);
57
58
  this.monitors = new Monitors(this);
58
59
  this.endpoints = new Endpoints(this);
60
+ this.schedules = new Schedules(this);
59
61
  }
60
62
  /**
61
63
  * Send a request immediately with reliable delivery and retries.
@@ -130,7 +132,7 @@ var Runlater = class {
130
132
  * ```
131
133
  */
132
134
  async cron(name, options) {
133
- const res = await this.request("POST", "/tasks", {
135
+ const res = await this.request("POST", "/schedules", {
134
136
  body: {
135
137
  name,
136
138
  url: options.url,
@@ -153,7 +155,7 @@ var Runlater = class {
153
155
  *
154
156
  * ```js
155
157
  * await rl.sync({
156
- * tasks: [
158
+ * schedules: [
157
159
  * { name: "daily-report", url: "https://...", schedule: "0 9 * * *" }
158
160
  * ],
159
161
  * deleteRemoved: true
@@ -162,14 +164,13 @@ var Runlater = class {
162
164
  */
163
165
  async sync(options) {
164
166
  const body = {};
165
- if (options.tasks) {
166
- body.tasks = options.tasks.map((t) => ({
167
+ if (options.schedules) {
168
+ body.schedules = options.schedules.map((t) => ({
167
169
  name: t.url,
168
170
  // name defaults to url if not in CronOptions
169
171
  url: t.url,
170
172
  method: t.method ?? "GET",
171
- schedule_type: "cron",
172
- cron_expression: t.schedule,
173
+ cron: t.schedule,
173
174
  headers: t.headers,
174
175
  body: t.body != null ? JSON.stringify(t.body) : void 0,
175
176
  timeout_ms: t.timeout,
@@ -344,6 +345,66 @@ var Tasks = class {
344
345
  return res.data;
345
346
  }
346
347
  };
348
+ var Schedules = class {
349
+ constructor(client) {
350
+ this.client = client;
351
+ }
352
+ async list(options = {}) {
353
+ const params = new URLSearchParams();
354
+ if (options.limit != null) params.set("limit", String(options.limit));
355
+ if (options.offset != null) params.set("offset", String(options.offset));
356
+ const query = params.toString();
357
+ return this.client.request("GET", `/schedules${query ? `?${query}` : ""}`);
358
+ }
359
+ async get(id) {
360
+ const res = await this.client.request("GET", `/schedules/${id}`);
361
+ return res.data;
362
+ }
363
+ async create(options) {
364
+ const res = await this.client.request("POST", "/schedules", {
365
+ body: {
366
+ name: options.name,
367
+ url: options.url,
368
+ method: options.method ?? "GET",
369
+ cron: options.cron,
370
+ headers: options.headers,
371
+ body: options.body != null ? JSON.stringify(options.body) : void 0,
372
+ timeout_ms: options.timeout,
373
+ callback_url: options.callback,
374
+ enabled: options.enabled,
375
+ expected_status_codes: options.expected_status_codes,
376
+ expected_body_pattern: options.expected_body_pattern,
377
+ on_failure_url: options.on_failure_url,
378
+ on_recovery_url: options.on_recovery_url,
379
+ script: options.script
380
+ }
381
+ });
382
+ return res.data;
383
+ }
384
+ async update(id, options) {
385
+ const res = await this.client.request("PUT", `/schedules/${id}`, {
386
+ body: options
387
+ });
388
+ return res.data;
389
+ }
390
+ async delete(id) {
391
+ await this.client.request("DELETE", `/schedules/${id}`);
392
+ }
393
+ async trigger(id) {
394
+ const res = await this.client.request(
395
+ "POST",
396
+ `/schedules/${id}/trigger`
397
+ );
398
+ return res.data;
399
+ }
400
+ async executions(id, limit = 50) {
401
+ const res = await this.client.request(
402
+ "GET",
403
+ `/schedules/${id}/executions?limit=${limit}`
404
+ );
405
+ return res.data;
406
+ }
407
+ };
347
408
  var Monitors = class {
348
409
  constructor(client) {
349
410
  this.client = client;
package/dist/index.mjs CHANGED
@@ -18,6 +18,7 @@ var Runlater = class {
18
18
  tasks;
19
19
  monitors;
20
20
  endpoints;
21
+ schedules;
21
22
  constructor(options) {
22
23
  if (typeof options === "string") {
23
24
  this.apiKey = options;
@@ -29,6 +30,7 @@ var Runlater = class {
29
30
  this.tasks = new Tasks(this);
30
31
  this.monitors = new Monitors(this);
31
32
  this.endpoints = new Endpoints(this);
33
+ this.schedules = new Schedules(this);
32
34
  }
33
35
  /**
34
36
  * Send a request immediately with reliable delivery and retries.
@@ -103,7 +105,7 @@ var Runlater = class {
103
105
  * ```
104
106
  */
105
107
  async cron(name, options) {
106
- const res = await this.request("POST", "/tasks", {
108
+ const res = await this.request("POST", "/schedules", {
107
109
  body: {
108
110
  name,
109
111
  url: options.url,
@@ -126,7 +128,7 @@ var Runlater = class {
126
128
  *
127
129
  * ```js
128
130
  * await rl.sync({
129
- * tasks: [
131
+ * schedules: [
130
132
  * { name: "daily-report", url: "https://...", schedule: "0 9 * * *" }
131
133
  * ],
132
134
  * deleteRemoved: true
@@ -135,14 +137,13 @@ var Runlater = class {
135
137
  */
136
138
  async sync(options) {
137
139
  const body = {};
138
- if (options.tasks) {
139
- body.tasks = options.tasks.map((t) => ({
140
+ if (options.schedules) {
141
+ body.schedules = options.schedules.map((t) => ({
140
142
  name: t.url,
141
143
  // name defaults to url if not in CronOptions
142
144
  url: t.url,
143
145
  method: t.method ?? "GET",
144
- schedule_type: "cron",
145
- cron_expression: t.schedule,
146
+ cron: t.schedule,
146
147
  headers: t.headers,
147
148
  body: t.body != null ? JSON.stringify(t.body) : void 0,
148
149
  timeout_ms: t.timeout,
@@ -317,6 +318,66 @@ var Tasks = class {
317
318
  return res.data;
318
319
  }
319
320
  };
321
+ var Schedules = class {
322
+ constructor(client) {
323
+ this.client = client;
324
+ }
325
+ async list(options = {}) {
326
+ const params = new URLSearchParams();
327
+ if (options.limit != null) params.set("limit", String(options.limit));
328
+ if (options.offset != null) params.set("offset", String(options.offset));
329
+ const query = params.toString();
330
+ return this.client.request("GET", `/schedules${query ? `?${query}` : ""}`);
331
+ }
332
+ async get(id) {
333
+ const res = await this.client.request("GET", `/schedules/${id}`);
334
+ return res.data;
335
+ }
336
+ async create(options) {
337
+ const res = await this.client.request("POST", "/schedules", {
338
+ body: {
339
+ name: options.name,
340
+ url: options.url,
341
+ method: options.method ?? "GET",
342
+ cron: options.cron,
343
+ headers: options.headers,
344
+ body: options.body != null ? JSON.stringify(options.body) : void 0,
345
+ timeout_ms: options.timeout,
346
+ callback_url: options.callback,
347
+ enabled: options.enabled,
348
+ expected_status_codes: options.expected_status_codes,
349
+ expected_body_pattern: options.expected_body_pattern,
350
+ on_failure_url: options.on_failure_url,
351
+ on_recovery_url: options.on_recovery_url,
352
+ script: options.script
353
+ }
354
+ });
355
+ return res.data;
356
+ }
357
+ async update(id, options) {
358
+ const res = await this.client.request("PUT", `/schedules/${id}`, {
359
+ body: options
360
+ });
361
+ return res.data;
362
+ }
363
+ async delete(id) {
364
+ await this.client.request("DELETE", `/schedules/${id}`);
365
+ }
366
+ async trigger(id) {
367
+ const res = await this.client.request(
368
+ "POST",
369
+ `/schedules/${id}/trigger`
370
+ );
371
+ return res.data;
372
+ }
373
+ async executions(id, limit = 50) {
374
+ const res = await this.client.request(
375
+ "GET",
376
+ `/schedules/${id}/executions?limit=${limit}`
377
+ );
378
+ return res.data;
379
+ }
380
+ };
320
381
  var Monitors = class {
321
382
  constructor(client) {
322
383
  this.client = client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runlater-js",
3
- "version": "0.8.0",
3
+ "version": "0.10.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",