Skip to content

Commit d7989a8

Browse files
authored
making hs schema nullish instead of partial (#119)
* making hs schema nullish instead of partial * changing to nullable * small fixes
1 parent 2d0edfe commit d7989a8

File tree

2 files changed

+85
-79
lines changed

2 files changed

+85
-79
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vesselapi/integrations",
3-
"version": "0.0.85",
3+
"version": "0.0.86",
44
"description": "Vessel integrations",
55
"main": "dist/index.js",
66
"module": "dist/index.mjs",

src/platforms/hubspot/schemas.ts

+84-78
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ export const hubspotOwnerSchema = z
104104
id: hubspotIdSchema,
105105
createdAt: z.string().transform((val) => new Date(val)),
106106
updatedAt: z.string().transform((val) => new Date(val)),
107-
firstName: z.string(),
108-
lastName: z.string(),
109-
email: z.string(),
107+
firstName: z.string().nullable(),
108+
lastName: z.string().nullable(),
109+
email: z.string().nullable(),
110110
})
111111
.passthrough();
112112
export type HubspotOwner = z.infer<typeof hubspotOwnerSchema>;
@@ -116,17 +116,16 @@ export type HubspotOwner = z.infer<typeof hubspotOwnerSchema>;
116116
// -
117117
const contactPropertiesSchema = z
118118
.object({
119-
firstname: z.string(),
120-
lastname: z.string(),
121-
email: z.string(),
122-
jobtitle: z.string(),
123-
phone: z.string(),
124-
mobilephone: z.string(),
125-
hs_lead_status: z.string(),
126-
company: z.string(),
127-
hubspot_owner_id: z.string(),
119+
firstname: z.string().nullable(),
120+
lastname: z.string().nullable(),
121+
email: z.string().nullable(),
122+
jobtitle: z.string().nullable(),
123+
phone: z.string().nullable(),
124+
mobilephone: z.string().nullable(),
125+
hs_lead_status: z.string().nullable(),
126+
company: z.string().nullable(),
127+
hubspot_owner_id: z.string().nullable(),
128128
})
129-
.partial()
130129
.passthrough();
131130
export const contactProperties = Object.keys(contactPropertiesSchema.shape);
132131

@@ -158,17 +157,19 @@ export type HubspotContactUpdate = z.infer<
158157
// -
159158
const dealPropertiesSchema = z
160159
.object({
161-
amount: z.union([z.string(), z.number()]),
162-
dealname: z.string(),
163-
closedate: z.string().transform((val) => new Date(val)),
164-
dealstage: z.string(),
165-
hs_deal_stage_probability: z.union([z.string(), z.number()]),
166-
hs_projected_amount: z.union([z.string(), z.number()]),
167-
hs_is_closed_won: hubspotBooleanSchema,
168-
hs_is_closed: hubspotBooleanSchema,
169-
hubspot_owner_id: z.string(),
160+
amount: z.union([z.string(), z.number()]).nullable(),
161+
dealname: z.string().nullable(),
162+
closedate: z
163+
.string()
164+
.transform((val) => new Date(val))
165+
.nullable(),
166+
dealstage: z.string().nullable(),
167+
hs_deal_stage_probability: z.union([z.string(), z.number()]).nullable(),
168+
hs_projected_amount: z.union([z.string(), z.number()]).nullable(),
169+
hs_is_closed_won: hubspotBooleanSchema.nullable(),
170+
hs_is_closed: hubspotBooleanSchema.nullable(),
171+
hubspot_owner_id: z.string().nullable(),
170172
})
171-
.partial()
172173
.passthrough();
173174
export const dealProperties = Object.keys(dealPropertiesSchema.shape);
174175

