@aloma.io/integration-sdk 3.8.55 → 3.8.56
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/MULTI_RESOURCE_GUIDE.md +24 -21
 - package/OPENAPI_TO_CONNECTOR.md +146 -16
 - package/README.md +62 -10
 - package/build/cli.mjs +122 -33
 - package/build/openapi-to-connector.d.mts +88 -11
 - package/build/openapi-to-connector.mjs +904 -207
 - package/package.json +3 -1
 - package/src/cli.mts +140 -37
 - package/src/openapi-to-connector.mts +1006 -217
 - package/test/scenarios/README.md +148 -0
 - package/test/scenarios/complex/expected/controller.mts +271 -0
 - package/test/scenarios/complex/expected/orders-resource.mts +264 -0
 - package/test/scenarios/complex/expected/products-resource.mts +239 -0
 - package/test/scenarios/complex/specs/orders.json +362 -0
 - package/test/scenarios/complex/specs/products.json +308 -0
 - package/test/scenarios/simple/expected-controller.mts +60 -0
 - package/test/scenarios/simple/simple-api.json +39 -0
 - package/test/scenarios.test.mts +286 -0
 - package/test/verify-scenarios.mjs +298 -0
 
    
        package/MULTI_RESOURCE_GUIDE.md
    CHANGED
    
    | 
         @@ -13,26 +13,27 @@ src/ 
     | 
|
| 
       13 
13 
     | 
    
         
             
            ├── controller/
         
     | 
| 
       14 
14 
     | 
    
         
             
            │   └── index.mts          # Main controller (extends AbstractController)
         
     | 
| 
       15 
15 
     | 
    
         
             
            └── resources/
         
     | 
| 
       16 
     | 
    
         
            -
                ├── companies.mts      #  
     | 
| 
       17 
     | 
    
         
            -
                ├── contacts.mts       #  
     | 
| 
       18 
     | 
    
         
            -
                └── lists.mts          #  
     | 
| 
      
 16 
     | 
    
         
            +
                ├── companies.mts      # Companies resource functions
         
     | 
| 
      
 17 
     | 
    
         
            +
                ├── contacts.mts       # Contacts resource functions
         
     | 
| 
      
 18 
     | 
    
         
            +
                └── lists.mts          # Lists resource functions
         
     | 
| 
       19 
19 
     | 
    
         
             
            ```
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            ### Main Controller
         
     | 
| 
       22 
22 
     | 
    
         
             
            - Extends `AbstractController`
         
     | 
| 
       23 
23 
     | 
    
         
             
            - Has `private api: any` and `protected async start()`
         
     | 
| 
       24 
     | 
    
         
            -
            -  
     | 
| 
       25 
     | 
    
         
            -
            - Initializes API client once
         
     | 
| 
      
 24 
     | 
    
         
            +
            - Binds resource functions to controller context with `function.bind(this)`
         
     | 
| 
      
 25 
     | 
    
         
            +
            - Initializes API client once and provides context to bound functions
         
     | 
| 
       26 
26 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
            ### Resource  
     | 
| 
       28 
     | 
    
         
            -
            - Plain TypeScript  
     | 
| 
       29 
     | 
    
         
            -
            -  
     | 
| 
       30 
     | 
    
         
            -
            - Access `api` via  
     | 
| 
      
 27 
     | 
    
         
            +
            ### Resource Functions (New Pattern!)
         
     | 
| 
      
 28 
     | 
    
         
            +
            - Plain TypeScript exported functions (no classes)
         
     | 
| 
      
 29 
     | 
    
         
            +
            - Bound to controller context using `function.bind(this)`
         
     | 
| 
      
 30 
     | 
    
         
            +
            - Access `api` directly via `this.api` (bound context)
         
     | 
| 
       31 
31 
     | 
    
         
             
            - Focus on their specific domain
         
     | 
| 
      
 32 
     | 
    
         
            +
            - Enable proper API introspection by the framework
         
     | 
| 
       32 
33 
     | 
    
         | 
| 
       33 
34 
     | 
    
         
             
            ## Creating Multi-Resource Connectors
         
     | 
| 
       34 
35 
     | 
    
         | 
| 
       35 
     | 
    
         
            -
            ### 1.  
     | 
| 
      
 36 
     | 
    
         
            +
            ### 1. Generate Base Controller (Functions Pattern)
         
     | 
| 
       36 
37 
     | 
    
         | 
| 
       37 
38 
     | 
    
         
             
            ```bash
         
     | 
| 
       38 
39 
     | 
    
         
             
            npx @aloma.io/integration-sdk@latest create-multi-resource "MyConnector" \
         
     | 
| 
         @@ -42,7 +43,7 @@ npx @aloma.io/integration-sdk@latest create-multi-resource "MyConnector" \ 
     | 
|
| 
       42 
43 
     | 
    
         
             
            ```
         
     | 
| 
       43 
44 
     | 
    
         | 
| 
       44 
45 
     | 
    
         
             
            **Parameters:**
         
     | 
| 
       45 
     | 
    
         
            -
            - `--resources`: Comma-separated list of ` 
     | 
