@maroonedsoftware/jobbroker 1.8.2 → 1.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.
@@ -0,0 +1,72 @@
1
+ import { Duration } from 'luxon';
2
+ /**
3
+ * Backend-agnostic reliability policy for a job *queue*: how many times a failed
4
+ * job is retried, how long to wait between attempts, how long a running job may
5
+ * take before it is considered stuck, and where a job goes once it has exhausted
6
+ * its retries.
7
+ *
8
+ * Like {@link JobSendOptions}, this type describes *intent* rather than any one
9
+ * backend's wire format. Retry, backoff, and dead-lettering are queue-level
10
+ * concepts on every mainstream queue (pg-boss `retryLimit`/`deadLetter`, SQS's
11
+ * redrive policy `maxReceiveCount` + DLQ ARN, Cloud Tasks' `maxAttempts` /
12
+ * `minBackoff`), so a policy declared here maps cleanly onto whichever backend
13
+ * is in use. A backend that cannot honor a requested knob throws a
14
+ * `NotSupportedError` rather than silently ignoring it.
15
+ *
16
+ * Because these are queue-level properties, the policy is declared where the job
17
+ * is registered (see the pg-boss `PgBossJobRegistration`), not per individual
18
+ * `send`. Deferring a single job is still a per-send concern (see
19
+ * {@link JobSendOptions.startAfter}); retry/dead-letter behavior is not.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const policy: JobQueuePolicy = {
24
+ * retryLimit: 5,
25
+ * retryDelay: Duration.fromObject({ seconds: 30 }),
26
+ * retryBackoff: true,
27
+ * deadLetter: 'charge.webhook.dead',
28
+ * };
29
+ * ```
30
+ */
31
+ export interface JobQueuePolicy {
32
+ /**
33
+ * How many times a failed job is retried before it is marked failed (and, if a
34
+ * {@link deadLetter} queue is set, dead-lettered). Omit to use the backend's
35
+ * default.
36
+ */
37
+ retryLimit?: number;
38
+ /**
39
+ * Delay to wait before retrying a failed job. When {@link retryBackoff} is
40
+ * enabled this is the *base* delay that the backoff curve grows from. Backends
41
+ * that measure retry delay in whole seconds receive this rounded to the
42
+ * nearest second.
43
+ */
44
+ retryDelay?: Duration;
45
+ /**
46
+ * Grow the delay between successive retries exponentially (with jitter)
47
+ * starting from {@link retryDelay}, instead of waiting a fixed
48
+ * {@link retryDelay} each time. Useful for backing off transient failures such
49
+ * as a rate-limited external API.
50
+ */
51
+ retryBackoff?: boolean;
52
+ /**
53
+ * Upper bound on the delay between retries when {@link retryBackoff} is
54
+ * enabled. Ignored for fixed-delay retries. Rounded to whole seconds for
55
+ * backends that require it.
56
+ */
57
+ retryDelayMax?: Duration;
58
+ /**
59
+ * How long a job may run before it is considered stuck and made eligible for
60
+ * retry (or failure). Maps onto pg-boss `expireInSeconds`, an SQS visibility
61
+ * timeout, and similar. Rounded to whole seconds for backends that require it.
62
+ */
63
+ expiresIn?: Duration;
64
+ /**
65
+ * Name of the dead-letter queue that receives a job once it has exhausted all
66
+ * of its retries, so terminal failures are preserved for inspection or replay
67
+ * instead of being dropped. The referenced queue must exist; backends that can
68
+ * do so (pg-boss) create it automatically when absent.
69
+ */
70
+ deadLetter?: string;
71
+ }
72
+ //# sourceMappingURL=job.queue.policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.queue.policy.d.ts","sourceRoot":"","sources":["../src/job.queue.policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC;IAEtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IAEvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,QAAQ,CAAC;IAEzB;;;;OAIG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC;IAErB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
@@ -0,0 +1,56 @@
1
+ import { PgBossConnectionProvider } from './pgboss.connection.provider.js';
2
+ import { fromKysely, type Db } from 'pg-boss';
3
+ /**
4
+ * Structural shape of a Kysely instance or transaction, matching what pg-boss's
5
+ * `fromKysely` adapter consumes.
6
+ *
7
+ * Declared structurally rather than as `Kysely<DB>` so the package carries no
8
+ * dependency (not even an optional peer) on `kysely`, and so both `Kysely<DB>`
9
+ * and `Transaction<DB>` are accepted without a type argument or a cast.
10
+ */
11
+ export interface KyselyLike {
12
+ withoutPlugins(): Parameters<typeof fromKysely>[0];
13
+ }
14
+ /**
15
+ * {@link PgBossConnectionProvider} bound to an active Kysely transaction, so
16
+ * jobs enqueued while that transaction is open commit or roll back with it.
17
+ *
18
+ * Register it as a request-scoped override of {@link PgBossConnectionProvider}
19
+ * alongside whatever binds the transaction itself, and every enqueue performed
20
+ * during the request inserts on the transaction's connection instead of
21
+ * pg-boss's pool — closing the dual-write gap between domain writes and job
22
+ * enqueues.
23
+ *
24
+ * Plugins are stripped before the transaction is adapted: pg-boss runs raw SQL
25
+ * straight through `executeQuery`, so a column-rewriting plugin on the caller's
26
+ * instance (a camel-case mapper, for example) would corrupt pg-boss's own
27
+ * result columns. `withoutPlugins()` returns an instance sharing the same
28
+ * connection-bound executor, so atomicity is preserved.
29
+ *
30
+ * @example
31
+ * ```typescript
32
+ * await db.transaction().execute(async trx => {
33
+ * const scope = container.createScope();
34
+ * scope.override(PgBossConnectionProvider, new KyselyTransactionConnectionProvider(trx));
35
+ *
36
+ * await repository.createOrder(trx, order);
37
+ * await scope.get(JobBroker).send(new SendReceiptJob({ orderId: order.id }));
38
+ * });
39
+ * ```
40
+ */
41
+ export declare class KyselyTransactionConnectionProvider extends PgBossConnectionProvider {
42
+ private readonly trx;
43
+ /**
44
+ * @param trx - The active Kysely transaction (or any Kysely instance) whose
45
+ * connection job inserts should run on.
46
+ */
47
+ constructor(trx: KyselyLike);
48
+ /**
49
+ * Returns the transaction's connection adapted to pg-boss's executor shape,
50
+ * with the caller's Kysely plugins stripped.
51
+ *
52
+ * @returns A {@link Db} executor bound to the transaction's connection.
53
+ */
54
+ executor(): Db;
55
+ }
56
+ //# sourceMappingURL=kysely.transaction.connection.provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kysely.transaction.connection.provider.d.ts","sourceRoot":"","sources":["../../src/pgboss/kysely.transaction.connection.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB,cAAc,IAAI,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;CACpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,mCAAoC,SAAQ,wBAAwB;IAKnE,OAAO,CAAC,QAAQ,CAAC,GAAG;IAJhC;;;OAGG;gBAC0B,GAAG,EAAE,UAAU;IAI5C;;;;;OAKG;IACM,QAAQ,IAAI,EAAE;CAGxB"}
@@ -0,0 +1,82 @@
1
+ import { PgBoss } from 'pg-boss';
2
+ import { JobInfo } from '../job.info.js';
3
+ import { JobMonitor, JobQueryOptions, JobQueueStats, JobRedriveOptions } from '../job.monitor.js';
4
+ import { PgBossConnectionProvider } from './pgboss.connection.provider.js';
5
+ /**
6
+ * pg-boss implementation of the {@link JobMonitor} interface.
7
+ *
8
+ * Provides the operator-side view of pg-boss queues — depth/health stats, job
9
+ * enumeration, and dead-letter remediation (redrive, discard, retry) — on top of
10
+ * pg-boss's native `getQueue`, `findJobs`, `redrive`, `deleteJob`, and `retry`.
11
+ *
12
+ * Like {@link PgBossJobBroker}, every operation sources its pg-boss `db` executor
13
+ * from the injected {@link PgBossConnectionProvider}, so a remediation action can
14
+ * participate in a surrounding transaction when a request-scoped override supplies
15
+ * a transaction-bound executor. Unlike the broker, the monitor does not consult
16
+ * the job registry: it works on any queue name, including an unregistered
17
+ * dead-letter sink.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const monitor = new PgBossJobMonitor(pgboss, new PgBossConnectionProvider());
22
+ *
23
+ * const stats = await monitor.getQueueStats('charge.webhook.dead');
24
+ * if (stats && stats.total > 0) {
25
+ * await monitor.redrive('charge.webhook.dead', { limit: 100 });
26
+ * }
27
+ * ```
28
+ */
29
+ export declare class PgBossJobMonitor extends JobMonitor {
30
+ private readonly pgboss;
31
+ private readonly connectionProvider;
32
+ /**
33
+ * Creates a new PgBossJobMonitor instance.
34
+ *
35
+ * @param pgboss - The pg-boss instance to use for queue operations.
36
+ * @param connectionProvider - Supplies the pg-boss `db` executor for each
37
+ * operation; the default returns `undefined` (pg-boss's own pool),
38
+ * while a request-scoped override enables transactional remediation.
39
+ */
40
+ constructor(pgboss: PgBoss, connectionProvider: PgBossConnectionProvider);
41
+ /**
42
+ * Reports the depth and health of a queue by reading pg-boss's cached queue
43
+ * counters.
44
+ *
45
+ * @param name - The queue name to inspect.
46
+ * @returns The {@link JobQueueStats}, or `null` if the queue does not exist.
47
+ */
48
+ getQueueStats(name: string): Promise<JobQueueStats | null>;
49
+ /**
50
+ * Lists jobs retained in a queue, mapping pg-boss's records down to the
51
+ * backend-agnostic {@link JobInfo} shape.
52
+ *
53
+ * @typeParam Payload - The type of the job payloads.
54
+ * @param name - The queue name to list.
55
+ * @param options - Optional {@link JobQueryOptions} filters.
56
+ * @returns The matching jobs (empty if none, or if the queue does not exist).
57
+ */
58
+ listJobs<Payload extends object>(name: string, options?: JobQueryOptions): Promise<JobInfo<Payload>[]>;
59
+ /**
60
+ * Moves dead-lettered jobs back into circulation via pg-boss `redrive`.
61
+ *
62
+ * @param name - The (dead-letter) queue to drain.
63
+ * @param options - Optional {@link JobRedriveOptions}.
64
+ * @returns The number of jobs moved.
65
+ */
66
+ redrive(name: string, options?: JobRedriveOptions): Promise<number>;
67
+ /**
68
+ * Permanently deletes one or more jobs from a queue.
69
+ *
70
+ * @param name - The queue name the jobs live in.
71
+ * @param id - A single job id, or an array of ids, to delete.
72
+ */
73
+ deleteJob(name: string, id: string | string[]): Promise<void>;
74
+ /**
75
+ * Re-attempts one or more failed jobs in place via pg-boss `retry`.
76
+ *
77
+ * @param name - The queue name the jobs live in.
78
+ * @param id - A single job id, or an array of ids, to retry.
79
+ */
80
+ retryJob(name: string, id: string | string[]): Promise<void>;
81
+ }
82
+ //# sourceMappingURL=pgboss.job.monitor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pgboss.job.monitor.d.ts","sourceRoot":"","sources":["../../src/pgboss/pgboss.job.monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBACa,gBAAiB,SAAQ,UAAU;IAU5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAVrC;;;;;;;OAOG;gBAEgB,MAAM,EAAE,MAAM,EACd,kBAAkB,EAAE,wBAAwB;IAK/D;;;;;;OAMG;IACG,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAehE;;;;;;;;OAQG;IACG,QAAQ,CAAC,OAAO,SAAS,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;IAW5G;;;;;;OAMG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;IASzE;;;;;OAKG;IACG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE;;;;;OAKG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAGnE"}
@@ -1,31 +1,56 @@
1
1
  import { Identifier } from 'injectkit';
