itlab-internal-services 2.15.7 → 2.16.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.
- package/README.md +1 -187
- package/dist/classes/document-merger.class.js +2 -3
- package/dist/classes/index.d.ts +4 -1
- package/dist/classes/index.js +7 -3
- package/dist/classes/report-category.class.d.ts +55 -0
- package/dist/classes/report-category.class.js +120 -0
- package/dist/classes/schema-builder.class.d.ts +75 -0
- package/dist/classes/schema-builder.class.js +109 -0
- package/dist/classes/task-manager.class.d.ts +71 -0
- package/dist/classes/task-manager.class.js +99 -0
- package/dist/decorators/{account.decorator.d.ts → authenticated-account.decorator.d.ts} +4 -4
- package/dist/decorators/{account.decorator.js → authenticated-account.decorator.js} +8 -10
- package/dist/decorators/index.d.ts +1 -1
- package/dist/decorators/index.js +1 -1
- package/dist/exceptions/authenticated-user-required.exception.d.ts +34 -0
- package/dist/exceptions/authenticated-user-required.exception.js +51 -0
- package/dist/exceptions/bad-body.exception.d.ts +19 -8
- package/dist/exceptions/bad-body.exception.js +26 -10
- package/dist/exceptions/bad-parameter.exception.d.ts +23 -8
- package/dist/exceptions/bad-parameter.exception.js +41 -18
- package/dist/exceptions/duplicate.exception.d.ts +20 -8
- package/dist/exceptions/duplicate.exception.js +27 -10
- package/dist/exceptions/index.d.ts +1 -0
- package/dist/exceptions/index.js +1 -0
- package/dist/functions/add-views-likes-virtuals.function.d.ts +15 -0
- package/dist/functions/add-views-likes-virtuals.function.js +43 -0
- package/dist/functions/create-internal-axios-client.function.js +2 -2
- package/dist/functions/index.d.ts +1 -0
- package/dist/functions/index.js +3 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/interceptors/attribute-sanitizer.interceptor.d.ts +68 -0
- package/dist/interceptors/attribute-sanitizer.interceptor.js +154 -0
- package/dist/interceptors/index.d.ts +1 -0
- package/dist/interceptors/index.js +17 -0
- package/dist/middleware/http-logging.middleware.d.ts +19 -0
- package/dist/middleware/http-logging.middleware.js +50 -0
- package/dist/middleware/index.d.ts +1 -0
- package/dist/middleware/index.js +17 -0
- package/dist/models/account.model.d.ts +23 -0
- package/dist/models/account.model.js +59 -0
- package/dist/models/index.d.ts +3 -1
- package/dist/models/index.js +7 -3
- package/dist/{modules/search/models → models}/search-document.model.d.ts +1 -1
- package/dist/{modules/search/models → models}/search-document.model.js +1 -1
- package/dist/models/{account-entity.model.d.ts → user.model.d.ts} +8 -21
- package/dist/models/{account-entity.model.js → user.model.js} +11 -25
- package/dist/modules/authentication/authentication-module-options.interface.d.ts +2 -8
- package/dist/modules/authentication/authentication-options.parameter.d.ts +4 -0
- package/dist/modules/authentication/{inject-auth-options.decorator.js → authentication-options.parameter.js} +5 -2
- package/dist/modules/authentication/authentication.module.d.ts +23 -0
- package/dist/modules/authentication/authentication.module.js +24 -1
- package/dist/modules/authentication/guards/index.d.ts +2 -2
- package/dist/modules/authentication/guards/index.js +7 -7
- package/dist/modules/authentication/guards/jwt-auth.guard.d.ts +17 -0
- package/dist/modules/authentication/guards/jwt-auth.guard.js +67 -0
- package/dist/modules/authentication/guards/permissions.guard.d.ts +5 -27
- package/dist/modules/authentication/guards/permissions.guard.js +27 -59
- package/dist/modules/authentication/guards/public.guard.d.ts +7 -13
- package/dist/modules/authentication/guards/public.guard.js +10 -24
- package/dist/modules/authentication/guards/service-auth.guard.d.ts +22 -0
- package/dist/modules/authentication/guards/service-auth.guard.js +65 -0
- package/dist/modules/authentication/index.d.ts +3 -3
- package/dist/modules/authentication/index.js +3 -5
- package/dist/modules/cache/cache-response.interceptor.d.ts +2 -2
- package/dist/modules/cache/cache-response.interceptor.js +2 -2
- package/dist/modules/cache/index.d.ts +1 -0
- package/dist/modules/cache/index.js +1 -0
- package/dist/modules/comment/comment-module-options.interface.d.ts +38 -0
- package/dist/modules/comment/comment.controller.d.ts +24 -30
- package/dist/modules/comment/comment.controller.js +59 -61
- package/dist/modules/comment/comment.module-definition.d.ts +1 -42
- package/dist/modules/comment/comment.module-definition.js +1 -2
- package/dist/modules/comment/comment.module.d.ts +13 -13
- package/dist/modules/comment/comment.module.js +15 -42
- package/dist/modules/comment/comment.service.d.ts +27 -37
- package/dist/modules/comment/comment.service.js +50 -84
- package/dist/modules/comment/index.d.ts +2 -3
- package/dist/modules/comment/index.js +16 -7
- package/dist/modules/database/database.module.js +2 -5
- package/dist/modules/database/index.d.ts +2 -5
- package/dist/modules/database/index.js +17 -9
- package/dist/modules/index.d.ts +2 -6
- package/dist/modules/index.js +2 -6
- package/dist/modules/like/index.d.ts +2 -1
- package/dist/modules/like/index.js +16 -3
- package/dist/modules/like/like-module-options.interface.d.ts +21 -0
- package/dist/modules/like/like.controller.d.ts +45 -37
- package/dist/modules/like/like.controller.js +117 -102
- package/dist/modules/like/like.module-definition.d.ts +1 -17
- package/dist/modules/like/like.module-definition.js +1 -2
- package/dist/modules/like/like.module.d.ts +12 -12
- package/dist/modules/like/like.module.js +14 -37
- package/dist/modules/like/like.service.d.ts +31 -27
- package/dist/modules/like/like.service.js +42 -35
- package/dist/modules/merge/index.d.ts +3 -0
- package/dist/modules/merge/index.js +19 -0
- package/dist/modules/merge/merge-module-options.interface.d.ts +21 -0
- package/dist/modules/merge/merge.controller.d.ts +30 -0
- package/dist/modules/merge/merge.controller.js +76 -0
- package/dist/modules/merge/merge.module.d.ts +18 -0
- package/dist/modules/merge/merge.module.js +41 -0
- package/dist/modules/merge/merge.service.interface.d.ts +17 -0
- package/dist/modules/services/base-http.service.d.ts +83 -0
- package/dist/modules/services/base-http.service.js +124 -0
- package/dist/modules/services/base-urls.d.ts +22 -0
- package/dist/modules/services/base-urls.js +121 -0
- package/dist/modules/services/index.d.ts +4 -0
- package/dist/modules/services/index.js +20 -0
- package/dist/modules/services/providers/accounts.service.d.ts +52 -0
- package/dist/modules/services/providers/accounts.service.js +84 -0
- package/dist/modules/services/providers/books.service.d.ts +29 -0
- package/dist/modules/services/providers/books.service.js +55 -0
- package/dist/modules/services/providers/changelog.service.d.ts +18 -0
- package/dist/modules/services/providers/changelog.service.js +43 -0
- package/dist/modules/services/providers/comments/comments.service-definition.d.ts +1 -0
- package/dist/modules/services/providers/comments/comments.service-definition.js +4 -0
- package/dist/modules/services/providers/comments/comments.service.d.ts +60 -0
- package/dist/modules/services/providers/comments/comments.service.js +139 -0
- package/dist/modules/services/providers/comments/index.d.ts +1 -0
- package/dist/{factories → modules/services/providers/comments}/index.js +1 -1
- package/dist/modules/services/providers/content/content-return-types.d.ts +19 -0
- package/dist/modules/services/providers/content/content-return-types.js +7 -0
- package/dist/modules/services/providers/content/content.service-definition.d.ts +1 -0
- package/dist/modules/services/providers/content/content.service-definition.js +4 -0
- package/dist/modules/services/providers/content/content.service.d.ts +96 -0
- package/dist/modules/services/providers/content/content.service.js +231 -0
- package/dist/modules/services/providers/content/index.d.ts +2 -0
- package/dist/modules/{search/models → services/providers/content}/index.js +1 -1
- package/dist/modules/services/providers/demo-hive.service.d.ts +29 -0
- package/dist/modules/services/providers/demo-hive.service.js +55 -0
- package/dist/modules/services/providers/events.service.d.ts +29 -0
- package/dist/modules/services/providers/events.service.js +55 -0
- package/dist/modules/services/providers/hackschool.service.d.ts +49 -0
- package/dist/modules/services/providers/hackschool.service.js +79 -0
- package/dist/modules/services/providers/ideas.service.d.ts +18 -0
- package/dist/modules/services/providers/ideas.service.js +43 -0
- package/dist/modules/services/providers/index.d.ts +19 -0
- package/dist/modules/services/providers/index.js +35 -0
- package/dist/modules/services/providers/lunch-roulette.service.d.ts +18 -0
- package/dist/modules/services/providers/lunch-roulette.service.js +43 -0
- package/dist/modules/services/providers/mail/index.d.ts +3 -0
- package/dist/modules/services/providers/mail/index.js +19 -0
- package/dist/modules/services/providers/mail/mail-types.d.ts +30 -0
- package/dist/modules/services/providers/mail/mail-types.js +22 -0
- package/dist/modules/services/providers/mail/mail.service.d.ts +99 -0
- package/dist/modules/{mail → services/providers/mail}/mail.service.js +55 -92
- package/dist/modules/services/providers/newletter.service.d.ts +29 -0
- package/dist/modules/services/providers/newletter.service.js +55 -0
- package/dist/modules/services/providers/newsroom.service.d.ts +47 -0
- package/dist/modules/services/providers/newsroom.service.js +73 -0
- package/dist/modules/services/providers/notification/dtos/schedule-notification.dto.js +2 -0
- package/dist/modules/services/providers/notification/index.d.ts +2 -0
- package/dist/modules/services/providers/notification/index.js +18 -0
- package/dist/modules/services/providers/notification/notification.service-definition.d.ts +1 -0
- package/dist/modules/services/providers/notification/notification.service-definition.js +4 -0
- package/dist/modules/services/providers/notification/notification.service.d.ts +50 -0
- package/dist/modules/services/providers/notification/notification.service.js +130 -0
- package/dist/modules/services/providers/pass/dtos/create-guild-member-pass.dto.js +2 -0
- package/dist/modules/services/providers/pass/dtos/create-team-member-pass.dto.js +2 -0
- package/dist/modules/services/providers/pass/index.d.ts +2 -0
- package/dist/modules/services/providers/pass/index.js +18 -0
- package/dist/modules/services/providers/pass/pass-types.d.ts +18 -0
- package/dist/modules/services/providers/pass/pass-types.js +7 -0
- package/dist/modules/{pass → services/providers/pass}/pass.service.d.ts +15 -39
- package/dist/modules/{pass → services/providers/pass}/pass.service.js +46 -61
- package/dist/modules/services/providers/podcasts.service.d.ts +29 -0
- package/dist/modules/services/providers/podcasts.service.js +55 -0
- package/dist/modules/services/providers/search/dtos/index-search-document.dto.js +2 -0
- package/dist/modules/services/providers/search/index.d.ts +2 -0
- package/dist/modules/services/providers/search/index.js +18 -0
- package/dist/modules/services/providers/search/search.service-definition.d.ts +1 -0
- package/dist/modules/services/providers/search/search.service-definition.js +4 -0
- package/dist/modules/services/providers/search/search.service.d.ts +66 -0
- package/dist/modules/services/providers/search/search.service.js +171 -0
- package/dist/modules/services/providers/team.service.d.ts +29 -0
- package/dist/modules/services/providers/team.service.js +55 -0
- package/dist/modules/services/providers/tech-radar.service.d.ts +39 -0
- package/dist/modules/services/providers/tech-radar.service.js +67 -0
- package/dist/modules/services/services-module-options.interface.d.ts +4 -0
- package/dist/modules/services/services-module-options.interface.js +2 -0
- package/dist/modules/services/services-options.parameter.d.ts +1 -0
- package/dist/modules/services/services-options.parameter.js +8 -0
- package/dist/modules/services/services.module-definition.d.ts +16 -0
- package/dist/modules/services/services.module-definition.js +21 -0
- package/dist/modules/services/services.module.d.ts +17 -0
- package/dist/modules/services/services.module.js +63 -0
- package/dist/pipes/index.d.ts +2 -3
- package/dist/pipes/index.js +2 -3
- package/dist/pipes/params/hub-id.pipe.d.ts +22 -0
- package/dist/pipes/{hub-id.pipe.js → params/hub-id.pipe.js} +14 -17
- package/dist/pipes/params/hub-resource.pipe.d.ts +22 -0
- package/dist/pipes/{hub-resource.pipe.js → params/hub-resource.pipe.js} +19 -20
- package/dist/pipes/params/index.d.ts +3 -0
- package/dist/pipes/params/index.js +19 -0
- package/dist/pipes/params/mongo-id.pipe.d.ts +15 -0
- package/dist/pipes/params/mongo-id.pipe.js +52 -0
- package/dist/pipes/queries/index.d.ts +3 -0
- package/dist/pipes/queries/index.js +19 -0
- package/dist/pipes/queries/mongo-ids.pipe.d.ts +22 -0
- package/dist/pipes/queries/mongo-ids.pipe.js +60 -0
- package/dist/pipes/queries/optional-boolean.pipe.d.ts +29 -0
- package/dist/pipes/queries/optional-boolean.pipe.js +72 -0
- package/dist/pipes/queries/optional-include-drafts.pipe.d.ts +28 -0
- package/dist/pipes/queries/optional-include-drafts.pipe.js +38 -0
- package/dist/properties/content-return-type.property.d.ts +7 -0
- package/dist/properties/content-return-type.property.js +22 -0
- package/dist/properties/index.d.ts +4 -0
- package/dist/properties/index.js +11 -0
- package/dist/properties/likeable.properties.d.ts +1 -0
- package/dist/properties/likeable.properties.js +66 -0
- package/dist/properties/viewable.properties.d.ts +1 -0
- package/dist/properties/viewable.properties.js +66 -0
- package/dist/swagger/index.d.ts +1 -0
- package/dist/swagger/index.js +5 -0
- package/dist/swagger/remove-public-route-auth.plugin.d.ts +9 -0
- package/dist/swagger/remove-public-route-auth.plugin.js +25 -0
- package/dist/swagger/swagger-options.interface.d.ts +14 -0
- package/dist/swagger/swagger-options.interface.js +2 -0
- package/dist/swagger/swagger.function.d.ts +11 -0
- package/dist/swagger/swagger.function.js +47 -0
- package/dist/transform/boolean.transform.js +3 -3
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +18 -0
- package/dist/types/likeable.type.d.ts +15 -0
- package/dist/types/likeable.type.js +2 -0
- package/dist/types/viewable.type.d.ts +15 -0
- package/dist/types/viewable.type.js +2 -0
- package/package.json +2 -2
- package/dist/classes/document-updater.class.d.ts +0 -39
- package/dist/classes/document-updater.class.js +0 -57
- package/dist/factories/index.d.ts +0 -1
- package/dist/factories/virtuals.factory.d.ts +0 -79
- package/dist/factories/virtuals.factory.js +0 -171
- package/dist/http-logger.middleware.d.ts +0 -12
- package/dist/http-logger.middleware.js +0 -43
- package/dist/likeable.interface.d.ts +0 -41
- package/dist/likeable.interface.js +0 -48
- package/dist/modules/authentication/guards/auth.guard.d.ts +0 -36
- package/dist/modules/authentication/guards/auth.guard.js +0 -107
- package/dist/modules/authentication/guards/internal.guard.d.ts +0 -33
- package/dist/modules/authentication/guards/internal.guard.js +0 -72
- package/dist/modules/authentication/inject-auth-options.decorator.d.ts +0 -1
- package/dist/modules/comment/comment.model.d.ts +0 -29
- package/dist/modules/comment/comment.model.js +0 -43
- package/dist/modules/content/content.module-definition.d.ts +0 -5
- package/dist/modules/content/content.module-definition.js +0 -8
- package/dist/modules/content/content.module.d.ts +0 -31
- package/dist/modules/content/content.module.js +0 -60
- package/dist/modules/content/content.service.d.ts +0 -50
- package/dist/modules/content/content.service.js +0 -145
- package/dist/modules/content/index.d.ts +0 -3
- package/dist/modules/content/index.js +0 -9
- package/dist/modules/database/model-service/dbs/hub-account.db.d.ts +0 -28
- package/dist/modules/database/model-service/dbs/hub-account.db.js +0 -44
- package/dist/modules/database/model-service/dbs/hub-books.db.d.ts +0 -23
- package/dist/modules/database/model-service/dbs/hub-books.db.js +0 -45
- package/dist/modules/database/model-service/dbs/hub-comments.db.d.ts +0 -29
- package/dist/modules/database/model-service/dbs/hub-comments.db.js +0 -68
- package/dist/modules/database/model-service/dbs/hub-content.db.d.ts +0 -24
- package/dist/modules/database/model-service/dbs/hub-content.db.js +0 -49
- package/dist/modules/database/model-service/dbs/hub-demo-hive.db.d.ts +0 -23
- package/dist/modules/database/model-service/dbs/hub-demo-hive.db.js +0 -45
- package/dist/modules/database/model-service/dbs/hub-events.db.d.ts +0 -24
- package/dist/modules/database/model-service/dbs/hub-events.db.js +0 -49
- package/dist/modules/database/model-service/dbs/hub-hackschool.db.d.ts +0 -60
- package/dist/modules/database/model-service/dbs/hub-hackschool.db.js +0 -106
- package/dist/modules/database/model-service/dbs/hub-newsroom.db.d.ts +0 -25
- package/dist/modules/database/model-service/dbs/hub-newsroom.db.js +0 -53
- package/dist/modules/database/model-service/dbs/hub-podcasts.db.d.ts +0 -23
- package/dist/modules/database/model-service/dbs/hub-podcasts.db.js +0 -45
- package/dist/modules/database/model-service/dbs/hub-team.db.d.ts +0 -22
- package/dist/modules/database/model-service/dbs/hub-team.db.js +0 -41
- package/dist/modules/database/model-service/dbs/hub-tech-radar.db.d.ts +0 -42
- package/dist/modules/database/model-service/dbs/hub-tech-radar.db.js +0 -81
- package/dist/modules/database/model-service/model.service.d.ts +0 -6407
- package/dist/modules/database/model-service/model.service.js +0 -136
- package/dist/modules/database/populate-service/populate.service.d.ts +0 -73
- package/dist/modules/database/populate-service/populate.service.js +0 -163
- package/dist/modules/database/service-mapper-service/service-mapper.service.d.ts +0 -32
- package/dist/modules/database/service-mapper-service/service-mapper.service.js +0 -73
- package/dist/modules/fetch/fetch.module.d.ts +0 -31
- package/dist/modules/fetch/fetch.module.js +0 -60
- package/dist/modules/fetch/fetch.service.d.ts +0 -153
- package/dist/modules/fetch/fetch.service.js +0 -274
- package/dist/modules/fetch/index.d.ts +0 -2
- package/dist/modules/fetch/index.js +0 -7
- package/dist/modules/mail/index.d.ts +0 -4
- package/dist/modules/mail/index.js +0 -23
- package/dist/modules/mail/mail.module.d.ts +0 -31
- package/dist/modules/mail/mail.module.js +0 -60
- package/dist/modules/mail/mail.service.d.ts +0 -136
- package/dist/modules/notification/index.d.ts +0 -3
- package/dist/modules/notification/index.js +0 -22
- package/dist/modules/notification/notification.module-definition.d.ts +0 -5
- package/dist/modules/notification/notification.module-definition.js +0 -8
- package/dist/modules/notification/notification.module.d.ts +0 -34
- package/dist/modules/notification/notification.module.js +0 -63
- package/dist/modules/notification/notification.service.d.ts +0 -42
- package/dist/modules/notification/notification.service.js +0 -100
- package/dist/modules/pass/index.d.ts +0 -3
- package/dist/modules/pass/index.js +0 -22
- package/dist/modules/pass/pass.module.d.ts +0 -32
- package/dist/modules/pass/pass.module.js +0 -61
- package/dist/modules/search/index.d.ts +0 -4
- package/dist/modules/search/index.js +0 -23
- package/dist/modules/search/models/index.d.ts +0 -1
- package/dist/modules/search/search.module-definition.d.ts +0 -5
- package/dist/modules/search/search.module-definition.js +0 -8
- package/dist/modules/search/search.module.d.ts +0 -33
- package/dist/modules/search/search.module.js +0 -62
- package/dist/modules/search/search.service.d.ts +0 -49
- package/dist/modules/search/search.service.js +0 -120
- package/dist/pipes/hub-id.pipe.d.ts +0 -22
- package/dist/pipes/hub-resource.pipe.d.ts +0 -22
- package/dist/pipes/mongo-id.pipe.d.ts +0 -14
- package/dist/pipes/mongo-id.pipe.js +0 -52
- package/dist/swagger.config.d.ts +0 -36
- package/dist/swagger.config.js +0 -76
- package/dist/viewable.interface.d.ts +0 -41
- package/dist/viewable.interface.js +0 -48
- /package/dist/modules/{mail/dtos/auth-login-token-mail.dto.js → comment/comment-module-options.interface.js} +0 -0
- /package/dist/modules/{mail/dtos/auth-password-reset-mail.dto.js → like/like-module-options.interface.js} +0 -0
- /package/dist/modules/{mail/dtos/event-cancel-mail.dto.js → merge/merge-module-options.interface.js} +0 -0
- /package/dist/modules/{mail/dtos/event-invite-mail.dto.js → merge/merge.service.interface.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/auth-login-token-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/idea-status-updated-mail.dto.js → services/providers/mail/dtos/auth-login-token-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/auth-password-reset-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/idea-submitted-mail.dto.js → services/providers/mail/dtos/auth-password-reset-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/event-cancel-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/lunch-roulette-cancel-mail.dto.js → services/providers/mail/dtos/event-cancel-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/event-invite-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/lunch-roulette-matched-mail.dto.js → services/providers/mail/dtos/event-invite-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/idea-status-updated-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/lunch-roulette-submitted-mail.dto.js → services/providers/mail/dtos/idea-status-updated-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/idea-submitted-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/lunch-roulette-unmatched-mail.dto.js → services/providers/mail/dtos/idea-submitted-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/index.d.ts +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/index.js +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-cancel-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/newsletter-issue-mail.dto.js → services/providers/mail/dtos/lunch-roulette-cancel-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-matched-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/newsletter-subscribed-mail.dto.js → services/providers/mail/dtos/lunch-roulette-matched-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-submitted-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/newsletter-unsubscribed-mail.dto.js → services/providers/mail/dtos/lunch-roulette-submitted-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/lunch-roulette-unmatched-mail.dto.d.ts +0 -0
- /package/dist/modules/{mail/dtos/notification-mail.dto.js → services/providers/mail/dtos/lunch-roulette-unmatched-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-issue-mail.dto.d.ts +0 -0
- /package/dist/modules/{notification/dtos/schedule-notification.dto.js → services/providers/mail/dtos/newsletter-issue-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-subscribed-mail.dto.d.ts +0 -0
- /package/dist/modules/{pass/dtos/create-guild-member-pass.dto.js → services/providers/mail/dtos/newsletter-subscribed-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/newsletter-unsubscribed-mail.dto.d.ts +0 -0
- /package/dist/modules/{pass/dtos/create-team-member-pass.dto.js → services/providers/mail/dtos/newsletter-unsubscribed-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/dtos/notification-mail.dto.d.ts +0 -0
- /package/dist/modules/{search/dtos/index-search-document.dto.js → services/providers/mail/dtos/notification-mail.dto.js} +0 -0
- /package/dist/modules/{mail → services/providers/mail}/models/index.d.ts +0 -0
- /package/dist/modules/{mail → services/providers/mail}/models/index.js +0 -0
- /package/dist/modules/{mail → services/providers/mail}/models/mail-recipient.model.d.ts +0 -0
- /package/dist/modules/{mail → services/providers/mail}/models/mail-recipient.model.js +0 -0
- /package/dist/modules/{notification → services/providers/notification}/dtos/index.d.ts +0 -0
- /package/dist/modules/{notification → services/providers/notification}/dtos/index.js +0 -0
- /package/dist/modules/{notification → services/providers/notification}/dtos/schedule-notification.dto.d.ts +0 -0
- /package/dist/modules/{pass → services/providers/pass}/dtos/create-guild-member-pass.dto.d.ts +0 -0
- /package/dist/modules/{pass → services/providers/pass}/dtos/create-team-member-pass.dto.d.ts +0 -0
- /package/dist/modules/{pass → services/providers/pass}/dtos/index.d.ts +0 -0
- /package/dist/modules/{pass → services/providers/pass}/dtos/index.js +0 -0
- /package/dist/modules/{search → services/providers/search}/dtos/index-search-document.dto.d.ts +0 -0
- /package/dist/modules/{search → services/providers/search}/dtos/index.d.ts +0 -0
- /package/dist/modules/{search → services/providers/search}/dtos/index.js +0 -0
- /package/dist/{modules/content → properties}/content.property.d.ts +0 -0
- /package/dist/{modules/content → properties}/content.property.js +0 -0
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.createLikeController = createLikeController;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const swagger_1 = require("@nestjs/swagger");
|
|
18
18
|
const decorators_1 = require("../../decorators");
|
|
@@ -20,106 +20,121 @@ const pipes_1 = require("../../pipes");
|
|
|
20
20
|
const authentication_1 = require("../authentication");
|
|
21
21
|
const like_service_1 = require("./like.service");
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
23
|
+
* Factory function for creating a LikeController bound to a specific route suffix.
|
|
24
24
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
* Why: Instead of writing separate controllers for each resource type,
|
|
26
|
+
* we generate one dynamically. This ensures DRY principles while still
|
|
27
|
+
* supporting custom routes (e.g. `/like/news` or `/like/event`).
|
|
28
|
+
*
|
|
29
|
+
* @param {string} [routeSuffix] - Suffix appended to the "like" route.
|
|
30
|
+
* @returns A dynamically generated controller class.
|
|
28
31
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
32
|
+
function createLikeController(routeSuffix) {
|
|
33
|
+
// Normalize route path, removing duplicate/trailing slashes
|
|
34
|
+
const normalizedRoute = `like/${routeSuffix}`.replace(/\/{2,}/g, '/').replace(/\/$/, '');
|
|
35
|
+
let LikeController = class LikeController {
|
|
36
|
+
constructor(likeService) {
|
|
37
|
+
this.likeService = likeService;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Adds the authenticated user's like to a given resource.
|
|
41
|
+
*
|
|
42
|
+
* Why: Prevents duplicate likes using `$addToSet`,
|
|
43
|
+
* ensuring idempotency of repeated requests.
|
|
44
|
+
*
|
|
45
|
+
* @param {string} resourceId - The MongoDB ObjectId of the resource.
|
|
46
|
+
* @param {string} accountId - The authenticated account performing the like.
|
|
47
|
+
* @returns {Promise<number>} The updated like count.
|
|
48
|
+
*/
|
|
49
|
+
async addLikeToResource(resourceId, accountId) {
|
|
50
|
+
return this.likeService.addLike(resourceId, accountId);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Removes the authenticated user's like from a given resource.
|
|
54
|
+
*
|
|
55
|
+
* Why: Uses `$pull` to ensure the user’s ID is removed only if present,
|
|
56
|
+
* maintaining database consistency without errors.
|
|
57
|
+
*
|
|
58
|
+
* @param {string} resourceId - The MongoDB ObjectId of the resource.
|
|
59
|
+
* @param {string} accountId - The authenticated account removing the like.
|
|
60
|
+
* @returns {Promise<number>} The updated like count.
|
|
61
|
+
*/
|
|
62
|
+
async removeLikeFromResource(resourceId, accountId) {
|
|
63
|
+
return this.likeService.removeLike(resourceId, accountId);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Determines whether the authenticated user has liked a given resource.
|
|
67
|
+
*
|
|
68
|
+
* Why: Useful for rendering UI states (e.g. "Like" vs. "Unlike" buttons)
|
|
69
|
+
* without fetching all likes.
|
|
70
|
+
*
|
|
71
|
+
* @param {string} resourceId - The MongoDB ObjectId of the resource.
|
|
72
|
+
* @param {string} accountId - The authenticated account to check.
|
|
73
|
+
* @returns {Promise<boolean>} True if the resource is liked by the user.
|
|
74
|
+
*/
|
|
75
|
+
async isResourceLikedByUser(resourceId, accountId) {
|
|
76
|
+
return this.likeService.hasLiked(resourceId, accountId);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
__decorate([
|
|
80
|
+
(0, swagger_1.ApiOperation)({
|
|
81
|
+
summary: 'Like a resource',
|
|
82
|
+
description: 'Registers a like from the authenticated user on the specified resource. ' +
|
|
83
|
+
'If the user has already liked it, the response still succeeds without creating a duplicate.',
|
|
84
|
+
}),
|
|
85
|
+
(0, swagger_1.ApiOkResponse)({
|
|
86
|
+
description: 'The total number of likes on the resource after this operation.',
|
|
87
|
+
schema: { type: 'number', example: 42 },
|
|
88
|
+
}),
|
|
89
|
+
(0, pipes_1.ApiMongoIdParam)('resourceId'),
|
|
90
|
+
(0, common_1.Put)(':resourceId'),
|
|
91
|
+
__param(0, (0, pipes_1.MongoIdParam)('resourceId')),
|
|
92
|
+
__param(1, (0, decorators_1.AuthenticatedAccount)('id')),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", [String, String]),
|
|
95
|
+
__metadata("design:returntype", Promise)
|
|
96
|
+
], LikeController.prototype, "addLikeToResource", null);
|
|
97
|
+
__decorate([
|
|
98
|
+
(0, swagger_1.ApiOperation)({
|
|
99
|
+
summary: 'Unlike a resource',
|
|
100
|
+
description: 'Removes the like from the authenticated user on the specified resource. ' +
|
|
101
|
+
'If the user has not liked it before, the resource remains unchanged.',
|
|
102
|
+
}),
|
|
103
|
+
(0, swagger_1.ApiNoContentResponse)({
|
|
104
|
+
description: 'The total number of likes on the resource after this operation.',
|
|
105
|
+
schema: { type: 'number', example: 41 },
|
|
106
|
+
}),
|
|
107
|
+
(0, pipes_1.ApiMongoIdParam)('resourceId'),
|
|
108
|
+
(0, common_1.Delete)(':resourceId'),
|
|
109
|
+
__param(0, (0, pipes_1.MongoIdParam)('resourceId')),
|
|
110
|
+
__param(1, (0, decorators_1.AuthenticatedAccount)('id')),
|
|
111
|
+
__metadata("design:type", Function),
|
|
112
|
+
__metadata("design:paramtypes", [String, String]),
|
|
113
|
+
__metadata("design:returntype", Promise)
|
|
114
|
+
], LikeController.prototype, "removeLikeFromResource", null);
|
|
115
|
+
__decorate([
|
|
116
|
+
(0, swagger_1.ApiOperation)({
|
|
117
|
+
summary: 'Check like status',
|
|
118
|
+
description: 'Determines whether the authenticated user has previously liked the specified resource. ' +
|
|
119
|
+
'Returns a boolean flag indicating the current like state.',
|
|
120
|
+
}),
|
|
121
|
+
(0, swagger_1.ApiOkResponse)({
|
|
122
|
+
description: 'True if the resource is liked by the authenticated user, false otherwise.',
|
|
123
|
+
schema: { type: 'boolean', example: true },
|
|
124
|
+
}),
|
|
125
|
+
(0, pipes_1.ApiMongoIdParam)('resourceId'),
|
|
126
|
+
(0, common_1.Get)(':resourceId'),
|
|
127
|
+
__param(0, (0, pipes_1.MongoIdParam)('resourceId')),
|
|
128
|
+
__param(1, (0, decorators_1.AuthenticatedAccount)('id')),
|
|
129
|
+
__metadata("design:type", Function),
|
|
130
|
+
__metadata("design:paramtypes", [String, String]),
|
|
131
|
+
__metadata("design:returntype", Promise)
|
|
132
|
+
], LikeController.prototype, "isResourceLikedByUser", null);
|
|
133
|
+
LikeController = __decorate([
|
|
134
|
+
(0, authentication_1.RequireJwtAuth)(),
|
|
135
|
+
(0, swagger_1.ApiTags)('Like'),
|
|
136
|
+
(0, common_1.Controller)(normalizedRoute),
|
|
137
|
+
__metadata("design:paramtypes", [like_service_1.LikeService])
|
|
138
|
+
], LikeController);
|
|
139
|
+
return LikeController;
|
|
140
|
+
}
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
import { ModelDefinition } from '@nestjs/mongoose';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*/
|
|
5
|
-
export type LikeModuleOptions = {
|
|
6
|
-
/**
|
|
7
|
-
* The Mongoose model definition representing the resource type to be liked.
|
|
8
|
-
*/
|
|
9
|
-
model: ModelDefinition;
|
|
10
|
-
/**
|
|
11
|
-
* Optional array of strings used to define the route path and API tag suffixes.
|
|
12
|
-
* Useful for scoping like functionality to different resource contexts (e.g., 'posts', 'comments').
|
|
13
|
-
*/
|
|
14
|
-
routeScope?: string[];
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Token used to inject LikeModule options into services or controllers if needed.
|
|
18
|
-
* Symbol is used to avoid accidental naming collisions across modules.
|
|
2
|
+
* Dependency injection token for LikeModule options.
|
|
19
3
|
*/
|
|
20
4
|
export declare const LIKE_MODULE_OPTIONS_TOKEN: unique symbol;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LIKE_MODULE_OPTIONS_TOKEN = void 0;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
* Symbol is used to avoid accidental naming collisions across modules.
|
|
5
|
+
* Dependency injection token for LikeModule options.
|
|
7
6
|
*/
|
|
8
7
|
exports.LIKE_MODULE_OPTIONS_TOKEN = Symbol('LIKE_MODULE_OPTIONS_TOKEN');
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { LikeModuleOptions } from './like
|
|
2
|
+
import { LikeModuleOptions } from './like-module-options.interface';
|
|
3
3
|
/**
|
|
4
|
-
* LikeModule dynamically registers controllers and services
|
|
5
|
-
*
|
|
4
|
+
* LikeModule dynamically registers controllers and services
|
|
5
|
+
* to handle "like" functionality for a given resource model.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* Why: Many resources (e.g. blogposts, events, demos) can be liked,
|
|
8
|
+
* but duplicating controller/service logic for each would be error-prone.
|
|
9
|
+
* Instead, this module centralizes the like-related logic, keeping it
|
|
10
|
+
* consistent while still allowing customization via options.
|
|
8
11
|
*/
|
|
9
12
|
export declare class LikeModule {
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
14
|
+
* Dynamically registers a LikeController bound to the provided model
|
|
15
|
+
* and optional route suffix.
|
|
12
16
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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.
|
|
17
|
+
* @param {LikeModuleOptions} options - Configuration for the resource model and route.
|
|
18
|
+
* @returns {DynamicModule} The dynamically created module definition.
|
|
19
19
|
*/
|
|
20
|
-
static
|
|
20
|
+
static forFeature(options: LikeModuleOptions): DynamicModule;
|
|
21
21
|
}
|
|
@@ -9,59 +9,36 @@ var LikeModule_1;
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.LikeModule = void 0;
|
|
11
11
|
const common_1 = require("@nestjs/common");
|
|
12
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
13
|
-
const itlab_functions_1 = require("itlab-functions");
|
|
14
12
|
const like_controller_1 = require("./like.controller");
|
|
15
13
|
const like_module_definition_1 = require("./like.module-definition");
|
|
16
14
|
const like_service_1 = require("./like.service");
|
|
17
15
|
/**
|
|
18
|
-
* LikeModule dynamically registers controllers and services
|
|
19
|
-
*
|
|
16
|
+
* LikeModule dynamically registers controllers and services
|
|
17
|
+
* to handle "like" functionality for a given resource model.
|
|
20
18
|
*
|
|
21
|
-
*
|
|
19
|
+
* Why: Many resources (e.g. blogposts, events, demos) can be liked,
|
|
20
|
+
* but duplicating controller/service logic for each would be error-prone.
|
|
21
|
+
* Instead, this module centralizes the like-related logic, keeping it
|
|
22
|
+
* consistent while still allowing customization via options.
|
|
22
23
|
*/
|
|
23
24
|
let LikeModule = LikeModule_1 = class LikeModule {
|
|
24
25
|
/**
|
|
25
|
-
*
|
|
26
|
+
* Dynamically registers a LikeController bound to the provided model
|
|
27
|
+
* and optional route suffix.
|
|
26
28
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
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.
|
|
29
|
+
* @param {LikeModuleOptions} options - Configuration for the resource model and route.
|
|
30
|
+
* @returns {DynamicModule} The dynamically created module definition.
|
|
33
31
|
*/
|
|
34
|
-
static
|
|
35
|
-
const
|
|
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);
|
|
32
|
+
static forFeature(options) {
|
|
33
|
+
const LikeController = (0, like_controller_1.createLikeController)(options.routeSuffix);
|
|
52
34
|
return {
|
|
53
35
|
module: LikeModule_1,
|
|
54
|
-
controllers: [LikeController],
|
|
55
36
|
providers: [like_service_1.LikeService, { provide: like_module_definition_1.LIKE_MODULE_OPTIONS_TOKEN, useValue: options }],
|
|
56
|
-
|
|
37
|
+
controllers: [LikeController],
|
|
57
38
|
};
|
|
58
39
|
}
|
|
59
40
|
};
|
|
60
41
|
exports.LikeModule = LikeModule;
|
|
61
42
|
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
|
-
})
|
|
43
|
+
(0, common_1.Module)({})
|
|
67
44
|
], LikeModule);
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Connection } from 'mongoose';
|
|
2
|
-
import { LikeModuleOptions } from './like
|
|
2
|
+
import { LikeModuleOptions } from './like-module-options.interface';
|
|
3
3
|
/**
|
|
4
|
-
* LikeService manages
|
|
4
|
+
* LikeService manages persistence and business logic
|
|
5
|
+
* for adding, removing, and verifying likes on resource entities.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* Why: Encapsulates MongoDB operations and ensures consistent handling
|
|
8
|
+
* of like-related behavior across all resources that support likes.
|
|
8
9
|
*/
|
|
9
10
|
export declare class LikeService {
|
|
10
11
|
private readonly moduleOptions;
|
|
@@ -12,50 +13,53 @@ export declare class LikeService {
|
|
|
12
13
|
private readonly logger;
|
|
13
14
|
private readonly likeModel;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Constructs the LikeService with a configured model instance.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
18
|
+
* Why: Using the provided Mongoose connection and model options ensures
|
|
19
|
+
* that likes are tied to the correct resource collection dynamically.
|
|
20
|
+
*
|
|
21
|
+
* @param {LikeModuleOptions} moduleOptions - Config for the likeable resource model.
|
|
22
|
+
* @param {Connection} connection - Mongoose database connection.
|
|
19
23
|
*/
|
|
20
24
|
constructor(moduleOptions: LikeModuleOptions, connection: Connection);
|
|
21
25
|
/**
|
|
22
|
-
*
|
|
26
|
+
* Safely retrieves the number of likes from a resource document.
|
|
23
27
|
*
|
|
24
|
-
* @param {Document & Likeable} [resource] - The resource document
|
|
25
|
-
* @returns {number}
|
|
28
|
+
* @param {Document & Likeable} [resource] - The resource document.
|
|
29
|
+
* @returns {number} Count of likes, or zero if not available.
|
|
26
30
|
*/
|
|
27
|
-
private
|
|
31
|
+
private countLikes;
|
|
28
32
|
/**
|
|
29
|
-
* Adds a like
|
|
33
|
+
* Adds a like from the specified account to a resource.
|
|
30
34
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
35
|
+
* Why: `$addToSet` prevents duplicates, ensuring data integrity
|
|
36
|
+
* when users attempt to like a resource multiple times.
|
|
33
37
|
*
|
|
34
|
-
* @param {string} resourceId - The
|
|
35
|
-
* @param {string} accountId - The account
|
|
38
|
+
* @param {string} resourceId - The resource’s ID.
|
|
39
|
+
* @param {string} accountId - The account ID adding the like.
|
|
36
40
|
* @returns {Promise<number>} The updated like count.
|
|
37
41
|
*/
|
|
38
42
|
addLike(resourceId: string, accountId: string): Promise<number>;
|
|
39
43
|
/**
|
|
40
|
-
* Removes a like from the specified
|
|
44
|
+
* Removes a like from the specified account on a resource.
|
|
41
45
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
46
|
+
* Why: `$pull` ensures the account is removed cleanly
|
|
47
|
+
* without affecting other users’ likes.
|
|
44
48
|
*
|
|
45
|
-
* @param {string} resourceId - The
|
|
46
|
-
* @param {string} accountId - The account
|
|
49
|
+
* @param {string} resourceId - The resource’s ID.
|
|
50
|
+
* @param {string} accountId - The account ID removing the like.
|
|
47
51
|
* @returns {Promise<number>} The updated like count.
|
|
48
52
|
*/
|
|
49
53
|
removeLike(resourceId: string, accountId: string): Promise<number>;
|
|
50
54
|
/**
|
|
51
|
-
*
|
|
55
|
+
* Verifies whether a given account has liked a resource.
|
|
52
56
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
57
|
+
* Why: Checking directly with MongoDB avoids fetching the full document,
|
|
58
|
+
* making it efficient for large `_likedBy` arrays.
|
|
55
59
|
*
|
|
56
|
-
* @param {string} resourceId - The resource
|
|
57
|
-
* @param {string} accountId - The account to
|
|
58
|
-
* @returns {Promise<boolean>} True if the account has liked the resource
|
|
60
|
+
* @param {string} resourceId - The resource ID.
|
|
61
|
+
* @param {string} accountId - The account ID to check.
|
|
62
|
+
* @returns {Promise<boolean>} True if the account has liked the resource.
|
|
59
63
|
*/
|
|
60
64
|
hasLiked(resourceId: string, accountId: string): Promise<boolean>;
|
|
61
65
|
}
|
|
@@ -19,79 +19,86 @@ const mongoose_1 = require("@nestjs/mongoose");
|
|
|
19
19
|
const mongoose_2 = require("mongoose");
|
|
20
20
|
const like_module_definition_1 = require("./like.module-definition");
|
|
21
21
|
/**
|
|
22
|
-
* LikeService manages
|
|
22
|
+
* LikeService manages persistence and business logic
|
|
23
|
+
* for adding, removing, and verifying likes on resource entities.
|
|
23
24
|
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
25
|
+
* Why: Encapsulates MongoDB operations and ensures consistent handling
|
|
26
|
+
* of like-related behavior across all resources that support likes.
|
|
26
27
|
*/
|
|
27
28
|
let LikeService = LikeService_1 = class LikeService {
|
|
28
29
|
/**
|
|
29
|
-
*
|
|
30
|
+
* Constructs the LikeService with a configured model instance.
|
|
30
31
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
32
|
+
* Why: Using the provided Mongoose connection and model options ensures
|
|
33
|
+
* that likes are tied to the correct resource collection dynamically.
|
|
34
|
+
*
|
|
35
|
+
* @param {LikeModuleOptions} moduleOptions - Config for the likeable resource model.
|
|
36
|
+
* @param {Connection} connection - Mongoose database connection.
|
|
33
37
|
*/
|
|
34
38
|
constructor(moduleOptions, connection) {
|
|
35
39
|
this.moduleOptions = moduleOptions;
|
|
36
40
|
this.connection = connection;
|
|
37
41
|
this.logger = new common_1.Logger(LikeService_1.name);
|
|
38
|
-
|
|
42
|
+
const { name, schema } = this.moduleOptions.model;
|
|
43
|
+
this.likeModel = this.connection.model(name, schema);
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
46
|
+
* Safely retrieves the number of likes from a resource document.
|
|
42
47
|
*
|
|
43
|
-
* @param {Document & Likeable} [resource] - The resource document
|
|
44
|
-
* @returns {number}
|
|
48
|
+
* @param {Document & Likeable} [resource] - The resource document.
|
|
49
|
+
* @returns {number} Count of likes, or zero if not available.
|
|
45
50
|
*/
|
|
46
|
-
|
|
51
|
+
countLikes(resource) {
|
|
47
52
|
var _a, _b;
|
|
48
53
|
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
54
|
}
|
|
50
55
|
/**
|
|
51
|
-
* Adds a like
|
|
56
|
+
* Adds a like from the specified account to a resource.
|
|
52
57
|
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
58
|
+
* Why: `$addToSet` prevents duplicates, ensuring data integrity
|
|
59
|
+
* when users attempt to like a resource multiple times.
|
|
55
60
|
*
|
|
56
|
-
* @param {string} resourceId - The
|
|
57
|
-
* @param {string} accountId - The account
|
|
61
|
+
* @param {string} resourceId - The resource’s ID.
|
|
62
|
+
* @param {string} accountId - The account ID adding the like.
|
|
58
63
|
* @returns {Promise<number>} The updated like count.
|
|
59
64
|
*/
|
|
60
65
|
async addLike(resourceId, accountId) {
|
|
61
|
-
this.logger.
|
|
66
|
+
this.logger.debug(`Account ${accountId} liked ${this.likeModel.name.toLowerCase()} resource ${resourceId}`);
|
|
62
67
|
const updatedResource = await this.likeModel.findOneAndUpdate({ _id: resourceId }, { $addToSet: { _likedBy: accountId } }, { new: true, upsert: false, timestamps: false });
|
|
63
|
-
return this.
|
|
68
|
+
return this.countLikes(updatedResource);
|
|
64
69
|
}
|
|
65
70
|
/**
|
|
66
|
-
* Removes a like from the specified
|
|
71
|
+
* Removes a like from the specified account on a resource.
|
|
67
72
|
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
73
|
+
* Why: `$pull` ensures the account is removed cleanly
|
|
74
|
+
* without affecting other users’ likes.
|
|
70
75
|
*
|
|
71
|
-
* @param {string} resourceId - The
|
|
72
|
-
* @param {string} accountId - The account
|
|
76
|
+
* @param {string} resourceId - The resource’s ID.
|
|
77
|
+
* @param {string} accountId - The account ID removing the like.
|
|
73
78
|
* @returns {Promise<number>} The updated like count.
|
|
74
79
|
*/
|
|
75
80
|
async removeLike(resourceId, accountId) {
|
|
76
|
-
this.logger.
|
|
81
|
+
this.logger.debug(`Account ${accountId} unliked ${this.likeModel.name.toLowerCase()} resource ${resourceId}`);
|
|
77
82
|
const updatedResource = await this.likeModel.findOneAndUpdate({ _id: resourceId }, { $pull: { _likedBy: accountId } }, { new: true, upsert: false, timestamps: false });
|
|
78
|
-
return this.
|
|
83
|
+
return this.countLikes(updatedResource);
|
|
79
84
|
}
|
|
80
85
|
/**
|
|
81
|
-
*
|
|
86
|
+
* Verifies whether a given account has liked a resource.
|
|
82
87
|
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
88
|
+
* Why: Checking directly with MongoDB avoids fetching the full document,
|
|
89
|
+
* making it efficient for large `_likedBy` arrays.
|
|
85
90
|
*
|
|
86
|
-
* @param {string} resourceId - The resource
|
|
87
|
-
* @param {string} accountId - The account to
|
|
88
|
-
* @returns {Promise<boolean>} True if the account has liked the resource
|
|
91
|
+
* @param {string} resourceId - The resource ID.
|
|
92
|
+
* @param {string} accountId - The account ID to check.
|
|
93
|
+
* @returns {Promise<boolean>} True if the account has liked the resource.
|
|
89
94
|
*/
|
|
90
95
|
async hasLiked(resourceId, accountId) {
|
|
91
|
-
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
this.logger.log(`Checking like status for account ${accountId} on ${this.likeModel.name.toLowerCase()} resource ${resourceId}`);
|
|
97
|
+
const resource = await this.likeModel.findOne({
|
|
98
|
+
_id: resourceId,
|
|
99
|
+
_likedBy: { $in: [accountId] },
|
|
100
|
+
});
|
|
101
|
+
return !!resource;
|
|
95
102
|
}
|
|
96
103
|
};
|
|
97
104
|
exports.LikeService = LikeService;
|