@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/CHANGELOG.md
CHANGED
package/bin/pikku-all.ts
CHANGED
|
@@ -6,29 +6,29 @@ import {
|
|
|
6
6
|
writeFileInDir,
|
|
7
7
|
} from '../src/utils.js'
|
|
8
8
|
import { getPikkuCLIConfig, PikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
9
|
-
import { pikkuHTTP } from '../src/
|
|
10
|
-
import { pikkuFunctionTypes } from '../src/
|
|
11
|
-
import { pikkuHTTPMap } from '../src/
|
|
9
|
+
import { pikkuHTTP } from '../src/wirings/http/pikku-command-http-routes.js'
|
|
10
|
+
import { pikkuFunctionTypes } from '../src/wirings/functions/pikku-command-function-types.js'
|
|
11
|
+
import { pikkuHTTPMap } from '../src/wirings/http/pikku-command-http-map.js'
|
|
12
12
|
import { existsSync } from 'fs'
|
|
13
|
-
import { pikkuChannelsMap } from '../src/
|
|
14
|
-
import { pikkuChannels } from '../src/
|
|
13
|
+
import { pikkuChannelsMap } from '../src/wirings/channels/pikku-command-channels-map.js'
|
|
14
|
+
import { pikkuChannels } from '../src/wirings/channels/pikku-command-channels.js'
|
|
15
15
|
import { inspectorGlob } from '../src/inspector-glob.js'
|
|
16
16
|
import chokidar from 'chokidar'
|
|
17
|
-
import { pikkuFunctions } from '../src/
|
|
18
|
-
import { pikkuServices } from '../src/
|
|
19
|
-
import { pikkuRPC } from '../src/
|
|
20
|
-
import { pikkuRPCMap } from '../src/
|
|
21
|
-
import { pikkuQueue } from '../src/
|
|
22
|
-
import { pikkuQueueMap } from '../src/
|
|
23
|
-
import { pikkuFetch } from '../src/
|
|
24
|
-
import { pikkuRPCClient } from '../src/
|
|
25
|
-
import { pikkuWebSocketTyped } from '../src/
|
|
26
|
-
import { pikkuOpenAPI } from '../src/
|
|
27
|
-
import { pikkuMCP } from '../src/
|
|
28
|
-
import { pikkuQueueService } from '../src/
|
|
29
|
-
import { pikkuScheduler } from '../src/
|
|
17
|
+
import { pikkuFunctions } from '../src/wirings/functions/pikku-command-functions.js'
|
|
18
|
+
import { pikkuServices } from '../src/wirings/functions/pikku-command-services.js'
|
|
19
|
+
import { pikkuRPC } from '../src/wirings/rpc/pikku-command-rpc.js'
|
|
20
|
+
import { pikkuRPCMap } from '../src/wirings/rpc/pikku-command-rpc-map.js'
|
|
21
|
+
import { pikkuQueue } from '../src/wirings/queue/pikku-command-queue.js'
|
|
22
|
+
import { pikkuQueueMap } from '../src/wirings/queue/pikku-command-queue-map.js'
|
|
23
|
+
import { pikkuFetch } from '../src/wirings/fetch/index.js'
|
|
24
|
+
import { pikkuRPCClient } from '../src/wirings/rpc/pikku-command-rpc-client.js'
|
|
25
|
+
import { pikkuWebSocketTyped } from '../src/wirings/channels/pikku-command-websocket-typed.js'
|
|
26
|
+
import { pikkuOpenAPI } from '../src/wirings/http/pikku-command-openapi.js'
|
|
27
|
+
import { pikkuMCP } from '../src/wirings/mcp/pikku-command-mcp.js'
|
|
28
|
+
import { pikkuQueueService } from '../src/wirings/queue/pikku-command-queue-service.js'
|
|
29
|
+
import { pikkuScheduler } from '../src/wirings/scheduler/pikku-command-scheduler.js'
|
|
30
30
|
import { pikkuSchemas } from '../src/schemas.js'
|
|
31
|
-
import { pikkuMCPJSON } from '../src/
|
|
31
|
+
import { pikkuMCPJSON } from '../src/wirings/mcp/pikku-command-mcp-json.js'
|
|
32
32
|
import { pikkuNext } from '../src/runtimes/nextjs/pikku-command-nextjs.js'
|
|
33
33
|
|
|
34
34
|
const generateBootstrapFile = async (
|
|
@@ -82,7 +82,7 @@ const runAll = async (
|
|
|
82
82
|
}
|
|
83
83
|
await pikkuFunctionTypes(logger, cliConfig, visitState, options)
|
|
84
84
|
|
|
85
|
-
// This is needed since the
|
|
85
|
+
// This is needed since the wireHTTP function will add the routes to the visitState
|
|
86
86
|
if (!typesDeclarationFileExists) {
|
|
87
87
|
logger.info(`• Type file first created, inspecting again...\x1b[0m`)
|
|
88
88
|
visitState = await inspectorGlob(
|
|
@@ -108,7 +108,7 @@ const runAll = async (
|
|
|
108
108
|
await pikkuRPC(logger, cliConfig, visitState)
|
|
109
109
|
await pikkuRPCMap(logger, cliConfig, visitState)
|
|
110
110
|
await pikkuRPCClient(logger, cliConfig)
|
|
111
|
-
allImports.push(cliConfig.
|
|
111
|
+
allImports.push(cliConfig.rpcWiringMetaFile)
|
|
112
112
|
|
|
113
113
|
const schemas = await pikkuSchemas(logger, cliConfig, visitState)
|
|
114
114
|
if (schemas) {
|
|
@@ -120,7 +120,7 @@ const runAll = async (
|
|
|
120
120
|
logger,
|
|
121
121
|
cliConfig,
|
|
122
122
|
cliConfig.bootstrapFiles.rpc,
|
|
123
|
-
[cliConfig.
|
|
123
|
+
[cliConfig.rpcWiringMetaFile],
|
|
124
124
|
schemas
|
|
125
125
|
)
|
|
126
126
|
|
|
@@ -128,26 +128,29 @@ const runAll = async (
|
|
|
128
128
|
if (http) {
|
|
129
129
|
await pikkuHTTPMap(logger, cliConfig, visitState)
|
|
130
130
|
await pikkuFetch(logger, cliConfig)
|
|
131
|
-
allImports.push(cliConfig.
|
|
131
|
+
allImports.push(cliConfig.httpWiringMetaFile, cliConfig.httpWiringsFile)
|
|
132
132
|
|
|
133
133
|
await generateBootstrapFile(
|
|
134
134
|
logger,
|
|
135
135
|
cliConfig,
|
|
136
136
|
cliConfig.bootstrapFiles.http,
|
|
137
|
-
[cliConfig.
|
|
137
|
+
[cliConfig.httpWiringMetaFile, cliConfig.httpWiringsFile],
|
|
138
138
|
schemas
|
|
139
139
|
)
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
const scheduler = await pikkuScheduler(logger, cliConfig, visitState)
|
|
143
143
|
if (scheduler) {
|
|
144
|
-
allImports.push(
|
|
144
|
+
allImports.push(
|
|
145
|
+
cliConfig.schedulersWiringMetaFile,
|
|
146
|
+
cliConfig.schedulersWiringFile
|
|
147
|
+
)
|
|
145
148
|
|
|
146
149
|
await generateBootstrapFile(
|
|
147
150
|
logger,
|
|
148
151
|
cliConfig,
|
|
149
152
|
cliConfig.bootstrapFiles.scheduler,
|
|
150
|
-
[cliConfig.
|
|
153
|
+
[cliConfig.schedulersWiringMetaFile, cliConfig.schedulersWiringFile],
|
|
151
154
|
schemas
|
|
152
155
|
)
|
|
153
156
|
}
|
|
@@ -156,13 +159,16 @@ const runAll = async (
|
|
|
156
159
|
if (queues) {
|
|
157
160
|
await pikkuQueueMap(logger, cliConfig, visitState)
|
|
158
161
|
await pikkuQueueService(logger, cliConfig)
|
|
159
|
-
allImports.push(
|
|
162
|
+
allImports.push(
|
|
163
|
+
cliConfig.queueWorkersWiringMetaFile,
|
|
164
|
+
cliConfig.queueWorkersWiringFile
|
|
165
|
+
)
|
|
160
166
|
|
|
161
167
|
await generateBootstrapFile(
|
|
162
168
|
logger,
|
|
163
169
|
cliConfig,
|
|
164
170
|
cliConfig.bootstrapFiles.queue,
|
|
165
|
-
[cliConfig.
|
|
171
|
+
[cliConfig.queueWorkersWiringMetaFile, cliConfig.queueWorkersWiringFile],
|
|
166
172
|
schemas
|
|
167
173
|
)
|
|
168
174
|
}
|
|
@@ -171,13 +177,16 @@ const runAll = async (
|
|
|
171
177
|
if (channels) {
|
|
172
178
|
await pikkuChannelsMap(logger, cliConfig, visitState)
|
|
173
179
|
await pikkuWebSocketTyped(logger, cliConfig)
|
|
174
|
-
allImports.push(
|
|
180
|
+
allImports.push(
|
|
181
|
+
cliConfig.channelsWiringMetaFile,
|
|
182
|
+
cliConfig.channelsWiringFile
|
|
183
|
+
)
|
|
175
184
|
|
|
176
185
|
await generateBootstrapFile(
|
|
177
186
|
logger,
|
|
178
187
|
cliConfig,
|
|
179
188
|
cliConfig.bootstrapFiles.channel,
|
|
180
|
-
[cliConfig.
|
|
189
|
+
[cliConfig.channelsWiringMetaFile, cliConfig.channelsWiringFile],
|
|
181
190
|
schemas
|
|
182
191
|
)
|
|
183
192
|
}
|
|
@@ -185,13 +194,13 @@ const runAll = async (
|
|
|
185
194
|
const mcp = await pikkuMCP(logger, cliConfig, visitState)
|
|
186
195
|
if (mcp) {
|
|
187
196
|
await pikkuMCPJSON(logger, cliConfig, visitState)
|
|
188
|
-
allImports.push(cliConfig.
|
|
197
|
+
allImports.push(cliConfig.mcpWiringsMetaFile, cliConfig.mcpWiringsFile)
|
|
189
198
|
|
|
190
199
|
await generateBootstrapFile(
|
|
191
200
|
logger,
|
|
192
201
|
cliConfig,
|
|
193
202
|
cliConfig.bootstrapFiles.mcp,
|
|
194
|
-
[cliConfig.
|
|
203
|
+
[cliConfig.mcpWiringsMetaFile, cliConfig.mcpWiringsFile],
|
|
195
204
|
schemas
|
|
196
205
|
)
|
|
197
206
|
}
|
package/bin/pikku-fetch.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
3
|
-
import { pikkuFetch } from '../src/
|
|
3
|
+
import { pikkuFetch } from '../src/wirings/fetch/index.js'
|
|
4
4
|
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
5
5
|
|
|
6
6
|
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
package/bin/pikku-openapi.ts
CHANGED
|
@@ -2,13 +2,13 @@ import { Command } from 'commander'
|
|
|
2
2
|
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
3
3
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
4
4
|
import { inspectorGlob } from '../src/inspector-glob.js'
|
|
5
|
-
import { pikkuOpenAPI } from '../src/
|
|
5
|
+
import { pikkuOpenAPI } from '../src/wirings/http/pikku-command-openapi.js'
|
|
6
6
|
|
|
7
7
|
async function action({ config, tags }: PikkuCLIOptions): Promise<void> {
|
|
8
8
|
const logger = new CLILogger({ logLogo: true })
|
|
9
9
|
const cliConfig = await getPikkuCLIConfig(
|
|
10
10
|
config,
|
|
11
|
-
['rootDir', '
|
|
11
|
+
['rootDir', 'httpWiringsFile', 'openAPI', 'schemaDirectory', 'tsconfig'],
|
|
12
12
|
{
|
|
13
13
|
tags: tags || [],
|
|
14
14
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
3
3
|
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
4
|
-
import { pikkuQueueService } from '../src/
|
|
4
|
+
import { pikkuQueueService } from '../src/wirings/queue/pikku-command-queue-service.js'
|
|
5
5
|
|
|
6
6
|
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
7
7
|
const logger = new CLILogger({ logLogo: true })
|
|
8
8
|
|
|
9
9
|
const cliConfig = await getPikkuCLIConfig(
|
|
10
10
|
options.config,
|
|
11
|
-
['rootDir', 'schemaDirectory', 'configDir', '
|
|
11
|
+
['rootDir', 'schemaDirectory', 'configDir', 'queueWiringsFile'],
|
|
12
12
|
{
|
|
13
13
|
tags: options.tags,
|
|
14
14
|
types: options.types,
|
package/bin/pikku-websocket.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander'
|
|
2
2
|
import { CLILogger, PikkuCLIOptions } from '../src/utils.js'
|
|
3
3
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js'
|
|
4
|
-
import { pikkuWebSocketTyped } from '../src/
|
|
4
|
+
import { pikkuWebSocketTyped } from '../src/wirings/channels/pikku-command-websocket-typed.js'
|
|
5
5
|
|
|
6
6
|
export const action = async (options: PikkuCLIOptions): Promise<void> => {
|
|
7
7
|
const logger = new CLILogger({ logLogo: true })
|
package/cli.schema.json
CHANGED
|
@@ -172,13 +172,13 @@
|
|
|
172
172
|
"required": ["http", "scheduler", "channel", "rpc", "queue", "mcp"],
|
|
173
173
|
"type": "object"
|
|
174
174
|
},
|
|
175
|
-
"
|
|
175
|
+
"channelsMapDeclarationFile": {
|
|
176
176
|
"type": "string"
|
|
177
177
|
},
|
|
178
|
-
"
|
|
178
|
+
"channelsWiringFile": {
|
|
179
179
|
"type": "string"
|
|
180
180
|
},
|
|
181
|
-
"
|
|
181
|
+
"channelsWiringMetaFile": {
|
|
182
182
|
"type": "string"
|
|
183
183
|
},
|
|
184
184
|
"configDir": {
|
|
@@ -199,22 +199,22 @@
|
|
|
199
199
|
"functionsMetaFile": {
|
|
200
200
|
"type": "string"
|
|
201
201
|
},
|
|
202
|
-
"
|
|
202
|
+
"httpMapDeclarationFile": {
|
|
203
203
|
"type": "string"
|
|
204
204
|
},
|
|
205
|
-
"
|
|
205
|
+
"httpWiringMetaFile": {
|
|
206
206
|
"type": "string"
|
|
207
207
|
},
|
|
208
|
-
"
|
|
208
|
+
"httpWiringsFile": {
|
|
209
209
|
"type": "string"
|
|
210
210
|
},
|
|
211
|
-
"
|
|
211
|
+
"mcpJsonFile": {
|
|
212
212
|
"type": "string"
|
|
213
213
|
},
|
|
214
|
-
"
|
|
214
|
+
"mcpWiringsFile": {
|
|
215
215
|
"type": "string"
|
|
216
216
|
},
|
|
217
|
-
"
|
|
217
|
+
"mcpWiringsMetaFile": {
|
|
218
218
|
"type": "string"
|
|
219
219
|
},
|
|
220
220
|
"middlewareServices": {
|
|
@@ -251,34 +251,34 @@
|
|
|
251
251
|
},
|
|
252
252
|
"type": "object"
|
|
253
253
|
},
|
|
254
|
-
"
|
|
254
|
+
"queueMapDeclarationFile": {
|
|
255
255
|
"type": "string"
|
|
256
256
|
},
|
|
257
|
-
"
|
|
257
|
+
"queueWiringsFile": {
|
|
258
258
|
"type": "string"
|
|
259
259
|
},
|
|
260
|
-
"
|
|
260
|
+
"queueWorkersWiringFile": {
|
|
261
261
|
"type": "string"
|
|
262
262
|
},
|
|
263
|
-
"
|
|
263
|
+
"queueWorkersWiringMetaFile": {
|
|
264
264
|
"type": "string"
|
|
265
265
|
},
|
|
266
266
|
"rootDir": {
|
|
267
267
|
"type": "string"
|
|
268
268
|
},
|
|
269
|
-
"
|
|
269
|
+
"rpcMapDeclarationFile": {
|
|
270
270
|
"type": "string"
|
|
271
271
|
},
|
|
272
|
-
"
|
|
272
|
+
"rpcWiringMetaFile": {
|
|
273
273
|
"type": "string"
|
|
274
274
|
},
|
|
275
|
-
"
|
|
275
|
+
"rpcWiringsFile": {
|
|
276
276
|
"type": "string"
|
|
277
277
|
},
|
|
278
|
-
"
|
|
278
|
+
"schedulersWiringFile": {
|
|
279
279
|
"type": "string"
|
|
280
280
|
},
|
|
281
|
-
"
|
|
281
|
+
"schedulersWiringMetaFile": {
|
|
282
282
|
"type": "string"
|
|
283
283
|
},
|
|
284
284
|
"schemaDirectory": {
|
|
@@ -309,27 +309,27 @@
|
|
|
309
309
|
"required": [
|
|
310
310
|
"bootstrapFile",
|
|
311
311
|
"bootstrapFiles",
|
|
312
|
-
"channelsFile",
|
|
313
312
|
"channelsMapDeclarationFile",
|
|
314
|
-
"
|
|
313
|
+
"channelsWiringFile",
|
|
314
|
+
"channelsWiringMetaFile",
|
|
315
315
|
"configDir",
|
|
316
316
|
"filters",
|
|
317
317
|
"functionsFile",
|
|
318
318
|
"functionsMetaFile",
|
|
319
|
-
"
|
|
320
|
-
"
|
|
321
|
-
"
|
|
322
|
-
"
|
|
323
|
-
"
|
|
319
|
+
"httpMapDeclarationFile",
|
|
320
|
+
"httpWiringMetaFile",
|
|
321
|
+
"httpWiringsFile",
|
|
322
|
+
"mcpWiringsFile",
|
|
323
|
+
"mcpWiringsMetaFile",
|
|
324
324
|
"packageMappings",
|
|
325
325
|
"queueMapDeclarationFile",
|
|
326
|
-
"
|
|
327
|
-
"
|
|
326
|
+
"queueWorkersWiringFile",
|
|
327
|
+
"queueWorkersWiringMetaFile",
|
|
328
328
|
"rootDir",
|
|
329
329
|
"rpcMapDeclarationFile",
|
|
330
|
-
"
|
|
331
|
-
"
|
|
332
|
-
"
|
|
330
|
+
"rpcWiringMetaFile",
|
|
331
|
+
"schedulersWiringFile",
|
|
332
|
+
"schedulersWiringMetaFile",
|
|
333
333
|
"schemaDirectory",
|
|
334
334
|
"servicesFile",
|
|
335
335
|
"srcDirectories",
|
package/dist/bin/pikku-all.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { CLILogger, getFileImportRelativePath, writeFileInDir, } from '../src/utils.js';
|
|
2
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
|
-
import { pikkuHTTP } from '../src/
|
|
4
|
-
import { pikkuFunctionTypes } from '../src/
|
|
5
|
-
import { pikkuHTTPMap } from '../src/
|
|
3
|
+
import { pikkuHTTP } from '../src/wirings/http/pikku-command-http-routes.js';
|
|
4
|
+
import { pikkuFunctionTypes } from '../src/wirings/functions/pikku-command-function-types.js';
|
|
5
|
+
import { pikkuHTTPMap } from '../src/wirings/http/pikku-command-http-map.js';
|
|
6
6
|
import { existsSync } from 'fs';
|
|
7
|
-
import { pikkuChannelsMap } from '../src/
|
|
8
|
-
import { pikkuChannels } from '../src/
|
|
7
|
+
import { pikkuChannelsMap } from '../src/wirings/channels/pikku-command-channels-map.js';
|
|
8
|
+
import { pikkuChannels } from '../src/wirings/channels/pikku-command-channels.js';
|
|
9
9
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
10
10
|
import chokidar from 'chokidar';
|
|
11
|
-
import { pikkuFunctions } from '../src/
|
|
12
|
-
import { pikkuServices } from '../src/
|
|
13
|
-
import { pikkuRPC } from '../src/
|
|
14
|
-
import { pikkuRPCMap } from '../src/
|
|
15
|
-
import { pikkuQueue } from '../src/
|
|
16
|
-
import { pikkuQueueMap } from '../src/
|
|
17
|
-
import { pikkuFetch } from '../src/
|
|
18
|
-
import { pikkuRPCClient } from '../src/
|
|
19
|
-
import { pikkuWebSocketTyped } from '../src/
|
|
20
|
-
import { pikkuOpenAPI } from '../src/
|
|
21
|
-
import { pikkuMCP } from '../src/
|
|
22
|
-
import { pikkuQueueService } from '../src/
|
|
23
|
-
import { pikkuScheduler } from '../src/
|
|
11
|
+
import { pikkuFunctions } from '../src/wirings/functions/pikku-command-functions.js';
|
|
12
|
+
import { pikkuServices } from '../src/wirings/functions/pikku-command-services.js';
|
|
13
|
+
import { pikkuRPC } from '../src/wirings/rpc/pikku-command-rpc.js';
|
|
14
|
+
import { pikkuRPCMap } from '../src/wirings/rpc/pikku-command-rpc-map.js';
|
|
15
|
+
import { pikkuQueue } from '../src/wirings/queue/pikku-command-queue.js';
|
|
16
|
+
import { pikkuQueueMap } from '../src/wirings/queue/pikku-command-queue-map.js';
|
|
17
|
+
import { pikkuFetch } from '../src/wirings/fetch/index.js';
|
|
18
|
+
import { pikkuRPCClient } from '../src/wirings/rpc/pikku-command-rpc-client.js';
|
|
19
|
+
import { pikkuWebSocketTyped } from '../src/wirings/channels/pikku-command-websocket-typed.js';
|
|
20
|
+
import { pikkuOpenAPI } from '../src/wirings/http/pikku-command-openapi.js';
|
|
21
|
+
import { pikkuMCP } from '../src/wirings/mcp/pikku-command-mcp.js';
|
|
22
|
+
import { pikkuQueueService } from '../src/wirings/queue/pikku-command-queue-service.js';
|
|
23
|
+
import { pikkuScheduler } from '../src/wirings/scheduler/pikku-command-scheduler.js';
|
|
24
24
|
import { pikkuSchemas } from '../src/schemas.js';
|
|
25
|
-
import { pikkuMCPJSON } from '../src/
|
|
25
|
+
import { pikkuMCPJSON } from '../src/wirings/mcp/pikku-command-mcp-json.js';
|
|
26
26
|
import { pikkuNext } from '../src/runtimes/nextjs/pikku-command-nextjs.js';
|
|
27
27
|
const generateBootstrapFile = async (logger, cliConfig, bootstrapFile, specificImports, schemas) => {
|
|
28
28
|
// Common imports that every bootstrap file needs
|
|
@@ -46,7 +46,7 @@ const runAll = async (logger, cliConfig, options) => {
|
|
|
46
46
|
typesDeclarationFileExists = false;
|
|
47
47
|
}
|
|
48
48
|
await pikkuFunctionTypes(logger, cliConfig, visitState, options);
|
|
49
|
-
// This is needed since the
|
|
49
|
+
// This is needed since the wireHTTP function will add the routes to the visitState
|
|
50
50
|
if (!typesDeclarationFileExists) {
|
|
51
51
|
logger.info(`• Type file first created, inspecting again...\x1b[0m`);
|
|
52
52
|
visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
@@ -63,44 +63,44 @@ const runAll = async (logger, cliConfig, options) => {
|
|
|
63
63
|
await pikkuRPC(logger, cliConfig, visitState);
|
|
64
64
|
await pikkuRPCMap(logger, cliConfig, visitState);
|
|
65
65
|
await pikkuRPCClient(logger, cliConfig);
|
|
66
|
-
allImports.push(cliConfig.
|
|
66
|
+
allImports.push(cliConfig.rpcWiringMetaFile);
|
|
67
67
|
const schemas = await pikkuSchemas(logger, cliConfig, visitState);
|
|
68
68
|
if (schemas) {
|
|
69
69
|
allImports.push(`${cliConfig.schemaDirectory}/register.gen.ts`);
|
|
70
70
|
}
|
|
71
71
|
// RPC bootstrap is always generated since RPC is always present
|
|
72
|
-
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.rpc, [cliConfig.
|
|
72
|
+
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.rpc, [cliConfig.rpcWiringMetaFile], schemas);
|
|
73
73
|
const http = await pikkuHTTP(logger, cliConfig, visitState);
|
|
74
74
|
if (http) {
|
|
75
75
|
await pikkuHTTPMap(logger, cliConfig, visitState);
|
|
76
76
|
await pikkuFetch(logger, cliConfig);
|
|
77
|
-
allImports.push(cliConfig.
|
|
78
|
-
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.http, [cliConfig.
|
|
77
|
+
allImports.push(cliConfig.httpWiringMetaFile, cliConfig.httpWiringsFile);
|
|
78
|
+
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.http, [cliConfig.httpWiringMetaFile, cliConfig.httpWiringsFile], schemas);
|
|
79
79
|
}
|
|
80
80
|
const scheduler = await pikkuScheduler(logger, cliConfig, visitState);
|
|
81
81
|
if (scheduler) {
|
|
82
|
-
allImports.push(cliConfig.
|
|
83
|
-
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.scheduler, [cliConfig.
|
|
82
|
+
allImports.push(cliConfig.schedulersWiringMetaFile, cliConfig.schedulersWiringFile);
|
|
83
|
+
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.scheduler, [cliConfig.schedulersWiringMetaFile, cliConfig.schedulersWiringFile], schemas);
|
|
84
84
|
}
|
|
85
85
|
const queues = await pikkuQueue(logger, cliConfig, visitState);
|
|
86
86
|
if (queues) {
|
|
87
87
|
await pikkuQueueMap(logger, cliConfig, visitState);
|
|
88
88
|
await pikkuQueueService(logger, cliConfig);
|
|
89
|
-
allImports.push(cliConfig.
|
|
90
|
-
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.queue, [cliConfig.
|
|
89
|
+
allImports.push(cliConfig.queueWorkersWiringMetaFile, cliConfig.queueWorkersWiringFile);
|
|
90
|
+
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.queue, [cliConfig.queueWorkersWiringMetaFile, cliConfig.queueWorkersWiringFile], schemas);
|
|
91
91
|
}
|
|
92
92
|
const channels = await pikkuChannels(logger, cliConfig, visitState);
|
|
93
93
|
if (channels) {
|
|
94
94
|
await pikkuChannelsMap(logger, cliConfig, visitState);
|
|
95
95
|
await pikkuWebSocketTyped(logger, cliConfig);
|
|
96
|
-
allImports.push(cliConfig.
|
|
97
|
-
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.channel, [cliConfig.
|
|
96
|
+
allImports.push(cliConfig.channelsWiringMetaFile, cliConfig.channelsWiringFile);
|
|
97
|
+
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.channel, [cliConfig.channelsWiringMetaFile, cliConfig.channelsWiringFile], schemas);
|
|
98
98
|
}
|
|
99
99
|
const mcp = await pikkuMCP(logger, cliConfig, visitState);
|
|
100
100
|
if (mcp) {
|
|
101
101
|
await pikkuMCPJSON(logger, cliConfig, visitState);
|
|
102
|
-
allImports.push(cliConfig.
|
|
103
|
-
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.mcp, [cliConfig.
|
|
102
|
+
allImports.push(cliConfig.mcpWiringsMetaFile, cliConfig.mcpWiringsFile);
|
|
103
|
+
await generateBootstrapFile(logger, cliConfig, cliConfig.bootstrapFiles.mcp, [cliConfig.mcpWiringsMetaFile, cliConfig.mcpWiringsFile], schemas);
|
|
104
104
|
}
|
|
105
105
|
if (cliConfig.nextBackendFile || cliConfig.nextHTTPFile) {
|
|
106
106
|
await pikkuNext(logger, cliConfig, visitState, options);
|
package/dist/bin/pikku-fetch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
2
|
-
import { pikkuFetch } from '../src/
|
|
2
|
+
import { pikkuFetch } from '../src/wirings/fetch/index.js';
|
|
3
3
|
import { CLILogger } from '../src/utils.js';
|
|
4
4
|
export const action = async (options) => {
|
|
5
5
|
const logger = new CLILogger({ logLogo: true });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CLILogger } from '../src/utils.js';
|
|
2
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
3
|
import { inspectorGlob } from '../src/inspector-glob.js';
|
|
4
|
-
import { pikkuOpenAPI } from '../src/
|
|
4
|
+
import { pikkuOpenAPI } from '../src/wirings/http/pikku-command-openapi.js';
|
|
5
5
|
async function action({ config, tags }) {
|
|
6
6
|
const logger = new CLILogger({ logLogo: true });
|
|
7
|
-
const cliConfig = await getPikkuCLIConfig(config, ['rootDir', '
|
|
7
|
+
const cliConfig = await getPikkuCLIConfig(config, ['rootDir', 'httpWiringsFile', 'openAPI', 'schemaDirectory', 'tsconfig'], {
|
|
8
8
|
tags: tags || [],
|
|
9
9
|
});
|
|
10
10
|
const visitState = await inspectorGlob(logger, cliConfig.rootDir, cliConfig.srcDirectories, cliConfig.filters);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
2
2
|
import { CLILogger } from '../src/utils.js';
|
|
3
|
-
import { pikkuQueueService } from '../src/
|
|
3
|
+
import { pikkuQueueService } from '../src/wirings/queue/pikku-command-queue-service.js';
|
|
4
4
|
export const action = async (options) => {
|
|
5
5
|
const logger = new CLILogger({ logLogo: true });
|
|
6
|
-
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir', '
|
|
6
|
+
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir', 'queueWiringsFile'], {
|
|
7
7
|
tags: options.tags,
|
|
8
8
|
types: options.types,
|
|
9
9
|
directories: options.directories,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CLILogger } from '../src/utils.js';
|
|
2
2
|
import { getPikkuCLIConfig } from '../src/pikku-cli-config.js';
|
|
3
|
-
import { pikkuWebSocketTyped } from '../src/
|
|
3
|
+
import { pikkuWebSocketTyped } from '../src/wirings/channels/pikku-command-websocket-typed.js';
|
|
4
4
|
export const action = async (options) => {
|
|
5
5
|
const logger = new CLILogger({ logLogo: true });
|
|
6
6
|
const cliConfig = await getPikkuCLIConfig(options.config, ['rootDir', 'schemaDirectory', 'configDir', 'fetchFile'], {
|
package/dist/bin/pikku.js
CHANGED
|
File without changes
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
2
|
export const pikkuChannels = async (logger, cliConfig, visitState) => {
|
|
3
3
|
return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
|
|
4
|
-
const {
|
|
4
|
+
const { channelsWiringFile, channelsWiringMetaFile, packageMappings } = cliConfig;
|
|
5
5
|
const { channels } = visitState;
|
|
6
|
-
await writeFileInDir(logger,
|
|
7
|
-
await writeFileInDir(logger,
|
|
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
8
|
});
|
|
9
9
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { logCommandInfoAndTime, serializeFileImports, writeFileInDir, } from '../../utils.js';
|
|
2
2
|
export const pikkuChannels = async (logger, cliConfig, visitState) => {
|
|
3
3
|
return await logCommandInfoAndTime(logger, 'Finding Channels', 'Found channels', [visitState.channels.files.size === 0], async () => {
|
|
4
|
-
const {
|
|
4
|
+
const { channelsWiringFile, channelsWiringMetaFile, packageMappings } = cliConfig;
|
|
5
5
|
const { channels } = visitState;
|
|
6
|
-
await writeFileInDir(logger,
|
|
7
|
-
await writeFileInDir(logger,
|
|
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
8
|
});
|
|
9
9
|
};
|
|
@@ -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
|
}
|
|
@@ -26,7 +26,7 @@ class PikkuWebSocketRoute<Channel extends keyof ChannelsMap, Route extends keyof
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export class PikkuWebSocket<Channel extends keyof ChannelsMap> extends CorePikkuWebsocket {
|
|
29
|
+
export class PikkuWebSocket<Channel extends keyof ChannelsMap, Topics 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 {};
|