@flusys/nestjs-core 1.1.0-beta → 1.1.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 (58) hide show
  1. package/README.md +505 -63
  2. package/cjs/config/env-config.service.js +1 -1
  3. package/cjs/docs/docs.config.js +77 -3
  4. package/cjs/docs/index.js +0 -1
  5. package/cjs/interfaces/base-entity.interface.js +5 -3
  6. package/cjs/interfaces/database.interface.js +1 -3
  7. package/cjs/migration/datasource.factory.js +1 -3
  8. package/cjs/migration/index.js +0 -12
  9. package/cjs/migration/migration.cli.js +1 -17
  10. package/cjs/migration/migration.runner.js +37 -65
  11. package/cjs/seeders/base-seeder.js +6 -25
  12. package/cjs/seeders/cli.js +65 -172
  13. package/cjs/seeders/data-generator.js +110 -142
  14. package/cjs/seeders/entity-reader.js +0 -17
  15. package/cjs/seeders/field-patterns.js +176 -0
  16. package/cjs/seeders/index.js +16 -8
  17. package/cjs/seeders/seed-config.js +9 -48
  18. package/cjs/seeders/seed-runner.js +8 -14
  19. package/cjs/utils/datasource-config.builder.js +2 -14
  20. package/docs/docs.config.d.ts +7 -0
  21. package/docs/index.d.ts +0 -1
  22. package/fesm/config/env-config.service.js +1 -1
  23. package/fesm/docs/docs.config.js +68 -0
  24. package/fesm/docs/index.js +0 -1
  25. package/fesm/interfaces/app-config.interfaces.js +1 -3
  26. package/fesm/interfaces/base-entity.interface.js +5 -5
  27. package/fesm/interfaces/database.interface.js +1 -5
  28. package/fesm/migration/cli.js +1 -20
  29. package/fesm/migration/datasource.factory.js +3 -20
  30. package/fesm/migration/index.js +0 -14
  31. package/fesm/migration/migration.cli.js +1 -17
  32. package/fesm/migration/migration.runner.js +43 -132
  33. package/fesm/seeders/base-seeder.js +7 -51
  34. package/fesm/seeders/cli.js +65 -182
  35. package/fesm/seeders/data-generator.js +110 -149
  36. package/fesm/seeders/entity-reader.js +0 -17
  37. package/fesm/seeders/field-patterns.js +147 -0
  38. package/fesm/seeders/index.js +3 -7
  39. package/fesm/seeders/seed-config.js +9 -59
  40. package/fesm/seeders/seed-runner.js +8 -14
  41. package/fesm/utils/datasource-config.builder.js +2 -13
  42. package/interfaces/app-config.interfaces.d.ts +1 -0
  43. package/interfaces/base-entity.interface.d.ts +3 -0
  44. package/interfaces/database.interface.d.ts +1 -0
  45. package/package.json +2 -2
  46. package/seeders/data-generator.d.ts +1 -1
  47. package/seeders/entity-reader.d.ts +0 -1
  48. package/seeders/field-patterns.d.ts +12 -0
  49. package/seeders/index.d.ts +3 -3
  50. package/seeders/seed-config.d.ts +1 -0
  51. package/seeders/seed-runner.d.ts +1 -0
  52. package/utils/datasource-config.builder.d.ts +0 -1
  53. package/cjs/docs/docs.setup.js +0 -14
  54. package/cjs/seeders/template-generator.js +0 -297
  55. package/docs/docs.setup.d.ts +0 -3
  56. package/fesm/docs/docs.setup.js +0 -4
  57. package/fesm/seeders/template-generator.js +0 -257
  58. package/seeders/template-generator.d.ts +0 -16
package/README.md CHANGED
@@ -1,70 +1,126 @@
1
1
  # Core Package Guide
2
2
 
3
3
  > **Package:** `@flusys/nestjs-core`
4
- > **Type:** Pure TypeScript utilities (Zero NestJS dependencies)
4
+ > **Version:** 1.1.0
5
+ > **Type:** Pure TypeScript foundation (zero NestJS dependencies)
5
6
 
