@warlock.js/core 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (356) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/esm/application/application.d.mts.map +1 -1
  3. package/esm/application/application.mjs.map +1 -1
  4. package/esm/benchmark/benchmark-snapshots.d.mts.map +1 -1
  5. package/esm/benchmark/benchmark.d.mts.map +1 -1
  6. package/esm/benchmark/channels/console.channel.mjs.map +1 -1
  7. package/esm/benchmark/channels/noop.channel.d.mts.map +1 -1
  8. package/esm/benchmark/profiler.d.mts.map +1 -1
  9. package/esm/benchmark/profiler.mjs.map +1 -1
  10. package/esm/bootstrap/setup.d.mts.map +1 -1
  11. package/esm/bootstrap/setup.mjs.map +1 -1
  12. package/esm/bootstrap.d.mts.map +1 -1
  13. package/esm/cache/database-cache-driver.d.mts.map +1 -1
  14. package/esm/cache/database-cache-driver.mjs.map +1 -1
  15. package/esm/cli/cli-commands.manager.mjs.map +1 -1
  16. package/esm/cli/cli-commands.utils.mjs +16 -10
  17. package/esm/cli/cli-commands.utils.mjs.map +1 -1
  18. package/esm/cli/commands/doctor/boot-for-diagnostics.mjs.map +1 -1
  19. package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -1
  20. package/esm/cli/commands/doctor/checks/handler-signature.check.mjs.map +1 -1
  21. package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -1
  22. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -1
  23. package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -1
  24. package/esm/cli/commands/generate/generate.command.mjs.map +1 -1
  25. package/esm/cli/commands/generate/generators/column-dsl-parser.mjs.map +1 -1
  26. package/esm/cli/commands/generate/generators/migration.generator.mjs.map +1 -1
  27. package/esm/cli/commands/generate/generators/model.generator.mjs.map +1 -1
  28. package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
  29. package/esm/cli/commands/generate/utils/name-parser.mjs.map +1 -1
  30. package/esm/cli/commands/generate/utils/prompt.mjs.map +1 -1
  31. package/esm/cli/commands/routes/diff-page-routes.mjs +84 -0
  32. package/esm/cli/commands/routes/diff-page-routes.mjs.map +1 -0
  33. package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -1
  34. package/esm/cli/commands/routes/route-row.mjs.map +1 -1
  35. package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -1
  36. package/esm/cli/commands/routes/routes-diff.action.mjs +84 -0
  37. package/esm/cli/commands/routes/routes-diff.action.mjs.map +1 -0
  38. package/esm/cli/commands/routes.command.mjs +15 -1
  39. package/esm/cli/commands/routes.command.mjs.map +1 -1
  40. package/esm/cli/commands/start-production.command.mjs +8 -1
  41. package/esm/cli/commands/start-production.command.mjs.map +1 -1
  42. package/esm/cli/commands/storage-put.action.mjs.map +1 -1
  43. package/esm/cli/commands/typings-generator.command.mjs.map +1 -1
  44. package/esm/cli/commands-loader.mjs.map +1 -1
  45. package/esm/cli/framework-cli-commands.mjs +2 -1
  46. package/esm/cli/framework-cli-commands.mjs.map +1 -1
  47. package/esm/cli/start.mjs.map +1 -1
  48. package/esm/cli/string-similarity.mjs.map +1 -1
  49. package/esm/commands/cli-command.mjs.map +1 -1
  50. package/esm/config/config-loader.d.mts +1 -1
  51. package/esm/config/config-loader.d.mts.map +1 -1
  52. package/esm/config/config-loader.mjs.map +1 -1
  53. package/esm/config/config-setter.d.mts.map +1 -1
  54. package/esm/config/config-special-handlers.d.mts +1 -1
  55. package/esm/config/config-special-handlers.mjs.map +1 -1
  56. package/esm/config/load-config-files.mjs.map +1 -1
  57. package/esm/connectors/access-connector.d.mts.map +1 -1
  58. package/esm/connectors/ai-connector.d.mts.map +1 -1
  59. package/esm/connectors/assert-no-reserved-connector-names.mjs.map +1 -1
  60. package/esm/connectors/assert-unique-connector-names.mjs.map +1 -1
  61. package/esm/connectors/base-connector.d.mts.map +1 -1
  62. package/esm/connectors/base-connector.mjs.map +1 -1
  63. package/esm/connectors/cache-connector.d.mts.map +1 -1
  64. package/esm/connectors/connectors-manager.d.mts.map +1 -1
  65. package/esm/connectors/connectors-manager.mjs.map +1 -1
  66. package/esm/connectors/database-connector.d.mts.map +1 -1
  67. package/esm/connectors/describe-server-address.mjs +20 -3
  68. package/esm/connectors/describe-server-address.mjs.map +1 -1
  69. package/esm/connectors/herald-connector.d.mts.map +1 -1
  70. package/esm/connectors/http-connector.d.mts.map +1 -1
  71. package/esm/connectors/http-connector.mjs +5 -1
  72. package/esm/connectors/http-connector.mjs.map +1 -1
  73. package/esm/connectors/logger-connector.d.mts.map +1 -1
  74. package/esm/connectors/mail-connector.d.mts.map +1 -1
  75. package/esm/connectors/notifications-connector.d.mts.map +1 -1
  76. package/esm/connectors/register-configured-connectors.mjs.map +1 -1
  77. package/esm/connectors/socket-connector.d.mts.map +1 -1
  78. package/esm/connectors/socket-connector.mjs.map +1 -1
  79. package/esm/connectors/storage.connector.d.mts.map +1 -1
  80. package/esm/container/index.d.mts.map +1 -1
  81. package/esm/database/create-database-action.mjs.map +1 -1
  82. package/esm/database/drop-tables-action.mjs.map +1 -1
  83. package/esm/database/migrate-action.mjs.map +1 -1
  84. package/esm/database/models/database-log/database-log.mjs.map +1 -1
  85. package/esm/database/seed-command-action.mjs.map +1 -1
  86. package/esm/database/seeds/seed-records-table-migration.mjs +1 -1
  87. package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -1
  88. package/esm/database/seeds/seeder.mjs.map +1 -1
  89. package/esm/database/seeds/seeders.manager.mjs.map +1 -1
  90. package/esm/database/seeds/seeds-table-migration.mjs +1 -1
  91. package/esm/database/seeds/seeds-table-migration.mjs.map +1 -1
  92. package/esm/database/utils.mjs.map +1 -1
  93. package/esm/dev-server/check-for-updates.mjs.map +1 -1
  94. package/esm/dev-server/dependency-graph.d.mts.map +1 -1
  95. package/esm/dev-server/dependency-graph.mjs.map +1 -1
  96. package/esm/dev-server/dev-logger.mjs.map +1 -1
  97. package/esm/dev-server/development-server.mjs.map +1 -1
  98. package/esm/dev-server/file-event-handler.mjs.map +1 -1
  99. package/esm/dev-server/file-manager.d.mts.map +1 -1
  100. package/esm/dev-server/file-manager.mjs.map +1 -1
  101. package/esm/dev-server/file-operations.d.mts.map +1 -1
  102. package/esm/dev-server/files-orchestrator.mjs.map +1 -1
  103. package/esm/dev-server/files-watcher.mjs.map +1 -1
  104. package/esm/dev-server/health-checker/checkers/eslint-health-checker.mjs.map +1 -1
  105. package/esm/dev-server/health-checker/checkers/typescript-health-checker.mjs.map +1 -1
  106. package/esm/dev-server/health-checker/file-health-result.d.mts.map +1 -1
  107. package/esm/dev-server/health-checker/file-health-result.mjs.map +1 -1
  108. package/esm/dev-server/health-checker/files-healthcare.manager.mjs.map +1 -1
  109. package/esm/dev-server/layer-executor.mjs +10 -3
  110. package/esm/dev-server/layer-executor.mjs.map +1 -1
  111. package/esm/dev-server/loader/hook-thread.d.mts.map +1 -1
  112. package/esm/dev-server/loader/own-resolver.mjs.map +1 -1
  113. package/esm/dev-server/loader/register-loader.mjs.map +1 -1
  114. package/esm/dev-server/loader/resolve-hook.mjs.map +1 -1
  115. package/esm/dev-server/loader/source-slug.mjs.map +1 -1
  116. package/esm/dev-server/loader/transpile-cache.mjs +12 -3
  117. package/esm/dev-server/loader/transpile-cache.mjs.map +1 -1
  118. package/esm/dev-server/loader/version-registry.mjs.map +1 -1
  119. package/esm/dev-server/manifest-manager.d.mts.map +1 -1
  120. package/esm/dev-server/manifest-manager.mjs.map +1 -1
  121. package/esm/dev-server/module-loader.mjs.map +1 -1
  122. package/esm/dev-server/package-json-manager.mjs.map +1 -1
  123. package/esm/dev-server/parse-imports.mjs.map +1 -1
  124. package/esm/dev-server/ready-block.mjs.map +1 -1
  125. package/esm/dev-server/special-files-collector.d.mts.map +1 -1
  126. package/esm/dev-server/special-files-collector.mjs.map +1 -1
  127. package/esm/dev-server/supervisor.mjs +9 -6
  128. package/esm/dev-server/supervisor.mjs.map +1 -1
  129. package/esm/dev-server/tsconfig-manager.mjs.map +1 -1
  130. package/esm/dev-server/type-generator.mjs.map +1 -1
  131. package/esm/dev-server/utils.mjs.map +1 -1
  132. package/esm/encryption/encrypt.mjs.map +1 -1
  133. package/esm/encryption/hash.mjs.map +1 -1
  134. package/esm/encryption/password.mjs.map +1 -1
  135. package/esm/generations/add-command.action.mjs +11 -4
  136. package/esm/generations/add-command.action.mjs.map +1 -1
  137. package/esm/generations/features/access.feature.mjs +2 -1
  138. package/esm/generations/features/access.feature.mjs.map +1 -1
  139. package/esm/generations/features/ai-anthropic.feature.mjs +3 -1
  140. package/esm/generations/features/ai-anthropic.feature.mjs.map +1 -1
  141. package/esm/generations/features/ai-bedrock.feature.mjs +3 -1
  142. package/esm/generations/features/ai-bedrock.feature.mjs.map +1 -1
  143. package/esm/generations/features/ai-google.feature.mjs +3 -1
  144. package/esm/generations/features/ai-google.feature.mjs.map +1 -1
  145. package/esm/generations/features/ai-ollama.feature.mjs +3 -1
  146. package/esm/generations/features/ai-ollama.feature.mjs.map +1 -1
  147. package/esm/generations/features/ai-openai.feature.mjs +3 -1
  148. package/esm/generations/features/ai-openai.feature.mjs.map +1 -1
  149. package/esm/generations/features/ai-panoptic.feature.mjs +2 -1
  150. package/esm/generations/features/ai-panoptic.feature.mjs.map +1 -1
  151. package/esm/generations/features/ai-tools.feature.mjs +2 -1
  152. package/esm/generations/features/ai-tools.feature.mjs.map +1 -1
  153. package/esm/generations/features/ai-workspace.feature.mjs +2 -1
  154. package/esm/generations/features/ai-workspace.feature.mjs.map +1 -1
  155. package/esm/generations/features/ai.feature.mjs +2 -1
  156. package/esm/generations/features/ai.feature.mjs.map +1 -1
  157. package/esm/generations/features/herald.feature.mjs +2 -1
  158. package/esm/generations/features/herald.feature.mjs.map +1 -1
  159. package/esm/generations/features/notifications.feature.mjs +3 -2
  160. package/esm/generations/features/notifications.feature.mjs.map +1 -1
  161. package/esm/generations/features/scheduler.feature.mjs +3 -1
  162. package/esm/generations/features/scheduler.feature.mjs.map +1 -1
  163. package/esm/generations/features/shadcn.feature.mjs.map +1 -1
  164. package/esm/generations/features/shared/migration-timestamp.mjs.map +1 -1
  165. package/esm/generations/features/tailwind.feature.mjs.map +1 -1
  166. package/esm/generations/features/types.mjs +14 -0
  167. package/esm/generations/features/types.mjs.map +1 -0
  168. package/esm/generations/features/web.feature.mjs +10 -2
  169. package/esm/generations/features/web.feature.mjs.map +1 -1
  170. package/esm/generations/stubs.mjs +169 -28
  171. package/esm/generations/stubs.mjs.map +1 -1
  172. package/esm/http/boot-port-preflight.d.mts +46 -0
  173. package/esm/http/boot-port-preflight.d.mts.map +1 -0
  174. package/esm/http/boot-port-preflight.mjs +87 -0
  175. package/esm/http/boot-port-preflight.mjs.map +1 -0
  176. package/esm/http/context/request-context.d.mts.map +1 -1
  177. package/esm/http/context/request-context.mjs.map +1 -1
  178. package/esm/http/context/request-memo.d.mts.map +1 -1
  179. package/esm/http/context/request-memo.mjs.map +1 -1
  180. package/esm/http/createHttpApplication.d.mts.map +1 -1
  181. package/esm/http/createHttpApplication.mjs.map +1 -1
  182. package/esm/http/health.d.mts.map +1 -1
  183. package/esm/http/index.d.mts +1 -0
  184. package/esm/http/index.mjs +1 -0
  185. package/esm/http/middleware/cache-response-middleware.mjs.map +1 -1
  186. package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
  187. package/esm/http/middleware/inject-request-context.mjs.map +1 -1
  188. package/esm/http/middleware/ip-filter.middleware.d.mts +1 -1
  189. package/esm/http/middleware/ip-filter.middleware.mjs +1 -1
  190. package/esm/http/middleware/ip-filter.middleware.mjs.map +1 -1
  191. package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
  192. package/esm/http/middleware/utils/idempotency-key.mjs.map +1 -1
  193. package/esm/http/port-preflight.d.mts +8 -0
  194. package/esm/http/port-preflight.d.mts.map +1 -1
  195. package/esm/http/port-preflight.mjs +8 -1
  196. package/esm/http/port-preflight.mjs.map +1 -1
  197. package/esm/http/ready-report.d.mts.map +1 -1
  198. package/esm/http/request-controller.d.mts.map +1 -1
  199. package/esm/http/request.d.mts +14 -2
  200. package/esm/http/request.d.mts.map +1 -1
  201. package/esm/http/request.mjs +16 -2
  202. package/esm/http/request.mjs.map +1 -1
  203. package/esm/http/response.d.mts +3 -3
  204. package/esm/http/response.d.mts.map +1 -1
  205. package/esm/http/response.mjs.map +1 -1
  206. package/esm/http/server.d.mts.map +1 -1
  207. package/esm/http/server.mjs +26 -2
  208. package/esm/http/server.mjs.map +1 -1
  209. package/esm/http/types.d.mts +1 -3
  210. package/esm/http/types.d.mts.map +1 -1
  211. package/esm/http/uploaded-file.d.mts.map +1 -1
  212. package/esm/http/uploaded-file.mjs.map +1 -1
  213. package/esm/http/uploads-config.d.mts.map +1 -1
  214. package/esm/image/image.d.mts.map +1 -1
  215. package/esm/image/image.mjs.map +1 -1
  216. package/esm/index.d.mts +6 -1
  217. package/esm/index.mjs +6 -1
  218. package/esm/logger/fatal-visibility.d.mts +25 -0
  219. package/esm/logger/fatal-visibility.d.mts.map +1 -0
  220. package/esm/logger/fatal-visibility.mjs +31 -0
  221. package/esm/logger/fatal-visibility.mjs.map +1 -0
  222. package/esm/logger/index.d.mts +1 -0
  223. package/esm/logger/index.mjs +1 -0
  224. package/esm/logger/logger.mjs.map +1 -1
  225. package/esm/mail/config.d.mts.map +1 -1
  226. package/esm/mail/events.d.mts.map +1 -1
  227. package/esm/mail/mail.d.mts.map +1 -1
  228. package/esm/mail/mail.mjs.map +1 -1
  229. package/esm/mail/mailer-pool.d.mts.map +1 -1
  230. package/esm/mail/mailer-pool.mjs +2 -0
  231. package/esm/mail/mailer-pool.mjs.map +1 -1
  232. package/esm/mail/send-mail.mjs.map +1 -1
  233. package/esm/mail/test-mailbox.d.mts.map +1 -1
  234. package/esm/mail/test-mailbox.mjs.map +1 -1
  235. package/esm/production/assert-dist-ready-to-start.mjs +24 -0
  236. package/esm/production/assert-dist-ready-to-start.mjs.map +1 -0
  237. package/esm/production/assert-generated-imports.mjs.map +1 -1
  238. package/esm/production/build-app-production.mjs.map +1 -1
  239. package/esm/production/dist-build-manifest.mjs +47 -0
  240. package/esm/production/dist-build-manifest.mjs.map +1 -0
  241. package/esm/production/production-builder.mjs +68 -13
  242. package/esm/production/production-builder.mjs.map +1 -1
  243. package/esm/production/production-supervisor.mjs +21 -9
  244. package/esm/production/production-supervisor.mjs.map +1 -1
  245. package/esm/production/promote-dist.mjs +115 -0
  246. package/esm/production/promote-dist.mjs.map +1 -0
  247. package/esm/production/resolve-build-config.mjs.map +1 -1
  248. package/esm/repositories/adapters/cascade/cascade-adapter.d.mts.map +1 -1
  249. package/esm/repositories/adapters/cascade/cascade-adapter.mjs.map +1 -1
  250. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
  251. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
  252. package/esm/repositories/adapters/cascade/filter-applicator.mjs.map +1 -1
  253. package/esm/repositories/repository.manager.d.mts.map +1 -1
  254. package/esm/repositories/repository.manager.mjs.map +1 -1
  255. package/esm/resource/register-resource.d.mts.map +1 -1
  256. package/esm/resource/resource-field-builder.d.mts.map +1 -1
  257. package/esm/resource/resource-field-builder.mjs.map +1 -1
  258. package/esm/resource/resource.d.mts.map +1 -1
  259. package/esm/resource/resource.mjs.map +1 -1
  260. package/esm/restful/restful.d.mts.map +1 -1
  261. package/esm/restful/restful.mjs.map +1 -1
  262. package/esm/router/index.d.mts +3 -0
  263. package/esm/router/index.mjs +3 -0
  264. package/esm/router/log-request-lifecycle.mjs.map +1 -1
  265. package/esm/router/normalize-request-path.d.mts +14 -0
  266. package/esm/router/normalize-request-path.d.mts.map +1 -0
  267. package/esm/router/normalize-request-path.mjs +18 -0
  268. package/esm/router/normalize-request-path.mjs.map +1 -0
  269. package/esm/router/normalize-route-path.d.mts +28 -0
  270. package/esm/router/normalize-route-path.d.mts.map +1 -0
  271. package/esm/router/normalize-route-path.mjs +33 -0
  272. package/esm/router/normalize-route-path.mjs.map +1 -0
  273. package/esm/router/positional-handler-diagnostics.d.mts.map +1 -1
  274. package/esm/router/positional-handler-diagnostics.mjs.map +1 -1
  275. package/esm/router/route-name-method-suffix.d.mts +33 -0
  276. package/esm/router/route-name-method-suffix.d.mts.map +1 -0
  277. package/esm/router/route-name-method-suffix.mjs +39 -0
  278. package/esm/router/route-name-method-suffix.mjs.map +1 -0
  279. package/esm/router/route-registry.d.mts.map +1 -1
  280. package/esm/router/route-registry.mjs +3 -2
  281. package/esm/router/route-registry.mjs.map +1 -1
  282. package/esm/router/router.d.mts +14 -0
  283. package/esm/router/router.d.mts.map +1 -1
  284. package/esm/router/router.mjs +50 -11
  285. package/esm/router/router.mjs.map +1 -1
  286. package/esm/socket/utils.d.mts.map +1 -1
  287. package/esm/storage/config.d.mts.map +1 -1
  288. package/esm/storage/context/storage-driver-context.d.mts.map +1 -1
  289. package/esm/storage/drivers/cloud-driver.d.mts.map +1 -1
  290. package/esm/storage/drivers/cloud-driver.mjs.map +1 -1
  291. package/esm/storage/drivers/do-spaces-driver.d.mts.map +1 -1
  292. package/esm/storage/drivers/local-driver.d.mts.map +1 -1
  293. package/esm/storage/drivers/local-driver.mjs.map +1 -1
  294. package/esm/storage/drivers/r2-driver.d.mts.map +1 -1
  295. package/esm/storage/scoped-storage.d.mts.map +1 -1
  296. package/esm/storage/scoped-storage.mjs.map +1 -1
  297. package/esm/storage/storage-file.d.mts.map +1 -1
  298. package/esm/storage/storage-file.mjs.map +1 -1
  299. package/esm/storage/storage.d.mts.map +1 -1
  300. package/esm/storage/types.d.mts +14 -0
  301. package/esm/storage/types.d.mts.map +1 -1
  302. package/esm/storage/utils/safe-fetch.mjs.map +1 -1
  303. package/esm/tests/start-http-development-server.d.mts.map +1 -1
  304. package/esm/tests/start-http-development-server.mjs +2 -1
  305. package/esm/tests/start-http-development-server.mjs.map +1 -1
  306. package/esm/tests/test-connectors-selection.mjs.map +1 -1
  307. package/esm/tests/test-helpers.d.mts.map +1 -1
  308. package/esm/tests/test-setup-timeout.mjs.map +1 -1
  309. package/esm/tests/vitest-setup.d.mts.map +1 -1
  310. package/esm/tests/vitest-setup.mjs.map +1 -1
  311. package/esm/updater/update-warlock-packages.mjs.map +1 -1
  312. package/esm/use-cases/use-case-broadcast.d.mts.map +1 -1
  313. package/esm/use-cases/use-case-events.d.mts.map +1 -1
  314. package/esm/use-cases/use-case-pipeline.d.mts.map +1 -1
  315. package/esm/use-cases/use-case.d.mts.map +1 -1
  316. package/esm/use-cases/use-cases-registry.d.mts.map +1 -1
  317. package/esm/use-cases/use-cases-registry.mjs.map +1 -1
  318. package/esm/utils/database-log.d.mts.map +1 -1
  319. package/esm/utils/database-log.mjs.map +1 -1
  320. package/esm/utils/environment.d.mts.map +1 -1
  321. package/esm/utils/framework-vesion.mjs.map +1 -1
  322. package/esm/utils/get-localized.mjs.map +1 -1
  323. package/esm/utils/load-environment.mjs.map +1 -1
  324. package/esm/utils/normalized-path.d.mts.map +1 -1
  325. package/esm/utils/paths.d.mts.map +1 -1
  326. package/esm/utils/promise-all-object.d.mts.map +1 -1
  327. package/esm/utils/promise-all-object.mjs.map +1 -1
  328. package/esm/utils/sluggable.mjs.map +1 -1
  329. package/esm/utils/version-compare.mjs.map +1 -1
  330. package/esm/validation/database/exists-except-current-id.mjs.map +1 -1
  331. package/esm/validation/database/exists-except-current-user.mjs.map +1 -1
  332. package/esm/validation/database/unique-except-current-id.mjs.map +1 -1
  333. package/esm/validation/plugins/localized-plugin.mjs.map +1 -1
  334. package/esm/validation/validators/file-validator.mjs.map +1 -1
  335. package/esm/vite/lower-stage3-decorators.d.mts.map +1 -1
  336. package/esm/warlock-config/default-configurations.mjs.map +1 -1
  337. package/esm/warlock-config/warlock-config.manager.d.mts.map +1 -1
  338. package/esm/warlock-config/warlock-config.manager.mjs.map +1 -1
  339. package/llms-full.txt +205 -90
  340. package/llms.txt +5 -5
  341. package/package.json +12 -12
  342. package/skills/add-connector/SKILL.md +35 -28
  343. package/skills/create-controller/SKILL.md +1 -1
  344. package/skills/create-module/SKILL.md +12 -12
  345. package/skills/hash-password/SKILL.md +4 -4
  346. package/skills/run-app/SKILL.md +77 -16
  347. package/skills/send-mail/SKILL.md +2 -2
  348. package/skills/use-middleware/SKILL.md +13 -4
  349. package/skills/use-model-transformers/SKILL.md +2 -2
  350. package/skills/use-repository/SKILL.md +1 -1
  351. package/skills/validate-input/SKILL.md +1 -1
  352. package/skills/warlock-conventions/SKILL.md +1 -1
  353. package/skills/warlock-doctor/SKILL.md +3 -3
  354. package/skills/warlock-routes/SKILL.md +47 -9
  355. package/skills/write-cli-command/SKILL.md +1 -1
  356. package/skills/write-seeder/SKILL.md +8 -8
