@budibase/backend-core 3.2.4 → 3.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js.map +1 -1
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +11 -4
- package/dist/plugins.js.meta.json +1 -1
- package/package.json +11 -4
- package/src/accounts/accounts.ts +0 -82
- package/src/accounts/api.ts +0 -59
- package/src/accounts/index.ts +0 -1
- package/src/auth/auth.ts +0 -210
- package/src/auth/index.ts +0 -1
- package/src/auth/tests/auth.spec.ts +0 -14
- package/src/blacklist/blacklist.ts +0 -54
- package/src/blacklist/index.ts +0 -1
- package/src/blacklist/tests/blacklist.spec.ts +0 -46
- package/src/cache/appMetadata.ts +0 -88
- package/src/cache/base/index.ts +0 -150
- package/src/cache/docWritethrough.ts +0 -105
- package/src/cache/generic.ts +0 -33
- package/src/cache/index.ts +0 -8
- package/src/cache/invite.ts +0 -86
- package/src/cache/passwordReset.ts +0 -49
- package/src/cache/tests/docWritethrough.spec.ts +0 -296
- package/src/cache/tests/user.spec.ts +0 -145
- package/src/cache/tests/writethrough.spec.ts +0 -139
- package/src/cache/user.ts +0 -154
- package/src/cache/writethrough.ts +0 -133
- package/src/configs/configs.ts +0 -263
- package/src/configs/index.ts +0 -1
- package/src/configs/tests/configs.spec.ts +0 -184
- package/src/constants/db.ts +0 -75
- package/src/constants/index.ts +0 -2
- package/src/constants/misc.ts +0 -36
- package/src/context/Context.ts +0 -14
- package/src/context/identity.ts +0 -58
- package/src/context/index.ts +0 -3
- package/src/context/mainContext.ts +0 -422
- package/src/context/tests/index.spec.ts +0 -255
- package/src/context/types.ts +0 -26
- package/src/db/Replication.ts +0 -94
- package/src/db/couch/DatabaseImpl.ts +0 -511
- package/src/db/couch/connections.ts +0 -89
- package/src/db/couch/index.ts +0 -4
- package/src/db/couch/pouchDB.ts +0 -97
- package/src/db/couch/pouchDump.ts +0 -0
- package/src/db/couch/tests/DatabaseImpl.spec.ts +0 -118
- package/src/db/couch/utils.ts +0 -55
- package/src/db/db.ts +0 -34
- package/src/db/errors.ts +0 -14
- package/src/db/index.ts +0 -12
- package/src/db/instrumentation.ts +0 -199
- package/src/db/lucene.ts +0 -721
- package/src/db/searchIndexes/index.ts +0 -1
- package/src/db/searchIndexes/searchIndexes.ts +0 -62
- package/src/db/tests/DatabaseImpl.spec.ts +0 -55
- package/src/db/tests/connections.spec.ts +0 -22
- package/src/db/tests/index.spec.ts +0 -32
- package/src/db/tests/lucene.spec.ts +0 -400
- package/src/db/tests/pouch.spec.js +0 -62
- package/src/db/tests/utils.spec.ts +0 -63
- package/src/db/utils.ts +0 -208
- package/src/db/views.ts +0 -245
- package/src/docIds/conversions.ts +0 -60
- package/src/docIds/ids.ts +0 -126
- package/src/docIds/index.ts +0 -2
- package/src/docIds/newid.ts +0 -5
- package/src/docIds/params.ts +0 -189
- package/src/docUpdates/index.ts +0 -24
- package/src/environment.ts +0 -293
- package/src/errors/errors.ts +0 -119
- package/src/errors/index.ts +0 -1
- package/src/events/analytics.ts +0 -6
- package/src/events/asyncEvents/index.ts +0 -2
- package/src/events/asyncEvents/publisher.ts +0 -12
- package/src/events/asyncEvents/queue.ts +0 -22
- package/src/events/backfill.ts +0 -183
- package/src/events/documentId.ts +0 -56
- package/src/events/events.ts +0 -47
- package/src/events/identification.ts +0 -311
- package/src/events/index.ts +0 -15
- package/src/events/processors/AnalyticsProcessor.ts +0 -64
- package/src/events/processors/AuditLogsProcessor.ts +0 -92
- package/src/events/processors/LoggingProcessor.ts +0 -36
- package/src/events/processors/Processors.ts +0 -52
- package/src/events/processors/async/DocumentUpdateProcessor.ts +0 -38
- package/src/events/processors/index.ts +0 -19
- package/src/events/processors/posthog/PosthogProcessor.ts +0 -118
- package/src/events/processors/posthog/index.ts +0 -3
- package/src/events/processors/posthog/rateLimiting.ts +0 -106
- package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +0 -164
- package/src/events/processors/types.ts +0 -1
- package/src/events/publishers/account.ts +0 -41
- package/src/events/publishers/ai.ts +0 -21
- package/src/events/publishers/app.ts +0 -168
- package/src/events/publishers/auditLog.ts +0 -26
- package/src/events/publishers/auth.ts +0 -73
- package/src/events/publishers/automation.ts +0 -110
- package/src/events/publishers/backfill.ts +0 -74
- package/src/events/publishers/backup.ts +0 -42
- package/src/events/publishers/datasource.ts +0 -48
- package/src/events/publishers/email.ts +0 -17
- package/src/events/publishers/environmentVariable.ts +0 -38
- package/src/events/publishers/group.ts +0 -99
- package/src/events/publishers/index.ts +0 -25
- package/src/events/publishers/installation.ts +0 -38
- package/src/events/publishers/layout.ts +0 -26
- package/src/events/publishers/license.ts +0 -84
- package/src/events/publishers/org.ts +0 -37
- package/src/events/publishers/plugin.ts +0 -47
- package/src/events/publishers/query.ts +0 -89
- package/src/events/publishers/role.ts +0 -62
- package/src/events/publishers/rows.ts +0 -29
- package/src/events/publishers/screen.ts +0 -36
- package/src/events/publishers/serve.ts +0 -43
- package/src/events/publishers/table.ts +0 -70
- package/src/events/publishers/user.ts +0 -202
- package/src/events/publishers/view.ts +0 -107
- package/src/features/features.ts +0 -277
- package/src/features/index.ts +0 -2
- package/src/features/tests/features.spec.ts +0 -267
- package/src/features/tests/utils.ts +0 -64
- package/src/helpers.ts +0 -9
- package/src/index.ts +0 -59
- package/src/installation.ts +0 -115
- package/src/logging/alerts.ts +0 -26
- package/src/logging/correlation/correlation.ts +0 -15
- package/src/logging/correlation/index.ts +0 -1
- package/src/logging/correlation/middleware.ts +0 -18
- package/src/logging/index.ts +0 -4
- package/src/logging/pino/logger.ts +0 -239
- package/src/logging/pino/middleware.ts +0 -48
- package/src/logging/system.ts +0 -81
- package/src/logging/tests/system.spec.ts +0 -61
- package/src/middleware/adminOnly.ts +0 -9
- package/src/middleware/auditLog.ts +0 -6
- package/src/middleware/authenticated.ts +0 -247
- package/src/middleware/builderOnly.ts +0 -21
- package/src/middleware/builderOrAdmin.ts +0 -21
- package/src/middleware/contentSecurityPolicy.ts +0 -113
- package/src/middleware/csrf.ts +0 -81
- package/src/middleware/errorHandling.ts +0 -43
- package/src/middleware/index.ts +0 -24
- package/src/middleware/internalApi.ts +0 -23
- package/src/middleware/ip.ts +0 -12
- package/src/middleware/joi-validator.ts +0 -58
- package/src/middleware/matchers.ts +0 -39
- package/src/middleware/passport/datasource/google.ts +0 -102
- package/src/middleware/passport/local.ts +0 -54
- package/src/middleware/passport/sso/google.ts +0 -77
- package/src/middleware/passport/sso/oidc.ts +0 -152
- package/src/middleware/passport/sso/sso.ts +0 -138
- package/src/middleware/passport/sso/tests/google.spec.ts +0 -68
- package/src/middleware/passport/sso/tests/oidc.spec.ts +0 -144
- package/src/middleware/passport/sso/tests/sso.spec.ts +0 -197
- package/src/middleware/passport/utils.ts +0 -38
- package/src/middleware/querystringToBody.ts +0 -28
- package/src/middleware/tenancy.ts +0 -36
- package/src/middleware/tests/builder.spec.ts +0 -181
- package/src/middleware/tests/contentSecurityPolicy.spec.ts +0 -75
- package/src/middleware/tests/matchers.spec.ts +0 -100
- package/src/migrations/definitions.ts +0 -40
- package/src/migrations/index.ts +0 -2
- package/src/migrations/migrations.ts +0 -186
- package/src/migrations/tests/__snapshots__/migrations.spec.ts.snap +0 -11
- package/src/migrations/tests/migrations.spec.ts +0 -64
- package/src/objectStore/buckets/app.ts +0 -53
- package/src/objectStore/buckets/global.ts +0 -29
- package/src/objectStore/buckets/index.ts +0 -3
- package/src/objectStore/buckets/plugins.ts +0 -71
- package/src/objectStore/buckets/tests/app.spec.ts +0 -161
- package/src/objectStore/buckets/tests/global.spec.ts +0 -74
- package/src/objectStore/buckets/tests/plugins.spec.ts +0 -111
- package/src/objectStore/cloudfront.ts +0 -41
- package/src/objectStore/index.ts +0 -3
- package/src/objectStore/objectStore.ts +0 -585
- package/src/objectStore/utils.ts +0 -113
- package/src/platform/index.ts +0 -3
- package/src/platform/platformDb.ts +0 -6
- package/src/platform/tenants.ts +0 -101
- package/src/platform/tests/tenants.spec.ts +0 -26
- package/src/platform/users.ts +0 -129
- package/src/plugin/index.ts +0 -1
- package/src/plugin/tests/validation.spec.ts +0 -209
- package/src/plugin/utils.ts +0 -175
- package/src/queue/constants.ts +0 -8
- package/src/queue/inMemoryQueue.ts +0 -189
- package/src/queue/index.ts +0 -2
- package/src/queue/listeners.ts +0 -199
- package/src/queue/queue.ts +0 -84
- package/src/redis/index.ts +0 -6
- package/src/redis/init.ts +0 -118
- package/src/redis/redis.ts +0 -358
- package/src/redis/redlockImpl.ts +0 -155
- package/src/redis/tests/redis.spec.ts +0 -207
- package/src/redis/tests/redlockImpl.spec.ts +0 -105
- package/src/redis/utils.ts +0 -128
- package/src/security/auth.ts +0 -24
- package/src/security/encryption.ts +0 -185
- package/src/security/index.ts +0 -1
- package/src/security/permissions.ts +0 -166
- package/src/security/roles.ts +0 -655
- package/src/security/secrets.ts +0 -20
- package/src/security/sessions.ts +0 -123
- package/src/security/tests/auth.spec.ts +0 -45
- package/src/security/tests/encryption.spec.ts +0 -31
- package/src/security/tests/permissions.spec.ts +0 -146
- package/src/security/tests/secrets.spec.ts +0 -35
- package/src/security/tests/sessions.spec.ts +0 -12
- package/src/sql/designDoc.ts +0 -17
- package/src/sql/index.ts +0 -5
- package/src/sql/sql.ts +0 -1854
- package/src/sql/sqlTable.ts +0 -319
- package/src/sql/utils.ts +0 -193
- package/src/tenancy/db.ts +0 -6
- package/src/tenancy/index.ts +0 -2
- package/src/tenancy/tenancy.ts +0 -148
- package/src/tenancy/tests/tenancy.spec.ts +0 -184
- package/src/timers/index.ts +0 -1
- package/src/timers/timers.ts +0 -22
- package/src/users/db.ts +0 -582
- package/src/users/events.ts +0 -176
- package/src/users/index.ts +0 -4
- package/src/users/lookup.ts +0 -99
- package/src/users/test/db.spec.ts +0 -188
- package/src/users/test/utils.spec.ts +0 -67
- package/src/users/users.ts +0 -353
- package/src/users/utils.ts +0 -81
- package/src/utils/Duration.ts +0 -56
- package/src/utils/hashing.ts +0 -15
- package/src/utils/index.ts +0 -4
- package/src/utils/stringUtils.ts +0 -8
- package/src/utils/tests/Duration.spec.ts +0 -19
- package/src/utils/tests/utils.spec.ts +0 -204
- package/src/utils/utils.ts +0 -249
- package/tests/core/logging.ts +0 -34
- package/tests/core/users/users.spec.js +0 -53
- package/tests/core/utilities/index.ts +0 -7
- package/tests/core/utilities/jestUtils.ts +0 -33
- package/tests/core/utilities/mocks/alerts.ts +0 -4
- package/tests/core/utilities/mocks/date.ts +0 -3
- package/tests/core/utilities/mocks/events.ts +0 -132
- package/tests/core/utilities/mocks/index.ts +0 -9
- package/tests/core/utilities/mocks/licenses.ts +0 -119
- package/tests/core/utilities/queue.ts +0 -9
- package/tests/core/utilities/structures/Chance.ts +0 -20
- package/tests/core/utilities/structures/accounts.ts +0 -80
- package/tests/core/utilities/structures/apps.ts +0 -21
- package/tests/core/utilities/structures/common.ts +0 -7
- package/tests/core/utilities/structures/db.ts +0 -12
- package/tests/core/utilities/structures/documents/index.ts +0 -1
- package/tests/core/utilities/structures/documents/platform/index.ts +0 -1
- package/tests/core/utilities/structures/documents/platform/installation.ts +0 -12
- package/tests/core/utilities/structures/generator.ts +0 -3
- package/tests/core/utilities/structures/index.ts +0 -15
- package/tests/core/utilities/structures/koa.ts +0 -16
- package/tests/core/utilities/structures/licenses.ts +0 -190
- package/tests/core/utilities/structures/plugins.ts +0 -19
- package/tests/core/utilities/structures/quotas.ts +0 -72
- package/tests/core/utilities/structures/scim.ts +0 -80
- package/tests/core/utilities/structures/sso.ts +0 -118
- package/tests/core/utilities/structures/tenants.ts +0 -5
- package/tests/core/utilities/structures/userGroups.ts +0 -10
- package/tests/core/utilities/structures/users.ts +0 -89
- package/tests/core/utilities/testContainerUtils.ts +0 -165
- package/tests/core/utilities/utils/index.ts +0 -2
- package/tests/core/utilities/utils/queue.ts +0 -27
- package/tests/core/utilities/utils/time.ts +0 -3
- package/tests/extra/DBTestConfiguration.ts +0 -36
- package/tests/extra/index.ts +0 -2
- package/tests/extra/testEnv.ts +0 -95
- package/tests/index.ts +0 -2
- package/tests/jestEnv.ts +0 -10
- package/tests/jestSetup.ts +0 -36
package/src/docIds/params.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DocumentType,
|
|
3
|
-
InternalTable,
|
|
4
|
-
SEPARATOR,
|
|
5
|
-
UNICODE_MAX,
|
|
6
|
-
ViewName,
|
|
7
|
-
} from "../constants"
|
|
8
|
-
import { getProdAppID } from "./conversions"
|
|
9
|
-
import { DatabaseQueryOpts, VirtualDocumentType } from "@budibase/types"
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* If creating DB allDocs/query params with only a single top level ID this can be used, this
|
|
13
|
-
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
|
|
14
|
-
* More complex cases such as link docs and rows which have multiple levels of IDs that their
|
|
15
|
-
* ID consists of need their own functions to build the allDocs parameters.
|
|
16
|
-
* @param docType The type of document which input params are being built for, e.g. user,
|
|
17
|
-
* link, app, table and so on.
|
|
18
|
-
* @param docId The ID of the document minus its type - this is only needed if looking
|
|
19
|
-
* for a singular document.
|
|
20
|
-
* @param otherProps Add any other properties onto the request, e.g. include_docs.
|
|
21
|
-
* @returns Parameters which can then be used with an allDocs request.
|
|
22
|
-
*/
|
|
23
|
-
export function getDocParams(
|
|
24
|
-
docType: string,
|
|
25
|
-
docId?: string | null,
|
|
26
|
-
otherProps: Partial<DatabaseQueryOpts> = {}
|
|
27
|
-
): DatabaseQueryOpts {
|
|
28
|
-
if (docId == null) {
|
|
29
|
-
docId = ""
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
...otherProps,
|
|
33
|
-
startkey: `${docType}${SEPARATOR}${docId}`,
|
|
34
|
-
endkey: `${docType}${SEPARATOR}${docId}${UNICODE_MAX}`,
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Gets the DB allDocs/query params for retrieving a row.
|
|
40
|
-
* @param tableId The table in which the rows have been stored.
|
|
41
|
-
* @param rowId The ID of the row which is being specifically queried for. This can be
|
|
42
|
-
* left null to get all the rows in the table.
|
|
43
|
-
* @param otherProps Any other properties to add to the request.
|
|
44
|
-
* @returns Parameters which can then be used with an allDocs request.
|
|
45
|
-
*/
|
|
46
|
-
export function getRowParams(
|
|
47
|
-
tableId?: string | null,
|
|
48
|
-
rowId?: string | null,
|
|
49
|
-
otherProps: Partial<DatabaseQueryOpts> = {}
|
|
50
|
-
): DatabaseQueryOpts {
|
|
51
|
-
if (tableId == null) {
|
|
52
|
-
return getDocParams(DocumentType.ROW, null, otherProps)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const endOfKey = rowId == null ? `${tableId}${SEPARATOR}` : rowId
|
|
56
|
-
|
|
57
|
-
return getDocParams(DocumentType.ROW, endOfKey, otherProps)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Retrieve the correct index for a view based on default design DB.
|
|
62
|
-
*/
|
|
63
|
-
export function getQueryIndex(viewName: ViewName) {
|
|
64
|
-
return `database/${viewName}`
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Check if a given ID is that of a table.
|
|
69
|
-
*/
|
|
70
|
-
export const isTableId = (id: string): boolean => {
|
|
71
|
-
// this includes datasource plus tables
|
|
72
|
-
return (
|
|
73
|
-
!!id &&
|
|
74
|
-
(id.startsWith(`${DocumentType.TABLE}${SEPARATOR}`) ||
|
|
75
|
-
id.startsWith(`${DocumentType.DATASOURCE_PLUS}${SEPARATOR}`))
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export function isViewId(id: string): boolean {
|
|
80
|
-
return !!id && id.startsWith(`${VirtualDocumentType.VIEW}${SEPARATOR}`)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Check if a given ID is that of a datasource or datasource plus.
|
|
85
|
-
*/
|
|
86
|
-
export const isDatasourceId = (id: string): boolean => {
|
|
87
|
-
// this covers both datasources and datasource plus
|
|
88
|
-
return !!id && id.startsWith(`${DocumentType.DATASOURCE}${SEPARATOR}`)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Gets parameters for retrieving workspaces.
|
|
93
|
-
*/
|
|
94
|
-
export function getWorkspaceParams(
|
|
95
|
-
id = "",
|
|
96
|
-
otherProps: Partial<DatabaseQueryOpts> = {}
|
|
97
|
-
): DatabaseQueryOpts {
|
|
98
|
-
return {
|
|
99
|
-
...otherProps,
|
|
100
|
-
startkey: `${DocumentType.WORKSPACE}${SEPARATOR}${id}`,
|
|
101
|
-
endkey: `${DocumentType.WORKSPACE}${SEPARATOR}${id}${UNICODE_MAX}`,
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Gets parameters for retrieving users.
|
|
107
|
-
*/
|
|
108
|
-
export function getGlobalUserParams(
|
|
109
|
-
globalId: any,
|
|
110
|
-
otherProps: Partial<DatabaseQueryOpts> = {}
|
|
111
|
-
): DatabaseQueryOpts {
|
|
112
|
-
if (!globalId) {
|
|
113
|
-
globalId = ""
|
|
114
|
-
}
|
|
115
|
-
const startkey = otherProps?.startkey
|
|
116
|
-
return {
|
|
117
|
-
...otherProps,
|
|
118
|
-
// need to include this incase pagination
|
|
119
|
-
startkey: startkey
|
|
120
|
-
? startkey
|
|
121
|
-
: `${DocumentType.USER}${SEPARATOR}${globalId}`,
|
|
122
|
-
endkey: `${DocumentType.USER}${SEPARATOR}${globalId}${UNICODE_MAX}`,
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Gets parameters for retrieving users, this is a utility function for the getDocParams function.
|
|
128
|
-
*/
|
|
129
|
-
export function getUserMetadataParams(
|
|
130
|
-
userId?: string | null,
|
|
131
|
-
otherProps: Partial<DatabaseQueryOpts> = {}
|
|
132
|
-
): DatabaseQueryOpts {
|
|
133
|
-
return getRowParams(InternalTable.USER_METADATA, userId, otherProps)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export function getUsersByAppParams(
|
|
137
|
-
appId: any,
|
|
138
|
-
otherProps: Partial<DatabaseQueryOpts> = {}
|
|
139
|
-
): DatabaseQueryOpts {
|
|
140
|
-
const prodAppId = getProdAppID(appId)
|
|
141
|
-
return {
|
|
142
|
-
...otherProps,
|
|
143
|
-
startkey: prodAppId,
|
|
144
|
-
endkey: `${prodAppId}${UNICODE_MAX}`,
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Gets parameters for retrieving templates. Owner ID must be specified, either global or a workspace level.
|
|
150
|
-
*/
|
|
151
|
-
export function getTemplateParams(
|
|
152
|
-
ownerId: any,
|
|
153
|
-
templateId: any,
|
|
154
|
-
otherProps = {}
|
|
155
|
-
) {
|
|
156
|
-
if (!templateId) {
|
|
157
|
-
templateId = ""
|
|
158
|
-
}
|
|
159
|
-
let final
|
|
160
|
-
if (templateId) {
|
|
161
|
-
final = templateId
|
|
162
|
-
} else {
|
|
163
|
-
final = `${DocumentType.TEMPLATE}${SEPARATOR}${ownerId}${SEPARATOR}`
|
|
164
|
-
}
|
|
165
|
-
return {
|
|
166
|
-
...otherProps,
|
|
167
|
-
startkey: final,
|
|
168
|
-
endkey: `${final}${UNICODE_MAX}`,
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Gets parameters for retrieving a role, this is a utility function for the getDocParams function.
|
|
174
|
-
*/
|
|
175
|
-
export function getRoleParams(roleId?: string | null, otherProps = {}) {
|
|
176
|
-
return getDocParams(DocumentType.ROLE, roleId, otherProps)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export function getStartEndKeyURL(baseKey: any, tenantId?: string) {
|
|
180
|
-
const tenancy = tenantId ? `${SEPARATOR}${tenantId}` : ""
|
|
181
|
-
return `startkey="${baseKey}${tenancy}"&endkey="${baseKey}${tenancy}${UNICODE_MAX}"`
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Gets parameters for retrieving automations, this is a utility function for the getDocParams function.
|
|
186
|
-
*/
|
|
187
|
-
export const getPluginParams = (pluginId?: string | null, otherProps = {}) => {
|
|
188
|
-
return getDocParams(DocumentType.PLUGIN, pluginId, otherProps)
|
|
189
|
-
}
|
package/src/docUpdates/index.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { asyncEventQueue, init as initQueue } from "../events/asyncEvents"
|
|
2
|
-
import {
|
|
3
|
-
ProcessorMap,
|
|
4
|
-
default as DocumentUpdateProcessor,
|
|
5
|
-
} from "../events/processors/async/DocumentUpdateProcessor"
|
|
6
|
-
|
|
7
|
-
let processingPromise: Promise<void>
|
|
8
|
-
let documentProcessor: DocumentUpdateProcessor
|
|
9
|
-
|
|
10
|
-
export function init(processors: ProcessorMap) {
|
|
11
|
-
if (!asyncEventQueue) {
|
|
12
|
-
initQueue()
|
|
13
|
-
}
|
|
14
|
-
if (!documentProcessor) {
|
|
15
|
-
documentProcessor = new DocumentUpdateProcessor(processors)
|
|
16
|
-
}
|
|
17
|
-
// if not processing in this instance, kick it off
|
|
18
|
-
if (!processingPromise) {
|
|
19
|
-
processingPromise = asyncEventQueue.process(async job => {
|
|
20
|
-
const { event, identity, properties } = job.data
|
|
21
|
-
await documentProcessor.processEvent(event, identity, properties)
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
}
|
package/src/environment.ts
DELETED
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "fs"
|
|
2
|
-
import { ServiceType } from "@budibase/types"
|
|
3
|
-
import { cloneDeep } from "lodash"
|
|
4
|
-
import { createSecretKey } from "crypto"
|
|
5
|
-
|
|
6
|
-
function isTest() {
|
|
7
|
-
return isJest()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function isJest() {
|
|
11
|
-
return (
|
|
12
|
-
process.env.NODE_ENV === "jest" ||
|
|
13
|
-
(process.env.JEST_WORKER_ID != null &&
|
|
14
|
-
process.env.JEST_WORKER_ID !== "null")
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function isDev() {
|
|
19
|
-
return process.env.NODE_ENV !== "production"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let LOADED = false
|
|
23
|
-
if (!LOADED && isDev() && !isTest()) {
|
|
24
|
-
require("dotenv").config()
|
|
25
|
-
LOADED = true
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const DefaultBucketName = {
|
|
29
|
-
BACKUPS: "backups",
|
|
30
|
-
APPS: "prod-budi-app-assets",
|
|
31
|
-
TEMPLATES: "templates",
|
|
32
|
-
GLOBAL: "global",
|
|
33
|
-
PLUGINS: "plugins",
|
|
34
|
-
TEMP: "tmp-file-attachments",
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const selfHosted = !!parseInt(process.env.SELF_HOSTED || "")
|
|
38
|
-
|
|
39
|
-
function getAPIEncryptionKey() {
|
|
40
|
-
return process.env.API_ENCRYPTION_KEY
|
|
41
|
-
? process.env.API_ENCRYPTION_KEY
|
|
42
|
-
: process.env.JWT_SECRET // fallback to the JWT_SECRET used historically
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function httpLogging() {
|
|
46
|
-
if (process.env.HTTP_LOGGING === undefined) {
|
|
47
|
-
// on by default unless otherwise specified
|
|
48
|
-
return true
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return process.env.HTTP_LOGGING
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function getPackageJsonFields(): {
|
|
55
|
-
VERSION: string
|
|
56
|
-
SERVICE_NAME: string
|
|
57
|
-
} {
|
|
58
|
-
function getParentFile(file: string) {
|
|
59
|
-
function findFileInAncestors(
|
|
60
|
-
fileName: string,
|
|
61
|
-
currentDir: string
|
|
62
|
-
): string | null {
|
|
63
|
-
const filePath = `${currentDir}/${fileName}`
|
|
64
|
-
if (existsSync(filePath)) {
|
|
65
|
-
return filePath
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const parentDir = `${currentDir}/..`
|
|
69
|
-
if (parentDir === currentDir) {
|
|
70
|
-
// reached root directory
|
|
71
|
-
return null
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return findFileInAncestors(fileName, parentDir)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const packageJsonFile = findFileInAncestors(file, process.cwd())
|
|
78
|
-
const content = readFileSync(packageJsonFile!, "utf-8")
|
|
79
|
-
const parsedContent = JSON.parse(content)
|
|
80
|
-
return parsedContent
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let localVersion: string | undefined
|
|
84
|
-
if (isDev() && !isTest()) {
|
|
85
|
-
try {
|
|
86
|
-
const lerna = getParentFile("lerna.json")
|
|
87
|
-
localVersion = `${lerna.version}+local`
|
|
88
|
-
} catch {
|
|
89
|
-
//
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const parsedContent = getParentFile("package.json")
|
|
95
|
-
return {
|
|
96
|
-
VERSION:
|
|
97
|
-
localVersion || process.env.BUDIBASE_VERSION || parsedContent.version,
|
|
98
|
-
SERVICE_NAME: parsedContent.name,
|
|
99
|
-
}
|
|
100
|
-
} catch {
|
|
101
|
-
// throwing an error here is confusing/causes backend-core to be hard to import
|
|
102
|
-
return { VERSION: process.env.BUDIBASE_VERSION || "", SERVICE_NAME: "" }
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function isWorker() {
|
|
107
|
-
return environment.SERVICE_TYPE === ServiceType.WORKER
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function isApps() {
|
|
111
|
-
return environment.SERVICE_TYPE === ServiceType.APPS
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function isQA() {
|
|
115
|
-
return environment.BUDIBASE_ENVIRONMENT === "QA"
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const environment = {
|
|
119
|
-
isTest,
|
|
120
|
-
isJest,
|
|
121
|
-
isDev,
|
|
122
|
-
isWorker,
|
|
123
|
-
isApps,
|
|
124
|
-
isQA,
|
|
125
|
-
isProd: () => {
|
|
126
|
-
return !isDev()
|
|
127
|
-
},
|
|
128
|
-
BUDIBASE_ENVIRONMENT: process.env.BUDIBASE_ENVIRONMENT,
|
|
129
|
-
JS_BCRYPT: process.env.JS_BCRYPT,
|
|
130
|
-
JWT_SECRET: process.env.JWT_SECRET
|
|
131
|
-
? createSecretKey(Buffer.from(process.env.JWT_SECRET))
|
|
132
|
-
: undefined,
|
|
133
|
-
JWT_SECRET_FALLBACK: process.env.JWT_SECRET_FALLBACK
|
|
134
|
-
? createSecretKey(Buffer.from(process.env.JWT_SECRET_FALLBACK))
|
|
135
|
-
: undefined,
|
|
136
|
-
ENCRYPTION_KEY: process.env.ENCRYPTION_KEY,
|
|
137
|
-
API_ENCRYPTION_KEY: getAPIEncryptionKey(),
|
|
138
|
-
COUCH_DB_URL: process.env.COUCH_DB_URL || "http://localhost:4005",
|
|
139
|
-
COUCH_DB_SQL_URL: process.env.COUCH_DB_SQL_URL,
|
|
140
|
-
COUCH_DB_USERNAME: process.env.COUCH_DB_USER,
|
|
141
|
-
COUCH_DB_PASSWORD: process.env.COUCH_DB_PASSWORD,
|
|
142
|
-
GOOGLE_CLIENT_ID: process.env.GOOGLE_CLIENT_ID,
|
|
143
|
-
GOOGLE_CLIENT_SECRET: process.env.GOOGLE_CLIENT_SECRET,
|
|
144
|
-
SALT_ROUNDS: process.env.SALT_ROUNDS,
|
|
145
|
-
REDIS_URL: process.env.REDIS_URL || "localhost:6379",
|
|
146
|
-
REDIS_PASSWORD: process.env.REDIS_PASSWORD,
|
|
147
|
-
REDIS_CLUSTERED: process.env.REDIS_CLUSTERED,
|
|
148
|
-
MINIO_ACCESS_KEY: process.env.MINIO_ACCESS_KEY,
|
|
149
|
-
MINIO_SECRET_KEY: process.env.MINIO_SECRET_KEY,
|
|
150
|
-
AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN,
|
|
151
|
-
AWS_REGION: process.env.AWS_REGION,
|
|
152
|
-
MINIO_URL: process.env.MINIO_URL,
|
|
153
|
-
MINIO_ENABLED: process.env.MINIO_ENABLED || 1,
|
|
154
|
-
INTERNAL_API_KEY: process.env.INTERNAL_API_KEY,
|
|
155
|
-
INTERNAL_API_KEY_FALLBACK: process.env.INTERNAL_API_KEY_FALLBACK,
|
|
156
|
-
MULTI_TENANCY: process.env.MULTI_TENANCY,
|
|
157
|
-
ACCOUNT_PORTAL_URL:
|
|
158
|
-
process.env.ACCOUNT_PORTAL_URL || "https://account.budibase.app",
|
|
159
|
-
ACCOUNT_PORTAL_API_KEY: process.env.ACCOUNT_PORTAL_API_KEY || "",
|
|
160
|
-
DISABLE_ACCOUNT_PORTAL: process.env.DISABLE_ACCOUNT_PORTAL,
|
|
161
|
-
SELF_HOSTED: selfHosted,
|
|
162
|
-
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
|
163
|
-
PLATFORM_URL: process.env.PLATFORM_URL || "",
|
|
164
|
-
POSTHOG_TOKEN: process.env.POSTHOG_TOKEN,
|
|
165
|
-
POSTHOG_PERSONAL_TOKEN: process.env.POSTHOG_PERSONAL_TOKEN,
|
|
166
|
-
POSTHOG_API_HOST: process.env.POSTHOG_API_HOST || "https://us.i.posthog.com",
|
|
167
|
-
POSTHOG_FEATURE_FLAGS_ENABLED: process.env.POSTHOG_FEATURE_FLAGS_ENABLED,
|
|
168
|
-
ENABLE_ANALYTICS: process.env.ENABLE_ANALYTICS,
|
|
169
|
-
TENANT_FEATURE_FLAGS: process.env.TENANT_FEATURE_FLAGS,
|
|
170
|
-
CLOUDFRONT_CDN: process.env.CLOUDFRONT_CDN,
|
|
171
|
-
CLOUDFRONT_PRIVATE_KEY_64: process.env.CLOUDFRONT_PRIVATE_KEY_64,
|
|
172
|
-
CLOUDFRONT_PUBLIC_KEY_ID: process.env.CLOUDFRONT_PUBLIC_KEY_ID,
|
|
173
|
-
BACKUPS_BUCKET_NAME:
|
|
174
|
-
process.env.BACKUPS_BUCKET_NAME || DefaultBucketName.BACKUPS,
|
|
175
|
-
APPS_BUCKET_NAME: process.env.APPS_BUCKET_NAME || DefaultBucketName.APPS,
|
|
176
|
-
TEMPLATES_BUCKET_NAME:
|
|
177
|
-
process.env.TEMPLATES_BUCKET_NAME || DefaultBucketName.TEMPLATES,
|
|
178
|
-
GLOBAL_BUCKET_NAME:
|
|
179
|
-
process.env.GLOBAL_BUCKET_NAME || DefaultBucketName.GLOBAL,
|
|
180
|
-
PLUGIN_BUCKET_NAME:
|
|
181
|
-
process.env.PLUGIN_BUCKET_NAME || DefaultBucketName.PLUGINS,
|
|
182
|
-
TEMP_BUCKET_NAME: process.env.TEMP_BUCKET_NAME || DefaultBucketName.TEMP,
|
|
183
|
-
USE_COUCH: process.env.USE_COUCH || true,
|
|
184
|
-
MOCK_REDIS: process.env.MOCK_REDIS,
|
|
185
|
-
DEFAULT_LICENSE: process.env.DEFAULT_LICENSE,
|
|
186
|
-
SERVICE: process.env.SERVICE || "budibase",
|
|
187
|
-
LOG_LEVEL: process.env.LOG_LEVEL || "info",
|
|
188
|
-
SESSION_UPDATE_PERIOD: process.env.SESSION_UPDATE_PERIOD,
|
|
189
|
-
DEPLOYMENT_ENVIRONMENT:
|
|
190
|
-
process.env.DEPLOYMENT_ENVIRONMENT || "docker-compose",
|
|
191
|
-
HTTP_LOGGING: httpLogging(),
|
|
192
|
-
ENABLE_AUDIT_LOG_IP_ADDR: process.env.ENABLE_AUDIT_LOG_IP_ADDR,
|
|
193
|
-
// Couch/search
|
|
194
|
-
SQL_LOGGING_ENABLE: process.env.SQL_LOGGING_ENABLE,
|
|
195
|
-
SQL_MAX_ROWS: process.env.SQL_MAX_ROWS,
|
|
196
|
-
SQL_MAX_RELATED_ROWS: process.env.MAX_RELATED_ROWS,
|
|
197
|
-
// smtp
|
|
198
|
-
SMTP_FALLBACK_ENABLED: process.env.SMTP_FALLBACK_ENABLED,
|
|
199
|
-
SMTP_USER: process.env.SMTP_USER,
|
|
200
|
-
SMTP_PASSWORD: process.env.SMTP_PASSWORD,
|
|
201
|
-
SMTP_HOST: process.env.SMTP_HOST,
|
|
202
|
-
SMTP_PORT: parseInt(process.env.SMTP_PORT || ""),
|
|
203
|
-
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
|
|
204
|
-
DISABLE_JWT_WARNING: process.env.DISABLE_JWT_WARNING,
|
|
205
|
-
BLACKLIST_IPS: process.env.BLACKLIST_IPS,
|
|
206
|
-
SERVICE_TYPE: "unknown",
|
|
207
|
-
PASSWORD_MIN_LENGTH: process.env.PASSWORD_MIN_LENGTH,
|
|
208
|
-
PASSWORD_MAX_LENGTH: process.env.PASSWORD_MAX_LENGTH,
|
|
209
|
-
/**
|
|
210
|
-
* Enable to allow an admin user to login using a password.
|
|
211
|
-
* This can be useful to prevent lockout when configuring SSO.
|
|
212
|
-
* However, this should be turned OFF by default for security purposes.
|
|
213
|
-
*/
|
|
214
|
-
ENABLE_SSO_MAINTENANCE_MODE: selfHosted
|
|
215
|
-
? process.env.ENABLE_SSO_MAINTENANCE_MODE
|
|
216
|
-
: false,
|
|
217
|
-
...getPackageJsonFields(),
|
|
218
|
-
DISABLE_PINO_LOGGER: process.env.DISABLE_PINO_LOGGER,
|
|
219
|
-
OFFLINE_MODE: process.env.OFFLINE_MODE,
|
|
220
|
-
SESSION_EXPIRY_SECONDS: process.env.SESSION_EXPIRY_SECONDS,
|
|
221
|
-
_set(key: any, value: any) {
|
|
222
|
-
process.env[key] = value
|
|
223
|
-
// @ts-ignore
|
|
224
|
-
environment[key] = value
|
|
225
|
-
},
|
|
226
|
-
ROLLING_LOG_MAX_SIZE: process.env.ROLLING_LOG_MAX_SIZE || "10M",
|
|
227
|
-
DISABLE_SCIM_CALLS: process.env.DISABLE_SCIM_CALLS,
|
|
228
|
-
BB_ADMIN_USER_EMAIL: process.env.BB_ADMIN_USER_EMAIL,
|
|
229
|
-
BB_ADMIN_USER_PASSWORD: process.env.BB_ADMIN_USER_PASSWORD,
|
|
230
|
-
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
|
|
231
|
-
MIN_VERSION_WITHOUT_POWER_ROLE:
|
|
232
|
-
process.env.MIN_VERSION_WITHOUT_POWER_ROLE || "3.0.0",
|
|
233
|
-
DISABLE_CONTENT_SECURITY_POLICY: process.env.DISABLE_CONTENT_SECURITY_POLICY,
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
export function setEnv(newEnvVars: Partial<typeof environment>): () => void {
|
|
237
|
-
const oldEnv = cloneDeep(environment)
|
|
238
|
-
|
|
239
|
-
let key: keyof typeof newEnvVars
|
|
240
|
-
for (key in newEnvVars) {
|
|
241
|
-
environment._set(key, newEnvVars[key])
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
return () => {
|
|
245
|
-
for (const [key, value] of Object.entries(oldEnv)) {
|
|
246
|
-
environment._set(key, value)
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
export function withEnv<T>(envVars: Partial<typeof environment>, f: () => T) {
|
|
252
|
-
const cleanup = setEnv(envVars)
|
|
253
|
-
const result = f()
|
|
254
|
-
if (result instanceof Promise) {
|
|
255
|
-
return result.finally(cleanup)
|
|
256
|
-
} else {
|
|
257
|
-
cleanup()
|
|
258
|
-
return result
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
type EnvironmentKey = keyof typeof environment
|
|
263
|
-
export const SECRETS: EnvironmentKey[] = [
|
|
264
|
-
"API_ENCRYPTION_KEY",
|
|
265
|
-
"BB_ADMIN_USER_PASSWORD",
|
|
266
|
-
"COUCH_DB_PASSWORD",
|
|
267
|
-
"COUCH_DB_SQL_URL",
|
|
268
|
-
"COUCH_DB_URL",
|
|
269
|
-
"GOOGLE_CLIENT_SECRET",
|
|
270
|
-
"INTERNAL_API_KEY_FALLBACK",
|
|
271
|
-
"INTERNAL_API_KEY",
|
|
272
|
-
"JWT_SECRET",
|
|
273
|
-
"MINIO_ACCESS_KEY",
|
|
274
|
-
"MINIO_SECRET_KEY",
|
|
275
|
-
"OPENAI_API_KEY",
|
|
276
|
-
"REDIS_PASSWORD",
|
|
277
|
-
]
|
|
278
|
-
|
|
279
|
-
// clean up any environment variable edge cases
|
|
280
|
-
for (let [key, value] of Object.entries(environment)) {
|
|
281
|
-
// handle the edge case of "0" to disable an environment variable
|
|
282
|
-
if (value === "0") {
|
|
283
|
-
// @ts-ignore
|
|
284
|
-
environment[key] = 0
|
|
285
|
-
}
|
|
286
|
-
// handle the edge case of "false" to disable an environment variable
|
|
287
|
-
if (value === "false") {
|
|
288
|
-
// @ts-ignore
|
|
289
|
-
environment[key] = 0
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export default environment
|
package/src/errors/errors.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
// BASE
|
|
2
|
-
|
|
3
|
-
export abstract class BudibaseError extends Error {
|
|
4
|
-
code: string
|
|
5
|
-
|
|
6
|
-
constructor(message: string, code: ErrorCode) {
|
|
7
|
-
super(message)
|
|
8
|
-
this.code = code
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
protected getPublicError?(): any
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// ERROR HANDLING
|
|
15
|
-
|
|
16
|
-
export enum ErrorCode {
|
|
17
|
-
USAGE_LIMIT_EXCEEDED = "usage_limit_exceeded",
|
|
18
|
-
FEATURE_DISABLED = "feature_disabled",
|
|
19
|
-
INVALID_API_KEY = "invalid_api_key",
|
|
20
|
-
HTTP = "http",
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* For the given error, build the public representation that is safe
|
|
25
|
-
* to be exposed over an api.
|
|
26
|
-
*/
|
|
27
|
-
export const getPublicError = (err: any) => {
|
|
28
|
-
let error
|
|
29
|
-
if (err.code) {
|
|
30
|
-
// add generic error information
|
|
31
|
-
error = {
|
|
32
|
-
code: err.code,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (err.getPublicError) {
|
|
36
|
-
error = {
|
|
37
|
-
...error,
|
|
38
|
-
// get any additional context from this error
|
|
39
|
-
...err.getPublicError(),
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return error
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// HTTP
|
|
48
|
-
|
|
49
|
-
export class HTTPError extends BudibaseError {
|
|
50
|
-
status: number
|
|
51
|
-
|
|
52
|
-
constructor(message: string, httpStatus: number, code = ErrorCode.HTTP) {
|
|
53
|
-
super(message, code)
|
|
54
|
-
this.status = httpStatus
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export class NotFoundError extends HTTPError {
|
|
59
|
-
constructor(message: string) {
|
|
60
|
-
super(message, 404)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export class BadRequestError extends HTTPError {
|
|
65
|
-
constructor(message: string) {
|
|
66
|
-
super(message, 400)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// LICENSING
|
|
71
|
-
|
|
72
|
-
export class UsageLimitError extends HTTPError {
|
|
73
|
-
limitName: string
|
|
74
|
-
|
|
75
|
-
constructor(message: string, limitName: string) {
|
|
76
|
-
super(message, 400, ErrorCode.USAGE_LIMIT_EXCEEDED)
|
|
77
|
-
this.limitName = limitName
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
getPublicError() {
|
|
81
|
-
return {
|
|
82
|
-
limitName: this.limitName,
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export class FeatureDisabledError extends HTTPError {
|
|
88
|
-
featureName: string
|
|
89
|
-
|
|
90
|
-
constructor(message: string, featureName: string) {
|
|
91
|
-
super(message, 400, ErrorCode.FEATURE_DISABLED)
|
|
92
|
-
this.featureName = featureName
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
getPublicError() {
|
|
96
|
-
return {
|
|
97
|
-
featureName: this.featureName,
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// AUTH
|
|
103
|
-
|
|
104
|
-
export class InvalidAPIKeyError extends BudibaseError {
|
|
105
|
-
constructor() {
|
|
106
|
-
super(
|
|
107
|
-
"Invalid API key - may need re-generated, or user doesn't exist",
|
|
108
|
-
ErrorCode.INVALID_API_KEY
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// USERS
|
|
114
|
-
|
|
115
|
-
export class EmailUnavailableError extends Error {
|
|
116
|
-
constructor(email: string) {
|
|
117
|
-
super(`Email already in use: '${email}'`)
|
|
118
|
-
}
|
|
119
|
-
}
|
package/src/errors/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./errors"
|
package/src/events/analytics.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AsyncEvents } from "@budibase/types"
|
|
2
|
-
import { EventPayload, asyncEventQueue, init } from "./queue"
|
|
3
|
-
|
|
4
|
-
export async function publishAsyncEvent(payload: EventPayload) {
|
|
5
|
-
if (!asyncEventQueue) {
|
|
6
|
-
init()
|
|
7
|
-
}
|
|
8
|
-
const { event, identity } = payload
|
|
9
|
-
if (AsyncEvents.indexOf(event) !== -1 && identity.tenantId) {
|
|
10
|
-
await asyncEventQueue.add(payload)
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import BullQueue from "bull"
|
|
2
|
-
import { createQueue, JobQueue } from "../../queue"
|
|
3
|
-
import { Event, Identity } from "@budibase/types"
|
|
4
|
-
|
|
5
|
-
export interface EventPayload {
|
|
6
|
-
event: Event
|
|
7
|
-
identity: Identity
|
|
8
|
-
properties: any
|
|
9
|
-
timestamp?: string | number
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export let asyncEventQueue: BullQueue.Queue
|
|
13
|
-
|
|
14
|
-
export function init() {
|
|
15
|
-
asyncEventQueue = createQueue<EventPayload>(JobQueue.SYSTEM_EVENT_QUEUE)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function shutdown() {
|
|
19
|
-
if (asyncEventQueue) {
|
|
20
|
-
await asyncEventQueue.close()
|
|
21
|
-
}
|
|
22
|
-
}
|