bkper 4.13.7 → 4.14.0

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.
Files changed (44) hide show
  1. package/lib/commands/apps/build.d.ts +1 -2
  2. package/lib/commands/apps/build.d.ts.map +1 -1
  3. package/lib/commands/apps/build.js +13 -39
  4. package/lib/commands/apps/build.js.map +1 -1
  5. package/lib/commands/apps/config.d.ts +5 -14
  6. package/lib/commands/apps/config.d.ts.map +1 -1
  7. package/lib/commands/apps/config.js +13 -45
  8. package/lib/commands/apps/config.js.map +1 -1
  9. package/lib/commands/apps/deploy.d.ts +14 -4
  10. package/lib/commands/apps/deploy.d.ts.map +1 -1
  11. package/lib/commands/apps/deploy.js +42 -58
  12. package/lib/commands/apps/deploy.js.map +1 -1
  13. package/lib/commands/apps/dev.d.ts +1 -7
  14. package/lib/commands/apps/dev.d.ts.map +1 -1
  15. package/lib/commands/apps/dev.js +43 -115
  16. package/lib/commands/apps/dev.js.map +1 -1
  17. package/lib/commands/apps/init.d.ts +1 -1
  18. package/lib/commands/apps/init.d.ts.map +1 -1
  19. package/lib/commands/apps/init.js +6 -12
  20. package/lib/commands/apps/init.js.map +1 -1
  21. package/lib/commands/apps/register.d.ts.map +1 -1
  22. package/lib/commands/apps/register.js +3 -11
  23. package/lib/commands/apps/register.js.map +1 -1
  24. package/lib/commands/apps/types.d.ts +3 -27
  25. package/lib/commands/apps/types.d.ts.map +1 -1
  26. package/lib/dev/local-assets.d.ts +15 -0
  27. package/lib/dev/local-assets.d.ts.map +1 -0
  28. package/lib/dev/local-assets.js +43 -0
  29. package/lib/dev/local-assets.js.map +1 -0
  30. package/lib/dev/logger.d.ts +3 -7
  31. package/lib/dev/logger.d.ts.map +1 -1
  32. package/lib/dev/logger.js +3 -6
  33. package/lib/dev/logger.js.map +1 -1
  34. package/lib/dev/miniflare.d.ts +2 -0
  35. package/lib/dev/miniflare.d.ts.map +1 -1
  36. package/lib/dev/miniflare.js +83 -21
  37. package/lib/dev/miniflare.js.map +1 -1
  38. package/lib/docs/app-building.md +151 -141
  39. package/lib/docs/app-management.md +43 -28
  40. package/lib/docs/bkper-js.md +2 -0
  41. package/lib/docs/index.md +1 -1
  42. package/lib/platform/client.d.ts +2 -2
  43. package/lib/platform/client.js +2 -2
  44. package/package.json +1 -1
@@ -12,47 +12,63 @@ Build, deploy, and manage Bkper apps using the `bkper` CLI.
12
12
  When scaffolding, developing, or deploying an app, verify each step before proceeding. This prevents broken deployments and silent failures.
13
13
 
14
14
  ### 1. Init
15
+
15
16
  ```bash
16
17
  bkper app init my-app
17
18
  ```
19
+
18
20
  Verify:
19
- - `packages/web/client/`, `packages/web/server/`, `packages/events/`, and `packages/shared/` exist
21
+
22
+ - `client/` and `server/` exist
20
23
  - `bkper.yaml` has `id`, `name`, `description`, and `developers`
21
24
  - `package.json` scripts include `dev` and `build`
22
25
 
23
26
  ### 2. Develop
27
+
24
28
  ```bash
25
29
  npm run dev
26
30
  ```
31
+
27
32
  Verify:
28
- - Web server responds: `curl http://localhost:8787` (or the port you configured)
33
+
34
+ - Server worker responds: `curl http://localhost:8787/health` (or the port you configured)
29
35
  - Client dev server is reachable if running separately
