@nest-util/nest-crud 1.1.4 → 1.2.1

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 (38) hide show
  1. package/dist/index.d.ts +6 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +6 -0
  4. package/dist/lib/controllers/nest-crud.controller.d.ts +11 -0
  5. package/dist/lib/controllers/nest-crud.controller.d.ts.map +1 -1
  6. package/dist/lib/controllers/nest-crud.controller.js +113 -0
  7. package/dist/lib/dtos/request-modification.dto.d.ts +11 -0
  8. package/dist/lib/dtos/request-modification.dto.d.ts.map +1 -0
  9. package/dist/lib/dtos/request-modification.dto.js +57 -0
  10. package/dist/lib/dtos/status-change.dto.d.ts +5 -0
  11. package/dist/lib/dtos/status-change.dto.d.ts.map +1 -0
  12. package/dist/lib/dtos/status-change.dto.js +16 -0
  13. package/dist/lib/entities/approval-status.entity.d.ts +29 -0
  14. package/dist/lib/entities/approval-status.entity.d.ts.map +1 -0
  15. package/dist/lib/entities/approval-status.entity.js +72 -0
  16. package/dist/lib/entities/modification-request-history.entity.d.ts +20 -0
  17. package/dist/lib/entities/modification-request-history.entity.d.ts.map +1 -0
  18. package/dist/lib/entities/modification-request-history.entity.js +48 -0
  19. package/dist/lib/interfaces/approval-pipeline.interface.d.ts +90 -0
  20. package/dist/lib/interfaces/approval-pipeline.interface.d.ts.map +1 -0
  21. package/dist/lib/interfaces/approval-pipeline.interface.js +20 -0
  22. package/dist/lib/interfaces/crud.interface.d.ts +12 -1
  23. package/dist/lib/interfaces/crud.interface.d.ts.map +1 -1
  24. package/dist/lib/interfaces/status-pipeline.interface.d.ts +63 -0
  25. package/dist/lib/interfaces/status-pipeline.interface.d.ts.map +1 -0
  26. package/dist/lib/interfaces/status-pipeline.interface.js +2 -0
  27. package/dist/lib/nest-crud.module.d.ts.map +1 -1
  28. package/dist/lib/nest-crud.module.js +9 -1
  29. package/dist/lib/services/nest-crud.service.d.ts +44 -0
  30. package/dist/lib/services/nest-crud.service.d.ts.map +1 -1
  31. package/dist/lib/services/nest-crud.service.js +345 -1
  32. package/dist/lib/testing/crud-controller.test-suites.d.ts.map +1 -1
  33. package/dist/lib/testing/crud-controller.test-suites.js +15 -0
  34. package/dist/lib/testing/mock-repository.d.ts.map +1 -1
  35. package/dist/lib/testing/mock-repository.js +2 -0
  36. package/dist/lib/testing/testing.interface.d.ts +2 -1
  37. package/dist/lib/testing/testing.interface.d.ts.map +1 -1
  38. package/package.json +1 -1
package/dist/index.d.ts CHANGED
@@ -5,6 +5,8 @@ export * from './lib/dtos/filter.dto';
5
5
  export * from './lib/dtos/pagination.dto';
6
6
  export * from './lib/dtos/cursor-pagination.dto';
7
7
  export * from './lib/dtos/list-audit-logs.dto';
8
+ export * from './lib/dtos/status-change.dto';
9
+ export * from './lib/dtos/request-modification.dto';
8
10
  export * from './lib/decorators/response-message.decorator';
9
11
  export * from './lib/decorators/audit-log.decorator';
10
12
  export * from './lib/interceptors/response.interceptor';
@@ -13,10 +15,14 @@ export * from './lib/interfaces/crud.interface';
13
15
  export * from './lib/interfaces/cursor-strategy.interface';
14
16
  export * from './lib/interfaces/hooks.interface';
15
17
  export * from './lib/interfaces/find-mine.interface';
18
+ export * from './lib/interfaces/status-pipeline.interface';
19
+ export * from './lib/interfaces/approval-pipeline.interface';
16
20
  export * from './lib/interfaces/audit-log.interface';
17
21
  export * from './lib/helpers/exception-filter.helper';
18
22
  export * from './lib/helpers/cursor-pagination.helper';
19
23
  export * from './lib/entities/audit-log.entity';
24
+ export * from './lib/entities/approval-status.entity';
25
+ export * from './lib/entities/modification-request-history.entity';
20
26
  export * from './lib/services/audit-log.service';
21
27
  export * from './lib/events';
22
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,kCAAkC,CAAC;AACjD,cAAc,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ACnE,cAAc,kCAAkC,CAAC;AACjD,cAAc,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -8,6 +8,8 @@ tslib_1.__exportStar(require("./lib/dtos/filter.dto"), exports);
8
8
  tslib_1.__exportStar(require("./lib/dtos/pagination.dto"), exports);
