UNPKG

tyntec-sdk

Version:

TypeScript SDK for Tyntec Conversations API V3

73 lines (72 loc) 2.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.interactiveMessageSchema = exports.interactiveComponentsSchema = exports.productListSectionSchema = exports.listSectionSchema = exports.buttonSchema = void 0; const zod_1 = require("zod"); const base_schema_1 = require("./base.schema"); exports.buttonSchema = zod_1.z.object({ type: zod_1.z.literal('reply'), reply: zod_1.z.object({ payload: zod_1.z.string(), title: zod_1.z.string(), }), }); exports.listSectionSchema = zod_1.z.object({ title: zod_1.z.string(), rows: zod_1.z.array(zod_1.z.object({ payload: zod_1.z.string(), title: zod_1.z.string(), description: zod_1.z.string(), })), }); exports.productListSectionSchema = zod_1.z.object({ items: zod_1.z.array(zod_1.z.object({ productId: zod_1.z.string(), })), }); exports.interactiveComponentsSchema = zod_1.z.object({ header: zod_1.z .object({ type: zod_1.z.literal('text'), text: zod_1.z.string(), }) .optional(), body: zod_1.z .object({ type: zod_1.z.literal('text'), text: zod_1.z.string(), }) .optional(), footer: zod_1.z .object({ type: zod_1.z.literal('text'), text: zod_1.z.string(), }) .optional(), buttons: zod_1.z.array(exports.buttonSchema).optional(), list: zod_1.z .object({ title: zod_1.z.string(), sections: zod_1.z.array(exports.listSectionSchema), }) .optional(), productList: zod_1.z .object({ catalogId: zod_1.z.string(), sections: zod_1.z.array(exports.productListSectionSchema), }) .optional(), product: zod_1.z .object({ catalogId: zod_1.z.string(), productId: zod_1.z.string(), }) .optional(), }); // Extending the base schema with interactive content exports.interactiveMessageSchema = base_schema_1.whatsAppBaseFields.extend({ contentType: zod_1.z.literal('interactive'), interactive: zod_1.z.object({ subType: zod_1.z.enum(['buttons', 'list', 'product', 'productList']), components: exports.interactiveComponentsSchema, }), });