@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,77 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-pino
|
|
3
|
+
description: 'Use when setting up structured logging with Pino in a Pikku app. Covers PinoLogger setup and log levels.
|
|
4
|
+
TRIGGER when: code uses PinoLogger, user asks about structured logging, Pino, or @pikku/pino.
|
|
5
|
+
DO NOT TRIGGER when: user asks about ConsoleLogger (use pikku-services) or general service setup.'
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pikku Pino (Structured Logging)
|
|
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/pino` provides structured JSON logging via [Pino](https://getpino.io/). Implements the `Logger` interface from `@pikku/core`.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
yarn add @pikku/pino
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## API Reference
|
|
29
|
+
|
|
30
|
+
### `PinoLogger`
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { PinoLogger } from '@pikku/pino'
|
|
34
|
+
|
|
35
|
+
const logger = new PinoLogger()
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
No constructor parameters. Creates a Pino logger instance.
|
|
39
|
+
|
|
40
|
+
**Properties:**
|
|
41
|
+
|
|
42
|
+
- `pino: pino.Logger` — Access the underlying Pino instance for advanced config.
|
|
43
|
+
|
|
44
|
+
**Methods:**
|
|
45
|
+
|
|
46
|
+
- `setLevel(level: LogLevel): void` — Set minimum log level.
|
|
47
|
+
- `info(messageOrObj: string | Record<string, any> | Error): void`
|
|
48
|
+
- `warn(messageOrObj: string | Record<string, any> | Error): void`
|
|
49
|
+
- `error(messageOrObj: string | Record<string, any> | Error): void`
|
|
50
|
+
- `debug(messageOrObj: string | Record<string, any>): void`
|
|
51
|
+
|
|
52
|
+
## Usage Patterns
|
|
53
|
+
|
|
54
|
+
### Basic Setup
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { PinoLogger } from '@pikku/pino'
|
|
58
|
+
|
|
59
|
+
const logger = new PinoLogger()
|
|
60
|
+
logger.setLevel('debug')
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### With Pikku Services
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const createSingletonServices = pikkuServices(async (config) => {
|
|
67
|
+
const logger = new PinoLogger()
|
|
68
|
+
return { config, logger }
|
|
69
|
+
})
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Accessing Underlying Pino
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
const logger = new PinoLogger()
|
|
76
|
+
logger.pino.child({ module: 'auth' }).info('Token verified')
|
|
77
|
+
```
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-queue
|
|
3
|
+
description: 'Use when adding background job processing, async task queues, or distributed workers to a Pikku app. Covers wireQueueWorker, job enqueuing, progress tracking, retries, BullMQ and PgBoss adapters.
|
|
4
|
+
TRIGGER when: code uses wireQueueWorker, user asks about background jobs, task queues, async processing, BullMQ, PgBoss, or job retries.
|
|
5
|
+
DO NOT TRIGGER when: user asks about scheduled cron tasks (use pikku-cron) or event-driven triggers (use pikku-trigger).'
|
|
6
|
+
installGroups: [core]
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Pikku Queue 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 as background queue workers. Supports job control (progress, retry, discard), configurable concurrency, and type-safe job publishing.
|
|
22
|
+
|
|
23
|
+
## Before You Start
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pikku info functions --verbose # See existing functions and their types
|
|
27
|
+
pikku info tags --verbose # Understand project organization
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
See `pikku-concepts` for the core mental model.
|
|
31
|
+
|
|
32
|
+
## API Reference
|
|
33
|
+
|
|
34
|
+
### `wireQueueWorker(config)`
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { wireQueueWorker } from '@pikku/core/queue'
|
|
38
|
+
|
|
39
|
+
wireQueueWorker({
|
|
40
|
+
name: string, // Queue name (unique identifier)
|
|
41
|
+
func: PikkuFunc, // Worker function
|
|
42
|
+
config?: {
|
|
43
|
+
batchSize?: number, // Process N jobs at once
|
|
44
|
+
removeOnComplete?: number | boolean, // Clean up completed jobs
|
|
45
|
+
},
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Wire Object (`wire.queue`)
|
|
50
|
+
|
|
51
|
+
Inside queue worker functions:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
wire.queue.updateProgress(percent: number) // Report progress (0-100)
|
|
55
|
+
wire.queue.discard(reason: string) // Silently discard job
|
|
56
|
+
wire.queue.fail(reason: string) // Mark job as failed
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Job Publishing
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const jobId = await queue.add(queueName, data, options?)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Options:
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
{
|
|
69
|
+
priority?: number, // Higher = processed first
|
|
70
|
+
delay?: number, // Delay in ms before processing
|
|
71
|
+
attempts?: number, // Max retry attempts
|
|
72
|
+
backoff?: {
|
|
73
|
+
type: 'exponential' | 'fixed',
|
|
74
|
+
delay: number, // Base delay in ms
|
|
75
|
+
},
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Usage Patterns
|
|
80
|
+
|
|
81
|
+
### Basic Queue Worker
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const processReminder = pikkuSessionlessFunc({
|
|
85
|
+
title: 'Process Reminder',
|
|
86
|
+
func: async ({ db, emailService }, { todoId, userId }) => {
|
|
87
|
+
const todo = await db.getTodo(todoId)
|
|
88
|
+
await emailService.sendReminder(userId, todo)
|
|
89
|
+
return { sent: true }
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
wireQueueWorker({
|
|
94
|
+
name: 'todo-reminders',
|
|
95
|
+
func: processReminder,
|
|
96
|
+
})
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Job Control (Progress, Discard, Fail)
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const processReminder = pikkuSessionlessFunc({
|
|
103
|
+
title: 'Process Reminder',
|
|
104
|
+
func: async ({ db }, { todoId }, wire) => {
|
|
105
|
+
await wire.queue.updateProgress(25)
|
|
106
|
+
|
|
107
|
+
const todo = await db.getTodo(todoId)
|
|
108
|
+
if (!todo) {
|
|
109
|
+
await wire.queue.discard('Todo not found')
|
|
110
|
+
return
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (todo.completed) {
|
|
114
|
+
await wire.queue.fail('Todo already completed')
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await wire.queue.updateProgress(100)
|
|
119
|
+
return { sent: true }
|
|
120
|
+
},
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Retries & Configuration
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
wireQueueWorker({
|
|
128
|
+
name: 'todo-reminders',
|
|
129
|
+
func: processReminder,
|
|
130
|
+
config: {
|
|
131
|
+
batchSize: 5,
|
|
132
|
+
removeOnComplete: 100,
|
|
133
|
+
},
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
// Enqueue with retry options
|
|
137
|
+
const jobId = await queue.add(
|
|
138
|
+
'todo-reminders',
|
|
139
|
+
{
|
|
140
|
+
todoId: 'abc-123',
|
|
141
|
+
userId: 'user-456',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
priority: 10,
|
|
145
|
+
delay: 5000,
|
|
146
|
+
attempts: 3,
|
|
147
|
+
backoff: { type: 'exponential', delay: 1000 },
|
|
148
|
+
}
|
|
149
|
+
)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Type-Safe Queue Publishing
|
|
153
|
+
|
|
154
|
+
After `npx pikku prebuild`:
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
import { PikkuQueue } from '.pikku/pikku-queue.gen.js'
|
|
158
|
+
|
|
159
|
+
const queue = new PikkuQueue(queueService)
|
|
160
|
+
|
|
161
|
+
const jobId = await queue.add('todo-reminders', {
|
|
162
|
+
todoId: 'abc-123',
|
|
163
|
+
userId: 'user-456',
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
const job = await queue.getJob('todo-reminders', jobId)
|
|
167
|
+
const status = await job.status() // 'waiting' | 'active' | 'completed' | 'failed'
|
|
168
|
+
const result = await job.waitForCompletion(30_000)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Queue Adapters
|
|
172
|
+
|
|
173
|
+
**BullMQ** (Redis-based):
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { BullMQQueueService } from '@pikku/queue-bullmq'
|
|
177
|
+
|
|
178
|
+
const queueService = new BullMQQueueService({
|
|
179
|
+
connection: { host: 'localhost', port: 6379 },
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
**PgBoss** (PostgreSQL-based):
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import { PgBossQueueService } from '@pikku/queue-pg-boss'
|
|
187
|
+
|
|
188
|
+
const queueService = new PgBossQueueService({
|
|
189
|
+
connectionString: 'postgres://...',
|
|
190
|
+
})
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Complete Example
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
// functions/email.functions.ts
|
|
197
|
+
export const sendWelcomeEmail = pikkuSessionlessFunc({
|
|
198
|
+
title: 'Send Welcome Email',
|
|
199
|
+
func: async ({ emailService, db }, { userId }, wire) => {
|
|
200
|
+
await wire.queue.updateProgress(10)
|
|
201
|
+
|
|
202
|
+
const user = await db.getUser(userId)
|
|
203
|
+
if (!user) {
|
|
204
|
+
await wire.queue.discard('User not found')
|
|
205
|
+
return
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
await wire.queue.updateProgress(50)
|
|
209
|
+
await emailService.send({
|
|
210
|
+
to: user.email,
|
|
211
|
+
subject: 'Welcome!',
|
|
212
|
+
template: 'welcome',
|
|
213
|
+
data: { name: user.name },
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
await wire.queue.updateProgress(100)
|
|
217
|
+
return { sent: true, email: user.email }
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
// wirings/queue.wiring.ts
|
|
222
|
+
wireQueueWorker({
|
|
223
|
+
name: 'welcome-emails',
|
|
224
|
+
func: sendWelcomeEmail,
|
|
225
|
+
config: { removeOnComplete: 100 },
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
// Enqueue from another function
|
|
229
|
+
export const registerUser = pikkuSessionlessFunc({
|
|
230
|
+
title: 'Register User',
|
|
231
|
+
func: async ({ db, queue }, { email, name }) => {
|
|
232
|
+
const user = await db.createUser({ email, name })
|
|
233
|
+
await queue.add('welcome-emails', { userId: user.id })
|
|
234
|
+
return { user }
|
|
235
|
+
},
|
|
236
|
+
})
|
|
237
|
+
```
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-react
|
|
3
|
+
description: 'Set up @pikku/react in a React app: PikkuProvider context, createPikku factory, and the usePikkuRPC / usePikkuFetch hooks for direct (non-React-Query) calls. TRIGGER when: the user is bootstrapping a React frontend that talks to a Pikku backend, asks how to wire `PikkuProvider`, or needs to make one-off RPC calls outside of useQuery/useMutation. DO NOT TRIGGER when: the user is asking about useQuery/useMutation hooks (use pikku-react-query) or about workflows (use pikku-workflows-client).'
|
|
4
|
+
installGroups: [core]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pikku React
|
|
8
|
+
|
|
9
|
+
## Agent Operating Procedure
|
|
10
|
+
|
|
11
|
+
Use this skill as an execution checklist, not reference material.
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
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.
|
|
15
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
16
|
+
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.
|
|
17
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
18
|
+
|
|
19
|
+
`@pikku/react` is the smallest possible binding: a Context provider plus
|
|
20
|
+
two hooks. It does **not** depend on React Query — that's a separate
|
|
21
|
+
opt-in via the generated `api.gen.ts`. Use this skill when setting up the
|
|
22
|
+
provider or making direct RPC calls.
|
|
23
|
+
|
|
24
|
+
## What ships
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
import {
|
|
28
|
+
PikkuProvider,
|
|
29
|
+
createPikku,
|
|
30
|
+
usePikkuFetch,
|
|
31
|
+
usePikkuRPC,
|
|
32
|
+
usePikkuRealtime,
|
|
33
|
+
} from '@pikku/react'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Five exports. `usePikkuRealtime` is only valid when you wired a
|
|
37
|
+
`PikkuRealtime` class via `createPikku` — see step 3 below.
|
|
38
|
+
|
|
39
|
+
## Setup at the app root
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import { createPikku, PikkuProvider } from '@pikku/react'
|
|
43
|
+
import { PikkuFetch } from './pikku/pikku-fetch.gen'
|
|
44
|
+
import { PikkuRPC } from './pikku/pikku-rpc.gen'
|
|
45
|
+
|
|
46
|
+
const pikku = createPikku(PikkuFetch, PikkuRPC, {
|
|
47
|
+
serverUrl: import.meta.env.VITE_API_URL ?? 'http://localhost:3000',
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
createRoot(document.getElementById('root')!).render(
|
|
51
|
+
<PikkuProvider pikku={pikku}>
|
|
52
|
+
<App />
|
|
53
|
+
</PikkuProvider>
|
|
54
|
+
)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
If the project also exposes realtime events (see **pikku-realtime**), pass
|
|
58
|
+
the `PikkuRealtime` class as the third argument and the instance gets a
|
|
59
|
+
`realtime` field too:
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { PikkuRealtime } from './pikku/realtime.gen'
|
|
63
|
+
|
|
64
|
+
const pikku = createPikku(PikkuFetch, PikkuRPC, PikkuRealtime, {
|
|
65
|
+
serverUrl: import.meta.env.VITE_API_URL ?? 'http://localhost:3000',
|
|
66
|
+
})
|
|
67
|
+
// pikku.fetch / pikku.rpc / pikku.realtime — all share the same fetch
|
|
68
|
+
// (server URL + auth configured once).
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The generated classes come from your `pikku.config.json`:
|
|
72
|
+
|
|
73
|
+
| config field | generated file |
|
|
74
|
+
| ---------------------------- | ----------------------------------------------------- |
|
|
75
|
+
| `clientFiles.fetchFile` | typed HTTP client (`PikkuFetch` class) |
|
|
76
|
+
| `clientFiles.rpcWiringsFile` | RPC client (`PikkuRPC` class) calling all exposed fns |
|
|
77
|
+
| `clientFiles.realtimeFile` | `PikkuRealtime` (websocket events + SSE + channels) |
|
|
78
|
+
|
|
79
|
+
If a file isn't being generated, that field is missing from the config —
|
|
80
|
+
add it and re-run `pikku all`.
|
|
81
|
+
|
|
82
|
+
`createPikku(...)` accepts the same `CorePikkuFetchOptions` as `PikkuFetch`
|
|
83
|
+
plus `serverUrl`. Auth headers, request interceptors, etc. are configured
|
|
84
|
+
on the fetch instance — RPC and realtime inherit them automatically.
|
|
85
|
+
|
|
86
|
+
## Calling an RPC directly (no React Query)
|
|
87
|
+
|
|
88
|
+
Inside a component:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { usePikkuRPC } from '@pikku/react'
|
|
92
|
+
|
|
93
|
+
function Logout() {
|
|
94
|
+
const rpc = usePikkuRPC()
|
|
95
|
+
return <button onClick={() => rpc.invoke('logoutUser', {})}>Sign out</button>
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`rpc.invoke(name, data)` is typed against `FlattenedRPCMap` — `name` must
|
|
100
|
+
be an exposed function id, `data` matches the input schema, return value
|
|
101
|
+
matches the output schema.
|
|
102
|
+
|
|
103
|
+
You also have `rpc.<funcName>(data)` if the generated RPC client builds
|
|
104
|
+
direct methods (project-dependent).
|
|
105
|
+
|
|
106
|
+
## Calling fetch directly
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
const fetch = usePikkuFetch()
|
|
110
|
+
const data = await fetch.get('/some-rest-route', { searchParams: {...} })
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Use this only when the function is wired via HTTP (REST shape) and you
|
|
114
|
+
need a path-style call. For RPC calls, `usePikkuRPC()` is cleaner.
|
|
115
|
+
|
|
116
|
+
## Realtime subscriptions
|
|
117
|
+
|
|
118
|
+
If you wired a `PikkuRealtime` class into `createPikku`, use
|
|
119
|
+
`usePikkuRealtime()` to grab the shared instance:
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
import { usePikkuRealtime } from '@pikku/react'
|
|
123
|
+
import type { PikkuRealtime } from './pikku/realtime.gen'
|
|
124
|
+
|
|
125
|
+
function TodoList() {
|
|
126
|
+
const realtime = usePikkuRealtime<PikkuRealtime>()
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
return realtime.subscribe('todo-created', ({ todo }) => {
|
|
129
|
+
/* ... */
|
|
130
|
+
})
|
|
131
|
+
}, [realtime])
|
|
132
|
+
// ...
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The hook throws if no `PikkuRealtime` was wired — that's how you know to
|
|
137
|
+
add it to `createPikku(...)`. Full event-hub setup, publishing, and SSE
|
|
138
|
+
helpers live in **pikku-realtime**.
|
|
139
|
+
|
|
140
|
+
## When to reach for what
|
|
141
|
+
|
|
142
|
+
| Need | Use |
|
|
143
|
+
| ----------------------------------- | --------------------------------------------- |
|
|
144
|
+
| Render data, dedupe + cache | **usePikkuQuery** (react-query) |
|
|
145
|
+
| Trigger a write, wait for result | **usePikkuMutation** (react-query) |
|
|
146
|
+
| Paginate | **usePikkuInfiniteQuery** (react-query) |
|
|
147
|
+
| One-off call from an event handler | `usePikkuRPC()` direct |
|
|
148
|
+
| Hit a REST endpoint (not RPC) | `usePikkuFetch()` |
|
|
149
|
+
| Run a workflow | **pikku-workflows-client** |
|
|
150
|
+
| Subscribe to events / SSE / channel | `usePikkuRealtime()` (see **pikku-realtime**) |
|
|
151
|
+
|
|
152
|
+
The first three live in your generated `api.gen.ts` (see the
|
|
153
|
+
**pikku-react-query** skill). This skill covers the bottom four rows.
|
|
154
|
+
|
|
155
|
+
## Authentication
|
|
156
|
+
|
|
157
|
+
Auth is handled at the `PikkuFetch` layer — pass options to `createPikku`
|
|
158
|
+
or set headers on the fetch instance after creation. Common pattern:
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
const pikku = createPikku(PikkuFetch, PikkuRPC, {
|
|
162
|
+
serverUrl: '...',
|
|
163
|
+
fetchOptions: {
|
|
164
|
+
onRequest: (req) => {
|
|
165
|
+
const token = localStorage.getItem('token')
|
|
166
|
+
if (token) req.headers.set('Authorization', `Bearer ${token}`)
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
})
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Exact option names depend on the `@pikku/fetch` version — read
|
|
173
|
+
`PikkuFetch`'s constructor type if unsure.
|
|
174
|
+
|
|
175
|
+
## What NOT to do
|
|
176
|
+
|
|
177
|
+
- Don't instantiate `PikkuFetch`/`PikkuRPC` inside a component — `createPikku`
|
|
178
|
+
goes once at the app root, the instance flows through Context.
|
|
179
|
+
- Don't call `usePikkuRPC()` outside a `<PikkuProvider>` — it throws.
|
|
180
|
+
- Don't write a custom RPC client. The generated one already covers every
|
|
181
|
+
exposed function with full types.
|
|
182
|
+
- Don't hardcode user-facing strings. Every display string goes through an
|
|
183
|
+
i18n token — see **pikku-i18n** for the setup (it's English-only by default).
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pikku-react-query
|
|
3
|
+
description: 'Use the Pikku auto-generated React Query hooks (`usePikkuQuery`, `usePikkuMutation`, `usePikkuInfiniteQuery`) to call backend RPC functions from a React frontend with full type safety. TRIGGER when: writing React components that need to call a Pikku function, fetch data, mutate data, or paginate; user mentions React Query, useQuery, useMutation, or building a frontend that talks to a Pikku backend. DO NOT TRIGGER when: working on the backend (use pikku-rpc / pikku-feature) or wiring a non-React frontend.'
|
|
4
|
+
installGroups: [core]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pikku React Query Hooks
|
|
8
|
+
|
|
9
|
+
## Agent Operating Procedure
|
|
10
|
+
|
|
11
|
+
Use this skill as an execution checklist, not reference material.
|
|
12
|
+
|
|
13
|
+
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.
|
|
14
|
+
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.
|
|
15
|
+
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
16
|
+
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.
|
|
17
|
+
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
18
|
+
|
|
19
|
+
Pikku generates a typed React Query layer from your backend `expose: true`
|
|
20
|
+
functions. You don''t write `useQuery`/`useMutation` against `fetch`
|
|
21
|
+
yourself — you call hooks named after RPCs and get full type inference for
|
|
22
|
+
input + output.
|
|
23
|
+
|
|
24
|
+
## Discover what's available on the client
|
|
25
|
+
|
|
26
|
+
Before writing a hook, get the full client surface in one call:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
yarn pikku meta clients --json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Returns RPCs, workflows, and channels with descriptions and type names:
|
|
33
|
+
|
|
34
|
+
```json
|
|
35
|
+
{
|
|
36
|
+
"rpcs": [
|
|
37
|
+
{ "name": "createTodo", "description": "Create a todo",
|
|
38
|
+
"readonly": false, "input": "CreateTodoInput", "output": "CreateTodoOutput" },
|
|
39
|
+
{ "name": "listTodos", "description": "List all todos",
|
|
40
|
+
"readonly": true, "input": null, "output": "ListTodosOutput" }
|
|
41
|
+
],
|
|
42
|
+
"workflows": [...],
|
|
43
|
+
"channels": [...]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The `name` is the RPC identifier; pass it to the hooks below. Input/output
|
|
48
|
+
shapes are inferred automatically — the hook is typed against
|
|
49
|
+
`FlattenedRPCMap[name]['input' | 'output']`. Use `description` to pick the
|
|
50
|
+
right RPC; use `readonly` to choose `usePikkuQuery` vs `usePikkuMutation`.
|
|
51
|
+
|
|
52
|
+
## Setup (once per app)
|
|
53
|
+
|
|
54
|
+
In your app entry (e.g. `main.tsx`):
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
58
|
+
import { PikkuProvider, createPikku } from '@pikku/react'
|
|
59
|
+
import { PikkuFetch } from './pikku/pikku-fetch.gen'
|
|
60
|
+
import { PikkuRPC } from './pikku/pikku-rpc.gen'
|
|
61
|
+
|
|
62
|
+
const queryClient = new QueryClient()
|
|
63
|
+
const pikku = createPikku(PikkuFetch, PikkuRPC, {
|
|
64
|
+
serverUrl: import.meta.env.VITE_API_URL ?? 'http://localhost:3000',
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
<QueryClientProvider client={queryClient}>
|
|
68
|
+
<PikkuProvider pikku={pikku}>
|
|
69
|
+
<App />
|
|
70
|
+
</PikkuProvider>
|
|
71
|
+
</QueryClientProvider>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
The two generated files come from `pikku.config.json`'s
|
|
75
|
+
`clientFiles.fetchFile` and `clientFiles.rpcWiringsFile`. Hooks live in
|
|
76
|
+
the file at `clientFiles.reactQueryFile` (typically `api.gen.ts`).
|
|
77
|
+
|
|
78
|
+
## The hooks
|
|
79
|
+
|
|
80
|
+
All hooks are imported from your generated `api.gen.ts`:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import {
|
|
84
|
+
usePikkuQuery,
|
|
85
|
+
usePikkuMutation,
|
|
86
|
+
usePikkuInfiniteQuery,
|
|
87
|
+
} from './pikku/api.gen'
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### `usePikkuQuery(name, data, options?)`
|
|
91
|
+
|
|
92
|
+
For RPCs that **read** data. Cacheable. The hook is typed against the RPC's
|
|
93
|
+
input + output.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
export function TodoList() {
|
|
97
|
+
const { data, isLoading, error } = usePikkuQuery('listTodos', {})
|
|
98
|
+
|
|
99
|
+
if (isLoading) return <p>Loading…</p>
|
|
100
|
+
if (error) return <p>{error.message}</p>
|
|
101
|
+
return (
|
|
102
|
+
<ul>
|
|
103
|
+
{data?.todos.map((t) => (
|
|
104
|
+
<li key={t.id}>{t.title}</li>
|
|
105
|
+
))}
|
|
106
|
+
</ul>
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
The query key is `[name, data]` automatically — no manual key wrangling.
|
|
112
|
+
Pass standard `useQuery` options through (`staleTime`, `enabled`, etc.).
|
|
113
|
+
|
|
114
|
+
### `usePikkuMutation(name, options?)`
|
|
115
|
+
|
|
116
|
+
For RPCs that **write**. Returns a React Query mutation object.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
export function CreateTodoForm() {
|
|
120
|
+
const queryClient = useQueryClient()
|
|
121
|
+
const mutation = usePikkuMutation('createTodo', {
|
|
122
|
+
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['listTodos'] }),
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
const onSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
|
126
|
+
e.preventDefault()
|
|
127
|
+
const title = (
|
|
128
|
+
e.currentTarget.elements.namedItem('title') as HTMLInputElement
|
|
129
|
+
).value
|
|
130
|
+
mutation.mutate({ title })
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<form onSubmit={onSubmit}>
|
|
135
|
+
<input name="title" />
|
|
136
|
+
<button type="submit" disabled={mutation.isPending}>
|
|
137
|
+
{mutation.isPending ? 'Adding…' : 'Add'}
|
|
138
|
+
</button>
|
|
139
|
+
</form>
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The input passed to `mutation.mutate(...)` is type-checked against the RPC's
|
|
145
|
+
input schema. After success, **invalidate** any list/get queries that should
|
|
146
|
+
refetch.
|
|
147
|
+
|
|
148
|
+
### `usePikkuInfiniteQuery(name, data, options?)`
|
|
149
|
+
|
|
150
|
+
Only available for RPCs whose output has a `nextCursor?: string | null`
|
|
151
|
+
field — typically a list endpoint with pagination. The hook auto-feeds
|
|
152
|
+
`nextCursor` into the next page's request.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
const { data, fetchNextPage, hasNextPage, isFetchingNextPage } =
|
|
156
|
+
usePikkuInfiniteQuery('listTodos', { limit: 20 })
|
|
157
|
+
|
|
158
|
+
const todos = data?.pages.flatMap((p) => p.rows) ?? []
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
If the hook isn't generated for an RPC, the RPC's output doesn't include
|
|
162
|
+
`nextCursor` — paginate it on the backend or use `usePikkuQuery` with
|
|
163
|
+
manual cursor state.
|
|
164
|
+
|
|
165
|
+
## Workflow hooks
|
|
166
|
+
|
|
167
|
+
When the project has workflows (`capabilities.workflow: true`), three
|
|
168
|
+
extra hooks are generated. See the **pikku-workflows-client** skill.
|
|
169
|
+
|
|
170
|
+
## Calling RPCs without React Query
|
|
171
|
+
|
|
172
|
+
For one-off calls (event handlers outside of state, side effects), use
|
|
173
|
+
`usePikkuRPC()` from `@pikku/react`:
|
|
174
|
+
|
|
175
|
+
```tsx
|
|
176
|
+
const rpc = usePikkuRPC()
|
|
177
|
+
const handleClick = async () => {
|
|
178
|
+
const result = await rpc.invoke('createTodo', { title: 'inline' })
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
But prefer the React Query hooks for anything that touches render state —
|
|
183
|
+
caching, retries, dedup, and dev-tools come for free.
|
|
184
|
+
|
|
185
|
+
## Common patterns
|
|
186
|
+
|
|
187
|
+
- **Optimistic updates**: pass `onMutate` to `usePikkuMutation` to update
|
|
188
|
+
the cache before the server responds. Standard React Query pattern;
|
|
189
|
+
Pikku doesn't add anything special.
|
|
190
|
+
- **Conditional fetching**: pass `enabled: !!someValue` to skip a query
|
|
191
|
+
until you have the input.
|
|
192
|
+
- **Refetch on focus**: enabled by default in React Query; disable with
|
|
193
|
+
`refetchOnWindowFocus: false` in options.
|
|
194
|
+
|
|
195
|
+
## What NOT to do
|
|
196
|
+
|
|
197
|
+
- Don't import the RPC client directly and call it inside `useEffect` —
|
|
198
|
+
use the hooks. They handle dedup, caching, and unmount safely.
|
|
199
|
+
- Don't hand-write `useQuery({ queryKey: ['listTodos'], queryFn: ... })`
|
|
200
|
+
— `usePikkuQuery('listTodos', {})` does it correctly with one line.
|
|
201
|
+
- Don't construct hook names dynamically. Hook names = RPC names known at
|
|
202
|
+
generation time.
|
|
203
|
+
- Don't bypass the type system with `as any` — if a hook's types don't
|
|
204
|
+
match what you expect, the backend's input/output schemas are wrong;
|
|
205
|
+
fix those first.
|