30
- - Events tunnel URL is printed in terminal and registered in Bkper (check `webhookUrlDev` in app settings)
31
- - If any handler fails to start, fix before writing code
36
+ - If the app declares `events`, the events tunnel URL is printed in terminal and registered in Bkper as `webhookUrlDev`
37
+ - If the worker fails to start, fix before writing code
32
38
 
33
39
  ### 3. Build
40
+
34
41
  ```bash
35
42
  npm run build
36
43
  ```
44
+
37
45
  Verify:
38
- - `dist/web/server/` contains the web worker bundle
39
- - `dist/events/` contains the events handler bundle
46
+
47
+ - `dist/server/` contains the server Worker bundle
48
+ - `dist/client/` contains the Vite client build when `deployment.client` is configured
40
49
  - No build errors in terminal output
41
50
 
42
51
  ### 4. Sync & Deploy
52
+
43
53
  ```bash
44
54
  bkper app sync && bkper app deploy
45
55
  ```
56
+
46
57
  Verify:
58
+
47
59
  - `bkper app status` shows the deployed version
48
60
  - URLs in `bkper.yaml` match the deployed domain (`https://{appId}.bkper.app`)
49
61
 
50
62
  ### 5. Validate
63
+
51
64
  ```bash
52
65
  bkper app install <appId> -b <bookId>
53
66
  ```
67
+
54
68
  Verify:
69
+
55
70
  - Menu appears in the book's "More" menu (if configured)
71
+ - App server `/api/*` routes are called with `Authorization: Bearer <token>`
56
72
  - Trigger a subscribed event in the book
57
73
  - Check the Bkper activity stream for the handler response
58
74
  - If the handler writes back to the book, confirm loop prevention is in place (check `event.agent.id`)
@@ -66,11 +82,11 @@ Verify:
66
82
  bkper app init my-app
67
83
 
68
84
  # Start the worker runtime (Miniflare + tunnel + file watching)
69
- # In your project, use "npm run dev" to run both Vite and workers concurrently
85
+ # In your project, use "npm run dev" to run both Vite and the worker concurrently
70
86
  bkper app dev
71
87
 
72
- # Build worker bundles (web server + events handler)
73
- # In your project, use "npm run build" to build both client (Vite) and workers
88
+ # Build the server Worker bundle
89
+ # In your project, use "npm run build" to build both client (Vite) and worker
74
90
  bkper app build
75
91
 
76
92
  # Sync configuration and deploy to production
@@ -79,14 +95,11 @@ bkper app sync && bkper app deploy
79
95
  # Deploy to preview environment (URL: https://{appId}-preview.bkper.app)
80
96
  bkper app deploy --preview
81
97
 
82
- # Deploy only the events handler
83
- bkper app deploy --events
84
-
85
98
  # Check deployment status
86
99
  bkper app status
87
100
  ```
88
101
 
89
- > **Note:** `bkper app dev` runs the worker runtime only — Miniflare, file watching, and the Cloudflare tunnel. Miniflare is loaded from the app project's `devDependencies` so each app can keep its local Workers simulator aligned with its own code. The Vite client dev server is configured in the project's `vite.config.ts` and run separately. The project template composes both via `npm run dev` using `concurrently`. If needed, install Miniflare in the app root with `bun add -d miniflare` or `npm install -D miniflare`.
102
+ > **Note:** `bkper app dev` runs one local Worker runtime — Miniflare, file watching, and an optional Cloudflare tunnel to `/events` when the app subscribes to events. Miniflare is loaded from the app project's `devDependencies` so each app can keep its local Workers simulator aligned with its own code. The Vite client dev server is configured in the project's `vite.config.ts` and run separately. The project template composes both via `npm run dev` using `concurrently`. If needed, install Miniflare in the app root with `bun add -d miniflare` or `npm install -D miniflare`.
90
103
 
91
104
  ---
92
105
 
@@ -115,6 +128,8 @@ bkper app secrets list
115
128
  bkper app secrets delete EXTERNAL_SERVICE_TOKEN
116
129
  ```
117
130
 
131
+ Use `--preview` to manage preview secrets.
132
+
118
133
  ---
119
134
 
