@budibase/server 2.7.7-alpha.0 → 2.7.7-alpha.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@budibase/server",
3
3
  "email": "hi@budibase.com",
4
- "version": "2.7.7-alpha.0",
4
+ "version": "2.7.7-alpha.2",
5
5
  "description": "Budibase Web Server",
6
6
  "main": "src/index.ts",
7
7
  "repository": {
@@ -46,12 +46,12 @@
46
46
  "license": "GPL-3.0",
47
47
  "dependencies": {
48
48
  "@apidevtools/swagger-parser": "10.0.3",
49
- "@budibase/backend-core": "2.7.7-alpha.0",
50
- "@budibase/client": "2.7.7-alpha.0",
51
- "@budibase/pro": "2.7.7-alpha.0",
52
- "@budibase/shared-core": "2.7.7-alpha.0",
53
- "@budibase/string-templates": "2.7.7-alpha.0",
54
- "@budibase/types": "2.7.7-alpha.0",
49
+ "@budibase/backend-core": "2.7.7-alpha.2",
50
+ "@budibase/client": "2.7.7-alpha.2",
51
+ "@budibase/pro": "2.7.7-alpha.2",
52
+ "@budibase/shared-core": "2.7.7-alpha.2",
53
+ "@budibase/string-templates": "2.7.7-alpha.2",
54
+ "@budibase/types": "2.7.7-alpha.2",
55
55
  "@bull-board/api": "3.7.0",
56
56
  "@bull-board/koa": "3.9.4",
57
57
  "@elastic/elasticsearch": "7.10.0",
@@ -195,5 +195,5 @@
195
195
  }
196
196
  }
197
197
  },
198
- "gitHead": "eb71a172e7bd9fe46a6527763787441b52d634db"
198
+ "gitHead": "1ed4c86736987a6f9e912cfc37933af589102761"
199
199
  }
@@ -48,6 +48,35 @@ export const definition: AutomationStepSchema = {
48
48
  type: AutomationIOType.STRING,
49
49
  title: "HTML Contents",
50
50
  },
51
+ addInvite: {
52
+ type: AutomationIOType.BOOLEAN,
53
+ title: "Add calendar invite",
54
+ },
55
+ startTime: {
56
+ type: AutomationIOType.DATE,
57
+ title: "Start Time",
58
+ dependsOn: "addInvite",
59
+ },
60
+ endTime: {
61
+ type: AutomationIOType.DATE,
62
+ title: "End Time",
63
+ dependsOn: "addInvite",
64
+ },
65
+ summary: {
66
+ type: AutomationIOType.STRING,
67
+ title: "Meeting Summary",
68
+ dependsOn: "addInvite",
69
+ },
70
+ location: {
71
+ type: AutomationIOType.STRING,
72
+ title: "Location",
73
+ dependsOn: "addInvite",
74
+ },
75
+ url: {
76
+ type: AutomationIOType.STRING,
77
+ title: "URL",
78
+ dependsOn: "addInvite",
79
+ },
51
80
  },
52
81
  required: ["to", "from", "subject", "contents"],
53
82
  },
@@ -68,21 +97,43 @@ export const definition: AutomationStepSchema = {
68
97
  }
69
98
 
