@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/stores/store.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
1
|
import { Counter, Histogram } from "../core.js";
|
|
8
2
|
import { MemoryStore, ModelMapLoaderImplementation, Throttler, WebdaError } from "../index.js";
|
|
9
3
|
import { CoreModel } from "../models/coremodel.js";
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
4
|
+
import { Service, ServiceParameters } from "../services/service.js";
|
|
5
|
+
import * as WebdaQL from "@webda/ql";
|
|
12
6
|
export class StoreNotFoundError extends WebdaError.CodeError {
|
|
13
7
|
constructor(uuid, storeName) {
|
|
14
8
|
super("STORE_NOTFOUND", `Item not found ${uuid} Store(${storeName})`);
|
|
@@ -24,47 +18,23 @@ export class UpdateConditionFailError extends WebdaError.CodeError {
|
|
|
24
18
|
*/
|
|
25
19
|
export class StoreParameters extends ServiceParameters {
|
|
26
20
|
constructor(params, service) {
|
|
27
|
-
var _a;
|
|
28
21
|
super(params);
|
|
29
22
|
this.model ?? (this.model = "Webda/CoreModel");
|
|
30
|
-
let expose = params.expose;
|
|
31
|
-
if (typeof expose == "boolean") {
|
|
32
|
-
expose = {};
|
|
33
|
-
expose.url = "/" + service.getName().toLowerCase();
|
|
34
|
-
}
|
|
35
|
-
else if (typeof expose == "string") {
|
|
36
|
-
expose = {
|
|
37
|
-
url: expose
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
else if (typeof expose == "object" && expose.url == undefined) {
|
|
41
|
-
expose.url = "/" + service.getName().toLowerCase();
|
|
42
|
-
}
|
|
43
|
-
if (expose) {
|
|
44
|
-
expose.restrict = expose.restrict || {};
|
|
45
|
-
this.expose = expose;
|
|
46
|
-
(_a = this.expose).queryMethod ?? (_a.queryMethod = "GET");
|
|
47
|
-
this.url = expose.url;
|
|
48
|
-
}
|
|
49
|
-
if (params.map) {
|
|
50
|
-
throw new Error("Deprecated map usage, use a MapperService");
|
|
51
|
-
}
|
|
52
|
-
if (params.index) {
|
|
53
|
-
throw new Error("Deprecated index usage, use an AggregatorService");
|
|
54
|
-
}
|
|
55
23
|
this.strict ?? (this.strict = false);
|
|
56
24
|
this.defaultModel ?? (this.defaultModel = true);
|
|
57
25
|
this.forceModel ?? (this.forceModel = false);
|
|
58
26
|
this.slowQueryThreshold ?? (this.slowQueryThreshold = 30000);
|
|
59
27
|
this.modelAliases ?? (this.modelAliases = {});
|
|
60
28
|
this.additionalModels ?? (this.additionalModels = []);
|
|
29
|
+
// REFACTOR >= 5
|
|
30
|
+
if (params.expose) {
|
|
31
|
+
throw new Error("Expose is not supported anymore, use DomainService instead");
|
|
32
|
+
}
|
|
33
|
+
// END_REFACTOR
|
|
61
34
|
}
|
|
62
35
|
}
|
|
63
36
|
/**
|
|
64
37
|
* This class handle NoSQL storage and mapping (duplication) between NoSQL object
|
|
65
|
-
* TODO Create the mapping documentation
|
|
66
|
-
*
|
|
67
|
-
* It use basic CRUD, and can expose those 4 to through HTTP
|
|
68
38
|
*
|
|
69
39
|
* It emits events :
|
|
70
40
|
* Store.Save: Before saving the object
|
|
@@ -77,21 +47,6 @@ export class StoreParameters extends ServiceParameters {
|
|
|
77
47
|
* Store.Action: When an action will be done on an object
|
|
78
48
|
* Store.Actioned: When an action has been done on an object
|
|
79
49
|
*
|
|
80
|
-
* Mapping:
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* Parameters
|
|
84
|
-
*
|
|
85
|
-
* map: { ... }
|
|
86
|
-
* expose: { // Enable the HTTP exposure
|
|
87
|
-
* url: '', // The url to expose to by default it is service name in lowercase ( users for example )
|
|
88
|
-
* restrict: {
|
|
89
|
-
* create: true, // Don't expose the POST /users
|
|
90
|
-
* update: true, // Don't expose the PUT /users/{uuid}
|
|
91
|
-
* delete: true, // Don't expose the DELETE /users/{uuid}
|
|
92
|
-
* get: true // Don't expose the GET /users/{uuid}
|
|
93
|
-
* }
|
|
94
|
-
* }
|
|
95
50
|
* @category CoreServices
|
|
96
51
|
*/
|
|
97
52
|
class Store extends Service {
|
|
@@ -132,7 +87,7 @@ class Store extends Service {
|
|
|
132
87
|
}
|
|
133
88
|
const recursive = (tree, depth) => {
|
|
134
89
|
var _a;
|
|
135
|
-
for (
|
|
90
|
+
for (const i in tree) {
|
|
136
91
|
(_a = this._modelsHierarchy)[i] ?? (_a[i] = depth);
|
|
137
92
|
this._modelsHierarchy[i] = Math.min(depth, this._modelsHierarchy[i]);
|
|
138
93
|
this._modelsHierarchy[app.completeNamespace(i)] = this._modelsHierarchy[i];
|
|
@@ -153,7 +108,7 @@ class Store extends Service {
|
|
|
153
108
|
this.log("ERROR", "Cannot add additional models in strict mode");
|
|
154
109
|
}
|
|
155
110
|
else {
|
|
156
|
-
for (
|
|
111
|
+
for (const modelType of this.parameters.additionalModels) {
|
|
157
112
|
const model = app.getModel(modelType);
|
|
158
113
|
this._modelsHierarchy[model.getIdentifier(false)] = 0;
|
|
159
114
|
this._modelsHierarchy[model.getIdentifier()] = 0;
|
|
@@ -161,9 +116,6 @@ class Store extends Service {
|
|
|
161
116
|
}
|
|
162
117
|
}
|
|
163
118
|
}
|
|
164
|
-
if (this.getParameters().expose) {
|
|
165
|
-
this.log("WARN", "Exposing a store is not recommended, use a DomainService instead to expose all your CoreModel");
|
|
166
|
-
}
|
|
167
119
|
}
|
|
168
120
|
logSlowQuery(_query, _reason, _time) {
|
|
169
121
|
// TODO Need to implement: https://github.com/loopingz/webda.io/issues/202
|
|
@@ -175,7 +127,7 @@ class Store extends Service {
|
|
|
175
127
|
async invalidateCache(uid) {
|
|
176
128
|
if (this._cacheStore) {
|
|
177
129
|
this.metrics.cache_invalidations.inc();
|
|
178
|
-
await this._cacheStore.delete(uid
|
|
130
|
+
await this._cacheStore.delete(uid);
|
|
179
131
|
}
|
|
180
132
|
}
|
|
181
133
|
/**
|
|
@@ -251,125 +203,7 @@ class Store extends Service {
|
|
|
251
203
|
this.metrics.operations_total.inc({ operation: "get" });
|
|
252
204
|
return this._getFromCache(uid);
|
|
253
205
|
}
|
|
254
|
-
/**
|
|
255
|
-
* @override
|
|
256
|
-
*/
|
|
257
|
-
getUrl(url, methods) {
|
|
258
|
-
// If url is absolute
|
|
259
|
-
if (url.startsWith("/")) {
|
|
260
|
-
return url;
|
|
261
|
-
}
|
|
262
|
-
// Parent url to find here
|
|
263
|
-
const expose = this.parameters.expose;
|
|
264
|
-
if (!expose.url ||
|
|
265
|
-
(url === "." && methods.includes("POST") && expose.restrict.create) ||
|
|
266
|
-
(url === "./{uuid}" && methods.includes("DELETE") && expose.restrict.delete) ||
|
|
267
|
-
(url === "./{uuid}" && methods.includes("PATCH") && expose.restrict.update) ||
|
|
268
|
-
(url === "./{uuid}" && methods.includes("PUT") && expose.restrict.update) ||
|
|
269
|
-
(url === "./{uuid}" && methods.includes("GET") && expose.restrict.get) ||
|
|
270
|
-
(url === ".{?q}" && methods.includes("GET") && expose.restrict.query) ||
|
|
271
|
-
(url === "." && methods.includes("PUT") && expose.restrict.query)) {
|
|
272
|
-
return undefined;
|
|
273
|
-
}
|
|
274
|
-
return super.getUrl(url, methods);
|
|
275
|
-
}
|
|
276
206
|
static getOpenAPI() { }
|
|
277
|
-
/**
|
|
278
|
-
* @inheritdoc
|
|
279
|
-
*/
|
|
280
|
-
initRoutes() {
|
|
281
|
-
if (!this.parameters.expose) {
|
|
282
|
-
return;
|
|
283
|
-
}
|
|
284
|
-
super.initRoutes();
|
|
285
|
-
// We enforce ExposeParameters within the constructor
|
|
286
|
-
const expose = this.parameters.expose;
|
|
287
|
-
this.getWebda().getRouter().registerModelUrl(this.parameters.model, expose.url);
|
|
288
|
-
// Query endpoint
|
|
289
|
-
if (!expose.restrict.query) {
|
|
290
|
-
let requestBody;
|
|
291
|
-
if (expose.queryMethod === "PUT") {
|
|
292
|
-
requestBody = {
|
|
293
|
-
content: {
|
|
294
|
-
"application/json": {
|
|
295
|
-
schema: {
|
|
296
|
-
properties: {
|
|
297
|
-
q: {
|
|
298
|
-
type: "string"
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
this.addRoute(expose.queryMethod === "GET" ? `.{?q}` : ".", [expose.queryMethod], this.httpQuery, {
|
|
307
|
-
model: this.parameters.model,
|
|
308
|
-
[expose.queryMethod.toLowerCase()]: {
|
|
309
|
-
description: `Query on ${this.parameters.model} model with WebdaQL`,
|
|
310
|
-
summary: "Query " + this.parameters.model,
|
|
311
|
-
operationId: `query${this._model.name}`,
|
|
312
|
-
requestBody,
|
|
313
|
-
responses: {
|
|
314
|
-
"200": {
|
|
315
|
-
description: `Retrieve models ${this._model.name}`,
|
|
316
|
-
content: {
|
|
317
|
-
"application/json": {
|
|
318
|
-
schema: {
|
|
319
|
-
properties: {
|
|
320
|
-
continuationToken: {
|
|
321
|
-
type: "string"
|
|
322
|
-
},
|
|
323
|
-
results: {
|
|
324
|
-
type: "array",
|
|
325
|
-
items: {
|
|
326
|
-
$ref: `#/components/schemas/${this._model.name}`
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
"400": {
|
|
335
|
-
description: "Query is invalid"
|
|
336
|
-
},
|
|
337
|
-
"403": {
|
|
338
|
-
description: "You don't have permissions"
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
// Model actions
|
|
345
|
-
if (this._model && this._model.getActions) {
|
|
346
|
-
let actions = this._model.getActions();
|
|
347
|
-
Object.keys(actions).forEach(name => {
|
|
348
|
-
let action = actions[name];
|
|
349
|
-
action.method ?? (action.method = name);
|
|
350
|
-
if (!action.methods) {
|
|
351
|
-
action.methods = ["PUT"];
|
|
352
|
-
}
|
|
353
|
-
let executer;
|
|
354
|
-
if (action.global) {
|
|
355
|
-
// By default will grab the object and then call the action
|
|
356
|
-
if (!this._model[action.method]) {
|
|
357
|
-
throw Error("Action static method " + action.method + " does not exist");
|
|
358
|
-
}
|
|
359
|
-
executer = this.httpGlobalAction;
|
|
360
|
-
this.addRoute(`./${name}`, action.methods, executer, action.openapi);
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
// By default will grab the object and then call the action
|
|
364
|
-
if (!this._model.prototype[action.method]) {
|
|
365
|
-
throw Error("Action method " + action.method + " does not exist");
|
|
366
|
-
}
|
|
367
|
-
executer = ctx => this.httpAction(ctx, action.method);
|
|
368
|
-
this.addRoute(`./{uuid}/${name}`, action.methods, executer, action.openapi);
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
207
|
/**
|
|
374
208
|
* OVerwrite the model
|
|
375
209
|
* Used mainly in test
|
|
@@ -392,7 +226,7 @@ class Store extends Service {
|
|
|
392
226
|
});
|
|
393
227
|
};
|
|
394
228
|
};
|
|
395
|
-
for (
|
|
229
|
+
for (const i of [
|
|
396
230
|
"_get",
|
|
397
231
|
"_patch",
|
|
398
232
|
"_update",
|
|
@@ -441,9 +275,9 @@ class Store extends Service {
|
|
|
441
275
|
object.setUuid(object.generateUid(object));
|
|
442
276
|
}
|
|
443
277
|
object.__store = this;
|
|
444
|
-
for (
|
|
278
|
+
for (const i in this._reverseMap) {
|
|
445
279
|
object[_a = this._reverseMap[i].property] ?? (object[_a] = []);
|
|
446
|
-
for (
|
|
280
|
+
for (const j in object[this._reverseMap[i].property]) {
|
|
447
281
|
if (object[this._reverseMap[i].property][j] instanceof ModelMapLoaderImplementation) {
|
|
448
282
|
continue;
|
|
449
283
|
}
|
|
@@ -460,7 +294,7 @@ class Store extends Service {
|
|
|
460
294
|
* @returns
|
|
461
295
|
*/
|
|
462
296
|
newModel(object = {}) {
|
|
463
|
-
|
|
297
|
+
const result = this.initModel(object);
|
|
464
298
|
Object.keys(object).forEach(k => result.__dirty.add(k));
|
|
465
299
|
return result;
|
|
466
300
|
}
|
|
@@ -485,12 +319,12 @@ class Store extends Service {
|
|
|
485
319
|
* @returns
|
|
486
320
|
*/
|
|
487
321
|
async incrementAttributes(uid, info) {
|
|
488
|
-
|
|
322
|
+
const params = info.filter(i => i.value !== 0);
|
|
489
323
|
// If value === 0 no need to update anything
|
|
490
324
|
if (params.length === 0) {
|
|
491
325
|
return;
|
|
492
326
|
}
|
|
493
|
-
|
|
327
|
+
const updateDate = new Date();
|
|
494
328
|
this.metrics.operations_total.inc({ operation: "increment" });
|
|
495
329
|
await this._incrementAttributes(uid, params, updateDate);
|
|
496
330
|
const evt = {
|
|
@@ -525,7 +359,7 @@ class Store extends Service {
|
|
|
525
359
|
* @param itemWriteConditionField field to read the condition from (in case of update)
|
|
526
360
|
*/
|
|
527
361
|
async upsertItemToCollection(uid, prop, item, index = undefined, itemWriteCondition = undefined, itemWriteConditionField = this._uuidField) {
|
|
528
|
-
|
|
362
|
+
const updateDate = new Date();
|
|
529
363
|
this.metrics.operations_total.inc({ operation: "collectionUpsert" });
|
|
530
364
|
await this._upsertItemToCollection(uid, prop, item, index, itemWriteCondition, itemWriteConditionField, updateDate);
|
|
531
365
|
await this.emitStoreEvent("Store.PartialUpdated", {
|
|
@@ -552,7 +386,7 @@ class Store extends Service {
|
|
|
552
386
|
* @param itemWriteConditionField field to read the condition from
|
|
553
387
|
*/
|
|
554
388
|
async deleteItemFromCollection(uid, prop, index, itemWriteCondition, itemWriteConditionField = this._uuidField) {
|
|
555
|
-
|
|
389
|
+
const updateDate = new Date();
|
|
556
390
|
this.metrics.operations_total.inc({ operation: "collectionDelete" });
|
|
557
391
|
await this._deleteItemFromCollection(uid, prop, index, itemWriteCondition, itemWriteConditionField, updateDate);
|
|
558
392
|
await this.emitStoreEvent("Store.PartialUpdated", {
|
|
@@ -582,9 +416,9 @@ class Store extends Service {
|
|
|
582
416
|
}
|
|
583
417
|
let continuationToken;
|
|
584
418
|
do {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
for (
|
|
419
|
+
const q = query + (continuationToken !== undefined ? ` OFFSET "${continuationToken}"` : "");
|
|
420
|
+
const page = await this.query(q, context);
|
|
421
|
+
for (const item of page.results) {
|
|
588
422
|
yield item;
|
|
589
423
|
}
|
|
590
424
|
continuationToken = page.continuationToken;
|
|
@@ -601,8 +435,8 @@ class Store extends Service {
|
|
|
601
435
|
* @deprecated use iterate instead
|
|
602
436
|
*/
|
|
603
437
|
async queryAll(query, context) {
|
|
604
|
-
|
|
605
|
-
for await (
|
|
438
|
+
const res = [];
|
|
439
|
+
for await (const item of this.iterate(query, context)) {
|
|
606
440
|
res.push(item);
|
|
607
441
|
}
|
|
608
442
|
return res;
|
|
@@ -622,15 +456,15 @@ class Store extends Service {
|
|
|
622
456
|
* @param context to apply permission
|
|
623
457
|
*/
|
|
624
458
|
async query(query, context) {
|
|
625
|
-
|
|
459
|
+
const permissionQuery = this._model.getPermissionQuery(context);
|
|
626
460
|
let partialPermission = true;
|
|
627
461
|
let fullQuery = query;
|
|
628
462
|
if (permissionQuery) {
|
|
629
463
|
partialPermission = permissionQuery.partial;
|
|
630
464
|
fullQuery = WebdaQL.PrependCondition(query, permissionQuery.query);
|
|
631
465
|
}
|
|
632
|
-
|
|
633
|
-
|
|
466
|
+
const queryValidator = new WebdaQL.QueryValidator(fullQuery);
|
|
467
|
+
const offset = queryValidator.getOffset();
|
|
634
468
|
const limit = queryValidator.getLimit();
|
|
635
469
|
const parsedQuery = this.queryTypeUpdater(queryValidator.getQuery());
|
|
636
470
|
parsedQuery.limit = limit;
|
|
@@ -656,12 +490,13 @@ class Store extends Service {
|
|
|
656
490
|
by database does not endup being our final page cut, so we need a page offset to
|
|
657
491
|
abstract this completely
|
|
658
492
|
*/
|
|
493
|
+
// eslint-disable-next-line prefer-const
|
|
659
494
|
let [mainOffset, subOffset] = offset.split("_");
|
|
660
495
|
let secondOffset = parseInt(subOffset || "0");
|
|
661
496
|
let duration = Date.now();
|
|
662
497
|
this.metrics.operations_total.inc({ operation: "query" });
|
|
663
498
|
while (result.results.length < limit) {
|
|
664
|
-
|
|
499
|
+
const tmpResults = await this.find({
|
|
665
500
|
...parsedQuery,
|
|
666
501
|
continuationToken: mainOffset
|
|
667
502
|
});
|
|
@@ -671,7 +506,7 @@ class Store extends Service {
|
|
|
671
506
|
this.log("WARN", `Store '${this.getName()}' postquery full filtering`);
|
|
672
507
|
}
|
|
673
508
|
let subOffsetCount = 0;
|
|
674
|
-
for (
|
|
509
|
+
for (const item of tmpResults.results) {
|
|
675
510
|
item.setContext(context);
|
|
676
511
|
// Because of dynamic filter and permission we need to suboffset the pagination
|
|
677
512
|
subOffsetCount++;
|
|
@@ -719,28 +554,6 @@ class Store extends Service {
|
|
|
719
554
|
});
|
|
720
555
|
return result;
|
|
721
556
|
}
|
|
722
|
-
/**
|
|
723
|
-
* Expose query to http
|
|
724
|
-
*/
|
|
725
|
-
async httpQuery(ctx) {
|
|
726
|
-
let query;
|
|
727
|
-
if (ctx.getHttpContext().getMethod() === "GET") {
|
|
728
|
-
query = ctx.getParameters().q;
|
|
729
|
-
}
|
|
730
|
-
else {
|
|
731
|
-
query = WebdaQL.unsanitize((await ctx.getRequestBody()).q);
|
|
732
|
-
}
|
|
733
|
-
try {
|
|
734
|
-
ctx.write(await this.query(query, ctx));
|
|
735
|
-
}
|
|
736
|
-
catch (err) {
|
|
737
|
-
if (err instanceof SyntaxError) {
|
|
738
|
-
this.log("INFO", "Query syntax error");
|
|
739
|
-
throw new WebdaError.BadRequest("Query syntax error");
|
|
740
|
-
}
|
|
741
|
-
throw err;
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
557
|
/**
|
|
745
558
|
* Handle StoreEvent and update cache based on it
|
|
746
559
|
* Then emit the event, it allows the cache to be updated
|
|
@@ -833,7 +646,7 @@ class Store extends Service {
|
|
|
833
646
|
object._onSave()
|
|
834
647
|
]);
|
|
835
648
|
this.metrics.operations_total.inc({ operation: "save" });
|
|
836
|
-
|
|
649
|
+
const res = await this._save(object);
|
|
837
650
|
await this._cacheStore?._save(object);
|
|
838
651
|
object = this.initModel(res);
|
|
839
652
|
const evtSaved = {
|
|
@@ -959,12 +772,9 @@ class Store extends Service {
|
|
|
959
772
|
* @return {Promise} with saved object
|
|
960
773
|
*/
|
|
961
774
|
async update(object, reverseMap = true, partial = false, conditionField, conditionValue) {
|
|
962
|
-
/** @ignore */
|
|
963
|
-
let saved;
|
|
964
|
-
let loaded;
|
|
965
775
|
// Dont allow to update collections from map
|
|
966
776
|
if (this._reverseMap != undefined && reverseMap) {
|
|
967
|
-
for (
|
|
777
|
+
for (const i in this._reverseMap) {
|
|
968
778
|
if (object[this._reverseMap[i].property] != undefined) {
|
|
969
779
|
delete object[this._reverseMap[i].property];
|
|
970
780
|
}
|
|
@@ -976,12 +786,12 @@ class Store extends Service {
|
|
|
976
786
|
object._lastUpdate = new Date();
|
|
977
787
|
this.metrics.operations_total.inc({ operation: "get" });
|
|
978
788
|
const uuid = object.getUuid ? object.getUuid() : object[this._uuidField];
|
|
979
|
-
|
|
789
|
+
const load = await this._getFromCache(uuid, true);
|
|
980
790
|
if (load.__type !== this._modelType && this.parameters.strict) {
|
|
981
791
|
this.log("WARN", `Object '${uuid}' was not created by this store ${load.__type}:${this._modelType}`);
|
|
982
792
|
throw new StoreNotFoundError(uuid, this.getName());
|
|
983
793
|
}
|
|
984
|
-
loaded = this.initModel(load);
|
|
794
|
+
const loaded = this.initModel(load);
|
|
985
795
|
if (object instanceof CoreModel) {
|
|
986
796
|
loaded.setContext(object.getContext());
|
|
987
797
|
}
|
|
@@ -1009,7 +819,7 @@ class Store extends Service {
|
|
|
1009
819
|
}
|
|
1010
820
|
else {
|
|
1011
821
|
// Copy back the mappers
|
|
1012
|
-
for (
|
|
822
|
+
for (const i in this._reverseMap) {
|
|
1013
823
|
object[this._reverseMap[i].property] = loaded[this._reverseMap[i].property];
|
|
1014
824
|
}
|
|
1015
825
|
object = this.initModel(object);
|
|
@@ -1017,7 +827,7 @@ class Store extends Service {
|
|
|
1017
827
|
res = await this._update(object, uuid, conditionValue, conditionField);
|
|
1018
828
|
}
|
|
1019
829
|
// Reinit save
|
|
1020
|
-
saved = this.initModel({
|
|
830
|
+
const saved = this.initModel({
|
|
1021
831
|
...loaded,
|
|
1022
832
|
...res
|
|
1023
833
|
});
|
|
@@ -1035,16 +845,6 @@ class Store extends Service {
|
|
|
1035
845
|
]);
|
|
1036
846
|
return saved;
|
|
1037
847
|
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Manage the store migration for __type case sensitivity
|
|
1040
|
-
*/
|
|
1041
|
-
async v3Migration() {
|
|
1042
|
-
// Compute case for all object
|
|
1043
|
-
await this.recomputeTypeCase();
|
|
1044
|
-
// Compute all __types
|
|
1045
|
-
await this.recomputeTypes();
|
|
1046
|
-
// We do not move to short id as it is not compatible with v2
|
|
1047
|
-
}
|
|
1048
848
|
/**
|
|
1049
849
|
*
|
|
1050
850
|
*/
|
|
@@ -1084,29 +884,6 @@ class Store extends Service {
|
|
|
1084
884
|
}
|
|
1085
885
|
});
|
|
1086
886
|
}
|
|
1087
|
-
/**
|
|
1088
|
-
* Recompute type case
|
|
1089
|
-
*/
|
|
1090
|
-
async recomputeTypeCase() {
|
|
1091
|
-
this.log("INFO", "Ensuring __type is case sensitive from migration from v2.x");
|
|
1092
|
-
const app = this.getWebda().getApplication();
|
|
1093
|
-
// We need to be laxist for migration
|
|
1094
|
-
this.parameters.strict = false;
|
|
1095
|
-
await this.migration("typesCase", async (item) => {
|
|
1096
|
-
if (item.__type !== undefined) {
|
|
1097
|
-
if (!app.hasWebdaObject("models", item.__type, true) && app.hasWebdaObject("models", item.__type, false)) {
|
|
1098
|
-
const model = app.getWebdaObject("models", item.__type, false);
|
|
1099
|
-
const name = app.getModelName(model);
|
|
1100
|
-
if (model) {
|
|
1101
|
-
this.log("INFO", "Migrating type " + item.__type + " to " + name);
|
|
1102
|
-
return {
|
|
1103
|
-
__type: name
|
|
1104
|
-
};
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
});
|
|
1109
|
-
}
|
|
1110
887
|
/**
|
|
1111
888
|
* Recompute the __types for all objects (storeMigration.Registry.typesCompute)
|
|
1112
889
|
*/
|
|
@@ -1114,7 +891,7 @@ class Store extends Service {
|
|
|
1114
891
|
this.log("INFO", "Ensuring __types is correct from migration from v2.x");
|
|
1115
892
|
// Update __types for each __type will be more efficient
|
|
1116
893
|
await this.migration("typesCompute", async (item) => {
|
|
1117
|
-
|
|
894
|
+
const __types = this.getWebda().getApplication().getModelTypes(item);
|
|
1118
895
|
if (!item.__types ||
|
|
1119
896
|
item.__types.length !== __types.length ||
|
|
1120
897
|
!__types.every((element, index) => element === item.__types[index])) {
|
|
@@ -1145,15 +922,15 @@ class Store extends Service {
|
|
|
1145
922
|
* @param patcher
|
|
1146
923
|
*/
|
|
1147
924
|
async migration(name, patcher, batchSize = 500) {
|
|
1148
|
-
|
|
925
|
+
const status = await this.getWebda().getRegistry().get(`storeMigration.${this.getName()}.${name}`, undefined, {});
|
|
1149
926
|
status.count ?? (status.count = 0);
|
|
1150
927
|
status.updated ?? (status.updated = 0);
|
|
1151
928
|
const worker = new Throttler(20);
|
|
1152
929
|
do {
|
|
1153
930
|
const res = await this.query(status.continuationToken ? `LIMIT ${batchSize} OFFSET "${status.continuationToken}"` : `LIMIT ${batchSize}`);
|
|
1154
931
|
status.count += res.results.length;
|
|
1155
|
-
for (
|
|
1156
|
-
|
|
932
|
+
for (const item of res.results) {
|
|
933
|
+
const updated = await patcher(item);
|
|
1157
934
|
if (updated !== undefined) {
|
|
1158
935
|
status.updated++;
|
|
1159
936
|
if (typeof updated === "function") {
|
|
@@ -1201,22 +978,13 @@ class Store extends Service {
|
|
|
1201
978
|
// We dont need uuid but Binary store will need it
|
|
1202
979
|
return this.delete(obj.getUuid());
|
|
1203
980
|
}
|
|
1204
|
-
/**
|
|
1205
|
-
* Delete an object from the store without condition nor async
|
|
1206
|
-
* @param uid to delete
|
|
1207
|
-
* @returns
|
|
1208
|
-
*/
|
|
1209
|
-
async forceDelete(uid) {
|
|
1210
|
-
return this.delete(uid, undefined, undefined, true);
|
|
1211
|
-
}
|
|
1212
981
|
/**
|
|
1213
982
|
* Delete an object
|
|
1214
983
|
*
|
|
1215
984
|
* @param {String} uuid to delete
|
|
1216
|
-
* @param {Boolean} delete sync even if asyncDelete is active
|
|
1217
985
|
* @return {Promise} the deletion promise
|
|
1218
986
|
*/
|
|
1219
|
-
async delete(uid, writeCondition, writeConditionField
|
|
987
|
+
async delete(uid, writeCondition, writeConditionField) {
|
|
1220
988
|
/** @ignore */
|
|
1221
989
|
let to_delete;
|
|
1222
990
|
// Allow full object or just its uuid
|
|
@@ -1252,22 +1020,10 @@ class Store extends Service {
|
|
|
1252
1020
|
to_delete?.__class.emitSync("Store.Delete", evt),
|
|
1253
1021
|
to_delete._onDelete()
|
|
1254
1022
|
]);
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
__deleted: true
|
|
1260
|
-
}, to_delete.getUuid());
|
|
1261
|
-
await this._cacheStore?._patch({
|
|
1262
|
-
__deleted: true
|
|
1263
|
-
}, to_delete.getUuid());
|
|
1264
|
-
}
|
|
1265
|
-
else {
|
|
1266
|
-
this.metrics.operations_total.inc({ operation: "delete" });
|
|
1267
|
-
// Delete from the DB for real
|
|
1268
|
-
await this._delete(to_delete.getUuid(), writeCondition, writeConditionField);
|
|
1269
|
-
await this._cacheStore?._delete(to_delete.getUuid(), writeCondition, writeConditionField);
|
|
1270
|
-
}
|
|
1023
|
+
this.metrics.operations_total.inc({ operation: "delete" });
|
|
1024
|
+
// Delete from the DB for real
|
|
1025
|
+
await this._delete(to_delete.getUuid(), writeCondition, writeConditionField);
|
|
1026
|
+
await this._cacheStore?._delete(to_delete.getUuid(), writeCondition, writeConditionField);
|
|
1271
1027
|
// Send post event
|
|
1272
1028
|
const evtDeleted = {
|
|
1273
1029
|
object: to_delete,
|
|
@@ -1296,12 +1052,12 @@ class Store extends Service {
|
|
|
1296
1052
|
*/
|
|
1297
1053
|
async getConfiguration(id) {
|
|
1298
1054
|
this.metrics.operations_total.inc({ operation: "get" });
|
|
1299
|
-
|
|
1055
|
+
const object = await this._getFromCache(id);
|
|
1300
1056
|
if (!object) {
|
|
1301
1057
|
return undefined;
|
|
1302
1058
|
}
|
|
1303
|
-
|
|
1304
|
-
for (
|
|
1059
|
+
const result = {};
|
|
1060
|
+
for (const i in object) {
|
|
1305
1061
|
if (i === this._uuidField || i === "_lastUpdate" || i.startsWith("_")) {
|
|
1306
1062
|
continue;
|
|
1307
1063
|
}
|
|
@@ -1362,7 +1118,7 @@ class Store extends Service {
|
|
|
1362
1118
|
* @returns
|
|
1363
1119
|
*/
|
|
1364
1120
|
async setAttribute(uid, property, value) {
|
|
1365
|
-
|
|
1121
|
+
const patch = {};
|
|
1366
1122
|
patch[property] = value;
|
|
1367
1123
|
patch[this.getUuidField()] = uid;
|
|
1368
1124
|
await this.patch(patch);
|
|
@@ -1371,7 +1127,7 @@ class Store extends Service {
|
|
|
1371
1127
|
* @override
|
|
1372
1128
|
*/
|
|
1373
1129
|
async simulateFind(query, uuids) {
|
|
1374
|
-
|
|
1130
|
+
const result = {
|
|
1375
1131
|
results: [],
|
|
1376
1132
|
continuationToken: undefined,
|
|
1377
1133
|
filter: true
|
|
@@ -1379,20 +1135,20 @@ class Store extends Service {
|
|
|
1379
1135
|
let count = 0;
|
|
1380
1136
|
let limit = query.limit;
|
|
1381
1137
|
let offset = parseInt(query.continuationToken || "0");
|
|
1382
|
-
|
|
1138
|
+
const originalOffset = offset;
|
|
1383
1139
|
if (query.orderBy && query.orderBy.length) {
|
|
1384
1140
|
offset = 0;
|
|
1385
1141
|
// We need to retrieve everything to orderBy after
|
|
1386
1142
|
limit = Number.MAX_SAFE_INTEGER;
|
|
1387
1143
|
}
|
|
1388
1144
|
// Need to transfert to Array
|
|
1389
|
-
for (
|
|
1145
|
+
for (const uuid of uuids) {
|
|
1390
1146
|
count++;
|
|
1391
1147
|
// Offset start
|
|
1392
1148
|
if (offset >= count) {
|
|
1393
1149
|
continue;
|
|
1394
1150
|
}
|
|
1395
|
-
|
|
1151
|
+
const obj = await this._getFromCache(uuid);
|
|
1396
1152
|
if (obj && query.filter.eval(obj)) {
|
|
1397
1153
|
result.results.push(obj);
|
|
1398
1154
|
if (result.results.length >= limit) {
|
|
@@ -1406,8 +1162,8 @@ class Store extends Service {
|
|
|
1406
1162
|
// Sorting the results
|
|
1407
1163
|
result.results.sort((a, b) => {
|
|
1408
1164
|
let valA, valB;
|
|
1409
|
-
for (
|
|
1410
|
-
|
|
1165
|
+
for (const orderBy of query.orderBy) {
|
|
1166
|
+
const invert = orderBy.direction === "ASC" ? 1 : -1;
|
|
1411
1167
|
valA = WebdaQL.ComparisonExpression.getAttributeValue(a, orderBy.field.split("."));
|
|
1412
1168
|
valB = WebdaQL.ComparisonExpression.getAttributeValue(b, orderBy.field.split("."));
|
|
1413
1169
|
if (valA === valB) {
|
|
@@ -1432,232 +1188,6 @@ class Store extends Service {
|
|
|
1432
1188
|
modelName: this._model.name
|
|
1433
1189
|
};
|
|
1434
1190
|
}
|
|
1435
|
-
/**
|
|
1436
|
-
* Handle POST
|
|
1437
|
-
* @param ctx
|
|
1438
|
-
*/
|
|
1439
|
-
async httpCreate(ctx) {
|
|
1440
|
-
return this.operationCreate(ctx, this.parameters.model);
|
|
1441
|
-
}
|
|
1442
|
-
/**
|
|
1443
|
-
* Create a new object based on the context
|
|
1444
|
-
* @param ctx
|
|
1445
|
-
* @param model
|
|
1446
|
-
*/
|
|
1447
|
-
async operationCreate(ctx, model) {
|
|
1448
|
-
let body = await ctx.getInput();
|
|
1449
|
-
const modelPrototype = this.getWebda().getApplication().getModel(model);
|
|
1450
|
-
let object = modelPrototype.factory(body, ctx);
|
|
1451
|
-
object._creationDate = new Date();
|
|
1452
|
-
await object.checkAct(ctx, "create");
|
|
1453
|
-
try {
|
|
1454
|
-
await object.validate(ctx, body);
|
|
1455
|
-
}
|
|
1456
|
-
catch (err) {
|
|
1457
|
-
this.log("INFO", "Object is not valid", err);
|
|
1458
|
-
throw new WebdaError.BadRequest("Object is not valid");
|
|
1459
|
-
}
|
|
1460
|
-
if (object[this._uuidField] && (await this.exists(object[this._uuidField]))) {
|
|
1461
|
-
throw new WebdaError.Conflict("Object already exists");
|
|
1462
|
-
}
|
|
1463
|
-
await this.save(object, ctx);
|
|
1464
|
-
ctx.write(object);
|
|
1465
|
-
const evt = {
|
|
1466
|
-
context: ctx,
|
|
1467
|
-
values: body,
|
|
1468
|
-
object: object,
|
|
1469
|
-
object_id: object.getUuid(),
|
|
1470
|
-
store: this
|
|
1471
|
-
};
|
|
1472
|
-
await Promise.all([object.__class.emitSync("Store.WebCreate", evt), this.emitSync("Store.WebCreate", evt)]);
|
|
1473
|
-
}
|
|
1474
|
-
/**
|
|
1475
|
-
* Handle obect action
|
|
1476
|
-
* @param ctx
|
|
1477
|
-
*/
|
|
1478
|
-
async httpAction(ctx, actionMethod) {
|
|
1479
|
-
let action = ctx.getHttpContext().getUrl().split("/").pop();
|
|
1480
|
-
actionMethod ?? (actionMethod = action);
|
|
1481
|
-
let object = await this.get(ctx.parameter("uuid"), ctx);
|
|
1482
|
-
if (object === undefined || object.__deleted) {
|
|
1483
|
-
throw new WebdaError.NotFound("Object not found or is deleted");
|
|
1484
|
-
}
|
|
1485
|
-
const inputSchema = `${object.__class.getIdentifier(false)}.${action}.input`;
|
|
1486
|
-
if (this.getWebda().getApplication().hasSchema(inputSchema)) {
|
|
1487
|
-
const input = await ctx.getInput();
|
|
1488
|
-
try {
|
|
1489
|
-
this.getWebda().validateSchema(inputSchema, input);
|
|
1490
|
-
}
|
|
1491
|
-
catch (err) {
|
|
1492
|
-
this.log("INFO", "Object invalid", err);
|
|
1493
|
-
this.log("INFO", "Object invalid", inputSchema, input, this.getWebda().getApplication().getSchema(inputSchema));
|
|
1494
|
-
throw new WebdaError.BadRequest("Body is invalid");
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
await object.checkAct(ctx, action);
|
|
1498
|
-
const evt = {
|
|
1499
|
-
action: action,
|
|
1500
|
-
object: object,
|
|
1501
|
-
store: this,
|
|
1502
|
-
context: ctx
|
|
1503
|
-
};
|
|
1504
|
-
await Promise.all([this.emitSync("Store.Action", evt), object.__class.emitSync("Store.Action", evt)]);
|
|
1505
|
-
const res = await object[actionMethod](ctx);
|
|
1506
|
-
if (res) {
|
|
1507
|
-
ctx.write(res);
|
|
1508
|
-
}
|
|
1509
|
-
const evtActioned = {
|
|
1510
|
-
action: action,
|
|
1511
|
-
object: object,
|
|
1512
|
-
store: this,
|
|
1513
|
-
context: ctx,
|
|
1514
|
-
result: res
|
|
1515
|
-
};
|
|
1516
|
-
await Promise.all([
|
|
1517
|
-
this.emitSync("Store.Actioned", evtActioned),
|
|
1518
|
-
object?.__class.emitSync("Store.Actioned", evtActioned)
|
|
1519
|
-
]);
|
|
1520
|
-
}
|
|
1521
|
-
/**
|
|
1522
|
-
* Handle collection action
|
|
1523
|
-
* @param ctx
|
|
1524
|
-
*/
|
|
1525
|
-
async httpGlobalAction(ctx, model = this._model) {
|
|
1526
|
-
let action = ctx.getHttpContext().getUrl().split("/").pop();
|
|
1527
|
-
const evt = {
|
|
1528
|
-
action: action,
|
|
1529
|
-
store: this,
|
|
1530
|
-
context: ctx,
|
|
1531
|
-
model
|
|
1532
|
-
};
|
|
1533
|
-
await Promise.all([this.emitSync("Store.Action", evt), model.emitSync("Store.Action", evt)]);
|
|
1534
|
-
const res = await model[action](ctx);
|
|
1535
|
-
if (res) {
|
|
1536
|
-
ctx.write(res);
|
|
1537
|
-
}
|
|
1538
|
-
const evtActioned = {
|
|
1539
|
-
action: action,
|
|
1540
|
-
store: this,
|
|
1541
|
-
context: ctx,
|
|
1542
|
-
result: res,
|
|
1543
|
-
model
|
|
1544
|
-
};
|
|
1545
|
-
await Promise.all([this.emitSync("Store.Actioned", evtActioned), model?.emitSync("Store.Actioned", evtActioned)]);
|
|
1546
|
-
}
|
|
1547
|
-
/**
|
|
1548
|
-
* Handle HTTP Update for an object
|
|
1549
|
-
*
|
|
1550
|
-
* @param ctx context of the request
|
|
1551
|
-
*/
|
|
1552
|
-
async httpUpdate(ctx) {
|
|
1553
|
-
const { uuid } = ctx.getParameters();
|
|
1554
|
-
const body = await ctx.getInput();
|
|
1555
|
-
body[this._uuidField] = uuid;
|
|
1556
|
-
let object = await this.get(uuid, ctx);
|
|
1557
|
-
if (!object || object.__deleted)
|
|
1558
|
-
throw new WebdaError.NotFound("Object not found or is deleted");
|
|
1559
|
-
await object.checkAct(ctx, "update");
|
|
1560
|
-
if (ctx.getHttpContext().getMethod() === "PATCH") {
|
|
1561
|
-
try {
|
|
1562
|
-
await object.validate(ctx, body, true);
|
|
1563
|
-
}
|
|
1564
|
-
catch (err) {
|
|
1565
|
-
this.log("INFO", "Object invalid", err, object);
|
|
1566
|
-
throw new WebdaError.BadRequest("Object is not valid");
|
|
1567
|
-
}
|
|
1568
|
-
let updateObject = new this._model();
|
|
1569
|
-
// Clean any default attributes from the model
|
|
1570
|
-
Object.keys(updateObject)
|
|
1571
|
-
.filter(i => i !== "__class")
|
|
1572
|
-
.forEach(i => {
|
|
1573
|
-
delete updateObject[i];
|
|
1574
|
-
});
|
|
1575
|
-
updateObject.setContext(ctx);
|
|
1576
|
-
updateObject.setUuid(uuid);
|
|
1577
|
-
updateObject.load(body, false, false);
|
|
1578
|
-
await this.patch(updateObject);
|
|
1579
|
-
object = undefined;
|
|
1580
|
-
}
|
|
1581
|
-
else {
|
|
1582
|
-
let updateObject = new this._model();
|
|
1583
|
-
updateObject.setContext(ctx);
|
|
1584
|
-
updateObject.load(body);
|
|
1585
|
-
// Copy back the _ attributes
|
|
1586
|
-
Object.keys(object)
|
|
1587
|
-
.filter(i => i.startsWith("_"))
|
|
1588
|
-
.forEach(i => {
|
|
1589
|
-
updateObject[i] = object[i];
|
|
1590
|
-
});
|
|
1591
|
-
try {
|
|
1592
|
-
await updateObject.validate(ctx, body);
|
|
1593
|
-
}
|
|
1594
|
-
catch (err) {
|
|
1595
|
-
this.log("INFO", "Object invalid", err);
|
|
1596
|
-
throw new WebdaError.BadRequest("Object is not valid");
|
|
1597
|
-
}
|
|
1598
|
-
// Add mappers back to
|
|
1599
|
-
object = await this.update(updateObject);
|
|
1600
|
-
}
|
|
1601
|
-
ctx.write(object);
|
|
1602
|
-
const evt = {
|
|
1603
|
-
context: ctx,
|
|
1604
|
-
updates: body,
|
|
1605
|
-
object: object,
|
|
1606
|
-
store: this,
|
|
1607
|
-
method: ctx.getHttpContext().getMethod()
|
|
1608
|
-
};
|
|
1609
|
-
await Promise.all([object?.__class.emitSync("Store.WebUpdate", evt), this.emitSync("Store.WebUpdate", evt)]);
|
|
1610
|
-
}
|
|
1611
|
-
/**
|
|
1612
|
-
* Handle GET on object
|
|
1613
|
-
*
|
|
1614
|
-
* @param ctx context of the request
|
|
1615
|
-
*/
|
|
1616
|
-
async httpGet(ctx) {
|
|
1617
|
-
let uuid = ctx.parameter("uuid");
|
|
1618
|
-
let object = await this.get(uuid, ctx);
|
|
1619
|
-
await this.emitSync("Store.WebGetNotFound", {
|
|
1620
|
-
context: ctx,
|
|
1621
|
-
uuid,
|
|
1622
|
-
store: this
|
|
1623
|
-
});
|
|
1624
|
-
if (object === undefined || object.__deleted) {
|
|
1625
|
-
throw new WebdaError.NotFound("Object not found or is deleted");
|
|
1626
|
-
}
|
|
1627
|
-
await object.checkAct(ctx, "get");
|
|
1628
|
-
ctx.write(object);
|
|
1629
|
-
const evt = {
|
|
1630
|
-
context: ctx,
|
|
1631
|
-
object: object,
|
|
1632
|
-
store: this
|
|
1633
|
-
};
|
|
1634
|
-
await Promise.all([this.emitSync("Store.WebGet", evt), object.__class.emitSync("Store.WebGet", evt)]);
|
|
1635
|
-
ctx.write(object);
|
|
1636
|
-
}
|
|
1637
|
-
/**
|
|
1638
|
-
* Handle HTTP request
|
|
1639
|
-
*
|
|
1640
|
-
* @param ctx context of the request
|
|
1641
|
-
* @returns
|
|
1642
|
-
*/
|
|
1643
|
-
async httpDelete(ctx) {
|
|
1644
|
-
let uuid = ctx.parameter("uuid");
|
|
1645
|
-
let object = await this.get(uuid, ctx);
|
|
1646
|
-
if (!object || object.__deleted)
|
|
1647
|
-
throw new WebdaError.NotFound("Object not found or is deleted");
|
|
1648
|
-
await object.checkAct(ctx, "delete");
|
|
1649
|
-
// http://stackoverflow.com/questions/28684209/huge-delay-on-delete-requests-with-204-response-and-no-content-in-objectve-c#
|
|
1650
|
-
// IOS don't handle 204 with Content-Length != 0 it seems
|
|
1651
|
-
// Might still run into: Have trouble to handle the Content-Length on API Gateway so returning an empty object for now
|
|
1652
|
-
ctx.writeHead(204, { "Content-Length": "0" });
|
|
1653
|
-
await this.delete(uuid);
|
|
1654
|
-
const evt = {
|
|
1655
|
-
context: ctx,
|
|
1656
|
-
object_id: uuid,
|
|
1657
|
-
store: this
|
|
1658
|
-
};
|
|
1659
|
-
await Promise.all([this.emitSync("Store.WebDelete", evt), object.__class.emitSync("Store.WebDelete", evt)]);
|
|
1660
|
-
}
|
|
1661
1191
|
/**
|
|
1662
1192
|
* Return the model uuid field
|
|
1663
1193
|
*/
|
|
@@ -1676,135 +1206,5 @@ class Store extends Service {
|
|
|
1676
1206
|
return this._exists(uid);
|
|
1677
1207
|
}
|
|
1678
1208
|
}
|
|
1679
|
-
__decorate([
|
|
1680
|
-
Route(".", ["POST"], {
|
|
1681
|
-
post: {
|
|
1682
|
-
description: "The way to create a new ${modelName} model",
|
|
1683
|
-
summary: "Create a new ${modelName}",
|
|
1684
|
-
operationId: "create${modelName}",
|
|
1685
|
-
requestBody: {
|
|
1686
|
-
content: {
|
|
1687
|
-
"application/json": {
|
|
1688
|
-
schema: {
|
|
1689
|
-
$ref: "#/components/schemas/${modelName}"
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
},
|
|
1694
|
-
responses: {
|
|
1695
|
-
"200": {
|
|
1696
|
-
description: "Retrieve model",
|
|
1697
|
-
content: {
|
|
1698
|
-
"application/json": {
|
|
1699
|
-
schema: {
|
|
1700
|
-
$ref: "#/components/schemas/${modelName}"
|
|
1701
|
-
}
|
|
1702
|
-
}
|
|
1703
|
-
}
|
|
1704
|
-
},
|
|
1705
|
-
"400": {
|
|
1706
|
-
description: "Object is invalid"
|
|
1707
|
-
},
|
|
1708
|
-
"403": {
|
|
1709
|
-
description: "You don't have permissions"
|
|
1710
|
-
},
|
|
1711
|
-
"409": {
|
|
1712
|
-
description: "Object already exists"
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
})
|
|
1717
|
-
], Store.prototype, "httpCreate", null);
|
|
1718
|
-
__decorate([
|
|
1719
|
-
Route("./{uuid}", ["PUT", "PATCH"], {
|
|
1720
|
-
put: {
|
|
1721
|
-
description: "Update a ${modelName} if the permissions allow",
|
|
1722
|
-
summary: "Update a ${modelName}",
|
|
1723
|
-
operationId: "update${modelName}",
|
|
1724
|
-
schemas: {
|
|
1725
|
-
input: "${modelName}",
|
|
1726
|
-
output: "${modelName}"
|
|
1727
|
-
},
|
|
1728
|
-
responses: {
|
|
1729
|
-
"200": {},
|
|
1730
|
-
"400": {
|
|
1731
|
-
description: "Object is invalid"
|
|
1732
|
-
},
|
|
1733
|
-
"403": {
|
|
1734
|
-
description: "You don't have permissions"
|
|
1735
|
-
},
|
|
1736
|
-
"404": {
|
|
1737
|
-
description: "Unknown object"
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
},
|
|
1741
|
-
patch: {
|
|
1742
|
-
description: "Patch a ${modelName} if the permissions allow",
|
|
1743
|
-
summary: "Patch a ${modelName}",
|
|
1744
|
-
operationId: "partialUpdatet${modelName}",
|
|
1745
|
-
schemas: {
|
|
1746
|
-
input: "${modelName}"
|
|
1747
|
-
},
|
|
1748
|
-
responses: {
|
|
1749
|
-
"204": {
|
|
1750
|
-
description: ""
|
|
1751
|
-
},
|
|
1752
|
-
"400": {
|
|
1753
|
-
description: "Object is invalid"
|
|
1754
|
-
},
|
|
1755
|
-
"403": {
|
|
1756
|
-
description: "You don't have permissions"
|
|
1757
|
-
},
|
|
1758
|
-
"404": {
|
|
1759
|
-
description: "Unknown object"
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
}
|
|
1763
|
-
})
|
|
1764
|
-
], Store.prototype, "httpUpdate", null);
|
|
1765
|
-
__decorate([
|
|
1766
|
-
Route("./{uuid}", ["GET"], {
|
|
1767
|
-
get: {
|
|
1768
|
-
description: "Retrieve ${modelName} model if permissions allow",
|
|
1769
|
-
summary: "Retrieve a ${modelName}",
|
|
1770
|
-
operationId: "get${modelName}",
|
|
1771
|
-
schemas: {
|
|
1772
|
-
output: "${modelName}"
|
|
1773
|
-
},
|
|
1774
|
-
responses: {
|
|
1775
|
-
"200": {},
|
|
1776
|
-
"400": {
|
|
1777
|
-
description: "Object is invalid"
|
|
1778
|
-
},
|
|
1779
|
-
"403": {
|
|
1780
|
-
description: "You don't have permissions"
|
|
1781
|
-
},
|
|
1782
|
-
"404": {
|
|
1783
|
-
description: "Unknown object"
|
|
1784
|
-
}
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
})
|
|
1788
|
-
], Store.prototype, "httpGet", null);
|
|
1789
|
-
__decorate([
|
|
1790
|
-
Route("./{uuid}", ["DELETE"], {
|
|
1791
|
-
delete: {
|
|
1792
|
-
operationId: "delete${modelName}",
|
|
1793
|
-
description: "Delete ${modelName} if the permissions allow",
|
|
1794
|
-
summary: "Delete a ${modelName}",
|
|
1795
|
-
responses: {
|
|
1796
|
-
"204": {
|
|
1797
|
-
description: ""
|
|
1798
|
-
},
|
|
1799
|
-
"403": {
|
|
1800
|
-
description: "You don't have permissions"
|
|
1801
|
-
},
|
|
1802
|
-
"404": {
|
|
1803
|
-
description: "Unknown object"
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
})
|
|
1808
|
-
], Store.prototype, "httpDelete", null);
|
|
1809
1209
|
export { Store };
|
|
1810
1210
|
//# sourceMappingURL=store.js.map
|