feat(integration): ✨ Add webhooks
This commit is contained in:
@ -1,15 +1,20 @@
|
||||
import { StepBase } from '.'
|
||||
import { Table } from '../..'
|
||||
|
||||
export type IntegrationStep = GoogleSheetsStep | GoogleAnalyticsStep
|
||||
export type IntegrationStep =
|
||||
| GoogleSheetsStep
|
||||
| GoogleAnalyticsStep
|
||||
| WebhookStep
|
||||
|
||||
export type IntegrationStepOptions =
|
||||
| GoogleSheetsOptions
|
||||
| GoogleAnalyticsOptions
|
||||
| WebhookOptions
|
||||
|
||||
export enum IntegrationStepType {
|
||||
GOOGLE_SHEETS = 'Google Sheets',
|
||||
GOOGLE_ANALYTICS = 'Google Analytics',
|
||||
WEBHOOK = 'Webhook',
|
||||
}
|
||||
|
||||
export type GoogleSheetsStep = StepBase & {
|
||||
@ -22,6 +27,11 @@ export type GoogleAnalyticsStep = StepBase & {
|
||||
options?: GoogleAnalyticsOptions
|
||||
}
|
||||
|
||||
export type WebhookStep = StepBase & {
|
||||
type: IntegrationStepType.WEBHOOK
|
||||
options?: WebhookOptions
|
||||
}
|
||||
|
||||
export type GoogleAnalyticsOptions = {
|
||||
trackingId?: string
|
||||
category?: string
|
||||
@ -66,3 +76,40 @@ export type GoogleSheetsUpdateRowOptions = GoogleSheetsOptionsBase & {
|
||||
referenceCell?: Cell
|
||||
cellsToUpsert?: Table<Cell>
|
||||
}
|
||||
|
||||
export type ResponseVariableMapping = { bodyPath?: string; variableId?: string }
|
||||
|
||||
export type WebhookOptions = {
|
||||
webhookId?: string
|
||||
variablesForTest?: Table<VariableForTest>
|
||||
responseVariableMapping?: Table<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 = { key?: string; value?: string }
|
||||
export type VariableForTest = { variableId?: string; value?: string }
|
||||
|
||||
export type Webhook = {
|
||||
id: string
|
||||
url?: string
|
||||
method?: HttpMethod
|
||||
queryParams?: Table<KeyValue>
|
||||
headers?: Table<KeyValue>
|
||||
body?: string
|
||||
}
|
||||
|
||||
export type WebhookResponse = {
|
||||
statusCode: number
|
||||
data?: unknown
|
||||
}
|
||||
|
@ -5,16 +5,24 @@ import { Settings } from './settings'
|
||||
import { Step } from './steps/steps'
|
||||
import { Theme } from './theme'
|
||||
import { Variable } from './variable'
|
||||
import { Webhook } from '.'
|
||||
|
||||
export type Typebot = Omit<
|
||||
TypebotFromPrisma,
|
||||
'blocks' | 'theme' | 'settings' | 'steps' | 'choiceItems' | 'variables'
|
||||
| 'blocks'
|
||||
| 'theme'
|
||||
| 'settings'
|
||||
| 'steps'
|
||||
| 'choiceItems'
|
||||
| 'variables'
|
||||
| 'webhooks'
|
||||
> & {
|
||||
blocks: Table<Block>
|
||||
steps: Table<Step>
|
||||
choiceItems: Table<ChoiceItem>
|
||||
variables: Table<Variable>
|
||||
edges: Table<Edge>
|
||||
webhooks: Table<Webhook>
|
||||
theme: Theme
|
||||
settings: Settings
|
||||
}
|
||||
|
Reference in New Issue
Block a user