70
99
  export async function run({ inputs }: AutomationStepInput) {
71
- let { to, from, subject, contents, cc, bcc } = inputs
100
+ let {
101
+ to,
102
+ from,
103
+ subject,
104
+ contents,
105
+ cc,
106
+ bcc,
107
+ addInvite,
108
+ startTime,
109
+ endTime,
110
+ summary,
111
+ location,
112
+ url,
113
+ } = inputs
72
114
  if (!contents) {
73
115
  contents = "<h1>No content</h1>"
74
116
  }
75
117
  to = to || undefined
76
118
  try {
77
- let response = await sendSmtpEmail(
119
+ let response = await sendSmtpEmail({
78
120
  to,
79
121
  from,
80
122
  subject,
81
123
  contents,
82
124
  cc,
83
125
  bcc,
84
- true
85
- )
126
+ automation: true,
127
+ invite: addInvite
128
+ ? {
129
+ startTime,
130
+ endTime,
131
+ summary,
132
+ location,
133
+ url,
134
+ }
135
+ : undefined,
136
+ })
86
137
  return {
87
138
  success: true,
88
139
  response,
@@ -0,0 +1,74 @@
1
+ import * as workerRequests from "../../utilities/workerRequests"
2
+
3
+ jest.mock("../../utilities/workerRequests", () => ({
4
+ sendSmtpEmail: jest.fn(),
5
+ }))
6
+
7
+ function generateResponse(to: string, from: string) {
8
+ return {
9
+ success: true,
10
+ response: {
11
+ accepted: [to],
12
+ envelope: {
13
+ from: from,
14
+ to: [to],
15
+ },
16
+ message: `Email sent to ${to}.`,
17
+ },
18
+ }
19
+ }
20
+
21
+ const setup = require("./utilities")
22
+
23
+ describe("test the outgoing webhook action", () => {
24
+ let inputs
25
+ let config = setup.getConfig()
26
+ beforeAll(async () => {
27
+ await config.init()
28
+ })
29
+
30
+ afterAll(setup.afterAll)
31
+
32
+ it("should be able to run the action", async () => {
33
+ jest
34
+ .spyOn(workerRequests, "sendSmtpEmail")
35
+ .mockImplementationOnce(async () =>
36
+ generateResponse("user1@test.com", "admin@test.com")
37
+ )
38
+ const invite = {
39
+ startTime: new Date(),
40
+ endTime: new Date(),
41
+ summary: "summary",
42
+ location: "location",
43
+ url: "url",
44
+ }
45
+ inputs = {
46
+ to: "user1@test.com",
47
+ from: "admin@test.com",
48
+ subject: "hello",
49
+ contents: "testing",
50
+ cc: "cc",
51
+ bcc: "bcc",
52
+ addInvite: true,
53
+ ...invite,
54
+ }
55
+ let resp = generateResponse(inputs.to, inputs.from)
56
+ const res = await setup.runStep(
57
+ setup.actions.SEND_EMAIL_SMTP.stepId,
58
+ inputs
59
+ )
60
+ expect(res.response).toEqual(resp)
61
+ expect(res.success).toEqual(true)
62
+ expect(workerRequests.sendSmtpEmail).toHaveBeenCalledTimes(1)
63
+ expect(workerRequests.sendSmtpEmail).toHaveBeenCalledWith({
64
+ to: "user1@test.com",
65
+ from: "admin@test.com",
66
+ subject: "hello",
67
+ contents: "testing",
68
+ cc: "cc",
69
+ bcc: "bcc",
70
+ invite,
71
+ automation: true,
72
+ })
73
+ })
74
+ })
@@ -9,7 +9,7 @@ import {
9
9
  env as coreEnv,
10
10
  } from "@budibase/backend-core"
11
11
  import { updateAppRole } from "./global"
12
- import { BBContext, User } from "@budibase/types"
12
+ import { BBContext, User, EmailInvite } from "@budibase/types"
13
13
 
14
14
  export function request(ctx?: BBContext, request?: any) {
15
15
  if (!request.headers) {
@@ -65,15 +65,25 @@ async function checkResponse(
65
65
  }
66
66
 
67
67
  // have to pass in the tenant ID as this could be coming from an automation
68
- export async function sendSmtpEmail(
69
- to: string,
70
- from: string,
71
- subject: string,
72
- contents: string,
73
- cc: string,
74
- bcc: string,
68
+ export async function sendSmtpEmail({
69
+ to,
70
+ from,
71
+ subject,
72
+ contents,
73
+ cc,
74
+ bcc,
75
+ automation,
76
+ invite,
77
+ }: {
78
+ to: string
79
+ from: string
80
+ subject: string
81
+ contents: string
82
+ cc: string
83
+ bcc: string
75
84
  automation: boolean
76
- ) {
85
+ invite?: EmailInvite
86
+ }) {
77
87
  // tenant ID will be set in header
78
88
  const response = await fetch(
79
89
  checkSlashesInUrl(env.WORKER_URL + `/api/global/email/send`),
@@ -88,6 +98,7 @@ export async function sendSmtpEmail(
88
98
  bcc,
89
99
  purpose: "custom",
90
100
  automation,
101
+ invite,
91
102
  },
92
103
  })
93
104
  )
@@ -1,71 +0,0 @@
1
-
2
- function generateResponse(to, from) {
3
- return {
4
- "success": true,
5
- "response": {
6
- "accepted": [
7
- to
8
- ],
9
- "envelope": {
10
- "from": from,
11
- "to": [
12
- to
13
- ]
14
- },
15
- "message": `Email sent to ${to}.`
16
- }
17
-
18
- }
19
- }
20
-
21
- const mockFetch = jest.fn(() => ({
22
- headers: {
23
- raw: () => {
24
- return { "content-type": ["application/json"] }
25
- },
26
- get: () => ["application/json"],
27
- },
28
- json: jest.fn(() => response),
29
- status: 200,
30
- text: jest.fn(),
31
- }))
32
- jest.mock("node-fetch", () => mockFetch)
33
- const setup = require("./utilities")
34
-
35
-
36
- describe("test the outgoing webhook action", () => {
37
- let inputs
38
- let config = setup.getConfig()
39
- beforeAll(async () => {
40
- await config.init()
41
- })
42
-
43
- afterAll(setup.afterAll)
44
-
45
- it("should be able to run the action", async () => {
46
- inputs = {
47
- to: "user1@test.com",
48
- from: "admin@test.com",
49
- subject: "hello",
50
- contents: "testing",
51
- }
52
- let resp = generateResponse(inputs.to, inputs.from)
53
- mockFetch.mockImplementationOnce(() => ({
54
- headers: {
55
- raw: () => {
56
- return { "content-type": ["application/json"] }
57
- },
58
- get: () => ["application/json"],
59
- },
60
- json: jest.fn(() => resp),
61
- status: 200,
62
- text: jest.fn(),
63
- }))
64
- const res = await setup.runStep(setup.actions.SEND_EMAIL_SMTP.stepId, inputs)
65
- expect(res.response).toEqual(resp)
66
- expect(res.success).toEqual(true)
67
-
68
- })
69
-
70
-
71
- })