@forgrit/shared-contracts-jobs-queue 0.1.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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +57 -0
- package/dist/jobs/index.d.ts +3 -0
- package/dist/jobs/index.js +19 -0
- package/dist/jobs/tokens.d.ts +24 -0
- package/dist/jobs/tokens.js +27 -0
- package/dist/jobs/types.d.ts +94 -0
- package/dist/jobs/types.js +3 -0
- package/dist/queue/index.d.ts +3 -0
- package/dist/queue/index.js +19 -0
- package/dist/queue/tokens.d.ts +14 -0
- package/dist/queue/tokens.js +17 -0
- package/dist/queue/types.d.ts +43 -0
- package/dist/queue/types.js +3 -0
- package/package.json +63 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog — @forgrit/shared-contracts-jobs-queue
|
|
2
|
+
|
|
3
|
+
## [0.1.0] — 2026-05-26
|
|
4
|
+
|
|
5
|
+
### Added — initial public release
|
|
6
|
+
|
|
7
|
+
- `IJobsService` interface (3 methods: createStep, getJob, getFrozenPrompt) + `JOBS_SERVICE` Symbol token
|
|
8
|
+
- `IQueueService` interface (1 method: enqueue) + `QUEUE_SERVICE` Symbol token
|
|
9
|
+
- `IJobStepService` interface (2 methods) + `JOB_STEP_SERVICE` Symbol token
|
|
10
|
+
- `StepType`, `StepStatus`, `JobStatus` enum types (re-exported from @forgrit/contracts)
|
|
11
|
+
- Sub-path exports: `./jobs`, `./queue`
|
|
12
|
+
|
|
13
|
+
### Notes
|
|
14
|
+
|
|
15
|
+
- Narrow-surface discipline (FM-A from plan #5.05): 3 of 22 JobsService methods + 1 of 13 QueueService methods + 2 of N JobStepService methods. Consumers depend on the contracts; ForGrit's internal implementations may add private methods without breaking the contract.
|
|
16
|
+
- Designed for the BullMQ singleton-invariant pattern: consumers wire `useExisting: ConcreteJobsService` so DI never creates a duplicate Queue/Worker.
|
|
17
|
+
- Node 20+. Peer dep: `@nestjs/common`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ForGrit AI <forgritai@gmail.com>
|
|
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
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @forgrit/shared-contracts-jobs-queue
|
|
2
|
+
|
|
3
|
+
> Type-only contracts + NestJS DI Symbol tokens for ForGrit job + queue services — `IJobsService` (3 methods), `IQueueService` (1 method), `IJobStepService` (2 methods).
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@forgrit/shared-contracts-jobs-queue)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
|
|
8
|
+
> **Status: early-access (v0.x).** Internal-monorepo seam package. Pre-1.0 may include breaking changes in minor bumps.
|
|
9
|
+
|
|
10
|
+
Narrow-surface contracts: 3 + 1 + 2 = **6 total method signatures** across the 3 interfaces. ForGrit's internal implementations may have many more methods; the contracts capture only what cross-domain consumers depend on.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @forgrit/shared-contracts-jobs-queue
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Peer: `@nestjs/common`.
|
|
21
|
+
|
|
22
|
+
## Sub-modules
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { IJobsService, JOBS_SERVICE } from '@forgrit/shared-contracts-jobs-queue/jobs';
|
|
26
|
+
import { IQueueService, QUEUE_SERVICE } from '@forgrit/shared-contracts-jobs-queue/queue';
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Pattern
|
|
30
|
+
|
|
31
|
+
Use `useExisting` so DI never creates a duplicate BullMQ Queue/Worker:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
@Module({
|
|
35
|
+
providers: [MyJobsService, { provide: JOBS_SERVICE, useExisting: MyJobsService }],
|
|
36
|
+
})
|
|
37
|
+
export class MyModule {}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT — see [LICENSE](./LICENSE).
|
|
43
|
+
|
|
44
|
+
## Sibling packages
|
|
45
|
+
|
|
46
|
+
- [`@forgrit/shared-contracts-platform`](https://www.npmjs.com/package/@forgrit/shared-contracts-platform) — auth + logger + db contracts
|
|
47
|
+
- [`@forgrit/shared-contracts-prompt`](https://www.npmjs.com/package/@forgrit/shared-contracts-prompt) — prompt-pipeline contracts
|
|
48
|
+
- [`@forgrit/contracts`](https://www.npmjs.com/package/@forgrit/contracts) — domain Zod schemas + types
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @forgrit/shared-contracts-jobs-queue — public surface.
|
|
3
|
+
//
|
|
4
|
+
// Plan #5.05 (2026-05-25) — third contract package, sibling to
|
|
5
|
+
// @forgrit/shared-contracts-platform (plan #4.4) and
|
|
6
|
+
// @forgrit/shared-contracts-design-composition (plans #4.55 + #4.57).
|
|
7
|
+
//
|
|
8
|
+
// Surface:
|
|
9
|
+
// - Types: IJobsService (3 methods), IQueueService (1 method)
|
|
10
|
+
// - DI tokens: JOBS_SERVICE, QUEUE_SERVICE (both Symbol.for global)
|
|
11
|
+
// - No runtime values beyond the 2 Symbol tokens.
|
|
12
|
+
//
|
|
13
|
+
// Sub-path exports are preferred for tree-shaking:
|
|
14
|
+
// import { IJobsService, JOBS_SERVICE } from '@forgrit/shared-contracts-jobs-queue/jobs';
|
|
15
|
+
// import { IQueueService, QUEUE_SERVICE } from '@forgrit/shared-contracts-jobs-queue/queue';
|
|
16
|
+
// The root barrel exists for convenience only.
|
|
17
|
+
//
|
|
18
|
+
// No dependency on @forgrit/shared-contracts-platform OR
|
|
19
|
+
// @forgrit/shared-contracts-design-composition — orthogonal surfaces.
|
|
20
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
23
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
24
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(o, k2, desc);
|
|
27
|
+
}) : (function(o, m, k, k2) {
|
|
28
|
+
if (k2 === undefined) k2 = k;
|
|
29
|
+
o[k2] = m[k];
|
|
30
|
+
}));
|
|
31
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
32
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
33
|
+
}) : function(o, v) {
|
|
34
|
+
o["default"] = v;
|
|
35
|
+
});
|
|
36
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
37
|
+
var ownKeys = function(o) {
|
|
38
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
39
|
+
var ar = [];
|
|
40
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
41
|
+
return ar;
|
|
42
|
+
};
|
|
43
|
+
return ownKeys(o);
|
|
44
|
+
};
|
|
45
|
+
return function (mod) {
|
|
46
|
+
if (mod && mod.__esModule) return mod;
|
|
47
|
+
var result = {};
|
|
48
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
49
|
+
__setModuleDefault(result, mod);
|
|
50
|
+
return result;
|
|
51
|
+
};
|
|
52
|
+
})();
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.queue = exports.jobs = void 0;
|
|
55
|
+
exports.jobs = __importStar(require("./jobs"));
|
|
56
|
+
exports.queue = __importStar(require("./queue"));
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./tokens"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JOBS_SERVICE — Symbol.for() (global registry) DI token for IJobsService.
|
|
3
|
+
*
|
|
4
|
+
* Plan #5.05 (2026-05-25): use with @Inject(JOBS_SERVICE) in
|
|
5
|
+
* lifecycle/* NestJS providers. apps/api/src/platform-contracts.module.ts
|
|
6
|
+
* (T5) binds the token to the concrete JobsService instance via
|
|
7
|
+
* `useExisting:` so DI graph stays single-rooted.
|
|
8
|
+
*
|
|
9
|
+
* Namespace `@forgrit/jobs-queue/*` (NOT `@forgrit/platform/*`) so
|
|
10
|
+
* FM-C: no collision with plan #4.4's @forgrit/platform/auth/JobOwnerGuard.
|
|
11
|
+
* Each contract package gets its own Symbol.for() namespace; README
|
|
12
|
+
* documents the convention.
|
|
13
|
+
*/
|
|
14
|
+
export declare const JOBS_SERVICE: unique symbol;
|
|
15
|
+
/**
|
|
16
|
+
* JOB_STEP_SERVICE — Symbol.for() DI token for IJobStepService.
|
|
17
|
+
*
|
|
18
|
+
* Plan #5.6 T5 (2026-05-26): added as FM-A escalation when wave-3 survey
|
|
19
|
+
* surfaced JobStepService consumption in architecture-decisions.controller.
|
|
20
|
+
* Use with @Inject(JOB_STEP_SERVICE) in lifecycle/* providers.
|
|
21
|
+
* apps/api/src/platform-contracts.module.ts binds via `useExisting:`.
|
|
22
|
+
*/
|
|
23
|
+
export declare const JOB_STEP_SERVICE: unique symbol;
|
|
24
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JOB_STEP_SERVICE = exports.JOBS_SERVICE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* JOBS_SERVICE — Symbol.for() (global registry) DI token for IJobsService.
|
|
6
|
+
*
|
|
7
|
+
* Plan #5.05 (2026-05-25): use with @Inject(JOBS_SERVICE) in
|
|
8
|
+
* lifecycle/* NestJS providers. apps/api/src/platform-contracts.module.ts
|
|
9
|
+
* (T5) binds the token to the concrete JobsService instance via
|
|
10
|
+
* `useExisting:` so DI graph stays single-rooted.
|
|
11
|
+
*
|
|
12
|
+
* Namespace `@forgrit/jobs-queue/*` (NOT `@forgrit/platform/*`) so
|
|
13
|
+
* FM-C: no collision with plan #4.4's @forgrit/platform/auth/JobOwnerGuard.
|
|
14
|
+
* Each contract package gets its own Symbol.for() namespace; README
|
|
15
|
+
* documents the convention.
|
|
16
|
+
*/
|
|
17
|
+
exports.JOBS_SERVICE = Symbol.for('@forgrit/jobs-queue/JobsService');
|
|
18
|
+
/**
|
|
19
|
+
* JOB_STEP_SERVICE — Symbol.for() DI token for IJobStepService.
|
|
20
|
+
*
|
|
21
|
+
* Plan #5.6 T5 (2026-05-26): added as FM-A escalation when wave-3 survey
|
|
22
|
+
* surfaced JobStepService consumption in architecture-decisions.controller.
|
|
23
|
+
* Use with @Inject(JOB_STEP_SERVICE) in lifecycle/* providers.
|
|
24
|
+
* apps/api/src/platform-contracts.module.ts binds via `useExisting:`.
|
|
25
|
+
*/
|
|
26
|
+
exports.JOB_STEP_SERVICE = Symbol.for('@forgrit/jobs-queue/JobStepService');
|
|
27
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IJobsService — minimum-surface contract for the subset of
|
|
3
|
+
* apps/api/src/jobs/jobs.service.ts JobsService public methods that
|
|
4
|
+
* the wave-3 blueprint freeze set (plan #5.6) actually uses.
|
|
5
|
+
*
|
|
6
|
+
* Surface (per T1 grep survey on plan/exec-2026-05-25-blueprint-w1):
|
|
7
|
+
* - createStep — called 4× in blueprint.worker.ts,
|
|
8
|
+
* 1× in architecture/architecture.worker.ts
|
|
9
|
+
* - getJob — called 2× in architecture/architecture-decisions.controller.ts
|
|
10
|
+
* - getFrozenPrompt — called 1× in architecture/architecture-decisions.controller.ts
|
|
11
|
+
*
|
|
12
|
+
* Plan #5.05 (2026-05-25): contracted so the 6 wave-3 freeze files
|
|
13
|
+
* (blueprint.module.ts, blueprint.worker.ts, blueprint.service.ts,
|
|
14
|
+
* blueprint-codegen-bridge.ts, architecture-decisions.controller.ts,
|
|
15
|
+
* architecture.worker.ts, contract.worker.ts) can satisfy §1A.b
|
|
16
|
+
* without reaching into apps/api/src/jobs/jobs.service.ts at runtime.
|
|
17
|
+
*
|
|
18
|
+
* Method signatures use loose typing (Record<string, unknown> for
|
|
19
|
+
* inputs, Promise<unknown> for outputs) following plan #4.4's
|
|
20
|
+
* IPrismaService precedent — the full Prisma generic-arg machinery
|
|
21
|
+
* is too heavy to mirror by hand and would force lifecycle/* to
|
|
22
|
+
* depend on @prisma/client (defeating the contract). Call sites in
|
|
23
|
+
* lifecycle/* keep their own narrow types via TS inference at the
|
|
24
|
+
* assignment line. The `type` parameter corresponds to the StepType
|
|
25
|
+
* enum (sourced from apps/api/src/jobs/jobs.types.ts); contract uses
|
|
26
|
+
* `string` for portability, consumers narrow via the enum at the
|
|
27
|
+
* call site.
|
|
28
|
+
*
|
|
29
|
+
* If wave-3 execution surfaces a new JobsService method the freeze
|
|
30
|
+
* set needs (unlikely — survey was exhaustive — but possible if a
|
|
31
|
+
* dependency surfaces during plan #5.6's mechanical move), extend
|
|
32
|
+
* this interface in the SAME commit as plan #5.6. README documents
|
|
33
|
+
* the discipline.
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* IJobStepService — minimum-surface contract for the subset of
|
|
37
|
+
* apps/api/src/jobs/job-step.service.ts JobStepService public methods
|
|
38
|
+
* the wave-3 blueprint freeze set actually uses.
|
|
39
|
+
*
|
|
40
|
+
* Surface (per plan #5.6 T1 survey):
|
|
41
|
+
* - updateStep — called 1× in architecture-decisions.controller.ts
|
|
42
|
+
* - listStepsForJob — called 1× in architecture-decisions.controller.ts
|
|
43
|
+
*
|
|
44
|
+
* Plan #5.6 T5 (2026-05-26): added as FM-A escalation. Plan #5.05 originally
|
|
45
|
+
* contracted only JobsService + QueueService; the T1 survey surfaced
|
|
46
|
+
* JobStepService as a wave-3 dependency in architecture-decisions.controller.
|
|
47
|
+
* Same-commit extension keeps the wave-3 controller compatible with §1A.b.
|
|
48
|
+
*
|
|
49
|
+
* Loose typing follows IJobsService precedent — concrete callers in
|
|
50
|
+
* lifecycle/* retain narrow types via TS inference.
|
|
51
|
+
*/
|
|
52
|
+
export interface IJobStepService {
|
|
53
|
+
/**
|
|
54
|
+
* Update a JobStep row. `update` is loosely typed as Record<string, unknown>
|
|
55
|
+
* for portability — concrete callers narrow via TS inference at the
|
|
56
|
+
* assignment line. Typical use: persist outputJson + status transitions.
|
|
57
|
+
*/
|
|
58
|
+
updateStep(stepId: string, update: Record<string, unknown>): Promise<unknown>;
|
|
59
|
+
/**
|
|
60
|
+
* List all JobSteps for a job. Returns step rows ordered by createdAt
|
|
61
|
+
* (per the concrete service's default ordering). Returns [] if no steps.
|
|
62
|
+
*/
|
|
63
|
+
listStepsForJob(jobId: string): Promise<unknown[]>;
|
|
64
|
+
}
|
|
65
|
+
export interface IJobsService {
|
|
66
|
+
/**
|
|
67
|
+
* Create a JobStep. Increments attempt count for (jobId, type) pairs.
|
|
68
|
+
*
|
|
69
|
+
* `type` corresponds to the StepType enum (currently sourced from
|
|
70
|
+
* apps/api/src/jobs/jobs.types.ts). Contract uses `string` for
|
|
71
|
+
* portability; consumers narrow via the enum at the call site.
|
|
72
|
+
*
|
|
73
|
+
* `inputJson` is opaque per-step input; the concrete service casts
|
|
74
|
+
* it to Prisma.InputJsonValue.
|
|
75
|
+
*
|
|
76
|
+
* Returns the created JobStep row. Loosely typed for the same
|
|
77
|
+
* reason as IPrismaService — concrete callers retain narrow types
|
|
78
|
+
* via inference at the assignment line.
|
|
79
|
+
*/
|
|
80
|
+
createStep(jobId: string, type: string, inputJson: Record<string, unknown>): Promise<unknown>;
|
|
81
|
+
/**
|
|
82
|
+
* Fetch a job by id including its steps relation (ordered by
|
|
83
|
+
* createdAt desc). Returns null if the job doesn't exist (does NOT
|
|
84
|
+
* throw — see `getJobOrThrow` in the concrete service for the
|
|
85
|
+
* throwing variant, which is NOT in this contract).
|
|
86
|
+
*/
|
|
87
|
+
getJob(jobId: string): Promise<unknown | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Fetch a FrozenPrompt by its promptId (the business-key column,
|
|
90
|
+
* not the row id). Returns null if not found.
|
|
91
|
+
*/
|
|
92
|
+
getFrozenPrompt(promptId: string): Promise<unknown | null>;
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./tokens"), exports);
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QUEUE_SERVICE — Symbol.for() (global registry) DI token for IQueueService.
|
|
3
|
+
*
|
|
4
|
+
* Plan #5.05 (2026-05-25): use with @Inject(QUEUE_SERVICE) in
|
|
5
|
+
* lifecycle/* NestJS providers. apps/api/src/platform-contracts.module.ts
|
|
6
|
+
* (T5) binds the token to the concrete QueueService instance via
|
|
7
|
+
* `useExisting:` so the singleton BullMQ Queue + Worker + in-memory
|
|
8
|
+
* fallback array are preserved.
|
|
9
|
+
*
|
|
10
|
+
* Namespace `@forgrit/jobs-queue/*` (NOT `@forgrit/platform/*`) — see
|
|
11
|
+
* jobs/tokens.ts for the namespace convention rationale.
|
|
12
|
+
*/
|
|
13
|
+
export declare const QUEUE_SERVICE: unique symbol;
|
|
14
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.QUEUE_SERVICE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* QUEUE_SERVICE — Symbol.for() (global registry) DI token for IQueueService.
|
|
6
|
+
*
|
|
7
|
+
* Plan #5.05 (2026-05-25): use with @Inject(QUEUE_SERVICE) in
|
|
8
|
+
* lifecycle/* NestJS providers. apps/api/src/platform-contracts.module.ts
|
|
9
|
+
* (T5) binds the token to the concrete QueueService instance via
|
|
10
|
+
* `useExisting:` so the singleton BullMQ Queue + Worker + in-memory
|
|
11
|
+
* fallback array are preserved.
|
|
12
|
+
*
|
|
13
|
+
* Namespace `@forgrit/jobs-queue/*` (NOT `@forgrit/platform/*`) — see
|
|
14
|
+
* jobs/tokens.ts for the namespace convention rationale.
|
|
15
|
+
*/
|
|
16
|
+
exports.QUEUE_SERVICE = Symbol.for('@forgrit/jobs-queue/QueueService');
|
|
17
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IQueueService — minimum-surface contract for the subset of
|
|
3
|
+
* apps/api/src/queue/queue.service.ts QueueService public methods
|
|
4
|
+
* the wave-3 blueprint freeze set actually uses.
|
|
5
|
+
*
|
|
6
|
+
* Surface (per T1 grep survey):
|
|
7
|
+
* - enqueue — called 6× in blueprint.worker.ts,
|
|
8
|
+
* 1× in architecture/architecture.worker.ts
|
|
9
|
+
*
|
|
10
|
+
* Plan #5.05 (2026-05-25): contracted so the wave-3 freeze set can
|
|
11
|
+
* satisfy §1A.b without importing the QueueService class.
|
|
12
|
+
*
|
|
13
|
+
* Notably OUT of contract (NOT consumed by wave-3 freeze set):
|
|
14
|
+
* - getQueueMetrics, getWorkerHealth, startWorker, moveToDlq,
|
|
15
|
+
* getDlqEntries, requeueFromDlq, bulkRequeueFromDlq,
|
|
16
|
+
* purgeOldDlqEntries, getDlqStats, dailyDlqCleanup,
|
|
17
|
+
* onModuleInit, onModuleDestroy
|
|
18
|
+
* - BullMQ types (Queue, Worker, Job) — implementation detail
|
|
19
|
+
* - QueueMetrics, DlqEntry interfaces — admin/ops surfaces, not
|
|
20
|
+
* consumed by blueprint
|
|
21
|
+
*
|
|
22
|
+
* When a future lifecycle module needs DLQ or metrics, extend this
|
|
23
|
+
* interface in the SAME commit. README documents the discipline.
|
|
24
|
+
*/
|
|
25
|
+
export interface IQueueService {
|
|
26
|
+
/**
|
|
27
|
+
* Enqueue a JobStep for processing.
|
|
28
|
+
*
|
|
29
|
+
* In Redis mode: adds to BullMQ with priority derived from stepType.
|
|
30
|
+
* In memory mode: pushes to in-memory FIFO.
|
|
31
|
+
*
|
|
32
|
+
* The terminal-job guard inside the concrete QueueService silently
|
|
33
|
+
* skips enqueue if the parent job is in a terminal state
|
|
34
|
+
* (FAILED/CODEGEN_FAILED/BLUEPRINT_FAILED/CODEGEN_FROZEN/COMPLETED) —
|
|
35
|
+
* callers do NOT need to pre-check. Returns void (never throws).
|
|
36
|
+
*
|
|
37
|
+
* `stepType` is optional; when omitted the concrete service looks
|
|
38
|
+
* it up via Prisma. Pass it when known (callers in the wave-3 set
|
|
39
|
+
* always have it from the just-created JobStep).
|
|
40
|
+
*/
|
|
41
|
+
enqueue(stepId: string, stepType?: string): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@forgrit/shared-contracts-jobs-queue",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Type-only contracts + NestJS DI Symbol tokens for ForGrit job + queue services — IJobsService, IQueueService, IJobStepService.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"contracts",
|
|
7
|
+
"types",
|
|
8
|
+
"nestjs",
|
|
9
|
+
"jobs",
|
|
10
|
+
"queue",
|
|
11
|
+
"bullmq",
|
|
12
|
+
"forgrit"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "ForGrit AI <forgritai@gmail.com>",
|
|
16
|
+
"homepage": "https://github.com/forgrit-ai/forgrit/tree/main/shared/contracts-jobs-queue",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/forgrit-ai/forgrit.git",
|
|
20
|
+
"directory": "shared/contracts-jobs-queue"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/forgrit-ai/forgrit/issues"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"default": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./jobs": {
|
|
33
|
+
"types": "./dist/jobs/index.d.ts",
|
|
34
|
+
"default": "./dist/jobs/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./queue": {
|
|
37
|
+
"types": "./dist/queue/index.d.ts",
|
|
38
|
+
"default": "./dist/queue/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist/**/*.js",
|
|
43
|
+
"dist/**/*.d.ts",
|
|
44
|
+
"README.md",
|
|
45
|
+
"CHANGELOG.md",
|
|
46
|
+
"LICENSE"
|
|
47
|
+
],
|
|
48
|
+
"publishConfig": {
|
|
49
|
+
"access": "public",
|
|
50
|
+
"registry": "https://registry.npmjs.org/"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20.0.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"typescript": "^5.3.3",
|
|
57
|
+
"@forgrit/tsconfig": "0.1.0"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"build": "tsc -p tsconfig.json",
|
|
61
|
+
"check": "tsc --noEmit -p tsconfig.json"
|
|
62
|
+
}
|
|
63
|
+
}
|