itlab-internal-services 2.16.12 → 2.16.13

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 (126) hide show
  1. package/dist/classes/document/content-document.class.d.ts +2 -2
  2. package/dist/classes/fetch-options/content-options.class.d.ts +2 -2
  3. package/dist/hub-resource.enum.d.ts +0 -23
  4. package/dist/hub-resource.enum.js +1 -25
  5. package/dist/index.d.ts +0 -6
  6. package/dist/index.js +0 -10
  7. package/dist/modules/comments/comments.controller.d.ts +3 -3
  8. package/dist/modules/comments/comments.controller.js +1 -1
  9. package/dist/modules/comments/comments.service.d.ts +3 -3
  10. package/dist/modules/comments/comments.service.js +1 -1
  11. package/dist/modules/services/providers/books/books.service.d.ts +5 -5
  12. package/dist/modules/services/providers/books/books.service.js +2 -2
  13. package/dist/modules/services/providers/changelog/changelog.service.d.ts +1 -14
  14. package/dist/modules/services/providers/conflicts/conflicts.service.d.ts +5 -15
  15. package/dist/modules/services/providers/conflicts/conflicts.service.js +2 -2
  16. package/dist/modules/services/providers/content/content-return-types.d.ts +5 -5
  17. package/dist/modules/services/providers/content/content.service.d.ts +7 -6
  18. package/dist/modules/services/providers/demo-hive/demo-hive.service.d.ts +5 -5
  19. package/dist/modules/services/providers/demo-hive/demo-hive.service.js +2 -2
  20. package/dist/modules/services/providers/events/events.service.d.ts +5 -5
  21. package/dist/modules/services/providers/events/events.service.js +2 -2
  22. package/dist/modules/services/providers/files/files.service.d.ts +9 -30
  23. package/dist/modules/services/providers/files/files.service.js +4 -4
  24. package/dist/modules/services/providers/mail/dtos/newsletter-issue-mail.dto.v1.d.ts +2 -2
  25. package/dist/modules/services/providers/newsletter/newsletter.service.d.ts +5 -5
  26. package/dist/modules/services/providers/newsletter/newsletter.service.js +2 -2
  27. package/dist/modules/services/providers/newsroom/newsroom.service.d.ts +5 -5
  28. package/dist/modules/services/providers/newsroom/newsroom.service.js +2 -2
  29. package/dist/modules/services/providers/notifications/notifications.service.d.ts +5 -18
  30. package/dist/modules/services/providers/notifications/notifications.service.js +5 -3
  31. package/dist/modules/services/providers/podcasts/podcasts.service.d.ts +5 -5
  32. package/dist/modules/services/providers/podcasts/podcasts.service.js +2 -2
  33. package/dist/modules/services/providers/quick-links/quick-links.service.d.ts +5 -17
  34. package/dist/modules/services/providers/quick-links/quick-links.service.js +2 -2
  35. package/dist/pipes/restricted-fields.pipe.js +3 -1
  36. package/package.json +23 -23
  37. package/dist/classes/document-updater.class.d.ts +0 -40
  38. package/dist/classes/document-updater.class.js +0 -58
  39. package/dist/factories/index.d.ts +0 -1
  40. package/dist/factories/index.js +0 -5
  41. package/dist/factories/virtuals.factory.d.ts +0 -80
  42. package/dist/factories/virtuals.factory.js +0 -172
  43. package/dist/functions/create-duplicate-checker.function.d.ts +0 -29
  44. package/dist/functions/create-duplicate-checker.function.js +0 -52
  45. package/dist/likeable.interface.d.ts +0 -42
  46. package/dist/likeable.interface.js +0 -48
  47. package/dist/modules/_old/comment/comment.controller.d.ts +0 -35
  48. package/dist/modules/_old/comment/comment.controller.js +0 -86
  49. package/dist/modules/_old/comment/comment.model.d.ts +0 -29
  50. package/dist/modules/_old/comment/comment.model.js +0 -43
  51. package/dist/modules/_old/comment/comment.module-definition.d.ts +0 -45
  52. package/dist/modules/_old/comment/comment.module-definition.js +0 -8
  53. package/dist/modules/_old/comment/comment.module.d.ts +0 -22
  54. package/dist/modules/_old/comment/comment.module.js +0 -71
  55. package/dist/modules/_old/comment/comment.service.d.ts +0 -54
  56. package/dist/modules/_old/comment/comment.service.js +0 -133
  57. package/dist/modules/_old/comment/index.d.ts +0 -3
  58. package/dist/modules/_old/comment/index.js +0 -9
  59. package/dist/modules/_old/content/content.module-definition.d.ts +0 -5
  60. package/dist/modules/_old/content/content.module-definition.js +0 -8
  61. package/dist/modules/_old/content/content.module.d.ts +0 -31
  62. package/dist/modules/_old/content/content.module.js +0 -60
  63. package/dist/modules/_old/content/content.service.d.ts +0 -50
  64. package/dist/modules/_old/content/content.service.js +0 -145
  65. package/dist/modules/_old/content/index.d.ts +0 -2
  66. package/dist/modules/_old/content/index.js +0 -7
  67. package/dist/modules/_old/database/database-module-options.interface.d.ts +0 -41
  68. package/dist/modules/_old/database/database-module-options.interface.js +0 -2
  69. package/dist/modules/_old/database/database.liveness-controller.d.ts +0 -27
  70. package/dist/modules/_old/database/database.liveness-controller.js +0 -80
  71. package/dist/modules/_old/database/database.module.d.ts +0 -41
  72. package/dist/modules/_old/database/database.module.js +0 -97
  73. package/dist/modules/_old/database/index.d.ts +0 -6
  74. package/dist/modules/_old/database/index.js +0 -13
  75. package/dist/modules/_old/database/lock-service/lock.schema.d.ts +0 -38
  76. package/dist/modules/_old/database/lock-service/lock.schema.js +0 -51
  77. package/dist/modules/_old/database/lock-service/lock.service.d.ts +0 -53
  78. package/dist/modules/_old/database/lock-service/lock.service.js +0 -103
  79. package/dist/modules/_old/database/model-service/dbs/hub-account.db.d.ts +0 -28
  80. package/dist/modules/_old/database/model-service/dbs/hub-account.db.js +0 -44
  81. package/dist/modules/_old/database/model-service/dbs/hub-books.db.d.ts +0 -23
  82. package/dist/modules/_old/database/model-service/dbs/hub-books.db.js +0 -45
  83. package/dist/modules/_old/database/model-service/dbs/hub-comments.db.d.ts +0 -29
  84. package/dist/modules/_old/database/model-service/dbs/hub-comments.db.js +0 -68
  85. package/dist/modules/_old/database/model-service/dbs/hub-content.db.d.ts +0 -24
  86. package/dist/modules/_old/database/model-service/dbs/hub-content.db.js +0 -49
  87. package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.d.ts +0 -23
  88. package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.js +0 -45
  89. package/dist/modules/_old/database/model-service/dbs/hub-events.db.d.ts +0 -24
  90. package/dist/modules/_old/database/model-service/dbs/hub-events.db.js +0 -49
  91. package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.d.ts +0 -60
  92. package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.js +0 -106
  93. package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.d.ts +0 -25
  94. package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.js +0 -53
  95. package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.d.ts +0 -23
  96. package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.js +0 -45
  97. package/dist/modules/_old/database/model-service/dbs/hub-team.db.d.ts +0 -22
  98. package/dist/modules/_old/database/model-service/dbs/hub-team.db.js +0 -41
  99. package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.d.ts +0 -42
  100. package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.js +0 -81
  101. package/dist/modules/_old/database/model-service/model.service.d.ts +0 -8465
  102. package/dist/modules/_old/database/model-service/model.service.js +0 -136
  103. package/dist/modules/_old/database/populate-service/populate.service.d.ts +0 -73
  104. package/dist/modules/_old/database/populate-service/populate.service.js +0 -163
  105. package/dist/modules/_old/database/service-mapper-service/service-mapper.service.d.ts +0 -32
  106. package/dist/modules/_old/database/service-mapper-service/service-mapper.service.js +0 -73
  107. package/dist/modules/_old/fetch/fetch.module.d.ts +0 -31
  108. package/dist/modules/_old/fetch/fetch.module.js +0 -60
  109. package/dist/modules/_old/fetch/fetch.service.d.ts +0 -153
  110. package/dist/modules/_old/fetch/fetch.service.js +0 -274
  111. package/dist/modules/_old/fetch/index.d.ts +0 -2
  112. package/dist/modules/_old/fetch/index.js +0 -7
  113. package/dist/modules/_old/index.d.ts +0 -5
  114. package/dist/modules/_old/index.js +0 -21
  115. package/dist/modules/_old/like/index.d.ts +0 -1
  116. package/dist/modules/_old/like/index.js +0 -5
  117. package/dist/modules/_old/like/like.controller.d.ts +0 -41
  118. package/dist/modules/_old/like/like.controller.js +0 -125
  119. package/dist/modules/_old/like/like.module-definition.d.ts +0 -20
  120. package/dist/modules/_old/like/like.module-definition.js +0 -8
  121. package/dist/modules/_old/like/like.module.d.ts +0 -21
  122. package/dist/modules/_old/like/like.module.js +0 -67
  123. package/dist/modules/_old/like/like.service.d.ts +0 -61
  124. package/dist/modules/_old/like/like.service.js +0 -103
  125. package/dist/viewable.interface.d.ts +0 -42
  126. package/dist/viewable.interface.js +0 -48
