@pikku/cli 0.11.1 → 0.11.3

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 (358) hide show
  1. package/.pikku/channel/pikku-channel-types.gen.ts +73 -17
  2. package/.pikku/channel/pikku-channels-map.gen.d.ts +11 -11
  3. package/.pikku/channel/pikku-channels-meta.gen.json +1 -0
  4. package/.pikku/channel/pikku-channels-meta.gen.ts +4 -2
  5. package/.pikku/channel/pikku-channels.gen.ts +1 -1
  6. package/.pikku/cli/pikku-cli-channel.ts +2 -2
  7. package/.pikku/cli/pikku-cli-client.gen.ts +1 -3
  8. package/.pikku/cli/pikku-cli-types.gen.ts +3 -3
  9. package/.pikku/cli/pikku-cli-wirings-meta.gen.json +147 -0
  10. package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +4 -157
  11. package/.pikku/cli/pikku-cli-wirings.gen.ts +3 -3
  12. package/.pikku/cli/pikku-cli.gen.ts +3 -3
  13. package/.pikku/forge/pikku-forge-types.gen.ts +83 -0
  14. package/.pikku/function/pikku-function-types.gen.ts +223 -91
  15. package/.pikku/function/pikku-functions-meta-verbose.gen.json +1030 -0
  16. package/.pikku/function/pikku-functions-meta.gen.json +656 -0
  17. package/.pikku/function/pikku-functions-meta.gen.ts +4 -970
  18. package/.pikku/http/pikku-http-types.gen.ts +20 -4
  19. package/.pikku/http/pikku-http-wirings-map.gen.d.ts +11 -11
  20. package/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
  21. package/.pikku/http/pikku-http-wirings-meta.gen.ts +4 -10
  22. package/.pikku/http/pikku-http-wirings.gen.ts +1 -1
  23. package/.pikku/mcp/pikku-mcp-types.gen.ts +72 -20
  24. package/.pikku/mcp/pikku-mcp-wirings-meta.gen.json +5 -0
  25. package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +6 -4
  26. package/.pikku/mcp/pikku-mcp-wirings.gen.ts +1 -1
  27. package/.pikku/pikku-bootstrap.gen.ts +7 -12
  28. package/.pikku/pikku-services.gen.ts +6 -7
  29. package/.pikku/pikku-types.gen.ts +4 -1
  30. package/.pikku/pikku-websocket.gen.ts +1 -1
  31. package/.pikku/queue/pikku-queue-types.gen.ts +2 -2
  32. package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +11 -11
  33. package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +1 -0
  34. package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +5 -7
  35. package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +1 -1
  36. package/.pikku/rpc/pikku-remote-rpc-workers.gen.ts +5 -2
  37. package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +19 -14
  38. package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +46 -39
  39. package/.pikku/scheduler/pikku-scheduler-types.gen.ts +2 -2
  40. package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.json +1 -0
  41. package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +5 -2
  42. package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +1 -1
  43. package/.pikku/schemas/register.gen.ts +31 -23
  44. package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  45. package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
  46. package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
  47. package/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
  48. package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
  49. package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
  50. package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
  51. package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
  52. package/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
  53. package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
  54. package/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
  55. package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
  56. package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
  57. package/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
  58. package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
  59. package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
  60. package/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
  61. package/.pikku/services/config.gen.json +104 -0
  62. package/.pikku/services/getInspectorState.gen.json +10 -0
  63. package/.pikku/services/jwt.gen.json +13 -0
  64. package/.pikku/services/logger.gen.json +25 -0
  65. package/.pikku/services/queueService.gen.json +14 -0
  66. package/.pikku/services/schedulerService.gen.json +17 -0
  67. package/.pikku/services/schema.gen.json +14 -0
  68. package/.pikku/services/secrets.gen.json +13 -0
  69. package/.pikku/services/variables.gen.json +13 -0
  70. package/.pikku/services/workflowService.gen.json +31 -0
  71. package/.pikku/workflow/pikku-workflow-map.gen.d.ts +2 -36
  72. package/.pikku/workflow/pikku-workflow-types.gen.ts +305 -48
  73. package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +6 -2
  74. package/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -2
  75. package/CHANGELOG.md +44 -1
  76. package/bin/pikku.ts +6 -32
  77. package/build.sh +53 -31
  78. package/cli.schema.json +1 -1
  79. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +51 -10
  80. package/dist/.pikku/channel/pikku-channel-types.gen.js +3 -13
  81. package/dist/.pikku/channel/pikku-channels-meta.gen.js +3 -2
  82. package/dist/.pikku/channel/pikku-channels-meta.gen.json +1 -0
  83. package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
  84. package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
  85. package/dist/.pikku/cli/pikku-cli-channel.js +2 -2
  86. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  87. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -3
  88. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +3 -3
  89. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  90. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +3 -157
  91. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +147 -0
  92. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +2 -2
  93. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +2 -2
  94. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  95. package/dist/.pikku/cli/pikku-cli.gen.js +3 -3
  96. package/dist/.pikku/forge/pikku-forge-types.gen.d.ts +72 -0
  97. package/dist/.pikku/forge/pikku-forge-types.gen.js +55 -0
  98. package/dist/.pikku/function/pikku-function-types.gen.d.ts +141 -99
  99. package/dist/.pikku/function/pikku-function-types.gen.js +52 -62
  100. package/dist/.pikku/function/pikku-functions-meta.gen.js +3 -969
  101. package/dist/.pikku/function/pikku-functions-meta.gen.json +656 -0
  102. package/dist/.pikku/http/pikku-http-types.gen.d.ts +19 -4
  103. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  104. package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +3 -10
  105. package/dist/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
  106. package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
  107. package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
  108. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +57 -17
  109. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +7 -31
  110. package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +5 -4
  111. package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.json +5 -0
  112. package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
  113. package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
  114. package/dist/.pikku/pikku-bootstrap.gen.d.ts +7 -12
  115. package/dist/.pikku/pikku-bootstrap.gen.js +7 -12
  116. package/dist/.pikku/pikku-services.gen.d.ts +5 -7
  117. package/dist/.pikku/pikku-services.gen.js +3 -5
  118. package/dist/.pikku/pikku-types.gen.d.ts +2 -1
  119. package/dist/.pikku/pikku-types.gen.js +3 -1
  120. package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
  121. package/dist/.pikku/pikku-websocket.gen.js +1 -1
  122. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +2 -2
  123. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  124. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +3 -7
  125. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +1 -0
  126. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  127. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  128. package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.d.ts +9 -9
  129. package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +5 -2
  130. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +2 -2
  131. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  132. package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +3 -2
  133. package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.json +1 -0
  134. package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
  135. package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
  136. package/dist/.pikku/schemas/register.gen.js +19 -15
  137. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  138. package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
  139. package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
  140. package/dist/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
  141. package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
  142. package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
  143. package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
  144. package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
  145. package/dist/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
  146. package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
  147. package/dist/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
  148. package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
  149. package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
  150. package/dist/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
  151. package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
  152. package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
  153. package/dist/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
  154. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +213 -39
  155. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +106 -16
  156. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +3 -2
  157. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
  158. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -2
  159. package/dist/bin/pikku.js +5 -26
  160. package/dist/src/cli.wiring.js +4 -4
  161. package/dist/src/functions/commands/all.js +172 -94
  162. package/dist/src/functions/commands/bootstrap.js +21 -16
  163. package/dist/src/functions/commands/watch.js +6 -3
  164. package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +12 -8
  165. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -1
  166. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +74 -22
  167. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.d.ts +1 -1
  168. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.js +72 -20
  169. package/dist/src/functions/wirings/channels/pikku-channels.js +9 -2
  170. package/dist/src/functions/wirings/channels/pikku-command-channels.js +18 -2
  171. package/dist/src/functions/wirings/channels/serialize-channel-types.js +72 -16
  172. package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +1 -2
  173. package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +4 -4
  174. package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +1 -1
  175. package/dist/src/functions/wirings/cli/pikku-command-cli.js +17 -3
  176. package/dist/src/functions/wirings/cli/serialize-channel-cli.js +1 -1
  177. package/dist/src/functions/wirings/cli/serialize-cli-types.js +2 -2
  178. package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +1 -1
  179. package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +4 -4
  180. package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.d.ts +1 -0
  181. package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.js +90 -0
  182. package/dist/src/functions/wirings/forge/pikku-command-forge-types.d.ts +1 -0
  183. package/dist/src/functions/wirings/forge/pikku-command-forge-types.js +26 -0
  184. package/dist/src/functions/wirings/forge/serialize-forge-types.d.ts +4 -0
  185. package/dist/src/functions/wirings/forge/serialize-forge-types.js +90 -0
  186. package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +4 -4
  187. package/dist/src/functions/wirings/functions/pikku-command-function-types.js +7 -2
  188. package/dist/src/functions/wirings/functions/pikku-command-functions.js +35 -10
  189. package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
  190. package/dist/src/functions/wirings/functions/pikku-command-services.js +24 -24
  191. package/dist/src/functions/wirings/functions/pikku-function-types.js +2 -2
  192. package/dist/src/functions/wirings/functions/schemas.d.ts +1 -1
  193. package/dist/src/functions/wirings/functions/schemas.js +5 -4
  194. package/dist/src/functions/wirings/functions/serialize-function-imports.d.ts +3 -1
  195. package/dist/src/functions/wirings/functions/serialize-function-imports.js +7 -3
  196. package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +1 -1
  197. package/dist/src/functions/wirings/functions/serialize-function-types.js +224 -91
  198. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
  199. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +19 -21
  200. package/dist/src/functions/wirings/http/openapi-spec-generator.js +5 -5
  201. package/dist/src/functions/wirings/http/pikku-command-http-routes.js +18 -2
  202. package/dist/src/functions/wirings/http/pikku-command-openapi.js +2 -2
  203. package/dist/src/functions/wirings/http/pikku-http-routes.js +9 -2
  204. package/dist/src/functions/wirings/http/serialize-http-types.js +19 -3
  205. package/dist/src/functions/wirings/http/serialize-typed-http-map.js +33 -8
  206. package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +29 -6
  207. package/dist/src/functions/wirings/mcp/serialize-mcp-json.js +3 -2
  208. package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +71 -19
  209. package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +29 -2
  210. package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.d.ts +5 -2
  211. package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +5 -13
  212. package/dist/src/functions/wirings/package/pikku-command-package.d.ts +1 -0
  213. package/dist/src/functions/wirings/package/pikku-command-package.js +58 -0
  214. package/dist/src/functions/wirings/package/serialize-package.d.ts +5 -0
  215. package/dist/src/functions/wirings/package/serialize-package.js +32 -0
  216. package/dist/src/functions/wirings/queue/pikku-command-queue.js +17 -3
  217. package/dist/src/functions/wirings/queue/pikku-queue.js +9 -11
  218. package/dist/src/functions/wirings/queue/serialize-queue-map.js +20 -3
  219. package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +2 -1
  220. package/dist/src/functions/wirings/queue/serialize-queue-meta.js +10 -1
  221. package/dist/src/functions/wirings/queue/serialize-queue-types.js +1 -1
  222. package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +4 -4
  223. package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +9 -2
  224. package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +11 -4
  225. package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +4 -1
  226. package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +3 -3
  227. package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.d.ts +1 -1
  228. package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +54 -8
  229. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +15 -3
  230. package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.d.ts +2 -1
  231. package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.js +11 -1
  232. package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +1 -1
  233. package/dist/src/functions/wirings/services/pikku-command-service-metadata.d.ts +1 -0
  234. package/dist/src/functions/wirings/services/pikku-command-service-metadata.js +22 -0
  235. package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +58 -16
  236. package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +3 -0
  237. package/dist/src/functions/wirings/workflow/serialize-workflow-map.js +30 -32
  238. package/dist/src/functions/wirings/workflow/serialize-workflow-meta.d.ts +1 -2
  239. package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +43 -8
  240. package/dist/src/functions/wirings/workflow/serialize-workflow-registration.d.ts +7 -0
  241. package/dist/src/functions/wirings/workflow/serialize-workflow-registration.js +53 -0
  242. package/dist/src/functions/wirings/workflow/serialize-workflow-types.d.ts +4 -2
  243. package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +308 -49
  244. package/dist/src/functions/wirings/workflow/serialize-workflow-workers.d.ts +1 -1
  245. package/dist/src/functions/wirings/workflow/serialize-workflow-workers.js +16 -29
  246. package/dist/src/middleware/log-command-info-and-time.d.ts +2 -2
  247. package/dist/src/middleware/log-command-info-and-time.js +1 -4
  248. package/dist/src/services/cli-logger-forwarder.service.js +1 -1
  249. package/dist/src/services.d.ts +2 -7
  250. package/dist/src/services.js +18 -13
  251. package/dist/src/utils/check-required-types.d.ts +2 -2
  252. package/dist/src/utils/check-required-types.js +2 -3
  253. package/dist/src/utils/command-summary.d.ts +2 -0
  254. package/dist/src/utils/command-summary.js +2 -0
  255. package/dist/src/utils/custom-types-generator.js +13 -15
  256. package/dist/src/utils/generate-bootstrap-file.js +1 -1
  257. package/dist/src/utils/pikku-cli-config.js +65 -4
  258. package/dist/src/utils/pikku-files-and-methods.d.ts +2 -2
  259. package/dist/src/utils/pikku-files-and-methods.js +4 -4
  260. package/dist/src/utils/schema-generator.d.ts +4 -3
  261. package/dist/src/utils/schema-generator.js +135 -15
  262. package/dist/src/utils/strip-verbose-meta.d.ts +43 -0
  263. package/dist/src/utils/strip-verbose-meta.js +210 -0
  264. package/dist/tsconfig.tsbuildinfo +1 -1
  265. package/package.json +11 -9
  266. package/src/cli.wiring.ts +4 -4
  267. package/src/functions/commands/all.ts +203 -107
  268. package/src/functions/commands/bootstrap.ts +23 -16
  269. package/src/functions/commands/watch.ts +6 -3
  270. package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +26 -6
  271. package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +75 -22
  272. package/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts +72 -19
  273. package/src/functions/wirings/channels/pikku-channels.ts +27 -3
  274. package/src/functions/wirings/channels/pikku-command-channels.ts +46 -3
  275. package/src/functions/wirings/channels/serialize-channel-types.ts +72 -16
  276. package/src/functions/wirings/channels/serialize-typed-channel-map.ts +3 -2
  277. package/src/functions/wirings/cli/pikku-command-cli-entry.ts +4 -4
  278. package/src/functions/wirings/cli/pikku-command-cli-types.ts +1 -1
  279. package/src/functions/wirings/cli/pikku-command-cli.ts +45 -3
  280. package/src/functions/wirings/cli/serialize-channel-cli.ts +1 -1
  281. package/src/functions/wirings/cli/serialize-cli-types.ts +2 -2
  282. package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +5 -5
  283. package/src/functions/wirings/forge/pikku-command-forge-nodes.ts +135 -0
  284. package/src/functions/wirings/forge/pikku-command-forge-types.ts +38 -0
  285. package/src/functions/wirings/forge/serialize-forge-types.ts +94 -0
  286. package/src/functions/wirings/functions/pikku-command-function-types-split.ts +9 -8
  287. package/src/functions/wirings/functions/pikku-command-function-types.ts +17 -10
  288. package/src/functions/wirings/functions/pikku-command-functions.ts +59 -14
  289. package/src/functions/wirings/functions/pikku-command-services.ts +26 -26
  290. package/src/functions/wirings/functions/pikku-function-types.ts +3 -1
  291. package/src/functions/wirings/functions/schemas.ts +14 -4
  292. package/src/functions/wirings/functions/serialize-function-imports.ts +12 -3
  293. package/src/functions/wirings/functions/serialize-function-types.ts +227 -93
  294. package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +27 -26
  295. package/src/functions/wirings/http/openapi-spec-generator.ts +15 -6
  296. package/src/functions/wirings/http/pikku-command-http-routes.ts +46 -2
  297. package/src/functions/wirings/http/pikku-command-openapi.ts +3 -2
  298. package/src/functions/wirings/http/pikku-http-routes.ts +28 -2
  299. package/src/functions/wirings/http/serialize-http-types.ts +19 -3
  300. package/src/functions/wirings/http/serialize-typed-http-map.ts +32 -8
  301. package/src/functions/wirings/mcp/pikku-command-mcp.ts +58 -10
  302. package/src/functions/wirings/mcp/serialize-mcp-json.ts +8 -6
  303. package/src/functions/wirings/mcp/serialize-mcp-types.ts +71 -19
  304. package/src/functions/wirings/middleware/pikku-command-middleware.ts +39 -2
  305. package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +4 -19
  306. package/src/functions/wirings/package/pikku-command-package.ts +81 -0
  307. package/src/functions/wirings/package/serialize-package.ts +69 -0
  308. package/src/functions/wirings/permissions/pikku-command-permissions.ts +2 -2
  309. package/src/functions/wirings/queue/pikku-command-queue.ts +47 -2
  310. package/src/functions/wirings/queue/pikku-queue.ts +26 -10
  311. package/src/functions/wirings/queue/serialize-queue-map.ts +18 -3
  312. package/src/functions/wirings/queue/serialize-queue-meta.ts +15 -1
  313. package/src/functions/wirings/queue/serialize-queue-types.ts +1 -1
  314. package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +7 -4
  315. package/src/functions/wirings/rpc/pikku-command-rpc.ts +25 -2
  316. package/src/functions/wirings/rpc/serialize-public-rpc.ts +11 -4
  317. package/src/functions/wirings/rpc/serialize-remote-rpc.ts +4 -1
  318. package/src/functions/wirings/rpc/serialize-rpc-wrapper.ts +3 -3
  319. package/src/functions/wirings/rpc/serialize-typed-rpc-map.ts +74 -8
  320. package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +51 -4
  321. package/src/functions/wirings/scheduler/serialize-scheduler-meta.ts +20 -1
  322. package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +1 -1
  323. package/src/functions/wirings/services/pikku-command-service-metadata.ts +25 -0
  324. package/src/functions/wirings/workflow/pikku-command-workflow.ts +114 -19
  325. package/src/functions/wirings/workflow/serialize-workflow-map.ts +38 -40
  326. package/src/functions/wirings/workflow/serialize-workflow-meta.ts +68 -11
  327. package/src/functions/wirings/workflow/serialize-workflow-registration.ts +83 -0
  328. package/src/functions/wirings/workflow/serialize-workflow-types.ts +311 -49
  329. package/src/functions/wirings/workflow/serialize-workflow-workers.ts +16 -29
  330. package/src/middleware/log-command-info-and-time.ts +3 -6
  331. package/src/services/cli-logger-forwarder.service.ts +1 -1
  332. package/src/services.ts +23 -16
  333. package/src/utils/check-required-types.ts +4 -7
  334. package/src/utils/command-summary.ts +4 -0
  335. package/src/utils/custom-types-generator.ts +15 -15
  336. package/src/utils/generate-bootstrap-file.ts +1 -1
  337. package/src/utils/pikku-cli-config.ts +105 -5
  338. package/src/utils/pikku-files-and-methods.ts +10 -13
  339. package/src/utils/schema-generator.ts +185 -22
  340. package/src/utils/strip-verbose-meta.ts +254 -0
  341. package/types/application-types.d.ts +1 -1
  342. package/types/config.d.ts +47 -2
  343. package/.pikku/function/pikku-functions-meta.min.gen.ts +0 -211
  344. package/.pikku/function/pikku-functions.gen.ts +0 -84
  345. package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +0 -47
  346. package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +0 -1
  347. package/dist/.pikku/function/pikku-functions-meta.min.gen.js +0 -211
  348. package/dist/.pikku/function/pikku-functions.gen.d.ts +0 -1
  349. package/dist/.pikku/function/pikku-functions.gen.js +0 -83
  350. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +0 -1
  351. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +0 -47
  352. package/dist/.pikku/schemas/schemas/PikkuRemoteInternalRPCInput.schema.json +0 -1
  353. package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.d.ts +0 -1
  354. package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.js +0 -12
  355. package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.d.ts +0 -1
  356. package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.js +0 -11
  357. package/src/functions/wirings/workflow/pikku-command-workflow-map.ts +0 -24
  358. package/src/functions/wirings/workflow/pikku-command-workflow-types.ts +0 -22
