@pikku/cli 0.9.16-next.0 → 0.10.1

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 (268) 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 +15 -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/check-required-types.js +11 -1
  181. package/dist/src/utils/custom-types-generator.js +8 -2
  182. package/dist/src/utils/file-writer.d.ts +4 -1
  183. package/dist/src/utils/file-writer.js +13 -3
  184. package/dist/src/utils/get-cli-version.d.ts +5 -0
  185. package/dist/src/utils/get-cli-version.js +27 -0
  186. package/dist/src/utils/pikku-cli-config.d.ts +1 -2
  187. package/dist/src/utils/pikku-cli-config.js +9 -28
  188. package/dist/src/utils/schema-generator.js +3 -2
  189. package/dist/src/utils/serialize-import-map.js +0 -3
  190. package/dist/tsconfig.tsbuildinfo +1 -1
  191. package/package.json +10 -8
  192. package/pikku.config.json +4 -2
  193. package/src/cli.wiring.ts +101 -74
  194. package/src/functions/commands/all.ts +12 -0
  195. package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +12 -12
  196. package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +2 -2
  197. package/src/functions/wirings/channels/pikku-channels.ts +0 -5
  198. package/src/functions/wirings/channels/pikku-command-channel-types.ts +0 -2
  199. package/src/functions/wirings/channels/pikku-command-channels-map.ts +0 -5
  200. package/src/functions/wirings/channels/pikku-command-channels.ts +0 -5
  201. package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +7 -3
  202. package/src/functions/wirings/channels/serialize-channel-types.ts +27 -28
  203. package/src/functions/wirings/channels/serialize-typed-channel-map.ts +4 -1
  204. package/src/functions/wirings/cli/pikku-command-cli-entry.ts +52 -9
  205. package/src/functions/wirings/cli/pikku-command-cli-types.ts +0 -2
  206. package/src/functions/wirings/cli/pikku-command-cli.ts +0 -2
  207. package/src/functions/wirings/cli/serialize-channel-cli-client.ts +111 -12
  208. package/src/functions/wirings/cli/serialize-channel-cli.ts +2 -23
  209. package/src/functions/wirings/cli/serialize-cli-types.ts +13 -14
  210. package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +19 -14
  211. package/src/functions/wirings/fetch/index.ts +7 -3
  212. package/src/functions/wirings/functions/pikku-command-function-types-split.ts +14 -5
  213. package/src/functions/wirings/functions/pikku-command-function-types.ts +0 -2
  214. package/src/functions/wirings/functions/pikku-command-functions.ts +0 -2
  215. package/src/functions/wirings/functions/pikku-command-services.ts +13 -24
  216. package/src/functions/wirings/functions/pikku-function-types.ts +0 -2
  217. package/src/functions/wirings/functions/schemas.ts +0 -2
  218. package/src/functions/wirings/functions/serialize-function-types.ts +169 -19
  219. package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +0 -1
  220. package/src/functions/wirings/http/openapi-spec-generator.ts +2 -1
  221. package/src/functions/wirings/http/pikku-command-http-map.ts +0 -5
  222. package/src/functions/wirings/http/pikku-command-http-routes.ts +0 -5
  223. package/src/functions/wirings/http/pikku-command-http-types.ts +0 -2
  224. package/src/functions/wirings/http/pikku-command-openapi.ts +9 -4
  225. package/src/functions/wirings/http/pikku-http-routes.ts +0 -5
  226. package/src/functions/wirings/http/serialize-http-types.ts +27 -2
  227. package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +0 -5
  228. package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +0 -2
  229. package/src/functions/wirings/mcp/pikku-command-mcp.ts +0 -5
  230. package/src/functions/wirings/mcp/serialize-mcp-json.ts +1 -1
  231. package/src/functions/wirings/mcp/serialize-mcp-types.ts +14 -12
  232. package/src/functions/wirings/middleware/pikku-command-middleware.ts +0 -2
  233. package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +1 -7
  234. package/src/functions/wirings/permissions/pikku-command-permissions.ts +49 -0
  235. package/src/functions/wirings/permissions/serialize-permissions-imports.test.ts +274 -0
  236. package/src/functions/wirings/permissions/serialize-permissions-imports.ts +78 -0
  237. package/src/functions/wirings/queue/pikku-command-queue-map.ts +0 -5
  238. package/src/functions/wirings/queue/pikku-command-queue-service.ts +7 -3
  239. package/src/functions/wirings/queue/pikku-command-queue-types.ts +0 -2
  240. package/src/functions/wirings/queue/pikku-command-queue.ts +0 -5
  241. package/src/functions/wirings/queue/pikku-queue-map.ts +0 -5
  242. package/src/functions/wirings/queue/pikku-queue.ts +3 -6
  243. package/src/functions/wirings/queue/serialize-queue-meta.ts +1 -1
  244. package/src/functions/wirings/queue/serialize-queue-types.ts +0 -1
  245. package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +6 -3
  246. package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +0 -4
  247. package/src/functions/wirings/rpc/pikku-command-rpc.ts +0 -2
  248. package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +0 -2
  249. package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +0 -5
  250. package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +0 -1
  251. package/src/middleware/log-command-info-and-time.ts +2 -28
  252. package/src/services/cli-logger-forwarder.service.ts +15 -2
  253. package/src/services/cli-logger.service.ts +15 -0
  254. package/src/services.ts +148 -19
  255. package/src/utils/check-required-types.ts +16 -1
  256. package/src/utils/custom-types-generator.ts +8 -2
  257. package/src/utils/file-writer.ts +19 -3
  258. package/src/utils/get-cli-version.ts +28 -0
  259. package/src/utils/pikku-cli-config.ts +6 -35
  260. package/src/utils/schema-generator.ts +7 -3
  261. package/src/utils/serialize-import-map.ts +0 -4
  262. package/types/application-types.d.ts +4 -1
  263. package/types/config.d.ts +15 -3
  264. package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.d.ts +0 -6
  265. package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.js +0 -6
  266. package/dist/src/serialize-pikku-types.d.ts +0 -4
  267. package/dist/src/serialize-pikku-types.js +0 -605
  268. package/src/serialize-pikku-types.ts +0 -613
