@maroonedsoftware/jobbroker 1.12.3 → 1.13.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.
@@ -1,6 +1,9 @@
1
1
  import { PgBoss } from 'pg-boss';
2
+ import { DateTime } from 'luxon';
2
3
  import { JobBroker } from '../job.broker.js';
3
4
  import { JobInfo } from '../job.info.js';
5
+ import { JobSchedule } from '../job.schedule.js';
6
+ import { JobScheduleOptions, JobSchedulePreviewOptions } from '../job.schedule.options.js';
4
7
  import { JobSendOptions } from '../job.send.options.js';
5
8
  import { PgBossJobRegistryMap } from './pgboss.job.registration.js';
6
9
  import { PgBossConnectionProvider } from './pgboss.connection.provider.js';
@@ -9,7 +12,8 @@ import { PgBossConnectionProvider } from './pgboss.connection.provider.js';
9
12
  *
10
13
  * This broker uses PostgreSQL (via pg-boss) as the backing queue for job
11
14
  * processing. It provides reliable, transactional job queuing with support
12
- * for scheduled jobs using cron expressions.
15
+ * for recurring schedules on cron expressions or RFC 5545 recurrence rules,
16
+ * many per queue when each has its own key.
13
17
  *
14
18
  * Each enqueue and schedule call sources its pg-boss `db` executor from the
15
19
  * injected {@link PgBossConnectionProvider}. The default provider returns
