@pikku/cli 0.9.16-next.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (266) hide show
  1. package/.pikku/channel/pikku-channel-types.gen.ts +28 -29
  2. package/.pikku/channel/pikku-channels-map.gen.d.ts +44 -0
  3. package/.pikku/channel/pikku-channels-meta.gen.ts +5 -0
  4. package/.pikku/channel/pikku-channels.gen.ts +4 -0
  5. package/.pikku/cli/pikku-cli-channel.gen.ts +34 -0
  6. package/.pikku/cli/pikku-cli-client.gen.ts +43 -0
  7. package/.pikku/cli/pikku-cli-types.gen.ts +14 -15
  8. package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +142 -2
  9. package/.pikku/cli/pikku-cli-wirings.gen.ts +4 -2
  10. package/.pikku/cli/pikku-cli.gen.ts +41 -0
  11. package/.pikku/function/pikku-function-types.gen.ts +167 -19
  12. package/.pikku/function/pikku-functions-meta.gen.ts +220 -192
  13. package/.pikku/function/pikku-functions-meta.min.gen.ts +61 -56
  14. package/.pikku/function/pikku-functions.gen.ts +3 -1
  15. package/.pikku/http/pikku-http-types.gen.ts +28 -3
  16. package/.pikku/http/pikku-http-wirings-map.gen.d.ts +43 -0
  17. package/.pikku/http/pikku-http-wirings-meta.gen.ts +13 -0
  18. package/.pikku/http/pikku-http-wirings.gen.ts +4 -0
  19. package/.pikku/mcp/pikku-mcp-types.gen.ts +15 -13
  20. package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +7 -0
  21. package/.pikku/mcp/pikku-mcp-wirings.gen.ts +4 -0
  22. package/.pikku/mcp/pikku-mcp.gen.json +5 -0
  23. package/.pikku/pikku-bootstrap.gen.ts +11 -1
  24. package/.pikku/pikku-services.gen.ts +1 -5
  25. package/.pikku/pikku-types.gen.ts +1 -2
  26. package/.pikku/pikku-websocket.gen.ts +76 -0
  27. package/.pikku/queue/pikku-queue-types.gen.ts +1 -2
  28. package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +57 -0
  29. package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +5 -0
  30. package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +4 -0
  31. package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +5 -4
  32. package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +19 -17
  33. package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +15 -14
  34. package/.pikku/scheduler/pikku-scheduler-types.gen.ts +1 -2
  35. package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +5 -0
  36. package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +4 -0
  37. package/.pikku/schemas/register.gen.ts +15 -11
  38. package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  39. package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
  40. package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
  41. package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
  42. package/CHANGELOG.md +6 -0
  43. package/bin/pikku.ts +63 -11
  44. package/build.sh +1 -1
  45. package/cli.schema.json +1 -1
  46. package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +11 -20
  47. package/dist/.pikku/channel/pikku-channel-types.gen.js +9 -11
  48. package/dist/.pikku/channel/pikku-channels-meta.gen.d.ts +1 -0
  49. package/dist/.pikku/channel/pikku-channels-meta.gen.js +5 -0
  50. package/dist/.pikku/channel/pikku-channels.gen.d.ts +4 -0
  51. package/dist/.pikku/channel/pikku-channels.gen.js +5 -0
  52. package/dist/.pikku/cli/pikku-cli-channel.gen.d.ts +1 -0
  53. package/dist/.pikku/cli/pikku-cli-channel.gen.js +33 -0
  54. package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +10 -0
  55. package/dist/.pikku/cli/pikku-cli-client.gen.js +34 -0
  56. package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +9 -12
  57. package/dist/.pikku/cli/pikku-cli-types.gen.js +5 -4
  58. package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +142 -2
  59. package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +3 -2
  60. package/dist/.pikku/cli/pikku-cli-wirings.gen.js +4 -3
  61. package/dist/.pikku/cli/pikku-cli.gen.d.ts +10 -0
  62. package/dist/.pikku/cli/pikku-cli.gen.js +38 -0
  63. package/dist/.pikku/function/pikku-function-types.gen.d.ts +141 -20
  64. package/dist/.pikku/function/pikku-function-types.gen.js +108 -12
  65. package/dist/.pikku/function/pikku-functions-meta.gen.js +220 -192
  66. package/dist/.pikku/function/pikku-functions-meta.min.gen.js +61 -56
  67. package/dist/.pikku/function/pikku-functions.gen.js +3 -1
  68. package/dist/.pikku/http/pikku-http-types.gen.d.ts +21 -2
  69. package/dist/.pikku/http/pikku-http-types.gen.js +24 -3
  70. package/dist/.pikku/http/pikku-http-wirings-meta.gen.d.ts +1 -0
  71. package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +13 -0
  72. package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +4 -0
  73. package/dist/.pikku/http/pikku-http-wirings.gen.js +5 -0
  74. package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +11 -8
  75. package/dist/.pikku/mcp/pikku-mcp-types.gen.js +6 -6
  76. package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.d.ts +1 -0
  77. package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +7 -0
  78. package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +4 -0
  79. package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +5 -0
  80. package/dist/.pikku/pikku-bootstrap.gen.d.ts +11 -1
  81. package/dist/.pikku/pikku-bootstrap.gen.js +11 -1
  82. package/dist/.pikku/pikku-services.gen.d.ts +1 -4
  83. package/dist/.pikku/pikku-services.gen.js +0 -6
  84. package/dist/.pikku/pikku-types.gen.d.ts +1 -2
  85. package/dist/.pikku/pikku-types.gen.js +1 -2
  86. package/dist/.pikku/pikku-websocket.gen.d.ts +31 -0
  87. package/dist/.pikku/pikku-websocket.gen.js +49 -0
  88. package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -2
  89. package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -2
  90. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.d.ts +1 -0
  91. package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +5 -0
  92. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +4 -0
  93. package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +5 -0
  94. package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +15 -14
  95. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -2
  96. package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -2
  97. package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.d.ts +1 -0
  98. package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +5 -0
  99. package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +4 -0
  100. package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +5 -0
  101. package/dist/.pikku/schemas/register.gen.js +9 -7
  102. package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
  103. package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
  104. package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
  105. package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
  106. package/dist/bin/pikku.d.ts +1 -1
  107. package/dist/bin/pikku.js +37 -6
  108. package/dist/src/cli.wiring.js +99 -75
  109. package/dist/src/functions/commands/all.js +10 -0
  110. package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +10 -8
  111. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -1
  112. package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +2 -2
  113. package/dist/src/functions/wirings/channels/pikku-channels.js +0 -5
  114. package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +0 -2
  115. package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +0 -5
  116. package/dist/src/functions/wirings/channels/pikku-command-channels.js +0 -5
  117. package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.js +6 -3
  118. package/dist/src/functions/wirings/channels/serialize-channel-types.js +27 -28
  119. package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +4 -1
  120. package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +31 -8
  121. package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +0 -2
  122. package/dist/src/functions/wirings/cli/pikku-command-cli.js +0 -2
  123. package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +6 -2
  124. package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +88 -11
  125. package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +1 -1
  126. package/dist/src/functions/wirings/cli/serialize-channel-cli.js +1 -18
  127. package/dist/src/functions/wirings/cli/serialize-cli-types.js +13 -14
  128. package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +19 -14
  129. package/dist/src/functions/wirings/fetch/index.js +6 -3
  130. package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +6 -5
  131. package/dist/src/functions/wirings/functions/pikku-command-function-types.js +0 -2
  132. package/dist/src/functions/wirings/functions/pikku-command-functions.js +0 -2
  133. package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
  134. package/dist/src/functions/wirings/functions/pikku-command-services.js +11 -21
  135. package/dist/src/functions/wirings/functions/pikku-function-types.js +0 -2
  136. package/dist/src/functions/wirings/functions/schemas.js +0 -2
  137. package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +1 -1
  138. package/dist/src/functions/wirings/functions/serialize-function-types.js +167 -19
  139. package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +0 -1
  140. package/dist/src/functions/wirings/http/openapi-spec-generator.d.ts +2 -1
  141. package/dist/src/functions/wirings/http/pikku-command-http-map.js +0 -5
  142. package/dist/src/functions/wirings/http/pikku-command-http-routes.js +0 -5
  143. package/dist/src/functions/wirings/http/pikku-command-http-types.js +0 -2
  144. package/dist/src/functions/wirings/http/pikku-command-openapi.js +7 -4
  145. package/dist/src/functions/wirings/http/pikku-http-routes.js +0 -5
  146. package/dist/src/functions/wirings/http/serialize-http-types.js +27 -2
  147. package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +0 -5
  148. package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.js +0 -2
  149. package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +0 -5
  150. package/dist/src/functions/wirings/mcp/serialize-mcp-json.d.ts +1 -1
  151. package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +14 -12
  152. package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +0 -2
  153. package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +1 -7
  154. package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -0
  155. package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +28 -0
  156. package/dist/src/functions/wirings/permissions/serialize-permissions-imports.d.ts +2 -0
  157. package/dist/src/functions/wirings/permissions/serialize-permissions-imports.js +43 -0
  158. package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +0 -5
  159. package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +6 -3
  160. package/dist/src/functions/wirings/queue/pikku-command-queue-types.js +0 -2
  161. package/dist/src/functions/wirings/queue/pikku-command-queue.js +0 -5
  162. package/dist/src/functions/wirings/queue/pikku-queue-map.js +0 -5
  163. package/dist/src/functions/wirings/queue/pikku-queue.js +1 -5
  164. package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +1 -1
  165. package/dist/src/functions/wirings/queue/serialize-queue-types.js +0 -1
  166. package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +5 -3
  167. package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +0 -4
  168. package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +0 -2
  169. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.js +0 -2
  170. package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +0 -5
  171. package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +0 -1
  172. package/dist/src/middleware/log-command-info-and-time.d.ts +2 -8
  173. package/dist/src/middleware/log-command-info-and-time.js +2 -14
  174. package/dist/src/services/cli-logger-forwarder.service.d.ts +6 -2
  175. package/dist/src/services/cli-logger-forwarder.service.js +9 -0
  176. package/dist/src/services/cli-logger.service.d.ts +4 -0
  177. package/dist/src/services/cli-logger.service.js +11 -0
  178. package/dist/src/services.d.ts +5 -0
  179. package/dist/src/services.js +111 -13
  180. package/dist/src/utils/custom-types-generator.js +8 -2
  181. package/dist/src/utils/file-writer.d.ts +4 -1
  182. package/dist/src/utils/file-writer.js +13 -3
  183. package/dist/src/utils/get-cli-version.d.ts +5 -0
  184. package/dist/src/utils/get-cli-version.js +27 -0
  185. package/dist/src/utils/pikku-cli-config.d.ts +1 -2
  186. package/dist/src/utils/pikku-cli-config.js +9 -28
  187. package/dist/src/utils/schema-generator.js +3 -2
  188. package/dist/src/utils/serialize-import-map.js +0 -3
  189. package/dist/tsconfig.tsbuildinfo +1 -1
  190. package/package.json +10 -8
  191. package/pikku.config.json +4 -2
  192. package/src/cli.wiring.ts +101 -74
  193. package/src/functions/commands/all.ts +12 -0
  194. package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +12 -12
  195. package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +2 -2
  196. package/src/functions/wirings/channels/pikku-channels.ts +0 -5
  197. package/src/functions/wirings/channels/pikku-command-channel-types.ts +0 -2
  198. package/src/functions/wirings/channels/pikku-command-channels-map.ts +0 -5
  199. package/src/functions/wirings/channels/pikku-command-channels.ts +0 -5
  200. package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +7 -3
  201. package/src/functions/wirings/channels/serialize-channel-types.ts +27 -28
  202. package/src/functions/wirings/channels/serialize-typed-channel-map.ts +4 -1
  203. package/src/functions/wirings/cli/pikku-command-cli-entry.ts +52 -9
  204. package/src/functions/wirings/cli/pikku-command-cli-types.ts +0 -2
  205. package/src/functions/wirings/cli/pikku-command-cli.ts +0 -2
  206. package/src/functions/wirings/cli/serialize-channel-cli-client.ts +111 -12
  207. package/src/functions/wirings/cli/serialize-channel-cli.ts +2 -23
  208. package/src/functions/wirings/cli/serialize-cli-types.ts +13 -14
  209. package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +19 -14
  210. package/src/functions/wirings/fetch/index.ts +7 -3
  211. package/src/functions/wirings/functions/pikku-command-function-types-split.ts +14 -5
  212. package/src/functions/wirings/functions/pikku-command-function-types.ts +0 -2
  213. package/src/functions/wirings/functions/pikku-command-functions.ts +0 -2
  214. package/src/functions/wirings/functions/pikku-command-services.ts +13 -24
  215. package/src/functions/wirings/functions/pikku-function-types.ts +0 -2
  216. package/src/functions/wirings/functions/schemas.ts +0 -2
  217. package/src/functions/wirings/functions/serialize-function-types.ts +169 -19
  218. package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +0 -1
  219. package/src/functions/wirings/http/openapi-spec-generator.ts +2 -1
  220. package/src/functions/wirings/http/pikku-command-http-map.ts +0 -5
  221. package/src/functions/wirings/http/pikku-command-http-routes.ts +0 -5
  222. package/src/functions/wirings/http/pikku-command-http-types.ts +0 -2
  223. package/src/functions/wirings/http/pikku-command-openapi.ts +9 -4
  224. package/src/functions/wirings/http/pikku-http-routes.ts +0 -5
  225. package/src/functions/wirings/http/serialize-http-types.ts +27 -2
  226. package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +0 -5
  227. package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +0 -2
  228. package/src/functions/wirings/mcp/pikku-command-mcp.ts +0 -5
  229. package/src/functions/wirings/mcp/serialize-mcp-json.ts +1 -1
  230. package/src/functions/wirings/mcp/serialize-mcp-types.ts +14 -12
  231. package/src/functions/wirings/middleware/pikku-command-middleware.ts +0 -2
  232. package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +1 -7
  233. package/src/functions/wirings/permissions/pikku-command-permissions.ts +49 -0
  234. package/src/functions/wirings/permissions/serialize-permissions-imports.test.ts +274 -0
  235. package/src/functions/wirings/permissions/serialize-permissions-imports.ts +78 -0
  236. package/src/functions/wirings/queue/pikku-command-queue-map.ts +0 -5
  237. package/src/functions/wirings/queue/pikku-command-queue-service.ts +7 -3
  238. package/src/functions/wirings/queue/pikku-command-queue-types.ts +0 -2
  239. package/src/functions/wirings/queue/pikku-command-queue.ts +0 -5
  240. package/src/functions/wirings/queue/pikku-queue-map.ts +0 -5
  241. package/src/functions/wirings/queue/pikku-queue.ts +3 -6
  242. package/src/functions/wirings/queue/serialize-queue-meta.ts +1 -1
  243. package/src/functions/wirings/queue/serialize-queue-types.ts +0 -1
  244. package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +6 -3
  245. package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +0 -4
  246. package/src/functions/wirings/rpc/pikku-command-rpc.ts +0 -2
  247. package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +0 -2
  248. package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +0 -5
  249. package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +0 -1
  250. package/src/middleware/log-command-info-and-time.ts +2 -28
  251. package/src/services/cli-logger-forwarder.service.ts +15 -2
  252. package/src/services/cli-logger.service.ts +15 -0
  253. package/src/services.ts +148 -19
  254. package/src/utils/custom-types-generator.ts +8 -2
  255. package/src/utils/file-writer.ts +19 -3
  256. package/src/utils/get-cli-version.ts +28 -0
  257. package/src/utils/pikku-cli-config.ts +6 -35
  258. package/src/utils/schema-generator.ts +7 -3
  259. package/src/utils/serialize-import-map.ts +0 -4
  260. package/types/application-types.d.ts +4 -1
  261. package/types/config.d.ts +15 -3
  262. package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.d.ts +0 -6
  263. package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.js +0 -6
  264. package/dist/src/serialize-pikku-types.d.ts +0 -4
  265. package/dist/src/serialize-pikku-types.js +0 -605
  266. package/src/serialize-pikku-types.ts +0 -613
