@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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export const serializeNextJsBackendWrapper = (
|
|
2
2
|
bootstrapPath: string,
|
|
3
3
|
routesMapPath: string,
|
|
4
|
+
rpcMapPath: string,
|
|
4
5
|
configImport: string,
|
|
5
6
|
singleServicesFactoryImport: string,
|
|
6
|
-
|
|
7
|
+
wireServicesImport: string
|
|
7
8
|
) => {
|
|
8
9
|
return `'server-only'
|
|
9
10
|
|
|
@@ -14,12 +15,13 @@ export const serializeNextJsBackendWrapper = (
|
|
|
14
15
|
import { PikkuNextJS } from '@pikku/next'
|
|
15
16
|
import { NextRequest } from 'next/server.js'
|
|
16
17
|
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
18
|
+
import type { FlattenedRPCMap } from '${rpcMapPath}'
|
|
17
19
|
|
|
18
20
|
type RouteContext = { params: Promise<Record<string, string | string[]>> }
|
|
19
21
|
|
|
20
22
|
${configImport}
|
|
21
23
|
${singleServicesFactoryImport}
|
|
22
|
-
${
|
|
24
|
+
${wireServicesImport}
|
|
23
25
|
|
|
24
26
|
import '${bootstrapPath}'
|
|
25
27
|
|
|
@@ -40,7 +42,7 @@ export const pikku = (_options?: any) => {
|
|
|
40
42
|
_pikku = new PikkuNextJS(
|
|
41
43
|
createConfig as any,
|
|
42
44
|
createSingletonServices as any,
|
|
43
|
-
|
|
45
|
+
createWireServices
|
|
44
46
|
)
|
|
45
47
|
}
|
|
46
48
|
|
|
@@ -93,14 +95,16 @@ export const pikku = (_options?: any) => {
|
|
|
93
95
|
*
|
|
94
96
|
* @template Route - The route key with the POST method.
|
|
95
97
|
* @param route - The route identifier.
|
|
96
|
-
* @param data - The input data for the POST request
|
|
98
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
97
99
|
* @returns A promise that resolves to the output of the POST handler.
|
|
98
100
|
*/
|
|
99
101
|
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
100
102
|
route: Route,
|
|
101
|
-
|
|
103
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
104
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
105
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
102
106
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
103
|
-
return dynamicActionRequest(route, 'POST',
|
|
107
|
+
return dynamicActionRequest(route, 'POST', args[0] ?? null)
|
|
104
108
|
}
|
|
105
109
|
|
|
106
110
|
/**
|
|
@@ -108,14 +112,16 @@ export const pikku = (_options?: any) => {
|
|
|
108
112
|
*
|
|
109
113
|
* @template Route - The route key with the GET method.
|
|
110
114
|
* @param route - The route identifier.
|
|
111
|
-
* @param data - The input data for the GET request
|
|
115
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
112
116
|
* @returns A promise that resolves to the output of the GET handler.
|
|
113
117
|
*/
|
|
114
118
|
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
115
119
|
route: Route,
|
|
116
|
-
|
|
120
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
121
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
122
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
117
123
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
118
|
-
return dynamicActionRequest(route, 'GET',
|
|
124
|
+
return dynamicActionRequest(route, 'GET', args[0] ?? null)
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
/**
|
|
@@ -123,14 +129,16 @@ export const pikku = (_options?: any) => {
|
|
|
123
129
|
*
|
|
124
130
|
* @template Route - The route key with the PATCH method.
|
|
125
131
|
* @param route - The route identifier.
|
|
126
|
-
* @param data - The input data for the PATCH request
|
|
132
|
+
* @param data - The input data for the PATCH request (required if input type is defined).
|
|
127
133
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
128
134
|
*/
|
|
129
135
|
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
130
136
|
route: Route,
|
|
131
|
-
|
|
137
|
+
...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
|
|
138
|
+
? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
|
|
139
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
|
|
132
140
|
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
133
|
-
return dynamicActionRequest(route, 'PATCH',
|
|
141
|
+
return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
|
|
134
142
|
}
|
|
135
143
|
|
|
136
144
|
/**
|
|
@@ -138,14 +146,16 @@ export const pikku = (_options?: any) => {
|
|
|
138
146
|
*
|
|
139
147
|
* @template Route - The route key with the DELETE method.
|
|
140
148
|
* @param route - The route identifier.
|
|
141
|
-
* @param data - The input data for the DELETE request
|
|
149
|
+
* @param data - The input data for the DELETE request (required if input type is defined).
|
|
142
150
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
143
151
|
*/
|
|
144
152
|
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
145
153
|
route: Route,
|
|
146
|
-
|
|
154
|
+
...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
|
|
155
|
+
? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
|
|
156
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
|
|
147
157
|
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
148
|
-
return dynamicActionRequest(route, 'DELETE',
|
|
158
|
+
return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
|
|
149
159
|
}
|
|
150
160
|
|
|
151
161
|
// Static Requests
|
|
@@ -155,14 +165,16 @@ export const pikku = (_options?: any) => {
|
|
|
155
165
|
*
|
|
156
166
|
* @template Route - The route key with the POST method.
|
|
157
167
|
* @param route - The route identifier.
|
|
158
|
-
* @param data - The input data for the POST request
|
|
168
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
159
169
|
* @returns A promise that resolves to the output of the POST handler.
|
|
160
170
|
*/
|
|
161
171
|
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
162
172
|
route: Route,
|
|
163
|
-
|
|
173
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
174
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
175
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
164
176
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
165
|
-
return staticActionRequest(route, 'POST',
|
|
177
|
+
return staticActionRequest(route, 'POST', args[0] ?? null)
|
|
166
178
|
}
|
|
167
179
|
|
|
168
180
|
/**
|
|
@@ -170,23 +182,64 @@ export const pikku = (_options?: any) => {
|
|
|
170
182
|
*
|
|
171
183
|
* @template Route - The route key with the GET method.
|
|
172
184
|
* @param route - The route identifier.
|
|
173
|
-
* @param data - The input data for the GET request
|
|
185
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
174
186
|
* @returns A promise that resolves to the output of the GET handler.
|
|
175
187
|
*/
|
|
176
188
|
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
177
189
|
route: Route,
|
|
178
|
-
|
|
190
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
191
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
192
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
179
193
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
180
|
-
return staticActionRequest(route, 'GET',
|
|
194
|
+
return staticActionRequest(route, 'GET', args[0] ?? null)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// RPC Requests
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Makes a dynamic RPC request.
|
|
201
|
+
*
|
|
202
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
203
|
+
* @param name - The RPC function identifier.
|
|
204
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
205
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
206
|
+
*/
|
|
207
|
+
const rpc = async <Name extends keyof FlattenedRPCMap>(
|
|
208
|
+
rpcName: Name,
|
|
209
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
210
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
211
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
212
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
213
|
+
return dynamicActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Makes a static RPC request.
|
|
218
|
+
* Note: In HTTP wrapper context, both rpc and staticRPC behave the same way.
|
|
219
|
+
*
|
|
220
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
221
|
+
* @param name - The RPC function identifier.
|
|
222
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
223
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
224
|
+
*/
|
|
225
|
+
const staticRPC = async <Name extends keyof FlattenedRPCMap>(
|
|
226
|
+
rpcName: Name,
|
|
227
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
228
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
229
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
230
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
231
|
+
return staticActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
181
232
|
}
|
|
182
233
|
|
|
183
234
|
return {
|
|
235
|
+
rpc,
|
|
184
236
|
get: dynamicGet,
|
|
185
237
|
post: dynamicPost,
|
|
186
238
|
patch: dynamicPatch,
|
|
187
239
|
del: dynamicDel,
|
|
188
240
|
staticGet,
|
|
189
241
|
staticPost,
|
|
242
|
+
staticRPC,
|
|
190
243
|
}
|
|
191
244
|
}
|
|
192
245
|
|
|
@@ -210,7 +263,7 @@ export const pikkuAPIRequest = (
|
|
|
210
263
|
_pikku = new PikkuNextJS(
|
|
211
264
|
createConfig as any,
|
|
212
265
|
createSingletonServices as any,
|
|
213
|
-
|
|
266
|
+
createWireServices
|
|
214
267
|
)
|
|
215
268
|
}
|
|
216
269
|
if (_removeAPIPrefix) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const serializeNextJsHTTPWrapper = (
|
|
2
2
|
routesMapPath: string,
|
|
3
|
+
rpcMapPath: string,
|
|
3
4
|
pikkuFetchImport: string
|
|
4
5
|
) => {
|
|
5
6
|
return `'server-only'
|
|
@@ -10,6 +11,7 @@ export const serializeNextJsHTTPWrapper = (
|
|
|
10
11
|
*/
|
|
11
12
|
import { CorePikkuFetchOptions } from '@pikku/fetch'
|
|
12
13
|
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
14
|
+
import type { FlattenedRPCMap } from '${rpcMapPath}'
|
|
13
15
|
import { PikkuFetch } from '${pikkuFetchImport}'
|
|
14
16
|
|
|
15
17
|
let _pikku: PikkuFetch | undefined
|
|
@@ -62,14 +64,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
62
64
|
*
|
|
63
65
|
* @template Route - The route key with the POST method.
|
|
64
66
|
* @param route - The route identifier.
|
|
65
|
-
* @param data - The input data for the POST request
|
|
67
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
66
68
|
* @returns A promise that resolves to the output of the POST handler.
|
|
67
69
|
*/
|
|
68
70
|
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
69
71
|
route: Route,
|
|
70
|
-
|
|
72
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
73
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
74
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
71
75
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
72
|
-
return dynamicActionRequest(route, 'POST',
|
|
76
|
+
return dynamicActionRequest(route, 'POST', args[0] ?? null)
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
/**
|
|
@@ -77,14 +81,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
77
81
|
*
|
|
78
82
|
* @template Route - The route key with the GET method.
|
|
79
83
|
* @param route - The route identifier.
|
|
80
|
-
* @param data - The input data for the GET request
|
|
84
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
81
85
|
* @returns A promise that resolves to the output of the GET handler.
|
|
82
86
|
*/
|
|
83
87
|
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
84
88
|
route: Route,
|
|
85
|
-
|
|
89
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
90
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
91
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
86
92
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
87
|
-
return dynamicActionRequest(route, 'GET',
|
|
93
|
+
return dynamicActionRequest(route, 'GET', args[0] ?? null)
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
/**
|
|
@@ -92,14 +98,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
92
98
|
*
|
|
93
99
|
* @template Route - The route key with the PATCH method.
|
|
94
100
|
* @param route - The route identifier.
|
|
95
|
-
* @param data - The input data for the PATCH request
|
|
101
|
+
* @param data - The input data for the PATCH request (required if input type is defined).
|
|
96
102
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
97
103
|
*/
|
|
98
104
|
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
99
105
|
route: Route,
|
|
100
|
-
|
|
106
|
+
...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
|
|
107
|
+
? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
|
|
108
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
|
|
101
109
|
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
102
|
-
return dynamicActionRequest(route, 'PATCH',
|
|
110
|
+
return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
/**
|
|
@@ -107,14 +115,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
107
115
|
*
|
|
108
116
|
* @template Route - The route key with the DELETE method.
|
|
109
117
|
* @param route - The route identifier.
|
|
110
|
-
* @param data - The input data for the DELETE request
|
|
118
|
+
* @param data - The input data for the DELETE request (required if input type is defined).
|
|
111
119
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
112
120
|
*/
|
|
113
121
|
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
114
122
|
route: Route,
|
|
115
|
-
|
|
123
|
+
...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
|
|
124
|
+
? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
|
|
125
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
|
|
116
126
|
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
117
|
-
return dynamicActionRequest(route, 'DELETE',
|
|
127
|
+
return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
|
|
118
128
|
}
|
|
119
129
|
|
|
120
130
|
// Static Requests
|
|
@@ -124,14 +134,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
124
134
|
*
|
|
125
135
|
* @template Route - The route key with the POST method.
|
|
126
136
|
* @param route - The route identifier.
|
|
127
|
-
* @param data - The input data for the POST request
|
|
137
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
128
138
|
* @returns A promise that resolves to the output of the POST handler.
|
|
129
139
|
*/
|
|
130
140
|
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
131
141
|
route: Route,
|
|
132
|
-
|
|
142
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
143
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
144
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
133
145
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
134
|
-
return staticActionRequest(route, 'POST',
|
|
146
|
+
return staticActionRequest(route, 'POST', args[0] ?? null)
|
|
135
147
|
}
|
|
136
148
|
|
|
137
149
|
/**
|
|
@@ -139,23 +151,64 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
139
151
|
*
|
|
140
152
|
* @template Route - The route key with the GET method.
|
|
141
153
|
* @param route - The route identifier.
|
|
142
|
-
* @param data - The input data for the GET request
|
|
154
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
143
155
|
* @returns A promise that resolves to the output of the GET handler.
|
|
144
156
|
*/
|
|
145
157
|
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
146
158
|
route: Route,
|
|
147
|
-
|
|
159
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
160
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
161
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
148
162
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
149
|
-
return staticActionRequest(route, 'GET',
|
|
163
|
+
return staticActionRequest(route, 'GET', args[0] ?? null)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// RPC Requests
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Makes a dynamic RPC request.
|
|
170
|
+
*
|
|
171
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
172
|
+
* @param name - The RPC function identifier.
|
|
173
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
174
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
175
|
+
*/
|
|
176
|
+
const rpc = async <Name extends keyof FlattenedRPCMap>(
|
|
177
|
+
rpcName: Name,
|
|
178
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
179
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
180
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
181
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
182
|
+
return dynamicActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Makes a static RPC request.
|
|
187
|
+
* Note: In HTTP wrapper context, both rpc and rpcStatic behave the same way.
|
|
188
|
+
*
|
|
189
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
190
|
+
* @param name - The RPC function identifier.
|
|
191
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
192
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
193
|
+
*/
|
|
194
|
+
const staticRPC = async <Name extends keyof FlattenedRPCMap>(
|
|
195
|
+
rpcName: Name,
|
|
196
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
197
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
198
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
199
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
200
|
+
return staticActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
150
201
|
}
|
|
151
202
|
|
|
152
203
|
return {
|
|
204
|
+
rpc,
|
|
153
205
|
get: dynamicGet,
|
|
154
206
|
post: dynamicPost,
|
|
155
207
|
patch: dynamicPatch,
|
|
156
208
|
del: dynamicDel,
|
|
157
209
|
staticGet,
|
|
158
|
-
staticPost
|
|
210
|
+
staticPost,
|
|
211
|
+
staticRPC
|
|
159
212
|
}
|
|
160
213
|
}
|
|
161
214
|
`
|
|
@@ -2,12 +2,18 @@ import { pikkuVoidFunc } 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 pikkuChannels: any = pikkuVoidFunc({
|
|
7
8
|
func: async ({ logger, config, getInspectorState }) => {
|
|
8
9
|
const visitState = await getInspectorState()
|
|
9
|
-
const {
|
|
10
|
-
|
|
10
|
+
const {
|
|
11
|
+
channelsWiringFile,
|
|
12
|
+
channelsWiringMetaFile,
|
|
13
|
+
channelsWiringMetaJsonFile,
|
|
14
|
+
packageMappings,
|
|
15
|
+
schema,
|
|
16
|
+
} = config
|
|
11
17
|
const { channels } = visitState
|
|
12
18
|
|
|
13
19
|
await writeFileInDir(
|
|
@@ -20,10 +26,28 @@ export const pikkuChannels: any = pikkuVoidFunc({
|
|
|
20
26
|
packageMappings
|
|
21
27
|
)
|
|
22
28
|
)
|
|
29
|
+
|
|
30
|
+
await writeFileInDir(
|
|
31
|
+
logger,
|
|
32
|
+
channelsWiringMetaJsonFile,
|
|
33
|
+
JSON.stringify(channels.meta, null, 2)
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
37
|
+
channelsWiringMetaFile,
|
|
38
|
+
channelsWiringMetaJsonFile,
|
|
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
|
+
|
|
23
47
|
await writeFileInDir(
|
|
24
48
|
logger,
|
|
25
49
|
channelsWiringMetaFile,
|
|
26
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta',
|
|
50
|
+
`import { pikkuState } from '@pikku/core'\nimport { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`
|
|
27
51
|
)
|
|
28
52
|
},
|
|
29
53
|
middleware: [
|
|
@@ -2,6 +2,11 @@ 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 pikkuChannels: any = pikkuSessionlessFunc<
|
|
7
12
|
void,
|
|
@@ -9,8 +14,13 @@ export const pikkuChannels: any = pikkuSessionlessFunc<
|
|
|
9
14
|
>({
|
|
10
15
|
func: async ({ logger, config, getInspectorState }) => {
|
|
11
16
|
const visitState = await getInspectorState()
|
|
12
|
-
const {
|
|
13
|
-
|
|
17
|
+
const {
|
|
18
|
+
channelsWiringFile,
|
|
19
|
+
channelsWiringMetaFile,
|
|
20
|
+
channelsWiringMetaJsonFile,
|
|
21
|
+
packageMappings,
|
|
22
|
+
schema,
|
|
23
|
+
} = config
|
|
14
24
|
const { channels } = visitState
|
|
15
25
|
|
|
16
26
|
await writeFileInDir(
|
|
@@ -23,10 +33,43 @@ export const pikkuChannels: any = pikkuSessionlessFunc<
|
|
|
23
33
|
packageMappings
|
|
24
34
|
)
|
|
25
35
|
)
|
|
36
|
+
|
|
37
|
+
// Write minimal JSON (runtime-only fields)
|
|
38
|
+
const minimalMeta = stripVerboseFields(channels.meta)
|
|
39
|
+
await writeFileInDir(
|
|
40
|
+
logger,
|
|
41
|
+
channelsWiringMetaJsonFile,
|
|
42
|
+
JSON.stringify(minimalMeta, null, 2)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
// Write verbose JSON only if it has additional fields
|
|
46
|
+
if (hasVerboseFields(channels.meta)) {
|
|
47
|
+
const verbosePath = channelsWiringMetaJsonFile.replace(
|
|
48
|
+
/\.gen\.json$/,
|
|
49
|
+
'-verbose.gen.json'
|
|
50
|
+
)
|
|
51
|
+
await writeFileInDir(
|
|
52
|
+
logger,
|
|
53
|
+
verbosePath,
|
|
54
|
+
JSON.stringify(channels.meta, null, 2)
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Generate TypeScript file that imports the minimal JSON
|
|
59
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
60
|
+
channelsWiringMetaFile,
|
|
61
|
+
channelsWiringMetaJsonFile,
|
|
62
|
+
packageMappings
|
|
63
|
+
)
|
|
64
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false
|
|
65
|
+
const importStatement = supportsImportAttributes
|
|
66
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
67
|
+
: `import metaData from '${jsonImportPath}'`
|
|
68
|
+
|
|
26
69
|
await writeFileInDir(
|
|
27
70
|
logger,
|
|
28
71
|
channelsWiringMetaFile,
|
|
29
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta',
|
|
72
|
+
`import { pikkuState } from '@pikku/core'\nimport type { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`
|
|
30
73
|
)
|
|
31
74
|
|
|
32
75
|
return true
|
|
@@ -8,9 +8,14 @@ export const serializeChannelTypes = (functionTypesImportPath: string) => {
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import { CoreChannel, wireChannel as wireChannelCore } from '@pikku/core/channel'
|
|
11
|
-
import { CorePikkuFunctionConfig } from '@pikku/core'
|
|
12
11
|
import { AssertHTTPWiringParams } from '@pikku/core/http'
|
|
13
|
-
import type {
|
|
12
|
+
import type { PikkuFunctionConfig, PikkuFunctionSessionless, PikkuPermission, PikkuMiddleware } from '${functionTypesImportPath}'
|
|
13
|
+
import type { ZodLike, CorePermissionGroup } from '@pikku/core'
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Helper type to infer the output type from a Zod schema
|
|
17
|
+
*/
|
|
18
|
+
type InferZodOutput<T> = T extends ZodLike<infer U> ? U : never
|
|
14
19
|
|
|
15
20
|
/**
|
|
16
21
|
* Type definition for WebSocket channels with typed data exchange.
|
|
@@ -23,9 +28,9 @@ import type { PikkuFunction, PikkuFunctionSessionless, PikkuPermission, PikkuMid
|
|
|
23
28
|
type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<
|
|
24
29
|
ChannelData,
|
|
25
30
|
Channel,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
PikkuFunctionConfig<void, any, 'channel' | 'session' | 'rpc'>,
|
|
32
|
+
PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>,
|
|
33
|
+
PikkuFunctionConfig<any, any, 'channel' | 'session' | 'rpc'>,
|
|
29
34
|
PikkuPermission,
|
|
30
35
|
PikkuMiddleware
|
|
31
36
|
>
|
|
@@ -40,8 +45,8 @@ type ChannelWiring<ChannelData, Channel extends string> = CoreChannel<
|
|
|
40
45
|
*/
|
|
41
46
|
export const pikkuChannelConnectionFunc = <Out = unknown>(
|
|
42
47
|
func:
|
|
43
|
-
| PikkuFunctionSessionless<void, Out,
|
|
44
|
-
|
|
|
48
|
+
| PikkuFunctionSessionless<void, Out, 'channel' | 'session' | 'rpc'>
|
|
49
|
+
| PikkuFunctionConfig<void, Out, 'channel' | 'session' | 'rpc'>
|
|
45
50
|
) => {
|
|
46
51
|
return typeof func === 'function' ? { func } : func
|
|
47
52
|
}
|
|
@@ -55,27 +60,78 @@ export const pikkuChannelConnectionFunc = <Out = unknown>(
|
|
|
55
60
|
*/
|
|
56
61
|
export const pikkuChannelDisconnectionFunc = (
|
|
57
62
|
func:
|
|
58
|
-
| PikkuFunctionSessionless<void, void,
|
|
59
|
-
|
|
|
63
|
+
| PikkuFunctionSessionless<void, void, 'channel'>
|
|
64
|
+
| PikkuFunctionConfig<void, void, 'channel' | 'session' | 'rpc'>
|
|
60
65
|
) => {
|
|
61
66
|
return typeof func === 'function' ? { func } : func
|
|
62
67
|
}
|
|
63
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Configuration object for channel functions with Zod schema validation.
|
|
71
|
+
*/
|
|
72
|
+
type PikkuChannelFuncConfigWithSchema<
|
|
73
|
+
InputSchema extends ZodLike,
|
|
74
|
+
OutputSchema extends ZodLike | undefined = undefined
|
|
75
|
+
> = {
|
|
76
|
+
name?: string
|
|
77
|
+
tags?: string[]
|
|
78
|
+
expose?: boolean
|
|
79
|
+
internal?: boolean
|
|
80
|
+
func: PikkuFunctionSessionless<
|
|
81
|
+
InferZodOutput<InputSchema>,
|
|
82
|
+
OutputSchema extends ZodLike ? InferZodOutput<OutputSchema> : unknown,
|
|
83
|
+
'channel' | 'session' | 'rpc'
|
|
84
|
+
>
|
|
85
|
+
auth?: boolean
|
|
86
|
+
permissions?: CorePermissionGroup<PikkuPermission<InferZodOutput<InputSchema>>>
|
|
87
|
+
middleware?: PikkuMiddleware[]
|
|
88
|
+
input: InputSchema
|
|
89
|
+
output?: OutputSchema
|
|
90
|
+
}
|
|
91
|
+
|
|
64
92
|
/**
|
|
65
93
|
* Creates a function that handles WebSocket channel messages.
|
|
66
94
|
* Called when a message is received on a channel.
|
|
67
|
-
* This is the same as pikkuSessionlessFunc but with ChannelData = unknown by default.
|
|
68
95
|
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
96
|
+
* Supports two patterns:
|
|
97
|
+
* 1. Generic types: \`pikkuChannelFunc<Input, Output>({ func: ... })\`
|
|
98
|
+
* 2. Zod schemas: \`pikkuChannelFunc({ input: z.object(...), func: ... })\`
|
|
99
|
+
*
|
|
100
|
+
* @template In - Input type for channel messages (inferred from schema if provided)
|
|
101
|
+
* @template Out - Output type for channel responses (inferred from schema if provided)
|
|
71
102
|
* @param func - Function definition, either direct function or configuration object
|
|
72
103
|
* @returns The normalized configuration object
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* \`\`\`typescript
|
|
107
|
+
* // Pattern 1: Using generic types
|
|
108
|
+
* const handleMessage = pikkuChannelFunc<{text: string}, {received: boolean}>({
|
|
109
|
+
* func: async (_services, { text }) => ({ received: true })
|
|
110
|
+
* })
|
|
111
|
+
*
|
|
112
|
+
* // Pattern 2: Using Zod schemas
|
|
113
|
+
* const messageInput = z.object({ text: z.string() })
|
|
114
|
+
* const messageOutput = z.object({ received: z.boolean() })
|
|
115
|
+
*
|
|
116
|
+
* const handleMessage = pikkuChannelFunc({
|
|
117
|
+
* input: messageInput,
|
|
118
|
+
* output: messageOutput,
|
|
119
|
+
* func: async (_services, { text }) => ({ received: true })
|
|
120
|
+
* })
|
|
121
|
+
* \`\`\`
|
|
73
122
|
*/
|
|
74
|
-
export
|
|
123
|
+
export function pikkuChannelFunc<
|
|
124
|
+
InputSchema extends ZodLike,
|
|
125
|
+
OutputSchema extends ZodLike | undefined = undefined
|
|
126
|
+
>(
|
|
127
|
+
config: PikkuChannelFuncConfigWithSchema<InputSchema, OutputSchema>
|
|
128
|
+
): PikkuFunctionConfig<InferZodOutput<InputSchema>, OutputSchema extends ZodLike ? InferZodOutput<OutputSchema> : unknown, 'channel' | 'session' | 'rpc'>
|
|
129
|
+
export function pikkuChannelFunc<In, Out = unknown>(
|
|
75
130
|
func:
|
|
76
|
-
| PikkuFunctionSessionless<In, Out,
|
|
77
|
-
|
|
|
78
|
-
)
|
|
131
|
+
| PikkuFunctionSessionless<In, Out, 'channel' | 'session' | 'rpc'>
|
|
132
|
+
| PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
|
|
133
|
+
): PikkuFunctionConfig<In, Out, 'channel' | 'session' | 'rpc'>
|
|
134
|
+
export function pikkuChannelFunc(func: any) {
|
|
79
135
|
return typeof func === 'function' ? { func } : func
|
|
80
136
|
}
|
|
81
137
|
|