@pikku/cli 0.9.14 → 0.9.16-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (445) hide show
  1. package/.pikku/channel/pikku-channel-types.gen.ts +92 -0
  2. package/.pikku/cli/pikku-cli-types.gen.ts +71 -0
  3. package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +5 -0
  4. package/.pikku/cli/pikku-cli-wirings.gen.ts +4 -0
  5. package/.pikku/function/pikku-function-types.gen.ts +292 -0
  6. package/.pikku/function/pikku-functions-meta.gen.ts +817 -0
  7. package/.pikku/function/pikku-functions-meta.min.gen.ts +176 -0
  8. package/.pikku/function/pikku-functions.gen.ts +74 -0
  9. package/.pikku/http/pikku-http-types.gen.ts +61 -0
  10. package/.pikku/mcp/pikku-mcp-types.gen.ts +138 -0
  11. package/.pikku/pikku-bootstrap.gen.ts +9 -0
  12. package/.pikku/pikku-services.gen.ts +24 -0
  13. package/.pikku/pikku-types.gen.ts +28 -0
  14. package/.pikku/queue/pikku-queue-types.gen.ts +28 -0
  15. package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +46 -0
  16. package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +80 -0
  17. package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +40 -0
  18. package/.pikku/scheduler/pikku-scheduler-types.gen.ts +26 -0
  19. package/.pikku/schemas/register.gen.ts +47 -0
  20. package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
  21. package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
  22. package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
  23. package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
  24. package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
  25. package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
  26. package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
  27. package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
  28. package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
  29. package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
  30. package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
  31. package/CHANGELOG.md +15 -0
  32. package/bin/pikku.ts +45 -14
  33. package/build.sh +53 -0
  34. package/cli.schema.json +1 -382
  35. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +65 -0
  36. package/dist/.pikku/channel/pikku-channel-types.gen.js +54 -0
  37. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +55 -0
  38. package/dist/.pikku/cli/pikku-cli-types.gen.js +30 -0
  39. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +5 -0
  40. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +4 -0
  41. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +5 -0
  42. package/dist/.pikku/function/pikku-function-types.gen.d.ts +259 -0
  43. package/dist/.pikku/function/pikku-function-types.gen.js +175 -0
  44. package/dist/.pikku/function/pikku-functions-meta.gen.d.ts +1 -0
  45. package/dist/.pikku/function/pikku-functions-meta.gen.js +817 -0
  46. package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +1 -0
  47. package/dist/.pikku/function/pikku-functions-meta.min.gen.js +176 -0
  48. package/dist/.pikku/function/pikku-functions.gen.d.ts +1 -0
  49. package/dist/.pikku/function/pikku-functions.gen.js +73 -0
  50. package/dist/.pikku/http/pikku-http-types.gen.d.ts +49 -0
  51. package/dist/.pikku/http/pikku-http-types.gen.js +41 -0
  52. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +88 -0
  53. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +71 -0
  54. package/dist/.pikku/pikku-bootstrap.gen.d.ts +9 -0
  55. package/dist/.pikku/pikku-bootstrap.gen.js +9 -0
  56. package/dist/.pikku/pikku-services.gen.d.ts +16 -0
  57. package/dist/.pikku/pikku-services.gen.js +11 -0
  58. package/dist/.pikku/pikku-types.gen.d.ts +14 -0
  59. package/dist/.pikku/pikku-types.gen.js +21 -0
  60. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +24 -0
  61. package/dist/.pikku/queue/pikku-queue-types.gen.js +17 -0
  62. package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.d.ts +6 -0
  63. package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.js +6 -0
  64. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +1 -0
  65. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +40 -0
  66. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +22 -0
  67. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +17 -0
  68. package/dist/.pikku/schemas/register.gen.d.ts +1 -0
  69. package/dist/.pikku/schemas/register.gen.js +26 -0
  70. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
  71. package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
  72. package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
  73. package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
  74. package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
  75. package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
  76. package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
  77. package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
  78. package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
  79. package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
  80. package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
  81. package/dist/bin/pikku.d.ts +1 -1
  82. package/dist/bin/pikku.js +32 -14
  83. package/dist/src/cli.wiring.d.ts +1 -0
  84. package/dist/src/cli.wiring.js +75 -0
  85. package/dist/src/functions/commands/all.d.ts +1 -0
  86. package/dist/src/functions/commands/all.js +104 -0
  87. package/dist/src/functions/commands/watch.d.ts +1 -0
  88. package/dist/src/functions/commands/watch.js +47 -0
  89. package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.d.ts +1 -0
  90. package/dist/src/{runtimes → functions/runtimes}/nextjs/pikku-command-nextjs.js +28 -9
  91. package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -0
  92. package/dist/src/functions/wirings/channels/pikku-channels.js +24 -0
  93. package/dist/src/functions/wirings/channels/pikku-command-channel-types.d.ts +1 -0
  94. package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +21 -0
  95. package/dist/src/functions/wirings/channels/pikku-command-channels-map.d.ts +1 -0
  96. package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +23 -0
  97. package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -0
  98. package/dist/src/functions/wirings/channels/pikku-command-channels.js +25 -0
  99. package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.d.ts +1 -0
  100. package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.js +24 -0
  101. package/dist/src/functions/wirings/channels/serialize-channel-types.d.ts +4 -0
  102. package/dist/src/functions/wirings/channels/serialize-channel-types.js +95 -0
  103. package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.js +2 -2
  104. package/dist/src/functions/wirings/cli/pikku-command-cli-entry.d.ts +1 -0
  105. package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +100 -0
  106. package/dist/src/functions/wirings/cli/pikku-command-cli-types.d.ts +1 -0
  107. package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +33 -0
  108. package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -0
  109. package/dist/src/functions/wirings/cli/pikku-command-cli.js +24 -0
  110. package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +7 -0
  111. package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +54 -0
  112. package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +9 -0
  113. package/dist/src/functions/wirings/cli/serialize-channel-cli.js +84 -0
  114. package/dist/src/functions/wirings/cli/serialize-cli-types.d.ts +4 -0
  115. package/dist/src/functions/wirings/cli/serialize-cli-types.js +74 -0
  116. package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +14 -0
  117. package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +46 -0
  118. package/dist/src/functions/wirings/fetch/index.d.ts +1 -0
  119. package/dist/src/functions/wirings/fetch/index.js +24 -0
  120. package/dist/src/functions/wirings/functions/pikku-command-function-types-split.d.ts +1 -0
  121. package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +32 -0
  122. package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +1 -0
  123. package/dist/src/functions/wirings/functions/pikku-command-function-types.js +20 -0
  124. package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -0
  125. package/dist/src/functions/wirings/functions/pikku-command-functions.js +28 -0
  126. package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.d.ts +1 -2
  127. package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.js +27 -10
  128. package/dist/src/functions/wirings/functions/pikku-function-types.d.ts +1 -0
  129. package/dist/src/functions/wirings/functions/pikku-function-types.js +20 -0
  130. package/dist/src/functions/wirings/functions/schemas.d.ts +4 -0
  131. package/dist/src/functions/wirings/functions/schemas.js +22 -0
  132. package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.js +4 -21
  133. package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +4 -0
  134. package/dist/src/functions/wirings/functions/serialize-function-types.js +295 -0
  135. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +4 -0
  136. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +31 -0
  137. package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.d.ts +2 -1
  138. package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.js +2 -2
  139. package/dist/src/functions/wirings/http/pikku-command-http-map.d.ts +1 -0
  140. package/dist/src/functions/wirings/http/pikku-command-http-map.js +23 -0
  141. package/dist/src/functions/wirings/http/pikku-command-http-routes.d.ts +1 -0
  142. package/dist/src/functions/wirings/http/pikku-command-http-routes.js +25 -0
  143. package/dist/src/functions/wirings/http/pikku-command-http-types.d.ts +1 -0
  144. package/dist/src/functions/wirings/http/pikku-command-http-types.js +21 -0
  145. package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -0
  146. package/dist/src/functions/wirings/http/pikku-command-openapi.js +34 -0
  147. package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -0
  148. package/dist/src/functions/wirings/http/pikku-http-routes.js +25 -0
  149. package/dist/src/functions/wirings/http/serialize-http-types.d.ts +4 -0
  150. package/dist/src/functions/wirings/http/serialize-http-types.js +64 -0
  151. package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.js +2 -2
  152. package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.d.ts +1 -0
  153. package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +28 -0
  154. package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.d.ts +1 -0
  155. package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.js +21 -0
  156. package/dist/src/functions/wirings/mcp/pikku-command-mcp.d.ts +1 -0
  157. package/dist/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.js +22 -5
  158. package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.d.ts +1 -1
  159. package/dist/src/functions/wirings/mcp/serialize-mcp-types.d.ts +4 -0
  160. package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +141 -0
  161. package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -0
  162. package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +38 -0
  163. package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.d.ts +8 -0
  164. package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +50 -0
  165. package/dist/src/functions/wirings/middleware/serialize-middleware-imports.d.ts +2 -0
  166. package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +43 -0
  167. package/dist/src/functions/wirings/queue/pikku-command-queue-map.d.ts +1 -0
  168. package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +23 -0
  169. package/dist/src/functions/wirings/queue/pikku-command-queue-service.d.ts +1 -0
  170. package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +24 -0
  171. package/dist/src/functions/wirings/queue/pikku-command-queue-types.d.ts +1 -0
  172. package/dist/src/functions/wirings/queue/pikku-command-queue-types.js +21 -0
  173. package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -0
  174. package/dist/src/functions/wirings/queue/pikku-command-queue.js +26 -0
  175. package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -0
  176. package/dist/src/functions/wirings/queue/pikku-queue-map.js +23 -0
  177. package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -0
  178. package/dist/src/functions/wirings/queue/pikku-queue.js +25 -0
  179. package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.js +2 -2
  180. package/dist/src/functions/wirings/queue/serialize-queue-types.d.ts +4 -0
  181. package/dist/src/functions/wirings/queue/serialize-queue-types.js +31 -0
  182. package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.d.ts +1 -0
  183. package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +25 -0
  184. package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.d.ts +2 -0
  185. package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +36 -0
  186. package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +1 -0
  187. package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +22 -0
  188. package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.js +2 -2
  189. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.d.ts +1 -0
  190. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.js +21 -0
  191. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -0
  192. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +26 -0
  193. package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.d.ts +4 -0
  194. package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +29 -0
  195. package/dist/src/middleware/log-command-info-and-time.d.ts +19 -0
  196. package/dist/src/middleware/log-command-info-and-time.js +27 -0
  197. package/dist/src/serialize-pikku-types.js +2 -2
  198. package/dist/src/services/cli-logger-forwarder.service.d.ts +26 -0
  199. package/dist/src/services/cli-logger-forwarder.service.js +55 -0
  200. package/dist/src/services/cli-logger.service.d.ts +19 -0
  201. package/dist/src/services/cli-logger.service.js +66 -0
  202. package/dist/src/services.d.ts +15 -0
  203. package/dist/src/services.js +64 -0
  204. package/dist/src/utils/check-required-types.d.ts +10 -0
  205. package/dist/src/utils/check-required-types.js +31 -0
  206. package/dist/src/utils/custom-types-generator.d.ts +2 -0
  207. package/dist/src/utils/custom-types-generator.js +37 -0
  208. package/dist/src/utils/file-import-path.d.ts +1 -0
  209. package/dist/src/utils/file-import-path.js +43 -0
  210. package/dist/src/utils/file-imports-serializer.d.ts +1 -0
  211. package/dist/src/utils/file-imports-serializer.js +13 -0
  212. package/dist/src/utils/file-writer.d.ts +6 -0
  213. package/dist/src/utils/file-writer.js +40 -0
  214. package/dist/src/utils/generate-bootstrap-file.d.ts +3 -0
  215. package/dist/src/utils/generate-bootstrap-file.js +21 -0
  216. package/dist/src/utils/pikku-cli-config.d.ts +5 -0
  217. package/dist/src/utils/pikku-cli-config.js +243 -0
  218. package/dist/src/utils/pikku-files-and-methods.d.ts +21 -0
  219. package/dist/src/utils/pikku-files-and-methods.js +70 -0
  220. package/dist/src/{schema-generator.d.ts → utils/schema-generator.d.ts} +1 -1
  221. package/dist/src/{schema-generator.js → utils/schema-generator.js} +1 -1
  222. package/dist/src/{serialize-import-map.js → utils/serialize-import-map.js} +1 -1
  223. package/dist/tsconfig.tsbuildinfo +1 -1
  224. package/package.json +6 -6
  225. package/pikku.config.json +24 -0
  226. package/src/cli.wiring.ts +75 -0
  227. package/src/functions/commands/all.ts +141 -0
  228. package/src/functions/commands/watch.ts +58 -0
  229. package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +111 -0
  230. package/src/functions/wirings/channels/pikku-channels.ts +40 -0
  231. package/src/functions/wirings/channels/pikku-command-channel-types.ts +27 -0
  232. package/src/functions/wirings/channels/pikku-command-channels-map.ts +31 -0
  233. package/src/functions/wirings/channels/pikku-command-channels.ts +45 -0
  234. package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +33 -0
  235. package/src/functions/wirings/channels/serialize-channel-types.ts +95 -0
  236. package/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.ts +2 -2
  237. package/src/functions/wirings/cli/pikku-command-cli-entry.ts +173 -0
  238. package/src/functions/wirings/cli/pikku-command-cli-types.ts +50 -0
  239. package/src/functions/wirings/cli/pikku-command-cli.ts +41 -0
  240. package/src/functions/wirings/cli/serialize-channel-cli-client.ts +72 -0
  241. package/src/functions/wirings/cli/serialize-channel-cli.ts +123 -0
  242. package/src/functions/wirings/cli/serialize-cli-types.ts +80 -0
  243. package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +75 -0
  244. package/src/functions/wirings/fetch/index.ts +32 -0
  245. package/src/functions/wirings/functions/pikku-command-function-types-split.ts +51 -0
  246. package/src/functions/wirings/functions/pikku-command-function-types.ts +45 -0
  247. package/src/functions/wirings/functions/pikku-command-functions.ts +61 -0
  248. package/src/{wirings → functions/wirings}/functions/pikku-command-services.ts +41 -44
  249. package/src/functions/wirings/functions/pikku-function-types.ts +45 -0
  250. package/src/functions/wirings/functions/schemas.ts +47 -0
  251. package/src/{wirings → functions/wirings}/functions/serialize-function-imports.ts +4 -30
  252. package/src/functions/wirings/functions/serialize-function-types.ts +303 -0
  253. package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +39 -0
  254. package/src/{wirings → functions/wirings}/http/openapi-spec-generator.ts +3 -1
  255. package/src/functions/wirings/http/pikku-command-http-map.ts +32 -0
  256. package/src/functions/wirings/http/pikku-command-http-routes.ts +41 -0
  257. package/src/functions/wirings/http/pikku-command-http-types.ts +27 -0
  258. package/src/functions/wirings/http/pikku-command-openapi.ts +57 -0
  259. package/src/functions/wirings/http/pikku-http-routes.ts +40 -0
  260. package/src/functions/wirings/http/serialize-http-types.ts +64 -0
  261. package/src/{wirings → functions/wirings}/http/serialize-typed-http-map.ts +2 -2
  262. package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +38 -0
  263. package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +27 -0
  264. package/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.ts +55 -46
  265. package/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.ts +1 -1
  266. package/src/functions/wirings/mcp/serialize-mcp-types.ts +141 -0
  267. package/src/functions/wirings/middleware/pikku-command-middleware.ts +65 -0
  268. package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +61 -0
  269. package/src/functions/wirings/middleware/serialize-middleware-imports.ts +78 -0
  270. package/src/functions/wirings/queue/pikku-command-queue-map.ts +31 -0
  271. package/src/functions/wirings/queue/pikku-command-queue-service.ts +33 -0
  272. package/src/functions/wirings/queue/pikku-command-queue-types.ts +27 -0
  273. package/src/functions/wirings/queue/pikku-command-queue.ts +46 -0
  274. package/src/functions/wirings/queue/pikku-queue-map.ts +31 -0
  275. package/src/functions/wirings/queue/pikku-queue.ts +44 -0
  276. package/src/{wirings → functions/wirings}/queue/serialize-queue-map.ts +2 -2
  277. package/src/functions/wirings/queue/serialize-queue-types.ts +31 -0
  278. package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +32 -0
  279. package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +52 -0
  280. package/src/functions/wirings/rpc/pikku-command-rpc.ts +28 -0
  281. package/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.ts +2 -2
  282. package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +27 -0
  283. package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +46 -0
  284. package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +29 -0
  285. package/src/middleware/log-command-info-and-time.ts +61 -0
  286. package/src/serialize-pikku-types.ts +2 -2
  287. package/src/services/cli-logger-forwarder.service.ts +77 -0
  288. package/src/services/cli-logger.service.ts +78 -0
  289. package/src/services.ts +111 -0
  290. package/src/utils/check-required-types.ts +53 -0
  291. package/src/utils/custom-types-generator.ts +49 -0
  292. package/src/{utils.test.ts → utils/file-import-path.test.ts} +1 -1
  293. package/src/utils/file-import-path.ts +53 -0
  294. package/src/utils/file-imports-serializer.ts +25 -0
  295. package/src/utils/file-writer.ts +56 -0
  296. package/src/utils/generate-bootstrap-file.ts +43 -0
  297. package/src/utils/pikku-cli-config.ts +356 -0
  298. package/src/utils/pikku-files-and-methods.ts +148 -0
  299. package/src/{schema-generator.ts → utils/schema-generator.ts} +3 -1
  300. package/src/{serialize-import-map.ts → utils/serialize-import-map.ts} +1 -1
  301. package/tsconfig.json +2 -2
  302. package/types/application-types.d.ts +20 -0
  303. package/types/config.d.ts +192 -0
  304. package/bin/pikku-all.ts +0 -349
  305. package/bin/pikku-fetch.ts +0 -27
  306. package/bin/pikku-nextjs.ts +0 -44
  307. package/bin/pikku-openapi.ts +0 -31
  308. package/bin/pikku-queue-service.ts +0 -28
  309. package/bin/pikku-rpc.ts +0 -28
  310. package/bin/pikku-schemas.ts +0 -31
  311. package/bin/pikku-websocket.ts +0 -28
  312. package/dist/bin/pikku-all.d.ts +0 -4
  313. package/dist/bin/pikku-all.js +0 -194
  314. package/dist/bin/pikku-fetch.d.ts +0 -4
  315. package/dist/bin/pikku-fetch.js +0 -19
  316. package/dist/bin/pikku-nextjs.d.ts +0 -4
  317. package/dist/bin/pikku-nextjs.js +0 -24
  318. package/dist/bin/pikku-openapi.d.ts +0 -2
  319. package/dist/bin/pikku-openapi.js +0 -19
  320. package/dist/bin/pikku-queue-service.d.ts +0 -4
  321. package/dist/bin/pikku-queue-service.js +0 -19
  322. package/dist/bin/pikku-rpc.d.ts +0 -4
  323. package/dist/bin/pikku-rpc.js +0 -19
  324. package/dist/bin/pikku-schemas.d.ts +0 -2
  325. package/dist/bin/pikku-schemas.js +0 -21
  326. package/dist/bin/pikku-websocket.d.ts +0 -4
  327. package/dist/bin/pikku-websocket.js +0 -19
  328. package/dist/src/inspector-glob.d.ts +0 -2
  329. package/dist/src/inspector-glob.js +0 -12
  330. package/dist/src/pikku-cli-config.d.ts +0 -56
  331. package/dist/src/pikku-cli-config.js +0 -203
  332. package/dist/src/pikku-command-schemas.d.ts +0 -2
  333. package/dist/src/pikku-command-schemas.js +0 -8
  334. package/dist/src/runtimes/nextjs/pikku-command-nextjs.d.ts +0 -2
  335. package/dist/src/schemas.d.ts +0 -2
  336. package/dist/src/schemas.js +0 -8
  337. package/dist/src/types.d.ts +0 -5
  338. package/dist/src/utils.d.ts +0 -60
  339. package/dist/src/utils.js +0 -248
  340. package/dist/src/wirings/channels/pikku-channels.d.ts +0 -2
  341. package/dist/src/wirings/channels/pikku-channels.js +0 -9
  342. package/dist/src/wirings/channels/pikku-command-channels-map.d.ts +0 -2
  343. package/dist/src/wirings/channels/pikku-command-channels-map.js +0 -8
  344. package/dist/src/wirings/channels/pikku-command-channels.d.ts +0 -2
  345. package/dist/src/wirings/channels/pikku-command-channels.js +0 -9
  346. package/dist/src/wirings/channels/pikku-command-websocket-typed.d.ts +0 -2
  347. package/dist/src/wirings/channels/pikku-command-websocket-typed.js +0 -15
  348. package/dist/src/wirings/fetch/index.d.ts +0 -2
  349. package/dist/src/wirings/fetch/index.js +0 -12
  350. package/dist/src/wirings/functions/pikku-command-function-types.d.ts +0 -2
  351. package/dist/src/wirings/functions/pikku-command-function-types.js +0 -13
  352. package/dist/src/wirings/functions/pikku-command-functions.d.ts +0 -2
  353. package/dist/src/wirings/functions/pikku-command-functions.js +0 -14
  354. package/dist/src/wirings/functions/pikku-function-types.d.ts +0 -2
  355. package/dist/src/wirings/functions/pikku-function-types.js +0 -13
  356. package/dist/src/wirings/http/pikku-command-http-map.d.ts +0 -2
  357. package/dist/src/wirings/http/pikku-command-http-map.js +0 -8
  358. package/dist/src/wirings/http/pikku-command-http-routes.d.ts +0 -2
  359. package/dist/src/wirings/http/pikku-command-http-routes.js +0 -9
  360. package/dist/src/wirings/http/pikku-command-openapi.d.ts +0 -2
  361. package/dist/src/wirings/http/pikku-command-openapi.js +0 -20
  362. package/dist/src/wirings/http/pikku-http-routes.d.ts +0 -2
  363. package/dist/src/wirings/http/pikku-http-routes.js +0 -9
  364. package/dist/src/wirings/mcp/pikku-command-mcp-json.d.ts +0 -2
  365. package/dist/src/wirings/mcp/pikku-command-mcp-json.js +0 -13
  366. package/dist/src/wirings/mcp/pikku-command-mcp.d.ts +0 -2
  367. package/dist/src/wirings/queue/pikku-command-queue-map.d.ts +0 -2
  368. package/dist/src/wirings/queue/pikku-command-queue-map.js +0 -8
  369. package/dist/src/wirings/queue/pikku-command-queue-service.d.ts +0 -2
  370. package/dist/src/wirings/queue/pikku-command-queue-service.js +0 -15
  371. package/dist/src/wirings/queue/pikku-command-queue.d.ts +0 -2
  372. package/dist/src/wirings/queue/pikku-command-queue.js +0 -10
  373. package/dist/src/wirings/queue/pikku-queue-map.d.ts +0 -2
  374. package/dist/src/wirings/queue/pikku-queue-map.js +0 -8
  375. package/dist/src/wirings/queue/pikku-queue.d.ts +0 -2
  376. package/dist/src/wirings/queue/pikku-queue.js +0 -10
  377. package/dist/src/wirings/rpc/pikku-command-rpc-client.d.ts +0 -2
  378. package/dist/src/wirings/rpc/pikku-command-rpc-client.js +0 -15
  379. package/dist/src/wirings/rpc/pikku-command-rpc-map.d.ts +0 -3
  380. package/dist/src/wirings/rpc/pikku-command-rpc-map.js +0 -14
  381. package/dist/src/wirings/rpc/pikku-command-rpc.d.ts +0 -2
  382. package/dist/src/wirings/rpc/pikku-command-rpc.js +0 -8
  383. package/dist/src/wirings/scheduler/pikku-command-scheduler.d.ts +0 -2
  384. package/dist/src/wirings/scheduler/pikku-command-scheduler.js +0 -10
  385. package/src/inspector-glob.ts +0 -30
  386. package/src/pikku-cli-config.ts +0 -387
  387. package/src/pikku-command-schemas.ts +0 -35
  388. package/src/runtimes/nextjs/pikku-command-nextjs.ts +0 -110
  389. package/src/schemas.ts +0 -35
  390. package/src/types.ts +0 -16
  391. package/src/utils.ts +0 -420
  392. package/src/wirings/channels/pikku-channels.ts +0 -41
  393. package/src/wirings/channels/pikku-command-channels-map.ts +0 -26
  394. package/src/wirings/channels/pikku-command-channels.ts +0 -39
  395. package/src/wirings/channels/pikku-command-websocket-typed.ts +0 -36
  396. package/src/wirings/fetch/index.ts +0 -33
  397. package/src/wirings/functions/pikku-command-function-types.ts +0 -53
  398. package/src/wirings/functions/pikku-command-functions.ts +0 -48
  399. package/src/wirings/functions/pikku-function-types.ts +0 -52
  400. package/src/wirings/http/pikku-command-http-map.ts +0 -27
  401. package/src/wirings/http/pikku-command-http-routes.ts +0 -40
  402. package/src/wirings/http/pikku-command-openapi.ts +0 -55
  403. package/src/wirings/http/pikku-http-routes.ts +0 -40
  404. package/src/wirings/mcp/pikku-command-mcp-json.ts +0 -33
  405. package/src/wirings/queue/pikku-command-queue-map.ts +0 -26
  406. package/src/wirings/queue/pikku-command-queue-service.ts +0 -36
  407. package/src/wirings/queue/pikku-command-queue.ts +0 -45
  408. package/src/wirings/queue/pikku-queue-map.ts +0 -26
  409. package/src/wirings/queue/pikku-queue.ts +0 -43
  410. package/src/wirings/rpc/pikku-command-rpc-client.ts +0 -35
  411. package/src/wirings/rpc/pikku-command-rpc-map.ts +0 -49
  412. package/src/wirings/rpc/pikku-command-rpc.ts +0 -24
  413. package/src/wirings/scheduler/pikku-command-scheduler.ts +0 -43
  414. /package/dist/{src/types.js → .pikku/cli/pikku-cli-wirings-meta.gen.d.ts} +0 -0
  415. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.d.ts +0 -0
  416. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.js +0 -0
  417. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.d.ts +0 -0
  418. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.js +0 -0
  419. /package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
  420. /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
  421. /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.js +0 -0
  422. /package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.d.ts +0 -0
  423. /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
  424. /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.js +0 -0
  425. /package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.d.ts +0 -0
  426. /package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.js +0 -0
  427. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.d.ts +0 -0
  428. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.d.ts +0 -0
  429. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.js +0 -0
  430. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
  431. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.js +0 -0
  432. /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
  433. /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.js +0 -0
  434. /package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
  435. /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
  436. /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.js +0 -0
  437. /package/dist/src/{serialize-import-map.d.ts → utils/serialize-import-map.d.ts} +0 -0
  438. /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.ts +0 -0
  439. /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.ts +0 -0
  440. /package/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.ts +0 -0
  441. /package/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.ts +0 -0
  442. /package/src/{wirings → functions/wirings}/queue/serialize-queue-meta.ts +0 -0
  443. /package/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.ts +0 -0
  444. /package/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.ts +0 -0
  445. /package/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.ts +0 -0
