@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
|
@@ -1,128 +1,5 @@
|
|
|
1
|
-
import { Core, JSONUtils, Service, ServiceParameters, WebdaError
|
|
1
|
+
import { Core, JSONUtils, Service, ServiceParameters, WebdaError } from "../index.js";
|
|
2
2
|
import { TransformCase } from "../utils/case.js";
|
|
3
|
-
/**
|
|
4
|
-
* @WebdaModda
|
|
5
|
-
*/
|
|
6
|
-
export class ModelsOperationsService extends Service {
|
|
7
|
-
/**
|
|
8
|
-
* Add operations for all exposed models
|
|
9
|
-
* @returns
|
|
10
|
-
*/
|
|
11
|
-
initOperations() {
|
|
12
|
-
super.initOperations();
|
|
13
|
-
const app = this.getWebda().getApplication();
|
|
14
|
-
// Add default schemas
|
|
15
|
-
if (!app.hasSchema("uuidRequest")) {
|
|
16
|
-
app.registerSchema("uuidRequest", {
|
|
17
|
-
type: "object",
|
|
18
|
-
properties: {
|
|
19
|
-
uuid: {
|
|
20
|
-
type: "string"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
required: ["uuid"]
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
if (!app.hasSchema("searchRequest")) {
|
|
27
|
-
app.registerSchema("searchRequest", {
|
|
28
|
-
type: "object",
|
|
29
|
-
properties: {
|
|
30
|
-
query: {
|
|
31
|
-
type: "string"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
const getSchema = (id, input, params) => {
|
|
37
|
-
const schema = {
|
|
38
|
-
type: "object",
|
|
39
|
-
properties: {},
|
|
40
|
-
required: []
|
|
41
|
-
};
|
|
42
|
-
if (input && app.hasSchema(input)) {
|
|
43
|
-
schema.properties["input"] = app.getSchema(input);
|
|
44
|
-
schema.required.push("input");
|
|
45
|
-
}
|
|
46
|
-
if (params) {
|
|
47
|
-
schema.properties["params"] = app.getSchema(params);
|
|
48
|
-
schema.required.push("params");
|
|
49
|
-
}
|
|
50
|
-
app.registerSchema(id, schema);
|
|
51
|
-
return id;
|
|
52
|
-
};
|
|
53
|
-
const models = app.getModels();
|
|
54
|
-
for (let modelKey in models) {
|
|
55
|
-
const model = models[modelKey];
|
|
56
|
-
const expose = model.Expose;
|
|
57
|
-
if (!expose) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const prefix = modelKey.split("/").pop();
|
|
61
|
-
const modelSchema = modelKey;
|
|
62
|
-
["create", "update"]
|
|
63
|
-
.filter(k => !expose.restrict[k])
|
|
64
|
-
.forEach(k => {
|
|
65
|
-
k = k.substring(0, 1).toUpperCase() + k.substring(1);
|
|
66
|
-
const id = `${prefix}.${k}`;
|
|
67
|
-
this.getWebda().registerOperation(id, {
|
|
68
|
-
service: this.getName(),
|
|
69
|
-
method: k === "Create" ? "httpCreate" : "operationUpdate",
|
|
70
|
-
id,
|
|
71
|
-
input: getSchema(id, modelSchema, k === "Update" ? "uuidRequest" : undefined),
|
|
72
|
-
output: modelSchema
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
["delete", "get"]
|
|
76
|
-
.filter(k => !expose.restrict[k])
|
|
77
|
-
.forEach(k => {
|
|
78
|
-
k = k.substring(0, 1).toUpperCase() + k.substring(1);
|
|
79
|
-
const id = `${prefix}.${k}`;
|
|
80
|
-
const info = {
|
|
81
|
-
service: this.getName(),
|
|
82
|
-
method: `http${k}`,
|
|
83
|
-
id,
|
|
84
|
-
input: getSchema(id, undefined, "uuidRequest")
|
|
85
|
-
};
|
|
86
|
-
if (k === "Get") {
|
|
87
|
-
info.output = modelSchema;
|
|
88
|
-
}
|
|
89
|
-
this.getWebda().registerOperation(id, info);
|
|
90
|
-
});
|
|
91
|
-
if (!expose.restrict.query) {
|
|
92
|
-
const id = `${prefix}.Query`;
|
|
93
|
-
this.getWebda().registerOperation(id, {
|
|
94
|
-
service: this.getName(),
|
|
95
|
-
method: "httpQuery",
|
|
96
|
-
id,
|
|
97
|
-
input: getSchema(id, undefined, "searchRequest")
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
// Add patch
|
|
101
|
-
if (!expose.restrict.update) {
|
|
102
|
-
const id = `${prefix}.Patch`;
|
|
103
|
-
this.getWebda().registerOperation(id, {
|
|
104
|
-
service: this.getName(),
|
|
105
|
-
method: "operationPatch",
|
|
106
|
-
id,
|
|
107
|
-
input: getSchema(id, modelSchema + "?", "uuidRequest")
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
// Add all operations for Actions
|
|
111
|
-
let actions = model.getActions();
|
|
112
|
-
Object.keys(actions).forEach(name => {
|
|
113
|
-
const id = `${prefix}.${name.substring(0, 1).toUpperCase() + name.substring(1)}`;
|
|
114
|
-
const info = {
|
|
115
|
-
service: this.getName(),
|
|
116
|
-
method: `action${name}`,
|
|
117
|
-
id
|
|
118
|
-
};
|
|
119
|
-
info.input = getSchema(id, `${modelKey}.${name}.input`, "uuidRequest");
|
|
120
|
-
info.output = `${modelKey}.${name}.output`;
|
|
121
|
-
this.getWebda().registerOperation(id, info);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
3
|
export class DomainServiceParameters extends ServiceParameters {
|
|
127
4
|
constructor(params) {
|
|
128
5
|
super(params);
|
|
@@ -154,48 +31,6 @@ export class DomainServiceParameters extends ServiceParameters {
|
|
|
154
31
|
return this.excludedModels.includes(model);
|
|
155
32
|
}
|
|
156
33
|
}
|
|
157
|
-
/**
|
|
158
|
-
* Swagger static html
|
|
159
|
-
*/
|
|
160
|
-
const swagger = `
|
|
161
|
-
<html>
|
|
162
|
-
<head>
|
|
163
|
-
<meta charset="UTF-8">
|
|
164
|
-
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.19.5/swagger-ui.css" >
|
|
165
|
-
<style>
|
|
166
|
-
.topbar {
|
|
167
|
-
display: none;
|
|
168
|
-
}
|
|
169
|
-
</style>
|
|
170
|
-
</head>
|
|
171
|
-
|
|
172
|
-
<body>
|
|
173
|
-
<div id="swagger-ui"></div>
|
|
174
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.19.5/swagger-ui-bundle.js"> </script>
|
|
175
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.19.5/swagger-ui-standalone-preset.js"> </script>
|
|
176
|
-
<script>
|
|
177
|
-
const spec = {{OPENAPI}};
|
|
178
|
-
window.onload = function() {
|
|
179
|
-
const ui = SwaggerUIBundle({
|
|
180
|
-
spec: spec,
|
|
181
|
-
dom_id: '#swagger-ui',
|
|
182
|
-
deepLinking: true,
|
|
183
|
-
presets: [
|
|
184
|
-
SwaggerUIBundle.presets.apis,
|
|
185
|
-
SwaggerUIStandalonePreset
|
|
186
|
-
],
|
|
187
|
-
plugins: [
|
|
188
|
-
SwaggerUIBundle.plugins.DownloadUrl
|
|
189
|
-
],
|
|
190
|
-
layout: "StandaloneLayout"
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
window.ui = ui
|
|
194
|
-
}
|
|
195
|
-
</script>
|
|
196
|
-
</body>
|
|
197
|
-
</html>
|
|
198
|
-
`;
|
|
199
34
|
/**
|
|
200
35
|
* Domain Service expose all the models as Route and Operations
|
|
201
36
|
*
|
|
@@ -230,6 +65,11 @@ export class DomainService extends Service {
|
|
|
230
65
|
if (!model.Expose || (model.getIdentifier && !this.parameters.isIncluded(model.getIdentifier()))) {
|
|
231
66
|
return;
|
|
232
67
|
}
|
|
68
|
+
const shortId = model.getIdentifier(true);
|
|
69
|
+
// Overlap object are hidden by design
|
|
70
|
+
if (shortId.includes("/")) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
233
73
|
const context = JSONUtils.duplicate(modelContext);
|
|
234
74
|
context.depth = depth;
|
|
235
75
|
if (!this.handleModel(model, name, context)) {
|
|
@@ -258,627 +98,554 @@ export class DomainService extends Service {
|
|
|
258
98
|
});
|
|
259
99
|
return this;
|
|
260
100
|
}
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
*
|
|
264
|
-
*/
|
|
265
|
-
export class RESTDomainServiceParameters extends DomainServiceParameters {
|
|
266
101
|
/**
|
|
267
|
-
*
|
|
268
|
-
* @param
|
|
102
|
+
*
|
|
103
|
+
* @param model
|
|
104
|
+
* @param uuid
|
|
269
105
|
*/
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
106
|
+
async getModel(context) {
|
|
107
|
+
const { model } = context.getExtension("operationContext");
|
|
108
|
+
const { uuid } = context.getParameters();
|
|
109
|
+
const object = await model.ref(uuid).get();
|
|
110
|
+
if (object === undefined || object.isDeleted()) {
|
|
111
|
+
await this.emitSync("Store.WebNotFound", {
|
|
112
|
+
context,
|
|
113
|
+
uuid
|
|
114
|
+
});
|
|
115
|
+
throw new WebdaError.NotFound("Object not found");
|
|
116
|
+
}
|
|
117
|
+
return object;
|
|
273
118
|
}
|
|
274
|
-
}
|
|
275
|
-
/**
|
|
276
|
-
* Expose all models via a REST API
|
|
277
|
-
* @WebdaModda
|
|
278
|
-
*/
|
|
279
|
-
export class RESTDomainService extends DomainService {
|
|
280
119
|
/**
|
|
281
|
-
*
|
|
282
|
-
* @
|
|
120
|
+
* Create a model operation implementation
|
|
121
|
+
* @param context
|
|
283
122
|
*/
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
123
|
+
async modelCreate(context) {
|
|
124
|
+
const { model } = context.getExtension("operationContext");
|
|
125
|
+
const object = model.factory(await context.getInput(), context);
|
|
126
|
+
await object.checkAct(context, "create");
|
|
127
|
+
// Enforce the UUID
|
|
128
|
+
object.setUuid(object.generateUid());
|
|
129
|
+
// Check for conflict
|
|
130
|
+
// await object.validate(context, {});
|
|
131
|
+
if (await model.ref(object.getUuid()).exists()) {
|
|
132
|
+
throw new WebdaError.Conflict("Object already exists");
|
|
290
133
|
}
|
|
291
|
-
|
|
134
|
+
await object.save();
|
|
135
|
+
// Set the location header to only uuid for now
|
|
136
|
+
context.setHeader("Location", object.getUuid());
|
|
137
|
+
context.write(object);
|
|
292
138
|
}
|
|
293
139
|
/**
|
|
294
|
-
*
|
|
140
|
+
* Update a model operation implementation
|
|
141
|
+
* @param context
|
|
295
142
|
*/
|
|
296
|
-
|
|
297
|
-
|
|
143
|
+
async modelUpdate(context) {
|
|
144
|
+
const object = await this.getModel(context);
|
|
145
|
+
const input = await context.getInput();
|
|
146
|
+
await object.checkAct(context, "update");
|
|
147
|
+
object.load(input);
|
|
148
|
+
await object.save(true);
|
|
149
|
+
context.write(object);
|
|
298
150
|
}
|
|
299
151
|
/**
|
|
300
|
-
*
|
|
301
|
-
* @param
|
|
302
|
-
|
|
152
|
+
* Get a model operation implementation
|
|
153
|
+
* @param context
|
|
154
|
+
*/
|
|
155
|
+
async modelGet(context) {
|
|
156
|
+
const object = await this.getModel(context);
|
|
157
|
+
await object.checkAct(context, "get");
|
|
158
|
+
const evt = {
|
|
159
|
+
context,
|
|
160
|
+
object: object
|
|
161
|
+
};
|
|
162
|
+
//
|
|
163
|
+
await Promise.all([this.emitSync("Store.WebGet", evt), object.__class.emitSync("Store.WebGet", evt)]);
|
|
164
|
+
context.write(object);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Delete a model operation implementation
|
|
168
|
+
* @param context
|
|
169
|
+
*/
|
|
170
|
+
async modelDelete(context) {
|
|
171
|
+
const object = await this.getModel(context);
|
|
172
|
+
if (!object) {
|
|
173
|
+
throw new WebdaError.NotFound("Object not found");
|
|
174
|
+
}
|
|
175
|
+
await object.checkAct(context, "delete");
|
|
176
|
+
// Object can decide to not delete but mark as deleted
|
|
177
|
+
await object.delete();
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Query models
|
|
181
|
+
* @param context
|
|
182
|
+
*/
|
|
183
|
+
async modelQuery(context) {
|
|
184
|
+
const { model } = context.getExtension("operationContext");
|
|
185
|
+
const { query } = context.getParameters();
|
|
186
|
+
try {
|
|
187
|
+
context.write(await model.query(query, true, context));
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
if (err instanceof SyntaxError) {
|
|
191
|
+
this.log("INFO", "Query syntax error");
|
|
192
|
+
throw new WebdaError.BadRequest("Query syntax error");
|
|
193
|
+
}
|
|
194
|
+
throw err;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Patch a model
|
|
199
|
+
* @param context
|
|
200
|
+
*/
|
|
201
|
+
async modelPatch(context) {
|
|
202
|
+
const object = await this.getModel(context);
|
|
203
|
+
const input = await context.getInput();
|
|
204
|
+
await object.checkAct(context, "update");
|
|
205
|
+
await object.patch(input);
|
|
206
|
+
context.write(object);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Action on a model
|
|
303
210
|
* @param context
|
|
211
|
+
*/
|
|
212
|
+
async modelAction(context) {
|
|
213
|
+
const { model, action } = context.getExtension("operationContext");
|
|
214
|
+
if (!action.global) {
|
|
215
|
+
const object = await model.ref(context.getParameters().uuid).get();
|
|
216
|
+
if (!object || object.isDeleted()) {
|
|
217
|
+
throw new WebdaError.NotFound("Object not found");
|
|
218
|
+
}
|
|
219
|
+
await object.checkAct(context, action.name);
|
|
220
|
+
const output = await object[action.name](context);
|
|
221
|
+
context.write(output);
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
model[action.name](context);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Add operations for all exposed models
|
|
304
229
|
* @returns
|
|
305
230
|
*/
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
231
|
+
initOperations() {
|
|
232
|
+
super.initOperations();
|
|
233
|
+
if (!this.parameters.operations) {
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
310
236
|
const app = this.getWebda().getApplication();
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
(await context.getInput())[injectAttribute] = context.getPathParameters()[parentId];
|
|
316
|
-
}
|
|
317
|
-
else if (type === "QUERY") {
|
|
318
|
-
let input = await context.getInput({ defaultValue: { q: "" } });
|
|
319
|
-
let q;
|
|
320
|
-
if (context.getHttpContext().getMethod() === "GET") {
|
|
321
|
-
q = context.getParameters().q;
|
|
322
|
-
}
|
|
323
|
-
else {
|
|
324
|
-
q = input.q;
|
|
325
|
-
}
|
|
326
|
-
let query;
|
|
327
|
-
try {
|
|
328
|
-
query = new WebdaQL.QueryValidator(q);
|
|
329
|
-
}
|
|
330
|
-
catch (err) {
|
|
331
|
-
throw new WebdaError.BadRequest("Invalid query " + q);
|
|
332
|
-
}
|
|
333
|
-
if (injectAttribute) {
|
|
334
|
-
query.merge(`${injectAttribute} = "${context.getPathParameters()[parentId]}"`);
|
|
335
|
-
}
|
|
336
|
-
if (args[0] !== 0) {
|
|
337
|
-
query.merge(`__types CONTAINS "${model.getIdentifier()}"`);
|
|
338
|
-
}
|
|
339
|
-
if (context.getHttpContext().getMethod() === "GET") {
|
|
340
|
-
context.getParameters().q = query.toString();
|
|
341
|
-
}
|
|
342
|
-
else {
|
|
343
|
-
input.q = query.toString();
|
|
344
|
-
}
|
|
345
|
-
this.log("TRACE", `Query modified to '${query.toString()}' from '${q}' ${args[0]}`);
|
|
346
|
-
}
|
|
347
|
-
// Complete the uuid if needed
|
|
348
|
-
if (context.getParameters().uuid) {
|
|
349
|
-
context.getParameters().uuid = model.completeUid(context.getParameters().uuid);
|
|
350
|
-
}
|
|
351
|
-
await service[method](context, ...args);
|
|
352
|
-
};
|
|
353
|
-
};
|
|
354
|
-
// Update prefix
|
|
355
|
-
const prefix = (context.prefix || (this.parameters.url.endsWith("/") ? this.parameters.url : this.parameters.url + "/")) +
|
|
356
|
-
this.transformName(name);
|
|
357
|
-
context.prefix = prefix + `/{pid.${depth}}/`;
|
|
358
|
-
// Register the model url
|
|
359
|
-
this.getWebda().getRouter().registerModelUrl(app.getModelName(model), prefix);
|
|
360
|
-
let openapi = {
|
|
361
|
-
[this.parameters.queryMethod.toLowerCase()]: {
|
|
362
|
-
tags: [name],
|
|
363
|
-
summary: `Query ${name}`,
|
|
364
|
-
operationId: `query${name}`,
|
|
365
|
-
requestBody: this.parameters.queryMethod === "GET"
|
|
366
|
-
? undefined
|
|
367
|
-
: {
|
|
368
|
-
content: {
|
|
369
|
-
"application/json": {
|
|
370
|
-
schema: {
|
|
371
|
-
properties: {
|
|
372
|
-
q: {
|
|
373
|
-
type: "string"
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
-
parameters: this.parameters.queryMethod === "GET"
|
|
381
|
-
? [
|
|
382
|
-
{
|
|
383
|
-
name: "q",
|
|
384
|
-
in: "query",
|
|
385
|
-
description: "Query to execute",
|
|
386
|
-
schema: {
|
|
387
|
-
type: "string"
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
]
|
|
391
|
-
: [],
|
|
392
|
-
responses: {
|
|
393
|
-
"200": {
|
|
394
|
-
description: "Operation success",
|
|
395
|
-
content: {
|
|
396
|
-
"application/json": {
|
|
397
|
-
schema: {
|
|
398
|
-
properties: {
|
|
399
|
-
continuationToken: {
|
|
400
|
-
type: "string"
|
|
401
|
-
},
|
|
402
|
-
results: {
|
|
403
|
-
type: "array",
|
|
404
|
-
items: {
|
|
405
|
-
$ref: `#/components/schemas/${model.getIdentifier()}`
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
},
|
|
413
|
-
"400": {
|
|
414
|
-
description: "Query is invalid"
|
|
415
|
-
},
|
|
416
|
-
"403": {
|
|
417
|
-
description: "You don't have permissions"
|
|
418
|
-
}
|
|
419
|
-
}
|
|
237
|
+
// Add default schemas - used for operation parameters
|
|
238
|
+
for (const i in ModelsOperationsService.schemas) {
|
|
239
|
+
if (app.hasSchema(i)) {
|
|
240
|
+
continue;
|
|
420
241
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
242
|
+
app.registerSchema(i, ModelsOperationsService.schemas[i]);
|
|
243
|
+
}
|
|
244
|
+
const models = app.getModels();
|
|
245
|
+
for (const modelKey in models) {
|
|
246
|
+
const model = models[modelKey];
|
|
247
|
+
const expose = model.Expose;
|
|
248
|
+
// Skip if not exposed or not included
|
|
249
|
+
if (!expose || !this.parameters.isIncluded(model.getIdentifier())) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const shortId = model.getIdentifier(true);
|
|
253
|
+
// Overlap object are hidden by design
|
|
254
|
+
if (shortId.includes("/")) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const plurial = app.getModelPlural(model.getIdentifier(false));
|
|
258
|
+
const modelSchema = modelKey;
|
|
259
|
+
["create", "update"]
|
|
260
|
+
.filter(k => !expose.restrict[k])
|
|
261
|
+
.forEach(k => {
|
|
262
|
+
k = k.substring(0, 1).toUpperCase() + k.substring(1);
|
|
263
|
+
const id = `${shortId}.${k}`;
|
|
264
|
+
this.getWebda().registerOperation(id, {
|
|
265
|
+
service: this.getName(),
|
|
266
|
+
method: k === "Create" ? "modelCreate" : "modelUpdate",
|
|
267
|
+
input: modelSchema,
|
|
268
|
+
output: modelSchema,
|
|
269
|
+
parameters: k === "Create" ? undefined : "uuidRequest",
|
|
270
|
+
context: {
|
|
271
|
+
model
|
|
436
272
|
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
},
|
|
452
|
-
"403": {
|
|
453
|
-
description: "You don't have permissions"
|
|
454
|
-
},
|
|
455
|
-
"409": {
|
|
456
|
-
description: "Object already exists"
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
["delete", "get"]
|
|
276
|
+
.filter(k => !expose.restrict[k])
|
|
277
|
+
.forEach(k => {
|
|
278
|
+
k = k.substring(0, 1).toUpperCase() + k.substring(1);
|
|
279
|
+
const id = `${shortId}.${k}`;
|
|
280
|
+
const info = {
|
|
281
|
+
service: this.getName(),
|
|
282
|
+
method: `model${k}`,
|
|
283
|
+
id,
|
|
284
|
+
parameters: "uuidRequest",
|
|
285
|
+
context: {
|
|
286
|
+
model
|
|
457
287
|
}
|
|
288
|
+
};
|
|
289
|
+
if (k === "Get") {
|
|
290
|
+
info.output = modelSchema;
|
|
458
291
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
responses: {
|
|
470
|
-
"204": {
|
|
471
|
-
description: "Operation success"
|
|
472
|
-
},
|
|
473
|
-
"403": {
|
|
474
|
-
description: "You don't have permissions"
|
|
475
|
-
},
|
|
476
|
-
"404": {
|
|
477
|
-
description: "Unknown object"
|
|
292
|
+
this.getWebda().registerOperation(id, info);
|
|
293
|
+
});
|
|
294
|
+
if (!expose.restrict.query) {
|
|
295
|
+
const id = `${plurial}.Query`;
|
|
296
|
+
this.getWebda().registerOperation(id, {
|
|
297
|
+
service: this.getName(),
|
|
298
|
+
method: "modelQuery",
|
|
299
|
+
parameters: "searchRequest",
|
|
300
|
+
context: {
|
|
301
|
+
model
|
|
478
302
|
}
|
|
479
|
-
}
|
|
303
|
+
});
|
|
480
304
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
"application/json": {
|
|
492
|
-
schema: {
|
|
493
|
-
$ref: `#/components/schemas/${model.getIdentifier()}`
|
|
494
|
-
}
|
|
305
|
+
// Add patch
|
|
306
|
+
if (!expose.restrict.update) {
|
|
307
|
+
const id = `${shortId}.Patch`;
|
|
308
|
+
this.getWebda().registerOperation(id, {
|
|
309
|
+
service: this.getName(),
|
|
310
|
+
method: "modelPatch",
|
|
311
|
+
input: modelSchema + "?",
|
|
312
|
+
parameters: "uuidRequest",
|
|
313
|
+
context: {
|
|
314
|
+
model
|
|
495
315
|
}
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
// Add all operations for Actions
|
|
319
|
+
const actions = model.getActions();
|
|
320
|
+
Object.keys(actions).forEach(name => {
|
|
321
|
+
const id = `${shortId}.${name.substring(0, 1).toUpperCase() + name.substring(1)}`;
|
|
322
|
+
const info = {
|
|
323
|
+
service: this.getName(),
|
|
324
|
+
method: `modelAction`,
|
|
325
|
+
id
|
|
326
|
+
};
|
|
327
|
+
info.input = `${modelKey}.${name}.input`;
|
|
328
|
+
info.output = `${modelKey}.${name}.output`;
|
|
329
|
+
info.parameters = actions[name].global ? undefined : "uuidRequest";
|
|
330
|
+
info.context = {
|
|
331
|
+
model,
|
|
332
|
+
action: { ...actions[name], name }
|
|
333
|
+
};
|
|
334
|
+
this.getWebda().registerOperation(id, info);
|
|
335
|
+
});
|
|
336
|
+
this.addBinaryOperations(model, shortId);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
addBinaryOperations(model, name) {
|
|
340
|
+
(model.getRelations().binaries || []).forEach(binary => {
|
|
341
|
+
const webda = Core.get();
|
|
342
|
+
const attribute = binary.attribute.substring(0, 1).toUpperCase() + binary.attribute.substring(1);
|
|
343
|
+
const info = {
|
|
344
|
+
service: this.getName(),
|
|
345
|
+
context: {
|
|
346
|
+
model,
|
|
347
|
+
binary,
|
|
348
|
+
binaryStore: this.getWebda().getBinaryStore(model, binary.attribute)
|
|
501
349
|
},
|
|
502
|
-
"
|
|
503
|
-
|
|
350
|
+
parameters: "uuidRequest"
|
|
351
|
+
};
|
|
352
|
+
webda.registerOperation(`${name}.${attribute}.AttachChallenge`, {
|
|
353
|
+
...info,
|
|
354
|
+
method: "binaryChallenge",
|
|
355
|
+
input: "binaryChallengeRequest"
|
|
356
|
+
});
|
|
357
|
+
webda.registerOperation(`${name}.${attribute}.Attach`, {
|
|
358
|
+
...info,
|
|
359
|
+
context: {
|
|
360
|
+
...info.context,
|
|
361
|
+
action: "create"
|
|
504
362
|
},
|
|
505
|
-
"
|
|
506
|
-
|
|
363
|
+
method: "binaryPut",
|
|
364
|
+
parameters: "binaryAttachParameters"
|
|
365
|
+
});
|
|
366
|
+
webda.registerOperation(`${name}.${attribute}.Get`, {
|
|
367
|
+
...info,
|
|
368
|
+
method: "binaryGet",
|
|
369
|
+
parameters: binary.cardinality === "ONE" ? "uuidRequest" : "binaryGetRequest"
|
|
370
|
+
});
|
|
371
|
+
webda.registerOperation(`${name}.${attribute}.Delete`, {
|
|
372
|
+
...info,
|
|
373
|
+
context: {
|
|
374
|
+
...info.context,
|
|
375
|
+
action: "delete"
|
|
507
376
|
},
|
|
508
|
-
"
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
"application/json": {
|
|
529
|
-
schema: {
|
|
530
|
-
$ref: `#/components/schemas/${model.getIdentifier()}`
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
},
|
|
535
|
-
"400": {
|
|
536
|
-
description: "Object is invalid"
|
|
537
|
-
},
|
|
538
|
-
"403": {
|
|
539
|
-
description: "You don't have permissions"
|
|
540
|
-
},
|
|
541
|
-
"404": {
|
|
542
|
-
description: "Unknown object"
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
};
|
|
547
|
-
model.Expose.restrict.get ||
|
|
548
|
-
this.addRoute(`${prefix}/{uuid}`, ["GET"], injector(model.store(), "httpGet", "GET"), openapi);
|
|
549
|
-
// Add all actions
|
|
550
|
-
// Actions cannot be restricted as its purpose is to be exposed
|
|
551
|
-
let actions = model.getActions();
|
|
552
|
-
Object.keys(actions).forEach(actionName => {
|
|
553
|
-
let action = actions[actionName];
|
|
554
|
-
openapi = {
|
|
555
|
-
...action.openapi
|
|
556
|
-
};
|
|
557
|
-
(action.methods || ["PUT"]).forEach(method => {
|
|
558
|
-
openapi[method.toLowerCase()] = {
|
|
559
|
-
tags: [name],
|
|
560
|
-
...(action.openapi?.[method.toLowerCase()] ?? {})
|
|
561
|
-
};
|
|
377
|
+
method: "binaryAction",
|
|
378
|
+
parameters: binary.cardinality === "ONE" ? "binaryHashRequest" : "binaryIndexHashRequest"
|
|
379
|
+
});
|
|
380
|
+
webda.registerOperation(`${name}.${attribute}.SetMetadata`, {
|
|
381
|
+
...info,
|
|
382
|
+
context: {
|
|
383
|
+
...info.context,
|
|
384
|
+
action: "metadata"
|
|
385
|
+
},
|
|
386
|
+
method: "binaryAction",
|
|
387
|
+
parameters: binary.cardinality === "ONE" ? "binaryHashRequest" : "binaryIndexHashRequest"
|
|
388
|
+
});
|
|
389
|
+
webda.registerOperation(`${name}.${attribute}.GetUrl`, {
|
|
390
|
+
...info,
|
|
391
|
+
context: {
|
|
392
|
+
...info.context,
|
|
393
|
+
returnUrl: true
|
|
394
|
+
},
|
|
395
|
+
method: "binaryGet",
|
|
396
|
+
parameters: binary.cardinality === "ONE" ? "uuidRequest" : "binaryGetRequest"
|
|
562
397
|
});
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
398
|
+
});
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Implement the binary challenge operation
|
|
402
|
+
* @param context
|
|
403
|
+
*/
|
|
404
|
+
async binaryChallenge(context) {
|
|
405
|
+
const body = await context.getInput();
|
|
406
|
+
const { model, binaryStore, binary } = context.getExtension("operationContext");
|
|
407
|
+
// First verify if map exist
|
|
408
|
+
const object = await model.ref(context.parameter("uuid")).get();
|
|
409
|
+
if (object === undefined || object.isDeleted()) {
|
|
410
|
+
throw new WebdaError.NotFound("Object does not exist");
|
|
411
|
+
}
|
|
412
|
+
if (this.checkBinaryAlreadyLinked(object[binary.attribute], body.hash)) {
|
|
413
|
+
return;
|
|
414
|
+
}
|
|
415
|
+
await object.checkAct(context, "attach_binary");
|
|
416
|
+
const url = await binaryStore.putRedirectUrl(object, binary.attribute, body, context);
|
|
417
|
+
const base64String = Buffer.from(body.hash, "hex").toString("base64");
|
|
418
|
+
context.write({
|
|
419
|
+
...url,
|
|
420
|
+
done: url === undefined,
|
|
421
|
+
md5: base64String
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
*
|
|
426
|
+
* @param property
|
|
427
|
+
* @param hash
|
|
428
|
+
* @returns
|
|
429
|
+
*/
|
|
430
|
+
checkBinaryAlreadyLinked(property, hash) {
|
|
431
|
+
if (Array.isArray(property)) {
|
|
432
|
+
return property.find(f => f.hash === hash) !== undefined;
|
|
433
|
+
}
|
|
434
|
+
return property && property.hash === hash;
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Set the binary content
|
|
438
|
+
* @param context
|
|
439
|
+
*/
|
|
440
|
+
async binaryPut(context) {
|
|
441
|
+
const { model, binaryStore, binary } = context.getExtension("operationContext");
|
|
442
|
+
// First verify if map exist
|
|
443
|
+
const object = await model.ref(context.parameter("uuid")).get();
|
|
444
|
+
if (object === undefined || object.isDeleted()) {
|
|
445
|
+
throw new WebdaError.NotFound("Object does not exist");
|
|
446
|
+
}
|
|
447
|
+
const file = await binaryStore.getFile(context);
|
|
448
|
+
const { hash } = await file.getHashes();
|
|
449
|
+
if (this.checkBinaryAlreadyLinked(object[binary.attribute], hash)) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
await object.checkAct(context, "attach_binary");
|
|
453
|
+
await binaryStore.store(object, binary.attribute, file);
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Get the binary content
|
|
457
|
+
* @param context
|
|
458
|
+
*/
|
|
459
|
+
async binaryGet(context) {
|
|
460
|
+
const { model, returnUrl, binaryStore, binary } = context.getExtension("operationContext");
|
|
461
|
+
const { index, uuid } = context.getParameters();
|
|
462
|
+
// First verify if map exist
|
|
463
|
+
const object = await model.ref(uuid).get();
|
|
464
|
+
if (object === undefined || object.isDeleted()) {
|
|
465
|
+
throw new WebdaError.NotFound("Object does not exist");
|
|
466
|
+
}
|
|
467
|
+
const property = binary.attribute;
|
|
468
|
+
if (!object || (Array.isArray(object[property]) && object[property].length <= index)) {
|
|
469
|
+
throw new WebdaError.NotFound("Object does not exist or attachment does not exist");
|
|
470
|
+
}
|
|
471
|
+
await object.checkAct(context, "get_binary");
|
|
472
|
+
const file = Array.isArray(object[property]) ? object[property][index] : object[property];
|
|
473
|
+
const url = await binaryStore.getRedirectUrlFromObject(file, context);
|
|
474
|
+
// No url, we return the file
|
|
475
|
+
if (url === null) {
|
|
476
|
+
if (returnUrl) {
|
|
477
|
+
// Redirect to same url without /url
|
|
478
|
+
context.write({
|
|
479
|
+
Location: context
|
|
480
|
+
.getHttpContext()
|
|
481
|
+
.getAbsoluteUrl()
|
|
482
|
+
.replace(/\/url$/, ""),
|
|
483
|
+
Map: file
|
|
576
484
|
});
|
|
577
485
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
.
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
}
|
|
591
|
-
};
|
|
486
|
+
else {
|
|
487
|
+
// Output
|
|
488
|
+
context.writeHead(200, {
|
|
489
|
+
"Content-Type": file.mimetype === undefined ? "application/octet-steam" : file.mimetype,
|
|
490
|
+
"Content-Length": file.size
|
|
491
|
+
});
|
|
492
|
+
const readStream = await binaryStore.get(file);
|
|
493
|
+
await new Promise((resolve, reject) => {
|
|
494
|
+
// We replaced all the event handlers with a simple call to readStream.pipe()
|
|
495
|
+
context._stream.on("finish", resolve);
|
|
496
|
+
context._stream.on("error", reject);
|
|
497
|
+
readStream.pipe(context._stream);
|
|
592
498
|
});
|
|
593
499
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
await store.httpChallenge(ctx);
|
|
633
|
-
};
|
|
634
|
-
const modelInjectorGet = async (ctx) => {
|
|
635
|
-
ctx.getParameters().model = model.getIdentifier();
|
|
636
|
-
ctx.getParameters().property = binary.attribute;
|
|
637
|
-
await store.httpGet(ctx);
|
|
638
|
-
};
|
|
639
|
-
openapi = {
|
|
640
|
-
put: {
|
|
641
|
-
tags: [name],
|
|
642
|
-
summary: `Upload ${binary.attribute} of ${name} after challenge`,
|
|
643
|
-
description: `You will need to call the challenge method first to get a signed url to upload the content\nIf the data is already known then done is returned`,
|
|
644
|
-
operationId: `upload${name}${binary.attribute}`,
|
|
645
|
-
requestBody: {
|
|
646
|
-
content: {
|
|
647
|
-
"application/octet-stream": {
|
|
648
|
-
schema: {
|
|
649
|
-
type: "object",
|
|
650
|
-
required: ["hash", "challenge"],
|
|
651
|
-
properties: {
|
|
652
|
-
hash: {
|
|
653
|
-
type: "string",
|
|
654
|
-
description: "md5(data)"
|
|
655
|
-
},
|
|
656
|
-
challenge: {
|
|
657
|
-
type: "string",
|
|
658
|
-
description: "md5('Webda' + data)"
|
|
659
|
-
},
|
|
660
|
-
size: {
|
|
661
|
-
type: "number",
|
|
662
|
-
description: "Size of the data"
|
|
663
|
-
},
|
|
664
|
-
name: {
|
|
665
|
-
type: "string",
|
|
666
|
-
description: "Name of the file"
|
|
667
|
-
},
|
|
668
|
-
mimetype: {
|
|
669
|
-
type: "string",
|
|
670
|
-
description: "Mimetype of the file"
|
|
671
|
-
},
|
|
672
|
-
metadata: {
|
|
673
|
-
type: "object",
|
|
674
|
-
description: "Metadata to add to the binary"
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
responses: {
|
|
682
|
-
"200": {
|
|
683
|
-
description: "Operation success",
|
|
684
|
-
content: {
|
|
685
|
-
"application/octet-stream": {
|
|
686
|
-
schema: {
|
|
687
|
-
type: "object",
|
|
688
|
-
properties: {
|
|
689
|
-
done: {
|
|
690
|
-
type: "boolean"
|
|
691
|
-
},
|
|
692
|
-
url: {
|
|
693
|
-
type: "string"
|
|
694
|
-
},
|
|
695
|
-
method: {
|
|
696
|
-
type: "string"
|
|
697
|
-
},
|
|
698
|
-
md5: {
|
|
699
|
-
type: "string",
|
|
700
|
-
description: "base64 md5 of the data\nThe next request requires Content-MD5 to be added with this one along with Content-Type: 'application/octet-stream'"
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
},
|
|
707
|
-
"403": {
|
|
708
|
-
description: "You don't have permissions"
|
|
709
|
-
},
|
|
710
|
-
"404": {
|
|
711
|
-
description: "Unknown object"
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
};
|
|
716
|
-
this.addRoute(`${prefix}/{uuid}/${binary.attribute}`, ["PUT"], modelInjectorChallenge, openapi);
|
|
717
|
-
openapi = {
|
|
718
|
-
post: {
|
|
719
|
-
tags: [name],
|
|
720
|
-
summary: `Upload ${binary.attribute} of ${name} directly`,
|
|
721
|
-
description: `You can upload the content directly to the server\nThis is not the recommended way as it wont be able to optimize network traffic`,
|
|
722
|
-
operationId: `upload${name}${binary.attribute}`,
|
|
723
|
-
requestBody: {
|
|
724
|
-
content: {
|
|
725
|
-
"application/octet-stream": {
|
|
726
|
-
schema: {
|
|
727
|
-
type: "string",
|
|
728
|
-
format: "binary"
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
}
|
|
732
|
-
},
|
|
733
|
-
responses: {
|
|
734
|
-
"204": {
|
|
735
|
-
description: ""
|
|
736
|
-
},
|
|
737
|
-
"403": {
|
|
738
|
-
description: "You don't have permissions"
|
|
739
|
-
},
|
|
740
|
-
"404": {
|
|
741
|
-
description: "Object does not exist or attachment does not exist"
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
this.addRoute(`${prefix}/{uuid}/${binary.attribute}`, ["POST"], modelInjector, openapi);
|
|
747
|
-
let rootUrl = `${prefix}/{uuid}/${binary.attribute}`;
|
|
748
|
-
if (binary.cardinality === "MANY") {
|
|
749
|
-
rootUrl += "/{index}";
|
|
500
|
+
}
|
|
501
|
+
else if (returnUrl) {
|
|
502
|
+
context.write({ Location: url, Map: file });
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
context.writeHead(302, {
|
|
506
|
+
Location: url
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
async binaryAction(context) {
|
|
511
|
+
const { model, binaryStore, binary, action } = context.getExtension("operationContext");
|
|
512
|
+
const { index, uuid, hash } = context.getParameters();
|
|
513
|
+
// First verify if map exist
|
|
514
|
+
const object = await model.ref(uuid).get();
|
|
515
|
+
if (object === undefined || object.isDeleted()) {
|
|
516
|
+
throw new WebdaError.NotFound("Object does not exist");
|
|
517
|
+
}
|
|
518
|
+
if (action === "create") {
|
|
519
|
+
await object.checkAct(context, "attach_binary");
|
|
520
|
+
await binaryStore.store(object, binary.attribute, await binaryStore.getFile(context));
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
// Current file - would be empty on creation
|
|
524
|
+
const file = Array.isArray(object[binary.attribute]) ? object[binary.attribute][index] : object[binary.attribute];
|
|
525
|
+
if (!file || file?.hash !== hash) {
|
|
526
|
+
throw new WebdaError.BadRequest("Hash does not match");
|
|
527
|
+
}
|
|
528
|
+
if (action === "delete") {
|
|
529
|
+
await object.checkAct(context, "detach_binary");
|
|
530
|
+
await binaryStore.delete(object, binary.attribute, index);
|
|
531
|
+
}
|
|
532
|
+
else if (action === "metadata") {
|
|
533
|
+
await object.checkAct(context, "update_binary_metadata");
|
|
534
|
+
const metadata = await context.getInput();
|
|
535
|
+
// Limit metadata to 4kb
|
|
536
|
+
if (JSON.stringify(metadata).length >= 4096) {
|
|
537
|
+
throw new WebdaError.BadRequest("Metadata is too big: 4kb max");
|
|
750
538
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
}
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
$ref: "#/components/schemas/BinaryMap"
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
}
|
|
861
|
-
},
|
|
862
|
-
"403": {
|
|
863
|
-
description: "You don't have permissions"
|
|
864
|
-
},
|
|
865
|
-
"404": {
|
|
866
|
-
description: "Object does not exist or attachment does not exist"
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
}
|
|
870
|
-
};
|
|
871
|
-
this.addRoute(`${rootUrl}/url`, ["GET"], modelInjectorGet, openapi);
|
|
872
|
-
});
|
|
873
|
-
return true;
|
|
539
|
+
file.metadata = metadata;
|
|
540
|
+
await object.patch({
|
|
541
|
+
[binary.attribute]: object[binary.attribute]
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
DomainService.schemas = {
|
|
547
|
+
uuidRequest: {
|
|
548
|
+
type: "object",
|
|
549
|
+
properties: {
|
|
550
|
+
uuid: {
|
|
551
|
+
type: "string"
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
required: ["uuid"]
|
|
555
|
+
},
|
|
556
|
+
binaryGetRequest: {
|
|
557
|
+
type: "object",
|
|
558
|
+
properties: {
|
|
559
|
+
uuid: {
|
|
560
|
+
type: "string"
|
|
561
|
+
},
|
|
562
|
+
index: {
|
|
563
|
+
type: "number"
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
required: ["uuid", "index"]
|
|
567
|
+
},
|
|
568
|
+
binaryHashRequest: {
|
|
569
|
+
type: "object",
|
|
570
|
+
properties: {
|
|
571
|
+
uuid: {
|
|
572
|
+
type: "string"
|
|
573
|
+
},
|
|
574
|
+
hash: {
|
|
575
|
+
type: "string"
|
|
576
|
+
}
|
|
577
|
+
},
|
|
578
|
+
required: ["uuid", "hash"]
|
|
579
|
+
},
|
|
580
|
+
binaryIndexHashRequest: {
|
|
581
|
+
type: "object",
|
|
582
|
+
properties: {
|
|
583
|
+
uuid: {
|
|
584
|
+
type: "string"
|
|
585
|
+
},
|
|
586
|
+
index: {
|
|
587
|
+
type: "number"
|
|
588
|
+
},
|
|
589
|
+
hash: {
|
|
590
|
+
type: "string"
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
required: ["uuid", "index", "hash"]
|
|
594
|
+
},
|
|
595
|
+
binaryAttachParameters: {
|
|
596
|
+
type: "object",
|
|
597
|
+
properties: {
|
|
598
|
+
filename: {
|
|
599
|
+
type: "string"
|
|
600
|
+
},
|
|
601
|
+
size: {
|
|
602
|
+
type: "number"
|
|
603
|
+
},
|
|
604
|
+
mimetype: {
|
|
605
|
+
type: "string"
|
|
606
|
+
},
|
|
607
|
+
uuid: {
|
|
608
|
+
type: "string"
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
required: ["uuid"]
|
|
612
|
+
},
|
|
613
|
+
binaryChallengeRequest: {
|
|
614
|
+
type: "object",
|
|
615
|
+
properties: {
|
|
616
|
+
hash: {
|
|
617
|
+
type: "string"
|
|
618
|
+
},
|
|
619
|
+
challenge: {
|
|
620
|
+
type: "string"
|
|
621
|
+
}
|
|
622
|
+
},
|
|
623
|
+
required: ["hash", "challenge"]
|
|
624
|
+
},
|
|
625
|
+
searchRequest: {
|
|
626
|
+
type: "object",
|
|
627
|
+
properties: {
|
|
628
|
+
query: {
|
|
629
|
+
type: "string"
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
/**
|
|
635
|
+
* @WebdaModda
|
|
636
|
+
*/
|
|
637
|
+
export class ModelsOperationsService extends DomainService {
|
|
638
|
+
/**
|
|
639
|
+
* Default domain
|
|
640
|
+
*/
|
|
641
|
+
loadParameters(params) {
|
|
642
|
+
return new DomainServiceParameters(params);
|
|
874
643
|
}
|
|
875
644
|
/**
|
|
876
|
-
*
|
|
877
|
-
* @param ctx
|
|
645
|
+
* Do nothing here
|
|
878
646
|
*/
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
ctx.write(this.openapiContent);
|
|
647
|
+
handleModel(model, name, context) {
|
|
648
|
+
return true;
|
|
882
649
|
}
|
|
883
650
|
}
|
|
884
651
|
//# sourceMappingURL=domainservice.js.map
|