@pikku/cli 0.11.2 → 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 (301) hide show
  1. package/.pikku/channel/pikku-channel-types.gen.ts +63 -6
  2. package/.pikku/channel/pikku-channels-map.gen.d.ts +4 -4
  3. package/.pikku/channel/pikku-channels-meta.gen.ts +4 -2
  4. package/.pikku/channel/pikku-channels.gen.ts +1 -1
  5. package/.pikku/cli/pikku-cli-channel.ts +1 -1
  6. package/.pikku/cli/pikku-cli-client.gen.ts +1 -1
  7. package/.pikku/cli/pikku-cli-types.gen.ts +1 -1
  8. package/.pikku/cli/pikku-cli-wirings-meta.gen.json +2 -1
  9. package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +2 -2
  10. package/.pikku/cli/pikku-cli-wirings.gen.ts +1 -1
  11. package/.pikku/cli/pikku-cli.gen.ts +1 -1
  12. package/.pikku/forge/pikku-forge-types.gen.ts +83 -0
  13. package/.pikku/function/pikku-function-types.gen.ts +181 -35
  14. package/.pikku/function/pikku-functions-meta-verbose.gen.json +1030 -0
  15. package/.pikku/function/pikku-functions-meta.gen.json +88 -420
  16. package/.pikku/function/pikku-functions-meta.gen.ts +2 -2
  17. package/.pikku/http/pikku-http-types.gen.ts +19 -3
  18. package/.pikku/http/pikku-http-wirings-map.gen.d.ts +4 -4
  19. package/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
  20. package/.pikku/http/pikku-http-wirings-meta.gen.ts +4 -10
  21. package/.pikku/http/pikku-http-wirings.gen.ts +1 -1
  22. package/.pikku/mcp/pikku-mcp-types.gen.ts +69 -17
  23. package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +4 -4
  24. package/.pikku/mcp/pikku-mcp-wirings.gen.ts +1 -1
  25. package/.pikku/pikku-bootstrap.gen.ts +7 -9
  26. package/.pikku/pikku-services.gen.ts +3 -2
  27. package/.pikku/pikku-types.gen.ts +4 -1
  28. package/.pikku/pikku-websocket.gen.ts +1 -1
  29. package/.pikku/queue/pikku-queue-types.gen.ts +1 -1
  30. package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +4 -4
  31. package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +2 -2
  32. package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +1 -1
  33. package/.pikku/rpc/pikku-remote-rpc-workers.gen.ts +4 -1
  34. package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +12 -7
  35. package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +15 -9
  36. package/.pikku/scheduler/pikku-scheduler-types.gen.ts +1 -1
  37. package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +2 -2
  38. package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +1 -1
  39. package/.pikku/schemas/register.gen.ts +9 -1
  40. package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  41. package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
  42. package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
  43. package/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
  44. package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
  45. package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
  46. package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
  47. package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
  48. package/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
  49. package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
  50. package/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
  51. package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
  52. package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
  53. package/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
  54. package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
  55. package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
  56. package/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
  57. package/.pikku/services/config.gen.json +11 -6
  58. package/.pikku/services/getInspectorState.gen.json +2 -2
  59. package/.pikku/services/jwt.gen.json +2 -2
  60. package/.pikku/services/logger.gen.json +2 -2
  61. package/.pikku/services/queueService.gen.json +2 -2
  62. package/.pikku/services/schedulerService.gen.json +2 -2
  63. package/.pikku/services/schema.gen.json +2 -2
  64. package/.pikku/services/secrets.gen.json +13 -0
  65. package/.pikku/services/variables.gen.json +2 -2
  66. package/.pikku/services/workflowService.gen.json +6 -6
  67. package/.pikku/workflow/pikku-workflow-map.gen.d.ts +2 -36
  68. package/.pikku/workflow/pikku-workflow-types.gen.ts +297 -45
  69. package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +5 -4
  70. package/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -6
  71. package/CHANGELOG.md +23 -1
  72. package/cli.schema.json +1 -1
  73. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +47 -5
  74. package/dist/.pikku/channel/pikku-channel-types.gen.js +3 -13
  75. package/dist/.pikku/channel/pikku-channels-meta.gen.js +3 -2
  76. package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
  77. package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
  78. package/dist/.pikku/cli/pikku-cli-channel.js +1 -1
  79. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
  80. package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
  81. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
  82. package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
  83. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +2 -2
  84. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +2 -1
  85. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
  86. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
  87. package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
  88. package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
  89. package/dist/.pikku/forge/pikku-forge-types.gen.d.ts +72 -0
  90. package/dist/.pikku/forge/pikku-forge-types.gen.js +55 -0
  91. package/dist/.pikku/function/pikku-function-types.gen.d.ts +123 -31
  92. package/dist/.pikku/function/pikku-function-types.gen.js +37 -51
  93. package/dist/.pikku/function/pikku-functions-meta.gen.js +2 -2
  94. package/dist/.pikku/function/pikku-functions-meta.gen.json +88 -420
  95. package/dist/.pikku/http/pikku-http-types.gen.d.ts +18 -3
  96. package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
  97. package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +3 -10
  98. package/dist/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
  99. package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
  100. package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
  101. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +54 -14
  102. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +7 -31
  103. package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +4 -4
  104. package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
  105. package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
  106. package/dist/.pikku/pikku-bootstrap.gen.d.ts +7 -9
  107. package/dist/.pikku/pikku-bootstrap.gen.js +7 -9
  108. package/dist/.pikku/pikku-services.gen.d.ts +3 -2
  109. package/dist/.pikku/pikku-services.gen.js +1 -0
  110. package/dist/.pikku/pikku-types.gen.d.ts +2 -1
  111. package/dist/.pikku/pikku-types.gen.js +3 -1
  112. package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
  113. package/dist/.pikku/pikku-websocket.gen.js +1 -1
  114. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
  115. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
  116. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +2 -2
  117. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
  118. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
  119. package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.d.ts +4 -1
  120. package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +4 -1
  121. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
  122. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
  123. package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +2 -2
  124. package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
  125. package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
  126. package/dist/.pikku/schemas/register.gen.js +5 -1
  127. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  128. package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
  129. package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
  130. package/dist/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
  131. package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
  132. package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
  133. package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
  134. package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
  135. package/dist/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
  136. package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
  137. package/dist/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
  138. package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
  139. package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
  140. package/dist/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
  141. package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
  142. package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
  143. package/dist/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
  144. package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +207 -37
  145. package/dist/.pikku/workflow/pikku-workflow-types.gen.js +104 -28
  146. package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +3 -3
  147. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +2 -6
  148. package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +2 -6
  149. package/dist/src/functions/commands/all.js +117 -79
  150. package/dist/src/functions/commands/bootstrap.js +2 -9
  151. package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +0 -1
  152. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +49 -35
  153. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.js +49 -35
  154. package/dist/src/functions/wirings/channels/pikku-channels.js +1 -1
  155. package/dist/src/functions/wirings/channels/pikku-command-channels.js +18 -2
  156. package/dist/src/functions/wirings/channels/serialize-channel-types.js +62 -5
  157. package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +1 -2
  158. package/dist/src/functions/wirings/cli/pikku-command-cli.js +10 -2
  159. package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.d.ts +1 -0
  160. package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.js +90 -0
  161. package/dist/src/functions/wirings/forge/pikku-command-forge-types.d.ts +1 -0
  162. package/dist/src/functions/wirings/forge/pikku-command-forge-types.js +26 -0
  163. package/dist/src/functions/wirings/forge/serialize-forge-types.d.ts +4 -0
  164. package/dist/src/functions/wirings/forge/serialize-forge-types.js +90 -0
  165. package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
  166. package/dist/src/functions/wirings/functions/pikku-command-function-types.js +7 -2
  167. package/dist/src/functions/wirings/functions/pikku-command-functions.js +33 -18
  168. package/dist/src/functions/wirings/functions/pikku-command-services.js +1 -1
  169. package/dist/src/functions/wirings/functions/pikku-function-types.js +2 -2
  170. package/dist/src/functions/wirings/functions/schemas.d.ts +1 -1
  171. package/dist/src/functions/wirings/functions/schemas.js +5 -4
  172. package/dist/src/functions/wirings/functions/serialize-function-imports.d.ts +3 -1
  173. package/dist/src/functions/wirings/functions/serialize-function-imports.js +7 -3
  174. package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +1 -1
  175. package/dist/src/functions/wirings/functions/serialize-function-types.js +181 -34
  176. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
  177. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +19 -21
  178. package/dist/src/functions/wirings/http/openapi-spec-generator.js +1 -1
  179. package/dist/src/functions/wirings/http/pikku-command-http-routes.js +18 -2
  180. package/dist/src/functions/wirings/http/pikku-command-openapi.js +2 -2
  181. package/dist/src/functions/wirings/http/pikku-http-routes.js +1 -1
  182. package/dist/src/functions/wirings/http/serialize-http-types.js +18 -2
  183. package/dist/src/functions/wirings/http/serialize-typed-http-map.js +33 -8
  184. package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +15 -6
  185. package/dist/src/functions/wirings/mcp/serialize-mcp-json.js +3 -2
  186. package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +68 -16
  187. package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +5 -2
  188. package/dist/src/functions/wirings/package/pikku-command-package.d.ts +1 -0
  189. package/dist/src/functions/wirings/package/pikku-command-package.js +58 -0
  190. package/dist/src/functions/wirings/package/serialize-package.d.ts +5 -0
  191. package/dist/src/functions/wirings/package/serialize-package.js +32 -0
  192. package/dist/src/functions/wirings/queue/pikku-command-queue.js +10 -2
  193. package/dist/src/functions/wirings/queue/pikku-queue.js +1 -9
  194. package/dist/src/functions/wirings/queue/serialize-queue-map.js +20 -3
  195. package/dist/src/functions/wirings/queue/serialize-queue-meta.js +1 -1
  196. package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +4 -4
  197. package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +1 -1
  198. package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +3 -0
  199. package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +1 -1
  200. package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.d.ts +1 -1
  201. package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +54 -8
  202. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +10 -1
  203. package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.js +1 -1
  204. package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +56 -18
  205. package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +3 -0
  206. package/dist/src/functions/wirings/workflow/serialize-workflow-map.js +30 -32
  207. package/dist/src/functions/wirings/workflow/serialize-workflow-meta.d.ts +1 -3
  208. package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +43 -18
  209. package/dist/src/functions/wirings/workflow/serialize-workflow-registration.d.ts +7 -0
  210. package/dist/src/functions/wirings/workflow/serialize-workflow-registration.js +53 -0
  211. package/dist/src/functions/wirings/workflow/serialize-workflow-types.d.ts +3 -1
  212. package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +299 -45
  213. package/dist/src/functions/wirings/workflow/serialize-workflow-workers.d.ts +1 -1
  214. package/dist/src/functions/wirings/workflow/serialize-workflow-workers.js +14 -27
  215. package/dist/src/services.js +4 -1
  216. package/dist/src/utils/command-summary.d.ts +2 -0
  217. package/dist/src/utils/command-summary.js +2 -0
  218. package/dist/src/utils/custom-types-generator.js +13 -15
  219. package/dist/src/utils/generate-bootstrap-file.js +1 -1
  220. package/dist/src/utils/pikku-cli-config.js +37 -9
  221. package/dist/src/utils/schema-generator.d.ts +4 -3
  222. package/dist/src/utils/schema-generator.js +135 -15
  223. package/dist/src/utils/strip-verbose-meta.d.ts +43 -0
  224. package/dist/src/utils/strip-verbose-meta.js +210 -0
  225. package/dist/tsconfig.tsbuildinfo +1 -1
  226. package/package.json +7 -4
  227. package/src/functions/commands/all.ts +144 -97
  228. package/src/functions/commands/bootstrap.ts +2 -10
  229. package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +0 -1
  230. package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +49 -35
  231. package/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts +49 -35
  232. package/src/functions/wirings/channels/pikku-channels.ts +1 -1
  233. package/src/functions/wirings/channels/pikku-command-channels.ts +46 -3
  234. package/src/functions/wirings/channels/serialize-channel-types.ts +62 -5
  235. package/src/functions/wirings/channels/serialize-typed-channel-map.ts +3 -2
  236. package/src/functions/wirings/cli/pikku-command-cli.ts +21 -2
  237. package/src/functions/wirings/forge/pikku-command-forge-nodes.ts +135 -0
  238. package/src/functions/wirings/forge/pikku-command-forge-types.ts +38 -0
  239. package/src/functions/wirings/forge/serialize-forge-types.ts +94 -0
  240. package/src/functions/wirings/functions/pikku-command-function-types-split.ts +3 -2
  241. package/src/functions/wirings/functions/pikku-command-function-types.ts +17 -10
  242. package/src/functions/wirings/functions/pikku-command-functions.ts +47 -37
  243. package/src/functions/wirings/functions/pikku-command-services.ts +1 -1
  244. package/src/functions/wirings/functions/pikku-function-types.ts +3 -1
  245. package/src/functions/wirings/functions/schemas.ts +14 -4
  246. package/src/functions/wirings/functions/serialize-function-imports.ts +12 -3
  247. package/src/functions/wirings/functions/serialize-function-types.ts +182 -34
  248. package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +27 -26
  249. package/src/functions/wirings/http/openapi-spec-generator.ts +1 -1
  250. package/src/functions/wirings/http/pikku-command-http-routes.ts +46 -2
  251. package/src/functions/wirings/http/pikku-command-openapi.ts +3 -2
  252. package/src/functions/wirings/http/pikku-http-routes.ts +1 -1
  253. package/src/functions/wirings/http/serialize-http-types.ts +18 -2
  254. package/src/functions/wirings/http/serialize-typed-http-map.ts +32 -8
  255. package/src/functions/wirings/mcp/pikku-command-mcp.ts +32 -10
  256. package/src/functions/wirings/mcp/serialize-mcp-json.ts +8 -6
  257. package/src/functions/wirings/mcp/serialize-mcp-types.ts +68 -16
  258. package/src/functions/wirings/middleware/pikku-command-middleware.ts +6 -2
  259. package/src/functions/wirings/package/pikku-command-package.ts +81 -0
  260. package/src/functions/wirings/package/serialize-package.ts +69 -0
  261. package/src/functions/wirings/queue/pikku-command-queue.ts +22 -2
  262. package/src/functions/wirings/queue/pikku-queue.ts +1 -10
  263. package/src/functions/wirings/queue/serialize-queue-map.ts +18 -3
  264. package/src/functions/wirings/queue/serialize-queue-meta.ts +1 -1
  265. package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +7 -4
  266. package/src/functions/wirings/rpc/pikku-command-rpc.ts +1 -1
  267. package/src/functions/wirings/rpc/serialize-remote-rpc.ts +3 -0
  268. package/src/functions/wirings/rpc/serialize-rpc-wrapper.ts +1 -1
  269. package/src/functions/wirings/rpc/serialize-typed-rpc-map.ts +74 -8
  270. package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +22 -1
  271. package/src/functions/wirings/scheduler/serialize-scheduler-meta.ts +1 -1
  272. package/src/functions/wirings/workflow/pikku-command-workflow.ts +104 -37
  273. package/src/functions/wirings/workflow/serialize-workflow-map.ts +38 -40
  274. package/src/functions/wirings/workflow/serialize-workflow-meta.ts +66 -26
  275. package/src/functions/wirings/workflow/serialize-workflow-registration.ts +83 -0
  276. package/src/functions/wirings/workflow/serialize-workflow-types.ts +299 -45
  277. package/src/functions/wirings/workflow/serialize-workflow-workers.ts +14 -27
  278. package/src/services.ts +8 -1
  279. package/src/utils/command-summary.ts +4 -0
  280. package/src/utils/custom-types-generator.ts +15 -15
  281. package/src/utils/generate-bootstrap-file.ts +1 -1
  282. package/src/utils/pikku-cli-config.ts +51 -18
  283. package/src/utils/schema-generator.ts +185 -22
  284. package/src/utils/strip-verbose-meta.ts +254 -0
  285. package/types/config.d.ts +37 -3
  286. package/.pikku/function/pikku-functions-meta.min.gen.json +0 -212
  287. package/.pikku/function/pikku-functions-meta.min.gen.ts +0 -6
  288. package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +0 -1
  289. package/dist/.pikku/function/pikku-functions-meta.min.gen.js +0 -6
  290. package/dist/.pikku/function/pikku-functions-meta.min.gen.json +0 -212
  291. package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.d.ts +0 -1
  292. package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.js +0 -12
  293. package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.d.ts +0 -1
  294. package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.js +0 -13
  295. package/dist/src/functions/wirings/workflow/serialize-workflow-wirings.d.ts +0 -8
  296. package/dist/src/functions/wirings/workflow/serialize-workflow-wirings.js +0 -30
  297. package/src/functions/wirings/workflow/pikku-command-workflow-map.ts +0 -24
  298. package/src/functions/wirings/workflow/pikku-command-workflow-types.ts +0 -29
  299. package/src/functions/wirings/workflow/serialize-workflow-wirings.ts +0 -47
  300. /package/.pikku/{workflow/pikku-workflow-wirings-meta.gen.json → channel/pikku-channels-meta.gen.json} +0 -0
  301. /package/dist/.pikku/{workflow/pikku-workflow-wirings-meta.gen.json → channel/pikku-channels-meta.gen.json} +0 -0