@@ -3,23 +3,18 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
3
3
  import { checkRequiredTypes } from '../../../utils/check-required-types.js';
4
4
  import { writeFileInDir } from '../../../utils/file-writer.js';
5
5
  import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
6
- export const serializeServicesMap = (functionsMetaData, middlewareServices = [], servicesImport, sessionServicesImport) => {
7
- // Extract all unique services from all functions
8
- const usedServices = new Set();
6
+ export const serializeServicesMap = (requiredServices, forceRequiredServices = [], servicesImport, sessionServicesImport) => {
7
+ // Use pre-aggregated services from inspector state
8
+ // This includes services from:
9
+ // - Wired functions (HTTP, channels, queues, schedulers, MCP, CLI, RPC)
10
+ // - Middleware used by wired functions
11
+ // - Permissions used by wired functions
12
+ // - Session factories
13
+ const usedServices = new Set(requiredServices);
9
14
  // Internal services that are created internally and not via the create service script
10
15
  const internalServices = new Set(['rpc', 'mcp', 'channel', 'userSession']);
11
- for (const funcMeta of Object.values(functionsMetaData)) {
12
- if (funcMeta.services && Array.isArray(funcMeta.services.services)) {
13
- funcMeta.services.services.forEach((service) => {
14
- // Only include services that are not internal
15
- if (!internalServices.has(service)) {
16
- usedServices.add(service);
17
- }
18
- });
19
- }
20
- }
21
- // Add middleware services that might not be detected from function inspection
22
- middlewareServices.forEach((service) => {
16
+ // Add force-required services that might not be detected from function inspection
17
+ forceRequiredServices.forEach((service) => {
23
18
  if (!internalServices.has(service)) {
24
19
  usedServices.add(service);
25
20
  }
@@ -40,10 +35,6 @@ export const serializeServicesMap = (functionsMetaData, middlewareServices = [],
40
35
  // This will be resolved at compile time based on what's actually in the SingletonServices interface
41
36
  // We don't need to hardcode which services are singletons beyond the core framework ones
42
37
  const code = [
43
- '/**',
44
- ' * This file was generated by the @pikku/cli',
45
- ' */',
46
- '',
47
38
  servicesImport,
48
39
  sessionServicesImport,
49
40
  "import type { PikkuInteraction } from '@pikku/core'",
@@ -77,14 +68,13 @@ export const pikkuServices = pikkuSessionlessFunc({
77
68
  }
78
69
  const servicesImport = `import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(config.typesDeclarationFile, singletonServicesType.typePath, config.packageMappings)}'`;
79
70
  const sessionServicesImport = `import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(config.typesDeclarationFile, sessionServicesType.typePath, config.packageMappings)}'`;
80
- const servicesCode = serializeServicesMap(visitState.functions.meta, config.middlewareServices, servicesImport, sessionServicesImport);
71
+ const servicesCode = serializeServicesMap(visitState.serviceAggregation.requiredServices, config.forceRequiredServices, servicesImport, sessionServicesImport);
81
72
  await writeFileInDir(logger, config.servicesFile, servicesCode);
82
73
  },
83
74
  middleware: [
84
75
  logCommandInfoAndTime({
85
76
  commandStart: 'Generating Pikku services map',
86
77
  commandEnd: 'Generated Pikku services map',
87
- skipMessage: '',
88
78
  }),
89
79
  ],
90
80
  });
@@ -13,8 +13,6 @@ export const pikkuFunctionTypes = pikkuSessionlessFunc({
13
13
  logCommandInfoAndTime({
14
14
  commandStart: 'Creating api types hub',
15
15
  commandEnd: 'Created api types hub',
16
- skipCondition: false,
17
- skipMessage: '',
18
16
  }),
19
17
  ],
20
18
  });
@@ -15,8 +15,6 @@ export const pikkuSchemas = pikkuSessionlessFunc({
15
15
  logCommandInfoAndTime({
16
16
  commandStart: 'Generating schemas',
17
17
  commandEnd: 'Generated schemas',
18
- skipCondition: false,
19
- skipMessage: '',
20
18
  }),
21
19
  ],
22
20
  });
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Generates core function, middleware, and permission type definitions
3
3
  */
4
- export declare const serializeFunctionTypes: (userSessionTypeImport: string, userSessionTypeName: string, singletonServicesTypeImport: string, singletonServicesTypeName: string, sessionServicesTypeImport: string, sessionServicesTypeName: string, rpcMapTypeImport: string) => string;
4
+ export declare const serializeFunctionTypes: (userSessionTypeImport: string, userSessionTypeName: string, singletonServicesTypeImport: string, singletonServicesTypeName: string, sessionServicesTypeImport: string, sessionServicesTypeName: string, rpcMapTypeImport: string, requiredServicesTypeImport: string, configTypeImport: string) => string;
@@ -1,24 +1,27 @@
1
1
  /**
2
2
  * Generates core function, middleware, and permission type definitions
3
3
  */
4
- export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeName, singletonServicesTypeImport, singletonServicesTypeName, sessionServicesTypeImport, sessionServicesTypeName, rpcMapTypeImport) => {
4
+ export const serializeFunctionTypes = (userSessionTypeImport, userSessionTypeName, singletonServicesTypeImport, singletonServicesTypeName, sessionServicesTypeImport, sessionServicesTypeName, rpcMapTypeImport, requiredServicesTypeImport, configTypeImport) => {
5
5
  return `/**
6
- * This file was generated by the @pikku/cli
7
6
  * Core function, middleware, and permission types for all wirings
8
7
  */
9
8
 
10
- import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore } from '@pikku/core'
9
+ import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore } from '@pikku/core'
11
10
  import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
12
- import { PikkuChannel, PikkuMCP } from '@pikku/core'
11
+ import { PikkuChannel } from '@pikku/core/channel'
12
+ import { PikkuMCP } from '@pikku/core/mcp'
13
13
 
14
14
  ${userSessionTypeImport}
15
15
  ${singletonServicesTypeImport}
16
16
  ${sessionServicesTypeImport}
17
+ ${configTypeImport}
17
18
  ${rpcMapTypeImport}
19
+ ${requiredServicesTypeImport}
18
20
 
19
21
  ${singletonServicesTypeName !== 'SingletonServices' ? `type SingletonServices = ${singletonServicesTypeName}` : ''}
20
22
  ${sessionServicesTypeName !== 'Services' ? `type Services = ${sessionServicesTypeName}` : ''}
21
23
  ${userSessionTypeName !== 'Session' ? `type Session = ${userSessionTypeName}` : ''}
24
+ ${configTypeImport.includes('Config type not found') ? 'type Config = any' : ''}
22
25
 
23
26
  /**
24
27
  * Type-safe API permission definition that integrates with your application's session type.
@@ -37,35 +40,84 @@ export type PikkuPermission<In = unknown, RequiredServices extends Services = Se
37
40
  */
38
41
  export type PikkuMiddleware<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuMiddleware<RequiredServices, Session>
39
42
 
43
+ /**
44
+ * Configuration object for creating a permission with metadata
45
+ */
46
+ export type PikkuPermissionConfig<In = unknown, RequiredServices extends Services = Services> = {
47
+ /** The permission function */
48
+ func: PikkuPermission<In, RequiredServices>
49
+ /** Optional human-readable name for the permission */
50
+ name?: string
51
+ /** Optional description of what the permission checks */
52
+ description?: string
53
+ }
54
+
40
55
  /**
41
56
  * Factory function for creating permissions with tree-shaking support.
42
- * This enables the bundler to detect which services your permission actually uses.
57
+ * Supports both direct function and configuration object syntax.
43
58
  *
44
59
  * @example
45
60
  * \`\`\`typescript
61
+ * // Direct function syntax
46
62
  * const permission = pikkuPermission(({ logger }, data, session) => {
47
- * return session?.isAdmin || false
63
+ * return session?.role === 'admin'
64
+ * })
65
+ *
66
+ * // Configuration object syntax with metadata
67
+ * const adminPermission = pikkuPermission({
68
+ * name: 'Admin Permission',
69
+ * description: 'Checks if user has admin role',
70
+ * func: async ({ logger }, data, session) => {
71
+ * return session?.role === 'admin'
72
+ * }
48
73
  * })
49
74
  * \`\`\`
50
75
  */
51
- export const pikkuPermission = <In>(func: PikkuPermission<In>) => {
52
- return func
76
+ export const pikkuPermission = <In>(
77
+ permission: PikkuPermission<In> | PikkuPermissionConfig<In>
78
+ ): PikkuPermission<In> => {
79
+ return typeof permission === 'function' ? permission : permission.func
80
+ }
81
+
82
+ /**
83
+ * Configuration object for creating middleware with metadata
84
+ */
85
+ export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = SingletonServices> = {
86
+ /** The middleware function */
87
+ func: PikkuMiddleware<RequiredServices>
88
+ /** Optional human-readable name for the middleware */
89
+ name?: string
90
+ /** Optional description of what the middleware does */
91
+ description?: string
53
92
  }
54
93
 
55
94
  /**
56
95
  * Factory function for creating middleware with tree-shaking support.
57
- * This enables the bundler to detect which services your middleware actually uses.
96
+ * Supports both direct function and configuration object syntax.
58
97
  *
59
98
  * @example
60
99
  * \`\`\`typescript
100
+ * // Direct function syntax
61
101
  * const middleware = pikkuMiddleware(({ logger }, interactions, next) => {
62
102
  * logger.info('Middleware executed')
63
103
  * await next()
64
104
  * })
105
+ *
106
+ * // Configuration object syntax with metadata
107
+ * const logMiddleware = pikkuMiddleware({
108
+ * name: 'Request Logger',
109
+ * description: 'Logs all incoming requests',
110
+ * func: async ({ logger }, interactions, next) => {
111
+ * logger.info('Request started')
112
+ * await next()
113
+ * }
114
+ * })
65
115
  * \`\`\`
66
116
  */
67
- export const pikkuMiddleware = (func: PikkuMiddleware) => {
68
- return func
117
+ export const pikkuMiddleware = <RequiredServices extends SingletonServices = SingletonServices>(
118
+ middleware: PikkuMiddleware<RequiredServices> | PikkuMiddlewareConfig<RequiredServices>
119
+ ): PikkuMiddleware<RequiredServices> => {
120
+ return typeof middleware === 'function' ? middleware : middleware.func
69
121
  }
70
122
 
71
123
  /**
@@ -91,6 +143,31 @@ export const pikkuMiddlewareFactory = <In = any>(
91
143
  return factory
92
144
  }
93
145
 
146
+ /**
147
+ * Factory function for creating permission factories
148
+ * Use this when your permission needs configuration/input parameters
149
+ *
150
+ * @example
151
+ * \`\`\`typescript
152
+ * export const requireRole = pikkuPermissionFactory<{ role: string }>(({
153
+ * role
154
+ * }) => {
155
+ * return pikkuPermission(async ({ logger }, data, session) => {
156
+ * if (!session || session.role !== role) {
157
+ * logger.warn(\`Permission denied: required role '\${role}'\`)
158
+ * return false
159
+ * }
160
+ * return true
161
+ * })
162
+ * })
163
+ * \`\`\`
164
+ */
165
+ export const pikkuPermissionFactory = <In = any>(
166
+ factory: (input: In) => PikkuPermission<any>
167
+ ): ((input: In) => PikkuPermission<any>) => {
168
+ return factory
169
+ }
170
+
94
171
  /**
95
172
  * A sessionless API function that doesn't require user authentication.
96
173
  * Use this for public endpoints, health checks, or operations that don't need user context.
@@ -106,7 +183,7 @@ export type PikkuFunctionSessionless<
106
183
  Out = never,
107
184
  ChannelData = null, // null means optional channel
108
185
  MCPData = null, // null means optional MCP
109
- RequiredServices extends Services = Services &
186
+ RequiredServices extends Services = Omit<Services, 'rpc' | 'channel' | 'mcp'> &
110
187
  { rpc: TypedPikkuRPC } & (
111
188
  [ChannelData] extends [null]
112
189
  ? { channel?: PikkuChannel<unknown, Out> } // Optional channel
@@ -132,7 +209,7 @@ export type PikkuFunction<
132
209
  Out = never,
133
210
  ChannelData = null, // null means optional channel
134
211
  MCPData = null, // null means optional MCP
135
- RequiredServices extends Services = Omit<Services, 'rpc'> &
212
+ RequiredServices extends Services = Omit<Services, 'rpc' | 'channel' | 'mcp'> &
136
213
  { rpc: TypedPikkuRPC } & (
137
214
  [ChannelData] extends [null]
138
215
  ? { channel?: PikkuChannel<unknown, Out> } // Optional channel
@@ -149,12 +226,16 @@ export type PikkuFunction<
149
226
  *
150
227
  * @template In - The input type
151
228
  * @template Out - The output type
229
+ * @template ChannelData - Channel data type
230
+ * @template MCPData - MCP data type
152
231
  * @template PikkuFunc - The function type (can be narrowed to PikkuFunction or PikkuFunctionSessionless)
153
232
  */
154
233
  export type PikkuFunctionConfig<
155
234
  In = unknown,
156
235
  Out = unknown,
157
- PikkuFunc extends PikkuFunction<In, Out> | PikkuFunctionSessionless<In, Out> = PikkuFunction<In, Out> | PikkuFunctionSessionless<In, Out>
236
+ ChannelData = unknown,
237
+ MCPData = unknown,
238
+ PikkuFunc extends PikkuFunction<In, Out, ChannelData, MCPData> | PikkuFunctionSessionless<In, Out, ChannelData, MCPData> = PikkuFunction<In, Out, ChannelData, MCPData> | PikkuFunctionSessionless<In, Out, ChannelData, MCPData>
158
239
  > = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware>
159
240
 
160
241
  /**
@@ -181,7 +262,7 @@ export type PikkuFunctionConfig<
181
262
  export const pikkuFunc = <In, Out = unknown>(
182
263
  func:
183
264
  | PikkuFunction<In, Out>
184
- | CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In>>
265
+ | CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In>, PikkuMiddleware>
185
266
  ) => {
186
267
  return typeof func === 'function' ? { func } : func
187
268
  }
@@ -238,6 +319,73 @@ export const pikkuVoidFunc = (
238
319
  return typeof func === 'function' ? { func } : func
239
320
  }
240
321
 
322
+ /**
323
+ * Creates a Pikku config factory.
324
+ * Use this to define your application's configuration factory.
325
+ *
326
+ * @param func - Config factory function that returns your application's config
327
+ * @returns The config factory function
328
+ *
329
+ * @example
330
+ * \`\`\`typescript
331
+ * export const createConfig = pikkuConfig(async () => {
332
+ * return {
333
+ * apiUrl: process.env.API_URL || 'http://localhost:3000',
334
+ * dbUrl: process.env.DATABASE_URL
335
+ * }
336
+ * })
337
+ * \`\`\`
338
+ */
339
+ export const pikkuConfig = (
340
+ func: (variables?: any, ...args: any[]) => Promise<Config>
341
+ ) => func
342
+
343
+ /**
344
+ * Creates a Pikku singleton services factory.
345
+ * Use this to define services that are created once and shared across all requests.
346
+ *
347
+ * @param func - Singleton services factory function
348
+ * @returns The singleton services factory function
349
+ *
350
+ * @example
351
+ * \`\`\`typescript
352
+ * export const createSingletonServices = pikkuServices(async (config, existingServices) => {
353
+ * return {
354
+ * config,
355
+ * logger: new CustomLogger(),
356
+ * db: await createDatabaseConnection(config.dbUrl)
357
+ * }
358
+ * })
359
+ * \`\`\`
360
+ */
361
+ export const pikkuServices = (
362
+ func: (config: Config, existingServices?: Partial<SingletonServices>) => Promise<RequiredSingletonServices>
363
+ ) => func
364
+
365
+ /**
366
+ * Creates a Pikku session services factory.
367
+ * Use this to define services that are created per-request/session.
368
+ *
369
+ * @param func - Session services factory function
370
+ * @returns The session services factory function
371
+ *
372
+ * @example
373
+ * \`\`\`typescript
374
+ * export const createSessionServices = pikkuSessionServices(async (services, interaction, session) => {
375
+ * return {
376
+ * userCache: new UserCache(session?.userId)
377
+ * }
378
+ * })
379
+ * \`\`\`
380
+ */
381
+ export const pikkuSessionServices = (
382
+ func: (
383
+ services: SingletonServices,
384
+ interaction: any,
385
+ session: Session | undefined
386
+ ) => Promise<RequiredSessionServices>
387
+ ) => func
388
+
241
389
  /**
242
390
  * Adds global middleware for a specific tag.
243
391
  *
@@ -272,7 +420,7 @@ export const addMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
272
420
  * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
273
421
  *
274
422
  * @param tag - The tag that the permissions should apply to.
275
- * @param permissions - The permissions array to apply for the specified tag.
423
+ * @param permissions - The permissions array or object to apply for the specified tag.
276
424
  *
277
425
  * @throws Error if permissions for the tag already exist.
278
426
  *
@@ -284,11 +432,11 @@ export const addMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
284
432
  * // Add authentication permissions for auth endpoints
285
433
  * addPermission('auth', [authPermission])
286
434
  *
287
- * // Add read permissions for all API endpoints
288
- * addPermission('api', [readPermission])
435
+ * // Add read permissions for all API endpoints (as object)
436
+ * addPermission('api', { read: readPermission })
289
437
  * \`\`\`
290
438
  */
291
- export const addPermission = <In = unknown>(tag: string, permissions: PikkuPermission<In>[]) => {
439
+ export const addPermission = <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
292
440
  addPermissionCore(tag, permissions as any)
293
441
  }
294
442
  `;
@@ -3,7 +3,6 @@
3
3
  */
4
4
  export const serializePikkuTypesHub = (functionTypesImportPath, httpTypesImportPath, channelTypesImportPath, schedulerTypesImportPath, queueTypesImportPath, mcpTypesImportPath, cliTypesImportPath) => {
5
5
  return `/**
6
- * This file was generated by the @pikku/cli
7
6
  * Main type export hub - re-exports all wiring-specific types
8
7
  */
9
8
 
@@ -1,4 +1,5 @@
1
- import { FunctionsMeta, HTTPWiringsMeta } from '@pikku/core';
1
+ import { FunctionsMeta } from '@pikku/core';
2
+ import { HTTPWiringsMeta } from '@pikku/core/http';
2
3
  import { CLILogger } from '../../../services/cli-logger.service.js';
3
4
  interface OpenAPISpec {
4
5
  openapi: string;
@@ -13,11 +13,6 @@ export const pikkuHTTPMap = pikkuSessionlessFunc({
13
13
  logCommandInfoAndTime({
14
14
  commandStart: 'Creating HTTP map',
15
15
  commandEnd: 'Created HTTP map',
16
- skipCondition: async ({ getInspectorState }) => {
17
- const { http } = await getInspectorState();
18
- return http.files.size === 0;
19
- },
20
- skipMessage: 'none found',
21
16
  }),
22
17
  ],
23
18
  });
@@ -15,11 +15,6 @@ export const pikkuHTTP = pikkuSessionlessFunc({
15
15
  logCommandInfoAndTime({
16
16
  commandStart: 'Finding HTTP routes',
17
17
  commandEnd: 'Found HTTP routes',
18
- skipCondition: async ({ getInspectorState }) => {
19
- const visitState = await getInspectorState();
20
- return visitState.http.files.size === 0;
21
- },
22
- skipMessage: 'none found',
23
18
  }),
24
19
  ],
25
20
  });
@@ -14,8 +14,6 @@ export const pikkuHTTPTypes = pikkuSessionlessFunc({
14
14
  logCommandInfoAndTime({
15
15
  commandStart: 'Creating HTTP types',
16
16
  commandEnd: 'Created HTTP types',
17
- skipCondition: false,
18
- skipMessage: '',
19
17
  }),
20
18
  ],
21
19
  });
@@ -6,11 +6,16 @@ import { generateOpenAPISpec } from './openapi-spec-generator.js';
6
6
  import { stringify } from 'yaml';
7
7
  export const pikkuOpenAPI = pikkuSessionlessFunc({
8
8
  func: async ({ logger, config, getInspectorState }) => {
9
- const { http, functions } = await getInspectorState();
10
9
  const { tsconfig, openAPI, schemasFromTypes } = config;
10
+ // If openAPI outputFile is not defined, clean up any existing file and return
11
11
  if (!openAPI?.outputFile) {
12
- throw new Error('openAPI is required');
12
+ logger.info({
13
+ message: 'Skipping creating OpenAPI spec since openAPI outfile is not defined.',
14
+ type: 'skip',
15
+ });
16
+ return;
13
17
  }
18
+ const { http, functions } = await getInspectorState();
14
19
  const schemas = await generateSchemas(logger, tsconfig, functions.typesMap, functions.meta, http.meta, schemasFromTypes);
15
20
  const openAPISpec = await generateOpenAPISpec(logger, functions.meta, http.meta, schemas, openAPI.additionalInfo);
16
21
  if (openAPI.outputFile.endsWith('.json')) {
@@ -27,8 +32,6 @@ export const pikkuOpenAPI = pikkuSessionlessFunc({
27
32
  logCommandInfoAndTime({
28
33
  commandStart: 'Creating OpenAPI spec',
29
34
  commandEnd: 'Created OpenAPI spec',
30
- skipCondition: ({ config }) => config.openAPI?.outputFile === undefined,
31
- skipMessage: 'openAPI outfile is not defined',
32
35
  }),
33
36
  ],
34
37
  });
@@ -15,11 +15,6 @@ export const pikkuHTTP = pikkuSessionlessFunc({
15
15
  logCommandInfoAndTime({
16
16
  commandStart: 'Finding HTTP routes',
17
17
  commandEnd: 'Found HTTP routes',
18
- skipCondition: async ({ getInspectorState }) => {
19
- const visitState = await getInspectorState();
20
- return visitState.http.files.size === 0;
21
- },
22
- skipMessage: 'none found',
23
18
  }),
24
19
  ],
25
20
  });
@@ -3,11 +3,10 @@
3
3
  */
4
4
  export const serializeHTTPTypes = (functionTypesImportPath) => {
5
5
  return `/**
6
- * This file was generated by the @pikku/cli
7
6
  * HTTP-specific type definitions for tree-shaking optimization
8
7
  */
9
8
 
10
- import { AssertHTTPWiringParams, wireHTTP as wireHTTPCore, addHTTPMiddleware as addHTTPMiddlewareCore } from '@pikku/core/http'
9
+ import { AssertHTTPWiringParams, wireHTTP as wireHTTPCore, addHTTPMiddleware as addHTTPMiddlewareCore, addHTTPPermission as addHTTPPermissionCore } from '@pikku/core/http'
11
10
  import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
12
11
  import type { CoreHTTPFunctionWiring } from '@pikku/core/http'
13
12
 
@@ -60,5 +59,31 @@ export const addHTTPMiddleware = (
60
59
  ) => {
61
60
  addHTTPMiddlewareCore(routeOrMiddleware as any, middleware as any)
62
61
  }
62
+
63
+ /**
64
+ * Registers HTTP permissions either globally or for a specific route pattern.
65
+ *
66
+ * When a string route pattern is provided along with permissions, the permissions
67
+ * are applied only to that route. Permissions can be passed as an array or as a
68
+ * permission group object.
69
+ *
70
+ * @param pattern - Route pattern string (e.g., '*' for all routes, '/api/*' for specific routes)
71
+ * @param permissions - The permissions to apply for the specified route pattern
72
+ *
73
+ * @example
74
+ * \`\`\`typescript
75
+ * // Add global HTTP permissions
76
+ * addHTTPPermission('*', { global: globalPermission })
77
+ *
78
+ * // Add route-specific permissions
79
+ * addHTTPPermission('/api/admin/*', { admin: adminPermission })
80
+ * \`\`\`
81
+ */
82
+ export const addHTTPPermission = <In = unknown>(
83
+ pattern: string,
84
+ permissions: Record<string, PikkuPermission<In>> | PikkuPermission<In>[]
85
+ ) => {
86
+ addHTTPPermissionCore(pattern, permissions as any)
87
+ }
63
88
  `;
64
89
  };
@@ -18,11 +18,6 @@ export const pikkuMCPJSON = pikkuSessionlessFunc({
18
18
  logCommandInfoAndTime({
19
19
  commandStart: 'Generating MCP JSON',
20
20
  commandEnd: 'Generated MCP JSON',
21
- skipCondition: async ({ getInspectorState, config }) => {
22
- const { mcpEndpoints } = await getInspectorState();
23
- return mcpEndpoints.files.size === 0 || !config.mcpJsonFile;
24
- },
25
- skipMessage: 'none found or mcpJsonFile not set',
26
21
  }),
27
22
  ],
28
23
  });
@@ -14,8 +14,6 @@ export const pikkuMCPTypes = pikkuSessionlessFunc({
14
14
  logCommandInfoAndTime({
15
15
  commandStart: 'Creating MCP types',
16
16
  commandEnd: 'Created MCP types',
17
- skipCondition: false,
18
- skipMessage: '',
19
17
  }),
20
18
  ],
21
19
  });
@@ -61,11 +61,6 @@ pikkuState('mcp', 'promptsMeta', ${JSON.stringify(promptsMetaWithArguments, null
61
61
  logCommandInfoAndTime({
62
62
  commandStart: 'Finding MCP endpoints',
63
63
  commandEnd: 'Found MCP endpoints',
64
- skipCondition: async ({ getInspectorState }) => {
65
- const { mcpEndpoints } = await getInspectorState();
66
- return mcpEndpoints.files.size === 0;
67
- },
68
- skipMessage: 'none found',
69
64
  }),
70
65
  ],
71
66
  });
@@ -1,4 +1,4 @@
1
- import { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core';
1
+ import { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core/mcp';
2
2
  import { FunctionsMeta } from '@pikku/core';
3
3
  import { TypesMap } from '@pikku/inspector';
4
4
  import { CLILogger } from '../../../services/cli-logger.service.js';
@@ -3,7 +3,6 @@
3
3
  */
4
4
  export const serializeMCPTypes = (functionTypesImportPath) => {
5
5
  return `/**
6
- * This file was generated by the @pikku/cli
7
6
  * MCP-specific type definitions for tree-shaking optimization
8
7
  */
9
8
 
@@ -16,8 +15,9 @@ import {
16
15
  wireMCPPrompt as wireMCPPromptCore,
17
16
  MCPResourceResponse,
18
17
  MCPToolResponse,
19
- MCPPromptResponse
20
- } from '@pikku/core'
18
+ MCPPromptResponse,
19
+ AssertMCPResourceURIParams
20
+ } from '@pikku/core/mcp'
21
21
 
22
22
  import type { PikkuFunctionConfig, PikkuFunctionSessionless } from '${functionTypesImportPath}'
23
23
 
@@ -25,8 +25,9 @@ import type { PikkuFunctionConfig, PikkuFunctionSessionless } from '${functionTy
25
25
  * Type definition for MCP resources that provide data to AI models.
26
26
  *
27
27
  * @template In - Input type for the resource request
28
+ * @template URI - URI template string type for compile-time parameter validation
28
29
  */
29
- type MCPResourceWiring<In> = CoreMCPResource<PikkuFunctionConfig<In, MCPResourceResponse>>
30
+ type MCPResourceWiring<In, URI extends string> = CoreMCPResource<PikkuFunctionConfig<In, MCPResourceResponse>> & { uri: URI }
30
31
 
31
32
  /**
32
33
  * Type definition for MCP tools that AI models can invoke.
@@ -47,10 +48,11 @@ type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionConfig<In, MCPPromptRespon
47
48
  * Resources provide data that AI models can access.
48
49
  *
49
50
  * @template In - Input type for the resource request
51
+ * @template URI - URI template string for compile-time parameter validation
50
52
  * @param mcpResource - MCP resource definition with data provider function
51
53
  */
52
- export const wireMCPResource = <In>(
53
- mcpResource: MCPResourceWiring<In>
54
+ export const wireMCPResource = <In, URI extends string>(
55
+ mcpResource: MCPResourceWiring<In, URI> & AssertMCPResourceURIParams<In, URI>
54
56
  ) => {
55
57
  wireMCPResourceCore(mcpResource as any)
56
58
  }
@@ -96,8 +98,8 @@ export const pikkuMCPPromptFunc = <In>(
96
98
  func: PikkuFunctionSessionless<In, MCPPromptResponse>
97
99
  name?: string
98
100
  }
99
- ) => {
100
- return typeof func === 'function' ? func : func.func
101
+ ): PikkuFunctionConfig<In, MCPPromptResponse> => {
102
+ return typeof func === 'function' ? { func } : func
101
103
  }
102
104
 
103
105
  /**
@@ -115,8 +117,8 @@ export const pikkuMCPToolFunc = <In>(
115
117
  func: PikkuFunctionSessionless<In, MCPToolResponse, null, true>
116
118
  name?: string
117
119
  }
118
- ) => {
119
- return typeof func === 'function' ? func : func.func
120
+ ): PikkuFunctionConfig<In, MCPToolResponse> => {
121
+ return typeof func === 'function' ? { func } : func
120
122
  }
121
123
 
122
124
  /**
@@ -134,8 +136,8 @@ export const pikkuMCPResourceFunc = <In>(
134
136
  func: PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
135
137
  name?: string
136
138
  }
137
- ) => {
138
- return typeof func === 'function' ? func : func.func
139
+ ): PikkuFunctionConfig<In, MCPResourceResponse> => {
140
+ return typeof func === 'function' ? { func } : func
139
141
  }
140
142
  `;
141
143
  };
@@ -31,8 +31,6 @@ export const pikkuMiddleware = pikkuSessionlessFunc({
31
31
  logCommandInfoAndTime({
32
32
  commandStart: 'Serializing Pikku middleware',
33
33
  commandEnd: 'Serialized Pikku middleware',
34
- skipCondition: false,
35
- skipMessage: '',
36
34
  }),
37
35
  ],
38
36
  });