@aloma.io/integration-sdk 3.8.56 → 3.8.57

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.
@@ -139,10 +139,11 @@ ${arg.configurableClientScope}
139
139
  query = query
140
140
  .filter((what) => !!what?.trim() && !['constructor', '__proto__', 'toString', 'toSource', 'prototype'].includes(what))
141
141
  .slice(0, 20);
142
+ const originalQuery = [...query];
142
143
  const method = resolveMethod(query);
143
144
  if (!method && !_resolvers.__default)
144
- throw new Error(`${query} not found`);
145
- return method ? method(variables) : _resolvers.__default(variables ? { ...variables, __method: query } : variables);
145
+ throw new Error(`${originalQuery} not found`);
146
+ return method ? method(variables) : _resolvers.__default(variables ? { ...variables, __method: originalQuery } : variables);
146
147
  };
147
148
  const introspect = () => local._types;
148
149
  const configSchema = () => local._config;
@@ -186,7 +186,7 @@ export class OpenAPIToConnector {
186
186
  this.addRequestBodyProperties(operation.requestBody, optionProps);
187
187
  }
188
188
  // Check if options parameter is required (has required query params or required body)
189
- const hasRequiredNonPathParams = queryParams.some(p => p.required) || (hasBody && operation.requestBody?.required);
189
+ const hasRequiredNonPathParams = queryParams.some((p) => p.required) || (hasBody && operation.requestBody?.required);
190
190
  const optionsRequired = hasRequiredNonPathParams ? '' : '?';
191
191
  // Only add options parameter if there are actual options
