mongodb-dynamic-api 1.6.0 → 2.1.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/CHANGELOG.md +72 -19
- package/README.md +91 -67
- package/package.json +13 -1
- package/src/builders/casl/casl-ability.builder.d.ts +5 -0
- package/src/builders/casl/casl-ability.builder.js +14 -0
- package/src/builders/index.d.ts +3 -1
- package/src/builders/index.js +3 -1
- package/src/builders/route-decorators/auth-decorators.builder.d.ts +7 -0
- package/src/builders/route-decorators/auth-decorators.builder.js +14 -0
- package/src/builders/route-decorators/route-decorators.builder.d.ts +23 -0
- package/src/builders/route-decorators/route-decorators.builder.js +110 -0
- package/src/decorators/check-policies.decorator.d.ts +5 -0
- package/src/decorators/check-policies.decorator.js +8 -0
- package/src/decorators/index.d.ts +2 -0
- package/src/decorators/index.js +2 -0
- package/src/decorators/public.decorator.d.ts +3 -0
- package/src/decorators/public.decorator.js +8 -0
- package/src/dtos/delete-many-entity.query.d.ts +3 -0
- package/src/dtos/delete-many-entity.query.js +24 -0
- package/src/dtos/index.d.ts +1 -0
- package/src/dtos/index.js +1 -0
- package/src/dynamic-api.module.d.ts +6 -4
- package/src/dynamic-api.module.js +145 -69
- package/src/guards/base-policies.guard.d.ts +13 -0
- package/src/guards/base-policies.guard.js +32 -0
- package/src/guards/dynamic-api-jwt-auth.guard.d.ts +11 -0
- package/src/guards/dynamic-api-jwt-auth.guard.js +38 -0
- package/src/guards/index.d.ts +2 -0
- package/src/guards/index.js +18 -0
- package/src/helpers/controller-ability-predicates.helper.d.ts +4 -0
- package/src/helpers/controller-ability-predicates.helper.js +18 -0
- package/src/helpers/format.helper.d.ts +2 -0
- package/src/helpers/format.helper.js +12 -0
- package/src/helpers/index.d.ts +6 -1
- package/src/helpers/index.js +6 -1
- package/src/helpers/route-decorators.helper.d.ts +2 -2
- package/src/helpers/route-description.helper.d.ts +3 -0
- package/src/helpers/route-description.helper.js +34 -0
- package/src/helpers/schema.helper.d.ts +28 -0
- package/src/helpers/schema.helper.js +30 -0
- package/src/helpers/swagger-config.helper.d.ts +4 -0
- package/src/helpers/{config.helper.js → swagger-config.helper.js} +37 -21
- package/src/helpers/validation-config.helper.d.ts +3 -0
- package/src/helpers/validation-config.helper.js +8 -0
- package/src/helpers/versioning-config.helper.d.ts +4 -0
- package/src/helpers/versioning-config.helper.js +15 -0
- package/src/index.d.ts +3 -1
- package/src/index.js +3 -1
- package/src/interceptors/dynamic-api-cache.interceptor.d.ts +16 -0
- package/src/interceptors/dynamic-api-cache.interceptor.js +48 -0
- package/src/interceptors/index.d.ts +1 -0
- package/src/interceptors/index.js +17 -0
- package/src/interfaces/dynamic-api-cache-options.interface.d.ts +9 -0
- package/src/interfaces/dynamic-api-casl-ability.interface.d.ts +9 -0
- package/src/interfaces/dynamic-api-controller-options.interface.d.ts +12 -0
- package/src/interfaces/dynamic-api-decorator-builder.interface.d.ts +5 -0
- package/src/interfaces/dynamic-api-global-state.interface.d.ts +16 -0
- package/src/interfaces/dynamic-api-options.interface.d.ts +14 -11
- package/src/interfaces/dynamic-api-options.interface.js +3 -0
- package/src/interfaces/dynamic-api-policy-handler.interface.d.ts +16 -0
- package/src/interfaces/dynamic-api-route-config.interface.d.ts +15 -0
- package/src/interfaces/dynamic-api-route-dtos-bundle.type.d.ts +8 -0
- package/src/interfaces/dynamic-api-route-module.type.d.ts +3 -0
- package/src/interfaces/dynamic-api-route-type.type.d.ts +2 -0
- package/src/interfaces/dynamic-api-schema-options.interface.d.ts +9 -2
- package/src/interfaces/dynamic-api-schema-options.interface.js +14 -0
- package/src/interfaces/{service-provider.interface.d.ts → dynamic-api-service-provider.interface.d.ts} +2 -2
- package/src/{helpers/config.helper.d.ts → interfaces/dynamic-api-swagger-options.type.d.ts} +23 -15
- package/src/interfaces/index.d.ts +13 -4
- package/src/interfaces/index.js +13 -4
- package/src/mixins/create-policies-guard.mixin.d.ts +5 -0
- package/src/mixins/create-policies-guard.mixin.js +37 -0
- package/src/mixins/entity-presenter.mixin.d.ts +1 -1
- package/src/mixins/entity-presenter.mixin.js +12 -2
- package/src/mixins/index.d.ts +1 -0
- package/src/mixins/index.js +1 -0
- package/src/models/base-entity.model.d.ts +1 -1
- package/src/modules/auth/auth.helper.d.ts +10 -0
- package/src/modules/auth/auth.helper.js +103 -0
- package/src/modules/auth/auth.module.d.ts +12 -0
- package/src/modules/auth/auth.module.js +55 -0
- package/src/modules/auth/guards/index.d.ts +2 -0
- package/src/modules/auth/guards/index.js +18 -0
- package/src/modules/auth/guards/jwt-auth.guard.d.ts +4 -0
- package/src/modules/auth/guards/jwt-auth.guard.js +17 -0
- package/src/modules/auth/guards/local-auth.guard.d.ts +4 -0
- package/src/modules/auth/guards/local-auth.guard.js +17 -0
- package/src/modules/auth/index.d.ts +7 -0
- package/src/modules/auth/index.js +23 -0
- package/src/modules/auth/interfaces/auth-controller.interface.d.ts +9 -0
- package/src/modules/auth/interfaces/auth-options.interface.d.ts +25 -0
- package/src/modules/auth/interfaces/auth-service.interface.d.ts +12 -0
- package/src/modules/auth/interfaces/index.d.ts +3 -0
- package/src/modules/auth/interfaces/index.js +19 -0
- package/src/modules/auth/mixins/auth-controller.mixin.d.ts +5 -0
- package/src/modules/auth/mixins/auth-controller.mixin.js +118 -0
- package/src/modules/auth/mixins/auth-register-policies-guard.mixin.d.ts +6 -0
- package/src/modules/auth/mixins/auth-register-policies-guard.mixin.js +59 -0
- package/src/modules/auth/mixins/index.d.ts +2 -0
- package/src/modules/auth/mixins/index.js +18 -0
- package/src/modules/auth/services/base-auth.service.d.ts +51 -0
- package/src/modules/auth/services/base-auth.service.js +64 -0
- package/src/modules/auth/services/index.d.ts +1 -0
- package/src/modules/auth/services/index.js +17 -0
- package/src/modules/auth/strategies/index.d.ts +1 -0
- package/src/modules/auth/strategies/index.js +17 -0
- package/src/modules/auth/strategies/jwt.strategy.d.ts +8 -0
- package/src/modules/auth/strategies/jwt.strategy.js +35 -0
- package/src/modules/dynamic-api-config/dynamic-api-config.module.d.ts +5 -0
- package/src/modules/dynamic-api-config/dynamic-api-config.module.js +31 -0
- package/src/modules/dynamic-api-config/index.d.ts +1 -0
- package/src/modules/dynamic-api-config/index.js +17 -0
- package/src/modules/index.d.ts +2 -8
- package/src/modules/index.js +2 -8
- package/src/routes/create-many/create-many-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/create-many/create-many-controller.mixin.js +31 -9
- package/src/routes/create-many/create-many.helper.d.ts +7 -0
- package/src/{modules → routes}/create-many/create-many.helper.js +14 -11
- package/src/routes/create-many/create-many.module.d.ts +6 -0
- package/src/{modules → routes}/create-many/create-many.module.js +3 -3
- package/src/routes/create-one/create-one-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/create-one/create-one-controller.mixin.js +29 -7
- package/src/routes/create-one/create-one.helper.d.ts +7 -0
- package/src/{modules → routes}/create-one/create-one.helper.js +14 -11
- package/src/routes/create-one/create-one.module.d.ts +6 -0
- package/src/{modules → routes}/create-one/create-one.module.js +4 -4
- package/src/routes/delete-many/base-delete-many.service.d.ts +34 -0
- package/src/routes/delete-many/base-delete-many.service.js +29 -0
- package/src/routes/delete-many/delete-many-controller.interface.d.ts +8 -0
- package/src/routes/delete-many/delete-many-controller.interface.js +2 -0
- package/src/routes/delete-many/delete-many-controller.mixin.d.ts +6 -0
- package/src/routes/delete-many/delete-many-controller.mixin.js +77 -0
- package/src/routes/delete-many/delete-many-service.interface.d.ts +6 -0
- package/src/routes/delete-many/delete-many-service.interface.js +2 -0
- package/src/routes/delete-many/delete-many.helper.d.ts +7 -0
- package/src/routes/delete-many/delete-many.helper.js +71 -0
- package/src/routes/delete-many/delete-many.module.d.ts +6 -0
- package/src/routes/delete-many/delete-many.module.js +28 -0
- package/src/routes/delete-many/delete-many.presenter.d.ts +3 -0
- package/src/routes/delete-many/delete-many.presenter.js +20 -0
- package/src/routes/delete-many/index.d.ts +7 -0
- package/src/routes/delete-many/index.js +23 -0
- package/src/routes/delete-one/delete-one-controller.interface.js +2 -0
- package/src/routes/delete-one/delete-one-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/delete-one/delete-one-controller.mixin.js +30 -7
- package/src/routes/delete-one/delete-one-service.interface.js +2 -0
- package/src/routes/delete-one/delete-one.helper.d.ts +7 -0
- package/src/{modules → routes}/delete-one/delete-one.helper.js +14 -11
- package/src/routes/delete-one/delete-one.module.d.ts +6 -0
- package/src/{modules → routes}/delete-one/delete-one.module.js +4 -4
- package/src/routes/duplicate-many/base-duplicate-many.service.d.ts +33 -0
- package/src/routes/duplicate-many/base-duplicate-many.service.js +43 -0
- package/src/routes/duplicate-many/duplicate-many-controller.interface.d.ts +7 -0
- package/src/routes/duplicate-many/duplicate-many-controller.interface.js +2 -0
- package/src/routes/duplicate-many/duplicate-many-controller.mixin.d.ts +6 -0
- package/src/routes/duplicate-many/duplicate-many-controller.mixin.js +85 -0
- package/src/routes/duplicate-many/duplicate-many-service.interface.d.ts +5 -0
- package/src/routes/duplicate-many/duplicate-many-service.interface.js +2 -0
- package/src/routes/duplicate-many/duplicate-many.helper.d.ts +7 -0
- package/src/routes/duplicate-many/duplicate-many.helper.js +71 -0
- package/src/routes/duplicate-many/duplicate-many.module.d.ts +6 -0
- package/src/routes/duplicate-many/duplicate-many.module.js +28 -0
- package/src/routes/duplicate-many/index.d.ts +6 -0
- package/src/routes/duplicate-many/index.js +22 -0
- package/src/routes/duplicate-one/duplicate-one-controller.interface.js +2 -0
- package/src/routes/duplicate-one/duplicate-one-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/duplicate-one/duplicate-one-controller.mixin.js +30 -8
- package/src/routes/duplicate-one/duplicate-one-service.interface.js +2 -0
- package/src/routes/duplicate-one/duplicate-one.helper.d.ts +7 -0
- package/src/{modules → routes}/duplicate-one/duplicate-one.helper.js +14 -11
- package/src/routes/duplicate-one/duplicate-one.module.d.ts +6 -0
- package/src/{modules → routes}/duplicate-one/duplicate-one.module.js +4 -4
- package/src/routes/get-many/get-many-controller.interface.js +2 -0
- package/src/routes/get-many/get-many-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/get-many/get-many-controller.mixin.js +29 -7
- package/src/routes/get-many/get-many-service.interface.js +2 -0
- package/src/routes/get-many/get-many.helper.d.ts +7 -0
- package/src/{modules → routes}/get-many/get-many.helper.js +14 -11
- package/src/routes/get-many/get-many.module.d.ts +6 -0
- package/src/{modules → routes}/get-many/get-many.module.js +4 -4
- package/src/routes/get-one/get-one-controller.interface.js +2 -0
- package/src/routes/get-one/get-one-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/get-one/get-one-controller.mixin.js +30 -8
- package/src/routes/get-one/get-one-service.interface.js +2 -0
- package/src/routes/get-one/get-one.helper.d.ts +7 -0
- package/src/{modules → routes}/get-one/get-one.helper.js +14 -11
- package/src/routes/get-one/get-one.module.d.ts +6 -0
- package/src/{modules → routes}/get-one/get-one.module.js +4 -4
- package/src/routes/index.d.ts +11 -0
- package/src/routes/index.js +27 -0
- package/src/routes/replace-one/replace-one-controller.interface.js +2 -0
- package/src/routes/replace-one/replace-one-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/replace-one/replace-one-controller.mixin.js +30 -8
- package/src/routes/replace-one/replace-one-service.interface.js +2 -0
- package/src/routes/replace-one/replace-one.helper.d.ts +7 -0
- package/src/{modules → routes}/replace-one/replace-one.helper.js +14 -11
- package/src/routes/replace-one/replace-one.module.d.ts +6 -0
- package/src/{modules → routes}/replace-one/replace-one.module.js +4 -4
- package/src/routes/update-many/base-update-many.service.d.ts +33 -0
- package/src/routes/update-many/base-update-many.service.js +32 -0
- package/src/routes/update-many/index.d.ts +6 -0
- package/src/routes/update-many/index.js +22 -0
- package/src/routes/update-many/update-many-controller.interface.d.ts +7 -0
- package/src/routes/update-many/update-many-controller.interface.js +2 -0
- package/src/routes/update-many/update-many-controller.mixin.d.ts +6 -0
- package/src/routes/update-many/update-many-controller.mixin.js +85 -0
- package/src/routes/update-many/update-many-service.interface.d.ts +5 -0
- package/src/routes/update-many/update-many-service.interface.js +2 -0
- package/src/routes/update-many/update-many.helper.d.ts +7 -0
- package/src/routes/update-many/update-many.helper.js +71 -0
- package/src/routes/update-many/update-many.module.d.ts +6 -0
- package/src/routes/update-many/update-many.module.js +28 -0
- package/src/routes/update-one/update-one-controller.interface.js +2 -0
- package/src/routes/update-one/update-one-controller.mixin.d.ts +6 -0
- package/src/{modules → routes}/update-one/update-one-controller.mixin.js +30 -8
- package/src/routes/update-one/update-one-service.interface.js +2 -0
- package/src/routes/update-one/update-one.helper.d.ts +7 -0
- package/src/{modules → routes}/update-one/update-one.helper.js +14 -11
- package/src/routes/update-one/update-one.module.d.ts +6 -0
- package/src/{modules → routes}/update-one/update-one.module.js +4 -4
- package/src/services/{base.service.d.ts → base/base.service.d.ts} +1 -1
- package/src/services/{base.service.js → base/base.service.js} +2 -2
- package/src/services/bcrypt/bcrypt.service.d.ts +5 -0
- package/src/services/bcrypt/bcrypt.service.js +26 -0
- package/src/services/dynamic-api-global-state/dynamic-api-global-state.service.d.ts +11 -0
- package/src/services/dynamic-api-global-state/dynamic-api-global-state.service.js +36 -0
- package/src/services/index.d.ts +3 -1
- package/src/services/index.js +3 -1
- package/src/version.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/src/builders/route-decorators.builder.d.ts +0 -18
- package/src/builders/route-decorators.builder.js +0 -76
- package/src/interfaces/maybe-promise.type.d.ts +0 -2
- package/src/interfaces/route-config.interface.d.ts +0 -17
- package/src/modules/create-many/create-many-controller.mixin.d.ts +0 -6
- package/src/modules/create-many/create-many.helper.d.ts +0 -7
- package/src/modules/create-many/create-many.module.d.ts +0 -6
- package/src/modules/create-one/create-one-controller.mixin.d.ts +0 -6
- package/src/modules/create-one/create-one.helper.d.ts +0 -7
- package/src/modules/create-one/create-one.module.d.ts +0 -6
- package/src/modules/delete-one/delete-one-controller.mixin.d.ts +0 -6
- package/src/modules/delete-one/delete-one.helper.d.ts +0 -7
- package/src/modules/delete-one/delete-one.module.d.ts +0 -6
- package/src/modules/duplicate-one/duplicate-one-controller.mixin.d.ts +0 -6
- package/src/modules/duplicate-one/duplicate-one.helper.d.ts +0 -7
- package/src/modules/duplicate-one/duplicate-one.module.d.ts +0 -6
- package/src/modules/get-many/get-many-controller.mixin.d.ts +0 -6
- package/src/modules/get-many/get-many.helper.d.ts +0 -7
- package/src/modules/get-many/get-many.module.d.ts +0 -6
- package/src/modules/get-one/get-one-controller.mixin.d.ts +0 -6
- package/src/modules/get-one/get-one.helper.d.ts +0 -7
- package/src/modules/get-one/get-one.module.d.ts +0 -6
- package/src/modules/replace-one/replace-one-controller.mixin.d.ts +0 -6
- package/src/modules/replace-one/replace-one.helper.d.ts +0 -7
- package/src/modules/replace-one/replace-one.module.d.ts +0 -6
- package/src/modules/update-one/update-one-controller.mixin.d.ts +0 -6
- package/src/modules/update-one/update-one.helper.d.ts +0 -7
- package/src/modules/update-one/update-one.module.d.ts +0 -6
- package/src/interfaces/{entity-mappers.interface.js → dynamic-api-cache-options.interface.js} +0 -0
- package/src/interfaces/{maybe-promise.type.js → dynamic-api-casl-ability.interface.js} +0 -0
- package/src/interfaces/{route-config.interface.js → dynamic-api-controller-options.interface.js} +0 -0
- package/src/interfaces/{service-provider.interface.js → dynamic-api-decorator-builder.interface.js} +0 -0
- package/src/interfaces/{entity-mappers.interface.d.ts → dynamic-api-entity-mappers.interface.d.ts} +0 -0
- package/src/{modules/create-many/create-many-controller.interface.js → interfaces/dynamic-api-entity-mappers.interface.js} +0 -0
- package/src/{modules/create-many/create-many-service.interface.js → interfaces/dynamic-api-global-state.interface.js} +0 -0
- package/src/{modules/create-one/create-one-controller.interface.js → interfaces/dynamic-api-policy-handler.interface.js} +0 -0
- package/src/{modules/create-one/create-one-service.interface.js → interfaces/dynamic-api-route-config.interface.js} +0 -0
- package/src/{modules/delete-one/delete-one-controller.interface.js → interfaces/dynamic-api-route-dtos-bundle.type.js} +0 -0
- package/src/{modules/delete-one/delete-one-service.interface.js → interfaces/dynamic-api-route-module.type.js} +0 -0
- package/src/{modules/duplicate-one/duplicate-one-controller.interface.js → interfaces/dynamic-api-route-type.type.js} +0 -0
- package/src/{modules/duplicate-one/duplicate-one-service.interface.js → interfaces/dynamic-api-service-provider.interface.js} +0 -0
- package/src/{modules/get-many/get-many-controller.interface.js → interfaces/dynamic-api-swagger-options.type.js} +0 -0
- package/src/modules/{get-many/get-many-service.interface.js → auth/interfaces/auth-controller.interface.js} +0 -0
- package/src/modules/{get-one/get-one-controller.interface.js → auth/interfaces/auth-options.interface.js} +0 -0
- package/src/modules/{get-one/get-one-service.interface.js → auth/interfaces/auth-service.interface.js} +0 -0
- package/src/{modules → routes}/create-many/base-create-many.service.d.ts +0 -0
- package/src/{modules → routes}/create-many/base-create-many.service.js +0 -0
- package/src/{modules → routes}/create-many/create-many-controller.interface.d.ts +0 -0
- package/src/{modules/replace-one/replace-one-controller.interface.js → routes/create-many/create-many-controller.interface.js} +0 -0
- package/src/{modules → routes}/create-many/create-many-service.interface.d.ts +0 -0
- package/src/{modules/replace-one/replace-one-service.interface.js → routes/create-many/create-many-service.interface.js} +0 -0
- package/src/{modules → routes}/create-many/index.d.ts +0 -0
- package/src/{modules → routes}/create-many/index.js +0 -0
- package/src/{modules → routes}/create-one/base-create-one.service.d.ts +0 -0
- package/src/{modules → routes}/create-one/base-create-one.service.js +0 -0
- package/src/{modules → routes}/create-one/create-one-controller.interface.d.ts +0 -0
- package/src/{modules/update-one/update-one-controller.interface.js → routes/create-one/create-one-controller.interface.js} +0 -0
- package/src/{modules → routes}/create-one/create-one-service.interface.d.ts +0 -0
- package/src/{modules/update-one/update-one-service.interface.js → routes/create-one/create-one-service.interface.js} +0 -0
- package/src/{modules → routes}/create-one/index.d.ts +0 -0
- package/src/{modules → routes}/create-one/index.js +0 -0
- package/src/{modules → routes}/delete-one/base-delete-one.service.d.ts +0 -0
- package/src/{modules → routes}/delete-one/base-delete-one.service.js +0 -0
- package/src/{modules → routes}/delete-one/delete-one-controller.interface.d.ts +0 -0
- package/src/{modules → routes}/delete-one/delete-one-service.interface.d.ts +0 -0
- package/src/{modules → routes}/delete-one/delete-one.presenter.d.ts +0 -0
- package/src/{modules → routes}/delete-one/delete-one.presenter.js +0 -0
- package/src/{modules → routes}/delete-one/index.d.ts +0 -0
- package/src/{modules → routes}/delete-one/index.js +0 -0
- package/src/{modules → routes}/duplicate-one/base-duplicate-one.service.d.ts +0 -0
- package/src/{modules → routes}/duplicate-one/base-duplicate-one.service.js +0 -0
- package/src/{modules → routes}/duplicate-one/duplicate-one-controller.interface.d.ts +0 -0
- package/src/{modules → routes}/duplicate-one/duplicate-one-service.interface.d.ts +0 -0
- package/src/{modules → routes}/duplicate-one/index.d.ts +0 -0
- package/src/{modules → routes}/duplicate-one/index.js +0 -0
- package/src/{modules → routes}/get-many/base-get-many.service.d.ts +0 -0
- package/src/{modules → routes}/get-many/base-get-many.service.js +1 -1
- /package/src/{modules → routes}/get-many/get-many-controller.interface.d.ts +0 -0
- /package/src/{modules → routes}/get-many/get-many-service.interface.d.ts +0 -0
- /package/src/{modules → routes}/get-many/index.d.ts +0 -0
- /package/src/{modules → routes}/get-many/index.js +0 -0
- /package/src/{modules → routes}/get-one/base-get-one.service.d.ts +0 -0
- /package/src/{modules → routes}/get-one/base-get-one.service.js +0 -0
- /package/src/{modules → routes}/get-one/get-one-controller.interface.d.ts +0 -0
- /package/src/{modules → routes}/get-one/get-one-service.interface.d.ts +0 -0
- /package/src/{modules → routes}/get-one/index.d.ts +0 -0
- /package/src/{modules → routes}/get-one/index.js +0 -0
- /package/src/{modules → routes}/replace-one/base-replace-one.service.d.ts +0 -0
- /package/src/{modules → routes}/replace-one/base-replace-one.service.js +0 -0
- /package/src/{modules → routes}/replace-one/index.d.ts +0 -0
- /package/src/{modules → routes}/replace-one/index.js +0 -0
- /package/src/{modules → routes}/replace-one/replace-one-controller.interface.d.ts +0 -0
- /package/src/{modules → routes}/replace-one/replace-one-service.interface.d.ts +0 -0
- /package/src/{modules → routes}/update-one/base-update-one.service.d.ts +0 -0
- /package/src/{modules → routes}/update-one/base-update-one.service.js +0 -0
- /package/src/{modules → routes}/update-one/index.d.ts +0 -0
- /package/src/{modules → routes}/update-one/index.js +0 -0
- /package/src/{modules → routes}/update-one/update-one-controller.interface.d.ts +0 -0
- /package/src/{modules → routes}/update-one/update-one-service.interface.d.ts +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const common_1 = require("@nestjs/common");
|
|
3
|
+
exports.enableDynamicAPISwagger = void 0;
|
|
5
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
6
5
|
const version_json_1 = require("../version.json");
|
|
7
6
|
function buildExtraConfig(config, swaggerConfig) {
|
|
@@ -52,19 +51,44 @@ function buildExtraConfig(config, swaggerConfig) {
|
|
|
52
51
|
});
|
|
53
52
|
break;
|
|
54
53
|
case 'bearerAuth':
|
|
55
|
-
|
|
54
|
+
if (typeof value === 'boolean' && value) {
|
|
55
|
+
config.addBearerAuth();
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
config.addBearerAuth(value);
|
|
59
|
+
}
|
|
56
60
|
break;
|
|
57
61
|
case 'oAuth2':
|
|
58
|
-
|
|
62
|
+
if (typeof value === 'boolean' && value) {
|
|
63
|
+
config.addOAuth2();
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
config.addOAuth2(value);
|
|
67
|
+
}
|
|
59
68
|
break;
|
|
60
69
|
case 'apiKey':
|
|
61
|
-
|
|
70
|
+
if (typeof value === 'boolean' && value) {
|
|
71
|
+
config.addApiKey();
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
config.addApiKey(value);
|
|
75
|
+
}
|
|
62
76
|
break;
|
|
63
77
|
case 'basicAuth':
|
|
64
|
-
|
|
78
|
+
if (typeof value === 'boolean' && value) {
|
|
79
|
+
config.addBasicAuth();
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
config.addBasicAuth(value);
|
|
83
|
+
}
|
|
65
84
|
break;
|
|
66
85
|
case 'cookieAuth':
|
|
67
|
-
|
|
86
|
+
if (typeof value === 'boolean' && value) {
|
|
87
|
+
config.addCookieAuth();
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
config.addCookieAuth(value.cookieName, value.options, value.securityName);
|
|
91
|
+
}
|
|
68
92
|
break;
|
|
69
93
|
default:
|
|
70
94
|
break;
|
|
@@ -72,24 +96,16 @@ function buildExtraConfig(config, swaggerConfig) {
|
|
|
72
96
|
});
|
|
73
97
|
}
|
|
74
98
|
function enableDynamicAPISwagger(app, options = {}) {
|
|
75
|
-
const
|
|
99
|
+
const versionFile = require('../version.json');
|
|
100
|
+
const { title = 'MongoDB Dynamic API', description = 'Auto generated CRUD for MongoDB', version = (version_json_1.default ?? versionFile)?.version, path = '/dynamic-api', swaggerExtraConfig, swaggerDocumentOptions, } = options ?? {};
|
|
76
101
|
const config = new swagger_1.DocumentBuilder()
|
|
77
102
|
.setTitle(title)
|
|
78
103
|
.setDescription(description)
|
|
79
104
|
.setVersion(version);
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
if (swaggerExtraConfig) {
|
|
106
|
+
buildExtraConfig(config, swaggerExtraConfig);
|
|
107
|
+
}
|
|
108
|
+
const document = swagger_1.SwaggerModule.createDocument(app, config.build(), swaggerDocumentOptions);
|
|
82
109
|
swagger_1.SwaggerModule.setup(path, app, document);
|
|
83
110
|
}
|
|
84
111
|
exports.enableDynamicAPISwagger = enableDynamicAPISwagger;
|
|
85
|
-
function enableDynamicAPIVersioning(app, options) {
|
|
86
|
-
app.enableVersioning({
|
|
87
|
-
type: common_1.VersioningType.URI,
|
|
88
|
-
...options,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
exports.enableDynamicAPIVersioning = enableDynamicAPIVersioning;
|
|
92
|
-
function enableDynamicAPIValidation(app, options = {}) {
|
|
93
|
-
app.useGlobalPipes(new common_1.ValidationPipe(options));
|
|
94
|
-
}
|
|
95
|
-
exports.enableDynamicAPIValidation = enableDynamicAPIValidation;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableDynamicAPIValidation = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
function enableDynamicAPIValidation(app, options = {}) {
|
|
6
|
+
app.useGlobalPipes(new common_1.ValidationPipe(options));
|
|
7
|
+
}
|
|
8
|
+
exports.enableDynamicAPIValidation = enableDynamicAPIValidation;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { INestApplication, VersioningOptions } from '@nestjs/common';
|
|
2
|
+
declare function enableDynamicAPIVersioning(app: INestApplication, options?: VersioningOptions): void;
|
|
3
|
+
declare function addVersionSuffix(version?: string): string;
|
|
4
|
+
export { addVersionSuffix, enableDynamicAPIVersioning };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enableDynamicAPIVersioning = exports.addVersionSuffix = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
function enableDynamicAPIVersioning(app, options) {
|
|
6
|
+
app.enableVersioning({
|
|
7
|
+
type: common_1.VersioningType.URI,
|
|
8
|
+
...options,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.enableDynamicAPIVersioning = enableDynamicAPIVersioning;
|
|
12
|
+
function addVersionSuffix(version) {
|
|
13
|
+
return version ? `V${version}` : '';
|
|
14
|
+
}
|
|
15
|
+
exports.addVersionSuffix = addVersionSuffix;
|
package/src/index.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export * from './builders';
|
|
2
2
|
export * from './decorators';
|
|
3
3
|
export * from './dtos';
|
|
4
|
+
export * from './guards';
|
|
4
5
|
export * from './helpers';
|
|
6
|
+
export * from './interceptors';
|
|
5
7
|
export * from './interfaces';
|
|
6
8
|
export * from './mixins';
|
|
7
9
|
export * from './models';
|
|
8
|
-
export * from './
|
|
10
|
+
export * from './routes';
|
|
9
11
|
export * from './services';
|
|
10
12
|
export * from './dynamic-api.module';
|
package/src/index.js
CHANGED
|
@@ -17,10 +17,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./builders"), exports);
|
|
18
18
|
__exportStar(require("./decorators"), exports);
|
|
19
19
|
__exportStar(require("./dtos"), exports);
|
|
20
|
+
__exportStar(require("./guards"), exports);
|
|
20
21
|
__exportStar(require("./helpers"), exports);
|
|
22
|
+
__exportStar(require("./interceptors"), exports);
|
|
21
23
|
__exportStar(require("./interfaces"), exports);
|
|
22
24
|
__exportStar(require("./mixins"), exports);
|
|
23
25
|
__exportStar(require("./models"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
26
|
+
__exportStar(require("./routes"), exports);
|
|
25
27
|
__exportStar(require("./services"), exports);
|
|
26
28
|
__exportStar(require("./dynamic-api.module"), exports);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CacheInterceptor } from '@nestjs/cache-manager';
|
|
2
|
+
import { CallHandler, ExecutionContext } from '@nestjs/common';
|
|
3
|
+
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import { HttpAdapterHost } from '@nestjs/core/helpers/http-adapter-host';
|
|
5
|
+
import { Observable } from 'rxjs';
|
|
6
|
+
import { DynamicApiGlobalState } from '../interfaces';
|
|
7
|
+
export declare class DynamicApiCacheInterceptor extends CacheInterceptor {
|
|
8
|
+
protected readonly cacheManager: any;
|
|
9
|
+
protected readonly reflector: Reflector;
|
|
10
|
+
protected readonly httpAdapterHost: HttpAdapterHost;
|
|
11
|
+
private readonly state;
|
|
12
|
+
private readonly excludePaths;
|
|
13
|
+
constructor(cacheManager: any, reflector: Reflector, httpAdapterHost: HttpAdapterHost, state: DynamicApiGlobalState);
|
|
14
|
+
intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<any>>;
|
|
15
|
+
isRequestCacheable(context: ExecutionContext): boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DynamicApiCacheInterceptor = void 0;
|
|
13
|
+
const cache_manager_1 = require("@nestjs/cache-manager");
|
|
14
|
+
const common_1 = require("@nestjs/common");
|
|
15
|
+
const core_1 = require("@nestjs/core");
|
|
16
|
+
const http_adapter_host_1 = require("@nestjs/core/helpers/http-adapter-host");
|
|
17
|
+
let DynamicApiCacheInterceptor = class DynamicApiCacheInterceptor extends cache_manager_1.CacheInterceptor {
|
|
18
|
+
constructor(cacheManager, reflector, httpAdapterHost, state) {
|
|
19
|
+
super(cacheManager, reflector);
|
|
20
|
+
this.cacheManager = cacheManager;
|
|
21
|
+
this.reflector = reflector;
|
|
22
|
+
this.httpAdapterHost = httpAdapterHost;
|
|
23
|
+
this.state = state;
|
|
24
|
+
this.excludePaths = [
|
|
25
|
+
'/',
|
|
26
|
+
...this.state.cacheExcludedPaths,
|
|
27
|
+
];
|
|
28
|
+
this.httpAdapterHost = httpAdapterHost;
|
|
29
|
+
}
|
|
30
|
+
intercept(context, next) {
|
|
31
|
+
if (!this.state.isGlobalCacheEnabled) {
|
|
32
|
+
return Promise.resolve(next.handle());
|
|
33
|
+
}
|
|
34
|
+
return super.intercept(context, next);
|
|
35
|
+
}
|
|
36
|
+
isRequestCacheable(context) {
|
|
37
|
+
const req = context.switchToHttp().getRequest();
|
|
38
|
+
return (this.state.isGlobalCacheEnabled &&
|
|
39
|
+
this.allowedMethods.includes(req.method) &&
|
|
40
|
+
!this.excludePaths.includes(req.url));
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
exports.DynamicApiCacheInterceptor = DynamicApiCacheInterceptor;
|
|
44
|
+
exports.DynamicApiCacheInterceptor = DynamicApiCacheInterceptor = __decorate([
|
|
45
|
+
(0, common_1.Injectable)(),
|
|
46
|
+
__metadata("design:paramtypes", [Object, core_1.Reflector,
|
|
47
|
+
http_adapter_host_1.HttpAdapterHost, Object])
|
|
48
|
+
], DynamicApiCacheInterceptor);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './dynamic-api-cache.interceptor';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dynamic-api-cache.interceptor"), exports);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CacheStore, CacheStoreFactory } from '@nestjs/cache-manager/dist/interfaces/cache-manager.interface';
|
|
2
|
+
interface DynamicApiCacheOptions {
|
|
3
|
+
max?: number;
|
|
4
|
+
ttl?: number;
|
|
5
|
+
store?: string | CacheStoreFactory | CacheStore;
|
|
6
|
+
isCacheableValue?: (value: any) => boolean;
|
|
7
|
+
excludePaths?: string[];
|
|
8
|
+
}
|
|
9
|
+
export { DynamicApiCacheOptions };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseEntity } from '../models';
|
|
2
|
+
import { RouteType } from './dynamic-api-route-type.type';
|
|
3
|
+
type DynamicApiRouteCaslAbilityPredicate<Entity extends BaseEntity, T = any> = (entity: Entity, user?: T) => boolean;
|
|
4
|
+
type DynamicApiRegisterAbilityPredicate<T = any> = (user?: T) => boolean;
|
|
5
|
+
type DynamicApiControllerAbilityPredicate<Entity extends BaseEntity> = {
|
|
6
|
+
targets: RouteType[];
|
|
7
|
+
predicate: DynamicApiRouteCaslAbilityPredicate<Entity>;
|
|
8
|
+
};
|
|
9
|
+
export { DynamicApiRouteCaslAbilityPredicate, DynamicApiRegisterAbilityPredicate, DynamicApiControllerAbilityPredicate, };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
+
import { BaseEntity } from '../models';
|
|
3
|
+
import { DynamicApiControllerAbilityPredicate } from './dynamic-api-casl-ability.interface';
|
|
4
|
+
interface DynamicApiControllerOptions<Entity extends BaseEntity> {
|
|
5
|
+
path: string;
|
|
6
|
+
apiTag?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
isPublic?: boolean;
|
|
9
|
+
validationPipeOptions?: ValidationPipeOptions;
|
|
10
|
+
abilityPredicates?: DynamicApiControllerAbilityPredicate<Entity>[];
|
|
11
|
+
}
|
|
12
|
+
export { DynamicApiControllerOptions };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
|
+
type Credentials = {
|
|
3
|
+
loginField: string;
|
|
4
|
+
passwordField: string;
|
|
5
|
+
};
|
|
6
|
+
interface DynamicApiGlobalState {
|
|
7
|
+
initialized: boolean;
|
|
8
|
+
connectionName: string;
|
|
9
|
+
isGlobalCacheEnabled: boolean;
|
|
10
|
+
cacheExcludedPaths: string[];
|
|
11
|
+
isAuthEnabled: boolean;
|
|
12
|
+
credentials: Credentials;
|
|
13
|
+
jwtSecret: string | undefined;
|
|
14
|
+
onInitialized(): BehaviorSubject<boolean>;
|
|
15
|
+
}
|
|
16
|
+
export { DynamicApiGlobalState, Credentials };
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { Type
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
2
|
import { BaseEntity } from '../models';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
import { DynamicApiAuthOptions } from '../modules';
|
|
4
|
+
import { DynamicApiControllerOptions } from './dynamic-api-controller-options.interface';
|
|
5
|
+
import { DynamicApiCacheOptions } from './dynamic-api-cache-options.interface';
|
|
6
|
+
import { DynamicAPIRouteConfig } from './dynamic-api-route-config.interface';
|
|
7
|
+
declare const DYNAMIC_API_GLOBAL_STATE: unique symbol;
|
|
8
|
+
interface DynamicApiForRootOptions {
|
|
9
|
+
useGlobalCache?: boolean;
|
|
10
|
+
cacheOptions?: DynamicApiCacheOptions;
|
|
11
|
+
useAuth?: DynamicApiAuthOptions;
|
|
9
12
|
}
|
|
10
|
-
interface
|
|
13
|
+
interface DynamicApiForFeatureOptions<Entity extends BaseEntity> {
|
|
11
14
|
entity: Type<Entity>;
|
|
12
|
-
controllerOptions:
|
|
13
|
-
routes?:
|
|
15
|
+
controllerOptions: DynamicApiControllerOptions<Entity>;
|
|
16
|
+
routes?: DynamicAPIRouteConfig<Entity>[];
|
|
14
17
|
}
|
|
15
|
-
export {
|
|
18
|
+
export { DynamicApiForFeatureOptions, DynamicApiForRootOptions, DYNAMIC_API_GLOBAL_STATE };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MongoAbility } from '@casl/ability/dist/types';
|
|
2
|
+
import { ExecutionContext, Type } from '@nestjs/common';
|
|
3
|
+
import { Reflector } from '@nestjs/core';
|
|
4
|
+
import { BaseEntity } from '../models';
|
|
5
|
+
import { RouteType } from './dynamic-api-route-type.type';
|
|
6
|
+
type AppAbility<Entity extends BaseEntity> = MongoAbility<[RouteType, Type<Entity>]>;
|
|
7
|
+
interface IPolicyHandler<Entity extends BaseEntity> {
|
|
8
|
+
handle(ability: AppAbility<Entity>): boolean;
|
|
9
|
+
}
|
|
10
|
+
type PolicyHandlerCallback<Entity extends BaseEntity> = (ability: AppAbility<Entity>) => boolean;
|
|
11
|
+
type PolicyHandler<Entity extends BaseEntity> = IPolicyHandler<Entity> | PolicyHandlerCallback<Entity>;
|
|
12
|
+
interface PoliciesGuard<Entity extends BaseEntity> {
|
|
13
|
+
canActivate(context: ExecutionContext): boolean;
|
|
14
|
+
}
|
|
15
|
+
type PoliciesGuardConstructor<Entity extends BaseEntity> = new (reflector: Reflector) => PoliciesGuard<Entity>;
|
|
16
|
+
export { AppAbility, PolicyHandler, PoliciesGuardConstructor, PoliciesGuard };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ValidationPipeOptions } from '@nestjs/common';
|
|
2
|
+
import { BaseEntity } from '../models';
|
|
3
|
+
import { DynamicApiRouteCaslAbilityPredicate } from './dynamic-api-casl-ability.interface';
|
|
4
|
+
import { DTOsBundle } from './dynamic-api-route-dtos-bundle.type';
|
|
5
|
+
import { RouteType } from './dynamic-api-route-type.type';
|
|
6
|
+
interface DynamicAPIRouteConfig<Entity extends BaseEntity> {
|
|
7
|
+
type: RouteType;
|
|
8
|
+
isPublic?: boolean;
|
|
9
|
+
description?: string;
|
|
10
|
+
version?: string;
|
|
11
|
+
dTOs?: DTOsBundle;
|
|
12
|
+
validationPipeOptions?: ValidationPipeOptions;
|
|
13
|
+
abilityPredicate?: DynamicApiRouteCaslAbilityPredicate<Entity>;
|
|
14
|
+
}
|
|
15
|
+
export { DynamicAPIRouteConfig };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { CreateManyModule, CreateOneModule, DeleteManyModule, DeleteOneModule, DuplicateOneModule, GetManyModule, GetOneModule, ReplaceOneModule, UpdateManyModule, UpdateOneModule } from '../routes';
|
|
2
|
+
type RouteModule = CreateManyModule | CreateOneModule | DeleteManyModule | DeleteOneModule | DuplicateOneModule | GetManyModule | GetOneModule | ReplaceOneModule | UpdateManyModule | UpdateOneModule;
|
|
3
|
+
export { RouteModule };
|
|
@@ -22,8 +22,10 @@
|
|
|
22
22
|
/// <reference types="mongoose/types/validation" />
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
-
import { IndexDefinition, IndexOptions } from 'mongoose';
|
|
26
|
-
|
|
25
|
+
import { IndexDefinition, IndexOptions, Schema } from 'mongoose';
|
|
26
|
+
import { RouteType } from './dynamic-api-route-type.type';
|
|
27
|
+
type HookEvent = RouteType;
|
|
28
|
+
type MongoDBQuery = 'deleteMany' | 'deleteOne' | 'find' | 'findOne' | 'findOneAndReplace' | 'findOneAndUpdate' | 'save' | 'updateMany' | 'updateOne';
|
|
27
29
|
type SchemaHook = {
|
|
28
30
|
type: HookEvent;
|
|
29
31
|
method: 'pre' | 'post';
|
|
@@ -33,11 +35,16 @@ type SchemaHook = {
|
|
|
33
35
|
query?: boolean;
|
|
34
36
|
};
|
|
35
37
|
};
|
|
38
|
+
export declare const queryByRouteTypeMap: Map<HookEvent, {
|
|
39
|
+
query: MongoDBQuery;
|
|
40
|
+
softDeletableQuery?: MongoDBQuery;
|
|
41
|
+
}>;
|
|
36
42
|
interface DynamicAPISchemaOptionsInterface {
|
|
37
43
|
indexes?: {
|
|
38
44
|
fields: IndexDefinition;
|
|
39
45
|
options?: IndexOptions;
|
|
40
46
|
}[];
|
|
41
47
|
hooks?: SchemaHook[];
|
|
48
|
+
customInit?: (schema: Schema) => void;
|
|
42
49
|
}
|
|
43
50
|
export type { SchemaHook, DynamicAPISchemaOptionsInterface };
|
|
@@ -1,2 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.queryByRouteTypeMap = void 0;
|
|
4
|
+
exports.queryByRouteTypeMap = new Map([
|
|
5
|
+
['CreateMany', { query: 'save' }],
|
|
6
|
+
['CreateOne', { query: 'save' }],
|
|
7
|
+
['DeleteMany', { query: 'deleteMany', softDeletableQuery: 'updateMany' }],
|
|
8
|
+
['DeleteOne', { query: 'deleteOne', softDeletableQuery: 'updateOne' }],
|
|
9
|
+
['DuplicateMany', { query: 'save' }],
|
|
10
|
+
['DuplicateOne', { query: 'save' }],
|
|
11
|
+
['GetMany', { query: 'find' }],
|
|
12
|
+
['GetOne', { query: 'findOne' }],
|
|
13
|
+
['ReplaceOne', { query: 'findOneAndReplace' }],
|
|
14
|
+
['UpdateMany', { query: 'updateMany' }],
|
|
15
|
+
['UpdateOne', { query: 'findOneAndUpdate' }],
|
|
16
|
+
]);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { INestApplication, ValidationPipeOptions, VersioningOptions } from '@nestjs/common';
|
|
2
1
|
import { SwaggerDocumentOptions } from '@nestjs/swagger';
|
|
3
2
|
import { ExternalDocumentationObject, ParameterObject, SecuritySchemeObject, ServerVariableObject } from '@nestjs/swagger/dist/interfaces/open-api-spec.interface';
|
|
4
3
|
type DynamicAPISwaggerExtraConfig = {
|
|
@@ -37,25 +36,34 @@ type DynamicAPISwaggerExtraConfig = {
|
|
|
37
36
|
securityRequirements?: {
|
|
38
37
|
[key: string]: string[];
|
|
39
38
|
};
|
|
40
|
-
bearerAuth?:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
bearerAuth?: {
|
|
40
|
+
options?: SecuritySchemeObject;
|
|
41
|
+
name?: string;
|
|
42
|
+
} | boolean;
|
|
43
|
+
oAuth2?: {
|
|
44
|
+
options?: SecuritySchemeObject;
|
|
45
|
+
name?: string;
|
|
46
|
+
} | boolean;
|
|
47
|
+
apiKey?: {
|
|
48
|
+
options?: SecuritySchemeObject;
|
|
49
|
+
name?: string;
|
|
50
|
+
} | boolean;
|
|
51
|
+
basicAuth?: {
|
|
52
|
+
options?: SecuritySchemeObject;
|
|
53
|
+
name?: string;
|
|
54
|
+
} | boolean;
|
|
44
55
|
cookieAuth?: {
|
|
45
|
-
cookieName
|
|
46
|
-
options
|
|
47
|
-
securityName
|
|
48
|
-
};
|
|
56
|
+
cookieName?: string;
|
|
57
|
+
options?: SecuritySchemeObject;
|
|
58
|
+
securityName?: string;
|
|
59
|
+
} | boolean;
|
|
49
60
|
};
|
|
50
61
|
type DynamicAPISwaggerOptions = {
|
|
51
62
|
title?: string;
|
|
52
63
|
description?: string;
|
|
53
64
|
version?: string;
|
|
54
65
|
path?: string;
|
|
55
|
-
|
|
56
|
-
|
|
66
|
+
swaggerExtraConfig?: DynamicAPISwaggerExtraConfig;
|
|
67
|
+
swaggerDocumentOptions?: SwaggerDocumentOptions;
|
|
57
68
|
};
|
|
58
|
-
|
|
59
|
-
declare function enableDynamicAPIVersioning(app: INestApplication, options?: VersioningOptions): void;
|
|
60
|
-
declare function enableDynamicAPIValidation(app: INestApplication, options?: ValidationPipeOptions): void;
|
|
61
|
-
export { enableDynamicAPISwagger, enableDynamicAPIVersioning, enableDynamicAPIValidation, DynamicAPISwaggerOptions, DynamicAPISwaggerExtraConfig, };
|
|
69
|
+
export { DynamicAPISwaggerOptions, DynamicAPISwaggerExtraConfig };
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './dynamic-api-controller-options.interface';
|
|
2
|
+
export * from './dynamic-api-decorator-builder.interface';
|
|
3
|
+
export * from './dynamic-api-cache-options.interface';
|
|
4
|
+
export * from './dynamic-api-casl-ability.interface';
|
|
5
|
+
export * from './dynamic-api-entity-mappers.interface';
|
|
6
|
+
export * from './dynamic-api-global-state.interface';
|
|
2
7
|
export * from './dynamic-api-options.interface';
|
|
8
|
+
export * from './dynamic-api-policy-handler.interface';
|
|
9
|
+
export * from './dynamic-api-route-config.interface';
|
|
10
|
+
export * from './dynamic-api-route-dtos-bundle.type';
|
|
11
|
+
export * from './dynamic-api-route-module.type';
|
|
12
|
+
export * from './dynamic-api-route-type.type';
|
|
3
13
|
export * from './dynamic-api-schema-options.interface';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
6
|
-
export * from './service-provider.interface';
|
|
14
|
+
export * from './dynamic-api-service-provider.interface';
|
|
15
|
+
export * from './dynamic-api-swagger-options.type';
|
package/src/interfaces/index.js
CHANGED
|
@@ -14,9 +14,18 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./dynamic-api-controller-options.interface"), exports);
|
|
18
|
+
__exportStar(require("./dynamic-api-decorator-builder.interface"), exports);
|
|
19
|
+
__exportStar(require("./dynamic-api-cache-options.interface"), exports);
|
|
20
|
+
__exportStar(require("./dynamic-api-casl-ability.interface"), exports);
|
|
21
|
+
__exportStar(require("./dynamic-api-entity-mappers.interface"), exports);
|
|
22
|
+
__exportStar(require("./dynamic-api-global-state.interface"), exports);
|
|
18
23
|
__exportStar(require("./dynamic-api-options.interface"), exports);
|
|
24
|
+
__exportStar(require("./dynamic-api-policy-handler.interface"), exports);
|
|
25
|
+
__exportStar(require("./dynamic-api-route-config.interface"), exports);
|
|
26
|
+
__exportStar(require("./dynamic-api-route-dtos-bundle.type"), exports);
|
|
27
|
+
__exportStar(require("./dynamic-api-route-module.type"), exports);
|
|
28
|
+
__exportStar(require("./dynamic-api-route-type.type"), exports);
|
|
19
29
|
__exportStar(require("./dynamic-api-schema-options.interface"), exports);
|
|
20
|
-
__exportStar(require("./
|
|
21
|
-
__exportStar(require("./
|
|
22
|
-
__exportStar(require("./service-provider.interface"), exports);
|
|
30
|
+
__exportStar(require("./dynamic-api-service-provider.interface"), exports);
|
|
31
|
+
__exportStar(require("./dynamic-api-swagger-options.type"), exports);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import { DynamicApiRouteCaslAbilityPredicate, PoliciesGuardConstructor, RouteType } from '../interfaces';
|
|
3
|
+
import { BaseEntity } from '../models';
|
|
4
|
+
declare function CreatePoliciesGuardMixin<Entity extends BaseEntity>(entity: Type<Entity>, routeType: RouteType, version: string | undefined, abilityPredicate: DynamicApiRouteCaslAbilityPredicate<Entity> | undefined): PoliciesGuardConstructor<Entity>;
|
|
5
|
+
export { CreatePoliciesGuardMixin };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CreatePoliciesGuardMixin = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const core_1 = require("@nestjs/core");
|
|
15
|
+
const guards_1 = require("../guards");
|
|
16
|
+
const helpers_1 = require("../helpers");
|
|
17
|
+
function CreatePoliciesGuardMixin(entity, routeType, version, abilityPredicate) {
|
|
18
|
+
let RoutePoliciesGuard = class RoutePoliciesGuard extends guards_1.BasePoliciesGuard {
|
|
19
|
+
constructor(reflector) {
|
|
20
|
+
super(reflector);
|
|
21
|
+
this.reflector = reflector;
|
|
22
|
+
this.routeType = routeType;
|
|
23
|
+
this.entity = entity;
|
|
24
|
+
this.abilityPredicate = abilityPredicate;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
RoutePoliciesGuard = __decorate([
|
|
28
|
+
(0, common_1.Injectable)(),
|
|
29
|
+
__metadata("design:paramtypes", [core_1.Reflector])
|
|
30
|
+
], RoutePoliciesGuard);
|
|
31
|
+
Object.defineProperty(RoutePoliciesGuard, 'name', {
|
|
32
|
+
value: `${routeType}${entity.name}${(0, helpers_1.addVersionSuffix)(version)}PoliciesGuard`,
|
|
33
|
+
writable: false,
|
|
34
|
+
});
|
|
35
|
+
return RoutePoliciesGuard;
|
|
36
|
+
}
|
|
37
|
+
exports.CreatePoliciesGuardMixin = CreatePoliciesGuardMixin;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Type } from '@nestjs/common';
|
|
2
2
|
import { BaseEntity } from '../models';
|
|
3
|
-
declare function EntityPresenterMixin<Entity extends BaseEntity>(entity: Type<Entity>,
|
|
3
|
+
declare function EntityPresenterMixin<Entity extends BaseEntity>(entity: Type<Entity>, additionalKeysToExclude?: (keyof Entity)[]): {
|
|
4
4
|
new (...args: any[]): {};
|
|
5
5
|
apply(this: Function, thisArg: any, argArray?: any): any;
|
|
6
6
|
call(this: Function, thisArg: any, ...argArray: any[]): any;
|
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EntityPresenterMixin = void 0;
|
|
4
4
|
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const baseEntityKeysToExclude = () => [
|
|
6
|
+
'deletedAt',
|
|
7
|
+
'isDeleted',
|
|
8
|
+
'_id',
|
|
9
|
+
'__v',
|
|
10
|
+
];
|
|
11
|
+
function EntityPresenterMixin(entity, additionalKeysToExclude) {
|
|
12
|
+
const keysToExclude = [
|
|
13
|
+
...baseEntityKeysToExclude(),
|
|
14
|
+
...(additionalKeysToExclude ?? []),
|
|
15
|
+
];
|
|
16
|
+
class EntityPresenter extends (0, swagger_1.OmitType)(entity, keysToExclude) {
|
|
7
17
|
}
|
|
8
18
|
return EntityPresenter;
|
|
9
19
|
}
|