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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskManager = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* TaskManager is a utility class that collects asynchronous tasks
|
|
6
|
+
* and executes them in parallel.
|
|
7
|
+
*
|
|
8
|
+
* This is especially useful for orchestrating optional async operations
|
|
9
|
+
* where not all tasks need to be executed every time.
|
|
10
|
+
*
|
|
11
|
+
* Example:
|
|
12
|
+
* ```ts
|
|
13
|
+
* const taskManager = new TaskManager();
|
|
14
|
+
* taskManager.add(async () => { ... });
|
|
15
|
+
* taskManager.add(async () => { ... });
|
|
16
|
+
* await taskManager.run();
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
class TaskManager {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.tasks = [];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Fetches all users for the given ID groups and returns a mapping.
|
|
25
|
+
* Ensures each user is fetched only once.
|
|
26
|
+
* @param userIdGroups Array of arrays of user IDs (e.g., authors, likedBy, viewedBy)
|
|
27
|
+
* @param accountsService Service responsible for fetching users
|
|
28
|
+
* @returns Map of userId -> user
|
|
29
|
+
*/
|
|
30
|
+
static async fetchAndMapUsers(userIdGroups, accountsService) {
|
|
31
|
+
// Collect all unique user IDs across all groups
|
|
32
|
+
const uniqueUserIds = new Set(userIdGroups.flat());
|
|
33
|
+
// Fetch all users once
|
|
34
|
+
const userCollection = await accountsService.getUserCollection(Array.from(uniqueUserIds));
|
|
35
|
+
// Build a map for quick lookup
|
|
36
|
+
return new Map(userCollection.map((user) => [user.id, user]));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Fetches all users for the given ID groups and returns a mapping.
|
|
40
|
+
* Ensures each user is fetched only once.
|
|
41
|
+
* @param accountIdGroups Array of arrays of user IDs (e.g., authors, likedBy, viewedBy)
|
|
42
|
+
* @param accountsService Service responsible for fetching users
|
|
43
|
+
* @returns Map of userId -> user
|
|
44
|
+
*/
|
|
45
|
+
static async fetchAndMapAccounts(accountIdGroups, accountsService) {
|
|
46
|
+
// Collect all unique user IDs across all groups
|
|
47
|
+
const uniqueAccountIds = new Set(accountIdGroups.flat());
|
|
48
|
+
// Fetch all users once
|
|
49
|
+
const accountCollection = await accountsService.getAccountCollection(Array.from(uniqueAccountIds));
|
|
50
|
+
// Build a map for quick lookup
|
|
51
|
+
return new Map(accountCollection.map((account) => [account.id, account]));
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Maps an array of IDs to user objects using a userMap.
|
|
55
|
+
* Filters out any IDs that don’t have a corresponding user.
|
|
56
|
+
* @param userIds Array of user IDs to map
|
|
57
|
+
* @param userMap Map of userId -> user object
|
|
58
|
+
* @returns Array of user objects
|
|
59
|
+
*/
|
|
60
|
+
static mapIdsToUsers(userIds, userMap) {
|
|
61
|
+
return userIds.map((userId) => userMap.get(userId)).filter(Boolean);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Maps an array of IDs to user objects using a userMap.
|
|
65
|
+
* Filters out any IDs that don’t have a corresponding user.
|
|
66
|
+
* @param accountIds Array of user IDs to map
|
|
67
|
+
* @param accountMap Map of userId -> user object
|
|
68
|
+
* @returns Array of user objects
|
|
69
|
+
*/
|
|
70
|
+
static mapIdsToAccounts(accountIds, accountMap) {
|
|
71
|
+
return accountIds.map((accountId) => accountMap.get(accountId)).filter(Boolean);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Adds a new asynchronous task to the queue.
|
|
75
|
+
*
|
|
76
|
+
* @param task - A function that returns a Promise.
|
|
77
|
+
* It should contain the actual async logic to be executed.
|
|
78
|
+
*/
|
|
79
|
+
add(task) {
|
|
80
|
+
this.tasks.push(task);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Executes all queued tasks in parallel and waits for their completion.
|
|
84
|
+
*
|
|
85
|
+
* - Tasks are executed concurrently using `Promise.all`.
|
|
86
|
+
* - If one task fails, the error will propagate and stop execution.
|
|
87
|
+
*/
|
|
88
|
+
async run() {
|
|
89
|
+
await Promise.all(this.tasks.map((task) => task()));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Clears all tasks from the queue without executing them.
|
|
93
|
+
* Useful if you want to reset and reuse the TaskManager instance.
|
|
94
|
+
*/
|
|
95
|
+
clear() {
|
|
96
|
+
this.tasks = [];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.TaskManager = TaskManager;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Account } from '../models';
|
|
2
2
|
/**
|
|
3
3
|
* Custom parameter decorator to extract the authenticated user's account
|
|
4
4
|
* or a specific attribute from it within route handlers.
|
|
@@ -10,8 +10,8 @@ import { AccountEntity } from '../models';
|
|
|
10
10
|
* If no user account is found on the request, it throws an UnprocessableEntityException,
|
|
11
11
|
* signaling that the request is missing necessary authentication context.
|
|
12
12
|
*
|
|
13
|
-
* @param {keyof
|
|
13
|
+
* @param {keyof Account} [attribute] - Optional key of the Account to extract.
|
|
14
14
|
* @param {ExecutionContext} executionContext - The context of the current request.
|
|
15
|
-
* @returns {
|
|
15
|
+
* @returns {Account[keyof Account] | Account} The requested account attribute or full account object.
|
|
16
16
|
*/
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const AuthenticatedAccount: (...dataOrPipes: (keyof Account | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AuthenticatedAccount = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
+
const exceptions_1 = require("../exceptions");
|
|
5
6
|
/**
|
|
6
7
|
* Custom parameter decorator to extract the authenticated user's account
|
|
7
8
|
* or a specific attribute from it within route handlers.
|
|
@@ -13,16 +14,13 @@ const common_1 = require("@nestjs/common");
|
|
|
13
14
|
* If no user account is found on the request, it throws an UnprocessableEntityException,
|
|
14
15
|
* signaling that the request is missing necessary authentication context.
|
|
15
16
|
*
|
|
16
|
-
* @param {keyof
|
|
17
|
+
* @param {keyof Account} [attribute] - Optional key of the Account to extract.
|
|
17
18
|
* @param {ExecutionContext} executionContext - The context of the current request.
|
|
18
|
-
* @returns {
|
|
19
|
+
* @returns {Account[keyof Account] | Account} The requested account attribute or full account object.
|
|
19
20
|
*/
|
|
20
|
-
exports.
|
|
21
|
+
exports.AuthenticatedAccount = (0, common_1.createParamDecorator)((attribute, executionContext) => {
|
|
21
22
|
const request = executionContext.switchToHttp().getRequest();
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
// Return the requested attribute if specified; otherwise, return the entire account object.
|
|
27
|
-
return attribute ? userAccount[attribute] : userAccount;
|
|
23
|
+
if (!request.account)
|
|
24
|
+
throw new exceptions_1.AuthenticatedAccountRequiredException();
|
|
25
|
+
return attribute ? request.account[attribute] : request.account;
|
|
28
26
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './account.decorator';
|
|
1
|
+
export * from './authenticated-account.decorator';
|
|
2
2
|
export * from './jwt.decorator';
|
package/dist/decorators/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./account.decorator"), exports);
|
|
17
|
+
__exportStar(require("./authenticated-account.decorator"), exports);
|
|
18
18
|
__exportStar(require("./jwt.decorator"), exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ForbiddenException } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* AuthenticatedAccountRequiredException
|
|
4
|
+
*
|
|
5
|
+
* Custom exception extending NestJS's `ForbiddenException`.
|
|
6
|
+
* This should be thrown when a request is made to an endpoint that
|
|
7
|
+
* explicitly requires a Bearer Token for authentication.
|
|
8
|
+
*
|
|
9
|
+
* By centralizing the exception here, we ensure consistent error
|
|
10
|
+
* messaging and simplify future changes (e.g., localization or
|
|
11
|
+
* error structure updates).
|
|
12
|
+
*/
|
|
13
|
+
export declare class AuthenticatedAccountRequiredException extends ForbiddenException {
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new `AuthenticatedAccountRequiredException`.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} [message] - Optional custom error message.
|
|
18
|
+
* Defaults to a standard message if none is provided.
|
|
19
|
+
*/
|
|
20
|
+
constructor(message?: string);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* ApiAuthenticatedAccountRequiredResponse
|
|
24
|
+
*
|
|
25
|
+
* Swagger documentation decorator for endpoints that return a `403 Forbidden`
|
|
26
|
+
* when accessed without authentication. Applying this makes the generated
|
|
27
|
+
* API docs clear about the requirement for a Bearer Token and communicates
|
|
28
|
+
* the error condition to consumers.
|
|
29
|
+
*
|
|
30
|
+
* @param {string} [description] - Optional custom description for the response.
|
|
31
|
+
* Defaults to the standard authentication error message.
|
|
32
|
+
* @returns {MethodDecorator} - Swagger decorator marking a 403 forbidden response.
|
|
33
|
+
*/
|
|
34
|
+
export declare function ApiAuthenticatedAccountRequiredResponse(description?: string): MethodDecorator;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthenticatedAccountRequiredException = void 0;
|
|
4
|
+
exports.ApiAuthenticatedAccountRequiredResponse = ApiAuthenticatedAccountRequiredResponse;
|
|
5
|
+
const common_1 = require("@nestjs/common");
|
|
6
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
7
|
+
/**
|
|
8
|
+
* Default error message used when an endpoint is accessed without authentication.
|
|
9
|
+
* This provides a consistent and descriptive response to unauthorized users.
|
|
10
|
+
*/
|
|
11
|
+
const defaultAuthenticatedAccountRequiredErrorMessage = 'Authenticated user context is missing in the request.';
|
|
12
|
+
/**
|
|
13
|
+
* AuthenticatedAccountRequiredException
|
|
14
|
+
*
|
|
15
|
+
* Custom exception extending NestJS's `ForbiddenException`.
|
|
16
|
+
* This should be thrown when a request is made to an endpoint that
|
|
17
|
+
* explicitly requires a Bearer Token for authentication.
|
|
18
|
+
*
|
|
19
|
+
* By centralizing the exception here, we ensure consistent error
|
|
20
|
+
* messaging and simplify future changes (e.g., localization or
|
|
21
|
+
* error structure updates).
|
|
22
|
+
*/
|
|
23
|
+
class AuthenticatedAccountRequiredException extends common_1.ForbiddenException {
|
|
24
|
+
/**
|
|
25
|
+
* Creates a new `AuthenticatedAccountRequiredException`.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} [message] - Optional custom error message.
|
|
28
|
+
* Defaults to a standard message if none is provided.
|
|
29
|
+
*/
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message || defaultAuthenticatedAccountRequiredErrorMessage);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AuthenticatedAccountRequiredException = AuthenticatedAccountRequiredException;
|
|
35
|
+
/**
|
|
36
|
+
* ApiAuthenticatedAccountRequiredResponse
|
|
37
|
+
*
|
|
38
|
+
* Swagger documentation decorator for endpoints that return a `403 Forbidden`
|
|
39
|
+
* when accessed without authentication. Applying this makes the generated
|
|
40
|
+
* API docs clear about the requirement for a Bearer Token and communicates
|
|
41
|
+
* the error condition to consumers.
|
|
42
|
+
*
|
|
43
|
+
* @param {string} [description] - Optional custom description for the response.
|
|
44
|
+
* Defaults to the standard authentication error message.
|
|
45
|
+
* @returns {MethodDecorator} - Swagger decorator marking a 403 forbidden response.
|
|
46
|
+
*/
|
|
47
|
+
function ApiAuthenticatedAccountRequiredResponse(description) {
|
|
48
|
+
return (0, swagger_1.ApiForbiddenResponse)({
|
|
49
|
+
description: description || defaultAuthenticatedAccountRequiredErrorMessage,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -2,26 +2,37 @@ import { UnprocessableEntityException } from '@nestjs/common';
|
|
|
2
2
|
/**
|
|
3
3
|
* BadBodyException
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* or
|
|
5
|
+
* Custom exception extending NestJS's `UnprocessableEntityException`.
|
|
6
|
+
* This exception should be thrown when the request body fails validation
|
|
7
|
+
* or cannot be interpreted correctly by the server.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
9
|
+
* Typical scenarios include:
|
|
10
|
+
* - Missing required fields
|
|
11
|
+
* - Incorrect or unexpected data types
|
|
12
|
+
* - Values violating schema constraints or business rules
|
|
13
|
+
*
|
|
14
|
+
* By encapsulating this exception, we provide a clear and consistent
|
|
15
|
+
* mechanism for handling client input errors across the application.
|
|
10
16
|
*/
|
|
11
17
|
export declare class BadBodyException extends UnprocessableEntityException {
|
|
12
18
|
/**
|
|
13
|
-
*
|
|
19
|
+
* Constructs a new `BadBodyException`.
|
|
14
20
|
*
|
|
15
|
-
* @param {string} [message] - Optional error message
|
|
21
|
+
* @param {string} [message] - Optional custom error message for additional context.
|
|
22
|
+
* Defaults to a standardized message if not provided.
|
|
16
23
|
*/
|
|
17
24
|
constructor(message?: string);
|
|
18
25
|
}
|
|
19
26
|
/**
|
|
20
27
|
* ApiBadBodyResponse
|
|
21
28
|
*
|
|
22
|
-
* Swagger decorator for
|
|
29
|
+
* Swagger documentation decorator for `422 Unprocessable Entity` responses.
|
|
30
|
+
* Apply this to routes that may reject invalid or malformed request bodies.
|
|
31
|
+
* This ensures the generated API documentation communicates the validation
|
|
32
|
+
* expectations and error conditions to API consumers.
|
|
23
33
|
*
|
|
24
34
|
* @param {string} [description] - Optional custom description for the response.
|
|
25
|
-
*
|
|
35
|
+
* Defaults to a standardized message if not provided.
|
|
36
|
+
* @returns {MethodDecorator} - Swagger method decorator marking the response.
|
|
26
37
|
*/
|
|
27
38
|
export declare function ApiBadBodyResponse(description?: string): MethodDecorator;
|
|
@@ -4,36 +4,52 @@ exports.BadBodyException = void 0;
|
|
|
4
4
|
exports.ApiBadBodyResponse = ApiBadBodyResponse;
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
7
|
+
/**
|
|
8
|
+
* Default error message returned when the request body cannot be processed.
|
|
9
|
+
* This ensures consistency across thrown exceptions and documented responses.
|
|
10
|
+
*/
|
|
11
|
+
const defaultBadBodyErrorMessage = 'The request body is invalid or malformed.';
|
|
7
12
|
/**
|
|
8
13
|
* BadBodyException
|
|
9
14
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* or
|
|
15
|
+
* Custom exception extending NestJS's `UnprocessableEntityException`.
|
|
16
|
+
* This exception should be thrown when the request body fails validation
|
|
17
|
+
* or cannot be interpreted correctly by the server.
|
|
18
|
+
*
|
|
19
|
+
* Typical scenarios include:
|
|
20
|
+
* - Missing required fields
|
|
21
|
+
* - Incorrect or unexpected data types
|
|
22
|
+
* - Values violating schema constraints or business rules
|
|
13
23
|
*
|
|
14
|
-
*
|
|
24
|
+
* By encapsulating this exception, we provide a clear and consistent
|
|
25
|
+
* mechanism for handling client input errors across the application.
|
|
15
26
|
*/
|
|
16
27
|
class BadBodyException extends common_1.UnprocessableEntityException {
|
|
17
28
|
/**
|
|
18
|
-
*
|
|
29
|
+
* Constructs a new `BadBodyException`.
|
|
19
30
|
*
|
|
20
|
-
* @param {string} [message] - Optional error message
|
|
31
|
+
* @param {string} [message] - Optional custom error message for additional context.
|
|
32
|
+
* Defaults to a standardized message if not provided.
|
|
21
33
|
*/
|
|
22
34
|
constructor(message) {
|
|
23
|
-
super(message ||
|
|
35
|
+
super(message || defaultBadBodyErrorMessage);
|
|
24
36
|
}
|
|
25
37
|
}
|
|
26
38
|
exports.BadBodyException = BadBodyException;
|
|
27
39
|
/**
|
|
28
40
|
* ApiBadBodyResponse
|
|
29
41
|
*
|
|
30
|
-
* Swagger decorator for
|
|
42
|
+
* Swagger documentation decorator for `422 Unprocessable Entity` responses.
|
|
43
|
+
* Apply this to routes that may reject invalid or malformed request bodies.
|
|
44
|
+
* This ensures the generated API documentation communicates the validation
|
|
45
|
+
* expectations and error conditions to API consumers.
|
|
31
46
|
*
|
|
32
47
|
* @param {string} [description] - Optional custom description for the response.
|
|
33
|
-
*
|
|
48
|
+
* Defaults to a standardized message if not provided.
|
|
49
|
+
* @returns {MethodDecorator} - Swagger method decorator marking the response.
|
|
34
50
|
*/
|
|
35
51
|
function ApiBadBodyResponse(description) {
|
|
36
52
|
return (0, swagger_1.ApiUnprocessableEntityResponse)({
|
|
37
|
-
description: description ||
|
|
53
|
+
description: description || defaultBadBodyErrorMessage,
|
|
38
54
|
});
|
|
39
55
|
}
|
|
@@ -2,25 +2,40 @@ import { BadRequestException } from '@nestjs/common';
|
|
|
2
2
|
/**
|
|
3
3
|
* BadParameterException
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Custom exception extending NestJS's `BadRequestException`.
|
|
6
|
+
* This exception is thrown when one or more request parameters (query,
|
|
7
|
+
* route, or body) are invalid or malformed.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* Common scenarios:
|
|
10
|
+
* - Query string contains unexpected or invalid values
|
|
11
|
+
* - Route parameters fail validation
|
|
12
|
+
* - Request body includes fields that do not conform to expected types
|
|
13
|
+
*
|
|
14
|
+
* By encapsulating this exception, we standardize error responses for
|
|
15
|
+
* invalid parameters and provide consistent error messaging across the API.
|
|
9
16
|
*/
|
|
10
17
|
export declare class BadParameterException extends BadRequestException {
|
|
11
18
|
/**
|
|
12
|
-
* Constructs a BadParameterException
|
|
19
|
+
* Constructs a new `BadParameterException`.
|
|
13
20
|
*
|
|
14
|
-
* @param {string} [parameter] -
|
|
21
|
+
* @param {string} [parameter] - Optional name of the invalid parameter.
|
|
22
|
+
* If provided, the message will reference that parameter directly.
|
|
15
23
|
*/
|
|
16
24
|
constructor(parameter?: string);
|
|
17
25
|
}
|
|
18
26
|
/**
|
|
19
27
|
* ApiBadParameterResponse
|
|
20
28
|
*
|
|
21
|
-
* Swagger decorator for
|
|
29
|
+
* Swagger documentation decorator for `400 Bad Request` responses caused
|
|
30
|
+
* by invalid request parameters. This makes it explicit in API docs that
|
|
31
|
+
* certain routes may reject requests with malformed or unsupported input.
|
|
32
|
+
*
|
|
33
|
+
* The decorator dynamically adjusts the description based on the provided
|
|
34
|
+
* parameter names, making documentation precise and self-explanatory.
|
|
22
35
|
*
|
|
23
|
-
* @param {string
|
|
24
|
-
*
|
|
36
|
+
* @param {...string} params - One or more invalid parameter names to
|
|
37
|
+
* include in the response description. If none are provided, a generic
|
|
38
|
+
* description is used instead.
|
|
39
|
+
* @returns {MethodDecorator} - Swagger method decorator for a 400 response.
|
|
25
40
|
*/
|
|
26
41
|
export declare function ApiBadParameterResponse(...params: string[]): MethodDecorator;
|
|
@@ -8,38 +8,61 @@ const itlab_functions_1 = require("itlab-functions");
|
|
|
8
8
|
/**
|
|
9
9
|
* BadParameterException
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* Custom exception extending NestJS's `BadRequestException`.
|
|
12
|
+
* This exception is thrown when one or more request parameters (query,
|
|
13
|
+
* route, or body) are invalid or malformed.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
+
* Common scenarios:
|
|
16
|
+
* - Query string contains unexpected or invalid values
|
|
17
|
+
* - Route parameters fail validation
|
|
18
|
+
* - Request body includes fields that do not conform to expected types
|
|
19
|
+
*
|
|
20
|
+
* By encapsulating this exception, we standardize error responses for
|
|
21
|
+
* invalid parameters and provide consistent error messaging across the API.
|
|
15
22
|
*/
|
|
16
23
|
class BadParameterException extends common_1.BadRequestException {
|
|
17
24
|
/**
|
|
18
|
-
* Constructs a BadParameterException
|
|
25
|
+
* Constructs a new `BadParameterException`.
|
|
19
26
|
*
|
|
20
|
-
* @param {string} [parameter] -
|
|
27
|
+
* @param {string} [parameter] - Optional name of the invalid parameter.
|
|
28
|
+
* If provided, the message will reference that parameter directly.
|
|
21
29
|
*/
|
|
22
30
|
constructor(parameter) {
|
|
23
|
-
super(parameter ? `Invalid parameter: ${parameter}` : 'One or more parameters are invalid.');
|
|
31
|
+
super(parameter ? `Invalid parameter: ${parameter}` : 'One or more request parameters are invalid.');
|
|
24
32
|
}
|
|
25
33
|
}
|
|
26
34
|
exports.BadParameterException = BadParameterException;
|
|
27
35
|
/**
|
|
28
36
|
* ApiBadParameterResponse
|
|
29
37
|
*
|
|
30
|
-
* Swagger decorator for
|
|
38
|
+
* Swagger documentation decorator for `400 Bad Request` responses caused
|
|
39
|
+
* by invalid request parameters. This makes it explicit in API docs that
|
|
40
|
+
* certain routes may reject requests with malformed or unsupported input.
|
|
41
|
+
*
|
|
42
|
+
* The decorator dynamically adjusts the description based on the provided
|
|
43
|
+
* parameter names, making documentation precise and self-explanatory.
|
|
31
44
|
*
|
|
32
|
-
* @param {string
|
|
33
|
-
*
|
|
45
|
+
* @param {...string} params - One or more invalid parameter names to
|
|
46
|
+
* include in the response description. If none are provided, a generic
|
|
47
|
+
* description is used instead.
|
|
48
|
+
* @returns {MethodDecorator} - Swagger method decorator for a 400 response.
|
|
34
49
|
*/
|
|
35
50
|
function ApiBadParameterResponse(...params) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
const decorator = (target, propertyKey, descriptor) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
// Extract existing Swagger metadata for this method (if any).
|
|
54
|
+
const existingResponses = Reflect.getMetadata('swagger/apiResponse', (descriptor === null || descriptor === void 0 ? void 0 : descriptor.value) || target) || {};
|
|
55
|
+
// Collect any already-registered bad request description.
|
|
56
|
+
const existingDescription = (_b = (_a = existingResponses === null || existingResponses === void 0 ? void 0 : existingResponses[400]) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : '';
|
|
57
|
+
// Format description with proper pluralization.
|
|
58
|
+
const pluralized = params.length > 1 ? 's' : '';
|
|
59
|
+
const newDescription = params.length
|
|
60
|
+
? `Invalid parameter${pluralized}: ${(0, itlab_functions_1.formatList)(params, 'or')}`
|
|
61
|
+
: 'One or more request parameters are invalid.';
|
|
62
|
+
// Merge with existing description if needed.
|
|
63
|
+
const mergedDescription = existingDescription ? `${existingDescription}<br />${newDescription}` : newDescription;
|
|
64
|
+
// Apply merged Swagger metadata.
|
|
65
|
+
(0, swagger_1.ApiBadRequestResponse)({ description: mergedDescription })(target, propertyKey, descriptor);
|
|
66
|
+
};
|
|
67
|
+
return decorator;
|
|
45
68
|
}
|
|
@@ -2,25 +2,37 @@ import { ConflictException } from '@nestjs/common';
|
|
|
2
2
|
/**
|
|
3
3
|
* DuplicateException
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Custom exception extending NestJS's `ConflictException`.
|
|
6
|
+
* This should be thrown when an operation attempts to create or register
|
|
7
|
+
* an entity that violates a uniqueness constraint or already exists in the system.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* Typical scenarios include:
|
|
10
|
+
* - Attempting to register a username or email already in use
|
|
11
|
+
* - Inserting database records that violate unique constraints
|
|
12
|
+
* - Uploading or creating resources with duplicate identifiers
|
|
13
|
+
*
|
|
14
|
+
* Returning a standardized `409 Conflict` response helps API consumers
|
|
15
|
+
* distinguish duplication errors from other kinds of client-side mistakes.
|
|
9
16
|
*/
|
|
10
17
|
export declare class DuplicateException extends ConflictException {
|
|
11
18
|
/**
|
|
12
|
-
*
|
|
19
|
+
* Creates a new `DuplicateException`.
|
|
13
20
|
*
|
|
14
|
-
* @param {string} [message] - Optional
|
|
21
|
+
* @param {string} [message] - Optional custom error message describing
|
|
22
|
+
* the specific duplication issue. Defaults to a standardized message if omitted.
|
|
15
23
|
*/
|
|
16
24
|
constructor(message?: string);
|
|
17
25
|
}
|
|
18
26
|
/**
|
|
19
27
|
* ApiDuplicateResponse
|
|
20
28
|
*
|
|
21
|
-
* Swagger decorator for
|
|
29
|
+
* Swagger documentation decorator for `409 Conflict` responses caused
|
|
30
|
+
* by duplicate resource creation attempts. Applying this decorator
|
|
31
|
+
* ensures that the generated API docs communicate uniqueness constraints
|
|
32
|
+
* and possible error conditions clearly to consumers.
|
|
22
33
|
*
|
|
23
|
-
* @param {string} [description] - Optional description
|
|
24
|
-
*
|
|
34
|
+
* @param {string} [description] - Optional custom description of the duplication error.
|
|
35
|
+
* Defaults to a standardized message if omitted.
|
|
36
|
+
* @returns {MethodDecorator} - Swagger method decorator for documenting conflict responses.
|
|
25
37
|
*/
|
|
26
38
|
export declare function ApiDuplicateResponse(description?: string): MethodDecorator;
|
|
@@ -4,35 +4,52 @@ exports.DuplicateException = void 0;
|
|
|
4
4
|
exports.ApiDuplicateResponse = ApiDuplicateResponse;
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
6
|
const swagger_1 = require("@nestjs/swagger");
|
|
7
|
+
/**
|
|
8
|
+
* Default error message used when a duplicate resource is encountered.
|
|
9
|
+
* This ensures consistent error responses and simplifies reuse across the app.
|
|
10
|
+
*/
|
|
11
|
+
const defaultDuplicateResourceMessage = 'A resource with the same value already exists.';
|
|
7
12
|
/**
|
|
8
13
|
* DuplicateException
|
|
9
14
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
15
|
+
* Custom exception extending NestJS's `ConflictException`.
|
|
16
|
+
* This should be thrown when an operation attempts to create or register
|
|
17
|
+
* an entity that violates a uniqueness constraint or already exists in the system.
|
|
18
|
+
*
|
|
19
|
+
* Typical scenarios include:
|
|
20
|
+
* - Attempting to register a username or email already in use
|
|
21
|
+
* - Inserting database records that violate unique constraints
|
|
22
|
+
* - Uploading or creating resources with duplicate identifiers
|
|
12
23
|
*
|
|
13
|
-
*
|
|
24
|
+
* Returning a standardized `409 Conflict` response helps API consumers
|
|
25
|
+
* distinguish duplication errors from other kinds of client-side mistakes.
|
|
14
26
|
*/
|
|
15
27
|
class DuplicateException extends common_1.ConflictException {
|
|
16
28
|
/**
|
|
17
|
-
*
|
|
29
|
+
* Creates a new `DuplicateException`.
|
|
18
30
|
*
|
|
19
|
-
* @param {string} [message] - Optional
|
|
31
|
+
* @param {string} [message] - Optional custom error message describing
|
|
32
|
+
* the specific duplication issue. Defaults to a standardized message if omitted.
|
|
20
33
|
*/
|
|
21
34
|
constructor(message) {
|
|
22
|
-
super(message ||
|
|
35
|
+
super(message || defaultDuplicateResourceMessage);
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
exports.DuplicateException = DuplicateException;
|
|
26
39
|
/**
|
|
27
40
|
* ApiDuplicateResponse
|
|
28
41
|
*
|
|
29
|
-
* Swagger decorator for
|
|
42
|
+
* Swagger documentation decorator for `409 Conflict` responses caused
|
|
43
|
+
* by duplicate resource creation attempts. Applying this decorator
|
|
44
|
+
* ensures that the generated API docs communicate uniqueness constraints
|
|
45
|
+
* and possible error conditions clearly to consumers.
|
|
30
46
|
*
|
|
31
|
-
* @param {string} [description] - Optional description
|
|
32
|
-
*
|
|
47
|
+
* @param {string} [description] - Optional custom description of the duplication error.
|
|
48
|
+
* Defaults to a standardized message if omitted.
|
|
49
|
+
* @returns {MethodDecorator} - Swagger method decorator for documenting conflict responses.
|
|
33
50
|
*/
|
|
34
51
|
function ApiDuplicateResponse(description) {
|
|
35
52
|
return (0, swagger_1.ApiConflictResponse)({
|
|
36
|
-
description: description ||
|
|
53
|
+
description: description || defaultDuplicateResourceMessage,
|
|
37
54
|
});
|
|
38
55
|
}
|
package/dist/exceptions/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./authenticated-user-required.exception"), exports);
|
|
17
18
|
__exportStar(require("./bad-body.exception"), exports);
|
|
18
19
|
__exportStar(require("./bad-parameter.exception"), exports);
|
|
19
20
|
__exportStar(require("./duplicate.exception"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Document, Schema } from 'mongoose';
|
|
2
|
+
/**
|
|
3
|
+
* Enhances a Mongoose schema by adding virtual fields for computed values.
|
|
4
|
+
*
|
|
5
|
+
* This function inspects the schema's definition for special tracking arrays
|
|
6
|
+
* (such as `_viewedBy` or `_likedBy`). If those arrays exist, it adds
|
|
7
|
+
* corresponding virtual properties (`views` and `likes`) to the schema.
|
|
8
|
+
* These virtuals provide a clean way to access the number of views or likes
|
|
9
|
+
* without needing to calculate them manually each time.
|
|
10
|
+
*
|
|
11
|
+
* @template T - A type extending the Mongoose Document interface.
|
|
12
|
+
* @param {Schema<T>} schema - The Mongoose schema to augment with virtuals.
|
|
13
|
+
* @returns {void} - Modifies the schema in place; no return value.
|
|
14
|
+
*/
|
|
15
|
+
export declare function addViewsLikesVirtuals<T extends Document>(schema: Schema<T>): void;
|