@pikku/cli 0.11.1 → 0.11.3
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 +73 -17
- package/.pikku/channel/pikku-channels-map.gen.d.ts +11 -11
- package/.pikku/channel/pikku-channels-meta.gen.json +1 -0
- package/.pikku/channel/pikku-channels-meta.gen.ts +4 -2
- package/.pikku/channel/pikku-channels.gen.ts +1 -1
- package/.pikku/cli/pikku-cli-channel.ts +2 -2
- package/.pikku/cli/pikku-cli-client.gen.ts +1 -3
- package/.pikku/cli/pikku-cli-types.gen.ts +3 -3
- package/.pikku/cli/pikku-cli-wirings-meta.gen.json +147 -0
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +4 -157
- package/.pikku/cli/pikku-cli-wirings.gen.ts +3 -3
- package/.pikku/cli/pikku-cli.gen.ts +3 -3
- package/.pikku/forge/pikku-forge-types.gen.ts +83 -0
- package/.pikku/function/pikku-function-types.gen.ts +223 -91
- package/.pikku/function/pikku-functions-meta-verbose.gen.json +1030 -0
- package/.pikku/function/pikku-functions-meta.gen.json +656 -0
- package/.pikku/function/pikku-functions-meta.gen.ts +4 -970
- package/.pikku/http/pikku-http-types.gen.ts +20 -4
- package/.pikku/http/pikku-http-wirings-map.gen.d.ts +11 -11
- package/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
- package/.pikku/http/pikku-http-wirings-meta.gen.ts +4 -10
- package/.pikku/http/pikku-http-wirings.gen.ts +1 -1
- package/.pikku/mcp/pikku-mcp-types.gen.ts +72 -20
- package/.pikku/mcp/pikku-mcp-wirings-meta.gen.json +5 -0
- package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +6 -4
- package/.pikku/mcp/pikku-mcp-wirings.gen.ts +1 -1
- package/.pikku/pikku-bootstrap.gen.ts +7 -12
- package/.pikku/pikku-services.gen.ts +6 -7
- package/.pikku/pikku-types.gen.ts +4 -1
- package/.pikku/pikku-websocket.gen.ts +1 -1
- package/.pikku/queue/pikku-queue-types.gen.ts +2 -2
- package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +11 -11
- package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +1 -0
- package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +5 -7
- package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +1 -1
- package/.pikku/rpc/pikku-remote-rpc-workers.gen.ts +5 -2
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +19 -14
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +46 -39
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +2 -2
- package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.json +1 -0
- package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +5 -2
- package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +1 -1
- package/.pikku/schemas/register.gen.ts +31 -23
- package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
- package/.pikku/services/config.gen.json +104 -0
- package/.pikku/services/getInspectorState.gen.json +10 -0
- package/.pikku/services/jwt.gen.json +13 -0
- package/.pikku/services/logger.gen.json +25 -0
- package/.pikku/services/queueService.gen.json +14 -0
- package/.pikku/services/schedulerService.gen.json +17 -0
- package/.pikku/services/schema.gen.json +14 -0
- package/.pikku/services/secrets.gen.json +13 -0
- package/.pikku/services/variables.gen.json +13 -0
- package/.pikku/services/workflowService.gen.json +31 -0
- package/.pikku/workflow/pikku-workflow-map.gen.d.ts +2 -36
- package/.pikku/workflow/pikku-workflow-types.gen.ts +305 -48
- package/.pikku/workflow/pikku-workflow-wirings-meta.gen.ts +6 -2
- package/.pikku/workflow/pikku-workflow-wirings.gen.ts +1 -2
- package/CHANGELOG.md +44 -1
- package/bin/pikku.ts +6 -32
- package/build.sh +53 -31
- package/cli.schema.json +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +51 -10
- package/dist/.pikku/channel/pikku-channel-types.gen.js +3 -13
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +3 -2
- package/dist/.pikku/channel/pikku-channels-meta.gen.json +1 -0
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +2 -2
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -3
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +3 -3
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +3 -157
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +147 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +2 -2
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +2 -2
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +3 -3
- package/dist/.pikku/forge/pikku-forge-types.gen.d.ts +72 -0
- package/dist/.pikku/forge/pikku-forge-types.gen.js +55 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +141 -99
- package/dist/.pikku/function/pikku-function-types.gen.js +52 -62
- package/dist/.pikku/function/pikku-functions-meta.gen.js +3 -969
- package/dist/.pikku/function/pikku-functions-meta.gen.json +656 -0
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +19 -4
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +3 -10
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.json +9 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +57 -17
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +7 -31
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +5 -4
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.json +5 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +7 -12
- package/dist/.pikku/pikku-bootstrap.gen.js +7 -12
- package/dist/.pikku/pikku-services.gen.d.ts +5 -7
- package/dist/.pikku/pikku-services.gen.js +3 -5
- package/dist/.pikku/pikku-types.gen.d.ts +2 -1
- package/dist/.pikku/pikku-types.gen.js +3 -1
- package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
- package/dist/.pikku/pikku-websocket.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +2 -2
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +3 -7
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.d.ts +9 -9
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +5 -2
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +2 -2
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +3 -2
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.json +1 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +19 -15
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuForgeNodesOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuPackageOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuPublicRPCOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuRemoteRPCOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuWorkflowOutput.schema.json +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +213 -39
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +106 -16
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +3 -2
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -2
- package/dist/bin/pikku.js +5 -26
- package/dist/src/cli.wiring.js +4 -4
- package/dist/src/functions/commands/all.js +172 -94
- package/dist/src/functions/commands/bootstrap.js +21 -16
- package/dist/src/functions/commands/watch.js +6 -3
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +12 -8
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +74 -22
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.js +72 -20
- package/dist/src/functions/wirings/channels/pikku-channels.js +9 -2
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +18 -2
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +72 -16
- package/dist/src/functions/wirings/channels/serialize-typed-channel-map.js +1 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +4 -4
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +1 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +17 -3
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +1 -1
- package/dist/src/functions/wirings/cli/serialize-cli-types.js +2 -2
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +4 -4
- package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.d.ts +1 -0
- package/dist/src/functions/wirings/forge/pikku-command-forge-nodes.js +90 -0
- package/dist/src/functions/wirings/forge/pikku-command-forge-types.d.ts +1 -0
- package/dist/src/functions/wirings/forge/pikku-command-forge-types.js +26 -0
- package/dist/src/functions/wirings/forge/serialize-forge-types.d.ts +4 -0
- package/dist/src/functions/wirings/forge/serialize-forge-types.js +90 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +4 -4
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +7 -2
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +35 -10
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-services.js +24 -24
- package/dist/src/functions/wirings/functions/pikku-function-types.js +2 -2
- package/dist/src/functions/wirings/functions/schemas.d.ts +1 -1
- package/dist/src/functions/wirings/functions/schemas.js +5 -4
- package/dist/src/functions/wirings/functions/serialize-function-imports.d.ts +3 -1
- package/dist/src/functions/wirings/functions/serialize-function-imports.js +7 -3
- package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-function-types.js +224 -91
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +19 -21
- package/dist/src/functions/wirings/http/openapi-spec-generator.js +5 -5
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +18 -2
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +2 -2
- package/dist/src/functions/wirings/http/pikku-http-routes.js +9 -2
- package/dist/src/functions/wirings/http/serialize-http-types.js +19 -3
- package/dist/src/functions/wirings/http/serialize-typed-http-map.js +33 -8
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.js +29 -6
- package/dist/src/functions/wirings/mcp/serialize-mcp-json.js +3 -2
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +71 -19
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +29 -2
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.d.ts +5 -2
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +5 -13
- package/dist/src/functions/wirings/package/pikku-command-package.d.ts +1 -0
- package/dist/src/functions/wirings/package/pikku-command-package.js +58 -0
- package/dist/src/functions/wirings/package/serialize-package.d.ts +5 -0
- package/dist/src/functions/wirings/package/serialize-package.js +32 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +17 -3
- package/dist/src/functions/wirings/queue/pikku-queue.js +9 -11
- package/dist/src/functions/wirings/queue/serialize-queue-map.js +20 -3
- package/dist/src/functions/wirings/queue/serialize-queue-meta.d.ts +2 -1
- package/dist/src/functions/wirings/queue/serialize-queue-meta.js +10 -1
- package/dist/src/functions/wirings/queue/serialize-queue-types.js +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +4 -4
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +9 -2
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +11 -4
- package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +4 -1
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +3 -3
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +54 -8
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +15 -3
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.d.ts +2 -1
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-meta.js +11 -1
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +1 -1
- package/dist/src/functions/wirings/services/pikku-command-service-metadata.d.ts +1 -0
- package/dist/src/functions/wirings/services/pikku-command-service-metadata.js +22 -0
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +58 -16
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.d.ts +3 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-map.js +30 -32
- package/dist/src/functions/wirings/workflow/serialize-workflow-meta.d.ts +1 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-meta.js +43 -8
- package/dist/src/functions/wirings/workflow/serialize-workflow-registration.d.ts +7 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-registration.js +53 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-types.d.ts +4 -2
- package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +308 -49
- package/dist/src/functions/wirings/workflow/serialize-workflow-workers.d.ts +1 -1
- package/dist/src/functions/wirings/workflow/serialize-workflow-workers.js +16 -29
- package/dist/src/middleware/log-command-info-and-time.d.ts +2 -2
- package/dist/src/middleware/log-command-info-and-time.js +1 -4
- package/dist/src/services/cli-logger-forwarder.service.js +1 -1
- package/dist/src/services.d.ts +2 -7
- package/dist/src/services.js +18 -13
- package/dist/src/utils/check-required-types.d.ts +2 -2
- package/dist/src/utils/check-required-types.js +2 -3
- package/dist/src/utils/command-summary.d.ts +2 -0
- package/dist/src/utils/command-summary.js +2 -0
- package/dist/src/utils/custom-types-generator.js +13 -15
- package/dist/src/utils/generate-bootstrap-file.js +1 -1
- package/dist/src/utils/pikku-cli-config.js +65 -4
- package/dist/src/utils/pikku-files-and-methods.d.ts +2 -2
- package/dist/src/utils/pikku-files-and-methods.js +4 -4
- package/dist/src/utils/schema-generator.d.ts +4 -3
- package/dist/src/utils/schema-generator.js +135 -15
- package/dist/src/utils/strip-verbose-meta.d.ts +43 -0
- package/dist/src/utils/strip-verbose-meta.js +210 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -9
- package/src/cli.wiring.ts +4 -4
- package/src/functions/commands/all.ts +203 -107
- package/src/functions/commands/bootstrap.ts +23 -16
- package/src/functions/commands/watch.ts +6 -3
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +26 -6
- package/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts +75 -22
- package/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts +72 -19
- package/src/functions/wirings/channels/pikku-channels.ts +27 -3
- package/src/functions/wirings/channels/pikku-command-channels.ts +46 -3
- package/src/functions/wirings/channels/serialize-channel-types.ts +72 -16
- package/src/functions/wirings/channels/serialize-typed-channel-map.ts +3 -2
- package/src/functions/wirings/cli/pikku-command-cli-entry.ts +4 -4
- package/src/functions/wirings/cli/pikku-command-cli-types.ts +1 -1
- package/src/functions/wirings/cli/pikku-command-cli.ts +45 -3
- package/src/functions/wirings/cli/serialize-channel-cli.ts +1 -1
- package/src/functions/wirings/cli/serialize-cli-types.ts +2 -2
- package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +5 -5
- package/src/functions/wirings/forge/pikku-command-forge-nodes.ts +135 -0
- package/src/functions/wirings/forge/pikku-command-forge-types.ts +38 -0
- package/src/functions/wirings/forge/serialize-forge-types.ts +94 -0
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +9 -8
- package/src/functions/wirings/functions/pikku-command-function-types.ts +17 -10
- package/src/functions/wirings/functions/pikku-command-functions.ts +59 -14
- package/src/functions/wirings/functions/pikku-command-services.ts +26 -26
- package/src/functions/wirings/functions/pikku-function-types.ts +3 -1
- package/src/functions/wirings/functions/schemas.ts +14 -4
- package/src/functions/wirings/functions/serialize-function-imports.ts +12 -3
- package/src/functions/wirings/functions/serialize-function-types.ts +227 -93
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +27 -26
- package/src/functions/wirings/http/openapi-spec-generator.ts +15 -6
- package/src/functions/wirings/http/pikku-command-http-routes.ts +46 -2
- package/src/functions/wirings/http/pikku-command-openapi.ts +3 -2
- package/src/functions/wirings/http/pikku-http-routes.ts +28 -2
- package/src/functions/wirings/http/serialize-http-types.ts +19 -3
- package/src/functions/wirings/http/serialize-typed-http-map.ts +32 -8
- package/src/functions/wirings/mcp/pikku-command-mcp.ts +58 -10
- package/src/functions/wirings/mcp/serialize-mcp-json.ts +8 -6
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +71 -19
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +39 -2
- package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +4 -19
- package/src/functions/wirings/package/pikku-command-package.ts +81 -0
- package/src/functions/wirings/package/serialize-package.ts +69 -0
- package/src/functions/wirings/permissions/pikku-command-permissions.ts +2 -2
- package/src/functions/wirings/queue/pikku-command-queue.ts +47 -2
- package/src/functions/wirings/queue/pikku-queue.ts +26 -10
- package/src/functions/wirings/queue/serialize-queue-map.ts +18 -3
- package/src/functions/wirings/queue/serialize-queue-meta.ts +15 -1
- package/src/functions/wirings/queue/serialize-queue-types.ts +1 -1
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +7 -4
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +25 -2
- package/src/functions/wirings/rpc/serialize-public-rpc.ts +11 -4
- package/src/functions/wirings/rpc/serialize-remote-rpc.ts +4 -1
- package/src/functions/wirings/rpc/serialize-rpc-wrapper.ts +3 -3
- package/src/functions/wirings/rpc/serialize-typed-rpc-map.ts +74 -8
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +51 -4
- package/src/functions/wirings/scheduler/serialize-scheduler-meta.ts +20 -1
- package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +1 -1
- package/src/functions/wirings/services/pikku-command-service-metadata.ts +25 -0
- package/src/functions/wirings/workflow/pikku-command-workflow.ts +114 -19
- package/src/functions/wirings/workflow/serialize-workflow-map.ts +38 -40
- package/src/functions/wirings/workflow/serialize-workflow-meta.ts +68 -11
- package/src/functions/wirings/workflow/serialize-workflow-registration.ts +83 -0
- package/src/functions/wirings/workflow/serialize-workflow-types.ts +311 -49
- package/src/functions/wirings/workflow/serialize-workflow-workers.ts +16 -29
- package/src/middleware/log-command-info-and-time.ts +3 -6
- package/src/services/cli-logger-forwarder.service.ts +1 -1
- package/src/services.ts +23 -16
- package/src/utils/check-required-types.ts +4 -7
- package/src/utils/command-summary.ts +4 -0
- package/src/utils/custom-types-generator.ts +15 -15
- package/src/utils/generate-bootstrap-file.ts +1 -1
- package/src/utils/pikku-cli-config.ts +105 -5
- package/src/utils/pikku-files-and-methods.ts +10 -13
- package/src/utils/schema-generator.ts +185 -22
- package/src/utils/strip-verbose-meta.ts +254 -0
- package/types/application-types.d.ts +1 -1
- package/types/config.d.ts +47 -2
- package/.pikku/function/pikku-functions-meta.min.gen.ts +0 -211
- package/.pikku/function/pikku-functions.gen.ts +0 -84
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +0 -47
- package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +0 -1
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +0 -211
- package/dist/.pikku/function/pikku-functions.gen.d.ts +0 -1
- package/dist/.pikku/function/pikku-functions.gen.js +0 -83
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +0 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +0 -47
- package/dist/.pikku/schemas/schemas/PikkuRemoteInternalRPCInput.schema.json +0 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.d.ts +0 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-map.js +0 -12
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.d.ts +0 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-types.js +0 -11
- package/src/functions/wirings/workflow/pikku-command-workflow-map.ts +0 -24
- package/src/functions/wirings/workflow/pikku-command-workflow-types.ts +0 -22
|
@@ -2,11 +2,22 @@ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
|
2
2
|
import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
|
|
3
3
|
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
4
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
6
|
+
import {
|
|
7
|
+
stripVerboseFields,
|
|
8
|
+
hasVerboseFields,
|
|
9
|
+
} from '../../../utils/strip-verbose-meta.js'
|
|
5
10
|
|
|
6
11
|
export const pikkuHTTP: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
7
12
|
func: async ({ logger, config, getInspectorState }) => {
|
|
8
13
|
const visitState = await getInspectorState()
|
|
9
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
httpWiringsFile,
|
|
16
|
+
httpWiringMetaFile,
|
|
17
|
+
httpWiringMetaJsonFile,
|
|
18
|
+
packageMappings,
|
|
19
|
+
schema,
|
|
20
|
+
} = config
|
|
10
21
|
const { http } = visitState
|
|
11
22
|
|
|
12
23
|
await writeFileInDir(
|
|
@@ -19,10 +30,43 @@ export const pikkuHTTP: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
|
19
30
|
packageMappings
|
|
20
31
|
)
|
|
21
32
|
)
|
|
33
|
+
|
|
34
|
+
// Write minimal JSON (runtime-only fields)
|
|
35
|
+
const minimalMeta = stripVerboseFields(http.meta)
|
|
36
|
+
await writeFileInDir(
|
|
37
|
+
logger,
|
|
38
|
+
httpWiringMetaJsonFile,
|
|
39
|
+
JSON.stringify(minimalMeta, null, 2)
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
// Write verbose JSON only if it has additional fields
|
|
43
|
+
if (hasVerboseFields(http.meta)) {
|
|
44
|
+
const verbosePath = httpWiringMetaJsonFile.replace(
|
|
45
|
+
/\.gen\.json$/,
|
|
46
|
+
'-verbose.gen.json'
|
|
47
|
+
)
|
|
48
|
+
await writeFileInDir(
|
|
49
|
+
logger,
|
|
50
|
+
verbosePath,
|
|
51
|
+
JSON.stringify(http.meta, null, 2)
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Generate TypeScript file that imports the minimal JSON
|
|
56
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
57
|
+
httpWiringMetaFile,
|
|
58
|
+
httpWiringMetaJsonFile,
|
|
59
|
+
packageMappings
|
|
60
|
+
)
|
|
61
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false
|
|
62
|
+
const importStatement = supportsImportAttributes
|
|
63
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
64
|
+
: `import metaData from '${jsonImportPath}'`
|
|
65
|
+
|
|
22
66
|
await writeFileInDir(
|
|
23
67
|
logger,
|
|
24
68
|
httpWiringMetaFile,
|
|
25
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta',
|
|
69
|
+
`import { pikkuState } from '@pikku/core'\nimport type { HTTPWiringsMeta } from '@pikku/core/http'\n${importStatement}\npikkuState(null, 'http', 'meta', metaData as HTTPWiringsMeta)`
|
|
26
70
|
)
|
|
27
71
|
|
|
28
72
|
return true
|
|
@@ -19,7 +19,7 @@ export const pikkuOpenAPI: any = pikkuSessionlessFunc<void, void>({
|
|
|
19
19
|
return
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const { http, functions } = await getInspectorState()
|
|
22
|
+
const { http, functions, zodLookup } = await getInspectorState()
|
|
23
23
|
|
|
24
24
|
const schemas = await generateSchemas(
|
|
25
25
|
logger,
|
|
@@ -28,7 +28,8 @@ export const pikkuOpenAPI: any = pikkuSessionlessFunc<void, void>({
|
|
|
28
28
|
functions.meta,
|
|
29
29
|
http.meta,
|
|
30
30
|
schemasFromTypes,
|
|
31
|
-
config.schema?.additionalProperties
|
|
31
|
+
config.schema?.additionalProperties,
|
|
32
|
+
zodLookup
|
|
32
33
|
)
|
|
33
34
|
const openAPISpec = await generateOpenAPISpec(
|
|
34
35
|
logger,
|
|
@@ -2,11 +2,18 @@ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
|
2
2
|
import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
|
|
3
3
|
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
4
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
5
6
|
|
|
6
7
|
export const pikkuHTTP: any = pikkuSessionlessFunc<void, boolean>({
|
|
7
8
|
func: async ({ logger, config, getInspectorState }) => {
|
|
8
9
|
const visitState = await getInspectorState()
|
|
9
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
httpWiringsFile,
|
|
12
|
+
httpWiringMetaFile,
|
|
13
|
+
httpWiringMetaJsonFile,
|
|
14
|
+
packageMappings,
|
|
15
|
+
schema,
|
|
16
|
+
} = config
|
|
10
17
|
const { http } = visitState
|
|
11
18
|
|
|
12
19
|
await writeFileInDir(
|
|
@@ -19,11 +26,30 @@ export const pikkuHTTP: any = pikkuSessionlessFunc<void, boolean>({
|
|
|
19
26
|
packageMappings
|
|
20
27
|
)
|
|
21
28
|
)
|
|
29
|
+
|
|
30
|
+
await writeFileInDir(
|
|
31
|
+
logger,
|
|
32
|
+
httpWiringMetaJsonFile,
|
|
33
|
+
JSON.stringify(http.meta, null, 2)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
37
|
+
httpWiringMetaFile,
|
|
38
|
+
httpWiringMetaJsonFile,
|
|
39
|
+
packageMappings
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false
|
|
43
|
+
const importStatement = supportsImportAttributes
|
|
44
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
45
|
+
: `import metaData from '${jsonImportPath}'`
|
|
46
|
+
|
|
22
47
|
await writeFileInDir(
|
|
23
48
|
logger,
|
|
24
49
|
httpWiringMetaFile,
|
|
25
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta',
|
|
50
|
+
`import { pikkuState, HTTPWiringsMeta } from '@pikku/core'\n${importStatement}\npikkuState(null, 'http', 'meta', metaData as HTTPWiringsMeta)`
|
|
26
51
|
)
|
|
52
|
+
|
|
27
53
|
return true
|
|
28
54
|
},
|
|
29
55
|
middleware: [
|
|
@@ -8,7 +8,7 @@ export const serializeHTTPTypes = (functionTypesImportPath: string) => {
|
|
|
8
8
|
|
|
9
9
|
import { AssertHTTPWiringParams, wireHTTP as wireHTTPCore, addHTTPMiddleware as addHTTPMiddlewareCore, addHTTPPermission as addHTTPPermissionCore } from '@pikku/core/http'
|
|
10
10
|
import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
|
|
11
|
-
import type { CoreHTTPFunctionWiring } from '@pikku/core/http'
|
|
11
|
+
import type { CoreHTTPFunctionWiring, HTTPMethod } from '@pikku/core/http'
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Type definition for HTTP API wirings with type-safe path parameters.
|
|
@@ -18,7 +18,23 @@ import type { CoreHTTPFunctionWiring } from '@pikku/core/http'
|
|
|
18
18
|
* @template Out - Output type for the HTTP wiring
|
|
19
19
|
* @template Route - String literal type for the HTTP path (e.g., "/users/:id")
|
|
20
20
|
*/
|
|
21
|
-
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out>, PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>
|
|
21
|
+
type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out, Route, PikkuFunction<In, Out, 'rpc' | 'session'>, PikkuFunctionSessionless<In, Out, 'rpc' | 'session'>, PikkuPermission<In>, PikkuMiddleware>
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* HTTP wiring for workflow triggers (no function needed)
|
|
25
|
+
*/
|
|
26
|
+
type HTTPWorkflowWiring<Route extends string> = {
|
|
27
|
+
route: Route
|
|
28
|
+
method: HTTPMethod
|
|
29
|
+
workflow: true
|
|
30
|
+
func?: undefined
|
|
31
|
+
permissions?: undefined
|
|
32
|
+
auth?: undefined
|
|
33
|
+
tags?: undefined
|
|
34
|
+
middleware?: undefined
|
|
35
|
+
returnsJSON?: undefined
|
|
36
|
+
sse?: boolean
|
|
37
|
+
}
|
|
22
38
|
|
|
23
39
|
/**
|
|
24
40
|
* Registers an HTTP wiring with the Pikku framework.
|
|
@@ -29,7 +45,7 @@ type HTTPWiring<In, Out, Route extends string> = CoreHTTPFunctionWiring<In, Out,
|
|
|
29
45
|
* @param httpWiring - HTTP wiring definition with handler, method, and optional middleware
|
|
30
46
|
*/
|
|
31
47
|
export const wireHTTP = <In, Out, Route extends string>(
|
|
32
|
-
httpWiring: HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>
|
|
48
|
+
httpWiring: (HTTPWiring<In, Out, Route> & AssertHTTPWiringParams<In, Route>) | HTTPWorkflowWiring<Route>
|
|
33
49
|
) => {
|
|
34
50
|
wireHTTPCore(httpWiring as any)
|
|
35
51
|
}
|
|
@@ -32,7 +32,7 @@ export const serializeTypedHTTPWiringsMap = (
|
|
|
32
32
|
return `/**
|
|
33
33
|
* This provides the structure needed for typescript to be aware of routes and their return types
|
|
34
34
|
*/
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
${serializedImportMap}
|
|
37
37
|
${serializedCustomTypes}
|
|
38
38
|
${serializedMetaTypes}
|
|
@@ -70,6 +70,12 @@ function generateHTTPWirings(
|
|
|
70
70
|
for (const methods of Object.values(routesMeta)) {
|
|
71
71
|
for (const meta of Object.values(methods)) {
|
|
72
72
|
const { route, method, pikkuFuncName } = meta
|
|
73
|
+
|
|
74
|
+
// Skip workflow-triggered routes (they don't have a function)
|
|
75
|
+
if (meta.workflow) {
|
|
76
|
+
continue
|
|
77
|
+
}
|
|
78
|
+
|
|
73
79
|
const functionMeta = functionsMeta[pikkuFuncName]
|
|
74
80
|
if (!functionMeta) {
|
|
75
81
|
throw new Error(
|
|
@@ -79,16 +85,28 @@ function generateHTTPWirings(
|
|
|
79
85
|
const input = functionMeta.inputs ? functionMeta.inputs[0] : undefined
|
|
80
86
|
const output = functionMeta.outputs ? functionMeta.outputs[0] : undefined
|
|
81
87
|
|
|
82
|
-
// Initialize the route entry if it doesn't exist
|
|
83
88
|
if (!routesObj[route]) {
|
|
84
89
|
routesObj[route] = {}
|
|
85
90
|
}
|
|
86
91
|
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
// For zod-derived schemas, the type might not be in typesMap, so use the schema name directly
|
|
93
|
+
let inputType = 'null'
|
|
94
|
+
if (input) {
|
|
95
|
+
try {
|
|
96
|
+
inputType = typesMap.getTypeMeta(input).uniqueName
|
|
97
|
+
} catch {
|
|
98
|
+
inputType = input
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
let outputType = 'null'
|
|
102
|
+
if (output) {
|
|
103
|
+
try {
|
|
104
|
+
outputType = typesMap.getTypeMeta(output).uniqueName
|
|
105
|
+
} catch {
|
|
106
|
+
// Zod-derived schema - use the schema name directly
|
|
107
|
+
outputType = output
|
|
108
|
+
}
|
|
109
|
+
}
|
|
92
110
|
|
|
93
111
|
requiredTypes.add(inputType)
|
|
94
112
|
requiredTypes.add(outputType)
|
|
@@ -121,7 +139,13 @@ const generateMetaTypes = (metaTypes: MetaInputTypes, typesMap: TypesMap) => {
|
|
|
121
139
|
const nameToTypeMap = Array.from(metaTypes.entries()).reduce<
|
|
122
140
|
Map<string, string>
|
|
123
141
|
>((result, [_name, { query, body, params }]) => {
|
|
124
|
-
|
|
142
|
+
let uniqueName: string
|
|
143
|
+
try {
|
|
144
|
+
uniqueName = typesMap.getTypeMeta(_name).uniqueName
|
|
145
|
+
} catch {
|
|
146
|
+
// Zod-derived schema - use the name directly
|
|
147
|
+
uniqueName = _name
|
|
148
|
+
}
|
|
125
149
|
const queryType =
|
|
126
150
|
query && query.length > 0
|
|
127
151
|
? `Pick<${uniqueName}, '${query?.join("' | '")}'>`
|
|
@@ -4,6 +4,11 @@ import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
|
4
4
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
5
|
import { readFile } from 'fs/promises'
|
|
6
6
|
import { join } from 'path'
|
|
7
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
8
|
+
import {
|
|
9
|
+
stripVerboseFields,
|
|
10
|
+
hasVerboseFields,
|
|
11
|
+
} from '../../../utils/strip-verbose-meta.js'
|
|
7
12
|
|
|
8
13
|
// Helper function to generate arguments from schema
|
|
9
14
|
const generateArgumentsFromSchema = async (
|
|
@@ -25,12 +30,13 @@ const generateArgumentsFromSchema = async (
|
|
|
25
30
|
const uniqueName = typesMap.getUniqueName(inputSchema)
|
|
26
31
|
if (!uniqueName) return []
|
|
27
32
|
|
|
33
|
+
const schemaPath = join(
|
|
34
|
+
schemaDirectory,
|
|
35
|
+
'schemas',
|
|
36
|
+
`${uniqueName}.schema.json`
|
|
37
|
+
)
|
|
38
|
+
|
|
28
39
|
try {
|
|
29
|
-
const schemaPath = join(
|
|
30
|
-
schemaDirectory,
|
|
31
|
-
'schemas',
|
|
32
|
-
`${uniqueName}.schema.json`
|
|
33
|
-
)
|
|
34
40
|
const schemaContent = await readFile(schemaPath, 'utf-8')
|
|
35
41
|
const schema = JSON.parse(schemaContent)
|
|
36
42
|
|
|
@@ -53,7 +59,8 @@ const generateArgumentsFromSchema = async (
|
|
|
53
59
|
}
|
|
54
60
|
return argumentsArray
|
|
55
61
|
} catch (e) {
|
|
56
|
-
logger.warn(`Could not load schema for type: ${uniqueName}`)
|
|
62
|
+
logger.warn(`Command MCP: Could not load schema for type: ${uniqueName} from ${schemaPath}`)
|
|
63
|
+
console.error(e)
|
|
57
64
|
return []
|
|
58
65
|
}
|
|
59
66
|
}
|
|
@@ -66,6 +73,7 @@ export const pikkuMCP: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
|
66
73
|
mcpWiringsMetaFile,
|
|
67
74
|
packageMappings,
|
|
68
75
|
schemaDirectory,
|
|
76
|
+
schema,
|
|
69
77
|
} = config
|
|
70
78
|
|
|
71
79
|
await writeFileInDir(
|
|
@@ -81,7 +89,7 @@ export const pikkuMCP: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
|
81
89
|
|
|
82
90
|
// Populate arguments for prompts meta before serializing
|
|
83
91
|
const promptsMetaWithArguments = { ...mcpEndpoints.promptsMeta }
|
|
84
|
-
for (const promptMeta of Object.values(promptsMetaWithArguments)) {
|
|
92
|
+
for (const promptMeta of Object.values(promptsMetaWithArguments) as any[]) {
|
|
85
93
|
const functionMeta = functions.meta[promptMeta.pikkuFuncName]
|
|
86
94
|
if (functionMeta) {
|
|
87
95
|
const inputType = functionMeta.inputs?.[0]
|
|
@@ -94,13 +102,53 @@ export const pikkuMCP: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
|
94
102
|
}
|
|
95
103
|
}
|
|
96
104
|
|
|
105
|
+
const metaData = {
|
|
106
|
+
resourcesMeta: mcpEndpoints.resourcesMeta,
|
|
107
|
+
toolsMeta: mcpEndpoints.toolsMeta,
|
|
108
|
+
promptsMeta: promptsMetaWithArguments,
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Write minimal JSON (runtime-only fields)
|
|
112
|
+
const minimalMeta = stripVerboseFields(metaData)
|
|
113
|
+
await writeFileInDir(
|
|
114
|
+
logger,
|
|
115
|
+
config.mcpWiringsMetaJsonFile,
|
|
116
|
+
JSON.stringify(minimalMeta, null, 2)
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
// Write verbose JSON only if it has additional fields
|
|
120
|
+
if (hasVerboseFields(metaData)) {
|
|
121
|
+
const verbosePath = config.mcpWiringsMetaJsonFile.replace(
|
|
122
|
+
/\.gen\.json$/,
|
|
123
|
+
'-verbose.gen.json'
|
|
124
|
+
)
|
|
125
|
+
await writeFileInDir(
|
|
126
|
+
logger,
|
|
127
|
+
verbosePath,
|
|
128
|
+
JSON.stringify(metaData, null, 2)
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
133
|
+
mcpWiringsMetaFile,
|
|
134
|
+
config.mcpWiringsMetaJsonFile,
|
|
135
|
+
packageMappings
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false
|
|
139
|
+
const importStatement = supportsImportAttributes
|
|
140
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
141
|
+
: `import metaData from '${jsonImportPath}'`
|
|
142
|
+
|
|
97
143
|
await writeFileInDir(
|
|
98
144
|
logger,
|
|
99
145
|
mcpWiringsMetaFile,
|
|
100
146
|
`import { pikkuState } from '@pikku/core'
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
pikkuState('mcp', '
|
|
147
|
+
import type { MCPResourceMeta, MCPToolMeta, MCPPromptMeta } from '@pikku/core/mcp'
|
|
148
|
+
${importStatement}
|
|
149
|
+
pikkuState(null, 'mcp', 'resourcesMeta', metaData.resourcesMeta as MCPResourceMeta)
|
|
150
|
+
pikkuState(null, 'mcp', 'toolsMeta', metaData.toolsMeta as MCPToolMeta)
|
|
151
|
+
pikkuState(null, 'mcp', 'promptsMeta', metaData.promptsMeta as MCPPromptMeta)`
|
|
104
152
|
)
|
|
105
153
|
|
|
106
154
|
return true
|
|
@@ -44,16 +44,18 @@ export const serializeMCPJson = async (
|
|
|
44
44
|
return undefined
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
const schemaPath = join(
|
|
48
|
+
schemaDirectory,
|
|
49
|
+
'schemas',
|
|
50
|
+
`${uniqueName}.schema.json`
|
|
51
|
+
)
|
|
52
|
+
|
|
47
53
|
try {
|
|
48
|
-
const schemaPath = join(
|
|
49
|
-
schemaDirectory,
|
|
50
|
-
'schemas',
|
|
51
|
-
`${uniqueName}.schema.json`
|
|
52
|
-
)
|
|
53
54
|
const schemaContent = await readFile(schemaPath, 'utf-8')
|
|
54
55
|
return JSON.parse(schemaContent)
|
|
55
56
|
} catch (e) {
|
|
56
|
-
logger.warn(`Could not load schema for type: ${uniqueName}`)
|
|
57
|
+
logger.warn(`Serialize MCP: Could not load schema for type: ${uniqueName} from ${schemaPath}`)
|
|
58
|
+
console.error(e)
|
|
57
59
|
return undefined
|
|
58
60
|
}
|
|
59
61
|
}
|
|
@@ -19,7 +19,8 @@ import {
|
|
|
19
19
|
AssertMCPResourceURIParams
|
|
20
20
|
} from '@pikku/core/mcp'
|
|
21
21
|
|
|
22
|
-
import type { PikkuFunctionConfig, PikkuFunctionSessionless } from '${functionTypesImportPath}'
|
|
22
|
+
import type { PikkuFunctionConfig, PikkuFunctionSessionless, InferZodOutput } from '${functionTypesImportPath}'
|
|
23
|
+
import type { ZodLike } from '@pikku/core'
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Type definition for MCP resources that provide data to AI models.
|
|
@@ -27,21 +28,21 @@ import type { PikkuFunctionConfig, PikkuFunctionSessionless } from '${functionTy
|
|
|
27
28
|
* @template In - Input type for the resource request
|
|
28
29
|
* @template URI - URI template string type for compile-time parameter validation
|
|
29
30
|
*/
|
|
30
|
-
type MCPResourceWiring<In, URI extends string> = CoreMCPResource<PikkuFunctionConfig<In, MCPResourceResponse>> & { uri: URI }
|
|
31
|
+
type MCPResourceWiring<In, URI extends string> = CoreMCPResource<PikkuFunctionConfig<In, MCPResourceResponse, 'rpc' | 'session' | 'mcp'>> & { uri: URI }
|
|
31
32
|
|
|
32
33
|
/**
|
|
33
34
|
* Type definition for MCP tools that AI models can invoke.
|
|
34
35
|
*
|
|
35
36
|
* @template In - Input type for the tool invocation
|
|
36
37
|
*/
|
|
37
|
-
type MCPToolWiring<In> = CoreMCPTool<PikkuFunctionConfig<In, MCPToolResponse>>
|
|
38
|
+
type MCPToolWiring<In> = CoreMCPTool<PikkuFunctionConfig<In, MCPToolResponse, 'rpc' | 'session' | 'mcp'>>
|
|
38
39
|
|
|
39
40
|
/**
|
|
40
41
|
* Type definition for MCP prompts that provide templates to AI models.
|
|
41
42
|
*
|
|
42
43
|
* @template In - Input type for the prompt parameters
|
|
43
44
|
*/
|
|
44
|
-
type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionConfig<In, MCPPromptResponse>>
|
|
45
|
+
type MCPPromptWiring<In> = CoreMCPPrompt<PikkuFunctionConfig<In, MCPPromptResponse, 'rpc' | 'session' | 'mcp'>>
|
|
45
46
|
|
|
46
47
|
/**
|
|
47
48
|
* Registers an MCP resource with the Pikku framework.
|
|
@@ -83,60 +84,111 @@ export const wireMCPPrompt = <In>(
|
|
|
83
84
|
wireMCPPromptCore(mcpPrompt as any)
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for MCP prompt with Zod schema input validation.
|
|
89
|
+
*/
|
|
90
|
+
type MCPPromptFuncConfigWithSchema<InputSchema extends ZodLike> = {
|
|
91
|
+
func: PikkuFunctionSessionless<InferZodOutput<InputSchema>, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
92
|
+
name?: string
|
|
93
|
+
input: InputSchema
|
|
94
|
+
}
|
|
95
|
+
|
|
86
96
|
/**
|
|
87
97
|
* Creates a function for handling MCP prompt requests.
|
|
88
98
|
* These functions generate prompt templates for AI models.
|
|
89
99
|
*
|
|
90
|
-
*
|
|
100
|
+
* Supports two patterns:
|
|
101
|
+
* 1. Generic types: \`pikkuMCPPromptFunc<Input>({ func: ... })\`
|
|
102
|
+
* 2. Zod schemas: \`pikkuMCPPromptFunc({ input: z.object(...), func: ... })\`
|
|
103
|
+
*
|
|
104
|
+
* @template In - Input type for the prompt parameters (inferred from schema if provided)
|
|
91
105
|
* @param func - Function definition, either direct function or configuration object
|
|
92
106
|
* @returns The unwrapped function for internal use
|
|
93
107
|
*/
|
|
94
|
-
export
|
|
108
|
+
export function pikkuMCPPromptFunc<InputSchema extends ZodLike>(
|
|
109
|
+
config: MCPPromptFuncConfigWithSchema<InputSchema>
|
|
110
|
+
): PikkuFunctionConfig<InferZodOutput<InputSchema>, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
111
|
+
export function pikkuMCPPromptFunc<In>(
|
|
95
112
|
func:
|
|
96
|
-
| PikkuFunctionSessionless<In, MCPPromptResponse>
|
|
113
|
+
| PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
97
114
|
| {
|
|
98
|
-
func: PikkuFunctionSessionless<In, MCPPromptResponse>
|
|
115
|
+
func: PikkuFunctionSessionless<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
99
116
|
name?: string
|
|
100
117
|
}
|
|
101
|
-
): PikkuFunctionConfig<In, MCPPromptResponse
|
|
118
|
+
): PikkuFunctionConfig<In, MCPPromptResponse, 'mcp' | 'rpc'>
|
|
119
|
+
export function pikkuMCPPromptFunc(func: any): any {
|
|
102
120
|
return typeof func === 'function' ? { func } : func
|
|
103
121
|
}
|
|
104
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Configuration for MCP tool with Zod schema input validation.
|
|
125
|
+
*/
|
|
126
|
+
type MCPToolFuncConfigWithSchema<InputSchema extends ZodLike> = {
|
|
127
|
+
func: PikkuFunctionSessionless<InferZodOutput<InputSchema>, MCPToolResponse, 'mcp' | 'rpc'>
|
|
128
|
+
name?: string
|
|
129
|
+
input: InputSchema
|
|
130
|
+
}
|
|
131
|
+
|
|
105
132
|
/**
|
|
106
133
|
* Creates a function for handling MCP tool invocations.
|
|
107
134
|
* These functions perform actions that AI models can request.
|
|
108
135
|
*
|
|
109
|
-
*
|
|
136
|
+
* Supports two patterns:
|
|
137
|
+
* 1. Generic types: \`pikkuMCPToolFunc<Input>({ func: ... })\`
|
|
138
|
+
* 2. Zod schemas: \`pikkuMCPToolFunc({ input: z.object(...), func: ... })\`
|
|
139
|
+
*
|
|
140
|
+
* @template In - Input type for the tool invocation (inferred from schema if provided)
|
|
110
141
|
* @param func - Function definition, either direct function or configuration object
|
|
111
142
|
* @returns The unwrapped function for internal use
|
|
112
143
|
*/
|
|
113
|
-
export
|
|
144
|
+
export function pikkuMCPToolFunc<InputSchema extends ZodLike>(
|
|
145
|
+
config: MCPToolFuncConfigWithSchema<InputSchema>
|
|
146
|
+
): PikkuFunctionConfig<InferZodOutput<InputSchema>, MCPToolResponse, 'mcp' | 'rpc'>
|
|
147
|
+
export function pikkuMCPToolFunc<In>(
|
|
114
148
|
func:
|
|
115
|
-
| PikkuFunctionSessionless<In, MCPToolResponse,
|
|
149
|
+
| PikkuFunctionSessionless<In, MCPToolResponse, 'mcp' | 'rpc'>
|
|
116
150
|
| {
|
|
117
|
-
func: PikkuFunctionSessionless<In, MCPToolResponse,
|
|
151
|
+
func: PikkuFunctionSessionless<In, MCPToolResponse, 'mcp' | 'rpc'>
|
|
118
152
|
name?: string
|
|
119
153
|
}
|
|
120
|
-
): PikkuFunctionConfig<In, MCPToolResponse
|
|
154
|
+
): PikkuFunctionConfig<In, MCPToolResponse, 'mcp' | 'rpc'>
|
|
155
|
+
export function pikkuMCPToolFunc(func: any): any {
|
|
121
156
|
return typeof func === 'function' ? { func } : func
|
|
122
157
|
}
|
|
123
158
|
|
|
159
|
+
/**
|
|
160
|
+
* Configuration for MCP resource with Zod schema input validation.
|
|
161
|
+
*/
|
|
162
|
+
type MCPResourceFuncConfigWithSchema<InputSchema extends ZodLike> = {
|
|
163
|
+
func: PikkuFunctionSessionless<InferZodOutput<InputSchema>, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
164
|
+
name?: string
|
|
165
|
+
input: InputSchema
|
|
166
|
+
}
|
|
167
|
+
|
|
124
168
|
/**
|
|
125
169
|
* Creates a function for handling MCP resource requests.
|
|
126
170
|
* These functions provide data that AI models can access.
|
|
127
171
|
*
|
|
128
|
-
*
|
|
172
|
+
* Supports two patterns:
|
|
173
|
+
* 1. Generic types: \`pikkuMCPResourceFunc<Input>({ func: ... })\`
|
|
174
|
+
* 2. Zod schemas: \`pikkuMCPResourceFunc({ input: z.object(...), func: ... })\`
|
|
175
|
+
*
|
|
176
|
+
* @template In - Input type for the resource request (inferred from schema if provided)
|
|
129
177
|
* @param func - Function definition, either direct function or configuration object
|
|
130
178
|
* @returns The unwrapped function for internal use
|
|
131
179
|
*/
|
|
132
|
-
export
|
|
180
|
+
export function pikkuMCPResourceFunc<InputSchema extends ZodLike>(
|
|
181
|
+
config: MCPResourceFuncConfigWithSchema<InputSchema>
|
|
182
|
+
): PikkuFunctionConfig<InferZodOutput<InputSchema>, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
183
|
+
export function pikkuMCPResourceFunc<In>(
|
|
133
184
|
func:
|
|
134
|
-
| PikkuFunctionSessionless<In, MCPResourceResponse,
|
|
185
|
+
| PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
135
186
|
| {
|
|
136
|
-
func: PikkuFunctionSessionless<In, MCPResourceResponse,
|
|
187
|
+
func: PikkuFunctionSessionless<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
137
188
|
name?: string
|
|
138
189
|
}
|
|
139
|
-
): PikkuFunctionConfig<In, MCPResourceResponse
|
|
190
|
+
): PikkuFunctionConfig<In, MCPResourceResponse, 'mcp' | 'rpc'>
|
|
191
|
+
export function pikkuMCPResourceFunc(func: any): any {
|
|
140
192
|
return typeof func === 'function' ? { func } : func
|
|
141
193
|
}
|
|
142
194
|
`
|
|
@@ -3,6 +3,7 @@ import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
|
3
3
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
4
|
import { serializeMiddlewareImports } from './serialize-middleware-imports.js'
|
|
5
5
|
import { serializeMiddlewareGroupsMeta } from './serialize-middleware-groups-meta.js'
|
|
6
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
6
7
|
|
|
7
8
|
export const pikkuMiddleware: any = pikkuSessionlessFunc<
|
|
8
9
|
void,
|
|
@@ -11,7 +12,7 @@ export const pikkuMiddleware: any = pikkuSessionlessFunc<
|
|
|
11
12
|
func: async ({ logger, config, getInspectorState }) => {
|
|
12
13
|
const state = await getInspectorState()
|
|
13
14
|
const { middleware } = state
|
|
14
|
-
const { middlewareFile, packageMappings } = config
|
|
15
|
+
const { middlewareFile, packageMappings, schema } = config
|
|
15
16
|
|
|
16
17
|
let filesGenerated = false
|
|
17
18
|
|
|
@@ -20,12 +21,48 @@ export const pikkuMiddleware: any = pikkuSessionlessFunc<
|
|
|
20
21
|
const hasTagGroups = state.middleware.tagMiddleware.size > 0
|
|
21
22
|
|
|
22
23
|
if (hasHTTPGroups || hasTagGroups) {
|
|
24
|
+
const metaData = serializeMiddlewareGroupsMeta(state)
|
|
25
|
+
|
|
26
|
+
// Write JSON file
|
|
23
27
|
await writeFileInDir(
|
|
24
28
|
logger,
|
|
29
|
+
config.middlewareGroupsMetaJsonFile,
|
|
30
|
+
JSON.stringify(metaData, null, 2)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// Calculate relative path from TS file to JSON file
|
|
34
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
25
35
|
config.middlewareGroupsMetaFile,
|
|
26
|
-
|
|
36
|
+
config.middlewareGroupsMetaJsonFile,
|
|
37
|
+
packageMappings
|
|
27
38
|
)
|
|
28
39
|
|
|
40
|
+
// Write TypeScript file that imports JSON
|
|
41
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false
|
|
42
|
+
const importStatement = supportsImportAttributes
|
|
43
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
44
|
+
: `import metaData from '${jsonImportPath}'`
|
|
45
|
+
|
|
46
|
+
const packageNameValue = config.externalPackageName
|
|
47
|
+
? `'${config.externalPackageName}'`
|
|
48
|
+
: 'null'
|
|
49
|
+
|
|
50
|
+
const tsContent = `import { pikkuState } from '@pikku/core'
|
|
51
|
+
${importStatement}
|
|
52
|
+
|
|
53
|
+
// HTTP middleware groups metadata
|
|
54
|
+
if (metaData.httpGroups && Object.keys(metaData.httpGroups).length > 0) {
|
|
55
|
+
pikkuState(${packageNameValue}, 'middleware', 'httpGroupMeta', metaData.httpGroups)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Tag middleware groups metadata
|
|
59
|
+
if (metaData.tagGroups && Object.keys(metaData.tagGroups).length > 0) {
|
|
60
|
+
pikkuState(${packageNameValue}, 'middleware', 'tagGroupMeta', metaData.tagGroups)
|
|
61
|
+
}
|
|
62
|
+
`
|
|
63
|
+
|
|
64
|
+
await writeFileInDir(logger, config.middlewareGroupsMetaFile, tsContent)
|
|
65
|
+
|
|
29
66
|
// Always generate middleware imports file when groups exist (even if empty)
|
|
30
67
|
await writeFileInDir(
|
|
31
68
|
logger,
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { InspectorState } from '@pikku/inspector'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Generates the middleware groups metadata
|
|
4
|
+
* Generates the middleware groups metadata that stores metadata about
|
|
5
5
|
* tag-based and HTTP middleware groups for visualization and inspection.
|
|
6
6
|
*
|
|
7
7
|
* This includes services, middleware count, factory status, etc.
|
|
8
8
|
*/
|
|
9
9
|
export const serializeMiddlewareGroupsMeta = (state: InspectorState) => {
|
|
10
|
-
const lines: string[] = [`import { pikkuState } from '@pikku/core'`, ``]
|
|
11
|
-
|
|
12
10
|
// Serialize HTTP middleware groups metadata
|
|
13
11
|
const httpGroups: Record<string, any> = {}
|
|
14
12
|
for (const [pattern, meta] of state.http.routeMiddleware.entries()) {
|
|
@@ -22,14 +20,6 @@ export const serializeMiddlewareGroupsMeta = (state: InspectorState) => {
|
|
|
22
20
|
}
|
|
23
21
|
}
|
|
24
22
|
|
|
25
|
-
if (Object.keys(httpGroups).length > 0) {
|
|
26
|
-
lines.push(`// HTTP middleware groups metadata`)
|
|
27
|
-
lines.push(
|
|
28
|
-
`pikkuState('middleware', 'httpGroupMeta', ${JSON.stringify(httpGroups, null, 2)})`
|
|
29
|
-
)
|
|
30
|
-
lines.push(``)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
23
|
// Serialize tag middleware groups metadata
|
|
34
24
|
const tagGroups: Record<string, any> = {}
|
|
35
25
|
for (const [tag, meta] of state.middleware.tagMiddleware.entries()) {
|
|
@@ -43,13 +33,8 @@ export const serializeMiddlewareGroupsMeta = (state: InspectorState) => {
|
|
|
43
33
|
}
|
|
44
34
|
}
|
|
45
35
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
`pikkuState('middleware', 'tagGroupMeta', ${JSON.stringify(tagGroups, null, 2)})`
|
|
50
|
-
)
|
|
51
|
-
lines.push(``)
|
|
36
|
+
return {
|
|
37
|
+
httpGroups,
|
|
38
|
+
tagGroups,
|
|
52
39
|
}
|
|
53
|
-
|
|
54
|
-
return lines.join('\n')
|
|
55
40
|
}
|