@warlock.js/core 4.5.0 → 4.6.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 (203) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/esm/ai/src/agent/agent.mjs +126 -7
  3. package/esm/ai/src/agent/agent.mjs.map +1 -1
  4. package/esm/ai/src/agent/signature.mjs +57 -0
  5. package/esm/ai/src/agent/signature.mjs.map +1 -0
  6. package/esm/ai/src/agent/snapshot.mjs +101 -0
  7. package/esm/ai/src/agent/snapshot.mjs.map +1 -0
  8. package/esm/ai/src/ai.mjs +37 -1
  9. package/esm/ai/src/ai.mjs.map +1 -1
  10. package/esm/ai/src/errors/agent-drift-error.mjs +31 -0
  11. package/esm/ai/src/errors/agent-drift-error.mjs.map +1 -0
  12. package/esm/ai/src/errors/index.mjs +2 -0
  13. package/esm/ai/src/errors/planner-drift-error.mjs +33 -0
  14. package/esm/ai/src/errors/planner-drift-error.mjs.map +1 -0
  15. package/esm/ai/src/image/image-cost.mjs +55 -0
  16. package/esm/ai/src/image/image-cost.mjs.map +1 -0
  17. package/esm/ai/src/image/image.mjs +112 -0
  18. package/esm/ai/src/image/image.mjs.map +1 -0
  19. package/esm/ai/src/image/index.mjs +4 -0
  20. package/esm/ai/src/index.mjs +20 -0
  21. package/esm/ai/src/planner/planner-run.mjs +161 -6
  22. package/esm/ai/src/planner/planner-run.mjs.map +1 -1
  23. package/esm/ai/src/planner/planner.mjs +25 -1
  24. package/esm/ai/src/planner/planner.mjs.map +1 -1
  25. package/esm/ai/src/planner/snapshot.mjs +95 -0
  26. package/esm/ai/src/planner/snapshot.mjs.map +1 -0
  27. package/esm/ai/src/rag/hybrid/bm25.mjs +51 -0
  28. package/esm/ai/src/rag/hybrid/bm25.mjs.map +1 -0
  29. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs +29 -0
  30. package/esm/ai/src/rag/hybrid/hybrid-rank.mjs.map +1 -0
  31. package/esm/ai/src/rag/hybrid/rrf.mjs +30 -0
  32. package/esm/ai/src/rag/hybrid/rrf.mjs.map +1 -0
  33. package/esm/ai/src/rag/index.mjs +11 -0
  34. package/esm/ai/src/rag/loaders/errors.mjs +25 -0
  35. package/esm/ai/src/rag/loaders/errors.mjs.map +1 -0
  36. package/esm/ai/src/rag/loaders/index.mjs +7 -0
  37. package/esm/ai/src/rag/loaders/load-html.mjs +138 -0
  38. package/esm/ai/src/rag/loaders/load-html.mjs.map +1 -0
  39. package/esm/ai/src/rag/loaders/load-pdf.mjs +150 -0
  40. package/esm/ai/src/rag/loaders/load-pdf.mjs.map +1 -0
  41. package/esm/ai/src/rag/loaders/load-text.mjs +60 -0
  42. package/esm/ai/src/rag/loaders/load-text.mjs.map +1 -0
  43. package/esm/ai/src/rag/loaders/load-web.mjs +89 -0
  44. package/esm/ai/src/rag/loaders/load-web.mjs.map +1 -0
  45. package/esm/ai/src/rag/store/pg-vector-store.mjs +328 -0
  46. package/esm/ai/src/rag/store/pg-vector-store.mjs.map +1 -0
  47. package/esm/ai/src/rag/transforms/multi-query.mjs +41 -0
  48. package/esm/ai/src/rag/transforms/multi-query.mjs.map +1 -0
  49. package/esm/ai/src/speech/index.mjs +3 -0
  50. package/esm/ai/src/speech/speech.mjs +122 -0
  51. package/esm/ai/src/speech/speech.mjs.map +1 -0
  52. package/esm/ai/src/supervisor/entries.mjs +2 -2
  53. package/esm/ai/src/supervisor/entries.mjs.map +1 -1
  54. package/esm/ai/src/transcribe/audio-input.mjs +84 -0
  55. package/esm/ai/src/transcribe/audio-input.mjs.map +1 -0
  56. package/esm/ai/src/transcribe/index.mjs +4 -0
  57. package/esm/ai/src/transcribe/transcribe.mjs +127 -0
  58. package/esm/ai/src/transcribe/transcribe.mjs.map +1 -0
  59. package/esm/ai-openai/src/image.mjs +5 -0
  60. package/esm/ai-openai/src/index.mjs +3 -0
  61. package/esm/ai-openai/src/sdk.mjs +3 -0
  62. package/esm/ai-openai/src/speech.mjs +5 -0
  63. package/esm/ai-openai/src/transcription.mjs +6 -0
  64. package/esm/ai-openai/src/utils/index.mjs +1 -0
  65. package/esm/ai-openai/src/utils/to-openai-messages.mjs +3 -0
  66. package/esm/bootstrap.d.mts.map +1 -1
  67. package/esm/bootstrap.mjs +3 -1
  68. package/esm/bootstrap.mjs.map +1 -1
  69. package/esm/cli/commands/doctor/checks/config.check.mjs +42 -0
  70. package/esm/cli/commands/doctor/checks/config.check.mjs.map +1 -0
  71. package/esm/cli/commands/doctor/checks/connectors.check.mjs +28 -0
  72. package/esm/cli/commands/doctor/checks/connectors.check.mjs.map +1 -0
  73. package/esm/cli/commands/doctor/checks/health.check.mjs +35 -0
  74. package/esm/cli/commands/doctor/checks/health.check.mjs.map +1 -0
  75. package/esm/cli/commands/doctor/checks/index.mjs +25 -0
  76. package/esm/cli/commands/doctor/checks/index.mjs.map +1 -0
  77. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs +90 -0
  78. package/esm/cli/commands/doctor/checks/optional-peers.check.mjs.map +1 -0
  79. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs +69 -0
  80. package/esm/cli/commands/doctor/checks/release-hygiene.check.mjs.map +1 -0
  81. package/esm/cli/commands/doctor/checks/routes.check.mjs +30 -0
  82. package/esm/cli/commands/doctor/checks/routes.check.mjs.map +1 -0
  83. package/esm/cli/commands/doctor/doctor-command.action.mjs +28 -0
  84. package/esm/cli/commands/doctor/doctor-command.action.mjs.map +1 -0
  85. package/esm/cli/commands/doctor/format-report.mjs +44 -0
  86. package/esm/cli/commands/doctor/format-report.mjs.map +1 -0
  87. package/esm/cli/commands/doctor/run-checks.mjs +50 -0
  88. package/esm/cli/commands/doctor/run-checks.mjs.map +1 -0
  89. package/esm/cli/commands/doctor.command.mjs +29 -0
  90. package/esm/cli/commands/doctor.command.mjs.map +1 -0
  91. package/esm/cli/commands/generate/templates/stubs.mjs +6 -8
  92. package/esm/cli/commands/generate/templates/stubs.mjs.map +1 -1
  93. package/esm/cli/commands/routes/format-routes-table.mjs +129 -0
  94. package/esm/cli/commands/routes/format-routes-table.mjs.map +1 -0
  95. package/esm/cli/commands/routes/route-row.mjs +92 -0
  96. package/esm/cli/commands/routes/route-row.mjs.map +1 -0
  97. package/esm/cli/commands/routes/routes-command.action.mjs +43 -0
  98. package/esm/cli/commands/routes/routes-command.action.mjs.map +1 -0
  99. package/esm/cli/commands/routes.command.mjs +51 -0
  100. package/esm/cli/commands/routes.command.mjs.map +1 -0
  101. package/esm/cli/commands/seed.command.mjs +5 -0
  102. package/esm/cli/commands/seed.command.mjs.map +1 -1
  103. package/esm/cli/framework-cli-commands.mjs +4 -0
  104. package/esm/cli/framework-cli-commands.mjs.map +1 -1
  105. package/esm/config/config-getter.mjs +5 -5
  106. package/esm/config/config-getter.mjs.map +1 -1
  107. package/esm/config/config-loader.mjs +2 -2
  108. package/esm/config/config-loader.mjs.map +1 -1
  109. package/esm/connectors/access-connector.mjs +2 -2
  110. package/esm/connectors/access-connector.mjs.map +1 -1
  111. package/esm/connectors/ai-connector.mjs +2 -2
  112. package/esm/connectors/ai-connector.mjs.map +1 -1
  113. package/esm/connectors/cache-connector.mjs +2 -2
  114. package/esm/connectors/cache-connector.mjs.map +1 -1
  115. package/esm/connectors/database-connector.mjs +2 -2
  116. package/esm/connectors/database-connector.mjs.map +1 -1
  117. package/esm/connectors/herald-connector.mjs +2 -2
  118. package/esm/connectors/herald-connector.mjs.map +1 -1
  119. package/esm/connectors/http-connector.d.mts.map +1 -1
  120. package/esm/connectors/http-connector.mjs +9 -7
  121. package/esm/connectors/http-connector.mjs.map +1 -1
  122. package/esm/connectors/logger-connector.mjs +2 -2
  123. package/esm/connectors/logger-connector.mjs.map +1 -1
  124. package/esm/connectors/mail-connector.mjs +2 -2
  125. package/esm/connectors/mail-connector.mjs.map +1 -1
  126. package/esm/connectors/notifications-connector.mjs +2 -2
  127. package/esm/connectors/notifications-connector.mjs.map +1 -1
  128. package/esm/connectors/socket-connector.mjs +3 -3
  129. package/esm/connectors/socket-connector.mjs.map +1 -1
  130. package/esm/database/index.d.mts +2 -1
  131. package/esm/database/index.mjs +1 -0
  132. package/esm/database/seed-command-action.mjs +44 -4
  133. package/esm/database/seed-command-action.mjs.map +1 -1
  134. package/esm/database/seeds/seed-records-table-migration.mjs +36 -0
  135. package/esm/database/seeds/seed-records-table-migration.mjs.map +1 -0
  136. package/esm/database/seeds/seeder.d.mts +22 -5
  137. package/esm/database/seeds/seeder.d.mts.map +1 -1
  138. package/esm/database/seeds/seeder.errors.d.mts +22 -0
  139. package/esm/database/seeds/seeder.errors.d.mts.map +1 -0
  140. package/esm/database/seeds/seeder.errors.mjs +29 -0
  141. package/esm/database/seeds/seeder.errors.mjs.map +1 -0
  142. package/esm/database/seeds/seeder.mjs.map +1 -1
  143. package/esm/database/seeds/seeders.manager.mjs +90 -11
  144. package/esm/database/seeds/seeders.manager.mjs.map +1 -1
  145. package/esm/database/seeds/types.d.mts +117 -1
  146. package/esm/database/seeds/types.d.mts.map +1 -1
  147. package/esm/database/seeds/utils.mjs +6 -1
  148. package/esm/database/seeds/utils.mjs.map +1 -1
  149. package/esm/dev-server/module-loader.d.mts +12 -0
  150. package/esm/dev-server/module-loader.d.mts.map +1 -1
  151. package/esm/dev-server/module-loader.mjs +30 -2
  152. package/esm/dev-server/module-loader.mjs.map +1 -1
  153. package/esm/http/config.mjs +2 -2
  154. package/esm/http/config.mjs.map +1 -1
  155. package/esm/http/createHttpApplication.mjs +2 -2
  156. package/esm/http/createHttpApplication.mjs.map +1 -1
  157. package/esm/http/health.d.mts +14 -0
  158. package/esm/http/health.d.mts.map +1 -1
  159. package/esm/http/health.mjs +16 -0
  160. package/esm/http/health.mjs.map +1 -1
  161. package/esm/http/middleware/idempotency.middleware.mjs +5 -5
  162. package/esm/http/middleware/idempotency.middleware.mjs.map +1 -1
  163. package/esm/http/middleware/inject-request-context.mjs +2 -2
  164. package/esm/http/middleware/inject-request-context.mjs.map +1 -1
  165. package/esm/http/middleware/maintenance.middleware.mjs +4 -4
  166. package/esm/http/middleware/maintenance.middleware.mjs.map +1 -1
  167. package/esm/http/plugins.mjs +9 -9
  168. package/esm/http/plugins.mjs.map +1 -1
  169. package/esm/http/response.mjs +5 -5
  170. package/esm/http/response.mjs.map +1 -1
  171. package/esm/http/server.mjs +4 -4
  172. package/esm/http/server.mjs.map +1 -1
  173. package/esm/index.d.mts +4 -3
  174. package/esm/index.mjs +2 -1
  175. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts +28 -1
  176. package/esm/repositories/adapters/cascade/cascade-query-builder.d.mts.map +1 -1
  177. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs +39 -0
  178. package/esm/repositories/adapters/cascade/cascade-query-builder.mjs.map +1 -1
  179. package/esm/repositories/contracts/index.d.mts +1 -1
  180. package/esm/repositories/contracts/query-builder.contract.d.mts +87 -1
  181. package/esm/repositories/contracts/query-builder.contract.d.mts.map +1 -1
  182. package/esm/repositories/index.d.mts +1 -1
  183. package/esm/repositories/repository.manager.d.mts +99 -1
  184. package/esm/repositories/repository.manager.d.mts.map +1 -1
  185. package/esm/repositories/repository.manager.mjs +128 -0
  186. package/esm/repositories/repository.manager.mjs.map +1 -1
  187. package/esm/router/router.d.mts +9 -0
  188. package/esm/router/router.d.mts.map +1 -1
  189. package/esm/router/router.mjs +21 -1
  190. package/esm/router/router.mjs.map +1 -1
  191. package/esm/utils/paths.mjs +2 -2
  192. package/esm/utils/paths.mjs.map +1 -1
  193. package/esm/validation/validateAll.mjs +2 -2
  194. package/esm/validation/validateAll.mjs.map +1 -1
  195. package/llms-full.txt +427 -45
  196. package/llms.txt +4 -2
  197. package/package.json +9 -9
  198. package/skills/README.md +65 -0
  199. package/skills/health-checks/SKILL.md +13 -0
  200. package/skills/use-repository/SKILL.md +38 -1
  201. package/skills/warlock-doctor/SKILL.md +135 -0
  202. package/skills/warlock-routes/SKILL.md +91 -0
  203. package/skills/write-seeder/SKILL.md +143 -45
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.mjs","names":[],"sources":["../../../../../../../../../../@warlock.js/core/src/cli/commands/generate/templates/stubs.ts"],"sourcesContent":["import type { ParsedName } from \"../types\";\nimport { Name } from \"../utils/name-parser\";\n\n/**\n * Controller template stub\n *\n * Controllers default to the guarded handler type since application\n * routes run behind `guarded()`. When `withValidation` is set, the\n * schema's exported type + value are imported directly from the\n * `schema/` folder and bound to the handler — no `requests/` alias.\n */\nexport function controllerStub(\n name: ParsedName,\n options: { withValidation?: boolean } = {},\n): string {\n const { withValidation } = options;\n\n if (!withValidation) {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler = async (request, response) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n`;\n }\n\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type ${name.pascal}Schema, ${name.camel}Schema } from \"../schema/${name.kebab}.schema\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler<${name.pascal}Schema> = async (\n request,\n response,\n) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n\n${name.camel}Controller.validation = {\n schema: ${name.camel}Schema,\n};\n`;\n}\n\n/**\n * CRUD Create Controller template\n * Note: moduleName is the module (plural), we need singular entity name\n */\nexport function crudCreateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Create${moduleName.pascal}Schema, create${moduleName.pascal}Schema } from \"../schema/create-${moduleName.kebab}.schema\";\nimport { create${moduleName.pascal}Service } from \"../services/create-${moduleName.kebab}.service\";\n\nexport const create${moduleName.pascal}Controller: GuardedRequestHandler<Create${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await create${moduleName.pascal}Service(request.validated());\n\n return response.successCreate({\n ${moduleName.camel},\n });\n};\n\ncreate${moduleName.pascal}Controller.validation = {\n schema: create${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD Update Controller template\n */\nexport function crudUpdateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Update${moduleName.pascal}Schema, update${moduleName.pascal}Schema } from \"../schema/update-${moduleName.kebab}.schema\";\nimport { update${moduleName.pascal}Service } from \"../services/update-${moduleName.kebab}.service\";\n\nexport const update${moduleName.pascal}Controller: GuardedRequestHandler<Update${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await update${moduleName.pascal}Service(request.input(\"id\"), request.validated());\n\n return response.success({\n ${moduleName.camel},\n });\n};\n\nupdate${moduleName.pascal}Controller.validation = {\n schema: update${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD List Controller template\n */\nexport function crudListControllerStub(moduleName: Name): string {\n const plural = moduleName.plural;\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { list${plural.pascal}Service } from \"../services/list-${plural.kebab}.service\";\n\nexport const list${plural.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const { data, pagination } = await list${plural.pascal}Service(request.all());\n\n return response.success({\n data,\n pagination,\n });\n};\n`;\n}\n\n/**\n * CRUD Show/Get Controller template\n */\nexport function crudShowControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { get${moduleName.pascal}Service } from \"../services/get-${moduleName.kebab}.service\";\n\nexport const get${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await get${moduleName.pascal}Service(request.input(\"id\"));\n\n if (!${moduleName.camel}) {\n return response.notFound();\n }\n\n return response.success({\n ${moduleName.camel},\n });\n};\n`;\n}\n\n/**\n * CRUD Delete Controller template\n */\nexport function crudDeleteControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { delete${moduleName.pascal}Service } from \"../services/delete-${moduleName.kebab}.service\";\n\nexport const delete${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n await delete${moduleName.pascal}Service(request.input(\"id\"));\n\n return response.noContent();\n};\n`;\n}\n\n/**\n * CRUD Routes template\n */\nexport function crudRoutesStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { router } from \"@warlock.js/core\";\nimport { guarded } from \"app/shared/utils/router\";\nimport { create${singular.pascal}Controller } from \"./controllers/create-${singular.kebab}.controller\";\nimport { delete${singular.pascal}Controller } from \"./controllers/delete-${singular.kebab}.controller\";\nimport { get${singular.pascal}Controller } from \"./controllers/get-${singular.kebab}.controller\";\nimport { list${plural.pascal}Controller } from \"./controllers/list-${plural.kebab}.controller\";\nimport { update${singular.pascal}Controller } from \"./controllers/update-${singular.kebab}.controller\";\n\nguarded(() => {\n router\n .route(\"/${plural.kebab}\")\n .list(list${plural.pascal}Controller)\n .show(get${singular.pascal}Controller)\n .create(create${singular.pascal}Controller)\n .update(update${singular.pascal}Controller)\n .destroy(delete${singular.pascal}Controller);\n});\n`;\n}\n\n/**\n * CRUD Model template\n */\nexport function crudModelStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { Model, RegisterModel } from \"@warlock.js/cascade\";\nimport { type Infer, v } from \"@warlock.js/seal\";\nimport { ${singular.pascal}Resource } from \"app/${plural.kebab}/resources/${singular.kebab}.resource\";\n\nexport const ${singular.camel}Schema = v.object({\n // TODO: Add more fields\n});\n\nexport type ${singular.pascal}Schema = Infer.Output<typeof ${singular.camel}Schema>;\n\n@RegisterModel()\nexport class ${singular.pascal} extends Model<${singular.pascal}Schema> {\n public static table = \"${plural.snake}\";\n\n public static schema = ${singular.camel}Schema;\n\n public static relations = {};\n\n public static resource = ${singular.pascal}Resource;\n}\n`;\n}\n\n/**\n * CRUD Resource template\n */\nexport function crudResourceStub(moduleName: Name): string {\n // Get singular entity name\n const entity = moduleName.singular;\n\n return `import { defineResource } from \"@warlock.js/core\";\n\nexport const ${entity.pascal}Resource = defineResource({\n schema: {\n id: \"number\",\n // TODO: Add more resource fields\n },\n});\n`;\n}\n\n/**\n * CRUD Repository template\n */\nexport function crudRepositoryStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n const modulePluralName = entity.plural;\n return `import type { FilterRules, TypedRepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\n\ntype ${moduleSingularName.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${moduleSingularName.pascal}ListOptions = TypedRepositoryOptions<${moduleSingularName.pascal}ListFilter>;\n\nclass ${modulePluralName.pascal}Repository extends RepositoryManager<${moduleSingularName.pascal}, ${moduleSingularName.pascal}ListOptions> {\n public source = ${moduleSingularName.pascal};\n\n public simpleSelectColumns: string[] = [\"id\"];\n\n public filterBy: FilterRules = {\n id: \"=\",\n };\n\n public defaultOptions: RepositoryOptions = {\n orderBy: {\n id: \"desc\",\n },\n };\n}\n\nexport const ${modulePluralName.camel}Repository = new ${modulePluralName.pascal}Repository();\n`;\n}\n\n/**\n * CRUD Create Service template\n */\nexport function crudCreateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\nimport type { Create${moduleSingularName.pascal}Schema } from \"../schema/create-${moduleSingularName.kebab}.schema\";\n\nexport async function create${moduleSingularName.pascal}Service(data: Create${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await ${moduleSingularName.pascal}.create(data);\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD Update Service template\n */\nexport function crudUpdateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${moduleSingularName.pascal}Service } from \"./get-${moduleSingularName.kebab}.service\";\nimport type { Update${moduleSingularName.pascal}Schema } from \"../schema/update-${moduleSingularName.kebab}.schema\";\n\nexport async function update${moduleSingularName.pascal}Service(id: number | string, data: Update${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await get${moduleSingularName.pascal}Service(id);\n\n await ${moduleSingularName.camel}.save({ merge: data });\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD List Service template\n */\nexport function crudListServiceStub(entity: Name): string {\n const modulePluralName = entity.plural;\n return `import { ${modulePluralName.camel}Repository } from \"../repositories/${modulePluralName.kebab}.repository\";\n\nexport async function list${modulePluralName.pascal}Service(filters: any) {\n return ${modulePluralName.camel}Repository.listCached(filters);\n}\n`;\n}\n\n/**\n * CRUD Get Service template\n */\nexport function crudGetServiceStub(entity: Name): string {\n return `import { ${entity.plural.camel}Repository } from \"../repositories/${entity.plural.kebab}.repository\";\nimport { ResourceNotFoundError } from \"@warlock.js/core\";\n\nexport async function get${entity.singular.pascal}Service(id: number | string) {\n const ${entity.singular.camel} = await ${entity.plural.camel}Repository.getCached(id);\n\n if (!${entity.singular.camel}) {\n throw new ResourceNotFoundError(\"${entity.singular.pascal} resource not found!\");\n }\n\n return ${entity.singular.camel};\n}\n`;\n}\n\n/**\n * CRUD Delete Service template\n */\nexport function crudDeleteServiceStub(entity: Name): string {\n const singular = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${singular.pascal}Service } from \"./get-${singular.kebab}.service\";\n\nexport async function delete${singular.pascal}Service(id: number | string) {\n const ${singular.camel} = await get${singular.pascal}Service(id);\n if (!${singular.camel}) {\n throw new ResourceNotFoundError(\"${singular.pascal} not found\");\n }\n await ${singular.camel}.destroy();\n}\n`;\n}\n\n/**\n * CRUD Seed template\n */\nexport function crudSeedStub(entity: Name): string {\n return `import { seeder } from \"@warlock.js/core\";\nimport { ${entity.singular.pascal} } from \"../models/${entity.singular.kebab}\";\n\nexport default seeder({\n name: \"Seed ${entity.plural.pascal}\",\n once: true,\n enabled: true,\n run: async () => {\n const total = 10;\n for (let i = 0; i < total; i++) {\n await ${entity.singular.pascal}.create({\n // TODO: Add more fields\n });\n }\n\n return {\n recordsCreated: total,\n };\n },\n});\n`;\n}\n\n/**\n * Migration template\n */\n/**\n * Migration Create template\n */\nexport function migrationStub(\n entityName: ParsedName,\n options: {\n columns?: string;\n imports?: string[];\n timestamps?: boolean;\n tableName?: string;\n } = {},\n): string {\n const { columns = \"\", imports = [], timestamps = true } = options;\n\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n let optionsString = \"\";\n if (timestamps === false) {\n optionsString = `, { timestamps: false }`;\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.create(${entityName.pascal}, {\n${columns ? columns : \" // add your columns here, id is auto added to the list\"}\n}${optionsString});\n`;\n}\n\n/**\n * Migration Alter template\n */\nexport function migrationAlterStub(\n entityName: ParsedName,\n options: {\n add?: string;\n drop?: string; // stringified array like `\"[\\\"col1\\\", \\\"col2\\\"]\"`\n rename?: string; // stringified object like `{ old: \"new\" }`\n imports?: string[];\n } = {},\n): string {\n const { add = \"\", drop, rename, imports = [] } = options;\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n // Build the schema object dynamically\n const schemaParts: string[] = [];\n\n if (add) {\n schemaParts.push(` add: {\\n${add}\\n },`);\n }\n\n if (drop) {\n schemaParts.push(` drop: ${drop},`);\n }\n\n if (rename) {\n schemaParts.push(` rename: ${rename},`);\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.alter(${entityName.pascal}, {\n${schemaParts.join(\"\\n\")}\n});\n`;\n}\n\n/**\n * CRUD Create Schema template\n * Outputs to: schema/create-{entity}.schema.ts\n */\nexport function crudCreateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const create${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Create${moduleName.pascal}Schema = Infer<typeof create${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * CRUD Update Schema template\n * Outputs to: schema/update-{entity}.schema.ts\n */\nexport function crudUpdateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const update${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Update${moduleName.pascal}Schema = Infer<typeof update${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * Service template stub\n */\nexport function serviceStub(name: Name): string {\n return `export async function ${name.camel}Service(data: any): Promise<any> {\n // TODO: Implement service logic\n throw new Error(\"${name.camel}Service not implemented\");\n}\n`;\n}\n\n/**\n * Schema template stub\n * Outputs to: schema/{name}.schema.ts\n */\nexport function schemaStub(name: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const ${name.camel}Schema = v.object({\n // TODO: Define validation schema\n});\n\nexport type ${name.pascal}Schema = Infer<typeof ${name.camel}Schema>;\n`;\n}\n\n/**\n * Model template stub\n */\nexport function modelStub(\n name: Name,\n options: { tableName?: string; withResource?: boolean } = {},\n): string {\n const { tableName = `${name.plural.snake}`, withResource } = options;\n\n return `import { Model, type StrictMode } from \"@warlock.js/cascade\";\nimport { v, type Infer } from \"@warlock.js/seal\";\n${withResource ? `import { ${name.singular.pascal}Resource } from \"../../resources/${name.singular.kebab}.resource\";` : \"\"}\n\nconst ${name.singular.camel}Schema = v.object({\n // TODO: Define model schema\n});\n\nexport type ${name.singular.pascal}Type = Infer.Output<typeof ${name.singular.camel}Schema>;\n\nexport class ${name.singular.pascal} extends Model<${name.singular.pascal}Type> {\n public static table = \"${tableName}\";\n public static strictMode: StrictMode = \"fail\";\n${withResource ? ` public static resource = ${name.singular.pascal}Resource;` : \"\"}\n\n public static schema = ${name.singular.camel}Schema;\n\n public static relations = {\n // TODO: Define relations\n };\n}\n`;\n}\n\n/**\n * Repository template stub\n */\nexport function repositoryStub(name: Name): string {\n return `import type { FilterByOptions, RepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${name.singular.pascal} } from \"../models/${name.singular.kebab}\";\n\ntype ${name.singular.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${name.singular.pascal}ListOptions = RepositoryOptions & ${name.singular.pascal}ListFilter;\n\nexport class ${name.plural.pascal}Repository extends RepositoryManager<${name.singular.pascal}, ${name.singular.pascal}ListFilter> {\n public source = ${name.singular.pascal};\n\n protected defaultOptions: RepositoryOptions = this.withDefaultOptions({});\n\n protected filterBy: FilterByOptions = this.withDefaultFilters({\n name: \"like\",\n });\n}\n\nexport const ${name.plural.camel}Repository = new ${name.plural.pascal}Repository();\n`;\n}\n\n/**\n * Resource template stub\n */\nexport function resourceStub(name: Name): string {\n return `import { Resource } from \"@warlock.js/core\";\n\nexport class ${name.singular.pascal}Resource extends Resource {\n public schema = {\n id: \"int\",\n name: \"string\",\n // TODO: Define resource schema\n };\n}\n`;\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,eACd,MACA,UAAwC,CAAC,GACjC;CACR,MAAM,EAAE,mBAAmB;CAE3B,IAAI,CAAC,gBACH,OAAO;;eAEI,KAAK,MAAM;;;;;CAOxB,OAAO;gBACO,KAAK,OAAO,UAAU,KAAK,MAAM,2BAA2B,KAAK,MAAM;;eAExE,KAAK,MAAM,oCAAoC,KAAK,OAAO;;;;;;;;EAQxE,KAAK,MAAM;YACD,KAAK,MAAM;;;AAGvB;;;;;AAMA,SAAgB,yBAAyB,YAA0B;CACjE,OAAO;sBACa,WAAW,OAAO,gBAAgB,WAAW,OAAO,kCAAkC,WAAW,MAAM;iBAC5G,WAAW,OAAO,qCAAqC,WAAW,MAAM;;qBAEpE,WAAW,OAAO,0CAA0C,WAAW,OAAO;;;;UAIzF,WAAW,MAAM,iBAAiB,WAAW,OAAO;;;MAGxD,WAAW,MAAM;;;;QAIf,WAAW,OAAO;kBACR,WAAW,OAAO;;;AAGpC;;;;AAKA,SAAgB,yBAAyB,YAA0B;CACjE,OAAO;sBACa,W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AAS,OAAO,iBAAiB,KAAK,SAAS,OAAO;2BAC/C,UAAU;;EAEnC,eAAe,8BAA8B,KAAK,SAAS,OAAO,aAAa,GAAG;;2BAEzD,KAAK,SAAS,MAAM;;;;;;;AAO/C;;;;AAKA,SAAgB,eAAe,MAAoB;CACjD,OAAO;;WAEE,KAAK,SAAS,OAAO,qBAAqB,KAAK,SAAS,MAAM;;OAElE,KAAK,SAAS,OAAO;;;;cAId,KAAK,SAAS,OAAO,oCAAoC,KAAK,SAAS,OAAO;;eAE7E,KAAK,OAAO,OAAO,uCAAuC,KAAK,SAAS,OAAO,IAAI,KAAK,SAAS,OAAO;oBACnG,KAAK,SAAS,OAAO;;;;;;;;;eAS1B,KAAK,OAAO,MAAM,mBAAmB,KAAK,OAAO,OAAO;;AAEvE;;;;AAKA,SAAgB,aAAa,MAAoB;CAC/C,OAAO;;eAEM,KAAK,SAAS,OAAO;;;;;;;;AAQpC"}
1
+ {"version":3,"file":"stubs.mjs","names":[],"sources":["../../../../../../../../../../@warlock.js/core/src/cli/commands/generate/templates/stubs.ts"],"sourcesContent":["import type { ParsedName } from \"../types\";\nimport { Name } from \"../utils/name-parser\";\n\n/**\n * Controller template stub\n *\n * Controllers default to the guarded handler type since application\n * routes run behind `guarded()`. When `withValidation` is set, the\n * schema's exported type + value are imported directly from the\n * `schema/` folder and bound to the handler — no `requests/` alias.\n */\nexport function controllerStub(\n name: ParsedName,\n options: { withValidation?: boolean } = {},\n): string {\n const { withValidation } = options;\n\n if (!withValidation) {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler = async (request, response) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n`;\n }\n\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type ${name.pascal}Schema, ${name.camel}Schema } from \"../schema/${name.kebab}.schema\";\n\nexport const ${name.camel}Controller: GuardedRequestHandler<${name.pascal}Schema> = async (\n request,\n response,\n) => {\n // TODO: Implement controller logic\n return response.success({});\n};\n\n${name.camel}Controller.validation = {\n schema: ${name.camel}Schema,\n};\n`;\n}\n\n/**\n * CRUD Create Controller template\n * Note: moduleName is the module (plural), we need singular entity name\n */\nexport function crudCreateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Create${moduleName.pascal}Schema, create${moduleName.pascal}Schema } from \"../schema/create-${moduleName.kebab}.schema\";\nimport { create${moduleName.pascal}Service } from \"../services/create-${moduleName.kebab}.service\";\n\nexport const create${moduleName.pascal}Controller: GuardedRequestHandler<Create${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await create${moduleName.pascal}Service(request.validated());\n\n return response.successCreate({\n ${moduleName.camel},\n });\n};\n\ncreate${moduleName.pascal}Controller.validation = {\n schema: create${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD Update Controller template\n */\nexport function crudUpdateControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { type Update${moduleName.pascal}Schema, update${moduleName.pascal}Schema } from \"../schema/update-${moduleName.kebab}.schema\";\nimport { update${moduleName.pascal}Service } from \"../services/update-${moduleName.kebab}.service\";\n\nexport const update${moduleName.pascal}Controller: GuardedRequestHandler<Update${moduleName.pascal}Schema> = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await update${moduleName.pascal}Service(request.input(\"id\"), request.validated());\n\n return response.success({\n ${moduleName.camel},\n });\n};\n\nupdate${moduleName.pascal}Controller.validation = {\n schema: update${moduleName.pascal}Schema,\n};\n`;\n}\n\n/**\n * CRUD List Controller template\n */\nexport function crudListControllerStub(moduleName: Name): string {\n const plural = moduleName.plural;\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { list${plural.pascal}Service } from \"../services/list-${plural.kebab}.service\";\n\nexport const list${plural.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const { data, pagination } = await list${plural.pascal}Service(request.all());\n\n return response.success({\n data,\n pagination,\n });\n};\n`;\n}\n\n/**\n * CRUD Show/Get Controller template\n */\nexport function crudShowControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { get${moduleName.pascal}Service } from \"../services/get-${moduleName.kebab}.service\";\n\nexport const get${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n const ${moduleName.camel} = await get${moduleName.pascal}Service(request.input(\"id\"));\n\n if (!${moduleName.camel}) {\n return response.notFound();\n }\n\n return response.success({\n ${moduleName.camel},\n });\n};\n`;\n}\n\n/**\n * CRUD Delete Controller template\n */\nexport function crudDeleteControllerStub(moduleName: Name): string {\n return `import { type GuardedRequestHandler } from \"app/auth/requests/guarded.request\";\nimport { delete${moduleName.pascal}Service } from \"../services/delete-${moduleName.kebab}.service\";\n\nexport const delete${moduleName.pascal}Controller: GuardedRequestHandler = async (\n request,\n response,\n) => {\n await delete${moduleName.pascal}Service(request.input(\"id\"));\n\n return response.noContent();\n};\n`;\n}\n\n/**\n * CRUD Routes template\n */\nexport function crudRoutesStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { router } from \"@warlock.js/core\";\nimport { guarded } from \"app/shared/utils/router\";\nimport { create${singular.pascal}Controller } from \"./controllers/create-${singular.kebab}.controller\";\nimport { delete${singular.pascal}Controller } from \"./controllers/delete-${singular.kebab}.controller\";\nimport { get${singular.pascal}Controller } from \"./controllers/get-${singular.kebab}.controller\";\nimport { list${plural.pascal}Controller } from \"./controllers/list-${plural.kebab}.controller\";\nimport { update${singular.pascal}Controller } from \"./controllers/update-${singular.kebab}.controller\";\n\nguarded(() => {\n router\n .route(\"/${plural.kebab}\")\n .list(list${plural.pascal}Controller)\n .show(get${singular.pascal}Controller)\n .create(create${singular.pascal}Controller)\n .update(update${singular.pascal}Controller)\n .destroy(delete${singular.pascal}Controller);\n});\n`;\n}\n\n/**\n * CRUD Model template\n */\nexport function crudModelStub(moduleName: Name): string {\n const singular = moduleName.singular;\n const plural = moduleName.plural;\n\n return `import { Model, RegisterModel } from \"@warlock.js/cascade\";\nimport { type Infer, v } from \"@warlock.js/seal\";\nimport { ${singular.pascal}Resource } from \"app/${plural.kebab}/resources/${singular.kebab}.resource\";\n\nexport const ${singular.camel}Schema = v.object({\n // TODO: Add more fields\n});\n\nexport type ${singular.pascal}Schema = Infer.Output<typeof ${singular.camel}Schema>;\n\n@RegisterModel()\nexport class ${singular.pascal} extends Model<${singular.pascal}Schema> {\n public static table = \"${plural.snake}\";\n\n public static schema = ${singular.camel}Schema;\n\n public static relations = {};\n\n public static resource = ${singular.pascal}Resource;\n}\n`;\n}\n\n/**\n * CRUD Resource template\n */\nexport function crudResourceStub(moduleName: Name): string {\n // Get singular entity name\n const entity = moduleName.singular;\n\n return `import { defineResource } from \"@warlock.js/core\";\n\nexport const ${entity.pascal}Resource = defineResource({\n schema: {\n id: \"number\",\n // TODO: Add more resource fields\n },\n});\n`;\n}\n\n/**\n * CRUD Repository template\n */\nexport function crudRepositoryStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n const modulePluralName = entity.plural;\n return `import type { FilterRules, TypedRepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\n\ntype ${moduleSingularName.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${moduleSingularName.pascal}ListOptions = TypedRepositoryOptions<${moduleSingularName.pascal}ListFilter>;\n\nclass ${modulePluralName.pascal}Repository extends RepositoryManager<${moduleSingularName.pascal}, ${moduleSingularName.pascal}ListOptions> {\n public source = ${moduleSingularName.pascal};\n\n public simpleSelectColumns: string[] = [\"id\"];\n\n public filterBy: FilterRules = {\n id: \"=\",\n };\n\n public defaultOptions: RepositoryOptions = {\n orderBy: {\n id: \"desc\",\n },\n };\n}\n\nexport const ${modulePluralName.camel}Repository = new ${modulePluralName.pascal}Repository();\n`;\n}\n\n/**\n * CRUD Create Service template\n */\nexport function crudCreateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ${moduleSingularName.pascal} } from \"../models/${moduleSingularName.kebab}\";\nimport type { Create${moduleSingularName.pascal}Schema } from \"../schema/create-${moduleSingularName.kebab}.schema\";\n\nexport async function create${moduleSingularName.pascal}Service(data: Create${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await ${moduleSingularName.pascal}.create(data);\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD Update Service template\n */\nexport function crudUpdateServiceStub(entity: Name): string {\n const moduleSingularName = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${moduleSingularName.pascal}Service } from \"./get-${moduleSingularName.kebab}.service\";\nimport type { Update${moduleSingularName.pascal}Schema } from \"../schema/update-${moduleSingularName.kebab}.schema\";\n\nexport async function update${moduleSingularName.pascal}Service(id: number | string, data: Update${moduleSingularName.pascal}Schema) {\n const ${moduleSingularName.camel} = await get${moduleSingularName.pascal}Service(id);\n\n await ${moduleSingularName.camel}.save({ merge: data });\n return ${moduleSingularName.camel};\n}\n`;\n}\n\n/**\n * CRUD List Service template\n */\nexport function crudListServiceStub(entity: Name): string {\n const modulePluralName = entity.plural;\n return `import { ${modulePluralName.camel}Repository } from \"../repositories/${modulePluralName.kebab}.repository\";\n\nexport async function list${modulePluralName.pascal}Service(filters: any) {\n return ${modulePluralName.camel}Repository.listCached(filters);\n}\n`;\n}\n\n/**\n * CRUD Get Service template\n */\nexport function crudGetServiceStub(entity: Name): string {\n return `import { ${entity.plural.camel}Repository } from \"../repositories/${entity.plural.kebab}.repository\";\nimport { ResourceNotFoundError } from \"@warlock.js/core\";\n\nexport async function get${entity.singular.pascal}Service(id: number | string) {\n const ${entity.singular.camel} = await ${entity.plural.camel}Repository.getCached(id);\n\n if (!${entity.singular.camel}) {\n throw new ResourceNotFoundError(\"${entity.singular.pascal} resource not found!\");\n }\n\n return ${entity.singular.camel};\n}\n`;\n}\n\n/**\n * CRUD Delete Service template\n */\nexport function crudDeleteServiceStub(entity: Name): string {\n const singular = entity.singular;\n return `import { ResourceNotFoundError } from \"@warlock.js/core\";\nimport { get${singular.pascal}Service } from \"./get-${singular.kebab}.service\";\n\nexport async function delete${singular.pascal}Service(id: number | string) {\n const ${singular.camel} = await get${singular.pascal}Service(id);\n if (!${singular.camel}) {\n throw new ResourceNotFoundError(\"${singular.pascal} not found\");\n }\n await ${singular.camel}.destroy();\n}\n`;\n}\n\n/**\n * CRUD Seed template\n */\nexport function crudSeedStub(entity: Name): string {\n return `import { seeder } from \"@warlock.js/core\";\nimport { ${entity.singular.pascal} } from \"../models/${entity.singular.kebab}\";\n\nexport default seeder({\n name: \"Seed ${entity.plural.pascal}\",\n once: true,\n enabled: true,\n run: async ({ track }) => {\n const total = 10;\n for (let i = 0; i < total; i++) {\n track(\n await ${entity.singular.pascal}.create({\n // TODO: Add more fields\n }),\n );\n }\n },\n});\n`;\n}\n\n/**\n * Migration template\n */\n/**\n * Migration Create template\n */\nexport function migrationStub(\n entityName: ParsedName,\n options: {\n columns?: string;\n imports?: string[];\n timestamps?: boolean;\n tableName?: string;\n } = {},\n): string {\n const { columns = \"\", imports = [], timestamps = true } = options;\n\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n let optionsString = \"\";\n if (timestamps === false) {\n optionsString = `, { timestamps: false }`;\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.create(${entityName.pascal}, {\n${columns ? columns : \" // add your columns here, id is auto added to the list\"}\n}${optionsString});\n`;\n}\n\n/**\n * Migration Alter template\n */\nexport function migrationAlterStub(\n entityName: ParsedName,\n options: {\n add?: string;\n drop?: string; // stringified array like `\"[\\\"col1\\\", \\\"col2\\\"]\"`\n rename?: string; // stringified object like `{ old: \"new\" }`\n imports?: string[];\n } = {},\n): string {\n const { add = \"\", drop, rename, imports = [] } = options;\n const allImports = [\"Migration\", ...imports].join(\", \");\n\n // Build the schema object dynamically\n const schemaParts: string[] = [];\n\n if (add) {\n schemaParts.push(` add: {\\n${add}\\n },`);\n }\n\n if (drop) {\n schemaParts.push(` drop: ${drop},`);\n }\n\n if (rename) {\n schemaParts.push(` rename: ${rename},`);\n }\n\n return `import { ${allImports} } from \"@warlock.js/cascade\";\nimport { ${entityName.pascal} } from \"../${entityName.kebab}.model\";\n\nexport default Migration.alter(${entityName.pascal}, {\n${schemaParts.join(\"\\n\")}\n});\n`;\n}\n\n/**\n * CRUD Create Schema template\n * Outputs to: schema/create-{entity}.schema.ts\n */\nexport function crudCreateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const create${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Create${moduleName.pascal}Schema = Infer<typeof create${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * CRUD Update Schema template\n * Outputs to: schema/update-{entity}.schema.ts\n */\nexport function crudUpdateSchemaStub(moduleName: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const update${moduleName.pascal}Schema = v.object({\n // TODO: Add validation rules\n});\n\nexport type Update${moduleName.pascal}Schema = Infer<typeof update${moduleName.pascal}Schema>;\n`;\n}\n\n/**\n * Service template stub\n */\nexport function serviceStub(name: Name): string {\n return `export async function ${name.camel}Service(data: any): Promise<any> {\n // TODO: Implement service logic\n throw new Error(\"${name.camel}Service not implemented\");\n}\n`;\n}\n\n/**\n * Schema template stub\n * Outputs to: schema/{name}.schema.ts\n */\nexport function schemaStub(name: Name): string {\n return `import { type Infer, v } from \"@warlock.js/seal\";\n\nexport const ${name.camel}Schema = v.object({\n // TODO: Define validation schema\n});\n\nexport type ${name.pascal}Schema = Infer<typeof ${name.camel}Schema>;\n`;\n}\n\n/**\n * Model template stub\n */\nexport function modelStub(\n name: Name,\n options: { tableName?: string; withResource?: boolean } = {},\n): string {\n const { tableName = `${name.plural.snake}`, withResource } = options;\n\n return `import { Model, type StrictMode } from \"@warlock.js/cascade\";\nimport { v, type Infer } from \"@warlock.js/seal\";\n${withResource ? `import { ${name.singular.pascal}Resource } from \"../../resources/${name.singular.kebab}.resource\";` : \"\"}\n\nconst ${name.singular.camel}Schema = v.object({\n // TODO: Define model schema\n});\n\nexport type ${name.singular.pascal}Type = Infer.Output<typeof ${name.singular.camel}Schema>;\n\nexport class ${name.singular.pascal} extends Model<${name.singular.pascal}Type> {\n public static table = \"${tableName}\";\n public static strictMode: StrictMode = \"fail\";\n${withResource ? ` public static resource = ${name.singular.pascal}Resource;` : \"\"}\n\n public static schema = ${name.singular.camel}Schema;\n\n public static relations = {\n // TODO: Define relations\n };\n}\n`;\n}\n\n/**\n * Repository template stub\n */\nexport function repositoryStub(name: Name): string {\n return `import type { FilterByOptions, RepositoryOptions } from \"@warlock.js/core\";\nimport { RepositoryManager } from \"@warlock.js/core\";\nimport { ${name.singular.pascal} } from \"../models/${name.singular.kebab}\";\n\ntype ${name.singular.pascal}ListFilter = {\n // Repository list filters\n};\n\nexport type ${name.singular.pascal}ListOptions = RepositoryOptions & ${name.singular.pascal}ListFilter;\n\nexport class ${name.plural.pascal}Repository extends RepositoryManager<${name.singular.pascal}, ${name.singular.pascal}ListFilter> {\n public source = ${name.singular.pascal};\n\n protected defaultOptions: RepositoryOptions = this.withDefaultOptions({});\n\n protected filterBy: FilterByOptions = this.withDefaultFilters({\n name: \"like\",\n });\n}\n\nexport const ${name.plural.camel}Repository = new ${name.plural.pascal}Repository();\n`;\n}\n\n/**\n * Resource template stub\n */\nexport function resourceStub(name: Name): string {\n return `import { Resource } from \"@warlock.js/core\";\n\nexport class ${name.singular.pascal}Resource extends Resource {\n public schema = {\n id: \"int\",\n name: \"string\",\n // TODO: Define resource schema\n };\n}\n`;\n}\n"],"mappings":";;;;;;;;;AAWA,SAAgB,eACd,MACA,UAAwC,CAAC,GACjC;C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"@mongez/copper";
3
+
4
+ //#region ../@warlock.js/core/src/cli/commands/routes/format-routes-table.ts
5
+ /** The columns rendered, in order, with their header labels. */
6
+ const COLUMNS = [
7
+ {
8
+ key: "method",
9
+ header: "METHOD"
10
+ },
11
+ {
12
+ key: "path",
13
+ header: "PATH"
14
+ },
15
+ {
16
+ key: "name",
17
+ header: "NAME"
18
+ },
19
+ {
20
+ key: "action",
21
+ header: "ACTION"
22
+ },
23
+ {
24
+ key: "middleware",
25
+ header: "MW"
26
+ },
27
+ {
28
+ key: "source",
29
+ header: "SOURCE"
30
+ }
31
+ ];
32
+ /** Two spaces between columns. */
33
+ const GAP = " ";
34
+ /** Shown for an empty string cell so the column doesn't read as a gap. */
35
+ const EMPTY_CELL = "—";
36
+ /**
37
+ * The plain (uncolored) text of one cell. Numbers render as-is; an empty string
38
+ * renders as {@link EMPTY_CELL}. This is the single source of truth for both
39
+ * the width math and the rendered text, so colored and uncolored output stay
40
+ * aligned.
41
+ *
42
+ * @param row - The row
43
+ * @param key - The column key
44
+ * @returns The cell's printable text
45
+ */
46
+ function cellText(row, key) {
47
+ if (key === "middleware") return String(row.middleware);
48
+ const value = row[key];
49
+ return value.length > 0 ? value : EMPTY_CELL;
50
+ }
51
+ /**
52
+ * Per-column display width: the longest of the header and every cell.
53
+ *
54
+ * @param rows - The rows to measure
55
+ * @returns One width per column, in column order
56
+ */
57
+ function columnWidths(rows) {
58
+ return COLUMNS.map((column) => Math.max(column.header.length, ...rows.map((row) => cellText(row, column.key).length)));
59
+ }
60
+ /**
61
+ * Build a one-line, human-readable summary: the total plus a per-method
62
+ * breakdown ordered by {@link methodRank}, e.g.
63
+ * `42 routes (38 GET · 2 POST · 1 PUT · 1 DELETE)`.
64
+ *
65
+ * @param rows - The rows being summarized
66
+ * @returns The summary line
67
+ */
68
+ function routesSummary(rows) {
69
+ const noun = rows.length === 1 ? "route" : "routes";
70
+ if (rows.length === 0) return `0 ${noun}`;
71
+ const counts = /* @__PURE__ */ new Map();
72
+ for (const row of rows) counts.set(row.method, (counts.get(row.method) ?? 0) + 1);
73
+ const breakdown = [...counts.entries()].sort(([a], [b]) => methodRank(a) - methodRank(b)).map(([method, count]) => `${count} ${method}`).join(" · ");
74
+ return `${rows.length} ${noun} (${breakdown})`;
75
+ }
76
+ /** Per-verb color for the METHOD column. Unknown verbs fall back to white. */
77
+ const METHOD_COLOR = {
78
+ GET: colors.green,
79
+ POST: colors.blue,
80
+ PUT: colors.yellow,
81
+ PATCH: colors.yellow,
82
+ DELETE: colors.red,
83
+ OPTIONS: colors.gray,
84
+ HEAD: colors.gray,
85
+ ALL: colors.magenta
86
+ };
87
+ /**
88
+ * Colorize the method label, then right-pad with plain spaces so column
89
+ * alignment is computed from the visible width, not the ANSI-coded length.
90
+ *
91
+ * @param method - The uppercased HTTP verb
92
+ * @param width - The METHOD column width
93
+ * @returns The colored, padded cell
94
+ */
95
+ function colorizeMethodCell(method, width) {
96
+ return (METHOD_COLOR[method] ?? colors.white)(method) + " ".repeat(Math.max(0, width - method.length));
97
+ }
98
+ /**
99
+ * Print the routes table to stdout with a bold header, verb-colored METHOD
100
+ * column, and a dimmed summary. The empty case prints a single yellow notice
101
+ * (a booted app with zero routes usually means a route module failed to load).
102
+ *
103
+ * Thin presentation wrapper over {@link formatRoutesTableLines} /
104
+ * {@link routesSummary} — those stay the source of truth for layout.
105
+ *
106
+ * @param rows - The rows to print (already filtered/sorted by the caller)
107
+ */
108
+ function printRoutesTable(rows) {
109
+ if (rows.length === 0) {
110
+ console.log(colors.yellow("No routes registered — did a route module fail to load?"));
111
+ return;
112
+ }
113
+ const widths = columnWidths(rows);
114
+ const headerLine = COLUMNS.map((column, index) => column.header.padEnd(widths[index])).join(GAP).trimEnd();
115
+ console.log(colors.bold(headerLine));
116
+ for (const row of rows) {
117
+ const cells = COLUMNS.map((column, index) => {
118
+ if (column.key === "method") return colorizeMethodCell(row.method, widths[index]);
119
+ return cellText(row, column.key).padEnd(widths[index]);
120
+ });
121
+ console.log(cells.join(GAP).trimEnd());
122
+ }
123
+ console.log("");
124
+ console.log(colors.gray(routesSummary(rows)));
125
+ }
126
+
127
+ //#endregion
128
+ export { printRoutesTable };
129
+ //# sourceMappingURL=format-routes-table.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-routes-table.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/core/src/cli/commands/routes/format-routes-table.ts"],"sourcesContent":["import { colors } from \"@mongez/copper\";\nimport { methodRank, type RouteRow } from \"./route-row\";\n\n/** The columns rendered, in order, with their header labels. */\nconst COLUMNS = [\n { key: \"method\", header: \"METHOD\" },\n { key: \"path\", header: \"PATH\" },\n { key: \"name\", header: \"NAME\" },\n { key: \"action\", header: \"ACTION\" },\n { key: \"middleware\", header: \"MW\" },\n { key: \"source\", header: \"SOURCE\" },\n] as const;\n\ntype ColumnKey = (typeof COLUMNS)[number][\"key\"];\n\n/** Two spaces between columns. */\nconst GAP = \" \";\n\n/** Shown for an empty string cell so the column doesn't read as a gap. */\nconst EMPTY_CELL = \"—\";\n\n/**\n * The plain (uncolored) text of one cell. Numbers render as-is; an empty string\n * renders as {@link EMPTY_CELL}. This is the single source of truth for both\n * the width math and the rendered text, so colored and uncolored output stay\n * aligned.\n *\n * @param row - The row\n * @param key - The column key\n * @returns The cell's printable text\n */\nfunction cellText(row: RouteRow, key: ColumnKey): string {\n if (key === \"middleware\") return String(row.middleware);\n\n const value = row[key] as string;\n\n return value.length > 0 ? value : EMPTY_CELL;\n}\n\n/**\n * Per-column display width: the longest of the header and every cell.\n *\n * @param rows - The rows to measure\n * @returns One width per column, in column order\n */\nfunction columnWidths(rows: RouteRow[]): number[] {\n return COLUMNS.map((column) =>\n Math.max(column.header.length, ...rows.map((row) => cellText(row, column.key).length)),\n );\n}\n\n/**\n * Build a one-line, human-readable summary: the total plus a per-method\n * breakdown ordered by {@link methodRank}, e.g.\n * `42 routes (38 GET · 2 POST · 1 PUT · 1 DELETE)`.\n *\n * @param rows - The rows being summarized\n * @returns The summary line\n */\nexport function routesSummary(rows: RouteRow[]): string {\n const noun = rows.length === 1 ? \"route\" : \"routes\";\n\n if (rows.length === 0) return `0 ${noun}`;\n\n const counts = new Map<string, number>();\n\n for (const row of rows) {\n counts.set(row.method, (counts.get(row.method) ?? 0) + 1);\n }\n\n const breakdown = [...counts.entries()]\n .sort(([a], [b]) => methodRank(a) - methodRank(b))\n .map(([method, count]) => `${count} ${method}`)\n .join(\" · \");\n\n return `${rows.length} ${noun} (${breakdown})`;\n}\n\n/**\n * Render the routes table as an ordered list of plain (uncolored) lines:\n * a header row, one row per route, a blank line, then the summary. Returned as\n * strings (not printed) so the layout is unit-testable without ANSI noise.\n *\n * @param rows - The rows to render (already filtered/sorted by the caller)\n * @returns The lines to print, top to bottom\n */\nexport function formatRoutesTableLines(rows: RouteRow[]): string[] {\n if (rows.length === 0) {\n return [\"No routes registered.\"];\n }\n\n const widths = columnWidths(rows);\n\n const renderRow = (cells: string[]) =>\n cells.map((text, index) => text.padEnd(widths[index])).join(GAP).trimEnd();\n\n const lines = [renderRow(COLUMNS.map((column) => column.header))];\n\n for (const row of rows) {\n lines.push(renderRow(COLUMNS.map((column) => cellText(row, column.key))));\n }\n\n lines.push(\"\");\n lines.push(routesSummary(rows));\n\n return lines;\n}\n\n/** Per-verb color for the METHOD column. Unknown verbs fall back to white. */\nconst METHOD_COLOR: Record<string, (input: string) => string> = {\n GET: colors.green,\n POST: colors.blue,\n PUT: colors.yellow,\n PATCH: colors.yellow,\n DELETE: colors.red,\n OPTIONS: colors.gray,\n HEAD: colors.gray,\n ALL: colors.magenta,\n};\n\n/**\n * Colorize the method label, then right-pad with plain spaces so column\n * alignment is computed from the visible width, not the ANSI-coded length.\n *\n * @param method - The uppercased HTTP verb\n * @param width - The METHOD column width\n * @returns The colored, padded cell\n */\nfunction colorizeMethodCell(method: string, width: number): string {\n const colorize = METHOD_COLOR[method] ?? colors.white;\n\n return colorize(method) + \" \".repeat(Math.max(0, width - method.length));\n}\n\n/**\n * Print the routes table to stdout with a bold header, verb-colored METHOD\n * column, and a dimmed summary. The empty case prints a single yellow notice\n * (a booted app with zero routes usually means a route module failed to load).\n *\n * Thin presentation wrapper over {@link formatRoutesTableLines} /\n * {@link routesSummary} — those stay the source of truth for layout.\n *\n * @param rows - The rows to print (already filtered/sorted by the caller)\n */\nexport function printRoutesTable(rows: RouteRow[]): void {\n if (rows.length === 0) {\n console.log(colors.yellow(\"No routes registered — did a route module fail to load?\"));\n return;\n }\n\n const widths = columnWidths(rows);\n\n const headerLine = COLUMNS.map((column, index) => column.header.padEnd(widths[index]))\n .join(GAP)\n .trimEnd();\n\n console.log(colors.bold(headerLine));\n\n for (const row of rows) {\n const cells = COLUMNS.map((column, index) => {\n if (column.key === \"method\") {\n return colorizeMethodCell(row.method, widths[index]);\n }\n\n return cellText(row, column.key).padEnd(widths[index]);\n });\n\n console.log(cells.join(GAP).trimEnd());\n }\n\n console.log(\"\");\n console.log(colors.gray(routesSummary(rows)));\n}\n"],"mappings":";;;;;AAIA,MAAM,UAAU;CACd;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAQ,QAAQ;CAAO;CAC9B;EAAE,KAAK;EAAU,QAAQ;CAAS;CAClC;EAAE,KAAK;EAAc,QAAQ;CAAK;CAClC;EAAE,KAAK;EAAU,QAAQ;CAAS;AACpC;;AAKA,MAAM,MAAM;;AAGZ,MAAM,aAAa;;;;;;;;;;;AAYnB,SAAS,SAAS,KAAe,KAAwB;CACvD,IAAI,QAAQ,cAAc,OAAO,OAAO,IAAI,UAAU;CAEtD,MAAM,QAAQ,IAAI;CAElB,OAAO,MAAM,SAAS,IAAI,QAAQ;AACpC;;;;;;;AAQA,SAAS,aAAa,MAA4B;CAChD,OAAO,QAAQ,KAAK,WAClB,KAAK,IAAI,OAAO,OAAO,QAAQ,GAAG,KAAK,KAAK,QAAQ,SAAS,KAAK,OAAO,GAAG,CAAC,CA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,OAAO,MAAM;EACtB,MAAM,QAAQ,QAAQ,KAAK,QAAQ,UAAU;GAC3C,IAAI,OAAO,QAAQ,UACjB,OAAO,mBAAmB,IAAI,QAAQ,OAAO,MAAM;GAGrD,OAAO,SAAS,KAAK,OAAO,GAAG,CAAC,CAAC,OAAO,OAAO,MAAM;EACvD,CAAC;EAED,QAAQ,IAAI,MAAM,KAAK,GAAG,CAAC,CAAC,QAAQ,CAAC;CACvC;CAEA,QAAQ,IAAI,EAAE;CACd,QAAQ,IAAI,OAAO,KAAK,cAAc,IAAI,CAAC,CAAC;AAC9C"}
@@ -0,0 +1,92 @@
1
+ //#region ../@warlock.js/core/src/cli/commands/routes/route-row.ts
2
+ /**
3
+ * Display order of HTTP methods — used to rank rows within a path and to order
4
+ * the per-method breakdown in the summary line.
5
+ */
6
+ const METHOD_ORDER = [
7
+ "GET",
8
+ "POST",
9
+ "PUT",
10
+ "PATCH",
11
+ "DELETE",
12
+ "OPTIONS",
13
+ "HEAD",
14
+ "ALL"
15
+ ];
16
+ /**
17
+ * Rank of a method for sorting. Unknown methods sort last (stable among
18
+ * themselves).
19
+ *
20
+ * @param method - Uppercased HTTP verb
21
+ * @returns The sort index
22
+ */
23
+ function methodRank(method) {
24
+ const index = METHOD_ORDER.indexOf(method);
25
+ return index === -1 ? METHOD_ORDER.length : index;
26
+ }
27
+ /**
28
+ * Derive the handler/controller-action label for a route. Uses the handler
29
+ * function's name, stripping the `bound ` prefix that `Function.prototype.bind`
30
+ * prepends, and falls back to `"anonymous"` for an unnamed handler.
31
+ *
32
+ * @param route - The route to label
33
+ * @returns A printable action label
34
+ */
35
+ function routeAction(route) {
36
+ const handler = route.handler;
37
+ if (typeof handler !== "function") return "anonymous";
38
+ const name = handler.name?.replace(/^bound /, "").trim();
39
+ return name ? name : "anonymous";
40
+ }
41
+ /**
42
+ * Normalize a live {@link Route} into a printable {@link RouteRow}.
43
+ *
44
+ * @param route - The registered route
45
+ * @returns The display-ready row
46
+ */
47
+ function toRouteRow(route) {
48
+ return {
49
+ method: route.method.toUpperCase(),
50
+ path: route.path,
51
+ name: route.name ?? "",
52
+ action: routeAction(route),
53
+ middleware: route.middleware?.length ?? 0,
54
+ source: route.sourceFile ?? ""
55
+ };
56
+ }
57
+ /**
58
+ * Apply the `--method` / `--path` / `--name` filters to a set of rows. An
59
+ * omitted filter matches everything; provided filters are AND-ed.
60
+ *
61
+ * @param rows - The rows to filter
62
+ * @param filter - The active filters
63
+ * @returns The matching rows (a new array)
64
+ */
65
+ function filterRouteRows(rows, filter) {
66
+ const method = filter.method?.toUpperCase();
67
+ const path = filter.path?.toLowerCase();
68
+ const name = filter.name?.toLowerCase();
69
+ return rows.filter((row) => {
70
+ if (method && row.method !== method) return false;
71
+ if (path && !row.path.toLowerCase().includes(path)) return false;
72
+ if (name && !row.name.toLowerCase().includes(name)) return false;
73
+ return true;
74
+ });
75
+ }
76
+ /**
77
+ * Sort rows by path (ascending), then by HTTP-method order within a path, so
78
+ * every verb of one resource lists together in a predictable sequence.
79
+ *
80
+ * @param rows - The rows to sort
81
+ * @returns A new, sorted array
82
+ */
83
+ function sortRouteRows(rows) {
84
+ return [...rows].sort((a, b) => {
85
+ if (a.path !== b.path) return a.path < b.path ? -1 : 1;
86
+ return methodRank(a.method) - methodRank(b.method);
87
+ });
88
+ }
89
+
90
+ //#endregion
91
+ export { filterRouteRows, methodRank, sortRouteRows, toRouteRow };
92
+ //# sourceMappingURL=route-row.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-row.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/core/src/cli/commands/routes/route-row.ts"],"sourcesContent":["import type { Route } from \"../../../router/types\";\n\n/**\n * A single registered route, normalized to the flat, display-ready shape the\n * `warlock routes` table (and its `--json` output) render. Kept separate from\n * the live {@link Route} so the formatter and filters never touch the handler\n * function, validation object, or Fastify server options — only printable\n * scalars.\n */\nexport type RouteRow = {\n /** Uppercased HTTP verb (`\"all\"` → `\"ALL\"`). */\n method: string;\n\n /** Full request path (prefix already folded in by the router). */\n path: string;\n\n /** Route name, or `\"\"` when the route was registered without one. */\n name: string;\n\n /** Handler/controller-action label — the handler function name, or `\"anonymous\"`. */\n action: string;\n\n /** Number of middleware attached to the route. */\n middleware: number;\n\n /** Relative source file the route was registered from, or `\"\"`. */\n source: string;\n};\n\n/** Filters accepted by `warlock routes`, each optional and additive (AND-ed). */\nexport type RouteFilter = {\n /** Exact HTTP method (case-insensitive). */\n method?: string;\n\n /** Case-insensitive substring matched against the path. */\n path?: string;\n\n /** Case-insensitive substring matched against the route name. */\n name?: string;\n};\n\n/**\n * Display order of HTTP methods — used to rank rows within a path and to order\n * the per-method breakdown in the summary line.\n */\nexport const METHOD_ORDER = [\n \"GET\",\n \"POST\",\n \"PUT\",\n \"PATCH\",\n \"DELETE\",\n \"OPTIONS\",\n \"HEAD\",\n \"ALL\",\n];\n\n/**\n * Rank of a method for sorting. Unknown methods sort last (stable among\n * themselves).\n *\n * @param method - Uppercased HTTP verb\n * @returns The sort index\n */\nexport function methodRank(method: string): number {\n const index = METHOD_ORDER.indexOf(method);\n return index === -1 ? METHOD_ORDER.length : index;\n}\n\n/**\n * Derive the handler/controller-action label for a route. Uses the handler\n * function's name, stripping the `bound ` prefix that `Function.prototype.bind`\n * prepends, and falls back to `\"anonymous\"` for an unnamed handler.\n *\n * @param route - The route to label\n * @returns A printable action label\n */\nfunction routeAction(route: Route): string {\n const handler = route.handler as unknown;\n\n if (typeof handler !== \"function\") return \"anonymous\";\n\n const name = handler.name?.replace(/^bound /, \"\").trim();\n\n return name ? name : \"anonymous\";\n}\n\n/**\n * Normalize a live {@link Route} into a printable {@link RouteRow}.\n *\n * @param route - The registered route\n * @returns The display-ready row\n */\nexport function toRouteRow(route: Route): RouteRow {\n return {\n method: route.method.toUpperCase(),\n path: route.path,\n name: route.name ?? \"\",\n action: routeAction(route),\n middleware: route.middleware?.length ?? 0,\n source: route.sourceFile ?? \"\",\n };\n}\n\n/**\n * Apply the `--method` / `--path` / `--name` filters to a set of rows. An\n * omitted filter matches everything; provided filters are AND-ed.\n *\n * @param rows - The rows to filter\n * @param filter - The active filters\n * @returns The matching rows (a new array)\n */\nexport function filterRouteRows(rows: RouteRow[], filter: RouteFilter): RouteRow[] {\n const method = filter.method?.toUpperCase();\n const path = filter.path?.toLowerCase();\n const name = filter.name?.toLowerCase();\n\n return rows.filter((row) => {\n if (method && row.method !== method) return false;\n if (path && !row.path.toLowerCase().includes(path)) return false;\n if (name && !row.name.toLowerCase().includes(name)) return false;\n return true;\n });\n}\n\n/**\n * Sort rows by path (ascending), then by HTTP-method order within a path, so\n * every verb of one resource lists together in a predictable sequence.\n *\n * @param rows - The rows to sort\n * @returns A new, sorted array\n */\nexport function sortRouteRows(rows: RouteRow[]): RouteRow[] {\n return [...rows].sort((a, b) => {\n if (a.path !== b.path) return a.path < b.path ? -1 : 1;\n return methodRank(a.method) - methodRank(b.method);\n });\n}\n"],"mappings":";;;;;AA6CA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;;;;;AASA,SAAgB,WAAW,QAAwB;CACjD,MAAM,QAAQ,aAAa,QAAQ,MAAM;CACzC,OAAO,UAAU,KAAK,aAAa,SAAS;AAC9C;;;;;;;;;AAUA,SAAS,YAAY,OAAsB;CACzC,MAAM,UAAU,MAAM;CAEtB,IAAI,OAAO,YAAY,YAAY,OAAO;CAE1C,MAAM,OAAO,QAAQ,MAAM,QAAQ,WAAW,EAAE,CAAC,CAAC,KAAK;CAEvD,OAAO,OAAO,OAAO;AACvB;;;;;;;AAQA,SAAgB,WAAW,OAAwB;CACjD,OAAO;EACL,QAAQ,MAAM,OAAO,YAAY;EACjC,MAAM,MAAM;EACZ,MAAM,MAAM,QAAQ;EACpB,QAAQ,YAAY,KAAK;EACzB,YAAY,MAAM,YAAY,UAAU;EACxC,QAAQ,MAAM,cAAc;CAC9B;AACF;;;;;;;;;AAUA,SAAgB,gBAAgB,MAAkB,QAAiC;CACjF,MAAM,SAAS,OAAO,QAAQ,YAAY;CAC1C,MAAM,OAAO,OAAO,MAAM,YAAY;CACtC,MAAM,OAAO,OAAO,MAAM,YAAY;CAEtC,OAAO,KAAK,QAAQ,QAAQ;EAC1B,IAAI,UAAU,IAAI,WAAW,QAAQ,OAAO;EAC5C,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,GAAG,OAAO;EAC3D,IAAI,QAAQ,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,SAAS,IAAI,GAAG,OAAO;EAC3D,OAAO;CACT,CAAC;AACH;;;;;;;;AASA,SAAgB,cAAc,MAA8B;CAC1D,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,MAAM;EAC9B,IAAI,EAAE,SAAS,EAAE,MAAM,OAAO,EAAE,OAAO,EAAE,OAAO,KAAK;EACrD,OAAO,WAAW,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM;CACnD,CAAC;AACH"}
@@ -0,0 +1,43 @@
1
+ import { router } from "../../../router/router.mjs";
2
+ import { filterRouteRows, sortRouteRows, toRouteRow } from "./route-row.mjs";
3
+ import { printRoutesTable } from "./format-routes-table.mjs";
4
+
5
+ //#region ../@warlock.js/core/src/cli/commands/routes/routes-command.action.ts
6
+ /**
7
+ * Read the active option as a trimmed string, or `undefined` when it is absent
8
+ * or not a string (a bare boolean flag).
9
+ *
10
+ * @param value - The parsed option value
11
+ * @returns The string value, or `undefined`
12
+ */
13
+ function stringOption(value) {
14
+ return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
15
+ }
16
+ /**
17
+ * Action behind `warlock routes`. Reads the registered routes from the router
18
+ * singleton (populated by the `bootstrap` preload, with no connectors started),
19
+ * applies the `--method` / `--path` / `--name` filters, sorts them, and either
20
+ * prints a verb-colored table or — with `--json` — emits the normalized rows as
21
+ * JSON for piping into scripts/CI.
22
+ *
23
+ * Read-only: it never opens a database/cache/socket connection and never
24
+ * mutates the router.
25
+ *
26
+ * @param data - Parsed CLI args (`options.method` / `path` / `name` / `json`).
27
+ */
28
+ function routesCommandAction({ options }) {
29
+ const rows = sortRouteRows(filterRouteRows(router.list().map(toRouteRow), {
30
+ method: stringOption(options.method),
31
+ path: stringOption(options.path),
32
+ name: stringOption(options.name)
33
+ }));
34
+ if (options.json) {
35
+ console.log(JSON.stringify(rows, null, 2));
36
+ return;
37
+ }
38
+ printRoutesTable(rows);
39
+ }
40
+
41
+ //#endregion
42
+ export { routesCommandAction };
43
+ //# sourceMappingURL=routes-command.action.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes-command.action.mjs","names":[],"sources":["../../../../../../../../../@warlock.js/core/src/cli/commands/routes/routes-command.action.ts"],"sourcesContent":["import { router } from \"../../../router/router\";\nimport type { CommandActionData } from \"../../types\";\nimport { printRoutesTable } from \"./format-routes-table\";\nimport { filterRouteRows, sortRouteRows, toRouteRow } from \"./route-row\";\n\n/**\n * Read the active option as a trimmed string, or `undefined` when it is absent\n * or not a string (a bare boolean flag).\n *\n * @param value - The parsed option value\n * @returns The string value, or `undefined`\n */\nfunction stringOption(value: string | number | boolean | undefined): string | undefined {\n return typeof value === \"string\" && value.trim().length > 0 ? value.trim() : undefined;\n}\n\n/**\n * Action behind `warlock routes`. Reads the registered routes from the router\n * singleton (populated by the `bootstrap` preload, with no connectors started),\n * applies the `--method` / `--path` / `--name` filters, sorts them, and either\n * prints a verb-colored table or — with `--json` — emits the normalized rows as\n * JSON for piping into scripts/CI.\n *\n * Read-only: it never opens a database/cache/socket connection and never\n * mutates the router.\n *\n * @param data - Parsed CLI args (`options.method` / `path` / `name` / `json`).\n */\nexport function routesCommandAction({ options }: CommandActionData): void {\n const rows = sortRouteRows(\n filterRouteRows(router.list().map(toRouteRow), {\n method: stringOption(options.method),\n path: stringOption(options.path),\n name: stringOption(options.name),\n }),\n );\n\n if (options.json) {\n console.log(JSON.stringify(rows, null, 2));\n return;\n }\n\n printRoutesTable(rows);\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAS,aAAa,OAAkE;CACtF,OAAO,OAAO,UAAU,YAAY,MAAM,KAAK,CAAC,CAAC,SAAS,IAAI,MAAM,KAAK,IAAI;AAC/E;;;;;;;;;;;;;AAcA,SAAgB,oBAAoB,EAAE,WAAoC;CACxE,MAAM,OAAO,cACX,gBAAgB,OAAO,KAAK,CAAC,CAAC,IAAI,UAAU,GAAG;EAC7C,QAAQ,aAAa,QAAQ,MAAM;EACnC,MAAM,aAAa,QAAQ,IAAI;EAC/B,MAAM,aAAa,QAAQ,IAAI;CACjC,CAAC,CACH;CAEA,IAAI,QAAQ,MAAM;EAChB,QAAQ,IAAI,KAAK,UAAU,MAAM,MAAM,CAAC,CAAC;EACzC;CACF;CAEA,iBAAiB,IAAI;AACvB"}
@@ -0,0 +1,51 @@
1
+ import { command } from "../cli-command.mjs";
2
+ import { routesCommandAction } from "./routes/routes-command.action.mjs";
3
+
4
+ //#region ../@warlock.js/core/src/cli/commands/routes.command.ts
5
+ /**
6
+ * `warlock routes` — list every registered HTTP route as a table (a read-only
7
+ * sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,
8
+ * or emit the normalized rows as JSON with `--json`.
9
+ *
10
+ * Preload plan: load config + bootstrap app code so route modules register on
11
+ * the router singleton, but start NO connectors — listing routes must never
12
+ * open a database/cache/socket connection. Because the route-module loader is
13
+ * fail-loud, a route file that throws on import surfaces here instead of being
14
+ * silently omitted from the table.
15
+ */
16
+ const routesCommand = command({
17
+ name: "routes",
18
+ description: "List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json",
19
+ action: routesCommandAction,
20
+ preload: {
21
+ config: true,
22
+ env: true,
23
+ bootstrap: true
24
+ },
25
+ options: [
26
+ {
27
+ text: "--method, -m",
28
+ description: "Filter by HTTP method (case-insensitive, e.g. GET, POST)",
29
+ type: "string"
30
+ },
31
+ {
32
+ text: "--path, -p",
33
+ description: "Filter by a case-insensitive path substring",
34
+ type: "string"
35
+ },
36
+ {
37
+ text: "--name, -n",
38
+ description: "Filter by a case-insensitive route-name substring",
39
+ type: "string"
40
+ },
41
+ {
42
+ text: "--json, -j",
43
+ description: "Output the routes as JSON instead of a table",
44
+ type: "boolean"
45
+ }
46
+ ]
47
+ });
48
+
49
+ //#endregion
50
+ export { routesCommand };
51
+ //# sourceMappingURL=routes.command.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.command.mjs","names":[],"sources":["../../../../../../../../@warlock.js/core/src/cli/commands/routes.command.ts"],"sourcesContent":["import { command } from \"../cli-command\";\nimport { routesCommandAction } from \"./routes/routes-command.action\";\n\n/**\n * `warlock routes` — list every registered HTTP route as a table (a read-only\n * sibling of `warlock doctor`). Filter with `--method` / `--path` / `--name`,\n * or emit the normalized rows as JSON with `--json`.\n *\n * Preload plan: load config + bootstrap app code so route modules register on\n * the router singleton, but start NO connectors — listing routes must never\n * open a database/cache/socket connection. Because the route-module loader is\n * fail-loud, a route file that throws on import surfaces here instead of being\n * silently omitted from the table.\n */\nexport const routesCommand = command({\n name: \"routes\",\n description:\n \"List the registered HTTP routes as a table (read-only); filter with --method / --path / --name, or emit JSON with --json\",\n action: routesCommandAction,\n preload: {\n config: true,\n env: true,\n bootstrap: true,\n },\n options: [\n {\n text: \"--method, -m\",\n description: \"Filter by HTTP method (case-insensitive, e.g. GET, POST)\",\n type: \"string\",\n },\n {\n text: \"--path, -p\",\n description: \"Filter by a case-insensitive path substring\",\n type: \"string\",\n },\n {\n text: \"--name, -n\",\n description: \"Filter by a case-insensitive route-name substring\",\n type: \"string\",\n },\n {\n text: \"--json, -j\",\n description: \"Output the routes as JSON instead of a table\",\n type: \"boolean\",\n },\n ],\n});\n"],"mappings":";;;;;;;;;;;;;;;AAcA,MAAa,gBAAgB,QAAQ;CACnC,MAAM;CACN,aACE;CACF,QAAQ;CACR,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;CACb;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;CACF;AACF,CAAC"}
@@ -32,6 +32,11 @@ const seedCommand = command({
32
32
  description: "Run seeds in a transaction",
33
33
  type: "boolean",
34
34
  defaultValue: true
35
+ },
36
+ {
37
+ text: "--drop, -d",
38
+ description: "Undo seeded data — delete tracked records (reverse order) and reset the seed log; scope to one seeder with --drop=\"Seed Name\"",
39
+ type: "string"
35
40
  }
36
41
  ]
37
42
  });
