@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
@@ -17,12 +17,12 @@ export const serializeTypedChannelsMap = (
17
17
  )
18
18
  typesMap.customTypes.forEach(({ references }) => {
19
19
  for (const reference of references) {
20
- // Skip __object types (placeholder types for invalid/broken functions)
21
20
  if (reference !== '__object' && !reference.startsWith('__object_')) {
22
21
  requiredTypes.add(reference)
23
22
  }
24
23
  }
25
24
  })
25
+
26
26
  const imports = serializeImportMap(
27
27
  relativeToPath,
28
28
  packageMappings,
@@ -30,10 +30,11 @@ export const serializeTypedChannelsMap = (
30
30
  requiredTypes
31
31
  )
32
32
  const serializedCustomTypes = generateCustomTypes(typesMap, requiredTypes)
33
+
33
34
  return `/**
34
35
  * This provides the structure needed for TypeScript to be aware of channels
35
36
  */
36
-
37
+
37
38
  ${imports}
38
39
  ${serializedCustomTypes}
39
40
 
@@ -173,19 +173,19 @@ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
173
173
  checkRequiredTypes(visitState.filesAndMethodsErrors, {
174
174
  config: true,
175
175
  singletonServicesFactory: true,
176
- sessionServicesFactory: true,
176
+ wireServicesFactory: true,
177
177
  })
178
178
 
179
179
  const {
180
180
  pikkuConfigFactory,
181
181
  singletonServicesFactory,
182
- sessionServicesFactory,
182
+ wireServicesFactory,
183
183
  } = visitState.filesAndMethods
184
184
 
185
185
  if (
186
186
  !pikkuConfigFactory ||
187
187
  !singletonServicesFactory ||
188
- !sessionServicesFactory
188
+ !wireServicesFactory
189
189
  ) {
190
190
  throw new Error('Required types not found')
191
191
  }
@@ -197,7 +197,7 @@ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
197
197
  config,
198
198
  pikkuConfigFactory,
199
199
  singletonServicesFactory,
200
- sessionServicesFactory
200
+ wireServicesFactory
201
201
  )
202
202
 
203
203
  await writeFileInDir(logger, bootstrapFile, bootstrapCode)
@@ -19,7 +19,7 @@ export const pikkuCLITypes: any = pikkuSessionlessFunc<void, void>({
19
19
  // Check for required types
20
20
  checkRequiredTypes(visitState.filesAndMethodsErrors, {
21
21
  userSessionType: true,
22
- sessionServiceType: true,
22
+ wireServiceType: true,
23
23
  singletonServicesType: true,
24
24
  })
25
25
 
@@ -2,11 +2,22 @@ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
2
2
  import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
3
3
  import { writeFileInDir } from '../../../utils/file-writer.js'
4
4
  import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
5
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
6
+ import {
7
+ stripVerboseFields,
8
+ hasVerboseFields,
9
+ } from '../../../utils/strip-verbose-meta.js'
5
10
 
6
11
  export const pikkuCLI: any = pikkuSessionlessFunc<void, boolean | undefined>({
7
12
  func: async ({ logger, config, getInspectorState }) => {
8
13
  const visitState = await getInspectorState()
9
- const { cliWiringsFile, cliWiringMetaFile, packageMappings } = config
14
+ const {
15
+ cliWiringsFile,
16
+ cliWiringMetaFile,
17
+ cliWiringMetaJsonFile,
18
+ packageMappings,
19
+ schema,
20
+ } = config
10
21
  const { cli } = visitState
11
22
 
12
23
  // Generate CLI wirings file
@@ -21,11 +32,42 @@ export const pikkuCLI: any = pikkuSessionlessFunc<void, boolean | undefined>({
21
32
  )
22
33
  )
23
34
 
24
- // Generate CLI metadata file
35
+ // Write minimal JSON (runtime-only fields)
36
+ const minimalMeta = stripVerboseFields(cli.meta)
37
+ await writeFileInDir(
38
+ logger,
39
+ cliWiringMetaJsonFile,
40
+ JSON.stringify(minimalMeta, null, 2)
41
+ )
42
+
43
+ // Write verbose JSON only if it has additional fields
44
+ if (hasVerboseFields(cli.meta)) {
45
+ const verbosePath = cliWiringMetaJsonFile.replace(
46
+ /\.gen\.json$/,
47
+ '-verbose.gen.json'
48
+ )
49
+ await writeFileInDir(
50
+ logger,
51
+ verbosePath,
52
+ JSON.stringify(cli.meta, null, 2)
53
+ )
54
+ }
55
+
56
+ const jsonImportPath = getFileImportRelativePath(
57
+ cliWiringMetaFile,
58
+ cliWiringMetaJsonFile,
59
+ packageMappings
60
+ )
61
+
62
+ const supportsImportAttributes = schema?.supportsImportAttributes ?? false
63
+ const importStatement = supportsImportAttributes
64
+ ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
65
+ : `import metaData from '${jsonImportPath}'`
66
+
25
67
  await writeFileInDir(
26
68
  logger,
27
69
  cliWiringMetaFile,
28
- `import { pikkuState } from '@pikku/core'\npikkuState('cli', 'meta', ${JSON.stringify(cli.meta, null, 2)})`
70
+ `import { pikkuState } from '@pikku/core'\nimport { CLIMeta } from '@pikku/core/cli'\n${importStatement}\npikkuState(null, 'cli', 'meta', metaData as CLIMeta)`
29
71
  )
30
72
 
31
73
  return true
@@ -89,7 +89,7 @@ import { pikkuMiddleware } from '${functionTypesPath}'
89
89
  ${imports}
90
90
 
91
91
  // Middleware to close the channel after CLI command completes
92
- const cliCloseOnComplete = pikkuMiddleware(async (services, { channel }, next) => {
92
+ const cliCloseOnComplete = pikkuMiddleware(async (_services, { channel }, next) => {
93
93
  const closeChannel = () => {
94
94
  setTimeout(async () => {
95
95
  try {
@@ -56,7 +56,7 @@ export const pikkuCLIRender = <Data, RequiredServices extends SingletonServices
56
56
  * CLI command configuration with project-specific types.
57
57
  * Uses CoreCLICommandConfig from @pikku/core with local middleware and render types.
58
58
  */
59
- type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
59
+ type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out, 'cli' | 'rpc' | 'session'>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
60
60
 
61
61
  /**
62
62
  * Type definition for CLI applications with commands and global options.
@@ -90,7 +90,7 @@ export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any
90
90
  * @returns CLI command configuration with inferred types
91
91
  */
92
92
  export const pikkuCLICommand = <
93
- FuncConfig extends PikkuFunctionConfig<any, any>,
93
+ FuncConfig extends PikkuFunctionConfig<any, any, 'cli' | 'rpc' | 'session'>,
94
94
  Params extends string
95
95
  >(
96
96
  config: CLICommandConfig<FuncConfig, any, any, Params>
@@ -11,7 +11,7 @@ export function serializeLocalCLIBootstrap(
11
11
  config: Config,
12
12
  pikkuConfigFactory: { file: string; variable: string },
13
13
  singletonServicesFactory: { file: string; variable: string },
14
- sessionServicesFactory: { file: string; variable: string }
14
+ wireServicesFactory: { file: string; variable: string }
15
15
  ): string {
16
16
  const capitalizedName =
17
17
  programName.charAt(0).toUpperCase() + programName.slice(1).replace(/-/g, '')
@@ -27,9 +27,9 @@ export function serializeLocalCLIBootstrap(
27
27
  singletonServicesFactory.file,
28
28
  config.packageMappings
29
29
  )
30
- const sessionServicesPath = getFileImportRelativePath(
30
+ const wireServicesPath = getFileImportRelativePath(
31
31
  bootstrapFile,
32
- sessionServicesFactory.file,
32
+ wireServicesFactory.file,
33
33
  config.packageMappings
34
34
  )
35
35
  const cliBootstrapPath = getFileImportRelativePath(
@@ -42,7 +42,7 @@ export function serializeLocalCLIBootstrap(
42
42
  import { executeCLI, CLIError } from '@pikku/core/cli'
43
43
  import { ${pikkuConfigFactory.variable} as createConfig } from '${pikkuConfigPath}'
44
44
  import { ${singletonServicesFactory.variable} as createSingletonServices } from '${singletonServicesPath}'
45
- import { ${sessionServicesFactory.variable} as createSessionServices } from '${sessionServicesPath}'
45
+ import { ${wireServicesFactory.variable} as createWireServices } from '${wireServicesPath}'
46
46
  import '${cliBootstrapPath}'
47
47
 
48
48
  /**
@@ -56,7 +56,7 @@ export async function ${capitalizedName}CLI(args: string[]): Promise<void> {
56
56
  args: args || process.argv.slice(2),
57
57
  createConfig,
58
58
  createSingletonServices,
59
- createSessionServices,
59
+ createWireServices,
60
60
  })
61
61
  } catch (error) {
62
62
  if (error instanceof CLIError) {
@@ -0,0 +1,135 @@
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 {
8
+ stripVerboseFields,
9
+ hasVerboseFields,
10
+ } from '../../../utils/strip-verbose-meta.js'
11
+
12
+ /**
13
+ * Load and sanitize an SVG icon file.
14
+ * Returns the SVG content as a string, or undefined if not found.
15
+ */
16
+ const loadIcon = async (
17
+ iconPath: string | undefined,
18
+ rootDir: string,
19
+ logger: any
20
+ ): Promise<string | undefined> => {
21
+ if (!iconPath) return undefined
22
+
23
+ // Resolve the full path to the icon
24
+ const fullPath = isAbsolute(iconPath) ? iconPath : join(rootDir, iconPath)
25
+
26
+ try {
27
+ const content = await readFile(fullPath, 'utf-8')
28
+
29
+ // Basic SVG validation - must start with <svg
30
+ const trimmed = content.trim()
31
+ if (!trimmed.startsWith('<svg') && !trimmed.startsWith('<?xml')) {
32
+ logger.warn(`Icon file is not a valid SVG: ${fullPath}`)
33
+ return undefined
34
+ }
35
+
36
+ // Return the sanitized SVG (remove XML declaration if present)
37
+ return trimmed.replace(/<\?xml[^?]*\?>\s*/g, '').trim()
38
+ } catch (e) {
39
+ logger.warn(`Could not load icon: ${fullPath}`)
40
+ return undefined
41
+ }
42
+ }
43
+
44
+ export const pikkuForgeNodes: any = pikkuSessionlessFunc<
45
+ void,
46
+ boolean | undefined
47
+ >({
48
+ func: async ({ logger, config, getInspectorState }) => {
49
+ const { forgeNodes, forgeCredentials } = await getInspectorState()
50
+ const { forgeNodesMetaJsonFile, forge, rootDir } = config
51
+
52
+ const hasNodes = Object.keys(forgeNodes.meta).length > 0
53
+ const hasCredentials = Object.keys(forgeCredentials.meta).length > 0
54
+
55
+ // Only generate if there are forge nodes or credentials
56
+ if (!hasNodes && !hasCredentials) {
57
+ return undefined
58
+ }
59
+
60
+ // Validate categories if configured
61
+ const allowedCategories = forge?.node?.categories
62
+ if (allowedCategories && allowedCategories.length > 0) {
63
+ for (const [name, meta] of Object.entries(forgeNodes.meta) as [
64
+ string,
65
+ any,
66
+ ][]) {
67
+ if (!allowedCategories.includes(meta.category)) {
68
+ logger.critical(
69
+ ErrorCode.INVALID_VALUE,
70
+ `Forge node '${name}' has invalid category '${meta.category}'. ` +
71
+ `Allowed categories: ${allowedCategories.join(', ')}`
72
+ )
73
+ }
74
+ }
75
+ }
76
+
77
+ // Build the output metadata - remove per-node icon field
78
+ const outputMeta: Record<string, any> = {}
79
+ for (const [name, meta] of Object.entries(forgeNodes.meta) as [
80
+ string,
81
+ any,
82
+ ][]) {
83
+ // Remove icon from node meta - only package-level icon is used
84
+ const { icon: _icon, ...nodeMetaWithoutIcon } = meta
85
+ outputMeta[name] = nodeMetaWithoutIcon
86
+ }
87
+
88
+ // Load package-level icon
89
+ const packageIcon = await loadIcon(forge?.node?.icon, rootDir, logger)
90
+
91
+ const metaData = {
92
+ nodes: outputMeta,
93
+ credentials: forgeCredentials.meta,
94
+ package: {
95
+ displayName: forge?.node?.displayName,
96
+ description: forge?.node?.description,
97
+ icon: packageIcon,
98
+ categories: forge?.node?.categories,
99
+ },
100
+ }
101
+
102
+ if (forgeNodesMetaJsonFile) {
103
+ // Write minimal JSON (runtime-only fields)
104
+ const minimalMeta = stripVerboseFields(metaData)
105
+ await writeFileInDir(
106
+ logger,
107
+ forgeNodesMetaJsonFile,
108
+ JSON.stringify(minimalMeta, null, 2),
109
+ { ignoreModifyComment: true }
110
+ )
111
+
112
+ // Write verbose JSON only if it has additional fields
113
+ if (hasVerboseFields(metaData)) {
114
+ const verbosePath = forgeNodesMetaJsonFile.replace(
115
+ /\.gen\.json$/,
116
+ '-verbose.gen.json'
117
+ )
118
+ await writeFileInDir(
119
+ logger,
120
+ verbosePath,
121
+ JSON.stringify(metaData, null, 2),
122
+ { ignoreModifyComment: true }
123
+ )
124
+ }
125
+ }
126
+
127
+ return true
128
+ },
129
+ middleware: [
130
+ logCommandInfoAndTime({
131
+ commandStart: 'Generating Forge nodes metadata',
132
+ commandEnd: 'Generated Forge nodes metadata',
133
+ }),
134
+ ],
135
+ })
@@ -0,0 +1,38 @@
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
+
7
+ export const pikkuForgeTypes: any = pikkuSessionlessFunc<void, void>({
8
+ func: async ({ logger, config }) => {
9
+ const {
10
+ forgeTypesFile,
11
+ rpcInternalMapDeclarationFile,
12
+ packageMappings,
13
+ forge,
14
+ } = config
15
+
16
+ // Get the import path for the RPC map declaration file
17
+ // The declaration file ends in .d.ts, but we need to import from .js
18
+ // getFileImportRelativePath converts .ts -> .js, so .d.ts -> .d.js
19
+ // We need to remove the extra .d extension
20
+ let rpcMapImportPath = getFileImportRelativePath(
21
+ forgeTypesFile,
22
+ rpcInternalMapDeclarationFile,
23
+ packageMappings
24
+ )
25
+ // Fix: .d.ts files should be imported as .js (TypeScript resolves types from .d.ts)
26
+ rpcMapImportPath = rpcMapImportPath.replace('.d.js', '.js')
27
+
28
+ const categories = forge?.node?.categories
29
+ const content = serializeForgeTypes(rpcMapImportPath, categories)
30
+ await writeFileInDir(logger, forgeTypesFile, content)
31
+ },
32
+ middleware: [
33
+ logCommandInfoAndTime({
34
+ commandStart: 'Creating Forge types',
35
+ commandEnd: 'Created Forge types',
36
+ }),
37
+ ],
38
+ })
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Generates type definitions for Forge wirings with typed category and RPC validation
3
+ */
4
+ export const serializeForgeTypes = (
5
+ rpcMapImportPath: string,
6
+ categories: string[] | undefined
7
+ ) => {
8
+ // Generate category union type - 'never' if no categories configured
9
+ const categoryType = categories?.length
10
+ ? categories.map((c) => `'${c}'`).join(' | ')
11
+ : 'never'
12
+
13
+ return `/**
14
+ * Forge-specific type definitions for typed wireForgeNode and wireForgeCredential
15
+ */
16
+
17
+ import { wireForgeNode as wireForgeNodeCore, wireForgeCredential as wireForgeCredentialCore } from '@pikku/core/forge-node'
18
+ import type { CoreForgeNode, CoreForgeCredential } from '@pikku/core/forge-node'
19
+ import type { FlattenedRPCMap } from '${rpcMapImportPath}'
20
+
21
+ /**
22
+ * Valid category values for forge nodes.
23
+ * ${categories?.length ? `Configured categories: ${categories.join(', ')}` : 'No categories configured - wireForgeNode cannot be used until forge.node.categories is defined in pikku.config.json.'}
24
+ */
25
+ export type ForgeCategory = ${categoryType}
26
+
27
+ /**
28
+ * Valid RPC names that can be used with forge nodes.
29
+ * These are derived from the FlattenedRPCMap which includes both local and external package RPCs.
30
+ */
31
+ export type ForgeRPCName = keyof FlattenedRPCMap
32
+
33
+ /**
34
+ * Typed forge node configuration.
35
+ * Validates that category and rpc are valid values.
36
+ */
37
+ export type TypedForgeNode = Omit<CoreForgeNode, 'category' | 'rpc'> & {
38
+ /** Grouping category (validated against forge.node.categories in config) */
39
+ category: ForgeCategory
40
+ /** RPC name to call when node executes (must be a valid RPC name) */
41
+ rpc: ForgeRPCName
42
+ }
43
+
44
+ /**
45
+ * Registers a Forge node with validated category and RPC.
46
+ *
47
+ * @param config - Forge node configuration with typed category and rpc
48
+ *
49
+ * @example
50
+ * \`\`\`typescript
51
+ * wireForgeNode({
52
+ * name: 'send-email',
53
+ * displayName: 'Send Email',
54
+ * category: 'Communication', // Must be in forge.node.categories
55
+ * type: 'action',
56
+ * rpc: 'sendEmail', // Must be a valid RPC name
57
+ * description: 'Sends an email to a recipient'
58
+ * })
59
+ * \`\`\`
60
+ */
61
+ export const wireForgeNode = (config: TypedForgeNode): void => {
62
+ wireForgeNodeCore(config as CoreForgeNode)
63
+ }
64
+
65
+ /**
66
+ * Registers a Forge credential definition.
67
+ * Credentials define secrets/API keys required by the package.
68
+ *
69
+ * @template T - Zod schema type for the credential structure
70
+ * @param config - Forge credential configuration
71
+ *
72
+ * @example
73
+ * \`\`\`typescript
74
+ * import { z } from 'zod'
75
+ *
76
+ * const apiCredentials = z.object({
77
+ * apiKey: z.string().describe('API key for authentication'),
78
+ * apiSecret: z.string().describe('API secret')
79
+ * })
80
+ *
81
+ * wireForgeCredential({
82
+ * name: 'example-api',
83
+ * displayName: 'Example API Credentials',
84
+ * description: 'Credentials for the example external API',
85
+ * secretId: 'EXAMPLE_API_CREDENTIALS',
86
+ * schema: apiCredentials
87
+ * })
88
+ * \`\`\`
89
+ */
90
+ export const wireForgeCredential = <T>(config: CoreForgeCredential<T>): void => {
91
+ wireForgeCredentialCore(config)
92
+ }
93
+ `
94
+ }
@@ -18,18 +18,18 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
18
18
  // Check for required types
19
19
  checkRequiredTypes(visitState.filesAndMethodsErrors, {
20
20
  userSessionType: true,
21
- sessionServiceType: true,
21
+ wireServiceType: true,
22
22
  singletonServicesType: true,
23
23
  })
24
24
 
25
25
  const {
26
26
  userSessionType,
27
- sessionServicesType,
27
+ wireServicesType,
28
28
  singletonServicesType,
29
29
  pikkuConfigType,
30
30
  } = visitState.filesAndMethods
31
31
 
32
- if (!userSessionType || !sessionServicesType || !singletonServicesType) {
32
+ if (!userSessionType || !wireServicesType || !singletonServicesType) {
33
33
  throw new Error('Required types not found')
34
34
  }
35
35
 
@@ -42,11 +42,12 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
42
42
  userSessionType.type,
43
43
  `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`,
44
44
  singletonServicesType.type,
45
- `import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, sessionServicesType.typePath, packageMappings)}'`,
46
- sessionServicesType.type,
47
- `import type { TypedPikkuRPC } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`,
48
- `import type { RequiredSingletonServices, RequiredSessionServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`,
49
- configTypeImport
45
+ `import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`,
46
+ wireServicesType.type,
47
+ `import type { TypedPikkuRPC, FlattenedRPCMap } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`,
48
+ `import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`,
49
+ configTypeImport,
50
+ config.externalPackageName
50
51
  )