@@ -1 +1 @@
1
- {"version":3,"file":"test-setup-timeout.mjs","names":[],"sources":["../../../../../../../core/src/tests/test-setup-timeout.ts"],"sourcesContent":["/**\n * The setup bound for the worker test lifecycle.\n *\n * Owns one decision: how long a `setupTest` attempt may run before the\n * lifecycle gives up on it. `vitest-setup.ts` owns what giving up MEANS.\n *\n * This is a HANG GUARD, not a startup-performance deadline. A cold database, a\n * container that has just been started, a first-run migration — all of those are\n * legitimately slow and none of them are a stuck lifecycle. The default is\n * therefore generous on purpose: it exists so that a setup which will never\n * finish fails with a sentence a caller can act on, instead of stranding the\n * lifecycle in `starting` where `teardownTest`'s wait-then-re-enter path spins\n * until the worker dies of heap exhaustion.\n */\nimport type { GenericObject } from \"@mongez/reinforcements\";\nimport { config } from \"../config\";\n\n/**\n * Two minutes. Chosen to sit far above any healthy bootstrap and far below the\n * point where a human stops watching — a stuck worker should announce itself\n * while someone is still looking at the terminal.\n */\nexport const DEFAULT_TEST_SETUP_TIMEOUT = 120_000;\n\n/**\n * A scheduled expiry the lifecycle can cancel when the attempt settles first.\n *\n * @internal\n */\nexport type TestTimeoutHandle = {\n cancel: () => void;\n};\n\n/**\n * How the lifecycle schedules its expiry.\n *\n * Injectable so a spec can prove the bound in milliseconds instead of outliving\n * a real one — see {@link TestLifecycleRegistry.scheduleTimeout}. Deliberately\n * internal: the public API stays the `setupTest` / `teardownTest` pair.\n *\n * @internal\n */\nexport type TestTimeoutScheduler = (\n timeout: number,\n onExpiry: () => void,\n) => TestTimeoutHandle;\n\n/**\n * The real scheduler.\n *\n * `unref` matters: a pending hang guard must never be the reason a worker stays\n * alive after its tests have finished.\n *\n * @internal\n */\nexport const scheduleRealTimeout: TestTimeoutScheduler = (timeout, onExpiry) => {\n const timer = setTimeout(onExpiry, timeout);\n\n timer.unref?.();\n\n return { cancel: () => clearTimeout(timer) };\n};\n\n/**\n * Read `tests.setupTimeout`, or `undefined` when the project has not set one.\n *\n * Only meaningful once config files are loaded — before that, every project\n * looks like a project without a `tests` config.\n *\n * @throws when the key is present but is not a positive finite number of\n * milliseconds. Falling back to the default would silently erase a project's\n * configuration, which is the same defect the connector precedence rules out.\n */\nexport function readConfiguredSetupTimeout(): number | undefined {\n // `config.get` resolves an absent key to its default, and ITS default is\n // `null` — not `{}` — so the explicit `{}` is what keeps this from throwing\n // \"Cannot read properties of null\" on a project with no `src/config/tests.ts`.\n const testsConfig = config.get<GenericObject>(\"tests\", {});\n const configured = testsConfig?.setupTimeout as unknown;\n\n if (configured === undefined) {\n return undefined;\n }\n\n if (typeof configured !== \"number\" || !Number.isFinite(configured) || configured <= 0) {\n throw new Error(\n `tests.setupTimeout must be a positive number of milliseconds, but it is ${JSON.stringify(configured)}. Remove the key to use the default of ${DEFAULT_TEST_SETUP_TIMEOUT}ms.`,\n );\n }\n\n return configured;\n}\n\n/**\n * The message a caller sees when the bound expires.\n *\n * Names three things, because a hang guard that only says \"timed out\" sends the\n * reader to the framework's source: what state the lifecycle is stuck in, what\n * bound it exceeded, and how to raise that bound.\n */\nexport function describeExpiredSetup(timeout: number): string {\n return (\n `setupTest() did not finish within ${timeout}ms and is stuck in the \"starting\" state. ` +\n \"The lifecycle is now poisoned: whatever that attempt had already started is not known to be \" +\n \"closed, so later setupTest() calls refuse until the Vitest worker is recycled. \" +\n `If your cold start is legitimately slower than this, raise the bound with \\`tests.setupTimeout\\` ` +\n `in \\`src/config/tests.ts\\` — milliseconds, default ${DEFAULT_TEST_SETUP_TIMEOUT}.`\n );\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAa,6BAA6B;;;;;;;;;AAiC1C,MAAa,uBAA6C,SAAS,aAAa;CAC9E,MAAM,QAAQ,WAAW,UAAU,OAAO;CAE1C,MAAM,QAAQ;CAEd,OAAO,EAAE,cAAc,aAAa,KAAK,EAAE;AAC7C;;;;;;;;;;;AAYA,SAAgB,6BAAiD;CAK/D,MAAM,aADc,OAAO,IAAmB,SAAS,CAAC,CAC3B,CAAC,EAAE;CAEhC,IAAI,eAAe,QACjB;CAGF,IAAI,OAAO,eAAe,YAAY,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,GAClF,MAAM,IAAI,MACR,2EAA2E,KAAK,UAAU,UAAU,EAAE,yCAAyC,2BAA2B,IAC5K;CAGF,OAAO;AACT;;;;;;;;AASA,SAAgB,qBAAqB,SAAyB;CAC5D,OACE,qCAAqC,QAAQ,0WAIS,2BAA2B;AAErF"}
1
+ {"version":3,"file":"test-setup-timeout.mjs","names":[],"sources":["../../../../../../../core/src/tests/test-setup-timeout.ts"],"sourcesContent":["/**\n * The setup bound for the worker test lifecycle.\n *\n * Owns one decision: how long a `setupTest` attempt may run before the\n * lifecycle gives up on it. `vitest-setup.ts` owns what giving up MEANS.\n *\n * This is a HANG GUARD, not a startup-performance deadline. A cold database, a\n * container that has just been started, a first-run migration — all of those are\n * legitimately slow and none of them are a stuck lifecycle. The default is\n * therefore generous on purpose: it exists so that a setup which will never\n * finish fails with a sentence a caller can act on, instead of stranding the\n * lifecycle in `starting` where `teardownTest`'s wait-then-re-enter path spins\n * until the worker dies of heap exhaustion.\n */\nimport type { GenericObject } from \"@mongez/reinforcements\";\nimport { config } from \"../config\";\n\n/**\n * Two minutes. Chosen to sit far above any healthy bootstrap and far below the\n * point where a human stops watching — a stuck worker should announce itself\n * while someone is still looking at the terminal.\n */\nexport const DEFAULT_TEST_SETUP_TIMEOUT = 120_000;\n\n/**\n * A scheduled expiry the lifecycle can cancel when the attempt settles first.\n *\n * @internal\n */\nexport type TestTimeoutHandle = {\n cancel: () => void;\n};\n\n/**\n * How the lifecycle schedules its expiry.\n *\n * Injectable so a spec can prove the bound in milliseconds instead of outliving\n * a real one — see {@link TestLifecycleRegistry.scheduleTimeout}. Deliberately\n * internal: the public API stays the `setupTest` / `teardownTest` pair.\n *\n * @internal\n */\nexport type TestTimeoutScheduler = (\n timeout: number,\n onExpiry: () => void,\n) => TestTimeoutHandle;\n\n/**\n * The real scheduler.\n *\n * `unref` matters: a pending hang guard must never be the reason a worker stays\n * alive after its tests have finished.\n *\n * @internal\n */\nexport const scheduleRealTimeout: TestTimeoutScheduler = (timeout, onExpiry) => {\n const timer = setTimeout(onExpiry, timeout);\n\n timer.unref?.();\n\n return { cancel: () => clearTimeout(timer) };\n};\n\n/**\n * Read `tests.setupTimeout`, or `undefined` when the project has not set one.\n *\n * Only meaningful once config files are loaded — before that, every project\n * looks like a project without a `tests` config.\n *\n * @throws when the key is present but is not a positive finite number of\n * milliseconds. Falling back to the default would silently erase a project's\n * configuration, which is the same defect the connector precedence rules out.\n */\nexport function readConfiguredSetupTimeout(): number | undefined {\n // `config.get` resolves an absent key to its default, and ITS default is\n // `null` — not `{}` — so the explicit `{}` is what keeps this from throwing\n // \"Cannot read properties of null\" on a project with no `src/config/tests.ts`.\n const testsConfig = config.get<GenericObject>(\"tests\", {});\n const configured = testsConfig?.setupTimeout as unknown;\n\n if (configured === undefined) {\n return undefined;\n }\n\n if (typeof configured !== \"number\" || !Number.isFinite(configured) || configured <= 0) {\n throw new Error(\n `tests.setupTimeout must be a positive number of milliseconds, but it is ${JSON.stringify(configured)}. Remove the key to use the default of ${DEFAULT_TEST_SETUP_TIMEOUT}ms.`,\n );\n }\n\n return configured;\n}\n\n/**\n * The message a caller sees when the bound expires.\n *\n * Names three things, because a hang guard that only says \"timed out\" sends the\n * reader to the framework's source: what state the lifecycle is stuck in, what\n * bound it exceeded, and how to raise that bound.\n */\nexport function describeExpiredSetup(timeout: number): string {\n return (\n `setupTest() did not finish within ${timeout}ms and is stuck in the \"starting\" state. ` +\n \"The lifecycle is now poisoned: whatever that attempt had already started is not known to be \" +\n \"closed, so later setupTest() calls refuse until the Vitest worker is recycled. \" +\n `If your cold start is legitimately slower than this, raise the bound with \\`tests.setupTimeout\\` ` +\n `in \\`src/config/tests.ts\\` — milliseconds, default ${DEFAULT_TEST_SETUP_TIMEOUT}.`\n );\n}\n"],"mappings":";;;;;;;;;AAsBA,MAAa,6BAA6B;;;;;;;;;AAiC1C,MAAa,uBAA6C,SAAS,aAAa;CAC9E,MAAM,QAAQ,WAAW,UAAU,OAAO;CAE1C,MAAM,QAAQ;CAEd,OAAO,EAAE,cAAc,aAAa,KAAK,EAAE;AAC7C;;;;;;;;;;;AAYA,SAAgB,6BAAiD;CAK/D,MAAM,aADc,OAAO,IAAmB,SAAS,CAAC,CAC3B,GAAG;CAEhC,IAAI,eAAe,QACjB;CAGF,IAAI,OAAO,eAAe,YAAY,CAAC,OAAO,SAAS,UAAU,KAAK,cAAc,GAClF,MAAM,IAAI,MACR,2EAA2E,KAAK,UAAU,UAAU,EAAE,yCAAyC,2BAA2B,IAC5K;CAGF,OAAO;AACT;;;;;;;;AASA,SAAgB,qBAAqB,SAAyB;CAC5D,OACE,qCAAqC,QAAQ,0WAIS,2BAA2B;AAErF"}
@@ -1 +1 @@
1
- {"version":3,"file":"vitest-setup.d.mts","names":[],"sources":["../../../../../../../core/src/tests/vitest-setup.ts"],"mappings":";;;KAoDY,gBAAA;EAAA;;;;AAS0B;AAOtC;;;EAPE,UAAA,GAAa,uBAAuB;AAAA;;;;AAQF;cADvB,kBAAA,SAA2B,KAAK;cACxB,OAAA;AAAA;;;;;;AAqC+C;AAgDpE;;;;AAA6C;;;;;;;;;;;;;;;;;iBAhDvB,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,OAAO;;;;;;;;;;;;;;;;;;iBAgD9C,YAAA,IAAgB,OAAO"}
1
+ {"version":3,"file":"vitest-setup.d.mts","names":[],"sources":["../../../../../../../core/src/tests/vitest-setup.ts"],"mappings":";;;KAoDY,gBAAA;EAAA;;;;AAS0B;AAOtC;;;EAPE,UAAA,GAAa,uBAAuB;AAAA;;;;AAQF;cADvB,kBAAA,SAA2B,KAAK;cACxB,OAAA;AAAA;;;;;;AAqC+C;AAgDpE;;;;AAA6C;;;;;;;;;;;;;;;;;iBAhDvB,SAAA,CAAU,OAAA,GAAU,gBAAA,GAAmB,OAAO;;;;;;;;;;;;;;;;;;iBAgD9C,YAAA,CAAA,GAAgB,OAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"vitest-setup.mjs","names":[],"sources":["../../../../../../../core/src/tests/vitest-setup.ts"],"sourcesContent":["/**\r\n * Worker test lifecycle — `setupTest` / `teardownTest`.\r\n *\r\n * Implements `contracts/2026-08-12-test-worker-lifecycle.md`. The pair is\r\n * context-scoped, not \"once per worker\": Vitest runs `setupFiles` before EVERY\r\n * test file and rebuilds the module registry each time, so the harness that\r\n * calls `setupTest` owns pairing it with `teardownTest` in the same runtime\r\n * context.\r\n *\r\n * Ownership, stated once because teardown is wider than it looks:\r\n *\r\n * - the runtime assumes exclusive ownership of the process-local\r\n * `connectorsManager` for its lifetime;\r\n * - it owns the framework bootstrap, the application shutdown hooks, and the\r\n * connectors it starts — including the `connectors: false` case, where\r\n * bootstrap still registers hooks;\r\n * - teardown is MANAGER-WIDE. `connectorsManager.shutdown()` has no selective\r\n * ownership handle, so a lifecycle that started two connectors still closes\r\n * every connector the manager holds. Mixing `setupTest` with manual connector\r\n * startup in the same process is unsupported for exactly that reason.\r\n * - HTTP global setup stays separately owned by `startHttpTestServer` /\r\n * `stopHttpTestServer`.\r\n */\r\nimport { Application } from \"../application/application\";\r\nimport { bootstrap } from \"../bootstrap\";\r\nimport { loadConfigFiles } from \"../config/load-config-files\";\r\nimport { connectorsManager } from \"../connectors\";\r\nimport { filesOrchestrator } from \"../dev-server/files-orchestrator\";\r\nimport { warlockConfigManager } from \"../warlock-config/warlock-config.manager\";\r\nimport {\r\n describeConnectorsSelection,\r\n isSameConnectorsSelection,\r\n normalizeConnectorNames,\r\n readRequestedConnectors,\r\n resolveEffectiveConnectors,\r\n} from \"./test-connectors-selection\";\r\nimport type {\r\n RequestedTestConnectors,\r\n TestConnectorsSelection,\r\n} from \"./test-connectors-selection\";\r\nimport { getTestLifecycleRegistry } from \"./test-lifecycle-state\";\r\nimport type { TestLifecycleRegistry, TestSetupAttempt } from \"./test-lifecycle-state\";\r\nimport {\r\n DEFAULT_TEST_SETUP_TIMEOUT,\r\n describeExpiredSetup,\r\n readConfiguredSetupTimeout,\r\n scheduleRealTimeout,\r\n} from \"./test-setup-timeout\";\r\nimport type { TestTimeoutHandle } from \"./test-setup-timeout\";\r\n\r\nexport type { TestConnectorsSelection } from \"./test-connectors-selection\";\r\n\r\nexport type TestSetupOptions = {\r\n /**\r\n * Which connectors to start.\r\n *\r\n * Precedence is `explicit non-undefined option > tests.connectors config >\r\n * true`. Omitting the property, or passing `undefined`, lets project config\r\n * apply — so an optional variable that happens to be `undefined` cannot erase\r\n * it.\r\n */\r\n connectors?: TestConnectorsSelection;\r\n};\r\n\r\n/**\r\n * Raised by the lifecycle itself, never by the runtime it manages — a conflict\r\n * between two calls, or a refusal to reuse a runtime that did not close.\r\n */\r\nexport class TestLifecycleError extends Error {\r\n public constructor(message: string) {\r\n super(message);\r\n\r\n this.name = \"TestLifecycleError\";\r\n }\r\n}\r\n\r\nconst POISONED_MESSAGE =\r\n \"setupTest() refuses to start a test runtime: an earlier teardownTest() reported a shutdown failure, so the connectors, ports and pools it owned are not known to be closed. Restart the Vitest worker before setting up again, or call teardownTest() to retry the shutdown — the lifecycle only returns to idle on a fully successful retry.\";\r\n\r\n/**\r\n * Bootstrap the test runtime and start the selected connectors.\r\n *\r\n * ⚠ Runs once per TEST FILE, not once per worker: `setupFiles` is executed for\r\n * every file and its module registry is rebuilt with it, measured across both\r\n * pools with isolation on and off. The lifecycle state lives on the runtime\r\n * context rather than in this module precisely so that a rebuild cannot hide a\r\n * runtime that is still up.\r\n *\r\n * Repeated calls:\r\n *\r\n * - concurrent calls with the same effective selection share one startup;\r\n * - while ready, the same effective selection is a no-op;\r\n * - while starting or ready, a DIFFERENT effective selection rejects and leaves\r\n * the live runtime untouched;\r\n * - a failed setup unwinds and returns to idle, so a clean retry is allowed;\r\n * - after a successful `teardownTest`, a later setup may use a different\r\n * selection.\r\n *\r\n * @example\r\n * // let project config decide, falling back to the default set\r\n * await setupTest();\r\n *\r\n * @example\r\n * // bootstrap only — no connectors, whatever config says\r\n * await setupTest({ connectors: false });\r\n */\r\nexport async function setupTest(options?: TestSetupOptions): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n const requested = readRequestedConnectors(options?.connectors);\r\n\r\n if (registry.state === \"poisoned\") {\r\n throw new TestLifecycleError(POISONED_MESSAGE);\r\n }\r\n\r\n if (registry.state === \"stopping\" && registry.teardownAttempt) {\r\n await settled(registry.teardownAttempt);\r\n\r\n return setupTest(options);\r\n }\r\n\r\n if (registry.state === \"ready\") {\r\n assertReadySelectionMatches(registry.activeSelection, requested);\r\n\r\n return;\r\n }\r\n\r\n if (registry.state === \"starting\" && registry.setupAttempt) {\r\n const attempt = registry.setupAttempt;\r\n\r\n await assertPendingSetupMatches(attempt, requested);\r\n\r\n return attempt.completion;\r\n }\r\n\r\n return startTestRuntime(requested);\r\n}\r\n\r\n/**\r\n * Shut the test runtime down and release the lifecycle.\r\n *\r\n * - idle is a no-op;\r\n * - concurrent calls share one attempt;\r\n * - a call made while setup is still running waits for that attempt to settle,\r\n * then closes the runtime if it succeeded;\r\n * - the local \"ready\" state is always cleared, including when shutdown rejects;\r\n * - a shutdown rejection is surfaced, never swallowed, and poisons the\r\n * lifecycle — a reported close failure is not proof that anything closed, so\r\n * later `setupTest` calls refuse until the worker is restarted or a retry\r\n * fully succeeds.\r\n *\r\n * ⚠ Individual connector shutdown failures are caught and logged inside\r\n * `connectorsManager.shutdown()`, so they never reach this function and never\r\n * poison anything. This lifecycle can only surface what that layer reports.\r\n */\r\nexport async function teardownTest(): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n\r\n if (registry.state === \"stopping\" && registry.teardownAttempt) {\r\n return registry.teardownAttempt;\r\n }\r\n\r\n if (registry.state === \"starting\" && registry.setupAttempt) {\r\n // A runtime that is still opening cannot be closed halfway. Wait for the\r\n // attempt to settle: a failed one has already unwound itself and left the\r\n // lifecycle idle, which the re-entry below then reads as \"nothing to do\".\r\n await settled(registry.setupAttempt.completion);\r\n\r\n return teardownTest();\r\n }\r\n\r\n if (registry.state === \"idle\") {\r\n return;\r\n }\r\n\r\n registry.state = \"stopping\";\r\n\r\n // Deferred by a microtask so the registry is fully published before the\r\n // attempt's first line runs — a synchronous throw would otherwise reach the\r\n // `finally` below, and reset the state, before this function had recorded\r\n // that a teardown was in flight at all.\r\n const attempt = Promise.resolve().then(() => runTestRuntimeShutdown());\r\n\r\n registry.teardownAttempt = attempt;\r\n\r\n return attempt;\r\n}\r\n\r\n/**\r\n * The setup attempt's hang guard, as the lifecycle consumes it.\r\n *\r\n * The bound's POLICY — the default, the config key, the message — lives in\r\n * `test-setup-timeout.ts`. What expiry MEANS lives here.\r\n *\r\n * @internal\r\n */\r\ntype SetupBound = {\r\n /**\r\n * Rejects with the expiry error. Never resolves: the attempt is the only side\r\n * of the race that can succeed.\r\n */\r\n readonly expiry: Promise<never>;\r\n\r\n /**\r\n * Re-aim the bound at `next` ms measured from when the ATTEMPT STARTED, once\r\n * config has made `tests.setupTimeout` readable.\r\n */\r\n rearm(next: number): void;\r\n\r\n /** The race is over — cancel whatever timer is still pending. */\r\n settle(): void;\r\n\r\n /** Whether the bound, rather than the attempt, won the race. */\r\n hasExpired(): boolean;\r\n};\r\n\r\n/**\r\n * Arm the hang guard for one setup attempt.\r\n *\r\n * Armed at the default BEFORE the attempt runs, because `tests.setupTimeout` is\r\n * not readable until the attempt has loaded config — and loading config is\r\n * itself one of the steps that can hang. `rearm` then narrows or widens it the\r\n * moment config arrives.\r\n */\r\nfunction armSetupBound(registry: TestLifecycleRegistry): SetupBound {\r\n const schedule = registry.scheduleTimeout ?? scheduleRealTimeout;\r\n const armedAt = Date.now();\r\n\r\n let handle: TestTimeoutHandle | undefined;\r\n let expired = false;\r\n let closed = false;\r\n let expire: (error: unknown) => void = () => undefined;\r\n\r\n const expiry = new Promise<never>((_resolve, reject) => {\r\n expire = reject;\r\n });\r\n\r\n // Only `awaitSetupWithinBound` observes this, and only until the attempt wins\r\n // — after that nobody is listening, and an unobserved rejection surfaces as an\r\n // unhandled rejection that fails an unrelated test file. Same reason as the\r\n // `effectiveSelection` barrier below.\r\n expiry.catch(() => undefined);\r\n\r\n const expireNow = (bound: number): void => {\r\n if (closed) {\r\n return;\r\n }\r\n\r\n closed = true;\r\n expired = true;\r\n\r\n handle?.cancel();\r\n handle = undefined;\r\n\r\n expire(new TestLifecycleError(describeExpiredSetup(bound)));\r\n };\r\n\r\n const armFor = (bound: number, delay: number): void => {\r\n if (closed) {\r\n return;\r\n }\r\n\r\n handle?.cancel();\r\n\r\n // Already overdue. A bound the attempt has ALREADY exceeded must fire now,\r\n // not be rescheduled for time that was spent before it was known.\r\n if (delay <= 0) {\r\n expireNow(bound);\r\n\r\n return;\r\n }\r\n\r\n handle = schedule(delay, () => expireNow(bound));\r\n };\r\n\r\n const initialBound = registry.setupTimeoutOverride ?? DEFAULT_TEST_SETUP_TIMEOUT;\r\n\r\n armFor(initialBound, initialBound);\r\n\r\n return {\r\n expiry,\r\n\r\n // Measured from `armedAt`, never from now: adding a configured bound to the\r\n // time already spent would make the real bound default-plus-configured, and\r\n // a project that lowered the key would get a LONGER guard than the default.\r\n rearm: (next) => armFor(next, next - (Date.now() - armedAt)),\r\n\r\n settle: () => {\r\n closed = true;\r\n\r\n handle?.cancel();\r\n handle = undefined;\r\n },\r\n\r\n hasExpired: () => expired,\r\n };\r\n}\r\n\r\n/**\r\n * Race one setup attempt against its bound.\r\n *\r\n * The losing attempt is NOT cancellable — nothing here can interrupt a bootstrap\r\n * stuck in a socket connect — so when the bound wins, the lifecycle is poisoned\r\n * and every later state write from that abandoned attempt is dropped. That\r\n * dropping happens in `runTestRuntimeStartup`, guarded on `hasExpired()`;\r\n * without it the still-running attempt would quietly overwrite `poisoned` with\r\n * `ready` or `idle` and hand the next caller a runtime nobody owns.\r\n */\r\nasync function awaitSetupWithinBound(\r\n attempt: Promise<void>,\r\n bound: SetupBound,\r\n registry: TestLifecycleRegistry,\r\n): Promise<void> {\r\n try {\r\n await Promise.race([attempt, bound.expiry]);\r\n } catch (error) {\r\n if (bound.hasExpired()) {\r\n registry.state = \"poisoned\";\r\n registry.activeSelection = undefined;\r\n registry.setupAttempt = undefined;\r\n }\r\n\r\n throw error;\r\n } finally {\r\n bound.settle();\r\n }\r\n}\r\n\r\n/**\r\n * Open a new setup attempt and publish it before it runs.\r\n */\r\nfunction startTestRuntime(requested: RequestedTestConnectors): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n\r\n let publishEffectiveSelection: (selection: TestConnectorsSelection) => void = () => undefined;\r\n let failEffectiveSelection: (error: unknown) => void = () => undefined;\r\n\r\n const effectiveSelection = new Promise<TestConnectorsSelection>((resolve, reject) => {\r\n publishEffectiveSelection = resolve;\r\n failEffectiveSelection = reject;\r\n });\r\n\r\n // Only the mixed explicit/config comparison ever awaits this barrier, so its\r\n // rejection is usually unobserved — and an unobserved rejection would surface\r\n // as an unhandled rejection and fail an unrelated test file.\r\n effectiveSelection.catch(() => undefined);\r\n\r\n const bound = armSetupBound(registry);\r\n\r\n const attempt = Promise.resolve().then(() =>\r\n runTestRuntimeStartup(requested, publishEffectiveSelection, failEffectiveSelection, bound),\r\n );\r\n\r\n // The attempt outlives a bound that beat it, and by then `completion` has\r\n // already rejected with the expiry error — so the attempt's own late rejection\r\n // has no observer. Same unhandled-rejection hazard as above.\r\n attempt.catch(() => undefined);\r\n\r\n // `teardownTest` waits on this same promise, which is how a teardown requested\r\n // during setup inherits the bound. There is deliberately no second timer and\r\n // no separate teardown deadline.\r\n const completion = awaitSetupWithinBound(attempt, bound, registry);\r\n\r\n registry.state = \"starting\";\r\n registry.setupAttempt = { requested, effectiveSelection, completion };\r\n\r\n return completion;\r\n}\r\n\r\n/**\r\n * The startup attempt itself.\r\n *\r\n * On failure: best-effort unwind, reset bookkeeping, rethrow the ORIGINAL error\r\n * unchanged. A cleanup failure is a secondary diagnostic and never replaces the\r\n * cause the caller needs to read.\r\n */\r\nasync function runTestRuntimeStartup(\r\n requested: RequestedTestConnectors,\r\n publishEffectiveSelection: (selection: TestConnectorsSelection) => void,\r\n failEffectiveSelection: (error: unknown) => void,\r\n bound: SetupBound,\r\n): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n\r\n try {\r\n Application.setEnvironment(\"test\");\r\n\r\n await warlockConfigManager.load();\r\n await bootstrap();\r\n\r\n await filesOrchestrator.init();\r\n await loadConfigFiles(true);\r\n\r\n // The first point at which `tests.setupTimeout` is readable at all. An\r\n // invalid value throws from here and takes the normal failure path — falling\r\n // back to the default would silently erase what the project configured.\r\n const configuredTimeout = readConfiguredSetupTimeout();\r\n\r\n if (configuredTimeout !== undefined) {\r\n bound.rearm(configuredTimeout);\r\n }\r\n\r\n // Resolved here and not at call time: the config layer is only readable once\r\n // the four steps above have run.\r\n const effectiveSelection = resolveEffectiveConnectors(requested);\r\n\r\n // Every state write below is conditional on this attempt still being the one\r\n // the lifecycle is waiting for. Once the bound has expired the lifecycle is\r\n // poisoned and this attempt is abandoned — it may still be running, but it\r\n // no longer speaks for the runtime.\r\n if (!bound.hasExpired()) {\r\n registry.activeSelection = effectiveSelection;\r\n }\r\n\r\n publishEffectiveSelection(effectiveSelection);\r\n\r\n await startSelectedConnectors(effectiveSelection);\r\n\r\n if (!bound.hasExpired()) {\r\n registry.state = \"ready\";\r\n registry.setupAttempt = undefined;\r\n }\r\n } catch (error) {\r\n failEffectiveSelection(error);\r\n\r\n await unwindPartialStartup();\r\n\r\n if (!bound.hasExpired()) {\r\n registry.state = \"idle\";\r\n registry.activeSelection = undefined;\r\n registry.setupAttempt = undefined;\r\n }\r\n\r\n console.error(\"[vitest-setup] Failed to setup test environment:\", error);\r\n\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * `false` means none at all. Everything else starts something: an array starts\r\n * exactly those, and `true` starts the default set — all but http, which is the\r\n * global setup's job and shared across every worker.\r\n */\r\nasync function startSelectedConnectors(selection: TestConnectorsSelection): Promise<void> {\r\n if (selection === false) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(selection)) {\r\n await connectorsManager.start(normalizeConnectorNames(selection));\r\n\r\n return;\r\n }\r\n\r\n await connectorsManager.startWithout([\"http\"]);\r\n}\r\n\r\n/**\r\n * Best-effort teardown of whatever a failed startup managed to start.\r\n *\r\n * Runs while an error is already in flight, so no step here may throw and every\r\n * step is attempted independently.\r\n */\r\nasync function unwindPartialStartup(): Promise<void> {\r\n // Two steps rather than one: `connectorsManager.shutdown()` runs the\r\n // application hooks itself, but it runs them FIRST and does not isolate their\r\n // rejection — so a hook that rejects would take the connector teardown down\r\n // with it and leave every connector up. Both calls are idempotent, so running\r\n // the hooks on their own first costs nothing and means neither failure can\r\n // skip the other step.\r\n await attemptCleanupStep(\"application shutdown hooks\", () => Application.runShutdownHooks());\r\n await attemptCleanupStep(\"connectors shutdown\", () => connectorsManager.shutdown());\r\n}\r\n\r\n/**\r\n * Run one cleanup step, isolating its failure so the next step still runs.\r\n */\r\nasync function attemptCleanupStep(step: string, run: () => Promise<void>): Promise<void> {\r\n try {\r\n await run();\r\n } catch (error) {\r\n // Reported, not thrown — it is secondary to the startup error about to be\r\n // rethrown, and losing that one to this would be the worse outcome.\r\n console.error(`[vitest-setup] Cleanup after a failed setup did not complete (${step}):`, error);\r\n }\r\n}\r\n\r\n/**\r\n * The teardown attempt itself.\r\n */\r\nasync function runTestRuntimeShutdown(): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n let shutdownSucceeded = false;\r\n\r\n try {\r\n // Manager-wide, and deliberately called whatever the selection was: with\r\n // `connectors: false` nothing was started, but bootstrap still registered\r\n // application shutdown hooks, and the manager runs those first (see\r\n // `connectors-manager.ts` — `Application.runShutdownHooks()` is its first\r\n // line). Skipping the call to \"match\" an empty selection would leak them.\r\n await connectorsManager.shutdown();\r\n\r\n shutdownSucceeded = true;\r\n } finally {\r\n // In a `finally`, not after the `await`: a rejected shutdown must not leave\r\n // the lifecycle claiming a runtime it no longer owns. Poisoned rather than\r\n // idle, because a cleared flag does not prove that ports, sockets, pools or\r\n // timers closed.\r\n registry.activeSelection = undefined;\r\n registry.setupAttempt = undefined;\r\n registry.teardownAttempt = undefined;\r\n registry.state = shutdownSucceeded ? \"idle\" : \"poisoned\";\r\n }\r\n}\r\n\r\n/**\r\n * Reject when a ready runtime was set up with a different selection.\r\n */\r\nfunction assertReadySelectionMatches(\r\n activeSelection: TestConnectorsSelection | undefined,\r\n requested: RequestedTestConnectors,\r\n): void {\r\n if (activeSelection === undefined) {\r\n return;\r\n }\r\n\r\n // Config is loaded by the time anything is ready, so the config-derived layer\r\n // is resolvable right here.\r\n const requestedSelection = resolveEffectiveConnectors(requested);\r\n\r\n assertSelectionsMatch(activeSelection, requestedSelection);\r\n}\r\n\r\n/**\r\n * Reject when an in-flight setup attempt is starting a different selection.\r\n */\r\nasync function assertPendingSetupMatches(\r\n attempt: TestSetupAttempt,\r\n requested: RequestedTestConnectors,\r\n): Promise<void> {\r\n const pending = attempt.requested;\r\n\r\n // Two calls that both defer to project config resolve to the same thing by\r\n // construction — knowable without waiting for config to load.\r\n if (!pending.isExplicit && !requested.isExplicit) {\r\n return;\r\n }\r\n\r\n if (pending.isExplicit && requested.isExplicit) {\r\n assertSelectionsMatch(pending.selection, requested.selection);\r\n\r\n return;\r\n }\r\n\r\n // Mixed: one side is config-derived and config is not readable until the\r\n // running attempt has loaded it, so wait for that barrier first.\r\n const activeSelection = await attempt.effectiveSelection;\r\n const requestedSelection = resolveEffectiveConnectors(requested);\r\n\r\n assertSelectionsMatch(activeSelection, requestedSelection);\r\n}\r\n\r\n/**\r\n * Name both selections: a caller looking at this message has to be able to tell\r\n * which call to change without reading the framework's source.\r\n */\r\nfunction assertSelectionsMatch(\r\n activeSelection: TestConnectorsSelection,\r\n requestedSelection: TestConnectorsSelection,\r\n): void {\r\n if (isSameConnectorsSelection(activeSelection, requestedSelection)) {\r\n return;\r\n }\r\n\r\n throw new TestLifecycleError(\r\n `setupTest() is already using ${describeConnectorsSelection(activeSelection)}, and this call asked for ${describeConnectorsSelection(requestedSelection)}. One test runtime serves one connector selection — call teardownTest() before setting up a different one.`,\r\n );\r\n}\r\n\r\n/**\r\n * Await an attempt for its state transition only, not its result.\r\n */\r\nfunction settled(attempt: Promise<void>): Promise<void> {\r\n return attempt.catch(() => undefined);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,AAAO,YAAY,SAAiB;EAClC,MAAM,OAAO;EAEb,KAAK,OAAO;CACd;AACF;AAEA,MAAM,mBACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BF,eAAsB,UAAU,SAA2C;CACzE,MAAM,WAAW,yBAAyB;CAC1C,MAAM,YAAY,wBAAwB,SAAS,UAAU;CAE7D,IAAI,SAAS,UAAU,YACrB,MAAM,IAAI,mBAAmB,gBAAgB;CAG/C,IAAI,SAAS,UAAU,cAAc,SAAS,iBAAiB;EAC7D,MAAM,QAAQ,SAAS,eAAe;EAEtC,OAAO,UAAU,OAAO;CAC1B;CAEA,IAAI,SAAS,UAAU,SAAS;EAC9B,4BAA4B,SAAS,iBAAiB,SAAS;EAE/D;CACF;CAEA,IAAI,SAAS,UAAU,cAAc,SAAS,cAAc;EAC1D,MAAM,UAAU,SAAS;EAEzB,MAAM,0BAA0B,SAAS,SAAS;EAElD,O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Ac,UAAU,YAAY;EAC9C,sBAAsB,QAAQ,WAAW,UAAU,SAAS;EAE5D;CACF;CAOA,sBAAsB,MAHQ,QAAQ,oBACX,2BAA2B,SAEE,CAAC;AAC3D;;;;;AAMA,SAAS,sBACP,iBACA,oBACM;CACN,IAAI,0BAA0B,iBAAiB,kBAAkB,GAC/D;CAGF,MAAM,IAAI,mBACR,gCAAgC,4BAA4B,eAAe,EAAE,4BAA4B,4BAA4B,kBAAkB,EAAE,2GAC3J;AACF;;;;AAKA,SAAS,QAAQ,SAAuC;CACtD,OAAO,QAAQ,YAAY,MAAS;AACtC"}
1
+ {"version":3,"file":"vitest-setup.mjs","names":[],"sources":["../../../../../../../core/src/tests/vitest-setup.ts"],"sourcesContent":["/**\r\n * Worker test lifecycle — `setupTest` / `teardownTest`.\r\n *\r\n * Implements `contracts/2026-08-12-test-worker-lifecycle.md`. The pair is\r\n * context-scoped, not \"once per worker\": Vitest runs `setupFiles` before EVERY\r\n * test file and rebuilds the module registry each time, so the harness that\r\n * calls `setupTest` owns pairing it with `teardownTest` in the same runtime\r\n * context.\r\n *\r\n * Ownership, stated once because teardown is wider than it looks:\r\n *\r\n * - the runtime assumes exclusive ownership of the process-local\r\n * `connectorsManager` for its lifetime;\r\n * - it owns the framework bootstrap, the application shutdown hooks, and the\r\n * connectors it starts — including the `connectors: false` case, where\r\n * bootstrap still registers hooks;\r\n * - teardown is MANAGER-WIDE. `connectorsManager.shutdown()` has no selective\r\n * ownership handle, so a lifecycle that started two connectors still closes\r\n * every connector the manager holds. Mixing `setupTest` with manual connector\r\n * startup in the same process is unsupported for exactly that reason.\r\n * - HTTP global setup stays separately owned by `startHttpTestServer` /\r\n * `stopHttpTestServer`.\r\n */\r\nimport { Application } from \"../application/application\";\r\nimport { bootstrap } from \"../bootstrap\";\r\nimport { loadConfigFiles } from \"../config/load-config-files\";\r\nimport { connectorsManager } from \"../connectors\";\r\nimport { filesOrchestrator } from \"../dev-server/files-orchestrator\";\r\nimport { warlockConfigManager } from \"../warlock-config/warlock-config.manager\";\r\nimport {\r\n describeConnectorsSelection,\r\n isSameConnectorsSelection,\r\n normalizeConnectorNames,\r\n readRequestedConnectors,\r\n resolveEffectiveConnectors,\r\n} from \"./test-connectors-selection\";\r\nimport type {\r\n RequestedTestConnectors,\r\n TestConnectorsSelection,\r\n} from \"./test-connectors-selection\";\r\nimport { getTestLifecycleRegistry } from \"./test-lifecycle-state\";\r\nimport type { TestLifecycleRegistry, TestSetupAttempt } from \"./test-lifecycle-state\";\r\nimport {\r\n DEFAULT_TEST_SETUP_TIMEOUT,\r\n describeExpiredSetup,\r\n readConfiguredSetupTimeout,\r\n scheduleRealTimeout,\r\n} from \"./test-setup-timeout\";\r\nimport type { TestTimeoutHandle } from \"./test-setup-timeout\";\r\n\r\nexport type { TestConnectorsSelection } from \"./test-connectors-selection\";\r\n\r\nexport type TestSetupOptions = {\r\n /**\r\n * Which connectors to start.\r\n *\r\n * Precedence is `explicit non-undefined option > tests.connectors config >\r\n * true`. Omitting the property, or passing `undefined`, lets project config\r\n * apply — so an optional variable that happens to be `undefined` cannot erase\r\n * it.\r\n */\r\n connectors?: TestConnectorsSelection;\r\n};\r\n\r\n/**\r\n * Raised by the lifecycle itself, never by the runtime it manages — a conflict\r\n * between two calls, or a refusal to reuse a runtime that did not close.\r\n */\r\nexport class TestLifecycleError extends Error {\r\n public constructor(message: string) {\r\n super(message);\r\n\r\n this.name = \"TestLifecycleError\";\r\n }\r\n}\r\n\r\nconst POISONED_MESSAGE =\r\n \"setupTest() refuses to start a test runtime: an earlier teardownTest() reported a shutdown failure, so the connectors, ports and pools it owned are not known to be closed. Restart the Vitest worker before setting up again, or call teardownTest() to retry the shutdown — the lifecycle only returns to idle on a fully successful retry.\";\r\n\r\n/**\r\n * Bootstrap the test runtime and start the selected connectors.\r\n *\r\n * ⚠ Runs once per TEST FILE, not once per worker: `setupFiles` is executed for\r\n * every file and its module registry is rebuilt with it, measured across both\r\n * pools with isolation on and off. The lifecycle state lives on the runtime\r\n * context rather than in this module precisely so that a rebuild cannot hide a\r\n * runtime that is still up.\r\n *\r\n * Repeated calls:\r\n *\r\n * - concurrent calls with the same effective selection share one startup;\r\n * - while ready, the same effective selection is a no-op;\r\n * - while starting or ready, a DIFFERENT effective selection rejects and leaves\r\n * the live runtime untouched;\r\n * - a failed setup unwinds and returns to idle, so a clean retry is allowed;\r\n * - after a successful `teardownTest`, a later setup may use a different\r\n * selection.\r\n *\r\n * @example\r\n * // let project config decide, falling back to the default set\r\n * await setupTest();\r\n *\r\n * @example\r\n * // bootstrap only — no connectors, whatever config says\r\n * await setupTest({ connectors: false });\r\n */\r\nexport async function setupTest(options?: TestSetupOptions): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n const requested = readRequestedConnectors(options?.connectors);\r\n\r\n if (registry.state === \"poisoned\") {\r\n throw new TestLifecycleError(POISONED_MESSAGE);\r\n }\r\n\r\n if (registry.state === \"stopping\" && registry.teardownAttempt) {\r\n await settled(registry.teardownAttempt);\r\n\r\n return setupTest(options);\r\n }\r\n\r\n if (registry.state === \"ready\") {\r\n assertReadySelectionMatches(registry.activeSelection, requested);\r\n\r\n return;\r\n }\r\n\r\n if (registry.state === \"starting\" && registry.setupAttempt) {\r\n const attempt = registry.setupAttempt;\r\n\r\n await assertPendingSetupMatches(attempt, requested);\r\n\r\n return attempt.completion;\r\n }\r\n\r\n return startTestRuntime(requested);\r\n}\r\n\r\n/**\r\n * Shut the test runtime down and release the lifecycle.\r\n *\r\n * - idle is a no-op;\r\n * - concurrent calls share one attempt;\r\n * - a call made while setup is still running waits for that attempt to settle,\r\n * then closes the runtime if it succeeded;\r\n * - the local \"ready\" state is always cleared, including when shutdown rejects;\r\n * - a shutdown rejection is surfaced, never swallowed, and poisons the\r\n * lifecycle — a reported close failure is not proof that anything closed, so\r\n * later `setupTest` calls refuse until the worker is restarted or a retry\r\n * fully succeeds.\r\n *\r\n * ⚠ Individual connector shutdown failures are caught and logged inside\r\n * `connectorsManager.shutdown()`, so they never reach this function and never\r\n * poison anything. This lifecycle can only surface what that layer reports.\r\n */\r\nexport async function teardownTest(): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n\r\n if (registry.state === \"stopping\" && registry.teardownAttempt) {\r\n return registry.teardownAttempt;\r\n }\r\n\r\n if (registry.state === \"starting\" && registry.setupAttempt) {\r\n // A runtime that is still opening cannot be closed halfway. Wait for the\r\n // attempt to settle: a failed one has already unwound itself and left the\r\n // lifecycle idle, which the re-entry below then reads as \"nothing to do\".\r\n await settled(registry.setupAttempt.completion);\r\n\r\n return teardownTest();\r\n }\r\n\r\n if (registry.state === \"idle\") {\r\n return;\r\n }\r\n\r\n registry.state = \"stopping\";\r\n\r\n // Deferred by a microtask so the registry is fully published before the\r\n // attempt's first line runs — a synchronous throw would otherwise reach the\r\n // `finally` below, and reset the state, before this function had recorded\r\n // that a teardown was in flight at all.\r\n const attempt = Promise.resolve().then(() => runTestRuntimeShutdown());\r\n\r\n registry.teardownAttempt = attempt;\r\n\r\n return attempt;\r\n}\r\n\r\n/**\r\n * The setup attempt's hang guard, as the lifecycle consumes it.\r\n *\r\n * The bound's POLICY — the default, the config key, the message — lives in\r\n * `test-setup-timeout.ts`. What expiry MEANS lives here.\r\n *\r\n * @internal\r\n */\r\ntype SetupBound = {\r\n /**\r\n * Rejects with the expiry error. Never resolves: the attempt is the only side\r\n * of the race that can succeed.\r\n */\r\n readonly expiry: Promise<never>;\r\n\r\n /**\r\n * Re-aim the bound at `next` ms measured from when the ATTEMPT STARTED, once\r\n * config has made `tests.setupTimeout` readable.\r\n */\r\n rearm(next: number): void;\r\n\r\n /** The race is over — cancel whatever timer is still pending. */\r\n settle(): void;\r\n\r\n /** Whether the bound, rather than the attempt, won the race. */\r\n hasExpired(): boolean;\r\n};\r\n\r\n/**\r\n * Arm the hang guard for one setup attempt.\r\n *\r\n * Armed at the default BEFORE the attempt runs, because `tests.setupTimeout` is\r\n * not readable until the attempt has loaded config — and loading config is\r\n * itself one of the steps that can hang. `rearm` then narrows or widens it the\r\n * moment config arrives.\r\n */\r\nfunction armSetupBound(registry: TestLifecycleRegistry): SetupBound {\r\n const schedule = registry.scheduleTimeout ?? scheduleRealTimeout;\r\n const armedAt = Date.now();\r\n\r\n let handle: TestTimeoutHandle | undefined;\r\n let expired = false;\r\n let closed = false;\r\n let expire: (error: unknown) => void = () => undefined;\r\n\r\n const expiry = new Promise<never>((_resolve, reject) => {\r\n expire = reject;\r\n });\r\n\r\n // Only `awaitSetupWithinBound` observes this, and only until the attempt wins\r\n // — after that nobody is listening, and an unobserved rejection surfaces as an\r\n // unhandled rejection that fails an unrelated test file. Same reason as the\r\n // `effectiveSelection` barrier below.\r\n expiry.catch(() => undefined);\r\n\r\n const expireNow = (bound: number): void => {\r\n if (closed) {\r\n return;\r\n }\r\n\r\n closed = true;\r\n expired = true;\r\n\r\n handle?.cancel();\r\n handle = undefined;\r\n\r\n expire(new TestLifecycleError(describeExpiredSetup(bound)));\r\n };\r\n\r\n const armFor = (bound: number, delay: number): void => {\r\n if (closed) {\r\n return;\r\n }\r\n\r\n handle?.cancel();\r\n\r\n // Already overdue. A bound the attempt has ALREADY exceeded must fire now,\r\n // not be rescheduled for time that was spent before it was known.\r\n if (delay <= 0) {\r\n expireNow(bound);\r\n\r\n return;\r\n }\r\n\r\n handle = schedule(delay, () => expireNow(bound));\r\n };\r\n\r\n const initialBound = registry.setupTimeoutOverride ?? DEFAULT_TEST_SETUP_TIMEOUT;\r\n\r\n armFor(initialBound, initialBound);\r\n\r\n return {\r\n expiry,\r\n\r\n // Measured from `armedAt`, never from now: adding a configured bound to the\r\n // time already spent would make the real bound default-plus-configured, and\r\n // a project that lowered the key would get a LONGER guard than the default.\r\n rearm: (next) => armFor(next, next - (Date.now() - armedAt)),\r\n\r\n settle: () => {\r\n closed = true;\r\n\r\n handle?.cancel();\r\n handle = undefined;\r\n },\r\n\r\n hasExpired: () => expired,\r\n };\r\n}\r\n\r\n/**\r\n * Race one setup attempt against its bound.\r\n *\r\n * The losing attempt is NOT cancellable — nothing here can interrupt a bootstrap\r\n * stuck in a socket connect — so when the bound wins, the lifecycle is poisoned\r\n * and every later state write from that abandoned attempt is dropped. That\r\n * dropping happens in `runTestRuntimeStartup`, guarded on `hasExpired()`;\r\n * without it the still-running attempt would quietly overwrite `poisoned` with\r\n * `ready` or `idle` and hand the next caller a runtime nobody owns.\r\n */\r\nasync function awaitSetupWithinBound(\r\n attempt: Promise<void>,\r\n bound: SetupBound,\r\n registry: TestLifecycleRegistry,\r\n): Promise<void> {\r\n try {\r\n await Promise.race([attempt, bound.expiry]);\r\n } catch (error) {\r\n if (bound.hasExpired()) {\r\n registry.state = \"poisoned\";\r\n registry.activeSelection = undefined;\r\n registry.setupAttempt = undefined;\r\n }\r\n\r\n throw error;\r\n } finally {\r\n bound.settle();\r\n }\r\n}\r\n\r\n/**\r\n * Open a new setup attempt and publish it before it runs.\r\n */\r\nfunction startTestRuntime(requested: RequestedTestConnectors): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n\r\n let publishEffectiveSelection: (selection: TestConnectorsSelection) => void = () => undefined;\r\n let failEffectiveSelection: (error: unknown) => void = () => undefined;\r\n\r\n const effectiveSelection = new Promise<TestConnectorsSelection>((resolve, reject) => {\r\n publishEffectiveSelection = resolve;\r\n failEffectiveSelection = reject;\r\n });\r\n\r\n // Only the mixed explicit/config comparison ever awaits this barrier, so its\r\n // rejection is usually unobserved — and an unobserved rejection would surface\r\n // as an unhandled rejection and fail an unrelated test file.\r\n effectiveSelection.catch(() => undefined);\r\n\r\n const bound = armSetupBound(registry);\r\n\r\n const attempt = Promise.resolve().then(() =>\r\n runTestRuntimeStartup(requested, publishEffectiveSelection, failEffectiveSelection, bound),\r\n );\r\n\r\n // The attempt outlives a bound that beat it, and by then `completion` has\r\n // already rejected with the expiry error — so the attempt's own late rejection\r\n // has no observer. Same unhandled-rejection hazard as above.\r\n attempt.catch(() => undefined);\r\n\r\n // `teardownTest` waits on this same promise, which is how a teardown requested\r\n // during setup inherits the bound. There is deliberately no second timer and\r\n // no separate teardown deadline.\r\n const completion = awaitSetupWithinBound(attempt, bound, registry);\r\n\r\n registry.state = \"starting\";\r\n registry.setupAttempt = { requested, effectiveSelection, completion };\r\n\r\n return completion;\r\n}\r\n\r\n/**\r\n * The startup attempt itself.\r\n *\r\n * On failure: best-effort unwind, reset bookkeeping, rethrow the ORIGINAL error\r\n * unchanged. A cleanup failure is a secondary diagnostic and never replaces the\r\n * cause the caller needs to read.\r\n */\r\nasync function runTestRuntimeStartup(\r\n requested: RequestedTestConnectors,\r\n publishEffectiveSelection: (selection: TestConnectorsSelection) => void,\r\n failEffectiveSelection: (error: unknown) => void,\r\n bound: SetupBound,\r\n): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n\r\n try {\r\n Application.setEnvironment(\"test\");\r\n\r\n await warlockConfigManager.load();\r\n await bootstrap();\r\n\r\n await filesOrchestrator.init();\r\n await loadConfigFiles(true);\r\n\r\n // The first point at which `tests.setupTimeout` is readable at all. An\r\n // invalid value throws from here and takes the normal failure path — falling\r\n // back to the default would silently erase what the project configured.\r\n const configuredTimeout = readConfiguredSetupTimeout();\r\n\r\n if (configuredTimeout !== undefined) {\r\n bound.rearm(configuredTimeout);\r\n }\r\n\r\n // Resolved here and not at call time: the config layer is only readable once\r\n // the four steps above have run.\r\n const effectiveSelection = resolveEffectiveConnectors(requested);\r\n\r\n // Every state write below is conditional on this attempt still being the one\r\n // the lifecycle is waiting for. Once the bound has expired the lifecycle is\r\n // poisoned and this attempt is abandoned — it may still be running, but it\r\n // no longer speaks for the runtime.\r\n if (!bound.hasExpired()) {\r\n registry.activeSelection = effectiveSelection;\r\n }\r\n\r\n publishEffectiveSelection(effectiveSelection);\r\n\r\n await startSelectedConnectors(effectiveSelection);\r\n\r\n if (!bound.hasExpired()) {\r\n registry.state = \"ready\";\r\n registry.setupAttempt = undefined;\r\n }\r\n } catch (error) {\r\n failEffectiveSelection(error);\r\n\r\n await unwindPartialStartup();\r\n\r\n if (!bound.hasExpired()) {\r\n registry.state = \"idle\";\r\n registry.activeSelection = undefined;\r\n registry.setupAttempt = undefined;\r\n }\r\n\r\n console.error(\"[vitest-setup] Failed to setup test environment:\", error);\r\n\r\n throw error;\r\n }\r\n}\r\n\r\n/**\r\n * `false` means none at all. Everything else starts something: an array starts\r\n * exactly those, and `true` starts the default set — all but http, which is the\r\n * global setup's job and shared across every worker.\r\n */\r\nasync function startSelectedConnectors(selection: TestConnectorsSelection): Promise<void> {\r\n if (selection === false) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(selection)) {\r\n await connectorsManager.start(normalizeConnectorNames(selection));\r\n\r\n return;\r\n }\r\n\r\n await connectorsManager.startWithout([\"http\"]);\r\n}\r\n\r\n/**\r\n * Best-effort teardown of whatever a failed startup managed to start.\r\n *\r\n * Runs while an error is already in flight, so no step here may throw and every\r\n * step is attempted independently.\r\n */\r\nasync function unwindPartialStartup(): Promise<void> {\r\n // Two steps rather than one: `connectorsManager.shutdown()` runs the\r\n // application hooks itself, but it runs them FIRST and does not isolate their\r\n // rejection — so a hook that rejects would take the connector teardown down\r\n // with it and leave every connector up. Both calls are idempotent, so running\r\n // the hooks on their own first costs nothing and means neither failure can\r\n // skip the other step.\r\n await attemptCleanupStep(\"application shutdown hooks\", () => Application.runShutdownHooks());\r\n await attemptCleanupStep(\"connectors shutdown\", () => connectorsManager.shutdown());\r\n}\r\n\r\n/**\r\n * Run one cleanup step, isolating its failure so the next step still runs.\r\n */\r\nasync function attemptCleanupStep(step: string, run: () => Promise<void>): Promise<void> {\r\n try {\r\n await run();\r\n } catch (error) {\r\n // Reported, not thrown — it is secondary to the startup error about to be\r\n // rethrown, and losing that one to this would be the worse outcome.\r\n console.error(`[vitest-setup] Cleanup after a failed setup did not complete (${step}):`, error);\r\n }\r\n}\r\n\r\n/**\r\n * The teardown attempt itself.\r\n */\r\nasync function runTestRuntimeShutdown(): Promise<void> {\r\n const registry = getTestLifecycleRegistry();\r\n let shutdownSucceeded = false;\r\n\r\n try {\r\n // Manager-wide, and deliberately called whatever the selection was: with\r\n // `connectors: false` nothing was started, but bootstrap still registered\r\n // application shutdown hooks, and the manager runs those first (see\r\n // `connectors-manager.ts` — `Application.runShutdownHooks()` is its first\r\n // line). Skipping the call to \"match\" an empty selection would leak them.\r\n await connectorsManager.shutdown();\r\n\r\n shutdownSucceeded = true;\r\n } finally {\r\n // In a `finally`, not after the `await`: a rejected shutdown must not leave\r\n // the lifecycle claiming a runtime it no longer owns. Poisoned rather than\r\n // idle, because a cleared flag does not prove that ports, sockets, pools or\r\n // timers closed.\r\n registry.activeSelection = undefined;\r\n registry.setupAttempt = undefined;\r\n registry.teardownAttempt = undefined;\r\n registry.state = shutdownSucceeded ? \"idle\" : \"poisoned\";\r\n }\r\n}\r\n\r\n/**\r\n * Reject when a ready runtime was set up with a different selection.\r\n */\r\nfunction assertReadySelectionMatches(\r\n activeSelection: TestConnectorsSelection | undefined,\r\n requested: RequestedTestConnectors,\r\n): void {\r\n if (activeSelection === undefined) {\r\n return;\r\n }\r\n\r\n // Config is loaded by the time anything is ready, so the config-derived layer\r\n // is resolvable right here.\r\n const requestedSelection = resolveEffectiveConnectors(requested);\r\n\r\n assertSelectionsMatch(activeSelection, requestedSelection);\r\n}\r\n\r\n/**\r\n * Reject when an in-flight setup attempt is starting a different selection.\r\n */\r\nasync function assertPendingSetupMatches(\r\n attempt: TestSetupAttempt,\r\n requested: RequestedTestConnectors,\r\n): Promise<void> {\r\n const pending = attempt.requested;\r\n\r\n // Two calls that both defer to project config resolve to the same thing by\r\n // construction — knowable without waiting for config to load.\r\n if (!pending.isExplicit && !requested.isExplicit) {\r\n return;\r\n }\r\n\r\n if (pending.isExplicit && requested.isExplicit) {\r\n assertSelectionsMatch(pending.selection, requested.selection);\r\n\r\n return;\r\n }\r\n\r\n // Mixed: one side is config-derived and config is not readable until the\r\n // running attempt has loaded it, so wait for that barrier first.\r\n const activeSelection = await attempt.effectiveSelection;\r\n const requestedSelection = resolveEffectiveConnectors(requested);\r\n\r\n assertSelectionsMatch(activeSelection, requestedSelection);\r\n}\r\n\r\n/**\r\n * Name both selections: a caller looking at this message has to be able to tell\r\n * which call to change without reading the framework's source.\r\n */\r\nfunction assertSelectionsMatch(\r\n activeSelection: TestConnectorsSelection,\r\n requestedSelection: TestConnectorsSelection,\r\n): void {\r\n if (isSameConnectorsSelection(activeSelection, requestedSelection)) {\r\n return;\r\n }\r\n\r\n throw new TestLifecycleError(\r\n `setupTest() is already using ${describeConnectorsSelection(activeSelection)}, and this call asked for ${describeConnectorsSelection(requestedSelection)}. One test runtime serves one connector selection — call teardownTest() before setting up a different one.`,\r\n );\r\n}\r\n\r\n/**\r\n * Await an attempt for its state transition only, not its result.\r\n */\r\nfunction settled(attempt: Promise<void>): Promise<void> {\r\n return attempt.catch(() => undefined);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,AAAO,YAAY,SAAiB;EAClC,MAAM,OAAO;EAEb,KAAK,OAAO;CACd;AACF;AAEA,MAAM,mBACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BF,eAAsB,UAAU,SAA2C;CACzE,MAAM,WAAW,yBAAyB;CAC1C,MAAM,YAAY,wBAAwB,SAAS,UAAU;CAE7D,IAAI,SAAS,UAAU,YACrB,MAAM,IAAI,mBAAmB,gBAAgB;CAG/C,IAAI,SAAS,UAAU,cAAc,SAAS,iBAAiB;EAC7D,MAAM,QAAQ,SAAS,eAAe;EAEtC,OAAO,UAAU,OAAO;CAC1B;CAEA,IAAI,SAAS,UAAU,SAAS;EAC9B,4BAA4B,SAAS,iBAAiB,SAAS;EAE/D;CACF;CAEA,IAAI,SAAS,UAAU,cAAc,SAAS,cAAc;EAC1D,MAAM,UAAU,SAAS;EAEzB,MAAM,0BAA0B,SAAS,SAAS;EAElD,OAAO,QAAQ;CACjB;CAEA,OAAO,iBAAiB,SAA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S;EAE5D;CACF;CAOA,sBAAsB,MAHQ,QAAQ,oBACX,2BAA2B,SAEE,CAAC;AAC3D;;;;;AAMA,SAAS,sBACP,iBACA,oBACM;CACN,IAAI,0BAA0B,iBAAiB,kBAAkB,GAC/D;CAGF,MAAM,IAAI,mBACR,gCAAgC,4BAA4B,eAAe,EAAE,4BAA4B,4BAA4B,kBAAkB,EAAE,2GAC3J;AACF;;;;AAKA,SAAS,QAAQ,SAAuC;CACtD,OAAO,QAAQ,YAAY,MAAS;AACtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"update-warlock-packages.mjs","names":[],"sources":["../../../../../../../core/src/updater/update-warlock-packages.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { fileExistsAsync, getJsonFileAsync, putJsonFileAsync } from \"@warlock.js/fs\";\nimport { execSync } from \"node:child_process\";\nimport { rootPath } from \"../utils\";\nimport { fetchLatestVersion } from \"../utils/npm-registry\";\nimport { isNewerVersion } from \"../utils/version-compare\";\nimport { detectPackageManager, getInstallCommand } from \"./package-manager\";\n\n/** Scope prefix that identifies a Warlock framework package. */\nconst WARLOCK_SCOPE = \"@warlock.js/\";\n\n/** The dependency maps in package.json we update, in display order. */\nconst DEPENDENCY_SECTIONS = [\"dependencies\", \"devDependencies\"] as const;\n\ntype DependencySection = (typeof DEPENDENCY_SECTIONS)[number];\n\ntype DependencyMap = Record<string, string>;\n\ntype PackageJson = Record<string, unknown> & {\n dependencies?: DependencyMap;\n devDependencies?: DependencyMap;\n};\n\n/** A `@warlock.js/*` dependency found in package.json. */\ntype WarlockDependency = {\n name: string;\n section: DependencySection;\n /** The current spec exactly as written, e.g. `^4.2.0`. */\n current: string;\n};\n\n/** A dependency whose latest version has been resolved from the registry. */\nexport type ResolvedDependency = WarlockDependency & {\n /** Latest version from npm, or `undefined` when the lookup failed. */\n latest: string | undefined;\n};\n\n/** A concrete version bump to write back into package.json. */\nexport type PackageUpdate = {\n name: string;\n section: DependencySection;\n /** Existing spec, e.g. `^4.2.0`. */\n from: string;\n /** New spec with the original range operator preserved, e.g. `^4.3.0`. */\n to: string;\n};\n\n/** Options accepted by {@link updateWarlockPackages}. */\nexport type UpdateWarlockPackagesOptions = {\n /** Run the package manager install after rewriting versions (default true). */\n install?: boolean;\n /**\n * Report what would change without touching package.json or node_modules.\n * Resolves with the `outdated` outcome instead of `updated`.\n */\n dryRun?: boolean;\n};\n\n/**\n * How an update run ended. Callers branch on this instead of re-deriving the\n * situation from the printed output — the dev-server `u` shortcut needs to\n * know whether restarting is warranted, and whether it may offer a retry.\n */\nexport type UpdateOutcome =\n /** No package.json at the project root — nothing to do. */\n | \"no-package-json\"\n /** package.json carries no `@warlock.js/*` dependency. */\n | \"no-packages\"\n /** Every registry lookup failed — offline, DNS down, or npm unreachable. */\n | \"registry-unreachable\"\n /** Every package is already at (or ahead of) its latest published version. */\n | \"up-to-date\"\n /** Newer versions exist, and a dry run left everything untouched. */\n | \"outdated\"\n /** Versions were rewritten (and installed, unless `install: false`). */\n | \"updated\"\n /** Versions were rewritten but the package manager install failed. */\n | \"install-failed\";\n\n/** The result of an update run. */\nexport type UpdateWarlockPackagesResult = {\n outcome: UpdateOutcome;\n /** The bumps written to package.json — empty unless `outcome` wrote any. */\n updates: PackageUpdate[];\n /** The install failure, present only for `install-failed`. */\n error?: Error;\n};\n\n/**\n * Update every `@warlock.js/*` package listed in the project's root\n * package.json to its latest published version, then reconcile `node_modules`\n * via the detected package manager.\n *\n * The original range operator on each dependency (`^`, `~`, or an exact pin)\n * is preserved; specs that aren't a plain semver — `workspace:*`, `*`,\n * `latest`, git/file URLs — are left untouched. Only genuine upgrades are\n * written, so re-running on an already-current project is a no-op.\n *\n * Resolves rather than throws on the two failures a caller is expected to\n * survive — an unreachable registry and a failed install — so the dev-server\n * shortcut can report them and keep serving.\n */\nexport async function updateWarlockPackages(\n options: UpdateWarlockPackagesOptions = {},\n): Promise<UpdateWarlockPackagesResult> {\n const runInstall = options.install ?? true;\n const packageJsonPath = rootPath(\"package.json\");\n\n if (!(await fileExistsAsync(packageJsonPath))) {\n console.log(`${colors.red(\"✖\")} No package.json found at the project root.`);\n return { outcome: \"no-package-json\", updates: [] };\n }\n\n const packageJson = (await getJsonFileAsync(packageJsonPath)) as PackageJson;\n const dependencies = collectWarlockDependencies(packageJson);\n\n if (dependencies.length === 0) {\n console.log(`${colors.yellow(\"⚠\")} No @warlock.js packages found in package.json.`);\n return { outcome: \"no-packages\", updates: [] };\n }\n\n console.log(\n `${colors.cyan(\"›\")} Checking ${colors.bold(String(dependencies.length))} ` +\n `@warlock.js package(s) for updates…`,\n );\n\n const resolved = await resolveLatestVersions(dependencies);\n\n // Distinguish \"nothing newer\" from \"we never got an answer\". Without this,\n // an offline run reports every package as up to date, which is a lie.\n if (isRegistryUnreachable(resolved)) {\n console.log(\n `${colors.yellow(\"⚠\")} Could not reach the npm registry — ` +\n `no versions were changed. Check your connection and try again.`,\n );\n return { outcome: \"registry-unreachable\", updates: [] };\n }\n\n const updates = resolvePackageUpdates(resolved);\n\n if (updates.length === 0) {\n console.log(`${colors.green(\"✓\")} All @warlock.js packages are already up to date.`);\n return { outcome: \"up-to-date\", updates: [] };\n }\n\n if (options.dryRun) {\n printUpdates(updates, { pending: true });\n return { outcome: \"outdated\", updates };\n }\n\n applyUpdates(packageJson, updates);\n await putJsonFileAsync(packageJsonPath, packageJson);\n\n printUpdates(updates);\n\n if (!runInstall) {\n console.log(\n colors.dim(\"Skipped install (--no-install). Run your package manager to apply the changes.\"),\n );\n return { outcome: \"updated\", updates };\n }\n\n try {\n await installDependencies();\n } catch (error) {\n console.log(\n `${colors.red(\"✖\")} The install failed. package.json is already updated — ` +\n `re-run your package manager install to finish.`,\n );\n return { outcome: \"install-failed\", updates, error: error as Error };\n }\n\n return { outcome: \"updated\", updates };\n}\n\n/**\n * Whether *every* lookup came back empty, which in practice means the\n * registry was never reached. A single failed package (unpublished, renamed,\n * private) leaves the rest resolvable and is not treated as an outage.\n */\nexport function isRegistryUnreachable(resolved: ResolvedDependency[]): boolean {\n return resolved.length > 0 && resolved.every((dependency) => !dependency.latest);\n}\n\n/** Collect every `@warlock.js/*` dependency across the relevant sections. */\nfunction collectWarlockDependencies(packageJson: PackageJson): WarlockDependency[] {\n const dependencies: WarlockDependency[] = [];\n\n for (const section of DEPENDENCY_SECTIONS) {\n const map = packageJson[section];\n\n if (!map) {\n continue;\n }\n\n for (const [name, current] of Object.entries(map)) {\n if (name.startsWith(WARLOCK_SCOPE)) {\n dependencies.push({ name, section, current });\n }\n }\n }\n\n return dependencies;\n}\n\n/** Resolve each dependency's latest version from the registry in parallel. */\nasync function resolveLatestVersions(\n dependencies: WarlockDependency[],\n): Promise<ResolvedDependency[]> {\n return Promise.all(\n dependencies.map(async (dependency) => ({\n ...dependency,\n latest: await fetchLatestVersion(dependency.name),\n })),\n );\n}\n\n/**\n * Turn resolved dependencies into the concrete set of version bumps to write.\n * Pure (no I/O) so it can be unit-tested directly: skips lookups that failed,\n * non-semver specs, and anything already at (or ahead of) the latest version,\n * and preserves the original range operator on everything it does rewrite.\n */\nexport function resolvePackageUpdates(resolved: ResolvedDependency[]): PackageUpdate[] {\n const updates: PackageUpdate[] = [];\n\n for (const dependency of resolved) {\n if (!dependency.latest) {\n continue;\n }\n\n const parsed = parseSpec(dependency.current);\n\n if (!parsed) {\n continue;\n }\n\n if (!isNewerVersion(dependency.latest, parsed.version)) {\n continue;\n }\n\n updates.push({\n name: dependency.name,\n section: dependency.section,\n from: dependency.current,\n to: `${parsed.operator}${dependency.latest}`,\n });\n }\n\n return updates;\n}\n\n/**\n * Split a dependency spec into its range operator and concrete version.\n * Returns `undefined` for specs we won't touch — `workspace:*`, `*`,\n * `latest`, multi-part ranges, or git/file URLs — leaving them exactly as\n * the author wrote them.\n */\nfunction parseSpec(spec: string): { operator: string; version: string } | undefined {\n const match = spec.trim().match(/^(\\^|~)?(\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?)$/);\n\n if (!match) {\n return undefined;\n }\n\n return { operator: match[1] ?? \"\", version: match[2] };\n}\n\n/** Write the resolved bumps back into the package.json object in place. */\nfunction applyUpdates(packageJson: PackageJson, updates: PackageUpdate[]): void {\n for (const update of updates) {\n const map = packageJson[update.section];\n\n if (map) {\n map[update.name] = update.to;\n }\n }\n}\n\n/** Print the version bumps — applied, or pending on a dry run. */\nfunction printUpdates(updates: PackageUpdate[], { pending = false } = {}): void {\n const headline = pending\n ? `${colors.yellow(\"↑\")} ${colors.bold(String(updates.length))} package(s) can be updated:`\n : `${colors.green(\"✓\")} Updated ${colors.bold(String(updates.length))} package(s):`;\n\n console.log(headline);\n\n for (const update of updates) {\n console.log(\n ` ${colors.cyan(update.name)} ` +\n `${colors.dim(update.from)} ${colors.dim(\"→\")} ${colors.greenBright(update.to)}`,\n );\n }\n}\n\n/** Reconcile node_modules to the rewritten package.json via the project PM. */\nasync function installDependencies(): Promise<void> {\n const packageManager = await detectPackageManager();\n const installCommand = getInstallCommand(packageManager);\n\n console.log(`${colors.cyan(\"›\")} Running ${colors.bold(installCommand)}…`);\n\n execSync(installCommand, { cwd: process.cwd(), stdio: \"inherit\" });\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,gBAAgB;;AAGtB,MAAM,sBAAsB,CAAC,gBAAgB,iBAAiB;;;;;;;;;;;;;;;AA0F9D,eAAsB,sBACpB,UAAwC,CAAC,GACH;CACtC,MAAM,aAAa,QAAQ,WAAW;CACtC,MAAM,kBAAkB,SAAS,cAAc;CAE/C,IAAI,CAAE,MAAM,gBAAgB,eAAe,GAAI;EAC7C,QAAQ,IAAI,GAAG,OAAO,IAAI,GAAG,EAAE,4CAA4C;EAC3E,OAAO;GAAE,SAAS;GAAmB,SAAS,CAAC;EAAE;CACnD;CAEA,MAAM,cAAe,MAAM,iBAAiB,eAAe;CAC3D,MAAM,eAAe,2BAA2B,WAAW;CAE3D,IAAI,aAAa,WAAW,GAAG;EAC7B,QAAQ,IAAI,GAAG,OAAO,OAAO,GAAG,EAAE,gDAAgD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AAO,MAAM,GAAG,EAAE,WAAW,OAAO,KAAK,OAAO,QAAQ,MAAM,CAAC,EAAE;CAExE,QAAQ,IAAI,QAAQ;CAEpB,KAAK,MAAM,UAAU,SACnB,QAAQ,IACN,MAAM,OAAO,KAAK,OAAO,IAAI,EAAE,IAC1B,OAAO,IAAI,OAAO,IAAI,EAAE,GAAG,OAAO,IAAI,GAAG,EAAE,GAAG,OAAO,YAAY,OAAO,EAAE,GACjF;AAEJ;;AAGA,eAAe,sBAAqC;CAElD,MAAM,iBAAiB,kBAAkB,MADZ,qBAAqB,CACK;CAEvD,QAAQ,IAAI,GAAG,OAAO,KAAK,GAAG,EAAE,WAAW,OAAO,KAAK,cAAc,EAAE,EAAE;CAEzE,SAAS,gBAAgB;EAAE,KAAK,QAAQ,IAAI;EAAG,OAAO;CAAU,CAAC;AACnE"}
1
+ {"version":3,"file":"update-warlock-packages.mjs","names":[],"sources":["../../../../../../../core/src/updater/update-warlock-packages.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { fileExistsAsync, getJsonFileAsync, putJsonFileAsync } from \"@warlock.js/fs\";\nimport { execSync } from \"node:child_process\";\nimport { rootPath } from \"../utils\";\nimport { fetchLatestVersion } from \"../utils/npm-registry\";\nimport { isNewerVersion } from \"../utils/version-compare\";\nimport { detectPackageManager, getInstallCommand } from \"./package-manager\";\n\n/** Scope prefix that identifies a Warlock framework package. */\nconst WARLOCK_SCOPE = \"@warlock.js/\";\n\n/** The dependency maps in package.json we update, in display order. */\nconst DEPENDENCY_SECTIONS = [\"dependencies\", \"devDependencies\"] as const;\n\ntype DependencySection = (typeof DEPENDENCY_SECTIONS)[number];\n\ntype DependencyMap = Record<string, string>;\n\ntype PackageJson = Record<string, unknown> & {\n dependencies?: DependencyMap;\n devDependencies?: DependencyMap;\n};\n\n/** A `@warlock.js/*` dependency found in package.json. */\ntype WarlockDependency = {\n name: string;\n section: DependencySection;\n /** The current spec exactly as written, e.g. `^4.2.0`. */\n current: string;\n};\n\n/** A dependency whose latest version has been resolved from the registry. */\nexport type ResolvedDependency = WarlockDependency & {\n /** Latest version from npm, or `undefined` when the lookup failed. */\n latest: string | undefined;\n};\n\n/** A concrete version bump to write back into package.json. */\nexport type PackageUpdate = {\n name: string;\n section: DependencySection;\n /** Existing spec, e.g. `^4.2.0`. */\n from: string;\n /** New spec with the original range operator preserved, e.g. `^4.3.0`. */\n to: string;\n};\n\n/** Options accepted by {@link updateWarlockPackages}. */\nexport type UpdateWarlockPackagesOptions = {\n /** Run the package manager install after rewriting versions (default true). */\n install?: boolean;\n /**\n * Report what would change without touching package.json or node_modules.\n * Resolves with the `outdated` outcome instead of `updated`.\n */\n dryRun?: boolean;\n};\n\n/**\n * How an update run ended. Callers branch on this instead of re-deriving the\n * situation from the printed output — the dev-server `u` shortcut needs to\n * know whether restarting is warranted, and whether it may offer a retry.\n */\nexport type UpdateOutcome =\n /** No package.json at the project root — nothing to do. */\n | \"no-package-json\"\n /** package.json carries no `@warlock.js/*` dependency. */\n | \"no-packages\"\n /** Every registry lookup failed — offline, DNS down, or npm unreachable. */\n | \"registry-unreachable\"\n /** Every package is already at (or ahead of) its latest published version. */\n | \"up-to-date\"\n /** Newer versions exist, and a dry run left everything untouched. */\n | \"outdated\"\n /** Versions were rewritten (and installed, unless `install: false`). */\n | \"updated\"\n /** Versions were rewritten but the package manager install failed. */\n | \"install-failed\";\n\n/** The result of an update run. */\nexport type UpdateWarlockPackagesResult = {\n outcome: UpdateOutcome;\n /** The bumps written to package.json — empty unless `outcome` wrote any. */\n updates: PackageUpdate[];\n /** The install failure, present only for `install-failed`. */\n error?: Error;\n};\n\n/**\n * Update every `@warlock.js/*` package listed in the project's root\n * package.json to its latest published version, then reconcile `node_modules`\n * via the detected package manager.\n *\n * The original range operator on each dependency (`^`, `~`, or an exact pin)\n * is preserved; specs that aren't a plain semver — `workspace:*`, `*`,\n * `latest`, git/file URLs — are left untouched. Only genuine upgrades are\n * written, so re-running on an already-current project is a no-op.\n *\n * Resolves rather than throws on the two failures a caller is expected to\n * survive — an unreachable registry and a failed install — so the dev-server\n * shortcut can report them and keep serving.\n */\nexport async function updateWarlockPackages(\n options: UpdateWarlockPackagesOptions = {},\n): Promise<UpdateWarlockPackagesResult> {\n const runInstall = options.install ?? true;\n const packageJsonPath = rootPath(\"package.json\");\n\n if (!(await fileExistsAsync(packageJsonPath))) {\n console.log(`${colors.red(\"✖\")} No package.json found at the project root.`);\n return { outcome: \"no-package-json\", updates: [] };\n }\n\n const packageJson = (await getJsonFileAsync(packageJsonPath)) as PackageJson;\n const dependencies = collectWarlockDependencies(packageJson);\n\n if (dependencies.length === 0) {\n console.log(`${colors.yellow(\"⚠\")} No @warlock.js packages found in package.json.`);\n return { outcome: \"no-packages\", updates: [] };\n }\n\n console.log(\n `${colors.cyan(\"›\")} Checking ${colors.bold(String(dependencies.length))} ` +\n `@warlock.js package(s) for updates…`,\n );\n\n const resolved = await resolveLatestVersions(dependencies);\n\n // Distinguish \"nothing newer\" from \"we never got an answer\". Without this,\n // an offline run reports every package as up to date, which is a lie.\n if (isRegistryUnreachable(resolved)) {\n console.log(\n `${colors.yellow(\"⚠\")} Could not reach the npm registry — ` +\n `no versions were changed. Check your connection and try again.`,\n );\n return { outcome: \"registry-unreachable\", updates: [] };\n }\n\n const updates = resolvePackageUpdates(resolved);\n\n if (updates.length === 0) {\n console.log(`${colors.green(\"✓\")} All @warlock.js packages are already up to date.`);\n return { outcome: \"up-to-date\", updates: [] };\n }\n\n if (options.dryRun) {\n printUpdates(updates, { pending: true });\n return { outcome: \"outdated\", updates };\n }\n\n applyUpdates(packageJson, updates);\n await putJsonFileAsync(packageJsonPath, packageJson);\n\n printUpdates(updates);\n\n if (!runInstall) {\n console.log(\n colors.dim(\"Skipped install (--no-install). Run your package manager to apply the changes.\"),\n );\n return { outcome: \"updated\", updates };\n }\n\n try {\n await installDependencies();\n } catch (error) {\n console.log(\n `${colors.red(\"✖\")} The install failed. package.json is already updated — ` +\n `re-run your package manager install to finish.`,\n );\n return { outcome: \"install-failed\", updates, error: error as Error };\n }\n\n return { outcome: \"updated\", updates };\n}\n\n/**\n * Whether *every* lookup came back empty, which in practice means the\n * registry was never reached. A single failed package (unpublished, renamed,\n * private) leaves the rest resolvable and is not treated as an outage.\n */\nexport function isRegistryUnreachable(resolved: ResolvedDependency[]): boolean {\n return resolved.length > 0 && resolved.every((dependency) => !dependency.latest);\n}\n\n/** Collect every `@warlock.js/*` dependency across the relevant sections. */\nfunction collectWarlockDependencies(packageJson: PackageJson): WarlockDependency[] {\n const dependencies: WarlockDependency[] = [];\n\n for (const section of DEPENDENCY_SECTIONS) {\n const map = packageJson[section];\n\n if (!map) {\n continue;\n }\n\n for (const [name, current] of Object.entries(map)) {\n if (name.startsWith(WARLOCK_SCOPE)) {\n dependencies.push({ name, section, current });\n }\n }\n }\n\n return dependencies;\n}\n\n/** Resolve each dependency's latest version from the registry in parallel. */\nasync function resolveLatestVersions(\n dependencies: WarlockDependency[],\n): Promise<ResolvedDependency[]> {\n return Promise.all(\n dependencies.map(async (dependency) => ({\n ...dependency,\n latest: await fetchLatestVersion(dependency.name),\n })),\n );\n}\n\n/**\n * Turn resolved dependencies into the concrete set of version bumps to write.\n * Pure (no I/O) so it can be unit-tested directly: skips lookups that failed,\n * non-semver specs, and anything already at (or ahead of) the latest version,\n * and preserves the original range operator on everything it does rewrite.\n */\nexport function resolvePackageUpdates(resolved: ResolvedDependency[]): PackageUpdate[] {\n const updates: PackageUpdate[] = [];\n\n for (const dependency of resolved) {\n if (!dependency.latest) {\n continue;\n }\n\n const parsed = parseSpec(dependency.current);\n\n if (!parsed) {\n continue;\n }\n\n if (!isNewerVersion(dependency.latest, parsed.version)) {\n continue;\n }\n\n updates.push({\n name: dependency.name,\n section: dependency.section,\n from: dependency.current,\n to: `${parsed.operator}${dependency.latest}`,\n });\n }\n\n return updates;\n}\n\n/**\n * Split a dependency spec into its range operator and concrete version.\n * Returns `undefined` for specs we won't touch — `workspace:*`, `*`,\n * `latest`, multi-part ranges, or git/file URLs — leaving them exactly as\n * the author wrote them.\n */\nfunction parseSpec(spec: string): { operator: string; version: string } | undefined {\n const match = spec.trim().match(/^(\\^|~)?(\\d+\\.\\d+\\.\\d+(?:-[0-9A-Za-z.-]+)?)$/);\n\n if (!match) {\n return undefined;\n }\n\n return { operator: match[1] ?? \"\", version: match[2] };\n}\n\n/** Write the resolved bumps back into the package.json object in place. */\nfunction applyUpdates(packageJson: PackageJson, updates: PackageUpdate[]): void {\n for (const update of updates) {\n const map = packageJson[update.section];\n\n if (map) {\n map[update.name] = update.to;\n }\n }\n}\n\n/** Print the version bumps — applied, or pending on a dry run. */\nfunction printUpdates(updates: PackageUpdate[], { pending = false } = {}): void {\n const headline = pending\n ? `${colors.yellow(\"↑\")} ${colors.bold(String(updates.length))} package(s) can be updated:`\n : `${colors.green(\"✓\")} Updated ${colors.bold(String(updates.length))} package(s):`;\n\n console.log(headline);\n\n for (const update of updates) {\n console.log(\n ` ${colors.cyan(update.name)} ` +\n `${colors.dim(update.from)} ${colors.dim(\"→\")} ${colors.greenBright(update.to)}`,\n );\n }\n}\n\n/** Reconcile node_modules to the rewritten package.json via the project PM. */\nasync function installDependencies(): Promise<void> {\n const packageManager = await detectPackageManager();\n const installCommand = getInstallCommand(packageManager);\n\n console.log(`${colors.cyan(\"›\")} Running ${colors.bold(installCommand)}…`);\n\n execSync(installCommand, { cwd: process.cwd(), stdio: \"inherit\" });\n}\n"],"mappings":";;;;;;;;;;;AASA,MAAM,gBAAgB;;AAGtB,MAAM,sBAAsB,CAAC,gBAAgB,iBAAiB;;;;;;;;;;;;;;;AA0F9D,eAAsB,sBACpB,UAAwC,CAAC,GACH;CACtC,MAAM,aAAa,QAAQ,WAAW;CACtC,MAAM,kBAAkB,SAAS,cAAc;CAE/C,IAAI,CAAE,MAAM,gBAAgB,eAAe,GAAI;EAC7C,QAAQ,IAAI,GAAG,OAAO,IAAI,GAAG,EAAE,4CAA4C;EAC3E,OAAO;GAAE,SAAS;GAA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B;AACF;;AAGA,SAAS,aAAa,SAA0B,EAAE,UAAU,UAAU,CAAC,GAAS;CAC9E,MAAM,WAAW,UACb,GAAG,OAAO,OAAO,GAAG,EAAE,GAAG,OAAO,KAAK,OAAO,QAAQ,MAAM,CAAC,EAAE,+BAC7D,GAAG,OAAO,MAAM,GAAG,EAAE,WAAW,OAAO,KAAK,OAAO,QAAQ,MAAM,CAAC,EAAE;CAExE,QAAQ,IAAI,QAAQ;CAEpB,KAAK,MAAM,UAAU,SACnB,QAAQ,IACN,MAAM,OAAO,KAAK,OAAO,IAAI,EAAE,IAC1B,OAAO,IAAI,OAAO,IAAI,EAAE,GAAG,OAAO,IAAI,GAAG,EAAE,GAAG,OAAO,YAAY,OAAO,EAAE,GACjF;AAEJ;;AAGA,eAAe,sBAAqC;CAElD,MAAM,iBAAiB,kBAAkB,MADZ,qBAAqB,CACK;CAEvD,QAAQ,IAAI,GAAG,OAAO,KAAK,GAAG,EAAE,WAAW,OAAO,KAAK,cAAc,EAAE,EAAE;CAEzE,SAAS,gBAAgB;EAAE,KAAK,QAAQ,IAAI;EAAG,OAAO;CAAU,CAAC;AACnE"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-case-broadcast.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case-broadcast.ts"],"mappings":";;;;;AAkBA;;;;;;;;iBAAsB,sBAAA,SAA+B,MAAA;EACnD,IAAA;EACA,EAAA;EACA,MAAA,EAAQ,MAAA;EACR,MAAA,EAAQ,aAAA,CAAc,MAAA;EACtB,SAAA,GAAY,sBAAA,CAAuB,MAAA;EACnC,MAAA,GAAS,qBAAA;AAAA,IACP,OAAA"}
1
+ {"version":3,"file":"use-case-broadcast.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case-broadcast.ts"],"mappings":";;;;;AAkBA;;;;;;;;iBAAsB,sBAAA,QAAA,CAA+B,MAAA;EACnD,IAAA;EACA,EAAA;EACA,MAAA,EAAQ,MAAA;EACR,MAAA,EAAQ,aAAA,CAAc,MAAA;EACtB,SAAA,GAAY,sBAAA,CAAuB,MAAA;EACnC,MAAA,GAAS,qBAAA;AAAA,IACP,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-case-events.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case-events.ts"],"mappings":";;;;;AAWA;cAAa,wBAAA,EAA0B,yBAItC;;;AAAA;AASD;;;;cAAa,oBAAA;yBACY,GAAA,EAAK,yBAAA;;;sBASV,QAAA,GAAa,MAAA,EAAQ,aAAA,CAAc,MAAA;;;qBASlC,GAAA,EAAK,kBAAA;;;;;;;;;;;iBAkBJ,kBAAA,WACpB,GAAA,EAAK,QAAA,EACL,SAAA;EACE,UAAA,KAAe,GAAA,EAAK,QAAA,YAAoB,OAAA;EACxC,OAAA,KAAY,GAAA,EAAK,QAAA,YAAoB,OAAA;EACrC,MAAA,KAAW,GAAA,EAAK,QAAA,YAAoB,OAAA;AAAA,IACrC,OAAA"}
1
+ {"version":3,"file":"use-case-events.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case-events.ts"],"mappings":";;;;;AAWA;cAAa,wBAAA,EAA0B,yBAItC;;;AAAA;AASD;;;;cAAa,oBAAA;yBACY,GAAA,EAAK,yBAAA;;;sBASV,QAAA,GAAa,MAAA,EAAQ,aAAA,CAAc,MAAA;;;qBASlC,GAAA,EAAK,kBAAA;;;;;;;;;;;iBAkBJ,kBAAA,UAAA,CACpB,GAAA,EAAK,QAAA,EACL,SAAA;EACE,UAAA,KAAe,GAAA,EAAK,QAAA,YAAoB,OAAA;EACxC,OAAA,KAAY,GAAA,EAAK,QAAA,YAAoB,OAAA;EACrC,MAAA,KAAW,GAAA,EAAK,QAAA,YAAoB,OAAA;AAAA,IACrC,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-case-pipeline.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case-pipeline.ts"],"mappings":";;;;KAWY,eAAA;EACV,IAAA;EACA,EAAA;EACA,IAAA,EAAM,KAAA;EACN,GAAA,EAAK,cAAA;EACL,SAAA,EAAW,IAAA;EACX,MAAA,GAAS,eAAA;EACT,MAAA,GAAS,YAAA,CAAa,KAAA;EACtB,MAAA,GAAS,uBAAA,CAAwB,KAAA,KADX;EAGtB,WAAA,IAAe,GAAA,EAAK,yBAAA,WAFa;EAIjC,aAAA,IAAiB,GAAA,EAAK,yBAAA;AAAA;;;;;;;;;;;;;;iBAgBF,WAAA,QAAmB,IAAA,EAAM,eAAA,CAAgB,KAAA,IAAS,OAAA,CAAQ,KAAA"}
1
+ {"version":3,"file":"use-case-pipeline.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case-pipeline.ts"],"mappings":";;;;KAWY,eAAA;EACV,IAAA;EACA,EAAA;EACA,IAAA,EAAM,KAAA;EACN,GAAA,EAAK,cAAA;EACL,SAAA,EAAW,IAAA;EACX,MAAA,GAAS,eAAA;EACT,MAAA,GAAS,YAAA,CAAa,KAAA;EACtB,MAAA,GAAS,uBAAA,CAAwB,KAAA,KADX;EAGtB,WAAA,IAAe,GAAA,EAAK,yBAAA,WAFa;EAIjC,aAAA,IAAiB,GAAA,EAAK,yBAAA;AAAA;;;;;;;;;;;;;;iBAgBF,WAAA,OAAA,CAAmB,IAAA,EAAM,eAAA,CAAgB,KAAA,IAAS,OAAA,CAAQ,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-case.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case.ts"],"mappings":";;;;;;AAwDA;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,OAAA,wBAEC,eAAA,cACH,cAAA,GAAiB,cAAA,EAC7B,OAAA,EAAS,iBAAA,CAAkB,MAAA,EAAQ,MAAA,EAAQ,GAAA,IAAO,cAAA,CAAe,MAAA,EAAQ,KAAA,CAAM,MAAA;AAAA,iBACjE,OAAA,wCAA+C,cAAA,GAAiB,cAAA,EAC9E,OAAA,EAAS,OAAA,CAAQ,MAAA,EAAQ,KAAA,EAAO,GAAA,IAC/B,cAAA,CAAe,MAAA,EAAQ,KAAA"}
1
+ {"version":3,"file":"use-case.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-case.ts"],"mappings":";;;;;;AAwDA;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,OAAA,wBAEC,eAAA,cACH,cAAA,GAAiB,cAAA,CAAA,CAC7B,OAAA,EAAS,iBAAA,CAAkB,MAAA,EAAQ,MAAA,EAAQ,GAAA,IAAO,cAAA,CAAe,MAAA,EAAQ,KAAA,CAAM,MAAA;AAAA,iBACjE,OAAA,wCAA+C,cAAA,GAAiB,cAAA,CAAA,CAC9E,OAAA,EAAS,OAAA,CAAQ,MAAA,EAAQ,KAAA,EAAO,GAAA,IAC/B,cAAA,CAAe,MAAA,EAAQ,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-cases-registry.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-cases-registry.ts"],"mappings":";;;;;AAaA;iBAAgB,gBAAA,gBACd,IAAA,UACA,OAAA,EAAS,iBAAA,CAAkB,MAAA,EAAQ,KAAA;;;;;;;;iBAoBrB,kBAAA,CAAmB,IAAY;;;;;;;AApBJ;iBAmC3B,UAAA,gBAA0B,IAAA,WACJ,iBAAA,CAAkB,MAAA,EAAQ,KAAA;;;;iBAMhD,WAAA,IAAW,GAAA,SAAA,iBAAA;AAP3B;;;AAAA,iBAcgB,2BAAA,CAA4B,IAAY;;;;iBAexC,0BAAA,CAA2B,IAAY;;;;;;iBA2BjC,iBAAA,CAAkB,IAAA,WAAe,OAAO,CAAC,aAAA;;AAvDM;AAMrE;;iBA+EsB,iBAAA,CAAkB,IAAA,UAAc,MAAA,EAAQ,aAAA,QAAkB,OAAA"}
1
+ {"version":3,"file":"use-cases-registry.d.mts","names":[],"sources":["../../../../../../../core/src/use-cases/use-cases-registry.ts"],"mappings":";;;;;AAaA;iBAAgB,gBAAA,eAAA,CACd,IAAA,UACA,OAAA,EAAS,iBAAA,CAAkB,MAAA,EAAQ,KAAA;;;;;;;;iBAoBrB,kBAAA,CAAmB,IAAY;;;;;;;AApBJ;iBAmC3B,UAAA,eAAA,CAA0B,IAAA,WACJ,iBAAA,CAAkB,MAAA,EAAQ,KAAA;;;;iBAMhD,WAAA,CAAA,GAAW,GAAA,SAAA,iBAAA;AAP3B;;;AAAA,iBAcgB,2BAAA,CAA4B,IAAY;;;;iBAexC,0BAAA,CAA2B,IAAY;;;;;;iBA2BjC,iBAAA,CAAkB,IAAA,WAAe,OAAO,CAAC,aAAA;;AAvDM;AAMrE;;iBA+EsB,iBAAA,CAAkB,IAAA,UAAc,MAAA,EAAQ,aAAA,QAAkB,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-cases-registry.mjs","names":[],"sources":["../../../../../../../core/src/use-cases/use-cases-registry.ts"],"sourcesContent":["import { cache } from \"@warlock.js/cache\";\nimport { log } from \"@warlock.js/logger\";\nimport { config } from \"../config\";\nimport { RegisteredUseCase, UseCaseConfigurations, UseCaseResult } from \"./types\";\n\n/**\n * Store registered use cases\n */\nconst useCaseRegister = new Map<string, RegisteredUseCase>();\n\n/**\n * Register a use case\n */\nexport function $registerUseCase<Output, Input>(\n name: string,\n useCase: RegisteredUseCase<Output, Input>,\n) {\n if (useCaseRegister.has(name) && process.env.NODE_ENV !== \"production\") {\n log.warn(\n \"use-cases\",\n \"registering\",\n `Use case \"${name}\" is already registered. Overwriting.`,\n );\n }\n\n useCaseRegister.set(name, useCase);\n}\n\n/**\n * Unregister a use case.\n *\n * Dropping the history namespace is best-effort: `$cleanup` is synchronous, so the\n * async cache removal is fire-and-forget with a `.catch` guard — a rejecting cache\n * driver must never turn cleanup into an unhandled rejection.\n */\nexport function $unregisterUseCase(name: string) {\n useCaseRegister.delete(name);\n\n Promise.resolve(cache.removeNamespace(`use-case:history:${name}`)).catch((error) => {\n log.error(\"use-cases\", name, \"history namespace removal failed\", { error });\n });\n}\n\n/**\n * Get a use case.\n *\n * Returns the `RegisteredUseCase` shape — including the runtime `calls` counters\n * the registry actually stores — so consumers can read call stats without an\n * ad-hoc cast.\n */\nexport function getUseCase<Output, Input>(name: string) {\n return useCaseRegister.get(name) as RegisteredUseCase<Output, Input> | undefined;\n}\n\n/**\n * Get all use cases\n */\nexport function getUseCases() {\n return useCaseRegister;\n}\n\n/**\n * Increase use case success calls\n */\nexport function increaseUseCaseSuccessCalls(name: string): number {\n const useCase = useCaseRegister.get(name);\n if (useCase) {\n useCase.calls.success++;\n useCase.calls.total++;\n\n return useCase.calls.success;\n }\n\n return 0;\n}\n\n/**\n * Increase use case failed calls\n */\nexport function increaseUseCaseFailedCalls(name: string): number {\n const useCase = useCaseRegister.get(name);\n if (useCase) {\n useCase.calls.failed++;\n useCase.calls.total++;\n\n return useCase.calls.failed;\n }\n\n return 0;\n}\n\n/**\n * Resolve the history cache TTL (seconds) from config.\n * `false` means \"use the cache driver's default\", represented as `undefined`.\n */\nfunction resolveHistoryTtl(useCaseConfig?: UseCaseConfigurations): number | undefined {\n const ttlConfig = useCaseConfig?.history?.ttl ?? 3600; // 1 hour default\n\n return ttlConfig === false ? undefined : ttlConfig;\n}\n\n/**\n * Get use case history from cache.\n *\n * Prunes ids whose entries have expired so the list can't accumulate dead refs.\n */\nexport async function getUseCaseHistory(name: string): Promise<UseCaseResult<any>[]> {\n const listKey = `use-case:history:${name}:list`;\n const ids = (await cache.get<string[]>(listKey)) || [];\n\n const entries = await Promise.all(\n ids.map(async (id: string) => ({\n id,\n result: await cache.get<UseCaseResult<any>>(`use-case:history:${name}:${id}`),\n })),\n );\n\n const liveEntries = entries.filter((entry) => Boolean(entry.result));\n\n if (liveEntries.length !== ids.length) {\n const useCaseConfig = config.get<UseCaseConfigurations>(\"use-cases\");\n\n await cache.set(\n listKey,\n liveEntries.map((entry) => entry.id),\n resolveHistoryTtl(useCaseConfig),\n );\n }\n\n return liveEntries.map((entry) => entry.result) as UseCaseResult<any>[];\n}\n\n/**\n * Add use case history to cache, capping the per-use-case list so it can't grow\n * unbounded — oldest entries (and their ids) are evicted past MAX_HISTORY_ENTRIES.\n */\nexport async function addUseCaseHistory(name: string, result: UseCaseResult<any>) {\n const useCaseConfig = config.get<UseCaseConfigurations>(\"use-cases\");\n\n if (useCaseConfig?.history?.enabled === false) return;\n\n const ttl = resolveHistoryTtl(useCaseConfig);\n const maxEntries = useCaseConfig?.history?.maxEntries ?? 100;\n const key = `use-case:history:${name}:${result.id}`;\n const listKey = `use-case:history:${name}:list`;\n\n await cache.set(key, result, ttl);\n\n const list = (await cache.get<string[]>(listKey)) || [];\n\n list.push(result.id);\n\n while (list.length > maxEntries) {\n const evictedId = list.shift();\n\n if (evictedId) {\n await cache.remove(`use-case:history:${name}:${evictedId}`);\n }\n }\n\n await cache.set(listKey, list, ttl);\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,kCAAkB,IAAI,IAA+B;;;;AAK3D,SAAgB,iBACd,MACA,SACA;CACA,IAAI,gBAAgB,IAAI,IAAI,KAAK,QAAQ,IAAI,aAAa,cACxD,IAAI,KACF,aACA,eACA,aAAa,KAAK,sCACpB;CAGF,gBAAgB,IAAI,MAAM,OAAO;AACnC;;;;;;;;AASA,SAAgB,mBAAmB,MAAc;CAC/C,gBAAgB,OAAO,IAAI;CAE3B,QAAQ,QAAQ,MAAM,gBAAgB,oBAAoB,MAAM,CAAC,CAAC,CAAC,OAAO,UAAU;EAClF,IAAI,MAAM,aAAa,MAAM,oCAAoC,EAAE,MAAM,CAAC;CAC5E,CAAC;AACH;;;;;;;;AASA,SAAgB,WAA0B,MAAc;CACtD,OAAO,gBAAgB,IAAI,IAAI;AACjC;;;;AAKA,SAAgB,cAAc;CAC5B,OAAO;AACT;;;;AAKA,SAAgB,4BAA4B,MAAsB;CAChE,MAAM,UAAU,gBAAgB,IAAI,IAAI;CACxC,IAAI,SAAS;EACX,QAAQ,MAAM;EACd,QAAQ,MAAM;EAEd,OAAO,QAAQ,MAAM;CACvB;CAEA,OAAO;AACT;;;;AAKA,SAAgB,2BAA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/B,MAAM,YAAY,KAAK,MAAM;EAE7B,IAAI,WACF,MAAM,MAAM,OAAO,oBAAoB,KAAK,GAAG,WAAW;CAE9D;CAEA,MAAM,MAAM,IAAI,SAAS,MAAM,GAAG;AACpC"}
1
+ {"version":3,"file":"use-cases-registry.mjs","names":[],"sources":["../../../../../../../core/src/use-cases/use-cases-registry.ts"],"sourcesContent":["import { cache } from \"@warlock.js/cache\";\nimport { log } from \"@warlock.js/logger\";\nimport { config } from \"../config\";\nimport { type RegisteredUseCase, type UseCaseConfigurations, type UseCaseResult } from \"./types\";\n\n/**\n * Store registered use cases\n */\nconst useCaseRegister = new Map<string, RegisteredUseCase>();\n\n/**\n * Register a use case\n */\nexport function $registerUseCase<Output, Input>(\n name: string,\n useCase: RegisteredUseCase<Output, Input>,\n) {\n if (useCaseRegister.has(name) && process.env.NODE_ENV !== \"production\") {\n log.warn(\n \"use-cases\",\n \"registering\",\n `Use case \"${name}\" is already registered. Overwriting.`,\n );\n }\n\n useCaseRegister.set(name, useCase);\n}\n\n/**\n * Unregister a use case.\n *\n * Dropping the history namespace is best-effort: `$cleanup` is synchronous, so the\n * async cache removal is fire-and-forget with a `.catch` guard — a rejecting cache\n * driver must never turn cleanup into an unhandled rejection.\n */\nexport function $unregisterUseCase(name: string) {\n useCaseRegister.delete(name);\n\n Promise.resolve(cache.removeNamespace(`use-case:history:${name}`)).catch((error) => {\n log.error(\"use-cases\", name, \"history namespace removal failed\", { error });\n });\n}\n\n/**\n * Get a use case.\n *\n * Returns the `RegisteredUseCase` shape — including the runtime `calls` counters\n * the registry actually stores — so consumers can read call stats without an\n * ad-hoc cast.\n */\nexport function getUseCase<Output, Input>(name: string) {\n return useCaseRegister.get(name) as RegisteredUseCase<Output, Input> | undefined;\n}\n\n/**\n * Get all use cases\n */\nexport function getUseCases() {\n return useCaseRegister;\n}\n\n/**\n * Increase use case success calls\n */\nexport function increaseUseCaseSuccessCalls(name: string): number {\n const useCase = useCaseRegister.get(name);\n if (useCase) {\n useCase.calls.success++;\n useCase.calls.total++;\n\n return useCase.calls.success;\n }\n\n return 0;\n}\n\n/**\n * Increase use case failed calls\n */\nexport function increaseUseCaseFailedCalls(name: string): number {\n const useCase = useCaseRegister.get(name);\n if (useCase) {\n useCase.calls.failed++;\n useCase.calls.total++;\n\n return useCase.calls.failed;\n }\n\n return 0;\n}\n\n/**\n * Resolve the history cache TTL (seconds) from config.\n * `false` means \"use the cache driver's default\", represented as `undefined`.\n */\nfunction resolveHistoryTtl(useCaseConfig?: UseCaseConfigurations): number | undefined {\n const ttlConfig = useCaseConfig?.history?.ttl ?? 3600; // 1 hour default\n\n return ttlConfig === false ? undefined : ttlConfig;\n}\n\n/**\n * Get use case history from cache.\n *\n * Prunes ids whose entries have expired so the list can't accumulate dead refs.\n */\nexport async function getUseCaseHistory(name: string): Promise<UseCaseResult<any>[]> {\n const listKey = `use-case:history:${name}:list`;\n const ids = (await cache.get<string[]>(listKey)) || [];\n\n const entries = await Promise.all(\n ids.map(async (id: string) => ({\n id,\n result: await cache.get<UseCaseResult<any>>(`use-case:history:${name}:${id}`),\n })),\n );\n\n const liveEntries = entries.filter((entry) => Boolean(entry.result));\n\n if (liveEntries.length !== ids.length) {\n const useCaseConfig = config.get<UseCaseConfigurations>(\"use-cases\");\n\n await cache.set(\n listKey,\n liveEntries.map((entry) => entry.id),\n resolveHistoryTtl(useCaseConfig),\n );\n }\n\n return liveEntries.map((entry) => entry.result) as UseCaseResult<any>[];\n}\n\n/**\n * Add use case history to cache, capping the per-use-case list so it can't grow\n * unbounded — oldest entries (and their ids) are evicted past MAX_HISTORY_ENTRIES.\n */\nexport async function addUseCaseHistory(name: string, result: UseCaseResult<any>) {\n const useCaseConfig = config.get<UseCaseConfigurations>(\"use-cases\");\n\n if (useCaseConfig?.history?.enabled === false) return;\n\n const ttl = resolveHistoryTtl(useCaseConfig);\n const maxEntries = useCaseConfig?.history?.maxEntries ?? 100;\n const key = `use-case:history:${name}:${result.id}`;\n const listKey = `use-case:history:${name}:list`;\n\n await cache.set(key, result, ttl);\n\n const list = (await cache.get<string[]>(listKey)) || [];\n\n list.push(result.id);\n\n while (list.length > maxEntries) {\n const evictedId = list.shift();\n\n if (evictedId) {\n await cache.remove(`use-case:history:${name}:${evictedId}`);\n }\n }\n\n await cache.set(listKey, list, ttl);\n}\n"],"mappings":";;;;;;;;;AAQA,MAAM,kCAAkB,IAAI,IAA+B;;;;AAK3D,SAAgB,iBACd,MACA,SACA;CACA,IAAI,gBAAgB,IAAI,IAAI,KAAK,QAAQ,IAAI,aAAa,cACxD,IAAI,KACF,aACA,eACA,aAAa,KAAK,sCACpB;CAGF,gBAAgB,IAAI,MAAM,OAAO;AACnC;;;;;;;;AASA,SAAgB,mBAAmB,MAAc;CAC/C,gBAAgB,OAAO,IAAI;CAE3B,QAAQ,QAAQ,MAAM,gBAAgB,oBAAoB,MAAM,CAAC,EAAE,OAAO,UAAU;EAClF,IAAI,MAAM,aAAa,MAAM,oCAAoC,EAAE,MAAM,CAAC;CAC5E,CAAC;AACH;;;;;;;;AASA,SAAgB,WAA0B,MAAc;CACtD,OAAO,gBAAgB,IAAI,IAAI;AACjC;;;;AAKA,SAAgB,cAAc;CAC5B,OAAO;AACT;;;;AAKA,SAAgB,4BAA4B,MAAsB;CAChE,MAAM,UAAU,gBAAgB,IAAI,IAAI;CACxC,IAAI,SAAS;EACX,QAAQ,MAAM;EACd,QAAQ,MAAM;EAEd,OAAO,QAAQ,MAAM;CACvB;CAEA,OAAO;AACT;;;;AAKA,SAAgB,2BAA2B,MAAsB;CAC/D,MAAM,UAAU,gBAAgB,IAAI,IAAI;CACxC,IAAI,SAAS;EACX,QAAQ,MAAM;EACd,QAAQ,MAAM;EAEd,OAAO,QAAQ,MAAM;CACvB;CAEA,OAAO;AACT;;;;;AAMA,SAAS,kBAAkB,eAA2D;CACpF,MAAM,YAAY,eAAe,SAAS,OAAO;CAEjD,OAAO,cAAc,QAAQ,SAAY;AAC3C;;;;;;AAOA,eAAsB,kBAAkB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gBAAgB;AAAA;AAAA,cAGpB,WAAA,SAAoB,UAAA,CAAW,kBAAA,aAA+B,WAAA;EAHzE;;;EAOO,IAAA;EAJI;;;EAAA,IASA,KAAA,IAAS,UAAA,CAAW,KAAA;EAAA;;;EAOlB,GAAA,CAAI,GAAA,EAAK,WAAA,GAAW,OAAA;AAAA"}
1
+ {"version":3,"file":"database-log.d.mts","names":[],"sources":["../../../../../../../core/src/utils/database-log.ts"],"mappings":";;;;;KAKY,kBAAA,GAAqB,sBAAA;;AAAjC;;EAIE,KAAA,UAAe,gBAAgB;AAAA;AAAA,cAGpB,WAAA,SAAoB,UAAA,CAAW,kBAAA,aAA+B,WAAA;EAHzE;;;EAOO,IAAA;EAJI;;;EAAA,IASA,KAAA,CAAA,GAAS,UAAA,CAAW,KAAA;EAAA;;;EAOlB,GAAA,CAAI,GAAA,EAAK,WAAA,GAAW,OAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"database-log.mjs","names":[],"sources":["../../../../../../../core/src/utils/database-log.ts"],"sourcesContent":["import type { ChildModel, Model } from \"@warlock.js/cascade\";\nimport type { BasicLogConfigurations, LoggingData } from \"@warlock.js/logger\";\nimport { LogChannel, type LogContract, type LogMessage } from \"@warlock.js/logger\";\nimport { DatabaseLogModel } from \"../database/models/database-log\";\n\nexport type DatabaseLogOptions = BasicLogConfigurations & {\n /**\n * Model to use for logging\n */\n model?: typeof DatabaseLogModel;\n};\n\nexport class DatabaseLog extends LogChannel<DatabaseLogOptions> implements LogContract {\n /**\n * {@inheritdoc}\n */\n public name = \"database\";\n\n /**\n * Database model\n */\n public get model(): ChildModel<Model> {\n return this.config(\"model\") ?? DatabaseLogModel;\n }\n\n /**\n * {@inheritdoc}\n */\n public async log(log: LoggingData) {\n const { module, action, message, type: level } = log;\n\n if (!this.model.getDataSource().driver?.isConnected) return;\n\n if (!this.shouldBeLogged(log)) return;\n\n const data: LogMessage = {\n module,\n action,\n content: message,\n level,\n date: new Date().toISOString(),\n };\n\n if (message instanceof Error) {\n data.stack = message.stack;\n data.content = message.message;\n } else {\n data.content = message;\n data.stack = new Error().stack;\n }\n\n try {\n await this.model.create(data);\n } catch (error) {\n console.log(\"Error\", error);\n }\n }\n}\n"],"mappings":";;;;;AAYA,IAAa,cAAb,cAAiC,WAAsD;;;cAIvE;;;;;CAKd,IAAW,QAA2B;EACpC,OAAO,KAAK,OAAO,OAAO,KAAK;CACjC;;;;CAKA,MAAa,IAAI,KAAkB;EACjC,MAAM,EAAE,QAAQ,QAAQ,SAAS,MAAM,UAAU;EAEjD,IAAI,CAAC,KAAK,MAAM,cAAc,CAAC,CAAC,QAAQ,aAAa;EAErD,IAAI,CAAC,KAAK,eAAe,GAAG,GAAG;EAE/B,MAAM,OAAmB;GACvB;GACA;GACA,SAAS;GACT;GACA,uBAAM,IAAI,KAAK,EAAC,CAAC,YAAY;EAC/B;EAEA,IAAI,mBAAmB,OAAO;GAC5B,KAAK,QAAQ,QAAQ;GACrB,KAAK,UAAU,QAAQ;EACzB,OAAO;GACL,KAAK,UAAU;GACf,KAAK,yBAAQ,IAAI,MAAM,EAAC,CAAC;EAC3B;EAEA,IAAI;GACF,MAAM,KAAK,MAAM,OAAO,IAAI;EAC9B,SAAS,OAAO;GACd,QAAQ,IAAI,SAAS,KAAK;EAC5B;CACF;AACF"}
1
+ {"version":3,"file":"database-log.mjs","names":[],"sources":["../../../../../../../core/src/utils/database-log.ts"],"sourcesContent":["import type { ChildModel, Model } from \"@warlock.js/cascade\";\nimport type { BasicLogConfigurations, LoggingData } from \"@warlock.js/logger\";\nimport { LogChannel, type LogContract, type LogMessage } from \"@warlock.js/logger\";\nimport { DatabaseLogModel } from \"../database/models/database-log\";\n\nexport type DatabaseLogOptions = BasicLogConfigurations & {\n /**\n * Model to use for logging\n */\n model?: typeof DatabaseLogModel;\n};\n\nexport class DatabaseLog extends LogChannel<DatabaseLogOptions> implements LogContract {\n /**\n * {@inheritdoc}\n */\n public name = \"database\";\n\n /**\n * Database model\n */\n public get model(): ChildModel<Model> {\n return this.config(\"model\") ?? DatabaseLogModel;\n }\n\n /**\n * {@inheritdoc}\n */\n public async log(log: LoggingData) {\n const { module, action, message, type: level } = log;\n\n if (!this.model.getDataSource().driver?.isConnected) return;\n\n if (!this.shouldBeLogged(log)) return;\n\n const data: LogMessage = {\n module,\n action,\n content: message,\n level,\n date: new Date().toISOString(),\n };\n\n if (message instanceof Error) {\n data.stack = message.stack;\n data.content = message.message;\n } else {\n data.content = message;\n data.stack = new Error().stack;\n }\n\n try {\n await this.model.create(data);\n } catch (error) {\n console.log(\"Error\", error);\n }\n }\n}\n"],"mappings":";;;;;AAYA,IAAa,cAAb,cAAiC,WAAsD;;;cAIvE;;;;;CAKd,IAAW,QAA2B;EACpC,OAAO,KAAK,OAAO,OAAO,KAAK;CACjC;;;;CAKA,MAAa,IAAI,KAAkB;EACjC,MAAM,EAAE,QAAQ,QAAQ,SAAS,MAAM,UAAU;EAEjD,IAAI,CAAC,KAAK,MAAM,cAAc,EAAE,QAAQ,aAAa;EAErD,IAAI,CAAC,KAAK,eAAe,GAAG,GAAG;EAE/B,MAAM,OAAmB;GACvB;GACA;GACA,SAAS;GACT;GACA,uBAAM,IAAI,KAAK,GAAE,YAAY;EAC/B;EAEA,IAAI,mBAAmB,OAAO;GAC5B,KAAK,QAAQ,QAAQ;GACrB,KAAK,UAAU,QAAQ;EACzB,OAAO;GACL,KAAK,UAAU;GACf,KAAK,yBAAQ,IAAI,MAAM,GAAE;EAC3B;EAEA,IAAI;GACF,MAAM,KAAK,MAAM,OAAO,IAAI;EAC9B,SAAS,OAAO;GACd,QAAQ,IAAI,SAAS,KAAK;EAC5B;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"environment.d.mts","names":[],"sources":["../../../../../../../core/src/utils/environment.ts"],"mappings":";KAAY,WAAA;AAAZ;;;;AAAA,KAMY,eAAA;AAAA,iBAEI,WAAA,IAAe,WAAW;AAAA,iBAI1B,cAAA,CAAe,GAAgB,EAAX,WAAW"}
1
+ {"version":3,"file":"environment.d.mts","names":[],"sources":["../../../../../../../core/src/utils/environment.ts"],"mappings":";KAAY,WAAA;AAAZ;;;;AAAA,KAMY,eAAA;AAAA,iBAEI,WAAA,CAAA,GAAe,WAAW;AAAA,iBAI1B,cAAA,CAAe,GAAgB,EAAX,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"framework-vesion.mjs","names":[],"sources":["../../../../../../../core/src/utils/framework-vesion.ts"],"sourcesContent":["import { getJsonFileAsync } from \"@warlock.js/fs\";\r\nimport path from \"node:path\";\r\n\r\n/**\r\n * Cached version string\r\n */\r\nlet cachedVersion: string | null = null;\r\n\r\n/**\r\n * Get the framework version from package.json (cached)\r\n */\r\nexport async function getWarlockVersion(): Promise<string> {\r\n if (cachedVersion) return cachedVersion;\r\n\r\n const frameworkPackageJson = (await getJsonFileAsync(\r\n path.join(import.meta.dirname, \"./../../package.json\"),\r\n )) as { version: string };\r\n\r\n const version = frameworkPackageJson.version.replace(/\\^|\\~/g, \"\");\r\n cachedVersion = version;\r\n return version;\r\n}\r\n\r\nexport function getFrameworkVersion(): string | null {\r\n return cachedVersion;\r\n}\r\n"],"mappings":";;;;;;;AAMA,IAAI,gBAA+B;;;;AAKnC,eAAsB,oBAAqC;CACzD,IAAI,eAAe,OAAO;CAM1B,MAAM,WAAU,MAJoB,iBAClC,KAAK,KAAK,OAAO,KAAK,SAAS,sBAAsB,CACvD,EAEoC,CAAC,QAAQ,QAAQ,UAAU,EAAE;CACjE,gBAAgB;CAChB,OAAO;AACT;AAEA,SAAgB,sBAAqC;CACnD,OAAO;AACT"}
1
+ {"version":3,"file":"framework-vesion.mjs","names":[],"sources":["../../../../../../../core/src/utils/framework-vesion.ts"],"sourcesContent":["import { getJsonFileAsync } from \"@warlock.js/fs\";\r\nimport path from \"node:path\";\r\n\r\n/**\r\n * Cached version string\r\n */\r\nlet cachedVersion: string | null = null;\r\n\r\n/**\r\n * Get the framework version from package.json (cached)\r\n */\r\nexport async function getWarlockVersion(): Promise<string> {\r\n if (cachedVersion) return cachedVersion;\r\n\r\n const frameworkPackageJson = (await getJsonFileAsync(\r\n path.join(import.meta.dirname, \"./../../package.json\"),\r\n )) as { version: string };\r\n\r\n const version = frameworkPackageJson.version.replace(/\\^|\\~/g, \"\");\r\n cachedVersion = version;\r\n return version;\r\n}\r\n\r\nexport function getFrameworkVersion(): string | null {\r\n return cachedVersion;\r\n}\r\n"],"mappings":";;;;;;;AAMA,IAAI,gBAA+B;;;;AAKnC,eAAsB,oBAAqC;CACzD,IAAI,eAAe,OAAO;CAM1B,MAAM,WAAU,MAJoB,iBAClC,KAAK,KAAK,OAAO,KAAK,SAAS,sBAAsB,CACvD,GAEqC,QAAQ,QAAQ,UAAU,EAAE;CACjE,gBAAgB;CAChB,OAAO;AACT;AAEA,SAAgB,sBAAqC;CACnD,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"get-localized.mjs","names":[],"sources":["../../../../../../../core/src/utils/get-localized.ts"],"sourcesContent":["import { useRequestStore } from \"../http/context/request-context\";\n\nexport type LocalizedObject = {\n localeCode: string;\n value: any;\n};\n\n/**\n * Get localized value based on the given locale code\n * If the locale code is not given and the function is called within a request context, it will get the current locale code\n */\nexport function getLocalized(values: LocalizedObject[], localeCode?: string, key = \"value\") {\n if (!values) return values;\n\n if (!localeCode) {\n localeCode = useRequestStore().request?.getLocaleCode();\n }\n\n if (Array.isArray(values)) {\n return values.find((value) => value.localeCode === localeCode)?.[key as keyof LocalizedObject];\n }\n\n return values;\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,aAAa,QAA2B,YAAqB,MAAM,SAAS;CAC1F,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,CAAC,YACH,aAAa,gBAAgB,CAAC,CAAC,SAAS,cAAc;CAGxD,IAAI,MAAM,QAAQ,MAAM,GACtB,OAAO,OAAO,MAAM,UAAU,MAAM,eAAe,UAAU,CAAC,GAAG;CAGnE,OAAO;AACT"}
1
+ {"version":3,"file":"get-localized.mjs","names":[],"sources":["../../../../../../../core/src/utils/get-localized.ts"],"sourcesContent":["import { useRequestStore } from \"../http/context/request-context\";\n\nexport type LocalizedObject = {\n localeCode: string;\n value: any;\n};\n\n/**\n * Get localized value based on the given locale code\n * If the locale code is not given and the function is called within a request context, it will get the current locale code\n */\nexport function getLocalized(values: LocalizedObject[], localeCode?: string, key = \"value\") {\n if (!values) return values;\n\n if (!localeCode) {\n localeCode = useRequestStore().request?.getLocaleCode();\n }\n\n if (Array.isArray(values)) {\n return values.find((value) => value.localeCode === localeCode)?.[key as keyof LocalizedObject];\n }\n\n return values;\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,aAAa,QAA2B,YAAqB,MAAM,SAAS;CAC1F,IAAI,CAAC,QAAQ,OAAO;CAEpB,IAAI,CAAC,YACH,aAAa,gBAAgB,EAAE,SAAS,cAAc;CAGxD,IAAI,MAAM,QAAQ,MAAM,GACtB,OAAO,OAAO,MAAM,UAAU,MAAM,eAAe,UAAU,IAAI;CAGnE,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"load-environment.mjs","names":[],"sources":["../../../../../../../core/src/utils/load-environment.ts"],"sourcesContent":["import { loadEnv, type EnvLoaderOptions } from \"@mongez/dotenv\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Core's env precedence policy, in one place because two callers load env:\n * this module at boot, and the dev server when an `.env` file changes.\n *\n * `@mongez/dotenv` defaults to `precedence: \"file-wins\"`, which is backwards.\n * The `.env` file is a checked-in DEFAULT; a variable already exported into\n * `process.env` is the deliberate, situational override — a second instance on\n * another port, CI pointed at another database, a container's configuration.\n * Under the default, `PORT=6060 warlock dev` produced a server on the `.env`\n * file's 3000 and said nothing. A default that silently beats an explicit\n * instruction is the wrong way round, so core opts into `process-wins`:\n * the file supplies only the keys the environment does not already carry.\n *\n * EMPTY STRING — `FOO=` in the environment counts as SET, and wins, so the\n * file's value is discarded and `env(\"FOO\")` returns `\"\"`. Chosen over\n * \"empty means absent\" because the loader cannot tell a deliberate blanking\n * from an accident, and only one of the two readings is expressible: an\n * operator who wants the file's value can unset the variable, whereas under\n * \"empty means absent\" an operator who wants a blank value has no way to ask\n * for one. It also matches POSIX (an exported empty variable is set), dotenv,\n * dotenv-flow and Vite. Note the consequence: a blank export beats the second\n * argument too, so `env(\"FOO\", \"fallback\")` yields `\"\"`, not the fallback.\n *\n * Keys this loader itself wrote are tracked by the library and are NOT treated\n * as process-provided, so editing `.env` during a dev session still takes\n * effect on reload rather than being pinned by the previous load's own writes.\n */\nexport const environmentLoaderOptions: EnvLoaderOptions = {\n precedence: \"process-wins\",\n};\n\n/**\n * The files `loadEnv()` will look for, in the order it considers them.\n *\n * Mirrors `@mongez/dotenv`'s own resolution — `.env.shared` first, then\n * `.env.<NODE_ENV>` if it exists, else plain `.env` — because the presence\n * check has to ask the same question the loader is about to ask.\n */\nfunction candidateEnvFiles(directory: string): string[] {\n const files = [path.join(directory, \".env\"), path.join(directory, \".env.shared\")];\n\n if (process.env.NODE_ENV) {\n files.push(path.join(directory, `.env.${process.env.NODE_ENV}`));\n }\n\n return files;\n}\n\n/**\n * Whether this process has already loaded its env files.\n *\n * Two callers reach here on a bootstrapping command — the CLI preload phase and\n * `bootstrap()` — and `loadEnv()` defaults to `override: true`, so a second pass\n * re-parses the same files and re-writes `process.env`. Anything set in between\n * (a `warlock.config.ts` module body, a config file, an orchestrator) would be\n * silently clobbered by the later load. Same shape as the defect where a\n * caller's test-server port was overwritten by a re-read of `.env`.\n *\n * A deliberate reload is still possible and still used: the dev server calls\n * `loadEnv()` directly when an `.env` file changes on disk, which is a reload\n * the user asked for rather than an accidental second pass.\n */\nlet environmentLoaded = false;\n\n/**\n * Load `.env` files when there are any, and do nothing when there are not.\n *\n * Loads at most **once per process** — see {@link environmentLoaded}.\n *\n * `@mongez/dotenv`'s `loadEnvFile` **throws** when the file is absent. That was\n * survivable while only `dev` loaded env; now that every command loads it —\n * because `warlock.config.ts` calls `env()` in its module body and had been\n * evaluated against an empty store under every command — an unguarded call\n * would turn \"this project has no .env\" from a non-event into a hard failure\n * of `warlock build`. A project without a `.env` is legitimate: config files\n * carry defaults, and containers inject their own variables.\n *\n * The guard lives here rather than waiting on a fix in `@mongez/dotenv`: core\n * decides its own env policy and must not depend on another package's release\n * schedule to avoid crashing a working build.\n */\nexport async function loadEnvironmentFiles(directory: string = process.cwd()): Promise<void> {\n if (environmentLoaded) {\n return;\n }\n\n const hasEnvFile = candidateEnvFiles(directory).some((file) => existsSync(file));\n\n if (!hasEnvFile) {\n // Not latched: a project may create its `.env` between a command's preload\n // and its bootstrap, and there is nothing to protect from a second override\n // when the first pass loaded nothing.\n return;\n }\n\n environmentLoaded = true;\n\n // `dir` has to be forwarded: `loadEnv()` defaults it to `process.cwd()`, so\n // without this the existence check above asks about `directory` while the\n // load itself reads somewhere else entirely. Identical in production, where\n // `directory` IS `process.cwd()`.\n await loadEnv(undefined, { ...environmentLoaderOptions, dir: directory });\n}\n\n/**\n * Forget that env has been loaded, so the next call loads again.\n *\n * @internal For tests, which run many boots inside one process.\n */\nexport function resetLoadedEnvironment(): void {\n environmentLoaded = false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,2BAA6C,EACxD,YAAY,eACd;;;;;;;;AASA,SAAS,kBAAkB,WAA6B;CACtD,MAAM,QAAQ,CAAC,KAAK,KAAK,WAAW,MAAM,GAAG,KAAK,KAAK,WAAW,aAAa,CAAC;CAEhF,IAAI,QAAQ,IAAI,UACd,MAAM,KAAK,KAAK,KAAK,WAAW,QAAQ,QAAQ,IAAI,UAAU,CAAC;CAGjE,OAAO;AACT;;;;;;;;;;;;;;;AAgBA,IAAI,oBAAoB;;;;;;;;;;;;;;;;;;AAmBxB,eAAsB,qBAAqB,YAAoB,QAAQ,IAAI,GAAkB;CAC3F,IAAI,mBACF;CAKF,IAAI,CAFe,kBAAkB,SAAS,CAAC,CAAC,MAAM,SAAS,WAAW,IAAI,CAEhE,GAIZ;CAGF,oBAAoB;CAMpB,MAAM,QAAQ,QAAW;EAAE,GAAG;EAA0B,KAAK;CAAU,CAAC;AAC1E"}
1
+ {"version":3,"file":"load-environment.mjs","names":[],"sources":["../../../../../../../core/src/utils/load-environment.ts"],"sourcesContent":["import { loadEnv, type EnvLoaderOptions } from \"@mongez/dotenv\";\nimport { existsSync } from \"node:fs\";\nimport path from \"node:path\";\n\n/**\n * Core's env precedence policy, in one place because two callers load env:\n * this module at boot, and the dev server when an `.env` file changes.\n *\n * `@mongez/dotenv` defaults to `precedence: \"file-wins\"`, which is backwards.\n * The `.env` file is a checked-in DEFAULT; a variable already exported into\n * `process.env` is the deliberate, situational override — a second instance on\n * another port, CI pointed at another database, a container's configuration.\n * Under the default, `PORT=6060 warlock dev` produced a server on the `.env`\n * file's 3000 and said nothing. A default that silently beats an explicit\n * instruction is the wrong way round, so core opts into `process-wins`:\n * the file supplies only the keys the environment does not already carry.\n *\n * EMPTY STRING — `FOO=` in the environment counts as SET, and wins, so the\n * file's value is discarded and `env(\"FOO\")` returns `\"\"`. Chosen over\n * \"empty means absent\" because the loader cannot tell a deliberate blanking\n * from an accident, and only one of the two readings is expressible: an\n * operator who wants the file's value can unset the variable, whereas under\n * \"empty means absent\" an operator who wants a blank value has no way to ask\n * for one. It also matches POSIX (an exported empty variable is set), dotenv,\n * dotenv-flow and Vite. Note the consequence: a blank export beats the second\n * argument too, so `env(\"FOO\", \"fallback\")` yields `\"\"`, not the fallback.\n *\n * Keys this loader itself wrote are tracked by the library and are NOT treated\n * as process-provided, so editing `.env` during a dev session still takes\n * effect on reload rather than being pinned by the previous load's own writes.\n */\nexport const environmentLoaderOptions: EnvLoaderOptions = {\n precedence: \"process-wins\",\n};\n\n/**\n * The files `loadEnv()` will look for, in the order it considers them.\n *\n * Mirrors `@mongez/dotenv`'s own resolution — `.env.shared` first, then\n * `.env.<NODE_ENV>` if it exists, else plain `.env` — because the presence\n * check has to ask the same question the loader is about to ask.\n */\nfunction candidateEnvFiles(directory: string): string[] {\n const files = [path.join(directory, \".env\"), path.join(directory, \".env.shared\")];\n\n if (process.env.NODE_ENV) {\n files.push(path.join(directory, `.env.${process.env.NODE_ENV}`));\n }\n\n return files;\n}\n\n/**\n * Whether this process has already loaded its env files.\n *\n * Two callers reach here on a bootstrapping command — the CLI preload phase and\n * `bootstrap()` — and `loadEnv()` defaults to `override: true`, so a second pass\n * re-parses the same files and re-writes `process.env`. Anything set in between\n * (a `warlock.config.ts` module body, a config file, an orchestrator) would be\n * silently clobbered by the later load. Same shape as the defect where a\n * caller's test-server port was overwritten by a re-read of `.env`.\n *\n * A deliberate reload is still possible and still used: the dev server calls\n * `loadEnv()` directly when an `.env` file changes on disk, which is a reload\n * the user asked for rather than an accidental second pass.\n */\nlet environmentLoaded = false;\n\n/**\n * Load `.env` files when there are any, and do nothing when there are not.\n *\n * Loads at most **once per process** — see {@link environmentLoaded}.\n *\n * `@mongez/dotenv`'s `loadEnvFile` **throws** when the file is absent. That was\n * survivable while only `dev` loaded env; now that every command loads it —\n * because `warlock.config.ts` calls `env()` in its module body and had been\n * evaluated against an empty store under every command — an unguarded call\n * would turn \"this project has no .env\" from a non-event into a hard failure\n * of `warlock build`. A project without a `.env` is legitimate: config files\n * carry defaults, and containers inject their own variables.\n *\n * The guard lives here rather than waiting on a fix in `@mongez/dotenv`: core\n * decides its own env policy and must not depend on another package's release\n * schedule to avoid crashing a working build.\n */\nexport async function loadEnvironmentFiles(directory: string = process.cwd()): Promise<void> {\n if (environmentLoaded) {\n return;\n }\n\n const hasEnvFile = candidateEnvFiles(directory).some((file) => existsSync(file));\n\n if (!hasEnvFile) {\n // Not latched: a project may create its `.env` between a command's preload\n // and its bootstrap, and there is nothing to protect from a second override\n // when the first pass loaded nothing.\n return;\n }\n\n environmentLoaded = true;\n\n // `dir` has to be forwarded: `loadEnv()` defaults it to `process.cwd()`, so\n // without this the existence check above asks about `directory` while the\n // load itself reads somewhere else entirely. Identical in production, where\n // `directory` IS `process.cwd()`.\n await loadEnv(undefined, { ...environmentLoaderOptions, dir: directory });\n}\n\n/**\n * Forget that env has been loaded, so the next call loads again.\n *\n * @internal For tests, which run many boots inside one process.\n */\nexport function resetLoadedEnvironment(): void {\n environmentLoaded = false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,2BAA6C,EACxD,YAAY,eACd;;;;;;;;AASA,SAAS,kBAAkB,WAA6B;CACtD,MAAM,QAAQ,CAAC,KAAK,KAAK,WAAW,MAAM,GAAG,KAAK,KAAK,WAAW,aAAa,CAAC;CAEhF,IAAI,QAAQ,IAAI,UACd,MAAM,KAAK,KAAK,KAAK,WAAW,QAAQ,QAAQ,IAAI,UAAU,CAAC;CAGjE,OAAO;AACT;;;;;;;;;;;;;;;AAgBA,IAAI,oBAAoB;;;;;;;;;;;;;;;;;;AAmBxB,eAAsB,qBAAqB,YAAoB,QAAQ,IAAI,GAAkB;CAC3F,IAAI,mBACF;CAKF,IAAI,CAFe,kBAAkB,SAAS,EAAE,MAAM,SAAS,WAAW,IAAI,CAEhE,GAIZ;CAGF,oBAAoB;CAMpB,MAAM,QAAQ,QAAW;EAAE,GAAG;EAA0B,KAAK;CAAU,CAAC;AAC1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"normalized-path.d.mts","names":[],"sources":["../../../../../../../core/src/utils/normalized-path.ts"],"mappings":";;AAeA;;;;;;;;;;;;cAAa,IAAA;EAgCa;;;EAAA,OA5BV,UAAA,CAAW,YAAA;EA0CH;;;EAAA,OAnCR,QAAA,CAAS,YAAA;EAiDT;;;EAAA,OA1CA,oBAAA,CAAqB,YAAA;;;;SAOrB,UAAA,CAAW,YAAA;;;;SAOX,SAAA,CAAU,QAAA;;;;SAOV,IAAA,IAAQ,KAAA;;;;SAOR,OAAA,CAAQ,QAAA;;;;SAOR,QAAA,CAAS,QAAA,UAAkB,GAAA;;;;SAO3B,OAAA,CAAQ,QAAA;AAAA"}
1
+ {"version":3,"file":"normalized-path.d.mts","names":[],"sources":["../../../../../../../core/src/utils/normalized-path.ts"],"mappings":";;AAeA;;;;;;;;;;;;cAAa,IAAA;EAgCa;;;EAAA,OA5BV,UAAA,CAAW,YAAA;EA0CH;;;EAAA,OAnCR,QAAA,CAAS,YAAA;EAiDT;;;EAAA,OA1CA,oBAAA,CAAqB,YAAA;;;;SAOrB,UAAA,CAAW,YAAA;;;;SAOX,SAAA,CAAU,QAAA;;;;SAOV,IAAA,CAAA,GAAQ,KAAA;;;;SAOR,OAAA,CAAQ,QAAA;;;;SAOR,QAAA,CAAS,QAAA,UAAkB,GAAA;;;;SAO3B,OAAA,CAAQ,QAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"paths.d.mts","names":[],"sources":["../../../../../../../core/src/utils/paths.ts"],"mappings":";;AAMA;;iBAAgB,QAAA,IAAY,KAAK;;AAAA;AAOjC;iBAAgB,OAAA,IAAW,KAAK;;;AAAA;AAShC;;iBAAgB,WAAA,CAAY,YAAiB;;AAAA;AAS7C;;;iBAAgB,WAAA,CAAY,YAAiB;AAAA;AAgB7C;;;;AAhB6C,iBAgB7B,UAAA,CAAW,YAAiB;AAS5C;;;;AAA2C;AAA3C,iBAAgB,SAAA,CAAU,YAAiB;;;;iBAO3B,OAAA,CAAQ,YAAiB;AAOzC;;;AAAA,iBAAgB,QAAA,CAAS,YAAiB;AAAA;AAO1C;;AAP0C,iBAO1B,QAAA,CAAS,YAAiB;AAAA,iBAS1B,YAAA,CAAa,QAAgB;AATH;AAS1C;;;AAT0C,iBAiB1B,WAAA,IAAe,IAAI;AARU;AAQ7C;;AAR6C,iBAe7B,UAAA,IAAc,IAAI;AAAA,cAIrB,KAAA"}
1
+ {"version":3,"file":"paths.d.mts","names":[],"sources":["../../../../../../../core/src/utils/paths.ts"],"mappings":";;AAMA;;iBAAgB,QAAA,CAAA,GAAY,KAAK;;AAAA;AAOjC;iBAAgB,OAAA,CAAA,GAAW,KAAK;;;AAAA;AAShC;;iBAAgB,WAAA,CAAY,YAAiB;;AAAA;AAS7C;;;iBAAgB,WAAA,CAAY,YAAiB;AAAA;AAgB7C;;;;AAhB6C,iBAgB7B,UAAA,CAAW,YAAiB;AAS5C;;;;AAA2C;AAA3C,iBAAgB,SAAA,CAAU,YAAiB;;;;iBAO3B,OAAA,CAAQ,YAAiB;AAOzC;;;AAAA,iBAAgB,QAAA,CAAS,YAAiB;AAAA;AAO1C;;AAP0C,iBAO1B,QAAA,CAAS,YAAiB;AAAA,iBAS1B,YAAA,CAAa,QAAgB;AATH;AAS1C;;;AAT0C,iBAiB1B,WAAA,CAAA,GAAe,IAAI;AARU;AAQ7C;;AAR6C,iBAe7B,UAAA,CAAA,GAAc,IAAI;AAAA,cAIrB,KAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"promise-all-object.d.mts","names":[],"sources":["../../../../../../../core/src/utils/promise-all-object.ts"],"mappings":";;AAIA;;;iBAAsB,gBAAA,WAA2B,MAAA,SAAe,OAAA,QAC9D,QAAA,EAAU,CAAA,GACT,OAAA,eAAsB,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,OAAA,YAAmB,CAAA"}
1
+ {"version":3,"file":"promise-all-object.d.mts","names":[],"sources":["../../../../../../../core/src/utils/promise-all-object.ts"],"mappings":";;AAIA;;;iBAAsB,gBAAA,WAA2B,MAAA,SAAe,OAAA,OAAA,CAC9D,QAAA,EAAU,CAAA,GACT,OAAA,eAAsB,CAAA,GAAI,CAAA,CAAE,CAAA,UAAW,OAAA,YAAmB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"promise-all-object.mjs","names":[],"sources":["../../../../../../../core/src/utils/promise-all-object.ts"],"sourcesContent":["/**\n * Resolve all of the given promises in the object and return the results as an object.\n * This is more convenient than using `Promise.all` and then mapping the results back to the keys.\n */\nexport async function promiseAllObject<T extends Record<string, Promise<any>>>(\n promises: T,\n): Promise<{ [K in keyof T]: T[K] extends Promise<infer U> ? U : never }> {\n const results = await Promise.all(Object.values(promises));\n const keys = Object.keys(promises);\n\n return keys.reduce(\n (result, key, index) => {\n (result as any)[key] = results[index];\n return result;\n },\n {} as { [K in keyof T]: T[K] extends Promise<infer U> ? U : never },\n );\n}\n"],"mappings":";;;;;AAIA,eAAsB,iBACpB,UACwE;CACxE,MAAM,UAAU,MAAM,QAAQ,IAAI,OAAO,OAAO,QAAQ,CAAC;CAGzD,OAFa,OAAO,KAAK,QAEf,CAAC,CAAC,QACT,QAAQ,KAAK,UAAU;EACtB,AAAC,OAAe,OAAO,QAAQ;EAC/B,OAAO;CACT,GACA,CAAC,CACH;AACF"}
1
+ {"version":3,"file":"promise-all-object.mjs","names":[],"sources":["../../../../../../../core/src/utils/promise-all-object.ts"],"sourcesContent":["/**\n * Resolve all of the given promises in the object and return the results as an object.\n * This is more convenient than using `Promise.all` and then mapping the results back to the keys.\n */\nexport async function promiseAllObject<T extends Record<string, Promise<any>>>(\n promises: T,\n): Promise<{ [K in keyof T]: T[K] extends Promise<infer U> ? U : never }> {\n const results = await Promise.all(Object.values(promises));\n const keys = Object.keys(promises);\n\n return keys.reduce(\n (result, key, index) => {\n (result as any)[key] = results[index];\n return result;\n },\n {} as { [K in keyof T]: T[K] extends Promise<infer U> ? U : never },\n );\n}\n"],"mappings":";;;;;AAIA,eAAsB,iBACpB,UACwE;CACxE,MAAM,UAAU,MAAM,QAAQ,IAAI,OAAO,OAAO,QAAQ,CAAC;CAGzD,OAFa,OAAO,KAAK,QAEf,EAAE,QACT,QAAQ,KAAK,UAAU;EACtB,AAAC,OAAe,OAAO,QAAQ;EAC/B,OAAO;CACT,GACA,CAAC,CACH;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"sluggable.mjs","names":[],"sources":["../../../../../../../core/src/utils/sluggable.ts"],"sourcesContent":["import slug from \"@mongez/slug\";\nimport type { Model } from \"@warlock.js/cascade\";\n\n/**\n * Used for model castings\n */\nexport function sluggable(generateFrom: string, slugLocaleCode = \"en\") {\n return (model: Model) => {\n let value = model.get(generateFrom);\n\n if (!value) return \"\";\n\n if (Array.isArray(value)) {\n value = (value as any[]).find((value) => value.localeCode === slugLocaleCode)?.value;\n }\n\n const slugFunction = (slug as any).default || slug;\n\n return slugFunction(String(value));\n };\n}\n"],"mappings":";;;;;;AAMA,SAAgB,UAAU,cAAsB,iBAAiB,MAAM;CACrE,QAAQ,UAAiB;EACvB,IAAI,QAAQ,MAAM,IAAI,YAAY;EAElC,IAAI,CAAC,OAAO,OAAO;EAEnB,IAAI,MAAM,QAAQ,KAAK,GACrB,QAAS,MAAgB,MAAM,UAAU,MAAM,eAAe,cAAc,CAAC,EAAE;EAKjF,QAFsB,KAAa,WAAW,KAE3B,CAAC,OAAO,KAAK,CAAC;CACnC;AACF"}
1
+ {"version":3,"file":"sluggable.mjs","names":[],"sources":["../../../../../../../core/src/utils/sluggable.ts"],"sourcesContent":["import slug from \"@mongez/slug\";\nimport type { Model } from \"@warlock.js/cascade\";\n\n/**\n * Used for model castings\n */\nexport function sluggable(generateFrom: string, slugLocaleCode = \"en\") {\n return (model: Model) => {\n let value = model.get(generateFrom);\n\n if (!value) return \"\";\n\n if (Array.isArray(value)) {\n value = (value as any[]).find((value) => value.localeCode === slugLocaleCode)?.value;\n }\n\n const slugFunction = (slug as any).default || slug;\n\n return slugFunction(String(value));\n };\n}\n"],"mappings":";;;;;;AAMA,SAAgB,UAAU,cAAsB,iBAAiB,MAAM;CACrE,QAAQ,UAAiB;EACvB,IAAI,QAAQ,MAAM,IAAI,YAAY;EAElC,IAAI,CAAC,OAAO,OAAO;EAEnB,IAAI,MAAM,QAAQ,KAAK,GACrB,QAAS,MAAgB,MAAM,UAAU,MAAM,eAAe,cAAc,GAAG;EAKjF,QAFsB,KAAa,WAAW,MAE1B,OAAO,KAAK,CAAC;CACnC;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"version-compare.mjs","names":[],"sources":["../../../../../../../core/src/utils/version-compare.ts"],"sourcesContent":["/**\n * Zero-dependency semver comparison — just enough for the framework's\n * self-update tooling (the dev-server update notice + the `warlock update`\n * command).\n *\n * We deliberately avoid pulling in a semver library: the only question these\n * callers ask is \"is the published version newer than what's installed?\".\n */\n\ntype ParsedVersion = {\n /** Numeric core as `[major, minor, patch]`. */\n core: [number, number, number];\n /** Dot-separated prerelease identifiers; empty for a stable release. */\n prerelease: string[];\n};\n\n/**\n * Parse a semver string into its numeric core + prerelease identifiers.\n * Tolerates a leading `v` and ignores build metadata (`+…`). Returns\n * `undefined` when the core isn't exactly three non-negative integers.\n */\nfunction parseVersion(version: string): ParsedVersion | undefined {\n const cleaned = version.trim().replace(/^v/i, \"\");\n const [coreAndPrerelease] = cleaned.split(\"+\"); // drop build metadata\n const [core, ...prereleaseParts] = coreAndPrerelease.split(\"-\");\n const segments = core.split(\".\");\n\n if (segments.length !== 3) {\n return undefined;\n }\n\n const numbers = segments.map((segment) => Number(segment));\n\n if (numbers.some((value) => !Number.isInteger(value) || value < 0)) {\n return undefined;\n }\n\n const prerelease = prereleaseParts.length > 0 ? prereleaseParts.join(\"-\").split(\".\") : [];\n\n return {\n core: [numbers[0], numbers[1], numbers[2]],\n prerelease,\n };\n}\n\n/**\n * Compare two prerelease identifier lists per semver rules: numeric\n * identifiers compare numerically, alphanumeric ones lexically, a numeric\n * identifier ranks below an alphanumeric one, and a longer list wins when\n * otherwise equal. Returns a negative / zero / positive number.\n */\nfunction comparePrerelease(left: string[], right: string[]): number {\n const length = Math.max(left.length, right.length);\n\n for (let index = 0; index < length; index++) {\n const a = left[index];\n const b = right[index];\n\n if (a === undefined) {\n return -1;\n }\n\n if (b === undefined) {\n return 1;\n }\n\n const aIsNumeric = /^\\d+$/.test(a);\n const bIsNumeric = /^\\d+$/.test(b);\n\n if (aIsNumeric && bIsNumeric) {\n const diff = Number(a) - Number(b);\n\n if (diff !== 0) {\n return diff;\n }\n\n continue;\n }\n\n if (aIsNumeric !== bIsNumeric) {\n return aIsNumeric ? -1 : 1;\n }\n\n if (a !== b) {\n return a < b ? -1 : 1;\n }\n }\n\n return 0;\n}\n\n/**\n * Return `true` when `latest` is a strictly newer semantic version than\n * `current`. Compares the numeric `major.minor.patch` first, then treats a\n * stable release as newer than a prerelease of the same core\n * (`1.2.0` > `1.2.0-beta`). Unparseable input yields `false` — we never nag\n * on a version string we can't understand.\n */\nexport function isNewerVersion(latest: string, current: string): boolean {\n const latestParsed = parseVersion(latest);\n const currentParsed = parseVersion(current);\n\n if (!latestParsed || !currentParsed) {\n return false;\n }\n\n for (let index = 0; index < 3; index++) {\n if (latestParsed.core[index] !== currentParsed.core[index]) {\n return latestParsed.core[index] > currentParsed.core[index];\n }\n }\n\n // Equal numeric core — order by prerelease (a stable release beats a prerelease).\n const latestIsStable = latestParsed.prerelease.length === 0;\n const currentIsStable = currentParsed.prerelease.length === 0;\n\n if (latestIsStable && currentIsStable) {\n return false;\n }\n\n if (latestIsStable !== currentIsStable) {\n return latestIsStable;\n }\n\n return comparePrerelease(latestParsed.prerelease, currentParsed.prerelease) > 0;\n}\n"],"mappings":";;;;;;AAqBA,SAAS,aAAa,SAA4C;CAEhE,MAAM,CAAC,qBADS,QAAQ,KAAK,CAAC,CAAC,QAAQ,OAAO,EACZ,CAAC,CAAC,MAAM,GAAG;CAC7C,MAAM,CAAC,MAAM,GAAG,mBAAmB,kBAAkB,MAAM,GAAG;CAC9D,MAAM,WAAW,KAAK,MAAM,GAAG;CAE/B,IAAI,SAAS,WAAW,GACtB;CAGF,MAAM,UAAU,SAAS,KAAK,YAAY,OAAO,OAAO,CAAC;CAEzD,IAAI,QAAQ,MAAM,UAAU,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,CAAC,GAC/D;CAGF,MAAM,aAAa,gBAAgB,SAAS,IAAI,gBAAgB,KAAK,GAAG,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC;CAExF,OAAO;EACL,MAAM;GAAC,QAAQ;GAAI,QAAQ;GAAI,QAAQ;EAAE;EACzC;CACF;AACF;;;;;;;AAQA,SAAS,kBAAkB,MAAgB,OAAyB;CAClE,MAAM,SAAS,KAAK,IAAI,KAAK,QAAQ,MAAM,MAAM;CAEjD,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,SAAS;EAC3C,MAAM,IAAI,KAAK;EACf,MAAM,IAAI,MAAM;EAEhB,IAAI,MAAM,QACR,OAAO;EAGT,IAAI,MAAM,QACR,OAAO;EAGT,MAAM,aAAa,QAAQ,KAAK,CAAC;EACjC,MAAM,aAAa,QAAQ,KAAK,CAAC;EAEjC,IAAI,cAAc,YAAY;GAC5B,MAAM,OAAO,OAAO,CAAC,IAAI,OAAO,CAAC;GAEjC,IAAI,SAAS,GACX,OAAO;GAGT;EACF;EAEA,IAAI,eAAe,YACjB,OAAO,aAAa,KAAK;EAG3B,IAAI,MAAM,GACR,OAAO,IAAI,IAAI,KAAK;CAExB;CAEA,OAAO;AACT;;;;;;;;AASA,SAAgB,eAAe,QAAgB,SAA0B;CACvE,MAAM,eAAe,aAAa,MAAM;CACxC,MAAM,gBAAgB,aAAa,OAAO;CAE1C,IAAI,CAAC,gBAAgB,CAAC,eACpB,OAAO;CAGT,KAAK,IAAI,QAAQ,GAAG,QAAQ,GAAG,SAC7B,IAAI,aAAa,KAAK,WAAW,cAAc,KAAK,QAClD,OAAO,aAAa,KAAK,SAAS,cAAc,KAAK;CAKzD,MAAM,iBAAiB,aAAa,WAAW,WAAW;CAC1D,MAAM,kBAAkB,cAAc,WAAW,WAAW;CAE5D,IAAI,kBAAkB,iBACpB,OAAO;CAGT,IAAI,mBAAmB,iBACrB,OAAO;CAGT,OAAO,kBAAkB,aAAa,YAAY,cAAc,UAAU,IAAI;AAChF"}
1
+ {"version":3,"file":"version-compare.mjs","names":[],"sources":["../../../../../../../core/src/utils/version-compare.ts"],"sourcesContent":["/**\n * Zero-dependency semver comparison — just enough for the framework's\n * self-update tooling (the dev-server update notice + the `warlock update`\n * command).\n *\n * We deliberately avoid pulling in a semver library: the only question these\n * callers ask is \"is the published version newer than what's installed?\".\n */\n\ntype ParsedVersion = {\n /** Numeric core as `[major, minor, patch]`. */\n core: [number, number, number];\n /** Dot-separated prerelease identifiers; empty for a stable release. */\n prerelease: string[];\n};\n\n/**\n * Parse a semver string into its numeric core + prerelease identifiers.\n * Tolerates a leading `v` and ignores build metadata (`+…`). Returns\n * `undefined` when the core isn't exactly three non-negative integers.\n */\nfunction parseVersion(version: string): ParsedVersion | undefined {\n const cleaned = version.trim().replace(/^v/i, \"\");\n const [coreAndPrerelease] = cleaned.split(\"+\"); // drop build metadata\n const [core, ...prereleaseParts] = coreAndPrerelease.split(\"-\");\n const segments = core.split(\".\");\n\n if (segments.length !== 3) {\n return undefined;\n }\n\n const numbers = segments.map((segment) => Number(segment));\n\n if (numbers.some((value) => !Number.isInteger(value) || value < 0)) {\n return undefined;\n }\n\n const prerelease = prereleaseParts.length > 0 ? prereleaseParts.join(\"-\").split(\".\") : [];\n\n return {\n core: [numbers[0], numbers[1], numbers[2]],\n prerelease,\n };\n}\n\n/**\n * Compare two prerelease identifier lists per semver rules: numeric\n * identifiers compare numerically, alphanumeric ones lexically, a numeric\n * identifier ranks below an alphanumeric one, and a longer list wins when\n * otherwise equal. Returns a negative / zero / positive number.\n */\nfunction comparePrerelease(left: string[], right: string[]): number {\n const length = Math.max(left.length, right.length);\n\n for (let index = 0; index < length; index++) {\n const a = left[index];\n const b = right[index];\n\n if (a === undefined) {\n return -1;\n }\n\n if (b === undefined) {\n return 1;\n }\n\n const aIsNumeric = /^\\d+$/.test(a);\n const bIsNumeric = /^\\d+$/.test(b);\n\n if (aIsNumeric && bIsNumeric) {\n const diff = Number(a) - Number(b);\n\n if (diff !== 0) {\n return diff;\n }\n\n continue;\n }\n\n if (aIsNumeric !== bIsNumeric) {\n return aIsNumeric ? -1 : 1;\n }\n\n if (a !== b) {\n return a < b ? -1 : 1;\n }\n }\n\n return 0;\n}\n\n/**\n * Return `true` when `latest` is a strictly newer semantic version than\n * `current`. Compares the numeric `major.minor.patch` first, then treats a\n * stable release as newer than a prerelease of the same core\n * (`1.2.0` > `1.2.0-beta`). Unparseable input yields `false` — we never nag\n * on a version string we can't understand.\n */\nexport function isNewerVersion(latest: string, current: string): boolean {\n const latestParsed = parseVersion(latest);\n const currentParsed = parseVersion(current);\n\n if (!latestParsed || !currentParsed) {\n return false;\n }\n\n for (let index = 0; index < 3; index++) {\n if (latestParsed.core[index] !== currentParsed.core[index]) {\n return latestParsed.core[index] > currentParsed.core[index];\n }\n }\n\n // Equal numeric core — order by prerelease (a stable release beats a prerelease).\n const latestIsStable = latestParsed.prerelease.length === 0;\n const currentIsStable = currentParsed.prerelease.length === 0;\n\n if (latestIsStable && currentIsStable) {\n return false;\n }\n\n if (latestIsStable !== currentIsStable) {\n return latestIsStable;\n }\n\n return comparePrerelease(latestParsed.prerelease, currentParsed.prerelease) > 0;\n}\n"],"mappings":";;;;;;AAqBA,SAAS,aAAa,SAA4C;CAEhE,MAAM,CAAC,qBADS,QAAQ,KAAK,EAAE,QAAQ,OAAO,EACZ,EAAE,MAAM,GAAG;CAC7C,MAAM,CAAC,MAAM,GAAG,mBAAmB,kBAAkB,MAAM,GAAG;CAC9D,MAAM,WAAW,KAAK,MAAM,GAAG;CAE/B,IAAI,SAAS,WAAW,GACtB;CAGF,MAAM,UAAU,SAAS,KAAK,YAAY,OAAO,OAAO,CAAC;CAEzD,IAAI,QAAQ,MAAM,UAAU,CAAC,OAAO,UAAU,KAAK,KAAK,QAAQ,CAAC,GAC/D;CAGF,MAAM,aAAa,gBAAgB,SAAS,IAAI,gBAAgB,KAAK,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAExF,OAAO;EACL,MAAM;GAAC,QAAQ;GAAI,QAAQ;GAAI,QAAQ;EAAE;EACzC;CACF;AACF;;;;;;;AAQA,SAAS,kBAAkB,MAAgB,OAAyB;CAClE,MAAM,SAAS,KAAK,IAAI,KAAK,QAAQ,MAAM,MAAM;CAEjD,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,SAAS;EAC3C,MAAM,IAAI,KAAK;EACf,MAAM,IAAI,MAAM;EAEhB,IAAI,MAAM,QACR,OAAO;EAGT,IAAI,MAAM,QACR,OAAO;EAGT,MAAM,aAAa,QAAQ,KAAK,CAAC;EACjC,MAAM,aAAa,QAAQ,KAAK,CAAC;EAEjC,IAAI,cAAc,YAAY;GAC5B,MAAM,OAAO,OAAO,CAAC,IAAI,OAAO,CAAC;GAEjC,IAAI,SAAS,GACX,OAAO;GAGT;EACF;EAEA,IAAI,eAAe,YACjB,OAAO,aAAa,KAAK;EAG3B,IAAI,MAAM,GACR,OAAO,IAAI,IAAI,KAAK;CAExB;CAEA,OAAO;AACT;;;;;;;;AASA,SAAgB,eAAe,QAAgB,SAA0B;CACvE,MAAM,eAAe,aAAa,MAAM;CACxC,MAAM,gBAAgB,aAAa,OAAO;CAE1C,IAAI,CAAC,gBAAgB,CAAC,eACpB,OAAO;CAGT,KAAK,IAAI,QAAQ,GAAG,QAAQ,GAAG,SAC7B,IAAI,aAAa,KAAK,WAAW,cAAc,KAAK,QAClD,OAAO,aAAa,KAAK,SAAS,cAAc,KAAK;CAKzD,MAAM,iBAAiB,aAAa,WAAW,WAAW;CAC1D,MAAM,kBAAkB,cAAc,WAAW,WAAW;CAE5D,IAAI,kBAAkB,iBACpB,OAAO;CAGT,IAAI,mBAAmB,iBACrB,OAAO;CAGT,OAAO,kBAAkB,aAAa,YAAY,cAAc,UAAU,IAAI;AAChF"}
@@ -1 +1 @@
1
- {"version":3,"file":"exists-except-current-id.mjs","names":[],"sources":["../../../../../../../../core/src/validation/database/exists-except-current-id.ts"],"sourcesContent":["import { resolveModelClass } from \"@warlock.js/cascade\";\nimport { invalidRule, VALID_RULE, type SchemaRule } from \"@warlock.js/seal\";\nimport { useRequestStore } from \"../../http\";\nimport type { ExistsExceptCurrentIdRuleOptions } from \"../types\";\n\n/**\n * Exists except current ID rule\n */\nexport const existsExceptCurrentIdRule: SchemaRule<ExistsExceptCurrentIdRuleOptions> = {\n name: \"existsExceptCurrentId\",\n defaultErrorMessage: \"The :input must exist\",\n async validate(value: any, context) {\n const {\n Model,\n query,\n column = context.key,\n exceptCurrentIdColumn = \"id\",\n } = this.context.options;\n\n const { request } = useRequestStore();\n\n const ResolvedModelClass = resolveModelClass(Model);\n\n const dbQuery = ResolvedModelClass.query();\n\n dbQuery.where(column, value);\n dbQuery.where(exceptCurrentIdColumn, \"!=\", request.int(\"id\"));\n\n if (query) {\n await query({\n query: dbQuery,\n value,\n allValues: context.allValues,\n });\n }\n\n const document = await dbQuery.first();\n return document ? VALID_RULE : invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,4BAA0E;CACrF,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EACJ,OACA,OACA,SAAS,QAAQ,KACjB,wBAAwB,SACtB,KAAK,QAAQ;EAEjB,MAAM,EAAE,YAAY,gBAAgB;EAIpC,MAAM,UAFqB,kBAAkB,KAEZ,CAAC,CAAC,MAAM;EAEzC,QAAQ,MAAM,QAAQ,KAAK;EAC3B,QAAQ,MAAM,uBAAuB,MAAM,QAAQ,IAAI,IAAI,CAAC;EAE5D,IAAI,OACF,MAAM,MAAM;GACV,OAAO;GACP;GACA,WAAW,QAAQ;EACrB,CAAC;EAIH,OAAO,MADgB,QAAQ,MAAM,IACnB,aAAa,YAAY,MAAM,OAAO;CAC1D;AACF"}
1
+ {"version":3,"file":"exists-except-current-id.mjs","names":[],"sources":["../../../../../../../../core/src/validation/database/exists-except-current-id.ts"],"sourcesContent":["import { resolveModelClass } from \"@warlock.js/cascade\";\nimport { invalidRule, VALID_RULE, type SchemaRule } from \"@warlock.js/seal\";\nimport { useRequestStore } from \"../../http\";\nimport type { ExistsExceptCurrentIdRuleOptions } from \"../types\";\n\n/**\n * Exists except current ID rule\n */\nexport const existsExceptCurrentIdRule: SchemaRule<ExistsExceptCurrentIdRuleOptions> = {\n name: \"existsExceptCurrentId\",\n defaultErrorMessage: \"The :input must exist\",\n async validate(value: any, context) {\n const {\n Model,\n query,\n column = context.key,\n exceptCurrentIdColumn = \"id\",\n } = this.context.options;\n\n const { request } = useRequestStore();\n\n const ResolvedModelClass = resolveModelClass(Model);\n\n const dbQuery = ResolvedModelClass.query();\n\n dbQuery.where(column, value);\n dbQuery.where(exceptCurrentIdColumn, \"!=\", request.int(\"id\"));\n\n if (query) {\n await query({\n query: dbQuery,\n value,\n allValues: context.allValues,\n });\n }\n\n const document = await dbQuery.first();\n return document ? VALID_RULE : invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,4BAA0E;CACrF,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EACJ,OACA,OACA,SAAS,QAAQ,KACjB,wBAAwB,SACtB,KAAK,QAAQ;EAEjB,MAAM,EAAE,YAAY,gBAAgB;EAIpC,MAAM,UAFqB,kBAAkB,KAEZ,EAAE,MAAM;EAEzC,QAAQ,MAAM,QAAQ,KAAK;EAC3B,QAAQ,MAAM,uBAAuB,MAAM,QAAQ,IAAI,IAAI,CAAC;EAE5D,IAAI,OACF,MAAM,MAAM;GACV,OAAO;GACP;GACA,WAAW,QAAQ;EACrB,CAAC;EAIH,OAAO,MADgB,QAAQ,MAAM,IACnB,aAAa,YAAY,MAAM,OAAO;CAC1D;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"exists-except-current-user.mjs","names":[],"sources":["../../../../../../../../core/src/validation/database/exists-except-current-user.ts"],"sourcesContent":["import { resolveModelClass } from \"@warlock.js/cascade\";\nimport { invalidRule, VALID_RULE, type SchemaRule } from \"@warlock.js/seal\";\nimport { useCurrentUser } from \"../../http\";\nimport type { ExistsExceptCurrentUserRuleOptions } from \"../types\";\n\n/**\n * Exists except current user rule\n */\nexport const existsExceptCurrentUserRule: SchemaRule<ExistsExceptCurrentUserRuleOptions> = {\n name: \"existsExceptCurrentUser\",\n defaultErrorMessage: \"The :input must exist\",\n async validate(value: any, context) {\n const {\n Model,\n query,\n column = context.key,\n exceptCurrentUserColumn = \"id\",\n exceptCurrentUserValue = \"id\",\n } = this.context.options;\n\n const user = useCurrentUser();\n\n const ResolvedModelClass = resolveModelClass(Model);\n\n const dbQuery = ResolvedModelClass.query();\n\n dbQuery.where(column, value);\n\n if (user) {\n dbQuery.where(exceptCurrentUserColumn, \"!=\", user.get(exceptCurrentUserValue));\n }\n\n if (query) {\n await query({\n query: dbQuery,\n value,\n allValues: context.allValues,\n });\n }\n\n const document = await dbQuery.first();\n return document ? VALID_RULE : invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,8BAA8E;CACzF,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EACJ,OACA,OACA,SAAS,QAAQ,KACjB,0BAA0B,MAC1B,yBAAyB,SACvB,KAAK,QAAQ;EAEjB,MAAM,OAAO,eAAe;EAI5B,MAAM,UAFqB,kBAAkB,KAEZ,CAAC,CAAC,MAAM;EAEzC,QAAQ,MAAM,QAAQ,KAAK;EAE3B,IAAI,MACF,QAAQ,MAAM,yBAAyB,MAAM,KAAK,IAAI,sBAAsB,CAAC;EAG/E,IAAI,OACF,MAAM,MAAM;GACV,OAAO;GACP;GACA,WAAW,QAAQ;EACrB,CAAC;EAIH,OAAO,MADgB,QAAQ,MAAM,IACnB,aAAa,YAAY,MAAM,OAAO;CAC1D;AACF"}
1
+ {"version":3,"file":"exists-except-current-user.mjs","names":[],"sources":["../../../../../../../../core/src/validation/database/exists-except-current-user.ts"],"sourcesContent":["import { resolveModelClass } from \"@warlock.js/cascade\";\nimport { invalidRule, VALID_RULE, type SchemaRule } from \"@warlock.js/seal\";\nimport { useCurrentUser } from \"../../http\";\nimport type { ExistsExceptCurrentUserRuleOptions } from \"../types\";\n\n/**\n * Exists except current user rule\n */\nexport const existsExceptCurrentUserRule: SchemaRule<ExistsExceptCurrentUserRuleOptions> = {\n name: \"existsExceptCurrentUser\",\n defaultErrorMessage: \"The :input must exist\",\n async validate(value: any, context) {\n const {\n Model,\n query,\n column = context.key,\n exceptCurrentUserColumn = \"id\",\n exceptCurrentUserValue = \"id\",\n } = this.context.options;\n\n const user = useCurrentUser();\n\n const ResolvedModelClass = resolveModelClass(Model);\n\n const dbQuery = ResolvedModelClass.query();\n\n dbQuery.where(column, value);\n\n if (user) {\n dbQuery.where(exceptCurrentUserColumn, \"!=\", user.get(exceptCurrentUserValue));\n }\n\n if (query) {\n await query({\n query: dbQuery,\n value,\n allValues: context.allValues,\n });\n }\n\n const document = await dbQuery.first();\n return document ? VALID_RULE : invalidRule(this, context);\n },\n};\n"],"mappings":";;;;;;;;;AAQA,MAAa,8BAA8E;CACzF,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EACJ,OACA,OACA,SAAS,QAAQ,KACjB,0BAA0B,MAC1B,yBAAyB,SACvB,KAAK,QAAQ;EAEjB,MAAM,OAAO,eAAe;EAI5B,MAAM,UAFqB,kBAAkB,KAEZ,EAAE,MAAM;EAEzC,QAAQ,MAAM,QAAQ,KAAK;EAE3B,IAAI,MACF,QAAQ,MAAM,yBAAyB,MAAM,KAAK,IAAI,sBAAsB,CAAC;EAG/E,IAAI,OACF,MAAM,MAAM;GACV,OAAO;GACP;GACA,WAAW,QAAQ;EACrB,CAAC;EAIH,OAAO,MADgB,QAAQ,MAAM,IACnB,aAAa,YAAY,MAAM,OAAO;CAC1D;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"unique-except-current-id.mjs","names":[],"sources":["../../../../../../../../core/src/validation/database/unique-except-current-id.ts"],"sourcesContent":["import { resolveModelClass } from \"@warlock.js/cascade\";\nimport { invalidRule, VALID_RULE, type SchemaRule } from \"@warlock.js/seal\";\nimport { useRequestStore } from \"../../http\";\nimport type { UniqueExceptCurrentIdRuleOptions } from \"../types\";\n/**\n * Unique except current ID rule\n */\nexport const uniqueExceptCurrentIdRule: SchemaRule<UniqueExceptCurrentIdRuleOptions> = {\n name: \"uniqueExceptCurrentId\",\n defaultErrorMessage: \"The :input must be unique\",\n async validate(value: any, context) {\n const {\n Model,\n column = context.key,\n exceptCurrentIdColumn = \"id\",\n query,\n } = this.context.options;\n\n const { request } = useRequestStore();\n\n const ResolvedModelClass = resolveModelClass(Model);\n\n const dbQuery = ResolvedModelClass.query();\n\n dbQuery.where(column, value);\n dbQuery.where(exceptCurrentIdColumn, \"!=\", request.input(\"id\"));\n\n if (query) {\n await query({\n query: dbQuery,\n value,\n allValues: context.allValues,\n });\n }\n\n const document = await dbQuery.first();\n return document ? invalidRule(this, context) : VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,4BAA0E;CACrF,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EACJ,OACA,SAAS,QAAQ,KACjB,wBAAwB,MACxB,UACE,KAAK,QAAQ;EAEjB,MAAM,EAAE,YAAY,gBAAgB;EAIpC,MAAM,UAFqB,kBAAkB,KAEZ,CAAC,CAAC,MAAM;EAEzC,QAAQ,MAAM,QAAQ,KAAK;EAC3B,QAAQ,MAAM,uBAAuB,MAAM,QAAQ,MAAM,IAAI,CAAC;EAE9D,IAAI,OACF,MAAM,MAAM;GACV,OAAO;GACP;GACA,WAAW,QAAQ;EACrB,CAAC;EAIH,OAAO,MADgB,QAAQ,MAAM,IACnB,YAAY,MAAM,OAAO,IAAI;CACjD;AACF"}
1
+ {"version":3,"file":"unique-except-current-id.mjs","names":[],"sources":["../../../../../../../../core/src/validation/database/unique-except-current-id.ts"],"sourcesContent":["import { resolveModelClass } from \"@warlock.js/cascade\";\nimport { invalidRule, VALID_RULE, type SchemaRule } from \"@warlock.js/seal\";\nimport { useRequestStore } from \"../../http\";\nimport type { UniqueExceptCurrentIdRuleOptions } from \"../types\";\n/**\n * Unique except current ID rule\n */\nexport const uniqueExceptCurrentIdRule: SchemaRule<UniqueExceptCurrentIdRuleOptions> = {\n name: \"uniqueExceptCurrentId\",\n defaultErrorMessage: \"The :input must be unique\",\n async validate(value: any, context) {\n const {\n Model,\n column = context.key,\n exceptCurrentIdColumn = \"id\",\n query,\n } = this.context.options;\n\n const { request } = useRequestStore();\n\n const ResolvedModelClass = resolveModelClass(Model);\n\n const dbQuery = ResolvedModelClass.query();\n\n dbQuery.where(column, value);\n dbQuery.where(exceptCurrentIdColumn, \"!=\", request.input(\"id\"));\n\n if (query) {\n await query({\n query: dbQuery,\n value,\n allValues: context.allValues,\n });\n }\n\n const document = await dbQuery.first();\n return document ? invalidRule(this, context) : VALID_RULE;\n },\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,4BAA0E;CACrF,MAAM;CACN,qBAAqB;CACrB,MAAM,SAAS,OAAY,SAAS;EAClC,MAAM,EACJ,OACA,SAAS,QAAQ,KACjB,wBAAwB,MACxB,UACE,KAAK,QAAQ;EAEjB,MAAM,EAAE,YAAY,gBAAgB;EAIpC,MAAM,UAFqB,kBAAkB,KAEZ,EAAE,MAAM;EAEzC,QAAQ,MAAM,QAAQ,KAAK;EAC3B,QAAQ,MAAM,uBAAuB,MAAM,QAAQ,MAAM,IAAI,CAAC;EAE9D,IAAI,OACF,MAAM,MAAM;GACV,OAAO;GACP;GACA,WAAW,QAAQ;EACrB,CAAC;EAIH,OAAO,MADgB,QAAQ,MAAM,IACnB,YAAY,MAAM,OAAO,IAAI;CACjD;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"localized-plugin.mjs","names":[],"sources":["../../../../../../../../core/src/validation/plugins/localized-plugin.ts"],"sourcesContent":["/**\n * Localized Validator Plugin\n *\n * Adds localized() method to Seal v factory\n */\n\nimport type { ArrayValidator, BaseValidator, SealPlugin } from \"@warlock.js/seal\";\nimport { v } from \"@warlock.js/seal\";\n\ntype LocalizedReturn = ArrayValidator & {\n validator: BaseValidator;\n};\n\n/**\n * Localized validation plugin for Seal\n */\nexport const localizedPlugin: SealPlugin = {\n name: \"localized\",\n version: \"1.0.0\",\n description: \"Adds localized validation (v.localized())\",\n install() {\n v.localized = (valueValidator?: BaseValidator, errorMessage?: string): LocalizedReturn =>\n v.array(\n v.object({\n localeCode: v.string().required(),\n value: valueValidator || v.scalar(),\n }),\n errorMessage,\n ) as LocalizedReturn;\n },\n};\n"],"mappings":";;;;;;AAgBA,MAAa,kBAA8B;CACzC,MAAM;CACN,SAAS;CACT,aAAa;CACb,UAAU;EACR,EAAE,aAAa,gBAAgC,iBAC7C,EAAE,MACA,EAAE,OAAO;GACP,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS;GAChC,OAAO,kBAAkB,EAAE,OAAO;EACpC,CAAC,GACD,YACF;CACJ;AACF"}
1
+ {"version":3,"file":"localized-plugin.mjs","names":[],"sources":["../../../../../../../../core/src/validation/plugins/localized-plugin.ts"],"sourcesContent":["/**\n * Localized Validator Plugin\n *\n * Adds localized() method to Seal v factory\n */\n\nimport type { ArrayValidator, BaseValidator, SealPlugin } from \"@warlock.js/seal\";\nimport { v } from \"@warlock.js/seal\";\n\ntype LocalizedReturn = ArrayValidator & {\n validator: BaseValidator;\n};\n\n/**\n * Localized validation plugin for Seal\n */\nexport const localizedPlugin: SealPlugin = {\n name: \"localized\",\n version: \"1.0.0\",\n description: \"Adds localized validation (v.localized())\",\n install() {\n v.localized = (valueValidator?: BaseValidator, errorMessage?: string): LocalizedReturn =>\n v.array(\n v.object({\n localeCode: v.string().required(),\n value: valueValidator || v.scalar(),\n }),\n errorMessage,\n ) as LocalizedReturn;\n },\n};\n"],"mappings":";;;;;;AAgBA,MAAa,kBAA8B;CACzC,MAAM;CACN,SAAS;CACT,aAAa;CACb,UAAU;EACR,EAAE,aAAa,gBAAgC,iBAC7C,EAAE,MACA,EAAE,OAAO;GACP,YAAY,EAAE,OAAO,EAAE,SAAS;GAChC,OAAO,kBAAkB,EAAE,OAAO;EACpC,CAAC,GACD,YACF;CACJ;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"file-validator.mjs","names":[],"sources":["../../../../../../../../core/src/validation/validators/file-validator.ts"],"sourcesContent":["import type { FileSizeOption, JsonSchemaResult, JsonSchemaTarget } from \"@warlock.js/seal\";\nimport {\n BaseValidator,\n maxFileSizeRule,\n maxHeightRule,\n maxWidthRule,\n minFileSizeRule,\n minHeightRule,\n minWidthRule,\n resolveFileSize,\n v,\n} from \"@warlock.js/seal\";\nimport { UploadedFile } from \"../../http\";\nimport { fileExtensionRule, fileRule, fileTypeRule, imageRule } from \"../file\";\n\nexport const uploadedFileMetadataSchema = v.object({\n location: v.string().oneOf([\"local\", \"cloud\"]),\n width: v.int().positive(),\n height: v.int().positive(),\n size: v.int().positive(),\n mimeType: v.string(),\n extension: v.string(),\n name: v.string(),\n});\n\n/**\n * File validator class\n */\nexport class FileValidator extends BaseValidator {\n public constructor(errorMessage?: string) {\n super();\n this.addMutableRule(fileRule, errorMessage);\n }\n\n /**\n * Check if value is a File type\n */\n public matchesType(value: any): boolean {\n return value instanceof UploadedFile;\n }\n\n /** Value must be an image */\n public image(errorMessage?: string): FileValidator {\n return this.addRule(imageRule, errorMessage);\n }\n\n /** Accept specific file extensions */\n public accept(extensions: string | string[], errorMessage?: string): FileValidator {\n return this.addRule(fileExtensionRule, errorMessage, {\n extensions,\n });\n }\n\n /** Allow specific MIME types */\n public mimeType(mimeTypes: string | string[], errorMessage?: string): FileValidator {\n return this.addRule(fileTypeRule, errorMessage, {\n mimeTypes,\n });\n }\n\n /** Allow only pdf files */\n public pdf(errorMessage?: string): FileValidator {\n return this.mimeType(\"application/pdf\", errorMessage);\n }\n\n /** Allow only excel files */\n public excel(errorMessage?: string): FileValidator {\n return this.mimeType(\n [\n \"application/vnd.ms-excel\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n ],\n errorMessage,\n );\n }\n\n /** Allow only word files */\n public word(errorMessage?: string): FileValidator {\n return this.mimeType(\n [\n \"application/msword\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n ],\n errorMessage,\n );\n }\n\n /** Minimum file size */\n public minSize(size: number | FileSizeOption, errorMessage?: string): FileValidator {\n return this.addRule(minFileSizeRule, errorMessage, {\n minSize: resolveFileSize(size),\n });\n }\n\n /** @alias minSize */\n public min(size: number | FileSizeOption, errorMessage?: string): FileValidator {\n return this.minSize(size, errorMessage);\n }\n\n /** Maximum file size */\n public maxSize(size: number | FileSizeOption, errorMessage?: string): FileValidator {\n return this.addRule(maxFileSizeRule, errorMessage, {\n maxSize: resolveFileSize(size),\n });\n }\n\n /** @alias maxSize */\n public max(size: number, errorMessage?: string): FileValidator {\n return this.maxSize(size, errorMessage);\n }\n\n /** Minimum image width */\n public minWidth(width: number, errorMessage?: string): FileValidator {\n return this.addRule(minWidthRule, errorMessage, {\n minWidth: width,\n });\n }\n\n /** Maximum image width */\n public maxWidth(width: number, errorMessage?: string): FileValidator {\n return this.addRule(maxWidthRule, errorMessage, {\n maxWidth: width,\n });\n }\n\n /** Minimum image height */\n public minHeight(height: number, errorMessage?: string): FileValidator {\n return this.addRule(minHeightRule, errorMessage, {\n minHeight: height,\n });\n }\n\n /** Maximum image height */\n public maxHeight(height: number, errorMessage?: string): FileValidator {\n return this.addRule(maxHeightRule, errorMessage, {\n maxHeight: height,\n });\n }\n\n /**\n * Save the file and return it as a string\n */\n public saveTo(relativeDirectory: string): FileValidator {\n return this.addTransformer(async (file: UploadedFile) => {\n const output = await file.save(relativeDirectory);\n\n return output.path;\n });\n }\n\n /**\n * @inheritdoc\n *\n * File uploads are not natively representable in JSON Schema.\n * The output varies by target:\n * - `openapi-3.0` → `{ type: \"string\", format: \"binary\" }` (standard for multipart/form-data uploads)\n * - `draft-2020-12` → `{ type: \"string\", contentEncoding: \"binary\" }`\n * - `draft-07` → `{}` (no standard binary representation — permissive fallback)\n *\n * @example\n * ```ts\n * v.file().toJsonSchema(\"openapi-3.0\")\n * // → { type: \"string\", format: \"binary\" }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n if (target === \"openapi-3.0\") {\n return { type: \"string\", format: \"binary\" };\n }\n\n if (target === \"draft-2020-12\") {\n return { type: \"string\", contentEncoding: \"binary\" };\n }\n\n // draft-07: no standard binary representation\n return {};\n }\n}\n"],"mappings":";;;;;;;AAeA,MAAa,6BAA6B,EAAE,OAAO;CACjD,UAAU,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,SAAS,OAAO,CAAC;CAC7C,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS;CACxB,QAAQ,EAAE,IAAI,CAAC,CAAC,SAAS;CACzB,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS;CACvB,UAAU,EAAE,OAAO;CACnB,WAAW,EAAE,OAAO;CACpB,MAAM,EAAE,OAAO;AACjB,CAAC;;;;AAKD,IAAa,gBAAb,cAAmC,cAAc;CAC/C,AAAO,YAAY,cAAuB;EACxC,MAAM;EACN,KAAK,eAAe,UAAU,YAAY;CAC5C;;;;CAKA,AAAO,YAAY,OAAqB;EACtC,OAAO,iBAAiB;CAC1B;;CAGA,AAAO,MAAM,cAAsC;EACjD,OAAO,KAAK,QAAQ,WAAW,YAAY;CAC7C;;CAGA,AAAO,OAAO,YAA+B,cAAsC;EACjF,OAAO,KAAK,QAAQ,mBAAmB,cAAc,EACnD,WACF,CAAC;CACH;;CAGA,AAAO,SAAS,WAA8B,cAAsC;EAClF,OAAO,KAAK,QAAQ,cAAc,cAAc,EAC9C,UACF,CAAC;CACH;;CAGA,AAAO,IAAI,cAAsC;EAC/C,OAAO,KAAK,SAAS,mBAAmB,YAAY;CACtD;;CAGA,AAAO,MAAM,cAAsC;EACjD,OAAO,KAAK,SACV,CACE,4BACA,mEACF,GACA,YACF;CACF;;CAGA,AAAO,KAAK,cAAsC;EAChD,OAAO,KAAK,SACV,CACE,sBACA,yEACF,GACA,YACF;CACF;;CAGA,AAAO,QAAQ,MAA+B,cAAsC;EAClF,OAAO,KAAK,QAAQ,iBAAiB,cAAc,EACjD,SAAS,gBAAgB,IAAI,EAC/B,CAAC;CACH;;CAGA,AAAO,IAAI,MAA+B,cAAsC;EAC9E,OAAO,KAAK,QAAQ,MAAM,YAAY;CACxC;;CAGA,AAAO,QAAQ,MAA+B,cAAsC;EAClF,OAAO,KAAK,QAAQ,iBAAiB,cAAc,EACjD,SAAS,gBAAgB,IAAI,EAC/B,CAAC;CACH;;CAGA,AAAO,IAAI,MAAc,cAAsC;EAC7D,OAAO,KAAK,QAAQ,MAAM,YAAY;CACxC;;CAGA,AAAO,SAAS,OAAe,cAAsC;EACnE,OAAO,KAAK,QAAQ,cAAc,cAAc,EAC9C,UAAU,MACZ,CAAC;CACH;;CAGA,AAAO,SAAS,OAAe,cAAsC;EACnE,OAAO,KAAK,QAAQ,cAAc,cAAc,EAC9C,UAAU,MACZ,CAAC;CACH;;CAGA,AAAO,UAAU,QAAgB,cAAsC;EACrE,OAAO,KAAK,QAAQ,eAAe,cAAc,EAC/C,WAAW,OACb,CAAC;CACH;;CAGA,AAAO,UAAU,QAAgB,cAAsC;EACrE,OAAO,KAAK,QAAQ,eAAe,cAAc,EAC/C,WAAW,OACb,CAAC;CACH;;;;CAKA,AAAO,OAAO,mBAA0C;EACtD,OAAO,KAAK,eAAe,OAAO,SAAuB;GAGvD,QAAO,MAFc,KAAK,KAAK,iBAAiB,EAEnC,CAAC;EAChB,CAAC;CACH;;;;;;;;;;;;;;;;CAiBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,IAAI,WAAW,eACb,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAS;EAG5C,IAAI,WAAW,iBACb,OAAO;GAAE,MAAM;GAAU,iBAAiB;EAAS;EAIrD,OAAO,CAAC;CACV;AACF"}
1
+ {"version":3,"file":"file-validator.mjs","names":[],"sources":["../../../../../../../../core/src/validation/validators/file-validator.ts"],"sourcesContent":["import type { FileSizeOption, JsonSchemaResult, JsonSchemaTarget } from \"@warlock.js/seal\";\nimport {\n BaseValidator,\n maxFileSizeRule,\n maxHeightRule,\n maxWidthRule,\n minFileSizeRule,\n minHeightRule,\n minWidthRule,\n resolveFileSize,\n v,\n} from \"@warlock.js/seal\";\nimport { UploadedFile } from \"../../http\";\nimport { fileExtensionRule, fileRule, fileTypeRule, imageRule } from \"../file\";\n\nexport const uploadedFileMetadataSchema = v.object({\n location: v.string().oneOf([\"local\", \"cloud\"]),\n width: v.int().positive(),\n height: v.int().positive(),\n size: v.int().positive(),\n mimeType: v.string(),\n extension: v.string(),\n name: v.string(),\n});\n\n/**\n * File validator class\n */\nexport class FileValidator extends BaseValidator {\n public constructor(errorMessage?: string) {\n super();\n this.addMutableRule(fileRule, errorMessage);\n }\n\n /**\n * Check if value is a File type\n */\n public matchesType(value: any): boolean {\n return value instanceof UploadedFile;\n }\n\n /** Value must be an image */\n public image(errorMessage?: string): FileValidator {\n return this.addRule(imageRule, errorMessage);\n }\n\n /** Accept specific file extensions */\n public accept(extensions: string | string[], errorMessage?: string): FileValidator {\n return this.addRule(fileExtensionRule, errorMessage, {\n extensions,\n });\n }\n\n /** Allow specific MIME types */\n public mimeType(mimeTypes: string | string[], errorMessage?: string): FileValidator {\n return this.addRule(fileTypeRule, errorMessage, {\n mimeTypes,\n });\n }\n\n /** Allow only pdf files */\n public pdf(errorMessage?: string): FileValidator {\n return this.mimeType(\"application/pdf\", errorMessage);\n }\n\n /** Allow only excel files */\n public excel(errorMessage?: string): FileValidator {\n return this.mimeType(\n [\n \"application/vnd.ms-excel\",\n \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n ],\n errorMessage,\n );\n }\n\n /** Allow only word files */\n public word(errorMessage?: string): FileValidator {\n return this.mimeType(\n [\n \"application/msword\",\n \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n ],\n errorMessage,\n );\n }\n\n /** Minimum file size */\n public minSize(size: number | FileSizeOption, errorMessage?: string): FileValidator {\n return this.addRule(minFileSizeRule, errorMessage, {\n minSize: resolveFileSize(size),\n });\n }\n\n /** @alias minSize */\n public min(size: number | FileSizeOption, errorMessage?: string): FileValidator {\n return this.minSize(size, errorMessage);\n }\n\n /** Maximum file size */\n public maxSize(size: number | FileSizeOption, errorMessage?: string): FileValidator {\n return this.addRule(maxFileSizeRule, errorMessage, {\n maxSize: resolveFileSize(size),\n });\n }\n\n /** @alias maxSize */\n public max(size: number, errorMessage?: string): FileValidator {\n return this.maxSize(size, errorMessage);\n }\n\n /** Minimum image width */\n public minWidth(width: number, errorMessage?: string): FileValidator {\n return this.addRule(minWidthRule, errorMessage, {\n minWidth: width,\n });\n }\n\n /** Maximum image width */\n public maxWidth(width: number, errorMessage?: string): FileValidator {\n return this.addRule(maxWidthRule, errorMessage, {\n maxWidth: width,\n });\n }\n\n /** Minimum image height */\n public minHeight(height: number, errorMessage?: string): FileValidator {\n return this.addRule(minHeightRule, errorMessage, {\n minHeight: height,\n });\n }\n\n /** Maximum image height */\n public maxHeight(height: number, errorMessage?: string): FileValidator {\n return this.addRule(maxHeightRule, errorMessage, {\n maxHeight: height,\n });\n }\n\n /**\n * Save the file and return it as a string\n */\n public saveTo(relativeDirectory: string): FileValidator {\n return this.addTransformer(async (file: UploadedFile) => {\n const output = await file.save(relativeDirectory);\n\n return output.path;\n });\n }\n\n /**\n * @inheritdoc\n *\n * File uploads are not natively representable in JSON Schema.\n * The output varies by target:\n * - `openapi-3.0` → `{ type: \"string\", format: \"binary\" }` (standard for multipart/form-data uploads)\n * - `draft-2020-12` → `{ type: \"string\", contentEncoding: \"binary\" }`\n * - `draft-07` → `{}` (no standard binary representation — permissive fallback)\n *\n * @example\n * ```ts\n * v.file().toJsonSchema(\"openapi-3.0\")\n * // → { type: \"string\", format: \"binary\" }\n * ```\n */\n public override toJsonSchema(target: JsonSchemaTarget = \"draft-2020-12\"): JsonSchemaResult {\n if (target === \"openapi-3.0\") {\n return { type: \"string\", format: \"binary\" };\n }\n\n if (target === \"draft-2020-12\") {\n return { type: \"string\", contentEncoding: \"binary\" };\n }\n\n // draft-07: no standard binary representation\n return {};\n }\n}\n"],"mappings":";;;;;;;AAeA,MAAa,6BAA6B,EAAE,OAAO;C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CAGA,AAAO,IAAI,MAAc,cAAsC;EAC7D,OAAO,KAAK,QAAQ,MAAM,YAAY;CACxC;;CAGA,AAAO,SAAS,OAAe,cAAsC;EACnE,OAAO,KAAK,QAAQ,cAAc,cAAc,EAC9C,UAAU,MACZ,CAAC;CACH;;CAGA,AAAO,SAAS,OAAe,cAAsC;EACnE,OAAO,KAAK,QAAQ,cAAc,cAAc,EAC9C,UAAU,MACZ,CAAC;CACH;;CAGA,AAAO,UAAU,QAAgB,cAAsC;EACrE,OAAO,KAAK,QAAQ,eAAe,cAAc,EAC/C,WAAW,OACb,CAAC;CACH;;CAGA,AAAO,UAAU,QAAgB,cAAsC;EACrE,OAAO,KAAK,QAAQ,eAAe,cAAc,EAC/C,WAAW,OACb,CAAC;CACH;;;;CAKA,AAAO,OAAO,mBAA0C;EACtD,OAAO,KAAK,eAAe,OAAO,SAAuB;GAGvD,QAAO,MAFc,KAAK,KAAK,iBAAiB,GAElC;EAChB,CAAC;CACH;;;;;;;;;;;;;;;;CAiBA,AAAgB,aAAa,SAA2B,iBAAmC;EACzF,IAAI,WAAW,eACb,OAAO;GAAE,MAAM;GAAU,QAAQ;EAAS;EAG5C,IAAI,WAAW,iBACb,OAAO;GAAE,MAAM;GAAU,iBAAiB;EAAS;EAIrD,OAAO,CAAC;CACV;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"lower-stage3-decorators.d.mts","names":[],"sources":["../../../../../../../core/src/vite/lower-stage3-decorators.ts"],"mappings":";;AASA;;;;;;UAAiB,uBAAA;EACf,IAAA;EACA,OAAA;EACA,SAAA,CAAU,IAAA,UAAc,EAAA,WAAa,OAAO;IAAG,IAAA;IAAc,GAAA;EAAA;AAAA;AAoC/D;;;;AAAgE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAhE,iBAAgB,qBAAA,IAAyB,uBAAuB"}
1
+ {"version":3,"file":"lower-stage3-decorators.d.mts","names":[],"sources":["../../../../../../../core/src/vite/lower-stage3-decorators.ts"],"mappings":";;AASA;;;;;;UAAiB,uBAAA;EACf,IAAA;EACA,OAAA;EACA,SAAA,CAAU,IAAA,UAAc,EAAA,WAAa,OAAO;IAAG,IAAA;IAAc,GAAA;EAAA;AAAA;AAoC/D;;;;AAAgE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAhE,iBAAgB,qBAAA,CAAA,GAAyB,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"default-configurations.mjs","names":[],"sources":["../../../../../../../core/src/warlock-config/default-configurations.ts"],"sourcesContent":["import { WarlockConfig } from \"./types\";\n\nexport const defaultWarlockConfigurations: WarlockConfig = {\n build: {\n outdir: process.cwd() + \"/dist\",\n outFile: \"app.js\",\n sourcemap: true,\n minify: true,\n },\n};\n"],"mappings":";AAEA,MAAa,+BAA8C,EACzD,OAAO;CACL,QAAQ,QAAQ,IAAI,IAAI;CACxB,SAAS;CACT,WAAW;CACX,QAAQ;AACV,EACF"}
1
+ {"version":3,"file":"default-configurations.mjs","names":[],"sources":["../../../../../../../core/src/warlock-config/default-configurations.ts"],"sourcesContent":["import { type WarlockConfig } from \"./types\";\n\nexport const defaultWarlockConfigurations: WarlockConfig = {\n build: {\n outdir: process.cwd() + \"/dist\",\n outFile: \"app.js\",\n sourcemap: true,\n minify: true,\n },\n};\n"],"mappings":";AAEA,MAAa,+BAA8C,EACzD,OAAO;CACL,QAAQ,QAAQ,IAAI,IAAI;CACxB,SAAS;CACT,WAAW;CACX,QAAQ;AACV,EACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"warlock-config.manager.d.mts","names":[],"sources":["../../../../../../../core/src/warlock-config/warlock-config.manager.ts"],"mappings":";;;;;AAeA;;;;AAAwD;AAaxD;iBAbgB,yBAAA,CAA0B,KAAc;;;;;;;cAa3C,oBAAA;EAyHR;;;EAAA,QArHK,MAAA;EAyIS;;;EAAA,QApIT,OAAA;EAqIL;;;;;EA9HU,IAAA,IAAQ,OAAA,CAAQ,aAAA;EAPrB;;;;;;EAAA,QAgCM,MAAA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