@budibase/server 2.6.14 → 2.6.16-alpha.0

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/jest.config.ts CHANGED
@@ -20,9 +20,9 @@ const baseConfig: Config.InitialProjectOptions = {
20
20
  }
21
21
 
22
22
  // add pro sources if they exist
23
- if (fs.existsSync("../../../budibase-pro")) {
24
- baseConfig.moduleNameMapper["@budibase/pro"] =
25
- "<rootDir>/../../../budibase-pro/packages/pro/src"
23
+ if (fs.existsSync("../pro/packages")) {
24
+ baseConfig.moduleNameMapper!["@budibase/pro"] =
25
+ "<rootDir>/../pro/packages/pro/src"
26
26
  }
27
27
 
28
28
  const config: Config.InitialOptions = {
package/nodemon.json CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
- "watch": ["src", "../backend-core", "../../../budibase-pro/packages/pro"],
2
+ "watch": ["src", "../backend-core", "../pro/packages/pro"],
3
3
  "ext": "js,ts,json",
4
- "ignore": ["src/**/*.spec.ts", "src/**/*.spec.js", "../backend-core/dist/**/*"],
4
+ "ignore": [
5
+ "src/**/*.spec.ts",
6
+ "src/**/*.spec.js",
7
+ "../backend-core/dist/**/*"
8
+ ],
5
9
  "exec": "ts-node src/index.ts"
6
- }
10
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.6.14",
4
+ "version": "2.6.16-alpha.0",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -45,12 +45,12 @@
45
45
  "license": "GPL-3.0",
46
46
  "dependencies": {
47
47
  "@apidevtools/swagger-parser": "10.0.3",
48
- "@budibase/backend-core": "^2.6.14",
49
- "@budibase/client": "^2.6.14",
50
- "@budibase/pro": "2.6.13",
51
- "@budibase/shared-core": "^2.6.14",
52
- "@budibase/string-templates": "^2.6.14",
53
- "@budibase/types": "^2.6.14",
48
+ "@budibase/backend-core": "2.6.16-alpha.0",
49
+ "@budibase/client": "2.6.16-alpha.0",
50
+ "@budibase/pro": "2.6.16-alpha.0",
51
+ "@budibase/shared-core": "2.6.16-alpha.0",
52
+ "@budibase/string-templates": "2.6.16-alpha.0",
53
+ "@budibase/types": "2.6.16-alpha.0",
54
54
  "@bull-board/api": "3.7.0",
55
55
  "@bull-board/koa": "3.9.4",
56
56
  "@elastic/elasticsearch": "7.10.0",
@@ -176,5 +176,5 @@
176
176
  "optionalDependencies": {
177
177
  "oracledb": "5.3.0"
178
178
  },
179
- "gitHead": "c3e1ca7a2b83c899ef9a7683013ee87c49636125"
179
+ "gitHead": "f593465257b0321ebf907403b35a71a7df72d64f"
180
180
  }
@@ -26,6 +26,10 @@ export const definition: AutomationStepSchema = {
26
26
  type: AutomationIOType.STRING,
27
27
  title: "Webhook URL",
28
28
  },
29
+ body: {
30
+ type: AutomationIOType.JSON,
31
+ title: "Payload",
32
+ },
29
33
  value1: {
30
34
  type: AutomationIOType.STRING,
31
35
  title: "Input Value 1",
@@ -70,7 +74,19 @@ export const definition: AutomationStepSchema = {
70
74
  }
71
75
 
72
76
  export async function run({ inputs }: AutomationStepInput) {
73
- const { url, value1, value2, value3, value4, value5 } = inputs
77
+ //TODO - Remove deprecated values 1,2,3,4,5 after November 2023
78
+ const { url, value1, value2, value3, value4, value5, body } = inputs
79
+
80
+ let payload = {}
81
+ try {
82
+ payload = body?.value ? JSON.parse(body?.value) : {}
83
+ } catch (err) {
84
+ return {
85
+ httpStatus: 400,
86
+ response: "Invalid payload JSON",
87
+ success: false,
88
+ }
89
+ }
74
90
 
75
91
  if (!url?.trim()?.length) {
76
92
  return {
@@ -89,6 +105,7 @@ export async function run({ inputs }: AutomationStepInput) {
89
105
  value3,
90
106
  value4,
91
107
  value5,
108
+ ...payload,
92
109
  }),
93
110
  headers: {
94
111
  "Content-Type": "application/json",
@@ -24,6 +24,10 @@ export const definition: AutomationStepSchema = {
24
24
  type: AutomationIOType.STRING,
25
25
  title: "Webhook URL",
26
26
  },
27
+ body: {
28
+ type: AutomationIOType.JSON,
29
+ title: "Payload",
30
+ },
27
31
  value1: {
28
32
  type: AutomationIOType.STRING,
29
33
  title: "Payload Value 1",
@@ -63,7 +67,19 @@ export const definition: AutomationStepSchema = {
63
67
  }
64
68
 
65
69
  export async function run({ inputs }: AutomationStepInput) {
66
- const { url, value1, value2, value3, value4, value5 } = inputs
70
+ //TODO - Remove deprecated values 1,2,3,4,5 after November 2023
71
+ const { url, value1, value2, value3, value4, value5, body } = inputs
72
+
73
+ let payload = {}
74
+ try {
75
+ payload = body?.value ? JSON.parse(body?.value) : {}
76
+ } catch (err) {
77
+ return {
78
+ httpStatus: 400,
79
+ response: "Invalid payload JSON",
80
+ success: false,
81
+ }
82
+ }
67
83
 
68
84
  if (!url?.trim()?.length) {
69
85
  return {
@@ -85,6 +101,7 @@ export async function run({ inputs }: AutomationStepInput) {
85
101
  value3,
86
102
  value4,
87
103
  value5,
104
+ ...payload,
88
105
  }),
89
106
  headers: {
90
107
  "Content-Type": "application/json",
@@ -0,0 +1,54 @@
1
+ import { getConfig, afterAll, runStep, actions } from "./utilities"
2
+
3
+ describe("test the outgoing webhook action", () => {
4
+ let config = getConfig()
5
+
6
+ beforeAll(async () => {
7
+ await config.init()
8
+ })
9
+
10
+ afterAll()
11
+
12
+ it("should be able to run the action", async () => {
13
+ const res = await runStep(actions.integromat.stepId, {
14
+ value1: "test",
15
+ url: "http://www.test.com",
16
+ })
17
+ expect(res.response.url).toEqual("http://www.test.com")
18
+ expect(res.response.method).toEqual("post")
19
+ expect(res.success).toEqual(true)
20
+ })
21
+
22
+ it("should add the payload props when a JSON string is provided", async () => {
23
+ const payload = `{"value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}`
24
+ const res = await runStep(actions.integromat.stepId, {
25
+ value1: "ONE",
26
+ value2: "TWO",
27
+ value3: "THREE",
28
+ value4: "FOUR",
29
+ value5: "FIVE",
30
+ body: {
31
+ value: payload,
32
+ },
33
+ url: "http://www.test.com",
34
+ })
35
+ expect(res.response.url).toEqual("http://www.test.com")
36
+ expect(res.response.method).toEqual("post")
37
+ expect(res.response.body).toEqual(payload)
38
+ expect(res.success).toEqual(true)
39
+ })
40
+
41
+ it("should return a 400 if the JSON payload string is malformed", async () => {
42
+ const payload = `{ value1 1 }`
43
+ const res = await runStep(actions.integromat.stepId, {
44
+ value1: "ONE",
45
+ body: {
46
+ value: payload,
47
+ },
48
+ url: "http://www.test.com",
49
+ })
50
+ expect(res.httpStatus).toEqual(400)
51
+ expect(res.response).toEqual("Invalid payload JSON")
52
+ expect(res.success).toEqual(false)
53
+ })
54
+ })
@@ -0,0 +1,56 @@
1
+ import { getConfig, afterAll, runStep, actions } from "./utilities"
2
+
3
+ describe("test the outgoing webhook action", () => {
4
+ let config = getConfig()
5
+
6
+ beforeAll(async () => {
7
+ await config.init()
8
+ })
9
+
10
+ afterAll()
11
+
12
+ it("should be able to run the action", async () => {
13
+ const res = await runStep(actions.zapier.stepId, {
14
+ value1: "test",
15
+ url: "http://www.test.com",
16
+ })
17
+ expect(res.response.url).toEqual("http://www.test.com")
18
+ expect(res.response.method).toEqual("post")
19
+ expect(res.success).toEqual(true)
20
+ })
21
+
22
+ it("should add the payload props when a JSON string is provided", async () => {
23
+ const payload = `{ "value1": 1, "value2": 2, "value3": 3, "value4": 4, "value5": 5, "name": "Adam", "age": 9 }`
24
+ const res = await runStep(actions.zapier.stepId, {
25
+ value1: "ONE",
26
+ value2: "TWO",
27
+ value3: "THREE",
28
+ value4: "FOUR",
29
+ value5: "FIVE",
30
+ body: {
31
+ value: payload,
32
+ },
33
+ url: "http://www.test.com",
34
+ })
35
+ expect(res.response.url).toEqual("http://www.test.com")
36
+ expect(res.response.method).toEqual("post")
37
+ expect(res.response.body).toEqual(
38
+ `{"platform":"budibase","value1":1,"value2":2,"value3":3,"value4":4,"value5":5,"name":"Adam","age":9}`
39
+ )
40
+ expect(res.success).toEqual(true)
41
+ })
42
+
43
+ it("should return a 400 if the JSON payload string is malformed", async () => {
44
+ const payload = `{ value1 1 }`
45
+ const res = await runStep(actions.zapier.stepId, {
46
+ value1: "ONE",
47
+ body: {
48
+ value: payload,
49
+ },
50
+ url: "http://www.test.com",
51
+ })
52
+ expect(res.httpStatus).toEqual(400)
53
+ expect(res.response).toEqual("Invalid payload JSON")
54
+ expect(res.success).toEqual(false)
55
+ })
56
+ })
@@ -15,7 +15,7 @@ import {
15
15
  } from "@budibase/types"
16
16
  import { OAuth2Client } from "google-auth-library"
17
17
  import { buildExternalTableId, finaliseExternalTables } from "./utils"
18
- import { GoogleSpreadsheet } from "google-spreadsheet"
18
+ import { GoogleSpreadsheet, GoogleSpreadsheetRow } from "google-spreadsheet"
19
19
  import fetch from "node-fetch"
20
20
  import { configs, HTTPError } from "@budibase/backend-core"
21
21
  import { dataFilters } from "@budibase/shared-core"
@@ -434,7 +434,20 @@ class GoogleSheetsIntegration implements DatasourcePlus {
434
434
  try {
435
435
  await this.connect()
436
436
  const sheet = this.client.sheetsByTitle[query.sheet]
437
- const rows = await sheet.getRows()
437
+ let rows: GoogleSpreadsheetRow[] = []
438
+ if (query.paginate) {
439
+ const limit = query.paginate.limit || 100
440
+ let page: number =
441
+ typeof query.paginate.page === "number"
442
+ ? query.paginate.page
443
+ : parseInt(query.paginate.page || "1")
444
+ rows = await sheet.getRows({
445
+ limit,
446
+ offset: (page - 1) * limit,
447
+ })
448
+ } else {
449
+ rows = await sheet.getRows()
450
+ }
438
451
  const filtered = dataFilters.runLuceneQuery(rows, query.filters)
439
452
  const headerValues = sheet.headerValues
440
453
  let response = []
package/tsconfig.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "@budibase/backend-core": ["../backend-core/src"],
12
12
  "@budibase/backend-core/*": ["../backend-core/*"],
13
13
  "@budibase/shared-core": ["../shared-core/src"],
14
- "@budibase/pro": ["../../../budibase-pro/packages/pro/src"]
14
+ "@budibase/pro": ["../pro/packages/pro/src"]
15
15
  }
16
16
  },
17
17
  "ts-node": {
@@ -1,27 +0,0 @@
1
- const setup = require("./utilities")
2
- const fetch = require("node-fetch")
3
-
4
- jest.mock("node-fetch")
5
-
6
- describe("test the outgoing webhook action", () => {
7
- let inputs
8
- let config = setup.getConfig()
9
-
10
- beforeAll(async () => {
11
- await config.init()
12
- inputs = {
13
- value1: "test",
14
- url: "http://www.test.com",
15
- }
16
- })
17
-
18
- afterAll(setup.afterAll)
19
-
20
- it("should be able to run the action", async () => {
21
- const res = await setup.runStep(setup.actions.zapier.stepId, inputs)
22
- expect(res.response.url).toEqual("http://www.test.com")
23
- expect(res.response.method).toEqual("post")
24
- expect(res.success).toEqual(true)
25
- })
26
-
27
- })