@warlock.js/core 5.30.0 → 5.31.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 (797) hide show
  1. package/CHANGELOG.md +142 -36
  2. package/README.md +28 -23
  3. package/bin/source-load-hook.mjs +63 -0
  4. package/bin/warlock.js +102 -42
  5. package/esm/cli/commands/add.command.mjs +4 -2
  6. package/esm/cli/commands/add.command.mjs.map +1 -1
  7. package/esm/cli/commands/agents-md/agents-md-command.action.mjs +69 -0
  8. package/esm/cli/commands/agents-md/agents-md-command.action.mjs.map +1 -0
  9. package/esm/cli/commands/agents-md.command.mjs +38 -0
  10. package/esm/cli/commands/agents-md.command.mjs.map +1 -0
  11. package/esm/cli/commands/board/board-command.action.mjs +279 -0
  12. package/esm/cli/commands/board/board-command.action.mjs.map +1 -0
  13. package/esm/cli/commands/board.command.mjs +78 -0
  14. package/esm/cli/commands/board.command.mjs.map +1 -0
  15. package/esm/cli/commands/build.command.mjs +6 -1
  16. package/esm/cli/commands/build.command.mjs.map +1 -1
  17. package/esm/cli/commands/check/check-command.action.mjs +57 -0
  18. package/esm/cli/commands/check/check-command.action.mjs.map +1 -0
  19. package/esm/cli/commands/check/child-typecheck.mjs +66 -0
  20. package/esm/cli/commands/check/child-typecheck.mjs.map +1 -0
  21. package/esm/cli/commands/check/format-problems.mjs +43 -0
  22. package/esm/cli/commands/check/format-problems.mjs.map +1 -0
  23. package/esm/cli/commands/check/typecheck-command.action.mjs +61 -0
  24. package/esm/cli/commands/check/typecheck-command.action.mjs.map +1 -0
  25. package/esm/cli/commands/check.command.mjs +50 -0
  26. package/esm/cli/commands/check.command.mjs.map +1 -0
  27. package/esm/cli/commands/dev-server.command.mjs +9 -1
  28. package/esm/cli/commands/dev-server.command.mjs.map +1 -1
  29. package/esm/cli/commands/doctor/boot-for-diagnostics.mjs +8 -3
  30. package/esm/cli/commands/doctor/boot-for-diagnostics.mjs.map +1 -1
  31. package/esm/cli/commands/doctor/check.types.d.mts +76 -0
  32. package/esm/cli/commands/doctor/check.types.d.mts.map +1 -0
  33. package/esm/cli/commands/doctor/checks/config.check.mjs +1 -0
  34. package/esm/cli/commands/doctor/checks/config.check.mjs.map +1 -1
  35. package/esm/cli/commands/doctor/checks/connectors.check.mjs +2 -0
  36. package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -1
  37. package/esm/cli/commands/doctor/checks/handler-signature.check.mjs +1 -0
  38. package/esm/cli/commands/doctor/checks/handler-signature.check.mjs.map +1 -1
  39. package/esm/cli/commands/doctor/checks/health.check.mjs +3 -0
  40. package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -1
  41. package/esm/cli/commands/doctor/checks/jwt-secret.check.mjs +1 -0
  42. package/esm/cli/commands/doctor/checks/jwt-secret.check.mjs.map +1 -1
  43. package/esm/cli/commands/doctor/checks/locales-ts-deprecated.check.mjs +1 -0
  44. package/esm/cli/commands/doctor/checks/locales-ts-deprecated.check.mjs.map +1 -1
  45. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs +1 -0
  46. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -1
  47. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs +4 -0
  48. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs.map +1 -1
  49. package/esm/cli/commands/doctor/checks/routes.check.mjs +3 -0
  50. package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -1
  51. package/esm/cli/commands/doctor/doctor-command.action.mjs +14 -6
  52. package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -1
  53. package/esm/cli/commands/doctor/format-report.mjs +30 -2
  54. package/esm/cli/commands/doctor/format-report.mjs.map +1 -1
  55. package/esm/cli/commands/doctor.command.mjs +4 -0
  56. package/esm/cli/commands/doctor.command.mjs.map +1 -1
  57. package/esm/cli/commands/explain/explain-command.action.mjs +64 -0
  58. package/esm/cli/commands/explain/explain-command.action.mjs.map +1 -0
  59. package/esm/cli/commands/explain.command.mjs +23 -0
  60. package/esm/cli/commands/explain.command.mjs.map +1 -0
  61. package/esm/cli/commands/generate/generate.command.mjs +124 -124
  62. package/esm/cli/commands/generate/generate.command.mjs.map +1 -1
  63. package/esm/cli/commands/generate/generators/endpoint.generator.mjs +311 -0
  64. package/esm/cli/commands/generate/generators/endpoint.generator.mjs.map +1 -0
  65. package/esm/cli/commands/generate/generators/migration.generator.mjs +1 -1
  66. package/esm/cli/commands/generate/generators/migration.generator.mjs.map +1 -1
  67. package/esm/cli/commands/generate/generators/model.generator.mjs +1 -1
  68. package/esm/cli/commands/generate/templates/endpoint-stubs.mjs +341 -0
  69. package/esm/cli/commands/generate/templates/endpoint-stubs.mjs.map +1 -0
  70. package/esm/cli/commands/generate/templates/stubs.mjs +19 -6
  71. package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
  72. package/esm/cli/commands/generate/utils/endpoint-schema.mjs +137 -0
  73. package/esm/cli/commands/generate/utils/endpoint-schema.mjs.map +1 -0
  74. package/esm/cli/commands/generate/utils/name-parser.mjs +1 -1
  75. package/esm/cli/commands/generate/utils/name-parser.mjs.map +1 -1
  76. package/esm/cli/commands/generate/utils/prompt.mjs.map +1 -1
  77. package/esm/cli/commands/generate/utils/writer.mjs +38 -13
  78. package/esm/cli/commands/generate/utils/writer.mjs.map +1 -1
  79. package/esm/cli/commands/inspect/inspect-command.action.mjs +72 -0
  80. package/esm/cli/commands/inspect/inspect-command.action.mjs.map +1 -0
  81. package/esm/cli/commands/inspect.command.mjs +39 -0
  82. package/esm/cli/commands/inspect.command.mjs.map +1 -0
  83. package/esm/cli/commands/mcp/mcp-command.action.mjs +103 -0
  84. package/esm/cli/commands/mcp/mcp-command.action.mjs.map +1 -0
  85. package/esm/cli/commands/mcp.command.mjs +76 -0
  86. package/esm/cli/commands/mcp.command.mjs.map +1 -0
  87. package/esm/cli/commands/openapi-generator.action.mjs.map +1 -1
  88. package/esm/cli/commands/openapi-generator.command.mjs.map +1 -1
  89. package/esm/cli/commands/postman-generator.action.mjs.map +1 -1
  90. package/esm/cli/commands/postman-generator.command.mjs.map +1 -1
  91. package/esm/cli/commands/routes/routes-diff.action.mjs +1 -1
  92. package/esm/cli/commands/test.command.mjs +131 -0
  93. package/esm/cli/commands/test.command.mjs.map +1 -0
  94. package/esm/cli/commands/trace/trace-command.action.mjs +145 -0
  95. package/esm/cli/commands/trace/trace-command.action.mjs.map +1 -0
  96. package/esm/cli/commands/trace.command.mjs +60 -0
  97. package/esm/cli/commands/trace.command.mjs.map +1 -0
  98. package/esm/cli/commands/typecheck.command.mjs +40 -0
  99. package/esm/cli/commands/typecheck.command.mjs.map +1 -0
  100. package/esm/cli/commands/upgrade.command.mjs +46 -0
  101. package/esm/cli/commands/upgrade.command.mjs.map +1 -0
  102. package/esm/cli/flush-and-exit.mjs +34 -0
  103. package/esm/cli/flush-and-exit.mjs.map +1 -0
  104. package/esm/cli/framework-cli-commands.mjs +23 -1
  105. package/esm/cli/framework-cli-commands.mjs.map +1 -1
  106. package/esm/cli/parse-cli-args.mjs +1 -0
  107. package/esm/cli/parse-cli-args.mjs.map +1 -1
  108. package/esm/config/config-loader.d.mts.map +1 -1
  109. package/esm/config/config-loader.mjs +34 -13
  110. package/esm/config/config-loader.mjs.map +1 -1
  111. package/esm/config/config-schema.d.mts +67 -0
  112. package/esm/config/config-schema.d.mts.map +1 -0
  113. package/esm/config/config-schema.mjs +77 -0
  114. package/esm/config/config-schema.mjs.map +1 -0
  115. package/esm/config/index.d.mts +6 -0
  116. package/esm/config/index.mjs +1 -0
  117. package/esm/connectors/assert-no-reserved-connector-names.d.mts.map +1 -1
  118. package/esm/connectors/assert-no-reserved-connector-names.mjs +2 -1
  119. package/esm/connectors/assert-no-reserved-connector-names.mjs.map +1 -1
  120. package/esm/connectors/assert-unique-connector-names.d.mts.map +1 -1
  121. package/esm/connectors/assert-unique-connector-names.mjs +26 -2
  122. package/esm/connectors/assert-unique-connector-names.mjs.map +1 -1
  123. package/esm/connectors/http-connector.d.mts.map +1 -1
  124. package/esm/connectors/http-connector.mjs +3 -2
  125. package/esm/connectors/http-connector.mjs.map +1 -1
  126. package/esm/connectors/single-server-warnings.mjs.map +1 -1
  127. package/esm/connectors/socket-connector.d.mts.map +1 -1
  128. package/esm/connectors/socket-connector.mjs.map +1 -1
  129. package/esm/container/index.d.mts.map +1 -1
  130. package/esm/container/index.mjs.map +1 -1
  131. package/esm/database/migrate-action.mjs.map +1 -1
  132. package/esm/database/models/database-log/database-log.d.mts +0 -28
  133. package/esm/database/models/database-log/database-log.d.mts.map +1 -1
  134. package/esm/database/seeds/seeder.errors.d.mts +4 -0
  135. package/esm/database/seeds/seeder.errors.d.mts.map +1 -1
  136. package/esm/database/seeds/seeder.errors.mjs +2 -0
  137. package/esm/database/seeds/seeder.errors.mjs.map +1 -1
  138. package/esm/dev-server/boot-precondition-error.mjs +1 -0
  139. package/esm/dev-server/boot-precondition-error.mjs.map +1 -1
  140. package/esm/dev-server/create-worker.mjs +15 -9
  141. package/esm/dev-server/create-worker.mjs.map +1 -1
  142. package/esm/dev-server/dev-agent-tooling.mjs +135 -0
  143. package/esm/dev-server/dev-agent-tooling.mjs.map +1 -0
  144. package/esm/dev-server/dev-logger.mjs.map +1 -1
  145. package/esm/dev-server/development-server.mjs +8 -0
  146. package/esm/dev-server/development-server.mjs.map +1 -1
  147. package/esm/dev-server/files-orchestrator.mjs +4 -5
  148. package/esm/dev-server/files-orchestrator.mjs.map +1 -1
  149. package/esm/dev-server/files-watcher.mjs +1 -1
  150. package/esm/dev-server/health-checker/checkers/eslint-health-checker.mjs +2 -3
  151. package/esm/dev-server/health-checker/checkers/eslint-health-checker.mjs.map +1 -1
  152. package/esm/dev-server/health-checker/checkers/oxlint-health-checker.mjs +33 -0
  153. package/esm/dev-server/health-checker/checkers/oxlint-health-checker.mjs.map +1 -0
  154. package/esm/dev-server/health-checker/default-health-checkers.mjs +31 -0
  155. package/esm/dev-server/health-checker/default-health-checkers.mjs.map +1 -0
  156. package/esm/dev-server/health-checker/file-health-checker.contract.d.mts +9 -3
  157. package/esm/dev-server/health-checker/file-health-checker.contract.d.mts.map +1 -1
  158. package/esm/dev-server/health-checker/files-healthcare.manager.mjs +15 -4
  159. package/esm/dev-server/health-checker/files-healthcare.manager.mjs.map +1 -1
  160. package/esm/dev-server/health-checker/oxlint-runner.mjs +302 -0
  161. package/esm/dev-server/health-checker/oxlint-runner.mjs.map +1 -0
  162. package/esm/dev-server/health-checker/workers/oxlint-health.worker.d.mts +1 -0
  163. package/esm/dev-server/health-checker/workers/oxlint-health.worker.mjs +42 -0
  164. package/esm/dev-server/health-checker/workers/oxlint-health.worker.mjs.map +1 -0
  165. package/esm/dev-server/loader/loader-port-acks.mjs +1 -1
  166. package/esm/dev-server/loader/loader-port-acks.mjs.map +1 -1
  167. package/esm/dev-server/loader/register-loader.mjs +1 -1
  168. package/esm/dev-server/loader/register-loader.mjs.map +1 -1
  169. package/esm/dev-server/loader/resolve-hook.mjs +1 -1
  170. package/esm/dev-server/loader/transpile-cache.mjs +1 -1
  171. package/esm/dev-server/model-resource-typings.mjs.map +1 -1
  172. package/esm/dev-server/module-loader.mjs +1 -0
  173. package/esm/dev-server/module-loader.mjs.map +1 -1
  174. package/esm/dev-server/parse-imports.mjs +1 -1
  175. package/esm/dev-server/parse-imports.mjs.map +1 -1
  176. package/esm/dev-server/route-types-publisher.mjs +1 -1
  177. package/esm/dev-server/start-development-server.mjs.map +1 -1
  178. package/esm/dev-server/translation-keys-sources.mjs +1 -1
  179. package/esm/dev-server/translation-keys-sources.mjs.map +1 -1
  180. package/esm/dev-server/tsconfig-manager.mjs.map +1 -1
  181. package/esm/dev-server/type-generator.mjs +3 -3
  182. package/esm/dev-server/type-generator.mjs.map +1 -1
  183. package/esm/dev-server/types.d.mts.map +1 -1
  184. package/esm/errors/container-key-missing-error.mjs +1 -0
  185. package/esm/errors/container-key-missing-error.mjs.map +1 -1
  186. package/esm/errors/error-codes.d.mts +653 -0
  187. package/esm/errors/error-codes.d.mts.map +1 -0
  188. package/esm/errors/error-codes.mjs +634 -0
  189. package/esm/errors/error-codes.mjs.map +1 -0
  190. package/esm/errors/esbuild-binary-missing-error.mjs +1 -0
  191. package/esm/errors/esbuild-binary-missing-error.mjs.map +1 -1
  192. package/esm/errors/index.d.mts +3 -1
  193. package/esm/errors/index.mjs +3 -1
  194. package/esm/errors/unknown-locale-error.mjs +1 -0
  195. package/esm/errors/unknown-locale-error.mjs.map +1 -1
  196. package/esm/errors/warlock-error.d.mts +23 -0
  197. package/esm/errors/warlock-error.d.mts.map +1 -0
  198. package/esm/errors/warlock-error.mjs +22 -0
  199. package/esm/errors/warlock-error.mjs.map +1 -0
  200. package/esm/generations/add-command.action.mjs +19 -3
  201. package/esm/generations/add-command.action.mjs.map +1 -1
  202. package/esm/generations/features/access.feature.mjs +1 -1
  203. package/esm/generations/features/access.feature.mjs.map +1 -1
  204. package/esm/generations/features/bull-board.feature.mjs +1 -1
  205. package/esm/generations/features/bull-board.feature.mjs.map +1 -1
  206. package/esm/generations/features/mysql.feature.mjs.map +1 -1
  207. package/esm/generations/features/notifications.feature.mjs +5 -2
  208. package/esm/generations/features/notifications.feature.mjs.map +1 -1
  209. package/esm/generations/features/queue.feature.mjs +1 -1
  210. package/esm/generations/features/queue.feature.mjs.map +1 -1
  211. package/esm/generations/features/react-email.feature.mjs +1 -1
  212. package/esm/generations/features/react-email.feature.mjs.map +1 -1
  213. package/esm/generations/features/shadcn.feature.mjs +1 -1
  214. package/esm/generations/features/shadcn.feature.mjs.map +1 -1
  215. package/esm/generations/features/shared/link-ai-package-import.mjs +1 -1
  216. package/esm/generations/features/shared/link-ai-package-import.mjs.map +1 -1
  217. package/esm/generations/features/shared/merge-web-sitemap-config.mjs.map +1 -1
  218. package/esm/generations/features/shared/patch-tsconfig-include.mjs +1 -1
  219. package/esm/generations/features/shared/patch-tsconfig-include.mjs.map +1 -1
  220. package/esm/generations/features/shared/relocate-conflicting-home-route.mjs +1 -1
  221. package/esm/generations/features/shared/relocate-conflicting-home-route.mjs.map +1 -1
  222. package/esm/generations/features/sitemap.feature.mjs +1 -1
  223. package/esm/generations/features/sitemap.feature.mjs.map +1 -1
  224. package/esm/generations/features/tailwind.feature.mjs +1 -1
  225. package/esm/generations/features/tailwind.feature.mjs.map +1 -1
  226. package/esm/generations/features/test.feature.mjs +11 -6
  227. package/esm/generations/features/test.feature.mjs.map +1 -1
  228. package/esm/generations/features/web.feature.mjs +1 -1
  229. package/esm/generations/features/web.feature.mjs.map +1 -1
  230. package/esm/generations/generation-fs.mjs +73 -0
  231. package/esm/generations/generation-fs.mjs.map +1 -0
  232. package/esm/generations/generation-run.mjs +185 -0
  233. package/esm/generations/generation-run.mjs.map +1 -0
  234. package/esm/generations/stubs.mjs +155 -13
  235. package/esm/generations/stubs.mjs.map +1 -1
  236. package/esm/http/bounded-stream-queue.d.mts +10 -0
  237. package/esm/http/bounded-stream-queue.d.mts.map +1 -0
  238. package/esm/http/bounded-stream-queue.mjs +97 -0
  239. package/esm/http/bounded-stream-queue.mjs.map +1 -0
  240. package/esm/http/build-rate-limit-options.d.mts +13 -0
  241. package/esm/http/build-rate-limit-options.d.mts.map +1 -1
  242. package/esm/http/build-rate-limit-options.mjs.map +1 -1
  243. package/esm/http/conditional-request.d.mts +86 -0
  244. package/esm/http/conditional-request.d.mts.map +1 -0
  245. package/esm/http/conditional-request.mjs +121 -0
  246. package/esm/http/conditional-request.mjs.map +1 -0
  247. package/esm/http/csp.d.mts +2 -0
  248. package/esm/http/csp.d.mts.map +1 -1
  249. package/esm/http/csp.mjs +1 -0
  250. package/esm/http/csp.mjs.map +1 -1
  251. package/esm/http/csrf-origin-policy.mjs.map +1 -1
  252. package/esm/http/database/RequestLog.d.mts +24 -84
  253. package/esm/http/database/RequestLog.d.mts.map +1 -1
  254. package/esm/http/errors/errors.d.mts +2 -0
  255. package/esm/http/errors/errors.d.mts.map +1 -1
  256. package/esm/http/errors/errors.mjs +1 -0
  257. package/esm/http/errors/errors.mjs.map +1 -1
  258. package/esm/http/escape-header-value.d.mts +18 -0
  259. package/esm/http/escape-header-value.d.mts.map +1 -0
  260. package/esm/http/escape-header-value.mjs +27 -0
  261. package/esm/http/escape-header-value.mjs.map +1 -0
  262. package/esm/http/flush-pending-cookies.mjs.map +1 -1
  263. package/esm/http/index.d.mts +5 -2
  264. package/esm/http/index.mjs +4 -1
  265. package/esm/http/lazy-static.mjs +194 -0
  266. package/esm/http/lazy-static.mjs.map +1 -0
  267. package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
  268. package/esm/http/plugins.d.mts.map +1 -1
  269. package/esm/http/plugins.mjs +7 -4
  270. package/esm/http/plugins.mjs.map +1 -1
  271. package/esm/http/rate-limit-cache-store.mjs +2 -1
  272. package/esm/http/rate-limit-cache-store.mjs.map +1 -1
  273. package/esm/http/request-log-snapshot.d.mts +12 -5
  274. package/esm/http/request-log-snapshot.d.mts.map +1 -1
  275. package/esm/http/request-log-snapshot.mjs +83 -4
  276. package/esm/http/request-log-snapshot.mjs.map +1 -1
  277. package/esm/http/request.d.mts +2 -2
  278. package/esm/http/request.d.mts.map +1 -1
  279. package/esm/http/request.mjs +5 -4
  280. package/esm/http/request.mjs.map +1 -1
  281. package/esm/http/response.d.mts +11 -1
  282. package/esm/http/response.d.mts.map +1 -1
  283. package/esm/http/response.mjs +164 -76
  284. package/esm/http/response.mjs.map +1 -1
  285. package/esm/http/safe-redirect.d.mts +51 -0
  286. package/esm/http/safe-redirect.d.mts.map +1 -0
  287. package/esm/http/safe-redirect.mjs +80 -0
  288. package/esm/http/safe-redirect.mjs.map +1 -0
  289. package/esm/http/serialized.d.mts.map +1 -1
  290. package/esm/http/server.d.mts +3 -1
  291. package/esm/http/server.d.mts.map +1 -1
  292. package/esm/http/server.mjs +14 -4
  293. package/esm/http/server.mjs.map +1 -1
  294. package/esm/http/stream-transport.mjs +4 -2
  295. package/esm/http/stream-transport.mjs.map +1 -1
  296. package/esm/http/types.d.mts +44 -11
  297. package/esm/http/types.d.mts.map +1 -1
  298. package/esm/http/uploads/generate-image-variant.mjs +1 -1
  299. package/esm/http/uploads/generate-image-variants.d.mts +10 -7
  300. package/esm/http/uploads/generate-image-variants.d.mts.map +1 -1
  301. package/esm/http/uploads/generate-image-variants.mjs +61 -24
  302. package/esm/http/uploads/generate-image-variants.mjs.map +1 -1
  303. package/esm/http/uploads/image-variant-cache-entries.mjs +78 -0
  304. package/esm/http/uploads/image-variant-cache-entries.mjs.map +1 -0
  305. package/esm/http/uploads/image-variant-cache.mjs +72 -30
  306. package/esm/http/uploads/image-variant-cache.mjs.map +1 -1
  307. package/esm/http/uploads/image-variant-types.d.mts +2 -0
  308. package/esm/http/uploads/image-variant-types.d.mts.map +1 -1
  309. package/esm/http/uploads/image-variants-config-error.d.mts +3 -1
  310. package/esm/http/uploads/image-variants-config-error.d.mts.map +1 -1
  311. package/esm/http/uploads/image-variants-config-error.mjs +3 -2
  312. package/esm/http/uploads/image-variants-config-error.mjs.map +1 -1
  313. package/esm/http/uploads/load-variant-source.mjs +1 -1
  314. package/esm/http/uploads/load-variant-source.mjs.map +1 -1
  315. package/esm/http/uploads/purge-image-variants.d.mts +7 -2
  316. package/esm/http/uploads/purge-image-variants.d.mts.map +1 -1
  317. package/esm/http/uploads/purge-image-variants.mjs +16 -16
  318. package/esm/http/uploads/purge-image-variants.mjs.map +1 -1
  319. package/esm/http/uploads/remote-variant-source.mjs +115 -0
  320. package/esm/http/uploads/remote-variant-source.mjs.map +1 -0
  321. package/esm/http/uploads/resolve-image-variant.d.mts +3 -4
  322. package/esm/http/uploads/resolve-image-variant.d.mts.map +1 -1
  323. package/esm/http/uploads/resolve-image-variant.mjs +10 -18
  324. package/esm/http/uploads/resolve-image-variant.mjs.map +1 -1
  325. package/esm/http/uploads/resolve-image-variants-config.mjs +5 -3
  326. package/esm/http/uploads/resolve-image-variants-config.mjs.map +1 -1
  327. package/esm/http/uploads/resolve-remote-image-variant.mjs +89 -0
  328. package/esm/http/uploads/resolve-remote-image-variant.mjs.map +1 -0
  329. package/esm/http/uploads/trim-image-variant-cache.mjs +193 -0
  330. package/esm/http/uploads/trim-image-variant-cache.mjs.map +1 -0
  331. package/esm/http/uploads/uploaded-file.controller.d.mts +5 -3
  332. package/esm/http/uploads/uploaded-file.controller.d.mts.map +1 -1
  333. package/esm/http/uploads/uploaded-file.controller.mjs +16 -8
  334. package/esm/http/uploads/uploaded-file.controller.mjs.map +1 -1
  335. package/esm/http/uploads/variant-cache-key.mjs +1 -1
  336. package/esm/http/uploads-types.d.mts +6 -2
  337. package/esm/http/uploads-types.d.mts.map +1 -1
  338. package/esm/index.d.mts +17 -6
  339. package/esm/index.mjs +14 -3
  340. package/esm/localization/parse-locale-dictionary.d.mts +2 -0
  341. package/esm/localization/parse-locale-dictionary.d.mts.map +1 -1
  342. package/esm/localization/parse-locale-dictionary.mjs +1 -0
  343. package/esm/localization/parse-locale-dictionary.mjs.map +1 -1
  344. package/esm/mail/config.d.mts +12 -1
  345. package/esm/mail/config.d.mts.map +1 -1
  346. package/esm/mail/config.mjs +16 -1
  347. package/esm/mail/config.mjs.map +1 -1
  348. package/esm/mail/index.d.mts +1 -1
  349. package/esm/mail/index.mjs +1 -1
  350. package/esm/net/index.d.mts +2 -0
  351. package/esm/net/index.mjs +3 -0
  352. package/esm/openapi/build-openapi-document.d.mts.map +1 -1
  353. package/esm/openapi/build-openapi-document.mjs +8 -5
  354. package/esm/openapi/build-openapi-document.mjs.map +1 -1
  355. package/esm/openapi/error-responses.mjs +28 -2
  356. package/esm/openapi/error-responses.mjs.map +1 -1
  357. package/esm/openapi/postman/build-request-body.mjs.map +1 -1
  358. package/esm/openapi/postman/build-request-url.mjs.map +1 -1
  359. package/esm/openapi/postman/build-saved-responses.mjs.map +1 -1
  360. package/esm/openapi/postman/example-from-schema.d.mts.map +1 -1
  361. package/esm/openapi/postman/example-from-schema.mjs.map +1 -1
  362. package/esm/openapi/postman/openapi-to-postman-collection.d.mts.map +1 -1
  363. package/esm/openapi/postman/openapi-to-postman-collection.mjs.map +1 -1
  364. package/esm/openapi/postman/schema-refs.mjs.map +1 -1
  365. package/esm/openapi/postman/uuid-v5.mjs.map +1 -1
  366. package/esm/openapi/request-schemas.mjs.map +1 -1
  367. package/esm/openapi/response-schemas.mjs.map +1 -1
  368. package/esm/openapi/schema-registry.d.mts +1 -0
  369. package/esm/openapi/schema-registry.mjs.map +1 -1
  370. package/esm/openapi/security.mjs.map +1 -1
  371. package/esm/openapi/types.d.mts +3 -2
  372. package/esm/openapi/types.d.mts.map +1 -1
  373. package/esm/production/assert-generated-imports.mjs +1 -0
  374. package/esm/production/assert-generated-imports.mjs.map +1 -1
  375. package/esm/production/production-builder.mjs +12 -4
  376. package/esm/production/production-builder.mjs.map +1 -1
  377. package/esm/production/resolve-build-config.mjs +1 -0
  378. package/esm/production/resolve-build-config.mjs.map +1 -1
  379. package/esm/production/route-registration-child.mjs.map +1 -1
  380. package/esm/production/route-registration-snapshot.mjs.map +1 -1
  381. package/esm/repositories/contracts/query-builder.contract.d.mts.map +1 -1
  382. package/esm/repositories/contracts/types.d.mts.map +1 -1
  383. package/esm/repositories/repository.manager.mjs.map +1 -1
  384. package/esm/resource/resource.d.mts.map +1 -1
  385. package/esm/resource/resource.mjs.map +1 -1
  386. package/esm/resource/types.d.mts.map +1 -1
  387. package/esm/restful/restful.d.mts +5 -5
  388. package/esm/restful/restful.d.mts.map +1 -1
  389. package/esm/restful/restful.mjs.map +1 -1
  390. package/esm/router/build-route-rate-limit.mjs.map +1 -1
  391. package/esm/router/dev-dispatch.mjs +31 -12
  392. package/esm/router/dev-dispatch.mjs.map +1 -1
  393. package/esm/router/index.d.mts +4 -2
  394. package/esm/router/index.mjs +2 -0
  395. package/esm/router/log-request-lifecycle.mjs.map +1 -1
  396. package/esm/router/positional-handler-diagnostics.d.mts.map +1 -1
  397. package/esm/router/positional-handler-diagnostics.mjs.map +1 -1
  398. package/esm/router/resolve-route-rate-limit.mjs +47 -0
  399. package/esm/router/resolve-route-rate-limit.mjs.map +1 -0
  400. package/esm/router/resolve-route-validation.mjs +19 -0
  401. package/esm/router/resolve-route-validation.mjs.map +1 -0
  402. package/esm/router/route-guard-names.mjs +30 -0
  403. package/esm/router/route-guard-names.mjs.map +1 -0
  404. package/esm/router/route-name-taken-error.d.mts +14 -0
  405. package/esm/router/route-name-taken-error.d.mts.map +1 -0
  406. package/esm/router/route-name-taken-error.mjs +18 -0
  407. package/esm/router/route-name-taken-error.mjs.map +1 -0
  408. package/esm/router/router.d.mts +32 -13
  409. package/esm/router/router.d.mts.map +1 -1
  410. package/esm/router/router.mjs +71 -38
  411. package/esm/router/router.mjs.map +1 -1
  412. package/esm/router/types.d.mts +137 -17
  413. package/esm/router/types.d.mts.map +1 -1
  414. package/esm/router/unguarded-route-diagnostics.d.mts +40 -0
  415. package/esm/router/unguarded-route-diagnostics.d.mts.map +1 -0
  416. package/esm/router/unguarded-route-diagnostics.mjs +95 -0
  417. package/esm/router/unguarded-route-diagnostics.mjs.map +1 -0
  418. package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
  419. package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
  420. package/esm/storage/drivers/local-driver.d.mts.map +1 -1
  421. package/esm/storage/drivers/local-driver.mjs.map +1 -1
  422. package/esm/storage/local-disk-roots.mjs +24 -0
  423. package/esm/storage/local-disk-roots.mjs.map +1 -0
  424. package/esm/storage/storage.d.mts +14 -0
  425. package/esm/storage/storage.d.mts.map +1 -1
  426. package/esm/storage/storage.mjs +22 -0
  427. package/esm/storage/storage.mjs.map +1 -1
  428. package/esm/storage/types.d.mts.map +1 -1
  429. package/esm/storage/utils/storage-not-initialized-error.d.mts +2 -0
  430. package/esm/storage/utils/storage-not-initialized-error.d.mts.map +1 -1
  431. package/esm/storage/utils/storage-not-initialized-error.mjs +1 -0
  432. package/esm/storage/utils/storage-not-initialized-error.mjs.map +1 -1
  433. package/esm/tests/authenticated-test-client.d.mts +32 -0
  434. package/esm/tests/authenticated-test-client.d.mts.map +1 -0
  435. package/esm/tests/authenticated-test-client.mjs +40 -0
  436. package/esm/tests/authenticated-test-client.mjs.map +1 -0
  437. package/esm/tests/factories.d.mts +59 -0
  438. package/esm/tests/factories.d.mts.map +1 -0
  439. package/esm/tests/factories.mjs +105 -0
  440. package/esm/tests/factories.mjs.map +1 -0
  441. package/esm/tests/fakes/cache-fake.d.mts +29 -0
  442. package/esm/tests/fakes/cache-fake.d.mts.map +1 -0
  443. package/esm/tests/fakes/cache-fake.mjs +79 -0
  444. package/esm/tests/fakes/cache-fake.mjs.map +1 -0
  445. package/esm/tests/fakes/clock-fake.d.mts +32 -0
  446. package/esm/tests/fakes/clock-fake.d.mts.map +1 -0
  447. package/esm/tests/fakes/clock-fake.mjs +69 -0
  448. package/esm/tests/fakes/clock-fake.mjs.map +1 -0
  449. package/esm/tests/fakes/fake-assertion-error.d.mts +13 -0
  450. package/esm/tests/fakes/fake-assertion-error.d.mts.map +1 -0
  451. package/esm/tests/fakes/fake-assertion-error.mjs +20 -0
  452. package/esm/tests/fakes/fake-assertion-error.mjs.map +1 -0
  453. package/esm/tests/fakes/ids-fake.d.mts +22 -0
  454. package/esm/tests/fakes/ids-fake.d.mts.map +1 -0
  455. package/esm/tests/fakes/ids-fake.mjs +57 -0
  456. package/esm/tests/fakes/ids-fake.mjs.map +1 -0
  457. package/esm/tests/fakes/index.d.mts +8 -0
  458. package/esm/tests/fakes/index.mjs +10 -0
  459. package/esm/tests/fakes/mail-fake.d.mts +41 -0
  460. package/esm/tests/fakes/mail-fake.d.mts.map +1 -0
  461. package/esm/tests/fakes/mail-fake.mjs +111 -0
  462. package/esm/tests/fakes/mail-fake.mjs.map +1 -0
  463. package/esm/tests/fakes/queue-fake.d.mts +48 -0
  464. package/esm/tests/fakes/queue-fake.d.mts.map +1 -0
  465. package/esm/tests/fakes/queue-fake.mjs +134 -0
  466. package/esm/tests/fakes/queue-fake.mjs.map +1 -0
  467. package/esm/tests/fakes/storage-fake.d.mts +31 -0
  468. package/esm/tests/fakes/storage-fake.d.mts.map +1 -0
  469. package/esm/tests/fakes/storage-fake.mjs +122 -0
  470. package/esm/tests/fakes/storage-fake.mjs.map +1 -0
  471. package/esm/tests/fakes/test-fakes.d.mts +39 -0
  472. package/esm/tests/fakes/test-fakes.d.mts.map +1 -0
  473. package/esm/tests/fakes/test-fakes.mjs +90 -0
  474. package/esm/tests/fakes/test-fakes.mjs.map +1 -0
  475. package/esm/tests/index.d.mts +14 -2
  476. package/esm/tests/index.mjs +15 -2
  477. package/esm/tests/snapshot-response.d.mts +34 -0
  478. package/esm/tests/snapshot-response.d.mts.map +1 -0
  479. package/esm/tests/snapshot-response.mjs +42 -0
  480. package/esm/tests/snapshot-response.mjs.map +1 -0
  481. package/esm/tests/start-http-development-server.d.mts +22 -0
  482. package/esm/tests/start-http-development-server.d.mts.map +1 -1
  483. package/esm/tests/start-http-development-server.mjs +36 -3
  484. package/esm/tests/start-http-development-server.mjs.map +1 -1
  485. package/esm/tests/test-helpers.d.mts +20 -1
  486. package/esm/tests/test-helpers.d.mts.map +1 -1
  487. package/esm/tests/test-helpers.mjs +40 -27
  488. package/esm/tests/test-helpers.mjs.map +1 -1
  489. package/esm/tests/test-http-server.d.mts +62 -0
  490. package/esm/tests/test-http-server.d.mts.map +1 -0
  491. package/esm/tests/test-http-server.mjs +119 -0
  492. package/esm/tests/test-http-server.mjs.map +1 -0
  493. package/esm/tests/vitest-setup.d.mts +11 -0
  494. package/esm/tests/vitest-setup.d.mts.map +1 -1
  495. package/esm/tests/vitest-setup.mjs +12 -4
  496. package/esm/tests/vitest-setup.mjs.map +1 -1
  497. package/esm/tooling/agents-md/agents-md-markers.d.mts +27 -0
  498. package/esm/tooling/agents-md/agents-md-markers.d.mts.map +1 -0
  499. package/esm/tooling/agents-md/agents-md-markers.mjs +59 -0
  500. package/esm/tooling/agents-md/agents-md-markers.mjs.map +1 -0
  501. package/esm/tooling/agents-md/agents-md-refresher.d.mts +36 -0
  502. package/esm/tooling/agents-md/agents-md-refresher.d.mts.map +1 -0
  503. package/esm/tooling/agents-md/agents-md-refresher.mjs +72 -0
  504. package/esm/tooling/agents-md/agents-md-refresher.mjs.map +1 -0
  505. package/esm/tooling/agents-md/index.mjs +7 -0
  506. package/esm/tooling/agents-md/installed-skills.d.mts +30 -0
  507. package/esm/tooling/agents-md/installed-skills.d.mts.map +1 -0
  508. package/esm/tooling/agents-md/installed-skills.mjs +74 -0
  509. package/esm/tooling/agents-md/installed-skills.mjs.map +1 -0
  510. package/esm/tooling/agents-md/render-agents-md.d.mts +33 -0
  511. package/esm/tooling/agents-md/render-agents-md.d.mts.map +1 -0
  512. package/esm/tooling/agents-md/render-agents-md.mjs +195 -0
  513. package/esm/tooling/agents-md/render-agents-md.mjs.map +1 -0
  514. package/esm/tooling/agents-md/write-agents-md.d.mts +33 -0
  515. package/esm/tooling/agents-md/write-agents-md.d.mts.map +1 -0
  516. package/esm/tooling/agents-md/write-agents-md.mjs +49 -0
  517. package/esm/tooling/agents-md/write-agents-md.mjs.map +1 -0
  518. package/esm/tooling/board/board-message.d.mts +31 -0
  519. package/esm/tooling/board/board-message.d.mts.map +1 -0
  520. package/esm/tooling/board/board-message.mjs +86 -0
  521. package/esm/tooling/board/board-message.mjs.map +1 -0
  522. package/esm/tooling/board/board.d.mts +109 -0
  523. package/esm/tooling/board/board.d.mts.map +1 -0
  524. package/esm/tooling/board/board.mjs +406 -0
  525. package/esm/tooling/board/board.mjs.map +1 -0
  526. package/esm/tooling/board/board.types.d.mts +72 -0
  527. package/esm/tooling/board/board.types.d.mts.map +1 -0
  528. package/esm/tooling/board/board.types.mjs +54 -0
  529. package/esm/tooling/board/board.types.mjs.map +1 -0
  530. package/esm/tooling/check/changed-files.d.mts +33 -0
  531. package/esm/tooling/check/changed-files.d.mts.map +1 -0
  532. package/esm/tooling/check/changed-files.mjs +73 -0
  533. package/esm/tooling/check/changed-files.mjs.map +1 -0
  534. package/esm/tooling/check/check-report.types.d.mts +62 -0
  535. package/esm/tooling/check/check-report.types.d.mts.map +1 -0
  536. package/esm/tooling/check/check-report.types.mjs +37 -0
  537. package/esm/tooling/check/check-report.types.mjs.map +1 -0
  538. package/esm/tooling/check/code-style-conventions.mjs +106 -0
  539. package/esm/tooling/check/code-style-conventions.mjs.map +1 -0
  540. package/esm/tooling/check/conventions-step.d.mts +34 -0
  541. package/esm/tooling/check/conventions-step.d.mts.map +1 -0
  542. package/esm/tooling/check/conventions-step.mjs +184 -0
  543. package/esm/tooling/check/conventions-step.mjs.map +1 -0
  544. package/esm/tooling/check/environment-step.d.mts +18 -0
  545. package/esm/tooling/check/environment-step.d.mts.map +1 -0
  546. package/esm/tooling/check/environment-step.mjs +78 -0
  547. package/esm/tooling/check/environment-step.mjs.map +1 -0
  548. package/esm/tooling/check/index.d.mts +8 -0
  549. package/esm/tooling/check/index.mjs +10 -0
  550. package/esm/tooling/check/lint-step.d.mts +19 -0
  551. package/esm/tooling/check/lint-step.d.mts.map +1 -0
  552. package/esm/tooling/check/lint-step.mjs +111 -0
  553. package/esm/tooling/check/lint-step.mjs.map +1 -0
  554. package/esm/tooling/check/request-input.mjs +132 -0
  555. package/esm/tooling/check/request-input.mjs.map +1 -0
  556. package/esm/tooling/check/run-check.d.mts +35 -0
  557. package/esm/tooling/check/run-check.d.mts.map +1 -0
  558. package/esm/tooling/check/run-check.mjs +192 -0
  559. package/esm/tooling/check/run-check.mjs.map +1 -0
  560. package/esm/tooling/check/run-tests.d.mts +48 -0
  561. package/esm/tooling/check/run-tests.d.mts.map +1 -0
  562. package/esm/tooling/check/run-tests.mjs +93 -0
  563. package/esm/tooling/check/run-tests.mjs.map +1 -0
  564. package/esm/tooling/check/security-conventions.mjs +648 -0
  565. package/esm/tooling/check/security-conventions.mjs.map +1 -0
  566. package/esm/tooling/check/source-ast.mjs +195 -0
  567. package/esm/tooling/check/source-ast.mjs.map +1 -0
  568. package/esm/tooling/check/source-files.mjs +27 -0
  569. package/esm/tooling/check/source-files.mjs.map +1 -0
  570. package/esm/tooling/check/tests-step.d.mts +34 -0
  571. package/esm/tooling/check/tests-step.d.mts.map +1 -0
  572. package/esm/tooling/check/tests-step.mjs +177 -0
  573. package/esm/tooling/check/tests-step.mjs.map +1 -0
  574. package/esm/tooling/dev-state/dev-server-state.d.mts +39 -0
  575. package/esm/tooling/dev-state/dev-server-state.d.mts.map +1 -0
  576. package/esm/tooling/dev-state/dev-server-state.mjs +67 -0
  577. package/esm/tooling/dev-state/dev-server-state.mjs.map +1 -0
  578. package/esm/tooling/devtools/devtools-client.d.mts +91 -0
  579. package/esm/tooling/devtools/devtools-client.d.mts.map +1 -0
  580. package/esm/tooling/devtools/devtools-client.mjs +155 -0
  581. package/esm/tooling/devtools/devtools-client.mjs.map +1 -0
  582. package/esm/tooling/generate/generation.d.mts +78 -0
  583. package/esm/tooling/generate/generation.d.mts.map +1 -0
  584. package/esm/tooling/generate/generation.mjs +123 -0
  585. package/esm/tooling/generate/generation.mjs.map +1 -0
  586. package/esm/tooling/generate/generator-spec.d.mts +57 -0
  587. package/esm/tooling/generate/generator-spec.d.mts.map +1 -0
  588. package/esm/tooling/generate/generator-spec.mjs +102 -0
  589. package/esm/tooling/generate/generator-spec.mjs.map +1 -0
  590. package/esm/tooling/generate/index.mjs +6 -0
  591. package/esm/tooling/generate/project-files.mjs +121 -0
  592. package/esm/tooling/generate/project-files.mjs.map +1 -0
  593. package/esm/tooling/generate/run-cli.d.mts +40 -0
  594. package/esm/tooling/generate/run-cli.d.mts.map +1 -0
  595. package/esm/tooling/generate/run-cli.mjs +93 -0
  596. package/esm/tooling/generate/run-cli.mjs.map +1 -0
  597. package/esm/tooling/generate/unified-diff.d.mts +37 -0
  598. package/esm/tooling/generate/unified-diff.d.mts.map +1 -0
  599. package/esm/tooling/generate/unified-diff.mjs +161 -0
  600. package/esm/tooling/generate/unified-diff.mjs.map +1 -0
  601. package/esm/tooling/index.d.mts +41 -0
  602. package/esm/tooling/index.mjs +45 -0
  603. package/esm/tooling/inspect/boot-for-inspect.d.mts +23 -0
  604. package/esm/tooling/inspect/boot-for-inspect.d.mts.map +1 -0
  605. package/esm/tooling/inspect/boot-for-inspect.mjs +63 -0
  606. package/esm/tooling/inspect/boot-for-inspect.mjs.map +1 -0
  607. package/esm/tooling/inspect/collect-config.mjs +77 -0
  608. package/esm/tooling/inspect/collect-config.mjs.map +1 -0
  609. package/esm/tooling/inspect/collect-models.d.mts +9 -0
  610. package/esm/tooling/inspect/collect-models.d.mts.map +1 -0
  611. package/esm/tooling/inspect/collect-models.mjs +154 -0
  612. package/esm/tooling/inspect/collect-models.mjs.map +1 -0
  613. package/esm/tooling/inspect/collect-packages.d.mts +10 -0
  614. package/esm/tooling/inspect/collect-packages.d.mts.map +1 -0
  615. package/esm/tooling/inspect/collect-packages.mjs +157 -0
  616. package/esm/tooling/inspect/collect-packages.mjs.map +1 -0
  617. package/esm/tooling/inspect/collect-pages.mjs +108 -0
  618. package/esm/tooling/inspect/collect-pages.mjs.map +1 -0
  619. package/esm/tooling/inspect/collect-routes.mjs +168 -0
  620. package/esm/tooling/inspect/collect-routes.mjs.map +1 -0
  621. package/esm/tooling/inspect/event-recorder.d.mts +37 -0
  622. package/esm/tooling/inspect/event-recorder.d.mts.map +1 -0
  623. package/esm/tooling/inspect/event-recorder.mjs +91 -0
  624. package/esm/tooling/inspect/event-recorder.mjs.map +1 -0
  625. package/esm/tooling/inspect/index.d.mts +7 -0
  626. package/esm/tooling/inspect/index.mjs +7 -0
  627. package/esm/tooling/inspect/inspect-app.d.mts +53 -0
  628. package/esm/tooling/inspect/inspect-app.d.mts.map +1 -0
  629. package/esm/tooling/inspect/inspect-app.mjs +92 -0
  630. package/esm/tooling/inspect/inspect-app.mjs.map +1 -0
  631. package/esm/tooling/inspect/inspect-report.schema.d.mts +15 -0
  632. package/esm/tooling/inspect/inspect-report.schema.d.mts.map +1 -0
  633. package/esm/tooling/inspect/inspect-report.schema.mjs +463 -0
  634. package/esm/tooling/inspect/inspect-report.schema.mjs.map +1 -0
  635. package/esm/tooling/inspect/inspect-report.types.d.mts +196 -0
  636. package/esm/tooling/inspect/inspect-report.types.d.mts.map +1 -0
  637. package/esm/tooling/inspect/inspect-report.types.mjs +33 -0
  638. package/esm/tooling/inspect/inspect-report.types.mjs.map +1 -0
  639. package/esm/tooling/mcp/create-mcp-context.d.mts +26 -0
  640. package/esm/tooling/mcp/create-mcp-context.d.mts.map +1 -0
  641. package/esm/tooling/mcp/create-mcp-context.mjs +75 -0
  642. package/esm/tooling/mcp/create-mcp-context.mjs.map +1 -0
  643. package/esm/tooling/mcp/db-schema.d.mts +49 -0
  644. package/esm/tooling/mcp/db-schema.d.mts.map +1 -0
  645. package/esm/tooling/mcp/db-schema.mjs +56 -0
  646. package/esm/tooling/mcp/db-schema.mjs.map +1 -0
  647. package/esm/tooling/mcp/docs-search.d.mts +72 -0
  648. package/esm/tooling/mcp/docs-search.d.mts.map +1 -0
  649. package/esm/tooling/mcp/docs-search.mjs +178 -0
  650. package/esm/tooling/mcp/docs-search.mjs.map +1 -0
  651. package/esm/tooling/mcp/index.mjs +9 -0
  652. package/esm/tooling/mcp/load-ai-tools.d.mts +62 -0
  653. package/esm/tooling/mcp/load-ai-tools.d.mts.map +1 -0
  654. package/esm/tooling/mcp/load-ai-tools.mjs +44 -0
  655. package/esm/tooling/mcp/load-ai-tools.mjs.map +1 -0
  656. package/esm/tooling/mcp/mcp-tools.d.mts +60 -0
  657. package/esm/tooling/mcp/mcp-tools.d.mts.map +1 -0
  658. package/esm/tooling/mcp/mcp-tools.mjs +513 -0
  659. package/esm/tooling/mcp/mcp-tools.mjs.map +1 -0
  660. package/esm/tooling/mcp/start-mcp-server.d.mts +56 -0
  661. package/esm/tooling/mcp/start-mcp-server.d.mts.map +1 -0
  662. package/esm/tooling/mcp/start-mcp-server.mjs +126 -0
  663. package/esm/tooling/mcp/start-mcp-server.mjs.map +1 -0
  664. package/esm/tooling/mcp/tool-input.d.mts +75 -0
  665. package/esm/tooling/mcp/tool-input.d.mts.map +1 -0
  666. package/esm/tooling/mcp/tool-input.mjs +72 -0
  667. package/esm/tooling/mcp/tool-input.mjs.map +1 -0
  668. package/esm/tooling/problem.d.mts +45 -0
  669. package/esm/tooling/problem.d.mts.map +1 -0
  670. package/esm/tooling/problem.mjs +28 -0
  671. package/esm/tooling/problem.mjs.map +1 -0
  672. package/esm/tooling/trace/trace-report.types.d.mts +71 -0
  673. package/esm/tooling/trace/trace-report.types.d.mts.map +1 -0
  674. package/esm/tooling/trace/trace-report.types.mjs +7 -0
  675. package/esm/tooling/trace/trace-report.types.mjs.map +1 -0
  676. package/esm/tooling/trace/trace-request.d.mts +83 -0
  677. package/esm/tooling/trace/trace-request.d.mts.map +1 -0
  678. package/esm/tooling/trace/trace-request.mjs +241 -0
  679. package/esm/tooling/trace/trace-request.mjs.map +1 -0
  680. package/esm/tooling/typecheck/index.d.mts +1 -0
  681. package/esm/tooling/typecheck/index.mjs +3 -0
  682. package/esm/tooling/typecheck/run-typecheck.d.mts +59 -0
  683. package/esm/tooling/typecheck/run-typecheck.d.mts.map +1 -0
  684. package/esm/tooling/typecheck/run-typecheck.mjs +153 -0
  685. package/esm/tooling/typecheck/run-typecheck.mjs.map +1 -0
  686. package/esm/upgrade/codemods/head-viewport.mjs +46 -0
  687. package/esm/upgrade/codemods/head-viewport.mjs.map +1 -0
  688. package/esm/upgrade/codemods/helpers.mjs +81 -0
  689. package/esm/upgrade/codemods/helpers.mjs.map +1 -0
  690. package/esm/upgrade/codemods/index.mjs +34 -0
  691. package/esm/upgrade/codemods/index.mjs.map +1 -0
  692. package/esm/upgrade/codemods/logger-sync-calls.mjs +57 -0
  693. package/esm/upgrade/codemods/logger-sync-calls.mjs.map +1 -0
  694. package/esm/upgrade/codemods/package-json.mjs +122 -0
  695. package/esm/upgrade/codemods/package-json.mjs.map +1 -0
  696. package/esm/upgrade/codemods/request-log-snapshot.mjs +82 -0
  697. package/esm/upgrade/codemods/request-log-snapshot.mjs.map +1 -0
  698. package/esm/upgrade/codemods/review-sites.mjs +262 -0
  699. package/esm/upgrade/codemods/review-sites.mjs.map +1 -0
  700. package/esm/upgrade/diff.mjs +119 -0
  701. package/esm/upgrade/diff.mjs.map +1 -0
  702. package/esm/upgrade/format-upgrade-report.mjs +32 -0
  703. package/esm/upgrade/format-upgrade-report.mjs.map +1 -0
  704. package/esm/upgrade/load-ts-morph.mjs +48 -0
  705. package/esm/upgrade/load-ts-morph.mjs.map +1 -0
  706. package/esm/upgrade/notes.mjs +16 -0
  707. package/esm/upgrade/notes.mjs.map +1 -0
  708. package/esm/upgrade/run-upgrade.mjs +246 -0
  709. package/esm/upgrade/run-upgrade.mjs.map +1 -0
  710. package/esm/upgrade/upgrade-command.action.mjs +37 -0
  711. package/esm/upgrade/upgrade-command.action.mjs.map +1 -0
  712. package/esm/upgrade/version.mjs +39 -0
  713. package/esm/upgrade/version.mjs.map +1 -0
  714. package/esm/use-cases/use-cases-registry.mjs.map +1 -1
  715. package/esm/utils/clock.d.mts +33 -0
  716. package/esm/utils/clock.d.mts.map +1 -0
  717. package/esm/utils/clock.mjs +27 -0
  718. package/esm/utils/clock.mjs.map +1 -0
  719. package/esm/utils/framework-vesion.mjs +1 -1
  720. package/esm/utils/framework-vesion.mjs.map +1 -1
  721. package/esm/utils/ids.d.mts +32 -0
  722. package/esm/utils/ids.d.mts.map +1 -0
  723. package/esm/utils/ids.mjs +33 -0
  724. package/esm/utils/ids.mjs.map +1 -0
  725. package/esm/utils/index.d.mts +3 -0
  726. package/esm/utils/index.mjs +3 -0
  727. package/esm/utils/runtime.d.mts +59 -0
  728. package/esm/utils/runtime.d.mts.map +1 -0
  729. package/esm/utils/runtime.mjs +85 -0
  730. package/esm/utils/runtime.mjs.map +1 -0
  731. package/esm/validation/index.d.mts +1 -1
  732. package/esm/validation/types.d.mts +57 -2
  733. package/esm/validation/types.d.mts.map +1 -1
  734. package/esm/validation/validateAll.mjs +19 -2
  735. package/esm/validation/validateAll.mjs.map +1 -1
  736. package/esm/validation/validation-failure-status.mjs +15 -0
  737. package/esm/validation/validation-failure-status.mjs.map +1 -0
  738. package/esm/validation/validators/file-validator.d.mts +0 -16
  739. package/esm/validation/validators/file-validator.d.mts.map +1 -1
  740. package/esm/warlock-config/bundle-config.mjs +1 -1
  741. package/esm/warlock-config/types.d.mts +27 -3
  742. package/esm/warlock-config/types.d.mts.map +1 -1
  743. package/llms-full.txt +3166 -736
  744. package/llms.txt +16 -6
  745. package/package.json +43 -13
  746. package/schemas/inspect-report.schema.json +554 -0
  747. package/skills/README.md +9 -0
  748. package/skills/add-connector/SKILL.md +26 -38
  749. package/skills/benchmark-code/SKILL.md +30 -24
  750. package/skills/build-restful/SKILL.md +14 -14
  751. package/skills/build-url/SKILL.md +18 -18
  752. package/skills/configure-app/SKILL.md +107 -14
  753. package/skills/create-controller/SKILL.md +25 -12
  754. package/skills/create-module/SKILL.md +3 -3
  755. package/skills/define-resource/SKILL.md +32 -29
  756. package/skills/encrypt-data/SKILL.md +21 -19
  757. package/skills/generate-openapi/SKILL.md +50 -24
  758. package/skills/hash-password/SKILL.md +2 -2
  759. package/skills/health-checks/SKILL.md +24 -7
  760. package/skills/index.md +9 -4
  761. package/skills/lower-stage3-decorators/SKILL.md +4 -4
  762. package/skills/make-endpoint/SKILL.md +110 -0
  763. package/skills/model-factories/SKILL.md +92 -0
  764. package/skills/process-image/SKILL.md +32 -30
  765. package/skills/register-route/SKILL.md +109 -10
  766. package/skills/request-memo/SKILL.md +1 -1
  767. package/skills/request-tracing/SKILL.md +4 -1
  768. package/skills/resolve-path/SKILL.md +45 -44
  769. package/skills/retry-operation/SKILL.md +20 -11
  770. package/skills/run-app/SKILL.md +106 -22
  771. package/skills/send-response/SKILL.md +179 -14
  772. package/skills/store-file/SKILL.md +93 -53
  773. package/skills/test-fakes/SKILL.md +123 -0
  774. package/skills/test-http/SKILL.md +125 -21
  775. package/skills/test-service/SKILL.md +41 -1
  776. package/skills/update-packages/SKILL.md +29 -18
  777. package/skills/upgrade-from-5-29/SKILL.md +413 -0
  778. package/skills/upload-file/SKILL.md +31 -33
  779. package/skills/use-app-context/SKILL.md +38 -31
  780. package/skills/use-middleware/SKILL.md +45 -25
  781. package/skills/use-model-transformers/SKILL.md +37 -28
  782. package/skills/use-repository/SKILL.md +2 -2
  783. package/skills/validate-input/SKILL.md +72 -28
  784. package/skills/warlock-agents-md/SKILL.md +96 -0
  785. package/skills/warlock-board/SKILL.md +123 -0
  786. package/skills/warlock-check/SKILL.md +132 -0
  787. package/skills/warlock-conventions/SKILL.md +115 -0
  788. package/skills/warlock-doctor/SKILL.md +55 -22
  789. package/skills/warlock-inspect/SKILL.md +134 -0
  790. package/skills/warlock-mcp/SKILL.md +120 -0
  791. package/skills/warlock-routes/SKILL.md +18 -11
  792. package/skills/warlock-trace/SKILL.md +81 -0
  793. package/skills/wire-socket/SKILL.md +8 -8
  794. package/skills/write-seeder/SKILL.md +46 -32
  795. package/skills/write-use-case/SKILL.md +40 -27
  796. package/esm/http/uploads/matches-if-none-match.mjs +0 -13
  797. package/esm/http/uploads/matches-if-none-match.mjs.map +0 -1
