@corsair-dev/hubspot 0.1.7 → 0.1.9
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.
- package/README.md +65 -0
- package/dist/client.d.ts +19 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/endpoints/companies.d.ts.map +1 -1
- package/dist/endpoints/contacts.d.ts.map +1 -1
- package/dist/endpoints/deals.d.ts.map +1 -1
- package/dist/endpoints/index.d.ts +1 -0
- package/dist/endpoints/index.d.ts.map +1 -1
- package/dist/endpoints/recent.test.d.ts +2 -0
- package/dist/endpoints/recent.test.d.ts.map +1 -0
- package/dist/endpoints/types.d.ts +7 -0
- package/dist/endpoints/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/webhooks/types.test.d.ts +2 -0
- package/dist/webhooks/types.test.d.ts.map +1 -0
- package/package.json +9 -3
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @corsair-dev/hubspot
|
|
2
|
+
|
|
3
|
+
Hubspot plugin for Corsair.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @corsair-dev/hubspot
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Endpoints
|
|
12
|
+
|
|
13
|
+
| Operation | Operation ID | Risk | Description |
|
|
14
|
+
|-----------|--------------|------|-------------|
|
|
15
|
+
| `companies.create` | `hubspot.api.companies.create` | `write` | Create a new company |
|
|
16
|
+
| `companies.delete` | `hubspot.api.companies.delete` | `destructive` | Permanently delete a company [DESTRUCTIVE · IRREVERSIBLE] |
|
|
17
|
+
| `companies.get` | `hubspot.api.companies.get` | `read` | Get a specific company |
|
|
18
|
+
| `companies.getMany` | `hubspot.api.companies.getMany` | `read` | Pages through companies in id order, default properties only unless properties is set. To find a company by domain use companies.searchByDomain. |
|
|
19
|
+
| `companies.getRecentlyCreated` | `hubspot.api.companies.getRecentlyCreated` | `read` | Newest companies first by creation date; since keeps only those created at or after it. Page with paging.next.after. |
|
|
20
|
+
| `companies.getRecentlyUpdated` | `hubspot.api.companies.getRecentlyUpdated` | `read` | Most recently modified companies first; since keeps only those modified at or after it. Page with paging.next.after. |
|
|
21
|
+
| `companies.searchByDomain` | `hubspot.api.companies.searchByDomain` | `read` | Finds companies whose domain equals domain exactly (a search, not a prefix match). |
|
|
22
|
+
| `companies.update` | `hubspot.api.companies.update` | `write` | Update an existing company |
|
|
23
|
+
| `contactLists.addContact` | `hubspot.api.contactLists.addContact` | `write` | Add a contact to a static contact list |
|
|
24
|
+
| `contactLists.removeContact` | `hubspot.api.contactLists.removeContact` | `write` | Remove a contact from a static contact list |
|
|
25
|
+
| `contacts.create` | `hubspot.api.contacts.create` | `write` | Create a new contact |
|
|
26
|
+
| `contacts.delete` | `hubspot.api.contacts.delete` | `destructive` | Permanently delete a contact [DESTRUCTIVE · IRREVERSIBLE] |
|
|
27
|
+
| `contacts.get` | `hubspot.api.contacts.get` | `read` | Get a specific contact |
|
|
28
|
+
| `contacts.getMany` | `hubspot.api.contacts.getMany` | `read` | Pages through contacts in id order, default properties only unless properties is set. To find contacts by field or date use contacts.search. |
|
|
29
|
+
| `contacts.getRecentlyCreated` | `hubspot.api.contacts.getRecentlyCreated` | `read` | Newest contacts first by creation date; since keeps only those created at or after it. Page with paging.next.after. |
|
|
30
|
+
| `contacts.getRecentlyUpdated` | `hubspot.api.contacts.getRecentlyUpdated` | `read` | Most recently modified contacts first; since keeps only those modified at or after it. Page with paging.next.after. |
|
|
31
|
+
| `contacts.search` | `hubspot.api.contacts.search` | `read` | Search with query text and/or filterGroups; only default properties come back unless properties is set. Up to 200 per page and 10,000 results; follow paging.next.after. |
|
|
32
|
+
| `contacts.update` | `hubspot.api.contacts.update` | `write` | Update an existing contact |
|
|
33
|
+
| `deals.create` | `hubspot.api.deals.create` | `write` | Create a new deal |
|
|
34
|
+
| `deals.delete` | `hubspot.api.deals.delete` | `destructive` | Permanently delete a deal [DESTRUCTIVE · IRREVERSIBLE] |
|
|
35
|
+
| `deals.get` | `hubspot.api.deals.get` | `read` | Get a specific deal |
|
|
36
|
+
| `deals.getMany` | `hubspot.api.deals.getMany` | `read` | Pages through deals in id order, default properties only unless properties is set. To find deals by field or date use deals.search. |
|
|
37
|
+
| `deals.getRecentlyCreated` | `hubspot.api.deals.getRecentlyCreated` | `read` | Newest deals first by creation date; since keeps only those created at or after it. Page with paging.next.after. |
|
|
38
|
+
| `deals.getRecentlyUpdated` | `hubspot.api.deals.getRecentlyUpdated` | `read` | Most recently modified deals first; since keeps only those modified at or after it. Page with paging.next.after. |
|
|
39
|
+
| `deals.search` | `hubspot.api.deals.search` | `read` | Search with query text and/or filterGroups; only default properties come back unless properties is set. Up to 200 per page and 10,000 results; follow paging.next.after. |
|
|
40
|
+
| `deals.update` | `hubspot.api.deals.update` | `write` | Update an existing deal |
|
|
41
|
+
| `engagements.create` | `hubspot.api.engagements.create` | `write` | Create a new engagement |
|
|
42
|
+
| `engagements.delete` | `hubspot.api.engagements.delete` | `destructive` | Permanently delete an engagement [DESTRUCTIVE · IRREVERSIBLE] |
|
|
43
|
+
| `engagements.get` | `hubspot.api.engagements.get` | `read` | Get a specific engagement |
|
|
44
|
+
| `engagements.getMany` | `hubspot.api.engagements.getMany` | `read` | Get multiple engagements |
|
|
45
|
+
| `tickets.create` | `hubspot.api.tickets.create` | `write` | Create a new support ticket |
|
|
46
|
+
| `tickets.delete` | `hubspot.api.tickets.delete` | `destructive` | Permanently delete a ticket [DESTRUCTIVE · IRREVERSIBLE] |
|
|
47
|
+
| `tickets.get` | `hubspot.api.tickets.get` | `read` | Get a specific ticket |
|
|
48
|
+
| `tickets.getMany` | `hubspot.api.tickets.getMany` | `read` | Pages through tickets in id order, default properties only unless properties is set. |
|
|
49
|
+
| `tickets.update` | `hubspot.api.tickets.update` | `write` | Update an existing ticket |
|
|
50
|
+
|
|
51
|
+
## Auth
|
|
52
|
+
|
|
53
|
+
Auth: API key, OAuth 2.0, Managed OAuth (default API key). Set `authType` on the plugin factory to pick one.
|
|
54
|
+
|
|
55
|
+
## Webhooks
|
|
56
|
+
|
|
57
|
+
Handles 12 webhook events. See the reference for payloads and `webhookHooks`.
|
|
58
|
+
|
|
59
|
+
## Reference
|
|
60
|
+
|
|
61
|
+
Full docs, types, and examples: https://docs.corsair.dev/plugins/hubspot
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
Apache-2.0
|
package/dist/client.d.ts
CHANGED
|
@@ -7,4 +7,23 @@ export declare function makeHubSpotRequest<T>(endpoint: string, token: string, o
|
|
|
7
7
|
body?: Record<string, unknown>;
|
|
8
8
|
query?: Record<string, string | number | boolean | undefined>;
|
|
9
9
|
}): Promise<T>;
|
|
10
|
+
export declare function recentSearchBody(rawInput: {
|
|
11
|
+
count?: number;
|
|
12
|
+
after?: string;
|
|
13
|
+
since?: string;
|
|
14
|
+
} | undefined, property: string): {
|
|
15
|
+
filterGroups?: {
|
|
16
|
+
filters: {
|
|
17
|
+
propertyName: string;
|
|
18
|
+
operator: string;
|
|
19
|
+
value: string;
|
|
20
|
+
}[];
|
|
21
|
+
}[] | undefined;
|
|
22
|
+
limit: number | undefined;
|
|
23
|
+
after: string | undefined;
|
|
24
|
+
sorts: {
|
|
25
|
+
propertyName: string;
|
|
26
|
+
direction: string;
|
|
27
|
+
}[];
|
|
28
|
+
};
|
|
10
29
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../client.ts"],"names":[],"mappings":"AAIA,qBAAa,eAAgB,SAAQ,KAAK;aAGxB,IAAI,CAAC,EAAE,MAAM;gBAD7B,OAAO,EAAE,MAAM,EACC,IAAI,CAA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Root":"","sources":["../../endpoints/companies.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AASjD,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,cAAc,CA+BhD,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,CAAC,kBAAkB,CAoCxD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,iBAAiB,CA2BtD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,iBAAiB,CA2BtD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,gBAAgB,CAAC,iBAAiB,CAwB7D,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,6BAA6B,CA0B7E,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,6BAA6B,CA0B7E,CAAC;AAEH,eAAO,MAAM,cAAc,EAAE,gBAAgB,CAAC,yBAAyB,CA8BrE,CAAC"}
|
|
@@ -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;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,CA2BrD,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,
|
|
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,CA2BrD,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,CAgB5E,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,4BAA4B,CAgB5E,CAAC;AAEH,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,gBAAgB,CA6BrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deals.d.ts","sourceRoot":"","sources":["../../endpoints/deals.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAQjD,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,UAAU,CA2B5C,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAiCpD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,aAAa,CAwBlD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,aAAa,CAwBlD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,aAAa,CAwBtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,yBAAyB,
|
|
1
|
+
{"version":3,"file":"deals.d.ts","sourceRoot":"","sources":["../../endpoints/deals.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAQjD,eAAO,MAAM,GAAG,EAAE,gBAAgB,CAAC,UAAU,CA2B5C,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,gBAAgB,CAAC,cAAc,CAiCpD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,aAAa,CAwBlD,CAAC;AAEF,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,aAAa,CAwBlD,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,gBAAgB,CAAC,aAAa,CAwBtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,yBAAyB,CAgBzE,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,CAAC,yBAAyB,CAgBzE,CAAC;AAEH,eAAO,MAAM,MAAM,EAAE,gBAAgB,CAAC,aAAa,CAgBlD,CAAC"}
|
|
@@ -366,6 +366,7 @@ export declare const CompaniesEndpoints: {
|
|
|
366
366
|
searchByDomain: (ctx: import("..").HubSpotContext, args: {
|
|
367
367
|
domain: string;
|
|
368
368
|
properties?: string[] | undefined;
|
|
369
|
+
after?: string | undefined;
|
|
369
370
|
}) => Promise<{
|
|
370
371
|
[x: string]: unknown;
|
|
371
372
|
total?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../endpoints/index.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAS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;;;;;;;;;;;;;;;;CAKhC,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;CAGjC,CAAC;AAEF,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recent.test.d.ts","sourceRoot":"","sources":["../../endpoints/recent.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare function parseSince(since: string): number | undefined;
|
|
3
|
+
export declare const RecentInputSchema: z.ZodObject<{
|
|
4
|
+
count: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
after: z.ZodOptional<z.ZodString>;
|
|
6
|
+
since: z.ZodOptional<z.ZodString>;
|
|
7
|
+
}, z.core.$strip>;
|
|
2
8
|
export declare const HubSpotEndpointInputSchemas: {
|
|
3
9
|
readonly contactsGet: z.ZodObject<{
|
|
4
10
|
contactId: z.ZodString;
|
|
@@ -129,6 +135,7 @@ export declare const HubSpotEndpointInputSchemas: {
|
|
|
129
135
|
readonly companiesSearchByDomain: z.ZodObject<{
|
|
130
136
|
domain: z.ZodString;
|
|
131
137
|
properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
|
+
after: z.ZodOptional<z.ZodString>;
|
|
132
139
|
}, z.core.$strip>;
|
|
133
140
|
readonly dealsGet: z.ZodObject<{
|
|
134
141
|
dealId: z.ZodString;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../endpoints/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../endpoints/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA6GxB,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS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ZodString;
|
|
521
521
|
properties: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
522
|
+
after: z.ZodOptional<z.ZodString>;
|
|
522
523
|
}, z.core.$strip>;
|
|
523
524
|
readonly output: z.ZodObject<{
|
|
524
525
|
total: z.ZodOptional<z.ZodNumber>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,EAER,uBAAuB,EAGvB,MAAM,cAAc,CAAC;AAGtB,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,EACtB,MAAM,YAAY,CAAC;AAwBpB,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAChD,OAAO,aAAa,EACpB,oBAAoB,CACpB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;AAE/E,KAAK,eAAe,CAAC,CAAC,SAAS,MAAM,sBAAsB,IAAI,eAAe,CAC7E,cAAc,EACd,qBAAqB,CAAC,CAAC,CAAC,EACxB,sBAAsB,CAAC,CAAC,CAAC,C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AuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,EACtB,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,kBAAkB,CAAC;AAM1B,YAAY,EACX,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,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{AuthMissingError as ae}from"corsair/core";import{attachManagedRefreshAuth as ho,getManagedAccessToken as So}from"corsair/hub";import{z as y}from"zod";import{logEventFromContext as f}from"corsair/core";import{request as yt}from"corsair/http";var H=class extends Error{constructor(n,r){super(n);this.code=r;this.name="HubSpotAPIError"}},mt="https://api.hubapi.com";async function d(t,a,n={}){let{method:r="GET",body:s,query:o}=n,p={BASE:mt,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"?s:void 0,mediaType:"application/json",query:r==="GET"?o:void 0};try{return await yt(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 ne=async(t,a)=>{let{companyId:n,...r}=a,s=`/crm/v3/objects/companies/${n}`,o=await d(s,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 f(t,"hubspot.companies.get",{...a},"completed"),o},se=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/companies",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.companies)try{for(let o of s.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await f(t,"hubspot.companies.getMany",{...a},"completed"),s},re=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/companies",t.key,{method:"POST",body:n});if(s&&t.db.companies)try{await t.db.companies.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save company to database:",o)}return await f(t,"hubspot.companies.create",{...a},"completed"),s},pe=async(t,a)=>{let{companyId:n,...r}=a,s=`/crm/v3/objects/companies/${n}`,o=await d(s,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 f(t,"hubspot.companies.update",{...a},"completed"),o},ce=async(t,a)=>{let{companyId:n}=a,r=`/crm/v3/objects/companies/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.companies)try{await t.db.companies.deleteByEntityId(n)}catch(s){console.warn("Failed to delete company from database:",s)}await f(t,"hubspot.companies.delete",{...a},"completed")},ie=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/companies",t.key,{query:n});if(s.results&&t.db.companies)try{for(let o of s.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await f(t,"hubspot.companies.getRecentlyCreated",{...a},"completed"),s},de=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/companies",t.key,{query:n});if(s.results&&t.db.companies)try{for(let o of s.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await f(t,"hubspot.companies.getRecentlyUpdated",{...a},"completed"),s},le=async(t,a)=>{let{domain:n,...r}=a,o=await d("/crm/v3/objects/companies/search",t.key,{query:{...r,domain:n,properties:r.properties?.join(",")}});return await f(t,"hubspot.companies.searchByDomain",{...a},"completed"),o};import{logEventFromContext as ue}from"corsair/core";var ye=async(t,a)=>{let{listId:n,...r}=a,s=`/contacts/v1/lists/${n}/add`,o=await d(s,t.key,{method:"POST",body:r});return await ue(t,"hubspot.contactLists.addContact",{...a},"completed"),o},me=async(t,a)=>{let{listId:n,...r}=a,s=`/contacts/v1/lists/${n}/remove`,o=await d(s,t.key,{method:"POST",body:r});return await ue(t,"hubspot.contactLists.removeContact",{...a},"completed"),o};import{logEventFromContext as E}from"corsair/core";var be=async(t,a)=>{let{contactId:n,...r}=a,s=`/crm/v3/objects/contacts/${n}`,o=await d(s,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 E(t,"hubspot.contacts.get",{...a},"completed"),o},ge=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/contacts",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.contacts)try{for(let o of s.results)await t.db.contacts.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save contacts to database:",o)}return await E(t,"hubspot.contacts.getMany",{...a},"completed"),s},he=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/contacts",t.key,{method:"POST",body:n});if(s&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save contact to database:",o)}return await E(t,"hubspot.contacts.create",{...a},"completed"),s},Se=async(t,a)=>{let{contactId:n,...r}=a,s=`/crm/v3/objects/contacts/${n}`,o=await d(s,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 E(t,"hubspot.contacts.update",{...a},"completed"),o},Ce=async(t,a)=>{let{contactId:n}=a,r=`/crm/v3/objects/contacts/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.contacts)try{await t.db.contacts.deleteByEntityId(n)}catch(s){console.warn("Failed to delete contact from database:",s)}await E(t,"hubspot.contacts.delete",{...a},"completed")},ke=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/contacts",t.key,{query:n});return await E(t,"hubspot.contacts.getRecentlyCreated",{...a},"completed"),s},fe=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/contacts",t.key,{query:n});return await E(t,"hubspot.contacts.getRecentlyUpdated",{...a},"completed"),s},Ee=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/contacts/search",t.key,{method:"POST",body:n});if(s.results&&t.db.contacts)try{for(let o of s.results)await t.db.contacts.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save contacts to database:",o)}return await E(t,"hubspot.contacts.search",{...a},"completed"),s};import{logEventFromContext as v}from"corsair/core";var ve=async(t,a)=>{let{dealId:n,...r}=a,s=`/crm/v3/objects/deals/${n}`,o=await d(s,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},He=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/deals",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.deals)try{for(let o of s.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"),s},Re=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/deals",t.key,{method:"POST",body:n});if(s&&t.db.deals)try{await t.db.deals.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save deal to database:",o)}return await v(t,"hubspot.deals.create",{...a},"completed"),s},we=async(t,a)=>{let{dealId:n,...r}=a,s=`/crm/v3/objects/deals/${n}`,o=await d(s,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},Ie=async(t,a)=>{let{dealId:n}=a,r=`/crm/v3/objects/deals/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.deals)try{await t.db.deals.deleteByEntityId(n)}catch(s){console.warn("Failed to delete deal from database:",s)}await v(t,"hubspot.deals.delete",{...a},"completed")},Te=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/deals",t.key,{query:n});return await v(t,"hubspot.deals.getRecentlyCreated",{...a},"completed"),s},De=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/deals",t.key,{query:n});return await v(t,"hubspot.deals.getRecentlyUpdated",{...a},"completed"),s},je=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/deals/search",t.key,{method:"POST",body:n});return await v(t,"hubspot.deals.search",{...a},"completed"),s};import{logEventFromContext as G}from"corsair/core";var Ge=async(t,a)=>{let{engagementId:n}=a,r=`/crm/v3/objects/engagements/${n}`,s=await d(r,t.key);if(s&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(s.id,{...s})}catch(o){console.warn("Failed to save engagement to database:",o)}return await G(t,"hubspot.engagements.get",{...a},"completed"),s},Ue=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/engagements",t.key,{query:n});if(s.results&&t.db.engagements)try{for(let o of s.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"),s},Ae=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/engagements",t.key,{method:"POST",body:n});if(s&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(s.id,{...s})}catch(o){console.warn("Failed to save engagement to database:",o)}return await G(t,"hubspot.engagements.create",{...a},"completed"),s},Me=async(t,a)=>{let{engagementId:n}=a,r=`/crm/v3/objects/engagements/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.engagements)try{await t.db.engagements.deleteByEntityId(n)}catch(s){console.warn("Failed to delete engagement from database:",s)}await G(t,"hubspot.engagements.delete",{...a},"completed")};import{logEventFromContext as I}from"corsair/core";var We=async(t,a)=>{let{ticketId:n,...r}=a,s=`/crm/v3/objects/tickets/${n}`,o=await d(s,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{...n}=a||{},s=await d("/crm/v3/objects/tickets",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.tickets)try{for(let o of s.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"),s},xe=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/tickets",t.key,{method:"POST",body:n});if(s&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save ticket to database:",o)}return await I(t,"hubspot.tickets.create",{...a},"completed"),s},Le=async(t,a)=>{let{ticketId:n,...r}=a,s=`/crm/v3/objects/tickets/${n}`,o=await d(s,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},Be=async(t,a)=>{let{ticketId:n}=a,r=`/crm/v3/objects/tickets/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.tickets)try{await t.db.tickets.deleteByEntityId(n)}catch(s){console.warn("Failed to delete ticket from database:",s)}await I(t,"hubspot.tickets.delete",{...a},"completed")};import{z as e}from"zod";var ft=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()}),Et=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()}),vt=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()}),Ht=e.object({contactId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Rt=e.object({contactId:e.string()}),wt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),It=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Tt=e.enum(["BETWEEN","CONTAINS_TOKEN","EQ","GT","GTE","HAS_PROPERTY","IN","LT","LTE","NEQ","NOT_CONTAINS_TOKEN","NOT_HAS_PROPERTY","NOT_IN"]),Dt=e.object({operator:Tt,propertyName:e.string(),highValue:e.string().optional(),value:e.string().optional(),values:e.array(e.string()).optional()}),Fe=e.object({filters:e.array(Dt)}),jt=e.enum(["ASCENDING","DESCENDING"]),Ne=e.object({propertyName:e.string(),direction:jt}),Gt=e.object({id:e.string(),type:e.string().optional()}),Ut=e.object({results:e.array(Gt)}),D=e.record(e.string(),e.union([Ut,e.array(e.string())])),At=e.object({query:e.string().optional(),limit:e.number().optional(),after:e.string().optional(),sorts:e.array(Ne).optional(),properties:e.array(e.string()).optional(),filterGroups:e.array(Fe).optional()}),Mt=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()}),Wt=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()}),Pt=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()}),xt=e.object({companyId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Lt=e.object({companyId:e.string()}),Bt=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Ot=e.object({count:e.number().optional(),after:e.string().optional(),since:e.string().optional()}),Ft=e.object({domain:e.string(),properties:e.array(e.string()).optional()}),Nt=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()}),zt=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()}),_t=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()}),Vt=e.object({dealId:e.string(),properties:e.record(e.string(),e.string()).optional()}),qt=e.object({dealId:e.string()}),$t=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()}),Qt=e.object({query:e.string().optional(),limit:e.number().optional(),after:e.string().optional(),sorts:e.array(Ne).optional(),properties:e.array(e.string()).optional(),filterGroups:e.array(Fe).optional()}),Yt=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()}),Jt=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()}),Zt=e.object({ticketId:e.string(),properties:e.record(e.string(),e.string()).optional()}),eo=e.object({ticketId:e.string()}),to=e.object({engagementId:e.string()}),oo=e.object({limit:e.number().optional(),after:e.string().optional()}),ao=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()}),no=e.object({engagementId:e.string()}),so=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),ro=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),l={contactsGet:ft,contactsGetMany:Et,contactsCreate:vt,contactsUpdate:Ht,contactsDelete:Rt,contactsGetRecentlyCreated:wt,contactsGetRecentlyUpdated:It,contactsSearch:At,companiesGet:Mt,companiesGetMany:Wt,companiesCreate:Pt,companiesUpdate:xt,companiesDelete:Lt,companiesGetRecentlyCreated:Bt,companiesGetRecentlyUpdated:Ot,companiesSearchByDomain:Ft,dealsGet:Nt,dealsGetMany:zt,dealsCreate:_t,dealsUpdate:Vt,dealsDelete:qt,dealsGetRecentlyCreated:$t,dealsGetRecentlyUpdated:Kt,dealsSearch:Qt,ticketsGet:Yt,ticketsGetMany:Jt,ticketsCreate:Xt,ticketsUpdate:Zt,ticketsDelete:eo,engagementsGet:to,engagementsGetMany:oo,engagementsCreate:ao,engagementsDelete:no,contactListsAddContact:so,contactListsRemoveContact:ro},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:D.optional()}).loose(),T=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:D.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:D.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:D.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:D.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(T).optional(),paging:R.optional()}).loose(),A=e.object({total:e.number().optional(),results:e.array(W).optional(),paging:R.optional()}).loose(),po=e.object({results:e.array(P).optional(),paging:R.optional()}).loose(),co=e.object({results:e.array(z).optional(),paging:R.optional()}).loose(),io=e.object({total:e.number().optional(),results:e.array(T).optional(),paging:R.optional()}).loose(),Oe=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()}),u={contactsGet:M,contactsGetMany:U,contactsCreate:M,contactsUpdate:M,contactsDelete:e.void(),contactsGetRecentlyCreated:U,contactsGetRecentlyUpdated:U,contactsSearch:U,companiesGet:T,companiesGetMany:N,companiesCreate:T,companiesUpdate:T,companiesDelete:e.void(),companiesGetRecentlyCreated:N,companiesGetRecentlyUpdated:N,companiesSearchByDomain:io,dealsGet:W,dealsGetMany:A,dealsCreate:W,dealsUpdate:W,dealsDelete:e.void(),dealsGetRecentlyCreated:A,dealsGetRecentlyUpdated:A,dealsSearch:A,ticketsGet:P,ticketsGetMany:po,ticketsCreate:P,ticketsUpdate:P,ticketsDelete:e.void(),engagementsGet:z,engagementsGetMany:co,engagementsCreate:z,engagementsDelete:e.void(),contactListsAddContact:Oe,contactListsRemoveContact:Oe};var S={get:be,getMany:ge,create:he,update:Se,delete:Ce,getRecentlyCreated:ke,getRecentlyUpdated:fe,search:Ee},C={get:ne,getMany:se,create:re,update:pe,delete:ce,getRecentlyCreated:ie,getRecentlyUpdated:de,searchByDomain:le},k={get:ve,getMany:He,create:Re,update:we,delete:Ie,getRecentlyCreated:Te,getRecentlyUpdated:De,search:je},w={get:We,getMany:Pe,create:xe,update:Le,delete:Be},j={get:Ge,getMany:Ue,create:Ae,delete:Me},_={addContact:ye,removeContact:me};import{ApiError as ze}from"corsair/http";var _e={PERMISSION_ERROR:{match:(t,a)=>{if((t instanceof ze&&t.status===403||t instanceof H&&t.code===403)&&a.operation.toLowerCase().includes("tickets"))return!0;let n=t.message.toLowerCase();return n.includes("forbidden")||n.includes("permission denied")||n.includes("access denied")},handler:async(t,a)=>({maxRetries:0})},VALIDATION_ERROR:{match:(t,a)=>!!((t instanceof ze&&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 Ye}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()}),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()}),$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()}),Ke=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(),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 Jo=Ye.object({token:Ye.string()}),Je={version:"1.0.0",entities:{contacts:Ve,companies:qe,deals:$e,tickets:Ke,engagements:Qe}};import{verifyHmacSignature as lo}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()}),V=h.extend({subscriptionType:i.literal("contact.creation"),objectId:i.number()}),q=h.extend({subscriptionType:i.literal("contact.propertyChange"),objectId:i.number(),propertyName:i.string(),propertyValue:i.string()}),$=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()}),ta=i.union([V,q,$,K,Q,Y,J,X,Z,ee,te,oe]);function uo(t){return typeof t=="string"?JSON.parse(t):t}function m(t,a){if(!a)return{valid:!1};let n=t.rawBody;if(!n)return{valid:!1,error:"Missing raw body for signature verification"};let r=t.headers,s=Array.isArray(r["x-hubspot-signature-v3"])?r["x-hubspot-signature-v3"][0]:r["x-hubspot-signature-v3"];return s?lo(n,a,s)?{valid:!0}:{valid:!1,error:"Invalid signature"}:{valid:!1,error:"Missing x-hubspot-signature-v3 header"}}function b(t){return a=>{let n=uo(a.body);return(Array.isArray(n)?n:[n]).some(s=>typeof s=="object"&&s!==null&&"subscriptionType"in s&&typeof s.subscriptionType=="string"&&s.subscriptionType===t)}}var Xe={match:b("company.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},Ze={match:b("company.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},et={match:b("company.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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 tt={match:b("contact.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},ot={match:b("contact.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},at={match:b("contact.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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 nt={match:b("deal.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},st={match:b("deal.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},rt={match:b("deal.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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 pt={match:b("ticket.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},ct={match:b("ticket.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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}}}},it={match:b("ticket.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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:tt,updated:ot,deleted:at},L={created:Xe,updated:Ze,deleted:et},B={created:nt,updated:st,deleted:rt},O={created:pt,updated:ct,deleted:it};import{asRecord as yo,toExternalId as dt}from"corsair/core";async function lt(t){let a=dt(t.hub_id??yo(t.hub_domain)?.hub_id);if(a)return{linkType:"portal_id",externalId:a};let n=t.access_token;if(!n)return null;let r=await fetch(`https://api.hubapi.com/oauth/v1/access-tokens/${encodeURIComponent(n)}`);if(!r.ok)return null;let s=await r.json(),o=dt(s.hub_id);return o?{linkType:"portal_id",externalId:o}:null}import{asRecord as mo,firstString as bo}from"corsair/core";function go(t){if(Array.isArray(t))return t.filter(n=>n!==null&&typeof n=="object"&&!Array.isArray(n));let a=mo(t);return a?[a]:[]}function ut(t){let a=go(t.body);if(a.length===0)return null;let n=bo(a.map(r=>r.portalId));return n?{linkType:"portal_id",externalId:n}:null}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:k.get,getMany:k.getMany,create:k.create,update:k.update,delete:k.delete,getRecentlyCreated:k.getRecentlyCreated,getRecentlyUpdated:k.getRecentlyUpdated,search:k.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:_.addContact,removeContact:_.removeContact}},ko={"contacts.get":{input:l.contactsGet,output:u.contactsGet},"contacts.getMany":{input:l.contactsGetMany,output:u.contactsGetMany},"contacts.create":{input:l.contactsCreate,output:u.contactsCreate},"contacts.update":{input:l.contactsUpdate,output:u.contactsUpdate},"contacts.delete":{input:l.contactsDelete,output:u.contactsDelete},"contacts.getRecentlyCreated":{input:l.contactsGetRecentlyCreated,output:u.contactsGetRecentlyCreated},"contacts.getRecentlyUpdated":{input:l.contactsGetRecentlyUpdated,output:u.contactsGetRecentlyUpdated},"contacts.search":{input:l.contactsSearch,output:u.contactsSearch},"companies.get":{input:l.companiesGet,output:u.companiesGet},"companies.getMany":{input:l.companiesGetMany,output:u.companiesGetMany},"companies.create":{input:l.companiesCreate,output:u.companiesCreate},"companies.update":{input:l.companiesUpdate,output:u.companiesUpdate},"companies.delete":{input:l.companiesDelete,output:u.companiesDelete},"companies.getRecentlyCreated":{input:l.companiesGetRecentlyCreated,output:u.companiesGetRecentlyCreated},"companies.getRecentlyUpdated":{input:l.companiesGetRecentlyUpdated,output:u.companiesGetRecentlyUpdated},"companies.searchByDomain":{input:l.companiesSearchByDomain,output:u.companiesSearchByDomain},"deals.get":{input:l.dealsGet,output:u.dealsGet},"deals.getMany":{input:l.dealsGetMany,output:u.dealsGetMany},"deals.create":{input:l.dealsCreate,output:u.dealsCreate},"deals.update":{input:l.dealsUpdate,output:u.dealsUpdate},"deals.delete":{input:l.dealsDelete,output:u.dealsDelete},"deals.getRecentlyCreated":{input:l.dealsGetRecentlyCreated,output:u.dealsGetRecentlyCreated},"deals.getRecentlyUpdated":{input:l.dealsGetRecentlyUpdated,output:u.dealsGetRecentlyUpdated},"deals.search":{input:l.dealsSearch,output:u.dealsSearch},"tickets.get":{input:l.ticketsGet,output:u.ticketsGet},"tickets.getMany":{input:l.ticketsGetMany,output:u.ticketsGetMany},"tickets.create":{input:l.ticketsCreate,output:u.ticketsCreate},"tickets.update":{input:l.ticketsUpdate,output:u.ticketsUpdate},"tickets.delete":{input:l.ticketsDelete,output:u.ticketsDelete},"engagements.get":{input:l.engagementsGet,output:u.engagementsGet},"engagements.getMany":{input:l.engagementsGetMany,output:u.engagementsGetMany},"engagements.create":{input:l.engagementsCreate,output:u.engagementsCreate},"engagements.delete":{input:l.engagementsDelete,output:u.engagementsDelete},"contactLists.addContact":{input:l.contactListsAddContact,output:u.contactListsAddContact},"contactLists.removeContact":{input:l.contactListsRemoveContact,output:u.contactListsRemoveContact}},fo={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},Eo={contactCreated:{description:"A new contact was created",payload:V,response:y.object({success:y.boolean()})},contactUpdated:{description:"A contact property was updated",payload:q,response:y.object({success:y.boolean()})},contactDeleted:{description:"A contact was deleted",payload:$,response:y.object({success:y.boolean()})},companyCreated:{description:"A new company was created",payload:K,response:y.object({success:y.boolean()})},companyUpdated:{description:"A company property was updated",payload:Q,response:y.object({success:y.boolean()})},companyDeleted:{description:"A company was deleted",payload:Y,response:y.object({success:y.boolean()})},dealCreated:{description:"A new deal was created",payload:J,response:y.object({success:y.boolean()})},dealUpdated:{description:"A deal property was updated",payload:X,response:y.object({success:y.boolean()})},dealDeleted:{description:"A deal was deleted",payload:Z,response:y.object({success:y.boolean()})},ticketCreated:{description:"A new support ticket was created",payload:ee,response:y.object({success:y.boolean()})},ticketUpdated:{description:"A support ticket property was updated",payload:te,response:y.object({success:y.boolean()})},ticketDeleted:{description:"A support ticket was deleted",payload:oe,response:y.object({success:y.boolean()})}},vo="api_key",Ho={api_key:{account:["portal_id"]},oauth_2:{account:["portal_id"]},managed:{account:["portal_id"]}},Ro={"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??vo};return{id:"hubspot",authConfig:Ho,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:Je,options:a,hooks:a.hooks,webhookHooks:a.webhookHooks,endpoints:Co,webhooks:fo,endpointMeta:Ro,endpointSchemas:ko,webhookSchemas:Eo,pluginWebhookMatcher:n=>{let s="x-hubspot-signature-v3"in n.headers,o=n.body,F=(Array.isArray(o)?o:[o]).some(g=>typeof g.subscriptionType=="string"&&g.subscriptionType!==void 0);return s||F},pluginTenantWebhookMatcher:ut,oauthWebhookTenantLinkResolver:lt,errorHandlers:a.errorHandlers||_e,keyBuilder:async(n,r)=>{let s=n.authType;if(r==="webhook"&&a.webhookSecret)return a.webhookSecret;if(r==="webhook"){let o=await n.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(n.authType==="api_key"){let o=await n.keys.get_api_key();if(!o)throw new ae("hubspot","api_key");return o}else if(n.authType==="oauth_2"){let o=await n.keys.get_access_token();if(!o)throw new ae("hubspot","oauth_2");return o}}if(n.authType==="managed"){if(!n.hub)throw new Error("[auth-missing:hubspot:managed]: Hub config is required for managed auth. Pass hub: { ... } to createCorsair().");let o={keys:n.keys,hub:n.hub,plugin:"hubspot",tenantId:n.tenantId},p=await So(o);return await ho(n,o),p.accessToken}throw new ae("hubspot","oauth_2")}}}export{b as createHubSpotEventMatch,Ua as hubspot,Ho as hubspotAuthConfig,ko as hubspotEndpointSchemas,m as verifyHubSpotWebhookSignature};
|
|
1
|
+
import{AuthMissingError as re}from"corsair/core";import{attachManagedRefreshAuth as go,getManagedAccessToken as ho}from"corsair/hub";import{z as y}from"zod";import{logEventFromContext as v}from"corsair/core";import{request as to}from"corsair/http";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()}),ft=e.object({limit:e.number().optional().describe("Page size, max 100."),after:e.string().optional().describe("paging.next.after from the previous page."),properties:e.array(e.string()).optional().describe('Internal property names such as "hs_lead_status", not labels. Only default properties come back if omitted.'),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(),properties:e.record(e.string(),e.string()).optional()}),kt=e.object({contactId:e.string()}),Et=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:Et,propertyName:e.string(),highValue:e.string().optional(),value:e.string().optional(),values:e.array(e.string()).optional()}),pe=e.object({filters:e.array(vt)}),Ht=e.enum(["ASCENDING","DESCENDING"]),ce=e.object({propertyName:e.string(),direction:Ht}),Rt=e.object({id:e.string(),type:e.string().optional()}),wt=e.object({results:e.array(Rt)}),G=e.record(e.string(),e.union([wt,e.array(e.string())])),It=/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;function $(t){if(/^\d+$/.test(t))return Number(t);let a=It.exec(t);if(!a)return;let[n=0,r=0,s=0,o=0,i=0]=a.slice(1,6).map(gt=>Number(gt??0)),I=new Date(Date.UTC(n,r-1,s));if(I.getUTCMonth()!==r-1||I.getUTCDate()!==s||o>23||i>59||Number(a[6]??0)>59)return;let g=Date.parse(a[4]&&!a[7]?`${t}Z`:t);return Number.isNaN(g)?void 0:g}var E=e.object({count:e.number().int().max(200).optional().describe("Page size, max 200."),after:e.string().optional().describe("paging.next.after from the previous page."),since:e.string().refine(t=>$(t)!==void 0,{message:"since must be an ISO 8601 date-time or epoch milliseconds"}).optional().describe("ISO 8601 date-time (UTC when it has no offset) or epoch milliseconds; keeps records created (getRecentlyCreated) or modified (getRecentlyUpdated) at or after it.")}),Tt=e.object({query:e.string().optional().describe("Free text matched against the default searchable text properties."),limit:e.number().optional().describe("Page size, max 200."),after:e.string().optional().describe("paging.next.after from the previous page."),sorts:e.array(ce).optional().describe('One sort only, e.g. [{"propertyName":"createdate","direction":"DESCENDING"}].'),properties:e.array(e.string()).optional().describe("Internal property names to return, not labels. Only default properties come back if omitted."),filterGroups:e.array(pe).optional().describe('Groups are ORed, filters inside a group are ANDed (max 5 groups, 6 filters each). Dates as epoch milliseconds in a string. e.g. [{"filters":[{"propertyName":"email","operator":"EQ","value":"a@b.com"}]}].')}),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()}),jt=e.object({limit:e.number().optional().describe("Page size, max 100."),after:e.string().optional().describe("paging.next.after from the previous page."),properties:e.array(e.string()).optional().describe('Internal property names such as "hs_lead_status", not labels. Only default properties come back if omitted.'),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),Gt=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()}),Ut=e.object({companyId:e.string(),properties:e.record(e.string(),e.string()).optional()}),At=e.object({companyId:e.string()}),Mt=e.object({domain:e.string().describe('Company domain such as "example.com", matched exactly.'),properties:e.array(e.string()).optional().describe("Internal property names to return, not labels."),after:e.string().optional().describe("paging.next.after from the previous page.")}),xt=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().describe("Page size, max 100."),after:e.string().optional().describe("paging.next.after from the previous page."),properties:e.array(e.string()).optional().describe('Internal property names such as "hs_lead_status", not labels. Only default properties come back if omitted.'),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),Wt=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()}),Ot=e.object({dealId:e.string(),properties:e.record(e.string(),e.string()).optional()}),Bt=e.object({dealId:e.string()}),Lt=e.object({query:e.string().optional().describe("Free text matched against the default searchable text properties."),limit:e.number().optional().describe("Page size, max 200."),after:e.string().optional().describe("paging.next.after from the previous page."),sorts:e.array(ce).optional().describe('One sort only, e.g. [{"propertyName":"createdate","direction":"DESCENDING"}].'),properties:e.array(e.string()).optional().describe("Internal property names to return, not labels. Only default properties come back if omitted."),filterGroups:e.array(pe).optional().describe('Groups are ORed, filters inside a group are ANDed (max 5 groups, 6 filters each). Dates as epoch milliseconds in a string. e.g. [{"filters":[{"propertyName":"dealname","operator":"EQ","value":"Acme renewal"}]}].')}),Nt=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()}),zt=e.object({limit:e.number().optional().describe("Page size, max 100."),after:e.string().optional().describe("paging.next.after from the previous page."),properties:e.array(e.string()).optional().describe('Internal property names such as "hs_lead_status", not labels. Only default properties come back if omitted.'),propertiesWithHistory:e.array(e.string()).optional(),associations:e.array(e.string()).optional(),archived:e.boolean().optional()}),Ft=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()}),Vt=e.object({ticketId:e.string()}),$t=e.object({engagementId:e.string()}),Kt=e.object({limit:e.number().optional(),after:e.string().optional()}),qt=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()}),Qt=e.object({engagementId:e.string()}),Yt=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),Zt=e.object({listId:e.string(),emails:e.array(e.string()).optional(),vids:e.array(e.number()).optional()}),l={contactsGet:ht,contactsGetMany:ft,contactsCreate:St,contactsUpdate:Ct,contactsDelete:kt,contactsGetRecentlyCreated:E,contactsGetRecentlyUpdated:E,contactsSearch:Tt,companiesGet:Dt,companiesGetMany:jt,companiesCreate:Gt,companiesUpdate:Ut,companiesDelete:At,companiesGetRecentlyCreated:E,companiesGetRecentlyUpdated:E,companiesSearchByDomain:Mt,dealsGet:xt,dealsGetMany:Pt,dealsCreate:Wt,dealsUpdate:Ot,dealsDelete:Bt,dealsGetRecentlyCreated:E,dealsGetRecentlyUpdated:E,dealsSearch:Lt,ticketsGet:Nt,ticketsGetMany:zt,ticketsCreate:Ft,ticketsUpdate:_t,ticketsDelete:Vt,engagementsGet:$t,engagementsGetMany:Kt,engagementsCreate:qt,engagementsDelete:Qt,contactListsAddContact:Yt,contactListsRemoveContact:Zt},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:G.optional()}).loose(),j=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:G.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:G.optional()}).loose(),O=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:G.optional()}).loose(),V=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:G.optional(),metadata:e.record(e.string(),e.any()).optional()}).loose(),T=e.object({next:e.object({after:e.string()}).optional(),prev:e.object({before:e.string()}).optional()}),M=e.object({total:e.number().optional(),results:e.array(P).optional(),paging:T.optional()}).loose(),_=e.object({total:e.number().optional(),results:e.array(j).optional(),paging:T.optional()}).loose(),x=e.object({total:e.number().optional(),results:e.array(W).optional(),paging:T.optional()}).loose(),Jt=e.object({results:e.array(O).optional(),paging:T.optional()}).loose(),Xt=e.object({results:e.array(V).optional(),paging:T.optional()}).loose(),eo=e.object({total:e.number().optional(),results:e.array(j).optional(),paging:T.optional()}).loose(),ie=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()}),u={contactsGet:P,contactsGetMany:M,contactsCreate:P,contactsUpdate:P,contactsDelete:e.void(),contactsGetRecentlyCreated:M,contactsGetRecentlyUpdated:M,contactsSearch:M,companiesGet:j,companiesGetMany:_,companiesCreate:j,companiesUpdate:j,companiesDelete:e.void(),companiesGetRecentlyCreated:_,companiesGetRecentlyUpdated:_,companiesSearchByDomain:eo,dealsGet:W,dealsGetMany:x,dealsCreate:W,dealsUpdate:W,dealsDelete:e.void(),dealsGetRecentlyCreated:x,dealsGetRecentlyUpdated:x,dealsSearch:x,ticketsGet:O,ticketsGetMany:Jt,ticketsCreate:O,ticketsUpdate:O,ticketsDelete:e.void(),engagementsGet:V,engagementsGetMany:Xt,engagementsCreate:V,engagementsDelete:e.void(),contactListsAddContact:ie,contactListsRemoveContact:ie};var w=class extends Error{constructor(n,r){super(n);this.code=r;this.name="HubSpotAPIError"}},oo="https://api.hubapi.com";async function d(t,a,n={}){let{method:r="GET",body:s,query:o}=n,i={BASE:oo,VERSION:"1.0.0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",TOKEN:a,HEADERS:{"Content-Type":"application/json"}},I={method:r,url:t,body:r==="POST"||r==="PUT"||r==="PATCH"?s:void 0,mediaType:"application/json",query:r==="GET"?o:void 0};try{return await to(i,I)}catch(g){throw g&&typeof g=="object"&&"status"in g&&typeof g.status=="number"?new w(g instanceof Error?g.message:"HubSpot API error",g.status):new w(g instanceof Error?g.message:"Unknown error")}}function f(t,a){let{count:n,after:r,since:s}=E.parse(t??{}),o=s&&String($(s));return{limit:n,after:r,sorts:[{propertyName:a,direction:"DESCENDING"}],...o&&{filterGroups:[{filters:[{propertyName:a,operator:"GTE",value:o}]}]}}}var de=async(t,a)=>{let{companyId:n,...r}=a,s=`/crm/v3/objects/companies/${n}`,o=await d(s,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(i){console.warn("Failed to save company to database:",i)}return await v(t,"hubspot.companies.get",{...a},"completed"),o},le=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/companies",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.companies)try{for(let o of s.results)await t.db.companies.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save companies to database:",o)}return await v(t,"hubspot.companies.getMany",{...a},"completed"),s},ue=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/companies",t.key,{method:"POST",body:n});if(s&&t.db.companies)try{await t.db.companies.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save company to database:",o)}return await v(t,"hubspot.companies.create",{...a},"completed"),s},ye=async(t,a)=>{let{companyId:n,...r}=a,s=`/crm/v3/objects/companies/${n}`,o=await d(s,t.key,{method:"PATCH",body:r});if(o&&t.db.companies)try{await t.db.companies.upsertByEntityId(o.id,o)}catch(i){console.warn("Failed to save company to database:",i)}return await v(t,"hubspot.companies.update",{...a},"completed"),o},me=async(t,a)=>{let{companyId:n}=a,r=`/crm/v3/objects/companies/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.companies)try{await t.db.companies.deleteByEntityId(n)}catch(s){console.warn("Failed to delete company from database:",s)}await v(t,"hubspot.companies.delete",{...a},"completed")},be=async(t,a)=>{let r=await d("/crm/v3/objects/companies/search",t.key,{method:"POST",body:f(a,"createdate")});if(r.results&&t.db.companies)try{for(let s of r.results)await t.db.companies.upsertByEntityId(s.id,s)}catch(s){console.warn("Failed to save companies to database:",s)}return await v(t,"hubspot.companies.getRecentlyCreated",{...a},"completed"),r},ge=async(t,a)=>{let r=await d("/crm/v3/objects/companies/search",t.key,{method:"POST",body:f(a,"hs_lastmodifieddate")});if(r.results&&t.db.companies)try{for(let s of r.results)await t.db.companies.upsertByEntityId(s.id,s)}catch(s){console.warn("Failed to save companies to database:",s)}return await v(t,"hubspot.companies.getRecentlyUpdated",{...a},"completed"),r},he=async(t,a)=>{let{domain:n,properties:r,after:s}=a,i=await d("/crm/v3/objects/companies/search",t.key,{method:"POST",body:{filterGroups:[{filters:[{propertyName:"domain",operator:"EQ",value:n}]}],properties:r,after:s}});return await v(t,"hubspot.companies.searchByDomain",{...a},"completed"),i};import{logEventFromContext as fe}from"corsair/core";var Se=async(t,a)=>{let{listId:n,...r}=a,s=`/contacts/v1/lists/${n}/add`,o=await d(s,t.key,{method:"POST",body:r});return await fe(t,"hubspot.contactLists.addContact",{...a},"completed"),o},Ce=async(t,a)=>{let{listId:n,...r}=a,s=`/contacts/v1/lists/${n}/remove`,o=await d(s,t.key,{method:"POST",body:r});return await fe(t,"hubspot.contactLists.removeContact",{...a},"completed"),o};import{logEventFromContext as H}from"corsair/core";var ke=async(t,a)=>{let{contactId:n,...r}=a,s=`/crm/v3/objects/contacts/${n}`,o=await d(s,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(i){console.warn("Failed to save contact to database:",i)}return await H(t,"hubspot.contacts.get",{...a},"completed"),o},Ee=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/contacts",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.contacts)try{for(let o of s.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"),s},ve=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/contacts",t.key,{method:"POST",body:n});if(s&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save contact to database:",o)}return await H(t,"hubspot.contacts.create",{...a},"completed"),s},He=async(t,a)=>{let{contactId:n,...r}=a,s=`/crm/v3/objects/contacts/${n}`,o=await d(s,t.key,{method:"PATCH",body:r});if(o&&t.db.contacts)try{await t.db.contacts.upsertByEntityId(o.id,o)}catch(i){console.warn("Failed to save contact to database:",i)}return await H(t,"hubspot.contacts.update",{...a},"completed"),o},Re=async(t,a)=>{let{contactId:n}=a,r=`/crm/v3/objects/contacts/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.contacts)try{await t.db.contacts.deleteByEntityId(n)}catch(s){console.warn("Failed to delete contact from database:",s)}await H(t,"hubspot.contacts.delete",{...a},"completed")},we=async(t,a)=>{let r=await d("/crm/v3/objects/contacts/search",t.key,{method:"POST",body:f(a,"createdate")});return await H(t,"hubspot.contacts.getRecentlyCreated",{...a},"completed"),r},Ie=async(t,a)=>{let r=await d("/crm/v3/objects/contacts/search",t.key,{method:"POST",body:f(a,"lastmodifieddate")});return await H(t,"hubspot.contacts.getRecentlyUpdated",{...a},"completed"),r},Te=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/contacts/search",t.key,{method:"POST",body:n});if(s.results&&t.db.contacts)try{for(let o of s.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"),s};import{logEventFromContext as R}from"corsair/core";var De=async(t,a)=>{let{dealId:n,...r}=a,s=`/crm/v3/objects/deals/${n}`,o=await d(s,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(i){console.warn("Failed to save deal to database:",i)}return await R(t,"hubspot.deals.get",{...a},"completed"),o},je=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/deals",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.deals)try{for(let o of s.results)await t.db.deals.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save deals to database:",o)}return await R(t,"hubspot.deals.getMany",{...a},"completed"),s},Ge=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/deals",t.key,{method:"POST",body:n});if(s&&t.db.deals)try{await t.db.deals.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save deal to database:",o)}return await R(t,"hubspot.deals.create",{...a},"completed"),s},Ue=async(t,a)=>{let{dealId:n,...r}=a,s=`/crm/v3/objects/deals/${n}`,o=await d(s,t.key,{method:"PATCH",body:r});if(o&&t.db.deals)try{await t.db.deals.upsertByEntityId(o.id,o)}catch(i){console.warn("Failed to update deal in database:",i)}return await R(t,"hubspot.deals.update",{...a},"completed"),o},Ae=async(t,a)=>{let{dealId:n}=a,r=`/crm/v3/objects/deals/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.deals)try{await t.db.deals.deleteByEntityId(n)}catch(s){console.warn("Failed to delete deal from database:",s)}await R(t,"hubspot.deals.delete",{...a},"completed")},Me=async(t,a)=>{let r=await d("/crm/v3/objects/deals/search",t.key,{method:"POST",body:f(a,"createdate")});return await R(t,"hubspot.deals.getRecentlyCreated",{...a},"completed"),r},xe=async(t,a)=>{let r=await d("/crm/v3/objects/deals/search",t.key,{method:"POST",body:f(a,"hs_lastmodifieddate")});return await R(t,"hubspot.deals.getRecentlyUpdated",{...a},"completed"),r},Pe=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/deals/search",t.key,{method:"POST",body:n});return await R(t,"hubspot.deals.search",{...a},"completed"),s};import{logEventFromContext as B}from"corsair/core";var We=async(t,a)=>{let{engagementId:n}=a,r=`/crm/v3/objects/engagements/${n}`,s=await d(r,t.key);if(s&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(s.id,{...s})}catch(o){console.warn("Failed to save engagement to database:",o)}return await B(t,"hubspot.engagements.get",{...a},"completed"),s},Oe=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/engagements",t.key,{query:n});if(s.results&&t.db.engagements)try{for(let o of s.results)await t.db.engagements.upsertByEntityId(o.id,{...o})}catch(o){console.warn("Failed to save engagements to database:",o)}return await B(t,"hubspot.engagements.getMany",{...a},"completed"),s},Be=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/engagements",t.key,{method:"POST",body:n});if(s&&t.db.engagements)try{await t.db.engagements.upsertByEntityId(s.id,{...s})}catch(o){console.warn("Failed to save engagement to database:",o)}return await B(t,"hubspot.engagements.create",{...a},"completed"),s},Le=async(t,a)=>{let{engagementId:n}=a,r=`/crm/v3/objects/engagements/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.engagements)try{await t.db.engagements.deleteByEntityId(n)}catch(s){console.warn("Failed to delete engagement from database:",s)}await B(t,"hubspot.engagements.delete",{...a},"completed")};import{logEventFromContext as U}from"corsair/core";var Ne=async(t,a)=>{let{ticketId:n,...r}=a,s=`/crm/v3/objects/tickets/${n}`,o=await d(s,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(i){console.warn("Failed to save ticket to database:",i)}return await U(t,"hubspot.tickets.get",{...a},"completed"),o},ze=async(t,a)=>{let{...n}=a||{},s=await d("/crm/v3/objects/tickets",t.key,{query:{...n,properties:n.properties?.join(","),propertiesWithHistory:n.propertiesWithHistory?.join(","),associations:n.associations?.join(",")}});if(s.results&&t.db.tickets)try{for(let o of s.results)await t.db.tickets.upsertByEntityId(o.id,o)}catch(o){console.warn("Failed to save tickets to database:",o)}return await U(t,"hubspot.tickets.getMany",{...a},"completed"),s},Fe=async(t,a)=>{let{...n}=a,s=await d("/crm/v3/objects/tickets",t.key,{method:"POST",body:n});if(s&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(s.id,s)}catch(o){console.warn("Failed to save ticket to database:",o)}return await U(t,"hubspot.tickets.create",{...a},"completed"),s},_e=async(t,a)=>{let{ticketId:n,...r}=a,s=`/crm/v3/objects/tickets/${n}`,o=await d(s,t.key,{method:"PATCH",body:r});if(o&&t.db.tickets)try{await t.db.tickets.upsertByEntityId(o.id,o)}catch(i){console.warn("Failed to update ticket in database:",i)}return await U(t,"hubspot.tickets.update",{...a},"completed"),o},Ve=async(t,a)=>{let{ticketId:n}=a,r=`/crm/v3/objects/tickets/${n}`;if(await d(r,t.key,{method:"DELETE"}),t.db.tickets)try{await t.db.tickets.deleteByEntityId(n)}catch(s){console.warn("Failed to delete ticket from database:",s)}await U(t,"hubspot.tickets.delete",{...a},"completed")};var S={get:ke,getMany:Ee,create:ve,update:He,delete:Re,getRecentlyCreated:we,getRecentlyUpdated:Ie,search:Te},C={get:de,getMany:le,create:ue,update:ye,delete:me,getRecentlyCreated:be,getRecentlyUpdated:ge,searchByDomain:he},k={get:De,getMany:je,create:Ge,update:Ue,delete:Ae,getRecentlyCreated:Me,getRecentlyUpdated:xe,search:Pe},D={get:Ne,getMany:ze,create:Fe,update:_e,delete:Ve},A={get:We,getMany:Oe,create:Be,delete:Le},K={addContact:Se,removeContact:Ce};import{ApiError as $e}from"corsair/http";var Ke={PERMISSION_ERROR:{match:(t,a)=>{if((t instanceof $e&&t.status===403||t instanceof w&&t.code===403)&&a.operation.toLowerCase().includes("tickets"))return!0;let n=t.message.toLowerCase();return n.includes("forbidden")||n.includes("permission denied")||n.includes("access denied")},handler:async(t,a)=>({maxRetries:0})},VALIDATION_ERROR:{match:(t,a)=>!!((t instanceof $e&&t.status===400||t instanceof w&&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 Xe}from"zod";import{z as p}from"zod";var qe=p.object({id:p.string(),properties:p.record(p.string(),p.any()).optional(),createdAt:p.coerce.date().nullable().optional(),updatedAt:p.coerce.date().nullable().optional(),archived:p.boolean().optional()}),Qe=p.object({id:p.string(),properties:p.record(p.string(),p.any()).optional(),createdAt:p.coerce.date().nullable().optional(),updatedAt:p.coerce.date().nullable().optional(),archived:p.boolean().optional()}),Ye=p.object({id:p.string(),properties:p.record(p.string(),p.any()).optional(),createdAt:p.coerce.date().nullable().optional(),updatedAt:p.coerce.date().nullable().optional(),archived:p.boolean().optional()}),Ze=p.object({id:p.string(),properties:p.record(p.string(),p.any()).optional(),createdAt:p.coerce.date().nullable().optional(),updatedAt:p.coerce.date().nullable().optional(),archived:p.boolean().optional()}),Je=p.object({id:p.string(),engagement:p.object({id:p.number().optional(),portalId:p.number().optional(),active:p.boolean().optional(),createdAt:p.number().optional(),lastUpdated:p.number().optional(),createdBy:p.number().optional(),modifiedBy:p.number().optional(),ownerId:p.number().optional(),type:p.string().optional(),timestamp:p.number().optional()}).optional(),associations:p.record(p.string(),p.any()).optional(),metadata:p.record(p.string(),p.any()).optional()});var Zo=Xe.object({token:Xe.string()}),et={version:"1.0.0",entities:{contacts:qe,companies:Qe,deals:Ye,tickets:Ze,engagements:Je}};import{verifyHmacSignature as co}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()}),q=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()}),Y=h.extend({subscriptionType:c.literal("contact.deletion"),objectId:c.number()}),Z=h.extend({subscriptionType:c.literal("company.creation"),objectId:c.number()}),J=h.extend({subscriptionType:c.literal("company.propertyChange"),objectId:c.number(),propertyName:c.string(),propertyValue:c.string()}),X=h.extend({subscriptionType:c.literal("company.deletion"),objectId:c.number()}),ee=h.extend({subscriptionType:c.literal("deal.creation"),objectId:c.number()}),te=h.extend({subscriptionType:c.literal("deal.propertyChange"),objectId:c.number(),propertyName:c.string(),propertyValue:c.string()}),oe=h.extend({subscriptionType:c.literal("deal.deletion"),objectId:c.number()}),ae=h.extend({subscriptionType:c.literal("ticket.creation"),objectId:c.number()}),ne=h.extend({subscriptionType:c.literal("ticket.propertyChange"),objectId:c.number(),propertyName:c.string(),propertyValue:c.string()}),se=h.extend({subscriptionType:c.literal("ticket.deletion"),objectId:c.number()}),ta=c.union([q,Q,Y,Z,J,X,ee,te,oe,ae,ne,se]);function lo(t){return typeof t=="string"?JSON.parse(t):t}function m(t,a){if(!a)return{valid:!1,error:"Missing webhook secret"};let n=t.rawBody;if(!n)return{valid:!1,error:"Missing raw body for signature verification"};let r=t.headers,s=Array.isArray(r["x-hubspot-signature-v3"])?r["x-hubspot-signature-v3"][0]:r["x-hubspot-signature-v3"];return s?co(n,a,s)?{valid:!0}:{valid:!1,error:"Invalid signature"}:{valid:!1,error:"Missing x-hubspot-signature-v3 header"}}function b(t){return a=>{let n=lo(a.body);return(Array.isArray(n)?n:[n]).some(s=>typeof s=="object"&&s!==null&&"subscriptionType"in s&&typeof s.subscriptionType=="string"&&s.subscriptionType===t)}}var tt={match:b("company.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to save company to database:",i)}return{success:!0,data:{success:!0}}}},ot={match:b("company.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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 i=await t.db.companies.findByEntityId(o.objectId.toString());await t.db.companies.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...i?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:i?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(i){console.warn("Failed to update company in database:",i)}return{success:!0,data:{success:!0}}}},at={match:b("company.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to delete company from database:",i)}return{success:!0,data:{success:!0}}}};var nt={match:b("contact.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to save contact to database:",i)}return{success:!0,data:{success:!0}}}},st={match:b("contact.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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 i=await t.db.contacts.findByEntityId(o.objectId.toString());await t.db.contacts.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...i?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:i?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(i){console.warn("Failed to update contact in database:",i)}return{success:!0,data:{success:!0}}}},rt={match:b("contact.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to delete contact from database:",i)}return{success:!0,data:{success:!0}}}};var it={match:b("deal.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to save deal to database:",i)}return{success:!0,data:{success:!0}}}},pt={match:b("deal.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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 i=await t.db.deals.findByEntityId(o.objectId.toString());await t.db.deals.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...i?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:i?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(i){console.warn("Failed to update deal in database:",i)}return{success:!0,data:{success:!0}}}},ct={match:b("deal.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to delete deal from database:",i)}return{success:!0,data:{success:!0}}}};var dt={match:b("ticket.creation"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to save ticket to database:",i)}return{success:!0,data:{success:!0}}}},lt={match:b("ticket.propertyChange"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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 i=await t.db.tickets.findByEntityId(o.objectId.toString());await t.db.tickets.upsertByEntityId(o.objectId.toString(),{id:o.objectId.toString(),properties:{...i?.data?.properties||{},[o.propertyName||""]:o.propertyValue},createdAt:i?.data?.createdAt||new Date(o.occurredAt),updatedAt:new Date(o.occurredAt)})}catch(i){console.warn("Failed to update ticket in database:",i)}return{success:!0,data:{success:!0}}}},ut={match:b("ticket.deletion"),handler:async(t,a)=>{let n=t.key,r=m(a,n);if(!r.valid)return{success:!1,statusCode:401,error:r.error||"Signature verification failed"};let s=Array.isArray(a.payload)?a.payload:[a.payload];for(let o of s)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(i){console.warn("Failed to delete ticket from database:",i)}return{success:!0,data:{success:!0}}}};var L={created:nt,updated:st,deleted:rt},N={created:tt,updated:ot,deleted:at},z={created:it,updated:pt,deleted:ct},F={created:dt,updated:lt,deleted:ut};import{asRecord as uo,toExternalId as yt}from"corsair/core";async function mt(t){let a=yt(t.hub_id??uo(t.hub_domain)?.hub_id);if(a)return{linkType:"portal_id",externalId:a};let n=t.access_token;if(!n)return null;let r=await fetch(`https://api.hubapi.com/oauth/v1/access-tokens/${encodeURIComponent(n)}`);if(!r.ok)return null;let s=await r.json(),o=yt(s.hub_id);return o?{linkType:"portal_id",externalId:o}:null}import{asRecord as yo,firstString as mo}from"corsair/core";function bo(t){if(Array.isArray(t))return t.filter(n=>n!==null&&typeof n=="object"&&!Array.isArray(n));let a=yo(t);return a?[a]:[]}function bt(t){let a=bo(t.body);if(a.length===0)return null;let n=mo(a.map(r=>r.portalId));return n?{linkType:"portal_id",externalId:n}:null}var fo={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:k.get,getMany:k.getMany,create:k.create,update:k.update,delete:k.delete,getRecentlyCreated:k.getRecentlyCreated,getRecentlyUpdated:k.getRecentlyUpdated,search:k.search},tickets:{get:D.get,getMany:D.getMany,create:D.create,update:D.update,delete:D.delete},engagements:{get:A.get,getMany:A.getMany,create:A.create,delete:A.delete},contactLists:{addContact:K.addContact,removeContact:K.removeContact}},So={"contacts.get":{input:l.contactsGet,output:u.contactsGet},"contacts.getMany":{input:l.contactsGetMany,output:u.contactsGetMany},"contacts.create":{input:l.contactsCreate,output:u.contactsCreate},"contacts.update":{input:l.contactsUpdate,output:u.contactsUpdate},"contacts.delete":{input:l.contactsDelete,output:u.contactsDelete},"contacts.getRecentlyCreated":{input:l.contactsGetRecentlyCreated,output:u.contactsGetRecentlyCreated},"contacts.getRecentlyUpdated":{input:l.contactsGetRecentlyUpdated,output:u.contactsGetRecentlyUpdated},"contacts.search":{input:l.contactsSearch,output:u.contactsSearch},"companies.get":{input:l.companiesGet,output:u.companiesGet},"companies.getMany":{input:l.companiesGetMany,output:u.companiesGetMany},"companies.create":{input:l.companiesCreate,output:u.companiesCreate},"companies.update":{input:l.companiesUpdate,output:u.companiesUpdate},"companies.delete":{input:l.companiesDelete,output:u.companiesDelete},"companies.getRecentlyCreated":{input:l.companiesGetRecentlyCreated,output:u.companiesGetRecentlyCreated},"companies.getRecentlyUpdated":{input:l.companiesGetRecentlyUpdated,output:u.companiesGetRecentlyUpdated},"companies.searchByDomain":{input:l.companiesSearchByDomain,output:u.companiesSearchByDomain},"deals.get":{input:l.dealsGet,output:u.dealsGet},"deals.getMany":{input:l.dealsGetMany,output:u.dealsGetMany},"deals.create":{input:l.dealsCreate,output:u.dealsCreate},"deals.update":{input:l.dealsUpdate,output:u.dealsUpdate},"deals.delete":{input:l.dealsDelete,output:u.dealsDelete},"deals.getRecentlyCreated":{input:l.dealsGetRecentlyCreated,output:u.dealsGetRecentlyCreated},"deals.getRecentlyUpdated":{input:l.dealsGetRecentlyUpdated,output:u.dealsGetRecentlyUpdated},"deals.search":{input:l.dealsSearch,output:u.dealsSearch},"tickets.get":{input:l.ticketsGet,output:u.ticketsGet},"tickets.getMany":{input:l.ticketsGetMany,output:u.ticketsGetMany},"tickets.create":{input:l.ticketsCreate,output:u.ticketsCreate},"tickets.update":{input:l.ticketsUpdate,output:u.ticketsUpdate},"tickets.delete":{input:l.ticketsDelete,output:u.ticketsDelete},"engagements.get":{input:l.engagementsGet,output:u.engagementsGet},"engagements.getMany":{input:l.engagementsGetMany,output:u.engagementsGetMany},"engagements.create":{input:l.engagementsCreate,output:u.engagementsCreate},"engagements.delete":{input:l.engagementsDelete,output:u.engagementsDelete},"contactLists.addContact":{input:l.contactListsAddContact,output:u.contactListsAddContact},"contactLists.removeContact":{input:l.contactListsRemoveContact,output:u.contactListsRemoveContact}},Co={contactCreated:L.created,contactUpdated:L.updated,contactDeleted:L.deleted,companyCreated:N.created,companyUpdated:N.updated,companyDeleted:N.deleted,dealCreated:z.created,dealUpdated:z.updated,dealDeleted:z.deleted,ticketCreated:F.created,ticketUpdated:F.updated,ticketDeleted:F.deleted},ko={contactCreated:{description:"A new contact was created",payload:q,response:y.object({success:y.boolean()})},contactUpdated:{description:"A contact property was updated",payload:Q,response:y.object({success:y.boolean()})},contactDeleted:{description:"A contact was deleted",payload:Y,response:y.object({success:y.boolean()})},companyCreated:{description:"A new company was created",payload:Z,response:y.object({success:y.boolean()})},companyUpdated:{description:"A company property was updated",payload:J,response:y.object({success:y.boolean()})},companyDeleted:{description:"A company was deleted",payload:X,response:y.object({success:y.boolean()})},dealCreated:{description:"A new deal was created",payload:ee,response:y.object({success:y.boolean()})},dealUpdated:{description:"A deal property was updated",payload:te,response:y.object({success:y.boolean()})},dealDeleted:{description:"A deal was deleted",payload:oe,response:y.object({success:y.boolean()})},ticketCreated:{description:"A new support ticket was created",payload:ae,response:y.object({success:y.boolean()})},ticketUpdated:{description:"A support ticket property was updated",payload:ne,response:y.object({success:y.boolean()})},ticketDeleted:{description:"A support ticket was deleted",payload:se,response:y.object({success:y.boolean()})}},Eo="api_key",vo={api_key:{account:["portal_id"]},oauth_2:{account:["portal_id"]},managed:{account:["portal_id"]}},Ho={"contacts.get":{riskLevel:"read",description:"Get a specific contact"},"contacts.getMany":{riskLevel:"read",description:"Pages through contacts in id order, default properties only unless properties is set. To find contacts by field or date use contacts.search."},"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:"Newest contacts first by creation date; since keeps only those created at or after it. Page with paging.next.after."},"contacts.getRecentlyUpdated":{riskLevel:"read",description:"Most recently modified contacts first; since keeps only those modified at or after it. Page with paging.next.after."},"contacts.search":{riskLevel:"read",description:"Search with query text and/or filterGroups; only default properties come back unless properties is set. Up to 200 per page and 10,000 results; follow paging.next.after."},"companies.get":{riskLevel:"read",description:"Get a specific company"},"companies.getMany":{riskLevel:"read",description:"Pages through companies in id order, default properties only unless properties is set. To find a company by domain use companies.searchByDomain."},"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:"Newest companies first by creation date; since keeps only those created at or after it. Page with paging.next.after."},"companies.getRecentlyUpdated":{riskLevel:"read",description:"Most recently modified companies first; since keeps only those modified at or after it. Page with paging.next.after."},"companies.searchByDomain":{riskLevel:"read",description:"Finds companies whose domain equals domain exactly (a search, not a prefix match)."},"deals.get":{riskLevel:"read",description:"Get a specific deal"},"deals.getMany":{riskLevel:"read",description:"Pages through deals in id order, default properties only unless properties is set. To find deals by field or date use deals.search."},"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:"Newest deals first by creation date; since keeps only those created at or after it. Page with paging.next.after."},"deals.getRecentlyUpdated":{riskLevel:"read",description:"Most recently modified deals first; since keeps only those modified at or after it. Page with paging.next.after."},"deals.search":{riskLevel:"read",description:"Search with query text and/or filterGroups; only default properties come back unless properties is set. Up to 200 per page and 10,000 results; follow paging.next.after."},"tickets.get":{riskLevel:"read",description:"Get a specific ticket"},"tickets.getMany":{riskLevel:"read",description:"Pages through tickets in id order, default properties only unless properties is set."},"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??Eo};return{id:"hubspot",authConfig:vo,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:et,options:a,hooks:a.hooks,webhookHooks:a.webhookHooks,endpoints:fo,webhooks:Co,endpointMeta:Ho,endpointSchemas:So,webhookSchemas:ko,pluginWebhookMatcher:n=>{let s="x-hubspot-signature-v3"in n.headers,o=n.body,I=(Array.isArray(o)?o:[o]).some(g=>typeof g.subscriptionType=="string"&&g.subscriptionType!==void 0);return s||I},pluginTenantWebhookMatcher:bt,oauthWebhookTenantLinkResolver:mt,errorHandlers:a.errorHandlers||Ke,keyBuilder:async(n,r)=>{let s=n.authType;if(r==="webhook"&&a.webhookSecret)return a.webhookSecret;if(r==="webhook"){let o=await n.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(n.authType==="api_key"){let o=await n.keys.get_api_key();if(!o)throw new re("hubspot","api_key");return o}else if(n.authType==="oauth_2"){let o=await n.keys.get_access_token();if(!o)throw new re("hubspot","oauth_2");return o}}if(n.authType==="managed"){if(!n.hub)throw new Error("[auth-missing:hubspot:managed]: Hub config is required for managed auth. Pass hub: { ... } to createCorsair().");let o={keys:n.keys,hub:n.hub,plugin:"hubspot",tenantId:n.tenantId},i=await ho(o);return await go(n,o),i.accessToken}throw new re("hubspot","oauth_2")}}}export{b as createHubSpotEventMatch,Ua as hubspot,vo as hubspotAuthConfig,So as hubspotEndpointSchemas,m as verifyHubSpotWebhookSignature};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.test.d.ts","sourceRoot":"","sources":["../../webhooks/types.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@corsair-dev/hubspot",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Hubspot plugin for Corsair",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,18 +28,24 @@
|
|
|
28
28
|
"typescript": "^5.9.3",
|
|
29
29
|
"zod": "^4.1.13",
|
|
30
30
|
"jest": "^29.7.0",
|
|
31
|
-
"corsair": "0.
|
|
31
|
+
"corsair": "0.2.31"
|
|
32
32
|
},
|
|
33
33
|
"keywords": [
|
|
34
34
|
"corsair",
|
|
35
35
|
"hubspot",
|
|
36
36
|
"plugin"
|
|
37
37
|
],
|
|
38
|
-
"author": "",
|
|
38
|
+
"author": "Corsair (https://corsair.dev)",
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"files": [
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "git+https://github.com/corsairdev/corsair.git",
|
|
46
|
+
"directory": "packages/hubspot"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://docs.corsair.dev/plugins/hubspot",
|
|
43
49
|
"scripts": {
|
|
44
50
|
"build": "rm -rf dist && tsc --build --force && tsup",
|
|
45
51
|
"typecheck": "tsc --noEmit",
|