@@ -1,9 +1,10 @@
1
1
  export const serializeNextJsBackendWrapper = (
2
2
  bootstrapPath: string,
3
3
  routesMapPath: string,
4
+ rpcMapPath: string,
4
5
  configImport: string,
5
6
  singleServicesFactoryImport: string,
6
- sessionServicesImport: string
7
+ wireServicesImport: string
7
8
  ) => {
8
9
  return `'server-only'
9
10
 
@@ -14,12 +15,13 @@ export const serializeNextJsBackendWrapper = (
14
15
  import { PikkuNextJS } from '@pikku/next'
15
16
  import { NextRequest } from 'next/server.js'
16
17
  import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
18
+ import type { FlattenedRPCMap } from '${rpcMapPath}'
17
19
 
18
20
  type RouteContext = { params: Promise<Record<string, string | string[]>> }
19
21
 
20
22
  ${configImport}
21
23
  ${singleServicesFactoryImport}
22
- ${sessionServicesImport}
24
+ ${wireServicesImport}
23
25
 
24
26
  import '${bootstrapPath}'
25
27
 
@@ -40,7 +42,7 @@ export const pikku = (_options?: any) => {
40
42
  _pikku = new PikkuNextJS(
41
43
  createConfig as any,
42
44
  createSingletonServices as any,
43
- createSessionServices
45
+ createWireServices
44
46
  )
45
47
  }
46
48
 
@@ -93,14 +95,16 @@ export const pikku = (_options?: any) => {
93
95
  *
94
96
  * @template Route - The route key with the POST method.
95
97
  * @param route - The route identifier.
96
- * @param data - The input data for the POST request, defaults to null.
98
+ * @param data - The input data for the POST request (required if input type is defined).
97
99
  * @returns A promise that resolves to the output of the POST handler.
98
100
  */
99
101
  const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
100
102
  route: Route,
101
- data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
103
+ ...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
104
+ ? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
105
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
102
106
  ): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
103
- return dynamicActionRequest(route, 'POST', data)
107
+ return dynamicActionRequest(route, 'POST', args[0] ?? null)
104
108
  }
105
109
 
106
110
  /**
@@ -108,14 +112,16 @@ export const pikku = (_options?: any) => {
108
112
  *
109
113
  * @template Route - The route key with the GET method.
110
114
  * @param route - The route identifier.
111
- * @param data - The input data for the GET request, defaults to null.
115
+ * @param data - The input data for the GET request (required if input type is defined).
112
116
  * @returns A promise that resolves to the output of the GET handler.
113
117
  */
114
118
  const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
115
119
  route: Route,
116
- data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
120
+ ...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
121
+ ? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
122
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
117
123
  ): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
118
- return dynamicActionRequest(route, 'GET', data)
124
+ return dynamicActionRequest(route, 'GET', args[0] ?? null)
119
125
  }
120
126
 
121
127
  /**
@@ -123,14 +129,16 @@ export const pikku = (_options?: any) => {
123
129
  *
124
130
  * @template Route - The route key with the PATCH method.
125
131
  * @param route - The route identifier.
126
- * @param data - The input data for the PATCH request, defaults to null.
132
+ * @param data - The input data for the PATCH request (required if input type is defined).
127
133
  * @returns A promise that resolves to the output of the PATCH handler.
128
134
  */
129
135
  const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
130
136
  route: Route,
131
- data: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] = null
137
+ ...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
138
+ ? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
139
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
132
140
  ): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
133
- return dynamicActionRequest(route, 'PATCH', data)
141
+ return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
134
142
  }
135
143
 
136
144
  /**
@@ -138,14 +146,16 @@ export const pikku = (_options?: any) => {
138
146
  *
139
147
  * @template Route - The route key with the DELETE method.
140
148
  * @param route - The route identifier.
141
- * @param data - The input data for the DELETE request, defaults to null.
149
+ * @param data - The input data for the DELETE request (required if input type is defined).
142
150
  * @returns A promise that resolves to the output of the DELETE handler.
143
151
  */
144
152
  const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
145
153
  route: Route,
146
- data: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] = null
154
+ ...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
155
+ ? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
156
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
147
157
  ): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
148
- return dynamicActionRequest(route, 'DELETE', data)
158
+ return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
149
159
  }
150
160
 
151
161
  // Static Requests
@@ -155,14 +165,16 @@ export const pikku = (_options?: any) => {
155
165
  *
156
166
  * @template Route - The route key with the POST method.
157
167
  * @param route - The route identifier.
158
- * @param data - The input data for the POST request, defaults to null.
168
+ * @param data - The input data for the POST request (required if input type is defined).
159
169
  * @returns A promise that resolves to the output of the POST handler.
160
170
  */
161
171
  const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
162
172
  route: Route,
163
- data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
173
+ ...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
174
+ ? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
175
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
164
176
  ): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
165
- return staticActionRequest(route, 'POST', data)
177
+ return staticActionRequest(route, 'POST', args[0] ?? null)
166
178
  }
167
179
 
168
180
  /**
@@ -170,23 +182,64 @@ export const pikku = (_options?: any) => {
170
182
  *
171
183
  * @template Route - The route key with the GET method.
172
184
  * @param route - The route identifier.
173
- * @param data - The input data for the GET request, defaults to null.
185
+ * @param data - The input data for the GET request (required if input type is defined).
174
186
  * @returns A promise that resolves to the output of the GET handler.
175
187
  */
176
188
  const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
177
189
  route: Route,
178
- data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
190
+ ...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
191
+ ? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
192
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
179
193
  ): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
180
- return staticActionRequest(route, 'GET', data)
194
+ return staticActionRequest(route, 'GET', args[0] ?? null)
195
+ }
196
+
197
+ // RPC Requests
198
+
199
+ /**
200
+ * Makes a dynamic RPC request.
201
+ *
202
+ * @template Name - The RPC function name from the FlattenedRPCMap.
203
+ * @param name - The RPC function identifier.
204
+ * @param data - The input data for the RPC request (required if input type is defined).
205
+ * @returns A promise that resolves to the output of the RPC handler.
206
+ */
207
+ const rpc = async <Name extends keyof FlattenedRPCMap>(
208
+ rpcName: Name,
209
+ ...args: FlattenedRPCMap[Name]['input'] extends null | undefined
210
+ ? [data?: FlattenedRPCMap[Name]['input']]
211
+ : [data: NonNullable<FlattenedRPCMap[Name]['input']>]
212
+ ): Promise<FlattenedRPCMap[Name]['output']> => {
213
+ return dynamicActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
214
+ }
215
+
216
+ /**
217
+ * Makes a static RPC request.
218
+ * Note: In HTTP wrapper context, both rpc and staticRPC behave the same way.
219
+ *
220
+ * @template Name - The RPC function name from the FlattenedRPCMap.
221
+ * @param name - The RPC function identifier.
222
+ * @param data - The input data for the RPC request (required if input type is defined).
223
+ * @returns A promise that resolves to the output of the RPC handler.
224
+ */
225
+ const staticRPC = async <Name extends keyof FlattenedRPCMap>(
226
+ rpcName: Name,
227
+ ...args: FlattenedRPCMap[Name]['input'] extends null | undefined
228
+ ? [data?: FlattenedRPCMap[Name]['input']]
229
+ : [data: NonNullable<FlattenedRPCMap[Name]['input']>]
230
+ ): Promise<FlattenedRPCMap[Name]['output']> => {
231
+ return staticActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
181
232
  }
182
233
 
183
234
  return {
235
+ rpc,
184
236
  get: dynamicGet,
185
237
  post: dynamicPost,
186
238
  patch: dynamicPatch,
187
239
  del: dynamicDel,
188
240
  staticGet,
189
241
  staticPost,
242
+ staticRPC,
190
243
  }
191
244
  }
192
245
 
@@ -210,7 +263,7 @@ export const pikkuAPIRequest = (
210
263
  _pikku = new PikkuNextJS(
211
264
  createConfig as any,
212
265
  createSingletonServices as any,
213
- createSessionServices
266
+ createWireServices
214
267
  )
215
268
  }
216
269
  if (_removeAPIPrefix) {
@@ -1,5 +1,6 @@
1
1
  export const serializeNextJsHTTPWrapper = (
2
2
  routesMapPath: string,
3
+ rpcMapPath: string,
3
4
  pikkuFetchImport: string
4
5
  ) => {
5
6
  return `'server-only'
@@ -10,6 +11,7 @@ export const serializeNextJsHTTPWrapper = (
10
11
  */
11
12
  import { CorePikkuFetchOptions } from '@pikku/fetch'
12
13
  import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
14
+ import type { FlattenedRPCMap } from '${rpcMapPath}'
13
15
  import { PikkuFetch } from '${pikkuFetchImport}'
14
16
 
15
17
  let _pikku: PikkuFetch | undefined
@@ -62,14 +64,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
62
64
  *
63
65
  * @template Route - The route key with the POST method.
64
66
  * @param route - The route identifier.
65
- * @param data - The input data for the POST request, defaults to null.
67
+ * @param data - The input data for the POST request (required if input type is defined).
66
68
  * @returns A promise that resolves to the output of the POST handler.
67
69
  */
68
70
  const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
69
71
  route: Route,
70
- data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
72
+ ...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
73
+ ? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
74
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
71
75
  ): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
72
- return dynamicActionRequest(route, 'POST', data)
76
+ return dynamicActionRequest(route, 'POST', args[0] ?? null)
73
77
  }
