@corsair-dev/hubspot 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../api.test.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAuBvB,OAAO,eAAe,CAAC"}
1
+ {"version":3,"file":"api.test.d.ts","sourceRoot":"","sources":["../api.test.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAwBvB,OAAO,eAAe,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import type { HubSpotEndpoints } from '../index';
2
2
  export declare const get: HubSpotEndpoints['contactsGet'];
3
3
  export declare const getMany: HubSpotEndpoints['contactsGetMany'];
4
- export declare const createOrUpdate: HubSpotEndpoints['contactsCreateOrUpdate'];
4
+ export declare const create: HubSpotEndpoints['contactsCreate'];
5
+ export declare const update: HubSpotEndpoints['contactsUpdate'];
5
6
  export declare const deleteContact: HubSpotEndpoints['contactsDelete'];
6
7
  export declare const getRecentlyCreated: HubSpotEndpoints['contactsGetRecentlyCreated'];
7
8
  export declare const getRecentlyUpdated: HubSpotEndpoints['contactsGetRecentlyUpdated'];
@@ -1 +1 @@
1
- {"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../endpoints/contacts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAOjD,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,aAAa,CA+B/C,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAoCvD,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,wBAAwB,CAyBpE,CAAC;AAEH,eAAO,MAAM,aAAa,EAAE,gBAAgB,CAAC,gBAAgB,CAwB5D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,4BAA4B,CAiB5E,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,4BAA4B,CAiB5E,CAAC;AAEH,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,gBAAgB,CA6BrD,CAAC"}
1
+ {"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../endpoints/contacts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAQjD,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,aAAa,CA+B/C,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,CAAC,iBAAiB,CAoCvD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,gBAAgB,CAwBrD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,gBAAgB,CA2BrD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,gBAAgB,CAAC,gBAAgB,CAwB5D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,4BAA4B,CAiB5E,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,4BAA4B,CAiB5E,CAAC;AAEH,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,gBAAgB,CA6BrD,CAAC"}
@@ -53,7 +53,7 @@ export declare const ContactsEndpoints: {
53
53
  } | undefined;
54
54
  } | undefined;
55
55
  }>;