@@ -7,7 +7,7 @@ export const serializeNextJsHTTPWrapper = (routesMapPath, rpcMapPath, pikkuFetch
7
7
  */
8
8
  import { CorePikkuFetchOptions } from '@pikku/fetch'
9
9
  import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
10
- import type { RPCMap } from '${rpcMapPath}'
10
+ import type { FlattenedRPCMap } from '${rpcMapPath}'
11
11
  import { PikkuFetch } from '${pikkuFetchImport}'
12
12
 
13
13
  let _pikku: PikkuFetch | undefined
@@ -60,14 +60,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
60
60
  *
61
61
  * @template Route - The route key with the POST method.
62
62
  * @param route - The route identifier.
63
- * @param data - The input data for the POST request, defaults to null.
63
+ * @param data - The input data for the POST request (required if input type is defined).
64
64
  * @returns A promise that resolves to the output of the POST handler.
65
65
  */
66
66
  const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
67
67
  route: Route,
68
- data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
68
+ ...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
69
+ ? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
70
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
69
71
  ): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
70
- return dynamicActionRequest(route, 'POST', data)
72
+ return dynamicActionRequest(route, 'POST', args[0] ?? null)
71
73
  }
72
74
 
73
75
  /**
@@ -75,14 +77,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
75
77
  *
76
78
  * @template Route - The route key with the GET method.
77
79
  * @param route - The route identifier.
78
- * @param data - The input data for the GET request, defaults to null.
80
+ * @param data - The input data for the GET request (required if input type is defined).
79
81
  * @returns A promise that resolves to the output of the GET handler.
80
82
  */
