2
0

feat(editor): Add send email integration

This commit is contained in:
Baptiste Arnaud
2022-02-07 18:06:37 +01:00
parent f4336b83cc
commit d6238b3474
48 changed files with 2119 additions and 2606 deletions

View File

@ -0,0 +1,38 @@
import { Credentials as CredentialsFromPrisma } from 'db'
export type Credentials = SmtpCredentials | GoogleSheetsCredentials
export type CredentialsBase = Omit<CredentialsFromPrisma, 'data' | 'type'>
export enum CredentialsType {
GOOGLE_SHEETS = 'google sheets',
SMTP = 'smtp',
}
export type SmtpCredentials = CredentialsBase & {
type: CredentialsType.SMTP
data: SmtpCredentialsData
}
export type GoogleSheetsCredentials = CredentialsBase & {
type: CredentialsType.GOOGLE_SHEETS
data: GoogleSheetsCredentialsData
}
export type GoogleSheetsCredentialsData = {
refresh_token?: string | null
expiry_date?: number | null
access_token?: string | null
token_type?: string | null
id_token?: string | null
scope?: string
}
export type SmtpCredentialsData = {
host?: string
username?: string
password?: string
isTlsEnabled?: boolean
port: number
from: { email?: string; name?: string }
}

View File

@ -3,3 +3,4 @@ export * from './publicTypebot'
export * from './result'
export * from './answer'
export * from './utils'
export * from './credentials'

View File

@ -4,16 +4,19 @@ export type IntegrationStep =
| GoogleSheetsStep
| GoogleAnalyticsStep
| WebhookStep
| SendEmailStep
export type IntegrationStepOptions =
| GoogleSheetsOptions
| GoogleAnalyticsOptions
| WebhookOptions
| SendEmailOptions
export enum IntegrationStepType {
GOOGLE_SHEETS = 'Google Sheets',
GOOGLE_ANALYTICS = 'Google Analytics',
WEBHOOK = 'Webhook',
EMAIL = 'Email',
}
export type GoogleSheetsStep = StepBase & {
@ -32,6 +35,18 @@ export type WebhookStep = StepBase & {
webhook: Webhook
}
export type SendEmailStep = StepBase & {
type: IntegrationStepType.EMAIL
options: SendEmailOptions
}
export type SendEmailOptions = {
credentialsId: string | 'default'
recipients: string[]
subject?: string
body?: string
}
export type GoogleAnalyticsOptions = {
trackingId?: string
category?: string
@ -142,3 +157,8 @@ export const defaultWebhookAttributes: Omit<Webhook, 'id'> = {
headers: [],
queryParams: [],
}
export const defaultSendEmailOptions: SendEmailOptions = {
credentialsId: 'default',
recipients: [],
}

View File

@ -7,7 +7,6 @@ import {
RedirectStep,
SetVariableStep,
} from '.'
import { Edge } from '..'
import { BubbleStep, BubbleStepType } from './bubble'
import { InputStep, InputStepType } from './inputs'
import { IntegrationStep } from './integration'