@pikku/cli 0.12.6 → 0.12.8
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/cli.schema.json +1 -1
- package/console-app/assets/{index-AX4YS8AA.js → index-DOk9fqHB.js} +49 -49
- package/console-app/index.html +1 -1
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +6 -6
- package/dist/.pikku/agent/pikku-agent-wirings-meta.gen.js +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.d.ts +1 -1
- package/dist/.pikku/agent/pikku-agent-wirings.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channels-meta.gen.js +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channels.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings-meta.gen.json +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +160 -160
- package/dist/.pikku/function/pikku-functions.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-types.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings-meta.gen.js +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.d.ts +1 -1
- package/dist/.pikku/http/pikku-http-wirings.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-types.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings-meta.gen.js +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.d.ts +1 -1
- package/dist/.pikku/mcp/pikku-mcp-wirings.gen.js +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.gen.js +1 -1
- package/dist/.pikku/pikku-websocket.gen.d.ts +1 -1
- package/dist/.pikku/pikku-websocket.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-types.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-remote-rpc-workers.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +2 -2
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-scheduler-types.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings-meta.gen.js +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scheduler/pikku-schedulers-wirings.gen.js +1 -1
- package/dist/.pikku/schemas/register.gen.js +9 -9
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secret-types.gen.js +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.d.ts +1 -1
- package/dist/.pikku/secrets/pikku-secrets.gen.js +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.d.ts +1 -1
- package/dist/.pikku/trigger/pikku-trigger-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variable-types.gen.js +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.d.ts +1 -1
- package/dist/.pikku/variables/pikku-variables.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +35 -5
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +5 -5
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/src/cli.wiring.js +1 -1
- package/dist/src/functions/commands/all.js +16 -1
- package/dist/src/functions/commands/new-addon.js +20 -6
- package/dist/src/functions/commands/versions-check.js +4 -4
- package/dist/src/functions/commands/versions-init.js +1 -1
- package/dist/src/functions/commands/versions-update.js +1 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +2 -2
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.js +2 -2
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.js +2 -2
- package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.js +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-ai-agent-types.js +12 -6
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +5 -5
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +2 -2
- package/dist/src/functions/wirings/console/pikku-command-console-functions.js +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.d.ts +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.js +2 -2
- package/dist/src/functions/wirings/middleware/serialize-middleware-imports.js +22 -0
- package/dist/src/functions/wirings/permissions/serialize-permissions-imports.js +22 -0
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.js +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +1 -1
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +4 -4
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/serialize-rpc-wrapper.js +6 -6
- package/dist/src/functions/wirings/workflow/serialize-workflow-types.js +64 -8
- package/dist/src/services.js +5 -1
- package/dist/src/utils/pikku-cli-config.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/dist/src/utils/openapi/codegen.d.ts +0 -20
- package/dist/src/utils/openapi/codegen.js +0 -442
- package/dist/src/utils/openapi/naming.d.ts +0 -30
- package/dist/src/utils/openapi/naming.js +0 -167
- package/dist/src/utils/openapi/parse-openapi.d.ts +0 -61
- package/dist/src/utils/openapi/parse-openapi.js +0 -306
- package/dist/src/utils/openapi/zod-codegen.d.ts +0 -1
- package/dist/src/utils/openapi/zod-codegen.js +0 -1
|
@@ -354,6 +354,7 @@ const _getPikkuCLIConfig = async (logger, configFile = undefined, requiredFields
|
|
|
354
354
|
if (!result.variablesMetaJsonFile) {
|
|
355
355
|
result.variablesMetaJsonFile = join(variablesDir, 'pikku-variables-meta.gen.json');
|
|
356
356
|
}
|
|
357
|
+
result.globalHTTPPrefix = result.globalHTTPPrefix ? result.globalHTTPPrefix.replace(/\/+$/, '') : '';
|
|
357
358
|
if (requiredFields.length > 0) {
|
|
358
359
|
validateCLIConfig(result, requiredFields);
|
|
359
360
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../bin/pikku.ts","../src/cli.wiring.ts","../src/services.ts","../src/functions/commands/all.ts","../src/functions/commands/bootstrap.ts","../src/functions/commands/console.ts","../src/functions/commands/enable.ts","../src/functions/commands/info.ts","../src/functions/commands/new-addon.ts","../src/functions/commands/new-function.ts","../src/functions/commands/new-middleware.ts","../src/functions/commands/new-permission.ts","../src/functions/commands/new-wiring.ts","../src/functions/commands/pikku-command-bootstrap.ts","../src/functions/commands/pikku-command-summary.ts","../src/functions/commands/versions-check.ts","../src/functions/commands/versions-init.ts","../src/functions/commands/versions-update.ts","../src/functions/commands/watch.ts","../src/functions/runtimes/fetch/index.ts","../src/functions/runtimes/nextjs/pikku-command-nextjs.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/functions/runtimes/websocket/pikku-command-websocket-typed.ts","../src/functions/runtimes/websocket/serialize-websocket-wrapper.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent-types.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent.ts","../src/functions/wirings/ai-agent/pikku-command-public-agent.ts","../src/functions/wirings/ai-agent/serialize-agent-map.ts","../src/functions/wirings/ai-agent/serialize-ai-agent-types.ts","../src/functions/wirings/ai-agent/serialize-public-agent.ts","../src/functions/wirings/channels/pikku-channels.ts","../src/functions/wirings/channels/pikku-command-channel-types.ts","../src/functions/wirings/channels/pikku-command-channels-map.ts","../src/functions/wirings/channels/pikku-command-channels.ts","../src/functions/wirings/channels/serialize-channel-types.ts","../src/functions/wirings/channels/serialize-typed-channel-map.ts","../src/functions/wirings/cli/pikku-command-cli-entry.ts","../src/functions/wirings/cli/pikku-command-cli-types.ts","../src/functions/wirings/cli/pikku-command-cli.ts","../src/functions/wirings/cli/serialize-channel-cli-client.ts","../src/functions/wirings/cli/serialize-channel-cli.ts","../src/functions/wirings/cli/serialize-cli-types.ts","../src/functions/wirings/cli/serialize-local-cli-bootstrap.ts","../src/functions/wirings/console/pikku-command-console-functions.ts","../src/functions/wirings/console/pikku-command-node-types.ts","../src/functions/wirings/console/pikku-command-nodes-meta.ts","../src/functions/wirings/console/serialize-console-functions.ts","../src/functions/wirings/console/serialize-node-types.ts","../src/functions/wirings/functions/pikku-command-addon-types.ts","../src/functions/wirings/functions/pikku-command-function-types-split.ts","../src/functions/wirings/functions/pikku-command-function-types.ts","../src/functions/wirings/functions/pikku-command-functions.ts","../src/functions/wirings/functions/pikku-command-services.ts","../src/functions/wirings/functions/schemas.ts","../src/functions/wirings/functions/serialize-addon-types.ts","../src/functions/wirings/functions/serialize-function-imports.ts","../src/functions/wirings/functions/serialize-function-types.ts","../src/functions/wirings/functions/serialize-pikku-types-hub.ts","../src/functions/wirings/gateway/pikku-command-gateway.ts","../src/functions/wirings/http/pikku-command-http-map.ts","../src/functions/wirings/http/pikku-command-http-routes.ts","../src/functions/wirings/http/pikku-command-http-types.ts","../src/functions/wirings/http/pikku-command-openapi.ts","../src/functions/wirings/http/pikku-http-routes.ts","../src/functions/wirings/http/serialize-fetch-wrapper.ts","../src/functions/wirings/http/serialize-http-types.ts","../src/functions/wirings/http/serialize-typed-http-map.ts","../src/functions/wirings/mcp/pikku-command-mcp-json.ts","../src/functions/wirings/mcp/pikku-command-mcp-types.ts","../src/functions/wirings/mcp/pikku-command-mcp.ts","../src/functions/wirings/mcp/serialize-mcp-types.ts","../src/functions/wirings/middleware/pikku-command-middleware.ts","../src/functions/wirings/middleware/serialize-middleware-imports.ts","../src/functions/wirings/package/pikku-command-package-types.ts","../src/functions/wirings/package/pikku-command-package.ts","../src/functions/wirings/package/serialize-package-types.ts","../src/functions/wirings/package/serialize-package.ts","../src/functions/wirings/permissions/pikku-command-permissions.ts","../src/functions/wirings/permissions/serialize-permissions-imports.ts","../src/functions/wirings/queue/pikku-command-queue-map.ts","../src/functions/wirings/queue/pikku-command-queue-service.ts","../src/functions/wirings/queue/pikku-command-queue-types.ts","../src/functions/wirings/queue/pikku-command-queue.ts","../src/functions/wirings/queue/pikku-queue-map.ts","../src/functions/wirings/queue/pikku-queue.ts","../src/functions/wirings/queue/serialize-queue-map.ts","../src/functions/wirings/queue/serialize-queue-meta.ts","../src/functions/wirings/queue/serialize-queue-types.ts","../src/functions/wirings/queue/serialize-queue-wrapper.ts","../src/functions/wirings/rpc/pikku-command-public-rpc.ts","../src/functions/wirings/rpc/pikku-command-remote-rpc.ts","../src/functions/wirings/rpc/pikku-command-rpc-client.ts","../src/functions/wirings/rpc/pikku-command-rpc-map.ts","../src/functions/wirings/rpc/pikku-command-rpc.ts","../src/functions/wirings/rpc/serialize-public-rpc.ts","../src/functions/wirings/rpc/serialize-remote-rpc.ts","../src/functions/wirings/rpc/serialize-rpc-wrapper.ts","../src/functions/wirings/rpc/serialize-typed-rpc-map.ts","../src/functions/wirings/scheduler/pikku-command-scheduler-types.ts","../src/functions/wirings/scheduler/pikku-command-scheduler.ts","../src/functions/wirings/scheduler/serialize-scheduler-meta.ts","../src/functions/wirings/scheduler/serialize-scheduler-types.ts","../src/functions/wirings/secrets/pikku-command-secrets.ts","../src/functions/wirings/secrets/serialize-secrets-types.ts","../src/functions/wirings/triggers/pikku-command-trigger-types.ts","../src/functions/wirings/triggers/pikku-command-trigger.ts","../src/functions/wirings/triggers/serialize-trigger-meta.ts","../src/functions/wirings/triggers/serialize-trigger-types.ts","../src/functions/wirings/variables/pikku-command-variables.ts","../src/functions/wirings/variables/serialize-variables-types.ts","../src/functions/wirings/workflow/pikku-command-workflow.ts","../src/functions/wirings/workflow/serialize-workflow-map.ts","../src/functions/wirings/workflow/serialize-workflow-meta.ts","../src/functions/wirings/workflow/serialize-workflow-registration.ts","../src/functions/wirings/workflow/serialize-workflow-types.ts","../src/functions/wirings/workflow/serialize-workflow-workers.ts","../src/middleware/log-command-info-and-time.ts","../src/services/cli-logger-forwarder.service.ts","../src/services/cli-logger.service.ts","../src/utils/check-required-types.ts","../src/utils/command-summary.ts","../src/utils/contract-versions.ts","../src/utils/file-import-path.ts","../src/utils/file-imports-serializer.ts","../src/utils/file-writer.ts","../src/utils/generate-bootstrap-file.ts","../src/utils/get-cli-version.ts","../src/utils/pikku-cli-config.ts","../src/utils/pikku-files-and-methods.ts","../src/utils/serialize-import-map.ts","../src/utils/serialize-meta-ts.ts","../src/utils/serialize-schemas.ts","../src/utils/strip-verbose-meta.ts","
|
|
1
|
+
{"root":["../bin/pikku.ts","../src/cli.wiring.ts","../src/services.ts","../src/functions/commands/all.ts","../src/functions/commands/bootstrap.ts","../src/functions/commands/console.ts","../src/functions/commands/enable.ts","../src/functions/commands/info.ts","../src/functions/commands/new-addon.ts","../src/functions/commands/new-function.ts","../src/functions/commands/new-middleware.ts","../src/functions/commands/new-permission.ts","../src/functions/commands/new-wiring.ts","../src/functions/commands/pikku-command-bootstrap.ts","../src/functions/commands/pikku-command-summary.ts","../src/functions/commands/versions-check.ts","../src/functions/commands/versions-init.ts","../src/functions/commands/versions-update.ts","../src/functions/commands/watch.ts","../src/functions/runtimes/fetch/index.ts","../src/functions/runtimes/nextjs/pikku-command-nextjs.ts","../src/functions/runtimes/nextjs/serialize-nextjs-backend-wrapper.ts","../src/functions/runtimes/nextjs/serialize-nextjs-http-wrapper.ts","../src/functions/runtimes/websocket/pikku-command-websocket-typed.ts","../src/functions/runtimes/websocket/serialize-websocket-wrapper.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent-types.ts","../src/functions/wirings/ai-agent/pikku-command-ai-agent.ts","../src/functions/wirings/ai-agent/pikku-command-public-agent.ts","../src/functions/wirings/ai-agent/serialize-agent-map.ts","../src/functions/wirings/ai-agent/serialize-ai-agent-types.ts","../src/functions/wirings/ai-agent/serialize-public-agent.ts","../src/functions/wirings/channels/pikku-channels.ts","../src/functions/wirings/channels/pikku-command-channel-types.ts","../src/functions/wirings/channels/pikku-command-channels-map.ts","../src/functions/wirings/channels/pikku-command-channels.ts","../src/functions/wirings/channels/serialize-channel-types.ts","../src/functions/wirings/channels/serialize-typed-channel-map.ts","../src/functions/wirings/cli/pikku-command-cli-entry.ts","../src/functions/wirings/cli/pikku-command-cli-types.ts","../src/functions/wirings/cli/pikku-command-cli.ts","../src/functions/wirings/cli/serialize-channel-cli-client.ts","../src/functions/wirings/cli/serialize-channel-cli.ts","../src/functions/wirings/cli/serialize-cli-types.ts","../src/functions/wirings/cli/serialize-local-cli-bootstrap.ts","../src/functions/wirings/console/pikku-command-console-functions.ts","../src/functions/wirings/console/pikku-command-node-types.ts","../src/functions/wirings/console/pikku-command-nodes-meta.ts","../src/functions/wirings/console/serialize-console-functions.ts","../src/functions/wirings/console/serialize-node-types.ts","../src/functions/wirings/functions/pikku-command-addon-types.ts","../src/functions/wirings/functions/pikku-command-function-types-split.ts","../src/functions/wirings/functions/pikku-command-function-types.ts","../src/functions/wirings/functions/pikku-command-functions.ts","../src/functions/wirings/functions/pikku-command-services.ts","../src/functions/wirings/functions/schemas.ts","../src/functions/wirings/functions/serialize-addon-types.ts","../src/functions/wirings/functions/serialize-function-imports.ts","../src/functions/wirings/functions/serialize-function-types.ts","../src/functions/wirings/functions/serialize-pikku-types-hub.ts","../src/functions/wirings/gateway/pikku-command-gateway.ts","../src/functions/wirings/http/pikku-command-http-map.ts","../src/functions/wirings/http/pikku-command-http-routes.ts","../src/functions/wirings/http/pikku-command-http-types.ts","../src/functions/wirings/http/pikku-command-openapi.ts","../src/functions/wirings/http/pikku-http-routes.ts","../src/functions/wirings/http/serialize-fetch-wrapper.ts","../src/functions/wirings/http/serialize-http-types.ts","../src/functions/wirings/http/serialize-typed-http-map.ts","../src/functions/wirings/mcp/pikku-command-mcp-json.ts","../src/functions/wirings/mcp/pikku-command-mcp-types.ts","../src/functions/wirings/mcp/pikku-command-mcp.ts","../src/functions/wirings/mcp/serialize-mcp-types.ts","../src/functions/wirings/middleware/pikku-command-middleware.ts","../src/functions/wirings/middleware/serialize-middleware-imports.ts","../src/functions/wirings/package/pikku-command-package-types.ts","../src/functions/wirings/package/pikku-command-package.ts","../src/functions/wirings/package/serialize-package-types.ts","../src/functions/wirings/package/serialize-package.ts","../src/functions/wirings/permissions/pikku-command-permissions.ts","../src/functions/wirings/permissions/serialize-permissions-imports.ts","../src/functions/wirings/queue/pikku-command-queue-map.ts","../src/functions/wirings/queue/pikku-command-queue-service.ts","../src/functions/wirings/queue/pikku-command-queue-types.ts","../src/functions/wirings/queue/pikku-command-queue.ts","../src/functions/wirings/queue/pikku-queue-map.ts","../src/functions/wirings/queue/pikku-queue.ts","../src/functions/wirings/queue/serialize-queue-map.ts","../src/functions/wirings/queue/serialize-queue-meta.ts","../src/functions/wirings/queue/serialize-queue-types.ts","../src/functions/wirings/queue/serialize-queue-wrapper.ts","../src/functions/wirings/rpc/pikku-command-public-rpc.ts","../src/functions/wirings/rpc/pikku-command-remote-rpc.ts","../src/functions/wirings/rpc/pikku-command-rpc-client.ts","../src/functions/wirings/rpc/pikku-command-rpc-map.ts","../src/functions/wirings/rpc/pikku-command-rpc.ts","../src/functions/wirings/rpc/serialize-public-rpc.ts","../src/functions/wirings/rpc/serialize-remote-rpc.ts","../src/functions/wirings/rpc/serialize-rpc-wrapper.ts","../src/functions/wirings/rpc/serialize-typed-rpc-map.ts","../src/functions/wirings/scheduler/pikku-command-scheduler-types.ts","../src/functions/wirings/scheduler/pikku-command-scheduler.ts","../src/functions/wirings/scheduler/serialize-scheduler-meta.ts","../src/functions/wirings/scheduler/serialize-scheduler-types.ts","../src/functions/wirings/secrets/pikku-command-secrets.ts","../src/functions/wirings/secrets/serialize-secrets-types.ts","../src/functions/wirings/triggers/pikku-command-trigger-types.ts","../src/functions/wirings/triggers/pikku-command-trigger.ts","../src/functions/wirings/triggers/serialize-trigger-meta.ts","../src/functions/wirings/triggers/serialize-trigger-types.ts","../src/functions/wirings/variables/pikku-command-variables.ts","../src/functions/wirings/variables/serialize-variables-types.ts","../src/functions/wirings/workflow/pikku-command-workflow.ts","../src/functions/wirings/workflow/serialize-workflow-map.ts","../src/functions/wirings/workflow/serialize-workflow-meta.ts","../src/functions/wirings/workflow/serialize-workflow-registration.ts","../src/functions/wirings/workflow/serialize-workflow-types.ts","../src/functions/wirings/workflow/serialize-workflow-workers.ts","../src/middleware/log-command-info-and-time.ts","../src/services/cli-logger-forwarder.service.ts","../src/services/cli-logger.service.ts","../src/utils/check-required-types.ts","../src/utils/command-summary.ts","../src/utils/contract-versions.ts","../src/utils/file-import-path.ts","../src/utils/file-imports-serializer.ts","../src/utils/file-writer.ts","../src/utils/generate-bootstrap-file.ts","../src/utils/get-cli-version.ts","../src/utils/pikku-cli-config.ts","../src/utils/pikku-files-and-methods.ts","../src/utils/serialize-import-map.ts","../src/utils/serialize-meta-ts.ts","../src/utils/serialize-schemas.ts","../src/utils/strip-verbose-meta.ts","../.pikku/pikku-bootstrap.gen.ts","../.pikku/pikku-services.gen.ts","../.pikku/pikku-types.gen.ts","../.pikku/pikku-websocket.gen.ts","../.pikku/agent/pikku-agent-map.gen.d.ts","../.pikku/agent/pikku-agent-types.gen.ts","../.pikku/agent/pikku-agent-wirings-meta.gen.ts","../.pikku/agent/pikku-agent-wirings.gen.ts","../.pikku/channel/pikku-channel-types.gen.ts","../.pikku/channel/pikku-channels-map.gen.d.ts","../.pikku/channel/pikku-channels-meta.gen.ts","../.pikku/channel/pikku-channels.gen.ts","../.pikku/cli/pikku-cli-channel.ts","../.pikku/cli/pikku-cli-client.gen.ts","../.pikku/cli/pikku-cli-types.gen.ts","../.pikku/cli/pikku-cli-wirings-meta.gen.ts","../.pikku/cli/pikku-cli-wirings.gen.ts","../.pikku/cli/pikku-cli.gen.ts","../.pikku/console/pikku-node-types.gen.ts","../.pikku/function/pikku-function-types.gen.ts","../.pikku/function/pikku-functions-meta.gen.ts","../.pikku/function/pikku-functions.gen.ts","../.pikku/http/pikku-http-types.gen.ts","../.pikku/http/pikku-http-wirings-map.gen.d.ts","../.pikku/http/pikku-http-wirings-meta.gen.ts","../.pikku/http/pikku-http-wirings.gen.ts","../.pikku/mcp/pikku-mcp-types.gen.ts","../.pikku/mcp/pikku-mcp-wirings-meta.gen.ts","../.pikku/mcp/pikku-mcp-wirings.gen.ts","../.pikku/node/pikku-node-types.gen.ts","../.pikku/queue/pikku-queue-types.gen.ts","../.pikku/queue/pikku-queue-workers-wirings-map.gen.d.ts","../.pikku/queue/pikku-queue-workers-wirings-meta.gen.ts","../.pikku/queue/pikku-queue-workers-wirings.gen.ts","../.pikku/rpc/pikku-remote-rpc-workers.gen.ts","../.pikku/rpc/pikku-rpc-wirings-map.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-map.internal.gen.d.ts","../.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.ts","../.pikku/scheduler/pikku-scheduler-types.gen.ts","../.pikku/scheduler/pikku-schedulers-wirings-meta.gen.ts","../.pikku/scheduler/pikku-schedulers-wirings.gen.ts","../.pikku/schemas/register.gen.ts","../.pikku/secrets/pikku-secret-types.gen.ts","../.pikku/secrets/pikku-secrets.gen.ts","../.pikku/trigger/pikku-trigger-types.gen.ts","../.pikku/variables/pikku-variable-types.gen.ts","../.pikku/variables/pikku-variables.gen.ts","../.pikku/workflow/pikku-workflow-map.gen.d.ts","../.pikku/workflow/pikku-workflow-types.gen.ts","../.pikku/workflow/pikku-workflow-wirings-meta.gen.ts","../.pikku/workflow/pikku-workflow-wirings.gen.ts","../types/application-types.d.ts","../types/config.d.ts"],"version":"5.9.3"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pikku/cli",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.8",
|
|
4
4
|
"author": "yasser.fadl@gmail.com",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"imports": {
|
|
@@ -21,13 +21,14 @@
|
|
|
21
21
|
"release": "yarn build && npm test",
|
|
22
22
|
"test": "bash run-tests.sh",
|
|
23
23
|
"test:watch": "bash run-tests.sh --watch",
|
|
24
|
-
"test:coverage": "bash run-tests.sh --coverage"
|
|
24
|
+
"test:coverage": "bash run-tests.sh --coverage",
|
|
25
|
+
"prepublishOnly": "yarn build"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@openapi-contrib/json-schema-to-openapi-schema": "^4.3.1",
|
|
28
|
-
"@pikku/core": "^0.12.
|
|
29
|
-
"@pikku/inspector": "^0.12.
|
|
30
|
-
"@pikku/openapi-
|
|
29
|
+
"@pikku/core": "^0.12.9",
|
|
30
|
+
"@pikku/inspector": "^0.12.4",
|
|
31
|
+
"@pikku/openapi-parser": "^0.12.4",
|
|
31
32
|
"@types/cookie": "^1.0.0",
|
|
32
33
|
"@types/json-schema": "^7.0.15",
|
|
33
34
|
"chalk": "^5.6.2",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates addon files from a parsed OpenAPI spec.
|
|
3
|
-
* Returns Record<string, string> compatible with getAddonFiles output.
|
|
4
|
-
*/
|
|
5
|
-
import type { ParsedSpec } from './parse-openapi.js';
|
|
6
|
-
interface AddonVars {
|
|
7
|
-
name: string;
|
|
8
|
-
camelName: string;
|
|
9
|
-
pascalName: string;
|
|
10
|
-
screamingName: string;
|
|
11
|
-
displayName: string;
|
|
12
|
-
description: string;
|
|
13
|
-
}
|
|
14
|
-
interface CodegenFlags {
|
|
15
|
-
oauth: boolean;
|
|
16
|
-
secret: boolean;
|
|
17
|
-
mcp?: boolean;
|
|
18
|
-
}
|
|
19
|
-
export declare function generateAddonFromOpenAPI(spec: ParsedSpec, vars: AddonVars, flags: CodegenFlags): Record<string, string>;
|
|
20
|
-
export {};
|
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
import { schemaToZod, schemaVarName, sanitizeTypeName, createContext, } from './zod-codegen.js';
|
|
2
|
-
import { generateOperationNames, detectCommonPrefix, } from './naming.js';
|
|
3
|
-
function safeKey(key) {
|
|
4
|
-
return /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
5
|
-
}
|
|
6
|
-
const GENERIC_SUMMARIES = new Set([
|
|
7
|
-
'index',
|
|
8
|
-
'show',
|
|
9
|
-
'create',
|
|
10
|
-
'update',
|
|
11
|
-
'destroy',
|
|
12
|
-
'delete',
|
|
13
|
-
'list',
|
|
14
|
-
]);
|
|
15
|
-
/** Map from HTTP status code to pikku error class name */
|
|
16
|
-
const STATUS_TO_ERROR = {
|
|
17
|
-
400: 'BadRequestError',
|
|
18
|
-
401: 'UnauthorizedError',
|
|
19
|
-
403: 'ForbiddenError',
|
|
20
|
-
404: 'NotFoundError',
|
|
21
|
-
405: 'MethodNotAllowedError',
|
|
22
|
-
409: 'ConflictError',
|
|
23
|
-
422: 'UnprocessableContentError',
|
|
24
|
-
429: 'TooManyRequestsError',
|
|
25
|
-
500: 'InternalServerError',
|
|
26
|
-
};
|
|
27
|
-
function capitalize(str) {
|
|
28
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
29
|
-
}
|
|
30
|
-
function humanDescription(parsed) {
|
|
31
|
-
const description = parsed.description?.trim();
|
|
32
|
-
if (description && !GENERIC_SUMMARIES.has(description.toLowerCase())) {
|
|
33
|
-
return capitalize(description);
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
function getErrorClassesForResponses(errorResponses) {
|
|
38
|
-
const classes = [];
|
|
39
|
-
for (const err of errorResponses) {
|
|
40
|
-
const cls = STATUS_TO_ERROR[err.statusCode];
|
|
41
|
-
if (cls && !classes.includes(cls)) {
|
|
42
|
-
classes.push(cls);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return classes;
|
|
46
|
-
}
|
|
47
|
-
export function generateAddonFromOpenAPI(spec, vars, flags) {
|
|
48
|
-
const files = {};
|
|
49
|
-
const { name } = vars;
|
|
50
|
-
// Build context for Zod codegen with component schema refs
|
|
51
|
-
const schemaRefs = new Map();
|
|
52
|
-
for (const schemaName of Object.keys(spec.componentSchemas)) {
|
|
53
|
-
schemaRefs.set(schemaName, schemaVarName(schemaName));
|
|
54
|
-
}
|
|
55
|
-
const ctx = createContext(schemaRefs);
|
|
56
|
-
// Generate operation names
|
|
57
|
-
const paths = spec.operations.map((op) => op.path);
|
|
58
|
-
const commonPrefix = detectCommonPrefix(paths);
|
|
59
|
-
const namedOps = generateOperationNames(spec.operations.map((op) => ({
|
|
60
|
-
method: op.method,
|
|
61
|
-
path: op.path,
|
|
62
|
-
operationId: op.operationId,
|
|
63
|
-
})), commonPrefix);
|
|
64
|
-
// Pair named operations with their parsed data
|
|
65
|
-
const opPairs = namedOps.map((named, i) => ({ named, parsed: spec.operations[i] }));
|
|
66
|
-
// Generate types file with shared schemas (only if there are any)
|
|
67
|
-
if (Object.keys(spec.componentSchemas).length > 0) {
|
|
68
|
-
files[`src/${name}.types.ts`] = generateTypesFile(spec, ctx);
|
|
69
|
-
}
|
|
70
|
-
// Generate function files
|
|
71
|
-
const functionExports = [];
|
|
72
|
-
for (const { named, parsed } of opPairs) {
|
|
73
|
-
const funcCtx = createContext(schemaRefs);
|
|
74
|
-
const funcCode = generateFunctionFile(named, parsed, vars, funcCtx, spec, flags);
|
|
75
|
-
files[`src/functions/${named.functionName}.function.ts`] = funcCode;
|
|
76
|
-
functionExports.push(named.functionName);
|
|
77
|
-
}
|
|
78
|
-
// Generate index.ts with all exports
|
|
79
|
-
files['src/index.ts'] = generateIndexFile(functionExports);
|
|
80
|
-
// Generate typed API service class with route map
|
|
81
|
-
files[`src/${name}-api.service.ts`] = generateServiceFile(spec, opPairs, vars, flags);
|
|
82
|
-
// Generate variable file for BASE_URL
|
|
83
|
-
files[`src/${name}.variable.ts`] = generateVariableFile(spec, vars);
|
|
84
|
-
return files;
|
|
85
|
-
}
|
|
86
|
-
function generateTypesFile(spec, ctx) {
|
|
87
|
-
const lines = [];
|
|
88
|
-
lines.push("import { z } from 'zod'");
|
|
89
|
-
lines.push('');
|
|
90
|
-
lines.push(`// Shared schemas from ${spec.info.title} v${spec.info.version}`);
|
|
91
|
-
lines.push('');
|
|
92
|
-
for (const [name, schema] of Object.entries(spec.componentSchemas)) {
|
|
93
|
-
const varName = schemaVarName(name);
|
|
94
|
-
const zodCode = schemaToZod(schema, ctx);
|
|
95
|
-
lines.push(`export const ${varName} = ${zodCode}`);
|
|
96
|
-
lines.push(`export type ${sanitizeTypeName(name)} = z.infer<typeof ${varName}>`);
|
|
97
|
-
lines.push('');
|
|
98
|
-
}
|
|
99
|
-
return lines.join('\n');
|
|
100
|
-
}
|
|
101
|
-
function generateFunctionFile(named, parsed, vars, ctx, spec, flags) {
|
|
102
|
-
const lines = [];
|
|
103
|
-
const { camelName } = vars;
|
|
104
|
-
// Tag description as file header
|
|
105
|
-
if (parsed.tags.length > 0) {
|
|
106
|
-
const tag = parsed.tags[0];
|
|
107
|
-
const tagDesc = spec.tagDescriptions[tag];
|
|
108
|
-
if (tagDesc) {
|
|
109
|
-
lines.push(`// ${tag} — ${tagDesc}`);
|
|
110
|
-
lines.push('');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
const hasInput = parsed.pathParams.length > 0 ||
|
|
114
|
-
parsed.queryParams.length > 0 ||
|
|
115
|
-
parsed.headerParams.length > 0 ||
|
|
116
|
-
parsed.requestBody;
|
|
117
|
-
const pascalName = named.functionName.charAt(0).toUpperCase() + named.functionName.slice(1);
|
|
118
|
-
const inputName = `${pascalName}Input`;
|
|
119
|
-
const outputName = `${pascalName}Output`;
|
|
120
|
-
// Determine error imports needed
|
|
121
|
-
const errorClasses = getErrorClassesForResponses(parsed.errorResponses);
|
|
122
|
-
lines.push("import { z } from 'zod'");
|
|
123
|
-
lines.push("import { pikkuSessionlessFunc } from '#pikku'");
|
|
124
|
-
if (errorClasses.length > 0) {
|
|
125
|
-
lines.push(`import { ${errorClasses.join(', ')} } from '@pikku/core/errors'`);
|
|
126
|
-
}
|
|
127
|
-
lines.push('');
|
|
128
|
-
// Build Input schema (exported for pikku schema discovery)
|
|
129
|
-
if (hasInput) {
|
|
130
|
-
const inputCode = buildInputSchema(parsed, ctx);
|
|
131
|
-
lines.push(`export const ${inputName} = ${inputCode}`);
|
|
132
|
-
lines.push('');
|
|
133
|
-
}
|
|
134
|
-
// Build Output schema (exported for pikku schema discovery)
|
|
135
|
-
if (parsed.responseSchema) {
|
|
136
|
-
const outputCode = buildOutputSchema(parsed.responseSchema, ctx);
|
|
137
|
-
lines.push(`export const ${outputName} = ${outputCode}`);
|
|
138
|
-
lines.push('');
|
|
139
|
-
}
|
|
140
|
-
const description = humanDescription(parsed);
|
|
141
|
-
const method = parsed.method.toUpperCase();
|
|
142
|
-
const funcConfig = [];
|
|
143
|
-
if (description) {
|
|
144
|
-
funcConfig.push(` description: ${JSON.stringify(description)},`);
|
|
145
|
-
}
|
|
146
|
-
if (hasInput)
|
|
147
|
-
funcConfig.push(` input: ${inputName},`);
|
|
148
|
-
if (parsed.responseSchema) {
|
|
149
|
-
funcConfig.push(` output: ${outputName},`);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
funcConfig.push(' output: z.void(),');
|
|
153
|
-
}
|
|
154
|
-
if (errorClasses.length > 0) {
|
|
155
|
-
funcConfig.push(` errors: [${errorClasses.join(', ')}],`);
|
|
156
|
-
}
|
|
157
|
-
if (flags.mcp) {
|
|
158
|
-
funcConfig.push(' mcp: true,');
|
|
159
|
-
}
|
|
160
|
-
const funcParams = hasInput ? `{ ${camelName} }, data` : `{ ${camelName} }`;
|
|
161
|
-
const returnCast = parsed.responseSchema ? ' as any' : '';
|
|
162
|
-
funcConfig.push(` func: async (${funcParams}) => {`, ` return ${camelName}.call('${method}', '${parsed.path}'${hasInput ? ', data' : ''})${returnCast}`, ' },');
|
|
163
|
-
lines.push(`export const ${named.functionName} = pikkuSessionlessFunc({`);
|
|
164
|
-
lines.push(funcConfig.join('\n'));
|
|
165
|
-
lines.push('})');
|
|
166
|
-
lines.push('');
|
|
167
|
-
return lines.join('\n');
|
|
168
|
-
}
|
|
169
|
-
function buildInputSchema(parsed, ctx) {
|
|
170
|
-
const props = [];
|
|
171
|
-
for (const param of parsed.pathParams) {
|
|
172
|
-
props.push(formatParamProp(param, ctx));
|
|
173
|
-
}
|
|
174
|
-
for (const param of parsed.queryParams) {
|
|
175
|
-
props.push(formatParamProp(param, ctx));
|
|
176
|
-
}
|
|
177
|
-
for (const param of parsed.headerParams) {
|
|
178
|
-
props.push(formatParamProp(param, ctx));
|
|
179
|
-
}
|
|
180
|
-
if (parsed.requestBody) {
|
|
181
|
-
if (parsed.requestBody.properties) {
|
|
182
|
-
const requiredSet = new Set(parsed.requestBody.required ?? []);
|
|
183
|
-
for (const [key, propSchema] of Object.entries(parsed.requestBody.properties)) {
|
|
184
|
-
// Skip readOnly properties from input
|
|
185
|
-
if (propSchema.readOnly)
|
|
186
|
-
continue;
|
|
187
|
-
const isOptional = !requiredSet.has(key);
|
|
188
|
-
const zodCode = schemaToZod(propSchema, ctx, { optional: isOptional });
|
|
189
|
-
const withDesc = propSchema.description
|
|
190
|
-
? `${zodCode}.describe(${JSON.stringify(propSchema.description)})`
|
|
191
|
-
: zodCode;
|
|
192
|
-
props.push(` ${safeKey(key)}: ${withDesc},`);
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
const bodyZod = schemaToZod(parsed.requestBody, ctx);
|
|
197
|
-
props.push(` body: ${bodyZod},`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
return `z.object({\n${props.join('\n')}\n})`;
|
|
201
|
-
}
|
|
202
|
-
function formatParamProp(param, ctx) {
|
|
203
|
-
const zodCode = schemaToZod(param.schema, ctx, { optional: !param.required });
|
|
204
|
-
let descParts = [];
|
|
205
|
-
if (param.description)
|
|
206
|
-
descParts.push(param.description);
|
|
207
|
-
if (param.example !== undefined)
|
|
208
|
-
descParts.push(`Example: ${JSON.stringify(param.example)}`);
|
|
209
|
-
const desc = descParts.length > 0
|
|
210
|
-
? `${zodCode}.describe(${JSON.stringify(descParts.join('. '))})`
|
|
211
|
-
: zodCode;
|
|
212
|
-
return ` ${safeKey(param.name)}: ${desc},`;
|
|
213
|
-
}
|
|
214
|
-
function buildOutputSchema(schema, ctx) {
|
|
215
|
-
// For output schemas, filter out writeOnly properties
|
|
216
|
-
if (schema.properties) {
|
|
217
|
-
const filteredProps = {};
|
|
218
|
-
for (const [key, propSchema] of Object.entries(schema.properties)) {
|
|
219
|
-
if (!propSchema.writeOnly) {
|
|
220
|
-
filteredProps[key] = propSchema;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
const filteredSchema = { ...schema, properties: filteredProps };
|
|
224
|
-
return schemaToZod(filteredSchema, ctx);
|
|
225
|
-
}
|
|
226
|
-
return schemaToZod(schema, ctx);
|
|
227
|
-
}
|
|
228
|
-
function generateIndexFile(functionExports) {
|
|
229
|
-
const lines = [];
|
|
230
|
-
for (const name of functionExports) {
|
|
231
|
-
lines.push(`export { ${name} } from './functions/${name}.function.js'`);
|
|
232
|
-
}
|
|
233
|
-
lines.push('');
|
|
234
|
-
return lines.join('\n');
|
|
235
|
-
}
|
|
236
|
-
function generateServiceFile(spec, opPairs, vars, flags) {
|
|
237
|
-
const { name, pascalName, screamingName, displayName } = vars;
|
|
238
|
-
const lines = [];
|
|
239
|
-
// Always import all error classes used in the switch statement
|
|
240
|
-
const allErrorClasses = new Set(Object.values(STATUS_TO_ERROR));
|
|
241
|
-
if (flags.oauth) {
|
|
242
|
-
lines.push("import { OAuth2Client } from '@pikku/core/oauth2'");
|
|
243
|
-
lines.push("import type { TypedSecretService } from '#pikku/secrets/pikku-secrets.gen.js'");
|
|
244
|
-
}
|
|
245
|
-
else if (flags.secret) {
|
|
246
|
-
lines.push(`import type { ${pascalName}Secrets } from './${name}.secret.js'`);
|
|
247
|
-
}
|
|
248
|
-
if (allErrorClasses.size > 0) {
|
|
249
|
-
lines.push(`import { ${[...allErrorClasses].sort().join(', ')} } from '@pikku/core/errors'`);
|
|
250
|
-
}
|
|
251
|
-
lines.push(`import type { TypedVariablesService } from '#pikku/variables/pikku-variables.gen.js'`);
|
|
252
|
-
lines.push('');
|
|
253
|
-
if (flags.oauth) {
|
|
254
|
-
// Use OAuth2 details from spec if available
|
|
255
|
-
const oauthScheme = Object.values(spec.securitySchemes).find((s) => s.type === 'oauth2');
|
|
256
|
-
const authUrl = oauthScheme?.flows?.authorizationUrl ??
|
|
257
|
-
'https://example.com/oauth2/authorize';
|
|
258
|
-
const tokenUrl = oauthScheme?.flows?.tokenUrl ?? 'https://example.com/oauth2/token';
|
|
259
|
-
const scopes = oauthScheme?.flows?.scopes
|
|
260
|
-
? Object.keys(oauthScheme.flows.scopes)
|
|
261
|
-
: ['read', 'write'];
|
|
262
|
-
lines.push(`export const ${screamingName}_OAUTH2_CONFIG = {`);
|
|
263
|
-
lines.push(` tokenSecretId: '${screamingName}_TOKENS',`);
|
|
264
|
-
lines.push(` authorizationUrl: ${JSON.stringify(authUrl)},`);
|
|
265
|
-
lines.push(` tokenUrl: ${JSON.stringify(tokenUrl)},`);
|
|
266
|
-
lines.push(` scopes: ${JSON.stringify(scopes)},`);
|
|
267
|
-
lines.push('}');
|
|
268
|
-
lines.push('');
|
|
269
|
-
}
|
|
270
|
-
// Generate route map from parsed operations
|
|
271
|
-
const routes = {};
|
|
272
|
-
for (const { parsed } of opPairs) {
|
|
273
|
-
const key = `${parsed.method.toUpperCase()} ${parsed.path}`;
|
|
274
|
-
const route = {
|
|
275
|
-
path: parsed.pathParams.map((p) => p.name),
|
|
276
|
-
query: parsed.queryParams.map((p) => p.name),
|
|
277
|
-
headers: parsed.headerParams.map((p) => p.name),
|
|
278
|
-
};
|
|
279
|
-
if (parsed.errorResponses.length > 0) {
|
|
280
|
-
route.errors = {};
|
|
281
|
-
for (const err of parsed.errorResponses) {
|
|
282
|
-
route.errors[err.statusCode] = err.description;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
routes[key] = route;
|
|
286
|
-
}
|
|
287
|
-
lines.push(`const ROUTES: Record<string, { path: string[], query: string[], headers: string[], errors?: Record<number, string> }> = ${JSON.stringify(routes, null, 2)}`);
|
|
288
|
-
lines.push('');
|
|
289
|
-
// Class declaration
|
|
290
|
-
lines.push(`export class ${pascalName}Service {`);
|
|
291
|
-
lines.push(' private baseUrl: string');
|
|
292
|
-
if (flags.oauth) {
|
|
293
|
-
lines.push(' private oauth: OAuth2Client');
|
|
294
|
-
lines.push('');
|
|
295
|
-
lines.push(` constructor(secrets: TypedSecretService, variables: TypedVariablesService) {`);
|
|
296
|
-
lines.push(` this.baseUrl = variables.get('${screamingName}_BASE_URL') as string`);
|
|
297
|
-
lines.push(' this.oauth = new OAuth2Client(');
|
|
298
|
-
lines.push(` ${screamingName}_OAUTH2_CONFIG,`);
|
|
299
|
-
lines.push(` '${screamingName}_APP_CREDENTIALS',`);
|
|
300
|
-
lines.push(' secrets');
|
|
301
|
-
lines.push(' )');
|
|
302
|
-
lines.push(' }');
|
|
303
|
-
}
|
|
304
|
-
else if (flags.secret) {
|
|
305
|
-
lines.push('');
|
|
306
|
-
lines.push(` constructor(private creds: ${pascalName}Secrets, variables: TypedVariablesService) {`);
|
|
307
|
-
lines.push(` this.baseUrl = variables.get('${screamingName}_BASE_URL') as string`);
|
|
308
|
-
lines.push(' }');
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
lines.push('');
|
|
312
|
-
lines.push(` constructor(variables: TypedVariablesService) {`);
|
|
313
|
-
lines.push(` this.baseUrl = variables.get('${screamingName}_BASE_URL') as string`);
|
|
314
|
-
lines.push(' }');
|
|
315
|
-
}
|
|
316
|
-
lines.push('');
|
|
317
|
-
// call() method — splits data into path/query/headers/body using route map
|
|
318
|
-
lines.push(' async call<T>(');
|
|
319
|
-
lines.push(" method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',");
|
|
320
|
-
lines.push(' path: string,');
|
|
321
|
-
lines.push(' data?: Record<string, unknown>');
|
|
322
|
-
lines.push(' ): Promise<T> {');
|
|
323
|
-
lines.push(' const route = ROUTES[`${method} ${path}`]');
|
|
324
|
-
lines.push(' let endpoint = path');
|
|
325
|
-
lines.push(' let body: Record<string, unknown> | undefined');
|
|
326
|
-
lines.push(' const query: Record<string, string> = {}');
|
|
327
|
-
lines.push(' const headers: Record<string, string> = {');
|
|
328
|
-
lines.push(" 'Content-Type': 'application/json',");
|
|
329
|
-
lines.push(' }');
|
|
330
|
-
lines.push('');
|
|
331
|
-
lines.push(' if (data && route) {');
|
|
332
|
-
lines.push(' // Interpolate path params');
|
|
333
|
-
lines.push(' for (const param of route.path) {');
|
|
334
|
-
lines.push(' if (data[param] !== undefined) {');
|
|
335
|
-
lines.push(' endpoint = endpoint.replace(`{${param}}`, String(data[param]))');
|
|
336
|
-
lines.push(' }');
|
|
337
|
-
lines.push(' }');
|
|
338
|
-
lines.push(' // Extract query params');
|
|
339
|
-
lines.push(' for (const param of route.query) {');
|
|
340
|
-
lines.push(' if (data[param] !== undefined) {');
|
|
341
|
-
lines.push(' query[param] = String(data[param])');
|
|
342
|
-
lines.push(' }');
|
|
343
|
-
lines.push(' }');
|
|
344
|
-
lines.push(' // Extract header params');
|
|
345
|
-
lines.push(' for (const param of route.headers) {');
|
|
346
|
-
lines.push(' if (data[param] !== undefined) {');
|
|
347
|
-
lines.push(' headers[param] = String(data[param])');
|
|
348
|
-
lines.push(' }');
|
|
349
|
-
lines.push(' }');
|
|
350
|
-
lines.push(' // Everything else goes into body');
|
|
351
|
-
lines.push(' const pathQueryHeaders = new Set([...route.path, ...route.query, ...route.headers])');
|
|
352
|
-
lines.push(' const remaining = Object.fromEntries(');
|
|
353
|
-
lines.push(' Object.entries(data).filter(([k]) => !pathQueryHeaders.has(k))');
|
|
354
|
-
lines.push(' )');
|
|
355
|
-
lines.push(' if (Object.keys(remaining).length > 0) {');
|
|
356
|
-
lines.push(' body = remaining');
|
|
357
|
-
lines.push(' }');
|
|
358
|
-
lines.push(' }');
|
|
359
|
-
lines.push('');
|
|
360
|
-
lines.push(' const url = new URL(`${this.baseUrl}${endpoint}`)');
|
|
361
|
-
lines.push(' for (const [key, value] of Object.entries(query)) {');
|
|
362
|
-
lines.push(' url.searchParams.set(key, value)');
|
|
363
|
-
lines.push(' }');
|
|
364
|
-
lines.push('');
|
|
365
|
-
if (flags.oauth) {
|
|
366
|
-
lines.push(' const response = await this.oauth.request(url.toString(), {');
|
|
367
|
-
lines.push(' method,');
|
|
368
|
-
lines.push(' headers,');
|
|
369
|
-
lines.push(' body: body ? JSON.stringify(body) : undefined,');
|
|
370
|
-
lines.push(' })');
|
|
371
|
-
}
|
|
372
|
-
else if (flags.secret) {
|
|
373
|
-
// Use apiKey details from spec if available
|
|
374
|
-
const apiKeyScheme = Object.values(spec.securitySchemes).find((s) => s.type === 'apiKey');
|
|
375
|
-
if (apiKeyScheme?.name && apiKeyScheme?.in === 'header') {
|
|
376
|
-
lines.push(` headers[${JSON.stringify(apiKeyScheme.name)}] = this.creds.apiKey`);
|
|
377
|
-
}
|
|
378
|
-
else {
|
|
379
|
-
lines.push(' headers.Authorization = `Bearer ${this.creds.apiKey}`');
|
|
380
|
-
}
|
|
381
|
-
lines.push('');
|
|
382
|
-
lines.push(' const response = await fetch(url.toString(), {');
|
|
383
|
-
lines.push(' method,');
|
|
384
|
-
lines.push(' headers,');
|
|
385
|
-
lines.push(' body: body ? JSON.stringify(body) : undefined,');
|
|
386
|
-
lines.push(' })');
|
|
387
|
-
}
|
|
388
|
-
else {
|
|
389
|
-
lines.push(' const response = await fetch(url.toString(), {');
|
|
390
|
-
lines.push(' method,');
|
|
391
|
-
lines.push(' headers,');
|
|
392
|
-
lines.push(' body: body ? JSON.stringify(body) : undefined,');
|
|
393
|
-
lines.push(' })');
|
|
394
|
-
}
|
|
395
|
-
lines.push('');
|
|
396
|
-
lines.push(' if (!response.ok) {');
|
|
397
|
-
lines.push(' const errorText = await response.text()');
|
|
398
|
-
lines.push(' const errorMessage = route?.errors?.[response.status] ?? errorText');
|
|
399
|
-
lines.push(' switch (response.status) {');
|
|
400
|
-
lines.push(' case 400: throw new BadRequestError(errorMessage)');
|
|
401
|
-
lines.push(' case 401: throw new UnauthorizedError(errorMessage)');
|
|
402
|
-
lines.push(' case 403: throw new ForbiddenError(errorMessage)');
|
|
403
|
-
lines.push(' case 404: throw new NotFoundError(errorMessage)');
|
|
404
|
-
lines.push(' case 405: throw new MethodNotAllowedError(errorMessage)');
|
|
405
|
-
lines.push(' case 409: throw new ConflictError(errorMessage)');
|
|
406
|
-
lines.push(' case 422: throw new UnprocessableContentError(errorMessage)');
|
|
407
|
-
lines.push(' case 429: throw new TooManyRequestsError(errorMessage)');
|
|
408
|
-
lines.push(' case 500: throw new InternalServerError(errorMessage)');
|
|
409
|
-
lines.push(` default: throw new Error(\`${displayName} API error (\${response.status}): \${errorText}\`)`);
|
|
410
|
-
lines.push(' }');
|
|
411
|
-
lines.push(' }');
|
|
412
|
-
lines.push('');
|
|
413
|
-
lines.push(' const text = await response.text()');
|
|
414
|
-
lines.push(' if (!text) return {} as T');
|
|
415
|
-
lines.push(' return JSON.parse(text) as T');
|
|
416
|
-
lines.push(' }');
|
|
417
|
-
lines.push('}');
|
|
418
|
-
lines.push('');
|
|
419
|
-
return lines.join('\n');
|
|
420
|
-
}
|
|
421
|
-
function generateVariableFile(spec, vars) {
|
|
422
|
-
const { camelName, screamingName, displayName } = vars;
|
|
423
|
-
const serverUrls = spec.serverUrls.length > 0 ? spec.serverUrls : [];
|
|
424
|
-
const defaultUrl = serverUrls[0];
|
|
425
|
-
const lines = [];
|
|
426
|
-
lines.push("import { z } from 'zod'");
|
|
427
|
-
lines.push("import { wireVariable } from '@pikku/core/variable'");
|
|
428
|
-
lines.push('');
|
|
429
|
-
const schemaVarName = `${camelName}BaseUrlSchema`;
|
|
430
|
-
const urlsLiteral = serverUrls.map((u) => JSON.stringify(u)).join(', ');
|
|
431
|
-
lines.push(`export const ${schemaVarName} = z.enum([${urlsLiteral}]).default(${JSON.stringify(defaultUrl)})`);
|
|
432
|
-
lines.push('');
|
|
433
|
-
lines.push(`wireVariable({`);
|
|
434
|
-
lines.push(` name: '${screamingName}_BASE_URL',`);
|
|
435
|
-
lines.push(` displayName: '${displayName} Base URL',`);
|
|
436
|
-
lines.push(` description: 'The base URL for the ${displayName} API.',`);
|
|
437
|
-
lines.push(` variableId: '${screamingName}_BASE_URL',`);
|
|
438
|
-
lines.push(` schema: ${schemaVarName},`);
|
|
439
|
-
lines.push(`})`);
|
|
440
|
-
lines.push('');
|
|
441
|
-
return lines.join('\n');
|
|
442
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Derives function/method names from HTTP method + path.
|
|
3
|
-
* Uses operationId when available, otherwise generates from path segments.
|
|
4
|
-
*/
|
|
5
|
-
export declare function singularize(word: string): string;
|
|
6
|
-
export declare function toCamelCase(str: string): string;
|
|
7
|
-
export declare function toPascalCase(str: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Strip common API prefix from paths (e.g. /api/v2/).
|
|
10
|
-
* Uses majority voting — a prefix shared by >75% of paths is stripped,
|
|
11
|
-
* so a few outlier paths (e.g. /oauth/...) don't break detection.
|
|
12
|
-
*/
|
|
13
|
-
export declare function detectCommonPrefix(paths: string[]): string;
|
|
14
|
-
interface OperationForNaming {
|
|
15
|
-
method: string;
|
|
16
|
-
path: string;
|
|
17
|
-
operationId?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface NamedOperation {
|
|
20
|
-
method: string;
|
|
21
|
-
path: string;
|
|
22
|
-
functionName: string;
|
|
23
|
-
methodName: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Generate function names for a list of operations.
|
|
27
|
-
* Handles collision detection and auto-deduplication.
|
|
28
|
-
*/
|
|
29
|
-
export declare function generateOperationNames(operations: OperationForNaming[], commonPrefix: string): NamedOperation[];
|
|
30
|
-
export {};
|