74
78
 
75
79
  /**
@@ -77,14 +81,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
77
81
  *
78
82
  * @template Route - The route key with the GET method.
79
83
  * @param route - The route identifier.
80
- * @param data - The input data for the GET request, defaults to null.
84
+ * @param data - The input data for the GET request (required if input type is defined).
81
85
  * @returns A promise that resolves to the output of the GET handler.
82
86
  */
83
87
  const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
84
88
  route: Route,
85
- data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
89
+ ...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
90
+ ? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
91
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
86
92
  ): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
87
- return dynamicActionRequest(route, 'GET', data)
93
+ return dynamicActionRequest(route, 'GET', args[0] ?? null)
88
94
  }
89
95
 
90
96
  /**
@@ -92,14 +98,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
92
98
  *
93
99
  * @template Route - The route key with the PATCH method.
94
100
  * @param route - The route identifier.
95
- * @param data - The input data for the PATCH request, defaults to null.
101
+ * @param data - The input data for the PATCH request (required if input type is defined).
96
102
  * @returns A promise that resolves to the output of the PATCH handler.
97
103
  */
98
104
  const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
99
105
  route: Route,
100
- data: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] = null
106
+ ...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
107
+ ? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
108
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
101
109
  ): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
102
- return dynamicActionRequest(route, 'PATCH', data)
110
+ return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
103
111
  }