81
83
  const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
82
84
  route: Route,
83
- data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
85
+ ...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
86
+ ? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
87
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
84
88
  ): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
85
- return dynamicActionRequest(route, 'GET', data)
89
+ return dynamicActionRequest(route, 'GET', args[0] ?? null)
86
90
  }
87
91
 
88
92
  /**
@@ -90,14 +94,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
90
94
  *
91
95
  * @template Route - The route key with the PATCH method.
92
96
  * @param route - The route identifier.
93
- * @param data - The input data for the PATCH request, defaults to null.
97
+ * @param data - The input data for the PATCH request (required if input type is defined).
94
98
  * @returns A promise that resolves to the output of the PATCH handler.
95
99
  */
96
100
  const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
97
101
  route: Route,
98
- data: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] = null
102
+ ...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
103
+ ? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
104
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
99
105
  ): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
100
- return dynamicActionRequest(route, 'PATCH', data)
106
+ return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
101
107
  }
102
108
 
103
109
  /**
@@ -105,14 +111,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
105
111
  *
106
112
  * @template Route - The route key with the DELETE method.
107
113
  * @param route - The route identifier.
108
- * @param data - The input data for the DELETE request, defaults to null.
114
+ * @param data - The input data for the DELETE request (required if input type is defined).
109
115
  * @returns A promise that resolves to the output of the DELETE handler.
110
116
  */
