@budibase/server 2.5.6-alpha.3 → 2.5.6-alpha.31
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.a33a6c3d.js → index.39cfdb4b.js} +382 -366
- package/builder/assets/index.44a18341.css +6 -0
- package/builder/index.html +2 -2
- package/dist/api/controllers/application.js +2 -3
- package/dist/api/controllers/automation.js +13 -7
- package/dist/api/controllers/dev.js +1 -1
- package/dist/api/controllers/plugin/index.js +6 -37
- package/dist/api/controllers/query/index.js +2 -2
- package/dist/api/controllers/row/ExternalRequest.js +21 -14
- package/dist/api/controllers/table/utils.js +9 -3
- package/dist/api/index.js +1 -2
- package/dist/api/routes/index.js +0 -2
- package/dist/app.js +2 -2
- package/dist/automations/actions.js +32 -6
- package/dist/automations/index.js +3 -2
- 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/integrations/base/sqlTable.js +9 -2
- package/dist/integrations/index.js +3 -3
- package/dist/migrations/functions/syncQuotas.js +2 -0
- package/dist/migrations/functions/usageQuotas/syncApps.js +0 -1
- package/dist/migrations/functions/usageQuotas/syncUsers.js +21 -0
- package/dist/sdk/app/backups/exports.js +1 -35
- package/dist/sdk/index.js +2 -0
- package/dist/{api/routes/cloud.js → sdk/plugins/index.js} +2 -14
- package/dist/sdk/plugins/plugins.js +53 -0
- package/dist/threads/automation.js +2 -2
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utilities/fileSystem/plugin.js +33 -23
- package/dist/utilities/rowProcessor/utils.js +4 -5
- package/dist/watch.js +2 -2
- package/dist/websockets/client.js +14 -0
- package/dist/websockets/grid.js +60 -0
- package/dist/websockets/index.js +17 -0
- package/dist/websockets/websocket.js +78 -0
- package/package.json +11 -10
- package/src/api/controllers/application.ts +3 -3
- package/src/api/controllers/automation.ts +12 -6
- package/src/api/controllers/dev.ts +2 -2
- package/src/api/controllers/plugin/index.ts +8 -45
- package/src/api/controllers/query/index.ts +2 -2
- package/src/api/controllers/row/ExternalRequest.ts +21 -12
- package/src/api/controllers/table/utils.ts +10 -3
- package/src/api/index.ts +2 -4
- package/src/api/routes/index.ts +0 -2
- package/src/api/routes/tests/automation.spec.js +2 -2
- package/src/app.ts +2 -2
- package/src/automations/actions.ts +56 -24
- package/src/automations/index.ts +1 -1
- package/src/automations/steps/bash.ts +10 -7
- package/src/automations/steps/createRow.ts +15 -12
- package/src/automations/steps/delay.ts +6 -4
- package/src/automations/steps/deleteRow.ts +12 -9
- package/src/automations/steps/discord.ts +10 -8
- package/src/automations/steps/executeQuery.ts +13 -10
- package/src/automations/steps/executeScript.ts +10 -7
- package/src/automations/steps/filter.ts +8 -6
- package/src/automations/steps/integromat.ts +12 -10
- package/src/automations/steps/loop.ts +16 -10
- package/src/automations/steps/outgoingWebhook.ts +14 -11
- package/src/automations/steps/queryRows.ts +18 -15
- package/src/automations/steps/sendSmtpEmail.ts +11 -9
- package/src/automations/steps/serverLog.ts +6 -4
- package/src/automations/steps/slack.ts +8 -6
- package/src/automations/steps/updateRow.ts +15 -12
- package/src/automations/steps/zapier.ts +11 -9
- package/src/automations/tests/utilities/index.ts +2 -2
- package/src/automations/triggerInfo/app.ts +8 -5
- package/src/automations/triggerInfo/cron.ts +7 -4
- package/src/automations/triggerInfo/rowDeleted.ts +8 -5
- package/src/automations/triggerInfo/rowSaved.ts +10 -7
- package/src/automations/triggerInfo/rowUpdated.ts +10 -7
- package/src/automations/triggerInfo/webhook.ts +9 -6
- package/src/integration-test/postgres.spec.ts +2 -0
- package/src/integrations/base/sqlTable.ts +9 -2
- package/src/integrations/index.ts +3 -3
- package/src/migrations/functions/syncQuotas.ts +2 -0
- package/src/migrations/functions/usageQuotas/syncApps.ts +1 -2
- package/src/migrations/functions/usageQuotas/syncUsers.ts +9 -0
- package/src/migrations/functions/usageQuotas/tests/syncUsers.spec.ts +26 -0
- package/src/migrations/index.ts +1 -0
- package/src/sdk/app/backups/exports.ts +0 -35
- package/src/sdk/index.ts +2 -0
- package/src/sdk/plugins/index.ts +5 -0
- package/src/sdk/plugins/plugins.ts +41 -0
- package/src/tests/utilities/structures.ts +25 -17
- package/src/threads/automation.ts +2 -2
- package/src/utilities/fileSystem/plugin.ts +13 -4
- package/src/utilities/rowProcessor/utils.ts +9 -10
- package/src/watch.ts +2 -2
- package/src/websockets/client.ts +11 -0
- package/src/websockets/grid.ts +55 -0
- package/src/websockets/index.ts +14 -0
- package/src/websockets/websocket.ts +83 -0
- package/tsconfig.build.json +3 -5
- package/tsconfig.json +2 -1
- package/builder/assets/index.841e62d8.css +0 -6
- package/dist/api/controllers/cloud.js +0 -130
- package/dist/package.json +0 -179
- package/dist/websocket.js +0 -22
- package/src/api/controllers/cloud.ts +0 -119
- package/src/api/routes/cloud.ts +0 -18
- package/src/api/routes/tests/cloud.spec.ts +0 -54
- package/src/migrations/functions/tests/syncQuotas.spec.js +0 -26
- package/src/websocket.ts +0 -26
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import authorized from "../middleware/authorized"
|
|
2
|
+
import Socket from "./websocket"
|
|
3
|
+
import { permissions } from "@budibase/backend-core"
|
|
4
|
+
import http from "http"
|
|
5
|
+
import Koa from "koa"
|
|
6
|
+
|
|
7
|
+
export default class GridSocket extends Socket {
|
|
8
|
+
constructor(app: Koa, server: http.Server) {
|
|
9
|
+
super(app, server, "/socket/grid", [authorized(permissions.BUILDER)])
|
|
10
|
+
|
|
11
|
+
this.io.on("connection", socket => {
|
|
12
|
+
const user = socket.data.user
|
|
13
|
+
console.log(`Spreadsheet user connected: ${user?.id}`)
|
|
14
|
+
|
|
15
|
+
// Socket state
|
|
16
|
+
let currentRoom: string
|
|
17
|
+
|
|
18
|
+
// Initial identification of connected spreadsheet
|
|
19
|
+
socket.on("select-table", async (tableId, callback) => {
|
|
20
|
+
// Leave current room
|
|
21
|
+
if (currentRoom) {
|
|
22
|
+
socket.to(currentRoom).emit("user-disconnect", socket.data.user)
|
|
23
|
+
socket.leave(currentRoom)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Join new room
|
|
27
|
+
currentRoom = tableId
|
|
28
|
+
socket.join(currentRoom)
|
|
29
|
+
socket.to(currentRoom).emit("user-update", socket.data.user)
|
|
30
|
+
|
|
31
|
+
// Reply with all users in current room
|
|
32
|
+
const sockets = await this.io.in(currentRoom).fetchSockets()
|
|
33
|
+
callback({
|
|
34
|
+
users: sockets.map(socket => socket.data.user),
|
|
35
|
+
id: user.id,
|
|
36
|
+
})
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
// Handle users selecting a new cell
|
|
40
|
+
socket.on("select-cell", cellId => {
|
|
41
|
+
socket.data.user.selectedCellId = cellId
|
|
42
|
+
if (currentRoom) {
|
|
43
|
+
socket.to(currentRoom).emit("user-update", socket.data.user)
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Disconnection cleanup
|
|
48
|
+
socket.on("disconnect", () => {
|
|
49
|
+
if (currentRoom) {
|
|
50
|
+
socket.to(currentRoom).emit("user-disconnect", socket.data.user)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import http from "http"
|
|
2
|
+
import Koa from "koa"
|
|
3
|
+
import GridSocket from "./grid"
|
|
4
|
+
import ClientAppSocket from "./client"
|
|
5
|
+
|
|
6
|
+
let clientAppSocket: ClientAppSocket
|
|
7
|
+
let gridSocket: GridSocket
|
|
8
|
+
|
|
9
|
+
export const initialise = (app: Koa, server: http.Server) => {
|
|
10
|
+
clientAppSocket = new ClientAppSocket(app, server)
|
|
11
|
+
gridSocket = new GridSocket(app, server)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { clientAppSocket, gridSocket }
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Server } from "socket.io"
|
|
2
|
+
import http from "http"
|
|
3
|
+
import Koa from "koa"
|
|
4
|
+
import Cookies from "cookies"
|
|
5
|
+
import { userAgent } from "koa-useragent"
|
|
6
|
+
import { auth } from "@budibase/backend-core"
|
|
7
|
+
import currentApp from "../middleware/currentapp"
|
|
8
|
+
|
|
9
|
+
export default class Socket {
|
|
10
|
+
io: Server
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
app: Koa,
|
|
14
|
+
server: http.Server,
|
|
15
|
+
path: string,
|
|
16
|
+
additionalMiddlewares?: any[]
|
|
17
|
+
) {
|
|
18
|
+
this.io = new Server(server, {
|
|
19
|
+
path,
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
// Attach default middlewares
|
|
23
|
+
const authenticate = auth.buildAuthMiddleware([], {
|
|
24
|
+
publicAllowed: true,
|
|
25
|
+
})
|
|
26
|
+
const middlewares = [
|
|
27
|
+
userAgent,
|
|
28
|
+
authenticate,
|
|
29
|
+
currentApp,
|
|
30
|
+
...(additionalMiddlewares || []),
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
// Apply middlewares
|
|
34
|
+
this.io.use(async (socket, next) => {
|
|
35
|
+
// Build fake koa context
|
|
36
|
+
const res = new http.ServerResponse(socket.request)
|
|
37
|
+
const ctx: any = {
|
|
38
|
+
...app.createContext(socket.request, res),
|
|
39
|
+
|
|
40
|
+
// Additional overrides needed to make our middlewares work with this
|
|
41
|
+
// fake koa context
|
|
42
|
+
cookies: new Cookies(socket.request, res),
|
|
43
|
+
get: (field: string) => socket.request.headers[field],
|
|
44
|
+
throw: (code: number, message: string) => {
|
|
45
|
+
throw new Error(message)
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
// Needed for koa-useragent middleware
|
|
49
|
+
headers: socket.request.headers,
|
|
50
|
+
header: socket.request.headers,
|
|
51
|
+
|
|
52
|
+
// We don't really care about the path since it will never contain
|
|
53
|
+
// an app ID
|
|
54
|
+
path: "/socket",
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Run all koa middlewares
|
|
58
|
+
try {
|
|
59
|
+
for (let [idx, middleware] of middlewares.entries()) {
|
|
60
|
+
await middleware(ctx, () => {
|
|
61
|
+
if (idx === middlewares.length - 1) {
|
|
62
|
+
// Middlewares are finished.
|
|
63
|
+
// Extract some data from our enriched koa context to persist
|
|
64
|
+
// as metadata for the socket
|
|
65
|
+
socket.data.user = {
|
|
66
|
+
id: ctx.user._id,
|
|
67
|
+
email: ctx.user.email,
|
|
68
|
+
}
|
|
69
|
+
next()
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
} catch (error: any) {
|
|
74
|
+
next(error)
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Emit an event to all sockets
|
|
80
|
+
emit(event: string, payload: any) {
|
|
81
|
+
this.io.sockets.emit(event, payload)
|
|
82
|
+
}
|
|
83
|
+
}
|
package/tsconfig.build.json
CHANGED
|
@@ -8,13 +8,11 @@
|
|
|
8
8
|
"esModuleInterop": true,
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"incremental": true,
|
|
11
|
-
"types": [
|
|
12
|
-
"outDir": "dist",
|
|
11
|
+
"types": ["node", "jest"],
|
|
12
|
+
"outDir": "dist/src",
|
|
13
13
|
"skipLibCheck": true
|
|
14
14
|
},
|
|
15
|
-
"include": [
|
|
16
|
-
"src/**/*"
|
|
17
|
-
],
|
|
15
|
+
"include": ["src/**/*"],
|
|
18
16
|
"exclude": [
|
|
19
17
|
"node_modules",
|
|
20
18
|
"dist",
|
package/tsconfig.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"declaration": true,
|
|
6
6
|
"sourceMap": true,
|
|
7
7
|
"baseUrl": ".",
|
|
8
|
+
"outDir": "dist",
|
|
8
9
|
"paths": {
|
|
9
10
|
"@budibase/types": ["../types/src"],
|
|
10
11
|
"@budibase/backend-core": ["../backend-core/src"],
|
|
@@ -23,6 +24,6 @@
|
|
|
23
24
|
{ "path": "../shared-core" },
|
|
24
25
|
{ "path": "../../../budibase-pro/packages/pro" }
|
|
25
26
|
],
|
|
26
|
-
"include": ["src/**/*", "specs"
|
|
27
|
+
"include": ["src/**/*", "specs"],
|
|
27
28
|
"exclude": ["node_modules", "dist"]
|
|
28
29
|
}
|