@pikku/cli 0.8.3 → 0.9.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.
- package/CHANGELOG.md +6 -0
- package/bin/pikku-all.ts +41 -32
- 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 +32 -32
- 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/bin/pikku.js +0 -0
- package/dist/src/events/channels/pikku-channels.js +3 -3
- package/dist/src/events/channels/pikku-command-channels.js +3 -3
- package/dist/src/events/channels/serialize-typed-channel-map.js +2 -2
- package/dist/src/events/channels/serialize-websocket-wrapper.js +15 -1
- package/dist/src/events/fetch/index.js +2 -2
- package/dist/src/events/http/openapi-spec-generator.d.ts +2 -2
- package/dist/src/events/http/pikku-command-http-map.js +4 -4
- package/dist/src/events/http/pikku-command-http-routes.js +3 -3
- package/dist/src/events/http/pikku-command-nextjs.d.ts +2 -0
- package/dist/src/events/http/pikku-command-nextjs.js +36 -0
- package/dist/src/events/http/pikku-http-routes.js +3 -3
- package/dist/src/events/http/serialize-typed-http-map.d.ts +2 -2
- package/dist/src/events/http/serialize-typed-http-map.js +11 -11
- package/dist/src/events/mcp/pikku-command-mcp.js +3 -3
- package/dist/src/events/queue/pikku-command-queue-service.js +6 -6
- package/dist/src/events/queue/pikku-command-queue.js +3 -3
- package/dist/src/events/queue/pikku-queue.js +3 -3
- package/dist/src/events/rpc/index.d.ts +2 -0
- package/dist/src/events/rpc/index.js +12 -0
- package/dist/src/events/rpc/pikku-command-rpc-client.js +6 -6
- package/dist/src/events/rpc/pikku-command-rpc.js +2 -2
- package/dist/src/events/rpc/pikku-rpc.js +2 -2
- package/dist/src/events/rpc/serialize-rpc-wrapper.js +40 -1
- package/dist/src/events/scheduler/pikku-command-scheduler.js +3 -3
- 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/wirings/channels/pikku-channels.d.ts +2 -0
- package/dist/src/wirings/channels/pikku-channels.js +9 -0
- package/dist/src/wirings/channels/pikku-command-channels-map.d.ts +2 -0
- package/dist/src/wirings/channels/pikku-command-channels-map.js +8 -0
- package/dist/src/wirings/channels/pikku-command-channels.d.ts +2 -0
- package/dist/src/wirings/channels/pikku-command-channels.js +9 -0
- package/dist/src/wirings/channels/pikku-command-websocket-typed.d.ts +2 -0
- package/dist/src/wirings/channels/pikku-command-websocket-typed.js +15 -0
- package/dist/src/wirings/channels/serialize-typed-channel-map.d.ts +4 -0
- package/dist/src/wirings/channels/serialize-typed-channel-map.js +111 -0
- package/dist/src/wirings/channels/serialize-websocket-wrapper.d.ts +1 -0
- package/dist/src/wirings/channels/serialize-websocket-wrapper.js +75 -0
- package/dist/src/wirings/fetch/index.d.ts +2 -0
- package/dist/src/wirings/fetch/index.js +12 -0
- package/dist/src/wirings/functions/pikku-command-function-types.d.ts +2 -0
- package/dist/src/wirings/functions/pikku-command-function-types.js +13 -0
- package/dist/src/wirings/functions/pikku-command-functions.d.ts +6 -0
- package/dist/src/wirings/functions/pikku-command-functions.js +35 -0
- package/dist/src/wirings/functions/pikku-command-services.d.ts +3 -0
- package/dist/src/wirings/functions/pikku-command-services.js +73 -0
- package/dist/src/wirings/functions/pikku-function-types.d.ts +2 -0
- package/dist/src/wirings/functions/pikku-function-types.js +13 -0
- package/dist/src/wirings/functions/pikku-functions.d.ts +6 -0
- package/dist/src/wirings/functions/pikku-functions.js +35 -0
- package/dist/src/wirings/http/openapi-spec-generator.d.ts +79 -0
- package/dist/src/wirings/http/openapi-spec-generator.js +145 -0
- package/dist/src/wirings/http/pikku-command-http-map.d.ts +2 -0
- package/dist/src/wirings/http/pikku-command-http-map.js +8 -0
- package/dist/src/wirings/http/pikku-command-http-routes.d.ts +2 -0
- package/dist/src/wirings/http/pikku-command-http-routes.js +9 -0
- package/dist/src/wirings/http/pikku-command-openapi.d.ts +2 -0
- package/dist/src/wirings/http/pikku-command-openapi.js +20 -0
- package/dist/src/wirings/http/pikku-http-routes.d.ts +2 -0
- package/dist/src/wirings/http/pikku-http-routes.js +9 -0
- package/dist/src/wirings/http/serialize-fetch-wrapper.d.ts +1 -0
- 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/wirings/http/serialize-typed-http-map.js +100 -0
- package/dist/src/wirings/mcp/pikku-command-mcp-json.d.ts +2 -0
- package/dist/src/wirings/mcp/pikku-command-mcp-json.js +13 -0
- package/dist/src/wirings/mcp/pikku-command-mcp.d.ts +2 -0
- package/dist/src/wirings/mcp/pikku-command-mcp.js +54 -0
- package/dist/src/wirings/mcp/serialize-mcp-json.d.ts +5 -0
- package/dist/src/wirings/mcp/serialize-mcp-json.js +101 -0
- package/dist/src/wirings/queue/pikku-command-queue-map.d.ts +2 -0
- package/dist/src/wirings/queue/pikku-command-queue-map.js +8 -0
- package/dist/src/wirings/queue/pikku-command-queue-service.d.ts +2 -0
- package/dist/src/wirings/queue/pikku-command-queue-service.js +15 -0
- package/dist/src/wirings/queue/pikku-command-queue.d.ts +2 -0
- package/dist/src/wirings/queue/pikku-command-queue.js +10 -0
- package/dist/src/wirings/queue/pikku-queue-map.d.ts +2 -0
- package/dist/src/wirings/queue/pikku-queue-map.js +8 -0
- package/dist/src/wirings/queue/pikku-queue.d.ts +2 -0
- package/dist/src/wirings/queue/pikku-queue.js +10 -0
- package/dist/src/wirings/queue/serialize-queue-map.d.ts +4 -0
- package/dist/src/wirings/queue/serialize-queue-map.js +77 -0
- package/dist/src/wirings/queue/serialize-queue-meta.d.ts +2 -0
- package/dist/src/wirings/queue/serialize-queue-meta.js +6 -0
- package/dist/src/wirings/queue/serialize-queue-wrapper.d.ts +1 -0
- package/dist/src/wirings/queue/serialize-queue-wrapper.js +35 -0
- package/dist/src/wirings/rpc/pikku-command-rpc-client.d.ts +2 -0
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +15 -0
- package/dist/src/wirings/rpc/pikku-command-rpc-map.d.ts +2 -0
- package/dist/src/wirings/rpc/pikku-command-rpc-map.js +8 -0
- package/dist/src/wirings/rpc/pikku-command-rpc.d.ts +2 -0
- package/dist/src/wirings/rpc/pikku-command-rpc.js +6 -0
- package/dist/src/wirings/rpc/pikku-rpc.d.ts +2 -0
- package/dist/src/wirings/rpc/pikku-rpc.js +6 -0
- package/dist/src/wirings/rpc/serialize-rpc-wrapper.d.ts +1 -0
- package/dist/src/wirings/rpc/serialize-rpc-wrapper.js +68 -0
- package/dist/src/wirings/rpc/serialize-typed-rpc-map.d.ts +4 -0
- package/dist/src/wirings/rpc/serialize-typed-rpc-map.js +66 -0
- package/dist/src/wirings/scheduler/pikku-command-scheduler.d.ts +2 -0
- package/dist/src/wirings/scheduler/pikku-command-scheduler.js +10 -0
- package/dist/src/wirings/scheduler/serialize-scheduler-meta.d.ts +2 -0
- package/dist/src/wirings/scheduler/serialize-scheduler-meta.js +10 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/lcov.info +582 -0
- 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/{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/src/events/http/serialize-fetch-wrapper.ts +0 -67
- package/src/events/rpc/serialize-rpc-wrapper.ts +0 -29
- /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
package/src/pikku-cli-config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { join, dirname, resolve, isAbsolute } from 'path'
|
|
2
2
|
import { readdir, readFile } from 'fs/promises'
|
|
3
|
-
import { OpenAPISpecInfo } from './
|
|
3
|
+
import { OpenAPISpecInfo } from './wirings/http/openapi-spec-generator.js'
|
|
4
4
|
import { InspectorFilters } from '@pikku/inspector'
|
|
5
|
-
import {
|
|
5
|
+
import { PikkuWiringTypes } from '@pikku/core'
|
|
6
6
|
|
|
7
7
|
export interface PikkuCLICoreOutputFiles {
|
|
8
8
|
// Base directory
|
|
@@ -16,39 +16,39 @@ export interface PikkuCLICoreOutputFiles {
|
|
|
16
16
|
functionsFile: string
|
|
17
17
|
functionsMetaFile: string
|
|
18
18
|
|
|
19
|
-
// HTTP
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
// HTTP
|
|
20
|
+
httpWiringsFile: string
|
|
21
|
+
httpWiringMetaFile: string
|
|
22
|
+
httpMapDeclarationFile: string
|
|
23
23
|
|
|
24
24
|
// Channels
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
channelsWiringFile: string
|
|
26
|
+
channelsWiringMetaFile: string
|
|
27
27
|
channelsMapDeclarationFile: string
|
|
28
28
|
|
|
29
29
|
// RPC
|
|
30
|
-
|
|
30
|
+
rpcWiringMetaFile: string
|
|
31
31
|
rpcMapDeclarationFile: string
|
|
32
32
|
|
|
33
33
|
// Schedulers
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
schedulersWiringFile: string
|
|
35
|
+
schedulersWiringMetaFile: string
|
|
36
36
|
|
|
37
37
|
// Queue processors
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
queueWorkersWiringFile: string
|
|
39
|
+
queueWorkersWiringMetaFile: string
|
|
40
40
|
queueMapDeclarationFile: string
|
|
41
41
|
|
|
42
42
|
// MCP
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
mcpWiringsFile: string
|
|
44
|
+
mcpWiringsMetaFile: string
|
|
45
45
|
|
|
46
46
|
// Services
|
|
47
47
|
servicesFile: string
|
|
48
48
|
|
|
49
49
|
// Application bootstrap
|
|
50
50
|
bootstrapFile: string
|
|
51
|
-
bootstrapFiles: Record<
|
|
51
|
+
bootstrapFiles: Record<PikkuWiringTypes, string>
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export type PikkuCLIConfig = {
|
|
@@ -68,8 +68,8 @@ export type PikkuCLIConfig = {
|
|
|
68
68
|
nextHTTPFile?: string
|
|
69
69
|
fetchFile?: string
|
|
70
70
|
websocketFile?: string
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
rpcWiringsFile?: string
|
|
72
|
+
queueWiringsFile?: string
|
|
73
73
|
mcpJsonFile?: string
|
|
74
74
|
|
|
75
75
|
openAPI?: {
|
|
@@ -87,8 +87,8 @@ const CONFIG_DIR_FILES = [
|
|
|
87
87
|
'nextHTTPFile',
|
|
88
88
|
'fetchFile',
|
|
89
89
|
'websocketFile',
|
|
90
|
-
'
|
|
91
|
-
'
|
|
90
|
+
'rpcWiringsFile',
|
|
91
|
+
'queueWiringsFile',
|
|
92
92
|
'mcpJsonFile',
|
|
93
93
|
]
|
|
94
94
|
|
|
@@ -192,28 +192,31 @@ const _getPikkuCLIConfig = async (
|
|
|
192
192
|
}
|
|
193
193
|
|
|
194
194
|
// HTTP
|
|
195
|
-
if (!result.
|
|
196
|
-
result.
|
|
195
|
+
if (!result.httpWiringsFile) {
|
|
196
|
+
result.httpWiringsFile = join(httpDir, 'pikku-http-wirings.gen.ts')
|
|
197
197
|
}
|
|
198
|
-
if (!result.
|
|
199
|
-
result.
|
|
198
|
+
if (!result.httpWiringMetaFile) {
|
|
199
|
+
result.httpWiringMetaFile = join(
|
|
200
200
|
httpDir,
|
|
201
|
-
'pikku-http-
|
|
201
|
+
'pikku-http-wirings-meta.gen.ts'
|
|
202
202
|
)
|
|
203
203
|
}
|
|
204
|
-
if (!result.
|
|
205
|
-
result.
|
|
204
|
+
if (!result.httpMapDeclarationFile) {
|
|
205
|
+
result.httpMapDeclarationFile = join(
|
|
206
206
|
httpDir,
|
|
207
|
-
'pikku-http-
|
|
207
|
+
'pikku-http-wirings-map.gen.d.ts'
|
|
208
208
|
)
|
|
209
209
|
}
|
|
210
210
|
|
|
211
211
|
// Channels/WebSocket
|
|
212
|
-
if (!result.
|
|
213
|
-
result.
|
|
212
|
+
if (!result.channelsWiringFile) {
|
|
213
|
+
result.channelsWiringFile = join(channelDir, 'pikku-channels.gen.ts')
|
|
214
214
|
}
|
|
215
|
-
if (!result.
|
|
216
|
-
result.
|
|
215
|
+
if (!result.channelsWiringMetaFile) {
|
|
216
|
+
result.channelsWiringMetaFile = join(
|
|
217
|
+
channelDir,
|
|
218
|
+
'pikku-channels-meta.gen.ts'
|
|
219
|
+
)
|
|
217
220
|
}
|
|
218
221
|
if (!result.channelsMapDeclarationFile) {
|
|
219
222
|
result.channelsMapDeclarationFile = join(
|
|
@@ -223,38 +226,47 @@ const _getPikkuCLIConfig = async (
|
|
|
223
226
|
}
|
|
224
227
|
|
|
225
228
|
// RPC
|
|
226
|
-
if (!result.
|
|
227
|
-
result.
|
|
229
|
+
if (!result.rpcWiringMetaFile) {
|
|
230
|
+
result.rpcWiringMetaFile = join(rpcDir, 'pikku-rpc-wirings-meta.gen.ts')
|
|
228
231
|
}
|
|
229
232
|
if (!result.rpcMapDeclarationFile) {
|
|
230
|
-
result.rpcMapDeclarationFile = join(
|
|
233
|
+
result.rpcMapDeclarationFile = join(
|
|
234
|
+
rpcDir,
|
|
235
|
+
'pikku-rpc-wirings-map.gen.d.ts'
|
|
236
|
+
)
|
|
231
237
|
}
|
|
232
238
|
|
|
233
239
|
// Scheduler
|
|
234
|
-
if (!result.
|
|
235
|
-
result.
|
|
240
|
+
if (!result.schedulersWiringFile) {
|
|
241
|
+
result.schedulersWiringFile = join(
|
|
242
|
+
schedulerDir,
|
|
243
|
+
'pikku-schedulers-wirings.gen.ts'
|
|
244
|
+
)
|
|
236
245
|
}
|
|
237
|
-
if (!result.
|
|
238
|
-
result.
|
|
246
|
+
if (!result.schedulersWiringMetaFile) {
|
|
247
|
+
result.schedulersWiringMetaFile = join(
|
|
239
248
|
schedulerDir,
|
|
240
|
-
'pikku-
|
|
249
|
+
'pikku-schedulers-wirings-meta.gen.ts'
|
|
241
250
|
)
|
|
242
251
|
}
|
|
243
252
|
|
|
244
253
|
// Queue
|
|
245
|
-
if (!result.
|
|
246
|
-
result.
|
|
254
|
+
if (!result.queueWorkersWiringFile) {
|
|
255
|
+
result.queueWorkersWiringFile = join(
|
|
256
|
+
queueDir,
|
|
257
|
+
'pikku-queue-workers-wirings.gen.ts'
|
|
258
|
+
)
|
|
247
259
|
}
|
|
248
|
-
if (!result.
|
|
249
|
-
result.
|
|
260
|
+
if (!result.queueWorkersWiringMetaFile) {
|
|
261
|
+
result.queueWorkersWiringMetaFile = join(
|
|
250
262
|
queueDir,
|
|
251
|
-
'pikku-queue-workers-meta.gen.ts'
|
|
263
|
+
'pikku-queue-workers-wirings-meta.gen.ts'
|
|
252
264
|
)
|
|
253
265
|
}
|
|
254
266
|
if (!result.queueMapDeclarationFile) {
|
|
255
267
|
result.queueMapDeclarationFile = join(
|
|
256
268
|
queueDir,
|
|
257
|
-
'pikku-queue-map.gen.ts'
|
|
269
|
+
'pikku-queue-workers-wirings-map.gen.d.ts'
|
|
258
270
|
)
|
|
259
271
|
}
|
|
260
272
|
|
|
@@ -269,18 +281,21 @@ const _getPikkuCLIConfig = async (
|
|
|
269
281
|
}
|
|
270
282
|
|
|
271
283
|
// MCP
|
|
272
|
-
if (!result.
|
|
273
|
-
result.
|
|
284
|
+
if (!result.mcpWiringsMetaFile) {
|
|
285
|
+
result.mcpWiringsMetaFile = join(
|
|
286
|
+
mcpDir,
|
|
287
|
+
'pikku-mcp-wirings-meta.gen.ts'
|
|
288
|
+
)
|
|
274
289
|
}
|
|
275
|
-
if (!result.
|
|
276
|
-
result.
|
|
290
|
+
if (!result.mcpWiringsFile) {
|
|
291
|
+
result.mcpWiringsFile = join(mcpDir, 'pikku-mcp-wirings.gen.ts')
|
|
277
292
|
}
|
|
278
293
|
if (!result.mcpJsonFile) {
|
|
279
|
-
result.mcpJsonFile = join(mcpDir, 'mcp.gen.json')
|
|
294
|
+
result.mcpJsonFile = join(mcpDir, 'pikku-mcp.gen.json')
|
|
280
295
|
}
|
|
281
296
|
|
|
282
297
|
result.bootstrapFiles = result.bootstrapFiles || {}
|
|
283
|
-
for (const key of Object.keys(
|
|
298
|
+
for (const key of Object.keys(PikkuWiringTypes)) {
|
|
284
299
|
const eventDir = join(result.outDir, key.toLowerCase())
|
|
285
300
|
result.bootstrapFiles[key] = join(
|
|
286
301
|
eventDir,
|
|
@@ -13,7 +13,7 @@ export const pikkuNext: PikkuCommand = async (
|
|
|
13
13
|
{
|
|
14
14
|
nextBackendFile,
|
|
15
15
|
nextHTTPFile,
|
|
16
|
-
|
|
16
|
+
httpMapDeclarationFile,
|
|
17
17
|
packageMappings,
|
|
18
18
|
fetchFile,
|
|
19
19
|
bootstrapFiles,
|
|
@@ -72,7 +72,7 @@ export const pikkuNext: PikkuCommand = async (
|
|
|
72
72
|
|
|
73
73
|
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
74
74
|
nextBackendFile,
|
|
75
|
-
|
|
75
|
+
httpMapDeclarationFile,
|
|
76
76
|
packageMappings
|
|
77
77
|
)
|
|
78
78
|
|
|
@@ -89,7 +89,7 @@ export const pikkuNext: PikkuCommand = async (
|
|
|
89
89
|
if (nextHTTPFile && fetchFile) {
|
|
90
90
|
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
91
91
|
nextHTTPFile,
|
|
92
|
-
|
|
92
|
+
httpMapDeclarationFile,
|
|
93
93
|
packageMappings
|
|
94
94
|
)
|
|
95
95
|
|
|
@@ -12,7 +12,7 @@ export const serializeNextJsBackendWrapper = (
|
|
|
12
12
|
* It ensures type safety for route handling methods when integrating with the @pikku/core framework.
|
|
13
13
|
*/
|
|
14
14
|
import { PikkuNextJS } from '@pikku/next'
|
|
15
|
-
import type {
|
|
15
|
+
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
16
16
|
|
|
17
17
|
${configImport}
|
|
18
18
|
${singleServicesFactoryImport}
|
|
@@ -40,7 +40,7 @@ export const pikku = (_options?: any) => {
|
|
|
40
40
|
* Makes a dynamic action request for a specified route and method.
|
|
41
41
|
* Dynamic requests may access headers and cookies and are therefore unsuitable for precompile stages.
|
|
42
42
|
*
|
|
43
|
-
* @template Route - The route key from the
|
|
43
|
+
* @template Route - The route key from the HTTPWiringsMap.
|
|
44
44
|
* @template Method - The method key from the specified route.
|
|
45
45
|
* @param route - The route identifier.
|
|
46
46
|
* @param method - The HTTP method to be used for the request.
|
|
@@ -48,13 +48,13 @@ export const pikku = (_options?: any) => {
|
|
|
48
48
|
* @returns A promise that resolves to the output of the route handler.
|
|
49
49
|
*/
|
|
50
50
|
const dynamicActionRequest = async <
|
|
51
|
-
Route extends keyof
|
|
52
|
-
Method extends keyof
|
|
51
|
+
Route extends keyof HTTPWiringsMap,
|
|
52
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
53
53
|
>(
|
|
54
54
|
route: Route,
|
|
55
55
|
method: Method,
|
|
56
|
-
data:
|
|
57
|
-
): Promise<
|
|
56
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
57
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
58
58
|
return _pikku!.actionRequest(route, method, data as any)
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -62,7 +62,7 @@ export const pikku = (_options?: any) => {
|
|
|
62
62
|
* Makes a static action request for a specified route and method.
|
|
63
63
|
* Static requests do not depend on headers or cookies and are suitable for precompile stages.
|
|
64
64
|
*
|
|
65
|
-
* @template Route - The route key from the
|
|
65
|
+
* @template Route - The route key from the HTTPWiringsMap.
|
|
66
66
|
* @template Method - The method key from the specified route.
|
|
67
67
|
* @param route - The route identifier.
|
|
68
68
|
* @param method - The HTTP method to be used for the request.
|
|
@@ -70,13 +70,13 @@ export const pikku = (_options?: any) => {
|
|
|
70
70
|
* @returns A promise that resolves to the output of the route handler.
|
|
71
71
|
*/
|
|
72
72
|
const staticActionRequest = async <
|
|
73
|
-
Route extends keyof
|
|
74
|
-
Method extends keyof
|
|
73
|
+
Route extends keyof HTTPWiringsMap,
|
|
74
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
75
75
|
>(
|
|
76
76
|
route: Route,
|
|
77
77
|
method: Method,
|
|
78
|
-
data:
|
|
79
|
-
): Promise<
|
|
78
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
79
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
80
80
|
return _pikku!.staticActionRequest(route, method, data as any)
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -88,10 +88,10 @@ export const pikku = (_options?: any) => {
|
|
|
88
88
|
* @param data - The input data for the POST request, defaults to null.
|
|
89
89
|
* @returns A promise that resolves to the output of the POST handler.
|
|
90
90
|
*/
|
|
91
|
-
const dynamicPost = <Route extends
|
|
91
|
+
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
92
92
|
route: Route,
|
|
93
|
-
data:
|
|
94
|
-
): Promise<
|
|
93
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
94
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
95
95
|
return dynamicActionRequest(route, 'POST', data)
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -103,10 +103,10 @@ export const pikku = (_options?: any) => {
|
|
|
103
103
|
* @param data - The input data for the GET request, defaults to null.
|
|
104
104
|
* @returns A promise that resolves to the output of the GET handler.
|
|
105
105
|
*/
|
|
106
|
-
const dynamicGet = <Route extends
|
|
106
|
+
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
107
107
|
route: Route,
|
|
108
|
-
data:
|
|
109
|
-
): Promise<
|
|
108
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
109
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
110
110
|
return dynamicActionRequest(route, 'GET', data)
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -118,10 +118,10 @@ export const pikku = (_options?: any) => {
|
|
|
118
118
|
* @param data - The input data for the PATCH request, defaults to null.
|
|
119
119
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
120
120
|
*/
|
|
121
|
-
const dynamicPatch = <Route extends
|
|
121
|
+
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
122
122
|
route: Route,
|
|
123
|
-
data:
|
|
124
|
-
): Promise<
|
|
123
|
+
data: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] = null
|
|
124
|
+
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
125
125
|
return dynamicActionRequest(route, 'PATCH', data)
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -133,10 +133,10 @@ export const pikku = (_options?: any) => {
|
|
|
133
133
|
* @param data - The input data for the DELETE request, defaults to null.
|
|
134
134
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
135
135
|
*/
|
|
136
|
-
const dynamicDel = <Route extends
|
|
136
|
+
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
137
137
|
route: Route,
|
|
138
|
-
data:
|
|
139
|
-
): Promise<
|
|
138
|
+
data: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] = null
|
|
139
|
+
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
140
140
|
return dynamicActionRequest(route, 'DELETE', data)
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -150,10 +150,10 @@ export const pikku = (_options?: any) => {
|
|
|
150
150
|
* @param data - The input data for the POST request, defaults to null.
|
|
151
151
|
* @returns A promise that resolves to the output of the POST handler.
|
|
152
152
|
*/
|
|
153
|
-
const staticPost = <Route extends
|
|
153
|
+
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
154
154
|
route: Route,
|
|
155
|
-
data:
|
|
156
|
-
): Promise<
|
|
155
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
156
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
157
157
|
return staticActionRequest(route, 'POST', data)
|
|
158
158
|
}
|
|
159
159
|
|
|
@@ -165,10 +165,10 @@ export const pikku = (_options?: any) => {
|
|
|
165
165
|
* @param data - The input data for the GET request, defaults to null.
|
|
166
166
|
* @returns A promise that resolves to the output of the GET handler.
|
|
167
167
|
*/
|
|
168
|
-
const staticGet = <Route extends
|
|
168
|
+
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
169
169
|
route: Route,
|
|
170
|
-
data:
|
|
171
|
-
): Promise<
|
|
170
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
171
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
172
172
|
return staticActionRequest(route, 'GET', data)
|
|
173
173
|
}
|
|
174
174
|
|
|
@@ -9,7 +9,7 @@ export const serializeNextJsHTTPWrapper = (
|
|
|
9
9
|
* It ensures type safety for route handling methods when integrating with the @pikku/core framework.
|
|
10
10
|
*/
|
|
11
11
|
import { CorePikkuFetchOptions } from '@pikku/fetch'
|
|
12
|
-
import type {
|
|
12
|
+
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
13
13
|
import { PikkuFetch } from '${pikkuFetchImport}'
|
|
14
14
|
|
|
15
15
|
let _pikku: PikkuFetch | undefined
|
|
@@ -25,13 +25,13 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
const dynamicActionRequest = async <
|
|
28
|
-
Route extends keyof
|
|
29
|
-
Method extends keyof
|
|
28
|
+
Route extends keyof HTTPWiringsMap,
|
|
29
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
30
30
|
>(
|
|
31
31
|
route: Route,
|
|
32
32
|
method: Method,
|
|
33
|
-
data:
|
|
34
|
-
): Promise<
|
|
33
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
34
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
35
35
|
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -39,7 +39,7 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
39
39
|
* Makes a static action request for a specified route and method.
|
|
40
40
|
* Static requests do not depend on headers or cookies and are suitable for precompile stages.
|
|
41
41
|
*
|
|
42
|
-
* @template Route - The route key from the
|
|
42
|
+
* @template Route - The route key from the HTTPWiringsMap.
|
|
43
43
|
* @template Method - The method key from the specified route.
|
|
44
44
|
* @param route - The route identifier.
|
|
45
45
|
* @param method - The HTTP method to be used for the request.
|
|
@@ -47,13 +47,13 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
47
47
|
* @returns A promise that resolves to the output of the route handler.
|
|
48
48
|
*/
|
|
49
49
|
const staticActionRequest = async <
|
|
50
|
-
Route extends keyof
|
|
51
|
-
Method extends keyof
|
|
50
|
+
Route extends keyof HTTPWiringsMap,
|
|
51
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
52
52
|
>(
|
|
53
53
|
route: Route,
|
|
54
54
|
method: Method,
|
|
55
|
-
data:
|
|
56
|
-
): Promise<
|
|
55
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
56
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
57
57
|
return (_pikku! as any)[(method as string).toLowerCase()](route, data as any)
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -65,10 +65,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
65
65
|
* @param data - The input data for the POST request, defaults to null.
|
|
66
66
|
* @returns A promise that resolves to the output of the POST handler.
|
|
67
67
|
*/
|
|
68
|
-
const dynamicPost = <Route extends
|
|
68
|
+
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
69
69
|
route: Route,
|
|
70
|
-
data:
|
|
71
|
-
): Promise<
|
|
70
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
71
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
72
72
|
return dynamicActionRequest(route, 'POST', data)
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -80,10 +80,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
80
80
|
* @param data - The input data for the GET request, defaults to null.
|
|
81
81
|
* @returns A promise that resolves to the output of the GET handler.
|
|
82
82
|
*/
|
|
83
|
-
const dynamicGet = <Route extends
|
|
83
|
+
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
84
84
|
route: Route,
|
|
85
|
-
data:
|
|
86
|
-
): Promise<
|
|
85
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
86
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
87
87
|
return dynamicActionRequest(route, 'GET', data)
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -95,10 +95,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
95
95
|
* @param data - The input data for the PATCH request, defaults to null.
|
|
96
96
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
97
97
|
*/
|
|
98
|
-
const dynamicPatch = <Route extends
|
|
98
|
+
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
99
99
|
route: Route,
|
|
100
|
-
data:
|
|
101
|
-
): Promise<
|
|
100
|
+
data: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] = null
|
|
101
|
+
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
102
102
|
return dynamicActionRequest(route, 'PATCH', data)
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -110,10 +110,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
110
110
|
* @param data - The input data for the DELETE request, defaults to null.
|
|
111
111
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
112
112
|
*/
|
|
113
|
-
const dynamicDel = <Route extends
|
|
113
|
+
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
114
114
|
route: Route,
|
|
115
|
-
data:
|
|
116
|
-
): Promise<
|
|
115
|
+
data: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] = null
|
|
116
|
+
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
117
117
|
return dynamicActionRequest(route, 'DELETE', data)
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -127,10 +127,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
127
127
|
* @param data - The input data for the POST request, defaults to null.
|
|
128
128
|
* @returns A promise that resolves to the output of the POST handler.
|
|
129
129
|
*/
|
|
130
|
-
const staticPost = <Route extends
|
|
130
|
+
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
131
131
|
route: Route,
|
|
132
|
-
data:
|
|
133
|
-
): Promise<
|
|
132
|
+
data: HTTPWiringHandlerOf<Route, 'POST'>['input'] = null
|
|
133
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
134
134
|
return staticActionRequest(route, 'POST', data)
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -142,10 +142,10 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
142
142
|
* @param data - The input data for the GET request, defaults to null.
|
|
143
143
|
* @returns A promise that resolves to the output of the GET handler.
|
|
144
144
|
*/
|
|
145
|
-
const staticGet = <Route extends
|
|
145
|
+
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
146
146
|
route: Route,
|
|
147
|
-
data:
|
|
148
|
-
): Promise<
|
|
147
|
+
data: HTTPWiringHandlerOf<Route, 'GET'>['input'] = null
|
|
148
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
149
149
|
return staticActionRequest(route, 'GET', data)
|
|
150
150
|
}
|
|
151
151
|
|
package/src/schema-generator.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createGenerator, RootlessError } from 'ts-json-schema-generator'
|
|
|
2
2
|
import { CLILogger, writeFileInDir } from './utils.js'
|
|
3
3
|
import { mkdir, writeFile } from 'fs/promises'
|
|
4
4
|
import { FunctionsMeta, JSONValue } from '@pikku/core'
|
|
5
|
-
import {
|
|
5
|
+
import { HTTPWiringsMeta } from '@pikku/core/http'
|
|
6
6
|
import { TypesMap } from '@pikku/inspector'
|
|
7
7
|
|
|
8
8
|
export async function generateSchemas(
|
|
@@ -10,7 +10,7 @@ export async function generateSchemas(
|
|
|
10
10
|
tsconfig: string,
|
|
11
11
|
typesMap: TypesMap,
|
|
12
12
|
functionMeta: FunctionsMeta,
|
|
13
|
-
|
|
13
|
+
httpWiringsMeta: HTTPWiringsMeta
|
|
14
14
|
): Promise<Record<string, JSONValue>> {
|
|
15
15
|
const schemasSet = new Set(typesMap.customTypes.keys())
|
|
16
16
|
for (const { inputs, outputs } of Object.values(functionMeta)) {
|
|
@@ -22,7 +22,7 @@ export async function generateSchemas(
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
for (const { inputTypes } of
|
|
25
|
+
for (const { inputTypes } of httpWiringsMeta) {
|
|
26
26
|
if (inputTypes?.body) {
|
|
27
27
|
schemasSet.add(inputTypes.body)
|
|
28
28
|
}
|