@pikku/cli 0.9.15 → 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 (443) 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 +9 -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/services/cli-logger-forwarder.service.d.ts +26 -0
  198. package/dist/src/services/cli-logger-forwarder.service.js +55 -0
  199. package/dist/src/services/cli-logger.service.d.ts +19 -0
  200. package/dist/src/services/cli-logger.service.js +66 -0
  201. package/dist/src/services.d.ts +15 -0
  202. package/dist/src/services.js +64 -0
  203. package/dist/src/utils/check-required-types.d.ts +10 -0
  204. package/dist/src/utils/check-required-types.js +31 -0
  205. package/dist/src/utils/custom-types-generator.d.ts +2 -0
  206. package/dist/src/utils/custom-types-generator.js +37 -0
  207. package/dist/src/utils/file-import-path.d.ts +1 -0
  208. package/dist/src/utils/file-import-path.js +43 -0
  209. package/dist/src/utils/file-imports-serializer.d.ts +1 -0
  210. package/dist/src/utils/file-imports-serializer.js +13 -0
  211. package/dist/src/utils/file-writer.d.ts +6 -0
  212. package/dist/src/utils/file-writer.js +40 -0
  213. package/dist/src/utils/generate-bootstrap-file.d.ts +3 -0
  214. package/dist/src/utils/generate-bootstrap-file.js +21 -0
  215. package/dist/src/utils/pikku-cli-config.d.ts +5 -0
  216. package/dist/src/utils/pikku-cli-config.js +243 -0
  217. package/dist/src/utils/pikku-files-and-methods.d.ts +21 -0
  218. package/dist/src/utils/pikku-files-and-methods.js +70 -0
  219. package/dist/src/{schema-generator.d.ts → utils/schema-generator.d.ts} +1 -1
  220. package/dist/src/{schema-generator.js → utils/schema-generator.js} +1 -1
  221. package/dist/src/{serialize-import-map.js → utils/serialize-import-map.js} +1 -1
  222. package/dist/tsconfig.tsbuildinfo +1 -1
  223. package/package.json +6 -6
  224. package/pikku.config.json +24 -0
  225. package/src/cli.wiring.ts +75 -0
  226. package/src/functions/commands/all.ts +141 -0
  227. package/src/functions/commands/watch.ts +58 -0
  228. package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +111 -0
  229. package/src/functions/wirings/channels/pikku-channels.ts +40 -0
  230. package/src/functions/wirings/channels/pikku-command-channel-types.ts +27 -0
  231. package/src/functions/wirings/channels/pikku-command-channels-map.ts +31 -0
  232. package/src/functions/wirings/channels/pikku-command-channels.ts +45 -0
  233. package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +33 -0
  234. package/src/functions/wirings/channels/serialize-channel-types.ts +95 -0
  235. package/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.ts +2 -2
  236. package/src/functions/wirings/cli/pikku-command-cli-entry.ts +173 -0
  237. package/src/functions/wirings/cli/pikku-command-cli-types.ts +50 -0
  238. package/src/functions/wirings/cli/pikku-command-cli.ts +41 -0
  239. package/src/functions/wirings/cli/serialize-channel-cli-client.ts +72 -0
  240. package/src/functions/wirings/cli/serialize-channel-cli.ts +123 -0
  241. package/src/functions/wirings/cli/serialize-cli-types.ts +80 -0
  242. package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +75 -0
  243. package/src/functions/wirings/fetch/index.ts +32 -0
  244. package/src/functions/wirings/functions/pikku-command-function-types-split.ts +51 -0
  245. package/src/functions/wirings/functions/pikku-command-function-types.ts +45 -0
  246. package/src/functions/wirings/functions/pikku-command-functions.ts +61 -0
  247. package/src/{wirings → functions/wirings}/functions/pikku-command-services.ts +41 -44
  248. package/src/functions/wirings/functions/pikku-function-types.ts +45 -0
  249. package/src/functions/wirings/functions/schemas.ts +47 -0
  250. package/src/{wirings → functions/wirings}/functions/serialize-function-imports.ts +4 -30
  251. package/src/functions/wirings/functions/serialize-function-types.ts +303 -0
  252. package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +39 -0
  253. package/src/{wirings → functions/wirings}/http/openapi-spec-generator.ts +3 -1
  254. package/src/functions/wirings/http/pikku-command-http-map.ts +32 -0
  255. package/src/functions/wirings/http/pikku-command-http-routes.ts +41 -0
  256. package/src/functions/wirings/http/pikku-command-http-types.ts +27 -0
  257. package/src/functions/wirings/http/pikku-command-openapi.ts +57 -0
  258. package/src/functions/wirings/http/pikku-http-routes.ts +40 -0
  259. package/src/functions/wirings/http/serialize-http-types.ts +64 -0
  260. package/src/{wirings → functions/wirings}/http/serialize-typed-http-map.ts +2 -2
  261. package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +38 -0
  262. package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +27 -0
  263. package/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.ts +55 -46
  264. package/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.ts +1 -1
  265. package/src/functions/wirings/mcp/serialize-mcp-types.ts +141 -0
  266. package/src/functions/wirings/middleware/pikku-command-middleware.ts +65 -0
  267. package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +61 -0
  268. package/src/functions/wirings/middleware/serialize-middleware-imports.ts +78 -0
  269. package/src/functions/wirings/queue/pikku-command-queue-map.ts +31 -0
  270. package/src/functions/wirings/queue/pikku-command-queue-service.ts +33 -0
  271. package/src/functions/wirings/queue/pikku-command-queue-types.ts +27 -0
  272. package/src/functions/wirings/queue/pikku-command-queue.ts +46 -0
  273. package/src/functions/wirings/queue/pikku-queue-map.ts +31 -0
  274. package/src/functions/wirings/queue/pikku-queue.ts +44 -0
  275. package/src/{wirings → functions/wirings}/queue/serialize-queue-map.ts +2 -2
  276. package/src/functions/wirings/queue/serialize-queue-types.ts +31 -0
  277. package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +32 -0
  278. package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +52 -0
  279. package/src/functions/wirings/rpc/pikku-command-rpc.ts +28 -0
  280. package/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.ts +2 -2
  281. package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +27 -0
  282. package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +46 -0
  283. package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +29 -0
  284. package/src/middleware/log-command-info-and-time.ts +61 -0
  285. package/src/services/cli-logger-forwarder.service.ts +77 -0
  286. package/src/services/cli-logger.service.ts +78 -0
  287. package/src/services.ts +111 -0
  288. package/src/utils/check-required-types.ts +53 -0
  289. package/src/utils/custom-types-generator.ts +49 -0
  290. package/src/{utils.test.ts → utils/file-import-path.test.ts} +1 -1
  291. package/src/utils/file-import-path.ts +53 -0
  292. package/src/utils/file-imports-serializer.ts +25 -0
  293. package/src/utils/file-writer.ts +56 -0
  294. package/src/utils/generate-bootstrap-file.ts +43 -0
  295. package/src/utils/pikku-cli-config.ts +356 -0
  296. package/src/utils/pikku-files-and-methods.ts +148 -0
  297. package/src/{schema-generator.ts → utils/schema-generator.ts} +3 -1
  298. package/src/{serialize-import-map.ts → utils/serialize-import-map.ts} +1 -1
  299. package/tsconfig.json +2 -2
  300. package/types/application-types.d.ts +20 -0
  301. package/types/config.d.ts +192 -0
  302. package/bin/pikku-all.ts +0 -349
  303. package/bin/pikku-fetch.ts +0 -27
  304. package/bin/pikku-nextjs.ts +0 -44
  305. package/bin/pikku-openapi.ts +0 -31
  306. package/bin/pikku-queue-service.ts +0 -28
  307. package/bin/pikku-rpc.ts +0 -28
  308. package/bin/pikku-schemas.ts +0 -31
  309. package/bin/pikku-websocket.ts +0 -28
  310. package/dist/bin/pikku-all.d.ts +0 -4
  311. package/dist/bin/pikku-all.js +0 -194
  312. package/dist/bin/pikku-fetch.d.ts +0 -4
  313. package/dist/bin/pikku-fetch.js +0 -19
  314. package/dist/bin/pikku-nextjs.d.ts +0 -4
  315. package/dist/bin/pikku-nextjs.js +0 -24
  316. package/dist/bin/pikku-openapi.d.ts +0 -2
  317. package/dist/bin/pikku-openapi.js +0 -19
  318. package/dist/bin/pikku-queue-service.d.ts +0 -4
  319. package/dist/bin/pikku-queue-service.js +0 -19
  320. package/dist/bin/pikku-rpc.d.ts +0 -4
  321. package/dist/bin/pikku-rpc.js +0 -19
  322. package/dist/bin/pikku-schemas.d.ts +0 -2
  323. package/dist/bin/pikku-schemas.js +0 -21
  324. package/dist/bin/pikku-websocket.d.ts +0 -4
  325. package/dist/bin/pikku-websocket.js +0 -19
  326. package/dist/src/inspector-glob.d.ts +0 -2
  327. package/dist/src/inspector-glob.js +0 -12
  328. package/dist/src/pikku-cli-config.d.ts +0 -56
  329. package/dist/src/pikku-cli-config.js +0 -203
  330. package/dist/src/pikku-command-schemas.d.ts +0 -2
  331. package/dist/src/pikku-command-schemas.js +0 -8
  332. package/dist/src/runtimes/nextjs/pikku-command-nextjs.d.ts +0 -2
  333. package/dist/src/schemas.d.ts +0 -2
  334. package/dist/src/schemas.js +0 -8
  335. package/dist/src/types.d.ts +0 -5
  336. package/dist/src/utils.d.ts +0 -60
  337. package/dist/src/utils.js +0 -248
  338. package/dist/src/wirings/channels/pikku-channels.d.ts +0 -2
  339. package/dist/src/wirings/channels/pikku-channels.js +0 -9
  340. package/dist/src/wirings/channels/pikku-command-channels-map.d.ts +0 -2
  341. package/dist/src/wirings/channels/pikku-command-channels-map.js +0 -8
  342. package/dist/src/wirings/channels/pikku-command-channels.d.ts +0 -2
  343. package/dist/src/wirings/channels/pikku-command-channels.js +0 -9
  344. package/dist/src/wirings/channels/pikku-command-websocket-typed.d.ts +0 -2
  345. package/dist/src/wirings/channels/pikku-command-websocket-typed.js +0 -15
  346. package/dist/src/wirings/fetch/index.d.ts +0 -2
  347. package/dist/src/wirings/fetch/index.js +0 -12
  348. package/dist/src/wirings/functions/pikku-command-function-types.d.ts +0 -2
  349. package/dist/src/wirings/functions/pikku-command-function-types.js +0 -13
  350. package/dist/src/wirings/functions/pikku-command-functions.d.ts +0 -2
  351. package/dist/src/wirings/functions/pikku-command-functions.js +0 -14
  352. package/dist/src/wirings/functions/pikku-function-types.d.ts +0 -2
  353. package/dist/src/wirings/functions/pikku-function-types.js +0 -13
  354. package/dist/src/wirings/http/pikku-command-http-map.d.ts +0 -2
  355. package/dist/src/wirings/http/pikku-command-http-map.js +0 -8
  356. package/dist/src/wirings/http/pikku-command-http-routes.d.ts +0 -2
  357. package/dist/src/wirings/http/pikku-command-http-routes.js +0 -9
  358. package/dist/src/wirings/http/pikku-command-openapi.d.ts +0 -2
  359. package/dist/src/wirings/http/pikku-command-openapi.js +0 -20
  360. package/dist/src/wirings/http/pikku-http-routes.d.ts +0 -2
  361. package/dist/src/wirings/http/pikku-http-routes.js +0 -9
  362. package/dist/src/wirings/mcp/pikku-command-mcp-json.d.ts +0 -2
  363. package/dist/src/wirings/mcp/pikku-command-mcp-json.js +0 -13
  364. package/dist/src/wirings/mcp/pikku-command-mcp.d.ts +0 -2
  365. package/dist/src/wirings/queue/pikku-command-queue-map.d.ts +0 -2
  366. package/dist/src/wirings/queue/pikku-command-queue-map.js +0 -8
  367. package/dist/src/wirings/queue/pikku-command-queue-service.d.ts +0 -2
  368. package/dist/src/wirings/queue/pikku-command-queue-service.js +0 -15
  369. package/dist/src/wirings/queue/pikku-command-queue.d.ts +0 -2
  370. package/dist/src/wirings/queue/pikku-command-queue.js +0 -10
  371. package/dist/src/wirings/queue/pikku-queue-map.d.ts +0 -2
  372. package/dist/src/wirings/queue/pikku-queue-map.js +0 -8
  373. package/dist/src/wirings/queue/pikku-queue.d.ts +0 -2
  374. package/dist/src/wirings/queue/pikku-queue.js +0 -10
  375. package/dist/src/wirings/rpc/pikku-command-rpc-client.d.ts +0 -2
  376. package/dist/src/wirings/rpc/pikku-command-rpc-client.js +0 -15
  377. package/dist/src/wirings/rpc/pikku-command-rpc-map.d.ts +0 -3
  378. package/dist/src/wirings/rpc/pikku-command-rpc-map.js +0 -14
  379. package/dist/src/wirings/rpc/pikku-command-rpc.d.ts +0 -2
  380. package/dist/src/wirings/rpc/pikku-command-rpc.js +0 -8
  381. package/dist/src/wirings/scheduler/pikku-command-scheduler.d.ts +0 -2
  382. package/dist/src/wirings/scheduler/pikku-command-scheduler.js +0 -10
  383. package/src/inspector-glob.ts +0 -30
  384. package/src/pikku-cli-config.ts +0 -387
  385. package/src/pikku-command-schemas.ts +0 -35
  386. package/src/runtimes/nextjs/pikku-command-nextjs.ts +0 -110
  387. package/src/schemas.ts +0 -35
  388. package/src/types.ts +0 -16
  389. package/src/utils.ts +0 -420
  390. package/src/wirings/channels/pikku-channels.ts +0 -41
  391. package/src/wirings/channels/pikku-command-channels-map.ts +0 -26
  392. package/src/wirings/channels/pikku-command-channels.ts +0 -39
  393. package/src/wirings/channels/pikku-command-websocket-typed.ts +0 -36
  394. package/src/wirings/fetch/index.ts +0 -33
  395. package/src/wirings/functions/pikku-command-function-types.ts +0 -53
  396. package/src/wirings/functions/pikku-command-functions.ts +0 -48
  397. package/src/wirings/functions/pikku-function-types.ts +0 -52
  398. package/src/wirings/http/pikku-command-http-map.ts +0 -27
  399. package/src/wirings/http/pikku-command-http-routes.ts +0 -40
  400. package/src/wirings/http/pikku-command-openapi.ts +0 -55
  401. package/src/wirings/http/pikku-http-routes.ts +0 -40
  402. package/src/wirings/mcp/pikku-command-mcp-json.ts +0 -33
  403. package/src/wirings/queue/pikku-command-queue-map.ts +0 -26
  404. package/src/wirings/queue/pikku-command-queue-service.ts +0 -36
  405. package/src/wirings/queue/pikku-command-queue.ts +0 -45
  406. package/src/wirings/queue/pikku-queue-map.ts +0 -26
  407. package/src/wirings/queue/pikku-queue.ts +0 -43
  408. package/src/wirings/rpc/pikku-command-rpc-client.ts +0 -35
  409. package/src/wirings/rpc/pikku-command-rpc-map.ts +0 -49
  410. package/src/wirings/rpc/pikku-command-rpc.ts +0 -24
  411. package/src/wirings/scheduler/pikku-command-scheduler.ts +0 -43
  412. /package/dist/{src/types.js → .pikku/cli/pikku-cli-wirings-meta.gen.d.ts} +0 -0
  413. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.d.ts +0 -0
  414. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.js +0 -0
  415. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.d.ts +0 -0
  416. /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.js +0 -0
  417. /package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
  418. /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
  419. /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.js +0 -0
  420. /package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.d.ts +0 -0
  421. /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
  422. /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.js +0 -0
  423. /package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.d.ts +0 -0
  424. /package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.js +0 -0
  425. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.d.ts +0 -0
  426. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.d.ts +0 -0
  427. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.js +0 -0
  428. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
  429. /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.js +0 -0
  430. /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
  431. /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.js +0 -0
  432. /package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
  433. /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
  434. /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.js +0 -0
  435. /package/dist/src/{serialize-import-map.d.ts → utils/serialize-import-map.d.ts} +0 -0
  436. /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.ts +0 -0
  437. /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.ts +0 -0
  438. /package/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.ts +0 -0
  439. /package/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.ts +0 -0
  440. /package/src/{wirings → functions/wirings}/queue/serialize-queue-meta.ts +0 -0
  441. /package/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.ts +0 -0
  442. /package/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.ts +0 -0
  443. /package/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.ts +0 -0