104
112
 
105
113
  /**
@@ -107,14 +115,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
107
115
  *
108
116
  * @template Route - The route key with the DELETE method.
109
117
  * @param route - The route identifier.
110
- * @param data - The input data for the DELETE request, defaults to null.
118
+ * @param data - The input data for the DELETE request (required if input type is defined).
111
119
  * @returns A promise that resolves to the output of the DELETE handler.
112
120
  */
113
121
  const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
114
122
  route: Route,
115
- data: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] = null
123
+ ...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
124
+ ? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
125
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
116
126
  ): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
117
- return dynamicActionRequest(route, 'DELETE', data)
127
+ return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
118
128
  }
119
129
 
120
130
  // Static Requests
@@ -124,14 +134,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
124
134
  *
125
135
  * @template Route - The route key with the POST method.
126
136
  * @param route - The route identifier.
127
- * @param data - The input data for the POST request, defaults to null.
137
+ * @param data - The input data for the POST request (required if input type is defined).
128
138
  * @returns A promise that resolves to the output of the POST handler.
129
139
  */
130
140
  const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
131
141
  route: Route,
132
- data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
142
+ ...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
143
+ ? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
144
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
133
145
  ): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
134
- return staticActionRequest(route, 'POST', data)
146
+ return staticActionRequest(route, 'POST', args[0] ?? null)
135
147
  }