120
135
  ## Configuration
@@ -231,6 +246,7 @@ menuPopupHeight: 300
231
246
  # EVENT HANDLING (optional)
232
247
  # -----------------------------------------------------------------------------
233
248
  # When configured, Bkper calls your webhook URL when subscribed events occur.
249
+ # On the Bkper Platform, /events is handled by the same Worker as /api/*.
234
250
 
235
251
  # Production webhook URL
236
252
  webhookUrl: https://${id}.bkper.app/events
@@ -323,19 +339,23 @@ propertiesSchema:
323
339
  # -----------------------------------------------------------------------------
324
340
  # For apps deployed to Bkper's Workers for Platforms infrastructure.
325
341
  deployment:
326
- # Web handler (serves UI and API)
327
- web:
328
- bundle: packages/web/server/dist
329
- # assets: packages/web/client/dist # Static assets (when supported)
342
+ # Single server Worker entry point. It serves /api/* and /events.
343
+ server: server/src/index.ts
330
344
 
331
- # Events handler (processes webhooks)
332
- events:
333
- bundle: packages/events/dist
345
+ # Optional Vite/static client root. Built assets are deployed with the same Worker.
346
+ client: client
334
347
 
335
348
  # Platform services available to your app (one per type, auto-provisioned)
336
349
  # See: https://developers.cloudflare.com/kv/
337
350
  services:
338
351
  - KV # Key-value storage
