Merge branches 'budi-9055-provide-a-filtering-option-for-a-relationships-_id-when' and 'master' of github.com:budibase/budibase into budi-9055-provide-a-filtering-option-for-a-relationships-_id-when
This commit is contained in:
commit
b5886a7d9b
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
|
||||||
"version": "3.4.16",
|
"version": "3.4.17",
|
||||||
"npmClient": "yarn",
|
"npmClient": "yarn",
|
||||||
"concurrency": 20,
|
"concurrency": 20,
|
||||||
"command": {
|
"command": {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { SendEmailResponse } from "@budibase/types"
|
||||||
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
import TestConfiguration from "../../../tests/utilities/TestConfiguration"
|
||||||
import * as workerRequests from "../../../utilities/workerRequests"
|
import * as workerRequests from "../../../utilities/workerRequests"
|
||||||
|
|
||||||
|
@ -5,17 +6,18 @@ jest.mock("../../../utilities/workerRequests", () => ({
|
||||||
sendSmtpEmail: jest.fn(),
|
sendSmtpEmail: jest.fn(),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
function generateResponse(to: string, from: string) {
|
function generateResponse(to: string, from: string): SendEmailResponse {
|
||||||
return {
|
return {
|
||||||
success: true,
|
message: `Email sent to ${to}.`,
|
||||||
response: {
|
|
||||||
accepted: [to],
|
accepted: [to],
|
||||||
envelope: {
|
envelope: {
|
||||||
from: from,
|
from: from,
|
||||||
to: [to],
|
to: [to],
|
||||||
},
|
},
|
||||||
message: `Email sent to ${to}.`,
|
messageId: "messageId",
|
||||||
},
|
pending: [],
|
||||||
|
rejected: [],
|
||||||
|
response: "response",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,15 @@ import {
|
||||||
logging,
|
logging,
|
||||||
env as coreEnv,
|
env as coreEnv,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import { Ctx, User, EmailInvite, EmailAttachment } from "@budibase/types"
|
import {
|
||||||
|
Ctx,
|
||||||
|
User,
|
||||||
|
EmailInvite,
|
||||||
|
EmailAttachment,
|
||||||
|
SendEmailResponse,
|
||||||
|
SendEmailRequest,
|
||||||
|
EmailTemplatePurpose,
|
||||||
|
} from "@budibase/types"
|
||||||
|
|
||||||
interface Request {
|
interface Request {
|
||||||
ctx?: Ctx
|
ctx?: Ctx
|
||||||
|
@ -110,25 +118,23 @@ export async function sendSmtpEmail({
|
||||||
invite?: EmailInvite
|
invite?: EmailInvite
|
||||||
}) {
|
}) {
|
||||||
// tenant ID will be set in header
|
// tenant ID will be set in header
|
||||||
const response = await fetch(
|
const request: SendEmailRequest = {
|
||||||
checkSlashesInUrl(env.WORKER_URL + `/api/global/email/send`),
|
|
||||||
createRequest({
|
|
||||||
method: "POST",
|
|
||||||
body: {
|
|
||||||
email: to,
|
email: to,
|
||||||
from,
|
from,
|
||||||
contents,
|
contents,
|
||||||
subject,
|
subject,
|
||||||
cc,
|
cc,
|
||||||
bcc,
|
bcc,
|
||||||
purpose: "custom",
|
purpose: EmailTemplatePurpose.CUSTOM,
|
||||||
automation,
|
automation,
|
||||||
invite,
|
invite,
|
||||||
attachments,
|
attachments,
|
||||||
},
|
}
|
||||||
})
|
const response = await fetch(
|
||||||
|
checkSlashesInUrl(env.WORKER_URL + `/api/global/email/send`),
|
||||||
|
createRequest({ method: "POST", body: request })
|
||||||
)
|
)
|
||||||
return checkResponse(response, "send email")
|
return (await checkResponse(response, "send email")) as SendEmailResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function removeAppFromUserRoles(ctx: Ctx, appId: string) {
|
export async function removeAppFromUserRoles(ctx: Ctx, appId: string) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
"@budibase/nano": "10.1.5",
|
"@budibase/nano": "10.1.5",
|
||||||
"@types/json-schema": "^7.0.15",
|
"@types/json-schema": "^7.0.15",
|
||||||
"@types/koa": "2.13.4",
|
"@types/koa": "2.13.4",
|
||||||
|
"@types/nodemailer": "^6.4.17",
|
||||||
"@types/redlock": "4.0.7",
|
"@types/redlock": "4.0.7",
|
||||||
"koa-useragent": "^4.1.0",
|
"koa-useragent": "^4.1.0",
|
||||||
"rimraf": "3.0.2",
|
"rimraf": "3.0.2",
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { EmailAttachment, EmailInvite } from "../../../documents"
|
import { EmailAttachment, EmailInvite } from "../../../documents"
|
||||||
|
import SMTPTransport from "nodemailer/lib/smtp-transport"
|
||||||
|
|
||||||
export enum EmailTemplatePurpose {
|
export enum EmailTemplatePurpose {
|
||||||
CORE = "core",
|
CORE = "core",
|
||||||
|
@ -12,17 +13,17 @@ export enum EmailTemplatePurpose {
|
||||||
export interface SendEmailRequest {
|
export interface SendEmailRequest {
|
||||||
workspaceId?: string
|
workspaceId?: string
|
||||||
email: string
|
email: string
|
||||||
userId: string
|
userId?: string
|
||||||
purpose: EmailTemplatePurpose
|
purpose: EmailTemplatePurpose
|
||||||
contents?: string
|
contents?: string
|
||||||
from?: string
|
from?: string
|
||||||
subject: string
|
subject: string
|
||||||
cc?: boolean
|
cc?: string
|
||||||
bcc?: boolean
|
bcc?: string
|
||||||
automation?: boolean
|
automation?: boolean
|
||||||
invite?: EmailInvite
|
invite?: EmailInvite
|
||||||
attachments?: EmailAttachment[]
|
attachments?: EmailAttachment[]
|
||||||
}
|
}
|
||||||
export interface SendEmailResponse extends Record<string, any> {
|
export interface SendEmailResponse extends SMTPTransport.SentMessageInfo {
|
||||||
message: string
|
message: string
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { Document } from "../../document"
|
import { Document } from "../../document"
|
||||||
import { User } from "../../global"
|
import { User } from "../../global"
|
||||||
import { ReadStream } from "fs"
|
|
||||||
import { Row } from "../row"
|
import { Row } from "../row"
|
||||||
import { Table } from "../table"
|
import { Table } from "../table"
|
||||||
import { AutomationStep, AutomationTrigger } from "./schema"
|
import { AutomationStep, AutomationTrigger } from "./schema"
|
||||||
import { ContextEmitter } from "../../../sdk"
|
import { ContextEmitter } from "../../../sdk"
|
||||||
|
import { Readable } from "stream"
|
||||||
|
|
||||||
export enum AutomationIOType {
|
export enum AutomationIOType {
|
||||||
OBJECT = "object",
|
OBJECT = "object",
|
||||||
|
@ -108,8 +108,8 @@ export interface SendEmailOpts {
|
||||||
subject: string
|
subject: string
|
||||||
// info Pass in a structure of information to be stored alongside the invitation.
|
// info Pass in a structure of information to be stored alongside the invitation.
|
||||||
info?: any
|
info?: any
|
||||||
cc?: boolean
|
cc?: string
|
||||||
bcc?: boolean
|
bcc?: string
|
||||||
automation?: boolean
|
automation?: boolean
|
||||||
invite?: EmailInvite
|
invite?: EmailInvite
|
||||||
attachments?: EmailAttachment[]
|
attachments?: EmailAttachment[]
|
||||||
|
@ -269,7 +269,7 @@ export type AutomationAttachment = {
|
||||||
|
|
||||||
export type AutomationAttachmentContent = {
|
export type AutomationAttachmentContent = {
|
||||||
filename: string
|
filename: string
|
||||||
content: ReadStream | NodeJS.ReadableStream
|
content: Readable
|
||||||
}
|
}
|
||||||
|
|
||||||
export type BucketedContent = AutomationAttachmentContent & {
|
export type BucketedContent = AutomationAttachmentContent & {
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
"@types/koa__router": "12.0.4",
|
"@types/koa__router": "12.0.4",
|
||||||
"@types/lodash": "4.14.200",
|
"@types/lodash": "4.14.200",
|
||||||
"@types/node-fetch": "2.6.4",
|
"@types/node-fetch": "2.6.4",
|
||||||
|
"@types/nodemailer": "^6.4.17",
|
||||||
"@types/server-destroy": "1.0.1",
|
"@types/server-destroy": "1.0.1",
|
||||||
"@types/supertest": "2.0.14",
|
"@types/supertest": "2.0.14",
|
||||||
"@types/uuid": "8.3.4",
|
"@types/uuid": "8.3.4",
|
||||||
|
|
|
@ -24,10 +24,13 @@ export async function sendEmail(
|
||||||
invite,
|
invite,
|
||||||
attachments,
|
attachments,
|
||||||
} = ctx.request.body
|
} = ctx.request.body
|
||||||
let user: any
|
let user: User | undefined = undefined
|
||||||
if (userId) {
|
if (userId) {
|
||||||
const db = tenancy.getGlobalDB()
|
const db = tenancy.getGlobalDB()
|
||||||
user = await db.get<User>(userId)
|
user = await db.tryGet<User>(userId)
|
||||||
|
}
|
||||||
|
if (!user) {
|
||||||
|
ctx.throw(404, "User not found.")
|
||||||
}
|
}
|
||||||
const response = await sendEmailFn(email, purpose, {
|
const response = await sendEmailFn(email, purpose, {
|
||||||
workspaceId,
|
workspaceId,
|
||||||
|
|
|
@ -13,7 +13,8 @@ import { configs, cache, objectStore } from "@budibase/backend-core"
|
||||||
import ical from "ical-generator"
|
import ical from "ical-generator"
|
||||||
import _ from "lodash"
|
import _ from "lodash"
|
||||||
|
|
||||||
const nodemailer = require("nodemailer")
|
import nodemailer from "nodemailer"
|
||||||
|
import SMTPTransport from "nodemailer/lib/smtp-transport"
|
||||||
|
|
||||||
const TEST_MODE = env.ENABLE_EMAIL_TEST_MODE && env.isDev()
|
const TEST_MODE = env.ENABLE_EMAIL_TEST_MODE && env.isDev()
|
||||||
const TYPE = TemplateType.EMAIL
|
const TYPE = TemplateType.EMAIL
|
||||||
|
@ -26,7 +27,7 @@ const FULL_EMAIL_PURPOSES = [
|
||||||
]
|
]
|
||||||
|
|
||||||
function createSMTPTransport(config?: SMTPInnerConfig) {
|
function createSMTPTransport(config?: SMTPInnerConfig) {
|
||||||
let options: any
|
let options: SMTPTransport.Options
|
||||||
let secure = config?.secure
|
let secure = config?.secure
|
||||||
// default it if not specified
|
// default it if not specified
|
||||||
if (secure == null) {
|
if (secure == null) {
|
||||||
|
@ -161,7 +162,7 @@ export async function sendEmail(
|
||||||
const code = await getLinkCode(purpose, email, opts.user, opts?.info)
|
const code = await getLinkCode(purpose, email, opts.user, opts?.info)
|
||||||
let context = await getSettingsTemplateContext(purpose, code)
|
let context = await getSettingsTemplateContext(purpose, code)
|
||||||
|
|
||||||
let message: any = {
|
let message: Parameters<typeof transport.sendMail>[0] = {
|
||||||
from: opts?.from || config?.from,
|
from: opts?.from || config?.from,
|
||||||
html: await buildEmail(purpose, email, context, {
|
html: await buildEmail(purpose, email, context, {
|
||||||
user: opts?.user,
|
user: opts?.user,
|
||||||
|
|
13
yarn.lock
13
yarn.lock
|
@ -2785,9 +2785,9 @@
|
||||||
through2 "^2.0.0"
|
through2 "^2.0.0"
|
||||||
|
|
||||||
"@budibase/pro@npm:@budibase/pro@latest":
|
"@budibase/pro@npm:@budibase/pro@latest":
|
||||||
version "3.4.12"
|
version "3.4.16"
|
||||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-3.4.12.tgz#60e630944de4e2de970a04179d8f0f57d48ce75e"
|
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-3.4.16.tgz#c482a400e27b7e89ca73092c4c81bdeac1d24581"
|
||||||
integrity sha512-msUBmcWxRDg+ugjZvd27XudERQqtQRdiARsO8MaDVTcp5ejIXgshEIVVshHOCj3hcbRblw9pXvBIMI53iTMUsA==
|
integrity sha512-8ECnqOh9jQ10KlQEwmKPFcoVGE+2gGgSybj+vbshwDp1zAW76doyMR2DMNjEatNpWVnpoMnTkDWtE9aqQ5v0vQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@anthropic-ai/sdk" "^0.27.3"
|
"@anthropic-ai/sdk" "^0.27.3"
|
||||||
"@budibase/backend-core" "*"
|
"@budibase/backend-core" "*"
|
||||||
|
@ -6775,6 +6775,13 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
undici-types "~6.19.2"
|
undici-types "~6.19.2"
|
||||||
|
|
||||||
|
"@types/nodemailer@^6.4.17":
|
||||||
|
version "6.4.17"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/nodemailer/-/nodemailer-6.4.17.tgz#5c82a42aee16a3dd6ea31446a1bd6a447f1ac1a4"
|
||||||
|
integrity sha512-I9CCaIp6DTldEg7vyUTZi8+9Vo0hi1/T8gv3C89yk1rSAAzoKQ8H8ki/jBYJSFoH/BisgLP8tkZMlQ91CIquww==
|
||||||
|
dependencies:
|
||||||
|
"@types/node" "*"
|
||||||
|
|
||||||
"@types/normalize-package-data@^2.4.0":
|
"@types/normalize-package-data@^2.4.0":
|
||||||
version "2.4.1"
|
version "2.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
|
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
|
||||||
|
|
Loading…
Reference in New Issue