51
52
 
52
53
  await writeFileInDir(logger, functionTypesFile, content)
@@ -16,20 +16,27 @@ export const pikkuFunctionTypes: any = pikkuSessionlessFunc<void, void>({
16
16
  queueTypesFile,
17
17
  mcpTypesFile,
18
18
  cliTypesFile,
19
+ forgeTypesFile,
19
20
  } = config
20
21
 
22
+ const getImportPath = (file: string) =>
23
+ config.externalPackage
24
+ ? null
25
+ : getFileImportRelativePath(typesFile, file, packageMappings)
26
+
27
+ // Forge types are included for external packages (they need wireForgeNode/wireForgeCredential)
28
+ const getForgeImportPath = (file: string) =>
29
+ getFileImportRelativePath(typesFile, file, packageMappings)
30
+
21
31
  const content = serializePikkuTypesHub(
22
32
  getFileImportRelativePath(typesFile, functionTypesFile, packageMappings),
23
- getFileImportRelativePath(typesFile, httpTypesFile, packageMappings),
24
- getFileImportRelativePath(typesFile, channelsTypesFile, packageMappings),
25
- getFileImportRelativePath(
26
- typesFile,
27
- schedulersTypesFile,
28
- packageMappings
29
- ),
30
- getFileImportRelativePath(typesFile, queueTypesFile, packageMappings),
31
- getFileImportRelativePath(typesFile, mcpTypesFile, packageMappings),
32
- getFileImportRelativePath(typesFile, cliTypesFile, packageMappings)
33
+ getImportPath(httpTypesFile),
34
+ getImportPath(channelsTypesFile),
35
+ getImportPath(schedulersTypesFile),
36
+ getImportPath(queueTypesFile),
37
+ getImportPath(mcpTypesFile),
38
+ getImportPath(cliTypesFile),
39
+ getForgeImportPath(forgeTypesFile)
33
40
  )
34
41
 
35
42
  await writeFileInDir(logger, typesFile, content)
@@ -1,10 +1,12 @@
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 { serializeFunctionImports } from './serialize-function-imports.js'
5
+ import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
4
6
  import {
5
- generateRuntimeMeta,
6
- serializeFunctionImports,
7
- } from './serialize-function-imports.js'
7
+ stripVerboseFields,
8
+ hasVerboseFields,
9
+ } from '../../../utils/strip-verbose-meta.js'
8
10
 