2
2
  import { Job } from '../job.js';
3
+ import { JobQueuePolicy } from '../job.queue.policy.js';
3
4
  /**
4
- * Configuration for a scheduled job registration.
5
+ * Configuration object for a job registration.
5
6
  *
6
- * Use this type when you need to register a job that runs on a schedule
7
- * rather than being triggered manually.
7
+ * Use the object form (rather than a bare job identifier) when you need to
8
+ * attach a cron schedule, a per-queue {@link JobQueuePolicy}, or both. Every
9
+ * field beyond `job` is optional, so this shape covers three cases:
10
+ *
11
+ * - `{ job }` — an on-demand job (equivalent to registering the bare identifier).
12
+ * - `{ job, cron }` — a job that also runs on a schedule.
13
+ * - `{ job, policy }` / `{ job, cron, policy }` — either of the above with retry
14
+ * and dead-letter behavior declared where the job is mapped.
8
15
  *
9
16
  * @example
10
17
  * ```typescript
18
+ * // Scheduled job
11
19
  * const scheduledJob: PgBossJobRegistration = {
12
20
  * job: DailyReportJob,
13
- * cron: '0 9 * * *' // Every day at 9 AM
21
+ * cron: '0 9 * * *', // Every day at 9 AM
22
+ * };
23
+ *
24
+ * // On-demand job with a retry / dead-letter policy
25
+ * const webhookJob: PgBossJobRegistration = {
26
+ * job: DeliverWebhookJob,
27
+ * policy: {
28
+ * retryLimit: 5,
29
+ * retryDelay: Duration.fromObject({ seconds: 30 }),
30
+ * retryBackoff: true,
31
+ * deadLetter: 'deliver.webhook.dead',
32
+ * },
14
33
  * };
15
34
  * ```
16
35
  */
