@rockster/core 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cache/cache-cleaner.d.ts +7 -0
- package/cache/cache-cleaner.js +28 -0
- package/cache/cache.controller.d.ts +10 -0
- package/cache/cache.controller.js +53 -0
- package/cache/constants.d.ts +5 -0
- package/cache/constants.js +6 -0
- package/cache/decorators/index.d.ts +2 -0
- package/cache/decorators/index.js +18 -0
- package/cache/decorators/inject-cache.decorator.d.ts +1 -0
- package/cache/decorators/inject-cache.decorator.js +14 -0
- package/cache/decorators/key-value.d.ts +2 -0
- package/cache/decorators/key-value.js +40 -0
- package/cache/functions/get-cache.d.ts +1 -0
- package/cache/functions/get-cache.js +8 -0
- package/cache/functions/get-key.-handle.d.ts +2 -0
- package/cache/functions/get-key.-handle.js +23 -0
- package/cache/index.d.ts +3 -0
- package/cache/index.js +19 -0
- package/cache/interfaces/cache-instance.d.ts +4 -0
- package/cache/interfaces/cache-instance.js +2 -0
- package/cache/interfaces/cache-key-options.d.ts +6 -0
- package/cache/interfaces/cache-key-options.js +2 -0
- package/cache/interfaces/cache-options.d.ts +12 -0
- package/cache/interfaces/cache-options.js +2 -0
- package/cache/interfaces/get-key-value-handle.d.ts +1 -0
- package/cache/interfaces/get-key-value-handle.js +2 -0
- package/cache/interfaces/index.d.ts +4 -0
- package/cache/interfaces/index.js +20 -0
- package/command/constants.d.ts +4 -0
- package/command/constants.js +7 -0
- package/command/decorators/index.d.ts +6 -0
- package/command/decorators/index.js +22 -0
- package/command/decorators/only-modify.decorator.d.ts +1 -0
- package/command/decorators/only-modify.decorator.js +14 -0
- package/command/decorators/post-action.decorator.d.ts +2 -0
- package/command/decorators/post-action.decorator.js +26 -0
- package/command/decorators/post-content.decorator.d.ts +1 -0
- package/command/decorators/post-content.decorator.js +11 -0
- package/command/decorators/read-only.decorator.d.ts +1 -0
- package/command/decorators/read-only.decorator.js +14 -0
- package/command/decorators/remove-action.decorator.d.ts +2 -0
- package/command/decorators/remove-action.decorator.js +27 -0
- package/command/decorators/remove-content.decorator.d.ts +1 -0
- package/command/decorators/remove-content.decorator.js +11 -0
- package/command/functions/execute-post.d.ts +2 -0
- package/command/functions/execute-post.js +50 -0
- package/command/functions/execute-remove.d.ts +4 -0
- package/command/functions/execute-remove.js +50 -0
- package/command/interfaces/command-property.d.ts +7 -0
- package/command/interfaces/command-property.js +2 -0
- package/command/interfaces/index.d.ts +5 -0
- package/command/interfaces/index.js +21 -0
- package/command/interfaces/post-action-options.d.ts +23 -0
- package/command/interfaces/post-action-options.js +2 -0
- package/command/interfaces/post-content.d.ts +8 -0
- package/command/interfaces/post-content.js +2 -0
- package/command/interfaces/remove-aciton-options.d.ts +23 -0
- package/command/interfaces/remove-aciton-options.js +2 -0
- package/command/interfaces/remove-content.d.ts +5 -0
- package/command/interfaces/remove-content.js +2 -0
- package/command/services/post-action-builder.d.ts +19 -0
- package/command/services/post-action-builder.js +219 -0
- package/command/services/remove-action-builder.d.ts +14 -0
- package/command/services/remove-action-builder.js +165 -0
- package/command/utils/deep-merge-keep-undefined.d.ts +1 -0
- package/command/utils/deep-merge-keep-undefined.js +18 -0
- package/common/entities/base-entity.d.ts +7 -0
- package/common/entities/base-entity.js +47 -0
- package/common/index.d.ts +1 -0
- package/common/index.js +17 -0
- package/common/interfaces/enum/index.d.ts +3 -0
- package/common/interfaces/enum/index.js +19 -0
- package/common/interfaces/enum/object-type.d.ts +12 -0
- package/common/interfaces/enum/object-type.js +16 -0
- package/common/interfaces/enum/property-type.d.ts +7 -0
- package/common/interfaces/enum/property-type.js +11 -0
- package/common/interfaces/enum/request-status.d.ts +3 -0
- package/common/interfaces/enum/request-status.js +7 -0
- package/common/interfaces/get-type-callback.d.ts +2 -0
- package/common/interfaces/get-type-callback.js +2 -0
- package/common/interfaces/index.d.ts +2 -0
- package/common/interfaces/index.js +18 -0
- package/common/models/executed-response.d.ts +3 -0
- package/common/models/executed-response.js +22 -0
- package/controllers/constants.d.ts +11 -0
- package/controllers/constants.js +14 -0
- package/controllers/controller.controller.d.ts +19 -0
- package/controllers/controller.controller.js +50 -0
- package/controllers/decorators/actions/action-content.decorator.d.ts +2 -0
- package/controllers/decorators/actions/action-content.decorator.js +20 -0
- package/controllers/decorators/actions/action.decorator.d.ts +2 -0
- package/controllers/decorators/actions/action.decorator.js +28 -0
- package/controllers/decorators/actions/index.d.ts +2 -0
- package/controllers/decorators/actions/index.js +18 -0
- package/controllers/decorators/controller.decorator.d.ts +3 -0
- package/controllers/decorators/controller.decorator.js +32 -0
- package/controllers/decorators/http-methods/custom-response.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/custom-response.decorator.js +14 -0
- package/controllers/decorators/http-methods/delete.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/delete.decorator.js +16 -0
- package/controllers/decorators/http-methods/from-body.decorator.d.ts +3 -0
- package/controllers/decorators/http-methods/from-body.decorator.js +24 -0
- package/controllers/decorators/http-methods/from-headers.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/from-headers.decorator.js +21 -0
- package/controllers/decorators/http-methods/from-params.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/from-params.decorator.js +21 -0
- package/controllers/decorators/http-methods/from-query.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/from-query.decorator.js +21 -0
- package/controllers/decorators/http-methods/get.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/get.decorator.js +16 -0
- package/controllers/decorators/http-methods/http-req.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/http-req.decorator.js +10 -0
- package/controllers/decorators/http-methods/index.d.ts +12 -0
- package/controllers/decorators/http-methods/index.js +28 -0
- package/controllers/decorators/http-methods/patch.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/patch.decorator.js +16 -0
- package/controllers/decorators/http-methods/post.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/post.decorator.js +16 -0
- package/controllers/decorators/http-methods/put.decorator.d.ts +1 -0
- package/controllers/decorators/http-methods/put.decorator.js +16 -0
- package/controllers/decorators/http-methods/response-type.decorator.d.ts +6 -0
- package/controllers/decorators/http-methods/response-type.decorator.js +19 -0
- package/controllers/decorators/index.d.ts +5 -0
- package/controllers/decorators/index.js +21 -0
- package/controllers/decorators/no-auth.decorator.d.ts +1 -0
- package/controllers/decorators/no-auth.decorator.js +11 -0
- package/controllers/decorators/request-context.decorator.d.ts +1 -0
- package/controllers/decorators/request-context.decorator.js +11 -0
- package/controllers/decorators/session.decorator.d.ts +1 -0
- package/controllers/decorators/session.decorator.js +10 -0
- package/controllers/index.d.ts +2 -0
- package/controllers/index.js +18 -0
- package/controllers/interfaces/action-options.d.ts +31 -0
- package/controllers/interfaces/action-options.js +2 -0
- package/controllers/interfaces/content-options.d.ts +5 -0
- package/controllers/interfaces/content-options.js +2 -0
- package/controllers/interfaces/controller-object.d.ts +7 -0
- package/controllers/interfaces/controller-object.js +2 -0
- package/controllers/interfaces/controller-options.d.ts +4 -0
- package/controllers/interfaces/controller-options.js +2 -0
- package/controllers/interfaces/controller-property.d.ts +34 -0
- package/controllers/interfaces/controller-property.js +2 -0
- package/controllers/interfaces/enum/index.d.ts +1 -0
- package/controllers/interfaces/enum/index.js +17 -0
- package/controllers/interfaces/enum/request-interceptor.d.ts +3 -0
- package/controllers/interfaces/enum/request-interceptor.js +6 -0
- package/controllers/interfaces/get-only-data.d.ts +3 -0
- package/controllers/interfaces/get-only-data.js +2 -0
- package/controllers/interfaces/index.d.ts +9 -0
- package/controllers/interfaces/index.js +25 -0
- package/controllers/interfaces/on-before-validation-data.d.ts +4 -0
- package/controllers/interfaces/on-before-validation-data.js +2 -0
- package/controllers/interfaces/response-options.d.ts +5 -0
- package/controllers/interfaces/response-options.js +3 -0
- package/controllers/services/default-action-builder.d.ts +14 -0
- package/controllers/services/default-action-builder.js +166 -0
- package/controllers/services/restful-action-builder.d.ts +11 -0
- package/controllers/services/restful-action-builder.js +132 -0
- package/core/core.controller.d.ts +41 -0
- package/core/core.controller.js +208 -0
- package/core/functions/bootstrap.d.ts +3 -0
- package/core/functions/bootstrap.js +13 -0
- package/core/functions/create-action.d.ts +2 -0
- package/core/functions/create-action.js +18 -0
- package/core/functions/create-interceptor.d.ts +12 -0
- package/core/functions/create-interceptor.js +76 -0
- package/core/functions/format-message.d.ts +2 -0
- package/core/functions/format-message.js +7 -0
- package/core/functions/get-action-path.d.ts +1 -0
- package/core/functions/get-action-path.js +7 -0
- package/core/functions/get-env.d.ts +11 -0
- package/core/functions/get-env.js +19 -0
- package/core/functions/get-node-key.d.ts +1 -0
- package/core/functions/get-node-key.js +7 -0
- package/core/functions/get-other-types.d.ts +2 -0
- package/core/functions/get-other-types.js +19 -0
- package/core/index.d.ts +10 -0
- package/core/index.js +26 -0
- package/core/interfaces/action-def.d.ts +16 -0
- package/core/interfaces/action-def.js +2 -0
- package/core/interfaces/action-docs.d.ts +10 -0
- package/core/interfaces/action-docs.js +2 -0
- package/core/interfaces/core-options.d.ts +32 -0
- package/core/interfaces/core-options.js +2 -0
- package/core/interfaces/docs-options.d.ts +3 -0
- package/core/interfaces/docs-options.js +2 -0
- package/core/interfaces/enum/connect-type.d.ts +4 -0
- package/core/interfaces/enum/connect-type.js +8 -0
- package/core/interfaces/enum/index.d.ts +1 -0
- package/core/interfaces/enum/index.js +17 -0
- package/core/interfaces/format-message-options.d.ts +6 -0
- package/core/interfaces/format-message-options.js +2 -0
- package/core/interfaces/forms-options.d.ts +3 -0
- package/core/interfaces/forms-options.js +2 -0
- package/core/interfaces/index.d.ts +23 -0
- package/core/interfaces/index.js +39 -0
- package/core/interfaces/interceptor.d.ts +38 -0
- package/core/interfaces/interceptor.js +7 -0
- package/core/interfaces/locale-options.d.ts +5 -0
- package/core/interfaces/locale-options.js +2 -0
- package/core/interfaces/mapper.d.ts +3 -0
- package/core/interfaces/mapper.js +2 -0
- package/core/interfaces/object-docs.d.ts +5 -0
- package/core/interfaces/object-docs.js +3 -0
- package/core/interfaces/object.d.ts +15 -0
- package/core/interfaces/object.js +2 -0
- package/core/interfaces/pending-action.d.ts +10 -0
- package/core/interfaces/pending-action.js +2 -0
- package/core/interfaces/property-docs.d.ts +5 -0
- package/core/interfaces/property-docs.js +2 -0
- package/core/interfaces/property.d.ts +9 -0
- package/core/interfaces/property.js +2 -0
- package/core/interfaces/request-callback-handle.d.ts +3 -0
- package/core/interfaces/request-callback-handle.js +2 -0
- package/core/interfaces/request-callback.d.ts +4 -0
- package/core/interfaces/request-callback.js +2 -0
- package/core/interfaces/request-callbacks.d.ts +5 -0
- package/core/interfaces/request-callbacks.js +2 -0
- package/core/interfaces/request-context.d.ts +28 -0
- package/core/interfaces/request-context.js +2 -0
- package/core/interfaces/request-data.d.ts +6 -0
- package/core/interfaces/request-data.js +2 -0
- package/core/interfaces/router-options.d.ts +5 -0
- package/core/interfaces/router-options.js +2 -0
- package/core/interfaces/sanitizer.d.ts +4 -0
- package/core/interfaces/sanitizer.js +2 -0
- package/core/interfaces/storage-options.d.ts +6 -0
- package/core/interfaces/storage-options.js +2 -0
- package/core/interfaces/translations-options.d.ts +7 -0
- package/core/interfaces/translations-options.js +2 -0
- package/core/interfaces/transport-options.d.ts +3 -0
- package/core/interfaces/transport-options.js +2 -0
- package/core/services/context-builder.d.ts +15 -0
- package/core/services/context-builder.js +91 -0
- package/core/services/locale-service.d.ts +13 -0
- package/core/services/locale-service.js +71 -0
- package/core/services/node-control.service.d.ts +5 -0
- package/core/services/node-control.service.js +46 -0
- package/core/services/object-loader.d.ts +10 -0
- package/core/services/object-loader.js +27 -0
- package/core/services/request-executor.d.ts +9 -0
- package/core/services/request-executor.js +108 -0
- package/core/services/request-router.d.ts +15 -0
- package/core/services/request-router.js +127 -0
- package/database/contexts/index.d.ts +1 -0
- package/database/contexts/index.js +17 -0
- package/database/contexts/transaction-context.d.ts +6 -0
- package/database/contexts/transaction-context.js +5 -0
- package/database/database.controller.d.ts +20 -0
- package/database/database.controller.js +92 -0
- package/database/decorators/column.decorator.d.ts +72 -0
- package/database/decorators/column.decorator.js +9 -0
- package/database/decorators/entity.decorator.d.ts +2 -0
- package/database/decorators/entity.decorator.js +10 -0
- package/database/decorators/id-generated.decorator.d.ts +30 -0
- package/database/decorators/id-generated.decorator.js +76 -0
- package/database/decorators/id.decorator.d.ts +13 -0
- package/database/decorators/id.decorator.js +27 -0
- package/database/decorators/index.d.ts +13 -0
- package/database/decorators/index.js +29 -0
- package/database/decorators/inject-data-source.decorator.d.ts +1 -0
- package/database/decorators/inject-data-source.decorator.js +13 -0
- package/database/decorators/inject-repository.decorator.d.ts +2 -0
- package/database/decorators/inject-repository.decorator.js +17 -0
- package/database/decorators/protect-context-column.decorator.d.ts +3 -0
- package/database/decorators/protect-context-column.decorator.js +11 -0
- package/database/decorators/protect-entity.decorator.d.ts +4 -0
- package/database/decorators/protect-entity.decorator.js +12 -0
- package/database/decorators/protect-key-column.decorator.d.ts +2 -0
- package/database/decorators/protect-key-column.decorator.js +11 -0
- package/database/decorators/protect-target-column.decorator.d.ts +3 -0
- package/database/decorators/protect-target-column.decorator.js +11 -0
- package/database/decorators/protected-entity.decorator.d.ts +8 -0
- package/database/decorators/protected-entity.decorator.js +25 -0
- package/database/decorators/relation.decorator.d.ts +3 -0
- package/database/decorators/relation.decorator.js +13 -0
- package/database/decorators/virtual-column.decorator.d.ts +4 -0
- package/database/decorators/virtual-column.decorator.js +16 -0
- package/database/environment.d.ts +21 -0
- package/database/environment.js +25 -0
- package/database/exports/index.d.ts +1 -0
- package/database/exports/index.js +17 -0
- package/database/exports/typeorm.d.ts +1 -0
- package/database/exports/typeorm.js +9 -0
- package/database/extensions/select-query-builder.d.ts +11 -0
- package/database/extensions/select-query-builder.js +21 -0
- package/database/functions/column-decorator.d.ts +6 -0
- package/database/functions/column-decorator.js +31 -0
- package/database/functions/create-entity.d.ts +7 -0
- package/database/functions/create-entity.js +51 -0
- package/database/functions/create-new-class.d.ts +1 -0
- package/database/functions/create-new-class.js +16 -0
- package/database/functions/entity-decorator.d.ts +3 -0
- package/database/functions/entity-decorator.js +29 -0
- package/database/functions/execute-if-not-exists-column.d.ts +3 -0
- package/database/functions/execute-if-not-exists-column.js +16 -0
- package/database/functions/execute-if-not-exists-table.d.ts +3 -0
- package/database/functions/execute-if-not-exists-table.js +14 -0
- package/database/functions/find-relation.d.ts +3 -0
- package/database/functions/find-relation.js +43 -0
- package/database/functions/generate-id.d.ts +2 -0
- package/database/functions/generate-id.js +14 -0
- package/database/functions/get-column-type.d.ts +3 -0
- package/database/functions/get-column-type.js +18 -0
- package/database/functions/get-id-property.d.ts +3 -0
- package/database/functions/get-id-property.js +14 -0
- package/database/functions/get-name-by-strategy.d.ts +6 -0
- package/database/functions/get-name-by-strategy.js +9 -0
- package/database/functions/get-primitive-type.d.ts +3 -0
- package/database/functions/get-primitive-type.js +8 -0
- package/database/functions/get-relations.d.ts +2 -0
- package/database/functions/get-relations.js +12 -0
- package/database/functions/has-update.d.ts +2 -0
- package/database/functions/has-update.js +7 -0
- package/database/functions/inject-repository-handle.d.ts +2 -0
- package/database/functions/inject-repository-handle.js +36 -0
- package/database/functions/object-to-jsonb.d.ts +1 -0
- package/database/functions/object-to-jsonb.js +36 -0
- package/database/functions/register-column.d.ts +7 -0
- package/database/functions/register-column.js +16 -0
- package/database/functions/register-entity.d.ts +5 -0
- package/database/functions/register-entity.js +8 -0
- package/database/functions/register-generated-id.d.ts +6 -0
- package/database/functions/register-generated-id.js +8 -0
- package/database/functions/register-id.d.ts +7 -0
- package/database/functions/register-id.js +8 -0
- package/database/functions/register-relation.d.ts +8 -0
- package/database/functions/register-relation.js +12 -0
- package/database/functions/relation-decorator.d.ts +4 -0
- package/database/functions/relation-decorator.js +74 -0
- package/database/functions/use-protector.d.ts +2 -0
- package/database/functions/use-protector.js +10 -0
- package/database/functions/use-repository.d.ts +2 -0
- package/database/functions/use-repository.js +10 -0
- package/database/functions/use-transaction.d.ts +1 -0
- package/database/functions/use-transaction.js +12 -0
- package/database/index.d.ts +16 -0
- package/database/index.js +32 -0
- package/database/interfaces/base-columns-name-override.d.ts +6 -0
- package/database/interfaces/base-columns-name-override.js +2 -0
- package/database/interfaces/column-def.d.ts +26 -0
- package/database/interfaces/column-def.js +2 -0
- package/database/interfaces/connection.options.d.ts +15 -0
- package/database/interfaces/connection.options.js +2 -0
- package/database/interfaces/direact-alias.d.ts +1 -0
- package/database/interfaces/direact-alias.js +2 -0
- package/database/interfaces/entity-object.d.ts +15 -0
- package/database/interfaces/entity-object.js +2 -0
- package/database/interfaces/entity-options.d.ts +15 -0
- package/database/interfaces/entity-options.js +2 -0
- package/database/interfaces/entity-property.d.ts +19 -0
- package/database/interfaces/entity-property.js +2 -0
- package/database/interfaces/enum/column-def-type.d.ts +5 -0
- package/database/interfaces/enum/column-def-type.js +9 -0
- package/database/interfaces/enum/index.d.ts +5 -0
- package/database/interfaces/enum/index.js +21 -0
- package/database/interfaces/enum/naming-strategy-type.d.ts +5 -0
- package/database/interfaces/enum/naming-strategy-type.js +9 -0
- package/database/interfaces/enum/nano-id-alphabet-type.d.ts +14 -0
- package/database/interfaces/enum/nano-id-alphabet-type.js +18 -0
- package/database/interfaces/enum/order-by-direction.d.ts +4 -0
- package/database/interfaces/enum/order-by-direction.js +8 -0
- package/database/interfaces/enum/primary-strategy-type.d.ts +5 -0
- package/database/interfaces/enum/primary-strategy-type.js +9 -0
- package/database/interfaces/enum/relation-path-type.d.ts +4 -0
- package/database/interfaces/enum/relation-path-type.js +8 -0
- package/database/interfaces/execute-callback.d.ts +3 -0
- package/database/interfaces/execute-callback.js +2 -0
- package/database/interfaces/id-column-def.d.ts +6 -0
- package/database/interfaces/id-column-def.js +2 -0
- package/database/interfaces/index.d.ts +17 -0
- package/database/interfaces/index.js +33 -0
- package/database/interfaces/inverse-alias.d.ts +5 -0
- package/database/interfaces/inverse-alias.js +2 -0
- package/database/interfaces/nano-id-column-options.d.ts +12 -0
- package/database/interfaces/nano-id-column-options.js +2 -0
- package/database/interfaces/path.d.ts +43 -0
- package/database/interfaces/path.js +2 -0
- package/database/interfaces/protector.d.ts +51 -0
- package/database/interfaces/protector.js +2 -0
- package/database/interfaces/register-one-to-many-handle.d.ts +3 -0
- package/database/interfaces/register-one-to-many-handle.js +2 -0
- package/database/interfaces/register-one-to-many.d.ts +6 -0
- package/database/interfaces/register-one-to-many.js +2 -0
- package/database/interfaces/relation-def.d.ts +8 -0
- package/database/interfaces/relation-def.js +2 -0
- package/database/interfaces/relation-path.d.ts +10 -0
- package/database/interfaces/relation-path.js +2 -0
- package/database/interfaces/relation.options.d.ts +9 -0
- package/database/interfaces/relation.options.js +2 -0
- package/database/interfaces/repository.d.ts +8 -0
- package/database/interfaces/repository.js +2 -0
- package/database/migrations/1737637321043-UUIDVarcharMigration.d.ts +5 -0
- package/database/migrations/1737637321043-UUIDVarcharMigration.js +81 -0
- package/database/migrations/use-uuid-varchar-migration.d.ts +2 -0
- package/database/migrations/use-uuid-varchar-migration.js +10 -0
- package/database/services/paths-builder.d.ts +12 -0
- package/database/services/paths-builder.js +82 -0
- package/database/services/protect-builder.d.ts +59 -0
- package/database/services/protect-builder.js +523 -0
- package/database/services/repository.service.d.ts +14 -0
- package/database/services/repository.service.js +75 -0
- package/forms/entities/form.d.ts +8 -0
- package/forms/entities/form.js +61 -0
- package/forms/entities/property.d.ts +7 -0
- package/forms/entities/property.js +51 -0
- package/forms/forms.controller.d.ts +8 -0
- package/forms/forms.controller.js +59 -0
- package/forms/interfaces/form-item.d.ts +5 -0
- package/forms/interfaces/form-item.js +2 -0
- package/forms/interfaces/form.d.ts +8 -0
- package/forms/interfaces/form.js +2 -0
- package/forms/interfaces/property.d.ts +6 -0
- package/forms/interfaces/property.js +2 -0
- package/forms/migrations/1725969116484-CreateFormsTables.d.ts +5 -0
- package/forms/migrations/1725969116484-CreateFormsTables.js +38 -0
- package/forms/models/form-load.request.d.ts +3 -0
- package/forms/models/form-load.request.js +21 -0
- package/forms/queries/form.query.d.ts +1 -0
- package/forms/queries/form.query.js +9 -0
- package/forms/queries/property.query.d.ts +1 -0
- package/forms/queries/property.query.js +9 -0
- package/forms/requests/form.request.d.ts +14 -0
- package/forms/requests/form.request.js +83 -0
- package/forms/requests/property.request.d.ts +8 -0
- package/forms/requests/property.request.js +65 -0
- package/forms/services/form.service.d.ts +20 -0
- package/forms/services/form.service.js +64 -0
- package/forms/services/property.service.d.ts +6 -0
- package/forms/services/property.service.js +30 -0
- package/forms/utils/build-form-validator.d.ts +11 -0
- package/forms/utils/build-form-validator.js +30 -0
- package/forms/utils/get-form-items.d.ts +2 -0
- package/forms/utils/get-form-items.js +20 -0
- package/global.d.ts +52 -0
- package/global.js +50 -0
- package/http/http.controller.d.ts +25 -0
- package/http/http.controller.js +137 -0
- package/http/index.d.ts +2 -0
- package/http/index.js +18 -0
- package/http/interfaces/csrf.options.d.ts +11 -0
- package/http/interfaces/csrf.options.js +2 -0
- package/http/interfaces/http-request.d.ts +6 -0
- package/http/interfaces/http-request.js +2 -0
- package/http/interfaces/http-response.d.ts +4 -0
- package/http/interfaces/http-response.js +3 -0
- package/http/interfaces/http-settings.d.ts +13 -0
- package/http/interfaces/http-settings.js +2 -0
- package/http/interfaces/http-use.d.ts +6 -0
- package/http/interfaces/http-use.js +2 -0
- package/http/interfaces/index.d.ts +6 -0
- package/http/interfaces/index.js +22 -0
- package/http/interfaces/route.d.ts +10 -0
- package/http/interfaces/route.js +2 -0
- package/index.d.ts +44 -0
- package/index.js +65 -0
- package/jobs/constants.d.ts +2 -0
- package/jobs/constants.js +4 -0
- package/jobs/decorators/index.d.ts +1 -0
- package/jobs/decorators/index.js +17 -0
- package/jobs/decorators/job.decorator.d.ts +11 -0
- package/jobs/decorators/job.decorator.js +26 -0
- package/jobs/interfaces/index.d.ts +3 -0
- package/jobs/interfaces/index.js +19 -0
- package/jobs/interfaces/job-data.d.ts +13 -0
- package/jobs/interfaces/job-data.js +2 -0
- package/jobs/interfaces/job-executor.d.ts +3 -0
- package/jobs/interfaces/job-executor.js +2 -0
- package/jobs/interfaces/job-object.d.ts +6 -0
- package/jobs/interfaces/job-object.js +2 -0
- package/jobs/interfaces/job.options.d.ts +1 -0
- package/jobs/interfaces/job.options.js +2 -0
- package/jobs/jobs.controller.d.ts +18 -0
- package/jobs/jobs.controller.js +122 -0
- package/module/decorators/index.d.ts +4 -0
- package/module/decorators/index.js +20 -0
- package/module/decorators/module.decorator.d.ts +2 -0
- package/module/decorators/module.decorator.js +16 -0
- package/module/decorators/on-after-app-start.d.ts +1 -0
- package/module/decorators/on-after-app-start.js +11 -0
- package/module/decorators/on-after-database-init.d.ts +1 -0
- package/module/decorators/on-after-database-init.js +11 -0
- package/module/decorators/on-module-init.d.ts +1 -0
- package/module/decorators/on-module-init.js +11 -0
- package/module/index.d.ts +3 -0
- package/module/index.js +19 -0
- package/module/interfaces/index.d.ts +3 -0
- package/module/interfaces/index.js +19 -0
- package/module/interfaces/module-events.d.ts +5 -0
- package/module/interfaces/module-events.js +2 -0
- package/module/interfaces/module-object.d.ts +7 -0
- package/module/interfaces/module-object.js +2 -0
- package/module/interfaces/module-options.d.ts +8 -0
- package/module/interfaces/module-options.js +2 -0
- package/module/module.controller.d.ts +31 -0
- package/module/module.controller.js +159 -0
- package/package.json +70 -0
- package/query/constants.d.ts +2 -0
- package/query/constants.js +5 -0
- package/query/decorators/index.d.ts +1 -0
- package/query/decorators/index.js +17 -0
- package/query/decorators/query-content.decorator.d.ts +1 -0
- package/query/decorators/query-content.decorator.js +11 -0
- package/query/functions/add-join.d.ts +5 -0
- package/query/functions/add-join.js +37 -0
- package/query/functions/create-query-builder.d.ts +4 -0
- package/query/functions/create-query-builder.js +54 -0
- package/query/functions/create-query.d.ts +5 -0
- package/query/functions/create-query.js +96 -0
- package/query/functions/describe-query-filter.d.ts +7 -0
- package/query/functions/describe-query-filter.js +298 -0
- package/query/functions/execute-query.d.ts +11 -0
- package/query/functions/execute-query.js +74 -0
- package/query/functions/get-column-path.d.ts +2 -0
- package/query/functions/get-column-path.js +14 -0
- package/query/functions/get-native-select.d.ts +2 -0
- package/query/functions/get-native-select.js +9 -0
- package/query/functions/load-properties.d.ts +19 -0
- package/query/functions/load-properties.js +138 -0
- package/query/functions/map-query-property-to-column-name.d.ts +3 -0
- package/query/functions/map-query-property-to-column-name.js +17 -0
- package/query/functions/replace-property-key-to-column-name.d.ts +1 -0
- package/query/functions/replace-property-key-to-column-name.js +10 -0
- package/query/interfaces/index.d.ts +3 -0
- package/query/interfaces/index.js +19 -0
- package/query/interfaces/query-action-options.d.ts +14 -0
- package/query/interfaces/query-action-options.js +2 -0
- package/query/interfaces/query-object.d.ts +10 -0
- package/query/interfaces/query-object.js +2 -0
- package/query/interfaces/query.d.ts +54 -0
- package/query/interfaces/query.js +2 -0
- package/query/models/base-query-response.d.ts +12 -0
- package/query/models/base-query-response.js +41 -0
- package/query/services/query-action-builder.d.ts +14 -0
- package/query/services/query-action-builder.js +145 -0
- package/security/auth.controller.d.ts +8 -0
- package/security/auth.controller.js +68 -0
- package/security/constants.d.ts +0 -0
- package/security/constants.js +2 -0
- package/security/env.d.ts +7 -0
- package/security/env.js +8 -0
- package/security/functions/add-protect.d.ts +2 -0
- package/security/functions/add-protect.js +10 -0
- package/security/functions/add-protected.d.ts +3 -0
- package/security/functions/add-protected.js +23 -0
- package/security/functions/create-authorization.d.ts +2 -0
- package/security/functions/create-authorization.js +12 -0
- package/security/functions/find-auth-context.d.ts +3 -0
- package/security/functions/find-auth-context.js +25 -0
- package/security/functions/is-auth-enabled.d.ts +1 -0
- package/security/functions/is-auth-enabled.js +7 -0
- package/security/functions/use-auth.d.ts +1 -0
- package/security/functions/use-auth.js +8 -0
- package/security/index.d.ts +3 -0
- package/security/index.js +19 -0
- package/security/interceptors/index.d.ts +1 -0
- package/security/interceptors/index.js +17 -0
- package/security/interceptors/is-authorized.interceptor.d.ts +2 -0
- package/security/interceptors/is-authorized.interceptor.js +34 -0
- package/security/interfaces/auth-controller.d.ts +7 -0
- package/security/interfaces/auth-controller.js +2 -0
- package/security/interfaces/auth-object.d.ts +6 -0
- package/security/interfaces/auth-object.js +2 -0
- package/security/interfaces/auth-property.d.ts +4 -0
- package/security/interfaces/auth-property.js +2 -0
- package/security/interfaces/authorization-schema.d.ts +26 -0
- package/security/interfaces/authorization-schema.js +2 -0
- package/security/interfaces/index.d.ts +6 -0
- package/security/interfaces/index.js +22 -0
- package/security/interfaces/security-options.d.ts +8 -0
- package/security/interfaces/security-options.js +2 -0
- package/security/interfaces/ssl-certificate.d.ts +4 -0
- package/security/interfaces/ssl-certificate.js +2 -0
- package/security/models/auth-context-data.d.ts +4 -0
- package/security/models/auth-context-data.js +25 -0
- package/security/models/auth-context.d.ts +9 -0
- package/security/models/auth-context.js +48 -0
- package/security/models/auth-key.d.ts +7 -0
- package/security/models/auth-key.js +36 -0
- package/security/models/get-user-permissions-payload.d.ts +4 -0
- package/security/models/get-user-permissions-payload.js +21 -0
- package/security/models/get-user-permissions-response.d.ts +3 -0
- package/security/models/get-user-permissions-response.js +22 -0
- package/security/models/set-user-permissions-payload.d.ts +5 -0
- package/security/models/set-user-permissions-payload.js +26 -0
- package/security/requests/security.request.d.ts +14 -0
- package/security/requests/security.request.js +75 -0
- package/security/services/authorization.service.d.ts +11 -0
- package/security/services/authorization.service.js +60 -0
- package/storage/entities/metadata.entity.d.ts +19 -0
- package/storage/entities/metadata.entity.js +86 -0
- package/storage/entities/storage.entity.d.ts +6 -0
- package/storage/entities/storage.entity.js +32 -0
- package/storage/env.d.ts +9 -0
- package/storage/env.js +9 -0
- package/storage/functions/index.d.ts +1 -0
- package/storage/functions/index.js +17 -0
- package/storage/functions/set-storage-settings.d.ts +2 -0
- package/storage/functions/set-storage-settings.js +13 -0
- package/storage/index.d.ts +2 -0
- package/storage/index.js +18 -0
- package/storage/interfaces/directory-metadata.d.ts +6 -0
- package/storage/interfaces/directory-metadata.js +2 -0
- package/storage/interfaces/enum/gcp-credentials-type.d.ts +3 -0
- package/storage/interfaces/enum/gcp-credentials-type.js +7 -0
- package/storage/interfaces/enum/index.d.ts +3 -0
- package/storage/interfaces/enum/index.js +19 -0
- package/storage/interfaces/enum/metadata-type.d.ts +4 -0
- package/storage/interfaces/enum/metadata-type.js +8 -0
- package/storage/interfaces/enum/storage-type.d.ts +3 -0
- package/storage/interfaces/enum/storage-type.js +7 -0
- package/storage/interfaces/file-metadata.d.ts +12 -0
- package/storage/interfaces/file-metadata.js +2 -0
- package/storage/interfaces/index.d.ts +7 -0
- package/storage/interfaces/index.js +23 -0
- package/storage/interfaces/metadata.d.ts +18 -0
- package/storage/interfaces/metadata.js +2 -0
- package/storage/interfaces/storage-controller.d.ts +13 -0
- package/storage/interfaces/storage-controller.js +2 -0
- package/storage/interfaces/storage-settings.d.ts +16 -0
- package/storage/interfaces/storage-settings.js +2 -0
- package/storage/interfaces/storage.d.ts +7 -0
- package/storage/interfaces/storage.js +2 -0
- package/storage/services/routes.service.d.ts +31 -0
- package/storage/services/routes.service.js +384 -0
- package/storage/services/storage.service.d.ts +10 -0
- package/storage/services/storage.service.js +92 -0
- package/storage/storage.controller.d.ts +10 -0
- package/storage/storage.controller.js +49 -0
- package/tasks/constants.d.ts +12 -0
- package/tasks/constants.js +21 -0
- package/tasks/decorators/index.d.ts +1 -0
- package/tasks/decorators/index.js +17 -0
- package/tasks/decorators/task.decorator.d.ts +2 -0
- package/tasks/decorators/task.decorator.js +45 -0
- package/tasks/functions/create-task-message-find.d.ts +3 -0
- package/tasks/functions/create-task-message-find.js +23 -0
- package/tasks/functions/create-task-message-model.d.ts +3 -0
- package/tasks/functions/create-task-message-model.js +11 -0
- package/tasks/functions/create-task-message-receptor.d.ts +3 -0
- package/tasks/functions/create-task-message-receptor.js +23 -0
- package/tasks/functions/create-task-message-retry.d.ts +3 -0
- package/tasks/functions/create-task-message-retry.js +22 -0
- package/tasks/functions/create-task-message-schema.d.ts +182 -0
- package/tasks/functions/create-task-message-schema.js +20 -0
- package/tasks/functions/create-task-message-trigger.d.ts +2 -0
- package/tasks/functions/create-task-message-trigger.js +18 -0
- package/tasks/functions/create-task-naming.d.ts +2 -0
- package/tasks/functions/create-task-naming.js +31 -0
- package/tasks/functions/generate-entity-id.d.ts +1 -0
- package/tasks/functions/generate-entity-id.js +5 -0
- package/tasks/functions/get-check-table-exists-script.d.ts +1 -0
- package/tasks/functions/get-check-table-exists-script.js +12 -0
- package/tasks/functions/get-create-table-partition-script.d.ts +2 -0
- package/tasks/functions/get-create-table-partition-script.js +10 -0
- package/tasks/functions/get-create-table-script.d.ts +1 -0
- package/tasks/functions/get-create-table-script.js +22 -0
- package/tasks/functions/get-database-connection-name.d.ts +1 -0
- package/tasks/functions/get-database-connection-name.js +8 -0
- package/tasks/functions/get-database-uri.d.ts +1 -0
- package/tasks/functions/get-database-uri.js +8 -0
- package/tasks/functions/get-partitions-of-table-script.d.ts +1 -0
- package/tasks/functions/get-partitions-of-table-script.js +10 -0
- package/tasks/functions/get-pending-task-script.d.ts +2 -0
- package/tasks/functions/get-pending-task-script.js +19 -0
- package/tasks/functions/parse-task-message-search.d.ts +20 -0
- package/tasks/functions/parse-task-message-search.js +62 -0
- package/tasks/functions/throw-task-error.d.ts +1 -0
- package/tasks/functions/throw-task-error.js +7 -0
- package/tasks/index.d.ts +3 -0
- package/tasks/index.js +19 -0
- package/tasks/interfaces/index.d.ts +6 -0
- package/tasks/interfaces/index.js +22 -0
- package/tasks/interfaces/task-naming.d.ts +11 -0
- package/tasks/interfaces/task-naming.js +2 -0
- package/tasks/interfaces/task-object.d.ts +17 -0
- package/tasks/interfaces/task-object.js +2 -0
- package/tasks/interfaces/task-post-intercept.d.ts +8 -0
- package/tasks/interfaces/task-post-intercept.js +2 -0
- package/tasks/interfaces/task-runner.d.ts +6 -0
- package/tasks/interfaces/task-runner.js +2 -0
- package/tasks/interfaces/task-search-intercept.d.ts +4 -0
- package/tasks/interfaces/task-search-intercept.js +2 -0
- package/tasks/interfaces/task-settings.d.ts +15 -0
- package/tasks/interfaces/task-settings.js +2 -0
- package/tasks/models/task-error.d.ts +8 -0
- package/tasks/models/task-error.js +40 -0
- package/tasks/models/task-message-find.d.ts +3 -0
- package/tasks/models/task-message-find.js +21 -0
- package/tasks/models/task-message.d.ts +13 -0
- package/tasks/models/task-message.js +57 -0
- package/tasks/requests/task.request.d.ts +17 -0
- package/tasks/requests/task.request.js +71 -0
- package/tasks/services/task-manager.service.d.ts +10 -0
- package/tasks/services/task-manager.service.js +60 -0
- package/tasks/services/task-runner.service.d.ts +16 -0
- package/tasks/services/task-runner.service.js +88 -0
- package/tasks/tasks.controller.d.ts +19 -0
- package/tasks/tasks.controller.js +75 -0
- package/translations/entities/translation-config.entity.d.ts +9 -0
- package/translations/entities/translation-config.entity.js +65 -0
- package/translations/entities/translation-values.entity.d.ts +10 -0
- package/translations/entities/translation-values.entity.js +53 -0
- package/translations/env.d.ts +2 -0
- package/translations/env.js +7 -0
- package/translations/functions/check-can-use.d.ts +1 -0
- package/translations/functions/check-can-use.js +10 -0
- package/translations/functions/create-translation-config.d.ts +3 -0
- package/translations/functions/create-translation-config.js +19 -0
- package/translations/functions/create-translation-values.d.ts +3 -0
- package/translations/functions/create-translation-values.js +22 -0
- package/translations/functions/get-translation-config.d.ts +3 -0
- package/translations/functions/get-translation-config.js +14 -0
- package/translations/interfaces/translation-config.d.ts +8 -0
- package/translations/interfaces/translation-config.js +2 -0
- package/translations/interfaces/translation-values.d.ts +9 -0
- package/translations/interfaces/translation-values.js +2 -0
- package/translations/interfaces/translator-handle.d.ts +4 -0
- package/translations/interfaces/translator-handle.js +2 -0
- package/translations/migrations/1723760669185-CreateTranslationTables.d.ts +5 -0
- package/translations/migrations/1723760669185-CreateTranslationTables.js +43 -0
- package/translations/models/get-values.request.d.ts +5 -0
- package/translations/models/get-values.request.js +25 -0
- package/translations/models/get-values.response.d.ts +4 -0
- package/translations/models/get-values.response.js +20 -0
- package/translations/queries/translation-config.query.d.ts +1 -0
- package/translations/queries/translation-config.query.js +9 -0
- package/translations/queries/translation-values.query.d.ts +1 -0
- package/translations/queries/translation-values.query.js +16 -0
- package/translations/requests/translation.request.d.ts +16 -0
- package/translations/requests/translation.request.js +99 -0
- package/translations/services/translations.service.d.ts +11 -0
- package/translations/services/translations.service.js +56 -0
- package/translations/services/translator.service.d.ts +11 -0
- package/translations/services/translator.service.js +56 -0
- package/translations/translations.controller.d.ts +8 -0
- package/translations/translations.controller.js +57 -0
- package/transport/entities/transport-client.d.ts +12 -0
- package/transport/entities/transport-client.js +67 -0
- package/transport/entities/transport-gateway-status.d.ts +9 -0
- package/transport/entities/transport-gateway-status.js +51 -0
- package/transport/entities/transport-gateway.d.ts +6 -0
- package/transport/entities/transport-gateway.js +35 -0
- package/transport/environment.d.ts +4 -0
- package/transport/environment.js +6 -0
- package/transport/index.d.ts +2 -0
- package/transport/index.js +18 -0
- package/transport/interfaces/index.d.ts +1 -0
- package/transport/interfaces/index.js +17 -0
- package/transport/interfaces/transport-module-options.d.ts +14 -0
- package/transport/interfaces/transport-module-options.js +8 -0
- package/transport/transport.module.d.ts +5 -0
- package/transport/transport.module.js +38 -0
- package/web-socket/constants.d.ts +1 -0
- package/web-socket/constants.js +4 -0
- package/web-socket/functions/encode-message.d.ts +2 -0
- package/web-socket/functions/encode-message.js +14 -0
- package/web-socket/functions/get-fake-http-context.d.ts +26 -0
- package/web-socket/functions/get-fake-http-context.js +55 -0
- package/web-socket/functions/get-ip-address.d.ts +1 -0
- package/web-socket/functions/get-ip-address.js +23 -0
- package/web-socket/functions/parse-message.d.ts +1 -0
- package/web-socket/functions/parse-message.js +10 -0
- package/web-socket/index.d.ts +5 -0
- package/web-socket/index.js +21 -0
- package/web-socket/interfaces/client.d.ts +15 -0
- package/web-socket/interfaces/client.js +2 -0
- package/web-socket/interfaces/enum/client-type.d.ts +4 -0
- package/web-socket/interfaces/enum/client-type.js +8 -0
- package/web-socket/interfaces/enum/index.d.ts +3 -0
- package/web-socket/interfaces/enum/index.js +19 -0
- package/web-socket/interfaces/enum/message-type.d.ts +6 -0
- package/web-socket/interfaces/enum/message-type.js +10 -0
- package/web-socket/interfaces/enum/ws-connection-type.d.ts +4 -0
- package/web-socket/interfaces/enum/ws-connection-type.js +8 -0
- package/web-socket/interfaces/index.d.ts +4 -0
- package/web-socket/interfaces/index.js +20 -0
- package/web-socket/interfaces/message.d.ts +30 -0
- package/web-socket/interfaces/message.js +2 -0
- package/web-socket/interfaces/ws-connection.d.ts +4 -0
- package/web-socket/interfaces/ws-connection.js +2 -0
- package/web-socket/web-socket.controller.d.ts +25 -0
- package/web-socket/web-socket.controller.js +184 -0
- package/workers/functions/decode-message.d.ts +2 -0
- package/workers/functions/decode-message.js +7 -0
- package/workers/functions/dispatch-task.d.ts +2 -0
- package/workers/functions/dispatch-task.js +23 -0
- package/workers/functions/encode-message.d.ts +2 -0
- package/workers/functions/encode-message.js +7 -0
- package/workers/interfaces/enum/index.d.ts +1 -0
- package/workers/interfaces/enum/index.js +17 -0
- package/workers/interfaces/enum/worker-message-type.d.ts +6 -0
- package/workers/interfaces/enum/worker-message-type.js +10 -0
- package/workers/interfaces/index.d.ts +3 -0
- package/workers/interfaces/index.js +19 -0
- package/workers/interfaces/worker-data.d.ts +9 -0
- package/workers/interfaces/worker-data.js +2 -0
- package/workers/interfaces/worker-message.d.ts +20 -0
- package/workers/interfaces/worker-message.js +2 -0
- package/workers/workers.controller.d.ts +6 -0
- package/workers/workers.controller.js +72 -0
|
@@ -0,0 +1,523 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ProtectBuilder = void 0;
|
|
10
|
+
const class_injector_1 = require("@rockster/class-injector");
|
|
11
|
+
const common_1 = require("@rockster/common");
|
|
12
|
+
const __1 = require("..");
|
|
13
|
+
const use_repository_1 = require("../functions/use-repository");
|
|
14
|
+
const find_auth_context_1 = require("../../security/functions/find-auth-context");
|
|
15
|
+
let ProtectBuilder = class ProtectBuilder {
|
|
16
|
+
async build(object) {
|
|
17
|
+
if (object.protected) {
|
|
18
|
+
core.isAuthRequired = true;
|
|
19
|
+
await this.buildProtectedConfig(object);
|
|
20
|
+
}
|
|
21
|
+
if (object.isProtect) {
|
|
22
|
+
await this.buildProtectorConfig(object);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
buildProtectorConfig(object) {
|
|
26
|
+
const protectorData = this
|
|
27
|
+
.getProtectorData(object.objectClass);
|
|
28
|
+
object.protector = {
|
|
29
|
+
isAuthorized: ({ keys, userId, context, contextId, entityManager }) => {
|
|
30
|
+
return this.checkIsAuthorized({
|
|
31
|
+
context,
|
|
32
|
+
contextId,
|
|
33
|
+
data: protectorData,
|
|
34
|
+
keys,
|
|
35
|
+
userId,
|
|
36
|
+
entityManager
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
getUserPermissions: this.getGetUserPermissions(protectorData),
|
|
40
|
+
setUserPermissions: this.getSetUserPermissions(protectorData)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
getRepository(target, entityManager) {
|
|
44
|
+
return entityManager
|
|
45
|
+
? entityManager.getRepository(target)
|
|
46
|
+
: (0, use_repository_1.useRepository)(target);
|
|
47
|
+
}
|
|
48
|
+
createQueryBuilder({ authKeys, data, protectorData, userId, displayContext, entityManager, protectedData }) {
|
|
49
|
+
let contextSQL = '';
|
|
50
|
+
let keySQL = '';
|
|
51
|
+
let contextName = protectedData
|
|
52
|
+
? protectedData.object.objectKey
|
|
53
|
+
: displayContext;
|
|
54
|
+
const repository = this
|
|
55
|
+
.getRepository(protectorData.object.objectClass, entityManager);
|
|
56
|
+
const userIdValue = Number.isInteger(userId)
|
|
57
|
+
? userId
|
|
58
|
+
: `'${userId}'`;
|
|
59
|
+
if (protectorData.context) {
|
|
60
|
+
const contextId = protectedData
|
|
61
|
+
? data[protectedData.context.propertyKey]
|
|
62
|
+
: data[protectorData.context.propertyKey];
|
|
63
|
+
if (!contextId) {
|
|
64
|
+
throw new common_1.ForbiddenError({
|
|
65
|
+
message: `Context value not found for [${contextName}]`
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
const contextIdValue = Number.isInteger(contextId)
|
|
69
|
+
? contextId
|
|
70
|
+
: `'${contextId}'`;
|
|
71
|
+
contextSQL = ` AND "${protectorData.object.alias}"."${protectorData.context.propertyKey}" = ${contextIdValue}`;
|
|
72
|
+
}
|
|
73
|
+
if (protectorData.key && authKeys?.length > 0) {
|
|
74
|
+
const keysFilter = this
|
|
75
|
+
.buildFilterKeys(protectorData.object.alias, protectorData.key.propertyKey, authKeys);
|
|
76
|
+
keySQL = ` AND (${keysFilter})`;
|
|
77
|
+
}
|
|
78
|
+
const queryBuilder = repository
|
|
79
|
+
.createQueryBuilder(protectorData.object.alias)
|
|
80
|
+
.where(`
|
|
81
|
+
"${protectorData.object.alias}"."${protectorData.target.propertyKey}" = ${userIdValue}
|
|
82
|
+
${contextSQL}
|
|
83
|
+
${keySQL}
|
|
84
|
+
`);
|
|
85
|
+
return queryBuilder;
|
|
86
|
+
}
|
|
87
|
+
buildFilterKeys(protectorAlias, protectorKey, keys) {
|
|
88
|
+
let keysFilter = '';
|
|
89
|
+
for (const key of keys) {
|
|
90
|
+
if (keysFilter) {
|
|
91
|
+
keysFilter += ' OR ';
|
|
92
|
+
}
|
|
93
|
+
;
|
|
94
|
+
keysFilter += `"${protectorAlias}"."${protectorKey}" = '${key}'`;
|
|
95
|
+
}
|
|
96
|
+
return keysFilter;
|
|
97
|
+
}
|
|
98
|
+
getQueryContextAndKeyCondition(protectorData, protectedData, protectorAlias, alias, contextParams, rootPath) {
|
|
99
|
+
let context = '';
|
|
100
|
+
let key = '';
|
|
101
|
+
if (protectorData.context) {
|
|
102
|
+
const protectorContext = protectorData.context.propertyKey;
|
|
103
|
+
const protectedContext = protectedData.context.propertyKey;
|
|
104
|
+
context = ` AND "${alias}"."${protectedContext}" = "${protectorAlias}"."${protectorContext}"`;
|
|
105
|
+
if (!protectedData.isContext) {
|
|
106
|
+
if (rootPath && rootPath !== protectorData.context.getRelationType()) {
|
|
107
|
+
const contextId = contextParams[`$${protectorContext}`];
|
|
108
|
+
if (!contextId) {
|
|
109
|
+
throw new common_1.ValidationError({
|
|
110
|
+
properties: [{
|
|
111
|
+
message: `Context value is required to this query`,
|
|
112
|
+
property: `$${protectorContext}`,
|
|
113
|
+
value: contextId
|
|
114
|
+
}]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
const contextIdValue = Number.isInteger(contextId)
|
|
118
|
+
? contextId
|
|
119
|
+
: `'${contextId}'`;
|
|
120
|
+
context = `${context} AND "${alias}"."${protectedContext}" = ${contextIdValue}`;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (protectorData.key
|
|
125
|
+
&& protectedData.options?.keys?.read) {
|
|
126
|
+
const authContext = (0, find_auth_context_1.findAuthContext)(protectorData.object.objectClass);
|
|
127
|
+
const keysFilter = this
|
|
128
|
+
.buildFilterKeys(protectorAlias, protectorData.key.propertyKey, [
|
|
129
|
+
protectedData.options.keys.read.name,
|
|
130
|
+
authContext.adminKey.name,
|
|
131
|
+
authContext.ownerKey.name
|
|
132
|
+
]);
|
|
133
|
+
key = ` AND (${keysFilter})`;
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
context,
|
|
137
|
+
key
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
buildProtectedConfig(object) {
|
|
141
|
+
const protectorData = this
|
|
142
|
+
.getProtectorData(object.protected.type());
|
|
143
|
+
const protectedData = this
|
|
144
|
+
.getProtectedData(protectorData, object);
|
|
145
|
+
const overrideData = {
|
|
146
|
+
canCreateProtector: null,
|
|
147
|
+
canCreateProtected: null,
|
|
148
|
+
canRemoveProtector: null,
|
|
149
|
+
canRemoveProtected: null,
|
|
150
|
+
canModifyProtector: null,
|
|
151
|
+
canModifyProtected: null,
|
|
152
|
+
canReadProtector: null,
|
|
153
|
+
canReadProtected: null
|
|
154
|
+
};
|
|
155
|
+
if (protectedData.options?.keys?.create?.protector) {
|
|
156
|
+
overrideData.canCreateProtector = this.getProtectorData(protectedData.options.keys.create.protector());
|
|
157
|
+
overrideData.canCreateProtected = this.getProtectedData(overrideData.canCreateProtector, object);
|
|
158
|
+
}
|
|
159
|
+
if (protectedData.options?.keys?.modify?.protector) {
|
|
160
|
+
overrideData.canModifyProtector = this.getProtectorData(protectedData.options.keys.modify.protector());
|
|
161
|
+
overrideData.canModifyProtected = this.getProtectedData(overrideData.canModifyProtector, object);
|
|
162
|
+
}
|
|
163
|
+
if (protectedData.options?.keys?.read?.protector) {
|
|
164
|
+
overrideData.canReadProtector = this.getProtectorData(protectedData.options.keys.read.protector());
|
|
165
|
+
overrideData.canReadProtected = this.getProtectedData(overrideData.canReadProtector, object);
|
|
166
|
+
}
|
|
167
|
+
if (protectedData.options?.keys?.remove?.protector) {
|
|
168
|
+
overrideData.canRemoveProtector = this.getProtectorData(protectedData.options.keys.remove.protector());
|
|
169
|
+
overrideData.canRemoveProtected = this.getProtectedData(overrideData.canRemoveProtector, object);
|
|
170
|
+
}
|
|
171
|
+
object.protector = {
|
|
172
|
+
target: protectorData.object.objectClass,
|
|
173
|
+
relationCondition: ({ userId, contextParams, alias, rootPath }) => {
|
|
174
|
+
const protectorAlias = `${protectorData.object.alias}_${protectedData.object.alias}`;
|
|
175
|
+
const protectorTarget = protectorData.target.propertyKey;
|
|
176
|
+
const userIdValue = Number.isInteger(userId)
|
|
177
|
+
? userId
|
|
178
|
+
: `'${userId}'`;
|
|
179
|
+
const { context, key } = this
|
|
180
|
+
.getQueryContextAndKeyCondition(protectorData, protectedData, protectorAlias, alias, contextParams, rootPath);
|
|
181
|
+
let condition = `
|
|
182
|
+
AND EXISTS (
|
|
183
|
+
SELECT * FROM "${protectorData.object.tableName}" "${protectorAlias}"
|
|
184
|
+
WHERE "${protectorAlias}"."${protectorTarget}" = ${userIdValue}
|
|
185
|
+
${context}${key}
|
|
186
|
+
)
|
|
187
|
+
`;
|
|
188
|
+
return condition;
|
|
189
|
+
},
|
|
190
|
+
rootCondition: ({ userId, contextParams, queryBuilder, rootAlias }) => {
|
|
191
|
+
const protectorAlias = `${protectorData.object.alias}_${protectedData.object.alias}`;
|
|
192
|
+
const protectorTarget = protectorData.target.propertyKey;
|
|
193
|
+
const userIdValue = Number.isInteger(userId)
|
|
194
|
+
? userId
|
|
195
|
+
: `'${userId}'`;
|
|
196
|
+
const { context, key } = this
|
|
197
|
+
.getQueryContextAndKeyCondition(protectorData, protectedData, protectorAlias, rootAlias, contextParams);
|
|
198
|
+
queryBuilder.innerJoin(protectorData.object.objectClass, protectorAlias, `"${protectorAlias}"."${protectorTarget}" = ${userIdValue}${context}${key}`);
|
|
199
|
+
return queryBuilder;
|
|
200
|
+
},
|
|
201
|
+
canCreate: async (userId, data, entityManager) => {
|
|
202
|
+
const canCreateProtectorData = overrideData.canCreateProtector || protectorData;
|
|
203
|
+
const canCreateProtectedData = overrideData.canCreateProtected || protectedData;
|
|
204
|
+
const key = canCreateProtectedData.options?.keys?.create?.name;
|
|
205
|
+
if (!key) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const forbiddenError = new common_1.ForbiddenError({
|
|
209
|
+
message: `Current user [${userId}] cannot create [${canCreateProtectedData.object.objectClass.name}]`,
|
|
210
|
+
requirements: [key]
|
|
211
|
+
});
|
|
212
|
+
const authContext = (0, find_auth_context_1.findAuthContext)(canCreateProtectorData.object.objectClass);
|
|
213
|
+
const exists = await this
|
|
214
|
+
.createQueryBuilder({
|
|
215
|
+
protectorData: canCreateProtectorData,
|
|
216
|
+
userId,
|
|
217
|
+
data,
|
|
218
|
+
authKeys: key
|
|
219
|
+
? [
|
|
220
|
+
key,
|
|
221
|
+
authContext.adminKey.name,
|
|
222
|
+
authContext.ownerKey.name
|
|
223
|
+
]
|
|
224
|
+
: [],
|
|
225
|
+
protectedData: canCreateProtectedData,
|
|
226
|
+
entityManager
|
|
227
|
+
})
|
|
228
|
+
.getOne();
|
|
229
|
+
if (!exists) {
|
|
230
|
+
throw forbiddenError;
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
canRemove: async (userId, entityId, entityManager) => {
|
|
234
|
+
const canRemoveProtectorData = overrideData.canRemoveProtector || protectorData;
|
|
235
|
+
const canRemoveProtectedData = overrideData.canRemoveProtected || protectedData;
|
|
236
|
+
const key = canRemoveProtectedData.options?.keys?.remove?.name;
|
|
237
|
+
if (!key) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
const forbiddenError = new common_1.ForbiddenError({
|
|
241
|
+
message: `Current user [${userId}] cannot remove [${canRemoveProtectedData.object.objectClass.name}]`,
|
|
242
|
+
requirements: [key]
|
|
243
|
+
});
|
|
244
|
+
let storedValue;
|
|
245
|
+
const repository = this
|
|
246
|
+
.getRepository(canRemoveProtectedData.object.objectClass, entityManager);
|
|
247
|
+
const invalidError = new common_1.BadRequestError({
|
|
248
|
+
message: `invalid id value [${entityId}]`
|
|
249
|
+
});
|
|
250
|
+
try {
|
|
251
|
+
storedValue = await repository
|
|
252
|
+
.findOneBy({
|
|
253
|
+
[canRemoveProtectedData.object.idProperty]: entityId
|
|
254
|
+
});
|
|
255
|
+
if (!storedValue) {
|
|
256
|
+
throw invalidError;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
throw invalidError;
|
|
261
|
+
}
|
|
262
|
+
const authContext = (0, find_auth_context_1.findAuthContext)(canRemoveProtectorData.object.objectClass);
|
|
263
|
+
const exists = await this
|
|
264
|
+
.createQueryBuilder({
|
|
265
|
+
protectorData: canRemoveProtectorData,
|
|
266
|
+
userId,
|
|
267
|
+
data: storedValue,
|
|
268
|
+
authKeys: key
|
|
269
|
+
? [
|
|
270
|
+
key,
|
|
271
|
+
authContext.adminKey.name,
|
|
272
|
+
authContext.ownerKey.name
|
|
273
|
+
]
|
|
274
|
+
: [],
|
|
275
|
+
protectedData: canRemoveProtectedData,
|
|
276
|
+
entityManager
|
|
277
|
+
})
|
|
278
|
+
.getOne();
|
|
279
|
+
if (!exists) {
|
|
280
|
+
throw forbiddenError;
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
canModify: async (userId, data, entityManager) => {
|
|
284
|
+
const canModifyProtectorData = overrideData.canModifyProtector || protectorData;
|
|
285
|
+
const canModifyProtectedData = overrideData.canModifyProtected || protectedData;
|
|
286
|
+
const key = canModifyProtectedData.options?.keys?.modify?.name;
|
|
287
|
+
if (!key) {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
const forbiddenError = new common_1.ForbiddenError({
|
|
291
|
+
message: `Current user [${userId}] cannot modify [${canModifyProtectedData.object.objectClass.name}]`,
|
|
292
|
+
requirements: [key]
|
|
293
|
+
});
|
|
294
|
+
const repository = this
|
|
295
|
+
.getRepository(canModifyProtectedData.object.objectClass, entityManager);
|
|
296
|
+
const storedId = data[canModifyProtectedData.object.idProperty];
|
|
297
|
+
if (!storedId) {
|
|
298
|
+
throw new common_1.ForbiddenError({
|
|
299
|
+
message: `Context value not found for [${canModifyProtectedData.object.objectClass.name}]`
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
if (canModifyProtectorData.context) {
|
|
303
|
+
try {
|
|
304
|
+
const storedValue = await repository
|
|
305
|
+
.findOneBy({
|
|
306
|
+
[canModifyProtectedData.object.idProperty]: storedId
|
|
307
|
+
});
|
|
308
|
+
data[canModifyProtectedData.context.propertyKey] = storedValue[canModifyProtectedData.context.propertyKey];
|
|
309
|
+
}
|
|
310
|
+
catch (error) {
|
|
311
|
+
throw new common_1.BadRequestError({
|
|
312
|
+
message: `invalid id value [${storedId}]`
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const authContext = (0, find_auth_context_1.findAuthContext)(canModifyProtectorData.object.objectClass);
|
|
317
|
+
const exists = await this
|
|
318
|
+
.createQueryBuilder({
|
|
319
|
+
protectorData: canModifyProtectorData,
|
|
320
|
+
userId,
|
|
321
|
+
data,
|
|
322
|
+
authKeys: key
|
|
323
|
+
? [
|
|
324
|
+
key,
|
|
325
|
+
authContext.adminKey.name,
|
|
326
|
+
authContext.ownerKey.name
|
|
327
|
+
]
|
|
328
|
+
: [],
|
|
329
|
+
protectedData: canModifyProtectedData,
|
|
330
|
+
entityManager
|
|
331
|
+
})
|
|
332
|
+
.getOne();
|
|
333
|
+
if (!exists) {
|
|
334
|
+
throw forbiddenError;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
getSetUserPermissions(data) {
|
|
340
|
+
return async ({ contextId, userId, entityManager, context, targetUserId, accessKeys }) => {
|
|
341
|
+
const authContext = (0, find_auth_context_1.findAuthContext)(context);
|
|
342
|
+
await this.checkIsAuthorized({
|
|
343
|
+
data,
|
|
344
|
+
context,
|
|
345
|
+
contextId,
|
|
346
|
+
keys: [
|
|
347
|
+
authContext.adminKey.name,
|
|
348
|
+
authContext.ownerKey.name
|
|
349
|
+
],
|
|
350
|
+
userId,
|
|
351
|
+
entityManager
|
|
352
|
+
});
|
|
353
|
+
if (targetUserId === userId
|
|
354
|
+
&& !accessKeys.find((accessKey) => accessKey === authContext.ownerKey.name)
|
|
355
|
+
&& !accessKeys.find((accessKey) => accessKey === authContext.adminKey.name)) {
|
|
356
|
+
throw new common_1.ForbiddenError({
|
|
357
|
+
message: `User cannot revoke their own permissions`
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
const repository = entityManager
|
|
361
|
+
.getRepository(data.object.objectClass);
|
|
362
|
+
const { keyProperty, contextProperty, targetProperty, where } = this.getAuthContextFilter(targetUserId, data, contextId);
|
|
363
|
+
const newAccessKeys = accessKeys.map((accessKey, i) => {
|
|
364
|
+
const isKey = authContext
|
|
365
|
+
.keys
|
|
366
|
+
?.find((key) => {
|
|
367
|
+
return key.name === accessKey;
|
|
368
|
+
});
|
|
369
|
+
if (!isKey
|
|
370
|
+
&& accessKey !== authContext.adminKey.name
|
|
371
|
+
&& accessKey !== authContext.ownerKey.name) {
|
|
372
|
+
throw new common_1.BadRequestError({
|
|
373
|
+
message: `accessKeys[${i}] is not valid`
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
const newAccessKey = {
|
|
377
|
+
[targetProperty.propertyKey]: targetUserId,
|
|
378
|
+
[keyProperty.propertyKey]: accessKey
|
|
379
|
+
};
|
|
380
|
+
if (contextProperty) {
|
|
381
|
+
newAccessKey[contextProperty.propertyKey] = contextId;
|
|
382
|
+
}
|
|
383
|
+
return newAccessKey;
|
|
384
|
+
});
|
|
385
|
+
await repository.delete(where);
|
|
386
|
+
await repository.save(newAccessKeys);
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
getGetUserPermissions(data) {
|
|
390
|
+
return async ({ contextId, userId, targetUserId, entityManager, context }) => {
|
|
391
|
+
const authContext = (0, find_auth_context_1.findAuthContext)(context);
|
|
392
|
+
if (userId !== targetUserId) {
|
|
393
|
+
await this.checkIsAuthorized({
|
|
394
|
+
data,
|
|
395
|
+
context,
|
|
396
|
+
contextId,
|
|
397
|
+
keys: [
|
|
398
|
+
authContext.adminKey.name,
|
|
399
|
+
authContext.ownerKey.name
|
|
400
|
+
],
|
|
401
|
+
userId,
|
|
402
|
+
entityManager
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
const repository = entityManager
|
|
406
|
+
.getRepository(data.object.objectClass);
|
|
407
|
+
const { keyProperty, where } = this.getAuthContextFilter(targetUserId, data, contextId);
|
|
408
|
+
const accessKeys = await repository.findBy(where);
|
|
409
|
+
return accessKeys.map((accessKey) => {
|
|
410
|
+
return accessKey[keyProperty.propertyKey];
|
|
411
|
+
});
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
getAuthContextFilter(targetUserId, data, contextId) {
|
|
415
|
+
const properties = core
|
|
416
|
+
.storage
|
|
417
|
+
.getProperties(data.object.objectClass);
|
|
418
|
+
const contextProperty = properties
|
|
419
|
+
.find((property) => {
|
|
420
|
+
return property.isProtectContext;
|
|
421
|
+
});
|
|
422
|
+
const keyProperty = properties
|
|
423
|
+
.find((property) => {
|
|
424
|
+
return property.isProtectKey;
|
|
425
|
+
});
|
|
426
|
+
const targetProperty = properties
|
|
427
|
+
.find((property) => {
|
|
428
|
+
return property.isProtectTarget;
|
|
429
|
+
});
|
|
430
|
+
const where = {
|
|
431
|
+
[targetProperty.propertyKey]: targetUserId
|
|
432
|
+
};
|
|
433
|
+
if (contextProperty) {
|
|
434
|
+
where[contextProperty.propertyKey] = contextId;
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
where,
|
|
438
|
+
keyProperty,
|
|
439
|
+
contextProperty,
|
|
440
|
+
targetProperty
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
async checkIsAuthorized({ data, userId, entityManager, keys, context, contextId }) {
|
|
444
|
+
const forbiddenError = new common_1.ForbiddenError({
|
|
445
|
+
message: `[${userId}] cannot execute action on [${context || data.object.objectKey}]`,
|
|
446
|
+
requirements: [keys.join(',')]
|
|
447
|
+
});
|
|
448
|
+
const exists = await this
|
|
449
|
+
.createQueryBuilder({
|
|
450
|
+
protectorData: data,
|
|
451
|
+
userId,
|
|
452
|
+
data: data.context
|
|
453
|
+
? { [data.context.propertyKey]: contextId }
|
|
454
|
+
: {},
|
|
455
|
+
authKeys: keys,
|
|
456
|
+
displayContext: context,
|
|
457
|
+
entityManager
|
|
458
|
+
})
|
|
459
|
+
.getOne();
|
|
460
|
+
if (!exists) {
|
|
461
|
+
throw forbiddenError;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
getProtectedData(protector, object) {
|
|
465
|
+
let context;
|
|
466
|
+
let options = object.protected;
|
|
467
|
+
let isContext = false;
|
|
468
|
+
if (protector.context) {
|
|
469
|
+
isContext = object.objectClass === protector.context.getRelationType();
|
|
470
|
+
context = isContext
|
|
471
|
+
? (0, __1.getIdProperty)(object.objectClass)
|
|
472
|
+
: core
|
|
473
|
+
.storage
|
|
474
|
+
.getProperties(object.objectClass)
|
|
475
|
+
.find((property) => {
|
|
476
|
+
return property.isRelation
|
|
477
|
+
&& property.getRelationType() === protector.context.getRelationType();
|
|
478
|
+
});
|
|
479
|
+
if (!context) {
|
|
480
|
+
throw new Error(`[${protector.object.objectClass.name}] Context property not found on protected entity [${object.objectClass.name}]`);
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
return {
|
|
484
|
+
object,
|
|
485
|
+
options,
|
|
486
|
+
context: context,
|
|
487
|
+
isContext
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
getProtectorData(protector) {
|
|
491
|
+
const object = core
|
|
492
|
+
.storage
|
|
493
|
+
.findObject(protector);
|
|
494
|
+
const target = core
|
|
495
|
+
.storage
|
|
496
|
+
.getProperties(protector)
|
|
497
|
+
.find((property) => {
|
|
498
|
+
return property.isProtectTarget;
|
|
499
|
+
});
|
|
500
|
+
const context = core
|
|
501
|
+
.storage
|
|
502
|
+
.getProperties(protector)
|
|
503
|
+
.find((property) => {
|
|
504
|
+
return property.isProtectContext;
|
|
505
|
+
});
|
|
506
|
+
const key = core
|
|
507
|
+
.storage
|
|
508
|
+
.getProperties(protector)
|
|
509
|
+
.find((property) => {
|
|
510
|
+
return property.isProtectKey;
|
|
511
|
+
});
|
|
512
|
+
return {
|
|
513
|
+
object,
|
|
514
|
+
target: target,
|
|
515
|
+
context: context,
|
|
516
|
+
key: key
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
exports.ProtectBuilder = ProtectBuilder;
|
|
521
|
+
exports.ProtectBuilder = ProtectBuilder = __decorate([
|
|
522
|
+
(0, class_injector_1.Injectable)()
|
|
523
|
+
], ProtectBuilder);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Repository } from "../interfaces";
|
|
2
|
+
import { QueryDeepPartialEntity } from "typeorm/query-builder/QueryPartialEntity";
|
|
3
|
+
import { FindManyOptions, FindOneOptions, FindOptionsWhere } from 'typeorm';
|
|
4
|
+
export declare abstract class RepositoryService<T> {
|
|
5
|
+
protected abstract repository: Repository<T>;
|
|
6
|
+
getOne(options: FindOneOptions<T>): Promise<T>;
|
|
7
|
+
getMany(options?: FindManyOptions<T>): Promise<T[]>;
|
|
8
|
+
getOneBy(where: FindOptionsWhere<T> | FindOptionsWhere<T>[]): Promise<T>;
|
|
9
|
+
saveMany(values: QueryDeepPartialEntity<T>[]): Promise<import("typeorm").InsertResult>;
|
|
10
|
+
save(value: T): Promise<T>;
|
|
11
|
+
updateBy(criteria: FindOptionsWhere<T>, update: QueryDeepPartialEntity<T>): Promise<import("typeorm").UpdateResult>;
|
|
12
|
+
removeBy(where: FindOptionsWhere<T>): Promise<import("typeorm").DeleteResult>;
|
|
13
|
+
upsert(data: QueryDeepPartialEntity<T>, columns: (keyof T)[]): Promise<T>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RepositoryService = void 0;
|
|
7
|
+
const generate_id_1 = __importDefault(require("../functions/generate-id"));
|
|
8
|
+
const get_id_property_1 = require("../functions/get-id-property");
|
|
9
|
+
class RepositoryService {
|
|
10
|
+
async getOne(options) {
|
|
11
|
+
return this
|
|
12
|
+
.repository
|
|
13
|
+
.findOne(options);
|
|
14
|
+
}
|
|
15
|
+
async getMany(options) {
|
|
16
|
+
return this
|
|
17
|
+
.repository
|
|
18
|
+
.find(options);
|
|
19
|
+
}
|
|
20
|
+
async getOneBy(where) {
|
|
21
|
+
return this
|
|
22
|
+
.repository
|
|
23
|
+
.findOneBy(where);
|
|
24
|
+
}
|
|
25
|
+
async saveMany(values) {
|
|
26
|
+
return this
|
|
27
|
+
.repository
|
|
28
|
+
.insert(values.map((value) => {
|
|
29
|
+
(0, generate_id_1.default)(this.repository.target, value);
|
|
30
|
+
return value;
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
async save(value) {
|
|
34
|
+
const idProperty = (0, get_id_property_1.getIdProperty)(this.repository.target);
|
|
35
|
+
if (!value[idProperty.propertyKey]) {
|
|
36
|
+
(0, generate_id_1.default)(this.repository.target, value);
|
|
37
|
+
}
|
|
38
|
+
return this
|
|
39
|
+
.repository
|
|
40
|
+
.save(value);
|
|
41
|
+
}
|
|
42
|
+
async updateBy(criteria, update) {
|
|
43
|
+
return this
|
|
44
|
+
.repository
|
|
45
|
+
.update(criteria, update);
|
|
46
|
+
}
|
|
47
|
+
async removeBy(where) {
|
|
48
|
+
return this
|
|
49
|
+
.repository
|
|
50
|
+
.delete(where);
|
|
51
|
+
}
|
|
52
|
+
async upsert(data, columns) {
|
|
53
|
+
await this
|
|
54
|
+
.repository
|
|
55
|
+
.upsert(data, columns);
|
|
56
|
+
const alias = this
|
|
57
|
+
.repository
|
|
58
|
+
.target
|
|
59
|
+
.constructor
|
|
60
|
+
.name;
|
|
61
|
+
let conditions = '';
|
|
62
|
+
for (const column of columns) {
|
|
63
|
+
const value = typeof data[column] === 'number'
|
|
64
|
+
? data[column]
|
|
65
|
+
: `'${data[column]}'`;
|
|
66
|
+
conditions += `${!isNullOrEmpty(conditions) ? ' AND ' : ''}"${alias}"."${column}" = ${value}`;
|
|
67
|
+
}
|
|
68
|
+
return this
|
|
69
|
+
.repository
|
|
70
|
+
.createQueryBuilder(alias)
|
|
71
|
+
.where(conditions)
|
|
72
|
+
.getOne();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.RepositoryService = RepositoryService;
|
|
@@ -0,0 +1,61 @@
|
|
|
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.Form = void 0;
|
|
13
|
+
const class_pipe_1 = require("@rockster/class-pipe");
|
|
14
|
+
const database_1 = require("../../database");
|
|
15
|
+
let Form = class Form {
|
|
16
|
+
};
|
|
17
|
+
exports.Form = Form;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, class_pipe_1.Expose)(),
|
|
20
|
+
(0, class_pipe_1.IsString)(),
|
|
21
|
+
(0, class_pipe_1.IsOptional)(),
|
|
22
|
+
(0, database_1.IdGenerated)('nanoid'),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], Form.prototype, "id", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
(0, class_pipe_1.Expose)(),
|
|
27
|
+
(0, class_pipe_1.IsString)(),
|
|
28
|
+
(0, database_1.Column)(),
|
|
29
|
+
(0, class_pipe_1.IsRequired)(),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], Form.prototype, "name", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, class_pipe_1.Expose)({ ignoreType: true }),
|
|
34
|
+
(0, class_pipe_1.IsOptional)(),
|
|
35
|
+
(0, class_pipe_1.IsArray)(),
|
|
36
|
+
(0, database_1.Column)({
|
|
37
|
+
type: 'jsonb',
|
|
38
|
+
default: '[]'
|
|
39
|
+
}),
|
|
40
|
+
__metadata("design:type", Array)
|
|
41
|
+
], Form.prototype, "items", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, class_pipe_1.Expose)({ ignoreType: true }),
|
|
44
|
+
(0, class_pipe_1.IsOptional)(),
|
|
45
|
+
(0, class_pipe_1.IsObject)(),
|
|
46
|
+
(0, database_1.Column)({
|
|
47
|
+
type: 'jsonb',
|
|
48
|
+
default: '{}'
|
|
49
|
+
}),
|
|
50
|
+
__metadata("design:type", Object)
|
|
51
|
+
], Form.prototype, "config", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, class_pipe_1.Expose)(),
|
|
54
|
+
(0, class_pipe_1.IsOptional)(),
|
|
55
|
+
(0, class_pipe_1.IsString)(),
|
|
56
|
+
(0, database_1.Column)({ nullable: true }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], Form.prototype, "contextId", void 0);
|
|
59
|
+
exports.Form = Form = __decorate([
|
|
60
|
+
(0, database_1.Entity)()
|
|
61
|
+
], Form);
|