6
- Foundation layer providing type-safe configuration, database utilities, migration CLI, seeders, and Swagger setup.
7
+ Foundation layer providing type-safe configuration, database utilities, migration CLI, seeders with intelligent pattern detection, and Swagger setup.
8
+
9
+ ## Table of Contents
10
+
11
+ - [Package Architecture](#package-architecture)
12
+ - [Environment Configuration](#environment-configuration)
13
+ - [Database Interfaces](#database-interfaces)
14
+ - [Migration System](#migration-system)
15
+ - [Seed System](#seed-system)
16
+ - [Field Pattern Detection](#field-pattern-detection)
17
+ - [Swagger Documentation](#swagger-documentation)
18
+ - [API Reference](#api-reference)
19
+
20
+ ---
7
21
 
8
22
  ## Package Architecture
9
23
 
10
24
  ```
11
25
  nestjs-core/src/
12
26
  ├── config/
13
- │ └── env-config.service.ts # Environment configuration singleton
27
+ │ └── env-config.service.ts # Environment configuration singleton
14
28
  ├── constants/
15
- │ └── database.constants.ts # MODULE_OPTIONS, DEFAULT_TENANT_HEADER
29
+ │ └── database.constants.ts # MODULE_OPTIONS, DEFAULT_TENANT_HEADER
16
30
  ├── interfaces/
17
- │ ├── app-config.interfaces.ts # IBootstrapAppConfig, IDynamicModuleConfig
18
- │ ├── base-entity.interface.ts # IBaseEntity, ISoftDeletable, ITimestampable
19
- │ ├── database.interface.ts # IDatabaseConfig, ITenantDatabaseConfig
20
- │ └── migration.interface.ts # IMigrationConfig, IMigrationResult
31
+ │ ├── app-config.interfaces.ts # IBootstrapAppConfig, IDynamicModuleConfig
32
+ │ ├── base-entity.interface.ts # IBaseEntity, ISoftDeletable, ITimestampable
33
+ │ ├── database.interface.ts # IDatabaseConfig, ITenantDatabaseConfig
34
+ │ └── migration.interface.ts # IMigrationConfig, IMigrationResult
21
35
  ├── utils/
22
- │ └── datasource-config.builder.ts
36
+ │ └── datasource-config.builder.ts # DataSource utilities
23
37
  ├── migration/
24
- │ ├── cli.ts, migration.cli.ts, datasource.factory.ts, migration.runner.ts
38
+ │ ├── cli.ts # CLI entry point
39
+ │ ├── migration.cli.ts # Migration CLI commands
40
+ │ ├── datasource.factory.ts # DataSource factory
41
+ │ └── migration.runner.ts # Migration execution
25
42
  ├── seeders/
26
- │ ├── cli.ts, base-seeder.ts, seed-runner.ts, seed-config.ts
27
- │ ├── entity-reader.ts, data-generator.ts, template-generator.ts
43
+ │ ├── cli.ts # Seed CLI entry point
44
+ │ ├── base-seeder.ts # Abstract base seeder class
45
+ │ ├── seed-runner.ts # Seed orchestration
46
+ │ ├── seed-config.ts # Global seed configuration
47
+ │ ├── entity-reader.ts # TypeORM metadata extraction
48
+ │ ├── data-generator.ts # Faker.js data generation
49
+ │ ├── field-patterns.ts # Intelligent field pattern detection
50
+ │ └── template-generator.ts # Seeder template generation
28
51
  ├── docs/
29
- ├── docs.config.ts, docs.setup.ts
52
+ └── docs.config.ts # Swagger setup utilities
30
53
  └── index.ts
31
54
  ```
32
55
 
56
+ ---
57
+
33
58
  ## Environment Configuration
34
59
 
35
60
  ```typescript
36
61
  import { envConfig } from '@flusys/nestjs-core/config';
37
62
  ```
38
63
 
64
+ ### Available Methods
65
+
39
66
  | Method | Description |
40
67
  |--------|-------------|
41
68
  | `tryGetValue(key)` | Get env value (throws for restricted keys) |
42
- | `getNumber(key)` | Get env value as number |
43
- | `getBoolean(key)` | Get env value as boolean |
69
+ | `getValue(key, throwOnMissing?)` | Raw string access |
70
+ | `getNumber(key, throwOnMissing?)` | Get env value as number |
71
+ | `getBoolean(key, throwOnMissing?)` | Get env value as boolean |
44
72
  | `getPort()` | Get PORT (default: 3000) |
45
73
  | `isProduction()` | Check if MODE !== 'DEV' |
46
74
  | `getFrontendUrl()` | Get FRONTEND_URL |
47
- | `getOrigins()` | Get ALLOW_ORIGINS as array |
75
+ | `getOrigins()` | Get ALLOW_ORIGINS as comma-separated array |
48
76
  | `getTypeOrmConfig()` | Get database config |
49
- | `getJwtConfig()` | Get JWT config |
50
- | `getRedisUrl()` | Get Redis connection URL |
51
- | `getMailConfig()` | Get mail configuration |
77
+ | `getJwtConfig()` | Get JWT secret + expiration |
78
+ | `getRedisUrl()` | Get Redis connection URL (default: redis://localhost:6379) |
79
+ | `getMailConfig()` | Get mail configuration (MAIL_FROM, MAIL_APP_PASSWORD) |
52
80
  | `getTenantId()` | Get TENANT_ID |
53
81
  | `useTenantMode()` | Check USE_TENANT_MODE |
54
82
  | `getLogConfig()` | Get logging configuration |
55
83
  | `getEnv()` | Get all env vars as Record |
56
84
 
85
+ ### Restricted Keys
86
+
87
+ The following keys require using specific methods (prevents misuse):
88
+
89
+ | Key | Use Instead |
90
+ |-----|-------------|
91
+ | `FRONTEND_URL` | `getFrontendUrl()` |
92
+ | `ALLOW_ORIGINS` | `getOrigins()` |
93
+ | `PORT` | `getPort()` |
94
+ | `MODE` | `isProduction()` |
95
+ | `DB_HOST/PORT/USER/PASSWORD` | `getTypeOrmConfig()` |
96
+
97
+ ---
98
+
57
99
  ## Database Interfaces
58
100
 
101
+ ### Core Interfaces
102
+
59
103
  ```typescript
104
+ type DatabaseType = 'mysql' | 'postgres' | 'mariadb' | 'sqlite' | 'mssql';
105
+ type DatabaseMode = 'single' | 'multi-tenant';
106
+
60
107
  interface IDatabaseConfig {
61
- type: 'mysql' | 'postgres' | 'mariadb' | 'sqlite' | 'mssql';
62
- host?: string; port?: number; username?: string; password?: string; database?: string;
108
+ type: DatabaseType;
109
+ host?: string;
110
+ port?: number;
111
+ username?: string;
112
+ password?: string;
113
+ database?: string;
63
114
  }
64
115
 
65
116
  interface ITenantDatabaseConfig {
66
- id: string; database: string; name?: string;
67
- host?: string; port?: number; username?: string; password?: string;
117
+ id: string;
118
+ database: string;
119
+ name?: string;
120
+ host?: string;
121
+ port?: number;
122
+ username?: string;
123
+ password?: string;
68
124
  enableCompanyFeature?: boolean;
69
125
  permissionMode?: 'FULL' | 'RBAC' | 'DIRECT';
70
126
  }
@@ -76,122 +132,508 @@ interface IBootstrapAppConfig {
76
132
  }
77
133
  ```
78
134
 
79
- ## Migration CLI
135
+ ### Entity Interfaces
136
+
137
+ ```typescript
138
+ interface IBaseEntity {
139
+ id: string;
140
+ createdAt: Date;
141
+ updatedAt: Date;
142
+ deletedAt?: Date | null;
143
+ }
144
+
145
+ interface ISoftDeletable {
146
+ deletedAt?: Date | null;
147
+ }
148
+
149
+ interface ITimestampable {
150
+ createdAt: Date;
151
+ updatedAt: Date;
152
+ }
153
+
154
+ interface IOrderable {
155
+ serial?: number;
156
+ }
157
+
158
+ interface IMetadata {
159
+ metadata?: Record<string, any> | null;
160
+ }
161
+
162
+ interface ICompanyOwned {
163
+ companyId?: string | null;
164
+ }
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Migration System
170
+
171
+ ### CLI Commands
80
172
 
81
173
  ```bash
82
- npm run migration:generate --name=CreateUsers
83
- npm run migration:run
84
- npm run migration:revert
85
- npm run migration:status
86
- TENANT_ID=tenant1 npm run migration:run # specific tenant
87
- npm run migration:run:all # all tenants
174
+ npm run migration:generate -- -n CreateUsers # Generate migration
175
+ npm run migration:run # Run pending migrations
176
+ npm run migration:revert # Revert last migration
177
+ npm run migration:status # Show migration status
178
+ TENANT_ID=tenant1 npm run migration:run # Specific tenant
179
+ npm run migration:run:all # All tenants
180
+ npm run migration:revert:all # Revert all tenants
181
+ npm run migration:status:all # Status all tenants
182
+ ```
183
+
184
+ ### Migration Configuration
185
+
186
+ ```typescript
187
+ import { IMigrationConfig } from '@flusys/nestjs-core';
188
+
189
+ const migrationConfig: IMigrationConfig = {
190
+ defaultDatabaseConfig: {
191
+ type: 'postgres',
192
+ host: 'localhost',
193
+ port: 5432,
194
+ username: 'user',
195
+ password: 'password',
196
+ database: 'app_db',
197
+ },
198
+ bootstrapAppConfig: {
199
+ databaseMode: 'multi-tenant',
200
+ enableCompanyFeature: true,
201
+ },
202
+ tenants: [
203
+ { id: 'tenant1', database: 'tenant1_db' },
204
+ { id: 'tenant2', database: 'tenant2_db', host: 'different-server.com' },
205
+ ],
206
+ migrationsPath: './src/persistence/migrations',
207
+ entities: (tenantConfig) => {
208
+ // Dynamic entity resolution per tenant
209
+ return tenantConfig?.enableCompanyFeature
210
+ ? [UserWithCompany, RoleWithCompany]
211
+ : [User, Role];
212
+ },
213
+ migrationsTableName: 'typeorm_migrations',
214
+ };
88
215
  ```
89
216
 
217
+ ### Core Functions
218
+
90
219
  ```typescript
91
- import { runMigrationCli, createMigrationDataSource } from '@flusys/nestjs-core/migration';
220
+ import {
221
+ generateMigration,
222
+ runMigrations,
223
+ revertMigration,
224
+ migrationStatus,
225
+ runForAllTenants,
226
+ createMigrationDataSource,
227
+ } from '@flusys/nestjs-core/migration';
228
+
229
+ // Generate new migration
230
+ await generateMigration(config, 'CreateUsersTable', tenantId?);
231
+
232
+ // Run pending migrations
233
+ const result: IMigrationResult = await runMigrations(config, tenantId?);
234
+
235
+ // Revert last migration
236
+ const result: IMigrationResult = await revertMigration(config, tenantId?);
237
+
238
+ // Check status
239
+ await migrationStatus(config, tenantId?);
240
+
241
+ // Multi-tenant operations
242
+ const results: IMigrationResult[] = await runForAllTenants(config, 'run');
92
243
  ```
93
244
 
245
+ ---
246
+
94
247
  ## Seed System
95
248
 
249
+ ### CLI Commands
250
+
96
251
  ```bash
97
- npm run seed:generate
98
- npm run seed:run -- --entity=User --count=100
99
- npm run seed:clear
100
- npm run seed:status
252
+ npm run seed:run # Seed all entities
253
+ npm run seed:run -- --entity=User --count=100 # Specific entity
254
+ npm run seed:run -- --count=50 --clear # Clear before seeding
255
+ npm run seed:clear # Clear all data
256
+ npm run seed:clear -- --hard # Hard delete
257
+ npm run seed:status # Show status
258
+ npm run seed:run:all # Multi-tenant
259
+ ```
260
+
261
+ ### Seed Configuration
262
+
263
+ ```typescript
264
+ import { configureSeedConfig, seedConfig, ISeedConfig } from '@flusys/nestjs-core/seeders';
265
+
266
+ interface ISeedConfig {
267
+ counts: Record<string, number>; // Per-entity counts
268
+ order: string[]; // Preferred seeding order
269
+ skipEntities: string[]; // Entities to skip
270
+ locale: string; // Faker locale
271
+ respectSoftDelete: boolean; // Default clear behavior
272
+ }
273
+
274
+ // Configure before running seeders
275
+ configureSeedConfig({
276
+ counts: { User: 50, Product: 100, Order: 200 },
277
+ order: ['User', 'Company', 'Product', 'Order'],
278
+ skipEntities: ['migrations', 'typeorm_metadata', 'Migration'],
279
+ locale: 'en',
280
+ respectSoftDelete: true,
281
+ });
101
282
  ```
102
283
 
284
+ ### SeedRunner
285
+
286
+ The main orchestrator for seed operations:
287
+
288
+ ```typescript
289
+ import { SeedRunner, ISeedOptions, ISeedResult } from '@flusys/nestjs-core/seeders';
290
+
291
+ const runner = new SeedRunner(dataSource, logger?);
292
+
293
+ // Register custom seeders (take precedence over generic)
294
+ runner.registerCustomSeeder('User', new UserSeeder(dataSource));
295
+
296
+ // Run all entities in dependency order
297
+ const results: ISeedResult[] = await runner.runAll({
298
+ count: 50, // Records per entity
299
+ clear: true, // Clear before seeding
300
+ skipIfExists: false, // Skip if data exists
301
+ dryRun: false, // Preview without executing
302
+ continueOnError: true, // Continue on failures
303
+ batchSize: 1000, // Batch size for bulk inserts
304
+ onProgress: (current, total, entity) => { },
305
+ });
306
+
307
+ // Run single entity
308
+ const result: ISeedResult = await runner.runSingle('User', options);
309
+
310
+ // Clear all data (reverse dependency order)
311
+ const results = await runner.clearAll(hard?, continueOnError?);
312
+
313
+ // Get status
314
+ const status = await runner.getStatus();
315
+ // Returns: [{ entity, tableName, count, isEmpty, hasSoftDelete }]
316
+ ```
317
+
318
+ ### Custom Seeders
319
+
103
320
  ```typescript
104
- import { BaseSeeder, SeedRunner } from '@flusys/nestjs-core/seeders';
321
+ import { BaseSeeder, DataGenerator } from '@flusys/nestjs-core/seeders';
105
322
 
106
323
  class UserSeeder extends BaseSeeder<User> {
107
- constructor(ds: DataSource) { super(ds, User); }
324
+ private generator: DataGenerator;
325
+
326
+ constructor(ds: DataSource) {
327
+ super(ds, User);
328
+ this.generator = new DataGenerator('en');
329
+ }
330
+
108
331
  async generate(count: number): Promise<User[]> {
109
- const users = [];
332
+ const users: User[] = [];
110
333
  for (let i = 0; i < count; i++) {
111
- users.push(this.repository.create({ email: faker.internet.email() }));
334
+ users.push(this.repository.create({
335
+ email: faker.internet.email(),
336
+ name: faker.person.fullName(),
337
+ password: await bcrypt.hash('password123', 12),
338
+ }));
112
339
  }
113
340
  return this.repository.save(users);
114
341
  }
115
342
  }
116
343
 
344
+ // Register before running
117
345
  const runner = new SeedRunner(dataSource);
118
346
  runner.registerCustomSeeder('User', new UserSeeder(dataSource));
119
347
  await runner.runAll({ count: 50, clear: true });
120
348
  ```
121
349
 
350
+ ### EntityReader
351
+
352
+ Extracts TypeORM metadata for intelligent seeding:
353
+
354
+ ```typescript
355
+ import { EntityReader, IEntityInfo, IColumnInfo } from '@flusys/nestjs-core/seeders';
356
+
357
+ const reader = new EntityReader(dataSource);
358
+
359
+ // Get all entities
360
+ const entities = reader.getAllEntities();
361
+
362
+ // Get detailed entity info
363
+ const info: IEntityInfo = reader.getEntityInfo('User');
364
+ // Returns: { name, tableName, columns, relations, hasSoftDelete, hasCompany }
365
+
366
+ // Get seeding order (topological sort by FK dependencies)
367
+ const order: string[] = reader.getSeedingOrder(skipEntities?);
368
+ // Independent entities first, then dependents
369
+ ```
370
+
371
+ ### DataGenerator
372
+
373
+ Generates realistic sample data using Faker.js:
374
+
375
+ ```typescript
376
+ import { DataGenerator, IColumnInfo } from '@flusys/nestjs-core/seeders';
377
+
378
+ const generator = new DataGenerator('en');
379
+
380
+ // Generate value for a column
381
+ const value = generator.generateValue(columnInfo);
382
+
383
+ // Generate complete entity
384
+ const entity = generator.generateEntity(columns);
385
+
386
+ // Relation helpers
387
+ const relatedId = generator.generateRelationId(relatedEntities);
388
+ const relatedIds = generator.generateRelationIds(relatedEntities, min?, max?);
389
+ ```
390
+
391
+ ---
392
+
393
+ ## Field Pattern Detection
394
+
395
+ Intelligent field pattern detection for realistic data generation.
396
+
397
+ ### Supported Patterns
398
+
399
+ ```typescript
400
+ import { detectFieldPattern, FieldPatternType } from '@flusys/nestjs-core/seeders';
401
+
402
+ // Pattern detection returns one of 58 patterns:
403
+ type FieldPatternType =
404
+ | 'skip' | 'null' | 'boolean' | 'token'
405
+ | 'firstName' | 'lastName' | 'fullName'
406
+ | 'email' | 'phone'
407
+ | 'address' | 'street' | 'city' | 'state' | 'country' | 'zipCode'
408
+ | 'url' | 'domain' | 'slug'
409
+ | 'description' | 'summary' | 'content' | 'title'
410
+ | 'username' | 'password'
411
+ | 'birthdate' | 'futureDate' | 'recentDateOrNull'
412
+ | 'serial' | 'company'
413
+ | /* ...more */;
414
+
415
+ // Detect pattern for a column
416
+ const pattern = detectFieldPattern(column);
417
+ ```
418
+
419
+ ### System Fields
420
+
421
+ Automatically handled fields:
422
+
423
+ ```typescript
424
+ import { SYSTEM_FIELDS, AUDIT_FIELDS, IDENTITY_FIELDS, BOOLEAN_KEYWORDS } from '@flusys/nestjs-core/seeders';
425
+
426
+ SYSTEM_FIELDS = ['id', 'createdAt', 'updatedAt', 'deletedAt', ...];
427
+ AUDIT_FIELDS = ['createdbyid', 'updatedbyid', 'deletedbyid'];
428
+ IDENTITY_FIELDS = ['id', 'createdat', 'updatedat', 'deletedat'];
429
+ BOOLEAN_KEYWORDS = ['verified', 'active', 'enabled', 'public', 'readonly', 'valid'];
430
+ ```
431
+
432
+ ### Type Category Detection
433
+
434
+ ```typescript
435
+ import { detectTypeCategory, getStringLengthCategory } from '@flusys/nestjs-core/seeders';
436
+
437
+ // Categorize database type
438
+ const category = detectTypeCategory('varchar'); // 'string'
439
+ // Categories: string | integer | decimal | boolean | date | timestamp | time | uuid | json | array | unknown
440
+
441
+ // String length categorization
442
+ const lengthCategory = getStringLengthCategory(255); // 'sentence'
443
+ // ≤ 50 chars → 'word'
444
+ // ≤ 255 chars → 'sentence'
445
+ // > 255 chars → 'paragraph'
446
+ ```
447
+
448
+ ---
449
+
122
450
  ## Swagger Documentation
123
451
 
452
+ ### Setup Functions
453
+
124
454
  ```typescript
125
- import { setupSwaggerDocs, setupModuleSwaggerDocs } from '@flusys/nestjs-core/docs';
455
+ import { setupSwaggerDocs, setupModuleSwaggerDocs, IModuleSwaggerOptions } from '@flusys/nestjs-core/docs';
126
456
 
457
+ // Variadic API for multiple configs
458
+ setupSwaggerDocs(app, authConfig, adminConfig, iamConfig);
459
+
460
+ // Array API for module docs
127
461
  setupModuleSwaggerDocs(app, [
128
462
  { title: 'Auth API', path: 'auth/docs', bearerAuth: true },
129
463
  { title: 'Admin API', path: 'admin/docs', excludeTags: ['public'] },
130
464
  ]);
131
465
  ```
132
466
 
467
+ ### Configuration Options
468
+
469
+ ```typescript
470
+ interface IModuleSwaggerOptions {
471
+ modules?: Type<unknown>[]; // Include specific modules
472
+ title: string;
473
+ description: string;
474
+ version?: string; // Default: '1.0'
475
+ path: string; // Swagger UI path
476
+ bearerAuth?: boolean; // Add JWT auth
477
+ globalHeaders?: ISwaggerGlobalHeader[];
478
+ excludeTags?: string[]; // Hide endpoints by tag
479
+ excludeSchemaProperties?: ISchemaPropertyExclusion[];
480
+ excludeQueryParameters?: IQueryParameterExclusion[];
481
+ excludeExamples?: IExampleExclusion[];
482
+ }
483
+
484
+ interface ISchemaPropertyExclusion {
485
+ schemaName: string;
486
+ properties: string[];
487
+ }
488
+
489
+ interface IQueryParameterExclusion {
490
+ pathPattern: string; // Supports wildcards: /iam/permissions/*
491
+ method?: string; // Optional: 'post', 'get', etc.
492
+ parameters: string[];
493
+ }
494
+ ```
495
+
133
496
  ### Conditional Schema Exclusion
134
497
 
135
498
  ```typescript
136
499
  setupModuleSwaggerDocs(app, [{
137
500
  title: 'Auth API',
138
501
  path: 'auth/docs',
502
+ bearerAuth: true,
139
503
  excludeSchemaProperties: enableCompanyFeature ? undefined : [
140
504
  { schemaName: 'LoginResponseDto', properties: ['company', 'branch'] },
505
+ { schemaName: 'UserDto', properties: ['companyId'] },
141
506
  ],
507
+ excludeTags: enableCompanyFeature ? undefined : ['Companies', 'Branches'],
142
508
  }]);
143
509
  ```
144
510
 
511
+ ---
512
+
145
513
  ## API Reference
146
514
 
515
+ ### Interfaces
516
+
147
517
  ```typescript
148
- // Interfaces
149
518
  import {
150
- IDatabaseConfig, ITenantDatabaseConfig, IBootstrapAppConfig,
151
- IDynamicModuleConfig, IDataSourceServiceOptions,
152
- IMigrationConfig, IMigrationResult,
153
- IBaseEntity, ISoftDeletable, ITimestampable, IOrderable,
519
+ IDatabaseConfig,
520
+ ITenantDatabaseConfig,
521
+ IBootstrapAppConfig,
522
+ IDynamicModuleConfig,
523
+ IDataSourceServiceOptions,
524
+ IModuleOptionsFactory,
525
+ IAsyncModuleOptions,
526
+ IMigrationConfig,
527
+ IMigrationResult,
528
+ IBaseEntity,
529
+ ISoftDeletable,
530
+ ITimestampable,
531
+ IOrderable,
532
+ ICompanyOwned,
533
+ IMetadata,
154
534
  } from '@flusys/nestjs-core';
535
+ ```
155
536
 
156
- // Constants
537
+ ### Constants
538
+
539
+ ```typescript
157
540
  import { MODULE_OPTIONS, DEFAULT_TENANT_HEADER } from '@flusys/nestjs-core';
541
+ ```
542
+
543
+ ### Config
158
544
 
159
- // Config
545
+ ```typescript
160
546
  import { envConfig } from '@flusys/nestjs-core/config';
547
+ ```
548
+
549
+ ### Utils
161
550
 
162
- // Utils
551
+ ```typescript
163
552
  import {
164
- buildDataSourceOptions, getDatabaseForTenant,
165
- resolveEntities, getActiveTenants,
553
+ buildDataSourceOptions,
554
+ getDatabaseForTenant,
555
+ resolveEntities,
556
+ getActiveTenants,
557
+ getMigrationsFolderPath,
558
+ getMigrationsGlobPattern,
166
559
  } from '@flusys/nestjs-core/utils';
560
+ ```
167
561
 
168
- // Migration
562
+ ### Migration
563
+
564
+ ```typescript
169
565
  import {
170
- createMigrationDataSource, initializeDataSource, runMigrationCli,
171
- generateMigration, runMigrations, revertMigration, migrationStatus,
566
+ createMigrationDataSource,
567
+ initializeDataSource,
568
+ runMigrationCli,
569
+ generateMigration,
570
+ runMigrations,
571
+ revertMigration,
572
+ migrationStatus,
573
+ runForAllTenants,
574
+ ensureMigrationsFolder,
172
575
  } from '@flusys/nestjs-core/migration';
576
+ ```
577
+
578
+ ### Seeders
173
579
 
174
- // Seeders
580
+ ```typescript
175
581
  import {
176
- BaseSeeder, SeedRunner, EntityReader, DataGenerator,
177
- seedConfig, runSeedCli,
582
+ // Classes
583
+ BaseSeeder,
584
+ SeedRunner,
585
+ EntityReader,
586
+ DataGenerator,
587
+ // Interfaces
588
+ ISeedResult,
589
+ ISeedOptions,
590
+ ISeederLogger,
591
+ IEntityInfo,
592
+ IColumnInfo,
593
+ IRelationInfo,
594
+ ISeedConfig,
595
+ // Functions
596
+ defaultLogger,
597
+ seedConfig,
598
+ configureSeedConfig,
599
+ runSeedCli,
600
+ getEntityCount,
601
+ shouldSkipEntity,
602
+ getSeedingOrder,
603
+ // Field pattern functions
604
+ detectFieldPattern,
605
+ detectTypeCategory,
606
+ isSystemField,
607
+ // Constants
608
+ SYSTEM_FIELDS,
178
609
  } from '@flusys/nestjs-core/seeders';
610
+ ```
611
+
612
+ > **Note:** `FieldPatternType`, `AUDIT_FIELDS`, `IDENTITY_FIELDS`, `BOOLEAN_KEYWORDS`, `getStringLengthCategory`, and `getTokenLength` are internal utilities available in `field-patterns.ts` but not exported from the public API.
613
+
614
+ ### Swagger
179
615
 
180
- // Swagger
616
+ ```typescript
181
617
  import {
182
- setupSwaggerDocs, setupModuleSwaggerDocs,
183
- IModuleSwaggerOptions, ISchemaPropertyExclusion,
618
+ setupSwaggerDocs,
619
+ setupModuleSwaggerDocs,
620
+ IModuleSwaggerOptions,
621
+ ISchemaPropertyExclusion,
622
+ IQueryParameterExclusion,
623
+ ISwaggerGlobalHeader,
624
+ IExampleExclusion,
184
625
  } from '@flusys/nestjs-core/docs';
185
626
  ```
186
627
 
628
+ ---
629
+
187
630
  ## Dependencies
188
631
 
189
632
  - `dotenv` - Environment variable loading
190
- - `typeorm` - Migration/seeder utilities
633
+ - `typeorm` - Migration/seeder utilities (DataSource, EntityMetadata)
191
634
  - `@faker-js/faker` - Seed data generation
192
-
193
- **No NestJS dependencies** - Can be used in any TypeScript project.
635
+ - `@nestjs/common`, `@nestjs/swagger` - Swagger documentation setup only
194
636
 
195
637
  ---
196
638
 
197
- **Last Updated:** 2026-02-16
639
+ **Last Updated:** 2026-02-21