@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,528 @@
|
|
|
1
|
+
# Concept Mapping: Generic Backend → Pikku
|
|
2
|
+
|
|
3
|
+
Side-by-side code examples showing how common backend patterns translate to Pikku.
|
|
4
|
+
|
|
5
|
+
## Route Handler / Controller → pikkuFunc
|
|
6
|
+
|
|
7
|
+
**Traditional (generic):**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// A controller method tied to HTTP
|
|
11
|
+
class TodoController {
|
|
12
|
+
async create(req: Request, res: Response) {
|
|
13
|
+
const { title, priority } = req.body
|
|
14
|
+
const todo = await this.todoService.create(title, priority)
|
|
15
|
+
res.json({ todo })
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
// Route: router.post('/todos', controller.create)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Pikku:**
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// Function knows nothing about HTTP
|
|
25
|
+
const createTodo = pikkuSessionlessFunc<CreateTodoInput, TodoOutput>(
|
|
26
|
+
async ({ todoStore, logger }, { title, priority }) => {
|
|
27
|
+
const todo = todoStore.createTodo(title, priority)
|
|
28
|
+
logger.info(`Created todo: ${todo.id}`)
|
|
29
|
+
return { todo }
|
|
30
|
+
}
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
// Wiring (separate file) - grouped with defineHTTPRoutes
|
|
34
|
+
export const todoRoutes = defineHTTPRoutes({
|
|
35
|
+
basePath: '/todos',
|
|
36
|
+
tags: ['todos'],
|
|
37
|
+
auth: false,
|
|
38
|
+
routes: {
|
|
39
|
+
create: { method: 'post', route: '', func: createTodo },
|
|
40
|
+
list: { method: 'get', route: '', func: listTodos },
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// Compose into top-level API
|
|
45
|
+
wireHTTPRoutes({
|
|
46
|
+
basePath: '/api',
|
|
47
|
+
routes: { todos: todoRoutes },
|
|
48
|
+
})
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Key difference:** The function receives `{ title, priority }` as typed data - it doesn't know if it came from HTTP body, WebSocket message, or CLI args. Routes are grouped with `defineHTTPRoutes` (like a controller) and composed with `wireHTTPRoutes`.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Route Parameters → Merged into Data
|
|
56
|
+
|
|
57
|
+
**Traditional:**
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
// Must extract from req.params, req.query, req.body separately
|
|
61
|
+
async getUser(req: Request, res: Response) {
|
|
62
|
+
const id = req.params.id // from URL
|
|
63
|
+
const fields = req.query.fields // from query string
|
|
64
|
+
const updates = req.body // from body
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Pikku:**
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// All sources merged into a single typed `data` object
|
|
72
|
+
const getUser = pikkuSessionlessFunc<
|
|
73
|
+
{ id: string; fields?: string },
|
|
74
|
+
UserOutput
|
|
75
|
+
>(async (services, { id, fields }) => {
|
|
76
|
+
// id comes from route param, fields from query - function doesn't care
|
|
77
|
+
return { user: await services.db.getUser(id, fields) }
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
wireHTTP({ method: 'get', route: '/users/:id', func: getUser, auth: false })
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Pikku merges route params + query string + body + headers into a single typed input.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Middleware → pikkuMiddleware
|
|
88
|
+
|
|
89
|
+
**Traditional:**
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
// Express-style middleware
|
|
93
|
+
function logRequest(req: Request, res: Response, next: NextFunction) {
|
|
94
|
+
console.log(`${req.method} ${req.url}`)
|
|
95
|
+
next()
|
|
96
|
+
console.log(`Response: ${res.statusCode}`)
|
|
97
|
+
}
|
|
98
|
+
app.use(logRequest)
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Pikku:**
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
const logRequest = pikkuMiddleware(async ({ logger }, wire, next) => {
|
|
105
|
+
logger.info('Request started')
|
|
106
|
+
await next()
|
|
107
|
+
logger.info('Request completed')
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
// Apply globally
|
|
111
|
+
addHTTPMiddleware('*', [logRequest])
|
|
112
|
+
|
|
113
|
+
// Apply by route pattern
|
|
114
|
+
addHTTPMiddleware('/api/*', [logRequest])
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Key difference:** Pikku middleware receives services (injected), not raw req/res.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Auth Guard → Built-in Auth Middleware
|
|
122
|
+
|
|
123
|
+
**Traditional:**
|
|
124
|
+
|
|
125
|
+
```typescript
|
|
126
|
+
// Custom auth middleware
|
|
127
|
+
function authMiddleware(req, res, next) {
|
|
128
|
+
const token = req.headers.authorization?.replace('Bearer ', '')
|
|
129
|
+
if (!token) return res.status(401).json({ error: 'Unauthorized' })
|
|
130
|
+
try {
|
|
131
|
+
req.user = jwt.verify(token)
|
|
132
|
+
next()
|
|
133
|
+
} catch {
|
|
134
|
+
res.status(401).json({ error: 'Invalid token' })
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Pikku:**
|
|
140
|
+
|
|
141
|
+
```typescript
|
|
142
|
+
import { authBearer } from '@pikku/core/middleware'
|
|
143
|
+
|
|
144
|
+
// One line - handles token extraction, JWT verification, session population
|
|
145
|
+
addHTTPMiddleware('*', [authBearer({})])
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Other built-in options: `authCookie({ cookieName })`, `authApiKey({ header })`.
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## Authorization / Role Checks → pikkuPermission
|
|
153
|
+
|
|
154
|
+
**Traditional:**
|
|
155
|
+
|
|
156
|
+
```typescript
|
|
157
|
+
// Guard or middleware that checks roles
|
|
158
|
+
function requireRole(role: string) {
|
|
159
|
+
return (req, res, next) => {
|
|
160
|
+
if (req.user.role !== role)
|
|
161
|
+
return res.status(403).json({ error: 'Forbidden' })
|
|
162
|
+
next()
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
router.delete('/users/:id', requireRole('admin'), deleteUser)
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
**Pikku:**
|
|
169
|
+
|
|
170
|
+
```typescript
|
|
171
|
+
const isAdmin = pikkuPermission(async (services, data, wire) => {
|
|
172
|
+
const session = await wire.session.get()
|
|
173
|
+
return session?.role === 'admin'
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
// Apply to route pattern
|
|
177
|
+
addHTTPPermission('/admin/*', { admin: [isAdmin] })
|
|
178
|
+
|
|
179
|
+
// Or inline on specific wiring
|
|
180
|
+
wireHTTP({
|
|
181
|
+
route: '/users/:id',
|
|
182
|
+
method: 'delete',
|
|
183
|
+
func: deleteUser,
|
|
184
|
+
permissions: { admin: [isAdmin] },
|
|
185
|
+
})
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
**Permission groups:** `{ groupA: [perm1, perm2], groupB: [perm3] }` means `(perm1 AND perm2) OR perm3`.
|
|
189
|
+
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## DTO / Request Validation → Standard Schema
|
|
193
|
+
|
|
194
|
+
**Traditional (class-validator):**
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
class CreateTodoDTO {
|
|
198
|
+
@IsString()
|
|
199
|
+
@IsNotEmpty()
|
|
200
|
+
@MaxLength(200)
|
|
201
|
+
title: string
|
|
202
|
+
|
|
203
|
+
@IsOptional()
|
|
204
|
+
@IsIn(['low', 'medium', 'high'])
|
|
205
|
+
priority?: string
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Pikku (Zod):**
|
|
210
|
+
|
|
211
|
+
```typescript
|
|
212
|
+
const CreateTodoInputSchema = z.object({
|
|
213
|
+
title: z.string().min(1).max(200),
|
|
214
|
+
priority: z.enum(['low', 'medium', 'high']).optional(),
|
|
215
|
+
})
|
|
216
|
+
|
|
217
|
+
// Schema declared on function - auto-validated before function runs
|
|
218
|
+
const createTodo = pikkuSessionlessFunc({
|
|
219
|
+
input: CreateTodoInputSchema,
|
|
220
|
+
output: TodoOutputSchema,
|
|
221
|
+
func: async (services, data) => { ... },
|
|
222
|
+
})
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Also supports Valibot, ArkType, or any Standard Schema-compatible library.
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## Dependency Injection → Service Factories
|
|
230
|
+
|
|
231
|
+
**Traditional (class-based DI):**
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
@Injectable()
|
|
235
|
+
class TodoService {
|
|
236
|
+
constructor(
|
|
237
|
+
@Inject('DATABASE') private db: Database,
|
|
238
|
+
private logger: Logger
|
|
239
|
+
) {}
|
|
240
|
+
|
|
241
|
+
async create(title: string) {
|
|
242
|
+
this.logger.info('Creating todo')
|
|
243
|
+
return this.db.insert('todos', { title })
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
**Pikku:**
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
// Define services once at startup
|
|
252
|
+
const createSingletonServices = pikkuServices(async (config) => ({
|
|
253
|
+
logger: new ConsoleLogger(),
|
|
254
|
+
db: new KyselyService(config.database),
|
|
255
|
+
todoStore: new TodoStore(),
|
|
256
|
+
}))
|
|
257
|
+
|
|
258
|
+
// Functions destructure what they need
|
|
259
|
+
const createTodo = pikkuSessionlessFunc(
|
|
260
|
+
async ({ logger, todoStore }, { title }) => {
|
|
261
|
+
logger.info('Creating todo')
|
|
262
|
+
return { todo: todoStore.createTodo(title) }
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Key difference:** No container, no decorators, no class hierarchy. Just a factory function returning an object.
|
|
268
|
+
|
|
269
|
+
Per-request services (like scoped loggers) use `pikkuWireServices`:
|
|
270
|
+
|
|
271
|
+
```typescript
|
|
272
|
+
const createWireServices = pikkuWireServices(
|
|
273
|
+
async (singletonServices, wire) => ({
|
|
274
|
+
scopedLogger: new ScopedLogger(wire.session?.initial?.userId),
|
|
275
|
+
})
|
|
276
|
+
)
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
---
|
|
280
|
+
|
|
281
|
+
## WebSocket Handlers → wireChannel
|
|
282
|
+
|
|
283
|
+
**Traditional:**
|
|
284
|
+
|
|
285
|
+
```typescript
|
|
286
|
+
wss.on('connection', (ws) => {
|
|
287
|
+
ws.on('message', (raw) => {
|
|
288
|
+
const { type, payload } = JSON.parse(raw)
|
|
289
|
+
switch (type) {
|
|
290
|
+
case 'subscribe':
|
|
291
|
+
handleSubscribe(ws, payload)
|
|
292
|
+
break
|
|
293
|
+
case 'create':
|
|
294
|
+
handleCreate(ws, payload)
|
|
295
|
+
break
|
|
296
|
+
}
|
|
297
|
+
})
|
|
298
|
+
ws.on('close', () => handleDisconnect(ws))
|
|
299
|
+
})
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
**Pikku:**
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
wireChannel({
|
|
306
|
+
name: 'todos-live',
|
|
307
|
+
route: '/',
|
|
308
|
+
onConnect, // pikkuVoidFunc
|
|
309
|
+
onDisconnect, // pikkuVoidFunc
|
|
310
|
+
onMessageWiring: {
|
|
311
|
+
action: {
|
|
312
|
+
// First level of message routing
|
|
313
|
+
subscribe: { func: subscribe },
|
|
314
|
+
create: { func: createTodo },
|
|
315
|
+
auth: { func: login, auth: false },
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
})
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Functions send data back via `wire.channel.send(data)`. Structured message routing replaces manual switch/case parsing.
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
## Job Queue Workers → wireQueueWorker
|
|
326
|
+
|
|
327
|
+
**Traditional (Bull/BullMQ):**
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
const queue = new Queue('reminders')
|
|
331
|
+
|
|
332
|
+
// Producer
|
|
333
|
+
await queue.add('send-reminder', { todoId: '123', userId: 'user1' })
|
|
334
|
+
|
|
335
|
+
// Consumer
|
|
336
|
+
const worker = new Worker('reminders', async (job) => {
|
|
337
|
+
const { todoId, userId } = job.data
|
|
338
|
+
await sendReminder(todoId, userId)
|
|
339
|
+
})
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Pikku:**
|
|
343
|
+
|
|
344
|
+
```typescript
|
|
345
|
+
// Same pikkuFunc shape - knows nothing about queues
|
|
346
|
+
const processReminder = pikkuSessionlessFunc(
|
|
347
|
+
async ({ todoStore, logger }, { todoId, userId }) => {
|
|
348
|
+
const todo = todoStore.getTodo(todoId)
|
|
349
|
+
if (todo && !todo.completed) {
|
|
350
|
+
logger.info(`Sending reminder for: ${todo.title}`)
|
|
351
|
+
}
|
|
352
|
+
return { processed: true }
|
|
353
|
+
}
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
// Wire it to a queue
|
|
357
|
+
wireQueueWorker({ name: 'todo-reminders', func: processReminder })
|
|
358
|
+
|
|
359
|
+
// Enqueue from other functions via queue service
|
|
360
|
+
await services.queueService.addJob('todo-reminders', {
|
|
361
|
+
todoId: '123',
|
|
362
|
+
userId: 'user1',
|
|
363
|
+
})
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
---
|
|
367
|
+
|
|
368
|
+
## Cron / Scheduled Tasks → wireScheduler
|
|
369
|
+
|
|
370
|
+
**Traditional:**
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
import cron from 'node-cron'
|
|
374
|
+
cron.schedule('0 9 * * *', async () => {
|
|
375
|
+
const stats = await todoService.getStats()
|
|
376
|
+
console.log(`Daily: ${stats.completed}/${stats.total}`)
|
|
377
|
+
})
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
**Pikku:**
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
const dailySummary = pikkuVoidFunc(async ({ logger, todoStore }) => {
|
|
384
|
+
const stats = todoStore.getStats('user1')
|
|
385
|
+
logger.info(`Daily: ${stats.completed}/${stats.total}`)
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
wireScheduler({
|
|
389
|
+
name: 'dailySummary',
|
|
390
|
+
schedule: '0 9 * * *',
|
|
391
|
+
func: dailySummary,
|
|
392
|
+
})
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## Module / Feature Grouping → Tags + File Organization
|
|
398
|
+
|
|
399
|
+
**Traditional (NestJS):**
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
@Module({
|
|
403
|
+
imports: [DatabaseModule],
|
|
404
|
+
controllers: [TodoController],
|
|
405
|
+
providers: [TodoService],
|
|
406
|
+
exports: [TodoService],
|
|
407
|
+
})
|
|
408
|
+
export class TodoModule {}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
**Pikku:**
|
|
412
|
+
|
|
413
|
+
```text
|
|
414
|
+
// No module system. Organize by convention:
|
|
415
|
+
src/
|
|
416
|
+
├── functions/
|
|
417
|
+
│ └── todos.functions.ts # All todo business logic
|
|
418
|
+
├── wirings/
|
|
419
|
+
│ └── todos.http.ts # All todo HTTP routes
|
|
420
|
+
└── schemas.ts # Shared schemas
|
|
421
|
+
|
|
422
|
+
// Use tags for cross-cutting concerns:
|
|
423
|
+
wireHTTP({ route: '/todos', func: listTodos, tags: ['todos', 'public'] })
|
|
424
|
+
addMiddleware('todos', [loggingMiddleware]) // Applies to all 'todos'-tagged functions
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
---
|
|
428
|
+
|
|
429
|
+
## Error Handling → Typed Errors
|
|
430
|
+
|
|
431
|
+
**Traditional:**
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
if (!todo) {
|
|
435
|
+
res.status(404).json({ error: 'Todo not found' })
|
|
436
|
+
return
|
|
437
|
+
}
|
|
438
|
+
if (!canEdit(user, todo)) {
|
|
439
|
+
res.status(403).json({ error: 'Forbidden' })
|
|
440
|
+
return
|
|
441
|
+
}
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
**Pikku:**
|
|
445
|
+
|
|
446
|
+
```typescript
|
|
447
|
+
import { NotFoundError, ForbiddenError } from '@pikku/core/errors'
|
|
448
|
+
|
|
449
|
+
const updateTodo = pikkuFunc(async (services, { id, title }, wire) => {
|
|
450
|
+
const todo = services.todoStore.getTodo(id)
|
|
451
|
+
if (!todo) throw new NotFoundError('Todo not found')
|
|
452
|
+
|
|
453
|
+
const session = await wire.session.get()
|
|
454
|
+
if (todo.userId !== session.userId) throw new ForbiddenError()
|
|
455
|
+
|
|
456
|
+
return { todo: services.todoStore.update(id, { title }) }
|
|
457
|
+
})
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
Pikku catches these errors and maps them to appropriate HTTP status codes automatically.
|
|
461
|
+
|
|
462
|
+
---
|
|
463
|
+
|
|
464
|
+
## Session Management
|
|
465
|
+
|
|
466
|
+
**Traditional:**
|
|
467
|
+
|
|
468
|
+
```typescript
|
|
469
|
+
// Express session
|
|
470
|
+
app.use(session({ store: new RedisStore({ client: redis }), secret: 'key' }))
|
|
471
|
+
|
|
472
|
+
// In handler
|
|
473
|
+
req.session.userId = user.id // Set
|
|
474
|
+
const userId = req.session.userId // Get
|
|
475
|
+
req.session.destroy() // Clear
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
**Pikku:**
|
|
479
|
+
|
|
480
|
+
```typescript
|
|
481
|
+
// Session is on the wire context, managed by auth middleware
|
|
482
|
+
const login = pikkuSessionlessFunc(
|
|
483
|
+
async ({ jwt }, { username, password }, wire) => {
|
|
484
|
+
const user = authenticate(username, password)
|
|
485
|
+
const token = await jwt.sign({ userId: user.id })
|
|
486
|
+
await wire.session.set({ userId: user.id, user }) // Set
|
|
487
|
+
return { token, user }
|
|
488
|
+
}
|
|
489
|
+
)
|
|
490
|
+
|
|
491
|
+
const getMe = pikkuFunc(async (services, data, wire) => {
|
|
492
|
+
const session = await wire.session.get() // Get
|
|
493
|
+
return { user: session.user }
|
|
494
|
+
})
|
|
495
|
+
|
|
496
|
+
const logout = pikkuFunc(async (services, data, wire) => {
|
|
497
|
+
await wire.session.clear() // Clear
|
|
498
|
+
return { success: true }
|
|
499
|
+
})
|
|
500
|
+
```
|
|
501
|
+
|
|
502
|
+
---
|
|
503
|
+
|
|
504
|
+
## API Client Generation
|
|
505
|
+
|
|
506
|
+
**Traditional:**
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
// Manually written or generated via OpenAPI
|
|
510
|
+
const response = await fetch('/api/todos', {
|
|
511
|
+
method: 'POST',
|
|
512
|
+
headers: { 'Content-Type': 'application/json' },
|
|
513
|
+
body: JSON.stringify({ title: 'New todo' }),
|
|
514
|
+
})
|
|
515
|
+
const data: unknown = await response.json()
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
**Pikku (auto-generated, fully typed):**
|
|
519
|
+
|
|
520
|
+
```typescript
|
|
521
|
+
import { createPikkuFetchClient } from './.pikku/pikku-fetch.gen.js'
|
|
522
|
+
|
|
523
|
+
const client = createPikkuFetchClient({ baseUrl: 'http://localhost:4002' })
|
|
524
|
+
const result = await client.post('/todos', { title: 'New todo' })
|
|
525
|
+
// result is fully typed as TodoOutput - no manual type casting
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Generated by running `npx pikku prebuild`. Both HTTP and WebSocket clients available.
|