9
9
  tslib_1.__exportStar(require("./lib/dtos/cursor-pagination.dto"), exports);
10
10
  tslib_1.__exportStar(require("./lib/dtos/list-audit-logs.dto"), exports);
11
+ tslib_1.__exportStar(require("./lib/dtos/status-change.dto"), exports);
12
+ tslib_1.__exportStar(require("./lib/dtos/request-modification.dto"), exports);
11
13
  tslib_1.__exportStar(require("./lib/decorators/response-message.decorator"), exports);
12
14
  tslib_1.__exportStar(require("./lib/decorators/audit-log.decorator"), exports);
13
15
  tslib_1.__exportStar(require("./lib/interceptors/response.interceptor"), exports);
@@ -16,9 +18,13 @@ tslib_1.__exportStar(require("./lib/interfaces/crud.interface"), exports);
16
18
  tslib_1.__exportStar(require("./lib/interfaces/cursor-strategy.interface"), exports);
17
19
  tslib_1.__exportStar(require("./lib/interfaces/hooks.interface"), exports);
18
20
  tslib_1.__exportStar(require("./lib/interfaces/find-mine.interface"), exports);
21
+ tslib_1.__exportStar(require("./lib/interfaces/status-pipeline.interface"), exports);
22
+ tslib_1.__exportStar(require("./lib/interfaces/approval-pipeline.interface"), exports);
19
23
  tslib_1.__exportStar(require("./lib/interfaces/audit-log.interface"), exports);
20
24
  tslib_1.__exportStar(require("./lib/helpers/exception-filter.helper"), exports);
21
25
  tslib_1.__exportStar(require("./lib/helpers/cursor-pagination.helper"), exports);
22
26
  tslib_1.__exportStar(require("./lib/entities/audit-log.entity"), exports);
27
+ tslib_1.__exportStar(require("./lib/entities/approval-status.entity"), exports);
28
+ tslib_1.__exportStar(require("./lib/entities/modification-request-history.entity"), exports);
23
29
  tslib_1.__exportStar(require("./lib/services/audit-log.service"), exports);
24
30
  tslib_1.__exportStar(require("./lib/events"), exports);
@@ -3,7 +3,9 @@ import { CrudEndpoint, CrudInterface } from '../interfaces/crud.interface';
3
3
  import { PaginationDto } from '../dtos/pagination.dto';
4
4
  import { FilterDto } from '../dtos/filter.dto';
5
5
  import { ListAuditLogsDto } from '../dtos/list-audit-logs.dto';
6
+ import { StatusChangeDto } from '../dtos/status-change.dto';
6
7
  import type { OwnershipUser } from '../interfaces/find-mine.interface';
8
+ import type { ApprovalHistoryView, ApprovalStatusView, RequestModificationPayload } from '../interfaces/approval-pipeline.interface';
7
9
  export declare const AUTH_PERMISSIONS_METADATA_KEY = "auth:permissions";
8
10
  export type CrudEndpointPermissions = string | readonly string[];
9
11
  export type CrudPermissionsMap = Partial<Record<CrudEndpoint, CrudEndpointPermissions>>;
@@ -20,8 +22,17 @@ export interface IBaseController<CD, UD, RD> {
20
22
  findOne(id: number, user?: OwnershipUser): Promise<RD>;
21
23
  create(dto: CD, user?: OwnershipUser): Promise<RD>;
22
24
  update(id: number, dto: UD, user?: OwnershipUser): Promise<RD>;
25
+ changeStatus?(id: number, dto: StatusChangeDto, user?: OwnershipUser): Promise<RD>;
23
26
  remove(id: number, user?: OwnershipUser): Promise<boolean>;
24
27
  findAuditLogs?(query: ListAuditLogsDto): Promise<unknown>;
28
+ getApproval?(id: number, user?: OwnershipUser): Promise<{
29
+ approval: ApprovalStatusView;
30
+ history: ApprovalHistoryView[];
31
+ }>;
32
+ approveApproval?(id: number, user?: OwnershipUser): Promise<ApprovalStatusView>;
33
+ rejectApproval?(id: number, user?: OwnershipUser): Promise<ApprovalStatusView>;
34
+ requestModification?(id: number, dto: RequestModificationPayload, user?: OwnershipUser): Promise<ApprovalStatusView>;
35
+ resubmitApproval?(id: number, user?: OwnershipUser): Promise<ApprovalStatusView>;
25
36
  }
26
37
  export declare function CreateNestedCrudController<CD, UD, RD>(createDto: Type<CD>, updateDto: Type<UD>, responseDto: Type<RD>, options?: CrudControllerFactoryOptions): Type<IBaseController<CD, UD, RD>>;
27
38
  //# sourceMappingURL=nest-crud.controller.d.ts.map