9
11
  export const pikkuFunctions: any = pikkuSessionlessFunc<
10
12
  void,
@@ -14,41 +16,84 @@ export const pikkuFunctions: any = pikkuSessionlessFunc<
14
16
  const { functions, rpc } = await getInspectorState()
15
17
  const {
16
18
  functionsMetaFile,
17
- functionsMetaMinFile,
19
+ functionsMetaJsonFile,
18
20
  functionsFile,
19
21
  packageMappings,
22
+ schema,
20
23
  } = config
21
24
 
22
- // Generate full metadata
25
+ // Write minimal JSON (runtime-only fields)
26
+ const minimalMeta = stripVerboseFields(functions.meta)
23
27
  await writeFileInDir(
24
28
  logger,
29
+ functionsMetaJsonFile,
30
+ JSON.stringify(minimalMeta, null, 2)
31
+ )
32
+
33
+ // Write verbose JSON only if it has additional fields
34
+ if (hasVerboseFields(functions.meta)) {
35
+ const verbosePath = functionsMetaJsonFile.replace(
36
+ /\.gen\.json$/,
37
+ '-verbose.gen.json'
38
+ )
39
+ await writeFileInDir(
40
+ logger,
41
+ verbosePath,
42
+ JSON.stringify(functions.meta, null, 2)
43
+ )
44
+ }
45
+
46
+ const jsonImportPath = getFileImportRelativePath(
25
47
  functionsMetaFile,
26
- `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(functions.meta, null, 2)})`
48
+ functionsMetaJsonFile,
49
+ packageMappings
27
50
  )
