@pikku/cli 0.9.14 → 0.9.16-next.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 +92 -0
- package/.pikku/cli/pikku-cli-types.gen.ts +71 -0
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +5 -0
- package/.pikku/cli/pikku-cli-wirings.gen.ts +4 -0
- package/.pikku/function/pikku-function-types.gen.ts +292 -0
- package/.pikku/function/pikku-functions-meta.gen.ts +817 -0
- package/.pikku/function/pikku-functions-meta.min.gen.ts +176 -0
- package/.pikku/function/pikku-functions.gen.ts +74 -0
- package/.pikku/http/pikku-http-types.gen.ts +61 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +138 -0
- package/.pikku/pikku-bootstrap.gen.ts +9 -0
- package/.pikku/pikku-services.gen.ts +24 -0
- package/.pikku/pikku-types.gen.ts +28 -0
- package/.pikku/queue/pikku-queue-types.gen.ts +28 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +46 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +80 -0
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +40 -0
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +26 -0
- package/.pikku/schemas/register.gen.ts +47 -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/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 +45 -14
- package/build.sh +53 -0
- package/cli.schema.json +1 -382
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +65 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js +54 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +55 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.js +30 -0
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +5 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +4 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +5 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +259 -0
- package/dist/.pikku/function/pikku-function-types.gen.js +175 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.js +817 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +176 -0
- package/dist/.pikku/function/pikku-functions.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions.gen.js +73 -0
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +49 -0
- package/dist/.pikku/http/pikku-http-types.gen.js +41 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +88 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +71 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +9 -0
- package/dist/.pikku/pikku-bootstrap.gen.js +9 -0
- package/dist/.pikku/pikku-services.gen.d.ts +16 -0
- package/dist/.pikku/pikku-services.gen.js +11 -0
- package/dist/.pikku/pikku-types.gen.d.ts +14 -0
- package/dist/.pikku/pikku-types.gen.js +21 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +24 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js +17 -0
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.d.ts +6 -0
- package/dist/.pikku/rpc/pikku-bootstrap-rpc.gen.js +6 -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 +40 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +22 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +17 -0
- package/dist/.pikku/schemas/register.gen.d.ts +1 -0
- package/dist/.pikku/schemas/register.gen.js +26 -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/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.d.ts +1 -1
- package/dist/bin/pikku.js +32 -14
- package/dist/src/cli.wiring.d.ts +1 -0
- package/dist/src/cli.wiring.js +75 -0
- package/dist/src/functions/commands/all.d.ts +1 -0
- package/dist/src/functions/commands/all.js +104 -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 +28 -9
- package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-channels.js +24 -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 +21 -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 +23 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +25 -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 +24 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.d.ts +4 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +95 -0
- package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.js +2 -2
- 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 +100 -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 +33 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +24 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +7 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +54 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +9 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +84 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.d.ts +4 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.js +74 -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 +46 -0
- package/dist/src/functions/wirings/fetch/index.d.ts +1 -0
- package/dist/src/functions/wirings/fetch/index.js +24 -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 +32 -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 +20 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +28 -0
- package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.d.ts +1 -2
- package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.js +27 -10
- package/dist/src/functions/wirings/functions/pikku-function-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-function-types.js +20 -0
- package/dist/src/functions/wirings/functions/schemas.d.ts +4 -0
- package/dist/src/functions/wirings/functions/schemas.js +22 -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 +295 -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 +31 -0
- package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.d.ts +2 -1
- 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 +23 -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 +25 -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 +21 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +34 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.js +25 -0
- package/dist/src/functions/wirings/http/serialize-http-types.d.ts +4 -0
- package/dist/src/functions/wirings/http/serialize-http-types.js +64 -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 +28 -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 +21 -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 +22 -5
- package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.d.ts +4 -0
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +141 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +38 -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 +50 -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/queue/pikku-command-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +23 -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 +24 -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 +21 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +26 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.js +23 -0
- package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue.js +25 -0
- package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.js +2 -2
- package/dist/src/functions/wirings/queue/serialize-queue-types.d.ts +4 -0
- package/dist/src/functions/wirings/queue/serialize-queue-types.js +31 -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 +25 -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 +36 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +1 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +22 -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 +21 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +26 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.d.ts +4 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +29 -0
- package/dist/src/middleware/log-command-info-and-time.d.ts +19 -0
- package/dist/src/middleware/log-command-info-and-time.js +27 -0
- package/dist/src/serialize-pikku-types.js +2 -2
- package/dist/src/services/cli-logger-forwarder.service.d.ts +26 -0
- package/dist/src/services/cli-logger-forwarder.service.js +55 -0
- package/dist/src/services/cli-logger.service.d.ts +19 -0
- package/dist/src/services/cli-logger.service.js +66 -0
- package/dist/src/services.d.ts +15 -0
- package/dist/src/services.js +64 -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 +37 -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 +6 -0
- package/dist/src/utils/file-writer.js +40 -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/pikku-cli-config.d.ts +5 -0
- package/dist/src/utils/pikku-cli-config.js +243 -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} +1 -1
- package/dist/src/{serialize-import-map.js → utils/serialize-import-map.js} +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -6
- package/pikku.config.json +24 -0
- package/src/cli.wiring.ts +75 -0
- package/src/functions/commands/all.ts +141 -0
- package/src/functions/commands/watch.ts +58 -0
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +111 -0
- package/src/functions/wirings/channels/pikku-channels.ts +40 -0
- package/src/functions/wirings/channels/pikku-command-channel-types.ts +27 -0
- package/src/functions/wirings/channels/pikku-command-channels-map.ts +31 -0
- package/src/functions/wirings/channels/pikku-command-channels.ts +45 -0
- package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +33 -0
- package/src/functions/wirings/channels/serialize-channel-types.ts +95 -0
- package/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.ts +2 -2
- package/src/functions/wirings/cli/pikku-command-cli-entry.ts +173 -0
- package/src/functions/wirings/cli/pikku-command-cli-types.ts +50 -0
- package/src/functions/wirings/cli/pikku-command-cli.ts +41 -0
- package/src/functions/wirings/cli/serialize-channel-cli-client.ts +72 -0
- package/src/functions/wirings/cli/serialize-channel-cli.ts +123 -0
- package/src/functions/wirings/cli/serialize-cli-types.ts +80 -0
- package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +75 -0
- package/src/functions/wirings/fetch/index.ts +32 -0
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +51 -0
- package/src/functions/wirings/functions/pikku-command-function-types.ts +45 -0
- package/src/functions/wirings/functions/pikku-command-functions.ts +61 -0
- package/src/{wirings → functions/wirings}/functions/pikku-command-services.ts +41 -44
- package/src/functions/wirings/functions/pikku-function-types.ts +45 -0
- package/src/functions/wirings/functions/schemas.ts +47 -0
- package/src/{wirings → functions/wirings}/functions/serialize-function-imports.ts +4 -30
- package/src/functions/wirings/functions/serialize-function-types.ts +303 -0
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +39 -0
- package/src/{wirings → functions/wirings}/http/openapi-spec-generator.ts +3 -1
- package/src/functions/wirings/http/pikku-command-http-map.ts +32 -0
- package/src/functions/wirings/http/pikku-command-http-routes.ts +41 -0
- package/src/functions/wirings/http/pikku-command-http-types.ts +27 -0
- package/src/functions/wirings/http/pikku-command-openapi.ts +57 -0
- package/src/functions/wirings/http/pikku-http-routes.ts +40 -0
- package/src/functions/wirings/http/serialize-http-types.ts +64 -0
- package/src/{wirings → functions/wirings}/http/serialize-typed-http-map.ts +2 -2
- package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +38 -0
- package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +27 -0
- package/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.ts +55 -46
- package/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.ts +1 -1
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +141 -0
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +65 -0
- package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +61 -0
- package/src/functions/wirings/middleware/serialize-middleware-imports.ts +78 -0
- package/src/functions/wirings/queue/pikku-command-queue-map.ts +31 -0
- package/src/functions/wirings/queue/pikku-command-queue-service.ts +33 -0
- package/src/functions/wirings/queue/pikku-command-queue-types.ts +27 -0
- package/src/functions/wirings/queue/pikku-command-queue.ts +46 -0
- package/src/functions/wirings/queue/pikku-queue-map.ts +31 -0
- package/src/functions/wirings/queue/pikku-queue.ts +44 -0
- package/src/{wirings → functions/wirings}/queue/serialize-queue-map.ts +2 -2
- package/src/functions/wirings/queue/serialize-queue-types.ts +31 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +32 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +52 -0
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +28 -0
- package/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.ts +2 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +27 -0
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +46 -0
- package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +29 -0
- package/src/middleware/log-command-info-and-time.ts +61 -0
- package/src/serialize-pikku-types.ts +2 -2
- package/src/services/cli-logger-forwarder.service.ts +77 -0
- package/src/services/cli-logger.service.ts +78 -0
- package/src/services.ts +111 -0
- package/src/utils/check-required-types.ts +53 -0
- package/src/utils/custom-types-generator.ts +49 -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 +56 -0
- package/src/utils/generate-bootstrap-file.ts +43 -0
- package/src/utils/pikku-cli-config.ts +356 -0
- package/src/utils/pikku-files-and-methods.ts +148 -0
- package/src/{schema-generator.ts → utils/schema-generator.ts} +3 -1
- package/src/{serialize-import-map.ts → utils/serialize-import-map.ts} +1 -1
- package/tsconfig.json +2 -2
- package/types/application-types.d.ts +20 -0
- package/types/config.d.ts +192 -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/schemas.d.ts +0 -2
- package/dist/src/schemas.js +0 -8
- 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-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/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-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/cli/pikku-cli-wirings-meta.gen.d.ts} +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.d.ts +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.js +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.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-backend-wrapper.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-meta.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,70 @@
|
|
|
1
|
+
const getMetaTypes = (type, map, desiredType) => {
|
|
2
|
+
const errors = new Map();
|
|
3
|
+
if (desiredType) {
|
|
4
|
+
for (const [file, meta] of map.entries()) {
|
|
5
|
+
for (const { type: entryType, variable, typePath } of meta) {
|
|
6
|
+
if (entryType === desiredType) {
|
|
7
|
+
if (entryType === null || typePath === null) {
|
|
8
|
+
throw new Error(`Unknown state due to metaType calculation: entryType or typePath is null for ${desiredType} in ${file}`);
|
|
9
|
+
}
|
|
10
|
+
return { file, variable, type: entryType, typePath, errors };
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
errors.set(`No ${desiredType} found that extends ${type}`, map);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const totalValues = Array.from(map.values()).flat();
|
|
18
|
+
if (totalValues.length === 0) {
|
|
19
|
+
const helpMessage = type === 'CoreConfig'
|
|
20
|
+
? `No ${type} found. Make sure you have exported a createConfig function in your codebase:\n\n` +
|
|
21
|
+
`export const createConfig: CreateConfig<Config> = async () => {\n` +
|
|
22
|
+
` return {}\n` +
|
|
23
|
+
`}\n\n` +
|
|
24
|
+
`Possible issues:\n` +
|
|
25
|
+
`- srcDirectories in pikku.config.json doesn't include the file with the createConfig method`
|
|
26
|
+
: `No ${type} found`;
|
|
27
|
+
errors.set(helpMessage, map);
|
|
28
|
+
}
|
|
29
|
+
else if (totalValues.length > 1) {
|
|
30
|
+
errors.set(`More than one ${type} found`, map);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
const entry = Array.from(map.entries())[0];
|
|
34
|
+
if (entry) {
|
|
35
|
+
const [file, [{ type: entryType, variable, typePath }]] = entry;
|
|
36
|
+
if (entryType === null || typePath === null) {
|
|
37
|
+
throw new Error(`Unknown state due to metaType calculation: entryType or typePath is null for ${type} in ${file}`);
|
|
38
|
+
}
|
|
39
|
+
return { file, type: entryType, variable, typePath, errors };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @deprecated Use state.filesAndMethods from InspectorState instead
|
|
46
|
+
*/
|
|
47
|
+
export const getPikkuFilesAndMethods = async (state, options = {}) => {
|
|
48
|
+
const { singletonServicesTypeImportMap, sessionServicesTypeImportMap, userSessionTypeImportMap, sessionServicesFactories, singletonServicesFactories, configFactories, } = state;
|
|
49
|
+
const { configFileType, userSessionType, singletonServicesFactoryType, sessionServicesFactoryType, } = options;
|
|
50
|
+
let errors = new Map();
|
|
51
|
+
const result = {
|
|
52
|
+
userSessionType: getMetaTypes('CoreUserSession', userSessionTypeImportMap, userSessionType),
|
|
53
|
+
singletonServicesType: getMetaTypes('CoreSingletonServices', singletonServicesTypeImportMap),
|
|
54
|
+
sessionServicesType: getMetaTypes('CoreServices', sessionServicesTypeImportMap),
|
|
55
|
+
pikkuConfigFactory: getMetaTypes('CoreConfig', configFactories, configFileType),
|
|
56
|
+
singletonServicesFactory: getMetaTypes('CreateSingletonServices', singletonServicesFactories, singletonServicesFactoryType),
|
|
57
|
+
sessionServicesFactory: getMetaTypes('CreateSessionServices', sessionServicesFactories, sessionServicesFactoryType),
|
|
58
|
+
};
|
|
59
|
+
if (errors.size > 0) {
|
|
60
|
+
const result = ['Found errors:'];
|
|
61
|
+
errors.forEach((filesAndMethods, message) => {
|
|
62
|
+
result.push(`- ${message}`);
|
|
63
|
+
filesAndMethods.forEach((methods, file) => {
|
|
64
|
+
result.push(`\t* methods: ${methods.map(({ variable, type }) => `${variable}: ${type}`).join(', ')}`);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
throw new Error(result.join('\n'));
|
|
68
|
+
}
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CLILogger } from './utils.js';
|
|
2
1
|
import { FunctionsMeta, JSONValue } from '@pikku/core';
|
|
3
2
|
import { HTTPWiringsMeta } from '@pikku/core/http';
|
|
4
3
|
import { TypesMap } from '@pikku/inspector';
|
|
4
|
+
import { CLILogger } from '../services/cli-logger.service.js';
|
|
5
5
|
export declare function generateSchemas(logger: CLILogger, tsconfig: string, typesMap: TypesMap, functionMeta: FunctionsMeta, httpWiringsMeta: HTTPWiringsMeta, additionalTypes?: string[]): Promise<Record<string, JSONValue>>;
|
|
6
6
|
export declare function saveSchemas(logger: CLILogger, schemaParentDir: string, schemas: Record<string, JSONValue>, typesMap: TypesMap, functionsMeta: FunctionsMeta, supportsImportAttributes: boolean, additionalTypes?: string[]): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createGenerator, RootlessError } from 'ts-json-schema-generator';
|
|
2
|
-
import { writeFileInDir } from './
|
|
2
|
+
import { writeFileInDir } from './file-writer.js';
|
|
3
3
|
import { mkdir, writeFile } from 'fs/promises';
|
|
4
4
|
export async function generateSchemas(logger, tsconfig, typesMap, functionMeta, httpWiringsMeta, additionalTypes) {
|
|
5
5
|
const schemasSet = new Set(typesMap.customTypes.keys());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getFileImportRelativePath } from './
|
|
1
|
+
import { getFileImportRelativePath } from './file-import-path.js';
|
|
2
2
|
export const serializeImportMap = (relativeToPath, packageMappings, typesMap, requiredTypes) => {
|
|
3
3
|
const paths = new Map();
|
|
4
4
|
Array.from(requiredTypes).forEach((requiredType) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../bin/pikku
|
|
1
|
+
{"root":["../bin/pikku.ts","../src/cli.wiring.ts","../src/serialize-pikku-types.ts","../src/services.ts","../src/functions/commands/all.ts","../src/functions/commands/watch.ts","../src/functions/runtimes/nextjs/pikku-command-nextjs.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/functions/wirings/channels/pikku-channels.ts","../src/functions/wirings/channels/pikku-command-channel-types.ts","../src/functions/wirings/channels/pikku-command-channels-map.ts","../src/functions/wirings/channels/pikku-command-channels.ts","../src/functions/wirings/channels/pikku-command-websocket-typed.ts","../src/functions/wirings/channels/serialize-channel-types.ts","../src/functions/wirings/channels/serialize-typed-channel-map.ts","../src/functions/wirings/channels/serialize-websocket-wrapper.ts","../src/functions/wirings/cli/pikku-command-cli-entry.ts","../src/functions/wirings/cli/pikku-command-cli-types.ts","../src/functions/wirings/cli/pikku-command-cli.ts","../src/functions/wirings/cli/serialize-channel-cli-client.ts","../src/functions/wirings/cli/serialize-channel-cli.ts","../src/functions/wirings/cli/serialize-cli-types.ts","../src/functions/wirings/cli/serialize-local-cli-bootstrap.ts","../src/functions/wirings/fetch/index.ts","../src/functions/wirings/functions/pikku-command-function-types-split.ts","../src/functions/wirings/functions/pikku-command-function-types.ts","../src/functions/wirings/functions/pikku-command-functions.ts","../src/functions/wirings/functions/pikku-command-services.ts","../src/functions/wirings/functions/pikku-function-types.ts","../src/functions/wirings/functions/schemas.ts","../src/functions/wirings/functions/serialize-function-imports.ts","../src/functions/wirings/functions/serialize-function-types.ts","../src/functions/wirings/functions/serialize-pikku-types-hub.ts","../src/functions/wirings/http/openapi-spec-generator.ts","../src/functions/wirings/http/pikku-command-http-map.ts","../src/functions/wirings/http/pikku-command-http-routes.ts","../src/functions/wirings/http/pikku-command-http-types.ts","../src/functions/wirings/http/pikku-command-openapi.ts","../src/functions/wirings/http/pikku-http-routes.ts","../src/functions/wirings/http/serialize-fetch-wrapper.ts","../src/functions/wirings/http/serialize-http-types.ts","../src/functions/wirings/http/serialize-typed-http-map.ts","../src/functions/wirings/mcp/pikku-command-mcp-json.ts","../src/functions/wirings/mcp/pikku-command-mcp-types.ts","../src/functions/wirings/mcp/pikku-command-mcp.ts","../src/functions/wirings/mcp/serialize-mcp-json.ts","../src/functions/wirings/mcp/serialize-mcp-types.ts","../src/functions/wirings/middleware/pikku-command-middleware.ts","../src/functions/wirings/middleware/serialize-middleware-groups-meta.ts","../src/functions/wirings/middleware/serialize-middleware-imports.ts","../src/functions/wirings/queue/pikku-command-queue-map.ts","../src/functions/wirings/queue/pikku-command-queue-service.ts","../src/functions/wirings/queue/pikku-command-queue-types.ts","../src/functions/wirings/queue/pikku-command-queue.ts","../src/functions/wirings/queue/pikku-queue-map.ts","../src/functions/wirings/queue/pikku-queue.ts","../src/functions/wirings/queue/serialize-queue-map.ts","../src/functions/wirings/queue/serialize-queue-meta.ts","../src/functions/wirings/queue/serialize-queue-types.ts","../src/functions/wirings/queue/serialize-queue-wrapper.ts","../src/functions/wirings/rpc/pikku-command-rpc-client.ts","../src/functions/wirings/rpc/pikku-command-rpc-map.ts","../src/functions/wirings/rpc/pikku-command-rpc.ts","../src/functions/wirings/rpc/serialize-rpc-wrapper.ts","../src/functions/wirings/rpc/serialize-typed-rpc-map.ts","../src/functions/wirings/scheduler/pikku-command-scheduler-types.ts","../src/functions/wirings/scheduler/pikku-command-scheduler.ts","../src/functions/wirings/scheduler/serialize-scheduler-meta.ts","../src/functions/wirings/scheduler/serialize-scheduler-types.ts","../src/middleware/log-command-info-and-time.ts","../src/services/cli-logger-forwarder.service.ts","../src/services/cli-logger.service.ts","../src/utils/check-required-types.ts","../src/utils/custom-types-generator.ts","../src/utils/file-import-path.ts","../src/utils/file-imports-serializer.ts","../src/utils/file-writer.ts","../src/utils/generate-bootstrap-file.ts","../src/utils/pikku-cli-config.ts","../src/utils/pikku-files-and-methods.ts","../src/utils/schema-generator.ts","../src/utils/serialize-import-map.ts","../.pikku/pikku-bootstrap.gen.ts","../.pikku/pikku-services.gen.ts","../.pikku/pikku-types.gen.ts","../.pikku/channel/pikku-channel-types.gen.ts","../.pikku/cli/pikku-cli-types.gen.ts","../.pikku/cli/pikku-cli-wirings-meta.gen.ts","../.pikku/cli/pikku-cli-wirings.gen.ts","../.pikku/function/pikku-function-types.gen.ts","../.pikku/function/pikku-functions-meta.gen.ts","../.pikku/function/pikku-functions-meta.min.gen.ts","../.pikku/function/pikku-functions.gen.ts","../.pikku/http/pikku-http-types.gen.ts","../.pikku/mcp/pikku-mcp-types.gen.ts","../.pikku/queue/pikku-queue-types.gen.ts","../.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts","../.pikku/scheduler/pikku-scheduler-types.gen.ts","../.pikku/schemas/register.gen.ts","../types/application-types.d.ts","../types/config.d.ts"],"version":"5.9.2"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.16-next.0",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"module": "dist/bin/pikku.js",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"tsc": "tsc",
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"build": "
|
|
14
|
+
"schema": "ts-json-schema-generator -o cli.schema.json --path 'src/utils/pikku-cli-config.ts' --type 'PikkuCLIConfig'",
|
|
15
|
+
"build": "yarn build:esm",
|
|
16
|
+
"build:esm": "./build.sh",
|
|
17
17
|
"ncu": "npx npm-check-updates -x '/.*glob.*/'",
|
|
18
18
|
"release": "yarn build && npm test",
|
|
19
19
|
"test": "bash run-tests.sh",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@openapi-contrib/json-schema-to-openapi-schema": "^4.0.2",
|
|
25
|
-
"@pikku/core": "^0.9.
|
|
26
|
-
"@pikku/inspector": "^0.9.
|
|
25
|
+
"@pikku/core": "^0.9.12-next.0",
|
|
26
|
+
"@pikku/inspector": "^0.9.6-next.0",
|
|
27
27
|
"@types/cookie": "^1.0.0",
|
|
28
28
|
"@types/uuid": "^10.0.0",
|
|
29
29
|
"chalk": "^5.5.0",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/pikkujs/pikku/refs/heads/main/packages/cli/cli.schema.json",
|
|
3
|
+
"tsconfig": "./tsconfig.json",
|
|
4
|
+
"srcDirectories": ["src", "bin", "types"],
|
|
5
|
+
"outDir": ".pikku",
|
|
6
|
+
"packageMappings": {
|
|
7
|
+
"../inspector/src": "@pikku/inspector"
|
|
8
|
+
},
|
|
9
|
+
"supportsImportAttributes": true,
|
|
10
|
+
"schemasFromTypes": ["PikkuCLIConfig"],
|
|
11
|
+
"websocketFile": ".pikku/pikku-websocket.gen.ts",
|
|
12
|
+
"cli": {
|
|
13
|
+
"entrypoints": {
|
|
14
|
+
"pikku": [
|
|
15
|
+
".pikku/cli/pikku-cli.gen.ts",
|
|
16
|
+
{
|
|
17
|
+
"type": "channel",
|
|
18
|
+
"wirePath": ".pikku/cli/pikku-channel.wire.gen.ts",
|
|
19
|
+
"path": ".pikku/cli/pikku-channel.client.gen.ts"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// import { pikkuSchemas } from './functions/wirings/functions/schemas.js'
|
|
2
|
+
// import { pikkuFetch } from './functions/wirings/fetch/index.js'
|
|
3
|
+
// import { pikkuWebSocketTyped } from './functions/wirings/channels/pikku-command-websocket-typed.js'
|
|
4
|
+
// import { pikkuRPCClient } from './functions/wirings/rpc/pikku-command-rpc-client.js'
|
|
5
|
+
// import { pikkuQueueService } from './functions/wirings/queue/pikku-command-queue-service.js'
|
|
6
|
+
// import { pikkuOpenAPI } from './functions/wirings/http/pikku-command-openapi.js'
|
|
7
|
+
// import { pikkuNext } from './functions/runtimes/nextjs/pikku-command-nextjs.js'
|
|
8
|
+
// import { pikkuCLICommand, wireCLI } from '../.pikku/cli/pikku-cli-types.gen.js'
|
|
9
|
+
// import { all } from './functions/commands/all.js'
|
|
10
|
+
// import { defaultCLIRenderer } from './services.js'
|
|
11
|
+
|
|
12
|
+
// wireCLI({
|
|
13
|
+
// program: 'pikku',
|
|
14
|
+
// description:
|
|
15
|
+
// 'Pikku CLI - Code generation tool for type-safe backend development',
|
|
16
|
+
// render: defaultCLIRenderer,
|
|
17
|
+
// options: {
|
|
18
|
+
// config: {
|
|
19
|
+
// description: 'Path to pikku.config.json file',
|
|
20
|
+
// short: 'c',
|
|
21
|
+
// },
|
|
22
|
+
// logLevel: {
|
|
23
|
+
// description: 'Set log level',
|
|
24
|
+
// default: 'info',
|
|
25
|
+
// short: 'l',
|
|
26
|
+
// },
|
|
27
|
+
// },
|
|
28
|
+
// commands: {
|
|
29
|
+
// all: pikkuCLICommand({
|
|
30
|
+
// func: all,
|
|
31
|
+
// description: 'Generate all Pikku files (types, schemas, wirings, etc.)',
|
|
32
|
+
// options: {
|
|
33
|
+
// tags: {
|
|
34
|
+
// description: 'Filter functions by tags (comma-separated)',
|
|
35
|
+
// short: 't',
|
|
36
|
+
// },
|
|
37
|
+
// types: {
|
|
38
|
+
// description: 'Filter functions by types (comma-separated)',
|
|
39
|
+
// },
|
|
40
|
+
// directories: {
|
|
41
|
+
// description: 'Filter functions by directories (comma-separated)',
|
|
42
|
+
// short: 'd',
|
|
43
|
+
// },
|
|
44
|
+
// },
|
|
45
|
+
// }),
|
|
46
|
+
// schemas: pikkuCLICommand({
|
|
47
|
+
// func: pikkuSchemas,
|
|
48
|
+
// description: 'Generate JSON schemas for function input/output types',
|
|
49
|
+
// }),
|
|
50
|
+
// fetch: pikkuCLICommand({
|
|
51
|
+
// func: pikkuFetch,
|
|
52
|
+
// description: 'Generate type-safe HTTP fetch client',
|
|
53
|
+
// }),
|
|
54
|
+
// websocket: pikkuCLICommand({
|
|
55
|
+
// func: pikkuWebSocketTyped,
|
|
56
|
+
// description: 'Generate type-safe WebSocket client',
|
|
57
|
+
// }),
|
|
58
|
+
// rpc: pikkuCLICommand({
|
|
59
|
+
// func: pikkuRPCClient,
|
|
60
|
+
// description: 'Generate RPC client wrappers',
|
|
61
|
+
// }),
|
|
62
|
+
// 'queue-service': pikkuCLICommand({
|
|
63
|
+
// func: pikkuQueueService,
|
|
64
|
+
// description: 'Generate queue service wrapper',
|
|
65
|
+
// }),
|
|
66
|
+
// openapi: pikkuCLICommand({
|
|
67
|
+
// func: pikkuOpenAPI,
|
|
68
|
+
// description: 'Generate OpenAPI specification from HTTP routes',
|
|
69
|
+
// }),
|
|
70
|
+
// nextjs: pikkuCLICommand({
|
|
71
|
+
// func: pikkuNext,
|
|
72
|
+
// description: 'Generate Next.js backend and HTTP wrappers',
|
|
73
|
+
// }),
|
|
74
|
+
// },
|
|
75
|
+
// })
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { existsSync } from 'fs'
|
|
2
|
+
import { pikkuVoidFunc } from '../../../.pikku/pikku-types.gen.js'
|
|
3
|
+
import { getFileImportRelativePath } from '../../utils/file-import-path.js'
|
|
4
|
+
import { writeFileInDir } from '../../utils/file-writer.js'
|
|
5
|
+
|
|
6
|
+
export const all: any = pikkuVoidFunc({
|
|
7
|
+
func: async ({ logger, config, rpc, getInspectorState }) => {
|
|
8
|
+
const allImports: string[] = []
|
|
9
|
+
let typesDeclarationFileExists = true
|
|
10
|
+
|
|
11
|
+
if (!existsSync(config.typesDeclarationFile)) {
|
|
12
|
+
typesDeclarationFileExists = false
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
await rpc.invoke('pikkuFunctionTypes', null)
|
|
16
|
+
|
|
17
|
+
// This is needed since the wireHTTP function will add the routes to the visitState
|
|
18
|
+
if (!typesDeclarationFileExists) {
|
|
19
|
+
logger.info(`• Type file first created, inspecting again...\x1b[0m`)
|
|
20
|
+
await getInspectorState(true)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Generate wiring-specific type files for tree-shaking
|
|
24
|
+
await rpc.invoke('pikkuFunctionTypesSplit', null)
|
|
25
|
+
await rpc.invoke('pikkuHTTPTypes', null)
|
|
26
|
+
await rpc.invoke('pikkuChannelTypes', null)
|
|
27
|
+
await rpc.invoke('pikkuSchedulerTypes', null)
|
|
28
|
+
await rpc.invoke('pikkuQueueTypes', null)
|
|
29
|
+
await rpc.invoke('pikkuMCPTypes', null)
|
|
30
|
+
await rpc.invoke('pikkuCLITypes', null)
|
|
31
|
+
|
|
32
|
+
const hasFunctionRegistrations = await rpc.invoke('pikkuFunctions', null)
|
|
33
|
+
|
|
34
|
+
// Generate and register middleware
|
|
35
|
+
const middleware = await rpc.invoke('pikkuMiddleware', null)
|
|
36
|
+
// Middleware must be imported before functions meta to ensure registration happens first
|
|
37
|
+
if (middleware) {
|
|
38
|
+
allImports.push(config.middlewareFile)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Always import functions meta (needed for all function metadata)
|
|
42
|
+
allImports.push(config.functionsMetaFile)
|
|
43
|
+
|
|
44
|
+
// Only import functionsFile if it was generated (has internal/external RPCs)
|
|
45
|
+
if (hasFunctionRegistrations) {
|
|
46
|
+
allImports.push(config.functionsFile)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Generate services map
|
|
50
|
+
await rpc.invoke('pikkuServices', null)
|
|
51
|
+
|
|
52
|
+
const hasInternalRPCs = await rpc.invoke('pikkuRPC', null)
|
|
53
|
+
await rpc.invoke('pikkuRPCInternalMap', null)
|
|
54
|
+
await rpc.invoke('pikkuRPCExposedMap', null)
|
|
55
|
+
await rpc.invoke('pikkuRPCClient', null)
|
|
56
|
+
|
|
57
|
+
if (hasInternalRPCs) {
|
|
58
|
+
allImports.push(config.rpcInternalWiringMetaFile)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const schemas = await rpc.invoke('pikkuSchemas', null)
|
|
62
|
+
if (schemas) {
|
|
63
|
+
allImports.push(`${config.schemaDirectory}/register.gen.ts`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Generate HTTP
|
|
67
|
+
const http = await rpc.invoke('pikkuHTTP', null)
|
|
68
|
+
if (http) {
|
|
69
|
+
await rpc.invoke('pikkuHTTPMap', null)
|
|
70
|
+
await rpc.invoke('pikkuFetch', null)
|
|
71
|
+
allImports.push(config.httpWiringMetaFile, config.httpWiringsFile)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Generate Scheduler
|
|
75
|
+
const scheduler = await rpc.invoke('pikkuScheduler', null)
|
|
76
|
+
if (scheduler) {
|
|
77
|
+
allImports.push(
|
|
78
|
+
config.schedulersWiringMetaFile,
|
|
79
|
+
config.schedulersWiringFile
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Generate Queues
|
|
84
|
+
const queues = await rpc.invoke('pikkuQueue', null)
|
|
85
|
+
if (queues) {
|
|
86
|
+
await rpc.invoke('pikkuQueueMap', null)
|
|
87
|
+
await rpc.invoke('pikkuQueueService', null)
|
|
88
|
+
allImports.push(
|
|
89
|
+
config.queueWorkersWiringMetaFile,
|
|
90
|
+
config.queueWorkersWiringFile
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Generate Channels
|
|
95
|
+
const channels = await rpc.invoke('pikkuChannels', null)
|
|
96
|
+
if (channels) {
|
|
97
|
+
await rpc.invoke('pikkuChannelsMap', null)
|
|
98
|
+
await rpc.invoke('pikkuWebSocketTyped', null)
|
|
99
|
+
allImports.push(config.channelsWiringMetaFile, config.channelsWiringFile)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Generate MCP
|
|
103
|
+
const mcp = await rpc.invoke('pikkuMCP', null)
|
|
104
|
+
if (mcp) {
|
|
105
|
+
await rpc.invoke('pikkuMCPJSON', null)
|
|
106
|
+
allImports.push(config.mcpWiringsMetaFile, config.mcpWiringsFile)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Generate CLI
|
|
110
|
+
const cli = await rpc.invoke('pikkuCLI', null)
|
|
111
|
+
if (cli) {
|
|
112
|
+
await rpc.invoke('pikkuCLIEntry', null)
|
|
113
|
+
allImports.push(config.cliWiringMetaFile, config.cliWiringsFile)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (config.nextBackendFile || config.nextHTTPFile) {
|
|
117
|
+
await rpc.invoke('pikkuNext', null)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (config.openAPI) {
|
|
121
|
+
logger.info(
|
|
122
|
+
`• OpenAPI requires a reinspection to pickup new generated types..`
|
|
123
|
+
)
|
|
124
|
+
await getInspectorState(true)
|
|
125
|
+
await rpc.invoke('pikkuOpenAPI', null)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Generate main bootstrap file (pass all imports directly since this is the main file)
|
|
129
|
+
await writeFileInDir(
|
|
130
|
+
logger,
|
|
131
|
+
config.bootstrapFile,
|
|
132
|
+
allImports
|
|
133
|
+
.map(
|
|
134
|
+
(to) =>
|
|
135
|
+
`import '${getFileImportRelativePath(config.bootstrapFile, to, config.packageMappings)}'`
|
|
136
|
+
)
|
|
137
|
+
.sort((to) => (to.includes('meta') ? -1 : 1)) // Ensure meta files are at the top
|
|
138
|
+
.join('\n')
|
|
139
|
+
)
|
|
140
|
+
},
|
|
141
|
+
})
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { pikkuVoidFunc } from '../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import chokidar from 'chokidar'
|
|
3
|
+
|
|
4
|
+
export const watch: any = pikkuVoidFunc({
|
|
5
|
+
func: async ({ logger, config, rpc }) => {
|
|
6
|
+
const configWatcher = chokidar.watch(config.srcDirectories, {
|
|
7
|
+
ignoreInitial: true,
|
|
8
|
+
ignored: /.*\.gen\.tsx?/,
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
let watcher = new chokidar.FSWatcher({})
|
|
12
|
+
|
|
13
|
+
const generatorWatcher = () => {
|
|
14
|
+
watcher.close()
|
|
15
|
+
|
|
16
|
+
logger.info(
|
|
17
|
+
`• Watching directories: \n - ${config.srcDirectories.join('\n - ')}`
|
|
18
|
+
)
|
|
19
|
+
watcher = chokidar.watch(config.srcDirectories, {
|
|
20
|
+
ignoreInitial: true,
|
|
21
|
+
ignored: /.*\.gen\.ts/,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
watcher.on('ready', async () => {
|
|
25
|
+
const handle = async () => {
|
|
26
|
+
try {
|
|
27
|
+
const start = Date.now()
|
|
28
|
+
await rpc.invoke('all', null)
|
|
29
|
+
logger.info({
|
|
30
|
+
message: `✓ Generated in ${Date.now() - start}ms`,
|
|
31
|
+
type: 'timing',
|
|
32
|
+
})
|
|
33
|
+
} catch (err) {
|
|
34
|
+
logger.error(err)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await handle()
|
|
39
|
+
|
|
40
|
+
let timeout: ReturnType<typeof setTimeout> | undefined
|
|
41
|
+
|
|
42
|
+
const deduped = (_file: string) => {
|
|
43
|
+
if (timeout) {
|
|
44
|
+
clearTimeout(timeout)
|
|
45
|
+
}
|
|
46
|
+
timeout = setTimeout(handle, 10)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
watcher.on('change', deduped)
|
|
50
|
+
watcher.on('add', deduped)
|
|
51
|
+
watcher.on('unlink', deduped)
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
configWatcher.on('ready', generatorWatcher)
|
|
56
|
+
configWatcher.on('change', generatorWatcher)
|
|
57
|
+
},
|
|
58
|
+
})
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { checkRequiredTypes } from '../../../utils/check-required-types.js'
|
|
3
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
4
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
5
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
6
|
+
import { serializeNextJsBackendWrapper as serializeNextBackendWrapper } from './serialize-nextjs-backend-wrapper.js'
|
|
7
|
+
import { serializeNextJsHTTPWrapper as serializeNextHTTPWrapper } from './serialize-nextjs-http-wrapper.js'
|
|
8
|
+
|
|
9
|
+
export const pikkuNext: any = pikkuSessionlessFunc<void, void>({
|
|
10
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
11
|
+
const {
|
|
12
|
+
nextBackendFile,
|
|
13
|
+
nextHTTPFile,
|
|
14
|
+
httpMapDeclarationFile,
|
|
15
|
+
packageMappings,
|
|
16
|
+
fetchFile,
|
|
17
|
+
bootstrapFiles,
|
|
18
|
+
} = config
|
|
19
|
+
const visitState = await getInspectorState()
|
|
20
|
+
|
|
21
|
+
if (!nextBackendFile && !nextHTTPFile) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
'nextBackendFile or nextHTTPFile is required in pikku config for nextJS'
|
|
24
|
+
)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (nextHTTPFile && !fetchFile) {
|
|
28
|
+
throw new Error(
|
|
29
|
+
'fetchFile is required in pikku config in order for nextJS http wrapper to work'
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (nextBackendFile) {
|
|
34
|
+
// Check for required types
|
|
35
|
+
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
36
|
+
config: true,
|
|
37
|
+
singletonServicesFactory: true,
|
|
38
|
+
sessionServicesFactory: true,
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
pikkuConfigFactory,
|
|
43
|
+
singletonServicesFactory,
|
|
44
|
+
sessionServicesFactory,
|
|
45
|
+
} = visitState.filesAndMethods
|
|
46
|
+
|
|
47
|
+
if (
|
|
48
|
+
!pikkuConfigFactory ||
|
|
49
|
+
!singletonServicesFactory ||
|
|
50
|
+
!sessionServicesFactory
|
|
51
|
+
) {
|
|
52
|
+
throw new Error('Required types not found')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const pikkuConfigImport = `import { ${pikkuConfigFactory.variable} as createConfig } from '${getFileImportRelativePath(nextBackendFile, pikkuConfigFactory.file, packageMappings)}'`
|
|
56
|
+
const singletonServicesImport = `import { ${singletonServicesFactory.variable} as createSingletonServices } from '${getFileImportRelativePath(nextBackendFile, singletonServicesFactory.file, packageMappings)}'`
|
|
57
|
+
const sessionServicesImport = `import { ${sessionServicesFactory.variable} as createSessionServices } from '${getFileImportRelativePath(nextBackendFile, sessionServicesFactory.file, packageMappings)}'`
|
|
58
|
+
|
|
59
|
+
const httpBootstrapPath = getFileImportRelativePath(
|
|
60
|
+
nextBackendFile,
|
|
61
|
+
bootstrapFiles.http,
|
|
62
|
+
packageMappings
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
66
|
+
nextBackendFile,
|
|
67
|
+
httpMapDeclarationFile,
|
|
68
|
+
packageMappings
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
const content = serializeNextBackendWrapper(
|
|
72
|
+
httpBootstrapPath,
|
|
73
|
+
routesMapDeclarationPath,
|
|
74
|
+
pikkuConfigImport,
|
|
75
|
+
singletonServicesImport,
|
|
76
|
+
sessionServicesImport
|
|
77
|
+
)
|
|
78
|
+
await writeFileInDir(logger, nextBackendFile, content)
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (nextHTTPFile && fetchFile) {
|
|
82
|
+
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
83
|
+
nextHTTPFile,
|
|
84
|
+
httpMapDeclarationFile,
|
|
85
|
+
packageMappings
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
const fetchPath = getFileImportRelativePath(
|
|
89
|
+
nextHTTPFile,
|
|
90
|
+
fetchFile,
|
|
91
|
+
packageMappings
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
const content = serializeNextHTTPWrapper(
|
|
95
|
+
routesMapDeclarationPath,
|
|
96
|
+
fetchPath
|
|
97
|
+
)
|
|
98
|
+
await writeFileInDir(logger, nextHTTPFile, content)
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
middleware: [
|
|
102
|
+
logCommandInfoAndTime({
|
|
103
|
+
commandStart: 'Generating nextjs wrapper',
|
|
104
|
+
commandEnd: 'Generated nextjs wrapper',
|
|
105
|
+
skipCondition: ({ config }) =>
|
|
106
|
+
config.nextBackendFile === undefined &&
|
|
107
|
+
config.nextHTTPFile === undefined,
|
|
108
|
+
skipMessage: 'nextjs outfile is not defined',
|
|
109
|
+
}),
|
|
110
|
+
],
|
|
111
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { pikkuVoidFunc } 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 pikkuChannels: any = pikkuVoidFunc({
|
|
7
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
8
|
+
const visitState = await getInspectorState()
|
|
9
|
+
const { channelsWiringFile, channelsWiringMetaFile, packageMappings } =
|
|
10
|
+
config
|
|
11
|
+
const { channels } = visitState
|
|
12
|
+
|
|
13
|
+
await writeFileInDir(
|
|
14
|
+
logger,
|
|
15
|
+
channelsWiringFile,
|
|
16
|
+
serializeFileImports(
|
|
17
|
+
'addChannel',
|
|
18
|
+
channelsWiringFile,
|
|
19
|
+
channels.files,
|
|
20
|
+
packageMappings
|
|
21
|
+
)
|
|
22
|
+
)
|
|
23
|
+
await writeFileInDir(
|
|
24
|
+
logger,
|
|
25
|
+
channelsWiringMetaFile,
|
|
26
|
+
`import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`
|
|
27
|
+
)
|
|
28
|
+
},
|
|
29
|
+
middleware: [
|
|
30
|
+
logCommandInfoAndTime({
|
|
31
|
+
commandStart: 'Finding Channels',
|
|
32
|
+
commandEnd: 'Found channels',
|
|
33
|
+
skipCondition: async ({ getInspectorState }: any) => {
|
|
34
|
+
const visitState = await getInspectorState()
|
|
35
|
+
return visitState.channels.files.size === 0
|
|
36
|
+
},
|
|
37
|
+
skipMessage: 'none found',
|
|
38
|
+
}),
|
|
39
|
+
],
|
|
40
|
+
})
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { serializeChannelTypes } from './serialize-channel-types.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuChannelTypes: any = pikkuSessionlessFunc<void, void>({
|
|
8
|
+
func: async ({ logger, config }) => {
|
|
9
|
+
const { channelsTypesFile, functionTypesFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const functionTypesImportPath = getFileImportRelativePath(
|
|
12
|
+
channelsTypesFile,
|
|
13
|
+
functionTypesFile,
|
|
14
|
+
packageMappings
|
|
15
|
+
)
|
|
16
|
+
const content = serializeChannelTypes(functionTypesImportPath)
|
|
17
|
+
await writeFileInDir(logger, channelsTypesFile, content)
|
|
18
|
+
},
|
|
19
|
+
middleware: [
|
|
20
|
+
logCommandInfoAndTime({
|
|
21
|
+
commandStart: 'Creating channel types',
|
|
22
|
+
commandEnd: 'Created channel types',
|
|
23
|
+
skipCondition: false,
|
|
24
|
+
skipMessage: '',
|
|
25
|
+
}),
|
|
26
|
+
],
|
|
27
|
+
})
|