nestjs-to-collection 1.0.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +334 -0
  3. package/dist/cli/index.d.ts +3 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +234 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/generators/index.d.ts +3 -0
  8. package/dist/generators/index.d.ts.map +1 -0
  9. package/dist/generators/index.js +8 -0
  10. package/dist/generators/index.js.map +1 -0
  11. package/dist/generators/insomnia.generator.d.ts +24 -0
  12. package/dist/generators/insomnia.generator.d.ts.map +1 -0
  13. package/dist/generators/insomnia.generator.js +276 -0
  14. package/dist/generators/insomnia.generator.js.map +1 -0
  15. package/dist/generators/postman.generator.d.ts +22 -0
  16. package/dist/generators/postman.generator.d.ts.map +1 -0
  17. package/dist/generators/postman.generator.js +299 -0
  18. package/dist/generators/postman.generator.js.map +1 -0
  19. package/dist/index.d.ts +6 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +30 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/parsers/decorator.parser.d.ts +20 -0
  24. package/dist/parsers/decorator.parser.d.ts.map +1 -0
  25. package/dist/parsers/decorator.parser.js +396 -0
  26. package/dist/parsers/decorator.parser.js.map +1 -0
  27. package/dist/parsers/index.d.ts +3 -0
  28. package/dist/parsers/index.d.ts.map +1 -0
  29. package/dist/parsers/index.js +8 -0
  30. package/dist/parsers/index.js.map +1 -0
  31. package/dist/parsers/swagger.parser.d.ts +25 -0
  32. package/dist/parsers/swagger.parser.d.ts.map +1 -0
  33. package/dist/parsers/swagger.parser.js +237 -0
  34. package/dist/parsers/swagger.parser.js.map +1 -0
  35. package/dist/types/index.d.ts +187 -0
  36. package/dist/types/index.d.ts.map +1 -0
  37. package/dist/types/index.js +3 -0
  38. package/dist/types/index.js.map +1 -0
  39. package/package.json +73 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,334 @@
