@budibase/backend-core 2.11.37 → 2.11.39
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 +324 -276
- package/dist/index.js.map +3 -3
- package/dist/index.js.meta.json +1 -1
- package/dist/package.json +4 -4
- package/dist/plugins.js.map +1 -1
- package/dist/plugins.js.meta.json +1 -1
- package/dist/src/cache/appMetadata.d.ts +5 -5
- package/dist/src/cache/appMetadata.js +5 -5
- package/dist/src/cache/user.d.ts +5 -5
- package/dist/src/cache/user.js +5 -5
- package/dist/src/cache/writethrough.d.ts +1 -1
- package/dist/src/cache/writethrough.js +2 -2
- package/dist/src/cache/writethrough.js.map +1 -1
- package/dist/src/configs/configs.d.ts +1 -1
- package/dist/src/configs/configs.js +1 -1
- package/dist/src/context/mainContext.d.ts +1 -1
- package/dist/src/context/mainContext.js +1 -1
- package/dist/src/db/Replication.d.ts +4 -4
- package/dist/src/db/Replication.js +4 -4
- package/dist/src/db/lucene.d.ts +8 -8
- package/dist/src/db/lucene.js +12 -12
- package/dist/src/db/utils.d.ts +1 -1
- package/dist/src/db/utils.js +1 -1
- package/dist/src/docIds/conversions.d.ts +1 -1
- package/dist/src/docIds/conversions.js +1 -1
- package/dist/src/docIds/ids.d.ts +11 -11
- package/dist/src/docIds/ids.js +11 -11
- package/dist/src/docIds/params.d.ts +8 -8
- package/dist/src/docIds/params.js +8 -8
- package/dist/src/helpers.d.ts +2 -2
- package/dist/src/helpers.js +2 -2
- package/dist/src/middleware/passport/local.d.ts +4 -4
- package/dist/src/middleware/passport/local.js +4 -4
- package/dist/src/middleware/passport/sso/oidc.js +11 -11
- package/dist/src/middleware/passport/utils.d.ts +3 -3
- package/dist/src/middleware/passport/utils.js +3 -3
- package/dist/src/objectStore/buckets/app.d.ts +3 -3
- package/dist/src/objectStore/buckets/app.js +3 -3
- package/dist/src/objectStore/objectStore.d.ts +3 -3
- package/dist/src/objectStore/objectStore.js +3 -3
- package/dist/src/queue/inMemoryQueue.d.ts +6 -6
- package/dist/src/queue/inMemoryQueue.js +9 -9
- package/dist/src/redis/redis.js +1 -1
- package/dist/src/security/permissions.d.ts +2 -2
- package/dist/src/security/permissions.js +2 -2
- package/dist/src/security/roles.d.ts +6 -6
- package/dist/src/security/roles.js +6 -6
- package/dist/src/users/db.d.ts +1 -1
- package/dist/src/users/db.js +12 -5
- package/dist/src/users/db.js.map +1 -1
- package/dist/src/users/users.d.ts +2 -1
- package/dist/src/users/users.js +20 -2
- package/dist/src/users/users.js.map +1 -1
- package/dist/src/users/utils.d.ts +1 -0
- package/dist/src/users/utils.js +2 -1
- package/dist/src/users/utils.js.map +1 -1
- package/dist/src/utils/utils.d.ts +11 -11
- package/dist/src/utils/utils.js +11 -11
- package/dist/tests/core/utilities/structures/licenses.js +13 -0
- package/dist/tests/core/utilities/structures/licenses.js.map +1 -1
- package/dist/tests/core/utilities/structures/quotas.d.ts +1 -1
- package/dist/tests/core/utilities/structures/quotas.js +3 -2
- package/dist/tests/core/utilities/structures/quotas.js.map +1 -1
- package/package.json +4 -4
- package/src/cache/appMetadata.ts +5 -5
- package/src/cache/user.ts +5 -5
- package/src/cache/writethrough.ts +2 -2
- package/src/configs/configs.ts +1 -1
- package/src/context/mainContext.ts +1 -1
- package/src/db/Replication.ts +4 -4
- package/src/db/lucene.ts +12 -12
- package/src/db/utils.ts +1 -1
- package/src/docIds/conversions.ts +1 -1
- package/src/docIds/ids.ts +11 -11
- package/src/docIds/params.ts +8 -8
- package/src/helpers.ts +2 -2
- package/src/middleware/passport/local.ts +4 -4
- package/src/middleware/passport/sso/oidc.ts +11 -11
- package/src/middleware/passport/utils.ts +3 -3
- package/src/objectStore/buckets/app.ts +3 -3
- package/src/objectStore/objectStore.ts +3 -3
- package/src/queue/inMemoryQueue.ts +9 -9
- package/src/redis/redis.ts +1 -1
- package/src/security/permissions.ts +2 -2
- package/src/security/roles.ts +6 -6
- package/src/users/db.ts +63 -48
- package/src/users/users.ts +16 -2
- package/src/users/utils.ts +1 -0
- package/src/utils/utils.ts +11 -11
- package/tests/core/users/users.spec.js +54 -0
- package/tests/core/utilities/structures/licenses.ts +13 -0
- package/tests/core/utilities/structures/quotas.ts +3 -2
|
@@ -60,6 +60,11 @@ function quotas() {
|
|
|
60
60
|
value: 1,
|
|
61
61
|
triggers: [],
|
|
62
62
|
},
|
|
63
|
+
creators: {
|
|
64
|
+
name: "Creators",
|
|
65
|
+
value: 1,
|
|
66
|
+
triggers: [],
|
|
67
|
+
},
|
|
63
68
|
userGroups: {
|
|
64
69
|
name: "User Groups",
|
|
65
70
|
value: 1,
|
|
@@ -104,6 +109,10 @@ exports.customer = customer;
|
|
|
104
109
|
function subscription() {
|
|
105
110
|
return {
|
|
106
111
|
amount: 10000,
|
|
112
|
+
amounts: {
|
|
113
|
+
user: 10000,
|
|
114
|
+
creator: 0,
|
|
115
|
+
},
|
|
107
116
|
cancelAt: undefined,
|
|
108
117
|
currency: "usd",
|
|
109
118
|
currentPeriodEnd: 0,
|
|
@@ -112,6 +121,10 @@ function subscription() {
|
|
|
112
121
|
duration: types_1.PriceDuration.MONTHLY,
|
|
113
122
|
pastDueAt: undefined,
|
|
114
123
|
quantity: 0,
|
|
124
|
+
quantities: {
|
|
125
|
+
user: 0,
|
|
126
|
+
creator: 0,
|
|
127
|
+
},
|
|
115
128
|
status: "active",
|
|
116
129
|
};
|
|
117
130
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"licenses.js","sourceRoot":"","sources":["../../../../../tests/core/utilities/structures/licenses.ts"],"names":[],"mappings":";;;AAAA,2CAcwB;AACxB,2CAAuC;AAEvC,SAAgB,KAAK;IACnB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,qBAAa,CAAC,OAAO;QAC/B,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,IAAI;KAChB,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AAQ,EAAE;YACR,0BAA0B,EAAE;gBAC1B,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,CAAC;gBACR,QAAQ,EAAE,EAAE;aACb;YACD,sBAAsB,EAAE;gBACtB,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE,CAAC;gBACR,QAAQ,EAAE,EAAE;aACb;SACF;KACF,CAAA;AACH,CAAC;
|
|
1
|
+
{"version":3,"file":"licenses.js","sourceRoot":"","sources":["../../../../../tests/core/utilities/structures/licenses.ts"],"names":[],"mappings":";;;AAAA,2CAcwB;AACxB,2CAAuC;AAEvC,SAAgB,KAAK;IACnB,OAAO;QACL,MAAM,EAAE,KAAK;QACb,aAAa,EAAE,KAAK;QACpB,QAAQ,EAAE,KAAK;QACf,QAAQ,EAAE,qBAAa,CAAC,OAAO;QAC/B,OAAO,EAAE,WAAW;QACpB,SAAS,EAAE,SAAS;QACpB,SAAS,EAAE,IAAI;KAChB,CAAA;AACH,CAAC;AAVD,sBAUC;AAEM,MAAM,IAAI,GAAG,CAAC,OAAiB,gBAAQ,CAAC,IAAI,EAAiB,EAAE;IACpE,OAAO;QACL,IAAI;QACJ,aAAa,EAAE,KAAK;QACpB,KAAK,EAAE,iBAAS,CAAC,QAAQ;QACzB,KAAK,EAAE,IAAI,KAAK,gBAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS;KACpD,CAAA;AACH,CAAC,CAAA;AAPY,QAAA,IAAI,QAOhB;AAED,SAAgB,MAAM;IACpB,OAAO;QACL,KAAK,EAAE;YACL,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,CAAC;oBACR,QAAQ,EAAE,EAAE;iBACb;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,CAAC;oBACR,QAAQ,EAAE,EAAE;iBACb;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,SAAS;oB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CAAC;AARD,8CAQC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { QuotaUsage } from "@budibase/types";
|
|
2
|
-
export declare const usage: () => QuotaUsage;
|
|
2
|
+
export declare const usage: (users?: number, creators?: number) => QuotaUsage;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.usage = void 0;
|
|
4
4
|
const types_1 = require("@budibase/types");
|
|
5
|
-
const usage = () => {
|
|
5
|
+
const usage = (users = 0, creators = 0) => {
|
|
6
6
|
return {
|
|
7
7
|
_id: "usage_quota",
|
|
8
8
|
quotaReset: new Date().toISOString(),
|
|
@@ -60,7 +60,8 @@ const usage = () => {
|
|
|
60
60
|
usageQuota: {
|
|
61
61
|
apps: 0,
|
|
62
62
|
plugins: 0,
|
|
63
|
-
users
|
|
63
|
+
users,
|
|
64
|
+
creators,
|
|
64
65
|
userGroups: 0,
|
|
65
66
|
rows: 0,
|
|
66
67
|
triggers: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quotas.js","sourceRoot":"","sources":["../../../../../tests/core/utilities/structures/quotas.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAEvD,MAAM,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"quotas.js","sourceRoot":"","sources":["../../../../../tests/core/utilities/structures/quotas.ts"],"names":[],"mappings":";;;AAAA,2CAA8D;AAEvD,MAAM,KAAK,GAAG,CAAC,QAAgB,CAAC,EAAE,WAAmB,CAAC,EAAc,EAAE;IAC3E,OAAO;QACL,GAAG,EAAE,aAAa;QAClB,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACpC,IAAI,EAAE;YACJ,KAAK,EAAE;gBACL,oEAAoE;gBACpE,UAAU,EAAE;oBACV,IAAI,EAAE,CAAC;iBACR;aACF;SACF;QACD,OAAO,EAAE;YACP,SAAS,EAAE;gBACT,WAAW,EAAE,CAAC;gBACd,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,EAAE;gBACZ,SAAS,EAAE;oBACT,UAAU,EAAE;wBACV,MAAM,EAAE,wBAAgB,CAAC,OAAO;wBAChC,MAAM,EAAE;4BACN,KAAK,EAAE,CAAC;4BACR,KAAK,EAAE,CAAC;yBACT;qBACF;oBACD,iBAAiB,EAAE;wBACjB,MAAM,EAAE,wBAAgB,CAAC,OAAO;wBAChC,MAAM,EAAE;4BACN,IAAI,EAAE,CAAC;4BACP,IAAI,EAAE,CAAC;yBACR;qBACF;oBACD,WAAW,EAAE;wBACX,MAAM,EAAE,wBAAgB,CAAC,WAAW;wBACpC,MAAM,EAAE;4BACN,MAAM,EAAE,CAAC;4BACT,MAAM,EAAE,CAAC;yBACV;qBACF;iBACF;aACF;YACD,SAAS,EAAE;gBACT,WAAW,EAAE,CAAC;gBACd,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,EAAE;aACb;YACD,OAAO,EAAE;gBACP,WAAW,EAAE,CAAC;gBACd,SAAS,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,EAAE;aACb;SACF;QACD,UAAU,EAAE;YACV,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,CAAC;YACV,KAAK;YACL,QAAQ;YACR,UAAU,EAAE,CAAC;YACb,IAAI,EAAE,CAAC;YACP,QAAQ,EAAE,EAAE;SACb;KACF,CAAA;AACH,CAAC,CAAA;AAjEY,QAAA,KAAK,SAiEjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@budibase/backend-core",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.39",
|
|
4
4
|
"description": "Budibase backend core libraries used in server and worker",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@budibase/nano": "10.1.2",
|
|
25
25
|
"@budibase/pouchdb-replication-stream": "1.2.10",
|
|
26
|
-
"@budibase/shared-core": "2.11.
|
|
27
|
-
"@budibase/types": "2.11.
|
|
26
|
+
"@budibase/shared-core": "2.11.39",
|
|
27
|
+
"@budibase/types": "2.11.39",
|
|
28
28
|
"@techpass/passport-openidconnect": "0.3.2",
|
|
29
29
|
"aws-cloudfront-sign": "3.0.2",
|
|
30
30
|
"aws-sdk": "2.1030.0",
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "ecc330f4521e60e5766d7f0e87ac7030a94d8bfc"
|
|
100
100
|
}
|
package/src/cache/appMetadata.ts
CHANGED
|
@@ -33,8 +33,8 @@ function isInvalid(metadata?: { state: string }) {
|
|
|
33
33
|
* Get the requested app metadata by id.
|
|
34
34
|
* Use redis cache to first read the app metadata.
|
|
35
35
|
* If not present fallback to loading the app metadata directly and re-caching.
|
|
36
|
-
* @param
|
|
37
|
-
* @returns
|
|
36
|
+
* @param appId the id of the app to get metadata from.
|
|
37
|
+
* @returns the app metadata.
|
|
38
38
|
*/
|
|
39
39
|
export async function getAppMetadata(appId: string): Promise<App | DeletedApp> {
|
|
40
40
|
const client = await getAppClient()
|
|
@@ -72,9 +72,9 @@ export async function getAppMetadata(appId: string): Promise<App | DeletedApp> {
|
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
74
|
* Invalidate/reset the cached metadata when a change occurs in the db.
|
|
75
|
-
* @param appId
|
|
76
|
-
* @param newMetadata
|
|
77
|
-
* @return
|
|
75
|
+
* @param appId the cache key to bust/update.
|
|
76
|
+
* @param newMetadata optional - can simply provide the new metadata to update with.
|
|
77
|
+
* @return will respond with success when cache is updated.
|
|
78
78
|
*/
|
|
79
79
|
export async function invalidateAppMetadata(appId: string, newMetadata?: any) {
|
|
80
80
|
if (!appId) {
|
package/src/cache/user.ts
CHANGED
|
@@ -61,9 +61,9 @@ async function populateUsersFromDB(
|
|
|
61
61
|
* Get the requested user by id.
|
|
62
62
|
* Use redis cache to first read the user.
|
|
63
63
|
* If not present fallback to loading the user directly and re-caching.
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @param
|
|
64
|
+
* @param userId the id of the user to get
|
|
65
|
+
* @param tenantId the tenant of the user to get
|
|
66
|
+
* @param populateUser function to provide the user for re-caching. default to couch db
|
|
67
67
|
* @returns
|
|
68
68
|
*/
|
|
69
69
|
export async function getUser(
|
|
@@ -111,8 +111,8 @@ export async function getUser(
|
|
|
111
111
|
* Get the requested users by id.
|
|
112
112
|
* Use redis cache to first read the users.
|
|
113
113
|
* If not present fallback to loading the users directly and re-caching.
|
|
114
|
-
* @param
|
|
115
|
-
* @param
|
|
114
|
+
* @param userIds the ids of the user to get
|
|
115
|
+
* @param tenantId the tenant of the users to get
|
|
116
116
|
* @returns
|
|
117
117
|
*/
|
|
118
118
|
export async function getUsers(
|
|
@@ -119,8 +119,8 @@ export class Writethrough {
|
|
|
119
119
|
this.writeRateMs = writeRateMs
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
async put(doc: any) {
|
|
123
|
-
return put(this.db, doc,
|
|
122
|
+
async put(doc: any, writeRateMs: number = this.writeRateMs) {
|
|
123
|
+
return put(this.db, doc, writeRateMs)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
async get(id: string) {
|
package/src/configs/configs.ts
CHANGED
|
@@ -23,7 +23,7 @@ import environment from "../environment"
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Generates a new configuration ID.
|
|
26
|
-
* @returns
|
|
26
|
+
* @returns The new configuration ID which the config doc can be stored under.
|
|
27
27
|
*/
|
|
28
28
|
export function generateConfigID(type: ConfigType) {
|
|
29
29
|
return `${DocumentType.CONFIG}${SEPARATOR}${type}`
|
|
@@ -62,7 +62,7 @@ export function isTenancyEnabled() {
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Given an app ID this will attempt to retrieve the tenant ID from it.
|
|
65
|
-
* @return
|
|
65
|
+
* @return The tenant ID found within the app ID.
|
|
66
66
|
*/
|
|
67
67
|
export function getTenantIDFromAppID(appId: string) {
|
|
68
68
|
if (!appId) {
|
package/src/db/Replication.ts
CHANGED
|
@@ -8,8 +8,8 @@ class Replication {
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
11
|
+
* @param source - the DB you want to replicate or rollback to
|
|
12
|
+
* @param target - the DB you want to replicate to, or rollback from
|
|
13
13
|
*/
|
|
14
14
|
constructor({ source, target }: any) {
|
|
15
15
|
this.source = getPouchDB(source)
|
|
@@ -38,7 +38,7 @@ class Replication {
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Two way replication operation, intended to be promise based.
|
|
41
|
-
* @param
|
|
41
|
+
* @param opts - PouchDB replication options
|
|
42
42
|
*/
|
|
43
43
|
sync(opts = {}) {
|
|
44
44
|
this.replication = this.promisify(this.source.sync, opts)
|
|
@@ -47,7 +47,7 @@ class Replication {
|
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
49
|
* One way replication operation, intended to be promise based.
|
|
50
|
-
* @param
|
|
50
|
+
* @param opts - PouchDB replication options
|
|
51
51
|
*/
|
|
52
52
|
replicate(opts = {}) {
|
|
53
53
|
this.replication = this.promisify(this.source.replicate.to, opts)
|
package/src/db/lucene.ts
CHANGED
|
@@ -599,10 +599,10 @@ async function runQuery<T>(
|
|
|
599
599
|
* Gets round the fixed limit of 200 results from a query by fetching as many
|
|
600
600
|
* pages as required and concatenating the results. This recursively operates
|
|
601
601
|
* until enough results have been found.
|
|
602
|
-
* @param dbName
|
|
603
|
-
* @param index
|
|
604
|
-
* @param query
|
|
605
|
-
* @param params
|
|
602
|
+
* @param dbName Which database to run a lucene query on
|
|
603
|
+
* @param index Which search index to utilise
|
|
604
|
+
* @param query The JSON query structure
|
|
605
|
+
* @param params The search params including:
|
|
606
606
|
* tableId {string} The table ID to search
|
|
607
607
|
* sort {string} The sort column
|
|
608
608
|
* sortOrder {string} The sort order ("ascending" or "descending")
|
|
@@ -655,10 +655,10 @@ async function recursiveSearch<T>(
|
|
|
655
655
|
* Performs a paginated search. A bookmark will be returned to allow the next
|
|
656
656
|
* page to be fetched. There is a max limit off 200 results per page in a
|
|
657
657
|
* paginated search.
|
|
658
|
-
* @param dbName
|
|
659
|
-
* @param index
|
|
660
|
-
* @param query
|
|
661
|
-
* @param params
|
|
658
|
+
* @param dbName Which database to run a lucene query on
|
|
659
|
+
* @param index Which search index to utilise
|
|
660
|
+
* @param query The JSON query structure
|
|
661
|
+
* @param params The search params including:
|
|
662
662
|
* tableId {string} The table ID to search
|
|
663
663
|
* sort {string} The sort column
|
|
664
664
|
* sortOrder {string} The sort order ("ascending" or "descending")
|
|
@@ -722,10 +722,10 @@ export async function paginatedSearch<T>(
|
|
|
722
722
|
* desired amount of results. There is a limit of 1000 results to avoid
|
|
723
723
|
* heavy performance hits, and to avoid client components breaking from
|
|
724
724
|
* handling too much data.
|
|
725
|
-
* @param dbName
|
|
726
|
-
* @param index
|
|
727
|
-
* @param query
|
|
728
|
-
* @param params
|
|
725
|
+
* @param dbName Which database to run a lucene query on
|
|
726
|
+
* @param index Which search index to utilise
|
|
727
|
+
* @param query The JSON query structure
|
|
728
|
+
* @param params The search params including:
|
|
729
729
|
* tableId {string} The table ID to search
|
|
730
730
|
* sort {string} The sort column
|
|
731
731
|
* sortOrder {string} The sort order ("ascending" or "descending")
|
package/src/db/utils.ts
CHANGED
|
@@ -45,7 +45,7 @@ export async function getAllDbs(opts = { efficient: false }) {
|
|
|
45
45
|
* Lots of different points in the system need to find the full list of apps, this will
|
|
46
46
|
* enumerate the entire CouchDB cluster and get the list of databases (every app).
|
|
47
47
|
*
|
|
48
|
-
* @return
|
|
48
|
+
* @return returns the app information document stored in each app database.
|
|
49
49
|
*/
|
|
50
50
|
export async function getAllApps({
|
|
51
51
|
dev,
|
|
@@ -25,7 +25,7 @@ export function isDevApp(app: App) {
|
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* Generates a development app ID from a real app ID.
|
|
28
|
-
* @returns
|
|
28
|
+
* @returns the dev app ID which can be used for dev database.
|
|
29
29
|
*/
|
|
30
30
|
export function getDevelopmentAppID(appId: string) {
|
|
31
31
|
if (!appId || appId.startsWith(APP_DEV_PREFIX)) {
|
package/src/docIds/ids.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { newid } from "./newid"
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Generates a new app ID.
|
|
11
|
-
* @returns
|
|
11
|
+
* @returns The new app ID which the app doc can be stored under.
|
|
12
12
|
*/
|
|
13
13
|
export const generateAppID = (tenantId?: string | null) => {
|
|
14
14
|
let id = APP_PREFIX
|
|
@@ -20,9 +20,9 @@ export const generateAppID = (tenantId?: string | null) => {
|
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Gets a new row ID for the specified table.
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @returns
|
|
23
|
+
* @param tableId The table which the row is being created for.
|
|
24
|
+
* @param id If an ID is to be used then the UUID can be substituted for this.
|
|
25
|
+
* @returns The new ID which a row doc can be stored under.
|
|
26
26
|
*/
|
|
27
27
|
export function generateRowID(tableId: string, id?: string) {
|
|
28
28
|
id = id || newid()
|
|
@@ -31,7 +31,7 @@ export function generateRowID(tableId: string, id?: string) {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Generates a new workspace ID.
|
|
34
|
-
* @returns
|
|
34
|
+
* @returns The new workspace ID which the workspace doc can be stored under.
|
|
35
35
|
*/
|
|
36
36
|
export function generateWorkspaceID() {
|
|
37
37
|
return `${DocumentType.WORKSPACE}${SEPARATOR}${newid()}`
|
|
@@ -39,7 +39,7 @@ export function generateWorkspaceID() {
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Generates a new global user ID.
|
|
42
|
-
* @returns
|
|
42
|
+
* @returns The new user ID which the user doc can be stored under.
|
|
43
43
|
*/
|
|
44
44
|
export function generateGlobalUserID(id?: any) {
|
|
45
45
|
return `${DocumentType.USER}${SEPARATOR}${id || newid()}`
|
|
@@ -52,8 +52,8 @@ export function isGlobalUserID(id: string) {
|
|
|
52
52
|
|
|
53
53
|
/**
|
|
54
54
|
* Generates a new user ID based on the passed in global ID.
|
|
55
|
-
* @param
|
|
56
|
-
* @returns
|
|
55
|
+
* @param globalId The ID of the global user.
|
|
56
|
+
* @returns The new user ID which the user doc can be stored under.
|
|
57
57
|
*/
|
|
58
58
|
export function generateUserMetadataID(globalId: string) {
|
|
59
59
|
return generateRowID(InternalTable.USER_METADATA, globalId)
|
|
@@ -84,7 +84,7 @@ export function generateAppUserID(prodAppId: string, userId: string) {
|
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
86
|
* Generates a new role ID.
|
|
87
|
-
* @returns
|
|
87
|
+
* @returns The new role ID which the role doc can be stored under.
|
|
88
88
|
*/
|
|
89
89
|
export function generateRoleID(name: string) {
|
|
90
90
|
const prefix = `${DocumentType.ROLE}${SEPARATOR}`
|
|
@@ -103,7 +103,7 @@ export function prefixRoleID(name: string) {
|
|
|
103
103
|
|
|
104
104
|
/**
|
|
105
105
|
* Generates a new dev info document ID - this is scoped to a user.
|
|
106
|
-
* @returns
|
|
106
|
+
* @returns The new dev info ID which info for dev (like api key) can be stored under.
|
|
107
107
|
*/
|
|
108
108
|
export const generateDevInfoID = (userId: any) => {
|
|
109
109
|
return `${DocumentType.DEV_INFO}${SEPARATOR}${userId}`
|
|
@@ -111,7 +111,7 @@ export const generateDevInfoID = (userId: any) => {
|
|
|
111
111
|
|
|
112
112
|
/**
|
|
113
113
|
* Generates a new plugin ID - to be used in the global DB.
|
|
114
|
-
* @returns
|
|
114
|
+
* @returns The new plugin ID which a plugin metadata document can be stored under.
|
|
115
115
|
*/
|
|
116
116
|
export const generatePluginID = (name: string) => {
|
|
117
117
|
return `${DocumentType.PLUGIN}${SEPARATOR}${name}`
|
package/src/docIds/params.ts
CHANGED
|
@@ -12,12 +12,12 @@ import { getProdAppID } from "./conversions"
|
|
|
12
12
|
* is usually the case as most of our docs are top level e.g. tables, automations, users and so on.
|
|
13
13
|
* More complex cases such as link docs and rows which have multiple levels of IDs that their
|
|
14
14
|
* ID consists of need their own functions to build the allDocs parameters.
|
|
15
|
-
* @param
|
|
15
|
+
* @param docType The type of document which input params are being built for, e.g. user,
|
|
16
16
|
* link, app, table and so on.
|
|
17
|
-
* @param
|
|
17
|
+
* @param docId The ID of the document minus its type - this is only needed if looking
|
|
18
18
|
* for a singular document.
|
|
19
|
-
* @param
|
|
20
|
-
* @returns
|
|
19
|
+
* @param otherProps Add any other properties onto the request, e.g. include_docs.
|
|
20
|
+
* @returns Parameters which can then be used with an allDocs request.
|
|
21
21
|
*/
|
|
22
22
|
export function getDocParams(
|
|
23
23
|
docType: string,
|
|
@@ -36,11 +36,11 @@ export function getDocParams(
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Gets the DB allDocs/query params for retrieving a row.
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
39
|
+
* @param tableId The table in which the rows have been stored.
|
|
40
|
+
* @param rowId The ID of the row which is being specifically queried for. This can be
|
|
41
41
|
* left null to get all the rows in the table.
|
|
42
|
-
* @param
|
|
43
|
-
* @returns
|
|
42
|
+
* @param otherProps Any other properties to add to the request.
|
|
43
|
+
* @returns Parameters which can then be used with an allDocs request.
|
|
44
44
|
*/
|
|
45
45
|
export function getRowParams(
|
|
46
46
|
tableId?: string | null,
|
package/src/helpers.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Makes sure that a URL has the correct number of slashes, while maintaining the
|
|
3
3
|
* http(s):// double slashes.
|
|
4
|
-
* @param
|
|
5
|
-
* @return
|
|
4
|
+
* @param url The URL to test and remove any extra double slashes.
|
|
5
|
+
* @return The updated url.
|
|
6
6
|
*/
|
|
7
7
|
export function checkSlashesInUrl(url: string) {
|
|
8
8
|
return url.replace(/(https?:\/\/)|(\/)+/g, "$1$2")
|
|
@@ -13,10 +13,10 @@ export const options = {
|
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Passport Local Authentication Middleware.
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
16
|
+
* @param ctx the request structure
|
|
17
|
+
* @param email username to login with
|
|
18
|
+
* @param password plain text password to log in with
|
|
19
|
+
* @param done callback from passport to return user information and errors
|
|
20
20
|
* @returns The authenticated user, or errors if they occur
|
|
21
21
|
*/
|
|
22
22
|
export async function authenticate(
|
|
@@ -17,15 +17,15 @@ const OIDCStrategy = require("@techpass/passport-openidconnect").Strategy
|
|
|
17
17
|
|
|
18
18
|
export function buildVerifyFn(saveUserFn: SaveSSOUserFunction) {
|
|
19
19
|
/**
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
20
|
+
* @param issuer The identity provider base URL
|
|
21
|
+
* @param sub The user ID
|
|
22
|
+
* @param profile The user profile information. Created by passport from the /userinfo response
|
|
23
|
+
* @param jwtClaims The parsed id_token claims
|
|
24
|
+
* @param accessToken The access_token for contacting the identity provider - may or may not be a JWT
|
|
25
|
+
* @param refreshToken The refresh_token for obtaining a new access_token - usually not a JWT
|
|
26
|
+
* @param idToken The id_token - always a JWT
|
|
27
|
+
* @param params The response body from requesting an access_token
|
|
28
|
+
* @param done The passport callback: err, user, info
|
|
29
29
|
*/
|
|
30
30
|
return async (
|
|
31
31
|
issuer: string,
|
|
@@ -61,8 +61,8 @@ export function buildVerifyFn(saveUserFn: SaveSSOUserFunction) {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
64
|
+
* @param profile The structured profile created by passport using the user info endpoint
|
|
65
|
+
* @param jwtClaims The claims returned in the id token
|
|
66
66
|
*/
|
|
67
67
|
function getEmail(profile: SSOProfile, jwtClaims: JwtClaims) {
|
|
68
68
|
// profile not guaranteed to contain email e.g. github connected azure ad account
|
|
@@ -5,9 +5,9 @@ import { ConfigType, GoogleInnerConfig } from "@budibase/types"
|
|
|
5
5
|
/**
|
|
6
6
|
* Utility to handle authentication errors.
|
|
7
7
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
8
|
+
* @param done The passport callback.
|
|
9
|
+
* @param message Message that will be returned in the response body
|
|
10
|
+
* @param err (Optional) error that will be logged
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export function authError(done: Function, message: string, err?: any) {
|
|
@@ -6,10 +6,10 @@ import * as cloudfront from "../cloudfront"
|
|
|
6
6
|
* In production the client library is stored in the object store, however in development
|
|
7
7
|
* we use the symlinked version produced by lerna, located in node modules. We link to this
|
|
8
8
|
* via a specific endpoint (under /api/assets/client).
|
|
9
|
-
* @param
|
|
9
|
+
* @param appId In production we need the appId to look up the correct bucket, as the
|
|
10
10
|
* version of the client lib may differ between apps.
|
|
11
|
-
* @param
|
|
12
|
-
* @return
|
|
11
|
+
* @param version The version to retrieve.
|
|
12
|
+
* @return The URL to be inserted into appPackage response or server rendered
|
|
13
13
|
* app index file.
|
|
14
14
|
*/
|
|
15
15
|
export const clientLibraryUrl = (appId: string, version: string) => {
|
|
@@ -61,9 +61,9 @@ export function sanitizeBucket(input: string) {
|
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
63
|
* Gets a connection to the object store using the S3 SDK.
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @return
|
|
64
|
+
* @param bucket the name of the bucket which blobs will be uploaded/retrieved from.
|
|
65
|
+
* @param opts configuration for the object store.
|
|
66
|
+
* @return an S3 object store object, check S3 Nodejs SDK for usage.
|
|
67
67
|
* @constructor
|
|
68
68
|
*/
|
|
69
69
|
export const ObjectStore = (
|
|
@@ -5,9 +5,9 @@ import { timeout } from "../utils"
|
|
|
5
5
|
* Bull works with a Job wrapper around all messages that contains a lot more information about
|
|
6
6
|
* the state of the message, this object constructor implements the same schema of Bull jobs
|
|
7
7
|
* for the sake of maintaining API consistency.
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @returns
|
|
8
|
+
* @param queue The name of the queue which the message will be carried on.
|
|
9
|
+
* @param message The JSON message which will be passed back to the consumer.
|
|
10
|
+
* @returns A new job which can now be put onto the queue, this is mostly an
|
|
11
11
|
* internal structure so that an in memory queue can be easily swapped for a Bull queue.
|
|
12
12
|
*/
|
|
13
13
|
function newJob(queue: string, message: any) {
|
|
@@ -32,8 +32,8 @@ class InMemoryQueue {
|
|
|
32
32
|
_addCount: number
|
|
33
33
|
/**
|
|
34
34
|
* The constructor the queue, exactly the same as that of Bulls.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
35
|
+
* @param name The name of the queue which is being configured.
|
|
36
|
+
* @param opts This is not used by the in memory queue as there is no real use
|
|
37
37
|
* case when in memory, but is the same API as Bull
|
|
38
38
|
*/
|
|
39
39
|
constructor(name: string, opts = null) {
|
|
@@ -49,7 +49,7 @@ class InMemoryQueue {
|
|
|
49
49
|
* Same callback API as Bull, each callback passed to this will consume messages as they are
|
|
50
50
|
* available. Please note this is a queue service, not a notification service, so each
|
|
51
51
|
* consumer will receive different messages.
|
|
52
|
-
* @param
|
|
52
|
+
* @param func The callback function which will return a "Job", the same
|
|
53
53
|
* as the Bull API, within this job the property "data" contains the JSON message. Please
|
|
54
54
|
* note this is incredibly limited compared to Bull as in reality the Job would contain
|
|
55
55
|
* a lot more information about the queue and current status of Bull cluster.
|
|
@@ -73,9 +73,9 @@ class InMemoryQueue {
|
|
|
73
73
|
* Simple function to replicate the add message functionality of Bull, putting
|
|
74
74
|
* a new message on the queue. This then emits an event which will be used to
|
|
75
75
|
* return the message to a consumer (if one is attached).
|
|
76
|
-
* @param
|
|
76
|
+
* @param msg A message to be transported over the queue, this should be
|
|
77
77
|
* a JSON message as this is required by Bull.
|
|
78
|
-
* @param
|
|
78
|
+
* @param repeat serves no purpose for the import queue.
|
|
79
79
|
*/
|
|
80
80
|
// eslint-disable-next-line no-unused-vars
|
|
81
81
|
add(msg: any, repeat: boolean) {
|
|
@@ -96,7 +96,7 @@ class InMemoryQueue {
|
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* This removes a cron which has been implemented, this is part of Bull API.
|
|
99
|
-
* @param
|
|
99
|
+
* @param cronJobId The cron which is to be removed.
|
|
100
100
|
*/
|
|
101
101
|
removeRepeatableByKey(cronJobId: string) {
|
|
102
102
|
// TODO: implement for testing
|
package/src/redis/redis.ts
CHANGED
|
@@ -142,7 +142,7 @@ function waitForConnection(selectDb: number = DEFAULT_SELECT_DB) {
|
|
|
142
142
|
* this can only be done with redis streams because they will have an end.
|
|
143
143
|
* @param stream A redis stream, specifically as this type of stream will have an end.
|
|
144
144
|
* @param client The client to use for further lookups.
|
|
145
|
-
* @return
|
|
145
|
+
* @return The final output of the stream
|
|
146
146
|
*/
|
|
147
147
|
function promisifyStream(stream: any, client: RedisWrapper) {
|
|
148
148
|
return new Promise((resolve, reject) => {
|
|
@@ -36,8 +36,8 @@ export function levelToNumber(perm: PermissionLevel) {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Given the specified permission level for the user return the levels they are allowed to carry out.
|
|
39
|
-
* @param
|
|
40
|
-
* @return
|
|
39
|
+
* @param userPermLevel The permission level of the user.
|
|
40
|
+
* @return All the permission levels this user is allowed to carry out.
|
|
41
41
|
*/
|
|
42
42
|
export function getAllowedLevels(userPermLevel: PermissionLevel): string[] {
|
|
43
43
|
switch (userPermLevel) {
|
package/src/security/roles.ts
CHANGED
|
@@ -149,9 +149,9 @@ export function lowerBuiltinRoleID(roleId1?: string, roleId2?: string): string {
|
|
|
149
149
|
/**
|
|
150
150
|
* Gets the role object, this is mainly useful for two purposes, to check if the level exists and
|
|
151
151
|
* to check if the role inherits any others.
|
|
152
|
-
* @param
|
|
153
|
-
* @param
|
|
154
|
-
* @returns
|
|
152
|
+
* @param roleId The level ID to lookup.
|
|
153
|
+
* @param opts options for the function, like whether to halt errors, instead return public.
|
|
154
|
+
* @returns The role object, which may contain an "inherits" property.
|
|
155
155
|
*/
|
|
156
156
|
export async function getRole(
|
|
157
157
|
roleId?: string,
|
|
@@ -225,8 +225,8 @@ export async function getUserRoleIdHierarchy(
|
|
|
225
225
|
/**
|
|
226
226
|
* Returns an ordered array of the user's inherited role IDs, this can be used
|
|
227
227
|
* to determine if a user can access something that requires a specific role.
|
|
228
|
-
* @param
|
|
229
|
-
* @returns
|
|
228
|
+
* @param userRoleId The user's role ID, this can be found in their access token.
|
|
229
|
+
* @returns returns an ordered array of the roles, with the first being their
|
|
230
230
|
* highest level of access and the last being the lowest level.
|
|
231
231
|
*/
|
|
232
232
|
export async function getUserRoleHierarchy(userRoleId?: string) {
|
|
@@ -258,7 +258,7 @@ export async function getAllRoleIds(appId?: string) {
|
|
|
258
258
|
|
|
259
259
|
/**
|
|
260
260
|
* Given an app ID this will retrieve all of the roles that are currently within that app.
|
|
261
|
-
* @return
|
|
261
|
+
* @return An array of the role objects that were found.
|
|
262
262
|
*/
|
|
263
263
|
export async function getAllRoles(appId?: string): Promise<RoleDoc[]> {
|
|
264
264
|
if (appId) {
|