@webda/core 4.0.0-beta.1 → 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 +20 -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 +14 -11
- package/lib/core.d.ts.map +1 -0
- package/lib/core.js +101 -77
- 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 -2
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -2
- 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 +10 -1
- package/lib/models/coremodel.d.ts.map +1 -0
- package/lib/models/coremodel.js +33 -27
- 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 +3 -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 -85
- package/lib/services/binary.d.ts.map +1 -0
- package/lib/services/binary.js +38 -407
- 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 -750
- 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 +222 -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 +132 -119
- 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 +16 -1
- package/lib/services/resource.d.ts.map +1 -0
- package/lib/services/resource.js +17 -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 +2 -1
- 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 +1 -0
- 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 +117 -182
- 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 +3 -144
- package/lib/stores/store.d.ts.map +1 -0
- package/lib/stores/store.js +53 -653
- 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 +89 -258
- 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 +10 -2
- package/lib/unpackedapplication.d.ts.map +1 -0
- package/lib/unpackedapplication.js +81 -30
- 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 +48 -41
- 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 +25 -14
- package/lib/utils/context.spec.js.map +1 -1
- package/lib/utils/cookie.d.ts +3 -2
- 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 +1 -0
- package/lib/utils/serializers.d.ts.map +1 -0
- package/lib/utils/serializers.js +8 -8
- 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 +6 -8
- 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 +2 -2
- 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 +658 -408
- 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/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.spec.js
CHANGED
|
@@ -4,15 +4,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { test } from "@testdeck/mocha";
|
|
8
8
|
import * as assert from "assert";
|
|
9
9
|
import { stub } from "sinon";
|
|
10
10
|
import { randomUUID } from "crypto";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
11
|
+
import { TestIdent } from "../test.js";
|
|
12
|
+
import { AggregatorService, MapperService } from "../index.js";
|
|
13
13
|
import { CoreModel } from "../models/coremodel.js";
|
|
14
|
-
import {
|
|
15
|
-
import { HttpContext } from "../utils/httpcontext.js";
|
|
14
|
+
import { WebdaSimpleTest } from "../test.js";
|
|
16
15
|
import { StoreNotFoundError, UpdateConditionFailError } from "./store.js";
|
|
17
16
|
/**
|
|
18
17
|
* Fake model that refuse the half of the items
|
|
@@ -25,50 +24,31 @@ export class PermissionModel extends CoreModel {
|
|
|
25
24
|
return true;
|
|
26
25
|
}
|
|
27
26
|
}
|
|
28
|
-
|
|
29
|
-
cov() {
|
|
30
|
-
let params = new StoreParameters({ expose: "/plop", lastUpdateField: "bz", creationDateField: "c" }, undefined);
|
|
31
|
-
assert.deepStrictEqual(params.expose, {
|
|
32
|
-
queryMethod: "GET",
|
|
33
|
-
url: "/plop",
|
|
34
|
-
restrict: {}
|
|
35
|
-
});
|
|
36
|
-
assert.throws(() => new StoreParameters({ map: {} }, undefined), Error);
|
|
37
|
-
assert.throws(() => new StoreParameters({ index: [] }, undefined), Error);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
__decorate([
|
|
41
|
-
test
|
|
42
|
-
], StoreParametersTest.prototype, "cov", null);
|
|
43
|
-
StoreParametersTest = __decorate([
|
|
44
|
-
suite
|
|
45
|
-
], StoreParametersTest);
|
|
46
|
-
class StoreTest extends WebdaTest {
|
|
47
|
-
/**
|
|
48
|
-
* By default no testing index
|
|
49
|
-
* @returns
|
|
50
|
-
*/
|
|
51
|
-
async getIndex() {
|
|
52
|
-
return undefined;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Recreate index if needed
|
|
56
|
-
*/
|
|
57
|
-
async recreateIndex() { }
|
|
27
|
+
class StoreTest extends WebdaSimpleTest {
|
|
58
28
|
async before() {
|
|
59
29
|
await super.before();
|
|
60
|
-
await this.getUserStore()
|
|
61
|
-
await this.getIdentStore()
|
|
62
|
-
|
|
30
|
+
this.userStore = await this.getUserStore();
|
|
31
|
+
this.identStore = await this.getIdentStore();
|
|
32
|
+
// ensure service are registered
|
|
33
|
+
this.registerService(this.userStore);
|
|
34
|
+
this.registerService(this.identStore);
|
|
35
|
+
await this.userStore?.__clean();
|
|
36
|
+
await this.identStore?.__clean();
|
|
37
|
+
this.getIdentStore = () => {
|
|
38
|
+
throw new Error("Use this.identStore instead");
|
|
39
|
+
};
|
|
40
|
+
this.getUserStore = () => {
|
|
41
|
+
throw new Error("Use this.userStore instead");
|
|
42
|
+
};
|
|
63
43
|
}
|
|
64
44
|
getModelClass() {
|
|
65
|
-
return
|
|
45
|
+
return TestIdent;
|
|
66
46
|
}
|
|
67
47
|
/**
|
|
68
48
|
* Get the base of documents to query
|
|
69
49
|
*/
|
|
70
50
|
getQueryDocuments() {
|
|
71
|
-
|
|
51
|
+
const docs = [];
|
|
72
52
|
for (let i = 0; i < 1000; i++) {
|
|
73
53
|
docs.push({
|
|
74
54
|
state: ["CA", "OR", "NY", "FL"][i % 4],
|
|
@@ -86,14 +66,14 @@ class StoreTest extends WebdaTest {
|
|
|
86
66
|
* Fill the Store with data to be queried
|
|
87
67
|
*/
|
|
88
68
|
async fillForQuery() {
|
|
89
|
-
|
|
69
|
+
const userStore = this.userStore;
|
|
90
70
|
this.webda.getApplication().getModel("Webda/User").prototype.canAct = async () => true;
|
|
91
71
|
userStore._model.prototype.canAct = async () => true;
|
|
92
72
|
await Promise.all(this.getQueryDocuments().map(d => userStore.save(d)));
|
|
93
73
|
return userStore;
|
|
94
74
|
}
|
|
95
75
|
async query() {
|
|
96
|
-
|
|
76
|
+
const userStore = await this.fillForQuery();
|
|
97
77
|
const queries = {
|
|
98
78
|
'state = "CA"': 250,
|
|
99
79
|
"team.id > 15": 200,
|
|
@@ -113,7 +93,7 @@ class StoreTest extends WebdaTest {
|
|
|
113
93
|
"role = 4": 100,
|
|
114
94
|
"": 1000
|
|
115
95
|
};
|
|
116
|
-
for (
|
|
96
|
+
for (const i in queries) {
|
|
117
97
|
assert.strictEqual((await userStore.query(i)).results.length, queries[i], `Query: ${i} should return ${queries[i]}`);
|
|
118
98
|
}
|
|
119
99
|
// Verify pagination system
|
|
@@ -131,44 +111,6 @@ class StoreTest extends WebdaTest {
|
|
|
131
111
|
assert.strictEqual(res.results.length, 100, `Query: LIMIT 100 ${offset ? 'OFFSET "' + offset + '"' : ""} should return 0`);
|
|
132
112
|
}
|
|
133
113
|
} while (offset !== undefined);
|
|
134
|
-
// Verify permission issue and half pagination
|
|
135
|
-
userStore.setModel(PermissionModel);
|
|
136
|
-
userStore.getParameters().forceModel = true;
|
|
137
|
-
if (userStore._cacheStore) {
|
|
138
|
-
userStore._cacheStore.getParameters().forceModel = true;
|
|
139
|
-
}
|
|
140
|
-
let context = await this.newContext();
|
|
141
|
-
// Verify pagination system
|
|
142
|
-
i = 0;
|
|
143
|
-
let total = 0;
|
|
144
|
-
let q;
|
|
145
|
-
// To ensure we trigger slowQuery
|
|
146
|
-
userStore.getParameters().slowQueryThreshold = 0;
|
|
147
|
-
do {
|
|
148
|
-
q = `team.id > 10 LIMIT 100 ${offset ? 'OFFSET "' + offset + '"' : ""}`;
|
|
149
|
-
context.setHttpContext(new HttpContext("test.webda.io", i++ % 2 ? "GET" : "PUT", userStore.getParameters().expose.url + "?q=" + encodeURI(q), "https", 443));
|
|
150
|
-
context.getHttpContext().setBody({ q });
|
|
151
|
-
context.getParameters().q = q;
|
|
152
|
-
// @ts-ignore
|
|
153
|
-
await userStore.httpQuery(context);
|
|
154
|
-
res = JSON.parse(context.getResponseBody());
|
|
155
|
-
offset = res.continuationToken;
|
|
156
|
-
total += res.results.length;
|
|
157
|
-
} while (offset !== undefined);
|
|
158
|
-
assert.strictEqual(total, 180);
|
|
159
|
-
q = "BAD QUERY !";
|
|
160
|
-
context.setHttpContext(new HttpContext("test.webda.io", "PUT", userStore.getParameters().expose.url, "https", 443));
|
|
161
|
-
context.getHttpContext().setBody({ q });
|
|
162
|
-
await assert.rejects(() => userStore["httpQuery"](context), (err) => err.getResponseCode() === 400);
|
|
163
|
-
let mock = stub(userStore, "query").callsFake(() => {
|
|
164
|
-
throw new Error("Plop");
|
|
165
|
-
});
|
|
166
|
-
try {
|
|
167
|
-
await assert.rejects(() => userStore["httpQuery"](context), /Plop/);
|
|
168
|
-
}
|
|
169
|
-
finally {
|
|
170
|
-
mock.restore();
|
|
171
|
-
}
|
|
172
114
|
return userStore;
|
|
173
115
|
}
|
|
174
116
|
/**
|
|
@@ -184,8 +126,8 @@ class StoreTest extends WebdaTest {
|
|
|
184
126
|
};
|
|
185
127
|
}
|
|
186
128
|
async queryOrder() {
|
|
187
|
-
|
|
188
|
-
|
|
129
|
+
const userStore = await this.fillForQuery();
|
|
130
|
+
const model = await userStore.save({
|
|
189
131
|
order: 996,
|
|
190
132
|
state: "CA",
|
|
191
133
|
team: { id: 16 }
|
|
@@ -231,11 +173,24 @@ class StoreTest extends WebdaTest {
|
|
|
231
173
|
}
|
|
232
174
|
}
|
|
233
175
|
async mapper() {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
176
|
+
// Create a mapper - keep the test here as it is a good test for stores
|
|
177
|
+
const identStore = this.identStore;
|
|
178
|
+
const userStore = this.userStore;
|
|
179
|
+
await this.addService(MapperService, {
|
|
180
|
+
source: identStore.getName(),
|
|
181
|
+
targetAttribute: "idents",
|
|
182
|
+
target: userStore.getName(),
|
|
183
|
+
attribute: "_user",
|
|
184
|
+
fields: ["type", "_lastUpdate"],
|
|
185
|
+
cascade: true
|
|
186
|
+
}, "Mapper");
|
|
187
|
+
await this.addService(AggregatorService, {
|
|
188
|
+
source: identStore.getName(),
|
|
189
|
+
key: "idents-index",
|
|
190
|
+
fields: ["type"]
|
|
191
|
+
});
|
|
192
|
+
let eventFired = 0;
|
|
193
|
+
const events = [
|
|
239
194
|
"Store.Save",
|
|
240
195
|
"Store.Saved",
|
|
241
196
|
"Store.Get",
|
|
@@ -246,20 +201,20 @@ class StoreTest extends WebdaTest {
|
|
|
246
201
|
"Store.Query",
|
|
247
202
|
"Store.Queried"
|
|
248
203
|
];
|
|
249
|
-
for (
|
|
250
|
-
identStore.on(events[evt],
|
|
204
|
+
for (const evt in events) {
|
|
205
|
+
identStore.on(events[evt], evt => {
|
|
251
206
|
eventFired++;
|
|
252
207
|
});
|
|
253
208
|
}
|
|
254
209
|
assert.strictEqual(await userStore.get(undefined), undefined);
|
|
255
|
-
user1 = (await userStore.save({
|
|
210
|
+
let user1 = (await userStore.save({
|
|
256
211
|
name: "test"
|
|
257
212
|
})).getUuid();
|
|
258
213
|
let user = await userStore.get(user1);
|
|
259
214
|
// Save a user and add an ident
|
|
260
215
|
assert.notStrictEqual(user, undefined);
|
|
261
216
|
user1 = user.getUuid();
|
|
262
|
-
ident1 = await identStore.save({
|
|
217
|
+
const ident1 = await identStore.save({
|
|
263
218
|
type: "facebook",
|
|
264
219
|
_user: user.getUuid()
|
|
265
220
|
});
|
|
@@ -269,7 +224,7 @@ class StoreTest extends WebdaTest {
|
|
|
269
224
|
assert.notStrictEqual(user.idents, undefined);
|
|
270
225
|
assert.strictEqual(user.idents.length, 1);
|
|
271
226
|
// Retrieve index to verify it is in it too
|
|
272
|
-
|
|
227
|
+
const index = await this.webda.getRegistry().get("idents-index");
|
|
273
228
|
// Do not force index test for store
|
|
274
229
|
if (index) {
|
|
275
230
|
assert.notStrictEqual(index[ident1.uuid], undefined);
|
|
@@ -297,7 +252,7 @@ class StoreTest extends WebdaTest {
|
|
|
297
252
|
await user.refresh();
|
|
298
253
|
assert.notStrictEqual(user.idents[0]._lastUpdate.length, 0);
|
|
299
254
|
this.assertLastUpdateNotEqual(user.idents[0]._lastUpdate, lastUpdate, "lastUpdate on a map after deleteItemFromCollection");
|
|
300
|
-
ident2 = await identStore.save({
|
|
255
|
+
const ident2 = await identStore.save({
|
|
301
256
|
type: "google",
|
|
302
257
|
_user: user.uuid
|
|
303
258
|
});
|
|
@@ -314,7 +269,7 @@ class StoreTest extends WebdaTest {
|
|
|
314
269
|
}
|
|
315
270
|
ident2.type = "google2";
|
|
316
271
|
// Update ident2 to check mapper update
|
|
317
|
-
|
|
272
|
+
const res = await identStore.patch({
|
|
318
273
|
uuid: ident2.uuid,
|
|
319
274
|
type: "google2"
|
|
320
275
|
}, true, null);
|
|
@@ -336,7 +291,7 @@ class StoreTest extends WebdaTest {
|
|
|
336
291
|
user = await userStore.save({
|
|
337
292
|
name: "test2"
|
|
338
293
|
});
|
|
339
|
-
user2 = user.uuid;
|
|
294
|
+
const user2 = user.uuid;
|
|
340
295
|
// Move ident2 from user1 to user2
|
|
341
296
|
await identStore.patch({
|
|
342
297
|
_user: user.uuid,
|
|
@@ -369,24 +324,19 @@ class StoreTest extends WebdaTest {
|
|
|
369
324
|
assert.strictEqual(user.idents[0].type, "google2");
|
|
370
325
|
// Verify delete cascade
|
|
371
326
|
await userStore.delete(user2);
|
|
372
|
-
|
|
373
|
-
assert.strictEqual(ident
|
|
327
|
+
const ident = await identStore.get(ident2.uuid);
|
|
328
|
+
assert.strictEqual(ident, undefined);
|
|
374
329
|
// Check index
|
|
375
330
|
if (index) {
|
|
376
331
|
await index.refresh();
|
|
377
332
|
assert.strictEqual(index[ident2.uuid], undefined);
|
|
378
333
|
assert.strictEqual(index[ident1.uuid], undefined);
|
|
379
334
|
}
|
|
380
|
-
assert.strictEqual(eventFired,
|
|
381
|
-
// Force sync delete - overriding the asyncDelete parameter
|
|
382
|
-
await identStore.forceDelete(ident2.uuid);
|
|
383
|
-
ident = await identStore.get(ident2.uuid);
|
|
384
|
-
assert.strictEqual(ident, undefined);
|
|
385
|
-
assert.strictEqual(eventFired, 11);
|
|
335
|
+
assert.strictEqual(eventFired, 8);
|
|
386
336
|
}
|
|
387
337
|
async collection() {
|
|
388
|
-
|
|
389
|
-
|
|
338
|
+
const identStore = this.identStore;
|
|
339
|
+
let ident;
|
|
390
340
|
ident = await identStore.save({
|
|
391
341
|
test: "plop"
|
|
392
342
|
});
|
|
@@ -446,16 +396,14 @@ class StoreTest extends WebdaTest {
|
|
|
446
396
|
assert.strictEqual(ident.actions[0].uuid, "action_2");
|
|
447
397
|
}
|
|
448
398
|
async getAll() {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
var user3;
|
|
452
|
-
user1 = await userStore.save({
|
|
399
|
+
const userStore = this.userStore;
|
|
400
|
+
const user1 = await userStore.save({
|
|
453
401
|
name: "test1"
|
|
454
402
|
});
|
|
455
403
|
await userStore.save({
|
|
456
404
|
name: "test2"
|
|
457
405
|
});
|
|
458
|
-
user3 = await userStore.save({
|
|
406
|
+
const user3 = await userStore.save({
|
|
459
407
|
name: "test3"
|
|
460
408
|
});
|
|
461
409
|
let users = await userStore.getAll();
|
|
@@ -469,9 +417,9 @@ class StoreTest extends WebdaTest {
|
|
|
469
417
|
assert.strictEqual(users[1] instanceof userStore._model, true);
|
|
470
418
|
}
|
|
471
419
|
async crud() {
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
420
|
+
const identStore = this.identStore;
|
|
421
|
+
let eventFired = 0;
|
|
422
|
+
const events = [
|
|
475
423
|
"Store.Save",
|
|
476
424
|
"Store.Saved",
|
|
477
425
|
"Store.Get",
|
|
@@ -485,8 +433,8 @@ class StoreTest extends WebdaTest {
|
|
|
485
433
|
"Store.Query",
|
|
486
434
|
"Store.Queried"
|
|
487
435
|
];
|
|
488
|
-
for (
|
|
489
|
-
identStore.on(events[evt],
|
|
436
|
+
for (const evt in events) {
|
|
437
|
+
identStore.on(events[evt], e => {
|
|
490
438
|
eventFired++;
|
|
491
439
|
});
|
|
492
440
|
}
|
|
@@ -521,7 +469,6 @@ class StoreTest extends WebdaTest {
|
|
|
521
469
|
getter.details.blank = "";
|
|
522
470
|
getter.details.bouzouf = undefined;
|
|
523
471
|
getter.empty = [];
|
|
524
|
-
let object;
|
|
525
472
|
this.log("DEBUG", "Update ident");
|
|
526
473
|
await identStore.update(getter);
|
|
527
474
|
assert.strictEqual(eventFired, 2);
|
|
@@ -534,7 +481,7 @@ class StoreTest extends WebdaTest {
|
|
|
534
481
|
assert.strictEqual(eventFired, 2);
|
|
535
482
|
eventFired = 0;
|
|
536
483
|
this.log("DEBUG", "Get ident to check update");
|
|
537
|
-
object = await identStore.get(ident1.uuid);
|
|
484
|
+
const object = await identStore.get(ident1.uuid);
|
|
538
485
|
this.log("DEBUG", "Retrieved object", object);
|
|
539
486
|
assert.strictEqual(object.test, "plop2");
|
|
540
487
|
assert.strictEqual(object.details.plop, "plop2");
|
|
@@ -564,7 +511,7 @@ class StoreTest extends WebdaTest {
|
|
|
564
511
|
assert.strictEqual(ident1.counter, -2);
|
|
565
512
|
// Check DELETE
|
|
566
513
|
eventFired = 0;
|
|
567
|
-
await identStore.
|
|
514
|
+
await identStore.delete(ident1.uuid);
|
|
568
515
|
assert.strictEqual(eventFired, 2);
|
|
569
516
|
eventFired = 0;
|
|
570
517
|
ident = await identStore.get(ident1.uuid);
|
|
@@ -576,15 +523,15 @@ class StoreTest extends WebdaTest {
|
|
|
576
523
|
assert.notStrictEqual(d1, d2, msg);
|
|
577
524
|
}
|
|
578
525
|
async exists() {
|
|
579
|
-
|
|
580
|
-
|
|
526
|
+
const store = this.identStore;
|
|
527
|
+
const model = await store.save({});
|
|
581
528
|
assert.ok(await store.exists(model.getUuid()));
|
|
582
529
|
assert.ok(await store.exists(model));
|
|
583
530
|
assert.ok(!(await store.exists(randomUUID())));
|
|
584
531
|
}
|
|
585
532
|
async incrementAttribute() {
|
|
586
|
-
|
|
587
|
-
|
|
533
|
+
const store = this.identStore;
|
|
534
|
+
const model = await store.save({ counter: 0 });
|
|
588
535
|
await store.incrementAttribute(model.getUuid(), "counter", 3);
|
|
589
536
|
await store.incrementAttribute(model.getUuid(), "counter2", 2);
|
|
590
537
|
await model.refresh();
|
|
@@ -593,8 +540,8 @@ class StoreTest extends WebdaTest {
|
|
|
593
540
|
await assert.rejects(() => store.incrementAttribute(randomUUID(), "counter", 1), StoreNotFoundError);
|
|
594
541
|
}
|
|
595
542
|
async removeAttribute() {
|
|
596
|
-
|
|
597
|
-
|
|
543
|
+
const store = this.identStore;
|
|
544
|
+
const model = await store.save({ counter: 0, counter2: 12, counter3: 13 });
|
|
598
545
|
await store.removeAttribute(model.getUuid(), "counter");
|
|
599
546
|
await model.refresh();
|
|
600
547
|
assert.strictEqual(model.counter, undefined);
|
|
@@ -604,8 +551,8 @@ class StoreTest extends WebdaTest {
|
|
|
604
551
|
assert.strictEqual(model.counter2, 12);
|
|
605
552
|
}
|
|
606
553
|
async setAttribute() {
|
|
607
|
-
|
|
608
|
-
|
|
554
|
+
const store = this.identStore;
|
|
555
|
+
const model = await store.save({ counter: 0 });
|
|
609
556
|
await store.setAttribute(model.getUuid(), "counter", 3);
|
|
610
557
|
await store.setAttribute(model.getUuid(), "status", "TESTED");
|
|
611
558
|
await model.refresh();
|
|
@@ -628,7 +575,7 @@ class StoreTest extends WebdaTest {
|
|
|
628
575
|
await assert.rejects(() => store.setAttribute(randomUUID(), "counter", 4), err => err instanceof StoreNotFoundError || err instanceof UpdateConditionFailError);
|
|
629
576
|
}
|
|
630
577
|
async deleteAsync() {
|
|
631
|
-
|
|
578
|
+
const store = this.identStore;
|
|
632
579
|
let model = await store.save({ counter: 1 });
|
|
633
580
|
// Delete with condition
|
|
634
581
|
await assert.rejects(() => store.delete(model.getUuid(), 4, "counter"), UpdateConditionFailError);
|
|
@@ -637,11 +584,11 @@ class StoreTest extends WebdaTest {
|
|
|
637
584
|
model = await store.save({ counter: 2 });
|
|
638
585
|
await store.delete(model);
|
|
639
586
|
// Deleting a non-existing object should be ignored
|
|
640
|
-
await store.
|
|
587
|
+
await store.delete(randomUUID());
|
|
641
588
|
}
|
|
642
589
|
async delete() {
|
|
643
590
|
// UserStore is not supposed to be async
|
|
644
|
-
|
|
591
|
+
const store = this.userStore;
|
|
645
592
|
let model = await store.save({ counter: 1 });
|
|
646
593
|
// Delete with condition
|
|
647
594
|
await assert.rejects(() => store.delete(model.getUuid(), 4, "counter"), UpdateConditionFailError);
|
|
@@ -650,11 +597,11 @@ class StoreTest extends WebdaTest {
|
|
|
650
597
|
model = await store.save({ counter: 2 });
|
|
651
598
|
await store.delete(model);
|
|
652
599
|
// Deleting a non-existing object should be ignored
|
|
653
|
-
await store.
|
|
600
|
+
await store.delete(randomUUID());
|
|
654
601
|
}
|
|
655
602
|
async deleteConcurrent() {
|
|
656
|
-
|
|
657
|
-
|
|
603
|
+
const store = this.userStore;
|
|
604
|
+
const model = await store.save({ counter: 1 });
|
|
658
605
|
store.addListener("Store.Delete", async () => {
|
|
659
606
|
await store.incrementAttribute(model.getUuid(), "counter", 1);
|
|
660
607
|
});
|
|
@@ -663,8 +610,8 @@ class StoreTest extends WebdaTest {
|
|
|
663
610
|
await store.delete(model.getUuid(), 2, "counter");
|
|
664
611
|
}
|
|
665
612
|
async conditionUpdate() {
|
|
666
|
-
|
|
667
|
-
|
|
613
|
+
const store = this.identStore;
|
|
614
|
+
const model = await store.save({ counter: 1 });
|
|
668
615
|
assert.ok(await store.conditionalPatch(model.getUuid(), {
|
|
669
616
|
plop: 12,
|
|
670
617
|
counter: 2
|
|
@@ -684,14 +631,14 @@ class StoreTest extends WebdaTest {
|
|
|
684
631
|
}, "counter", 1), /Fake Error/);
|
|
685
632
|
}
|
|
686
633
|
async update(delay = 1) {
|
|
687
|
-
|
|
688
|
-
|
|
634
|
+
const store = this.identStore;
|
|
635
|
+
const model = await store.save({ counter: 1 });
|
|
689
636
|
model.saveUpdateCompat = true;
|
|
690
637
|
await store.save(model, await this.newContext());
|
|
691
638
|
model.saveInnerMethod = true;
|
|
692
639
|
model.setContext(await this.newContext());
|
|
693
640
|
await model.save();
|
|
694
|
-
|
|
641
|
+
const model2 = await store.get(model.getUuid());
|
|
695
642
|
store.on("Store.Update", async () => {
|
|
696
643
|
model2._lastUpdate = new Date(100);
|
|
697
644
|
// @ts-ignore
|
|
@@ -710,10 +657,10 @@ class StoreTest extends WebdaTest {
|
|
|
710
657
|
await assert.rejects(() => store.update({ uuid: randomUUID(), test: true }), err => err instanceof StoreNotFoundError || err instanceof UpdateConditionFailError);
|
|
711
658
|
}
|
|
712
659
|
async upsertItem() {
|
|
713
|
-
|
|
660
|
+
const store = this.identStore;
|
|
714
661
|
this.log("DEBUG", "Save empty logs array");
|
|
715
|
-
|
|
716
|
-
|
|
662
|
+
const model = await store.save({ logs: [] });
|
|
663
|
+
const ps = [];
|
|
717
664
|
this.log("DEBUG", "Upsert 10 lines");
|
|
718
665
|
for (let i = 0; i < 10; i++) {
|
|
719
666
|
ps.push(store.upsertItemToCollection(model.getUuid(), "logs", `line${i}`));
|
|
@@ -728,7 +675,7 @@ class StoreTest extends WebdaTest {
|
|
|
728
675
|
await assert.rejects(() => store.deleteItemFromCollection(randomUUID(), "logs", 0, undefined, undefined), err => err instanceof StoreNotFoundError || err instanceof UpdateConditionFailError);
|
|
729
676
|
}
|
|
730
677
|
async put() {
|
|
731
|
-
const store = this.
|
|
678
|
+
const store = this.identStore;
|
|
732
679
|
const uuid = store.getWebda().getUuid();
|
|
733
680
|
if (await store.exists(uuid)) {
|
|
734
681
|
await store.delete(uuid);
|
|
@@ -737,122 +684,6 @@ class StoreTest extends WebdaTest {
|
|
|
737
684
|
// Verify put acts like a upsert
|
|
738
685
|
await store.put(uuid, { test: false });
|
|
739
686
|
}
|
|
740
|
-
async httpCRUD(url = "/users") {
|
|
741
|
-
let eventFired;
|
|
742
|
-
let userStore = this.getUserStore();
|
|
743
|
-
let ctx, executor;
|
|
744
|
-
await userStore.__clean();
|
|
745
|
-
ctx = await this.newContext({});
|
|
746
|
-
ctx.session.login("PLOP", "fake_ident");
|
|
747
|
-
executor = this.getExecutor(ctx, "test.webda.io", "POST", url, {
|
|
748
|
-
type: "CRUD",
|
|
749
|
-
uuid: "PLOP",
|
|
750
|
-
displayName: "Coucou"
|
|
751
|
-
});
|
|
752
|
-
assert.notStrictEqual(executor, undefined);
|
|
753
|
-
await executor.execute(ctx);
|
|
754
|
-
ctx.body = undefined;
|
|
755
|
-
assert.strictEqual((await userStore.getAll()).length, 1);
|
|
756
|
-
await this.getExecutor(ctx, "test.webda.io", "GET", `${url}/PLOP`).execute(ctx);
|
|
757
|
-
assert.notStrictEqual(ctx.getResponseBody(), undefined);
|
|
758
|
-
assert.strictEqual(ctx.getResponseBody().indexOf("_lastUpdate") >= 0, true);
|
|
759
|
-
executor = this.getExecutor(ctx, "test.webda.io", "POST", url, {
|
|
760
|
-
type: "CRUD2",
|
|
761
|
-
uuid: "PLOP",
|
|
762
|
-
displayName: "Coucou 2"
|
|
763
|
-
});
|
|
764
|
-
await assert.rejects(executor.execute(ctx), (err) => err.getResponseCode() === 409);
|
|
765
|
-
// Verify the none overide of UUID
|
|
766
|
-
await this.execute(ctx, "test.webda.io", "PUT", `${url}/PLOP`, {
|
|
767
|
-
type: "CRUD2",
|
|
768
|
-
additional: "field",
|
|
769
|
-
uuid: "PLOP2",
|
|
770
|
-
user: "fake_user",
|
|
771
|
-
displayName: "Coucou 3",
|
|
772
|
-
roles: []
|
|
773
|
-
});
|
|
774
|
-
let user = await userStore.get("PLOP");
|
|
775
|
-
assert.strictEqual(user.getUuid(), "PLOP");
|
|
776
|
-
assert.strictEqual(user.type, "CRUD2");
|
|
777
|
-
assert.strictEqual(user.additional, "field");
|
|
778
|
-
assert.strictEqual(user.user, "fake_user");
|
|
779
|
-
// Add a role to the user
|
|
780
|
-
user.roles.push("plop");
|
|
781
|
-
await user.save();
|
|
782
|
-
user = await userStore.get("PLOP");
|
|
783
|
-
assert.deepStrictEqual(user.roles, ["plop"]);
|
|
784
|
-
ctx.resetResponse();
|
|
785
|
-
// Check PATH
|
|
786
|
-
await this.execute(ctx, "test.webda.io", "PATCH", `${url}/PLOP`, {
|
|
787
|
-
type: "CRUD3",
|
|
788
|
-
uuid: "PLOP2",
|
|
789
|
-
_testor: "_ should not be update by client"
|
|
790
|
-
});
|
|
791
|
-
user = await userStore.get("PLOP");
|
|
792
|
-
assert.strictEqual(user.uuid, "PLOP");
|
|
793
|
-
assert.strictEqual(user.type, "CRUD3");
|
|
794
|
-
assert.strictEqual(user.additional, "field");
|
|
795
|
-
assert.strictEqual(user._testor, undefined);
|
|
796
|
-
assert.deepStrictEqual(user.roles, ["plop"]);
|
|
797
|
-
executor = this.getExecutor(ctx, "test.webda.io", "PUT", `${url}/PLOP`, {
|
|
798
|
-
type: "CRUD3",
|
|
799
|
-
uuid: "PLOP2",
|
|
800
|
-
_testor: "_ should not be update by client",
|
|
801
|
-
displayName: "yep"
|
|
802
|
-
});
|
|
803
|
-
await executor.execute(ctx);
|
|
804
|
-
user = await userStore.get("PLOP");
|
|
805
|
-
assert.strictEqual(user.uuid, "PLOP");
|
|
806
|
-
assert.strictEqual(user.type, "CRUD3");
|
|
807
|
-
assert.strictEqual(user.additional, undefined);
|
|
808
|
-
assert.strictEqual(user._testor, undefined);
|
|
809
|
-
assert.deepStrictEqual(user.roles, undefined);
|
|
810
|
-
await this.getExecutor(ctx, "test.webda.io", "DELETE", `${url}/PLOP`).execute(ctx);
|
|
811
|
-
eventFired = 0;
|
|
812
|
-
executor = this.getExecutor(ctx, "test.webda.io", "GET", `${url}/PLOP`);
|
|
813
|
-
await assert.rejects(() => executor.execute(ctx), WebdaError.NotFound);
|
|
814
|
-
eventFired++;
|
|
815
|
-
executor = this.getExecutor(ctx, "test.webda.io", "DELETE", `${url}/PLOP`);
|
|
816
|
-
await assert.rejects(() => executor.execute(ctx), WebdaError.NotFound);
|
|
817
|
-
eventFired++;
|
|
818
|
-
executor = this.getExecutor(ctx, "test.webda.io", "PUT", `${url}/PLOP`);
|
|
819
|
-
await assert.rejects(() => executor.execute(ctx), WebdaError.NotFound);
|
|
820
|
-
eventFired++;
|
|
821
|
-
assert.strictEqual(eventFired, 3);
|
|
822
|
-
}
|
|
823
|
-
async modelActions(url = "/idents") {
|
|
824
|
-
let identStore = this.getIdentStore();
|
|
825
|
-
assert.notStrictEqual(identStore.getModel(), undefined);
|
|
826
|
-
let eventFired = 0;
|
|
827
|
-
let executor, ctx;
|
|
828
|
-
identStore.on("Store.Action", evt => {
|
|
829
|
-
eventFired++;
|
|
830
|
-
});
|
|
831
|
-
identStore.on("Store.Actioned", evt => {
|
|
832
|
-
eventFired++;
|
|
833
|
-
});
|
|
834
|
-
ctx = await this.newContext({
|
|
835
|
-
type: "CRUD",
|
|
836
|
-
uuid: "PLOP"
|
|
837
|
-
});
|
|
838
|
-
executor = this.getExecutor(ctx, "test.webda.io", "PUT", `${url}/coucou/plop`);
|
|
839
|
-
assert.notStrictEqual(executor, undefined);
|
|
840
|
-
await assert.rejects(executor.execute(ctx), WebdaError.NotFound);
|
|
841
|
-
await identStore.save({
|
|
842
|
-
uuid: "coucou"
|
|
843
|
-
});
|
|
844
|
-
await executor.execute(ctx);
|
|
845
|
-
// Our fake action is pushing true to _plop
|
|
846
|
-
assert.strictEqual(JSON.parse(ctx.getResponseBody())._plop, true);
|
|
847
|
-
assert.strictEqual(eventFired, 2);
|
|
848
|
-
assert.notStrictEqual(this.getExecutor(ctx, "test.webda.io", "POST", `${url}/coucou/yop`), null);
|
|
849
|
-
executor = this.getExecutor(ctx, "test.webda.io", "GET", `${url}/coucou/yop`);
|
|
850
|
-
assert.notStrictEqual(executor, null);
|
|
851
|
-
// Test with action returning the result instead of writing it
|
|
852
|
-
ctx.resetResponse();
|
|
853
|
-
await executor.execute(ctx);
|
|
854
|
-
assert.strictEqual(ctx.getResponseBody(), "youpi");
|
|
855
|
-
}
|
|
856
687
|
}
|
|
857
688
|
__decorate([
|
|
858
689
|
test
|