| 
      
 46 
     | 
    
         
            +
            - `--resources`: Comma-separated list of `ResourceName:specFile` pairs
         
     | 
| 
       46 
47 
     | 
    
         
             
            - `--base-url`: API base URL (optional, extracted from first spec if not provided)
         
     | 
| 
       47 
48 
     | 
    
         
             
            - `--no-build`: Skip dependency installation and building
         
     | 
| 
       48 
49 
     | 
    
         | 
| 
         @@ -72,12 +73,13 @@ The `--resources` parameter accepts a comma-separated list in this format: 
     | 
|
| 
       72 
73 
     | 
    
         
             
            ```bash
         
     | 
| 
       73 
74 
     | 
    
         
             
            npx @aloma.io/integration-sdk@latest add-resource ./existing-project \
         
     | 
| 
       74 
75 
     | 
    
         
             
              --className "DealsResource" \
         
     | 
| 
       75 
     | 
    
         
            -
              --spec "deals.json"
         
     | 
| 
      
 76 
     | 
    
         
            +
              --spec "deals.json" \
         
     | 
| 
      
 77 
     | 
    
         
            +
              --no-build
         
     | 
| 
       76 
78 
     | 
    
         
             
            ```
         
     | 
| 
       77 
79 
     | 
    
         | 
| 
       78 
80 
     | 
    
         
             
            This will:
         
     | 
| 
       79 
     | 
    
         
            -
            - Generate the new resource  
     | 
| 
       80 
     | 
    
         
            -
            - Save  
     | 
| 
      
 81 
     | 
    
         
            +
            - Generate the new resource functions
         
     | 
| 
      
 82 
     | 
    
         
            +
            - Save them to `src/resources/deals.mts`
         
     | 
| 
       81 
83 
     | 
    
         
             
            - Provide instructions for updating the main controller
         
     | 
| 
       82 
84 
     | 
    
         | 
| 
       83 
85 
     | 
    
         
             
            ### 2. Update Main Controller Manually
         
     | 
| 
         @@ -86,13 +88,13 @@ After adding a resource, you need to update the main controller: 
     | 
|
| 
       86 
88 
     | 
    
         | 
| 
       87 
89 
     | 
    
         
             
            ```typescript
         
     | 
| 
       88 
90 
     | 
    
         
             
            // 1. Add import
         
     | 
| 
       89 
     | 
    
         
            -
            import  
     | 
| 
      
 91 
     | 
    
         
            +
            import * as dealsResource from '../resources/deals.mjs';
         
     | 
| 
       90 
92 
     | 
    
         | 
| 
       91 
93 
     | 
    
         
             
            // 2. Add property
         
     | 
| 
       92 
     | 
    
         
            -
            deals!:  
     | 
| 
      
 94 
     | 
    
         
            +
            deals!: typeof dealsResource;
         
     | 
| 
       93 
95 
     | 
    
         | 
| 
       94 
96 
     | 
    
         
             
            // 3. Add initialization in start()
         
     | 
| 
       95 
     | 
    
         
            -
            this.deals =  
     | 
| 
      
 97 
     | 
    
         
            +
            this.deals = this.bindResourceFunctions(dealsResource);
         
     | 
| 
       96 
98 
     | 
    
         
             
            ```
         
     | 
| 
       97 
99 
     | 
    
         | 
| 
       98 
100 
     | 
    
         
             
            ## Usage Examples
         
     | 
