@zintrust/core 0.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 (494) hide show
  1. package/bin/z.d.ts +7 -0
  2. package/bin/z.d.ts.map +1 -0
  3. package/bin/z.js +6 -0
  4. package/bin/zin.d.ts +7 -0
  5. package/bin/zin.d.ts.map +1 -0
  6. package/bin/zin.js +6 -0
  7. package/bin/zintrust-microservices.d.ts +7 -0
  8. package/bin/zintrust-microservices.d.ts.map +1 -0
  9. package/bin/zintrust-microservices.js +165 -0
  10. package/bin/zintrust.d.ts +9 -0
  11. package/bin/zintrust.d.ts.map +1 -0
  12. package/bin/zintrust.js +51 -0
  13. package/bin/zt.d.ts +7 -0
  14. package/bin/zt.d.ts.map +1 -0
  15. package/bin/zt.js +6 -0
  16. package/package.json +80 -0
  17. package/src/boot/Application.d.ts +31 -0
  18. package/src/boot/Application.d.ts.map +1 -0
  19. package/src/boot/Application.js +159 -0
  20. package/src/boot/Server.d.ts +23 -0
  21. package/src/boot/Server.d.ts.map +1 -0
  22. package/src/boot/Server.js +236 -0
  23. package/src/boot/bootstrap.d.ts +7 -0
  24. package/src/boot/bootstrap.d.ts.map +1 -0
  25. package/src/boot/bootstrap.js +64 -0
  26. package/src/builder/BundleOptimizer.d.ts +42 -0
  27. package/src/builder/BundleOptimizer.d.ts.map +1 -0
  28. package/src/builder/BundleOptimizer.js +356 -0
  29. package/src/cache/Cache.d.ts +26 -0
  30. package/src/cache/Cache.d.ts.map +1 -0
  31. package/src/cache/Cache.js +89 -0
  32. package/src/cache/CacheDriver.d.ts +28 -0
  33. package/src/cache/CacheDriver.d.ts.map +1 -0
  34. package/src/cache/CacheDriver.js +6 -0
  35. package/src/cache/drivers/KVDriver.d.ts +12 -0
  36. package/src/cache/drivers/KVDriver.d.ts.map +1 -0
  37. package/src/cache/drivers/KVDriver.js +54 -0
  38. package/src/cache/drivers/MemoryDriver.d.ts +12 -0
  39. package/src/cache/drivers/MemoryDriver.d.ts.map +1 -0
  40. package/src/cache/drivers/MemoryDriver.js +50 -0
  41. package/src/cache/drivers/MongoDriver.d.ts +17 -0
  42. package/src/cache/drivers/MongoDriver.d.ts.map +1 -0
  43. package/src/cache/drivers/MongoDriver.js +80 -0
  44. package/src/cache/drivers/RedisDriver.d.ts +12 -0
  45. package/src/cache/drivers/RedisDriver.d.ts.map +1 -0
  46. package/src/cache/drivers/RedisDriver.js +79 -0
  47. package/src/cli/BaseCommand.d.ts +39 -0
  48. package/src/cli/BaseCommand.d.ts.map +1 -0
  49. package/src/cli/BaseCommand.js +58 -0
  50. package/src/cli/CLI.d.ts +21 -0
  51. package/src/cli/CLI.d.ts.map +1 -0
  52. package/src/cli/CLI.js +203 -0
  53. package/src/cli/ErrorHandler.d.ts +23 -0
  54. package/src/cli/ErrorHandler.d.ts.map +1 -0
  55. package/src/cli/ErrorHandler.js +95 -0
  56. package/src/cli/PromptHelper.d.ts +47 -0
  57. package/src/cli/PromptHelper.d.ts.map +1 -0
  58. package/src/cli/PromptHelper.js +155 -0
  59. package/src/cli/commands/AddCommand.d.ts +15 -0
  60. package/src/cli/commands/AddCommand.d.ts.map +1 -0
  61. package/src/cli/commands/AddCommand.js +817 -0
  62. package/src/cli/commands/ConfigCommand.d.ts +15 -0
  63. package/src/cli/commands/ConfigCommand.d.ts.map +1 -0
  64. package/src/cli/commands/ConfigCommand.js +273 -0
  65. package/src/cli/commands/D1MigrateCommand.d.ts +15 -0
  66. package/src/cli/commands/D1MigrateCommand.d.ts.map +1 -0
  67. package/src/cli/commands/D1MigrateCommand.js +73 -0
  68. package/src/cli/commands/DebugCommand.d.ts +15 -0
  69. package/src/cli/commands/DebugCommand.d.ts.map +1 -0
  70. package/src/cli/commands/DebugCommand.js +52 -0
  71. package/src/cli/commands/FixCommand.d.ts +15 -0
  72. package/src/cli/commands/FixCommand.d.ts.map +1 -0
  73. package/src/cli/commands/FixCommand.js +80 -0
  74. package/src/cli/commands/KeyGenerateCommand.d.ts +9 -0
  75. package/src/cli/commands/KeyGenerateCommand.d.ts.map +1 -0
  76. package/src/cli/commands/KeyGenerateCommand.js +76 -0
  77. package/src/cli/commands/LogsCommand.d.ts +19 -0
  78. package/src/cli/commands/LogsCommand.d.ts.map +1 -0
  79. package/src/cli/commands/LogsCommand.js +185 -0
  80. package/src/cli/commands/MigrateCommand.d.ts +15 -0
  81. package/src/cli/commands/MigrateCommand.d.ts.map +1 -0
  82. package/src/cli/commands/MigrateCommand.js +56 -0
  83. package/src/cli/commands/NewCommand.d.ts +32 -0
  84. package/src/cli/commands/NewCommand.d.ts.map +1 -0
  85. package/src/cli/commands/NewCommand.js +280 -0
  86. package/src/cli/commands/PluginCommand.d.ts +9 -0
  87. package/src/cli/commands/PluginCommand.d.ts.map +1 -0
  88. package/src/cli/commands/PluginCommand.js +94 -0
  89. package/src/cli/commands/PrepareCommand.d.ts +8 -0
  90. package/src/cli/commands/PrepareCommand.d.ts.map +1 -0
  91. package/src/cli/commands/PrepareCommand.js +51 -0
  92. package/src/cli/commands/QACommand.d.ts +33 -0
  93. package/src/cli/commands/QACommand.d.ts.map +1 -0
  94. package/src/cli/commands/QACommand.js +490 -0
  95. package/src/cli/commands/SimulateCommand.d.ts +12 -0
  96. package/src/cli/commands/SimulateCommand.d.ts.map +1 -0
  97. package/src/cli/commands/SimulateCommand.js +79 -0
  98. package/src/cli/commands/StartCommand.d.ts +5 -0
  99. package/src/cli/commands/StartCommand.d.ts.map +1 -0
  100. package/src/cli/commands/StartCommand.js +227 -0
  101. package/src/cli/commands/index.d.ts +11 -0
  102. package/src/cli/commands/index.d.ts.map +1 -0
  103. package/src/cli/commands/index.js +10 -0
  104. package/src/cli/config/ConfigManager.d.ts +42 -0
  105. package/src/cli/config/ConfigManager.d.ts.map +1 -0
  106. package/src/cli/config/ConfigManager.js +175 -0
  107. package/src/cli/config/ConfigSchema.d.ts +195 -0
  108. package/src/cli/config/ConfigSchema.d.ts.map +1 -0
  109. package/src/cli/config/ConfigSchema.js +171 -0
  110. package/src/cli/config/ConfigValidator.d.ts +41 -0
  111. package/src/cli/config/ConfigValidator.d.ts.map +1 -0
  112. package/src/cli/config/ConfigValidator.js +200 -0
  113. package/src/cli/config/index.d.ts +8 -0
  114. package/src/cli/config/index.d.ts.map +1 -0
  115. package/src/cli/config/index.js +7 -0
  116. package/src/cli/debug/Dashboard.d.ts +34 -0
  117. package/src/cli/debug/Dashboard.d.ts.map +1 -0
  118. package/src/cli/debug/Dashboard.js +152 -0
  119. package/src/cli/index.d.ts +14 -0
  120. package/src/cli/index.d.ts.map +1 -0
  121. package/src/cli/index.js +14 -0
  122. package/src/cli/logger/Logger.d.ts +43 -0
  123. package/src/cli/logger/Logger.d.ts.map +1 -0
  124. package/src/cli/logger/Logger.js +137 -0
  125. package/src/cli/scaffolding/ControllerGenerator.d.ts +44 -0
  126. package/src/cli/scaffolding/ControllerGenerator.d.ts.map +1 -0
  127. package/src/cli/scaffolding/ControllerGenerator.js +540 -0
  128. package/src/cli/scaffolding/FactoryGenerator.d.ts +47 -0
  129. package/src/cli/scaffolding/FactoryGenerator.d.ts.map +1 -0
  130. package/src/cli/scaffolding/FactoryGenerator.js +356 -0
  131. package/src/cli/scaffolding/FeatureScaffolder.d.ts +40 -0
  132. package/src/cli/scaffolding/FeatureScaffolder.d.ts.map +1 -0
  133. package/src/cli/scaffolding/FeatureScaffolder.js +747 -0
  134. package/src/cli/scaffolding/FileGenerator.d.ts +31 -0
  135. package/src/cli/scaffolding/FileGenerator.d.ts.map +1 -0
  136. package/src/cli/scaffolding/FileGenerator.js +222 -0
  137. package/src/cli/scaffolding/MigrationGenerator.d.ts +35 -0
  138. package/src/cli/scaffolding/MigrationGenerator.d.ts.map +1 -0
  139. package/src/cli/scaffolding/MigrationGenerator.js +257 -0
  140. package/src/cli/scaffolding/ModelGenerator.d.ts +81 -0
  141. package/src/cli/scaffolding/ModelGenerator.d.ts.map +1 -0
  142. package/src/cli/scaffolding/ModelGenerator.js +249 -0
  143. package/src/cli/scaffolding/ProjectScaffolder.d.ts +66 -0
  144. package/src/cli/scaffolding/ProjectScaffolder.d.ts.map +1 -0
  145. package/src/cli/scaffolding/ProjectScaffolder.js +439 -0
  146. package/src/cli/scaffolding/RequestFactoryGenerator.d.ts +50 -0
  147. package/src/cli/scaffolding/RequestFactoryGenerator.d.ts.map +1 -0
  148. package/src/cli/scaffolding/RequestFactoryGenerator.js +465 -0
  149. package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts +43 -0
  150. package/src/cli/scaffolding/ResponseFactoryGenerator.d.ts.map +1 -0
  151. package/src/cli/scaffolding/ResponseFactoryGenerator.js +321 -0
  152. package/src/cli/scaffolding/RouteGenerator.d.ts +66 -0
  153. package/src/cli/scaffolding/RouteGenerator.d.ts.map +1 -0
  154. package/src/cli/scaffolding/RouteGenerator.js +306 -0
  155. package/src/cli/scaffolding/SeederGenerator.d.ts +47 -0
  156. package/src/cli/scaffolding/SeederGenerator.d.ts.map +1 -0
  157. package/src/cli/scaffolding/SeederGenerator.js +286 -0
  158. package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts +40 -0
  159. package/src/cli/scaffolding/ServiceIntegrationTestGenerator.d.ts.map +1 -0
  160. package/src/cli/scaffolding/ServiceIntegrationTestGenerator.js +267 -0
  161. package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts +45 -0
  162. package/src/cli/scaffolding/ServiceRequestFactoryGenerator.d.ts.map +1 -0
  163. package/src/cli/scaffolding/ServiceRequestFactoryGenerator.js +397 -0
  164. package/src/cli/scaffolding/ServiceScaffolder.d.ts +45 -0
  165. package/src/cli/scaffolding/ServiceScaffolder.d.ts.map +1 -0
  166. package/src/cli/scaffolding/ServiceScaffolder.js +367 -0
  167. package/src/cli/scaffolding/TemplateEngine.d.ts +35 -0
  168. package/src/cli/scaffolding/TemplateEngine.d.ts.map +1 -0
  169. package/src/cli/scaffolding/TemplateEngine.js +379 -0
  170. package/src/cli/scaffolding/WorkflowGenerator.d.ts +31 -0
  171. package/src/cli/scaffolding/WorkflowGenerator.d.ts.map +1 -0
  172. package/src/cli/scaffolding/WorkflowGenerator.js +193 -0
  173. package/src/cli/scaffolding/index.d.ts +34 -0
  174. package/src/cli/scaffolding/index.d.ts.map +1 -0
  175. package/src/cli/scaffolding/index.js +18 -0
  176. package/src/cli/utils/DistPackager.d.ts +8 -0
  177. package/src/cli/utils/DistPackager.d.ts.map +1 -0
  178. package/src/cli/utils/DistPackager.js +94 -0
  179. package/src/cli/utils/EnvFileLoader.d.ts +21 -0
  180. package/src/cli/utils/EnvFileLoader.d.ts.map +1 -0
  181. package/src/cli/utils/EnvFileLoader.js +166 -0
  182. package/src/cli/utils/spawn.d.ts +11 -0
  183. package/src/cli/utils/spawn.d.ts.map +1 -0
  184. package/src/cli/utils/spawn.js +81 -0
  185. package/src/common/index.d.ts +87 -0
  186. package/src/common/index.d.ts.map +1 -0
  187. package/src/common/index.js +207 -0
  188. package/src/config/SecretsManager.d.ts +122 -0
  189. package/src/config/SecretsManager.d.ts.map +1 -0
  190. package/src/config/SecretsManager.js +328 -0
  191. package/src/config/app.d.ts +56 -0
  192. package/src/config/app.d.ts.map +1 -0
  193. package/src/config/app.js +77 -0
  194. package/src/config/cache.d.ts +76 -0
  195. package/src/config/cache.d.ts.map +1 -0
  196. package/src/config/cache.js +62 -0
  197. package/src/config/constants.d.ts +108 -0
  198. package/src/config/constants.d.ts.map +1 -0
  199. package/src/config/constants.js +64 -0
  200. package/src/config/database.d.ts +122 -0
  201. package/src/config/database.d.ts.map +1 -0
  202. package/src/config/database.js +89 -0
  203. package/src/config/env.d.ts +56 -0
  204. package/src/config/env.d.ts.map +1 -0
  205. package/src/config/env.js +133 -0
  206. package/src/config/features.d.ts +27 -0
  207. package/src/config/features.d.ts.map +1 -0
  208. package/src/config/features.js +49 -0
  209. package/src/config/index.d.ts +554 -0
  210. package/src/config/index.d.ts.map +1 -0
  211. package/src/config/index.js +31 -0
  212. package/src/config/logger.d.ts +17 -0
  213. package/src/config/logger.d.ts.map +1 -0
  214. package/src/config/logger.js +77 -0
  215. package/src/config/microservices.d.ts +88 -0
  216. package/src/config/microservices.d.ts.map +1 -0
  217. package/src/config/microservices.js +90 -0
  218. package/src/config/queue.d.ts +107 -0
  219. package/src/config/queue.d.ts.map +1 -0
  220. package/src/config/queue.js +74 -0
  221. package/src/config/security.d.ts +108 -0
  222. package/src/config/security.d.ts.map +1 -0
  223. package/src/config/security.js +134 -0
  224. package/src/config/storage.d.ts +105 -0
  225. package/src/config/storage.d.ts.map +1 -0
  226. package/src/config/storage.js +79 -0
  227. package/src/container/ServiceContainer.d.ts +25 -0
  228. package/src/container/ServiceContainer.d.ts.map +1 -0
  229. package/src/container/ServiceContainer.js +75 -0
  230. package/src/database/migrations/index.d.ts +2 -0
  231. package/src/database/migrations/index.d.ts.map +1 -0
  232. package/src/database/migrations/index.js +1 -0
  233. package/src/exceptions/ZintrustError.d.ts +88 -0
  234. package/src/exceptions/ZintrustError.d.ts.map +1 -0
  235. package/src/exceptions/ZintrustError.js +110 -0
  236. package/src/features/Auth.d.ts +20 -0
  237. package/src/features/Auth.d.ts.map +1 -0
  238. package/src/features/Auth.js +32 -0
  239. package/src/features/Queue.d.ts +21 -0
  240. package/src/features/Queue.d.ts.map +1 -0
  241. package/src/features/Queue.js +59 -0
  242. package/src/functions/cloudflare.d.ts +5 -0
  243. package/src/functions/cloudflare.d.ts.map +1 -0
  244. package/src/functions/cloudflare.js +34 -0
  245. package/src/functions/deno.d.ts +3 -0
  246. package/src/functions/deno.d.ts.map +1 -0
  247. package/src/functions/deno.js +31 -0
  248. package/src/functions/lambda.d.ts +2 -0
  249. package/src/functions/lambda.d.ts.map +1 -0
  250. package/src/functions/lambda.js +32 -0
  251. package/src/http/Controller.d.ts +20 -0
  252. package/src/http/Controller.d.ts.map +1 -0
  253. package/src/http/Controller.js +46 -0
  254. package/src/http/Kernel.d.ts +24 -0
  255. package/src/http/Kernel.d.ts.map +1 -0
  256. package/src/http/Kernel.js +72 -0
  257. package/src/http/Request.d.ts +36 -0
  258. package/src/http/Request.d.ts.map +1 -0
  259. package/src/http/Request.js +142 -0
  260. package/src/http/Response.d.ts +32 -0
  261. package/src/http/Response.d.ts.map +1 -0
  262. package/src/http/Response.js +70 -0
  263. package/src/index.d.ts +43 -0
  264. package/src/index.d.ts.map +1 -0
  265. package/src/index.js +37 -0
  266. package/src/microservices/MicroserviceBootstrap.d.ts +75 -0
  267. package/src/microservices/MicroserviceBootstrap.d.ts.map +1 -0
  268. package/src/microservices/MicroserviceBootstrap.js +285 -0
  269. package/src/microservices/MicroserviceGenerator.d.ts +27 -0
  270. package/src/microservices/MicroserviceGenerator.d.ts.map +1 -0
  271. package/src/microservices/MicroserviceGenerator.js +436 -0
  272. package/src/microservices/MicroserviceManager.d.ts +68 -0
  273. package/src/microservices/MicroserviceManager.d.ts.map +1 -0
  274. package/src/microservices/MicroserviceManager.js +266 -0
  275. package/src/microservices/PostgresAdapter.d.ts +90 -0
  276. package/src/microservices/PostgresAdapter.d.ts.map +1 -0
  277. package/src/microservices/PostgresAdapter.js +286 -0
  278. package/src/microservices/RequestTracingMiddleware.d.ts +41 -0
  279. package/src/microservices/RequestTracingMiddleware.d.ts.map +1 -0
  280. package/src/microservices/RequestTracingMiddleware.js +122 -0
  281. package/src/microservices/ServiceAuthMiddleware.d.ts +58 -0
  282. package/src/microservices/ServiceAuthMiddleware.d.ts.map +1 -0
  283. package/src/microservices/ServiceAuthMiddleware.js +240 -0
  284. package/src/microservices/ServiceBundler.d.ts +45 -0
  285. package/src/microservices/ServiceBundler.d.ts.map +1 -0
  286. package/src/microservices/ServiceBundler.js +297 -0
  287. package/src/microservices/ServiceHealthMonitor.d.ts +96 -0
  288. package/src/microservices/ServiceHealthMonitor.d.ts.map +1 -0
  289. package/src/microservices/ServiceHealthMonitor.js +379 -0
  290. package/src/middleware/CsrfMiddleware.d.ts +19 -0
  291. package/src/middleware/CsrfMiddleware.d.ts.map +1 -0
  292. package/src/middleware/CsrfMiddleware.js +121 -0
  293. package/src/middleware/MiddlewareStack.d.ts +27 -0
  294. package/src/middleware/MiddlewareStack.d.ts.map +1 -0
  295. package/src/middleware/MiddlewareStack.js +43 -0
  296. package/src/middleware/RateLimiter.d.ts +22 -0
  297. package/src/middleware/RateLimiter.d.ts.map +1 -0
  298. package/src/middleware/RateLimiter.js +72 -0
  299. package/src/middleware/SecurityMiddleware.d.ts +33 -0
  300. package/src/middleware/SecurityMiddleware.d.ts.map +1 -0
  301. package/src/middleware/SecurityMiddleware.js +106 -0
  302. package/src/middleware/index.d.ts +9 -0
  303. package/src/middleware/index.d.ts.map +1 -0
  304. package/src/middleware/index.js +8 -0
  305. package/src/node-singletons/child-process.d.ts +7 -0
  306. package/src/node-singletons/child-process.d.ts.map +1 -0
  307. package/src/node-singletons/child-process.js +6 -0
  308. package/src/node-singletons/crypto.d.ts +7 -0
  309. package/src/node-singletons/crypto.d.ts.map +1 -0
  310. package/src/node-singletons/crypto.js +6 -0
  311. package/src/node-singletons/events.d.ts +7 -0
  312. package/src/node-singletons/events.d.ts.map +1 -0
  313. package/src/node-singletons/events.js +6 -0
  314. package/src/node-singletons/fs.d.ts +12 -0
  315. package/src/node-singletons/fs.d.ts.map +1 -0
  316. package/src/node-singletons/fs.js +14 -0
  317. package/src/node-singletons/http.d.ts +8 -0
  318. package/src/node-singletons/http.d.ts.map +1 -0
  319. package/src/node-singletons/http.js +6 -0
  320. package/src/node-singletons/index.d.ts +30 -0
  321. package/src/node-singletons/index.d.ts.map +1 -0
  322. package/src/node-singletons/index.js +31 -0
  323. package/src/node-singletons/os.d.ts +9 -0
  324. package/src/node-singletons/os.d.ts.map +1 -0
  325. package/src/node-singletons/os.js +9 -0
  326. package/src/node-singletons/path.d.ts +7 -0
  327. package/src/node-singletons/path.d.ts.map +1 -0
  328. package/src/node-singletons/path.js +6 -0
  329. package/src/node-singletons/perf-hooks.d.ts +7 -0
  330. package/src/node-singletons/perf-hooks.d.ts.map +1 -0
  331. package/src/node-singletons/perf-hooks.js +6 -0
  332. package/src/node-singletons/readline.d.ts +10 -0
  333. package/src/node-singletons/readline.d.ts.map +1 -0
  334. package/src/node-singletons/readline.js +9 -0
  335. package/src/node-singletons/url.d.ts +7 -0
  336. package/src/node-singletons/url.d.ts.map +1 -0
  337. package/src/node-singletons/url.js +6 -0
  338. package/src/orm/ConnectionManager.d.ts +118 -0
  339. package/src/orm/ConnectionManager.d.ts.map +1 -0
  340. package/src/orm/ConnectionManager.js +401 -0
  341. package/src/orm/Database.d.ts +31 -0
  342. package/src/orm/Database.d.ts.map +1 -0
  343. package/src/orm/Database.js +163 -0
  344. package/src/orm/DatabaseAdapter.d.ts +96 -0
  345. package/src/orm/DatabaseAdapter.d.ts.map +1 -0
  346. package/src/orm/DatabaseAdapter.js +40 -0
  347. package/src/orm/Model.d.ts +91 -0
  348. package/src/orm/Model.d.ts.map +1 -0
  349. package/src/orm/Model.js +206 -0
  350. package/src/orm/QueryBuilder.d.ts +52 -0
  351. package/src/orm/QueryBuilder.d.ts.map +1 -0
  352. package/src/orm/QueryBuilder.js +134 -0
  353. package/src/orm/Relationships.d.ts +53 -0
  354. package/src/orm/Relationships.d.ts.map +1 -0
  355. package/src/orm/Relationships.js +98 -0
  356. package/src/orm/Schema.d.ts +123 -0
  357. package/src/orm/Schema.d.ts.map +1 -0
  358. package/src/orm/Schema.js +169 -0
  359. package/src/orm/adapters/D1Adapter.d.ts +15 -0
  360. package/src/orm/adapters/D1Adapter.d.ts.map +1 -0
  361. package/src/orm/adapters/D1Adapter.js +125 -0
  362. package/src/orm/adapters/MySQLAdapter.d.ts +16 -0
  363. package/src/orm/adapters/MySQLAdapter.d.ts.map +1 -0
  364. package/src/orm/adapters/MySQLAdapter.js +87 -0
  365. package/src/orm/adapters/PostgreSQLAdapter.d.ts +16 -0
  366. package/src/orm/adapters/PostgreSQLAdapter.d.ts.map +1 -0
  367. package/src/orm/adapters/PostgreSQLAdapter.js +87 -0
  368. package/src/orm/adapters/SQLServerAdapter.d.ts +16 -0
  369. package/src/orm/adapters/SQLServerAdapter.d.ts.map +1 -0
  370. package/src/orm/adapters/SQLServerAdapter.js +81 -0
  371. package/src/orm/adapters/SQLiteAdapter.d.ts +11 -0
  372. package/src/orm/adapters/SQLiteAdapter.d.ts.map +1 -0
  373. package/src/orm/adapters/SQLiteAdapter.js +131 -0
  374. package/src/performance/Benchmark.d.ts +87 -0
  375. package/src/performance/Benchmark.d.ts.map +1 -0
  376. package/src/performance/Benchmark.js +304 -0
  377. package/src/performance/CodeGenerationBenchmark.d.ts +23 -0
  378. package/src/performance/CodeGenerationBenchmark.d.ts.map +1 -0
  379. package/src/performance/CodeGenerationBenchmark.js +249 -0
  380. package/src/performance/Optimizer.d.ts +99 -0
  381. package/src/performance/Optimizer.d.ts.map +1 -0
  382. package/src/performance/Optimizer.js +396 -0
  383. package/src/performance/establish-baseline.d.ts +9 -0
  384. package/src/performance/establish-baseline.d.ts.map +1 -0
  385. package/src/performance/establish-baseline.js +55 -0
  386. package/src/profiling/MemoryProfiler.d.ts +32 -0
  387. package/src/profiling/MemoryProfiler.d.ts.map +1 -0
  388. package/src/profiling/MemoryProfiler.js +84 -0
  389. package/src/profiling/N1Detector.d.ts +16 -0
  390. package/src/profiling/N1Detector.d.ts.map +1 -0
  391. package/src/profiling/N1Detector.js +120 -0
  392. package/src/profiling/QueryLogger.d.ts +107 -0
  393. package/src/profiling/QueryLogger.d.ts.map +1 -0
  394. package/src/profiling/QueryLogger.js +148 -0
  395. package/src/profiling/RequestProfiler.d.ts +30 -0
  396. package/src/profiling/RequestProfiler.d.ts.map +1 -0
  397. package/src/profiling/RequestProfiler.js +94 -0
  398. package/src/profiling/types.d.ts +77 -0
  399. package/src/profiling/types.d.ts.map +1 -0
  400. package/src/profiling/types.js +5 -0
  401. package/src/routing/Router.d.ts +52 -0
  402. package/src/routing/Router.d.ts.map +1 -0
  403. package/src/routing/Router.js +191 -0
  404. package/src/runtime/PluginManager.d.ts +30 -0
  405. package/src/runtime/PluginManager.d.ts.map +1 -0
  406. package/src/runtime/PluginManager.js +197 -0
  407. package/src/runtime/PluginRegistry.d.ts +22 -0
  408. package/src/runtime/PluginRegistry.d.ts.map +1 -0
  409. package/src/runtime/PluginRegistry.js +93 -0
  410. package/src/runtime/RuntimeAdapter.d.ts +126 -0
  411. package/src/runtime/RuntimeAdapter.d.ts.map +1 -0
  412. package/src/runtime/RuntimeAdapter.js +127 -0
  413. package/src/runtime/RuntimeDetector.d.ts +15 -0
  414. package/src/runtime/RuntimeDetector.d.ts.map +1 -0
  415. package/src/runtime/RuntimeDetector.js +219 -0
  416. package/src/runtime/adapters/CloudflareAdapter.d.ts +43 -0
  417. package/src/runtime/adapters/CloudflareAdapter.d.ts.map +1 -0
  418. package/src/runtime/adapters/CloudflareAdapter.js +175 -0
  419. package/src/runtime/adapters/DenoAdapter.d.ts +30 -0
  420. package/src/runtime/adapters/DenoAdapter.d.ts.map +1 -0
  421. package/src/runtime/adapters/DenoAdapter.js +191 -0
  422. package/src/runtime/adapters/FargateAdapter.d.ts +40 -0
  423. package/src/runtime/adapters/FargateAdapter.d.ts.map +1 -0
  424. package/src/runtime/adapters/FargateAdapter.js +156 -0
  425. package/src/runtime/adapters/LambdaAdapter.d.ts +13 -0
  426. package/src/runtime/adapters/LambdaAdapter.d.ts.map +1 -0
  427. package/src/runtime/adapters/LambdaAdapter.js +302 -0
  428. package/src/runtime/adapters/NodeServerAdapter.d.ts +16 -0
  429. package/src/runtime/adapters/NodeServerAdapter.d.ts.map +1 -0
  430. package/src/runtime/adapters/NodeServerAdapter.js +199 -0
  431. package/src/scripts/TemplateSync.d.ts +7 -0
  432. package/src/scripts/TemplateSync.d.ts.map +1 -0
  433. package/src/scripts/TemplateSync.js +234 -0
  434. package/src/security/CsrfTokenManager.d.ts +28 -0
  435. package/src/security/CsrfTokenManager.d.ts.map +1 -0
  436. package/src/security/CsrfTokenManager.js +78 -0
  437. package/src/security/Encryptor.d.ts +15 -0
  438. package/src/security/Encryptor.d.ts.map +1 -0
  439. package/src/security/Encryptor.js +142 -0
  440. package/src/security/JwtManager.d.ts +41 -0
  441. package/src/security/JwtManager.d.ts.map +1 -0
  442. package/src/security/JwtManager.js +229 -0
  443. package/src/security/UrlValidator.d.ts +21 -0
  444. package/src/security/UrlValidator.d.ts.map +1 -0
  445. package/src/security/UrlValidator.js +42 -0
  446. package/src/security/XssProtection.d.ts +24 -0
  447. package/src/security/XssProtection.d.ts.map +1 -0
  448. package/src/security/XssProtection.js +133 -0
  449. package/src/templates/TemplateRegistry.d.ts +40 -0
  450. package/src/templates/TemplateRegistry.d.ts.map +1 -0
  451. package/src/templates/TemplateRegistry.js +78 -0
  452. package/src/templates/TemplateRegistry.ts +91 -0
  453. package/src/templates/adapters/MySQLAdapter.ts.tpl +97 -0
  454. package/src/templates/adapters/PostgreSQLAdapter.ts.tpl +101 -0
  455. package/src/templates/adapters/SQLServerAdapter.ts.tpl +95 -0
  456. package/src/templates/adapters/SQLiteAdapter.ts.tpl +189 -0
  457. package/src/templates/features/Auth.ts.tpl +40 -0
  458. package/src/templates/features/Queue.ts.tpl +75 -0
  459. package/src/templates/project/basic/.env.example.tpl +26 -0
  460. package/src/templates/project/basic/.env.tpl +164 -0
  461. package/src/templates/project/basic/README.md.tpl +13 -0
  462. package/src/templates/project/basic/app/Controllers/UserController.ts.tpl +155 -0
  463. package/src/templates/project/basic/app/Middleware/ProfilerMiddleware.ts.tpl +55 -0
  464. package/src/templates/project/basic/app/Middleware/index.ts.tpl +304 -0
  465. package/src/templates/project/basic/app/Models/Post.ts.tpl +30 -0
  466. package/src/templates/project/basic/app/Models/User.ts.tpl +53 -0
  467. package/src/templates/project/basic/config/SecretsManager.ts.tpl +453 -0
  468. package/src/templates/project/basic/config/app.ts.tpl +97 -0
  469. package/src/templates/project/basic/config/cache.ts.tpl +117 -0
  470. package/src/templates/project/basic/config/constants.ts.tpl +70 -0
  471. package/src/templates/project/basic/config/database.ts.tpl +152 -0
  472. package/src/templates/project/basic/config/env.ts.tpl +148 -0
  473. package/src/templates/project/basic/config/features.ts.tpl +57 -0
  474. package/src/templates/project/basic/config/index.ts.tpl +36 -0
  475. package/src/templates/project/basic/config/logger.ts.tpl +95 -0
  476. package/src/templates/project/basic/config/microservices.ts.tpl +104 -0
  477. package/src/templates/project/basic/config/queue.ts.tpl +134 -0
  478. package/src/templates/project/basic/config/security.ts.tpl +149 -0
  479. package/src/templates/project/basic/config/storage.ts.tpl +136 -0
  480. package/src/templates/project/basic/database/factories/.gitkeep.tpl +0 -0
  481. package/src/templates/project/basic/database/migrations/.gitkeep.tpl +0 -0
  482. package/src/templates/project/basic/database/migrations/index.ts.tpl +2 -0
  483. package/src/templates/project/basic/database/seeders/.gitkeep.tpl +0 -0
  484. package/src/templates/project/basic/package.json.tpl +22 -0
  485. package/src/templates/project/basic/routes/api.ts.tpl +135 -0
  486. package/src/templates/project/basic/src/index.ts.tpl +49 -0
  487. package/src/templates/project/basic/template.json +17 -0
  488. package/src/templates/project/basic/tsconfig.json.tpl +20 -0
  489. package/src/validation/ValidationError.d.ts +42 -0
  490. package/src/validation/ValidationError.d.ts.map +1 -0
  491. package/src/validation/ValidationError.js +53 -0
  492. package/src/validation/Validator.d.ts +60 -0
  493. package/src/validation/Validator.d.ts.map +1 -0
  494. package/src/validation/Validator.js +190 -0