28
51
 
29
- // Generate minimal metadata (runtime)
30
- const runtimeMeta = generateRuntimeMeta(functions.meta)
52
+ const supportsImportAttributes = schema?.supportsImportAttributes ?? false
53
+ const importStatement = supportsImportAttributes
54
+ ? `import metaData from '${jsonImportPath}' with { type: 'json' }`
55
+ : `import metaData from '${jsonImportPath}'`
56
+
57
+ const packageName = config.externalPackageName
58
+ ? `'${config.externalPackageName}'`
59
+ : 'null'
60
+
31
61
  await writeFileInDir(
32
62
  logger,
33
- functionsMetaMinFile,
34
- `import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta', ${JSON.stringify(runtimeMeta, null, 2)})`
63
+ functionsMetaFile,
64
+ `import { pikkuState, FunctionsMeta } from '@pikku/core'\n${importStatement}\npikkuState(${packageName}, 'function', 'meta', metaData as FunctionsMeta)`
35
65
  )
36
66
 
67
+ // For external packages, register ALL functions (they'll be invoked by consumers)
68
+ // For main packages, only register functions that are invoked via internal RPCs
69
+ const isExternalPackage = !!config.externalPackageName
37
70
  const hasRPCs = rpc.exposedFiles.size > 0 || rpc.internalFiles.size > 0
38
- if (hasRPCs) {
71
+ const hasFunctions = functions.files.size > 0
72
+
73
+ const shouldGenerateFunctionsFile = isExternalPackage
74
+ ? hasFunctions
75
+ : hasRPCs
76
+
77
+ if (shouldGenerateFunctionsFile) {
78
+ // For external packages, use all function files; for main packages, use internal RPC files
79
+ const filesToRegister = isExternalPackage
80
+ ? functions.files
81
+ : rpc.internalFiles
82
+
39
83
  await writeFileInDir(
40
84
  logger,
41
85
  functionsFile,
42
86
  serializeFunctionImports(
43
87
  functionsFile,
44
- rpc.internalFiles,
88
+ filesToRegister,
45
89
  functions.meta,
46
- packageMappings
90
+ packageMappings,
91
+ config.externalPackageName
47
92
  )
48
93
  )
49
94
  }
50
95
 
51
- return hasRPCs
96
+ return shouldGenerateFunctionsFile
52
97
  },
53
98
  middleware: [
54
99
  logCommandInfoAndTime({