@nest-boot/queue-api 0.0.0-stage → 8.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.
Files changed (36) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -2
  3. package/dist/connections/job.connection-definition.d.ts +9 -0
  4. package/dist/connections/job.connection-definition.js +50 -0
  5. package/dist/connections/job.connection-definition.js.map +1 -0
  6. package/dist/decorators/queue-visible.decorator.d.ts +14 -0
  7. package/dist/decorators/queue-visible.decorator.js +20 -0
  8. package/dist/decorators/queue-visible.decorator.js.map +1 -0
  9. package/dist/entities/index.d.ts +4 -0
  10. package/dist/entities/index.js +5 -0
  11. package/dist/entities/index.js.map +1 -0
  12. package/dist/entities/job.entity.d.ts +24 -0
  13. package/dist/entities/job.entity.js +128 -0
  14. package/dist/entities/job.entity.js.map +1 -0
  15. package/dist/enums/job-status.enum.d.ts +19 -0
  16. package/dist/enums/job-status.enum.js +23 -0
  17. package/dist/enums/job-status.enum.js.map +1 -0
  18. package/dist/index.d.ts +7 -0
  19. package/dist/index.js +8 -0
  20. package/dist/index.js.map +1 -0
  21. package/dist/processors/job.processor.d.ts +18 -0
  22. package/dist/processors/job.processor.js +111 -0
  23. package/dist/processors/job.processor.js.map +1 -0
  24. package/dist/queue-api.module.d.ts +3 -0
  25. package/dist/queue-api.module.js +25 -0
  26. package/dist/queue-api.module.js.map +1 -0
  27. package/dist/queues/job.queue.d.ts +32 -0
  28. package/dist/queues/job.queue.js +65 -0
  29. package/dist/queues/job.queue.js.map +1 -0
  30. package/dist/resolvers/job.resolver.d.ts +54 -0
  31. package/dist/resolvers/job.resolver.js +145 -0
  32. package/dist/resolvers/job.resolver.js.map +1 -0
  33. package/dist/services/job.service.d.ts +77 -0
  34. package/dist/services/job.service.js +276 -0
  35. package/dist/services/job.service.js.map +1 -0
  36. package/package.json +115 -3