@@ -0,0 +1,33 @@
1
+ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
2
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
3
+ import { writeFileInDir } from '../../../utils/file-writer.js'
4
+ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
5
+ import { serializeWebsocketWrapper } from './serialize-websocket-wrapper.js'
6
+
7
+ export const pikkuWebSocketTyped: any = pikkuSessionlessFunc<void, void>({
8
+ func: async ({ logger, config }) => {
9
+ const { websocketFile, channelsMapDeclarationFile, packageMappings } =
10
+ config
11
+
12
+ if (!websocketFile) {
13
+ throw new Error("fetchFile is isn't set in the pikku config")
14
+ }
15
+
16
+ const channelsMapDeclarationPath = getFileImportRelativePath(
17
+ websocketFile,
18
+ channelsMapDeclarationFile,
19
+ packageMappings
20
+ )
21
+
22
+ const content = [serializeWebsocketWrapper(channelsMapDeclarationPath)]
23
+ await writeFileInDir(logger, websocketFile, content.join('\n'))
24
+ },
25
+ middleware: [
26
+ logCommandInfoAndTime({
27
+ commandStart: 'Generating websocket wrapper',
28
+ commandEnd: 'Generated websocket wrapper',
29
+ skipCondition: ({ config }) => config.websocketFile === undefined,
30
+ skipMessage: "websocketFile isn't set in the pikku config",
31
+ }),
32
+ ],
33
+ })
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Generates type definitions for WebSocket channel wirings
3
+ */
4
+ export const serializeChannelTypes = (functionTypesImportPath: string) => {
5
+ return `/**
6
+ * This file was generated by the @pikku/cli
7
+ * Channel-specific type definitions for tree-shaking optimization
8
+ */
9
+
10
+ import { CoreChannel, wireChannel as wireChannelCore } from '@pikku/core/channel'
11
+ import { CorePikkuFunctionConfig } from '@pikku/core'
12
+ import { AssertHTTPWiringParams } from '@pikku/core/http'
13
+ import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
14
+
15
+ /**
16
+ * Type definition for WebSocket channels with typed data exchange.
17
+ * Supports connection, disconnection, and message handling.
18
+ *
19
+ * @template ChannelData - Type of data exchanged through the channel
20
+ * @template Channel - String literal type for the channel name
21
+ */
22
+ type ChannelWiringFunction<I, O, C = {}> = PikkuFunctionSessionless<I, O, C> | PikkuFunction<I, O, C>
23
+ type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<ChannelData, Channel, ChannelWiringFunction<void, unknown> | ChannelWiringFunction<void, unknown, ChannelData>, ChannelWiringFunction<void, void> | ChannelWiringFunction<void, void, ChannelData>, ChannelWiringFunction<any, any> | ChannelWiringFunction<any, any, ChannelData>, PikkuPermission, PikkuMiddleware>
24
+
25
+ /**
26
+ * Creates a function that handles WebSocket channel connections.
27
+ * Called when a client connects to a channel.
28
+ *
29
+ * @template Out - Output type for connection response
30
+ * @template ChannelData - Type of data associated with the channel
31
+ * @param func - Function definition, either direct function or configuration object
32
+ * @returns The unwrapped function for internal use
33
+ */
34
+ export const pikkuChannelConnectionFunc = <Out = unknown, ChannelData = unknown>(
35
+ func:
36
+ | PikkuFunctionSessionless<void, Out, ChannelData>
37
+ | {
38
+ func: PikkuFunctionSessionless<void, Out, ChannelData>
39
+ name?: string
40
+ }
41
+ ) => {
42
+ return typeof func === 'function' ? func : func.func
43
+ }
44
+
45
+ /**
46
+ * Creates a function that handles WebSocket channel disconnections.
47
+ * Called when a client disconnects from a channel.
48
+ *
49
+ * @template ChannelData - Type of data associated with the channel
50
+ * @param func - Function definition, either direct function or configuration object
51
+ * @returns The unwrapped function for internal use
52
+ */
53
+ export const pikkuChannelDisconnectionFunc = <ChannelData = unknown>(
54
+ func:
55
+ | PikkuFunctionSessionless<void, void, ChannelData>
56
+ | {
57
+ func: PikkuFunction<void, void, ChannelData>
58
+ name?: string
59
+ }
60
+ ) => {
61
+ return typeof func === 'function' ? func : func.func
62
+ }
63
+
64
+ /**
65
+ * Creates a function that handles WebSocket channel messages.
66
+ * Called when a message is received on a channel.
67
+ *
68
+ * @template In - Input type for channel messages
69
+ * @template Out - Output type for channel responses
70
+ * @template ChannelData - Type of data associated with the channel
71
+ * @param func - Function definition, either direct function or configuration object
72
+ * @returns The unwrapped function for internal use
73
+ */
74
+ export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unknown>(
75
+ func:
76
+ | PikkuFunctionSessionless<In, Out, ChannelData>
77
+ | CorePikkuFunctionConfig<PikkuFunction<In, Out, ChannelData>, PikkuPermission<In>>
78
+ ) => {
79
+ return typeof func === 'function' ? func : func.func
80
+ }
81
+
82
+ /**
83
+ * Registers a WebSocket channel with the Pikku framework.
84
+ *
85
+ * @template ChannelData - Type of data associated with the channel
86
+ * @template Channel - String literal type for the channel name
87
+ * @param channel - Channel definition with connection, disconnection, and message handlers
88
+ */
89
+ export const wireChannel = <ChannelData, Channel extends string>(
90
+ channel: ChannelWiring<ChannelData, Channel> & AssertHTTPWiringParams<ChannelData, Channel>
91
+ ) => {
92
+ wireChannelCore(channel as any) // TODO
93
+ }
94
+ `
95
+ }
@@ -1,7 +1,7 @@
1
1
  import { ChannelsMeta } from '@pikku/core/channel'
