@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,4 +1,4 @@
|
|
|
1
|
-
export const serializeNextJsBackendWrapper = (bootstrapPath, routesMapPath, configImport, singleServicesFactoryImport,
|
|
1
|
+
export const serializeNextJsBackendWrapper = (bootstrapPath, routesMapPath, rpcMapPath, configImport, singleServicesFactoryImport, wireServicesImport) => {
|
|
2
2
|
return `'server-only'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -8,12 +8,13 @@ export const serializeNextJsBackendWrapper = (bootstrapPath, routesMapPath, conf
|
|
|
8
8
|
import { PikkuNextJS } from '@pikku/next'
|
|
9
9
|
import { NextRequest } from 'next/server.js'
|
|
10
10
|
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
11
|
+
import type { FlattenedRPCMap } from '${rpcMapPath}'
|
|
11
12
|
|
|
12
13
|
type RouteContext = { params: Promise<Record<string, string | string[]>> }
|
|
13
14
|
|
|
14
15
|
${configImport}
|
|
15
16
|
${singleServicesFactoryImport}
|
|
16
|
-
${
|
|
17
|
+
${wireServicesImport}
|
|
17
18
|
|
|
18
19
|
import '${bootstrapPath}'
|
|
19
20
|
|
|
@@ -34,7 +35,7 @@ export const pikku = (_options?: any) => {
|
|
|
34
35
|
_pikku = new PikkuNextJS(
|
|
35
36
|
createConfig as any,
|
|
36
37
|
createSingletonServices as any,
|
|
37
|
-
|
|
38
|
+
createWireServices
|
|
38
39
|
)
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -87,14 +88,16 @@ export const pikku = (_options?: any) => {
|
|
|
87
88
|
*
|
|
88
89
|
* @template Route - The route key with the POST method.
|
|
89
90
|
* @param route - The route identifier.
|
|
90
|
-
* @param data - The input data for the POST request
|
|
91
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
91
92
|
* @returns A promise that resolves to the output of the POST handler.
|
|
92
93
|
*/
|
|
93
94
|
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
94
95
|
route: Route,
|
|
95
|
-
|
|
96
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
97
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
98
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
96
99
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
97
|
-
return dynamicActionRequest(route, 'POST',
|
|
100
|
+
return dynamicActionRequest(route, 'POST', args[0] ?? null)
|
|
98
101
|
}
|
|
99
102
|
|
|
100
103
|
/**
|
|
@@ -102,14 +105,16 @@ export const pikku = (_options?: any) => {
|
|
|
102
105
|
*
|
|
103
106
|
* @template Route - The route key with the GET method.
|
|
104
107
|
* @param route - The route identifier.
|
|
105
|
-
* @param data - The input data for the GET request
|
|
108
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
106
109
|
* @returns A promise that resolves to the output of the GET handler.
|
|
107
110
|
*/
|
|
108
111
|
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
109
112
|
route: Route,
|
|
110
|
-
|
|
113
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
114
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
115
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
111
116
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
112
|
-
return dynamicActionRequest(route, 'GET',
|
|
117
|
+
return dynamicActionRequest(route, 'GET', args[0] ?? null)
|
|
113
118
|
}
|
|
114
119
|
|
|
115
120
|
/**
|
|
@@ -117,14 +122,16 @@ export const pikku = (_options?: any) => {
|
|
|
117
122
|
*
|
|
118
123
|
* @template Route - The route key with the PATCH method.
|
|
119
124
|
* @param route - The route identifier.
|
|
120
|
-
* @param data - The input data for the PATCH request
|
|
125
|
+
* @param data - The input data for the PATCH request (required if input type is defined).
|
|
121
126
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
122
127
|
*/
|
|
123
128
|
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
124
129
|
route: Route,
|
|
125
|
-
|
|
130
|
+
...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
|
|
131
|
+
? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
|
|
132
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
|
|
126
133
|
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
127
|
-
return dynamicActionRequest(route, 'PATCH',
|
|
134
|
+
return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
|
|
128
135
|
}
|
|
129
136
|
|
|
130
137
|
/**
|
|
@@ -132,14 +139,16 @@ export const pikku = (_options?: any) => {
|
|
|
132
139
|
*
|
|
133
140
|
* @template Route - The route key with the DELETE method.
|
|
134
141
|
* @param route - The route identifier.
|
|
135
|
-
* @param data - The input data for the DELETE request
|
|
142
|
+
* @param data - The input data for the DELETE request (required if input type is defined).
|
|
136
143
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
137
144
|
*/
|
|
138
145
|
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
139
146
|
route: Route,
|
|
140
|
-
|
|
147
|
+
...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
|
|
148
|
+
? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
|
|
149
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
|
|
141
150
|
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
142
|
-
return dynamicActionRequest(route, 'DELETE',
|
|
151
|
+
return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
|
|
143
152
|
}
|
|
144
153
|
|
|
145
154
|
// Static Requests
|
|
@@ -149,14 +158,16 @@ export const pikku = (_options?: any) => {
|
|
|
149
158
|
*
|
|
150
159
|
* @template Route - The route key with the POST method.
|
|
151
160
|
* @param route - The route identifier.
|
|
152
|
-
* @param data - The input data for the POST request
|
|
161
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
153
162
|
* @returns A promise that resolves to the output of the POST handler.
|
|
154
163
|
*/
|
|
155
164
|
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
156
165
|
route: Route,
|
|
157
|
-
|
|
166
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
167
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
168
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
158
169
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
159
|
-
return staticActionRequest(route, 'POST',
|
|
170
|
+
return staticActionRequest(route, 'POST', args[0] ?? null)
|
|
160
171
|
}
|
|
161
172
|
|
|
162
173
|
/**
|
|
@@ -164,23 +175,64 @@ export const pikku = (_options?: any) => {
|
|
|
164
175
|
*
|
|
165
176
|
* @template Route - The route key with the GET method.
|
|
166
177
|
* @param route - The route identifier.
|
|
167
|
-
* @param data - The input data for the GET request
|
|
178
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
168
179
|
* @returns A promise that resolves to the output of the GET handler.
|
|
169
180
|
*/
|
|
170
181
|
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
171
182
|
route: Route,
|
|
172
|
-
|
|
183
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
184
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
185
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
173
186
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
174
|
-
return staticActionRequest(route, 'GET',
|
|
187
|
+
return staticActionRequest(route, 'GET', args[0] ?? null)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// RPC Requests
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Makes a dynamic RPC request.
|
|
194
|
+
*
|
|
195
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
196
|
+
* @param name - The RPC function identifier.
|
|
197
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
198
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
199
|
+
*/
|
|
200
|
+
const rpc = async <Name extends keyof FlattenedRPCMap>(
|
|
201
|
+
rpcName: Name,
|
|
202
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
203
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
204
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
205
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
206
|
+
return dynamicActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Makes a static RPC request.
|
|
211
|
+
* Note: In HTTP wrapper context, both rpc and staticRPC behave the same way.
|
|
212
|
+
*
|
|
213
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
214
|
+
* @param name - The RPC function identifier.
|
|
215
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
216
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
217
|
+
*/
|
|
218
|
+
const staticRPC = async <Name extends keyof FlattenedRPCMap>(
|
|
219
|
+
rpcName: Name,
|
|
220
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
221
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
222
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
223
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
224
|
+
return staticActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
175
225
|
}
|
|
176
226
|
|
|
177
227
|
return {
|
|
228
|
+
rpc,
|
|
178
229
|
get: dynamicGet,
|
|
179
230
|
post: dynamicPost,
|
|
180
231
|
patch: dynamicPatch,
|
|
181
232
|
del: dynamicDel,
|
|
182
233
|
staticGet,
|
|
183
234
|
staticPost,
|
|
235
|
+
staticRPC,
|
|
184
236
|
}
|
|
185
237
|
}
|
|
186
238
|
|
|
@@ -204,7 +256,7 @@ export const pikkuAPIRequest = (
|
|
|
204
256
|
_pikku = new PikkuNextJS(
|
|
205
257
|
createConfig as any,
|
|
206
258
|
createSingletonServices as any,
|
|
207
|
-
|
|
259
|
+
createWireServices
|
|
208
260
|
)
|
|
209
261
|
}
|
|
210
262
|
if (_removeAPIPrefix) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const serializeNextJsHTTPWrapper: (routesMapPath: string, pikkuFetchImport: string) => string;
|
|
1
|
+
export declare const serializeNextJsHTTPWrapper: (routesMapPath: string, rpcMapPath: string, pikkuFetchImport: string) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const serializeNextJsHTTPWrapper = (routesMapPath, pikkuFetchImport) => {
|
|
1
|
+
export const serializeNextJsHTTPWrapper = (routesMapPath, rpcMapPath, pikkuFetchImport) => {
|
|
2
2
|
return `'server-only'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -7,6 +7,7 @@ export const serializeNextJsHTTPWrapper = (routesMapPath, pikkuFetchImport) => {
|
|
|
7
7
|
*/
|
|
8
8
|
import { CorePikkuFetchOptions } from '@pikku/fetch'
|
|
9
9
|
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
10
|
+
import type { FlattenedRPCMap } from '${rpcMapPath}'
|
|
10
11
|
import { PikkuFetch } from '${pikkuFetchImport}'
|
|
11
12
|
|
|
12
13
|
let _pikku: PikkuFetch | undefined
|
|
@@ -59,14 +60,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
59
60
|
*
|
|
60
61
|
* @template Route - The route key with the POST method.
|
|
61
62
|
* @param route - The route identifier.
|
|
62
|
-
* @param data - The input data for the POST request
|
|
63
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
63
64
|
* @returns A promise that resolves to the output of the POST handler.
|
|
64
65
|
*/
|
|
65
66
|
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
66
67
|
route: Route,
|
|
67
|
-
|
|
68
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
69
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
70
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
68
71
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
69
|
-
return dynamicActionRequest(route, 'POST',
|
|
72
|
+
return dynamicActionRequest(route, 'POST', args[0] ?? null)
|
|
70
73
|
}
|
|
71
74
|
|
|
72
75
|
/**
|
|
@@ -74,14 +77,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
74
77
|
*
|
|
75
78
|
* @template Route - The route key with the GET method.
|
|
76
79
|
* @param route - The route identifier.
|
|
77
|
-
* @param data - The input data for the GET request
|
|
80
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
78
81
|
* @returns A promise that resolves to the output of the GET handler.
|
|
79
82
|
*/
|
|
80
83
|
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
81
84
|
route: Route,
|
|
82
|
-
|
|
85
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
86
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
87
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
83
88
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
84
|
-
return dynamicActionRequest(route, 'GET',
|
|
89
|
+
return dynamicActionRequest(route, 'GET', args[0] ?? null)
|
|
85
90
|
}
|
|
86
91
|
|
|
87
92
|
/**
|
|
@@ -89,14 +94,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
89
94
|
*
|
|
90
95
|
* @template Route - The route key with the PATCH method.
|
|
91
96
|
* @param route - The route identifier.
|
|
92
|
-
* @param data - The input data for the PATCH request
|
|
97
|
+
* @param data - The input data for the PATCH request (required if input type is defined).
|
|
93
98
|
* @returns A promise that resolves to the output of the PATCH handler.
|
|
94
99
|
*/
|
|
95
100
|
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
96
101
|
route: Route,
|
|
97
|
-
|
|
102
|
+
...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
|
|
103
|
+
? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
|
|
104
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
|
|
98
105
|
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
99
|
-
return dynamicActionRequest(route, 'PATCH',
|
|
106
|
+
return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
|
|
100
107
|
}
|
|
101
108
|
|
|
102
109
|
/**
|
|
@@ -104,14 +111,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
104
111
|
*
|
|
105
112
|
* @template Route - The route key with the DELETE method.
|
|
106
113
|
* @param route - The route identifier.
|
|
107
|
-
* @param data - The input data for the DELETE request
|
|
114
|
+
* @param data - The input data for the DELETE request (required if input type is defined).
|
|
108
115
|
* @returns A promise that resolves to the output of the DELETE handler.
|
|
109
116
|
*/
|
|
110
117
|
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
111
118
|
route: Route,
|
|
112
|
-
|
|
119
|
+
...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
|
|
120
|
+
? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
|
|
121
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
|
|
113
122
|
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
114
|
-
return dynamicActionRequest(route, 'DELETE',
|
|
123
|
+
return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
|
|
115
124
|
}
|
|
116
125
|
|
|
117
126
|
// Static Requests
|
|
@@ -121,14 +130,16 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
121
130
|
*
|
|
122
131
|
* @template Route - The route key with the POST method.
|
|
123
132
|
* @param route - The route identifier.
|
|
124
|
-
* @param data - The input data for the POST request
|
|
133
|
+
* @param data - The input data for the POST request (required if input type is defined).
|
|
125
134
|
* @returns A promise that resolves to the output of the POST handler.
|
|
126
135
|
*/
|
|
127
136
|
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
128
137
|
route: Route,
|
|
129
|
-
|
|
138
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
139
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
140
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
130
141
|
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
131
|
-
return staticActionRequest(route, 'POST',
|
|
142
|
+
return staticActionRequest(route, 'POST', args[0] ?? null)
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
/**
|
|
@@ -136,23 +147,64 @@ export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
|
136
147
|
*
|
|
137
148
|
* @template Route - The route key with the GET method.
|
|
138
149
|
* @param route - The route identifier.
|
|
139
|
-
* @param data - The input data for the GET request
|
|
150
|
+
* @param data - The input data for the GET request (required if input type is defined).
|
|
140
151
|
* @returns A promise that resolves to the output of the GET handler.
|
|
141
152
|
*/
|
|
142
153
|
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
143
154
|
route: Route,
|
|
144
|
-
|
|
155
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
156
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
157
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
145
158
|
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
146
|
-
return staticActionRequest(route, 'GET',
|
|
159
|
+
return staticActionRequest(route, 'GET', args[0] ?? null)
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// RPC Requests
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Makes a dynamic RPC request.
|
|
166
|
+
*
|
|
167
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
168
|
+
* @param name - The RPC function identifier.
|
|
169
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
170
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
171
|
+
*/
|
|
172
|
+
const rpc = async <Name extends keyof FlattenedRPCMap>(
|
|
173
|
+
rpcName: Name,
|
|
174
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
175
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
176
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
177
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
178
|
+
return dynamicActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Makes a static RPC request.
|
|
183
|
+
* Note: In HTTP wrapper context, both rpc and rpcStatic behave the same way.
|
|
184
|
+
*
|
|
185
|
+
* @template Name - The RPC function name from the FlattenedRPCMap.
|
|
186
|
+
* @param name - The RPC function identifier.
|
|
187
|
+
* @param data - The input data for the RPC request (required if input type is defined).
|
|
188
|
+
* @returns A promise that resolves to the output of the RPC handler.
|
|
189
|
+
*/
|
|
190
|
+
const staticRPC = async <Name extends keyof FlattenedRPCMap>(
|
|
191
|
+
rpcName: Name,
|
|
192
|
+
...args: FlattenedRPCMap[Name]['input'] extends null | undefined
|
|
193
|
+
? [data?: FlattenedRPCMap[Name]['input']]
|
|
194
|
+
: [data: NonNullable<FlattenedRPCMap[Name]['input']>]
|
|
195
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
196
|
+
return staticActionRequest('/rpc/:rpcName' as '/rpc/:rpcName', 'POST', { rpcName, data: args[0] ?? null }) as unknown as FlattenedRPCMap[Name]['output']
|
|
147
197
|
}
|
|
148
198
|
|
|
149
199
|
return {
|
|
200
|
+
rpc,
|
|
150
201
|
get: dynamicGet,
|
|
151
202
|
post: dynamicPost,
|
|
152
203
|
patch: dynamicPatch,
|
|
153
204
|
del: dynamicDel,
|
|
154
205
|
staticGet,
|
|
155
|
-
staticPost
|
|
206
|
+
staticPost,
|
|
207
|
+
staticRPC
|
|
156
208
|
}
|
|
157
209
|
}
|
|
158
210
|
`;
|
|
@@ -2,13 +2,20 @@ 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
|
export const pikkuChannels = pikkuVoidFunc({
|
|
6
7
|
func: async ({ logger, config, getInspectorState }) => {
|
|
7
8
|
const visitState = await getInspectorState();
|
|
8
|
-
const { channelsWiringFile, channelsWiringMetaFile, packageMappings } = config;
|
|
9
|
+
const { channelsWiringFile, channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
9
10
|
const { channels } = visitState;
|
|
10
11
|
await writeFileInDir(logger, channelsWiringFile, serializeFileImports('addChannel', channelsWiringFile, channels.files, packageMappings));
|
|
11
|
-
await writeFileInDir(logger,
|
|
12
|
+
await writeFileInDir(logger, channelsWiringMetaJsonFile, JSON.stringify(channels.meta, null, 2));
|
|
13
|
+
const jsonImportPath = getFileImportRelativePath(channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings);
|
|
14
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false;
|
|
15
|
+
const importStatement = supportsImportAttributes
|
|
16
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
17
|
+
: `import metaData from '${jsonImportPath}'`;
|
|
18
|
+
await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
|
|
12
19
|
},
|
|
13
20
|
middleware: [
|
|
14
21
|
logCommandInfoAndTime({
|
|
@@ -2,13 +2,29 @@ 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 { stripVerboseFields, hasVerboseFields, } from '../../../utils/strip-verbose-meta.js';
|
|
5
7
|
export const pikkuChannels = pikkuSessionlessFunc({
|
|
6
8
|
func: async ({ logger, config, getInspectorState }) => {
|
|
7
9
|
const visitState = await getInspectorState();
|
|
8
|
-
const { channelsWiringFile, channelsWiringMetaFile, packageMappings } = config;
|
|
10
|
+
const { channelsWiringFile, channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings, schema, } = config;
|
|
9
11
|
const { channels } = visitState;
|
|
10
12
|
await writeFileInDir(logger, channelsWiringFile, serializeFileImports('addChannel', channelsWiringFile, channels.files, packageMappings));
|
|
11
|
-
|
|
13
|
+
// Write minimal JSON (runtime-only fields)
|
|
14
|
+
const minimalMeta = stripVerboseFields(channels.meta);
|
|
15
|
+
await writeFileInDir(logger, channelsWiringMetaJsonFile, JSON.stringify(minimalMeta, null, 2));
|
|
16
|
+
// Write verbose JSON only if it has additional fields
|
|
17
|
+
if (hasVerboseFields(channels.meta)) {
|
|
18
|
+
const verbosePath = channelsWiringMetaJsonFile.replace(/\.gen\.json$/, '-verbose.gen.json');
|
|
19
|
+
await writeFileInDir(logger, verbosePath, JSON.stringify(channels.meta, null, 2));
|
|
20
|
+
}
|
|
21
|
+
// Generate TypeScript file that imports the minimal JSON
|
|
22
|
+
const jsonImportPath = getFileImportRelativePath(channelsWiringMetaFile, channelsWiringMetaJsonFile, packageMappings);
|
|
23
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false;
|
|
24
|
+
const importStatement = supportsImportAttributes
|
|
25
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
26
|
+
: `import metaData from '${jsonImportPath}'`;
|
|
27
|
+
await writeFileInDir(logger, channelsWiringMetaFile, `import { pikkuState } from '@pikku/core'\nimport type { ChannelsMeta } from '@pikku/core/channel'\n${importStatement}\npikkuState(null, 'channel', 'meta', metaData as ChannelsMeta)`);
|
|
12
28
|
return true;
|
|
13
29
|
},
|
|
14
30
|
middleware: [
|
|
@@ -8,9 +8,14 @@ export const serializeChannelTypes = (functionTypesImportPath) => {
|
|
|
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
|
|
|
@@ -4,7 +4,6 @@ export const serializeTypedChannelsMap = (relativeToPath, packageMappings, types
|
|
|
4
4
|
const { channels, requiredTypes } = generateChannels(functionsMeta, channelsMeta);
|
|
5
5
|
typesMap.customTypes.forEach(({ references }) => {
|
|
6
6
|
for (const reference of references) {
|
|
7
|
-
// Skip __object types (placeholder types for invalid/broken functions)
|
|
8
7
|
if (reference !== '__object' && !reference.startsWith('__object_')) {
|
|
9
8
|
requiredTypes.add(reference);
|
|
10
9
|
}
|
|
@@ -15,7 +14,7 @@ export const serializeTypedChannelsMap = (relativeToPath, packageMappings, types
|
|
|
15
14
|
return `/**
|
|
16
15
|
* This provides the structure needed for TypeScript to be aware of channels
|
|
17
16
|
*/
|
|
18
|
-
|
|
17
|
+
|
|
19
18
|
${imports}
|
|
20
19
|
${serializedCustomTypes}
|
|
21
20
|
|
|
@@ -100,15 +100,15 @@ export const pikkuCLIEntry = pikkuSessionlessFunc({
|
|
|
100
100
|
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
101
101
|
config: true,
|
|
102
102
|
singletonServicesFactory: true,
|
|
103
|
-
|
|
103
|
+
wireServicesFactory: true,
|
|
104
104
|
});
|
|
105
|
-
const { pikkuConfigFactory, singletonServicesFactory,
|
|
105
|
+
const { pikkuConfigFactory, singletonServicesFactory, wireServicesFactory, } = visitState.filesAndMethods;
|
|
106
106
|
if (!pikkuConfigFactory ||
|
|
107
107
|
!singletonServicesFactory ||
|
|
108
|
-
!
|
|
108
|
+
!wireServicesFactory) {
|
|
109
109
|
throw new Error('Required types not found');
|
|
110
110
|
}
|
|
111
|
-
const bootstrapCode = serializeLocalCLIBootstrap(programName, programMeta, bootstrapFile, config, pikkuConfigFactory, singletonServicesFactory,
|
|
111
|
+
const bootstrapCode = serializeLocalCLIBootstrap(programName, programMeta, bootstrapFile, config, pikkuConfigFactory, singletonServicesFactory, wireServicesFactory);
|
|
112
112
|
await writeFileInDir(logger, bootstrapFile, bootstrapCode);
|
|
113
113
|
logger.debug(`Serialized CLI bootstrap for ${programName}: ${bootstrapFile}`);
|
|
114
114
|
}
|
|
@@ -12,7 +12,7 @@ export const pikkuCLITypes = pikkuSessionlessFunc({
|
|
|
12
12
|
// Check for required types
|
|
13
13
|
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
14
14
|
userSessionType: true,
|
|
15
|
-
|
|
15
|
+
wireServiceType: true,
|
|
16
16
|
singletonServicesType: true,
|
|
17
17
|
});
|
|
18
18
|
const { userSessionType, singletonServicesType } = visitState.filesAndMethods;
|