17
36
  export type PgBossJobRegistration = {
18
37
  /** The job class identifier to instantiate when the job runs. */
19
38
  job: Identifier<Job>;
20
- /** A cron expression defining when the job should run. */
21
- cron: string;
39
+ /** An optional cron expression defining when the job should run. */
40
+ cron?: string;
41
+ /**
42
+ * An optional per-queue retry and dead-letter policy applied to this job's
43
+ * queue when the runner starts. See {@link JobQueuePolicy}.
44
+ */
45
+ policy?: JobQueuePolicy;
22
46
  };
23
47
  /**
24
48
  * Registry map for PgBoss job registrations.
25
49
  *
26
50
  * This map holds all job registrations, mapping job names to either:
27
- * - A job class identifier (for on-demand jobs)
28
- * - A {@link PgBossJobRegistration} object (for scheduled jobs)
51
+ * - A bare job class identifier (for a plain on-demand job)
52
+ * - A {@link PgBossJobRegistration} object, which adds an optional cron schedule
53
+ * and/or an optional per-queue {@link JobQueuePolicy}
29
54
  *
30
55
  * The registry is used by both {@link PgBossJobBroker} and {@link PgBossJobRunner}
31
56
  * to validate job names and resolve job handlers.
@@ -43,6 +68,12 @@ export type PgBossJobRegistration = {
43
68
  * cron: '0 0 * * *'
44
69
  * });
45
70
  *
71
+ * // Register an on-demand job with a retry / dead-letter policy
72
+ * registry.set('deliver-webhook', {
73
+ * job: DeliverWebhookJob,
74
+ * policy: { retryLimit: 5, deadLetter: 'deliver-webhook-dead' }
75
+ * });
76
+ *
46
77
  * // Use with dependency injection
47
78
  * container.bind(PgBossJobRegistryMap).toValue(registry);
48
79
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"pgboss.job.registration.d.ts","sourceRoot":"","sources":["../../src/pgboss/pgboss.job.registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,iEAAiE;IACjE,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACrB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBACa,oBAAqB,SAAQ,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC;CAAG"}
1
+ {"version":3,"file":"pgboss.job.registration.d.ts","sourceRoot":"","sources":["../../src/pgboss/pgboss.job.registration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAc,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,iEAAiE;IACjE,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;IACrB,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBACa,oBAAqB,SAAQ,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,GAAG,qBAAqB,CAAC;CAAG"}
@@ -1,5 +1,6 @@
1
1
  import { PgBoss } from 'pg-boss';
2
2
  import { Container } from 'injectkit';
3
+ import { JobQueuePolicy } from '../job.queue.policy.js';
3
4
  import { JobRunner } from '../job.runner.js';
4
5
  import { PgBossJobRegistryMap } from './pgboss.job.registration.js';
5
6
  import { Logger } from '@maroonedsoftware/logger';
@@ -49,6 +50,19 @@ export declare class PgBossJobRunner extends JobRunner {
49
50
  * @default 5
50
51
  */