@@ -196,21 +197,20 @@ export type HubspotDealUpdate = z.infer<typeof hubspotDealUpsertSchema> & {
196197
// -
197198
const companyPropertiesSchema = z
198199
.object({
199-
name: z.string(),
200-
website: z.string(),
201-
industry: z.string(),
202-
phone: z.string(),
203-
address: z.string(),
204-
city: z.string(),
205-
state: z.string(),
206-
zip: z.string(),
207-
country: z.string(),
208-
numberofemployees: z.union([z.string(), z.number()]),
209-
annualrevenue: z.union([z.string(), z.number()]),
210-
description: z.string(),
211-
hubspot_owner_id: z.string(),
200+
name: z.string().nullable(),
201+
website: z.string().nullable(),
202+
industry: z.string().nullable(),
203+
phone: z.string().nullable(),
204+
address: z.string().nullable(),
205+
city: z.string().nullable(),
206+
state: z.string().nullable(),
207+
zip: z.string().nullable(),
208+
country: z.string().nullable(),
209+
numberofemployees: z.union([z.string(), z.number()]).nullable(),
210+
annualrevenue: z.union([z.string(), z.number()]).nullable(),
211+
description: z.string().nullable(),
212+
hubspot_owner_id: z.string().nullable(),
212213
})
213-
.partial()
214214
.passthrough();
215215
export const companyProperties = Object.keys(companyPropertiesSchema.shape);
216216

@@ -247,11 +247,10 @@ export type HubspotCompanyUpdate = z.infer<
247247
// -
248248
const notePropertiesSchema = z
249249
.object({
250-
hubspot_owner_id: hubspotIdSchema,
251-
hs_note_body: z.string(),
252-
hs_timestamp: z.string(),
250+
hubspot_owner_id: hubspotIdSchema.nullable(),
251+
hs_note_body: z.string().nullable(),
252+
hs_timestamp: z.string().nullable(),
253253
})
254-
.partial()
255254
.passthrough();
256255
export const noteProperties = Object.keys(notePropertiesSchema.shape);
257256

@@ -277,14 +276,16 @@ export type HubspotNoteCreate = z.infer<typeof hubspotNoteUpsertSchema>;
277276
// -
278277
const taskPropertiesSchema = z
279278
.object({
280-
hs_task_body: z.string(),
281-
hs_task_subject: z.string(),
282-
hs_task_status: z.string(),
283-
hs_timestamp: z.string().transform((val) => new Date(val)),
284-
hs_task_priority: z.string(),
285-
hubspot_owner_id: hubspotIdSchema,
279+
hs_task_body: z.string().nullable(),
280+
hs_task_subject: z.string().nullable(),
281+
hs_task_status: z.string().nullable(),
282+
hs_timestamp: z
283+
.string()
284+
.transform((val) => new Date(val))
285+
.nullable(),
286+
hs_task_priority: z.string().nullable(),
287+
hubspot_owner_id: hubspotIdSchema.nullable(),
286288
})
287-
.partial()
288289
.passthrough();
289290
export const taskProperties = Object.keys(taskPropertiesSchema.shape);
290291

@@ -313,15 +314,14 @@ export type HubspotTaskCreate = z.infer<typeof hubspotTaskUpsertSchema>;
313314
// -
314315
const meetingPropertiesSchema = z
315316
.object({
316-
hs_timestamp: custom.date(),
317-
hs_meeting_title: z.string(),
318-
hs_meeting_body: z.string(),
319-
hs_meeting_location: z.string(),
320-
hs_meeting_start_time: custom.date().optional(),
321-
hs_meeting_end_time: custom.date().optional(),
322-
hubspot_owner_id: hubspotIdSchema,
317+
hs_timestamp: custom.date().nullable(),
318+
hs_meeting_title: z.string().nullable(),
319+
hs_meeting_body: z.string().nullable(),
320+
hs_meeting_location: z.string().nullable(),
321+
hs_meeting_start_time: custom.date().nullable(),
322+
hs_meeting_end_time: custom.date().nullable(),
323+
hubspot_owner_id: hubspotIdSchema.nullable(),
323324
})
324-
.partial()
325325
.passthrough();
326326
export const meetingProperties = Object.keys(meetingPropertiesSchema.shape);
327327

@@ -358,21 +358,23 @@ export const hubspotEmailDirectionSchema = z.enum([
358358

359359
const emailPropertiesSchema = z
360360
.object({
361-
hs_email_from_email: z.string(),
362-
hs_email_to_email: z.string(),
363-
hs_email_cc_email: z.string(),
364-
hs_email_bcc_email: z.string(),
365-
hs_email_html: z.string(),
366-
hs_email_text: z.string(),
367-
hs_email_direction: hubspotEmailDirectionSchema,
368-
hs_email_subject: z.string(),
369-
hs_email_bounce_error_detail_status_code: z.number(),
370-
hs_attachment_ids: z.array(hubspotIdSchema),
371-
hs_timestamp: z.string().transform((val) => new Date(val)),
372-
hs_email_status: z.string(),
373-
hubspot_owner_id: hubspotIdSchema,
361+
hs_email_from_email: z.string().nullable(),
362+
hs_email_to_email: z.string().nullable(),
363+
hs_email_cc_email: z.string().nullable(),
364+
hs_email_bcc_email: z.string().nullable(),
365+
hs_email_html: z.string().nullable(),
366+
hs_email_text: z.string().nullable(),
367+
hs_email_direction: hubspotEmailDirectionSchema.nullable(),
368+
hs_email_subject: z.string().nullable(),
369+
hs_email_bounce_error_detail_status_code: z.number().nullable(),
370+
hs_attachment_ids: z.array(hubspotIdSchema).nullable(),
371+
hs_timestamp: z
372+
.string()
373+
.transform((val) => new Date(val))
374+
.nullable(),
375+
hs_email_status: z.string().nullable(),
376+
hubspot_owner_id: hubspotIdSchema.nullable(),
374377
})
375-
.partial()
376378
.passthrough();
377379
export const emailProperties = Object.keys(emailPropertiesSchema.shape);
378380

@@ -421,14 +423,18 @@ export const callDispositionsSchema = z.array(
421423

422424
const callPropertiesSchema = z
423425
.object({
424-
hs_call_disposition: z.string(),
425-
hs_call_direction: z.union([z.literal('INBOUND'), z.literal('OUTBOUND')]),
426-
hs_timestamp: z.string().transform((val) => new Date(val)),
427-
hs_call_body: z.string(),
428-
hs_call_title: z.string(),
429-
hubspot_owner_id: hubspotIdSchema,
426+
hs_call_disposition: z.string().nullable(),
427+
hs_call_direction: z
428+
.union([z.literal('INBOUND'), z.literal('OUTBOUND')])
429+
.nullable(),
430+
hs_timestamp: z
431+
.string()
432+
.transform((val) => new Date(val))
433+
.nullable(),
434+
hs_call_body: z.string().nullable(),
435+
hs_call_title: z.string().nullable(),
436+
hubspot_owner_id: hubspotIdSchema.nullable(),
430437
})
431-
.partial()
432438
.passthrough();
433439
export const callProperties = Object.keys(callPropertiesSchema.shape);
434440

@@ -464,7 +470,7 @@ export type HubspotCallUpdate = z.infer<typeof hubspotCallUpdateSchema> & {
464470
export const hubspotContactListSchema = z
465471
.object({
466472
listId: hubspotIdSchema,
467-
name: z.string(),
473+
name: z.string().nullable(),
468474
dynamic: z.boolean(),
469475
createdAt: z.number().transform((val) => new Date(val)),
470476
updatedAt: z.number().transform((val) => new Date(val)),

0 commit comments

Comments
 (0)