pg-boss 12.1.1 → 12.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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  Queueing jobs in Postgres from Node.js like a boss.
2
2
 
3
- [![npm version](https://badge.fury.io/js/pg-boss.svg?icon=si%3Anpm)](https://badge.fury.io/js/pg-boss)
3
+ [![NPM](https://nodei.co/npm/pg-boss.svg?style=shields&color=blue)](https://nodei.co/npm/pg-boss/)
4
4
  [![Build](https://github.com/timgit/pg-boss/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/timgit/pg-boss/actions/workflows/ci.yml)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/timgit/pg-boss/badge.svg?branch=master)](https://coveralls.io/github/timgit/pg-boss?branch=master)
6
6
 
package/dist/index.d.mts CHANGED
@@ -1,227 +1,7 @@
1
+ import { CommandResponse, ConnectionOptions, ConstructorOptions, Events, FetchOptions, IDatabase, InsertOptions, Job, JobFetchOptions, JobInsert, JobPollingOptions, JobStates, JobWithMetadata, MaintenanceOptions, OffWorkOptions, PgBossEventMap, Queue, QueuePolicy, QueueResult, Request, Schedule, ScheduleOptions, SchedulingOptions, SendOptions, StopOptions, UpdateQueueOptions, WipData, WorkHandler, WorkOptions, WorkWithMetadataHandler } from "./src/types.mjs";
2
+ import { JOB_STATES, QUEUE_POLICIES } from "./src/plans.mjs";
1
3
  import EventEmitter from "node:events";
2
4
 
3
- //#region src/types.d.ts
4
- type JobStates = {
5
- created: 'created';
6
- retry: 'retry';
7
- active: 'active';
8
- completed: 'completed';
9
- cancelled: 'cancelled';
10
- failed: 'failed';
11
- };
12
- type Events = {
13
- error: 'error';
14
- warning: 'warning';
15
- wip: 'wip';
16
- stopped: 'stopped';
17
- };
18
- interface IDatabase {
19
- executeSql(text: string, values?: unknown[]): Promise<{
20
- rows: any[];
21
- }>;
22
- }
23
- interface DatabaseOptions {
24
- application_name?: string;
25
- database?: string;
26
- user?: string;
27
- password?: string | (() => string) | (() => Promise<string>);
28
- host?: string;
29
- port?: number;
30
- schema?: string;
31
- ssl?: any;
32
- connectionString?: string;
33
- max?: number;
34
- db?: IDatabase;
35
- }
36
- interface SchedulingOptions {
37
- schedule?: boolean;
38
- clockMonitorIntervalSeconds?: number;
39
- cronWorkerIntervalSeconds?: number;
40
- cronMonitorIntervalSeconds?: number;
41
- }
42
- interface MaintenanceOptions {
43
- supervise?: boolean;
44
- migrate?: boolean;
45
- createSchema?: boolean;
46
- warningSlowQuerySeconds?: number;
47
- warningQueueSize?: number;
48
- superviseIntervalSeconds?: number;
49
- maintenanceIntervalSeconds?: number;
50
- queueCacheIntervalSeconds?: number;
51
- monitorIntervalSeconds?: number;
52
- }
53
- interface ConstructorOptions extends DatabaseOptions, SchedulingOptions, MaintenanceOptions {}
54
- interface QueueOptions {
55
- expireInSeconds?: number;
56
- retentionSeconds?: number;
57
- deleteAfterSeconds?: number;
58
- retryLimit?: number;
59
- retryDelay?: number;
60
- retryBackoff?: boolean;
61
- retryDelayMax?: number;
62
- }
63
- interface JobOptions {
64
- id?: string;
65
- priority?: number;
66
- startAfter?: number | string | Date;
67
- singletonKey?: string;
68
- singletonSeconds?: number;
69
- singletonNextSlot?: boolean;
70
- keepUntil?: number | string | Date;
71
- }
72
- interface ConnectionOptions {
73
- db?: IDatabase;
74
- }
75
- type InsertOptions = ConnectionOptions;
76
- type SendOptions = JobOptions & QueueOptions & ConnectionOptions;
77
- type QueuePolicy = 'standard' | 'short' | 'singleton' | 'stately' | 'exclusive';
78
- interface Queue extends QueueOptions {
79
- name: string;
80
- policy?: QueuePolicy;
81
- partition?: boolean;
82
- deadLetter?: string;
83
- warningQueueSize?: number;
84
- }
85
- interface QueueResult extends Queue {
86
- deferredCount: number;
87
- queuedCount: number;
88
- activeCount: number;
89
- totalCount: number;
90
- table: string;
91
- createdOn: Date;
92
- updatedOn: Date;
93
- singletonsActive: string[] | null;
94
- }
95
- type ScheduleOptions = SendOptions & {
96
- tz?: string;
97
- key?: string;
98
- };
99
- interface JobPollingOptions {
100
- pollingIntervalSeconds?: number;
101
- }
102
- interface JobFetchOptions {
103
- includeMetadata?: boolean;
104
- priority?: boolean;
105
- batchSize?: number;
106
- ignoreStartAfter?: boolean;
107
- }
108
- type WorkOptions = JobFetchOptions & JobPollingOptions;
109
- type FetchOptions = JobFetchOptions & ConnectionOptions;
110
- interface WorkHandler<ReqData> {
111
- (job: Job<ReqData>[]): Promise<any>;
112
- }
113
- interface WorkWithMetadataHandler<ReqData> {
114
- (job: JobWithMetadata<ReqData>[]): Promise<any>;
115
- }
116
- interface Request {
117
- name: string;
118
- data?: object;
119
- options?: SendOptions;
120
- }
121
- interface Schedule {
122
- name: string;
123
- key: string;
124
- cron: string;
125
- timezone: string;
126
- data?: object;
127
- options?: SendOptions;
128
- }
129
- interface Job<T = object> {
130
- id: string;
131
- name: string;
132
- data: T;
133
- expireInSeconds: number;
134
- }
135
- interface JobWithMetadata<T = object> extends Job<T> {
136
- priority: number;
137
- state: 'created' | 'retry' | 'active' | 'completed' | 'cancelled' | 'failed';
138
- retryLimit: number;
139
- retryCount: number;
140
- retryDelay: number;
141
- retryBackoff: boolean;
142
- retryDelayMax?: number;
143
- startAfter: Date;
144
- startedOn: Date;
145
- singletonKey: string | null;
146
- singletonOn: Date | null;
147
- expireInSeconds: number;
148
- deleteAfterSeconds: number;
149
- createdOn: Date;
150
- completedOn: Date | null;
151
- keepUntil: Date;
152
- policy: QueuePolicy;
153
- deadLetter: string;
154
- output: object;
155
- }
156
- interface JobInsert<T = object> {
157
- id?: string;
158
- data?: T;
159
- priority?: number;
160
- retryLimit?: number;
161
- retryDelay?: number;
162
- retryBackoff?: boolean;
163
- retryDelayMax?: number;
164
- startAfter?: number | string | Date;
165
- singletonKey?: string;
166
- singletonSeconds?: number;
167
- expireInSeconds?: number;
168
- deleteAfterSeconds?: number;
169
- retentionSeconds?: number;
170
- }
171
- type WorkerState = 'created' | 'active' | 'stopping' | 'stopped';
172
- interface WipData {
173
- id: string;
174
- name: string;
175
- options: WorkOptions;
176
- state: WorkerState;
177
- count: number;
178
- createdOn: number;
179
- lastFetchedOn: number | null;
180
- lastJobStartedOn: number | null;
181
- lastJobEndedOn: number | null;
182
- lastJobDuration: number | null;
183
- lastError: object | null;
184
- lastErrorOn: number | null;
185
- }
186
- interface StopOptions {
187
- close?: boolean;
188
- graceful?: boolean;
189
- timeout?: number;
190
- wait?: boolean;
191
- }
192
- interface OffWorkOptions {
193
- id: string;
194
- }
195
- type UpdateQueueOptions = Omit<Queue, 'name' | 'partition' | 'policy'>;
196
- interface Warning {
197
- message: string;
198
- data: object;
199
- }
200
- interface CommandResponse {}
201
- type PgBossEventMap = {
202
- error: [error: Error];
203
- warning: [warning: Warning];
204
- wip: [data: WipData[]];
205
- stopped: [];
206
- };
207
- //#endregion
208
- //#region src/plans.d.ts
209
- declare const JOB_STATES: Readonly<{
210
- created: "created";
211
- retry: "retry";
212
- active: "active";
213
- completed: "completed";
214
- cancelled: "cancelled";
215
- failed: "failed";
216
- }>;
217
- declare const QUEUE_POLICIES: Readonly<{
218
- standard: "standard";
219
- short: "short";
220
- singleton: "singleton";
221
- stately: "stately";
222
- exclusive: "exclusive";
223
- }>;
224
- //#endregion
225
5
  //#region src/index.d.ts
226
6
  declare const events: Events;
227
7
  declare function getConstructionPlans(schema?: string): string;
@@ -250,8 +30,7 @@ declare class PgBoss extends EventEmitter<PgBossEventMap> {
250
30
  includeMetadata: true;
251
31
  }, handler: WorkWithMetadataHandler<ReqData>): Promise<string>;
252
32
  work<ReqData>(name: string, options: WorkOptions, handler: WorkHandler<ReqData>): Promise<string>;
253
- offWork(name: string): Promise<void>;
254
- offWork(options: OffWorkOptions): Promise<void>;
33
+ offWork(name: string, options?: OffWorkOptions): Promise<void>;
255
34
  notifyWorker(workerId: string): void;
256
35
  subscribe(event: string, name: string): Promise<void>;
257
36
  unsubscribe(event: string, name: string): Promise<void>;
@@ -281,5 +60,4 @@ declare class PgBoss extends EventEmitter<PgBossEventMap> {
281
60
  getDb(): IDatabase;
282
61
  }
283
62
  //#endregion
284
- export { type ConnectionOptions, type ConstructorOptions, type IDatabase as Db, type Events, type FetchOptions, type Job, type JobFetchOptions, type JobInsert, type JobPollingOptions, type JobStates, type JobWithMetadata, type MaintenanceOptions, type OffWorkOptions, PgBoss, type Queue, type QueuePolicy, type QueueResult, type Request, type Schedule, type ScheduleOptions, type SchedulingOptions, type SendOptions, type StopOptions, type WipData, type WorkHandler, type WorkOptions, type WorkWithMetadataHandler, events, getConstructionPlans, getMigrationPlans, getRollbackPlans, QUEUE_POLICIES as policies, JOB_STATES as states };
285
- //# sourceMappingURL=index.d.mts.map
63
+ export { type ConnectionOptions, type ConstructorOptions, type IDatabase as Db, type Events, type FetchOptions, type Job, type JobFetchOptions, type JobInsert, type JobPollingOptions, type JobStates, type JobWithMetadata, type MaintenanceOptions, type OffWorkOptions, PgBoss, type Queue, type QueuePolicy, type QueueResult, type Request, type Schedule, type ScheduleOptions, type SchedulingOptions, type SendOptions, type StopOptions, type WipData, type WorkHandler, type WorkOptions, type WorkWithMetadataHandler, events, getConstructionPlans, getMigrationPlans, getRollbackPlans, QUEUE_POLICIES as policies, JOB_STATES as states };