@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
@@ -2,15 +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 pikkuCLI = pikkuSessionlessFunc({
6
8
  func: async ({ logger, config, getInspectorState }) => {
7
9
  const visitState = await getInspectorState();
8
- const { cliWiringsFile, cliWiringMetaFile, packageMappings } = config;
10
+ const { cliWiringsFile, cliWiringMetaFile, cliWiringMetaJsonFile, packageMappings, schema, } = config;
9
11
  const { cli } = visitState;
10
12
  // Generate CLI wirings file
11
13
  await writeFileInDir(logger, cliWiringsFile, serializeFileImports('wireCLI', cliWiringsFile, cli.files, packageMappings));
12
- // Generate CLI metadata file
13
- await writeFileInDir(logger, cliWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('cli', 'meta', ${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
+ }
22
+ const jsonImportPath = getFileImportRelativePath(cliWiringMetaFile, cliWiringMetaJsonFile, 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, cliWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { CLIMeta } from '@pikku/core/cli'\n${importStatement}\npikkuState(null, 'cli', 'meta', metaData as CLIMeta)`);
14
28
  return true;
15
29
  },
16
30
  middleware: [
@@ -50,7 +50,7 @@ import { pikkuMiddleware } from '${functionTypesPath}'
50
50
  ${imports}
51
51
 
52
52
  // Middleware to close the channel after CLI command completes
53
- const cliCloseOnComplete = pikkuMiddleware(async (services, { channel }, next) => {
53
+ const cliCloseOnComplete = pikkuMiddleware(async (_services, { channel }, next) => {
54
54
  const closeChannel = () => {
55
55
  setTimeout(async () => {
56
56
  try {
@@ -50,7 +50,7 @@ export const pikkuCLIRender = <Data, RequiredServices extends SingletonServices
50
50
  * CLI command configuration with project-specific types.
51
51
  * Uses CoreCLICommandConfig from @pikku/core with local middleware and render types.
52
52
  */
53
- type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
53
+ type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out, 'cli' | 'rpc' | 'session'>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
54
54
 
55
55
  /**
56
56
  * Type definition for CLI applications with commands and global options.
@@ -84,7 +84,7 @@ export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any
84
84
  * @returns CLI command configuration with inferred types
85
85
  */
86
86
  export const pikkuCLICommand = <
87
- FuncConfig extends PikkuFunctionConfig<any, any>,
87
+ FuncConfig extends PikkuFunctionConfig<any, any, 'cli' | 'rpc' | 'session'>,
88
88
  Params extends string
89
89
  >(
90
90
  config: CLICommandConfig<FuncConfig, any, any, Params>
@@ -8,7 +8,7 @@ export declare function serializeLocalCLIBootstrap(programName: string, _program
8
8
  }, singletonServicesFactory: {
9
9
  file: string;
10
10
  variable: string;
11
- }, sessionServicesFactory: {
11
+ }, wireServicesFactory: {
12
12
  file: string;
13
13
  variable: string;
14
14
  }): string;
@@ -2,18 +2,18 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
2
2
  /**
3
3
  * Serializes the local (in-program) CLI bootstrap code
4
4
  */
5
- export function serializeLocalCLIBootstrap(programName, _programMeta, bootstrapFile, config, pikkuConfigFactory, singletonServicesFactory, sessionServicesFactory) {
5
+ export function serializeLocalCLIBootstrap(programName, _programMeta, bootstrapFile, config, pikkuConfigFactory, singletonServicesFactory, wireServicesFactory) {
6
6
  const capitalizedName = programName.charAt(0).toUpperCase() + programName.slice(1).replace(/-/g, '');
7
7
  // Get relative import paths
8
8
  const pikkuConfigPath = getFileImportRelativePath(bootstrapFile, pikkuConfigFactory.file, config.packageMappings);
9
9
  const singletonServicesPath = getFileImportRelativePath(bootstrapFile, singletonServicesFactory.file, config.packageMappings);
10
- const sessionServicesPath = getFileImportRelativePath(bootstrapFile, sessionServicesFactory.file, config.packageMappings);
10
+ const wireServicesPath = getFileImportRelativePath(bootstrapFile, wireServicesFactory.file, config.packageMappings);
11
11
  const cliBootstrapPath = getFileImportRelativePath(bootstrapFile, config.bootstrapFile, config.packageMappings);
12
12
  return `
13
13
  import { executeCLI, CLIError } from '@pikku/core/cli'
14
14
  import { ${pikkuConfigFactory.variable} as createConfig } from '${pikkuConfigPath}'
15
15
  import { ${singletonServicesFactory.variable} as createSingletonServices } from '${singletonServicesPath}'
16
- import { ${sessionServicesFactory.variable} as createSessionServices } from '${sessionServicesPath}'
16
+ import { ${wireServicesFactory.variable} as createWireServices } from '${wireServicesPath}'
17
17
  import '${cliBootstrapPath}'
18
18
 
19
19
  /**
@@ -27,7 +27,7 @@ export async function ${capitalizedName}CLI(args: string[]): Promise<void> {
27
27
  args: args || process.argv.slice(2),
28
28
  createConfig,
29
29
  createSingletonServices,
30
- createSessionServices,
30
+ createWireServices,
31
31
  })
32
32
  } catch (error) {
33
33
  if (error instanceof CLIError) {
@@ -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
+ };
@@ -11,17 +11,17 @@ export const pikkuFunctionTypesSplit = pikkuSessionlessFunc({
11
11
  // Check for required types
12
12
  checkRequiredTypes(visitState.filesAndMethodsErrors, {
13
13
  userSessionType: true,
14
- sessionServiceType: true,
14
+ wireServiceType: true,
15
15
  singletonServicesType: true,
16
16
  });
17
- const { userSessionType, sessionServicesType, singletonServicesType, pikkuConfigType, } = visitState.filesAndMethods;
18
- if (!userSessionType || !sessionServicesType || !singletonServicesType) {
17
+ const { userSessionType, wireServicesType, singletonServicesType, pikkuConfigType, } = visitState.filesAndMethods;
18
+ if (!userSessionType || !wireServicesType || !singletonServicesType) {
19
19
  throw new Error('Required types not found');
20
20
  }
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 { ${sessionServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, sessionServicesType.typePath, packageMappings)}'`, sessionServicesType.type, `import type { TypedPikkuRPC } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`, `import type { RequiredSingletonServices, RequiredSessionServices } 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: [
@@ -1,21 +1,46 @@
1
1
  import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js';
2
2
  import { writeFileInDir } from '../../../utils/file-writer.js';
3
3
  import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
4
- import { generateRuntimeMeta, serializeFunctionImports, } from './serialize-function-imports.js';
4
+ import { serializeFunctionImports } from './serialize-function-imports.js';
5
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
6
+ import { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
5
7
  export const pikkuFunctions = pikkuSessionlessFunc({
6
8
  func: async ({ logger, config, getInspectorState }) => {
7
9
  const { functions, rpc } = await getInspectorState();
8
- const { functionsMetaFile, functionsMetaMinFile, functionsFile, packageMappings, } = config;
9
- // Generate full metadata
10
- await writeFileInDir(logger, functionsMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`);
11
- // Generate minimal metadata (runtime)
12
- const runtimeMeta = generateRuntimeMeta(functions.meta);
13
- await writeFileInDir(logger, functionsMetaMinFile, `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(runtimeMeta, null, 2)})`);
10
+ const { functionsMetaFile, functionsMetaJsonFile, functionsFile, packageMappings, schema, } = config;
11
+ // Write minimal JSON (runtime-only fields)
12
+ const minimalMeta = stripVerboseFields(functions.meta);
13
+ await writeFileInDir(logger, functionsMetaJsonFile, JSON.stringify(minimalMeta, null, 2));
14
+ // Write verbose JSON only if it has additional fields
15
+ if (hasVerboseFields(functions.meta)) {
16
+ const verbosePath = functionsMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json');
17
+ await writeFileInDir(logger, verbosePath, JSON.stringify(functions.meta, null, 2));
18
+ }
19
+ const jsonImportPath = getFileImportRelativePath(functionsMetaFile, functionsMetaJsonFile, packageMappings);
20
+ const supportsImportAttributes = schema?.supportsImportAttributes ?? false;
21
+ const importStatement = supportsImportAttributes
22
+ ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
23
+ : `import metaData from '${jsonImportPath}'`;
24
+ const packageName = config.externalPackageName
25
+ ? `'${config.externalPackageName}'`
26
+ : 'null';
27
+ await writeFileInDir(logger, functionsMetaFile, `import { pikkuState, FunctionsMeta } from '@pikku/core'\n${importStatement}\npikkuState(${packageName}, 'function', 'meta', metaData as FunctionsMeta)`);
28
+ // For external packages, register ALL functions (they'll be invoked by consumers)
29
+ // For main packages, only register functions that are invoked via internal RPCs
30
+ const isExternalPackage = !!config.externalPackageName;
14
31
  const hasRPCs = rpc.exposedFiles.size > 0 || rpc.internalFiles.size > 0;
15
- if (hasRPCs) {
16
- await writeFileInDir(logger, functionsFile, serializeFunctionImports(functionsFile, rpc.internalFiles, functions.meta, packageMappings));
32
+ const hasFunctions = functions.files.size > 0;
33
+ const shouldGenerateFunctionsFile = isExternalPackage
34
+ ? hasFunctions
35
+ : hasRPCs;
36
+ if (shouldGenerateFunctionsFile) {
37
+ // For external packages, use all function files; for main packages, use internal RPC files
38
+ const filesToRegister = isExternalPackage
39
+ ? functions.files
40
+ : rpc.internalFiles;
41
+ await writeFileInDir(logger, functionsFile, serializeFunctionImports(functionsFile, filesToRegister, functions.meta, packageMappings, config.externalPackageName));
17
42
  }
18
- return hasRPCs;
43
+ return shouldGenerateFunctionsFile;
19
44
  },
20
45
  middleware: [
21
46
  logCommandInfoAndTime({
@@ -1,2 +1,2 @@
1
- export declare const serializeServicesMap: (allSingletonServices: string[], allSessionServices: string[], requiredServices: Set<string>, forceRequiredServices: string[] | undefined, servicesImport: string, sessionServicesImport: string) => string;
1
+ export declare const serializeServicesMap: (allSingletonServices: string[], allWireServices: string[], requiredServices: Set<string>, forceRequiredServices: string[] | undefined, servicesImport: string, wireServicesImport: string) => string;
2
2
  export declare const pikkuServices: any;
@@ -3,7 +3,7 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
3
3
  import { checkRequiredTypes } from '../../../utils/check-required-types.js';
4
4
  import { writeFileInDir } from '../../../utils/file-writer.js';
5
5
  import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
6
- export const serializeServicesMap = (allSingletonServices, allSessionServices, requiredServices, forceRequiredServices = [], servicesImport, sessionServicesImport) => {
6
+ export const serializeServicesMap = (allSingletonServices, allWireServices, requiredServices, forceRequiredServices = [], servicesImport, wireServicesImport) => {
7
7
  // Use pre-aggregated services from inspector state
8
8
  // This includes services from:
9
9
  // - Wired functions (HTTP, channels, queues, schedulers, MCP, CLI, RPC)
@@ -11,7 +11,7 @@ export const serializeServicesMap = (allSingletonServices, allSessionServices, r
11
11
  // - Permissions used by wired functions
12
12
  // - Session factories
13
13
  const usedServices = new Set(requiredServices);
14
- // Internal services that are created internally by the framework (PikkuInteraction)
14
+ // Internal services that are created internally by the framework (PikkuWire)
15
15
  // These should not appear in the services maps
16
16
  const internalServices = new Set([
17
17
  'rpc',
@@ -30,31 +30,31 @@ export const serializeServicesMap = (allSingletonServices, allSessionServices, r
30
30
  }
31
31
  });
32
32
  // Services that are always required internally by the framework
33
- const defaultServices = ['config', 'logger', 'variables', 'schema'];
33
+ const defaultServices = ['config', 'logger', 'variables', 'schema', 'secrets'];
34
34
  defaultServices.forEach((service) => usedServices.add(service));
35
35
  // Create singleton services map: all singleton services with true/false based on usage
36
36
  const singletonServicesMap = {};
37
37
  allSingletonServices.forEach((service) => {
38
38
  singletonServicesMap[service] = usedServices.has(service);
39
39
  });
40
- // Create session services map: all session services with true/false based on usage
41
- // Exclude internal framework services (PikkuInteraction)
42
- const sessionServicesMap = {};
43
- allSessionServices.forEach((service) => {
40
+ // Create wire services map: all wire services with true/false based on usage
41
+ // Exclude internal framework services (PikkuWire)
42
+ const wireServicesMap = {};
43
+ allWireServices.forEach((service) => {
44
44
  if (!internalServices.has(service)) {
45
- sessionServicesMap[service] = usedServices.has(service);
45
+ wireServicesMap[service] = usedServices.has(service);
46
46
  }
47
47
  });
48
48
  // Get all required service names (those marked as true)
49
49
  const requiredSingletonServiceNames = Object.keys(singletonServicesMap)
50
50
  .filter((key) => singletonServicesMap[key])
51
51
  .sort();
52
- const requiredSessionServiceNames = Object.keys(sessionServicesMap)
53
- .filter((key) => sessionServicesMap[key])
52
+ const requiredWireServiceNames = Object.keys(wireServicesMap)
53
+ .filter((key) => wireServicesMap[key])
54
54
  .sort();
55
55
  const code = [
56
56
  servicesImport,
57
- sessionServicesImport,
57
+ wireServicesImport,
58
58
  '',
59
59
  '// Singleton services map: true if required, false if available but unused',
60
60
  'export const requiredSingletonServices = {',
@@ -63,11 +63,11 @@ export const serializeServicesMap = (allSingletonServices, allSessionServices, r
63
63
  .map((service) => ` '${service}': ${singletonServicesMap[service]},`),
64
64
  '} as const',
65
65
  '',
66
- '// Session services map: true if required, false if available but unused',
67
- 'export const requiredSessionServices = {',
68
- ...Object.keys(sessionServicesMap)
66
+ '// Wire services map: true if required, false if available but unused',
67
+ 'export const requiredWireServices = {',
68
+ ...Object.keys(wireServicesMap)
69
69
  .sort()
70
- .map((service) => ` '${service}': ${sessionServicesMap[service]},`),
70
+ .map((service) => ` '${service}': ${wireServicesMap[service]},`),
71
71
  '} as const',
72
72
  '',
73
73
  '// Type exports',
@@ -75,9 +75,9 @@ export const serializeServicesMap = (allSingletonServices, allSessionServices, r
75
75
  ? `export type RequiredSingletonServices = Pick<SingletonServices, ${requiredSingletonServiceNames.map((key) => `'${key}'`).join(' | ')}> & Partial<Omit<SingletonServices, ${requiredSingletonServiceNames.map((key) => `'${key}'`).join(' | ')}>>`
76
76
  : 'export type RequiredSingletonServices = Partial<SingletonServices>',
77
77
  '',
78
- requiredSessionServiceNames.length > 0
79
- ? `export type RequiredSessionServices = Pick<Services, ${requiredSessionServiceNames.map((key) => `'${key}'`).join(' | ')}> & Partial<Omit<Services, ${requiredSessionServiceNames.map((key) => `'${key}'`).join(' | ')}>>`
80
- : 'export type RequiredSessionServices = Partial<Services>',
78
+ requiredWireServiceNames.length > 0
79
+ ? `export type RequiredWireServices = Pick<Services, ${requiredWireServiceNames.map((key) => `'${key}'`).join(' | ')}> & Partial<Omit<Services, ${requiredWireServiceNames.map((key) => `'${key}'`).join(' | ')}>>`
80
+ : 'export type RequiredWireServices = Partial<Services>',
81
81
  '',
82
82
  ].join('\n');
83
83
  return code;
@@ -87,16 +87,16 @@ export const pikkuServices = pikkuSessionlessFunc({
87
87
  const visitState = await getInspectorState();
88
88
  // Check for required types
89
89
  checkRequiredTypes(visitState.filesAndMethodsErrors, {
90
- sessionServiceType: true,
90
+ wireServiceType: true,
91
91
  singletonServicesType: true,
92
92
  });
93
- const { sessionServicesType, singletonServicesType } = visitState.filesAndMethods;
94
- if (!sessionServicesType || !singletonServicesType) {
95
- throw new Error('Required types not found: sessionServicesType or singletonServicesType');
93
+ const { wireServicesType, singletonServicesType } = visitState.filesAndMethods;
94
+ if (!wireServicesType || !singletonServicesType) {
95
+ throw new Error('Required types not found: wireServicesType or singletonServicesType');
96
96
  }
97
97
  const servicesImport = `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(config.typesDeclarationFile, singletonServicesType.typePath, config.packageMappings)}'`;
98
- const sessionServicesImport = `import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(config.typesDeclarationFile, sessionServicesType.typePath, config.packageMappings)}'`;
99
- const servicesCode = serializeServicesMap(visitState.serviceAggregation.allSingletonServices, visitState.serviceAggregation.allSessionServices, visitState.serviceAggregation.requiredServices, config.forceRequiredServices, servicesImport, sessionServicesImport);
98
+ const wireServicesImport = `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(config.typesDeclarationFile, wireServicesType.typePath, config.packageMappings)}'`;
99
+ const servicesCode = serializeServicesMap(visitState.serviceAggregation.allSingletonServices, visitState.serviceAggregation.allWireServices, visitState.serviceAggregation.requiredServices, config.forceRequiredServices, servicesImport, wireServicesImport);
100
100
  await writeFileInDir(logger, config.servicesFile, servicesCode);
101
101
  },
102
102
  middleware: [
@@ -5,8 +5,8 @@ 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 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), getFileImportRelativePath(typesFile, forgeTypesFile, packageMappings));
10
10
  await writeFileInDir(logger, typesFile, content);
11
11
  },
12
12
  middleware: [
@@ -1,4 +1,4 @@
1
1
  /**
2
- * Generate JSON schemas from TypeScript types
2
+ * Generate JSON schemas from TypeScript types and Zod schemas
3
3
  */
4
4
  export declare const pikkuSchemas: any;
@@ -1,14 +1,15 @@
1
1
  import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js';
2
- import { saveSchemas, generateSchemas, } from '../../../utils/schema-generator.js';
2
+ import { saveSchemas, generateSchemas, generateZodSchemas, } from '../../../utils/schema-generator.js';
3
3
  import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
4
4
  /**
5
- * Generate JSON schemas from TypeScript types
5
+ * Generate JSON schemas from TypeScript types and Zod schemas
6
6
  */
7
7
  export const pikkuSchemas = pikkuSessionlessFunc({
8
8
  func: async ({ logger, config, getInspectorState }) => {
9
9
  const visitState = await getInspectorState();
10
- const schemas = await generateSchemas(logger, config.tsconfig, visitState.functions.typesMap, visitState.functions.meta, visitState.http.meta, config.schemasFromTypes, config.schema?.additionalProperties);
11
- await saveSchemas(logger, config.schemaDirectory, schemas, visitState.functions.typesMap, visitState.functions.meta, config.schemasFromTypes, config.schema?.supportsImportAttributes);
10
+ const schemas = await generateSchemas(logger, config.tsconfig, visitState.functions.typesMap, visitState.functions.meta, visitState.http.meta, config.schemasFromTypes, config.schema?.additionalProperties, visitState.zodLookup);
11
+ const zodSchemas = await generateZodSchemas(logger, visitState.zodLookup, visitState.functions.typesMap);
12
+ await saveSchemas(logger, config.schemaDirectory, { ...schemas, ...zodSchemas }, visitState.functions.typesMap, visitState.functions.meta, config.schema?.supportsImportAttributes || true, config.schemasFromTypes, visitState.zodLookup, config.externalPackageName || null);
12
13
  return true;
13
14
  },
14
15
  middleware: [
@@ -2,5 +2,7 @@ import { FunctionsMeta, FunctionsRuntimeMeta } from '@pikku/core';
2
2
  export declare const serializeFunctionImports: (outputPath: string, functionsMap: Map<string, {
3
3
  path: string;
4
4
  exportedName: string;
5
- }>, functionsMeta: FunctionsMeta, packageMappings?: Record<string, string>) => string;
5
+ }>, functionsMeta: FunctionsMeta, packageMappings?: Record<string, string>,
6
+ /** Package name for external packages (e.g., '@pikku/templates-function-external') */
7
+ externalPackageName?: string) => string;
6
8
  export declare const generateRuntimeMeta: (functions: FunctionsMeta) => FunctionsRuntimeMeta;