@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,94 @@
1
+ import { Logger } from '../../config/logger';
2
+ import { ErrorFactory } from '../../exceptions/ZintrustError';
3
+ import fs from '../../node-singletons/fs';
4
+ import * as path from '../../node-singletons/path';
5
+ const readRootPackageJson = (rootPath) => {
6
+ const rootPackageJsonPath = path.join(rootPath, 'package.json');
7
+ if (!fs.existsSync(rootPackageJsonPath)) {
8
+ throw ErrorFactory.createConfigError(`Missing package.json at: ${rootPackageJsonPath}`);
9
+ }
10
+ try {
11
+ const raw = fs.readFileSync(rootPackageJsonPath, 'utf8');
12
+ return JSON.parse(raw);
13
+ }
14
+ catch (error) {
15
+ throw ErrorFactory.createTryCatchError('Failed to read root package.json', error);
16
+ }
17
+ };
18
+ const coerceDependencies = (value) => {
19
+ if (typeof value !== 'object' || value === null)
20
+ return {};
21
+ return value;
22
+ };
23
+ const buildDistPackageJson = (rootPkg) => {
24
+ const name = typeof rootPkg.name === 'string' && rootPkg.name.trim() !== ''
25
+ ? rootPkg.name
26
+ : '@zintrust/core';
27
+ const version = typeof rootPkg.version === 'string' && rootPkg.version.trim() !== ''
28
+ ? rootPkg.version
29
+ : '0.0.0';
30
+ return {
31
+ name,
32
+ version,
33
+ private: true,
34
+ type: 'module',
35
+ main: './index.js',
36
+ types: './index.d.ts',
37
+ bin: {
38
+ zintrust: './bin/zintrust.js',
39
+ zin: './bin/zin.js',
40
+ z: './bin/z.js',
41
+ zt: './bin/zt.js',
42
+ },
43
+ exports: {
44
+ '.': {
45
+ types: './index.d.ts',
46
+ default: './index.js',
47
+ },
48
+ },
49
+ dependencies: coerceDependencies(rootPkg.dependencies),
50
+ };
51
+ };
52
+ const writeDistEntrypoints = (distPath) => {
53
+ const distIndexJsPath = path.join(distPath, 'index.js');
54
+ const distIndexDtsPath = path.join(distPath, 'index.d.ts');
55
+ fs.writeFileSync(distIndexJsPath, "export * from './src/index.js';\n");
56
+ fs.writeFileSync(distIndexDtsPath, "export * from './src/index';\n");
57
+ };
58
+ const writeDistPackageJson = (distPath, pkg) => {
59
+ const distPackageJsonPath = path.join(distPath, 'package.json');
60
+ fs.writeFileSync(distPackageJsonPath, JSON.stringify(pkg, null, 2) + '\n');
61
+ };
62
+ const warnIfMissingDistArtifacts = (distPath) => {
63
+ const expected = [
64
+ path.join(distPath, 'src', 'index.js'),
65
+ path.join(distPath, 'bin', 'zintrust.js'),
66
+ path.join(distPath, 'bin', 'zin.js'),
67
+ ];
68
+ for (const candidate of expected) {
69
+ if (!fs.existsSync(candidate)) {
70
+ Logger.warn(`Dist artifact missing (did you run build?): ${candidate}`);
71
+ }
72
+ }
73
+ const docsRoot = path.join(distPath, 'public');
74
+ if (!fs.existsSync(docsRoot)) {
75
+ Logger.warn(`Docs public root missing at ${docsRoot} (expected dist/public)`);
76
+ }
77
+ };
78
+ export const DistPackager = Object.freeze({
79
+ /**
80
+ * Creates minimal metadata so `dist/` can be installed via `file:/.../dist`.
81
+ * This is intended for local dev/simulate apps, not publishing.
82
+ */
83
+ prepare(distPath, rootPath = process.cwd()) {
84
+ if (!fs.existsSync(distPath)) {
85
+ throw ErrorFactory.createConfigError(`Missing dist output at: ${distPath}. Run 'npm run build' first.`);
86
+ }
87
+ const rootPkg = readRootPackageJson(rootPath);
88
+ const distPkg = buildDistPackageJson(rootPkg);
89
+ writeDistPackageJson(distPath, distPkg);
90
+ writeDistEntrypoints(distPath);
91
+ warnIfMissingDistArtifacts(distPath);
92
+ Logger.info(`✅ Prepared dist package metadata at: ${path.join(distPath, 'package.json')}`);
93
+ },
94
+ });
@@ -0,0 +1,21 @@
1
+ type LoadOptions = {
2
+ cwd?: string;
3
+ overrideExisting?: boolean;
4
+ };
5
+ type LoadState = {
6
+ loadedFiles: string[];
7
+ mode?: string;
8
+ };
9
+ type CliOverrides = {
10
+ nodeEnv?: 'development' | 'production' | 'testing';
11
+ port?: number;
12
+ runtime?: string;
13
+ };
14
+ export declare const EnvFileLoader: Readonly<{
15
+ load: (options?: LoadOptions) => LoadState;
16
+ ensureLoaded: () => LoadState;
17
+ applyCliOverrides: (overrides: CliOverrides) => void;
18
+ getState: () => LoadState;
19
+ }>;
20
+ export {};
21
+ //# sourceMappingURL=EnvFileLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EnvFileLoader.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/EnvFileLoader.ts"],"names":[],"mappings":"AA2GA,KAAK,WAAW,GAAG;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,SAAS,GAAG;IACf,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,OAAO,CAAC,EAAE,aAAa,GAAG,YAAY,GAAG,SAAS,CAAC;IACnD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAsFF,eAAO,MAAM,aAAa;qBA7DH,WAAW,KAAQ,SAAS;wBA8B1B,SAAS;mCAEI,YAAY,KAAG,IAAI;oBA2BpC,SAAS;EAO5B,CAAC"}
@@ -0,0 +1,166 @@
1
+ import { existsSync, readFileSync } from '../../node-singletons/fs';
2
+ import { join } from '../../node-singletons/path';
3
+ const normalizeAppMode = (value) => {
4
+ const normalized = value.trim().toLowerCase();
5
+ if (normalized === 'production' || normalized === 'pro' || normalized === 'prod')
6
+ return 'production';
7
+ if (normalized === 'dev' || normalized === 'development')
8
+ return 'dev';
9
+ // Per spec: any other value is treated as development.
10
+ return 'dev';
11
+ };
12
+ const stripInlineComment = (value) => {
13
+ let inSingle = false;
14
+ let inDouble = false;
15
+ for (let i = 0; i < value.length; i += 1) {
16
+ const ch = value[i];
17
+ if (ch === "'" && !inDouble)
18
+ inSingle = !inSingle;
19
+ if (ch === '"' && !inSingle)
20
+ inDouble = !inDouble;
21
+ if (!inSingle && !inDouble && ch === '#') {
22
+ const prev = value[i - 1];
23
+ if (prev === undefined || prev === ' ' || prev === '\t') {
24
+ return value.slice(0, i).trimEnd();
25
+ }
26
+ }
27
+ }
28
+ return value;
29
+ };
30
+ const unquote = (value) => {
31
+ const trimmed = value.trim();
32
+ if (trimmed.length >= 2) {
33
+ const first = trimmed[0];
34
+ const last = trimmed.at(-1);
35
+ if ((first === '"' && last === '"') || (first === "'" && last === "'")) {
36
+ return trimmed.slice(1, -1);
37
+ }
38
+ }
39
+ return trimmed;
40
+ };
41
+ const parseEnvFile = (raw) => {
42
+ const result = {};
43
+ const lines = raw.split(/\r?\n/);
44
+ for (const line of lines) {
45
+ const trimmed = line.trim();
46
+ if (trimmed === '' || trimmed.startsWith('#'))
47
+ continue;
48
+ const withoutExport = trimmed.startsWith('export ') ? trimmed.slice('export '.length) : trimmed;
49
+ const eq = withoutExport.indexOf('=');
50
+ if (eq <= 0)
51
+ continue;
52
+ const key = withoutExport.slice(0, eq).trim();
53
+ if (key === '')
54
+ continue;
55
+ const rhs = withoutExport.slice(eq + 1);
56
+ const withoutComment = stripInlineComment(rhs);
57
+ const value = unquote(withoutComment);
58
+ result[key] = value;
59
+ }
60
+ return result;
61
+ };
62
+ const applyToProcessEnv = (values, overrideExisting) => {
63
+ for (const [key, value] of Object.entries(values)) {
64
+ if (!overrideExisting && typeof process.env[key] === 'string')
65
+ continue;
66
+ process.env[key] = value;
67
+ }
68
+ // Compatibility helpers
69
+ if (typeof process.env['PORT'] !== 'string' && typeof process.env['APP_PORT'] === 'string') {
70
+ process.env['PORT'] = process.env['APP_PORT'];
71
+ }
72
+ if (typeof process.env['NODE_ENV'] !== 'string' && typeof process.env['APP_MODE'] === 'string') {
73
+ const mode = normalizeAppMode(process.env['APP_MODE']);
74
+ process.env['NODE_ENV'] = mode === 'production' ? 'production' : 'development';
75
+ }
76
+ };
77
+ const readEnvFileIfExists = (cwd, filename) => {
78
+ const fullPath = join(cwd, filename);
79
+ if (!existsSync(fullPath))
80
+ return undefined;
81
+ const raw = readFileSync(fullPath, 'utf-8');
82
+ return parseEnvFile(raw);
83
+ };
84
+ const resolveAppMode = (cwd) => {
85
+ const existing = process.env['APP_MODE'];
86
+ if (typeof existing === 'string' && existing.trim() !== '')
87
+ return normalizeAppMode(existing);
88
+ const fromDotEnv = readEnvFileIfExists(cwd, '.env');
89
+ const value = fromDotEnv?.['APP_MODE'];
90
+ if (typeof value === 'string' && value.trim() !== '')
91
+ return normalizeAppMode(value);
92
+ return undefined;
93
+ };
94
+ const filesLoader = (cwd, mode) => {
95
+ const files = [];
96
+ if (existsSync(join(cwd, '.env')))
97
+ files.push('.env');
98
+ // Per your rule: production uses .env; dev uses .env.dev
99
+ if (mode !== undefined && mode !== '' && mode !== 'production') {
100
+ const modeFile = `.env.${mode}`;
101
+ if (existsSync(join(cwd, modeFile)))
102
+ files.push(modeFile);
103
+ }
104
+ const local = '.env.local';
105
+ if (existsSync(join(cwd, local)))
106
+ files.push(local);
107
+ if (mode !== undefined && mode !== '') {
108
+ const modeLocal = `.env.${mode}.local`;
109
+ if (existsSync(join(cwd, modeLocal)))
110
+ files.push(modeLocal);
111
+ }
112
+ return files;
113
+ };
114
+ let cached;
115
+ const load = (options = {}) => {
116
+ if (cached !== undefined)
117
+ return cached;
118
+ const cwd = typeof options.cwd === 'string' && options.cwd !== '' ? options.cwd : process.cwd();
119
+ const overrideExisting = options.overrideExisting ?? true;
120
+ const mode = resolveAppMode(cwd);
121
+ const files = filesLoader(cwd, mode);
122
+ let baseApplied = false;
123
+ for (const file of files) {
124
+ const parsed = readEnvFileIfExists(cwd, file);
125
+ if (!parsed)
126
+ continue;
127
+ if (file === '.env') {
128
+ applyToProcessEnv(parsed, overrideExisting);
129
+ baseApplied = true;
130
+ continue;
131
+ }
132
+ // .env is primary: overlays only fill missing values and never override base.
133
+ applyToProcessEnv(parsed, baseApplied ? false : overrideExisting);
134
+ }
135
+ cached = { loadedFiles: files, mode };
136
+ return cached;
137
+ };
138
+ const ensureLoaded = () => load({ overrideExisting: true });
139
+ const applyCliOverrides = (overrides) => {
140
+ // Ensure base env is loaded first.
141
+ ensureLoaded();
142
+ if (typeof overrides.runtime === 'string' && overrides.runtime.trim() !== '') {
143
+ process.env['RUNTIME'] = overrides.runtime.trim();
144
+ }
145
+ if (typeof overrides.nodeEnv === 'string') {
146
+ process.env['NODE_ENV'] = overrides.nodeEnv;
147
+ }
148
+ if (typeof overrides.port === 'number') {
149
+ process.env['PORT'] = String(overrides.port);
150
+ process.env['APP_PORT'] = String(overrides.port);
151
+ }
152
+ // Keep PORT/APP_PORT in sync if only one exists.
153
+ if (typeof process.env['PORT'] !== 'string' && typeof process.env['APP_PORT'] === 'string') {
154
+ process.env['PORT'] = process.env['APP_PORT'];
155
+ }
156
+ if (typeof process.env['APP_PORT'] !== 'string' && typeof process.env['PORT'] === 'string') {
157
+ process.env['APP_PORT'] = process.env['PORT'];
158
+ }
159
+ };
160
+ const getState = () => ensureLoaded();
161
+ export const EnvFileLoader = Object.freeze({
162
+ load,
163
+ ensureLoaded,
164
+ applyCliOverrides,
165
+ getState,
166
+ });
@@ -0,0 +1,11 @@
1
+ export interface SpawnAndWaitInput {
2
+ command: string;
3
+ args: string[];
4
+ cwd?: string;
5
+ env?: NodeJS.ProcessEnv;
6
+ forwardSignals?: boolean;
7
+ }
8
+ export declare const SpawnUtil: Readonly<{
9
+ spawnAndWait(input: SpawnAndWaitInput): Promise<number>;
10
+ }>;
11
+ //# sourceMappingURL=spawn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spawn.d.ts","sourceRoot":"","sources":["../../../../src/cli/utils/spawn.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;IACxB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AA8BD,eAAO,MAAM,SAAS;wBACM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC;EAwD7D,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { appConfig } from '../../config/app';
2
+ import { ErrorFactory } from '../../exceptions/ZintrustError';
3
+ import { spawn } from '../../node-singletons/child-process';
4
+ import { existsSync } from '../../node-singletons/fs';
5
+ import * as path from 'node:path';
6
+ const getExitCode = (exitCode, signal) => {
7
+ if (typeof exitCode === 'number')
8
+ return exitCode;
9
+ if (signal === 'SIGINT' || signal === 'SIGTERM')
10
+ return 0;
11
+ return 1;
12
+ };
13
+ const resolveLocalBin = (command, cwd) => {
14
+ // If command is already a path, leave it alone.
15
+ if (command.includes('/') || command.includes('\\'))
16
+ return command;
17
+ const binDir = path.join(cwd, 'node_modules', '.bin');
18
+ const candidates = process.platform === 'win32'
19
+ ? [
20
+ path.join(binDir, `${command}.cmd`),
21
+ path.join(binDir, `${command}.exe`),
22
+ path.join(binDir, `${command}.bat`),
23
+ path.join(binDir, command),
24
+ ]
25
+ : [path.join(binDir, command)];
26
+ for (const candidate of candidates) {
27
+ if (existsSync(candidate))
28
+ return candidate;
29
+ }
30
+ return command;
31
+ };
32
+ export const SpawnUtil = Object.freeze({
33
+ async spawnAndWait(input) {
34
+ const cwd = input.cwd ?? process.cwd();
35
+ const resolvedCommand = resolveLocalBin(input.command, cwd);
36
+ const child = spawn(resolvedCommand, input.args, {
37
+ cwd,
38
+ env: input.env ?? appConfig.getSafeEnv(),
39
+ stdio: 'inherit',
40
+ });
41
+ const forwardSignals = input.forwardSignals !== false;
42
+ const forwardSignal = (signal) => {
43
+ try {
44
+ child.kill(signal);
45
+ }
46
+ catch (error) {
47
+ throw ErrorFactory.createTryCatchError('Failed to forward signal to child process', error);
48
+ }
49
+ };
50
+ const onSigint = () => forwardSignal('SIGINT');
51
+ const onSigterm = () => forwardSignal('SIGTERM');
52
+ if (forwardSignals) {
53
+ process.on('SIGINT', onSigint);
54
+ process.on('SIGTERM', onSigterm);
55
+ }
56
+ try {
57
+ const result = await new Promise((resolve, reject) => {
58
+ child.once('error', (error) => {
59
+ reject(error);
60
+ });
61
+ child.once('close', (code, signal) => {
62
+ resolve({ exitCode: code, signal });
63
+ });
64
+ });
65
+ return getExitCode(result.exitCode, result.signal);
66
+ }
67
+ catch (error) {
68
+ const code = error?.code;
69
+ if (code === 'ENOENT') {
70
+ throw ErrorFactory.createCliError(`Error: '${input.command}' not found on PATH.`);
71
+ }
72
+ throw ErrorFactory.createTryCatchError('Failed to spawn child process', error);
73
+ }
74
+ finally {
75
+ if (forwardSignals) {
76
+ process.off('SIGINT', onSigint);
77
+ process.off('SIGTERM', onSigterm);
78
+ }
79
+ }
80
+ },
81
+ });
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Common utilities - Sealed namespace for immutability
3
+ */
4
+ export declare const CommonUtils: Readonly<{
5
+ /**
6
+ * Resolve npm executable path from Node.js installation
7
+ */
8
+ resolveNpmPath(): string;
9
+ /**
10
+ * STRING UTILITIES
11
+ */
12
+ /**
13
+ * Convert string to camelCase
14
+ */
15
+ camelCase(str: string): string;
16
+ /**
17
+ * Convert string to snake_case
18
+ */
19
+ toSnakeCase(str: string): string;
20
+ /**
21
+ * Convert string to PascalCase
22
+ */
23
+ toPascalCase(str: string): string;
24
+ /**
25
+ * FILE SYSTEM UTILITIES
26
+ */
27
+ /**
28
+ * Check if file exists
29
+ */
30
+ fileExists(filePath: string): boolean;
31
+ /**
32
+ * Ensure directory exists, create if missing
33
+ */
34
+ ensureDir(dirPath: string): void;
35
+ /**
36
+ * Read file contents as string
37
+ */
38
+ readFile(filePath: string): string;
39
+ /**
40
+ * Write file with optional directory creation
41
+ */
42
+ writeFile(filePath: string, content: string, createDir?: boolean): void;
43
+ /**
44
+ * Delete file if it exists
45
+ */
46
+ deleteFile(filePath: string): void;
47
+ /**
48
+ * TIMESTAMP UTILITIES
49
+ */
50
+ /**
51
+ * Get current timestamp in ISO format
52
+ */
53
+ getCurrentTimestamp(): string;
54
+ /**
55
+ * Format timestamp for filenames (YYYY-MM-DDTHH-MM-SS-SSSZ)
56
+ */
57
+ formatTimestamp(date?: Date): string;
58
+ /**
59
+ * Parse ISO timestamp string to Date
60
+ */
61
+ parseTimestamp(timestamp: string): Date;
62
+ /**
63
+ * VALIDATION UTILITIES
64
+ */
65
+ /**
66
+ * Extract error message from unknown error type
67
+ */
68
+ extractErrorMessage(error: unknown): string;
69
+ /**
70
+ * Validate options object and throw if invalid
71
+ */
72
+ validateOptions(options: Record<string, unknown>, requiredFields: string[], context: string): void;
73
+ /**
74
+ * Check if value is valid (not null, undefined, or empty string)
75
+ */
76
+ isValid(value: unknown): boolean;
77
+ /**
78
+ * Ensure value is string, throw otherwise
79
+ */
80
+ ensureString(value: unknown, fieldName: string): string;
81
+ /**
82
+ * Ensure value is object, throw otherwise
83
+ */
84
+ ensureObject(value: unknown, fieldName: string): Record<string, unknown>;
85
+ }>;
86
+ export declare const resolveNpmPath: () => string;
87
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,eAAO,MAAM,WAAW;IACtB;;OAEG;sBACe,MAAM;IAgBxB;;OAEG;IAEH;;OAEG;mBACY,MAAM,GAAG,MAAM;IAgB9B;;OAEG;qBACc,MAAM,GAAG,MAAM;IAUhC;;OAEG;sBACe,MAAM,GAAG,MAAM;IAQjC;;OAEG;IAEH;;OAEG;yBACkB,MAAM,GAAG,OAAO;IAQrC;;OAEG;uBACgB,MAAM,GAAG,IAAI;IAMhC;;OAEG;uBACgB,MAAM,GAAG,MAAM;IAUlC;;OAEG;wBACiB,MAAM,WAAW,MAAM,wBAAqB,IAAI;IAcpE;;OAEG;yBACkB,MAAM,GAAG,IAAI;IAYlC;;OAEG;IAEH;;OAEG;2BACoB,MAAM;IAI7B;;OAEG;2BACmB,IAAI,GAAgB,MAAM;IAIhD;;OAEG;8BACuB,MAAM,GAAG,IAAI;IAYvC;;OAEG;IAEH;;OAEG;+BACwB,OAAO,GAAG,MAAM;IAa3C;;OAEG;6BAEQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,kBAChB,MAAM,EAAE,WACf,MAAM,GACd,IAAI;IAWP;;OAEG;mBACY,OAAO,GAAG,OAAO;IAIhC;;OAEG;wBACiB,OAAO,aAAa,MAAM,GAAG,MAAM;IAOvD;;OAEG;wBACiB,OAAO,aAAa,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;EAMxE,CAAC;AAGH,eAAO,MAAM,cAAc,QAAO,MAAsC,CAAC"}
@@ -0,0 +1,207 @@
1
+ import { ErrorFactory } from '../exceptions/ZintrustError';
2
+ import fs from '../node-singletons/fs';
3
+ import * as path from 'node:path';
4
+ /**
5
+ * Common utilities - Sealed namespace for immutability
6
+ */
7
+ export const CommonUtils = Object.freeze({
8
+ /**
9
+ * Resolve npm executable path from Node.js installation
10
+ */
11
+ resolveNpmPath() {
12
+ const nodeBinDir = path.dirname(process.execPath);
13
+ const candidates = process.platform === 'win32'
14
+ ? [path.join(nodeBinDir, 'npm.cmd'), path.join(nodeBinDir, 'npm.exe')]
15
+ : [path.join(nodeBinDir, 'npm')];
16
+ for (const candidate of candidates) {
17
+ if (fs.existsSync(candidate))
18
+ return candidate;
19
+ }
20
+ throw ErrorFactory.createGeneralError('Unable to locate npm executable. Ensure Node.js (with npm) is installed in the standard location.');
21
+ },
22
+ /**
23
+ * STRING UTILITIES
24
+ */
25
+ /**
26
+ * Convert string to camelCase
27
+ */
28
+ camelCase(str) {
29
+ return (str
30
+ // First convert PascalCase/camelCase to snake_case format for splitting
31
+ .replaceAll(/([a-z])([A-Z])/g, '$1_$2')
32
+ .split(/[\s_-]+/)
33
+ .map((word, index) => {
34
+ if (index === 0) {
35
+ return word.charAt(0).toLowerCase() + word.slice(1).toLowerCase();
36
+ }
37
+ return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
38
+ })
39
+ .join(''));
40
+ },
41
+ /**
42
+ * Convert string to snake_case
43
+ */
44
+ toSnakeCase(str) {
45
+ return str
46
+ .replaceAll(/([a-z])([A-Z])/g, '$1_$2')
47
+ .replaceAll(/([A-Z])/g, '_$1')
48
+ .replaceAll(/(\d)([A-Z])/g, '$1_$2')
49
+ .toLowerCase()
50
+ .replace(/^_/, '')
51
+ .replaceAll(/__+/g, '_');
52
+ },
53
+ /**
54
+ * Convert string to PascalCase
55
+ */
56
+ toPascalCase(str) {
57
+ return str
58
+ .replaceAll(/([a-z])([A-Z])/g, '$1_$2') // Add underscore before capital letters in camelCase
59
+ .split(/[\s_-]+/)
60
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
61
+ .join('');
62
+ },
63
+ /**
64
+ * FILE SYSTEM UTILITIES
65
+ */
66
+ /**
67
+ * Check if file exists
68
+ */
69
+ fileExists(filePath) {
70
+ try {
71
+ return fs.existsSync(filePath);
72
+ }
73
+ catch {
74
+ return false;
75
+ }
76
+ },
77
+ /**
78
+ * Ensure directory exists, create if missing
79
+ */
80
+ ensureDir(dirPath) {
81
+ if (!fs.existsSync(dirPath)) {
82
+ fs.mkdirSync(dirPath, { recursive: true });
83
+ }
84
+ },
85
+ /**
86
+ * Read file contents as string
87
+ */
88
+ readFile(filePath) {
89
+ try {
90
+ return fs.readFileSync(filePath, 'utf-8');
91
+ }
92
+ catch (error) {
93
+ throw ErrorFactory.createGeneralError(`Failed to read file: ${filePath}. ${error instanceof Error ? error.message : 'Unknown error'}`);
94
+ }
95
+ },
96
+ /**
97
+ * Write file with optional directory creation
98
+ */
99
+ writeFile(filePath, content, createDir = true) {
100
+ try {
101
+ if (createDir) {
102
+ const dir = path.dirname(filePath);
103
+ this.ensureDir(dir);
104
+ }
105
+ fs.writeFileSync(filePath, content, 'utf-8');
106
+ }
107
+ catch (error) {
108
+ throw ErrorFactory.createGeneralError(`Failed to write file: ${filePath}. ${error instanceof Error ? error.message : 'Unknown error'}`);
109
+ }
110
+ },
111
+ /**
112
+ * Delete file if it exists
113
+ */
114
+ deleteFile(filePath) {
115
+ try {
116
+ if (fs.existsSync(filePath)) {
117
+ fs.unlinkSync(filePath);
118
+ }
119
+ }
120
+ catch (error) {
121
+ throw ErrorFactory.createGeneralError(`Failed to delete file: ${filePath}. ${error instanceof Error ? error.message : 'Unknown error'}`);
122
+ }
123
+ },
124
+ /**
125
+ * TIMESTAMP UTILITIES
126
+ */
127
+ /**
128
+ * Get current timestamp in ISO format
129
+ */
130
+ getCurrentTimestamp() {
131
+ return new Date().toISOString();
132
+ },
133
+ /**
134
+ * Format timestamp for filenames (YYYY-MM-DDTHH-MM-SS-SSSZ)
135
+ */
136
+ formatTimestamp(date = new Date()) {
137
+ return date.toISOString().replaceAll(/[:.]/g, '-');
138
+ },
139
+ /**
140
+ * Parse ISO timestamp string to Date
141
+ */
142
+ parseTimestamp(timestamp) {
143
+ try {
144
+ const date = new Date(timestamp);
145
+ if (date.toString() === 'Invalid Date') {
146
+ throw ErrorFactory.createGeneralError('Invalid date');
147
+ }
148
+ return date;
149
+ }
150
+ catch (error) {
151
+ throw ErrorFactory.createGeneralError(`Failed to parse timestamp: ${timestamp}`, error);
152
+ }
153
+ },
154
+ /**
155
+ * VALIDATION UTILITIES
156
+ */
157
+ /**
158
+ * Extract error message from unknown error type
159
+ */
160
+ extractErrorMessage(error) {
161
+ if (error instanceof Error) {
162
+ return error.message;
163
+ }
164
+ if (typeof error === 'string') {
165
+ return error;
166
+ }
167
+ if (error !== undefined && error !== null && typeof error === 'object' && 'message' in error) {
168
+ return String(error.message);
169
+ }
170
+ return 'Unknown error occurred';
171
+ },
172
+ /**
173
+ * Validate options object and throw if invalid
174
+ */
175
+ validateOptions(options, requiredFields, context) {
176
+ const missingFields = requiredFields.filter((field) => options[field] === undefined || options[field] === null);
177
+ if (missingFields.length > 0) {
178
+ throw ErrorFactory.createGeneralError(`${context}: Missing required options: ${missingFields.join(', ')}`);
179
+ }
180
+ },
181
+ /**
182
+ * Check if value is valid (not null, undefined, or empty string)
183
+ */
184
+ isValid(value) {
185
+ return value !== null && value !== undefined && value !== '';
186
+ },
187
+ /**
188
+ * Ensure value is string, throw otherwise
189
+ */
190
+ ensureString(value, fieldName) {
191
+ if (typeof value !== 'string') {
192
+ throw ErrorFactory.createGeneralError(`${fieldName} must be a string, got ${typeof value}`);
193
+ }
194
+ return value;
195
+ },
196
+ /**
197
+ * Ensure value is object, throw otherwise
198
+ */
199
+ ensureObject(value, fieldName) {
200
+ if (typeof value !== 'object' || value === null) {
201
+ throw ErrorFactory.createGeneralError(`${fieldName} must be an object, got ${typeof value}`);
202
+ }
203
+ return value;
204
+ },
205
+ });
206
+ // Re-export for backward compatibility
207
+ export const resolveNpmPath = () => CommonUtils.resolveNpmPath();