@@ -1 +1 @@
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C;IAE1D,WAAW,CAAC,CACV,EAAE,EAAE,MAAM,EACV,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC;QAAE,QAAQ,EAAE,kBAAkB,CAAC;QAAC,OAAO,EAAE,mBAAmB,EAAE,CAAA;KAAE,CAAC,CAAC;IAC7E,eAAe,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAChF,cAAc,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/E,mBAAmB,CAAC,CAClB,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,0BAA0B,EAC/B,IAAI,CAAC,EAAE,aAAa,GACnB,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/B,gBAAgB,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAClF;AAyDD,wBAAgB,0BAA0B,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EACnD,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,EACnB,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,EACnB,WAAW,EAAE,IAAI,CAAC,EAAE,CAAC,EACrB,OAAO,CAAC,EAAE,4BAA4B,GACrC,IAAI,CAAC,eAAe,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAiPnC"}
@@ -8,6 +8,8 @@ const swagger_1 = require("@nestjs/swagger");
8
8
  const response_message_decorator_1 = require("../decorators/response-message.decorator");
9
9
  const audit_log_decorator_1 = require("../decorators/audit-log.decorator");
10
10
  const list_audit_logs_dto_1 = require("../dtos/list-audit-logs.dto");
11
+ const status_change_dto_1 = require("../dtos/status-change.dto");
12
+ const request_modification_dto_1 = require("../dtos/request-modification.dto");
11
13
  const nest_auth_1 = require("@nest-util/nest-auth");
12
14
  exports.AUTH_PERMISSIONS_METADATA_KEY = 'auth:permissions';
13
15
  const toPermissionList = (permissionValue) => {
@@ -76,6 +78,48 @@ function CreateNestedCrudController(createDto, updateDto, responseDto, options)
76
78
  this.ensureEndpointEnabled('update');
77
79
  return this.service.update(id, dto, user);
78
80
  }
81
+ changeStatus(id, dto, user) {
82
+ this.ensureEndpointEnabled('changeStatus');
83
+ if (!this.service.changeStatus) {
84
+ throw new common_1.NotFoundException('Resource not found');
85
+ }
86
+ return this.service.changeStatus(id, dto.status, user);
87
+ }
88
+ getApproval(id, user) {
89
+ this.ensureEndpointEnabled('getApproval');
90
+ if (!this.service.getApproval) {
91
+ throw new common_1.NotFoundException('Resource not found');
92
+ }
93
+ return this.service.getApproval(id, user);
94
+ }
95
+ approveApproval(id, user) {
96
+ this.ensureEndpointEnabled('approveApproval');
97
+ if (!this.service.approveApproval) {
98
+ throw new common_1.NotFoundException('Resource not found');
99
+ }
100
+ return this.service.approveApproval(id, user);
101
+ }
102
+ rejectApproval(id, user) {
103
+ this.ensureEndpointEnabled('rejectApproval');
104
+ if (!this.service.rejectApproval) {
105
+ throw new common_1.NotFoundException('Resource not found');
106
+ }
107
+ return this.service.rejectApproval(id, user);
108
+ }
109
+ requestModification(id, dto, user) {
110
+ this.ensureEndpointEnabled('requestModification');
111
+ if (!this.service.requestModification) {
112
+ throw new common_1.NotFoundException('Resource not found');
113
+ }
114
+ return this.service.requestModification(id, dto, user);
115
+ }
116
+ resubmitApproval(id, user) {
117
+ this.ensureEndpointEnabled('resubmitApproval');
118
+ if (!this.service.resubmitApproval) {
119
+ throw new common_1.NotFoundException('Resource not found');
120
+ }
121
+ return this.service.resubmitApproval(id, user);
122
+ }
79
123
  remove(id, user) {
80
124
  this.ensureEndpointEnabled('remove');
81
125
  return this.service.remove(id, user);
@@ -166,6 +210,75 @@ function CreateNestedCrudController(createDto, updateDto, responseDto, options)
166
210
  tslib_1.__metadata("design:paramtypes", [Number, Object, Object]),
167
211
  tslib_1.__metadata("design:returntype", void 0)
168
212
  ], BaseController.prototype, "update", null);
