itlab-internal-services 2.16.12 → 2.16.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/classes/document/content-document.class.d.ts +2 -2
- package/dist/classes/fetch-options/content-options.class.d.ts +2 -2
- package/dist/hub-resource.enum.d.ts +0 -23
- package/dist/hub-resource.enum.js +1 -25
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -10
- package/dist/modules/comments/comments.controller.d.ts +3 -3
- package/dist/modules/comments/comments.controller.js +1 -1
- package/dist/modules/comments/comments.service.d.ts +3 -3
- package/dist/modules/comments/comments.service.js +1 -1
- package/dist/modules/services/providers/books/books.service.d.ts +5 -5
- package/dist/modules/services/providers/books/books.service.js +2 -2
- package/dist/modules/services/providers/changelog/changelog.service.d.ts +1 -14
- package/dist/modules/services/providers/conflicts/conflicts.service.d.ts +5 -15
- package/dist/modules/services/providers/conflicts/conflicts.service.js +2 -2
- package/dist/modules/services/providers/content/content-return-types.d.ts +5 -5
- package/dist/modules/services/providers/content/content.service.d.ts +7 -6
- package/dist/modules/services/providers/content/content.service.js +2 -2
- package/dist/modules/services/providers/demo-hive/demo-hive.service.d.ts +5 -5
- package/dist/modules/services/providers/demo-hive/demo-hive.service.js +2 -2
- package/dist/modules/services/providers/events/events.service.d.ts +5 -5
- package/dist/modules/services/providers/events/events.service.js +2 -2
- package/dist/modules/services/providers/files/files.service.d.ts +9 -30
- package/dist/modules/services/providers/files/files.service.js +4 -4
- package/dist/modules/services/providers/mail/dtos/newsletter-issue-mail.dto.v1.d.ts +2 -2
- package/dist/modules/services/providers/newsletter/newsletter.service.d.ts +5 -5
- package/dist/modules/services/providers/newsletter/newsletter.service.js +2 -2
- package/dist/modules/services/providers/newsroom/newsroom.service.d.ts +5 -5
- package/dist/modules/services/providers/newsroom/newsroom.service.js +2 -2
- package/dist/modules/services/providers/notifications/notifications.service.d.ts +5 -18
- package/dist/modules/services/providers/notifications/notifications.service.js +5 -3
- package/dist/modules/services/providers/podcasts/podcasts.service.d.ts +5 -5
- package/dist/modules/services/providers/podcasts/podcasts.service.js +2 -2
- package/dist/modules/services/providers/quick-links/quick-links.service.d.ts +5 -17
- package/dist/modules/services/providers/quick-links/quick-links.service.js +2 -2
- package/dist/pipes/restricted-fields.pipe.js +3 -1
- package/package.json +23 -23
- package/dist/classes/document-updater.class.d.ts +0 -40
- package/dist/classes/document-updater.class.js +0 -58
- package/dist/factories/index.d.ts +0 -1
- package/dist/factories/index.js +0 -5
- package/dist/factories/virtuals.factory.d.ts +0 -80
- package/dist/factories/virtuals.factory.js +0 -172
- package/dist/functions/create-duplicate-checker.function.d.ts +0 -29
- package/dist/functions/create-duplicate-checker.function.js +0 -52
- package/dist/likeable.interface.d.ts +0 -42
- package/dist/likeable.interface.js +0 -48
- package/dist/modules/_old/comment/comment.controller.d.ts +0 -35
- package/dist/modules/_old/comment/comment.controller.js +0 -86
- package/dist/modules/_old/comment/comment.model.d.ts +0 -29
- package/dist/modules/_old/comment/comment.model.js +0 -43
- package/dist/modules/_old/comment/comment.module-definition.d.ts +0 -45
- package/dist/modules/_old/comment/comment.module-definition.js +0 -8
- package/dist/modules/_old/comment/comment.module.d.ts +0 -22
- package/dist/modules/_old/comment/comment.module.js +0 -71
- package/dist/modules/_old/comment/comment.service.d.ts +0 -54
- package/dist/modules/_old/comment/comment.service.js +0 -133
- package/dist/modules/_old/comment/index.d.ts +0 -3
- package/dist/modules/_old/comment/index.js +0 -9
- package/dist/modules/_old/content/content.module-definition.d.ts +0 -5
- package/dist/modules/_old/content/content.module-definition.js +0 -8
- package/dist/modules/_old/content/content.module.d.ts +0 -31
- package/dist/modules/_old/content/content.module.js +0 -60
- package/dist/modules/_old/content/content.service.d.ts +0 -50
- package/dist/modules/_old/content/content.service.js +0 -145
- package/dist/modules/_old/content/index.d.ts +0 -2
- package/dist/modules/_old/content/index.js +0 -7
- package/dist/modules/_old/database/database-module-options.interface.d.ts +0 -41
- package/dist/modules/_old/database/database-module-options.interface.js +0 -2
- package/dist/modules/_old/database/database.liveness-controller.d.ts +0 -27
- package/dist/modules/_old/database/database.liveness-controller.js +0 -80
- package/dist/modules/_old/database/database.module.d.ts +0 -41
- package/dist/modules/_old/database/database.module.js +0 -97
- package/dist/modules/_old/database/index.d.ts +0 -6
- package/dist/modules/_old/database/index.js +0 -13
- package/dist/modules/_old/database/lock-service/lock.schema.d.ts +0 -38
- package/dist/modules/_old/database/lock-service/lock.schema.js +0 -51
- package/dist/modules/_old/database/lock-service/lock.service.d.ts +0 -53
- package/dist/modules/_old/database/lock-service/lock.service.js +0 -103
- package/dist/modules/_old/database/model-service/dbs/hub-account.db.d.ts +0 -28
- package/dist/modules/_old/database/model-service/dbs/hub-account.db.js +0 -44
- package/dist/modules/_old/database/model-service/dbs/hub-books.db.d.ts +0 -23
- package/dist/modules/_old/database/model-service/dbs/hub-books.db.js +0 -45
- package/dist/modules/_old/database/model-service/dbs/hub-comments.db.d.ts +0 -29
- package/dist/modules/_old/database/model-service/dbs/hub-comments.db.js +0 -68
- package/dist/modules/_old/database/model-service/dbs/hub-content.db.d.ts +0 -24
- package/dist/modules/_old/database/model-service/dbs/hub-content.db.js +0 -49
- package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.d.ts +0 -23
- package/dist/modules/_old/database/model-service/dbs/hub-demo-hive.db.js +0 -45
- package/dist/modules/_old/database/model-service/dbs/hub-events.db.d.ts +0 -24
- package/dist/modules/_old/database/model-service/dbs/hub-events.db.js +0 -49
- package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.d.ts +0 -60
- package/dist/modules/_old/database/model-service/dbs/hub-hackschool.db.js +0 -106
- package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.d.ts +0 -25
- package/dist/modules/_old/database/model-service/dbs/hub-newsroom.db.js +0 -53
- package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.d.ts +0 -23
- package/dist/modules/_old/database/model-service/dbs/hub-podcasts.db.js +0 -45
- package/dist/modules/_old/database/model-service/dbs/hub-team.db.d.ts +0 -22
- package/dist/modules/_old/database/model-service/dbs/hub-team.db.js +0 -41
- package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.d.ts +0 -42
- package/dist/modules/_old/database/model-service/dbs/hub-tech-radar.db.js +0 -81
- package/dist/modules/_old/database/model-service/model.service.d.ts +0 -8465
- package/dist/modules/_old/database/model-service/model.service.js +0 -136
- package/dist/modules/_old/database/populate-service/populate.service.d.ts +0 -73
- package/dist/modules/_old/database/populate-service/populate.service.js +0 -163
- package/dist/modules/_old/database/service-mapper-service/service-mapper.service.d.ts +0 -32
- package/dist/modules/_old/database/service-mapper-service/service-mapper.service.js +0 -73
- package/dist/modules/_old/fetch/fetch.module.d.ts +0 -31
- package/dist/modules/_old/fetch/fetch.module.js +0 -60
- package/dist/modules/_old/fetch/fetch.service.d.ts +0 -153
- package/dist/modules/_old/fetch/fetch.service.js +0 -274
- package/dist/modules/_old/fetch/index.d.ts +0 -2
- package/dist/modules/_old/fetch/index.js +0 -7
- package/dist/modules/_old/index.d.ts +0 -5
- package/dist/modules/_old/index.js +0 -21
- package/dist/modules/_old/like/index.d.ts +0 -1
- package/dist/modules/_old/like/index.js +0 -5
- package/dist/modules/_old/like/like.controller.d.ts +0 -41
- package/dist/modules/_old/like/like.controller.js +0 -125
- package/dist/modules/_old/like/like.module-definition.d.ts +0 -20
- package/dist/modules/_old/like/like.module-definition.js +0 -8
- package/dist/modules/_old/like/like.module.d.ts +0 -21
- package/dist/modules/_old/like/like.module.js +0 -67
- package/dist/modules/_old/like/like.service.d.ts +0 -61
- package/dist/modules/_old/like/like.service.js +0 -103
- package/dist/viewable.interface.d.ts +0 -42
- package/dist/viewable.interface.js +0 -48
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LIKE_MODULE_OPTIONS_TOKEN = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Token used to inject LikeModule options into services or controllers if needed.
|
|
6
|
-
* Symbol is used to avoid accidental naming collisions across modules.
|
|
7
|
-
*/
|
|
8
|
-
exports.LIKE_MODULE_OPTIONS_TOKEN = Symbol('LIKE_MODULE_OPTIONS_TOKEN');
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { LikeModuleOptions } from './like.module-definition';
|
|
3
|
-
/**
|
|
4
|
-
* LikeModule dynamically registers controllers and services to handle "like" functionality
|
|
5
|
-
* for different resources based on the provided model and optional suffix.
|
|
6
|
-
*
|
|
7
|
-
* This design enables modularity and reuse of like-related logic across various resource types.
|
|
8
|
-
*/
|
|
9
|
-
export declare class LikeModule {
|
|
10
|
-
/**
|
|
11
|
-
* Registers and configures the LikeModule dynamically.
|
|
12
|
-
*
|
|
13
|
-
* - Automatically generates an endpoint path based on provided suffix.
|
|
14
|
-
* - Tags the controller in Swagger docs for better discoverability.
|
|
15
|
-
* - Inherits all business logic from the base LikeController.
|
|
16
|
-
*
|
|
17
|
-
* @param options - Configuration options including the model and route suffix.
|
|
18
|
-
* @returns A fully configured dynamic NestJS module.
|
|
19
|
-
*/
|
|
20
|
-
static register(options: LikeModuleOptions): DynamicModule;
|
|
21
|
-
}
|
|
@@ -1,67 +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 LikeModule_1;
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.LikeModule = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
12
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
13
|
-
const itlab_functions_1 = require("itlab-functions");
|
|
14
|
-
const like_controller_1 = require("./like.controller");
|
|
15
|
-
const like_module_definition_1 = require("./like.module-definition");
|
|
16
|
-
const like_service_1 = require("./like.service");
|
|
17
|
-
/**
|
|
18
|
-
* LikeModule dynamically registers controllers and services to handle "like" functionality
|
|
19
|
-
* for different resources based on the provided model and optional suffix.
|
|
20
|
-
*
|
|
21
|
-
* This design enables modularity and reuse of like-related logic across various resource types.
|
|
22
|
-
*/
|
|
23
|
-
let LikeModule = LikeModule_1 = class LikeModule {
|
|
24
|
-
/**
|
|
25
|
-
* Registers and configures the LikeModule dynamically.
|
|
26
|
-
*
|
|
27
|
-
* - Automatically generates an endpoint path based on provided suffix.
|
|
28
|
-
* - Tags the controller in Swagger docs for better discoverability.
|
|
29
|
-
* - Inherits all business logic from the base LikeController.
|
|
30
|
-
*
|
|
31
|
-
* @param options - Configuration options including the model and route suffix.
|
|
32
|
-
* @returns A fully configured dynamic NestJS module.
|
|
33
|
-
*/
|
|
34
|
-
static register(options) {
|
|
35
|
-
const { routeScope = [] } = options;
|
|
36
|
-
// Transform suffixes into a readable Swagger tag (e.g., "Like Module - Posts")
|
|
37
|
-
const swaggerTag = ['Like Module', ...routeScope.map((scope) => (0, itlab_functions_1.capitalize)(scope))].join(' -');
|
|
38
|
-
// Build the controller route path (e.g., "/like/posts")
|
|
39
|
-
const controllerRoutePath = ['like', ...routeScope].join('/');
|
|
40
|
-
/**
|
|
41
|
-
* A dynamically scoped LikeController for a specific resource.
|
|
42
|
-
*
|
|
43
|
-
* This controller uses a generated route path and custom Swagger tag,
|
|
44
|
-
* but otherwise inherits all base LikeController behavior.
|
|
45
|
-
*/
|
|
46
|
-
let LikeController = class LikeController extends like_controller_1.LikeController {
|
|
47
|
-
};
|
|
48
|
-
LikeController = __decorate([
|
|
49
|
-
(0, swagger_1.ApiTags)(swaggerTag),
|
|
50
|
-
(0, common_1.Controller)(controllerRoutePath)
|
|
51
|
-
], LikeController);
|
|
52
|
-
return {
|
|
53
|
-
module: LikeModule_1,
|
|
54
|
-
controllers: [LikeController],
|
|
55
|
-
providers: [like_service_1.LikeService, { provide: like_module_definition_1.LIKE_MODULE_OPTIONS_TOKEN, useValue: options }],
|
|
56
|
-
exports: [like_service_1.LikeService],
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
exports.LikeModule = LikeModule;
|
|
61
|
-
exports.LikeModule = LikeModule = LikeModule_1 = __decorate([
|
|
62
|
-
(0, common_1.Module)({
|
|
63
|
-
controllers: [like_controller_1.LikeController],
|
|
64
|
-
providers: [like_service_1.LikeService],
|
|
65
|
-
exports: [like_service_1.LikeService],
|
|
66
|
-
})
|
|
67
|
-
], LikeModule);
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { Connection } from 'mongoose';
|
|
2
|
-
import { LikeModuleOptions } from './like.module-definition';
|
|
3
|
-
/**
|
|
4
|
-
* LikeService manages the "like" functionality for resources.
|
|
5
|
-
*
|
|
6
|
-
* It provides methods to add, remove, and verify likes on resource entities,
|
|
7
|
-
* interacting with the underlying MongoDB collection configured by the module options.
|
|
8
|
-
*/
|
|
9
|
-
export declare class LikeService {
|
|
10
|
-
private readonly moduleOptions;
|
|
11
|
-
private readonly connection;
|
|
12
|
-
private readonly logger;
|
|
13
|
-
private readonly likeModel;
|
|
14
|
-
/**
|
|
15
|
-
* Initializes LikeService with database connection and module configuration.
|
|
16
|
-
*
|
|
17
|
-
* @param {LikeModuleOptions} moduleOptions - The module options containing model info.
|
|
18
|
-
* @param {Connection} connection - The active MongoDB connection injected by Mongoose.
|
|
19
|
-
*/
|
|
20
|
-
constructor(moduleOptions: LikeModuleOptions, connection: Connection);
|
|
21
|
-
/**
|
|
22
|
-
* Computes the number of likes for a given resource document.
|
|
23
|
-
*
|
|
24
|
-
* @param {Document & Likeable} [resource] - The resource document which contains _likedBy array.
|
|
25
|
-
* @returns {number} The count of likes, or zero if none exist.
|
|
26
|
-
*/
|
|
27
|
-
private getLikeCount;
|
|
28
|
-
/**
|
|
29
|
-
* Adds a like to the specified resource by the given account.
|
|
30
|
-
*
|
|
31
|
-
* Uses MongoDB's `$addToSet` to avoid duplicate entries efficiently.
|
|
32
|
-
* Returns the updated count of likes after addition.
|
|
33
|
-
*
|
|
34
|
-
* @param {string} resourceId - The identifier of the resource to like.
|
|
35
|
-
* @param {string} accountId - The account identifier that likes the resource.
|
|
36
|
-
* @returns {Promise<number>} The updated like count.
|
|
37
|
-
*/
|
|
38
|
-
addLike(resourceId: string, accountId: string): Promise<number>;
|
|
39
|
-
/**
|
|
40
|
-
* Removes a like from the specified resource by the given account.
|
|
41
|
-
*
|
|
42
|
-
* Uses MongoDB's `$pull` operator to remove the account ID from the liked list.
|
|
43
|
-
* Returns the updated count of likes after removal.
|
|
44
|
-
*
|
|
45
|
-
* @param {string} resourceId - The identifier of the resource to unlike.
|
|
46
|
-
* @param {string} accountId - The account identifier that removes the like.
|
|
47
|
-
* @returns {Promise<number>} The updated like count.
|
|
48
|
-
*/
|
|
49
|
-
removeLike(resourceId: string, accountId: string): Promise<number>;
|
|
50
|
-
/**
|
|
51
|
-
* Checks whether the specified account has liked the resource.
|
|
52
|
-
*
|
|
53
|
-
* This method fetches the resource document and checks if the account ID
|
|
54
|
-
* exists in the `_likedBy` array.
|
|
55
|
-
*
|
|
56
|
-
* @param {string} resourceId - The resource to check.
|
|
57
|
-
* @param {string} accountId - The account to verify.
|
|
58
|
-
* @returns {Promise<boolean>} True if the account has liked the resource; false otherwise.
|
|
59
|
-
*/
|
|
60
|
-
hasLiked(resourceId: string, accountId: string): Promise<boolean>;
|
|
61
|
-
}
|
|
@@ -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 LikeService_1;
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.LikeService = void 0;
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const mongoose_1 = require("@nestjs/mongoose");
|
|
19
|
-
const mongoose_2 = require("mongoose");
|
|
20
|
-
const like_module_definition_1 = require("./like.module-definition");
|
|
21
|
-
/**
|
|
22
|
-
* LikeService manages the "like" functionality for resources.
|
|
23
|
-
*
|
|
24
|
-
* It provides methods to add, remove, and verify likes on resource entities,
|
|
25
|
-
* interacting with the underlying MongoDB collection configured by the module options.
|
|
26
|
-
*/
|
|
27
|
-
let LikeService = LikeService_1 = class LikeService {
|
|
28
|
-
/**
|
|
29
|
-
* Initializes LikeService with database connection and module configuration.
|
|
30
|
-
*
|
|
31
|
-
* @param {LikeModuleOptions} moduleOptions - The module options containing model info.
|
|
32
|
-
* @param {Connection} connection - The active MongoDB connection injected by Mongoose.
|
|
33
|
-
*/
|
|
34
|
-
constructor(moduleOptions, connection) {
|
|
35
|
-
this.moduleOptions = moduleOptions;
|
|
36
|
-
this.connection = connection;
|
|
37
|
-
this.logger = new common_1.Logger(LikeService_1.name);
|
|
38
|
-
this.likeModel = this.connection.model(this.moduleOptions.model.name, this.moduleOptions.model.schema);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Computes the number of likes for a given resource document.
|
|
42
|
-
*
|
|
43
|
-
* @param {Document & Likeable} [resource] - The resource document which contains _likedBy array.
|
|
44
|
-
* @returns {number} The count of likes, or zero if none exist.
|
|
45
|
-
*/
|
|
46
|
-
getLikeCount(resource) {
|
|
47
|
-
var _a, _b;
|
|
48
|
-
return (_b = (_a = resource === null || resource === void 0 ? void 0 : resource._likedBy) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Adds a like to the specified resource by the given account.
|
|
52
|
-
*
|
|
53
|
-
* Uses MongoDB's `$addToSet` to avoid duplicate entries efficiently.
|
|
54
|
-
* Returns the updated count of likes after addition.
|
|
55
|
-
*
|
|
56
|
-
* @param {string} resourceId - The identifier of the resource to like.
|
|
57
|
-
* @param {string} accountId - The account identifier that likes the resource.
|
|
58
|
-
* @returns {Promise<number>} The updated like count.
|
|
59
|
-
*/
|
|
60
|
-
async addLike(resourceId, accountId) {
|
|
61
|
-
this.logger.log(`Adding like to resource ${resourceId} by account ${accountId}`);
|
|
62
|
-
const updatedResource = await this.likeModel.findOneAndUpdate({ _id: resourceId }, { $addToSet: { _likedBy: accountId } }, { new: true, upsert: false, timestamps: false });
|
|
63
|
-
return this.getLikeCount(updatedResource);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Removes a like from the specified resource by the given account.
|
|
67
|
-
*
|
|
68
|
-
* Uses MongoDB's `$pull` operator to remove the account ID from the liked list.
|
|
69
|
-
* Returns the updated count of likes after removal.
|
|
70
|
-
*
|
|
71
|
-
* @param {string} resourceId - The identifier of the resource to unlike.
|
|
72
|
-
* @param {string} accountId - The account identifier that removes the like.
|
|
73
|
-
* @returns {Promise<number>} The updated like count.
|
|
74
|
-
*/
|
|
75
|
-
async removeLike(resourceId, accountId) {
|
|
76
|
-
this.logger.log(`Removing like from resource ${resourceId} by account ${accountId}`);
|
|
77
|
-
const updatedResource = await this.likeModel.findOneAndUpdate({ _id: resourceId }, { $pull: { _likedBy: accountId } }, { new: true, upsert: false, timestamps: false });
|
|
78
|
-
return this.getLikeCount(updatedResource);
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Checks whether the specified account has liked the resource.
|
|
82
|
-
*
|
|
83
|
-
* This method fetches the resource document and checks if the account ID
|
|
84
|
-
* exists in the `_likedBy` array.
|
|
85
|
-
*
|
|
86
|
-
* @param {string} resourceId - The resource to check.
|
|
87
|
-
* @param {string} accountId - The account to verify.
|
|
88
|
-
* @returns {Promise<boolean>} True if the account has liked the resource; false otherwise.
|
|
89
|
-
*/
|
|
90
|
-
async hasLiked(resourceId, accountId) {
|
|
91
|
-
var _a;
|
|
92
|
-
this.logger.log(`Checking if account ${accountId} has liked resource ${resourceId}`);
|
|
93
|
-
const resource = await this.likeModel.findOne({ _id: resourceId });
|
|
94
|
-
return !!((_a = resource === null || resource === void 0 ? void 0 : resource._likedBy) === null || _a === void 0 ? void 0 : _a.includes(accountId));
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
exports.LikeService = LikeService;
|
|
98
|
-
exports.LikeService = LikeService = LikeService_1 = __decorate([
|
|
99
|
-
(0, common_1.Injectable)(),
|
|
100
|
-
__param(0, (0, common_1.Inject)(like_module_definition_1.LIKE_MODULE_OPTIONS_TOKEN)),
|
|
101
|
-
__param(1, (0, mongoose_1.InjectConnection)()),
|
|
102
|
-
__metadata("design:paramtypes", [Object, mongoose_2.Connection])
|
|
103
|
-
], LikeService);
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TODO: REMOVE
|
|
3
|
-
* Interface for entities that track user views. This allows the system to monitor
|
|
4
|
-
* which accounts have viewed an item and how many total views it has received.
|
|
5
|
-
*
|
|
6
|
-
* Used to enable features such as view analytics, popularity ranking, or recommendation systems.
|
|
7
|
-
*/
|
|
8
|
-
export interface Viewable {
|
|
9
|
-
/**
|
|
10
|
-
* List of account IDs who have viewed this entity.
|
|
11
|
-
*/
|
|
12
|
-
_viewedBy: string[];
|
|
13
|
-
/**
|
|
14
|
-
* Count of total views.
|
|
15
|
-
*/
|
|
16
|
-
views: number;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Mongoose schema decorator for the `_viewedBy` field, which tracks unique viewer IDs.
|
|
20
|
-
* Initialized as an empty array to ensure a consistent schema across documents.
|
|
21
|
-
*
|
|
22
|
-
* @returns {PropertyDecorator} - Mongoose configuration for tracking viewers.
|
|
23
|
-
*/
|
|
24
|
-
export declare function PropertyViewedBy(): PropertyDecorator;
|
|
25
|
-
/**
|
|
26
|
-
* Swagger schema decorator for the `_viewedBy` field. Used in OpenAPI documentation
|
|
27
|
-
* to describe which users have viewed the entity.
|
|
28
|
-
*
|
|
29
|
-
* It enhances API clarity for clients consuming entities that support view tracking.
|
|
30
|
-
*
|
|
31
|
-
* @returns {PropertyDecorator} - Swagger metadata for the `viewedBy` field.
|
|
32
|
-
*/
|
|
33
|
-
export declare function ApiViewedBy(): PropertyDecorator;
|
|
34
|
-
/**
|
|
35
|
-
* Swagger schema decorator for the `views` field. Communicates to API consumers
|
|
36
|
-
* the meaning and default value of the view count.
|
|
37
|
-
*
|
|
38
|
-
* Helps visualize popularity or engagement metrics in API tooling.
|
|
39
|
-
*
|
|
40
|
-
* @returns {PropertyDecorator} - Swagger metadata for the `views` field.
|
|
41
|
-
*/
|
|
42
|
-
export declare function ApiViews(): PropertyDecorator;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PropertyViewedBy = PropertyViewedBy;
|
|
4
|
-
exports.ApiViewedBy = ApiViewedBy;
|
|
5
|
-
exports.ApiViews = ApiViews;
|
|
6
|
-
const mongoose_1 = require("@nestjs/mongoose");
|
|
7
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
8
|
-
const models_1 = require("./models");
|
|
9
|
-
/**
|
|
10
|
-
* Mongoose schema decorator for the `_viewedBy` field, which tracks unique viewer IDs.
|
|
11
|
-
* Initialized as an empty array to ensure a consistent schema across documents.
|
|
12
|
-
*
|
|
13
|
-
* @returns {PropertyDecorator} - Mongoose configuration for tracking viewers.
|
|
14
|
-
*/
|
|
15
|
-
function PropertyViewedBy() {
|
|
16
|
-
return (0, mongoose_1.Prop)({ required: true, default: () => [] });
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Swagger schema decorator for the `_viewedBy` field. Used in OpenAPI documentation
|
|
20
|
-
* to describe which users have viewed the entity.
|
|
21
|
-
*
|
|
22
|
-
* It enhances API clarity for clients consuming entities that support view tracking.
|
|
23
|
-
*
|
|
24
|
-
* @returns {PropertyDecorator} - Swagger metadata for the `viewedBy` field.
|
|
25
|
-
*/
|
|
26
|
-
function ApiViewedBy() {
|
|
27
|
-
return (0, swagger_1.ApiProperty)({
|
|
28
|
-
name: 'viewedBy',
|
|
29
|
-
type: [models_1.Account],
|
|
30
|
-
default: [],
|
|
31
|
-
description: 'Accounts that have viewed this entity.',
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Swagger schema decorator for the `views` field. Communicates to API consumers
|
|
36
|
-
* the meaning and default value of the view count.
|
|
37
|
-
*
|
|
38
|
-
* Helps visualize popularity or engagement metrics in API tooling.
|
|
39
|
-
*
|
|
40
|
-
* @returns {PropertyDecorator} - Swagger metadata for the `views` field.
|
|
41
|
-
*/
|
|
42
|
-
function ApiViews() {
|
|
43
|
-
return (0, swagger_1.ApiProperty)({
|
|
44
|
-
type: Number,
|
|
45
|
-
default: 0,
|
|
46
|
-
description: 'Total number of views this entity has received.',
|
|
47
|
-
});
|
|
48
|
-
}
|