@@ -0,0 +1,311 @@
1
+ import { appPath, srcPath } from "../../../../utils/paths.mjs";
2
+ import "../../../../utils/index.mjs";
3
+ import { importAppModule } from "../../../../loader/app-module-importer.mjs";
4
+ import { recordSkippedFile, setGenerationDetail } from "../../../../generations/generation-run.mjs";
5
+ import { fileExistsAsync, getFileAsync, putFileAsync } from "../../../../generations/generation-fs.mjs";
6
+ import { parseModulePath, parseName, singularName } from "../utils/name-parser.mjs";
7
+ import { isDryRun, putFileAsync as putFileAsync$1, setDryRun } from "../utils/writer.mjs";
8
+ import { endpointControllerStub, endpointLabel, endpointLocaleEntries, endpointResourceStub, endpointRouteImports, endpointRouteRegistration, endpointRoutesFileStub, endpointSchemaStub, endpointServiceStub, endpointTestStub } from "../templates/endpoint-stubs.mjs";
9
+ import { readEndpointFields } from "../utils/endpoint-schema.mjs";
10
+ import path from "node:path";
11
+ import { existsSync, readFileSync } from "node:fs";
12
+ import { pathToFileURL } from "node:url";
13
+ import { colors } from "@mongez/copper";
14
+
15
+ //#region ../../packages/core/src/cli/commands/generate/generators/endpoint.generator.ts
16
+ const METHODS = [
17
+ "get",
18
+ "post",
19
+ "put",
20
+ "patch",
21
+ "delete"
22
+ ];
23
+ const USAGE = "Usage: warlock make endpoint <module>/<name> [--method post] [--path /posts] [--schema ./schema.ts] [--resource Post] [--auth | --public]";
24
+ /**
25
+ * Import an app TypeScript file from the CLI: register the framework's
26
+ * loader (path aliases, TypeScript) first, as `warlock dev` does.
27
+ */
28
+ const loadSchemaModuleWithAppLoader = async (absolutePath) => {
29
+ const { filesOrchestrator } = await import("../../../../dev-server/files-orchestrator.mjs");
30
+ const { warlockConfigManager } = await import("../../../../warlock-config/warlock-config.manager.mjs");
31
+ await warlockConfigManager.load();
32
+ await filesOrchestrator.init();
33
+ return await importAppModule(pathToFileURL(absolutePath).href);
34
+ };
35
+ function isSchemaLike(value) {
36
+ return typeof value === "object" && value !== null && "toJsonSchema" in value && typeof value.toJsonSchema === "function" && "schema" in value && typeof value.schema === "object";
37
+ }
38
+ var EndpointInputError = class extends Error {};
39
+ function fail(message) {
40
+ throw new EndpointInputError(message);
41
+ }
42
+ /** Pick the request schema out of the `--schema` module's exports. */
43
+ function pickSchemaExport(exports, preferredName) {
44
+ const preferred = exports[preferredName];
45
+ if (isSchemaLike(preferred)) return {
46
+ exportName: preferredName,
47
+ schema: preferred
48
+ };
49
+ const candidates = Object.entries(exports).filter((entry) => entry[0] !== "default" && isSchemaLike(entry[1]));
50
+ if (candidates.length === 1 && candidates[0]) return {
51
+ exportName: candidates[0][0],
52
+ schema: candidates[0][1]
53
+ };
54
+ const fallback = exports.default;
55
+ if (candidates.length === 0 && isSchemaLike(fallback)) return {
56
+ exportName: "default",
57
+ schema: fallback
58
+ };
59
+ const names = candidates.map(([name]) => name);
60
+ return fail(names.length === 0 ? `The schema file exports no seal object schema (v.object(...)). Export one, e.g. \`export const ${preferredName} = v.object({ ... })\`.` : `The schema file exports several object schemas (${names.join(", ")}). Name the one for this endpoint \`${preferredName}\`.`);
61
+ }
62
+ /**
63
+ * The `schema/<name>.schema.ts` content for a `--schema` file.
64
+ *
65
+ * A file already under `src/` is imported where it lives (one source of
66
+ * truth). A file outside `src/` — a scratch spec — is copied in, with its
67
+ * relative imports re-pointed at the new location. Either way the module
68
+ * exports `<name>Schema` and its `<Name>Schema` type, the names the
69
+ * controller and service import.
70
+ */
71
+ function schemaModuleFromFile(options) {
72
+ const { sourcePath, source, exportName, targetPath, valueName, typeName } = options;
73
+ const targetDirectory = path.dirname(targetPath);
74
+ if (isInside(srcPath(), sourcePath)) {
75
+ const specifier = toImportSpecifier(targetDirectory, sourcePath);
76
+ const header = `import type { Infer } from "@warlock.js/seal";`;
77
+ const footer = `export type ${typeName} = Infer<typeof ${valueName}>;\n`;
78
+ if (exportName === valueName) return `${header}\nimport { ${valueName} } from "${specifier}";\n\nexport { ${valueName} };\n\n${footer}`;
79
+ const local = exportName === "default" ? "source" : exportName;
80
+ return `${header}\n${exportName === "default" ? `import source from "${specifier}";` : `import { ${exportName} } from "${specifier}";`}\n\nexport const ${valueName} = ${local};\n\n${footer}`;
81
+ }
82
+ let content = source.replace(/(from\s+|import\s*\(\s*|import\s+)(["'])(\.{1,2}\/[^"']+)\2/g, (_match, prefix, quote, specifier) => {
83
+ return `${prefix}${quote}${toImportSpecifier(targetDirectory, path.resolve(path.dirname(sourcePath), specifier))}${quote}`;
84
+ });
85
+ if (exportName === "default") content = content.replace(/export\s+default\s+/, `export const ${valueName} = `);
86
+ else if (exportName !== valueName) content = `${content.trimEnd()}\n\nexport const ${valueName} = ${exportName};\n`;
87
+ if (!new RegExp(`export\\s+type\\s+${typeName}\\b`).test(content)) {
88
+ if (!/\bInfer\b/.test(content.split("\n").filter((line) => line.startsWith("import")).join("\n"))) content = `import type { Infer } from "@warlock.js/seal";\n${content}`;
89
+ content = `${content.trimEnd()}\n\nexport type ${typeName} = Infer<typeof ${valueName}>;\n`;
90
+ }
91
+ return content;
92
+ }
93
+ function isInside(directory, file) {
94
+ const relative = path.relative(directory, file);
95
+ return relative !== "" && !relative.startsWith("..") && !path.isAbsolute(relative);
96
+ }
97
+ /** A relative, extensionless, `/`-separated import specifier from `fromDirectory` to `file`. */
98
+ function toImportSpecifier(fromDirectory, file) {
99
+ const withoutExtension = file.replace(/\.(?:ts|tsx|mts|js|mjs)$/, "");
100
+ const relative = path.relative(fromDirectory, withoutExtension).split(path.sep).join("/");
101
+ return relative.startsWith(".") ? relative : `./${relative}`;
102
+ }
103
+ /** Parse and check the command input. Throws {@link EndpointInputError} with a fix. */
104
+ function readEndpointInput(data) {
105
+ const input = data.args[0];
106
+ if (!input) fail(`Endpoint name is required.\n${USAGE}`);
107
+ const { module, name } = parseModulePath(input);
108
+ if (!module || !name) fail(`Write the endpoint as <module>/<name>, e.g. posts/create-post.\n${USAGE}`);
109
+ const moduleName = parseName(module).kebab;
110
+ const rawMethod = String(data.options.method ?? "post").toLowerCase();
111
+ const method = METHODS.find((candidate) => candidate === rawMethod);
112
+ if (!method) fail(`Unknown --method "${rawMethod}". Use one of: ${METHODS.join(", ")}.`);
113
+ const wantsAuth = data.options.auth === true;
114
+ const wantsPublic = data.options.public === true;
115
+ if (wantsAuth && wantsPublic) fail("Pass either --auth or --public, not both.");
116
+ const rawPath = typeof data.options.path === "string" ? data.options.path : void 0;
117
+ const defaultPath = method === "get" || method === "post" ? `/${moduleName}` : `/${moduleName}/:id`;
118
+ const routePath = rawPath ? rawPath.startsWith("/") ? rawPath : `/${rawPath}` : defaultPath;
119
+ const resource = typeof data.options.resource === "string" && data.options.resource.trim() !== "" ? data.options.resource.trim() : singularName(moduleName).pascal;
120
+ const schemaFile = typeof data.options.schema === "string" && data.options.schema.trim() !== "" ? data.options.schema.trim() : void 0;
121
+ return {
122
+ module: moduleName,
123
+ name,
124
+ method,
125
+ path: routePath,
126
+ access: wantsPublic ? "public" : "guarded",
127
+ resource,
128
+ schemaFile,
129
+ force: data.options.force === true || data.options.f === true
130
+ };
131
+ }
132
+ /**
133
+ * Write a whole generated file unless it exists. Without `--force` an
134
+ * existing file is the app's own code: it is skipped and reported, never
135
+ * overwritten.
136
+ */
137
+ async function writeNewFile(target, content, force) {
138
+ if (!force && await fileExistsAsync(target)) {
139
+ recordSkippedFile(target, "exists (pass --force to overwrite)");
140
+ console.log(`${colors.yellow("-")} skipped ${colors.gray(displayPath(target))} (exists)`);
141
+ return;
142
+ }
143
+ await putFileAsync$1(target, content);
144
+ }
145
+ function displayPath(target) {
146
+ return path.relative(process.cwd(), target).split(path.sep).join("/");
147
+ }
148
+ /** Append the endpoint to the module's `routes.ts`, creating the file if needed. */
149
+ async function registerRoute(spec, routesPath) {
150
+ if (!existsSync(routesPath)) {
151
+ await putFileAsync(routesPath, endpointRoutesFileStub(spec));
152
+ logEdit(routesPath, "created");
153
+ return;
154
+ }
155
+ const current = await getFileAsync(routesPath);
156
+ const controller = `${spec.name.camel}Controller`;
157
+ if (new RegExp(`\\b${controller}\\b`).test(current)) {
158
+ recordSkippedFile(routesPath, `${controller} is already registered`);
159
+ console.log(`${colors.yellow("-")} skipped ${colors.gray(displayPath(routesPath))} (${controller} is already registered)`);
160
+ return;
161
+ }
162
+ const imports = [...endpointRouteImports(spec)];
163
+ if (!/import\s*\{[^}]*\brouter\b[^}]*\}\s*from\s*["']@warlock\.js\/core["']/.test(current)) imports.unshift(`import { router } from "@warlock.js/core";`);
164
+ if (spec.access === "guarded" && !/\bguarded\b/.test(current)) imports.unshift(`import { guarded } from "app/shared/utils/router";`);
165
+ const lines = current.split("\n");
166
+ let lastImport = -1;
167
+ let inImport = false;
168
+ for (let index = 0; index < lines.length; index++) {
169
+ const line = lines[index] ?? "";
170
+ if (/^import\s/.test(line)) inImport = true;
171
+ if (inImport && (/;\s*$/.test(line) || /from\s+["'][^"']+["']\s*$/.test(line))) {
172
+ lastImport = index;
173
+ inImport = false;
174
+ }
175
+ }
176
+ lines.splice(lastImport + 1, 0, ...imports);
177
+ await putFileAsync(routesPath, `${lines.join("\n").trimEnd()}\n\n${endpointRouteRegistration(spec)}`);
178
+ logEdit(routesPath, "updated");
179
+ }
180
+ /** Merge the endpoint's message into `utils/locales.json`; existing keys win. */
181
+ async function registerLocales(spec, localesPath) {
182
+ const entries = endpointLocaleEntries(spec);
183
+ if (!existsSync(localesPath)) {
184
+ await putFileAsync(localesPath, `${JSON.stringify(entries, null, 2)}\n`);
185
+ logEdit(localesPath, "created");
186
+ return;
187
+ }
188
+ let dictionary;
189
+ try {
190
+ const parsed = JSON.parse(await getFileAsync(localesPath));
191
+ if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error();
192
+ dictionary = parsed;
193
+ } catch {
194
+ recordSkippedFile(localesPath, "not a JSON object; add the message key by hand");
195
+ console.log(colors.yellow(`! ${displayPath(localesPath)} is not a JSON object; add ${Object.keys(entries).join(", ")} by hand.`));
196
+ return;
197
+ }
198
+ if (dictionary.$group !== void 0 && dictionary.$group !== spec.module) {
199
+ recordSkippedFile(localesPath, `declares $group "${String(dictionary.$group)}"`);
200
+ console.log(colors.yellow(`! ${displayPath(localesPath)} declares another $group; add ${spec.module}.${Object.keys(entries).join(", ")} by hand.`));
201
+ return;
202
+ }
203
+ const missing = Object.keys(entries).filter((key) => dictionary[key] === void 0);
204
+ if (missing.length === 0) {
205
+ recordSkippedFile(localesPath, "message key already present");
206
+ return;
207
+ }
208
+ for (const key of missing) dictionary[key] = entries[key];
209
+ await putFileAsync(localesPath, `${JSON.stringify(dictionary, null, 2)}\n`);
210
+ logEdit(localesPath, "updated");
211
+ }
212
+ function logEdit(target, verb) {
213
+ const prefix = isDryRun() ? `${colors.cyan("○")} would ${verb === "created" ? "create" : "update"}` : `${colors.green("✓")} ${verb}`;
214
+ console.log(`${prefix} ${colors.gray(displayPath(target))}`);
215
+ }
216
+ /**
217
+ * `warlock make endpoint <module>/<name>` — a spec-first endpoint.
218
+ *
219
+ * Writes, under `src/app/<module>/`: the request schema (from `--schema` or a
220
+ * stub), a service, the resource (unless it exists), one controller with its
221
+ * validation and OpenAPI `responseSchema`, the route (guarded, or
222
+ * `public: true` with `--public`), the success message in `utils/locales.json`,
223
+ * and `tests/<name>.test.ts`, which requests the endpoint over the real HTTP
224
+ * stack. Existing files are skipped and reported unless `--force`.
225
+ */
226
+ function createEndpointGenerator(loadSchemaModule = loadSchemaModuleWithAppLoader) {
227
+ return async (data) => {
228
+ let input;
229
+ try {
230
+ input = readEndpointInput(data);
231
+ } catch (error) {
232
+ if (!(error instanceof EndpointInputError)) throw error;
233
+ console.log(colors.red(`Error: ${error.message}`));
234
+ process.exit(1);
235
+ }
236
+ setDryRun(data.options.dryRun === true);
237
+ const name = parseName(input.name);
238
+ const modulePath = appPath(input.module);
239
+ const schemaPath = path.join(modulePath, "schema", `${name.kebab}.schema.ts`);
240
+ const valueName = `${name.camel}Schema`;
241
+ const typeName = `${name.pascal}Schema`;
242
+ let jsonSchema;
243
+ let schemaContent;
244
+ if (input.schemaFile) {
245
+ const sourcePath = path.resolve(process.cwd(), input.schemaFile);
246
+ if (!existsSync(sourcePath)) {
247
+ console.log(colors.red(`Error: Schema file not found: ${input.schemaFile}`));
248
+ process.exit(1);
249
+ }
250
+ let exports;
251
+ try {
252
+ exports = await loadSchemaModule(sourcePath);
253
+ } catch (error) {
254
+ console.log(colors.red(`Error: Could not load ${input.schemaFile} to read its fields: ${error instanceof Error ? error.message : String(error)}`));
255
+ process.exit(1);
256
+ }
257
+ let picked;
258
+ try {
259
+ picked = pickSchemaExport(exports, valueName);
260
+ } catch (error) {
261
+ console.log(colors.red(`Error: ${error instanceof Error ? error.message : String(error)}`));
262
+ process.exit(1);
263
+ }
264
+ jsonSchema = picked.schema.toJsonSchema("draft-2020-12");
265
+ if (path.resolve(sourcePath) !== path.resolve(schemaPath)) schemaContent = schemaModuleFromFile({
266
+ sourcePath,
267
+ source: readFileSync(sourcePath, "utf8"),
268
+ exportName: picked.exportName,
269
+ targetPath: schemaPath,
270
+ valueName,
271
+ typeName
272
+ });
273
+ }
274
+ const spec = {
275
+ module: input.module,
276
+ name,
277
+ method: input.method,
278
+ path: input.path,
279
+ access: input.access,
280
+ resource: parseName(input.resource),
281
+ fields: readEndpointFields(jsonSchema)
282
+ };
283
+ const resourcePath = path.join(modulePath, "resources", `${spec.resource.singular.kebab}.resource.ts`);
284
+ const testPath = path.join(modulePath, "tests", `${name.kebab}.test.ts`);
285
+ setGenerationDetail("endpoint", {
286
+ method: spec.method.toUpperCase(),
287
+ path: spec.path,
288
+ access: spec.access,
289
+ controller: `${name.camel}Controller`,
290
+ resource: `${spec.resource.pascal}Resource`,
291
+ fields: spec.fields.map((field) => field.name),
292
+ test: displayPath(testPath)
293
+ });
294
+ console.log(colors.cyan(`\nGenerating ${endpointLabel(spec)} in src/app/${spec.module}\n`));
295
+ if (input.schemaFile === void 0) await writeNewFile(schemaPath, endpointSchemaStub(spec), input.force);
296
+ else if (schemaContent !== void 0) await writeNewFile(schemaPath, schemaContent, input.force);
297
+ await writeNewFile(path.join(modulePath, "services", `${name.kebab}.service.ts`), endpointServiceStub(spec), input.force);
298
+ await writeNewFile(resourcePath, endpointResourceStub(spec), input.force);
299
+ await writeNewFile(path.join(modulePath, "controllers", `${name.kebab}.controller.ts`), endpointControllerStub(spec), input.force);
300
+ await registerRoute(spec, path.join(modulePath, "routes.ts"));
301
+ await registerLocales(spec, path.join(modulePath, "utils", "locales.json"));
302
+ await writeNewFile(testPath, endpointTestStub(spec), input.force);
303
+ console.log(colors.cyan(`\n${endpointLabel(spec)} ${isDryRun() ? "previewed" : "generated"} (${spec.access === "public" ? "public: true" : "guarded"}).`));
304
+ console.log(colors.gray(`Next: fill in services/${name.kebab}.service.ts, then run the test with \`warlock test --related ${displayPath(testPath)}\`.`));
305
+ };
306
+ }
307
+ const generateEndpoint = createEndpointGenerator();
308
+
309
+ //#endregion
310
+ export { generateEndpoint };
311
+ //# sourceMappingURL=endpoint.generator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint.generator.mjs","names":["putFileAsync","putEditedFileAsync"],"sources":["../../../../../../../../../../../packages/core/src/cli/commands/generate/generators/endpoint.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport type { CommandActionData } from \"../../../../commands/types\";\nimport {\n fileExistsAsync,\n getFileAsync,\n putFileAsync as putEditedFileAsync,\n} from \"../../../../generations/generation-fs\";\nimport { recordSkippedFile, setGenerationDetail } from \"../../../../generations/generation-run\";\nimport { importAppModule } from \"../../../../loader/app-module-importer\";\nimport { appPath, srcPath } from \"../../../../utils\";\nimport {\n type EndpointAccess,\n type EndpointMethod,\n type EndpointSpec,\n endpointControllerStub,\n endpointLabel,\n endpointLocaleEntries,\n endpointResourceStub,\n endpointRouteImports,\n endpointRouteRegistration,\n endpointRoutesFileStub,\n endpointSchemaStub,\n endpointServiceStub,\n endpointTestStub,\n} from \"../templates/endpoint-stubs\";\nimport { readEndpointFields } from \"../utils/endpoint-schema\";\nimport { parseModulePath, parseName, singularName } from \"../utils/name-parser\";\nimport { isDryRun, putFileAsync, setDryRun } from \"../utils/writer\";\n\nconst METHODS: readonly EndpointMethod[] = [\"get\", \"post\", \"put\", \"patch\", \"delete\"];\n\nconst USAGE =\n \"Usage: warlock make endpoint <module>/<name> [--method post] [--path /posts] [--schema ./schema.ts] [--resource Post] [--auth | --public]\";\n\n/** Loads the `--schema` file and returns its exports. Replaceable in tests. */\nexport type SchemaModuleLoader = (absolutePath: string) => Promise<Record<string, unknown>>;\n\n/**\n * Import an app TypeScript file from the CLI: register the framework's\n * loader (path aliases, TypeScript) first, as `warlock dev` does.\n */\nconst loadSchemaModuleWithAppLoader: SchemaModuleLoader = async (absolutePath) => {\n const { filesOrchestrator } = await import(\"../../../../dev-server/files-orchestrator\");\n const { warlockConfigManager } =\n await import(\"../../../../warlock-config/warlock-config.manager\");\n\n await warlockConfigManager.load();\n await filesOrchestrator.init();\n\n return (await importAppModule(pathToFileURL(absolutePath).href)) as Record<string, unknown>;\n};\n\n/** A seal object validator, recognised structurally so a second seal copy still counts. */\ntype SchemaLike = { toJsonSchema(target?: string): unknown; schema: unknown };\n\nfunction isSchemaLike(value: unknown): value is SchemaLike {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"toJsonSchema\" in value &&\n typeof value.toJsonSchema === \"function\" &&\n \"schema\" in value &&\n typeof value.schema === \"object\"\n );\n}\n\nclass EndpointInputError extends Error {}\n\nfunction fail(message: string): never {\n throw new EndpointInputError(message);\n}\n\n/** Pick the request schema out of the `--schema` module's exports. */\nexport function pickSchemaExport(\n exports: Record<string, unknown>,\n preferredName: string,\n): { exportName: string; schema: SchemaLike } {\n const preferred = exports[preferredName];\n\n if (isSchemaLike(preferred)) return { exportName: preferredName, schema: preferred };\n\n const candidates = Object.entries(exports).filter(\n (entry): entry is [string, SchemaLike] => entry[0] !== \"default\" && isSchemaLike(entry[1]),\n );\n\n if (candidates.length === 1 && candidates[0]) {\n return { exportName: candidates[0][0], schema: candidates[0][1] };\n }\n\n const fallback = exports.default;\n\n if (candidates.length === 0 && isSchemaLike(fallback)) {\n return { exportName: \"default\", schema: fallback };\n }\n\n const names = candidates.map(([name]) => name);\n\n return fail(\n names.length === 0\n ? `The schema file exports no seal object schema (v.object(...)). Export one, e.g. \\`export const ${preferredName} = v.object({ ... })\\`.`\n : `The schema file exports several object schemas (${names.join(\", \")}). Name the one for this endpoint \\`${preferredName}\\`.`,\n );\n}\n\n/**\n * The `schema/<name>.schema.ts` content for a `--schema` file.\n *\n * A file already under `src/` is imported where it lives (one source of\n * truth). A file outside `src/` — a scratch spec — is copied in, with its\n * relative imports re-pointed at the new location. Either way the module\n * exports `<name>Schema` and its `<Name>Schema` type, the names the\n * controller and service import.\n */\nexport function schemaModuleFromFile(options: {\n sourcePath: string;\n source: string;\n exportName: string;\n targetPath: string;\n valueName: string;\n typeName: string;\n}): string {\n const { sourcePath, source, exportName, targetPath, valueName, typeName } = options;\n const targetDirectory = path.dirname(targetPath);\n\n if (isInside(srcPath(), sourcePath)) {\n const specifier = toImportSpecifier(targetDirectory, sourcePath);\n const header = `import type { Infer } from \"@warlock.js/seal\";`;\n const footer = `export type ${typeName} = Infer<typeof ${valueName}>;\\n`;\n\n if (exportName === valueName) {\n return `${header}\\nimport { ${valueName} } from \"${specifier}\";\\n\\nexport { ${valueName} };\\n\\n${footer}`;\n }\n\n const local = exportName === \"default\" ? \"source\" : exportName;\n const importLine =\n exportName === \"default\"\n ? `import source from \"${specifier}\";`\n : `import { ${exportName} } from \"${specifier}\";`;\n\n return `${header}\\n${importLine}\\n\\nexport const ${valueName} = ${local};\\n\\n${footer}`;\n }\n\n let content = source.replace(\n /(from\\s+|import\\s*\\(\\s*|import\\s+)([\"'])(\\.{1,2}\\/[^\"']+)\\2/g,\n (_match, prefix: string, quote: string, specifier: string) => {\n const resolved = path.resolve(path.dirname(sourcePath), specifier);\n\n return `${prefix}${quote}${toImportSpecifier(targetDirectory, resolved)}${quote}`;\n },\n );\n\n if (exportName === \"default\") {\n content = content.replace(/export\\s+default\\s+/, `export const ${valueName} = `);\n } else if (exportName !== valueName) {\n content = `${content.trimEnd()}\\n\\nexport const ${valueName} = ${exportName};\\n`;\n }\n\n const hasType = new RegExp(`export\\\\s+type\\\\s+${typeName}\\\\b`).test(content);\n\n if (!hasType) {\n const importsInfer = /\\bInfer\\b/.test(\n content\n .split(\"\\n\")\n .filter((line) => line.startsWith(\"import\"))\n .join(\"\\n\"),\n );\n\n if (!importsInfer) content = `import type { Infer } from \"@warlock.js/seal\";\\n${content}`;\n\n content = `${content.trimEnd()}\\n\\nexport type ${typeName} = Infer<typeof ${valueName}>;\\n`;\n }\n\n return content;\n}\n\nfunction isInside(directory: string, file: string): boolean {\n const relative = path.relative(directory, file);\n\n return relative !== \"\" && !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n}\n\n/** A relative, extensionless, `/`-separated import specifier from `fromDirectory` to `file`. */\nfunction toImportSpecifier(fromDirectory: string, file: string): string {\n const withoutExtension = file.replace(/\\.(?:ts|tsx|mts|js|mjs)$/, \"\");\n const relative = path.relative(fromDirectory, withoutExtension).split(path.sep).join(\"/\");\n\n return relative.startsWith(\".\") ? relative : `./${relative}`;\n}\n\n/** Parse and check the command input. Throws {@link EndpointInputError} with a fix. */\nexport function readEndpointInput(data: CommandActionData): {\n module: string;\n name: string;\n method: EndpointMethod;\n path: string;\n access: EndpointAccess;\n resource: string;\n schemaFile?: string;\n force: boolean;\n} {\n const input = data.args[0];\n\n if (!input) fail(`Endpoint name is required.\\n${USAGE}`);\n\n const { module, name } = parseModulePath(input);\n\n if (!module || !name)\n fail(`Write the endpoint as <module>/<name>, e.g. posts/create-post.\\n${USAGE}`);\n\n const moduleName = parseName(module).kebab;\n const rawMethod = String(data.options.method ?? \"post\").toLowerCase();\n const method = METHODS.find((candidate) => candidate === rawMethod);\n\n if (!method) fail(`Unknown --method \"${rawMethod}\". Use one of: ${METHODS.join(\", \")}.`);\n\n const wantsAuth = data.options.auth === true;\n const wantsPublic = data.options.public === true;\n\n if (wantsAuth && wantsPublic) fail(\"Pass either --auth or --public, not both.\");\n\n const rawPath = typeof data.options.path === \"string\" ? data.options.path : undefined;\n const defaultPath =\n method === \"get\" || method === \"post\" ? `/${moduleName}` : `/${moduleName}/:id`;\n const routePath = rawPath ? (rawPath.startsWith(\"/\") ? rawPath : `/${rawPath}`) : defaultPath;\n const resource =\n typeof data.options.resource === \"string\" && data.options.resource.trim() !== \"\"\n ? data.options.resource.trim()\n : singularName(moduleName).pascal;\n const schemaFile =\n typeof data.options.schema === \"string\" && data.options.schema.trim() !== \"\"\n ? data.options.schema.trim()\n : undefined;\n\n return {\n module: moduleName,\n name,\n method,\n path: routePath,\n // Guarded unless the caller says, in so many words, that it is public.\n access: wantsPublic ? \"public\" : \"guarded\",\n resource,\n schemaFile,\n force: data.options.force === true || data.options.f === true,\n };\n}\n\n/**\n * Write a whole generated file unless it exists. Without `--force` an\n * existing file is the app's own code: it is skipped and reported, never\n * overwritten.\n */\nasync function writeNewFile(target: string, content: string, force: boolean): Promise<void> {\n if (!force && (await fileExistsAsync(target))) {\n recordSkippedFile(target, \"exists (pass --force to overwrite)\");\n console.log(`${colors.yellow(\"-\")} skipped ${colors.gray(displayPath(target))} (exists)`);\n return;\n }\n\n await putFileAsync(target, content);\n}\n\nfunction displayPath(target: string): string {\n return path.relative(process.cwd(), target).split(path.sep).join(\"/\");\n}\n\n/** Append the endpoint to the module's `routes.ts`, creating the file if needed. */\nasync function registerRoute(spec: EndpointSpec, routesPath: string): Promise<void> {\n if (!existsSync(routesPath)) {\n await putEditedFileAsync(routesPath, endpointRoutesFileStub(spec));\n logEdit(routesPath, \"created\");\n return;\n }\n\n const current = await getFileAsync(routesPath);\n const controller = `${spec.name.camel}Controller`;\n\n if (new RegExp(`\\\\b${controller}\\\\b`).test(current)) {\n recordSkippedFile(routesPath, `${controller} is already registered`);\n console.log(\n `${colors.yellow(\"-\")} skipped ${colors.gray(displayPath(routesPath))} (${controller} is already registered)`,\n );\n return;\n }\n\n const imports = [...endpointRouteImports(spec)];\n\n if (!/import\\s*\\{[^}]*\\brouter\\b[^}]*\\}\\s*from\\s*[\"']@warlock\\.js\\/core[\"']/.test(current)) {\n imports.unshift(`import { router } from \"@warlock.js/core\";`);\n }\n\n if (spec.access === \"guarded\" && !/\\bguarded\\b/.test(current)) {\n imports.unshift(`import { guarded } from \"app/shared/utils/router\";`);\n }\n\n const lines = current.split(\"\\n\");\n let lastImport = -1;\n let inImport = false;\n\n // An import may span lines; new imports go after the last statement ends.\n for (let index = 0; index < lines.length; index++) {\n const line = lines[index] ?? \"\";\n\n if (/^import\\s/.test(line)) inImport = true;\n\n if (inImport && (/;\\s*$/.test(line) || /from\\s+[\"'][^\"']+[\"']\\s*$/.test(line))) {\n lastImport = index;\n inImport = false;\n }\n }\n\n lines.splice(lastImport + 1, 0, ...imports);\n\n const updated = `${lines.join(\"\\n\").trimEnd()}\\n\\n${endpointRouteRegistration(spec)}`;\n\n await putEditedFileAsync(routesPath, updated);\n logEdit(routesPath, \"updated\");\n}\n\n/** Merge the endpoint's message into `utils/locales.json`; existing keys win. */\nasync function registerLocales(spec: EndpointSpec, localesPath: string): Promise<void> {\n const entries = endpointLocaleEntries(spec);\n\n if (!existsSync(localesPath)) {\n await putEditedFileAsync(localesPath, `${JSON.stringify(entries, null, 2)}\\n`);\n logEdit(localesPath, \"created\");\n return;\n }\n\n let dictionary: Record<string, unknown>;\n\n try {\n const parsed: unknown = JSON.parse(await getFileAsync(localesPath));\n\n if (parsed === null || typeof parsed !== \"object\" || Array.isArray(parsed)) throw new Error();\n\n dictionary = parsed as Record<string, unknown>;\n } catch {\n recordSkippedFile(localesPath, \"not a JSON object; add the message key by hand\");\n console.log(\n colors.yellow(\n `! ${displayPath(localesPath)} is not a JSON object; add ${Object.keys(entries).join(\", \")} by hand.`,\n ),\n );\n return;\n }\n\n if (dictionary.$group !== undefined && dictionary.$group !== spec.module) {\n recordSkippedFile(localesPath, `declares $group \"${String(dictionary.$group)}\"`);\n console.log(\n colors.yellow(\n `! ${displayPath(localesPath)} declares another $group; add ${spec.module}.${Object.keys(entries).join(\", \")} by hand.`,\n ),\n );\n return;\n }\n\n const missing = Object.keys(entries).filter((key) => dictionary[key] === undefined);\n\n if (missing.length === 0) {\n recordSkippedFile(localesPath, \"message key already present\");\n return;\n }\n\n for (const key of missing) dictionary[key] = entries[key];\n\n await putEditedFileAsync(localesPath, `${JSON.stringify(dictionary, null, 2)}\\n`);\n logEdit(localesPath, \"updated\");\n}\n\nfunction logEdit(target: string, verb: \"created\" | \"updated\"): void {\n const prefix = isDryRun()\n ? `${colors.cyan(\"○\")} would ${verb === \"created\" ? \"create\" : \"update\"}`\n : `${colors.green(\"✓\")} ${verb}`;\n\n console.log(`${prefix} ${colors.gray(displayPath(target))}`);\n}\n\n/**\n * `warlock make endpoint <module>/<name>` — a spec-first endpoint.\n *\n * Writes, under `src/app/<module>/`: the request schema (from `--schema` or a\n * stub), a service, the resource (unless it exists), one controller with its\n * validation and OpenAPI `responseSchema`, the route (guarded, or\n * `public: true` with `--public`), the success message in `utils/locales.json`,\n * and `tests/<name>.test.ts`, which requests the endpoint over the real HTTP\n * stack. Existing files are skipped and reported unless `--force`.\n */\nexport function createEndpointGenerator(\n loadSchemaModule: SchemaModuleLoader = loadSchemaModuleWithAppLoader,\n): (data: CommandActionData) => Promise<void> {\n return async (data) => {\n let input: ReturnType<typeof readEndpointInput>;\n\n try {\n input = readEndpointInput(data);\n } catch (error) {\n if (!(error instanceof EndpointInputError)) throw error;\n\n console.log(colors.red(`Error: ${error.message}`));\n process.exit(1);\n }\n\n setDryRun(data.options.dryRun === true);\n\n const name = parseName(input.name);\n const modulePath = appPath(input.module);\n const schemaPath = path.join(modulePath, \"schema\", `${name.kebab}.schema.ts`);\n const valueName = `${name.camel}Schema`;\n const typeName = `${name.pascal}Schema`;\n\n let jsonSchema: unknown;\n let schemaContent: string | undefined;\n\n if (input.schemaFile) {\n const sourcePath = path.resolve(process.cwd(), input.schemaFile);\n\n if (!existsSync(sourcePath)) {\n console.log(colors.red(`Error: Schema file not found: ${input.schemaFile}`));\n process.exit(1);\n }\n\n let exports: Record<string, unknown>;\n\n try {\n exports = await loadSchemaModule(sourcePath);\n } catch (error) {\n console.log(\n colors.red(\n `Error: Could not load ${input.schemaFile} to read its fields: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n process.exit(1);\n }\n\n let picked: ReturnType<typeof pickSchemaExport>;\n\n try {\n picked = pickSchemaExport(exports, valueName);\n } catch (error) {\n console.log(colors.red(`Error: ${error instanceof Error ? error.message : String(error)}`));\n process.exit(1);\n }\n\n jsonSchema = picked.schema.toJsonSchema(\"draft-2020-12\");\n\n if (path.resolve(sourcePath) !== path.resolve(schemaPath)) {\n schemaContent = schemaModuleFromFile({\n sourcePath,\n source: readFileSync(sourcePath, \"utf8\"),\n exportName: picked.exportName,\n targetPath: schemaPath,\n valueName,\n typeName,\n });\n }\n }\n\n const spec: EndpointSpec = {\n module: input.module,\n name,\n method: input.method,\n path: input.path,\n access: input.access,\n resource: parseName(input.resource),\n fields: readEndpointFields(jsonSchema),\n };\n\n const resourcePath = path.join(\n modulePath,\n \"resources\",\n `${spec.resource.singular.kebab}.resource.ts`,\n );\n const testPath = path.join(modulePath, \"tests\", `${name.kebab}.test.ts`);\n\n setGenerationDetail(\"endpoint\", {\n method: spec.method.toUpperCase(),\n path: spec.path,\n access: spec.access,\n controller: `${name.camel}Controller`,\n resource: `${spec.resource.pascal}Resource`,\n fields: spec.fields.map((field) => field.name),\n test: displayPath(testPath),\n });\n\n console.log(colors.cyan(`\\nGenerating ${endpointLabel(spec)} in src/app/${spec.module}\\n`));\n\n if (input.schemaFile === undefined) {\n await writeNewFile(schemaPath, endpointSchemaStub(spec), input.force);\n } else if (schemaContent !== undefined) {\n await writeNewFile(schemaPath, schemaContent, input.force);\n }\n\n await writeNewFile(\n path.join(modulePath, \"services\", `${name.kebab}.service.ts`),\n endpointServiceStub(spec),\n input.force,\n );\n await writeNewFile(resourcePath, endpointResourceStub(spec), input.force);\n await writeNewFile(\n path.join(modulePath, \"controllers\", `${name.kebab}.controller.ts`),\n endpointControllerStub(spec),\n input.force,\n );\n await registerRoute(spec, path.join(modulePath, \"routes.ts\"));\n await registerLocales(spec, path.join(modulePath, \"utils\", \"locales.json\"));\n await writeNewFile(testPath, endpointTestStub(spec), input.force);\n\n console.log(\n colors.cyan(\n `\\n${endpointLabel(spec)} ${isDryRun() ? \"previewed\" : \"generated\"} (${spec.access === \"public\" ? \"public: true\" : \"guarded\"}).`,\n ),\n );\n console.log(\n colors.gray(\n `Next: fill in services/${name.kebab}.service.ts, then run the test with \\`warlock test --related ${displayPath(testPath)}\\`.`,\n ),\n );\n };\n}\n\nexport const generateEndpoint = createEndpointGenerator();\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,MAAM,UAAqC;CAAC;CAAO;CAAQ;CAAO;CAAS;AAAQ;AAEnF,M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{ parseColumnDsl } from "./column-dsl-parser.mjs";
8
8
  import path from "node:path";
9
- import { colors } from "@mongez/copper";
10
9
  import { existsSync, readdirSync } from "node:fs";
10
+ import { colors } from "@mongez/copper";
11
11
 
12
12
  //#region ../../packages/core/src/cli/commands/generate/generators/migration.generator.ts
13
13
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"migration.generator.mjs","names":[],"sources":["../../../../../../../../../../../packages/core/src/cli/commands/generate/generators/migration.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { existsSync, readdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { appPath } from \"../../../../utils\";\nimport type { CommandActionData } from \"../../../../commands/types\";\nimport { migrationAlterStub, migrationStub } from \"../templates/stubs\";\nimport { migrationTimestamp } from \"../../../../generations/features/shared/migration-timestamp\";\nimport { parseColumnDsl } from \"./column-dsl-parser\";\nimport { parseName } from \"../utils/name-parser\";\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\n\n/**\n * Generate a migration file for a model\n */\n/**\n * Create a migration file for a model\n */\nexport async function createMigrationFile(\n moduleName: string,\n entityName: string,\n options: any = {},\n) {\n const entity = parseName(entityName);\n\n // Generate timestamp: MM-DD-YYYY_HH-MM-SS\n const timestamp = migrationTimestamp();\n\n // \"Create missing, skip existing\": never write a second CREATE-table migration\n // for an entity that already has one (it would fail with \"table already exists\").\n const isCreate = !(options.add || options.drop || options.rename);\n const existingDir = path.join(appPath(), moduleName, \"models\", entity.kebab, \"migrations\");\n\n if (isCreate && existsSync(existingDir) && readdirSync(existingDir).some((file) => file.endsWith(\".migration.ts\"))) {\n return undefined;\n }\n\n const migrationFileName = `${timestamp}-${entity.kebab}.migration.ts`;\n const migrationsPath = path.join(appPath(), moduleName, \"models\", entity.kebab, \"migrations\");\n\n // Ensure migrations directory exists\n await ensureDirectoryAsync(migrationsPath);\n\n const addParams = options.add as string;\n const dropParams = options.drop as string;\n const renameParams = options.rename as string;\n const timestamps =\n options.timestamps !== \"false\" && options.timestamps !== false && !options.noTimestamps;\n\n let migrationContent = \"\";\n\n if (addParams || dropParams || renameParams) {\n // Generate alter stub\n const parsedAdd = parseColumnDsl(addParams || \"\");\n const helpersSet = new Set<string>();\n\n const addLines = parsedAdd.map((col) => {\n helpersSet.add(col.helper);\n return ` ${col.name}: ${col.helper}()${col.modifiers.join(\"\")},`;\n });\n\n let formattedDrop: string | undefined = undefined;\n if (dropParams) {\n formattedDrop = JSON.stringify(dropParams.split(\",\").map((s) => s.trim()));\n }\n\n let formattedRename: string | undefined = undefined;\n if (renameParams) {\n const obj: Record<string, string> = {};\n renameParams\n .split(\",\")\n .map((s) => s.trim())\n .forEach((p) => {\n const [oldN, newN] = p.split(\":\").map((s) => s.trim());\n if (oldN && newN) obj[oldN] = newN;\n });\n formattedRename = JSON.stringify(obj, null, 2).replace(/\\n/g, \"\\n \");\n }\n\n migrationContent = migrationAlterStub(entity, {\n add: addLines.length > 0 ? addLines.join(\"\\n\") : undefined,\n drop: formattedDrop,\n rename: formattedRename,\n imports: Array.from(helpersSet),\n });\n } else {\n // Generate create stub\n migrationContent = migrationStub(entity, {\n timestamps,\n });\n }\n\n // Create migration file\n const migrationFilePath = path.join(migrationsPath, migrationFileName);\n await putFileAsync(migrationFilePath, migrationContent);\n\n return migrationFilePath;\n}\n\n/**\n * Generate a migration file for a model\n */\nexport async function generateMigration(data: CommandActionData) {\n const modelPath = data.args[0] as string;\n\n if (!modelPath) {\n console.log(colors.red(\"Error: Model path is required\"));\n console.log(colors.gray(\"Usage: warlock gen.migration <model-path>\"));\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\n process.exit(1);\n }\n\n // Parse model path (e.g., \"products/product\")\n const [moduleName, entityName] = modelPath.split(\"/\");\n\n if (!moduleName || !entityName) {\n console.log(colors.red(\"Error: Invalid model path format. Expected: <module>/<entity>\"));\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\n process.exit(1);\n }\n\n const entity = parseName(entityName);\n const modelFilePath = path.join(\n appPath(),\n moduleName,\n \"models\",\n entity.kebab,\n `${entity.kebab}.model.ts`,\n );\n\n if (!existsSync(modelFilePath)) {\n console.log(\n colors.red(`Error: Model not found at ${path.relative(appPath(), modelFilePath)}`),\n );\n console.log(colors.gray(\"Generate the model first: warlock gen.model \" + modelPath));\n process.exit(1);\n }\n\n setDryRun(Boolean(data.options.dryRun));\n\n const migrationFilePath = await createMigrationFile(moduleName, entityName, data.options);\n\n if (!migrationFilePath) {\n console.log(\n colors.yellow(\n \"Skipped: this model already has a create migration. Use --add/--drop/--rename for changes.\",\n ),\n );\n return;\n }\n\n console.log(\n colors.cyan(`\\n✨ Migration file created at: ${path.relative(appPath(), migrationFilePath)}`),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,eAAsB,oBACpB,YACA,YACA,UAAe,CAAC,GAChB;CACA,MAAM,SAAS,UAAU,UAAU;CAGnC,MAAM,YAAY,mBAAmB;CAIrC,MAAM,WAAW,EAAE,QAAQ,OAAO,QAAQ,QAAQ,QAAQ;CAC1D,MAAM,cAAc,KAAK,KAAK,QAAQ,GAAG,YAAY,UAAU,OAAO,OAAO,YAAY;CAEzF,IAAI,YAAY,WAAW,WAAW,KAAK,YAAY,WAAW,CAAC,CAAC,MAAM,SAAS,KAAK,SAAS,eAAe,CAAC,GAC/G;CAGF,MAAM,oBAAoB,GAAG,UAAU,GAAG,OAAO,MAAM;CACvD,MAAM,iBAAiB,KAAK,KAAK,QAAQ,GAAG,YAAY,UAAU,OAAO,OAAO,YAAY;CAG5F,MAAM,qBAAqB,cAAc;CAEzC,MAAM,YAAY,QAAQ;CAC1B,MAAM,aAAa,QAAQ;CAC3B,MAAM,eAAe,QAAQ;CAC7B,MAAM,aACJ,QAAQ,eAAe,WAAW,QAAQ,eAAe,SAAS,CAAC,QAAQ;CAE7E,IAAI,mBAAmB;CAEvB,IAAI,aAAa,cAAc,cAAc;EAE3C,MAAM,YAAY,eAAe,aAAa,EAAE;EAChD,MAAM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AAC;CAChB;CAGA,MAAM,CAAC,YAAY,cAAc,UAAU,MAAM,GAAG;CAEpD,IAAI,CAAC,cAAc,CAAC,YAAY;EAC9B,QAAQ,IAAI,OAAO,IAAI,+DAA+D,CAAC;EACvF,QAAQ,IAAI,OAAO,KAAK,iDAAiD,CAAC;EAC1E,QAAQ,KAAK,CAAC;CAChB;CAEA,MAAM,SAAS,UAAU,UAAU;CACnC,MAAM,gBAAgB,KAAK,KACzB,QAAQ,GACR,YACA,UACA,OAAO,OACP,GAAG,OAAO,MAAM,UAClB;CAEA,IAAI,CAAC,WAAW,aAAa,GAAG;EAC9B,QAAQ,IACN,OAAO,IAAI,6BAA6B,KAAK,SAAS,QAAQ,GAAG,aAAa,GAAG,CACnF;EACA,QAAQ,IAAI,OAAO,KAAK,iDAAiD,SAAS,CAAC;EACnF,QAAQ,KAAK,CAAC;CAChB;CAEA,UAAU,QAAQ,KAAK,QAAQ,MAAM,CAAC;CAEtC,MAAM,oBAAoB,MAAM,oBAAoB,YAAY,YAAY,KAAK,OAAO;CAExF,IAAI,CAAC,mBAAmB;EACtB,QAAQ,IACN,OAAO,OACL,4FACF,CACF;EACA;CACF;CAEA,QAAQ,IACN,OAAO,KAAK,kCAAkC,KAAK,SAAS,QAAQ,GAAG,iBAAiB,GAAG,CAC7F;AACF"}
1
+ {"version":3,"file":"migration.generator.mjs","names":[],"sources":["../../../../../../../../../../../packages/core/src/cli/commands/generate/generators/migration.generator.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { existsSync, readdirSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { appPath } from \"../../../../utils\";\nimport type { CommandActionData } from \"../../../../commands/types\";\nimport { migrationAlterStub, migrationStub } from \"../templates/stubs\";\nimport { migrationTimestamp } from \"../../../../generations/features/shared/migration-timestamp\";\nimport { parseColumnDsl } from \"./column-dsl-parser\";\nimport { parseName } from \"../utils/name-parser\";\nimport { ensureDirectoryAsync, putFileAsync, setDryRun } from \"../utils/writer\";\n\n/**\n * Generate a migration file for a model\n */\n/**\n * Create a migration file for a model\n */\nexport async function createMigrationFile(\n moduleName: string,\n entityName: string,\n options: any = {},\n) {\n const entity = parseName(entityName);\n\n // Generate timestamp: MM-DD-YYYY_HH-MM-SS\n const timestamp = migrationTimestamp();\n\n // \"Create missing, skip existing\": never write a second CREATE-table migration\n // for an entity that already has one (it would fail with \"table already exists\").\n const isCreate = !(options.add || options.drop || options.rename);\n const existingDir = path.join(appPath(), moduleName, \"models\", entity.kebab, \"migrations\");\n\n if (\n isCreate &&\n existsSync(existingDir) &&\n readdirSync(existingDir).some((file) => file.endsWith(\".migration.ts\"))\n ) {\n return undefined;\n }\n\n const migrationFileName = `${timestamp}-${entity.kebab}.migration.ts`;\n const migrationsPath = path.join(appPath(), moduleName, \"models\", entity.kebab, \"migrations\");\n\n // Ensure migrations directory exists\n await ensureDirectoryAsync(migrationsPath);\n\n const addParams = options.add as string;\n const dropParams = options.drop as string;\n const renameParams = options.rename as string;\n const timestamps =\n options.timestamps !== \"false\" && options.timestamps !== false && !options.noTimestamps;\n\n let migrationContent = \"\";\n\n if (addParams || dropParams || renameParams) {\n // Generate alter stub\n const parsedAdd = parseColumnDsl(addParams || \"\");\n const helpersSet = new Set<string>();\n\n const addLines = parsedAdd.map((col) => {\n helpersSet.add(col.helper);\n return ` ${col.name}: ${col.helper}()${col.modifiers.join(\"\")},`;\n });\n\n let formattedDrop: string | undefined = undefined;\n if (dropParams) {\n formattedDrop = JSON.stringify(dropParams.split(\",\").map((s) => s.trim()));\n }\n\n let formattedRename: string | undefined = undefined;\n if (renameParams) {\n const obj: Record<string, string> = {};\n renameParams\n .split(\",\")\n .map((s) => s.trim())\n .forEach((p) => {\n const [oldN, newN] = p.split(\":\").map((s) => s.trim());\n if (oldN && newN) obj[oldN] = newN;\n });\n formattedRename = JSON.stringify(obj, null, 2).replace(/\\n/g, \"\\n \");\n }\n\n migrationContent = migrationAlterStub(entity, {\n add: addLines.length > 0 ? addLines.join(\"\\n\") : undefined,\n drop: formattedDrop,\n rename: formattedRename,\n imports: Array.from(helpersSet),\n });\n } else {\n // Generate create stub\n migrationContent = migrationStub(entity, {\n timestamps,\n });\n }\n\n // Create migration file\n const migrationFilePath = path.join(migrationsPath, migrationFileName);\n await putFileAsync(migrationFilePath, migrationContent);\n\n return migrationFilePath;\n}\n\n/**\n * Generate a migration file for a model\n */\nexport async function generateMigration(data: CommandActionData) {\n const modelPath = data.args[0] as string;\n\n if (!modelPath) {\n console.log(colors.red(\"Error: Model path is required\"));\n console.log(colors.gray(\"Usage: warlock gen.migration <model-path>\"));\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\n process.exit(1);\n }\n\n // Parse model path (e.g., \"products/product\")\n const [moduleName, entityName] = modelPath.split(\"/\");\n\n if (!moduleName || !entityName) {\n console.log(colors.red(\"Error: Invalid model path format. Expected: <module>/<entity>\"));\n console.log(colors.gray(\"Example: warlock gen.migration products/product\"));\n process.exit(1);\n }\n\n const entity = parseName(entityName);\n const modelFilePath = path.join(\n appPath(),\n moduleName,\n \"models\",\n entity.kebab,\n `${entity.kebab}.model.ts`,\n );\n\n if (!existsSync(modelFilePath)) {\n console.log(colors.red(`Error: Model not found at ${path.relative(appPath(), modelFilePath)}`));\n console.log(colors.gray(\"Generate the model first: warlock gen.model \" + modelPath));\n process.exit(1);\n }\n\n setDryRun(Boolean(data.options.dryRun));\n\n const migrationFilePath = await createMigrationFile(moduleName, entityName, data.options);\n\n if (!migrationFilePath) {\n console.log(\n colors.yellow(\n \"Skipped: this model already has a create migration. Use --add/--drop/--rename for changes.\",\n ),\n );\n return;\n }\n\n console.log(\n colors.cyan(`\\n✨ Migration file created at: ${path.relative(appPath(), migrationFilePath)}`),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,eAAsB,oBACpB,YACA,YACA,UAAe,CAAC,GAChB;CACA,MAAM,SAAS,UAAU,UAAU;CAGnC,MAAM,YAAY,mBAAmB;CAIrC,MAAM,WAAW,EAAE,QA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oBAAoB,YAAY,YAAY,KAAK,OAAO;CAExF,IAAI,CAAC,mBAAmB;EACtB,QAAQ,IACN,OAAO,OACL,4FACF,CACF;EACA;CACF;CAEA,QAAQ,IACN,OAAO,KAAK,kCAAkC,KAAK,SAAS,QAAQ,GAAG,iBAAiB,GAAG,CAC7F;AACF"}
@@ -4,8 +4,8 @@ import { parseModulePath, singularName } from "../utils/name-parser.mjs";
4
4
  import { ensureDirectoryAsync, putFileAsync, reportSkippedFiles, setDryRun, setSkipExisting } from "../utils/writer.mjs";
5
5
  import { componentExists, ensureComponentDirectory, moduleExists, resolveComponentPath, resolveModulePath } from "../utils/path-resolver.mjs";
6
6
  import path from "node:path";
7
- import { colors } from "@mongez/copper";
8
7
  import { existsSync, readdirSync } from "node:fs";
8
+ import { colors } from "@mongez/copper";
9
9
 
10
10
  //#region ../../packages/core/src/cli/commands/generate/generators/model.generator.ts
11
11
  async function generateModel(data) {