@pikku/cli 0.8.3 → 0.9.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 (159) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/bin/pikku-all.ts +47 -33
  3. package/bin/pikku-fetch.ts +1 -1
  4. package/bin/pikku-openapi.ts +2 -2
  5. package/bin/pikku-queue-service.ts +2 -2
  6. package/bin/pikku-websocket.ts +1 -1
  7. package/cli.schema.json +30 -30
  8. package/dist/bin/pikku-all.js +38 -33
  9. package/dist/bin/pikku-fetch.js +1 -1
  10. package/dist/bin/pikku-openapi.js +2 -2
  11. package/dist/bin/pikku-queue-service.js +2 -2
  12. package/dist/bin/pikku-websocket.js +1 -1
  13. package/dist/src/inspector-glob.js +2 -2
  14. package/dist/src/pikku-cli-config.d.ts +17 -17
  15. package/dist/src/pikku-cli-config.js +31 -31
  16. package/dist/src/runtimes/nextjs/pikku-command-nextjs.js +3 -3
  17. package/dist/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +29 -29
  18. package/dist/src/runtimes/nextjs/serialize-nextjs-http-wrapper.js +28 -28
  19. package/dist/src/schema-generator.d.ts +2 -2
  20. package/dist/src/schema-generator.js +2 -2
  21. package/dist/src/serialize-pikku-types.js +67 -67
  22. package/dist/src/utils.d.ts +5 -1
  23. package/dist/src/utils.js +17 -6
  24. package/dist/src/wirings/channels/pikku-channels.js +9 -0
  25. package/dist/src/wirings/channels/pikku-command-channels.js +9 -0
  26. package/dist/src/{events → wirings}/channels/serialize-typed-channel-map.js +3 -3
  27. package/dist/src/{events → wirings}/channels/serialize-websocket-wrapper.js +19 -5
  28. package/dist/src/{events → wirings}/fetch/index.js +2 -2
  29. package/dist/src/{events → wirings}/http/openapi-spec-generator.d.ts +2 -2
  30. package/dist/src/wirings/http/pikku-command-http-map.js +8 -0
  31. package/dist/src/{events → wirings}/http/pikku-command-http-routes.js +3 -3
  32. package/dist/src/{events → wirings}/http/pikku-http-routes.js +3 -3
  33. package/dist/src/wirings/http/serialize-fetch-wrapper.js +67 -0
  34. package/dist/src/wirings/http/serialize-typed-http-map.d.ts +4 -0
  35. package/dist/src/{events → wirings}/http/serialize-typed-http-map.js +13 -13
  36. package/dist/src/{events → wirings}/mcp/pikku-command-mcp.js +3 -3
  37. package/dist/src/wirings/queue/pikku-command-queue-service.js +15 -0
  38. package/dist/src/{events → wirings}/queue/pikku-command-queue.js +3 -3
  39. package/dist/src/{events → wirings}/queue/pikku-queue.js +3 -3
  40. package/dist/src/wirings/rpc/pikku-command-rpc-client.js +15 -0
  41. package/dist/src/wirings/rpc/pikku-command-rpc.js +6 -0
  42. package/dist/src/wirings/rpc/pikku-rpc.js +6 -0
  43. package/dist/src/wirings/rpc/serialize-rpc-wrapper.js +68 -0
  44. package/dist/src/{events → wirings}/scheduler/pikku-command-scheduler.js +3 -3
  45. package/dist/tsconfig.tsbuildinfo +1 -1
  46. package/package.json +3 -3
  47. package/src/inspector-glob.ts +2 -2
  48. package/src/pikku-cli-config.ts +67 -52
  49. package/src/runtimes/nextjs/pikku-command-nextjs.ts +3 -3
  50. package/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +29 -29
  51. package/src/runtimes/nextjs/serialize-nextjs-http-wrapper.ts +28 -28
  52. package/src/schema-generator.ts +3 -3
  53. package/src/serialize-pikku-types.ts +67 -67
  54. package/src/utils.ts +26 -6
  55. package/src/{events → wirings}/channels/pikku-channels.ts +5 -4
  56. package/src/{events → wirings}/channels/pikku-command-channels.ts +5 -4
  57. package/src/{events → wirings}/channels/serialize-typed-channel-map.ts +3 -3
  58. package/src/{events → wirings}/channels/serialize-websocket-wrapper.ts +19 -5
  59. package/src/{events → wirings}/fetch/index.ts +2 -2
  60. package/src/{events → wirings}/http/openapi-spec-generator.ts +3 -3
  61. package/src/{events → wirings}/http/pikku-command-http-map.ts +5 -5
  62. package/src/{events → wirings}/http/pikku-command-http-routes.ts +5 -5
  63. package/src/{events → wirings}/http/pikku-http-routes.ts +5 -5
  64. package/src/wirings/http/serialize-fetch-wrapper.ts +67 -0
  65. package/src/{events → wirings}/http/serialize-typed-http-map.ts +17 -17
  66. package/src/{events → wirings}/mcp/pikku-command-mcp.ts +5 -5
  67. package/src/{events → wirings}/queue/pikku-command-queue-service.ts +9 -6
  68. package/src/{events → wirings}/queue/pikku-command-queue.ts +8 -5
  69. package/src/{events → wirings}/queue/pikku-queue.ts +8 -5
  70. package/src/{events → wirings}/rpc/pikku-command-rpc-client.ts +9 -6
  71. package/src/{events → wirings}/rpc/pikku-command-rpc.ts +2 -2
  72. package/src/{events → wirings}/rpc/pikku-rpc.ts +2 -2
  73. package/src/wirings/rpc/serialize-rpc-wrapper.ts +68 -0
  74. package/src/{events → wirings}/scheduler/pikku-command-scheduler.ts +8 -4
  75. package/dist/src/events/channels/pikku-channels.js +0 -9
  76. package/dist/src/events/channels/pikku-command-channels.js +0 -9
  77. package/dist/src/events/http/pikku-command-http-map.js +0 -8
  78. package/dist/src/events/http/serialize-fetch-wrapper.js +0 -67
  79. package/dist/src/events/http/serialize-typed-http-map.d.ts +0 -4
  80. package/dist/src/events/queue/pikku-command-queue-service.js +0 -12
  81. package/dist/src/events/rpc/pikku-command-rpc-client.js +0 -12
  82. package/dist/src/events/rpc/pikku-command-rpc.js +0 -6
  83. package/dist/src/events/rpc/pikku-rpc.js +0 -6
  84. package/dist/src/events/rpc/serialize-rpc-wrapper.js +0 -29
  85. package/src/events/http/serialize-fetch-wrapper.ts +0 -67
  86. package/src/events/rpc/serialize-rpc-wrapper.ts +0 -29
  87. /package/dist/src/{events → wirings}/channels/pikku-channels.d.ts +0 -0
  88. /package/dist/src/{events → wirings}/channels/pikku-command-channels-map.d.ts +0 -0
  89. /package/dist/src/{events → wirings}/channels/pikku-command-channels-map.js +0 -0
  90. /package/dist/src/{events → wirings}/channels/pikku-command-channels.d.ts +0 -0
  91. /package/dist/src/{events → wirings}/channels/pikku-command-websocket-typed.d.ts +0 -0
  92. /package/dist/src/{events → wirings}/channels/pikku-command-websocket-typed.js +0 -0
  93. /package/dist/src/{events → wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
  94. /package/dist/src/{events → wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
  95. /package/dist/src/{events → wirings}/fetch/index.d.ts +0 -0
  96. /package/dist/src/{events → wirings}/functions/pikku-command-function-types.d.ts +0 -0
  97. /package/dist/src/{events → wirings}/functions/pikku-command-function-types.js +0 -0
  98. /package/dist/src/{events → wirings}/functions/pikku-command-functions.d.ts +0 -0
  99. /package/dist/src/{events → wirings}/functions/pikku-command-functions.js +0 -0
  100. /package/dist/src/{events → wirings}/functions/pikku-command-services.d.ts +0 -0
  101. /package/dist/src/{events → wirings}/functions/pikku-command-services.js +0 -0
  102. /package/dist/src/{events → wirings}/functions/pikku-function-types.d.ts +0 -0
  103. /package/dist/src/{events → wirings}/functions/pikku-function-types.js +0 -0
  104. /package/dist/src/{events → wirings}/functions/pikku-functions.d.ts +0 -0
  105. /package/dist/src/{events → wirings}/functions/pikku-functions.js +0 -0
  106. /package/dist/src/{events → wirings}/http/openapi-spec-generator.js +0 -0
  107. /package/dist/src/{events → wirings}/http/pikku-command-http-map.d.ts +0 -0
  108. /package/dist/src/{events → wirings}/http/pikku-command-http-routes.d.ts +0 -0
  109. /package/dist/src/{events → wirings}/http/pikku-command-openapi.d.ts +0 -0
  110. /package/dist/src/{events → wirings}/http/pikku-command-openapi.js +0 -0
  111. /package/dist/src/{events → wirings}/http/pikku-http-routes.d.ts +0 -0
  112. /package/dist/src/{events → wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
  113. /package/dist/src/{events → wirings}/mcp/pikku-command-mcp-json.d.ts +0 -0
  114. /package/dist/src/{events → wirings}/mcp/pikku-command-mcp-json.js +0 -0
  115. /package/dist/src/{events → wirings}/mcp/pikku-command-mcp.d.ts +0 -0
  116. /package/dist/src/{events → wirings}/mcp/serialize-mcp-json.d.ts +0 -0
  117. /package/dist/src/{events → wirings}/mcp/serialize-mcp-json.js +0 -0
  118. /package/dist/src/{events → wirings}/queue/pikku-command-queue-map.d.ts +0 -0
  119. /package/dist/src/{events → wirings}/queue/pikku-command-queue-map.js +0 -0
  120. /package/dist/src/{events → wirings}/queue/pikku-command-queue-service.d.ts +0 -0
  121. /package/dist/src/{events → wirings}/queue/pikku-command-queue.d.ts +0 -0
  122. /package/dist/src/{events → wirings}/queue/pikku-queue-map.d.ts +0 -0
  123. /package/dist/src/{events → wirings}/queue/pikku-queue-map.js +0 -0
  124. /package/dist/src/{events → wirings}/queue/pikku-queue.d.ts +0 -0
  125. /package/dist/src/{events → wirings}/queue/serialize-queue-map.d.ts +0 -0
  126. /package/dist/src/{events → wirings}/queue/serialize-queue-map.js +0 -0
  127. /package/dist/src/{events → wirings}/queue/serialize-queue-meta.d.ts +0 -0
  128. /package/dist/src/{events → wirings}/queue/serialize-queue-meta.js +0 -0
  129. /package/dist/src/{events → wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
  130. /package/dist/src/{events → wirings}/queue/serialize-queue-wrapper.js +0 -0
  131. /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-client.d.ts +0 -0
  132. /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-map.d.ts +0 -0
  133. /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-map.js +0 -0
  134. /package/dist/src/{events → wirings}/rpc/pikku-command-rpc.d.ts +0 -0
  135. /package/dist/src/{events → wirings}/rpc/pikku-rpc.d.ts +0 -0
  136. /package/dist/src/{events → wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
  137. /package/dist/src/{events → wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
  138. /package/dist/src/{events → wirings}/rpc/serialize-typed-rpc-map.js +0 -0
  139. /package/dist/src/{events → wirings}/scheduler/pikku-command-scheduler.d.ts +0 -0
  140. /package/dist/src/{events → wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
  141. /package/dist/src/{events → wirings}/scheduler/serialize-scheduler-meta.js +0 -0
  142. /package/src/{events → wirings}/channels/pikku-command-channels-map.ts +0 -0
  143. /package/src/{events → wirings}/channels/pikku-command-websocket-typed.ts +0 -0
  144. /package/src/{events → wirings}/functions/pikku-command-function-types.ts +0 -0
  145. /package/src/{events → wirings}/functions/pikku-command-functions.ts +0 -0
  146. /package/src/{events → wirings}/functions/pikku-command-services.ts +0 -0
  147. /package/src/{events → wirings}/functions/pikku-function-types.ts +0 -0
  148. /package/src/{events → wirings}/functions/pikku-functions.ts +0 -0
  149. /package/src/{events → wirings}/http/pikku-command-openapi.ts +0 -0
  150. /package/src/{events → wirings}/mcp/pikku-command-mcp-json.ts +0 -0
  151. /package/src/{events → wirings}/mcp/serialize-mcp-json.ts +0 -0
  152. /package/src/{events → wirings}/queue/pikku-command-queue-map.ts +0 -0
  153. /package/src/{events → wirings}/queue/pikku-queue-map.ts +0 -0
  154. /package/src/{events → wirings}/queue/serialize-queue-map.ts +0 -0
  155. /package/src/{events → wirings}/queue/serialize-queue-meta.ts +0 -0
  156. /package/src/{events → wirings}/queue/serialize-queue-wrapper.ts +0 -0
  157. /package/src/{events → wirings}/rpc/pikku-command-rpc-map.ts +0 -0
  158. /package/src/{events → wirings}/rpc/serialize-typed-rpc-map.ts +0 -0
  159. /package/src/{events → wirings}/scheduler/serialize-scheduler-meta.ts +0 -0
@@ -6,13 +6,13 @@ export const serializePikkuTypes = (userSessionTypeImport, userSessionTypeName,
6
6
  * This is used to provide the application types in the typescript project
7
7
  */
8
8
 
9
- import { CoreAPIPermission, PikkuMiddleware } from '@pikku/core'
10
- import { CoreAPIFunction, CoreAPIFunctionSessionless } from '@pikku/core/function'
11
- import { CoreHTTPFunctionRoute, AssertRouteParams, addHTTPRoute as addCoreHTTPRoute } from '@pikku/core/http'
12
- import { CoreScheduledTask, addScheduledTask as addCoreScheduledTask } from '@pikku/core/scheduler'
13
- import { CoreAPIChannel, PikkuChannel, addChannel as addCoreChannel } from '@pikku/core/channel'
14
- import { CoreQueueWorker, addQueueWorker as addCoreQueueWorker } from '@pikku/core/queue'
15
- import { CoreMCPResource, CoreMCPTool, CoreMCPPrompt, addMCPResource as addCoreMCPResource, addMCPTool as addCoreMCPTool, addMCPPrompt as addCoreMCPPrompt, MCPResourceResponse, MCPToolResponse, MCPPromptResponse, PikkuMCP } from '@pikku/core'
9
+ import { CorePikkuPermission, PikkuMiddleware } 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
16
 
17
17
  ${userSessionTypeImport}
18
18
  ${singletonServicesTypeImport}
@@ -26,11 +26,11 @@ ${rpcMapTypeImport}
26
26
  * @template In - The input type that the permission check will receive
27
27
  * @template RequiredServices - The services required for this permission check
28
28
  */
29
- export type APIPermission<In = unknown, RequiredServices extends ${singletonServicesTypeName} = ${singletonServicesTypeName}> = CoreAPIPermission<In, RequiredServices, ${userSessionTypeName}>
29
+ export type PikkuPermission<In = unknown, RequiredServices extends ${singletonServicesTypeName} = ${singletonServicesTypeName}> = CorePikkuPermission<In, RequiredServices, ${userSessionTypeName}>
30
30
 
31
31
  /**
32
32
  * Type-safe middleware definition that can access your application's services and session.
33
- * Use this to define reusable middleware that can be applied to multiple routes.
33
+ * Use this to define reusable middleware that can be applied to multiple HTTP wirings.
34
34
  *
35
35
  * @template RequiredServices - The services required for this middleware
36
36
  */
@@ -46,7 +46,7 @@ export type APIMiddleware<RequiredServices extends ${singletonServicesTypeName}
46
46
  * @template MCPData - MCP data type (null = optional MCP)
47
47
  * @template RequiredServices - Services required by this function
48
48
  */
49
- type APIFunctionSessionless<
49
+ type PikkuFunctionSessionless<
50
50
  In = unknown,
51
51
  Out = never,
52
52
  ChannelData = null, // null means optional channel
@@ -60,7 +60,7 @@ type APIFunctionSessionless<
60
60
  ? { mcp?: PikkuMCP } // Optional MCP
61
61
  : { mcp: PikkuMCP } // Required MCP
62
62
  )
63
- > = CoreAPIFunctionSessionless<In, Out, ChannelData, RequiredServices, ${userSessionTypeName}>
63
+ > = CorePikkuFunctionSessionless<In, Out, ChannelData, RequiredServices, ${userSessionTypeName}>
64
64
 
65
65
  /**
66
66
  * A session-aware API function that requires user authentication.
@@ -72,7 +72,7 @@ type APIFunctionSessionless<
72
72
  * @template MCPData - MCP data type (null = optional MCP)
73
73
  * @template RequiredServices - Services required by this function
74
74
  */
75
- type APIFunction<
75
+ type PikkuFunction<
76
76
  In = unknown,
77
77
  Out = never,
78
78
  ChannelData = null, // null means optional channel
@@ -86,17 +86,17 @@ type APIFunction<
86
86
  ? { mcp?: PikkuMCP } // Optional MCP
87
87
  : { mcp: PikkuMCP } // Required MCP
88
88
  )
89
- > = CoreAPIFunction<In, Out, ChannelData, RequiredServices, ${userSessionTypeName}>
89
+ > = CorePikkuFunction<In, Out, ChannelData, RequiredServices, ${userSessionTypeName}>
90
90
 
91
91
  /**
92
- * Type definition for HTTP API routes with type-safe path parameters.
92
+ * Type definition for HTTP API wirings with type-safe path parameters.
93
93
  * Supports both authenticated and unauthenticated functions.
94
94
  *
95
- * @template In - Input type for the route
96
- * @template Out - Output type for the route
97
- * @template Route - String literal type for the route path (e.g., "/users/:id")
95
+ * @template In - Input type for the HTTP wiring
96
+ * @template Out - Output type for the HTTP wiring
97
+ * @template Route - String literal type for the HTTP path (e.g., "/users/:id")
98
98
  */
99
- type APIRoute<In, Out, Route extends string> = CoreHTTPFunctionRoute<In, Out, Route, APIFunction<In, Out>, APIFunctionSessionless<In, Out>, APIPermission<In>, APIMiddleware>
99
+ type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out>, PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, APIMiddleware>
100
100
 
101
101
  /**
102
102
  * Type definition for WebSocket channels with typed data exchange.
@@ -105,13 +105,13 @@ type APIRoute<In, Out, Route extends string> = CoreHTTPFunctionRoute<In, Out, Ro
105
105
  * @template ChannelData - Type of data exchanged through the channel
106
106
  * @template Channel - String literal type for the channel name
107
107
  */
108
- type APIChannel<ChannelData, Channel extends string> = CoreAPIChannel<ChannelData, Channel, APIFunction<void, unknown> | APIFunction<void, unknown, ChannelData>, APIFunction<void, void> | APIFunction<void, void, ChannelData>, APIFunction<any, any> | APIFunction<any, any, ChannelData>, APIPermission>
108
+ type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<ChannelData, Channel, PikkuFunction<void, unknown> | PikkuFunction<void, unknown, ChannelData>, PikkuFunction<void, void> | PikkuFunction<void, void, ChannelData>, PikkuFunction<any, any> | PikkuFunction<any, any, ChannelData>, PikkuPermission>
109
109
 
110
110
  /**
111
111
  * Type definition for scheduled tasks that run at specified intervals.
112
112
  * These are sessionless functions that execute based on cron expressions.
113
113
  */
114
- type ScheduledTask = CoreScheduledTask<APIFunctionSessionless<void, void>>
114
+ type SchedulerWiring = CoreScheduledTask<PikkuFunctionSessionless<void, void>>
115
115
 
116
116
  /**
117
117
  * Type definition for queue workers that process background jobs.
@@ -119,28 +119,28 @@ type ScheduledTask = CoreScheduledTask<APIFunctionSessionless<void, void>>
119
119
  * @template In - Input type for the queue job
120
120
  * @template Out - Output type for the queue job
121
121
  */
122
- type QueueWorker<In, Out> = CoreQueueWorker<APIFunctionSessionless<In, Out>>
122
+ type QueueWiring<In, Out> = CoreQueueWorker<PikkuFunctionSessionless<In, Out>>
123
123
 
124
124
  /**
125
125
  * Type definition for MCP resources that provide data to AI models.
126
126
  *
127
127
  * @template In - Input type for the resource request
128
128
  */
129
- type MCPResource<In> = CoreMCPResource<APIFunctionSessionless<In, MCPResourceResponse, null, true>>
129
+ type MCPResourceWiring<In> = CoreMCPResource<PikkuFunctionSessionless<In, MCPResourceResponse, null, true>>
130
130
 
131
131
  /**
132
132
  * Type definition for MCP tools that AI models can invoke.
133
133
  *
134
134
  * @template In - Input type for the tool invocation
135
135
  */
136
- type MCPTool<In> = CoreMCPTool<APIFunctionSessionless<In, MCPToolResponse, null, true>>
136
+ type MCPToolWiring<In> = CoreMCPTool<PikkuFunctionSessionless<In, MCPToolResponse, null, true>>
137
137
 
138
138
  /**
139
139
  * Type definition for MCP prompts that provide templates to AI models.
140
140
  *
141
141
  * @template In - Input type for the prompt parameters
142
142
  */
143
- type MCPPrompt<In> = CoreMCPPrompt<APIFunctionSessionless<In, MCPPromptResponse, null, true>>
143
+ type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionSessionless<In, MCPPromptResponse, null, true>>
144
144
 
145
145
  /**
146
146
  * Creates a Pikku function that can be either session-aware or sessionless.
@@ -165,14 +165,14 @@ type MCPPrompt<In> = CoreMCPPrompt<APIFunctionSessionless<In, MCPPromptResponse,
165
165
  */
166
166
  export const pikkuFunc = <In, Out = unknown>(
167
167
  func:
168
- | APIFunction<In, Out>
168
+ | PikkuFunction<In, Out>
169
169
  | {
170
- func: APIFunction<In, Out>
170
+ func: PikkuFunction<In, Out>
171
171
  auth?: true
172
172
  name?: string
173
173
  }
174
174
  | {
175
- func: APIFunctionSessionless<In, Out>
175
+ func: PikkuFunctionSessionless<In, Out>
176
176
  auth: false
177
177
  name?: string
178
178
  }
@@ -202,9 +202,9 @@ export const pikkuFunc = <In, Out = unknown>(
202
202
  */
203
203
  export const pikkuSessionlessFunc = <In, Out = unknown>(
204
204
  func:
205
- | APIFunctionSessionless<In, Out>
205
+ | PikkuFunctionSessionless<In, Out>
206
206
  | {
207
- func: APIFunctionSessionless<In, Out>
207
+ func: PikkuFunctionSessionless<In, Out>
208
208
  name?: string
209
209
  }
210
210
  ) => {
@@ -233,9 +233,9 @@ export const pikkuSessionlessFunc = <In, Out = unknown>(
233
233
  */
234
234
  export const pikkuChannelConnectionFunc = <Out = unknown, ChannelData = unknown>(
235
235
  func:
236
- | APIFunctionSessionless<void, Out, ChannelData>
236
+ | PikkuFunctionSessionless<void, Out, ChannelData>
237
237
  | {
238
- func: APIFunctionSessionless<void, Out, ChannelData>
238
+ func: PikkuFunctionSessionless<void, Out, ChannelData>
239
239
  name?: string
240
240
  }
241
241
  ) => {
@@ -262,9 +262,9 @@ export const pikkuChannelConnectionFunc = <Out = unknown, ChannelData = unknown>
262
262
  */
263
263
  export const pikkuChannelDisconnectionFunc = <ChannelData = unknown>(
264
264
  func:
265
- | APIFunctionSessionless<void, void, ChannelData>
265
+ | PikkuFunctionSessionless<void, void, ChannelData>
266
266
  | {
267
- func: APIFunction<void, void, ChannelData>
267
+ func: PikkuFunction<void, void, ChannelData>
268
268
  name?: string
269
269
  }
270
270
  ) => {
@@ -292,9 +292,9 @@ export const pikkuChannelDisconnectionFunc = <ChannelData = unknown>(
292
292
  */
293
293
  export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unknown>(
294
294
  func:
295
- | APIFunctionSessionless<In, Out, ChannelData>
295
+ | PikkuFunctionSessionless<In, Out, ChannelData>
296
296
  | {
297
- func: APIFunctionSessionless<In, Out, ChannelData>
297
+ func: PikkuFunctionSessionless<In, Out, ChannelData>
298
298
  name?: string
299
299
  }
300
300
  ) => {
@@ -319,9 +319,9 @@ export const pikkuChannelFunc = <In = unknown, Out = unknown, ChannelData = unkn
319
319
  */
320
320
  export const pikkuVoidFunc = (
321
321
  func:
322
- | APIFunctionSessionless<void, void>
322
+ | PikkuFunctionSessionless<void, void>
323
323
  | {
324
- func: APIFunctionSessionless<void, void>
324
+ func: PikkuFunctionSessionless<void, void>
325
325
  name?: string
326
326
  }
327
327
  ) => {
@@ -335,24 +335,24 @@ export const pikkuVoidFunc = (
335
335
  * @template Channel - String literal type for the channel name
336
336
  * @param channel - Channel definition with connection, disconnection, and message handlers
337
337
  */
338
- export const addChannel = <ChannelData, Channel extends string>(
339
- channel: APIChannel<ChannelData, Channel> & AssertRouteParams<ChannelData, Channel>
338
+ export const wireChannel = <ChannelData, Channel extends string>(
339
+ channel: ChannelWiring<ChannelData, Channel> & AssertHTTPWiringParams<ChannelData, Channel>
340
340
  ) => {
341
- addCoreChannel(channel as any) // TODO
341
+ wireChannelCore(channel as any) // TODO
342
342
  }
343
343
 
344
344
  /**
345
- * Registers an HTTP route with the Pikku framework.
345
+ * Registers an HTTP wiring with the Pikku framework.
346
346
  *
347
- * @template In - Input type for the route
348
- * @template Out - Output type for the route
349
- * @template Route - String literal type for the route path (e.g., "/users/:id")
350
- * @param route - Route definition with handler, method, and optional middleware
347
+ * @template In - Input type for the HTTP wiring
348
+ * @template Out - Output type for the HTTP wiring
349
+ * @template Route - String literal type for the HTTP path (e.g., "/users/:id")
350
+ * @param httpWiring - HTTP wiring definition with handler, method, and optional middleware
351
351
  */
352
- export const addHTTPRoute = <In, Out, Route extends string>(
353
- route: APIRoute<In, Out, Route> & AssertRouteParams<In, Route>
352
+ export const wireHTTP = <In, Out, Route extends string>(
353
+ httpWiring: HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>
354
354
  ) => {
355
- addCoreHTTPRoute(route)
355
+ wireHTTPCore(httpWiring)
356
356
  }
357
357
 
358
358
  /**
@@ -361,8 +361,8 @@ export const addHTTPRoute = <In, Out, Route extends string>(
361
361
  *
362
362
  * @param task - Scheduled task definition with cron expression and handler
363
363
  */
364
- export const addScheduledTask = (task: ScheduledTask) => {
365
- addCoreScheduledTask(task as any) // TODO
364
+ export const wireScheduler = (task: SchedulerWiring) => {
365
+ wireSchedulerCore(task as any) // TODO
366
366
  }
367
367
 
368
368
  /**
@@ -371,8 +371,8 @@ export const addScheduledTask = (task: ScheduledTask) => {
371
371
  *
372
372
  * @param queueWorker - Queue worker definition with job handler
373
373
  */
374
- export const addQueueWorker = (queueWorker: QueueWorker<any, any>) => {
375
- addCoreQueueWorker(queueWorker as any) // TODO
374
+ export const wireQueueWorker = (queueWorker: QueueWiring<any, any>) => {
375
+ wireQueueWorkerCore(queueWorker as any) // TODO
376
376
  }
377
377
 
378
378
  /**
@@ -382,10 +382,10 @@ export const addQueueWorker = (queueWorker: QueueWorker<any, any>) => {
382
382
  * @template In - Input type for the resource request
383
383
  * @param mcpResource - MCP resource definition with data provider function
384
384
  */
385
- export const addMCPResource = <In>(
386
- mcpResource: MCPResource<In>
385
+ export const wireMCPResource = <In>(
386
+ mcpResource: MCPResourceWiring<In>
387
387
  ) => {
388
- addCoreMCPResource(mcpResource as any)
388
+ wireMCPResourceCore(mcpResource as any)
389
389
  }
390
390
 
391
391
  /**
@@ -395,10 +395,10 @@ export const addMCPResource = <In>(
395
395
  * @template In - Input type for the tool invocation
396
396
  * @param mcpTool - MCP tool definition with action function
397
397
  */
398
- export const addMCPTool = <In>(
399
- mcpTool: MCPTool<In>
398
+ export const wireMCPTool = <In>(
399
+ mcpTool: MCPToolWiring<In>
400
400
  ) => {
401
- addCoreMCPTool(mcpTool as any)
401
+ wireMCPToolCore(mcpTool as any)
402
402
  }
403
403
 
404
404
  /**
@@ -408,10 +408,10 @@ export const addMCPTool = <In>(
408
408
  * @template In - Input type for the prompt parameters
409
409
  * @param mcpPrompt - MCP prompt definition with template function
410
410
  */
411
- export const addMCPPrompt = <In>(
412
- mcpPrompt: MCPPrompt<In>
411
+ export const wireMCPPrompt = <In>(
412
+ mcpPrompt: MCPPromptWiring<In>
413
413
  ) => {
414
- addCoreMCPPrompt(mcpPrompt as any)
414
+ wireMCPPromptCore(mcpPrompt as any)
415
415
  }
416
416
 
417
417
  /**
@@ -439,9 +439,9 @@ export const addMCPPrompt = <In>(
439
439
  */
440
440
  export const pikkuMCPPromptFunc = <In>(
441
441
  func:
442
- | APIFunctionSessionless<In, MCPPromptResponse>
442
+ | PikkuFunctionSessionless<In, MCPPromptResponse>
443
443
  | {
444
- func: APIFunctionSessionless<In, MCPPromptResponse>
444
+ func: PikkuFunctionSessionless<In, MCPPromptResponse>
445
445
  name?: string
446
446
  }
447
447
  ) => {
@@ -471,9 +471,9 @@ export const pikkuMCPPromptFunc = <In>(
471
471
  */
472
472
  export const pikkuMCPToolFunc = <In>(
473
473
  func:
474
- | APIFunctionSessionless<In, MCPToolResponse, null, true>
474
+ | PikkuFunctionSessionless<In, MCPToolResponse, null, true>
475
475
  | {
476
- func: APIFunctionSessionless<In, MCPToolResponse, null, true>
476
+ func: PikkuFunctionSessionless<In, MCPToolResponse, null, true>
477
477
  name?: string
478
478
  }
479
479
  ) => {
@@ -504,9 +504,9 @@ export const pikkuMCPToolFunc = <In>(
504
504
  */
505
505
  export const pikkuMCPResourceFunc = <In>(
506
506
  func:
507
- | APIFunctionSessionless<In, MCPResourceResponse, null, true>
507
+ | PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
508
508
  | {
509
- func: APIFunctionSessionless<In, MCPResourceResponse, null, true>
509
+ func: PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
510
510
  name?: string
511
511
  }
512
512
  ) => {
@@ -1,7 +1,9 @@
1
1
  import { InspectorState, TypesMap } from '@pikku/inspector';
2
2
  export declare class CLILogger {
3
- constructor({ logLogo }: {
3
+ private silent;
4
+ constructor({ logLogo, silent, }: {
4
5
  logLogo: boolean;
6
+ silent?: boolean;
5
7
  });
6
8
  primary(message: string): void;
7
9
  success(message: string): void;
@@ -9,6 +11,7 @@ export declare class CLILogger {
9
11
  error(message: string): void;
10
12
  warn(message: string): void;
11
13
  debug(message: string): void;
14
+ timing(message: string): void;
12
15
  private logPikkuLogo;
13
16
  }
14
17
  export declare const getFileImportRelativePath: (from: string, to: string, packageMappings: Record<string, string>) => string;
@@ -36,6 +39,7 @@ export interface PikkuCLIOptions {
36
39
  tags?: string[];
37
40
  types?: string[];
38
41
  directories?: string[];
42
+ silent?: boolean;
39
43
  }
40
44
  export declare const getPikkuFilesAndMethods: (logger: CLILogger, { singletonServicesTypeImportMap, sessionServicesTypeImportMap, userSessionTypeImportMap, sessionServicesFactories, singletonServicesFactories, configFactories, }: InspectorState, packageMappings: Record<string, string>, outputFile: string, { configFileType, singletonServicesFactoryType, sessionServicesFactoryType, }: PikkuCLIOptions, requires?: Partial<{
41
45
  config: boolean;
package/dist/src/utils.js CHANGED
@@ -13,19 +13,27 @@ const logo = `
13
13
  |_| |_|_| \_)_| \_)____/
14
14
  `;
15
15
  export class CLILogger {
16
- constructor({ logLogo }) {
17
- if (logLogo) {
16
+ silent;
17
+ constructor({ logLogo, silent = false, }) {
18
+ this.silent = silent;
19
+ if (logLogo && !silent) {
18
20
  this.logPikkuLogo();
19
21
  }
20
22
  }
21
23
  primary(message) {
22
- console.log(chalk.green(message));
24
+ if (!this.silent) {
25
+ console.log(chalk.green(message));
26
+ }
23
27
  }
24
28
  success(message) {
25
- console.log(chalk.green(message));
29
+ if (!this.silent) {
30
+ console.log(chalk.green(message));
31
+ }
26
32
  }
27
33
  info(message) {
28
- console.log(chalk.blue(message));
34
+ if (!this.silent) {
35
+ console.log(chalk.blue(message));
36
+ }
29
37
  }
30
38
  error(message) {
31
39
  console.error(chalk.red(message));
@@ -34,10 +42,13 @@ export class CLILogger {
34
42
  console.error(chalk.yellow(message));
35
43
  }
36
44
  debug(message) {
37
- if (process.env.DEBUG) {
45
+ if (process.env.DEBUG && !this.silent) {
38
46
  console.log(chalk.gray(message));
39
47
  }
40
48
  }
49
+ timing(message) {
50
+ console.log(chalk.gray(message));
51
+ }
41
52
  logPikkuLogo() {
42
53
  this.primary(logo);
43
54
  const packageJson = JSON.parse(readFileSync(`${dirname(__filename)}/../../package.json`, 'utf-8'));
@@ -0,0 +1,9 @@
1
+ import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
2
+ export const pikkuChannels = async (logger, cliConfig, visitState) => {
3
+ return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
4
+ const { channelsWiringFile, channelsWiringMetaFile, packageMappings } = cliConfig;
5
+ const { channels } = visitState;
6
+ await writeFileInDir(logger, channelsWiringFile, serializeFileImports('addChannel', channelsWiringFile, channels.files, packageMappings));
7
+ await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`);
8
+ });
9
+ };
@@ -0,0 +1,9 @@
1
+ import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
2
+ export const pikkuChannels = async (logger, cliConfig, visitState) => {
3
+ return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
4
+ const { channelsWiringFile, channelsWiringMetaFile, packageMappings } = cliConfig;
5
+ const { channels } = visitState;
6
+ await writeFileInDir(logger, channelsWiringFile, serializeFileImports('addChannel', channelsWiringFile, channels.files, packageMappings));
7
+ await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`);
8
+ });
9
+ };
@@ -28,7 +28,7 @@ export type ChannelDefaultHandlerOf<Channel extends keyof ChannelsMap> =
28
28
  ? ChannelHandler<I, O>
29
29
  : never;
30
30
 
31
- export type ChannelRouteHandlerOf<
31
+ export type ChannelWiringHandlerOf<
32
32
  Channel extends keyof ChannelsMap,
33
33
  Route extends keyof ChannelsMap[Channel]['routes'],
34
34
  Method extends keyof ChannelsMap[Channel]['routes'][Route],
@@ -42,7 +42,7 @@ function generateChannels(functionsMeta, channelsMeta) {
42
42
  const requiredTypes = new Set();
43
43
  const channelsObject = {};
44
44
  for (const meta of Object.values(channelsMeta)) {
45
- const { name, messageRoutes, message } = meta;
45
+ const { name, messageWirings, message } = meta;
46
46
  if (!channelsObject[name]) {
47
47
  channelsObject[name] = { message: null, routes: {} };
48
48
  }
@@ -60,7 +60,7 @@ function generateChannels(functionsMeta, channelsMeta) {
60
60
  inputTypes?.forEach((type) => requiredTypes.add(type));
61
61
  outputTypes?.forEach((type) => requiredTypes.add(type));
62
62
  }
63
- for (const [key, route] of Object.entries(messageRoutes)) {
63
+ for (const [key, route] of Object.entries(messageWirings)) {
64
64
  if (!channelsObject[name].routes[key]) {
65
65
  channelsObject[name].routes[key] = {};
66
66
  }
@@ -1,11 +1,11 @@
1
1
  export const serializeWebsocketWrapper = (channelsMapPath) => {
2
2
  return `import { CorePikkuWebsocket, CorePikkuRouteHandler } from '@pikku/websocket'
3
- import { ChannelDefaultHandlerOf, ChannelRouteHandlerOf, ChannelsMap } from '${channelsMapPath}';
3
+ import { ChannelDefaultHandlerOf, ChannelWiringHandlerOf, ChannelsMap } from '${channelsMapPath}';
4
4
 
5
5
  class PikkuWebSocketRoute<Channel extends keyof ChannelsMap, Route extends keyof ChannelsMap[Channel]['routes']> extends CorePikkuRouteHandler {
6
6
  public subscribe<
7
7
  Method extends keyof ChannelsMap[Channel]['routes'][Route],
8
- Data extends ChannelRouteHandlerOf<Channel, Route, Method>['output']
8
+ Data extends ChannelWiringHandlerOf<Channel, Route, Method>['output']
9
9
  >(method: Method, callback: (data: Data) => void
10
10
  ) {
11
11
  super.subscribe(method.toString(), callback)
@@ -13,20 +13,20 @@ class PikkuWebSocketRoute<Channel extends keyof ChannelsMap, Route extends keyof
13
13
 
14
14
  public unsubscribe<
15
15
  Method extends keyof ChannelsMap[Channel]['routes'][Route],
16
- Data extends ChannelRouteHandlerOf<Channel, Route, Method>['output']
16
+ Data extends ChannelWiringHandlerOf<Channel, Route, Method>['output']
17
17
  >(method: Method, callback?: (data: Data) => void) {
18
18
  super.unsubscribe(method.toString(), callback)
19
19
  }
20
20
 
21
21
  public send<
22
22
  Method extends keyof ChannelsMap[Channel]['routes'][Route],
23
- Data extends ChannelRouteHandlerOf<Channel, Route, Method>['input']
23
+ Data extends ChannelWiringHandlerOf<Channel, Route, Method>['input']
24
24
  >(method: Method, data: Data) {
25
25
  super.send(method.toString(), data)
26
26
  }
27
27
  }
28
28
 
29
- export class PikkuWebSocket<Channel extends keyof ChannelsMap> extends CorePikkuWebsocket {
29
+ export class PikkuWebSocket<Channel extends keyof ChannelsMap, EventHubTopics extends Record<string, any> = {}> extends CorePikkuWebsocket {
30
30
  /**
31
31
  * Send a message to a specific route and method.
32
32
  * Validates the input data type.
@@ -56,6 +56,20 @@ export class PikkuWebSocket<Channel extends keyof ChannelsMap> extends CorePikku
56
56
  public send(data: ChannelDefaultHandlerOf<Channel>['input']) {
57
57
  super.send(data)
58
58
  }
59
+
60
+ /**
61
+ * Subscribe to a topic from the EventHub system with strong typing.
62
+ */
63
+ public subscribeToEventHub<Topic extends keyof EventHubTopics>(
64
+ topic: Topic,
65
+ callback: (data: EventHubTopics[Topic]) => void
66
+ ) {
67
+ super.subscribe((data) => {
68
+ if (data.topic === topic) {
69
+ callback(data as EventHubTopics[Topic])
70
+ }
71
+ })
72
+ }
59
73
  }
60
74
  `;
61
75
  };
@@ -1,11 +1,11 @@
1
1
  import { serializeFetchWrapper } from '../http/serialize-fetch-wrapper.js';
2
2
  import { getFileImportRelativePath, logCommandInfoAndTime, writeFileInDir, } from '../../utils.js';
3
- export const pikkuFetch = async (logger, { fetchFile, httpRoutesMapDeclarationFile, packageMappings }) => {
3
+ export const pikkuFetch = async (logger, { fetchFile, httpMapDeclarationFile, packageMappings }) => {
4
4
  return await logCommandInfoAndTime(logger, 'Generating fetch wrapper', 'Generated fetch wrapper', [fetchFile === undefined, "fetchFile isn't set in the pikku config"], async () => {
5
5
  if (!fetchFile) {
6
6
  throw new Error("fetchFile is isn't set in the pikku config");
7
7
  }
8
- const routesMapDeclarationPath = getFileImportRelativePath(fetchFile, httpRoutesMapDeclarationFile, packageMappings);
8
+ const routesMapDeclarationPath = getFileImportRelativePath(fetchFile, httpMapDeclarationFile, packageMappings);
9
9
  const content = [serializeFetchWrapper(routesMapDeclarationPath)];
10
10
  await writeFileInDir(logger, fetchFile, content.join('\n'));
11
11
  });
@@ -1,4 +1,4 @@
1
- import { FunctionsMeta, HTTPRoutesMeta } from '@pikku/core';
1
+ import { FunctionsMeta, HTTPWiringsMeta } from '@pikku/core';
2
2
  interface OpenAPISpec {
3
3
  openapi: string;
4
4
  info: {
@@ -75,5 +75,5 @@ export interface OpenAPISpecInfo {
75
75
  [key: string]: any[];
76
76
  }[];
77
77
  }
78
- export declare function generateOpenAPISpec(functionsMeta: FunctionsMeta, routeMeta: HTTPRoutesMeta, schemas: Record<string, any>, additionalInfo: OpenAPISpecInfo): Promise<OpenAPISpec>;
78
+ export declare function generateOpenAPISpec(functionsMeta: FunctionsMeta, routeMeta: HTTPWiringsMeta, schemas: Record<string, any>, additionalInfo: OpenAPISpecInfo): Promise<OpenAPISpec>;
79
79
  export {};
@@ -0,0 +1,8 @@
1
+ import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js';
2
+ import { serializeTypedHTTPWiringsMap } from './serialize-typed-http-map.js';
3
+ export const pikkuHTTPMap = async (logger, { httpMapDeclarationFile, packageMappings }, { http, functions }) => {
4
+ return await logCommandInfoAndTime(logger, 'Creating HTTP map', 'Created HTTP map', [http.files.size === 0], async () => {
5
+ const content = serializeTypedHTTPWiringsMap(httpMapDeclarationFile, packageMappings, functions.typesMap, functions.meta, http.meta, http.metaInputTypes);
6
+ await writeFileInDir(logger, httpMapDeclarationFile, content);
7
+ });
8
+ };
@@ -1,9 +1,9 @@
1
1
  import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
2
2
  export const pikkuHTTP = async (logger, cliConfig, visitState) => {
3
3
  return await logCommandInfoAndTime(logger, 'Finding HTTP routes', 'Found HTTP routes', [visitState.http.files.size === 0], async () => {
4
- const { httpRoutesFile, httpRoutesMetaFile, packageMappings } = cliConfig;
4
+ const { httpWiringsFile, httpWiringMetaFile, packageMappings } = cliConfig;
5
5
  const { http } = visitState;
6
- await writeFileInDir(logger, httpRoutesFile, serializeFileImports('addHTTPRoute', httpRoutesFile, http.files, packageMappings));
7
- await writeFileInDir(logger, httpRoutesMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
6
+ await writeFileInDir(logger, httpWiringsFile, serializeFileImports('wireHTTP', httpWiringsFile, http.files, packageMappings));
7
+ await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
8
8
  });
9
9
  };
@@ -1,9 +1,9 @@
1
1
  import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
2
2
  export const pikkuHTTP = async (logger, cliConfig, visitState) => {
3
3
  return await logCommandInfoAndTime(logger, 'Finding HTTP routes', 'Found HTTP routes', [visitState.http.files.size === 0], async () => {
4
- const { httpRoutesFile, httpRoutesMetaFile, packageMappings } = cliConfig;
4
+ const { httpWiringsFile, httpWiringMetaFile, packageMappings } = cliConfig;
5
5
  const { http } = visitState;
6
- await writeFileInDir(logger, httpRoutesFile, serializeFileImports('addHTTPRoute', httpRoutesFile, http.files, packageMappings));
7
- await writeFileInDir(logger, httpRoutesMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
6
+ await writeFileInDir(logger, httpWiringsFile, serializeFileImports('wireHTTP', httpWiringsFile, http.files, packageMappings));
7
+ await writeFileInDir(logger, httpWiringMetaFile, `import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`);
8
8
  });
9
9
  };