111
117
  const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
112
118
  route: Route,
113
- data: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] = null
119
+ ...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
120
+ ? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
121
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
114
122
  ): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
115
- return dynamicActionRequest(route, 'DELETE', data)
123
+ return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
116
124
  }
117
125
 
118
126
  // Static Requests
@@ -122,14 +130,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
122
130
  *
123
131
  * @template Route - The route key with the POST method.
124
132
  * @param route - The route identifier.
125
- * @param data - The input data for the POST request, defaults to null.
133
+ * @param data - The input data for the POST request (required if input type is defined).
126
134
  * @returns A promise that resolves to the output of the POST handler.
127
135
  */
128
136
  const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
129
137
  route: Route,
130
- data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
138
+ ...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
139
+ ? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
140
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
131
141
  ): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
132
- return staticActionRequest(route, 'POST', data)
142
+ return staticActionRequest(route, 'POST', args[0] ?? null)
133
143
  }
134
144
 
135
145
  /**
@@ -137,49 +147,53 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
137
147
  *
138
148
  * @template Route - The route key with the GET method.
139
149
  * @param route - The route identifier.
140
- * @param data - The input data for the GET request, defaults to null.
150
+ * @param data - The input data for the GET request (required if input type is defined).
141
151
  * @returns A promise that resolves to the output of the GET handler.
142
152
  */
143
153
  const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
144
154
  route: Route,
145
- data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
155
+ ...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
156
+ ? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
157
+ : [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
146
158
  ): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
147
- return staticActionRequest(route, 'GET', data)
159
+ return staticActionRequest(route, 'GET', args[0] ?? null)
148
160
  }
149
161
 
150
162
  // RPC Requests
151
163
 