136
148
 
137
149
  /**
@@ -139,23 +151,64 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
139
151
  *
140
152
  * @template Route - The route key with the GET method.
141
153
  * @param route - The route identifier.
142
- * @param data - The input data for the GET request, defaults to null.
154
+ * @param data - The input data for the GET request (required if input type is defined).
143
155
  * @returns A promise that resolves to the output of the GET handler.
144
156
  */
145
157
  const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
146
158
  route: Route,
147
- data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
159
+ ...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
160
+ ? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
161
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
148
162
  ): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
149
- return staticActionRequest(route, 'GET', data)
163
+ return staticActionRequest(route, 'GET', args[0] ?? null)
164
+ }
165
+
166
+ // RPC Requests
167
+
168
+ /**
169
+ * Makes a dynamic RPC request.
170
+ *
171
+ * @template Name - The RPC function name from the FlattenedRPCMap.
172
+ * @param name - The RPC function identifier.
173
+ * @param data - The input data for the RPC request (required if input type is defined).
174
+ * @returns A promise that resolves to the output of the RPC handler.
175
+ */
176
+ const rpc = async <Name extends keyof FlattenedRPCMap>(
177
+ rpcName: Name,
178
+ ...args: FlattenedRPCMap[Name]['input'] extends null | undefined
179
+ ? [data?: FlattenedRPCMap[Name]['input']]
180
+ : [data: NonNullable<FlattenedRPCMap[Name]['input']>]
181
+ ): Promise<FlattenedRPCMap[Name]['output']> => {
182
+ return dynamicActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
183
+ }
184
+
185
+ /**
186
+ * Makes a static RPC request.
187
+ * Note: In HTTP wrapper context, both rpc and rpcStatic behave the same way.
188
+ *
189
+ * @template Name - The RPC function name from the FlattenedRPCMap.
190
+ * @param name - The RPC function identifier.
191
+ * @param data - The input data for the RPC request (required if input type is defined).
192
+ * @returns A promise that resolves to the output of the RPC handler.
193
+ */
194
+ const staticRPC = async <Name extends keyof FlattenedRPCMap>(
195
+ rpcName: Name,
196
+ ...args: FlattenedRPCMap[Name]['input'] extends null | undefined
197
+ ? [data?: FlattenedRPCMap[Name]['input']]
198
+ : [data: NonNullable<FlattenedRPCMap[Name]['input']>]
199
+ ): Promise<FlattenedRPCMap[Name]['output']> => {
200
+ return staticActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
150
201
  }
