@webda/core 3.16.4 → 4.0.0-beta.2
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/lib/application.d.ts +29 -8
- package/lib/application.d.ts.map +1 -0
- package/lib/application.js +65 -38
- package/lib/application.js.map +1 -1
- package/lib/application.spec.d.ts +1 -0
- package/lib/application.spec.d.ts.map +1 -0
- package/lib/application.spec.js +57 -43
- package/lib/application.spec.js.map +1 -1
- package/lib/core.d.ts +16 -12
- package/lib/core.d.ts.map +1 -0
- package/lib/core.js +105 -80
- package/lib/core.js.map +1 -1
- package/lib/core.spec.d.ts +1 -0
- package/lib/core.spec.d.ts.map +1 -0
- package/lib/core.spec.js +96 -67
- package/lib/core.spec.js.map +1 -1
- package/lib/errors.d.ts +59 -60
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +92 -108
- package/lib/errors.js.map +1 -1
- package/lib/errors.spec.d.ts +1 -0
- package/lib/errors.spec.d.ts.map +1 -0
- package/lib/errors.spec.js +1 -1
- package/lib/errors.spec.js.map +1 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -3
- package/lib/index.js.map +1 -1
- package/lib/models/aclmodel.d.ts +2 -2
- package/lib/models/aclmodel.d.ts.map +1 -0
- package/lib/models/aclmodel.js +8 -9
- package/lib/models/aclmodel.js.map +1 -1
- package/lib/models/aclmodel.spec.d.ts +1 -0
- package/lib/models/aclmodel.spec.d.ts.map +1 -0
- package/lib/models/aclmodel.spec.js +3 -3
- package/lib/models/aclmodel.spec.js.map +1 -1
- package/lib/models/coremodel.d.ts +15 -0
- package/lib/models/coremodel.d.ts.map +1 -0
- package/lib/models/coremodel.js +35 -28
- package/lib/models/coremodel.js.map +1 -1
- package/lib/models/coremodel.spec.d.ts +1 -0
- package/lib/models/coremodel.spec.d.ts.map +1 -0
- package/lib/models/coremodel.spec.js +33 -31
- package/lib/models/coremodel.spec.js.map +1 -1
- package/lib/models/deployment.d.ts +1 -0
- package/lib/models/deployment.d.ts.map +1 -0
- package/lib/models/ident.d.ts +17 -2
- package/lib/models/ident.d.ts.map +1 -0
- package/lib/models/ident.js +0 -14
- package/lib/models/ident.js.map +1 -1
- package/lib/models/ident.spec.d.ts +1 -0
- package/lib/models/ident.spec.d.ts.map +1 -0
- package/lib/models/ident.spec.js +1 -20
- package/lib/models/ident.spec.js.map +1 -1
- package/lib/models/ownermodel.d.ts +1 -0
- package/lib/models/ownermodel.d.ts.map +1 -0
- package/lib/models/ownermodel.spec.d.ts +1 -0
- package/lib/models/ownermodel.spec.d.ts.map +1 -0
- package/lib/models/ownermodel.spec.js +57 -33
- package/lib/models/ownermodel.spec.js.map +1 -1
- package/lib/models/relations.d.ts +1 -0
- package/lib/models/relations.d.ts.map +1 -0
- package/lib/models/relations.js +3 -3
- package/lib/models/relations.js.map +1 -1
- package/lib/models/relations.spec.d.ts +2 -0
- package/lib/models/relations.spec.d.ts.map +1 -0
- package/lib/models/relations.spec.js +10 -17
- package/lib/models/relations.spec.js.map +1 -1
- package/lib/models/rolemodel.d.ts +1 -0
- package/lib/models/rolemodel.d.ts.map +1 -0
- package/lib/models/rolemodel.js +2 -2
- package/lib/models/rolemodel.js.map +1 -1
- package/lib/models/rolemodel.spec.d.ts +1 -0
- package/lib/models/rolemodel.spec.d.ts.map +1 -0
- package/lib/models/rolemodel.spec.js +5 -1
- package/lib/models/rolemodel.spec.js.map +1 -1
- package/lib/models/simpleuser.d.ts +47 -0
- package/lib/models/simpleuser.d.ts.map +1 -0
- package/lib/models/simpleuser.js +84 -0
- package/lib/models/simpleuser.js.map +1 -0
- package/lib/models/test.d.ts +11 -0
- package/lib/models/test.d.ts.map +1 -0
- package/lib/models/test.js +7 -0
- package/lib/models/test.js.map +1 -0
- package/lib/models/user.d.ts +2 -35
- package/lib/models/user.d.ts.map +1 -0
- package/lib/models/user.js +3 -74
- package/lib/models/user.js.map +1 -1
- package/lib/models/user.spec.d.ts +1 -0
- package/lib/models/user.spec.d.ts.map +1 -0
- package/lib/models/user.spec.js +7 -6
- package/lib/models/user.spec.js.map +1 -1
- package/lib/queues/filequeue.d.ts +1 -0
- package/lib/queues/filequeue.d.ts.map +1 -0
- package/lib/queues/filequeue.js +5 -5
- package/lib/queues/filequeue.js.map +1 -1
- package/lib/queues/filequeue.spec.d.ts +1 -0
- package/lib/queues/filequeue.spec.d.ts.map +1 -0
- package/lib/queues/filequeue.spec.js +11 -5
- package/lib/queues/filequeue.spec.js.map +1 -1
- package/lib/queues/memoryqueue.d.ts +14 -0
- package/lib/queues/memoryqueue.d.ts.map +1 -0
- package/lib/queues/memoryqueue.js +38 -7
- package/lib/queues/memoryqueue.js.map +1 -1
- package/lib/queues/memoryqueue.spec.d.ts +1 -0
- package/lib/queues/memoryqueue.spec.d.ts.map +1 -0
- package/lib/queues/memoryqueue.spec.js +18 -7
- package/lib/queues/memoryqueue.spec.js.map +1 -1
- package/lib/queues/pubsubservice.d.ts +1 -0
- package/lib/queues/pubsubservice.d.ts.map +1 -0
- package/lib/queues/queue.spec.d.ts +3 -2
- package/lib/queues/queue.spec.d.ts.map +1 -0
- package/lib/queues/queue.spec.js +5 -3
- package/lib/queues/queue.spec.js.map +1 -1
- package/lib/queues/queueservice.d.ts +1 -0
- package/lib/queues/queueservice.d.ts.map +1 -0
- package/lib/queues/queueservice.js +7 -7
- package/lib/queues/queueservice.js.map +1 -1
- package/lib/rest/restdomainservice.d.ts +63 -0
- package/lib/rest/restdomainservice.d.ts.map +1 -0
- package/lib/rest/restdomainservice.js +687 -0
- package/lib/rest/restdomainservice.js.map +1 -0
- package/lib/rest/restdomainservice.spec.d.ts +2 -0
- package/lib/rest/restdomainservice.spec.d.ts.map +1 -0
- package/lib/rest/restdomainservice.spec.js +124 -0
- package/lib/rest/restdomainservice.spec.js.map +1 -0
- package/lib/{router.d.ts → rest/router.d.ts} +6 -4
- package/lib/rest/router.d.ts.map +1 -0
- package/lib/{router.js → rest/router.js} +33 -23
- package/lib/rest/router.js.map +1 -0
- package/lib/rest/router.spec.d.ts +2 -0
- package/lib/rest/router.spec.d.ts.map +1 -0
- package/lib/{router.spec.js → rest/router.spec.js} +54 -28
- package/lib/rest/router.spec.js.map +1 -0
- package/lib/services/asyncevents.d.ts +1 -0
- package/lib/services/asyncevents.d.ts.map +1 -0
- package/lib/services/asyncevents.js +4 -4
- package/lib/services/asyncevents.js.map +1 -1
- package/lib/services/asyncevents.spec.d.ts +1 -0
- package/lib/services/asyncevents.spec.d.ts.map +1 -0
- package/lib/services/asyncevents.spec.js +10 -10
- package/lib/services/asyncevents.spec.js.map +1 -1
- package/lib/services/authentication.d.ts +2 -1
- package/lib/services/authentication.d.ts.map +1 -0
- package/lib/services/authentication.js +26 -25
- package/lib/services/authentication.js.map +1 -1
- package/lib/services/authentication.spec.d.ts +1 -0
- package/lib/services/authentication.spec.d.ts.map +1 -0
- package/lib/services/authentication.spec.js +24 -24
- package/lib/services/authentication.spec.js.map +1 -1
- package/lib/services/binary.d.ts +13 -87
- package/lib/services/binary.d.ts.map +1 -0
- package/lib/services/binary.js +39 -421
- package/lib/services/binary.js.map +1 -1
- package/lib/services/binary.spec.d.ts +19 -22
- package/lib/services/binary.spec.d.ts.map +1 -0
- package/lib/services/binary.spec.js +87 -374
- package/lib/services/binary.spec.js.map +1 -1
- package/lib/services/cloudbinary.d.ts +3 -2
- package/lib/services/cloudbinary.d.ts.map +1 -0
- package/lib/services/cloudbinary.js +1 -1
- package/lib/services/cloudbinary.js.map +1 -1
- package/lib/services/cloudbinary.spec.d.ts +1 -8
- package/lib/services/cloudbinary.spec.d.ts.map +1 -0
- package/lib/services/cloudbinary.spec.js +4 -130
- package/lib/services/cloudbinary.spec.js.map +1 -1
- package/lib/services/configuration.d.ts +10 -1
- package/lib/services/configuration.d.ts.map +1 -0
- package/lib/services/configuration.js +22 -7
- package/lib/services/configuration.js.map +1 -1
- package/lib/services/configuration.spec.d.ts +1 -0
- package/lib/services/configuration.spec.d.ts.map +1 -0
- package/lib/services/configuration.spec.js +60 -17
- package/lib/services/configuration.spec.js.map +1 -1
- package/lib/services/cron.d.ts +2 -1
- package/lib/services/cron.d.ts.map +1 -0
- package/lib/services/cron.js +10 -10
- package/lib/services/cron.js.map +1 -1
- package/lib/services/cron.spec.d.ts +1 -0
- package/lib/services/cron.spec.d.ts.map +1 -0
- package/lib/services/cron.spec.js +2 -2
- package/lib/services/cron.spec.js.map +1 -1
- package/lib/services/cryptoservice.d.ts +3 -2
- package/lib/services/cryptoservice.d.ts.map +1 -0
- package/lib/services/cryptoservice.js +29 -30
- package/lib/services/cryptoservice.js.map +1 -1
- package/lib/services/cryptoservice.spec.d.ts +1 -0
- package/lib/services/cryptoservice.spec.d.ts.map +1 -0
- package/lib/services/cryptoservice.spec.js +17 -17
- package/lib/services/cryptoservice.spec.js.map +1 -1
- package/lib/services/debugmailer.d.ts +2 -2
- package/lib/services/debugmailer.d.ts.map +1 -0
- package/lib/services/debugmailer.js +1 -2
- package/lib/services/debugmailer.js.map +1 -1
- package/lib/services/debugmailer.spec.d.ts +1 -0
- package/lib/services/debugmailer.spec.d.ts.map +1 -0
- package/lib/services/debugmailer.spec.js +6 -3
- package/lib/services/debugmailer.spec.js.map +1 -1
- package/lib/services/domainservice.d.ts +167 -47
- package/lib/services/domainservice.d.ts.map +1 -0
- package/lib/services/domainservice.js +520 -753
- package/lib/services/domainservice.js.map +1 -1
- package/lib/services/domainservice.spec.d.ts +1 -0
- package/lib/services/domainservice.spec.d.ts.map +1 -0
- package/lib/services/domainservice.spec.js +201 -31
- package/lib/services/domainservice.spec.js.map +1 -1
- package/lib/services/filebinary.d.ts +8 -5
- package/lib/services/filebinary.d.ts.map +1 -0
- package/lib/services/filebinary.js +34 -32
- package/lib/services/filebinary.js.map +1 -1
- package/lib/services/filebinary.spec.d.ts +12 -8
- package/lib/services/filebinary.spec.d.ts.map +1 -0
- package/lib/services/filebinary.spec.js +135 -122
- package/lib/services/filebinary.spec.js.map +1 -1
- package/lib/services/fileconfiguration.d.ts +2 -1
- package/lib/services/fileconfiguration.d.ts.map +1 -0
- package/lib/services/fileconfiguration.js +1 -1
- package/lib/services/fileconfiguration.js.map +1 -1
- package/lib/services/fileconfiguration.spec.d.ts +1 -0
- package/lib/services/fileconfiguration.spec.d.ts.map +1 -0
- package/lib/services/fileconfiguration.spec.js +65 -27
- package/lib/services/fileconfiguration.spec.js.map +1 -1
- package/lib/services/invitationservice.d.ts +2 -1
- package/lib/services/invitationservice.d.ts.map +1 -0
- package/lib/services/invitationservice.js +19 -16
- package/lib/services/invitationservice.js.map +1 -1
- package/lib/services/invitationservice.spec.d.ts +1 -0
- package/lib/services/invitationservice.spec.d.ts.map +1 -0
- package/lib/services/invitationservice.spec.js +73 -22
- package/lib/services/invitationservice.spec.js.map +1 -1
- package/lib/services/kubernetesconfiguration.d.ts +1 -0
- package/lib/services/kubernetesconfiguration.d.ts.map +1 -0
- package/lib/services/kubernetesconfiguration.js +0 -2
- package/lib/services/kubernetesconfiguration.js.map +1 -1
- package/lib/services/kubernetesconfiguration.spec.d.ts +1 -0
- package/lib/services/kubernetesconfiguration.spec.d.ts.map +1 -0
- package/lib/services/kubernetesconfiguration.spec.js +67 -8
- package/lib/services/kubernetesconfiguration.spec.js.map +1 -1
- package/lib/services/mailer.d.ts +1 -0
- package/lib/services/mailer.d.ts.map +1 -0
- package/lib/services/mailer.js +3 -3
- package/lib/services/mailer.js.map +1 -1
- package/lib/services/mailer.spec.d.ts +1 -0
- package/lib/services/mailer.spec.d.ts.map +1 -0
- package/lib/services/mailer.spec.js +18 -4
- package/lib/services/mailer.spec.js.map +1 -1
- package/lib/services/notificationservice.d.ts +1 -0
- package/lib/services/notificationservice.d.ts.map +1 -0
- package/lib/services/notificationservice.js +1 -1
- package/lib/services/notificationservice.js.map +1 -1
- package/lib/services/notificationservice.spec.d.ts +1 -0
- package/lib/services/notificationservice.spec.d.ts.map +1 -0
- package/lib/services/notificationservice.spec.js +8 -3
- package/lib/services/notificationservice.spec.js.map +1 -1
- package/lib/services/oauth.d.ts +6 -3
- package/lib/services/oauth.d.ts.map +1 -0
- package/lib/services/oauth.js +11 -8
- package/lib/services/oauth.js.map +1 -1
- package/lib/services/oauth.spec.d.ts +1 -0
- package/lib/services/oauth.spec.d.ts.map +1 -0
- package/lib/services/oauth.spec.js +39 -15
- package/lib/services/oauth.spec.js.map +1 -1
- package/lib/services/prometheus.d.ts +1 -0
- package/lib/services/prometheus.d.ts.map +1 -0
- package/lib/services/prometheus.spec.d.ts +1 -0
- package/lib/services/prometheus.spec.d.ts.map +1 -0
- package/lib/services/prometheus.spec.js +38 -19
- package/lib/services/prometheus.spec.js.map +1 -1
- package/lib/services/resource.d.ts +21 -1
- package/lib/services/resource.d.ts.map +1 -0
- package/lib/services/resource.js +20 -3
- package/lib/services/resource.js.map +1 -1
- package/lib/services/resource.spec.d.ts +1 -0
- package/lib/services/resource.spec.d.ts.map +1 -0
- package/lib/services/resource.spec.js +38 -20
- package/lib/services/resource.spec.js.map +1 -1
- package/lib/services/service.d.ts +2 -2
- package/lib/services/service.d.ts.map +1 -0
- package/lib/services/service.js +13 -23
- package/lib/services/service.js.map +1 -1
- package/lib/services/service.spec.d.ts +1 -0
- package/lib/services/service.spec.d.ts.map +1 -0
- package/lib/services/service.spec.js +58 -40
- package/lib/services/service.spec.js.map +1 -1
- package/lib/stores/aggregator.d.ts +10 -3
- package/lib/stores/aggregator.d.ts.map +1 -0
- package/lib/stores/aggregator.js +6 -6
- package/lib/stores/aggregator.js.map +1 -1
- package/lib/stores/file.d.ts +3 -2
- package/lib/stores/file.d.ts.map +1 -0
- package/lib/stores/file.js +13 -13
- package/lib/stores/file.js.map +1 -1
- package/lib/stores/file.spec.d.ts +5 -11
- package/lib/stores/file.spec.d.ts.map +1 -0
- package/lib/stores/file.spec.js +20 -114
- package/lib/stores/file.spec.js.map +1 -1
- package/lib/stores/mapper.d.ts +2 -1
- package/lib/stores/mapper.d.ts.map +1 -0
- package/lib/stores/mapper.js +12 -12
- package/lib/stores/mapper.js.map +1 -1
- package/lib/stores/mapper.spec.d.ts +1 -0
- package/lib/stores/mapper.spec.d.ts.map +1 -0
- package/lib/stores/mapper.spec.js +24 -17
- package/lib/stores/mapper.spec.js.map +1 -1
- package/lib/stores/memory.d.ts +2 -1
- package/lib/stores/memory.d.ts.map +1 -0
- package/lib/stores/memory.js +15 -15
- package/lib/stores/memory.js.map +1 -1
- package/lib/stores/memory.spec.d.ts +7 -13
- package/lib/stores/memory.spec.d.ts.map +1 -0
- package/lib/stores/memory.spec.js +118 -183
- package/lib/stores/memory.spec.js.map +1 -1
- package/lib/stores/modelmapper.d.ts +1 -0
- package/lib/stores/modelmapper.d.ts.map +1 -0
- package/lib/stores/modelmapper.js +8 -10
- package/lib/stores/modelmapper.js.map +1 -1
- package/lib/stores/store.d.ts +4 -145
- package/lib/stores/store.d.ts.map +1 -0
- package/lib/stores/store.js +54 -654
- package/lib/stores/store.js.map +1 -1
- package/lib/stores/store.spec.d.ts +11 -19
- package/lib/stores/store.spec.d.ts.map +1 -0
- package/lib/stores/store.spec.js +99 -268
- package/lib/stores/store.spec.js.map +1 -1
- package/lib/test.d.ts +109 -6
- package/lib/test.d.ts.map +1 -0
- package/lib/test.js +245 -22
- package/lib/test.js.map +1 -1
- package/lib/unpackedapplication.d.ts +3 -2
- package/lib/unpackedapplication.d.ts.map +1 -0
- package/lib/unpackedapplication.js +29 -16
- package/lib/unpackedapplication.js.map +1 -1
- package/lib/utils/abstractdeployer.d.ts +1 -0
- package/lib/utils/abstractdeployer.d.ts.map +1 -0
- package/lib/utils/abstractdeployer.spec.d.ts +1 -0
- package/lib/utils/abstractdeployer.spec.d.ts.map +1 -0
- package/lib/utils/case.d.ts +1 -0
- package/lib/utils/case.d.ts.map +1 -0
- package/lib/utils/case.spec.d.ts +1 -0
- package/lib/utils/case.spec.d.ts.map +1 -0
- package/lib/utils/context.d.ts +37 -17
- package/lib/utils/context.d.ts.map +1 -0
- package/lib/utils/context.js +53 -42
- package/lib/utils/context.js.map +1 -1
- package/lib/utils/context.spec.d.ts +1 -0
- package/lib/utils/context.spec.d.ts.map +1 -0
- package/lib/utils/context.spec.js +21 -14
- package/lib/utils/context.spec.js.map +1 -1
- package/lib/utils/cookie.d.ts +1 -0
- package/lib/utils/cookie.d.ts.map +1 -0
- package/lib/utils/cookie.js +2 -2
- package/lib/utils/cookie.js.map +1 -1
- package/lib/utils/cookie.spec.d.ts +1 -0
- package/lib/utils/cookie.spec.d.ts.map +1 -0
- package/lib/utils/cookie.spec.js +20 -10
- package/lib/utils/cookie.spec.js.map +1 -1
- package/lib/utils/esm.d.ts +1 -0
- package/lib/utils/esm.d.ts.map +1 -0
- package/lib/utils/httpcontext.d.ts +1 -0
- package/lib/utils/httpcontext.d.ts.map +1 -0
- package/lib/utils/httpcontext.js +7 -7
- package/lib/utils/httpcontext.js.map +1 -1
- package/lib/utils/httpcontext.spec.d.ts +1 -0
- package/lib/utils/httpcontext.spec.d.ts.map +1 -0
- package/lib/utils/httpcontext.spec.js +7 -7
- package/lib/utils/httpcontext.spec.js.map +1 -1
- package/lib/utils/logger.d.ts +1 -0
- package/lib/utils/logger.d.ts.map +1 -0
- package/lib/utils/logger.spec.d.ts +1 -0
- package/lib/utils/logger.spec.d.ts.map +1 -0
- package/lib/utils/logger.spec.js +5 -5
- package/lib/utils/logger.spec.js.map +1 -1
- package/lib/utils/serializers.d.ts +6 -4
- package/lib/utils/serializers.d.ts.map +1 -0
- package/lib/utils/serializers.js +30 -27
- package/lib/utils/serializers.js.map +1 -1
- package/lib/utils/serializers.spec.d.ts +1 -0
- package/lib/utils/serializers.spec.d.ts.map +1 -0
- package/lib/utils/serializers.spec.js +12 -14
- package/lib/utils/serializers.spec.js.map +1 -1
- package/lib/utils/session.d.ts +2 -5
- package/lib/utils/session.d.ts.map +1 -0
- package/lib/utils/session.js +1 -11
- package/lib/utils/session.js.map +1 -1
- package/lib/utils/session.spec.d.ts +1 -0
- package/lib/utils/session.spec.d.ts.map +1 -0
- package/lib/utils/session.spec.js +22 -12
- package/lib/utils/session.spec.js.map +1 -1
- package/lib/utils/throttler.d.ts +1 -4
- package/lib/utils/throttler.d.ts.map +1 -0
- package/lib/utils/throttler.js +1 -9
- package/lib/utils/throttler.js.map +1 -1
- package/lib/utils/throttler.spec.d.ts +1 -0
- package/lib/utils/throttler.spec.d.ts.map +1 -0
- package/lib/utils/throttler.spec.js +4 -6
- package/lib/utils/throttler.spec.js.map +1 -1
- package/lib/utils/waiter.d.ts +1 -0
- package/lib/utils/waiter.d.ts.map +1 -0
- package/lib/utils/waiter.js +3 -3
- package/lib/utils/waiter.js.map +1 -1
- package/lib/utils/waiter.spec.d.ts +1 -0
- package/lib/utils/waiter.spec.d.ts.map +1 -0
- package/lib/utils/waiter.spec.js +6 -6
- package/lib/utils/waiter.spec.js.map +1 -1
- package/package.json +20 -16
- package/test/config.json +6 -90
- package/test/data/.env +1 -0
- package/webda.module.json +607 -377
- package/lib/router.js.map +0 -1
- package/lib/router.spec.d.ts +0 -1
- package/lib/router.spec.js.map +0 -1
- package/lib/stores/aliasstore.d.ts +0 -108
- package/lib/stores/aliasstore.js +0 -168
- package/lib/stores/aliasstore.js.map +0 -1
- package/lib/stores/aliasstore.spec.d.ts +0 -11
- package/lib/stores/aliasstore.spec.js +0 -89
- package/lib/stores/aliasstore.spec.js.map +0 -1
- package/lib/stores/webdaql/WebdaQLLexer.d.ts +0 -54
- package/lib/stores/webdaql/WebdaQLLexer.js +0 -295
- package/lib/stores/webdaql/WebdaQLLexer.js.map +0 -1
- package/lib/stores/webdaql/WebdaQLParserLexer.d.ts +0 -54
- package/lib/stores/webdaql/WebdaQLParserLexer.js +0 -295
- package/lib/stores/webdaql/WebdaQLParserLexer.js.map +0 -1
- package/lib/stores/webdaql/WebdaQLParserListener.d.ts +0 -296
- package/lib/stores/webdaql/WebdaQLParserListener.js +0 -3
- package/lib/stores/webdaql/WebdaQLParserListener.js.map +0 -1
- package/lib/stores/webdaql/WebdaQLParserParser.d.ts +0 -311
- package/lib/stores/webdaql/WebdaQLParserParser.js +0 -1807
- package/lib/stores/webdaql/WebdaQLParserParser.js.map +0 -1
- package/lib/stores/webdaql/WebdaQLParserVisitor.d.ts +0 -181
- package/lib/stores/webdaql/WebdaQLParserVisitor.js +0 -3
- package/lib/stores/webdaql/WebdaQLParserVisitor.js.map +0 -1
- package/lib/stores/webdaql/query.d.ts +0 -390
- package/lib/stores/webdaql/query.js +0 -702
- package/lib/stores/webdaql/query.js.map +0 -1
- package/lib/stores/webdaql/query.spec.d.ts +0 -1
- package/lib/stores/webdaql/query.spec.js +0 -206
- package/lib/stores/webdaql/query.spec.js.map +0 -1
- package/test/config-file-missing-file-no-default.json +0 -44
- package/test/config-file-missing-file.json +0 -55
- package/test/config-file-no-reload.json +0 -69
- package/test/config-file-reload.json +0 -68
- package/test/config-invitation.json +0 -63
- package/test/config-kube-reload.json +0 -68
- package/test/config-reload.json +0 -66
- package/test/config.old.json +0 -152
- package/test/moddas/annotatedservice.js +0 -23
- package/test/moddas/debugmailer.js +0 -13
- package/test/moddas/fakeservice.js +0 -4
- package/test/moddas/voidstore.js +0 -66
- package/test/models/ident.js +0 -36
- package/test/models/task.js +0 -42
package/lib/services/binary.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -12,7 +11,6 @@ import * as path from "path";
|
|
|
12
11
|
import { Readable } from "stream";
|
|
13
12
|
import { Core, Counter, WebdaError } from "../index.js";
|
|
14
13
|
import { NotEnumerable } from "../models/coremodel.js";
|
|
15
|
-
import { Store } from "../stores/store.js";
|
|
16
14
|
import { Service, ServiceParameters } from "./service.js";
|
|
17
15
|
/**
|
|
18
16
|
* Emitted if binary does not exist
|
|
@@ -76,7 +74,7 @@ export class BinaryFile {
|
|
|
76
74
|
resolve();
|
|
77
75
|
});
|
|
78
76
|
stream.on("data", chunk => {
|
|
79
|
-
|
|
77
|
+
const buffer = Buffer.from(chunk);
|
|
80
78
|
hash.update(buffer);
|
|
81
79
|
challenge.update(buffer);
|
|
82
80
|
});
|
|
@@ -211,6 +209,7 @@ export class Binary extends BinaryMap {
|
|
|
211
209
|
async delete() {
|
|
212
210
|
await this.__store.delete(this.model, this.attribute);
|
|
213
211
|
this.set({});
|
|
212
|
+
this.empty = true;
|
|
214
213
|
}
|
|
215
214
|
/**
|
|
216
215
|
* Return undefined if no hash
|
|
@@ -267,7 +266,7 @@ export class BinariesImpl extends Array {
|
|
|
267
266
|
assign(model, attribute) {
|
|
268
267
|
this.model = model;
|
|
269
268
|
this.attribute = attribute;
|
|
270
|
-
for (
|
|
269
|
+
for (const binary of model[attribute] || []) {
|
|
271
270
|
this.push(binary);
|
|
272
271
|
}
|
|
273
272
|
this.__service = Core.get().getBinaryStore(model, attribute);
|
|
@@ -330,14 +329,11 @@ __decorate([
|
|
|
330
329
|
export class BinaryParameters extends ServiceParameters {
|
|
331
330
|
constructor(params, _service) {
|
|
332
331
|
super(params);
|
|
333
|
-
if (this.expose) {
|
|
334
|
-
this.expose.restrict = this.expose.restrict || {};
|
|
335
|
-
}
|
|
336
|
-
this.map ?? (this.map = {});
|
|
337
332
|
// Store all models in it by default
|
|
338
333
|
this.models ?? (this.models = {
|
|
339
334
|
"*": ["*"]
|
|
340
335
|
});
|
|
336
|
+
this.maxFileSize ?? (this.maxFileSize = 10 * 1024 * 1024);
|
|
341
337
|
}
|
|
342
338
|
}
|
|
343
339
|
/**
|
|
@@ -386,65 +382,6 @@ export class BinaryService extends Service {
|
|
|
386
382
|
help: "Number of binary metadata updated"
|
|
387
383
|
});
|
|
388
384
|
}
|
|
389
|
-
/**
|
|
390
|
-
* Redirect to the temporary link to S3 object
|
|
391
|
-
* or return it if returnInfo=true
|
|
392
|
-
*
|
|
393
|
-
* @param ctx of the request
|
|
394
|
-
* @param returnInfo
|
|
395
|
-
*/
|
|
396
|
-
async httpGet(context) {
|
|
397
|
-
const returnInfo = context.getHttpContext().getRelativeUri().endsWith("/url");
|
|
398
|
-
const { uuid, index, property } = context.getParameters();
|
|
399
|
-
let targetStore = this._verifyMapAndStore(context);
|
|
400
|
-
let object = await targetStore.get(uuid);
|
|
401
|
-
if (!object || (Array.isArray(object[property]) && object[property].length <= index)) {
|
|
402
|
-
throw new WebdaError.NotFound("Object does not exist or attachment does not exist");
|
|
403
|
-
}
|
|
404
|
-
await object.checkAct(context, "get_binary");
|
|
405
|
-
const file = Array.isArray(object[property]) ? object[property][index] : object[property];
|
|
406
|
-
await this.emitSync("Binary.Get", {
|
|
407
|
-
object: file,
|
|
408
|
-
service: this,
|
|
409
|
-
context: context
|
|
410
|
-
});
|
|
411
|
-
let url = await this.getRedirectUrlFromObject(file, context);
|
|
412
|
-
// No url, we return the file
|
|
413
|
-
if (url === null) {
|
|
414
|
-
if (returnInfo) {
|
|
415
|
-
// Redirect to same url without /url
|
|
416
|
-
context.write({
|
|
417
|
-
Location: context
|
|
418
|
-
.getHttpContext()
|
|
419
|
-
.getAbsoluteUrl()
|
|
420
|
-
.replace(/\/url$/, ""),
|
|
421
|
-
Map: file
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
else {
|
|
425
|
-
// Output
|
|
426
|
-
context.writeHead(200, {
|
|
427
|
-
"Content-Type": file.mimetype === undefined ? "application/octet-steam" : file.mimetype,
|
|
428
|
-
"Content-Length": file.size
|
|
429
|
-
});
|
|
430
|
-
let readStream = await this.get(file);
|
|
431
|
-
await new Promise((resolve, reject) => {
|
|
432
|
-
// We replaced all the event handlers with a simple call to readStream.pipe()
|
|
433
|
-
context._stream.on("finish", resolve);
|
|
434
|
-
context._stream.on("error", reject);
|
|
435
|
-
readStream.pipe(context._stream);
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
else if (returnInfo) {
|
|
440
|
-
context.write({ Location: url, Map: file });
|
|
441
|
-
}
|
|
442
|
-
else {
|
|
443
|
-
context.writeHead(302, {
|
|
444
|
-
Location: url
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
385
|
/**
|
|
449
386
|
* Get a UrlFromObject
|
|
450
387
|
*
|
|
@@ -462,7 +399,7 @@ export class BinaryService extends Service {
|
|
|
462
399
|
let key = Object.keys(this.parameters.models).find(k => k === modelName);
|
|
463
400
|
if (key) {
|
|
464
401
|
// Explicit model
|
|
465
|
-
|
|
402
|
+
const attributes = this.parameters.models[key];
|
|
466
403
|
if (attributes.includes(attribute)) {
|
|
467
404
|
return 2;
|
|
468
405
|
}
|
|
@@ -475,7 +412,7 @@ export class BinaryService extends Service {
|
|
|
475
412
|
if (!key) {
|
|
476
413
|
return -1;
|
|
477
414
|
}
|
|
478
|
-
|
|
415
|
+
const attributes = this.parameters.models[key];
|
|
479
416
|
if (attributes.includes(attribute)) {
|
|
480
417
|
return 1;
|
|
481
418
|
}
|
|
@@ -510,8 +447,8 @@ export class BinaryService extends Service {
|
|
|
510
447
|
service: this
|
|
511
448
|
});
|
|
512
449
|
this.metrics.download.inc();
|
|
513
|
-
|
|
514
|
-
|
|
450
|
+
const readStream = await this._get(info);
|
|
451
|
+
const writeStream = fs.createWriteStream(filename);
|
|
515
452
|
return new Promise((resolve, reject) => {
|
|
516
453
|
writeStream.on("finish", _src => {
|
|
517
454
|
return resolve();
|
|
@@ -530,45 +467,6 @@ export class BinaryService extends Service {
|
|
|
530
467
|
readStream.pipe(writeStream);
|
|
531
468
|
});
|
|
532
469
|
}
|
|
533
|
-
/**
|
|
534
|
-
* @override
|
|
535
|
-
*/
|
|
536
|
-
resolve() {
|
|
537
|
-
super.resolve();
|
|
538
|
-
this.initMap(this.parameters.map);
|
|
539
|
-
return this;
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* Init the declared maps, adding reverse maps
|
|
543
|
-
*
|
|
544
|
-
* @param map
|
|
545
|
-
*/
|
|
546
|
-
initMap(map) {
|
|
547
|
-
if (map == undefined || map._init) {
|
|
548
|
-
return;
|
|
549
|
-
}
|
|
550
|
-
this._lowercaseMaps = {};
|
|
551
|
-
Object.keys(map).forEach(prop => {
|
|
552
|
-
this._lowercaseMaps[prop.toLowerCase()] = prop;
|
|
553
|
-
let reverseStore = this._webda.getService(prop);
|
|
554
|
-
if (reverseStore === undefined || !(reverseStore instanceof Store)) {
|
|
555
|
-
this._webda.log("WARN", "Can't setup mapping as store ", prop, " doesn't exist");
|
|
556
|
-
map[prop]["-onerror"] = "NoStore";
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
for (let i in map[prop]) {
|
|
560
|
-
reverseStore.addReverseMap(map[prop][i], this);
|
|
561
|
-
}
|
|
562
|
-
// Cascade delete
|
|
563
|
-
reverseStore.on("Store.Deleted", async (evt) => {
|
|
564
|
-
let infos = [];
|
|
565
|
-
if (evt.object[map[prop]]) {
|
|
566
|
-
infos.push(...evt.object[map[prop]]);
|
|
567
|
-
}
|
|
568
|
-
await Promise.all(infos.map(info => this.cascadeDelete(info, evt.object.getUuid())));
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
470
|
/**
|
|
573
471
|
* Based on the raw Map init a BinaryMap
|
|
574
472
|
* @param obj
|
|
@@ -602,40 +500,13 @@ export class BinaryService extends Service {
|
|
|
602
500
|
if (this.handleBinary(object.__type, property) !== -1) {
|
|
603
501
|
return;
|
|
604
502
|
}
|
|
605
|
-
// DELETE_IN_4.0.0
|
|
606
|
-
const name = object.getStore().getName();
|
|
607
|
-
let map = this.parameters.map[this._lowercaseMaps[name.toLowerCase()]];
|
|
608
|
-
if (map === undefined) {
|
|
609
|
-
throw new Error("Unknown mapping");
|
|
610
|
-
}
|
|
611
|
-
if (Array.isArray(map) && map.indexOf(property) === -1) {
|
|
612
|
-
throw new Error("Unknown mapping");
|
|
613
|
-
}
|
|
614
|
-
/*
|
|
615
|
-
// END_DELETE_IN_4.0.0
|
|
616
503
|
throw new Error("Unknown mapping");
|
|
617
|
-
// DELETE_IN_4.0.0
|
|
618
|
-
*/
|
|
619
|
-
// END_DELETE_IN_4.0.0
|
|
620
504
|
}
|
|
621
505
|
/**
|
|
622
506
|
* Ensure events are sent correctly after an upload and update the BinaryFileInfo in targetted object
|
|
623
507
|
*/
|
|
624
|
-
async uploadSuccess(object, property,
|
|
625
|
-
|
|
626
|
-
// Ensure we do not have a full object
|
|
627
|
-
if (fileInfo["toBinaryFileInfo"] && typeof fileInfo["toBinaryFileInfo"] === "function") {
|
|
628
|
-
file = fileInfo["toBinaryFileInfo"]();
|
|
629
|
-
}
|
|
630
|
-
else {
|
|
631
|
-
file = fileInfo;
|
|
632
|
-
}
|
|
633
|
-
let additionalAttrs = Object.keys(file).filter(k => !["name", "size", "mimetype", "hash", "challenge", "metadata"].includes(k));
|
|
634
|
-
if (additionalAttrs.length > 0) {
|
|
635
|
-
throw new Error("Invalid file object it should be a plain BinaryFileInfo found additional properties: " +
|
|
636
|
-
additionalAttrs.join(","));
|
|
637
|
-
}
|
|
638
|
-
let object_uid = object.getUuid();
|
|
508
|
+
async uploadSuccess(object, property, file) {
|
|
509
|
+
const object_uid = object.getUuid();
|
|
639
510
|
// Check if the file is already in the array then skip
|
|
640
511
|
if (Array.isArray(object[property]) && object[property].find(i => i.hash === file.hash)) {
|
|
641
512
|
return;
|
|
@@ -648,7 +519,9 @@ export class BinaryService extends Service {
|
|
|
648
519
|
const relations = this.getWebda().getApplication().getRelations(object);
|
|
649
520
|
const cardinality = (relations.binaries || []).find(p => p.attribute === property)?.cardinality || "MANY";
|
|
650
521
|
if (cardinality === "MANY") {
|
|
651
|
-
await object
|
|
522
|
+
await object
|
|
523
|
+
.getStore()
|
|
524
|
+
.upsertItemToCollection(object_uid, property, file);
|
|
652
525
|
}
|
|
653
526
|
else {
|
|
654
527
|
await object.getStore().setAttribute(object_uid, property, file);
|
|
@@ -669,12 +542,14 @@ export class BinaryService extends Service {
|
|
|
669
542
|
* @returns
|
|
670
543
|
*/
|
|
671
544
|
async deleteSuccess(object, property, index) {
|
|
672
|
-
|
|
545
|
+
const info = (index !== undefined ? object[property][index] : object[property]);
|
|
673
546
|
const relations = this.getWebda().getApplication().getRelations(object);
|
|
674
547
|
const cardinality = (relations.binaries || []).find(p => p.attribute === property)?.cardinality || "MANY";
|
|
675
548
|
let update;
|
|
676
549
|
if (cardinality === "MANY") {
|
|
677
|
-
update = object
|
|
550
|
+
update = object
|
|
551
|
+
.getStore()
|
|
552
|
+
.deleteItemFromCollection(object.getUuid(), property, index, info.hash, "hash");
|
|
678
553
|
}
|
|
679
554
|
else {
|
|
680
555
|
object.getStore().removeAttribute(object.getUuid(), property);
|
|
@@ -691,178 +566,26 @@ export class BinaryService extends Service {
|
|
|
691
566
|
* @param req
|
|
692
567
|
* @returns
|
|
693
568
|
*/
|
|
694
|
-
async
|
|
695
|
-
|
|
696
|
-
|
|
569
|
+
async getFile(req) {
|
|
570
|
+
const { size } = req.getParameters();
|
|
571
|
+
let { mimetype, name } = req.getParameters();
|
|
572
|
+
if (size > this.parameters.maxFileSize) {
|
|
573
|
+
throw new WebdaError.BadRequest("File too big");
|
|
574
|
+
}
|
|
575
|
+
const file = await req.getRawInput(size ?? this.parameters.maxFileSize);
|
|
576
|
+
mimetype ?? (mimetype = "application/octet-stream");
|
|
577
|
+
name ?? (name = "data.bin");
|
|
697
578
|
return new MemoryBinaryFile(Buffer.from(file), {
|
|
698
|
-
mimetype
|
|
699
|
-
size
|
|
700
|
-
name:
|
|
579
|
+
mimetype,
|
|
580
|
+
size,
|
|
581
|
+
name: name,
|
|
582
|
+
hash: crypto.createHash("md5").update(file).digest("hex"),
|
|
583
|
+
challenge: crypto
|
|
584
|
+
.createHash("md5")
|
|
585
|
+
.update("WEBDA" + file)
|
|
586
|
+
.digest("hex")
|
|
701
587
|
});
|
|
702
588
|
}
|
|
703
|
-
/**
|
|
704
|
-
* @override
|
|
705
|
-
*/
|
|
706
|
-
initRoutes() {
|
|
707
|
-
if (!this.parameters.expose) {
|
|
708
|
-
return;
|
|
709
|
-
}
|
|
710
|
-
this._initRoutes();
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Init the Binary system routes
|
|
714
|
-
*
|
|
715
|
-
* Making sure parameters.expose exists prior
|
|
716
|
-
*/
|
|
717
|
-
_initRoutes() {
|
|
718
|
-
let url;
|
|
719
|
-
let name = this.getOperationName();
|
|
720
|
-
if (!this.parameters.expose.restrict.get) {
|
|
721
|
-
url = this.parameters.expose.url + "/{store}/{uuid}/{property}/{index}";
|
|
722
|
-
this.addRoute(url, ["GET"], this.httpGet, {
|
|
723
|
-
get: {
|
|
724
|
-
operationId: `get${name}Binary`,
|
|
725
|
-
description: "Download a binary linked to an object",
|
|
726
|
-
summary: "Download a binary",
|
|
727
|
-
responses: {
|
|
728
|
-
"200": {
|
|
729
|
-
description: "Binary stream"
|
|
730
|
-
},
|
|
731
|
-
"403": {
|
|
732
|
-
description: "You don't have permissions"
|
|
733
|
-
},
|
|
734
|
-
"404": {
|
|
735
|
-
description: "Object does not exist or attachment does not exist"
|
|
736
|
-
},
|
|
737
|
-
"412": {
|
|
738
|
-
description: "Provided hash does not match"
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
});
|
|
743
|
-
this.addRoute(url + "/url", ["GET"], this.httpGet, {
|
|
744
|
-
get: {
|
|
745
|
-
operationId: `get${name}BinaryInfo`,
|
|
746
|
-
description: "Return the url and information of a binary linked to an object",
|
|
747
|
-
summary: "GetInfo of a binary",
|
|
748
|
-
responses: {
|
|
749
|
-
"200": {
|
|
750
|
-
description: "Url and BinaryMap"
|
|
751
|
-
},
|
|
752
|
-
"403": {
|
|
753
|
-
description: "You don't have permissions"
|
|
754
|
-
},
|
|
755
|
-
"404": {
|
|
756
|
-
description: "Object does not exist or attachment does not exist"
|
|
757
|
-
},
|
|
758
|
-
"412": {
|
|
759
|
-
description: "Provided hash does not match"
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
}
|
|
765
|
-
if (!this.parameters.expose.restrict.create) {
|
|
766
|
-
// No need the index to add file
|
|
767
|
-
url = this.parameters.expose.url + "/{store}/{uuid}/{property}";
|
|
768
|
-
this.addRoute(url, ["POST"], this.httpRoute, {
|
|
769
|
-
post: {
|
|
770
|
-
operationId: `add${name}Binary`,
|
|
771
|
-
description: "Add a binary linked to an object",
|
|
772
|
-
summary: "Add a binary",
|
|
773
|
-
responses: {
|
|
774
|
-
"200": {
|
|
775
|
-
description: ""
|
|
776
|
-
},
|
|
777
|
-
"403": {
|
|
778
|
-
description: "You don't have permissions"
|
|
779
|
-
},
|
|
780
|
-
"404": {
|
|
781
|
-
description: "Object does not exist or attachment does not exist"
|
|
782
|
-
},
|
|
783
|
-
"412": {
|
|
784
|
-
description: "Provided hash does not match"
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
});
|
|
789
|
-
}
|
|
790
|
-
if (!this.parameters.expose.restrict.create) {
|
|
791
|
-
// Add file with challenge
|
|
792
|
-
url = this.parameters.expose.url + "/upload/{store}/{uuid}/{property}";
|
|
793
|
-
this.addRoute(url, ["PUT"], this.httpChallenge, {
|
|
794
|
-
put: {
|
|
795
|
-
operationId: `put${name}Binary`,
|
|
796
|
-
description: "Add a binary to an object after challenge",
|
|
797
|
-
summary: "Add a binary",
|
|
798
|
-
responses: {
|
|
799
|
-
"204": {
|
|
800
|
-
description: ""
|
|
801
|
-
},
|
|
802
|
-
"403": {
|
|
803
|
-
description: "You don't have permissions"
|
|
804
|
-
},
|
|
805
|
-
"404": {
|
|
806
|
-
description: "Object does not exist or attachment does not exist"
|
|
807
|
-
},
|
|
808
|
-
"412": {
|
|
809
|
-
description: "Provided hash does not match"
|
|
810
|
-
}
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
if (!this.parameters.expose.restrict.delete) {
|
|
816
|
-
// Need hash to avoid concurrent delete
|
|
817
|
-
url = this.parameters.expose.url + "/{store}/{uuid}/{property}/{index}/{hash}";
|
|
818
|
-
this.addRoute(url, ["DELETE"], this.httpRoute, {
|
|
819
|
-
delete: {
|
|
820
|
-
operationId: `delete${name}Binary`,
|
|
821
|
-
description: "Delete a binary linked to an object",
|
|
822
|
-
summary: "Delete a binary",
|
|
823
|
-
responses: {
|
|
824
|
-
"204": {
|
|
825
|
-
description: ""
|
|
826
|
-
},
|
|
827
|
-
"403": {
|
|
828
|
-
description: "You don't have permissions"
|
|
829
|
-
},
|
|
830
|
-
"404": {
|
|
831
|
-
description: "Object does not exist or attachment does not exist"
|
|
832
|
-
},
|
|
833
|
-
"412": {
|
|
834
|
-
description: "Provided hash does not match"
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
}
|
|
838
|
-
});
|
|
839
|
-
}
|
|
840
|
-
if (!this.parameters.expose.restrict.metadata) {
|
|
841
|
-
// Need hash to avoid concurrent delete
|
|
842
|
-
url = this.parameters.expose.url + "/{store}/{uuid}/{property}/{index}/{hash}";
|
|
843
|
-
this.addRoute(url, ["PUT"], this.httpRoute, {
|
|
844
|
-
put: {
|
|
845
|
-
operationId: `update${name}BinaryMetadata`,
|
|
846
|
-
description: "Update a binary metadata linked to an object",
|
|
847
|
-
summary: "Update a binary metadata",
|
|
848
|
-
responses: {
|
|
849
|
-
"204": {
|
|
850
|
-
description: ""
|
|
851
|
-
},
|
|
852
|
-
"403": {
|
|
853
|
-
description: "You don't have permissions"
|
|
854
|
-
},
|
|
855
|
-
"404": {
|
|
856
|
-
description: "Object does not exist or attachment does not exist"
|
|
857
|
-
},
|
|
858
|
-
"412": {
|
|
859
|
-
description: "Provided hash does not match"
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
});
|
|
864
|
-
}
|
|
865
|
-
}
|
|
866
589
|
/**
|
|
867
590
|
* Return the name of the service for OpenAPI
|
|
868
591
|
* @returns
|
|
@@ -875,125 +598,20 @@ export class BinaryService extends Service {
|
|
|
875
598
|
* @param ctx
|
|
876
599
|
* @returns
|
|
877
600
|
*/
|
|
878
|
-
|
|
601
|
+
verifyMapAndStore(ctx) {
|
|
879
602
|
// Check for model
|
|
880
|
-
if (ctx.parameter("model")) {
|
|
881
|
-
|
|
882
|
-
throw new WebdaError.NotFound("Model not managed by this store");
|
|
883
|
-
}
|
|
884
|
-
return this.getWebda().getModelStore(this.getWebda().getModel(ctx.parameter("model")));
|
|
885
|
-
}
|
|
886
|
-
let store = ctx.parameter("store").toLowerCase();
|
|
887
|
-
// To avoid any problem lowercase everything
|
|
888
|
-
let map = this.parameters.map[this._lowercaseMaps[store]];
|
|
889
|
-
if (map === undefined) {
|
|
890
|
-
throw new WebdaError.NotFound("Unknown map");
|
|
891
|
-
}
|
|
892
|
-
if (!map.includes(ctx.parameter("property"))) {
|
|
893
|
-
throw new WebdaError.NotFound("Unknown property");
|
|
894
|
-
}
|
|
895
|
-
let targetStore = this.getService(this._lowercaseMaps[store]);
|
|
896
|
-
if (targetStore === undefined) {
|
|
897
|
-
throw new WebdaError.NotFound("Unknown store");
|
|
603
|
+
if (this.handleBinary(ctx.parameter("model"), ctx.parameter("property")) === -1) {
|
|
604
|
+
throw new WebdaError.NotFound("Model not managed by this store");
|
|
898
605
|
}
|
|
899
|
-
return
|
|
606
|
+
return this.getWebda().getModelStore(this.getWebda().getModel(ctx.parameter("model")));
|
|
900
607
|
}
|
|
901
608
|
/**
|
|
902
609
|
* By default no challenge is managed so throws 404
|
|
903
610
|
*
|
|
904
|
-
* @param ctx
|
|
905
611
|
*/
|
|
906
|
-
async putRedirectUrl(
|
|
612
|
+
async putRedirectUrl(...args) {
|
|
907
613
|
// Dont handle the redirect url
|
|
908
614
|
throw new WebdaError.NotFound("No redirect url");
|
|
909
615
|
}
|
|
910
|
-
/**
|
|
911
|
-
* Mechanism to add a data based on challenge
|
|
912
|
-
*/
|
|
913
|
-
async httpChallenge(ctx) {
|
|
914
|
-
let body = await ctx.getRequestBody();
|
|
915
|
-
if (!body.hash || !body.challenge) {
|
|
916
|
-
throw new WebdaError.BadRequest("Missing hash or challenge");
|
|
917
|
-
}
|
|
918
|
-
// First verify if map exist
|
|
919
|
-
let targetStore = this._verifyMapAndStore(ctx);
|
|
920
|
-
// Get the object
|
|
921
|
-
let object = await targetStore.get(ctx.parameter("uuid"), ctx);
|
|
922
|
-
if (object === undefined) {
|
|
923
|
-
throw new WebdaError.NotFound("Object does not exist");
|
|
924
|
-
}
|
|
925
|
-
await object.checkAct(ctx, "attach_binary");
|
|
926
|
-
let url = await this.putRedirectUrl(ctx);
|
|
927
|
-
let base64String = Buffer.from(body.hash, "hex").toString("base64");
|
|
928
|
-
ctx.write({
|
|
929
|
-
...url,
|
|
930
|
-
done: url === undefined,
|
|
931
|
-
md5: base64String
|
|
932
|
-
});
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Manage the different routes
|
|
936
|
-
* @param ctx
|
|
937
|
-
*/
|
|
938
|
-
async httpRoute(ctx) {
|
|
939
|
-
// First verify if map exist
|
|
940
|
-
let targetStore = this._verifyMapAndStore(ctx);
|
|
941
|
-
// Get the object
|
|
942
|
-
let object = await targetStore.get(ctx.parameter("uuid"), ctx);
|
|
943
|
-
if (object === undefined) {
|
|
944
|
-
throw new WebdaError.NotFound("Object does not exist");
|
|
945
|
-
}
|
|
946
|
-
const { property, index } = ctx.getParameters();
|
|
947
|
-
// Current file - would be empty on creation
|
|
948
|
-
const file = Array.isArray(object[property]) ? object[property][index] : object[property];
|
|
949
|
-
// Check permissions
|
|
950
|
-
let action = "unknown";
|
|
951
|
-
if (ctx.getHttpContext().getMethod() === "DELETE") {
|
|
952
|
-
action = "detach_binary";
|
|
953
|
-
}
|
|
954
|
-
else if (ctx.getHttpContext().getMethod() === "POST") {
|
|
955
|
-
action = "attach_binary";
|
|
956
|
-
}
|
|
957
|
-
else if (ctx.getHttpContext().getMethod() === "PUT") {
|
|
958
|
-
action = "update_binary_metadata";
|
|
959
|
-
}
|
|
960
|
-
await object.checkAct(ctx, action);
|
|
961
|
-
// Now do the action
|
|
962
|
-
if (ctx.getHttpContext().getMethod() === "POST") {
|
|
963
|
-
await this.store(object, property, await this._getFile(ctx));
|
|
964
|
-
}
|
|
965
|
-
else {
|
|
966
|
-
if (file.hash !== ctx.parameter("hash")) {
|
|
967
|
-
throw new WebdaError.BadRequest("Hash does not match");
|
|
968
|
-
}
|
|
969
|
-
if (ctx.getHttpContext().getMethod() === "DELETE") {
|
|
970
|
-
await this.delete(object, property, index);
|
|
971
|
-
}
|
|
972
|
-
else if (ctx.getHttpContext().getMethod() === "PUT") {
|
|
973
|
-
let metadata = await ctx.getRequestBody();
|
|
974
|
-
// Limit metadata to 4kb
|
|
975
|
-
if (JSON.stringify(metadata).length >= 4096) {
|
|
976
|
-
throw new WebdaError.BadRequest("Metadata is too big: 4kb max");
|
|
977
|
-
}
|
|
978
|
-
let evt = {
|
|
979
|
-
service: this,
|
|
980
|
-
object: file,
|
|
981
|
-
target: object
|
|
982
|
-
};
|
|
983
|
-
await this.emitSync("Binary.MetadataUpdate", {
|
|
984
|
-
...evt,
|
|
985
|
-
metadata
|
|
986
|
-
});
|
|
987
|
-
file.metadata = metadata;
|
|
988
|
-
// Update mapper on purpose
|
|
989
|
-
await object.getStore().patch({
|
|
990
|
-
[object.__class.getUuidField()]: object.getUuid(),
|
|
991
|
-
[property]: object[property]
|
|
992
|
-
}, false);
|
|
993
|
-
this.metrics.metadataUpdate.inc();
|
|
994
|
-
await this.emitSync("Binary.MetadataUpdated", evt);
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
}
|
|
998
616
|
}
|
|
999
617
|
//# sourceMappingURL=binary.js.map
|