@wavezync/nestjs-pgboss 2.1.0 → 2.2.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/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/README.MD +4 -0
- package/dist/pgboss.service.d.ts +2 -1
- package/dist/pgboss.service.js +9 -6
- package/dist/pgboss.service.js.map +1 -1
- package/lib/pgboss.service.ts +14 -6
- package/package.json +1 -1
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Bug report
|
|
3
|
+
about: Create a report to help us improve
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Describe the bug**
|
|
11
|
+
A clear and concise description of what the bug is.
|
|
12
|
+
|
|
13
|
+
**To Reproduce**
|
|
14
|
+
Steps to reproduce the behavior:
|
|
15
|
+
1. Go to '...'
|
|
16
|
+
2. Click on '....'
|
|
17
|
+
3. Scroll down to '....'
|
|
18
|
+
4. See error
|
|
19
|
+
|
|
20
|
+
**Expected behavior**
|
|
21
|
+
A clear and concise description of what you expected to happen.
|
|
22
|
+
|
|
23
|
+
**Screenshots**
|
|
24
|
+
If applicable, add screenshots to help explain your problem.
|
|
25
|
+
|
|
26
|
+
**Desktop (please complete the following information):**
|
|
27
|
+
- OS: [e.g. iOS]
|
|
28
|
+
- Browser [e.g. chrome, safari]
|
|
29
|
+
- Version [e.g. 22]
|
|
30
|
+
|
|
31
|
+
**Smartphone (please complete the following information):**
|
|
32
|
+
- Device: [e.g. iPhone6]
|
|
33
|
+
- OS: [e.g. iOS8.1]
|
|
34
|
+
- Browser [e.g. stock browser, safari]
|
|
35
|
+
- Version [e.g. 22]
|
|
36
|
+
|
|
37
|
+
**Additional context**
|
|
38
|
+
Add any other context about the problem here.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: Feature request
|
|
3
|
+
about: Suggest an idea for this project
|
|
4
|
+
title: ''
|
|
5
|
+
labels: ''
|
|
6
|
+
assignees: ''
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
|
12
|
+
|
|
13
|
+
**Describe the solution you'd like**
|
|
14
|
+
A clear and concise description of what you want to happen.
|
|
15
|
+
|
|
16
|
+
**Describe alternatives you've considered**
|
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
|
18
|
+
|
|
19
|
+
**Additional context**
|
|
20
|
+
Add any other context or screenshots about the feature request here.
|
package/README.MD
CHANGED
package/dist/pgboss.service.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import PgBoss, { WorkWithMetadataHandler } from "pg-boss";
|
|
2
2
|
export declare class PgBossService {
|
|
3
|
-
private
|
|
3
|
+
private pgBoss;
|
|
4
4
|
constructor(boss: PgBoss);
|
|
5
|
+
get boss(): PgBoss;
|
|
5
6
|
scheduleJob<TData extends object>(name: string, data: TData, options?: PgBoss.SendOptions): Promise<void>;
|
|
6
7
|
scheduleCronJob<TData extends object>(name: string, cron: string, data?: TData, options?: PgBoss.ScheduleOptions): Promise<void>;
|
|
7
8
|
registerCronJob<TData extends object>(name: string, cron: string, handler: WorkWithMetadataHandler<TData>, data?: TData, options?: PgBoss.ScheduleOptions): Promise<void>;
|
package/dist/pgboss.service.js
CHANGED
|
@@ -22,20 +22,23 @@ const common_2 = require("@nestjs/common");
|
|
|
22
22
|
const consts_1 = require("./utils/consts");
|
|
23
23
|
let PgBossService = class PgBossService {
|
|
24
24
|
constructor(boss) {
|
|
25
|
-
this.
|
|
25
|
+
this.pgBoss = boss;
|
|
26
|
+
}
|
|
27
|
+
get boss() {
|
|
28
|
+
return this.pgBoss;
|
|
26
29
|
}
|
|
27
30
|
async scheduleJob(name, data, options) {
|
|
28
|
-
await this.
|
|
31
|
+
await this.pgBoss.send(name, data, options);
|
|
29
32
|
}
|
|
30
33
|
async scheduleCronJob(name, cron, data, options) {
|
|
31
|
-
await this.
|
|
34
|
+
await this.pgBoss.schedule(name, cron, data !== null && data !== void 0 ? data : {}, options !== null && options !== void 0 ? options : {});
|
|
32
35
|
}
|
|
33
36
|
async registerCronJob(name, cron, handler, data, options) {
|
|
34
|
-
await this.
|
|
35
|
-
await this.
|
|
37
|
+
await this.pgBoss.schedule(name, cron, data !== null && data !== void 0 ? data : {}, options !== null && options !== void 0 ? options : {});
|
|
38
|
+
await this.pgBoss.work(name, Object.assign(Object.assign({}, options), { includeMetadata: true }), handler);
|
|
36
39
|
}
|
|
37
40
|
async registerJob(name, handler, options) {
|
|
38
|
-
await this.
|
|
41
|
+
await this.pgBoss.work(name, Object.assign(Object.assign({}, options), { includeMetadata: true }), handler);
|
|
39
42
|
}
|
|
40
43
|
};
|
|
41
44
|
exports.PgBossService = PgBossService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pgboss.service.js","sourceRoot":"","sources":["../lib/pgboss.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,sDAA0D;AAC1D,2CAAwC;AACxC,2CAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;
|
|
1
|
+
{"version":3,"file":"pgboss.service.js","sourceRoot":"","sources":["../lib/pgboss.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAC5C,sDAA0D;AAC1D,2CAAwC;AACxC,2CAA8C;AAGvC,IAAM,aAAa,GAAnB,MAAM,aAAa;IAGxB,YAAkC,IAAY;QAC5C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,WAAW,CACf,IA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injectable()
|
|
7
7
|
export class PgBossService {
|
|
8
|
-
|
|
8
|
+
private pgBoss: PgBoss;
|
|
9
|
+
|
|
10
|
+
constructor(@Inject(PGBOSS_TOKEN) boss: PgBoss) {
|
|
11
|
+
this.pgBoss = boss;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
get boss(): PgBoss {
|
|
15
|
+
return this.pgBoss;
|
|
16
|
+
}
|
|
9
17
|
|
|
10
18
|
async scheduleJob<TData extends object>(
|
|
11
19
|
name: string,
|
|
12
20
|
data: TData,
|
|
13
21
|
options?: PgBoss.SendOptions,
|
|
14
22
|
) {
|
|
15
|
-
await this.
|
|
23
|
+
await this.pgBoss.send(name, data, options);
|
|
16
24
|
}
|
|
17
25
|
|
|
18
26
|
async scheduleCronJob<TData extends object>(
|
|
@@ -21,7 +29,7 @@ export class PgBossService {
|
|
|
21
29
|
data?: TData,
|
|
22
30
|
options?: PgBoss.ScheduleOptions,
|
|
23
31
|
) {
|
|
24
|
-
await this.
|
|
32
|
+
await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {});
|
|
25
33
|
}
|
|
26
34
|
|
|
27
35
|
async registerCronJob<TData extends object>(
|
|
@@ -31,8 +39,8 @@ export class PgBossService {
|
|
|
31
39
|
data?: TData,
|
|
32
40
|
options?: PgBoss.ScheduleOptions,
|
|
33
41
|
) {
|
|
34
|
-
await this.
|
|
35
|
-
await this.
|
|
42
|
+
await this.pgBoss.schedule(name, cron, data ?? {}, options ?? {});
|
|
43
|
+
await this.pgBoss.work<TData>(
|
|
36
44
|
name,
|
|
37
45
|
{ ...options, includeMetadata: true },
|
|
38
46
|
handler,
|
|
@@ -44,7 +52,7 @@ export class PgBossService {
|
|
|
44
52
|
handler: WorkWithMetadataHandler<TData>,
|
|
45
53
|
options?: PgBoss.BatchWorkOptions,
|
|
46
54
|
) {
|
|
47
|
-
await this.
|
|
55
|
+
await this.pgBoss.work<TData>(
|
|
48
56
|
name,
|
|
49
57
|
{ ...options, includeMetadata: true },
|
|
50
58
|
handler,
|