1
+ # nestjs-to-collection
2
+
3
+ šŸš€ Transform NestJS endpoints into Postman and Insomnia collections via CLI.
4
+
5
+ [![npm version](https://badge.fury.io/js/nestjs-to-collection.svg)](https://www.npmjs.com/package/nestjs-to-collection)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ## Features
9
+
10
+ - šŸ“„ **Swagger/OpenAPI Support**: Generate collections from your existing Swagger specification
11
+ - šŸ” **Decorator Scanning**: Automatically extract endpoints from NestJS decorators
12
+ - šŸ“® **Postman Export**: Generate Postman Collection v2.1 format
13
+ - šŸ¦‹ **Insomnia Export**: Generate Insomnia Collection v4 format
14
+ - šŸŽÆ **Interactive CLI**: User-friendly prompts for easy configuration
15
+ - ⚔ **Programmatic API**: Use as a library in your code
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ # Global installation (recommended for CLI usage)
21
+ npm install -g nestjs-to-collection
22
+
23
+ # Local installation (for programmatic usage)
24
+ npm install nestjs-to-collection
25
+ ```
26
+
27
+ ## Requirements
28
+
29
+ - Node.js >= 20.0.0
30
+ - NestJS >= 10.0.0 (peer dependency)
31
+ - @nestjs/swagger >= 7.0.0 (optional, for Swagger support)
32
+
33
+ ## CLI Usage
34
+
35
+ ### Interactive Mode
36
+
37
+ The easiest way to use the tool is through interactive mode:
38
+
39
+ ```bash
40
+ nest-to-collection generate -i
41
+ # or using the short alias
42
+ ntc generate -i
43
+ ```
44
+
45
+ This will guide you through the following options:
46
+
47
+ 1. Source type (Swagger or Decorators)
48
+ 2. Path to swagger.json or source folder
49
+ 3. Output format (Postman or Insomnia)
50
+ 4. Collection name
51
+ 5. Base URL
52
+ 6. Output file path
53
+
54
+ ### Command Line Options
55
+
56
+ ```bash
57
+ nest-to-collection generate [options]
58
+
59
+ Options:
60
+ -s, --source <type> Source type: swagger or decorators (default: "swagger")
61
+ -o, --output <format> Output format: postman or insomnia (default: "postman")
62
+ -p, --swagger-path <path> Path to swagger.json file
63
+ -d, --src-path <path> Path to NestJS src folder (default: "./src")
64
+ -out, --output-path <path> Output file path (default: "./collection")
65
+ -b, --base-url <url> Base URL for API (default: "{{baseUrl}}")
66
+ -n, --name <name> Collection name
67
+ -i, --interactive Run in interactive mode
68
+ ```
69
+
70
+ ### Examples
71
+
72
+ #### Generate from Swagger (Postman)
73
+
74
+ ```bash
75
+ ntc generate -s swagger -p ./swagger.json -o postman -n "My API" -out ./my-api
76
+ ```
77
+
78
+ #### Generate from Swagger (Insomnia)
79
+
80
+ ```bash
81
+ ntc generate -s swagger -p ./swagger.json -o insomnia -n "My API" -out ./my-api
82
+ ```
83
+
84
+ #### Generate from Decorators (Postman)
85
+
86
+ ```bash
87
+ ntc generate -s decorators -d ./src -o postman -n "My API" -out ./my-api
88
+ ```
89
+
90
+ #### Generate from Decorators (Insomnia)
91
+
92
+ ```bash
93
+ ntc generate -s decorators -d ./src -o insomnia -n "My API" -out ./my-api
94
+ ```
95
+
96
+ ### Save Configuration
97
+
98
+ You can save your configuration for future use:
99
+
100
+ ```bash
101
+ ntc init
102
+ ```
103
+
104
+ This creates a `nest-to-collection.config.json` file in your project root.
105
+
106
+ ## Programmatic Usage
107
+
108
+ ### Using with Swagger
109
+
110
+ ```typescript
111
+ import { SwaggerParser, PostmanGenerator, InsomniaGenerator } from 'nestjs-to-collection';
112
+
113
+ // Parse Swagger file
114
+ const parser = new SwaggerParser();
115
+ const collection = await parser.parse('./swagger.json');
116
+
117
+ // Generate Postman collection
118
+ const postmanGenerator = new PostmanGenerator();
119
+ const postmanJson = postmanGenerator.generate(collection);
120
+
121
+ // Generate Insomnia collection
122
+ const insomniaGenerator = new InsomniaGenerator();
123
+ const insomniaJson = insomniaGenerator.generate(collection);
124
+
125
+ // Save to files
126
+ fs.writeFileSync('collection.postman_collection.json', postmanJson);
127
+ fs.writeFileSync('collection.insomnia_collection.json', insomniaJson);
128
+ ```
129
+
130
+ ### Using with NestJS Decorators
131
+
132
+ ```typescript
133
+ import { DecoratorParser, PostmanGenerator } from 'nestjs-to-collection';
134
+
135
+ // Parse NestJS source files
136
+ const parser = new DecoratorParser();
137
+ const collection = await parser.parse('./src');
138
+
139
+ // Customize collection
140
+ collection.name = 'My Custom API';
141
+ collection.baseUrl = 'https://api.example.com';
142
+
143
+ // Generate Postman collection
144
+ const generator = new PostmanGenerator();
145
+ const json = generator.generate(collection);
146
+ ```
147
+
148
+ ### Parse from Swagger URL
149
+
150
+ ```typescript
151
+ import { SwaggerParser, PostmanGenerator } from 'nestjs-to-collection';
152
+
153
+ const parser = new SwaggerParser();
154
+ const collection = await parser.parseFromUrl('https://api.example.com/swagger.json');
155
+
156
+ const generator = new PostmanGenerator();
157
+ const json = generator.generate(collection);
158
+ ```
159
+
160
+ ## Supported NestJS Decorators
161
+
162
+ The decorator parser supports the following NestJS decorators:
163
+
164
+ ### HTTP Method Decorators
165
+
166
+ - `@Get()`
167
+ - `@Post()`
168
+ - `@Put()`
169
+ - `@Patch()`
170
+ - `@Delete()`
171
+ - `@Options()`
172
+ - `@Head()`
173
+
174
+ ### Parameter Decorators
175
+
176
+ - `@Param()`
177
+ - `@Query()`
178
+ - `@Body()`
179
+ - `@Headers()`
180
+
181
+ ### Swagger Decorators (from @nestjs/swagger)
182
+
183
+ - `@ApiTags()`
184
+ - `@ApiOperation()`
185
+ - `@ApiParam()`
186
+ - `@ApiQuery()`
187
+ - `@ApiBody()`
188
+ - `@ApiResponse()`
189
+
190
+ ## Output Formats
191
+
192
+ ### Postman Collection v2.1
193
+
194
+ The generated Postman collection includes:
195
+
196
+ - Organized folder structure based on controllers/tags
197
+ - Request body examples
198
+ - Query parameters
199
+ - Path parameters
200
+ - Headers
201
+ - Collection variables (baseUrl)
202
+ - Response examples
203
+
204
+ ### Insomnia Collection v4
205
+
206
+ The generated Insomnia collection includes:
207
+
208
+ - Workspace with organized request groups
209
+ - Environment variables
210
+ - Request body with proper MIME types
211
+ - Query parameters
212
+ - Path parameters (Insomnia format)
213
+ - Headers
214
+
215
+ ## Generating Swagger from NestJS
216
+
217
+ If you don't have a swagger.json file yet, you can generate one from your NestJS application:
218
+
219
+ ### 1. Install @nestjs/swagger
220
+
221
+ ```bash
222
+ npm install @nestjs/swagger
223
+ ```
224
+
225
+ ### 2. Configure Swagger in main.ts
226
+
227
+ ```typescript
228
+ import { NestFactory } from '@nestjs/core';
229
+ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
230
+ import { AppModule } from './app.module';
231
+ import * as fs from 'fs';
232
+
233
+ async function bootstrap() {
234
+ const app = await NestFactory.create(AppModule);
235
+
236
+ const config = new DocumentBuilder()
237
+ .setTitle('My API')
238
+ .setDescription('API description')
239
+ .setVersion('1.0')
240
+ .addBearerAuth()
241
+ .build();
242
+
243
+ const document = SwaggerModule.createDocument(app, config);
244
+
245
+ // Save swagger.json to file
246
+ fs.writeFileSync('./swagger.json', JSON.stringify(document, null, 2));
247
+
248
+ SwaggerModule.setup('api', app, document);
249
+
250
+ await app.listen(3000);
251
+ }
252
+ bootstrap();
253
+ ```
254
+
255
+ ### 3. Run your application
256
+
257
+ ```bash
258
+ npm run start
259
+ ```
260
+
261
+ This will generate a `swagger.json` file that you can use with this tool.
262
+
263
+ ## API Reference
264
+
265
+ ### Types
266
+
267
+ ```typescript
268
+ interface ApiCollection {
269
+ name: string;
270
+ description?: string;
271
+ version?: string;
272
+ baseUrl?: string;
273
+ groups: ApiGroup[];
274
+ variables?: CollectionVariable[];
275
+ }
276
+
277
+ interface ApiGroup {
278
+ name: string;
279
+ description?: string;
280
+ endpoints: ApiEndpoint[];
281
+ }
282
+
283
+ interface ApiEndpoint {
284
+ path: string;
285
+ method: HttpMethod;
286
+ summary?: string;
287
+ description?: string;
288
+ operationId?: string;
289
+ tags?: string[];
290
+ parameters?: ApiParameter[];
291
+ requestBody?: ApiRequestBody;
292
+ responses?: Record<string, ApiResponse>;
293
+ }
294
+ ```
295
+
296
+ ### Classes
297
+
298
+ #### SwaggerParser
299
+
300
+ - `parse(filePath: string): Promise<ApiCollection>` - Parse from file
301
+ - `parseFromUrl(url: string): Promise<ApiCollection>` - Parse from URL
302
+ - `parseFromObject(swagger: SwaggerDocument): ApiCollection` - Parse from object
303
+
304
+ #### DecoratorParser
305
+
306
+ - `parse(srcPath: string): Promise<ApiCollection>` - Parse NestJS source files
307
+
308
+ #### PostmanGenerator
309
+
310
+ - `generate(collection: ApiCollection): string` - Generate Postman JSON
311
+
312
+ #### InsomniaGenerator
313
+
314
+ - `generate(collection: ApiCollection): string` - Generate Insomnia JSON
315
+
316
+ ## Contributing
317
+
318
+ Contributions are welcome! Please feel free to submit a Pull Request.
319
+
320
+ 1. Fork the repository
321
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
322
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
323
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
324
+ 5. Open a Pull Request
325
+
326
+ ## License
327
+
328
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
329
+
330
+ ## Support
331
+
332
+ If you find this package helpful, please consider giving it a ⭐ on GitHub!
333
+
334
+ For bugs and feature requests, please [open an issue](https://github.com/your-username/nestjs-to-collection/issues).
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,234 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const commander_1 = require("commander");
41
+ const inquirer_1 = __importDefault(require("inquirer"));
42
+ const chalk_1 = __importDefault(require("chalk"));
43
+ const ora_1 = __importDefault(require("ora"));
44
+ const fs = __importStar(require("fs"));
45
+ const path = __importStar(require("path"));
46
+ const swagger_parser_1 = require("../parsers/swagger.parser");
47
+ const decorator_parser_1 = require("../parsers/decorator.parser");
48
+ const postman_generator_1 = require("../generators/postman.generator");
49
+ const insomnia_generator_1 = require("../generators/insomnia.generator");
50
+ const program = new commander_1.Command();
51
+ program
52
+ .name('nest-to-collection')
53
+ .description('Transform NestJS endpoints into Postman and Insomnia collections')
54
+ .version('1.0.0');
55
+ program
56
+ .command('generate')
57
+ .alias('g')
58
+ .description('Generate API collection from NestJS project')
59
+ .option('-s, --source <type>', 'Source type: swagger or decorators', 'swagger')
60
+ .option('-o, --output <format>', 'Output format: postman or insomnia', 'postman')
61
+ .option('-p, --swagger-path <path>', 'Path to swagger.json file')
62
+ .option('-d, --src-path <path>', 'Path to NestJS src folder', './src')
63
+ .option('-out, --output-path <path>', 'Output file path', './collection')
64
+ .option('-b, --base-url <url>', 'Base URL for API', '{{baseUrl}}')
65
+ .option('-n, --name <name>', 'Collection name')
66
+ .option('-i, --interactive', 'Run in interactive mode')
67
+ .action(async (options) => {
68
+ try {
69
+ let cliOptions;
70
+ if (options.interactive) {
71
+ cliOptions = await runInteractiveMode();
72
+ }
73
+ else {
74
+ cliOptions = {
75
+ source: options.source,
76
+ output: options.output,
77
+ swaggerPath: options.swaggerPath,
78
+ srcPath: options.srcPath,
79
+ outputPath: options.outputPath,
80
+ baseUrl: options.baseUrl,
81
+ collectionName: options.name,
82
+ };
83
+ }
84
+ await generateCollection(cliOptions);
85
+ }
86
+ catch (error) {
87
+ console.error(chalk_1.default.red('Error:'), error instanceof Error ? error.message : error);
88
+ process.exit(1);
89
+ }
90
+ });
91
+ program
92
+ .command('init')
93
+ .description('Initialize configuration file')
94
+ .action(async () => {
95
+ const config = await runInteractiveMode();
96
+ const configPath = path.join(process.cwd(), 'nest-to-collection.config.json');
97
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
98
+ console.log(chalk_1.default.green('āœ“'), `Configuration saved to ${configPath}`);
99
+ });
100
+ async function runInteractiveMode() {
101
+ console.log(chalk_1.default.cyan('\nšŸš€ NestJS to Collection Generator\n'));
102
+ const answers = await inquirer_1.default.prompt([
103
+ {
104
+ type: 'list',
105
+ name: 'source',
106
+ message: 'How would you like to extract endpoints?',
107
+ choices: [
108
+ { name: 'šŸ“„ From Swagger/OpenAPI specification', value: 'swagger' },
109
+ { name: 'šŸ” From NestJS decorators (scan source code)', value: 'decorators' },
110
+ ],
111
+ },
112
+ {
113
+ type: 'input',
114
+ name: 'swaggerPath',
115
+ message: 'Enter the path to your swagger.json file:',
116
+ default: './swagger.json',
117
+ when: (answers) => answers.source === 'swagger',
118
+ validate: (input) => {
119
+ if (!input)
120
+ return 'Please enter a valid path';
121
+ return true;
122
+ },
123
+ },
124
+ {
125
+ type: 'input',
126
+ name: 'srcPath',
127
+ message: 'Enter the path to your NestJS src folder:',
128
+ default: './src',
129
+ when: (answers) => answers.source === 'decorators',
130
+ },
131
+ {
132
+ type: 'list',
133
+ name: 'output',
134
+ message: 'Select the output format:',
135
+ choices: [
136
+ { name: 'šŸ“® Postman Collection (v2.1)', value: 'postman' },
137
+ { name: 'šŸ¦‹ Insomnia Collection (v4)', value: 'insomnia' },
138
+ ],
139
+ },
140
+ {
141
+ type: 'input',
142
+ name: 'collectionName',
143
+ message: 'Enter the collection name:',
144
+ default: 'My API Collection',
145
+ },
146
+ {
147
+ type: 'input',
148
+ name: 'baseUrl',
149
+ message: 'Enter the base URL (use {{variable}} for variables):',
150
+ default: '{{baseUrl}}',
151
+ },
152
+ {
153
+ type: 'input',
154
+ name: 'outputPath',
155
+ message: 'Enter the output file path (without extension):',
156
+ default: './collection',
157
+ },
158
+ ]);
159
+ return {
160
+ source: answers.source,
161
+ output: answers.output,
162
+ swaggerPath: answers.swaggerPath,
163
+ srcPath: answers.srcPath,
164
+ outputPath: answers.outputPath,
165
+ baseUrl: answers.baseUrl,
166
+ collectionName: answers.collectionName,
167
+ };
168
+ }
169
+ async function generateCollection(options) {
170
+ const spinner = (0, ora_1.default)('Processing...').start();
171
+ try {
172
+ // Parse endpoints
173
+ spinner.text = 'Extracting endpoints...';
174
+ let apiCollection;
175
+ if (options.source === 'swagger') {
176
+ if (!options.swaggerPath) {
177
+ throw new Error('Swagger path is required when using swagger source');
178
+ }
179
+ const parser = new swagger_parser_1.SwaggerParser();
180
+ apiCollection = await parser.parse(options.swaggerPath);
181
+ }
182
+ else {
183
+ if (!options.srcPath) {
184
+ throw new Error('Source path is required when using decorators source');
185
+ }
186
+ const parser = new decorator_parser_1.DecoratorParser();
187
+ apiCollection = await parser.parse(options.srcPath);
188
+ }
189
+ // Apply custom options
190
+ if (options.collectionName) {
191
+ apiCollection.name = options.collectionName;
192
+ }
193
+ if (options.baseUrl) {
194
+ apiCollection.baseUrl = options.baseUrl;
195
+ }
196
+ // Generate collection
197
+ spinner.text = 'Generating collection...';
198
+ let outputContent;
199
+ let fileExtension;
200
+ if (options.output === 'postman') {
201
+ const generator = new postman_generator_1.PostmanGenerator();
202
+ outputContent = generator.generate(apiCollection);
203
+ fileExtension = '.postman_collection.json';
204
+ }
205
+ else {
206
+ const generator = new insomnia_generator_1.InsomniaGenerator();
207
+ outputContent = generator.generate(apiCollection);
208
+ fileExtension = '.insomnia_collection.json';
209
+ }
210
+ // Write output file
211
+ const outputPath = (options.outputPath || './collection') + fileExtension;
212
+ const absolutePath = path.resolve(process.cwd(), outputPath);
213
+ const outputDir = path.dirname(absolutePath);
214
+ if (!fs.existsSync(outputDir)) {
215
+ fs.mkdirSync(outputDir, { recursive: true });
216
+ }
217
+ fs.writeFileSync(absolutePath, outputContent, 'utf-8');
218
+ spinner.succeed(chalk_1.default.green('Collection generated successfully!'));
219
+ console.log(chalk_1.default.cyan('\nšŸ“ Output file:'), absolutePath);
220
+ console.log(chalk_1.default.cyan('šŸ“Š Total groups:'), apiCollection.groups.length);
221
+ const totalEndpoints = apiCollection.groups.reduce((sum, g) => sum + g.endpoints.length, 0);
222
+ console.log(chalk_1.default.cyan('šŸ”— Total endpoints:'), totalEndpoints);
223
+ console.log(chalk_1.default.yellow('\nšŸ’” Tip: Import the generated file into ' +
224
+ (options.output === 'postman' ? 'Postman' : 'Insomnia') +
225
+ ' to start testing your API!\n'));
226
+ }
227
+ catch (error) {
228
+ spinner.fail(chalk_1.default.red('Failed to generate collection'));
229
+ throw error;
230
+ }
231
+ }
232
+ // Run the CLI
233
+ program.parse();
234
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,yCAAoC;AACpC,wDAAgC;AAChC,kDAA0B;AAC1B,8CAAsB;AACtB,uCAAyB;AACzB,2CAA6B;AAG7B,8DAA0D;AAC1D,kEAA8D;AAC9D,uEAAmE;AACnE,yEAAqE;AAErE,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,oBAAoB,CAAC;KAC1B,WAAW,CAAC,kEAAkE,CAAC;KAC/E,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,OAAO;KACJ,OAAO,CAAC,UAAU,CAAC;KACnB,KAAK,CAAC,GAAG,CAAC;KACV,WAAW,CAAC,6CAA6C,CAAC;KAC1D,MAAM,CAAC,qBAAqB,EAAE,oCAAoC,EAAE,SAAS,CAAC;KAC9E,MAAM,CAAC,uBAAuB,EA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AAS,CAAC,CAAC,CAAC,UAAU,CAAC;YACvD,+BAA+B,CAClC,CACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,eAAK,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC,CAAC;QACzD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,cAAc;AACd,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { PostmanGenerator } from './postman.generator';
2
+ export { InsomniaGenerator } from './insomnia.generator';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InsomniaGenerator = exports.PostmanGenerator = void 0;
4
+ var postman_generator_1 = require("./postman.generator");
5
+ Object.defineProperty(exports, "PostmanGenerator", { enumerable: true, get: function () { return postman_generator_1.PostmanGenerator; } });
6
+ var insomnia_generator_1 = require("./insomnia.generator");
7
+ Object.defineProperty(exports, "InsomniaGenerator", { enumerable: true, get: function () { return insomnia_generator_1.InsomniaGenerator; } });
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generators/index.ts"],"names":[],"mappings":";;;AAAA,yDAAuD;AAA9C,qHAAA,gBAAgB,OAAA;AACzB,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,24 @@
1
+ import { ApiCollection } from '../types';
2
+ /**
3
+ * Generator for Insomnia Collection v4 format
4
+ */
5
+ export declare class InsomniaGenerator {
6
+ private baseUrl;
7
+ private workspaceId;
8
+ /**
9
+ * Generate Insomnia collection JSON from ApiCollection
10
+ */
11
+ generate(collection: ApiCollection): string;
12
+ private createEnvironment;
13
+ private convertGroup;
14
+ private convertEndpoint;
15
+ private buildUrl;
16
+ private buildParameters;
17
+ private buildPathParameters;
18
+ private buildHeaders;
19
+ private buildBody;
20
+ private formatInsomniaVariable;
21
+ private generateExampleFromSchema;
22
+ private extractFormFields;
23
+ }
24
+ //# sourceMappingURL=insomnia.generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"insomnia.generator.d.ts","sourceRoot":"","sources":["../../src/generators/insomnia.generator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAqC,MAAM,UAAU,CAAC;AAqH5E;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,WAAW,CAAc;IAEjC;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,aAAa,GAAG,MAAM;IA2C3C,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,YAAY;IAgCpB,OAAO,CAAC,eAAe;IAsCvB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IAkCpB,OAAO,CAAC,SAAS;IAuCjB,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,yBAAyB;IAmDjC,OAAO,CAAC,iBAAiB;CAa1B"}