@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
@@ -1,605 +0,0 @@
1
- /**
2
- *
3
- */
4
- export const serializePikkuTypes = (userSessionTypeImport, userSessionTypeName, singletonServicesTypeImport, singletonServicesTypeName, sessionServicesTypeImport, sessionServicesTypeName, rpcMapTypeImport) => {
5
- return `/**
6
- * This is used to provide the application types in the typescript project
7
- */
8
-
9
- import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, addHTTPMiddleware, addMiddleware, addPermission } from '@pikku/core'
10
- import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
11
- import { CoreHTTPFunctionWiring, AssertHTTPWiringParams, wireHTTP as wireHTTPCore } from '@pikku/core/http'
12
- import { CoreScheduledTask, wireScheduler as wireSchedulerCore } from '@pikku/core/scheduler'
13
- import { CoreChannel, PikkuChannel, wireChannel as wireChannelCore } from '@pikku/core/channel'
14
- import { CoreQueueWorker, wireQueueWorker as wireQueueWorkerCore } from '@pikku/core/queue'
15
- import { CoreMCPResource, CoreMCPTool, CoreMCPPrompt, wireMCPResource as wireMCPResourceCore, wireMCPTool as wireMCPToolCore, wireMCPPrompt as wireMCPPromptCore, MCPResourceResponse, MCPToolResponse, MCPPromptResponse, PikkuMCP } from '@pikku/core'
16
-
17
- ${userSessionTypeImport}
18
- ${singletonServicesTypeImport}
19
- ${sessionServicesTypeImport}
20
- ${rpcMapTypeImport}
21
-
22
- ${singletonServicesTypeName !== 'SingletonServices' ? `type SingletonServices = ${singletonServicesTypeName}` : ''}
23
- ${sessionServicesTypeName !== 'Services' ? `type Services = ${sessionServicesTypeName}` : ''}
24
- ${userSessionTypeName !== 'Session' ? `type Session = ${userSessionTypeName}` : ''}
25
-
26
- /**
27
- * Type-safe API permission definition that integrates with your application's session type.
28
- * Use this to define authorization logic for your API endpoints.
29
- *
30
- * @template In - The input type that the permission check will receive
31
- * @template RequiredServices - The services required for this permission check
32
- */
33
- type PikkuPermission<In = unknown, RequiredServices extends Services = Services> = CorePikkuPermission<In, RequiredServices, Session>
34
-
35
- /**
36
- * Type-safe middleware definition that can access your application's services and session.
37
- * Use this to define reusable middleware that can be applied to multiple HTTP wirings.
38
- *
39
- * @template RequiredServices - The services required for this middleware
40
- */
41
- type PikkuMiddleware<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuMiddleware<RequiredServices, Session>
42
-
43
- /**
44
- * Factory function for creating permissions with tree-shaking support.
45
- * This enables the bundler to detect which services your permission actually uses.
46
- *
47
- * @example
48
- * \`\`\`typescript
49
- * const permission = pikkuPermission(({ logger }, data, session) => {
50
- * return session?.isAdmin || false
51
- * })
52
- * \`\`\`
53
- */
54
- export const pikkuPermission = <In>(func: PikkuPermission<In>) => {
55
- return func
56
- }
57
-
58
- /**
59
- * Factory function for creating middleware with tree-shaking support.
60
- * This enables the bundler to detect which services your middleware actually uses.
61
- *
62
- * @example
63
- * \`\`\`typescript
64
- * const middleware = pikkuMiddleware(({ logger }, interactions, next) => {
65
- * logger.info('Middleware executed')
66
- * await next()
67
- * })
68
- * \`\`\`
69
- */
70
- export const pikkuMiddleware = (func: PikkuMiddleware) => {
71
- return func
72
- }
73
-
74
- /**
75
- * A sessionless API function that doesn't require user authentication.
76
- * Use this for public endpoints, health checks, or operations that don't need user context.
77
- *
78
- * @template In - The input type
79
- * @template Out - The output type that the function returns
80
- * @template ChannelData - Channel data type (null = optional channel)
81
- * @template MCPData - MCP data type (null = optional MCP)
82
- * @template RequiredServices - Services required by this function
83
- */
84
- type PikkuFunctionSessionless<
85
- In = unknown,
86
- Out = never,
87
- ChannelData = null, // null means optional channel
88
- MCPData = null, // null means optional MCP
89
- RequiredServices extends Services = Services &
90
- { rpc: TypedPikkuRPC } & (
91
- [ChannelData] extends [null]
92
- ? { channel?: PikkuChannel<unknown, Out> } // Optional channel
93
- : { channel: PikkuChannel<ChannelData, Out> } // Required channel with any data type
94
- ) & ([MCPData] extends [null]
95
- ? { mcp?: PikkuMCP } // Optional MCP
96
- : { mcp: PikkuMCP } // Required MCP
97
- )
98
- > = CorePikkuFunctionSessionless<In, Out, ChannelData, RequiredServices, Session>
99
-
100
- /**
101
- * A session-aware API function that requires user authentication.
102
- * Use this for protected endpoints that need access to user session data.
103
- *
104
- * @template In - The input type
105
- * @template Out - The output type that the function returns
106
- * @template ChannelData - Channel data type (null = optional channel)
107
- * @template MCPData - MCP data type (null = optional MCP)
108
- * @template RequiredServices - Services required by this function
109
- */
110
- type PikkuFunction<
111
- In = unknown,
112
- Out = never,
113
- ChannelData = null, // null means optional channel
114
- MCPData = null, // null means optional MCP
115
- RequiredServices extends Services = Services &
116
- { rpc: TypedPikkuRPC } & (
117
- [ChannelData] extends [null]
118
- ? { channel?: PikkuChannel<unknown, Out> } // Optional channel
119
- : { channel: PikkuChannel<ChannelData, Out> } // Required channel with any data type
120
- ) & ([MCPData] extends [null]
121
- ? { mcp?: PikkuMCP } // Optional MCP
122
- : { mcp: PikkuMCP } // Required MCP
123
- )
124
- > = CorePikkuFunction<In, Out, ChannelData, RequiredServices, Session>
125
-
126
- /**
127
- * Type definition for HTTP API wirings with type-safe path parameters.
128
- * Supports both authenticated and unauthenticated functions.
129
- *
130
- * @template In - Input type for the HTTP wiring
131
- * @template Out - Output type for the HTTP wiring
132
- * @template Route - String literal type for the HTTP path (e.g., "/users/:id")
133
- */
134
- type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out>, PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>
135
-
136
- /**
137
- * Type definition for WebSocket channels with typed data exchange.
138
- * Supports connection, disconnection, and message handling.
139
- *
140
- * @template ChannelData - Type of data exchanged through the channel
141
- * @template Channel - String literal type for the channel name
142
- */
143
- type ChannelWiringFunction<I, O, C = {}> = PikkuFunctionSessionless<I, O, C> | PikkuFunction<I, O, C>
144
- 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>
145
-
146
- /**
147
- * Type definition for scheduled tasks that run at specified intervals.
148
- * These are sessionless functions that execute based on cron expressions.
149
- */
150
- type SchedulerWiring = CoreScheduledTask<PikkuFunctionSessionless<void, void>, PikkuMiddleware>
151
-
152
- /**
153
- * Type definition for queue workers that process background jobs.
154
- *
155
- * @template In - Input type for the queue job
156
- * @template Out - Output type for the queue job
157
- */
158
- type QueueWiring<In, Out> = CoreQueueWorker<any>
159
-
160
- /**
161
- * Type definition for MCP resources that provide data to AI models.
162
- *
163
- * @template In - Input type for the resource request
164
- */
165
- type MCPResourceWiring<In> = CoreMCPResource<PikkuFunctionSessionless<In, MCPResourceResponse, null, true>>
166
-
167
- /**
168
- * Type definition for MCP tools that AI models can invoke.
169
- *
170
- * @template In - Input type for the tool invocation
171
- */
172
- type MCPToolWiring<In> = CoreMCPTool<PikkuFunctionSessionless<In, MCPToolResponse, null, true>>
173
-
174
- /**
175
- * Type definition for MCP prompts that provide templates to AI models.
176
- *
177
- * @template In - Input type for the prompt parameters
178
- */
179
- type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionSessionless<In, MCPPromptResponse, null, true>>
180
-
181
- /**
182
- * Creates a Pikku function that can be either session-aware or sessionless.
183
- * This is the main function wrapper for creating API endpoints.
184
- *
185
- * @template In - Input type for the function
186
- * @template Out - Output type for the function
187
- * @param func - Function definition, either direct function or configuration object
188
- * @returns The unwrapped function for internal use
189
- *
190
- * @example
191
- * \\\`\\\`\\\`typescript
192
- * const createUser = pikkuFunc<{name: string, email: string}, {id: number, message: string}>({
193
- * func: async ({db, logger}, input) => {
194
- * logger.info('Creating user', input.name)
195
- * const user = await db.users.create(input)
196
- * return {id: user.id, message: \\\`User \\\${input.name} created successfully\\\`}
197
- * },
198
- * auth: true
199
- * })
200
- * \\\`\\\`\\\`
201
- */
202
- export const pikkuFunc = <In, Out = unknown>(
203
- func:
204
- | PikkuFunction<In, Out>
205
- | CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In>>
206
- ) => {
207
- return typeof func === 'function' ? { func } : func
208
- }
209
-
210
- /**
211
- * Creates a sessionless Pikku function that doesn't require user authentication.
212
- * Use this for public endpoints, webhooks, or background tasks.
213
- *
214
- * @template In - Input type for the function
215
- * @template Out - Output type for the function
216
- * @param func - Function definition, either direct function or configuration object
217
- * @returns The unwrapped function for internal use
218
- *
219
- * @example
220
- * \\\`\\\`\\\`typescript
221
- * const healthCheck = pikkuSessionlessFunc<void, {status: string, timestamp: string}>({
222
- * func: async ({logger}) => {
223
- * logger.info('Health check requested')
224
- * return {status: 'healthy', timestamp: new Date().toISOString()}
225
- * },
226
- * name: 'healthCheck'
227
- * })
228
- * \\\`\\\`\\\`
229
- */
230
- export const pikkuSessionlessFunc = <In, Out = unknown>(
231
- func:
232
- | PikkuFunctionSessionless<In, Out>
233
- | CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>
234
- ) => {
235
- return typeof func === 'function' ? { func } : func
236
- }
237
-
238
- /**
239
- * Creates a function that handles WebSocket channel connections.
240
- * Called when a client connects to a channel.
241
- *
242
- * @template Out - Output type for connection response
243
- * @template ChannelData - Type of data associated with the channel
244
- * @param func - Function definition, either direct function or configuration object
245
- * @returns The unwrapped function for internal use
246
- *
247
- * @example
248
- * \\\`\\\`\\\`typescript
249
- * const onChatConnect = pikkuChannelConnectionFunc<string>({
250
- * func: async ({logger, channel, eventHub}) => {
251
- * logger.info('User connected to chat')
252
- * await eventHub.publish('chat:join', channel.channelId, {channelId: channel.channelId})
253
- * return 'Welcome to the chat!'
254
- * }
255
- * })
256
- * \\\`\\\`\\\`
257
- */
258
- export const pikkuChannelConnectionFunc = <Out = unknown, ChannelData = unknown>(
259
- func:
260
- | PikkuFunctionSessionless<void, Out, ChannelData>
261
- | {
262
- func: PikkuFunctionSessionless<void, Out, ChannelData>
263
- name?: string
264
- }
265
- ) => {
266
- return typeof func === 'function' ? { func } : func
267
- }
268
-
269
- /**
270
- * Creates a function that handles WebSocket channel disconnections.
271
- * Called when a client disconnects from a channel.
272
- *
273
- * @template ChannelData - Type of data associated with the channel
274
- * @param func - Function definition, either direct function or configuration object
275
- * @returns The unwrapped function for internal use
276
- *
277
- * @example
278
- * \\\`\\\`\\\`typescript
279
- * const onChatDisconnect = pikkuChannelDisconnectionFunc({
280
- * func: async ({logger, channel, eventHub}) => {
281
- * logger.info('User disconnected from chat')
282
- * await eventHub.publish('chat:join', channel.channelId, {channelId: channel.channelId})
283
- * }
284
- * })
285
- * \\\`\\\`\\\`
286
- */
287
- export const pikkuChannelDisconnectionFunc = <ChannelData = unknown>(
288
- func:
289
- | PikkuFunctionSessionless<void, void, ChannelData>
290
- | {
291
- func: PikkuFunction<void, void, ChannelData>
292
- name?: string
293
- }
294
- ) => {
295
- return typeof func === 'function' ? { func } : func
296
- }
297
-
298
- /**
299
- * Creates a function that handles WebSocket channel messages.
300
- * Called when a message is received on a channel.
301
- *
302
- * @template In - Input type for channel messages
303
- * @template Out - Output type for channel responses
304
- * @template ChannelData - Type of data associated with the channel
305
- * @param func - Function definition, either direct function or configuration object
306
- * @returns The unwrapped function for internal use
307
- *
308
- * @example
309
- * \\\`\\\`\\\`typescript
310
- * const handleChatMessage = pikkuChannelFunc<{message: string}, void>({
311
- * func: async ({logger, channel}, input) => {
312
- * logger.info('Chat message received:', input.message)
313
- * }
314
- * })
315
- * \\\`\\\`\\\`
316
- */
317
- export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unknown>(
318
- func:
319
- | PikkuFunctionSessionless<In, Out, ChannelData>
320
- | CorePikkuFunctionConfig<PikkuFunction<In, Out, ChannelData>, PikkuPermission<In>>
321
- ) => {
322
- return typeof func === 'function' ? { func } : func
323
- }
324
-
325
- /**
326
- * Creates a function that takes no input and returns no output.
327
- * Useful for health checks, triggers, or cleanup operations.
328
- *
329
- * @param func - Function definition, either direct function or configuration object
330
- * @returns The unwrapped function for internal use
331
- *
332
- * @example
333
- * \\\`\\\`\\\`typescript
334
- * const cleanupTempFiles = pikkuVoidFunc(async ({fileSystem, logger}) => {
335
- * logger.info('Starting cleanup of temporary files')
336
- * await fileSystem.deleteDirectory('/tmp/uploads')
337
- * logger.info('Cleanup completed')
338
- * })
339
- * \\\`\\\`\\\`
340
- */
341
- export const pikkuVoidFunc = (
342
- func:
343
- | PikkuFunctionSessionless<void, void>
344
- | CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void>, PikkuPermission<void>>
345
- ) => {
346
- return typeof func === 'function' ? { func } : func
347
- }
348
-
349
- /**
350
- * Registers a WebSocket channel with the Pikku framework.
351
- *
352
- * @template ChannelData - Type of data associated with the channel
353
- * @template Channel - String literal type for the channel name
354
- * @param channel - Channel definition with connection, disconnection, and message handlers
355
- */
356
- export const wireChannel = <ChannelData, Channel extends string>(
357
- channel: ChannelWiring<ChannelData, Channel> & AssertHTTPWiringParams<ChannelData, Channel>
358
- ) => {
359
- wireChannelCore(channel as any) // TODO
360
- }
361
-
362
- /**
363
- * Registers middleware either globally or for a specific route.
364
- *
365
- * When a string route pattern is provided along with middleware, the middleware
366
- * is applied only to that route. Otherwise, if an array is provided, it is treated
367
- * as global middleware (applied to all routes).
368
- *
369
- * @param routeOrMiddleware - Either a global middleware array or a route pattern string
370
- * @param middleware - The middleware array to apply when a route pattern is specified
371
- *
372
- * @example
373
- * \`\`\`typescript
374
- * // Add global middleware
375
- * addHTTPMiddleware([authMiddleware, loggingMiddleware])
376
- *
377
- * // Add route-specific middleware
378
- * addHTTPMiddleware('/api/admin/*', [adminAuthMiddleware])
379
- * \`\`\`
380
- */
381
- export { addHTTPMiddleware }
382
-
383
- /**
384
- * Adds global middleware for a specific tag.
385
- *
386
- * This function allows you to register middleware that will be applied to
387
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
388
- *
389
- * @param tag - The tag that the middleware should apply to.
390
- * @param middleware - The middleware array to apply for the specified tag.
391
- *
392
- * @throws Error if middleware for the tag already exists.
393
- *
394
- * @example
395
- * \`\`\`typescript
396
- * // Add admin middleware for admin endpoints
397
- * addMiddleware('admin', [adminMiddleware])
398
- *
399
- * // Add authentication middleware for auth endpoints
400
- * addMiddleware('auth', [authMiddleware])
401
- *
402
- * // Add logging middleware for all API endpoints
403
- * addMiddleware('api', [loggingMiddleware])
404
- * \`\`\`
405
- */
406
- export { addMiddleware }
407
-
408
- /**
409
- * Adds global permissions for a specific tag.
410
- *
411
- * This function allows you to register permissions that will be applied to
412
- * any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
413
- *
414
- * @param tag - The tag that the permissions should apply to.
415
- * @param permissions - The permissions array to apply for the specified tag.
416
- *
417
- * @throws Error if permissions for the tag already exist.
418
- *
419
- * @example
420
- * \`\`\`typescript
421
- * // Add admin permissions for admin endpoints
422
- * addPermission('admin', [adminPermission])
423
- *
424
- * // Add authentication permissions for auth endpoints
425
- * addPermission('auth', [authPermission])
426
- *
427
- * // Add read permissions for all API endpoints
428
- * addPermission('api', [readPermission])
429
- * \`\`\`
430
- */
431
- export { addPermission }
432
-
433
- /**
434
- * Registers an HTTP wiring with the Pikku framework.
435
- *
436
- * @template In - Input type for the HTTP wiring
437
- * @template Out - Output type for the HTTP wiring
438
- * @template Route - String literal type for the HTTP path (e.g., "/users/:id")
439
- * @param httpWiring - HTTP wiring definition with handler, method, and optional middleware
440
- */
441
- export const wireHTTP = <In, Out, Route extends string>(
442
- httpWiring: HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>
443
- ) => {
444
- wireHTTPCore(httpWiring as any) // TODO
445
- }
446
-
447
- /**
448
- * Registers a scheduled task with the Pikku framework.
449
- * Tasks run based on cron expressions and are sessionless.
450
- *
451
- * @param task - Scheduled task definition with cron expression and handler
452
- */
453
- export const wireScheduler = (task: SchedulerWiring) => {
454
- wireSchedulerCore(task as any) // TODO
455
- }
456
-
457
- /**
458
- * Registers a queue worker with the Pikku framework.
459
- * Workers process background jobs from queues.
460
- *
461
- * @param queueWorker - Queue worker definition with job handler
462
- */
463
- export const wireQueueWorker = (queueWorker: QueueWiring<any, any>) => {
464
- wireQueueWorkerCore(queueWorker as any) // TODO
465
- }
466
-
467
- /**
468
- * Registers an MCP resource with the Pikku framework.
469
- * Resources provide data that AI models can access.
470
- *
471
- * @template In - Input type for the resource request
472
- * @param mcpResource - MCP resource definition with data provider function
473
- */
474
- export const wireMCPResource = <In>(
475
- mcpResource: MCPResourceWiring<In>
476
- ) => {
477
- wireMCPResourceCore(mcpResource as any)
478
- }
479
-
480
- /**
481
- * Registers an MCP tool with the Pikku framework.
482
- * Tools are functions that AI models can invoke.
483
- *
484
- * @template In - Input type for the tool invocation
485
- * @param mcpTool - MCP tool definition with action function
486
- */
487
- export const wireMCPTool = <In>(
488
- mcpTool: MCPToolWiring<In>
489
- ) => {
490
- wireMCPToolCore(mcpTool as any)
491
- }
492
-
493
- /**
494
- * Registers an MCP prompt with the Pikku framework.
495
- * Prompts provide templates that AI models can use.
496
- *
497
- * @template In - Input type for the prompt parameters
498
- * @param mcpPrompt - MCP prompt definition with template function
499
- */
500
- export const wireMCPPrompt = <In>(
501
- mcpPrompt: MCPPromptWiring<In>
502
- ) => {
503
- wireMCPPromptCore(mcpPrompt as any)
504
- }
505
-
506
- /**
507
- * Creates a function for handling MCP prompt requests.
508
- * These functions generate prompt templates for AI models.
509
- *
510
- * @template In - Input type for the prompt parameters
511
- * @param func - Function definition, either direct function or configuration object
512
- * @returns The unwrapped function for internal use
513
- *
514
- * @example
515
- * \`\`\`typescript
516
- * const codeReviewPrompt = pikkuMCPPromptFunc<{language: string, code: string}>({
517
- * func: async ({}, input) => ({
518
- * messages: [{
519
- * role: 'user',
520
- * content: {
521
- * type: 'text',
522
- * text: \`Please review this \${input.language} code: \${input.code}\`
523
- * }
524
- * }]
525
- * })
526
- * })
527
- * \`\`\`
528
- */
529
- export const pikkuMCPPromptFunc = <In>(
530
- func:
531
- | PikkuFunctionSessionless<In, MCPPromptResponse>
532
- | {
533
- func: PikkuFunctionSessionless<In, MCPPromptResponse>
534
- name?: string
535
- }
536
- ) => {
537
- return typeof func === 'function' ? { func } : func
538
- }
539
-
540
- /**
541
- * Creates a function for handling MCP tool invocations.
542
- * These functions perform actions that AI models can request.
543
- *
544
- * @template In - Input type for the tool invocation
545
- * @param func - Function definition, either direct function or configuration object
546
- * @returns The unwrapped function for internal use
547
- *
548
- * @example
549
- * \`\`\`typescript
550
- * const searchFiles = pikkuMCPToolFunc<{query: string, directory: string}>({
551
- * func: async ({fileSystem}, input) => {
552
- * const results = await fileSystem.search(input.query, input.directory)
553
- * return [{
554
- * type: 'text',
555
- * text: \`Found \${results.length} files matching "\${input.query}"\`
556
- * }]
557
- * }
558
- * })
559
- * \`\`\`
560
- */
561
- export const pikkuMCPToolFunc = <In>(
562
- func:
563
- | PikkuFunctionSessionless<In, MCPToolResponse, null, true>
564
- | {
565
- func: PikkuFunctionSessionless<In, MCPToolResponse, null, true>
566
- name?: string
567
- }
568
- ) => {
569
- return typeof func === 'function' ? { func } : func
570
- }
571
-
572
- /**
573
- * Creates a function for handling MCP resource requests.
574
- * These functions provide data that AI models can access.
575
- *
576
- * @template In - Input type for the resource request
577
- * @param func - Function definition, either direct function or configuration object
578
- * @returns The unwrapped function for internal use
579
- *
580
- * @example
581
- * \`\`\`typescript
582
- * const getProjectFiles = pikkuMCPResourceFunc<{path: string}>({
583
- * func: async ({ fileSystem }, input) => {
584
- * const fileContent = await fileSystem.readFile(input.path)
585
- * return [{
586
- * uri: \`file://\${input.path}\`,
587
- * mimeType: 'text/plain',
588
- * text: fileContent
589
- * }]
590
- * }
591
- * })
592
- * \`\`\`
593
- */
594
- export const pikkuMCPResourceFunc = <In>(
595
- func:
596
- | PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
597
- | {
598
- func: PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
599
- name?: string
600
- }
601
- ) => {
602
- return typeof func === 'function' ? { func } : func
603
- }
604
- `;
605
- };