@@ -3,14 +3,14 @@
3
3
  */
4
4
  export const serializeChannelTypes = (functionTypesImportPath: string) => {
5
5
  return `/**
6
- * This file was generated by the @pikku/cli
6
+
7
7
  * Channel-specific type definitions for tree-shaking optimization
8
8
  */
9
9
 
10
10
  import { CoreChannel, wireChannel as wireChannelCore } from '@pikku/core/channel'
11
11
  import { CorePikkuFunctionConfig } from '@pikku/core'
12
12
  import { AssertHTTPWiringParams } from '@pikku/core/http'
13
- import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
13
+ import type { PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
14
14
 
15
15
  /**
16
16
  * Type definition for WebSocket channels with typed data exchange.
@@ -19,64 +19,63 @@ import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMid
19
19
  * @template ChannelData - Type of data exchanged through the channel
20
20
  * @template Channel - String literal type for the channel name
21
21
  */
22
- type ChannelWiringFunction<I, O, C = {}> = PikkuFunctionSessionless<I, O, C> | PikkuFunction<I, O, C>
23
- type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<ChannelData, Channel, ChannelWiringFunction<void, unknown> | ChannelWiringFunction<void, unknown, ChannelData>, ChannelWiringFunction<void, void> | ChannelWiringFunction<void, void, ChannelData>, ChannelWiringFunction<any, any> | ChannelWiringFunction<any, any, ChannelData>, PikkuPermission, PikkuMiddleware>
22
+ type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<
23
+ ChannelData,
24
+ Channel,
25
+ CorePikkuFunctionConfig<PikkuFunctionSessionless<void, any, ChannelData>, PikkuPermission<void>, PikkuMiddleware>,
26
+ CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void, ChannelData>, PikkuPermission<void>, PikkuMiddleware>,
27
+ CorePikkuFunctionConfig<PikkuFunctionSessionless<any, any, ChannelData>, PikkuPermission<any>, PikkuMiddleware>,
28
+ PikkuPermission,
29
+ PikkuMiddleware
30
+ >
24
31
 
25
32
  /**
26
33
  * Creates a function that handles WebSocket channel connections.
27
34
  * Called when a client connects to a channel.
28
35
  *
29
36
  * @template Out - Output type for connection response
30
- * @template ChannelData - Type of data associated with the channel
31
37
  * @param func - Function definition, either direct function or configuration object
32
- * @returns The unwrapped function for internal use
38
+ * @returns The normalized configuration object
33
39
  */
34
- export const pikkuChannelConnectionFunc = <Out = unknown, ChannelData = unknown>(
40
+ export const pikkuChannelConnectionFunc = <Out = unknown>(
35
41
  func:
36
- | PikkuFunctionSessionless<void, Out, ChannelData>
37
- | {
38
- func: PikkuFunctionSessionless<void, Out, ChannelData>
39
- name?: string
40
- }
42
+ | PikkuFunctionSessionless<void, Out, unknown>
43
+ | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, Out, unknown>, PikkuPermission<void>, PikkuMiddleware>
41
44
  ) => {
42
- return typeof func === 'function' ? func : func.func
45
+ return typeof func === 'function' ? { func } : func
43
46
  }
44
47
 
45
48
  /**
46
49
  * Creates a function that handles WebSocket channel disconnections.
47
50
  * Called when a client disconnects from a channel.
48
51
  *
49
- * @template ChannelData - Type of data associated with the channel
50
52
  * @param func - Function definition, either direct function or configuration object
51
- * @returns The unwrapped function for internal use
53
+ * @returns The normalized configuration object
52
54
  */
53
- export const pikkuChannelDisconnectionFunc = <ChannelData = unknown>(
55
+ export const pikkuChannelDisconnectionFunc = (
54
56
  func:
55
- | PikkuFunctionSessionless<void, void, ChannelData>
56
- | {
57
- func: PikkuFunction<void, void, ChannelData>
58
- name?: string
59
- }
57
+ | PikkuFunctionSessionless<void, void, unknown>
58
+ | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void, unknown>, PikkuPermission<void>, PikkuMiddleware>
60
59
  ) => {
61
- return typeof func === 'function' ? func : func.func
60
+ return typeof func === 'function' ? { func } : func
62
61
  }
63
62
 
64
63
  /**
65
64
  * Creates a function that handles WebSocket channel messages.
66
65
  * Called when a message is received on a channel.
66
+ * This is the same as pikkuSessionlessFunc but with ChannelData = unknown by default.
67
67
  *
68
68
  * @template In - Input type for channel messages
69
69
  * @template Out - Output type for channel responses
70
- * @template ChannelData - Type of data associated with the channel
71
70
  * @param func - Function definition, either direct function or configuration object
72
- * @returns The unwrapped function for internal use
71
+ * @returns The normalized configuration object
73
72
  */
74
- export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unknown>(
73
+ export const pikkuChannelFunc = <In, Out = unknown>(
75
74
  func:
76
- | PikkuFunctionSessionless<In, Out, ChannelData>
77
- | CorePikkuFunctionConfig<PikkuFunction<In, Out, ChannelData>, PikkuPermission<In>>
75
+ | PikkuFunctionSessionless<In, Out, unknown>
76
+ | CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out, unknown>, PikkuPermission<In>, PikkuMiddleware>
78
77
  ) => {
79
- return typeof func === 'function' ? func : func.func
78
+ return typeof func === 'function' ? { func } : func
80
79
  }
81
80
 
82
81
  /**
@@ -17,7 +17,10 @@ export const serializeTypedChannelsMap = (
17
17
  )
18
18
  typesMap.customTypes.forEach(({ references }) => {
19
19
  for (const reference of references) {
20
- requiredTypes.add(reference)
20
+ // Skip __object types (placeholder types for invalid/broken functions)
21
+ if (reference !== '__object' && !reference.startsWith('__object_')) {
22
+ requiredTypes.add(reference)
23
+ }
21
24
  }
22
25
  })
23
26
  const imports = serializeImportMap(
@@ -5,7 +5,13 @@ import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-
5
5
  import { join } from 'node:path'
6
6
  import { serializeLocalCLIBootstrap } from './serialize-local-cli-bootstrap.js'
7
7
  import { serializeChannelCLI } from './serialize-channel-cli.js'
8
- import { serializeChannelCLIClient } from './serialize-channel-cli-client.js'
8
+ import {
9
+ serializeChannelCLIClient,
10
+ collectRendererNames,
11
+ } from './serialize-channel-cli-client.js'
12
+ import { existsSync } from 'fs'
13
+ import { rm } from 'fs/promises'
14
+ import { ErrorCode } from '@pikku/inspector'
9
15
 
10
16
  export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
11
17
  func: async ({ logger, config, getInspectorState }) => {
@@ -28,7 +34,7 @@ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
28
34
  for (const [programName, entrypointConfigs] of Object.entries(
29
35
  config.cli.entrypoints
30
36
  )) {
31
- const programMeta = visitState.cli.meta[programName]
37
+ const programMeta = visitState.cli.meta.programs[programName]
32
38
 
33
39
  if (!programMeta) {
34
40
  logger.warn(
@@ -86,13 +92,55 @@ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
86
92
  if (channelClientPath) {
87
93
  const channelClientFile = join(config.rootDir, channelClientPath)
88
94
 
95
+ // Validate that renderers don't depend on services (client-side renderers can't access server services)
96
+ const rendererNames = collectRendererNames(programMeta)
97
+ const problematicRenderers: Array<{
98
+ name: string
99
+ services: string[]
100
+ }> = []
101
+
102
+ for (const rendererName of rendererNames) {
103
+ const rendererMeta = visitState.cli.meta.renderers[rendererName]
104
+ if (rendererMeta?.services?.services?.length > 0) {
105
+ problematicRenderers.push({
106
+ name: rendererName,
107
+ services: rendererMeta.services.services,
108
+ })
109
+ }
110
+ }
111
+
112
+ // If any renderers depend on services, abort client generation
113
+ if (problematicRenderers.length > 0) {
114
+ const details = problematicRenderers
115
+ .map(
116
+ (r) => ` - ${r.name} depends on: ${r.services.join(', ')}`
117
+ )
118
+ .join('\n')
119
+
120
+ logger.critical(
121
+ ErrorCode.CLI_CLIENTSIDE_RENDERER_HAS_SERVICES,
122
+ `Cannot generate CLI channel client for '${programName}': renderers cannot depend on services (client-side execution)\n${details}\n\nRenderers used in CLI-over-channel must be service-free since they execute on the client.`
123
+ )
124
+
125
+ // Delete existing client file if it exists
126
+ if (existsSync(channelClientFile)) {
127
+ await rm(channelClientFile)
128
+ logger.debug(
129
+ `Deleted existing CLI channel client: ${channelClientFile}`
130
+ )
131
+ }
132
+
133
+ continue
134
+ }
135
+
89
136
  const clientCode = serializeChannelCLIClient(
90
137
  programName,
91
138
  programMeta,
92
139
  channelClientFile,
93
140
  config,
94
- config.bootstrapFiles.cli,
95
- channelRoute
141
+ config.bootstrapFile,
142
+ channelRoute,
143
+ visitState.cli.meta.renderers
96
144
  )
97
145
 
98
146
  await writeFileInDir(logger, channelClientFile, clientCode)
@@ -163,11 +211,6 @@ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
163
211
  logCommandInfoAndTime({
164
212
  commandStart: 'Serializing CLI',
165
213
  commandEnd: 'Serialized CLI',
166
- skipCondition: async ({ getInspectorState }) => {
167
- const visitState = await getInspectorState()
168
- return visitState.cli.files.size === 0
169
- },
170
- skipMessage: 'none found',
171
214
  }),
172
215
  ],
173
216
  })
@@ -43,8 +43,6 @@ export const pikkuCLITypes: any = pikkuSessionlessFunc<void, void>({
43
43
  logCommandInfoAndTime({
44
44
  commandStart: 'Creating CLI types',
45
45
  commandEnd: 'Created CLI types',
46
- skipCondition: false,
47
- skipMessage: '',
48
46
  }),
49
47
  ],
50
48
  })
@@ -34,8 +34,6 @@ export const pikkuCLI: any = pikkuSessionlessFunc<void, boolean | undefined>({
34
34
  logCommandInfoAndTime({
35
35
  commandStart: 'Finding CLI commands',
36
36
  commandEnd: 'Found CLI commands',
37
- skipCondition: false,
38
- skipMessage: 'none found',
39
37
  }),
40
38
  ],
41
39
  })
@@ -1,7 +1,73 @@
1
- import { CLIProgramMeta } from '@pikku/core'
1
+ import { CLIProgramMeta, CLICommandMeta } from '@pikku/core/cli'
2
2
  import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
3
3
  import { Config } from '../../../../types/application-types.js'
4
4
 
5
+ /**
6
+ * Collect all unique renderer names from CLI metadata (populated by inspector)
7
+ */
8
+ export function collectRendererNames(programMeta: CLIProgramMeta): Set<string> {
9
+ const rendererNames = new Set<string>()
10
+
11
+ // Add program-level default renderer
12
+ if (programMeta.defaultRenderName) {
13
+ rendererNames.add(programMeta.defaultRenderName)
14
+ }
15
+
16
+ // Recursively collect renderer names from commands
17
+ function collectFromCommand(command: CLICommandMeta): void {
18
+ if (command.renderName) {
19
+ rendererNames.add(command.renderName)
20
+ }
21
+
22
+ // Recursively process subcommands
23
+ if (command.subcommands) {
24
+ for (const subCommand of Object.values(command.subcommands)) {
25
+ collectFromCommand(subCommand)
26
+ }
27
+ }
28
+ }
29
+
30
+ // Process all commands
31
+ for (const command of Object.values(programMeta.commands)) {
32
+ collectFromCommand(command)
33
+ }
34
+
35
+ return rendererNames
36
+ }
37
+
38
+ /**
39
+ * Build a renderers map for CLI commands
40
+ */
41
+ function buildRenderersMap(programMeta: CLIProgramMeta): string {
42
+ const entries: string[] = []
43
+
44
+ // Build map entries for each command that has a renderer
45
+ function addCommandRenderer(command: CLICommandMeta, path: string[]): void {
46
+ const commandId = path.join('.')
47
+ if (command.renderName) {
48
+ entries.push(` '${commandId}': ${command.renderName}`)
49
+ }
50
+
51
+ // Recursively process subcommands
52
+ if (command.subcommands) {
53
+ for (const [subName, subCommand] of Object.entries(command.subcommands)) {
54
+ addCommandRenderer(subCommand, [...path, subName])
55
+ }
56
+ }
57
+ }
58
+
59
+ // Process all commands
60
+ for (const [commandName, command] of Object.entries(programMeta.commands)) {
61
+ addCommandRenderer(command, [commandName])
62
+ }
63
+
64
+ if (entries.length === 0) {
65
+ return '{}'
66
+ }
67
+
68
+ return `{\n${entries.join(',\n')}\n }`
69
+ }
70
+
5
71
  /**
6
72
  * Serializes a CLI-over-Channel client bootstrap file
7
73
  * Similar to local CLI bootstrap but uses WebSocket connection
@@ -12,7 +78,8 @@ export function serializeChannelCLIClient(
12
78
  clientFile: string,
13
79
  config: Config,
14
80
  cliBootstrapPath: string,
15
- channelRoute?: string
81
+ channelRoute?: string,
82
+ renderersMeta?: Record<string, any>
16
83
  ): string {
17
84
  const capitalizedName =
18
85
  programName.charAt(0).toUpperCase() + programName.slice(1).replace(/-/g, '')
@@ -25,16 +92,48 @@ export function serializeChannelCLIClient(
25
92
  config.packageMappings
26
93
  )
27
94
 
28
- // TODO: Collect renderer imports and create renderers map
29
- // For now, renderers are not implemented
95
+ // Collect all unique renderer names from CLI metadata (populated by inspector)
96
+ const rendererNames = collectRendererNames(programMeta)
30
97
 
31
- return `/**
32
- * This file was generated by the @pikku/cli
33
- */
98
+ // Generate renderer imports from their source files
99
+ let rendererImports = ''
100
+ if (rendererNames.size > 0 && renderersMeta) {
101
+ const importsByFile = new Map<string, string[]>()
102
+
103
+ for (const rendererName of rendererNames) {
104
+ const meta = renderersMeta[rendererName]
105
+ if (meta?.exportedName && meta?.filePath) {
106
+ const relativePath = getFileImportRelativePath(
107
+ clientFile,
108
+ meta.filePath,
109
+ config.packageMappings
110
+ )
111
+ if (!importsByFile.has(relativePath)) {
112
+ importsByFile.set(relativePath, [])
113
+ }
114
+ importsByFile.get(relativePath)!.push(meta.exportedName)
115
+ }
116
+ }
117
+
118
+ // Generate import statements
119
+ for (const [path, names] of importsByFile) {
120
+ rendererImports += `import { ${names.join(', ')} } from '${path}'\n`
121
+ }
122
+ }
123
+
124
+ // Build renderers map
125
+ const renderersMap = buildRenderersMap(programMeta)
126
+
127
+ // Determine default renderer
128
+ const defaultRendererCode = programMeta.defaultRenderName
129
+ ? `,\n defaultRenderer: ${programMeta.defaultRenderName}`
130
+ : ''
131
+
132
+ return `
34
133
  import { executeCLIViaChannel } from '@pikku/core/cli/channel'
35
134
  import { CorePikkuWebsocket } from '@pikku/websocket'
36
135
  import '${bootstrapImportPath}'
37
-
136
+ ${rendererImports}
38
137
  /**
39
138
  * ${capitalizedName} CLI Client (via WebSocket Channel)
40
139
  * Executes CLI commands over a WebSocket connection
@@ -46,14 +145,14 @@ export async function ${capitalizedName}CLIClient(
46
145
  // Create WebSocket connection
47
146
  const pikkuWS = new CorePikkuWebsocket(url)
48
147
 
49
- // TODO: Import and register renderers when renderer tracking is implemented
50
- const renderers = {}
148
+ // Register renderers for CLI commands
149
+ const renderers = ${renderersMap}
51
150
 
52
151
  await executeCLIViaChannel({
53
152
  programName: '${programName}',
54
153
  pikkuWS,
55
154
  args,
56
- renderers,
155
+ renderers${defaultRendererCode},
57
156
  })
58
157
  }
59
158
 
@@ -63,7 +162,7 @@ export default ${capitalizedName}CLIClient
63
162
  // For direct execution (if this file is run directly)
64
163
  if (import.meta.url === \`file://\${process.argv[1]}\`) {
65
164
  const url = process.env.PIKKU_WS_URL || 'ws://localhost:3000${finalChannelRoute}'
66
- ${capitalizedName}CLIClient(url).catch(error => {
165
+ ${capitalizedName}CLIClient(url, process.argv.slice(2)).catch(error => {
67
166
  console.error('Fatal error:', error.message)
68
167
  process.exit(1)
69
168
  })
@@ -1,4 +1,4 @@
1
- import { CLIProgramMeta } from '@pikku/core'
1
+ import { CLIProgramMeta } from '@pikku/core/cli'
2
2
  import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
3
3
 
4
4
  /**
@@ -74,44 +74,23 @@ export function serializeChannelCLI(
74
74
  })
75
75
  .join('\n')
76
76
 
77
- // Get relative paths to type files
77
+ // Get relative path to channel types file
78
78
  const channelTypesPath = getFileImportRelativePath(
79
79
  channelFile,
80
80
  channelTypesFile,
81
81
  packageMappings
82
82
  )
83
- const functionTypesPath = getFileImportRelativePath(
84
- channelFile,
85
- functionTypesFile,
86
- packageMappings
87
- )
88
83
 
89
84
  return `/**
90
- * This file was generated by the @pikku/cli
91
85
  * WebSocket channel backend for '${programName}' CLI commands
92
86
  */
93
87
  import { wireChannel } from '${channelTypesPath}'
94
- import { PikkuMiddleware } from '${functionTypesPath}'
95
88
  ${imports}
96
89
 
97
- // Middleware to close channel after command execution
98
- const closeAfterExecution: PikkuMiddleware = async (_services, interaction, next) => {
99
- try {
100
- const result = await next()
101
- return result
102
- } finally {
103
- // Close the channel after function completes
104
- if (interaction.channel) {
105
- await interaction.channel.close()
106
- }
107
- }
108
- }
109
-
110
90
  wireChannel({
111
91
  name: '${finalChannelName}',
112
92
  route: '${finalChannelRoute}',
113
93
  auth: false,
114
- middleware: [closeAfterExecution],
115
94
  onMessageWiring: {
116
95
  command: {
117
96
  ${commandEntries}
@@ -9,11 +9,11 @@ export const serializeCLITypes = (
9
9
  singletonServicesTypeName: string
10
10
  ) => {
11
11
  return `/**
12
- * This file was generated by the @pikku/cli
12
+
13
13
  * CLI-specific type definitions for tree-shaking optimization
14
14
  */
15
15
 
16
- import { CoreCLI, wireCLI as wireCLICore, CorePikkuCLIRender, CoreCLICommandConfig } from '@pikku/core'
16
+ import { CoreCLI, wireCLI as wireCLICore, CorePikkuCLIRender, CoreCLICommandConfig } from '@pikku/core/cli'
17
17
  import type { PikkuFunctionConfig, PikkuMiddleware } from '${functionTypesImportPath}'
18
18
  ${userSessionTypeImport}
19
19
  ${singletonServicesTypeImport}
@@ -34,12 +34,7 @@ type PikkuCLIRender<Data, RequiredServices extends SingletonServices = Singleton
34
34
  * CLI command configuration with project-specific types.
35
35
  * Uses CoreCLICommandConfig from @pikku/core with local middleware and render types.
36
36
  */
37
- type CLICommandConfig<Func extends PikkuFunctionConfig<any, any>> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>>
38
-
39
- /**
40
- * Result type for CLI command configuration
41
- */
42
- type CLICommandResult<Func extends PikkuFunctionConfig<any, any>> = CLICommandConfig<Func>
37
+ type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
43
38
 
44
39
  /**
45
40
  * Type definition for CLI applications with commands and global options.
@@ -47,7 +42,7 @@ type CLICommandResult<Func extends PikkuFunctionConfig<any, any>> = CLICommandCo
47
42
  * @template Commands - Type describing the command structure
48
43
  * @template GlobalOptions - Type for global CLI options
49
44
  */
50
- type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>>>, GlobalOptions> = CoreCLI<Commands, GlobalOptions, PikkuMiddleware, PikkuCLIRender<any>>
45
+ type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>, any>>, GlobalOptions> = CoreCLI<Commands, GlobalOptions, PikkuMiddleware, PikkuCLIRender<any>>
51
46
 
52
47
  /**
53
48
  * Registers a CLI application with the Pikku framework.
@@ -57,7 +52,7 @@ type CLIWiring<Commands extends Record<string, CoreCLICommandConfig<any, PikkuMi
57
52
  * @template GlobalOptions - Type for global CLI options
58
53
  * @param cli - CLI definition with program name, commands, and global options
59
54
  */
60
- export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>>>, GlobalOptions>(
55
+ export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any, PikkuMiddleware, PikkuCLIRender<any>, any>>, GlobalOptions>(
61
56
  cli: CLIWiring<Commands, GlobalOptions>
62
57
  ) => {
63
58
  wireCLICore(cli as any)
@@ -67,13 +62,17 @@ export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any
67
62
  * Creates a CLI command definition with automatic option inference from the function's input type.
68
63
  * This allows TypeScript to automatically derive CLI options from the function signature.
69
64
  *
70
- * @template Func - The Pikku function config type to create a CLI command for
65
+ * @template FuncConfig - The Pikku function config type
66
+ * @template Params - The parameters string literal type
71
67
  * @param config - CLI command configuration
72
68
  * @returns CLI command configuration with inferred types
73
69
  */
74
- export const pikkuCLICommand = <Func extends PikkuFunctionConfig<any, any>>(
75
- config: CLICommandConfig<Func>
76
- ): CLICommandResult<Func> => {
70
+ export const pikkuCLICommand = <
71
+ FuncConfig extends PikkuFunctionConfig<any, any>,
72
+ Params extends string
73
+ >(
74
+ config: CLICommandConfig<FuncConfig, any, any, Params>
75
+ ): CoreCLICommandConfig<FuncConfig, PikkuMiddleware, PikkuCLIRender<any>, string> => {
77
76
  return config as any
78
77
  }
79
78
  `
@@ -34,14 +34,12 @@ export function serializeLocalCLIBootstrap(
34
34
  )
35
35
  const cliBootstrapPath = getFileImportRelativePath(
36
36
  bootstrapFile,
37
- config.bootstrapFiles.cli,
37
+ config.bootstrapFile,
38
38
  config.packageMappings
39
39
  )
40
40
 
41
- return `/**
42
- * This file was generated by the @pikku/cli
43
- */
44
- import { executeCLI } from '@pikku/core'
41
+ return `
42
+ import { executeCLI, CLIError } from '@pikku/core/cli'
45
43
  import { ${pikkuConfigFactory.variable} as createConfig } from '${pikkuConfigPath}'
46
44
  import { ${singletonServicesFactory.variable} as createSingletonServices } from '${singletonServicesPath}'
47
45
  import { ${sessionServicesFactory.variable} as createSessionServices } from '${sessionServicesPath}'
@@ -51,14 +49,21 @@ import '${cliBootstrapPath}'
51
49
  * ${capitalizedName} CLI function
52
50
  * Handles command line arguments and executes the appropriate function
53
51
  */
54
- export async function ${capitalizedName}CLI(args?: string[]): Promise<void> {
55
- await executeCLI({
56
- programName: '${programName}',
57
- args,
58
- createConfig,
59
- createSingletonServices,
60
- createSessionServices,
61
- })
52
+ export async function ${capitalizedName}CLI(args: string[]): Promise<void> {
53
+ try {
54
+ await executeCLI({
55
+ programName: '${programName}',
56
+ args: args || process.argv.slice(2),
57
+ createConfig,
58
+ createSingletonServices,
59
+ createSessionServices,
60
+ })
61
+ } catch (error) {
62
+ if (error instanceof CLIError) {
63
+ process.exit(error.exitCode)
64
+ }
65
+ throw error
66
+ }
62
67
  }
63
68
 
64
69
  // Export as default for easy importing
@@ -66,7 +71,7 @@ export default ${capitalizedName}CLI
66
71
 
67
72
  // For direct execution (if this file is run directly)
68
73
  if (import.meta.url === \`file://\${process.argv[1]}\`) {
69
- ${capitalizedName}CLI().catch(error => {
74
+ ${capitalizedName}CLI(process.argv.slice(2)).catch(error => {
70
75
  console.error('Fatal error:', error.message)
71
76
  process.exit(1)
72
77
  })
@@ -8,8 +8,14 @@ export const pikkuFetch: any = pikkuSessionlessFunc<void, void>({
8
8
  func: async ({ logger, config }) => {
9
9
  const { fetchFile, httpMapDeclarationFile, packageMappings } = config
10
10
 
11
+ // If fetchFile is not set, clean up any existing file and return
11
12
  if (!fetchFile) {
12
- throw new Error("fetchFile is isn't set in the pikku config")
13
+ logger.info({
14
+ message:
15
+ "Skipping generating fetch wrapper since fetchFile isn't set in the pikku config.",
16
+ type: 'skip',
17
+ })
18
+ return
13
19
  }
14
20
 
15
21
  const routesMapDeclarationPath = getFileImportRelativePath(
@@ -25,8 +31,6 @@ export const pikkuFetch: any = pikkuSessionlessFunc<void, void>({
25
31
  logCommandInfoAndTime({
26
32
  commandStart: 'Generating fetch wrapper',
27
33
  commandEnd: 'Generated fetch wrapper',
28
- skipCondition: ({ config }) => config.fetchFile === undefined,
29
- skipMessage: "fetchFile isn't set in the pikku config",
30
34
  }),
31
35
  ],
32
36
  })
@@ -12,6 +12,7 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
12
12
  functionTypesFile,
13
13
  packageMappings,
14
14
  rpcInternalMapDeclarationFile,
15
+ servicesFile,
15
16
  } = config
16
17
 
17
18
  // Check for required types
@@ -21,13 +22,21 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
21
22
  singletonServicesType: true,
22
23
  })
23
24
 
24
- const { userSessionType, sessionServicesType, singletonServicesType } =
25
- visitState.filesAndMethods
25
+ const {
26
+ userSessionType,
27
+ sessionServicesType,
28
+ singletonServicesType,
29
+ pikkuConfigType,
30
+ } = visitState.filesAndMethods
26
31
 
27
32
  if (!userSessionType || !sessionServicesType || !singletonServicesType) {
28
33
  throw new Error('Required types not found')
29
34
  }
30
35
 
36
+ const configTypeImport = pikkuConfigType
37
+ ? `import type { ${pikkuConfigType.type} } from '${getFileImportRelativePath(functionTypesFile, pikkuConfigType.typePath, packageMappings)}'`
38
+ : '// Config type not found, will use fallback'
39
+
31
40
  const content = serializeFunctionTypes(
32
41
  `import type { ${userSessionType.type} } from '${getFileImportRelativePath(functionTypesFile, userSessionType.typePath, packageMappings)}'`,
33
42
  userSessionType.type,
@@ -35,7 +44,9 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
35
44
  singletonServicesType.type,
36
45
  `import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, sessionServicesType.typePath, packageMappings)}'`,
37
46
  sessionServicesType.type,
38
- `import type { TypedPikkuRPC } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`
47
+ `import type { TypedPikkuRPC } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`,
48
+ `import type { RequiredSingletonServices, RequiredSessionServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`,
49
+ configTypeImport
39
50
  )
40
51
 
41
52
  await writeFileInDir(logger, functionTypesFile, content)
@@ -44,8 +55,6 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
44
55
  logCommandInfoAndTime({
45
56
  commandStart: 'Creating function types',
46
57
  commandEnd: 'Created function types',
47
- skipCondition: false,
48
- skipMessage: '',
49
58
  }),
50
59
  ],
51
60
  })
@@ -38,8 +38,6 @@ export const pikkuFunctionTypes: any = pikkuSessionlessFunc<void, void>({
38
38
  logCommandInfoAndTime({
39
39
  commandStart: 'Creating api types hub',
40
40
  commandEnd: 'Created api types hub',
41
- skipCondition: false,
42
- skipMessage: '',
43
41
  }),
44
42
  ],
45
43
  })