2
- import { serializeImportMap } from '../../serialize-import-map.js'
2
+ import { serializeImportMap } from '../../../utils/serialize-import-map.js'
3
3
  import { TypesMap } from '@pikku/inspector'
4
- import { generateCustomTypes } from '../../utils.js'
4
+ import { generateCustomTypes } from '../../../utils/custom-types-generator.js'
5
5
  import { FunctionsMeta } from '@pikku/core'
6
6
 
7
7
  export const serializeTypedChannelsMap = (
@@ -0,0 +1,173 @@
1
+ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
2
+ import { writeFileInDir } from '../../../utils/file-writer.js'
3
+ import { checkRequiredTypes } from '../../../utils/check-required-types.js'
4
+ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
5
+ import { join } from 'node:path'
6
+ import { serializeLocalCLIBootstrap } from './serialize-local-cli-bootstrap.js'
7
+ import { serializeChannelCLI } from './serialize-channel-cli.js'
8
+ import { serializeChannelCLIClient } from './serialize-channel-cli-client.js'
9
+
10
+ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
11
+ func: async ({ logger, config, getInspectorState }) => {
12
+ const visitState = await getInspectorState()
13
+
14
+ // Check if CLI entrypoints are configured
15
+ if (
16
+ !config.cli?.entrypoints ||
17
+ Object.keys(config.cli.entrypoints).length === 0
18
+ ) {
19
+ logger.info({
20
+ message:
21
+ 'No CLI entrypoints configured in config.cli.entrypoints, skipping CLI bootstrap generation',
22
+ type: 'skip',
23
+ })
24
+ return
25
+ }
26
+
27
+ // Generate bootstrap files for each configured entrypoint
28
+ for (const [programName, entrypointConfigs] of Object.entries(
29
+ config.cli.entrypoints
30
+ )) {
31
+ const programMeta = visitState.cli.meta[programName]
32
+
33
+ if (!programMeta) {
34
+ logger.warn(
35
+ `CLI program '${programName}' not found in metadata, skipping`
36
+ )
37
+ continue
38
+ }
39
+
40
+ // Normalize to array
41
+ const configs = Array.isArray(entrypointConfigs)
42
+ ? entrypointConfigs
43
+ : [entrypointConfigs]
44
+
45
+ for (const entrypointConfig of configs) {
46
+ // Normalize entrypoint config to get type
47
+ const entrypointType =
48
+ typeof entrypointConfig === 'string'
49
+ ? 'cli'
50
+ : entrypointConfig.type || 'cli'
51
+
52
+ // Handle channel type entrypoint
53
+ if (entrypointType === 'channel') {
54
+ if (
55
+ typeof entrypointConfig === 'string' ||
56
+ entrypointConfig.type !== 'channel'
57
+ ) {
58
+ throw new Error('Channel entrypoint must be a channel type object')
59
+ }
60
+
61
+ const channelWirePath = entrypointConfig.wirePath
62
+ const channelClientPath = entrypointConfig.path
63
+ const channelName = entrypointConfig.name
64
+ const channelRoute = entrypointConfig.route
65
+
66
+ const channelWireFile = join(config.rootDir, channelWirePath)
67
+
68
+ const channelCode = serializeChannelCLI(
69
+ programName,
70
+ programMeta,
71
+ channelWireFile,
72
+ visitState.functions.files,
73
+ config.packageMappings,
74
+ config.channelsTypesFile,
75
+ config.functionTypesFile,
76
+ channelName,
77
+ channelRoute
78
+ )
79
+
80
+ await writeFileInDir(logger, channelWireFile, channelCode)
81
+ logger.debug(
82
+ `Serialized CLI channel for ${programName}: ${channelWireFile}`
83
+ )
84
+
85
+ // Generate client code if clientPath is provided
86
+ if (channelClientPath) {
87
+ const channelClientFile = join(config.rootDir, channelClientPath)
88
+
89
+ const clientCode = serializeChannelCLIClient(
90
+ programName,
91
+ programMeta,
92
+ channelClientFile,
93
+ config,
94
+ config.bootstrapFiles.cli,
95
+ channelRoute
96
+ )
97
+
98
+ await writeFileInDir(logger, channelClientFile, clientCode)
99
+ logger.debug(
100
+ `Serialized CLI channel client for ${programName}: ${channelClientFile}`
101
+ )
102
+ }
103
+
104
+ continue
105
+ }
106
+
107
+ // Handle CLI type entrypoint (default)
108
+ const entrypointPath =
109
+ typeof entrypointConfig === 'string'
110
+ ? entrypointConfig
111
+ : entrypointConfig.type === 'cli'
112
+ ? entrypointConfig.path
113
+ : undefined
114
+
115
+ if (!entrypointPath) {
116
+ throw new Error(
117
+ `CLI entrypoint must have a path: ${JSON.stringify(entrypointConfig)}`
118
+ )
119
+ }
120
+
121
+ const bootstrapFile = join(config.rootDir, entrypointPath)
122
+
123
+ // Get service factories for local mode
124
+ // Check for required types
125
+ checkRequiredTypes(visitState.filesAndMethodsErrors, {
126
+ config: true,
127
+ singletonServicesFactory: true,
128
+ sessionServicesFactory: true,
129
+ })
130
+
131
+ const {
132
+ pikkuConfigFactory,
133
+ singletonServicesFactory,
134
+ sessionServicesFactory,
135
+ } = visitState.filesAndMethods
136
+
137
+ if (
138
+ !pikkuConfigFactory ||
139
+ !singletonServicesFactory ||
140
+ !sessionServicesFactory
141
+ ) {
142
+ throw new Error('Required types not found')
143
+ }
144
+
145
+ const bootstrapCode = serializeLocalCLIBootstrap(
146
+ programName,
147
+ programMeta,
148
+ bootstrapFile,
149
+ config,
150
+ pikkuConfigFactory,
151
+ singletonServicesFactory,
152
+ sessionServicesFactory
153
+ )
154
+
155
+ await writeFileInDir(logger, bootstrapFile, bootstrapCode)
156
+ logger.debug(
157
+ `Serialized CLI bootstrap for ${programName}: ${bootstrapFile}`
158
+ )
159
+ }
160
+ }
161
+ },
162
+ middleware: [
163
+ logCommandInfoAndTime({
164
+ commandStart: 'Serializing CLI',
165
+ commandEnd: 'Serialized CLI',
166
+ skipCondition: async ({ getInspectorState }) => {
167
+ const visitState = await getInspectorState()
168
+ return visitState.cli.files.size === 0
169
+ },
170
+ skipMessage: 'none found',
171
+ }),
172
+ ],
173
+ })
@@ -0,0 +1,50 @@
1
+ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
2
+ import { writeFileInDir } from '../../../utils/file-writer.js'
3
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
4
+ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
5
+ import { serializeCLITypes } from './serialize-cli-types.js'
6
+ import { checkRequiredTypes } from '../../../utils/check-required-types.js'
7
+
8
+ export const pikkuCLITypes: any = pikkuSessionlessFunc<void, void>({
9
+ func: async ({ logger, config, getInspectorState }) => {
10
+ const { cliTypesFile, functionTypesFile, packageMappings } = config
11
+ const visitState = await getInspectorState()
12
+
13
+ const functionTypesImportPath = getFileImportRelativePath(
14
+ cliTypesFile,
15
+ functionTypesFile,
16
+ packageMappings
17
+ )
18
+
19
+ // Check for required types
20
+ checkRequiredTypes(visitState.filesAndMethodsErrors, {
21
+ userSessionType: true,
22
+ sessionServiceType: true,
23
+ singletonServicesType: true,
24
+ })
25
+
26
+ const { userSessionType, singletonServicesType } =
27
+ visitState.filesAndMethods
28
+
29
+ if (!userSessionType || !singletonServicesType) {
30
+ throw new Error('Required types not found')
31
+ }
32
+
33
+ const content = serializeCLITypes(
34
+ functionTypesImportPath,
35
+ `import type { ${userSessionType.type} } from '${getFileImportRelativePath(cliTypesFile, userSessionType.typePath, packageMappings)}'`,
36
+ userSessionType.type,
37
+ `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(cliTypesFile, singletonServicesType.typePath, packageMappings)}'`,
38
+ singletonServicesType.type
39
+ )
40
+ await writeFileInDir(logger, cliTypesFile, content)
41
+ },
42
+ middleware: [
43
+ logCommandInfoAndTime({
44
+ commandStart: 'Creating CLI types',
45
+ commandEnd: 'Created CLI types',
46
+ skipCondition: false,
47
+ skipMessage: '',
48
+ }),
49
+ ],
50
+ })
@@ -0,0 +1,41 @@
1
+ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
2
+ import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
3
+ import { writeFileInDir } from '../../../utils/file-writer.js'
4
+ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
5
+
6
+ export const pikkuCLI: any = pikkuSessionlessFunc<void, boolean | undefined>({
7
+ func: async ({ logger, config, getInspectorState }) => {
8
+ const visitState = await getInspectorState()
9
+ const { cliWiringsFile, cliWiringMetaFile, packageMappings } = config
10
+ const { cli } = visitState
11
+
12
+ // Generate CLI wirings file
13
+ await writeFileInDir(
14
+ logger,
15
+ cliWiringsFile,
16
+ serializeFileImports(
17
+ 'wireCLI',
18
+ cliWiringsFile,
19
+ cli.files,
20
+ packageMappings
21
+ )
22
+ )
23
+
24
+ // Generate CLI metadata file
25
+ await writeFileInDir(
26
+ logger,
27
+ cliWiringMetaFile,
28
+ `import { pikkuState } from '@pikku/core'\npikkuState('cli', 'meta', ${JSON.stringify(cli.meta, null, 2)})`
29
+ )
30
+
31
+ return true
32
+ },
33
+ middleware: [
34
+ logCommandInfoAndTime({
35
+ commandStart: 'Finding CLI commands',
36
+ commandEnd: 'Found CLI commands',
37
+ skipCondition: false,
38
+ skipMessage: 'none found',
39
+ }),
40
+ ],
41
+ })
@@ -0,0 +1,72 @@
1
+ import { CLIProgramMeta } from '@pikku/core'
2
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
3
+ import { Config } from '../../../../types/application-types.js'
4
+
5
+ /**
6
+ * Serializes a CLI-over-Channel client bootstrap file
7
+ * Similar to local CLI bootstrap but uses WebSocket connection
8
+ */
9
+ export function serializeChannelCLIClient(
10
+ programName: string,
11
+ programMeta: CLIProgramMeta,
12
+ clientFile: string,
13
+ config: Config,
14
+ cliBootstrapPath: string,
15
+ channelRoute?: string
16
+ ): string {
17
+ const capitalizedName =
18
+ programName.charAt(0).toUpperCase() + programName.slice(1).replace(/-/g, '')
19
+ const finalChannelRoute = channelRoute || `/cli/${programName}`
20
+
21
+ // Get relative import path to CLI bootstrap (for metadata)
22
+ const bootstrapImportPath = getFileImportRelativePath(
23
+ clientFile,
24
+ cliBootstrapPath,
25
+ config.packageMappings
26
+ )
27
+
28
+ // TODO: Collect renderer imports and create renderers map
29
+ // For now, renderers are not implemented
30
+
31
+ return `/**
32
+ * This file was generated by the @pikku/cli
33
+ */
34
+ import { executeCLIViaChannel } from '@pikku/core/cli/channel'
35
+ import { CorePikkuWebsocket } from '@pikku/websocket'
36
+ import '${bootstrapImportPath}'
37
+
38
+ /**
39
+ * ${capitalizedName} CLI Client (via WebSocket Channel)
40
+ * Executes CLI commands over a WebSocket connection
41
+ */
42
+ export async function ${capitalizedName}CLIClient(
43
+ url: string,
44
+ args?: string[]
45
+ ): Promise<void> {
46
+ // Create WebSocket connection
47
+ const pikkuWS = new CorePikkuWebsocket(url)
48
+
49
+ // TODO: Import and register renderers when renderer tracking is implemented
50
+ const renderers = {}
51
+
52
+ await executeCLIViaChannel({
53
+ programName: '${programName}',
54
+ pikkuWS,
55
+ args,
56
+ renderers,
57
+ })
58
+ }
59
+
60
+ // Export as default for easy importing
61
+ export default ${capitalizedName}CLIClient
62
+
63
+ // For direct execution (if this file is run directly)
64
+ if (import.meta.url === \`file://\${process.argv[1]}\`) {
65
+ const url = process.env.PIKKU_WS_URL || 'ws://localhost:3000${finalChannelRoute}'
66
+ ${capitalizedName}CLIClient(url).catch(error => {
67
+ console.error('Fatal error:', error.message)
68
+ process.exit(1)
69
+ })
70
+ }
71
+ `
72
+ }
@@ -0,0 +1,123 @@
1
+ import { CLIProgramMeta } from '@pikku/core'
2
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
3
+
4
+ /**
5
+ * Serializes a wireChannel call from CLI metadata
6
+ * This creates a WebSocket backend for all CLI commands
7
+ */
8
+ export function serializeChannelCLI(
9
+ programName: string,
10
+ programMeta: CLIProgramMeta,
11
+ channelFile: string,
12
+ functionFiles: Map<string, { path: string; exportedName: string }>,
13
+ packageMappings: Record<string, string>,
14
+ channelTypesFile: string,
15
+ functionTypesFile: string,
16
+ channelName?: string,
17
+ channelRoute?: string
18
+ ): string {
19
+ const finalChannelName = channelName || `${programName}-cli`
20
+ const finalChannelRoute = channelRoute || `/cli/${programName}`
21
+ // Flatten all commands into a single routing map
22
+ const commandMap: Record<
23
+ string,
24
+ { pikkuFuncName: string; importPath?: string }
25
+ > = {}
26
+
27
+ const collectCommands = (
28
+ commands: Record<string, any>,
29
+ path: string[] = []
30
+ ) => {
31
+ for (const [name, cmd] of Object.entries(commands)) {
32
+ const fullPath = [...path, name]
33
+ const commandKey = fullPath.join('.')
34
+
35
+ if (cmd.pikkuFuncName) {
36
+ commandMap[commandKey] = {
37
+ pikkuFuncName: cmd.pikkuFuncName,
38
+ }
39
+ }
40
+
41
+ // Recursively process subcommands
42
+ if (cmd.subcommands) {
43
+ collectCommands(cmd.subcommands, fullPath)
44
+ }
45
+ }
46
+ }
47
+
48
+ collectCommands(programMeta.commands)
49
+
50
+ // Generate the wireChannel call
51
+ const commandEntries = Object.entries(commandMap)
52
+ .map(([commandKey, { pikkuFuncName }]) => {
53
+ return ` '${commandKey}': ${pikkuFuncName}`
54
+ })
55
+ .join(',\n')
56
+
57
+ // Generate imports from function file locations
58
+ const funcNames = [
59
+ ...new Set(Object.values(commandMap).map((v) => v.pikkuFuncName)),
60
+ ]
61
+ const imports = funcNames
62
+ .map((pikkuFuncName) => {
63
+ const fileInfo = functionFiles.get(pikkuFuncName)
64
+ if (!fileInfo) {
65
+ throw new Error(`Function not found in files map: ${pikkuFuncName}`)
66
+ }
67
+
68
+ const importPath = getFileImportRelativePath(
69
+ channelFile,
70
+ fileInfo.path,
71
+ packageMappings
72
+ )
73
+ return `import { ${fileInfo.exportedName} } from '${importPath}'`
74
+ })
75
+ .join('\n')
76
+
77
+ // Get relative paths to type files
78
+ const channelTypesPath = getFileImportRelativePath(
79
+ channelFile,
80
+ channelTypesFile,
81
+ packageMappings
82
+ )
83
+ const functionTypesPath = getFileImportRelativePath(
84
+ channelFile,
85
+ functionTypesFile,
86
+ packageMappings
87
+ )
88
+
89
+ return `/**
90
+ * This file was generated by the @pikku/cli
91
+ * WebSocket channel backend for '${programName}' CLI commands
92
+ */
93
+ import { wireChannel } from '${channelTypesPath}'
94
+ import { PikkuMiddleware } from '${functionTypesPath}'
95
+ ${imports}
96
+
97
+ // Middleware to close channel after command execution
98
+ const closeAfterExecution: PikkuMiddleware = async (_services, interaction, next) => {
99
+ try {
100
+ const result = await next()
101
+ return result
102
+ } finally {
103
+ // Close the channel after function completes
104
+ if (interaction.channel) {
105
+ await interaction.channel.close()
106
+ }
107
+ }
108
+ }
109
+
110
+ wireChannel({
111
+ name: '${finalChannelName}',
112
+ route: '${finalChannelRoute}',
113
+ auth: false,
114
+ middleware: [closeAfterExecution],
115
+ onMessageWiring: {
116
+ command: {
117
+ ${commandEntries}
118
+ }
119
+ },
120
+ tags: ['cli', '${programName}']
121
+ })
122
+ `
123
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Generates type definitions for CLI wirings
3
+ */
4
+ export const serializeCLITypes = (
5
+ functionTypesImportPath: string,
6
+ userSessionTypeImport: string,
7
+ userSessionTypeName: string,
8
+ singletonServicesTypeImport: string,
9
+ singletonServicesTypeName: string
10
+ ) => {
11
+ return `/**
12
+ * This file was generated by the @pikku/cli
13
+ * CLI-specific type definitions for tree-shaking optimization
14
+ */
15
+
16
+ import { CoreCLI, wireCLI as wireCLICore, CorePikkuCLIRender, CoreCLICommandConfig } from '@pikku/core'
17
+ import type { PikkuFunctionConfig, PikkuMiddleware } from '${functionTypesImportPath}'
18
+ ${userSessionTypeImport}
19
+ ${singletonServicesTypeImport}
20
+
21
+ ${singletonServicesTypeName !== 'SingletonServices' ? `type SingletonServices = ${singletonServicesTypeName}` : ''}
22
+ ${userSessionTypeName !== 'Session' ? `type Session = ${userSessionTypeName}` : ''}
23
+
24
+ /**
25
+ * Type-safe CLI renderer definition that can access your application's services.
26
+ * Use this to define custom renderers for CLI command output.
27
+ *
28
+ * @template Data - The output data type from the CLI command
29
+ * @template RequiredServices - The services required for this renderer
30
+ */
31
+ type PikkuCLIRender<Data, RequiredServices extends SingletonServices = SingletonServices> = CorePikkuCLIRender<Data, RequiredServices, Session>
32
+
33
+ /**
34
+ * CLI command configuration with project-specific types.
35
+ * Uses CoreCLICommandConfig from @pikku/core with local middleware and render types.
36
+ */
37
+ type CLICommandConfig<Func extends PikkuFunctionConfig<any, any>> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>>
38
+
39
+ /**
40
+ * Result type for CLI command configuration
41
+ */
42
+ type CLICommandResult<Func extends PikkuFunctionConfig<any, any>> = CLICommandConfig<Func>
43
+
44
+ /**
45
+ * Type definition for CLI applications with commands and global options.
46
+ *
47
+ * @template Commands - Type describing the command structure
48
+ * @template GlobalOptions - Type for global CLI options
49
+ */
50
+ type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>>>, GlobalOptions> = CoreCLI<Commands, GlobalOptions, PikkuMiddleware, PikkuCLIRender<any>>
51
+
52
+ /**
53
+ * Registers a CLI application with the Pikku framework.
54
+ * Creates command-line interfaces with type-safe commands and options.
55
+ *
56
+ * @template Commands - Type describing the command structure
57
+ * @template GlobalOptions - Type for global CLI options
58
+ * @param cli - CLI definition with program name, commands, and global options
59
+ */
60
+ export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>>>, GlobalOptions>(
61
+ cli: CLIWiring<Commands, GlobalOptions>
62
+ ) => {
63
+ wireCLICore(cli as any)
64
+ }
65
+
66
+ /**
67
+ * Creates a CLI command definition with automatic option inference from the function's input type.
68
+ * This allows TypeScript to automatically derive CLI options from the function signature.
69
+ *
70
+ * @template Func - The Pikku function config type to create a CLI command for
71
+ * @param config - CLI command configuration
72
+ * @returns CLI command configuration with inferred types
73
+ */
74
+ export const pikkuCLICommand = <Func extends PikkuFunctionConfig<any, any>>(
75
+ config: CLICommandConfig<Func>
76
+ ): CLICommandResult<Func> => {
77
+ return config as any
78
+ }
79
+ `
80
+ }