@@ -0,0 +1,817 @@
1
+ /**
2
+ * Add Command - Phase 4 Integration
3
+ * Add services and features to existing Zintrust project
4
+ */
5
+ import { BaseCommand } from '../BaseCommand';
6
+ import { ControllerGenerator } from '../scaffolding/ControllerGenerator';
7
+ import { FactoryGenerator } from '../scaffolding/FactoryGenerator';
8
+ import { FeatureScaffolder } from '../scaffolding/FeatureScaffolder';
9
+ import { MigrationGenerator } from '../scaffolding/MigrationGenerator';
10
+ import { ModelGenerator } from '../scaffolding/ModelGenerator';
11
+ import { RequestFactoryGenerator } from '../scaffolding/RequestFactoryGenerator';
12
+ import { ResponseFactoryGenerator, } from '../scaffolding/ResponseFactoryGenerator';
13
+ import { RouteGenerator } from '../scaffolding/RouteGenerator';
14
+ import { SeederGenerator } from '../scaffolding/SeederGenerator';
15
+ import { ServiceScaffolder } from '../scaffolding/ServiceScaffolder';
16
+ import { WorkflowGenerator } from '../scaffolding/WorkflowGenerator';
17
+ import { ErrorFactory } from '../../exceptions/ZintrustError';
18
+ import fs from '../../node-singletons/fs';
19
+ import inquirer from 'inquirer';
20
+ import * as path from 'node:path';
21
+ const addOptions = (command) => {
22
+ command
23
+ .argument('<type>', 'What to add: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, or workflow')
24
+ .argument('[name]', 'Name of service/feature/migration/model/controller/factory/seeder/requestfactory/responsefactory/workflow')
25
+ .option('--database <type>', 'Database (shared|isolated) - for services')
26
+ .option('--auth <strategy>', 'Auth strategy (api-key|jwt|none|custom) - for services')
27
+ .option('--port <number>', 'Service port - for services')
28
+ .option('--with-test', 'Generate test files - for features')
29
+ .option('--controller-type <type>', 'Controller type: crud, resource, api, graphql, websocket, webhook - for controllers')
30
+ .option('--soft-delete', 'Add soft delete to model')
31
+ .option('--timestamps', 'Add timestamps to model (default: true)')
32
+ .option('--resource', 'Generate resource routes')
33
+ .option('--model <name>', 'Model name for factory or seeder')
34
+ .option('--relationships <models>', 'Comma-separated related models for factory or seeder')
35
+ .option('--count <number>', 'Record count for seeder (1-100,000)')
36
+ .option('--states', 'Seed with state distribution (active/inactive/deleted)')
37
+ .option('--truncate', 'Truncate table before seeding')
38
+ .option('--platform <type>', 'Deployment platform: lambda, fargate, cloudflare, deno, all')
39
+ .option('--branch <name>', 'Deployment branch (default: master)')
40
+ .option('--node-version <version>', 'Node.js version (default: 20.x)')
41
+ .option('--no-interactive', 'Skip interactive prompts');
42
+ };
43
+ const promptServiceConfig = async (defaultName) => {
44
+ return inquirer.prompt([
45
+ {
46
+ type: 'input',
47
+ name: 'name',
48
+ message: 'Service name (lowercase, no spaces):',
49
+ default: defaultName,
50
+ validate: (v) => /^[a-z]+$/.test(v) || 'Must be lowercase letters only',
51
+ },
52
+ {
53
+ type: 'input',
54
+ name: 'domain',
55
+ message: 'Domain (e.g., ecommerce, payments):',
56
+ default: 'default',
57
+ },
58
+ {
59
+ type: 'number',
60
+ name: 'port',
61
+ message: 'Service port:',
62
+ default: 3001,
63
+ },
64
+ {
65
+ type: 'list',
66
+ name: 'database',
67
+ message: 'Database isolation:',
68
+ choices: ['shared', 'isolated'],
69
+ default: 'shared',
70
+ },
71
+ {
72
+ type: 'list',
73
+ name: 'auth',
74
+ message: 'Authentication strategy:',
75
+ choices: ['api-key', 'jwt', 'none', 'custom'],
76
+ default: 'api-key',
77
+ },
78
+ ]);
79
+ };
80
+ const addService = async (cmd, serviceName, opts) => {
81
+ const projectRoot = process.cwd();
82
+ let name = serviceName ?? '';
83
+ if (name === '' && opts.noInteractive !== true) {
84
+ const answers = await promptServiceConfig(name);
85
+ name = answers.name;
86
+ Object.assign(opts, answers);
87
+ }
88
+ else if (name === '') {
89
+ throw ErrorFactory.createValidationError('Service name is required');
90
+ }
91
+ cmd.info(`Creating service: ${name}...`);
92
+ const result = await ServiceScaffolder.scaffold(projectRoot, {
93
+ name,
94
+ domain: opts.domain ?? 'default',
95
+ port: opts.port === undefined ? 3001 : Number.parseInt(opts.port, 10),
96
+ database: opts.database ?? 'shared',
97
+ auth: opts.auth ?? 'api-key',
98
+ });
99
+ if (result.success === false)
100
+ throw ErrorFactory.createCliError(result.message);
101
+ cmd.success(`Service '${name}' created successfully!`);
102
+ cmd.info(`\nFiles created: ${result.filesCreated.length}`);
103
+ cmd.info(`Location: ${result.servicePath}`);
104
+ cmd.info(`\nNext steps:\n • Update service.config.json\n • Add environment variables\n • Create routes and controllers`);
105
+ };
106
+ const promptFeatureConfig = async () => {
107
+ const availableFeatures = FeatureScaffolder.getAvailableFeatures();
108
+ return inquirer.prompt([
109
+ {
110
+ type: 'list',
111
+ name: 'name',
112
+ message: 'Select feature to add:',
113
+ choices: availableFeatures,
114
+ },
115
+ {
116
+ type: 'input',
117
+ name: 'servicePath',
118
+ message: 'Service path (relative to project):',
119
+ default: 'src/services/default/users',
120
+ },
121
+ {
122
+ type: 'confirm',
123
+ name: 'withTest',
124
+ message: 'Generate test file?',
125
+ default: true,
126
+ },
127
+ ]);
128
+ };
129
+ const addFeature = async (cmd, featureName, opts) => {
130
+ const projectRoot = process.cwd();
131
+ let name = featureName ?? '';
132
+ let servicePath = opts.service ?? '';
133
+ if (name === '' && opts.noInteractive !== true) {
134
+ const answers = await promptFeatureConfig();
135
+ name = answers.name;
136
+ servicePath = answers.servicePath;
137
+ opts.withTest = answers.withTest;
138
+ }
139
+ else if (name === '') {
140
+ throw ErrorFactory.createValidationError('Feature name is required');
141
+ }
142
+ if (servicePath === '')
143
+ throw ErrorFactory.createValidationError('Service path is required');
144
+ const fullServicePath = path.join(projectRoot, servicePath);
145
+ cmd.info(`Adding feature: ${name}...`);
146
+ const result = await FeatureScaffolder.addFeature({
147
+ name: name,
148
+ servicePath: fullServicePath,
149
+ withTest: opts.withTest,
150
+ });
151
+ if (result.success === false)
152
+ throw ErrorFactory.createCliError(result.message);
153
+ cmd.success(`Feature '${name}' added successfully!`);
154
+ cmd.info(`Files created: ${result.filesCreated.length}`);
155
+ cmd.info(`\nNext steps:\n • Integrate feature in service\n • Update routes if needed\n • Add to configuration`);
156
+ };
157
+ const promptMigrationConfig = async () => {
158
+ return inquirer.prompt([
159
+ {
160
+ type: 'input',
161
+ name: 'name',
162
+ message: 'Migration name (snake_case, e.g., create_users_table):',
163
+ validate: (v) => /^[a-z_]+$/.test(v) || 'Must be snake_case',
164
+ },
165
+ {
166
+ type: 'list',
167
+ name: 'type',
168
+ message: 'Migration type:',
169
+ choices: ['create', 'alter', 'drop'],
170
+ },
171
+ ]);
172
+ };
173
+ const addMigration = async (cmd, migrationName, opts) => {
174
+ const projectRoot = process.cwd();
175
+ let name = migrationName ?? '';
176
+ if (name === '' && opts.noInteractive !== true) {
177
+ const answers = await promptMigrationConfig();
178
+ name = answers.name;
179
+ opts.type = answers.type;
180
+ }
181
+ else if (name === '') {
182
+ throw ErrorFactory.createValidationError('Migration name is required');
183
+ }
184
+ const migrationsPath = path.join(projectRoot, 'database', 'migrations');
185
+ cmd.info(`Creating migration: ${name}...`);
186
+ const result = await MigrationGenerator.generateMigration({
187
+ name,
188
+ migrationsPath,
189
+ type: (opts.type ?? 'create'),
190
+ });
191
+ if (result.success === false)
192
+ throw ErrorFactory.createCliError(result.message);
193
+ cmd.success('Migration created successfully!');
194
+ cmd.info(`File: ${path.basename(result.filePath)}`);
195
+ cmd.info(`\nNext steps:\n • Edit migration file\n • Add up() and down() implementations\n • Run migrations`);
196
+ };
197
+ const promptModelConfig = async () => {
198
+ return inquirer.prompt([
199
+ {
200
+ type: 'input',
201
+ name: 'name',
202
+ message: 'Model name (PascalCase, e.g., User, Post):',
203
+ validate: (v) => /^[A-Z][a-zA-Z\d]*$/.test(v) || 'Must be PascalCase',
204
+ },
205
+ {
206
+ type: 'confirm',
207
+ name: 'softDelete',
208
+ message: 'Add soft delete?',
209
+ default: false,
210
+ },
211
+ {
212
+ type: 'confirm',
213
+ name: 'timestamps',
214
+ message: 'Add timestamps (created_at, updated_at)?',
215
+ default: true,
216
+ },
217
+ ]);
218
+ };
219
+ const addModel = async (cmd, modelName, opts) => {
220
+ const projectRoot = process.cwd();
221
+ let name = modelName ?? '';
222
+ if (name === '' && opts.noInteractive !== true) {
223
+ const answers = await promptModelConfig();
224
+ name = answers.name;
225
+ opts.softDelete = answers.softDelete;
226
+ opts.timestamps = answers.timestamps;
227
+ }
228
+ else if (name === '') {
229
+ throw ErrorFactory.createValidationError('Model name is required');
230
+ }
231
+ const modelPath = path.join(projectRoot, 'app', 'Models');
232
+ cmd.info(`Creating model: ${name}...`);
233
+ const result = await ModelGenerator.generateModel({
234
+ name,
235
+ modelPath,
236
+ softDelete: opts.softDelete === true,
237
+ timestamps: opts.timestamps !== false,
238
+ });
239
+ if (result.success === false)
240
+ throw ErrorFactory.createCliError(result.message);
241
+ cmd.success(`Model '${name}' created successfully!`);
242
+ cmd.info(`File: ${path.basename(result.modelFile)}`);
243
+ cmd.info(`\nNext steps:\n • Add fillable attributes\n • Define relationships\n • Create migration for table`);
244
+ };
245
+ const promptControllerConfig = async () => {
246
+ return inquirer.prompt([
247
+ {
248
+ type: 'input',
249
+ name: 'name',
250
+ message: 'Controller name (PascalCase, e.g., UserController):',
251
+ validate: (v) => /^[A-Z][a-zA-Z\d]*Controller$/.test(v) || 'Must be PascalCase ending with "Controller"',
252
+ },
253
+ {
254
+ type: 'list',
255
+ name: 'type',
256
+ message: 'Controller type:',
257
+ choices: ['crud', 'resource', 'api', 'graphql', 'websocket', 'webhook'],
258
+ default: 'crud',
259
+ },
260
+ ]);
261
+ };
262
+ const addController = async (cmd, controllerName, opts) => {
263
+ const projectRoot = process.cwd();
264
+ let name = controllerName ?? '';
265
+ let controllerType = opts.controllerType ?? '';
266
+ if (name === '' && opts.noInteractive !== true) {
267
+ const answers = await promptControllerConfig();
268
+ name = answers.name;
269
+ controllerType = answers.type;
270
+ }
271
+ else if (name === '') {
272
+ throw ErrorFactory.createValidationError('Controller name is required');
273
+ }
274
+ const controllerPath = path.join(projectRoot, 'app', 'Controllers');
275
+ cmd.info(`Creating controller: ${name}...`);
276
+ const result = await ControllerGenerator.generateController({
277
+ name,
278
+ controllerPath,
279
+ type: (controllerType === ''
280
+ ? (opts.controllerType ?? 'crud')
281
+ : controllerType),
282
+ });
283
+ if (result.success === false)
284
+ throw ErrorFactory.createCliError(result.message);
285
+ cmd.success(`Controller '${name}' created successfully!`);
286
+ cmd.info(`File: ${path.basename(result.controllerFile)}`);
287
+ cmd.info(`\nNext steps:\n • Implement action methods\n • Add validation logic\n • Register routes for this controller`);
288
+ };
289
+ const promptRoutesConfig = async () => {
290
+ return inquirer.prompt([
291
+ {
292
+ type: 'input',
293
+ name: 'name',
294
+ message: 'Route group name (e.g., api, admin, public):',
295
+ default: 'api',
296
+ },
297
+ ]);
298
+ };
299
+ const addRoutes = async (cmd, routeName, opts) => {
300
+ const projectRoot = process.cwd();
301
+ let name = routeName ?? '';
302
+ if (name === '' && opts.noInteractive !== true) {
303
+ const answers = await promptRoutesConfig();
304
+ name = answers.name;
305
+ }
306
+ else if (name === '') {
307
+ throw ErrorFactory.createValidationError('Route group name is required');
308
+ }
309
+ const routesPath = path.join(projectRoot, 'routes');
310
+ cmd.info(`Creating routes: ${name}...`);
311
+ const result = await RouteGenerator.generateRoutes({
312
+ groupName: name,
313
+ routesPath,
314
+ routes: [],
315
+ });
316
+ if (result.success === false)
317
+ throw ErrorFactory.createCliError(result.message);
318
+ cmd.success(`Routes file '${name}' created successfully!`);
319
+ cmd.info(`File: ${path.basename(result.routeFile)}`);
320
+ cmd.info(`\nNext steps:\n • Add route definitions\n • Import controllers\n • Register in main router`);
321
+ };
322
+ const getFactoryInitialConfig = (factoryName, opts) => {
323
+ return {
324
+ name: factoryName ?? '',
325
+ modelName: opts.model ?? '',
326
+ relationships: opts.relationships ?? '',
327
+ };
328
+ };
329
+ const displayFactorySuccess = (cmd, name, filePath) => {
330
+ cmd.success(`Factory '${name}' created successfully!`);
331
+ cmd.info(`File: ${filePath === undefined ? 'factory' : path.basename(filePath)}`);
332
+ cmd.info(`\nUsage in tests:\n const user = new ${name}().create();\n const users = new ${name}().count(10).create();`);
333
+ cmd.info(`\nAvailable states:\n • active() - for published/active data\n • inactive() - for draft/inactive data\n • deleted() - for soft-deleted data`);
334
+ };
335
+ const promptFactoryConfig = async () => {
336
+ const answers = await inquirer.prompt([
337
+ {
338
+ type: 'input',
339
+ name: 'name',
340
+ message: 'Factory name (PascalCase, must end with "Factory", e.g., UserFactory):',
341
+ validate: (v) => /^[A-Z][a-zA-Z\d]*Factory$/.test(v) || 'Must be PascalCase ending with "Factory"',
342
+ },
343
+ {
344
+ type: 'input',
345
+ name: 'model',
346
+ message: 'Model name (e.g., User, Post):',
347
+ validate: (v) => /^[A-Z][a-zA-Z\d]*$/.test(v) || 'Must be PascalCase',
348
+ },
349
+ {
350
+ type: 'confirm',
351
+ name: 'addRelationships',
352
+ message: 'Add relationships (will be prompted for each)?',
353
+ default: false,
354
+ },
355
+ ]);
356
+ if (answers.addRelationships === true) {
357
+ const relAnswers = await inquirer.prompt([
358
+ {
359
+ type: 'input',
360
+ name: 'relationships',
361
+ message: 'Related models (comma-separated, e.g., User,Category):',
362
+ default: '',
363
+ },
364
+ ]);
365
+ return { ...answers, relationships: relAnswers.relationships };
366
+ }
367
+ return answers;
368
+ };
369
+ const addFactory = async (cmd, factoryName, opts) => {
370
+ const projectRoot = process.cwd();
371
+ let config = getFactoryInitialConfig(factoryName, opts);
372
+ if (config.name === '' && opts.noInteractive !== true) {
373
+ const answers = await promptFactoryConfig();
374
+ config = {
375
+ name: answers.name,
376
+ modelName: answers.model,
377
+ relationships: answers.relationships ?? '',
378
+ };
379
+ }
380
+ else if (config.name === '') {
381
+ throw ErrorFactory.createValidationError('Factory name is required');
382
+ }
383
+ if (config.modelName === '' && opts.noInteractive !== true) {
384
+ throw ErrorFactory.createValidationError('Model name is required for factory generation');
385
+ }
386
+ const factoriesPath = path.join(projectRoot, 'database', 'factories');
387
+ cmd.info(`Creating factory: ${config.name} for model ${config.modelName}...`);
388
+ const result = await FactoryGenerator.generateFactory({
389
+ factoryName: config.name,
390
+ modelName: config.modelName,
391
+ factoriesPath,
392
+ relationships: config.relationships === ''
393
+ ? undefined
394
+ : config.relationships.split(',').map((r) => r.trim()),
395
+ });
396
+ if (result.success === false)
397
+ throw ErrorFactory.createCliError(result.message);
398
+ displayFactorySuccess(cmd, config.name, result.filePath);
399
+ };
400
+ const getSeederInitialConfig = (seederName, opts) => {
401
+ return {
402
+ name: seederName ?? '',
403
+ modelName: opts.model ?? '',
404
+ count: opts.count === undefined ? 100 : Number.parseInt(opts.count, 10),
405
+ states: opts.states === true,
406
+ relationships: opts.relationships !== undefined,
407
+ truncate: opts.truncate !== false,
408
+ };
409
+ };
410
+ const ensureDirectoryExists = (dirPath) => {
411
+ if (fs.existsSync(dirPath) === false) {
412
+ fs.mkdirSync(dirPath, { recursive: true });
413
+ }
414
+ };
415
+ const displaySeederSuccess = (cmd, name, count, filePath, states, relationships) => {
416
+ cmd.success(`Seeder '${name}' created successfully!`);
417
+ cmd.info(`File: ${path.basename(filePath)}`);
418
+ cmd.info(`\nUsage in migrations or database seeds:\n await ${name}.run() // Run with ${count} records\n await ${name}.getRecords() // Get records without inserting`);
419
+ if (states === true) {
420
+ cmd.info(`\nWith state distribution:\n await ${name}.seedWithStates() // 50% active, 30% inactive, 20% deleted`);
421
+ }
422
+ if (relationships === true) {
423
+ cmd.info(`\nWith relationships:\n await ${name}.seedWithRelationships() // Seed with related data`);
424
+ }
425
+ cmd.info(`\nOther methods:\n await ${name}.reset() // Truncate table\n await ${name}.runWithTruncate() // Reset and seed`);
426
+ };
427
+ const promptSeederConfig = async () => {
428
+ return inquirer.prompt([
429
+ {
430
+ type: 'input',
431
+ name: 'name',
432
+ message: 'Seeder name (PascalCase, must end with "Seeder", e.g., UserSeeder):',
433
+ validate: (v) => /^[A-Z][a-zA-Z\d]*Seeder$/.test(v) || 'Must be PascalCase ending with "Seeder"',
434
+ },
435
+ {
436
+ type: 'input',
437
+ name: 'model',
438
+ message: 'Model name (e.g., User, Post):',
439
+ validate: (v) => /^[A-Z][a-zA-Z\d]*$/.test(v) || 'Must be PascalCase',
440
+ },
441
+ {
442
+ type: 'input',
443
+ name: 'count',
444
+ message: 'Number of records to seed (1-100,000):',
445
+ default: '100',
446
+ validate: (v) => {
447
+ const num = Number.parseInt(v, 10);
448
+ return (num >= 1 && num <= 100000) || 'Must be between 1 and 100,000';
449
+ },
450
+ },
451
+ {
452
+ type: 'confirm',
453
+ name: 'states',
454
+ message: 'Use state distribution (50% active, 30% inactive, 20% deleted)?',
455
+ default: false,
456
+ },
457
+ {
458
+ type: 'confirm',
459
+ name: 'relationships',
460
+ message: 'Seed with relationships?',
461
+ default: false,
462
+ },
463
+ {
464
+ type: 'confirm',
465
+ name: 'truncate',
466
+ message: 'Truncate table before seeding?',
467
+ default: true,
468
+ },
469
+ ]);
470
+ };
471
+ const addSeeder = async (cmd, seederName, opts) => {
472
+ const projectRoot = process.cwd();
473
+ let config = getSeederInitialConfig(seederName, opts);
474
+ if (config.name === '' && opts.noInteractive !== true) {
475
+ const answers = await promptSeederConfig();
476
+ config = {
477
+ name: answers.name,
478
+ modelName: answers.model,
479
+ count: Number.parseInt(answers.count, 10),
480
+ states: answers.states,
481
+ relationships: answers.relationships,
482
+ truncate: answers.truncate,
483
+ };
484
+ }
485
+ else if (config.name === '') {
486
+ throw ErrorFactory.createValidationError('Seeder name is required');
487
+ }
488
+ if (config.modelName === '' && opts.noInteractive !== true) {
489
+ throw ErrorFactory.createValidationError('Model name is required for seeder generation');
490
+ }
491
+ const seedersPath = path.join(projectRoot, 'database', 'seeders');
492
+ ensureDirectoryExists(seedersPath);
493
+ cmd.info(`Creating seeder: ${config.name} for model ${config.modelName}...`);
494
+ const result = await SeederGenerator.generateSeeder({
495
+ seederName: config.name,
496
+ modelName: config.modelName,
497
+ count: config.count,
498
+ seedersPath,
499
+ relationships: config.relationships === true ? ['related'] : undefined,
500
+ truncate: config.truncate,
501
+ });
502
+ if (result.success === false)
503
+ throw ErrorFactory.createCliError(result.message);
504
+ displaySeederSuccess(cmd, config.name, config.count, result.filePath, config.states, config.relationships);
505
+ };
506
+ const promptRequestFactoryConfig = async () => {
507
+ return inquirer.prompt([
508
+ {
509
+ type: 'input',
510
+ name: 'factoryName',
511
+ message: 'Request factory name (e.g., CreateUserRequestFactory):',
512
+ validate: (input) => {
513
+ if (input === '')
514
+ return 'Factory name is required';
515
+ if (!input.endsWith('RequestFactory'))
516
+ return 'Factory name must end with "RequestFactory"';
517
+ return true;
518
+ },
519
+ },
520
+ {
521
+ type: 'input',
522
+ name: 'requestName',
523
+ message: 'Request name:',
524
+ default: (ans) => ans.factoryName.replace('Factory', ''),
525
+ },
526
+ {
527
+ type: 'input',
528
+ name: 'endpoint',
529
+ message: 'API endpoint (e.g., /api/v1/users):',
530
+ default: '/api/v1/resource',
531
+ },
532
+ {
533
+ type: 'list',
534
+ name: 'method',
535
+ message: 'HTTP method:',
536
+ choices: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
537
+ default: 'POST',
538
+ },
539
+ {
540
+ type: 'confirm',
541
+ name: 'withDTO',
542
+ message: 'Generate request DTO?',
543
+ default: true,
544
+ },
545
+ ]);
546
+ };
547
+ const addRequestFactory = async (cmd, factoryName, opts) => {
548
+ let name = factoryName ?? '';
549
+ let requestName = '';
550
+ let endpoint = '';
551
+ let method = 'POST';
552
+ let withDTO = true;
553
+ if (name === '' && opts.noInteractive !== true) {
554
+ const answer = await promptRequestFactoryConfig();
555
+ name = answer.factoryName;
556
+ requestName = answer.requestName;
557
+ endpoint = answer.endpoint;
558
+ method = answer.method;
559
+ withDTO = answer.withDTO;
560
+ }
561
+ if (name === '')
562
+ throw ErrorFactory.createValidationError('Factory name is required');
563
+ const factoriesPath = path.join(process.cwd(), 'database', 'factories');
564
+ const requestsPath = withDTO === true ? path.join(process.cwd(), 'app', 'Requests') : undefined;
565
+ ensureDirectoryExists(factoriesPath);
566
+ if (requestsPath !== undefined)
567
+ ensureDirectoryExists(requestsPath);
568
+ const result = await RequestFactoryGenerator.generateRequestFactory({
569
+ factoryName: name,
570
+ requestName: requestName === '' ? name.replace('Factory', '') : requestName,
571
+ endpoint: endpoint === '' ? '/api/v1/resource' : endpoint,
572
+ method: (method === '' ? 'POST' : method),
573
+ factoriesPath,
574
+ requestsPath,
575
+ });
576
+ if (result.success === false)
577
+ throw ErrorFactory.createCliError(result.message);
578
+ cmd.success(`Request factory '${name}' created successfully!`);
579
+ cmd.info(`Factory: ${path.basename(result.factoryPath)}`);
580
+ if (result.requestPath !== undefined)
581
+ cmd.info(`DTO: ${path.basename(result.requestPath)}`);
582
+ cmd.info(`\nUsage in tests:\n const request = ${name}.create() // Create single request\n const requests = ${name}.times(5).makeMany() // Create multiple requests\n const invalid = ${name}.create().state('invalid').make() // Test validation`);
583
+ };
584
+ const promptResponseFactoryName = async () => {
585
+ const answer = await inquirer.prompt([
586
+ {
587
+ type: 'input',
588
+ name: 'factoryName',
589
+ message: 'Response factory name (e.g., UserResponseFactory):',
590
+ validate: (input) => {
591
+ if (input === '')
592
+ return 'Factory name is required';
593
+ if (!input.endsWith('ResponseFactory'))
594
+ return 'Factory name must end with "ResponseFactory"';
595
+ return true;
596
+ },
597
+ },
598
+ ]);
599
+ return answer.factoryName;
600
+ };
601
+ const promptResponseFactoryConfig = async (defaultResponseName) => {
602
+ return inquirer.prompt([
603
+ {
604
+ type: 'input',
605
+ name: 'factoryName',
606
+ message: 'Factory name:',
607
+ default: `${defaultResponseName}Factory`,
608
+ validate: (input) => {
609
+ if (input === '')
610
+ return 'Factory name is required';
611
+ if (!input.endsWith('Factory'))
612
+ return 'Factory name must end with "Factory"';
613
+ return true;
614
+ },
615
+ },
616
+ {
617
+ type: 'input',
618
+ name: 'responseName',
619
+ message: 'Response name:',
620
+ default: defaultResponseName,
621
+ validate: (input) => {
622
+ if (input === '')
623
+ return 'Response name is required';
624
+ if (!input.endsWith('Response'))
625
+ return 'Response name must end with "Response"';
626
+ return true;
627
+ },
628
+ },
629
+ {
630
+ type: 'list',
631
+ name: 'responseType',
632
+ message: 'Response type:',
633
+ choices: ['success', 'error', 'paginated', 'custom'],
634
+ default: 'success',
635
+ },
636
+ {
637
+ type: 'confirm',
638
+ name: 'withDTO',
639
+ message: 'Generate response DTO?',
640
+ default: true,
641
+ },
642
+ ]);
643
+ };
644
+ const getResponseFactoryAnswers = async (name, responseName, opts) => {
645
+ if (opts.noInteractive === true) {
646
+ return { factoryName: name, responseName, responseType: 'success', withDTO: true };
647
+ }
648
+ return promptResponseFactoryConfig(responseName);
649
+ };
650
+ const getDefaultResponseFields = (responseType) => {
651
+ const fields = [];
652
+ if (responseType === 'success') {
653
+ fields.push({ name: 'id', type: 'uuid' }, { name: 'name', type: 'string' }, { name: 'created_at', type: 'date' });
654
+ }
655
+ else if (responseType === 'error') {
656
+ fields.push({ name: 'code', type: 'number' }, { name: 'message', type: 'string' });
657
+ }
658
+ else if (responseType === 'paginated') {
659
+ fields.push({ name: 'id', type: 'uuid' }, { name: 'name', type: 'string' });
660
+ }
661
+ return fields;
662
+ };
663
+ const displayResponseFactorySuccess = (cmd, name, result) => {
664
+ cmd.success(`Response factory '${name}' created successfully!`);
665
+ cmd.info(`Factory: ${path.basename(result.factoryPath ?? '')}`);
666
+ if (result.responsePath !== undefined)
667
+ cmd.info(`DTO: ${path.basename(result.responsePath)}`);
668
+ cmd.info(`\nUsage in tests:\n const response = ${name}.create() // Create single response\n const responses = ${name}.times(5).makeMany() // Create multiple responses\n const error = ${name}.create().state('error').make() // Test error responses`);
669
+ };
670
+ const addResponseFactory = async (cmd, factoryName, opts) => {
671
+ let name = factoryName ?? '';
672
+ if (name === '' && opts.noInteractive !== true) {
673
+ name = await promptResponseFactoryName();
674
+ }
675
+ if (name === '')
676
+ throw ErrorFactory.createValidationError('Factory name is required');
677
+ const responseName = name.replace('Factory', '');
678
+ const answers = await getResponseFactoryAnswers(name, responseName, opts);
679
+ const factoriesPath = path.join(process.cwd(), 'database', 'factories');
680
+ const responsesPath = answers.withDTO === true ? path.join(process.cwd(), 'app', 'Responses') : undefined;
681
+ ensureDirectoryExists(factoriesPath);
682
+ if (responsesPath !== undefined)
683
+ ensureDirectoryExists(responsesPath);
684
+ const result = await ResponseFactoryGenerator.generate({
685
+ factoryName: name,
686
+ responseName: answers.responseName,
687
+ fields: getDefaultResponseFields(answers.responseType),
688
+ factoriesPath,
689
+ responsesPath,
690
+ });
691
+ if (result.success === false)
692
+ throw ErrorFactory.createCliError(result.message);
693
+ displayResponseFactorySuccess(cmd, name, result);
694
+ };
695
+ const promptWorkflowConfig = async (defaultName) => {
696
+ return inquirer.prompt([
697
+ {
698
+ type: 'input',
699
+ name: 'name',
700
+ message: 'Workflow name:',
701
+ default: defaultName,
702
+ },
703
+ {
704
+ type: 'list',
705
+ name: 'platform',
706
+ message: 'Target platform:',
707
+ choices: ['lambda', 'fargate', 'cloudflare', 'deno', 'all'],
708
+ default: 'all',
709
+ },
710
+ ]);
711
+ };
712
+ const addWorkflow = async (cmd, workflowName, opts) => {
713
+ const projectRoot = process.cwd();
714
+ let name = workflowName ?? 'deploy-cloud';
715
+ const validPlatforms = ['lambda', 'fargate', 'cloudflare', 'deno', 'all'];
716
+ let platform = 'all';
717
+ if (opts.platform !== undefined && validPlatforms.includes(opts.platform)) {
718
+ platform = opts.platform;
719
+ }
720
+ const isInteractive = opts.noInteractive !== true;
721
+ const hasNoName = workflowName === undefined || workflowName === '';
722
+ const hasNoPlatform = opts.platform === undefined || opts.platform === '';
723
+ if (isInteractive && (hasNoName || hasNoPlatform)) {
724
+ const answers = await promptWorkflowConfig(name);
725
+ name = answers.name;
726
+ platform = answers.platform;
727
+ }
728
+ cmd.info(`Generating workflow: ${name}...`);
729
+ const result = await WorkflowGenerator.generate({
730
+ name,
731
+ platform,
732
+ projectRoot,
733
+ branch: opts.branch ?? 'master',
734
+ nodeVersion: opts.nodeVersion ?? '20.x',
735
+ });
736
+ if (result.success === false)
737
+ throw ErrorFactory.createCliError(result.message);
738
+ cmd.success(result.message);
739
+ };
740
+ const handleType = async (cmd, type, name, opts) => {
741
+ switch (type) {
742
+ case 'service':
743
+ await addService(cmd, name, opts);
744
+ break;
745
+ case 'feature':
746
+ await addFeature(cmd, name, opts);
747
+ break;
748
+ case 'migration':
749
+ await addMigration(cmd, name, opts);
750
+ break;
751
+ case 'model':
752
+ await addModel(cmd, name, opts);
753
+ break;
754
+ case 'controller':
755
+ await addController(cmd, name, opts);
756
+ break;
757
+ case 'routes':
758
+ await addRoutes(cmd, name, opts);
759
+ break;
760
+ case 'factory':
761
+ await addFactory(cmd, name, opts);
762
+ break;
763
+ case 'seeder':
764
+ await addSeeder(cmd, name, opts);
765
+ break;
766
+ case 'requestfactory':
767
+ case 'request-factory':
768
+ await addRequestFactory(cmd, name, opts);
769
+ break;
770
+ case 'responsefactory':
771
+ case 'response-factory':
772
+ await addResponseFactory(cmd, name, opts);
773
+ break;
774
+ case 'workflow':
775
+ await addWorkflow(cmd, name, opts);
776
+ break;
777
+ default:
778
+ throw ErrorFactory.createCliError(`Unknown type "${type}". Use: service, feature, migration, model, controller, routes, factory, seeder, requestfactory, responsefactory, or workflow`);
779
+ }
780
+ };
781
+ const getArgs = (args) => Array.isArray(args) ? args : undefined;
782
+ const executeAdd = async (cmd, options) => {
783
+ const command = cmd.getCommand();
784
+ const args = getArgs(options.args) ?? getArgs(command.args) ?? [];
785
+ const type = args[0];
786
+ const name = args[1];
787
+ const commandOpts = typeof command.opts === 'function' ? command.opts() : {};
788
+ const addOpts = { ...options, ...commandOpts };
789
+ try {
790
+ if (type === undefined || type === '') {
791
+ throw ErrorFactory.createCliError('Please specify what to add: service, feature, migration, model, controller, routes, factory, or seeder');
792
+ }
793
+ await handleType(cmd, type.toLowerCase(), name, addOpts);
794
+ }
795
+ catch (error) {
796
+ ErrorFactory.createCliError('Add command failed', error);
797
+ cmd.warn(`Failed: ${error.message}`);
798
+ throw error;
799
+ }
800
+ };
801
+ /**
802
+ * Add Command Factory
803
+ */
804
+ export const AddCommand = Object.freeze({
805
+ /**
806
+ * Create a new add command instance
807
+ */
808
+ create() {
809
+ const cmd = BaseCommand.create({
810
+ name: 'add',
811
+ description: 'Add services and features to existing project',
812
+ addOptions,
813
+ execute: async (options) => executeAdd(cmd, options),
814
+ });
815
+ return cmd;
816
+ },
817
+ });