@@ -1 +1 @@
1
- {"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../@warlock.js/core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\r\nimport { command } from \"../cli-command\";\r\n\r\nexport const seedCommand = command({\r\n action: seedCommandAction,\r\n name: \"seed\",\r\n description: \"Run database seeds\",\r\n preload: {\r\n config: true,\r\n env: true,\r\n bootstrap: true,\r\n connectors: [\"database\", \"cache\", \"logger\"],\r\n },\r\n options: [\r\n {\r\n text: \"--fresh, -f\",\r\n description: \"Drop all tables records and run seeds\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--list, -l\",\r\n description: \"Display the seeds list in order without execution\",\r\n type: \"boolean\",\r\n },\r\n {\r\n text: \"--transaction, -t\",\r\n description: \"Run seeds in a transaction\",\r\n type: \"boolean\",\r\n defaultValue: true,\r\n },\r\n ],\r\n});\r\n"],"mappings":";;;;AAGA,MAAa,cAAc,QAAQ;CACjC,QAAQ;CACR,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;EACX,YAAY;GAAC;GAAY;GAAS;EAAQ;CAC5C;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACN,cAAc;EAChB;CACF;AACF,CAAC"}
1
+ {"version":3,"file":"seed.command.mjs","names":[],"sources":["../../../../../../../../@warlock.js/core/src/cli/commands/seed.command.ts"],"sourcesContent":["import { seedCommandAction } from \"../../database/seed-command-action\";\nimport { command } from \"../cli-command\";\n\nexport const seedCommand = command({\n action: seedCommandAction,\n name: \"seed\",\n description: \"Run database seeds\",\n preload: {\n config: true,\n env: true,\n bootstrap: true,\n connectors: [\"database\", \"cache\", \"logger\"],\n },\n options: [\n {\n text: \"--fresh, -f\",\n description: \"Drop all tables records and run seeds\",\n type: \"boolean\",\n },\n {\n text: \"--list, -l\",\n description: \"Display the seeds list in order without execution\",\n type: \"boolean\",\n },\n {\n text: \"--transaction, -t\",\n description: \"Run seeds in a transaction\",\n type: \"boolean\",\n defaultValue: true,\n },\n {\n text: \"--drop, -d\",\n description:\n 'Undo seeded data — delete tracked records (reverse order) and reset the seed log; scope to one seeder with --drop=\"Seed Name\"',\n type: \"string\",\n },\n ],\n});\n"],"mappings":";;;;AAGA,MAAa,cAAc,QAAQ;CACjC,QAAQ;CACR,MAAM;CACN,aAAa;CACb,SAAS;EACP,QAAQ;EACR,KAAK;EACL,WAAW;EACX,YAAY;GAAC;GAAY;GAAS;EAAQ;CAC5C;CACA,SAAS;EACP;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;EACR;EACA;GACE,MAAM;GACN,aAAa;GACb,MAAM;GACN,cAAc;EAChB;EACA;GACE,MAAM;GACN,aACE;GACF,MAAM;EACR;CACF;AACF,CAAC"}
@@ -2,9 +2,11 @@ import { addCommand } from "./commands/add.command.mjs";
2
2
  import { buildCommand } from "./commands/build.command.mjs";
