Merge branch 'master' into fix-branch-error-with-no-condition
This commit is contained in:
commit
9ea943863c
|
@ -62,6 +62,12 @@ http {
|
||||||
proxy_connect_timeout 120s;
|
proxy_connect_timeout 120s;
|
||||||
proxy_send_timeout 120s;
|
proxy_send_timeout 120s;
|
||||||
proxy_http_version 1.1;
|
proxy_http_version 1.1;
|
||||||
|
|
||||||
|
# Enable buffering for potentially large OIDC configs
|
||||||
|
proxy_buffering on;
|
||||||
|
proxy_buffer_size 16k;
|
||||||
|
proxy_buffers 4 32k;
|
||||||
|
|
||||||
proxy_set_header Host $host;
|
proxy_set_header Host $host;
|
||||||
proxy_set_header Connection "";
|
proxy_set_header Connection "";
|
||||||
|
|
||||||
|
|
|
@ -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": {
|
||||||
|
|
|
@ -484,7 +484,7 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
branches.forEach((branch, bIdx) => {
|
branches.forEach((branch, bIdx) => {
|
||||||
children[branch.id].forEach(
|
children[branch.id].forEach(
|
||||||
(bBlock: AutomationStep, sIdx: number, array: AutomationStep[]) => {
|
(bBlock: AutomationStep, sIdx: number, array: AutomationStep[]) => {
|
||||||
const ended = array.length - 1 === sIdx && !branches.length
|
const ended = array.length - 1 === sIdx
|
||||||
treeTraverse(bBlock, pathToCurrentNode, sIdx, bIdx, ended)
|
treeTraverse(bBlock, pathToCurrentNode, sIdx, bIdx, ended)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -505,7 +505,6 @@ const automationActions = (store: AutomationStore) => ({
|
||||||
blocks.forEach((block, idx, array) => {
|
blocks.forEach((block, idx, array) => {
|
||||||
treeTraverse(block, null, idx, null, array.length - 1 === idx)
|
treeTraverse(block, null, idx, null, array.length - 1 === idx)
|
||||||
})
|
})
|
||||||
|
|
||||||
return blockRefs
|
return blockRefs
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -3553,6 +3553,31 @@ if (descriptions.length) {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
}).toContainExactly([row])
|
}).toContainExactly([row])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
isInternal &&
|
||||||
|
describe("search by _id for relations", () => {
|
||||||
|
it("can filter by the related _id", async () => {
|
||||||
|
await expectSearch({
|
||||||
|
query: {
|
||||||
|
equal: { "rel._id": row.rel[0]._id },
|
||||||
|
},
|
||||||
|
}).toContainExactly([row])
|
||||||
|
|
||||||
|
await expectSearch({
|
||||||
|
query: {
|
||||||
|
equal: { "rel._id": row.rel[1]._id },
|
||||||
|
},
|
||||||
|
}).toContainExactly([row])
|
||||||
|
})
|
||||||
|
|
||||||
|
it("can filter by the related _id and find nothing", async () => {
|
||||||
|
await expectSearch({
|
||||||
|
query: {
|
||||||
|
equal: { "rel._id": "rel_none" },
|
||||||
|
},
|
||||||
|
}).toFindNothing()
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
!isInternal &&
|
!isInternal &&
|
||||||
|
|
|
@ -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",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import {
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
import { cloneDeep } from "lodash/fp"
|
import { cloneDeep } from "lodash/fp"
|
||||||
import sdk from "../../../sdk"
|
import sdk from "../../../sdk"
|
||||||
|
import { isInternal } from "../tables/utils"
|
||||||
|
|
||||||
export const removeInvalidFilters = (
|
export const removeInvalidFilters = (
|
||||||
filters: SearchFilters,
|
filters: SearchFilters,
|
||||||
|
@ -70,6 +71,10 @@ export const getQueryableFields = async (
|
||||||
opts?: { noRelationships?: boolean }
|
opts?: { noRelationships?: boolean }
|
||||||
): Promise<string[]> => {
|
): Promise<string[]> => {
|
||||||
const result = []
|
const result = []
|
||||||
|
if (isInternal({ table })) {
|
||||||
|
result.push("_id")
|
||||||
|
}
|
||||||
|
|
||||||
for (const field of Object.keys(table.schema).filter(
|
for (const field of Object.keys(table.schema).filter(
|
||||||
f => allowedFields.includes(f) && table.schema[f].visible !== false
|
f => allowedFields.includes(f) && table.schema[f].visible !== false
|
||||||
)) {
|
)) {
|
||||||
|
@ -113,14 +118,13 @@ export const getQueryableFields = async (
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = [
|
// Querying by _id is always allowed, even if it's never part of the schema
|
||||||
"_id", // Querying by _id is always allowed, even if it's never part of the schema
|
const result = ["_id"]
|
||||||
]
|
|
||||||
|
|
||||||
if (fields == null) {
|
if (fields == null) {
|
||||||
fields = Object.keys(table.schema)
|
fields = Object.keys(table.schema)
|
||||||
}
|
}
|
||||||
result.push(...(await extractTableFields(table, fields, [table._id!])))
|
result.push(...(await extractTableFields(table, fields, [table._id!])))
|
||||||
|
|
||||||
return result
|
return Array.from(new Set(result))
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,6 +250,8 @@ describe("query utils", () => {
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
"_id",
|
"_id",
|
||||||
"name",
|
"name",
|
||||||
|
"aux._id",
|
||||||
|
"auxTable._id",
|
||||||
"aux.title",
|
"aux.title",
|
||||||
"auxTable.title",
|
"auxTable.title",
|
||||||
"aux.name",
|
"aux.name",
|
||||||
|
@ -284,7 +286,14 @@ describe("query utils", () => {
|
||||||
const result = await config.doInContext(config.appId, () => {
|
const result = await config.doInContext(config.appId, () => {
|
||||||
return getQueryableFields(table)
|
return getQueryableFields(table)
|
||||||
})
|
})
|
||||||
expect(result).toEqual(["_id", "name", "aux.name", "auxTable.name"])
|
expect(result).toEqual([
|
||||||
|
"_id",
|
||||||
|
"name",
|
||||||
|
"aux._id",
|
||||||
|
"auxTable._id",
|
||||||
|
"aux.name",
|
||||||
|
"auxTable.name",
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it("excludes all relationship fields if hidden", async () => {
|
it("excludes all relationship fields if hidden", async () => {
|
||||||
|
@ -387,10 +396,14 @@ describe("query utils", () => {
|
||||||
"_id",
|
"_id",
|
||||||
"name",
|
"name",
|
||||||
// aux1 primitive props
|
// aux1 primitive props
|
||||||
|
"aux1._id",
|
||||||
|
"aux1Table._id",
|
||||||
"aux1.name",
|
"aux1.name",
|
||||||
"aux1Table.name",
|
"aux1Table.name",
|
||||||
|
|
||||||
// aux2 primitive props
|
// aux2 primitive props
|
||||||
|
"aux2._id",
|
||||||
|
"aux2Table._id",
|
||||||
"aux2.title",
|
"aux2.title",
|
||||||
"aux2Table.title",
|
"aux2Table.title",
|
||||||
])
|
])
|
||||||
|
@ -405,14 +418,18 @@ describe("query utils", () => {
|
||||||
"name",
|
"name",
|
||||||
|
|
||||||
// aux2_1 primitive props
|
// aux2_1 primitive props
|
||||||
|
"aux2_1._id",
|
||||||
|
"aux2Table._id",
|
||||||
"aux2_1.title",
|
"aux2_1.title",
|
||||||
"aux2Table.title",
|
"aux2Table.title",
|
||||||
|
|
||||||
// aux2_2 primitive props
|
// aux2_2 primitive props
|
||||||
|
"aux2_2._id",
|
||||||
"aux2_2.title",
|
"aux2_2.title",
|
||||||
"aux2Table.title",
|
|
||||||
|
|
||||||
// table primitive props
|
// table primitive props
|
||||||
|
"table._id",
|
||||||
|
"TestTable._id",
|
||||||
"table.name",
|
"table.name",
|
||||||
"TestTable.name",
|
"TestTable.name",
|
||||||
])
|
])
|
||||||
|
@ -427,14 +444,18 @@ describe("query utils", () => {
|
||||||
"title",
|
"title",
|
||||||
|
|
||||||
// aux1_1 primitive props
|
// aux1_1 primitive props
|
||||||
|
"aux1_1._id",
|
||||||
|
"aux1Table._id",
|
||||||
"aux1_1.name",
|
"aux1_1.name",
|
||||||
"aux1Table.name",
|
"aux1Table.name",
|
||||||
|
|
||||||
// aux1_2 primitive props
|
// aux1_2 primitive props
|
||||||
|
"aux1_2._id",
|
||||||
"aux1_2.name",
|
"aux1_2.name",
|
||||||
"aux1Table.name",
|
|
||||||
|
|
||||||
// table primitive props
|
// table primitive props
|
||||||
|
"table._id",
|
||||||
|
"TestTable._id",
|
||||||
"table.name",
|
"table.name",
|
||||||
"TestTable.name",
|
"TestTable.name",
|
||||||
])
|
])
|
||||||
|
@ -481,6 +502,8 @@ describe("query utils", () => {
|
||||||
"name",
|
"name",
|
||||||
|
|
||||||
// deep 1 aux primitive props
|
// deep 1 aux primitive props
|
||||||
|
"aux._id",
|
||||||
|
"auxTable._id",
|
||||||
"aux.title",
|
"aux.title",
|
||||||
"auxTable.title",
|
"auxTable.title",
|
||||||
])
|
])
|
||||||
|
@ -495,6 +518,8 @@ describe("query utils", () => {
|
||||||
"title",
|
"title",
|
||||||
|
|
||||||
// deep 1 dependency primitive props
|
// deep 1 dependency primitive props
|
||||||
|
"table._id",
|
||||||
|
"TestTable._id",
|
||||||
"table.name",
|
"table.name",
|
||||||
"TestTable.name",
|
"TestTable.name",
|
||||||
])
|
])
|
||||||
|
|
|
@ -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 & {
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
"koa-body": "4.2.0",
|
"koa-body": "4.2.0",
|
||||||
"koa-compress": "4.0.1",
|
"koa-compress": "4.0.1",
|
||||||
"koa-passport": "4.1.4",
|
"koa-passport": "4.1.4",
|
||||||
|
"koa-redis": "^4.0.1",
|
||||||
"koa-send": "5.0.1",
|
"koa-send": "5.0.1",
|
||||||
"koa-session": "5.13.1",
|
"koa-session": "5.13.1",
|
||||||
"koa-static": "5.0.0",
|
"koa-static": "5.0.0",
|
||||||
|
@ -85,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,
|
||||||
|
|
|
@ -311,7 +311,7 @@ describe("/api/global/auth", () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe("GET /api/global/auth/:tenantId/oidc/callback", () => {
|
describe.skip("GET /api/global/auth/:tenantId/oidc/callback", () => {
|
||||||
it("logs in", async () => {
|
it("logs in", async () => {
|
||||||
const email = `${generator.guid()}@example.com`
|
const email = `${generator.guid()}@example.com`
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ if (process.env.DD_APM_ENABLED) {
|
||||||
|
|
||||||
// need to load environment first
|
// need to load environment first
|
||||||
import env from "./environment"
|
import env from "./environment"
|
||||||
import Application from "koa"
|
import Application, { Middleware } from "koa"
|
||||||
import { bootstrap } from "global-agent"
|
import { bootstrap } from "global-agent"
|
||||||
import * as db from "./db"
|
import * as db from "./db"
|
||||||
import { sdk as proSdk } from "@budibase/pro"
|
import { sdk as proSdk } from "@budibase/pro"
|
||||||
|
@ -20,6 +20,7 @@ import {
|
||||||
cache,
|
cache,
|
||||||
features,
|
features,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
|
import RedisStore from "koa-redis"
|
||||||
|
|
||||||
db.init()
|
db.init()
|
||||||
import koaBody from "koa-body"
|
import koaBody from "koa-body"
|
||||||
|
@ -52,7 +53,23 @@ app.proxy = true
|
||||||
app.use(handleScimBody)
|
app.use(handleScimBody)
|
||||||
app.use(koaBody({ multipart: true }))
|
app.use(koaBody({ multipart: true }))
|
||||||
|
|
||||||
app.use(koaSession(app))
|
const sessionMiddleware: Middleware = async (ctx: any, next: any) => {
|
||||||
|
const redisClient = await new redis.Client(
|
||||||
|
redis.utils.Databases.SESSIONS
|
||||||
|
).init()
|
||||||
|
return koaSession(
|
||||||
|
{
|
||||||
|
// @ts-ignore
|
||||||
|
store: new RedisStore({ client: redisClient.getClient() }),
|
||||||
|
key: "koa:sess",
|
||||||
|
maxAge: 86400000, // one day
|
||||||
|
},
|
||||||
|
app
|
||||||
|
)(ctx, next)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.use(sessionMiddleware)
|
||||||
|
|
||||||
app.use(middleware.correlation)
|
app.use(middleware.correlation)
|
||||||
app.use(middleware.pino)
|
app.use(middleware.pino)
|
||||||
app.use(middleware.ip)
|
app.use(middleware.ip)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
declare module "koa-redis" {}
|
|
@ -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,
|
||||||
|
|
41
yarn.lock
41
yarn.lock
|
@ -2695,6 +2695,13 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
regenerator-runtime "^0.14.0"
|
regenerator-runtime "^0.14.0"
|
||||||
|
|
||||||
|
"@babel/runtime@^7.8.3":
|
||||||
|
version "7.26.9"
|
||||||
|
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.9.tgz#aa4c6facc65b9cb3f87d75125ffd47781b475433"
|
||||||
|
integrity sha512-aA63XwOkcl4xxQa3HjPMqOP6LiK0ZDv3mUPYEFXkpHbaFjtGggE1A61FjFzJnB+p7/oy2gA8E+rcBNl/zC1tMg==
|
||||||
|
dependencies:
|
||||||
|
regenerator-runtime "^0.14.0"
|
||||||
|
|
||||||
"@babel/template@^7.22.15", "@babel/template@^7.22.5", "@babel/template@^7.25.9", "@babel/template@^7.3.3":
|
"@babel/template@^7.22.15", "@babel/template@^7.22.5", "@babel/template@^7.25.9", "@babel/template@^7.3.3":
|
||||||
version "7.25.9"
|
version "7.25.9"
|
||||||
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.25.9.tgz#ecb62d81a8a6f5dc5fe8abfc3901fc52ddf15016"
|
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.25.9.tgz#ecb62d81a8a6f5dc5fe8abfc3901fc52ddf15016"
|
||||||
|
@ -2778,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" "*"
|
||||||
|
@ -6768,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"
|
||||||
|
@ -9041,7 +9055,14 @@ co-body@^5.1.1:
|
||||||
raw-body "^2.2.0"
|
raw-body "^2.2.0"
|
||||||
type-is "^1.6.14"
|
type-is "^1.6.14"
|
||||||
|
|
||||||
co@^4.6.0:
|
co-wrap-all@^1.0.0:
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/co-wrap-all/-/co-wrap-all-1.0.0.tgz#370ae3e8333510a53f6b2f7fdfbe4568a11b7ecf"
|
||||||
|
integrity sha512-aru6gLi2vTUazr+MxVm3Rv6ST7/EKtFj9BrfkcOrbCO2Qv6LqJdE71m88HhHiBEviKw/ucVrwoGLrq2xHpOsJA==
|
||||||
|
dependencies:
|
||||||
|
co "^4.0.0"
|
||||||
|
|
||||||
|
co@^4.0.0, co@^4.6.0:
|
||||||
version "4.6.0"
|
version "4.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
|
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
|
||||||
integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==
|
integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==
|
||||||
|
@ -13177,7 +13198,7 @@ ioredis@5.3.2:
|
||||||
redis-parser "^3.0.0"
|
redis-parser "^3.0.0"
|
||||||
standard-as-callback "^2.1.0"
|
standard-as-callback "^2.1.0"
|
||||||
|
|
||||||
ioredis@^4.28.5:
|
ioredis@^4.14.1, ioredis@^4.28.5:
|
||||||
version "4.28.5"
|
version "4.28.5"
|
||||||
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.5.tgz#5c149e6a8d76a7f8fa8a504ffc85b7d5b6797f9f"
|
resolved "https://registry.yarnpkg.com/ioredis/-/ioredis-4.28.5.tgz#5c149e6a8d76a7f8fa8a504ffc85b7d5b6797f9f"
|
||||||
integrity sha512-3GYo0GJtLqgNXj4YhrisLaNNvWSNwSS2wS4OELGfGxH8I69+XfNdnmV1AyN+ZqMh0i7eX+SWjrwFKDBDgfBC1A==
|
integrity sha512-3GYo0GJtLqgNXj4YhrisLaNNvWSNwSS2wS4OELGfGxH8I69+XfNdnmV1AyN+ZqMh0i7eX+SWjrwFKDBDgfBC1A==
|
||||||
|
@ -14677,6 +14698,16 @@ koa-pino-logger@4.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
pino-http "^6.5.0"
|
pino-http "^6.5.0"
|
||||||
|
|
||||||
|
koa-redis@^4.0.1:
|
||||||
|
version "4.0.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/koa-redis/-/koa-redis-4.0.1.tgz#57ac1b46d9ab851221a9f4952c1e8d4bf289db40"
|
||||||
|
integrity sha512-o2eTVNo1NBnloeUGhHed5Q2ZvJSLpUEj/+E1/7oH5EmH8WuQ+QLdl/VawkshxdFQ47W1p6V09lM3hCTu7D0YnQ==
|
||||||
|
dependencies:
|
||||||
|
"@babel/runtime" "^7.8.3"
|
||||||
|
co-wrap-all "^1.0.0"
|
||||||
|
debug "^4.1.1"
|
||||||
|
ioredis "^4.14.1"
|
||||||
|
|
||||||
koa-router@^10.0.0:
|
koa-router@^10.0.0:
|
||||||
version "10.1.1"
|
version "10.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/koa-router/-/koa-router-10.1.1.tgz#20809f82648518b84726cd445037813cd99f17ff"
|
resolved "https://registry.yarnpkg.com/koa-router/-/koa-router-10.1.1.tgz#20809f82648518b84726cd445037813cd99f17ff"
|
||||||
|
|
Loading…
Reference in New Issue