@wavezync/nestjs-pgboss 5.1.1 → 6.0.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.
@@ -1,23 +1,28 @@
1
1
  name: Publish to NPM
2
2
 
3
3
  on:
4
- release:
5
- types: [published]
4
+ push:
5
+ tags:
6
+ - "v*.*.*"
7
+
8
+ permissions:
9
+ id-token: write
10
+ contents: write
6
11
 
7
12
  jobs:
8
13
  publish-npm:
9
14
  runs-on: ubuntu-latest
10
15
  steps:
11
16
  - name: Check out Git repository
12
- uses: actions/checkout@v4
17
+ uses: actions/checkout@v6
13
18
 
14
19
  - name: Setup Node
15
- uses: actions/setup-node@v4
20
+ uses: actions/setup-node@v6
16
21
  with:
17
- node-version: "20"
22
+ node-version: "24"
18
23
  registry-url: "https://registry.npmjs.org/"
19
24
 
20
- - uses: actions/cache@v4
25
+ - uses: actions/cache@v5
21
26
  name: Setup npm cache
22
27
  with:
23
28
  path: ~/.npm
@@ -35,6 +40,42 @@ jobs:
35
40
  run: npm run build
36
41
 
37
42
  - name: Publish to NPM
38
- run: npm publish --access public
43
+ run: npm publish
44
+
45
+ release:
46
+ needs: publish-npm
47
+ runs-on: ubuntu-latest
48
+ steps:
49
+ - name: Check out Git repository
50
+ uses: actions/checkout@v6
51
+ with:
52
+ fetch-depth: 0
53
+
54
+ - name: Generate release notes
55
+ uses: orhun/git-cliff-action@v4
56
+ with:
57
+ args: --latest --strip header
58
+ env:
59
+ OUTPUT: CHANGES.md
60
+ GITHUB_REPO: ${{ github.repository }}
61
+
62
+ - name: Create GitHub Release
63
+ uses: softprops/action-gh-release@v2
64
+ with:
65
+ body_path: CHANGES.md
66
+
67
+ - name: Generate full changelog
68
+ uses: orhun/git-cliff-action@v4
69
+ with:
70
+ args: --output CHANGELOG.md
39
71
  env:
