@pikku/cli 0.12.91 → 0.12.93
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/LICENSE +106 -0
- package/console-app/assets/{index-D0HG8q0B.css → index-BYj7ZbUU.css} +1 -1
- package/console-app/assets/{index-CpkvmAGb.js → index-CmAplHjZ.js} +151 -149
- package/console-app/index.html +2 -2
- package/dist/.pikku/agent/pikku-agent-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.d.ts +1 -1
- package/dist/.pikku/channel/pikku-channel-types.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-channel.js +16 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-client.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli-contracts-meta.gen.json +15 -0
- 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 +48 -0
- package/dist/.pikku/cli/pikku-cli-wirings.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli-wirings.gen.js +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.d.ts +1 -1
- package/dist/.pikku/cli/pikku-cli.gen.js +1 -1
- package/dist/.pikku/console/pikku-node-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.d.ts +1 -1
- package/dist/.pikku/function/pikku-function-types.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.js +1 -1
- package/dist/.pikku/function/pikku-functions-meta.gen.json +73 -40
- package/dist/.pikku/function/pikku-functions.gen.js +1 -3
- 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/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-scenarios.gen.d.ts +2 -1
- package/dist/.pikku/pikku-bootstrap-scenarios.gen.js +2 -1
- package/dist/.pikku/pikku-bootstrap.gen.d.ts +1 -1
- package/dist/.pikku/pikku-bootstrap.gen.js +1 -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 +1 -1
- 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.js +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.d.ts +1 -1
- package/dist/.pikku/queue/pikku-queue-workers-wirings.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.js +1 -1
- package/dist/.pikku/rpc/pikku-rpc-wirings-meta.internal.gen.json +3 -1
- package/dist/.pikku/scenarios/pikku-scenario-functions-meta.gen.js +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-functions.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-wirings-meta.gen.js +1 -1
- package/dist/.pikku/scenarios/pikku-scenario-wirings.gen.d.ts +1 -1
- package/dist/.pikku/scenarios/schemas/register.gen.d.ts +4 -0
- package/dist/.pikku/scenarios/schemas/register.gen.js +4 -0
- 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 +13 -3
- package/dist/.pikku/schemas/schemas/FabricSecretsListOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/FabricSecretsRotateInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsRotateOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/FabricSecretsSetOutput.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/KnowledgeIndexInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/KnowledgeIndexOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/KnowledgeValidateInput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/KnowledgeValidateOutput.schema.json +1 -0
- package/dist/.pikku/schemas/schemas/PikkuCLIConfig.schema.json +1 -1
- package/dist/.pikku/schemas/schemas/ScenarioRunInput.schema.json +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.d.ts +1 -1
- package/dist/.pikku/scopes/pikku-scope-types.gen.js +1 -1
- package/dist/.pikku/scopes/pikku-scopes.gen.d.ts +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 +2 -8
- package/dist/.pikku/workflow/pikku-scenario-actors.gen.d.ts +1 -1
- package/dist/.pikku/workflow/pikku-scenario-actors.gen.js +1 -1
- 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 +2 -2
- package/dist/src/cli.wiring.js +29 -0
- package/dist/src/deploy/analyzer/analyzer.js +22 -5
- package/dist/src/deploy/build-pipeline.js +5 -1
- package/dist/src/fabric/fabric-commands.d.ts +37 -9
- package/dist/src/fabric/fabric-commands.js +12 -0
- package/dist/src/fabric/functions/domains-add.function.d.ts +4 -4
- package/dist/src/fabric/functions/secrets-list.function.d.ts +16 -4
- package/dist/src/fabric/functions/secrets-list.function.js +12 -10
- package/dist/src/fabric/functions/secrets-rotate.function.d.ts +24 -0
- package/dist/src/fabric/functions/secrets-rotate.function.js +36 -0
- package/dist/src/fabric/functions/secrets-set.function.d.ts +8 -4
- package/dist/src/fabric/functions/secrets-set.function.js +18 -7
- package/dist/src/fabric/functions/validate.function.js +16 -7
- package/dist/src/fabric/lib/http.d.ts +7 -1
- package/dist/src/fabric/lib/sealed-box.d.ts +16 -0
- package/dist/src/fabric/lib/sealed-box.js +72 -0
- package/dist/src/functions/commands/dev.js +9 -0
- package/dist/src/functions/commands/knowledge-index.d.ts +30 -0
- package/dist/src/functions/commands/knowledge-index.js +11 -0
- package/dist/src/functions/commands/knowledge-validate.d.ts +33 -0
- package/dist/src/functions/commands/knowledge-validate.js +11 -0
- package/dist/src/functions/commands/new-addon.d.ts +18 -0
- package/dist/src/functions/commands/new-addon.js +40 -24
- package/dist/src/functions/commands/pikku-command-bootstrap.js +1 -0
- package/dist/src/functions/commands/scenario-browser.d.ts +17 -2
- package/dist/src/functions/commands/scenario-browser.js +16 -8
- package/dist/src/functions/commands/scenario-environment.d.ts +32 -0
- package/dist/src/functions/commands/scenario-environment.js +61 -0
- package/dist/src/functions/commands/scenario.d.ts +6 -0
- package/dist/src/functions/commands/scenario.js +14 -9
- package/dist/src/functions/commands/skills.js +27 -61
- package/dist/src/functions/db/db-codegen.d.ts +6 -0
- package/dist/src/functions/db/db-codegen.js +9 -0
- package/dist/src/functions/db/db-migrator.js +14 -0
- package/dist/src/functions/db/local-db.d.ts +8 -0
- package/dist/src/functions/db/local-db.js +24 -2
- package/dist/src/functions/db/migration-identifiers.d.ts +58 -0
- package/dist/src/functions/db/migration-identifiers.js +262 -0
- package/dist/src/functions/db/migration-provenance.d.ts +35 -0
- package/dist/src/functions/db/migration-provenance.js +80 -0
- package/dist/src/functions/db/schema-sql.d.ts +43 -0
- package/dist/src/functions/db/schema-sql.js +135 -0
- package/dist/src/functions/db/sqlite/sqlite-kysely.js +22 -2
- package/dist/src/functions/knowledge/render.d.ts +3 -0
- package/dist/src/functions/knowledge/render.js +66 -0
- package/dist/src/functions/knowledge/schemas.d.ts +51 -0
- package/dist/src/functions/knowledge/schemas.js +25 -0
- package/dist/src/functions/wirings/credentials/serialize-credentials-types.js +8 -1
- package/dist/src/functions/wirings/functions/schemas.js +13 -1
- package/dist/src/functions/wirings/rpc/pikku-command-rpc.js +6 -1
- package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.d.ts +10 -0
- package/dist/src/functions/wirings/scenarios/register-scenario-instrumentation.js +102 -0
- package/dist/src/functions/wirings/scenarios/scenario-partition.d.ts +13 -0
- package/dist/src/functions/wirings/scenarios/scenario-partition.js +15 -2
- package/dist/src/functions/wirings/scenarios/scenario-schema-partition.d.ts +33 -0
- package/dist/src/functions/wirings/scenarios/scenario-schema-partition.js +49 -0
- package/dist/src/functions/wirings/secrets/serialize-secrets-types.js +10 -3
- package/dist/src/functions/wirings/variables/serialize-variables-types.js +8 -1
- package/dist/src/functions/workflows/all.workflow.js +2 -7
- package/dist/src/utils/file-writer.js +14 -2
- package/dist/src/utils/pikku-cli-config.d.ts +14 -0
- package/dist/src/utils/pikku-cli-config.js +34 -0
- package/dist/src/utils/remove-legacy-scaffold-file.d.ts +14 -0
- package/dist/src/utils/remove-legacy-scaffold-file.js +23 -0
- package/dist/src/utils/serialize-schemas.d.ts +3 -1
- package/dist/src/utils/serialize-schemas.js +39 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -9
- package/dist/.pikku/schemas/schemas/PikkuScenarioFunctionsOutput.schema.json +0 -1
- package/dist/src/functions/wirings/scenarios/pikku-command-scenario-functions.d.ts +0 -1
- package/dist/src/functions/wirings/scenarios/pikku-command-scenario-functions.js +0 -31
- package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.d.ts +0 -10
- package/dist/src/functions/wirings/scenarios/serialize-scenario-functions.js +0 -104
- package/skills/pikku-addon/SKILL.md +0 -243
- package/skills/pikku-addon/references/addon-package-manifest.md +0 -63
- package/skills/pikku-ai-agent/SKILL.md +0 -231
- package/skills/pikku-ai-vercel/SKILL.md +0 -82
- package/skills/pikku-ai-voice/SKILL.md +0 -88
- package/skills/pikku-audit/SKILL.md +0 -175
- package/skills/pikku-aws/SKILL.md +0 -111
- package/skills/pikku-backblaze/SKILL.md +0 -71
- package/skills/pikku-better-auth/SKILL.md +0 -298
- package/skills/pikku-cli/SKILL.md +0 -198
- package/skills/pikku-cli/references/complete-example.md +0 -82
- package/skills/pikku-concepts/SKILL.md +0 -250
- package/skills/pikku-concepts/references/concept-mapping.md +0 -556
- package/skills/pikku-concepts/references/packages.md +0 -29
- package/skills/pikku-config/SKILL.md +0 -212
- package/skills/pikku-cron/SKILL.md +0 -214
- package/skills/pikku-deploy-azure/SKILL.md +0 -71
- package/skills/pikku-deploy-cloudflare/SKILL.md +0 -82
- package/skills/pikku-deploy-express/SKILL.md +0 -86
- package/skills/pikku-deploy-fastify/SKILL.md +0 -73
- package/skills/pikku-deploy-lambda/SKILL.md +0 -110
- package/skills/pikku-deploy-nextjs/SKILL.md +0 -78
- package/skills/pikku-deploy-uws/SKILL.md +0 -88
- package/skills/pikku-deps/SKILL.md +0 -98
- package/skills/pikku-emails/SKILL.md +0 -163
- package/skills/pikku-fabric/SKILL.md +0 -318
- package/skills/pikku-fabric-debug/SKILL.md +0 -112
- package/skills/pikku-feature/SKILL.md +0 -258
- package/skills/pikku-gateway-slack/SKILL.md +0 -115
- package/skills/pikku-http/SKILL.md +0 -220
- package/skills/pikku-http/references/http-options.md +0 -55
- package/skills/pikku-i18n/SKILL.md +0 -137
- package/skills/pikku-info/SKILL.md +0 -100
- package/skills/pikku-jose/SKILL.md +0 -105
- package/skills/pikku-kysely/SKILL.md +0 -219
- package/skills/pikku-machine-auth/SKILL.md +0 -183
- package/skills/pikku-mcp/SKILL.md +0 -241
- package/skills/pikku-middleware/SKILL.md +0 -231
- package/skills/pikku-middleware/references/middleware-patterns.md +0 -61
- package/skills/pikku-mongodb/SKILL.md +0 -105
- package/skills/pikku-n8n-import/SKILL.md +0 -109
- package/skills/pikku-n8n-import/SPEC.md +0 -84
- package/skills/pikku-n8n-import/references/addon-mapping.md +0 -121
- package/skills/pikku-n8n-import/references/code-translation.md +0 -121
- package/skills/pikku-n8n-import/references/loops-and-control.md +0 -87
- package/skills/pikku-paraglide/SKILL.md +0 -117
- package/skills/pikku-permissions/SKILL.md +0 -192
- package/skills/pikku-pino/SKILL.md +0 -79
- package/skills/pikku-product-second-opinion/README.md +0 -43
- package/skills/pikku-product-second-opinion/SKILL.md +0 -158
- package/skills/pikku-product-second-opinion/example/sample-report.md +0 -90
- package/skills/pikku-product-second-opinion/references/report-template.md +0 -73
- package/skills/pikku-queue/SKILL.md +0 -240
- package/skills/pikku-react/SKILL.md +0 -212
- package/skills/pikku-react-query/SKILL.md +0 -242
- package/skills/pikku-realtime/SKILL.md +0 -236
- package/skills/pikku-realtime/references/other-routes.md +0 -23
- package/skills/pikku-redis/SKILL.md +0 -90
- package/skills/pikku-rpc/SKILL.md +0 -171
- package/skills/pikku-rtl/SKILL.md +0 -219
- package/skills/pikku-scenario/SKILL.md +0 -382
- package/skills/pikku-schedule/SKILL.md +0 -57
- package/skills/pikku-schema-ajv/SKILL.md +0 -62
- package/skills/pikku-schema-cfworker/SKILL.md +0 -63
- package/skills/pikku-security/SKILL.md +0 -108
- package/skills/pikku-services/SKILL.md +0 -248
- package/skills/pikku-services/references/audit-wire-service.md +0 -34
- package/skills/pikku-software-archaeology/README.md +0 -70
- package/skills/pikku-software-archaeology/SKILL.md +0 -186
- package/skills/pikku-software-archaeology/references/blueprint.schema.json +0 -625
- package/skills/pikku-software-archaeology/references/pikku-mapping.md +0 -49
- package/skills/pikku-software-archaeology/scripts/validate.mjs +0 -173
- package/skills/pikku-tag-middleware/SKILL.md +0 -13
- package/skills/pikku-template-clone/SKILL.md +0 -40
- package/skills/pikku-trigger/SKILL.md +0 -181
- package/skills/pikku-versioning/SKILL.md +0 -173
- package/skills/pikku-websocket/SKILL.md +0 -243
- package/skills/pikku-workflow/SKILL.md +0 -172
- package/skills/pikku-workflow/references/workflow-reference.md +0 -63
- package/skills/pikku-workflows-client/SKILL.md +0 -150
- package/skills/pikku-ws/SKILL.md +0 -47
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-ai-vercel
|
|
3
|
-
description: >-
|
|
4
|
-
Use when setting up AI agent execution with the Vercel AI SDK in a Pikku app. Covers
|
|
5
|
-
VercelAIAgentRunner for streaming and non-streaming AI agent steps. TRIGGER when: code uses
|
|
6
|
-
VercelAIAgentRunner, user asks about Vercel AI SDK integration, AI agent runners, or
|
|
7
|
-
@pikku/ai-vercel. DO NOT TRIGGER when: user asks about AI agent wiring (use pikku-ai-agent) or
|
|
8
|
-
voice I/O (use pikku-ai-voice).
|
|
9
|
-
installGroups: [core]
|
|
10
|
-
---
|
|
11
|
-
|
|
12
|
-
# Pikku AI Vercel (Agent Runner)
|
|
13
|
-
|
|
14
|
-
## Agent Operating Procedure
|
|
15
|
-
|
|
16
|
-
Use this skill as an execution checklist, not reference material.
|
|
17
|
-
|
|
18
|
-
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.
|
|
19
|
-
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.
|
|
20
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
21
|
-
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.
|
|
22
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
23
|
-
|
|
24
|
-
`@pikku/ai-vercel` provides an AI agent runner backed by the [Vercel AI SDK](https://sdk.vercel.ai/). Implements `AIAgentRunnerService` from `@pikku/core`.
|
|
25
|
-
|
|
26
|
-
## Installation
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
yarn add @pikku/ai-vercel ai @ai-sdk/openai # or any AI SDK provider
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## API Reference
|
|
33
|
-
|
|
34
|
-
### `VercelAIAgentRunner`
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { VercelAIAgentRunner } from '@pikku/ai-vercel'
|
|
38
|
-
|
|
39
|
-
const runner = new VercelAIAgentRunner(
|
|
40
|
-
providers: Record<string, any> // Map of provider name → Vercel AI SDK provider instance
|
|
41
|
-
)
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
**Methods:**
|
|
45
|
-
|
|
46
|
-
- `stream(params: AIAgentRunnerParams, channel: AIStreamChannel): Promise<AIAgentStepResult>` — Stream AI responses with tool calls
|
|
47
|
-
- `run(params: AIAgentRunnerParams): Promise<AIAgentStepResult>` — Execute a single AI step (non-streaming)
|
|
48
|
-
|
|
49
|
-
The `providers` map lets you register multiple AI providers. Model strings use `provider:model` format (e.g., `"openai:gpt-4o"`).
|
|
50
|
-
|
|
51
|
-
## Usage Patterns
|
|
52
|
-
|
|
53
|
-
### Basic Setup
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import { VercelAIAgentRunner } from '@pikku/ai-vercel'
|
|
57
|
-
import { openai } from '@ai-sdk/openai'
|
|
58
|
-
import { anthropic } from '@ai-sdk/anthropic'
|
|
59
|
-
|
|
60
|
-
const createSingletonServices = pikkuServices(async (config) => {
|
|
61
|
-
const aiRunner = new VercelAIAgentRunner({
|
|
62
|
-
openai: openai,
|
|
63
|
-
anthropic: anthropic,
|
|
64
|
-
})
|
|
65
|
-
return { config, aiRunner }
|
|
66
|
-
})
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### With AI Agent Wiring
|
|
70
|
-
|
|
71
|
-
```typescript
|
|
72
|
-
import { wireAIAgent } from '@pikku/core/ai-agent'
|
|
73
|
-
|
|
74
|
-
wireAIAgent({
|
|
75
|
-
name: 'assistant',
|
|
76
|
-
model: 'openai:gpt-4o',
|
|
77
|
-
systemPrompt: 'You are a helpful assistant.',
|
|
78
|
-
func: myAgentFunc,
|
|
79
|
-
})
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
The `VercelAIAgentRunner` is used internally by Pikku's AI agent wiring to execute model calls. See `pikku-ai-agent` for wiring details.
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-ai-voice
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding voice input (speech-to-text) or voice output (text-to-speech) to AI agents in a
|
|
5
|
-
Pikku app. Covers voiceInput/voiceOutput middleware hooks and STT/TTS service interfaces.
|
|
6
|
-
TRIGGER when: code uses voiceInput, voiceOutput, STTService, TTSService, or user asks about
|
|
7
|
-
voice, speech-to-text, text-to-speech, or @pikku/ai-voice. DO NOT TRIGGER when: user asks about
|
|
8
|
-
AI agent wiring (use pikku-ai-agent) or Vercel AI SDK (use pikku-ai-vercel).
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Pikku AI Voice (Speech I/O)
|
|
12
|
-
|
|
13
|
-
## Agent Operating Procedure
|
|
14
|
-
|
|
15
|
-
Use this skill as an execution checklist, not reference material.
|
|
16
|
-
|
|
17
|
-
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.
|
|
18
|
-
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.
|
|
19
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
20
|
-
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.
|
|
21
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
22
|
-
|
|
23
|
-
`@pikku/ai-voice` provides speech-to-text and text-to-speech middleware hooks for Pikku AI agents.
|
|
24
|
-
|
|
25
|
-
## Installation
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
yarn add @pikku/ai-voice
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## API Reference
|
|
32
|
-
|
|
33
|
-
### Service Interfaces
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
interface STTService {
|
|
37
|
-
transcribe(
|
|
38
|
-
audio: Uint8Array,
|
|
39
|
-
options?: { language?: string; format?: string }
|
|
40
|
-
): Promise<string>
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface TTSService {
|
|
44
|
-
synthesize(
|
|
45
|
-
text: string,
|
|
46
|
-
options?: { voice?: string; format?: string }
|
|
47
|
-
): Promise<Uint8Array>
|
|
48
|
-
synthesizeStream?(
|
|
49
|
-
text: string,
|
|
50
|
-
options?: { voice?: string; format?: string }
|
|
51
|
-
): AsyncIterable<Uint8Array>
|
|
52
|
-
}
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Middleware Hooks
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { voiceInput, voiceOutput } from '@pikku/ai-voice'
|
|
59
|
-
|
|
60
|
-
voiceInput(config?: { language?: string }): PikkuAIMiddlewareHooks
|
|
61
|
-
voiceOutput(config?: { format?: string; voice?: string }): PikkuAIMiddlewareHooks
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
These return middleware hooks that can be attached to AI agent wirings to automatically transcribe audio input and synthesize audio output.
|
|
65
|
-
|
|
66
|
-
## Usage Patterns
|
|
67
|
-
|
|
68
|
-
### Voice-Enabled Agent
|
|
69
|
-
|
|
70
|
-
```typescript
|
|
71
|
-
import { voiceInput, voiceOutput } from '@pikku/ai-voice'
|
|
72
|
-
import { wireAIAgent } from '@pikku/core/ai-agent'
|
|
73
|
-
|
|
74
|
-
wireAIAgent({
|
|
75
|
-
name: 'voice-assistant',
|
|
76
|
-
model: 'openai:gpt-4o',
|
|
77
|
-
systemPrompt: 'You are a voice assistant.',
|
|
78
|
-
middlewareHooks: [
|
|
79
|
-
voiceInput({ language: 'en' }),
|
|
80
|
-
voiceOutput({ voice: 'alloy', format: 'mp3' }),
|
|
81
|
-
],
|
|
82
|
-
func: myAgentFunc,
|
|
83
|
-
})
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
### Custom STT/TTS Services
|
|
87
|
-
|
|
88
|
-
Implement the `STTService` and `TTSService` interfaces with your provider (OpenAI Whisper, ElevenLabs, etc.) and register them as singleton services.
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-audit
|
|
3
|
-
description: >-
|
|
4
|
-
Use when adding audit / activity-history / change-tracking to a Pikku app, or when a function
|
|
5
|
-
needs to record who changed what. Covers the built-in AuditService sink, the per-invocation
|
|
6
|
-
auditLog buffer (createInvocationAudit / pikkuWireServices), the `audit: true` function flag,
|
|
7
|
-
explicit `auditLog.write()` domain events, automatic query-level capture via
|
|
8
|
-
createAuditedKysely, and the durable KyselyAuditService sink. TRIGGER when: user asks for an
|
|
9
|
-
audit log, change history, activity feed, "who did this", or a custom audit/history table; code
|
|
10
|
-
uses auditLog, createInvocationAudit, createAuditedKysely, or AuditService. DO NOT TRIGGER when:
|
|
11
|
-
user wants app logging/telemetry (use the logger) or DB migrations in general (use
|
|
12
|
-
pikku-kysely).
|
|
13
|
-
installGroups: [core]
|
|
14
|
-
---
|
|
15
|
-
|
|
16
|
-
# Pikku Audit
|
|
17
|
-
|
|
18
|
-
## Agent Operating Procedure
|
|
19
|
-
|
|
20
|
-
Use this skill as an execution checklist, not reference material.
|
|
21
|
-
|
|
22
|
-
1. Discover before editing. Check how services are wired (`services.ts`) and whether an `audit` table migration exists before adding audit calls.
|
|
23
|
-
2. NEVER hand-roll a custom `audit_log` / history table with direct `insertInto('audit_log')` calls. The framework owns audit. A bespoke table drifts from the runtime (missing actor/trace/wire context, hand-written CHECK constraints that reject valid events, no prod sink). Use the built-in path below.
|
|
24
|
-
3. Make the smallest source change: mark the function `audit: true`, inject `auditLog`, call `auditLog.write(...)`. Do not invent a new service.
|
|
25
|
-
4. Validate with `pikku all` (regenerates the service flags) then run the app / e2e.
|
|
26
|
-
|
|
27
|
-
## Mental model — two layers
|
|
28
|
-
|
|
29
|
-
- **`audit` (singleton `AuditService`)** — the durable **sink**. Write-only: `audit(event)` + optional `write(batch)`. Defaults to `NoopAuditService` (discards). Swap in a real sink to persist (see Sinks).
|
|
30
|
-
- **`auditLog` (wire service `AuditLog`)** — a per-invocation **buffer** built from the sink via `createInvocationAudit(audit, wire)`. `auditLog.write(input)` enriches each event with `functionId`, `wireType`, `traceId`, `occurredAt`, and `actor` (from the wire session) automatically, then flushes to the sink when the invocation ends.
|
|
31
|
-
|
|
32
|
-
An event only persists when the function opts in with **`audit: true`** — otherwise `auditLog` is a no-op that warns.
|
|
33
|
-
|
|
34
|
-
## Wiring (services.ts)
|
|
35
|
-
|
|
36
|
-
```typescript
|
|
37
|
-
import { NoopAuditService, createInvocationAudit } from '@pikku/core/services'
|
|
38
|
-
|
|
39
|
-
export const createSingletonServices = pikkuServices(async (config, existing) => {
|
|
40
|
-
// Prod platforms may inject a queue-backed sink as existing.audit.
|
|
41
|
-
const audit = existing?.audit ?? new NoopAuditService()
|
|
42
|
-
return { ...existing, config, /* ... */ audit }
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
// auditLog is created per invocation from the sink. Returned unconditionally so
|
|
46
|
-
// a write from a function that forgot `audit: true` warns instead of vanishing.
|
|
47
|
-
export const createWireServices = pikkuWireServices(async (services, wire) => {
|
|
48
|
-
if (!services.audit) return {}
|
|
49
|
-
return { auditLog: createInvocationAudit(services.audit, wire) }
|
|
50
|
-
})
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
`audit` and `auditLog` are already declared on `CoreSingletonServices` / `CoreServices`, so no type change is needed to inject them.
|
|
54
|
-
|
|
55
|
-
## Recording events — explicit domain events (default)
|
|
56
|
-
|
|
57
|
-
Mark the function `audit: true` and call `auditLog?.write(...)`. Domain history goes in `metadata`; the actor is derived from the session, so do NOT pass it manually.
|
|
58
|
-
|
|
59
|
-
```typescript
|
|
60
|
-
export const cancelInvoice = pikkuFunc({
|
|
61
|
-
audit: true, // REQUIRED — else write() is a no-op
|
|
62
|
-
input: CancelInvoiceInput,
|
|
63
|
-
output: CancelInvoiceOutput,
|
|
64
|
-
func: async ({ kysely, auditLog }, { invoiceId }, { session }) => {
|
|
65
|
-
const inv = await kysely.selectFrom('invoice')/* ... */.executeTakeFirstOrThrow()
|
|
66
|
-
await kysely.updateTable('invoice').set({ status: 'cancelled' })/* ... */.execute()
|
|
67
|
-
|
|
68
|
-
await auditLog?.write({
|
|
69
|
-
type: 'invoice.update',
|
|
70
|
-
source: 'explicit',
|
|
71
|
-
metadata: {
|
|
72
|
-
entity: 'invoice',
|
|
73
|
-
entityId: invoiceId,
|
|
74
|
-
action: 'update',
|
|
75
|
-
field: 'status',
|
|
76
|
-
before: inv.status,
|
|
77
|
-
after: 'cancelled',
|
|
78
|
-
},
|
|
79
|
-
})
|
|
80
|
-
return { ok: true }
|
|
81
|
-
},
|
|
82
|
-
})
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
For a **system/cron** function there is no session, so `actor` is simply absent (nulls out `actor_user_id`). Use `pikkuVoidFunc({ audit: true, func: async ({ auditLog }) => { ... } })` — the void/config form accepts `audit`.
|
|
86
|
-
|
|
87
|
-
Helper functions (in `lib/`) that record audit take `auditLog?: AuditLog` in their services arg and are passed it from a `audit: true` caller — never import a service.
|
|
88
|
-
|
|
89
|
-
Note: events buffer and flush on invocation close. For a write inside a DB transaction, call `auditLog.write()` **after** the transaction commits — the sink is not part of your `trx`, so only record committed state.
|
|
90
|
-
|
|
91
|
-
## Recording events — automatic query capture (optional)
|
|
92
|
-
|
|
93
|
-
To audit every DB mutation without explicit calls, wrap kysely so each query emits an event. Note this captures table/column changes only — it cannot see semantic events that do no DB write (e.g. "email sent"), so combine with explicit writes when you need those.
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
import { createAuditedKysely } from '@pikku/kysely'
|
|
97
|
-
export const createWireServices = pikkuWireServices(async (services, wire) => {
|
|
98
|
-
if (!services.audit) return {}
|
|
99
|
-
const auditLog = createInvocationAudit(services.audit, wire)
|
|
100
|
-
return { auditLog, kysely: createAuditedKysely(services.kysely, { audit: auditLog }) }
|
|
101
|
-
})
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Sinks
|
|
105
|
-
|
|
106
|
-
- **`NoopAuditService`** (`@pikku/core/services`) — default; discards events. Fine when audit isn't needed.
|
|
107
|
-
- **`KyselyAuditService`** (`@pikku/kysely`) — durable: persists events to an `audit` table via kysely. Use as the local/dev sink so events are queryable without a platform queue: `new KyselyAuditService(kysely)`.
|
|
108
|
-
- **Platform-injected sink** — a deploy platform may inject its own queue-backed `audit` (hence the `existing?.audit ??` fallback above). Its rows land in the same `audit` table shape.
|
|
109
|
-
|
|
110
|
-
### The `audit` table (add this migration if you persist audit)
|
|
111
|
-
|
|
112
|
-
```sql
|
|
113
|
-
CREATE TABLE IF NOT EXISTS audit (
|
|
114
|
-
audit_id TEXT NOT NULL PRIMARY KEY DEFAULT (lower(hex(randomblob(16)))),
|
|
115
|
-
occurred_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
116
|
-
type TEXT NOT NULL,
|
|
117
|
-
source TEXT NOT NULL DEFAULT 'auto',
|
|
118
|
-
outcome TEXT,
|
|
119
|
-
function_id TEXT,
|
|
120
|
-
wire_type TEXT,
|
|
121
|
-
trace_id TEXT,
|
|
122
|
-
transaction_id TEXT,
|
|
123
|
-
query_id TEXT,
|
|
124
|
-
actor_user_id TEXT,
|
|
125
|
-
actor_org_id TEXT,
|
|
126
|
-
tables TEXT, -- JSON: table names touched (auto capture)
|
|
127
|
-
changed_cols TEXT, -- JSON: changed column names (auto capture)
|
|
128
|
-
event TEXT, -- custom event label
|
|
129
|
-
old TEXT, -- JSON: previous values
|
|
130
|
-
data TEXT -- JSON: metadata / new values / event payload
|
|
131
|
-
);
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
`auditLog.write({ metadata })` lands in the `data` column. Read history back by filtering it (SQLite `json_extract`, Postgres `->>`):
|
|
135
|
-
|
|
136
|
-
```typescript
|
|
137
|
-
const rows = await kysely
|
|
138
|
-
.selectFrom('audit')
|
|
139
|
-
.leftJoin('user', 'user.id', 'audit.actorUserId')
|
|
140
|
-
.where(sql<boolean>`json_extract(audit.data, '$.entity') = 'invoice'`)
|
|
141
|
-
.where(sql<boolean>`json_extract(audit.data, '$.entityId') = ${invoiceId}`)
|
|
142
|
-
.orderBy('audit.occurredAt', 'desc')
|
|
143
|
-
.select([
|
|
144
|
-
'audit.auditId',
|
|
145
|
-
sql<string>`json_extract(audit.data, '$.action')`.as('action'),
|
|
146
|
-
'audit.occurredAt as at',
|
|
147
|
-
'user.name as userName',
|
|
148
|
-
])
|
|
149
|
-
.execute()
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## AuditEvent shape
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
type AuditEvent = {
|
|
156
|
-
type: string // e.g. 'invoice.update'
|
|
157
|
-
source: 'auto' | 'explicit'
|
|
158
|
-
occurredAt: string // auto-filled by auditLog
|
|
159
|
-
outcome?: string
|
|
160
|
-
functionId?; wireType?; wireId?; traceId?; transactionId?; queryId? // auto
|
|
161
|
-
actor?: { userId?; orgId? } // auto from wire session
|
|
162
|
-
input?: unknown
|
|
163
|
-
metadata?: Record<string, unknown> // your domain payload
|
|
164
|
-
}
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
`auditLog.write()` takes `Omit<AuditEvent, 'occurredAt'>` — you only supply `type`, `source`, and `metadata` (and `actor` if overriding the session default).
|
|
168
|
-
|
|
169
|
-
## Do / Don't
|
|
170
|
-
|
|
171
|
-
- DO mark recording functions `audit: true`, inject `auditLog`, and call `auditLog.write({ type, source: 'explicit', metadata })`.
|
|
172
|
-
- DO let the actor come from the session — don't thread `userId` into metadata for the actor.
|
|
173
|
-
- DON'T create a custom `audit_log`/history table or `insertInto('audit_log')` by hand.
|
|
174
|
-
- DON'T annotate the function's I/O from audit; audit is a side channel, not part of `input`/`output`.
|
|
175
|
-
- DON'T write audit inside a DB transaction expecting rollback — record after commit.
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-aws
|
|
3
|
-
description: >-
|
|
4
|
-
Use when setting up AWS services (S3, SQS, Secrets Manager) in a Pikku app. Covers S3Content for
|
|
5
|
-
file storage, SQSQueueService for queues, and AWSSecrets for secret management. TRIGGER when:
|
|
6
|
-
code uses S3Content, SQSQueueService, AWSSecrets, or user asks about AWS integration, S3
|
|
7
|
-
uploads, SQS queues, or AWS Secrets Manager with Pikku. DO NOT TRIGGER when: user asks about AWS
|
|
8
|
-
Lambda runtime (use pikku-deploy-lambda).
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# Pikku AWS Services
|
|
12
|
-
|
|
13
|
-
## Agent Operating Procedure
|
|
14
|
-
|
|
15
|
-
Use this skill as an execution checklist, not reference material.
|
|
16
|
-
|
|
17
|
-
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.
|
|
18
|
-
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.
|
|
19
|
-
3. Make the smallest source change that satisfies the task. Keep generated files generated, and avoid hand-editing SDKs, schema output, or typegen.
|
|
20
|
-
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.
|
|
21
|
-
5. If validation fails, fix the source cause and rerun validation. Do not paper over generated errors by editing generated files.
|
|
22
|
-
|
|
23
|
-
`@pikku/aws-services` provides AWS-backed implementations of Pikku's content, queue, and secret service interfaces.
|
|
24
|
-
|
|
25
|
-
## Installation
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
yarn add @pikku/aws-services
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## API Reference
|
|
32
|
-
|
|
33
|
-
### `S3Content` (File Storage)
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { S3Content } from '@pikku/aws-services'
|
|
37
|
-
|
|
38
|
-
const content = new S3Content(
|
|
39
|
-
config: S3ContentConfig,
|
|
40
|
-
logger: Logger,
|
|
41
|
-
signConfig: { keyPairId: string; privateKey: string }
|
|
42
|
-
)
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
**Methods:**
|
|
46
|
-
|
|
47
|
-
- `signURL(url: string, dateLessThan: Date, dateGreaterThan?: Date): Promise<string>` — Sign a CloudFront URL
|
|
48
|
-
- `signContentKey(key: string, dateLessThan: Date, dateGreaterThan?: Date): Promise<string>` — Sign a content key
|
|
49
|
-
- `getUploadURL(Key: string, ContentType: string): Promise<{ uploadUrl, assetKey }>` — Get presigned upload URL
|
|
50
|
-
- `readFile(Key: string): Promise<ReadableStream>` — Read file as stream
|
|
51
|
-
- `readFileAsBuffer(Key: string): Promise<Buffer>` — Read file as buffer
|
|
52
|
-
- `writeFile(Key: string, stream: ReadableStream): Promise<boolean>` — Write file from stream
|
|
53
|
-
- `copyFile(Key: string, fromAbsolutePath: string): Promise<boolean>` — Copy local file to S3
|
|
54
|
-
- `deleteFile(Key: string): Promise<boolean>` — Delete file
|
|
55
|
-
|
|
56
|
-
### `SQSQueueService` (Queue)
|
|
57
|
-
|
|
58
|
-
```typescript
|
|
59
|
-
import { SQSQueueService } from '@pikku/aws-services'
|
|
60
|
-
|
|
61
|
-
const queue = new SQSQueueService(config: SQSQueueServiceConfig)
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
Implements `QueueService`. Note: `supportsResults = false` — job status tracking is not supported.
|
|
65
|
-
|
|
66
|
-
**Methods:**
|
|
67
|
-
|
|
68
|
-
- `add<T>(queueName: string, data: T, options?: JobOptions): Promise<string>` — Enqueue a message
|
|
69
|
-
|
|
70
|
-
### `AWSSecrets` (Secrets Manager)
|
|
71
|
-
|
|
72
|
-
```typescript
|
|
73
|
-
import { AWSSecrets } from '@pikku/aws-services'
|
|
74
|
-
|
|
75
|
-
const secrets = new AWSSecrets(config: AWSConfig)
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**Methods:**
|
|
79
|
-
|
|
80
|
-
- `getSecret<T = string>(SecretId: string): Promise<T>` — Get a secret value; a JSON secret is parsed automatically, so pass a shape as `T` (a non-JSON value comes back as the raw string)
|
|
81
|
-
- `getSecrets<T>(SecretIds: (keyof T & string)[]): Promise<Partial<T>>` — Batch fetch; missing keys are omitted rather than thrown
|
|
82
|
-
- `hasSecret(SecretId: string): Promise<boolean>` — Check if secret exists
|
|
83
|
-
- `setSecret` / `deleteSecret` — **not implemented** for `AWSSecrets`; it throws. Manage AWS secrets out of band.
|
|
84
|
-
|
|
85
|
-
## Usage Patterns
|
|
86
|
-
|
|
87
|
-
### S3 Content Service
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
const createSingletonServices = pikkuServices(async (config) => {
|
|
91
|
-
const logger = new PinoLogger()
|
|
92
|
-
const content = new S3Content(
|
|
93
|
-
{ bucket: config.s3Bucket, region: config.awsRegion },
|
|
94
|
-
logger,
|
|
95
|
-
{ keyPairId: config.cfKeyPairId, privateKey: config.cfPrivateKey }
|
|
96
|
-
)
|
|
97
|
-
return { config, logger, content }
|
|
98
|
-
})
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
### SQS Queue
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
const createSingletonServices = pikkuServices(async (config) => {
|
|
105
|
-
const queue = new SQSQueueService({
|
|
106
|
-
region: config.awsRegion,
|
|
107
|
-
queueUrlPrefix: config.sqsUrlPrefix,
|
|
108
|
-
})
|
|
109
|
-
return { config, queue }
|
|
110
|
-
})
|
|
111
|
-
```
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: pikku-backblaze
|
|
3
|
-
description: >-
|
|
4
|
-
Use when setting up Backblaze B2 file storage in a Pikku app. Covers B2Content for file uploads,
|
|
5
|
-
downloads, and signed URLs. TRIGGER when: code uses B2Content, user asks about Backblaze B2, or
|
|
6
|
-
@pikku/backblaze. DO NOT TRIGGER when: user asks about S3 storage (use pikku-aws).
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
# Pikku Backblaze (B2 Content Storage)
|
|
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
|
-
`@pikku/backblaze` provides Backblaze B2-backed file storage implementing the `ContentService` interface.
|
|
22
|
-
|
|
23
|
-
## Installation
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
yarn add @pikku/backblaze
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## API Reference
|
|
30
|
-
|
|
31
|
-
### `B2Content`
|
|
32
|
-
|
|
33
|
-
```typescript
|
|
34
|
-
import { B2Content } from '@pikku/backblaze'
|
|
35
|
-
|
|
36
|
-
const content = new B2Content(
|
|
37
|
-
config: B2ContentConfig,
|
|
38
|
-
logger: Logger
|
|
39
|
-
)
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
**Methods:**
|
|
43
|
-
|
|
44
|
-
- `signContentKey(key: string, dateLessThan: Date): Promise<string>` — Sign a content key
|
|
45
|
-
- `signURL(url: string, dateLessThan: Date): Promise<string>` — Sign a URL
|
|
46
|
-
- `getUploadURL(fileKey: string, contentType: string): Promise<{ uploadUrl, assetKey, uploadMethod?, uploadHeaders? }>` — Get upload URL
|
|
47
|
-
- `writeFile(assetKey: string, stream: ReadableStream): Promise<boolean>` — Write file
|
|
48
|
-
- `copyFile(assetKey: string, fromAbsolutePath: string): Promise<boolean>` — Copy local file to B2
|
|
49
|
-
- `readFile(assetKey: string): Promise<ReadableStream>` — Read file as stream
|
|
50
|
-
- `readFileAsBuffer(assetKey: string): Promise<Buffer>` — Read file as buffer
|
|
51
|
-
- `deleteFile(fileName: string): Promise<boolean>` — Delete file
|
|
52
|
-
|
|
53
|
-
## Usage Patterns
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import { B2Content } from '@pikku/backblaze'
|
|
57
|
-
|
|
58
|
-
const createSingletonServices = pikkuServices(async (config) => {
|
|
59
|
-
const logger = new PinoLogger()
|
|
60
|
-
const content = new B2Content(
|
|
61
|
-
{
|
|
62
|
-
applicationKeyId: config.b2KeyId,
|
|
63
|
-
applicationKey: config.b2AppKey,
|
|
64
|
-
bucketId: config.b2BucketId,
|
|
65
|
-
cdnUrl: config.b2CdnUrl,
|
|
66
|
-
},
|
|
67
|
-
logger
|
|
68
|
-
)
|
|
69
|
-
return { config, logger, content }
|
|
70
|
-
})
|
|
71
|
-
```
|