51
52
  cancelPollIntervalSeconds: number;
53
+ /**
54
+ * A base {@link JobQueuePolicy} applied to *every* registered queue, beneath
55
+ * each queue's own policy. Set it to give all queues sane retry/dead-letter
56
+ * defaults without repeating them on each registration; a field a queue sets
57
+ * on its own `policy` overrides the same field here.
58
+ *
59
+ * Leave it unset (the default) to opt in per queue only. When neither this nor
60
+ * a queue's own policy supplies any option, that queue is created exactly as
61
+ * before, with no options passed.
62
+ *
63
+ * @default undefined
64
+ */
65
+ defaultQueuePolicy?: JobQueuePolicy;
52
66
  /**
53
67
  * Creates a new PgBossJobRunner instance.
54
68
  *
@@ -62,9 +76,15 @@ export declare class PgBossJobRunner extends JobRunner {
62
76
  * Starts the job runner and begins processing registered jobs.
63
77
  *
64
78
  * For each registered job, this method:
65
- * 1. Creates the queue if it doesn't exist
66
- * 2. Sets up the cron schedule (for scheduled jobs)
67
- * 3. Starts a worker to process jobs from the queue
79
+ * 1. Resolves the effective queue policy (the runner's {@link defaultQueuePolicy}
80
+ * merged with the registration's own policy, if any)
81
+ * 2. Auto-creates any dead-letter queue the policy references, before the queue
82
+ * that references it
83
+ * 3. Creates the queue with the policy's options if it doesn't exist, or updates
84
+ * an existing queue to match; when no policy applies, the queue is created
85
+ * with the name only (unchanged pre-policy behavior)
86
+ * 4. Sets up the cron schedule (for scheduled jobs)
87
+ * 5. Starts a worker to process jobs from the queue
68
88
  *
69
89
  * Each item in a batch resolves its `Job` instance from the DI container
70
90
  * individually and execution is awaited via `Promise.allSettled`, so pg-boss
@@ -74,6 +94,41 @@ export declare class PgBossJobRunner extends JobRunner {
74
94
  * @returns A promise that resolves when all workers are registered with pg-boss.
75
95
  */
