@pikku/cli 0.9.15 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pikku/channel/pikku-channel-types.gen.ts +91 -0
- package/.pikku/channel/pikku-channels-map.gen.d.ts +44 -0
- package/.pikku/channel/pikku-channels-meta.gen.ts +5 -0
- package/.pikku/channel/pikku-channels.gen.ts +4 -0
- package/.pikku/cli/pikku-cli-channel.gen.ts +34 -0
- package/.pikku/cli/pikku-cli-client.gen.ts +43 -0
- package/.pikku/cli/pikku-cli-types.gen.ts +70 -0
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +145 -0
- package/.pikku/cli/pikku-cli-wirings.gen.ts +6 -0
- package/.pikku/cli/pikku-cli.gen.ts +41 -0
- package/.pikku/function/pikku-function-types.gen.ts +440 -0
- package/.pikku/function/pikku-functions-meta.gen.ts +845 -0
- package/.pikku/function/pikku-functions-meta.min.gen.ts +181 -0
- package/.pikku/function/pikku-functions.gen.ts +76 -0
- package/.pikku/http/pikku-http-types.gen.ts +86 -0
- package/.pikku/http/pikku-http-wirings-map.gen.d.ts +43 -0
- package/.pikku/http/pikku-http-wirings-meta.gen.ts +13 -0
- package/.pikku/http/pikku-http-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +140 -0
- package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +7 -0
- package/.pikku/mcp/pikku-mcp-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp.gen.json +5 -0
- package/.pikku/pikku-bootstrap.gen.ts +19 -0
- package/.pikku/pikku-services.gen.ts +20 -0
- package/.pikku/pikku-types.gen.ts +27 -0
- package/.pikku/pikku-websocket.gen.ts +76 -0
- package/.pikku/queue/pikku-queue-types.gen.ts +27 -0
- package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +57 -0
- package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +5 -0
- package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +4 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +47 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +82 -0
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +41 -0
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
- package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +5 -0
- package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +4 -0
- package/.pikku/schemas/register.gen.ts +51 -0
- package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
- package/CHANGELOG.md +15 -0
- package/bin/pikku.ts +97 -14
- package/build.sh +53 -0
- package/cli.schema.json +1 -382
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +56 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js +52 -0
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +5 -0
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +4 -0
- package/dist/.pikku/channel/pikku-channels.gen.js +5 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.d.ts +1 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.js +33 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.js +34 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +52 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.js +31 -0
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +145 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +5 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +6 -0
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli.gen.js +38 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +380 -0
- package/dist/.pikku/function/pikku-function-types.gen.js +271 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.js +845 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +181 -0
- package/dist/.pikku/function/pikku-functions.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions.gen.js +75 -0
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +68 -0
- package/dist/.pikku/http/pikku-http-types.gen.js +62 -0
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +13 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +4 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.js +5 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +91 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +71 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +7 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +4 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +5 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +19 -0
- package/dist/.pikku/pikku-bootstrap.gen.js +19 -0
- package/dist/.pikku/pikku-services.gen.d.ts +13 -0
- package/dist/.pikku/pikku-services.gen.js +5 -0
- package/dist/.pikku/pikku-types.gen.d.ts +13 -0
- package/dist/.pikku/pikku-types.gen.js +20 -0
- package/dist/.pikku/pikku-websocket.gen.d.ts +31 -0
- package/dist/.pikku/pikku-websocket.gen.js +49 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +23 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js +16 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +5 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +1 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +41 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +21 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +16 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +5 -0
- package/dist/.pikku/schemas/register.gen.d.ts +1 -0
- package/dist/.pikku/schemas/register.gen.js +28 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
- package/dist/bin/pikku.js +63 -14
- package/dist/src/cli.wiring.d.ts +1 -0
- package/dist/src/cli.wiring.js +99 -0
- package/dist/src/functions/commands/all.d.ts +1 -0
- package/dist/src/functions/commands/all.js +114 -0
- package/dist/src/functions/commands/watch.d.ts +1 -0
- package/dist/src/functions/commands/watch.js +47 -0
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.d.ts +1 -0
- package/dist/src/{runtimes → functions/runtimes}/nextjs/pikku-command-nextjs.js +33 -12
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -0
- package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.js +2 -2
- package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-channels.js +19 -0
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +19 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +18 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +20 -0
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.js +27 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.d.ts +4 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +94 -0
- package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.js +6 -3
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +123 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +31 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +22 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +11 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +131 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +9 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +67 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.d.ts +4 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.js +73 -0
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +14 -0
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +51 -0
- package/dist/src/functions/wirings/fetch/index.d.ts +1 -0
- package/dist/src/functions/wirings/fetch/index.js +27 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +33 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +18 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +26 -0
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +2 -0
- package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.js +36 -29
- package/dist/src/functions/wirings/functions/pikku-function-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-function-types.js +18 -0
- package/dist/src/functions/wirings/functions/schemas.d.ts +4 -0
- package/dist/src/functions/wirings/functions/schemas.js +20 -0
- package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.js +4 -21
- package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +4 -0
- package/dist/src/functions/wirings/functions/serialize-function-types.js +443 -0
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +4 -0
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +30 -0
- package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.d.ts +4 -2
- package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.js +2 -2
- package/dist/src/functions/wirings/http/pikku-command-http-map.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-map.js +18 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +20 -0
- package/dist/src/functions/wirings/http/pikku-command-http-types.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-types.js +19 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +37 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.js +20 -0
- package/dist/src/functions/wirings/http/serialize-http-types.d.ts +4 -0
- package/dist/src/functions/wirings/http/serialize-http-types.js +89 -0
- package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.js +2 -2
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.d.ts +1 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +23 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.d.ts +1 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.js +19 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.d.ts +1 -0
- package/dist/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.js +17 -5
- package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.d.ts +2 -2
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.d.ts +4 -0
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +143 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +36 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.d.ts +8 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +44 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-imports.d.ts +2 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +43 -0
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -0
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +28 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.d.ts +2 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.js +43 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +18 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +27 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.js +19 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +21 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.js +18 -0
- package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue.js +21 -0
- package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.js +2 -2
- package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.d.ts +1 -1
- package/dist/src/functions/wirings/queue/serialize-queue-types.d.ts +4 -0
- package/dist/src/functions/wirings/queue/serialize-queue-types.js +30 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.d.ts +1 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +27 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.d.ts +2 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +32 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +1 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +20 -0
- package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.js +2 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.d.ts +1 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.js +19 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +21 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.d.ts +4 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +28 -0
- package/dist/src/middleware/log-command-info-and-time.d.ts +13 -0
- package/dist/src/middleware/log-command-info-and-time.js +15 -0
- package/dist/src/services/cli-logger-forwarder.service.d.ts +30 -0
- package/dist/src/services/cli-logger-forwarder.service.js +64 -0
- package/dist/src/services/cli-logger.service.d.ts +23 -0
- package/dist/src/services/cli-logger.service.js +77 -0
- package/dist/src/services.d.ts +20 -0
- package/dist/src/services.js +162 -0
- package/dist/src/utils/check-required-types.d.ts +10 -0
- package/dist/src/utils/check-required-types.js +31 -0
- package/dist/src/utils/custom-types-generator.d.ts +2 -0
- package/dist/src/utils/custom-types-generator.js +43 -0
- package/dist/src/utils/file-import-path.d.ts +1 -0
- package/dist/src/utils/file-import-path.js +43 -0
- package/dist/src/utils/file-imports-serializer.d.ts +1 -0
- package/dist/src/utils/file-imports-serializer.js +13 -0
- package/dist/src/utils/file-writer.d.ts +9 -0
- package/dist/src/utils/file-writer.js +50 -0
- package/dist/src/utils/generate-bootstrap-file.d.ts +3 -0
- package/dist/src/utils/generate-bootstrap-file.js +21 -0
- package/dist/src/utils/get-cli-version.d.ts +5 -0
- package/dist/src/utils/get-cli-version.js +27 -0
- package/dist/src/utils/pikku-cli-config.d.ts +4 -0
- package/dist/src/utils/pikku-cli-config.js +224 -0
- package/dist/src/utils/pikku-files-and-methods.d.ts +21 -0
- package/dist/src/utils/pikku-files-and-methods.js +70 -0
- package/dist/src/{schema-generator.d.ts → utils/schema-generator.d.ts} +1 -1
- package/dist/src/{schema-generator.js → utils/schema-generator.js} +4 -3
- package/dist/src/{serialize-import-map.js → utils/serialize-import-map.js} +1 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -11
- package/pikku.config.json +26 -0
- package/src/cli.wiring.ts +102 -0
- package/src/functions/commands/all.ts +153 -0
- package/src/functions/commands/watch.ts +58 -0
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +111 -0
- package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.ts +2 -2
- package/src/functions/wirings/channels/pikku-channels.ts +35 -0
- package/src/functions/wirings/channels/pikku-command-channel-types.ts +25 -0
- package/src/functions/wirings/channels/pikku-command-channels-map.ts +26 -0
- package/src/functions/wirings/channels/pikku-command-channels.ts +40 -0
- package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +37 -0
- package/src/functions/wirings/channels/serialize-channel-types.ts +94 -0
- package/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.ts +6 -3
- package/src/functions/wirings/cli/pikku-command-cli-entry.ts +216 -0
- package/src/functions/wirings/cli/pikku-command-cli-types.ts +48 -0
- package/src/functions/wirings/cli/pikku-command-cli.ts +39 -0
- package/src/functions/wirings/cli/serialize-channel-cli-client.ts +171 -0
- package/src/functions/wirings/cli/serialize-channel-cli.ts +102 -0
- package/src/functions/wirings/cli/serialize-cli-types.ts +79 -0
- package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +80 -0
- package/src/functions/wirings/fetch/index.ts +36 -0
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +60 -0
- package/src/functions/wirings/functions/pikku-command-function-types.ts +43 -0
- package/src/functions/wirings/functions/pikku-command-functions.ts +59 -0
- package/src/functions/wirings/functions/pikku-command-services.ts +111 -0
- package/src/functions/wirings/functions/pikku-function-types.ts +43 -0
- package/src/functions/wirings/functions/schemas.ts +45 -0
- package/src/{wirings → functions/wirings}/functions/serialize-function-imports.ts +4 -30
- package/src/functions/wirings/functions/serialize-function-types.ts +453 -0
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +38 -0
- package/src/{wirings → functions/wirings}/http/openapi-spec-generator.ts +5 -2
- package/src/functions/wirings/http/pikku-command-http-map.ts +27 -0
- package/src/functions/wirings/http/pikku-command-http-routes.ts +36 -0
- package/src/functions/wirings/http/pikku-command-http-types.ts +25 -0
- package/src/functions/wirings/http/pikku-command-openapi.ts +62 -0
- package/src/functions/wirings/http/pikku-http-routes.ts +35 -0
- package/src/functions/wirings/http/serialize-http-types.ts +89 -0
- package/src/{wirings → functions/wirings}/http/serialize-typed-http-map.ts +2 -2
- package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +33 -0
- package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +25 -0
- package/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.ts +50 -46
- package/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.ts +2 -2
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +143 -0
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +63 -0
- package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +55 -0
- package/src/functions/wirings/middleware/serialize-middleware-imports.ts +78 -0
- package/src/functions/wirings/permissions/pikku-command-permissions.ts +49 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.test.ts +274 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.ts +78 -0
- package/src/functions/wirings/queue/pikku-command-queue-map.ts +26 -0
- package/src/functions/wirings/queue/pikku-command-queue-service.ts +37 -0
- package/src/functions/wirings/queue/pikku-command-queue-types.ts +25 -0
- package/src/functions/wirings/queue/pikku-command-queue.ts +41 -0
- package/src/functions/wirings/queue/pikku-queue-map.ts +26 -0
- package/src/functions/wirings/queue/pikku-queue.ts +41 -0
- package/src/{wirings → functions/wirings}/queue/serialize-queue-map.ts +2 -2
- package/src/{wirings → functions/wirings}/queue/serialize-queue-meta.ts +1 -1
- package/src/functions/wirings/queue/serialize-queue-types.ts +30 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +35 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +48 -0
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +26 -0
- package/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.ts +2 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +25 -0
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +41 -0
- package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +28 -0
- package/src/middleware/log-command-info-and-time.ts +35 -0
- package/src/services/cli-logger-forwarder.service.ts +90 -0
- package/src/services/cli-logger.service.ts +93 -0
- package/src/services.ts +240 -0
- package/src/utils/check-required-types.ts +53 -0
- package/src/utils/custom-types-generator.ts +55 -0
- package/src/{utils.test.ts → utils/file-import-path.test.ts} +1 -1
- package/src/utils/file-import-path.ts +53 -0
- package/src/utils/file-imports-serializer.ts +25 -0
- package/src/utils/file-writer.ts +72 -0
- package/src/utils/generate-bootstrap-file.ts +43 -0
- package/src/utils/get-cli-version.ts +28 -0
- package/src/utils/pikku-cli-config.ts +327 -0
- package/src/utils/pikku-files-and-methods.ts +148 -0
- package/src/{schema-generator.ts → utils/schema-generator.ts} +10 -4
- package/src/{serialize-import-map.ts → utils/serialize-import-map.ts} +1 -5
- package/tsconfig.json +2 -2
- package/types/application-types.d.ts +23 -0
- package/types/config.d.ts +204 -0
- package/bin/pikku-all.ts +0 -349
- package/bin/pikku-fetch.ts +0 -27
- package/bin/pikku-nextjs.ts +0 -44
- package/bin/pikku-openapi.ts +0 -31
- package/bin/pikku-queue-service.ts +0 -28
- package/bin/pikku-rpc.ts +0 -28
- package/bin/pikku-schemas.ts +0 -31
- package/bin/pikku-websocket.ts +0 -28
- package/dist/bin/pikku-all.d.ts +0 -4
- package/dist/bin/pikku-all.js +0 -194
- package/dist/bin/pikku-fetch.d.ts +0 -4
- package/dist/bin/pikku-fetch.js +0 -19
- package/dist/bin/pikku-nextjs.d.ts +0 -4
- package/dist/bin/pikku-nextjs.js +0 -24
- package/dist/bin/pikku-openapi.d.ts +0 -2
- package/dist/bin/pikku-openapi.js +0 -19
- package/dist/bin/pikku-queue-service.d.ts +0 -4
- package/dist/bin/pikku-queue-service.js +0 -19
- package/dist/bin/pikku-rpc.d.ts +0 -4
- package/dist/bin/pikku-rpc.js +0 -19
- package/dist/bin/pikku-schemas.d.ts +0 -2
- package/dist/bin/pikku-schemas.js +0 -21
- package/dist/bin/pikku-websocket.d.ts +0 -4
- package/dist/bin/pikku-websocket.js +0 -19
- package/dist/src/inspector-glob.d.ts +0 -2
- package/dist/src/inspector-glob.js +0 -12
- package/dist/src/pikku-cli-config.d.ts +0 -56
- package/dist/src/pikku-cli-config.js +0 -203
- package/dist/src/pikku-command-schemas.d.ts +0 -2
- package/dist/src/pikku-command-schemas.js +0 -8
- package/dist/src/runtimes/nextjs/pikku-command-nextjs.d.ts +0 -2
- package/dist/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +0 -1
- package/dist/src/schemas.d.ts +0 -2
- package/dist/src/schemas.js +0 -8
- package/dist/src/serialize-pikku-types.d.ts +0 -4
- package/dist/src/serialize-pikku-types.js +0 -605
- package/dist/src/types.d.ts +0 -5
- package/dist/src/utils.d.ts +0 -60
- package/dist/src/utils.js +0 -248
- package/dist/src/wirings/channels/pikku-channels.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-channels.js +0 -9
- package/dist/src/wirings/channels/pikku-command-channels-map.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-channels-map.js +0 -8
- package/dist/src/wirings/channels/pikku-command-channels.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-channels.js +0 -9
- package/dist/src/wirings/channels/pikku-command-websocket-typed.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-websocket-typed.js +0 -15
- package/dist/src/wirings/fetch/index.d.ts +0 -2
- package/dist/src/wirings/fetch/index.js +0 -12
- package/dist/src/wirings/functions/pikku-command-function-types.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-command-function-types.js +0 -13
- package/dist/src/wirings/functions/pikku-command-functions.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-command-functions.js +0 -14
- package/dist/src/wirings/functions/pikku-command-services.d.ts +0 -3
- package/dist/src/wirings/functions/pikku-function-types.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-function-types.js +0 -13
- package/dist/src/wirings/http/pikku-command-http-map.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-http-map.js +0 -8
- package/dist/src/wirings/http/pikku-command-http-routes.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-http-routes.js +0 -9
- package/dist/src/wirings/http/pikku-command-openapi.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-openapi.js +0 -20
- package/dist/src/wirings/http/pikku-http-routes.d.ts +0 -2
- package/dist/src/wirings/http/pikku-http-routes.js +0 -9
- package/dist/src/wirings/mcp/pikku-command-mcp-json.d.ts +0 -2
- package/dist/src/wirings/mcp/pikku-command-mcp-json.js +0 -13
- package/dist/src/wirings/mcp/pikku-command-mcp.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-map.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-map.js +0 -8
- package/dist/src/wirings/queue/pikku-command-queue-service.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-service.js +0 -15
- package/dist/src/wirings/queue/pikku-command-queue.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue.js +0 -10
- package/dist/src/wirings/queue/pikku-queue-map.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-queue-map.js +0 -8
- package/dist/src/wirings/queue/pikku-queue.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-queue.js +0 -10
- package/dist/src/wirings/rpc/pikku-command-rpc-client.d.ts +0 -2
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +0 -15
- package/dist/src/wirings/rpc/pikku-command-rpc-map.d.ts +0 -3
- package/dist/src/wirings/rpc/pikku-command-rpc-map.js +0 -14
- package/dist/src/wirings/rpc/pikku-command-rpc.d.ts +0 -2
- package/dist/src/wirings/rpc/pikku-command-rpc.js +0 -8
- package/dist/src/wirings/scheduler/pikku-command-scheduler.d.ts +0 -2
- package/dist/src/wirings/scheduler/pikku-command-scheduler.js +0 -10
- package/src/inspector-glob.ts +0 -30
- package/src/pikku-cli-config.ts +0 -387
- package/src/pikku-command-schemas.ts +0 -35
- package/src/runtimes/nextjs/pikku-command-nextjs.ts +0 -110
- package/src/schemas.ts +0 -35
- package/src/serialize-pikku-types.ts +0 -613
- package/src/types.ts +0 -16
- package/src/utils.ts +0 -420
- package/src/wirings/channels/pikku-channels.ts +0 -41
- package/src/wirings/channels/pikku-command-channels-map.ts +0 -26
- package/src/wirings/channels/pikku-command-channels.ts +0 -39
- package/src/wirings/channels/pikku-command-websocket-typed.ts +0 -36
- package/src/wirings/fetch/index.ts +0 -33
- package/src/wirings/functions/pikku-command-function-types.ts +0 -53
- package/src/wirings/functions/pikku-command-functions.ts +0 -48
- package/src/wirings/functions/pikku-command-services.ts +0 -125
- package/src/wirings/functions/pikku-function-types.ts +0 -52
- package/src/wirings/http/pikku-command-http-map.ts +0 -27
- package/src/wirings/http/pikku-command-http-routes.ts +0 -40
- package/src/wirings/http/pikku-command-openapi.ts +0 -55
- package/src/wirings/http/pikku-http-routes.ts +0 -40
- package/src/wirings/mcp/pikku-command-mcp-json.ts +0 -33
- package/src/wirings/queue/pikku-command-queue-map.ts +0 -26
- package/src/wirings/queue/pikku-command-queue-service.ts +0 -36
- package/src/wirings/queue/pikku-command-queue.ts +0 -45
- package/src/wirings/queue/pikku-queue-map.ts +0 -26
- package/src/wirings/queue/pikku-queue.ts +0 -43
- package/src/wirings/rpc/pikku-command-rpc-client.ts +0 -35
- package/src/wirings/rpc/pikku-command-rpc-map.ts +0 -49
- package/src/wirings/rpc/pikku-command-rpc.ts +0 -24
- package/src/wirings/scheduler/pikku-command-scheduler.ts +0 -43
- /package/dist/{src/types.js → .pikku/channel/pikku-channels-meta.gen.d.ts} +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.d.ts +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.js +0 -0
- /package/dist/src/{serialize-import-map.d.ts → utils/serialize-import-map.d.ts} +0 -0
- /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.ts +0 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates core function, middleware, and permission type definitions
|
|
3
|
+
*/
|
|
4
|
+
export const serializeFunctionTypes = (
|
|
5
|
+
userSessionTypeImport: string,
|
|
6
|
+
userSessionTypeName: string,
|
|
7
|
+
singletonServicesTypeImport: string,
|
|
8
|
+
singletonServicesTypeName: string,
|
|
9
|
+
sessionServicesTypeImport: string,
|
|
10
|
+
sessionServicesTypeName: string,
|
|
11
|
+
rpcMapTypeImport: string,
|
|
12
|
+
requiredServicesTypeImport: string,
|
|
13
|
+
configTypeImport: string
|
|
14
|
+
) => {
|
|
15
|
+
return `/**
|
|
16
|
+
* Core function, middleware, and permission types for all wirings
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { CorePikkuFunctionConfig, CorePikkuPermission, CorePikkuMiddleware, CorePermissionGroup, addMiddleware as addMiddlewareCore, addPermission as addPermissionCore } from '@pikku/core'
|
|
20
|
+
import { CorePikkuFunction, CorePikkuFunctionSessionless } from '@pikku/core/function'
|
|
21
|
+
import { PikkuChannel } from '@pikku/core/channel'
|
|
22
|
+
import { PikkuMCP } from '@pikku/core/mcp'
|
|
23
|
+
|
|
24
|
+
${userSessionTypeImport}
|
|
25
|
+
${singletonServicesTypeImport}
|
|
26
|
+
${sessionServicesTypeImport}
|
|
27
|
+
${configTypeImport}
|
|
28
|
+
${rpcMapTypeImport}
|
|
29
|
+
${requiredServicesTypeImport}
|
|
30
|
+
|
|
31
|
+
${singletonServicesTypeName !== 'SingletonServices' ? `type SingletonServices = ${singletonServicesTypeName}` : ''}
|
|
32
|
+
${sessionServicesTypeName !== 'Services' ? `type Services = ${sessionServicesTypeName}` : ''}
|
|
33
|
+
${userSessionTypeName !== 'Session' ? `type Session = ${userSessionTypeName}` : ''}
|
|
34
|
+
${configTypeImport.includes('Config type not found') ? 'type Config = any' : ''}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Type-safe API permission definition that integrates with your application's session type.
|
|
38
|
+
* Use this to define authorization logic for your API endpoints.
|
|
39
|
+
*
|
|
40
|
+
* @template In - The input type that the permission check will receive
|
|
41
|
+
* @template RequiredServices - The services required for this permission check
|
|
42
|
+
*/
|
|
43
|
+
export type PikkuPermission<In = unknown, RequiredServices extends Services = Services> = CorePikkuPermission<In, RequiredServices, Session>
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Type-safe middleware definition that can access your application's services and session.
|
|
47
|
+
* Use this to define reusable middleware that can be applied to multiple wirings.
|
|
48
|
+
*
|
|
49
|
+
* @template RequiredServices - The services required for this middleware
|
|
50
|
+
*/
|
|
51
|
+
export type PikkuMiddleware<RequiredServices extends SingletonServices = SingletonServices> = CorePikkuMiddleware<RequiredServices, Session>
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Configuration object for creating a permission with metadata
|
|
55
|
+
*/
|
|
56
|
+
export type PikkuPermissionConfig<In = unknown, RequiredServices extends Services = Services> = {
|
|
57
|
+
/** The permission function */
|
|
58
|
+
func: PikkuPermission<In, RequiredServices>
|
|
59
|
+
/** Optional human-readable name for the permission */
|
|
60
|
+
name?: string
|
|
61
|
+
/** Optional description of what the permission checks */
|
|
62
|
+
description?: string
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Factory function for creating permissions with tree-shaking support.
|
|
67
|
+
* Supports both direct function and configuration object syntax.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* \`\`\`typescript
|
|
71
|
+
* // Direct function syntax
|
|
72
|
+
* const permission = pikkuPermission(({ logger }, data, session) => {
|
|
73
|
+
* return session?.role === 'admin'
|
|
74
|
+
* })
|
|
75
|
+
*
|
|
76
|
+
* // Configuration object syntax with metadata
|
|
77
|
+
* const adminPermission = pikkuPermission({
|
|
78
|
+
* name: 'Admin Permission',
|
|
79
|
+
* description: 'Checks if user has admin role',
|
|
80
|
+
* func: async ({ logger }, data, session) => {
|
|
81
|
+
* return session?.role === 'admin'
|
|
82
|
+
* }
|
|
83
|
+
* })
|
|
84
|
+
* \`\`\`
|
|
85
|
+
*/
|
|
86
|
+
export const pikkuPermission = <In>(
|
|
87
|
+
permission: PikkuPermission<In> | PikkuPermissionConfig<In>
|
|
88
|
+
): PikkuPermission<In> => {
|
|
89
|
+
return typeof permission === 'function' ? permission : permission.func
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Configuration object for creating middleware with metadata
|
|
94
|
+
*/
|
|
95
|
+
export type PikkuMiddlewareConfig<RequiredServices extends SingletonServices = SingletonServices> = {
|
|
96
|
+
/** The middleware function */
|
|
97
|
+
func: PikkuMiddleware<RequiredServices>
|
|
98
|
+
/** Optional human-readable name for the middleware */
|
|
99
|
+
name?: string
|
|
100
|
+
/** Optional description of what the middleware does */
|
|
101
|
+
description?: string
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Factory function for creating middleware with tree-shaking support.
|
|
106
|
+
* Supports both direct function and configuration object syntax.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* \`\`\`typescript
|
|
110
|
+
* // Direct function syntax
|
|
111
|
+
* const middleware = pikkuMiddleware(({ logger }, interactions, next) => {
|
|
112
|
+
* logger.info('Middleware executed')
|
|
113
|
+
* await next()
|
|
114
|
+
* })
|
|
115
|
+
*
|
|
116
|
+
* // Configuration object syntax with metadata
|
|
117
|
+
* const logMiddleware = pikkuMiddleware({
|
|
118
|
+
* name: 'Request Logger',
|
|
119
|
+
* description: 'Logs all incoming requests',
|
|
120
|
+
* func: async ({ logger }, interactions, next) => {
|
|
121
|
+
* logger.info('Request started')
|
|
122
|
+
* await next()
|
|
123
|
+
* }
|
|
124
|
+
* })
|
|
125
|
+
* \`\`\`
|
|
126
|
+
*/
|
|
127
|
+
export const pikkuMiddleware = <RequiredServices extends SingletonServices = SingletonServices>(
|
|
128
|
+
middleware: PikkuMiddleware<RequiredServices> | PikkuMiddlewareConfig<RequiredServices>
|
|
129
|
+
): PikkuMiddleware<RequiredServices> => {
|
|
130
|
+
return typeof middleware === 'function' ? middleware : middleware.func
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Factory function for creating middleware factories
|
|
135
|
+
* Use this when your middleware needs configuration/input parameters
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* \`\`\`typescript
|
|
139
|
+
* export const logMiddleware = pikkuMiddlewareFactory<LogOptions>(({
|
|
140
|
+
* message,
|
|
141
|
+
* level = 'info'
|
|
142
|
+
* }) => {
|
|
143
|
+
* return pikkuMiddleware(async ({ logger }, _interaction, next) => {
|
|
144
|
+
* logger[level](message)
|
|
145
|
+
* await next()
|
|
146
|
+
* })
|
|
147
|
+
* })
|
|
148
|
+
* \`\`\`
|
|
149
|
+
*/
|
|
150
|
+
export const pikkuMiddlewareFactory = <In = any>(
|
|
151
|
+
factory: (input: In) => PikkuMiddleware
|
|
152
|
+
): ((input: In) => PikkuMiddleware) => {
|
|
153
|
+
return factory
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Factory function for creating permission factories
|
|
158
|
+
* Use this when your permission needs configuration/input parameters
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* \`\`\`typescript
|
|
162
|
+
* export const requireRole = pikkuPermissionFactory<{ role: string }>(({
|
|
163
|
+
* role
|
|
164
|
+
* }) => {
|
|
165
|
+
* return pikkuPermission(async ({ logger }, data, session) => {
|
|
166
|
+
* if (!session || session.role !== role) {
|
|
167
|
+
* logger.warn(\`Permission denied: required role '\${role}'\`)
|
|
168
|
+
* return false
|
|
169
|
+
* }
|
|
170
|
+
* return true
|
|
171
|
+
* })
|
|
172
|
+
* })
|
|
173
|
+
* \`\`\`
|
|
174
|
+
*/
|
|
175
|
+
export const pikkuPermissionFactory = <In = any>(
|
|
176
|
+
factory: (input: In) => PikkuPermission<any>
|
|
177
|
+
): ((input: In) => PikkuPermission<any>) => {
|
|
178
|
+
return factory
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* A sessionless API function that doesn't require user authentication.
|
|
183
|
+
* Use this for public endpoints, health checks, or operations that don't need user context.
|
|
184
|
+
*
|
|
185
|
+
* @template In - The input type
|
|
186
|
+
* @template Out - The output type that the function returns
|
|
187
|
+
* @template ChannelData - Channel data type (null = optional channel)
|
|
188
|
+
* @template MCPData - MCP data type (null = optional MCP)
|
|
189
|
+
* @template RequiredServices - Services required by this function
|
|
190
|
+
*/
|
|
191
|
+
export type PikkuFunctionSessionless<
|
|
192
|
+
In = unknown,
|
|
193
|
+
Out = never,
|
|
194
|
+
ChannelData = null, // null means optional channel
|
|
195
|
+
MCPData = null, // null means optional MCP
|
|
196
|
+
RequiredServices extends Services = Omit<Services, 'rpc' | 'channel' | 'mcp'> &
|
|
197
|
+
{ rpc: TypedPikkuRPC } & (
|
|
198
|
+
[ChannelData] extends [null]
|
|
199
|
+
? { channel?: PikkuChannel<unknown, Out> } // Optional channel
|
|
200
|
+
: { channel: PikkuChannel<ChannelData, Out> } // Required channel with any data type
|
|
201
|
+
) & ([MCPData] extends [null]
|
|
202
|
+
? { mcp?: PikkuMCP } // Optional MCP
|
|
203
|
+
: { mcp: PikkuMCP } // Required MCP
|
|
204
|
+
)
|
|
205
|
+
> = CorePikkuFunctionSessionless<In, Out, ChannelData, RequiredServices, Session>
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* A session-aware API function that requires user authentication.
|
|
209
|
+
* Use this for protected endpoints that need access to user session data.
|
|
210
|
+
*
|
|
211
|
+
* @template In - The input type
|
|
212
|
+
* @template Out - The output type that the function returns
|
|
213
|
+
* @template ChannelData - Channel data type (null = optional channel)
|
|
214
|
+
* @template MCPData - MCP data type (null = optional MCP)
|
|
215
|
+
* @template RequiredServices - Services required by this function
|
|
216
|
+
*/
|
|
217
|
+
export type PikkuFunction<
|
|
218
|
+
In = unknown,
|
|
219
|
+
Out = never,
|
|
220
|
+
ChannelData = null, // null means optional channel
|
|
221
|
+
MCPData = null, // null means optional MCP
|
|
222
|
+
RequiredServices extends Services = Omit<Services, 'rpc' | 'channel' | 'mcp'> &
|
|
223
|
+
{ rpc: TypedPikkuRPC } & (
|
|
224
|
+
[ChannelData] extends [null]
|
|
225
|
+
? { channel?: PikkuChannel<unknown, Out> } // Optional channel
|
|
226
|
+
: { channel: PikkuChannel<ChannelData, Out> } // Required channel with any data type
|
|
227
|
+
) & ([MCPData] extends [null]
|
|
228
|
+
? { mcp?: PikkuMCP } // Optional MCP
|
|
229
|
+
: { mcp: PikkuMCP } // Required MCP
|
|
230
|
+
)
|
|
231
|
+
> = CorePikkuFunction<In, Out, ChannelData, RequiredServices, Session>
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Configuration object for Pikku functions with optional middleware, permissions, tags, and documentation.
|
|
235
|
+
* This type wraps CorePikkuFunctionConfig with the user's custom types.
|
|
236
|
+
*
|
|
237
|
+
* @template In - The input type
|
|
238
|
+
* @template Out - The output type
|
|
239
|
+
* @template ChannelData - Channel data type
|
|
240
|
+
* @template MCPData - MCP data type
|
|
241
|
+
* @template PikkuFunc - The function type (can be narrowed to PikkuFunction or PikkuFunctionSessionless)
|
|
242
|
+
*/
|
|
243
|
+
export type PikkuFunctionConfig<
|
|
244
|
+
In = unknown,
|
|
245
|
+
Out = unknown,
|
|
246
|
+
ChannelData = unknown,
|
|
247
|
+
MCPData = unknown,
|
|
248
|
+
PikkuFunc extends PikkuFunction<In, Out, ChannelData, MCPData> | PikkuFunctionSessionless<In, Out, ChannelData, MCPData> = PikkuFunction<In, Out, ChannelData, MCPData> | PikkuFunctionSessionless<In, Out, ChannelData, MCPData>
|
|
249
|
+
> = CorePikkuFunctionConfig<PikkuFunc, PikkuPermission<In>, PikkuMiddleware>
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Creates a Pikku function that can be either session-aware or sessionless.
|
|
253
|
+
* This is the main function wrapper for creating API endpoints.
|
|
254
|
+
*
|
|
255
|
+
* @template In - Input type for the function
|
|
256
|
+
* @template Out - Output type for the function
|
|
257
|
+
* @param func - Function definition, either direct function or configuration object
|
|
258
|
+
* @returns The normalized configuration object
|
|
259
|
+
*
|
|
260
|
+
* @example
|
|
261
|
+
* \\\`\\\`\\\`typescript
|
|
262
|
+
* const createUser = pikkuFunc<{name: string, email: string}, {id: number, message: string}>({
|
|
263
|
+
* func: async ({db, logger}, input) => {
|
|
264
|
+
* logger.info('Creating user', input.name)
|
|
265
|
+
* const user = await db.users.create(input)
|
|
266
|
+
* return {id: user.id, message: \\\`User \\\${input.name} created successfully\\\`}
|
|
267
|
+
* },
|
|
268
|
+
* auth: true
|
|
269
|
+
* })
|
|
270
|
+
* \\\`\\\`\\\`
|
|
271
|
+
*/
|
|
272
|
+
export const pikkuFunc = <In, Out = unknown>(
|
|
273
|
+
func:
|
|
274
|
+
| PikkuFunction<In, Out>
|
|
275
|
+
| CorePikkuFunctionConfig<PikkuFunction<In, Out>, PikkuPermission<In>, PikkuMiddleware>
|
|
276
|
+
) => {
|
|
277
|
+
return typeof func === 'function' ? { func } : func
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Creates a sessionless Pikku function that doesn't require user authentication.
|
|
282
|
+
* Use this for public endpoints, webhooks, or background tasks.
|
|
283
|
+
*
|
|
284
|
+
* @template In - Input type for the function
|
|
285
|
+
* @template Out - Output type for the function
|
|
286
|
+
* @param func - Function definition, either direct function or configuration object
|
|
287
|
+
* @returns The normalized configuration object
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* \\\`\\\`\\\`typescript
|
|
291
|
+
* const healthCheck = pikkuSessionlessFunc<void, {status: string, timestamp: string}>({
|
|
292
|
+
* func: async ({logger}) => {
|
|
293
|
+
* logger.info('Health check requested')
|
|
294
|
+
* return {status: 'healthy', timestamp: new Date().toISOString()}
|
|
295
|
+
* },
|
|
296
|
+
* name: 'healthCheck'
|
|
297
|
+
* })
|
|
298
|
+
* \\\`\\\`\\\`
|
|
299
|
+
*/
|
|
300
|
+
export const pikkuSessionlessFunc = <In, Out = unknown>(
|
|
301
|
+
func:
|
|
302
|
+
| PikkuFunctionSessionless<In, Out>
|
|
303
|
+
| CorePikkuFunctionConfig<PikkuFunctionSessionless<In, Out>, PikkuPermission<In>, PikkuMiddleware>
|
|
304
|
+
) => {
|
|
305
|
+
return typeof func === 'function' ? { func } : func
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Creates a function that takes no input and returns no output.
|
|
310
|
+
* Useful for health checks, triggers, or cleanup operations.
|
|
311
|
+
*
|
|
312
|
+
* @param func - Function definition, either direct function or configuration object
|
|
313
|
+
* @returns The normalized configuration object
|
|
314
|
+
*
|
|
315
|
+
* @example
|
|
316
|
+
* \\\`\\\`\\\`typescript
|
|
317
|
+
* const cleanupTempFiles = pikkuVoidFunc(async ({fileSystem, logger}) => {
|
|
318
|
+
* logger.info('Starting cleanup of temporary files')
|
|
319
|
+
* await fileSystem.deleteDirectory('/tmp/uploads')
|
|
320
|
+
* logger.info('Cleanup completed')
|
|
321
|
+
* })
|
|
322
|
+
* \\\`\\\`\\\`
|
|
323
|
+
*/
|
|
324
|
+
export const pikkuVoidFunc = (
|
|
325
|
+
func:
|
|
326
|
+
| PikkuFunctionSessionless<void, void>
|
|
327
|
+
| CorePikkuFunctionConfig<PikkuFunctionSessionless<void, void>, PikkuPermission<void>>
|
|
328
|
+
) => {
|
|
329
|
+
return typeof func === 'function' ? { func } : func
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* Creates a Pikku config factory.
|
|
334
|
+
* Use this to define your application's configuration factory.
|
|
335
|
+
*
|
|
336
|
+
* @param func - Config factory function that returns your application's config
|
|
337
|
+
* @returns The config factory function
|
|
338
|
+
*
|
|
339
|
+
* @example
|
|
340
|
+
* \`\`\`typescript
|
|
341
|
+
* export const createConfig = pikkuConfig(async () => {
|
|
342
|
+
* return {
|
|
343
|
+
* apiUrl: process.env.API_URL || 'http://localhost:3000',
|
|
344
|
+
* dbUrl: process.env.DATABASE_URL
|
|
345
|
+
* }
|
|
346
|
+
* })
|
|
347
|
+
* \`\`\`
|
|
348
|
+
*/
|
|
349
|
+
export const pikkuConfig = (
|
|
350
|
+
func: (variables?: any, ...args: any[]) => Promise<Config>
|
|
351
|
+
) => func
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Creates a Pikku singleton services factory.
|
|
355
|
+
* Use this to define services that are created once and shared across all requests.
|
|
356
|
+
*
|
|
357
|
+
* @param func - Singleton services factory function
|
|
358
|
+
* @returns The singleton services factory function
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* \`\`\`typescript
|
|
362
|
+
* export const createSingletonServices = pikkuServices(async (config, existingServices) => {
|
|
363
|
+
* return {
|
|
364
|
+
* config,
|
|
365
|
+
* logger: new CustomLogger(),
|
|
366
|
+
* db: await createDatabaseConnection(config.dbUrl)
|
|
367
|
+
* }
|
|
368
|
+
* })
|
|
369
|
+
* \`\`\`
|
|
370
|
+
*/
|
|
371
|
+
export const pikkuServices = (
|
|
372
|
+
func: (config: Config, existingServices?: Partial<SingletonServices>) => Promise<RequiredSingletonServices>
|
|
373
|
+
) => func
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Creates a Pikku session services factory.
|
|
377
|
+
* Use this to define services that are created per-request/session.
|
|
378
|
+
*
|
|
379
|
+
* @param func - Session services factory function
|
|
380
|
+
* @returns The session services factory function
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* \`\`\`typescript
|
|
384
|
+
* export const createSessionServices = pikkuSessionServices(async (services, interaction, session) => {
|
|
385
|
+
* return {
|
|
386
|
+
* userCache: new UserCache(session?.userId)
|
|
387
|
+
* }
|
|
388
|
+
* })
|
|
389
|
+
* \`\`\`
|
|
390
|
+
*/
|
|
391
|
+
export const pikkuSessionServices = (
|
|
392
|
+
func: (
|
|
393
|
+
services: SingletonServices,
|
|
394
|
+
interaction: any,
|
|
395
|
+
session: Session | undefined
|
|
396
|
+
) => Promise<RequiredSessionServices>
|
|
397
|
+
) => func
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Adds global middleware for a specific tag.
|
|
401
|
+
*
|
|
402
|
+
* This function allows you to register middleware that will be applied to
|
|
403
|
+
* any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
|
|
404
|
+
*
|
|
405
|
+
* @param tag - The tag that the middleware should apply to.
|
|
406
|
+
* @param middleware - The middleware array to apply for the specified tag.
|
|
407
|
+
*
|
|
408
|
+
* @throws Error if middleware for the tag already exists.
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* \`\`\`typescript
|
|
412
|
+
* // Add admin middleware for admin endpoints
|
|
413
|
+
* addMiddleware('admin', [adminMiddleware])
|
|
414
|
+
*
|
|
415
|
+
* // Add authentication middleware for auth endpoints
|
|
416
|
+
* addMiddleware('auth', [authMiddleware])
|
|
417
|
+
*
|
|
418
|
+
* // Add logging middleware for all API endpoints
|
|
419
|
+
* addMiddleware('api', [loggingMiddleware])
|
|
420
|
+
* \`\`\`
|
|
421
|
+
*/
|
|
422
|
+
export const addMiddleware = (tag: string, middleware: PikkuMiddleware[]) => {
|
|
423
|
+
addMiddlewareCore(tag, middleware as any)
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Adds global permissions for a specific tag.
|
|
428
|
+
*
|
|
429
|
+
* This function allows you to register permissions that will be applied to
|
|
430
|
+
* any wiring (HTTP, Channel, Queue, Scheduler, MCP) that includes the matching tag.
|
|
431
|
+
*
|
|
432
|
+
* @param tag - The tag that the permissions should apply to.
|
|
433
|
+
* @param permissions - The permissions array or object to apply for the specified tag.
|
|
434
|
+
*
|
|
435
|
+
* @throws Error if permissions for the tag already exist.
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* \`\`\`typescript
|
|
439
|
+
* // Add admin permissions for admin endpoints
|
|
440
|
+
* addPermission('admin', [adminPermission])
|
|
441
|
+
*
|
|
442
|
+
* // Add authentication permissions for auth endpoints
|
|
443
|
+
* addPermission('auth', [authPermission])
|
|
444
|
+
*
|
|
445
|
+
* // Add read permissions for all API endpoints (as object)
|
|
446
|
+
* addPermission('api', { read: readPermission })
|
|
447
|
+
* \`\`\`
|
|
448
|
+
*/
|
|
449
|
+
export const addPermission = <In = unknown>(tag: string, permissions: CorePermissionGroup<PikkuPermission<In>> | PikkuPermission<In>[]) => {
|
|
450
|
+
addPermissionCore(tag, permissions as any)
|
|
451
|
+
}
|
|
452
|
+
`
|
|
453
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the main pikku-types.gen.ts file as a re-export hub
|
|
3
|
+
*/
|
|
4
|
+
export const serializePikkuTypesHub = (
|
|
5
|
+
functionTypesImportPath: string,
|
|
6
|
+
httpTypesImportPath: string,
|
|
7
|
+
channelTypesImportPath: string,
|
|
8
|
+
schedulerTypesImportPath: string,
|
|
9
|
+
queueTypesImportPath: string,
|
|
10
|
+
mcpTypesImportPath: string,
|
|
11
|
+
cliTypesImportPath: string
|
|
12
|
+
) => {
|
|
13
|
+
return `/**
|
|
14
|
+
* Main type export hub - re-exports all wiring-specific types
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Core function, middleware, and permission types
|
|
18
|
+
export * from '${functionTypesImportPath}'
|
|
19
|
+
|
|
20
|
+
// HTTP wiring types
|
|
21
|
+
export * from '${httpTypesImportPath}'
|
|
22
|
+
|
|
23
|
+
// Channel wiring types
|
|
24
|
+
export * from '${channelTypesImportPath}'
|
|
25
|
+
|
|
26
|
+
// Scheduler wiring types
|
|
27
|
+
export * from '${schedulerTypesImportPath}'
|
|
28
|
+
|
|
29
|
+
// Queue wiring types
|
|
30
|
+
export * from '${queueTypesImportPath}'
|
|
31
|
+
|
|
32
|
+
// MCP wiring types
|
|
33
|
+
export * from '${mcpTypesImportPath}'
|
|
34
|
+
|
|
35
|
+
// CLI wiring types
|
|
36
|
+
export * from '${cliTypesImportPath}'
|
|
37
|
+
`
|
|
38
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { FunctionsMeta,
|
|
1
|
+
import { FunctionsMeta, pikkuState } from '@pikku/core'
|
|
2
|
+
import { HTTPWiringsMeta } from '@pikku/core/http'
|
|
2
3
|
import _convertSchema from '@openapi-contrib/json-schema-to-openapi-schema'
|
|
4
|
+
import { CLILogger } from '../../../services/cli-logger.service.js'
|
|
3
5
|
const convertSchema =
|
|
4
6
|
'default' in _convertSchema ? (_convertSchema.default as any) : _convertSchema
|
|
5
7
|
|
|
@@ -108,6 +110,7 @@ const convertSchemasToBodyPayloads = async (
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
export async function generateOpenAPISpec(
|
|
113
|
+
logger: CLILogger,
|
|
111
114
|
functionsMeta: FunctionsMeta,
|
|
112
115
|
httpMeta: HTTPWiringsMeta,
|
|
113
116
|
schemas: Record<string, any>,
|
|
@@ -121,7 +124,7 @@ export async function generateOpenAPISpec(
|
|
|
121
124
|
meta
|
|
122
125
|
const functionMeta = functionsMeta[pikkuFuncName]
|
|
123
126
|
if (!functionMeta) {
|
|
124
|
-
|
|
127
|
+
logger.error(
|
|
125
128
|
`• No function metadata found for '${pikkuFuncName}' in route '${route}'.`
|
|
126
129
|
)
|
|
127
130
|
continue
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
import { serializeTypedHTTPWiringsMap } from './serialize-typed-http-map.js'
|
|
5
|
+
|
|
6
|
+
export const pikkuHTTPMap: any = pikkuSessionlessFunc<void, void>({
|
|
7
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
8
|
+
const { http, functions } = await getInspectorState()
|
|
9
|
+
const { httpMapDeclarationFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const content = serializeTypedHTTPWiringsMap(
|
|
12
|
+
httpMapDeclarationFile,
|
|
13
|
+
packageMappings,
|
|
14
|
+
functions.typesMap,
|
|
15
|
+
functions.meta,
|
|
16
|
+
http.meta,
|
|
17
|
+
http.metaInputTypes
|
|
18
|
+
)
|
|
19
|
+
await writeFileInDir(logger, httpMapDeclarationFile, content)
|
|
20
|
+
},
|
|
21
|
+
middleware: [
|
|
22
|
+
logCommandInfoAndTime({
|
|
23
|
+
commandStart: 'Creating HTTP map',
|
|
24
|
+
commandEnd: 'Created HTTP map',
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
|
|
6
|
+
export const pikkuHTTP: any = pikkuSessionlessFunc<void, boolean | undefined>({
|
|
7
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
8
|
+
const visitState = await getInspectorState()
|
|
9
|
+
const { httpWiringsFile, httpWiringMetaFile, packageMappings } = config
|
|
10
|
+
const { http } = visitState
|
|
11
|
+
|
|
12
|
+
await writeFileInDir(
|
|
13
|
+
logger,
|
|
14
|
+
httpWiringsFile,
|
|
15
|
+
serializeFileImports(
|
|
16
|
+
'wireHTTP',
|
|
17
|
+
httpWiringsFile,
|
|
18
|
+
http.files,
|
|
19
|
+
packageMappings
|
|
20
|
+
)
|
|
21
|
+
)
|
|
22
|
+
await writeFileInDir(
|
|
23
|
+
logger,
|
|
24
|
+
httpWiringMetaFile,
|
|
25
|
+
`import { pikkuState } from '@pikku/core'\npikkuState('http', 'meta', ${JSON.stringify(http.meta, null, 2)})`
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
return true
|
|
29
|
+
},
|
|
30
|
+
middleware: [
|
|
31
|
+
logCommandInfoAndTime({
|
|
32
|
+
commandStart: 'Finding HTTP routes',
|
|
33
|
+
commandEnd: 'Found HTTP routes',
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
})
|
|
@@ -0,0 +1,25 @@
|
|
|
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 { serializeHTTPTypes } from './serialize-http-types.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuHTTPTypes: any = pikkuSessionlessFunc<void, void>({
|
|
8
|
+
func: async ({ logger, config }) => {
|
|
9
|
+
const { httpTypesFile, functionTypesFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const functionTypesImportPath = getFileImportRelativePath(
|
|
12
|
+
httpTypesFile,
|
|
13
|
+
functionTypesFile,
|
|
14
|
+
packageMappings
|
|
15
|
+
)
|
|
16
|
+
const content = serializeHTTPTypes(functionTypesImportPath)
|
|
17
|
+
await writeFileInDir(logger, httpTypesFile, content)
|
|
18
|
+
},
|
|
19
|
+
middleware: [
|
|
20
|
+
logCommandInfoAndTime({
|
|
21
|
+
commandStart: 'Creating HTTP types',
|
|
22
|
+
commandEnd: 'Created HTTP types',
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
})
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
import { generateSchemas } from '../../../utils/schema-generator.js'
|
|
5
|
+
import { generateOpenAPISpec } from './openapi-spec-generator.js'
|
|
6
|
+
import { stringify } from 'yaml'
|
|
7
|
+
|
|
8
|
+
export const pikkuOpenAPI: any = pikkuSessionlessFunc<void, void>({
|
|
9
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
10
|
+
const { tsconfig, openAPI, schemasFromTypes } = config
|
|
11
|
+
|
|
12
|
+
// If openAPI outputFile is not defined, clean up any existing file and return
|
|
13
|
+
if (!openAPI?.outputFile) {
|
|
14
|
+
logger.info({
|
|
15
|
+
message:
|
|
16
|
+
'Skipping creating OpenAPI spec since openAPI outfile is not defined.',
|
|
17
|
+
type: 'skip',
|
|
18
|
+
})
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { http, functions } = await getInspectorState()
|
|
23
|
+
|
|
24
|
+
const schemas = await generateSchemas(
|
|
25
|
+
logger,
|
|
26
|
+
tsconfig,
|
|
27
|
+
functions.typesMap,
|
|
28
|
+
functions.meta,
|
|
29
|
+
http.meta,
|
|
30
|
+
schemasFromTypes
|
|
31
|
+
)
|
|
32
|
+
const openAPISpec = await generateOpenAPISpec(
|
|
33
|
+
logger,
|
|
34
|
+
functions.meta,
|
|
35
|
+
http.meta,
|
|
36
|
+
schemas,
|
|
37
|
+
openAPI.additionalInfo
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
if (openAPI.outputFile.endsWith('.json')) {
|
|
41
|
+
await writeFileInDir(
|
|
42
|
+
logger,
|
|
43
|
+
openAPI.outputFile,
|
|
44
|
+
JSON.stringify(openAPISpec, null, 2),
|
|
45
|
+
{ ignoreModifyComment: true }
|
|
46
|
+
)
|
|
47
|
+
} else if (
|
|
48
|
+
openAPI.outputFile.endsWith('.yaml') ||
|
|
49
|
+
openAPI.outputFile.endsWith('.yml')
|
|
50
|
+
) {
|
|
51
|
+
await writeFileInDir(logger, openAPI.outputFile, stringify(openAPISpec), {
|
|
52
|
+
ignoreModifyComment: true,
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
middleware: [
|
|
57
|
+
logCommandInfoAndTime({
|
|
58
|
+
commandStart: 'Creating OpenAPI spec',
|
|
59
|
+
commandEnd: 'Created OpenAPI spec',
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
})
|