56
- createOrUpdate: (ctx: import("..").HubSpotContext, args: {
56
+ create: (ctx: import("..").HubSpotContext, args: {
57
57
  properties?: Record<string, string> | undefined;
58
58
  associations?: {
59
59
  to: {
@@ -78,6 +78,23 @@ export declare const ContactsEndpoints: {
78
78
  }[];
79
79
  }> | undefined;
80
80
  }>;
81
+ update: (ctx: import("..").HubSpotContext, args: {
82
+ contactId: string;
83
+ properties?: Record<string, string> | undefined;
84
+ }) => Promise<{
85
+ [x: string]: unknown;
86
+ id: string;
87
+ properties?: Record<string, string> | undefined;
88
+ createdAt?: Date | null | undefined;
89
+ updatedAt?: Date | null | undefined;
90
+ archived?: boolean | undefined;
91
+ associations?: Record<string, string[] | {
92
+ results: {
93
+ id: string;
94
+ type?: string | undefined;
95
+ }[];
96
+ }> | undefined;
97
+ }>;
81
98
  delete: (ctx: import("..").HubSpotContext, args: {
82
99
  contactId: string;
83
100
  }) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../endpoints/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQ7B,CAAC;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS9B,CAAC;AAEF,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS1B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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EF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAM5B,CAAC;AAEF,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAKhC,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAGjC,CAAC;AAEF,cAAc,SAAS,CAAC"}
@@ -16,7 +16,7 @@ export declare const HubSpotEndpointInputSchemas: {
16
16
  associations: z.ZodOptional<z.ZodArray<z.ZodString>>;
17
17
  archived: z.ZodOptional<z.ZodBoolean>;
18
18
  }, z.core.$strip>;
19
- readonly contactsCreateOrUpdate: z.ZodObject<{
19
+ readonly contactsCreate: z.ZodObject<{
20
20
  properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
21
21
  associations: z.ZodOptional<z.ZodArray<z.ZodObject<{
22
22
  to: z.ZodObject<{
@@ -28,6 +28,10 @@ export declare const HubSpotEndpointInputSchemas: {
28
28
  }, z.core.$strip>>;
29
29
  }, z.core.$strip>>>;
30
30
  }, z.core.$strip>;
31
+ readonly contactsUpdate: z.ZodObject<{
32
+ contactId: z.ZodString;
33
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
34
+ }, z.core.$strip>;
31
35
  readonly contactsDelete: z.ZodObject<{
32
36
  contactId: z.ZodString;
33
37
  }, z.core.$strip>;
@@ -318,7 +322,20 @@ export declare const HubSpotEndpointOutputSchemas: {
318
322
  }, z.core.$strip>>;
319
323
  }, z.core.$strip>>;
320
324
  }, z.core.$loose>;
321
- readonly contactsCreateOrUpdate: z.ZodObject<{
325
+ readonly contactsCreate: z.ZodObject<{
326
+ id: z.ZodString;
327
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
328
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
329
+ updatedAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
330
+ archived: z.ZodOptional<z.ZodBoolean>;
331
+ associations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
332
+ results: z.ZodArray<z.ZodObject<{
333
+ id: z.ZodString;
334
+ type: z.ZodOptional<z.ZodString>;
335
+ }, z.core.$strip>>;
336
+ }, z.core.$strip>, z.ZodArray<z.ZodString>]>>>;
337
+ }, z.core.$loose>;
338
+ readonly contactsUpdate: z.ZodObject<{
322
339
  id: z.ZodString;
323
340
  properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
324
341
  createdAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
@@ -834,7 +851,8 @@ export type HubSpotEndpointOutputs = {
834
851
  };
835
852
  export type GetContactResponse = z.infer<typeof HubSpotEndpointOutputSchemas.contactsGet>;
836
853
  export type GetManyContactsResponse = z.infer<typeof HubSpotEndpointOutputSchemas.contactsGetMany>;
837
- export type CreateOrUpdateContactResponse = z.infer<typeof HubSpotEndpointOutputSchemas.contactsCreateOrUpdate>;
854
+ export type CreateContactResponse = z.infer<typeof HubSpotEndpointOutputSchemas.contactsCreate>;
855
+ export type UpdateContactResponse = z.infer<typeof HubSpotEndpointOutputSchemas.contactsUpdate>;
838
856
  export type GetCompanyResponse = z.infer<typeof HubSpotEndpointOutputSchemas.companiesGet>;
839
857
  export type GetManyCompaniesResponse = z.infer<typeof HubSpotEndpointOutputSchemas.companiesGetMany>;
840
858
  export type CreateCompanyResponse = z.infer<typeof HubSpotEndpointOutputSchemas.companiesCreate>;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../endpoints/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE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K,CACvC,OAAO,4BAA4B,CAAC,WAAW,CAC/C,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CACtC,OAAO,4BAA4B,CAAC,UAAU,CAC9C,CAAC;AACF,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,4BAA4B,CAAC,cAAc,CAClD,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CACzC,OAAO,4BAA4B,CAAC,aAAa,CACjD,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CACzC,OAAO,4BAA4B,CAAC,aAAa,CACjD,CAAC;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAC1C,OAAO,4BAA4B,CAAC,cAAc,CAClD,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC/C,OAAO,4BAA4B,CAAC,kBAAkB,CACtD,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,4BAA4B,CAAC,iBAAiB,CACrD,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,4BAA4B,CAAC,sBAAsB,CAC1D,CAAC;AACF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAClD,OAAO,4BAA4B,CAAC,yBAAyB,CAC7D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -10,7 +10,8 @@ type HubSpotEndpoint<K extends keyof HubSpotEndpointOutputs> = CorsairEndpoint<H
10
10
  export type HubSpotEndpoints = {
11
11
  contactsGet: HubSpotEndpoint<'contactsGet'>;
12
12
  contactsGetMany: HubSpotEndpoint<'contactsGetMany'>;
13
- contactsCreateOrUpdate: HubSpotEndpoint<'contactsCreateOrUpdate'>;
13
+ contactsCreate: HubSpotEndpoint<'contactsCreate'>;
14
+ contactsUpdate: HubSpotEndpoint<'contactsUpdate'>;
14
15
  contactsDelete: HubSpotEndpoint<'contactsDelete'>;
15
16
  contactsGetRecentlyCreated: HubSpotEndpoint<'contactsGetRecentlyCreated'>;
16
17
  contactsGetRecentlyUpdated: HubSpotEndpoint<'contactsGetRecentlyUpdated'>;
@@ -64,7 +65,8 @@ declare const hubspotEndpointsNested: {
64
65
  readonly contacts: {
65
66
  readonly get: HubSpotEndpoint<"contactsGet">;
66
67
  readonly getMany: HubSpotEndpoint<"contactsGetMany">;
67
- readonly createOrUpdate: HubSpotEndpoint<"contactsCreateOrUpdate">;
68
+ readonly create: HubSpotEndpoint<"contactsCreate">;
69
+ readonly update: HubSpotEndpoint<"contactsUpdate">;
68
70
  readonly delete: HubSpotEndpoint<"contactsDelete">;
69
71
  readonly getRecentlyCreated: HubSpotEndpoint<"contactsGetRecentlyCreated">;
70
72
  readonly getRecentlyUpdated: HubSpotEndpoint<"contactsGetRecentlyUpdated">;
@@ -166,7 +168,7 @@ export declare const hubspotEndpointSchemas: {
166
168
  }, z.core.$strip>>;
167
169
  }, z.core.$loose>;
168
170
  };
169
- readonly 'contacts.createOrUpdate': {
171
+ readonly 'contacts.create': {
170
172
  readonly input: z.ZodObject<{
171
173
  properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
172
174
  associations: z.ZodOptional<z.ZodArray<z.ZodObject<{
@@ -193,6 +195,25 @@ export declare const hubspotEndpointSchemas: {
193
195
  }, z.core.$strip>, z.ZodArray<z.ZodString>]>>>;
194
196
  }, z.core.$loose>;
195
197
  };
198
+ readonly 'contacts.update': {
199
+ readonly input: z.ZodObject<{
200
+ contactId: z.ZodString;
201
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
202
+ }, z.core.$strip>;
203
+ readonly output: z.ZodObject<{
204
+ id: z.ZodString;
205
+ properties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
206
+ createdAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
207
+ updatedAt: z.ZodOptional<z.ZodNullable<z.ZodCoercedDate<unknown>>>;
208
+ archived: z.ZodOptional<z.ZodBoolean>;
209
+ associations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodObject<{
210
+ results: z.ZodArray<z.ZodObject<{
211
+ id: z.ZodString;
212
+ type: z.ZodOptional<z.ZodString>;
213
+ }, z.core.$strip>>;
214
+ }, z.core.$strip>, z.ZodArray<z.ZodString>]>>>;
215
+ }, z.core.$loose>;
216
+ };
196
217
  readonly 'contacts.delete': {
197
218
  readonly input: z.ZodObject<{
198
219
  contactId: z.ZodString;
@@ -1173,6 +1194,6 @@ export type ExternalHubSpotPlugin<PluginOptions extends HubSpotPluginOptions> =
1173
1194
  export declare function hubspot<const PluginOptions extends HubSpotPluginOptions>(incomingOptions?: HubSpotPluginOptions & PluginOptions): ExternalHubSpotPlugin<PluginOptions>;
1174
1195
  export { createHubSpotEventMatch, verifyHubSpotWebhookSignature, } from './webhooks/types';
1175
1196
  export type { CompanyCreatedEvent, CompanyCreatedEventType, CompanyDeletedEvent, CompanyDeletedEventType, CompanyUpdatedEvent, CompanyUpdatedEventType, ContactCreatedEvent, ContactCreatedEventType, ContactDeletedEvent, ContactDeletedEventType, ContactUpdatedEvent, ContactUpdatedEventType, DealCreatedEvent, DealCreatedEventType, DealDeletedEvent, DealDeletedEventType, DealUpdatedEvent, DealUpdatedEventType, HubSpotWebhookEventType, HubSpotWebhookOutputs, HubSpotWebhookPayload, HubSpotWebhookPayloadType, TicketCreatedEvent, TicketCreatedEventType, TicketDeletedEvent, TicketDeletedEventType, TicketUpdatedEvent, TicketUpdatedEventType, } from './webhooks/types';
1176
- export type { AddContactToListResponse, CreateCompanyResponse, CreateDealResponse, CreateEngagementResponse, CreateOrUpdateContactResponse, CreateTicketResponse, GetCompanyResponse, GetContactResponse, GetDealResponse, GetEngagementResponse, GetManyCompaniesResponse, GetManyContactsResponse, GetManyDealsResponse, GetManyEngagementsResponse, GetManyTicketsResponse, GetTicketResponse, HubSpotEndpointInputs, HubSpotEndpointOutputs, RemoveContactFromListResponse, SearchCompanyByDomainResponse, UpdateCompanyResponse, UpdateDealResponse, UpdateTicketResponse, } from './endpoints/types';
1197
+ export type { AddContactToListResponse, CreateCompanyResponse, CreateContactResponse, CreateDealResponse, CreateEngagementResponse, CreateTicketResponse, GetCompanyResponse, GetContactResponse, GetDealResponse, GetEngagementResponse, GetManyCompaniesResponse, GetManyContactsResponse, GetManyDealsResponse, GetManyEngagementsResponse, GetManyTicketsResponse, GetTicketResponse, HubSpotEndpointInputs, HubSpotEndpointOutputs, RemoveContactFromListResponse, SearchCompanyByDomainResponse, UpdateCompanyResponse, UpdateContactResponse, UpdateDealResponse, UpdateTicketResponse, } from './endpoints/types';
1177
1198
  export type { HubSpotCredentials } from './schema';
1178
1199
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACR,uBAAuB,EAGvB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EACX,qBAAqB,EACrB,sBAAsB,EACtB,MAAM,aAAa,CAAC;AAcrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,EACX,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,oBAAoB,EACpB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB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f,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACpB,0BAA0B,EAC1B,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,6BAA6B,EAC7B,6BAA6B,EAC7B,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,mBAAmB,CAAC;AAM3B,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{z as u}from"zod";import{logEventFromContext as E}from"corsair/core";import{request as it}from"corsair/http";var v=class extends Error{constructor(s,r){super(s);this.code=r;this.name="HubSpotAPIError"}},ct="https://api.hubapi.com";async function d(t,a,s={}){let{method:r="GET",body:n,query:o}=s,p={BASE:ct,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TOKEN:a,HEADERS:{"Content-Type":"application/json"}},B={method:r,url:t,body:r==="POST"||r==="PUT"||r==="PATCH"?n:void 0,mediaType:"application/json",query:r==="GET"?o:void 0};try{return await it(p,B)}catch(g){throw g&&typeof g=="object"&&"status"in g&&typeof g.status=="number"?new v(g instanceof Error?g.message:"HubSpot API error",g.status):new v(g instanceof Error?g.message:"Unknown error")}}var ae=async(t,a)=>{let{companyId:s,...r}=a,n=`/crm/v3/objects/companies/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.companies)try{await t.db.companies.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save company to database:",p)}return await E(t,"hubspot.companies.get",{...a},"completed"),o},ne=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/companies",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.companies)try{for(let o of n.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await E(t,"hubspot.companies.getMany",{...a},"completed"),n},se=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/companies",t.key,{method:"POST",body:s});if(n&&t.db.companies)try{await t.db.companies.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save company to database:",o)}return await E(t,"hubspot.companies.create",{...a},"completed"),n},re=async(t,a)=>{let{companyId:s,...r}=a,n=`/crm/v3/objects/companies/${s}`,o=await d(n,t.key,{method:"PATCH",body:r});if(o&&t.db.companies)try{await t.db.companies.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save company to database:",p)}return await E(t,"hubspot.companies.update",{...a},"completed"),o},pe=async(t,a)=>{let{companyId:s}=a,r=`/crm/v3/objects/companies/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.companies)try{await t.db.companies.deleteByEntityId(s)}catch(n){console.warn("Failed to delete company from database:",n)}await E(t,"hubspot.companies.delete",{...a},"completed")},ie=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/companies",t.key,{query:s});if(n.results&&t.db.companies)try{for(let o of n.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await E(t,"hubspot.companies.getRecentlyCreated",{...a},"completed"),n},ce=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/companies",t.key,{query:s});if(n.results&&t.db.companies)try{for(let o of n.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await E(t,"hubspot.companies.getRecentlyUpdated",{...a},"completed"),n},de=async(t,a)=>{let{domain:s,...r}=a,o=await d("/crm/v3/objects/companies/search",t.key,{query:{...r,domain:s,properties:r.properties?.join(",")}});return await E(t,"hubspot.companies.searchByDomain",{...a},"completed"),o};import{logEventFromContext as le}from"corsair/core";var ye=async(t,a)=>{let{listId:s,...r}=a,n=`/contacts/v1/lists/${s}/add`,o=await d(n,t.key,{method:"POST",body:r});return await le(t,"hubspot.contactLists.addContact",{...a},"completed"),o},ue=async(t,a)=>{let{listId:s,...r}=a,n=`/contacts/v1/lists/${s}/remove`,o=await d(n,t.key,{method:"POST",body:r});return await le(t,"hubspot.contactLists.removeContact",{...a},"completed"),o};import{logEventFromContext as H}from"corsair/core";var me=async(t,a)=>{let{contactId:s,...r}=a,n=`/crm/v3/objects/contacts/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save contact to database:",p)}return await H(t,"hubspot.contacts.get",{...a},"completed"),o},be=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/contacts",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.contacts)try{for(let o of n.results)await t.db.contacts.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save contacts to database:",o)}return await H(t,"hubspot.contacts.getMany",{...a},"completed"),n},ge=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/contacts",t.key,{method:"POST",body:s});if(n&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save contact to database:",o)}return await H(t,"hubspot.contacts.createOrUpdate",{...a},"completed"),n},he=async(t,a)=>{let{contactId:s}=a,r=`/crm/v3/objects/contacts/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.contacts)try{await t.db.contacts.deleteByEntityId(s)}catch(n){console.warn("Failed to delete contact from database:",n)}await H(t,"hubspot.contacts.delete",{...a},"completed")},Se=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/contacts",t.key,{query:s});return await H(t,"hubspot.contacts.getRecentlyCreated",{...a},"completed"),n},Ce=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/contacts",t.key,{query:s});return await H(t,"hubspot.contacts.getRecentlyUpdated",{...a},"completed"),n},Ee=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/contacts/search",t.key,{method:"POST",body:s});if(n.results&&t.db.contacts)try{for(let o of n.results)await t.db.contacts.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save contacts to database:",o)}return await H(t,"hubspot.contacts.search",{...a},"completed"),n};import{logEventFromContext as k}from"corsair/core";var ke=async(t,a)=>{let{dealId:s,...r}=a,n=`/crm/v3/objects/deals/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.deals)try{await t.db.deals.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save deal to database:",p)}return await k(t,"hubspot.deals.get",{...a},"completed"),o},fe=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/deals",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.deals)try{for(let o of n.results)await t.db.deals.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save deals to database:",o)}return await k(t,"hubspot.deals.getMany",{...a},"completed"),n},ve=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/deals",t.key,{method:"POST",body:s});if(n&&t.db.deals)try{await t.db.deals.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save deal to database:",o)}return await k(t,"hubspot.deals.create",{...a},"completed"),n},He=async(t,a)=>{let{dealId:s,...r}=a,n=`/crm/v3/objects/deals/${s}`,o=await d(n,t.key,{method:"PATCH",body:r});if(o&&t.db.deals)try{await t.db.deals.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to update deal in database:",p)}return await k(t,"hubspot.deals.update",{...a},"completed"),o},Re=async(t,a)=>{let{dealId:s}=a,r=`/crm/v3/objects/deals/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.deals)try{await t.db.deals.deleteByEntityId(s)}catch(n){console.warn("Failed to delete deal from database:",n)}await k(t,"hubspot.deals.delete",{...a},"completed")},we=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/deals",t.key,{query:s});return await k(t,"hubspot.deals.getRecentlyCreated",{...a},"completed"),n},Ie=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/deals",t.key,{query:s});return await k(t,"hubspot.deals.getRecentlyUpdated",{...a},"completed"),n},De=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/deals/search",t.key,{method:"POST",body:s});return await k(t,"hubspot.deals.search",{...a},"completed"),n};import{logEventFromContext as G}from"corsair/core";var Te=async(t,a)=>{let{engagementId:s}=a,r=`/crm/v3/objects/engagements/${s}`,n=await d(r,t.key);if(n&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(n.id,{...n})}catch(o){console.warn("Failed to save engagement to database:",o)}return await G(t,"hubspot.engagements.get",{...a},"completed"),n},je=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/engagements",t.key,{query:s});if(n.results&&t.db.engagements)try{for(let o of n.results)await t.db.engagements.upsertByEntityId(o.id,{...o})}catch(o){console.warn("Failed to save engagements to database:",o)}return await G(t,"hubspot.engagements.getMany",{...a},"completed"),n},Ge=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/engagements",t.key,{method:"POST",body:s});if(n&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(n.id,{...n})}catch(o){console.warn("Failed to save engagement to database:",o)}return await G(t,"hubspot.engagements.create",{...a},"completed"),n},Ue=async(t,a)=>{let{engagementId:s}=a,r=`/crm/v3/objects/engagements/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.engagements)try{await t.db.engagements.deleteByEntityId(s)}catch(n){console.warn("Failed to delete engagement from database:",n)}await G(t,"hubspot.engagements.delete",{...a},"completed")};import{logEventFromContext as I}from"corsair/core";var Ae=async(t,a)=>{let{ticketId:s,...r}=a,n=`/crm/v3/objects/tickets/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save ticket to database:",p)}return await I(t,"hubspot.tickets.get",{...a},"completed"),o},Me=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/tickets",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.tickets)try{for(let o of n.results)await t.db.tickets.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save tickets to database:",o)}return await I(t,"hubspot.tickets.getMany",{...a},"completed"),n},We=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/tickets",t.key,{method:"POST",body:s});if(n&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save ticket to database:",o)}return await I(t,"hubspot.tickets.create",{...a},"completed"),n},Oe=async(t,a)=>{let{ticketId:s,...r}=a,n=`/crm/v3/objects/tickets/${s}`,o=await d(n,t.key,{method:"PATCH",body:r});if(o&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to update ticket in database:",p)}return await I(t,"hubspot.tickets.update",{...a},"completed"),o},Pe=async(t,a)=>{let{ticketId:s}=a,r=`/crm/v3/objects/tickets/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.tickets)try{await t.db.tickets.deleteByEntityId(s)}catch(n){console.warn("Failed to delete ticket from database:",n)}await I(t,"hubspot.tickets.delete",{...a},"completed")};import{z as e}from"zod";var gt=e.object({contactId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),ht=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),St=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),Ct=e.object({contactId:e.string()}),Et=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),kt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),ft=e.enum(["BETWEEN","CONTAINS_TOKEN","EQ","GT","GTE","HAS_PROPERTY","IN","LT","LTE","NEQ","NOT_CONTAINS_TOKEN","NOT_HAS_PROPERTY","NOT_IN"]),vt=e.object({operator:ft,propertyName:e.string(),highValue:e.string().optional(),value:e.string().optional(),values:e.array(e.string()).optional()}),Le=e.object({filters:e.array(vt)}),Ht=e.enum(["ASCENDING","DESCENDING"]),Be=e.object({propertyName:e.string(),direction:Ht}),Rt=e.object({id:e.string(),type:e.string().optional()}),wt=e.object({results:e.array(Rt)}),T=e.record(e.string(),e.union([wt,e.array(e.string())])),It=e.object({query:e.string().optional(),limit:e.number().optional(),after:e.string().optional(),sorts:e.array(Be).optional(),properties:e.array(e.string()).optional(),filterGroups:e.array(Le).optional()}),Dt=e.object({companyId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),Tt=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),jt=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),Gt=e.object({companyId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Ut=e.object({companyId:e.string()}),At=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Mt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Wt=e.object({domain:e.string(),properties:e.array(e.string()).optional()}),Ot=e.object({dealId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),Pt=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),xt=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),Lt=e.object({dealId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Bt=e.object({dealId:e.string()}),Ft=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Nt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),zt=e.object({query:e.string().optional(),limit:e.number().optional(),after:e.string().optional(),sorts:e.array(Be).optional(),properties:e.array(e.string()).optional(),filterGroups:e.array(Le).optional()}),Vt=e.object({ticketId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),_t=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),qt=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),$t=e.object({ticketId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Kt=e.object({ticketId:e.string()}),Qt=e.object({engagementId:e.string()}),Yt=e.object({limit:e.number().optional(),after:e.string().optional()}),Jt=e.object({engagement:e.object({active:e.boolean().optional(),type:e.string(),timestamp:e.number().optional()}),associations:e.object({contactIds:e.array(e.number()).optional(),companyIds:e.array(e.number()).optional(),dealIds:e.array(e.number()).optional(),ownerIds:e.array(e.number()).optional()}).optional(),metadata:e.record(e.string(),e.any()).optional()}),Xt=e.object({engagementId:e.string()}),Zt=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),eo=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),l={contactsGet:gt,contactsGetMany:ht,contactsCreateOrUpdate:St,contactsDelete:Ct,contactsGetRecentlyCreated:Et,contactsGetRecentlyUpdated:kt,contactsSearch:It,companiesGet:Dt,companiesGetMany:Tt,companiesCreate:jt,companiesUpdate:Gt,companiesDelete:Ut,companiesGetRecentlyCreated:At,companiesGetRecentlyUpdated:Mt,companiesSearchByDomain:Wt,dealsGet:Ot,dealsGetMany:Pt,dealsCreate:xt,dealsUpdate:Lt,dealsDelete:Bt,dealsGetRecentlyCreated:Ft,dealsGetRecentlyUpdated:Nt,dealsSearch:zt,ticketsGet:Vt,ticketsGetMany:_t,ticketsCreate:qt,ticketsUpdate:$t,ticketsDelete:Kt,engagementsGet:Qt,engagementsGetMany:Yt,engagementsCreate:Jt,engagementsDelete:Xt,contactListsAddContact:Zt,contactListsRemoveContact:eo},N=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),D=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),M=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),W=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),z=e.object({id:e.string(),engagement:e.object({id:e.number().optional(),portalId:e.number().optional(),active:e.boolean().optional(),createdAt:e.number().optional(),lastUpdated:e.number().optional(),createdBy:e.number().optional(),modifiedBy:e.number().optional(),ownerId:e.number().optional(),type:e.string().optional(),timestamp:e.number().optional()}).optional(),associations:T.optional(),metadata:e.record(e.string(),e.any()).optional()}).loose(),R=e.object({next:e.object({after:e.string()}).optional(),prev:e.object({before:e.string()}).optional()}),U=e.object({total:e.number().optional(),results:e.array(N).optional(),paging:R.optional()}).loose(),F=e.object({total:e.number().optional(),results:e.array(D).optional(),paging:R.optional()}).loose(),A=e.object({total:e.number().optional(),results:e.array(M).optional(),paging:R.optional()}).loose(),to=e.object({results:e.array(W).optional(),paging:R.optional()}).loose(),oo=e.object({results:e.array(z).optional(),paging:R.optional()}).loose(),ao=e.object({total:e.number().optional(),results:e.array(D).optional(),paging:R.optional()}).loose(),xe=e.object({updated:e.array(e.number()).optional(),discarded:e.array(e.number()).optional(),invalidVids:e.array(e.number()).optional(),invalidEmails:e.array(e.string()).optional()}),y={contactsGet:N,contactsGetMany:U,contactsCreateOrUpdate:N,contactsDelete:e.void(),contactsGetRecentlyCreated:U,contactsGetRecentlyUpdated:U,contactsSearch:U,companiesGet:D,companiesGetMany:F,companiesCreate:D,companiesUpdate:D,companiesDelete:e.void(),companiesGetRecentlyCreated:F,companiesGetRecentlyUpdated:F,companiesSearchByDomain:ao,dealsGet:M,dealsGetMany:A,dealsCreate:M,dealsUpdate:M,dealsDelete:e.void(),dealsGetRecentlyCreated:A,dealsGetRecentlyUpdated:A,dealsSearch:A,ticketsGet:W,ticketsGetMany:to,ticketsCreate:W,ticketsUpdate:W,ticketsDelete:e.void(),engagementsGet:z,engagementsGetMany:oo,engagementsCreate:z,engagementsDelete:e.void(),contactListsAddContact:xe,contactListsRemoveContact:xe};var f={get:me,getMany:be,createOrUpdate:ge,delete:he,getRecentlyCreated:Se,getRecentlyUpdated:Ce,search:Ee},S={get:ae,getMany:ne,create:se,update:re,delete:pe,getRecentlyCreated:ie,getRecentlyUpdated:ce,searchByDomain:de},C={get:ke,getMany:fe,create:ve,update:He,delete:Re,getRecentlyCreated:we,getRecentlyUpdated:Ie,search:De},w={get:Ae,getMany:Me,create:We,update:Oe,delete:Pe},j={get:Te,getMany:je,create:Ge,delete:Ue},V={addContact:ye,removeContact:ue};import{ApiError as Fe}from"corsair/http";var Ne={PERMISSION_ERROR:{match:(t,a)=>{if((t instanceof Fe&&t.status===403||t instanceof v&&t.code===403)&&a.operation.toLowerCase().includes("tickets"))return!0;let s=t.message.toLowerCase();return s.includes("forbidden")||s.includes("permission denied")||s.includes("access denied")},handler:async(t,a)=>({maxRetries:0})},VALIDATION_ERROR:{match:(t,a)=>!!((t instanceof Fe&&t.status===400||t instanceof v&&t.code===400)&&a.operation.toLowerCase().includes("engagements.create")),handler:async(t,a)=>({maxRetries:0})},DEFAULT:{match:(t,a)=>!0,handler:async(t,a)=>(console.error(`[corsair:${a.pluginId}:${a.operation}]`,{error:t.message,input:a.input}),{maxRetries:0})}};import{z as Ke}from"zod";import{z as i}from"zod";var ze=i.object({id:i.string(),properties:i.record(i.string(),i.any()).optional(),createdAt:i.coerce.date().nullable().optional(),updatedAt:i.coerce.date().nullable().optional(),archived:i.boolean().optional()}),Ve=i.object({id:i.string(),properties:i.record(i.string(),i.any()).optional(),createdAt:i.coerce.date().nullable().optional(),updatedAt:i.coerce.date().nullable().optional(),archived:i.boolean().optional()}),_e=i.object({id:i.string(),properties:i.record(i.string(),i.any()).optional(),createdAt:i.coerce.date().nullable().optional(),updatedAt:i.coerce.date().nullable().optional(),archived:i.boolean().optional()}),qe=i.object({id:i.string(),properties:i.record(i.string(),i.any()).optional(),createdAt:i.coerce.date().nullable().optional(),updatedAt:i.coerce.date().nullable().optional(),archived:i.boolean().optional()}),$e=i.object({id:i.string(),engagement:i.object({id:i.number().optional(),portalId:i.number().optional(),active:i.boolean().optional(),createdAt:i.number().optional(),lastUpdated:i.number().optional(),createdBy:i.number().optional(),modifiedBy:i.number().optional(),ownerId:i.number().optional(),type:i.string().optional(),timestamp:i.number().optional()}).optional(),associations:i.record(i.string(),i.any()).optional(),metadata:i.record(i.string(),i.any()).optional()});var xo=Ke.object({token:Ke.string()}),Qe={version:"1.0.0",entities:{contacts:ze,companies:Ve,deals:_e,tickets:qe,engagements:$e}};import{verifyHmacSignature as no}from"corsair/http";import{z as c}from"zod";var h=c.object({subscriptionId:c.number(),portalId:c.number(),occurredAt:c.number(),subscriptionType:c.string(),attemptNumber:c.number(),objectId:c.number().optional(),propertyName:c.string().optional(),propertyValue:c.string().optional(),changeSource:c.string().optional(),eventId:c.string().optional()}),_=h.extend({subscriptionType:c.literal("contact.creation"),objectId:c.number()}),q=h.extend({subscriptionType:c.literal("contact.propertyChange"),objectId:c.number(),propertyName:c.string(),propertyValue:c.string()}),$=h.extend({subscriptionType:c.literal("contact.deletion"),objectId:c.number()}),K=h.extend({subscriptionType:c.literal("company.creation"),objectId:c.number()}),Q=h.extend({subscriptionType:c.literal("company.propertyChange"),objectId:c.number(),propertyName:c.string(),propertyValue:c.string()}),Y=h.extend({subscriptionType:c.literal("company.deletion"),objectId:c.number()}),J=h.extend({subscriptionType:c.literal("deal.creation"),objectId:c.number()}),X=h.extend({subscriptionType:c.literal("deal.propertyChange"),objectId:c.number(),propertyName:c.string(),propertyValue:c.string()}),Z=h.extend({subscriptionType:c.literal("deal.deletion"),objectId:c.number()}),ee=h.extend({subscriptionType:c.literal("ticket.creation"),objectId:c.number()}),te=h.extend({subscriptionType:c.literal("ticket.propertyChange"),objectId:c.number(),propertyName:c.string(),propertyValue:c.string()}),oe=h.extend({subscriptionType:c.literal("ticket.deletion"),objectId:c.number()}),No=c.union([_,q,$,K,Q,Y,J,X,Z,ee,te,oe]);function so(t){return typeof t=="string"?JSON.parse(t):t}function m(t,a){if(!a)return{valid:!1};let s=t.rawBody;if(!s)return{valid:!1,error:"Missing raw body for signature verification"};let r=t.headers,n=Array.isArray(r["x-hubspot-signature-v3"])?r["x-hubspot-signature-v3"][0]:r["x-hubspot-signature-v3"];return n?no(s,a,n)?{valid:!0}:{valid:!1,error:"Invalid signature"}:{valid:!1,error:"Missing x-hubspot-signature-v3 header"}}function b(t){return a=>{let s=so(a.body);return(Array.isArray(s)?s:[s]).some(n=>typeof n=="object"&&n!==null&&"subscriptionType"in n&&typeof n.subscriptionType=="string"&&n.subscriptionType===t)}}var Ye={match:b("company.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="company.creation"&&(console.log("\u{1F3E2} HubSpot Company Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.companies&&o.objectId))try{await t.db.companies.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save company to database:",p)}return{success:!0,data:{success:!0}}}},Je={match:b("company.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="company.propertyChange"&&(console.log("\u{1F4DD} HubSpot Company Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.companies&&o.objectId))try{let p=await t.db.companies.findByEntityId(o.objectId.toString());await t.db.companies.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update company in database:",p)}return{success:!0,data:{success:!0}}}},Xe={match:b("company.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="company.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Company Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.companies&&o.objectId))try{await t.db.companies.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete company from database:",p)}return{success:!0,data:{success:!0}}}};var Ze={match:b("contact.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="contact.creation"&&(console.log("\u{1F464} HubSpot Contact Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.contacts&&o.objectId))try{await t.db.contacts.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save contact to database:",p)}return{success:!0,data:{success:!0}}}},et={match:b("contact.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="contact.propertyChange"&&(console.log("\u{1F4DD} HubSpot Contact Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.contacts&&o.objectId))try{let p=await t.db.contacts.findByEntityId(o.objectId.toString());await t.db.contacts.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update contact in database:",p)}return{success:!0,data:{success:!0}}}},tt={match:b("contact.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="contact.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Contact Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.contacts&&o.objectId))try{await t.db.contacts.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete contact from database:",p)}return{success:!0,data:{success:!0}}}};var ot={match:b("deal.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="deal.creation"&&(console.log("\u{1F4BC} HubSpot Deal Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.deals&&o.objectId))try{await t.db.deals.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save deal to database:",p)}return{success:!0,data:{success:!0}}}},at={match:b("deal.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="deal.propertyChange"&&(console.log("\u{1F4DD} HubSpot Deal Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.deals&&o.objectId))try{let p=await t.db.deals.findByEntityId(o.objectId.toString());await t.db.deals.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update deal in database:",p)}return{success:!0,data:{success:!0}}}},nt={match:b("deal.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="deal.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Deal Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.deals&&o.objectId))try{await t.db.deals.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete deal from database:",p)}return{success:!0,data:{success:!0}}}};var st={match:b("ticket.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="ticket.creation"&&(console.log("\u{1F3AB} HubSpot Ticket Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.tickets&&o.objectId))try{await t.db.tickets.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save ticket to database:",p)}return{success:!0,data:{success:!0}}}},rt={match:b("ticket.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="ticket.propertyChange"&&(console.log("\u{1F4DD} HubSpot Ticket Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.tickets&&o.objectId))try{let p=await t.db.tickets.findByEntityId(o.objectId.toString());await t.db.tickets.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update ticket in database:",p)}return{success:!0,data:{success:!0}}}},pt={match:b("ticket.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="ticket.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Ticket Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.tickets&&o.objectId))try{await t.db.tickets.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete ticket from database:",p)}return{success:!0,data:{success:!0}}}};var O={created:Ze,updated:et,deleted:tt},P={created:Ye,updated:Je,deleted:Xe},x={created:ot,updated:at,deleted:nt},L={created:st,updated:rt,deleted:pt};var ro={contacts:{get:f.get,getMany:f.getMany,createOrUpdate:f.createOrUpdate,delete:f.delete,getRecentlyCreated:f.getRecentlyCreated,getRecentlyUpdated:f.getRecentlyUpdated,search:f.search},companies:{get:S.get,getMany:S.getMany,create:S.create,update:S.update,delete:S.delete,getRecentlyCreated:S.getRecentlyCreated,getRecentlyUpdated:S.getRecentlyUpdated,searchByDomain:S.searchByDomain},deals:{get:C.get,getMany:C.getMany,create:C.create,update:C.update,delete:C.delete,getRecentlyCreated:C.getRecentlyCreated,getRecentlyUpdated:C.getRecentlyUpdated,search:C.search},tickets:{get:w.get,getMany:w.getMany,create:w.create,update:w.update,delete:w.delete},engagements:{get:j.get,getMany:j.getMany,create:j.create,delete:j.delete},contactLists:{addContact:V.addContact,removeContact:V.removeContact}},po={"contacts.get":{input:l.contactsGet,output:y.contactsGet},"contacts.getMany":{input:l.contactsGetMany,output:y.contactsGetMany},"contacts.createOrUpdate":{input:l.contactsCreateOrUpdate,output:y.contactsCreateOrUpdate},"contacts.delete":{input:l.contactsDelete,output:y.contactsDelete},"contacts.getRecentlyCreated":{input:l.contactsGetRecentlyCreated,output:y.contactsGetRecentlyCreated},"contacts.getRecentlyUpdated":{input:l.contactsGetRecentlyUpdated,output:y.contactsGetRecentlyUpdated},"contacts.search":{input:l.contactsSearch,output:y.contactsSearch},"companies.get":{input:l.companiesGet,output:y.companiesGet},"companies.getMany":{input:l.companiesGetMany,output:y.companiesGetMany},"companies.create":{input:l.companiesCreate,output:y.companiesCreate},"companies.update":{input:l.companiesUpdate,output:y.companiesUpdate},"companies.delete":{input:l.companiesDelete,output:y.companiesDelete},"companies.getRecentlyCreated":{input:l.companiesGetRecentlyCreated,output:y.companiesGetRecentlyCreated},"companies.getRecentlyUpdated":{input:l.companiesGetRecentlyUpdated,output:y.companiesGetRecentlyUpdated},"companies.searchByDomain":{input:l.companiesSearchByDomain,output:y.companiesSearchByDomain},"deals.get":{input:l.dealsGet,output:y.dealsGet},"deals.getMany":{input:l.dealsGetMany,output:y.dealsGetMany},"deals.create":{input:l.dealsCreate,output:y.dealsCreate},"deals.update":{input:l.dealsUpdate,output:y.dealsUpdate},"deals.delete":{input:l.dealsDelete,output:y.dealsDelete},"deals.getRecentlyCreated":{input:l.dealsGetRecentlyCreated,output:y.dealsGetRecentlyCreated},"deals.getRecentlyUpdated":{input:l.dealsGetRecentlyUpdated,output:y.dealsGetRecentlyUpdated},"deals.search":{input:l.dealsSearch,output:y.dealsSearch},"tickets.get":{input:l.ticketsGet,output:y.ticketsGet},"tickets.getMany":{input:l.ticketsGetMany,output:y.ticketsGetMany},"tickets.create":{input:l.ticketsCreate,output:y.ticketsCreate},"tickets.update":{input:l.ticketsUpdate,output:y.ticketsUpdate},"tickets.delete":{input:l.ticketsDelete,output:y.ticketsDelete},"engagements.get":{input:l.engagementsGet,output:y.engagementsGet},"engagements.getMany":{input:l.engagementsGetMany,output:y.engagementsGetMany},"engagements.create":{input:l.engagementsCreate,output:y.engagementsCreate},"engagements.delete":{input:l.engagementsDelete,output:y.engagementsDelete},"contactLists.addContact":{input:l.contactListsAddContact,output:y.contactListsAddContact},"contactLists.removeContact":{input:l.contactListsRemoveContact,output:y.contactListsRemoveContact}},io={contactCreated:O.created,contactUpdated:O.updated,contactDeleted:O.deleted,companyCreated:P.created,companyUpdated:P.updated,companyDeleted:P.deleted,dealCreated:x.created,dealUpdated:x.updated,dealDeleted:x.deleted,ticketCreated:L.created,ticketUpdated:L.updated,ticketDeleted:L.deleted},co={contactCreated:{description:"A new contact was created",payload:_,response:u.object({success:u.boolean()})},contactUpdated:{description:"A contact property was updated",payload:q,response:u.object({success:u.boolean()})},contactDeleted:{description:"A contact was deleted",payload:$,response:u.object({success:u.boolean()})},companyCreated:{description:"A new company was created",payload:K,response:u.object({success:u.boolean()})},companyUpdated:{description:"A company property was updated",payload:Q,response:u.object({success:u.boolean()})},companyDeleted:{description:"A company was deleted",payload:Y,response:u.object({success:u.boolean()})},dealCreated:{description:"A new deal was created",payload:J,response:u.object({success:u.boolean()})},dealUpdated:{description:"A deal property was updated",payload:X,response:u.object({success:u.boolean()})},dealDeleted:{description:"A deal was deleted",payload:Z,response:u.object({success:u.boolean()})},ticketCreated:{description:"A new support ticket was created",payload:ee,response:u.object({success:u.boolean()})},ticketUpdated:{description:"A support ticket property was updated",payload:te,response:u.object({success:u.boolean()})},ticketDeleted:{description:"A support ticket was deleted",payload:oe,response:u.object({success:u.boolean()})}},lo="api_key",yo={"contacts.get":{riskLevel:"read",description:"Get a specific contact"},"contacts.getMany":{riskLevel:"read",description:"Get multiple contacts"},"contacts.createOrUpdate":{riskLevel:"write",description:"Create a new contact or update an existing one"},"contacts.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a contact [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"contacts.getRecentlyCreated":{riskLevel:"read",description:"List recently created contacts"},"contacts.getRecentlyUpdated":{riskLevel:"read",description:"List recently updated contacts"},"contacts.search":{riskLevel:"read",description:"Search contacts"},"companies.get":{riskLevel:"read",description:"Get a specific company"},"companies.getMany":{riskLevel:"read",description:"Get multiple companies"},"companies.create":{riskLevel:"write",description:"Create a new company"},"companies.update":{riskLevel:"write",description:"Update an existing company"},"companies.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a company [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"companies.getRecentlyCreated":{riskLevel:"read",description:"List recently created companies"},"companies.getRecentlyUpdated":{riskLevel:"read",description:"List recently updated companies"},"companies.searchByDomain":{riskLevel:"read",description:"Search companies by domain name"},"deals.get":{riskLevel:"read",description:"Get a specific deal"},"deals.getMany":{riskLevel:"read",description:"Get multiple deals"},"deals.create":{riskLevel:"write",description:"Create a new deal"},"deals.update":{riskLevel:"write",description:"Update an existing deal"},"deals.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a deal [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"deals.getRecentlyCreated":{riskLevel:"read",description:"List recently created deals"},"deals.getRecentlyUpdated":{riskLevel:"read",description:"List recently updated deals"},"deals.search":{riskLevel:"read",description:"Search deals"},"tickets.get":{riskLevel:"read",description:"Get a specific ticket"},"tickets.getMany":{riskLevel:"read",description:"Get multiple tickets"},"tickets.create":{riskLevel:"write",description:"Create a new support ticket"},"tickets.update":{riskLevel:"write",description:"Update an existing ticket"},"tickets.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a ticket [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"engagements.get":{riskLevel:"read",description:"Get a specific engagement"},"engagements.getMany":{riskLevel:"read",description:"Get multiple engagements"},"engagements.create":{riskLevel:"write",description:"Create a new engagement"},"engagements.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete an engagement [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"contactLists.addContact":{riskLevel:"write",description:"Add a contact to a static contact list"},"contactLists.removeContact":{riskLevel:"write",description:"Remove a contact from a static contact list"}};function la(t={}){let a={...t,authType:t.authType??lo};return{id:"hubspot",oauthConfig:{providerName:"HubSpot",authUrl:"https://app.hubspot.com/oauth/authorize",tokenUrl:"https://api.hubapi.com/oauth/v1/token",scopes:["crm.objects.contacts.read","crm.objects.contacts.write","crm.objects.companies.read","crm.objects.companies.write","crm.objects.deals.read","crm.objects.deals.write"]},schema:Qe,options:a,hooks:a.hooks,webhookHooks:a.webhookHooks,endpoints:ro,webhooks:io,endpointMeta:yo,endpointSchemas:po,webhookSchemas:co,pluginWebhookMatcher:s=>{let n="x-hubspot-signature-v3"in s.headers,o=s.body,B=(Array.isArray(o)?o:[o]).some(g=>typeof g.subscriptionType=="string"&&g.subscriptionType!==void 0);return n||B},errorHandlers:a.errorHandlers||Ne,keyBuilder:async(s,r)=>{let n=s.authType;if(r==="webhook"&&a.webhookSecret)return a.webhookSecret;if(r==="webhook"){let o=await s.keys.get_webhook_signature();if(!o)throw new Error("[auth-missing:hubspot:webhook_signature]: HubSpot webhook signature is missing");return o}if(r==="endpoint"){if(s.authType==="api_key"){let o=await s.keys.get_api_key();if(!o)throw new Error("[auth-missing:hubspot:api_key]: HubSpot API Key is missing");return o}else if(s.authType==="oauth_2"){let o=await s.keys.get_access_token();if(!o)throw new Error("[auth-missing:hubspot:oauth_2]: HubSpot access token is missing");return o}}throw new Error(`[auth-missing:hubspot:${n}]: HubSpot key is missing`)}}}export{b as createHubSpotEventMatch,la as hubspot,po as hubspotEndpointSchemas,m as verifyHubSpotWebhookSignature};
1
+ import{z as u}from"zod";import{logEventFromContext as k}from"corsair/core";import{request as it}from"corsair/http";var H=class extends Error{constructor(s,r){super(s);this.code=r;this.name="HubSpotAPIError"}},dt="https://api.hubapi.com";async function d(t,a,s={}){let{method:r="GET",body:n,query:o}=s,p={BASE:dt,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TOKEN:a,HEADERS:{"Content-Type":"application/json"}},F={method:r,url:t,body:r==="POST"||r==="PUT"||r==="PATCH"?n:void 0,mediaType:"application/json",query:r==="GET"?o:void 0};try{return await it(p,F)}catch(g){throw g&&typeof g=="object"&&"status"in g&&typeof g.status=="number"?new H(g instanceof Error?g.message:"HubSpot API error",g.status):new H(g instanceof Error?g.message:"Unknown error")}}var ae=async(t,a)=>{let{companyId:s,...r}=a,n=`/crm/v3/objects/companies/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.companies)try{await t.db.companies.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save company to database:",p)}return await k(t,"hubspot.companies.get",{...a},"completed"),o},ne=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/companies",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.companies)try{for(let o of n.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await k(t,"hubspot.companies.getMany",{...a},"completed"),n},se=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/companies",t.key,{method:"POST",body:s});if(n&&t.db.companies)try{await t.db.companies.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save company to database:",o)}return await k(t,"hubspot.companies.create",{...a},"completed"),n},re=async(t,a)=>{let{companyId:s,...r}=a,n=`/crm/v3/objects/companies/${s}`,o=await d(n,t.key,{method:"PATCH",body:r});if(o&&t.db.companies)try{await t.db.companies.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save company to database:",p)}return await k(t,"hubspot.companies.update",{...a},"completed"),o},pe=async(t,a)=>{let{companyId:s}=a,r=`/crm/v3/objects/companies/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.companies)try{await t.db.companies.deleteByEntityId(s)}catch(n){console.warn("Failed to delete company from database:",n)}await k(t,"hubspot.companies.delete",{...a},"completed")},ce=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/companies",t.key,{query:s});if(n.results&&t.db.companies)try{for(let o of n.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await k(t,"hubspot.companies.getRecentlyCreated",{...a},"completed"),n},ie=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/companies",t.key,{query:s});if(n.results&&t.db.companies)try{for(let o of n.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await k(t,"hubspot.companies.getRecentlyUpdated",{...a},"completed"),n},de=async(t,a)=>{let{domain:s,...r}=a,o=await d("/crm/v3/objects/companies/search",t.key,{query:{...r,domain:s,properties:r.properties?.join(",")}});return await k(t,"hubspot.companies.searchByDomain",{...a},"completed"),o};import{logEventFromContext as le}from"corsair/core";var ye=async(t,a)=>{let{listId:s,...r}=a,n=`/contacts/v1/lists/${s}/add`,o=await d(n,t.key,{method:"POST",body:r});return await le(t,"hubspot.contactLists.addContact",{...a},"completed"),o},ue=async(t,a)=>{let{listId:s,...r}=a,n=`/contacts/v1/lists/${s}/remove`,o=await d(n,t.key,{method:"POST",body:r});return await le(t,"hubspot.contactLists.removeContact",{...a},"completed"),o};import{logEventFromContext as f}from"corsair/core";var me=async(t,a)=>{let{contactId:s,...r}=a,n=`/crm/v3/objects/contacts/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save contact to database:",p)}return await f(t,"hubspot.contacts.get",{...a},"completed"),o},be=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/contacts",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.contacts)try{for(let o of n.results)await t.db.contacts.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save contacts to database:",o)}return await f(t,"hubspot.contacts.getMany",{...a},"completed"),n},ge=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/contacts",t.key,{method:"POST",body:s});if(n&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save contact to database:",o)}return await f(t,"hubspot.contacts.create",{...a},"completed"),n},he=async(t,a)=>{let{contactId:s,...r}=a,n=`/crm/v3/objects/contacts/${s}`,o=await d(n,t.key,{method:"PATCH",body:r});if(o&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save contact to database:",p)}return await f(t,"hubspot.contacts.update",{...a},"completed"),o},Se=async(t,a)=>{let{contactId:s}=a,r=`/crm/v3/objects/contacts/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.contacts)try{await t.db.contacts.deleteByEntityId(s)}catch(n){console.warn("Failed to delete contact from database:",n)}await f(t,"hubspot.contacts.delete",{...a},"completed")},Ce=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/contacts",t.key,{query:s});return await f(t,"hubspot.contacts.getRecentlyCreated",{...a},"completed"),n},Ee=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/contacts",t.key,{query:s});return await f(t,"hubspot.contacts.getRecentlyUpdated",{...a},"completed"),n},ke=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/contacts/search",t.key,{method:"POST",body:s});if(n.results&&t.db.contacts)try{for(let o of n.results)await t.db.contacts.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save contacts to database:",o)}return await f(t,"hubspot.contacts.search",{...a},"completed"),n};import{logEventFromContext as v}from"corsair/core";var fe=async(t,a)=>{let{dealId:s,...r}=a,n=`/crm/v3/objects/deals/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.deals)try{await t.db.deals.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save deal to database:",p)}return await v(t,"hubspot.deals.get",{...a},"completed"),o},ve=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/deals",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.deals)try{for(let o of n.results)await t.db.deals.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save deals to database:",o)}return await v(t,"hubspot.deals.getMany",{...a},"completed"),n},He=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/deals",t.key,{method:"POST",body:s});if(n&&t.db.deals)try{await t.db.deals.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save deal to database:",o)}return await v(t,"hubspot.deals.create",{...a},"completed"),n},Re=async(t,a)=>{let{dealId:s,...r}=a,n=`/crm/v3/objects/deals/${s}`,o=await d(n,t.key,{method:"PATCH",body:r});if(o&&t.db.deals)try{await t.db.deals.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to update deal in database:",p)}return await v(t,"hubspot.deals.update",{...a},"completed"),o},we=async(t,a)=>{let{dealId:s}=a,r=`/crm/v3/objects/deals/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.deals)try{await t.db.deals.deleteByEntityId(s)}catch(n){console.warn("Failed to delete deal from database:",n)}await v(t,"hubspot.deals.delete",{...a},"completed")},Ie=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/deals",t.key,{query:s});return await v(t,"hubspot.deals.getRecentlyCreated",{...a},"completed"),n},De=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/deals",t.key,{query:s});return await v(t,"hubspot.deals.getRecentlyUpdated",{...a},"completed"),n},Te=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/deals/search",t.key,{method:"POST",body:s});return await v(t,"hubspot.deals.search",{...a},"completed"),n};import{logEventFromContext as G}from"corsair/core";var je=async(t,a)=>{let{engagementId:s}=a,r=`/crm/v3/objects/engagements/${s}`,n=await d(r,t.key);if(n&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(n.id,{...n})}catch(o){console.warn("Failed to save engagement to database:",o)}return await G(t,"hubspot.engagements.get",{...a},"completed"),n},Ge=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/engagements",t.key,{query:s});if(n.results&&t.db.engagements)try{for(let o of n.results)await t.db.engagements.upsertByEntityId(o.id,{...o})}catch(o){console.warn("Failed to save engagements to database:",o)}return await G(t,"hubspot.engagements.getMany",{...a},"completed"),n},Ue=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/engagements",t.key,{method:"POST",body:s});if(n&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(n.id,{...n})}catch(o){console.warn("Failed to save engagement to database:",o)}return await G(t,"hubspot.engagements.create",{...a},"completed"),n},Ae=async(t,a)=>{let{engagementId:s}=a,r=`/crm/v3/objects/engagements/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.engagements)try{await t.db.engagements.deleteByEntityId(s)}catch(n){console.warn("Failed to delete engagement from database:",n)}await G(t,"hubspot.engagements.delete",{...a},"completed")};import{logEventFromContext as I}from"corsair/core";var Me=async(t,a)=>{let{ticketId:s,...r}=a,n=`/crm/v3/objects/tickets/${s}`,o=await d(n,t.key,{query:{...r,properties:r.properties?.join(","),propertiesWithHistory:r.propertiesWithHistory?.join(","),associations:r.associations?.join(",")}});if(o&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to save ticket to database:",p)}return await I(t,"hubspot.tickets.get",{...a},"completed"),o},Pe=async(t,a)=>{let{...s}=a||{},n=await d("/crm/v3/objects/tickets",t.key,{query:{...s,properties:s.properties?.join(","),propertiesWithHistory:s.propertiesWithHistory?.join(","),associations:s.associations?.join(",")}});if(n.results&&t.db.tickets)try{for(let o of n.results)await t.db.tickets.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save tickets to database:",o)}return await I(t,"hubspot.tickets.getMany",{...a},"completed"),n},We=async(t,a)=>{let{...s}=a,n=await d("/crm/v3/objects/tickets",t.key,{method:"POST",body:s});if(n&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(n.id,n)}catch(o){console.warn("Failed to save ticket to database:",o)}return await I(t,"hubspot.tickets.create",{...a},"completed"),n},xe=async(t,a)=>{let{ticketId:s,...r}=a,n=`/crm/v3/objects/tickets/${s}`,o=await d(n,t.key,{method:"PATCH",body:r});if(o&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(o.id,o)}catch(p){console.warn("Failed to update ticket in database:",p)}return await I(t,"hubspot.tickets.update",{...a},"completed"),o},Le=async(t,a)=>{let{ticketId:s}=a,r=`/crm/v3/objects/tickets/${s}`;if(await d(r,t.key,{method:"DELETE"}),t.db.tickets)try{await t.db.tickets.deleteByEntityId(s)}catch(n){console.warn("Failed to delete ticket from database:",n)}await I(t,"hubspot.tickets.delete",{...a},"completed")};import{z as e}from"zod";var ht=e.object({contactId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),St=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),Ct=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),Et=e.object({contactId:e.string(),properties:e.record(e.string(),e.string()).optional()}),kt=e.object({contactId:e.string()}),ft=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),vt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Ht=e.enum(["BETWEEN","CONTAINS_TOKEN","EQ","GT","GTE","HAS_PROPERTY","IN","LT","LTE","NEQ","NOT_CONTAINS_TOKEN","NOT_HAS_PROPERTY","NOT_IN"]),Rt=e.object({operator:Ht,propertyName:e.string(),highValue:e.string().optional(),value:e.string().optional(),values:e.array(e.string()).optional()}),Oe=e.object({filters:e.array(Rt)}),wt=e.enum(["ASCENDING","DESCENDING"]),Fe=e.object({propertyName:e.string(),direction:wt}),It=e.object({id:e.string(),type:e.string().optional()}),Dt=e.object({results:e.array(It)}),T=e.record(e.string(),e.union([Dt,e.array(e.string())])),Tt=e.object({query:e.string().optional(),limit:e.number().optional(),after:e.string().optional(),sorts:e.array(Fe).optional(),properties:e.array(e.string()).optional(),filterGroups:e.array(Oe).optional()}),jt=e.object({companyId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),Gt=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),Ut=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),At=e.object({companyId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Mt=e.object({companyId:e.string()}),Pt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Wt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),xt=e.object({domain:e.string(),properties:e.array(e.string()).optional()}),Lt=e.object({dealId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),Bt=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),Ot=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),Ft=e.object({dealId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Nt=e.object({dealId:e.string()}),zt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Vt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),_t=e.object({query:e.string().optional(),limit:e.number().optional(),after:e.string().optional(),sorts:e.array(Fe).optional(),properties:e.array(e.string()).optional(),filterGroups:e.array(Oe).optional()}),$t=e.object({ticketId:e.string(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional(),idProperty:e.string().optional()}),qt=e.object({limit:e.number().optional(),after:e.string().optional(),properties:e.array(e.string()).optional(),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),Kt=e.object({properties:e.record(e.string(),e.string()).optional(),associations:e.array(e.object({to:e.object({id:e.string()}),types:e.array(e.object({associationCategory:e.string(),associationTypeId:e.number()}))})).optional()}),Qt=e.object({ticketId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Yt=e.object({ticketId:e.string()}),Jt=e.object({engagementId:e.string()}),Xt=e.object({limit:e.number().optional(),after:e.string().optional()}),Zt=e.object({engagement:e.object({active:e.boolean().optional(),type:e.string(),timestamp:e.number().optional()}),associations:e.object({contactIds:e.array(e.number()).optional(),companyIds:e.array(e.number()).optional(),dealIds:e.array(e.number()).optional(),ownerIds:e.array(e.number()).optional()}).optional(),metadata:e.record(e.string(),e.any()).optional()}),eo=e.object({engagementId:e.string()}),to=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),oo=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),l={contactsGet:ht,contactsGetMany:St,contactsCreate:Ct,contactsUpdate:Et,contactsDelete:kt,contactsGetRecentlyCreated:ft,contactsGetRecentlyUpdated:vt,contactsSearch:Tt,companiesGet:jt,companiesGetMany:Gt,companiesCreate:Ut,companiesUpdate:At,companiesDelete:Mt,companiesGetRecentlyCreated:Pt,companiesGetRecentlyUpdated:Wt,companiesSearchByDomain:xt,dealsGet:Lt,dealsGetMany:Bt,dealsCreate:Ot,dealsUpdate:Ft,dealsDelete:Nt,dealsGetRecentlyCreated:zt,dealsGetRecentlyUpdated:Vt,dealsSearch:_t,ticketsGet:$t,ticketsGetMany:qt,ticketsCreate:Kt,ticketsUpdate:Qt,ticketsDelete:Yt,engagementsGet:Jt,engagementsGetMany:Xt,engagementsCreate:Zt,engagementsDelete:eo,contactListsAddContact:to,contactListsRemoveContact:oo},M=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),D=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),P=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),W=e.object({id:e.string(),properties:e.record(e.string(),e.string()).optional(),createdAt:e.coerce.date().nullable().optional(),updatedAt:e.coerce.date().nullable().optional(),archived:e.boolean().optional(),associations:T.optional()}).loose(),z=e.object({id:e.string(),engagement:e.object({id:e.number().optional(),portalId:e.number().optional(),active:e.boolean().optional(),createdAt:e.number().optional(),lastUpdated:e.number().optional(),createdBy:e.number().optional(),modifiedBy:e.number().optional(),ownerId:e.number().optional(),type:e.string().optional(),timestamp:e.number().optional()}).optional(),associations:T.optional(),metadata:e.record(e.string(),e.any()).optional()}).loose(),R=e.object({next:e.object({after:e.string()}).optional(),prev:e.object({before:e.string()}).optional()}),U=e.object({total:e.number().optional(),results:e.array(M).optional(),paging:R.optional()}).loose(),N=e.object({total:e.number().optional(),results:e.array(D).optional(),paging:R.optional()}).loose(),A=e.object({total:e.number().optional(),results:e.array(P).optional(),paging:R.optional()}).loose(),ao=e.object({results:e.array(W).optional(),paging:R.optional()}).loose(),no=e.object({results:e.array(z).optional(),paging:R.optional()}).loose(),so=e.object({total:e.number().optional(),results:e.array(D).optional(),paging:R.optional()}).loose(),Be=e.object({updated:e.array(e.number()).optional(),discarded:e.array(e.number()).optional(),invalidVids:e.array(e.number()).optional(),invalidEmails:e.array(e.string()).optional()}),y={contactsGet:M,contactsGetMany:U,contactsCreate:M,contactsUpdate:M,contactsDelete:e.void(),contactsGetRecentlyCreated:U,contactsGetRecentlyUpdated:U,contactsSearch:U,companiesGet:D,companiesGetMany:N,companiesCreate:D,companiesUpdate:D,companiesDelete:e.void(),companiesGetRecentlyCreated:N,companiesGetRecentlyUpdated:N,companiesSearchByDomain:so,dealsGet:P,dealsGetMany:A,dealsCreate:P,dealsUpdate:P,dealsDelete:e.void(),dealsGetRecentlyCreated:A,dealsGetRecentlyUpdated:A,dealsSearch:A,ticketsGet:W,ticketsGetMany:ao,ticketsCreate:W,ticketsUpdate:W,ticketsDelete:e.void(),engagementsGet:z,engagementsGetMany:no,engagementsCreate:z,engagementsDelete:e.void(),contactListsAddContact:Be,contactListsRemoveContact:Be};var S={get:me,getMany:be,create:ge,update:he,delete:Se,getRecentlyCreated:Ce,getRecentlyUpdated:Ee,search:ke},C={get:ae,getMany:ne,create:se,update:re,delete:pe,getRecentlyCreated:ce,getRecentlyUpdated:ie,searchByDomain:de},E={get:fe,getMany:ve,create:He,update:Re,delete:we,getRecentlyCreated:Ie,getRecentlyUpdated:De,search:Te},w={get:Me,getMany:Pe,create:We,update:xe,delete:Le},j={get:je,getMany:Ge,create:Ue,delete:Ae},V={addContact:ye,removeContact:ue};import{ApiError as Ne}from"corsair/http";var ze={PERMISSION_ERROR:{match:(t,a)=>{if((t instanceof Ne&&t.status===403||t instanceof H&&t.code===403)&&a.operation.toLowerCase().includes("tickets"))return!0;let s=t.message.toLowerCase();return s.includes("forbidden")||s.includes("permission denied")||s.includes("access denied")},handler:async(t,a)=>({maxRetries:0})},VALIDATION_ERROR:{match:(t,a)=>!!((t instanceof Ne&&t.status===400||t instanceof H&&t.code===400)&&a.operation.toLowerCase().includes("engagements.create")),handler:async(t,a)=>({maxRetries:0})},DEFAULT:{match:(t,a)=>!0,handler:async(t,a)=>(console.error(`[corsair:${a.pluginId}:${a.operation}]`,{error:t.message,input:a.input}),{maxRetries:0})}};import{z as Qe}from"zod";import{z as c}from"zod";var Ve=c.object({id:c.string(),properties:c.record(c.string(),c.any()).optional(),createdAt:c.coerce.date().nullable().optional(),updatedAt:c.coerce.date().nullable().optional(),archived:c.boolean().optional()}),_e=c.object({id:c.string(),properties:c.record(c.string(),c.any()).optional(),createdAt:c.coerce.date().nullable().optional(),updatedAt:c.coerce.date().nullable().optional(),archived:c.boolean().optional()}),$e=c.object({id:c.string(),properties:c.record(c.string(),c.any()).optional(),createdAt:c.coerce.date().nullable().optional(),updatedAt:c.coerce.date().nullable().optional(),archived:c.boolean().optional()}),qe=c.object({id:c.string(),properties:c.record(c.string(),c.any()).optional(),createdAt:c.coerce.date().nullable().optional(),updatedAt:c.coerce.date().nullable().optional(),archived:c.boolean().optional()}),Ke=c.object({id:c.string(),engagement:c.object({id:c.number().optional(),portalId:c.number().optional(),active:c.boolean().optional(),createdAt:c.number().optional(),lastUpdated:c.number().optional(),createdBy:c.number().optional(),modifiedBy:c.number().optional(),ownerId:c.number().optional(),type:c.string().optional(),timestamp:c.number().optional()}).optional(),associations:c.record(c.string(),c.any()).optional(),metadata:c.record(c.string(),c.any()).optional()});var Oo=Qe.object({token:Qe.string()}),Ye={version:"1.0.0",entities:{contacts:Ve,companies:_e,deals:$e,tickets:qe,engagements:Ke}};import{verifyHmacSignature as ro}from"corsair/http";import{z as i}from"zod";var h=i.object({subscriptionId:i.number(),portalId:i.number(),occurredAt:i.number(),subscriptionType:i.string(),attemptNumber:i.number(),objectId:i.number().optional(),propertyName:i.string().optional(),propertyValue:i.string().optional(),changeSource:i.string().optional(),eventId:i.string().optional()}),_=h.extend({subscriptionType:i.literal("contact.creation"),objectId:i.number()}),$=h.extend({subscriptionType:i.literal("contact.propertyChange"),objectId:i.number(),propertyName:i.string(),propertyValue:i.string()}),q=h.extend({subscriptionType:i.literal("contact.deletion"),objectId:i.number()}),K=h.extend({subscriptionType:i.literal("company.creation"),objectId:i.number()}),Q=h.extend({subscriptionType:i.literal("company.propertyChange"),objectId:i.number(),propertyName:i.string(),propertyValue:i.string()}),Y=h.extend({subscriptionType:i.literal("company.deletion"),objectId:i.number()}),J=h.extend({subscriptionType:i.literal("deal.creation"),objectId:i.number()}),X=h.extend({subscriptionType:i.literal("deal.propertyChange"),objectId:i.number(),propertyName:i.string(),propertyValue:i.string()}),Z=h.extend({subscriptionType:i.literal("deal.deletion"),objectId:i.number()}),ee=h.extend({subscriptionType:i.literal("ticket.creation"),objectId:i.number()}),te=h.extend({subscriptionType:i.literal("ticket.propertyChange"),objectId:i.number(),propertyName:i.string(),propertyValue:i.string()}),oe=h.extend({subscriptionType:i.literal("ticket.deletion"),objectId:i.number()}),Vo=i.union([_,$,q,K,Q,Y,J,X,Z,ee,te,oe]);function po(t){return typeof t=="string"?JSON.parse(t):t}function m(t,a){if(!a)return{valid:!1};let s=t.rawBody;if(!s)return{valid:!1,error:"Missing raw body for signature verification"};let r=t.headers,n=Array.isArray(r["x-hubspot-signature-v3"])?r["x-hubspot-signature-v3"][0]:r["x-hubspot-signature-v3"];return n?ro(s,a,n)?{valid:!0}:{valid:!1,error:"Invalid signature"}:{valid:!1,error:"Missing x-hubspot-signature-v3 header"}}function b(t){return a=>{let s=po(a.body);return(Array.isArray(s)?s:[s]).some(n=>typeof n=="object"&&n!==null&&"subscriptionType"in n&&typeof n.subscriptionType=="string"&&n.subscriptionType===t)}}var Je={match:b("company.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="company.creation"&&(console.log("\u{1F3E2} HubSpot Company Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.companies&&o.objectId))try{await t.db.companies.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save company to database:",p)}return{success:!0,data:{success:!0}}}},Xe={match:b("company.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="company.propertyChange"&&(console.log("\u{1F4DD} HubSpot Company Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.companies&&o.objectId))try{let p=await t.db.companies.findByEntityId(o.objectId.toString());await t.db.companies.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update company in database:",p)}return{success:!0,data:{success:!0}}}},Ze={match:b("company.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="company.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Company Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.companies&&o.objectId))try{await t.db.companies.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete company from database:",p)}return{success:!0,data:{success:!0}}}};var et={match:b("contact.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="contact.creation"&&(console.log("\u{1F464} HubSpot Contact Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.contacts&&o.objectId))try{await t.db.contacts.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save contact to database:",p)}return{success:!0,data:{success:!0}}}},tt={match:b("contact.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="contact.propertyChange"&&(console.log("\u{1F4DD} HubSpot Contact Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.contacts&&o.objectId))try{let p=await t.db.contacts.findByEntityId(o.objectId.toString());await t.db.contacts.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update contact in database:",p)}return{success:!0,data:{success:!0}}}},ot={match:b("contact.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="contact.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Contact Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.contacts&&o.objectId))try{await t.db.contacts.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete contact from database:",p)}return{success:!0,data:{success:!0}}}};var at={match:b("deal.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="deal.creation"&&(console.log("\u{1F4BC} HubSpot Deal Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.deals&&o.objectId))try{await t.db.deals.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save deal to database:",p)}return{success:!0,data:{success:!0}}}},nt={match:b("deal.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="deal.propertyChange"&&(console.log("\u{1F4DD} HubSpot Deal Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.deals&&o.objectId))try{let p=await t.db.deals.findByEntityId(o.objectId.toString());await t.db.deals.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update deal in database:",p)}return{success:!0,data:{success:!0}}}},st={match:b("deal.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="deal.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Deal Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.deals&&o.objectId))try{await t.db.deals.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete deal from database:",p)}return{success:!0,data:{success:!0}}}};var rt={match:b("ticket.creation"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="ticket.creation"&&(console.log("\u{1F3AB} HubSpot Ticket Created:",{objectId:o.objectId,portalId:o.portalId}),t.db.tickets&&o.objectId))try{await t.db.tickets.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{},createdAt:new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to save ticket to database:",p)}return{success:!0,data:{success:!0}}}},pt={match:b("ticket.propertyChange"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="ticket.propertyChange"&&(console.log("\u{1F4DD} HubSpot Ticket Updated:",{objectId:o.objectId,propertyName:o.propertyName,propertyValue:o.propertyValue}),t.db.tickets&&o.objectId))try{let p=await t.db.tickets.findByEntityId(o.objectId.toString());await t.db.tickets.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...p?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:p?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(p){console.warn("Failed to update ticket in database:",p)}return{success:!0,data:{success:!0}}}},ct={match:b("ticket.deletion"),handler:async(t,a)=>{let s=t.key,r=m(a,s);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let n=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of n)if(o.subscriptionType==="ticket.deletion"&&(console.log("\u{1F5D1}\uFE0F HubSpot Ticket Deleted:",{objectId:o.objectId,portalId:o.portalId}),t.db.tickets&&o.objectId))try{await t.db.tickets.deleteByEntityId(o.objectId.toString())}catch(p){console.warn("Failed to delete ticket from database:",p)}return{success:!0,data:{success:!0}}}};var x={created:et,updated:tt,deleted:ot},L={created:Je,updated:Xe,deleted:Ze},B={created:at,updated:nt,deleted:st},O={created:rt,updated:pt,deleted:ct};var co={contacts:{get:S.get,getMany:S.getMany,create:S.create,update:S.update,delete:S.delete,getRecentlyCreated:S.getRecentlyCreated,getRecentlyUpdated:S.getRecentlyUpdated,search:S.search},companies:{get:C.get,getMany:C.getMany,create:C.create,update:C.update,delete:C.delete,getRecentlyCreated:C.getRecentlyCreated,getRecentlyUpdated:C.getRecentlyUpdated,searchByDomain:C.searchByDomain},deals:{get:E.get,getMany:E.getMany,create:E.create,update:E.update,delete:E.delete,getRecentlyCreated:E.getRecentlyCreated,getRecentlyUpdated:E.getRecentlyUpdated,search:E.search},tickets:{get:w.get,getMany:w.getMany,create:w.create,update:w.update,delete:w.delete},engagements:{get:j.get,getMany:j.getMany,create:j.create,delete:j.delete},contactLists:{addContact:V.addContact,removeContact:V.removeContact}},io={"contacts.get":{input:l.contactsGet,output:y.contactsGet},"contacts.getMany":{input:l.contactsGetMany,output:y.contactsGetMany},"contacts.create":{input:l.contactsCreate,output:y.contactsCreate},"contacts.update":{input:l.contactsUpdate,output:y.contactsUpdate},"contacts.delete":{input:l.contactsDelete,output:y.contactsDelete},"contacts.getRecentlyCreated":{input:l.contactsGetRecentlyCreated,output:y.contactsGetRecentlyCreated},"contacts.getRecentlyUpdated":{input:l.contactsGetRecentlyUpdated,output:y.contactsGetRecentlyUpdated},"contacts.search":{input:l.contactsSearch,output:y.contactsSearch},"companies.get":{input:l.companiesGet,output:y.companiesGet},"companies.getMany":{input:l.companiesGetMany,output:y.companiesGetMany},"companies.create":{input:l.companiesCreate,output:y.companiesCreate},"companies.update":{input:l.companiesUpdate,output:y.companiesUpdate},"companies.delete":{input:l.companiesDelete,output:y.companiesDelete},"companies.getRecentlyCreated":{input:l.companiesGetRecentlyCreated,output:y.companiesGetRecentlyCreated},"companies.getRecentlyUpdated":{input:l.companiesGetRecentlyUpdated,output:y.companiesGetRecentlyUpdated},"companies.searchByDomain":{input:l.companiesSearchByDomain,output:y.companiesSearchByDomain},"deals.get":{input:l.dealsGet,output:y.dealsGet},"deals.getMany":{input:l.dealsGetMany,output:y.dealsGetMany},"deals.create":{input:l.dealsCreate,output:y.dealsCreate},"deals.update":{input:l.dealsUpdate,output:y.dealsUpdate},"deals.delete":{input:l.dealsDelete,output:y.dealsDelete},"deals.getRecentlyCreated":{input:l.dealsGetRecentlyCreated,output:y.dealsGetRecentlyCreated},"deals.getRecentlyUpdated":{input:l.dealsGetRecentlyUpdated,output:y.dealsGetRecentlyUpdated},"deals.search":{input:l.dealsSearch,output:y.dealsSearch},"tickets.get":{input:l.ticketsGet,output:y.ticketsGet},"tickets.getMany":{input:l.ticketsGetMany,output:y.ticketsGetMany},"tickets.create":{input:l.ticketsCreate,output:y.ticketsCreate},"tickets.update":{input:l.ticketsUpdate,output:y.ticketsUpdate},"tickets.delete":{input:l.ticketsDelete,output:y.ticketsDelete},"engagements.get":{input:l.engagementsGet,output:y.engagementsGet},"engagements.getMany":{input:l.engagementsGetMany,output:y.engagementsGetMany},"engagements.create":{input:l.engagementsCreate,output:y.engagementsCreate},"engagements.delete":{input:l.engagementsDelete,output:y.engagementsDelete},"contactLists.addContact":{input:l.contactListsAddContact,output:y.contactListsAddContact},"contactLists.removeContact":{input:l.contactListsRemoveContact,output:y.contactListsRemoveContact}},lo={contactCreated:x.created,contactUpdated:x.updated,contactDeleted:x.deleted,companyCreated:L.created,companyUpdated:L.updated,companyDeleted:L.deleted,dealCreated:B.created,dealUpdated:B.updated,dealDeleted:B.deleted,ticketCreated:O.created,ticketUpdated:O.updated,ticketDeleted:O.deleted},yo={contactCreated:{description:"A new contact was created",payload:_,response:u.object({success:u.boolean()})},contactUpdated:{description:"A contact property was updated",payload:$,response:u.object({success:u.boolean()})},contactDeleted:{description:"A contact was deleted",payload:q,response:u.object({success:u.boolean()})},companyCreated:{description:"A new company was created",payload:K,response:u.object({success:u.boolean()})},companyUpdated:{description:"A company property was updated",payload:Q,response:u.object({success:u.boolean()})},companyDeleted:{description:"A company was deleted",payload:Y,response:u.object({success:u.boolean()})},dealCreated:{description:"A new deal was created",payload:J,response:u.object({success:u.boolean()})},dealUpdated:{description:"A deal property was updated",payload:X,response:u.object({success:u.boolean()})},dealDeleted:{description:"A deal was deleted",payload:Z,response:u.object({success:u.boolean()})},ticketCreated:{description:"A new support ticket was created",payload:ee,response:u.object({success:u.boolean()})},ticketUpdated:{description:"A support ticket property was updated",payload:te,response:u.object({success:u.boolean()})},ticketDeleted:{description:"A support ticket was deleted",payload:oe,response:u.object({success:u.boolean()})}},uo="api_key",mo={"contacts.get":{riskLevel:"read",description:"Get a specific contact"},"contacts.getMany":{riskLevel:"read",description:"Get multiple contacts"},"contacts.create":{riskLevel:"write",description:"Create a new contact"},"contacts.update":{riskLevel:"write",description:"Update an existing contact"},"contacts.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a contact [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"contacts.getRecentlyCreated":{riskLevel:"read",description:"List recently created contacts"},"contacts.getRecentlyUpdated":{riskLevel:"read",description:"List recently updated contacts"},"contacts.search":{riskLevel:"read",description:"Search contacts"},"companies.get":{riskLevel:"read",description:"Get a specific company"},"companies.getMany":{riskLevel:"read",description:"Get multiple companies"},"companies.create":{riskLevel:"write",description:"Create a new company"},"companies.update":{riskLevel:"write",description:"Update an existing company"},"companies.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a company [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"companies.getRecentlyCreated":{riskLevel:"read",description:"List recently created companies"},"companies.getRecentlyUpdated":{riskLevel:"read",description:"List recently updated companies"},"companies.searchByDomain":{riskLevel:"read",description:"Search companies by domain name"},"deals.get":{riskLevel:"read",description:"Get a specific deal"},"deals.getMany":{riskLevel:"read",description:"Get multiple deals"},"deals.create":{riskLevel:"write",description:"Create a new deal"},"deals.update":{riskLevel:"write",description:"Update an existing deal"},"deals.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a deal [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"deals.getRecentlyCreated":{riskLevel:"read",description:"List recently created deals"},"deals.getRecentlyUpdated":{riskLevel:"read",description:"List recently updated deals"},"deals.search":{riskLevel:"read",description:"Search deals"},"tickets.get":{riskLevel:"read",description:"Get a specific ticket"},"tickets.getMany":{riskLevel:"read",description:"Get multiple tickets"},"tickets.create":{riskLevel:"write",description:"Create a new support ticket"},"tickets.update":{riskLevel:"write",description:"Update an existing ticket"},"tickets.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete a ticket [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"engagements.get":{riskLevel:"read",description:"Get a specific engagement"},"engagements.getMany":{riskLevel:"read",description:"Get multiple engagements"},"engagements.create":{riskLevel:"write",description:"Create a new engagement"},"engagements.delete":{riskLevel:"destructive",irreversible:!0,description:"Permanently delete an engagement [DESTRUCTIVE \xB7 IRREVERSIBLE]"},"contactLists.addContact":{riskLevel:"write",description:"Add a contact to a static contact list"},"contactLists.removeContact":{riskLevel:"write",description:"Remove a contact from a static contact list"}};function ua(t={}){let a={...t,authType:t.authType??uo};return{id:"hubspot",oauthConfig:{providerName:"HubSpot",authUrl:"https://app.hubspot.com/oauth/authorize",tokenUrl:"https://api.hubapi.com/oauth/v1/token",scopes:["crm.objects.contacts.read","crm.objects.contacts.write","crm.objects.companies.read","crm.objects.companies.write","crm.objects.deals.read","crm.objects.deals.write"]},schema:Ye,options:a,hooks:a.hooks,webhookHooks:a.webhookHooks,endpoints:co,webhooks:lo,endpointMeta:mo,endpointSchemas:io,webhookSchemas:yo,pluginWebhookMatcher:s=>{let n="x-hubspot-signature-v3"in s.headers,o=s.body,F=(Array.isArray(o)?o:[o]).some(g=>typeof g.subscriptionType=="string"&&g.subscriptionType!==void 0);return n||F},errorHandlers:a.errorHandlers||ze,keyBuilder:async(s,r)=>{let n=s.authType;if(r==="webhook"&&a.webhookSecret)return a.webhookSecret;if(r==="webhook"){let o=await s.keys.get_webhook_signature();if(!o)throw new Error("[auth-missing:hubspot:webhook_signature]: HubSpot webhook signature is missing");return o}if(r==="endpoint"){if(s.authType==="api_key"){let o=await s.keys.get_api_key();if(!o)throw new Error("[auth-missing:hubspot:api_key]: HubSpot API Key is missing");return o}else if(s.authType==="oauth_2"){let o=await s.keys.get_access_token();if(!o)throw new Error("[auth-missing:hubspot:oauth_2]: HubSpot access token is missing");return o}}throw new Error(`[auth-missing:hubspot:${n}]: HubSpot key is missing`)}}}export{b as createHubSpotEventMatch,ua as hubspot,io as hubspotEndpointSchemas,m as verifyHubSpotWebhookSignature};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corsair-dev/hubspot",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Hubspot plugin for Corsair",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",