itlab-internal-services 2.15.6 → 2.16.0
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 +3 -5
- package/dist/classes/index.d.ts +1 -0
- package/dist/classes/index.js +3 -1
- package/dist/classes/report-category.class.d.ts +55 -0
- package/dist/classes/report-category.class.js +120 -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 -19
- 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 +2 -2
- package/dist/index.js +2 -2
- package/dist/likeable.interface.d.ts +1 -1
- package/dist/likeable.interface.js +2 -2
- 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 +73 -0
- package/dist/modules/authentication/guards/permissions.guard.d.ts +5 -27
- package/dist/modules/authentication/guards/permissions.guard.js +26 -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 +82 -0
- package/dist/modules/services/providers/books.service.d.ts +29 -0
- package/dist/modules/services/providers/books.service.js +53 -0
- package/dist/modules/services/providers/changelog.service.d.ts +18 -0
- package/dist/modules/services/providers/changelog.service.js +41 -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 +138 -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-types.d.ts +20 -0
- package/dist/modules/services/providers/content/content-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 +94 -0
- package/dist/modules/services/providers/content/content.service.js +214 -0
- package/dist/modules/services/providers/content/index.d.ts +1 -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 +53 -0
- package/dist/modules/services/providers/events.service.d.ts +29 -0
- package/dist/modules/services/providers/events.service.js +53 -0
- package/dist/modules/services/providers/hackschool.service.d.ts +49 -0
- package/dist/modules/services/providers/hackschool.service.js +77 -0
- package/dist/modules/services/providers/ideas.service.d.ts +18 -0
- package/dist/modules/services/providers/ideas.service.js +41 -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 +41 -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 +54 -91
- package/dist/modules/services/providers/newletter.service.d.ts +29 -0
- package/dist/modules/services/providers/newletter.service.js +53 -0
- package/dist/modules/services/providers/newsroom.service.d.ts +47 -0
- package/dist/modules/services/providers/newsroom.service.js +71 -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 +53 -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 +53 -0
- package/dist/modules/services/providers/tech-radar.service.d.ts +39 -0
- package/dist/modules/services/providers/tech-radar.service.js +65 -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/index.d.ts +1 -0
- package/dist/properties/index.js +5 -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/viewable.interface.js +1 -1
- package/package.json +2 -2
- 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/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/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
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# IT Lab Internal Services
|
|
2
|
+
|
|
2
3
|
> Diese Library funktioniert nur mit NestJs
|
|
3
4
|
|
|
4
5
|
[](https://www.npmjs.org/package/itlab-internal-services)
|
|
@@ -17,190 +18,3 @@ To begin using it, we first install the required dependency.
|
|
|
17
18
|
```bash
|
|
18
19
|
yarn add itlab-internal-services
|
|
19
20
|
```
|
|
20
|
-
|
|
21
|
-
### Getting started
|
|
22
|
-
|
|
23
|
-
Once the installation process is complete, to use the `InternalServices`, first import `InternalModule`.
|
|
24
|
-
|
|
25
|
-
```typescript
|
|
26
|
-
@Module({
|
|
27
|
-
imports: [InternalModule],
|
|
28
|
-
providers: [NewsService],
|
|
29
|
-
})
|
|
30
|
-
export class NewsModule {}
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
Next, inject `CommentService`, `ContentService` or `SearchService` using normal constructor injection.
|
|
34
|
-
|
|
35
|
-
> **Hint** `InternalModule`, `CommentService`, `ContentService` & `SearchService` are imported from `itlab-internal-services` package.
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
@Injectable()
|
|
39
|
-
export class NewsService {
|
|
40
|
-
constructor(
|
|
41
|
-
private readonly commentService: CommentService,
|
|
42
|
-
private readonly contentService: ContentService,
|
|
43
|
-
private readonly searchService: SearchService,
|
|
44
|
-
) {}
|
|
45
|
-
}
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Comment Service
|
|
49
|
-
```typescript
|
|
50
|
-
async post(targetId: string, authorId: string, comment: Comment): Promise<Comment>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
async delete(targetId: string): Promise<void>
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
### Content Service
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
async verify(content: Content): Promise<void>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
async post(targetId: string, content: Content): Promise<void>
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
```typescript
|
|
68
|
-
async delete(targetId: string): Promise<void>
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Pipes
|
|
72
|
-
```typescript
|
|
73
|
-
@Controller("news")
|
|
74
|
-
export class NewsController {
|
|
75
|
-
|
|
76
|
-
@ApiTarget("target")
|
|
77
|
-
@Get(":target")
|
|
78
|
-
getNews(@Target("target") target: string) {}
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
@Controller("news")
|
|
85
|
-
export class NewsController {
|
|
86
|
-
|
|
87
|
-
@ApiHid("hid")
|
|
88
|
-
@Get(":hid")
|
|
89
|
-
getNews(@Hid("hid") hid: string) {}
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
```typescript
|
|
95
|
-
@Controller("news")
|
|
96
|
-
export class NewsController {
|
|
97
|
-
|
|
98
|
-
@ApiId("id")
|
|
99
|
-
@Get(":id")
|
|
100
|
-
getNews(@Id("id") id: string) {}
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
### Guards
|
|
106
|
-
```typescript
|
|
107
|
-
@Internal()
|
|
108
|
-
@Controller()
|
|
109
|
-
export class NewsController {}
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
```typescript
|
|
113
|
-
@Jwt()
|
|
114
|
-
@Controller()
|
|
115
|
-
export class NewsController {
|
|
116
|
-
@Get("")
|
|
117
|
-
getNews(@Account() account: LAccount) {}
|
|
118
|
-
|
|
119
|
-
@Get("")
|
|
120
|
-
getNews(@AccountId() accountId: string) {}
|
|
121
|
-
|
|
122
|
-
@Perms("perms.get", "perms.list")
|
|
123
|
-
@Get("")
|
|
124
|
-
getNews(@AccountId() accountId: string, @AccountPerms() accountPerms: string[]) {}
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### Configuration
|
|
129
|
-
|
|
130
|
-
To configure the underlying service instance, pass an optional options object to the `register()` method of `InternalModule` when importing it. This options object will be passed directly to the underlying service constructor.
|
|
131
|
-
|
|
132
|
-
```typescript
|
|
133
|
-
@Module({
|
|
134
|
-
imports: [
|
|
135
|
-
InternalModule.register({
|
|
136
|
-
target: Targets.NEWSROOM,
|
|
137
|
-
token: 'itlab token',
|
|
138
|
-
jwt_secret: 'secret',
|
|
139
|
-
}),
|
|
140
|
-
],
|
|
141
|
-
providers: [NewsService],
|
|
142
|
-
})
|
|
143
|
-
export class NewsModule {}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### Async configuration
|
|
147
|
-
|
|
148
|
-
When you need to pass module options asynchronously instead of statically, use the `registerAsync()` method. As with most dynamic modules, this package provides several techniques to deal with async configuration.
|
|
149
|
-
|
|
150
|
-
One technique is to use a factory function:
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
InternalModule.registerAsync({
|
|
154
|
-
useFactory: () => ({
|
|
155
|
-
target: Targets.NEWSROOM,
|
|
156
|
-
token: 'itlab token',
|
|
157
|
-
jwt_secret: 'secret',
|
|
158
|
-
}),
|
|
159
|
-
});
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
Like other factory providers, our factory function can be [async](https://docs.nestjs.com/fundamentals/custom-providers#factory-providers-usefactory) and can inject dependencies through `inject`.
|
|
163
|
-
|
|
164
|
-
```typescript
|
|
165
|
-
InternalModule.registerAsync({
|
|
166
|
-
imports: [ConfigModule],
|
|
167
|
-
useFactory: (configService: ConfigService) => ({
|
|
168
|
-
target: Targets.NEWSROOM,
|
|
169
|
-
token: configService.get<string>('K8S_TOKEN'),
|
|
170
|
-
jwt_secret: configService.get<string>('JWT_SECRET'),
|
|
171
|
-
}),
|
|
172
|
-
inject: [ConfigService],
|
|
173
|
-
});
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
Alternatively, you can configure the `InternalModule` using a class instead of a factory, as shown below.
|
|
177
|
-
|
|
178
|
-
```typescript
|
|
179
|
-
InternalModule.registerAsync({
|
|
180
|
-
useClass: InternalConfigService,
|
|
181
|
-
});
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
The construction above instantiates `InternalConfigService` inside `InternalModule`, using it to create an options object. Note that in this example, the `InternalConfigService` has to implement `InternalModuleOptionsFactory` interface as shown below. The `InternalModule` will call the `createInternalOptions()` method on the instantiated object of the supplied class.
|
|
185
|
-
|
|
186
|
-
```typescript
|
|
187
|
-
@Injectable()
|
|
188
|
-
class InternalConfigService implements InternalModuleOptionsFactory {
|
|
189
|
-
createInternalOptions(): InternalModuleOptions {
|
|
190
|
-
return {
|
|
191
|
-
target: Targets.NEWSROOM,
|
|
192
|
-
token: 'itlab token',
|
|
193
|
-
jwt_secret: 'secret',
|
|
194
|
-
};
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
If you want to reuse an existing options provider instead of creating a private copy inside the `InternalModule`, use the `useExisting` syntax.
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
InternalModule.registerAsync({
|
|
203
|
-
imports: [ConfigModule],
|
|
204
|
-
useExisting: InternalConfigService,
|
|
205
|
-
});
|
|
206
|
-
```
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocumentMerger = void 0;
|
|
4
4
|
const common_1 = require("@nestjs/common");
|
|
5
|
-
const itlab_functions_1 = require("itlab-functions");
|
|
6
5
|
/**
|
|
7
6
|
* DocumentMerger
|
|
8
7
|
*
|
|
@@ -51,8 +50,7 @@ class DocumentMerger {
|
|
|
51
50
|
async merge(transform) {
|
|
52
51
|
const startTime = Date.now();
|
|
53
52
|
const cursor = this.model.find().cursor();
|
|
54
|
-
|
|
55
|
-
for (let doc = await cursor.next(); doc != null; doc = await cursor.next()) {
|
|
53
|
+
await cursor.eachAsync(async (doc) => {
|
|
56
54
|
// Apply user-defined transformation if provided
|
|
57
55
|
if (transform) {
|
|
58
56
|
doc = transform(doc);
|
|
@@ -74,10 +72,10 @@ class DocumentMerger {
|
|
|
74
72
|
}
|
|
75
73
|
// Save changes to the database without updating timestamps
|
|
76
74
|
await doc.save({ timestamps: false });
|
|
77
|
-
}
|
|
75
|
+
});
|
|
78
76
|
const elapsedTime = Date.now() - startTime;
|
|
79
77
|
// Log completion with fields merged and time taken
|
|
80
|
-
this.logger.log(`Successfully merged fields: ${(
|
|
78
|
+
this.logger.log(`Successfully merged fields: ${this.fields.join(', ')} (took ${elapsedTime} ms)`);
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
exports.DocumentMerger = DocumentMerger;
|
package/dist/classes/index.d.ts
CHANGED
package/dist/classes/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocumentUpdater = exports.DocumentMerger = void 0;
|
|
3
|
+
exports.ReportCategory = exports.DocumentUpdater = exports.DocumentMerger = void 0;
|
|
4
4
|
var document_merger_class_1 = require("./document-merger.class");
|
|
5
5
|
Object.defineProperty(exports, "DocumentMerger", { enumerable: true, get: function () { return document_merger_class_1.DocumentMerger; } });
|
|
6
6
|
var document_updater_class_1 = require("./document-updater.class");
|
|
7
7
|
Object.defineProperty(exports, "DocumentUpdater", { enumerable: true, get: function () { return document_updater_class_1.DocumentUpdater; } });
|
|
8
|
+
var report_category_class_1 = require("./report-category.class");
|
|
9
|
+
Object.defineProperty(exports, "ReportCategory", { enumerable: true, get: function () { return report_category_class_1.ReportCategory; } });
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Document } from 'mongoose';
|
|
2
|
+
/**
|
|
3
|
+
* Defines which array-type attributes of a document should be tracked,
|
|
4
|
+
* along with human-readable labels for reporting.
|
|
5
|
+
*
|
|
6
|
+
* Only attributes of type `string[]` are tracked.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
* { genres: "Genres", tags: "Tags" }
|
|
10
|
+
*/
|
|
11
|
+
type ReportCategoryAttributes<T extends Document> = Partial<{
|
|
12
|
+
[K in keyof Omit<T, keyof Document> as T[K] extends string[] ? K : never]: string;
|
|
13
|
+
}>;
|
|
14
|
+
type ReportCategoryExport = Array<{
|
|
15
|
+
id: string;
|
|
16
|
+
} & Record<string, number>>;
|
|
17
|
+
/**
|
|
18
|
+
* ReportCategory
|
|
19
|
+
*
|
|
20
|
+
* Manages multiple AttributeAggregator instances, each associated
|
|
21
|
+
* with a unique entity key (e.g., organization, category).
|
|
22
|
+
* Provides methods to insert documents and export aggregated reports.
|
|
23
|
+
*
|
|
24
|
+
* @template T - A Mongoose document type with array attributes to track.
|
|
25
|
+
*/
|
|
26
|
+
export declare class ReportCategory<T extends Document> {
|
|
27
|
+
private aggregators;
|
|
28
|
+
private attributes;
|
|
29
|
+
/**
|
|
30
|
+
* Initializes the report manager with the attributes to track.
|
|
31
|
+
*
|
|
32
|
+
* @param attributes - Mapping of document array attributes to display labels.
|
|
33
|
+
*/
|
|
34
|
+
constructor(attributes: ReportCategoryAttributes<T>);
|
|
35
|
+
/**
|
|
36
|
+
* Inserts a document into one or multiple entity aggregators.
|
|
37
|
+
* Automatically creates the aggregator if it does not exist.
|
|
38
|
+
*
|
|
39
|
+
* @param document - The document to insert.
|
|
40
|
+
* @param entityKeys - Single or multiple entity identifiers.
|
|
41
|
+
*/
|
|
42
|
+
insertDocument(document: T, entityKeys: string[] | string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Exports aggregated statistics for all entities.
|
|
45
|
+
*
|
|
46
|
+
* Each object contains:
|
|
47
|
+
* - id: Entity key
|
|
48
|
+
* - documents: Number of documents processed for this entity
|
|
49
|
+
* - totalX / uniqueX: Aggregated counts for each tracked attribute
|
|
50
|
+
*
|
|
51
|
+
* @returns An array of aggregated reports for all entities.
|
|
52
|
+
*/
|
|
53
|
+
export(): ReportCategoryExport;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportCategory = void 0;
|
|
4
|
+
const itlab_functions_1 = require("itlab-functions");
|
|
5
|
+
/**
|
|
6
|
+
* AttributeAggregator
|
|
7
|
+
*
|
|
8
|
+
* Responsible for aggregating statistics for specified array attributes
|
|
9
|
+
* across multiple document records. Tracks both total counts and
|
|
10
|
+
* unique values for each attribute.
|
|
11
|
+
*
|
|
12
|
+
* @template T - A Mongoose document type with array attributes to track.
|
|
13
|
+
*/
|
|
14
|
+
class AttributeAggregator {
|
|
15
|
+
/**
|
|
16
|
+
* Initializes the aggregator with the attributes to track.
|
|
17
|
+
*
|
|
18
|
+
* @param attributes - Mapping of document array attributes to display labels.
|
|
19
|
+
*/
|
|
20
|
+
constructor(attributes) {
|
|
21
|
+
this.documents = 0;
|
|
22
|
+
this.totalCounts = new Map();
|
|
23
|
+
this.uniqueValues = new Map();
|
|
24
|
+
this.attributes = attributes;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Processes a single document, updating the total and unique value counts
|
|
28
|
+
* for each tracked attribute.
|
|
29
|
+
*
|
|
30
|
+
* @param document - The document to include in aggregation.
|
|
31
|
+
*/
|
|
32
|
+
processDocument(document) {
|
|
33
|
+
this.documents++;
|
|
34
|
+
for (const attribute of Object.keys(this.attributes)) {
|
|
35
|
+
const values = document[attribute];
|
|
36
|
+
// Only handle array attributes
|
|
37
|
+
if (!Array.isArray(values))
|
|
38
|
+
continue;
|
|
39
|
+
// Update total count for this attribute
|
|
40
|
+
const previousTotal = this.totalCounts.get(attribute) || 0;
|
|
41
|
+
this.totalCounts.set(attribute, previousTotal + values.length);
|
|
42
|
+
// Update the set of unique values for this attribute
|
|
43
|
+
const currentUnique = this.uniqueValues.get(attribute) || new Set();
|
|
44
|
+
values.forEach((value) => currentUnique.add(String(value)));
|
|
45
|
+
this.uniqueValues.set(attribute, currentUnique);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Exports aggregated statistics for this aggregator.
|
|
50
|
+
*
|
|
51
|
+
* Returns an object containing:
|
|
52
|
+
* - documents: Number of documents processed
|
|
53
|
+
* - totalX: Total count of values for each attribute
|
|
54
|
+
* - uniqueX: Count of unique values for each attribute
|
|
55
|
+
*
|
|
56
|
+
* @returns An object representing the aggregated data.
|
|
57
|
+
*/
|
|
58
|
+
export() {
|
|
59
|
+
var _a;
|
|
60
|
+
const report = {};
|
|
61
|
+
for (const [attribute, label] of Object.entries(this.attributes)) {
|
|
62
|
+
const capitalizedLabel = (0, itlab_functions_1.capitalize)(label);
|
|
63
|
+
report[`total${capitalizedLabel}`] = this.totalCounts.get(attribute) || 0;
|
|
64
|
+
report[`unique${capitalizedLabel}`] = ((_a = this.uniqueValues.get(attribute)) === null || _a === void 0 ? void 0 : _a.size) || 0;
|
|
65
|
+
}
|
|
66
|
+
return Object.assign({ documents: this.documents }, report);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* ReportCategory
|
|
71
|
+
*
|
|
72
|
+
* Manages multiple AttributeAggregator instances, each associated
|
|
73
|
+
* with a unique entity key (e.g., organization, category).
|
|
74
|
+
* Provides methods to insert documents and export aggregated reports.
|
|
75
|
+
*
|
|
76
|
+
* @template T - A Mongoose document type with array attributes to track.
|
|
77
|
+
*/
|
|
78
|
+
class ReportCategory {
|
|
79
|
+
/**
|
|
80
|
+
* Initializes the report manager with the attributes to track.
|
|
81
|
+
*
|
|
82
|
+
* @param attributes - Mapping of document array attributes to display labels.
|
|
83
|
+
*/
|
|
84
|
+
constructor(attributes) {
|
|
85
|
+
this.aggregators = new Map();
|
|
86
|
+
this.attributes = attributes;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Inserts a document into one or multiple entity aggregators.
|
|
90
|
+
* Automatically creates the aggregator if it does not exist.
|
|
91
|
+
*
|
|
92
|
+
* @param document - The document to insert.
|
|
93
|
+
* @param entityKeys - Single or multiple entity identifiers.
|
|
94
|
+
*/
|
|
95
|
+
insertDocument(document, entityKeys) {
|
|
96
|
+
var _a;
|
|
97
|
+
const keys = Array.isArray(entityKeys) ? entityKeys : [entityKeys];
|
|
98
|
+
for (const key of keys) {
|
|
99
|
+
const aggregator = (_a = this.aggregators.get(key)) !== null && _a !== void 0 ? _a : new AttributeAggregator(this.attributes);
|
|
100
|
+
aggregator.processDocument(document);
|
|
101
|
+
this.aggregators.set(key, aggregator);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Exports aggregated statistics for all entities.
|
|
106
|
+
*
|
|
107
|
+
* Each object contains:
|
|
108
|
+
* - id: Entity key
|
|
109
|
+
* - documents: Number of documents processed for this entity
|
|
110
|
+
* - totalX / uniqueX: Aggregated counts for each tracked attribute
|
|
111
|
+
*
|
|
112
|
+
* @returns An array of aggregated reports for all entities.
|
|
113
|
+
*/
|
|
114
|
+
export() {
|
|
115
|
+
return Array.from(this.aggregators.entries()).map(([id, aggregator]) => {
|
|
116
|
+
return Object.assign({ id }, aggregator.export());
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
exports.ReportCategory = ReportCategory;
|
|
@@ -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;
|