From ebe1687d674cbc949c1f8015f0a11001cd01dfdf Mon Sep 17 00:00:00 2001 From: Zachary Kirby Date: Fri, 14 Jul 2023 17:28:56 -0700 Subject: [PATCH] fix: Outreach template schema (#235) * fix schema * version bump * fix template types * fix template schema... again * fix outreach formatting * revert bad formatting * version fix --- package.json | 2 +- src/platforms/outreach/client.ts | 1 + src/platforms/outreach/schemas.ts | 24 +++++++++++++++--------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index ab0c1a6d..6adc7d4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@vesselapi/integrations", - "version": "1.0.24", + "version": "1.0.25", "description": "Vessel integrations", "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/src/platforms/outreach/client.ts b/src/platforms/outreach/client.ts index f31a1dfc..d1eac9a7 100644 --- a/src/platforms/outreach/client.ts +++ b/src/platforms/outreach/client.ts @@ -457,6 +457,7 @@ export const client = { schema: z.intersection( z.object({ data: z.array(outreachSequenceTemplate), + included: z.array(outreachTemplate).optional(), }), outreachPaginatedResponse, ), diff --git a/src/platforms/outreach/schemas.ts b/src/platforms/outreach/schemas.ts index 56bad36b..dc11bee9 100644 --- a/src/platforms/outreach/schemas.ts +++ b/src/platforms/outreach/schemas.ts @@ -3,15 +3,21 @@ import { z } from 'zod'; const outreachRelationship = z.object({ data: z.object({ - id: z.string(), + id: z.string().or(z.number()), }), }); +const outreachMultiRelationship = z.object({ + data: z.array( + z.object({ + id: z.string().or(z.number()), + }), + ), +}); export const outreachPaginatedResponse = z.object({ links: z .object({ next: z.string().nullish(), }) - .nullish(), }); @@ -170,14 +176,14 @@ export const outreachSequenceStep = custom.object({ positiveReplyCount: z.number().nullable(), replyCount: z.number().nullable(), scheduleCount: z.number().nullable(), - stepType: z.string().nullable(), + stepType: z.string(), taskAutoskipDelay: z.number().nullable(), taskNote: z.string().nullable(), updatedAt: custom.date().nullable(), }), relationships: z.object({ sequence: outreachRelationship.nullable(), - sequenceTemplates: outreachRelationship.nullable(), + sequenceTemplates: outreachMultiRelationship.nullable(), }), }); @@ -186,11 +192,11 @@ export const outreachTemplate = custom.object({ attributes: z.object({ archived: z.boolean().nullable(), archivedAt: custom.date().nullable(), - bccRecipients: z.string().nullable(), + bccRecipients: z.array(z.string()).nullable(), bodyHtml: z.string().nullable(), bodyText: z.string().nullable(), bounceCount: z.number().nullable(), - ccRecipients: z.string().nullable(), + ccRecipients: z.array(z.string()).nullable(), clickCount: z.number().nullable(), createdAt: custom.date().nullable(), deliverCount: z.number().nullable(), @@ -206,8 +212,8 @@ export const outreachTemplate = custom.object({ scheduleCount: z.number().nullable(), shareType: z.string().nullable(), subject: z.string().nullable(), - tags: z.string().nullable(), - toRecipients: z.string().nullable(), + tags: z.array(z.string()).nullable(), + toRecipients: z.array(z.string()).nullable(), trackLinks: z.boolean().nullable(), trackOpens: z.boolean().nullable(), updatedAt: custom.date().nullable(), @@ -235,7 +241,7 @@ export const outreachSequenceTemplate = custom.object({ updatedAt: custom.date().nullable(), }), relationships: z.object({ - template: outreachTemplate.nullable(), + template: outreachRelationship.nullable(), }), });