213
+ tslib_1.__decorate([
214
+ (0, common_1.Post)(':id/status'),
215
+ (0, response_message_decorator_1.Message)('updated'),
216
+ (0, audit_log_decorator_1.Audit)({ action: 'UPDATE' }),
217
+ (0, swagger_1.ApiBody)({ type: status_change_dto_1.StatusChangeDto }),
218
+ (0, swagger_1.ApiResponse)({ type: responseDto }),
219
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
220
+ tslib_1.__param(1, (0, common_1.Body)()),
221
+ tslib_1.__param(2, (0, nest_auth_1.CurrentUser)()),
222
+ tslib_1.__metadata("design:type", Function),
223
+ tslib_1.__metadata("design:paramtypes", [Number, status_change_dto_1.StatusChangeDto, Object]),
224
+ tslib_1.__metadata("design:returntype", void 0)
225
+ ], BaseController.prototype, "changeStatus", null);
226
+ tslib_1.__decorate([
227
+ (0, common_1.Get)(':id/approval'),
228
+ (0, response_message_decorator_1.Message)('fetched approval'),
229
+ (0, swagger_1.ApiResponse)({ description: 'Approval status and modification history' }),
230
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
231
+ tslib_1.__param(1, (0, nest_auth_1.CurrentUser)()),
232
+ tslib_1.__metadata("design:type", Function),
233
+ tslib_1.__metadata("design:paramtypes", [Number, Object]),
234
+ tslib_1.__metadata("design:returntype", void 0)
235
+ ], BaseController.prototype, "getApproval", null);
236
+ tslib_1.__decorate([
237
+ (0, common_1.Post)(':id/approval/approve'),
238
+ (0, response_message_decorator_1.Message)('approved'),
239
+ (0, audit_log_decorator_1.Audit)({ action: 'APPROVE' }),
240
+ (0, swagger_1.ApiResponse)({ description: 'The updated approval status' }),
241
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
242
+ tslib_1.__param(1, (0, nest_auth_1.CurrentUser)()),
243
+ tslib_1.__metadata("design:type", Function),
244
+ tslib_1.__metadata("design:paramtypes", [Number, Object]),
245
+ tslib_1.__metadata("design:returntype", void 0)
246
+ ], BaseController.prototype, "approveApproval", null);
247
+ tslib_1.__decorate([
248
+ (0, common_1.Post)(':id/approval/reject'),
249
+ (0, response_message_decorator_1.Message)('rejected'),
250
+ (0, audit_log_decorator_1.Audit)({ action: 'REJECT' }),
251
+ (0, swagger_1.ApiResponse)({ description: 'The updated approval status' }),
252
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
253
+ tslib_1.__param(1, (0, nest_auth_1.CurrentUser)()),
254
+ tslib_1.__metadata("design:type", Function),
255
+ tslib_1.__metadata("design:paramtypes", [Number, Object]),
256
+ tslib_1.__metadata("design:returntype", void 0)
257
+ ], BaseController.prototype, "rejectApproval", null);
258
+ tslib_1.__decorate([
259
+ (0, common_1.Post)(':id/approval/request-modification'),
260
+ (0, response_message_decorator_1.Message)('modification requested'),
261
+ (0, audit_log_decorator_1.Audit)({ action: 'REQUEST_MODIFICATION' }),
262
+ (0, swagger_1.ApiBody)({ type: request_modification_dto_1.RequestModificationDto }),
263
+ (0, swagger_1.ApiResponse)({ description: 'The updated approval status' }),
264
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
265
+ tslib_1.__param(1, (0, common_1.Body)()),
266
+ tslib_1.__param(2, (0, nest_auth_1.CurrentUser)()),
267
+ tslib_1.__metadata("design:type", Function),
268
+ tslib_1.__metadata("design:paramtypes", [Number, request_modification_dto_1.RequestModificationDto, Object]),
269
+ tslib_1.__metadata("design:returntype", void 0)
270
+ ], BaseController.prototype, "requestModification", null);
271
+ tslib_1.__decorate([
272
+ (0, common_1.Post)(':id/approval/resubmit'),
273
+ (0, response_message_decorator_1.Message)('resubmitted'),
274
+ (0, audit_log_decorator_1.Audit)({ action: 'RESUBMIT' }),
275
+ (0, swagger_1.ApiResponse)({ description: 'The updated approval status' }),
276
+ tslib_1.__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
277
+ tslib_1.__param(1, (0, nest_auth_1.CurrentUser)()),
278
+ tslib_1.__metadata("design:type", Function),
279
+ tslib_1.__metadata("design:paramtypes", [Number, Object]),
280
+ tslib_1.__metadata("design:returntype", void 0)
281
+ ], BaseController.prototype, "resubmitApproval", null);
169
282
  tslib_1.__decorate([
170
283
  (0, common_1.Delete)(':id'),
171
284
  (0, response_message_decorator_1.Message)('deleted'),
@@ -0,0 +1,11 @@
1
+ export declare class ModificationItemDto {
2
+ field: string;
3
+ currentValue?: unknown;
4
+ wantedValue: unknown;
5
+ note?: string;
6
+ }
7
+ export declare class RequestModificationDto {
8
+ modifications: ModificationItemDto[];
9
+ note?: string;
10
+ }
11
+ //# sourceMappingURL=request-modification.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-modification.dto.d.ts","sourceRoot":"","sources":["../../../src/lib/dtos/request-modification.dto.ts"],"names":[],"mappings":"AAWA,qBAAa,mBAAmB;IAG9B,KAAK,EAAG,MAAM,CAAC;IAOf,YAAY,CAAC,EAAE,OAAO,CAAC;IAIvB,WAAW,EAAG,OAAO,CAAC;IAKtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,sBAAsB;IASjC,aAAa,EAAG,mBAAmB,EAAE,CAAC;IAQtC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RequestModificationDto = exports.ModificationItemDto = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const swagger_1 = require("@nestjs/swagger");
6
+ const class_validator_1 = require("class-validator");
7
+ const class_transformer_1 = require("class-transformer");
8
+ class ModificationItemDto {
9
+ }
10
+ exports.ModificationItemDto = ModificationItemDto;
11
+ tslib_1.__decorate([
12
+ (0, swagger_1.ApiProperty)({ description: 'Entity field to modify, e.g. "title"' }),
13
+ (0, class_validator_1.IsString)(),
14
+ tslib_1.__metadata("design:type", String)
15
+ ], ModificationItemDto.prototype, "field", void 0);
16
+ tslib_1.__decorate([
17
+ (0, swagger_1.ApiProperty)({
18
+ description: 'Value currently stored on the record (captured at request time)',
19
+ required: false,
20
+ }),
21
+ (0, class_validator_1.IsOptional)(),
22
+ tslib_1.__metadata("design:type", Object)
23
+ ], ModificationItemDto.prototype, "currentValue", void 0);
24
+ tslib_1.__decorate([
25
+ (0, swagger_1.ApiProperty)({ description: 'Value the reviewer wants instead' }),
26
+ (0, class_validator_1.IsDefined)(),
27
+ tslib_1.__metadata("design:type", Object)
28
+ ], ModificationItemDto.prototype, "wantedValue", void 0);
29
+ tslib_1.__decorate([
30
+ (0, swagger_1.ApiProperty)({ description: 'Optional explanation', required: false }),
31
+ (0, class_validator_1.IsOptional)(),
32
+ (0, class_validator_1.IsString)(),
33
+ tslib_1.__metadata("design:type", String)
34
+ ], ModificationItemDto.prototype, "note", void 0);
35
+ class RequestModificationDto {
36
+ }
37
+ exports.RequestModificationDto = RequestModificationDto;
38
+ tslib_1.__decorate([
39
+ (0, swagger_1.ApiProperty)({
40
+ description: 'List of requested modifications',
41
+ type: [ModificationItemDto],
42
+ }),
43
+ (0, class_validator_1.IsArray)(),
44
+ (0, class_validator_1.ArrayMinSize)(1),
45
+ (0, class_validator_1.ValidateNested)({ each: true }),
46
+ (0, class_transformer_1.Type)(() => ModificationItemDto),
47
+ tslib_1.__metadata("design:type", Array)
48
+ ], RequestModificationDto.prototype, "modifications", void 0);
49
+ tslib_1.__decorate([
50
+ (0, swagger_1.ApiProperty)({
51
+ description: 'Optional overall note explaining the requested changes',
52
+ required: false,
53
+ }),
54
+ (0, class_validator_1.IsOptional)(),
55
+ (0, class_validator_1.IsString)(),
56
+ tslib_1.__metadata("design:type", String)
57
+ ], RequestModificationDto.prototype, "note", void 0);
@@ -0,0 +1,5 @@
1
+ import type { StatusValue } from '../interfaces/status-pipeline.interface';
2
+ export declare class StatusChangeDto {
3
+ status: StatusValue;
4
+ }
5
+ //# sourceMappingURL=status-change.dto.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status-change.dto.d.ts","sourceRoot":"","sources":["../../../src/lib/dtos/status-change.dto.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAE3E,qBAAa,eAAe;IAK1B,MAAM,EAAG,WAAW,CAAC;CACtB"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StatusChangeDto = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const class_validator_1 = require("class-validator");
6
+ const swagger_1 = require("@nestjs/swagger");
7
+ class StatusChangeDto {
8
+ }
9
+ exports.StatusChangeDto = StatusChangeDto;
10
+ tslib_1.__decorate([
11
+ (0, swagger_1.ApiProperty)({
12
+ description: 'The status value to transition to',
13
+ }),
14
+ (0, class_validator_1.IsDefined)(),
15
+ tslib_1.__metadata("design:type", Object)
16
+ ], StatusChangeDto.prototype, "status", void 0);
@@ -0,0 +1,29 @@
1
+ import type { ModificationItem } from '../interfaces/approval-pipeline.interface';
2
+ /**
3
+ * Tracks the approval lifecycle of a created record. One row per approved-or-
4
+ * pending entity, polymorphically referencing the target row via the table
5
+ * name (`entity`) and its primary key (`entityId`).
6
+ */
7
+ export declare class ApprovalStatusEntity {
8
+ id: number;
9
+ /** Target table name, e.g. 'posts'. */
10
+ entity: string;
11
+ /** Stringified primary key of the target row (works for int and uuid). */
12
+ entityId: string;
13
+ /** pending | approved | rejected | modification_requested | resubmitted */
14
+ status: string;
15
+ /** User who submitted the record for approval. */
16
+ requestedBy?: string | null;
17
+ requestedAt: Date;
18
+ /** Active list of requested modifications: { field, wantedValue, ... }. */
19
+ currentModifications?: ModificationItem[] | null;
20
+ /** User who approved or rejected the record. */
21
+ decidedBy?: string | null;
22
+ decidedAt?: Date | null;
23
+ /** User who resubmitted the record after modifications. */
24
+ resubmittedBy?: string | null;
25
+ resubmittedAt?: Date | null;
26
+ createdAt: Date;
27
+ updatedAt: Date;
28
+ }
29
+ //# sourceMappingURL=approval-status.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-status.entity.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/approval-status.entity.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAElF;;;;GAIG;AACH,qBACa,oBAAoB;IAE/B,EAAE,EAAG,MAAM,CAAC;IAEZ,uCAAuC;IAGvC,MAAM,EAAG,MAAM,CAAC;IAEhB,0EAA0E;IAG1E,QAAQ,EAAG,MAAM,CAAC;IAElB,2EAA2E;IAG3E,MAAM,EAAG,MAAM,CAAC;IAEhB,kDAAkD;IAGlD,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG5B,WAAW,EAAG,IAAI,CAAC;IAEnB,2EAA2E;IAE3E,oBAAoB,CAAC,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAAC;IAEjD,gDAAgD;IAEhD,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG1B,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAExB,2DAA2D;IAE3D,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAG9B,aAAa,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IAG5B,SAAS,EAAG,IAAI,CAAC;IAGjB,SAAS,EAAG,IAAI,CAAC;CAClB"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApprovalStatusEntity = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const typeorm_1 = require("typeorm");
6
+ /**
7
+ * Tracks the approval lifecycle of a created record. One row per approved-or-
8
+ * pending entity, polymorphically referencing the target row via the table
9
+ * name (`entity`) and its primary key (`entityId`).
10
+ */
11
+ let ApprovalStatusEntity = class ApprovalStatusEntity {
12
+ };
13
+ exports.ApprovalStatusEntity = ApprovalStatusEntity;
14
+ tslib_1.__decorate([
15
+ (0, typeorm_1.PrimaryGeneratedColumn)(),
16
+ tslib_1.__metadata("design:type", Number)
17
+ ], ApprovalStatusEntity.prototype, "id", void 0);
18
+ tslib_1.__decorate([
19
+ (0, typeorm_1.Index)(),
20
+ (0, typeorm_1.Column)(),
21
+ tslib_1.__metadata("design:type", String)
22
+ ], ApprovalStatusEntity.prototype, "entity", void 0);
23
+ tslib_1.__decorate([
24
+ (0, typeorm_1.Index)(),
25
+ (0, typeorm_1.Column)(),
26
+ tslib_1.__metadata("design:type", String)
27
+ ], ApprovalStatusEntity.prototype, "entityId", void 0);
28
+ tslib_1.__decorate([
29
+ (0, typeorm_1.Index)(),
30
+ (0, typeorm_1.Column)({ default: 'pending' }),
31
+ tslib_1.__metadata("design:type", String)
32
+ ], ApprovalStatusEntity.prototype, "status", void 0);
33
+ tslib_1.__decorate([
34
+ (0, typeorm_1.Index)(),
35
+ (0, typeorm_1.Column)({ nullable: true }),
36
+ tslib_1.__metadata("design:type", Object)
37
+ ], ApprovalStatusEntity.prototype, "requestedBy", void 0);
38
+ tslib_1.__decorate([
39
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
40
+ tslib_1.__metadata("design:type", Date)
41
+ ], ApprovalStatusEntity.prototype, "requestedAt", void 0);
42
+ tslib_1.__decorate([
43
+ (0, typeorm_1.Column)({ type: 'jsonb', nullable: true }),
44
+ tslib_1.__metadata("design:type", Object)
45
+ ], ApprovalStatusEntity.prototype, "currentModifications", void 0);
46
+ tslib_1.__decorate([
47
+ (0, typeorm_1.Column)({ nullable: true }),
48
+ tslib_1.__metadata("design:type", Object)
49
+ ], ApprovalStatusEntity.prototype, "decidedBy", void 0);
50
+ tslib_1.__decorate([
51
+ (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
52
+ tslib_1.__metadata("design:type", Object)
53
+ ], ApprovalStatusEntity.prototype, "decidedAt", void 0);
54
+ tslib_1.__decorate([
55
+ (0, typeorm_1.Column)({ nullable: true }),
56
+ tslib_1.__metadata("design:type", Object)
57
+ ], ApprovalStatusEntity.prototype, "resubmittedBy", void 0);
58
+ tslib_1.__decorate([
59
+ (0, typeorm_1.Column)({ type: 'timestamptz', nullable: true }),
60
+ tslib_1.__metadata("design:type", Object)
61
+ ], ApprovalStatusEntity.prototype, "resubmittedAt", void 0);
62
+ tslib_1.__decorate([
63
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
64
+ tslib_1.__metadata("design:type", Date)
65
+ ], ApprovalStatusEntity.prototype, "createdAt", void 0);
66
+ tslib_1.__decorate([
67
+ (0, typeorm_1.UpdateDateColumn)({ type: 'timestamptz' }),
68
+ tslib_1.__metadata("design:type", Date)
69
+ ], ApprovalStatusEntity.prototype, "updatedAt", void 0);
70
+ exports.ApprovalStatusEntity = ApprovalStatusEntity = tslib_1.__decorate([
71
+ (0, typeorm_1.Entity)('approval_statuses')
72
+ ], ApprovalStatusEntity);
@@ -0,0 +1,20 @@
1
+ import type { ModificationItem } from '../interfaces/approval-pipeline.interface';
2
+ import { ApprovalStatusEntity } from './approval-status.entity';
3
+ /**
4
+ * Immutable record of every modification request ever made against an
5
+ * approval status. A new row is appended each time modifications are
6
+ * requested.
7
+ */
8
+ export declare class ModificationRequestHistoryEntity {
9
+ id: number;
10
+ approvalStatus: ApprovalStatusEntity;
11
+ approvalStatusId: number;
12
+ /** The requested modifications: { field, wantedValue, ... }. */
13
+ modifications: ModificationItem[];
14
+ /** User who requested the modifications. */
15
+ requestedBy?: string | null;
16
+ /** Optional overall note explaining the requested changes. */
17
+ note?: string | null;
18
+ requestedAt: Date;
19
+ }
20
+ //# sourceMappingURL=modification-request-history.entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modification-request-history.entity.d.ts","sourceRoot":"","sources":["../../../src/lib/entities/modification-request-history.entity.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;GAIG;AACH,qBACa,gCAAgC;IAE3C,EAAE,EAAG,MAAM,CAAC;IAKZ,cAAc,EAAG,oBAAoB,CAAC;IAGtC,gBAAgB,EAAG,MAAM,CAAC;IAE1B,gEAAgE;IAEhE,aAAa,EAAG,gBAAgB,EAAE,CAAC;IAEnC,4CAA4C;IAG5C,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,8DAA8D;IAE9D,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAGrB,WAAW,EAAG,IAAI,CAAC;CACpB"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModificationRequestHistoryEntity = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const typeorm_1 = require("typeorm");
6
+ const approval_status_entity_1 = require("./approval-status.entity");
7
+ /**
8
+ * Immutable record of every modification request ever made against an
9
+ * approval status. A new row is appended each time modifications are
10
+ * requested.
11
+ */
12
+ let ModificationRequestHistoryEntity = class ModificationRequestHistoryEntity {
13
+ };
14
+ exports.ModificationRequestHistoryEntity = ModificationRequestHistoryEntity;
15
+ tslib_1.__decorate([
16
+ (0, typeorm_1.PrimaryGeneratedColumn)(),
17
+ tslib_1.__metadata("design:type", Number)
18
+ ], ModificationRequestHistoryEntity.prototype, "id", void 0);
19
+ tslib_1.__decorate([
20
+ (0, typeorm_1.Index)(),
21
+ (0, typeorm_1.ManyToOne)(() => approval_status_entity_1.ApprovalStatusEntity, { onDelete: 'CASCADE' }),
22
+ (0, typeorm_1.JoinColumn)({ name: 'approvalStatusId' }),
23
+ tslib_1.__metadata("design:type", approval_status_entity_1.ApprovalStatusEntity)
24
+ ], ModificationRequestHistoryEntity.prototype, "approvalStatus", void 0);
25
+ tslib_1.__decorate([
26
+ (0, typeorm_1.Column)({ name: 'approvalStatusId' }),
27
+ tslib_1.__metadata("design:type", Number)
28
+ ], ModificationRequestHistoryEntity.prototype, "approvalStatusId", void 0);
29
+ tslib_1.__decorate([
30
+ (0, typeorm_1.Column)({ type: 'jsonb' }),
31
+ tslib_1.__metadata("design:type", Array)
32
+ ], ModificationRequestHistoryEntity.prototype, "modifications", void 0);
33
+ tslib_1.__decorate([
34
+ (0, typeorm_1.Index)(),
35
+ (0, typeorm_1.Column)({ nullable: true }),
36
+ tslib_1.__metadata("design:type", Object)
37
+ ], ModificationRequestHistoryEntity.prototype, "requestedBy", void 0);
38
+ tslib_1.__decorate([
39
+ (0, typeorm_1.Column)({ nullable: true }),
40
+ tslib_1.__metadata("design:type", Object)
41
+ ], ModificationRequestHistoryEntity.prototype, "note", void 0);
42
+ tslib_1.__decorate([
43
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
44
+ tslib_1.__metadata("design:type", Date)
45
+ ], ModificationRequestHistoryEntity.prototype, "requestedAt", void 0);
46
+ exports.ModificationRequestHistoryEntity = ModificationRequestHistoryEntity = tslib_1.__decorate([
47
+ (0, typeorm_1.Entity)('approval_modification_history')
48
+ ], ModificationRequestHistoryEntity);
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Lifecycle of an approval status row.
3
+ *
4
+ * pending ──────────> approved
5
+ * │ └───────────> rejected
6
+ * └─> modification_requested ──> resubmitted ──> approved / rejected
7
+ * │ │
8
+ * └────────────────────────────────────┘
9
+ * (modifications may be requested again)
10
+ */
11
+ export declare const APPROVAL_STATUS: {
12
+ readonly pending: "pending";
13
+ readonly approved: "approved";
14
+ readonly rejected: "rejected";
15
+ readonly modificationRequested: "modification_requested";
16
+ readonly resubmitted: "resubmitted";
17
+ };
18
+ export type ApprovalStatus = (typeof APPROVAL_STATUS)[keyof typeof APPROVAL_STATUS];
19
+ /**
20
+ * A single requested modification on a pending record. Each item names the
21
+ * field to change and the value the reviewer wants instead.
22
+ */
23
+ export interface ModificationItem {
24
+ /** Entity field to modify, e.g. 'title'. */
25
+ field: string;
26
+ /** Value currently stored on the record (captured at request time). */
27
+ currentValue?: unknown;
28
+ /** Value the reviewer wants instead. */
29
+ wantedValue: unknown;
30
+ /** Optional human-readable explanation. */
31
+ note?: string;
32
+ }
33
+ export interface ApprovalStatusView {
34
+ id: number;
35
+ entity: string;
36
+ entityId: string;
37
+ status: ApprovalStatus;
38
+ requestedBy?: string | null;
39
+ requestedAt: Date;
40
+ currentModifications?: ModificationItem[] | null;
41
+ decidedBy?: string | null;
42
+ decidedAt?: Date | null;
43
+ resubmittedBy?: string | null;
44
+ resubmittedAt?: Date | null;
45
+ createdAt: Date;
46
+ updatedAt: Date;
47
+ }
48
+ export interface ApprovalHistoryView {
49
+ id: number;
50
+ approvalStatusId: number;
51
+ modifications: ModificationItem[];
52
+ requestedBy?: string | null;
53
+ requestedAt: Date;
54
+ note?: string | null;
55
+ }
56
+ export interface ApprovalPipelinePermissions {
57
+ /** Required permission to approve (pending/resubmitted -> approved). */
58
+ approve?: string;
59
+ /** Required permission to reject (pending/resubmitted -> rejected). */
60
+ reject?: string;
61
+ /** Required permission to request modifications. */
62
+ requestModification?: string;
63
+ /** Required permission to resubmit after modifications. */
64
+ resubmit?: string;
65
+ }
66
+ export interface ApprovalPipelineConfig {
67
+ /**
68
+ * When true, every created record also gets a pending approval status row
69
+ * (created in the same transaction). Defaults to true when the option is
70
+ * provided.
71
+ */
72
+ enabled?: boolean;
73
+ /**
74
+ * Optional permission strings required to perform each action. When unset,
75
+ * the action is allowed for any authenticated (or anonymous) caller.
76
+ */
77
+ permissions?: ApprovalPipelinePermissions;
78
+ /**
79
+ * When set, read endpoints (findAll / findOne / findMine /
80
+ * findAllWithCursor) only return records whose approval status is in this
81
+ * list, e.g. ['approved']. When unset, all records are visible regardless
82
+ * of approval state.
83
+ */
84
+ visibleStatuses?: readonly ApprovalStatus[];
85
+ }
86
+ export interface RequestModificationPayload {
87
+ modifications: ModificationItem[];
88
+ note?: string;
89
+ }
90
+ //# sourceMappingURL=approval-pipeline.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-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AAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,2BAA2B;IAC1C,wEAAwE;IACxE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,oDAAoD;IACpD,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;OAGG;IACH,WAAW,CAAC,EAAE,2BAA2B,CAAC;IAE1C;;;;;OAKG;IACH,eAAe,CAAC,EAAE,SAAS,cAAc,EAAE,CAAC;CAC7C;AAED,MAAM,WAAW,0BAA0B;IACzC,aAAa,EAAE,gBAAgB,EAAE,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.APPROVAL_STATUS = void 0;
4
+ /**
5
+ * Lifecycle of an approval status row.
6
+ *
7
+ * pending ──────────> approved
8
+ * │ └───────────> rejected
9
+ * └─> modification_requested ──> resubmitted ──> approved / rejected
10
+ * │ │
11
+ * └────────────────────────────────────┘
12
+ * (modifications may be requested again)
13
+ */
14
+ exports.APPROVAL_STATUS = {
15
+ pending: 'pending',
16
+ approved: 'approved',
17
+ rejected: 'rejected',
18
+ modificationRequested: 'modification_requested',
19
+ resubmitted: 'resubmitted',
20
+ };