152
- /**
153
- * Type definition for RPC invocation.
154
- */
155
- type RPCInvoke = <Name extends keyof RPCMap>(
156
- name: Name,
157
- data: RPCMap[Name]['input']
158
- ) => Promise<RPCMap[Name]['output']>
159
-
160
164
  /**
161
165
  * Makes a dynamic RPC request.
162
166
  *
163
- * @template Name - The RPC function name from the RPCMap.
167
+ * @template Name - The RPC function name from the FlattenedRPCMap.
164
168
  * @param name - The RPC function identifier.
165
- * @param data - The input data for the RPC request.
169
+ * @param data - The input data for the RPC request (required if input type is defined).
166
170
  * @returns A promise that resolves to the output of the RPC handler.
167
171
  */
168
- const rpc: RPCInvoke = async (rpcName, data) => {
169
- return dynamicActionRequest(\`/rpc/\${rpcName}\` as any, 'POST', { data }) as any
172
+ const rpc = async <Name extends keyof FlattenedRPCMap>(
173
+ rpcName: Name,
174
+ ...args: FlattenedRPCMap[Name]['input'] extends null | undefined
175
+ ? [data?: FlattenedRPCMap[Name]['input']]
176
+ : [data: NonNullable<FlattenedRPCMap[Name]['input']>]
177
+ ): Promise<FlattenedRPCMap[Name]['output']> => {
178
+ return dynamicActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
170
179
  }
171
180
 
172
181
  /**
173
182
  * Makes a static RPC request.
174
183
  * Note: In HTTP wrapper context, both rpc and rpcStatic behave the same way.
175
184
  *
176
- * @template Name - The RPC function name from the RPCMap.
185
+ * @template Name - The RPC function name from the FlattenedRPCMap.
177
186
  * @param name - The RPC function identifier.
178
- * @param data - The input data for the RPC request.
187
+ * @param data - The input data for the RPC request (required if input type is defined).
179
188
  * @returns A promise that resolves to the output of the RPC handler.
180
189
  */
181
- const staticRPC: RPCInvoke = async (rpcName, data) => {
182
- return staticActionRequest(\`/rpc/\${rpcName}\` as any, 'POST', { data }) as any
190
+ const staticRPC = async <Name extends keyof FlattenedRPCMap>(
191
+ rpcName: Name,
192
+ ...args: FlattenedRPCMap[Name]['input'] extends null | undefined
193
+ ? [data?: FlattenedRPCMap[Name]['input']]
194
+ : [data: NonNullable<FlattenedRPCMap[Name]['input']>]
195
+ ): Promise<FlattenedRPCMap[Name]['output']> => {
196
+ return staticActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
183
197
  }
184
198
 
185
199
  return {
@@ -15,7 +15,7 @@ export const pikkuChannels = pikkuVoidFunc({
15
15
  const importStatement = supportsImportAttributes
16
16
  ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
17
17
  : `import metaData from '${jsonImportPath}'`;
18
- await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState('channel', 'meta', metaData as ChannelsMeta)`);
18
+ await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
19
19
  },