@@ -1,27 +0,0 @@
1
- import { Response } from 'express';
2
- import { Connection } from 'mongoose';
3
- /**
4
- * Controller providing a Kubernetes liveness probe endpoint to verify
5
- * the health of the MongoDB connection. Kubernetes uses this endpoint
6
- * to determine if the application is alive and able to communicate with the database.
7
- */
8
- export declare class DatabaseLivenessProbeController {
9
- private readonly connection;
10
- /**
11
- * Receives an injected Mongoose connection instance for database health checks.
12
- *
13
- * @param connection - The active Mongoose database connection
14
- */
15
- constructor(connection: Connection);
16
- /**
17
- * GET /alive
18
- *
19
- * Endpoint for Kubernetes liveness probe to determine MongoDB connection health.
20
- * If the database is connected and responsive to a ping, a 200 response is returned.
21
- * Otherwise, the application returns a 500 error to indicate failure.
22
- *
23
- * @param res {Response} - Express response object used to return HTTP status
24
- * @returns {Promise<void>} - Sends status response directly via Express
25
- */
26
- getLivenessStatus(response: Response): Promise<void>;
27
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.DatabaseLivenessProbeController = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const mongoose_1 = require("@nestjs/mongoose");
18
- const swagger_1 = require("@nestjs/swagger");
19
- const mongoose_2 = require("mongoose");
20
- /**
21
- * Controller providing a Kubernetes liveness probe endpoint to verify
22
- * the health of the MongoDB connection. Kubernetes uses this endpoint
23
- * to determine if the application is alive and able to communicate with the database.
24
- */
25
- let DatabaseLivenessProbeController = class DatabaseLivenessProbeController {
26
- /**
27
- * Receives an injected Mongoose connection instance for database health checks.
28
- *
29
- * @param connection - The active Mongoose database connection
30
- */
31
- constructor(connection) {
32
- this.connection = connection;
33
- }
34
- /**
35
- * GET /alive
36
- *
37
- * Endpoint for Kubernetes liveness probe to determine MongoDB connection health.
38
- * If the database is connected and responsive to a ping, a 200 response is returned.
39
- * Otherwise, the application returns a 500 error to indicate failure.
40
- *
41
- * @param res {Response} - Express response object used to return HTTP status
42
- * @returns {Promise<void>} - Sends status response directly via Express
43
- */
44
- async getLivenessStatus(response) {
45
- // Confirm the Mongoose connection exists and is in a connected state (readyState = 1)
46
- if (!this.connection || this.connection.readyState !== mongoose_2.ConnectionStates.connected) {
47
- response.status(500).send('MongoDB connection is not established');
48
- return;
49
- }
50
- try {
51
- // Ping the MongoDB admin interface to verify responsiveness
52
- const pingResult = await this.connection.db.admin().ping();
53
- // Validate ping response; an 'ok' value of 1 indicates success
54
- if ((pingResult === null || pingResult === void 0 ? void 0 : pingResult.ok) === 1) {
55
- response.status(200).send({ ok: 1, db: 1 });
56
- return;
57
- }
58
- // If ping did not return success, raise an error indicating DB connectivity issues
59
- response.status(500).send('Failed to receive pong from MongoDB');
60
- }
61
- catch (_a) {
62
- // General catch-all for any unexpected errors during the ping process
63
- response.status(500).send('Error occurred while pinging MongoDB');
64
- }
65
- }
66
- };
67
- exports.DatabaseLivenessProbeController = DatabaseLivenessProbeController;
68
- __decorate([
69
- (0, common_1.Get)('/alive'),
70
- __param(0, (0, common_1.Res)()),
71
- __metadata("design:type", Function),
72
- __metadata("design:paramtypes", [Object]),
73
- __metadata("design:returntype", Promise)
74
- ], DatabaseLivenessProbeController.prototype, "getLivenessStatus", null);
75
- exports.DatabaseLivenessProbeController = DatabaseLivenessProbeController = __decorate([
76
- (0, swagger_1.ApiTags)('Kubernetes Liveness Probe'),
77
- (0, common_1.Controller)(),
78
- __param(0, (0, mongoose_1.InjectConnection)()),
79
- __metadata("design:paramtypes", [mongoose_2.Connection])
80
- ], DatabaseLivenessProbeController);
@@ -1,41 +0,0 @@
1
- import { DynamicModule } from '@nestjs/common';
2
- import { ModelDefinition } from '@nestjs/mongoose';
3
- import { DatabaseModuleAsyncOptions, OldDatabaseModuleOptions } from './database-module-options.interface';
4
- /**
5
- * DatabaseModule centralizes all database-related configuration and services.
6
- * It wraps Mongoose integration, model registration, liveness health checks,
7
- * populate strategies, locking utilities, and dynamic configuration support.
8
- */
9
- export declare class OldDatabaseModule {
10
- /**
11
- * Registers one or more Mongoose models for dependency injection in feature modules.
12
- *
13
- * @param {...ModelDefinition[]} modelDefinitions - Array of Mongoose model definitions
14
- * @returns {DynamicModule} A dynamic Mongoose module with registered models
15
- */
16
- static forFeature(...modelDefinitions: ModelDefinition[]): DynamicModule;
17
- /**
18
- * Registers and initializes the database module using static configuration options.
19
- * Enables global access to all database services and model providers.
20
- *
21
- * @param {OldDatabaseModuleOptions} options - Static configuration for MongoDB connection
22
- * @returns {DynamicModule} Configured dynamic module for database initialization
23
- */
24
- static forRoot(options: OldDatabaseModuleOptions): DynamicModule;
25
- /**
26
- * Registers and initializes the database module using async configuration.
27
- * Supports dynamic environment-based options and dependency-injected factories.
28
- *
29
- * @param {DatabaseModuleAsyncOptions} asyncOptions - Async factory-based config
30
- * @returns {DynamicModule} Configured dynamic module with async initialization
31
- */
32
- static forRootAsync(asyncOptions: DatabaseModuleAsyncOptions): DynamicModule;
33
- /**
34
- * Generates standard Mongoose module options with enhanced defaults.
35
- * This enforces strict query mode and sets retry logic to handle connection hiccups.
36
- *
37
- * @param {OldDatabaseModuleOptions} options - Base database config options
38
- * @returns {MongooseModuleOptions} Final Mongoose module config with enhancements
39
- */
40
- private static buildMongooseOptions;
41
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __importDefault = (this && this.__importDefault) || function (mod) {
9
- return (mod && mod.__esModule) ? mod : { "default": mod };
10
- };
11
- var OldDatabaseModule_1;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.OldDatabaseModule = void 0;
14
- const common_1 = require("@nestjs/common");
15
- const mongoose_1 = require("@nestjs/mongoose");
16
- const mongoose_2 = __importDefault(require("mongoose"));
17
- const database_liveness_controller_1 = require("./database.liveness-controller");
18
- const lock_service_1 = require("./lock-service/lock.service");
19
- const model_service_1 = require("./model-service/model.service");
20
- const populate_service_1 = require("./populate-service/populate.service");
21
- const service_mapper_service_1 = require("./service-mapper-service/service-mapper.service");
22
- /**
23
- * DatabaseModule centralizes all database-related configuration and services.
24
- * It wraps Mongoose integration, model registration, liveness health checks,
25
- * populate strategies, locking utilities, and dynamic configuration support.
26
- */
27
- let OldDatabaseModule = OldDatabaseModule_1 = class OldDatabaseModule {
28
- /**
29
- * Registers one or more Mongoose models for dependency injection in feature modules.
30
- *
31
- * @param {...ModelDefinition[]} modelDefinitions - Array of Mongoose model definitions
32
- * @returns {DynamicModule} A dynamic Mongoose module with registered models
33
- */
34
- static forFeature(...modelDefinitions) {
35
- return mongoose_1.MongooseModule.forFeature(modelDefinitions);
36
- }
37
- /**
38
- * Registers and initializes the database module using static configuration options.
39
- * Enables global access to all database services and model providers.
40
- *
41
- * @param {OldDatabaseModuleOptions} options - Static configuration for MongoDB connection
42
- * @returns {DynamicModule} Configured dynamic module for database initialization
43
- */
44
- static forRoot(options) {
45
- return {
46
- global: true,
47
- module: OldDatabaseModule_1,
48
- imports: [
49
- mongoose_1.MongooseModule.forRootAsync({
50
- useFactory: () => this.buildMongooseOptions(options),
51
- }),
52
- ],
53
- };
54
- }
55
- /**
56
- * Registers and initializes the database module using async configuration.
57
- * Supports dynamic environment-based options and dependency-injected factories.
58
- *
59
- * @param {DatabaseModuleAsyncOptions} asyncOptions - Async factory-based config
60
- * @returns {DynamicModule} Configured dynamic module with async initialization
61
- */
62
- static forRootAsync(asyncOptions) {
63
- return {
64
- global: true,
65
- module: OldDatabaseModule_1,
66
- imports: [
67
- mongoose_1.MongooseModule.forRootAsync({
68
- inject: asyncOptions.inject,
69
- useFactory: async (...args) => {
70
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
71
- const resolvedOptions = await asyncOptions.useFactory(...args);
72
- return this.buildMongooseOptions(resolvedOptions);
73
- },
74
- }),
75
- ],
76
- };
77
- }
78
- /**
79
- * Generates standard Mongoose module options with enhanced defaults.
80
- * This enforces strict query mode and sets retry logic to handle connection hiccups.
81
- *
82
- * @param {OldDatabaseModuleOptions} options - Base database config options
83
- * @returns {MongooseModuleOptions} Final Mongoose module config with enhancements
84
- */
85
- static buildMongooseOptions(options) {
86
- mongoose_2.default.set('strictQuery', true); // Enforce strict mode for queries
87
- return Object.assign(Object.assign({}, options), { retryAttempts: 3, retryDelay: 2000 });
88
- }
89
- };
90
- exports.OldDatabaseModule = OldDatabaseModule;
91
- exports.OldDatabaseModule = OldDatabaseModule = OldDatabaseModule_1 = __decorate([
92
- (0, common_1.Module)({
93
- providers: [model_service_1.OldModelService, populate_service_1.OldPopulateService, service_mapper_service_1.OldServiceMapperService, lock_service_1.OldLockService],
94
- exports: [model_service_1.OldModelService, populate_service_1.OldPopulateService, service_mapper_service_1.OldServiceMapperService, lock_service_1.OldLockService],
95
- controllers: [database_liveness_controller_1.DatabaseLivenessProbeController],
96
- })
97
- ], OldDatabaseModule);
@@ -1,6 +0,0 @@
1
- export { OldDatabaseModuleOptions } from './database-module-options.interface';
2
- export { OldDatabaseModule } from './database.module';
3
- export { OldLockService } from './lock-service/lock.service';
4
- export { OldModelService } from './model-service/model.service';
5
- export { OldPopulateService } from './populate-service/populate.service';
6
- export { OldServiceMapperService } from './service-mapper-service/service-mapper.service';
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OldServiceMapperService = exports.OldPopulateService = exports.OldModelService = exports.OldLockService = exports.OldDatabaseModule = void 0;
4
- var database_module_1 = require("./database.module");
5
- Object.defineProperty(exports, "OldDatabaseModule", { enumerable: true, get: function () { return database_module_1.OldDatabaseModule; } });
6
- var lock_service_1 = require("./lock-service/lock.service");
7
- Object.defineProperty(exports, "OldLockService", { enumerable: true, get: function () { return lock_service_1.OldLockService; } });
8
- var model_service_1 = require("./model-service/model.service");
9
- Object.defineProperty(exports, "OldModelService", { enumerable: true, get: function () { return model_service_1.OldModelService; } });
10
- var populate_service_1 = require("./populate-service/populate.service");
11
- Object.defineProperty(exports, "OldPopulateService", { enumerable: true, get: function () { return populate_service_1.OldPopulateService; } });
12
- var service_mapper_service_1 = require("./service-mapper-service/service-mapper.service");
13
- Object.defineProperty(exports, "OldServiceMapperService", { enumerable: true, get: function () { return service_mapper_service_1.OldServiceMapperService; } });
@@ -1,38 +0,0 @@
1
- import { ModelDefinition } from '@nestjs/mongoose';
2
- import { Document } from 'mongoose';
3
- /**
4
- * Lock
5
- *
6
- * Represents a distributed lock document stored in MongoDB.
7
- *
8
- * Each lock is uniquely identified by a `lockKey` and claimed by a specific
9
- * service instance via `serviceId`. Locks have an expiration date `expiresAt`
10
- * to automatically release stale locks and avoid deadlocks.
11
- */
12
- export declare class OldLock extends Document {
13
- /**
14
- * Unique identifier for the lock resource.
15
- *
16
- * Ensures that only one lock exists per key.
17
- */
18
- lockKey: string;
19
- /**
20
- * Identifier of the service instance that owns this lock.
21
- *
22
- * Used to verify ownership before releasing a lock.
23
- */
24
- serviceId: string;
25
- /**
26
- * Expiration date and time of the lock.
27
- *
28
- * MongoDB TTL index configured with `expires: 0` automatically removes the lock document
29
- * when the `expiresAt` time is reached, preventing stale locks from persisting.
30
- */
31
- expiresAt: Date;
32
- }
33
- /**
34
- * Model definition for the Lock schema.
35
- *
36
- * Used by Mongoose to create the model and enable typing.
37
- */
38
- export declare const LockDefinition: ModelDefinition;
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.LockDefinition = exports.OldLock = void 0;
13
- const mongoose_1 = require("@nestjs/mongoose");
14
- const mongoose_2 = require("mongoose");
15
- /**
16
- * Lock
17
- *
18
- * Represents a distributed lock document stored in MongoDB.
19
- *
20
- * Each lock is uniquely identified by a `lockKey` and claimed by a specific
21
- * service instance via `serviceId`. Locks have an expiration date `expiresAt`
22
- * to automatically release stale locks and avoid deadlocks.
23
- */
24
- let OldLock = class OldLock extends mongoose_2.Document {
25
- };
26
- exports.OldLock = OldLock;
27
- __decorate([
28
- (0, mongoose_1.Prop)({ required: true, unique: true }),
29
- __metadata("design:type", String)
30
- ], OldLock.prototype, "lockKey", void 0);
31
- __decorate([
32
- (0, mongoose_1.Prop)({ required: true }),
33
- __metadata("design:type", String)
34
- ], OldLock.prototype, "serviceId", void 0);
35
- __decorate([
36
- (0, mongoose_1.Prop)({ required: true, expires: 0 }),
37
- __metadata("design:type", Date)
38
- ], OldLock.prototype, "expiresAt", void 0);
39
- exports.OldLock = OldLock = __decorate([
40
- (0, mongoose_1.Schema)({ collection: 'locks', timestamps: true })
41
- ], OldLock);
42
- const LockSchema = mongoose_1.SchemaFactory.createForClass(OldLock);
43
- /**
44
- * Model definition for the Lock schema.
45
- *
46
- * Used by Mongoose to create the model and enable typing.
47
- */
48
- exports.LockDefinition = {
49
- name: OldLock.name,
50
- schema: LockSchema,
51
- };
@@ -1,53 +0,0 @@
1
- import { OnModuleInit } from '@nestjs/common';
2
- import { Connection } from 'mongoose';
3
- /**
4
- * LockService
5
- *
6
- * This service manages distributed locks using MongoDB. Each lock is uniquely identified by a `lockKey`
7
- * and associated with a service via `serviceId`. Locks ensure that only one service instance can perform
8
- * operations on a given resource at any time. Locks are automatically released after a specified timeout
9
- * to prevent deadlocks.
10
- */
11
- export declare class OldLockService implements OnModuleInit {
12
- private readonly databaseConnection;
13
- private readonly logger;
14
- private readonly lockModel;
15
- private readonly serviceId;
16
- private readonly lockDuration;
17
- /**
18
- * Initializes the LockService with an injected MongoDB connection.
19
- * Sets up the lock model based on the Lock schema.
20
- *
21
- * @param databaseConnection Injected Mongoose connection instance.
22
- */
23
- constructor(databaseConnection: Connection);
24
- /**
25
- * Ensures the lock model indexes and schema are initialized after module setup.
26
- */
27
- onModuleInit(): Promise<void>;
28
- /**
29
- * Attempts to acquire a distributed lock for the given key.
30
- *
31
- * The lock is acquired only if:
32
- * - No current lock exists for the key (i.e., serviceId field does not exist)
33
- * - Or the existing lock has expired (expiresAt less than current time)
34
- *
35
- * If successful, the lock document is created or updated with the current serviceId
36
- * and a new expiration timestamp.
37
- *
38
- * This atomic operation avoids race conditions where multiple services
39
- * attempt to acquire the same lock simultaneously.
40
- *
41
- * @param lockKey Unique identifier for the resource to lock.
42
- * @returns True if the lock was acquired successfully; false otherwise.
43
- */
44
- acquireLock(lockKey: string): Promise<boolean>;
45
- /**
46
- * Releases the lock for the specified key, but only if currently owned by this service instance.
47
- *
48
- * This prevents accidentally releasing locks held by other services.
49
- *
50
- * @param lockKey Unique identifier for the lock to release.
51
- */
52
- releaseLock(lockKey: string): Promise<void>;
53
- }
@@ -1,103 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- var OldLockService_1;
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.OldLockService = void 0;
17
- const common_1 = require("@nestjs/common");
18
- const mongoose_1 = require("@nestjs/mongoose");
19
- const crypto_1 = require("crypto");
20
- const mongoose_2 = require("mongoose");
21
- const lock_schema_1 = require("./lock.schema");
22
- /**
23
- * LockService
24
- *
25
- * This service manages distributed locks using MongoDB. Each lock is uniquely identified by a `lockKey`
26
- * and associated with a service via `serviceId`. Locks ensure that only one service instance can perform
27
- * operations on a given resource at any time. Locks are automatically released after a specified timeout
28
- * to prevent deadlocks.
29
- */
30
- let OldLockService = OldLockService_1 = class OldLockService {
31
- /**
32
- * Initializes the LockService with an injected MongoDB connection.
33
- * Sets up the lock model based on the Lock schema.
34
- *
35
- * @param databaseConnection Injected Mongoose connection instance.
36
- */
37
- constructor(databaseConnection) {
38
- this.databaseConnection = databaseConnection;
39
- this.logger = new common_1.Logger(OldLockService_1.name);
40
- this.serviceId = (0, crypto_1.randomUUID)(); // Unique identifier for this service instance
41
- this.lockDuration = 300000; // Duration for which a lock is held (5 minutes)
42
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
43
- this.lockModel = this.databaseConnection.model(lock_schema_1.LockDefinition.name, lock_schema_1.LockDefinition.schema);
44
- }
45
- /**
46
- * Ensures the lock model indexes and schema are initialized after module setup.
47
- */
48
- async onModuleInit() {
49
- await this.lockModel.init();
50
- }
51
- /**
52
- * Attempts to acquire a distributed lock for the given key.
53
- *
54
- * The lock is acquired only if:
55
- * - No current lock exists for the key (i.e., serviceId field does not exist)
56
- * - Or the existing lock has expired (expiresAt less than current time)
57
- *
58
- * If successful, the lock document is created or updated with the current serviceId
59
- * and a new expiration timestamp.
60
- *
61
- * This atomic operation avoids race conditions where multiple services
62
- * attempt to acquire the same lock simultaneously.
63
- *
64
- * @param lockKey Unique identifier for the resource to lock.
65
- * @returns True if the lock was acquired successfully; false otherwise.
66
- */
67
- async acquireLock(lockKey) {
68
- const now = new Date();
69
- const expiresAt = new Date(now.getTime() + this.lockDuration);
70
- this.logger.log(`Attempting to acquire lock for key "${lockKey}"`);
71
- try {
72
- const lock = await this.lockModel.findOneAndUpdate({ lockKey, serviceId: { $exists: false }, expiresAt: { $lt: now } }, { $set: { lockKey, serviceId: this.serviceId, expiresAt } }, { upsert: true, new: true });
73
- if (lock.serviceId !== this.serviceId) {
74
- this.logger.log(`Lock for key "${lockKey}" is currently held by another service.`);
75
- return false;
76
- }
77
- this.logger.log(`Lock for key "${lockKey}" acquired; expires at ${expiresAt.toISOString()}`);
78
- return true;
79
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
- }
81
- catch (error) {
82
- this.logger.log(`Failed to acquire lock (${lockKey}): Another service has already locked this item`);
83
- return false;
84
- }
85
- }
86
- /**
87
- * Releases the lock for the specified key, but only if currently owned by this service instance.
88
- *
89
- * This prevents accidentally releasing locks held by other services.
90
- *
91
- * @param lockKey Unique identifier for the lock to release.
92
- */
93
- async releaseLock(lockKey) {
94
- this.logger.log(`Releasing lock for key "${lockKey}" if owned by this service.`);
95
- await this.lockModel.deleteOne({ lockKey, serviceId: this.serviceId });
96
- }
97
- };
98
- exports.OldLockService = OldLockService;
99
- exports.OldLockService = OldLockService = OldLockService_1 = __decorate([
100
- (0, common_1.Injectable)(),
101
- __param(0, (0, mongoose_1.InjectConnection)()),
102
- __metadata("design:paramtypes", [mongoose_2.Connection])
103
- ], OldLockService);
@@ -1,28 +0,0 @@
1
- import { Document } from 'mongoose';
2
- export type AccountInformation = {
3
- id: string;
4
- username: string;
5
- email: string;
6
- avatar?: string;
7
- };
8
- declare class AccountModel extends Document {
9
- username: string;
10
- email: string;
11
- avatar?: boolean;
12
- }
13
- export declare const AccountDB: {
14
- name: string;
15
- account: {
16
- model: typeof AccountModel;
17
- schema: import("mongoose").Schema<AccountModel, import("mongoose").Model<AccountModel, any, any, any, Document<unknown, any, AccountModel, any, {}> & AccountModel & Required<{
18
- _id: unknown;
19
- }> & {
20
- __v: number;
21
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, AccountModel, Document<unknown, {}, import("mongoose").FlatRecord<AccountModel>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<AccountModel> & Required<{
22
- _id: unknown;
23
- }> & {
24
- __v: number;
25
- }>;
26
- };
27
- };
28
- export {};
@@ -1,44 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AccountDB = void 0;
13
- const mongoose_1 = require("@nestjs/mongoose");
14
- const mongoose_2 = require("mongoose");
15
- const functions_1 = require("../../../../../functions");
16
- const transform = (0, functions_1.createSchemaTransformer)((doc) => {
17
- const { _id, email, username, avatar } = doc;
18
- const account = { id: _id.toString(), email: email, username: username };
19
- if (avatar)
20
- account.avatar = `https://file.svi-itlab.com/avatar/${_id.toString()}.webp`;
21
- return account;
22
- });
23
- let AccountModel = class AccountModel extends mongoose_2.Document {
24
- };
25
- __decorate([
26
- (0, mongoose_1.Prop)(),
27
- __metadata("design:type", String)
28
- ], AccountModel.prototype, "username", void 0);
29
- __decorate([
30
- (0, mongoose_1.Prop)(),
31
- __metadata("design:type", String)
32
- ], AccountModel.prototype, "email", void 0);
33
- __decorate([
34
- (0, mongoose_1.Prop)({ required: false }),
35
- __metadata("design:type", Boolean)
36
- ], AccountModel.prototype, "avatar", void 0);
37
- AccountModel = __decorate([
38
- (0, mongoose_1.Schema)({ collection: 'accounts', toObject: transform, toJSON: transform })
39
- ], AccountModel);
40
- const AccountSchema = mongoose_1.SchemaFactory.createForClass(AccountModel);
41
- exports.AccountDB = {
42
- name: 'hub-account',
43
- account: { model: AccountModel, schema: AccountSchema },
44
- };
@@ -1,23 +0,0 @@
1
- import { Document } from 'mongoose';
2
- declare class BookModel extends Document {
3
- title: string;
4
- _hid: string;
5
- draft: boolean;
6
- submitterId: string;
7
- }
8
- export declare const BooksDB: {
9
- name: string;
10
- book: {
11
- model: typeof BookModel;
12
- schema: import("mongoose").Schema<BookModel, import("mongoose").Model<BookModel, any, any, any, Document<unknown, any, BookModel, any, {}> & BookModel & Required<{
13
- _id: unknown;
14
- }> & {
15
- __v: number;
16
- }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, BookModel, Document<unknown, {}, import("mongoose").FlatRecord<BookModel>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<BookModel> & Required<{
17
- _id: unknown;
18
- }> & {
19
- __v: number;
20
- }>;
21
- };
22
- };
23
- export {};
@@ -1,45 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- 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;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.BooksDB = void 0;
13
- const mongoose_1 = require("@nestjs/mongoose");
14
- const mongoose_2 = require("mongoose");
15
- const functions_1 = require("../../../../../functions");
16
- const transform = (0, functions_1.createSchemaTransformer)((doc) => {
17
- const { title, _hid } = doc;
18
- return { title, url: `https://www.svi-itlab.com/books/${_hid}` };
19
- });
20
- let BookModel = class BookModel extends mongoose_2.Document {
21
- };
22
- __decorate([
23
- (0, mongoose_1.Prop)(),
24
- __metadata("design:type", String)
25
- ], BookModel.prototype, "title", void 0);
26
- __decorate([
27
- (0, mongoose_1.Prop)(),
28
- __metadata("design:type", String)
29
- ], BookModel.prototype, "_hid", void 0);
30
- __decorate([
31
- (0, mongoose_1.Prop)(),
32
- __metadata("design:type", Boolean)
33
- ], BookModel.prototype, "draft", void 0);
34
- __decorate([
35
- (0, mongoose_1.Prop)(),
36
- __metadata("design:type", String)
37
- ], BookModel.prototype, "submitterId", void 0);
38
- BookModel = __decorate([
39
- (0, mongoose_1.Schema)({ collection: 'books', toObject: transform, toJSON: transform })
40
- ], BookModel);
41
- const BookSchema = mongoose_1.SchemaFactory.createForClass(BookModel);
42
- exports.BooksDB = {
43
- name: 'hub-books',
44
- book: { model: BookModel, schema: BookSchema },
45
- };