🚸 Rename "webhook" block to "HTTP request"
This commit is contained in:
@ -1,14 +1,14 @@
|
||||
import { z } from '../../../../zod'
|
||||
import { IntegrationBlockType } from '../constants'
|
||||
import { webhookBlockSchemas } from '../webhook'
|
||||
import { httpBlockSchemas } from '../webhook'
|
||||
|
||||
export const makeComBlockSchemas = {
|
||||
v5: webhookBlockSchemas.v5.merge(
|
||||
v5: httpBlockSchemas.v5.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.MAKE_COM]),
|
||||
})
|
||||
),
|
||||
v6: webhookBlockSchemas.v6.merge(
|
||||
v6: httpBlockSchemas.v6.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.MAKE_COM]),
|
||||
})
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { z } from '../../../../zod'
|
||||
import { IntegrationBlockType } from '../constants'
|
||||
import { webhookBlockSchemas } from '../webhook'
|
||||
import { httpBlockSchemas } from '../webhook'
|
||||
|
||||
export const pabblyConnectBlockSchemas = {
|
||||
v5: webhookBlockSchemas.v5.merge(
|
||||
v5: httpBlockSchemas.v5.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.PABBLY_CONNECT]),
|
||||
})
|
||||
),
|
||||
v6: webhookBlockSchemas.v6.merge(
|
||||
v6: httpBlockSchemas.v6.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.PABBLY_CONNECT]),
|
||||
})
|
||||
|
@ -7,7 +7,7 @@ import { pixelBlockSchema } from './pixel/schema'
|
||||
import { sendEmailBlockSchema } from './sendEmail'
|
||||
import { zemanticAiBlockSchema } from './zemanticAi'
|
||||
import { zapierBlockSchemas } from './zapier'
|
||||
import { webhookBlockSchemas } from './webhook'
|
||||
import { httpBlockSchemas } from './webhook'
|
||||
import { makeComBlockSchemas } from './makeCom'
|
||||
import { pabblyConnectBlockSchemas } from './pabblyConnect'
|
||||
|
||||
@ -20,7 +20,7 @@ export const integrationBlockSchemas = {
|
||||
openAIBlockSchema,
|
||||
pabblyConnectBlockSchemas.v5,
|
||||
sendEmailBlockSchema,
|
||||
webhookBlockSchemas.v5,
|
||||
httpBlockSchemas.v5,
|
||||
zapierBlockSchemas.v5,
|
||||
pixelBlockSchema,
|
||||
zemanticAiBlockSchema,
|
||||
@ -33,7 +33,7 @@ export const integrationBlockSchemas = {
|
||||
openAIBlockSchema,
|
||||
pabblyConnectBlockSchemas.v6,
|
||||
sendEmailBlockSchema,
|
||||
webhookBlockSchemas.v6,
|
||||
httpBlockSchemas.v6,
|
||||
zapierBlockSchemas.v6,
|
||||
pixelBlockSchema,
|
||||
zemanticAiBlockSchema,
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { WebhookBlockV6 } from './schema'
|
||||
import { HttpRequestBlockV6 } from './schema'
|
||||
|
||||
export enum HttpMethod {
|
||||
POST = 'POST',
|
||||
@ -20,7 +20,7 @@ export const defaultWebhookBlockOptions = {
|
||||
isAdvancedConfig: false,
|
||||
isCustomBody: false,
|
||||
isExecutedOnClient: false,
|
||||
} as const satisfies WebhookBlockV6['options']
|
||||
} as const satisfies HttpRequestBlockV6['options']
|
||||
|
||||
export const defaultTimeout = 10
|
||||
export const maxTimeout = 120
|
||||
|
@ -21,7 +21,7 @@ const keyValueSchema = z.object({
|
||||
value: z.string().optional(),
|
||||
})
|
||||
|
||||
export const webhookV5Schema = z.object({
|
||||
export const httpRequestV5Schema = z.object({
|
||||
id: z.string(),
|
||||
queryParams: keyValueSchema.array().optional(),
|
||||
headers: keyValueSchema.array().optional(),
|
||||
@ -30,61 +30,63 @@ export const webhookV5Schema = z.object({
|
||||
body: z.string().optional(),
|
||||
})
|
||||
|
||||
const webhookSchemas = {
|
||||
v5: webhookV5Schema,
|
||||
v6: webhookV5Schema.omit({
|
||||
const httpRequestSchemas = {
|
||||
v5: httpRequestV5Schema,
|
||||
v6: httpRequestV5Schema.omit({
|
||||
id: true,
|
||||
}),
|
||||
}
|
||||
|
||||
const webhookSchema = z.union([webhookSchemas.v5, webhookSchemas.v6])
|
||||
const httpRequestSchema = z.union([
|
||||
httpRequestSchemas.v5,
|
||||
httpRequestSchemas.v6,
|
||||
])
|
||||
|
||||
export const webhookOptionsV5Schema = z.object({
|
||||
export const httpRequestOptionsV5Schema = z.object({
|
||||
variablesForTest: z.array(variableForTestSchema).optional(),
|
||||
responseVariableMapping: z.array(responseVariableMappingSchema).optional(),
|
||||
isAdvancedConfig: z.boolean().optional(),
|
||||
isCustomBody: z.boolean().optional(),
|
||||
isExecutedOnClient: z.boolean().optional(),
|
||||
webhook: webhookSchemas.v5.optional(),
|
||||
webhook: httpRequestSchemas.v5.optional(),
|
||||
timeout: z.number().min(1).max(maxTimeout).optional(),
|
||||
})
|
||||
|
||||
const webhookOptionsSchemas = {
|
||||
v5: webhookOptionsV5Schema,
|
||||
v6: webhookOptionsV5Schema.merge(
|
||||
const httpRequestOptionsSchemas = {
|
||||
v5: httpRequestOptionsV5Schema,
|
||||
v6: httpRequestOptionsV5Schema.merge(
|
||||
z.object({
|
||||
webhook: webhookSchemas.v6.optional(),
|
||||
webhook: httpRequestSchemas.v6.optional(),
|
||||
})
|
||||
),
|
||||
}
|
||||
|
||||
const webhookBlockV5Schema = blockBaseSchema.merge(
|
||||
const httpBlockV5Schema = blockBaseSchema.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.WEBHOOK]),
|
||||
options: webhookOptionsSchemas.v5.optional(),
|
||||
type: z
|
||||
.enum([IntegrationBlockType.WEBHOOK])
|
||||
.describe('Legacy name for HTTP Request block'),
|
||||
options: httpRequestOptionsSchemas.v5.optional(),
|
||||
webhookId: z.string().optional(),
|
||||
})
|
||||
)
|
||||
|
||||
export const webhookBlockSchemas = {
|
||||
v5: webhookBlockV5Schema,
|
||||
v6: webhookBlockV5Schema
|
||||
export const httpBlockSchemas = {
|
||||
v5: httpBlockV5Schema,
|
||||
v6: httpBlockV5Schema
|
||||
.omit({
|
||||
webhookId: true,
|
||||
})
|
||||
.merge(
|
||||
z.object({
|
||||
options: webhookOptionsSchemas.v6.optional(),
|
||||
options: httpRequestOptionsSchemas.v6.optional(),
|
||||
})
|
||||
),
|
||||
}
|
||||
|
||||
const webhookBlockSchema = z.union([
|
||||
webhookBlockSchemas.v5,
|
||||
webhookBlockSchemas.v6,
|
||||
])
|
||||
const httpBlockSchema = z.union([httpBlockSchemas.v5, httpBlockSchemas.v6])
|
||||
|
||||
export const executableWebhookSchema = z.object({
|
||||
export const executableHttpRequestSchema = z.object({
|
||||
url: z.string(),
|
||||
headers: z.record(z.string()).optional(),
|
||||
body: z.unknown().optional(),
|
||||
@ -93,16 +95,16 @@ export const executableWebhookSchema = z.object({
|
||||
|
||||
export type KeyValue = { id: string; key?: string; value?: string }
|
||||
|
||||
export type WebhookResponse = {
|
||||
export type HttpResponse = {
|
||||
statusCode: number
|
||||
data?: unknown
|
||||
}
|
||||
|
||||
export type ExecutableWebhook = z.infer<typeof executableWebhookSchema>
|
||||
export type ExecutableHttpRequest = z.infer<typeof executableHttpRequestSchema>
|
||||
|
||||
export type Webhook = z.infer<typeof webhookSchema>
|
||||
export type WebhookBlock = z.infer<typeof webhookBlockSchema>
|
||||
export type WebhookBlockV6 = z.infer<typeof webhookBlockSchemas.v6>
|
||||
export type HttpRequest = z.infer<typeof httpRequestSchema>
|
||||
export type HttpRequestBlock = z.infer<typeof httpBlockSchema>
|
||||
export type HttpRequestBlockV6 = z.infer<typeof httpBlockSchemas.v6>
|
||||
export type ResponseVariableMapping = z.infer<
|
||||
typeof responseVariableMappingSchema
|
||||
>
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { z } from '../../../../zod'
|
||||
import { IntegrationBlockType } from '../constants'
|
||||
import { webhookBlockSchemas } from '../webhook'
|
||||
import { httpBlockSchemas } from '../webhook'
|
||||
|
||||
export const zapierBlockSchemas = {
|
||||
v5: webhookBlockSchemas.v5.merge(
|
||||
v5: httpBlockSchemas.v5.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.ZAPIER]),
|
||||
})
|
||||
),
|
||||
v6: webhookBlockSchemas.v6.merge(
|
||||
v6: httpBlockSchemas.v6.merge(
|
||||
z.object({
|
||||
type: z.enum([IntegrationBlockType.ZAPIER]),
|
||||
})
|
||||
|
@ -3,7 +3,7 @@ import { extendZodWithOpenApi } from 'zod-openapi'
|
||||
import { listVariableValue } from '../typebot/variable'
|
||||
import {
|
||||
googleAnalyticsOptionsSchema,
|
||||
executableWebhookSchema,
|
||||
executableHttpRequestSchema,
|
||||
pixelOptionsSchema,
|
||||
redirectOptionsSchema,
|
||||
} from '../blocks'
|
||||
@ -120,7 +120,7 @@ export const clientSideActionSchema = z.discriminatedUnion('type', [
|
||||
z
|
||||
.object({
|
||||
type: z.literal('webhookToExecute'),
|
||||
webhookToExecute: executableWebhookSchema,
|
||||
webhookToExecute: executableHttpRequestSchema,
|
||||
})
|
||||
.merge(clientSideActionBaseSchema)
|
||||
.openapi({
|
||||
|
Reference in New Issue
Block a user