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
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
|
-
```
|
|
@@ -51,8 +51,7 @@ class DocumentMerger {
|
|
|
51
51
|
async merge(transform) {
|
|
52
52
|
const startTime = Date.now();
|
|
53
53
|
const cursor = this.model.find().cursor();
|
|
54
|
-
|
|
55
|
-
for (let doc = await cursor.next(); doc != null; doc = await cursor.next()) {
|
|
54
|
+
await cursor.eachAsync(async (doc) => {
|
|
56
55
|
// Apply user-defined transformation if provided
|
|
57
56
|
if (transform) {
|
|
58
57
|
doc = transform(doc);
|
|
@@ -74,7 +73,7 @@ class DocumentMerger {
|
|
|
74
73
|
}
|
|
75
74
|
// Save changes to the database without updating timestamps
|
|
76
75
|
await doc.save({ timestamps: false });
|
|
77
|
-
}
|
|
76
|
+
});
|
|
78
77
|
const elapsedTime = Date.now() - startTime;
|
|
79
78
|
// Log completion with fields merged and time taken
|
|
80
79
|
this.logger.log(`Successfully merged fields: ${(0, itlab_functions_1.formatList)(this.fields)} (took ${elapsedTime} ms)`);
|
package/dist/classes/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { DocumentMerger } from './document-merger.class';
|
|
2
|
-
export {
|
|
2
|
+
export { ReportCategory } from './report-category.class';
|
|
3
|
+
export { SchemaBuilder } from './schema-builder.class';
|
|
4
|
+
export type { SchemaBuilderDocument, SchemaBuilderModel, SchemaBuilderOptions } from './schema-builder.class';
|
|
5
|
+
export { TaskManager } from './task-manager.class';
|
package/dist/classes/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TaskManager = exports.SchemaBuilder = exports.ReportCategory = 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
|
-
var
|
|
7
|
-
Object.defineProperty(exports, "
|
|
6
|
+
var report_category_class_1 = require("./report-category.class");
|
|
7
|
+
Object.defineProperty(exports, "ReportCategory", { enumerable: true, get: function () { return report_category_class_1.ReportCategory; } });
|
|
8
|
+
var schema_builder_class_1 = require("./schema-builder.class");
|
|
9
|
+
Object.defineProperty(exports, "SchemaBuilder", { enumerable: true, get: function () { return schema_builder_class_1.SchemaBuilder; } });
|
|
10
|
+
var task_manager_class_1 = require("./task-manager.class");
|
|
11
|
+
Object.defineProperty(exports, "TaskManager", { enumerable: true, get: function () { return task_manager_class_1.TaskManager; } });
|
|
@@ -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;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { Document, Model, Schema } from 'mongoose';
|
|
3
|
+
import { Likeable, Viewable } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Options that determine how the schema should be extended.
|
|
6
|
+
*
|
|
7
|
+
* @template TClass - The document type for the schema.
|
|
8
|
+
*/
|
|
9
|
+
export type SchemaBuilderOptions<TClass extends Document> = {
|
|
10
|
+
/** Whether this schema should support view tracking. */
|
|
11
|
+
viewable?: boolean;
|
|
12
|
+
/** Whether this schema should support like tracking. */
|
|
13
|
+
likeable?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* A set of keys that uniquely identify the document.
|
|
16
|
+
* These keys are used when checking for duplicates.
|
|
17
|
+
*/
|
|
18
|
+
criticalKeys?: (keyof Omit<TClass, keyof Document>)[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Computes the augmented document type based on SchemaOptions.
|
|
22
|
+
*/
|
|
23
|
+
export type SchemaBuilderDocument<TClass extends Document, TOptions extends SchemaBuilderOptions<TClass>> = TClass & (TOptions['viewable'] extends true ? Viewable : object) & (TOptions['likeable'] extends true ? Likeable : object);
|
|
24
|
+
/**
|
|
25
|
+
* Extends a standard Mongoose model with custom static methods
|
|
26
|
+
* injected by the SchemaBuilder.
|
|
27
|
+
*/
|
|
28
|
+
export type SchemaBuilderModel<TClass extends Document> = Model<TClass> & {
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the given object is a duplicate of an existing document.
|
|
31
|
+
*
|
|
32
|
+
* @param dto - Partial object with properties to check for duplicates.
|
|
33
|
+
* @param updateTarget - The document being updated, if applicable.
|
|
34
|
+
* @returns {Promise<boolean>} - True if a duplicate exists, false otherwise.
|
|
35
|
+
*/
|
|
36
|
+
isDuplicate(dto: Partial<TClass>, updateTarget?: TClass): Promise<boolean>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Generic builder for creating extended Mongoose schemas.
|
|
40
|
+
*
|
|
41
|
+
* This class wraps Nest's SchemaFactory and automatically injects common
|
|
42
|
+
* behaviors such as:
|
|
43
|
+
* - View tracking (who viewed, view counts)
|
|
44
|
+
* - Like tracking (who liked, like counts)
|
|
45
|
+
* - Duplicate checking based on critical keys
|
|
46
|
+
*
|
|
47
|
+
* @template TClass - A class extending Mongoose Document.
|
|
48
|
+
*/
|
|
49
|
+
export declare class SchemaBuilder<TClass extends Document> {
|
|
50
|
+
private schema;
|
|
51
|
+
readonly options: SchemaBuilderOptions<TClass>;
|
|
52
|
+
constructor(target: Type<TClass>, options?: SchemaBuilderOptions<TClass>);
|
|
53
|
+
/**
|
|
54
|
+
* Adds interaction tracking (likes or views) to a schema.
|
|
55
|
+
* This method generalizes the shared logic between "viewable" and "likeable".
|
|
56
|
+
*
|
|
57
|
+
* @param field - The internal array field storing account IDs. (e.g. _viewedBy or _likedBy)
|
|
58
|
+
* @param counter - The numeric counter field tracking totals. (e.g. views or likes)
|
|
59
|
+
*/
|
|
60
|
+
provideInteraction(field: string, counter: string): this;
|
|
61
|
+
/**
|
|
62
|
+
* Adds a duplicate-checking static method to the schema.
|
|
63
|
+
* This method compares critical keys to detect conflicts.
|
|
64
|
+
*/
|
|
65
|
+
private provideDuplicateChecker;
|
|
66
|
+
/**
|
|
67
|
+
* Finalizes the schema and injects any selected behaviors (viewable, likeable, duplicate checking).
|
|
68
|
+
*
|
|
69
|
+
* @returns An object containing:
|
|
70
|
+
* - `schema`: The Mongoose schema.
|
|
71
|
+
* - `modelType`: A strongly typed model with additional static methods.
|
|
72
|
+
* - `documentType`: The inferred document type with injected properties.
|
|
73
|
+
*/
|
|
74
|
+
build(): Schema;
|
|
75
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaBuilder = void 0;
|
|
4
|
+
const mongoose_1 = require("@nestjs/mongoose");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
/**
|
|
7
|
+
* Generic builder for creating extended Mongoose schemas.
|
|
8
|
+
*
|
|
9
|
+
* This class wraps Nest's SchemaFactory and automatically injects common
|
|
10
|
+
* behaviors such as:
|
|
11
|
+
* - View tracking (who viewed, view counts)
|
|
12
|
+
* - Like tracking (who liked, like counts)
|
|
13
|
+
* - Duplicate checking based on critical keys
|
|
14
|
+
*
|
|
15
|
+
* @template TClass - A class extending Mongoose Document.
|
|
16
|
+
*/
|
|
17
|
+
class SchemaBuilder {
|
|
18
|
+
constructor(target, options = {}) {
|
|
19
|
+
this.schema = mongoose_1.SchemaFactory.createForClass(target);
|
|
20
|
+
this.options = options;
|
|
21
|
+
/**
|
|
22
|
+
* Create a wildcard index required for CosmosDB to support sorting on all fields.
|
|
23
|
+
*
|
|
24
|
+
* This is a workaround for CosmosDB's partial MongoDB API compatibility.
|
|
25
|
+
* See: https://learn.microsoft.com/en-us/azure/cosmos-db/mongodb/indexing#wildcard-indexes
|
|
26
|
+
*/
|
|
27
|
+
this.schema.index({ '$**': 1 }, { name: 'Sort Index' });
|
|
28
|
+
this.provideDuplicateChecker();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Adds interaction tracking (likes or views) to a schema.
|
|
32
|
+
* This method generalizes the shared logic between "viewable" and "likeable".
|
|
33
|
+
*
|
|
34
|
+
* @param field - The internal array field storing account IDs. (e.g. _viewedBy or _likedBy)
|
|
35
|
+
* @param counter - The numeric counter field tracking totals. (e.g. views or likes)
|
|
36
|
+
*/
|
|
37
|
+
provideInteraction(field, counter) {
|
|
38
|
+
// Add fields to the schema
|
|
39
|
+
this.schema.add({ [field]: { type: [String], default: [] }, [counter]: { type: Number, default: 0 } });
|
|
40
|
+
// Expose a virtual property (without underscore) for convenience
|
|
41
|
+
this.schema.virtual(field.replace(/^_/, ''));
|
|
42
|
+
// Add method to increment counter
|
|
43
|
+
this.schema.methods[`add${counter[0].toUpperCase() + counter.slice(1)}`] = async function (accountId) {
|
|
44
|
+
if (!(0, class_validator_1.isMongoId)(accountId))
|
|
45
|
+
return Number(this[counter]);
|
|
46
|
+
// Ensure uniqueness by converting to a Set
|
|
47
|
+
this[field] = Array.from(new Set([...this[field], accountId]));
|
|
48
|
+
this[counter] = this[field].length;
|
|
49
|
+
await this.save({ timestamps: false });
|
|
50
|
+
return this[counter];
|
|
51
|
+
};
|
|
52
|
+
// Add method to decrement counter
|
|
53
|
+
this.schema.methods[`remove${counter[0].toUpperCase() + counter.slice(1)}`] = async function (accountId) {
|
|
54
|
+
if (!(0, class_validator_1.isMongoId)(accountId))
|
|
55
|
+
return Number(this[counter]);
|
|
56
|
+
// Remove the accountId from the list
|
|
57
|
+
this[field] = this[field].filter((id) => id !== accountId);
|
|
58
|
+
this[counter] = this[field].length;
|
|
59
|
+
await this.save({ timestamps: false });
|
|
60
|
+
return this[counter];
|
|
61
|
+
};
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adds a duplicate-checking static method to the schema.
|
|
66
|
+
* This method compares critical keys to detect conflicts.
|
|
67
|
+
*/
|
|
68
|
+
provideDuplicateChecker() {
|
|
69
|
+
var _a;
|
|
70
|
+
const criticalKeys = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.criticalKeys) || [];
|
|
71
|
+
this.schema.statics.isDuplicate = async function (dto, updateTarget) {
|
|
72
|
+
var _a;
|
|
73
|
+
if (criticalKeys.length === 0)
|
|
74
|
+
return false;
|
|
75
|
+
// Build a filter using the critical keys
|
|
76
|
+
const filterQuery = criticalKeys.reduce((query, key) => {
|
|
77
|
+
if (dto && key in dto)
|
|
78
|
+
query[String(key)] = dto[key];
|
|
79
|
+
else if (updateTarget && key in updateTarget)
|
|
80
|
+
query[String(key)] = updateTarget[key];
|
|
81
|
+
return query;
|
|
82
|
+
}, {});
|
|
83
|
+
// If a matching document exists, check whether it’s the same entity
|
|
84
|
+
const potentialDuplicate = await this.findOne(filterQuery);
|
|
85
|
+
if (!potentialDuplicate)
|
|
86
|
+
return false;
|
|
87
|
+
const potentialId = potentialDuplicate._id.toString().toLowerCase();
|
|
88
|
+
const targetId = (_a = updateTarget === null || updateTarget === void 0 ? void 0 : updateTarget._id) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase();
|
|
89
|
+
return potentialId !== targetId;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Finalizes the schema and injects any selected behaviors (viewable, likeable, duplicate checking).
|
|
94
|
+
*
|
|
95
|
+
* @returns An object containing:
|
|
96
|
+
* - `schema`: The Mongoose schema.
|
|
97
|
+
* - `modelType`: A strongly typed model with additional static methods.
|
|
98
|
+
* - `documentType`: The inferred document type with injected properties.
|
|
99
|
+
*/
|
|
100
|
+
build() {
|
|
101
|
+
var _a, _b;
|
|
102
|
+
if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.viewable)
|
|
103
|
+
this.provideInteraction('_viewedBy', 'views');
|
|
104
|
+
if ((_b = this.options) === null || _b === void 0 ? void 0 : _b.likeable)
|
|
105
|
+
this.provideInteraction('_likedBy', 'likes');
|
|
106
|
+
return this.schema;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.SchemaBuilder = SchemaBuilder;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { Account, User } from '../models';
|
|
2
|
+
import { AccountsService } from '../modules';
|
|
3
|
+
/**
|
|
4
|
+
* TaskManager is a utility class that collects asynchronous tasks
|
|
5
|
+
* and executes them in parallel.
|
|
6
|
+
*
|
|
7
|
+
* This is especially useful for orchestrating optional async operations
|
|
8
|
+
* where not all tasks need to be executed every time.
|
|
9
|
+
*
|
|
10
|
+
* Example:
|
|
11
|
+
* ```ts
|
|
12
|
+
* const taskManager = new TaskManager();
|
|
13
|
+
* taskManager.add(async () => { ... });
|
|
14
|
+
* taskManager.add(async () => { ... });
|
|
15
|
+
* await taskManager.run();
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare class TaskManager {
|
|
19
|
+
private tasks;
|
|
20
|
+
/**
|
|
21
|
+
* Fetches all users for the given ID groups and returns a mapping.
|
|
22
|
+
* Ensures each user is fetched only once.
|
|
23
|
+
* @param userIdGroups Array of arrays of user IDs (e.g., authors, likedBy, viewedBy)
|
|
24
|
+
* @param accountsService Service responsible for fetching users
|
|
25
|
+
* @returns Map of userId -> user
|
|
26
|
+
*/
|
|
27
|
+
static fetchAndMapUsers(userIdGroups: string[][], accountsService: AccountsService): Promise<Map<string, User>>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetches all users for the given ID groups and returns a mapping.
|
|
30
|
+
* Ensures each user is fetched only once.
|
|
31
|
+
* @param accountIdGroups Array of arrays of user IDs (e.g., authors, likedBy, viewedBy)
|
|
32
|
+
* @param accountsService Service responsible for fetching users
|
|
33
|
+
* @returns Map of userId -> user
|
|
34
|
+
*/
|
|
35
|
+
static fetchAndMapAccounts(accountIdGroups: string[][], accountsService: AccountsService): Promise<Map<string, Account>>;
|
|
36
|
+
/**
|
|
37
|
+
* Maps an array of IDs to user objects using a userMap.
|
|
38
|
+
* Filters out any IDs that don’t have a corresponding user.
|
|
39
|
+
* @param userIds Array of user IDs to map
|
|
40
|
+
* @param userMap Map of userId -> user object
|
|
41
|
+
* @returns Array of user objects
|
|
42
|
+
*/
|
|
43
|
+
static mapIdsToUsers(userIds: string[], userMap: Map<string, User>): any[];
|
|
44
|
+
/**
|
|
45
|
+
* Maps an array of IDs to user objects using a userMap.
|
|
46
|
+
* Filters out any IDs that don’t have a corresponding user.
|
|
47
|
+
* @param accountIds Array of user IDs to map
|
|
48
|
+
* @param accountMap Map of userId -> user object
|
|
49
|
+
* @returns Array of user objects
|
|
50
|
+
*/
|
|
51
|
+
static mapIdsToAccounts(accountIds: string[], accountMap: Map<string, Account>): any[];
|
|
52
|
+
/**
|
|
53
|
+
* Adds a new asynchronous task to the queue.
|
|
54
|
+
*
|
|
55
|
+
* @param task - A function that returns a Promise.
|
|
56
|
+
* It should contain the actual async logic to be executed.
|
|
57
|
+
*/
|
|
58
|
+
add(task: () => Promise<void>): void;
|
|
59
|
+
/**
|
|
60
|
+
* Executes all queued tasks in parallel and waits for their completion.
|
|
61
|
+
*
|
|
62
|
+
* - Tasks are executed concurrently using `Promise.all`.
|
|
63
|
+
* - If one task fails, the error will propagate and stop execution.
|
|
64
|
+
*/
|
|
65
|
+
run(): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Clears all tasks from the queue without executing them.
|
|
68
|
+
* Useful if you want to reset and reuse the TaskManager instance.
|
|
69
|
+
*/
|
|
70
|
+
clear(): void;
|
|
71
|
+
}
|