@budibase/backend-core 2.9.39-alpha.0 → 2.9.39-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/package.json +5 -5
- 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.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.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.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/features/index.js +105 -0
- package/dist/src/features/index.js.map +7 -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.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.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.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.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 -8467
- package/dist/tests.js.map +0 -7
- package/dist/tests.js.meta.json +0 -1
|
@@ -0,0 +1,275 @@
|
|
|
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 identification_exports = {};
|
|
30
|
+
__export(identification_exports, {
|
|
31
|
+
default: () => identification_default,
|
|
32
|
+
getUniqueTenantId: () => getUniqueTenantId
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(identification_exports);
|
|
35
|
+
var context = __toESM(require("../context"));
|
|
36
|
+
var identityCtx = __toESM(require("../context/identity"));
|
|
37
|
+
var import_environment = __toESM(require("../environment"));
|
|
38
|
+
var import_types = require("@budibase/types");
|
|
39
|
+
var import_processors = require("./processors");
|
|
40
|
+
var import_utils = require("../utils");
|
|
41
|
+
var installation = __toESM(require("../installation"));
|
|
42
|
+
var configs = __toESM(require("../configs"));
|
|
43
|
+
var users = __toESM(require("../users"));
|
|
44
|
+
var import_generic = require("../cache/generic");
|
|
45
|
+
const getCurrentIdentity = async () => {
|
|
46
|
+
let identityContext = identityCtx.getIdentity();
|
|
47
|
+
const environment = getDeploymentEnvironment();
|
|
48
|
+
let identityType;
|
|
49
|
+
if (!identityContext) {
|
|
50
|
+
identityType = import_types.IdentityType.TENANT;
|
|
51
|
+
} else {
|
|
52
|
+
identityType = identityContext.type;
|
|
53
|
+
}
|
|
54
|
+
if (identityType === import_types.IdentityType.INSTALLATION) {
|
|
55
|
+
const installationId = await getInstallationId();
|
|
56
|
+
const hosting = getHostingFromEnv();
|
|
57
|
+
return {
|
|
58
|
+
id: formatDistinctId(installationId, identityType),
|
|
59
|
+
hosting,
|
|
60
|
+
type: identityType,
|
|
61
|
+
installationId,
|
|
62
|
+
environment
|
|
63
|
+
};
|
|
64
|
+
} else if (identityType === import_types.IdentityType.TENANT) {
|
|
65
|
+
const installationId = await getInstallationId();
|
|
66
|
+
const tenantId = await getEventTenantId(context.getTenantId());
|
|
67
|
+
const hosting = getHostingFromEnv();
|
|
68
|
+
return {
|
|
69
|
+
id: formatDistinctId(tenantId, identityType),
|
|
70
|
+
type: identityType,
|
|
71
|
+
hosting,
|
|
72
|
+
installationId,
|
|
73
|
+
tenantId,
|
|
74
|
+
realTenantId: context.getTenantId(),
|
|
75
|
+
environment
|
|
76
|
+
};
|
|
77
|
+
} else if (identityType === import_types.IdentityType.USER) {
|
|
78
|
+
const userContext = identityContext;
|
|
79
|
+
const tenantId = await getEventTenantId(context.getTenantId());
|
|
80
|
+
const installationId = await getInstallationId();
|
|
81
|
+
const account = userContext.account;
|
|
82
|
+
let hosting;
|
|
83
|
+
if (account) {
|
|
84
|
+
hosting = account.hosting;
|
|
85
|
+
} else {
|
|
86
|
+
hosting = getHostingFromEnv();
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
id: userContext._id,
|
|
90
|
+
type: identityType,
|
|
91
|
+
hosting,
|
|
92
|
+
installationId,
|
|
93
|
+
tenantId,
|
|
94
|
+
environment,
|
|
95
|
+
realTenantId: context.getTenantId(),
|
|
96
|
+
hostInfo: userContext.hostInfo
|
|
97
|
+
};
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error("Unknown identity type");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const identifyInstallationGroup = async (installId, timestamp) => {
|
|
103
|
+
const id = installId;
|
|
104
|
+
const type = import_types.IdentityType.INSTALLATION;
|
|
105
|
+
const hosting = getHostingFromEnv();
|
|
106
|
+
const version = import_environment.default.VERSION;
|
|
107
|
+
const environment = getDeploymentEnvironment();
|
|
108
|
+
const group = {
|
|
109
|
+
id,
|
|
110
|
+
type,
|
|
111
|
+
hosting,
|
|
112
|
+
version,
|
|
113
|
+
environment
|
|
114
|
+
};
|
|
115
|
+
await identifyGroup(group, timestamp);
|
|
116
|
+
await identify({ ...group, id: `$${type}_${id}` }, timestamp);
|
|
117
|
+
};
|
|
118
|
+
const identifyTenantGroup = async (tenantId, account, timestamp) => {
|
|
119
|
+
const id = await getEventTenantId(tenantId);
|
|
120
|
+
const type = import_types.IdentityType.TENANT;
|
|
121
|
+
const installationId = await getInstallationId();
|
|
122
|
+
const environment = getDeploymentEnvironment();
|
|
123
|
+
let hosting;
|
|
124
|
+
let profession;
|
|
125
|
+
let companySize;
|
|
126
|
+
if (account) {
|
|
127
|
+
profession = account.profession;
|
|
128
|
+
companySize = account.size;
|
|
129
|
+
hosting = account.hosting;
|
|
130
|
+
} else {
|
|
131
|
+
hosting = getHostingFromEnv();
|
|
132
|
+
}
|
|
133
|
+
const group = {
|
|
134
|
+
id,
|
|
135
|
+
type,
|
|
136
|
+
hosting,
|
|
137
|
+
environment,
|
|
138
|
+
installationId,
|
|
139
|
+
profession,
|
|
140
|
+
companySize
|
|
141
|
+
};
|
|
142
|
+
await identifyGroup(group, timestamp);
|
|
143
|
+
await identify({ ...group, id: `$${type}_${id}` }, timestamp);
|
|
144
|
+
};
|
|
145
|
+
const identifyUser = async (user, account, timestamp) => {
|
|
146
|
+
const id = user._id;
|
|
147
|
+
const tenantId = await getEventTenantId(user.tenantId);
|
|
148
|
+
const type = import_types.IdentityType.USER;
|
|
149
|
+
let builder = users.hasBuilderPermissions(user);
|
|
150
|
+
let admin = users.hasAdminPermissions(user);
|
|
151
|
+
let providerType;
|
|
152
|
+
if ((0, import_types.isSSOUser)(user)) {
|
|
153
|
+
providerType = user.providerType;
|
|
154
|
+
}
|
|
155
|
+
const accountHolder = account?.budibaseUserId === user._id || false;
|
|
156
|
+
const verified = account && account?.budibaseUserId === user._id ? account.verified : false;
|
|
157
|
+
const installationId = await getInstallationId();
|
|
158
|
+
const hosting = account ? account.hosting : getHostingFromEnv();
|
|
159
|
+
const environment = getDeploymentEnvironment();
|
|
160
|
+
const identity = {
|
|
161
|
+
id,
|
|
162
|
+
type,
|
|
163
|
+
hosting,
|
|
164
|
+
installationId,
|
|
165
|
+
tenantId,
|
|
166
|
+
verified,
|
|
167
|
+
accountHolder,
|
|
168
|
+
providerType,
|
|
169
|
+
builder,
|
|
170
|
+
admin,
|
|
171
|
+
environment
|
|
172
|
+
};
|
|
173
|
+
await identify(identity, timestamp);
|
|
174
|
+
};
|
|
175
|
+
const identifyAccount = async (account) => {
|
|
176
|
+
let id = account.accountId;
|
|
177
|
+
const tenantId = account.tenantId;
|
|
178
|
+
let type = import_types.IdentityType.USER;
|
|
179
|
+
let providerType = (0, import_types.isSSOAccount)(account) ? account.providerType : void 0;
|
|
180
|
+
const verified = account.verified;
|
|
181
|
+
const accountHolder = true;
|
|
182
|
+
const hosting = account.hosting;
|
|
183
|
+
const installationId = await getInstallationId();
|
|
184
|
+
const environment = getDeploymentEnvironment();
|
|
185
|
+
if ((0, import_types.isCloudAccount)(account)) {
|
|
186
|
+
if (account.budibaseUserId) {
|
|
187
|
+
id = account.budibaseUserId;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const identity = {
|
|
191
|
+
id,
|
|
192
|
+
type,
|
|
193
|
+
hosting,
|
|
194
|
+
installationId,
|
|
195
|
+
tenantId,
|
|
196
|
+
providerType,
|
|
197
|
+
verified,
|
|
198
|
+
accountHolder,
|
|
199
|
+
environment
|
|
200
|
+
};
|
|
201
|
+
await identify(identity);
|
|
202
|
+
};
|
|
203
|
+
const identify = async (identity, timestamp) => {
|
|
204
|
+
await import_processors.processors.identify(identity, timestamp);
|
|
205
|
+
};
|
|
206
|
+
const identifyGroup = async (group, timestamp) => {
|
|
207
|
+
await import_processors.processors.identifyGroup(group, timestamp);
|
|
208
|
+
};
|
|
209
|
+
const getDeploymentEnvironment = () => {
|
|
210
|
+
if (import_environment.default.isDev()) {
|
|
211
|
+
return "development";
|
|
212
|
+
} else {
|
|
213
|
+
return import_environment.default.DEPLOYMENT_ENVIRONMENT;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
const getHostingFromEnv = () => {
|
|
217
|
+
return import_environment.default.SELF_HOSTED ? import_types.Hosting.SELF : import_types.Hosting.CLOUD;
|
|
218
|
+
};
|
|
219
|
+
const getInstallationId = async () => {
|
|
220
|
+
if (isAccountPortal()) {
|
|
221
|
+
return "account-portal";
|
|
222
|
+
}
|
|
223
|
+
const install = await installation.getInstall();
|
|
224
|
+
return install.installId;
|
|
225
|
+
};
|
|
226
|
+
const getEventTenantId = async (tenantId) => {
|
|
227
|
+
if (import_environment.default.SELF_HOSTED) {
|
|
228
|
+
return getUniqueTenantId(tenantId);
|
|
229
|
+
} else {
|
|
230
|
+
return tenantId;
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
const getUniqueTenantId = async (tenantId) => {
|
|
234
|
+
return context.doInTenant(tenantId, () => {
|
|
235
|
+
return (0, import_generic.withCache)(import_generic.CacheKey.UNIQUE_TENANT_ID, import_generic.TTL.ONE_DAY, async () => {
|
|
236
|
+
const db = context.getGlobalDB();
|
|
237
|
+
const config = await configs.getSettingsConfigDoc();
|
|
238
|
+
let uniqueTenantId;
|
|
239
|
+
if (config.config.uniqueTenantId) {
|
|
240
|
+
return config.config.uniqueTenantId;
|
|
241
|
+
} else {
|
|
242
|
+
uniqueTenantId = `${(0, import_utils.newid)()}_${tenantId}`;
|
|
243
|
+
config.config.uniqueTenantId = uniqueTenantId;
|
|
244
|
+
await db.put(config);
|
|
245
|
+
return uniqueTenantId;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
};
|
|
250
|
+
const isAccountPortal = () => {
|
|
251
|
+
return import_environment.default.SERVICE === "account-portal";
|
|
252
|
+
};
|
|
253
|
+
const formatDistinctId = (id, type) => {
|
|
254
|
+
if (type === import_types.IdentityType.INSTALLATION || type === import_types.IdentityType.TENANT) {
|
|
255
|
+
return `$${type}_${id}`;
|
|
256
|
+
} else {
|
|
257
|
+
return id;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
var identification_default = {
|
|
261
|
+
getCurrentIdentity,
|
|
262
|
+
identifyInstallationGroup,
|
|
263
|
+
identifyTenantGroup,
|
|
264
|
+
identifyUser,
|
|
265
|
+
identifyAccount,
|
|
266
|
+
identify,
|
|
267
|
+
identifyGroup,
|
|
268
|
+
getInstallationId,
|
|
269
|
+
getUniqueTenantId
|
|
270
|
+
};
|
|
271
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
272
|
+
0 && (module.exports = {
|
|
273
|
+
getUniqueTenantId
|
|
274
|
+
});
|
|
275
|
+
//# sourceMappingURL=identification.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/events/identification.ts"],
|
|
4
|
+
"sourcesContent": ["import * as context from \"../context\"\nimport * as identityCtx from \"../context/identity\"\nimport env from \"../environment\"\nimport {\n Hosting,\n User,\n Identity,\n IdentityType,\n Account,\n isCloudAccount,\n isSSOAccount,\n TenantGroup,\n CloudAccount,\n UserIdentity,\n InstallationGroup,\n UserContext,\n Group,\n isSSOUser,\n} from \"@budibase/types\"\nimport { processors } from \"./processors\"\nimport { newid } from \"../utils\"\nimport * as installation from \"../installation\"\nimport * as configs from \"../configs\"\nimport * as users from \"../users\"\nimport { withCache, TTL, CacheKey } from \"../cache/generic\"\n\n/**\n * An identity can be:\n * - account user (Self host)\n * - budibase user\n * - tenant\n * - installation\n */\nconst getCurrentIdentity = async (): Promise<Identity> => {\n let identityContext = identityCtx.getIdentity()\n const environment = getDeploymentEnvironment()\n\n let identityType\n\n if (!identityContext) {\n identityType = IdentityType.TENANT\n } else {\n identityType = identityContext.type\n }\n\n if (identityType === IdentityType.INSTALLATION) {\n const installationId = await getInstallationId()\n const hosting = getHostingFromEnv()\n return {\n id: formatDistinctId(installationId, identityType),\n hosting,\n type: identityType,\n installationId,\n environment,\n }\n } else if (identityType === IdentityType.TENANT) {\n const installationId = await getInstallationId()\n const tenantId = await getEventTenantId(context.getTenantId())\n const hosting = getHostingFromEnv()\n\n return {\n id: formatDistinctId(tenantId, identityType),\n type: identityType,\n hosting,\n installationId,\n tenantId,\n realTenantId: context.getTenantId(),\n environment,\n }\n } else if (identityType === IdentityType.USER) {\n const userContext = identityContext as UserContext\n const tenantId = await getEventTenantId(context.getTenantId())\n const installationId = await getInstallationId()\n\n const account = userContext.account\n let hosting\n if (account) {\n hosting = account.hosting\n } else {\n hosting = getHostingFromEnv()\n }\n\n return {\n id: userContext._id,\n type: identityType,\n hosting,\n installationId,\n tenantId,\n environment,\n realTenantId: context.getTenantId(),\n hostInfo: userContext.hostInfo,\n }\n } else {\n throw new Error(\"Unknown identity type\")\n }\n}\n\nconst identifyInstallationGroup = async (\n installId: string,\n timestamp?: string | number\n): Promise<void> => {\n const id = installId\n const type = IdentityType.INSTALLATION\n const hosting = getHostingFromEnv()\n const version = env.VERSION\n const environment = getDeploymentEnvironment()\n\n const group: InstallationGroup = {\n id,\n type,\n hosting,\n version,\n environment,\n }\n\n await identifyGroup(group, timestamp)\n // need to create a normal identity for the group to be able to query it globally\n // match the posthog syntax to link this identity to the empty auto generated one\n await identify({ ...group, id: `$${type}_${id}` }, timestamp)\n}\n\nconst identifyTenantGroup = async (\n tenantId: string,\n account: Account | undefined,\n timestamp?: string | number\n): Promise<void> => {\n const id = await getEventTenantId(tenantId)\n const type = IdentityType.TENANT\n const installationId = await getInstallationId()\n const environment = getDeploymentEnvironment()\n\n let hosting: Hosting\n let profession: string | undefined\n let companySize: string | undefined\n\n if (account) {\n profession = account.profession\n companySize = account.size\n hosting = account.hosting\n } else {\n hosting = getHostingFromEnv()\n }\n\n const group: TenantGroup = {\n id,\n type,\n hosting,\n environment,\n installationId,\n profession,\n companySize,\n }\n\n await identifyGroup(group, timestamp)\n // need to create a normal identity for the group to be able to query it globally\n // match the posthog syntax to link this identity to the auto generated one\n await identify({ ...group, id: `$${type}_${id}` }, timestamp)\n}\n\nconst identifyUser = async (\n user: User,\n account: CloudAccount | undefined,\n timestamp?: string | number\n) => {\n const id = user._id as string\n const tenantId = await getEventTenantId(user.tenantId)\n const type = IdentityType.USER\n let builder = users.hasBuilderPermissions(user)\n let admin = users.hasAdminPermissions(user)\n let providerType\n if (isSSOUser(user)) {\n providerType = user.providerType\n }\n const accountHolder = account?.budibaseUserId === user._id || false\n const verified =\n account && account?.budibaseUserId === user._id ? account.verified : false\n const installationId = await getInstallationId()\n const hosting = account ? account.hosting : getHostingFromEnv()\n const environment = getDeploymentEnvironment()\n\n const identity: UserIdentity = {\n id,\n type,\n hosting,\n installationId,\n tenantId,\n verified,\n accountHolder,\n providerType,\n builder,\n admin,\n environment,\n }\n\n await identify(identity, timestamp)\n}\n\nconst identifyAccount = async (account: Account) => {\n let id = account.accountId\n const tenantId = account.tenantId\n let type = IdentityType.USER\n let providerType = isSSOAccount(account) ? account.providerType : undefined\n const verified = account.verified\n const accountHolder = true\n const hosting = account.hosting\n const installationId = await getInstallationId()\n const environment = getDeploymentEnvironment()\n\n if (isCloudAccount(account)) {\n if (account.budibaseUserId) {\n // use the budibase user as the id if set\n id = account.budibaseUserId\n }\n }\n\n const identity: UserIdentity = {\n id,\n type,\n hosting,\n installationId,\n tenantId,\n providerType,\n verified,\n accountHolder,\n environment,\n }\n\n await identify(identity)\n}\n\nconst identify = async (identity: Identity, timestamp?: string | number) => {\n await processors.identify(identity, timestamp)\n}\n\nconst identifyGroup = async (group: Group, timestamp?: string | number) => {\n await processors.identifyGroup(group, timestamp)\n}\n\nconst getDeploymentEnvironment = () => {\n if (env.isDev()) {\n return \"development\"\n } else {\n return env.DEPLOYMENT_ENVIRONMENT\n }\n}\n\nconst getHostingFromEnv = () => {\n return env.SELF_HOSTED ? Hosting.SELF : Hosting.CLOUD\n}\n\nconst getInstallationId = async () => {\n if (isAccountPortal()) {\n return \"account-portal\"\n }\n const install = await installation.getInstall()\n return install.installId\n}\n\nconst getEventTenantId = async (tenantId: string): Promise<string> => {\n if (env.SELF_HOSTED) {\n return getUniqueTenantId(tenantId)\n } else {\n // tenant id's in the cloud are already unique\n return tenantId\n }\n}\n\nexport const getUniqueTenantId = async (tenantId: string): Promise<string> => {\n // make sure this tenantId always matches the tenantId in context\n return context.doInTenant(tenantId, () => {\n return withCache(CacheKey.UNIQUE_TENANT_ID, TTL.ONE_DAY, async () => {\n const db = context.getGlobalDB()\n const config = await configs.getSettingsConfigDoc()\n\n let uniqueTenantId: string\n if (config.config.uniqueTenantId) {\n return config.config.uniqueTenantId\n } else {\n uniqueTenantId = `${newid()}_${tenantId}`\n config.config.uniqueTenantId = uniqueTenantId\n await db.put(config)\n return uniqueTenantId\n }\n })\n })\n}\n\nconst isAccountPortal = () => {\n return env.SERVICE === \"account-portal\"\n}\n\nconst formatDistinctId = (id: string, type: IdentityType) => {\n if (type === IdentityType.INSTALLATION || type === IdentityType.TENANT) {\n return `$${type}_${id}`\n } else {\n return id\n }\n}\n\nexport default {\n getCurrentIdentity,\n identifyInstallationGroup,\n identifyTenantGroup,\n identifyUser,\n identifyAccount,\n identify,\n identifyGroup,\n getInstallationId,\n getUniqueTenantId,\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAAyB;AACzB,kBAA6B;AAC7B,yBAAgB;AAChB,mBAeO;AACP,wBAA2B;AAC3B,mBAAsB;AACtB,mBAA8B;AAC9B,cAAyB;AACzB,YAAuB;AACvB,qBAAyC;AASzC,MAAM,qBAAqB,YAA+B;AACxD,MAAI,kBAAkB,YAAY,YAAY;AAC9C,QAAM,cAAc,yBAAyB;AAE7C,MAAI;AAEJ,MAAI,CAAC,iBAAiB;AACpB,mBAAe,0BAAa;AAAA,EAC9B,OAAO;AACL,mBAAe,gBAAgB;AAAA,EACjC;AAEA,MAAI,iBAAiB,0BAAa,cAAc;AAC9C,UAAM,iBAAiB,MAAM,kBAAkB;AAC/C,UAAM,UAAU,kBAAkB;AAClC,WAAO;AAAA,MACL,IAAI,iBAAiB,gBAAgB,YAAY;AAAA,MACjD;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,IACF;AAAA,EACF,WAAW,iBAAiB,0BAAa,QAAQ;AAC/C,UAAM,iBAAiB,MAAM,kBAAkB;AAC/C,UAAM,WAAW,MAAM,iBAAiB,QAAQ,YAAY,CAAC;AAC7D,UAAM,UAAU,kBAAkB;AAElC,WAAO;AAAA,MACL,IAAI,iBAAiB,UAAU,YAAY;AAAA,MAC3C,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc,QAAQ,YAAY;AAAA,MAClC;AAAA,IACF;AAAA,EACF,WAAW,iBAAiB,0BAAa,MAAM;AAC7C,UAAM,cAAc;AACpB,UAAM,WAAW,MAAM,iBAAiB,QAAQ,YAAY,CAAC;AA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,CAAC;AACH;AAEA,MAAM,kBAAkB,MAAM;AAC5B,SAAO,mBAAAA,QAAI,YAAY;AACzB;AAEA,MAAM,mBAAmB,CAAC,IAAY,SAAuB;AAC3D,MAAI,SAAS,0BAAa,gBAAgB,SAAS,0BAAa,QAAQ;AACtE,WAAO,IAAI,IAAI,IAAI,EAAE;AAAA,EACvB,OAAO;AACL,WAAO;AAAA,EACT;AACF;AAEA,IAAO,yBAAQ;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;",
|
|
6
|
+
"names": ["env"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
+
mod
|
|
28
|
+
));
|
|
29
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
+
var events_exports = {};
|
|
31
|
+
__export(events_exports, {
|
|
32
|
+
analytics: () => analytics,
|
|
33
|
+
backfillCache: () => backfillCache,
|
|
34
|
+
identification: () => import_identification.default,
|
|
35
|
+
initAsyncEvents: () => initAsyncEvents,
|
|
36
|
+
processors: () => processors,
|
|
37
|
+
shutdown: () => shutdown
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(events_exports);
|
|
40
|
+
__reExport(events_exports, require("./publishers"), module.exports);
|
|
41
|
+
var processors = __toESM(require("./processors"));
|
|
42
|
+
var analytics = __toESM(require("./analytics"));
|
|
43
|
+
var import_identification = __toESM(require("./identification"));
|
|
44
|
+
var backfillCache = __toESM(require("./backfill"));
|
|
45
|
+
var import_processors = require("./processors");
|
|
46
|
+
function initAsyncEvents() {
|
|
47
|
+
}
|
|
48
|
+
const shutdown = () => {
|
|
49
|
+
import_processors.processors.shutdown();
|
|
50
|
+
console.log("Events shutdown");
|
|
51
|
+
};
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
analytics,
|
|
55
|
+
backfillCache,
|
|
56
|
+
identification,
|
|
57
|
+
initAsyncEvents,
|
|
58
|
+
processors,
|
|
59
|
+
shutdown,
|
|
60
|
+
...require("./publishers")
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/events/index.ts"],
|
|
4
|
+
"sourcesContent": ["export * from \"./publishers\"\nexport * as processors from \"./processors\"\nexport * as analytics from \"./analytics\"\nexport { default as identification } from \"./identification\"\nexport * as backfillCache from \"./backfill\"\n\nimport { processors } from \"./processors\"\n\nexport function initAsyncEvents() {}\n\nexport const shutdown = () => {\n processors.shutdown()\n console.log(\"Events shutdown\")\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAc,yBAAd;AACA,iBAA4B;AAC5B,gBAA2B;AAC3B,4BAA0C;AAC1C,oBAA+B;AAE/B,wBAA2B;AAEpB,SAAS,kBAAkB;AAAC;AAE5B,MAAM,WAAW,MAAM;AAC5B,+BAAW,SAAS;AACpB,UAAQ,IAAI,iBAAiB;AAC/B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 AnalyticsProcessor_exports = {};
|
|
30
|
+
__export(AnalyticsProcessor_exports, {
|
|
31
|
+
default: () => AnalyticsProcessor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(AnalyticsProcessor_exports);
|
|
34
|
+
var import_types = require("@budibase/types");
|
|
35
|
+
var import_environment = __toESM(require("../../environment"));
|
|
36
|
+
var analytics = __toESM(require("../analytics"));
|
|
37
|
+
var import_posthog = __toESM(require("./posthog"));
|
|
38
|
+
const EVENT_WHITELIST = [
|
|
39
|
+
import_types.Event.INSTALLATION_VERSION_UPGRADED,
|
|
40
|
+
import_types.Event.INSTALLATION_VERSION_DOWNGRADED
|
|
41
|
+
];
|
|
42
|
+
const IDENTITY_WHITELIST = [import_types.IdentityType.INSTALLATION, import_types.IdentityType.TENANT];
|
|
43
|
+
class AnalyticsProcessor {
|
|
44
|
+
constructor() {
|
|
45
|
+
if (import_environment.default.POSTHOG_TOKEN && !import_environment.default.isTest()) {
|
|
46
|
+
this.posthog = new import_posthog.default(import_environment.default.POSTHOG_TOKEN);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async processEvent(event, identity, properties, timestamp) {
|
|
50
|
+
if (!EVENT_WHITELIST.includes(event) && !await analytics.enabled()) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (this.posthog) {
|
|
54
|
+
await this.posthog.processEvent(event, identity, properties, timestamp);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
async identify(identity, timestamp) {
|
|
58
|
+
if (!IDENTITY_WHITELIST.includes(identity.type) && !await analytics.enabled()) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (this.posthog) {
|
|
62
|
+
await this.posthog.identify(identity, timestamp);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async identifyGroup(group, timestamp) {
|
|
66
|
+
if (this.posthog) {
|
|
67
|
+
await this.posthog.identifyGroup(group, timestamp);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
shutdown() {
|
|
71
|
+
if (this.posthog) {
|
|
72
|
+
this.posthog.shutdown();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=AnalyticsProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/events/processors/AnalyticsProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import { Event, Identity, Group, IdentityType } from \"@budibase/types\"\nimport { EventProcessor } from \"./types\"\nimport env from \"../../environment\"\nimport * as analytics from \"../analytics\"\nimport PosthogProcessor from \"./posthog\"\n\n/**\n * Events that are always captured.\n */\nconst EVENT_WHITELIST = [\n Event.INSTALLATION_VERSION_UPGRADED,\n Event.INSTALLATION_VERSION_DOWNGRADED,\n]\nconst IDENTITY_WHITELIST = [IdentityType.INSTALLATION, IdentityType.TENANT]\n\nexport default class AnalyticsProcessor implements EventProcessor {\n posthog: PosthogProcessor | undefined\n\n constructor() {\n if (env.POSTHOG_TOKEN && !env.isTest()) {\n this.posthog = new PosthogProcessor(env.POSTHOG_TOKEN)\n }\n }\n\n async processEvent(\n event: Event,\n identity: Identity,\n properties: any,\n timestamp?: string | number\n ): Promise<void> {\n if (!EVENT_WHITELIST.includes(event) && !(await analytics.enabled())) {\n return\n }\n if (this.posthog) {\n await this.posthog.processEvent(event, identity, properties, timestamp)\n }\n }\n\n async identify(identity: Identity, timestamp?: string | number) {\n // Group indentifications (tenant and installation) always on\n if (\n !IDENTITY_WHITELIST.includes(identity.type) &&\n !(await analytics.enabled())\n ) {\n return\n }\n if (this.posthog) {\n await this.posthog.identify(identity, timestamp)\n }\n }\n\n async identifyGroup(group: Group, timestamp?: string | number) {\n // Group indentifications (tenant and installation) always on\n if (this.posthog) {\n await this.posthog.identifyGroup(group, timestamp)\n }\n }\n\n shutdown() {\n if (this.posthog) {\n this.posthog.shutdown()\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqD;AAErD,yBAAgB;AAChB,gBAA2B;AAC3B,qBAA6B;AAK7B,MAAM,kBAAkB;AAAA,EACtB,mBAAM;AAAA,EACN,mBAAM;AACR;AACA,MAAM,qBAAqB,CAAC,0BAAa,cAAc,0BAAa,MAAM;AAE1E,MAAO,mBAA2D;AAAA,EAGhE,cAAc;AACZ,QAAI,mBAAAA,QAAI,iBAAiB,CAAC,mBAAAA,QAAI,OAAO,GAAG;AACtC,WAAK,UAAU,IAAI,eAAAC,QAAiB,mBAAAD,QAAI,aAAa;AAAA,IACvD;AAAA,EACF;AAAA,EAEA,MAAM,aACJ,OACA,UACA,YACA,WACe;AACf,QAAI,CAAC,gBAAgB,SAAS,KAAK,KAAK,CAAE,MAAM,UAAU,QAAQ,GAAI;AACpE;AAAA,IACF;AACA,QAAI,KAAK,SAAS;AAChB,YAAM,KAAK,QAAQ,aAAa,OAAO,UAAU,YAAY,SAAS;AAAA,IACxE;AAAA,EACF;AAAA,EAEA,MAAM,SAAS,UAAoB,WAA6B;AAE9D,QACE,CAAC,mBAAmB,SAAS,SAAS,IAAI,KAC1C,CAAE,MAAM,UAAU,QAAQ,GAC1B;AACA;AAAA,IACF;AACA,QAAI,KAAK,SAAS;AAChB,YAAM,KAAK,QAAQ,SAAS,UAAU,SAAS;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,MAAM,cAAc,OAAc,WAA6B;AAE7D,QAAI,KAAK,SAAS;AAChB,YAAM,KAAK,QAAQ,cAAc,OAAO,SAAS;AAAA,IACnD;AAAA,EACF;AAAA,EAEA,WAAW;AACT,QAAI,KAAK,SAAS;AAChB,WAAK,QAAQ,SAAS;AAAA,IACxB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["env", "PosthogProcessor"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
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 AuditLogsProcessor_exports = {};
|
|
30
|
+
__export(AuditLogsProcessor_exports, {
|
|
31
|
+
default: () => AuditLogsProcessor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(AuditLogsProcessor_exports);
|
|
34
|
+
var import_types = require("@budibase/types");
|
|
35
|
+
var import_context = require("../../context");
|
|
36
|
+
var import_queue = require("../../queue");
|
|
37
|
+
var import_utils = require("../../utils");
|
|
38
|
+
var import_environment = __toESM(require("../../environment"));
|
|
39
|
+
class AuditLogsProcessor {
|
|
40
|
+
static {
|
|
41
|
+
this.auditLogsEnabled = false;
|
|
42
|
+
}
|
|
43
|
+
// can't use constructor as need to return promise
|
|
44
|
+
static init(fn) {
|
|
45
|
+
AuditLogsProcessor.auditLogsEnabled = true;
|
|
46
|
+
const writeAuditLogs = fn;
|
|
47
|
+
AuditLogsProcessor.auditLogQueue = (0, import_queue.createQueue)(
|
|
48
|
+
import_queue.JobQueue.AUDIT_LOG
|
|
49
|
+
);
|
|
50
|
+
return AuditLogsProcessor.auditLogQueue.process(async (job) => {
|
|
51
|
+
return (0, import_context.doInTenant)(job.data.tenantId, async () => {
|
|
52
|
+
let properties = job.data.properties;
|
|
53
|
+
if (properties.audited) {
|
|
54
|
+
properties = {
|
|
55
|
+
...properties,
|
|
56
|
+
...properties.audited
|
|
57
|
+
};
|
|
58
|
+
delete properties.audited;
|
|
59
|
+
}
|
|
60
|
+
let hostInfo = {};
|
|
61
|
+
if (import_environment.default.ENABLE_AUDIT_LOG_IP_ADDR) {
|
|
62
|
+
hostInfo = job.data.opts.hostInfo;
|
|
63
|
+
}
|
|
64
|
+
await writeAuditLogs(job.data.event, properties, {
|
|
65
|
+
userId: job.data.opts.userId,
|
|
66
|
+
timestamp: job.data.opts.timestamp,
|
|
67
|
+
appId: job.data.opts.appId,
|
|
68
|
+
hostInfo
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async processEvent(event, identity, properties, timestamp) {
|
|
74
|
+
if (AuditLogsProcessor.auditLogsEnabled && (0, import_utils.isAudited)(event)) {
|
|
75
|
+
const userId = identity.type === import_types.IdentityType.USER ? identity.id : void 0;
|
|
76
|
+
await AuditLogsProcessor.auditLogQueue.add({
|
|
77
|
+
event,
|
|
78
|
+
properties,
|
|
79
|
+
opts: {
|
|
80
|
+
userId,
|
|
81
|
+
timestamp,
|
|
82
|
+
appId: (0, import_context.getAppId)(),
|
|
83
|
+
hostInfo: identity.hostInfo
|
|
84
|
+
},
|
|
85
|
+
tenantId: (0, import_context.getTenantId)()
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async identify(identity, timestamp) {
|
|
90
|
+
}
|
|
91
|
+
async identifyGroup(group, timestamp) {
|
|
92
|
+
}
|
|
93
|
+
shutdown() {
|
|
94
|
+
AuditLogsProcessor.auditLogQueue?.close();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=AuditLogsProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/events/processors/AuditLogsProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import {\n Event,\n Identity,\n Group,\n IdentityType,\n AuditLogQueueEvent,\n AuditLogFn,\n HostInfo,\n} from \"@budibase/types\"\nimport { EventProcessor } from \"./types\"\nimport { getAppId, doInTenant, getTenantId } from \"../../context\"\nimport BullQueue from \"bull\"\nimport { createQueue, JobQueue } from \"../../queue\"\nimport { isAudited } from \"../../utils\"\nimport env from \"../../environment\"\n\nexport default class AuditLogsProcessor implements EventProcessor {\n static auditLogsEnabled = false\n static auditLogQueue: BullQueue.Queue<AuditLogQueueEvent>\n\n // can't use constructor as need to return promise\n static init(fn: AuditLogFn) {\n AuditLogsProcessor.auditLogsEnabled = true\n const writeAuditLogs = fn\n AuditLogsProcessor.auditLogQueue = createQueue<AuditLogQueueEvent>(\n JobQueue.AUDIT_LOG\n )\n return AuditLogsProcessor.auditLogQueue.process(async job => {\n return doInTenant(job.data.tenantId, async () => {\n let properties = job.data.properties\n if (properties.audited) {\n properties = {\n ...properties,\n ...properties.audited,\n }\n delete properties.audited\n }\n\n // this feature is disabled by default due to privacy requirements\n // in some countries - available as env var in-case it is desired\n // in self host deployments\n let hostInfo: HostInfo | undefined = {}\n if (env.ENABLE_AUDIT_LOG_IP_ADDR) {\n hostInfo = job.data.opts.hostInfo\n }\n\n await writeAuditLogs(job.data.event, properties, {\n userId: job.data.opts.userId,\n timestamp: job.data.opts.timestamp,\n appId: job.data.opts.appId,\n hostInfo,\n })\n })\n })\n }\n\n async processEvent(\n event: Event,\n identity: Identity,\n properties: any,\n timestamp?: string\n ): Promise<void> {\n if (AuditLogsProcessor.auditLogsEnabled && isAudited(event)) {\n // only audit log actual events, don't include backfills\n const userId =\n identity.type === IdentityType.USER ? identity.id : undefined\n // add to the event queue, rather than just writing immediately\n await AuditLogsProcessor.auditLogQueue.add({\n event,\n properties,\n opts: {\n userId,\n timestamp,\n appId: getAppId(),\n hostInfo: identity.hostInfo,\n },\n tenantId: getTenantId(),\n })\n }\n }\n\n async identify(identity: Identity, timestamp?: string | number) {\n // no-op\n }\n\n async identifyGroup(group: Group, timestamp?: string | number) {\n // no-op\n }\n\n shutdown(): void {\n AuditLogsProcessor.auditLogQueue?.close()\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAQO;AAEP,qBAAkD;AAElD,mBAAs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MAAM,cAAc,OAAc,WAA6B;AAAA,EAE/D;AAAA,EAEA,WAAiB;AACf,uBAAmB,eAAe,MAAM;AAAA,EAC1C;AACF;",
|
|
6
|
+
"names": ["env"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
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 LoggingProcessor_exports = {};
|
|
30
|
+
__export(LoggingProcessor_exports, {
|
|
31
|
+
default: () => LoggingProcessor
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(LoggingProcessor_exports);
|
|
34
|
+
var import_environment = __toESM(require("../../environment"));
|
|
35
|
+
const skipLogging = import_environment.default.SELF_HOSTED && !import_environment.default.isDev();
|
|
36
|
+
class LoggingProcessor {
|
|
37
|
+
async processEvent(event, identity, properties, timestamp) {
|
|
38
|
+
if (skipLogging) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log(`[audit] [identityType=${identity.type}] ${event}`, properties);
|
|
42
|
+
}
|
|
43
|
+
async identify(identity, timestamp) {
|
|
44
|
+
if (skipLogging) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
console.log(`[audit] identified`, identity);
|
|
48
|
+
}
|
|
49
|
+
async identifyGroup(group, timestamp) {
|
|
50
|
+
if (skipLogging) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
console.log(`[audit] group identified`, group);
|
|
54
|
+
}
|
|
55
|
+
shutdown() {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=LoggingProcessor.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/events/processors/LoggingProcessor.ts"],
|
|
4
|
+
"sourcesContent": ["import { Event, Identity, Group } from \"@budibase/types\"\nimport { EventProcessor } from \"./types\"\nimport env from \"../../environment\"\n\nconst skipLogging = env.SELF_HOSTED && !env.isDev()\n\nexport default class LoggingProcessor implements EventProcessor {\n async processEvent(\n event: Event,\n identity: Identity,\n properties: any,\n timestamp?: string\n ): Promise<void> {\n if (skipLogging) {\n return\n }\n console.log(`[audit] [identityType=${identity.type}] ${event}`, properties)\n }\n\n async identify(identity: Identity, timestamp?: string | number) {\n if (skipLogging) {\n return\n }\n console.log(`[audit] identified`, identity)\n }\n\n async identifyGroup(group: Group, timestamp?: string | number) {\n if (skipLogging) {\n return\n }\n console.log(`[audit] group identified`, group)\n }\n\n shutdown(): void {\n // no-op\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,yBAAgB;AAEhB,MAAM,cAAc,mBAAAA,QAAI,eAAe,CAAC,mBAAAA,QAAI,MAAM;AAElD,MAAO,iBAAyD;AAAA,EAC9D,MAAM,aACJ,OACA,UACA,YACA,WACe;AACf,QAAI,aAAa;AACf;AAAA,IACF;AACA,YAAQ,IAAI,yBAAyB,SAAS,IAAI,KAAK,KAAK,IAAI,UAAU;AAAA,EAC5E;AAAA,EAEA,MAAM,SAAS,UAAoB,WAA6B;AAC9D,QAAI,aAAa;AACf;AAAA,IACF;AACA,YAAQ,IAAI,sBAAsB,QAAQ;AAAA,EAC5C;AAAA,EAEA,MAAM,cAAc,OAAc,WAA6B;AAC7D,QAAI,aAAa;AACf;AAAA,IACF;AACA,YAAQ,IAAI,4BAA4B,KAAK;AAAA,EAC/C;AAAA,EAEA,WAAiB;AAAA,EAEjB;AACF;",
|
|
6
|
+
"names": ["env"]
|
|
7
|
+
}
|