@budibase/backend-core 3.2.41 → 3.2.43
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 +3 -3
- package/dist/src/accounts/accounts.js +83 -0
- package/dist/src/accounts/accounts.js.map +1 -0
- package/dist/src/accounts/api.js +102 -0
- package/dist/src/accounts/api.js.map +1 -0
- package/dist/src/accounts/index.js +18 -0
- package/dist/src/accounts/index.js.map +1 -0
- package/dist/src/cache/appMetadata.js +96 -0
- package/dist/src/cache/appMetadata.js.map +1 -0
- package/dist/src/cache/base/index.js +189 -0
- package/dist/src/cache/base/index.js.map +1 -0
- package/dist/src/cache/docWritethrough.js +123 -0
- package/dist/src/cache/docWritethrough.js.map +1 -0
- package/dist/src/cache/generic.js +37 -0
- package/dist/src/cache/generic.js.map +1 -0
- package/dist/src/cache/index.js +48 -0
- package/dist/src/cache/index.js.map +1 -0
- package/dist/src/cache/invite.js +128 -0
- package/dist/src/cache/invite.js.map +1 -0
- package/dist/src/cache/passwordReset.js +92 -0
- package/dist/src/cache/passwordReset.js.map +1 -0
- package/dist/src/cache/user.js +183 -0
- package/dist/src/cache/user.js.map +1 -0
- package/dist/src/cache/writethrough.js +170 -0
- package/dist/src/cache/writethrough.js.map +1 -0
- package/dist/src/configs/configs.js +294 -0
- package/dist/src/configs/configs.js.map +1 -0
- package/dist/src/configs/index.js +18 -0
- package/dist/src/configs/index.js.map +1 -0
- package/dist/src/constants/db.js +75 -0
- package/dist/src/constants/db.js.map +1 -0
- package/dist/src/constants/index.js +19 -0
- package/dist/src/constants/index.js.map +1 -0
- package/dist/src/constants/misc.js +40 -0
- package/dist/src/constants/misc.js.map +1 -0
- package/dist/src/context/Context.js +14 -0
- package/dist/src/context/Context.js.map +1 -0
- package/dist/src/context/identity.js +81 -0
- package/dist/src/context/identity.js.map +1 -0
- package/dist/src/context/index.js +44 -0
- package/dist/src/context/index.js.map +1 -0
- package/dist/src/context/mainContext.js +446 -0
- package/dist/src/context/mainContext.js.map +1 -0
- package/dist/src/context/types.js +3 -0
- package/dist/src/context/types.js.map +1 -0
- package/dist/src/db/Replication.js +90 -0
- package/dist/src/db/Replication.js.map +1 -0
- package/dist/src/db/couch/DatabaseImpl.js +475 -0
- package/dist/src/db/couch/DatabaseImpl.js.map +1 -0
- package/dist/src/db/couch/connections.js +101 -0
- package/dist/src/db/couch/connections.js.map +1 -0
- package/dist/src/db/couch/index.js +26 -0
- package/dist/src/db/couch/index.js.map +1 -0
- package/dist/src/db/couch/pouchDB.js +108 -0
- package/dist/src/db/couch/pouchDB.js.map +1 -0
- package/dist/src/db/couch/utils.js +60 -0
- package/dist/src/db/couch/utils.js.map +1 -0
- package/dist/src/db/db.js +47 -0
- package/dist/src/db/db.js.map +1 -0
- package/dist/src/db/errors.js +21 -0
- package/dist/src/db/errors.js.map +1 -0
- package/dist/src/db/index.js +58 -0
- package/dist/src/db/index.js.map +1 -0
- package/dist/src/db/instrumentation.js +202 -0
- package/dist/src/db/instrumentation.js.map +1 -0
- package/dist/src/db/lucene.js +638 -0
- package/dist/src/db/lucene.js.map +1 -0
- package/dist/src/db/searchIndexes/index.js +18 -0
- package/dist/src/db/searchIndexes/index.js.map +1 -0
- package/dist/src/db/searchIndexes/searchIndexes.js +76 -0
- package/dist/src/db/searchIndexes/searchIndexes.js.map +1 -0
- package/dist/src/db/utils.js +212 -0
- package/dist/src/db/utils.js.map +1 -0
- package/dist/src/db/views.js +224 -0
- package/dist/src/db/views.js.map +1 -0
- package/dist/src/docIds/conversions.js +62 -0
- package/dist/src/docIds/conversions.js.map +1 -0
- package/dist/src/docIds/ids.js +125 -0
- package/dist/src/docIds/ids.js.map +1 -0
- package/dist/src/docIds/index.js +19 -0
- package/dist/src/docIds/index.js.map +1 -0
- package/dist/src/docIds/newid.js +8 -0
- package/dist/src/docIds/newid.js.map +1 -0
- package/dist/src/docIds/params.js +141 -0
- package/dist/src/docIds/params.js.map +1 -0
- package/dist/src/environment.js +182 -0
- package/dist/src/environment.js.map +1 -0
- package/dist/src/errors/errors.js +97 -0
- package/dist/src/errors/errors.js.map +1 -0
- package/dist/src/errors/index.js +18 -0
- package/dist/src/errors/index.js.map +1 -0
- package/dist/src/events/analytics.js +52 -0
- package/dist/src/events/analytics.js.map +1 -0
- package/dist/src/events/asyncEvents/index.js +19 -0
- package/dist/src/events/asyncEvents/index.js.map +1 -0
- package/dist/src/events/asyncEvents/publisher.js +26 -0
- package/dist/src/events/asyncEvents/publisher.js.map +1 -0
- package/dist/src/events/asyncEvents/queue.js +26 -0
- package/dist/src/events/asyncEvents/queue.js.map +1 -0
- package/dist/src/events/backfill.js +189 -0
- package/dist/src/events/backfill.js.map +1 -0
- package/dist/src/events/events.js +87 -0
- package/dist/src/events/events.js.map +1 -0
- package/dist/src/events/identification.js +299 -0
- package/dist/src/events/identification.js.map +1 -0
- package/dist/src/events/index.js +59 -0
- package/dist/src/events/index.js.map +1 -0
- package/dist/src/events/processors/AnalyticsProcessor.js +103 -0
- package/dist/src/events/processors/AnalyticsProcessor.js.map +1 -0
- package/dist/src/events/processors/AuditLogsProcessor.js +86 -0
- package/dist/src/events/processors/AuditLogsProcessor.js.map +1 -0
- package/dist/src/events/processors/LoggingProcessor.js +47 -0
- package/dist/src/events/processors/LoggingProcessor.js.map +1 -0
- package/dist/src/events/processors/Processors.js +52 -0
- package/dist/src/events/processors/Processors.js.map +1 -0
- package/dist/src/events/processors/index.js +23 -0
- package/dist/src/events/processors/index.js.map +1 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js +147 -0
- package/dist/src/events/processors/posthog/PosthogProcessor.js.map +1 -0
- package/dist/src/events/processors/posthog/index.js +8 -0
- package/dist/src/events/processors/posthog/index.js.map +1 -0
- package/dist/src/events/processors/posthog/rateLimiting.js +129 -0
- package/dist/src/events/processors/posthog/rateLimiting.js.map +1 -0
- package/dist/src/events/processors/types.js +3 -0
- package/dist/src/events/processors/types.js.map +1 -0
- package/dist/src/events/publishers/account.js +43 -0
- package/dist/src/events/publishers/account.js.map +1 -0
- package/dist/src/events/publishers/ai.js +30 -0
- package/dist/src/events/publishers/ai.js.map +1 -0
- package/dist/src/events/publishers/app.js +166 -0
- package/dist/src/events/publishers/app.js.map +1 -0
- package/dist/src/events/publishers/auditLog.js +34 -0
- package/dist/src/events/publishers/auditLog.js.map +1 -0
- package/dist/src/events/publishers/auth.js +80 -0
- package/dist/src/events/publishers/auth.js.map +1 -0
- package/dist/src/events/publishers/automation.js +117 -0
- package/dist/src/events/publishers/automation.js.map +1 -0
- package/dist/src/events/publishers/backfill.js +85 -0
- package/dist/src/events/publishers/backfill.js.map +1 -0
- package/dist/src/events/publishers/backup.js +41 -0
- package/dist/src/events/publishers/backup.js.map +1 -0
- package/dist/src/events/publishers/datasource.js +54 -0
- package/dist/src/events/publishers/datasource.js.map +1 -0
- package/dist/src/events/publishers/email.js +30 -0
- package/dist/src/events/publishers/email.js.map +1 -0
- package/dist/src/events/publishers/environmentVariable.js +44 -0
- package/dist/src/events/publishers/environmentVariable.js.map +1 -0
- package/dist/src/events/publishers/group.js +107 -0
- package/dist/src/events/publishers/group.js.map +1 -0
- package/dist/src/events/publishers/index.js +59 -0
- package/dist/src/events/publishers/index.js.map +1 -0
- package/dist/src/events/publishers/installation.js +52 -0
- package/dist/src/events/publishers/installation.js.map +1 -0
- package/dist/src/events/publishers/layout.js +34 -0
- package/dist/src/events/publishers/layout.js.map +1 -0
- package/dist/src/events/publishers/license.js +77 -0
- package/dist/src/events/publishers/license.js.map +1 -0
- package/dist/src/events/publishers/org.js +52 -0
- package/dist/src/events/publishers/org.js.map +1 -0
- package/dist/src/events/publishers/plugin.js +55 -0
- package/dist/src/events/publishers/plugin.js.map +1 -0
- package/dist/src/events/publishers/query.js +73 -0
- package/dist/src/events/publishers/query.js.map +1 -0
- package/dist/src/events/publishers/role.js +69 -0
- package/dist/src/events/publishers/role.js.map +1 -0
- package/dist/src/events/publishers/rowAction.js +22 -0
- package/dist/src/events/publishers/rowAction.js.map +1 -0
- package/dist/src/events/publishers/rows.js +31 -0
- package/dist/src/events/publishers/rows.js.map +1 -0
- package/dist/src/events/publishers/screen.js +46 -0
- package/dist/src/events/publishers/screen.js.map +1 -0
- package/dist/src/events/publishers/serve.js +47 -0
- package/dist/src/events/publishers/serve.js.map +1 -0
- package/dist/src/events/publishers/table.js +95 -0
- package/dist/src/events/publishers/table.js.map +1 -0
- package/dist/src/events/publishers/user.js +201 -0
- package/dist/src/events/publishers/user.js.map +1 -0
- package/dist/src/events/publishers/view.js +123 -0
- package/dist/src/events/publishers/view.js.map +1 -0
- package/dist/src/helpers.js +13 -0
- package/dist/src/helpers.js.map +1 -0
- package/dist/src/installation.js +159 -0
- package/dist/src/installation.js.map +1 -0
- package/dist/src/logging/alerts.js +23 -0
- package/dist/src/logging/alerts.js.map +1 -0
- package/dist/src/logging/correlation/correlation.js +18 -0
- package/dist/src/logging/correlation/correlation.js.map +1 -0
- package/dist/src/logging/correlation/index.js +18 -0
- package/dist/src/logging/correlation/index.js.map +1 -0
- package/dist/src/logging/index.js +45 -0
- package/dist/src/logging/index.js.map +1 -0
- package/dist/src/logging/pino/logger.js +234 -0
- package/dist/src/logging/pino/logger.js.map +1 -0
- package/dist/src/logging/system.js +110 -0
- package/dist/src/logging/system.js.map +1 -0
- package/dist/src/objectStore/buckets/app.js +95 -0
- package/dist/src/objectStore/buckets/app.js.map +1 -0
- package/dist/src/objectStore/buckets/global.js +68 -0
- package/dist/src/objectStore/buckets/global.js.map +1 -0
- package/dist/src/objectStore/buckets/index.js +20 -0
- package/dist/src/objectStore/buckets/index.js.map +1 -0
- package/dist/src/objectStore/buckets/plugins.js +104 -0
- package/dist/src/objectStore/buckets/plugins.js.map +1 -0
- package/dist/src/objectStore/cloudfront.js +73 -0
- package/dist/src/objectStore/cloudfront.js.map +1 -0
- package/dist/src/objectStore/index.js +20 -0
- package/dist/src/objectStore/index.js.map +1 -0
- package/dist/src/objectStore/objectStore.js +509 -0
- package/dist/src/objectStore/objectStore.js.map +1 -0
- package/dist/src/objectStore/utils.js +148 -0
- package/dist/src/objectStore/utils.js.map +1 -0
- package/dist/src/platform/index.js +43 -0
- package/dist/src/platform/index.js.map +1 -0
- package/dist/src/platform/platformDb.js +9 -0
- package/dist/src/platform/platformDb.js.map +1 -0
- package/dist/src/platform/tenants.js +149 -0
- package/dist/src/platform/tenants.js.map +1 -0
- package/dist/src/platform/users.js +118 -0
- package/dist/src/platform/users.js.map +1 -0
- package/dist/src/queue/constants.js +13 -0
- package/dist/src/queue/constants.js.map +1 -0
- package/dist/src/queue/inMemoryQueue.js +192 -0
- package/dist/src/queue/inMemoryQueue.js.map +1 -0
- package/dist/src/queue/index.js +19 -0
- package/dist/src/queue/index.js.map +1 -0
- package/dist/src/queue/listeners.js +199 -0
- package/dist/src/queue/listeners.js.map +1 -0
- package/dist/src/queue/queue.js +124 -0
- package/dist/src/queue/queue.js.map +1 -0
- package/dist/src/redis/index.js +47 -0
- package/dist/src/redis/index.js.map +1 -0
- package/dist/src/redis/init.js +184 -0
- package/dist/src/redis/init.js.map +1 -0
- package/dist/src/redis/redis.js +396 -0
- package/dist/src/redis/redis.js.map +1 -0
- package/dist/src/redis/redlockImpl.js +181 -0
- package/dist/src/redis/redlockImpl.js.map +1 -0
- package/dist/src/redis/utils.js +131 -0
- package/dist/src/redis/utils.js.map +1 -0
- package/dist/src/security/auth.js +26 -0
- package/dist/src/security/auth.js.map +1 -0
- package/dist/src/security/index.js +18 -0
- package/dist/src/security/index.js.map +1 -0
- package/dist/src/security/roles.js +566 -0
- package/dist/src/security/roles.js.map +1 -0
- package/dist/src/security/sessions.js +156 -0
- package/dist/src/security/sessions.js.map +1 -0
- package/dist/src/sql/utils.js +180 -0
- package/dist/src/sql/utils.js.map +1 -0
- package/dist/src/tenancy/db.js +9 -0
- package/dist/src/tenancy/db.js.map +1 -0
- package/dist/src/tenancy/index.js +19 -0
- package/dist/src/tenancy/index.js.map +1 -0
- package/dist/src/tenancy/tenancy.js +125 -0
- package/dist/src/tenancy/tenancy.js.map +1 -0
- package/dist/src/timers/index.js +18 -0
- package/dist/src/timers/index.js.map +1 -0
- package/dist/src/timers/timers.js +25 -0
- package/dist/src/timers/timers.js.map +1 -0
- package/dist/src/users/db.js +489 -0
- package/dist/src/users/db.js.map +1 -0
- package/dist/src/users/events.js +179 -0
- package/dist/src/users/events.js.map +1 -0
- package/dist/src/users/index.js +23 -0
- package/dist/src/users/index.js.map +1 -0
- package/dist/src/users/lookup.js +126 -0
- package/dist/src/users/lookup.js.map +1 -0
- package/dist/src/users/users.js +376 -0
- package/dist/src/users/users.js.map +1 -0
- package/dist/src/users/utils.js +127 -0
- package/dist/src/users/utils.js.map +1 -0
- package/dist/src/utils/Duration.js +54 -0
- package/dist/src/utils/Duration.js.map +1 -0
- package/dist/src/utils/hashing.js +46 -0
- package/dist/src/utils/hashing.js.map +1 -0
- package/dist/src/utils/index.js +21 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/utils/stringUtils.js +8 -0
- package/dist/src/utils/stringUtils.js.map +1 -0
- package/dist/src/utils/utils.js +267 -0
- package/dist/src/utils/utils.js.map +1 -0
- package/dist/tests/core/logging.js +33 -0
- package/dist/tests/core/logging.js.map +1 -0
- package/dist/tests/core/utilities/index.js +48 -0
- package/dist/tests/core/utilities/index.js.map +1 -0
- package/dist/tests/core/utilities/jestUtils.js +21 -0
- package/dist/tests/core/utilities/jestUtils.js.map +1 -0
- package/dist/tests/core/utilities/mocks/alerts.js +40 -0
- package/dist/tests/core/utilities/mocks/alerts.js.map +1 -0
- package/dist/tests/core/utilities/mocks/date.js +6 -0
- package/dist/tests/core/utilities/mocks/date.js.map +1 -0
- package/dist/tests/core/utilities/mocks/events.js +155 -0
- package/dist/tests/core/utilities/mocks/events.js.map +1 -0
- package/dist/tests/core/utilities/mocks/index.js +47 -0
- package/dist/tests/core/utilities/mocks/index.js.map +1 -0
- package/dist/tests/core/utilities/mocks/licenses.js +109 -0
- package/dist/tests/core/utilities/mocks/licenses.js.map +1 -0
- package/dist/tests/core/utilities/queue.js +21 -0
- package/dist/tests/core/utilities/queue.js.map +1 -0
- package/dist/tests/core/utilities/structures/Chance.js +21 -0
- package/dist/tests/core/utilities/structures/Chance.js.map +1 -0
- package/dist/tests/core/utilities/structures/accounts.js +43 -0
- package/dist/tests/core/utilities/structures/accounts.js.map +1 -0
- package/dist/tests/core/utilities/structures/apps.js +23 -0
- package/dist/tests/core/utilities/structures/apps.js.map +1 -0
- package/dist/tests/core/utilities/structures/common.js +11 -0
- package/dist/tests/core/utilities/structures/common.js.map +1 -0
- package/dist/tests/core/utilities/structures/db.js +15 -0
- package/dist/tests/core/utilities/structures/db.js.map +1 -0
- package/dist/tests/core/utilities/structures/documents/index.js +18 -0
- package/dist/tests/core/utilities/structures/documents/index.js.map +1 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js +38 -0
- package/dist/tests/core/utilities/structures/documents/platform/index.js.map +1 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js +47 -0
- package/dist/tests/core/utilities/structures/documents/platform/installation.js.map +1 -0
- package/dist/tests/core/utilities/structures/generator.js +9 -0
- package/dist/tests/core/utilities/structures/generator.js.map +1 -0
- package/dist/tests/core/utilities/structures/index.js +56 -0
- package/dist/tests/core/utilities/structures/index.js.map +1 -0
- package/dist/tests/core/utilities/structures/koa.js +10 -0
- package/dist/tests/core/utilities/structures/koa.js.map +1 -0
- package/dist/tests/core/utilities/structures/licenses.js +157 -0
- package/dist/tests/core/utilities/structures/licenses.js.map +1 -0
- package/dist/tests/core/utilities/structures/plugins.js +22 -0
- package/dist/tests/core/utilities/structures/plugins.js.map +1 -0
- package/dist/tests/core/utilities/structures/quotas.js +73 -0
- package/dist/tests/core/utilities/structures/quotas.js.map +1 -0
- package/dist/tests/core/utilities/structures/scim.js +62 -0
- package/dist/tests/core/utilities/structures/scim.js.map +1 -0
- package/dist/tests/core/utilities/structures/sso.js +140 -0
- package/dist/tests/core/utilities/structures/sso.js.map +1 -0
- package/dist/tests/core/utilities/structures/tenants.js +8 -0
- package/dist/tests/core/utilities/structures/tenants.js.map +1 -0
- package/dist/tests/core/utilities/structures/userGroups.js +12 -0
- package/dist/tests/core/utilities/structures/userGroups.js.map +1 -0
- package/dist/tests/core/utilities/structures/users.js +53 -0
- package/dist/tests/core/utilities/structures/users.js.map +1 -0
- package/dist/tests/core/utilities/testContainerUtils.js +161 -0
- package/dist/tests/core/utilities/testContainerUtils.js.map +1 -0
- package/dist/tests/core/utilities/utils/index.js +39 -0
- package/dist/tests/core/utilities/utils/index.js.map +1 -0
- package/dist/tests/core/utilities/utils/queue.js +37 -0
- package/dist/tests/core/utilities/utils/queue.js.map +1 -0
- package/dist/tests/core/utilities/utils/time.js +7 -0
- package/dist/tests/core/utilities/utils/time.js.map +1 -0
- package/dist/tests/extra/DBTestConfiguration.js +65 -0
- package/dist/tests/extra/DBTestConfiguration.js.map +1 -0
- package/dist/tests/extra/index.js +43 -0
- package/dist/tests/extra/index.js.map +1 -0
- package/dist/tests/extra/testEnv.js +136 -0
- package/dist/tests/extra/testEnv.js.map +1 -0
- package/dist/tests/index.js +19 -0
- package/dist/tests/index.js.map +1 -0
- package/dist/tests/jestEnv.js +12 -0
- package/dist/tests/jestEnv.js.map +1 -0
- package/dist/tests/jestSetup.js +33 -0
- package/dist/tests/jestSetup.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.getUniqueTenantId = void 0;
|
|
49
|
+
const context = __importStar(require("../context"));
|
|
50
|
+
const identityCtx = __importStar(require("../context/identity"));
|
|
51
|
+
const environment_1 = __importDefault(require("../environment"));
|
|
52
|
+
const types_1 = require("@budibase/types");
|
|
53
|
+
const processors_1 = require("./processors");
|
|
54
|
+
const utils_1 = require("../utils");
|
|
55
|
+
const installation = __importStar(require("../installation"));
|
|
56
|
+
const configs = __importStar(require("../configs"));
|
|
57
|
+
const users = __importStar(require("../users"));
|
|
58
|
+
const generic_1 = require("../cache/generic");
|
|
59
|
+
/**
|
|
60
|
+
* An identity can be:
|
|
61
|
+
* - account user (Self host)
|
|
62
|
+
* - budibase user
|
|
63
|
+
* - tenant
|
|
64
|
+
* - installation
|
|
65
|
+
*/
|
|
66
|
+
const getCurrentIdentity = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
let identityContext = identityCtx.getIdentity();
|
|
68
|
+
const environment = getDeploymentEnvironment();
|
|
69
|
+
let identityType;
|
|
70
|
+
if (!identityContext) {
|
|
71
|
+
identityType = types_1.IdentityType.TENANT;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
identityType = identityContext.type;
|
|
75
|
+
}
|
|
76
|
+
if (identityType === types_1.IdentityType.INSTALLATION) {
|
|
77
|
+
const installationId = yield getInstallationId();
|
|
78
|
+
const hosting = getHostingFromEnv();
|
|
79
|
+
return {
|
|
80
|
+
id: formatDistinctId(installationId, identityType),
|
|
81
|
+
hosting,
|
|
82
|
+
type: identityType,
|
|
83
|
+
installationId,
|
|
84
|
+
environment,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
else if (identityType === types_1.IdentityType.TENANT) {
|
|
88
|
+
const installationId = yield getInstallationId();
|
|
89
|
+
const tenantId = yield getEventTenantId(context.getTenantId());
|
|
90
|
+
const hosting = getHostingFromEnv();
|
|
91
|
+
return {
|
|
92
|
+
id: formatDistinctId(tenantId, identityType),
|
|
93
|
+
type: identityType,
|
|
94
|
+
hosting,
|
|
95
|
+
installationId,
|
|
96
|
+
tenantId,
|
|
97
|
+
realTenantId: context.getTenantId(),
|
|
98
|
+
environment,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
else if (identityType === types_1.IdentityType.USER) {
|
|
102
|
+
const userContext = identityContext;
|
|
103
|
+
const tenantId = yield getEventTenantId(context.getTenantId());
|
|
104
|
+
const installationId = yield getInstallationId();
|
|
105
|
+
const account = userContext.account;
|
|
106
|
+
let hosting;
|
|
107
|
+
if (account) {
|
|
108
|
+
hosting = account.hosting;
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
hosting = getHostingFromEnv();
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
id: userContext._id,
|
|
115
|
+
type: identityType,
|
|
116
|
+
hosting,
|
|
117
|
+
installationId,
|
|
118
|
+
tenantId,
|
|
119
|
+
environment,
|
|
120
|
+
realTenantId: context.getTenantId(),
|
|
121
|
+
hostInfo: userContext.hostInfo,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
throw new Error("Unknown identity type");
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
const identifyInstallationGroup = (installId, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
129
|
+
const id = installId;
|
|
130
|
+
const type = types_1.IdentityType.INSTALLATION;
|
|
131
|
+
const hosting = getHostingFromEnv();
|
|
132
|
+
const version = environment_1.default.VERSION;
|
|
133
|
+
const environment = getDeploymentEnvironment();
|
|
134
|
+
const group = {
|
|
135
|
+
id,
|
|
136
|
+
type,
|
|
137
|
+
hosting,
|
|
138
|
+
version,
|
|
139
|
+
environment,
|
|
140
|
+
};
|
|
141
|
+
yield identifyGroup(group, timestamp);
|
|
142
|
+
// need to create a normal identity for the group to be able to query it globally
|
|
143
|
+
// match the posthog syntax to link this identity to the empty auto generated one
|
|
144
|
+
yield identify(Object.assign(Object.assign({}, group), { id: `$${type}_${id}` }), timestamp);
|
|
145
|
+
});
|
|
146
|
+
const identifyTenantGroup = (tenantId, hosting, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const id = yield getEventTenantId(tenantId);
|
|
148
|
+
const type = types_1.IdentityType.TENANT;
|
|
149
|
+
const installationId = yield getInstallationId();
|
|
150
|
+
const environment = getDeploymentEnvironment();
|
|
151
|
+
const group = {
|
|
152
|
+
id,
|
|
153
|
+
type,
|
|
154
|
+
hosting,
|
|
155
|
+
environment,
|
|
156
|
+
installationId,
|
|
157
|
+
};
|
|
158
|
+
yield identifyGroup(group, timestamp);
|
|
159
|
+
// need to create a normal identity for the group to be able to query it globally
|
|
160
|
+
// match the posthog syntax to link this identity to the auto generated one
|
|
161
|
+
yield identify(Object.assign(Object.assign({}, group), { id: `$${type}_${id}` }), timestamp);
|
|
162
|
+
});
|
|
163
|
+
const identifyUser = (user, account, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
+
const id = user._id;
|
|
165
|
+
const tenantId = yield getEventTenantId(user.tenantId);
|
|
166
|
+
const type = types_1.IdentityType.USER;
|
|
167
|
+
let builder = users.hasBuilderPermissions(user);
|
|
168
|
+
let admin = users.hasAdminPermissions(user);
|
|
169
|
+
let providerType;
|
|
170
|
+
if ((0, types_1.isSSOUser)(user)) {
|
|
171
|
+
providerType = user.providerType;
|
|
172
|
+
}
|
|
173
|
+
const accountHolder = yield users.getExistingAccounts([user.email]);
|
|
174
|
+
const isAccountHolder = accountHolder.length > 0;
|
|
175
|
+
const verified = !!account && isAccountHolder && account.verified;
|
|
176
|
+
const installationId = yield getInstallationId();
|
|
177
|
+
const hosting = account ? account.hosting : getHostingFromEnv();
|
|
178
|
+
const environment = getDeploymentEnvironment();
|
|
179
|
+
const identity = {
|
|
180
|
+
id,
|
|
181
|
+
type,
|
|
182
|
+
hosting,
|
|
183
|
+
installationId,
|
|
184
|
+
tenantId,
|
|
185
|
+
verified,
|
|
186
|
+
accountHolder: isAccountHolder,
|
|
187
|
+
providerType,
|
|
188
|
+
builder,
|
|
189
|
+
admin,
|
|
190
|
+
environment,
|
|
191
|
+
};
|
|
192
|
+
yield identify(identity, timestamp);
|
|
193
|
+
});
|
|
194
|
+
const identifyAccount = (account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
195
|
+
let id = account.accountId;
|
|
196
|
+
const tenantId = account.tenantId;
|
|
197
|
+
let type = types_1.IdentityType.USER;
|
|
198
|
+
let providerType = (0, types_1.isSSOAccount)(account) ? account.providerType : undefined;
|
|
199
|
+
const verified = account.verified;
|
|
200
|
+
const accountHolder = true;
|
|
201
|
+
const hosting = account.hosting;
|
|
202
|
+
const installationId = yield getInstallationId();
|
|
203
|
+
const environment = getDeploymentEnvironment();
|
|
204
|
+
if ((0, types_1.isCloudAccount)(account)) {
|
|
205
|
+
const user = yield users.getGlobalUserByEmail(account.email);
|
|
206
|
+
if (user === null || user === void 0 ? void 0 : user._id) {
|
|
207
|
+
// use the budibase user as the id if set
|
|
208
|
+
id = user._id;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
const identity = {
|
|
212
|
+
id,
|
|
213
|
+
type,
|
|
214
|
+
hosting,
|
|
215
|
+
installationId,
|
|
216
|
+
tenantId,
|
|
217
|
+
providerType,
|
|
218
|
+
verified,
|
|
219
|
+
accountHolder,
|
|
220
|
+
environment,
|
|
221
|
+
};
|
|
222
|
+
yield identify(identity);
|
|
223
|
+
});
|
|
224
|
+
const identify = (identity, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
225
|
+
yield processors_1.processors.identify(identity, timestamp);
|
|
226
|
+
});
|
|
227
|
+
const identifyGroup = (group, timestamp) => __awaiter(void 0, void 0, void 0, function* () {
|
|
228
|
+
yield processors_1.processors.identifyGroup(group, timestamp);
|
|
229
|
+
});
|
|
230
|
+
const getDeploymentEnvironment = () => {
|
|
231
|
+
if (environment_1.default.isDev()) {
|
|
232
|
+
return "development";
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return environment_1.default.DEPLOYMENT_ENVIRONMENT;
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
const getHostingFromEnv = () => {
|
|
239
|
+
return environment_1.default.SELF_HOSTED ? types_1.Hosting.SELF : types_1.Hosting.CLOUD;
|
|
240
|
+
};
|
|
241
|
+
const getInstallationId = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
242
|
+
if (isAccountPortal()) {
|
|
243
|
+
return "account-portal";
|
|
244
|
+
}
|
|
245
|
+
const install = yield installation.getInstall();
|
|
246
|
+
return install.installId;
|
|
247
|
+
});
|
|
248
|
+
const getEventTenantId = (tenantId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
249
|
+
if (environment_1.default.SELF_HOSTED) {
|
|
250
|
+
return (0, exports.getUniqueTenantId)(tenantId);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
// tenant id's in the cloud are already unique
|
|
254
|
+
return tenantId;
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
const getUniqueTenantId = (tenantId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
258
|
+
// make sure this tenantId always matches the tenantId in context
|
|
259
|
+
return context.doInTenant(tenantId, () => {
|
|
260
|
+
return (0, generic_1.withCache)(generic_1.CacheKey.UNIQUE_TENANT_ID, generic_1.TTL.ONE_DAY, () => __awaiter(void 0, void 0, void 0, function* () {
|
|
261
|
+
const db = context.getGlobalDB();
|
|
262
|
+
const config = yield configs.getSettingsConfigDoc();
|
|
263
|
+
let uniqueTenantId;
|
|
264
|
+
if (config.config.uniqueTenantId) {
|
|
265
|
+
return config.config.uniqueTenantId;
|
|
266
|
+
}
|
|
267
|
+
else {
|
|
268
|
+
uniqueTenantId = `${(0, utils_1.newid)()}_${tenantId}`;
|
|
269
|
+
config.config.uniqueTenantId = uniqueTenantId;
|
|
270
|
+
yield db.put(config);
|
|
271
|
+
return uniqueTenantId;
|
|
272
|
+
}
|
|
273
|
+
}));
|
|
274
|
+
});
|
|
275
|
+
});
|
|
276
|
+
exports.getUniqueTenantId = getUniqueTenantId;
|
|
277
|
+
const isAccountPortal = () => {
|
|
278
|
+
return environment_1.default.SERVICE === "account-portal";
|
|
279
|
+
};
|
|
280
|
+
const formatDistinctId = (id, type) => {
|
|
281
|
+
if (type === types_1.IdentityType.INSTALLATION || type === types_1.IdentityType.TENANT) {
|
|
282
|
+
return `$${type}_${id}`;
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
return id;
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
exports.default = {
|
|
289
|
+
getCurrentIdentity,
|
|
290
|
+
identifyInstallationGroup,
|
|
291
|
+
identifyTenantGroup,
|
|
292
|
+
identifyUser,
|
|
293
|
+
identifyAccount,
|
|
294
|
+
identify,
|
|
295
|
+
identifyGroup,
|
|
296
|
+
getInstallationId,
|
|
297
|
+
getUniqueTenantId: exports.getUniqueTenantId,
|
|
298
|
+
};
|
|
299
|
+
//# sourceMappingURL=identification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identification.js","sourceRoot":"","sources":["../../../src/events/identification.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAAqC;AACrC,iEAAkD;AAClD,iEAAgC;AAChC,2CAewB;AACxB,6CAAyC;AACzC,oCAAgC;AAChC,8DAA+C;AAC/C,oDAAqC;AACrC,gDAAiC;AACjC,8CAA2D;AAE3D;;;;;;GAMG;AACH,MAAM,kBAAkB,GAAG,GAA4B,EAAE;IACvD,IAAI,eAAe,GAAG,WAAW,CAAC,WAAW,EAAE,CAAA;IAC/C,MAAM,WAAW,GAAG,wBAAwB,EAAE,CAAA;IAE9C,IAAI,YAAY,CAAA;IAEhB,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,YAAY,GAAG,oBAAY,CAAC,MAAM,CAAA;IACpC,CAAC;SAAM,CA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AAA;AAED,kBAAe;IACb,kBAAkB;IAClB,yBAAyB;IACzB,mBAAmB;IACnB,YAAY;IACZ,eAAe;IACf,QAAQ;IACR,aAAa;IACb,iBAAiB;IACjB,iBAAiB,EAAjB,yBAAiB;CAClB,CAAA"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.shutdown = exports.publishEvent = exports.backfillCache = exports.identification = exports.analytics = exports.processors = void 0;
|
|
43
|
+
exports.initAsyncEvents = initAsyncEvents;
|
|
44
|
+
__exportStar(require("./publishers"), exports);
|
|
45
|
+
exports.processors = __importStar(require("./processors"));
|
|
46
|
+
exports.analytics = __importStar(require("./analytics"));
|
|
47
|
+
var identification_1 = require("./identification");
|
|
48
|
+
Object.defineProperty(exports, "identification", { enumerable: true, get: function () { return __importDefault(identification_1).default; } });
|
|
49
|
+
exports.backfillCache = __importStar(require("./backfill"));
|
|
50
|
+
var events_1 = require("./events");
|
|
51
|
+
Object.defineProperty(exports, "publishEvent", { enumerable: true, get: function () { return events_1.publishEvent; } });
|
|
52
|
+
const processors_1 = require("./processors");
|
|
53
|
+
function initAsyncEvents() { }
|
|
54
|
+
const shutdown = () => {
|
|
55
|
+
processors_1.processors.shutdown();
|
|
56
|
+
console.log("Events shutdown");
|
|
57
|
+
};
|
|
58
|
+
exports.shutdown = shutdown;
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/events/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,0CAAoC;AATpC,+CAA4B;AAC5B,2DAA0C;AAC1C,yDAAwC;AACxC,mDAA4D;AAAnD,iIAAA,OAAO,OAAkB;AAClC,4DAA2C;AAC3C,mCAAuC;AAA9B,sGAAA,YAAY,OAAA;AAErB,6CAAyC;AAEzC,SAAgB,eAAe,KAAI,CAAC;AAE7B,MAAM,QAAQ,GAAG,GAAG,EAAE;IAC3B,uBAAU,CAAC,QAAQ,EAAE,CAAA;IACrB,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;AAChC,CAAC,CAAA;AAHY,QAAA,QAAQ,YAGpB"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
45
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
const types_1 = require("@budibase/types");
|
|
49
|
+
const environment_1 = __importDefault(require("../../environment"));
|
|
50
|
+
const analytics = __importStar(require("../analytics"));
|
|
51
|
+
const posthog_1 = __importDefault(require("./posthog"));
|
|
52
|
+
/**
|
|
53
|
+
* Events that are always captured.
|
|
54
|
+
*/
|
|
55
|
+
const EVENT_WHITELIST = [
|
|
56
|
+
types_1.Event.INSTALLATION_VERSION_UPGRADED,
|
|
57
|
+
types_1.Event.INSTALLATION_VERSION_DOWNGRADED,
|
|
58
|
+
];
|
|
59
|
+
const IDENTITY_WHITELIST = [types_1.IdentityType.INSTALLATION, types_1.IdentityType.TENANT];
|
|
60
|
+
class AnalyticsProcessor {
|
|
61
|
+
constructor() {
|
|
62
|
+
if (environment_1.default.POSTHOG_TOKEN && !environment_1.default.isTest()) {
|
|
63
|
+
this.posthog = new posthog_1.default(environment_1.default.POSTHOG_TOKEN);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
processEvent(event, identity, properties, timestamp) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
if (!EVENT_WHITELIST.includes(event) && !(yield analytics.enabled())) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (this.posthog) {
|
|
72
|
+
yield this.posthog.processEvent(event, identity, properties, timestamp);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
identify(identity, timestamp) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
// Group indentifications (tenant and installation) always on
|
|
79
|
+
if (!IDENTITY_WHITELIST.includes(identity.type) &&
|
|
80
|
+
!(yield analytics.enabled())) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (this.posthog) {
|
|
84
|
+
yield this.posthog.identify(identity, timestamp);
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
identifyGroup(group, timestamp) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
// Group indentifications (tenant and installation) always on
|
|
91
|
+
if (this.posthog) {
|
|
92
|
+
yield this.posthog.identifyGroup(group, timestamp);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
shutdown() {
|
|
97
|
+
if (this.posthog) {
|
|
98
|
+
this.posthog.shutdown();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.default = AnalyticsProcessor;
|
|
103
|
+
//# sourceMappingURL=AnalyticsProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnalyticsProcessor.js","sourceRoot":"","sources":["../../../../src/events/processors/AnalyticsProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA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,KAAY,EAAE,SAA2B;;YAC3D,6DAA6D;YAC7D,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;gBACjB,MAAM,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;YACpD,CAAC;QACH,CAAC;KAAA;IAED,QAAQ;QACN,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAA;QACzB,CAAC;IACH,CAAC;CACF;AAhDD,qCAgDC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const types_1 = require("@budibase/types");
|
|
16
|
+
const context_1 = require("../../context");
|
|
17
|
+
const queue_1 = require("../../queue");
|
|
18
|
+
const utils_1 = require("../../utils");
|
|
19
|
+
const environment_1 = __importDefault(require("../../environment"));
|
|
20
|
+
class AuditLogsProcessor {
|
|
21
|
+
// can't use constructor as need to return promise
|
|
22
|
+
static init(fn) {
|
|
23
|
+
AuditLogsProcessor.auditLogsEnabled = true;
|
|
24
|
+
const writeAuditLogs = fn;
|
|
25
|
+
AuditLogsProcessor.auditLogQueue = (0, queue_1.createQueue)(queue_1.JobQueue.AUDIT_LOG);
|
|
26
|
+
return AuditLogsProcessor.auditLogQueue.process((job) => __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return (0, context_1.doInTenant)(job.data.tenantId, () => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
let properties = job.data.properties;
|
|
29
|
+
if (properties.audited) {
|
|
30
|
+
properties = Object.assign(Object.assign({}, properties), properties.audited);
|
|
31
|
+
delete properties.audited;
|
|
32
|
+
}
|
|
33
|
+
// this feature is disabled by default due to privacy requirements
|
|
34
|
+
// in some countries - available as env var in-case it is desired
|
|
35
|
+
// in self host deployments
|
|
36
|
+
let hostInfo = {};
|
|
37
|
+
if (environment_1.default.ENABLE_AUDIT_LOG_IP_ADDR) {
|
|
38
|
+
hostInfo = job.data.opts.hostInfo;
|
|
39
|
+
}
|
|
40
|
+
yield writeAuditLogs(job.data.event, properties, {
|
|
41
|
+
userId: job.data.opts.userId,
|
|
42
|
+
timestamp: job.data.opts.timestamp,
|
|
43
|
+
appId: job.data.opts.appId,
|
|
44
|
+
hostInfo,
|
|
45
|
+
});
|
|
46
|
+
}));
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
processEvent(event, identity, properties, timestamp) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (AuditLogsProcessor.auditLogsEnabled && (0, utils_1.isAudited)(event)) {
|
|
52
|
+
// only audit log actual events, don't include backfills
|
|
53
|
+
const userId = identity.type === types_1.IdentityType.USER ? identity.id : undefined;
|
|
54
|
+
// add to the event queue, rather than just writing immediately
|
|
55
|
+
yield AuditLogsProcessor.auditLogQueue.add({
|
|
56
|
+
event,
|
|
57
|
+
properties,
|
|
58
|
+
opts: {
|
|
59
|
+
userId,
|
|
60
|
+
timestamp,
|
|
61
|
+
appId: (0, context_1.getAppId)(),
|
|
62
|
+
hostInfo: identity.hostInfo,
|
|
63
|
+
},
|
|
64
|
+
tenantId: (0, context_1.getTenantId)(),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
identify() {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
// no-op
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
identifyGroup() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
// no-op
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
shutdown() {
|
|
80
|
+
var _a;
|
|
81
|
+
(_a = AuditLogsProcessor.auditLogQueue) === null || _a === void 0 ? void 0 : _a.close();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
AuditLogsProcessor.auditLogsEnabled = false;
|
|
85
|
+
exports.default = AuditLogsProcessor;
|
|
86
|
+
//# sourceMappingURL=AuditLogsProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuditLogsProcessor.js","sourceRoot":"","sources":["../../../../src/events/processors/AuditLogsProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAOwB;AAExB,2CAAiE;AAEjE,uCAAmD;AACnD,uCAAuC;AACvC,oEAAmC;AAEnC,MAAqB,kBAAkB;IAIrC,kDAAkD;IAClD,MAAM,CAAC,IAAI,CAAC,EAAc;QACxB,kBAAkB,CAAC,gBAAgB,GAAG,IAAI,CAAA;QAC1C,MAAM,cAAc,GAAG,EAAE,CAAA;QACzB,kBAAkB,CAAC,aAAa,GAAG,IAAA,mBAAW,EAC5C,gBAAQ,CAAC,SAAS,CACnB,CAAA;QACD,OAAO,kBAAkB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAM,GAAG,EAAC,EAAE;YAC1D,OAAO,IAAA,oBAAU,EAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAS,EAAE;gBAC9C,IAAI,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,U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AQ,EAAE,QAAQ,CAAC,QAAQ;qBAC5B;oBACD,QAAQ,EAAE,IAAA,qBAAW,GAAE;iBACxB,CAAC,CAAA;YACJ,CAAC;QACH,CAAC;KAAA;IAEK,QAAQ;;YACZ,QAAQ;QACV,CAAC;KAAA;IAEK,aAAa;;YACjB,QAAQ;QACV,CAAC;KAAA;IAED,QAAQ;;QACN,MAAA,kBAAkB,CAAC,aAAa,0CAAE,KAAK,EAAE,CAAA;IAC3C,CAAC;;AA1EM,mCAAgB,GAAG,KAAK,CAAA;kBADZ,kBAAkB"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const environment_1 = __importDefault(require("../../environment"));
|
|
16
|
+
const skipLogging = environment_1.default.SELF_HOSTED && !environment_1.default.isDev();
|
|
17
|
+
class LoggingProcessor {
|
|
18
|
+
processEvent(event, identity, properties) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
if (skipLogging) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(`[audit] [identityType=${identity.type}] ${event}`, properties);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
identify(identity) {
|
|
27
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
+
if (skipLogging) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
console.log(`[audit] identified`, identity);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
identifyGroup(group) {
|
|
35
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
+
if (skipLogging) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
console.log(`[audit] group identified`, group);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
shutdown() {
|
|
43
|
+
// no-op
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.default = LoggingProcessor;
|
|
47
|
+
//# sourceMappingURL=LoggingProcessor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggingProcessor.js","sourceRoot":"","sources":["../../../../src/events/processors/LoggingProcessor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAEA,oEAAmC;AAEnC,MAAM,WAAW,GAAG,qBAAG,CAAC,WAAW,IAAI,CAAC,qBAAG,CAAC,KAAK,EAAE,CAAA;AAEnD,MAAqB,gBAAgB;IAC7B,YAAY,CAChB,KAAY,EACZ,QAAkB,EAClB,UAAe;;YAEf,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAM;YACR,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,yBAAyB,QAAQ,CAAC,IAAI,KAAK,KAAK,EAAE,EAAE,UAAU,CAAC,CAAA;QAC7E,CAAC;KAAA;IAEK,QAAQ,CAAC,QAAkB;;YAC/B,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAM;YACR,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAA;QAC7C,CAAC;KAAA;IAEK,aAAa,CAAC,KAAY;;YAC9B,IAAI,WAAW,EAAE,CAAC;gBAChB,OAAM;YACR,CAAC;YACD,OAAO,CAAC,GAAG,CAAC,0BAA0B,EAAE,KAAK,CAAC,CAAA;QAChD,CAAC;KAAA;IAED,QAAQ;QACN,QAAQ;IACV,CAAC;CACF;AA7BD,mCA6BC"}
|