@budibase/backend-core 2.9.38 → 2.9.39-alpha.1
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/index.js +3027 -3025
- package/dist/index.js.map +4 -4
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +5 -5
- package/dist/plugins.js +1 -1
- package/dist/plugins.js.map +2 -2
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/accounts/accounts.js +100 -0
- package/dist/src/accounts/accounts.js.map +7 -0
- package/dist/src/accounts/api.js +78 -0
- package/dist/src/accounts/api.js.map +7 -0
- package/dist/src/accounts/index.js +23 -0
- package/dist/src/accounts/index.js.map +7 -0
- package/dist/src/auth/auth.js +208 -0
- package/dist/src/auth/auth.js.map +7 -0
- package/dist/src/auth/index.js +23 -0
- package/dist/src/auth/index.js.map +7 -0
- package/dist/src/auth/tests/auth.spec.js +37 -0
- package/dist/src/auth/tests/auth.spec.js.map +7 -0
- package/dist/src/blacklist/blacklist.js +88 -0
- package/dist/src/blacklist/blacklist.js.map +7 -0
- package/dist/src/blacklist/index.js +23 -0
- package/dist/src/blacklist/index.js.map +7 -0
- package/dist/src/blacklist/tests/blacklist.spec.js +61 -0
- package/dist/src/blacklist/tests/blacklist.spec.js.map +7 -0
- package/dist/src/cache/appMetadata.js +86 -0
- package/dist/src/cache/appMetadata.js.map +7 -0
- package/dist/src/cache/base/index.js +102 -0
- package/dist/src/cache/base/index.js.map +7 -0
- package/dist/src/cache/generic.js +69 -0
- package/dist/src/cache/generic.js.map +7 -0
- package/dist/src/cache/index.js +51 -0
- package/dist/src/cache/index.js.map +7 -0
- package/dist/src/cache/tests/writethrough.spec.js +132 -0
- package/dist/src/cache/tests/writethrough.spec.js.map +7 -0
- package/dist/src/cache/user.js +99 -0
- package/dist/src/cache/user.js.map +7 -0
- package/dist/src/cache/writethrough.js +144 -0
- package/dist/src/cache/writethrough.js.map +7 -0
- package/dist/src/configs/configs.js +228 -0
- package/dist/src/configs/configs.js.map +7 -0
- package/dist/src/configs/index.js +23 -0
- package/dist/src/configs/index.js.map +7 -0
- package/dist/src/configs/tests/configs.spec.js +182 -0
- package/dist/src/configs/tests/configs.spec.js.map +7 -0
- package/dist/src/constants/db.js +107 -0
- package/dist/src/constants/db.js.map +7 -0
- package/dist/src/constants/index.js +25 -0
- package/dist/src/constants/index.js.map +7 -0
- package/dist/src/constants/misc.js +92 -0
- package/dist/src/constants/misc.js.map +7 -0
- package/dist/src/context/Context.js +36 -0
- package/dist/src/context/Context.js.map +7 -0
- package/dist/src/context/identity.js +87 -0
- package/dist/src/context/identity.js.map +7 -0
- package/dist/src/context/index.js +45 -0
- package/dist/src/context/index.js.map +7 -0
- package/dist/src/context/mainContext.js +320 -0
- package/dist/src/context/mainContext.js.map +7 -0
- package/dist/src/context/tests/index.spec.js +147 -0
- package/dist/src/context/tests/index.spec.js.map +7 -0
- package/dist/src/context/types.js +17 -0
- package/dist/src/context/types.js.map +7 -0
- package/dist/src/db/Replication.js +89 -0
- package/dist/src/db/Replication.js.map +7 -0
- package/dist/src/db/constants.js +39 -0
- package/dist/src/db/constants.js.map +7 -0
- package/dist/src/db/couch/DatabaseImpl.js +224 -0
- package/dist/src/db/couch/DatabaseImpl.js.map +7 -0
- package/dist/src/db/couch/connections.js +103 -0
- package/dist/src/db/couch/connections.js.map +7 -0
- package/dist/src/db/couch/index.js +44 -0
- package/dist/src/db/couch/index.js.map +7 -0
- package/dist/src/db/couch/pouchDB.js +118 -0
- package/dist/src/db/couch/pouchDB.js.map +7 -0
- package/dist/src/db/couch/pouchDump.js +2 -0
- package/dist/src/db/couch/pouchDump.js.map +7 -0
- package/dist/src/db/couch/utils.js +76 -0
- package/dist/src/db/couch/utils.js.map +7 -0
- package/dist/src/db/db.d.ts +1 -1
- package/dist/src/db/db.js +73 -0
- package/dist/src/db/db.js.map +7 -0
- package/dist/src/db/errors.js +43 -0
- package/dist/src/db/errors.js.map +7 -0
- package/dist/src/db/index.js +64 -0
- package/dist/src/db/index.js.map +7 -0
- package/dist/src/db/lucene.d.ts +2 -1
- package/dist/src/db/lucene.js +595 -0
- package/dist/src/db/lucene.js.map +7 -0
- package/dist/src/db/searchIndexes/index.js +23 -0
- package/dist/src/db/searchIndexes/index.js.map +7 -0
- package/dist/src/db/searchIndexes/searchIndexes.js +82 -0
- package/dist/src/db/searchIndexes/searchIndexes.js.map +7 -0
- package/dist/src/db/tests/index.spec.js +24 -0
- package/dist/src/db/tests/index.spec.js.map +7 -0
- package/dist/src/db/tests/lucene.spec.js +312 -0
- package/dist/src/db/tests/lucene.spec.js.map +7 -0
- package/dist/src/db/tests/pouch.spec.js +63 -0
- package/dist/src/db/tests/pouch.spec.js.map +7 -0
- package/dist/src/db/tests/utils.spec.js +50 -0
- package/dist/src/db/tests/utils.spec.js.map +7 -0
- package/dist/src/db/utils.d.ts +1 -1
- package/dist/src/db/utils.js +198 -0
- package/dist/src/db/utils.js.map +7 -0
- package/dist/src/db/views.js +223 -0
- package/dist/src/db/views.js.map +7 -0
- package/dist/src/docIds/conversions.js +83 -0
- package/dist/src/docIds/conversions.js.map +7 -0
- package/dist/src/docIds/ids.js +101 -0
- package/dist/src/docIds/ids.js.map +7 -0
- package/dist/src/docIds/index.js +25 -0
- package/dist/src/docIds/index.js.map +7 -0
- package/dist/src/docIds/newid.js +32 -0
- package/dist/src/docIds/newid.js.map +7 -0
- package/dist/src/docIds/params.js +136 -0
- package/dist/src/docIds/params.js.map +7 -0
- package/dist/src/docUpdates/index.js +61 -0
- package/dist/src/docUpdates/index.js.map +7 -0
- package/dist/src/environment.js +181 -0
- package/dist/src/environment.js.map +7 -0
- package/dist/src/errors/errors.js +126 -0
- package/dist/src/errors/errors.js.map +7 -0
- package/dist/src/errors/index.js +23 -0
- package/dist/src/errors/index.js.map +7 -0
- package/dist/src/events/analytics.js +42 -0
- package/dist/src/events/analytics.js.map +7 -0
- package/dist/src/events/asyncEvents/index.js +25 -0
- package/dist/src/events/asyncEvents/index.js.map +7 -0
- package/dist/src/events/asyncEvents/publisher.js +39 -0
- package/dist/src/events/asyncEvents/publisher.js.map +7 -0
- package/dist/src/events/asyncEvents/queue.js +42 -0
- package/dist/src/events/asyncEvents/queue.js.map +7 -0
- package/dist/src/events/backfill.js +172 -0
- package/dist/src/events/backfill.js.map +7 -0
- package/dist/src/events/documentId.js +51 -0
- package/dist/src/events/documentId.js.map +7 -0
- package/dist/src/events/events.js +63 -0
- package/dist/src/events/events.js.map +7 -0
- package/dist/src/events/identification.js +275 -0
- package/dist/src/events/identification.js.map +7 -0
- package/dist/src/events/index.js +62 -0
- package/dist/src/events/index.js.map +7 -0
- package/dist/src/events/processors/AnalyticsProcessor.js +76 -0
- package/dist/src/events/processors/AnalyticsProcessor.js.map +7 -0
- package/dist/src/events/processors/AuditLogsProcessor.js +97 -0
- package/dist/src/events/processors/AuditLogsProcessor.js.map +7 -0
- package/dist/src/events/processors/LoggingProcessor.js +58 -0
- package/dist/src/events/processors/LoggingProcessor.js.map +7 -0
- package/dist/src/events/processors/Processors.js +57 -0
- package/dist/src/events/processors/Processors.js.map +7 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js +53 -0
- package/dist/src/events/processors/async/DocumentUpdateProcessor.js.map +7 -0
- package/dist/src/events/processors/index.js +57 -0
- package/dist/src/events/processors/index.js.map +7 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js +126 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js.map +7 -0
- package/dist/src/events/processors/posthog/index.js +36 -0
- package/dist/src/events/processors/posthog/index.js.map +7 -0
- package/dist/src/events/processors/posthog/rateLimiting.js +105 -0
- package/dist/src/events/processors/posthog/rateLimiting.js.map +7 -0
- package/dist/src/events/processors/posthog/tests/PosthogProcessor.spec.js +154 -0
- package/dist/src/events/processors/posthog/tests/PosthogProcessor.spec.js.map +7 -0
- package/dist/src/events/processors/types.js +29 -0
- package/dist/src/events/processors/types.js.map +7 -0
- package/dist/src/events/publishers/account.js +49 -0
- package/dist/src/events/publishers/account.js.map +7 -0
- package/dist/src/events/publishers/app.js +145 -0
- package/dist/src/events/publishers/app.js.map +7 -0
- package/dist/src/events/publishers/auditLog.js +42 -0
- package/dist/src/events/publishers/auditLog.js.map +7 -0
- package/dist/src/events/publishers/auth.js +80 -0
- package/dist/src/events/publishers/auth.js.map +7 -0
- package/dist/src/events/publishers/automation.js +111 -0
- package/dist/src/events/publishers/automation.js.map +7 -0
- package/dist/src/events/publishers/backfill.js +92 -0
- package/dist/src/events/publishers/backfill.js.map +7 -0
- package/dist/src/events/publishers/backup.js +49 -0
- package/dist/src/events/publishers/backup.js.map +7 -0
- package/dist/src/events/publishers/datasource.js +59 -0
- package/dist/src/events/publishers/datasource.js.map +7 -0
- package/dist/src/events/publishers/email.js +38 -0
- package/dist/src/events/publishers/email.js.map +7 -0
- package/dist/src/events/publishers/environmentVariable.js +53 -0
- package/dist/src/events/publishers/environmentVariable.js.map +7 -0
- package/dist/src/events/publishers/group.js +105 -0
- package/dist/src/events/publishers/group.js.map +7 -0
- package/dist/src/events/publishers/index.js +108 -0
- package/dist/src/events/publishers/index.js.map +7 -0
- package/dist/src/events/publishers/installation.js +56 -0
- package/dist/src/events/publishers/installation.js.map +7 -0
- package/dist/src/events/publishers/layout.js +42 -0
- package/dist/src/events/publishers/layout.js.map +7 -0
- package/dist/src/events/publishers/license.js +78 -0
- package/dist/src/events/publishers/license.js.map +7 -0
- package/dist/src/events/publishers/org.js +53 -0
- package/dist/src/events/publishers/org.js.map +7 -0
- package/dist/src/events/publishers/plugin.js +61 -0
- package/dist/src/events/publishers/plugin.js.map +7 -0
- package/dist/src/events/publishers/query.js +85 -0
- package/dist/src/events/publishers/query.js.map +7 -0
- package/dist/src/events/publishers/role.js +71 -0
- package/dist/src/events/publishers/role.js.map +7 -0
- package/dist/src/events/publishers/rows.js +43 -0
- package/dist/src/events/publishers/rows.js.map +7 -0
- package/dist/src/events/publishers/screen.js +52 -0
- package/dist/src/events/publishers/screen.js.map +7 -0
- package/dist/src/events/publishers/serve.js +53 -0
- package/dist/src/events/publishers/serve.js.map +7 -0
- package/dist/src/events/publishers/table.js +79 -0
- package/dist/src/events/publishers/table.js.map +7 -0
- package/dist/src/events/publishers/user.js +191 -0
- package/dist/src/events/publishers/user.js.map +7 -0
- package/dist/src/events/publishers/view.js +102 -0
- package/dist/src/events/publishers/view.js.map +7 -0
- package/dist/src/{featureFlags → features}/index.d.ts +1 -0
- package/dist/src/features/index.js +105 -0
- package/dist/src/features/index.js.map +7 -0
- package/dist/src/features/installation.d.ts +1 -0
- package/dist/src/features/installation.js +42 -0
- package/dist/src/features/installation.js.map +7 -0
- package/dist/src/features/tests/featureFlags.spec.js +86 -0
- package/dist/src/features/tests/featureFlags.spec.js.map +7 -0
- package/dist/src/helpers.js +31 -0
- package/dist/src/helpers.js.map +7 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +154 -0
- package/dist/src/index.js.map +7 -0
- package/dist/src/installation.js +139 -0
- package/dist/src/installation.js.map +7 -0
- package/dist/src/logging/alerts.js +49 -0
- package/dist/src/logging/alerts.js.map +7 -0
- package/dist/src/logging/correlation/correlation.js +41 -0
- package/dist/src/logging/correlation/correlation.js.map +7 -0
- package/dist/src/logging/correlation/index.js +23 -0
- package/dist/src/logging/correlation/index.js.map +7 -0
- package/dist/src/logging/correlation/middleware.js +37 -0
- package/dist/src/logging/correlation/middleware.js.map +7 -0
- package/dist/src/logging/index.js +48 -0
- package/dist/src/logging/index.js.map +7 -0
- package/dist/src/logging/pino/logger.js +197 -0
- package/dist/src/logging/pino/logger.js.map +7 -0
- package/dist/src/logging/pino/middleware.js +77 -0
- package/dist/src/logging/pino/middleware.js.map +7 -0
- package/dist/src/logging/system.js +110 -0
- package/dist/src/logging/system.js.map +7 -0
- package/dist/src/logging/tests/system.spec.js +59 -0
- package/dist/src/logging/tests/system.spec.js.map +7 -0
- package/dist/src/middleware/adminOnly.js +31 -0
- package/dist/src/middleware/adminOnly.js.map +7 -0
- package/dist/src/middleware/auditLog.js +27 -0
- package/dist/src/middleware/auditLog.js.map +7 -0
- package/dist/src/middleware/authenticated.js +178 -0
- package/dist/src/middleware/authenticated.js.map +7 -0
- package/dist/src/middleware/builderOnly.js +48 -0
- package/dist/src/middleware/builderOnly.js.map +7 -0
- package/dist/src/middleware/builderOrAdmin.js +48 -0
- package/dist/src/middleware/builderOrAdmin.js.map +7 -0
- package/dist/src/middleware/csrf.js +60 -0
- package/dist/src/middleware/csrf.js.map +7 -0
- package/dist/src/middleware/errorHandling.js +62 -0
- package/dist/src/middleware/errorHandling.js.map +7 -0
- package/dist/src/middleware/index.js +95 -0
- package/dist/src/middleware/index.js.map +7 -0
- package/dist/src/middleware/internalApi.js +39 -0
- package/dist/src/middleware/internalApi.js.map +7 -0
- package/dist/src/middleware/joi-validator.js +73 -0
- package/dist/src/middleware/joi-validator.js.map +7 -0
- package/dist/src/middleware/matchers.js +62 -0
- package/dist/src/middleware/matchers.js.map +7 -0
- package/dist/src/middleware/passport/datasource/google.js +103 -0
- package/dist/src/middleware/passport/datasource/google.js.map +7 -0
- package/dist/src/middleware/passport/local.js +73 -0
- package/dist/src/middleware/passport/local.js.map +7 -0
- package/dist/src/middleware/passport/sso/google.js +93 -0
- package/dist/src/middleware/passport/sso/google.js.map +7 -0
- package/dist/src/middleware/passport/sso/oidc.js +135 -0
- package/dist/src/middleware/passport/sso/oidc.js.map +7 -0
- package/dist/src/middleware/passport/sso/sso.js +149 -0
- package/dist/src/middleware/passport/sso/sso.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/google.spec.js +77 -0
- package/dist/src/middleware/passport/sso/tests/google.spec.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/oidc.spec.js +143 -0
- package/dist/src/middleware/passport/sso/tests/oidc.spec.js.map +7 -0
- package/dist/src/middleware/passport/sso/tests/sso.spec.js +167 -0
- package/dist/src/middleware/passport/sso/tests/sso.spec.js.map +7 -0
- package/dist/src/middleware/passport/utils.js +62 -0
- package/dist/src/middleware/passport/utils.js.map +7 -0
- package/dist/src/middleware/querystringToBody.js +45 -0
- package/dist/src/middleware/querystringToBody.js.map +7 -0
- package/dist/src/middleware/tenancy.js +46 -0
- package/dist/src/middleware/tenancy.js.map +7 -0
- package/dist/src/middleware/tests/builder.spec.js +169 -0
- package/dist/src/middleware/tests/builder.spec.js.map +7 -0
- package/dist/src/middleware/tests/matchers.spec.js +120 -0
- package/dist/src/middleware/tests/matchers.spec.js.map +7 -0
- package/dist/src/migrations/definitions.js +63 -0
- package/dist/src/migrations/definitions.js.map +7 -0
- package/dist/src/migrations/index.js +25 -0
- package/dist/src/migrations/index.js.map +7 -0
- package/dist/src/migrations/migrations.js +178 -0
- package/dist/src/migrations/migrations.js.map +7 -0
- package/dist/src/migrations/tests/migrations.spec.js +78 -0
- package/dist/src/migrations/tests/migrations.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/app.js +65 -0
- package/dist/src/objectStore/buckets/app.js.map +7 -0
- package/dist/src/objectStore/buckets/global.js +63 -0
- package/dist/src/objectStore/buckets/global.js.map +7 -0
- package/dist/src/objectStore/buckets/index.js +27 -0
- package/dist/src/objectStore/buckets/index.js.map +7 -0
- package/dist/src/objectStore/buckets/plugins.js +101 -0
- package/dist/src/objectStore/buckets/plugins.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/app.spec.js +171 -0
- package/dist/src/objectStore/buckets/tests/app.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/global.spec.js +87 -0
- package/dist/src/objectStore/buckets/tests/global.spec.js.map +7 -0
- package/dist/src/objectStore/buckets/tests/plugins.spec.js +123 -0
- package/dist/src/objectStore/buckets/tests/plugins.spec.js.map +7 -0
- package/dist/src/objectStore/cloudfront.js +74 -0
- package/dist/src/objectStore/cloudfront.js.map +7 -0
- package/dist/src/objectStore/index.js +27 -0
- package/dist/src/objectStore/index.js.map +7 -0
- package/dist/src/objectStore/objectStore.js +372 -0
- package/dist/src/objectStore/objectStore.js.map +7 -0
- package/dist/src/objectStore/utils.js +58 -0
- package/dist/src/objectStore/utils.js.map +7 -0
- package/dist/src/platform/index.js +45 -0
- package/dist/src/platform/index.js.map +7 -0
- package/dist/src/platform/platformDb.js +33 -0
- package/dist/src/platform/platformDb.js.map +7 -0
- package/dist/src/platform/tenants.js +123 -0
- package/dist/src/platform/tenants.js.map +7 -0
- package/dist/src/platform/tests/tenants.spec.js +46 -0
- package/dist/src/platform/tests/tenants.spec.js.map +7 -0
- package/dist/src/platform/users.js +104 -0
- package/dist/src/platform/users.js.map +7 -0
- package/dist/src/plugin/index.js +23 -0
- package/dist/src/plugin/index.js.map +7 -0
- package/dist/src/plugin/tests/validation.spec.js +97 -0
- package/dist/src/plugin/tests/validation.spec.js.map +7 -0
- package/dist/src/plugin/utils.js +153 -0
- package/dist/src/plugin/utils.js.map +7 -0
- package/dist/src/queue/constants.js +35 -0
- package/dist/src/queue/constants.js.map +7 -0
- package/dist/src/queue/inMemoryQueue.js +139 -0
- package/dist/src/queue/inMemoryQueue.js.map +7 -0
- package/dist/src/queue/index.js +25 -0
- package/dist/src/queue/index.js.map +7 -0
- package/dist/src/queue/listeners.js +177 -0
- package/dist/src/queue/listeners.js.map +7 -0
- package/dist/src/queue/queue.js +85 -0
- package/dist/src/queue/queue.js.map +7 -0
- package/dist/src/redis/index.js +48 -0
- package/dist/src/redis/index.js.map +7 -0
- package/dist/src/redis/init.js +128 -0
- package/dist/src/redis/init.js.map +7 -0
- package/dist/src/redis/redis.js +277 -0
- package/dist/src/redis/redis.js.map +7 -0
- package/dist/src/redis/redlockImpl.js +145 -0
- package/dist/src/redis/redlockImpl.js.map +7 -0
- package/dist/src/redis/utils.js +136 -0
- package/dist/src/redis/utils.js.map +7 -0
- package/dist/src/security/encryption.js +184 -0
- package/dist/src/security/encryption.js.map +7 -0
- package/dist/src/security/permissions.js +188 -0
- package/dist/src/security/permissions.js.map +7 -0
- package/dist/src/security/roles.d.ts +1 -12
- package/dist/src/security/roles.js +337 -0
- package/dist/src/security/roles.js.map +7 -0
- package/dist/src/security/sessions.js +135 -0
- package/dist/src/security/sessions.js.map +7 -0
- package/dist/src/security/tests/encryption.spec.js +51 -0
- package/dist/src/security/tests/encryption.spec.js.map +7 -0
- package/dist/src/security/tests/permissions.spec.js +154 -0
- package/dist/src/security/tests/permissions.spec.js.map +7 -0
- package/dist/src/security/tests/sessions.spec.js +33 -0
- package/dist/src/security/tests/sessions.spec.js.map +7 -0
- package/dist/src/tenancy/db.js +33 -0
- package/dist/src/tenancy/db.js.map +7 -0
- package/dist/src/tenancy/index.js +25 -0
- package/dist/src/tenancy/index.js.map +7 -0
- package/dist/src/tenancy/tenancy.js +129 -0
- package/dist/src/tenancy/tenancy.js.map +7 -0
- package/dist/src/tenancy/tests/tenancy.spec.js +154 -0
- package/dist/src/tenancy/tests/tenancy.spec.js.map +7 -0
- package/dist/src/timers/index.js +23 -0
- package/dist/src/timers/index.js.map +7 -0
- package/dist/src/timers/timers.js +51 -0
- package/dist/src/timers/timers.js.map +7 -0
- package/dist/src/users/db.d.ts +9 -1
- package/dist/src/users/db.js +381 -0
- package/dist/src/users/db.js.map +7 -0
- package/dist/src/users/events.js +152 -0
- package/dist/src/users/events.js.map +7 -0
- package/dist/src/users/index.js +36 -0
- package/dist/src/users/index.js.map +7 -0
- package/dist/src/users/lookup.js +110 -0
- package/dist/src/users/lookup.js.map +7 -0
- package/dist/src/users/users.js +257 -0
- package/dist/src/users/users.js.map +7 -0
- package/dist/src/users/utils.js +95 -0
- package/dist/src/users/utils.js.map +7 -0
- package/dist/src/utils/hashing.js +53 -0
- package/dist/src/utils/hashing.js.map +7 -0
- package/dist/src/utils/index.js +27 -0
- package/dist/src/utils/index.js.map +7 -0
- package/dist/src/utils/stringUtils.js +33 -0
- package/dist/src/utils/stringUtils.js.map +7 -0
- package/dist/src/utils/tests/utils.spec.js +165 -0
- package/dist/src/utils/tests/utils.spec.js.map +7 -0
- package/dist/src/utils/utils.js +207 -0
- package/dist/src/utils/utils.js.map +7 -0
- package/dist/tests/core/logging.js +57 -0
- package/dist/tests/core/logging.js.map +7 -0
- package/dist/tests/core/utilities/index.js +54 -0
- package/dist/tests/core/utilities/index.js.map +7 -0
- package/dist/tests/core/utilities/jestUtils.js +50 -0
- package/dist/tests/core/utilities/jestUtils.js.map +7 -0
- package/dist/tests/core/utilities/mocks/alerts.js +41 -0
- package/dist/tests/core/utilities/mocks/alerts.js.map +7 -0
- package/dist/tests/core/utilities/mocks/date.js +32 -0
- package/dist/tests/core/utilities/mocks/date.js.map +7 -0
- package/dist/tests/core/utilities/mocks/events.js +133 -0
- package/dist/tests/core/utilities/mocks/events.js.map +7 -0
- package/dist/tests/core/utilities/mocks/fetch.js +39 -0
- package/dist/tests/core/utilities/mocks/fetch.js.map +7 -0
- package/dist/tests/core/utilities/mocks/index.js +55 -0
- package/dist/tests/core/utilities/mocks/index.js.map +7 -0
- package/dist/tests/core/utilities/mocks/licenses.d.ts +2 -0
- package/dist/tests/core/utilities/mocks/licenses.js +145 -0
- package/dist/tests/core/utilities/mocks/licenses.js.map +7 -0
- package/dist/tests/core/utilities/mocks/posthog.js +9 -0
- package/dist/tests/core/utilities/mocks/posthog.js.map +7 -0
- package/dist/tests/core/utilities/structures/Chance.js +48 -0
- package/dist/tests/core/utilities/structures/Chance.js.map +7 -0
- package/dist/tests/core/utilities/structures/accounts.js +148 -0
- package/dist/tests/core/utilities/structures/accounts.js.map +7 -0
- package/dist/tests/core/utilities/structures/apps.js +47 -0
- package/dist/tests/core/utilities/structures/apps.js.map +7 -0
- package/dist/tests/core/utilities/structures/common.js +35 -0
- package/dist/tests/core/utilities/structures/common.js.map +7 -0
- package/dist/tests/core/utilities/structures/db.js +40 -0
- package/dist/tests/core/utilities/structures/db.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/index.js +23 -0
- package/dist/tests/core/utilities/structures/documents/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js +39 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js +48 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js.map +7 -0
- package/dist/tests/core/utilities/structures/generator.js +40 -0
- package/dist/tests/core/utilities/structures/generator.js.map +7 -0
- package/dist/tests/core/utilities/structures/index.js +81 -0
- package/dist/tests/core/utilities/structures/index.js.map +7 -0
- package/dist/tests/core/utilities/structures/koa.js +42 -0
- package/dist/tests/core/utilities/structures/koa.js.map +7 -0
- package/dist/tests/core/utilities/structures/licenses.js +175 -0
- package/dist/tests/core/utilities/structures/licenses.js.map +7 -0
- package/dist/tests/core/utilities/structures/plugins.js +46 -0
- package/dist/tests/core/utilities/structures/plugins.js.map +7 -0
- package/dist/tests/core/utilities/structures/quotas.js +94 -0
- package/dist/tests/core/utilities/structures/quotas.js.map +7 -0
- package/dist/tests/core/utilities/structures/scim.js +90 -0
- package/dist/tests/core/utilities/structures/scim.js.map +7 -0
- package/dist/tests/core/utilities/structures/shared.js +46 -0
- package/dist/tests/core/utilities/structures/shared.js.map +7 -0
- package/dist/tests/core/utilities/structures/sso.js +144 -0
- package/dist/tests/core/utilities/structures/sso.js.map +7 -0
- package/dist/tests/core/utilities/structures/tenants.js +32 -0
- package/dist/tests/core/utilities/structures/tenants.js.map +7 -0
- package/dist/tests/core/utilities/structures/userGroups.js +36 -0
- package/dist/tests/core/utilities/structures/userGroups.js.map +7 -0
- package/dist/tests/core/utilities/structures/users.js +96 -0
- package/dist/tests/core/utilities/structures/users.js.map +7 -0
- package/dist/tests/core/utilities/testContainerUtils.js +100 -0
- package/dist/tests/core/utilities/testContainerUtils.js.map +7 -0
- package/dist/tests/core/utilities/utils/index.js +39 -0
- package/dist/tests/core/utilities/utils/index.js.map +7 -0
- package/dist/tests/core/utilities/utils/time.js +31 -0
- package/dist/tests/core/utilities/utils/time.js.map +7 -0
- package/dist/tests/extra/DBTestConfiguration.js +61 -0
- package/dist/tests/extra/DBTestConfiguration.js.map +7 -0
- package/dist/tests/extra/index.js +42 -0
- package/dist/tests/extra/index.js.map +7 -0
- package/dist/tests/extra/testEnv.js +106 -0
- package/dist/tests/extra/testEnv.js.map +7 -0
- package/dist/tests/index.js +23 -0
- package/dist/tests/index.js.map +7 -0
- package/dist/tests/jestEnv.js +8 -0
- package/dist/tests/jestEnv.js.map +7 -0
- package/dist/tests/jestSetup.js +41 -0
- package/dist/tests/jestSetup.js.map +7 -0
- package/package.json +5 -5
- package/dist/tests.js +0 -8476
- package/dist/tests.js.map +0 -7
- package/dist/tests.js.meta.json +0 -1
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var matchers = __toESM(require("../matchers"));
|
|
25
|
+
var import_tests = require("../../../tests");
|
|
26
|
+
describe("matchers", () => {
|
|
27
|
+
it("matches by path and method", () => {
|
|
28
|
+
const pattern = [
|
|
29
|
+
{
|
|
30
|
+
route: "/api/tests",
|
|
31
|
+
method: "POST"
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
const ctx = import_tests.structures.koa.newContext();
|
|
35
|
+
ctx.request.url = "/api/tests";
|
|
36
|
+
ctx.request.method = "POST";
|
|
37
|
+
const built = matchers.buildMatcherRegex(pattern);
|
|
38
|
+
expect(!!matchers.matches(ctx, built)).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
it("wildcards path", () => {
|
|
41
|
+
const pattern = [
|
|
42
|
+
{
|
|
43
|
+
route: "/api/tests",
|
|
44
|
+
method: "POST"
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
const ctx = import_tests.structures.koa.newContext();
|
|
48
|
+
ctx.request.url = "/api/tests/id/something/else";
|
|
49
|
+
ctx.request.method = "POST";
|
|
50
|
+
const built = matchers.buildMatcherRegex(pattern);
|
|
51
|
+
expect(!!matchers.matches(ctx, built)).toBe(true);
|
|
52
|
+
});
|
|
53
|
+
it("doesn't wildcard path with strict", () => {
|
|
54
|
+
const pattern = [
|
|
55
|
+
{
|
|
56
|
+
route: "/api/tests",
|
|
57
|
+
method: "POST",
|
|
58
|
+
strict: true
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
const ctx = import_tests.structures.koa.newContext();
|
|
62
|
+
ctx.request.url = "/api/tests/id/something/else";
|
|
63
|
+
ctx.request.method = "POST";
|
|
64
|
+
const built = matchers.buildMatcherRegex(pattern);
|
|
65
|
+
expect(!!matchers.matches(ctx, built)).toBe(false);
|
|
66
|
+
});
|
|
67
|
+
it("matches with param", () => {
|
|
68
|
+
const pattern = [
|
|
69
|
+
{
|
|
70
|
+
route: "/api/tests/:testId",
|
|
71
|
+
method: "GET"
|
|
72
|
+
}
|
|
73
|
+
];
|
|
74
|
+
const ctx = import_tests.structures.koa.newContext();
|
|
75
|
+
ctx.request.url = "/api/tests/id";
|
|
76
|
+
ctx.request.method = "GET";
|
|
77
|
+
const built = matchers.buildMatcherRegex(pattern);
|
|
78
|
+
expect(!!matchers.matches(ctx, built)).toBe(true);
|
|
79
|
+
});
|
|
80
|
+
it("doesn't match by path", () => {
|
|
81
|
+
const pattern = [
|
|
82
|
+
{
|
|
83
|
+
route: "/api/tests",
|
|
84
|
+
method: "POST"
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
const ctx = import_tests.structures.koa.newContext();
|
|
88
|
+
ctx.request.url = "/api/unknown";
|
|
89
|
+
ctx.request.method = "POST";
|
|
90
|
+
const built = matchers.buildMatcherRegex(pattern);
|
|
91
|
+
expect(!!matchers.matches(ctx, built)).toBe(false);
|
|
92
|
+
});
|
|
93
|
+
it("doesn't match by method", () => {
|
|
94
|
+
const pattern = [
|
|
95
|
+
{
|
|
96
|
+
route: "/api/tests",
|
|
97
|
+
method: "POST"
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
const ctx = import_tests.structures.koa.newContext();
|
|
101
|
+
ctx.request.url = "/api/tests";
|
|
102
|
+
ctx.request.method = "GET";
|
|
103
|
+
const built = matchers.buildMatcherRegex(pattern);
|
|
104
|
+
expect(!!matchers.matches(ctx, built)).toBe(false);
|
|
105
|
+
});
|
|
106
|
+
it("matches by path and wildcard method", () => {
|
|
107
|
+
const pattern = [
|
|
108
|
+
{
|
|
109
|
+
route: "/api/tests",
|
|
110
|
+
method: "ALL"
|
|
111
|
+
}
|
|
112
|
+
];
|
|
113
|
+
const ctx = import_tests.structures.koa.newContext();
|
|
114
|
+
ctx.request.url = "/api/tests";
|
|
115
|
+
ctx.request.method = "GET";
|
|
116
|
+
const built = matchers.buildMatcherRegex(pattern);
|
|
117
|
+
expect(!!matchers.matches(ctx, built)).toBe(true);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
//# sourceMappingURL=matchers.spec.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/middleware/tests/matchers.spec.ts"],
|
|
4
|
+
"sourcesContent": ["import * as matchers from \"../matchers\"\nimport { structures } from \"../../../tests\"\n\ndescribe(\"matchers\", () => {\n it(\"matches by path and method\", () => {\n const pattern = [\n {\n route: \"/api/tests\",\n method: \"POST\",\n },\n ]\n const ctx = structures.koa.newContext()\n ctx.request.url = \"/api/tests\"\n ctx.request.method = \"POST\"\n\n const built = matchers.buildMatcherRegex(pattern)\n\n expect(!!matchers.matches(ctx, built)).toBe(true)\n })\n\n it(\"wildcards path\", () => {\n const pattern = [\n {\n route: \"/api/tests\",\n method: \"POST\",\n },\n ]\n const ctx = structures.koa.newContext()\n ctx.request.url = \"/api/tests/id/something/else\"\n ctx.request.method = \"POST\"\n\n const built = matchers.buildMatcherRegex(pattern)\n\n expect(!!matchers.matches(ctx, built)).toBe(true)\n })\n\n it(\"doesn't wildcard path with strict\", () => {\n const pattern = [\n {\n route: \"/api/tests\",\n method: \"POST\",\n strict: true,\n },\n ]\n const ctx = structures.koa.newContext()\n ctx.request.url = \"/api/tests/id/something/else\"\n ctx.request.method = \"POST\"\n\n const built = matchers.buildMatcherRegex(pattern)\n\n expect(!!matchers.matches(ctx, built)).toBe(false)\n })\n\n it(\"matches with param\", () => {\n const pattern = [\n {\n route: \"/api/tests/:testId\",\n method: \"GET\",\n },\n ]\n const ctx = structures.koa.newContext()\n ctx.request.url = \"/api/tests/id\"\n ctx.request.method = \"GET\"\n\n const built = matchers.buildMatcherRegex(pattern)\n\n expect(!!matchers.matches(ctx, built)).toBe(true)\n })\n\n // TODO: Support the below behaviour\n // Strict does not work when a param is present\n // it(\"matches with param with strict\", () => {\n // const pattern = [{\n // route: \"/api/tests/:testId\",\n // method: \"GET\",\n // strict: true\n // }]\n // const ctx = structures.koa.newContext()\n // ctx.request.url = \"/api/tests/id\"\n // ctx.request.method = \"GET\"\n //\n // const built = matchers.buildMatcherRegex(pattern)\n //\n // expect(!!matchers.matches(ctx, built)).toBe(true)\n // })\n\n it(\"doesn't match by path\", () => {\n const pattern = [\n {\n route: \"/api/tests\",\n method: \"POST\",\n },\n ]\n const ctx = structures.koa.newContext()\n ctx.request.url = \"/api/unknown\"\n ctx.request.method = \"POST\"\n\n const built = matchers.buildMatcherRegex(pattern)\n\n expect(!!matchers.matches(ctx, built)).toBe(false)\n })\n\n it(\"doesn't match by method\", () => {\n const pattern = [\n {\n route: \"/api/tests\",\n method: \"POST\",\n },\n ]\n const ctx = structures.koa.newContext()\n ctx.request.url = \"/api/tests\"\n ctx.request.method = \"GET\"\n\n const built = matchers.buildMatcherRegex(pattern)\n\n expect(!!matchers.matches(ctx, built)).toBe(false)\n })\n\n it(\"matches by path and wildcard method\", () => {\n const pattern = [\n {\n route: \"/api/tests\",\n method: \"ALL\",\n },\n ]\n const ctx = structures.koa.newContext()\n ctx.request.url = \"/api/tests\"\n ctx.request.method = \"GET\"\n\n const built = matchers.buildMatcherRegex(pattern)\n\n expect(!!matchers.matches(ctx, built)).toBe(true)\n })\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,eAA0B;AAC1B,mBAA2B;AAE3B,SAAS,YAAY,MAAM;AACzB,KAAG,8BAA8B,MAAM;AACrC,UAAM,UAAU;AAAA,MACd;AAAA,QACE,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF;AACA,UAAM,MAAM,wBAAW,IAAI,WAAW;AACtC,QAAI,QAAQ,MAAM;AAClB,QAAI,QAAQ,SAAS;AAErB,UAAM,QAAQ,SAAS,kBAAkB,OAAO;AAEhD,WAAO,CAAC,CAAC,SAAS,QAAQ,KAAK,KAAK,CAAC,EAAE,KAAK,IAAI;AAAA,EAClD,CAAC;AAED,KAAG,kBAAkB,MAAM;AACzB,UAAM,UAAU;AAAA,MACd;AAAA,QACE,OAAO;AAAA,Q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,KAAK,KAAK;AAAA,EACnD,CAAC;AAED,KAAG,2BAA2B,MAAM;AAClC,UAAM,UAAU;AAAA,MACd;AAAA,QACE,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF;AACA,UAAM,MAAM,wBAAW,IAAI,WAAW;AACtC,QAAI,QAAQ,MAAM;AAClB,QAAI,QAAQ,SAAS;AAErB,UAAM,QAAQ,SAAS,kBAAkB,OAAO;AAEhD,WAAO,CAAC,CAAC,SAAS,QAAQ,KAAK,KAAK,CAAC,EAAE,KAAK,KAAK;AAAA,EACnD,CAAC;AAED,KAAG,uCAAuC,MAAM;AAC9C,UAAM,UAAU;AAAA,MACd;AAAA,QACE,OAAO;AAAA,QACP,QAAQ;AAAA,MACV;AAAA,IACF;AACA,UAAM,MAAM,wBAAW,IAAI,WAAW;AACtC,QAAI,QAAQ,MAAM;AAClB,QAAI,QAAQ,SAAS;AAErB,UAAM,QAAQ,SAAS,kBAAkB,OAAO;AAEhD,WAAO,CAAC,CAAC,SAAS,QAAQ,KAAK,KAAK,CAAC,EAAE,KAAK,IAAI;AAAA,EAClD,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var definitions_exports = {};
|
|
20
|
+
__export(definitions_exports, {
|
|
21
|
+
DEFINITIONS: () => DEFINITIONS
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(definitions_exports);
|
|
24
|
+
var import_types = require("@budibase/types");
|
|
25
|
+
const DEFINITIONS = [
|
|
26
|
+
{
|
|
27
|
+
type: import_types.MigrationType.GLOBAL,
|
|
28
|
+
name: import_types.MigrationName.USER_EMAIL_VIEW_CASING
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: import_types.MigrationType.GLOBAL,
|
|
32
|
+
name: import_types.MigrationName.SYNC_QUOTAS
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: import_types.MigrationType.APP,
|
|
36
|
+
name: import_types.MigrationName.APP_URLS
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: import_types.MigrationType.APP,
|
|
40
|
+
name: import_types.MigrationName.EVENT_APP_BACKFILL
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: import_types.MigrationType.APP,
|
|
44
|
+
name: import_types.MigrationName.TABLE_SETTINGS_LINKS_TO_ACTIONS
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: import_types.MigrationType.GLOBAL,
|
|
48
|
+
name: import_types.MigrationName.EVENT_GLOBAL_BACKFILL
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: import_types.MigrationType.INSTALLATION,
|
|
52
|
+
name: import_types.MigrationName.EVENT_INSTALLATION_BACKFILL
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: import_types.MigrationType.GLOBAL,
|
|
56
|
+
name: import_types.MigrationName.GLOBAL_INFO_SYNC_USERS
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {
|
|
61
|
+
DEFINITIONS
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=definitions.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/migrations/definitions.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n MigrationType,\n MigrationName,\n MigrationDefinition,\n} from \"@budibase/types\"\n\nexport const DEFINITIONS: MigrationDefinition[] = [\n {\n type: MigrationType.GLOBAL,\n name: MigrationName.USER_EMAIL_VIEW_CASING,\n },\n {\n type: MigrationType.GLOBAL,\n name: MigrationName.SYNC_QUOTAS,\n },\n {\n type: MigrationType.APP,\n name: MigrationName.APP_URLS,\n },\n {\n type: MigrationType.APP,\n name: MigrationName.EVENT_APP_BACKFILL,\n },\n {\n type: MigrationType.APP,\n name: MigrationName.TABLE_SETTINGS_LINKS_TO_ACTIONS,\n },\n {\n type: MigrationType.GLOBAL,\n name: MigrationName.EVENT_GLOBAL_BACKFILL,\n },\n {\n type: MigrationType.INSTALLATION,\n name: MigrationName.EVENT_INSTALLATION_BACKFILL,\n },\n {\n type: MigrationType.GLOBAL,\n name: MigrationName.GLOBAL_INFO_SYNC_USERS,\n },\n]\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAIO;AAEA,MAAM,cAAqC;AAAA,EAChD;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AAAA,EACA;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AAAA,EACA;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AAAA,EACA;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AAAA,EACA;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AAAA,EACA;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AAAA,EACA;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AAAA,EACA;AAAA,IACE,MAAM,2BAAc;AAAA,IACpB,MAAM,2BAAc;AAAA,EACtB;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
+
var migrations_exports = {};
|
|
17
|
+
module.exports = __toCommonJS(migrations_exports);
|
|
18
|
+
__reExport(migrations_exports, require("./migrations"), module.exports);
|
|
19
|
+
__reExport(migrations_exports, require("./definitions"), module.exports);
|
|
20
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
21
|
+
0 && (module.exports = {
|
|
22
|
+
...require("./migrations"),
|
|
23
|
+
...require("./definitions")
|
|
24
|
+
});
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var migrations_exports = {};
|
|
30
|
+
__export(migrations_exports, {
|
|
31
|
+
backPopulateMigrations: () => backPopulateMigrations,
|
|
32
|
+
getMigrationsDoc: () => getMigrationsDoc,
|
|
33
|
+
runMigration: () => runMigration,
|
|
34
|
+
runMigrations: () => runMigrations
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(migrations_exports);
|
|
37
|
+
var import_constants = require("../constants");
|
|
38
|
+
var import_db = require("../db");
|
|
39
|
+
var import_environment = __toESM(require("../environment"));
|
|
40
|
+
var platform = __toESM(require("../platform"));
|
|
41
|
+
var context = __toESM(require("../context"));
|
|
42
|
+
var import__ = require(".");
|
|
43
|
+
var import_types = require("@budibase/types");
|
|
44
|
+
const getMigrationsDoc = async (db) => {
|
|
45
|
+
try {
|
|
46
|
+
return await db.get(import_db.DocumentType.MIGRATIONS);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (err.status && err.status === 404) {
|
|
49
|
+
return { _id: import_db.DocumentType.MIGRATIONS };
|
|
50
|
+
} else {
|
|
51
|
+
console.error(err);
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const backPopulateMigrations = async (opts) => {
|
|
57
|
+
const migrations = import__.DEFINITIONS.filter(
|
|
58
|
+
(def) => def.type === opts.type
|
|
59
|
+
).map((d) => ({ ...d, fn: () => {
|
|
60
|
+
} }));
|
|
61
|
+
await runMigrations(migrations, { noOp: opts });
|
|
62
|
+
};
|
|
63
|
+
const runMigration = async (migration, options = {}) => {
|
|
64
|
+
const migrationType = migration.type;
|
|
65
|
+
let tenantId;
|
|
66
|
+
if (migrationType !== import_types.MigrationType.INSTALLATION) {
|
|
67
|
+
tenantId = context.getTenantId();
|
|
68
|
+
}
|
|
69
|
+
const migrationName = migration.name;
|
|
70
|
+
const silent = migration.silent;
|
|
71
|
+
const log = (message) => {
|
|
72
|
+
if (!silent) {
|
|
73
|
+
console.log(message);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
let dbNames;
|
|
77
|
+
if (migrationType === import_types.MigrationType.GLOBAL) {
|
|
78
|
+
dbNames = [(0, import_db.getGlobalDBName)()];
|
|
79
|
+
} else if (migrationType === import_types.MigrationType.APP) {
|
|
80
|
+
if (options.noOp) {
|
|
81
|
+
if (!options.noOp.appId) {
|
|
82
|
+
throw new Error("appId is required for noOp app migration");
|
|
83
|
+
}
|
|
84
|
+
dbNames = [options.noOp.appId];
|
|
85
|
+
} else {
|
|
86
|
+
const apps = await (0, import_db.getAllApps)(migration.appOpts);
|
|
87
|
+
dbNames = apps.map((app) => app.appId);
|
|
88
|
+
}
|
|
89
|
+
} else if (migrationType === import_types.MigrationType.INSTALLATION) {
|
|
90
|
+
dbNames = [import_db.StaticDatabases.PLATFORM_INFO.name];
|
|
91
|
+
} else {
|
|
92
|
+
throw new Error(`Unrecognised migration type [${migrationType}]`);
|
|
93
|
+
}
|
|
94
|
+
const length = dbNames.length;
|
|
95
|
+
let count = 0;
|
|
96
|
+
for (const dbName of dbNames) {
|
|
97
|
+
count++;
|
|
98
|
+
const lengthStatement = length > 1 ? `[${count}/${length}]` : "";
|
|
99
|
+
const db = (0, import_db.getDB)(dbName);
|
|
100
|
+
try {
|
|
101
|
+
const doc = await getMigrationsDoc(db);
|
|
102
|
+
if (doc[migrationName]) {
|
|
103
|
+
if (options.force && options.force[migrationType] && options.force[migrationType].includes(migrationName)) {
|
|
104
|
+
log(`[Migration: ${migrationName}] [DB: ${dbName}] Forcing`);
|
|
105
|
+
} else {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (!options.noOp) {
|
|
110
|
+
log(
|
|
111
|
+
`[Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}`
|
|
112
|
+
);
|
|
113
|
+
if (migration.preventRetry) {
|
|
114
|
+
doc[migrationName] = Date.now();
|
|
115
|
+
const response = await db.put(doc);
|
|
116
|
+
doc._rev = response.rev;
|
|
117
|
+
}
|
|
118
|
+
if (migrationType === import_types.MigrationType.APP) {
|
|
119
|
+
await context.doInAppContext(db.name, async () => {
|
|
120
|
+
await migration.fn(db);
|
|
121
|
+
});
|
|
122
|
+
} else {
|
|
123
|
+
await migration.fn(db);
|
|
124
|
+
}
|
|
125
|
+
log(`[Migration: ${migrationName}] [DB: ${dbName}] Complete`);
|
|
126
|
+
}
|
|
127
|
+
doc[migrationName] = Date.now();
|
|
128
|
+
await db.put(doc);
|
|
129
|
+
} catch (err) {
|
|
130
|
+
console.error(
|
|
131
|
+
`[Migration: ${migrationName}] [DB: ${dbName}] Error: `,
|
|
132
|
+
err
|
|
133
|
+
);
|
|
134
|
+
throw err;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const runMigrations = async (migrations, options = {}) => {
|
|
139
|
+
let tenantIds;
|
|
140
|
+
if (import_environment.default.MULTI_TENANCY) {
|
|
141
|
+
if (options.noOp) {
|
|
142
|
+
tenantIds = [options.noOp.tenantId];
|
|
143
|
+
} else if (!options.tenantIds || !options.tenantIds.length) {
|
|
144
|
+
tenantIds = await platform.tenants.getTenantIds();
|
|
145
|
+
} else {
|
|
146
|
+
tenantIds = options.tenantIds;
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
tenantIds = [import_constants.DEFAULT_TENANT_ID];
|
|
150
|
+
}
|
|
151
|
+
if (tenantIds.length > 1) {
|
|
152
|
+
console.log(`Checking migrations for ${tenantIds.length} tenants`);
|
|
153
|
+
} else {
|
|
154
|
+
console.log("Checking migrations");
|
|
155
|
+
}
|
|
156
|
+
let count = 0;
|
|
157
|
+
for (const tenantId of tenantIds) {
|
|
158
|
+
count++;
|
|
159
|
+
if (tenantIds.length > 1) {
|
|
160
|
+
console.log(`Progress [${count}/${tenantIds.length}]`);
|
|
161
|
+
}
|
|
162
|
+
for (const migration of migrations) {
|
|
163
|
+
await context.doInTenant(
|
|
164
|
+
tenantId,
|
|
165
|
+
async () => await runMigration(migration, options)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
console.log("Migrations complete");
|
|
170
|
+
};
|
|
171
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
172
|
+
0 && (module.exports = {
|
|
173
|
+
backPopulateMigrations,
|
|
174
|
+
getMigrationsDoc,
|
|
175
|
+
runMigration,
|
|
176
|
+
runMigrations
|
|
177
|
+
});
|
|
178
|
+
//# sourceMappingURL=migrations.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/migrations/migrations.ts"],
|
|
4
|
+
"sourcesContent": ["import { DEFAULT_TENANT_ID } from \"../constants\"\nimport {\n DocumentType,\n StaticDatabases,\n getAllApps,\n getGlobalDBName,\n getDB,\n} from \"../db\"\nimport environment from \"../environment\"\nimport * as platform from \"../platform\"\nimport * as context from \"../context\"\nimport { DEFINITIONS } from \".\"\nimport {\n Migration,\n MigrationOptions,\n MigrationType,\n MigrationNoOpOptions,\n App,\n} from \"@budibase/types\"\n\nexport const getMigrationsDoc = async (db: any) => {\n // get the migrations doc\n try {\n return await db.get(DocumentType.MIGRATIONS)\n } catch (err: any) {\n if (err.status && err.status === 404) {\n return { _id: DocumentType.MIGRATIONS }\n } else {\n console.error(err)\n throw err\n }\n }\n}\n\nexport const backPopulateMigrations = async (opts: MigrationNoOpOptions) => {\n // filter migrations to the type and populate a no-op migration\n const migrations: Migration[] = DEFINITIONS.filter(\n def => def.type === opts.type\n ).map(d => ({ ...d, fn: () => {} }))\n await runMigrations(migrations, { noOp: opts })\n}\n\nexport const runMigration = async (\n migration: Migration,\n options: MigrationOptions = {}\n) => {\n const migrationType = migration.type\n let tenantId: string | undefined\n if (migrationType !== MigrationType.INSTALLATION) {\n tenantId = context.getTenantId()\n }\n const migrationName = migration.name\n const silent = migration.silent\n\n const log = (message: string) => {\n if (!silent) {\n console.log(message)\n }\n }\n\n // get the db to store the migration in\n let dbNames: string[]\n if (migrationType === MigrationType.GLOBAL) {\n dbNames = [getGlobalDBName()]\n } else if (migrationType === MigrationType.APP) {\n if (options.noOp) {\n if (!options.noOp.appId) {\n throw new Error(\"appId is required for noOp app migration\")\n }\n dbNames = [options.noOp.appId]\n } else {\n const apps = (await getAllApps(migration.appOpts)) as App[]\n dbNames = apps.map(app => app.appId)\n }\n } else if (migrationType === MigrationType.INSTALLATION) {\n dbNames = [StaticDatabases.PLATFORM_INFO.name]\n } else {\n throw new Error(`Unrecognised migration type [${migrationType}]`)\n }\n\n const length = dbNames.length\n let count = 0\n\n // run the migration against each db\n for (const dbName of dbNames) {\n count++\n const lengthStatement = length > 1 ? `[${count}/${length}]` : \"\"\n\n const db = getDB(dbName)\n\n try {\n const doc = await getMigrationsDoc(db)\n\n // the migration has already been run\n if (doc[migrationName]) {\n // check for force\n if (\n options.force &&\n options.force[migrationType] &&\n options.force[migrationType].includes(migrationName)\n ) {\n log(`[Migration: ${migrationName}] [DB: ${dbName}] Forcing`)\n } else {\n // no force, exit\n return\n }\n }\n\n // check if the migration is not a no-op\n if (!options.noOp) {\n log(\n `[Migration: ${migrationName}] [DB: ${dbName}] Running ${lengthStatement}`\n )\n\n if (migration.preventRetry) {\n // eagerly set the completion date\n // so that we never run this migration twice even upon failure\n doc[migrationName] = Date.now()\n const response = await db.put(doc)\n doc._rev = response.rev\n }\n\n // run the migration\n if (migrationType === MigrationType.APP) {\n await context.doInAppContext(db.name, async () => {\n await migration.fn(db)\n })\n } else {\n await migration.fn(db)\n }\n\n log(`[Migration: ${migrationName}] [DB: ${dbName}] Complete`)\n }\n\n // mark as complete\n doc[migrationName] = Date.now()\n await db.put(doc)\n } catch (err) {\n console.error(\n `[Migration: ${migrationName}] [DB: ${dbName}] Error: `,\n err\n )\n throw err\n }\n }\n}\n\nexport const runMigrations = async (\n migrations: Migration[],\n options: MigrationOptions = {}\n) => {\n let tenantIds\n\n if (environment.MULTI_TENANCY) {\n if (options.noOp) {\n tenantIds = [options.noOp.tenantId]\n } else if (!options.tenantIds || !options.tenantIds.length) {\n // run for all tenants\n tenantIds = await platform.tenants.getTenantIds()\n } else {\n tenantIds = options.tenantIds\n }\n } else {\n // single tenancy\n tenantIds = [DEFAULT_TENANT_ID]\n }\n\n if (tenantIds.length > 1) {\n console.log(`Checking migrations for ${tenantIds.length} tenants`)\n } else {\n console.log(\"Checking migrations\")\n }\n\n let count = 0\n // for all tenants\n for (const tenantId of tenantIds) {\n count++\n if (tenantIds.length > 1) {\n console.log(`Progress [${count}/${tenantIds.length}]`)\n }\n // for all migrations\n for (const migration of migrations) {\n // run the migration\n await context.doInTenant(\n tenantId,\n async () => await runMigration(migration, options)\n )\n }\n }\n console.log(\"Migrations complete\")\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAAkC;AAClC,gBAMO;AACP,yBAAwB;AACxB,eAA0B;AAC1B,cAAyB;AACzB,eAA4B;AAC5B,mBAMO;AAEA,MAAM,mBAAmB,OAAO,OAAY;AAEjD,MAAI;AACF,WAAO,MAAM,GAAG,IAAI,uBAAa,UAAU;AAAA,EAC7C,SAAS,KAAU;AACjB,QAAI,IAAI,UAAU,IAAI,WAAW,KAAK;AACpC,aAAO,EAAE,KAAK,uBAAa,WAAW;AAAA,IACxC,OAAO;AACL,cAAQ,MAAM,GAAG;AACjB,YAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,OAAO,SAA+B;AAE1E,QAAM,aAA0B,qBAAY;AAAA,IAC1C,SAAO,IAAI,SAAS,KAAK;AAAA,EAC3B,EAAE,IAAI,QAAM,EAAE,GAAG,GAAG,IAAI,MAAM;AAAA,EAAC,EAAE,EAAE;AACnC,QAAM,cAAc,YAAY,EAAE,MAAM,KAAK,CAAC;AAChD;AAEO,MAAM,eAAe,OAC1B,WACA,UAA4B,CAAC,MAC1B;AACH,QAAM,gBAAgB,UAAU;AAChC,MAAI;AACJ,MAAI,kBAAkB,2BAAc,cAAc;AAChD,eAAW,QAAQ,YAAY;AAAA,EACjC;AACA,QAAM,gBAAgB,UA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AAElC,YAAM,QAAQ;AAAA,QACZ;AAAA,QACA,YAAY,MAAM,aAAa,WAAW,OAAO;AAAA,MACnD;AAAA,IACF;AAAA,EACF;AACA,UAAQ,IAAI,qBAAqB;AACnC;",
|
|
6
|
+
"names": ["environment"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_extra = require("../../../tests/extra");
|
|
25
|
+
var migrations = __toESM(require("../index"));
|
|
26
|
+
var context = __toESM(require("../../context"));
|
|
27
|
+
var import_types = require("@budibase/types");
|
|
28
|
+
import_extra.testEnv.multiTenant();
|
|
29
|
+
describe("migrations", () => {
|
|
30
|
+
const config = new import_extra.DBTestConfiguration();
|
|
31
|
+
const migrationFunction = jest.fn();
|
|
32
|
+
const MIGRATIONS = [
|
|
33
|
+
{
|
|
34
|
+
type: import_types.MigrationType.GLOBAL,
|
|
35
|
+
name: "test",
|
|
36
|
+
fn: migrationFunction
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
config.newTenant();
|
|
41
|
+
});
|
|
42
|
+
afterEach(async () => {
|
|
43
|
+
jest.clearAllMocks();
|
|
44
|
+
});
|
|
45
|
+
const migrate = () => {
|
|
46
|
+
return migrations.runMigrations(MIGRATIONS, {
|
|
47
|
+
tenantIds: [config.tenantId]
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
it("should run a new migration", async () => {
|
|
51
|
+
await config.doInTenant(async () => {
|
|
52
|
+
await migrate();
|
|
53
|
+
expect(migrationFunction).toHaveBeenCalled();
|
|
54
|
+
const db = context.getGlobalDB();
|
|
55
|
+
const doc = await migrations.getMigrationsDoc(db);
|
|
56
|
+
expect(doc.test).toBeDefined();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
it("should match snapshot", async () => {
|
|
60
|
+
await config.doInTenant(async () => {
|
|
61
|
+
await migrate();
|
|
62
|
+
const doc = await migrations.getMigrationsDoc(context.getGlobalDB());
|
|
63
|
+
expect(doc).toMatchSnapshot();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
it("should skip a previously run migration", async () => {
|
|
67
|
+
await config.doInTenant(async () => {
|
|
68
|
+
const db = context.getGlobalDB();
|
|
69
|
+
await migrate();
|
|
70
|
+
const previousDoc = await migrations.getMigrationsDoc(db);
|
|
71
|
+
await migrate();
|
|
72
|
+
const currentDoc = await migrations.getMigrationsDoc(db);
|
|
73
|
+
expect(migrationFunction).toHaveBeenCalledTimes(1);
|
|
74
|
+
expect(currentDoc.test).toBe(previousDoc.test);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
//# sourceMappingURL=migrations.spec.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/migrations/tests/migrations.spec.ts"],
|
|
4
|
+
"sourcesContent": ["import { testEnv, DBTestConfiguration } from \"../../../tests/extra\"\nimport * as migrations from \"../index\"\nimport * as context from \"../../context\"\nimport { MigrationType } from \"@budibase/types\"\n\ntestEnv.multiTenant()\n\ndescribe(\"migrations\", () => {\n const config = new DBTestConfiguration()\n\n const migrationFunction = jest.fn()\n\n const MIGRATIONS = [\n {\n type: MigrationType.GLOBAL,\n name: \"test\" as any,\n fn: migrationFunction,\n },\n ]\n\n beforeEach(() => {\n config.newTenant()\n })\n\n afterEach(async () => {\n jest.clearAllMocks()\n })\n\n const migrate = () => {\n return migrations.runMigrations(MIGRATIONS, {\n tenantIds: [config.tenantId],\n })\n }\n\n it(\"should run a new migration\", async () => {\n await config.doInTenant(async () => {\n await migrate()\n expect(migrationFunction).toHaveBeenCalled()\n const db = context.getGlobalDB()\n const doc = await migrations.getMigrationsDoc(db)\n expect(doc.test).toBeDefined()\n })\n })\n\n it(\"should match snapshot\", async () => {\n await config.doInTenant(async () => {\n await migrate()\n const doc = await migrations.getMigrationsDoc(context.getGlobalDB())\n expect(doc).toMatchSnapshot()\n })\n })\n\n it(\"should skip a previously run migration\", async () => {\n await config.doInTenant(async () => {\n const db = context.getGlobalDB()\n await migrate()\n const previousDoc = await migrations.getMigrationsDoc(db)\n await migrate()\n const currentDoc = await migrations.getMigrationsDoc(db)\n expect(migrationFunction).toHaveBeenCalledTimes(1)\n expect(currentDoc.test).toBe(previousDoc.test)\n })\n })\n})\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA,mBAA6C;AAC7C,iBAA4B;AAC5B,cAAyB;AACzB,mBAA8B;AAE9B,qBAAQ,YAAY;AAEpB,SAAS,cAAc,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
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var app_exports = {};
|
|
30
|
+
__export(app_exports, {
|
|
31
|
+
clientLibraryUrl: () => clientLibraryUrl,
|
|
32
|
+
getAppFileUrl: () => getAppFileUrl
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(app_exports);
|
|
35
|
+
var import_environment = __toESM(require("../../environment"));
|
|
36
|
+
var objectStore = __toESM(require("../objectStore"));
|
|
37
|
+
var cloudfront = __toESM(require("../cloudfront"));
|
|
38
|
+
const clientLibraryUrl = (appId, version) => {
|
|
39
|
+
if (import_environment.default.isProd()) {
|
|
40
|
+
let file = `${objectStore.sanitizeKey(appId)}/budibase-client.js`;
|
|
41
|
+
if (import_environment.default.CLOUDFRONT_CDN) {
|
|
42
|
+
if (version) {
|
|
43
|
+
file += `?v=${version}`;
|
|
44
|
+
}
|
|
45
|
+
return cloudfront.getUrl(file);
|
|
46
|
+
} else {
|
|
47
|
+
return objectStore.getPresignedUrl(import_environment.default.APPS_BUCKET_NAME, file);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
return `/api/assets/client`;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const getAppFileUrl = (s3Key) => {
|
|
54
|
+
if (import_environment.default.CLOUDFRONT_CDN) {
|
|
55
|
+
return cloudfront.getPresignedUrl(s3Key);
|
|
56
|
+
} else {
|
|
57
|
+
return objectStore.getPresignedUrl(import_environment.default.APPS_BUCKET_NAME, s3Key);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
+
0 && (module.exports = {
|
|
62
|
+
clientLibraryUrl,
|
|
63
|
+
getAppFileUrl
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=app.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/objectStore/buckets/app.ts"],
|
|
4
|
+
"sourcesContent": ["import env from \"../../environment\"\nimport * as objectStore from \"../objectStore\"\nimport * as cloudfront from \"../cloudfront\"\n\n/**\n * In production the client library is stored in the object store, however in development\n * we use the symlinked version produced by lerna, located in node modules. We link to this\n * via a specific endpoint (under /api/assets/client).\n * @param {string} appId In production we need the appId to look up the correct bucket, as the\n * version of the client lib may differ between apps.\n * @param {string} version The version to retrieve.\n * @return {string} The URL to be inserted into appPackage response or server rendered\n * app index file.\n */\nexport const clientLibraryUrl = (appId: string, version: string) => {\n if (env.isProd()) {\n let file = `${objectStore.sanitizeKey(appId)}/budibase-client.js`\n if (env.CLOUDFRONT_CDN) {\n // append app version to bust the cache\n if (version) {\n file += `?v=${version}`\n }\n // don't need to use presigned for client with cloudfront\n // file is public\n return cloudfront.getUrl(file)\n } else {\n return objectStore.getPresignedUrl(env.APPS_BUCKET_NAME, file)\n }\n } else {\n return `/api/assets/client`\n }\n}\n\nexport const getAppFileUrl = (s3Key: string) => {\n if (env.CLOUDFRONT_CDN) {\n return cloudfront.getPresignedUrl(s3Key)\n } else {\n return objectStore.getPresignedUrl(env.APPS_BUCKET_NAME, s3Key)\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAgB;AAChB,kBAA6B;AAC7B,iBAA4B;AAYrB,MAAM,mBAAmB,CAAC,OAAe,YAAoB;AAClE,MAAI,mBAAAA,QAAI,OAAO,GAAG;AAChB,QAAI,OAAO,GAAG,YAAY,YAAY,KAAK,CAAC;AAC5C,QAAI,mBAAAA,QAAI,gBAAgB;AAEtB,UAAI,SAAS;AACX,gBAAQ,MAAM,OAAO;AAAA,MACvB;AAGA,aAAO,WAAW,OAAO,IAAI;AAAA,IAC/B,OAAO;AACL,aAAO,YAAY,gBAAgB,mBAAAA,QAAI,kBAAkB,IAAI;AAAA,IAC/D;AAAA,EACF,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAEO,MAAM,gBAAgB,CAAC,UAAkB;AAC9C,MAAI,mBAAAA,QAAI,gBAAgB;AACtB,WAAO,WAAW,gBAAgB,KAAK;AAAA,EACzC,OAAO;AACL,WAAO,YAAY,gBAAgB,mBAAAA,QAAI,kBAAkB,KAAK;AAAA,EAChE;AACF;",
|
|
6
|
+
"names": ["env"]
|
|
7
|
+
}
|