2
0

feat(editor): Restore published version button

Had to migrate webhooks into a standalone table
This commit is contained in:
Baptiste Arnaud
2022-03-01 07:13:09 +01:00
parent 0df719d531
commit e17a1a0869
46 changed files with 578 additions and 348 deletions

View File

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

View File

@ -1,22 +1,13 @@
import { Block, Edge, Settings, Step, Theme, Variable } from './typebot'
import { Block, Edge, Settings, Theme, Variable } from './typebot'
import { PublicTypebot as PublicTypebotFromPrisma } from 'db'
export type PublicTypebot = Omit<
PublicTypebotFromPrisma,
| 'blocks'
| 'theme'
| 'settings'
| 'variables'
| 'edges'
| 'createdAt'
| 'updatedAt'
'blocks' | 'theme' | 'settings' | 'variables' | 'edges'
> & {
blocks: PublicBlock[]
blocks: Block[]
variables: Variable[]
edges: Edge[]
theme: Theme
settings: Settings
}
export type PublicBlock = Omit<Block, 'steps'> & { steps: PublicStep[] }
export type PublicStep = Omit<Step, 'webhook'> & { webhook?: string }

View File

@ -34,7 +34,7 @@ export type GoogleAnalyticsStep = StepBase & {
export type WebhookStep = StepBase & {
type: IntegrationStepType.WEBHOOK
options: WebhookOptions
webhook: Webhook
webhookId: string
}
export type ZapierStep = Omit<WebhookStep, 'type'> & {
@ -118,39 +118,12 @@ export type WebhookOptions = {
responseVariableMapping: ResponseVariableMapping[]
}
export enum HttpMethod {
POST = 'POST',
GET = 'GET',
PUT = 'PUT',
DELETE = 'DELETE',
PATCH = 'PATCH',
HEAD = 'HEAD',
CONNECT = 'CONNECT',
OPTIONS = 'OPTIONS',
TRACE = 'TRACE',
}
export type KeyValue = { id: string; key?: string; value?: string }
export type VariableForTest = {
id: string
variableId?: string
value?: string
}
export type Webhook = {
id: string
url?: string
method: HttpMethod
queryParams: KeyValue[]
headers: KeyValue[]
body?: string
}
export type WebhookResponse = {
statusCode: number
data?: unknown
}
export const defaultGoogleSheetsOptions: GoogleSheetsOptions = {}
export const defaultGoogleAnalyticsOptions: GoogleAnalyticsOptions = {}
@ -160,12 +133,6 @@ export const defaultWebhookOptions: Omit<WebhookOptions, 'webhookId'> = {
variablesForTest: [],
}
export const defaultWebhookAttributes: Omit<Webhook, 'id'> = {
method: HttpMethod.GET,
headers: [],
queryParams: [],
}
export const defaultSendEmailOptions: SendEmailOptions = {
credentialsId: 'default',
recipients: [],

View File

@ -0,0 +1,38 @@
import { Webhook as WebhookFromPrisma } from 'db'
export enum HttpMethod {
POST = 'POST',
GET = 'GET',
PUT = 'PUT',
DELETE = 'DELETE',
PATCH = 'PATCH',
HEAD = 'HEAD',
CONNECT = 'CONNECT',
OPTIONS = 'OPTIONS',
TRACE = 'TRACE',
}
export type KeyValue = { id: string; key?: string; value?: string }
export type Webhook = Omit<
WebhookFromPrisma,
'queryParams' | 'headers' | 'method'
> & {
queryParams: KeyValue[]
headers: KeyValue[]
method: HttpMethod
}
export type WebhookResponse = {
statusCode: number
data?: unknown
}
export const defaultWebhookAttributes: Omit<
Webhook,
'id' | 'body' | 'url' | 'typebotId'
> = {
method: HttpMethod.GET,
headers: [],
queryParams: [],
}