@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.
- package/CHANGELOG.md +16 -0
- package/bin/pikku-all.ts +47 -33
- package/bin/pikku-fetch.ts +1 -1
- package/bin/pikku-openapi.ts +2 -2
- package/bin/pikku-queue-service.ts +2 -2
- package/bin/pikku-websocket.ts +1 -1
- package/cli.schema.json +30 -30
- package/dist/bin/pikku-all.js +38 -33
- package/dist/bin/pikku-fetch.js +1 -1
- package/dist/bin/pikku-openapi.js +2 -2
- package/dist/bin/pikku-queue-service.js +2 -2
- package/dist/bin/pikku-websocket.js +1 -1
- package/dist/src/inspector-glob.js +2 -2
- package/dist/src/pikku-cli-config.d.ts +17 -17
- package/dist/src/pikku-cli-config.js +31 -31
- package/dist/src/runtimes/nextjs/pikku-command-nextjs.js +3 -3
- package/dist/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +29 -29
- package/dist/src/runtimes/nextjs/serialize-nextjs-http-wrapper.js +28 -28
- package/dist/src/schema-generator.d.ts +2 -2
- package/dist/src/schema-generator.js +2 -2
- package/dist/src/serialize-pikku-types.js +67 -67
- package/dist/src/utils.d.ts +5 -1
- package/dist/src/utils.js +17 -6
- package/dist/src/wirings/channels/pikku-channels.js +9 -0
- package/dist/src/wirings/channels/pikku-command-channels.js +9 -0
- package/dist/src/{events → wirings}/channels/serialize-typed-channel-map.js +3 -3
- package/dist/src/{events → wirings}/channels/serialize-websocket-wrapper.js +19 -5
- package/dist/src/{events → wirings}/fetch/index.js +2 -2
- package/dist/src/{events → wirings}/http/openapi-spec-generator.d.ts +2 -2
- package/dist/src/wirings/http/pikku-command-http-map.js +8 -0
- package/dist/src/{events → wirings}/http/pikku-command-http-routes.js +3 -3
- package/dist/src/{events → wirings}/http/pikku-http-routes.js +3 -3
- package/dist/src/wirings/http/serialize-fetch-wrapper.js +67 -0
- package/dist/src/wirings/http/serialize-typed-http-map.d.ts +4 -0
- package/dist/src/{events → wirings}/http/serialize-typed-http-map.js +13 -13
- package/dist/src/{events → wirings}/mcp/pikku-command-mcp.js +3 -3
- package/dist/src/wirings/queue/pikku-command-queue-service.js +15 -0
- package/dist/src/{events → wirings}/queue/pikku-command-queue.js +3 -3
- package/dist/src/{events → wirings}/queue/pikku-queue.js +3 -3
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +15 -0
- package/dist/src/wirings/rpc/pikku-command-rpc.js +6 -0
- package/dist/src/wirings/rpc/pikku-rpc.js +6 -0
- package/dist/src/wirings/rpc/serialize-rpc-wrapper.js +68 -0
- package/dist/src/{events → wirings}/scheduler/pikku-command-scheduler.js +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/inspector-glob.ts +2 -2
- package/src/pikku-cli-config.ts +67 -52
- package/src/runtimes/nextjs/pikku-command-nextjs.ts +3 -3
- package/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +29 -29
- package/src/runtimes/nextjs/serialize-nextjs-http-wrapper.ts +28 -28
- package/src/schema-generator.ts +3 -3
- package/src/serialize-pikku-types.ts +67 -67
- package/src/utils.ts +26 -6
- package/src/{events → wirings}/channels/pikku-channels.ts +5 -4
- package/src/{events → wirings}/channels/pikku-command-channels.ts +5 -4
- package/src/{events → wirings}/channels/serialize-typed-channel-map.ts +3 -3
- package/src/{events → wirings}/channels/serialize-websocket-wrapper.ts +19 -5
- package/src/{events → wirings}/fetch/index.ts +2 -2
- package/src/{events → wirings}/http/openapi-spec-generator.ts +3 -3
- package/src/{events → wirings}/http/pikku-command-http-map.ts +5 -5
- package/src/{events → wirings}/http/pikku-command-http-routes.ts +5 -5
- package/src/{events → wirings}/http/pikku-http-routes.ts +5 -5
- package/src/wirings/http/serialize-fetch-wrapper.ts +67 -0
- package/src/{events → wirings}/http/serialize-typed-http-map.ts +17 -17
- package/src/{events → wirings}/mcp/pikku-command-mcp.ts +5 -5
- package/src/{events → wirings}/queue/pikku-command-queue-service.ts +9 -6
- package/src/{events → wirings}/queue/pikku-command-queue.ts +8 -5
- package/src/{events → wirings}/queue/pikku-queue.ts +8 -5
- package/src/{events → wirings}/rpc/pikku-command-rpc-client.ts +9 -6
- package/src/{events → wirings}/rpc/pikku-command-rpc.ts +2 -2
- package/src/{events → wirings}/rpc/pikku-rpc.ts +2 -2
- package/src/wirings/rpc/serialize-rpc-wrapper.ts +68 -0
- package/src/{events → wirings}/scheduler/pikku-command-scheduler.ts +8 -4
- package/dist/src/events/channels/pikku-channels.js +0 -9
- package/dist/src/events/channels/pikku-command-channels.js +0 -9
- package/dist/src/events/http/pikku-command-http-map.js +0 -8
- package/dist/src/events/http/serialize-fetch-wrapper.js +0 -67
- package/dist/src/events/http/serialize-typed-http-map.d.ts +0 -4
- package/dist/src/events/queue/pikku-command-queue-service.js +0 -12
- package/dist/src/events/rpc/pikku-command-rpc-client.js +0 -12
- package/dist/src/events/rpc/pikku-command-rpc.js +0 -6
- package/dist/src/events/rpc/pikku-rpc.js +0 -6
- package/dist/src/events/rpc/serialize-rpc-wrapper.js +0 -29
- package/src/events/http/serialize-fetch-wrapper.ts +0 -67
- package/src/events/rpc/serialize-rpc-wrapper.ts +0 -29
- /package/dist/src/{events → wirings}/channels/pikku-channels.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-channels-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-channels-map.js +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-channels.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-websocket-typed.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/pikku-command-websocket-typed.js +0 -0
- /package/dist/src/{events → wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/fetch/index.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-function-types.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-function-types.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-functions.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-functions.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-services.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-command-services.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-function-types.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-function-types.js +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-functions.d.ts +0 -0
- /package/dist/src/{events → wirings}/functions/pikku-functions.js +0 -0
- /package/dist/src/{events → wirings}/http/openapi-spec-generator.js +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-http-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-http-routes.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-openapi.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/pikku-command-openapi.js +0 -0
- /package/dist/src/{events → wirings}/http/pikku-http-routes.d.ts +0 -0
- /package/dist/src/{events → wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/pikku-command-mcp-json.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/pikku-command-mcp-json.js +0 -0
- /package/dist/src/{events → wirings}/mcp/pikku-command-mcp.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/serialize-mcp-json.d.ts +0 -0
- /package/dist/src/{events → wirings}/mcp/serialize-mcp-json.js +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue-map.js +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue-service.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-command-queue.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-queue-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-queue-map.js +0 -0
- /package/dist/src/{events → wirings}/queue/pikku-queue.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-map.js +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-meta.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-meta.js +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/queue/serialize-queue-wrapper.js +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-client.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc-map.js +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-command-rpc.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/pikku-rpc.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
- /package/dist/src/{events → wirings}/rpc/serialize-typed-rpc-map.js +0 -0
- /package/dist/src/{events → wirings}/scheduler/pikku-command-scheduler.d.ts +0 -0
- /package/dist/src/{events → wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
- /package/dist/src/{events → wirings}/scheduler/serialize-scheduler-meta.js +0 -0
- /package/src/{events → wirings}/channels/pikku-command-channels-map.ts +0 -0
- /package/src/{events → wirings}/channels/pikku-command-websocket-typed.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-command-function-types.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-command-functions.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-command-services.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-function-types.ts +0 -0
- /package/src/{events → wirings}/functions/pikku-functions.ts +0 -0
- /package/src/{events → wirings}/http/pikku-command-openapi.ts +0 -0
- /package/src/{events → wirings}/mcp/pikku-command-mcp-json.ts +0 -0
- /package/src/{events → wirings}/mcp/serialize-mcp-json.ts +0 -0
- /package/src/{events → wirings}/queue/pikku-command-queue-map.ts +0 -0
- /package/src/{events → wirings}/queue/pikku-queue-map.ts +0 -0
- /package/src/{events → wirings}/queue/serialize-queue-map.ts +0 -0
- /package/src/{events → wirings}/queue/serialize-queue-meta.ts +0 -0
- /package/src/{events → wirings}/queue/serialize-queue-wrapper.ts +0 -0
- /package/src/{events → wirings}/rpc/pikku-command-rpc-map.ts +0 -0
- /package/src/{events → wirings}/rpc/serialize-typed-rpc-map.ts +0 -0
- /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 {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { CoreScheduledTask,
|
|
13
|
-
import {
|
|
14
|
-
import { CoreQueueWorker,
|
|
15
|
-
import { CoreMCPResource, CoreMCPTool, CoreMCPPrompt,
|
|
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
|
|
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
|
|
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
|
|
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
|
-
> =
|
|
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
|
|
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
|
-
> =
|
|
89
|
+
> = CorePikkuFunction<In, Out, ChannelData, RequiredServices, ${userSessionTypeName}>
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
|
-
* Type definition for HTTP API
|
|
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
|
|
96
|
-
* @template Out - Output type for the
|
|
97
|
-
* @template Route - String literal type for the
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
|
168
|
+
| PikkuFunction<In, Out>
|
|
169
169
|
| {
|
|
170
|
-
func:
|
|
170
|
+
func: PikkuFunction<In, Out>
|
|
171
171
|
auth?: true
|
|
172
172
|
name?: string
|
|
173
173
|
}
|
|
174
174
|
| {
|
|
175
|
-
func:
|
|
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
|
-
|
|
|
205
|
+
| PikkuFunctionSessionless<In, Out>
|
|
206
206
|
| {
|
|
207
|
-
func:
|
|
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
|
-
|
|
|
236
|
+
| PikkuFunctionSessionless<void, Out, ChannelData>
|
|
237
237
|
| {
|
|
238
|
-
func:
|
|
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
|
-
|
|
|
265
|
+
| PikkuFunctionSessionless<void, void, ChannelData>
|
|
266
266
|
| {
|
|
267
|
-
func:
|
|
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
|
-
|
|
|
295
|
+
| PikkuFunctionSessionless<In, Out, ChannelData>
|
|
296
296
|
| {
|
|
297
|
-
func:
|
|
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
|
-
|
|
|
322
|
+
| PikkuFunctionSessionless<void, void>
|
|
323
323
|
| {
|
|
324
|
-
func:
|
|
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
|
|
339
|
-
channel:
|
|
338
|
+
export const wireChannel = <ChannelData, Channel extends string>(
|
|
339
|
+
channel: ChannelWiring<ChannelData, Channel> & AssertHTTPWiringParams<ChannelData, Channel>
|
|
340
340
|
) => {
|
|
341
|
-
|
|
341
|
+
wireChannelCore(channel as any) // TODO
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
/**
|
|
345
|
-
* Registers an HTTP
|
|
345
|
+
* Registers an HTTP wiring with the Pikku framework.
|
|
346
346
|
*
|
|
347
|
-
* @template In - Input type for the
|
|
348
|
-
* @template Out - Output type for the
|
|
349
|
-
* @template Route - String literal type for the
|
|
350
|
-
* @param
|
|
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
|
|
353
|
-
|
|
352
|
+
export const wireHTTP = <In, Out, Route extends string>(
|
|
353
|
+
httpWiring: HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>
|
|
354
354
|
) => {
|
|
355
|
-
|
|
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
|
|
365
|
-
|
|
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
|
|
375
|
-
|
|
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
|
|
386
|
-
mcpResource:
|
|
385
|
+
export const wireMCPResource = <In>(
|
|
386
|
+
mcpResource: MCPResourceWiring<In>
|
|
387
387
|
) => {
|
|
388
|
-
|
|
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
|
|
399
|
-
mcpTool:
|
|
398
|
+
export const wireMCPTool = <In>(
|
|
399
|
+
mcpTool: MCPToolWiring<In>
|
|
400
400
|
) => {
|
|
401
|
-
|
|
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
|
|
412
|
-
mcpPrompt:
|
|
411
|
+
export const wireMCPPrompt = <In>(
|
|
412
|
+
mcpPrompt: MCPPromptWiring<In>
|
|
413
413
|
) => {
|
|
414
|
-
|
|
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
|
-
|
|
|
442
|
+
| PikkuFunctionSessionless<In, MCPPromptResponse>
|
|
443
443
|
| {
|
|
444
|
-
func:
|
|
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
|
-
|
|
|
474
|
+
| PikkuFunctionSessionless<In, MCPToolResponse, null, true>
|
|
475
475
|
| {
|
|
476
|
-
func:
|
|
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
|
-
|
|
|
507
|
+
| PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
|
|
508
508
|
| {
|
|
509
|
-
func:
|
|
509
|
+
func: PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
|
|
510
510
|
name?: string
|
|
511
511
|
}
|
|
512
512
|
) => {
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { InspectorState, TypesMap } from '@pikku/inspector';
|
|
2
2
|
export declare class CLILogger {
|
|
3
|
-
|
|
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
|
-
|
|
17
|
-
|
|
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
|
-
|
|
24
|
+
if (!this.silent) {
|
|
25
|
+
console.log(chalk.green(message));
|
|
26
|
+
}
|
|
23
27
|
}
|
|
24
28
|
success(message) {
|
|
25
|
-
|
|
29
|
+
if (!this.silent) {
|
|
30
|
+
console.log(chalk.green(message));
|
|
31
|
+
}
|
|
26
32
|
}
|
|
27
33
|
info(message) {
|
|
28
|
-
|
|
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
|
|
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,
|
|
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(
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
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,
|
|
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,
|
|
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,
|
|
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:
|
|
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 {
|
|
4
|
+
const { httpWiringsFile, httpWiringMetaFile, packageMappings } = cliConfig;
|
|
5
5
|
const { http } = visitState;
|
|
6
|
-
await writeFileInDir(logger,
|
|
7
|
-
await writeFileInDir(logger,
|
|
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 {
|
|
4
|
+
const { httpWiringsFile, httpWiringMetaFile, packageMappings } = cliConfig;
|
|
5
5
|
const { http } = visitState;
|
|
6
|
-
await writeFileInDir(logger,
|
|
7
|
-
await writeFileInDir(logger,
|
|
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
|
};
|