192
192
  if (optionProps.length > 0) {
@@ -285,7 +285,7 @@ export class OpenAPIToConnector {
285
285
  * Sanitize a name to be a valid TypeScript identifier
286
286
  */
287
287
  sanitizeTypeName(name) {
288
- return name
288
+ return (name
289
289
  // Replace dots with underscores
290
290
  .replace(/\./g, '_')
291
291
  // Replace + with _Plus (common in OpenAPI for enums)
@@ -297,9 +297,9 @@ export class OpenAPIToConnector {
297
297
  // Remove multiple consecutive underscores
298
298
  .replace(/_+/g, '_')
299
299
  // Remove trailing/leading underscores
300
- .replace(/^_+|_+$/g, '')
300
+ .replace(/^_+|_+$/g, '') ||
301
301
  // Ensure it's not empty
302
- || 'UnknownType';
302
+ 'UnknownType');
303
303
  }
304
304
  /**
305
305
  * Get TypeScript type from schema object
@@ -323,7 +323,8 @@ export class OpenAPIToConnector {
323
323
  if (schema.type === 'object' && schema.properties) {
324
324
  const propNames = Object.keys(schema.properties);
325
325
  // For response objects, generate inline type definitions
326
- if (propNames.length <= 5) { // Reasonable limit for inline types
326
+ if (propNames.length <= 5) {
327
+ // Reasonable limit for inline types
327
328
  const propTypes = Object.entries(schema.properties).map(([key, prop]) => {
328
329
  const propType = this.getTypeFromSchema(prop);
329
330
  return `${key}: ${propType}`;
@@ -420,14 +421,15 @@ export class OpenAPIToConnector {
420
421
  if (schema.properties) {
421
422
  for (const [propName, propSchema] of Object.entries(schema.properties)) {
422
423
  const propType = this.getTypeFromSchema(propSchema);
423
- const required = (schema.required && schema.required.includes(propName)) || (requestBody.required);
424
+ const required = (schema.required && schema.required.includes(propName)) || requestBody.required;
424
425
  const optional = required ? '' : '?';
425
426
  // Add description as comment if available
426
427
  const description = propSchema?.description;
427
428
  if (description) {
428
429
  // Clean up description for inline use
429
430
  const cleanDesc = description.replace(/\n/g, ' ').replace(/\s+/g, ' ').trim();
430
- if (cleanDesc.length < 100) { // Only add short descriptions inline
431
+ if (cleanDesc.length < 100) {
432
+ // Only add short descriptions inline
431
433
  optionProps.push(`${propName}${optional}: ${propType} /** ${cleanDesc} */`);
432
434
  }
433
435
  else {
@@ -708,7 +710,7 @@ export class OpenAPIToConnector {
708
710
  for (const resource of resources) {
709
711
  const resourceName = resource.fileName;
710
712
  // Find the corresponding spec for this resource
711
- const resourceSpec = resourceSpecs?.find(rs => rs.fileName === resourceName);
713
+ const resourceSpec = resourceSpecs?.find((rs) => rs.fileName === resourceName);
712
714
  if (resourceSpec) {
713
715
  // Create a temporary generator for this resource's spec
714
716
  const resourceGenerator = new OpenAPIToConnector(resourceSpec.spec, resourceName);
@@ -756,10 +758,13 @@ ${jsdoc}
756
758
  const paramMatch = signature.match(/\(([^)]+)\)/);
757
759
  if (!paramMatch || paramMatch[1].trim() === '')
758
760
  return '';
759
- const allParams = paramMatch[1].split(',').map(p => {
761
+ const allParams = paramMatch[1]
762
+ .split(',')
763
+ .map((p) => {
760
764
  const paramName = p.trim().split(':')[0].trim();
761
765
  return paramName.replace(/[?]/g, '');
762
- }).filter(p => p.length > 0);
766
+ })
767
+ .filter((p) => p.length > 0);
763
768
  // Check if signature actually has options parameter
764
769
  const hasOptionsParam = allParams.includes('options');
765
770
  // Always extract path parameters as discrete parameters when they exist
@@ -807,7 +812,7 @@ ${jsdoc}
807
812
  }
808
813
  // Handle allOf, oneOf, anyOf
809
814
  if (schema.allOf) {
810
- lines.push(` // Inherits from: ${schema.allOf.map((s) => s.$ref ? this.resolveSchemaRef(s.$ref) : 'unknown').join(', ')}`);
815
+ lines.push(` // Inherits from: ${schema.allOf.map((s) => (s.$ref ? this.resolveSchemaRef(s.$ref) : 'unknown')).join(', ')}`);
811
816
  }
812
817
  lines.push('}');
813
818
  return lines.join('\n');
@@ -845,7 +850,7 @@ ${jsdoc}
845
850
  lines.push(' *');
846
851
  // Split long descriptions into multiple lines
847
852
  const descLines = operation.description.split('\n');
848
- descLines.forEach(line => {
853
+ descLines.forEach((line) => {
849
854
  lines.push(` * ${line}`);
850
855
  });
851
856
  }
@@ -866,7 +871,7 @@ ${jsdoc}
866
871
  }
867
872
  }
868
873
  // Document discrete path parameters
869
- pathParams.forEach(param => {
874
+ pathParams.forEach((param) => {
870
875
  const paramType = this.getParameterType(param);
871
876
  const paramDesc = param.description || '';
872
877
  lines.push(` * @param {${paramType}} ${param.name} ${paramDesc}`);
@@ -875,7 +880,7 @@ ${jsdoc}
875
880
  if (queryParams.length > 0 || operation.requestBody) {
876
881
  lines.push(' * @param {Object} options - Request options');
877
882
  // Document query parameters
878
- queryParams.forEach(param => {
883
+ queryParams.forEach((param) => {
879
884
  const paramType = this.getParameterType(param);
880
885
  const paramDesc = param.description || '';
881
886
  const required = param.required ? '(required)' : '(optional)';
@@ -938,7 +943,7 @@ ${jsdoc}
938
943
  if (schema.properties) {
939
944
  for (const [propName, propSchema] of Object.entries(schema.properties)) {
940
945
  const propType = this.getTypeFromSchema(propSchema);
941
- const propRequired = (schema.required && schema.required.includes(propName)) || (requestBody.required);
946
+ const propRequired = (schema.required && schema.required.includes(propName)) || requestBody.required;
942
947
  const requiredText = propRequired ? '(required)' : '(optional)';
943
948
  const propDesc = propSchema?.description || '';
944
949
  lines.push(` * @param {${propType}} options.${propName} ${requiredText} - ${propDesc} [body property]`);
@@ -1156,9 +1161,7 @@ ${functions}`;
1156
1161
  const imports = resources
1157
1162
  .map((resource) => `import * as ${resource.fileName}Functions from '../resources/${resource.fileName}.mjs';`)
1158
1163
  .join('\n');
1159
- const properties = resources
1160
- .map((resource) => ` ${resource.fileName}: any = {};`)
1161
- .join('\n');
1164
+ const properties = resources.map((resource) => ` ${resource.fileName}: any = {};`).join('\n');
1162
1165
  const bindings = resources
1163
1166
  .map((resource) => ` this.bindResourceFunctions('${resource.fileName}', ${resource.fileName}Functions);`)
1164
1167
  .join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.8.56",
3
+ "version": "3.8.57",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -53,5 +53,17 @@
53
53
  "mocha": "^10",
54
54
  "prettier": "^3",
55
55
  "ts-node": "^10.9.2"
56
+ },
57
+ "resolutions": {
58
+ "path-to-regexp": "0.1.13"
59
+ },
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "https://github.com/aloma-io/integration.git",
63
+ "directory": "integration-sdk"
64
+ },
65
+ "publishConfig": {
66
+ "access": "public",
67
+ "registry": "https://registry.npmjs.org/"
56
68
  }
57
69
  }
@@ -172,10 +172,12 @@ ${arg.configurableClientScope}
172
172
  )
173
173
  .slice(0, 20);
174
174
 
175
+ const originalQuery = [...query];
176
+
175
177
  const method = resolveMethod(query);
176
- if (!method && !_resolvers.__default) throw new Error(`${query} not found`);
178
+ if (!method && !_resolvers.__default) throw new Error(`${originalQuery} not found`);
177
179
 
178
- return method ? method(variables) : _resolvers.__default(variables ? {...variables, __method: query} : variables);
180
+ return method ? method(variables) : _resolvers.__default(variables ? {...variables, __method: originalQuery} : variables);
179
181
  };
180
182
 
181
183
  const introspect = () => local._types;