@budibase/server 1.0.200-alpha.3 → 1.0.200
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/Dockerfile +0 -2
- package/builder/assets/index.f83b3433.js +1315 -0
- package/builder/index.html +1 -1
- package/coverage/clover.xml +1998 -2086
- package/coverage/coverage-final.json +122 -121
- package/coverage/lcov-report/api/controllers/analytics.js.html +202 -0
- package/coverage/lcov-report/api/controllers/apikeys.js.html +6 -6
- package/coverage/lcov-report/api/controllers/auth.js.html +7 -7
- package/coverage/lcov-report/api/controllers/automation.js.html +72 -174
- package/coverage/lcov-report/api/controllers/backup.js.html +6 -30
- package/coverage/lcov-report/api/controllers/cloud.js.html +11 -11
- package/coverage/lcov-report/api/controllers/component.js.html +5 -5
- package/coverage/lcov-report/api/controllers/datasource.js.html +41 -53
- package/coverage/lcov-report/api/controllers/dev.js.html +70 -94
- package/coverage/lcov-report/api/controllers/index.html +72 -57
- package/coverage/lcov-report/api/controllers/integration.js.html +8 -8
- package/coverage/lcov-report/api/controllers/layout.js.html +19 -28
- package/coverage/lcov-report/api/controllers/metadata.js.html +9 -9
- package/coverage/lcov-report/api/controllers/migrations.js.html +4 -4
- package/coverage/lcov-report/api/controllers/permission.js.html +15 -15
- package/coverage/lcov-report/api/controllers/query/index.html +1 -1
- package/coverage/lcov-report/api/controllers/query/validation.js.html +10 -10
- package/coverage/lcov-report/api/controllers/role.js.html +48 -78
- package/coverage/lcov-report/api/controllers/routing.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/external.js.html +19 -19
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +54 -54
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +9 -9
- package/coverage/lcov-report/api/controllers/row/staticFormula.js.html +24 -24
- package/coverage/lcov-report/api/controllers/row/utils.js.html +24 -24
- package/coverage/lcov-report/api/controllers/screen.js.html +20 -56
- package/coverage/lcov-report/api/controllers/script.js.html +4 -4
- package/coverage/lcov-report/api/controllers/table/bulkFormula.js.html +49 -49
- package/coverage/lcov-report/api/controllers/table/external.js.html +17 -23
- package/coverage/lcov-report/api/controllers/table/index.html +26 -26
- package/coverage/lcov-report/api/controllers/table/index.js.html +49 -85
- package/coverage/lcov-report/api/controllers/templates.js.html +6 -6
- package/coverage/lcov-report/api/controllers/user.js.html +19 -19
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +11 -11
- package/coverage/lcov-report/api/controllers/view/index.html +21 -21
- package/coverage/lcov-report/api/controllers/view/index.js.html +65 -275
- package/coverage/lcov-report/api/controllers/view/utils.js.html +23 -23
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +40 -40
- package/coverage/lcov-report/api/controllers/webhook.js.html +17 -17
- package/coverage/lcov-report/api/index.html +15 -15
- package/coverage/lcov-report/api/index.js.html +45 -39
- package/coverage/lcov-report/api/routes/analytics.js.html +13 -7
- package/coverage/lcov-report/api/routes/apikeys.js.html +8 -8
- package/coverage/lcov-report/api/routes/auth.js.html +6 -6
- package/coverage/lcov-report/api/routes/automation.js.html +11 -11
- package/coverage/lcov-report/api/routes/backup.js.html +8 -8
- package/coverage/lcov-report/api/routes/cloud.js.html +8 -8
- package/coverage/lcov-report/api/routes/component.js.html +8 -8
- package/coverage/lcov-report/api/routes/datasource.js.html +9 -9
- package/coverage/lcov-report/api/routes/deploy.js.html +8 -8
- package/coverage/lcov-report/api/routes/dev.js.html +13 -13
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +8 -8
- package/coverage/lcov-report/api/routes/layout.js.html +8 -8
- package/coverage/lcov-report/api/routes/metadata.js.html +9 -9
- package/coverage/lcov-report/api/routes/migrations.js.html +7 -7
- package/coverage/lcov-report/api/routes/permission.js.html +9 -9
- package/coverage/lcov-report/api/routes/query.js.html +10 -10
- package/coverage/lcov-report/api/routes/role.js.html +9 -9
- package/coverage/lcov-report/api/routes/routing.js.html +8 -8
- package/coverage/lcov-report/api/routes/screen.js.html +9 -9
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +10 -10
- package/coverage/lcov-report/api/routes/templates.js.html +8 -8
- package/coverage/lcov-report/api/routes/user.js.html +8 -8
- package/coverage/lcov-report/api/routes/utils/index.html +1 -1
- package/coverage/lcov-report/api/routes/utils/validators.js.html +36 -36
- package/coverage/lcov-report/api/routes/view.js.html +10 -10
- package/coverage/lcov-report/api/routes/webhook.js.html +9 -9
- package/coverage/lcov-report/automations/actions.js.html +25 -25
- package/coverage/lcov-report/automations/automationUtils.js.html +8 -8
- package/coverage/lcov-report/automations/bullboard.js.html +35 -35
- package/coverage/lcov-report/automations/index.html +29 -29
- package/coverage/lcov-report/automations/index.js.html +17 -29
- package/coverage/lcov-report/automations/steps/bash.js.html +7 -7
- package/coverage/lcov-report/automations/steps/delay.js.html +4 -4
- package/coverage/lcov-report/automations/steps/discord.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +7 -7
- package/coverage/lcov-report/automations/steps/executeScript.js.html +6 -6
- package/coverage/lcov-report/automations/steps/filter.js.html +7 -7
- package/coverage/lcov-report/automations/steps/index.html +1 -1
- package/coverage/lcov-report/automations/steps/integromat.js.html +5 -5
- package/coverage/lcov-report/automations/steps/loop.js.html +2 -2
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +8 -8
- package/coverage/lcov-report/automations/steps/queryRows.js.html +10 -10
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +5 -5
- package/coverage/lcov-report/automations/steps/serverLog.js.html +3 -3
- package/coverage/lcov-report/automations/steps/slack.js.html +5 -5
- package/coverage/lcov-report/automations/steps/updateRow.js.html +6 -6
- package/coverage/lcov-report/automations/steps/utils.js.html +3 -3
- package/coverage/lcov-report/automations/steps/zapier.js.html +5 -5
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +8 -8
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +2 -2
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +2 -2
- package/coverage/lcov-report/automations/triggers.js.html +18 -18
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +30 -30
- package/coverage/lcov-report/constants/layouts.js.html +5 -5
- package/coverage/lcov-report/constants/screens.js.html +4 -4
- package/coverage/lcov-report/db/inMemoryView.js.html +5 -5
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +9 -9
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +17 -17
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +36 -36
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +19 -19
- package/coverage/lcov-report/db/newid.js.html +4 -4
- package/coverage/lcov-report/db/utils.js.html +81 -81
- package/coverage/lcov-report/events/AutomationEmitter.js.html +1 -1
- package/coverage/lcov-report/events/index.html +1 -1
- package/coverage/lcov-report/events/index.js.html +7 -7
- package/coverage/lcov-report/events/utils.js.html +10 -10
- package/coverage/lcov-report/index.html +74 -74
- package/coverage/lcov-report/integrations/tests/TestConfiguration.js.html +1 -1
- package/coverage/lcov-report/integrations/tests/index.html +1 -1
- package/coverage/lcov-report/middleware/appInfo.js.html +5 -5
- package/coverage/lcov-report/middleware/builder.js.html +20 -20
- package/coverage/lcov-report/middleware/currentapp.js.html +49 -49
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +14 -14
- package/coverage/lcov-report/middleware/publicApi.js.html +5 -5
- package/coverage/lcov-report/middleware/resourceId.js.html +29 -29
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +4 -4
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +1 -1
- package/coverage/lcov-report/threads/query.js.html +1 -1
- package/coverage/lcov-report/threads/utils.js.html +13 -13
- package/coverage/lcov-report/utilities/budibaseDir.js.html +3 -3
- package/coverage/lcov-report/utilities/centralPath.js.html +14 -14
- package/coverage/lcov-report/utilities/csvParser.js.html +34 -34
- package/coverage/lcov-report/utilities/global.js.html +28 -28
- package/coverage/lcov-report/utilities/index.html +25 -25
- package/coverage/lcov-report/utilities/index.js.html +41 -41
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +18 -18
- package/coverage/lcov-report/utilities/queue/index.html +15 -15
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +6 -6
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +59 -59
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +15 -15
- package/coverage/lcov-report/utilities/scriptRunner.js.html +5 -5
- package/coverage/lcov-report/utilities/security.js.html +8 -8
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/index.html +1 -1
- package/coverage/lcov-report/utilities/usageQuota/rows.js.html +30 -30
- package/coverage/lcov-report/utilities/usageQuota/usageQuoteReset.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +7 -7
- package/coverage/lcov-report/utilities/workerRequests.js.html +29 -29
- package/coverage/lcov.info +2762 -2903
- package/dist/api/controllers/analytics.js +30 -7
- package/dist/api/controllers/application.js +16 -56
- package/dist/api/controllers/automation.js +2 -31
- package/dist/api/controllers/backup.js +0 -7
- package/dist/api/controllers/datasource.js +2 -8
- package/dist/api/controllers/deploy/index.js +2 -6
- package/dist/api/controllers/dev.js +2 -9
- package/dist/api/controllers/layout.js +0 -3
- package/dist/api/controllers/query/import/index.js +2 -12
- package/dist/api/controllers/query/import/sources/curl.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi2.js +0 -3
- package/dist/api/controllers/query/import/sources/openapi3.js +0 -3
- package/dist/api/controllers/query/index.js +2 -16
- package/dist/api/controllers/role.js +0 -11
- package/dist/api/controllers/screen.js +1 -10
- package/dist/api/controllers/static/index.js +15 -29
- package/dist/api/controllers/table/external.js +0 -2
- package/dist/api/controllers/table/index.js +0 -12
- package/dist/api/controllers/table/utils.js +3 -3
- package/dist/api/controllers/view/index.js +6 -62
- package/dist/api/index.js +4 -2
- package/dist/api/routes/analytics.js +3 -1
- package/dist/app.js +8 -16
- package/dist/automations/index.js +0 -4
- package/dist/automations/steps/executeQuery.js +1 -1
- package/dist/environment.js +2 -4
- package/dist/integrations/firebase.js +0 -1
- package/dist/migrations/index.js +31 -95
- package/dist/package.json +69 -79
- package/dist/tests/utilities/TestConfiguration.js +93 -121
- package/dist/tests/utilities/structures.js +0 -45
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/nodemon.json +1 -1
- package/package.json +70 -80
- package/scripts/dev/manage.js +0 -2
- package/scripts/jestSetup.js +0 -7
- package/scripts/likeCypress.ts +1 -1
- package/src/api/controllers/analytics.js +39 -0
- package/src/api/controllers/application.ts +18 -60
- package/src/api/controllers/automation.js +2 -36
- package/src/api/controllers/backup.js +0 -8
- package/src/api/controllers/datasource.js +4 -8
- package/src/api/controllers/deploy/index.ts +2 -6
- package/src/api/controllers/dev.js +2 -10
- package/src/api/controllers/layout.js +0 -3
- package/src/api/controllers/query/import/index.ts +3 -16
- package/src/api/controllers/query/import/sources/base/index.ts +1 -2
- package/src/api/controllers/query/import/sources/curl.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi2.ts +0 -4
- package/src/api/controllers/query/import/sources/openapi3.ts +0 -4
- package/src/api/controllers/query/import/tests/index.spec.js +7 -20
- package/src/api/controllers/query/index.ts +3 -16
- package/src/api/controllers/role.js +0 -10
- package/src/api/controllers/screen.js +1 -13
- package/src/api/controllers/static/index.js +15 -28
- package/src/api/controllers/table/external.js +0 -2
- package/src/api/controllers/table/index.js +0 -12
- package/src/api/controllers/table/utils.ts +4 -4
- package/src/api/controllers/view/index.js +6 -76
- package/src/api/index.js +4 -2
- package/src/api/routes/analytics.js +3 -1
- package/src/api/routes/public/utils/Endpoint.ts +1 -1
- package/src/api/routes/tests/__snapshots__/datasource.spec.js.snap +1 -5
- package/src/api/routes/tests/application.spec.js +4 -64
- package/src/api/routes/tests/automation.spec.js +60 -168
- package/src/api/routes/tests/backup.spec.js +0 -2
- package/src/api/routes/tests/datasource.spec.js +0 -5
- package/src/api/routes/tests/layout.spec.js +0 -4
- package/src/api/routes/tests/query.spec.js +13 -56
- package/src/api/routes/tests/role.spec.js +7 -40
- package/src/api/routes/tests/row.spec.js +3 -2
- package/src/api/routes/tests/screen.spec.js +4 -30
- package/src/api/routes/tests/static.spec.js +54 -120
- package/src/api/routes/tests/table.spec.js +38 -102
- package/src/api/routes/tests/view.spec.js +43 -222
- package/src/app.ts +9 -18
- package/src/automations/index.js +0 -4
- package/src/automations/steps/executeQuery.js +1 -1
- package/src/automations/tests/delay.spec.js +0 -4
- package/src/environment.js +2 -5
- package/src/integrations/firebase.ts +0 -1
- package/src/migrations/index.ts +51 -120
- package/src/module.d.ts +1 -0
- package/src/tests/utilities/TestConfiguration.js +90 -138
- package/src/tests/utilities/structures.js +0 -71
- package/tsconfig.build.json +5 -20
- package/tsconfig.json +17 -22
- package/builder/assets/index.05491b9d.js +0 -1315
- package/dist/migrations/functions/backfill/app/automations.js +0 -31
- package/dist/migrations/functions/backfill/app/datasources.js +0 -28
- package/dist/migrations/functions/backfill/app/layouts.js +0 -33
- package/dist/migrations/functions/backfill/app/queries.js +0 -32
- package/dist/migrations/functions/backfill/app/roles.js +0 -28
- package/dist/migrations/functions/backfill/app/screens.js +0 -28
- package/dist/migrations/functions/backfill/app/tables.js +0 -40
- package/dist/migrations/functions/backfill/app.js +0 -175
- package/dist/migrations/functions/backfill/global/configs.js +0 -61
- package/dist/migrations/functions/backfill/global/quotas.js +0 -60
- package/dist/migrations/functions/backfill/global/users.js +0 -50
- package/dist/migrations/functions/backfill/global.js +0 -189
- package/dist/migrations/functions/backfill/index.js +0 -32
- package/dist/migrations/functions/backfill/installation.js +0 -80
- package/dist/migrations/tests/helpers.js +0 -72
- package/dist/migrations/tests/structures.js +0 -37
- package/src/api/controllers/analytics.ts +0 -8
- package/src/api/routes/tests/data/export.txt +0 -1
- package/src/api/routes/tests/deployment.spec.js +0 -25
- package/src/api/routes/tests/dev.spec.js +0 -40
- package/src/migrations/functions/backfill/app/automations.ts +0 -26
- package/src/migrations/functions/backfill/app/datasources.ts +0 -22
- package/src/migrations/functions/backfill/app/layouts.ts +0 -29
- package/src/migrations/functions/backfill/app/queries.ts +0 -33
- package/src/migrations/functions/backfill/app/roles.ts +0 -22
- package/src/migrations/functions/backfill/app/screens.ts +0 -22
- package/src/migrations/functions/backfill/app/tables.ts +0 -36
- package/src/migrations/functions/backfill/app.ts +0 -148
- package/src/migrations/functions/backfill/global/configs.ts +0 -66
- package/src/migrations/functions/backfill/global/quotas.ts +0 -60
- package/src/migrations/functions/backfill/global/users.ts +0 -49
- package/src/migrations/functions/backfill/global.ts +0 -194
- package/src/migrations/functions/backfill/index.ts +0 -7
- package/src/migrations/functions/backfill/installation.ts +0 -50
- package/src/migrations/tests/helpers.ts +0 -40
- package/src/migrations/tests/index.spec.ts +0 -132
- package/src/migrations/tests/structures.ts +0 -66
|
@@ -55,10 +55,6 @@ class TestConfiguration {
|
|
|
55
55
|
return this.appId
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
getProdAppId() {
|
|
59
|
-
return this.prodAppId
|
|
60
|
-
}
|
|
61
|
-
|
|
62
58
|
async doInContext(appId, task) {
|
|
63
59
|
if (!appId) {
|
|
64
60
|
appId = this.appId
|
|
@@ -75,26 +71,6 @@ class TestConfiguration {
|
|
|
75
71
|
})
|
|
76
72
|
}
|
|
77
73
|
|
|
78
|
-
// SETUP / TEARDOWN
|
|
79
|
-
|
|
80
|
-
// use a new id as the name to avoid name collisions
|
|
81
|
-
async init(appName = newid()) {
|
|
82
|
-
await this.globalUser()
|
|
83
|
-
return this.createApp(appName)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
end() {
|
|
87
|
-
if (!this) {
|
|
88
|
-
return
|
|
89
|
-
}
|
|
90
|
-
if (this.server) {
|
|
91
|
-
this.server.close()
|
|
92
|
-
}
|
|
93
|
-
cleanup(this.allApps.map(app => app.appId))
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// UTILS
|
|
97
|
-
|
|
98
74
|
async _req(config, params, controlFunc) {
|
|
99
75
|
const request = {}
|
|
100
76
|
// fake cookies, we don't need them
|
|
@@ -115,11 +91,24 @@ class TestConfiguration {
|
|
|
115
91
|
})
|
|
116
92
|
}
|
|
117
93
|
|
|
118
|
-
|
|
94
|
+
async generateApiKey(userId = GLOBAL_USER_ID) {
|
|
95
|
+
return doWithGlobalDB(TENANT_ID, async db => {
|
|
96
|
+
const id = generateDevInfoID(userId)
|
|
97
|
+
let devInfo
|
|
98
|
+
try {
|
|
99
|
+
devInfo = await db.get(id)
|
|
100
|
+
} catch (err) {
|
|
101
|
+
devInfo = { _id: id, userId }
|
|
102
|
+
}
|
|
103
|
+
devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`)
|
|
104
|
+
await db.put(devInfo)
|
|
105
|
+
return devInfo.apiKey
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
119
109
|
async globalUser({
|
|
120
110
|
id = GLOBAL_USER_ID,
|
|
121
111
|
builder = true,
|
|
122
|
-
admin = false,
|
|
123
112
|
email = EMAIL,
|
|
124
113
|
roles,
|
|
125
114
|
} = {}) {
|
|
@@ -146,11 +135,6 @@ class TestConfiguration {
|
|
|
146
135
|
} else {
|
|
147
136
|
user.builder = { global: false }
|
|
148
137
|
}
|
|
149
|
-
if (admin) {
|
|
150
|
-
user.admin = { global: true }
|
|
151
|
-
} else {
|
|
152
|
-
user.admin = { global: false }
|
|
153
|
-
}
|
|
154
138
|
const resp = await db.put(user)
|
|
155
139
|
return {
|
|
156
140
|
_rev: resp._rev,
|
|
@@ -159,71 +143,20 @@ class TestConfiguration {
|
|
|
159
143
|
})
|
|
160
144
|
}
|
|
161
145
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
admin = false,
|
|
167
|
-
roles = {}
|
|
168
|
-
) {
|
|
169
|
-
const globalId = !id ? `us_${Math.random()}` : `us_${id}`
|
|
170
|
-
const resp = await this.globalUser({
|
|
171
|
-
id: globalId,
|
|
172
|
-
email,
|
|
173
|
-
builder,
|
|
174
|
-
admin,
|
|
175
|
-
roles,
|
|
176
|
-
})
|
|
177
|
-
await userCache.invalidateUser(globalId)
|
|
178
|
-
return {
|
|
179
|
-
...resp,
|
|
180
|
-
globalId,
|
|
181
|
-
}
|
|
146
|
+
// use a new id as the name to avoid name collisions
|
|
147
|
+
async init(appName = newid()) {
|
|
148
|
+
await this.globalUser()
|
|
149
|
+
return this.createApp(appName)
|
|
182
150
|
}
|
|
183
151
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
|
|
193
|
-
await this.globalUser({
|
|
194
|
-
id: userId,
|
|
195
|
-
builder,
|
|
196
|
-
roles: { [this.prodAppId]: roleId },
|
|
197
|
-
})
|
|
198
|
-
}
|
|
199
|
-
await createASession(userId, {
|
|
200
|
-
sessionId: "sessionid",
|
|
201
|
-
tenantId: TENANT_ID,
|
|
202
|
-
})
|
|
203
|
-
// have to fake this
|
|
204
|
-
const auth = {
|
|
205
|
-
userId,
|
|
206
|
-
sessionId: "sessionid",
|
|
207
|
-
tenantId: TENANT_ID,
|
|
208
|
-
}
|
|
209
|
-
const app = {
|
|
210
|
-
roleId: roleId,
|
|
211
|
-
appId,
|
|
212
|
-
}
|
|
213
|
-
const authToken = jwt.sign(auth, env.JWT_SECRET)
|
|
214
|
-
const appToken = jwt.sign(app, env.JWT_SECRET)
|
|
215
|
-
|
|
216
|
-
// returning necessary request headers
|
|
217
|
-
await userCache.invalidateUser(userId)
|
|
218
|
-
return {
|
|
219
|
-
Accept: "application/json",
|
|
220
|
-
Cookie: [
|
|
221
|
-
`${Cookies.Auth}=${authToken}`,
|
|
222
|
-
`${Cookies.CurrentApp}=${appToken}`,
|
|
223
|
-
],
|
|
224
|
-
[Headers.APP_ID]: appId,
|
|
225
|
-
}
|
|
226
|
-
})
|
|
152
|
+
end() {
|
|
153
|
+
if (!this) {
|
|
154
|
+
return
|
|
155
|
+
}
|
|
156
|
+
if (this.server) {
|
|
157
|
+
this.server.close()
|
|
158
|
+
}
|
|
159
|
+
cleanup(this.allApps.map(app => app.appId))
|
|
227
160
|
}
|
|
228
161
|
|
|
229
162
|
defaultHeaders(extras = {}) {
|
|
@@ -274,25 +207,6 @@ class TestConfiguration {
|
|
|
274
207
|
return this.login({ email, roleId, builder, prodApp })
|
|
275
208
|
}
|
|
276
209
|
|
|
277
|
-
// API
|
|
278
|
-
|
|
279
|
-
async generateApiKey(userId = GLOBAL_USER_ID) {
|
|
280
|
-
return doWithGlobalDB(TENANT_ID, async db => {
|
|
281
|
-
const id = generateDevInfoID(userId)
|
|
282
|
-
let devInfo
|
|
283
|
-
try {
|
|
284
|
-
devInfo = await db.get(id)
|
|
285
|
-
} catch (err) {
|
|
286
|
-
devInfo = { _id: id, userId }
|
|
287
|
-
}
|
|
288
|
-
devInfo.apiKey = encrypt(`${TENANT_ID}${SEPARATOR}${newid()}`)
|
|
289
|
-
await db.put(devInfo)
|
|
290
|
-
return devInfo.apiKey
|
|
291
|
-
})
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// APP
|
|
295
|
-
|
|
296
210
|
async createApp(appName) {
|
|
297
211
|
// create dev app
|
|
298
212
|
// clear any old app
|
|
@@ -325,8 +239,6 @@ class TestConfiguration {
|
|
|
325
239
|
})
|
|
326
240
|
}
|
|
327
241
|
|
|
328
|
-
// TABLE
|
|
329
|
-
|
|
330
242
|
async updateTable(config = null) {
|
|
331
243
|
config = config || basicTable()
|
|
332
244
|
this.table = await this._req(config, null, controllers.table.save)
|
|
@@ -375,8 +287,6 @@ class TestConfiguration {
|
|
|
375
287
|
return this.createTable(table)
|
|
376
288
|
}
|
|
377
289
|
|
|
378
|
-
// ROW
|
|
379
|
-
|
|
380
290
|
async createRow(config = null) {
|
|
381
291
|
if (!this.table) {
|
|
382
292
|
throw "Test requires table to be configured."
|
|
@@ -397,8 +307,6 @@ class TestConfiguration {
|
|
|
397
307
|
return this._req(null, { tableId }, controllers.row.fetch)
|
|
398
308
|
}
|
|
399
309
|
|
|
400
|
-
// ROLE
|
|
401
|
-
|
|
402
310
|
async createRole(config = null) {
|
|
403
311
|
config = config || basicRole()
|
|
404
312
|
return this._req(config, null, controllers.role.save)
|
|
@@ -416,21 +324,18 @@ class TestConfiguration {
|
|
|
416
324
|
)
|
|
417
325
|
}
|
|
418
326
|
|
|
419
|
-
// VIEW
|
|
420
|
-
|
|
421
327
|
async createView(config) {
|
|
422
328
|
if (!this.table) {
|
|
423
329
|
throw "Test requires table to be configured."
|
|
424
330
|
}
|
|
425
331
|
const view = config || {
|
|
332
|
+
map: "function(doc) { emit(doc[doc.key], doc._id); } ",
|
|
426
333
|
tableId: this.table._id,
|
|
427
334
|
name: "ViewTest",
|
|
428
335
|
}
|
|
429
336
|
return this._req(view, null, controllers.view.save)
|
|
430
337
|
}
|
|
431
338
|
|
|
432
|
-
// AUTOMATION
|
|
433
|
-
|
|
434
339
|
async createAutomation(config) {
|
|
435
340
|
config = config || basicAutomation()
|
|
436
341
|
if (config._rev) {
|
|
@@ -458,16 +363,6 @@ class TestConfiguration {
|
|
|
458
363
|
)
|
|
459
364
|
}
|
|
460
365
|
|
|
461
|
-
async createWebhook(config = null) {
|
|
462
|
-
if (!this.automation) {
|
|
463
|
-
throw "Must create an automation before creating webhook."
|
|
464
|
-
}
|
|
465
|
-
config = config || basicWebhook(this.automation._id)
|
|
466
|
-
return (await this._req(config, null, controllers.webhook.save)).webhook
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
// DATASOURCE
|
|
470
|
-
|
|
471
366
|
async createDatasource(config = null) {
|
|
472
367
|
config = config || basicDatasource()
|
|
473
368
|
const response = await this._req(config, null, controllers.datasource.save)
|
|
@@ -518,8 +413,6 @@ class TestConfiguration {
|
|
|
518
413
|
return { datasource, query: basedOnQuery }
|
|
519
414
|
}
|
|
520
415
|
|
|
521
|
-
// QUERY
|
|
522
|
-
|
|
523
416
|
async previewQuery(request, config, datasource, fields) {
|
|
524
417
|
return request
|
|
525
418
|
.post(`/api/queries/preview`)
|
|
@@ -543,19 +436,78 @@ class TestConfiguration {
|
|
|
543
436
|
return this._req(config, null, controllers.query.save)
|
|
544
437
|
}
|
|
545
438
|
|
|
546
|
-
// SCREEN
|
|
547
|
-
|
|
548
439
|
async createScreen(config = null) {
|
|
549
440
|
config = config || basicScreen()
|
|
550
441
|
return this._req(config, null, controllers.screen.save)
|
|
551
442
|
}
|
|
552
443
|
|
|
553
|
-
|
|
444
|
+
async createWebhook(config = null) {
|
|
445
|
+
if (!this.automation) {
|
|
446
|
+
throw "Must create an automation before creating webhook."
|
|
447
|
+
}
|
|
448
|
+
config = config || basicWebhook(this.automation._id)
|
|
449
|
+
return (await this._req(config, null, controllers.webhook.save)).webhook
|
|
450
|
+
}
|
|
554
451
|
|
|
555
452
|
async createLayout(config = null) {
|
|
556
453
|
config = config || basicLayout()
|
|
557
454
|
return await this._req(config, null, controllers.layout.save)
|
|
558
455
|
}
|
|
456
|
+
|
|
457
|
+
async createUser(id = null, email = EMAIL) {
|
|
458
|
+
const globalId = !id ? `us_${Math.random()}` : `us_${id}`
|
|
459
|
+
const resp = await this.globalUser({ id: globalId, email })
|
|
460
|
+
await userCache.invalidateUser(globalId)
|
|
461
|
+
return {
|
|
462
|
+
...resp,
|
|
463
|
+
globalId,
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
async login({ roleId, userId, builder, prodApp = false } = {}) {
|
|
468
|
+
const appId = prodApp ? this.prodAppId : this.appId
|
|
469
|
+
return context.doInAppContext(appId, async () => {
|
|
470
|
+
userId = !userId ? `us_uuid1` : userId
|
|
471
|
+
if (!this.request) {
|
|
472
|
+
throw "Server has not been opened, cannot login."
|
|
473
|
+
}
|
|
474
|
+
// make sure the user exists in the global DB
|
|
475
|
+
if (roleId !== BUILTIN_ROLE_IDS.PUBLIC) {
|
|
476
|
+
await this.globalUser({
|
|
477
|
+
id: userId,
|
|
478
|
+
builder,
|
|
479
|
+
roles: { [this.prodAppId]: roleId },
|
|
480
|
+
})
|
|
481
|
+
}
|
|
482
|
+
await createASession(userId, {
|
|
483
|
+
sessionId: "sessionid",
|
|
484
|
+
tenantId: TENANT_ID,
|
|
485
|
+
})
|
|
486
|
+
// have to fake this
|
|
487
|
+
const auth = {
|
|
488
|
+
userId,
|
|
489
|
+
sessionId: "sessionid",
|
|
490
|
+
tenantId: TENANT_ID,
|
|
491
|
+
}
|
|
492
|
+
const app = {
|
|
493
|
+
roleId: roleId,
|
|
494
|
+
appId,
|
|
495
|
+
}
|
|
496
|
+
const authToken = jwt.sign(auth, env.JWT_SECRET)
|
|
497
|
+
const appToken = jwt.sign(app, env.JWT_SECRET)
|
|
498
|
+
|
|
499
|
+
// returning necessary request headers
|
|
500
|
+
await userCache.invalidateUser(userId)
|
|
501
|
+
return {
|
|
502
|
+
Accept: "application/json",
|
|
503
|
+
Cookie: [
|
|
504
|
+
`${Cookies.Auth}=${authToken}`,
|
|
505
|
+
`${Cookies.CurrentApp}=${appToken}`,
|
|
506
|
+
],
|
|
507
|
+
[Headers.APP_ID]: appId,
|
|
508
|
+
}
|
|
509
|
+
})
|
|
510
|
+
}
|
|
559
511
|
}
|
|
560
512
|
|
|
561
513
|
module.exports = TestConfiguration
|
|
@@ -3,8 +3,6 @@ const { BUILTIN_PERMISSION_IDS } = require("@budibase/backend-core/permissions")
|
|
|
3
3
|
const { createHomeScreen } = require("../../constants/screens")
|
|
4
4
|
const { EMPTY_LAYOUT } = require("../../constants/layouts")
|
|
5
5
|
const { cloneDeep } = require("lodash/fp")
|
|
6
|
-
const { v4: uuidv4 } = require("uuid")
|
|
7
|
-
const { TRIGGER_DEFINITIONS, ACTION_DEFINITIONS } = require("../../automations")
|
|
8
6
|
|
|
9
7
|
exports.TENANT_ID = "default"
|
|
10
8
|
|
|
@@ -30,75 +28,6 @@ exports.basicTable = () => {
|
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
exports.basicView = tableId => {
|
|
34
|
-
return {
|
|
35
|
-
tableId,
|
|
36
|
-
name: "ViewTest",
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
exports.filterView = tableId => {
|
|
41
|
-
return {
|
|
42
|
-
...this.basicView(tableId),
|
|
43
|
-
filters: [
|
|
44
|
-
{
|
|
45
|
-
value: 0,
|
|
46
|
-
condition: "MT",
|
|
47
|
-
key: "count",
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
exports.calculationView = tableId => {
|
|
54
|
-
return {
|
|
55
|
-
...this.basicView(tableId),
|
|
56
|
-
field: "count",
|
|
57
|
-
calculation: "sum",
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
exports.view = tableId => {
|
|
62
|
-
return {
|
|
63
|
-
...this.filterView(tableId),
|
|
64
|
-
...this.calculationView(tableId),
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
exports.automationStep = (actionDefinition = ACTION_DEFINITIONS.CREATE_ROW) => {
|
|
69
|
-
return {
|
|
70
|
-
id: uuidv4(),
|
|
71
|
-
...actionDefinition,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
exports.automationTrigger = (
|
|
76
|
-
triggerDefinition = TRIGGER_DEFINITIONS.ROW_SAVED
|
|
77
|
-
) => {
|
|
78
|
-
return {
|
|
79
|
-
id: uuidv4(),
|
|
80
|
-
...triggerDefinition,
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
exports.newAutomation = ({ steps, trigger } = {}) => {
|
|
85
|
-
const automation = exports.basicAutomation()
|
|
86
|
-
|
|
87
|
-
if (trigger) {
|
|
88
|
-
automation.definition.trigger = trigger
|
|
89
|
-
} else {
|
|
90
|
-
automation.definition.trigger = exports.automationTrigger()
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (steps) {
|
|
94
|
-
automation.definition.steps = steps
|
|
95
|
-
} else {
|
|
96
|
-
automation.definition.steps = [exports.automationStep()]
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return automation
|
|
100
|
-
}
|
|
101
|
-
|
|
102
31
|
exports.basicAutomation = () => {
|
|
103
32
|
return {
|
|
104
33
|
name: "My Automation",
|
package/tsconfig.build.json
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"module": "commonjs",
|
|
5
|
-
"lib": ["es2020"],
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"strict": true,
|
|
8
|
-
"noImplicitAny": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"resolveJsonModule": true,
|
|
11
|
-
"incremental": true,
|
|
12
|
-
"types": [ "node", "jest" ],
|
|
13
|
-
"outDir": "dist",
|
|
14
|
-
"skipLibCheck": true
|
|
15
|
-
},
|
|
16
|
-
"include": [
|
|
17
|
-
"src/**/*"
|
|
18
|
-
],
|
|
2
|
+
// Used for building with tsc
|
|
3
|
+
"extends": "./tsconfig.json",
|
|
19
4
|
"exclude": [
|
|
20
5
|
"node_modules",
|
|
21
|
-
"
|
|
22
|
-
"**/*.spec.
|
|
23
|
-
"**/*.spec.
|
|
6
|
+
"**/*.json",
|
|
7
|
+
"**/*.spec.js",
|
|
8
|
+
"**/*.spec.ts"
|
|
24
9
|
]
|
|
25
10
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "./tsconfig.build.json",
|
|
3
2
|
"compilerOptions": {
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
"target": "es6",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"lib": ["es2019"],
|
|
6
|
+
"allowJs": true,
|
|
7
|
+
"outDir": "dist",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noImplicitAny": true,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"incremental": true,
|
|
13
|
+
"types": [ "node", "jest"],
|
|
13
14
|
},
|
|
14
|
-
"ts-node": {
|
|
15
|
-
"require": ["tsconfig-paths/register"]
|
|
16
|
-
},
|
|
17
|
-
"references": [
|
|
18
|
-
{ "path": "../types" },
|
|
19
|
-
{ "path": "../backend-core" },
|
|
20
|
-
],
|
|
21
15
|
"include": [
|
|
22
|
-
"src/**/*",
|
|
23
|
-
"
|
|
24
|
-
"package.json"
|
|
16
|
+
"./src/**/*",
|
|
17
|
+
"./src/module.d.ts"
|
|
25
18
|
],
|
|
26
19
|
"exclude": [
|
|
27
20
|
"node_modules",
|
|
28
|
-
"
|
|
21
|
+
"**/*.json",
|
|
22
|
+
"**/*.spec.js",
|
|
23
|
+
// "**/*.spec.ts" // don't exclude spec.ts files for editor support
|
|
29
24
|
]
|
|
30
|
-
}
|
|
25
|
+
}
|