3
3
  import { createDatabaseCommand } from "./commands/create-database.command.mjs";
4
4
  import { devServerCommand } from "./commands/dev-server.command.mjs";
5
+ import { doctorCommand } from "./commands/doctor.command.mjs";
5
6
  import { dropTablesCommand } from "./commands/drop-tables.command.mjs";
6
7
  import { generateCommand, generateControllerCommand, generateMigrationCommand, generateModelCommand, generateModuleCommand, generateRepositoryCommand, generateResourceCommand, generateServiceCommand } from "./commands/generate/generate.command.mjs";
7
8
  import { migrateCommand } from "./commands/migrate.command.mjs";
9
+ import { routesCommand } from "./commands/routes.command.mjs";
8
10
  import { seedCommand } from "./commands/seed.command.mjs";
9
11
  import { startProductionCommand } from "./commands/start-production.command.mjs";
10
12
  import { storagePutCommand } from "./commands/storage-put.command.mjs";
@@ -15,6 +17,8 @@ import { updateCommand } from "./commands/update.command.mjs";
15
17
  const frameworkCommands = [
16
18
  devServerCommand,
17
19
  typingsGeneratorCommand,
20
+ doctorCommand,
21
+ routesCommand,
18
22
  buildCommand,
19
23
  startProductionCommand,
20
24
  migrateCommand,
@@ -1 +1 @@
1
- {"version":3,"file":"framework-cli-commands.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/cli/framework-cli-commands.ts"],"sourcesContent":["import { addCommand } from \"./commands/add.command\";\r\nimport { buildCommand } from \"./commands/build.command\";\r\nimport { createDatabaseCommand } from \"./commands/create-database.command\";\r\nimport { devServerCommand } from \"./commands/dev-server.command\";\r\nimport { dropTablesCommand } from \"./commands/drop-tables.command\";\r\nimport {\r\n generateCommand,\r\n generateControllerCommand,\r\n generateMigrationCommand,\r\n generateModelCommand,\r\n generateModuleCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateServiceCommand,\r\n} from \"./commands/generate/generate.command\";\r\nimport { migrateCommand } from \"./commands/migrate.command\";\r\nimport { seedCommand } from \"./commands/seed.command\";\r\nimport { startProductionCommand } from \"./commands/start-production.command\";\r\nimport { storagePutCommand } from \"./commands/storage-put.command\";\r\nimport { typingsGeneratorCommand } from \"./commands/typings-generator.command\";\r\nimport { updateCommand } from \"./commands/update.command\";\r\n\r\nexport const frameworkCommands = [\r\n // development commands\r\n devServerCommand,\r\n typingsGeneratorCommand,\r\n\r\n // production commands\r\n buildCommand,\r\n startProductionCommand,\r\n\r\n // database commands\r\n migrateCommand,\r\n seedCommand,\r\n createDatabaseCommand,\r\n dropTablesCommand,\r\n\r\n // generation/installation commands\r\n addCommand,\r\n updateCommand,\r\n\r\n // scaffolding commands\r\n generateCommand,\r\n generateModuleCommand,\r\n generateControllerCommand,\r\n generateServiceCommand,\r\n generateModelCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateMigrationCommand,\r\n\r\n // storage commands\r\n storagePutCommand,\r\n];\r\n"],"mappings":";;;;;;;;;;;;;;AAsBA,MAAa,oBAAoB;CAE/B;CACA;CAGA;CACA;CAGA;CACA;CACA;CACA;CAGA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;AACF"}
1
+ {"version":3,"file":"framework-cli-commands.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/cli/framework-cli-commands.ts"],"sourcesContent":["import { addCommand } from \"./commands/add.command\";\r\nimport { buildCommand } from \"./commands/build.command\";\r\nimport { createDatabaseCommand } from \"./commands/create-database.command\";\r\nimport { devServerCommand } from \"./commands/dev-server.command\";\r\nimport { doctorCommand } from \"./commands/doctor.command\";\r\nimport { dropTablesCommand } from \"./commands/drop-tables.command\";\r\nimport {\r\n generateCommand,\r\n generateControllerCommand,\r\n generateMigrationCommand,\r\n generateModelCommand,\r\n generateModuleCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateServiceCommand,\r\n} from \"./commands/generate/generate.command\";\r\nimport { migrateCommand } from \"./commands/migrate.command\";\r\nimport { routesCommand } from \"./commands/routes.command\";\r\nimport { seedCommand } from \"./commands/seed.command\";\r\nimport { startProductionCommand } from \"./commands/start-production.command\";\r\nimport { storagePutCommand } from \"./commands/storage-put.command\";\r\nimport { typingsGeneratorCommand } from \"./commands/typings-generator.command\";\r\nimport { updateCommand } from \"./commands/update.command\";\r\n\r\nexport const frameworkCommands = [\r\n // development commands\r\n devServerCommand,\r\n typingsGeneratorCommand,\r\n\r\n // diagnostics commands\r\n doctorCommand,\r\n routesCommand,\r\n\r\n // production commands\r\n buildCommand,\r\n startProductionCommand,\r\n\r\n // database commands\r\n migrateCommand,\r\n seedCommand,\r\n createDatabaseCommand,\r\n dropTablesCommand,\r\n\r\n // generation/installation commands\r\n addCommand,\r\n updateCommand,\r\n\r\n // scaffolding commands\r\n generateCommand,\r\n generateModuleCommand,\r\n generateControllerCommand,\r\n generateServiceCommand,\r\n generateModelCommand,\r\n generateRepositoryCommand,\r\n generateResourceCommand,\r\n generateMigrationCommand,\r\n\r\n // storage commands\r\n storagePutCommand,\r\n];\r\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,oBAAoB;CAE/B;CACA;CAGA;CACA;CAGA;CACA;CAGA;CACA;CACA;CACA;CAGA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;AACF"}
@@ -1,4 +1,4 @@
1
- import baseConfig from "@mongez/config";
1
+ import config from "@mongez/config";
2
2
 
