@zukhruf/sqlite-queue 0.0.0-stage → 0.3.41

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.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +151 -2
  3. package/dist/activity.d.ts +10 -0
  4. package/dist/activity.d.ts.map +1 -0
  5. package/dist/activity.js +93 -0
  6. package/dist/activity.js.map +1 -0
  7. package/dist/attorney.d.ts +35 -0
  8. package/dist/attorney.d.ts.map +1 -0
  9. package/dist/attorney.js +367 -0
  10. package/dist/attorney.js.map +1 -0
  11. package/dist/claim-timer.d.ts +8 -0
  12. package/dist/claim-timer.d.ts.map +1 -0
  13. package/dist/claim-timer.js +80 -0
  14. package/dist/claim-timer.js.map +1 -0
  15. package/dist/completion-data.d.ts +6 -0
  16. package/dist/completion-data.d.ts.map +1 -0
  17. package/dist/completion-data.js +36 -0
  18. package/dist/completion-data.js.map +1 -0
  19. package/dist/database-error.d.ts +6 -0
  20. package/dist/database-error.d.ts.map +1 -0
  21. package/dist/database-error.js +12 -0
  22. package/dist/database-error.js.map +1 -0
  23. package/dist/database.d.ts +7 -0
  24. package/dist/database.d.ts.map +1 -0
  25. package/dist/database.js +28 -0
  26. package/dist/database.js.map +1 -0
  27. package/dist/in-flight.d.ts +7 -0
  28. package/dist/in-flight.d.ts.map +1 -0
  29. package/dist/in-flight.js +24 -0
  30. package/dist/in-flight.js.map +1 -0
  31. package/dist/index.d.ts +54 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +1069 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/job-fetcher.d.ts +16 -0
  36. package/dist/job-fetcher.d.ts.map +1 -0
  37. package/dist/job-fetcher.js +227 -0
  38. package/dist/job-fetcher.js.map +1 -0
  39. package/dist/job-queue.d.ts +27 -0
  40. package/dist/job-queue.d.ts.map +1 -0
  41. package/dist/job-queue.js +2 -0
  42. package/dist/job-queue.js.map +1 -0
  43. package/dist/job-rows.d.ts +49 -0
  44. package/dist/job-rows.d.ts.map +1 -0
  45. package/dist/job-rows.js +155 -0
  46. package/dist/job-rows.js.map +1 -0
  47. package/dist/job-settler.d.ts +24 -0
  48. package/dist/job-settler.d.ts.map +1 -0
  49. package/dist/job-settler.js +240 -0
  50. package/dist/job-settler.js.map +1 -0
  51. package/dist/jsonb.d.ts +7 -0
  52. package/dist/jsonb.d.ts.map +1 -0
  53. package/dist/jsonb.js +85 -0
  54. package/dist/jsonb.js.map +1 -0
  55. package/dist/local-groups.d.ts +16 -0
  56. package/dist/local-groups.d.ts.map +1 -0
  57. package/dist/local-groups.js +113 -0
  58. package/dist/local-groups.js.map +1 -0
  59. package/dist/naive-timestamp.d.ts +6 -0
  60. package/dist/naive-timestamp.d.ts.map +1 -0
  61. package/dist/naive-timestamp.js +21 -0
  62. package/dist/naive-timestamp.js.map +1 -0
  63. package/dist/queue-cache.d.ts +9 -0
  64. package/dist/queue-cache.d.ts.map +1 -0
  65. package/dist/queue-cache.js +27 -0
  66. package/dist/queue-cache.js.map +1 -0
  67. package/dist/queue-rows.d.ts +25 -0
  68. package/dist/queue-rows.d.ts.map +1 -0
  69. package/dist/queue-rows.js +44 -0
  70. package/dist/queue-rows.js.map +1 -0
  71. package/dist/recurrence.d.ts +11 -0
  72. package/dist/recurrence.d.ts.map +1 -0
  73. package/dist/recurrence.js +226 -0
  74. package/dist/recurrence.js.map +1 -0
  75. package/dist/rows.d.ts +10 -0
  76. package/dist/rows.d.ts.map +1 -0
  77. package/dist/rows.js +46 -0
  78. package/dist/rows.js.map +1 -0
  79. package/dist/schema.d.ts +3 -0
  80. package/dist/schema.d.ts.map +1 -0
  81. package/dist/schema.js +139 -0
  82. package/dist/schema.js.map +1 -0
  83. package/dist/sql-values.d.ts +9 -0
  84. package/dist/sql-values.d.ts.map +1 -0
  85. package/dist/sql-values.js +26 -0
  86. package/dist/sql-values.js.map +1 -0
  87. package/dist/start-after.d.ts +10 -0
  88. package/dist/start-after.d.ts.map +1 -0
  89. package/dist/start-after.js +125 -0
  90. package/dist/start-after.js.map +1 -0
  91. package/dist/supervisor.d.ts +16 -0
  92. package/dist/supervisor.d.ts.map +1 -0
  93. package/dist/supervisor.js +288 -0
  94. package/dist/supervisor.js.map +1 -0
  95. package/dist/throttle.d.ts +6 -0
  96. package/dist/throttle.d.ts.map +1 -0
  97. package/dist/throttle.js +35 -0
  98. package/dist/throttle.js.map +1 -0
  99. package/dist/timekeeper.d.ts +36 -0
  100. package/dist/timekeeper.d.ts.map +1 -0
  101. package/dist/timekeeper.js +305 -0
  102. package/dist/timekeeper.js.map +1 -0
  103. package/dist/timers.d.ts +9 -0
  104. package/dist/timers.d.ts.map +1 -0
  105. package/dist/timers.js +50 -0
  106. package/dist/timers.js.map +1 -0
  107. package/dist/uuid.d.ts +7 -0
  108. package/dist/uuid.d.ts.map +1 -0
  109. package/dist/uuid.js +36 -0
  110. package/dist/uuid.js.map +1 -0
  111. package/dist/worker.d.ts +35 -0
  112. package/dist/worker.d.ts.map +1 -0
  113. package/dist/worker.js +147 -0
  114. package/dist/worker.js.map +1 -0
  115. package/package.json +53 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ezzabuzaid
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,152 @@
1
- # Temporary Holding Version
1
+ # @zukhruf/sqlite-queue
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A program sends jobs to a queue, and workers do the jobs later, also after the program restarts. [pg-boss](https://github.com/timgit/pg-boss) is a job queue that keeps its jobs in Postgres. A program that has no Postgres server, for example a desktop app or a CLI, cannot use it. This package keeps the jobs in one SQLite file through `node:sqlite`, and gives the API of pg-boss: the same method names, the same options, the same results and the same errors. The API is a declared subset of pg-boss: 13 methods of `PgBoss`.
4
+
5
+ Zero divergence is the contract. A parity suite runs each scenario on real pg-boss 12.35.1 over PGlite, and on this package. Then it compares what each engine returned, stored and emitted. A test passes only when the two are equal. Thus a program can change from one engine to the other and keep its code.
6
+
7
+ The words in these documents have one meaning each. See the glossary in [CONTEXT.md](./CONTEXT.md).
8
+
9
+ ## Use it
10
+
11
+ This project is an experiment. It uses `node:sqlite`, and it uses pg-boss for its types and some of its values.
12
+
13
+ ```sh
14
+ npm install @zukhruf/sqlite-queue
15
+ ```
16
+
17
+ ```ts
18
+ import { mkdtempDisposable } from 'node:fs/promises';
19
+ import { tmpdir } from 'node:os';
20
+ import { join } from 'node:path';
21
+
22
+ import { type JobQueue, SqliteJobQueue } from '@zukhruf/sqlite-queue';
23
+
24
+ await using scratch = await mkdtempDisposable(join(tmpdir(), 'queue-'));
25
+ const queue: JobQueue = new SqliteJobQueue({
26
+ path: join(scratch.path, 'jobs.sqlite'),
27
+ });
28
+ queue.on('error', (error) => console.error(error));
29
+ await queue.start();
30
+ await queue.createQueue('email', { retryLimit: 2 });
31
+ await queue.send('email', { to: 'ada@example.com' });
32
+
33
+ const sent = Promise.withResolvers<void>();
34
+ await queue.work('email', async ([job]) => {
35
+ console.log('send to', job?.data);
36
+ sent.resolve();
37
+ });
38
+ await sent.promise;
39
+ await queue.stop();
40
+ ```
41
+
42
+ Output:
43
+
44
+ ```
45
+ send to { to: 'ada@example.com' }
46
+ ```
47
+
48
+ A `PgBoss` is also a `JobQueue`. Thus the same code runs on Postgres:
49
+
50
+ ```ts
51
+ import { PgBoss } from 'pg-boss';
52
+
53
+ const queue: JobQueue = new PgBoss(process.env.DATABASE_URL);
54
+ ```
55
+
56
+ ## The rules
57
+
58
+ - `new SqliteJobQueue({ path })` owns the database file. `start()` opens it and makes the tables, and `stop()` closes it.
59
+ - `new SqliteJobQueue({ database })` uses a `DatabaseSync` that the caller opened. The caller closes it.
60
+ - With no `path` and no `database`, the queue keeps its jobs in memory.
61
+ - The other options are the options of pg-boss with the same names: `clock`, `supervise`, `superviseIntervalSeconds`, `monitorIntervalSeconds`, `maintenanceIntervalSeconds`, `queueCacheIntervalSeconds`, `warningQueueSize`, `useListenNotify`, `schedule`, `cronMonitorIntervalSeconds`, `cronWorkerIntervalSeconds` and `clockMonitorIntervalSeconds`. The defaults are the defaults of pg-boss.
62
+ - The types of the options, the jobs and the results come from pg-boss. Import them from `pg-boss`, for example `import type { Job, SendOptions } from 'pg-boss'`.
63
+ - Job data is `unknown`. `work()` gives each handler `Job<unknown>`, and `findJobs()` gives `FoundJob<unknown>`. Validate the data that you read.
64
+ - A listener for `error` is necessary. A failure in work that no caller awaits, for example a worker poll, goes to the `error` event. With no listener, `EventEmitter` throws.
65
+ - `useListenNotify` wakes the workers of this `SqliteJobQueue` only. In pg-boss, each listener on the schema hears a `NOTIFY`. Here, another instance on the same file does not hear it.
66
+
67
+ ## Upgrades
68
+
69
+ A new release can change the tables. A file that an earlier release made keeps its jobs and its schedules ([ADR 0004](./docs/adr/0004-the-schema-is-a-declaration-and-keeps-the-jobs.md)).
70
+
71
+ - The schema is a declaration of [`@zukhruf/sqlite-drift`](../drift) with `rows: 'keep'`. `start()` compares the tables and the indexes in the file with the declaration.
72
+ - `start()` makes each missing object. It rebuilds each stale table and keeps its rows, and it replaces each stale index.
73
+ - No release writes a migration, and no file keeps a version number.
74
+ - When a kept row does not fit the declared table, `start()` fails with the error of SQLite, and the file stays as it was.
75
+ - When `pgboss_queue` is stale, the rebuild turns foreign keys off around its own transaction. Do not call `start()` in a transaction of your own.
76
+
77
+ ## Schedules
78
+
79
+ A schedule sends a job to its queue at each time that its cron or rrule rule gives. The timekeeper of pg-boss does this work, and this package copies it ([ADR 0003](./docs/adr/0003-the-timekeeper-is-ported-literally.md)).
80
+
81
+ - `schedule` is `true` by default, as in pg-boss. `start()` then makes the queue `__pgboss__send-it`, starts one worker on it, and starts the cron pass. `schedule: false` starts none of them.
82
+ - The cron pass runs at start, then every `cronMonitorIntervalSeconds` (30 by default) on the clock. It finds the occurrences of each schedule in the last 60 seconds. For each occurrence, it puts one job in `__pgboss__send-it`, in the slot of the minute of the occurrence. A unique index keeps one job for each schedule and slot, so the next pass does not send the same occurrence again.
83
+ - The worker of `__pgboss__send-it` polls every `cronWorkerIntervalSeconds` (5 by default). It sends each job to the queue of its schedule, with the data and the options of the schedule. Thus a job goes out up to 35 seconds after its time, as in pg-boss.
84
+ - A cron expression without `tz` uses UTC. An rrule without `DTSTART` counts from 1970-01-01, so `FREQ=MINUTELY;INTERVAL=2` gives the even minutes.
85
+ - `missed` tells the pass what to do after a time when no pass ran, for example when the program was stopped. With `skip` (the default), the pass sends only the occurrences of the last 60 seconds. With `once`, the pass also sends the latest occurrence of that time, but not one from before the schedule was written.
86
+ - When the send to the queue of the schedule fails, the failure goes to the `error` event, and the job in `__pgboss__send-it` completes. The pass does not send the occurrence again.
87
+ - `__pgboss__send-it` is a queue like the others: `findJobs` reads its jobs. Its worker is not in the `wip` events.
88
+ - `clockMonitorIntervalSeconds` is validated only. pg-boss uses it to measure the difference between its clock and the clock of Postgres. Here the clock of the queue is the clock of the database.
89
+
90
+ ## The subset
91
+
92
+ | Method | What it does |
93
+ | ------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
94
+ | `on('error', listener)` | Receives the failures that no caller awaits. |
95
+ | `start()`, `stop(options)` | Start and stop the queue. A second call while one runs shares it. |
96
+ | `createQueue(name, options)`, `updateQueue(name, options)`, `deleteQueue(name)` | Make, change and remove a queue, with its policy, retries, expiry, retention and dead letter queue. |
97
+ | `send(name, data, options)`, `send({ name, data, options })` | Add a job. It gives the id of the job, or `null` when a singleton or throttle refuses the job. |
98
+ | `work(name, handler)`, `work(name, options, handler)` | Start workers that fetch jobs and give them to the handler. It gives the id of the work. |
99
+ | `offWork(name, options)` | Stop the workers of a queue. |
100
+ | `findJobs(name, options)` | Find jobs by id, key, data or queued state. |
101
+ | `cancel(name, id)`, `fail(name, id, data)` | Cancel or fail jobs by id or by attempt. |
102
+ | `schedule(name, cron, data, options)`, `unschedule(name, key)` | Send a job on a cron or rrule schedule, and remove the schedule. |
103
+
104
+ Other methods of `PgBoss` are not in the subset, for example `getQueue`, `getJobById`, `complete`, `retry`, `resume`, `deleteJob`, `sendAfter`, `insert` and `getDb`. A method that needs Postgres itself, for example `getDb` and its SQL, will not come.
105
+
106
+ ## Errors
107
+
108
+ | Error | When |
109
+ | ------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
110
+ | `DatabaseError` | The same refusal that Postgres gives pg-boss, with its message and its SQLSTATE in `code`. For example `23503` for a dead letter queue that does not exist, `22P05` for `\u0000` in a JSON value, `23505`. |
111
+ | `UnsupportedStartAfterError` | A `startAfter` string outside the forms that this package resolves: a `Date`, seconds, an ISO 8601 date time or duration, or Postgres interval units with integer amounts. |
112
+ | The `Error` or `AssertionError` of pg-boss | A refused argument, with the message that pg-boss gives. For example `Workers are disabled. pg-boss is stopped`. |
113
+ | The error of SQLite | All other failures. |
114
+
115
+ Code that runs on both engines examines `code`, not the class. On Postgres, the error comes from the driver, not from this package, and `instanceof DatabaseError` is false. The `code` is the same on both engines.
116
+
117
+ ## The same concepts in other systems
118
+
119
+ | System | What it does |
120
+ | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
121
+ | [pg-boss](https://github.com/timgit/pg-boss) | The job queue that this package copies. It keeps the jobs in Postgres, and uses `SKIP LOCKED` to give each job to one worker. |
122
+ | [Oban](https://hexdocs.pm/oban) and its Lite engine | A job queue for Elixir. Its engine is a part apart from its API: the Basic engine uses Postgres, and the Lite engine uses SQLite. The API does not change with the engine. |
123
+ | [Solid Queue](https://github.com/rails/solid_queue) | The job queue of Rails 8. It keeps the jobs in the database of the app: Postgres, MySQL or SQLite. |
124
+
125
+ ## Documentation
126
+
127
+ - [0001 pg-boss's API on SQLite](./docs/adr/0001-pg-boss-api-on-sqlite.md)
128
+ - [0002 The parity suite is the contract](./docs/adr/0002-the-parity-suite-is-the-contract.md)
129
+ - [0003 The timekeeper is ported literally](./docs/adr/0003-the-timekeeper-is-ported-literally.md)
130
+ - [0004 The schema is a declaration and keeps the jobs](./docs/adr/0004-the-schema-is-a-declaration-and-keeps-the-jobs.md)
131
+
132
+ ## Development
133
+
134
+ This package is part of the [zukhruf](../../../README.md) workspace. Run the commands from the workspace root.
135
+
136
+ ```sh
137
+ npm install
138
+ npx nx run sqlite-queue:test # builds, then runs the unit tests and the parity suite
139
+ npx nx run sqlite-queue:typecheck # formats, lints, then type checks
140
+ npx nx run sqlite-queue:build # compiles src/ to dist/
141
+ ```
142
+
143
+ The test target sets `TZ=Asia/Kolkata`. The parity suite needs a zone that is not UTC, because pg-boss reads a throttle slot as local time.
144
+
145
+ ```
146
+ src/
147
+ index.ts SqliteJobQueue and the exports
148
+ job-queue.ts JobQueue, the subset, and FoundJob
149
+ *.ts the parts of the port, each one cites the pg-boss code that it copies
150
+ *.test.ts the unit tests, for behavior that only SQLite has
151
+ parity/ the parity suite: each scenario on pg-boss over PGlite and on SQLite
152
+ ```
@@ -0,0 +1,10 @@
1
+ import type { AttachableClock, Clock } from 'pg-boss';
2
+ export declare class Activity {
3
+ #private;
4
+ static isAttachable(clock: Clock): clock is AttachableClock;
5
+ attach(clock: AttachableClock): Promise<AsyncDisposable>;
6
+ query<T>(statement: () => T): Promise<T>;
7
+ deliver(notification: () => void): Promise<void>;
8
+ idle(): Promise<boolean>;
9
+ }
10
+ //# sourceMappingURL=activity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"activity.d.ts","sourceRoot":"","sources":["../src/activity.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAM,MAAM,SAAS,CAAC;AAM1D,qBAAa,QAAQ;;IAenB,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,IAAI,eAAe;IAK3D,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAUxD,KAAK,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAkBxC,OAAO,CAAC,YAAY,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IA2B1C,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;CAgB/B"}
@@ -0,0 +1,93 @@
1
+ import { setImmediate } from 'node:timers/promises';
2
+ // pg-boss counts the statements it has in flight so an attached TestClock
3
+ // lets them finish before it moves time on (node_modules/pg-boss/dist/
4
+ // activity.js:14-95). node:sqlite answers at once, so what this counts are
5
+ // the event-loop turns standing in for pg-boss's I/O.
6
+ export class Activity {
7
+ // The queue binds clock.now() into its own statements, so the Postgres
8
+ // clock table an attachment writes (clock.js:140-145, 189) has no receiver.
9
+ static #database = {
10
+ executeSql: async () => ({ rows: [] }),
11
+ };
12
+ // Dispose drops the clock table once no target shares the schema
13
+ // (clock.js:158), so this names no schema a PgBoss could use.
14
+ static #schema = 'sqlite job queue';
15
+ #inFlight = 0;
16
+ #started = 0;
17
+ #waiters = [];
18
+ // clock.js:10-12; pg-boss's root exports only TestClock and systemClock.
19
+ static isAttachable(clock) {
20
+ return 'attach' in clock && typeof clock.attach === 'function';
21
+ }
22
+ // index.js:152-154
23
+ attach(clock) {
24
+ return clock.attach({
25
+ db: Activity.#database,
26
+ schema: Activity.#schema,
27
+ idle: () => this.idle(),
28
+ });
29
+ }
30
+ // Runs a statement at once, as PGlite runs each in the order it arrives,
31
+ // and settles with its outcome one turn later, as pg-boss's I/O does.
32
+ query(statement) {
33
+ let outcome;
34
+ try {
35
+ outcome = { value: statement() };
36
+ }
37
+ catch (error) {
38
+ outcome = { error };
39
+ }
40
+ return this.#counted(async () => {
41
+ await setImmediate();
42
+ if ('error' in outcome) {
43
+ throw outcome.error;
44
+ }
45
+ return outcome.value;
46
+ });
47
+ }
48
+ // Runs `notification` one counted turn from now: pg-boss wakes its notify
49
+ // workers at start only after the listener's own I/O (notifier.js:55-57).
50
+ deliver(notification) {
51
+ return this.#counted(async () => {
52
+ await setImmediate();
53
+ notification();
54
+ });
55
+ }
56
+ // Counted while in flight (activity.js:18-33).
57
+ async #counted(work) {
58
+ this.#inFlight++;
59
+ this.#started++;
60
+ try {
61
+ return await work();
62
+ }
63
+ finally {
64
+ this.#inFlight--;
65
+ if (this.#inFlight === 0) {
66
+ const settled = this.#waiters;
67
+ this.#waiters = [];
68
+ for (const resolve of settled) {
69
+ resolve();
70
+ }
71
+ }
72
+ }
73
+ }
74
+ // activity.js:77-93: true if it had to wait. A caller whose turn just
75
+ // ended runs on in microtasks and may start another before this one ends.
76
+ async idle() {
77
+ let waited = false;
78
+ for (;;) {
79
+ if (this.#inFlight > 0) {
80
+ waited = true;
81
+ await new Promise((resolve) => this.#waiters.push(resolve));
82
+ continue;
83
+ }
84
+ const seen = this.#started;
85
+ await setImmediate();
86
+ if (this.#inFlight === 0 && this.#started === seen) {
87
+ return waited;
88
+ }
89
+ waited = true;
90
+ }
91
+ }
92
+ }
93
+ //# sourceMappingUR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E,SAAS;YACX,CAAC;YACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;YAC3B,MAAM,YAAY,EAAE,CAAC;YACrB,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,IAAI,IAAI,CAAC,QAAQ,KAAK,IAAI,EAAE,CAAC;gBACnD,OAAO,MAAM,CAAC;YAChB,CAAC;YACD,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;IACH,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { type Clock, type JobAttempt, type SendOptions } from 'pg-boss';
2
+ import type { TimekeeperConfig } from './timekeeper.ts';
3
+ export type SuperviseIntervals = {
4
+ superviseIntervalSeconds: number;
5
+ maintenanceIntervalSeconds: number;
6
+ monitorIntervalSeconds: number;
7
+ queueCacheIntervalSeconds: number;
8
+ };
9
+ export declare class Attorney {
10
+ #private;
11
+ static readonly MAX_EXPIRATION_HOURS = 24;
12
+ static readonly MIN_POLLING_INTERVAL_MS = 500;
13
+ static applyClockConfig(clock: Clock | undefined): Clock;
14
+ static applyOpsConfig(config: object): SuperviseIntervals;
15
+ static applyScheduleConfig(config: object): TimekeeperConfig;
16
+ static validateWarningConfig(config: object): void;
17
+ static checkWorkArgs(name: unknown, args: readonly unknown[]): {
18
+ pollingInterval: number;
19
+ notifyPollingInterval: number;
20
+ };
21
+ static assertObjectName(value: unknown, name: string): void;
22
+ static mapAttemptArg(id: string | string[] | JobAttempt | JobAttempt[], funcName: string): {
23
+ ids: string[];
24
+ attempts?: number[];
25
+ };
26
+ static assertKey(key: unknown): void;
27
+ static assertQueueName(name: unknown): asserts name is string;
28
+ static validateQueueArgs(config: object): void;
29
+ static checkSendArgs(args: readonly unknown[]): {
30
+ name: unknown;
31
+ data: unknown;
32
+ options: SendOptions;
33
+ };
34
+ }
35
+ //# sourceMappingURL=attorney.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attorney.d.ts","sourceRoot":"","sources":["../src/attorney.ts"],"names":[],"mappings":"AAEA,OA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