@@ -0,0 +1,25 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { QueueModule } from "@nest-boot/queue";
8
+ import { Global, Module } from "@nestjs/common";
9
+ import { JobProcessor } from "./processors/job.processor.js";
10
+ import { JobQueue } from "./queues/job.queue.js";
11
+ import { JobResolver } from "./resolvers/job.resolver.js";
12
+ import { JobService } from "./services/job.service.js";
13
+ /** Authenticated Job APIs using the application's global database and auth configuration. */
14
+ let QueueApiModule = class QueueApiModule {
15
+ };
16
+ QueueApiModule = __decorate([
17
+ Global(),
18
+ Module({
19
+ imports: [QueueModule],
20
+ providers: [JobQueue, JobProcessor, JobService, JobResolver],
21
+ exports: [JobService],
22
+ })
23
+ ], QueueApiModule);
24
+ export { QueueApiModule };
25
+ //# sourceMappingURL=queue-api.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queue-api.module.js","sourceRoot":"","sources":["../src/queue-api.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD,6FAA6F;AAOtF,IAAM,cAAc,GAApB,MAAM,cAAc;CAAG,CAAA;AAAjB,cAAc;IAN1B,MAAM,EAAE;IACR,MAAM,CAAC;QACN,OAAO,EAAE,CAAC,WAAW,CAAC;QACtB,SAAS,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,CAAC;QAC5D,OAAO,EAAE,CAAC,UAAU,CAAC;KACtB,CAAC;GACW,cAAc,CAAG"}
@@ -0,0 +1,32 @@
1
+ import type { QueueOptions } from "@nest-boot/queue";
2
+ import { BaseQueue } from "@nest-boot/queue";
3
+ import type { JobProgress } from "bullmq";
4
+ import { z } from "zod";
5
+ import { JobStatus } from "../enums/job-status.enum.js";
6
+ /** Built-in Redis queue for synchronizing and cleaning up Job records. */
7
+ export declare class JobQueue extends BaseQueue {
8
+ readonly jobSchemas: {
9
+ cleanup: {
10
+ data: z.ZodObject<{}, z.core.$strip>;
11
+ };
12
+ sync: {
13
+ data: z.ZodObject<{
14
+ eventId: z.ZodString;
15
+ data: z.ZodObject<{
16
+ queue: z.ZodString;
17
+ jobId: z.ZodString;
18
+ name: z.ZodOptional<z.ZodString>;
19
+ data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
20
+ status: z.ZodOptional<z.ZodEnum<typeof JobStatus>>;
21
+ progress: z.ZodOptional<z.ZodNullable<z.ZodCustom<JobProgress, JobProgress>>>;
22
+ returnValue: z.ZodOptional<z.ZodUnknown>;
23
+ failedReason: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ createdAt: z.ZodOptional<z.ZodNumber>;
25
+ startedAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
26
+ finishedAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
27
+ }, z.core.$strip>;
28
+ }, z.core.$strip>;
29
+ };
30
+ };
31
+ constructor(options?: QueueOptions);
32
+ }
@@ -0,0 +1,65 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { Queue } from "@nest-boot/queue";
14
+ import { BaseQueue } from "@nest-boot/queue";
15
+ import { Optional } from "@nestjs/common";
16
+ import { z } from "zod";
17
+ import { JobStatus } from "../enums/job-status.enum.js";
18
+ /** Built-in Redis queue for synchronizing and cleaning up Job records. */
19
+ let JobQueue = class JobQueue extends BaseQueue {
20
+ jobSchemas = {
21
+ cleanup: { data: z.object({}) },
22
+ sync: {
23
+ data: z.object({
24
+ eventId: z.string().regex(/^\d+-\d+$/),
25
+ data: z.object({
26
+ queue: z.string(),
27
+ jobId: z.string(),
28
+ name: z.string().optional(),
29
+ data: z.record(z.string(), z.unknown()).optional(),
30
+ status: z.enum(JobStatus).optional(),
31
+ progress: z
32
+ .custom((value) => typeof value === "number" ||
33
+ typeof value === "string" ||
34
+ typeof value === "boolean" ||
35
+ (typeof value === "object" && value !== null))
36
+ .nullish(),
37
+ returnValue: z.unknown().optional(),
38
+ failedReason: z.string().nullish(),
39
+ createdAt: z.number().int().nonnegative().optional(),
40
+ startedAt: z.number().int().nonnegative().nullish(),
41
+ finishedAt: z.number().int().nonnegative().nullish(),
42
+ }),
43
+ }),
44
+ },
45
+ };
46
+ constructor(options = {}) {
47
+ super({
48
+ ...options,
49
+ defaultJobOptions: {
50
+ attempts: 20,
51
+ backoff: { type: "exponential", delay: 1000 },
52
+ removeOnComplete: true,
53
+ removeOnFail: 1000,
54
+ ...options.defaultJobOptions,
55
+ },
56
+ });
57
+ }
58
+ };
59
+ JobQueue = __decorate([
60
+ Queue(),
61
+ __param(0, Optional()),
62
+ __metadata("design:paramtypes", [Object])
63
+ ], JobQueue);
64
+ export { JobQueue };
65
+ //# sourceMappingURL=job.queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.queue.js","sourceRoot":"","sources":["../../src/queues/job.queue.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAExD,0EAA0E;AAEnE,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,SAAS;IAC5B,UAAU,GAAG;QACpB,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QAC/B,IAAI,EAAE;YACJ,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;gBACb,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC;gBACtC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;oBACb,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;oBACjB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;oBACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;oBAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;oBAClD,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE;oBACpC,QAAQ,EAAE,CAAC;yBACR,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,CACR,OAAO,KAAK,KAAK,QAAQ;wBACzB,OAAO,KAAK,KAAK,QAAQ;wBACzB,OAAO,KAAK,KAAK,SAAS;wBAC1B,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAChD;yBACA,OAAO,EAAE;oBACZ,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;oBACnC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE;oBAClC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE;oBACpD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE;oBACnD,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE;iBACrD,CAAC;aACH,CAAC;SACH;KACF,CAAC;IAEF,YAAwB,UAAwB,EAAE;QAChD,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,iBAAiB,EAAE;gBACjB,QAAQ,EAAE,EAAE;gBACZ,OAAO,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE;gBAC7C,gBAAgB,EAAE,IAAI;gBACtB,YAAY,EAAE,IAAI;gBAClB,GAAG,OAAO,CAAC,iBAAiB;aAC7B;SACF,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA3CY,QAAQ;IADpB,KAAK,EAAE;IAgCO,WAAA,QAAQ,EAAE,CAAA;;GA/BZ,QAAQ,CA2CpB"}
@@ -0,0 +1,54 @@
1
+ import type { ConnectionArgsInterface, ConnectionResult } from "@nest-boot/graphql-connection";
2
+ import type { GraphQLResolveInfo } from "graphql";
3
+ import { Job as JobEntity } from "../entities/job.entity.js";
4
+ import { JobService } from "../services/job.service.js";
5
+ /** Authenticated Job queries with visibility and ownership enforced by JobService. */
6
+ export declare class JobResolver {
7
+ private readonly jobService;
8
+ constructor(jobService: JobService);
9
+ /**
10
+ * Returns numeric progress without exposing arbitrary BullMQ progress payloads.
11
+ * @param job - Authorized parent job.
12
+ * @returns Finite numeric progress, or null for other progress values.
13
+ */
14
+ progress(job: JobEntity): number | null;
15
+ /**
16
+ * Reads a task belonging to the current user.
17
+ * @param id - Database-generated Job UUID.
18
+ * @returns Matching record in the authorized scope, or null.
19
+ */
20
+ userJob(id: string): Promise<JobEntity | null>;
21
+ /**
22
+ * Paginates tasks belonging to the current user.
23
+ * @param args - Cursor pagination, filters and creation-time ordering.
24
+ * @param info - GraphQL selection used to shape the query.
25
+ * @returns Nodes and counts within the same authorized scope.
26
+ */
27
+ userJobs(args: ConnectionArgsInterface<JobEntity>, info: GraphQLResolveInfo): Promise<ConnectionResult<JobEntity>>;
28
+ /**
29
+ * Reads a task in the authorized current workspace.
30
+ * @param id - Database-generated Job UUID.
31
+ * @returns Matching record in the authorized scope, or null.
32
+ */
33
+ workspaceJob(id: string): Promise<JobEntity | null>;
34
+ /**
35
+ * Paginates tasks in the authorized current workspace.
36
+ * @param args - Cursor pagination, filters and creation-time ordering.
37
+ * @param info - GraphQL selection used to shape the query.
38
+ * @returns Nodes and counts within the same authorized scope.
39
+ */
40
+ workspaceJobs(args: ConnectionArgsInterface<JobEntity>, info: GraphQLResolveInfo): Promise<ConnectionResult<JobEntity>>;
41
+ /**
42
+ * Reads an unowned task after administrator authorization.
43
+ * @param id - Database-generated Job UUID.
44
+ * @returns Matching record in the authorized scope, or null.
45
+ */
46
+ systemJob(id: string): Promise<JobEntity | null>;
47
+ /**
48
+ * Paginates unowned tasks after administrator authorization.
49
+ * @param args - Cursor pagination, filters and creation-time ordering.
50
+ * @param info - GraphQL selection used to shape the query.
51
+ * @returns Nodes and counts within the same authorized scope.
52
+ */
53
+ systemJobs(args: ConnectionArgsInterface<JobEntity>, info: GraphQLResolveInfo): Promise<ConnectionResult<JobEntity>>;
54
+ }
@@ -0,0 +1,145 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
11
+ return function (target, key) { decorator(target, key, paramIndex); }
12
+ };
13
+ import { AuthGuard } from "@nest-boot/auth";
14
+ import { Args, Float, ID, Info, Parent, Query, ResolveField, Resolver, } from "@nest-boot/graphql";
15
+ import { UseGuards } from "@nestjs/common";
16
+ import { JobConnection, JobConnectionArgs, } from "../connections/job.connection-definition.js";
17
+ import { Job as JobEntity } from "../entities/job.entity.js";
18
+ import { JobService } from "../services/job.service.js";
19
+ /** Authenticated Job queries with visibility and ownership enforced by JobService. */
20
+ let JobResolver = class JobResolver {
21
+ jobService;
22
+ constructor(jobService) {
23
+ this.jobService = jobService;
24
+ }
25
+ /**
26
+ * Returns numeric progress without exposing arbitrary BullMQ progress payloads.
27
+ * @param job - Authorized parent job.
28
+ * @returns Finite numeric progress, or null for other progress values.
29
+ */
30
+ progress(job) {
31
+ return typeof job.progress === "number" && Number.isFinite(job.progress)
32
+ ? job.progress
33
+ : null;
34
+ }
35
+ /**
36
+ * Reads a task belonging to the current user.
37
+ * @param id - Database-generated Job UUID.
38
+ * @returns Matching record in the authorized scope, or null.
39
+ */
40
+ async userJob(id) {
41
+ return await this.jobService.getUserJob(id);
42
+ }
43
+ /**
44
+ * Paginates tasks belonging to the current user.
45
+ * @param args - Cursor pagination, filters and creation-time ordering.
46
+ * @param info - GraphQL selection used to shape the query.
47
+ * @returns Nodes and counts within the same authorized scope.
48
+ */
49
+ async userJobs(args, info) {
50
+ return await this.jobService.getUserJobConnection(args, info);
51
+ }
52
+ /**
53
+ * Reads a task in the authorized current workspace.
54
+ * @param id - Database-generated Job UUID.
55
+ * @returns Matching record in the authorized scope, or null.
56
+ */
57
+ async workspaceJob(id) {
58
+ return await this.jobService.getWorkspaceJob(id);
59
+ }
60
+ /**
61
+ * Paginates tasks in the authorized current workspace.
62
+ * @param args - Cursor pagination, filters and creation-time ordering.
63
+ * @param info - GraphQL selection used to shape the query.
64
+ * @returns Nodes and counts within the same authorized scope.
65
+ */
66
+ async workspaceJobs(args, info) {
67
+ return await this.jobService.getWorkspaceJobConnection(args, info);
68
+ }
69
+ /**
70
+ * Reads an unowned task after administrator authorization.
71
+ * @param id - Database-generated Job UUID.
72
+ * @returns Matching record in the authorized scope, or null.
73
+ */
74
+ async systemJob(id) {
75
+ return await this.jobService.getSystemJob(id);
76
+ }
77
+ /**
78
+ * Paginates unowned tasks after administrator authorization.
79
+ * @param args - Cursor pagination, filters and creation-time ordering.
80
+ * @param info - GraphQL selection used to shape the query.
81
+ * @returns Nodes and counts within the same authorized scope.
82
+ */
83
+ async systemJobs(args, info) {
84
+ return await this.jobService.getSystemJobConnection(args, info);
85
+ }
86
+ };
87
+ __decorate([
88
+ ResolveField(() => Float, { nullable: true }),
89
+ __param(0, Parent()),
90
+ __metadata("design:type", Function),
91
+ __metadata("design:paramtypes", [JobEntity]),
92
+ __metadata("design:returntype", Object)
93
+ ], JobResolver.prototype, "progress", null);
94
+ __decorate([
95
+ Query(() => JobEntity, { nullable: true }),
96
+ __param(0, Args("id", { type: () => ID })),
97
+ __metadata("design:type", Function),
98
+ __metadata("design:paramtypes", [String]),
99
+ __metadata("design:returntype", Promise)
100
+ ], JobResolver.prototype, "userJob", null);
101
+ __decorate([
102
+ Query(() => JobConnection),
103
+ __param(0, Args({ type: () => JobConnectionArgs })),
104
+ __param(1, Info()),
105
+ __metadata("design:type", Function),
106
+ __metadata("design:paramtypes", [Object, Object]),
107
+ __metadata("design:returntype", Promise)
108
+ ], JobResolver.prototype, "userJobs", null);
109
+ __decorate([
110
+ Query(() => JobEntity, { nullable: true }),
111
+ __param(0, Args("id", { type: () => ID })),
112
+ __metadata("design:type", Function),
113
+ __metadata("design:paramtypes", [String]),
114
+ __metadata("design:returntype", Promise)
115
+ ], JobResolver.prototype, "workspaceJob", null);
116
+ __decorate([
117
+ Query(() => JobConnection),
118
+ __param(0, Args({ type: () => JobConnectionArgs })),
119
+ __param(1, Info()),
120
+ __metadata("design:type", Function),
121
+ __metadata("design:paramtypes", [Object, Object]),
122
+ __metadata("design:returntype", Promise)
123
+ ], JobResolver.prototype, "workspaceJobs", null);
124
+ __decorate([
125
+ Query(() => JobEntity, { nullable: true }),
126
+ __param(0, Args("id", { type: () => ID })),
127
+ __metadata("design:type", Function),
128
+ __metadata("design:paramtypes", [String]),
129
+ __metadata("design:returntype", Promise)
130
+ ], JobResolver.prototype, "systemJob", null);
131
+ __decorate([
132
+ Query(() => JobConnection),
133
+ __param(0, Args({ type: () => JobConnectionArgs })),
134
+ __param(1, Info()),
135
+ __metadata("design:type", Function),
136
+ __metadata("design:paramtypes", [Object, Object]),
137
+ __metadata("design:returntype", Promise)
138
+ ], JobResolver.prototype, "systemJobs", null);
139
+ JobResolver = __decorate([
140
+ UseGuards(AuthGuard),
141
+ Resolver(() => JobEntity),
142
+ __metadata("design:paramtypes", [JobService])
143
+ ], JobResolver);
144
+ export { JobResolver };
145
+ //# sourceMappingURL=job.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"job.resolver.js","sourceRoot":"","sources":["../../src/resolvers/job.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,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AAE,CAAC,aAAa,CAAC;IAExB,WAAA,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC,CAAA;IAEvC,WAAA,IAAI,EAAE,CAAA;;;;gDAGR;AAQK;IADL,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAExC,WAAA,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;;;;4CAGhC;AASK;IADL,KAAK,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC;IAExB,WAAA,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC,CAAA;IAEvC,WAAA,IAAI,EAAE,CAAA;;;;6CAGR;AA9FU,WAAW;IAFvB,SAAS,CAAC,SAAS,CAAC;IACpB,QAAQ,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC;qCAEiB,UAAU;GADxC,WAAW,CA+FvB"}
@@ -0,0 +1,77 @@
1
+ import { EntityManager } from "@mikro-orm/core";
2
+ import { UserService, WorkspaceService } from "@nest-boot/auth";
3
+ import { type ConnectionArgsInterface, type ConnectionResult } from "@nest-boot/graphql-connection";
4
+ import { QueueManager } from "@nest-boot/queue";
5
+ import { type OnModuleDestroy, type OnModuleInit } from "@nestjs/common";
6
+ import type { GraphQLResolveInfo } from "graphql";
7
+ import { Job as JobEntity } from "../entities/job.entity.js";
8
+ import { JobQueue } from "../queues/job.queue.js";
9
+ /** Manages Job history queries and forwards Redis events to the persistence queue. */
10
+ export declare class JobService implements OnModuleInit, OnModuleDestroy {
11
+ private readonly em;
12
+ private readonly queue;
13
+ private readonly manager;
14
+ private readonly users;
15
+ private readonly workspaces;
16
+ private readonly logger;
17
+ private readonly sources;
18
+ private readonly pending;
19
+ private shutdown?;
20
+ constructor(em: EntityManager, queue: JobQueue, manager: QueueManager, users: UserService, workspaces: WorkspaceService);
21
+ /**
22
+ * Reads one task belonging to the current user.
23
+ * @param id - Database-generated Job UUID.
24
+ * @returns Matching record in the authorized scope, or null.
25
+ */
26
+ getUserJob(id: string): Promise<JobEntity | null>;
27
+ /**
28
+ * Paginates tasks belonging to the current user.
29
+ * @param args - Cursor pagination, filters and creation-time ordering.
30
+ * @param info - GraphQL selection used to shape the query.
31
+ * @returns Nodes and counts within the same authorized scope.
32
+ */
33
+ getUserJobConnection(args: ConnectionArgsInterface<JobEntity>, info?: GraphQLResolveInfo): Promise<ConnectionResult<JobEntity>>;
34
+ /**
35
+ * Reads one task in the authenticated, selected workspace.
36
+ * @param id - Database-generated Job UUID.
37
+ * @returns Matching record in the authorized scope, or null.
38
+ */
39
+ getWorkspaceJob(id: string): Promise<JobEntity | null>;
40
+ /**
41
+ * Paginates tasks in the authenticated, selected workspace.
42
+ * @param args - Cursor pagination, filters and creation-time ordering.
43
+ * @param info - GraphQL selection used to shape the query.
44
+ * @returns Nodes and counts within the same authorized scope.
45
+ */
46
+ getWorkspaceJobConnection(args: ConnectionArgsInterface<JobEntity>, info?: GraphQLResolveInfo): Promise<ConnectionResult<JobEntity>>;
47
+ /**
48
+ * Reads an unowned task after checking the current administrator session.
49
+ * @param id - Database-generated Job UUID.
50
+ * @returns Matching record in the authorized scope, or null.
51
+ */
52
+ getSystemJob(id: string): Promise<JobEntity | null>;
53
+ /**
54
+ * Paginates unowned tasks after checking the current administrator session.
55
+ * @param args - Cursor pagination, filters and creation-time ordering.
56
+ * @param info - GraphQL selection used to shape the query.
57
+ * @returns Nodes and counts within the same authorized scope.
58
+ */
59
+ getSystemJobConnection(args: ConnectionArgsInterface<JobEntity>, info?: GraphQLResolveInfo): Promise<ConnectionResult<JobEntity>>;
60
+ private currentUser;
61
+ private userFilter;
62
+ private workspaceFilter;
63
+ private systemFilter;
64
+ private getScopedJob;
65
+ private getScopedJobConnection;
66
+ private visibleFilter;
67
+ /** Attaches history forwarding before QueueManager starts its event readers. */
68
+ onModuleInit(): Promise<void>;
69
+ private forward;
70
+ private closeReaders;
71
+ /**
72
+ * Drains source Workers, event forwarding, then the persistence Worker.
73
+ * @returns Shared completion of synchronization shutdown.
74
+ */
75
+ onModuleDestroy(): Promise<void>;
76
+ private close;
77
+ }