@aloma.io/integration-sdk 3.8.51 → 3.8.52

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.
@@ -95,7 +95,27 @@ export class OpenAPIToConnector {
95
95
  */
96
96
  generateMethodName(operation) {
97
97
  if (operation.operationId) {
98
- return this.toValidIdentifier(operation.operationId);
98
+ // Clean up HubSpot-style operationIds like "get-/crm/v3/objects/companies_getPage"
99
+ let cleaned = operation.operationId;
100
+ // Extract the last part after underscore if it exists
101
+ const parts = cleaned.split('_');
102
+ if (parts.length > 1) {
103
+ const lastPart = parts[parts.length - 1];
104
+ // If the last part looks like a method name (camelCase), use it
105
+ if (lastPart && /^[a-z][a-zA-Z0-9]*$/.test(lastPart)) {
106
+ cleaned = lastPart;
107
+ }
108
+ }
109
+ // Remove any remaining special characters and clean up
110
+ cleaned = cleaned
111
+ .replace(/^(get|post|put|patch|delete|head|options)-/i, '') // Remove HTTP method prefix
112
+ .replace(/[^a-zA-Z0-9_]/g, '_')
113
+ .replace(/_+/g, '_')
114
+ .replace(/^_|_$/g, '');
115
+ // If we still have a valid identifier, use it
116
+ if (cleaned && /^[a-zA-Z]/.test(cleaned)) {
117
+ return cleaned;
118
+ }
99
119
  }
100
120
  // Generate from method + path
101
121
  const pathParts = operation.path
@@ -116,22 +136,47 @@ export class OpenAPIToConnector {
116
136
  lines.push(` * ${operation.summary}`);
117
137
  }
118
138
  if (operation.description) {
119
- lines.push(` * ${operation.description}`);
139
+ lines.push(` *`);
140
+ // Split long descriptions into multiple lines
141
+ const descLines = operation.description.split('\n');
142
+ descLines.forEach(line => {
143
+ if (line.trim()) {
144
+ lines.push(` * ${line.trim()}`);
145
+ }
146
+ });
120
147
  }
148
+ // Document parameters with full details
121
149
  if (operation.parameters && operation.parameters.length > 0) {
122
150
  lines.push(' *');
123
- lines.push(' * @param args - Request arguments');
151
+ lines.push(' * @param {Object} args - Request arguments');
124
152
  for (const param of operation.parameters) {
125
- if (typeof param === 'object' && 'name' in param && 'description' in param) {
126
- lines.push(` * @param args.${param.name} - ${param.description || 'Parameter'}`);
153
+ if (typeof param === 'object' && 'name' in param) {
154
+ const paramName = param.name;
155
+ const paramDesc = param.description || '';
156
+ const paramRequired = param.required ? '(required)' : '(optional)';
157
+ const paramType = param.schema?.type || 'any';
158
+ const paramIn = param.in || '';
159
+ let paramDoc = ` * @param {${paramType}} args.${paramName} ${paramRequired}`;
160
+ if (paramDesc) {
161
+ paramDoc += ` - ${paramDesc}`;
162
+ }
163
+ if (paramIn) {
164
+ paramDoc += ` [${paramIn}]`;
165
+ }
166
+ lines.push(paramDoc);
127
167
  }
128
168
  }
129
169
  }
170
+ // Document request body
130
171
  if (operation.requestBody) {
131
172
  lines.push(' *');
132
- lines.push(' * @param args.body - Request body');
173
+ const bodyDesc = operation.requestBody.description || 'Request body';
174
+ const required = operation.requestBody.required ? '(required)' : '(optional)';
175
+ lines.push(` * @param {Object} args.body ${required} - ${bodyDesc}`);
133
176
  }
134
- lines.push(' * @returns Response data');
177
+ // Document response
178
+ lines.push(' *');
179
+ lines.push(` * @returns {Promise<Object>} ${operation.method} ${operation.path} response`);
135
180
  return lines.join('\n');
136
181
  }
137
182
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.8.51",
3
+ "version": "3.8.52",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -122,7 +122,30 @@ export class OpenAPIToConnector {
122
122
  */
123
123
  private generateMethodName(operation: OperationInfo): string {
124
124
  if (operation.operationId) {
125
- return this.toValidIdentifier(operation.operationId);
125
+ // Clean up HubSpot-style operationIds like "get-/crm/v3/objects/companies_getPage"
126
+ let cleaned = operation.operationId;
127
+
128
+ // Extract the last part after underscore if it exists
129
+ const parts = cleaned.split('_');
130
+ if (parts.length > 1) {
131
+ const lastPart = parts[parts.length - 1];
132
+ // If the last part looks like a method name (camelCase), use it
133
+ if (lastPart && /^[a-z][a-zA-Z0-9]*$/.test(lastPart)) {
134
+ cleaned = lastPart;
135
+ }
136
+ }
137
+
138
+ // Remove any remaining special characters and clean up
139
+ cleaned = cleaned
140
+ .replace(/^(get|post|put|patch|delete|head|options)-/i, '') // Remove HTTP method prefix
141
+ .replace(/[^a-zA-Z0-9_]/g, '_')
142
+ .replace(/_+/g, '_')
143
+ .replace(/^_|_$/g, '');
144
+
145
+ // If we still have a valid identifier, use it
146
+ if (cleaned && /^[a-zA-Z]/.test(cleaned)) {
147
+ return cleaned;
148
+ }
126
149
  }
127
150
 
128
151
  // Generate from method + path
@@ -149,25 +172,52 @@ export class OpenAPIToConnector {
149
172
  }
150
173
 
151
174
  if (operation.description) {
152
- lines.push(` * ${operation.description}`);
175
+ lines.push(` *`);
176
+ // Split long descriptions into multiple lines
177
+ const descLines = operation.description.split('\n');
178
+ descLines.forEach(line => {
179
+ if (line.trim()) {
180
+ lines.push(` * ${line.trim()}`);
181
+ }
182
+ });
153
183
  }
154
184
 
185
+ // Document parameters with full details
155
186
  if (operation.parameters && operation.parameters.length > 0) {
156
187
  lines.push(' *');
157
- lines.push(' * @param args - Request arguments');
188
+ lines.push(' * @param {Object} args - Request arguments');
189
+
158
190
  for (const param of operation.parameters) {
159
- if (typeof param === 'object' && 'name' in param && 'description' in param) {
160
- lines.push(` * @param args.${param.name} - ${param.description || 'Parameter'}`);
191
+ if (typeof param === 'object' && 'name' in param) {
192
+ const paramName = param.name;
193
+ const paramDesc = param.description || '';
194
+ const paramRequired = param.required ? '(required)' : '(optional)';
195
+ const paramType = param.schema?.type || 'any';
196
+ const paramIn = param.in || '';
197
+
198
+ let paramDoc = ` * @param {${paramType}} args.${paramName} ${paramRequired}`;
199
+ if (paramDesc) {
200
+ paramDoc += ` - ${paramDesc}`;
201
+ }
202
+ if (paramIn) {
203
+ paramDoc += ` [${paramIn}]`;
204
+ }
205
+ lines.push(paramDoc);
161
206
  }
162
207
  }
163
208
  }
164
209
 
210
+ // Document request body
165
211
  if (operation.requestBody) {
166
212
  lines.push(' *');
167
- lines.push(' * @param args.body - Request body');
213
+ const bodyDesc = operation.requestBody.description || 'Request body';
214
+ const required = operation.requestBody.required ? '(required)' : '(optional)';
215
+ lines.push(` * @param {Object} args.body ${required} - ${bodyDesc}`);
168
216
  }
169
217
 
170
- lines.push(' * @returns Response data');
218
+ // Document response
219
+ lines.push(' *');
220
+ lines.push(` * @returns {Promise<Object>} ${operation.method} ${operation.path} response`);
171
221
 
172
222
  return lines.join('\n');
173
223
  }