40
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
72
+ GITHUB_REPO: ${{ github.repository }}
73
+
74
+ - name: Commit changelog to main
75
+ run: |
76
+ git config user.name "github-actions[bot]"
77
+ git config user.email "github-actions[bot]@users.noreply.github.com"
78
+ git checkout main
79
+ git add CHANGELOG.md
80
+ git diff --cached --quiet || git commit -m "chore: update changelog for ${{ github.ref_name }} [skip ci]"
81
+ git push origin main
package/CHANGELOG.md ADDED
@@ -0,0 +1,146 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ ## [Unreleased]
6
+
7
+ ### Features
8
+
9
+ - Use pg-boss native WorkOptions instead of internal wrapper ([28671a3](https://github.com/wavezync/nestjs-pgboss/commit/28671a37cd77cca56d04e326b07d006f953f54d4))
10
+
11
+ ### Miscellaneous Tasks
12
+
13
+ - Bump version to 5.2.0 ([acb1cee](https://github.com/wavezync/nestjs-pgboss/commit/acb1ceefed3206ac57d9cf407e74401d17d42bd0))
14
+ ## [5.1.1] - 2026-01-31
15
+
16
+ ### Miscellaneous Tasks
17
+
18
+ - Bump v5.1.1 ([c5164e9](https://github.com/wavezync/nestjs-pgboss/commit/c5164e9cb174b3017646d0441aaf1941acb90091))
19
+ ## [5.1.0] - 2026-01-18
20
+
21
+ ### Features
22
+
23
+ - Add teamSize option for parallel job processing ([3e1f02b](https://github.com/wavezync/nestjs-pgboss/commit/3e1f02b7d5db78ced41966810699bcaec21a0f7a))
24
+
25
+ ### Miscellaneous Tasks
26
+
27
+ - Bump version to 5.1.0 ([fc0a1cc](https://github.com/wavezync/nestjs-pgboss/commit/fc0a1cc5f6d3a3fcdb9ee510b5461203af3d1f63))
28
+ ## [5.0.0] - 2026-01-05
29
+
30
+ ### Miscellaneous Tasks
31
+
32
+ - Update dependencies to NestJS 11 and pg-boss 12 ([f229ee2](https://github.com/wavezync/nestjs-pgboss/commit/f229ee218dddfbac13373c1eadfe3701e44d809f))
33
+ - Bump version to 5.0.0 ([d980e11](https://github.com/wavezync/nestjs-pgboss/commit/d980e113976354288f5f805111fcd16e31bc84f2))
34
+ ## [4.0.1] - 2024-11-29
35
+
36
+ ### Features
37
+
38
+ - Full support for PgBoss ConstructorOptions ([f0725c8](https://github.com/wavezync/nestjs-pgboss/commit/f0725c813bbd0ece4df61810033b11386a9b7fec))
39
+
40
+ ### Miscellaneous Tasks
41
+
42
+ - Update README example with typed job data ([827c4c7](https://github.com/wavezync/nestjs-pgboss/commit/827c4c78dd3eea568b8d704db7e179fa8ad437bd))
43
+ - Bump version to v4.0.1 ([db797b8](https://github.com/wavezync/nestjs-pgboss/commit/db797b807c1000e7308418e5d7a497e87b50e949))
44
+ ## [4.0.0] - 2024-11-25
45
+
46
+ ### Bug Fixes
47
+
48
+ - Receive job arrays ([49e78bf](https://github.com/wavezync/nestjs-pgboss/commit/49e78bfcdfad205d764da7792d3563b6f4a9c38f))
49
+ - Update readme ([e1ea088](https://github.com/wavezync/nestjs-pgboss/commit/e1ea088d15c9f4f7c50ff5b67466f779c9c1ba0d))
50
+ - Update error log ([cb02c06](https://github.com/wavezync/nestjs-pgboss/commit/cb02c063b23c2ee2aacdcb2af2cc927ae8e735ec))
51
+
52
+ ### Features
53
+
54
+ - Work decorator with Batch Processing ([067076a](https://github.com/wavezync/nestjs-pgboss/commit/067076aa2ade246c782d03ee82a85db38ae2e558))
55
+
56
+ ### Miscellaneous Tasks
57
+
58
+ - Bump version to v4.0.0 ([3cb7fbc](https://github.com/wavezync/nestjs-pgboss/commit/3cb7fbce3756584072608b6689e5ca8582aba7b1))
59
+ ## [3.0.1] - 2024-11-04
60
+
61
+ ### Bug Fixes
62
+
63
+ - Pg-boss startup errors hidden issue ([3caeddf](https://github.com/wavezync/nestjs-pgboss/commit/3caeddf057218c2eda1827e67a9ec1f21985df71))
64
+
65
+ ### Miscellaneous Tasks
66
+
67
+ - Bump version to v3.0.1 ([42bc9a1](https://github.com/wavezync/nestjs-pgboss/commit/42bc9a17634be9f4d7a5657cae8a8ed620ecddfd))
68
+ ## [3.0.0] - 2024-09-10
69
+
70
+ ### Bug Fixes
71
+
72
+ - Ensure queue exists added ([cfb929d](https://github.com/wavezync/nestjs-pgboss/commit/cfb929d2f17ec347b8e251e54c0c8a5a4bd1aa4c))
73
+ - Update helpers ([393cd73](https://github.com/wavezync/nestjs-pgboss/commit/393cd735659d904e6271c31de829a4977f4eda07))
74
+ - Remove ensureQueueExists ([5939862](https://github.com/wavezync/nestjs-pgboss/commit/5939862e394572541f155e3c82f20f47b54c77d4))
75
+
76
+ ### Features
77
+
78
+ - Migrate to pgboss 10 ([a115473](https://github.com/wavezync/nestjs-pgboss/commit/a1154735da749ce2f393b1ecaca29cfc08343f68))
79
+
80
+ ### Miscellaneous Tasks
81
+
82
+ - Bump version to v3.0.0 ([45b9b2b](https://github.com/wavezync/nestjs-pgboss/commit/45b9b2b096bad6a3abae8487b8ee90b05885dbb1))
83
+ ## [2.2.0] - 2024-09-08
84
+
85
+ ### Bug Fixes
86
+
87
+ - Getter for boss instance added ([6ebd140](https://github.com/wavezync/nestjs-pgboss/commit/6ebd1400edd48b75106dad4aa317e4f8236588d6))
88
+
89
+ ### Features
90
+
91
+ - Direct access to pgboss added ([0c9badf](https://github.com/wavezync/nestjs-pgboss/commit/0c9badf2166351fcba579a8ca098d1a6a63d4bd3))
92
+
93
+ ### Miscellaneous Tasks
94
+
95
+ - Bump version to v2.2.0 ([04c0897](https://github.com/wavezync/nestjs-pgboss/commit/04c0897c548aba46006daf21fc6cae2287c9d8b3))
96
+ ## [2.1.0] - 2024-08-30
97
+
98
+ ### Bug Fixes
99
+
100
+ - Use WorkWithMetadataHandler ([1526515](https://github.com/wavezync/nestjs-pgboss/commit/1526515e70d21b03ee215c955aeb7767bb979c11))
101
+
102
+ ### Miscellaneous Tasks
103
+
104
+ - Clean code ([eaf2322](https://github.com/wavezync/nestjs-pgboss/commit/eaf23220019cac3da03b942175a6c4ef6fad0ac9))
105
+ - Bump version to v2.1.0 ([fd0dde3](https://github.com/wavezync/nestjs-pgboss/commit/fd0dde3526094762536377897481d3f286f82552))
106
+ ## [2.0.1] - 2024-08-30
107
+
108
+ ### Bug Fixes
109
+
110
+ - Pgboss module error handling ([f69d60c](https://github.com/wavezync/nestjs-pgboss/commit/f69d60c110e7c5324855cf7744a7755512673f8a))
111
+ - Handler scanner error handling ([8b80784](https://github.com/wavezync/nestjs-pgboss/commit/8b807845bc317222b938ce710d14a631d2582b0e))
112
+
113
+ ### Miscellaneous Tasks
114
+
115
+ - Bump version to 2.0.1 ([fcadeb9](https://github.com/wavezync/nestjs-pgboss/commit/fcadeb9ba9535f0782de81701a12a1c36ab20e89))
116
+ ## [2.0.0] - 2024-08-22
117
+
118
+ ### Bug Fixes
119
+
120
+ - Use registerJobHandler ([140bb11](https://github.com/wavezync/nestjs-pgboss/commit/140bb11bed5dd30652f760d270a83994495d4ce6))
121
+ - Register jobs with handler scanner ([105ae6a](https://github.com/wavezync/nestjs-pgboss/commit/105ae6a0a7f687179bf3e019ab28d3cbf2d836b7))
122
+ - Cleanup code ([ef3b53b](https://github.com/wavezync/nestjs-pgboss/commit/ef3b53b397ad062f1f88a04bc250b088e51605c1))
123
+ - Update readme ([8aeb18d](https://github.com/wavezync/nestjs-pgboss/commit/8aeb18da0349b3ff97af34b3bce476744c011f1e))
124
+
125
+ ### Documentation
126
+
127
+ - Update readme ([38533a2](https://github.com/wavezync/nestjs-pgboss/commit/38533a2fecf8aea933c7499bdd51a3200e06ee68))
128
+ ## [1.0.0] - 2024-08-12
129
+
130
+ ### Bug Fixes
131
+
132
+ - Update lint ([0c3f2a5](https://github.com/wavezync/nestjs-pgboss/commit/0c3f2a5b5940cf6b62afb8b18d9f4c9bc5295bdd))
133
+ - Update readme ([eb35c5b](https://github.com/wavezync/nestjs-pgboss/commit/eb35c5b398ceb2adaa323a524e6280fa139bd68c))
134
+ - Update readme ([9dc719c](https://github.com/wavezync/nestjs-pgboss/commit/9dc719cd8f03d048e36f92dc3f12ac0828f3a464))
135
+ - Configure dependencies ([a1d3da3](https://github.com/wavezync/nestjs-pgboss/commit/a1d3da3fc6ce167142e953e5f31bad08fa0837e1))
136
+ - Update readme ([317a55a](https://github.com/wavezync/nestjs-pgboss/commit/317a55a0c89786a062469e031849b3d42346edf7))
137
+ - Dependencies updated ([15d403b](https://github.com/wavezync/nestjs-pgboss/commit/15d403b41fb5c34375211cf8a16203821e3963ba))
138
+ - CronJob decorator updated ([b653e46](https://github.com/wavezync/nestjs-pgboss/commit/b653e46216da2914bfc97463d04ec98af495b59c))
139
+
140
+ ### Miscellaneous Tasks
141
+
142
+ - Structure ([5cca195](https://github.com/wavezync/nestjs-pgboss/commit/5cca195eae36d67aebf81b6f1cd54cfa878f8131))
143
+ - Update version ([644d39e](https://github.com/wavezync/nestjs-pgboss/commit/644d39e378cd45f695634ad4a795f36654af6f61))
144
+ - Update readme ([ae321cf](https://github.com/wavezync/nestjs-pgboss/commit/ae321cfc339dca905bc53d08bc6dd455c4e51563))
145
+ - Update LICENSE ([7ca3c1e](https://github.com/wavezync/nestjs-pgboss/commit/7ca3c1e5178fe0ab9cfaf5bb8f4905a971f422f4))
146
+ - Bump version to v1.0.0 ([8e71681](https://github.com/wavezync/nestjs-pgboss/commit/8e716817c883f00b2c320e1d2de0f809b0ea1086))
package/CLAUDE.md ADDED
@@ -0,0 +1,39 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ `@wavezync/nestjs-pgboss` is a NestJS module that integrates [pg-boss](https://github.com/timgit/pg-boss) for PostgreSQL-based job scheduling and handling. It's published as an npm package.
8
+
9
+ ## Commands
10
+
11
+ - **Build:** `npm run build` (uses `nest build`)
12
+ - **Test:** `npm test` (Jest, tests live in `test/`)
13
+ - **Run single test:** `npx jest --testPathPattern=<pattern>`
14
+ - **Lint:** `npm run lint` (ESLint with auto-fix)
15
+ - **Format:** `npm run format` (Prettier)
16
+
17
+ ## Architecture
18
+
19
+ Source code is in `lib/` (not `src/`), configured via `nest-cli.json` with `sourceRoot: "lib"`. Output goes to `dist/`.
20
+
21
+ ### Key Components
22
+
23
+ - **`PgBossModule`** (`lib/pgboss.module.ts`) — Global dynamic NestJS module. Only exposes `forRootAsync()` for async configuration. Manages the PgBoss lifecycle (start on init, stop on destroy) and triggers handler registration at application bootstrap.
24
+
25
+ - **`PgBossService`** (`lib/pgboss.service.ts`) — Injectable service wrapping the PgBoss instance. Provides `scheduleJob()`, `scheduleCronJob()`, `registerJob()`, and `registerCronJob()`. All methods call `createQueue()` before operating. Exposes raw `boss` getter for direct PgBoss access.
26
+
27
+ - **`HandlerScannerService`** (`lib/handler-scanner.service.ts`) — Scans all NestJS providers at bootstrap to find methods decorated with `@Job` or `@CronJob`, then registers them as workers via `PgBossService`.
28
+
29
+ - **Decorators** (`lib/decorators/job.decorator.ts`) — `@Job(name, options?)` and `@CronJob(name, cron, options?)` use `SetMetadata` to attach job metadata to handler methods. Options use pg-boss native `WorkOptions` and `ScheduleOptions` types.
30
+
31
+ - **Module options** (`lib/interfaces/pgboss-module-options.interface.ts`) — Extends pg-boss `ConstructorOptions` with `retryLimit` and `retryDelay` for connection retry logic.
32
+
33
+ ### Registration Flow
34
+
35
+ `forRootAsync()` creates PgBoss instance → `onApplicationBootstrap` triggers `HandlerScannerService.scanAndRegisterHandlers()` → scans all module providers for `@Job`/`@CronJob` metadata → registers workers via `PgBossService`.
36
+
37
+ ## Peer Dependencies
38
+
39
+ Requires `@nestjs/common` ^11, `@nestjs/core` ^11, `pg-boss` >=12.6.0.
package/cliff.toml ADDED
@@ -0,0 +1,49 @@
1
+ [changelog]
2
+ header = """
3
+ # Changelog\n
4
+ All notable changes to this project will be documented in this file.\n
5
+ """
6
+ body = """
7
+ {%- macro remote_url() -%}
8
+ https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
9
+ {%- endmacro -%}
10
+
11
+ {% if version -%}
12
+ ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
13
+ {% else -%}
14
+ ## [Unreleased]
15
+ {% endif -%}
16
+
17
+ {% for group, commits in commits | group_by(attribute="group") %}
18
+ ### {{ group | striptags | trim | upper_first }}
19
+ {% for commit in commits %}
20
+ - {% if commit.scope %}*({{ commit.scope }})* {% endif %}{{ commit.message | upper_first }} \
21
+ ([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
22
+ {% endfor %}
23
+ {% endfor %}
24
+ """
25
+ trim = true
26
+
27
+ [git]
28
+ conventional_commits = true
29
+ filter_unconventional = true
30
+ split_commits = false
31
+ commit_parsers = [
32
+ { message = "^feat", group = "Features" },
33
+ { message = "^fix", group = "Bug Fixes" },
34
+ { message = "^doc", group = "Documentation" },
35
+ { message = "^perf", group = "Performance" },
36
+ { message = "^refactor", group = "Refactor" },
37
+ { message = "^style", group = "Styling" },
38
+ { message = "^test", group = "Testing" },
39
+ { message = "^chore\\(release\\)", skip = true },
40
+ { message = "^chore\\(deps.*\\)", skip = true },
41
+ { message = "^chore\\(pr\\)", skip = true },
42
+ { message = "^chore\\(pull\\)", skip = true },
43
+ { message = "^chore: update changelog", skip = true },
44
+ { message = "^chore|^ci", group = "Miscellaneous Tasks" },
45
+ { body = ".*security", group = "Security" },
46
+ ]
47
+ filter_commits = false
48
+ tag_pattern = "v[0-9].*"
49
+ sort_commits = "oldest"
@@ -1,5 +1,4 @@
1
- import { ScheduleOptions } from "pg-boss";
2
- import { WorkOptions } from "../interfaces/handler-metadata.interface";
1
+ import { ScheduleOptions, WorkOptions } from "pg-boss";
3
2
  export declare const JOB_NAME = "JOB_NAME";
4
3
  export declare const JOB_OPTIONS = "JOB_OPTIONS";
5
4
  export declare const CRON_EXPRESSION = "CRON_EXPRESSION";
@@ -7,5 +6,5 @@ export declare const CRON_OPTIONS = "CRON_OPTIONS";
7
6
  export declare const PG_BOSS_JOB_METADATA = "PG_BOSS_JOB_METADATA";
8
7
  export declare const WORK_NAME = "WORK_NAME";
9
8
  export declare const WORK_OPTIONS = "WORK_OPTIONS";
10
- export declare function Job<_TData extends object = any>(name: string, options?: WorkOptions): (target: any, key: string, descriptor: PropertyDescriptor) => void;
11
- export declare function CronJob<_TData extends object = any>(name: string, cron: string, options?: ScheduleOptions): (target: any, key: string, descriptor: PropertyDescriptor) => void;
9
+ export declare function Job(name: string, options?: WorkOptions): (target: object, key: string, descriptor: PropertyDescriptor) => void;
10
+ export declare function CronJob(name: string, cron: string, options?: ScheduleOptions): (target: object, key: string, descriptor: PropertyDescriptor) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"job.decorator.js","sourceRoot":"","sources":["../../lib/decorators/job.decorator.ts"],"names":[],"mappings":";;;AAYA,kBAaC;AAED,0BAeC;AA1CD,2CAA6C;AAIhC,QAAA,QAAQ,GAAG,UAAU,CAAC;AACtB,QAAA,WAAW,GAAG,aAAa,CAAC;AAC5B,QAAA,eAAe,GAAG,iBAAiB,CAAC;AACpC,QAAA,YAAY,GAAG,cAAc,CAAC;AAC9B,QAAA,oBAAoB,GAAG,sBAAsB,CAAC;AAC9C,QAAA,SAAS,GAAG,WAAW,CAAC;AACxB,QAAA,YAAY,GAAG,cAAc,CAAC;AAE3C,SAAgB,GAAG,CACjB,IAAY,EACZ,UAAuB,EAAE;IAEzB,OAAO,CAAC,MAAW,EAAE,GAAW,EAAE,UAA8B,EAAE,EAAE;QAClE,IAAA,oBAAW,EAAC,gBAAQ,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QACrD,IAAA,oBAAW,EAAC,mBAAW,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC3D,IAAA,oBAAW,EAAC,4BAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CACxE,MAAM,EACN,GAAG,EACH,UAAU,CACX,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,OAAO,CACrB,IAAY,EACZ,IAAY,EACZ,UAA2B,EAAE;IAE7B,OAAO,CAAC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,oBAAW,EAAC,4BAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CACxE,MAAM,EACN,GAAG,EACH,UAAU,CACX,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAED,SAAgB,OAAO,CACrB,IAAY,EACZ,IAAY,EACZ,UAA2B,EAAE;IAE7B,OAAO,CAAC,MAAc,EAAE,GAAW,EAAE,UAA8B,EAAE,EAAE;QACrE,IAAA,oBAAW,EAAC,gBAAQ,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QACrD,IAAA,oBAAW,EAAC,uBAAe,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC5D,IAAA,oBAAW,EAAC,oBAAY,EAAE,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,UAAU,CAAC,CAAC;QAC5D,IAAA,oBAAW,EAAC,4BAAoB,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,CACxE,MAAM,EACN,GAAG,EACH,UAAU,CACX,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -31,12 +31,16 @@ let HandlerScannerService = class HandlerScannerService {
31
31
  }
32
32
  }
33
33
  async scanProvider(provider) {
34
- var _a;
35
- const { instance } = provider;
34
+ const instance = provider.instance;
36
35
  if (!instance || typeof instance !== "object")
37
36
  return;
38
37
  const prototype = Object.getPrototypeOf(instance);
39
- const methodNames = Object.getOwnPropertyNames(prototype).filter((method) => method !== "constructor" && typeof instance[method] === "function");
38
+ const methodNames = Object.getOwnPropertyNames(prototype).filter((method) => {
39
+ if (method === "constructor")
40
+ return false;
41
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, method);
42
+ return descriptor && typeof descriptor.value === "function";
43
+ });
40
44
  for (const methodName of methodNames) {
41
45
  const methodRef = instance[methodName];
42
46
  const jobName = this.reflector.get(job_decorator_1.JOB_NAME, methodRef);
@@ -50,11 +54,8 @@ let HandlerScannerService = class HandlerScannerService {
50
54
  this.logger.log(`Registered cron job: ${jobName}`);
51
55
  continue;
52
56
  }
53
- const teamSize = Math.max(1, (_a = jobOptions === null || jobOptions === void 0 ? void 0 : jobOptions.teamSize) !== null && _a !== void 0 ? _a : 1);
54
- for (let i = 0; i < teamSize; i++) {
55
- await this.pgBossService.registerJob(jobName, methodRef.bind(instance), jobOptions);
56
- }
57
- this.logger.log(`Registered job: ${jobName} (${teamSize} worker${teamSize > 1 ? 's' : ''})`);
57
+ await this.pgBossService.registerJob(jobName, methodRef.bind(instance), jobOptions);
58
+ this.logger.log(`Registered job: ${jobName}`);
58
59
  }
59
60
  catch (error) {
60
61
  this.logger.error(error, `Error registering job ${jobName}`);
@@ -1 +1 @@
1
- {"version":3,"file":"handler-scanner.service.js","sourceRoot":"","sources":["../lib/handler-scanner.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAA2D;AAC3D,qDAAiD;AACjD,8DAKoC;AAGpC,2CAAwC;AAIjC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAGhC,YACmB,aAA4B,EAC5B,SAAoB,EACpB,gBAAkC;QAFlC,kBAAa,GAAb,aAAa,CAAe;QAC5B,cAAS,GAAT,SAAS,CAAW;QACpB,qBAAgB,GAAhB,gBAAgB,CAAkB;QALpC,WAAM,GAAG,IAAI,eAAM,CAAC,eAAM,CAAC,CAAC;IAM1C,CAAC;IAEJ,KAAK,CAAC,uBAAuB;QAC3B,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC;YACpD,MAAM,SAAS,GAAG,CAAC,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;YAEjD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;gBACjC,MAAM,IAAI,CAAC,YAAY,CAAC,QAAQ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AC;YACF,MAAM,cAAc,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CACvC,+BAAe,EACf,SAAS,CACV,CAAC;YACF,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CACpC,4BAAY,EACZ,SAAS,CACV,CAAC;YAEF,IAAI,OAAO,EAAE,CAAC;gBACZ,IAAI,CAAC;oBACH,IAAI,cAAc,EAAE,CAAC;wBACnB,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CACtC,OAAO,EACP,cAAc,EACd,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAoC,EAC3D,EAAE,EACF,WAAW,CACZ,CAAC;wBACF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,wBAAwB,OAAO,EAAE,CAAC,CAAC;wBACnD,SAAS;oBACX,CAAC;oBAED,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAClC,OAAO,EACP,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAoC,EAC3D,UAAU,CACX,CAAC;oBAEF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,OAAO,EAAE,CAAC,CAAC;gBAChD,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,yBAAyB,OAAO,EAAE,CAAC,CAAC;gBAC/D,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAA;AAhFY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAKuB,8BAAa;QACjB,gBAAS;QACF,uBAAgB;GAN1C,qBAAqB,CAgFjC"}
@@ -1,7 +1,4 @@
1
- import { WorkOptions as PgBossWorkOptions, ScheduleOptions } from "pg-boss";
2
- export interface WorkOptions extends PgBossWorkOptions {
3
- teamSize?: number;
4
- }
1
+ import { WorkOptions, ScheduleOptions } from "pg-boss";
5
2
  export interface HandlerMetadata {
6
3
  jobName: string;
7
4
  workOptions?: WorkOptions;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CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,KAAK,CAAC,eAAe,CACnB,IAAY,EACZ,IAAY,EACZ,OAAuC,EACvC,IAAY,EACZ,OAAyB;QAEzB,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,CAAC;QAClE,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACpB,IAAI,EACJ,gCAAK,IAAA,0BAAgB,EAAC,OAAO,CAAC,KAAE,eAAe,EAAE,IAAI,GAEpD,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,WAAW,CACf,IAAY,EACZ,OAAuC,EACvC,OAAqB;QAErB,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CACpB,IAAI,kCACC,OAAO,KAAE,eAAe,EAAE,IAAI,KACnC,OAAO,CACR,CAAC;IACJ,CAAC;CACF,CAAA;AA5DY,sCAAa;wBAAb,aAAa;IADzB,IAAA,mBAAU,GAAE;IAIE,WAAA,IAAA,eAAM,EAAC,qBAAY,CAAC,CAAA;qCAAO,gBAAM;GAHnC,aAAa,CA4DzB"}
@@ -1 +1 @@
1
- export declare function handleRetry(retryAttempts?: number, retryDelay?: number, toRetry?: (err: any) => boolean): <T>(source: import("rxjs").Observable<T>) => import("rxjs").Observable<T>;
1
+ export declare function handleRetry(retryAttempts?: number, retryDelay?: number, toRetry?: (err: unknown) => boolean): <T>(source: import("rxjs").Observable<T>) => import("rxjs").Observable<T>;
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleRetry = handleRetry;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- function handleRetry(retryAttempts = 9, retryDelay = 3000, toRetry = (_err) => true) {
6
+ function handleRetry(retryAttempts = 9, retryDelay = 3000, toRetry = () => true) {
7
7
  return (source) => source.pipe((0, operators_1.retryWhen)((attempts) => attempts.pipe((0, operators_1.mergeMap)((error, index) => {
8
8
  const includeError = toRetry(error);
9
9
  if (includeError) {
10
10
  if (index + 1 >= retryAttempts) {
11
- return (0, rxjs_1.throwError)(() => new Error(error.message));
11
+ const message = error instanceof Error ? error.message : "Unknown error";
12
+ return (0, rxjs_1.throwError)(() => new Error(message));
12
13
  }
13
14
  return (0, rxjs_1.of)(error).pipe((0, operators_1.delay)(retryDelay));
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"handleRetry.js","sourceRoot":"","sources":["../../lib/utils/handleRetry.ts"],"names":[],"mappings":";;AAGA,kCAyBC;AA5BD,+BAAsC;AACtC,8CAA4D;AAE5D,SAAgB,WAAW,CACzB,aAAa,GAAG,CAAC,EACjB,UAAU,GAAG,IAAI,EACjB,UAAiC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI;IAEpD,OAAO,CAAI,MAAoC,EAAE,EAAE,CACjD,MAAM,CAAC,IAAI,CACT,IAAA,qBAAS,EAAC,CAAC,QAAQ,EAAE,EAAE,CACrB,QAAQ,CAAC,IAAI,CACX,IAAA,oBAAQ,EAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACxB,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;QAEpC,IAAI,YAAY,EAAE,CAAC;YACjB,IAAI,KAAK,GAAG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BAAK,EAAC,UAAU,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,IAAA,iBAAU,EAAC,GAAG,EAAE,CAAC,KAAc,CAAC,CAAC;IAC1C,CAAC,CAAC,CACH,CACF,CACF,CAAC;AACN,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { WorkOptions, ScheduleOptions } from "pg-boss";
2
- export declare function transformOptions(options?: WorkOptions | ScheduleOptions): any;
3
- export declare function normalizeJob(job: any): any;
2
+ export declare function transformOptions(options?: WorkOptions | ScheduleOptions): Record<string, unknown>;
3
+ export declare function normalizeJob(job: unknown): unknown;
@@ -6,14 +6,15 @@ function transformOptions(options) {
6
6
  if (!options)
7
7
  return {};
8
8
  const transformedOptions = Object.assign({}, options);
9
- if (typeof options.priority === "number") {
10
- transformedOptions.priority = options.priority > 0;
9
+ const opts = options;
10
+ if (typeof opts.priority === "number") {
11
+ transformedOptions.priority = opts.priority > 0;
11
12
  }
12
13
  return transformedOptions;
13
14
  }
14
15
  function normalizeJob(job) {
15
- if (typeof job === "object" && "0" in job) {
16
- return job[0];
16
+ if (typeof job === "object" && job !== null && "0" in job) {
17
+ return job["0"];
17
18
  }
18
19
  return job;
19
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../lib/utils/helpers.ts"],"names":[],"mappings":";;AAEA,4CAUC;AAED,oCAKC;AAjBD,SAAgB,gBAAgB,CAAC,OAAuC;IACtE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,kBAAkB,qBAAa,OAAO,CAAE,CAAC;IAE/C,IAAI,OAAQ,OAAe,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAClD,kBAAkB,CAAC,QAAQ,GAAI,OAAe,CAAC,QAAQ,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAgB,YAAY,CAAC,GAAQ;IACnC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1C,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;IAChB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../lib/utils/helpers.ts"],"names":[],"mappings":";;AAEA,4CAaC;AAED,oCAKC;AApBD,SAAgB,gBAAgB,CAC9B,OAAuC;IAEvC,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,kBAAkB,qBAAiC,OAAO,CAAE,CAAC;IACnE,MAAM,IAAI,GAAG,OAAkC,CAAC;IAEhD,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACtC,kBAAkB,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAED,SAAgB,YAAY,CAAC,GAAY;IACvC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1D,OAAQ,GAA+B,CAAC,GAAG,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,48 @@
1
+ // @ts-check
2
+ import eslint from '@eslint/js';
3
+ import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
4
+ import globals from 'globals';
5
+ import tseslint from 'typescript-eslint';
6
+
7
+ export default tseslint.config(
8
+ {
9
+ ignores: ['eslint.config.mjs', 'dist/**'],
10
+ },
11
+ eslint.configs.recommended,
12
+ ...tseslint.configs.recommendedTypeChecked,
13
+ eslintPluginPrettierRecommended,
14
+ {
15
+ languageOptions: {
16
+ globals: {
17
+ ...globals.node,
18
+ ...globals.jest,
19
+ },
20
+ sourceType: 'commonjs',
21
+ parserOptions: {
22
+ projectService: true,
23
+ tsconfigRootDir: import.meta.dirname,
24
+ },
25
+ },
26
+ },
27
+ {
28
+ rules: {
29
+ '@typescript-eslint/no-explicit-any': 'off',
30
+ '@typescript-eslint/explicit-function-return-type': 'off',
31
+ '@typescript-eslint/explicit-module-boundary-types': 'off',
32
+ '@typescript-eslint/no-floating-promises': 'warn',
33
+ '@typescript-eslint/no-unsafe-argument': 'warn',
34
+ '@typescript-eslint/no-unsafe-assignment': 'warn',
35
+ '@typescript-eslint/no-unsafe-call': 'warn',
36
+ '@typescript-eslint/no-unsafe-member-access': 'warn',
37
+ '@typescript-eslint/no-unsafe-return': 'warn',
38
+ '@typescript-eslint/no-unused-vars': [
39
+ 'error',
40
+ {
41
+ args: 'all',
42
+ argsIgnorePattern: '^_',
43
+ varsIgnorePattern: '^_',
44
+ },
45
+ ],
46
+ },
47
+ },
48
+ );
@@ -1,6 +1,5 @@
1
1
  import { SetMetadata } from "@nestjs/common";
2
- import { ScheduleOptions } from "pg-boss";
3
- import { WorkOptions } from "../interfaces/handler-metadata.interface";
2
+ import { ScheduleOptions, WorkOptions } from "pg-boss";
4
3
 
5
4
  export const JOB_NAME = "JOB_NAME";
6
5
  export const JOB_OPTIONS = "JOB_OPTIONS";
@@ -10,11 +9,8 @@ export const PG_BOSS_JOB_METADATA = "PG_BOSS_JOB_METADATA";
10
9
  export const WORK_NAME = "WORK_NAME";
11
10
  export const WORK_OPTIONS = "WORK_OPTIONS";
12
11
 
13
- export function Job<_TData extends object = any>(
14
- name: string,
15
- options: WorkOptions = {},
16
- ) {
17
- return (target: any, key: string, descriptor: PropertyDescriptor) => {
12
+ export function Job(name: string, options: WorkOptions = {}) {
13
+ return (target: object, key: string, descriptor: PropertyDescriptor) => {
18
14
  SetMetadata(JOB_NAME, name)(target, key, descriptor);
19
15
  SetMetadata(JOB_OPTIONS, options)(target, key, descriptor);
20
16
  SetMetadata(PG_BOSS_JOB_METADATA, { jobName: name, workOptions: options })(
@@ -25,12 +21,12 @@ export function Job<_TData extends object = any>(
25
21
  };
26
22
  }
27
23
 
28
- export function CronJob<_TData extends object = any>(
24
+ export function CronJob(
29
25
  name: string,
30
26
  cron: string,
31
27
  options: ScheduleOptions = {},
32
28
  ) {
33
- return (target: any, key: string, descriptor: PropertyDescriptor) => {
29
+ return (target: object, key: string, descriptor: PropertyDescriptor) => {
34
30
  SetMetadata(JOB_NAME, name)(target, key, descriptor);
35
31
  SetMetadata(CRON_EXPRESSION, cron)(target, key, descriptor);
36
32
  SetMetadata(CRON_OPTIONS, options)(target, key, descriptor);
@@ -8,9 +8,9 @@ import {
8
8
  CRON_OPTIONS,
9
9
  } from "./decorators/job.decorator";
10
10
  import { InstanceWrapper } from "@nestjs/core/injector/instance-wrapper";
11
- import PgBoss from "pg-boss";
11
+ import PgBoss, { WorkWithMetadataHandler } from "pg-boss";
12
12
  import { LOGGER } from "./utils/consts";
13
- import { WorkOptions } from "./interfaces/handler-metadata.interface";
13
+ import { WorkOptions } from "pg-boss";
14
14
 
15
15
  @Injectable()
16
16
  export class HandlerScannerService {
@@ -32,14 +32,21 @@ export class HandlerScannerService {
32
32
  }
33
33
  }
34
34
 
35
- private async scanProvider(provider: InstanceWrapper<any>) {
36
- const { instance } = provider;
35
+ private async scanProvider(provider: InstanceWrapper) {
36
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
37
+ const instance = provider.instance as Record<string, Function> | null;
37
38
  if (!instance || typeof instance !== "object") return;
38
39
 
39
- const prototype = Object.getPrototypeOf(instance);
40
+ const prototype = Object.getPrototypeOf(instance) as Record<
41
+ string,
42
+ unknown
43
+ >;
40
44
  const methodNames = Object.getOwnPropertyNames(prototype).filter(
41
- (method) =>
42
- method !== "constructor" && typeof instance[method] === "function",
45
+ (method) => {
46
+ if (method === "constructor") return false;
47
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, method);
48
+ return descriptor && typeof descriptor.value === "function";
49
+ },
43
50
  );
44
51
 
45
52
  for (const methodName of methodNames) {
@@ -65,7 +72,7 @@ export class HandlerScannerService {
65
72
  await this.pgBossService.registerCronJob(
66
73
  jobName,
67
74
  cronExpression,
68
- methodRef.bind(instance),
75
+ methodRef.bind(instance) as WorkWithMetadataHandler<object>,
69
76
  {},
70
77
  cronOptions,
71
78
  );
@@ -73,15 +80,13 @@ export class HandlerScannerService {
73
80
  continue;
74
81
  }
75
82
 
76
- const teamSize = Math.max(1, jobOptions?.teamSize ?? 1);
77
- for (let i = 0; i < teamSize; i++) {
78
- await this.pgBossService.registerJob(
79
- jobName,
80
- methodRef.bind(instance),
81
- jobOptions,
82
- );
83
- }
84
- this.logger.log(`Registered job: ${jobName} (${teamSize} worker${teamSize > 1 ? 's' : ''})`);
83
+ await this.pgBossService.registerJob(
84
+ jobName,
85
+ methodRef.bind(instance) as WorkWithMetadataHandler<object>,
86
+ jobOptions,
87
+ );
88
+
89
+ this.logger.log(`Registered job: ${jobName}`);
85
90
  } catch (error) {
86
91
  this.logger.error(error, `Error registering job ${jobName}`);
87
92
  }
@@ -1,8 +1,4 @@
1
- import { WorkOptions as PgBossWorkOptions, ScheduleOptions } from "pg-boss";
2
-
3
- export interface WorkOptions extends PgBossWorkOptions {
4
- teamSize?: number;
5
- }
1
+ import { WorkOptions, ScheduleOptions } from "pg-boss";
6
2
 
7
3
  export interface HandlerMetadata {
8
4
  jobName: string;