@budibase/backend-core 2.5.9 → 2.5.10-alpha.0
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/dist/package.json +13 -10
- package/dist/src/configs/configs.d.ts +2 -1
- package/dist/src/configs/configs.js +9 -1
- package/dist/src/configs/configs.js.map +1 -1
- package/dist/src/constants/db.d.ts +1 -0
- package/dist/src/constants/db.js +1 -0
- package/dist/src/constants/db.js.map +1 -1
- package/dist/src/constants/misc.d.ts +4 -2
- package/dist/src/constants/misc.js +2 -0
- package/dist/src/constants/misc.js.map +1 -1
- package/dist/src/context/mainContext.d.ts +5 -2
- package/dist/src/context/mainContext.js +20 -3
- package/dist/src/context/mainContext.js.map +1 -1
- package/dist/src/context/types.d.ts +1 -0
- package/dist/src/db/couch/DatabaseImpl.js +1 -1
- package/dist/src/db/couch/DatabaseImpl.js.map +1 -1
- package/dist/src/db/index.d.ts +2 -1
- package/dist/src/db/index.js +15 -2
- package/dist/src/db/index.js.map +1 -1
- package/dist/src/db/lucene.d.ts +8 -14
- package/dist/src/db/lucene.js +164 -97
- package/dist/src/db/lucene.js.map +1 -1
- package/dist/src/db/searchIndexes/index.d.ts +1 -0
- package/dist/src/db/searchIndexes/index.js +18 -0
- package/dist/src/db/searchIndexes/index.js.map +1 -0
- package/dist/src/db/searchIndexes/searchIndexes.d.ts +1 -0
- package/dist/src/db/searchIndexes/searchIndexes.js +77 -0
- package/dist/src/db/searchIndexes/searchIndexes.js.map +1 -0
- package/dist/src/db/utils.d.ts +5 -126
- package/dist/src/db/utils.js +20 -232
- package/dist/src/db/utils.js.map +1 -1
- package/dist/src/db/views.d.ts +3 -1
- package/dist/src/db/views.js +61 -30
- package/dist/src/db/views.js.map +1 -1
- package/dist/src/docIds/conversions.js.map +1 -0
- package/dist/src/docIds/ids.d.ts +53 -0
- package/dist/src/docIds/ids.js +101 -0
- package/dist/src/docIds/ids.js.map +1 -0
- package/dist/src/docIds/index.d.ts +2 -0
- package/dist/src/docIds/index.js +19 -0
- package/dist/src/docIds/index.js.map +1 -0
- package/dist/src/docIds/newid.js.map +1 -0
- package/dist/src/docIds/params.d.ts +69 -0
- package/dist/src/docIds/params.js +138 -0
- package/dist/src/docIds/params.js.map +1 -0
- package/dist/src/docUpdates/index.d.ts +2 -0
- package/dist/src/docUpdates/index.js +36 -0
- package/dist/src/docUpdates/index.js.map +1 -0
- package/dist/src/environment.d.ts +4 -2
- package/dist/src/environment.js +35 -2
- package/dist/src/environment.js.map +1 -1
- package/dist/src/errors/errors.d.ts +3 -0
- package/dist/src/errors/errors.js +8 -1
- package/dist/src/errors/errors.js.map +1 -1
- package/dist/src/events/asyncEvents/index.d.ts +2 -0
- package/dist/src/events/asyncEvents/index.js +19 -0
- package/dist/src/events/asyncEvents/index.js.map +1 -0
- package/dist/src/events/asyncEvents/publisher.d.ts +2 -0
- package/dist/src/events/asyncEvents/publisher.js +27 -0
- package/dist/src/events/asyncEvents/publisher.js.map +1 -0
- package/dist/src/events/asyncEvents/queue.d.ts +11 -0
- package/dist/src/events/asyncEvents/queue.js +26 -0
- package/dist/src/events/asyncEvents/queue.js.map +1 -0
- package/dist/src/events/documentId.d.ts +2 -0
- package/dist/src/events/documentId.js +28 -0
- package/dist/src/events/documentId.js.map +1 -0
- package/dist/src/events/events.js +9 -0
- package/dist/src/events/events.js.map +1 -1
- package/dist/src/events/identification.d.ts +1 -0
- package/dist/src/events/identification.js +3 -2
- package/dist/src/events/identification.js.map +1 -1
- package/dist/src/events/index.d.ts +1 -0
- package/dist/src/events/index.js +3 -1
- package/dist/src/events/index.js.map +1 -1
- package/dist/src/events/processors/LoggingProcessor.js +3 -17
- package/dist/src/events/processors/LoggingProcessor.js.map +1 -1
- package/dist/src/events/processors/Processors.js +9 -3
- package/dist/src/events/processors/Processors.js.map +1 -1
- package/dist/src/events/processors/async/DocumentUpdateProcessor.d.ts +13 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js +44 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js.map +1 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js +1 -2
- package/dist/src/events/processors/posthog/PosthogProcessor.js.map +1 -1
- package/dist/src/events/processors/types.d.ts +1 -11
- package/dist/src/events/processors/types.js +0 -6
- package/dist/src/events/processors/types.js.map +1 -1
- package/dist/src/events/publishers/group.js +6 -0
- package/dist/src/events/publishers/group.js.map +1 -1
- package/dist/src/events/publishers/license.d.ts +9 -4
- package/dist/src/events/publishers/license.js +2 -17
- package/dist/src/events/publishers/license.js.map +1 -1
- package/dist/src/events/publishers/user.js +4 -0
- package/dist/src/events/publishers/user.js.map +1 -1
- package/dist/src/index.d.ts +6 -2
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/installation.d.ts +1 -0
- package/dist/src/installation.js +7 -6
- package/dist/src/installation.js.map +1 -1
- package/dist/src/{logging.d.ts → logging/alerts.d.ts} +0 -5
- package/dist/src/logging/alerts.js +24 -0
- package/dist/src/logging/alerts.js.map +1 -0
- package/dist/src/logging/correlation/correlation.d.ts +2 -0
- package/dist/src/logging/correlation/correlation.js +17 -0
- package/dist/src/logging/correlation/correlation.js.map +1 -0
- package/dist/src/logging/correlation/index.d.ts +1 -0
- package/dist/src/logging/correlation/index.js +18 -0
- package/dist/src/logging/correlation/index.js.map +1 -0
- package/dist/src/logging/correlation/middleware.d.ts +2 -0
- package/dist/src/logging/correlation/middleware.js +17 -0
- package/dist/src/logging/correlation/middleware.js.map +1 -0
- package/dist/src/logging/index.d.ts +4 -0
- package/dist/src/logging/index.js +36 -0
- package/dist/src/logging/index.js.map +1 -0
- package/dist/src/logging/pino/logger.d.ts +2 -0
- package/dist/src/logging/pino/logger.js +167 -0
- package/dist/src/logging/pino/logger.js.map +1 -0
- package/dist/src/logging/pino/middleware.d.ts +4 -0
- package/dist/src/logging/pino/middleware.js +47 -0
- package/dist/src/logging/pino/middleware.js.map +1 -0
- package/dist/src/middleware/authenticated.js +6 -3
- package/dist/src/middleware/authenticated.js.map +1 -1
- package/dist/src/middleware/errorHandling.js +5 -7
- package/dist/src/middleware/errorHandling.js.map +1 -1
- package/dist/src/middleware/index.d.ts +2 -1
- package/dist/src/middleware/index.js +5 -3
- package/dist/src/middleware/index.js.map +1 -1
- package/dist/src/middleware/passport/sso/oidc.js +2 -5
- package/dist/src/middleware/passport/sso/oidc.js.map +1 -1
- package/dist/src/middleware/tenancy.d.ts +1 -1
- package/dist/src/migrations/migrations.js +4 -4
- package/dist/src/migrations/migrations.js.map +1 -1
- package/dist/src/objectStore/objectStore.js +3 -3
- package/dist/src/objectStore/objectStore.js.map +1 -1
- package/dist/src/plugin/utils.js +53 -2
- package/dist/src/plugin/utils.js.map +1 -1
- package/dist/src/queue/constants.d.ts +2 -1
- package/dist/src/queue/constants.js +1 -0
- package/dist/src/queue/constants.js.map +1 -1
- package/dist/src/redis/redlockImpl.js +4 -1
- package/dist/src/redis/redlockImpl.js.map +1 -1
- package/dist/src/security/encryption.d.ts +1 -0
- package/dist/src/security/encryption.js +2 -1
- package/dist/src/security/encryption.js.map +1 -1
- package/dist/src/security/permissions.d.ts +35 -2
- package/dist/src/security/permissions.js +9 -6
- package/dist/src/security/permissions.js.map +1 -1
- package/dist/src/tenancy/tenancy.js +1 -5
- package/dist/src/tenancy/tenancy.js.map +1 -1
- package/dist/src/users.d.ts +11 -1
- package/dist/src/users.js +45 -1
- package/dist/src/users.js.map +1 -1
- package/dist/src/utils/hashing.d.ts +1 -1
- package/dist/src/utils/hashing.js +1 -1
- package/dist/src/utils/hashing.js.map +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/stringUtils.d.ts +1 -0
- package/dist/src/utils/stringUtils.js +9 -0
- package/dist/src/utils/stringUtils.js.map +1 -0
- package/dist/src/utils/utils.d.ts +0 -1
- package/dist/src/utils/utils.js +1 -24
- package/dist/src/utils/utils.js.map +1 -1
- package/dist/tests/core/logging.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/index.d.ts +1 -2
- package/dist/tests/{utilities → core/utilities}/index.js +2 -7
- package/dist/tests/core/utilities/index.js.map +1 -0
- package/dist/tests/core/utilities/jestUtils.js.map +1 -0
- package/dist/tests/core/utilities/mocks/alerts.d.ts +3 -0
- package/dist/tests/core/utilities/mocks/alerts.js +30 -0
- package/dist/tests/core/utilities/mocks/alerts.js.map +1 -0
- package/dist/tests/core/utilities/mocks/date.js.map +1 -0
- package/dist/tests/core/utilities/mocks/events.js +144 -0
- package/dist/tests/core/utilities/mocks/events.js.map +1 -0
- package/dist/tests/core/utilities/mocks/fetch.d.ts +33 -0
- package/dist/tests/core/utilities/mocks/fetch.js +15 -0
- package/dist/tests/core/utilities/mocks/fetch.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/mocks/index.d.ts +4 -3
- package/dist/tests/{utilities → core/utilities}/mocks/index.js +7 -3
- package/dist/tests/core/utilities/mocks/index.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/mocks/licenses.d.ts +1 -0
- package/dist/tests/{utilities → core/utilities}/mocks/licenses.js +5 -1
- package/dist/tests/core/utilities/mocks/licenses.js.map +1 -0
- package/dist/tests/core/utilities/mocks/posthog.js.map +1 -0
- package/dist/tests/core/utilities/structures/Chance.d.ts +7 -0
- package/dist/tests/core/utilities/structures/Chance.js +21 -0
- package/dist/tests/core/utilities/structures/Chance.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/structures/accounts.js +3 -25
- package/dist/tests/core/utilities/structures/accounts.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/structures/apps.js +1 -1
- package/dist/tests/core/utilities/structures/apps.js.map +1 -0
- package/dist/tests/core/utilities/structures/common.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/structures/db.js +1 -1
- package/dist/tests/core/utilities/structures/db.js.map +1 -0
- package/dist/tests/core/utilities/structures/generator.d.ts +2 -0
- package/dist/tests/{utilities → core/utilities}/structures/generator.js +2 -2
- package/dist/tests/core/utilities/structures/generator.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/structures/index.d.ts +2 -0
- package/dist/tests/{utilities → core/utilities}/structures/index.js +3 -1
- package/dist/tests/core/utilities/structures/index.js.map +1 -0
- package/dist/tests/core/utilities/structures/koa.js.map +1 -0
- package/dist/tests/core/utilities/structures/licenses.d.ts +17 -0
- package/dist/tests/core/utilities/structures/licenses.js +127 -0
- package/dist/tests/core/utilities/structures/licenses.js.map +1 -0
- package/dist/tests/core/utilities/structures/plugins.js.map +1 -0
- package/dist/tests/core/utilities/structures/quotas.d.ts +2 -0
- package/dist/tests/core/utilities/structures/quotas.js +71 -0
- package/dist/tests/core/utilities/structures/quotas.js.map +1 -0
- package/dist/tests/core/utilities/structures/scim.d.ts +14 -0
- package/dist/tests/core/utilities/structures/scim.js +67 -0
- package/dist/tests/core/utilities/structures/scim.js.map +1 -0
- package/dist/tests/core/utilities/structures/shared.js.map +1 -0
- package/dist/tests/core/utilities/structures/sso.js.map +1 -0
- package/dist/tests/{utilities → core/utilities}/structures/tenants.js +1 -1
- package/dist/tests/core/utilities/structures/tenants.js.map +1 -0
- package/dist/tests/core/utilities/structures/userGroups.js.map +1 -0
- package/dist/tests/core/utilities/structures/users.js.map +1 -0
- package/dist/tests/core/utilities/testContainerUtils.js.map +1 -0
- package/dist/tests/core/utilities/utils/index.d.ts +1 -0
- package/dist/tests/core/utilities/utils/index.js +28 -0
- package/dist/tests/core/utilities/utils/index.js.map +1 -0
- package/dist/tests/core/utilities/utils/time.d.ts +1 -0
- package/dist/tests/core/utilities/utils/time.js +8 -0
- package/dist/tests/core/utilities/utils/time.js.map +1 -0
- package/dist/tests/{utilities → extra}/DBTestConfiguration.d.ts +1 -1
- package/dist/tests/{utilities → extra}/DBTestConfiguration.js +2 -2
- package/dist/tests/extra/DBTestConfiguration.js.map +1 -0
- package/dist/tests/extra/index.d.ts +2 -0
- package/dist/tests/extra/index.js +33 -0
- package/dist/tests/extra/index.js.map +1 -0
- package/dist/tests/{utilities → extra}/testEnv.d.ts +1 -1
- package/dist/tests/{utilities → extra}/testEnv.js +1 -1
- package/dist/tests/extra/testEnv.js.map +1 -0
- package/dist/tests/index.d.ts +1 -1
- package/dist/tests/index.js +1 -1
- package/dist/tests/index.js.map +1 -1
- package/dist/tests/jestEnv.js +0 -1
- package/dist/tests/jestEnv.js.map +1 -1
- package/dist/tests/jestSetup.d.ts +1 -1
- package/dist/tests/jestSetup.js +2 -2
- package/dist/tests/jestSetup.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +13 -10
- package/src/auth/tests/auth.spec.ts +2 -1
- package/src/cache/tests/writethrough.spec.ts +4 -3
- package/src/configs/configs.ts +9 -0
- package/src/configs/tests/configs.spec.ts +2 -6
- package/src/constants/db.ts +1 -0
- package/src/constants/misc.ts +2 -0
- package/src/context/mainContext.ts +22 -5
- package/src/context/tests/index.spec.ts +16 -3
- package/src/context/types.ts +1 -0
- package/src/db/couch/DatabaseImpl.ts +1 -1
- package/src/db/index.ts +2 -1
- package/src/db/lucene.ts +156 -99
- package/src/db/searchIndexes/index.ts +1 -0
- package/src/db/searchIndexes/searchIndexes.ts +62 -0
- package/src/db/tests/lucene.spec.ts +101 -1
- package/src/db/tests/utils.spec.ts +1 -1
- package/src/db/utils.ts +7 -275
- package/src/db/views.ts +64 -25
- package/src/docIds/ids.ts +102 -0
- package/src/docIds/index.ts +2 -0
- package/src/docIds/params.ts +174 -0
- package/src/docUpdates/index.ts +29 -0
- package/src/environment.ts +44 -2
- package/src/errors/errors.ts +8 -0
- package/src/events/asyncEvents/index.ts +2 -0
- package/src/events/asyncEvents/publisher.ts +12 -0
- package/src/events/asyncEvents/queue.ts +22 -0
- package/src/events/documentId.ts +56 -0
- package/src/events/events.ts +10 -1
- package/src/events/identification.ts +3 -3
- package/src/events/index.ts +2 -0
- package/src/events/processors/LoggingProcessor.ts +3 -22
- package/src/events/processors/Processors.ts +9 -3
- package/src/events/processors/async/DocumentUpdateProcessor.ts +43 -0
- package/src/events/processors/posthog/PosthogProcessor.ts +1 -2
- package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +1 -1
- package/src/events/processors/types.ts +1 -18
- package/src/events/publishers/group.ts +6 -1
- package/src/events/publishers/license.ts +12 -13
- package/src/events/publishers/user.ts +4 -0
- package/src/index.ts +1 -0
- package/src/installation.ts +4 -5
- package/src/logging/alerts.ts +26 -0
- package/src/logging/correlation/correlation.ts +13 -0
- package/src/logging/correlation/index.ts +1 -0
- package/src/logging/correlation/middleware.ts +17 -0
- package/src/logging/index.ts +6 -0
- package/src/logging/pino/logger.ts +173 -0
- package/src/logging/pino/middleware.ts +45 -0
- package/src/middleware/authenticated.ts +9 -3
- package/src/middleware/errorHandling.ts +4 -4
- package/src/middleware/index.ts +2 -1
- package/src/middleware/passport/sso/oidc.ts +2 -9
- package/src/middleware/passport/sso/tests/sso.spec.ts +2 -1
- package/src/migrations/migrations.ts +4 -8
- package/src/migrations/tests/__snapshots__/migrations.spec.ts.snap +1 -1
- package/src/migrations/tests/migrations.spec.ts +1 -1
- package/src/objectStore/buckets/tests/app.spec.ts +1 -1
- package/src/objectStore/buckets/tests/global.spec.ts +1 -1
- package/src/objectStore/buckets/tests/plugins.spec.ts +2 -1
- package/src/objectStore/objectStore.ts +3 -3
- package/src/platform/tests/tenants.spec.ts +2 -1
- package/src/plugin/tests/validation.spec.ts +83 -0
- package/src/plugin/utils.ts +63 -3
- package/src/queue/constants.ts +1 -0
- package/src/redis/redlockImpl.ts +9 -3
- package/src/security/encryption.ts +1 -1
- package/src/security/permissions.ts +5 -5
- package/src/security/tests/encryption.spec.ts +31 -0
- package/src/security/tests/permissions.spec.ts +145 -0
- package/src/tenancy/tenancy.ts +2 -2
- package/src/tenancy/tests/tenancy.spec.ts +184 -0
- package/src/users.ts +56 -7
- package/src/utils/hashing.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/stringUtils.ts +8 -0
- package/src/utils/tests/utils.spec.ts +2 -1
- package/src/utils/utils.ts +3 -23
- package/tests/{utilities → core/utilities}/index.ts +1 -4
- package/tests/core/utilities/mocks/alerts.ts +3 -0
- package/tests/core/utilities/mocks/events.ts +133 -0
- package/tests/core/utilities/mocks/fetch.ts +17 -0
- package/tests/{utilities → core/utilities}/mocks/index.ts +4 -3
- package/tests/{utilities → core/utilities}/mocks/licenses.ts +4 -0
- package/tests/core/utilities/structures/Chance.ts +20 -0
- package/tests/{utilities → core/utilities}/structures/accounts.ts +4 -3
- package/tests/{utilities → core/utilities}/structures/apps.ts +1 -1
- package/tests/{utilities → core/utilities}/structures/db.ts +1 -1
- package/tests/{utilities → core/utilities}/structures/generator.ts +1 -1
- package/tests/{utilities → core/utilities}/structures/index.ts +2 -0
- package/tests/core/utilities/structures/licenses.ts +145 -0
- package/tests/core/utilities/structures/quotas.ts +67 -0
- package/tests/core/utilities/structures/scim.ts +81 -0
- package/tests/{utilities → core/utilities}/structures/tenants.ts +1 -1
- package/tests/core/utilities/utils/index.ts +1 -0
- package/tests/core/utilities/utils/time.ts +3 -0
- package/tests/{utilities → extra}/DBTestConfiguration.ts +2 -2
- package/tests/extra/index.ts +2 -0
- package/tests/{utilities → extra}/testEnv.ts +1 -1
- package/tests/index.ts +1 -1
- package/tests/jestEnv.ts +0 -1
- package/tests/jestSetup.ts +2 -2
- package/tsconfig.build.json +3 -7
- package/dist/src/db/conversions.js.map +0 -1
- package/dist/src/logging.js +0 -56
- package/dist/src/logging.js.map +0 -1
- package/dist/src/middleware/logging.d.ts +0 -2
- package/dist/src/middleware/logging.js +0 -106
- package/dist/src/middleware/logging.js.map +0 -1
- package/dist/src/newid.js.map +0 -1
- package/dist/tests/logging.js.map +0 -1
- package/dist/tests/utilities/DBTestConfiguration.js.map +0 -1
- package/dist/tests/utilities/index.js.map +0 -1
- package/dist/tests/utilities/jestUtils.js.map +0 -1
- package/dist/tests/utilities/mocks/date.js.map +0 -1
- package/dist/tests/utilities/mocks/events.js +0 -126
- package/dist/tests/utilities/mocks/events.js.map +0 -1
- package/dist/tests/utilities/mocks/fetch.d.ts +0 -31
- package/dist/tests/utilities/mocks/fetch.js +0 -8
- package/dist/tests/utilities/mocks/fetch.js.map +0 -1
- package/dist/tests/utilities/mocks/index.js.map +0 -1
- package/dist/tests/utilities/mocks/licenses.js.map +0 -1
- package/dist/tests/utilities/mocks/posthog.js.map +0 -1
- package/dist/tests/utilities/structures/accounts.js.map +0 -1
- package/dist/tests/utilities/structures/apps.js.map +0 -1
- package/dist/tests/utilities/structures/common.js.map +0 -1
- package/dist/tests/utilities/structures/db.js.map +0 -1
- package/dist/tests/utilities/structures/generator.d.ts +0 -1
- package/dist/tests/utilities/structures/generator.js.map +0 -1
- package/dist/tests/utilities/structures/index.js.map +0 -1
- package/dist/tests/utilities/structures/koa.js.map +0 -1
- package/dist/tests/utilities/structures/licenses.d.ts +0 -5
- package/dist/tests/utilities/structures/licenses.js +0 -18
- package/dist/tests/utilities/structures/licenses.js.map +0 -1
- package/dist/tests/utilities/structures/plugins.js.map +0 -1
- package/dist/tests/utilities/structures/shared.js.map +0 -1
- package/dist/tests/utilities/structures/sso.js.map +0 -1
- package/dist/tests/utilities/structures/tenants.js.map +0 -1
- package/dist/tests/utilities/structures/userGroups.js.map +0 -1
- package/dist/tests/utilities/structures/users.js.map +0 -1
- package/dist/tests/utilities/testContainerUtils.js.map +0 -1
- package/dist/tests/utilities/testEnv.js.map +0 -1
- package/src/logging.ts +0 -60
- package/src/middleware/logging.ts +0 -90
- package/tests/utilities/mocks/events.ts +0 -122
- package/tests/utilities/mocks/fetch.ts +0 -10
- package/tests/utilities/structures/licenses.ts +0 -18
- /package/dist/src/{db → docIds}/conversions.d.ts +0 -0
- /package/dist/src/{db → docIds}/conversions.js +0 -0
- /package/dist/src/{newid.d.ts → docIds/newid.d.ts} +0 -0
- /package/dist/src/{newid.js → docIds/newid.js} +0 -0
- /package/dist/tests/{logging.d.ts → core/logging.d.ts} +0 -0
- /package/dist/tests/{logging.js → core/logging.js} +0 -0
- /package/dist/tests/{utilities → core/utilities}/jestUtils.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/jestUtils.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/mocks/date.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/mocks/date.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/mocks/events.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/mocks/posthog.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/mocks/posthog.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/accounts.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/apps.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/common.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/common.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/db.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/koa.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/koa.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/plugins.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/plugins.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/shared.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/shared.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/sso.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/sso.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/tenants.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/userGroups.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/userGroups.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/users.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/structures/users.js +0 -0
- /package/dist/tests/{utilities → core/utilities}/testContainerUtils.d.ts +0 -0
- /package/dist/tests/{utilities → core/utilities}/testContainerUtils.js +0 -0
- /package/src/{db → docIds}/conversions.ts +0 -0
- /package/src/{newid.ts → docIds/newid.ts} +0 -0
- /package/tests/{logging.ts → core/logging.ts} +0 -0
- /package/tests/{utilities → core/utilities}/jestUtils.ts +0 -0
- /package/tests/{utilities → core/utilities}/mocks/date.ts +0 -0
- /package/tests/{utilities → core/utilities}/mocks/posthog.ts +0 -0
- /package/tests/{utilities → core/utilities}/structures/common.ts +0 -0
- /package/tests/{utilities → core/utilities}/structures/koa.ts +0 -0
- /package/tests/{utilities → core/utilities}/structures/plugins.ts +0 -0
- /package/tests/{utilities → core/utilities}/structures/shared.ts +0 -0
- /package/tests/{utilities → core/utilities}/structures/sso.ts +0 -0
- /package/tests/{utilities → core/utilities}/structures/userGroups.ts +0 -0
- /package/tests/{utilities → core/utilities}/structures/users.ts +0 -0
- /package/tests/{utilities → core/utilities}/testContainerUtils.ts +0 -0
package/src/users.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
getProdAppID,
|
|
2
|
+
directCouchFind,
|
|
3
|
+
DocumentType,
|
|
5
4
|
generateAppUserID,
|
|
5
|
+
getGlobalUserParams,
|
|
6
|
+
getProdAppID,
|
|
7
|
+
getUsersByAppParams,
|
|
8
|
+
pagination,
|
|
6
9
|
queryGlobalView,
|
|
7
|
-
|
|
8
|
-
DocumentType,
|
|
10
|
+
queryGlobalViewRaw,
|
|
9
11
|
SEPARATOR,
|
|
10
|
-
|
|
12
|
+
UNICODE_MAX,
|
|
13
|
+
ViewName,
|
|
11
14
|
} from "./db"
|
|
12
|
-
import { BulkDocsResponse, User } from "@budibase/types"
|
|
15
|
+
import { BulkDocsResponse, SearchUsersRequest, User } from "@budibase/types"
|
|
13
16
|
import { getGlobalDB } from "./context"
|
|
14
17
|
import * as context from "./context"
|
|
15
18
|
|
|
@@ -199,3 +202,49 @@ export const searchGlobalUsersByEmail = async (
|
|
|
199
202
|
}
|
|
200
203
|
return users
|
|
201
204
|
}
|
|
205
|
+
|
|
206
|
+
const PAGE_LIMIT = 8
|
|
207
|
+
export const paginatedUsers = async ({
|
|
208
|
+
page,
|
|
209
|
+
email,
|
|
210
|
+
appId,
|
|
211
|
+
}: SearchUsersRequest = {}) => {
|
|
212
|
+
const db = getGlobalDB()
|
|
213
|
+
// get one extra document, to have the next page
|
|
214
|
+
const opts: any = {
|
|
215
|
+
include_docs: true,
|
|
216
|
+
limit: PAGE_LIMIT + 1,
|
|
217
|
+
}
|
|
218
|
+
// add a startkey if the page was specified (anchor)
|
|
219
|
+
if (page) {
|
|
220
|
+
opts.startkey = page
|
|
221
|
+
}
|
|
222
|
+
// property specifies what to use for the page/anchor
|
|
223
|
+
let userList: User[],
|
|
224
|
+
property = "_id",
|
|
225
|
+
getKey
|
|
226
|
+
if (appId) {
|
|
227
|
+
userList = await searchGlobalUsersByApp(appId, opts)
|
|
228
|
+
getKey = (doc: any) => getGlobalUserByAppPage(appId, doc)
|
|
229
|
+
} else if (email) {
|
|
230
|
+
userList = await searchGlobalUsersByEmail(email, opts)
|
|
231
|
+
property = "email"
|
|
232
|
+
} else {
|
|
233
|
+
// no search, query allDocs
|
|
234
|
+
const response = await db.allDocs(getGlobalUserParams(null, opts))
|
|
235
|
+
userList = response.rows.map((row: any) => row.doc)
|
|
236
|
+
}
|
|
237
|
+
return pagination(userList, PAGE_LIMIT, {
|
|
238
|
+
paginate: true,
|
|
239
|
+
property,
|
|
240
|
+
getKey,
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
export async function getUserCount() {
|
|
245
|
+
const response = await queryGlobalViewRaw(ViewName.USER_BY_EMAIL, {
|
|
246
|
+
limit: 0, // to be as fast as possible - we just want the total rows count
|
|
247
|
+
include_docs: false,
|
|
248
|
+
})
|
|
249
|
+
return response.total_rows
|
|
250
|
+
}
|
package/src/utils/hashing.ts
CHANGED
package/src/utils/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { structures
|
|
1
|
+
import { structures } from "../../../tests"
|
|
2
|
+
import { DBTestConfiguration } from "../../../tests/extra"
|
|
2
3
|
import * as utils from "../../utils"
|
|
3
4
|
import * as db from "../../db"
|
|
4
5
|
import { Header } from "../../constants"
|
package/src/utils/utils.ts
CHANGED
|
@@ -46,8 +46,9 @@ export async function resolveAppUrl(ctx: Ctx) {
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// search prod apps for a url that matches
|
|
49
|
-
const apps: App[] = await context.doInTenant(
|
|
50
|
-
|
|
49
|
+
const apps: App[] = await context.doInTenant(
|
|
50
|
+
tenantId,
|
|
51
|
+
() => getAllApps({ dev: false }) as Promise<App[]>
|
|
51
52
|
)
|
|
52
53
|
const app = apps.filter(
|
|
53
54
|
a => a.url && a.url.toLowerCase() === possibleAppUrl
|
|
@@ -221,27 +222,6 @@ export function isClient(ctx: Ctx) {
|
|
|
221
222
|
return ctx.headers[Header.TYPE] === "client"
|
|
222
223
|
}
|
|
223
224
|
|
|
224
|
-
async function getBuilders() {
|
|
225
|
-
const builders = await queryGlobalView(ViewName.USER_BY_BUILDERS, {
|
|
226
|
-
include_docs: false,
|
|
227
|
-
})
|
|
228
|
-
|
|
229
|
-
if (!builders) {
|
|
230
|
-
return []
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
if (Array.isArray(builders)) {
|
|
234
|
-
return builders
|
|
235
|
-
} else {
|
|
236
|
-
return [builders]
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export async function getBuildersCount() {
|
|
241
|
-
const builders = await getBuilders()
|
|
242
|
-
return builders.length
|
|
243
|
-
}
|
|
244
|
-
|
|
245
225
|
export function timeout(timeMs: number) {
|
|
246
226
|
return new Promise(resolve => setTimeout(resolve, timeMs))
|
|
247
227
|
}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export * as mocks from "./mocks"
|
|
2
2
|
export * as structures from "./structures"
|
|
3
3
|
export { generator } from "./structures"
|
|
4
|
-
export * as testEnv from "./testEnv"
|
|
5
4
|
export * as testContainerUtils from "./testContainerUtils"
|
|
6
|
-
|
|
5
|
+
export * as utils from "./utils"
|
|
7
6
|
export * from "./jestUtils"
|
|
8
|
-
|
|
9
|
-
export { default as DBTestConfiguration } from "./DBTestConfiguration"
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import * as events from "../../../../src/events"
|
|
2
|
+
|
|
3
|
+
beforeAll(async () => {
|
|
4
|
+
const processors = await import("../../../../src/events/processors")
|
|
5
|
+
const events = await import("../../../../src/events")
|
|
6
|
+
jest.spyOn(processors.analyticsProcessor, "processEvent")
|
|
7
|
+
|
|
8
|
+
jest.spyOn(events.identification, "identifyTenantGroup")
|
|
9
|
+
jest.spyOn(events.identification, "identifyUser")
|
|
10
|
+
|
|
11
|
+
jest.spyOn(events.backfill, "appSucceeded")
|
|
12
|
+
jest.spyOn(events.backfill, "tenantSucceeded")
|
|
13
|
+
|
|
14
|
+
jest.spyOn(events.account, "created")
|
|
15
|
+
jest.spyOn(events.account, "deleted")
|
|
16
|
+
jest.spyOn(events.account, "verified")
|
|
17
|
+
|
|
18
|
+
jest.spyOn(events.app, "created")
|
|
19
|
+
jest.spyOn(events.app, "updated")
|
|
20
|
+
jest.spyOn(events.app, "deleted")
|
|
21
|
+
jest.spyOn(events.app, "published")
|
|
22
|
+
jest.spyOn(events.app, "unpublished")
|
|
23
|
+
jest.spyOn(events.app, "templateImported")
|
|
24
|
+
jest.spyOn(events.app, "fileImported")
|
|
25
|
+
jest.spyOn(events.app, "versionUpdated")
|
|
26
|
+
jest.spyOn(events.app, "versionReverted")
|
|
27
|
+
jest.spyOn(events.app, "reverted")
|
|
28
|
+
jest.spyOn(events.app, "exported")
|
|
29
|
+
|
|
30
|
+
jest.spyOn(events.auth, "login")
|
|
31
|
+
jest.spyOn(events.auth, "logout")
|
|
32
|
+
jest.spyOn(events.auth, "SSOCreated")
|
|
33
|
+
jest.spyOn(events.auth, "SSOUpdated")
|
|
34
|
+
jest.spyOn(events.auth, "SSOActivated")
|
|
35
|
+
jest.spyOn(events.auth, "SSODeactivated")
|
|
36
|
+
|
|
37
|
+
jest.spyOn(events.automation, "created")
|
|
38
|
+
jest.spyOn(events.automation, "deleted")
|
|
39
|
+
jest.spyOn(events.automation, "tested")
|
|
40
|
+
jest.spyOn(events.automation, "stepCreated")
|
|
41
|
+
jest.spyOn(events.automation, "stepDeleted")
|
|
42
|
+
jest.spyOn(events.automation, "triggerUpdated")
|
|
43
|
+
|
|
44
|
+
jest.spyOn(events.datasource, "created")
|
|
45
|
+
jest.spyOn(events.datasource, "updated")
|
|
46
|
+
jest.spyOn(events.datasource, "deleted")
|
|
47
|
+
|
|
48
|
+
jest.spyOn(events.email, "SMTPCreated")
|
|
49
|
+
jest.spyOn(events.email, "SMTPUpdated")
|
|
50
|
+
|
|
51
|
+
jest.spyOn(events.layout, "created")
|
|
52
|
+
jest.spyOn(events.layout, "deleted")
|
|
53
|
+
|
|
54
|
+
jest.spyOn(events.org, "nameUpdated")
|
|
55
|
+
jest.spyOn(events.org, "logoUpdated")
|
|
56
|
+
jest.spyOn(events.org, "platformURLUpdated")
|
|
57
|
+
jest.spyOn(events.org, "analyticsOptOut")
|
|
58
|
+
|
|
59
|
+
jest.spyOn(events.installation, "versionChecked")
|
|
60
|
+
|
|
61
|
+
jest.spyOn(events.query, "created")
|
|
62
|
+
jest.spyOn(events.query, "updated")
|
|
63
|
+
jest.spyOn(events.query, "deleted")
|
|
64
|
+
jest.spyOn(events.query, "imported")
|
|
65
|
+
jest.spyOn(events.query, "previewed")
|
|
66
|
+
|
|
67
|
+
jest.spyOn(events.role, "created")
|
|
68
|
+
jest.spyOn(events.role, "updated")
|
|
69
|
+
jest.spyOn(events.role, "deleted")
|
|
70
|
+
jest.spyOn(events.role, "assigned")
|
|
71
|
+
jest.spyOn(events.role, "unassigned")
|
|
72
|
+
|
|
73
|
+
jest.spyOn(events.rows, "imported")
|
|
74
|
+
jest.spyOn(events.rows, "created")
|
|
75
|
+
|
|
76
|
+
jest.spyOn(events.screen, "created")
|
|
77
|
+
jest.spyOn(events.screen, "deleted")
|
|
78
|
+
|
|
79
|
+
jest.spyOn(events.user, "created")
|
|
80
|
+
jest.spyOn(events.user, "updated")
|
|
81
|
+
jest.spyOn(events.user, "deleted")
|
|
82
|
+
jest.spyOn(events.user, "permissionAdminAssigned")
|
|
83
|
+
jest.spyOn(events.user, "permissionAdminRemoved")
|
|
84
|
+
jest.spyOn(events.user, "permissionBuilderAssigned")
|
|
85
|
+
jest.spyOn(events.user, "permissionBuilderRemoved")
|
|
86
|
+
jest.spyOn(events.user, "invited")
|
|
87
|
+
jest.spyOn(events.user, "inviteAccepted")
|
|
88
|
+
jest.spyOn(events.user, "passwordForceReset")
|
|
89
|
+
jest.spyOn(events.user, "passwordUpdated")
|
|
90
|
+
jest.spyOn(events.user, "passwordResetRequested")
|
|
91
|
+
jest.spyOn(events.user, "passwordReset")
|
|
92
|
+
|
|
93
|
+
jest.spyOn(events.group, "created")
|
|
94
|
+
jest.spyOn(events.group, "updated")
|
|
95
|
+
jest.spyOn(events.group, "deleted")
|
|
96
|
+
jest.spyOn(events.group, "usersAdded")
|
|
97
|
+
jest.spyOn(events.group, "usersDeleted")
|
|
98
|
+
jest.spyOn(events.group, "createdOnboarding")
|
|
99
|
+
jest.spyOn(events.group, "permissionsEdited")
|
|
100
|
+
|
|
101
|
+
jest.spyOn(events.serve, "servedBuilder")
|
|
102
|
+
jest.spyOn(events.serve, "servedApp")
|
|
103
|
+
jest.spyOn(events.serve, "servedAppPreview")
|
|
104
|
+
|
|
105
|
+
jest.spyOn(events.table, "created")
|
|
106
|
+
jest.spyOn(events.table, "updated")
|
|
107
|
+
jest.spyOn(events.table, "deleted")
|
|
108
|
+
jest.spyOn(events.table, "exported")
|
|
109
|
+
jest.spyOn(events.table, "imported")
|
|
110
|
+
|
|
111
|
+
jest.spyOn(events.view, "created")
|
|
112
|
+
jest.spyOn(events.view, "updated")
|
|
113
|
+
jest.spyOn(events.view, "deleted")
|
|
114
|
+
jest.spyOn(events.view, "exported")
|
|
115
|
+
jest.spyOn(events.view, "filterCreated")
|
|
116
|
+
jest.spyOn(events.view, "filterUpdated")
|
|
117
|
+
jest.spyOn(events.view, "filterDeleted")
|
|
118
|
+
jest.spyOn(events.view, "calculationCreated")
|
|
119
|
+
jest.spyOn(events.view, "calculationUpdated")
|
|
120
|
+
jest.spyOn(events.view, "calculationDeleted")
|
|
121
|
+
|
|
122
|
+
jest.spyOn(events.plugin, "init")
|
|
123
|
+
jest.spyOn(events.plugin, "imported")
|
|
124
|
+
jest.spyOn(events.plugin, "deleted")
|
|
125
|
+
|
|
126
|
+
jest.spyOn(events.license, "planChanged")
|
|
127
|
+
jest.spyOn(events.license, "activated")
|
|
128
|
+
jest.spyOn(events.license, "checkoutOpened")
|
|
129
|
+
jest.spyOn(events.license, "checkoutSuccess")
|
|
130
|
+
jest.spyOn(events.license, "portalOpened")
|
|
131
|
+
jest.spyOn(events.license, "paymentFailed")
|
|
132
|
+
jest.spyOn(events.license, "paymentRecovered")
|
|
133
|
+
})
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const mockFetch = jest.fn((url: any, opts: any) => {
|
|
2
|
+
const fetch = jest.requireActual("node-fetch")
|
|
3
|
+
const env = jest.requireActual("../../../../src/environment").default
|
|
4
|
+
if (url.includes(env.COUCH_DB_URL) || url.includes("raw.github")) {
|
|
5
|
+
return fetch(url, opts)
|
|
6
|
+
}
|
|
7
|
+
return undefined
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
const enable = () => {
|
|
11
|
+
jest.mock("node-fetch", () => mockFetch)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
...mockFetch,
|
|
16
|
+
enable,
|
|
17
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
jest.mock("
|
|
2
|
-
import * as _accounts from "
|
|
1
|
+
jest.mock("../../../../src/accounts")
|
|
2
|
+
import * as _accounts from "../../../../src/accounts"
|
|
3
3
|
export const accounts = jest.mocked(_accounts)
|
|
4
4
|
|
|
5
5
|
export * as date from "./date"
|
|
6
6
|
export * as licenses from "./licenses"
|
|
7
7
|
export { default as fetch } from "./fetch"
|
|
8
|
-
|
|
8
|
+
export * from "./alerts"
|
|
9
9
|
import "./events"
|
|
10
|
+
import "./posthog"
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import Chance from "chance"
|
|
2
|
+
|
|
3
|
+
export default class CustomChance extends Chance {
|
|
4
|
+
arrayOf<T>(
|
|
5
|
+
generateFn: () => T,
|
|
6
|
+
opts: { min?: number; max?: number } = {}
|
|
7
|
+
): T[] {
|
|
8
|
+
const itemCount = this.integer({
|
|
9
|
+
min: opts.min != null ? opts.min : 1,
|
|
10
|
+
max: opts.max != null ? opts.max : 50,
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const items = []
|
|
14
|
+
for (let i = 0; i < itemCount; i++) {
|
|
15
|
+
items.push(generateFn())
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return items
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { generator, uuid } from "."
|
|
2
|
-
import
|
|
1
|
+
import { generator, uuid, quotas } from "."
|
|
2
|
+
import { generateGlobalUserID } from "../../../../src/docIds"
|
|
3
3
|
import {
|
|
4
4
|
Account,
|
|
5
5
|
AccountSSOProvider,
|
|
@@ -28,6 +28,7 @@ export const account = (): Account => {
|
|
|
28
28
|
name: generator.name(),
|
|
29
29
|
size: "10+",
|
|
30
30
|
profession: "Software Engineer",
|
|
31
|
+
quotaUsage: quotas.usage(),
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -39,7 +40,7 @@ export const cloudAccount = (): CloudAccount => {
|
|
|
39
40
|
return {
|
|
40
41
|
...account(),
|
|
41
42
|
hosting: Hosting.CLOUD,
|
|
42
|
-
budibaseUserId:
|
|
43
|
+
budibaseUserId: generateGlobalUserID(),
|
|
43
44
|
}
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { generator } from "."
|
|
2
2
|
import { App } from "@budibase/types"
|
|
3
|
-
import { DEFAULT_TENANT_ID, DocumentType } from "
|
|
3
|
+
import { DEFAULT_TENANT_ID, DocumentType } from "../../../../src/constants"
|
|
4
4
|
|
|
5
5
|
export function app(id: string): App {
|
|
6
6
|
return {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import Chance from "
|
|
1
|
+
import Chance from "./Chance"
|
|
2
2
|
export const generator = new Chance()
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Billing,
|
|
3
|
+
Customer,
|
|
4
|
+
Feature,
|
|
5
|
+
License,
|
|
6
|
+
PlanModel,
|
|
7
|
+
PlanType,
|
|
8
|
+
PriceDuration,
|
|
9
|
+
PurchasedPlan,
|
|
10
|
+
PurchasedPrice,
|
|
11
|
+
Quotas,
|
|
12
|
+
Subscription,
|
|
13
|
+
} from "@budibase/types"
|
|
14
|
+
|
|
15
|
+
export function price(): PurchasedPrice {
|
|
16
|
+
return {
|
|
17
|
+
amount: 10000,
|
|
18
|
+
amountMonthly: 10000,
|
|
19
|
+
currency: "usd",
|
|
20
|
+
duration: PriceDuration.MONTHLY,
|
|
21
|
+
priceId: "price_123",
|
|
22
|
+
dayPasses: undefined,
|
|
23
|
+
isPerUser: true,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const plan = (type: PlanType = PlanType.FREE): PurchasedPlan => {
|
|
28
|
+
return {
|
|
29
|
+
type,
|
|
30
|
+
usesInvoicing: false,
|
|
31
|
+
model: PlanModel.PER_USER,
|
|
32
|
+
price: type !== PlanType.FREE ? price() : undefined,
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function quotas(): Quotas {
|
|
37
|
+
return {
|
|
38
|
+
usage: {
|
|
39
|
+
monthly: {
|
|
40
|
+
queries: {
|
|
41
|
+
name: "Queries",
|
|
42
|
+
value: 1,
|
|
43
|
+
triggers: [],
|
|
44
|
+
},
|
|
45
|
+
automations: {
|
|
46
|
+
name: "Queries",
|
|
47
|
+
value: 1,
|
|
48
|
+
triggers: [],
|
|
49
|
+
},
|
|
50
|
+
dayPasses: {
|
|
51
|
+
name: "Queries",
|
|
52
|
+
value: 1,
|
|
53
|
+
triggers: [],
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
static: {
|
|
57
|
+
rows: {
|
|
58
|
+
name: "Rows",
|
|
59
|
+
value: 1,
|
|
60
|
+
triggers: [],
|
|
61
|
+
},
|
|
62
|
+
apps: {
|
|
63
|
+
name: "Apps",
|
|
64
|
+
value: 1,
|
|
65
|
+
triggers: [],
|
|
66
|
+
},
|
|
67
|
+
users: {
|
|
68
|
+
name: "Users",
|
|
69
|
+
value: 1,
|
|
70
|
+
triggers: [],
|
|
71
|
+
},
|
|
72
|
+
userGroups: {
|
|
73
|
+
name: "User Groups",
|
|
74
|
+
value: 1,
|
|
75
|
+
triggers: [],
|
|
76
|
+
},
|
|
77
|
+
plugins: {
|
|
78
|
+
name: "Plugins",
|
|
79
|
+
value: 1,
|
|
80
|
+
triggers: [],
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
constant: {
|
|
85
|
+
automationLogRetentionDays: {
|
|
86
|
+
name: "Automation Logs",
|
|
87
|
+
value: 1,
|
|
88
|
+
triggers: [],
|
|
89
|
+
},
|
|
90
|
+
appBackupRetentionDays: {
|
|
91
|
+
name: "Backups",
|
|
92
|
+
value: 1,
|
|
93
|
+
triggers: [],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function billing(
|
|
100
|
+
opts: { customer?: Customer; subscription?: Subscription } = {}
|
|
101
|
+
): Billing {
|
|
102
|
+
return {
|
|
103
|
+
customer: opts.customer || customer(),
|
|
104
|
+
subscription: opts.subscription || subscription(),
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function customer(): Customer {
|
|
109
|
+
return {
|
|
110
|
+
balance: 0,
|
|
111
|
+
currency: "usd",
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function subscription(): Subscription {
|
|
116
|
+
return {
|
|
117
|
+
amount: 10000,
|
|
118
|
+
cancelAt: undefined,
|
|
119
|
+
currency: "usd",
|
|
120
|
+
currentPeriodEnd: 0,
|
|
121
|
+
currentPeriodStart: 0,
|
|
122
|
+
downgradeAt: 0,
|
|
123
|
+
duration: PriceDuration.MONTHLY,
|
|
124
|
+
pastDueAt: undefined,
|
|
125
|
+
quantity: 0,
|
|
126
|
+
status: "active",
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const license = (
|
|
131
|
+
opts: {
|
|
132
|
+
quotas?: Quotas
|
|
133
|
+
plan?: PurchasedPlan
|
|
134
|
+
planType?: PlanType
|
|
135
|
+
features?: Feature[]
|
|
136
|
+
billing?: Billing
|
|
137
|
+
} = {}
|
|
138
|
+
): License => {
|
|
139
|
+
return {
|
|
140
|
+
features: opts.features || [],
|
|
141
|
+
quotas: opts.quotas || quotas(),
|
|
142
|
+
plan: opts.plan || plan(opts.planType),
|
|
143
|
+
billing: opts.billing || billing(),
|
|
144
|
+
}
|
|
145
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { MonthlyQuotaName, QuotaUsage } from "@budibase/types"
|
|
2
|
+
|
|
3
|
+
export const usage = (): QuotaUsage => {
|
|
4
|
+
return {
|
|
5
|
+
_id: "usage_quota",
|
|
6
|
+
quotaReset: new Date().toISOString(),
|
|
7
|
+
apps: {
|
|
8
|
+
app_1: {
|
|
9
|
+
// @ts-ignore - the apps definition doesn't match up to actual usage
|
|
10
|
+
usageQuota: {
|
|
11
|
+
rows: 0,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
monthly: {
|
|
16
|
+
"01-2023": {
|
|
17
|
+
automations: 0,
|
|
18
|
+
dayPasses: 0,
|
|
19
|
+
queries: 0,
|
|
20
|
+
triggers: {},
|
|
21
|
+
breakdown: {
|
|
22
|
+
rowQueries: {
|
|
23
|
+
parent: MonthlyQuotaName.QUERIES,
|
|
24
|
+
values: {
|
|
25
|
+
row_1: 0,
|
|
26
|
+
row_2: 0,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
datasourceQueries: {
|
|
30
|
+
parent: MonthlyQuotaName.QUERIES,
|
|
31
|
+
values: {
|
|
32
|
+
ds_1: 0,
|
|
33
|
+
ds_2: 0,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
automations: {
|
|
37
|
+
parent: MonthlyQuotaName.AUTOMATIONS,
|
|
38
|
+
values: {
|
|
39
|
+
auto_1: 0,
|
|
40
|
+
auto_2: 0,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
"02-2023": {
|
|
46
|
+
automations: 0,
|
|
47
|
+
dayPasses: 0,
|
|
48
|
+
queries: 0,
|
|
49
|
+
triggers: {},
|
|
50
|
+
},
|
|
51
|
+
current: {
|
|
52
|
+
automations: 0,
|
|
53
|
+
dayPasses: 0,
|
|
54
|
+
queries: 0,
|
|
55
|
+
triggers: {},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
usageQuota: {
|
|
59
|
+
apps: 0,
|
|
60
|
+
plugins: 0,
|
|
61
|
+
users: 0,
|
|
62
|
+
userGroups: 0,
|
|
63
|
+
rows: 0,
|
|
64
|
+
triggers: {},
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
}
|