76
96
  start(): Promise<void>;
97
+ /**
98
+ * Merges the runner-wide {@link defaultQueuePolicy} with a registration's own
99
+ * policy, letting the registration override individual fields. Returns
100
+ * `undefined` when neither supplies a policy, so a queue with no policy is left
101
+ * to pg-boss defaults and created exactly as it was before this feature.
102
+ *
103
+ * @param registration - The registry entry (a bare identifier or an object).
104
+ * @returns The effective policy for the queue, or `undefined` if none applies.
105
+ * @internal
106
+ */
107
+ private resolvePolicy;
108
+ /**
109
+ * Ensures a queue exists and, when a policy is supplied, that its retry and
110
+ * dead-letter options match. Creates the queue (with options) when absent, and
111
+ * updates an existing queue's options when a policy is given. When no policy
112
+ * option resolves, an absent queue is created with the name only — byte-for-byte
113
+ * the pre-policy behavior — and an existing queue is left untouched.
114
+ *
115
+ * @param name - The queue name to ensure.
116
+ * @param policy - The effective policy, or `undefined` for none.
117
+ * @param ensured - Names already ensured during this start pass (mutated).
118
+ * @internal
119
+ */
120
+ private ensureQueue;
121
+ /**
122
+ * Maps a backend-agnostic {@link JobQueuePolicy} onto pg-boss's native queue
123
+ * options. Luxon {@link Duration}s become whole-second counts (pg-boss measures
124
+ * these in seconds). Returns `undefined` when the policy carries no options to
125
+ * apply, so callers fall back to the name-only create/no-op update path.
126
+ *
127
+ * @param policy - The effective policy for a queue.
128
+ * @returns The pg-boss queue options, or `undefined` if the policy is empty.
129
+ * @internal
130
+ */
131
+ private toQueueOptions;
77
132
  /**
78
133
  * Polls pg-boss for a running job and aborts the given controller when the job
79
134
  * has been cancelled (or has disappeared, e.g. via {@link PgBossJobBroker.deleteJob}).
@@ -1 +1 @@
1
- {"version":3,"file":"pgboss.job.runner.d.ts","sourceRoot":"","sources":["../../src/pgboss/pgboss.job.runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAc,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAyB,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAclD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,eAAgB,SAAQ,SAAS;IAqB1C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAvBzB;;;;;;;;OAQG;IACH,yBAAyB,SAAK;IAE9B;;;;;;;OAOG;gBAEgB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,oBAAoB,EACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAKjC;;;;;;;;;;;;;;OAcG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAwD5B;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,oBAAoB;IAuB5B;;;;;;;;;OASG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
1
+ {"version":3,"file":"pgboss.job.runner.d.ts","sourceRoot":"","sources":["../../src/pgboss/pgboss.job.runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,MAAM,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAc,MAAM,WAAW,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAyB,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAsBlD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBACa,eAAgB,SAAQ,SAAS;IAmC1C,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IArCzB;;;;;;;;OAQG;IACH,yBAAyB,SAAK;IAE9B;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,cAAc,CAAC;IAEpC;;;;;;;OAOG;gBAEgB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,oBAAoB,EACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM;IAKjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAoE5B;;;;;;;;;OASG;IACH,OAAO,CAAC,aAAa;IAQrB;;;;;;;;;;;OAWG;YACW,WAAW;IAuBzB;;;;;;;;;OASG;IACH,OAAO,CAAC,cAAc;IAuBtB;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,oBAAoB;IAuB5B;;;;;;;;;OASG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAG5B"}
package/dist/pgboss.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from './pgboss/pgboss.job.broker.js';
2
+ export * from './pgboss/pgboss.job.monitor.js';
2
3
  export * from './pgboss/pgboss.job.runner.js';
3
4
  export * from './pgboss/pgboss.job.registration.js';
4
5
  export * from './pgboss/pgboss.connection.provider.js';
6
+ export * from './pgboss/kysely.transaction.connection.provider.js';
5
7
  //# sourceMappingURL=pgboss.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pgboss.d.ts","sourceRoot":"","sources":["../src/pgboss.ts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC"}
1
+ {"version":3,"file":"pgboss.d.ts","sourceRoot":"","sources":["../src/pgboss.ts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qCAAqC,CAAC;AACpD,cAAc,wCAAwC,CAAC;AACvD,cAAc,oDAAoD,CAAC"}