@alpha.consultings/eloquent-orm.js 1.0.1
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/CHANGELOG.md +73 -0
- package/README.md +215 -0
- package/dist/Model.d.ts +2 -0
- package/dist/Model.d.ts.map +1 -0
- package/dist/Model.js +7 -0
- package/dist/Model.js.map +1 -0
- package/dist/cli/commands/cacheClear.d.ts +2 -0
- package/dist/cli/commands/cacheClear.d.ts.map +1 -0
- package/dist/cli/commands/cacheClear.js +69 -0
- package/dist/cli/commands/cacheClear.js.map +1 -0
- package/dist/cli/commands/cacheStats.d.ts +2 -0
- package/dist/cli/commands/cacheStats.d.ts.map +1 -0
- package/dist/cli/commands/cacheStats.js +55 -0
- package/dist/cli/commands/cacheStats.js.map +1 -0
- package/dist/cli/commands/dbSeed.d.ts +16 -0
- package/dist/cli/commands/dbSeed.d.ts.map +1 -0
- package/dist/cli/commands/dbSeed.js +201 -0
- package/dist/cli/commands/dbSeed.js.map +1 -0
- package/dist/cli/commands/dbSeedBootstrapPrecheck.d.ts +3 -0
- package/dist/cli/commands/dbSeedBootstrapPrecheck.d.ts.map +1 -0
- package/dist/cli/commands/dbSeedBootstrapPrecheck.js +8 -0
- package/dist/cli/commands/dbSeedBootstrapPrecheck.js.map +1 -0
- package/dist/cli/commands/dbSeedFresh.d.ts +14 -0
- package/dist/cli/commands/dbSeedFresh.d.ts.map +1 -0
- package/dist/cli/commands/dbSeedFresh.js +81 -0
- package/dist/cli/commands/dbSeedFresh.js.map +1 -0
- package/dist/cli/commands/demoScenario.d.ts +9 -0
- package/dist/cli/commands/demoScenario.d.ts.map +1 -0
- package/dist/cli/commands/demoScenario.js +185 -0
- package/dist/cli/commands/demoScenario.js.map +1 -0
- package/dist/cli/commands/factoryStatus.d.ts +9 -0
- package/dist/cli/commands/factoryStatus.d.ts.map +1 -0
- package/dist/cli/commands/factoryStatus.js +103 -0
- package/dist/cli/commands/factoryStatus.js.map +1 -0
- package/dist/cli/commands/makeController.d.ts +11 -0
- package/dist/cli/commands/makeController.d.ts.map +1 -0
- package/dist/cli/commands/makeController.js +61 -0
- package/dist/cli/commands/makeController.js.map +1 -0
- package/dist/cli/commands/makeFactory.d.ts +14 -0
- package/dist/cli/commands/makeFactory.d.ts.map +1 -0
- package/dist/cli/commands/makeFactory.js +183 -0
- package/dist/cli/commands/makeFactory.js.map +1 -0
- package/dist/cli/commands/makeMigration.d.ts +18 -0
- package/dist/cli/commands/makeMigration.d.ts.map +1 -0
- package/dist/cli/commands/makeMigration.js +496 -0
- package/dist/cli/commands/makeMigration.js.map +1 -0
- package/dist/cli/commands/makeModel.d.ts +20 -0
- package/dist/cli/commands/makeModel.d.ts.map +1 -0
- package/dist/cli/commands/makeModel.js +360 -0
- package/dist/cli/commands/makeModel.js.map +1 -0
- package/dist/cli/commands/makeRegistry.d.ts +7 -0
- package/dist/cli/commands/makeRegistry.d.ts.map +1 -0
- package/dist/cli/commands/makeRegistry.js +88 -0
- package/dist/cli/commands/makeRegistry.js.map +1 -0
- package/dist/cli/commands/makeScenario.d.ts +12 -0
- package/dist/cli/commands/makeScenario.d.ts.map +1 -0
- package/dist/cli/commands/makeScenario.js +639 -0
- package/dist/cli/commands/makeScenario.js.map +1 -0
- package/dist/cli/commands/makeSeed.d.ts +11 -0
- package/dist/cli/commands/makeSeed.d.ts.map +1 -0
- package/dist/cli/commands/makeSeed.js +47 -0
- package/dist/cli/commands/makeSeed.js.map +1 -0
- package/dist/cli/commands/makeService.d.ts +5 -0
- package/dist/cli/commands/makeService.d.ts.map +1 -0
- package/dist/cli/commands/makeService.js +31 -0
- package/dist/cli/commands/makeService.js.map +1 -0
- package/dist/cli/commands/migrateFresh.d.ts +14 -0
- package/dist/cli/commands/migrateFresh.d.ts.map +1 -0
- package/dist/cli/commands/migrateFresh.js +150 -0
- package/dist/cli/commands/migrateFresh.js.map +1 -0
- package/dist/cli/commands/migrateReset.d.ts +12 -0
- package/dist/cli/commands/migrateReset.d.ts.map +1 -0
- package/dist/cli/commands/migrateReset.js +28 -0
- package/dist/cli/commands/migrateReset.js.map +1 -0
- package/dist/cli/commands/migrateRollback.d.ts +10 -0
- package/dist/cli/commands/migrateRollback.d.ts.map +1 -0
- package/dist/cli/commands/migrateRollback.js +303 -0
- package/dist/cli/commands/migrateRollback.js.map +1 -0
- package/dist/cli/commands/migrateRun.d.ts +10 -0
- package/dist/cli/commands/migrateRun.d.ts.map +1 -0
- package/dist/cli/commands/migrateRun.js +301 -0
- package/dist/cli/commands/migrateRun.js.map +1 -0
- package/dist/cli/commands/migrateStatus.d.ts +8 -0
- package/dist/cli/commands/migrateStatus.d.ts.map +1 -0
- package/dist/cli/commands/migrateStatus.js +118 -0
- package/dist/cli/commands/migrateStatus.js.map +1 -0
- package/dist/cli/eloquent.d.ts +18 -0
- package/dist/cli/eloquent.d.ts.map +1 -0
- package/dist/cli/eloquent.js +187 -0
- package/dist/cli/eloquent.js.map +1 -0
- package/dist/cli/utils/ArtifactCompatibility.d.ts +10 -0
- package/dist/cli/utils/ArtifactCompatibility.d.ts.map +1 -0
- package/dist/cli/utils/ArtifactCompatibility.js +60 -0
- package/dist/cli/utils/ArtifactCompatibility.js.map +1 -0
- package/dist/cli/utils/ArtifactRoutingReport.d.ts +10 -0
- package/dist/cli/utils/ArtifactRoutingReport.d.ts.map +1 -0
- package/dist/cli/utils/ArtifactRoutingReport.js +25 -0
- package/dist/cli/utils/ArtifactRoutingReport.js.map +1 -0
- package/dist/cli/utils/ArtifactStorage.d.ts +10 -0
- package/dist/cli/utils/ArtifactStorage.d.ts.map +1 -0
- package/dist/cli/utils/ArtifactStorage.js +193 -0
- package/dist/cli/utils/ArtifactStorage.js.map +1 -0
- package/dist/cli/utils/AuditTrail.d.ts +25 -0
- package/dist/cli/utils/AuditTrail.d.ts.map +1 -0
- package/dist/cli/utils/AuditTrail.js +74 -0
- package/dist/cli/utils/AuditTrail.js.map +1 -0
- package/dist/cli/utils/CliActionRuntime.d.ts +5 -0
- package/dist/cli/utils/CliActionRuntime.d.ts.map +1 -0
- package/dist/cli/utils/CliActionRuntime.js +22 -0
- package/dist/cli/utils/CliActionRuntime.js.map +1 -0
- package/dist/cli/utils/CliBootstrapSupport.d.ts +13 -0
- package/dist/cli/utils/CliBootstrapSupport.d.ts.map +1 -0
- package/dist/cli/utils/CliBootstrapSupport.js +55 -0
- package/dist/cli/utils/CliBootstrapSupport.js.map +1 -0
- package/dist/cli/utils/CliCommandCatalog.d.ts +6 -0
- package/dist/cli/utils/CliCommandCatalog.d.ts.map +1 -0
- package/dist/cli/utils/CliCommandCatalog.js +78 -0
- package/dist/cli/utils/CliCommandCatalog.js.map +1 -0
- package/dist/cli/utils/CliCommandTargets.d.ts +8 -0
- package/dist/cli/utils/CliCommandTargets.d.ts.map +1 -0
- package/dist/cli/utils/CliCommandTargets.js +19 -0
- package/dist/cli/utils/CliCommandTargets.js.map +1 -0
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.d.ts +3 -0
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.d.ts.map +1 -0
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.js +94 -0
- package/dist/cli/utils/CliMakeArtifactCommandRegistration.js.map +1 -0
- package/dist/cli/utils/CliMigrationCommandRegistration.d.ts +3 -0
- package/dist/cli/utils/CliMigrationCommandRegistration.d.ts.map +1 -0
- package/dist/cli/utils/CliMigrationCommandRegistration.js +195 -0
- package/dist/cli/utils/CliMigrationCommandRegistration.js.map +1 -0
- package/dist/cli/utils/CliPresentation.d.ts +2 -0
- package/dist/cli/utils/CliPresentation.d.ts.map +1 -0
- package/dist/cli/utils/CliPresentation.js +13 -0
- package/dist/cli/utils/CliPresentation.js.map +1 -0
- package/dist/cli/utils/CliProductionGuards.d.ts +11 -0
- package/dist/cli/utils/CliProductionGuards.d.ts.map +1 -0
- package/dist/cli/utils/CliProductionGuards.js +34 -0
- package/dist/cli/utils/CliProductionGuards.js.map +1 -0
- package/dist/cli/utils/CliScaffoldCommandRegistration.d.ts +3 -0
- package/dist/cli/utils/CliScaffoldCommandRegistration.d.ts.map +1 -0
- package/dist/cli/utils/CliScaffoldCommandRegistration.js +89 -0
- package/dist/cli/utils/CliScaffoldCommandRegistration.js.map +1 -0
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.d.ts +3 -0
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.d.ts.map +1 -0
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.js +123 -0
- package/dist/cli/utils/CliSeedScenarioCommandRegistration.js.map +1 -0
- package/dist/cli/utils/CliSupportCommandRegistration.d.ts +3 -0
- package/dist/cli/utils/CliSupportCommandRegistration.d.ts.map +1 -0
- package/dist/cli/utils/CliSupportCommandRegistration.js +44 -0
- package/dist/cli/utils/CliSupportCommandRegistration.js.map +1 -0
- package/dist/cli/utils/ConsoleSilencer.d.ts +6 -0
- package/dist/cli/utils/ConsoleSilencer.d.ts.map +1 -0
- package/dist/cli/utils/ConsoleSilencer.js +25 -0
- package/dist/cli/utils/ConsoleSilencer.js.map +1 -0
- package/dist/cli/utils/ImportResolver.d.ts +16 -0
- package/dist/cli/utils/ImportResolver.d.ts.map +1 -0
- package/dist/cli/utils/ImportResolver.js +57 -0
- package/dist/cli/utils/ImportResolver.js.map +1 -0
- package/dist/cli/utils/ModelIntrospector.d.ts +33 -0
- package/dist/cli/utils/ModelIntrospector.d.ts.map +1 -0
- package/dist/cli/utils/ModelIntrospector.js +76 -0
- package/dist/cli/utils/ModelIntrospector.js.map +1 -0
- package/dist/cli/utils/PathMap.d.ts +58 -0
- package/dist/cli/utils/PathMap.d.ts.map +1 -0
- package/dist/cli/utils/PathMap.js +132 -0
- package/dist/cli/utils/PathMap.js.map +1 -0
- package/dist/cli/utils/ProductionSafety.d.ts +25 -0
- package/dist/cli/utils/ProductionSafety.d.ts.map +1 -0
- package/dist/cli/utils/ProductionSafety.js +61 -0
- package/dist/cli/utils/ProductionSafety.js.map +1 -0
- package/dist/cli/utils/ScaffoldGeneratorSupport.d.ts +16 -0
- package/dist/cli/utils/ScaffoldGeneratorSupport.d.ts.map +1 -0
- package/dist/cli/utils/ScaffoldGeneratorSupport.js +66 -0
- package/dist/cli/utils/ScaffoldGeneratorSupport.js.map +1 -0
- package/dist/cli/utils/ScenarioMorphAliasRouting.d.ts +14 -0
- package/dist/cli/utils/ScenarioMorphAliasRouting.d.ts.map +1 -0
- package/dist/cli/utils/ScenarioMorphAliasRouting.js +62 -0
- package/dist/cli/utils/ScenarioMorphAliasRouting.js.map +1 -0
- package/dist/cli/utils/SeedBootstrapPrecheck.d.ts +20 -0
- package/dist/cli/utils/SeedBootstrapPrecheck.d.ts.map +1 -0
- package/dist/cli/utils/SeedBootstrapPrecheck.js +133 -0
- package/dist/cli/utils/SeedBootstrapPrecheck.js.map +1 -0
- package/dist/cli/utils/StructuredLogger.d.ts +11 -0
- package/dist/cli/utils/StructuredLogger.d.ts.map +1 -0
- package/dist/cli/utils/StructuredLogger.js +53 -0
- package/dist/cli/utils/StructuredLogger.js.map +1 -0
- package/dist/cli/utils/TemplateEngine.d.ts +30 -0
- package/dist/cli/utils/TemplateEngine.d.ts.map +1 -0
- package/dist/cli/utils/TemplateEngine.js +165 -0
- package/dist/cli/utils/TemplateEngine.js.map +1 -0
- package/dist/cli/utils/factories/Factory.d.ts +61 -0
- package/dist/cli/utils/factories/Factory.d.ts.map +1 -0
- package/dist/cli/utils/factories/Factory.js +140 -0
- package/dist/cli/utils/factories/Factory.js.map +1 -0
- package/dist/cli/utils/factories/FactoryDisplay.d.ts +6 -0
- package/dist/cli/utils/factories/FactoryDisplay.d.ts.map +1 -0
- package/dist/cli/utils/factories/FactoryDisplay.js +26 -0
- package/dist/cli/utils/factories/FactoryDisplay.js.map +1 -0
- package/dist/cli/utils/factories/FactoryGraph.d.ts +6 -0
- package/dist/cli/utils/factories/FactoryGraph.d.ts.map +1 -0
- package/dist/cli/utils/factories/FactoryGraph.js +72 -0
- package/dist/cli/utils/factories/FactoryGraph.js.map +1 -0
- package/dist/cli/utils/factories/FactoryLoader.d.ts +16 -0
- package/dist/cli/utils/factories/FactoryLoader.d.ts.map +1 -0
- package/dist/cli/utils/factories/FactoryLoader.js +35 -0
- package/dist/cli/utils/factories/FactoryLoader.js.map +1 -0
- package/dist/cli/utils/factories/FactoryRegistry.d.ts +16 -0
- package/dist/cli/utils/factories/FactoryRegistry.d.ts.map +1 -0
- package/dist/cli/utils/factories/FactoryRegistry.js +87 -0
- package/dist/cli/utils/factories/FactoryRegistry.js.map +1 -0
- package/dist/cli/utils/fileWriter.d.ts +7 -0
- package/dist/cli/utils/fileWriter.d.ts.map +1 -0
- package/dist/cli/utils/fileWriter.js +61 -0
- package/dist/cli/utils/fileWriter.js.map +1 -0
- package/dist/cli/utils/migrations/MigrationLockStrategy.d.ts +21 -0
- package/dist/cli/utils/migrations/MigrationLockStrategy.d.ts.map +1 -0
- package/dist/cli/utils/migrations/MigrationLockStrategy.js +129 -0
- package/dist/cli/utils/migrations/MigrationLockStrategy.js.map +1 -0
- package/dist/cli/utils/migrations/MigrationTracker.d.ts +25 -0
- package/dist/cli/utils/migrations/MigrationTracker.d.ts.map +1 -0
- package/dist/cli/utils/migrations/MigrationTracker.js +279 -0
- package/dist/cli/utils/migrations/MigrationTracker.js.map +1 -0
- package/dist/cli/utils/migrations/MongoMigrationTracker.d.ts +18 -0
- package/dist/cli/utils/migrations/MongoMigrationTracker.d.ts.map +1 -0
- package/dist/cli/utils/migrations/MongoMigrationTracker.js +276 -0
- package/dist/cli/utils/migrations/MongoMigrationTracker.js.map +1 -0
- package/dist/cli/utils/resolveConnectionFlags.d.ts +14 -0
- package/dist/cli/utils/resolveConnectionFlags.d.ts.map +1 -0
- package/dist/cli/utils/resolveConnectionFlags.js +42 -0
- package/dist/cli/utils/resolveConnectionFlags.js.map +1 -0
- package/dist/cli/utils/resolveSqlConnectionFlags.d.ts +9 -0
- package/dist/cli/utils/resolveSqlConnectionFlags.d.ts.map +1 -0
- package/dist/cli/utils/resolveSqlConnectionFlags.js +23 -0
- package/dist/cli/utils/resolveSqlConnectionFlags.js.map +1 -0
- package/dist/cli/utils/typescript/BaseCommand.d.ts +15 -0
- package/dist/cli/utils/typescript/BaseCommand.d.ts.map +1 -0
- package/dist/cli/utils/typescript/BaseCommand.js +36 -0
- package/dist/cli/utils/typescript/BaseCommand.js.map +1 -0
- package/dist/cli/utils/typescript/RuntimeDetector.d.ts +16 -0
- package/dist/cli/utils/typescript/RuntimeDetector.d.ts.map +1 -0
- package/dist/cli/utils/typescript/RuntimeDetector.js +45 -0
- package/dist/cli/utils/typescript/RuntimeDetector.js.map +1 -0
- package/dist/cli/utils/typescript/TypeScriptCompiler.d.ts +25 -0
- package/dist/cli/utils/typescript/TypeScriptCompiler.d.ts.map +1 -0
- package/dist/cli/utils/typescript/TypeScriptCompiler.js +109 -0
- package/dist/cli/utils/typescript/TypeScriptCompiler.js.map +1 -0
- package/dist/cli/utils/typescript/tsRuntime.d.ts +12 -0
- package/dist/cli/utils/typescript/tsRuntime.d.ts.map +1 -0
- package/dist/cli/utils/typescript/tsRuntime.js +189 -0
- package/dist/cli/utils/typescript/tsRuntime.js.map +1 -0
- package/dist/config/database.d.ts +58 -0
- package/dist/config/database.d.ts.map +1 -0
- package/dist/config/database.js +106 -0
- package/dist/config/database.js.map +1 -0
- package/dist/config/dbRoleEnv.d.ts +31 -0
- package/dist/config/dbRoleEnv.d.ts.map +1 -0
- package/dist/config/dbRoleEnv.js +171 -0
- package/dist/config/dbRoleEnv.js.map +1 -0
- package/dist/core/cache/CacheAnalytics.d.ts +47 -0
- package/dist/core/cache/CacheAnalytics.d.ts.map +1 -0
- package/dist/core/cache/CacheAnalytics.js +113 -0
- package/dist/core/cache/CacheAnalytics.js.map +1 -0
- package/dist/core/cache/CacheDriver.d.ts +19 -0
- package/dist/core/cache/CacheDriver.d.ts.map +1 -0
- package/dist/core/cache/CacheDriver.js +8 -0
- package/dist/core/cache/CacheDriver.js.map +1 -0
- package/dist/core/cache/CacheFallbackManager.d.ts +35 -0
- package/dist/core/cache/CacheFallbackManager.d.ts.map +1 -0
- package/dist/core/cache/CacheFallbackManager.js +118 -0
- package/dist/core/cache/CacheFallbackManager.js.map +1 -0
- package/dist/core/cache/CacheManager.d.ts +11 -0
- package/dist/core/cache/CacheManager.d.ts.map +1 -0
- package/dist/core/cache/CacheManager.js +27 -0
- package/dist/core/cache/CacheManager.js.map +1 -0
- package/dist/core/cache/CacheRegistry.d.ts +49 -0
- package/dist/core/cache/CacheRegistry.d.ts.map +1 -0
- package/dist/core/cache/CacheRegistry.js +117 -0
- package/dist/core/cache/CacheRegistry.js.map +1 -0
- package/dist/core/cache/drivers/FileCacheDriver.d.ts +11 -0
- package/dist/core/cache/drivers/FileCacheDriver.d.ts.map +1 -0
- package/dist/core/cache/drivers/FileCacheDriver.js +54 -0
- package/dist/core/cache/drivers/FileCacheDriver.js.map +1 -0
- package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts +15 -0
- package/dist/core/cache/drivers/MemcachedCacheDriver.d.ts.map +1 -0
- package/dist/core/cache/drivers/MemcachedCacheDriver.js +60 -0
- package/dist/core/cache/drivers/MemcachedCacheDriver.js.map +1 -0
- package/dist/core/cache/drivers/MemoryCacheDriver.d.ts +9 -0
- package/dist/core/cache/drivers/MemoryCacheDriver.d.ts.map +1 -0
- package/dist/core/cache/drivers/MemoryCacheDriver.js +33 -0
- package/dist/core/cache/drivers/MemoryCacheDriver.js.map +1 -0
- package/dist/core/cache/setupCache.d.ts +2 -0
- package/dist/core/cache/setupCache.d.ts.map +1 -0
- package/dist/core/cache/setupCache.js +38 -0
- package/dist/core/cache/setupCache.js.map +1 -0
- package/dist/core/connection/BetterSqliteConnection.d.ts +23 -0
- package/dist/core/connection/BetterSqliteConnection.d.ts.map +1 -0
- package/dist/core/connection/BetterSqliteConnection.js +33 -0
- package/dist/core/connection/BetterSqliteConnection.js.map +1 -0
- package/dist/core/connection/ConnectionFactory.d.ts +18 -0
- package/dist/core/connection/ConnectionFactory.d.ts.map +1 -0
- package/dist/core/connection/ConnectionFactory.js +111 -0
- package/dist/core/connection/ConnectionFactory.js.map +1 -0
- package/dist/core/connection/DatabaseConnection.d.ts +49 -0
- package/dist/core/connection/DatabaseConnection.d.ts.map +1 -0
- package/dist/core/connection/DatabaseConnection.js +120 -0
- package/dist/core/connection/DatabaseConnection.js.map +1 -0
- package/dist/core/connection/DriverAdapter.d.ts +23 -0
- package/dist/core/connection/DriverAdapter.d.ts.map +1 -0
- package/dist/core/connection/DriverAdapter.js +145 -0
- package/dist/core/connection/DriverAdapter.js.map +1 -0
- package/dist/core/connection/resolveConnectionName.d.ts +17 -0
- package/dist/core/connection/resolveConnectionName.d.ts.map +1 -0
- package/dist/core/connection/resolveConnectionName.js +47 -0
- package/dist/core/connection/resolveConnectionName.js.map +1 -0
- package/dist/core/model/BaseModel.d.ts +247 -0
- package/dist/core/model/BaseModel.d.ts.map +1 -0
- package/dist/core/model/BaseModel.js +165 -0
- package/dist/core/model/BaseModel.js.map +1 -0
- package/dist/core/model/BaseModelSafeFinderStatics.d.ts +33 -0
- package/dist/core/model/BaseModelSafeFinderStatics.d.ts.map +1 -0
- package/dist/core/model/BaseModelSafeFinderStatics.js +87 -0
- package/dist/core/model/BaseModelSafeFinderStatics.js.map +1 -0
- package/dist/core/model/CoreModel.d.ts +134 -0
- package/dist/core/model/CoreModel.d.ts.map +1 -0
- package/dist/core/model/CoreModel.js +541 -0
- package/dist/core/model/CoreModel.js.map +1 -0
- package/dist/core/model/CoreModelPersistenceState.d.ts +36 -0
- package/dist/core/model/CoreModelPersistenceState.d.ts.map +1 -0
- package/dist/core/model/CoreModelPersistenceState.js +141 -0
- package/dist/core/model/CoreModelPersistenceState.js.map +1 -0
- package/dist/core/model/CoreModelSafeFinderSupport.d.ts +5 -0
- package/dist/core/model/CoreModelSafeFinderSupport.d.ts.map +1 -0
- package/dist/core/model/CoreModelSafeFinderSupport.js +15 -0
- package/dist/core/model/CoreModelSafeFinderSupport.js.map +1 -0
- package/dist/core/model/CoreModelValidationEvents.d.ts +24 -0
- package/dist/core/model/CoreModelValidationEvents.d.ts.map +1 -0
- package/dist/core/model/CoreModelValidationEvents.js +45 -0
- package/dist/core/model/CoreModelValidationEvents.js.map +1 -0
- package/dist/core/model/SafeFinder.d.ts +46 -0
- package/dist/core/model/SafeFinder.d.ts.map +1 -0
- package/dist/core/model/SafeFinder.js +223 -0
- package/dist/core/model/SafeFinder.js.map +1 -0
- package/dist/core/orm/Relation.d.ts +47 -0
- package/dist/core/orm/Relation.d.ts.map +1 -0
- package/dist/core/orm/Relation.js +62 -0
- package/dist/core/orm/Relation.js.map +1 -0
- package/dist/core/orm/mixins/CastsMixin.d.ts +18 -0
- package/dist/core/orm/mixins/CastsMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/CastsMixin.js +125 -0
- package/dist/core/orm/mixins/CastsMixin.js.map +1 -0
- package/dist/core/orm/mixins/EagerLoadingMixin.d.ts +19 -0
- package/dist/core/orm/mixins/EagerLoadingMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/EagerLoadingMixin.js +137 -0
- package/dist/core/orm/mixins/EagerLoadingMixin.js.map +1 -0
- package/dist/core/orm/mixins/HooksMixin.d.ts +16 -0
- package/dist/core/orm/mixins/HooksMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/HooksMixin.js +95 -0
- package/dist/core/orm/mixins/HooksMixin.js.map +1 -0
- package/dist/core/orm/mixins/MorphRegistry.d.ts +47 -0
- package/dist/core/orm/mixins/MorphRegistry.d.ts.map +1 -0
- package/dist/core/orm/mixins/MorphRegistry.js +67 -0
- package/dist/core/orm/mixins/MorphRegistry.js.map +1 -0
- package/dist/core/orm/mixins/MorphableMixin.d.ts +29 -0
- package/dist/core/orm/mixins/MorphableMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/MorphableMixin.js +93 -0
- package/dist/core/orm/mixins/MorphableMixin.js.map +1 -0
- package/dist/core/orm/mixins/PivotHelperMixin.d.ts +26 -0
- package/dist/core/orm/mixins/PivotHelperMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/PivotHelperMixin.js +102 -0
- package/dist/core/orm/mixins/PivotHelperMixin.js.map +1 -0
- package/dist/core/orm/mixins/QueryCacheMixin.d.ts +23 -0
- package/dist/core/orm/mixins/QueryCacheMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/QueryCacheMixin.js +172 -0
- package/dist/core/orm/mixins/QueryCacheMixin.js.map +1 -0
- package/dist/core/orm/mixins/ScopeMixin.d.ts +20 -0
- package/dist/core/orm/mixins/ScopeMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/ScopeMixin.js +72 -0
- package/dist/core/orm/mixins/ScopeMixin.js.map +1 -0
- package/dist/core/orm/mixins/SerializeMixin.d.ts +44 -0
- package/dist/core/orm/mixins/SerializeMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/SerializeMixin.js +80 -0
- package/dist/core/orm/mixins/SerializeMixin.js.map +1 -0
- package/dist/core/orm/mixins/SoftDeletesMixin.d.ts +22 -0
- package/dist/core/orm/mixins/SoftDeletesMixin.d.ts.map +1 -0
- package/dist/core/orm/mixins/SoftDeletesMixin.js +146 -0
- package/dist/core/orm/mixins/SoftDeletesMixin.js.map +1 -0
- package/dist/core/orm/mixins/utils/BaseMethodResolver.d.ts +8 -0
- package/dist/core/orm/mixins/utils/BaseMethodResolver.d.ts.map +1 -0
- package/dist/core/orm/mixins/utils/BaseMethodResolver.js +26 -0
- package/dist/core/orm/mixins/utils/BaseMethodResolver.js.map +1 -0
- package/dist/core/orm/mixins/utils/HookStore.d.ts +26 -0
- package/dist/core/orm/mixins/utils/HookStore.d.ts.map +1 -0
- package/dist/core/orm/mixins/utils/HookStore.js +78 -0
- package/dist/core/orm/mixins/utils/HookStore.js.map +1 -0
- package/dist/core/orm/mixins/utils/ModelRegistry.d.ts +33 -0
- package/dist/core/orm/mixins/utils/ModelRegistry.d.ts.map +1 -0
- package/dist/core/orm/mixins/utils/ModelRegistry.js +87 -0
- package/dist/core/orm/mixins/utils/ModelRegistry.js.map +1 -0
- package/dist/core/orm/mixins/utils/modelRegistration.d.ts +9 -0
- package/dist/core/orm/mixins/utils/modelRegistration.d.ts.map +1 -0
- package/dist/core/orm/mixins/utils/modelRegistration.js +26 -0
- package/dist/core/orm/mixins/utils/modelRegistration.js.map +1 -0
- package/dist/core/orm/relations/BelongsTo.d.ts +6 -0
- package/dist/core/orm/relations/BelongsTo.d.ts.map +1 -0
- package/dist/core/orm/relations/BelongsTo.js +70 -0
- package/dist/core/orm/relations/BelongsTo.js.map +1 -0
- package/dist/core/orm/relations/BelongsToMany.d.ts +14 -0
- package/dist/core/orm/relations/BelongsToMany.d.ts.map +1 -0
- package/dist/core/orm/relations/BelongsToMany.js +245 -0
- package/dist/core/orm/relations/BelongsToMany.js.map +1 -0
- package/dist/core/orm/relations/HasMany.d.ts +6 -0
- package/dist/core/orm/relations/HasMany.d.ts.map +1 -0
- package/dist/core/orm/relations/HasMany.js +75 -0
- package/dist/core/orm/relations/HasMany.js.map +1 -0
- package/dist/core/orm/relations/HasOne.d.ts +6 -0
- package/dist/core/orm/relations/HasOne.d.ts.map +1 -0
- package/dist/core/orm/relations/HasOne.js +71 -0
- package/dist/core/orm/relations/HasOne.js.map +1 -0
- package/dist/core/orm/relations/MorphMany.d.ts +9 -0
- package/dist/core/orm/relations/MorphMany.d.ts.map +1 -0
- package/dist/core/orm/relations/MorphMany.js +107 -0
- package/dist/core/orm/relations/MorphMany.js.map +1 -0
- package/dist/core/orm/relations/MorphOne.d.ts +9 -0
- package/dist/core/orm/relations/MorphOne.d.ts.map +1 -0
- package/dist/core/orm/relations/MorphOne.js +101 -0
- package/dist/core/orm/relations/MorphOne.js.map +1 -0
- package/dist/core/orm/relations/MorphTo.d.ts +9 -0
- package/dist/core/orm/relations/MorphTo.d.ts.map +1 -0
- package/dist/core/orm/relations/MorphTo.js +85 -0
- package/dist/core/orm/relations/MorphTo.js.map +1 -0
- package/dist/core/schema/SQLDialect.d.ts +22 -0
- package/dist/core/schema/SQLDialect.d.ts.map +1 -0
- package/dist/core/schema/SQLDialect.js +38 -0
- package/dist/core/schema/SQLDialect.js.map +1 -0
- package/dist/core/schema/SchemaBlueprint.d.ts +61 -0
- package/dist/core/schema/SchemaBlueprint.d.ts.map +1 -0
- package/dist/core/schema/SchemaBlueprint.js +62 -0
- package/dist/core/schema/SchemaBlueprint.js.map +1 -0
- package/dist/core/schema/SchemaBuilder.d.ts +29 -0
- package/dist/core/schema/SchemaBuilder.d.ts.map +1 -0
- package/dist/core/schema/SchemaBuilder.js +661 -0
- package/dist/core/schema/SchemaBuilder.js.map +1 -0
- package/dist/core/schema/SchemaValidator.d.ts +23 -0
- package/dist/core/schema/SchemaValidator.d.ts.map +1 -0
- package/dist/core/schema/SchemaValidator.js +75 -0
- package/dist/core/schema/SchemaValidator.js.map +1 -0
- package/dist/core/security/AbstractSecurity.d.ts +24 -0
- package/dist/core/security/AbstractSecurity.d.ts.map +1 -0
- package/dist/core/security/AbstractSecurity.js +58 -0
- package/dist/core/security/AbstractSecurity.js.map +1 -0
- package/dist/core/security/EnvKeySecurity.d.ts +11 -0
- package/dist/core/security/EnvKeySecurity.d.ts.map +1 -0
- package/dist/core/security/EnvKeySecurity.js +46 -0
- package/dist/core/security/EnvKeySecurity.js.map +1 -0
- package/dist/core/security/NoSecurity.d.ts +10 -0
- package/dist/core/security/NoSecurity.d.ts.map +1 -0
- package/dist/core/security/NoSecurity.js +18 -0
- package/dist/core/security/NoSecurity.js.map +1 -0
- package/dist/core/security/SecretRedactor.d.ts +4 -0
- package/dist/core/security/SecretRedactor.d.ts.map +1 -0
- package/dist/core/security/SecretRedactor.js +60 -0
- package/dist/core/security/SecretRedactor.js.map +1 -0
- package/dist/core/security/SecurityContract.d.ts +13 -0
- package/dist/core/security/SecurityContract.d.ts.map +1 -0
- package/dist/core/security/SecurityContract.js +3 -0
- package/dist/core/security/SecurityContract.js.map +1 -0
- package/dist/core/security/SecurityFactory.d.ts +9 -0
- package/dist/core/security/SecurityFactory.d.ts.map +1 -0
- package/dist/core/security/SecurityFactory.js +29 -0
- package/dist/core/security/SecurityFactory.js.map +1 -0
- package/dist/core/security/index.d.ts +6 -0
- package/dist/core/security/index.d.ts.map +1 -0
- package/dist/core/security/index.js +22 -0
- package/dist/core/security/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/package.json +104 -0
- package/src/cli/templates/controller.tpl +80 -0
- package/src/cli/templates/factory.tpl +14 -0
- package/src/cli/templates/migration.tpl +36 -0
- package/src/cli/templates/model-registry.tpl +16 -0
- package/src/cli/templates/model.tpl +95 -0
- package/src/cli/templates/pivot-factory.tpl +85 -0
- package/src/cli/templates/seed.tpl +20 -0
- package/src/cli/templates/service.tpl +40 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { BaseModel } from "../../../core/model/BaseModel";
|
|
2
|
+
/** Plain object for attributes */
|
|
3
|
+
export type PlainObject = Record<string, unknown>;
|
|
4
|
+
/** Constructor helper */
|
|
5
|
+
export type ModelCtor<T> = new (...args: unknown[]) => T;
|
|
6
|
+
/** Factory constructor type */
|
|
7
|
+
export type FactoryCtor<K extends BaseModel> = new () => Factory<K>;
|
|
8
|
+
/** Shape of models supporting instance create() */
|
|
9
|
+
export interface InstanceCreatable {
|
|
10
|
+
create(data: PlainObject): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/** Shape of models supporting instance save() */
|
|
13
|
+
export interface InstanceSavable {
|
|
14
|
+
save(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** Shape of static creatable constructors */
|
|
17
|
+
export interface StaticCreatableCtor<T> {
|
|
18
|
+
create(data: PlainObject): Promise<T>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 🧩 Base Factory
|
|
22
|
+
* Fully strict, no `any` used anywhere.
|
|
23
|
+
*/
|
|
24
|
+
export declare abstract class Factory<T extends BaseModel> {
|
|
25
|
+
/** Model constructor reference */
|
|
26
|
+
abstract model: ModelCtor<T>;
|
|
27
|
+
/** Faker instance */
|
|
28
|
+
protected faker: import("@faker-js/faker").Faker;
|
|
29
|
+
/**
|
|
30
|
+
* Must return fake attributes.
|
|
31
|
+
* Index helps create sequences (createMany)
|
|
32
|
+
*/
|
|
33
|
+
abstract definition(index?: number): PlainObject;
|
|
34
|
+
/**
|
|
35
|
+
* Optional hooks
|
|
36
|
+
*/
|
|
37
|
+
beforeCreate?(attrs: Partial<T>, index: number): Promise<Partial<T> | void>;
|
|
38
|
+
afterCreate?(instance: T): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Create one record
|
|
41
|
+
*/
|
|
42
|
+
create(attrs?: Partial<T>, index?: number): Promise<T>;
|
|
43
|
+
/**
|
|
44
|
+
* 🔁 Create many with optional concurrency
|
|
45
|
+
*/
|
|
46
|
+
createMany(count: number, callback?: (model: T, index: number) => void | Promise<void>, concurrency?: number): Promise<T[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Helper: create related records
|
|
49
|
+
*/
|
|
50
|
+
protected related<K extends BaseModel>(factoryOrCtor: Factory<K> | FactoryCtor<K>, count?: number): Promise<K | K[]>;
|
|
51
|
+
/**
|
|
52
|
+
* Helper: create pivot relations
|
|
53
|
+
*/
|
|
54
|
+
protected relatedPivot<K extends BaseModel>(factory: {
|
|
55
|
+
createPivot: (foreignId: string | number, relatedIds: (string | number)[], extra?: Record<string, unknown>) => Promise<void>;
|
|
56
|
+
}, pivotTable: string, foreignKey: string, relatedKey: string, foreignId: string | number, relatedIds: (string | number)[], extraPivotAttrs?: Record<string, unknown>): Promise<void>;
|
|
57
|
+
private hasInstanceCreate;
|
|
58
|
+
private hasStaticCreate;
|
|
59
|
+
private hasInstanceSave;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=Factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Factory.d.ts","s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"__esModule", { value: true });
|
|
3
|
+
exports.Factory = void 0;
|
|
4
|
+
// src/cli/utils/factories/Factory.ts
|
|
5
|
+
const faker_1 = require("@faker-js/faker");
|
|
6
|
+
/**
|
|
7
|
+
* 🧩 Base Factory
|
|
8
|
+
* Fully strict, no `any` used anywhere.
|
|
9
|
+
*/
|
|
10
|
+
class Factory {
|
|
11
|
+
constructor() {
|
|
12
|
+
/** Faker instance */
|
|
13
|
+
this.faker = faker_1.faker;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Create one record
|
|
17
|
+
*/
|
|
18
|
+
async create(attrs = {}, index = 0) {
|
|
19
|
+
const base = this.definition(index);
|
|
20
|
+
const merged = { ...base, ...attrs };
|
|
21
|
+
if (this.beforeCreate) {
|
|
22
|
+
const modified = await this.beforeCreate(merged, index);
|
|
23
|
+
if (modified && typeof modified === "object") {
|
|
24
|
+
Object.assign(merged, modified);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
// Always instantiate the model
|
|
28
|
+
let instance = new this.model();
|
|
29
|
+
// Case 1: Instance has create()
|
|
30
|
+
if (this.hasInstanceCreate(instance)) {
|
|
31
|
+
const created = await instance.create(merged);
|
|
32
|
+
if (created) {
|
|
33
|
+
instance = created;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
// Case 2: Static create()
|
|
37
|
+
else if (this.hasStaticCreate(this.model)) {
|
|
38
|
+
const created = await this.model.create(merged);
|
|
39
|
+
// if static create returns an instance, override
|
|
40
|
+
return created;
|
|
41
|
+
}
|
|
42
|
+
// Case 3: Instance has save()
|
|
43
|
+
else if (this.hasInstanceSave(instance)) {
|
|
44
|
+
Object.assign(instance, merged);
|
|
45
|
+
await instance.save();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
throw new Error(`Model '${this.model.name}' has no valid create/save method.`);
|
|
49
|
+
}
|
|
50
|
+
if (this.afterCreate) {
|
|
51
|
+
await this.afterCreate(instance);
|
|
52
|
+
}
|
|
53
|
+
return instance;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* 🔁 Create many with optional concurrency
|
|
57
|
+
*/
|
|
58
|
+
async createMany(count, callback, concurrency = 1) {
|
|
59
|
+
const results = [];
|
|
60
|
+
const executeCreate = async (i) => {
|
|
61
|
+
const model = await this.create({}, i);
|
|
62
|
+
if (callback)
|
|
63
|
+
await callback(model, i);
|
|
64
|
+
results[i] = model;
|
|
65
|
+
};
|
|
66
|
+
if (concurrency <= 1) {
|
|
67
|
+
for (let i = 0; i < count; i++) {
|
|
68
|
+
await executeCreate(i);
|
|
69
|
+
}
|
|
70
|
+
return results;
|
|
71
|
+
}
|
|
72
|
+
let active = 0;
|
|
73
|
+
let index = 0;
|
|
74
|
+
let settled = false;
|
|
75
|
+
return new Promise((resolve, reject) => {
|
|
76
|
+
const maybeResolve = () => {
|
|
77
|
+
if (!settled && index >= count && active === 0) {
|
|
78
|
+
settled = true;
|
|
79
|
+
resolve(results);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const next = () => {
|
|
83
|
+
if (settled)
|
|
84
|
+
return;
|
|
85
|
+
while (active < concurrency && index < count && !settled) {
|
|
86
|
+
const i = index++;
|
|
87
|
+
active++;
|
|
88
|
+
void executeCreate(i)
|
|
89
|
+
.catch((err) => {
|
|
90
|
+
if (settled)
|
|
91
|
+
return;
|
|
92
|
+
settled = true;
|
|
93
|
+
reject(err);
|
|
94
|
+
})
|
|
95
|
+
.finally(() => {
|
|
96
|
+
active--;
|
|
97
|
+
if (settled)
|
|
98
|
+
return;
|
|
99
|
+
next();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
maybeResolve();
|
|
103
|
+
};
|
|
104
|
+
next();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Helper: create related records
|
|
109
|
+
*/
|
|
110
|
+
async related(factoryOrCtor, count = 1) {
|
|
111
|
+
const factory = typeof factoryOrCtor === "function"
|
|
112
|
+
? new factoryOrCtor()
|
|
113
|
+
: factoryOrCtor;
|
|
114
|
+
if (count === 1)
|
|
115
|
+
return factory.create();
|
|
116
|
+
return factory.createMany(count);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Helper: create pivot relations
|
|
120
|
+
*/
|
|
121
|
+
async relatedPivot(factory, pivotTable, foreignKey, relatedKey, foreignId, relatedIds, extraPivotAttrs) {
|
|
122
|
+
await factory.createPivot(foreignId, relatedIds, extraPivotAttrs);
|
|
123
|
+
// eslint-disable-next-line no-console
|
|
124
|
+
console.log(`🔗 [Pivot Attached] Table "${pivotTable}" (${foreignKey} → ${relatedKey})`);
|
|
125
|
+
}
|
|
126
|
+
//
|
|
127
|
+
// 👇 Type Guards — STRICT, no any
|
|
128
|
+
//
|
|
129
|
+
hasInstanceCreate(obj) {
|
|
130
|
+
return typeof obj.create === "function";
|
|
131
|
+
}
|
|
132
|
+
hasStaticCreate(ctor) {
|
|
133
|
+
return typeof ctor.create === "function";
|
|
134
|
+
}
|
|
135
|
+
hasInstanceSave(obj) {
|
|
136
|
+
return typeof obj.save === "function";
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.Factory = Factory;
|
|
140
|
+
//# sourceMappingURL=Factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Factory.js","sourceRoot":"","sources":["../../../../src/cli/utils/factories/Factory.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,2CAAwC;AA2BxC;;;GAGG;AACH,MAAsB,OAAO;IAA7B;QAIE,qBAAqB;QACX,UAAK,GAAG,aAAK,CAAC;IA4L1B,CAAC;IA9KC;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,QAAoB,EAAE,EAAE,KAAK,GAAG,CAAC;QAC5C,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QACpC,MAAM,MAAM,GAAgB,EAAE,GAAG,IAAI,EAAE,GAAG,KAAK,EAAE,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,MAAM,KAAK,UAAU,CAAC;IACjE,CAAC;IAEO,eAAe,CACrB,IAAa;QAEb,OAAO,OAAQ,IAA+B,CAAC,MAAM,KAAK,UAAU,CAAC;IACvE,CAAC;IAEO,eAAe,CACrB,GAAY;QAEZ,OAAO,OAAQ,GAAuB,CAAC,IAAI,KAAK,UAAU,CAAC;IAC7D,CAAC;CACF;AAjMD,0BAiMC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RelationDefinition } from "../../../core/schema/SchemaBlueprint";
|
|
2
|
+
export declare const FACTORY_EMPTY_MARK = "-";
|
|
3
|
+
export declare const FACTORY_STATUS_FOOTER = "\nUse factories directly via FactoryRegistry.make(<name>)\n";
|
|
4
|
+
export declare const FACTORY_GRAPH_HEADER = "\nModel Relationship Graph\n\n";
|
|
5
|
+
export declare function getFactoryRelationArrow(relation: RelationDefinition["relation"] | string): string;
|
|
6
|
+
//# sourceMappingURL=FactoryDisplay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryDisplay.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryDisplay.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAE/E,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,qBAAqB,gEAC6B,CAAC;AAChE,eAAO,MAAM,oBAAoB,mCAAmC,CAAC;AAErE,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,kBAAkB,CAAC,UAAU,CAAC,GAAG,MAAM,GAChD,MAAM,CAaR"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FACTORY_GRAPH_HEADER = exports.FACTORY_STATUS_FOOTER = exports.FACTORY_EMPTY_MARK = void 0;
|
|
7
|
+
exports.getFactoryRelationArrow = getFactoryRelationArrow;
|
|
8
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
9
|
+
exports.FACTORY_EMPTY_MARK = "-";
|
|
10
|
+
exports.FACTORY_STATUS_FOOTER = "\nUse factories directly via FactoryRegistry.make(<name>)\n";
|
|
11
|
+
exports.FACTORY_GRAPH_HEADER = "\nModel Relationship Graph\n\n";
|
|
12
|
+
function getFactoryRelationArrow(relation) {
|
|
13
|
+
switch (relation) {
|
|
14
|
+
case "belongsTo":
|
|
15
|
+
return chalk_1.default.blue("<-");
|
|
16
|
+
case "hasOne":
|
|
17
|
+
return chalk_1.default.green("->");
|
|
18
|
+
case "hasMany":
|
|
19
|
+
return chalk_1.default.green("->>");
|
|
20
|
+
case "belongsToMany":
|
|
21
|
+
return chalk_1.default.magenta("<->");
|
|
22
|
+
default:
|
|
23
|
+
return relation.startsWith("morph") ? chalk_1.default.yellow("~>") : "->";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=FactoryDisplay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryDisplay.js","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryDisplay.ts"],"names":[],"mappings":";;;;;;AAQA,0DAeC;AAvBD,kDAA0B;AAGb,QAAA,kBAAkB,GAAG,GAAG,CAAC;AACzB,QAAA,qBAAqB,GAChC,6DAA6D,CAAC;AACnD,QAAA,oBAAoB,GAAG,gCAAgC,CAAC;AAErE,SAAgB,uBAAuB,CACrC,QAAiD;IAEjD,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,eAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,KAAK,QAAQ;YACX,OAAO,eAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC3B,KAAK,SAAS;YACZ,OAAO,eAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,KAAK,eAAe;YAClB,OAAO,eAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC9B;YACE,OAAO,QAAQ,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,eAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACpE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryGraph.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryGraph.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsEH,wBAAgB,oBAAoB,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAiCnE"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* FactoryGraph
|
|
4
|
+
* Generates an ASCII relationship graph from registered factories.
|
|
5
|
+
*/
|
|
6
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.generateFactoryGraph = generateFactoryGraph;
|
|
11
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
12
|
+
const FactoryDisplay_1 = require("./FactoryDisplay");
|
|
13
|
+
const FactoryRegistry_1 = require("./FactoryRegistry");
|
|
14
|
+
function hasSchema(modelCtor) {
|
|
15
|
+
return (typeof modelCtor === "function" &&
|
|
16
|
+
Object.prototype.hasOwnProperty.call(modelCtor, "schema"));
|
|
17
|
+
}
|
|
18
|
+
function collectLinks(factoryNames) {
|
|
19
|
+
const links = [];
|
|
20
|
+
for (const factoryName of factoryNames) {
|
|
21
|
+
const factory = FactoryRegistry_1.FactoryRegistry.make(factoryName);
|
|
22
|
+
const modelCtor = factory.model;
|
|
23
|
+
const modelName = modelCtor.name.replace("Factory", "");
|
|
24
|
+
const modelInstance = new modelCtor();
|
|
25
|
+
if (!hasSchema(modelInstance.constructor)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
for (const field of Object.values(modelInstance.constructor.schema)) {
|
|
29
|
+
if (field.kind !== "relation") {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
const rel = field;
|
|
33
|
+
links.push({
|
|
34
|
+
from: modelName,
|
|
35
|
+
to: rel.model,
|
|
36
|
+
rel: rel.relation,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return links;
|
|
41
|
+
}
|
|
42
|
+
function dedupeLinks(links) {
|
|
43
|
+
return links.filter((link, index, array) => index ===
|
|
44
|
+
array.findIndex((candidate) => (candidate.from === link.from && candidate.to === link.to) ||
|
|
45
|
+
(candidate.from === link.to && candidate.to === link.from)));
|
|
46
|
+
}
|
|
47
|
+
function generateFactoryGraph(factoryNames) {
|
|
48
|
+
let output = chalk_1.default.cyanBright(FactoryDisplay_1.FACTORY_GRAPH_HEADER);
|
|
49
|
+
if (factoryNames.length === 0) {
|
|
50
|
+
return output + chalk_1.default.gray("No factories registered.\n");
|
|
51
|
+
}
|
|
52
|
+
const uniqueLinks = dedupeLinks(collectLinks(factoryNames));
|
|
53
|
+
if (uniqueLinks.length === 0) {
|
|
54
|
+
return output + chalk_1.default.gray("No relationships detected.\n");
|
|
55
|
+
}
|
|
56
|
+
const grouped = new Map();
|
|
57
|
+
for (const { from, to, rel } of uniqueLinks) {
|
|
58
|
+
if (!grouped.has(from)) {
|
|
59
|
+
grouped.set(from, []);
|
|
60
|
+
}
|
|
61
|
+
grouped.get(from).push({ to, rel });
|
|
62
|
+
}
|
|
63
|
+
for (const [node, relations] of grouped.entries()) {
|
|
64
|
+
output += chalk_1.default.greenBright(`${node}\n`);
|
|
65
|
+
for (const { to, rel } of relations) {
|
|
66
|
+
output += `${chalk_1.default.gray(` ${(0, FactoryDisplay_1.getFactoryRelationArrow)(rel)} `)}${chalk_1.default.cyan(to)} ${chalk_1.default.gray(`(${rel})`)}\n`;
|
|
67
|
+
}
|
|
68
|
+
output += "\n";
|
|
69
|
+
}
|
|
70
|
+
return output;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=FactoryGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryGraph.js","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryGraph.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;AAsEH,oDAiCC;AArGD,kDAA0B;AAK1B,qDAG0B;AAC1B,uDAAoD;AAEpD,SAAS,SAAS,CAChB,SAAkB;IAElB,OAAO,CACL,OAAO,SAAS,KAAK,UAAU;QAC/B,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAC1D,CAAC;AACJ,CAAC;AAQD,SAAS,YAAY,CAAC,YAAsB;IAC1C,MAAM,KAAK,GAAmB,EAAE,CAAC;IAEjC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,iCAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,MAAM,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC;QAChC,MAAM,SAAS,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,IAAI,SAAS,EAAE,CAAC;QAEtC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CAAC;YAC1C,SAAS;QACX,CAAC;QAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC;YACpE,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;gBAC9B,SAAS;YACX,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AI,WAAW,EAAE,CAAC;QAC5C,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACvB,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACxB,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAE,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAClD,MAAM,IAAI,eAAK,CAAC,WAAW,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC;QACzC,KAAK,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,GAAG,eAAK,CAAC,IAAI,CAAC,KAAK,IAAA,wCAAuB,EAAC,GAAG,CAAC,GAAG,CAAC,GAAG,eAAK,CAAC,IAAI,CACxE,EAAE,CACH,IAAI,eAAK,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QAClC,CAAC;QACD,MAAM,IAAI,IAAI,CAAC;IACjB,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { StorageKind } from "../ArtifactStorage";
|
|
2
|
+
/**
|
|
3
|
+
* FactoryLoader
|
|
4
|
+
* Automatically discovers and registers all factories at runtime.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* import { loadFactories } from "./FactoryLoader";
|
|
8
|
+
*
|
|
9
|
+
* After import, you can do:
|
|
10
|
+
* const userFactory = FactoryRegistry.make("UserFactory");
|
|
11
|
+
* const user = await userFactory.create();
|
|
12
|
+
*/
|
|
13
|
+
export declare function loadFactories(isTest?: boolean, options?: {
|
|
14
|
+
storageKind?: Exclude<StorageKind, "unknown" | "mixed">;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
//# sourceMappingURL=FactoryLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryLoader.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryLoader.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;;;;;;;GAUG;AAEH,wBAAsB,aAAa,CACjC,MAAM,UAAQ,EACd,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,CAAA;CAAO,GACxE,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.loadFactories = loadFactories;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const FactoryRegistry_1 = require("./FactoryRegistry");
|
|
9
|
+
/**
|
|
10
|
+
* FactoryLoader
|
|
11
|
+
* Automatically discovers and registers all factories at runtime.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* import { loadFactories } from "./FactoryLoader";
|
|
15
|
+
*
|
|
16
|
+
* After import, you can do:
|
|
17
|
+
* const userFactory = FactoryRegistry.make("UserFactory");
|
|
18
|
+
* const user = await userFactory.create();
|
|
19
|
+
*/
|
|
20
|
+
async function loadFactories(isTest = false, options = {}) {
|
|
21
|
+
console.log(chalk_1.default.cyanBright("Initializing FactoryRegistry..."));
|
|
22
|
+
try {
|
|
23
|
+
FactoryRegistry_1.FactoryRegistry.clear();
|
|
24
|
+
await FactoryRegistry_1.FactoryRegistry.autoDiscover(isTest, options);
|
|
25
|
+
const count = FactoryRegistry_1.FactoryRegistry.list().length;
|
|
26
|
+
console.log(chalk_1.default.greenBright(`Loaded ${count} factories.`));
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
console.error(chalk_1.default.red("Failed to initialize factories."));
|
|
30
|
+
if (error instanceof Error)
|
|
31
|
+
console.error(chalk_1.default.red(error.message));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Note: no auto-run here. The CLI entrypoint calls loadFactories explicitly.
|
|
35
|
+
//# sourceMappingURL=FactoryLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryLoader.js","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryLoader.ts"],"names":[],"mappings":";;;;;AAgBA,sCAgBC;AAhCD,kDAA0B;AAC1B,uDAAoD;AAGpD;;;;;;;;;;GAUG;AAEI,KAAK,UAAU,aAAa,CACjC,MAAM,GAAG,KAAK,EACd,UAAuE,EAAE;IAEzE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,UAAU,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAEjE,IAAI,CAAC;QACH,iCAAe,CAAC,KAAK,EAAE,CAAC;QACxB,MAAM,iCAAe,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAEpD,MAAM,KAAK,GAAG,iCAAe,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,WAAW,CAAC,UAAU,KAAK,aAAa,CAAC,CAAC,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC,CAAC;QAC5D,IAAI,KAAK,YAAY,KAAK;YAAE,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;IACtE,CAAC;AACH,CAAC;AAED,6EAA6E"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BaseModel } from "../../../core/model/BaseModel";
|
|
2
|
+
import { type StorageKind } from "../ArtifactStorage";
|
|
3
|
+
import type { Factory } from "./Factory";
|
|
4
|
+
export declare class FactoryRegistry {
|
|
5
|
+
private static registry;
|
|
6
|
+
static register<T extends Factory<BaseModel>>(name: string, factory: new () => T): void;
|
|
7
|
+
static registerBulk<T extends Record<string, new () => Factory<BaseModel>>>(factories: T): void;
|
|
8
|
+
static make<T extends Factory<BaseModel>>(name: string): T;
|
|
9
|
+
static makePivot<T extends Factory<BaseModel>>(name: string): T;
|
|
10
|
+
static autoDiscover(isTest?: boolean, options?: {
|
|
11
|
+
storageKind?: Exclude<StorageKind, "unknown" | "mixed">;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
static list(): string[];
|
|
14
|
+
static clear(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=FactoryRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryRegistry.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryRegistry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAmD;IAE1E,MAAM,CAAC,QAAQ,CAAC,CAAC,SAAS,OAAO,CAAC,SAAS,CAAC,EAC1C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,UAAU,CAAC,GACnB,IAAI;IASP,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,UAAU,OAAO,CAAC,SAAS,CAAC,CAAC,EACxE,SAAS,EAAE,CAAC,GACX,IAAI;IAMP,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;IAS1D,MAAM,CAAC,SAAS,CAAC,CAAC,SAAS,OAAO,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;WAOlD,YAAY,CACvB,MAAM,UAAQ,EACd,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,CAAA;KAAO,GACxE,OAAO,CAAC,IAAI,CAAC;IA2DhB,MAAM,CAAC,IAAI,IAAI,MAAM,EAAE;IAIvB,MAAM,CAAC,KAAK,IAAI,IAAI;CAGrB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FactoryRegistry = void 0;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const ArtifactRoutingReport_1 = require("../ArtifactRoutingReport");
|
|
11
|
+
const ArtifactStorage_1 = require("../ArtifactStorage");
|
|
12
|
+
const PathMap_1 = require("../PathMap");
|
|
13
|
+
const tsRuntime_1 = require("../typescript/tsRuntime");
|
|
14
|
+
class FactoryRegistry {
|
|
15
|
+
static register(name, factory) {
|
|
16
|
+
if (this.registry.has(name)) {
|
|
17
|
+
console.warn(chalk_1.default.yellow(`Factory already registered: ${name}`));
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
this.registry.set(name, factory);
|
|
21
|
+
}
|
|
22
|
+
static registerBulk(factories) {
|
|
23
|
+
for (const [key, factory] of Object.entries(factories)) {
|
|
24
|
+
this.register(key, factory);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
static make(name) {
|
|
28
|
+
const entry = this.registry.get(name);
|
|
29
|
+
if (!entry) {
|
|
30
|
+
throw new Error(`Factory '${name}' not found in registry.`);
|
|
31
|
+
}
|
|
32
|
+
return new entry();
|
|
33
|
+
}
|
|
34
|
+
static makePivot(name) {
|
|
35
|
+
const pivotName = name.endsWith("PivotFactory")
|
|
36
|
+
? name
|
|
37
|
+
: `${name}PivotFactory`;
|
|
38
|
+
return this.make(pivotName);
|
|
39
|
+
}
|
|
40
|
+
static async autoDiscover(isTest = false, options = {}) {
|
|
41
|
+
const dir = PathMap_1.PathMap.factories(isTest);
|
|
42
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
43
|
+
console.log(chalk_1.default.gray(`No factories folder found at: ${dir}`));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const files = fs_1.default.readdirSync(dir).filter((file) => file.endsWith(".ts"));
|
|
47
|
+
for (const file of files) {
|
|
48
|
+
const fullPath = path_1.default.join(dir, file);
|
|
49
|
+
try {
|
|
50
|
+
const importedModule = (0, tsRuntime_1.loadModule)(fullPath);
|
|
51
|
+
for (const [name, exported] of Object.entries(importedModule)) {
|
|
52
|
+
if (typeof exported !== "function" ||
|
|
53
|
+
!exported.name.endsWith("Factory")) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const factoryStorageKind = (0, ArtifactStorage_1.resolveFactoryStorageKindFromCtor)(exported);
|
|
57
|
+
if (options.storageKind &&
|
|
58
|
+
!(0, ArtifactStorage_1.matchesTargetStorageKind)(factoryStorageKind, options.storageKind)) {
|
|
59
|
+
const message = (0, ArtifactRoutingReport_1.summarizeSkippedArtifacts)("factory", [
|
|
60
|
+
(0, ArtifactRoutingReport_1.createTargetedArtifactDecision)(name, factoryStorageKind, options.storageKind),
|
|
61
|
+
], options.storageKind);
|
|
62
|
+
console.warn(chalk_1.default.yellow(message));
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
this.register(name, exported);
|
|
66
|
+
console.log(chalk_1.default.green(`Registered factory: ${name}`));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
console.error(chalk_1.default.red(`Failed to import factory file: ${file}`));
|
|
71
|
+
if (err instanceof Error) {
|
|
72
|
+
console.error(chalk_1.default.red(err.message));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
console.log(chalk_1.default.cyanBright("\nFactory auto-discovery complete.\n"));
|
|
77
|
+
}
|
|
78
|
+
static list() {
|
|
79
|
+
return Array.from(this.registry.keys());
|
|
80
|
+
}
|
|
81
|
+
static clear() {
|
|
82
|
+
this.registry.clear();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.FactoryRegistry = FactoryRegistry;
|
|
86
|
+
FactoryRegistry.registry = new Map();
|
|
87
|
+
//# sourceMappingURL=FactoryRegistry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FactoryRegistry.js","sourceRoot":"","sources":["../../../../src/cli/utils/factories/FactoryRegistry.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,4CAAoB;AACpB,gDAAwB;AAExB,oEAAqG;AACrG,wDAI4B;AAC5B,wCAAqC;AACrC,uDAAqD;AAGrD,MAAa,eAAe;IAG1B,MAAM,CAAC,QAAQ,CACb,IAAY,EACZ,OAAoB;QAEpB,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,IAAI,CAAC,eAAK,CAAC,MAAM,CAAC,+BAA+B,IAAI,EAAE,CAAC,CAAC,CAAC;YAClE,OAAO;QACT,CAAC;QAED,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,OAAuC,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,YAAY,CAC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O,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,UAAU,CAAC,sCAAsC,CAAC,CAAC,CAAC;IACxE,CAAC;IAED,MAAM,CAAC,IAAI;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,CAAC,KAAK;QACV,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;;AA3GH,0CA4GC;AA3GgB,wBAAQ,GAAG,IAAI,GAAG,EAAwC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function writeFileSafe(filePath: string, content: string): boolean;
|
|
2
|
+
/**
|
|
3
|
+
* Utility: overwriteFile
|
|
4
|
+
* Forces file writing (replaces existing file).
|
|
5
|
+
*/
|
|
6
|
+
export declare function overwriteFile(filePath: string, content: string): boolean;
|
|
7
|
+
//# sourceMappingURL=fileWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileWriter.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/fileWriter.ts"],"names":[],"mappings":"AAwBA,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAgBxE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAUxE"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeFileSafe = writeFileSafe;
|
|
7
|
+
exports.overwriteFile = overwriteFile;
|
|
8
|
+
const fs_1 = __importDefault(require("fs"));
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
11
|
+
/**
|
|
12
|
+
* Utility: writeFileSafe
|
|
13
|
+
* Creates directories recursively and writes the file safely.
|
|
14
|
+
* Returns true if created, false if skipped.
|
|
15
|
+
*/
|
|
16
|
+
function ensureParentDirectory(filePath) {
|
|
17
|
+
const dir = path_1.default.dirname(filePath);
|
|
18
|
+
if (!fs_1.default.existsSync(dir)) {
|
|
19
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
20
|
+
console.log(chalk_1.default.cyan(`Created directory: ${dir}`));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function logFileWriteError(action, filePath, err) {
|
|
24
|
+
console.error(chalk_1.default.red(`Error ${action} file: ${filePath}`));
|
|
25
|
+
if (err instanceof Error) {
|
|
26
|
+
console.error(chalk_1.default.red(`Reason: ${err.message}`));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function writeFileSafe(filePath, content) {
|
|
30
|
+
try {
|
|
31
|
+
ensureParentDirectory(filePath);
|
|
32
|
+
if (fs_1.default.existsSync(filePath)) {
|
|
33
|
+
console.log(chalk_1.default.yellow(`File already exists, skipped: ${filePath}`));
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
fs_1.default.writeFileSync(filePath, content, "utf8");
|
|
37
|
+
console.log(chalk_1.default.greenBright(`Created file: ${filePath}`));
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
logFileWriteError("writing", filePath, err);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Utility: overwriteFile
|
|
47
|
+
* Forces file writing (replaces existing file).
|
|
48
|
+
*/
|
|
49
|
+
function overwriteFile(filePath, content) {
|
|
50
|
+
try {
|
|
51
|
+
ensureParentDirectory(filePath);
|
|
52
|
+
fs_1.default.writeFileSync(filePath, content, "utf8");
|
|
53
|
+
console.log(chalk_1.default.green(`Overwritten: ${filePath}`));
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
logFileWriteError("overwriting", filePath, err);
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=fileWriter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fileWriter.js","sourceRoot":"","sources":["../../../src/cli/utils/fileWriter.ts"],"names":[],"mappings":";;;;;AAwBA,sCAgBC;AAMD,sCAUC;AAxDD,4CAAoB;AACpB,gDAAwB;AACxB,kDAA0B;AAE1B;;;;GAIG;AACH,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,MAAM,GAAG,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACnC,IAAI,CAAC,YAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACxB,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,sBAAsB,GAAG,EAAE,CAAC,CAAC,CAAC;IACvD,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAiC,EAAE,QAAgB,EAAE,GAAY;IAC1F,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,SAAS,MAAM,UAAU,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC9D,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,SAAgB,aAAa,CAAC,QAAgB,EAAE,OAAe;IAC7D,IAAI,CAAC;QACH,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAEhC,IAAI,YAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,iCAAiC,QAAQ,EAAE,CAAC,CAAC,CAAC;YACvE,OAAO,KAAK,CAAC;QACf,CAAC;QAED,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,WAAW,CAAC,iBAAiB,QAAQ,EAAE,CAAC,CAAC,CAAC;QAC5D,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,iBAAiB,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,aAAa,CAAC,QAAgB,EAAE,OAAe;IAC7D,IAAI,CAAC;QACH,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAChC,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,gBAAgB,QAAQ,EAAE,CAAC,CAAC,CAAC;QACrD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,iBAAiB,CAAC,aAAa,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { DriverAdapter } from "../../../core/connection/DriverAdapter";
|
|
2
|
+
export type SqlMigrationDriver = "mysql" | "pg" | "sqlite";
|
|
3
|
+
export interface MigrationLockStrategy {
|
|
4
|
+
ensureBootstrap(db: DriverAdapter, driver: SqlMigrationDriver): Promise<void>;
|
|
5
|
+
acquire(db: DriverAdapter, owner: string): Promise<void>;
|
|
6
|
+
release(db: DriverAdapter, owner: string, outcome?: {
|
|
7
|
+
success?: boolean;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
declare class NativeSqlMigrationLockStrategy implements MigrationLockStrategy {
|
|
11
|
+
ensureBootstrap(): Promise<void>;
|
|
12
|
+
acquire(db: DriverAdapter, owner: string): Promise<void>;
|
|
13
|
+
release(db: DriverAdapter, owner: string, outcome?: {
|
|
14
|
+
success?: boolean;
|
|
15
|
+
}): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
export declare function getMigrationLockStrategy(): MigrationLockStrategy;
|
|
18
|
+
export declare function setMigrationLockStrategy(strategy: MigrationLockStrategy): void;
|
|
19
|
+
export declare function resetMigrationLockStrategy(): void;
|
|
20
|
+
export { NativeSqlMigrationLockStrategy };
|
|
21
|
+
//# sourceMappingURL=MigrationLockStrategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MigrationLockStrategy.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/migrations/MigrationLockStrategy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wCAAwC,CAAC;AAG5E,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,IAAI,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,eAAe,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9E,OAAO,CAAC,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,OAAO,CACL,EAAE,EAAE,aAAa,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAC9B,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAiCD,cAAM,8BAA+B,YAAW,qBAAqB;IAC7D,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAIhC,OAAO,CAAC,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA2CxD,OAAO,CACX,EAAE,EAAE,aAAa,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,GAC9B,OAAO,CAAC,IAAI,CAAC;CAkDjB;AAID,wBAAgB,wBAAwB,IAAI,qBAAqB,CAEhE;AAED,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAE9E;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED,OAAO,EAAE,8BAA8B,EAAE,CAAC"}
|