151
202
 
152
203
  return {
204
+ rpc,
153
205
  get: dynamicGet,
154
206
  post: dynamicPost,
155
207
  patch: dynamicPatch,
156
208
  del: dynamicDel,
157
209
  staticGet,
158
- staticPost
210
+ staticPost,
211
+ staticRPC
159
212
  }
160
213
  }
161
214
  `
@@ -2,12 +2,18 @@ import { pikkuVoidFunc } from '../../../../.pikku/pikku-types.gen.js'
2
2
  import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
3
3
  import { writeFileInDir } from '../../../utils/file-writer.js'
4
4
  import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
5
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
5
6
 
6
7
  export const pikkuChannels: any = pikkuVoidFunc({
7
8
  func: async ({ logger, config, getInspectorState }) => {
8
9
  const visitState = await getInspectorState()
9
- const { channelsWiringFile, channelsWiringMetaFile, packageMappings } =
10
- config
10
+ const {
11
+ channelsWiringFile,
12
+ channelsWiringMetaFile,
13
+ channelsWiringMetaJsonFile,
14
+ packageMappings,
15
+ schema,
16
+ } = config
11
17
  const { channels } = visitState
12
18
 
13
19
  await writeFileInDir(
@@ -20,10 +26,28 @@ export const pikkuChannels: any = pikkuVoidFunc({
20
26
  packageMappings
21
27
  )
22
28
  )
29
+
30
+ await writeFileInDir(
31
+ logger,
32
+ channelsWiringMetaJsonFile,
33
+ JSON.stringify(channels.meta, null, 2)
34
+ )
35
+
36
+ const jsonImportPath = getFileImportRelativePath(
37
+ channelsWiringMetaFile,
38
+ channelsWiringMetaJsonFile,
39
+ packageMappings
40
+ )
41
+
42
+ const supportsImportAttributes = schema?.supportsImportAttributes ?? false
43
+ const importStatement = supportsImportAttributes
44
+ ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
45
+ : `import metaData from '${jsonImportPath}'`
46
+
23
47
  await writeFileInDir(
24
48
  logger,
25
49
  channelsWiringMetaFile,
26
- `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`
50
+ `import { pikkuState } from '@pikku/core'\nimport { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`
27
51
  )
28
52
  },
29
53
  middleware: [
@@ -2,6 +2,11 @@ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
2
2
  import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
3
3
  import { writeFileInDir } from '../../../utils/file-writer.js'
4
4
  import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
5
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
6
+ import {
7
+ stripVerboseFields,
8
+ hasVerboseFields,
9
+ } from '../../../utils/strip-verbose-meta.js'
5
10
 
6
11
  export const pikkuChannels: any = pikkuSessionlessFunc<
7
12
  void,
@@ -9,8 +14,13 @@ export const pikkuChannels: any = pikkuSessionlessFunc<
9
14
  >({
10
15
  func: async ({ logger, config, getInspectorState }) => {
11
16
  const visitState = await getInspectorState()
12
- const { channelsWiringFile, channelsWiringMetaFile, packageMappings } =
13
- config
17
+ const {
18
+ channelsWiringFile,
19
+ channelsWiringMetaFile,
20
+ channelsWiringMetaJsonFile,
21
+ packageMappings,
22
+ schema,
23
+ } = config
14
24
  const { channels } = visitState
15
25
 
16
26
  await writeFileInDir(
@@ -23,10 +33,43 @@ export const pikkuChannels: any = pikkuSessionlessFunc<
23
33
  packageMappings
24
34
  )
25
35
  )
36
+
37
+ // Write minimal JSON (runtime-only fields)
38
+ const minimalMeta = stripVerboseFields(channels.meta)
39
+ await writeFileInDir(
40
+ logger,
41
+ channelsWiringMetaJsonFile,
42
+ JSON.stringify(minimalMeta, null, 2)
43
+ )
44
+
45
+ // Write verbose JSON only if it has additional fields
46
+ if (hasVerboseFields(channels.meta)) {
47
+ const verbosePath = channelsWiringMetaJsonFile.replace(
48
+ /\.gen\.json$/,
49
+ '-verbose.gen.json'
50
+ )
51
+ await writeFileInDir(
52
+ logger,
53
+ verbosePath,
54
+ JSON.stringify(channels.meta, null, 2)
55
+ )
56
+ }
57
+
58
+ // Generate TypeScript file that imports the minimal JSON
59
+ const jsonImportPath = getFileImportRelativePath(
60
+ channelsWiringMetaFile,
61
+ channelsWiringMetaJsonFile,
62
+ packageMappings
63
+ )
64
+ const supportsImportAttributes = schema?.supportsImportAttributes ?? false
65
+ const importStatement = supportsImportAttributes
66
+ ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
67
+ : `import metaData from '${jsonImportPath}'`
68
+
26
69
  await writeFileInDir(
27
70
  logger,
28
71
  channelsWiringMetaFile,
29
- `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`
72
+ `import { pikkuState } from '@pikku/core'\nimport type { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`
30
73
  )
31
74
 
32
75
  return true
@@ -8,9 +8,14 @@ export const serializeChannelTypes = (functionTypesImportPath: string) => {
8
8
  */
9
9
 
10
10
  import { CoreChannel, wireChannel as wireChannelCore } from '@pikku/core/channel'
11
- import { CorePikkuFunctionConfig } from '@pikku/core'
12
11
  import { AssertHTTPWiringParams } from '@pikku/core/http'
13
- import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
12
+ import type { PikkuFunctionConfig, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
13
+ import type { ZodLike, CorePermissionGroup } from '@pikku/core'
14
+
15
+ /**
16
+ * Helper type to infer the output type from a Zod schema
17
+ */
18
+ type InferZodOutput<T> = T extends ZodLike<infer U> ? U : never
14
19
 
15
20
  /**
16
21
  * Type definition for WebSocket channels with typed data exchange.
@@ -23,9 +28,9 @@ import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMid
23
28
  type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<
24
29
  ChannelData,
25
30
  Channel,
26
- CorePikkuFunctionConfig<PikkuFunctionSessionless<void, any, ChannelData>, PikkuPermission<void>, PikkuMiddleware>,
27
- CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void, ChannelData>, PikkuPermission<void>, PikkuMiddleware>,
28
- CorePikkuFunctionConfig<PikkuFunctionSessionless<any, any, ChannelData> | PikkuFunction<any, any, ChannelData>, PikkuPermission<any>, PikkuMiddleware>,
31
+ PikkuFunctionConfig<void, any, 'channel' | 'session' | 'rpc'>,
32
+ PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>,
33
+ PikkuFunctionConfig<any, any, 'channel' | 'session' | 'rpc'>,
29
34
  PikkuPermission,
30
35
  PikkuMiddleware
31
36
  >
@@ -40,8 +45,8 @@ type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<
40
45
  */
41
46
  export const pikkuChannelConnectionFunc = <Out = unknown>(
42
47
  func:
43
- | PikkuFunctionSessionless<void, Out, unknown>
44
- | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, Out, unknown>, PikkuPermission<void>, PikkuMiddleware>
48
+ | PikkuFunctionSessionless<void, Out, 'channel' | 'session' | 'rpc'>
49
+ | PikkuFunctionConfig<void, Out, 'channel' | 'session' | 'rpc'>
45
50
  ) => {
46
51
  return typeof func === 'function' ? { func } : func
47
52
  }
@@ -55,27 +60,78 @@ export const pikkuChannelConnectionFunc = <Out = unknown>(
55
60
  */
56
61
  export const pikkuChannelDisconnectionFunc = (
57
62
  func:
58
- | PikkuFunctionSessionless<void, void, unknown>
59
- | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void, unknown>, PikkuPermission<void>, PikkuMiddleware>
63
+ | PikkuFunctionSessionless<void, void, 'channel'>
64
+ | PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>
60
65
  ) => {
61
66
  return typeof func === 'function' ? { func } : func
62
67
  }
63
68
 
69
+ /**
70
+ * Configuration object for channel functions with Zod schema validation.
71
+ */
72
+ type PikkuChannelFuncConfigWithSchema<
73
+ InputSchema extends ZodLike,
74
+ OutputSchema extends ZodLike | undefined = undefined
75
+ > = {
76
+ name?: string
77
+ tags?: string[]
78
+ expose?: boolean
79
+ internal?: boolean
80
+ func: PikkuFunctionSessionless<
81
+ InferZodOutput<InputSchema>,
82
+ OutputSchema extends ZodLike ? InferZodOutput<OutputSchema> : unknown,
83
+ 'channel' | 'session' | 'rpc'
84
+ >
85
+ auth?: boolean
86
+ permissions?: CorePermissionGroup<PikkuPermission<InferZodOutput<InputSchema>>>
87
+ middleware?: PikkuMiddleware[]
88
+ input: InputSchema
89
+ output?: OutputSchema
90
+ }
91
+
64
92
  /**
65
93
  * Creates a function that handles WebSocket channel messages.
66
94
  * Called when a message is received on a channel.
67
- * This is the same as pikkuSessionlessFunc but with ChannelData = unknown by default.
68
95
  *
69
- * @template In - Input type for channel messages
70
- * @template Out - Output type for channel responses
96
+ * Supports two patterns:
97
+ * 1. Generic types: \`pikkuChannelFunc<Input, Output>({ func: ... })\`
98
+ * 2. Zod schemas: \`pikkuChannelFunc({ input: z.object(...), func: ... })\`
99
+ *
100
+ * @template In - Input type for channel messages (inferred from schema if provided)
101
+ * @template Out - Output type for channel responses (inferred from schema if provided)
71
102
  * @param func - Function definition, either direct function or configuration object
72
103
  * @returns The normalized configuration object
104
+ *
105
+ * @example
106
+ * \`\`\`typescript
107
+ * // Pattern 1: Using generic types
108
+ * const handleMessage = pikkuChannelFunc<{text: string}, {received: boolean}>({
109
+ * func: async (_services, { text }) => ({ received: true })
110
+ * })
111
+ *
112
+ * // Pattern 2: Using Zod schemas
113
+ * const messageInput = z.object({ text: z.string() })
114
+ * const messageOutput = z.object({ received: z.boolean() })
115
+ *
116
+ * const handleMessage = pikkuChannelFunc({
117
+ * input: messageInput,
118
+ * output: messageOutput,
119
+ * func: async (_services, { text }) => ({ received: true })
120
+ * })
121
+ * \`\`\`
73
122
  */
74
- export const pikkuChannelFunc = <In, Out = unknown>(
123
+ export function pikkuChannelFunc<
124
+ InputSchema extends ZodLike,
125
+ OutputSchema extends ZodLike | undefined = undefined
126
+ >(
127
+ config: PikkuChannelFuncConfigWithSchema<InputSchema, OutputSchema>
128
+ ): PikkuFunctionConfig<InferZodOutput<InputSchema>, OutputSchema extends ZodLike ? InferZodOutput<OutputSchema> : unknown, 'channel' | 'session' | 'rpc'>
129
+ export function pikkuChannelFunc<In, Out = unknown>(
75
130
  func:
76
- | PikkuFunctionSessionless<In, Out, unknown>
77
- | CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out, unknown>, PikkuPermission<In>, PikkuMiddleware>
78
- ) => {
131
+ | PikkuFunctionSessionless<In, Out, 'channel' | 'session' | 'rpc'>
132
+ | PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
133
+ ): PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
134
+ export function pikkuChannelFunc(func: any) {
79
135
  return typeof func === 'function' ? { func } : func
80
136
  }
81
137