@@ -79,35 +83,89 @@ export declare class PgBossJobBroker extends JobBroker {
79
83
  */
80
84
  private toStartAfter;
81
85
  /**
82
- * Schedules a recurring job using a cron expression.
86
+ * Schedules a recurring job on a cron expression or an RFC 5545 recurrence rule.
83
87
  *
84
- * The job will be automatically enqueued by pg-boss according to the
85
- * specified cron schedule. If a schedule already exists for this job,
86
- * it will be updated with the new cron expression and payload.
88
+ * pg-boss decides the format from the expression itself and stores one row
89
+ * per job name and key, so scheduling again with the same name and key
90
+ * replaces that row. The options map onto pg-boss's own: `key` to `key`,
91
+ * `timeZone` to `tz`, and `missed` to `missed`. pg-boss validates the
92
+ * recurrence and the zone before writing and throws on either.
87
93
  *
88
94
  * The schedule-insert SQL runs against the executor returned by the injected
89
- * {@link PgBossConnectionProvider}; the default executor uses pg-boss's own
90
- * pool, which is the expected behavior for bootstrap-time scheduling.
95
+ * {@link PgBossConnectionProvider}; when that executor is bound to an active
96
+ * transaction, the schedule commits or rolls back with it.
91
97
  *
92
98
  * @typeParam Payload - The type of the job payload.
93
99
  * @param name - The name of the registered job to schedule.
94
- * @param cron - A cron expression (e.g., '0 9 * * *' for daily at 9am).
100
+ * @param recurrence - A cron expression or an RFC 5545 recurrence rule.
95
101
  * @param payload - Optional data to pass to the job on each execution.
96
- * @returns A promise that resolves when the schedule has been created.
102
+ * @param options - Optional key, time zone and missed-occurrence policy.
103
+ * @returns A promise that resolves when the schedule has been created or replaced.
97
104
  * @throws Error if the job name is not found in the registry.
105
+ * @throws Error if pg-boss rejects the recurrence, the time zone or the key.
106
+ */
107
+ schedule<Payload extends object>(name: string, recurrence: string, payload?: Payload, options?: JobScheduleOptions): Promise<void>;
108
+ /**
109
+ * Maps backend-agnostic schedule options onto pg-boss's `key`, `tz` and
110
+ * `missed`, leaving out any that were not given so pg-boss applies its own
111
+ * defaults (the unkeyed schedule, UTC, and `skip`).
98
112
  */
99
- schedule<Payload extends object>(name: string, cron: string, payload?: Payload): Promise<void>;
113
+ private toScheduleOptions;
100
114
  /**
101
115
  * Removes a scheduled job from pg-boss.
102
116
  *
103
- * This stops future executions of the scheduled job. Jobs that are
104
- * already queued will still be processed.
117
+ * This stops future executions of the schedule with the given name and key.
118
+ * Jobs that are already queued will still be processed. pg-boss reads a
119
+ * missing key as the empty key, so `unschedule(name)` removes only the
120
+ * unkeyed schedule and leaves keyed ones in place.
105
121
  *
106
- * @param name - The name of the scheduled job to remove.
122
+ * The delete runs against the executor returned by the injected
123
+ * {@link PgBossConnectionProvider}, so inside a transaction it rolls back
124
+ * with the transaction.
125
+ *
126
+ * @param name - The name of the scheduled job.
127
+ * @param key - The key the schedule was created with, if any.
107
128
  * @returns A promise that resolves when the schedule has been removed.
108
129
  * @throws Error if the job name is not found in the registry.
109
130
  */
110
- unschedule(name: string): Promise<void>;
131
+ unschedule(name: string, key?: string): Promise<void>;
132
+ /**
133
+ * Lists the schedules on a job name from pg-boss.
134
+ *
135
+ * With a key this reads the one row by its primary key. Without one it pages
136
+ * through every schedule on the name, so a queue with many keyed schedules is
137
+ * returned whole rather than cut off at pg-boss's page size.
138
+ *
139
+ * pg-boss offers no connection option for this read, so it always runs on
140
+ * pg-boss's own pool: a schedule written inside a transaction that has not
141
+ * committed yet is not visible here.
142
+ *
143
+ * @typeParam Payload - The type of the scheduled payload.
144
+ * @param name - The name of the registered job.
145
+ * @param key - When given, only the schedule with this key.
146
+ * @returns A promise that resolves with the matching schedules, ordered by key.
147
+ * @throws Error if the job name is not found in the registry.
148
+ */
149
+ getSchedules<Payload extends object>(name: string, key?: string): Promise<JobSchedule<Payload>[]>;
150
+ /** Rows read per page when {@link getSchedules} lists every schedule on a name. */
151
+ private static readonly schedulePageSize;
152
+ /** Maps a pg-boss schedule row onto the backend-agnostic {@link JobSchedule}. */
153
+ private toJobSchedule;
154
+ /**
155
+ * Computes the next occurrences of a recurrence with pg-boss's
156
+ * `previewSchedule`, which validates exactly as {@link schedule} does and
157
+ * touches neither the database nor the schedule table.
158
+ *
159
+ * `from` defaults to pg-boss's reading of database time, which on an instance
160
+ * that runs schedules accounts for clock skew against the database. The
161
+ * returned `DateTime`s are in `options.timeZone`, or UTC when omitted.
162
+ *
163
+ * @param recurrence - A cron expression or an RFC 5545 recurrence rule.
164
+ * @param options - Optional time zone, starting point and count.
165
+ * @returns A promise that resolves with the occurrences, earliest first.
166
+ * @throws Error if pg-boss rejects the recurrence, the time zone or the count.
167
+ */
168
+ previewSchedule(recurrence: string, options?: JobSchedulePreviewOptions): Promise<DateTime[]>;
111
169
  /**
112
170
  * Cancels one or more jobs in the PgBoss queue.
113
171
  *
@@ -1 +1 @@
1
- {"version":3,"file":"pgboss.job.broker.d.ts","sourceRoot":"","sources":["../../src/pgboss/pgboss.job.broker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAA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ASG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQhE;;;;;;;OAOG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAQnE;;;;;;;;;OASG;IACG,MAAM,CAAC,OAAO,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAYjG"}
package/dist/pgboss.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  JobRunner,
6
6
  PermanentJobError,
7
7
  __name
8
- } from "./chunk-MR3BBUMG.js";
8
+ } from "./chunk-KI5S6IPU.js";
9
9
 
10
10
  // src/pgboss/pgboss.job.broker.ts
11
11
  import { PgBoss } from "pg-boss";
@@ -70,7 +70,7 @@ function _ts_metadata(k, v) {
70
70
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
71
71
  }
72
72
  __name(_ts_metadata, "_ts_metadata");
73
- var PgBossJobBroker = class extends JobBroker {
73
+ var PgBossJobBroker = class _PgBossJobBroker extends JobBroker {
74
74
  static {
75
75
  __name(this, "PgBossJobBroker");
76
76
  }
@@ -145,46 +145,169 @@ var PgBossJobBroker = class extends JobBroker {
145
145
  return {};
146
146
  }
147
147
  /**
148
- * Schedules a recurring job using a cron expression.
148
+ * Schedules a recurring job on a cron expression or an RFC 5545 recurrence rule.
149
149
  *
150
- * The job will be automatically enqueued by pg-boss according to the
151
- * specified cron schedule. If a schedule already exists for this job,
152
- * it will be updated with the new cron expression and payload.
150
+ * pg-boss decides the format from the expression itself and stores one row
151
+ * per job name and key, so scheduling again with the same name and key
152
+ * replaces that row. The options map onto pg-boss's own: `key` to `key`,
153
+ * `timeZone` to `tz`, and `missed` to `missed`. pg-boss validates the
154
+ * recurrence and the zone before writing and throws on either.
153
155
  *
154
156
  * The schedule-insert SQL runs against the executor returned by the injected
155
- * {@link PgBossConnectionProvider}; the default executor uses pg-boss's own
156
- * pool, which is the expected behavior for bootstrap-time scheduling.
157
+ * {@link PgBossConnectionProvider}; when that executor is bound to an active
158
+ * transaction, the schedule commits or rolls back with it.
157
159
  *
158
160
  * @typeParam Payload - The type of the job payload.
159
161
  * @param name - The name of the registered job to schedule.
160
- * @param cron - A cron expression (e.g., '0 9 * * *' for daily at 9am).
162
+ * @param recurrence - A cron expression or an RFC 5545 recurrence rule.
161
163
  * @param payload - Optional data to pass to the job on each execution.
162
- * @returns A promise that resolves when the schedule has been created.
164
+ * @param options - Optional key, time zone and missed-occurrence policy.
165
+ * @returns A promise that resolves when the schedule has been created or replaced.
163
166
  * @throws Error if the job name is not found in the registry.
167
+ * @throws Error if pg-boss rejects the recurrence, the time zone or the key.
164
168
  */
165
- async schedule(name, cron, payload) {
169
+ async schedule(name, recurrence, payload, options) {
166
170
  if (!this.registrations.has(name)) {
167
171
  throw new Error(`Job ${name} is not registered`);
168
172
  }
169
- await this.pgboss.schedule(name, cron, payload, {
170
- db: this.connectionProvider.executor()
173
+ await this.pgboss.schedule(name, recurrence, payload, {
174
+ db: this.connectionProvider.executor(),
175
+ ...this.toScheduleOptions(options)
171
176
  });
172
177
  }
173
178
  /**
179
+ * Maps backend-agnostic schedule options onto pg-boss's `key`, `tz` and
180
+ * `missed`, leaving out any that were not given so pg-boss applies its own
181
+ * defaults (the unkeyed schedule, UTC, and `skip`).
182
+ */
183
+ toScheduleOptions(options) {
184
+ return {
185
+ ...options?.key !== void 0 && {
186
+ key: options.key
187
+ },
188
+ ...options?.timeZone !== void 0 && {
189
+ tz: options.timeZone
190
+ },
191
+ ...options?.missed !== void 0 && {
192
+ missed: options.missed
193
+ }
194
+ };
195
+ }
196
+ /**
174
197
  * Removes a scheduled job from pg-boss.
175
198
  *
176
- * This stops future executions of the scheduled job. Jobs that are
177
- * already queued will still be processed.
199
+ * This stops future executions of the schedule with the given name and key.
200
+ * Jobs that are already queued will still be processed. pg-boss reads a
201
+ * missing key as the empty key, so `unschedule(name)` removes only the
202
+ * unkeyed schedule and leaves keyed ones in place.
203
+ *
204
+ * The delete runs against the executor returned by the injected
205
+ * {@link PgBossConnectionProvider}, so inside a transaction it rolls back
206
+ * with the transaction.
178
207
  *
179
- * @param name - The name of the scheduled job to remove.
208
+ * @param name - The name of the scheduled job.
209
+ * @param key - The key the schedule was created with, if any.
180
210
  * @returns A promise that resolves when the schedule has been removed.
181
211
  * @throws Error if the job name is not found in the registry.
182
212
  */
183
- async unschedule(name) {
213
+ async unschedule(name, key) {
184
214
  if (!this.registrations.has(name)) {
185
215
  throw new Error(`Job ${name} is not registered`);
186
216
  }
187
- await this.pgboss.unschedule(name);
217
+ await this.pgboss.unschedule(name, key, {
218
+ db: this.connectionProvider.executor()
219
+ });
220
+ }
221
+ /**
222
+ * Lists the schedules on a job name from pg-boss.
223
+ *
224
+ * With a key this reads the one row by its primary key. Without one it pages
225
+ * through every schedule on the name, so a queue with many keyed schedules is
226
+ * returned whole rather than cut off at pg-boss's page size.
227
+ *
228
+ * pg-boss offers no connection option for this read, so it always runs on
229
+ * pg-boss's own pool: a schedule written inside a transaction that has not
230
+ * committed yet is not visible here.
231
+ *
232
+ * @typeParam Payload - The type of the scheduled payload.
233
+ * @param name - The name of the registered job.
234
+ * @param key - When given, only the schedule with this key.
235
+ * @returns A promise that resolves with the matching schedules, ordered by key.
236
+ * @throws Error if the job name is not found in the registry.
237
+ */
238
+ async getSchedules(name, key) {
239
+ if (!this.registrations.has(name)) {
240
+ throw new Error(`Job ${name} is not registered`);
241
+ }
242
+ if (key !== void 0) {
243
+ const schedule = await this.pgboss.getSchedule(name, key);
244
+ return schedule ? [
245
+ this.toJobSchedule(schedule)
246
+ ] : [];
247
+ }
248
+ const schedules = [];
249
+ let after;
250
+ for (; ; ) {
251
+ const page = await this.pgboss.getSchedules(name, void 0, {
252
+ limit: _PgBossJobBroker.schedulePageSize,
253
+ ...after && {
254
+ after
255
+ }
256
+ });
257
+ schedules.push(...page);
258
+ const last = page.at(-1);
259
+ if (page.length < _PgBossJobBroker.schedulePageSize || !last) {
260
+ break;
261
+ }
262
+ after = {
263
+ name: last.name,
264
+ key: last.key
265
+ };
266
+ }
267
+ return schedules.map((schedule) => this.toJobSchedule(schedule));
268
+ }
269
+ /** Rows read per page when {@link getSchedules} lists every schedule on a name. */
270
+ static schedulePageSize = 1e3;
271
+ /** Maps a pg-boss schedule row onto the backend-agnostic {@link JobSchedule}. */
272
+ toJobSchedule(schedule) {
273
+ return {
274
+ name: schedule.name,
275
+ key: schedule.key,
276
+ recurrence: schedule.cron,
277
+ timeZone: schedule.timezone || "UTC",
278
+ ...schedule.data != null && {
279
+ payload: schedule.data
280
+ }
281
+ };
282
+ }
283
+ /**
284
+ * Computes the next occurrences of a recurrence with pg-boss's
285
+ * `previewSchedule`, which validates exactly as {@link schedule} does and
286
+ * touches neither the database nor the schedule table.
287
+ *
288
+ * `from` defaults to pg-boss's reading of database time, which on an instance
289
+ * that runs schedules accounts for clock skew against the database. The
290
+ * returned `DateTime`s are in `options.timeZone`, or UTC when omitted.
291
+ *
292
+ * @param recurrence - A cron expression or an RFC 5545 recurrence rule.
293
+ * @param options - Optional time zone, starting point and count.
294
+ * @returns A promise that resolves with the occurrences, earliest first.
295
+ * @throws Error if pg-boss rejects the recurrence, the time zone or the count.
296
+ */
297
+ async previewSchedule(recurrence, options) {
298
+ const zone = options?.timeZone ?? "UTC";
299
+ const occurrences = this.pgboss.previewSchedule(recurrence, {
300
+ tz: zone,
301
+ ...options?.from !== void 0 && {
302
+ from: options.from.toJSDate()
303
+ },
304
+ ...options?.count !== void 0 && {
305
+ count: options.count
306
+ }
307
+ });
308
+ return occurrences.map((occurrence) => DateTime.fromJSDate(occurrence, {
309
+ zone
310
+ }));
188
311
  }
189
312
  /**
190
313
  * Cancels one or more jobs in the PgBoss queue.