@pikku/cli 0.9.15 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.pikku/channel/pikku-channel-types.gen.ts +91 -0
- package/.pikku/channel/pikku-channels-map.gen.d.ts +44 -0
- package/.pikku/channel/pikku-channels-meta.gen.ts +5 -0
- package/.pikku/channel/pikku-channels.gen.ts +4 -0
- package/.pikku/cli/pikku-cli-channel.gen.ts +34 -0
- package/.pikku/cli/pikku-cli-client.gen.ts +43 -0
- package/.pikku/cli/pikku-cli-types.gen.ts +70 -0
- package/.pikku/cli/pikku-cli-wirings-meta.gen.ts +145 -0
- package/.pikku/cli/pikku-cli-wirings.gen.ts +6 -0
- package/.pikku/cli/pikku-cli.gen.ts +41 -0
- package/.pikku/function/pikku-function-types.gen.ts +440 -0
- package/.pikku/function/pikku-functions-meta.gen.ts +845 -0
- package/.pikku/function/pikku-functions-meta.min.gen.ts +181 -0
- package/.pikku/function/pikku-functions.gen.ts +76 -0
- package/.pikku/http/pikku-http-types.gen.ts +86 -0
- package/.pikku/http/pikku-http-wirings-map.gen.d.ts +43 -0
- package/.pikku/http/pikku-http-wirings-meta.gen.ts +13 -0
- package/.pikku/http/pikku-http-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp-types.gen.ts +140 -0
- package/.pikku/mcp/pikku-mcp-wirings-meta.gen.ts +7 -0
- package/.pikku/mcp/pikku-mcp-wirings.gen.ts +4 -0
- package/.pikku/mcp/pikku-mcp.gen.json +5 -0
- package/.pikku/pikku-bootstrap.gen.ts +19 -0
- package/.pikku/pikku-services.gen.ts +20 -0
- package/.pikku/pikku-types.gen.ts +27 -0
- package/.pikku/pikku-websocket.gen.ts +76 -0
- package/.pikku/queue/pikku-queue-types.gen.ts +27 -0
- package/.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts +57 -0
- package/.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts +5 -0
- package/.pikku/queue/pikku-queue-workers-wirings.gen.ts +4 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts +47 -0
- package/.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts +82 -0
- package/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts +41 -0
- package/.pikku/scheduler/pikku-scheduler-types.gen.ts +25 -0
- package/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts +5 -0
- package/.pikku/scheduler/pikku-schedulers-wirings.gen.ts +4 -0
- package/.pikku/schemas/register.gen.ts +51 -0
- package/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
- package/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
- package/CHANGELOG.md +15 -0
- package/bin/pikku.ts +97 -14
- package/build.sh +53 -0
- package/cli.schema.json +1 -382
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +56 -0
- package/dist/.pikku/channel/pikku-channel-types.gen.js +52 -0
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +5 -0
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +4 -0
- package/dist/.pikku/channel/pikku-channels.gen.js +5 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.d.ts +1 -0
- package/dist/.pikku/cli/pikku-cli-channel.gen.js +33 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli-client.gen.js +34 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +52 -0
- package/dist/.pikku/cli/pikku-cli-types.gen.js +31 -0
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +145 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +5 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +6 -0
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +10 -0
- package/dist/.pikku/cli/pikku-cli.gen.js +38 -0
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +380 -0
- package/dist/.pikku/function/pikku-function-types.gen.js +271 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.gen.js +845 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions-meta.min.gen.js +181 -0
- package/dist/.pikku/function/pikku-functions.gen.d.ts +1 -0
- package/dist/.pikku/function/pikku-functions.gen.js +75 -0
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +68 -0
- package/dist/.pikku/http/pikku-http-types.gen.js +62 -0
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +13 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +4 -0
- package/dist/.pikku/http/pikku-http-wirings.gen.js +5 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +91 -0
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +71 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +7 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +4 -0
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +5 -0
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +19 -0
- package/dist/.pikku/pikku-bootstrap.gen.js +19 -0
- package/dist/.pikku/pikku-services.gen.d.ts +13 -0
- package/dist/.pikku/pikku-services.gen.js +5 -0
- package/dist/.pikku/pikku-types.gen.d.ts +13 -0
- package/dist/.pikku/pikku-types.gen.js +20 -0
- package/dist/.pikku/pikku-websocket.gen.d.ts +31 -0
- package/dist/.pikku/pikku-websocket.gen.js +49 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +23 -0
- package/dist/.pikku/queue/pikku-queue-types.gen.js +16 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +5 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.d.ts +1 -0
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +41 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +21 -0
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +16 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.d.ts +1 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +5 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +4 -0
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +5 -0
- package/dist/.pikku/schemas/register.gen.d.ts +1 -0
- package/dist/.pikku/schemas/register.gen.js +28 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuChannelsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuFunctionsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuHTTPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMCPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMiddlewareOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuPermissionsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuQueueOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuRPCOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchedulerOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSchemasOutput.schema.json +1 -0
- package/dist/bin/pikku.js +63 -14
- package/dist/src/cli.wiring.d.ts +1 -0
- package/dist/src/cli.wiring.js +99 -0
- package/dist/src/functions/commands/all.d.ts +1 -0
- package/dist/src/functions/commands/all.js +114 -0
- package/dist/src/functions/commands/watch.d.ts +1 -0
- package/dist/src/functions/commands/watch.js +47 -0
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.d.ts +1 -0
- package/dist/src/{runtimes → functions/runtimes}/nextjs/pikku-command-nextjs.js +33 -12
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -0
- package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.js +2 -2
- package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-channels.js +19 -0
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.js +19 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.js +18 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +20 -0
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.d.ts +1 -0
- package/dist/src/functions/wirings/channels/pikku-command-websocket-typed.js +27 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.d.ts +4 -0
- package/dist/src/functions/wirings/channels/serialize-channel-types.js +94 -0
- package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.js +6 -3
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +123 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +31 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -0
- package/dist/src/functions/wirings/cli/pikku-command-cli.js +22 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.d.ts +11 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +131 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +9 -0
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +67 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.d.ts +4 -0
- package/dist/src/functions/wirings/cli/serialize-cli-types.js +73 -0
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.d.ts +14 -0
- package/dist/src/functions/wirings/cli/serialize-local-cli-bootstrap.js +51 -0
- package/dist/src/functions/wirings/fetch/index.d.ts +1 -0
- package/dist/src/functions/wirings/fetch/index.js +27 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +33 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-function-types.js +18 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-command-functions.js +26 -0
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +2 -0
- package/dist/src/{wirings → functions/wirings}/functions/pikku-command-services.js +36 -29
- package/dist/src/functions/wirings/functions/pikku-function-types.d.ts +1 -0
- package/dist/src/functions/wirings/functions/pikku-function-types.js +18 -0
- package/dist/src/functions/wirings/functions/schemas.d.ts +4 -0
- package/dist/src/functions/wirings/functions/schemas.js +20 -0
- package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.js +4 -21
- package/dist/src/functions/wirings/functions/serialize-function-types.d.ts +4 -0
- package/dist/src/functions/wirings/functions/serialize-function-types.js +443 -0
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.d.ts +4 -0
- package/dist/src/functions/wirings/functions/serialize-pikku-types-hub.js +30 -0
- package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.d.ts +4 -2
- package/dist/src/{wirings → functions/wirings}/http/openapi-spec-generator.js +2 -2
- package/dist/src/functions/wirings/http/pikku-command-http-map.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-map.js +18 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +20 -0
- package/dist/src/functions/wirings/http/pikku-command-http-types.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-http-types.js +19 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-command-openapi.js +37 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -0
- package/dist/src/functions/wirings/http/pikku-http-routes.js +20 -0
- package/dist/src/functions/wirings/http/serialize-http-types.d.ts +4 -0
- package/dist/src/functions/wirings/http/serialize-http-types.js +89 -0
- package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.js +2 -2
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.d.ts +1 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.js +23 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.d.ts +1 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.js +19 -0
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.d.ts +1 -0
- package/dist/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.js +17 -5
- package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.d.ts +2 -2
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.d.ts +4 -0
- package/dist/src/functions/wirings/mcp/serialize-mcp-types.js +143 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -0
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.js +36 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.d.ts +8 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-groups-meta.js +44 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-imports.d.ts +2 -0
- package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +43 -0
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -0
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.js +28 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.d.ts +2 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.js +43 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +18 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.js +27 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.js +19 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +21 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue-map.js +18 -0
- package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -0
- package/dist/src/functions/wirings/queue/pikku-queue.js +21 -0
- package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.js +2 -2
- package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.d.ts +1 -1
- package/dist/src/functions/wirings/queue/serialize-queue-types.d.ts +4 -0
- package/dist/src/functions/wirings/queue/serialize-queue-types.js +30 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.d.ts +1 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +27 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.d.ts +2 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.js +32 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +1 -0
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +20 -0
- package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.js +2 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.d.ts +1 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.js +19 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -0
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.js +21 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.d.ts +4 -0
- package/dist/src/functions/wirings/scheduler/serialize-scheduler-types.js +28 -0
- package/dist/src/middleware/log-command-info-and-time.d.ts +13 -0
- package/dist/src/middleware/log-command-info-and-time.js +15 -0
- package/dist/src/services/cli-logger-forwarder.service.d.ts +30 -0
- package/dist/src/services/cli-logger-forwarder.service.js +64 -0
- package/dist/src/services/cli-logger.service.d.ts +23 -0
- package/dist/src/services/cli-logger.service.js +77 -0
- package/dist/src/services.d.ts +20 -0
- package/dist/src/services.js +162 -0
- package/dist/src/utils/check-required-types.d.ts +10 -0
- package/dist/src/utils/check-required-types.js +31 -0
- package/dist/src/utils/custom-types-generator.d.ts +2 -0
- package/dist/src/utils/custom-types-generator.js +43 -0
- package/dist/src/utils/file-import-path.d.ts +1 -0
- package/dist/src/utils/file-import-path.js +43 -0
- package/dist/src/utils/file-imports-serializer.d.ts +1 -0
- package/dist/src/utils/file-imports-serializer.js +13 -0
- package/dist/src/utils/file-writer.d.ts +9 -0
- package/dist/src/utils/file-writer.js +50 -0
- package/dist/src/utils/generate-bootstrap-file.d.ts +3 -0
- package/dist/src/utils/generate-bootstrap-file.js +21 -0
- package/dist/src/utils/get-cli-version.d.ts +5 -0
- package/dist/src/utils/get-cli-version.js +27 -0
- package/dist/src/utils/pikku-cli-config.d.ts +4 -0
- package/dist/src/utils/pikku-cli-config.js +224 -0
- package/dist/src/utils/pikku-files-and-methods.d.ts +21 -0
- package/dist/src/utils/pikku-files-and-methods.js +70 -0
- package/dist/src/{schema-generator.d.ts → utils/schema-generator.d.ts} +1 -1
- package/dist/src/{schema-generator.js → utils/schema-generator.js} +4 -3
- package/dist/src/{serialize-import-map.js → utils/serialize-import-map.js} +1 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +13 -11
- package/pikku.config.json +26 -0
- package/src/cli.wiring.ts +102 -0
- package/src/functions/commands/all.ts +153 -0
- package/src/functions/commands/watch.ts +58 -0
- package/src/functions/runtimes/nextjs/pikku-command-nextjs.ts +111 -0
- package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-backend-wrapper.ts +2 -2
- package/src/functions/wirings/channels/pikku-channels.ts +35 -0
- package/src/functions/wirings/channels/pikku-command-channel-types.ts +25 -0
- package/src/functions/wirings/channels/pikku-command-channels-map.ts +26 -0
- package/src/functions/wirings/channels/pikku-command-channels.ts +40 -0
- package/src/functions/wirings/channels/pikku-command-websocket-typed.ts +37 -0
- package/src/functions/wirings/channels/serialize-channel-types.ts +94 -0
- package/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.ts +6 -3
- package/src/functions/wirings/cli/pikku-command-cli-entry.ts +216 -0
- package/src/functions/wirings/cli/pikku-command-cli-types.ts +48 -0
- package/src/functions/wirings/cli/pikku-command-cli.ts +39 -0
- package/src/functions/wirings/cli/serialize-channel-cli-client.ts +171 -0
- package/src/functions/wirings/cli/serialize-channel-cli.ts +102 -0
- package/src/functions/wirings/cli/serialize-cli-types.ts +79 -0
- package/src/functions/wirings/cli/serialize-local-cli-bootstrap.ts +80 -0
- package/src/functions/wirings/fetch/index.ts +36 -0
- package/src/functions/wirings/functions/pikku-command-function-types-split.ts +60 -0
- package/src/functions/wirings/functions/pikku-command-function-types.ts +43 -0
- package/src/functions/wirings/functions/pikku-command-functions.ts +59 -0
- package/src/functions/wirings/functions/pikku-command-services.ts +111 -0
- package/src/functions/wirings/functions/pikku-function-types.ts +43 -0
- package/src/functions/wirings/functions/schemas.ts +45 -0
- package/src/{wirings → functions/wirings}/functions/serialize-function-imports.ts +4 -30
- package/src/functions/wirings/functions/serialize-function-types.ts +453 -0
- package/src/functions/wirings/functions/serialize-pikku-types-hub.ts +38 -0
- package/src/{wirings → functions/wirings}/http/openapi-spec-generator.ts +5 -2
- package/src/functions/wirings/http/pikku-command-http-map.ts +27 -0
- package/src/functions/wirings/http/pikku-command-http-routes.ts +36 -0
- package/src/functions/wirings/http/pikku-command-http-types.ts +25 -0
- package/src/functions/wirings/http/pikku-command-openapi.ts +62 -0
- package/src/functions/wirings/http/pikku-http-routes.ts +35 -0
- package/src/functions/wirings/http/serialize-http-types.ts +89 -0
- package/src/{wirings → functions/wirings}/http/serialize-typed-http-map.ts +2 -2
- package/src/functions/wirings/mcp/pikku-command-mcp-json.ts +33 -0
- package/src/functions/wirings/mcp/pikku-command-mcp-types.ts +25 -0
- package/src/{wirings → functions/wirings}/mcp/pikku-command-mcp.ts +50 -46
- package/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.ts +2 -2
- package/src/functions/wirings/mcp/serialize-mcp-types.ts +143 -0
- package/src/functions/wirings/middleware/pikku-command-middleware.ts +63 -0
- package/src/functions/wirings/middleware/serialize-middleware-groups-meta.ts +55 -0
- package/src/functions/wirings/middleware/serialize-middleware-imports.ts +78 -0
- package/src/functions/wirings/permissions/pikku-command-permissions.ts +49 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.test.ts +274 -0
- package/src/functions/wirings/permissions/serialize-permissions-imports.ts +78 -0
- package/src/functions/wirings/queue/pikku-command-queue-map.ts +26 -0
- package/src/functions/wirings/queue/pikku-command-queue-service.ts +37 -0
- package/src/functions/wirings/queue/pikku-command-queue-types.ts +25 -0
- package/src/functions/wirings/queue/pikku-command-queue.ts +41 -0
- package/src/functions/wirings/queue/pikku-queue-map.ts +26 -0
- package/src/functions/wirings/queue/pikku-queue.ts +41 -0
- package/src/{wirings → functions/wirings}/queue/serialize-queue-map.ts +2 -2
- package/src/{wirings → functions/wirings}/queue/serialize-queue-meta.ts +1 -1
- package/src/functions/wirings/queue/serialize-queue-types.ts +30 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-client.ts +35 -0
- package/src/functions/wirings/rpc/pikku-command-rpc-map.ts +48 -0
- package/src/functions/wirings/rpc/pikku-command-rpc.ts +26 -0
- package/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.ts +2 -2
- package/src/functions/wirings/scheduler/pikku-command-scheduler-types.ts +25 -0
- package/src/functions/wirings/scheduler/pikku-command-scheduler.ts +41 -0
- package/src/functions/wirings/scheduler/serialize-scheduler-types.ts +28 -0
- package/src/middleware/log-command-info-and-time.ts +35 -0
- package/src/services/cli-logger-forwarder.service.ts +90 -0
- package/src/services/cli-logger.service.ts +93 -0
- package/src/services.ts +240 -0
- package/src/utils/check-required-types.ts +53 -0
- package/src/utils/custom-types-generator.ts +55 -0
- package/src/{utils.test.ts → utils/file-import-path.test.ts} +1 -1
- package/src/utils/file-import-path.ts +53 -0
- package/src/utils/file-imports-serializer.ts +25 -0
- package/src/utils/file-writer.ts +72 -0
- package/src/utils/generate-bootstrap-file.ts +43 -0
- package/src/utils/get-cli-version.ts +28 -0
- package/src/utils/pikku-cli-config.ts +327 -0
- package/src/utils/pikku-files-and-methods.ts +148 -0
- package/src/{schema-generator.ts → utils/schema-generator.ts} +10 -4
- package/src/{serialize-import-map.ts → utils/serialize-import-map.ts} +1 -5
- package/tsconfig.json +2 -2
- package/types/application-types.d.ts +23 -0
- package/types/config.d.ts +204 -0
- package/bin/pikku-all.ts +0 -349
- package/bin/pikku-fetch.ts +0 -27
- package/bin/pikku-nextjs.ts +0 -44
- package/bin/pikku-openapi.ts +0 -31
- package/bin/pikku-queue-service.ts +0 -28
- package/bin/pikku-rpc.ts +0 -28
- package/bin/pikku-schemas.ts +0 -31
- package/bin/pikku-websocket.ts +0 -28
- package/dist/bin/pikku-all.d.ts +0 -4
- package/dist/bin/pikku-all.js +0 -194
- package/dist/bin/pikku-fetch.d.ts +0 -4
- package/dist/bin/pikku-fetch.js +0 -19
- package/dist/bin/pikku-nextjs.d.ts +0 -4
- package/dist/bin/pikku-nextjs.js +0 -24
- package/dist/bin/pikku-openapi.d.ts +0 -2
- package/dist/bin/pikku-openapi.js +0 -19
- package/dist/bin/pikku-queue-service.d.ts +0 -4
- package/dist/bin/pikku-queue-service.js +0 -19
- package/dist/bin/pikku-rpc.d.ts +0 -4
- package/dist/bin/pikku-rpc.js +0 -19
- package/dist/bin/pikku-schemas.d.ts +0 -2
- package/dist/bin/pikku-schemas.js +0 -21
- package/dist/bin/pikku-websocket.d.ts +0 -4
- package/dist/bin/pikku-websocket.js +0 -19
- package/dist/src/inspector-glob.d.ts +0 -2
- package/dist/src/inspector-glob.js +0 -12
- package/dist/src/pikku-cli-config.d.ts +0 -56
- package/dist/src/pikku-cli-config.js +0 -203
- package/dist/src/pikku-command-schemas.d.ts +0 -2
- package/dist/src/pikku-command-schemas.js +0 -8
- package/dist/src/runtimes/nextjs/pikku-command-nextjs.d.ts +0 -2
- package/dist/src/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +0 -1
- package/dist/src/schemas.d.ts +0 -2
- package/dist/src/schemas.js +0 -8
- package/dist/src/serialize-pikku-types.d.ts +0 -4
- package/dist/src/serialize-pikku-types.js +0 -605
- package/dist/src/types.d.ts +0 -5
- package/dist/src/utils.d.ts +0 -60
- package/dist/src/utils.js +0 -248
- package/dist/src/wirings/channels/pikku-channels.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-channels.js +0 -9
- package/dist/src/wirings/channels/pikku-command-channels-map.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-channels-map.js +0 -8
- package/dist/src/wirings/channels/pikku-command-channels.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-channels.js +0 -9
- package/dist/src/wirings/channels/pikku-command-websocket-typed.d.ts +0 -2
- package/dist/src/wirings/channels/pikku-command-websocket-typed.js +0 -15
- package/dist/src/wirings/fetch/index.d.ts +0 -2
- package/dist/src/wirings/fetch/index.js +0 -12
- package/dist/src/wirings/functions/pikku-command-function-types.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-command-function-types.js +0 -13
- package/dist/src/wirings/functions/pikku-command-functions.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-command-functions.js +0 -14
- package/dist/src/wirings/functions/pikku-command-services.d.ts +0 -3
- package/dist/src/wirings/functions/pikku-function-types.d.ts +0 -2
- package/dist/src/wirings/functions/pikku-function-types.js +0 -13
- package/dist/src/wirings/http/pikku-command-http-map.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-http-map.js +0 -8
- package/dist/src/wirings/http/pikku-command-http-routes.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-http-routes.js +0 -9
- package/dist/src/wirings/http/pikku-command-openapi.d.ts +0 -2
- package/dist/src/wirings/http/pikku-command-openapi.js +0 -20
- package/dist/src/wirings/http/pikku-http-routes.d.ts +0 -2
- package/dist/src/wirings/http/pikku-http-routes.js +0 -9
- package/dist/src/wirings/mcp/pikku-command-mcp-json.d.ts +0 -2
- package/dist/src/wirings/mcp/pikku-command-mcp-json.js +0 -13
- package/dist/src/wirings/mcp/pikku-command-mcp.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-map.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-map.js +0 -8
- package/dist/src/wirings/queue/pikku-command-queue-service.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue-service.js +0 -15
- package/dist/src/wirings/queue/pikku-command-queue.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-command-queue.js +0 -10
- package/dist/src/wirings/queue/pikku-queue-map.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-queue-map.js +0 -8
- package/dist/src/wirings/queue/pikku-queue.d.ts +0 -2
- package/dist/src/wirings/queue/pikku-queue.js +0 -10
- package/dist/src/wirings/rpc/pikku-command-rpc-client.d.ts +0 -2
- package/dist/src/wirings/rpc/pikku-command-rpc-client.js +0 -15
- package/dist/src/wirings/rpc/pikku-command-rpc-map.d.ts +0 -3
- package/dist/src/wirings/rpc/pikku-command-rpc-map.js +0 -14
- package/dist/src/wirings/rpc/pikku-command-rpc.d.ts +0 -2
- package/dist/src/wirings/rpc/pikku-command-rpc.js +0 -8
- package/dist/src/wirings/scheduler/pikku-command-scheduler.d.ts +0 -2
- package/dist/src/wirings/scheduler/pikku-command-scheduler.js +0 -10
- package/src/inspector-glob.ts +0 -30
- package/src/pikku-cli-config.ts +0 -387
- package/src/pikku-command-schemas.ts +0 -35
- package/src/runtimes/nextjs/pikku-command-nextjs.ts +0 -110
- package/src/schemas.ts +0 -35
- package/src/serialize-pikku-types.ts +0 -613
- package/src/types.ts +0 -16
- package/src/utils.ts +0 -420
- package/src/wirings/channels/pikku-channels.ts +0 -41
- package/src/wirings/channels/pikku-command-channels-map.ts +0 -26
- package/src/wirings/channels/pikku-command-channels.ts +0 -39
- package/src/wirings/channels/pikku-command-websocket-typed.ts +0 -36
- package/src/wirings/fetch/index.ts +0 -33
- package/src/wirings/functions/pikku-command-function-types.ts +0 -53
- package/src/wirings/functions/pikku-command-functions.ts +0 -48
- package/src/wirings/functions/pikku-command-services.ts +0 -125
- package/src/wirings/functions/pikku-function-types.ts +0 -52
- package/src/wirings/http/pikku-command-http-map.ts +0 -27
- package/src/wirings/http/pikku-command-http-routes.ts +0 -40
- package/src/wirings/http/pikku-command-openapi.ts +0 -55
- package/src/wirings/http/pikku-http-routes.ts +0 -40
- package/src/wirings/mcp/pikku-command-mcp-json.ts +0 -33
- package/src/wirings/queue/pikku-command-queue-map.ts +0 -26
- package/src/wirings/queue/pikku-command-queue-service.ts +0 -36
- package/src/wirings/queue/pikku-command-queue.ts +0 -45
- package/src/wirings/queue/pikku-queue-map.ts +0 -26
- package/src/wirings/queue/pikku-queue.ts +0 -43
- package/src/wirings/rpc/pikku-command-rpc-client.ts +0 -35
- package/src/wirings/rpc/pikku-command-rpc-map.ts +0 -49
- package/src/wirings/rpc/pikku-command-rpc.ts +0 -24
- package/src/wirings/scheduler/pikku-command-scheduler.ts +0 -43
- /package/dist/{src/types.js → .pikku/channel/pikku-channels-meta.gen.d.ts} +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.d.ts +0 -0
- /package/dist/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-typed-channel-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/functions/serialize-function-imports.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/http/serialize-typed-http-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/mcp/serialize-mcp-json.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-meta.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.js +0 -0
- /package/dist/src/{wirings → functions/wirings}/rpc/serialize-typed-rpc-map.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.d.ts +0 -0
- /package/dist/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.js +0 -0
- /package/dist/src/{serialize-import-map.d.ts → utils/serialize-import-map.d.ts} +0 -0
- /package/src/{runtimes → functions/runtimes}/nextjs/serialize-nextjs-http-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/channels/serialize-websocket-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/http/serialize-fetch-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/queue/serialize-queue-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/rpc/serialize-rpc-wrapper.ts +0 -0
- /package/src/{wirings → functions/wirings}/scheduler/serialize-scheduler-meta.ts +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
import { serializeTypedRPCMap } from './serialize-typed-rpc-map.js'
|
|
5
|
+
|
|
6
|
+
export const pikkuRPCInternalMap: any = pikkuSessionlessFunc<void, void>({
|
|
7
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
8
|
+
const { functions, rpc } = await getInspectorState()
|
|
9
|
+
const { rpcInternalMapDeclarationFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const content = serializeTypedRPCMap(
|
|
12
|
+
rpcInternalMapDeclarationFile,
|
|
13
|
+
packageMappings,
|
|
14
|
+
functions.typesMap,
|
|
15
|
+
functions.meta,
|
|
16
|
+
rpc.internalMeta
|
|
17
|
+
)
|
|
18
|
+
await writeFileInDir(logger, rpcInternalMapDeclarationFile, content)
|
|
19
|
+
},
|
|
20
|
+
middleware: [
|
|
21
|
+
logCommandInfoAndTime({
|
|
22
|
+
commandStart: 'Creating RPC internal map',
|
|
23
|
+
commandEnd: 'Created RPC internal map',
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
export const pikkuRPCExposedMap: any = pikkuSessionlessFunc<void, void>({
|
|
29
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
30
|
+
const { functions, rpc } = await getInspectorState()
|
|
31
|
+
const { rpcMapDeclarationFile, packageMappings } = config
|
|
32
|
+
|
|
33
|
+
const content = serializeTypedRPCMap(
|
|
34
|
+
rpcMapDeclarationFile,
|
|
35
|
+
packageMappings,
|
|
36
|
+
functions.typesMap,
|
|
37
|
+
functions.meta,
|
|
38
|
+
rpc.exposedMeta
|
|
39
|
+
)
|
|
40
|
+
await writeFileInDir(logger, rpcMapDeclarationFile, content)
|
|
41
|
+
},
|
|
42
|
+
middleware: [
|
|
43
|
+
logCommandInfoAndTime({
|
|
44
|
+
commandStart: 'Creating RPC external map',
|
|
45
|
+
commandEnd: 'Created RPC external map',
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
})
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
4
|
+
|
|
5
|
+
export const pikkuRPC: any = pikkuSessionlessFunc<void, boolean>({
|
|
6
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
7
|
+
const { rpc } = await getInspectorState()
|
|
8
|
+
const { rpcInternalWiringMetaFile } = config
|
|
9
|
+
|
|
10
|
+
if (rpc.internalFiles.size > 0) {
|
|
11
|
+
await writeFileInDir(
|
|
12
|
+
logger,
|
|
13
|
+
rpcInternalWiringMetaFile,
|
|
14
|
+
`import { pikkuState } from '@pikku/core'\npikkuState('rpc', 'meta', ${JSON.stringify(rpc.internalMeta, null, 2)})`
|
|
15
|
+
)
|
|
16
|
+
return true
|
|
17
|
+
}
|
|
18
|
+
return false
|
|
19
|
+
},
|
|
20
|
+
middleware: [
|
|
21
|
+
logCommandInfoAndTime({
|
|
22
|
+
commandStart: 'Finding RPCs tasks',
|
|
23
|
+
commandEnd: 'Found RPCs',
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { serializeImportMap } from '
|
|
1
|
+
import { serializeImportMap } from '../../../utils/serialize-import-map.js'
|
|
2
2
|
import { TypesMap } from '@pikku/inspector'
|
|
3
3
|
import { FunctionsMeta } from '@pikku/core'
|
|
4
|
-
import { generateCustomTypes } from '
|
|
4
|
+
import { generateCustomTypes } from '../../../utils/custom-types-generator.js'
|
|
5
5
|
|
|
6
6
|
export const serializeTypedRPCMap = (
|
|
7
7
|
relativeToPath: string,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
3
|
+
import { getFileImportRelativePath } from '../../../utils/file-import-path.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { serializeSchedulerTypes } from './serialize-scheduler-types.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuSchedulerTypes: any = pikkuSessionlessFunc<void, void>({
|
|
8
|
+
func: async ({ logger, config }) => {
|
|
9
|
+
const { schedulersTypesFile, functionTypesFile, packageMappings } = config
|
|
10
|
+
|
|
11
|
+
const functionTypesImportPath = getFileImportRelativePath(
|
|
12
|
+
schedulersTypesFile,
|
|
13
|
+
functionTypesFile,
|
|
14
|
+
packageMappings
|
|
15
|
+
)
|
|
16
|
+
const content = serializeSchedulerTypes(functionTypesImportPath)
|
|
17
|
+
await writeFileInDir(logger, schedulersTypesFile, content)
|
|
18
|
+
},
|
|
19
|
+
middleware: [
|
|
20
|
+
logCommandInfoAndTime({
|
|
21
|
+
commandStart: 'Creating cheduler types',
|
|
22
|
+
commandEnd: 'Created scheduler types',
|
|
23
|
+
}),
|
|
24
|
+
],
|
|
25
|
+
})
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { pikkuSessionlessFunc } from '../../../../.pikku/pikku-types.gen.js'
|
|
2
|
+
import { serializeFileImports } from '../../../utils/file-imports-serializer.js'
|
|
3
|
+
import { writeFileInDir } from '../../../utils/file-writer.js'
|
|
4
|
+
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js'
|
|
5
|
+
import { serializeSchedulerMeta } from './serialize-scheduler-meta.js'
|
|
6
|
+
|
|
7
|
+
export const pikkuScheduler: any = pikkuSessionlessFunc<
|
|
8
|
+
void,
|
|
9
|
+
boolean | undefined
|
|
10
|
+
>({
|
|
11
|
+
func: async ({ logger, config, getInspectorState }) => {
|
|
12
|
+
const visitState = await getInspectorState()
|
|
13
|
+
const { schedulersWiringFile, schedulersWiringMetaFile, packageMappings } =
|
|
14
|
+
config
|
|
15
|
+
const { scheduledTasks } = visitState
|
|
16
|
+
|
|
17
|
+
await writeFileInDir(
|
|
18
|
+
logger,
|
|
19
|
+
schedulersWiringMetaFile,
|
|
20
|
+
serializeSchedulerMeta(scheduledTasks.meta)
|
|
21
|
+
)
|
|
22
|
+
await writeFileInDir(
|
|
23
|
+
logger,
|
|
24
|
+
schedulersWiringFile,
|
|
25
|
+
serializeFileImports(
|
|
26
|
+
'addScheduledTasks',
|
|
27
|
+
schedulersWiringFile,
|
|
28
|
+
scheduledTasks.files,
|
|
29
|
+
packageMappings
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
return true
|
|
34
|
+
},
|
|
35
|
+
middleware: [
|
|
36
|
+
logCommandInfoAndTime({
|
|
37
|
+
commandStart: 'Finding Scheduled tasks',
|
|
38
|
+
commandEnd: 'Found Scheduled tasks',
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
})
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates type definitions for scheduler wirings
|
|
3
|
+
*/
|
|
4
|
+
export const serializeSchedulerTypes = (functionTypesImportPath: string) => {
|
|
5
|
+
return `/**
|
|
6
|
+
* Scheduler-specific type definitions for tree-shaking optimization
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { CoreScheduledTask, wireScheduler as wireSchedulerCore } from '@pikku/core/scheduler'
|
|
10
|
+
import type { PikkuFunctionConfig, PikkuMiddleware } from '${functionTypesImportPath}'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Type definition for scheduled tasks that run at specified intervals.
|
|
14
|
+
* These are sessionless functions that execute based on cron expressions.
|
|
15
|
+
*/
|
|
16
|
+
type SchedulerWiring = CoreScheduledTask<PikkuFunctionConfig<void, void>, PikkuMiddleware>
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Registers a scheduled task with the Pikku framework.
|
|
20
|
+
* Tasks run based on cron expressions and are sessionless.
|
|
21
|
+
*
|
|
22
|
+
* @param task - Scheduled task definition with cron expression and handler
|
|
23
|
+
*/
|
|
24
|
+
export const wireScheduler = (task: SchedulerWiring) => {
|
|
25
|
+
wireSchedulerCore(task as any) // TODO
|
|
26
|
+
}
|
|
27
|
+
`
|
|
28
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Services } from '../../types/application-types.js'
|
|
2
|
+
import type { PikkuInteraction } from '@pikku/core'
|
|
3
|
+
|
|
4
|
+
// Middleware type for CLI
|
|
5
|
+
type PikkuMiddleware = (
|
|
6
|
+
services: Services,
|
|
7
|
+
interaction: PikkuInteraction,
|
|
8
|
+
next: () => Promise<void>
|
|
9
|
+
) => Promise<void>
|
|
10
|
+
|
|
11
|
+
export interface LogCommandInfoOptions {
|
|
12
|
+
commandStart: string
|
|
13
|
+
commandEnd: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Middleware to log command execution timing and status
|
|
18
|
+
* Replaces the logCommandInfoAndTime wrapper function
|
|
19
|
+
*/
|
|
20
|
+
export const logCommandInfoAndTime = ({
|
|
21
|
+
commandStart,
|
|
22
|
+
commandEnd,
|
|
23
|
+
}: LogCommandInfoOptions): PikkuMiddleware => {
|
|
24
|
+
return async ({ logger }, _interaction, next) => {
|
|
25
|
+
// Log start
|
|
26
|
+
const start = Date.now()
|
|
27
|
+
logger.info(`• ${commandStart}...`)
|
|
28
|
+
|
|
29
|
+
// Execute the function
|
|
30
|
+
await next()
|
|
31
|
+
|
|
32
|
+
// Log completion
|
|
33
|
+
logger.info(`✓ ${commandEnd} in ${Date.now() - start}ms.`)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { Logger, LogLevel } from '@pikku/core'
|
|
2
|
+
import { PikkuChannel } from '@pikku/core/channel'
|
|
3
|
+
import { ErrorCode } from '@pikku/inspector'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Log message structure sent through the channel
|
|
7
|
+
*/
|
|
8
|
+
export interface ForwardedLogMessage {
|
|
9
|
+
message: string
|
|
10
|
+
level: 'trace' | 'debug' | 'info' | 'warn' | 'error'
|
|
11
|
+
type?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* A logger implementation that forwards log messages to a CLI channel
|
|
16
|
+
* instead of logging to console directly.
|
|
17
|
+
*/
|
|
18
|
+
export class CLILoggerForwarder implements Logger {
|
|
19
|
+
private level: LogLevel = LogLevel.info
|
|
20
|
+
|
|
21
|
+
constructor(
|
|
22
|
+
private logger: Logger,
|
|
23
|
+
private channel: PikkuChannel<unknown, any>
|
|
24
|
+
) {}
|
|
25
|
+
|
|
26
|
+
setLevel(level: LogLevel): void {
|
|
27
|
+
this.level = level
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private log(
|
|
31
|
+
level: ForwardedLogMessage['level'],
|
|
32
|
+
logLevel: LogLevel,
|
|
33
|
+
messageOrObj: string | Record<string, any> | Error,
|
|
34
|
+
type?: string
|
|
35
|
+
) {
|
|
36
|
+
if (this.level > logLevel) return
|
|
37
|
+
|
|
38
|
+
let message: string
|
|
39
|
+
|
|
40
|
+
if (messageOrObj instanceof Error) {
|
|
41
|
+
this.logger.error(messageOrObj)
|
|
42
|
+
message = messageOrObj.message
|
|
43
|
+
} else if (typeof messageOrObj === 'object') {
|
|
44
|
+
if (
|
|
45
|
+
'message' in messageOrObj &&
|
|
46
|
+
typeof messageOrObj.message === 'string'
|
|
47
|
+
) {
|
|
48
|
+
message = messageOrObj.message
|
|
49
|
+
type = type || (messageOrObj.type as string)
|
|
50
|
+
} else {
|
|
51
|
+
message = JSON.stringify(messageOrObj)
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
message = messageOrObj
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.channel.send({ message, level, type })
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
info(messageOrObj: string | Record<string, any>, ..._meta: any[]) {
|
|
61
|
+
this.log('info', LogLevel.info, messageOrObj)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
error(messageOrObj: string | Record<string, any> | Error, ..._meta: any[]) {
|
|
65
|
+
this.log('error', LogLevel.error, messageOrObj)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
warn(messageOrObj: string | Record<string, any>, ..._meta: any[]) {
|
|
69
|
+
this.log('warn', LogLevel.warn, messageOrObj)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
debug(message: string, ..._meta: any[]) {
|
|
73
|
+
this.log('debug', LogLevel.debug, message)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
trace(message: string, ..._meta: any[]) {
|
|
77
|
+
this.log('trace', LogLevel.trace, message)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
critical(code: ErrorCode, message: string) {
|
|
81
|
+
const url = `https://pikku.dev/docs/cli-errors/${code.toLowerCase()}`
|
|
82
|
+
const formattedMessage = `[${code}] ${message}\n → ${url}`
|
|
83
|
+
this.error(formattedMessage)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
hasCriticalErrors(): boolean {
|
|
87
|
+
// The underlying logger (CLILogger) tracks critical errors
|
|
88
|
+
return (this.logger as any).hasCriticalErrors?.() ?? false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import chalk from 'chalk'
|
|
2
|
+
import { Logger, LogLevel } from '@pikku/core'
|
|
3
|
+
import { ErrorCode } from '@pikku/inspector'
|
|
4
|
+
|
|
5
|
+
const logo = `
|
|
6
|
+
______ _ _ _
|
|
7
|
+
(_____ (_) | | |
|
|
8
|
+
_____) )| | _| | _ _ _
|
|
9
|
+
| ____/ | |_/ ) |_/ ) | | |
|
|
10
|
+
| | | | _ (| _ (| _ (| |_| |
|
|
11
|
+
|_| |_|_| _)_| _)____/
|
|
12
|
+
`
|
|
13
|
+
|
|
14
|
+
const BASE_ERROR_URL = 'https://pikku.dev/errors'
|
|
15
|
+
|
|
16
|
+
export class CLILogger implements Logger {
|
|
17
|
+
private silent: boolean
|
|
18
|
+
private level: LogLevel = LogLevel.info
|
|
19
|
+
private criticalErrors: string[] = []
|
|
20
|
+
|
|
21
|
+
constructor({
|
|
22
|
+
logLogo,
|
|
23
|
+
silent = false,
|
|
24
|
+
}: {
|
|
25
|
+
logLogo: boolean
|
|
26
|
+
silent?: boolean
|
|
27
|
+
}) {
|
|
28
|
+
this.silent = silent
|
|
29
|
+
if (logLogo && !silent) {
|
|
30
|
+
this.logPikkuLogo()
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
setLevel(level: LogLevel): void {
|
|
35
|
+
this.level = level
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
info(message: string | { message: string; type?: string }) {
|
|
39
|
+
if (this.level > LogLevel.info || this.silent) return
|
|
40
|
+
|
|
41
|
+
let c = chalk.blue
|
|
42
|
+
if (typeof message === 'object') {
|
|
43
|
+
if (message.type === 'success') {
|
|
44
|
+
c = chalk.green
|
|
45
|
+
} else if (message.type === 'timing') {
|
|
46
|
+
c = chalk.gray
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
console.log(c(typeof message === 'string' ? message : message.message))
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
error(message: string) {
|
|
53
|
+
if (this.level > LogLevel.error) return
|
|
54
|
+
console.error(chalk.red(message))
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
warn(message: string) {
|
|
58
|
+
if (this.level > LogLevel.warn) return
|
|
59
|
+
console.error(chalk.yellow(message))
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
debug(message: string) {
|
|
63
|
+
if (this.level > LogLevel.debug || this.silent) return
|
|
64
|
+
console.log(chalk.gray(message))
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
critical(code: ErrorCode, message: string) {
|
|
68
|
+
const url = `${BASE_ERROR_URL}/${code.toLowerCase()}`
|
|
69
|
+
const formattedMessage = `[${code}] ${message}\n → ${url}`
|
|
70
|
+
this.criticalErrors.push(formattedMessage)
|
|
71
|
+
console.error(chalk.red.bold(formattedMessage))
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
hasCriticalErrors(): boolean {
|
|
75
|
+
return this.criticalErrors.length > 0
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private logPikkuLogo() {
|
|
79
|
+
this.primary(logo)
|
|
80
|
+
// // When running from dist/, __filename is dist/src/services/cli-logger.service.js
|
|
81
|
+
// // So we need to go up 3 levels: dist/src/services -> dist/src -> dist -> package.json
|
|
82
|
+
// const packageJson = JSON.parse(
|
|
83
|
+
// readFileSync(`${dirname(__filename)}/../../../package.json`, 'utf-8')
|
|
84
|
+
// )
|
|
85
|
+
// this.primary(`⚙️ Welcome to the Pikku CLI (v${packageJson.version})\n`)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
private primary(message: string) {
|
|
89
|
+
if (!this.silent) {
|
|
90
|
+
console.log(chalk.green(message))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/services.ts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Config,
|
|
3
|
+
Services,
|
|
4
|
+
SingletonServices,
|
|
5
|
+
UserSession,
|
|
6
|
+
} from '../types/application-types.js'
|
|
7
|
+
import {
|
|
8
|
+
CreateConfig,
|
|
9
|
+
CreateSessionServices,
|
|
10
|
+
CreateSingletonServices,
|
|
11
|
+
} from '@pikku/core'
|
|
12
|
+
import { pikkuCLIRender } from '@pikku/core/cli'
|
|
13
|
+
import { LocalVariablesService } from '@pikku/core/services'
|
|
14
|
+
import { CLILogger } from './services/cli-logger.service.js'
|
|
15
|
+
import { getPikkuCLIConfig } from './utils/pikku-cli-config.js'
|
|
16
|
+
import {
|
|
17
|
+
inspect,
|
|
18
|
+
InspectorState,
|
|
19
|
+
InspectorFilters,
|
|
20
|
+
serializeInspectorState,
|
|
21
|
+
deserializeInspectorState,
|
|
22
|
+
filterInspectorState,
|
|
23
|
+
} from '@pikku/inspector'
|
|
24
|
+
import { glob } from 'tinyglobby'
|
|
25
|
+
import path from 'path'
|
|
26
|
+
import { PikkuCLIConfig } from '../types/config.js'
|
|
27
|
+
import {
|
|
28
|
+
CLILoggerForwarder,
|
|
29
|
+
ForwardedLogMessage,
|
|
30
|
+
} from './services/cli-logger-forwarder.service.js'
|
|
31
|
+
import { readFile, writeFile } from 'fs/promises'
|
|
32
|
+
|
|
33
|
+
const logger = new CLILogger({ logLogo: true, silent: false })
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Parse a comma-separated string or array into an array of trimmed, non-empty strings
|
|
37
|
+
* Returns undefined if the input is empty/undefined or results in an empty array
|
|
38
|
+
*/
|
|
39
|
+
function parseCommaSeparated(
|
|
40
|
+
value: string | string[] | undefined
|
|
41
|
+
): string[] | undefined {
|
|
42
|
+
if (!value) return undefined
|
|
43
|
+
|
|
44
|
+
// If already an array, flatten and split any comma-separated values
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
const flattened = value
|
|
47
|
+
.flatMap((item) => item.split(','))
|
|
48
|
+
.map((item) => item.trim())
|
|
49
|
+
.filter((item) => item.length > 0)
|
|
50
|
+
return flattened.length > 0 ? flattened : undefined
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// If string, split by comma
|
|
54
|
+
const parsed = value
|
|
55
|
+
.split(',')
|
|
56
|
+
.map((item) => item.trim())
|
|
57
|
+
.filter((item) => item.length > 0)
|
|
58
|
+
|
|
59
|
+
return parsed.length > 0 ? parsed : undefined
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Parse CLI filter arguments into InspectorFilters format
|
|
64
|
+
*/
|
|
65
|
+
function parseCLIFilters(data: any): InspectorFilters {
|
|
66
|
+
const filters: InspectorFilters = {}
|
|
67
|
+
|
|
68
|
+
if (data.filters) {
|
|
69
|
+
return JSON.parse(data.filters)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Parse each filter type from CLI arguments
|
|
73
|
+
const names = parseCommaSeparated(data.names)
|
|
74
|
+
const tags = parseCommaSeparated(data.tags)
|
|
75
|
+
const types = parseCommaSeparated(data.types)
|
|
76
|
+
const directories = parseCommaSeparated(data.directories)
|
|
77
|
+
const httpRoutes = parseCommaSeparated(data.httpRoutes)
|
|
78
|
+
const httpMethods = parseCommaSeparated(data.httpMethods)
|
|
79
|
+
|
|
80
|
+
// Only include non-undefined values in the result
|
|
81
|
+
if (names) filters.names = names
|
|
82
|
+
if (tags) filters.tags = tags
|
|
83
|
+
if (types) filters.types = types
|
|
84
|
+
if (directories) filters.directories = directories
|
|
85
|
+
if (httpRoutes) filters.httpRoutes = httpRoutes
|
|
86
|
+
if (httpMethods) filters.httpMethods = httpMethods
|
|
87
|
+
|
|
88
|
+
return filters
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Default CLI renderer that logs output using the logger
|
|
93
|
+
*/
|
|
94
|
+
export const defaultCLIRenderer = pikkuCLIRender<
|
|
95
|
+
ForwardedLogMessage,
|
|
96
|
+
SingletonServices
|
|
97
|
+
>((_services, data) => {
|
|
98
|
+
if (data) {
|
|
99
|
+
logger[data.level]({ message: data.message, type: data.type })
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Client-safe CLI renderer that outputs to console (no service dependencies)
|
|
105
|
+
* This renderer can be used in CLI-over-channel clients
|
|
106
|
+
*/
|
|
107
|
+
export const clientCLIRenderer = pikkuCLIRender<ForwardedLogMessage>(
|
|
108
|
+
(_services, data) => {
|
|
109
|
+
if (data) {
|
|
110
|
+
// Simple console output without service dependencies
|
|
111
|
+
const prefix = data.type ? `[${data.type}] ` : ''
|
|
112
|
+
console.log(`${prefix}${data.message}`)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
export const createConfig: CreateConfig<Config, [PikkuCLIConfig]> = async (
|
|
118
|
+
_variablesService,
|
|
119
|
+
data
|
|
120
|
+
) => {
|
|
121
|
+
const cliConfig = await getPikkuCLIConfig(logger, data.configFile, [], true)
|
|
122
|
+
|
|
123
|
+
// Load inspector state from file if stateInput is provided
|
|
124
|
+
let preloadedInspectorState: Omit<InspectorState, 'typesLookup'> | undefined =
|
|
125
|
+
undefined
|
|
126
|
+
|
|
127
|
+
if (data.stateInput) {
|
|
128
|
+
try {
|
|
129
|
+
logger.info(`Loading inspector state from ${data.stateInput}`)
|
|
130
|
+
const stateJson = await readFile(data.stateInput, 'utf-8')
|
|
131
|
+
const serializedState = JSON.parse(stateJson)
|
|
132
|
+
preloadedInspectorState = deserializeInspectorState(serializedState)
|
|
133
|
+
logger.info(`Inspector state loaded successfully`)
|
|
134
|
+
} catch (error: any) {
|
|
135
|
+
logger.error(
|
|
136
|
+
`Failed to load inspector state from ${data.stateInput}: ${error.message}`
|
|
137
|
+
)
|
|
138
|
+
throw error
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
...cliConfig,
|
|
144
|
+
...data,
|
|
145
|
+
filters: parseCLIFilters(data),
|
|
146
|
+
preloadedInspectorState,
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Singleton services factory for the Pikku CLI
|
|
152
|
+
* This function creates the singleton services used by the CLI and is created once on start.
|
|
153
|
+
*/
|
|
154
|
+
export const createSingletonServices: CreateSingletonServices<
|
|
155
|
+
Config,
|
|
156
|
+
SingletonServices
|
|
157
|
+
> = async (config) => {
|
|
158
|
+
const {
|
|
159
|
+
rootDir,
|
|
160
|
+
srcDirectories,
|
|
161
|
+
filters,
|
|
162
|
+
preloadedInspectorState,
|
|
163
|
+
stateOutput,
|
|
164
|
+
} = config
|
|
165
|
+
const variables = new LocalVariablesService()
|
|
166
|
+
|
|
167
|
+
// Store unfiltered state
|
|
168
|
+
let unfilteredState:
|
|
169
|
+
| InspectorState
|
|
170
|
+
| Omit<InspectorState, 'typesLookup'>
|
|
171
|
+
| undefined = preloadedInspectorState
|
|
172
|
+
|
|
173
|
+
const getInspectorState = async (refresh: boolean = false) => {
|
|
174
|
+
// Get or refresh the unfiltered state
|
|
175
|
+
if (!unfilteredState || refresh) {
|
|
176
|
+
// Run inspector WITHOUT filters to get full state
|
|
177
|
+
const wiringFiles = (
|
|
178
|
+
await Promise.all(
|
|
179
|
+
srcDirectories.map((dir) =>
|
|
180
|
+
glob(`${path.join(rootDir, dir)}/**/*.ts`)
|
|
181
|
+
)
|
|
182
|
+
)
|
|
183
|
+
).flat()
|
|
184
|
+
unfilteredState = await inspect(logger, wiringFiles, {
|
|
185
|
+
// NO filters here - inspector returns full unfiltered state
|
|
186
|
+
types: {
|
|
187
|
+
configFileType: config.configFile,
|
|
188
|
+
userSessionType: config.userSessionType,
|
|
189
|
+
singletonServicesFactoryType: config.singletonServicesFactoryType,
|
|
190
|
+
sessionServicesFactoryType: config.sessionServicesFactoryType,
|
|
191
|
+
},
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
// Save unfiltered inspector state to file if stateOutput is provided
|
|
195
|
+
if (stateOutput && 'typesLookup' in unfilteredState) {
|
|
196
|
+
try {
|
|
197
|
+
logger.info(`Saving inspector state to ${stateOutput}`)
|
|
198
|
+
const serialized = serializeInspectorState(unfilteredState)
|
|
199
|
+
await writeFile(
|
|
200
|
+
stateOutput,
|
|
201
|
+
JSON.stringify(serialized, null, 2),
|
|
202
|
+
'utf-8'
|
|
203
|
+
)
|
|
204
|
+
logger.info(`Inspector state saved successfully`)
|
|
205
|
+
} catch (error: any) {
|
|
206
|
+
logger.error(
|
|
207
|
+
`Failed to save inspector state to ${stateOutput}: ${error.message}`
|
|
208
|
+
)
|
|
209
|
+
// Don't throw - state saving is optional/nice-to-have
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Apply filters as a post-processing step
|
|
215
|
+
const filteredState = filterInspectorState(unfilteredState, filters, logger)
|
|
216
|
+
|
|
217
|
+
return filteredState as InspectorState
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
config,
|
|
222
|
+
logger,
|
|
223
|
+
variables,
|
|
224
|
+
getInspectorState,
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export const createSessionServices: CreateSessionServices<
|
|
229
|
+
SingletonServices,
|
|
230
|
+
Services,
|
|
231
|
+
UserSession
|
|
232
|
+
> = async ({ logger }, { cli, channel }) => {
|
|
233
|
+
const vChannel = cli ? cli.channel : channel
|
|
234
|
+
if (!vChannel) {
|
|
235
|
+
throw new Error('No channel provided for CLI services')
|
|
236
|
+
}
|
|
237
|
+
return {
|
|
238
|
+
logger: new CLILoggerForwarder(logger, vChannel),
|
|
239
|
+
}
|
|
240
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { FilesAndMethodsErrors } from '@pikku/inspector'
|
|
2
|
+
|
|
3
|
+
export type RequiredTypes = Partial<{
|
|
4
|
+
config: boolean
|
|
5
|
+
sessionServiceType: boolean
|
|
6
|
+
singletonServicesType: boolean
|
|
7
|
+
userSessionType: boolean
|
|
8
|
+
singletonServicesFactory: boolean
|
|
9
|
+
sessionServicesFactory: boolean
|
|
10
|
+
}>
|
|
11
|
+
|
|
12
|
+
export const checkRequiredTypes = (
|
|
13
|
+
errors: FilesAndMethodsErrors,
|
|
14
|
+
requires: RequiredTypes = {}
|
|
15
|
+
): void => {
|
|
16
|
+
// Only throw if there are errors AND we require those types
|
|
17
|
+
const hasRequiredErrors = Array.from(errors.keys()).some((message) => {
|
|
18
|
+
if (requires.config && message.includes('CoreConfig')) return true
|
|
19
|
+
if (requires.sessionServiceType && message.includes('CoreServices'))
|
|
20
|
+
return true
|
|
21
|
+
if (
|
|
22
|
+
requires.singletonServicesType &&
|
|
23
|
+
message.includes('CoreSingletonServices')
|
|
24
|
+
)
|
|
25
|
+
return true
|
|
26
|
+
if (requires.userSessionType && message.includes('CoreUserSession'))
|
|
27
|
+
return true
|
|
28
|
+
if (
|
|
29
|
+
requires.singletonServicesFactory &&
|
|
30
|
+
message.includes('CreateSingletonServices')
|
|
31
|
+
)
|
|
32
|
+
return true
|
|
33
|
+
if (
|
|
34
|
+
requires.sessionServicesFactory &&
|
|
35
|
+
message.includes('CreateSessionServices')
|
|
36
|
+
)
|
|
37
|
+
return true
|
|
38
|
+
return false
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
if (hasRequiredErrors) {
|
|
42
|
+
const result: string[] = ['Found errors:']
|
|
43
|
+
errors.forEach((filesAndMethods, message) => {
|
|
44
|
+
result.push(`- ${message}`)
|
|
45
|
+
filesAndMethods.forEach((methods, file) => {
|
|
46
|
+
result.push(
|
|
47
|
+
`\t* methods: ${methods.map(({ variable, type }) => `${variable}: ${type}`).join(', ')}`
|
|
48
|
+
)
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
throw new Error(result.join('\n'))
|
|
52
|
+
}
|
|
53
|
+
}
|