| 
         @@ -147,9 +149,9 @@ await controller.companies.getPage({ 
     | 
|
| 
       147 
149 
     | 
    
         
             
            ## Best Practices
         
     | 
| 
       148 
150 
     | 
    
         | 
| 
       149 
151 
     | 
    
         
             
            ### 1. Resource Naming
         
     | 
| 
       150 
     | 
    
         
            -
            - Use descriptive  
     | 
| 
      
 152 
     | 
    
         
            +
            - Use descriptive resource names: `CompaniesResource`, `ContactsResource`
         
     | 
| 
       151 
153 
     | 
    
         
             
            - File names are auto-generated: `companies.mts`, `contacts.mts`
         
     | 
| 
       152 
     | 
    
         
            -
            - Property names in controller: `companies`, `contacts`
         
     | 
| 
      
 154 
     | 
    
         
            +
            - Property names in controller (bound functions): `companies`, `contacts`
         
     | 
| 
       153 
155 
     | 
    
         | 
| 
       154 
156 
     | 
    
         
             
            ### 2. OpenAPI Specifications
         
     | 
| 
       155 
157 
     | 
    
         
             
            - Each resource should have its own focused OpenAPI spec
         
     | 
| 
         @@ -193,9 +195,10 @@ If you see TypeScript errors about missing file extensions: 
     | 
|
| 
       193 
195 
     | 
    
         
             
            - Ensure you're using `.mjs` extensions in imports
         
     | 
| 
       194 
196 
     | 
    
         
             
            - The generator handles this automatically in new projects
         
     | 
| 
       195 
197 
     | 
    
         | 
| 
       196 
     | 
    
         
            -
            ### Resource Not Found
         
     | 
| 
      
 198 
     | 
    
         
            +
            ### Resource Functions Not Found
         
     | 
| 
       197 
199 
     | 
    
         
             
            If a resource property is undefined:
         
     | 
| 
       198 
     | 
    
         
            -
            - Check that the resource  
     | 
| 
      
 200 
     | 
    
         
            +
            - Check that the resource functions are properly bound in `start()`
         
     | 
| 
      
 201 
     | 
    
         
            +
            - Ensure `bindResourceFunctions()` was called correctly
         
     | 
| 
       199 
202 
     | 
    
         
             
            - Verify the import path in the main controller
         
     | 
| 
       200 
203 
     | 
    
         
             
            - Ensure the resource file was generated correctly
         
     | 
| 
       201 
204 
     | 
    
         | 
    
        package/OPENAPI_TO_CONNECTOR.md
    CHANGED
    
    | 
         @@ -4,13 +4,30 @@ A deterministic script that generates Aloma connector controllers from OpenAPI 3 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            ## Features
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
      
 7 
     | 
    
         
            +
            ### Core Generation
         
     | 
| 
       7 
8 
     | 
    
         
             
            - ✅ **Deterministic**: Same OpenAPI input always produces the same connector definition
         
     | 
| 
       8 
9 
     | 
    
         
             
            - ✅ **No LLM involvement**: Pure parsing and code generation
         
     | 
| 
       9 
10 
     | 
    
         
             
            - ✅ **OpenAPI 3.x support**: Validates against OpenAPI 3.x schema
         
     | 
| 
       10 
11 
     | 
    
         
             
            - ✅ **JSON & YAML support**: Handles both JSON and YAML OpenAPI specifications
         
     | 
| 
       11 
12 
     | 
    
         
             
            - ✅ **Comprehensive coverage**: Generates methods for all endpoints and operations
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            ### TypeScript & Code Quality
         
     | 
| 
      
 15 
     | 
    
         
            +
            - ✅ **TypeScript Interface Generation**: Automatically generates interfaces from OpenAPI schemas
         
     | 
| 
      
 16 
     | 
    
         
            +
            - ✅ **Schema Name Sanitization**: Converts invalid names (e.g., `Complex.Name.With.Dots` → `Complex_Name_With_Dots`)
         
     | 
| 
      
 17 
     | 
    
         
            +
            - ✅ **Clean Parameter Handling**: No unnecessary options parameters for simple methods
         
     | 
| 
      
 18 
     | 
    
         
            +
            - ✅ **Path Parameter Separation**: Discrete path parameters with optional options object
         
     | 
| 
      
 19 
     | 
    
         
            +
            - ✅ **Inline Body Construction**: Direct body building without helper methods
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            ### Documentation & Usability
         
     | 
| 
      
 22 
     | 
    
         
            +
            - ✅ **Rich JSDoc Generation**: Detailed documentation with parameter descriptions and examples
         
     | 
| 
      
 23 
     | 
    
         
            +
            - ✅ **Schema Field Documentation**: Documents response object fields and properties
         
     | 
| 
      
 24 
     | 
    
         
            +
            - ✅ **Parameter Type Documentation**: Includes TypeScript types in JSDoc comments
         
     | 
| 
      
 25 
     | 
    
         
            +
            - ✅ **Controller-Only Mode**: Generate just the controller file for existing projects
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            ### Architecture Support
         
     | 
| 
      
 28 
     | 
    
         
            +
            - ✅ **Multi-Resource Architecture**: Support for complex APIs with multiple resource groups
         
     | 
| 
      
 29 
     | 
    
         
            +
            - ✅ **Resource Function Pattern**: Functions bound to controller context for proper introspection
         
     | 
| 
      
 30 
     | 
    
         
            +
            - ✅ **API Introspection**: Exposed methods for framework compatibility
         
     | 
| 
       14 
31 
     | 
    
         
             
            - ✅ **Error handling**: Clear error messages for invalid specifications
         
     | 
| 
       15 
32 
     | 
    
         | 
| 
       16 
33 
     | 
    
         
             
            ## Installation
         
     | 
| 
         @@ -39,6 +56,19 @@ npx @aloma.io/integration-sdk@latest from-openapi "My Connector" --connector-id 
     | 
|
| 
       39 
56 
     | 
    
         | 
| 
       40 
57 
     | 
    
         
             
            # With custom output path
         
     | 
| 
       41 
58 
     | 
    
         
             
            npx @aloma.io/integration-sdk@latest from-openapi "My Connector" --connector-id "my-connector-123" --spec api.yaml --out src/controller/index.mts
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
            # Controller-only mode (NEW!) - Generate just the controller file
         
     | 
| 
      
 61 
     | 
    
         
            +
            npx @aloma.io/integration-sdk@latest from-openapi "My Connector" \
         
     | 
| 
      
 62 
     | 
    
         
            +
              --connector-id "my-connector-123" \
         
     | 
| 
      
 63 
     | 
    
         
            +
              --spec api.yaml \
         
     | 
| 
      
 64 
     | 
    
         
            +
              --controller-only \
         
     | 
| 
      
 65 
     | 
    
         
            +
              --out "./src/controller/index.mts"
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            # Multi-resource connector
         
     | 
| 
      
 68 
     | 
    
         
            +
            npx @aloma.io/integration-sdk@latest create-multi-resource "My Connector" \
         
     | 
| 
      
 69 
     | 
    
         
            +
              --connector-id "my-connector-123" \
         
     | 
| 
      
 70 
     | 
    
         
            +
              --resources "ProductsResource:products.json,OrdersResource:orders.json" \
         
     | 
| 
      
 71 
     | 
    
         
            +
              --base-url "https://api.example.com"
         
     | 
| 
       42 
72 
     | 
    
         
             
            ```
         
     | 
| 
       43 
73 
     | 
    
         | 
| 
       44 
74 
     | 
    
         
             
            #### Options
         
     | 
| 
         @@ -47,6 +77,9 @@ npx @aloma.io/integration-sdk@latest from-openapi "My Connector" --connector-id 
     | 
|
| 
       47 
77 
     | 
    
         
             
            - `--connector-id <id>` (required): ID of the connector
         
     | 
| 
       48 
78 
     | 
    
         
             
            - `--spec <file>` (required): OpenAPI specification file (JSON or YAML)
         
     | 
| 
       49 
79 
     | 
    
         
             
            - `--out <file>` (optional): Output file path for the controller (default: `src/controller/index.mts`)
         
     | 
| 
      
 80 
     | 
    
         
            +
            - `--controller-only` (optional): Generate only the controller file, no project structure
         
     | 
| 
      
 81 
     | 
    
         
            +
            - `--resource <className>` (optional): Generate as a resource class instead of controller
         
     | 
| 
      
 82 
     | 
    
         
            +
            - `--no-build` (optional): Skip installing dependencies and building the project
         
     | 
| 
       50 
83 
     | 
    
         | 
| 
       51 
84 
     | 
    
         
             
            ### Standalone Script Usage
         
     | 
| 
       52 
85 
     | 
    
         | 
| 
         @@ -116,29 +149,94 @@ paths: 
     | 
|
| 
       116 
149 
     | 
    
         
             
            ```typescript
         
     | 
| 
       117 
150 
     | 
    
         
             
            import {AbstractController} from '@aloma.io/integration-sdk';
         
     | 
| 
       118 
151 
     | 
    
         | 
| 
      
 152 
     | 
    
         
            +
            // Generated TypeScript interfaces from OpenAPI schemas
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
            export interface User {
         
     | 
| 
      
 155 
     | 
    
         
            +
              id: string;
         
     | 
| 
      
 156 
     | 
    
         
            +
              name: string;
         
     | 
| 
      
 157 
     | 
    
         
            +
              email?: string;
         
     | 
| 
      
 158 
     | 
    
         
            +
              createdAt: string;
         
     | 
| 
      
 159 
     | 
    
         
            +
            }
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
            export interface UserList {
         
     | 
| 
      
 162 
     | 
    
         
            +
              users: User[];
         
     | 
| 
      
 163 
     | 
    
         
            +
              total: number;
         
     | 
| 
      
 164 
     | 
    
         
            +
              hasMore: boolean;
         
     | 
| 
      
 165 
     | 
    
         
            +
            }
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
       119 
167 
     | 
    
         
             
            export default class Controller extends AbstractController {
         
     | 
| 
       120 
168 
     | 
    
         | 
| 
      
 169 
     | 
    
         
            +
              private api: any;
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
              protected async start(): Promise<void> {
         
     | 
| 
      
 172 
     | 
    
         
            +
                const config = this.config;
         
     | 
| 
      
 173 
     | 
    
         
            +
                
         
     | 
| 
      
 174 
     | 
    
         
            +
                this.api = this.getClient({
         
     | 
| 
      
 175 
     | 
    
         
            +
                  baseUrl: 'https://api.example.com',
         
     | 
| 
      
 176 
     | 
    
         
            +
                  customize(request) {
         
     | 
| 
      
 177 
     | 
    
         
            +
                    request.headers ||= {};
         
     | 
| 
      
 178 
     | 
    
         
            +
                    // Add authentication headers based on your API requirements
         
     | 
| 
      
 179 
     | 
    
         
            +
                    // Example: request.headers["Authorization"] = `Bearer ${config.apiToken}`;
         
     | 
| 
      
 180 
     | 
    
         
            +
                  },
         
     | 
| 
      
 181 
     | 
    
         
            +
                });
         
     | 
| 
      
 182 
     | 
    
         
            +
              }
         
     | 
| 
      
 183 
     | 
    
         
            +
             
     | 
| 
       121 
184 
     | 
    
         
             
              /**
         
     | 
| 
       122 
185 
     | 
    
         
             
               * List all users
         
     | 
| 
       123 
186 
     | 
    
         
             
               *
         
     | 
| 
       124 
     | 
    
         
            -
               * @param  
     | 
| 
       125 
     | 
    
         
            -
               * @param  
     | 
| 
       126 
     | 
    
         
            -
               * 
     | 
| 
      
 187 
     | 
    
         
            +
               * @param {Object} options - Request options
         
     | 
| 
      
 188 
     | 
    
         
            +
               * @param {number} options.page (optional) - Page number for pagination [query]
         
     | 
| 
      
 189 
     | 
    
         
            +
               *
         
     | 
| 
      
 190 
     | 
    
         
            +
               * @returns {Promise<UserList>} GET /users response
         
     | 
| 
      
 191 
     | 
    
         
            +
               *
         
     | 
| 
      
 192 
     | 
    
         
            +
               * response fields:
         
     | 
| 
      
 193 
     | 
    
         
            +
               * - users: User[] - Array of user objects
         
     | 
| 
      
 194 
     | 
    
         
            +
               * - total: number - Total number of users
         
     | 
| 
      
 195 
     | 
    
         
            +
               * - hasMore: boolean - Whether there are more users available
         
     | 
| 
       127 
196 
     | 
    
         
             
               */
         
     | 
| 
       128 
     | 
    
         
            -
              async listUsers( 
     | 
| 
       129 
     | 
    
         
            -
                 
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
      
 197 
     | 
    
         
            +
              async listUsers(options?: {page?: number}) {
         
     | 
| 
      
 198 
     | 
    
         
            +
                options = options || {};
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
                const url = '/users';
         
     | 
| 
      
 201 
     | 
    
         
            +
             
     | 
| 
      
 202 
     | 
    
         
            +
                const fetchOptions: any = {
         
     | 
| 
      
 203 
     | 
    
         
            +
                  method: 'GET',
         
     | 
| 
      
 204 
     | 
    
         
            +
                  params: {},
         
     | 
| 
      
 205 
     | 
    
         
            +
                  headers: options.headers,
         
     | 
| 
      
 206 
     | 
    
         
            +
                };
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
      
 208 
     | 
    
         
            +
                // Add query parameters
         
     | 
| 
      
 209 
     | 
    
         
            +
                if (options.page !== undefined) {
         
     | 
| 
      
 210 
     | 
    
         
            +
                  fetchOptions.params.page = options.page;
         
     | 
| 
      
 211 
     | 
    
         
            +
                }
         
     | 
| 
      
 212 
     | 
    
         
            +
             
     | 
| 
      
 213 
     | 
    
         
            +
                return this.api.fetch(url, fetchOptions);
         
     | 
| 
       131 
214 
     | 
    
         
             
              }
         
     | 
| 
       132 
215 
     | 
    
         | 
| 
       133 
216 
     | 
    
         
             
              /**
         
     | 
| 
       134 
217 
     | 
    
         
             
               * Create user
         
     | 
| 
       135 
218 
     | 
    
         
             
               *
         
     | 
| 
       136 
     | 
    
         
            -
               * @param  
     | 
| 
       137 
     | 
    
         
            -
               * @ 
     | 
| 
      
 219 
     | 
    
         
            +
               * @param {Object} options - Request options
         
     | 
| 
      
 220 
     | 
    
         
            +
               * @param {string} options.name (required) - User's full name [body property]
         
     | 
| 
      
 221 
     | 
    
         
            +
               * @param {string} options.email (optional) - User's email address [body property]
         
     | 
| 
      
 222 
     | 
    
         
            +
               *
         
     | 
| 
      
 223 
     | 
    
         
            +
               * @returns {Promise<User>} POST /users response
         
     | 
| 
       138 
224 
     | 
    
         
             
               */
         
     | 
| 
       139 
     | 
    
         
            -
              async createUser( 
     | 
| 
       140 
     | 
    
         
            -
                 
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
      
 225 
     | 
    
         
            +
              async createUser(options: {name: string, email?: string}) {
         
     | 
| 
      
 226 
     | 
    
         
            +
                options = options || {};
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                const url = '/users';
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                const { headers, ...bodyData } = options;
         
     | 
| 
      
 231 
     | 
    
         
            +
                const requestBody = Object.keys(bodyData).length > 0 ? bodyData : undefined;
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                const fetchOptions: any = {
         
     | 
| 
      
 234 
     | 
    
         
            +
                  method: 'POST',
         
     | 
| 
      
 235 
     | 
    
         
            +
                  body: requestBody,
         
     | 
| 
      
 236 
     | 
    
         
            +
                  headers: options.headers,
         
     | 
| 
      
 237 
     | 
    
         
            +
                };
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                return this.api.fetch(url, fetchOptions);
         
     | 
| 
       142 
240 
     | 
    
         
             
              }
         
     | 
| 
       143 
241 
     | 
    
         
             
            }
         
     | 
| 
       144 
242 
     | 
    
         
             
            ```
         
     | 
| 
         @@ -180,17 +278,49 @@ The script provides clear error messages for: 
     | 
|
| 
       180 
278 
     | 
    
         | 
| 
       181 
279 
     | 
    
         
             
            ## Testing
         
     | 
| 
       182 
280 
     | 
    
         | 
| 
       183 
     | 
    
         
            -
             
     | 
| 
      
 281 
     | 
    
         
            +
            ### Comprehensive Scenario Tests
         
     | 
| 
      
 282 
     | 
    
         
            +
             
     | 
| 
      
 283 
     | 
    
         
            +
            The SDK includes comprehensive scenario tests that verify the complete code generation pipeline:
         
     | 
| 
       184 
284 
     | 
    
         | 
| 
       185 
285 
     | 
    
         
             
            ```bash
         
     | 
| 
       186 
     | 
    
         
            -
             
     | 
| 
      
 286 
     | 
    
         
            +
            # Run all scenario tests with fixtures
         
     | 
| 
      
 287 
     | 
    
         
            +
            npm run test:scenarios
         
     | 
| 
      
 288 
     | 
    
         
            +
             
     | 
| 
      
 289 
     | 
    
         
            +
            # Run all tests (including unit tests)
         
     | 
| 
      
 290 
     | 
    
         
            +
            npm run test:all
         
     | 
| 
       187 
291 
     | 
    
         
             
            ```
         
     | 
| 
       188 
292 
     | 
    
         | 
| 
       189 
     | 
    
         
            -
             
     | 
| 
      
 293 
     | 
    
         
            +
            ### Test Coverage
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
            The scenario tests verify:
         
     | 
| 
      
 296 
     | 
    
         
            +
            - ✅ **Complete code generation** from OpenAPI specs to connector code
         
     | 
| 
      
 297 
     | 
    
         
            +
            - ✅ **TypeScript interface generation** with proper schema sanitization
         
     | 
| 
      
 298 
     | 
    
         
            +
            - ✅ **Clean parameter handling** (no unnecessary options for simple methods)
         
     | 
| 
      
 299 
     | 
    
         
            +
            - ✅ **Multi-resource architecture** with resource binding and exposure
         
     | 
| 
      
 300 
     | 
    
         
            +
            - ✅ **Schema name sanitization** (e.g., `Complex.Name.With.Dots` → `Complex_Name_With_Dots`)
         
     | 
| 
      
 301 
     | 
    
         
            +
            - ✅ **Path parameter separation** from options object
         
     | 
| 
      
 302 
     | 
    
         
            +
            - ✅ **JSDoc generation** with detailed parameter documentation
         
     | 
| 
      
 303 
     | 
    
         
            +
            - ✅ **Regression protection** against common code generation issues
         
     | 
| 
      
 304 
     | 
    
         
            +
             
     | 
| 
      
 305 
     | 
    
         
            +
            ### Test Scenarios
         
     | 
| 
      
 306 
     | 
    
         
            +
            - **Simple Scenario**: Basic single-controller generation using `examples/simple-api.json`
         
     | 
| 
      
 307 
     | 
    
         
            +
            - **Complex Scenario**: Multi-resource generation with Products + Orders APIs
         
     | 
| 
      
 308 
     | 
    
         
            +
            - **Regression Tests**: Edge cases, schema sanitization, and clean code generation
         
     | 
| 
      
 309 
     | 
    
         
            +
             
     | 
| 
      
 310 
     | 
    
         
            +
            All tests compare generated output against fixtures to ensure deterministic, high-quality code generation.
         
     | 
| 
      
 311 
     | 
    
         
            +
             
     | 
| 
      
 312 
     | 
    
         
            +
            ### Manual Testing
         
     | 
| 
       190 
313 
     | 
    
         | 
| 
       191 
314 
     | 
    
         
             
            ```bash
         
     | 
| 
       192 
315 
     | 
    
         
             
            # Test with sample API
         
     | 
| 
       193 
316 
     | 
    
         
             
            node ./build/openapi-to-connector.mjs generate --name "Sample API" --spec ./examples/sample-api.yaml --out ./test-output.mts
         
     | 
| 
      
 317 
     | 
    
         
            +
             
     | 
| 
      
 318 
     | 
    
         
            +
            # Test controller-only mode
         
     | 
| 
      
 319 
     | 
    
         
            +
            node build/cli.mjs from-openapi test-connector \
         
     | 
| 
      
 320 
     | 
    
         
            +
              --connector-id "test" \
         
     | 
| 
      
 321 
     | 
    
         
            +
              --spec "examples/simple-api.json" \
         
     | 
| 
      
 322 
     | 
    
         
            +
              --controller-only \
         
     | 
| 
      
 323 
     | 
    
         
            +
              --out "./test-controller.mts"
         
     | 
| 
       194 
324 
     | 
    
         
             
            ```
         
     | 
| 
       195 
325 
     | 
    
         | 
| 
       196 
326 
     | 
    
         
             
            ## Requirements Met
         
     | 
    
        package/README.md
    CHANGED
    
    | 
         @@ -1,8 +1,19 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # nodejs - Aloma Integration SDK
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            A powerful toolkit for generating production-ready Aloma connectors from OpenAPI specifications with advanced features like multi-resource architecture, TypeScript type generation, and comprehensive testing.
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            ## ✨ Key Features
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            - 🎯 **Deterministic Code Generation** - Same input always produces the same output
         
     | 
| 
      
 8 
     | 
    
         
            +
            - 🔧 **Multi-Resource Architecture** - Organize large APIs into logical resource groups
         
     | 
| 
      
 9 
     | 
    
         
            +
            - 📘 **TypeScript First** - Full TypeScript support with proper interface generation
         
     | 
| 
      
 10 
     | 
    
         
            +
            - 🧪 **Comprehensive Testing** - Built-in scenario tests with fixtures
         
     | 
| 
      
 11 
     | 
    
         
            +
            - 🔍 **Schema Sanitization** - Converts invalid TypeScript names to valid identifiers
         
     | 
| 
      
 12 
     | 
    
         
            +
            - 📝 **Rich Documentation** - Detailed JSDoc generation from OpenAPI descriptions
         
     | 
| 
      
 13 
     | 
    
         
            +
            - 🎨 **Clean Code Generation** - No unnecessary parameters or boilerplate
         
     | 
| 
      
 14 
     | 
    
         
            +
            - 📦 **Controller-Only Mode** - Generate just the controller for existing projects
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            ## 🚀 Quick Start
         
     | 
| 
       6 
17 
     | 
    
         | 
| 
       7 
18 
     | 
    
         
             
            ### 1. Create from scratch
         
     | 
| 
       8 
19 
     | 
    
         
             
            ```bash
         
     | 
| 
         @@ -11,12 +22,25 @@ npx @aloma.io/integration-sdk@latest create connectorName --connector-id 1234 
     | 
|
| 
       11 
22 
     | 
    
         | 
| 
       12 
23 
     | 
    
         
             
            ### 2. Generate from OpenAPI specification
         
     | 
| 
       13 
24 
     | 
    
         
             
            ```bash
         
     | 
| 
       14 
     | 
    
         
            -
            npx @aloma.io/integration-sdk@latest from-openapi connectorName --connector-id 1234 --spec api.yaml
         
     | 
| 
      
 25 
     | 
    
         
            +
            npx @aloma.io/integration-sdk@latest from-openapi connectorName --connector-id 1234 --spec api.yaml --no-build
         
     | 
| 
       15 
26 
     | 
    
         
             
            ```
         
     | 
| 
       16 
27 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            This will automatically generate a complete connector project with 
     | 
| 
      
 28 
     | 
    
         
            +
            This will automatically generate a complete connector project with:
         
     | 
| 
      
 29 
     | 
    
         
            +
            - Methods for all OpenAPI endpoints
         
     | 
| 
      
 30 
     | 
    
         
            +
            - Proper TypeScript interfaces from schemas
         
     | 
| 
      
 31 
     | 
    
         
            +
            - Clean parameter handling (no unnecessary options)
         
     | 
| 
      
 32 
     | 
    
         
            +
            - Rich JSDoc documentation
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
            ### 3. Controller-Only Generation (New!)
         
     | 
| 
      
 35 
     | 
    
         
            +
            ```bash
         
     | 
| 
      
 36 
     | 
    
         
            +
            # Generate just the controller file for existing projects
         
     | 
| 
      
 37 
     | 
    
         
            +
            npx @aloma.io/integration-sdk@latest from-openapi connectorName \
         
     | 
| 
      
 38 
     | 
    
         
            +
              --connector-id 1234 \
         
     | 
| 
      
 39 
     | 
    
         
            +
              --spec api.yaml \
         
     | 
| 
      
 40 
     | 
    
         
            +
              --controller-only \
         
     | 
| 
      
 41 
     | 
    
         
            +
              --out "./src/controller/index.mts"
         
     | 
| 
      
 42 
     | 
    
         
            +
            ```
         
     | 
| 
       18 
43 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
            ### 3. Generate with Resource Architecture (Recommended for large APIs)
         
     | 
| 
       20 
44 
     | 
    
         
             
            ```bash
         
     | 
| 
       21 
45 
     | 
    
         
             
            npx @aloma.io/integration-sdk@latest from-openapi connectorName \
         
     | 
| 
       22 
46 
     | 
    
         
             
              --connector-id 1234 \
         
     | 
| 
         @@ -26,12 +50,13 @@ npx @aloma.io/integration-sdk@latest from-openapi connectorName \ 
     | 
|
| 
       26 
50 
     | 
    
         
             
              --no-build
         
     | 
| 
       27 
51 
     | 
    
         
             
            ```
         
     | 
| 
       28 
52 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
            ###  
     | 
| 
      
 53 
     | 
    
         
            +
            ### 5. Create Multi-Resource Connector (Recommended for complex APIs)
         
     | 
| 
       30 
54 
     | 
    
         
             
            ```bash
         
     | 
| 
       31 
55 
     | 
    
         
             
            npx @aloma.io/integration-sdk@latest create-multi-resource "HubSpot-v2" \
         
     | 
| 
       32 
56 
     | 
    
         
             
              --connector-id "hubspot-123" \
         
     | 
| 
       33 
57 
     | 
    
         
             
              --resources "CompaniesResource:examples/hubspot-companies.json,ContactsResource:examples/hubspot-contacts.json,ListsResource:examples/hubspot-lists.json" \
         
     | 
| 
       34 
     | 
    
         
            -
              --base-url "https://api.hubapi.com"
         
     | 
| 
      
 58 
     | 
    
         
            +
              --base-url "https://api.hubapi.com" \
         
     | 
| 
      
 59 
     | 
    
         
            +
              --no-build
         
     | 
| 
       35 
60 
     | 
    
         
             
            ```
         
     | 
| 
       36 
61 
     | 
    
         | 
| 
       37 
62 
     | 
    
         
             
            This creates a complete multi-resource connector with:
         
     | 
| 
         @@ -46,15 +71,41 @@ await controller.contacts.getPage({ limit: 10 }); 
     | 
|
| 
       46 
71 
     | 
    
         
             
            await controller.lists.getAll({ limit: 50 });
         
     | 
| 
       47 
72 
     | 
    
         
             
            ```
         
     | 
| 
       48 
73 
     | 
    
         | 
| 
       49 
     | 
    
         
            -
            ###  
     | 
| 
      
 74 
     | 
    
         
            +
            ### 6. Add Resource to Existing Project
         
     | 
| 
       50 
75 
     | 
    
         
             
            ```bash
         
     | 
| 
       51 
76 
     | 
    
         
             
            npx @aloma.io/integration-sdk@latest add-resource ./existing-project \
         
     | 
| 
       52 
77 
     | 
    
         
             
              --className "DealsResource" \
         
     | 
| 
       53 
     | 
    
         
            -
              --spec "deals.json"
         
     | 
| 
      
 78 
     | 
    
         
            +
              --spec "deals.json" \
         
     | 
| 
      
 79 
     | 
    
         
            +
              --no-build
         
     | 
| 
       54 
80 
     | 
    
         
             
            ```
         
     | 
| 
       55 
81 
     | 
    
         | 
| 
       56 
82 
     | 
    
         
             
            This adds a new resource to an existing multi-resource connector.
         
     | 
| 
       57 
83 
     | 
    
         | 
| 
      
 84 
     | 
    
         
            +
            ## 🧪 Testing & Quality
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            ### Run Scenario Tests
         
     | 
| 
      
 87 
     | 
    
         
            +
            ```bash
         
     | 
| 
      
 88 
     | 
    
         
            +
            # Run comprehensive scenario tests with fixtures
         
     | 
| 
      
 89 
     | 
    
         
            +
            npm run test:scenarios
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
            # Run all tests
         
     | 
| 
      
 92 
     | 
    
         
            +
            npm run test:all
         
     | 
| 
      
 93 
     | 
    
         
            +
            ```
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
            The SDK includes comprehensive scenario tests that verify:
         
     | 
| 
      
 96 
     | 
    
         
            +
            - ✅ **Complete code generation pipeline** from OpenAPI specs to connector code
         
     | 
| 
      
 97 
     | 
    
         
            +
            - ✅ **TypeScript interface generation** with schema sanitization
         
     | 
| 
      
 98 
     | 
    
         
            +
            - ✅ **Clean parameter handling** (no unnecessary options for simple methods)
         
     | 
| 
      
 99 
     | 
    
         
            +
            - ✅ **Multi-resource architecture** with proper resource binding
         
     | 
| 
      
 100 
     | 
    
         
            +
            - ✅ **Regression protection** against common code generation issues
         
     | 
| 
      
 101 
     | 
    
         
            +
             
     | 
| 
      
 102 
     | 
    
         
            +
            ### Test Scenarios
         
     | 
| 
      
 103 
     | 
    
         
            +
            - **Simple Scenario**: Basic single-controller generation
         
     | 
| 
      
 104 
     | 
    
         
            +
            - **Complex Scenario**: Multi-resource generation with Products + Orders APIs
         
     | 
| 
      
 105 
     | 
    
         
            +
            - **Regression Tests**: Edge cases and schema sanitization
         
     | 
| 
      
 106 
     | 
    
         
            +
             
     | 
| 
      
 107 
     | 
    
         
            +
            All tests use real OpenAPI specifications and compare generated output against fixtures to ensure deterministic, high-quality code generation.
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
       58 
109 
     | 
    
         
             
            ## 📚 Documentation
         
     | 
| 
       59 
110 
     | 
    
         | 
| 
       60 
111 
     | 
    
         
             
            - **[OPENAPI_TO_CONNECTOR.md](./OPENAPI_TO_CONNECTOR.md)** - OpenAPI generator details
         
     | 
| 
         @@ -67,6 +118,7 @@ This adds a new resource to an existing multi-resource connector. 
     | 
|
| 
       67 
118 
     | 
    
         
             
            # Create complete HubSpot connector with 3 resources
         
     | 
| 
       68 
119 
     | 
    
         
             
            npx @aloma.io/integration-sdk@latest create-multi-resource "HubSpot-v2" \
         
     | 
| 
       69 
120 
     | 
    
         
             
              --connector-id "hubspot-123" \
         
     | 
| 
       70 
     | 
    
         
            -
              --resources "CompaniesResource:examples/hubspot-companies.json,ContactsResource:examples/hubspot-contacts.json,ListsResource:examples/hubspot-lists.json"
         
     | 
| 
      
 121 
     | 
    
         
            +
              --resources "CompaniesResource:examples/hubspot-companies.json,ContactsResource:examples/hubspot-contacts.json,ListsResource:examples/hubspot-lists.json" \
         
     | 
| 
      
 122 
     | 
    
         
            +
              --no-build
         
     | 
| 
       71 
123 
     | 
    
         | 
| 
       72 
124 
     | 
    
         
             
            ```
         
     |