@aloma.io/integration-sdk 3.8.52 → 3.8.53

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.
@@ -0,0 +1,310 @@
1
+ import {AbstractController} from '@aloma.io/integration-sdk';
2
+
3
+ export default class Controller extends AbstractController {
4
+
5
+ /**
6
+ * Retrieve a batch of companies
7
+ *
8
+ * Retrieve a batch of companies by ID (`companyId`) or by a unique property (`idProperty`). You can specify what is returned using the `properties` query parameter.
9
+ *
10
+ * @param {boolean} archived (optional) - Whether to return only results that have been archived. [query]
11
+ *
12
+ * @param {Object} body (required) - Request body
13
+ *
14
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/read response
15
+ */
16
+ async read(archived?: any, body?: any) {
17
+ const url = '/crm/v3/objects/companies/batch/read';
18
+ const options: any = {
19
+ method: 'POST',
20
+ params: {},
21
+ body,
22
+ };
23
+
24
+ // Add query parameters
25
+ if (archived !== undefined) {
26
+ options.params.archived = archived;
27
+ }
28
+
29
+ return this.api.fetch(url, options);
30
+ }
31
+
32
+ /**
33
+ * Retrieve companies
34
+ *
35
+ * Retrieve all companies, using query parameters to control the information that gets returned.
36
+ *
37
+ * @param {integer} limit (optional) - The maximum number of results to display per page. [query]
38
+ * @param {string} after (optional) - The paging cursor token of the last successfully read resource will be returned as the `paging.next.after` JSON property of a paged response containing more results. [query]
39
+ * @param {array} properties (optional) - A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored. [query]
40
+ * @param {array} propertiesWithHistory (optional) - A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored. Usage of this parameter will reduce the maximum number of companies that can be read by a single request. [query]
41
+ * @param {array} associations (optional) - A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored. [query]
42
+ * @param {boolean} archived (optional) - Whether to return only results that have been archived. [query]
43
+ *
44
+ * @returns {Promise<Object>} GET /crm/v3/objects/companies response
45
+ */
46
+ async getPage(limit?: any, after?: any, properties?: any, propertiesWithHistory?: any, associations?: any, archived?: any) {
47
+ const url = '/crm/v3/objects/companies';
48
+ const options: any = {
49
+ method: 'GET',
50
+ params: {},
51
+ };
52
+
53
+ // Add query parameters
54
+ if (limit !== undefined) {
55
+ options.params.limit = limit;
56
+ }
57
+ if (after !== undefined) {
58
+ options.params.after = after;
59
+ }
60
+ if (properties !== undefined) {
61
+ options.params.properties = properties;
62
+ }
63
+ if (propertiesWithHistory !== undefined) {
64
+ options.params.propertiesWithHistory = propertiesWithHistory;
65
+ }
66
+ if (associations !== undefined) {
67
+ options.params.associations = associations;
68
+ }
69
+ if (archived !== undefined) {
70
+ options.params.archived = archived;
71
+ }
72
+
73
+ return this.api.fetch(url, options);
74
+ }
75
+
76
+ /**
77
+ * Create a company
78
+ *
79
+ * Create a single company. Include a `properties` object to define [property values](https://developers.hubspot.com/docs/guides/api/crm/properties) for the company, along with an `associations` array to define [associations](https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4) with other CRM records.
80
+ *
81
+ * @param {Object} body (required) - Request body
82
+ *
83
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies response
84
+ */
85
+ async create(body?: any) {
86
+ const url = '/crm/v3/objects/companies';
87
+ const options: any = {
88
+ method: 'POST',
89
+ body,
90
+ };
91
+
92
+ return this.api.fetch(url, options);
93
+ }
94
+
95
+ /**
96
+ * Search for companies
97
+ *
98
+ * Search for companies by filtering on properties, searching through associations, and sorting results. Learn more about [CRM search](https://developers.hubspot.com/docs/guides/api/crm/search#make-a-search-request).
99
+ *
100
+ * @param {Object} body (required) - Request body
101
+ *
102
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies/search response
103
+ */
104
+ async doSearch(body?: any) {
105
+ const url = '/crm/v3/objects/companies/search';
106
+ const options: any = {
107
+ method: 'POST',
108
+ body,
109
+ };
110
+
111
+ return this.api.fetch(url, options);
112
+ }
113
+
114
+ /**
115
+ * Retrieve a company
116
+ *
117
+ * Retrieve a company by its ID (`companyId`) or by a unique property (`idProperty`). You can specify what is returned using the `properties` query parameter.
118
+ *
119
+ * @param {string} companyId (required) - The ID of the company [path]
120
+ * @param {array} properties (optional) - A comma separated list of the properties to be returned in the response. If any of the specified properties are not present on the requested object(s), they will be ignored. [query]
121
+ * @param {array} propertiesWithHistory (optional) - A comma separated list of the properties to be returned along with their history of previous values. If any of the specified properties are not present on the requested object(s), they will be ignored. [query]
122
+ * @param {array} associations (optional) - A comma separated list of object types to retrieve associated IDs for. If any of the specified associations do not exist, they will be ignored. [query]
123
+ * @param {boolean} archived (optional) - Whether to return only results that have been archived. [query]
124
+ * @param {string} idProperty (optional) - The name of a property whose values are unique for this object [query]
125
+ *
126
+ * @returns {Promise<Object>} GET /crm/v3/objects/companies/{companyId} response
127
+ */
128
+ async getById(companyId: string, properties?: any, propertiesWithHistory?: any, associations?: any, archived?: any, idProperty?: any) {
129
+ // Build URL with path parameters
130
+ let url = '/crm/v3/objects/companies/{companyId}';
131
+ if (companyId) {
132
+ url = url.replace('{companyId}', companyId);
133
+ }
134
+
135
+ const options: any = {
136
+ method: 'GET',
137
+ params: {},
138
+ };
139
+
140
+ // Add query parameters
141
+ if (properties !== undefined) {
142
+ options.params.properties = properties;
143
+ }
144
+ if (propertiesWithHistory !== undefined) {
145
+ options.params.propertiesWithHistory = propertiesWithHistory;
146
+ }
147
+ if (associations !== undefined) {
148
+ options.params.associations = associations;
149
+ }
150
+ if (archived !== undefined) {
151
+ options.params.archived = archived;
152
+ }
153
+ if (idProperty !== undefined) {
154
+ options.params.idProperty = idProperty;
155
+ }
156
+
157
+ return this.api.fetch(url, options);
158
+ }
159
+
160
+ /**
161
+ * Update a company
162
+ *
163
+ * Update a company by ID (`companyId`) or unique property value (`idProperty`). Provided property values will be overwritten. Read-only and non-existent properties will result in an error. Properties values can be cleared by passing an empty string.
164
+ *
165
+ * @param {string} companyId (required) [path]
166
+ * @param {string} idProperty (optional) - The name of a property whose values are unique for this object [query]
167
+ *
168
+ * @param {Object} body (required) - Request body
169
+ *
170
+ * @returns {Promise<Object>} PATCH /crm/v3/objects/companies/{companyId} response
171
+ */
172
+ async update(companyId: string, idProperty?: any, body?: any) {
173
+ // Build URL with path parameters
174
+ let url = '/crm/v3/objects/companies/{companyId}';
175
+ if (companyId) {
176
+ url = url.replace('{companyId}', companyId);
177
+ }
178
+
179
+ const options: any = {
180
+ method: 'PATCH',
181
+ params: {},
182
+ body,
183
+ };
184
+
185
+ // Add query parameters
186
+ if (idProperty !== undefined) {
187
+ options.params.idProperty = idProperty;
188
+ }
189
+
190
+ return this.api.fetch(url, options);
191
+ }
192
+
193
+ /**
194
+ * Archive a company
195
+ *
196
+ * Delete a company by ID. Deleted companies can be restored within 90 days of deletion. Learn more about [restoring records](https://knowledge.hubspot.com/records/restore-deleted-records).
197
+ *
198
+ * @param {string} companyId (required) [path]
199
+ *
200
+ * @returns {Promise<Object>} DELETE /crm/v3/objects/companies/{companyId} response
201
+ */
202
+ async archive(companyId: string) {
203
+ // Build URL with path parameters
204
+ let url = '/crm/v3/objects/companies/{companyId}';
205
+ if (companyId) {
206
+ url = url.replace('{companyId}', companyId);
207
+ }
208
+
209
+ const options: any = {
210
+ method: 'DELETE',
211
+ };
212
+
213
+ return this.api.fetch(url, options);
214
+ }
215
+
216
+ /**
217
+ * Create or update a batch of companies by unique property values
218
+ *
219
+ * Create or update companies identified by a unique property value as specified by the `idProperty` query parameter. `idProperty` query param refers to a property whose values are unique for the object.
220
+ *
221
+ * @param {Object} body (required) - Request body
222
+ *
223
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/upsert response
224
+ */
225
+ async upsert(body?: any) {
226
+ const url = '/crm/v3/objects/companies/batch/upsert';
227
+ const options: any = {
228
+ method: 'POST',
229
+ body,
230
+ };
231
+
232
+ return this.api.fetch(url, options);
233
+ }
234
+
235
+ /**
236
+ * Create a batch of companies
237
+ *
238
+ * Create a batch of companies. The `inputs` array can contain a `properties` object to define property values for each company, along with an `associations` array to define [associations](https://developers.hubspot.com/docs/guides/api/crm/associations/associations-v4) with other CRM records.
239
+ *
240
+ * @param {Object} body (required) - Request body
241
+ *
242
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/create response
243
+ */
244
+ async create(body?: any) {
245
+ const url = '/crm/v3/objects/companies/batch/create';
246
+ const options: any = {
247
+ method: 'POST',
248
+ body,
249
+ };
250
+
251
+ return this.api.fetch(url, options);
252
+ }
253
+
254
+ /**
255
+ * Update a batch of companies
256
+ *
257
+ * Update a batch of companies by ID.
258
+ *
259
+ * @param {Object} body (required) - Request body
260
+ *
261
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/update response
262
+ */
263
+ async update(body?: any) {
264
+ const url = '/crm/v3/objects/companies/batch/update';
265
+ const options: any = {
266
+ method: 'POST',
267
+ body,
268
+ };
269
+
270
+ return this.api.fetch(url, options);
271
+ }
272
+
273
+ /**
274
+ * Archive a batch of companies
275
+ *
276
+ * Delete a batch of companies by ID. Deleted companies can be restored within 90 days of deletion. Learn more about [restoring records](https://knowledge.hubspot.com/records/restore-deleted-records).
277
+ *
278
+ * @param {Object} body (required) - Request body
279
+ *
280
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies/batch/archive response
281
+ */
282
+ async archive(body?: any) {
283
+ const url = '/crm/v3/objects/companies/batch/archive';
284
+ const options: any = {
285
+ method: 'POST',
286
+ body,
287
+ };
288
+
289
+ return this.api.fetch(url, options);
290
+ }
291
+
292
+ /**
293
+ * Merge two companies
294
+ *
295
+ * Merge two company records. Learn more about [merging records](https://knowledge.hubspot.com/records/merge-records).
296
+ *
297
+ * @param {Object} body (required) - Request body
298
+ *
299
+ * @returns {Promise<Object>} POST /crm/v3/objects/companies/merge response
300
+ */
301
+ async merge(body?: any) {
302
+ const url = '/crm/v3/objects/companies/merge';
303
+ const options: any = {
304
+ method: 'POST',
305
+ body,
306
+ };
307
+
308
+ return this.api.fetch(url, options);
309
+ }
310
+ }
@@ -0,0 +1,116 @@
1
+ #!/bin/bash
2
+
3
+ # Complete Example: Generate a Multi-Resource HubSpot Connector
4
+ # This script demonstrates how to create a connector with multiple resources
5
+
6
+ set -e # Exit on error
7
+
8
+ echo "🚀 Generating Multi-Resource HubSpot Connector"
9
+ echo "=============================================="
10
+ echo ""
11
+
12
+ # Step 1: Generate the main project with Companies resource
13
+ echo "📦 Step 1: Creating project with Companies resource..."
14
+ npx @aloma.io/integration-sdk@latest from-openapi "HubSpot" \
15
+ --connector-id "hubspot-connector" \
16
+ --spec hubspot-companies.json \
17
+ --out src/resources/companies.mts \
18
+ --resource CompaniesResource \
19
+ --no-build
20
+
21
+ cd HubSpot
22
+
23
+ echo ""
24
+ echo "✅ Project created with CompaniesResource"
25
+ echo ""
26
+
27
+ # Step 2: Generate additional resources (if you have the specs)
28
+ # Uncomment these when you have the OpenAPI specs
29
+
30
+ # echo "📦 Step 2: Adding Deals resource..."
31
+ # node <<EOF
32
+ # import {OpenAPIToConnector} from '@aloma.io/integration-sdk';
33
+ # import fs from 'fs';
34
+ #
35
+ # const specContent = fs.readFileSync('../hubspot-deals.json', 'utf-8');
36
+ # const spec = OpenAPIToConnector.parseSpec(specContent);
37
+ # const generator = new OpenAPIToConnector(spec, 'HubSpot Deals');
38
+ # const code = generator.generateResourceClass('DealsResource');
39
+ # fs.writeFileSync('src/resources/deals.mts', code);
40
+ # console.log('✅ Generated DealsResource');
41
+ # EOF
42
+
43
+ # echo ""
44
+ # echo "📦 Step 3: Adding Contacts resource..."
45
+ # node <<EOF
46
+ # import {OpenAPIToConnector} from '@aloma.io/integration-sdk';
47
+ # import fs from 'fs';
48
+ #
49
+ # const specContent = fs.readFileSync('../hubspot-contacts.json', 'utf-8');
50
+ # const spec = OpenAPIToConnector.parseSpec(specContent);
51
+ # const generator = new OpenAPIToConnector(spec, 'HubSpot Contacts');
52
+ # const code = generator.generateResourceClass('ContactsResource');
53
+ # fs.writeFileSync('src/resources/contacts.mts', code);
54
+ # console.log('✅ Generated ContactsResource');
55
+ # EOF
56
+
57
+ # Step 3: Create the main controller
58
+ echo "📝 Step 3: Creating main controller..."
59
+
60
+ cat > src/controller/index.mts << 'EOF'
61
+ import {AbstractController} from '@aloma.io/integration-sdk';
62
+ import CompaniesResource from '../resources/companies.mts';
63
+ // import DealsResource from '../resources/deals.mts';
64
+ // import ContactsResource from '../resources/contacts.mts';
65
+
66
+ export default class Controller extends AbstractController {
67
+ companies: CompaniesResource;
68
+ // deals: DealsResource;
69
+ // contacts: ContactsResource;
70
+
71
+ constructor(fetcher: any) {
72
+ super(fetcher);
73
+
74
+ // Each resource extends AbstractController and has access to this.api
75
+ this.companies = new CompaniesResource(fetcher);
76
+ // this.deals = new DealsResource(fetcher);
77
+ // this.contacts = new ContactsResource(fetcher);
78
+ }
79
+ }
80
+ EOF
81
+
82
+ echo "✅ Main controller created"
83
+ echo ""
84
+
85
+ # Step 4: Install dependencies and build
86
+ echo "📦 Step 4: Installing dependencies..."
87
+ yarn --ignore-engines
88
+
89
+ echo ""
90
+ echo "🔨 Step 5: Building project..."
91
+ yarn build
92
+
93
+ echo ""
94
+ echo "✅ Success! Your multi-resource connector is ready!"
95
+ echo ""
96
+ echo "📁 Project structure:"
97
+ echo " HubSpot/"
98
+ echo " ├── src/"
99
+ echo " │ ├── controller/"
100
+ echo " │ │ └── index.mts # Main controller"
101
+ echo " │ └── resources/"
102
+ echo " │ └── companies.mts # CompaniesResource"
103
+ echo " │ # └── deals.mts # (when added)"
104
+ echo " │ # └── contacts.mts # (when added)"
105
+ echo ""
106
+ echo "💡 Usage:"
107
+ echo " await controller.companies.create({ name: 'Acme Corp' });"
108
+ echo " await controller.companies.getPage(10);"
109
+ echo " await controller.companies.getById('12345');"
110
+ echo ""
111
+ echo "📝 Next steps:"
112
+ echo " 1. Add more resources (deals, contacts, etc.)"
113
+ echo " 2. Edit .env and insert the registration token"
114
+ echo " 3. Run: yarn start"
115
+ echo ""
116
+
@@ -0,0 +1,33 @@
1
+ #!/bin/bash
2
+
3
+ # Create HubSpot v2 Multi-Resource Connector
4
+ # This script demonstrates how to create a multi-resource connector with multiple OpenAPI specifications
5
+
6
+ echo "🚀 Creating HubSpot v2 Multi-Resource Connector..."
7
+
8
+ # Create the multi-resource connector with all 3 resources
9
+ npx @aloma.io/integration-sdk@latest create-multi-resource "HubSpot-v2" \
10
+ --connector-id "hubspot-123" \
11
+ --resources "CompaniesResource:examples/hubspot-companies.json,ContactsResource:examples/hubspot-contacts.json,ListsResource:examples/hubspot-lists.json" \
12
+ --base-url "https://api.hubapi.com" \
13
+ --no-build
14
+
15
+ echo "✅ HubSpot v2 connector created successfully!"
16
+ echo ""
17
+ echo "📁 Generated structure:"
18
+ echo "├── src/controller/index.mts (main controller)"
19
+ echo "├── src/resources/companies.mts (CompaniesResource)"
20
+ echo "├── src/resources/contacts.mts (ContactsResource)"
21
+ echo "└── src/resources/lists.mts (ListsResource)"
22
+ echo ""
23
+ echo "🔧 Next steps:"
24
+ echo "1.) cd HubSpot-v2"
25
+ echo "2.) yarn --ignore-engines"
26
+ echo "3.) yarn build"
27
+ echo "4.) Add to workspace and configure .env"
28
+ echo "5.) yarn start"
29
+ echo ""
30
+ echo "💡 Usage examples:"
31
+ echo "await controller.companies.create({ body: { properties: { name: 'Acme Corp' } } });"
32
+ echo "await controller.contacts.getPage({ limit: 10 });"
33
+ echo "await controller.lists.getAll({ limit: 50 });"