3
3
  //#region ../@warlock.js/core/src/config/config-getter.ts
4
4
  /**
@@ -14,15 +14,15 @@ import baseConfig from "@mongez/config";
14
14
  * const port = config.key<number>("database.port", 27017);
15
15
  * ```
16
16
  */
17
- const config = {
17
+ const config$1 = {
18
18
  key(key, defaultValue) {
19
- return baseConfig.get(key, defaultValue);
19
+ return config.get(key, defaultValue);
20
20
  },
21
21
  get(name, defaultValue) {
22
- return baseConfig.get(name, defaultValue);
22
+ return config.get(name, defaultValue);
23
23
  }
24
24
  };
25
25
 
26
26
  //#endregion
27
- export { config };
27
+ export { config$1 as config };
28
28
  //# sourceMappingURL=config-getter.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config-getter.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/config/config-getter.ts"],"sourcesContent":["import baseConfig from \"@mongez/config\";\nimport type { ConfigKey, ConfigRegistry } from \"./types\";\n\n/**\n * Config accessor interface with typed overloads\n */\ninterface ConfigAccessor {\n /**\n * Get a config value by dot-notation key path.\n */\n key<T = any>(key: ConfigKey | (string & {}), defaultValue?: T): T;\n\n /**\n * Get an entire config group by name with type inference.\n * Returns the typed config object for known config names.\n */\n get<K extends keyof ConfigRegistry>(name: K, defaultValue?: ConfigRegistry[K]): ConfigRegistry[K];\n\n /**\n * Get an entire config group by name (dynamic string).\n */\n get<T = any>(name: string, defaultValue?: T): T;\n}\n\n/**\n * Config accessor with typed autocomplete and return type inference.\n *\n * @example\n * ```typescript\n * // Get entire config group - returns the actual config type\n * const db = config.get(\"database\"); // → DatabaseConfigurations\n *\n * // Get specific key with dot notation\n * const host = config.key(\"database.host\");\n * const port = config.key<number>(\"database.port\", 27017);\n * ```\n */\nexport const config: ConfigAccessor = {\n key(key: ConfigKey | (string & {}), defaultValue?: any): any {\n return baseConfig.get(key, defaultValue);\n },\n\n get(name: string, defaultValue?: any): any {\n return baseConfig.get(name, defaultValue);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAa,SAAyB;CACpC,IAAI,KAAgC,cAAyB;EAC3D,OAAO,WAAW,IAAI,KAAK,YAAY;CACzC;CAEA,IAAI,MAAc,cAAyB;EACzC,OAAO,WAAW,IAAI,MAAM,YAAY;CAC1C;AACF"}
1
+ {"version":3,"file":"config-getter.mjs","names":["config","baseConfig"],"sources":["../../../../../../../@warlock.js/core/src/config/config-getter.ts"],"sourcesContent":["import baseConfig from \"@mongez/config\";\nimport type { ConfigKey, ConfigRegistry } from \"./types\";\n\n/**\n * Config accessor interface with typed overloads\n */\ninterface ConfigAccessor {\n /**\n * Get a config value by dot-notation key path.\n */\n key<T = any>(key: ConfigKey | (string & {}), defaultValue?: T): T;\n\n /**\n * Get an entire config group by name with type inference.\n * Returns the typed config object for known config names.\n */\n get<K extends keyof ConfigRegistry>(name: K, defaultValue?: ConfigRegistry[K]): ConfigRegistry[K];\n\n /**\n * Get an entire config group by name (dynamic string).\n */\n get<T = any>(name: string, defaultValue?: T): T;\n}\n\n/**\n * Config accessor with typed autocomplete and return type inference.\n *\n * @example\n * ```typescript\n * // Get entire config group - returns the actual config type\n * const db = config.get(\"database\"); // → DatabaseConfigurations\n *\n * // Get specific key with dot notation\n * const host = config.key(\"database.host\");\n * const port = config.key<number>(\"database.port\", 27017);\n * ```\n */\nexport const config: ConfigAccessor = {\n key(key: ConfigKey | (string & {}), defaultValue?: any): any {\n return baseConfig.get(key, defaultValue);\n },\n\n get(name: string, defaultValue?: any): any {\n return baseConfig.get(name, defaultValue);\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,MAAaA,WAAyB;CACpC,IAAI,KAAgC,cAAyB;EAC3D,OAAOC,OAAW,IAAI,KAAK,YAAY;CACzC;CAEA,IAAI,MAAc,cAAyB;EACzC,OAAOA,OAAW,IAAI,MAAM,YAAY;CAC1C;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { configSpecialHandlers } from "./config-special-handlers.mjs";
2
- import baseConfig from "@mongez/config";
2
+ import config from "@mongez/config";
3
3
  import { colors } from "@mongez/copper";
4
4
  import { pathToFileURL } from "node:url";
5
5
 
@@ -27,7 +27,7 @@ var ConfigLoader = class {
27
27
  console.log(colors.red(`config error: `), `Config file ${colors.yellow(file.relativePath)} does not have a default export`);
28
28
  return;
29
29
  }
30
- baseConfig.set(configName, configValue);
30
+ config.set(configName, configValue);
31
31
  await configSpecialHandlers.execute(configName, configValue);
32
32
  } catch (error) {
33
33
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { pathToFileURL } from \"node:url\";\r\nimport type { FileManager } from \"../dev-server/file-manager\";\r\nimport { configSpecialHandlers } from \"./config-special-handlers\";\r\n\r\n/**\r\n * Special Config Handler\r\n * A function that handles special configuration loading\r\n */\r\nexport type SpecialConfigHandler = (configValue: any) => void | Promise<void>;\r\n\r\n/**\r\n * Config Loader\r\n * Dynamically loads all configuration files and registers them with @mongez/config\r\n * Supports special handlers for configs that require additional processing\r\n */\r\nexport class ConfigLoader {\r\n public async loadAll(configFiles: FileManager[]): Promise<void> {\r\n for (const file of configFiles) {\r\n await this.loadConfig(file);\r\n }\r\n }\r\n\r\n /**\r\n * Load a single configuration file.\r\n *\r\n * The ESM loader hook stamps a version token onto the URL so that each HMR\r\n * cycle gets a fresh module — no manual cache-busting needed here.\r\n */\r\n public async loadConfig(file: FileManager): Promise<void> {\r\n const configName = this.getConfigName(file.relativePath);\r\n\r\n try {\r\n const fileUrl = pathToFileURL(file.absolutePath).href;\r\n const configModule = await import(fileUrl);\r\n const configValue = configModule.default;\r\n\r\n if (configValue === undefined) {\r\n console.log(\r\n colors.red(`config error: `),\r\n `Config file ${colors.yellow(file.relativePath)} does not have a default export`,\r\n );\r\n return;\r\n }\r\n\r\n config.set(configName, configValue);\r\n await configSpecialHandlers.execute(configName, configValue);\r\n } catch (error) {\r\n throw error;\r\n }\r\n }\r\n\r\n public async reloadConfig(file: FileManager): Promise<void> {\r\n await this.loadConfig(file);\r\n }\r\n\r\n private getConfigName(relativePath: string): string {\r\n const match = relativePath.match(/^src\\/config\\/(.+)\\.(ts|tsx)$/);\r\n\r\n if (!match) {\r\n throw new Error(`Invalid config file path: ${relativePath}`);\r\n }\r\n\r\n return match[1];\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,eAAb,MAA0B;CACxB,MAAa,QAAQ,aAA2C;EAC9D,KAAK,MAAM,QAAQ,aACjB,MAAM,KAAK,WAAW,IAAI;CAE9B;;;;;;;CAQA,MAAa,WAAW,MAAkC;EACxD,MAAM,aAAa,KAAK,cAAc,KAAK,YAAY;EAEvD,IAAI;GAGF,MAAM,eAAc,MADO,OADX,cAAc,KAAK,YAAY,CAAC,CAAC,MAEjB,CAAC;GAEjC,IAAI,gBAAgB,QAAW;IAC7B,QAAQ,IACN,OAAO,IAAI,gBAAgB,GAC3B,eAAe,OAAO,OAAO,KAAK,YAAY,EAAE,gCAClD;IACA;GACF;GAEA,WAAO,IAAI,YAAY,WAAW;GAClC,MAAM,sBAAsB,QAAQ,YAAY,WAAW;EAC7D,SAAS,OAAO;GACd,MAAM;EACR;CACF;CAEA,MAAa,aAAa,MAAkC;EAC1D,MAAM,KAAK,WAAW,IAAI;CAC5B;CAEA,AAAQ,cAAc,cAA8B;EAClD,MAAM,QAAQ,aAAa,MAAM,+BAA+B;EAEhE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,6BAA6B,cAAc;EAG7D,OAAO,MAAM;CACf;AACF"}
1
+ {"version":3,"file":"config-loader.mjs","names":[],"sources":["../../../../../../../@warlock.js/core/src/config/config-loader.ts"],"sourcesContent":["import config from \"@mongez/config\";\r\nimport { colors } from \"@mongez/copper\";\r\nimport { pathToFileURL } from \"node:url\";\r\nimport type { FileManager } from \"../dev-server/file-manager\";\r\nimport { configSpecialHandlers } from \"./config-special-handlers\";\r\n\r\n/**\r\n * Special Config Handler\r\n * A function that handles special configuration loading\r\n */\r\nexport type SpecialConfigHandler = (configValue: any) => void | Promise<void>;\r\n\r\n/**\r\n * Config Loader\r\n * Dynamically loads all configuration files and registers them with @mongez/config\r\n * Supports special handlers for configs that require additional processing\r\n */\r\nexport class ConfigLoader {\r\n public async loadAll(configFiles: FileManager[]): Promise<void> {\r\n for (const file of configFiles) {\r\n await this.loadConfig(file);\r\n }\r\n }\r\n\r\n /**\r\n * Load a single configuration file.\r\n *\r\n * The ESM loader hook stamps a version token onto the URL so that each HMR\r\n * cycle gets a fresh module — no manual cache-busting needed here.\r\n */\r\n public async loadConfig(file: FileManager): Promise<void> {\r\n const configName = this.getConfigName(file.relativePath);\r\n\r\n try {\r\n const fileUrl = pathToFileURL(file.absolutePath).href;\r\n const configModule = await import(fileUrl);\r\n const configValue = configModule.default;\r\n\r\n if (configValue === undefined) {\r\n console.log(\r\n colors.red(`config error: `),\r\n `Config file ${colors.yellow(file.relativePath)} does not have a default export`,\r\n );\r\n return;\r\n }\r\n\r\n config.set(configName, configValue);\r\n await configSpecialHandlers.execute(configName, configValue);\r\n } catch (error) {\r\n throw error;\r\n }\r\n }\r\n\r\n public async reloadConfig(file: FileManager): Promise<void> {\r\n await this.loadConfig(file);\r\n }\r\n\r\n private getConfigName(relativePath: string): string {\r\n const match = relativePath.match(/^src\\/config\\/(.+)\\.(ts|tsx)$/);\r\n\r\n if (!match) {\r\n throw new Error(`Invalid config file path: ${relativePath}`);\r\n }\r\n\r\n return match[1];\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;AAiBA,IAAa,eAAb,MAA0B;CACxB,MAAa,QAAQ,aAA2C;EAC9D,KAAK,MAAM,QAAQ,aACjB,MAAM,KAAK,WAAW,IAAI;CAE9B;;;;;;;CAQA,MAAa,WAAW,MAAkC;EACxD,MAAM,aAAa,KAAK,cAAc,KAAK,YAAY;EAEvD,IAAI;GAGF,MAAM,eAAc,MADO,OADX,cAAc,KAAK,YAAY,CAAC,CAAC,MAEjB,CAAC;GAEjC,IAAI,gBAAgB,QAAW;IAC7B,QAAQ,IACN,OAAO,IAAI,gBAAgB,GAC3B,eAAe,OAAO,OAAO,KAAK,YAAY,EAAE,gCAClD;IACA;GACF;GAEA,OAAO,IAAI,YAAY,WAAW;GAClC,MAAM,sBAAsB,QAAQ,YAAY,WAAW;EAC7D,SAAS,OAAO;GACd,MAAM;EACR;CACF;CAEA,MAAa,aAAa,MAAkC;EAC1D,MAAM,KAAK,WAAW,IAAI;CAC5B;CAEA,AAAQ,cAAc,cAA8B;EAClD,MAAM,QAAQ,aAAa,MAAM,+BAA+B;EAEhE,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,6BAA6B,cAAc;EAG7D,OAAO,MAAM;CACf;AACF"}