@frogbotai/piece-hubspot 0.0.0-stage → 0.41.0
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/LICENSE +21 -0
- package/README.md +146 -2
- package/dist/actions/associations.d.ts +161 -0
- package/dist/actions/associations.d.ts.map +1 -0
- package/dist/actions/associations.js +192 -0
- package/dist/actions/associations.js.map +1 -0
- package/dist/actions/createOrUpdateContact.d.ts +36 -0
- package/dist/actions/createOrUpdateContact.d.ts.map +1 -0
- package/dist/actions/createOrUpdateContact.js +65 -0
- package/dist/actions/createOrUpdateContact.js.map +1 -0
- package/dist/actions/crm.d.ts +1042 -0
- package/dist/actions/crm.d.ts.map +1 -0
- package/dist/actions/crm.js +266 -0
- package/dist/actions/crm.js.map +1 -0
- package/dist/actions/crud.d.ts +180 -0
- package/dist/actions/crud.d.ts.map +1 -0
- package/dist/actions/crud.js +203 -0
- package/dist/actions/crud.js.map +1 -0
- package/dist/actions/customApiCall.d.ts +6 -0
- package/dist/actions/customApiCall.d.ts.map +1 -0
- package/dist/actions/customApiCall.js +10 -0
- package/dist/actions/customApiCall.js.map +1 -0
- package/dist/actions/lists.d.ts +42 -0
- package/dist/actions/lists.d.ts.map +1 -0
- package/dist/actions/lists.js +108 -0
- package/dist/actions/lists.js.map +1 -0
- package/dist/actions/lookups.d.ts +110 -0
- package/dist/actions/lookups.d.ts.map +1 -0
- package/dist/actions/lookups.js +71 -0
- package/dist/actions/lookups.js.map +1 -0
- package/dist/actions/marketing.d.ts +45 -0
- package/dist/actions/marketing.d.ts.map +1 -0
- package/dist/actions/marketing.js +75 -0
- package/dist/actions/marketing.js.map +1 -0
- package/dist/actions/options.d.ts +38 -0
- package/dist/actions/options.d.ts.map +1 -0
- package/dist/actions/options.js +229 -0
- package/dist/actions/options.js.map +1 -0
- package/dist/actions/reads.d.ts +351 -0
- package/dist/actions/reads.d.ts.map +1 -0
- package/dist/actions/reads.js +253 -0
- package/dist/actions/reads.js.map +1 -0
- package/dist/actions/uploadFile.d.ts +47 -0
- package/dist/actions/uploadFile.d.ts.map +1 -0
- package/dist/actions/uploadFile.js +66 -0
- package/dist/actions/uploadFile.js.map +1 -0
- package/dist/client.d.ts +31 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +115 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +24 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +35 -0
- package/dist/config.js.map +1 -0
- package/dist/define.d.ts +76 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +4 -0
- package/dist/define.js.map +1 -0
- package/dist/files.d.ts +13 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +55 -0
- package/dist/files.js.map +1 -0
- package/dist/index.d.ts +3463 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +173 -0
- package/dist/index.js.map +1 -0
- package/dist/objects.d.ts +57 -0
- package/dist/objects.d.ts.map +1 -0
- package/dist/objects.js +194 -0
- package/dist/objects.js.map +1 -0
- package/dist/pagination.d.ts +41 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +29 -0
- package/dist/pagination.js.map +1 -0
- package/dist/records.d.ts +99 -0
- package/dist/records.d.ts.map +1 -0
- package/dist/records.js +106 -0
- package/dist/records.js.map +1 -0
- package/dist/triggers/marketing.d.ts +167 -0
- package/dist/triggers/marketing.d.ts.map +1 -0
- package/dist/triggers/marketing.js +227 -0
- package/dist/triggers/marketing.js.map +1 -0
- package/dist/triggers/newContactInList.d.ts +75 -0
- package/dist/triggers/newContactInList.d.ts.map +1 -0
- package/dist/triggers/newContactInList.js +78 -0
- package/dist/triggers/newContactInList.js.map +1 -0
- package/dist/triggers/newEngagement.d.ts +91 -0
- package/dist/triggers/newEngagement.d.ts.map +1 -0
- package/dist/triggers/newEngagement.js +125 -0
- package/dist/triggers/newEngagement.js.map +1 -0
- package/dist/triggers/poll.d.ts +94 -0
- package/dist/triggers/poll.d.ts.map +1 -0
- package/dist/triggers/poll.js +141 -0
- package/dist/triggers/poll.js.map +1 -0
- package/dist/triggers/records.d.ts +1234 -0
- package/dist/triggers/records.d.ts.map +1 -0
- package/dist/triggers/records.js +249 -0
- package/dist/triggers/records.js.map +1 -0
- package/package.json +41 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAoDxB,OAAO,EAAE,mBAAmB,EAA4C,MAAM,aAAa,CAAC;AA+B5F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK3C,4DAA4D;AAC5D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BzB,CAAC;AAoBF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4CxB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsFxB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { definePiece } from 'frogbot/pieces';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { createAssociations, findAssociations, removeAssociations } from './actions/associations.js';
|
|
4
|
+
import { createOrUpdateContact } from './actions/createOrUpdateContact.js';
|
|
5
|
+
import { createCompany, createContact, createCustomObject, createDeal, createLineItem, createProduct, createTicket, findCompany, findContact, findCustomObject, findDeal, findLineItem, findProduct, findTicket, getCompany, getContact, getCustomObject, getDeal, getLineItem, getProduct, getTicket, updateCompany, updateContact, updateCustomObject, updateDeal, updateLineItem, updateProduct, updateTicket } from './actions/crm.js';
|
|
6
|
+
import { customApiCall } from './actions/customApiCall.js';
|
|
7
|
+
import { addContactToList, removeContactFromList } from './actions/lists.js';
|
|
8
|
+
import { getOwnerByEmail, getOwnerById, getPipelineStageDetails } from './actions/lookups.js';
|
|
9
|
+
import { addContactToWorkflow, removeEmailSubscription } from './actions/marketing.js';
|
|
10
|
+
import { listAssociations, listListMembers, listLists, listOwners, listPipelines, listProperties, listRecords } from './actions/reads.js';
|
|
11
|
+
import { uploadFile } from './actions/uploadFile.js';
|
|
12
|
+
import { createHubSpotClient, HubSpotError, signal } from './client.js';
|
|
13
|
+
import { hubspotAuth } from './config.js';
|
|
14
|
+
import { owner } from './records.js';
|
|
15
|
+
import { newEmailEvent, newEmailSubscriptionsTimeline, newFormSubmission } from './triggers/marketing.js';
|
|
16
|
+
import { newContactInList } from './triggers/newContactInList.js';
|
|
17
|
+
import { newEngagement } from './triggers/newEngagement.js';
|
|
18
|
+
import { dealStageUpdated, newCompany, newCompanyPropertyChange, newContact, newContactPropertyChange, newCustomObject, newCustomObjectPropertyChange, newDeal, newDealPropertyChange, newLineItem, newOrUpdatedCompany, newOrUpdatedContact, newOrUpdatedLineItem, newOrUpdatedProduct, newProduct, newTask, newTicket, newTicketPropertyChange } from './triggers/records.js';
|
|
19
|
+
export { HubSpotError } from './client.js';
|
|
20
|
+
const scope = (...names)=>Object.fromEntries(names.map((name)=>[
|
|
21
|
+
name,
|
|
22
|
+
name
|
|
23
|
+
]));
|
|
24
|
+
/** HubSpot's own scope strings, each under its own name. */ export const hubspotScopes = scope('crm.objects.contacts.read', 'crm.objects.contacts.write', 'crm.objects.companies.read', 'crm.objects.companies.write', 'crm.objects.deals.read', 'crm.objects.deals.write', 'crm.objects.tickets.read', 'crm.objects.tickets.write', 'crm.objects.line_items.read', 'crm.objects.line_items.write', 'crm.objects.custom.read', 'crm.objects.custom.write', 'crm.objects.owners.read', 'crm.lists.read', 'crm.lists.write', 'crm.schemas.contacts.read', 'crm.schemas.companies.read', 'crm.schemas.deals.read', 'crm.schemas.custom.read', 'e-commerce', 'sales-email-read', 'files', 'forms', 'automation', 'communication_preferences.read_write');
|
|
25
|
+
const tokenIdentity = z.object({
|
|
26
|
+
hub_id: z.number(),
|
|
27
|
+
user_id: z.number()
|
|
28
|
+
});
|
|
29
|
+
async function ownerEmail(client, userId, abort) {
|
|
30
|
+
try {
|
|
31
|
+
const found = await client.request(owner, {
|
|
32
|
+
path: `/crm/v3/owners/${userId}`,
|
|
33
|
+
query: {
|
|
34
|
+
idProperty: 'userId'
|
|
35
|
+
},
|
|
36
|
+
signal: abort
|
|
37
|
+
});
|
|
38
|
+
return found.email;
|
|
39
|
+
} catch (error) {
|
|
40
|
+
if (error instanceof HubSpotError && error.status === 404) return undefined;
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export const hubspotOAuth = {
|
|
45
|
+
authorizationUrl: 'https://app.hubspot.com/oauth/authorize',
|
|
46
|
+
tokenUrl: 'https://api.hubapi.com/oauth/v3/token',
|
|
47
|
+
scopes: {
|
|
48
|
+
catalog: hubspotScopes,
|
|
49
|
+
defaults: [
|
|
50
|
+
'crm.objects.companies.read',
|
|
51
|
+
'crm.objects.deals.read',
|
|
52
|
+
'crm.objects.tickets.read',
|
|
53
|
+
'crm.objects.owners.read',
|
|
54
|
+
'crm.lists.read',
|
|
55
|
+
'crm.schemas.contacts.read',
|
|
56
|
+
'crm.schemas.companies.read',
|
|
57
|
+
'crm.schemas.deals.read',
|
|
58
|
+
'crm.schemas.custom.read'
|
|
59
|
+
],
|
|
60
|
+
required: [
|
|
61
|
+
'crm.objects.contacts.read'
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
toAuth ({ tokens }) {
|
|
65
|
+
if (!tokens.access_token?.trim()) {
|
|
66
|
+
throw new Error('HubSpot sign-in did not return an access token.');
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
accessToken: tokens.access_token
|
|
70
|
+
};
|
|
71
|
+
},
|
|
72
|
+
async account ({ tokens, client, req }) {
|
|
73
|
+
const identity = tokenIdentity.safeParse(tokens);
|
|
74
|
+
if (!identity.success) throw new Error('HubSpot sign-in did not name the user and portal.');
|
|
75
|
+
const { hub_id: hubId, user_id: userId } = identity.data;
|
|
76
|
+
const email = await ownerEmail(client, userId, signal(req));
|
|
77
|
+
return {
|
|
78
|
+
id: `${hubId}:${userId}`,
|
|
79
|
+
label: email ? `${email} (portal ${hubId})` : `HubSpot portal ${hubId}`,
|
|
80
|
+
...email ? {
|
|
81
|
+
email
|
|
82
|
+
} : {}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
export const createHubSpot = definePiece({
|
|
87
|
+
slug: 'hubspot',
|
|
88
|
+
label: 'HubSpot',
|
|
89
|
+
admin: {
|
|
90
|
+
description: 'Import, create, update and find HubSpot contacts, companies, deals, tickets, activities and lists',
|
|
91
|
+
group: 'Sales and CRM'
|
|
92
|
+
},
|
|
93
|
+
auth: hubspotAuth,
|
|
94
|
+
oauth: hubspotOAuth,
|
|
95
|
+
client: createHubSpotClient,
|
|
96
|
+
actions: [
|
|
97
|
+
listRecords,
|
|
98
|
+
listAssociations,
|
|
99
|
+
listLists,
|
|
100
|
+
listListMembers,
|
|
101
|
+
listOwners,
|
|
102
|
+
listPipelines,
|
|
103
|
+
listProperties,
|
|
104
|
+
createContact,
|
|
105
|
+
updateContact,
|
|
106
|
+
getContact,
|
|
107
|
+
findContact,
|
|
108
|
+
createOrUpdateContact,
|
|
109
|
+
createCompany,
|
|
110
|
+
updateCompany,
|
|
111
|
+
getCompany,
|
|
112
|
+
findCompany,
|
|
113
|
+
createDeal,
|
|
114
|
+
updateDeal,
|
|
115
|
+
getDeal,
|
|
116
|
+
findDeal,
|
|
117
|
+
createTicket,
|
|
118
|
+
updateTicket,
|
|
119
|
+
getTicket,
|
|
120
|
+
findTicket,
|
|
121
|
+
createLineItem,
|
|
122
|
+
updateLineItem,
|
|
123
|
+
getLineItem,
|
|
124
|
+
findLineItem,
|
|
125
|
+
createProduct,
|
|
126
|
+
updateProduct,
|
|
127
|
+
getProduct,
|
|
128
|
+
findProduct,
|
|
129
|
+
createCustomObject,
|
|
130
|
+
updateCustomObject,
|
|
131
|
+
getCustomObject,
|
|
132
|
+
findCustomObject,
|
|
133
|
+
createAssociations,
|
|
134
|
+
removeAssociations,
|
|
135
|
+
findAssociations,
|
|
136
|
+
addContactToList,
|
|
137
|
+
removeContactFromList,
|
|
138
|
+
getOwnerByEmail,
|
|
139
|
+
getOwnerById,
|
|
140
|
+
getPipelineStageDetails,
|
|
141
|
+
uploadFile,
|
|
142
|
+
addContactToWorkflow,
|
|
143
|
+
removeEmailSubscription,
|
|
144
|
+
customApiCall
|
|
145
|
+
],
|
|
146
|
+
triggers: [
|
|
147
|
+
newContact,
|
|
148
|
+
newOrUpdatedContact,
|
|
149
|
+
newContactPropertyChange,
|
|
150
|
+
newContactInList,
|
|
151
|
+
newCompany,
|
|
152
|
+
newOrUpdatedCompany,
|
|
153
|
+
newCompanyPropertyChange,
|
|
154
|
+
newDeal,
|
|
155
|
+
newDealPropertyChange,
|
|
156
|
+
dealStageUpdated,
|
|
157
|
+
newTicket,
|
|
158
|
+
newTicketPropertyChange,
|
|
159
|
+
newLineItem,
|
|
160
|
+
newOrUpdatedLineItem,
|
|
161
|
+
newProduct,
|
|
162
|
+
newOrUpdatedProduct,
|
|
163
|
+
newTask,
|
|
164
|
+
newCustomObject,
|
|
165
|
+
newCustomObjectPropertyChange,
|
|
166
|
+
newEngagement,
|
|
167
|
+
newFormSubmission,
|
|
168
|
+
newEmailEvent,
|
|
169
|
+
newEmailSubscriptionsTimeline
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["definePiece","z","createAssociations","findAssociations","removeAssociations","createOrUpdateContact","createCompany","createContact","createCustomObject","createDeal","createLineItem","createProduct","createTicket","findCompany","findContact","findCustomObject","findDeal","findLineItem","findProduct","findTicket","getCompany","getContact","getCustomObject","getDeal","getLineItem","getProduct","getTicket","updateCompany","updateContact","updateCustomObject","updateDeal","updateLineItem","updateProduct","updateTicket","customApiCall","addContactToList","removeContactFromList","getOwnerByEmail","getOwnerById","getPipelineStageDetails","addContactToWorkflow","removeEmailSubscription","listAssociations","listListMembers","listLists","listOwners","listPipelines","listProperties","listRecords","uploadFile","createHubSpotClient","HubSpotError","signal","hubspotAuth","owner","newEmailEvent","newEmailSubscriptionsTimeline","newFormSubmission","newContactInList","newEngagement","dealStageUpdated","newCompany","newCompanyPropertyChange","newContact","newContactPropertyChange","newCustomObject","newCustomObjectPropertyChange","newDeal","newDealPropertyChange","newLineItem","newOrUpdatedCompany","newOrUpdatedContact","newOrUpdatedLineItem","newOrUpdatedProduct","newProduct","newTask","newTicket","newTicketPropertyChange","scope","names","Object","fromEntries","map","name","hubspotScopes","tokenIdentity","object","hub_id","number","user_id","ownerEmail","client","userId","abort","found","request","path","query","idProperty","email","error","status","undefined","hubspotOAuth","authorizationUrl","tokenUrl","scopes","catalog","defaults","required","toAuth","tokens","access_token","trim","Error","accessToken","account","req","identity","safeParse","success","hubId","data","id","label","createHubSpot","slug","admin","description","group","auth","oauth","actions","triggers"],"mappings":"AAAA,SAASA,WAAW,QAAuD,iBAAiB;AAC5F,SAASC,CAAC,QAAQ,MAAM;AAExB,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,kBAAkB,QACb,4BAA4B;AACnC,SAASC,qBAAqB,QAAQ,qCAAqC;AAC3E,SACEC,aAAa,EACbC,aAAa,EACbC,kBAAkB,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ACR;QAEzC,IAAI,CAACO,SAASE,OAAO,EAAE,MAAM,IAAIN,MAAM;QAEvC,MAAM,EAAE3B,QAAQkC,KAAK,EAAEhC,SAASG,MAAM,EAAE,GAAG0B,SAASI,IAAI;QACxD,MAAMvB,QAAQ,MAAMT,WAAWC,QAAQC,QAAQxC,OAAOiE;QAEtD,OAAO;YACLM,IAAI,GAAGF,MAAM,CAAC,EAAE7B,QAAQ;YACxBgC,OAAOzB,QAAQ,GAAGA,MAAM,SAAS,EAAEsB,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,EAAEA,OAAO;YACvE,GAAItB,QAAQ;gBAAEA;YAAM,IAAI,CAAC,CAAC;QAC5B;IACF;AACF,EAKE;AAEF,OAAO,MAAM0B,gBAAgB7H,YAAY;IACvC8H,MAAM;IACNF,OAAO;IACPG,OAAO;QACLC,aACE;QACFC,OAAO;IACT;IACAC,MAAM7E;IACN8E,OAAO5B;IACPZ,QAAQzC;IACRkF,SAAS;QACPpF;QACAN;QACAE;QACAD;QACAE;QACAC;QACAC;QACAxC;QACAqB;QACAP;QACAP;QACAT;QACAC;QACAqB;QACAP;QACAP;QACAJ;QACAqB;QACAP;QACAP;QACAJ;QACAqB;QACAP;QACAP;QACAT;QACAqB;QACAP;QACAP;QACAN;QACAqB;QACAP;QACAP;QACAV;QACAqB;QACAP;QACAP;QACAb;QACAE;QACAD;QACAgC;QACAC;QACAC;QACAC;QACAC;QACAU;QACAT;QACAC;QACAP;KACD;IACDmG,UAAU;QACRtE;QACAQ;QACAP;QACAN;QACAG;QACAS;QACAR;QACAK;QACAC;QACAR;QACAgB;QACAC;QACAR;QACAG;QACAE;QACAD;QACAE;QACAV;QACAC;QACAP;QACAF;QACAF;QACAC;KACD;AACH,GAAG","file":"index.js"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { PieceOption } from 'frogbot/pieces';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { customObjectTypeOptions } from './actions/options.js';
|
|
4
|
+
import type { HubSpotClient } from './client.js';
|
|
5
|
+
export type Values = Record<string, unknown>;
|
|
6
|
+
export type Option = (args: {
|
|
7
|
+
client: HubSpotClient;
|
|
8
|
+
input: Values;
|
|
9
|
+
}) => Promise<PieceOption[]>;
|
|
10
|
+
/**
|
|
11
|
+
* A CRM object an action or trigger works on: its type, the input that picks it, its default
|
|
12
|
+
* properties, and the properties that hold its created and last modified times.
|
|
13
|
+
*/
|
|
14
|
+
export type CrmObject<TInput extends z.ZodRawShape = z.ZodRawShape> = {
|
|
15
|
+
input: TInput;
|
|
16
|
+
objectType(input: Values): string;
|
|
17
|
+
defaults: readonly string[];
|
|
18
|
+
created: string;
|
|
19
|
+
modified: string;
|
|
20
|
+
properties: Option;
|
|
21
|
+
options?: Record<string, Option>;
|
|
22
|
+
};
|
|
23
|
+
export declare const contacts: CrmObject<Record<never, never>>;
|
|
24
|
+
export declare const companies: CrmObject<Record<never, never>>;
|
|
25
|
+
export declare const deals: CrmObject<Record<never, never>>;
|
|
26
|
+
export declare const tickets: CrmObject<Record<never, never>>;
|
|
27
|
+
export declare const lineItems: CrmObject<Record<never, never>>;
|
|
28
|
+
export declare const products: CrmObject<Record<never, never>>;
|
|
29
|
+
export declare const tasks: CrmObject<Record<never, never>>;
|
|
30
|
+
export declare const customObjects: {
|
|
31
|
+
input: {
|
|
32
|
+
customObjectType: z.ZodString;
|
|
33
|
+
};
|
|
34
|
+
objectType: (input: Values) => string;
|
|
35
|
+
defaults: string[];
|
|
36
|
+
created: string;
|
|
37
|
+
modified: string;
|
|
38
|
+
properties: ({ client, input }: {
|
|
39
|
+
client: HubSpotClient;
|
|
40
|
+
input: Record<string, unknown>;
|
|
41
|
+
}) => Promise<{
|
|
42
|
+
label: string;
|
|
43
|
+
value: string;
|
|
44
|
+
}[]>;
|
|
45
|
+
options: {
|
|
46
|
+
customObjectType: typeof customObjectTypeOptions;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
/** Joins arrays with `;`, stringifies the rest, and skips empty arrays on update. */
|
|
50
|
+
export declare function format(values: Values | undefined, skipEmpty: boolean): Record<string, string>;
|
|
51
|
+
/** Keeps the named fields that were given. */
|
|
52
|
+
export declare function compact(values: Record<string, unknown>): {
|
|
53
|
+
[k: string]: string;
|
|
54
|
+
};
|
|
55
|
+
/** The default properties plus `additionalPropertiesToRetrieve`. */
|
|
56
|
+
export declare function retrieve(object: CrmObject, input: Values): string[];
|
|
57
|
+
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../src/objects.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EACL,uBAAuB,EAGxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE7C,MAAM,MAAM,MAAM,GAAG,CAAC,IAAI,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,KAAK,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAEhG;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,WAAW,IAAI;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC,CAAC;AAiBF,eAAO,MAAM,QAAQ,iCA+BpB,CAAC;AAEF,eAAO,MAAM,SAAS,iCA8BpB,CAAC;AAEH,eAAO,MAAM,KAAK,iCAgBhB,CAAC;AAEH,eAAO,MAAM,OAAO,iCAclB,CAAC;AAEH,eAAO,MAAM,SAAS,iCAmBpB,CAAC;AAEH,eAAO,MAAM,QAAQ,iCAOnB,CAAC;AAEH,eAAO,MAAM,KAAK,iCAmBjB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;wBAOJ,MAAM;;;;;;;;;;;;;;CAMP,CAAC;AAEtB,qFAAqF;AACrF,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,OAAO,0BAcpE;AAED,8CAA8C;AAC9C,wBAAgB,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;EAMtD;AAED,oEAAoE;AACpE,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAExD"}
|
package/dist/objects.js
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { customObjectTypeOptions, customPropertyOptions, propertyOptions } from './actions/options.js';
|
|
3
|
+
function standard(objectType, defaults, { created = 'createdate', modified = 'hs_lastmodifieddate' } = {}) {
|
|
4
|
+
return {
|
|
5
|
+
input: {},
|
|
6
|
+
objectType: ()=>objectType,
|
|
7
|
+
defaults,
|
|
8
|
+
created,
|
|
9
|
+
modified,
|
|
10
|
+
properties: propertyOptions(objectType)
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export const contacts = standard('contacts', [
|
|
14
|
+
'firstname',
|
|
15
|
+
'lastname',
|
|
16
|
+
'email',
|
|
17
|
+
'company',
|
|
18
|
+
'website',
|
|
19
|
+
'mobilephone',
|
|
20
|
+
'phone',
|
|
21
|
+
'fax',
|
|
22
|
+
'address',
|
|
23
|
+
'city',
|
|
24
|
+
'state',
|
|
25
|
+
'zip',
|
|
26
|
+
'salutation',
|
|
27
|
+
'country',
|
|
28
|
+
'jobtitle',
|
|
29
|
+
'hs_createdate',
|
|
30
|
+
'hs_email_domain',
|
|
31
|
+
'hs_object_id',
|
|
32
|
+
'lastmodifieddate',
|
|
33
|
+
'hs_persona',
|
|
34
|
+
'hs_language',
|
|
35
|
+
'lifecyclestage',
|
|
36
|
+
'createdate',
|
|
37
|
+
'numemployees',
|
|
38
|
+
'annualrevenue',
|
|
39
|
+
'industry'
|
|
40
|
+
], {
|
|
41
|
+
modified: 'lastmodifieddate'
|
|
42
|
+
});
|
|
43
|
+
export const companies = standard('companies', [
|
|
44
|
+
'name',
|
|
45
|
+
'domain',
|
|
46
|
+
'industry',
|
|
47
|
+
'about_us',
|
|
48
|
+
'phone',
|
|
49
|
+
'address',
|
|
50
|
+
'address2',
|
|
51
|
+
'city',
|
|
52
|
+
'state',
|
|
53
|
+
'zip',
|
|
54
|
+
'country',
|
|
55
|
+
'website',
|
|
56
|
+
'type',
|
|
57
|
+
'description',
|
|
58
|
+
'founded_year',
|
|
59
|
+
'hs_createdate',
|
|
60
|
+
'hs_lastmodifieddate',
|
|
61
|
+
'hs_object_id',
|
|
62
|
+
'is_public',
|
|
63
|
+
'timezone',
|
|
64
|
+
'total_money_raised',
|
|
65
|
+
'total_revenue',
|
|
66
|
+
'owneremail',
|
|
67
|
+
'ownername',
|
|
68
|
+
'numberofemployees',
|
|
69
|
+
'annualrevenue',
|
|
70
|
+
'lifecyclestage',
|
|
71
|
+
'createdate',
|
|
72
|
+
'web_technologies'
|
|
73
|
+
]);
|
|
74
|
+
export const deals = standard('deals', [
|
|
75
|
+
'dealtype',
|
|
76
|
+
'dealname',
|
|
77
|
+
'amount',
|
|
78
|
+
'description',
|
|
79
|
+
'closedate',
|
|
80
|
+
'createdate',
|
|
81
|
+
'num_associated_contacts',
|
|
82
|
+
'hs_forecast_amount',
|
|
83
|
+
'hs_forecast_probability',
|
|
84
|
+
'hs_manual_forecast_category',
|
|
85
|
+
'hs_next_step',
|
|
86
|
+
'hs_object_id',
|
|
87
|
+
'hs_lastmodifieddate',
|
|
88
|
+
'hubspot_owner_id',
|
|
89
|
+
'hubspot_team_id'
|
|
90
|
+
]);
|
|
91
|
+
export const tickets = standard('tickets', [
|
|
92
|
+
'subject',
|
|
93
|
+
'content',
|
|
94
|
+
'source_type',
|
|
95
|
+
'createdate',
|
|
96
|
+
'hs_pipeline',
|
|
97
|
+
'hs_pipeline_stage',
|
|
98
|
+
'hs_resolution',
|
|
99
|
+
'hs_ticket_category',
|
|
100
|
+
'hs_ticket_id',
|
|
101
|
+
'hs_ticket_priority',
|
|
102
|
+
'hs_lastmodifieddate',
|
|
103
|
+
'hubspot_owner_id',
|
|
104
|
+
'hubspot_team_id'
|
|
105
|
+
]);
|
|
106
|
+
export const lineItems = standard('line_items', [
|
|
107
|
+
'name',
|
|
108
|
+
'description',
|
|
109
|
+
'price',
|
|
110
|
+
'quantity',
|
|
111
|
+
'amount',
|
|
112
|
+
'discount',
|
|
113
|
+
'tax',
|
|
114
|
+
'createdate',
|
|
115
|
+
'hs_object_id',
|
|
116
|
+
'hs_product_id',
|
|
117
|
+
'hs_images',
|
|
118
|
+
'hs_lastmodifieddate',
|
|
119
|
+
'hs_line_item_currency_code',
|
|
120
|
+
'hs_sku',
|
|
121
|
+
'hs_url',
|
|
122
|
+
'hs_cost_of_goods_sold',
|
|
123
|
+
'hs_discount_percentage',
|
|
124
|
+
'hs_term_in_months'
|
|
125
|
+
]);
|
|
126
|
+
export const products = standard('products', [
|
|
127
|
+
'createdate',
|
|
128
|
+
'description',
|
|
129
|
+
'name',
|
|
130
|
+
'price',
|
|
131
|
+
'tax',
|
|
132
|
+
'hs_lastmodifieddate'
|
|
133
|
+
]);
|
|
134
|
+
export const tasks = standard('tasks', [
|
|
135
|
+
'hs_task_body',
|
|
136
|
+
'hubspot_owner_id',
|
|
137
|
+
'hs_task_subject',
|
|
138
|
+
'hs_task_status',
|
|
139
|
+
'hs_task_priority',
|
|
140
|
+
'hs_task_type',
|
|
141
|
+
'hs_created_by',
|
|
142
|
+
'hs_repeat_status',
|
|
143
|
+
'hs_task_completion_date',
|
|
144
|
+
'hs_task_is_completed',
|
|
145
|
+
'hs_timestamp',
|
|
146
|
+
'hs_queue_membership_ids',
|
|
147
|
+
'hs_lastmodifieddate',
|
|
148
|
+
'hs_createdate'
|
|
149
|
+
], {
|
|
150
|
+
created: 'hs_createdate'
|
|
151
|
+
});
|
|
152
|
+
export const customObjects = {
|
|
153
|
+
input: {
|
|
154
|
+
customObjectType: z.string().regex(/^2-\d+$/, 'customObjectType must be a custom object type ID, such as 2-3456789.').meta({
|
|
155
|
+
label: 'Type of custom object',
|
|
156
|
+
description: 'A type ID such as 2-3456789.'
|
|
157
|
+
})
|
|
158
|
+
},
|
|
159
|
+
objectType: (input)=>String(input.customObjectType),
|
|
160
|
+
defaults: [
|
|
161
|
+
'hs_object_id',
|
|
162
|
+
'hs_lastmodifieddate',
|
|
163
|
+
'hs_createdate'
|
|
164
|
+
],
|
|
165
|
+
created: 'hs_createdate',
|
|
166
|
+
modified: 'hs_lastmodifieddate',
|
|
167
|
+
properties: customPropertyOptions,
|
|
168
|
+
options: {
|
|
169
|
+
customObjectType: customObjectTypeOptions
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
/** Joins arrays with `;`, stringifies the rest, and skips empty arrays on update. */ export function format(values, skipEmpty) {
|
|
173
|
+
const result = {};
|
|
174
|
+
for (const [name, value] of Object.entries(values ?? {})){
|
|
175
|
+
if (Array.isArray(value)) {
|
|
176
|
+
if (skipEmpty && value.length === 0) continue;
|
|
177
|
+
result[name] = value.join(';');
|
|
178
|
+
} else {
|
|
179
|
+
result[name] = String(value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return result;
|
|
183
|
+
}
|
|
184
|
+
/** Keeps the named fields that were given. */ export function compact(values) {
|
|
185
|
+
return Object.fromEntries(Object.entries(values).filter((entry)=>typeof entry[1] === 'string' && entry[1] !== ''));
|
|
186
|
+
}
|
|
187
|
+
/** The default properties plus `additionalPropertiesToRetrieve`. */ export function retrieve(object, input) {
|
|
188
|
+
return [
|
|
189
|
+
...object.defaults,
|
|
190
|
+
...input.additionalPropertiesToRetrieve ?? []
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
//# sourceMappingURL=objects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/objects.ts"],"names":["z","customObjectTypeOptions","customPropertyOptions","propertyOptions","standard","objectType","defaults","created","modified","input","properties","contacts","companies","deals","tickets","lineItems","products","tasks","customObjects","customObjectType","string","regex","meta","label","description","String","options","format","values","skipEmpty","result","name","value","Object","entries","Array","isArray","length","join","compact","fromEntries","filter","entry","retrieve","object","additionalPropertiesToRetrieve"],"mappings":"AACA,SAASA,CAAC,QAAQ,MAAM;AAExB,SACEC,uBAAuB,EACvBC,qBAAqB,EACrBC,eAAe,QACV,uBAAuB;AAqB9B,SAASC,SACPC,UAAkB,EAClBC,QAA2B,EAC3B,EAAEC,UAAU,YAAY,EAAEC,WAAW,qBAAqB,EAAE,GAAG,CAAC,CAAC;IAEjE,OAAO;QACLC,OAAO,CAAC;QACRJ,YAAY,IAAMA;QAClBC;QACAC;QACAC;QACAE,YAAYP,gBAAgBE;IAC9B;AACF;AAEA,OAAO,MAAMM,WAAWP,SACtB,YACA;IACE;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD,EACD;IAAEI,UAAU;AAAmB,GAC/B;AAEF,OAAO,MAAMI,YAAYR,SAAS,aAAa;IAC7C;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA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AM,CAACC,KAAK,GAAGC,MAAMM,IAAI,CAAC;QAC5B,OAAO;YACLR,MAAM,CAACC,KAAK,GAAGN,OAAOO;QACxB;IACF;IAEA,OAAOF;AACT;AAEA,4CAA4C,GAC5C,OAAO,SAASS,QAAQX,MAA+B;IACrD,OAAOK,OAAOO,WAAW,CACvBP,OAAOC,OAAO,CAACN,QAAQa,MAAM,CAC3B,CAACC,QAAqC,OAAOA,KAAK,CAAC,EAAE,KAAK,YAAYA,KAAK,CAAC,EAAE,KAAK;AAGzF;AAEA,kEAAkE,GAClE,OAAO,SAASC,SAASC,MAAiB,EAAEnC,KAAa;IACvD,OAAO;WAAImC,OAAOtC,QAAQ;WAAM,AAACG,MAAMoC,8BAA8B,IAAiB,EAAE;KAAE;AAC5F","file":"objects.js"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The `limit` and `cursor` every paged read takes. */
|
|
3
|
+
export declare const pageInput: {
|
|
4
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
cursor: z.ZodOptional<z.ZodString>;
|
|
6
|
+
};
|
|
7
|
+
/** `{ results, nextCursor }`, where `nextCursor` is `null` on the last page. */
|
|
8
|
+
export declare function pageOutput<T extends z.ZodType>(item: T): z.ZodObject<{
|
|
9
|
+
results: z.ZodArray<T>;
|
|
10
|
+
nextCursor: z.ZodNullable<z.ZodString>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/** HubSpot's `paging` object. Only `next.after` is used; `link` is deprecated. */
|
|
13
|
+
export declare const paging: z.ZodPipe<z.ZodOptional<z.ZodObject<{
|
|
14
|
+
next: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
after: z.ZodString;
|
|
16
|
+
}, z.core.$strip>>;
|
|
17
|
+
}, z.core.$strip>>, z.ZodTransform<string | null, {
|
|
18
|
+
next?: {
|
|
19
|
+
after: string;
|
|
20
|
+
} | undefined;
|
|
21
|
+
} | undefined>>;
|
|
22
|
+
/** Reads one `{ results, paging }` page and maps `paging.next.after` to `nextCursor`. */
|
|
23
|
+
export declare function cursorPage<T extends z.ZodType>(item: T): z.ZodPipe<z.ZodObject<{
|
|
24
|
+
results: z.ZodArray<T>;
|
|
25
|
+
paging: z.ZodPipe<z.ZodOptional<z.ZodObject<{
|
|
26
|
+
next: z.ZodOptional<z.ZodObject<{
|
|
27
|
+
after: z.ZodString;
|
|
28
|
+
}, z.core.$strip>>;
|
|
29
|
+
}, z.core.$strip>>, z.ZodTransform<string | null, {
|
|
30
|
+
next?: {
|
|
31
|
+
after: string;
|
|
32
|
+
} | undefined;
|
|
33
|
+
} | undefined>>;
|
|
34
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
35
|
+
results: z.core.output<T>[];
|
|
36
|
+
nextCursor: string | null;
|
|
37
|
+
}, {
|
|
38
|
+
results: z.core.output<T>[];
|
|
39
|
+
paging: string | null;
|
|
40
|
+
}>>;
|
|
41
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uDAAuD;AACvD,eAAO,MAAM,SAAS;;;CAOrB,CAAC;AAEF,gFAAgF;AAChF,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;;;kBAEtD;AAED,kFAAkF;AAClF,eAAO,MAAM,MAAM;;;;;;;;eAGgC,CAAC;AAEpD,yFAAyF;AACzF,wBAAgB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;;;;;;;;;;;;;;;;;IAItD"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** The `limit` and `cursor` every paged read takes. */ export const pageInput = {
|
|
3
|
+
limit: z.number().int().min(1).max(100).default(100),
|
|
4
|
+
cursor: z.string().min(1).optional().meta({
|
|
5
|
+
description: "The previous page's nextCursor. Keep the other inputs the same."
|
|
6
|
+
})
|
|
7
|
+
};
|
|
8
|
+
/** `{ results, nextCursor }`, where `nextCursor` is `null` on the last page. */ export function pageOutput(item) {
|
|
9
|
+
return z.object({
|
|
10
|
+
results: z.array(item),
|
|
11
|
+
nextCursor: z.string().nullable()
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/** HubSpot's `paging` object. Only `next.after` is used; `link` is deprecated. */ export const paging = z.object({
|
|
15
|
+
next: z.object({
|
|
16
|
+
after: z.string()
|
|
17
|
+
}).optional()
|
|
18
|
+
}).optional().transform((value)=>value?.next?.after ?? null);
|
|
19
|
+
/** Reads one `{ results, paging }` page and maps `paging.next.after` to `nextCursor`. */ export function cursorPage(item) {
|
|
20
|
+
return z.object({
|
|
21
|
+
results: z.array(item),
|
|
22
|
+
paging
|
|
23
|
+
}).transform(({ results, paging: nextCursor })=>({
|
|
24
|
+
results,
|
|
25
|
+
nextCursor
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/pagination.ts"],"names":["z","pageInput","limit","number","int","min","max","default","cursor","string","optional","meta","description","pageOutput","item","object","results","array","nextCursor","nullable","paging","next","after","transform","value","cursorPage"],"mappings":"AAAA,SAASA,CAAC,QAAQ,MAAM;AAExB,qDAAqD,GACrD,OAAO,MAAMC,YAAY;IACvBC,OAAOF,EAAEG,MAAM,GAAGC,GAAG,GAAGC,GAAG,CAAC,GAAGC,GAAG,CAAC,KAAKC,OAAO,CAAC;IAChDC,QAAQR,EACLS,MAAM,GACNJ,GAAG,CAAC,GACJK,QAAQ,GACRC,IAAI,CAAC;QAAEC,aAAa;IAAkE;AAC3F,EAAE;AAEF,8EAA8E,GAC9E,OAAO,SAASC,WAAgCC,IAAO;IACrD,OAAOd,EAAEe,MAAM,CAAC;QAAEC,SAAShB,EAAEiB,KAAK,CAACH;QAAOI,YAAYlB,EAAES,MAAM,GAAGU,QAAQ;IAAG;AAC9E;AAEA,gFAAgF,GAChF,OAAO,MAAMC,SAASpB,EACnBe,MAAM,CAAC;IAAEM,MAAMrB,EAAEe,MAAM,CAAC;QAAEO,OAAOtB,EAAES,MAAM;IAAG,GAAGC,QAAQ;AAAG,GAC1DA,QAAQ,GACRa,SAAS,CAAC,CAACC,QAAUA,OAAOH,MAAMC,SAAS,MAAM;AAEpD,uFAAuF,GACvF,OAAO,SAASG,WAAgCX,IAAO;IACrD,OAAOd,EACJe,MAAM,CAAC;QAAEC,SAAShB,EAAEiB,KAAK,CAACH;QAAOM;IAAO,GACxCG,SAAS,CAAC,CAAC,EAAEP,OAAO,EAAEI,QAAQF,UAAU,EAAE,GAAM,CAAA;YAAEF;YAASE;QAAW,CAAA;AAC3E","file":"pagination.js"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const crmRecord: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
properties: z.ZodRecord<z.ZodString, z.ZodNullable<z.ZodString>>;
|
|
5
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
6
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
7
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
associations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
9
|
+
results: z.ZodArray<z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
type: z.ZodString;
|
|
12
|
+
}, z.core.$strip>>;
|
|
13
|
+
}, z.core.$strip>>>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
export declare const associationLabel: z.ZodObject<{
|
|
16
|
+
category: z.ZodString;
|
|
17
|
+
typeId: z.ZodNumber;
|
|
18
|
+
label: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const owner: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
email: z.ZodOptional<z.ZodString>;
|
|
23
|
+
firstName: z.ZodOptional<z.ZodString>;
|
|
24
|
+
lastName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
userId: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
26
|
+
type: z.ZodOptional<z.ZodString>;
|
|
27
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
29
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
30
|
+
teams: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
primary: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
export declare const pipelineStage: z.ZodObject<{
|
|
37
|
+
id: z.ZodString;
|
|
38
|
+
label: z.ZodString;
|
|
39
|
+
displayOrder: z.ZodNumber;
|
|
40
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
42
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
43
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>;
|
|
45
|
+
export declare const pipeline: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
label: z.ZodString;
|
|
48
|
+
displayOrder: z.ZodNumber;
|
|
49
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
50
|
+
stages: z.ZodArray<z.ZodObject<{
|
|
51
|
+
id: z.ZodString;
|
|
52
|
+
label: z.ZodString;
|
|
53
|
+
displayOrder: z.ZodNumber;
|
|
54
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
56
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
57
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
60
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export declare const property: z.ZodObject<{
|
|
63
|
+
name: z.ZodString;
|
|
64
|
+
label: z.ZodString;
|
|
65
|
+
type: z.ZodString;
|
|
66
|
+
fieldType: z.ZodString;
|
|
67
|
+
description: z.ZodOptional<z.ZodString>;
|
|
68
|
+
groupName: z.ZodOptional<z.ZodString>;
|
|
69
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
calculated: z.ZodOptional<z.ZodBoolean>;
|
|
71
|
+
hubspotDefined: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
referencedObjectType: z.ZodOptional<z.ZodString>;
|
|
73
|
+
options: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
74
|
+
label: z.ZodString;
|
|
75
|
+
value: z.ZodString;
|
|
76
|
+
displayOrder: z.ZodOptional<z.ZodNumber>;
|
|
77
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
}, z.core.$strip>>>;
|
|
79
|
+
modificationMetadata: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
archivable: z.ZodOptional<z.ZodBoolean>;
|
|
81
|
+
readOnlyDefinition: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
readOnlyValue: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
}, z.core.$strip>>;
|
|
84
|
+
}, z.core.$strip>;
|
|
85
|
+
export declare const list: z.ZodObject<{
|
|
86
|
+
listId: z.ZodString;
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
objectTypeId: z.ZodString;
|
|
89
|
+
processingType: z.ZodString;
|
|
90
|
+
processingStatus: z.ZodOptional<z.ZodString>;
|
|
91
|
+
createdAt: z.ZodOptional<z.ZodString>;
|
|
92
|
+
updatedAt: z.ZodOptional<z.ZodString>;
|
|
93
|
+
additionalProperties: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>, z.ZodTransform<string, string | number>>>>;
|
|
94
|
+
}, z.core.$strip>;
|
|
95
|
+
export declare const listMember: z.ZodObject<{
|
|
96
|
+
recordId: z.ZodString;
|
|
97
|
+
membershipTimestamp: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
//# sourceMappingURL=records.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"records.d.ts","sourceRoot":"","sources":["../src/records.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,SAAS;;;;;;;;;;;;iBAgBpB,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;iBAI3B,CAAC;AAEH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;iBAahB,CAAC;AAEH,eAAO,MAAM,aAAa;;;;;;;;iBAQxB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;iBAQnB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;iBA6BnB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;;;iBAYf,CAAC;AAEH,eAAO,MAAM,UAAU;;;iBAGrB,CAAC"}
|