@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
package/src/schemas.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { saveSchemas, generateSchemas } from './schema-generator.js'
|
|
2
|
-
import { logCommandInfoAndTime } from './utils.js'
|
|
3
|
-
import { PikkuCommand } from './types.js'
|
|
4
|
-
|
|
5
|
-
export const pikkuSchemas: PikkuCommand = async (
|
|
6
|
-
logger,
|
|
7
|
-
{ tsconfig, schemaDirectory, supportsImportAttributes, schemasFromTypes },
|
|
8
|
-
{ functions, http }
|
|
9
|
-
) => {
|
|
10
|
-
return await logCommandInfoAndTime(
|
|
11
|
-
logger,
|
|
12
|
-
'Creating schemas',
|
|
13
|
-
'Created schemas',
|
|
14
|
-
[false],
|
|
15
|
-
async () => {
|
|
16
|
-
const schemas = await generateSchemas(
|
|
17
|
-
logger,
|
|
18
|
-
tsconfig,
|
|
19
|
-
functions.typesMap,
|
|
20
|
-
functions.meta,
|
|
21
|
-
http.meta,
|
|
22
|
-
schemasFromTypes
|
|
23
|
-
)
|
|
24
|
-
await saveSchemas(
|
|
25
|
-
logger,
|
|
26
|
-
schemaDirectory,
|
|
27
|
-
schemas,
|
|
28
|
-
functions.typesMap,
|
|
29
|
-
functions.meta,
|
|
30
|
-
supportsImportAttributes,
|
|
31
|
-
schemasFromTypes
|
|
32
|
-
)
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { InspectorState } from '@pikku/inspector'
|
|
2
|
-
import { PikkuCLIConfig } from './pikku-cli-config.js'
|
|
3
|
-
import { CLILogger, PikkuCLIOptions } from './utils.js'
|
|
4
|
-
|
|
5
|
-
export type PikkuCommand = (
|
|
6
|
-
logger: CLILogger,
|
|
7
|
-
cliConfig: PikkuCLIConfig,
|
|
8
|
-
visitState: InspectorState,
|
|
9
|
-
options?: PikkuCLIOptions
|
|
10
|
-
) => Promise<boolean>
|
|
11
|
-
|
|
12
|
-
export type PikkuCommandWithoutState = (
|
|
13
|
-
logger: CLILogger,
|
|
14
|
-
cliConfig: PikkuCLIConfig,
|
|
15
|
-
options?: PikkuCLIOptions
|
|
16
|
-
) => Promise<boolean>
|
package/src/utils.ts
DELETED
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import { relative, dirname, resolve } from 'path'
|
|
2
|
-
import { PathToNameAndType, InspectorState, TypesMap } from '@pikku/inspector'
|
|
3
|
-
import { mkdir, readFile, writeFile } from 'fs/promises'
|
|
4
|
-
import chalk from 'chalk'
|
|
5
|
-
import { fileURLToPath } from 'url'
|
|
6
|
-
import { readFileSync } from 'fs'
|
|
7
|
-
|
|
8
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
9
|
-
|
|
10
|
-
const logo = `
|
|
11
|
-
______ _ _ _
|
|
12
|
-
(_____ (_) | | |
|
|
13
|
-
_____) )| | _| | _ _ _
|
|
14
|
-
| ____/ | |_/ ) |_/ ) | | |
|
|
15
|
-
| | | | _ (| _ (| |_| |
|
|
16
|
-
|_| |_|_| _)_| _)____/
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
export class CLILogger {
|
|
20
|
-
private silent: boolean
|
|
21
|
-
|
|
22
|
-
constructor({
|
|
23
|
-
logLogo,
|
|
24
|
-
silent = false,
|
|
25
|
-
}: {
|
|
26
|
-
logLogo: boolean
|
|
27
|
-
silent?: boolean
|
|
28
|
-
}) {
|
|
29
|
-
this.silent = silent
|
|
30
|
-
if (logLogo && !silent) {
|
|
31
|
-
this.logPikkuLogo()
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
primary(message: string) {
|
|
36
|
-
if (!this.silent) {
|
|
37
|
-
console.log(chalk.green(message))
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
success(message: string) {
|
|
41
|
-
if (!this.silent) {
|
|
42
|
-
console.log(chalk.green(message))
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
info(message: string) {
|
|
46
|
-
if (!this.silent) {
|
|
47
|
-
console.log(chalk.blue(message))
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
error(message: string) {
|
|
51
|
-
console.error(chalk.red(message))
|
|
52
|
-
}
|
|
53
|
-
warn(message: string) {
|
|
54
|
-
console.error(chalk.yellow(message))
|
|
55
|
-
}
|
|
56
|
-
debug(message: string) {
|
|
57
|
-
if (process.env.DEBUG && !this.silent) {
|
|
58
|
-
console.log(chalk.gray(message))
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
timing(message: string) {
|
|
63
|
-
console.log(chalk.gray(message))
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private logPikkuLogo() {
|
|
67
|
-
this.primary(logo)
|
|
68
|
-
const packageJson = JSON.parse(
|
|
69
|
-
readFileSync(`${dirname(__filename)}/../../package.json`, 'utf-8')
|
|
70
|
-
)
|
|
71
|
-
this.primary(`⚙️ Welcome to the Pikku CLI (v${packageJson.version})\n`)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export const getFileImportRelativePath = (
|
|
76
|
-
from: string,
|
|
77
|
-
to: string,
|
|
78
|
-
packageMappings: Record<string, string>
|
|
79
|
-
): string => {
|
|
80
|
-
let filePath = relative(dirname(from), to)
|
|
81
|
-
if (!/^\.+\//.test(filePath)) {
|
|
82
|
-
filePath = `./${filePath}`
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// If the path includes node_modules, strip everything before and including node_modules/
|
|
86
|
-
if (filePath.includes('node_modules')) {
|
|
87
|
-
const nodeModulesIndex = filePath.indexOf('node_modules/')
|
|
88
|
-
if (nodeModulesIndex !== -1) {
|
|
89
|
-
filePath = filePath.substring(nodeModulesIndex + 'node_modules/'.length)
|
|
90
|
-
}
|
|
91
|
-
return filePath.replace('.ts', '.js')
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const absolutePath = resolve(dirname(from), to)
|
|
95
|
-
const fromAbsolutePath = resolve(dirname(from))
|
|
96
|
-
|
|
97
|
-
// Check if both files are in the same package directory
|
|
98
|
-
// If so, skip packageMappings to use relative paths
|
|
99
|
-
let inSamePackage = false
|
|
100
|
-
for (const [path] of Object.entries(packageMappings)) {
|
|
101
|
-
if (absolutePath.includes(path) && fromAbsolutePath.includes(path)) {
|
|
102
|
-
inSamePackage = true
|
|
103
|
-
break
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Only apply packageMappings if files are not in the same package
|
|
108
|
-
if (!inSamePackage) {
|
|
109
|
-
// let usesPackageName = false
|
|
110
|
-
for (const [path, packageName] of Object.entries(packageMappings)) {
|
|
111
|
-
if (absolutePath.includes(path)) {
|
|
112
|
-
// usesPackageName = true
|
|
113
|
-
filePath = absolutePath.replace(new RegExp(`.*${path}`), packageName)
|
|
114
|
-
break
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// if (usesPackageName) {
|
|
120
|
-
// return filePath.replace('.ts', '')
|
|
121
|
-
// }
|
|
122
|
-
return filePath.replace('.ts', '.js')
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
interface Meta {
|
|
126
|
-
file: string
|
|
127
|
-
variable: string
|
|
128
|
-
type: string
|
|
129
|
-
typePath: string
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export type FilesAndMethods = {
|
|
133
|
-
userSessionType: Meta
|
|
134
|
-
sessionServicesType: Meta
|
|
135
|
-
singletonServicesType: Meta
|
|
136
|
-
pikkuConfigFactory: Meta
|
|
137
|
-
singletonServicesFactory: Meta
|
|
138
|
-
sessionServicesFactory: Meta
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface PikkuCLIOptions {
|
|
142
|
-
watch?: boolean
|
|
143
|
-
config?: string
|
|
144
|
-
configFileType?: string
|
|
145
|
-
userSessionType?: string
|
|
146
|
-
singletonServicesFactoryType?: string
|
|
147
|
-
sessionServicesFactoryType?: string
|
|
148
|
-
tags?: string[]
|
|
149
|
-
types?: string[]
|
|
150
|
-
directories?: string[]
|
|
151
|
-
silent?: boolean
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const getMetaTypes = (
|
|
155
|
-
type: string,
|
|
156
|
-
errors: Map<string, PathToNameAndType>,
|
|
157
|
-
map: PathToNameAndType,
|
|
158
|
-
desiredType?: string
|
|
159
|
-
) => {
|
|
160
|
-
if (desiredType) {
|
|
161
|
-
const entries = Object.entries(map)
|
|
162
|
-
for (const [file, meta] of entries) {
|
|
163
|
-
for (const { type, variable, typePath } of meta) {
|
|
164
|
-
if (type === desiredType) {
|
|
165
|
-
return { file, variable, type, typePath }
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
errors.set(`No ${desiredType} found that extends ${type}`, map)
|
|
170
|
-
return undefined
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const totalValues = Object.values(map).flat()
|
|
174
|
-
if (totalValues.length === 0) {
|
|
175
|
-
errors.set(`No ${type} found`, map)
|
|
176
|
-
} else if (totalValues.length > 1) {
|
|
177
|
-
errors.set(`More than one ${type} found`, map)
|
|
178
|
-
} else {
|
|
179
|
-
const entry = Object.entries(map)[0]
|
|
180
|
-
if (entry) {
|
|
181
|
-
const [file, [{ type, variable, typePath }]] = entry
|
|
182
|
-
return { file, type, variable, typePath }
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
return undefined
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export const getPikkuFilesAndMethods = async (
|
|
190
|
-
logger: CLILogger,
|
|
191
|
-
{
|
|
192
|
-
singletonServicesTypeImportMap,
|
|
193
|
-
sessionServicesTypeImportMap,
|
|
194
|
-
userSessionTypeImportMap,
|
|
195
|
-
sessionServicesFactories,
|
|
196
|
-
singletonServicesFactories,
|
|
197
|
-
configFactories,
|
|
198
|
-
}: InspectorState,
|
|
199
|
-
packageMappings: Record<string, string>,
|
|
200
|
-
outputFile: string,
|
|
201
|
-
{
|
|
202
|
-
configFileType,
|
|
203
|
-
singletonServicesFactoryType,
|
|
204
|
-
sessionServicesFactoryType,
|
|
205
|
-
}: PikkuCLIOptions,
|
|
206
|
-
requires: Partial<{
|
|
207
|
-
config: boolean
|
|
208
|
-
sessionServiceType: boolean
|
|
209
|
-
singletonServicesType: boolean
|
|
210
|
-
userSessionType: boolean
|
|
211
|
-
singletonServicesFactory: boolean
|
|
212
|
-
sessionServicesFactory: boolean
|
|
213
|
-
}> = {
|
|
214
|
-
config: false,
|
|
215
|
-
singletonServicesType: false,
|
|
216
|
-
sessionServiceType: false,
|
|
217
|
-
userSessionType: false,
|
|
218
|
-
singletonServicesFactory: false,
|
|
219
|
-
sessionServicesFactory: false,
|
|
220
|
-
}
|
|
221
|
-
): Promise<FilesAndMethods> => {
|
|
222
|
-
let errors = new Map<string, PathToNameAndType>()
|
|
223
|
-
|
|
224
|
-
const result: Partial<FilesAndMethods> = {
|
|
225
|
-
userSessionType: getMetaTypes(
|
|
226
|
-
'CoreUserSession',
|
|
227
|
-
requires.userSessionType ? errors : new Map(),
|
|
228
|
-
userSessionTypeImportMap,
|
|
229
|
-
configFileType
|
|
230
|
-
),
|
|
231
|
-
singletonServicesType: getMetaTypes(
|
|
232
|
-
'CoreSingletonServices',
|
|
233
|
-
requires.singletonServicesType ? errors : new Map(),
|
|
234
|
-
singletonServicesTypeImportMap
|
|
235
|
-
),
|
|
236
|
-
sessionServicesType: getMetaTypes(
|
|
237
|
-
'CoreServices',
|
|
238
|
-
requires.sessionServiceType ? errors : new Map(),
|
|
239
|
-
sessionServicesTypeImportMap
|
|
240
|
-
),
|
|
241
|
-
pikkuConfigFactory: getMetaTypes(
|
|
242
|
-
'CoreConfig',
|
|
243
|
-
requires.config ? errors : new Map(),
|
|
244
|
-
configFactories,
|
|
245
|
-
configFileType
|
|
246
|
-
),
|
|
247
|
-
singletonServicesFactory: getMetaTypes(
|
|
248
|
-
'CreateSingletonServices',
|
|
249
|
-
requires.singletonServicesFactory ? errors : new Map(),
|
|
250
|
-
singletonServicesFactories,
|
|
251
|
-
singletonServicesFactoryType
|
|
252
|
-
),
|
|
253
|
-
sessionServicesFactory: getMetaTypes(
|
|
254
|
-
'CreateSessionServices',
|
|
255
|
-
requires.sessionServicesFactory ? errors : new Map(),
|
|
256
|
-
sessionServicesFactories,
|
|
257
|
-
sessionServicesFactoryType
|
|
258
|
-
),
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
if (errors.size > 0) {
|
|
262
|
-
const result: string[] = ['Found errors:']
|
|
263
|
-
errors.forEach((filesAndMethods, message) => {
|
|
264
|
-
result.push(`- ${message}`)
|
|
265
|
-
for (const [file, methods] of Object.entries(filesAndMethods)) {
|
|
266
|
-
result.push(
|
|
267
|
-
`\t* file: ${getFileImportRelativePath(outputFile, file, packageMappings)}`
|
|
268
|
-
)
|
|
269
|
-
result.push(
|
|
270
|
-
`\t* methods: ${methods.map(({ variable, type }) => `${variable}: ${type}`).join(', ')}`
|
|
271
|
-
)
|
|
272
|
-
}
|
|
273
|
-
})
|
|
274
|
-
|
|
275
|
-
logger.error(result.join('\n'))
|
|
276
|
-
process.exit(1)
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
return result as FilesAndMethods
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
export const writeFileInDir = async (
|
|
283
|
-
logger: CLILogger,
|
|
284
|
-
path: string,
|
|
285
|
-
content: string,
|
|
286
|
-
{
|
|
287
|
-
ignoreModifyComment = false,
|
|
288
|
-
logWrite = true,
|
|
289
|
-
}: { ignoreModifyComment?: boolean; logWrite?: boolean } = {}
|
|
290
|
-
) => {
|
|
291
|
-
if (path.includes('.json')) {
|
|
292
|
-
ignoreModifyComment = true
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (content.includes('server-only')) {
|
|
296
|
-
content = content.replace(
|
|
297
|
-
"'server-only'",
|
|
298
|
-
`'server-only'\n\n${ignoreModifyComment ? '' : DO_NOT_MODIFY_COMMENT}`
|
|
299
|
-
)
|
|
300
|
-
} else {
|
|
301
|
-
content = `${ignoreModifyComment ? '' : DO_NOT_MODIFY_COMMENT}${content}`
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
// Try to read existing file content
|
|
305
|
-
let existingContent: string | undefined
|
|
306
|
-
try {
|
|
307
|
-
existingContent = await readFile(path, 'utf-8')
|
|
308
|
-
} catch (error) {
|
|
309
|
-
// File doesn't exist, so we need to write it
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// Only write if content has changed or file doesn't exist
|
|
313
|
-
if (existingContent !== content) {
|
|
314
|
-
await mkdir(dirname(path), { recursive: true })
|
|
315
|
-
await writeFile(path, content, 'utf-8')
|
|
316
|
-
|
|
317
|
-
if (logWrite) {
|
|
318
|
-
logger.success(`✓ File written to ${path}`)
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
export const logCommandInfoAndTime = async (
|
|
324
|
-
logger: CLILogger,
|
|
325
|
-
commandStart: string,
|
|
326
|
-
commandEnd: string,
|
|
327
|
-
[skipCondition, skipMessage = 'none found']: [boolean] | [boolean, string],
|
|
328
|
-
callback: (...args: any[]) => Promise<unknown>
|
|
329
|
-
): Promise<boolean> => {
|
|
330
|
-
if (skipCondition === true) {
|
|
331
|
-
logger.info(
|
|
332
|
-
`• Skipping ${commandStart.charAt(0).toLocaleLowerCase()}${commandStart.slice(1)} since ${skipMessage}.`
|
|
333
|
-
)
|
|
334
|
-
return false
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const start = Date.now()
|
|
338
|
-
chalk.blue(`• ${commandStart}...`)
|
|
339
|
-
await callback()
|
|
340
|
-
|
|
341
|
-
logger.success(`✓ ${commandEnd} in ${Date.now() - start}ms.`)
|
|
342
|
-
return true
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// TODO: add version back in once the ESM dust settles
|
|
346
|
-
export const DO_NOT_MODIFY_COMMENT = `/**
|
|
347
|
-
* This file was generated by the @pikku/cli
|
|
348
|
-
*/
|
|
349
|
-
`
|
|
350
|
-
|
|
351
|
-
export const serializeFileImports = (
|
|
352
|
-
importType: string,
|
|
353
|
-
outputPath: string,
|
|
354
|
-
files: Set<string>,
|
|
355
|
-
packageMappings: Record<string, string> = {}
|
|
356
|
-
) => {
|
|
357
|
-
const serializedOutput: string[] = [
|
|
358
|
-
`/* The files with an ${importType} function call */`,
|
|
359
|
-
]
|
|
360
|
-
|
|
361
|
-
Array.from(files)
|
|
362
|
-
.sort()
|
|
363
|
-
.forEach((path) => {
|
|
364
|
-
const filePath = getFileImportRelativePath(
|
|
365
|
-
outputPath,
|
|
366
|
-
path,
|
|
367
|
-
packageMappings
|
|
368
|
-
)
|
|
369
|
-
serializedOutput.push(`import '${filePath}'`)
|
|
370
|
-
})
|
|
371
|
-
|
|
372
|
-
return serializedOutput.join('\n')
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
export function generateCustomTypes(
|
|
376
|
-
typesMap: TypesMap,
|
|
377
|
-
requiredTypes: Set<string>
|
|
378
|
-
) {
|
|
379
|
-
return `
|
|
380
|
-
// Custom types are those that are defined directly within generics
|
|
381
|
-
// or are broken into simpler types
|
|
382
|
-
${Array.from(typesMap.customTypes.entries())
|
|
383
|
-
.map(([name, { type, references }]) => {
|
|
384
|
-
references.forEach((name) => {
|
|
385
|
-
requiredTypes.add(name)
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
// Extract type names from the type string that might not be in references
|
|
389
|
-
const typeString = type
|
|
390
|
-
// Use regex to extract potential type names (PascalCase identifiers)
|
|
391
|
-
const typeNameRegex = /\b[A-Z][a-zA-Z0-9]*\b/g
|
|
392
|
-
const potentialTypes = typeString.match(typeNameRegex) || []
|
|
393
|
-
|
|
394
|
-
potentialTypes.forEach((typeName) => {
|
|
395
|
-
// Skip string literals and common keywords
|
|
396
|
-
if (
|
|
397
|
-
typeString.includes(`"${typeName}"`) ||
|
|
398
|
-
['Pick', 'Omit', 'Partial', 'Required', 'Record', 'Readonly'].includes(
|
|
399
|
-
typeName
|
|
400
|
-
)
|
|
401
|
-
) {
|
|
402
|
-
return
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// Try to find this type in the typesMap and add it if found
|
|
406
|
-
try {
|
|
407
|
-
const typeMeta = typesMap.getTypeMeta(typeName)
|
|
408
|
-
if (typeMeta.path) {
|
|
409
|
-
requiredTypes.add(typeName)
|
|
410
|
-
}
|
|
411
|
-
} catch (e) {
|
|
412
|
-
// Type not found in map, but add it anyway for fallback resolution
|
|
413
|
-
requiredTypes.add(typeName)
|
|
414
|
-
}
|
|
415
|
-
})
|
|
416
|
-
|
|
417
|
-
return `export type ${name} = ${type}`
|
|
418
|
-
})
|
|
419
|
-
.join('\n')}`
|
|
420
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { PikkuCLIConfig } from '../../pikku-cli-config.js'
|
|
2
|
-
import { InspectorState } from '@pikku/inspector'
|
|
3
|
-
import {
|
|
4
|
-
logCommandInfoAndTime,
|
|
5
|
-
serializeFileImports,
|
|
6
|
-
writeFileInDir,
|
|
7
|
-
} from '../../utils.js'
|
|
8
|
-
import { PikkuCommand } from '../../types.js'
|
|
9
|
-
|
|
10
|
-
export const pikkuChannels: PikkuCommand = async (
|
|
11
|
-
logger,
|
|
12
|
-
cliConfig: PikkuCLIConfig,
|
|
13
|
-
visitState: InspectorState
|
|
14
|
-
) => {
|
|
15
|
-
return await logCommandInfoAndTime(
|
|
16
|
-
logger,
|
|
17
|
-
'Finding Channels',
|
|
18
|
-
'Found channels',
|
|
19
|
-
[visitState.channels.files.size === 0],
|
|
20
|
-
async () => {
|
|
21
|
-
const { channelsWiringFile, channelsWiringMetaFile, packageMappings } =
|
|
22
|
-
cliConfig
|
|
23
|
-
const { channels } = visitState
|
|
24
|
-
await writeFileInDir(
|
|
25
|
-
logger,
|
|
26
|
-
channelsWiringFile,
|
|
27
|
-
serializeFileImports(
|
|
28
|
-
'addChannel',
|
|
29
|
-
channelsWiringFile,
|
|
30
|
-
channels.files,
|
|
31
|
-
packageMappings
|
|
32
|
-
)
|
|
33
|
-
)
|
|
34
|
-
await writeFileInDir(
|
|
35
|
-
logger,
|
|
36
|
-
channelsWiringMetaFile,
|
|
37
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`
|
|
38
|
-
)
|
|
39
|
-
}
|
|
40
|
-
)
|
|
41
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { logCommandInfoAndTime, writeFileInDir } from '../../utils.js'
|
|
2
|
-
import { serializeTypedChannelsMap } from './serialize-typed-channel-map.js'
|
|
3
|
-
import { PikkuCommand } from '../../types.js'
|
|
4
|
-
|
|
5
|
-
export const pikkuChannelsMap: PikkuCommand = async (
|
|
6
|
-
logger,
|
|
7
|
-
{ channelsMapDeclarationFile, packageMappings },
|
|
8
|
-
state
|
|
9
|
-
) => {
|
|
10
|
-
return await logCommandInfoAndTime(
|
|
11
|
-
logger,
|
|
12
|
-
'Creating channels map',
|
|
13
|
-
'Created channels map',
|
|
14
|
-
[state.channels.files.size === 0],
|
|
15
|
-
async () => {
|
|
16
|
-
const content = serializeTypedChannelsMap(
|
|
17
|
-
channelsMapDeclarationFile,
|
|
18
|
-
packageMappings,
|
|
19
|
-
state.functions.typesMap,
|
|
20
|
-
state.functions.meta,
|
|
21
|
-
state.channels.meta
|
|
22
|
-
)
|
|
23
|
-
await writeFileInDir(logger, channelsMapDeclarationFile, content)
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
logCommandInfoAndTime,
|
|
3
|
-
serializeFileImports,
|
|
4
|
-
writeFileInDir,
|
|
5
|
-
} from '../../utils.js'
|
|
6
|
-
import { PikkuCommand } from '../../types.js'
|
|
7
|
-
|
|
8
|
-
export const pikkuChannels: PikkuCommand = async (
|
|
9
|
-
logger,
|
|
10
|
-
cliConfig,
|
|
11
|
-
visitState
|
|
12
|
-
) => {
|
|
13
|
-
return await logCommandInfoAndTime(
|
|
14
|
-
logger,
|
|
15
|
-
'Finding Channels',
|
|
16
|
-
'Found channels',
|
|
17
|
-
[visitState.channels.files.size === 0],
|
|
18
|
-
async () => {
|
|
19
|
-
const { channelsWiringFile, channelsWiringMetaFile, packageMappings } =
|
|
20
|
-
cliConfig
|
|
21
|
-
const { channels } = visitState
|
|
22
|
-
await writeFileInDir(
|
|
23
|
-
logger,
|
|
24
|
-
channelsWiringFile,
|
|
25
|
-
serializeFileImports(
|
|
26
|
-
'addChannel',
|
|
27
|
-
channelsWiringFile,
|
|
28
|
-
channels.files,
|
|
29
|
-
packageMappings
|
|
30
|
-
)
|
|
31
|
-
)
|
|
32
|
-
await writeFileInDir(
|
|
33
|
-
logger,
|
|
34
|
-
channelsWiringMetaFile,
|
|
35
|
-
`import { pikkuState } from '@pikku/core'\npikkuState('channel', 'meta', ${JSON.stringify(channels.meta, null, 2)})`
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { PikkuCommandWithoutState } from '../../types.js'
|
|
2
|
-
import {
|
|
3
|
-
logCommandInfoAndTime,
|
|
4
|
-
getFileImportRelativePath,
|
|
5
|
-
writeFileInDir,
|
|
6
|
-
} from '../../utils.js'
|
|
7
|
-
import { serializeWebsocketWrapper } from './serialize-websocket-wrapper.js'
|
|
8
|
-
|
|
9
|
-
export const pikkuWebSocketTyped: PikkuCommandWithoutState = async (
|
|
10
|
-
logger,
|
|
11
|
-
{ websocketFile, channelsMapDeclarationFile, packageMappings }
|
|
12
|
-
) => {
|
|
13
|
-
return await logCommandInfoAndTime(
|
|
14
|
-
logger,
|
|
15
|
-
'Generating websocket wrapper',
|
|
16
|
-
'Generated websocket wrapper',
|
|
17
|
-
[
|
|
18
|
-
websocketFile === undefined,
|
|
19
|
-
"websocketFile isn't set in the pikku config",
|
|
20
|
-
],
|
|
21
|
-
async () => {
|
|
22
|
-
if (!websocketFile) {
|
|
23
|
-
throw new Error("fetchFile is isn't set in the pikku config")
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const channelsMapDeclarationPath = getFileImportRelativePath(
|
|
27
|
-
websocketFile,
|
|
28
|
-
channelsMapDeclarationFile,
|
|
29
|
-
packageMappings
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const content = [serializeWebsocketWrapper(channelsMapDeclarationPath)]
|
|
33
|
-
await writeFileInDir(logger, websocketFile, content.join('\n'))
|
|
34
|
-
}
|
|
35
|
-
)
|
|
36
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { serializeFetchWrapper } from '../http/serialize-fetch-wrapper.js'
|
|
2
|
-
import {
|
|
3
|
-
getFileImportRelativePath,
|
|
4
|
-
logCommandInfoAndTime,
|
|
5
|
-
writeFileInDir,
|
|
6
|
-
} from '../../utils.js'
|
|
7
|
-
import { PikkuCommandWithoutState } from '../../types.js'
|
|
8
|
-
|
|
9
|
-
export const pikkuFetch: PikkuCommandWithoutState = async (
|
|
10
|
-
logger,
|
|
11
|
-
{ fetchFile, httpMapDeclarationFile, packageMappings }
|
|
12
|
-
) => {
|
|
13
|
-
return await logCommandInfoAndTime(
|
|
14
|
-
logger,
|
|
15
|
-
'Generating fetch wrapper',
|
|
16
|
-
'Generated fetch wrapper',
|
|
17
|
-
[fetchFile === undefined, "fetchFile isn't set in the pikku config"],
|
|
18
|
-
async () => {
|
|
19
|
-
if (!fetchFile) {
|
|
20
|
-
throw new Error("fetchFile is isn't set in the pikku config")
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const routesMapDeclarationPath = getFileImportRelativePath(
|
|
24
|
-
fetchFile,
|
|
25
|
-
httpMapDeclarationFile,
|
|
26
|
-
packageMappings
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
const content = [serializeFetchWrapper(routesMapDeclarationPath)]
|
|
30
|
-
await writeFileInDir(logger, fetchFile, content.join('\n'))
|
|
31
|
-
}
|
|
32
|
-
)
|
|
33
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getFileImportRelativePath,
|
|
3
|
-
getPikkuFilesAndMethods,
|
|
4
|
-
logCommandInfoAndTime,
|
|
5
|
-
writeFileInDir,
|
|
6
|
-
} from '../../utils.js'
|
|
7
|
-
import { serializePikkuTypes } from '../../serialize-pikku-types.js'
|
|
8
|
-
import { PikkuCommand } from '../../types.js'
|
|
9
|
-
|
|
10
|
-
export const pikkuFunctionTypes: PikkuCommand = async (
|
|
11
|
-
logger,
|
|
12
|
-
{
|
|
13
|
-
typesDeclarationFile: typesFile,
|
|
14
|
-
packageMappings,
|
|
15
|
-
rpcInternalMapDeclarationFile,
|
|
16
|
-
},
|
|
17
|
-
visitState,
|
|
18
|
-
options = {}
|
|
19
|
-
) => {
|
|
20
|
-
return await logCommandInfoAndTime(
|
|
21
|
-
logger,
|
|
22
|
-
'Creating api types',
|
|
23
|
-
'Created api types',
|
|
24
|
-
[false],
|
|
25
|
-
async () => {
|
|
26
|
-
const { userSessionType, sessionServicesType, singletonServicesType } =
|
|
27
|
-
await getPikkuFilesAndMethods(
|
|
28
|
-
logger,
|
|
29
|
-
visitState,
|
|
30
|
-
packageMappings,
|
|
31
|
-
typesFile,
|
|
32
|
-
options,
|
|
33
|
-
{
|
|
34
|
-
userSessionType: true,
|
|
35
|
-
sessionServiceType: true,
|
|
36
|
-
singletonServicesType: true,
|
|
37
|
-
}
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
const content = serializePikkuTypes(
|
|
41
|
-
`import type { ${userSessionType.type} } from '${getFileImportRelativePath(typesFile, userSessionType.typePath, packageMappings)}'`,
|
|
42
|
-
userSessionType.type,
|
|
43
|
-
`import type { ${singletonServicesType.type} } from '${getFileImportRelativePath(typesFile, singletonServicesType.typePath, packageMappings)}'`,
|
|
44
|
-
singletonServicesType.type,
|
|
45
|
-
`import type { ${sessionServicesType.type} } from '${getFileImportRelativePath(typesFile, sessionServicesType.typePath, packageMappings)}'`,
|
|
46
|
-
sessionServicesType.type,
|
|
47
|
-
`import type { TypedPikkuRPC } from '${getFileImportRelativePath(typesFile, rpcInternalMapDeclarationFile, packageMappings)}'`
|
|
48
|
-
)
|
|
49
|
-
|
|
50
|
-
await writeFileInDir(logger, typesFile, content)
|
|
51
|
-
}
|
|
52
|
-
)
|
|
53
|
-
}
|