@pikku/cli 0.9.14 → 0.9.16-next.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/.pikku/channel/pikku-channel-types.gen.ts +92 -0
- package/.pikku/cli/pikku-cli-types.gen.ts +71 -0
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +5 -0
- package/.pikku/cli/pikku-cli-wirings.gen.ts +4 -0
- package/.pikku/function/pikku-function-types.gen.ts +292 -0
- package/.pikku/function/pikku-functions-meta.gen.ts +817 -0
- package/.pikku/function/pikku-functions-meta.min.gen.ts +176 -0
- package/.pikku/function/pikku-functions.gen.ts +74 -0
- package/.pikku/http/pikku-http-types.gen.ts +61 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +138 -0
- package/.pikku/pikku-bootstrap.gen.ts +9 -0
- package/.pikku/pikku-services.gen.ts +24 -0
- package/.pikku/pikku-types.gen.ts +28 -0
- package/.pikku/queue/pikku-queue-types.gen.ts +28 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +46 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +80 -0
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +40 -0
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +26 -0
- package/.pikku/schemas/register.gen.ts +47 -0
- package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
- package/CHANGELOG.md +15 -0
- package/bin/pikku.ts +45 -14
- package/build.sh +53 -0
- package/cli.schema.json +1 -382
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +65 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js +54 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +55 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.js +30 -0
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +5 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +4 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +5 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +259 -0
- package/dist/.pikku/function/pikku-function-types.gen.js +175 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.js +817 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +176 -0
- package/dist/.pikku/function/pikku-functions.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions.gen.js +73 -0
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +49 -0
- package/dist/.pikku/http/pikku-http-types.gen.js +41 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +88 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +71 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +9 -0
- package/dist/.pikku/pikku-bootstrap.gen.js +9 -0
- package/dist/.pikku/pikku-services.gen.d.ts +16 -0
- package/dist/.pikku/pikku-services.gen.js +11 -0
- package/dist/.pikku/pikku-types.gen.d.ts +14 -0
- package/dist/.pikku/pikku-types.gen.js +21 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +24 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js +17 -0
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.d.ts +6 -0
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.js +6 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +1 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +40 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +22 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +17 -0
- package/dist/.pikku/schemas/register.gen.d.ts +1 -0
- package/dist/.pikku/schemas/register.gen.js +26 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
- package/dist/bin/pikku.d.ts +1 -1
- package/dist/bin/pikku.js +32 -14
- package/dist/src/cli.wiring.d.ts +1 -0
- package/dist/src/cli.wiring.js +75 -0
- package/dist/src/functions/commands/all.d.ts +1 -0
- package/dist/src/functions/commands/all.js +104 -0
- package/dist/src/functions/commands/watch.d.ts +1 -0
- package/dist/src/functions/commands/watch.js +47 -0
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.d.ts +1 -0
- package/dist/src/{runtimes → functions/runtimes}/nextjs/pikku-command-nextjs.js +28 -9
- package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-channels.js +24 -0
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +21 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +23 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +25 -0
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.js +24 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.d.ts +4 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +95 -0
- package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.js +2 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +100 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +33 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +24 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +7 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +54 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +9 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +84 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.d.ts +4 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.js +74 -0
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +14 -0
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +46 -0
- package/dist/src/functions/wirings/fetch/index.d.ts +1 -0
- package/dist/src/functions/wirings/fetch/index.js +24 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +32 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +20 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +28 -0
- package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.d.ts +1 -2
- package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.js +27 -10
- package/dist/src/functions/wirings/functions/pikku-function-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-function-types.js +20 -0
- package/dist/src/functions/wirings/functions/schemas.d.ts +4 -0
- package/dist/src/functions/wirings/functions/schemas.js +22 -0
- package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.js +4 -21
- package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +4 -0
- package/dist/src/functions/wirings/functions/serialize-function-types.js +295 -0
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +4 -0
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +31 -0
- package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.d.ts +2 -1
- package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.js +2 -2
- package/dist/src/functions/wirings/http/pikku-command-http-map.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-map.js +23 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +25 -0
- package/dist/src/functions/wirings/http/pikku-command-http-types.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-types.js +21 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +34 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.js +25 -0
- package/dist/src/functions/wirings/http/serialize-http-types.d.ts +4 -0
- package/dist/src/functions/wirings/http/serialize-http-types.js +64 -0
- package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.js +2 -2
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.d.ts +1 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +28 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.d.ts +1 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.js +21 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.d.ts +1 -0
- package/dist/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.js +22 -5
- package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.d.ts +4 -0
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +141 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +38 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.d.ts +8 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +50 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-imports.d.ts +2 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +43 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +23 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +24 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.js +21 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +26 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.js +23 -0
- package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue.js +25 -0
- package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.js +2 -2
- package/dist/src/functions/wirings/queue/serialize-queue-types.d.ts +4 -0
- package/dist/src/functions/wirings/queue/serialize-queue-types.js +31 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.d.ts +1 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +25 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.d.ts +2 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +36 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +1 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +22 -0
- package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.js +2 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.d.ts +1 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.js +21 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +26 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.d.ts +4 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +29 -0
- package/dist/src/middleware/log-command-info-and-time.d.ts +19 -0
- package/dist/src/middleware/log-command-info-and-time.js +27 -0
- package/dist/src/serialize-pikku-types.js +2 -2
- package/dist/src/services/cli-logger-forwarder.service.d.ts +26 -0
- package/dist/src/services/cli-logger-forwarder.service.js +55 -0
- package/dist/src/services/cli-logger.service.d.ts +19 -0
- package/dist/src/services/cli-logger.service.js +66 -0
- package/dist/src/services.d.ts +15 -0
- package/dist/src/services.js +64 -0
- package/dist/src/utils/check-required-types.d.ts +10 -0
- package/dist/src/utils/check-required-types.js +31 -0
- package/dist/src/utils/custom-types-generator.d.ts +2 -0
- package/dist/src/utils/custom-types-generator.js +37 -0
- package/dist/src/utils/file-import-path.d.ts +1 -0
- package/dist/src/utils/file-import-path.js +43 -0
- package/dist/src/utils/file-imports-serializer.d.ts +1 -0
- package/dist/src/utils/file-imports-serializer.js +13 -0
- package/dist/src/utils/file-writer.d.ts +6 -0
- package/dist/src/utils/file-writer.js +40 -0
- package/dist/src/utils/generate-bootstrap-file.d.ts +3 -0
- package/dist/src/utils/generate-bootstrap-file.js +21 -0
- package/dist/src/utils/pikku-cli-config.d.ts +5 -0
- package/dist/src/utils/pikku-cli-config.js +243 -0
- package/dist/src/utils/pikku-files-and-methods.d.ts +21 -0
- package/dist/src/utils/pikku-files-and-methods.js +70 -0
- package/dist/src/{schema-generator.d.ts → utils/schema-generator.d.ts} +1 -1
- package/dist/src/{schema-generator.js → utils/schema-generator.js} +1 -1
- package/dist/src/{serialize-import-map.js → utils/serialize-import-map.js} +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/pikku.config.json +24 -0
- package/src/cli.wiring.ts +75 -0
- package/src/functions/commands/all.ts +141 -0
- package/src/functions/commands/watch.ts +58 -0
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +111 -0
- package/src/functions/wirings/channels/pikku-channels.ts +40 -0
- package/src/functions/wirings/channels/pikku-command-channel-types.ts +27 -0
- package/src/functions/wirings/channels/pikku-command-channels-map.ts +31 -0
- package/src/functions/wirings/channels/pikku-command-channels.ts +45 -0
- package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +33 -0
- package/src/functions/wirings/channels/serialize-channel-types.ts +95 -0
- package/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.ts +2 -2
- package/src/functions/wirings/cli/pikku-command-cli-entry.ts +173 -0
- package/src/functions/wirings/cli/pikku-command-cli-types.ts +50 -0
- package/src/functions/wirings/cli/pikku-command-cli.ts +41 -0
- package/src/functions/wirings/cli/serialize-channel-cli-client.ts +72 -0
- package/src/functions/wirings/cli/serialize-channel-cli.ts +123 -0
- package/src/functions/wirings/cli/serialize-cli-types.ts +80 -0
- package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +75 -0
- package/src/functions/wirings/fetch/index.ts +32 -0
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +51 -0
- package/src/functions/wirings/functions/pikku-command-function-types.ts +45 -0
- package/src/functions/wirings/functions/pikku-command-functions.ts +61 -0
- package/src/{wirings → functions/wirings}/functions/pikku-command-services.ts +41 -44
- package/src/functions/wirings/functions/pikku-function-types.ts +45 -0
- package/src/functions/wirings/functions/schemas.ts +47 -0
- package/src/{wirings → functions/wirings}/functions/serialize-function-imports.ts +4 -30
- package/src/functions/wirings/functions/serialize-function-types.ts +303 -0
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +39 -0
- package/src/{wirings → functions/wirings}/http/openapi-spec-generator.ts +3 -1
- package/src/functions/wirings/http/pikku-command-http-map.ts +32 -0
- package/src/functions/wirings/http/pikku-command-http-routes.ts +41 -0
- package/src/functions/wirings/http/pikku-command-http-types.ts +27 -0
- package/src/functions/wirings/http/pikku-command-openapi.ts +57 -0
- package/src/functions/wirings/http/pikku-http-routes.ts +40 -0
- package/src/functions/wirings/http/serialize-http-types.ts +64 -0
- package/src/{wirings → functions/wirings}/http/serialize-typed-http-map.ts +2 -2
- package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +38 -0
- package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +27 -0
- package/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.ts +55 -46
- package/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.ts +1 -1
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +141 -0
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +65 -0
- package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +61 -0
- package/src/functions/wirings/middleware/serialize-middleware-imports.ts +78 -0
- package/src/functions/wirings/queue/pikku-command-queue-map.ts +31 -0
- package/src/functions/wirings/queue/pikku-command-queue-service.ts +33 -0
- package/src/functions/wirings/queue/pikku-command-queue-types.ts +27 -0
- package/src/functions/wirings/queue/pikku-command-queue.ts +46 -0
- package/src/functions/wirings/queue/pikku-queue-map.ts +31 -0
- package/src/functions/wirings/queue/pikku-queue.ts +44 -0
- package/src/{wirings → functions/wirings}/queue/serialize-queue-map.ts +2 -2
- package/src/functions/wirings/queue/serialize-queue-types.ts +31 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +32 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +52 -0
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +28 -0
- package/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.ts +2 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +27 -0
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +46 -0
- package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +29 -0
- package/src/middleware/log-command-info-and-time.ts +61 -0
- package/src/serialize-pikku-types.ts +2 -2
- package/src/services/cli-logger-forwarder.service.ts +77 -0
- package/src/services/cli-logger.service.ts +78 -0
- package/src/services.ts +111 -0
- package/src/utils/check-required-types.ts +53 -0
- package/src/utils/custom-types-generator.ts +49 -0
- package/src/{utils.test.ts → utils/file-import-path.test.ts} +1 -1
- package/src/utils/file-import-path.ts +53 -0
- package/src/utils/file-imports-serializer.ts +25 -0
- package/src/utils/file-writer.ts +56 -0
- package/src/utils/generate-bootstrap-file.ts +43 -0
- package/src/utils/pikku-cli-config.ts +356 -0
- package/src/utils/pikku-files-and-methods.ts +148 -0
- package/src/{schema-generator.ts → utils/schema-generator.ts} +3 -1
- package/src/{serialize-import-map.ts → utils/serialize-import-map.ts} +1 -1
- package/tsconfig.json +2 -2
- package/types/application-types.d.ts +20 -0
- package/types/config.d.ts +192 -0
- package/bin/pikku-all.ts +0 -349
- package/bin/pikku-fetch.ts +0 -27
- package/bin/pikku-nextjs.ts +0 -44
- package/bin/pikku-openapi.ts +0 -31
- package/bin/pikku-queue-service.ts +0 -28
- package/bin/pikku-rpc.ts +0 -28
- package/bin/pikku-schemas.ts +0 -31
- package/bin/pikku-websocket.ts +0 -28
- package/dist/bin/pikku-all.d.ts +0 -4
- package/dist/bin/pikku-all.js +0 -194
- package/dist/bin/pikku-fetch.d.ts +0 -4
- package/dist/bin/pikku-fetch.js +0 -19
- package/dist/bin/pikku-nextjs.d.ts +0 -4
- package/dist/bin/pikku-nextjs.js +0 -24
- package/dist/bin/pikku-openapi.d.ts +0 -2
- package/dist/bin/pikku-openapi.js +0 -19
- package/dist/bin/pikku-queue-service.d.ts +0 -4
- package/dist/bin/pikku-queue-service.js +0 -19
- package/dist/bin/pikku-rpc.d.ts +0 -4
- package/dist/bin/pikku-rpc.js +0 -19
- package/dist/bin/pikku-schemas.d.ts +0 -2
- package/dist/bin/pikku-schemas.js +0 -21
- package/dist/bin/pikku-websocket.d.ts +0 -4
- package/dist/bin/pikku-websocket.js +0 -19
- package/dist/src/inspector-glob.d.ts +0 -2
- package/dist/src/inspector-glob.js +0 -12
- package/dist/src/pikku-cli-config.d.ts +0 -56
- package/dist/src/pikku-cli-config.js +0 -203
- package/dist/src/pikku-command-schemas.d.ts +0 -2
- package/dist/src/pikku-command-schemas.js +0 -8
- package/dist/src/runtimes/nextjs/pikku-command-nextjs.d.ts +0 -2
- package/dist/src/schemas.d.ts +0 -2
- package/dist/src/schemas.js +0 -8
- package/dist/src/types.d.ts +0 -5
- package/dist/src/utils.d.ts +0 -60
- package/dist/src/utils.js +0 -248
- package/dist/src/wirings/channels/pikku-channels.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-channels.js +0 -9
- package/dist/src/wirings/channels/pikku-command-channels-map.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-channels-map.js +0 -8
- package/dist/src/wirings/channels/pikku-command-channels.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-channels.js +0 -9
- package/dist/src/wirings/channels/pikku-command-websocket-typed.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-websocket-typed.js +0 -15
- package/dist/src/wirings/fetch/index.d.ts +0 -2
- package/dist/src/wirings/fetch/index.js +0 -12
- package/dist/src/wirings/functions/pikku-command-function-types.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-command-function-types.js +0 -13
- package/dist/src/wirings/functions/pikku-command-functions.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-command-functions.js +0 -14
- package/dist/src/wirings/functions/pikku-function-types.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-function-types.js +0 -13
- package/dist/src/wirings/http/pikku-command-http-map.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-http-map.js +0 -8
- package/dist/src/wirings/http/pikku-command-http-routes.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-http-routes.js +0 -9
- package/dist/src/wirings/http/pikku-command-openapi.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-openapi.js +0 -20
- package/dist/src/wirings/http/pikku-http-routes.d.ts +0 -2
- package/dist/src/wirings/http/pikku-http-routes.js +0 -9
- package/dist/src/wirings/mcp/pikku-command-mcp-json.d.ts +0 -2
- package/dist/src/wirings/mcp/pikku-command-mcp-json.js +0 -13
- package/dist/src/wirings/mcp/pikku-command-mcp.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-map.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-map.js +0 -8
- package/dist/src/wirings/queue/pikku-command-queue-service.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-service.js +0 -15
- package/dist/src/wirings/queue/pikku-command-queue.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue.js +0 -10
- package/dist/src/wirings/queue/pikku-queue-map.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-queue-map.js +0 -8
- package/dist/src/wirings/queue/pikku-queue.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-queue.js +0 -10
- package/dist/src/wirings/rpc/pikku-command-rpc-client.d.ts +0 -2
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +0 -15
- package/dist/src/wirings/rpc/pikku-command-rpc-map.d.ts +0 -3
- package/dist/src/wirings/rpc/pikku-command-rpc-map.js +0 -14
- package/dist/src/wirings/rpc/pikku-command-rpc.d.ts +0 -2
- package/dist/src/wirings/rpc/pikku-command-rpc.js +0 -8
- package/dist/src/wirings/scheduler/pikku-command-scheduler.d.ts +0 -2
- package/dist/src/wirings/scheduler/pikku-command-scheduler.js +0 -10
- package/src/inspector-glob.ts +0 -30
- package/src/pikku-cli-config.ts +0 -387
- package/src/pikku-command-schemas.ts +0 -35
- package/src/runtimes/nextjs/pikku-command-nextjs.ts +0 -110
- package/src/schemas.ts +0 -35
- package/src/types.ts +0 -16
- package/src/utils.ts +0 -420
- package/src/wirings/channels/pikku-channels.ts +0 -41
- package/src/wirings/channels/pikku-command-channels-map.ts +0 -26
- package/src/wirings/channels/pikku-command-channels.ts +0 -39
- package/src/wirings/channels/pikku-command-websocket-typed.ts +0 -36
- package/src/wirings/fetch/index.ts +0 -33
- package/src/wirings/functions/pikku-command-function-types.ts +0 -53
- package/src/wirings/functions/pikku-command-functions.ts +0 -48
- package/src/wirings/functions/pikku-function-types.ts +0 -52
- package/src/wirings/http/pikku-command-http-map.ts +0 -27
- package/src/wirings/http/pikku-command-http-routes.ts +0 -40
- package/src/wirings/http/pikku-command-openapi.ts +0 -55
- package/src/wirings/http/pikku-http-routes.ts +0 -40
- package/src/wirings/mcp/pikku-command-mcp-json.ts +0 -33
- package/src/wirings/queue/pikku-command-queue-map.ts +0 -26
- package/src/wirings/queue/pikku-command-queue-service.ts +0 -36
- package/src/wirings/queue/pikku-command-queue.ts +0 -45
- package/src/wirings/queue/pikku-queue-map.ts +0 -26
- package/src/wirings/queue/pikku-queue.ts +0 -43
- package/src/wirings/rpc/pikku-command-rpc-client.ts +0 -35
- package/src/wirings/rpc/pikku-command-rpc-map.ts +0 -49
- package/src/wirings/rpc/pikku-command-rpc.ts +0 -24
- package/src/wirings/scheduler/pikku-command-scheduler.ts +0 -43
- /package/dist/{src/types.js → .pikku/cli/pikku-cli-wirings-meta.gen.d.ts} +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.d.ts +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.js +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.d.ts +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.js +0 -0
- /package/dist/src/{serialize-import-map.d.ts → utils/serialize-import-map.d.ts} +0 -0
- /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.ts +0 -0
- /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/queue/serialize-queue-meta.ts +0 -0
- /package/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.ts +0 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { serializeMCPTypes } from './serialize-mcp-types.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuMCPTypes: any = pikkuSessionlessFunc<void, void>({
|
|
8
|
+
func: async ({ logger, config }) => {
|
|
9
|
+
const { mcpTypesFile, functionTypesFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const functionTypesImportPath = getFileImportRelativePath(
|
|
12
|
+
mcpTypesFile,
|
|
13
|
+
functionTypesFile,
|
|
14
|
+
packageMappings
|
|
15
|
+
)
|
|
16
|
+
const content = serializeMCPTypes(functionTypesImportPath)
|
|
17
|
+
await writeFileInDir(logger, mcpTypesFile, content)
|
|
18
|
+
},
|
|
19
|
+
middleware: [
|
|
20
|
+
logCommandInfoAndTime({
|
|
21
|
+
commandStart: 'Creating MCP types',
|
|
22
|
+
commandEnd: 'Created MCP types',
|
|
23
|
+
skipCondition: false,
|
|
24
|
+
skipMessage: '',
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
})
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from '../../utils.js'
|
|
6
|
-
import { PikkuCommand } from '../../types.js'
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
7
5
|
import { readFile } from 'fs/promises'
|
|
8
6
|
import { join } from 'path'
|
|
9
7
|
|
|
@@ -60,51 +58,62 @@ const generateArgumentsFromSchema = async (
|
|
|
60
58
|
}
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
export const pikkuMCP:
|
|
64
|
-
logger,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
61
|
+
export const pikkuMCP: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
62
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
63
|
+
const { mcpEndpoints, functions } = await getInspectorState()
|
|
64
|
+
const {
|
|
65
|
+
mcpWiringsFile,
|
|
66
|
+
mcpWiringsMetaFile,
|
|
67
|
+
packageMappings,
|
|
68
|
+
schemaDirectory,
|
|
69
|
+
} = config
|
|
70
|
+
|
|
71
|
+
await writeFileInDir(
|
|
72
|
+
logger,
|
|
73
|
+
mcpWiringsFile,
|
|
74
|
+
serializeFileImports(
|
|
75
|
+
'wireMCPResource or wireMCPTool',
|
|
76
76
|
mcpWiringsFile,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
mcpWiringsFile,
|
|
80
|
-
mcpEndpoints.files,
|
|
81
|
-
packageMappings
|
|
82
|
-
)
|
|
77
|
+
mcpEndpoints.files,
|
|
78
|
+
packageMappings
|
|
83
79
|
)
|
|
80
|
+
)
|
|
84
81
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
82
|
+
// Populate arguments for prompts meta before serializing
|
|
83
|
+
const promptsMetaWithArguments = { ...mcpEndpoints.promptsMeta }
|
|
84
|
+
for (const promptMeta of Object.values(promptsMetaWithArguments)) {
|
|
85
|
+
const functionMeta = functions.meta[promptMeta.pikkuFuncName]
|
|
86
|
+
if (functionMeta) {
|
|
87
|
+
const inputType = functionMeta.inputs?.[0]
|
|
88
|
+
promptMeta.arguments = await generateArgumentsFromSchema(
|
|
89
|
+
inputType || null,
|
|
90
|
+
schemaDirectory || '',
|
|
91
|
+
functions.typesMap,
|
|
92
|
+
logger
|
|
93
|
+
)
|
|
98
94
|
}
|
|
95
|
+
}
|
|
99
96
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
97
|
+
await writeFileInDir(
|
|
98
|
+
logger,
|
|
99
|
+
mcpWiringsMetaFile,
|
|
100
|
+
`import { pikkuState } from '@pikku/core'
|
|
104
101
|
pikkuState('mcp', 'resourcesMeta', ${JSON.stringify(mcpEndpoints.resourcesMeta, null, 2)})
|
|
105
102
|
pikkuState('mcp', 'toolsMeta', ${JSON.stringify(mcpEndpoints.toolsMeta, null, 2)})
|
|
106
103
|
pikkuState('mcp', 'promptsMeta', ${JSON.stringify(promptsMetaWithArguments, null, 2)})`
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
return true
|
|
107
|
+
},
|
|
108
|
+
middleware: [
|
|
109
|
+
logCommandInfoAndTime({
|
|
110
|
+
commandStart: 'Finding MCP endpoints',
|
|
111
|
+
commandEnd: 'Found MCP endpoints',
|
|
112
|
+
skipCondition: async ({ getInspectorState }) => {
|
|
113
|
+
const { mcpEndpoints } = await getInspectorState()
|
|
114
|
+
return mcpEndpoints.files.size === 0
|
|
115
|
+
},
|
|
116
|
+
skipMessage: 'none found',
|
|
117
|
+
}),
|
|
118
|
+
],
|
|
119
|
+
})
|
|
@@ -3,7 +3,7 @@ import { join } from 'path'
|
|
|
3
3
|
import { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core'
|
|
4
4
|
import { FunctionsMeta, JSONValue } from '@pikku/core'
|
|
5
5
|
import { TypesMap } from '@pikku/inspector'
|
|
6
|
-
import { CLILogger } from '
|
|
6
|
+
import { CLILogger } from '../../../services/cli-logger.service.js'
|
|
7
7
|
|
|
8
8
|
interface MCPEndpoint {
|
|
9
9
|
name: string
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates type definitions for MCP wirings
|
|
3
|
+
*/
|
|
4
|
+
export const serializeMCPTypes = (functionTypesImportPath: string) => {
|
|
5
|
+
return `/**
|
|
6
|
+
* This file was generated by the @pikku/cli
|
|
7
|
+
* MCP-specific type definitions for tree-shaking optimization
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
CoreMCPResource,
|
|
12
|
+
CoreMCPTool,
|
|
13
|
+
CoreMCPPrompt,
|
|
14
|
+
wireMCPResource as wireMCPResourceCore,
|
|
15
|
+
wireMCPTool as wireMCPToolCore,
|
|
16
|
+
wireMCPPrompt as wireMCPPromptCore,
|
|
17
|
+
MCPResourceResponse,
|
|
18
|
+
MCPToolResponse,
|
|
19
|
+
MCPPromptResponse
|
|
20
|
+
} from '@pikku/core'
|
|
21
|
+
|
|
22
|
+
import type { PikkuFunctionConfig, PikkuFunctionSessionless } from '${functionTypesImportPath}'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Type definition for MCP resources that provide data to AI models.
|
|
26
|
+
*
|
|
27
|
+
* @template In - Input type for the resource request
|
|
28
|
+
*/
|
|
29
|
+
type MCPResourceWiring<In> = CoreMCPResource<PikkuFunctionConfig<In, MCPResourceResponse>>
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Type definition for MCP tools that AI models can invoke.
|
|
33
|
+
*
|
|
34
|
+
* @template In - Input type for the tool invocation
|
|
35
|
+
*/
|
|
36
|
+
type MCPToolWiring<In> = CoreMCPTool<PikkuFunctionConfig<In, MCPToolResponse>>
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Type definition for MCP prompts that provide templates to AI models.
|
|
40
|
+
*
|
|
41
|
+
* @template In - Input type for the prompt parameters
|
|
42
|
+
*/
|
|
43
|
+
type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionConfig<In, MCPPromptResponse>>
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Registers an MCP resource with the Pikku framework.
|
|
47
|
+
* Resources provide data that AI models can access.
|
|
48
|
+
*
|
|
49
|
+
* @template In - Input type for the resource request
|
|
50
|
+
* @param mcpResource - MCP resource definition with data provider function
|
|
51
|
+
*/
|
|
52
|
+
export const wireMCPResource = <In>(
|
|
53
|
+
mcpResource: MCPResourceWiring<In>
|
|
54
|
+
) => {
|
|
55
|
+
wireMCPResourceCore(mcpResource as any)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Registers an MCP tool with the Pikku framework.
|
|
60
|
+
* Tools are functions that AI models can invoke.
|
|
61
|
+
*
|
|
62
|
+
* @template In - Input type for the tool invocation
|
|
63
|
+
* @param mcpTool - MCP tool definition with action function
|
|
64
|
+
*/
|
|
65
|
+
export const wireMCPTool = <In>(
|
|
66
|
+
mcpTool: MCPToolWiring<In>
|
|
67
|
+
) => {
|
|
68
|
+
wireMCPToolCore(mcpTool as any)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Registers an MCP prompt with the Pikku framework.
|
|
73
|
+
* Prompts provide templates that AI models can use.
|
|
74
|
+
*
|
|
75
|
+
* @template In - Input type for the prompt parameters
|
|
76
|
+
* @param mcpPrompt - MCP prompt definition with template function
|
|
77
|
+
*/
|
|
78
|
+
export const wireMCPPrompt = <In>(
|
|
79
|
+
mcpPrompt: MCPPromptWiring<In>
|
|
80
|
+
) => {
|
|
81
|
+
wireMCPPromptCore(mcpPrompt as any)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Creates a function for handling MCP prompt requests.
|
|
86
|
+
* These functions generate prompt templates for AI models.
|
|
87
|
+
*
|
|
88
|
+
* @template In - Input type for the prompt parameters
|
|
89
|
+
* @param func - Function definition, either direct function or configuration object
|
|
90
|
+
* @returns The unwrapped function for internal use
|
|
91
|
+
*/
|
|
92
|
+
export const pikkuMCPPromptFunc = <In>(
|
|
93
|
+
func:
|
|
94
|
+
| PikkuFunctionSessionless<In, MCPPromptResponse>
|
|
95
|
+
| {
|
|
96
|
+
func: PikkuFunctionSessionless<In, MCPPromptResponse>
|
|
97
|
+
name?: string
|
|
98
|
+
}
|
|
99
|
+
) => {
|
|
100
|
+
return typeof func === 'function' ? func : func.func
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Creates a function for handling MCP tool invocations.
|
|
105
|
+
* These functions perform actions that AI models can request.
|
|
106
|
+
*
|
|
107
|
+
* @template In - Input type for the tool invocation
|
|
108
|
+
* @param func - Function definition, either direct function or configuration object
|
|
109
|
+
* @returns The unwrapped function for internal use
|
|
110
|
+
*/
|
|
111
|
+
export const pikkuMCPToolFunc = <In>(
|
|
112
|
+
func:
|
|
113
|
+
| PikkuFunctionSessionless<In, MCPToolResponse, null, true>
|
|
114
|
+
| {
|
|
115
|
+
func: PikkuFunctionSessionless<In, MCPToolResponse, null, true>
|
|
116
|
+
name?: string
|
|
117
|
+
}
|
|
118
|
+
) => {
|
|
119
|
+
return typeof func === 'function' ? func : func.func
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Creates a function for handling MCP resource requests.
|
|
124
|
+
* These functions provide data that AI models can access.
|
|
125
|
+
*
|
|
126
|
+
* @template In - Input type for the resource request
|
|
127
|
+
* @param func - Function definition, either direct function or configuration object
|
|
128
|
+
* @returns The unwrapped function for internal use
|
|
129
|
+
*/
|
|
130
|
+
export const pikkuMCPResourceFunc = <In>(
|
|
131
|
+
func:
|
|
132
|
+
| PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
|
|
133
|
+
| {
|
|
134
|
+
func: PikkuFunctionSessionless<In, MCPResourceResponse, null, true>
|
|
135
|
+
name?: string
|
|
136
|
+
}
|
|
137
|
+
) => {
|
|
138
|
+
return typeof func === 'function' ? func : func.func
|
|
139
|
+
}
|
|
140
|
+
`
|
|
141
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
import { serializeMiddlewareImports } from './serialize-middleware-imports.js'
|
|
5
|
+
import { serializeMiddlewareGroupsMeta } from './serialize-middleware-groups-meta.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuMiddleware: any = pikkuSessionlessFunc<
|
|
8
|
+
void,
|
|
9
|
+
boolean | undefined
|
|
10
|
+
>({
|
|
11
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
12
|
+
const state = await getInspectorState()
|
|
13
|
+
const { middleware } = state
|
|
14
|
+
const { middlewareFile, packageMappings } = config
|
|
15
|
+
|
|
16
|
+
let filesGenerated = false
|
|
17
|
+
|
|
18
|
+
// Check if there are any middleware group factories
|
|
19
|
+
const hasHTTPFactories = Array.from(
|
|
20
|
+
state.http.routeMiddleware.values()
|
|
21
|
+
).some((meta) => meta.exportName && meta.isFactory)
|
|
22
|
+
const hasTagFactories = Array.from(
|
|
23
|
+
state.middleware.tagMiddleware.values()
|
|
24
|
+
).some((meta) => meta.exportName && meta.isFactory)
|
|
25
|
+
const hasFactories = hasHTTPFactories || hasTagFactories
|
|
26
|
+
|
|
27
|
+
// Generate middleware imports file if there are factories
|
|
28
|
+
if (hasFactories) {
|
|
29
|
+
await writeFileInDir(
|
|
30
|
+
logger,
|
|
31
|
+
middlewareFile,
|
|
32
|
+
serializeMiddlewareImports(
|
|
33
|
+
middlewareFile,
|
|
34
|
+
middleware,
|
|
35
|
+
state.http,
|
|
36
|
+
packageMappings
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
filesGenerated = true
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Generate middleware groups metadata file
|
|
43
|
+
const hasHTTPGroups = state.http.routeMiddleware.size > 0
|
|
44
|
+
const hasTagGroups = state.middleware.tagMiddleware.size > 0
|
|
45
|
+
|
|
46
|
+
if (hasHTTPGroups || hasTagGroups) {
|
|
47
|
+
await writeFileInDir(
|
|
48
|
+
logger,
|
|
49
|
+
config.middlewareGroupsMetaFile,
|
|
50
|
+
serializeMiddlewareGroupsMeta(state)
|
|
51
|
+
)
|
|
52
|
+
filesGenerated = true
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return filesGenerated
|
|
56
|
+
},
|
|
57
|
+
middleware: [
|
|
58
|
+
logCommandInfoAndTime({
|
|
59
|
+
commandStart: 'Serializing Pikku middleware',
|
|
60
|
+
commandEnd: 'Serialized Pikku middleware',
|
|
61
|
+
skipCondition: false,
|
|
62
|
+
skipMessage: '',
|
|
63
|
+
}),
|
|
64
|
+
],
|
|
65
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { InspectorState } from '@pikku/inspector'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Generates the middleware groups metadata file that stores metadata about
|
|
5
|
+
* tag-based and HTTP middleware groups for visualization and inspection.
|
|
6
|
+
*
|
|
7
|
+
* This includes services, middleware count, factory status, etc.
|
|
8
|
+
*/
|
|
9
|
+
export const serializeMiddlewareGroupsMeta = (state: InspectorState) => {
|
|
10
|
+
const lines: string[] = [
|
|
11
|
+
`/**`,
|
|
12
|
+
` * This file was generated by the @pikku/cli`,
|
|
13
|
+
` */`,
|
|
14
|
+
`import { pikkuState } from '@pikku/core'`,
|
|
15
|
+
``,
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
// Serialize HTTP middleware groups metadata
|
|
19
|
+
const httpGroups: Record<string, any> = {}
|
|
20
|
+
for (const [pattern, meta] of state.http.routeMiddleware.entries()) {
|
|
21
|
+
httpGroups[pattern] = {
|
|
22
|
+
exportName: meta.exportName,
|
|
23
|
+
sourceFile: meta.sourceFile,
|
|
24
|
+
position: meta.position,
|
|
25
|
+
services: meta.services,
|
|
26
|
+
middlewareCount: meta.middlewareCount,
|
|
27
|
+
isFactory: meta.isFactory,
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (Object.keys(httpGroups).length > 0) {
|
|
32
|
+
lines.push(`// HTTP middleware groups metadata`)
|
|
33
|
+
lines.push(
|
|
34
|
+
`pikkuState('middleware', 'httpGroupMeta', ${JSON.stringify(httpGroups, null, 2)})`
|
|
35
|
+
)
|
|
36
|
+
lines.push(``)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Serialize tag middleware groups metadata
|
|
40
|
+
const tagGroups: Record<string, any> = {}
|
|
41
|
+
for (const [tag, meta] of state.middleware.tagMiddleware.entries()) {
|
|
42
|
+
tagGroups[tag] = {
|
|
43
|
+
exportName: meta.exportName,
|
|
44
|
+
sourceFile: meta.sourceFile,
|
|
45
|
+
position: meta.position,
|
|
46
|
+
services: meta.services,
|
|
47
|
+
middlewareCount: meta.middlewareCount,
|
|
48
|
+
isFactory: meta.isFactory,
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (Object.keys(tagGroups).length > 0) {
|
|
53
|
+
lines.push(`// Tag middleware groups metadata`)
|
|
54
|
+
lines.push(
|
|
55
|
+
`pikkuState('middleware', 'tagGroupMeta', ${JSON.stringify(tagGroups, null, 2)})`
|
|
56
|
+
)
|
|
57
|
+
lines.push(``)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return lines.join('\n')
|
|
61
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
2
|
+
import type {
|
|
3
|
+
InspectorMiddlewareState,
|
|
4
|
+
InspectorHTTPState,
|
|
5
|
+
InspectorState,
|
|
6
|
+
} from '@pikku/inspector'
|
|
7
|
+
|
|
8
|
+
export const serializeMiddlewareImports = (
|
|
9
|
+
outputPath: string,
|
|
10
|
+
middlewareState: InspectorMiddlewareState,
|
|
11
|
+
httpState: InspectorHTTPState,
|
|
12
|
+
packageMappings: Record<string, string> = {},
|
|
13
|
+
fullState?: InspectorState
|
|
14
|
+
) => {
|
|
15
|
+
const serializedImports: string[] = []
|
|
16
|
+
const serializedFactoryCalls: string[] = []
|
|
17
|
+
|
|
18
|
+
// Collect factory imports and calls for HTTP middleware groups
|
|
19
|
+
const httpFactories = new Map<
|
|
20
|
+
string,
|
|
21
|
+
{ exportName: string; filePath: string }
|
|
22
|
+
>()
|
|
23
|
+
for (const [, groupMeta] of httpState.routeMiddleware.entries()) {
|
|
24
|
+
if (groupMeta.exportName && groupMeta.isFactory) {
|
|
25
|
+
const filePath = getFileImportRelativePath(
|
|
26
|
+
outputPath,
|
|
27
|
+
groupMeta.sourceFile,
|
|
28
|
+
packageMappings
|
|
29
|
+
)
|
|
30
|
+
httpFactories.set(groupMeta.exportName, {
|
|
31
|
+
exportName: groupMeta.exportName,
|
|
32
|
+
filePath,
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Collect factory imports and calls for tag middleware groups
|
|
38
|
+
const tagFactories = new Map<
|
|
39
|
+
string,
|
|
40
|
+
{ exportName: string; filePath: string }
|
|
41
|
+
>()
|
|
42
|
+
for (const [, groupMeta] of middlewareState.tagMiddleware.entries()) {
|
|
43
|
+
if (groupMeta.exportName && groupMeta.isFactory) {
|
|
44
|
+
const filePath = getFileImportRelativePath(
|
|
45
|
+
outputPath,
|
|
46
|
+
groupMeta.sourceFile,
|
|
47
|
+
packageMappings
|
|
48
|
+
)
|
|
49
|
+
tagFactories.set(groupMeta.exportName, {
|
|
50
|
+
exportName: groupMeta.exportName,
|
|
51
|
+
filePath,
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Combine all factories and deduplicate by exportName (same factory might be used in multiple groups)
|
|
57
|
+
const allFactories = new Map([...httpFactories, ...tagFactories])
|
|
58
|
+
|
|
59
|
+
// Add factory imports and calls
|
|
60
|
+
if (allFactories.size > 0) {
|
|
61
|
+
serializedImports.push(
|
|
62
|
+
'/* Call middleware group factories to register at module evaluation */'
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
// Import factories
|
|
66
|
+
for (const [exportName, { filePath }] of allFactories) {
|
|
67
|
+
serializedImports.push(`import { ${exportName} } from '${filePath}'`)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Call factories
|
|
71
|
+
for (const [exportName] of allFactories) {
|
|
72
|
+
serializedFactoryCalls.push(`${exportName}()`)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Return combined output
|
|
77
|
+
return [...serializedImports, ...serializedFactoryCalls].join('\n')
|
|
78
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
import { serializeQueueMap } from './serialize-queue-map.js'
|
|
5
|
+
|
|
6
|
+
export const pikkuQueueMap: any = pikkuSessionlessFunc<void, void>({
|
|
7
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
8
|
+
const { queueWorkers, functions } = await getInspectorState()
|
|
9
|
+
const { queueMapDeclarationFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const content = serializeQueueMap(
|
|
12
|
+
queueMapDeclarationFile,
|
|
13
|
+
packageMappings,
|
|
14
|
+
functions.typesMap,
|
|
15
|
+
functions.meta,
|
|
16
|
+
queueWorkers.meta
|
|
17
|
+
)
|
|
18
|
+
await writeFileInDir(logger, queueMapDeclarationFile, content)
|
|
19
|
+
},
|
|
20
|
+
middleware: [
|
|
21
|
+
logCommandInfoAndTime({
|
|
22
|
+
commandStart: 'Creating Queue map',
|
|
23
|
+
commandEnd: 'Created Queue map',
|
|
24
|
+
skipCondition: async ({ getInspectorState }) => {
|
|
25
|
+
const { queueWorkers } = await getInspectorState()
|
|
26
|
+
return queueWorkers.files.size === 0
|
|
27
|
+
},
|
|
28
|
+
skipMessage: 'none found',
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { serializeQueueWrapper } from './serialize-queue-wrapper.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuQueueService: any = pikkuSessionlessFunc<void, void>({
|
|
8
|
+
func: async ({ logger, config }) => {
|
|
9
|
+
const { queueWiringsFile, queueMapDeclarationFile, packageMappings } =
|
|
10
|
+
config
|
|
11
|
+
|
|
12
|
+
if (!queueWiringsFile) {
|
|
13
|
+
throw new Error("queueWiringsFile is isn't set in the pikku config")
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const queueMapDeclarationPath = getFileImportRelativePath(
|
|
17
|
+
queueWiringsFile,
|
|
18
|
+
queueMapDeclarationFile,
|
|
19
|
+
packageMappings
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
const content = [serializeQueueWrapper(queueMapDeclarationPath)]
|
|
23
|
+
await writeFileInDir(logger, queueWiringsFile, content.join('\n'))
|
|
24
|
+
},
|
|
25
|
+
middleware: [
|
|
26
|
+
logCommandInfoAndTime({
|
|
27
|
+
commandStart: 'Generating queue service wrapper',
|
|
28
|
+
commandEnd: 'Generated queue service wrapper',
|
|
29
|
+
skipCondition: ({ config }) => config.queueWiringsFile === undefined,
|
|
30
|
+
skipMessage: "queueWiringsFile isn't set in the pikku config",
|
|
31
|
+
}),
|
|
32
|
+
],
|
|
33
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { serializeQueueTypes } from './serialize-queue-types.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuQueueTypes: any = pikkuSessionlessFunc<void, void>({
|
|
8
|
+
func: async ({ logger, config }) => {
|
|
9
|
+
const { queueTypesFile, functionTypesFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const functionTypesImportPath = getFileImportRelativePath(
|
|
12
|
+
queueTypesFile,
|
|
13
|
+
functionTypesFile,
|
|
14
|
+
packageMappings
|
|
15
|
+
)
|
|
16
|
+
const content = serializeQueueTypes(functionTypesImportPath)
|
|
17
|
+
await writeFileInDir(logger, queueTypesFile, content)
|
|
18
|
+
},
|
|
19
|
+
middleware: [
|
|
20
|
+
logCommandInfoAndTime({
|
|
21
|
+
commandStart: 'Creating queue types',
|
|
22
|
+
commandEnd: 'Created queue types',
|
|
23
|
+
skipCondition: false,
|
|
24
|
+
skipMessage: '',
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
})
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { serializeQueueMeta } from './serialize-queue-meta.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuQueue: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
8
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
9
|
+
const visitState = await getInspectorState()
|
|
10
|
+
const {
|
|
11
|
+
queueWorkersWiringFile,
|
|
12
|
+
queueWorkersWiringMetaFile,
|
|
13
|
+
packageMappings,
|
|
14
|
+
} = config
|
|
15
|
+
const { queueWorkers } = visitState
|
|
16
|
+
|
|
17
|
+
await writeFileInDir(
|
|
18
|
+
logger,
|
|
19
|
+
queueWorkersWiringMetaFile,
|
|
20
|
+
serializeQueueMeta(queueWorkers.meta)
|
|
21
|
+
)
|
|
22
|
+
await writeFileInDir(
|
|
23
|
+
logger,
|
|
24
|
+
queueWorkersWiringFile,
|
|
25
|
+
serializeFileImports(
|
|
26
|
+
'addQueueWorkers',
|
|
27
|
+
queueWorkersWiringFile,
|
|
28
|
+
queueWorkers.files,
|
|
29
|
+
packageMappings
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return true
|
|
34
|
+
},
|
|
35
|
+
middleware: [
|
|
36
|
+
logCommandInfoAndTime({
|
|
37
|
+
commandStart: 'Finding Queues',
|
|
38
|
+
commandEnd: 'Found Queues',
|
|
39
|
+
skipCondition: async ({ getInspectorState }) => {
|
|
40
|
+
const visitState = await getInspectorState()
|
|
41
|
+
return visitState.queueWorkers.files.size === 0
|
|
42
|
+
},
|
|
43
|
+
skipMessage: 'none found',
|
|
44
|
+
}),
|
|
45
|
+
],
|
|
46
|
+
})
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
import { serializeQueueMap } from './serialize-queue-map.js'
|
|
5
|
+
|
|
6
|
+
export const pikkuQueueMap: any = pikkuSessionlessFunc<void, void>({
|
|
7
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
8
|
+
const { queueWorkers, functions } = await getInspectorState()
|
|
9
|
+
const { queueMapDeclarationFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const content = serializeQueueMap(
|
|
12
|
+
queueMapDeclarationFile,
|
|
13
|
+
packageMappings,
|
|
14
|
+
functions.typesMap,
|
|
15
|
+
functions.meta,
|
|
16
|
+
queueWorkers.meta
|
|
17
|
+
)
|
|
18
|
+
await writeFileInDir(logger, queueMapDeclarationFile, content)
|
|
19
|
+
},
|
|
20
|
+
middleware: [
|
|
21
|
+
logCommandInfoAndTime({
|
|
22
|
+
commandStart: 'Creating Queue map',
|
|
23
|
+
commandEnd: 'Created Queue map',
|
|
24
|
+
skipCondition: async ({ getInspectorState }) => {
|
|
25
|
+
const { queueWorkers } = await getInspectorState()
|
|
26
|
+
return queueWorkers.files.size === 0
|
|
27
|
+
},
|
|
28
|
+
skipMessage: 'none found',
|
|
29
|
+
}),
|
|
30
|
+
],
|
|
31
|
+
})
|