20
20
  middleware: [
21
21
  logCommandInfoAndTime({
@@ -2,13 +2,29 @@ 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 { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
5
7
  export const pikkuChannels = pikkuSessionlessFunc({
6
8
  func: async ({ logger, config, getInspectorState }) => {
7
9
  const visitState = await getInspectorState();
8
- const { channelsWiringFile, channelsWiringMetaFile, packageMappings } = config;
10
+ const { channelsWiringFile, channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings, schema, } = config;
9
11
  const { channels } = visitState;
10
12
  await writeFileInDir(logger, channelsWiringFile, serializeFileImports('addChannel', channelsWiringFile, channels.files, packageMappings));
11
- await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`);
13
+ // Write minimal JSON (runtime-only fields)
14
+ const minimalMeta = stripVerboseFields(channels.meta);
15
+ await writeFileInDir(logger, channelsWiringMetaJsonFile, JSON.stringify(minimalMeta, null, 2));
16
+ // Write verbose JSON only if it has additional fields
17
+ if (hasVerboseFields(channels.meta)) {
18
+ const verbosePath = channelsWiringMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json');
19
+ await writeFileInDir(logger, verbosePath, JSON.stringify(channels.meta, null, 2));
20
+ }
21
+ // Generate TypeScript file that imports the minimal JSON
22
+ const jsonImportPath = getFileImportRelativePath(channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings);
23
+ const supportsImportAttributes = schema?.supportsImportAttributes ?? false;
24
+ const importStatement = supportsImportAttributes
25
+ ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
26
+ : `import metaData from '${jsonImportPath}'`;
27
+ await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport type { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
12
28
  return true;
13
29
  },
14
30
  middleware: [
@@ -10,6 +10,12 @@ export const serializeChannelTypes = (functionTypesImportPath) => {
10
10
  import { CoreChannel, wireChannel as wireChannelCore } from '@pikku/core/channel'
11
11
  import { AssertHTTPWiringParams } from '@pikku/core/http'
12
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
13
19
 
14
20
  /**
15
21
  * Type definition for WebSocket channels with typed data exchange.
@@ -60,21 +66,72 @@ export const pikkuChannelDisconnectionFunc = (
60
66
  return typeof func === 'function' ? { func } : func
61
67
  }
62
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
+
63
92
  /**
64
93
  * Creates a function that handles WebSocket channel messages.
65
94
  * Called when a message is received on a channel.
66
- * This is the same as pikkuSessionlessFunc but with ChannelData = unknown by default.
67
95
  *
68
- * @template In - Input type for channel messages
69
- * @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)
70
102
  * @param func - Function definition, either direct function or configuration object
71
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
+ * \`\`\`
72
122
  */
73
- 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>(
74
130
  func:
75
131
  | PikkuFunctionSessionless<In, Out, 'channel' | 'session' | 'rpc'>
76
132
  | PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
77
- ) => {
133
+ ): PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
134
+ export function pikkuChannelFunc(func: any) {
78
135
  return typeof func === 'function' ? { func } : func
79
136
  }
80
137
 
@@ -4,7 +4,6 @@ export const serializeTypedChannelsMap = (relativeToPath, packageMappings, types
4
4
  const { channels, requiredTypes } = generateChannels(functionsMeta, channelsMeta);
5
5
  typesMap.customTypes.forEach(({ references }) => {
6
6
  for (const reference of references) {
7
- // Skip __object types (placeholder types for invalid/broken functions)
8
7
  if (reference !== '__object' && !reference.startsWith('__object_')) {
9
8
  requiredTypes.add(reference);
10
9
  }
@@ -15,7 +14,7 @@ export const serializeTypedChannelsMap = (relativeToPath, packageMappings, types
15
14
  return `/**
16
15
  * This provides the structure needed for TypeScript to be aware of channels
17
16
  */
18
-
17
+
19
18
  ${imports}
20
19
  ${serializedCustomTypes}
21
20
 
@@ -3,6 +3,7 @@ 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
5
  import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
6
+ import { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
6
7
  export const pikkuCLI = pikkuSessionlessFunc({
7
8
  func: async ({ logger, config, getInspectorState }) => {
8
9
  const visitState = await getInspectorState();
@@ -10,13 +11,20 @@ export const pikkuCLI = pikkuSessionlessFunc({
10
11
  const { cli } = visitState;
11
12
  // Generate CLI wirings file
12
13
  await writeFileInDir(logger, cliWiringsFile, serializeFileImports('wireCLI', cliWiringsFile, cli.files, packageMappings));
13
- await writeFileInDir(logger, cliWiringMetaJsonFile, JSON.stringify(cli.meta, null, 2));
14
+ // Write minimal JSON (runtime-only fields)
15
+ const minimalMeta = stripVerboseFields(cli.meta);
16
+ await writeFileInDir(logger, cliWiringMetaJsonFile, JSON.stringify(minimalMeta, null, 2));
17
+ // Write verbose JSON only if it has additional fields
18
+ if (hasVerboseFields(cli.meta)) {
19
+ const verbosePath = cliWiringMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json');
20
+ await writeFileInDir(logger, verbosePath, JSON.stringify(cli.meta, null, 2));
21
+ }
14
22
  const jsonImportPath = getFileImportRelativePath(cliWiringMetaFile, cliWiringMetaJsonFile, packageMappings);
15
23
  const supportsImportAttributes = schema?.supportsImportAttributes ?? false;
16
24
  const importStatement = supportsImportAttributes
17
25
  ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
18
26
  : `import metaData from '${jsonImportPath}'`;
19
- await writeFileInDir(logger, cliWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { CLIMeta } from '@pikku/core/cli'\n${importStatement}\npikkuState('cli', 'meta', metaData as CLIMeta)`);
27
+ await writeFileInDir(logger, cliWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { CLIMeta } from '@pikku/core/cli'\n${importStatement}\npikkuState(null, 'cli', 'meta', metaData as CLIMeta)`);
20
28
  return true;
21
29
  },
22
30
  middleware: [
@@ -0,0 +1 @@
1
+ export declare const pikkuForgeNodes: any;
@@ -0,0 +1,90 @@
1
+ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js';
2
+ import { ErrorCode } from '@pikku/inspector';
3
+ import { writeFileInDir } from '../../../utils/file-writer.js';
4
+ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
5
+ import { readFile } from 'fs/promises';
6
+ import { join, isAbsolute } from 'path';
7
+ import { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
8
+ /**
9
+ * Load and sanitize an SVG icon file.
10
+ * Returns the SVG content as a string, or undefined if not found.
11
+ */
12
+ const loadIcon = async (iconPath, rootDir, logger) => {
13
+ if (!iconPath)
14
+ return undefined;
15
+ // Resolve the full path to the icon
16
+ const fullPath = isAbsolute(iconPath) ? iconPath : join(rootDir, iconPath);
17
+ try {
18
+ const content = await readFile(fullPath, 'utf-8');
19
+ // Basic SVG validation - must start with <svg
20
+ const trimmed = content.trim();
21
+ if (!trimmed.startsWith('<svg') && !trimmed.startsWith('<?xml')) {
22
+ logger.warn(`Icon file is not a valid SVG: ${fullPath}`);
23
+ return undefined;
24
+ }
25
+ // Return the sanitized SVG (remove XML declaration if present)
26
+ return trimmed.replace(/<\?xml[^?]*\?>\s*/g, '').trim();
27
+ }
28
+ catch (e) {
29
+ logger.warn(`Could not load icon: ${fullPath}`);
30
+ return undefined;
31
+ }
32
+ };
33
+ export const pikkuForgeNodes = pikkuSessionlessFunc({
34
+ func: async ({ logger, config, getInspectorState }) => {
35
+ const { forgeNodes, forgeCredentials } = await getInspectorState();
36
+ const { forgeNodesMetaJsonFile, forge, rootDir } = config;
37
+ const hasNodes = Object.keys(forgeNodes.meta).length > 0;
38
+ const hasCredentials = Object.keys(forgeCredentials.meta).length > 0;
39
+ // Only generate if there are forge nodes or credentials
40
+ if (!hasNodes && !hasCredentials) {
41
+ return undefined;
42
+ }
43
+ // Validate categories if configured
44
+ const allowedCategories = forge?.node?.categories;
45
+ if (allowedCategories && allowedCategories.length > 0) {
46
+ for (const [name, meta] of Object.entries(forgeNodes.meta)) {
47
+ if (!allowedCategories.includes(meta.category)) {
48
+ logger.critical(ErrorCode.INVALID_VALUE, `Forge node '${name}' has invalid category '${meta.category}'. ` +
49
+ `Allowed categories: ${allowedCategories.join(', ')}`);
50
+ }
51
+ }
52
+ }
53
+ // Build the output metadata - remove per-node icon field
54
+ const outputMeta = {};
55
+ for (const [name, meta] of Object.entries(forgeNodes.meta)) {
56
+ // Remove icon from node meta - only package-level icon is used
57
+ const { icon: _icon, ...nodeMetaWithoutIcon } = meta;
58
+ outputMeta[name] = nodeMetaWithoutIcon;
59
+ }
60
+ // Load package-level icon
61
+ const packageIcon = await loadIcon(forge?.node?.icon, rootDir, logger);
62
+ const metaData = {
63
+ nodes: outputMeta,
64
+ credentials: forgeCredentials.meta,
65
+ package: {
66
+ displayName: forge?.node?.displayName,
67
+ description: forge?.node?.description,
68
+ icon: packageIcon,
69
+ categories: forge?.node?.categories,
70
+ },
71
+ };
72
+ if (forgeNodesMetaJsonFile) {
73
+ // Write minimal JSON (runtime-only fields)
74
+ const minimalMeta = stripVerboseFields(metaData);
75
+ await writeFileInDir(logger, forgeNodesMetaJsonFile, JSON.stringify(minimalMeta, null, 2), { ignoreModifyComment: true });
76
+ // Write verbose JSON only if it has additional fields
77
+ if (hasVerboseFields(metaData)) {
78
+ const verbosePath = forgeNodesMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json');
79
+ await writeFileInDir(logger, verbosePath, JSON.stringify(metaData, null, 2), { ignoreModifyComment: true });
80
+ }
81
+ }
82
+ return true;
83
+ },
84
+ middleware: [
85
+ logCommandInfoAndTime({
86
+ commandStart: 'Generating Forge nodes metadata',
87
+ commandEnd: 'Generated Forge nodes metadata',
88
+ }),
89
+ ],
90
+ });
@@ -0,0 +1 @@
1
+ export declare const pikkuForgeTypes: any;
@@ -0,0 +1,26 @@
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 { serializeForgeTypes } from './serialize-forge-types.js';
6
+ export const pikkuForgeTypes = pikkuSessionlessFunc({
7
+ func: async ({ logger, config }) => {
8
+ const { forgeTypesFile, rpcInternalMapDeclarationFile, packageMappings, forge, } = config;
9
+ // Get the import path for the RPC map declaration file
10
+ // The declaration file ends in .d.ts, but we need to import from .js
11
+ // getFileImportRelativePath converts .ts -> .js, so .d.ts -> .d.js
12
+ // We need to remove the extra .d extension
13
+ let rpcMapImportPath = getFileImportRelativePath(forgeTypesFile, rpcInternalMapDeclarationFile, packageMappings);
14
+ // Fix: .d.ts files should be imported as .js (TypeScript resolves types from .d.ts)
15
+ rpcMapImportPath = rpcMapImportPath.replace('.d.js', '.js');
16
+ const categories = forge?.node?.categories;
17
+ const content = serializeForgeTypes(rpcMapImportPath, categories);
18
+ await writeFileInDir(logger, forgeTypesFile, content);
19
+ },
20
+ middleware: [
21
+ logCommandInfoAndTime({
22
+ commandStart: 'Creating Forge types',
23
+ commandEnd: 'Created Forge types',
24
+ }),
25
+ ],
26
+ });
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Generates type definitions for Forge wirings with typed category and RPC validation
3
+ */
4
+ export declare const serializeForgeTypes: (rpcMapImportPath: string, categories: string[] | undefined) => string;
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Generates type definitions for Forge wirings with typed category and RPC validation
3
+ */
4
+ export const serializeForgeTypes = (rpcMapImportPath, categories) => {
5
+ // Generate category union type - 'never' if no categories configured
6
+ const categoryType = categories?.length
7
+ ? categories.map((c) => `'${c}'`).join(' | ')
8
+ : 'never';
9
+ return `/**
10
+ * Forge-specific type definitions for typed wireForgeNode and wireForgeCredential
11
+ */
12
+
13
+ import { wireForgeNode as wireForgeNodeCore, wireForgeCredential as wireForgeCredentialCore } from '@pikku/core/forge-node'
14
+ import type { CoreForgeNode, CoreForgeCredential } from '@pikku/core/forge-node'
15
+ import type { FlattenedRPCMap } from '${rpcMapImportPath}'
16
+
17
+ /**
18
+ * Valid category values for forge nodes.
19
+ * ${categories?.length ? `Configured categories: ${categories.join(', ')}` : 'No categories configured - wireForgeNode cannot be used until forge.node.categories is defined in pikku.config.json.'}
20
+ */
21
+ export type ForgeCategory = ${categoryType}
22
+
23
+ /**
24
+ * Valid RPC names that can be used with forge nodes.
25
+ * These are derived from the FlattenedRPCMap which includes both local and external package RPCs.
26
+ */
27
+ export type ForgeRPCName = keyof FlattenedRPCMap
28
+
29
+ /**
30
+ * Typed forge node configuration.
31
+ * Validates that category and rpc are valid values.
32
+ */
33
+ export type TypedForgeNode = Omit<CoreForgeNode, 'category' | 'rpc'> & {
34
+ /** Grouping category (validated against forge.node.categories in config) */
35
+ category: ForgeCategory
36
+ /** RPC name to call when node executes (must be a valid RPC name) */
37
+ rpc: ForgeRPCName
38
+ }
39
+
40
+ /**
41
+ * Registers a Forge node with validated category and RPC.
42
+ *
43
+ * @param config - Forge node configuration with typed category and rpc
44
+ *
45
+ * @example
46
+ * \`\`\`typescript
47
+ * wireForgeNode({
48
+ * name: 'send-email',
49
+ * displayName: 'Send Email',
50
+ * category: 'Communication', // Must be in forge.node.categories
51
+ * type: 'action',
52
+ * rpc: 'sendEmail', // Must be a valid RPC name
53
+ * description: 'Sends an email to a recipient'
54
+ * })
55
+ * \`\`\`
56
+ */
57
+ export const wireForgeNode = (config: TypedForgeNode): void => {
58
+ wireForgeNodeCore(config as CoreForgeNode)
59
+ }
60
+
61
+ /**
62
+ * Registers a Forge credential definition.
63
+ * Credentials define secrets/API keys required by the package.
64
+ *
65
+ * @template T - Zod schema type for the credential structure
66
+ * @param config - Forge credential configuration
67
+ *
68
+ * @example
69
+ * \`\`\`typescript
70
+ * import { z } from 'zod'
71
+ *
72
+ * const apiCredentials = z.object({
73
+ * apiKey: z.string().describe('API key for authentication'),
74
+ * apiSecret: z.string().describe('API secret')
75
+ * })
76
+ *
77
+ * wireForgeCredential({
78
+ * name: 'example-api',
79
+ * displayName: 'Example API Credentials',
80
+ * description: 'Credentials for the example external API',
81
+ * secretId: 'EXAMPLE_API_CREDENTIALS',
82
+ * schema: apiCredentials
83
+ * })
84
+ * \`\`\`
85
+ */
86
+ export const wireForgeCredential = <T>(config: CoreForgeCredential<T>): void => {
87
+ wireForgeCredentialCore(config)
88
+ }
89
+ `;
90
+ };
@@ -21,7 +21,7 @@ export const pikkuFunctionTypesSplit = pikkuSessionlessFunc({
21
21
  const configTypeImport = pikkuConfigType
22
22
  ? `import type { ${pikkuConfigType.type} } from '${getFileImportRelativePath(functionTypesFile, pikkuConfigType.typePath, packageMappings)}'`
23
23
  : '// Config type not found, will use fallback';
24
- const content = serializeFunctionTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(functionTypesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`, wireServicesType.type, `import type { TypedPikkuRPC } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`, `import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`, configTypeImport);
24
+ const content = serializeFunctionTypes(`import type { ${userSessionType.type} } from '${getFileImportRelativePath(functionTypesFile, userSessionType.typePath, packageMappings)}'`, userSessionType.type, `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`, singletonServicesType.type, `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`, wireServicesType.type, `import type { TypedPikkuRPC, FlattenedRPCMap } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`, `import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`, configTypeImport, config.externalPackageName);
25
25
  await writeFileInDir(logger, functionTypesFile, content);
26
26
  },
27
27
  middleware: [
@@ -5,8 +5,13 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
5
5
  import { serializePikkuTypesHub } from './serialize-pikku-types-hub.js';
6
6
  export const pikkuFunctionTypes = pikkuSessionlessFunc({
7
7
  func: async ({ logger, config }) => {
8
- const { typesDeclarationFile: typesFile, packageMappings, functionTypesFile, httpTypesFile, channelsTypesFile, schedulersTypesFile, queueTypesFile, mcpTypesFile, cliTypesFile, } = config;
9
- const content = serializePikkuTypesHub(getFileImportRelativePath(typesFile, functionTypesFile, packageMappings), getFileImportRelativePath(typesFile, httpTypesFile, packageMappings), getFileImportRelativePath(typesFile, channelsTypesFile, packageMappings), getFileImportRelativePath(typesFile, schedulersTypesFile, packageMappings), getFileImportRelativePath(typesFile, queueTypesFile, packageMappings), getFileImportRelativePath(typesFile, mcpTypesFile, packageMappings), getFileImportRelativePath(typesFile, cliTypesFile, packageMappings));
8
+ const { typesDeclarationFile: typesFile, packageMappings, functionTypesFile, httpTypesFile, channelsTypesFile, schedulersTypesFile, queueTypesFile, mcpTypesFile, cliTypesFile, forgeTypesFile, } = config;
9
+ const getImportPath = (file) => config.externalPackage
10
+ ? null
11
+ : getFileImportRelativePath(typesFile, file, packageMappings);
12
+ // Forge types are included for external packages (they need wireForgeNode/wireForgeCredential)
13
+ const getForgeImportPath = (file) => getFileImportRelativePath(typesFile, file, packageMappings);
14
+ const content = serializePikkuTypesHub(getFileImportRelativePath(typesFile, functionTypesFile, packageMappings), getImportPath(httpTypesFile), getImportPath(channelsTypesFile), getImportPath(schedulersTypesFile), getImportPath(queueTypesFile), getImportPath(mcpTypesFile), getImportPath(cliTypesFile), getForgeImportPath(forgeTypesFile));
10
15
  await writeFileInDir(logger, typesFile, content);
11
16
  },
12
17
  middleware: [