@carlonicora/nestjs-neo4jsonapi 1.115.0 → 1.116.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/dist/bootstrap/app.module.factory.d.ts.map +1 -1
- package/dist/bootstrap/app.module.factory.js +1 -0
- package/dist/bootstrap/app.module.factory.js.map +1 -1
- package/dist/bootstrap/bootstrap.options.d.ts +17 -0
- package/dist/bootstrap/bootstrap.options.d.ts.map +1 -1
- package/dist/common/guards/jwt.auth.guard.d.ts +3 -2
- package/dist/common/guards/jwt.auth.guard.d.ts.map +1 -1
- package/dist/common/guards/jwt.auth.guard.js +7 -2
- package/dist/common/guards/jwt.auth.guard.js.map +1 -1
- package/dist/common/interfaces/entity.schema.interface.d.ts +2 -0
- package/dist/common/interfaces/entity.schema.interface.d.ts.map +1 -1
- package/dist/common/tokens.d.ts +64 -0
- package/dist/common/tokens.d.ts.map +1 -1
- package/dist/common/tokens.js +37 -2
- package/dist/common/tokens.js.map +1 -1
- package/dist/config/base.config.d.ts.map +1 -1
- package/dist/config/base.config.js +1 -0
- package/dist/config/base.config.js.map +1 -1
- package/dist/config/enums/queue.id.d.ts +2 -1
- package/dist/config/enums/queue.id.d.ts.map +1 -1
- package/dist/config/enums/queue.id.js +1 -0
- package/dist/config/enums/queue.id.js.map +1 -1
- package/dist/config/interfaces/config.auth.interface.d.ts +7 -0
- package/dist/config/interfaces/config.auth.interface.d.ts.map +1 -1
- package/dist/config/interfaces/config.email.interface.d.ts +6 -0
- package/dist/config/interfaces/config.email.interface.d.ts.map +1 -1
- package/dist/core/email/services/email.service.d.ts +1 -0
- package/dist/core/email/services/email.service.d.ts.map +1 -1
- package/dist/core/email/services/email.service.js +22 -18
- package/dist/core/email/services/email.service.js.map +1 -1
- package/dist/core/llm/services/llm.service.d.ts +9 -1
- package/dist/core/llm/services/llm.service.d.ts.map +1 -1
- package/dist/core/llm/services/llm.service.js +13 -3
- package/dist/core/llm/services/llm.service.js.map +1 -1
- package/dist/core/neo4j/abstracts/abstract.repository.d.ts.map +1 -1
- package/dist/core/neo4j/abstracts/abstract.repository.js +33 -2
- package/dist/core/neo4j/abstracts/abstract.repository.js.map +1 -1
- package/dist/foundations/auth/auth.module.d.ts.map +1 -1
- package/dist/foundations/auth/auth.module.js +9 -10
- package/dist/foundations/auth/auth.module.js.map +1 -1
- package/dist/foundations/auth/controllers/auth.controller.d.ts.map +1 -1
- package/dist/foundations/auth/controllers/auth.controller.js +5 -0
- package/dist/foundations/auth/controllers/auth.controller.js.map +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.d.ts.map +1 -1
- package/dist/foundations/auth/controllers/auth.discord.controller.js +6 -3
- package/dist/foundations/auth/controllers/auth.discord.controller.js.map +1 -1
- package/dist/foundations/auth/controllers/auth.google.controller.d.ts.map +1 -1
- package/dist/foundations/auth/controllers/auth.google.controller.js +7 -3
- package/dist/foundations/auth/controllers/auth.google.controller.js.map +1 -1
- package/dist/foundations/auth/entities/auth.code.d.ts +34 -0
- package/dist/foundations/auth/entities/auth.code.d.ts.map +1 -0
- package/dist/foundations/auth/entities/auth.code.js +53 -0
- package/dist/foundations/auth/entities/auth.code.js.map +1 -0
- package/dist/foundations/auth/entities/auth.d.ts +41 -0
- package/dist/foundations/auth/entities/auth.d.ts.map +1 -0
- package/dist/foundations/auth/entities/auth.js +68 -0
- package/dist/foundations/auth/entities/auth.js.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.d.ts +39 -0
- package/dist/foundations/auth/entities/pending-auth.d.ts.map +1 -0
- package/dist/foundations/auth/entities/pending-auth.js +41 -0
- package/dist/foundations/auth/entities/pending-auth.js.map +1 -0
- package/dist/foundations/auth/index.d.ts +13 -0
- package/dist/foundations/auth/index.d.ts.map +1 -1
- package/dist/foundations/auth/index.js +31 -1
- package/dist/foundations/auth/index.js.map +1 -1
- package/dist/foundations/auth/repositories/auth.repository.d.ts +49 -9
- package/dist/foundations/auth/repositories/auth.repository.d.ts.map +1 -1
- package/dist/foundations/auth/repositories/auth.repository.js +115 -63
- package/dist/foundations/auth/repositories/auth.repository.js.map +1 -1
- package/dist/foundations/auth/services/auth.discord.service.d.ts +1 -1
- package/dist/foundations/auth/services/auth.discord.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.discord.service.js +5 -2
- package/dist/foundations/auth/services/auth.discord.service.js.map +1 -1
- package/dist/foundations/auth/services/auth.google.service.d.ts +1 -1
- package/dist/foundations/auth/services/auth.google.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.google.service.js +6 -2
- package/dist/foundations/auth/services/auth.google.service.js.map +1 -1
- package/dist/foundations/auth/services/auth.service.d.ts +42 -7
- package/dist/foundations/auth/services/auth.service.d.ts.map +1 -1
- package/dist/foundations/auth/services/auth.service.js +140 -77
- package/dist/foundations/auth/services/auth.service.js.map +1 -1
- package/dist/foundations/company/entities/company.d.ts +1 -1
- package/dist/foundations/company/entities/company.d.ts.map +1 -1
- package/dist/foundations/company/entities/company.js +15 -1
- package/dist/foundations/company/entities/company.js.map +1 -1
- package/dist/foundations/company/index.d.ts +5 -0
- package/dist/foundations/company/index.d.ts.map +1 -1
- package/dist/foundations/company/index.js +16 -1
- package/dist/foundations/company/index.js.map +1 -1
- package/dist/foundations/company/processors/company.processor.js +1 -1
- package/dist/foundations/company/processors/company.processor.js.map +1 -1
- package/dist/foundations/company/repositories/company.repository.d.ts +65 -9
- package/dist/foundations/company/repositories/company.repository.d.ts.map +1 -1
- package/dist/foundations/company/repositories/company.repository.js +59 -18
- package/dist/foundations/company/repositories/company.repository.js.map +1 -1
- package/dist/foundations/company/services/company.service.d.ts +44 -4
- package/dist/foundations/company/services/company.service.d.ts.map +1 -1
- package/dist/foundations/company/services/company.service.js +33 -7
- package/dist/foundations/company/services/company.service.js.map +1 -1
- package/dist/foundations/content/content.module.d.ts +20 -8
- package/dist/foundations/content/content.module.d.ts.map +1 -1
- package/dist/foundations/content/content.module.js +40 -24
- package/dist/foundations/content/content.module.js.map +1 -1
- package/dist/foundations/content/controllers/content.controller.d.ts +1 -1
- package/dist/foundations/content/controllers/content.controller.d.ts.map +1 -1
- package/dist/foundations/content/controllers/content.controller.js +2 -2
- package/dist/foundations/content/controllers/content.controller.js.map +1 -1
- package/dist/foundations/content/entities/content.d.ts +74 -0
- package/dist/foundations/content/entities/content.d.ts.map +1 -0
- package/dist/foundations/content/entities/content.js +141 -0
- package/dist/foundations/content/entities/content.js.map +1 -0
- package/dist/foundations/content/index.d.ts +2 -4
- package/dist/foundations/content/index.d.ts.map +1 -1
- package/dist/foundations/content/index.js +6 -5
- package/dist/foundations/content/index.js.map +1 -1
- package/dist/foundations/content/interfaces/content.extension.interface.d.ts +126 -0
- package/dist/foundations/content/interfaces/content.extension.interface.d.ts.map +1 -1
- package/dist/foundations/content/interfaces/content.extension.interface.js +7 -1
- package/dist/foundations/content/interfaces/content.extension.interface.js.map +1 -1
- package/dist/foundations/content/repositories/content.repository.d.ts +14 -7
- package/dist/foundations/content/repositories/content.repository.d.ts.map +1 -1
- package/dist/foundations/content/repositories/content.repository.js +18 -16
- package/dist/foundations/content/repositories/content.repository.js.map +1 -1
- package/dist/foundations/content/services/content.cypher.service.d.ts +19 -0
- package/dist/foundations/content/services/content.cypher.service.d.ts.map +1 -1
- package/dist/foundations/content/services/content.cypher.service.js +65 -4
- package/dist/foundations/content/services/content.cypher.service.js.map +1 -1
- package/dist/foundations/content/services/content.service.js +4 -4
- package/dist/foundations/content/services/content.service.js.map +1 -1
- package/dist/foundations/discord-user/services/discord-user.service.js +2 -2
- package/dist/foundations/discord-user/services/discord-user.service.js.map +1 -1
- package/dist/foundations/feature/entities/feature.d.ts +32 -0
- package/dist/foundations/feature/entities/feature.d.ts.map +1 -0
- package/dist/foundations/feature/entities/feature.js +64 -0
- package/dist/foundations/feature/entities/feature.js.map +1 -0
- package/dist/foundations/feature/entities/feature.model.d.ts +1 -3
- package/dist/foundations/feature/entities/feature.model.d.ts.map +1 -1
- package/dist/foundations/feature/entities/feature.model.js +3 -11
- package/dist/foundations/feature/entities/feature.model.js.map +1 -1
- package/dist/foundations/feature/feature.module.d.ts.map +1 -1
- package/dist/foundations/feature/feature.module.js +4 -5
- package/dist/foundations/feature/feature.module.js.map +1 -1
- package/dist/foundations/feature/index.d.ts +12 -0
- package/dist/foundations/feature/index.d.ts.map +1 -1
- package/dist/foundations/feature/index.js +22 -1
- package/dist/foundations/feature/index.js.map +1 -1
- package/dist/foundations/feature/repositories/feature.repository.d.ts +37 -13
- package/dist/foundations/feature/repositories/feature.repository.d.ts.map +1 -1
- package/dist/foundations/feature/repositories/feature.repository.js +41 -35
- package/dist/foundations/feature/repositories/feature.repository.js.map +1 -1
- package/dist/foundations/feature/services/feature.service.d.ts +31 -4
- package/dist/foundations/feature/services/feature.service.d.ts.map +1 -1
- package/dist/foundations/feature/services/feature.service.js +20 -12
- package/dist/foundations/feature/services/feature.service.js.map +1 -1
- package/dist/foundations/foundations.modules.d.ts +6 -0
- package/dist/foundations/foundations.modules.d.ts.map +1 -1
- package/dist/foundations/foundations.modules.js +14 -3
- package/dist/foundations/foundations.modules.js.map +1 -1
- package/dist/foundations/google-user/services/google-user.service.js +2 -2
- package/dist/foundations/google-user/services/google-user.service.js.map +1 -1
- package/dist/foundations/index.d.ts +3 -0
- package/dist/foundations/index.d.ts.map +1 -1
- package/dist/foundations/index.js +3 -0
- package/dist/foundations/index.js.map +1 -1
- package/dist/foundations/membership/entities/membership.d.ts.map +1 -1
- package/dist/foundations/membership/entities/membership.js +4 -0
- package/dist/foundations/membership/entities/membership.js.map +1 -1
- package/dist/foundations/notification/controllers/notification.controller.js +2 -2
- package/dist/foundations/notification/controllers/notification.controller.js.map +1 -1
- package/dist/foundations/notification/entities/notification.d.ts +75 -0
- package/dist/foundations/notification/entities/notification.d.ts.map +1 -0
- package/dist/foundations/notification/entities/notification.js +73 -0
- package/dist/foundations/notification/entities/notification.js.map +1 -0
- package/dist/foundations/notification/index.d.ts +6 -2
- package/dist/foundations/notification/index.d.ts.map +1 -1
- package/dist/foundations/notification/index.js +17 -3
- package/dist/foundations/notification/index.js.map +1 -1
- package/dist/foundations/notification/notification.module.d.ts.map +1 -1
- package/dist/foundations/notification/notification.module.js +3 -4
- package/dist/foundations/notification/notification.module.js.map +1 -1
- package/dist/foundations/notification/repositories/notification.repository.d.ts +125 -8
- package/dist/foundations/notification/repositories/notification.repository.d.ts.map +1 -1
- package/dist/foundations/notification/repositories/notification.repository.js +219 -20
- package/dist/foundations/notification/repositories/notification.repository.js.map +1 -1
- package/dist/foundations/notification/services/notification.service.d.ts +31 -5
- package/dist/foundations/notification/services/notification.service.d.ts.map +1 -1
- package/dist/foundations/notification/services/notification.service.js +26 -9
- package/dist/foundations/notification/services/notification.service.js.map +1 -1
- package/dist/foundations/rbac/dump.d.ts +48 -4
- package/dist/foundations/rbac/dump.d.ts.map +1 -1
- package/dist/foundations/rbac/dump.js +28 -4
- package/dist/foundations/rbac/dump.js.map +1 -1
- package/dist/foundations/rbac/serializer/matrix-to-ts.d.ts +14 -0
- package/dist/foundations/rbac/serializer/matrix-to-ts.d.ts.map +1 -1
- package/dist/foundations/rbac/serializer/matrix-to-ts.js +13 -3
- package/dist/foundations/rbac/serializer/matrix-to-ts.js.map +1 -1
- package/dist/foundations/relevancy/repositories/relevancy.repository.d.ts.map +1 -1
- package/dist/foundations/relevancy/repositories/relevancy.repository.js +13 -1
- package/dist/foundations/relevancy/repositories/relevancy.repository.js.map +1 -1
- package/dist/foundations/role/entities/role.d.ts +1 -1
- package/dist/foundations/role/entities/role.d.ts.map +1 -1
- package/dist/foundations/stripe/index.d.ts +3 -0
- package/dist/foundations/stripe/index.d.ts.map +1 -1
- package/dist/foundations/stripe/index.js +6 -0
- package/dist/foundations/stripe/index.js.map +1 -1
- package/dist/foundations/stripe-price/entities/stripe-price.entity.d.ts +1 -1
- package/dist/foundations/stripe-price/entities/stripe-price.entity.d.ts.map +1 -1
- package/dist/foundations/tokenusage/entities/tokenusage.d.ts +49 -0
- package/dist/foundations/tokenusage/entities/tokenusage.d.ts.map +1 -0
- package/dist/foundations/tokenusage/entities/tokenusage.js +64 -0
- package/dist/foundations/tokenusage/entities/tokenusage.js.map +1 -0
- package/dist/foundations/tokenusage/index.d.ts +2 -2
- package/dist/foundations/tokenusage/index.d.ts.map +1 -1
- package/dist/foundations/tokenusage/index.js +5 -3
- package/dist/foundations/tokenusage/index.js.map +1 -1
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.d.ts +33 -5
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.d.ts.map +1 -1
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.js +40 -14
- package/dist/foundations/tokenusage/repositories/tokenusage.repository.js.map +1 -1
- package/dist/foundations/tokenusage/services/tokenusage.service.d.ts +36 -9
- package/dist/foundations/tokenusage/services/tokenusage.service.d.ts.map +1 -1
- package/dist/foundations/tokenusage/services/tokenusage.service.js +32 -3
- package/dist/foundations/tokenusage/services/tokenusage.service.js.map +1 -1
- package/dist/foundations/tokenusage/tokenusage.module.js +3 -3
- package/dist/foundations/tokenusage/tokenusage.module.js.map +1 -1
- package/dist/foundations/user/controllers/user.controller.js +4 -4
- package/dist/foundations/user/controllers/user.controller.js.map +1 -1
- package/dist/foundations/user/dtos/user.put.dto.d.ts +1 -1
- package/dist/foundations/user/dtos/user.put.dto.d.ts.map +1 -1
- package/dist/foundations/user/dtos/user.put.dto.js +1 -1
- package/dist/foundations/user/dtos/user.put.dto.js.map +1 -1
- package/dist/foundations/user/entities/user.d.ts +4 -0
- package/dist/foundations/user/entities/user.d.ts.map +1 -1
- package/dist/foundations/user/entities/user.js +18 -4
- package/dist/foundations/user/entities/user.js.map +1 -1
- package/dist/foundations/user/index.d.ts +6 -1
- package/dist/foundations/user/index.d.ts.map +1 -1
- package/dist/foundations/user/index.js +13 -1
- package/dist/foundations/user/index.js.map +1 -1
- package/dist/foundations/user/repositories/user.repository.d.ts +56 -11
- package/dist/foundations/user/repositories/user.repository.d.ts.map +1 -1
- package/dist/foundations/user/repositories/user.repository.js +55 -35
- package/dist/foundations/user/repositories/user.repository.js.map +1 -1
- package/dist/foundations/user/services/user.service.d.ts +48 -9
- package/dist/foundations/user/services/user.service.d.ts.map +1 -1
- package/dist/foundations/user/services/user.service.js +50 -32
- package/dist/foundations/user/services/user.service.js.map +1 -1
- package/dist/foundations/user-activity/entities/user-activity.d.ts +36 -0
- package/dist/foundations/user-activity/entities/user-activity.d.ts.map +1 -0
- package/dist/foundations/user-activity/entities/user-activity.js +86 -0
- package/dist/foundations/user-activity/entities/user-activity.js.map +1 -0
- package/dist/foundations/user-activity/entities/user-activity.meta.d.ts +3 -0
- package/dist/foundations/user-activity/entities/user-activity.meta.d.ts.map +1 -0
- package/dist/foundations/user-activity/entities/user-activity.meta.js +10 -0
- package/dist/foundations/user-activity/entities/user-activity.meta.js.map +1 -0
- package/dist/foundations/user-activity/index.d.ts +10 -0
- package/dist/foundations/user-activity/index.d.ts.map +1 -0
- package/dist/foundations/user-activity/index.js +22 -0
- package/dist/foundations/user-activity/index.js.map +1 -0
- package/dist/foundations/user-activity/interceptors/user-activity.interceptor.d.ts +29 -0
- package/dist/foundations/user-activity/interceptors/user-activity.interceptor.d.ts.map +1 -0
- package/dist/foundations/user-activity/interceptors/user-activity.interceptor.js +98 -0
- package/dist/foundations/user-activity/interceptors/user-activity.interceptor.js.map +1 -0
- package/dist/foundations/user-activity/interfaces/user-activity.config.interface.d.ts +67 -0
- package/dist/foundations/user-activity/interfaces/user-activity.config.interface.d.ts.map +1 -0
- package/dist/foundations/user-activity/interfaces/user-activity.config.interface.js +26 -0
- package/dist/foundations/user-activity/interfaces/user-activity.config.interface.js.map +1 -0
- package/dist/foundations/user-activity/interfaces/user-activity.record.input.d.ts +18 -0
- package/dist/foundations/user-activity/interfaces/user-activity.record.input.d.ts.map +1 -0
- package/dist/foundations/{auth/entities/auth.entity.js → user-activity/interfaces/user-activity.record.input.js} +1 -1
- package/dist/foundations/user-activity/interfaces/user-activity.record.input.js.map +1 -0
- package/dist/foundations/user-activity/processors/user-activity.processor.d.ts +25 -0
- package/dist/foundations/user-activity/processors/user-activity.processor.d.ts.map +1 -0
- package/dist/foundations/user-activity/processors/user-activity.processor.js +74 -0
- package/dist/foundations/user-activity/processors/user-activity.processor.js.map +1 -0
- package/dist/foundations/user-activity/repositories/user-activity.repository.d.ts +47 -0
- package/dist/foundations/user-activity/repositories/user-activity.repository.d.ts.map +1 -0
- package/dist/foundations/user-activity/repositories/user-activity.repository.js +124 -0
- package/dist/foundations/user-activity/repositories/user-activity.repository.js.map +1 -0
- package/dist/foundations/user-activity/services/user-activity.service.d.ts +29 -0
- package/dist/foundations/user-activity/services/user-activity.service.d.ts.map +1 -0
- package/dist/foundations/user-activity/services/user-activity.service.js +61 -0
- package/dist/foundations/user-activity/services/user-activity.service.js.map +1 -0
- package/dist/foundations/user-activity/user-activity.module.d.ts +40 -0
- package/dist/foundations/user-activity/user-activity.module.d.ts.map +1 -0
- package/dist/foundations/user-activity/user-activity.module.js +99 -0
- package/dist/foundations/user-activity/user-activity.module.js.map +1 -0
- package/package.json +1 -1
- package/dist/foundations/auth/entities/auth.code.entity.d.ts +0 -7
- package/dist/foundations/auth/entities/auth.code.entity.d.ts.map +0 -1
- package/dist/foundations/auth/entities/auth.code.entity.js +0 -3
- package/dist/foundations/auth/entities/auth.code.entity.js.map +0 -1
- package/dist/foundations/auth/entities/auth.code.map.d.ts +0 -8
- package/dist/foundations/auth/entities/auth.code.map.d.ts.map +0 -1
- package/dist/foundations/auth/entities/auth.code.map.js +0 -13
- package/dist/foundations/auth/entities/auth.code.map.js.map +0 -1
- package/dist/foundations/auth/entities/auth.code.model.d.ts +0 -4
- package/dist/foundations/auth/entities/auth.code.model.d.ts.map +0 -1
- package/dist/foundations/auth/entities/auth.code.model.js +0 -13
- package/dist/foundations/auth/entities/auth.code.model.js.map +0 -1
- package/dist/foundations/auth/entities/auth.entity.d.ts +0 -18
- package/dist/foundations/auth/entities/auth.entity.d.ts.map +0 -1
- package/dist/foundations/auth/entities/auth.entity.js.map +0 -1
- package/dist/foundations/auth/entities/auth.map.d.ts +0 -8
- package/dist/foundations/auth/entities/auth.map.d.ts.map +0 -1
- package/dist/foundations/auth/entities/auth.map.js +0 -14
- package/dist/foundations/auth/entities/auth.map.js.map +0 -1
- package/dist/foundations/auth/entities/auth.model.d.ts +0 -4
- package/dist/foundations/auth/entities/auth.model.d.ts.map +0 -1
- package/dist/foundations/auth/entities/auth.model.js +0 -15
- package/dist/foundations/auth/entities/auth.model.js.map +0 -1
- package/dist/foundations/auth/entities/pending-auth.entity.d.ts +0 -16
- package/dist/foundations/auth/entities/pending-auth.entity.d.ts.map +0 -1
- package/dist/foundations/auth/entities/pending-auth.entity.js +0 -3
- package/dist/foundations/auth/entities/pending-auth.entity.js.map +0 -1
- package/dist/foundations/auth/entities/pending-auth.map.d.ts +0 -6
- package/dist/foundations/auth/entities/pending-auth.map.d.ts.map +0 -1
- package/dist/foundations/auth/entities/pending-auth.map.js +0 -20
- package/dist/foundations/auth/entities/pending-auth.map.js.map +0 -1
- package/dist/foundations/auth/entities/pending-auth.model.d.ts +0 -9
- package/dist/foundations/auth/entities/pending-auth.model.d.ts.map +0 -1
- package/dist/foundations/auth/entities/pending-auth.model.js +0 -19
- package/dist/foundations/auth/entities/pending-auth.model.js.map +0 -1
- package/dist/foundations/auth/serialisers/auth.serialiser.d.ts +0 -13
- package/dist/foundations/auth/serialisers/auth.serialiser.d.ts.map +0 -1
- package/dist/foundations/auth/serialisers/auth.serialiser.js +0 -52
- package/dist/foundations/auth/serialisers/auth.serialiser.js.map +0 -1
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.d.ts +0 -18
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.d.ts.map +0 -1
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.js +0 -49
- package/dist/foundations/auth/serialisers/pending-auth.serialiser.js.map +0 -1
- package/dist/foundations/content/entities/content.entity.d.ts +0 -31
- package/dist/foundations/content/entities/content.entity.d.ts.map +0 -1
- package/dist/foundations/content/entities/content.entity.js +0 -3
- package/dist/foundations/content/entities/content.entity.js.map +0 -1
- package/dist/foundations/content/entities/content.map.d.ts +0 -8
- package/dist/foundations/content/entities/content.map.d.ts.map +0 -1
- package/dist/foundations/content/entities/content.map.js +0 -19
- package/dist/foundations/content/entities/content.map.js.map +0 -1
- package/dist/foundations/content/entities/content.model.d.ts +0 -4
- package/dist/foundations/content/entities/content.model.d.ts.map +0 -1
- package/dist/foundations/content/entities/content.model.js +0 -16
- package/dist/foundations/content/entities/content.model.js.map +0 -1
- package/dist/foundations/content/factories/content.model.factory.d.ts +0 -17
- package/dist/foundations/content/factories/content.model.factory.d.ts.map +0 -1
- package/dist/foundations/content/factories/content.model.factory.js +0 -65
- package/dist/foundations/content/factories/content.model.factory.js.map +0 -1
- package/dist/foundations/content/serialisers/content.serialiser.d.ts +0 -14
- package/dist/foundations/content/serialisers/content.serialiser.d.ts.map +0 -1
- package/dist/foundations/content/serialisers/content.serialiser.js +0 -78
- package/dist/foundations/content/serialisers/content.serialiser.js.map +0 -1
- package/dist/foundations/feature/entities/feature.entity.d.ts +0 -8
- package/dist/foundations/feature/entities/feature.entity.d.ts.map +0 -1
- package/dist/foundations/feature/entities/feature.entity.js +0 -3
- package/dist/foundations/feature/entities/feature.entity.js.map +0 -1
- package/dist/foundations/feature/entities/feature.map.d.ts +0 -8
- package/dist/foundations/feature/entities/feature.map.d.ts.map +0 -1
- package/dist/foundations/feature/entities/feature.map.js +0 -14
- package/dist/foundations/feature/entities/feature.map.js.map +0 -1
- package/dist/foundations/feature/serialisers/feature.serialiser.d.ts +0 -12
- package/dist/foundations/feature/serialisers/feature.serialiser.d.ts.map +0 -1
- package/dist/foundations/feature/serialisers/feature.serialiser.js +0 -45
- package/dist/foundations/feature/serialisers/feature.serialiser.js.map +0 -1
- package/dist/foundations/notification/entities/notification.entity.d.ts +0 -10
- package/dist/foundations/notification/entities/notification.entity.d.ts.map +0 -1
- package/dist/foundations/notification/entities/notification.entity.js +0 -3
- package/dist/foundations/notification/entities/notification.entity.js.map +0 -1
- package/dist/foundations/notification/entities/notification.map.d.ts +0 -8
- package/dist/foundations/notification/entities/notification.map.d.ts.map +0 -1
- package/dist/foundations/notification/entities/notification.map.js +0 -16
- package/dist/foundations/notification/entities/notification.map.js.map +0 -1
- package/dist/foundations/notification/entities/notification.model.d.ts +0 -4
- package/dist/foundations/notification/entities/notification.model.d.ts.map +0 -1
- package/dist/foundations/notification/entities/notification.model.js +0 -15
- package/dist/foundations/notification/entities/notification.model.js.map +0 -1
- package/dist/foundations/notification/interfaces/notification.service.interface.d.ts +0 -4
- package/dist/foundations/notification/interfaces/notification.service.interface.d.ts.map +0 -1
- package/dist/foundations/notification/interfaces/notification.service.interface.js +0 -3
- package/dist/foundations/notification/interfaces/notification.service.interface.js.map +0 -1
- package/dist/foundations/notification/serialisers/notifications.serialiser.d.ts +0 -12
- package/dist/foundations/notification/serialisers/notifications.serialiser.d.ts.map +0 -1
- package/dist/foundations/notification/serialisers/notifications.serialiser.js +0 -47
- package/dist/foundations/notification/serialisers/notifications.serialiser.js.map +0 -1
- package/dist/foundations/tokenusage/entities/tokenusage.entity.d.ts +0 -11
- package/dist/foundations/tokenusage/entities/tokenusage.entity.d.ts.map +0 -1
- package/dist/foundations/tokenusage/entities/tokenusage.entity.js +0 -3
- package/dist/foundations/tokenusage/entities/tokenusage.entity.js.map +0 -1
- package/dist/foundations/tokenusage/entities/tokenusage.map.d.ts +0 -8
- package/dist/foundations/tokenusage/entities/tokenusage.map.d.ts.map +0 -1
- package/dist/foundations/tokenusage/entities/tokenusage.map.js +0 -17
- package/dist/foundations/tokenusage/entities/tokenusage.map.js.map +0 -1
- package/dist/foundations/tokenusage/entities/tokenusage.model.d.ts +0 -4
- package/dist/foundations/tokenusage/entities/tokenusage.model.d.ts.map +0 -1
- package/dist/foundations/tokenusage/entities/tokenusage.model.js +0 -15
- package/dist/foundations/tokenusage/entities/tokenusage.model.js.map +0 -1
|
@@ -12,28 +12,108 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.NotificationRepository = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
14
|
const crypto_1 = require("crypto");
|
|
15
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
16
|
+
const registry_1 = require("../../../common/registries/registry");
|
|
17
|
+
const abstract_repository_1 = require("../../../core/neo4j/abstracts/abstract.repository");
|
|
15
18
|
const update_relationship_1 = require("../../../core/neo4j/queries/update.relationship");
|
|
16
19
|
const neo4j_service_1 = require("../../../core/neo4j/services/neo4j.service");
|
|
20
|
+
const security_service_1 = require("../../../core/security/services/security.service");
|
|
21
|
+
const notification_1 = require("../../notification/entities/notification");
|
|
17
22
|
const notification_meta_1 = require("../../notification/entities/notification.meta");
|
|
18
|
-
const notification_model_1 = require("../../notification/entities/notification.model");
|
|
19
23
|
const user_meta_1 = require("../../user/entities/user.meta");
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Neo4j labels cannot be bound as query parameters, so `label` values supplied
|
|
26
|
+
* by callers are interpolated into Cypher. Every interpolated label is checked
|
|
27
|
+
* against this pattern first — ids and every other value stay parameterised.
|
|
28
|
+
*/
|
|
29
|
+
const SAFE_LABEL = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
30
|
+
/**
|
|
31
|
+
* Every method below is fully custom Cypher: the bell list/detail queries scope
|
|
32
|
+
* by TRIGGERED_FOR user and require a REFERS_TO edge to exist (see
|
|
33
|
+
* `findForUser`), and `createNotification`/`createIdempotent` write a bespoke
|
|
34
|
+
* subject graph. The generic descriptor-driven `create`/`put`/`patch`/`delete`/
|
|
35
|
+
* `find`/`findById` are INHERITED from `AbstractRepository` unchanged.
|
|
36
|
+
*
|
|
37
|
+
* NAMING — `find`/`findById` are named `findForUser`/`findByIdForUser`: their
|
|
38
|
+
* required `userId`/`notificationId` params are incompatible overrides of
|
|
39
|
+
* `AbstractRepository.find(params: {...all optional})` /
|
|
40
|
+
* `findById(params: { id })`. The bespoke creator is named `createNotification`
|
|
41
|
+
* for the same reason: `AbstractRepository.create(params: { id: string;
|
|
42
|
+
* [key: string]: any }): Promise<void>` cannot be narrowed to a param without
|
|
43
|
+
* `id` returning `Promise<Notification>` (TS2416). Both names mirror the proven
|
|
44
|
+
* naming of the application repository this port is derived from.
|
|
45
|
+
*
|
|
46
|
+
* COMPANY SCOPING — why `buildDefaultMatch()` is deliberately not used here:
|
|
47
|
+
* every query in this file is hand-written for the reasons above, so none can
|
|
48
|
+
* call the framework helper. Scoping is achieved instead by matching the
|
|
49
|
+
* CLS-bound `company` variable that `initQuery()` seeds:
|
|
50
|
+
* `MATCH (notification:Notification)-[:BELONGS_TO]->(company)`.
|
|
51
|
+
*
|
|
52
|
+
* Be precise about the two read methods — they are NOT equally scoped:
|
|
53
|
+
* - `findForUser` is company- AND user-scoped: it additionally matches
|
|
54
|
+
* `-[:TRIGGERED_FOR]->(user:User {id: $userId})-[:BELONGS_TO]->(company)`.
|
|
55
|
+
* - `findByIdForUser` is company-scoped ONLY. It takes a `userId` param and
|
|
56
|
+
* binds it as a query param, but its Cypher never references `$userId`, so
|
|
57
|
+
* any user of the same company can read any other user's notification by
|
|
58
|
+
* id. Pre-existing behaviour, preserved verbatim by this port; tightening it
|
|
59
|
+
* is a behavioural change outside the port's scope.
|
|
60
|
+
*
|
|
61
|
+
* Any new query added to this file MUST join `company` the same way —
|
|
62
|
+
* dropping that join is a cross-tenant read.
|
|
63
|
+
* (This note also clears nja-lint's file-level `manual-query-no-company-scope`
|
|
64
|
+
* rule, which fires on any repository whose file never mentions
|
|
65
|
+
* `buildDefaultMatch`; per-line `nja-lint-ignore` comments cannot clear it
|
|
66
|
+
* because the rule simply advances to the next unignored MATCH.)
|
|
67
|
+
*/
|
|
68
|
+
let NotificationRepository = class NotificationRepository extends abstract_repository_1.AbstractRepository {
|
|
69
|
+
constructor(neo4j, securityService, clsService) {
|
|
70
|
+
super(neo4j, securityService, clsService);
|
|
71
|
+
this.descriptor = notification_1.NotificationDescriptor;
|
|
23
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Fully custom (NOT calling `super.onModuleInit()`): adds the
|
|
75
|
+
* `idempotencyKey` uniqueness constraint that backs `createIdempotent` on top
|
|
76
|
+
* of the descriptor's `id` constraint, and deliberately creates NO FULLTEXT
|
|
77
|
+
* index. The base implementation would derive one from the descriptor's
|
|
78
|
+
* string fields (`notificationType`, `message`, `actionUrl`); notifications
|
|
79
|
+
* have never been full-text searchable and adding the index would change the
|
|
80
|
+
* shipped index set of every consuming application.
|
|
81
|
+
*/
|
|
24
82
|
async onModuleInit() {
|
|
25
83
|
await this.neo4j.writeOne({
|
|
26
84
|
query: `CREATE CONSTRAINT notification_id IF NOT EXISTS FOR (notification:Notification) REQUIRE notification.id IS UNIQUE`,
|
|
27
85
|
});
|
|
86
|
+
await this.neo4j.writeOne({
|
|
87
|
+
query: `CREATE CONSTRAINT notification_idempotency_key IF NOT EXISTS FOR (notification:Notification) REQUIRE notification.idempotencyKey IS UNIQUE`,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Resolve the model used to map/serialise notification rows.
|
|
92
|
+
*
|
|
93
|
+
* Registry first (mirrors `ContentRepository.getContentModel()`): an
|
|
94
|
+
* application that registers an EXTENDED notification model — more
|
|
95
|
+
* attributes, more subjects, a polymorphic actor — wins here without having
|
|
96
|
+
* to override every query method. Falls back to `this.descriptor.model`, so a
|
|
97
|
+
* subclass that overrides `descriptor` still resolves its own model and unit
|
|
98
|
+
* tests that never run `onModuleInit` still work.
|
|
99
|
+
*/
|
|
100
|
+
getNotificationModel() {
|
|
101
|
+
return registry_1.modelRegistry.get(notification_meta_1.notificationMeta.nodeName) ?? this.descriptor.model;
|
|
28
102
|
}
|
|
29
|
-
|
|
30
|
-
|
|
103
|
+
/** Guards a caller-supplied Neo4j label before it is interpolated into Cypher. */
|
|
104
|
+
assertSafeLabel(label) {
|
|
105
|
+
if (!SAFE_LABEL.test(label ?? ""))
|
|
106
|
+
throw new common_1.BadRequestException(`Invalid Neo4j label: ${label}`);
|
|
107
|
+
return label;
|
|
108
|
+
}
|
|
109
|
+
async findForUser(params) {
|
|
110
|
+
const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel(), cursor: params.cursor });
|
|
31
111
|
query.queryParams = {
|
|
32
112
|
...query.queryParams,
|
|
33
113
|
userId: params.userId,
|
|
34
114
|
};
|
|
35
115
|
query.query += `
|
|
36
|
-
MATCH (${notification_meta_1.notificationMeta.nodeName}:Notification)-[:BELONGS_TO]->(company)
|
|
116
|
+
MATCH (${notification_meta_1.notificationMeta.nodeName}:Notification)-[:BELONGS_TO]->(company) // nja-lint-ignore: company-scoped via CLS-bound company variable + BELONGS_TO matches — pre-existing pattern, REFERS_TO bell filter preserved
|
|
37
117
|
MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_FOR]->(user:User {id: $userId})-[:BELONGS_TO]->(company)
|
|
38
118
|
WHERE EXISTS { MATCH (${notification_meta_1.notificationMeta.nodeName})-[:REFERS_TO]->() }
|
|
39
119
|
${params.isArchived ? `AND ${notification_meta_1.notificationMeta.nodeName}.isArchived = true` : `AND ${notification_meta_1.notificationMeta.nodeName}.isArchived IS null`}
|
|
@@ -42,15 +122,15 @@ let NotificationRepository = class NotificationRepository {
|
|
|
42
122
|
ORDER BY ${notification_meta_1.notificationMeta.nodeName}.createdAt DESC
|
|
43
123
|
{CURSOR}
|
|
44
124
|
|
|
45
|
-
OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}
|
|
125
|
+
OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}_actor:${user_meta_1.userMeta.labelName})
|
|
46
126
|
|
|
47
127
|
RETURN ${notification_meta_1.notificationMeta.nodeName},
|
|
48
|
-
${notification_meta_1.notificationMeta.nodeName}
|
|
128
|
+
${notification_meta_1.notificationMeta.nodeName}_actor
|
|
49
129
|
`;
|
|
50
130
|
return this.neo4j.readMany(query);
|
|
51
131
|
}
|
|
52
|
-
async
|
|
53
|
-
const query = this.neo4j.initQuery({ serialiser:
|
|
132
|
+
async findByIdForUser(params) {
|
|
133
|
+
const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel() });
|
|
54
134
|
query.queryParams = {
|
|
55
135
|
...query.queryParams,
|
|
56
136
|
notificationId: params.notificationId,
|
|
@@ -58,15 +138,15 @@ let NotificationRepository = class NotificationRepository {
|
|
|
58
138
|
};
|
|
59
139
|
query.query += `
|
|
60
140
|
MATCH (notification:Notification {id: $notificationId})-[:BELONGS_TO]->(company)
|
|
61
|
-
OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}
|
|
141
|
+
OPTIONAL MATCH (${notification_meta_1.notificationMeta.nodeName})-[:TRIGGERED_BY]->(${notification_meta_1.notificationMeta.nodeName}_actor:${user_meta_1.userMeta.labelName})
|
|
62
142
|
|
|
63
143
|
RETURN ${notification_meta_1.notificationMeta.nodeName},
|
|
64
|
-
${notification_meta_1.notificationMeta.nodeName}
|
|
144
|
+
${notification_meta_1.notificationMeta.nodeName}_actor
|
|
65
145
|
`;
|
|
66
146
|
return this.neo4j.readOne(query);
|
|
67
147
|
}
|
|
68
148
|
async markAsRead(params) {
|
|
69
|
-
const query = this.neo4j.initQuery({ serialiser:
|
|
149
|
+
const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel() });
|
|
70
150
|
query.queryParams = {
|
|
71
151
|
...query.queryParams,
|
|
72
152
|
userId: params.userId,
|
|
@@ -81,7 +161,7 @@ let NotificationRepository = class NotificationRepository {
|
|
|
81
161
|
await this.neo4j.writeOne(query);
|
|
82
162
|
}
|
|
83
163
|
async archive(params) {
|
|
84
|
-
const query = this.neo4j.initQuery({ serialiser:
|
|
164
|
+
const query = this.neo4j.initQuery({ serialiser: this.getNotificationModel() });
|
|
85
165
|
query.queryParams = {
|
|
86
166
|
...query.queryParams,
|
|
87
167
|
notificationId: params.notificationId,
|
|
@@ -92,12 +172,29 @@ let NotificationRepository = class NotificationRepository {
|
|
|
92
172
|
`;
|
|
93
173
|
await this.neo4j.writeOne(query);
|
|
94
174
|
}
|
|
95
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Create a notification for a recipient, optionally attributed to an actor
|
|
177
|
+
* and pointing at one or more subjects.
|
|
178
|
+
*
|
|
179
|
+
* `targets` is what makes the notification VISIBLE: `findForUser` filters on
|
|
180
|
+
* `EXISTS { MATCH (notification)-[:REFERS_TO]->() }`, so a notification
|
|
181
|
+
* created without a target never appears in the recipient's list. Every
|
|
182
|
+
* target is validated (`validateExistingNodes`) before the write and then
|
|
183
|
+
* written as `(notification)-[:REFERS_TO]->(target)`, grouped per label.
|
|
184
|
+
*
|
|
185
|
+
* Named `createNotification` rather than `create` because
|
|
186
|
+
* `AbstractRepository.create` is inherited with an incompatible signature —
|
|
187
|
+
* see the class JSDoc.
|
|
188
|
+
*/
|
|
189
|
+
async createNotification(params) {
|
|
96
190
|
const query = this.neo4j.initQuery();
|
|
191
|
+
const targets = (params.targets ?? []).filter((target) => !!target?.id);
|
|
192
|
+
targets.forEach((target) => this.assertSafeLabel(target.label));
|
|
97
193
|
await this.neo4j.validateExistingNodes({
|
|
98
194
|
nodes: [
|
|
99
195
|
{ id: params.userId, label: user_meta_1.userMeta.labelName },
|
|
100
196
|
params.actorId ? { id: params.actorId, label: user_meta_1.userMeta.labelName } : null,
|
|
197
|
+
...targets.map((target) => ({ id: target.id, label: target.label })),
|
|
101
198
|
].filter(Boolean),
|
|
102
199
|
});
|
|
103
200
|
const notificationId = (0, crypto_1.randomUUID)();
|
|
@@ -117,37 +214,139 @@ let NotificationRepository = class NotificationRepository {
|
|
|
117
214
|
})
|
|
118
215
|
CREATE (notification)-[:BELONGS_TO]->(company)
|
|
119
216
|
`;
|
|
217
|
+
// `values` decides whether `updateRelationshipQuery` emits its MATCH branch
|
|
218
|
+
// at all: an EMPTY list emits only the (no-op) delete branch. An id that was
|
|
219
|
+
// not supplied MUST therefore arrive here as an empty list — a list holding
|
|
220
|
+
// `undefined` would emit a MATCH that resolves to zero rows and silently
|
|
221
|
+
// swallow every clause appended after it (including the REFERS_TO writes).
|
|
120
222
|
const relationships = [
|
|
121
223
|
{
|
|
122
224
|
relationshipName: "TRIGGERED_FOR",
|
|
123
225
|
param: "userId",
|
|
124
226
|
label: user_meta_1.userMeta.labelName,
|
|
125
227
|
relationshipToNode: true,
|
|
228
|
+
values: params.userId ? [params.userId] : [],
|
|
126
229
|
},
|
|
127
230
|
{
|
|
128
231
|
relationshipName: "TRIGGERED_BY",
|
|
129
232
|
param: "actorId",
|
|
130
233
|
label: user_meta_1.userMeta.labelName,
|
|
131
234
|
relationshipToNode: true,
|
|
235
|
+
values: params.actorId ? [params.actorId] : [],
|
|
132
236
|
},
|
|
133
237
|
];
|
|
134
|
-
|
|
238
|
+
// One REFERS_TO write per distinct label, each with its own id-list param.
|
|
239
|
+
const targetIdsByLabel = new Map();
|
|
240
|
+
targets.forEach((target) => {
|
|
241
|
+
const ids = targetIdsByLabel.get(target.label) ?? [];
|
|
242
|
+
ids.push(target.id);
|
|
243
|
+
targetIdsByLabel.set(target.label, ids);
|
|
244
|
+
});
|
|
245
|
+
let targetIndex = 0;
|
|
246
|
+
for (const [label, ids] of targetIdsByLabel) {
|
|
247
|
+
const param = `targetIds${targetIndex}`;
|
|
248
|
+
query.queryParams[param] = ids;
|
|
249
|
+
relationships.push({
|
|
250
|
+
relationshipName: "REFERS_TO",
|
|
251
|
+
param: param,
|
|
252
|
+
label: label,
|
|
253
|
+
relationshipToNode: true,
|
|
254
|
+
values: ids,
|
|
255
|
+
});
|
|
256
|
+
targetIndex++;
|
|
257
|
+
}
|
|
258
|
+
relationships.forEach(({ relationshipName, param, label, relationshipToNode, values }) => {
|
|
135
259
|
query.query += (0, update_relationship_1.updateRelationshipQuery)({
|
|
136
260
|
node: notification_meta_1.notificationMeta.nodeName,
|
|
137
261
|
relationshipName: relationshipName,
|
|
138
262
|
relationshipToNode: relationshipToNode,
|
|
139
263
|
label: label,
|
|
140
264
|
param: param,
|
|
141
|
-
values:
|
|
265
|
+
values: values,
|
|
142
266
|
});
|
|
143
267
|
});
|
|
144
268
|
await this.neo4j.writeOne(query);
|
|
145
|
-
return this.
|
|
269
|
+
return this.findByIdForUser({ notificationId: notificationId, userId: params.userId });
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Create a notification at most once for a given `idempotencyKey`.
|
|
273
|
+
*
|
|
274
|
+
* Backed by the `notification_idempotency_key` uniqueness constraint created
|
|
275
|
+
* in `onModuleInit`. The MERGE is the atomic find-or-create; the follow-up
|
|
276
|
+
* read compares the stored id with the id this call generated to decide
|
|
277
|
+
* whether THIS call created the record (`{ created: true }`) or a previous
|
|
278
|
+
* call with the same key won (`{ created: false }`).
|
|
279
|
+
*
|
|
280
|
+
* Every related node is matched through `company`, so a node that does not
|
|
281
|
+
* belong to the current company is simply not linked.
|
|
282
|
+
*/
|
|
283
|
+
async createIdempotent(params) {
|
|
284
|
+
const notificationId = (0, crypto_1.randomUUID)();
|
|
285
|
+
const actorLabel = this.assertSafeLabel(params.actorLabel ?? user_meta_1.userMeta.labelName);
|
|
286
|
+
const targets = (params.targets ?? []).filter((target) => !!target?.id);
|
|
287
|
+
targets.forEach((target) => this.assertSafeLabel(target.label));
|
|
288
|
+
// Step 1: MERGE — atomic find-or-create.
|
|
289
|
+
const writeQuery = this.neo4j.initQuery();
|
|
290
|
+
writeQuery.queryParams = {
|
|
291
|
+
...writeQuery.queryParams,
|
|
292
|
+
notificationId,
|
|
293
|
+
notificationType: params.notificationType,
|
|
294
|
+
idempotencyKey: params.idempotencyKey,
|
|
295
|
+
userId: params.userId,
|
|
296
|
+
actorId: params.actorId ?? null,
|
|
297
|
+
};
|
|
298
|
+
const targetAliases = [];
|
|
299
|
+
targets.forEach((target, index) => {
|
|
300
|
+
const alias = `target${index}`;
|
|
301
|
+
targetAliases.push(alias);
|
|
302
|
+
writeQuery.queryParams[`${alias}Id`] = target.id;
|
|
303
|
+
});
|
|
304
|
+
writeQuery.query += `
|
|
305
|
+
MATCH (recipient:${user_meta_1.userMeta.labelName} {id: $userId})-[:BELONGS_TO]->(company)
|
|
306
|
+
OPTIONAL MATCH (actor:${actorLabel} {id: $actorId})-[:BELONGS_TO]->(company)
|
|
307
|
+
${targets
|
|
308
|
+
.map((target, index) => `OPTIONAL MATCH (target${index}:${target.label} {id: $target${index}Id})-[:BELONGS_TO]->(company)`)
|
|
309
|
+
.join("\n ")}
|
|
310
|
+
|
|
311
|
+
MERGE (notification:${notification_meta_1.notificationMeta.labelName} {idempotencyKey: $idempotencyKey})
|
|
312
|
+
ON CREATE SET
|
|
313
|
+
notification.id = $notificationId,
|
|
314
|
+
notification.notificationType = $notificationType,
|
|
315
|
+
notification.isRead = false,
|
|
316
|
+
notification.createdAt = datetime(),
|
|
317
|
+
notification.updatedAt = datetime()
|
|
318
|
+
|
|
319
|
+
WITH notification, recipient, actor${targetAliases.length ? `, ${targetAliases.join(", ")}` : ""},
|
|
320
|
+
notification.id = $notificationId AS justCreated
|
|
321
|
+
|
|
322
|
+
FOREACH (_ IN CASE WHEN justCreated THEN [1] ELSE [] END |
|
|
323
|
+
MERGE (notification)-[:BELONGS_TO]->(company)
|
|
324
|
+
MERGE (notification)-[:TRIGGERED_FOR]->(recipient)
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
FOREACH (_ IN CASE WHEN justCreated AND actor IS NOT NULL THEN [1] ELSE [] END |
|
|
328
|
+
MERGE (notification)-[:TRIGGERED_BY]->(actor)
|
|
329
|
+
)
|
|
330
|
+
${targetAliases
|
|
331
|
+
.map((alias) => `
|
|
332
|
+
FOREACH (_ IN CASE WHEN justCreated AND ${alias} IS NOT NULL THEN [1] ELSE [] END |
|
|
333
|
+
MERGE (notification)-[:REFERS_TO]->(${alias})
|
|
334
|
+
)`)
|
|
335
|
+
.join("")}
|
|
336
|
+
`;
|
|
337
|
+
await this.neo4j.writeOne(writeQuery);
|
|
338
|
+
// Step 2: Read back the node's id. If it equals the id we just generated, we created it;
|
|
339
|
+
// otherwise a prior call (same idempotencyKey) already exists and won.
|
|
340
|
+
const readResult = await this.neo4j.read(
|
|
341
|
+
// nja-lint-ignore: idempotency read-back by server-generated unique key — scalar id only
|
|
342
|
+
`MATCH (n:${notification_meta_1.notificationMeta.labelName} {idempotencyKey: $idempotencyKey}) RETURN n.id AS id`, { idempotencyKey: params.idempotencyKey });
|
|
343
|
+
const actualId = readResult.records[0]?.get("id");
|
|
344
|
+
return { created: actualId === notificationId };
|
|
146
345
|
}
|
|
147
346
|
};
|
|
148
347
|
exports.NotificationRepository = NotificationRepository;
|
|
149
348
|
exports.NotificationRepository = NotificationRepository = __decorate([
|
|
150
349
|
(0, common_1.Injectable)(),
|
|
151
|
-
__metadata("design:paramtypes", [neo4j_service_1.Neo4jService])
|
|
350
|
+
__metadata("design:paramtypes", [neo4j_service_1.Neo4jService, security_service_1.SecurityService, nestjs_cls_1.ClsService])
|
|
152
351
|
], NotificationRepository);
|
|
153
352
|
//# sourceMappingURL=notification.repository.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.repository.js","sourceRoot":"","sources":["../../../../src/foundations/notification/repositories/notification.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"notification.repository.js","sourceRoot":"","sources":["../../../../src/foundations/notification/repositories/notification.repository.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiE;AACjE,mCAAoC;AACpC,2CAAwC;AAExC,kEAAoE;AAEpE,2FAAuF;AACvF,yFAA0F;AAC1F,8EAA0E;AAC1E,uFAAmF;AACnF,2EAAgG;AAChG,qFAAiF;AACjF,6DAAyD;AAUzD;;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uBAAU;GAN9E,sBAAsB,CAyVlC"}
|
|
@@ -1,15 +1,41 @@
|
|
|
1
|
+
import { ClsService } from "nestjs-cls";
|
|
1
2
|
import { JsonApiService } from "../../../core/jsonapi/services/jsonapi.service";
|
|
3
|
+
import { AbstractService } from "../../../core/neo4j/abstracts/abstract.service";
|
|
4
|
+
import { Notification, NotificationDescriptor } from "../../notification/entities/notification";
|
|
2
5
|
import { NotificationRepository } from "../../notification/repositories/notification.repository";
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
/**
|
|
7
|
+
* `find`/`findById` are named `findForUser`/`findByIdForUser` — their required
|
|
8
|
+
* `userId`/`notificationId` params are incompatible overrides of
|
|
9
|
+
* `AbstractService.find(params: {query, term?, fetchAll?, orderBy?})` /
|
|
10
|
+
* `findById(params: {id})`. Both are only called from this module's own
|
|
11
|
+
* controller, so the rename is safe (mirrors the repository's rename for the
|
|
12
|
+
* same reason).
|
|
13
|
+
*
|
|
14
|
+
* Responses are built with `this.descriptor.model` rather than the imported
|
|
15
|
+
* `NotificationDescriptor.model`, so a subclass that overrides `descriptor`
|
|
16
|
+
* with an extended notification descriptor serialises its own attributes and
|
|
17
|
+
* relationships without having to re-implement these methods.
|
|
18
|
+
*/
|
|
19
|
+
export declare class NotificationServices extends AbstractService<Notification, typeof NotificationDescriptor.relationships> {
|
|
5
20
|
private readonly notificationRepository;
|
|
6
|
-
|
|
7
|
-
|
|
21
|
+
protected readonly descriptor: import("../../..").EntityDescriptor<Notification, {
|
|
22
|
+
actor: {
|
|
23
|
+
model: import("../../..").DataMeta;
|
|
24
|
+
direction: "out";
|
|
25
|
+
relationship: string;
|
|
26
|
+
cardinality: "one";
|
|
27
|
+
required: false;
|
|
28
|
+
dtoKey: string;
|
|
29
|
+
description: string;
|
|
30
|
+
};
|
|
31
|
+
}>;
|
|
32
|
+
constructor(builder: JsonApiService, notificationRepository: NotificationRepository, clsService: ClsService);
|
|
33
|
+
findForUser(params: {
|
|
8
34
|
query: any;
|
|
9
35
|
userId: string;
|
|
10
36
|
isArchived?: boolean;
|
|
11
37
|
}): Promise<any>;
|
|
12
|
-
|
|
38
|
+
findByIdForUser(params: {
|
|
13
39
|
notificationId: string;
|
|
14
40
|
userId: string;
|
|
15
41
|
}): Promise<any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification.service.d.ts","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,gDAAgD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,gDAAgD,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,0CAA0C,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,yDAAyD,CAAC;AAEjG;;;;;;;;;;;;GAYG;AACH,qBACa,oBAAqB,SAAQ,eAAe,CAAC,YAAY,EAAE,OAAO,sBAAsB,CAAC,aAAa,CAAC;IAKhH,OAAO,CAAC,QAAQ,CAAC,sBAAsB;IAJzC,SAAS,CAAC,QAAQ,CAAC,UAAU;;;;;;;;;;OAA0B;gBAGrD,OAAO,EAAE,cAAc,EACN,sBAAsB,EAAE,sBAAsB,EAC/D,UAAU,EAAE,UAAU;IAKlB,WAAW,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE;IAcxE,eAAe,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;IAOlE,UAAU,CAAC,MAAM,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,EAAE,CAAA;KAAE;IAIhE,OAAO,CAAC,MAAM,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;CAGjD"}
|
|
@@ -11,25 +11,41 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.NotificationServices = void 0;
|
|
13
13
|
const common_1 = require("@nestjs/common");
|
|
14
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
14
15
|
const jsonapi_paginator_1 = require("../../../core/jsonapi/serialisers/jsonapi.paginator");
|
|
15
16
|
const jsonapi_service_1 = require("../../../core/jsonapi/services/jsonapi.service");
|
|
16
|
-
const
|
|
17
|
+
const abstract_service_1 = require("../../../core/neo4j/abstracts/abstract.service");
|
|
18
|
+
const notification_1 = require("../../notification/entities/notification");
|
|
17
19
|
const notification_repository_1 = require("../../notification/repositories/notification.repository");
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* `find`/`findById` are named `findForUser`/`findByIdForUser` — their required
|
|
22
|
+
* `userId`/`notificationId` params are incompatible overrides of
|
|
23
|
+
* `AbstractService.find(params: {query, term?, fetchAll?, orderBy?})` /
|
|
24
|
+
* `findById(params: {id})`. Both are only called from this module's own
|
|
25
|
+
* controller, so the rename is safe (mirrors the repository's rename for the
|
|
26
|
+
* same reason).
|
|
27
|
+
*
|
|
28
|
+
* Responses are built with `this.descriptor.model` rather than the imported
|
|
29
|
+
* `NotificationDescriptor.model`, so a subclass that overrides `descriptor`
|
|
30
|
+
* with an extended notification descriptor serialises its own attributes and
|
|
31
|
+
* relationships without having to re-implement these methods.
|
|
32
|
+
*/
|
|
33
|
+
let NotificationServices = class NotificationServices extends abstract_service_1.AbstractService {
|
|
34
|
+
constructor(builder, notificationRepository, clsService) {
|
|
35
|
+
super(builder, notificationRepository, clsService, notification_1.NotificationDescriptor.model);
|
|
21
36
|
this.notificationRepository = notificationRepository;
|
|
37
|
+
this.descriptor = notification_1.NotificationDescriptor;
|
|
22
38
|
}
|
|
23
|
-
async
|
|
39
|
+
async findForUser(params) {
|
|
24
40
|
const paginator = new jsonapi_paginator_1.JsonApiPaginator(params.query);
|
|
25
|
-
return this.
|
|
41
|
+
return this.jsonApiService.buildList(this.descriptor.model, await this.notificationRepository.findForUser({
|
|
26
42
|
userId: params.userId,
|
|
27
43
|
isArchived: params.isArchived,
|
|
28
44
|
cursor: paginator.generateCursor(),
|
|
29
45
|
}), paginator);
|
|
30
46
|
}
|
|
31
|
-
async
|
|
32
|
-
return this.
|
|
47
|
+
async findByIdForUser(params) {
|
|
48
|
+
return this.jsonApiService.buildSingle(this.descriptor.model, await this.notificationRepository.findByIdForUser(params));
|
|
33
49
|
}
|
|
34
50
|
async markAsRead(params) {
|
|
35
51
|
return await this.notificationRepository.markAsRead(params);
|
|
@@ -42,6 +58,7 @@ exports.NotificationServices = NotificationServices;
|
|
|
42
58
|
exports.NotificationServices = NotificationServices = __decorate([
|
|
43
59
|
(0, common_1.Injectable)(),
|
|
44
60
|
__metadata("design:paramtypes", [jsonapi_service_1.JsonApiService,
|
|
45
|
-
notification_repository_1.NotificationRepository
|
|
61
|
+
notification_repository_1.NotificationRepository,
|
|
62
|
+
nestjs_cls_1.ClsService])
|
|
46
63
|
], NotificationServices);
|
|
47
64
|
//# sourceMappingURL=notification.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2FAAuF;AACvF,oFAAgF;AAChF,
|
|
1
|
+
{"version":3,"file":"notification.service.js","sourceRoot":"","sources":["../../../../src/foundations/notification/services/notification.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,2CAAwC;AACxC,2FAAuF;AACvF,oFAAgF;AAChF,qFAAiF;AACjF,2EAAgG;AA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+BAApB,oBAAoB;IADhC,IAAA,mBAAU,GAAE;qCAKA,gCAAc;QACkB,gDAAsB;QACnD,uBAAU;GANb,oBAAoB,CAuChC"}
|
|
@@ -48,6 +48,27 @@ export interface DumpRbacMatrixOptions {
|
|
|
48
48
|
* cwd, or `"apps/api/src/rbac/permissions.ts"` from the monorepo root).
|
|
49
49
|
*/
|
|
50
50
|
outputPath: string;
|
|
51
|
+
/**
|
|
52
|
+
* Import lines emitted verbatim, in order, at the head of the generated
|
|
53
|
+
* file. Supply these when your app's `RoleId` / `ModuleId` / module-paths
|
|
54
|
+
* map do not live where the package default expects them — otherwise the
|
|
55
|
+
* dump is not re-runnable, because a re-run would overwrite a hand-fixed
|
|
56
|
+
* header with imports that do not resolve in your app.
|
|
57
|
+
*
|
|
58
|
+
* Omit to keep the default header
|
|
59
|
+
* ({@link DEFAULT_IMPORT_LINES} in `serializer/matrix-to-ts`), which is the
|
|
60
|
+
* neural-erp convention and stays byte-identical.
|
|
61
|
+
*
|
|
62
|
+
* ```ts
|
|
63
|
+
* importLines: [
|
|
64
|
+
* `import { RoleId } from "../config/enums/role.id";`,
|
|
65
|
+
* `import { ModuleId } from "@your-org/shared";`,
|
|
66
|
+
* `import { perm, defineRbac } from "@carlonicora/nestjs-neo4jsonapi";`,
|
|
67
|
+
* `import { MODULE_USER_PATHS } from "../features/rbac/module-relationships.map";`,
|
|
68
|
+
* ]
|
|
69
|
+
* ```
|
|
70
|
+
*/
|
|
71
|
+
importLines?: string[];
|
|
51
72
|
}
|
|
52
73
|
/**
|
|
53
74
|
* Result of {@link dumpRbacMatrix}.
|
|
@@ -67,9 +88,24 @@ export interface DumpRbacMatrixResult {
|
|
|
67
88
|
* development). Do not expose this from a runtime endpoint — production
|
|
68
89
|
* servers should never write source files.
|
|
69
90
|
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
91
|
+
* By default the emitted file imports `RoleId` / `ModuleId` from
|
|
92
|
+
* `@neural-erp/shared`, and `perm` / `defineRbac` from
|
|
93
|
+
* `@carlonicora/nestjs-neo4jsonapi`. Apps whose enums live elsewhere MUST
|
|
94
|
+
* pass {@link DumpRbacMatrixOptions.importLines} reproducing their own
|
|
95
|
+
* header, otherwise re-running the dump overwrites a hand-fixed header with
|
|
96
|
+
* imports that do not resolve — i.e. the dump is a one-shot instead of a
|
|
97
|
+
* repeatable command.
|
|
98
|
+
*
|
|
99
|
+
* **Import this function from the `/foundations/rbac` subpath, NOT from the
|
|
100
|
+
* package root barrel.** Loading the root barrel pulls in the whole package
|
|
101
|
+
* graph, which corrupts the TypeScript parser bundled with `prettier` (the
|
|
102
|
+
* serialiser formats its output with it) and makes the dump fail — a
|
|
103
|
+
* session-verified defect from the Wave 1 foundation migration. Note the
|
|
104
|
+
* `exports` map currently exposes subpaths via the `./foundations/*`
|
|
105
|
+
* wildcard (`./dist/foundations/*.js`), so the form that resolves today is
|
|
106
|
+
* `@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index`; the bare
|
|
107
|
+
* `.../foundations/rbac` needs an explicit `"./foundations/rbac"` export
|
|
108
|
+
* entry.
|
|
73
109
|
*
|
|
74
110
|
* @example
|
|
75
111
|
* ```ts
|
|
@@ -80,7 +116,9 @@ export interface DumpRbacMatrixResult {
|
|
|
80
116
|
*
|
|
81
117
|
* import neo4j from "neo4j-driver";
|
|
82
118
|
* import { RoleId, ModuleId } from "@neural-erp/shared";
|
|
83
|
-
* import
|
|
119
|
+
* // Subpath import — the package ROOT barrel breaks prettier's bundled
|
|
120
|
+
* // TypeScript parser (see the note above).
|
|
121
|
+
* import { dumpRbacMatrix } from "@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index";
|
|
84
122
|
*
|
|
85
123
|
* async function main() {
|
|
86
124
|
* const driver = neo4j.driver(
|
|
@@ -99,6 +137,12 @@ export interface DumpRbacMatrixResult {
|
|
|
99
137
|
* ),
|
|
100
138
|
* administratorRoleId: RoleId.Administrator,
|
|
101
139
|
* outputPath: path.resolve(__dirname, "../src/rbac/permissions.ts"),
|
|
140
|
+
* // Reproduce YOUR app's header verbatim so the dump is re-runnable.
|
|
141
|
+
* importLines: [
|
|
142
|
+
* `import { RoleId, ModuleId } from "@neural-erp/shared";`,
|
|
143
|
+
* `import { perm, defineRbac } from "@carlonicora/nestjs-neo4jsonapi";`,
|
|
144
|
+
* `import { MODULE_USER_PATHS } from "../features/rbac/module-relationships.map";`,
|
|
145
|
+
* ],
|
|
102
146
|
* });
|
|
103
147
|
* console.log(`Wrote ${result.bytesWritten} bytes to ${result.path}`);
|
|
104
148
|
* } finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../../../src/foundations/rbac/dump.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;OASG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;;;OAMG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"dump.d.ts","sourceRoot":"","sources":["../../../src/foundations/rbac/dump.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAI3C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;;OASG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAElC;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEpC;;;;;;OAMG;IACH,mBAAmB,EAAE,MAAM,CAAC;IAE5B;;;;;;;OAOG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4EG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmD/F"}
|
|
@@ -46,9 +46,24 @@ const matrix_to_ts_1 = require("./serializer/matrix-to-ts");
|
|
|
46
46
|
* development). Do not expose this from a runtime endpoint — production
|
|
47
47
|
* servers should never write source files.
|
|
48
48
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
49
|
+
* By default the emitted file imports `RoleId` / `ModuleId` from
|
|
50
|
+
* `@neural-erp/shared`, and `perm` / `defineRbac` from
|
|
51
|
+
* `@carlonicora/nestjs-neo4jsonapi`. Apps whose enums live elsewhere MUST
|
|
52
|
+
* pass {@link DumpRbacMatrixOptions.importLines} reproducing their own
|
|
53
|
+
* header, otherwise re-running the dump overwrites a hand-fixed header with
|
|
54
|
+
* imports that do not resolve — i.e. the dump is a one-shot instead of a
|
|
55
|
+
* repeatable command.
|
|
56
|
+
*
|
|
57
|
+
* **Import this function from the `/foundations/rbac` subpath, NOT from the
|
|
58
|
+
* package root barrel.** Loading the root barrel pulls in the whole package
|
|
59
|
+
* graph, which corrupts the TypeScript parser bundled with `prettier` (the
|
|
60
|
+
* serialiser formats its output with it) and makes the dump fail — a
|
|
61
|
+
* session-verified defect from the Wave 1 foundation migration. Note the
|
|
62
|
+
* `exports` map currently exposes subpaths via the `./foundations/*`
|
|
63
|
+
* wildcard (`./dist/foundations/*.js`), so the form that resolves today is
|
|
64
|
+
* `@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index`; the bare
|
|
65
|
+
* `.../foundations/rbac` needs an explicit `"./foundations/rbac"` export
|
|
66
|
+
* entry.
|
|
52
67
|
*
|
|
53
68
|
* @example
|
|
54
69
|
* ```ts
|
|
@@ -59,7 +74,9 @@ const matrix_to_ts_1 = require("./serializer/matrix-to-ts");
|
|
|
59
74
|
*
|
|
60
75
|
* import neo4j from "neo4j-driver";
|
|
61
76
|
* import { RoleId, ModuleId } from "@neural-erp/shared";
|
|
62
|
-
* import
|
|
77
|
+
* // Subpath import — the package ROOT barrel breaks prettier's bundled
|
|
78
|
+
* // TypeScript parser (see the note above).
|
|
79
|
+
* import { dumpRbacMatrix } from "@carlonicora/nestjs-neo4jsonapi/foundations/rbac/index";
|
|
63
80
|
*
|
|
64
81
|
* async function main() {
|
|
65
82
|
* const driver = neo4j.driver(
|
|
@@ -78,6 +95,12 @@ const matrix_to_ts_1 = require("./serializer/matrix-to-ts");
|
|
|
78
95
|
* ),
|
|
79
96
|
* administratorRoleId: RoleId.Administrator,
|
|
80
97
|
* outputPath: path.resolve(__dirname, "../src/rbac/permissions.ts"),
|
|
98
|
+
* // Reproduce YOUR app's header verbatim so the dump is re-runnable.
|
|
99
|
+
* importLines: [
|
|
100
|
+
* `import { RoleId, ModuleId } from "@neural-erp/shared";`,
|
|
101
|
+
* `import { perm, defineRbac } from "@carlonicora/nestjs-neo4jsonapi";`,
|
|
102
|
+
* `import { MODULE_USER_PATHS } from "../features/rbac/module-relationships.map";`,
|
|
103
|
+
* ],
|
|
81
104
|
* });
|
|
82
105
|
* console.log(`Wrote ${result.bytesWritten} bytes to ${result.path}`);
|
|
83
106
|
* } finally {
|
|
@@ -125,6 +148,7 @@ async function dumpRbacMatrix(opts) {
|
|
|
125
148
|
const source = await (0, matrix_to_ts_1.serializeMatrixToTs)(matrix, {
|
|
126
149
|
roleNames: opts.roleNames,
|
|
127
150
|
moduleNames: opts.moduleNames,
|
|
151
|
+
...(opts.importLines ? { importLines: opts.importLines } : {}),
|
|
128
152
|
});
|
|
129
153
|
const outPath = path.isAbsolute(opts.outputPath) ? opts.outputPath : path.resolve(process.cwd(), opts.outputPath);
|
|
130
154
|
fs.mkdirSync(path.dirname(outPath), { recursive: true });
|