@budibase/backend-core 2.5.8 → 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
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
Event,
|
|
4
4
|
LicenseActivatedEvent,
|
|
5
5
|
LicensePlanChangedEvent,
|
|
6
|
-
LicenseTierChangedEvent,
|
|
7
6
|
PlanType,
|
|
8
7
|
Account,
|
|
9
8
|
LicensePortalOpenedEvent,
|
|
@@ -11,22 +10,23 @@ import {
|
|
|
11
10
|
LicenseCheckoutOpenedEvent,
|
|
12
11
|
LicensePaymentFailedEvent,
|
|
13
12
|
LicensePaymentRecoveredEvent,
|
|
13
|
+
PriceDuration,
|
|
14
14
|
} from "@budibase/types"
|
|
15
15
|
|
|
16
|
-
async function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
async function planChanged(
|
|
17
|
+
account: Account,
|
|
18
|
+
opts: {
|
|
19
|
+
from: PlanType
|
|
20
|
+
to: PlanType
|
|
21
|
+
fromQuantity: number | undefined
|
|
22
|
+
toQuantity: number | undefined
|
|
23
|
+
fromDuration: PriceDuration | undefined
|
|
24
|
+
toDuration: PriceDuration | undefined
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async function planChanged(account: Account, from: PlanType, to: PlanType) {
|
|
26
|
+
) {
|
|
26
27
|
const properties: LicensePlanChangedEvent = {
|
|
27
28
|
accountId: account.accountId,
|
|
28
|
-
|
|
29
|
-
from,
|
|
29
|
+
...opts,
|
|
30
30
|
}
|
|
31
31
|
await publishEvent(Event.LICENSE_PLAN_CHANGED, properties)
|
|
32
32
|
}
|
|
@@ -74,7 +74,6 @@ async function paymentRecovered(account: Account) {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
export default {
|
|
77
|
-
tierChanged,
|
|
78
77
|
planChanged,
|
|
79
78
|
activated,
|
|
80
79
|
checkoutOpened,
|
|
@@ -15,10 +15,12 @@ import {
|
|
|
15
15
|
UserUpdatedEvent,
|
|
16
16
|
UserOnboardingEvent,
|
|
17
17
|
} from "@budibase/types"
|
|
18
|
+
import { isScim } from "../../context"
|
|
18
19
|
|
|
19
20
|
async function created(user: User, timestamp?: number) {
|
|
20
21
|
const properties: UserCreatedEvent = {
|
|
21
22
|
userId: user._id as string,
|
|
23
|
+
viaScim: isScim(),
|
|
22
24
|
audited: {
|
|
23
25
|
email: user.email,
|
|
24
26
|
},
|
|
@@ -29,6 +31,7 @@ async function created(user: User, timestamp?: number) {
|
|
|
29
31
|
async function updated(user: User) {
|
|
30
32
|
const properties: UserUpdatedEvent = {
|
|
31
33
|
userId: user._id as string,
|
|
34
|
+
viaScim: isScim(),
|
|
32
35
|
audited: {
|
|
33
36
|
email: user.email,
|
|
34
37
|
},
|
|
@@ -39,6 +42,7 @@ async function updated(user: User) {
|
|
|
39
42
|
async function deleted(user: User) {
|
|
40
43
|
const properties: UserDeletedEvent = {
|
|
41
44
|
userId: user._id as string,
|
|
45
|
+
viaScim: isScim(),
|
|
42
46
|
audited: {
|
|
43
47
|
email: user.email,
|
|
44
48
|
},
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export * as errors from "./errors"
|
|
|
27
27
|
export * as timers from "./timers"
|
|
28
28
|
export { default as env } from "./environment"
|
|
29
29
|
export * as blacklist from "./blacklist"
|
|
30
|
+
export * as docUpdates from "./docUpdates"
|
|
30
31
|
export { SearchParams } from "./db"
|
|
31
32
|
// Add context to tenancy for backwards compatibility
|
|
32
33
|
// only do this for external usages to prevent internal
|
package/src/installation.ts
CHANGED
|
@@ -6,8 +6,7 @@ import { Installation, IdentityType, Database } from "@budibase/types"
|
|
|
6
6
|
import * as context from "./context"
|
|
7
7
|
import semver from "semver"
|
|
8
8
|
import { bustCache, withCache, TTL, CacheKey } from "./cache/generic"
|
|
9
|
-
|
|
10
|
-
const pkg = require("../package.json")
|
|
9
|
+
import environment from "./environment"
|
|
11
10
|
|
|
12
11
|
export const getInstall = async (): Promise<Installation> => {
|
|
13
12
|
return withCache(CacheKey.INSTALLATION, TTL.ONE_DAY, getInstallFromDB, {
|
|
@@ -18,7 +17,7 @@ async function createInstallDoc(platformDb: Database) {
|
|
|
18
17
|
const install: Installation = {
|
|
19
18
|
_id: StaticDatabases.PLATFORM_INFO.docs.install,
|
|
20
19
|
installId: newid(),
|
|
21
|
-
version:
|
|
20
|
+
version: environment.VERSION,
|
|
22
21
|
}
|
|
23
22
|
try {
|
|
24
23
|
const resp = await platformDb.put(install)
|
|
@@ -33,7 +32,7 @@ async function createInstallDoc(platformDb: Database) {
|
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
34
|
|
|
36
|
-
const getInstallFromDB = async (): Promise<Installation> => {
|
|
35
|
+
export const getInstallFromDB = async (): Promise<Installation> => {
|
|
37
36
|
return doWithDB(
|
|
38
37
|
StaticDatabases.PLATFORM_INFO.name,
|
|
39
38
|
async (platformDb: any) => {
|
|
@@ -80,7 +79,7 @@ export const checkInstallVersion = async (): Promise<void> => {
|
|
|
80
79
|
const install = await getInstall()
|
|
81
80
|
|
|
82
81
|
const currentVersion = install.version
|
|
83
|
-
const newVersion =
|
|
82
|
+
const newVersion = environment.VERSION
|
|
84
83
|
|
|
85
84
|
if (currentVersion !== newVersion) {
|
|
86
85
|
const isUpgrade = semver.gt(newVersion, currentVersion)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const NonErrors = ["AccountError"]
|
|
2
|
+
|
|
3
|
+
function isSuppressed(e?: any) {
|
|
4
|
+
return e && e["suppressAlert"]
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function logAlert(message: string, e?: any) {
|
|
8
|
+
if (e && NonErrors.includes(e.name) && isSuppressed(e)) {
|
|
9
|
+
return
|
|
10
|
+
}
|
|
11
|
+
console.error(`bb-alert: ${message}`, e)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function logAlertWithInfo(
|
|
15
|
+
message: string,
|
|
16
|
+
db: string,
|
|
17
|
+
id: string,
|
|
18
|
+
error: any
|
|
19
|
+
) {
|
|
20
|
+
message = `${message} - db: ${db} - doc: ${id} - error: `
|
|
21
|
+
logAlert(message, error)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function logWarn(message: string) {
|
|
25
|
+
console.warn(`bb-warn: ${message}`)
|
|
26
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Header } from "../../constants"
|
|
2
|
+
const correlator = require("correlation-id")
|
|
3
|
+
|
|
4
|
+
export const setHeader = (headers: any) => {
|
|
5
|
+
const correlationId = correlator.getId()
|
|
6
|
+
if (correlationId) {
|
|
7
|
+
headers[Header.CORRELATION_ID] = correlationId
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getId() {
|
|
12
|
+
return correlator.getId()
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./correlation"
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Header } from "../../constants"
|
|
2
|
+
import { v4 as uuid } from "uuid"
|
|
3
|
+
const correlator = require("correlation-id")
|
|
4
|
+
|
|
5
|
+
const correlation = (ctx: any, next: any) => {
|
|
6
|
+
// use the provided correlation id header if present
|
|
7
|
+
let correlationId = ctx.headers[Header.CORRELATION_ID]
|
|
8
|
+
if (!correlationId) {
|
|
9
|
+
correlationId = uuid()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return correlator.withId(correlationId, () => {
|
|
13
|
+
return next()
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default correlation
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import env from "../../environment"
|
|
2
|
+
import pino, { LoggerOptions } from "pino"
|
|
3
|
+
import * as context from "../../context"
|
|
4
|
+
import * as correlation from "../correlation"
|
|
5
|
+
import { IdentityType } from "@budibase/types"
|
|
6
|
+
import { LOG_CONTEXT } from "../index"
|
|
7
|
+
|
|
8
|
+
// LOGGER
|
|
9
|
+
|
|
10
|
+
let pinoInstance: pino.Logger | undefined
|
|
11
|
+
if (!env.DISABLE_PINO_LOGGER) {
|
|
12
|
+
const pinoOptions: LoggerOptions = {
|
|
13
|
+
level: env.LOG_LEVEL,
|
|
14
|
+
formatters: {
|
|
15
|
+
level: label => {
|
|
16
|
+
return { level: label.toUpperCase() }
|
|
17
|
+
},
|
|
18
|
+
bindings: () => {
|
|
19
|
+
return {}
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
timestamp: () => `,"timestamp":"${new Date(Date.now()).toISOString()}"`,
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (env.isDev()) {
|
|
26
|
+
pinoOptions.transport = {
|
|
27
|
+
target: "pino-pretty",
|
|
28
|
+
options: {
|
|
29
|
+
singleLine: true,
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pinoInstance = pino(pinoOptions)
|
|
35
|
+
|
|
36
|
+
// CONSOLE OVERRIDES
|
|
37
|
+
|
|
38
|
+
interface MergingObject {
|
|
39
|
+
objects?: any[]
|
|
40
|
+
tenantId?: string
|
|
41
|
+
appId?: string
|
|
42
|
+
identityId?: string
|
|
43
|
+
identityType?: IdentityType
|
|
44
|
+
correlationId?: string
|
|
45
|
+
err?: Error
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function isPlainObject(obj: any) {
|
|
49
|
+
return typeof obj === "object" && obj !== null && !(obj instanceof Error)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function isError(obj: any) {
|
|
53
|
+
return obj instanceof Error
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isMessage(obj: any) {
|
|
57
|
+
return typeof obj === "string"
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Backwards compatibility between console logging statements
|
|
62
|
+
* and pino logging requirements.
|
|
63
|
+
*/
|
|
64
|
+
function getLogParams(args: any[]): [MergingObject, string] {
|
|
65
|
+
let error = undefined
|
|
66
|
+
let objects: any[] = []
|
|
67
|
+
let message = ""
|
|
68
|
+
|
|
69
|
+
args.forEach(arg => {
|
|
70
|
+
if (isMessage(arg)) {
|
|
71
|
+
message = `${message} ${arg}`.trimStart()
|
|
72
|
+
}
|
|
73
|
+
if (isPlainObject(arg)) {
|
|
74
|
+
objects.push(arg)
|
|
75
|
+
}
|
|
76
|
+
if (isError(arg)) {
|
|
77
|
+
error = arg
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const identity = getIdentity()
|
|
82
|
+
|
|
83
|
+
let contextObject = {}
|
|
84
|
+
|
|
85
|
+
if (LOG_CONTEXT) {
|
|
86
|
+
contextObject = {
|
|
87
|
+
tenantId: getTenantId(),
|
|
88
|
+
appId: getAppId(),
|
|
89
|
+
identityId: identity?._id,
|
|
90
|
+
identityType: identity?.type,
|
|
91
|
+
correlationId: correlation.getId(),
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const mergingObject = {
|
|
96
|
+
objects: objects.length ? objects : undefined,
|
|
97
|
+
err: error,
|
|
98
|
+
...contextObject,
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return [mergingObject, message]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
console.log = (...arg: any[]) => {
|
|
105
|
+
const [obj, msg] = getLogParams(arg)
|
|
106
|
+
pinoInstance?.info(obj, msg)
|
|
107
|
+
}
|
|
108
|
+
console.info = (...arg: any[]) => {
|
|
109
|
+
const [obj, msg] = getLogParams(arg)
|
|
110
|
+
pinoInstance?.info(obj, msg)
|
|
111
|
+
}
|
|
112
|
+
console.warn = (...arg: any[]) => {
|
|
113
|
+
const [obj, msg] = getLogParams(arg)
|
|
114
|
+
pinoInstance?.warn(obj, msg)
|
|
115
|
+
}
|
|
116
|
+
console.error = (...arg: any[]) => {
|
|
117
|
+
const [obj, msg] = getLogParams(arg)
|
|
118
|
+
pinoInstance?.error(obj, msg)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* custom trace impl - this resembles the node trace behaviour rather
|
|
123
|
+
* than traditional trace logging
|
|
124
|
+
* @param arg
|
|
125
|
+
*/
|
|
126
|
+
console.trace = (...arg: any[]) => {
|
|
127
|
+
const [obj, msg] = getLogParams(arg)
|
|
128
|
+
if (!obj.err) {
|
|
129
|
+
// to get stack trace
|
|
130
|
+
obj.err = new Error()
|
|
131
|
+
}
|
|
132
|
+
pinoInstance?.trace(obj, msg)
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.debug = (...arg: any) => {
|
|
136
|
+
const [obj, msg] = getLogParams(arg)
|
|
137
|
+
pinoInstance?.debug(obj, msg)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// CONTEXT
|
|
141
|
+
|
|
142
|
+
const getTenantId = () => {
|
|
143
|
+
let tenantId
|
|
144
|
+
try {
|
|
145
|
+
tenantId = context.getTenantId()
|
|
146
|
+
} catch (e: any) {
|
|
147
|
+
// do nothing
|
|
148
|
+
}
|
|
149
|
+
return tenantId
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const getAppId = () => {
|
|
153
|
+
let appId
|
|
154
|
+
try {
|
|
155
|
+
appId = context.getAppId()
|
|
156
|
+
} catch (e) {
|
|
157
|
+
// do nothing
|
|
158
|
+
}
|
|
159
|
+
return appId
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const getIdentity = () => {
|
|
163
|
+
let identity
|
|
164
|
+
try {
|
|
165
|
+
identity = context.getIdentity()
|
|
166
|
+
} catch (e) {
|
|
167
|
+
// do nothing
|
|
168
|
+
}
|
|
169
|
+
return identity
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export const logger = pinoInstance
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import env from "../../environment"
|
|
2
|
+
import { logger } from "./logger"
|
|
3
|
+
import { IncomingMessage } from "http"
|
|
4
|
+
const pino = require("koa-pino-logger")
|
|
5
|
+
import { Options } from "pino-http"
|
|
6
|
+
import { Ctx } from "@budibase/types"
|
|
7
|
+
const correlator = require("correlation-id")
|
|
8
|
+
|
|
9
|
+
export function pinoSettings(): Options {
|
|
10
|
+
return {
|
|
11
|
+
logger,
|
|
12
|
+
genReqId: correlator.getId,
|
|
13
|
+
autoLogging: {
|
|
14
|
+
ignore: (req: IncomingMessage) => !!req.url?.includes("/health"),
|
|
15
|
+
},
|
|
16
|
+
serializers: {
|
|
17
|
+
req: req => {
|
|
18
|
+
return {
|
|
19
|
+
method: req.method,
|
|
20
|
+
url: req.url,
|
|
21
|
+
correlationId: req.id,
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
res: res => {
|
|
25
|
+
return {
|
|
26
|
+
status: res.statusCode,
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getMiddleware() {
|
|
34
|
+
if (env.HTTP_LOGGING) {
|
|
35
|
+
return pino(pinoSettings())
|
|
36
|
+
} else {
|
|
37
|
+
return (ctx: Ctx, next: any) => {
|
|
38
|
+
return next()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const pinoMiddleware = getMiddleware()
|
|
44
|
+
|
|
45
|
+
export default pinoMiddleware
|
|
@@ -44,7 +44,7 @@ async function checkApiKey(apiKey: string, populateUser?: Function) {
|
|
|
44
44
|
// check both the primary and the fallback internal api keys
|
|
45
45
|
// this allows for rotation
|
|
46
46
|
if (isValidInternalAPIKey(apiKey)) {
|
|
47
|
-
return { valid: true }
|
|
47
|
+
return { valid: true, user: undefined }
|
|
48
48
|
}
|
|
49
49
|
const decrypted = decrypt(apiKey)
|
|
50
50
|
const tenantId = decrypted.split(SEPARATOR)[0]
|
|
@@ -96,9 +96,15 @@ export default function (
|
|
|
96
96
|
}
|
|
97
97
|
try {
|
|
98
98
|
// check the actual user is authenticated first, try header or cookie
|
|
99
|
-
|
|
99
|
+
let headerToken = ctx.request.headers[Header.TOKEN]
|
|
100
|
+
|
|
100
101
|
const authCookie = getCookie(ctx, Cookie.Auth) || openJwt(headerToken)
|
|
101
|
-
|
|
102
|
+
let apiKey = ctx.request.headers[Header.API_KEY]
|
|
103
|
+
|
|
104
|
+
if (!apiKey && ctx.request.headers[Header.AUTHORIZATION]) {
|
|
105
|
+
apiKey = ctx.request.headers[Header.AUTHORIZATION].split(" ")[1]
|
|
106
|
+
}
|
|
107
|
+
|
|
102
108
|
const tenantId = ctx.request.headers[Header.TENANT_ID]
|
|
103
109
|
let authenticated = false,
|
|
104
110
|
user = null,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { APIError } from "@budibase/types"
|
|
2
2
|
import * as errors from "../errors"
|
|
3
|
-
import env from "../environment"
|
|
4
3
|
|
|
5
4
|
export async function errorHandling(ctx: any, next: any) {
|
|
6
5
|
try {
|
|
@@ -9,9 +8,10 @@ export async function errorHandling(ctx: any, next: any) {
|
|
|
9
8
|
const status = err.status || err.statusCode || 500
|
|
10
9
|
ctx.status = status
|
|
11
10
|
|
|
12
|
-
if (status
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
if (status >= 400 && status < 500) {
|
|
12
|
+
console.warn(err)
|
|
13
|
+
} else {
|
|
14
|
+
console.error(err)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const error = errors.getPublicError(err)
|
package/src/middleware/index.ts
CHANGED
|
@@ -14,7 +14,8 @@ export { default as csrf } from "./csrf"
|
|
|
14
14
|
export { default as adminOnly } from "./adminOnly"
|
|
15
15
|
export { default as builderOrAdmin } from "./builderOrAdmin"
|
|
16
16
|
export { default as builderOnly } from "./builderOnly"
|
|
17
|
-
export { default as
|
|
17
|
+
export { default as pino } from "../logging/pino/middleware"
|
|
18
|
+
export { default as correlation } from "../logging/correlation/middleware"
|
|
18
19
|
export { default as errorHandling } from "./errorHandling"
|
|
19
20
|
export { default as querystringToBody } from "./querystringToBody"
|
|
20
21
|
export * as joiValidator from "./joi-validator"
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fetch from "node-fetch"
|
|
2
2
|
import * as sso from "./sso"
|
|
3
3
|
import { ssoCallbackUrl } from "../utils"
|
|
4
|
+
import { validEmail } from "../../../utils"
|
|
4
5
|
import {
|
|
5
6
|
ConfigType,
|
|
6
7
|
OIDCInnerConfig,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
JwtClaims,
|
|
12
13
|
SaveSSOUserFunction,
|
|
13
14
|
} from "@budibase/types"
|
|
15
|
+
|
|
14
16
|
const OIDCStrategy = require("@techpass/passport-openidconnect").Strategy
|
|
15
17
|
|
|
16
18
|
export function buildVerifyFn(saveUserFn: SaveSSOUserFunction) {
|
|
@@ -86,15 +88,6 @@ function getEmail(profile: SSOProfile, jwtClaims: JwtClaims) {
|
|
|
86
88
|
)
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
function validEmail(value: string) {
|
|
90
|
-
return (
|
|
91
|
-
value &&
|
|
92
|
-
!!value.match(
|
|
93
|
-
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
|
|
94
|
-
)
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
91
|
/**
|
|
99
92
|
* Create an instance of the oidc passport strategy. This wrapper fetches the configuration
|
|
100
93
|
* from couchDB rather than environment variables, using this factory is necessary for dynamically configuring passport.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { structures,
|
|
1
|
+
import { structures, mocks } from "../../../../../tests"
|
|
2
|
+
import { testEnv } from "../../../../../tests/extra"
|
|
2
3
|
import { SSOAuthDetails, User } from "@budibase/types"
|
|
3
4
|
|
|
4
5
|
import { HTTPError } from "../../../../errors"
|
|
@@ -99,9 +99,7 @@ export const runMigration = async (
|
|
|
99
99
|
options.force[migrationType] &&
|
|
100
100
|
options.force[migrationType].includes(migrationName)
|
|
101
101
|
) {
|
|
102
|
-
log(
|
|
103
|
-
`[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Forcing`
|
|
104
|
-
)
|
|
102
|
+
log(`[Migration: ${migrationName}] [DB: ${dbName}] Forcing`)
|
|
105
103
|
} else {
|
|
106
104
|
// no force, exit
|
|
107
105
|
return
|
|
@@ -111,7 +109,7 @@ export const runMigration = async (
|
|
|
111
109
|
// check if the migration is not a no-op
|
|
112
110
|
if (!options.noOp) {
|
|
113
111
|
log(
|
|
114
|
-
`[
|
|
112
|
+
`[Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}`
|
|
115
113
|
)
|
|
116
114
|
|
|
117
115
|
if (migration.preventRetry) {
|
|
@@ -131,9 +129,7 @@ export const runMigration = async (
|
|
|
131
129
|
await migration.fn(db)
|
|
132
130
|
}
|
|
133
131
|
|
|
134
|
-
log(
|
|
135
|
-
`[Tenant: ${tenantId}] [Migration: ${migrationName}] [DB: ${dbName}] Complete`
|
|
136
|
-
)
|
|
132
|
+
log(`[Migration: ${migrationName}] [DB: ${dbName}] Complete`)
|
|
137
133
|
}
|
|
138
134
|
|
|
139
135
|
// mark as complete
|
|
@@ -141,7 +137,7 @@ export const runMigration = async (
|
|
|
141
137
|
await db.put(doc)
|
|
142
138
|
} catch (err) {
|
|
143
139
|
console.error(
|
|
144
|
-
`[
|
|
140
|
+
`[Migration: ${migrationName}] [DB: ${dbName}] Error: `,
|
|
145
141
|
err
|
|
146
142
|
)
|
|
147
143
|
throw err
|
|
@@ -3,7 +3,7 @@ import AWS from "aws-sdk"
|
|
|
3
3
|
import stream from "stream"
|
|
4
4
|
import fetch from "node-fetch"
|
|
5
5
|
import tar from "tar-fs"
|
|
6
|
-
|
|
6
|
+
import zlib from "zlib"
|
|
7
7
|
import { promisify } from "util"
|
|
8
8
|
import { join } from "path"
|
|
9
9
|
import fs from "fs"
|
|
@@ -415,7 +415,7 @@ export const downloadTarballDirect = async (
|
|
|
415
415
|
throw new Error(`unexpected response ${response.statusText}`)
|
|
416
416
|
}
|
|
417
417
|
|
|
418
|
-
await streamPipeline(response.body, zlib.
|
|
418
|
+
await streamPipeline(response.body, zlib.createUnzip(), tar.extract(path))
|
|
419
419
|
}
|
|
420
420
|
|
|
421
421
|
export const downloadTarball = async (
|
|
@@ -431,7 +431,7 @@ export const downloadTarball = async (
|
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
const tmpPath = join(budibaseTempDir(), path)
|
|
434
|
-
await streamPipeline(response.body, zlib.
|
|
434
|
+
await streamPipeline(response.body, zlib.createUnzip(), tar.extract(tmpPath))
|
|
435
435
|
if (!env.isTest() && env.SELF_HOSTED) {
|
|
436
436
|
await uploadDirectory(bucketName, tmpPath, path)
|
|
437
437
|
}
|