@pikku/cli 0.12.20 → 0.12.22
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-C52h1B_L.css +1 -0
- package/console-app/assets/index-CAk106ji.js +232 -0
- package/console-app/index.html +3 -6
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +3 -3
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.d.ts +6 -6
- package/dist/.pikku/cli/pikku-cli-channel.js +280 -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 +792 -8
- 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 +44 -70
- package/dist/.pikku/function/pikku-function-types.gen.js +33 -40
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +1439 -316
- package/dist/.pikku/function/pikku-functions.gen.js +21 -9
- 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/pikku-bootstrap.gen.d.ts +3 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +3 -1
- package/dist/.pikku/pikku-meta-service.gen.d.ts +1 -1
- package/dist/.pikku/pikku-meta-service.gen.js +1 -1
- package/dist/.pikku/pikku-services.gen.d.ts +2 -1
- package/dist/.pikku/pikku-services.gen.js +1 -0
- package/dist/.pikku/pikku-types.gen.d.ts +1 -1
- package/dist/.pikku/pikku-types.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.d.ts +1 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.js +6 -0
- package/dist/.pikku/queue/pikku-queue-workers-wirings-meta.gen.json +250 -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.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +66 -10
- 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/schemas/register.gen.js +157 -11
- package/dist/.pikku/schemas/schemas/BinaryInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/DbMigrateInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/DbResetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/DbSeedInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDbSchemaInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDbSchemaOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployApplyInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployApplyOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployListOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployPlanInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployPlanOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployUnitsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDeployUnitsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsAddInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsAddOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsListOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsRemoveInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricDomainsRemoveOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricErrorsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricErrorsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricInitInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricInitOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLLMKeyInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLLMKeyOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLinkInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLinkOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLoginInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLoginOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLogsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricLogsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricMetricsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricMetricsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricRollbackInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricRollbackOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsListOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsSetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsSetOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricStatusInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricStatusOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricTraceInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricTraceOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricValidateInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricValidateOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/PikkuCommandChannelsOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCommandHTTPOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCommandQueueOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuEventsScaffoldOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaClientsInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaContextInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaFunctionsGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaFunctionsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaMiddlewareGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaMiddlewareListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaPermissionsGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaPermissionsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaSchemasGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaSchemasListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresChannelInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresHttpInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresQueueInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresSchedulerInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresTriggerInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWiresTypeInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWorkflowsGetInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuMetaWorkflowsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSkillsInstallInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuSkillsListInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuTestsCoverageInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuTestsInitInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/WorkflowRunStatus.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/meta/allWorkflow.gen.json +237 -629
- package/dist/.pikku/workflow/pikku-workflow-types.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-workflow-types.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings-meta.gen.js +1 -1
- package/dist/.pikku/workflow/pikku-workflow-wirings.gen.js +1 -1
- package/dist/bin/pikku-bin.mjs +23 -0
- package/dist/bin/pikku.js +28 -1
- package/dist/src/cli.wiring.js +286 -10
- package/dist/src/deploy/analyzer/analyzer.d.ts +16 -1
- package/dist/src/deploy/analyzer/analyzer.js +83 -43
- package/dist/src/deploy/analyzer/manifest.d.ts +10 -0
- package/dist/src/deploy/build-pipeline.d.ts +2 -0
- package/dist/src/deploy/build-pipeline.js +123 -19
- package/dist/src/deploy/bundler/bundler.d.ts +3 -1
- package/dist/src/deploy/bundler/bundler.js +40 -9
- package/dist/src/deploy/bundler/dep-extractor.d.ts +5 -2
- package/dist/src/deploy/bundler/dep-extractor.js +103 -23
- package/dist/src/deploy/bundler/types.d.ts +5 -1
- package/dist/src/deploy/codegen/per-unit-codegen.d.ts +11 -1
- package/dist/src/deploy/codegen/per-unit-codegen.js +49 -6
- package/dist/src/deploy/plan/planner.js +25 -3
- package/dist/src/deploy/plan/provider.d.ts +2 -0
- package/dist/src/deploy/provider-adapter.d.ts +34 -0
- package/dist/src/deploy/server-entry.d.ts +16 -0
- package/dist/src/deploy/server-entry.js +81 -0
- package/dist/src/fabric/fabric-commands.d.ts +522 -0
- package/dist/src/fabric/fabric-commands.js +299 -0
- package/dist/src/fabric/functions/db-schema.function.d.ts +35 -0
- package/dist/src/fabric/functions/db-schema.function.js +37 -0
- package/dist/src/fabric/functions/deploy-list.function.d.ts +41 -0
- package/dist/src/fabric/functions/deploy-list.function.js +43 -0
- package/dist/src/fabric/functions/deploy-units.function.d.ts +35 -0
- package/dist/src/fabric/functions/deploy-units.function.js +41 -0
- package/dist/src/fabric/functions/deploy.function.d.ts +105 -0
- package/dist/src/fabric/functions/deploy.function.js +122 -0
- package/dist/src/fabric/functions/domains-add.function.d.ts +35 -0
- package/dist/src/fabric/functions/domains-add.function.js +46 -0
- package/dist/src/fabric/functions/domains-list.function.d.ts +20 -0
- package/dist/src/fabric/functions/domains-list.function.js +50 -0
- package/dist/src/fabric/functions/domains-remove.function.d.ts +24 -0
- package/dist/src/fabric/functions/domains-remove.function.js +44 -0
- package/dist/src/fabric/functions/errors.function.d.ts +44 -0
- package/dist/src/fabric/functions/errors.function.js +50 -0
- package/dist/src/fabric/functions/init.function.d.ts +51 -0
- package/dist/src/fabric/functions/init.function.js +54 -0
- package/dist/src/fabric/functions/link.function.d.ts +28 -0
- package/dist/src/fabric/functions/link.function.js +77 -0
- package/dist/src/fabric/functions/llm-key.function.d.ts +46 -0
- package/dist/src/fabric/functions/llm-key.function.js +76 -0
- package/dist/src/fabric/functions/login.function.d.ts +42 -0
- package/dist/src/fabric/functions/login.function.js +68 -0
- package/dist/src/fabric/functions/logs.function.d.ts +40 -0
- package/dist/src/fabric/functions/logs.function.js +84 -0
- package/dist/src/fabric/functions/metrics.function.d.ts +32 -0
- package/dist/src/fabric/functions/metrics.function.js +49 -0
- package/dist/src/fabric/functions/rollback.function.d.ts +76 -0
- package/dist/src/fabric/functions/rollback.function.js +69 -0
- package/dist/src/fabric/functions/secrets-list.function.d.ts +24 -0
- package/dist/src/fabric/functions/secrets-list.function.js +37 -0
- package/dist/src/fabric/functions/secrets-set.function.d.ts +32 -0
- package/dist/src/fabric/functions/secrets-set.function.js +36 -0
- package/dist/src/fabric/functions/status.function.d.ts +34 -0
- package/dist/src/fabric/functions/status.function.js +43 -0
- package/dist/src/fabric/functions/trace.function.d.ts +28 -0
- package/dist/src/fabric/functions/trace.function.js +45 -0
- package/dist/src/fabric/functions/validate.function.d.ts +50 -0
- package/dist/src/fabric/functions/validate.function.js +363 -0
- package/dist/src/fabric/lib/config.d.ts +64 -0
- package/dist/src/fabric/lib/config.js +62 -0
- package/dist/src/fabric/lib/console-url.d.ts +5 -0
- package/dist/src/fabric/lib/console-url.js +13 -0
- package/dist/src/fabric/lib/git.d.ts +53 -0
- package/dist/src/fabric/lib/git.js +151 -0
- package/dist/src/fabric/lib/http.d.ts +4 -0
- package/dist/src/fabric/lib/http.js +12 -0
- package/dist/src/fabric/lib/not-implemented.d.ts +5 -0
- package/dist/src/fabric/lib/not-implemented.js +8 -0
- package/dist/src/fabric/lib/output.d.ts +23 -0
- package/dist/src/fabric/lib/output.js +39 -0
- package/dist/src/fabric/lib/prompt.d.ts +12 -0
- package/dist/src/fabric/lib/prompt.js +32 -0
- package/dist/src/fabric/lib/stage.d.ts +7 -0
- package/dist/src/fabric/lib/stage.js +14 -0
- package/dist/src/fabric/sdk/pikku-fetch.gen.d.ts +14 -0
- package/dist/src/fabric/sdk/pikku-fetch.gen.js +30 -0
- package/dist/src/fabric/sdk/pikku-rpc.gen.d.ts +105 -0
- package/dist/src/fabric/sdk/pikku-rpc.gen.js +126 -0
- package/dist/src/functions/commands/all.d.ts +1 -1
- package/dist/src/functions/commands/binary.d.ts +7 -0
- package/dist/src/functions/commands/binary.js +40 -0
- package/dist/src/functions/commands/bootstrap.d.ts +1 -1
- package/dist/src/functions/commands/bootstrap.js +7 -4
- package/dist/src/functions/commands/console.d.ts +3 -3
- package/dist/src/functions/commands/db-migrate.d.ts +1 -0
- package/dist/src/functions/commands/db-migrate.js +35 -0
- package/dist/src/functions/commands/db-reset.d.ts +1 -0
- package/dist/src/functions/commands/db-reset.js +36 -0
- package/dist/src/functions/commands/db-seed.d.ts +1 -0
- package/dist/src/functions/commands/db-seed.js +27 -0
- package/dist/src/functions/commands/db-shared.d.ts +32 -0
- package/dist/src/functions/commands/db-shared.js +26 -0
- package/dist/src/functions/commands/deploy-apply.d.ts +3 -3
- package/dist/src/functions/commands/deploy-apply.js +6 -4
- package/dist/src/functions/commands/deploy-info.d.ts +1 -1
- package/dist/src/functions/commands/deploy-plan.d.ts +3 -3
- package/dist/src/functions/commands/deploy-plan.js +7 -1
- package/dist/src/functions/commands/dev.d.ts +3 -3
- package/dist/src/functions/commands/dev.js +142 -86
- package/dist/src/functions/commands/enable.d.ts +5 -4
- package/dist/src/functions/commands/enable.js +4 -0
- package/dist/src/functions/commands/info.d.ts +4 -4
- package/dist/src/functions/commands/load-user-project.d.ts +11 -0
- package/dist/src/functions/commands/load-user-project.js +40 -0
- package/dist/src/functions/commands/meta.d.ts +82 -0
- package/dist/src/functions/commands/meta.js +454 -0
- package/dist/src/functions/commands/new-addon.d.ts +3 -3
- package/dist/src/functions/commands/new-function.d.ts +3 -3
- package/dist/src/functions/commands/new-middleware.d.ts +3 -3
- package/dist/src/functions/commands/new-permission.d.ts +3 -3
- package/dist/src/functions/commands/new-wiring.d.ts +3 -3
- package/dist/src/functions/commands/pikku-command-bootstrap.d.ts +1 -1
- package/dist/src/functions/commands/pikku-command-bootstrap.js +15 -1
- package/dist/src/functions/commands/pikku-command-summary.d.ts +1 -1
- package/dist/src/functions/commands/pikku-command-summary.js +7 -1
- package/dist/src/functions/commands/skills.d.ts +26 -0
- package/dist/src/functions/commands/skills.js +184 -0
- package/dist/src/functions/commands/tests-coverage.d.ts +7 -0
- package/dist/src/functions/commands/tests-coverage.js +231 -0
- package/dist/src/functions/commands/tests-init.d.ts +7 -0
- package/dist/src/functions/commands/tests-init.js +225 -0
- package/dist/src/functions/commands/versions-check.d.ts +1 -1
- package/dist/src/functions/commands/versions-init.d.ts +3 -3
- package/dist/src/functions/commands/versions-update.d.ts +1 -1
- package/dist/src/functions/commands/versions-update.js +4 -2
- package/dist/src/functions/commands/watch.d.ts +3 -3
- package/dist/src/functions/commands/watch.js +1 -1
- package/dist/src/functions/db/local-db.d.ts +48 -0
- package/dist/src/functions/db/local-db.js +106 -0
- package/dist/src/functions/db/seed.d.ts +11 -0
- package/dist/src/functions/db/seed.js +22 -0
- package/dist/src/functions/db/sql-migrator.d.ts +26 -0
- package/dist/src/functions/db/sql-migrator.js +104 -0
- package/dist/src/functions/db/sqlite-codegen.d.ts +45 -0
- package/dist/src/functions/db/sqlite-codegen.js +294 -0
- package/dist/src/functions/db/zod-codegen.d.ts +10 -0
- package/dist/src/functions/db/zod-codegen.js +109 -0
- package/dist/src/functions/runtimes/fetch/index.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.d.ts +1 -1
- package/dist/src/functions/runtimes/nextjs/pikku-command-nextjs.js +21 -2
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-worker-rpc-wrapper.d.ts +1 -0
- package/dist/src/functions/runtimes/nextjs/serialize-nextjs-backend-worker-rpc-wrapper.js +163 -0
- 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 +5 -2
- package/dist/src/functions/runtimes/tanstack-start/pikku-command-tanstack-start.d.ts +1 -0
- package/dist/src/functions/runtimes/tanstack-start/pikku-command-tanstack-start.js +32 -0
- package/dist/src/functions/runtimes/tanstack-start/serialize-tanstack-start-shim.d.ts +11 -0
- package/dist/src/functions/runtimes/tanstack-start/serialize-tanstack-start-shim.js +36 -0
- package/dist/src/functions/runtimes/websocket/pikku-command-websocket-typed.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent-types.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/pikku-command-ai-agent.js +1 -10
- package/dist/src/functions/wirings/ai-agent/pikku-command-public-agent.d.ts +1 -1
- package/dist/src/functions/wirings/ai-agent/serialize-public-agent.js +76 -1
- package/dist/src/functions/wirings/channels/pikku-channels.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channel-types.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channels-map.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channels.d.ts +1 -1
- package/dist/src/functions/wirings/channels/pikku-command-channels.js +1 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.d.ts +1 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-entry.js +5 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.d.ts +5 -1
- package/dist/src/functions/wirings/cli/pikku-command-cli-types.js +8 -2
- package/dist/src/functions/wirings/cli/pikku-command-cli.d.ts +1 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli-client.js +27 -9
- package/dist/src/functions/wirings/cli/serialize-channel-cli.d.ts +5 -1
- package/dist/src/functions/wirings/cli/serialize-channel-cli.js +13 -3
- package/dist/src/functions/wirings/console/pikku-command-console-functions.d.ts +1 -1
- package/dist/src/functions/wirings/console/pikku-command-console-functions.js +5 -1
- package/dist/src/functions/wirings/console/pikku-command-node-types.d.ts +1 -1
- package/dist/src/functions/wirings/console/pikku-command-nodes-meta.d.ts +1 -1
- package/dist/src/functions/wirings/console/serialize-console-functions.js +5 -0
- package/dist/src/functions/wirings/credentials/pikku-command-credentials.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.d.ts +5 -1
- package/dist/src/functions/wirings/functions/pikku-command-addon-types.js +7 -2
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types-split.js +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-function-types.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-functions.d.ts +1 -1
- package/dist/src/functions/wirings/functions/pikku-command-services.d.ts +1 -1
- package/dist/src/functions/wirings/functions/schemas.d.ts +1 -1
- package/dist/src/functions/wirings/functions/serialize-function-types.js +105 -80
- package/dist/src/functions/wirings/gateway/pikku-command-gateway.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-map.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-routes.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-routes.js +1 -1
- package/dist/src/functions/wirings/http/pikku-command-http-types.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-command-openapi.d.ts +1 -1
- package/dist/src/functions/wirings/http/pikku-http-routes.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-json.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp-types.d.ts +1 -1
- package/dist/src/functions/wirings/mcp/pikku-command-mcp.d.ts +1 -1
- package/dist/src/functions/wirings/middleware/pikku-command-middleware.d.ts +1 -1
- package/dist/src/functions/wirings/package/pikku-command-package-types.d.ts +2 -2
- package/dist/src/functions/wirings/package/pikku-command-package.d.ts +1 -1
- package/dist/src/functions/wirings/permissions/pikku-command-permissions.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-map.js +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-service.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue-types.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-command-queue.js +1 -1
- package/dist/src/functions/wirings/queue/pikku-queue-map.d.ts +1 -1
- package/dist/src/functions/wirings/queue/pikku-queue.d.ts +1 -1
- package/dist/src/functions/wirings/realtime/pikku-command-events-scaffold.d.ts +1 -0
- package/dist/src/functions/wirings/realtime/pikku-command-events-scaffold.js +26 -0
- package/dist/src/functions/wirings/realtime/pikku-command-realtime.d.ts +1 -0
- package/dist/src/functions/wirings/realtime/pikku-command-realtime.js +35 -0
- package/dist/src/functions/wirings/realtime/serialize-events-scaffold.d.ts +23 -0
- package/dist/src/functions/wirings/realtime/serialize-events-scaffold.js +98 -0
- package/dist/src/functions/wirings/realtime/serialize-realtime-client.d.ts +22 -0
- package/dist/src/functions/wirings/realtime/serialize-realtime-client.js +337 -0
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-public-rpc.js +5 -1
- package/dist/src/functions/wirings/rpc/pikku-command-react-query.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-remote-rpc.js +5 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.d.ts +1 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-client.js +3 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc-map.d.ts +2 -2
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.d.ts +2 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +13 -7
- package/dist/src/functions/wirings/rpc/serialize-public-rpc.js +1 -0
- package/dist/src/functions/wirings/rpc/serialize-react-query-hooks.js +1 -1
- package/dist/src/functions/wirings/rpc/serialize-remote-rpc.js +7 -1
- package/dist/src/functions/wirings/rpc/serialize-typed-rpc-map.js +16 -2
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler-types.d.ts +1 -1
- package/dist/src/functions/wirings/scheduler/pikku-command-scheduler.d.ts +1 -1
- package/dist/src/functions/wirings/secrets/pikku-command-secrets.d.ts +1 -1
- package/dist/src/functions/wirings/triggers/pikku-command-trigger-types.d.ts +1 -1
- package/dist/src/functions/wirings/triggers/pikku-command-trigger-types.js +1 -1
- package/dist/src/functions/wirings/triggers/pikku-command-trigger.d.ts +1 -1
- package/dist/src/functions/wirings/variables/pikku-command-variables.d.ts +1 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.d.ts +1 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow-routes.js +1 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.d.ts +5 -1
- package/dist/src/functions/wirings/workflow/pikku-command-workflow.js +18 -4
- package/dist/src/functions/wirings/workflow/serialize-workflow-bootstrap-map.d.ts +3 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-bootstrap-map.js +40 -0
- package/dist/src/functions/wirings/workflow/serialize-workflow-routes.js +56 -2
- package/dist/src/functions/workflows/all.workflow.js +45 -12
- package/dist/src/scaffold/rpc-remote.gen.d.ts +3 -3
- package/dist/src/scaffold/rpc-remote.gen.js +7 -2
- package/dist/src/scaffold/workflow-routes.gen.d.ts +18 -18
- package/dist/src/scaffold/workflow-routes.gen.js +33 -1
- package/dist/src/services/cli-logger.service.d.ts +22 -3
- package/dist/src/services/cli-logger.service.js +107 -41
- package/dist/src/services.js +32 -67
- package/dist/src/utils/generate-bootstrap-file.js +3 -0
- package/dist/src/utils/parse-cli-filters.d.ts +18 -0
- package/dist/src/utils/parse-cli-filters.js +99 -0
- package/dist/src/utils/pikku-cli-config.js +29 -9
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -4
- package/skills/pikku-addon/SKILL.md +330 -0
- package/skills/pikku-ai-agent/SKILL.md +227 -0
- package/skills/pikku-ai-vercel/SKILL.md +78 -0
- package/skills/pikku-ai-voice/SKILL.md +85 -0
- package/skills/pikku-auth-js/SKILL.md +106 -0
- package/skills/pikku-aws/SKILL.md +107 -0
- package/skills/pikku-backblaze/SKILL.md +70 -0
- package/skills/pikku-cli/SKILL.md +281 -0
- package/skills/pikku-concepts/SKILL.md +281 -0
- package/skills/pikku-concepts/references/concept-mapping.md +528 -0
- package/skills/pikku-config/SKILL.md +208 -0
- package/skills/pikku-cron/SKILL.md +211 -0
- package/skills/pikku-deploy-azure/SKILL.md +69 -0
- package/skills/pikku-deploy-cloudflare/SKILL.md +80 -0
- package/skills/pikku-deploy-express/SKILL.md +83 -0
- package/skills/pikku-deploy-fastify/SKILL.md +70 -0
- package/skills/pikku-deploy-lambda/SKILL.md +107 -0
- package/skills/pikku-deploy-nextjs/SKILL.md +76 -0
- package/skills/pikku-deploy-uws/SKILL.md +85 -0
- package/skills/pikku-fabric/SKILL.md +245 -0
- package/skills/pikku-feature/SKILL.md +258 -0
- package/skills/pikku-gateway-slack/SKILL.md +112 -0
- package/skills/pikku-http/SKILL.md +317 -0
- package/skills/pikku-i18n/SKILL.md +208 -0
- package/skills/pikku-info/SKILL.md +95 -0
- package/skills/pikku-jose/SKILL.md +102 -0
- package/skills/pikku-kysely/SKILL.md +145 -0
- package/skills/pikku-mcp/SKILL.md +237 -0
- package/skills/pikku-mongodb/SKILL.md +102 -0
- package/skills/pikku-n8n-addon-map/SKILL.md +178 -0
- package/skills/pikku-n8n-code-translate/SKILL.md +166 -0
- package/skills/pikku-pino/SKILL.md +77 -0
- package/skills/pikku-queue/SKILL.md +237 -0
- package/skills/pikku-react/SKILL.md +183 -0
- package/skills/pikku-react-query/SKILL.md +205 -0
- package/skills/pikku-realtime/SKILL.md +285 -0
- package/skills/pikku-redis/SKILL.md +87 -0
- package/skills/pikku-rpc/SKILL.md +168 -0
- package/skills/pikku-rtl/SKILL.md +205 -0
- package/skills/pikku-schedule/SKILL.md +54 -0
- package/skills/pikku-schema-ajv/SKILL.md +60 -0
- package/skills/pikku-schema-cfworker/SKILL.md +60 -0
- package/skills/pikku-security/SKILL.md +243 -0
- package/skills/pikku-services/SKILL.md +247 -0
- package/skills/pikku-template-clone/SKILL.md +39 -0
- package/skills/pikku-testing/SKILL.md +428 -0
- package/skills/pikku-trigger/SKILL.md +177 -0
- package/skills/pikku-versioning/SKILL.md +169 -0
- package/skills/pikku-websocket/SKILL.md +239 -0
- package/skills/pikku-workflow/SKILL.md +283 -0
- package/skills/pikku-workflows-client/SKILL.md +150 -0
- package/skills/pikku-ws/SKILL.md +45 -0
- package/console-app/assets/index-BpY2pSuA.css +0 -10
- package/console-app/assets/index-DXLy-_D4.js +0 -717
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +0 -10
- package/dist/.pikku/cli/pikku-cli-client.gen.js +0 -44
- /package/dist/.pikku/schemas/schemas/{PikkuChannelsOutput.schema.json → PikkuCLIEntryOutput.schema.json} +0 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { readFileSync, writeFileSync, mkdirSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
const SKIP_TABLES = new Set(['sqlite_sequence', 'sql_migrations']);
|
|
4
|
+
function snakeToPascal(name) {
|
|
5
|
+
return name
|
|
6
|
+
.split('_')
|
|
7
|
+
.map((part) => part.charAt(0).toUpperCase() + part.slice(1).toLowerCase())
|
|
8
|
+
.join('');
|
|
9
|
+
}
|
|
10
|
+
function snakeToCamel(name) {
|
|
11
|
+
return name.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
|
12
|
+
}
|
|
13
|
+
function mapType(sqlType) {
|
|
14
|
+
const upper = sqlType.toUpperCase();
|
|
15
|
+
if (upper.includes('INT'))
|
|
16
|
+
return 'number';
|
|
17
|
+
if (upper.includes('CHAR') ||
|
|
18
|
+
upper.includes('CLOB') ||
|
|
19
|
+
upper.includes('TEXT')) {
|
|
20
|
+
return 'string';
|
|
21
|
+
}
|
|
22
|
+
if (upper.includes('BLOB'))
|
|
23
|
+
return 'Buffer';
|
|
24
|
+
if (upper.includes('REAL') ||
|
|
25
|
+
upper.includes('FLOA') ||
|
|
26
|
+
upper.includes('DOUB')) {
|
|
27
|
+
return 'number';
|
|
28
|
+
}
|
|
29
|
+
if (upper.includes('NUMERIC') || upper.includes('DECIMAL'))
|
|
30
|
+
return 'number';
|
|
31
|
+
if (upper.includes('BOOL'))
|
|
32
|
+
return 'number';
|
|
33
|
+
return 'string';
|
|
34
|
+
}
|
|
35
|
+
function listTables(db) {
|
|
36
|
+
const tableRows = db
|
|
37
|
+
.prepare(`SELECT name FROM sqlite_master
|
|
38
|
+
WHERE type = 'table'
|
|
39
|
+
AND name NOT LIKE 'sqlite\\_%' ESCAPE '\\'
|
|
40
|
+
ORDER BY name`)
|
|
41
|
+
.all();
|
|
42
|
+
return tableRows
|
|
43
|
+
.filter((t) => !SKIP_TABLES.has(t.name))
|
|
44
|
+
.map((t) => {
|
|
45
|
+
const allColumns = db
|
|
46
|
+
.prepare(`PRAGMA table_xinfo(${escapeIdentifier(t.name)})`)
|
|
47
|
+
.all();
|
|
48
|
+
// hidden: 0=regular, 2=virtual generated, 3=stored generated — include all; skip 1 (vtab hidden)
|
|
49
|
+
const columns = allColumns.filter((c) => c.hidden !== 1);
|
|
50
|
+
return { name: t.name, columns };
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function escapeIdentifier(name) {
|
|
54
|
+
return `"${name.replace(/"/g, '""')}"`;
|
|
55
|
+
}
|
|
56
|
+
// ─── Annotation parsing ──────────────────────────────────────────────────────
|
|
57
|
+
/**
|
|
58
|
+
* Determine column kind from naming conventions:
|
|
59
|
+
* *_at / *_on → date
|
|
60
|
+
* is_* / has_* / can_* → bool
|
|
61
|
+
*/
|
|
62
|
+
function annotationFromName(colName) {
|
|
63
|
+
if (/_at$|_on$/.test(colName))
|
|
64
|
+
return { kind: 'date' };
|
|
65
|
+
if (/^is_|^has_|^can_/.test(colName))
|
|
66
|
+
return { kind: 'bool' };
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parse `-- @bool | @date | @json [TypescriptType]` inline annotations from
|
|
71
|
+
* migration SQL files. The TypeScript type is optional and only meaningful for
|
|
72
|
+
* `@json` — it controls the generated TypeScript type (e.g. `string[]`,
|
|
73
|
+
* `Record<string, number>`).
|
|
74
|
+
*
|
|
75
|
+
* Returns an AnnotationMap: { table_name: { col_name: ColAnnotation } }.
|
|
76
|
+
*/
|
|
77
|
+
export function parseAnnotations(migrationsDir) {
|
|
78
|
+
let files;
|
|
79
|
+
try {
|
|
80
|
+
files = readdirSync(migrationsDir)
|
|
81
|
+
.filter((f) => f.endsWith('.sql'))
|
|
82
|
+
.sort();
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
const result = {};
|
|
88
|
+
for (const file of files) {
|
|
89
|
+
const content = readFileSync(join(migrationsDir, file), 'utf8');
|
|
90
|
+
const createTablePattern = /CREATE\s+TABLE\s+(?:IF\s+NOT\s+EXISTS\s+)?"?(\w+)"?\s*\(([^;]+)\)/gis;
|
|
91
|
+
let tableMatch;
|
|
92
|
+
while ((tableMatch = createTablePattern.exec(content)) !== null) {
|
|
93
|
+
const tableName = tableMatch[1].toLowerCase();
|
|
94
|
+
const body = tableMatch[2];
|
|
95
|
+
for (const line of body.split('\n')) {
|
|
96
|
+
const trimmed = line.trim();
|
|
97
|
+
if (/^(PRIMARY|UNIQUE|CHECK|FOREIGN|CONSTRAINT)/i.test(trimmed))
|
|
98
|
+
continue;
|
|
99
|
+
// Match: col_name TYPE ... -- @kind [optional ts type]
|
|
100
|
+
const annotationMatch = trimmed.match(/^(\w+)\s+\w.*?--\s*@(bool|date|json)(?:\s+(.+?))?$/i);
|
|
101
|
+
if (annotationMatch) {
|
|
102
|
+
const colName = annotationMatch[1].toLowerCase();
|
|
103
|
+
const kind = annotationMatch[2].toLowerCase();
|
|
104
|
+
const tsType = annotationMatch[3]?.trim() || undefined;
|
|
105
|
+
if (!result[tableName])
|
|
106
|
+
result[tableName] = {};
|
|
107
|
+
result[tableName][colName] = {
|
|
108
|
+
kind,
|
|
109
|
+
tsType: kind === 'json' ? tsType : undefined,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Merge explicit SQL annotations with naming-convention-based ones.
|
|
119
|
+
* Explicit annotations take precedence.
|
|
120
|
+
*/
|
|
121
|
+
function buildAnnotationMap(tables, explicit) {
|
|
122
|
+
const merged = {};
|
|
123
|
+
for (const table of tables) {
|
|
124
|
+
const explicitCols = explicit[table.name] ?? {};
|
|
125
|
+
for (const col of table.columns) {
|
|
126
|
+
const annotation = explicitCols[col.name] ?? annotationFromName(col.name);
|
|
127
|
+
if (annotation) {
|
|
128
|
+
if (!merged[table.name])
|
|
129
|
+
merged[table.name] = {};
|
|
130
|
+
merged[table.name][col.name] = annotation;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return merged;
|
|
135
|
+
}
|
|
136
|
+
// ─── Type expression ─────────────────────────────────────────────────────────
|
|
137
|
+
function columnTypeExpression(col, annotation) {
|
|
138
|
+
const nullable = !col.notnull && col.pk === 0;
|
|
139
|
+
const hasDefault = col.dflt_value !== null && col.dflt_value !== undefined;
|
|
140
|
+
const isAutoInt = col.pk === 1 && mapType(col.type) === 'number';
|
|
141
|
+
const isGenerated = col.hidden === 2 || col.hidden === 3;
|
|
142
|
+
const wrap = (inner) => hasDefault || isAutoInt || isGenerated ? `Generated<${inner}>` : inner;
|
|
143
|
+
if (annotation?.kind === 'bool') {
|
|
144
|
+
const base = nullable ? 'boolean | null' : 'boolean';
|
|
145
|
+
const rw = nullable ? 'boolean | number | null' : 'boolean | number';
|
|
146
|
+
return wrap(`ColumnType<${base}, ${rw}, ${rw}>`);
|
|
147
|
+
}
|
|
148
|
+
if (annotation?.kind === 'date') {
|
|
149
|
+
const base = nullable ? 'Date | null' : 'Date';
|
|
150
|
+
const rw = nullable ? 'Date | string | null' : 'Date | string';
|
|
151
|
+
return wrap(`ColumnType<${base}, ${rw}, ${rw}>`);
|
|
152
|
+
}
|
|
153
|
+
if (annotation?.kind === 'json') {
|
|
154
|
+
const base = annotation.tsType
|
|
155
|
+
? nullable
|
|
156
|
+
? `${annotation.tsType} | null`
|
|
157
|
+
: annotation.tsType
|
|
158
|
+
: nullable
|
|
159
|
+
? 'unknown | null'
|
|
160
|
+
: 'unknown';
|
|
161
|
+
return wrap(base);
|
|
162
|
+
}
|
|
163
|
+
// Default: plain SQL-mapped type
|
|
164
|
+
const base = mapType(col.type);
|
|
165
|
+
if (isAutoInt)
|
|
166
|
+
return `Generated<${base}>`;
|
|
167
|
+
if (hasDefault || isGenerated)
|
|
168
|
+
return `Generated<${base}${nullable ? ' | null' : ''}>`;
|
|
169
|
+
return nullable ? `${base} | null` : base;
|
|
170
|
+
}
|
|
171
|
+
// ─── Interface emitter ───────────────────────────────────────────────────────
|
|
172
|
+
function emitInterface(table, camelCase, annotations) {
|
|
173
|
+
const ifaceName = snakeToPascal(table.name);
|
|
174
|
+
const tableCols = annotations[table.name] ?? {};
|
|
175
|
+
const fields = table.columns
|
|
176
|
+
.map((col) => {
|
|
177
|
+
const fieldName = camelCase ? snakeToCamel(col.name) : col.name;
|
|
178
|
+
const annotation = tableCols[col.name] ?? null;
|
|
179
|
+
const type = columnTypeExpression(col, annotation);
|
|
180
|
+
const safeName = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(fieldName)
|
|
181
|
+
? fieldName
|
|
182
|
+
: JSON.stringify(fieldName);
|
|
183
|
+
return ` ${safeName}: ${type}`;
|
|
184
|
+
})
|
|
185
|
+
.join('\n');
|
|
186
|
+
return `export interface ${ifaceName} {\n${fields}\n}`;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Introspect the open SQLite database and emit a Kysely DB type to outFile
|
|
190
|
+
* plus a CoercionMap to coercionFile.
|
|
191
|
+
*
|
|
192
|
+
* Columns are annotated via:
|
|
193
|
+
* 1. Naming conventions (_at/_on → date; is_/has_/can_ → bool)
|
|
194
|
+
* 2. Inline SQL comments: `col_name TYPE ... -- @bool|@date|@json [TsType]`
|
|
195
|
+
* For @json, an optional TypeScript type string controls the generated type.
|
|
196
|
+
*
|
|
197
|
+
* Returns `written: false` if the on-disk file already matches.
|
|
198
|
+
*/
|
|
199
|
+
export function generateSchemaTypes(db, options) {
|
|
200
|
+
const camelCase = options.camelCase ?? true;
|
|
201
|
+
const tables = listTables(db);
|
|
202
|
+
const explicitAnnotations = options.migrationsDir
|
|
203
|
+
? parseAnnotations(options.migrationsDir)
|
|
204
|
+
: {};
|
|
205
|
+
const annotations = buildAnnotationMap(tables, explicitAnnotations);
|
|
206
|
+
// ── schema.d.ts ──
|
|
207
|
+
const interfaces = tables
|
|
208
|
+
.map((t) => emitInterface(t, camelCase, annotations))
|
|
209
|
+
.join('\n\n');
|
|
210
|
+
const dbEntries = tables
|
|
211
|
+
.map((t) => {
|
|
212
|
+
const tableKey = camelCase ? snakeToCamel(t.name) : t.name;
|
|
213
|
+
const safe = /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(tableKey)
|
|
214
|
+
? tableKey
|
|
215
|
+
: JSON.stringify(tableKey);
|
|
216
|
+
return ` ${safe}: ${snakeToPascal(t.name)}`;
|
|
217
|
+
})
|
|
218
|
+
.join('\n');
|
|
219
|
+
const schemaBody = [
|
|
220
|
+
`// Generated by @pikku/cli — do not edit by hand.`,
|
|
221
|
+
`// Run \`pikku db migrate\` to refresh.`,
|
|
222
|
+
``,
|
|
223
|
+
`import type { ColumnType } from 'kysely'`,
|
|
224
|
+
``,
|
|
225
|
+
`export type Generated<T> = T extends ColumnType<infer S, infer I, infer U>`,
|
|
226
|
+
` ? ColumnType<S, I | undefined, U>`,
|
|
227
|
+
` : ColumnType<T, T | undefined, T>`,
|
|
228
|
+
``,
|
|
229
|
+
interfaces,
|
|
230
|
+
``,
|
|
231
|
+
`export interface DB {`,
|
|
232
|
+
dbEntries,
|
|
233
|
+
`}`,
|
|
234
|
+
``,
|
|
235
|
+
].join('\n');
|
|
236
|
+
// ── coercion.gen.ts (runtime map — only kind, not tsType) ──
|
|
237
|
+
const runtimeMap = {};
|
|
238
|
+
for (const [table, cols] of Object.entries(annotations)) {
|
|
239
|
+
for (const [col, ann] of Object.entries(cols)) {
|
|
240
|
+
if (!runtimeMap[table])
|
|
241
|
+
runtimeMap[table] = {};
|
|
242
|
+
runtimeMap[table][col] = ann.kind;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
const coercionEntries = Object.entries(runtimeMap)
|
|
246
|
+
.map(([table, cols]) => {
|
|
247
|
+
const colEntries = Object.entries(cols)
|
|
248
|
+
.map(([col, kind]) => ` "${col}": "${kind}"`)
|
|
249
|
+
.join(',\n');
|
|
250
|
+
return ` "${table}": {\n${colEntries}\n }`;
|
|
251
|
+
})
|
|
252
|
+
.join(',\n');
|
|
253
|
+
const coercionBody = [
|
|
254
|
+
`// Generated by @pikku/cli — do not edit by hand.`,
|
|
255
|
+
`// Run \`pikku db migrate\` to refresh.`,
|
|
256
|
+
``,
|
|
257
|
+
`export const coercionMap = {`,
|
|
258
|
+
coercionEntries,
|
|
259
|
+
`} as const`,
|
|
260
|
+
``,
|
|
261
|
+
].join('\n');
|
|
262
|
+
// ── write files ──
|
|
263
|
+
let existingSchema = null;
|
|
264
|
+
let existingCoercion = null;
|
|
265
|
+
try {
|
|
266
|
+
existingSchema = readFileSync(options.outFile, 'utf8');
|
|
267
|
+
}
|
|
268
|
+
catch {
|
|
269
|
+
/* ok */
|
|
270
|
+
}
|
|
271
|
+
try {
|
|
272
|
+
existingCoercion = readFileSync(options.coercionFile, 'utf8');
|
|
273
|
+
}
|
|
274
|
+
catch {
|
|
275
|
+
/* ok */
|
|
276
|
+
}
|
|
277
|
+
const schemaChanged = existingSchema !== schemaBody;
|
|
278
|
+
const coercionChanged = existingCoercion !== coercionBody;
|
|
279
|
+
if (schemaChanged) {
|
|
280
|
+
mkdirSync(dirname(options.outFile), { recursive: true });
|
|
281
|
+
writeFileSync(options.outFile, schemaBody, 'utf8');
|
|
282
|
+
}
|
|
283
|
+
if (coercionChanged) {
|
|
284
|
+
mkdirSync(dirname(options.coercionFile), { recursive: true });
|
|
285
|
+
writeFileSync(options.coercionFile, coercionBody, 'utf8');
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
outFile: options.outFile,
|
|
289
|
+
coercionFile: options.coercionFile,
|
|
290
|
+
written: schemaChanged,
|
|
291
|
+
coercionWritten: coercionChanged,
|
|
292
|
+
tables: tables.map((t) => t.name),
|
|
293
|
+
};
|
|
294
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface ZodCodegenOptions {
|
|
2
|
+
schemaFile: string;
|
|
3
|
+
outFile: string;
|
|
4
|
+
}
|
|
5
|
+
export interface ZodCodegenResult {
|
|
6
|
+
outFile: string;
|
|
7
|
+
written: boolean;
|
|
8
|
+
tables: string[];
|
|
9
|
+
}
|
|
10
|
+
export declare function generateZodTypes(options: ZodCodegenOptions): ZodCodegenResult;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
3
|
+
const INTERFACE_RE = /export\s+interface\s+(\w+)\s*\{([^}]*)\}/g;
|
|
4
|
+
const FIELD_RE = /^\s*(\w+)\s*:\s*(.+?)\s*$/gm;
|
|
5
|
+
export function generateZodTypes(options) {
|
|
6
|
+
const src = readFileSync(options.schemaFile, 'utf8');
|
|
7
|
+
const tables = parseTables(src);
|
|
8
|
+
const body = emitZodModule(tables);
|
|
9
|
+
let existing = null;
|
|
10
|
+
try {
|
|
11
|
+
existing = readFileSync(options.outFile, 'utf8');
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
// ok
|
|
15
|
+
}
|
|
16
|
+
const written = existing !== body;
|
|
17
|
+
if (written) {
|
|
18
|
+
mkdirSync(dirname(options.outFile), { recursive: true });
|
|
19
|
+
writeFileSync(options.outFile, body, 'utf8');
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
outFile: options.outFile,
|
|
23
|
+
written,
|
|
24
|
+
tables: tables.map((table) => table.name),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function parseTables(src) {
|
|
28
|
+
const tables = [];
|
|
29
|
+
for (const match of src.matchAll(INTERFACE_RE)) {
|
|
30
|
+
const name = match[1];
|
|
31
|
+
if (name === 'DB')
|
|
32
|
+
continue;
|
|
33
|
+
const body = match[2];
|
|
34
|
+
const fields = [];
|
|
35
|
+
for (const field of body.matchAll(FIELD_RE)) {
|
|
36
|
+
fields.push({ name: field[1], type: field[2].trim() });
|
|
37
|
+
}
|
|
38
|
+
tables.push({ name, fields });
|
|
39
|
+
}
|
|
40
|
+
return tables;
|
|
41
|
+
}
|
|
42
|
+
function emitZodModule(tables) {
|
|
43
|
+
const lines = [];
|
|
44
|
+
lines.push('// Generated by @pikku/cli — do not edit by hand.');
|
|
45
|
+
lines.push('// Run `pikku db migrate` to refresh.');
|
|
46
|
+
lines.push('');
|
|
47
|
+
lines.push("import { z } from 'zod'");
|
|
48
|
+
lines.push('');
|
|
49
|
+
for (const table of tables) {
|
|
50
|
+
const rowFields = [];
|
|
51
|
+
const insertFields = [];
|
|
52
|
+
for (const field of table.fields) {
|
|
53
|
+
const { schema, generated } = zodForType(field.type);
|
|
54
|
+
rowFields.push(` ${field.name}: ${schema},`);
|
|
55
|
+
insertFields.push(` ${field.name}: ${schema}${generated ? '.optional()' : ''},`);
|
|
56
|
+
}
|
|
57
|
+
lines.push(`export const ${table.name}Z = z.object({`);
|
|
58
|
+
lines.push(...rowFields);
|
|
59
|
+
lines.push('})');
|
|
60
|
+
lines.push('');
|
|
61
|
+
lines.push(`export const ${table.name}InsertZ = z.object({`);
|
|
62
|
+
lines.push(...insertFields);
|
|
63
|
+
lines.push('})');
|
|
64
|
+
lines.push('');
|
|
65
|
+
lines.push(`export const ${table.name}PatchZ = ${table.name}Z.partial()`);
|
|
66
|
+
lines.push('');
|
|
67
|
+
}
|
|
68
|
+
return `${lines.join('\n')}\n`;
|
|
69
|
+
}
|
|
70
|
+
function zodForType(tsType) {
|
|
71
|
+
const generatedMatch = tsType.match(/^Generated<(.+)>$/);
|
|
72
|
+
const generated = generatedMatch !== null;
|
|
73
|
+
let inner = generated ? generatedMatch[1].trim() : tsType;
|
|
74
|
+
const nullable = inner.endsWith(' | null');
|
|
75
|
+
if (nullable) {
|
|
76
|
+
inner = inner.slice(0, -' | null'.length).trim();
|
|
77
|
+
}
|
|
78
|
+
let schema;
|
|
79
|
+
switch (inner) {
|
|
80
|
+
case 'string':
|
|
81
|
+
schema = 'z.string()';
|
|
82
|
+
break;
|
|
83
|
+
case 'number':
|
|
84
|
+
schema = 'z.number()';
|
|
85
|
+
break;
|
|
86
|
+
case 'boolean':
|
|
87
|
+
schema = 'z.boolean()';
|
|
88
|
+
break;
|
|
89
|
+
case 'Date':
|
|
90
|
+
schema = 'z.date()';
|
|
91
|
+
break;
|
|
92
|
+
case 'unknown':
|
|
93
|
+
schema = 'z.unknown()';
|
|
94
|
+
break;
|
|
95
|
+
default:
|
|
96
|
+
if (inner.endsWith('[]')) {
|
|
97
|
+
const item = zodForType(inner.slice(0, -2).trim()).schema;
|
|
98
|
+
schema = `z.array(${item})`;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
schema = 'z.unknown()';
|
|
102
|
+
}
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
if (nullable) {
|
|
106
|
+
schema += '.nullable()';
|
|
107
|
+
}
|
|
108
|
+
return { schema, generated };
|
|
109
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const pikkuFetch: import("#pikku").PikkuFunctionConfig<void, void, "
|
|
1
|
+
export declare const pikkuFetch: import("#pikku").PikkuFunctionConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").Services> | import("#pikku").PikkuFunction<void, void, "rpc" | "session", import("#pikku").Services>, undefined, undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const pikkuNext: import("#pikku").PikkuFunctionConfig<void, void, "
|
|
1
|
+
export declare const pikkuNext: import("#pikku").PikkuFunctionConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").Services> | import("#pikku").PikkuFunction<void, void, "rpc" | "session", import("#pikku").Services>, undefined, undefined>;
|
|
@@ -4,6 +4,7 @@ import { getFileImportRelativePath } from '../../../utils/file-import-path.js';
|
|
|
4
4
|
import { writeFileInDir } from '../../../utils/file-writer.js';
|
|
5
5
|
import { logCommandInfoAndTime } from '../../../middleware/log-command-info-and-time.js';
|
|
6
6
|
import { serializeNextJsBackendWrapper as serializeNextBackendWrapper } from './serialize-nextjs-backend-wrapper.js';
|
|
7
|
+
import { serializeNextJsBackendWorkerRPCWrapper as serializeNextBackendWorkerRPCWrapper } from './serialize-nextjs-backend-worker-rpc-wrapper.js';
|
|
7
8
|
import { serializeNextJsHTTPWrapper as serializeNextHTTPWrapper } from './serialize-nextjs-http-wrapper.js';
|
|
8
9
|
export const pikkuNext = pikkuSessionlessFunc({
|
|
9
10
|
func: async ({ logger, config, getInspectorState }) => {
|
|
@@ -20,13 +21,31 @@ export const pikkuNext = pikkuSessionlessFunc({
|
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
23
|
const visitState = await getInspectorState();
|
|
23
|
-
|
|
24
|
+
const nextBackendTransport = config.clientFiles?.nextBackendTransport ?? 'local';
|
|
25
|
+
const nextBackendFetcherImport = config.clientFiles?.nextBackendFetcherImport;
|
|
26
|
+
if ((nextHTTPFile || nextBackendTransport === 'http') && !fetchFile) {
|
|
24
27
|
throw new Error('fetchFile is required in pikku config in order for nextJS http wrapper to work');
|
|
25
28
|
}
|
|
26
29
|
if ((nextBackendFile || nextHTTPFile) && !rpcMapDeclarationFile) {
|
|
27
30
|
throw new Error('rpcMapDeclarationFile is required in pikku config in order for nextJS wrapper to work');
|
|
28
31
|
}
|
|
29
|
-
if (nextBackendFile) {
|
|
32
|
+
if (nextBackendFile && nextBackendTransport === 'http') {
|
|
33
|
+
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile, httpMapDeclarationFile, packageMappings);
|
|
34
|
+
const rpcMapDeclarationPath = getFileImportRelativePath(nextBackendFile, rpcMapDeclarationFile, packageMappings);
|
|
35
|
+
const fetchPath = getFileImportRelativePath(nextBackendFile, fetchFile, packageMappings);
|
|
36
|
+
const content = serializeNextHTTPWrapper(routesMapDeclarationPath, rpcMapDeclarationPath, fetchPath, config.globalHTTPPrefix || '', "process.env.PIKKU_DEV_MACHINE_API_BASE ?? 'http://127.0.0.1:4004'");
|
|
37
|
+
await writeFileInDir(logger, nextBackendFile, content);
|
|
38
|
+
}
|
|
39
|
+
else if (nextBackendFile && nextBackendTransport === 'worker-rpc') {
|
|
40
|
+
if (!nextBackendFetcherImport) {
|
|
41
|
+
throw new Error("clientFiles.nextBackendFetcherImport is required when nextBackendTransport === 'worker-rpc'");
|
|
42
|
+
}
|
|
43
|
+
const routesMapDeclarationPath = getFileImportRelativePath(nextBackendFile, httpMapDeclarationFile, packageMappings);
|
|
44
|
+
const rpcMapDeclarationPath = getFileImportRelativePath(nextBackendFile, rpcMapDeclarationFile, packageMappings);
|
|
45
|
+
const content = serializeNextBackendWorkerRPCWrapper(routesMapDeclarationPath, rpcMapDeclarationPath, nextBackendFetcherImport, config.globalHTTPPrefix || '');
|
|
46
|
+
await writeFileInDir(logger, nextBackendFile, content);
|
|
47
|
+
}
|
|
48
|
+
else if (nextBackendFile) {
|
|
30
49
|
checkRequiredTypes(visitState.filesAndMethodsErrors, {
|
|
31
50
|
config: true,
|
|
32
51
|
singletonServicesFactory: true,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const serializeNextJsBackendWorkerRPCWrapper: (routesMapPath: string, rpcMapPath: string, fetcherImportPath: string, globalHTTPPrefix?: string) => string;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
export const serializeNextJsBackendWorkerRPCWrapper = (routesMapPath, rpcMapPath, fetcherImportPath, globalHTTPPrefix = '') => {
|
|
2
|
+
return `'server-only'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Worker-RPC variant of the Next.js backend wrapper. Function code is NOT
|
|
6
|
+
* loaded in-process — every call is dispatched through the injected Fetcher.
|
|
7
|
+
* Generated by @pikku/cli (nextBackendTransport: 'worker-rpc').
|
|
8
|
+
*/
|
|
9
|
+
import { PikkuNextJSWorkerRPC } from '@pikku/next'
|
|
10
|
+
import { NextRequest } from 'next/server.js'
|
|
11
|
+
import type { HTTPWiringsMap, HTTPWiringHandlerOf, HTTPWiringsWithMethod } from '${routesMapPath}'
|
|
12
|
+
import type { FlattenedRPCMap } from '${rpcMapPath}'
|
|
13
|
+
import { fetcher } from '${fetcherImportPath}'
|
|
14
|
+
|
|
15
|
+
type RouteContext = { params: Promise<Record<string, string | string[]>> }
|
|
16
|
+
|
|
17
|
+
let _pikku: PikkuNextJSWorkerRPC | undefined
|
|
18
|
+
let _removeAPIPrefix = true
|
|
19
|
+
|
|
20
|
+
export const removeAPIPrefix = (enable: boolean) => {
|
|
21
|
+
_removeAPIPrefix = enable
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const pikku = (_options?: any) => {
|
|
25
|
+
if (!_pikku) {
|
|
26
|
+
_pikku = new PikkuNextJSWorkerRPC({ fetcher })
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const dynamicActionRequest = async <
|
|
30
|
+
Route extends keyof HTTPWiringsMap,
|
|
31
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
32
|
+
>(
|
|
33
|
+
route: Route,
|
|
34
|
+
method: Method,
|
|
35
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
36
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
37
|
+
return _pikku!.actionRequest(route, method, data as any)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const staticActionRequest = async <
|
|
41
|
+
Route extends keyof HTTPWiringsMap,
|
|
42
|
+
Method extends keyof HTTPWiringsMap[Route]
|
|
43
|
+
>(
|
|
44
|
+
route: Route,
|
|
45
|
+
method: Method,
|
|
46
|
+
data: HTTPWiringHandlerOf<Route, Method>['input'] = null
|
|
47
|
+
): Promise<HTTPWiringHandlerOf<Route, Method>['output']> => {
|
|
48
|
+
return _pikku!.staticActionRequest(route, method, data as any)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const dynamicPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
52
|
+
route: Route,
|
|
53
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
54
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
55
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
56
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
57
|
+
return dynamicActionRequest(route, 'POST', args[0] ?? null)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const dynamicGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
61
|
+
route: Route,
|
|
62
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
63
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
64
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
65
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
66
|
+
return dynamicActionRequest(route, 'GET', args[0] ?? null)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const dynamicPatch = <Route extends HTTPWiringsWithMethod<'PATCH'>>(
|
|
70
|
+
route: Route,
|
|
71
|
+
...args: HTTPWiringHandlerOf<Route, 'PATCH'>['input'] extends null | undefined
|
|
72
|
+
? [data?: HTTPWiringHandlerOf<Route, 'PATCH'>['input']]
|
|
73
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'PATCH'>['input']>]
|
|
74
|
+
): Promise<HTTPWiringHandlerOf<Route, 'PATCH'>['output']> => {
|
|
75
|
+
return dynamicActionRequest(route, 'PATCH', args[0] ?? null)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const dynamicDel = <Route extends HTTPWiringsWithMethod<'DELETE'>>(
|
|
79
|
+
route: Route,
|
|
80
|
+
...args: HTTPWiringHandlerOf<Route, 'DELETE'>['input'] extends null | undefined
|
|
81
|
+
? [data?: HTTPWiringHandlerOf<Route, 'DELETE'>['input']]
|
|
82
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'DELETE'>['input']>]
|
|
83
|
+
): Promise<HTTPWiringHandlerOf<Route, 'DELETE'>['output']> => {
|
|
84
|
+
return dynamicActionRequest(route, 'DELETE', args[0] ?? null)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const staticPost = <Route extends HTTPWiringsWithMethod<'POST'>>(
|
|
88
|
+
route: Route,
|
|
89
|
+
...args: HTTPWiringHandlerOf<Route, 'POST'>['input'] extends null | undefined
|
|
90
|
+
? [data?: HTTPWiringHandlerOf<Route, 'POST'>['input']]
|
|
91
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'POST'>['input']>]
|
|
92
|
+
): Promise<HTTPWiringHandlerOf<Route, 'POST'>['output']> => {
|
|
93
|
+
return staticActionRequest(route, 'POST', args[0] ?? null)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const staticGet = <Route extends HTTPWiringsWithMethod<'GET'>>(
|
|
97
|
+
route: Route,
|
|
98
|
+
...args: HTTPWiringHandlerOf<Route, 'GET'>['input'] extends null | undefined
|
|
99
|
+
? [data?: HTTPWiringHandlerOf<Route, 'GET'>['input']]
|
|
100
|
+
: [data: NonNullable<HTTPWiringHandlerOf<Route, 'GET'>['input']>]
|
|
101
|
+
): Promise<HTTPWiringHandlerOf<Route, 'GET'>['output']> => {
|
|
102
|
+
return staticActionRequest(route, 'GET', args[0] ?? null)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// RPC dispatch goes through the underlying actionRequest (route: unknown)
|
|
106
|
+
// rather than the typed dynamic/static wrappers — '/rpc/:rpcName' isn't
|
|
107
|
+
// necessarily registered as an HTTPWiringsMap key in projects that haven't
|
|
108
|
+
// explicitly wired one. Output type is enforced via FlattenedRPCMap.
|
|
109
|
+
const rpc = async <Name extends keyof FlattenedRPCMap>(
|
|
110
|
+
rpcName: Name,
|
|
111
|
+
data: FlattenedRPCMap[Name]['input']
|
|
112
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
113
|
+
return _pikku!.actionRequest(
|
|
114
|
+
'${globalHTTPPrefix}/rpc/:rpcName',
|
|
115
|
+
'POST',
|
|
116
|
+
{ rpcName, data: data ?? null }
|
|
117
|
+
) as Promise<FlattenedRPCMap[Name]['output']>
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const staticRPC = async <Name extends keyof FlattenedRPCMap>(
|
|
121
|
+
rpcName: Name,
|
|
122
|
+
data: FlattenedRPCMap[Name]['input']
|
|
123
|
+
): Promise<FlattenedRPCMap[Name]['output']> => {
|
|
124
|
+
return _pikku!.staticActionRequest(
|
|
125
|
+
'${globalHTTPPrefix}/rpc/:rpcName',
|
|
126
|
+
'POST',
|
|
127
|
+
{ rpcName, data: data ?? null }
|
|
128
|
+
) as Promise<FlattenedRPCMap[Name]['output']>
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
rpc,
|
|
133
|
+
get: dynamicGet,
|
|
134
|
+
post: dynamicPost,
|
|
135
|
+
patch: dynamicPatch,
|
|
136
|
+
del: dynamicDel,
|
|
137
|
+
staticGet,
|
|
138
|
+
staticPost,
|
|
139
|
+
staticRPC,
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const pikkuAPIRequest = (
|
|
144
|
+
req: NextRequest,
|
|
145
|
+
context: RouteContext
|
|
146
|
+
): Promise<Response> => {
|
|
147
|
+
if (!_pikku) {
|
|
148
|
+
_pikku = new PikkuNextJSWorkerRPC({ fetcher })
|
|
149
|
+
}
|
|
150
|
+
if (_removeAPIPrefix) {
|
|
151
|
+
const url = new URL(req.url)
|
|
152
|
+
url.pathname = url.pathname.replace(/^\\/api/, '') || '/'
|
|
153
|
+
req = new NextRequest(url.toString(), {
|
|
154
|
+
method: req.method,
|
|
155
|
+
headers: req.headers,
|
|
156
|
+
body: req.body,
|
|
157
|
+
duplex: 'half',
|
|
158
|
+
} as any)
|
|
159
|
+
}
|
|
160
|
+
return _pikku.apiRequest(req)
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const serializeNextJsHTTPWrapper: (routesMapPath: string, rpcMapPath: string, pikkuFetchImport: string, globalHTTPPrefix?: string) => string;
|
|
1
|
+
export declare const serializeNextJsHTTPWrapper: (routesMapPath: string, rpcMapPath: string, pikkuFetchImport: string, globalHTTPPrefix?: string, defaultServerUrlExpression?: string) => string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const serializeNextJsHTTPWrapper = (routesMapPath, rpcMapPath, pikkuFetchImport, globalHTTPPrefix = '') => {
|
|
1
|
+
export const serializeNextJsHTTPWrapper = (routesMapPath, rpcMapPath, pikkuFetchImport, globalHTTPPrefix = '', defaultServerUrlExpression) => {
|
|
2
2
|
return `'server-only'
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -11,6 +11,7 @@ import type { FlattenedRPCMap } from '${rpcMapPath}'
|
|
|
11
11
|
import { PikkuFetch } from '${pikkuFetchImport}'
|
|
12
12
|
|
|
13
13
|
let _pikku: PikkuFetch | undefined
|
|
14
|
+
const defaultServerUrl = ${defaultServerUrlExpression ?? 'undefined'}
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Initializes and returns an instance of PikkuNextJS with helper methods for handling route requests.
|
|
@@ -19,7 +20,9 @@ let _pikku: PikkuFetch | undefined
|
|
|
19
20
|
*/
|
|
20
21
|
export const pikku = (options?: CorePikkuFetchOptions) => {
|
|
21
22
|
if (!_pikku) {
|
|
22
|
-
_pikku = new PikkuFetch(
|
|
23
|
+
_pikku = new PikkuFetch(
|
|
24
|
+
defaultServerUrl ? { serverUrl: defaultServerUrl, ...options } : options
|
|
25
|
+
)
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
const dynamicActionRequest = async <
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const pikkuTanStackStart: import("#pikku").PikkuFunctionConfig<void, void, "rpc" | "session", import("#pikku").PikkuFunctionSessionless<void, void, "rpc" | "session", import("#pikku").Services> | import("#pikku").PikkuFunction<void, void, "rpc" | "session", import("#pikku").Services>, undefined, undefined>;
|