@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,258 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-feature
|
|
3
|
+
description: 'Drive create-a-feature work for a Pikku project: discover project context, work on a feature branch, implement + verify + commit, and ask the user to review via the diff. TRIGGER when: the user asks to "create a feature", "build a todo app", "add X to my Pikku project", "wire up a new endpoint", or anything that implies turning a natural-language request into Pikku functions/wirings/migrations. DO NOT TRIGGER when: the user asks for a one-off code edit in an existing function, or asks about Pikku concepts (use pikku-concepts).'
|
|
4
|
+
installGroups: [core]
|
|
5
|
+
allowed-tools: Bash(yarn pikku meta *), Bash(yarn pikku all *), Bash(yarn tsc), Bash(git status *), Bash(git diff *), Bash(git switch *), Bash(git checkout *), Bash(git checkout -b *), Bash(git add *), Bash(git commit *), Bash(git log *), Bash(git branch *)
|
|
6
|
+
argument-hint: '<feature description>'
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Pikku Create-a-Feature
|
|
10
|
+
|
|
11
|
+
## Agent Operating Procedure
|
|
12
|
+
|
|
13
|
+
Use this skill as an execution checklist, not reference material.
|
|
14
|
+
|
|
15
|
+
1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
16
|
+
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
17
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
18
|
+
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
19
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
20
|
+
|
|
21
|
+
End-to-end flow: **discover → state intent → branch → implement → verify → commit → hand to reviewer**.
|
|
22
|
+
|
|
23
|
+
There is **no plan JSON**. The branch + diff IS the contract. The reviewer
|
|
24
|
+
sees real, compiled, working code. Apply = merge. Reject = `git branch -D`.
|
|
25
|
+
|
|
26
|
+
## Stage 1 — Discover
|
|
27
|
+
|
|
28
|
+
Run **once** at the start of every feature request:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
yarn pikku meta context --json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
This single call returns functions, wires, middleware, permissions, workflows,
|
|
35
|
+
`capabilities` (which wire types are in use), and `layout` (where new files
|
|
36
|
+
should land).
|
|
37
|
+
|
|
38
|
+
Only fall back to targeted commands when you need full input/output JSON
|
|
39
|
+
schemas (`yarn pikku meta functions get <id>`) or workflow steps
|
|
40
|
+
(`yarn pikku meta workflows get <id>`).
|
|
41
|
+
|
|
42
|
+
**Capability rule:** do not introduce new wires of a type whose
|
|
43
|
+
`capabilities.<type>` is `false` unless the user explicitly asked for it.
|
|
44
|
+
|
|
45
|
+
## Stage 2 — State intent in plain English (BEFORE writing code)
|
|
46
|
+
|
|
47
|
+
Before touching any files, give the user one paragraph stating exactly what
|
|
48
|
+
you'll do. This is the lightweight "plan" — it is chat, not JSON.
|
|
49
|
+
|
|
50
|
+
> I'll add a `todos` table via a new migration in `sql/`, and two
|
|
51
|
+
> `pikkuSessionlessFunc`s (`createTodo`, `listTodos` with
|
|
52
|
+
> `readonly: true`) in `packages/functions/src/functions/`. Both
|
|
53
|
+
> `expose: true`, so they'll be reachable via the auto-generated RPC
|
|
54
|
+
> client and React Query hooks — no HTTP wiring needed. No new
|
|
55
|
+
> dependencies. OK to proceed?
|
|
56
|
+
|
|
57
|
+
Wait for the user to confirm or redirect. They can ask for changes ("use the
|
|
58
|
+
existing tasks table" / "make it a queue not http") in normal chat — no
|
|
59
|
+
schema, no JSON, no ceremony.
|
|
60
|
+
|
|
61
|
+
**Non-interactive runs (auto mode, CI, batch jobs):** state intent in one
|
|
62
|
+
paragraph and proceed without waiting. Surface course corrections promptly
|
|
63
|
+
in the post-implementation report.
|
|
64
|
+
|
|
65
|
+
## Stage 3 — Branch off
|
|
66
|
+
|
|
67
|
+
After confirmation, ensure the working tree is clean and create a feature
|
|
68
|
+
branch off the current default branch (whatever `git branch --show-current`
|
|
69
|
+
returns at the start — `main`, `master`, `develop`, all fine):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
git status
|
|
73
|
+
git switch -c feature/<short-slug>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
If the working tree is dirty, **stop and ask** — never stash silently or
|
|
77
|
+
overwrite uncommitted work.
|
|
78
|
+
|
|
79
|
+
## Stage 4 — Implement
|
|
80
|
+
|
|
81
|
+
Write the code as a normal human contributor would. Use the project's
|
|
82
|
+
existing conventions (look at neighbour files in `srcDirectories[0]/functions/`
|
|
83
|
+
and `.../wirings/` for style).
|
|
84
|
+
|
|
85
|
+
### RPC is the default transport
|
|
86
|
+
|
|
87
|
+
**Just write the function with `expose: true`** — that's enough to make it
|
|
88
|
+
callable. Pikku auto-generates an RPC client (and React Query hooks if the
|
|
89
|
+
project's `clientFiles.reactQueryFile` is set) from every exposed function.
|
|
90
|
+
You do **not** need an HTTP wiring for callers to reach the function.
|
|
91
|
+
|
|
92
|
+
Default flow for a feature:
|
|
93
|
+
|
|
94
|
+
1. Write the function file with `expose: true` (and `readonly: true` for
|
|
95
|
+
reads).
|
|
96
|
+
2. Run `pikku all` — RPC map, fetch client, and React Query hooks are
|
|
97
|
+
regenerated. Frontends call `useListTodos()` / `mutation.mutate(...)`
|
|
98
|
+
without you wiring anything.
|
|
99
|
+
|
|
100
|
+
Add an HTTP wiring **only when** the feature genuinely needs a specific
|
|
101
|
+
REST shape (third-party callers, webhooks, REST-conventional URLs). Most
|
|
102
|
+
in-app features don't.
|
|
103
|
+
|
|
104
|
+
### Hard rules that always apply
|
|
105
|
+
|
|
106
|
+
- **`expose: true`** for any function called from a frontend or another
|
|
107
|
+
service. Without it the RPC client won't generate hooks for it.
|
|
108
|
+
- **`readonly: true` for queries.** Mark read functions as `readonly: true`
|
|
109
|
+
on the function config. The runner uses this to enforce read-only sessions
|
|
110
|
+
(a write func called under a readonly session is rejected). The RPC layer
|
|
111
|
+
also uses it to pick `useQuery` (cacheable) vs `useMutation` for client
|
|
112
|
+
hooks. Mutations leave `readonly` unset (or `false`).
|
|
113
|
+
- **`kind` ⇔ `auth` coupling for HTTP wirings (when you have one).** If the
|
|
114
|
+
function is `pikkuFunc` (session-aware), the HTTP wiring needs
|
|
115
|
+
`auth: true`. `pikkuSessionlessFunc` ⇒ `auth: false`. Mismatching is a
|
|
116
|
+
hard error (PKU573).
|
|
117
|
+
- **HTTP method by intent (when you wire HTTP).** Reads → `GET`. Writes →
|
|
118
|
+
`POST`/`PUT`/`PATCH`/`DELETE` per REST conventions.
|
|
119
|
+
- **Workflows.** Prefer `pikkuWorkflowGraph` (DSL) over
|
|
120
|
+
`pikkuWorkflowComplexFunc`. `mode: 'inline'` is sync; `'distributed'` is
|
|
121
|
+
queue-dispatched.
|
|
122
|
+
- **Auth checks belong on the function or wiring**, not in function bodies.
|
|
123
|
+
Use the `permissions` field with a `pikkuPermission` factory.
|
|
124
|
+
- **Throw typed errors** from `@pikku/core/errors` — `NotFoundError`,
|
|
125
|
+
`ConflictError`, `BadRequestError`. Never bare `Error`.
|
|
126
|
+
- **Migrations are inline SQL files** in the project's migrations dir
|
|
127
|
+
(typically `sql/`). Use a numbered prefix matching existing files.
|
|
128
|
+
- **Secrets and env-vars: NEVER `process.env`.** Declare them with
|
|
129
|
+
`wireSecret` (sensitive) or `wireVariable` (non-sensitive) — both with a
|
|
130
|
+
zod schema for type-safe access. Read with
|
|
131
|
+
`services.secrets.getSecretJSON('NAME')` or `services.variables.get('NAME')`.
|
|
132
|
+
See the **pikku-config** skill for the full pattern (including
|
|
133
|
+
OAuth2 credentials). This applies even in `config.ts` and singleton
|
|
134
|
+
service factories.
|
|
135
|
+
|
|
136
|
+
### Conventions to copy from neighbours
|
|
137
|
+
|
|
138
|
+
Some patterns vary by project; **read a neighbour file before writing**:
|
|
139
|
+
|
|
140
|
+
- **Function shape**: zod schemas as exported `const`s (`CreateTodoInput`,
|
|
141
|
+
`CreateTodoOutput`) passed to `input`/`output` on the func config — vs
|
|
142
|
+
generic-typed config. Schema name **must match codegen expectations** (the
|
|
143
|
+
exported const name = the schema name in generated `.gen.json`).
|
|
144
|
+
- **Imports**: usually `'#pikku'` for `pikkuFunc` / `pikkuSessionlessFunc`
|
|
145
|
+
etc. Copy what neighbours do.
|
|
146
|
+
- **Service usage**: e.g. `kysely`, `redis`. Look at how an existing function
|
|
147
|
+
destructures services from its first arg. **Check `application-types.d.ts`**
|
|
148
|
+
to see whether services like `kysely` are typed (`Kysely<DB>`) or untyped
|
|
149
|
+
(`Kysely<any>`) — that drives whether you can lean on generated DB types
|
|
150
|
+
or have to coerce manually.
|
|
151
|
+
- **DB schema namespace**: many projects put tables under a `CREATE SCHEMA`
|
|
152
|
+
(e.g. `app.todos`). Read the first migration in `sql/` to see the
|
|
153
|
+
convention; reuse helper functions/triggers (e.g. `update_last_updated_at`)
|
|
154
|
+
rather than redefining them.
|
|
155
|
+
- **HTTP wiring style** (only relevant if you're adding one). Two common
|
|
156
|
+
shapes — match what the project already uses:
|
|
157
|
+
- Per-route `wireHTTP({ method, route, func, auth })`.
|
|
158
|
+
- Single map: `const routes = defineHTTPRoutes({ auth: false, routes: {
|
|
159
|
+
fooName: { method: 'post', route: '/foo', func: fooFunc } }}); wireHTTPRoutes(routes)`.
|
|
160
|
+
|
|
161
|
+
For shared wiring files (e.g. `todos.http.ts` holding both create and list):
|
|
162
|
+
create the file with imports if it doesn't exist; **append** wire calls and
|
|
163
|
+
add missing imports if it does.
|
|
164
|
+
|
|
165
|
+
## Stage 5 — Verify
|
|
166
|
+
|
|
167
|
+
Both must complete cleanly **for your changes** before committing:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
yarn pikku all
|
|
171
|
+
# Type-check the workspaces you touched:
|
|
172
|
+
cd packages/functions && npx tsc --noEmit
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Notes on running `tsc`:
|
|
176
|
+
|
|
177
|
+
- A root-level `yarn tsc` may be a no-op in monorepos that don't define a
|
|
178
|
+
`tsc` script in each workspace. Don't trust an exit-zero from the root if
|
|
179
|
+
no actual checking happened — verify by running `npx tsc --noEmit` in the
|
|
180
|
+
package(s) you touched.
|
|
181
|
+
|
|
182
|
+
### What "fails" means
|
|
183
|
+
|
|
184
|
+
**Trust the exit code, not the stderr noise.** `yarn pikku all` may print
|
|
185
|
+
warnings, `[PKUxxx]` messages, even `level: critical` log lines, while
|
|
186
|
+
still exiting `0` — those are pre-existing project state, not your
|
|
187
|
+
problem. Same for `meta context --json`: it streams logs to stderr that
|
|
188
|
+
look scary on a clean baseline. The exit code is the source of truth.
|
|
189
|
+
|
|
190
|
+
If a command exits non-zero, that's a real failure — fix or stop.
|
|
191
|
+
|
|
192
|
+
### Baseline noise — only your errors matter
|
|
193
|
+
|
|
194
|
+
Many real-world projects ship with pre-existing warnings or errors
|
|
195
|
+
(legacy types, version drift, gen-layer messages). Those are not your
|
|
196
|
+
problem; do not "fix" them.
|
|
197
|
+
|
|
198
|
+
To distinguish your errors from baseline:
|
|
199
|
+
|
|
200
|
+
1. **Before implementing** (Stage 4), capture the baseline:
|
|
201
|
+
```bash
|
|
202
|
+
yarn pikku all 2>&1 | tee /tmp/pikku-before.log
|
|
203
|
+
```
|
|
204
|
+
2. **After implementing**, compare:
|
|
205
|
+
```bash
|
|
206
|
+
yarn pikku all 2>&1 | tee /tmp/pikku-after.log
|
|
207
|
+
diff /tmp/pikku-before.log /tmp/pikku-after.log
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
A clean diff means your changes introduced no new issues — even if the
|
|
211
|
+
underlying logs both show pre-existing warnings.
|
|
212
|
+
|
|
213
|
+
If something genuinely failed because of YOUR change, fix the actual issue.
|
|
214
|
+
**Do not** mask errors with `as any`, `@ts-ignore`, or `--no-verify`. If
|
|
215
|
+
you're stuck, surface the failure to the user — don't hand them a broken
|
|
216
|
+
branch.
|
|
217
|
+
|
|
218
|
+
## Stage 6 — Commit
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
git add -A
|
|
222
|
+
git commit -m "feat: <short title>"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Stage 7 — Hand off
|
|
226
|
+
|
|
227
|
+
Tell the user the branch name and how to review. Two options:
|
|
228
|
+
|
|
229
|
+
- **Local review:** open the pikku console — the changes view diffs the
|
|
230
|
+
current branch against `main` with pikku-aware structure (added functions,
|
|
231
|
+
new wires, migrations).
|
|
232
|
+
- **PR review:** ask before pushing. Once they confirm, `git push -u origin
|
|
233
|
+
feature/<slug>` and surface the PR-create URL.
|
|
234
|
+
|
|
235
|
+
Do not push without explicit confirmation. Do not merge.
|
|
236
|
+
|
|
237
|
+
## Hard constraints
|
|
238
|
+
|
|
239
|
+
The skill's `allowed-tools` does **not** permit:
|
|
240
|
+
|
|
241
|
+
- `yarn add` / `npm install` / dependency changes (ask the user first)
|
|
242
|
+
- `yarn dbmigrate` (never run migrations against the real DB during planning)
|
|
243
|
+
- `pikku deploy apply` (never deploy)
|
|
244
|
+
- secret writes
|
|
245
|
+
- network calls beyond what the implementation requires
|
|
246
|
+
|
|
247
|
+
If the feature genuinely needs any of these, **stop and ask** with a clear
|
|
248
|
+
explanation of why and what would change.
|
|
249
|
+
|
|
250
|
+
## Output discipline
|
|
251
|
+
|
|
252
|
+
- Stage 2 (intent statement) is plain English, one paragraph.
|
|
253
|
+
- Between stages, give one-line updates: "Discovered 30 functions, http+queue
|
|
254
|
+
in use. Drafting intent..." → "Branch `feature/todos` created, implementing..."
|
|
255
|
+
→ "`pikku all` clean, `tsc` clean, committed. Review via console or run
|
|
256
|
+
`git diff main`."
|
|
257
|
+
- Don't narrate file-by-file. Only surface what's interesting (new patterns,
|
|
258
|
+
judgment calls, things you suppressed).
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-gateway-slack
|
|
3
|
+
description: 'Use when integrating Slack with a Pikku app. Covers SlackGatewayAdapter, slash commands, OAuth flow, message handling, and signature verification.
|
|
4
|
+
TRIGGER when: code uses SlackGatewayAdapter, parseSlashCommand, buildSlackInstallUrl, or user asks about Slack integration, Slack bots, or @pikku/gateway-slack.
|
|
5
|
+
DO NOT TRIGGER when: user asks about general gateway/webhook patterns (use pikku-trigger).'
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pikku Gateway Slack
|
|
9
|
+
|
|
10
|
+
## Agent Operating Procedure
|
|
11
|
+
|
|
12
|
+
Use this skill as an execution checklist, not reference material.
|
|
13
|
+
|
|
14
|
+
1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
15
|
+
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
16
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
17
|
+
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
18
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
19
|
+
|
|
20
|
+
`@pikku/gateway-slack` provides a Slack Events API gateway adapter, slash command handling, OAuth installation flow, and message utilities.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
yarn add @pikku/gateway-slack @slack/web-api
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API Reference
|
|
29
|
+
|
|
30
|
+
### `SlackGatewayAdapter`
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { SlackGatewayAdapter } from '@pikku/gateway-slack'
|
|
34
|
+
|
|
35
|
+
const adapter = new SlackGatewayAdapter(options: SlackGatewayAdapterOptions)
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Bridges Slack Events API webhooks with Pikku's gateway system for processing Slack events as Pikku functions.
|
|
39
|
+
|
|
40
|
+
### `SlackGatewayHelper`
|
|
41
|
+
|
|
42
|
+
Helper for handling Slack messages and metadata within gateway functions.
|
|
43
|
+
|
|
44
|
+
### Slash Commands
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { parseSlashCommand, respondToSlashCommand } from '@pikku/gateway-slack'
|
|
48
|
+
|
|
49
|
+
const command = parseSlashCommand(request)
|
|
50
|
+
await respondToSlashCommand(responseUrl, { text: 'Done!' })
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### OAuth Flow
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import {
|
|
57
|
+
buildSlackInstallUrl,
|
|
58
|
+
exchangeSlackOAuthCode,
|
|
59
|
+
RECOMMENDED_BOT_SCOPES,
|
|
60
|
+
} from '@pikku/gateway-slack'
|
|
61
|
+
|
|
62
|
+
const installUrl = buildSlackInstallUrl({
|
|
63
|
+
clientId: config.slackClientId,
|
|
64
|
+
scopes: RECOMMENDED_BOT_SCOPES,
|
|
65
|
+
redirectUri: config.slackRedirectUri,
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
const tokens = await exchangeSlackOAuthCode({
|
|
69
|
+
clientId: config.slackClientId,
|
|
70
|
+
clientSecret: config.slackClientSecret,
|
|
71
|
+
code: oauthCode,
|
|
72
|
+
redirectUri: config.slackRedirectUri,
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Signature Verification
|
|
77
|
+
|
|
78
|
+
```typescript
|
|
79
|
+
import { verifySlackSignature } from '@pikku/gateway-slack'
|
|
80
|
+
|
|
81
|
+
verifySlackSignature(signingSecret, timestamp, body, signature)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Usage Patterns
|
|
85
|
+
|
|
86
|
+
### Slack Bot Gateway
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
import { SlackGatewayAdapter } from '@pikku/gateway-slack'
|
|
90
|
+
|
|
91
|
+
const slackGateway = new SlackGatewayAdapter({
|
|
92
|
+
signingSecret: config.slackSigningSecret,
|
|
93
|
+
botToken: config.slackBotToken,
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// Register with your HTTP runner to handle /slack/events endpoint
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Slash Command Handler
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const handleSlashCommand = pikkuSessionlessFunc({
|
|
103
|
+
title: 'Handle Slack Command',
|
|
104
|
+
func: async ({ db }, data) => {
|
|
105
|
+
const command = parseSlashCommand(data)
|
|
106
|
+
// Process command...
|
|
107
|
+
await respondToSlashCommand(command.response_url, {
|
|
108
|
+
text: `Processed: ${command.text}`,
|
|
109
|
+
})
|
|
110
|
+
},
|
|
111
|
+
})
|
|
112
|
+
```
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-http
|
|
3
|
+
description: 'Use when adding HTTP routes, REST APIs, web endpoints, or SSE streams to a Pikku app. Covers wireHTTP, defineHTTPRoutes, route groups, auth, middleware, permissions, SSE, and generated fetch client.
|
|
4
|
+
TRIGGER when: code uses wireHTTP/defineHTTPRoutes/wireHTTPRoutes, user asks about REST endpoints, API routes, SSE, or the generated fetch client.
|
|
5
|
+
DO NOT TRIGGER when: user asks about WebSocket (use pikku-websocket), queue workers (use pikku-queue), or deployment (use pikku-deploy-*).'
|
|
6
|
+
installGroups: [core]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Pikku HTTP Wiring
|
|
10
|
+
|
|
11
|
+
## Agent Operating Procedure
|
|
12
|
+
|
|
13
|
+
Use this skill as an execution checklist, not reference material.
|
|
14
|
+
|
|
15
|
+
1. Discover before editing. Prefer OpenCode tools such as `pikku-meta` when available; otherwise run the relevant `pikku meta ... --json` command and inspect only the focused output you need.
|
|
16
|
+
2. Identify the source files that own the behavior. Do not start by reading generated output, `.pikku`, `node_modules`, vendored packages, or broad build artifacts.
|
|
17
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
18
|
+
4. Validate with the narrowest relevant command first, then run `pikku-verify` or `pikku all` when functions, wirings, schemas, or generated clients may have changed.
|
|
19
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
20
|
+
|
|
21
|
+
Wire Pikku functions to HTTP endpoints. Supports single routes, composable route groups, auth, middleware, permissions, SSE, and auto-generated type-safe clients.
|
|
22
|
+
|
|
23
|
+
## Before You Start
|
|
24
|
+
|
|
25
|
+
Run these commands to understand the current project:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
pikku info functions --verbose # See existing functions, their types, tags, middleware
|
|
29
|
+
pikku info tags --verbose # Understand project organization and naming conventions
|
|
30
|
+
pikku info middleware --verbose # See what middleware is already applied
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Follow existing patterns you find (naming, tag usage, file organization). See `pikku-concepts` for the core mental model.
|
|
34
|
+
|
|
35
|
+
## API Reference
|
|
36
|
+
|
|
37
|
+
### `wireHTTP(config)`
|
|
38
|
+
|
|
39
|
+
Wire a single function to an HTTP endpoint.
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { wireHTTP } from '@pikku/core/http'
|
|
43
|
+
|
|
44
|
+
wireHTTP({
|
|
45
|
+
method: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head',
|
|
46
|
+
route: string, // e.g. '/books/:bookId' — :params become data fields
|
|
47
|
+
func: PikkuFunc, // The function to call
|
|
48
|
+
auth?: boolean, // Override default auth (true = require session)
|
|
49
|
+
tags?: string[], // For grouping, middleware targeting
|
|
50
|
+
permissions?: Record<string, PikkuPermission | PikkuPermission[]>,
|
|
51
|
+
middleware?: PikkuMiddleware[],
|
|
52
|
+
sse?: boolean, // Enable Server-Sent Events
|
|
53
|
+
contentType?: 'xml' | 'json', // Response content type
|
|
54
|
+
timeout?: number, // Request timeout in ms
|
|
55
|
+
headers?: HTTPHeadersSchema, // Expected headers schema
|
|
56
|
+
docs?: HTTPRouteDocsConfig, // OpenAPI docs config
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### `defineHTTPRoutes(config)` + `wireHTTPRoutes(config)`
|
|
61
|
+
|
|
62
|
+
Group routes with shared configuration. Groups are composable and nestable.
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { defineHTTPRoutes, wireHTTPRoutes } from '.pikku/pikku-types.gen.js'
|
|
66
|
+
|
|
67
|
+
const routes = defineHTTPRoutes({
|
|
68
|
+
basePath?: string, // Prepended to all route paths
|
|
69
|
+
tags?: string[], // Applied to all routes in group
|
|
70
|
+
auth?: boolean, // Default auth for all routes (overridable per-route)
|
|
71
|
+
middleware?: PikkuMiddleware[],
|
|
72
|
+
routes: {
|
|
73
|
+
[key: string]: {
|
|
74
|
+
method: string,
|
|
75
|
+
route: string,
|
|
76
|
+
func: PikkuFunc,
|
|
77
|
+
auth?: boolean, // Override group auth
|
|
78
|
+
permissions?: Record<string, PikkuPermission | PikkuPermission[]>,
|
|
79
|
+
middleware?: PikkuMiddleware[],
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
wireHTTPRoutes({
|
|
85
|
+
basePath?: string, // Top-level prefix (e.g. '/api/v1')
|
|
86
|
+
middleware?: PikkuMiddleware[],
|
|
87
|
+
routes: {
|
|
88
|
+
[key: string]: ReturnType<typeof defineHTTPRoutes>,
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Config cascading rules:
|
|
94
|
+
|
|
95
|
+
- `basePath` — concatenates down the chain
|
|
96
|
+
- `tags` — merge (union)
|
|
97
|
+
- `auth` — child overrides parent
|
|
98
|
+
|
|
99
|
+
### `addHTTPMiddleware(pattern, middlewares)`
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
addHTTPMiddleware('*', [authBearer()]) // All routes
|
|
103
|
+
addHTTPMiddleware('/api/*', [rateLimit()]) // Pattern match
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `addHTTPPermission(pattern, permissions)`
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
addHTTPPermission('/admin/*', { admin: [isAdmin] })
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Data Flow
|
|
113
|
+
|
|
114
|
+
Pikku merges route params, query params, and request body into a single `data` object:
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// POST /books/42?format=pdf with body { title: "New Title" }
|
|
118
|
+
wireHTTP({ method: 'post', route: '/books/:bookId', func: updateBook })
|
|
119
|
+
// → updateBook receives: { bookId: "42", format: "pdf", title: "New Title" }
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Usage Patterns
|
|
123
|
+
|
|
124
|
+
### Single Route
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
wireHTTP({
|
|
128
|
+
method: 'get',
|
|
129
|
+
route: '/books/:bookId',
|
|
130
|
+
func: getBook,
|
|
131
|
+
})
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Route Groups (Recommended for CRUD)
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
const booksRoutes = defineHTTPRoutes({
|
|
138
|
+
tags: ['books'],
|
|
139
|
+
routes: {
|
|
140
|
+
list: { method: 'get', route: '/books', func: listBooks, auth: false },
|
|
141
|
+
get: { method: 'get', route: '/books/:bookId', func: getBook },
|
|
142
|
+
create: { method: 'post', route: '/books', func: createBook },
|
|
143
|
+
delete: { method: 'delete', route: '/books/:bookId', func: deleteBook },
|
|
144
|
+
},
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const todosRoutes = defineHTTPRoutes({
|
|
148
|
+
auth: false,
|
|
149
|
+
tags: ['todos'],
|
|
150
|
+
routes: {
|
|
151
|
+
list: { method: 'get', route: '/todos', func: listTodos },
|
|
152
|
+
create: { method: 'post', route: '/todos', func: createTodo },
|
|
153
|
+
get: { method: 'get', route: '/todos/:id', func: getTodo },
|
|
154
|
+
},
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
wireHTTPRoutes({
|
|
158
|
+
basePath: '/api/v1',
|
|
159
|
+
middleware: [cors()],
|
|
160
|
+
routes: {
|
|
161
|
+
books: booksRoutes,
|
|
162
|
+
todos: todosRoutes,
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
// Results in: GET /api/v1/books, POST /api/v1/books, etc.
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Auth & Permissions
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
// Public route (no auth)
|
|
172
|
+
wireHTTP({ method: 'get', route: '/books', func: listBooks, auth: false })
|
|
173
|
+
|
|
174
|
+
// Route with permission check
|
|
175
|
+
wireHTTP({
|
|
176
|
+
method: 'delete',
|
|
177
|
+
route: '/books/:bookId',
|
|
178
|
+
func: deleteBook,
|
|
179
|
+
permissions: { admin: isAdmin },
|
|
180
|
+
})
|
|
181
|
+
|
|
182
|
+
// Pattern-based permissions
|
|
183
|
+
addHTTPPermission('/admin/*', { admin: isAdmin })
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Middleware
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
import { cors, authBearer } from '@pikku/core/middleware'
|
|
190
|
+
|
|
191
|
+
// Global middleware
|
|
192
|
+
addHTTPMiddleware('*', [
|
|
193
|
+
cors({ origin: 'https://app.example.com', credentials: true }),
|
|
194
|
+
authBearer(),
|
|
195
|
+
])
|
|
196
|
+
|
|
197
|
+
// Scoped middleware
|
|
198
|
+
addHTTPMiddleware('/api/*', [rateLimit({ maxRequests: 100, windowMs: 60_000 })])
|
|
199
|
+
|
|
200
|
+
// Per-route middleware
|
|
201
|
+
wireHTTP({
|
|
202
|
+
method: 'delete',
|
|
203
|
+
route: '/books/:bookId',
|
|
204
|
+
func: deleteBook,
|
|
205
|
+
middleware: [auditLog],
|
|
206
|
+
})
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### SSE (Server-Sent Events)
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
wireHTTP({
|
|
213
|
+
method: 'get',
|
|
214
|
+
route: '/todos',
|
|
215
|
+
func: getTodos,
|
|
216
|
+
sse: true,
|
|
217
|
+
})
|
|
218
|
+
|
|
219
|
+
const getTodos = pikkuFunc({
|
|
220
|
+
title: 'Get Todos',
|
|
221
|
+
func: async ({ db, channel }, {}) => {
|
|
222
|
+
const todos = await db.getTodos()
|
|
223
|
+
|
|
224
|
+
if (channel) {
|
|
225
|
+
for (const todo of todos) {
|
|
226
|
+
channel.send({ todo })
|
|
227
|
+
await sleep(100)
|
|
228
|
+
}
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return { todos }
|
|
233
|
+
},
|
|
234
|
+
})
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
### Generated Fetch Client
|
|
238
|
+
|
|
239
|
+
After `npx pikku prebuild`, a type-safe client is generated:
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
import { pikkuFetch } from '.pikku/pikku-fetch.gen.js'
|
|
243
|
+
|
|
244
|
+
pikkuFetch.setServerUrl('http://localhost:4002')
|
|
245
|
+
|
|
246
|
+
const books = await pikkuFetch.get('/api/v1/books', {})
|
|
247
|
+
const book = await pikkuFetch.get('/api/v1/books/:bookId', { bookId: '42' })
|
|
248
|
+
const created = await pikkuFetch.post('/api/v1/books', {
|
|
249
|
+
title: 'The Pikku Guide',
|
|
250
|
+
author: 'You',
|
|
251
|
+
})
|
|
252
|
+
|
|
253
|
+
pikkuFetch.setAuthorizationJWT(token)
|
|
254
|
+
const deleted = await pikkuFetch.delete('/api/v1/books/:bookId', {
|
|
255
|
+
bookId: created.bookId,
|
|
256
|
+
})
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Complete Example
|
|
260
|
+
|
|
261
|
+
```typescript
|
|
262
|
+
// functions/books.functions.ts
|
|
263
|
+
import { pikkuFunc, pikkuSessionlessFunc } from '#pikku'
|
|
264
|
+
|
|
265
|
+
export const listBooks = pikkuSessionlessFunc({
|
|
266
|
+
title: 'List Books',
|
|
267
|
+
func: async ({ db }, { limit }) => {
|
|
268
|
+
return { books: await db.listBooks(limit) }
|
|
269
|
+
},
|
|
270
|
+
})
|
|
271
|
+
|
|
272
|
+
export const getBook = pikkuFunc({
|
|
273
|
+
title: 'Get Book',
|
|
274
|
+
description: 'Retrieve a book by ID',
|
|
275
|
+
func: async ({ db }, { bookId }) => {
|
|
276
|
+
return await db.getBook(bookId)
|
|
277
|
+
},
|
|
278
|
+
permissions: { user: isAuthenticated },
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
export const createBook = pikkuFunc({
|
|
282
|
+
title: 'Create Book',
|
|
283
|
+
func: async ({ db }, { title, author }) => {
|
|
284
|
+
return await db.createBook({ title, author })
|
|
285
|
+
},
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
export const deleteBook = pikkuFunc({
|
|
289
|
+
title: 'Delete Book',
|
|
290
|
+
func: async ({ db }, { bookId }) => {
|
|
291
|
+
await db.deleteBook(bookId)
|
|
292
|
+
return { deleted: true }
|
|
293
|
+
},
|
|
294
|
+
})
|
|
295
|
+
|
|
296
|
+
// wirings/books.http.ts
|
|
297
|
+
import { defineHTTPRoutes, wireHTTPRoutes } from '.pikku/pikku-types.gen.js'
|
|
298
|
+
import { addHTTPMiddleware } from '@pikku/core/http'
|
|
299
|
+
import { cors, authBearer } from '@pikku/core/middleware'
|
|
300
|
+
|
|
301
|
+
const booksRoutes = defineHTTPRoutes({
|
|
302
|
+
tags: ['books'],
|
|
303
|
+
routes: {
|
|
304
|
+
list: { method: 'get', route: '/books', func: listBooks, auth: false },
|
|
305
|
+
get: { method: 'get', route: '/books/:bookId', func: getBook },
|
|
306
|
+
create: { method: 'post', route: '/books', func: createBook },
|
|
307
|
+
delete: { method: 'delete', route: '/books/:bookId', func: deleteBook },
|
|
308
|
+
},
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
wireHTTPRoutes({
|
|
312
|
+
basePath: '/api',
|
|
313
|
+
routes: { books: booksRoutes },
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
addHTTPMiddleware('*', [cors(), authBearer()])
|
|
317
|
+
```
|