@budibase/server 1.0.27-alpha.2 → 1.0.27-alpha.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/__mocks__/node-fetch.ts +18 -0
- package/builder/assets/{index.5522fcd5.css → index.431d69df.css} +1 -1
- package/builder/assets/{index.e9e2c4d7.js → index.f909f0e2.js} +245 -240
- package/builder/index.html +2 -2
- package/coverage/clover.xml +429 -339
- package/coverage/coverage-final.json +22 -22
- package/coverage/lcov-report/api/controllers/analytics.js.html +1 -1
- package/coverage/lcov-report/api/controllers/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/controllers/application.js.html +54 -54
- package/coverage/lcov-report/api/controllers/auth.js.html +1 -1
- package/coverage/lcov-report/api/controllers/automation.js.html +1 -1
- package/coverage/lcov-report/api/controllers/backup.js.html +1 -1
- package/coverage/lcov-report/api/controllers/cloud.js.html +1 -1
- package/coverage/lcov-report/api/controllers/component.js.html +1 -1
- package/coverage/lcov-report/api/controllers/datasource.js.html +49 -49
- package/coverage/lcov-report/api/controllers/dev.js.html +1 -1
- package/coverage/lcov-report/api/controllers/hosting.js.html +1 -1
- package/coverage/lcov-report/api/controllers/index.html +20 -20
- package/coverage/lcov-report/api/controllers/integration.js.html +1 -1
- package/coverage/lcov-report/api/controllers/layout.js.html +1 -1
- package/coverage/lcov-report/api/controllers/metadata.js.html +1 -1
- package/coverage/lcov-report/api/controllers/permission.js.html +1 -1
- package/coverage/lcov-report/api/controllers/query/index.html +19 -19
- package/coverage/lcov-report/api/controllers/query/index.js.html +66 -150
- package/coverage/lcov-report/api/controllers/query/validation.js.html +6 -3
- package/coverage/lcov-report/api/controllers/role.js.html +1 -1
- package/coverage/lcov-report/api/controllers/routing.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.html +1 -1
- package/coverage/lcov-report/api/controllers/row/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/internalSearch.js.html +1 -1
- package/coverage/lcov-report/api/controllers/row/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/screen.js.html +1 -1
- package/coverage/lcov-report/api/controllers/script.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/external.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.html +1 -1
- package/coverage/lcov-report/api/controllers/table/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/internal.js.html +1 -1
- package/coverage/lcov-report/api/controllers/table/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/templates.js.html +1 -1
- package/coverage/lcov-report/api/controllers/user.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/exporters.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.html +1 -1
- package/coverage/lcov-report/api/controllers/view/index.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/utils.js.html +1 -1
- package/coverage/lcov-report/api/controllers/view/viewBuilder.js.html +1 -1
- package/coverage/lcov-report/api/controllers/webhook.js.html +1 -1
- package/coverage/lcov-report/api/index.html +1 -1
- package/coverage/lcov-report/api/index.js.html +5 -5
- package/coverage/lcov-report/api/routes/analytics.js.html +1 -1
- package/coverage/lcov-report/api/routes/apikeys.js.html +1 -1
- package/coverage/lcov-report/api/routes/application.js.html +1 -1
- package/coverage/lcov-report/api/routes/auth.js.html +1 -1
- package/coverage/lcov-report/api/routes/automation.js.html +1 -1
- package/coverage/lcov-report/api/routes/backup.js.html +1 -1
- package/coverage/lcov-report/api/routes/cloud.js.html +1 -1
- package/coverage/lcov-report/api/routes/component.js.html +1 -1
- package/coverage/lcov-report/api/routes/datasource.js.html +1 -1
- package/coverage/lcov-report/api/routes/deploy.js.html +1 -1
- package/coverage/lcov-report/api/routes/dev.js.html +1 -1
- package/coverage/lcov-report/api/routes/hosting.js.html +1 -1
- package/coverage/lcov-report/api/routes/index.html +1 -1
- package/coverage/lcov-report/api/routes/index.js.html +1 -1
- package/coverage/lcov-report/api/routes/integration.js.html +1 -1
- package/coverage/lcov-report/api/routes/layout.js.html +1 -1
- package/coverage/lcov-report/api/routes/metadata.js.html +1 -1
- package/coverage/lcov-report/api/routes/permission.js.html +1 -1
- package/coverage/lcov-report/api/routes/query.js.html +24 -3
- package/coverage/lcov-report/api/routes/role.js.html +1 -1
- package/coverage/lcov-report/api/routes/routing.js.html +1 -1
- package/coverage/lcov-report/api/routes/row.js.html +1 -1
- package/coverage/lcov-report/api/routes/screen.js.html +1 -1
- package/coverage/lcov-report/api/routes/script.js.html +1 -1
- package/coverage/lcov-report/api/routes/static.js.html +1 -1
- package/coverage/lcov-report/api/routes/table.js.html +1 -1
- package/coverage/lcov-report/api/routes/templates.js.html +1 -1
- package/coverage/lcov-report/api/routes/user.js.html +1 -1
- package/coverage/lcov-report/api/routes/view.js.html +1 -1
- package/coverage/lcov-report/api/routes/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/actions.js.html +1 -1
- package/coverage/lcov-report/automations/automationUtils.js.html +1 -1
- package/coverage/lcov-report/automations/bullboard.js.html +1 -1
- package/coverage/lcov-report/automations/index.html +1 -1
- package/coverage/lcov-report/automations/index.js.html +1 -1
- package/coverage/lcov-report/automations/steps/bash.js.html +1 -1
- package/coverage/lcov-report/automations/steps/createRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/delay.js.html +1 -1
- package/coverage/lcov-report/automations/steps/deleteRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/discord.js.html +1 -1
- package/coverage/lcov-report/automations/steps/executeQuery.js.html +31 -7
- package/coverage/lcov-report/automations/steps/executeScript.js.html +1 -1
- package/coverage/lcov-report/automations/steps/filter.js.html +1 -1
- package/coverage/lcov-report/automations/steps/index.html +11 -11
- package/coverage/lcov-report/automations/steps/integromat.js.html +1 -1
- package/coverage/lcov-report/automations/steps/outgoingWebhook.js.html +1 -1
- package/coverage/lcov-report/automations/steps/queryRows.js.html +1 -1
- package/coverage/lcov-report/automations/steps/sendSmtpEmail.js.html +1 -1
- package/coverage/lcov-report/automations/steps/serverLog.js.html +1 -1
- package/coverage/lcov-report/automations/steps/slack.js.html +1 -1
- package/coverage/lcov-report/automations/steps/updateRow.js.html +1 -1
- package/coverage/lcov-report/automations/steps/utils.js.html +1 -1
- package/coverage/lcov-report/automations/steps/zapier.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/app.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/cron.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/index.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowDeleted.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowSaved.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/rowUpdated.js.html +1 -1
- package/coverage/lcov-report/automations/triggerInfo/webhook.js.html +1 -1
- package/coverage/lcov-report/automations/triggers.js.html +1 -1
- package/coverage/lcov-report/automations/utils.js.html +5 -5
- package/coverage/lcov-report/constants/index.html +1 -1
- package/coverage/lcov-report/constants/index.js.html +1 -1
- package/coverage/lcov-report/constants/layouts.js.html +1 -1
- package/coverage/lcov-report/constants/screens.js.html +1 -1
- package/coverage/lcov-report/db/client.js.html +1 -1
- package/coverage/lcov-report/db/inMemoryView.js.html +1 -1
- package/coverage/lcov-report/db/index.html +1 -1
- package/coverage/lcov-report/db/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/LinkController.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.html +1 -1
- package/coverage/lcov-report/db/linkedRows/index.js.html +1 -1
- package/coverage/lcov-report/db/linkedRows/linkUtils.js.html +1 -1
- package/coverage/lcov-report/db/newid.js.html +2 -2
- package/coverage/lcov-report/db/utils.js.html +18 -18
- 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 +1 -1
- package/coverage/lcov-report/events/utils.js.html +1 -1
- package/coverage/lcov-report/index.html +46 -46
- 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 +1 -1
- package/coverage/lcov-report/middleware/authorized.js.html +10 -10
- package/coverage/lcov-report/middleware/builder.js.html +8 -8
- package/coverage/lcov-report/middleware/currentapp.js.html +28 -28
- package/coverage/lcov-report/middleware/index.html +1 -1
- package/coverage/lcov-report/middleware/joi-validator.js.html +9 -9
- package/coverage/lcov-report/middleware/resourceId.js.html +17 -17
- package/coverage/lcov-report/middleware/selfhost.js.html +1 -1
- package/coverage/lcov-report/middleware/usageQuota.js.html +1 -1
- package/coverage/lcov-report/middleware/utils.js.html +2 -2
- package/coverage/lcov-report/threads/automation.js.html +1 -1
- package/coverage/lcov-report/threads/index.html +30 -30
- package/coverage/lcov-report/threads/index.js.html +11 -11
- package/coverage/lcov-report/threads/query.js.html +358 -91
- package/coverage/lcov-report/threads/utils.js.html +352 -10
- package/coverage/lcov-report/utilities/bcrypt.js.html +1 -1
- package/coverage/lcov-report/utilities/budibaseDir.js.html +1 -1
- package/coverage/lcov-report/utilities/centralPath.js.html +1 -1
- package/coverage/lcov-report/utilities/csvParser.js.html +1 -1
- package/coverage/lcov-report/utilities/global.js.html +13 -13
- package/coverage/lcov-report/utilities/index.html +1 -1
- package/coverage/lcov-report/utilities/index.js.html +9 -9
- package/coverage/lcov-report/utilities/queue/inMemoryQueue.js.html +2 -2
- package/coverage/lcov-report/utilities/queue/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.html +1 -1
- package/coverage/lcov-report/utilities/routing/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/index.js.html +1 -1
- package/coverage/lcov-report/utilities/rowProcessor/utils.js.html +1 -1
- package/coverage/lcov-report/utilities/scriptRunner.js.html +1 -1
- package/coverage/lcov-report/utilities/security.js.html +1 -1
- package/coverage/lcov-report/utilities/statusCodes.js.html +1 -1
- package/coverage/lcov-report/utilities/users.js.html +1 -1
- package/coverage/lcov-report/utilities/workerRequests.js.html +1 -1
- package/coverage/lcov.info +732 -576
- package/dist/api/controllers/query/import/sources/curl.js +5 -1
- package/dist/api/controllers/query/index.js +29 -47
- package/dist/api/controllers/query/validation.js +2 -1
- package/dist/api/routes/query.js +3 -1
- package/dist/automations/steps/executeQuery.js +8 -1
- package/dist/integrations/rest.js +2 -2
- package/dist/package.json +5 -4
- package/dist/tests/utilities/TestConfiguration.js +7 -0
- package/dist/threads/query.js +145 -52
- package/dist/threads/utils.js +104 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/src/api/controllers/query/import/sources/curl.ts +5 -1
- package/src/api/controllers/query/index.js +27 -55
- package/src/api/controllers/query/validation.js +2 -1
- package/src/api/routes/query.js +8 -1
- package/src/api/routes/tests/query.spec.js +88 -0
- package/src/automations/steps/executeQuery.js +9 -1
- package/src/definitions/datasource.ts +10 -0
- package/src/integrations/rest.ts +5 -2
- package/src/tests/utilities/TestConfiguration.js +10 -0
- package/src/threads/query.js +145 -56
- package/src/threads/utils.js +114 -0
package/src/threads/utils.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
const env = require("../environment")
|
|
2
2
|
const CouchDB = require("../db")
|
|
3
3
|
const { init } = require("@budibase/auth")
|
|
4
|
+
const redis = require("@budibase/auth/redis")
|
|
5
|
+
const { SEPARATOR } = require("@budibase/auth/db")
|
|
6
|
+
const { processStringSync } = require("@budibase/string-templates")
|
|
7
|
+
|
|
8
|
+
const VARIABLE_TTL_SECONDS = 3600
|
|
9
|
+
let client
|
|
10
|
+
|
|
11
|
+
const IS_TRIPLE_BRACE = new RegExp(/^{{3}.*}{3}$/)
|
|
12
|
+
const IS_HANDLEBARS = new RegExp(/^{{2}.*}{2}$/)
|
|
13
|
+
|
|
14
|
+
async function getClient() {
|
|
15
|
+
if (!client) {
|
|
16
|
+
client = await new redis.Client(redis.utils.Databases.QUERY_VARS).init()
|
|
17
|
+
}
|
|
18
|
+
return client
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
process.on("exit", async () => {
|
|
22
|
+
if (client) await client.finish()
|
|
23
|
+
})
|
|
4
24
|
|
|
5
25
|
exports.threadSetup = () => {
|
|
6
26
|
// don't run this if not threading
|
|
@@ -11,3 +31,97 @@ exports.threadSetup = () => {
|
|
|
11
31
|
env.setInThread()
|
|
12
32
|
init(CouchDB)
|
|
13
33
|
}
|
|
34
|
+
|
|
35
|
+
function makeVariableKey(queryId, variable) {
|
|
36
|
+
return `${queryId}${SEPARATOR}${variable}`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.checkCacheForDynamicVariable = async (queryId, variable) => {
|
|
40
|
+
const cache = await getClient()
|
|
41
|
+
return cache.get(makeVariableKey(queryId, variable))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.invalidateDynamicVariables = async cachedVars => {
|
|
45
|
+
let promises = []
|
|
46
|
+
for (let variable of cachedVars) {
|
|
47
|
+
promises.push(
|
|
48
|
+
client.delete(makeVariableKey(variable.queryId, variable.name))
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
await Promise.all(promises)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
exports.storeDynamicVariable = async (queryId, variable, value) => {
|
|
55
|
+
const cache = await getClient()
|
|
56
|
+
await cache.store(
|
|
57
|
+
makeVariableKey(queryId, variable),
|
|
58
|
+
value,
|
|
59
|
+
VARIABLE_TTL_SECONDS
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.formatResponse = resp => {
|
|
64
|
+
if (typeof resp === "string") {
|
|
65
|
+
try {
|
|
66
|
+
resp = JSON.parse(resp)
|
|
67
|
+
} catch (err) {
|
|
68
|
+
resp = { response: resp }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return resp
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
exports.hasExtraData = response => {
|
|
75
|
+
return (
|
|
76
|
+
typeof response === "object" &&
|
|
77
|
+
!Array.isArray(response) &&
|
|
78
|
+
response.data != null &&
|
|
79
|
+
response.info != null
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.enrichQueryFields = (fields, parameters = {}) => {
|
|
84
|
+
const enrichedQuery = {}
|
|
85
|
+
|
|
86
|
+
// enrich the fields with dynamic parameters
|
|
87
|
+
for (let key of Object.keys(fields)) {
|
|
88
|
+
if (fields[key] == null) {
|
|
89
|
+
continue
|
|
90
|
+
}
|
|
91
|
+
if (typeof fields[key] === "object") {
|
|
92
|
+
// enrich nested fields object
|
|
93
|
+
enrichedQuery[key] = this.enrichQueryFields(fields[key], parameters)
|
|
94
|
+
} else if (typeof fields[key] === "string") {
|
|
95
|
+
// enrich string value as normal
|
|
96
|
+
let value = fields[key]
|
|
97
|
+
// add triple brace to avoid escaping e.g. '=' in cookie header
|
|
98
|
+
if (IS_HANDLEBARS.test(value) && !IS_TRIPLE_BRACE.test(value)) {
|
|
99
|
+
value = `{${value}}`
|
|
100
|
+
}
|
|
101
|
+
enrichedQuery[key] = processStringSync(value, parameters, {
|
|
102
|
+
noHelpers: true,
|
|
103
|
+
})
|
|
104
|
+
} else {
|
|
105
|
+
enrichedQuery[key] = fields[key]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
enrichedQuery.json ||
|
|
111
|
+
enrichedQuery.customData ||
|
|
112
|
+
enrichedQuery.requestBody
|
|
113
|
+
) {
|
|
114
|
+
try {
|
|
115
|
+
enrichedQuery.json = JSON.parse(
|
|
116
|
+
enrichedQuery.json ||
|
|
117
|
+
enrichedQuery.customData ||
|
|
118
|
+
enrichedQuery.requestBody
|
|
119
|
+
)
|
|
120
|
+
} catch (err) {
|
|
121
|
+
// no json found, ignore
|
|
122
|
+
}
|
|
123
|
+
delete enrichedQuery.customData
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return enrichedQuery
|
|
127
|
+
}
|