@budibase/server 2.5.6-alpha.9 → 2.5.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/builder/assets/index.56bca6f6.js +1817 -0
- package/builder/assets/index.7f9a008b.css +6 -0
- package/builder/index.html +2 -2
- package/dist/api/controllers/automation.js +7 -13
- package/dist/api/controllers/plugin/index.js +37 -6
- package/dist/api/controllers/table/utils.js +1 -2
- package/dist/api/controllers/user.js +83 -1
- package/dist/api/routes/index.js +0 -2
- package/dist/api/routes/user.js +1 -0
- package/dist/app.js +13 -4
- package/dist/automations/actions.js +6 -32
- package/dist/automations/index.js +2 -3
- package/dist/automations/steps/bash.js +6 -6
- package/dist/automations/steps/createRow.js +11 -11
- package/dist/automations/steps/delay.js +3 -3
- package/dist/automations/steps/deleteRow.js +8 -8
- package/dist/automations/steps/discord.js +8 -8
- package/dist/automations/steps/executeQuery.js +9 -9
- package/dist/automations/steps/executeScript.js +6 -6
- package/dist/automations/steps/filter.js +6 -6
- package/dist/automations/steps/integromat.js +10 -10
- package/dist/automations/steps/loop.js +9 -9
- package/dist/automations/steps/outgoingWebhook.js +10 -10
- package/dist/automations/steps/queryRows.js +14 -14
- package/dist/automations/steps/sendSmtpEmail.js +9 -9
- package/dist/automations/steps/serverLog.js +4 -4
- package/dist/automations/steps/slack.js +6 -6
- package/dist/automations/steps/updateRow.js +11 -11
- package/dist/automations/steps/zapier.js +9 -9
- package/dist/automations/triggerInfo/app.js +5 -5
- package/dist/automations/triggerInfo/cron.js +4 -4
- package/dist/automations/triggerInfo/rowDeleted.js +5 -5
- package/dist/automations/triggerInfo/rowSaved.js +7 -7
- package/dist/automations/triggerInfo/rowUpdated.js +7 -7
- package/dist/automations/triggerInfo/webhook.js +6 -6
- package/dist/elasticApm.js +14 -0
- package/dist/environment.js +1 -0
- package/dist/events/index.js +0 -3
- package/dist/integrations/index.js +3 -3
- package/dist/integrations/microsoftSqlServer.js +2 -5
- package/dist/integrations/mysql.js +3 -5
- package/dist/integrations/postgres.js +5 -7
- package/dist/integrations/redis.js +0 -7
- package/dist/integrations/rest.js +0 -4
- package/dist/migrations/functions/usageQuotas/syncApps.js +1 -1
- package/dist/migrations/functions/usageQuotas/syncRows.js +2 -1
- package/dist/package.json +15 -15
- package/dist/sdk/app/applications/sync.js +23 -117
- package/dist/sdk/index.js +0 -2
- package/dist/sdk/users/utils.js +4 -21
- package/dist/startup.js +28 -31
- package/dist/threads/automation.js +5 -16
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/plugin.js +23 -33
- package/dist/utilities/global.js +12 -17
- package/dist/watch.js +2 -2
- package/dist/websocket.js +22 -0
- package/jest.config.ts +3 -3
- package/nodemon.json +3 -7
- package/package.json +16 -16
- package/scripts/dev/manage.js +0 -2
- package/scripts/integrations/mssql/data/entrypoint.sh +0 -1
- package/scripts/integrations/mssql/data/setup.sql +17 -17
- package/scripts/integrations/mysql/init.sql +1 -1
- package/scripts/integrations/postgres/init.sql +0 -1
- package/scripts/likeCypress.ts +35 -0
- package/src/api/controllers/automation.ts +6 -12
- package/src/api/controllers/plugin/index.ts +45 -8
- package/src/api/controllers/row/internal.ts +10 -9
- package/src/api/controllers/row/utils.ts +2 -2
- package/src/api/controllers/table/utils.ts +1 -2
- package/src/api/controllers/user.ts +96 -10
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/tests/automation.spec.js +4 -7
- package/src/api/routes/tests/user.spec.js +37 -48
- package/src/api/routes/user.ts +5 -0
- package/src/app.ts +15 -4
- package/src/automations/actions.ts +24 -56
- package/src/automations/index.ts +1 -1
- package/src/automations/steps/bash.ts +7 -10
- package/src/automations/steps/createRow.ts +12 -15
- package/src/automations/steps/delay.ts +4 -6
- package/src/automations/steps/deleteRow.ts +9 -12
- package/src/automations/steps/discord.ts +8 -10
- package/src/automations/steps/executeQuery.ts +10 -13
- package/src/automations/steps/executeScript.ts +7 -10
- package/src/automations/steps/filter.ts +6 -8
- package/src/automations/steps/integromat.ts +10 -12
- package/src/automations/steps/loop.ts +10 -16
- package/src/automations/steps/outgoingWebhook.ts +11 -14
- package/src/automations/steps/queryRows.ts +15 -18
- package/src/automations/steps/sendSmtpEmail.ts +9 -11
- package/src/automations/steps/serverLog.ts +4 -6
- package/src/automations/steps/slack.ts +6 -8
- package/src/automations/steps/updateRow.ts +12 -15
- package/src/automations/steps/zapier.ts +9 -11
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/triggerInfo/app.ts +5 -8
- package/src/automations/triggerInfo/cron.ts +4 -7
- package/src/automations/triggerInfo/rowDeleted.ts +5 -8
- package/src/automations/triggerInfo/rowSaved.ts +7 -10
- package/src/automations/triggerInfo/rowUpdated.ts +7 -10
- package/src/automations/triggerInfo/webhook.ts +6 -9
- package/src/elasticApm.ts +10 -0
- package/src/environment.ts +1 -0
- package/src/events/index.ts +0 -1
- package/src/integrations/index.ts +3 -3
- package/src/integrations/microsoftSqlServer.ts +2 -5
- package/src/integrations/mysql.ts +3 -5
- package/src/integrations/postgres.ts +5 -7
- package/src/integrations/redis.ts +0 -8
- package/src/integrations/rest.ts +0 -3
- package/src/migrations/functions/usageQuotas/syncApps.ts +1 -1
- package/src/migrations/functions/usageQuotas/syncRows.ts +3 -2
- package/src/migrations/functions/usageQuotas/tests/syncRows.spec.ts +2 -2
- package/src/sdk/app/applications/sync.ts +22 -129
- package/src/sdk/index.ts +0 -2
- package/src/sdk/users/tests/utils.spec.ts +32 -1
- package/src/sdk/users/utils.ts +5 -23
- package/src/startup.ts +34 -36
- package/src/tests/jestEnv.ts +1 -0
- package/src/tests/jestSetup.ts +1 -0
- package/src/tests/logging.ts +34 -0
- package/src/tests/utilities/TestConfiguration.ts +0 -28
- package/src/tests/utilities/structures.ts +17 -25
- package/src/threads/automation.ts +6 -18
- package/src/utilities/fileSystem/plugin.ts +4 -13
- package/src/utilities/global.ts +16 -21
- package/src/watch.ts +2 -2
- package/src/websocket.ts +26 -0
- package/tsconfig.json +7 -1
- package/builder/assets/index.5c1a6913.js +0 -1776
- package/builder/assets/index.c0265b74.css +0 -6
- package/dist/api/controllers/ops.js +0 -40
- package/dist/api/routes/ops.js +0 -52
- package/dist/events/docUpdates/index.js +0 -17
- package/dist/events/docUpdates/processors.js +0 -18
- package/dist/events/docUpdates/syncUsers.js +0 -49
- package/dist/sdk/plugins/index.js +0 -27
- package/dist/sdk/plugins/plugins.js +0 -53
- package/dist/websockets/client.js +0 -14
- package/dist/websockets/grid.js +0 -60
- package/dist/websockets/index.js +0 -17
- package/dist/websockets/websocket.js +0 -78
- package/src/api/controllers/ops.ts +0 -32
- package/src/api/routes/ops.ts +0 -30
- package/src/events/docUpdates/index.ts +0 -1
- package/src/events/docUpdates/processors.ts +0 -14
- package/src/events/docUpdates/syncUsers.ts +0 -35
- package/src/sdk/app/applications/tests/sync.spec.ts +0 -137
- package/src/sdk/plugins/index.ts +0 -5
- package/src/sdk/plugins/plugins.ts +0 -41
- package/src/websockets/client.ts +0 -11
- package/src/websockets/grid.ts +0 -55
- package/src/websockets/index.ts +0 -14
- package/src/websockets/websocket.ts +0 -83
|
@@ -27,15 +27,15 @@ import { processObject } from "@budibase/string-templates"
|
|
|
27
27
|
import { cloneDeep } from "lodash/fp"
|
|
28
28
|
import * as sdkUtils from "../sdk/utils"
|
|
29
29
|
import env from "../environment"
|
|
30
|
-
const FILTER_STEP_ID = actions.
|
|
31
|
-
const LOOP_STEP_ID = actions.
|
|
30
|
+
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
|
|
31
|
+
const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId
|
|
32
32
|
const CRON_STEP_ID = triggerDefs.CRON.stepId
|
|
33
33
|
const STOPPED_STATUS = { success: true, status: AutomationStatus.STOPPED }
|
|
34
34
|
|
|
35
35
|
function getLoopIterations(loopStep: LoopStep, input: LoopInput) {
|
|
36
36
|
const binding = automationUtils.typecastForLooping(loopStep, input)
|
|
37
|
-
if (!binding) {
|
|
38
|
-
return
|
|
37
|
+
if (!loopStep || !binding) {
|
|
38
|
+
return 1
|
|
39
39
|
}
|
|
40
40
|
if (Array.isArray(binding)) {
|
|
41
41
|
return binding.length
|
|
@@ -43,7 +43,7 @@ function getLoopIterations(loopStep: LoopStep, input: LoopInput) {
|
|
|
43
43
|
if (typeof binding === "string") {
|
|
44
44
|
return automationUtils.stringSplit(binding).length
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return 1
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -423,25 +423,13 @@ class Orchestrator {
|
|
|
423
423
|
}
|
|
424
424
|
}
|
|
425
425
|
|
|
426
|
-
if (loopStep && iterations === 0) {
|
|
427
|
-
loopStep = undefined
|
|
428
|
-
this.executionOutput.steps.splice(loopStepNumber + 1, 0, {
|
|
429
|
-
id: step.id,
|
|
430
|
-
stepId: step.stepId,
|
|
431
|
-
outputs: { status: AutomationStatus.NO_ITERATIONS, success: true },
|
|
432
|
-
inputs: {},
|
|
433
|
-
})
|
|
434
|
-
|
|
435
|
-
this._context.steps.splice(loopStepNumber, 1)
|
|
436
|
-
iterations = 1
|
|
437
|
-
}
|
|
438
|
-
|
|
439
426
|
// Delete the step after the loop step as it's irrelevant, since information is included
|
|
440
427
|
// in the loop step
|
|
441
428
|
if (wasLoopStep && !loopStep) {
|
|
442
429
|
this._context.steps.splice(loopStepNumber + 1, 1)
|
|
443
430
|
wasLoopStep = false
|
|
444
431
|
}
|
|
432
|
+
|
|
445
433
|
if (loopSteps && loopSteps.length) {
|
|
446
434
|
let tempOutput = {
|
|
447
435
|
success: true,
|
|
@@ -5,7 +5,6 @@ import { join } from "path"
|
|
|
5
5
|
import { objectStore } from "@budibase/backend-core"
|
|
6
6
|
|
|
7
7
|
const DATASOURCE_PATH = join(budibaseTempDir(), "datasource")
|
|
8
|
-
const AUTOMATION_PATH = join(budibaseTempDir(), "automation")
|
|
9
8
|
|
|
10
9
|
export const getPluginMetadata = async (path: string) => {
|
|
11
10
|
let metadata: any = {}
|
|
@@ -34,12 +33,12 @@ export const getPluginMetadata = async (path: string) => {
|
|
|
34
33
|
return { metadata, directory: path }
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
|
|
36
|
+
export const getDatasourcePlugin = async (plugin: Plugin) => {
|
|
38
37
|
const hash = plugin.schema?.hash
|
|
39
|
-
if (!fs.existsSync(
|
|
40
|
-
fs.mkdirSync(
|
|
38
|
+
if (!fs.existsSync(DATASOURCE_PATH)) {
|
|
39
|
+
fs.mkdirSync(DATASOURCE_PATH)
|
|
41
40
|
}
|
|
42
|
-
const filename = join(
|
|
41
|
+
const filename = join(DATASOURCE_PATH, plugin.name)
|
|
43
42
|
const metadataName = `${filename}.bbmetadata`
|
|
44
43
|
if (fs.existsSync(filename)) {
|
|
45
44
|
const currentHash = fs.readFileSync(metadataName, "utf8")
|
|
@@ -63,11 +62,3 @@ async function getPluginImpl(path: string, plugin: Plugin) {
|
|
|
63
62
|
|
|
64
63
|
return require(filename)
|
|
65
64
|
}
|
|
66
|
-
|
|
67
|
-
export const getDatasourcePlugin = async (plugin: Plugin) => {
|
|
68
|
-
return getPluginImpl(DATASOURCE_PATH, plugin)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export const getAutomationPlugin = async (plugin: Plugin) => {
|
|
72
|
-
return getPluginImpl(AUTOMATION_PATH, plugin)
|
|
73
|
-
}
|
package/src/utilities/global.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
import env from "../environment"
|
|
10
10
|
import { groups } from "@budibase/pro"
|
|
11
11
|
import { UserCtx, ContextUser, User, UserGroup } from "@budibase/types"
|
|
12
|
-
import { global } from "yargs"
|
|
13
12
|
|
|
14
13
|
export function updateAppRole(
|
|
15
14
|
user: ContextUser,
|
|
@@ -17,7 +16,7 @@ export function updateAppRole(
|
|
|
17
16
|
) {
|
|
18
17
|
appId = appId || context.getAppId()
|
|
19
18
|
|
|
20
|
-
if (!user ||
|
|
19
|
+
if (!user || !user.roles) {
|
|
21
20
|
return user
|
|
22
21
|
}
|
|
23
22
|
// if in an multi-tenancy environment make sure roles are never updated
|
|
@@ -28,7 +27,7 @@ export function updateAppRole(
|
|
|
28
27
|
return user
|
|
29
28
|
}
|
|
30
29
|
// always use the deployed app
|
|
31
|
-
if (appId
|
|
30
|
+
if (appId) {
|
|
32
31
|
user.roleId = user.roles[dbCore.getProdAppID(appId)]
|
|
33
32
|
}
|
|
34
33
|
// if a role wasn't found then either set as admin (builder) or public (everyone else)
|
|
@@ -61,7 +60,7 @@ async function checkGroupRoles(
|
|
|
61
60
|
return user
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
|
|
63
|
+
async function processUser(
|
|
65
64
|
user: ContextUser,
|
|
66
65
|
opts: { appId?: string; groups?: UserGroup[] } = {}
|
|
67
66
|
) {
|
|
@@ -95,15 +94,16 @@ export async function getGlobalUser(userId: string) {
|
|
|
95
94
|
return processUser(user, { appId })
|
|
96
95
|
}
|
|
97
96
|
|
|
98
|
-
export async function getGlobalUsers(
|
|
99
|
-
userIds?: string[],
|
|
100
|
-
opts?: { noProcessing?: boolean }
|
|
101
|
-
) {
|
|
97
|
+
export async function getGlobalUsers(users?: ContextUser[]) {
|
|
102
98
|
const appId = context.getAppId()
|
|
103
99
|
const db = tenancy.getGlobalDB()
|
|
100
|
+
const allGroups = await groups.fetch()
|
|
104
101
|
let globalUsers
|
|
105
|
-
if (
|
|
106
|
-
|
|
102
|
+
if (users) {
|
|
103
|
+
const globalIds = users.map(user =>
|
|
104
|
+
getGlobalIDFromUserMetadataID(user._id!)
|
|
105
|
+
)
|
|
106
|
+
globalUsers = (await db.allDocs(getMultiIDParams(globalIds))).rows.map(
|
|
107
107
|
row => row.doc
|
|
108
108
|
)
|
|
109
109
|
} else {
|
|
@@ -126,20 +126,15 @@ export async function getGlobalUsers(
|
|
|
126
126
|
return globalUsers
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const allGroups = await groups.fetch()
|
|
135
|
-
return Promise.all(
|
|
136
|
-
globalUsers.map(user => processUser(user, { groups: allGroups }))
|
|
137
|
-
)
|
|
138
|
-
}
|
|
129
|
+
// pass in the groups, meaning we don't actually need to retrieve them for
|
|
130
|
+
// each user individually
|
|
131
|
+
return Promise.all(
|
|
132
|
+
globalUsers.map(user => processUser(user, { groups: allGroups }))
|
|
133
|
+
)
|
|
139
134
|
}
|
|
140
135
|
|
|
141
136
|
export async function getGlobalUsersFromMetadata(users: ContextUser[]) {
|
|
142
|
-
const globalUsers = await getGlobalUsers(users
|
|
137
|
+
const globalUsers = await getGlobalUsers(users)
|
|
143
138
|
return users.map(user => {
|
|
144
139
|
const globalUser = globalUsers.find(
|
|
145
140
|
globalUser => globalUser && user._id?.includes(globalUser._id)
|
package/src/watch.ts
CHANGED
|
@@ -3,7 +3,7 @@ import env from "./environment"
|
|
|
3
3
|
import chokidar from "chokidar"
|
|
4
4
|
import fs from "fs"
|
|
5
5
|
import { constants, tenancy } from "@budibase/backend-core"
|
|
6
|
-
import
|
|
6
|
+
import { processUploadedPlugin } from "./api/controllers/plugin"
|
|
7
7
|
|
|
8
8
|
export function watch() {
|
|
9
9
|
const watchPath = path.join(env.PLUGINS_DIR, "./**/*.tar.gz")
|
|
@@ -27,7 +27,7 @@ export function watch() {
|
|
|
27
27
|
const split = path.split("/")
|
|
28
28
|
const name = split[split.length - 1]
|
|
29
29
|
console.log("Importing plugin:", path)
|
|
30
|
-
await
|
|
30
|
+
await processUploadedPlugin({ name, path })
|
|
31
31
|
} catch (err: any) {
|
|
32
32
|
const message = err?.message ? err?.message : err
|
|
33
33
|
console.error("Failed to import plugin:", message)
|
package/src/websocket.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Server } from "socket.io"
|
|
2
|
+
import http from "http"
|
|
3
|
+
|
|
4
|
+
class Websocket {
|
|
5
|
+
socketServer: Server
|
|
6
|
+
|
|
7
|
+
constructor(server: http.Server, path: string) {
|
|
8
|
+
this.socketServer = new Server(server, {
|
|
9
|
+
path,
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Emit an event to all sockets
|
|
14
|
+
emit(event: string, payload: any) {
|
|
15
|
+
this.socketServer.sockets.emit(event, payload)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Likely to be more socket instances in future
|
|
20
|
+
let ClientAppSocket: Websocket
|
|
21
|
+
|
|
22
|
+
export const initialise = (server: http.Server) => {
|
|
23
|
+
ClientAppSocket = new Websocket(server, "/socket/client")
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { ClientAppSocket }
|
package/tsconfig.json
CHANGED
|
@@ -10,13 +10,19 @@
|
|
|
10
10
|
"@budibase/backend-core": ["../backend-core/src"],
|
|
11
11
|
"@budibase/backend-core/*": ["../backend-core/*"],
|
|
12
12
|
"@budibase/shared-core": ["../shared-core/src"],
|
|
13
|
-
"@budibase/pro": ["
|
|
13
|
+
"@budibase/pro": ["../../../budibase-pro/packages/pro/src"]
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
16
|
"ts-node": {
|
|
17
17
|
"require": ["tsconfig-paths/register"],
|
|
18
18
|
"swc": true
|
|
19
19
|
},
|
|
20
|
+
"references": [
|
|
21
|
+
{ "path": "../types" },
|
|
22
|
+
{ "path": "../backend-core" },
|
|
23
|
+
{ "path": "../shared-core" },
|
|
24
|
+
{ "path": "../../../budibase-pro/packages/pro" }
|
|
25
|
+
],
|
|
20
26
|
"include": ["src/**/*", "specs", "package.json"],
|
|
21
27
|
"exclude": ["node_modules", "dist"]
|
|
22
28
|
}
|