@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
|
@@ -17,12 +17,12 @@ export const serializeTypedChannelsMap = (
|
|
|
17
17
|
)
|
|
18
18
|
typesMap.customTypes.forEach(({ references }) => {
|
|
19
19
|
for (const reference of references) {
|
|
20
|
-
// Skip __object types (placeholder types for invalid/broken functions)
|
|
21
20
|
if (reference !== '__object' && !reference.startsWith('__object_')) {
|
|
22
21
|
requiredTypes.add(reference)
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
})
|
|
25
|
+
|
|
26
26
|
const imports = serializeImportMap(
|
|
27
27
|
relativeToPath,
|
|
28
28
|
packageMappings,
|
|
@@ -30,10 +30,11 @@ export const serializeTypedChannelsMap = (
|
|
|
30
30
|
requiredTypes
|
|
31
31
|
)
|
|
32
32
|
const serializedCustomTypes = generateCustomTypes(typesMap, requiredTypes)
|
|
33
|
+
|
|
33
34
|
return `/**
|
|
34
35
|
* This provides the structure needed for TypeScript to be aware of channels
|
|
35
36
|
*/
|
|
36
|
-
|
|
37
|
+
|
|
37
38
|
${imports}
|
|
38
39
|
${serializedCustomTypes}
|
|
39
40
|
|
|
@@ -173,19 +173,19 @@ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
|
|
|
173
173
|
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
174
174
|
config: true,
|
|
175
175
|
singletonServicesFactory: true,
|
|
176
|
-
|
|
176
|
+
wireServicesFactory: true,
|
|
177
177
|
})
|
|
178
178
|
|
|
179
179
|
const {
|
|
180
180
|
pikkuConfigFactory,
|
|
181
181
|
singletonServicesFactory,
|
|
182
|
-
|
|
182
|
+
wireServicesFactory,
|
|
183
183
|
} = visitState.filesAndMethods
|
|
184
184
|
|
|
185
185
|
if (
|
|
186
186
|
!pikkuConfigFactory ||
|
|
187
187
|
!singletonServicesFactory ||
|
|
188
|
-
!
|
|
188
|
+
!wireServicesFactory
|
|
189
189
|
) {
|
|
190
190
|
throw new Error('Required types not found')
|
|
191
191
|
}
|
|
@@ -197,7 +197,7 @@ export const pikkuCLIEntry: any = pikkuSessionlessFunc<void, void>({
|
|
|
197
197
|
config,
|
|
198
198
|
pikkuConfigFactory,
|
|
199
199
|
singletonServicesFactory,
|
|
200
|
-
|
|
200
|
+
wireServicesFactory
|
|
201
201
|
)
|
|
202
202
|
|
|
203
203
|
await writeFileInDir(logger, bootstrapFile, bootstrapCode)
|
|
@@ -19,7 +19,7 @@ export const pikkuCLITypes: any = pikkuSessionlessFunc<void, void>({
|
|
|
19
19
|
// Check for required types
|
|
20
20
|
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
21
21
|
userSessionType: true,
|
|
22
|
-
|
|
22
|
+
wireServiceType: true,
|
|
23
23
|
singletonServicesType: true,
|
|
24
24
|
})
|
|
25
25
|
|
|
@@ -2,11 +2,22 @@ import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
|
2
2
|
import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
|
|
3
3
|
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
4
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
6
|
+
import {
|
|
7
|
+
stripVerboseFields,
|
|
8
|
+
hasVerboseFields,
|
|
9
|
+
} from '../../../utils/strip-verbose-meta.js'
|
|
5
10
|
|
|
6
11
|
export const pikkuCLI: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
7
12
|
func: async ({ logger, config, getInspectorState }) => {
|
|
8
13
|
const visitState = await getInspectorState()
|
|
9
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
cliWiringsFile,
|
|
16
|
+
cliWiringMetaFile,
|
|
17
|
+
cliWiringMetaJsonFile,
|
|
18
|
+
packageMappings,
|
|
19
|
+
schema,
|
|
20
|
+
} = config
|
|
10
21
|
const { cli } = visitState
|
|
11
22
|
|
|
12
23
|
// Generate CLI wirings file
|
|
@@ -21,11 +32,42 @@ export const pikkuCLI: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
|
21
32
|
)
|
|
22
33
|
)
|
|
23
34
|
|
|
24
|
-
//
|
|
35
|
+
// Write minimal JSON (runtime-only fields)
|
|
36
|
+
const minimalMeta = stripVerboseFields(cli.meta)
|
|
37
|
+
await writeFileInDir(
|
|
38
|
+
logger,
|
|
39
|
+
cliWiringMetaJsonFile,
|
|
40
|
+
JSON.stringify(minimalMeta, null, 2)
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
// Write verbose JSON only if it has additional fields
|
|
44
|
+
if (hasVerboseFields(cli.meta)) {
|
|
45
|
+
const verbosePath = cliWiringMetaJsonFile.replace(
|
|
46
|
+
/\.gen\.json$/,
|
|
47
|
+
'-verbose.gen.json'
|
|
48
|
+
)
|
|
49
|
+
await writeFileInDir(
|
|
50
|
+
logger,
|
|
51
|
+
verbosePath,
|
|
52
|
+
JSON.stringify(cli.meta, null, 2)
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
57
|
+
cliWiringMetaFile,
|
|
58
|
+
cliWiringMetaJsonFile,
|
|
59
|
+
packageMappings
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false
|
|
63
|
+
const importStatement = supportsImportAttributes
|
|
64
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
65
|
+
: `import metaData from '${jsonImportPath}'`
|
|
66
|
+
|
|
25
67
|
await writeFileInDir(
|
|
26
68
|
logger,
|
|
27
69
|
cliWiringMetaFile,
|
|
28
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('cli', 'meta',
|
|
70
|
+
`import { pikkuState } from '@pikku/core'\nimport { CLIMeta } from '@pikku/core/cli'\n${importStatement}\npikkuState(null, 'cli', 'meta', metaData as CLIMeta)`
|
|
29
71
|
)
|
|
30
72
|
|
|
31
73
|
return true
|
|
@@ -89,7 +89,7 @@ import { pikkuMiddleware } from '${functionTypesPath}'
|
|
|
89
89
|
${imports}
|
|
90
90
|
|
|
91
91
|
// Middleware to close the channel after CLI command completes
|
|
92
|
-
const cliCloseOnComplete = pikkuMiddleware(async (
|
|
92
|
+
const cliCloseOnComplete = pikkuMiddleware(async (_services, { channel }, next) => {
|
|
93
93
|
const closeChannel = () => {
|
|
94
94
|
setTimeout(async () => {
|
|
95
95
|
try {
|
|
@@ -56,7 +56,7 @@ export const pikkuCLIRender = <Data, RequiredServices extends SingletonServices
|
|
|
56
56
|
* CLI command configuration with project-specific types.
|
|
57
57
|
* Uses CoreCLICommandConfig from @pikku/core with local middleware and render types.
|
|
58
58
|
*/
|
|
59
|
-
type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
|
|
59
|
+
type CLICommandConfig<Func extends PikkuFunctionConfig<In, Out, 'cli' | 'rpc' | 'session'>, In = any, Out = any, Params extends string = string> = CoreCLICommandConfig<Func, PikkuMiddleware, PikkuCLIRender<any>, Params>
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Type definition for CLI applications with commands and global options.
|
|
@@ -90,7 +90,7 @@ export const wireCLI = <Commands extends Record<string, CoreCLICommandConfig<any
|
|
|
90
90
|
* @returns CLI command configuration with inferred types
|
|
91
91
|
*/
|
|
92
92
|
export const pikkuCLICommand = <
|
|
93
|
-
FuncConfig extends PikkuFunctionConfig<any, any>,
|
|
93
|
+
FuncConfig extends PikkuFunctionConfig<any, any, 'cli' | 'rpc' | 'session'>,
|
|
94
94
|
Params extends string
|
|
95
95
|
>(
|
|
96
96
|
config: CLICommandConfig<FuncConfig, any, any, Params>
|
|
@@ -11,7 +11,7 @@ export function serializeLocalCLIBootstrap(
|
|
|
11
11
|
config: Config,
|
|
12
12
|
pikkuConfigFactory: { file: string; variable: string },
|
|
13
13
|
singletonServicesFactory: { file: string; variable: string },
|
|
14
|
-
|
|
14
|
+
wireServicesFactory: { file: string; variable: string }
|
|
15
15
|
): string {
|
|
16
16
|
const capitalizedName =
|
|
17
17
|
programName.charAt(0).toUpperCase() + programName.slice(1).replace(/-/g, '')
|
|
@@ -27,9 +27,9 @@ export function serializeLocalCLIBootstrap(
|
|
|
27
27
|
singletonServicesFactory.file,
|
|
28
28
|
config.packageMappings
|
|
29
29
|
)
|
|
30
|
-
const
|
|
30
|
+
const wireServicesPath = getFileImportRelativePath(
|
|
31
31
|
bootstrapFile,
|
|
32
|
-
|
|
32
|
+
wireServicesFactory.file,
|
|
33
33
|
config.packageMappings
|
|
34
34
|
)
|
|
35
35
|
const cliBootstrapPath = getFileImportRelativePath(
|
|
@@ -42,7 +42,7 @@ export function serializeLocalCLIBootstrap(
|
|
|
42
42
|
import { executeCLI, CLIError } from '@pikku/core/cli'
|
|
43
43
|
import { ${pikkuConfigFactory.variable} as createConfig } from '${pikkuConfigPath}'
|
|
44
44
|
import { ${singletonServicesFactory.variable} as createSingletonServices } from '${singletonServicesPath}'
|
|
45
|
-
import { ${
|
|
45
|
+
import { ${wireServicesFactory.variable} as createWireServices } from '${wireServicesPath}'
|
|
46
46
|
import '${cliBootstrapPath}'
|
|
47
47
|
|
|
48
48
|
/**
|
|
@@ -56,7 +56,7 @@ export async function ${capitalizedName}CLI(args: string[]): Promise<void> {
|
|
|
56
56
|
args: args || process.argv.slice(2),
|
|
57
57
|
createConfig,
|
|
58
58
|
createSingletonServices,
|
|
59
|
-
|
|
59
|
+
createWireServices,
|
|
60
60
|
})
|
|
61
61
|
} catch (error) {
|
|
62
62
|
if (error instanceof CLIError) {
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { ErrorCode } from '@pikku/inspector'
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { readFile } from 'fs/promises'
|
|
6
|
+
import { join, isAbsolute } from 'path'
|
|
7
|
+
import {
|
|
8
|
+
stripVerboseFields,
|
|
9
|
+
hasVerboseFields,
|
|
10
|
+
} from '../../../utils/strip-verbose-meta.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Load and sanitize an SVG icon file.
|
|
14
|
+
* Returns the SVG content as a string, or undefined if not found.
|
|
15
|
+
*/
|
|
16
|
+
const loadIcon = async (
|
|
17
|
+
iconPath: string | undefined,
|
|
18
|
+
rootDir: string,
|
|
19
|
+
logger: any
|
|
20
|
+
): Promise<string | undefined> => {
|
|
21
|
+
if (!iconPath) return undefined
|
|
22
|
+
|
|
23
|
+
// Resolve the full path to the icon
|
|
24
|
+
const fullPath = isAbsolute(iconPath) ? iconPath : join(rootDir, iconPath)
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const content = await readFile(fullPath, 'utf-8')
|
|
28
|
+
|
|
29
|
+
// Basic SVG validation - must start with <svg
|
|
30
|
+
const trimmed = content.trim()
|
|
31
|
+
if (!trimmed.startsWith('<svg') && !trimmed.startsWith('<?xml')) {
|
|
32
|
+
logger.warn(`Icon file is not a valid SVG: ${fullPath}`)
|
|
33
|
+
return undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Return the sanitized SVG (remove XML declaration if present)
|
|
37
|
+
return trimmed.replace(/<\?xml[^?]*\?>\s*/g, '').trim()
|
|
38
|
+
} catch (e) {
|
|
39
|
+
logger.warn(`Could not load icon: ${fullPath}`)
|
|
40
|
+
return undefined
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const pikkuForgeNodes: any = pikkuSessionlessFunc<
|
|
45
|
+
void,
|
|
46
|
+
boolean | undefined
|
|
47
|
+
>({
|
|
48
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
49
|
+
const { forgeNodes, forgeCredentials } = await getInspectorState()
|
|
50
|
+
const { forgeNodesMetaJsonFile, forge, rootDir } = config
|
|
51
|
+
|
|
52
|
+
const hasNodes = Object.keys(forgeNodes.meta).length > 0
|
|
53
|
+
const hasCredentials = Object.keys(forgeCredentials.meta).length > 0
|
|
54
|
+
|
|
55
|
+
// Only generate if there are forge nodes or credentials
|
|
56
|
+
if (!hasNodes && !hasCredentials) {
|
|
57
|
+
return undefined
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Validate categories if configured
|
|
61
|
+
const allowedCategories = forge?.node?.categories
|
|
62
|
+
if (allowedCategories && allowedCategories.length > 0) {
|
|
63
|
+
for (const [name, meta] of Object.entries(forgeNodes.meta) as [
|
|
64
|
+
string,
|
|
65
|
+
any,
|
|
66
|
+
][]) {
|
|
67
|
+
if (!allowedCategories.includes(meta.category)) {
|
|
68
|
+
logger.critical(
|
|
69
|
+
ErrorCode.INVALID_VALUE,
|
|
70
|
+
`Forge node '${name}' has invalid category '${meta.category}'. ` +
|
|
71
|
+
`Allowed categories: ${allowedCategories.join(', ')}`
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Build the output metadata - remove per-node icon field
|
|
78
|
+
const outputMeta: Record<string, any> = {}
|
|
79
|
+
for (const [name, meta] of Object.entries(forgeNodes.meta) as [
|
|
80
|
+
string,
|
|
81
|
+
any,
|
|
82
|
+
][]) {
|
|
83
|
+
// Remove icon from node meta - only package-level icon is used
|
|
84
|
+
const { icon: _icon, ...nodeMetaWithoutIcon } = meta
|
|
85
|
+
outputMeta[name] = nodeMetaWithoutIcon
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Load package-level icon
|
|
89
|
+
const packageIcon = await loadIcon(forge?.node?.icon, rootDir, logger)
|
|
90
|
+
|
|
91
|
+
const metaData = {
|
|
92
|
+
nodes: outputMeta,
|
|
93
|
+
credentials: forgeCredentials.meta,
|
|
94
|
+
package: {
|
|
95
|
+
displayName: forge?.node?.displayName,
|
|
96
|
+
description: forge?.node?.description,
|
|
97
|
+
icon: packageIcon,
|
|
98
|
+
categories: forge?.node?.categories,
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (forgeNodesMetaJsonFile) {
|
|
103
|
+
// Write minimal JSON (runtime-only fields)
|
|
104
|
+
const minimalMeta = stripVerboseFields(metaData)
|
|
105
|
+
await writeFileInDir(
|
|
106
|
+
logger,
|
|
107
|
+
forgeNodesMetaJsonFile,
|
|
108
|
+
JSON.stringify(minimalMeta, null, 2),
|
|
109
|
+
{ ignoreModifyComment: true }
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
// Write verbose JSON only if it has additional fields
|
|
113
|
+
if (hasVerboseFields(metaData)) {
|
|
114
|
+
const verbosePath = forgeNodesMetaJsonFile.replace(
|
|
115
|
+
/\.gen\.json$/,
|
|
116
|
+
'-verbose.gen.json'
|
|
117
|
+
)
|
|
118
|
+
await writeFileInDir(
|
|
119
|
+
logger,
|
|
120
|
+
verbosePath,
|
|
121
|
+
JSON.stringify(metaData, null, 2),
|
|
122
|
+
{ ignoreModifyComment: true }
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return true
|
|
128
|
+
},
|
|
129
|
+
middleware: [
|
|
130
|
+
logCommandInfoAndTime({
|
|
131
|
+
commandStart: 'Generating Forge nodes metadata',
|
|
132
|
+
commandEnd: 'Generated Forge nodes metadata',
|
|
133
|
+
}),
|
|
134
|
+
],
|
|
135
|
+
})
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { serializeForgeTypes } from './serialize-forge-types.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuForgeTypes: any = pikkuSessionlessFunc<void, void>({
|
|
8
|
+
func: async ({ logger, config }) => {
|
|
9
|
+
const {
|
|
10
|
+
forgeTypesFile,
|
|
11
|
+
rpcInternalMapDeclarationFile,
|
|
12
|
+
packageMappings,
|
|
13
|
+
forge,
|
|
14
|
+
} = config
|
|
15
|
+
|
|
16
|
+
// Get the import path for the RPC map declaration file
|
|
17
|
+
// The declaration file ends in .d.ts, but we need to import from .js
|
|
18
|
+
// getFileImportRelativePath converts .ts -> .js, so .d.ts -> .d.js
|
|
19
|
+
// We need to remove the extra .d extension
|
|
20
|
+
let rpcMapImportPath = getFileImportRelativePath(
|
|
21
|
+
forgeTypesFile,
|
|
22
|
+
rpcInternalMapDeclarationFile,
|
|
23
|
+
packageMappings
|
|
24
|
+
)
|
|
25
|
+
// Fix: .d.ts files should be imported as .js (TypeScript resolves types from .d.ts)
|
|
26
|
+
rpcMapImportPath = rpcMapImportPath.replace('.d.js', '.js')
|
|
27
|
+
|
|
28
|
+
const categories = forge?.node?.categories
|
|
29
|
+
const content = serializeForgeTypes(rpcMapImportPath, categories)
|
|
30
|
+
await writeFileInDir(logger, forgeTypesFile, content)
|
|
31
|
+
},
|
|
32
|
+
middleware: [
|
|
33
|
+
logCommandInfoAndTime({
|
|
34
|
+
commandStart: 'Creating Forge types',
|
|
35
|
+
commandEnd: 'Created Forge types',
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates type definitions for Forge wirings with typed category and RPC validation
|
|
3
|
+
*/
|
|
4
|
+
export const serializeForgeTypes = (
|
|
5
|
+
rpcMapImportPath: string,
|
|
6
|
+
categories: string[] | undefined
|
|
7
|
+
) => {
|
|
8
|
+
// Generate category union type - 'never' if no categories configured
|
|
9
|
+
const categoryType = categories?.length
|
|
10
|
+
? categories.map((c) => `'${c}'`).join(' | ')
|
|
11
|
+
: 'never'
|
|
12
|
+
|
|
13
|
+
return `/**
|
|
14
|
+
* Forge-specific type definitions for typed wireForgeNode and wireForgeCredential
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { wireForgeNode as wireForgeNodeCore, wireForgeCredential as wireForgeCredentialCore } from '@pikku/core/forge-node'
|
|
18
|
+
import type { CoreForgeNode, CoreForgeCredential } from '@pikku/core/forge-node'
|
|
19
|
+
import type { FlattenedRPCMap } from '${rpcMapImportPath}'
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Valid category values for forge nodes.
|
|
23
|
+
* ${categories?.length ? `Configured categories: ${categories.join(', ')}` : 'No categories configured - wireForgeNode cannot be used until forge.node.categories is defined in pikku.config.json.'}
|
|
24
|
+
*/
|
|
25
|
+
export type ForgeCategory = ${categoryType}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Valid RPC names that can be used with forge nodes.
|
|
29
|
+
* These are derived from the FlattenedRPCMap which includes both local and external package RPCs.
|
|
30
|
+
*/
|
|
31
|
+
export type ForgeRPCName = keyof FlattenedRPCMap
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Typed forge node configuration.
|
|
35
|
+
* Validates that category and rpc are valid values.
|
|
36
|
+
*/
|
|
37
|
+
export type TypedForgeNode = Omit<CoreForgeNode, 'category' | 'rpc'> & {
|
|
38
|
+
/** Grouping category (validated against forge.node.categories in config) */
|
|
39
|
+
category: ForgeCategory
|
|
40
|
+
/** RPC name to call when node executes (must be a valid RPC name) */
|
|
41
|
+
rpc: ForgeRPCName
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Registers a Forge node with validated category and RPC.
|
|
46
|
+
*
|
|
47
|
+
* @param config - Forge node configuration with typed category and rpc
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* \`\`\`typescript
|
|
51
|
+
* wireForgeNode({
|
|
52
|
+
* name: 'send-email',
|
|
53
|
+
* displayName: 'Send Email',
|
|
54
|
+
* category: 'Communication', // Must be in forge.node.categories
|
|
55
|
+
* type: 'action',
|
|
56
|
+
* rpc: 'sendEmail', // Must be a valid RPC name
|
|
57
|
+
* description: 'Sends an email to a recipient'
|
|
58
|
+
* })
|
|
59
|
+
* \`\`\`
|
|
60
|
+
*/
|
|
61
|
+
export const wireForgeNode = (config: TypedForgeNode): void => {
|
|
62
|
+
wireForgeNodeCore(config as CoreForgeNode)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Registers a Forge credential definition.
|
|
67
|
+
* Credentials define secrets/API keys required by the package.
|
|
68
|
+
*
|
|
69
|
+
* @template T - Zod schema type for the credential structure
|
|
70
|
+
* @param config - Forge credential configuration
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* \`\`\`typescript
|
|
74
|
+
* import { z } from 'zod'
|
|
75
|
+
*
|
|
76
|
+
* const apiCredentials = z.object({
|
|
77
|
+
* apiKey: z.string().describe('API key for authentication'),
|
|
78
|
+
* apiSecret: z.string().describe('API secret')
|
|
79
|
+
* })
|
|
80
|
+
*
|
|
81
|
+
* wireForgeCredential({
|
|
82
|
+
* name: 'example-api',
|
|
83
|
+
* displayName: 'Example API Credentials',
|
|
84
|
+
* description: 'Credentials for the example external API',
|
|
85
|
+
* secretId: 'EXAMPLE_API_CREDENTIALS',
|
|
86
|
+
* schema: apiCredentials
|
|
87
|
+
* })
|
|
88
|
+
* \`\`\`
|
|
89
|
+
*/
|
|
90
|
+
export const wireForgeCredential = <T>(config: CoreForgeCredential<T>): void => {
|
|
91
|
+
wireForgeCredentialCore(config)
|
|
92
|
+
}
|
|
93
|
+
`
|
|
94
|
+
}
|
|
@@ -18,18 +18,18 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
|
|
|
18
18
|
// Check for required types
|
|
19
19
|
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
20
20
|
userSessionType: true,
|
|
21
|
-
|
|
21
|
+
wireServiceType: true,
|
|
22
22
|
singletonServicesType: true,
|
|
23
23
|
})
|
|
24
24
|
|
|
25
25
|
const {
|
|
26
26
|
userSessionType,
|
|
27
|
-
|
|
27
|
+
wireServicesType,
|
|
28
28
|
singletonServicesType,
|
|
29
29
|
pikkuConfigType,
|
|
30
30
|
} = visitState.filesAndMethods
|
|
31
31
|
|
|
32
|
-
if (!userSessionType || !
|
|
32
|
+
if (!userSessionType || !wireServicesType || !singletonServicesType) {
|
|
33
33
|
throw new Error('Required types not found')
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -42,11 +42,12 @@ export const pikkuFunctionTypesSplit: any = pikkuSessionlessFunc<void, void>({
|
|
|
42
42
|
userSessionType.type,
|
|
43
43
|
`import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, singletonServicesType.typePath, packageMappings)}'`,
|
|
44
44
|
singletonServicesType.type,
|
|
45
|
-
`import type { ${
|
|
46
|
-
|
|
47
|
-
`import type { TypedPikkuRPC } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`,
|
|
48
|
-
`import type { RequiredSingletonServices,
|
|
49
|
-
configTypeImport
|
|
45
|
+
`import type { ${wireServicesType.type} } from '${getFileImportRelativePath(functionTypesFile, wireServicesType.typePath, packageMappings)}'`,
|
|
46
|
+
wireServicesType.type,
|
|
47
|
+
`import type { TypedPikkuRPC, FlattenedRPCMap } from '${getFileImportRelativePath(functionTypesFile, rpcInternalMapDeclarationFile, packageMappings)}'`,
|
|
48
|
+
`import type { RequiredSingletonServices, RequiredWireServices } from '${getFileImportRelativePath(functionTypesFile, servicesFile, packageMappings)}'`,
|
|
49
|
+
configTypeImport,
|
|
50
|
+
config.externalPackageName
|
|
50
51
|
)
|
|
51
52
|
|
|
52
53
|
await writeFileInDir(logger, functionTypesFile, content)
|
|
@@ -16,20 +16,27 @@ export const pikkuFunctionTypes: any = pikkuSessionlessFunc<void, void>({
|
|
|
16
16
|
queueTypesFile,
|
|
17
17
|
mcpTypesFile,
|
|
18
18
|
cliTypesFile,
|
|
19
|
+
forgeTypesFile,
|
|
19
20
|
} = config
|
|
20
21
|
|
|
22
|
+
const getImportPath = (file: string) =>
|
|
23
|
+
config.externalPackage
|
|
24
|
+
? null
|
|
25
|
+
: getFileImportRelativePath(typesFile, file, packageMappings)
|
|
26
|
+
|
|
27
|
+
// Forge types are included for external packages (they need wireForgeNode/wireForgeCredential)
|
|
28
|
+
const getForgeImportPath = (file: string) =>
|
|
29
|
+
getFileImportRelativePath(typesFile, file, packageMappings)
|
|
30
|
+
|
|
21
31
|
const content = serializePikkuTypesHub(
|
|
22
32
|
getFileImportRelativePath(typesFile, functionTypesFile, packageMappings),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
getFileImportRelativePath(typesFile, queueTypesFile, packageMappings),
|
|
31
|
-
getFileImportRelativePath(typesFile, mcpTypesFile, packageMappings),
|
|
32
|
-
getFileImportRelativePath(typesFile, cliTypesFile, packageMappings)
|
|
33
|
+
getImportPath(httpTypesFile),
|
|
34
|
+
getImportPath(channelsTypesFile),
|
|
35
|
+
getImportPath(schedulersTypesFile),
|
|
36
|
+
getImportPath(queueTypesFile),
|
|
37
|
+
getImportPath(mcpTypesFile),
|
|
38
|
+
getImportPath(cliTypesFile),
|
|
39
|
+
getForgeImportPath(forgeTypesFile)
|
|
33
40
|
)
|
|
34
41
|
|
|
35
42
|
await writeFileInDir(logger, typesFile, content)
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
2
|
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
3
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
import { serializeFunctionImports } from './serialize-function-imports.js'
|
|
5
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
4
6
|
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
7
|
+
stripVerboseFields,
|
|
8
|
+
hasVerboseFields,
|
|
9
|
+
} from '../../../utils/strip-verbose-meta.js'
|
|
8
10
|
|
|
9
11
|
export const pikkuFunctions: any = pikkuSessionlessFunc<
|
|
10
12
|
void,
|
|
@@ -14,41 +16,84 @@ export const pikkuFunctions: any = pikkuSessionlessFunc<
|
|
|
14
16
|
const { functions, rpc } = await getInspectorState()
|
|
15
17
|
const {
|
|
16
18
|
functionsMetaFile,
|
|
17
|
-
|
|
19
|
+
functionsMetaJsonFile,
|
|
18
20
|
functionsFile,
|
|
19
21
|
packageMappings,
|
|
22
|
+
schema,
|
|
20
23
|
} = config
|
|
21
24
|
|
|
22
|
-
//
|
|
25
|
+
// Write minimal JSON (runtime-only fields)
|
|
26
|
+
const minimalMeta = stripVerboseFields(functions.meta)
|
|
23
27
|
await writeFileInDir(
|
|
24
28
|
logger,
|
|
29
|
+
functionsMetaJsonFile,
|
|
30
|
+
JSON.stringify(minimalMeta, null, 2)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// Write verbose JSON only if it has additional fields
|
|
34
|
+
if (hasVerboseFields(functions.meta)) {
|
|
35
|
+
const verbosePath = functionsMetaJsonFile.replace(
|
|
36
|
+
/\.gen\.json$/,
|
|
37
|
+
'-verbose.gen.json'
|
|
38
|
+
)
|
|
39
|
+
await writeFileInDir(
|
|
40
|
+
logger,
|
|
41
|
+
verbosePath,
|
|
42
|
+
JSON.stringify(functions.meta, null, 2)
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const jsonImportPath = getFileImportRelativePath(
|
|
25
47
|
functionsMetaFile,
|
|
26
|
-
|
|
48
|
+
functionsMetaJsonFile,
|
|
49
|
+
packageMappings
|
|
27
50
|
)
|
|
28
51
|
|
|
29
|
-
|
|
30
|
-
const
|
|
52
|
+
const supportsImportAttributes = schema?.supportsImportAttributes ?? false
|
|
53
|
+
const importStatement = supportsImportAttributes
|
|
54
|
+
? `import metaData from '${jsonImportPath}' with { type: 'json' }`
|
|
55
|
+
: `import metaData from '${jsonImportPath}'`
|
|
56
|
+
|
|
57
|
+
const packageName = config.externalPackageName
|
|
58
|
+
? `'${config.externalPackageName}'`
|
|
59
|
+
: 'null'
|
|
60
|
+
|
|
31
61
|
await writeFileInDir(
|
|
32
62
|
logger,
|
|
33
|
-
|
|
34
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('function', 'meta',
|
|
63
|
+
functionsMetaFile,
|
|
64
|
+
`import { pikkuState, FunctionsMeta } from '@pikku/core'\n${importStatement}\npikkuState(${packageName}, 'function', 'meta', metaData as FunctionsMeta)`
|
|
35
65
|
)
|
|
36
66
|
|
|
67
|
+
// For external packages, register ALL functions (they'll be invoked by consumers)
|
|
68
|
+
// For main packages, only register functions that are invoked via internal RPCs
|
|
69
|
+
const isExternalPackage = !!config.externalPackageName
|
|
37
70
|
const hasRPCs = rpc.exposedFiles.size > 0 || rpc.internalFiles.size > 0
|
|
38
|
-
|
|
71
|
+
const hasFunctions = functions.files.size > 0
|
|
72
|
+
|
|
73
|
+
const shouldGenerateFunctionsFile = isExternalPackage
|
|
74
|
+
? hasFunctions
|
|
75
|
+
: hasRPCs
|
|
76
|
+
|
|
77
|
+
if (shouldGenerateFunctionsFile) {
|
|
78
|
+
// For external packages, use all function files; for main packages, use internal RPC files
|
|
79
|
+
const filesToRegister = isExternalPackage
|
|
80
|
+
? functions.files
|
|
81
|
+
: rpc.internalFiles
|
|
82
|
+
|
|
39
83
|
await writeFileInDir(
|
|
40
84
|
logger,
|
|
41
85
|
functionsFile,
|
|
42
86
|
serializeFunctionImports(
|
|
43
87
|
functionsFile,
|
|
44
|
-
|
|
88
|
+
filesToRegister,
|
|
45
89
|
functions.meta,
|
|
46
|
-
packageMappings
|
|
90
|
+
packageMappings,
|
|
91
|
+
config.externalPackageName
|
|
47
92
|
)
|
|
48
93
|
)
|
|
49
94
|
}
|
|
50
95
|
|
|
51
|
-
return
|
|
96
|
+
return shouldGenerateFunctionsFile
|
|
52
97
|
},
|
|
53
98
|
middleware: [
|
|
54
99
|
logCommandInfoAndTime({
|