pg-boss 12.2.0 → 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/dist/index.d.mts CHANGED
@@ -1,228 +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
- connectionTimeoutMillis?: number;
36
- }
37
- interface SchedulingOptions {
38
- schedule?: boolean;
39
- clockMonitorIntervalSeconds?: number;
40
- cronWorkerIntervalSeconds?: number;
41
- cronMonitorIntervalSeconds?: number;
42
- }
43
- interface MaintenanceOptions {
44
- supervise?: boolean;
45
- migrate?: boolean;
46
- createSchema?: boolean;
47
- warningSlowQuerySeconds?: number;
48
- warningQueueSize?: number;
49
- superviseIntervalSeconds?: number;
50
- maintenanceIntervalSeconds?: number;
51
- queueCacheIntervalSeconds?: number;
52
- monitorIntervalSeconds?: number;
53
- }
54
- interface ConstructorOptions extends DatabaseOptions, SchedulingOptions, MaintenanceOptions {}
55
- interface QueueOptions {
56
- expireInSeconds?: number;
57
- retentionSeconds?: number;
58
- deleteAfterSeconds?: number;
59
- retryLimit?: number;
60
- retryDelay?: number;
61
- retryBackoff?: boolean;
62
- retryDelayMax?: number;
63
- }
64
- interface JobOptions {
65
- id?: string;
66
- priority?: number;
67
- startAfter?: number | string | Date;
68
- singletonKey?: string;
69
- singletonSeconds?: number;
70
- singletonNextSlot?: boolean;
71
- keepUntil?: number | string | Date;
72
- }
73
- interface ConnectionOptions {
74
- db?: IDatabase;
75
- }
76
- type InsertOptions = ConnectionOptions;
77
- type SendOptions = JobOptions & QueueOptions & ConnectionOptions;
78
- type QueuePolicy = 'standard' | 'short' | 'singleton' | 'stately' | 'exclusive';
79
- interface Queue extends QueueOptions {
80
- name: string;
81
- policy?: QueuePolicy;
82
- partition?: boolean;
83
- deadLetter?: string;
84
- warningQueueSize?: number;
85
- }
86
- interface QueueResult extends Queue {
87
- deferredCount: number;
88
- queuedCount: number;
89
- activeCount: number;
90
- totalCount: number;
91
- table: string;
92
- createdOn: Date;
93
- updatedOn: Date;
94
- singletonsActive: string[] | null;
95
- }
96
- type ScheduleOptions = SendOptions & {
97
- tz?: string;
98
- key?: string;
99
- };
100
- interface JobPollingOptions {
101
- pollingIntervalSeconds?: number;
102
- }
103
- interface JobFetchOptions {
104
- includeMetadata?: boolean;
105
- priority?: boolean;
106
- batchSize?: number;
107
- ignoreStartAfter?: boolean;
108
- }
109
- type WorkOptions = JobFetchOptions & JobPollingOptions;
110
- type FetchOptions = JobFetchOptions & ConnectionOptions;
111
- interface WorkHandler<ReqData> {
112
- (job: Job<ReqData>[]): Promise<any>;
113
- }
114
- interface WorkWithMetadataHandler<ReqData> {
115
- (job: JobWithMetadata<ReqData>[]): Promise<any>;
116
- }
117
- interface Request {
118
- name: string;
119
- data?: object;
120
- options?: SendOptions;
121
- }
122
- interface Schedule {
123
- name: string;
124
- key: string;
125
- cron: string;
126
- timezone: string;
127
- data?: object;
128
- options?: SendOptions;
129
- }
130
- interface Job<T = object> {
131
- id: string;
132
- name: string;
133
- data: T;
134
- expireInSeconds: number;
135
- }
136
- interface JobWithMetadata<T = object> extends Job<T> {
137
- priority: number;
138
- state: 'created' | 'retry' | 'active' | 'completed' | 'cancelled' | 'failed';
139
- retryLimit: number;
140
- retryCount: number;
141
- retryDelay: number;
142
- retryBackoff: boolean;
143
- retryDelayMax?: number;
144
- startAfter: Date;
145
- startedOn: Date;
146
- singletonKey: string | null;
147
- singletonOn: Date | null;
148
- expireInSeconds: number;
149
- deleteAfterSeconds: number;
150
- createdOn: Date;
151
- completedOn: Date | null;
152
- keepUntil: Date;
153
- policy: QueuePolicy;
154
- deadLetter: string;
155
- output: object;
156
- }
157
- interface JobInsert<T = object> {
158
- id?: string;
159
- data?: T;
160
- priority?: number;
161
- retryLimit?: number;
162
- retryDelay?: number;
163
- retryBackoff?: boolean;
164
- retryDelayMax?: number;
165
- startAfter?: number | string | Date;
166
- singletonKey?: string;
167
- singletonSeconds?: number;
168
- expireInSeconds?: number;
169
- deleteAfterSeconds?: number;
170
- retentionSeconds?: number;
171
- }
172
- type WorkerState = 'created' | 'active' | 'stopping' | 'stopped';
173
- interface WipData {
174
- id: string;
175
- name: string;
176
- options: WorkOptions;
177
- state: WorkerState;
178
- count: number;
179
- createdOn: number;
180
- lastFetchedOn: number | null;
181
- lastJobStartedOn: number | null;
182
- lastJobEndedOn: number | null;
183
- lastJobDuration: number | null;
184
- lastError: object | null;
185
- lastErrorOn: number | null;
186
- }
187
- interface StopOptions {
188
- close?: boolean;
189
- graceful?: boolean;
190
- timeout?: number;
191
- }
192
- interface OffWorkOptions {
193
- id?: string;
194
- wait?: boolean;
195
- }
196
- type UpdateQueueOptions = Omit<Queue, 'name' | 'partition' | 'policy'>;
197
- interface Warning {
198
- message: string;
199
- data: object;
200
- }
201
- interface CommandResponse {}
202
- type PgBossEventMap = {
203
- error: [error: Error];
204
- warning: [warning: Warning];
205
- wip: [data: WipData[]];
206
- stopped: [];
207
- };
208
- //#endregion
209
- //#region src/plans.d.ts
210
- declare const JOB_STATES: Readonly<{
211
- created: "created";
212
- retry: "retry";
213
- active: "active";
214
- completed: "completed";
215
- cancelled: "cancelled";
216
- failed: "failed";
217
- }>;
218
- declare const QUEUE_POLICIES: Readonly<{
219
- standard: "standard";
220
- short: "short";
221
- singleton: "singleton";
222
- stately: "stately";
223
- exclusive: "exclusive";
224
- }>;
225
- //#endregion
226
5
  //#region src/index.d.ts
227
6
  declare const events: Events;
228
7
  declare function getConstructionPlans(schema?: string): string;
@@ -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 };