@@ -0,0 +1,66 @@
1
+ import chalk from 'chalk';
2
+ import { LogLevel } from '@pikku/core';
3
+ const logo = `
4
+ ______ _ _ _
5
+ (_____ (_) | | |
6
+ _____) )| | _| | _ _ _
7
+ | ____/ | |_/ ) |_/ ) | | |
8
+ | | | | _ (| _ (| _ (| |_| |
9
+ |_| |_|_| _)_| _)____/
10
+ `;
11
+ export class CLILogger {
12
+ silent;
13
+ level = LogLevel.info;
14
+ constructor({ logLogo, silent = false, }) {
15
+ this.silent = silent;
16
+ if (logLogo && !silent) {
17
+ this.logPikkuLogo();
18
+ }
19
+ }
20
+ setLevel(level) {
21
+ this.level = level;
22
+ }
23
+ info(message) {
24
+ if (this.level > LogLevel.info || this.silent)
25
+ return;
26
+ let c = chalk.blue;
27
+ if (typeof message === 'object') {
28
+ if (message.type === 'success') {
29
+ c = chalk.green;
30
+ }
31
+ else if (message.type === 'timing') {
32
+ c = chalk.gray;
33
+ }
34
+ }
35
+ console.log(c(typeof message === 'string' ? message : message.message));
36
+ }
37
+ error(message) {
38
+ if (this.level > LogLevel.error)
39
+ return;
40
+ console.error(chalk.red(message));
41
+ }
42
+ warn(message) {
43
+ if (this.level > LogLevel.warn)
44
+ return;
45
+ console.error(chalk.yellow(message));
46
+ }
47
+ debug(message) {
48
+ if (this.level > LogLevel.debug || this.silent)
49
+ return;
50
+ console.log(chalk.gray(message));
51
+ }
52
+ logPikkuLogo() {
53
+ this.primary(logo);
54
+ // // When running from dist/, __filename is dist/src/services/cli-logger.service.js
55
+ // // So we need to go up 3 levels: dist/src/services -> dist/src -> dist -> package.json
56
+ // const packageJson = JSON.parse(
57
+ // readFileSync(`${dirname(__filename)}/../../../package.json`, 'utf-8')
58
+ // )
59
+ // this.primary(`⚙️ Welcome to the Pikku CLI (v${packageJson.version})\n`)
60
+ }
61
+ primary(message) {
62
+ if (!this.silent) {
63
+ console.log(chalk.green(message));
64
+ }
65
+ }
66
+ }
@@ -0,0 +1,15 @@
1
+ import type { Config, Services, SingletonServices, UserSession } from '../types/application-types.js';
2
+ import { CreateConfig, CreateSessionServices, CreateSingletonServices } from '@pikku/core';
3
+ import { PikkuCLIConfig } from '../types/config.js';
4
+ import { ForwardedLogMessage } from './services/cli-logger-forwarder.service.js';
5
+ /**
6
+ * Default CLI renderer that logs output using the logger
7
+ */
8
+ export declare const defaultCLIRenderer: import("@pikku/core").CorePikkuCLIRender<ForwardedLogMessage, SingletonServices, import("@pikku/core").CoreUserSession>;
9
+ export declare const createConfig: CreateConfig<Config, [PikkuCLIConfig]>;
10
+ /**
11
+ * Singleton services factory for the Pikku CLI
12
+ * This function creates the singleton services used by the CLI and is created once on start.
13
+ */
14
+ export declare const createSingletonServices: CreateSingletonServices<Config, SingletonServices>;
15
+ export declare const createSessionServices: CreateSessionServices<SingletonServices, Services, UserSession>;
@@ -0,0 +1,64 @@
1
+ import { pikkuCLIRender, } from '@pikku/core';
2
+ import { LocalVariablesService } from '@pikku/core/services';
3
+ import { CLILogger } from './services/cli-logger.service.js';
4
+ import { getPikkuCLIConfig } from './utils/pikku-cli-config.js';
5
+ import { inspect } from '@pikku/inspector';
6
+ import { glob } from 'tinyglobby';
7
+ import path from 'path';
8
+ import { CLILoggerForwarder, } from './services/cli-logger-forwarder.service.js';
9
+ const logger = new CLILogger({ logLogo: true, silent: false });
10
+ /**
11
+ * Default CLI renderer that logs output using the logger
12
+ */
13
+ export const defaultCLIRenderer = pikkuCLIRender((_services, data) => {
14
+ if (data) {
15
+ logger[data.level]({ message: data.message, type: data.type });
16
+ }
17
+ });
18
+ export const createConfig = async (_variablesService, data) => {
19
+ const cliConfig = await getPikkuCLIConfig(logger, data.configFile, [], data, true);
20
+ return {
21
+ ...cliConfig,
22
+ ...data,
23
+ };
24
+ };
25
+ /**
26
+ * Singleton services factory for the Pikku CLI
27
+ * This function creates the singleton services used by the CLI and is created once on start.
28
+ */
29
+ export const createSingletonServices = async (config) => {
30
+ const { rootDir, srcDirectories, filters } = config;
31
+ const variables = new LocalVariablesService();
32
+ let inspectorState = undefined;
33
+ const getInspectorState = async (refresh = false) => {
34
+ if (refresh || !inspectorState) {
35
+ const wiringFiles = (await Promise.all(srcDirectories.map((dir) => glob(`${path.join(rootDir, dir)}/**/*.ts`)))).flat();
36
+ inspectorState = await inspect(logger, wiringFiles, {
37
+ filters,
38
+ types: {
39
+ configFileType: config.configFile,
40
+ userSessionType: config.tags?.[0], // TODO: Properly handle type selection
41
+ singletonServicesFactoryType: undefined,
42
+ sessionServicesFactoryType: undefined,
43
+ },
44
+ });
45
+ return inspectorState;
46
+ }
47
+ return inspectorState;
48
+ };
49
+ return {
50
+ config,
51
+ logger,
52
+ variables,
53
+ getInspectorState,
54
+ };
55
+ };
56
+ export const createSessionServices = async ({ logger }, { cli, channel }) => {
57
+ const vChannel = cli ? cli.channel : channel;
58
+ if (!vChannel) {
59
+ throw new Error('No channel provided for CLI services');
60
+ }
61
+ return {
62
+ logger: new CLILoggerForwarder(logger, vChannel),
63
+ };
64
+ };
@@ -0,0 +1,10 @@
1
+ import { FilesAndMethodsErrors } from '@pikku/inspector';
2
+ export type RequiredTypes = Partial<{
3
+ config: boolean;
4
+ sessionServiceType: boolean;
5
+ singletonServicesType: boolean;
6
+ userSessionType: boolean;
7
+ singletonServicesFactory: boolean;
8
+ sessionServicesFactory: boolean;
9
+ }>;
10
+ export declare const checkRequiredTypes: (errors: FilesAndMethodsErrors, requires?: RequiredTypes) => void;
@@ -0,0 +1,31 @@
1
+ export const checkRequiredTypes = (errors, requires = {}) => {
2
+ // Only throw if there are errors AND we require those types
3
+ const hasRequiredErrors = Array.from(errors.keys()).some((message) => {
4
+ if (requires.config && message.includes('CoreConfig'))
5
+ return true;
6
+ if (requires.sessionServiceType && message.includes('CoreServices'))
7
+ return true;
8
+ if (requires.singletonServicesType &&
9
+ message.includes('CoreSingletonServices'))
10
+ return true;
11
+ if (requires.userSessionType && message.includes('CoreUserSession'))
12
+ return true;
13
+ if (requires.singletonServicesFactory &&
14
+ message.includes('CreateSingletonServices'))
15
+ return true;
16
+ if (requires.sessionServicesFactory &&
17
+ message.includes('CreateSessionServices'))
18
+ return true;
19
+ return false;
20
+ });
21
+ if (hasRequiredErrors) {
22
+ const result = ['Found errors:'];
23
+ errors.forEach((filesAndMethods, message) => {
24
+ result.push(`- ${message}`);
25
+ filesAndMethods.forEach((methods, file) => {
26
+ result.push(`\t* methods: ${methods.map(({ variable, type }) => `${variable}: ${type}`).join(', ')}`);
27
+ });
28
+ });
29
+ throw new Error(result.join('\n'));
30
+ }
31
+ };
@@ -0,0 +1,2 @@
1
+ import { TypesMap } from '@pikku/inspector';
2
+ export declare function generateCustomTypes(typesMap: TypesMap, requiredTypes: Set<string>): string;
@@ -0,0 +1,37 @@
1
+ export function generateCustomTypes(typesMap, requiredTypes) {
2
+ return `
3
+ // Custom types are those that are defined directly within generics
4
+ // or are broken into simpler types
5
+ ${Array.from(typesMap.customTypes.entries())
6
+ .map(([name, { type, references }]) => {
7
+ references.forEach((name) => {
8
+ requiredTypes.add(name);
9
+ });
10
+ // Extract type names from the type string that might not be in references
11
+ const typeString = type;
12
+ // Use regex to extract potential type names (PascalCase identifiers)
13
+ const typeNameRegex = /\b[A-Z][a-zA-Z0-9]*\b/g;
14
+ const potentialTypes = typeString.match(typeNameRegex) || [];
15
+ potentialTypes.forEach((typeName) => {
16
+ // Skip string literals and common keywords
17
+ if (typeString.includes(`"${typeName}"`) ||
18
+ ['Pick', 'Omit', 'Partial', 'Required', 'Record', 'Readonly'].includes(typeName)) {
19
+ return;
20
+ }
21
+ // Try to find this type in the typesMap and add it if found
22
+ try {
23
+ const typeMeta = typesMap.getTypeMeta(typeName);
24
+ if (typeMeta.path) {
25
+ // Add originalName to preserve canonical import name
26
+ requiredTypes.add(typeMeta.originalName);
27
+ }
28
+ }
29
+ catch (e) {
30
+ // Type not found in map (ambient/builtin type) - ignore it
31
+ // Do NOT add to requiredTypes to avoid crashes in serializeImportMap
32
+ }
33
+ });
34
+ return `export type ${name} = ${type}`;
35
+ })
36
+ .join('\n')}`;
37
+ }
@@ -0,0 +1 @@
1
+ export declare const getFileImportRelativePath: (from: string, to: string, packageMappings: Record<string, string>) => string;
@@ -0,0 +1,43 @@
1
+ import { relative, dirname, resolve } from 'path';
2
+ export const getFileImportRelativePath = (from, to, packageMappings) => {
3
+ let filePath = relative(dirname(from), to);
4
+ if (!/^\.+\//.test(filePath)) {
5
+ filePath = `./${filePath}`;
6
+ }
7
+ // If the path includes node_modules, strip everything before and including node_modules/
8
+ if (filePath.includes('node_modules')) {
9
+ const nodeModulesIndex = filePath.indexOf('node_modules/');
10
+ if (nodeModulesIndex !== -1) {
11
+ filePath = filePath.substring(nodeModulesIndex + 'node_modules/'.length);
12
+ }
13
+ return filePath.replace('.ts', '.js');
14
+ }
15
+ const absolutePath = resolve(dirname(from), to);
16
+ const fromAbsolutePath = resolve(dirname(from));
17
+ // Check if both files are in the same package directory
18
+ // If so, skip packageMappings to use relative paths
19
+ let inSamePackage = false;
20
+ for (const [path] of Object.entries(packageMappings)) {
21
+ if (absolutePath.includes(path) && fromAbsolutePath.includes(path)) {
22
+ inSamePackage = true;
23
+ break;
24
+ }
25
+ }
26
+ // Only apply packageMappings if files are not in the same package
27
+ if (!inSamePackage) {
28
+ // let usesPackageName = false
29
+ for (const [path, packageName] of Object.entries(packageMappings)) {
30
+ if (absolutePath.includes(path)) {
31
+ // usesPackageName = true
32
+ // Use string slicing instead of regex to avoid ReDoS and ensure correct behavior
33
+ const pathIndex = absolutePath.indexOf(path);
34
+ filePath = packageName + absolutePath.slice(pathIndex + path.length);
35
+ break;
36
+ }
37
+ }
38
+ }
39
+ // if (usesPackageName) {
40
+ // return filePath.replace('.ts', '')
41
+ // }
42
+ return filePath.replace('.ts', '.js');
43
+ };
@@ -0,0 +1 @@
1
+ export declare const serializeFileImports: (importType: string, outputPath: string, files: Set<string>, packageMappings?: Record<string, string>) => string;
@@ -0,0 +1,13 @@
1
+ import { getFileImportRelativePath } from './file-import-path.js';
2
+ export const serializeFileImports = (importType, outputPath, files, packageMappings = {}) => {
3
+ const serializedOutput = [
4
+ `/* The files with an ${importType} function call */`,
5
+ ];
6
+ Array.from(files)
7
+ .sort()
8
+ .forEach((path) => {
9
+ const filePath = getFileImportRelativePath(outputPath, path, packageMappings);
10
+ serializedOutput.push(`import '${filePath}'`);
11
+ });
12
+ return serializedOutput.join('\n');
13
+ };
@@ -0,0 +1,6 @@
1
+ import { CLILogger } from '../services/cli-logger.service.js';
2
+ export declare const DO_NOT_MODIFY_COMMENT = "/**\n * This file was generated by the @pikku/cli\n */\n";
3
+ export declare const writeFileInDir: (logger: CLILogger, path: string, content: string, { ignoreModifyComment, logWrite, }?: {
4
+ ignoreModifyComment?: boolean;
5
+ logWrite?: boolean;
6
+ }) => Promise<void>;
@@ -0,0 +1,40 @@
1
+ import { dirname } from 'path';
2
+ import { mkdir, readFile, writeFile } from 'fs/promises';
3
+ // TODO: add version back in once the ESM dust settles
4
+ export const DO_NOT_MODIFY_COMMENT = `/**
5
+ * This file was generated by the @pikku/cli
6
+ */
7
+ `;
8
+ export const writeFileInDir = async (logger, path, content, { ignoreModifyComment = false, logWrite = true, } = {}) => {
9
+ if (path.includes('.json')) {
10
+ ignoreModifyComment = true;
11
+ }
12
+ if (content.includes('server-only')) {
13
+ content = content.replace("'server-only'", `'server-only'\n\n${ignoreModifyComment ? '' : DO_NOT_MODIFY_COMMENT}`);
14
+ }
15
+ else {
16
+ content = `${ignoreModifyComment ? '' : DO_NOT_MODIFY_COMMENT}${content}`;
17
+ }
18
+ // Try to read existing file content
19
+ let existingContent;
20
+ try {
21
+ existingContent = await readFile(path, 'utf-8');
22
+ }
23
+ catch (error) {
24
+ // Only suppress ENOENT (file not found) errors
25
+ // Rethrow permission, I/O, encoding, or other errors
26
+ const nodeError = error;
27
+ if (nodeError.code !== 'ENOENT') {
28
+ throw error;
29
+ }
30
+ // File doesn't exist, so we need to write it
31
+ }
32
+ // Only write if content has changed or file doesn't exist
33
+ if (existingContent !== content) {
34
+ await mkdir(dirname(path), { recursive: true });
35
+ await writeFile(path, content, 'utf-8');
36
+ if (logWrite) {
37
+ logger.info({ message: `✓ File written to ${path}`, type: 'success' });
38
+ }
39
+ }
40
+ };
@@ -0,0 +1,3 @@
1
+ import { Config } from '../../types/application-types.js';
2
+ import { CLILogger } from '../services/cli-logger.service.js';
3
+ export declare const generateBootstrapFile: (logger: CLILogger, config: Config, bootstrapFile: string, specificImports: string[], schemas?: boolean, hasMiddleware?: boolean) => Promise<void>;
@@ -0,0 +1,21 @@
1
+ import { getFileImportRelativePath } from './file-import-path.js';
2
+ import { writeFileInDir } from './file-writer.js';
3
+ export const generateBootstrapFile = async (logger, config, bootstrapFile, specificImports, schemas, hasMiddleware) => {
4
+ // Common imports that every bootstrap file needs
5
+ const commonImports = [];
6
+ // Add middleware first (must be registered before functions meta)
7
+ if (hasMiddleware) {
8
+ commonImports.push(config.middlewareFile);
9
+ }
10
+ commonImports.push(config.functionsMetaMinFile, config.functionsFile);
11
+ // Add schema if it exists
12
+ if (schemas) {
13
+ commonImports.push(`${config.schemaDirectory}/register.gen.ts`);
14
+ }
15
+ // Combine common imports with specific imports
16
+ const allImports = [...commonImports, ...specificImports];
17
+ await writeFileInDir(logger, bootstrapFile, allImports
18
+ .map((to) => `import '${getFileImportRelativePath(bootstrapFile, to, config.packageMappings)}'`)
19
+ .sort((to) => (to.includes('meta') ? -1 : 1)) // Ensure meta files are at the top
20
+ .join('\n'));
21
+ };
@@ -0,0 +1,5 @@
1
+ import { PikkuCLIConfig } from '../../types/config.js';
2
+ import { InspectorFilters } from '@pikku/inspector';
3
+ import { CLILogger } from '../services/cli-logger.service.js';
4
+ export declare const getPikkuCLIConfig: (logger: CLILogger, configFile: string | undefined, requiredFields: Array<keyof PikkuCLIConfig>, filters?: InspectorFilters, exitProcess?: boolean) => Promise<PikkuCLIConfig>;
5
+ export declare const validateCLIConfig: (cliConfig: PikkuCLIConfig, required: Array<keyof PikkuCLIConfig>) => void;
@@ -0,0 +1,243 @@
1
+ import { join, dirname, resolve, isAbsolute } from 'path';
2
+ import { readdir, readFile } from 'fs/promises';
3
+ import { PikkuWiringTypes } from '@pikku/core';
4
+ const CONFIG_DIR_FILES = [
5
+ 'nextBackendFile',
6
+ 'nextHTTPFile',
7
+ 'fetchFile',
8
+ 'websocketFile',
9
+ 'rpcWiringsFile',
10
+ 'queueWiringsFile',
11
+ 'mcpJsonFile',
12
+ ];
13
+ export const getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields, filters = {}, exitProcess = false) => {
14
+ const config = await _getPikkuCLIConfig(logger, configFile, requiredFields, filters, exitProcess);
15
+ return config;
16
+ };
17
+ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields, filters = {}, exitProcess = false) => {
18
+ if (!configFile) {
19
+ let execDirectory = process.cwd();
20
+ const files = await readdir(execDirectory);
21
+ const file = files.find((file) => /pikku\.config\.(ts|js|json)$/.test(file));
22
+ if (!file) {
23
+ throw new Error('Config file pikku.config.json not found');
24
+ }
25
+ configFile = join(execDirectory, file);
26
+ }
27
+ try {
28
+ let result;
29
+ const file = await readFile(configFile, 'utf-8');
30
+ const configDir = dirname(configFile);
31
+ const config = JSON.parse(file);
32
+ if (config.extends) {
33
+ const extendedConfig = await getPikkuCLIConfig(logger, resolve(configDir, config.extends), [], filters, exitProcess);
34
+ result = {
35
+ ...extendedConfig,
36
+ ...config,
37
+ configDir,
38
+ packageMappings: {
39
+ ...extendedConfig.packageMappings,
40
+ ...config.packageMappings,
41
+ },
42
+ };
43
+ }
44
+ else {
45
+ result = {
46
+ ...config,
47
+ configDir,
48
+ packageMappings: config.packageMappings || {},
49
+ rootDir: config.rootDir
50
+ ? resolve(configDir, config.rootDir)
51
+ : configDir,
52
+ };
53
+ }
54
+ // Create transport/event directories
55
+ const functionDir = join(result.outDir, 'function');
56
+ const httpDir = join(result.outDir, 'http');
57
+ const channelDir = join(result.outDir, 'channel');
58
+ const rpcDir = join(result.outDir, 'rpc');
59
+ const schedulerDir = join(result.outDir, 'scheduler');
60
+ const queueDir = join(result.outDir, 'queue');
61
+ const mcpDir = join(result.outDir, 'mcp');
62
+ const cliDir = join(result.outDir, 'cli');
63
+ const middlewareDir = join(result.outDir, 'middleware');
64
+ // Create directories if they don't exist (will be done lazily when files are written)
65
+ if (!result.schemaDirectory) {
66
+ result.schemaDirectory = join(result.outDir, 'schemas');
67
+ }
68
+ // Functions
69
+ if (!result.functionsFile) {
70
+ result.functionsFile = join(functionDir, 'pikku-functions.gen.ts');
71
+ }
72
+ if (!result.functionsMetaFile) {
73
+ result.functionsMetaFile = join(functionDir, 'pikku-functions-meta.gen.ts');
74
+ }
75
+ if (!result.functionsMetaMinFile) {
76
+ result.functionsMetaMinFile = join(functionDir, 'pikku-functions-meta.min.gen.ts');
77
+ }
78
+ if (!result.functionTypesFile) {
79
+ result.functionTypesFile = join(functionDir, 'pikku-function-types.gen.ts');
80
+ }
81
+ if (!result.typesDeclarationFile) {
82
+ result.typesDeclarationFile = join(result.outDir, 'pikku-types.gen.ts');
83
+ }
84
+ // HTTP
85
+ if (!result.httpWiringsFile) {
86
+ result.httpWiringsFile = join(httpDir, 'pikku-http-wirings.gen.ts');
87
+ }
88
+ if (!result.httpWiringMetaFile) {
89
+ result.httpWiringMetaFile = join(httpDir, 'pikku-http-wirings-meta.gen.ts');
90
+ }
91
+ if (!result.httpMapDeclarationFile) {
92
+ result.httpMapDeclarationFile = join(httpDir, 'pikku-http-wirings-map.gen.d.ts');
93
+ }
94
+ if (!result.httpTypesFile) {
95
+ result.httpTypesFile = join(httpDir, 'pikku-http-types.gen.ts');
96
+ }
97
+ // Channels/WebSocket
98
+ if (!result.channelsWiringFile) {
99
+ result.channelsWiringFile = join(channelDir, 'pikku-channels.gen.ts');
100
+ }
101
+ if (!result.channelsWiringMetaFile) {
102
+ result.channelsWiringMetaFile = join(channelDir, 'pikku-channels-meta.gen.ts');
103
+ }
104
+ if (!result.channelsMapDeclarationFile) {
105
+ result.channelsMapDeclarationFile = join(channelDir, 'pikku-channels-map.gen.d.ts');
106
+ }
107
+ if (!result.channelsTypesFile) {
108
+ result.channelsTypesFile = join(channelDir, 'pikku-channel-types.gen.ts');
109
+ }
110
+ // RPC (internal and external)
111
+ if (!result.rpcInternalWiringMetaFile) {
112
+ result.rpcInternalWiringMetaFile = join(rpcDir, 'pikku-rpc-wirings-meta.internal.gen.ts');
113
+ }
114
+ if (!result.rpcInternalMapDeclarationFile) {
115
+ result.rpcInternalMapDeclarationFile = join(rpcDir, 'pikku-rpc-wirings-map.internal.gen.d.ts');
116
+ }
117
+ if (!result.rpcMapDeclarationFile) {
118
+ result.rpcMapDeclarationFile = join(rpcDir, 'pikku-rpc-wirings-map.gen.d.ts');
119
+ }
120
+ // Scheduler
121
+ if (!result.schedulersWiringFile) {
122
+ result.schedulersWiringFile = join(schedulerDir, 'pikku-schedulers-wirings.gen.ts');
123
+ }
124
+ if (!result.schedulersWiringMetaFile) {
125
+ result.schedulersWiringMetaFile = join(schedulerDir, 'pikku-schedulers-wirings-meta.gen.ts');
126
+ }
127
+ if (!result.schedulersTypesFile) {
128
+ result.schedulersTypesFile = join(schedulerDir, 'pikku-scheduler-types.gen.ts');
129
+ }
130
+ // Queue
131
+ if (!result.queueWorkersWiringFile) {
132
+ result.queueWorkersWiringFile = join(queueDir, 'pikku-queue-workers-wirings.gen.ts');
133
+ }
134
+ if (!result.queueWorkersWiringMetaFile) {
135
+ result.queueWorkersWiringMetaFile = join(queueDir, 'pikku-queue-workers-wirings-meta.gen.ts');
136
+ }
137
+ if (!result.queueMapDeclarationFile) {
138
+ result.queueMapDeclarationFile = join(queueDir, 'pikku-queue-workers-wirings-map.gen.d.ts');
139
+ }
140
+ if (!result.queueTypesFile) {
141
+ result.queueTypesFile = join(queueDir, 'pikku-queue-types.gen.ts');
142
+ }
143
+ // Services
144
+ if (!result.servicesFile) {
145
+ result.servicesFile = join(result.outDir, 'pikku-services.gen.ts');
146
+ }
147
+ // Middleware
148
+ if (!result.middlewareFile) {
149
+ result.middlewareFile = join(middlewareDir, 'pikku-middleware.gen.ts');
150
+ }
151
+ if (!result.middlewareGroupsMetaFile) {
152
+ result.middlewareGroupsMetaFile = join(middlewareDir, 'pikku-middleware-groups-meta.gen.ts');
153
+ }
154
+ // Bootstrap files
155
+ if (!result.bootstrapFile) {
156
+ result.bootstrapFile = join(result.outDir, 'pikku-bootstrap.gen.ts');
157
+ }
158
+ // MCP
159
+ if (!result.mcpWiringsMetaFile) {
160
+ result.mcpWiringsMetaFile = join(mcpDir, 'pikku-mcp-wirings-meta.gen.ts');
161
+ }
162
+ if (!result.mcpWiringsFile) {
163
+ result.mcpWiringsFile = join(mcpDir, 'pikku-mcp-wirings.gen.ts');
164
+ }
165
+ if (!result.mcpJsonFile) {
166
+ result.mcpJsonFile = join(mcpDir, 'pikku-mcp.gen.json');
167
+ }
168
+ if (!result.mcpTypesFile) {
169
+ result.mcpTypesFile = join(mcpDir, 'pikku-mcp-types.gen.ts');
170
+ }
171
+ // CLI
172
+ if (!result.cliWiringsFile) {
173
+ result.cliWiringsFile = join(cliDir, 'pikku-cli-wirings.gen.ts');
174
+ }
175
+ if (!result.cliWiringMetaFile) {
176
+ result.cliWiringMetaFile = join(cliDir, 'pikku-cli-wirings-meta.gen.ts');
177
+ }
178
+ if (!result.cliBootstrapFile) {
179
+ result.cliBootstrapFile = join(cliDir, 'pikku-cli-bootstrap.gen.ts');
180
+ }
181
+ if (!result.cliTypesFile) {
182
+ result.cliTypesFile = join(cliDir, 'pikku-cli-types.gen.ts');
183
+ }
184
+ result.bootstrapFiles = result.bootstrapFiles || {};
185
+ for (const key of Object.keys(PikkuWiringTypes)) {
186
+ const eventDir = join(result.outDir, key.toLowerCase());
187
+ result.bootstrapFiles[key] = join(eventDir, `pikku-bootstrap-${key}.gen.ts`);
188
+ }
189
+ if (requiredFields.length > 0) {
190
+ validateCLIConfig(result, requiredFields);
191
+ }
192
+ for (const objectKey of Object.keys(result)) {
193
+ if (objectKey.endsWith('File') || objectKey.endsWith('Directory')) {
194
+ const relativeTo = CONFIG_DIR_FILES.includes(objectKey)
195
+ ? result.configDir
196
+ : result.rootDir;
197
+ // Only normalize string values to avoid corrupting nested objects
198
+ if (result[objectKey] && typeof result[objectKey] === 'string') {
199
+ if (!isAbsolute(result[objectKey])) {
200
+ result[objectKey] = join(relativeTo, result[objectKey]);
201
+ }
202
+ }
203
+ }
204
+ }
205
+ // Separately normalize bootstrapFiles (Record<string, string>)
206
+ if (result.bootstrapFiles && typeof result.bootstrapFiles === 'object') {
207
+ for (const [key, value] of Object.entries(result.bootstrapFiles)) {
208
+ if (typeof value === 'string' && !isAbsolute(value)) {
209
+ result.bootstrapFiles[key] = join(result.rootDir, value);
210
+ }
211
+ }
212
+ }
213
+ result.filters = result.filters || {};
214
+ if (filters.tags && filters.tags.length > 0) {
215
+ result.filters.tags = filters.tags;
216
+ }
217
+ if (filters.types && filters.types.length > 0) {
218
+ result.filters.types = filters.types;
219
+ }
220
+ if (filters.directories && filters.directories.length > 0) {
221
+ result.filters.directories = filters.directories;
222
+ }
223
+ if (!isAbsolute(result.tsconfig)) {
224
+ result.tsconfig = join(result.rootDir, result.tsconfig);
225
+ }
226
+ return result;
227
+ }
228
+ catch (e) {
229
+ logger.error(e);
230
+ throw new Error(`Config file not found: ${configFile}`);
231
+ }
232
+ };
233
+ export const validateCLIConfig = (cliConfig, required) => {
234
+ let errors = [];
235
+ for (const key of required) {
236
+ if (!cliConfig[key]) {
237
+ errors.push(key);
238
+ }
239
+ }
240
+ if (errors.length > 0) {
241
+ throw new Error(`${errors.join(', ')} ${errors.length === 1 ? 'is' : 'are'} required in pikku.config.json`);
242
+ }
243
+ };
@@ -0,0 +1,21 @@
1
+ import { InspectorState, InspectorOptions } from '@pikku/inspector';
2
+ interface Meta {
3
+ file: string;
4
+ variable: string;
5
+ type: string;
6
+ typePath: string;
7
+ errors: Map<string, string[]>;
8
+ }
9
+ export type FilesAndMethods = {
10
+ userSessionType: Meta;
11
+ sessionServicesType: Meta;
12
+ singletonServicesType: Meta;
13
+ pikkuConfigFactory: Meta;
14
+ singletonServicesFactory: Meta;
15
+ sessionServicesFactory: Meta;
16
+ };
17
+ /**
18
+ * @deprecated Use state.filesAndMethods from InspectorState instead
19
+ */
20
+ export declare const getPikkuFilesAndMethods: (state: InspectorState, options?: InspectorOptions["types"]) => Promise<FilesAndMethods>;
21
+ export {};