352
+
353
+ # Secret names managed with bkper app secrets
354
+ secrets:
355
+ - EXTERNAL_SERVICE_TOKEN
356
+
357
+ # Cloudflare Workers compatibility date
358
+ compatibility_date: '2026-01-28'
339
359
  ```
340
360
 
341
361
  </details>
@@ -364,30 +384,25 @@ deployment:
364
384
  - `app init <name>` - Scaffold a new app from the template
365
385
  - `app list` - List all apps you have access to
366
386
  - `app sync` - Sync [bkper.yaml][bkper.yaml reference] configuration (URLs, description) to Bkper API
367
- - `app build` - Build worker bundles for deployment
387
+ - `app build` - Build the server Worker bundle for deployment
368
388
  - `app deploy` - Deploy built artifacts to Cloudflare Workers for Platforms
369
389
  - `-p, --preview` - Deploy to preview environment
370
- - `--events` - Deploy events handler instead of web handler
371
390
  - `app status` - Show deployment status
372
391
  - `app logs` - View recent app logs
373
392
  - `--since <time>` - ISO8601 or relative lower bound (e.g. `5m`, `1h`, `15d`)
374
393
  - `--until <time>` - ISO8601 or relative upper bound
375
394
  - `--last <n>` - Show newest N entries after filters (default: 100)
376
395
  - `-p, --preview` - Query preview logs instead of production
377
- - `-w, --web` - Filter to the web handler
378
- - `-e, --events` - Filter to the events handler
396
+ - `-w, --web` - Filter to normal web/API requests
397
+ - `-e, --events` - Filter to `/events` requests
379
398
  - `--outcome <outcome>` - Filter by Cloudflare worker outcome
380
399
  - `--status-code <code>` - Filter by HTTP status code
381
400
  - `app undeploy` - Remove app from platform
382
401
  - `-p, --preview` - Remove from preview environment
383
- - `--events` - Remove events handler instead of web handler
384
402
  - `--delete-data` - Permanently delete all associated data (requires confirmation)
385
403
  - `--force` - Skip confirmation prompts (use with `--delete-data` for automation)
386
404
  - `app dev` - Start the worker runtime for local development
387
405
  - `--sp, --server-port <port>` - Server simulation port (default: `8787`)
388
- - `--ep, --events-port <port>` - Events handler port (default: `8791`)
389
- - `-w, --web` - Run only the web handler
390
- - `-e, --events` - Run only the events handler
391
406
 
392
407
  > **Note:** `sync` and `deploy` are independent operations. Use `sync` to update your app's URLs in Bkper (required for webhooks and menu integration). Use `deploy` to push code to Cloudflare. For a typical deployment workflow, run both: `bkper app sync && bkper app deploy`
393
408
 
@@ -122,6 +122,8 @@ const books = await bkper.getBooks();
122
122
 
123
123
  See the [@bkper/web-auth documentation](https://bkper.com/docs/api/bkper-web-auth) for more details.
124
124
 
125
+ For Bkper Platform app server routes under `/api/*`, send `Authorization: Bearer ${auth.getAccessToken()}` from the client. The server route can use `new Bkper()` without a token provider because platform outbound auth injects the validated user's token on Bkper API calls.
126
+
125
127
  ### API Key (Optional)
126
128
 
127
129
  API keys are optional and only needed for dedicated quota limits. If not provided, requests use a shared managed quota via the Bkper API proxy.
package/lib/docs/index.md CHANGED
@@ -4,7 +4,7 @@ Reference docs for Bkper tasks. Load only the specific doc(s) relevant to the ta
4
4
 
5
5
  - **data-management.md** — CLI reference for managing financial data and files: books, accounts, groups, files, transactions, per-account balance queries, query operators (on:, after:, before:, account:, group:), output formats (table/json/csv), batch operations via stdin/piping, collections.
6
6
  - **app-management.md** — CLI reference for building and deploying Bkper apps: dev/build/deploy workflow, app install/uninstall, secrets management, app logs, bkper.yaml configuration reference (identity, branding, events, menu integration, deployment).
7
- - **app-building.md** — Full app-building reference: architecture (packages, client/server/events), development loop, event handlers, deployment patterns, the Bkper Platform, and self-hosted alternatives. Includes authentication patterns for web clients (`@bkper/web-auth`), event handlers (`bkper-oauth-token` headers), and local development. Load this for scaffolding apps, understanding app structure, or debugging the dev/build/deploy lifecycle.
7
+ - **app-building.md** — Full app-building reference: single Worker app architecture (`client/` + `server/`), development loop, `/api/*` routes, `/events` handlers, deployment patterns, the Bkper Platform, and self-hosted alternatives. Includes authentication patterns for web clients (`@bkper/web-auth`), server API routes (`Authorization: Bearer` on `/api/*` with outbound auth injection), platform event handlers (`new Bkper()` with outbound auth injection), and local development.
8
8
  - **financial-statements.md** — Step-by-step workflow for aggregate financial reports (balance sheet, P&L): root group discovery, query patterns, date semantics (before: vs after:+before:), common mistakes to avoid.
9
9
  - **taxes.md** — Deterministic workflow for tax position and filing summaries: discovering tax-relevant groups, period-based balance queries, persisting a local tax runner. Jurisdiction-agnostic — outputs raw period balances, leaving rate/application to the user.
10
10
  - **bkper-js.md** — bkper-js Node.js/browser SDK: Bkper, Book, Account, Transaction, Group, Balance classes, all methods, getBalancesReport, OAuth configuration, library setup.
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * // Deploy an app
14
14
  * const { data, error } = await client.POST('/api/apps/{appId}/deploy', {
15
- * params: { path: { appId: 'my-app' }, query: { env: 'dev', type: 'web' } },
16
- * body: bundleBuffer,
15
+ * params: { path: { appId: 'my-app' }, query: { env: 'preview' } },
16
+ * body: formData,
17
17
  * });
18
18
  * ```
19
19
  */
@@ -12,8 +12,8 @@
12
12
  *
13
13
  * // Deploy an app
14
14
  * const { data, error } = await client.POST('/api/apps/{appId}/deploy', {
15
- * params: { path: { appId: 'my-app' }, query: { env: 'dev', type: 'web' } },
16
- * body: bundleBuffer,
15
+ * params: { path: { appId: 'my-app' }, query: { env: 'preview' } },
16
+ * body: formData,
17
17
  * });
18
18
  * ```
19
19
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bkper",
3
- "version": "4.13.7",
3
+ "version": "4.14.0",
4
4
  "description": "Command line client for Bkper",
5
5
  "bin": {
6
6
  "bkper": "./lib/cli.js"