@chidchanun/bcp 0.2.14 → 0.2.16
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/README.md +190 -12
- package/docs/README.md +45 -43
- package/docs/api-manifest.json +13 -5
- package/docs/api-reference.md +108 -3
- package/docs/cache-platform-v2.md +487 -0
- package/docs/docs-web-manifest.json +9 -5
- package/docs/platform-manifest.json +29 -4
- package/docs/plugin-module-platform.md +391 -0
- package/docs/releases/0.2.15.md +118 -0
- package/docs/releases/0.2.16.md +147 -0
- package/package.json +7 -2
- package/packages/bundler/src/client-boundary.ts +1 -0
- package/packages/cache/src/platform-v2.ts +1705 -0
- package/packages/client/src/cache.mjs +1554 -0
- package/packages/client/src/cache.ts +29 -0
- package/packages/client/src/plugins.mjs +811 -0
- package/packages/client/src/plugins.ts +26 -0
- package/packages/server/src/plugins.ts +1225 -0
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# BCP Framework
|
|
2
2
|
|
|
3
|
-
BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, API routes, authentication, authorization, SQL databases, background jobs, scheduling, workflow orchestration, transactional events, realtime delivery, framework-native testing, observability, uploads, storage and standalone Node.js deployment.
|
|
3
|
+
BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, API routes, authentication, authorization, SQL databases, background jobs, scheduling, workflow orchestration, transactional events, realtime delivery, framework-native testing, plugin/module composition, distributed caching, observability, uploads, storage and standalone Node.js deployment.
|
|
4
4
|
|
|
5
|
-
> **Development target:** `0.2.
|
|
5
|
+
> **Development target:** `0.2.16 — Cache Platform v2`
|
|
6
6
|
>
|
|
7
|
-
> `0.2.
|
|
7
|
+
> `0.2.16` remains unreleased until local validation, RC checks, tagging and npm publication complete.
|
|
8
8
|
|
|
9
9
|
## Current platform
|
|
10
10
|
|
|
@@ -25,10 +25,11 @@ BCP Framework is a React full-stack framework for file-based routing, SSR, SPA n
|
|
|
25
25
|
| Workflows | Sequential/parallel steps, retries, persisted delays, compensation and run leases |
|
|
26
26
|
| Events | Transactional outbox, SQL persistence, dispatcher leases, retries, event bus and durable queue handoff |
|
|
27
27
|
| Realtime | Channels/rooms, presence, broker delivery, WebSocket adapter contract, SSE and heartbeat |
|
|
28
|
-
| Testing | Request/route/auth/database/middleware/jobs/workflow/outbox/realtime/SSE test harnesses |
|
|
28
|
+
| Testing | Request/route/page/auth/database/middleware/jobs/workflow/outbox/realtime/SSE test harnesses |
|
|
29
|
+
| Plugins & modules | Dependency ordering, lifecycle hooks, config parsing, service registry and async extension hooks |
|
|
30
|
+
| Caching | Legacy request/data cache plus Cache Platform v2 adapters, Redis-compatible cache/locks, stampede protection, TTL/tag/path invalidation and metrics |
|
|
29
31
|
| Observability | Structured logs, metrics, Prometheus output and health/readiness checks |
|
|
30
32
|
| Uploads & storage | Multipart streaming, Local/S3-compatible storage and signed URLs |
|
|
31
|
-
| Caching | Response cache and revalidation primitives |
|
|
32
33
|
| Configuration | Typed config/environment validation and diagnostics |
|
|
33
34
|
| Production | Standalone Node.js build, packaging, dependency pruning, Docker starter and graceful shutdown |
|
|
34
35
|
| Documentation | Manifest-driven docs, platform metadata and API reference |
|
|
@@ -68,6 +69,7 @@ Generated projects normally use one framework dependency:
|
|
|
68
69
|
## Core backend entrypoints
|
|
69
70
|
|
|
70
71
|
```ts
|
|
72
|
+
import { createCacheStore } from "bcp/cache";
|
|
71
73
|
import { db } from "bcp/database";
|
|
72
74
|
import { createAuth } from "bcp/auth";
|
|
73
75
|
import { createJobQueue } from "bcp/jobs";
|
|
@@ -75,6 +77,7 @@ import { createWorkflow } from "bcp/workflow";
|
|
|
75
77
|
import { createTransactionalOutbox } from "bcp/events";
|
|
76
78
|
import { createRealtime } from "bcp/realtime";
|
|
77
79
|
import { createTestApp } from "bcp/testing";
|
|
80
|
+
import { createPluginHost } from "bcp/plugins";
|
|
78
81
|
import { createMetricsRegistry } from "bcp/observability";
|
|
79
82
|
```
|
|
80
83
|
|
|
@@ -369,6 +372,175 @@ readSseEvents()
|
|
|
369
372
|
|
|
370
373
|
Read more: [Testing Platform](docs/testing-platform.md)
|
|
371
374
|
|
|
375
|
+
## Plugin & Module Platform — 0.2.15
|
|
376
|
+
|
|
377
|
+
`0.2.15` adds the server-only `bcp/plugins` entrypoint for reusable application/framework extensions.
|
|
378
|
+
|
|
379
|
+
Define plugins with explicit dependencies:
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
import {
|
|
383
|
+
createPluginHost,
|
|
384
|
+
definePlugin,
|
|
385
|
+
} from "bcp/plugins";
|
|
386
|
+
|
|
387
|
+
const databasePlugin =
|
|
388
|
+
definePlugin({
|
|
389
|
+
name: "database",
|
|
390
|
+
setup(context) {
|
|
391
|
+
context.services.provide(
|
|
392
|
+
"database",
|
|
393
|
+
db
|
|
394
|
+
);
|
|
395
|
+
},
|
|
396
|
+
start() {
|
|
397
|
+
return db.connect();
|
|
398
|
+
},
|
|
399
|
+
stop() {
|
|
400
|
+
return db.disconnect();
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
const jobsPlugin =
|
|
405
|
+
definePlugin({
|
|
406
|
+
name: "jobs",
|
|
407
|
+
requires: [
|
|
408
|
+
"database",
|
|
409
|
+
],
|
|
410
|
+
});
|
|
411
|
+
|
|
412
|
+
const host =
|
|
413
|
+
createPluginHost({
|
|
414
|
+
plugins: [
|
|
415
|
+
jobsPlugin,
|
|
416
|
+
databasePlugin,
|
|
417
|
+
],
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
await host.start();
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Dependency order is resolved automatically. Startup follows dependency order while stop/dispose runs in reverse order.
|
|
424
|
+
|
|
425
|
+
Modules group reusable plugin sets:
|
|
426
|
+
|
|
427
|
+
```ts
|
|
428
|
+
import {
|
|
429
|
+
defineModule,
|
|
430
|
+
} from "bcp/plugins";
|
|
431
|
+
|
|
432
|
+
const backendModule =
|
|
433
|
+
defineModule({
|
|
434
|
+
name: "backend",
|
|
435
|
+
plugins: [
|
|
436
|
+
databasePlugin,
|
|
437
|
+
jobsPlugin,
|
|
438
|
+
],
|
|
439
|
+
});
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
Plugin configuration can be parsed at setup time and overridden through `createPluginHost({ configs })`.
|
|
443
|
+
|
|
444
|
+
Plugins share a service registry and awaited in-process hook bus through `context.services` and `context.hooks`.
|
|
445
|
+
|
|
446
|
+
If startup fails, already-started plugins are stopped in reverse order before the lifecycle error is propagated.
|
|
447
|
+
|
|
448
|
+
Read more: [Plugin & Module Platform](docs/plugin-module-platform.md)
|
|
449
|
+
|
|
450
|
+
## Cache Platform v2 — 0.2.16
|
|
451
|
+
|
|
452
|
+
`0.2.16` keeps the original `cache()` and `dedupe()` APIs while adding provider-neutral asynchronous cache stores for production multi-instance applications.
|
|
453
|
+
|
|
454
|
+
Create a cache store:
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
import {
|
|
458
|
+
createCacheStore,
|
|
459
|
+
} from "bcp/cache";
|
|
460
|
+
|
|
461
|
+
export const applicationCache =
|
|
462
|
+
createCacheStore();
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
Cache-aside loading:
|
|
466
|
+
|
|
467
|
+
```ts
|
|
468
|
+
const user =
|
|
469
|
+
await applicationCache.getOrSet(
|
|
470
|
+
"user:42",
|
|
471
|
+
async () =>
|
|
472
|
+
loadUser(42),
|
|
473
|
+
{
|
|
474
|
+
ttlMs: 60_000,
|
|
475
|
+
tags: [
|
|
476
|
+
"users",
|
|
477
|
+
],
|
|
478
|
+
paths: [
|
|
479
|
+
"/users/42",
|
|
480
|
+
],
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
Within one store, concurrent misses share one loader automatically.
|
|
486
|
+
|
|
487
|
+
For multiple application instances, use shared cache and lock adapters:
|
|
488
|
+
|
|
489
|
+
```ts
|
|
490
|
+
import {
|
|
491
|
+
createRedisCacheAdapter,
|
|
492
|
+
createRedisCacheLockAdapter,
|
|
493
|
+
} from "bcp/cache";
|
|
494
|
+
|
|
495
|
+
const redisCache =
|
|
496
|
+
createRedisCacheAdapter({
|
|
497
|
+
client: redisClient,
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
const redisLock =
|
|
501
|
+
createRedisCacheLockAdapter({
|
|
502
|
+
client: redisClient,
|
|
503
|
+
});
|
|
504
|
+
|
|
505
|
+
export const cache =
|
|
506
|
+
createCacheStore({
|
|
507
|
+
adapter: redisCache,
|
|
508
|
+
lock: redisLock,
|
|
509
|
+
});
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
The default Redis namespace is `bcp:{cache}`. BCP does not install or own a Redis library/connection.
|
|
513
|
+
|
|
514
|
+
Distributed `getOrSet()` uses owner-scoped lock leases, heartbeat renewal when supported, double-check-after-lock, contention wait/poll and configurable lock-timeout behavior.
|
|
515
|
+
|
|
516
|
+
Tag/path invalidation remains available through the new async store:
|
|
517
|
+
|
|
518
|
+
```ts
|
|
519
|
+
await cache.revalidateTag(
|
|
520
|
+
"users"
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
await cache.revalidatePath(
|
|
524
|
+
"/dashboard"
|
|
525
|
+
);
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
Connect cache events to BCP metrics:
|
|
529
|
+
|
|
530
|
+
```ts
|
|
531
|
+
const cache =
|
|
532
|
+
createCacheStore({
|
|
533
|
+
metrics:
|
|
534
|
+
createCacheMetrics(
|
|
535
|
+
metricsRegistry
|
|
536
|
+
),
|
|
537
|
+
});
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
Prepared npm packages compile `bcp/cache` to `cache.mjs` for standalone Node runtime use.
|
|
541
|
+
|
|
542
|
+
Read more: [Cache Platform v2](docs/cache-platform-v2.md)
|
|
543
|
+
|
|
372
544
|
## Public entrypoints
|
|
373
545
|
|
|
374
546
|
```text
|
|
@@ -385,6 +557,7 @@ bcp/workflow
|
|
|
385
557
|
bcp/events
|
|
386
558
|
bcp/realtime
|
|
387
559
|
bcp/testing
|
|
560
|
+
bcp/plugins
|
|
388
561
|
bcp/observability
|
|
389
562
|
bcp/server
|
|
390
563
|
bcp/server-only
|
|
@@ -433,17 +606,20 @@ Browser / API / Realtime clients
|
|
|
433
606
|
|
|
|
434
607
|
security + auth
|
|
435
608
|
|
|
|
436
|
-
|
|
609
|
+
Plugin Host
|
|
437
610
|
/ | \
|
|
438
611
|
database workflows realtime
|
|
439
612
|
| | ^
|
|
440
613
|
outbox jobs |
|
|
441
614
|
\__________|_________/
|
|
442
615
|
durable state
|
|
443
|
-
|
|
444
|
-
|
|
616
|
+
|
|
|
617
|
+
shared cache layer
|
|
618
|
+
Redis / other
|
|
445
619
|
```
|
|
446
620
|
|
|
621
|
+
Cache is an optimization layer and must not replace durable application truth or transactional invariants.
|
|
622
|
+
|
|
447
623
|
## Packaging
|
|
448
624
|
|
|
449
625
|
```bash
|
|
@@ -469,7 +645,7 @@ docs/api-manifest.json
|
|
|
469
645
|
|
|
470
646
|
## Release validation
|
|
471
647
|
|
|
472
|
-
Before publishing `0.2.
|
|
648
|
+
Before publishing `0.2.16`:
|
|
473
649
|
|
|
474
650
|
```bash
|
|
475
651
|
npm run typecheck
|
|
@@ -480,7 +656,7 @@ npm run test:package
|
|
|
480
656
|
npm run rc:check
|
|
481
657
|
```
|
|
482
658
|
|
|
483
|
-
`0.2.
|
|
659
|
+
`0.2.16` adds unit and prepared-package smoke coverage for TTL/tag/path invalidation, local singleflight, distributed lock contention, lock timeout behavior, Redis cache/lock command contracts, cache metrics and compiled `cache.mjs` execution.
|
|
484
660
|
|
|
485
661
|
Do not tag or publish until the exact final release commit passes the full RC sequence.
|
|
486
662
|
|
|
@@ -509,12 +685,14 @@ Do not tag or publish until the exact final release commit passes the full RC se
|
|
|
509
685
|
| `0.2.12` | Transactional Outbox & Events |
|
|
510
686
|
| `0.2.13` | Realtime Platform |
|
|
511
687
|
| `0.2.14` | Testing Platform |
|
|
688
|
+
| `0.2.15` | Plugin & Module Platform |
|
|
689
|
+
| `0.2.16` | Cache Platform v2 |
|
|
512
690
|
|
|
513
691
|
## Roadmap
|
|
514
692
|
|
|
515
|
-
`0.2.
|
|
693
|
+
`0.2.16` establishes provider-neutral shared caching and distributed cache-fill coordination while preserving the original process-local cache API.
|
|
516
694
|
|
|
517
|
-
The next logical milestone is **`0.2.
|
|
695
|
+
The next logical milestone is **`0.2.17 — Observability Platform v3`**, focused on tracing, correlation across HTTP/jobs/workflows/events/realtime/cache, richer runtime metrics and exporter/provider integration.
|
|
518
696
|
|
|
519
697
|
Native desktop/mobile compilation remains later roadmap work.
|
|
520
698
|
|
package/docs/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The `docs/` directory is the documentation source of truth for BCP Framework and is organized for **`bcp-docs-web`**.
|
|
4
4
|
|
|
5
|
-
> **Documentation target:** BCP Framework `0.2.
|
|
5
|
+
> **Documentation target:** BCP Framework `0.2.16 — Cache Platform v2`
|
|
6
6
|
>
|
|
7
7
|
> **Release state:** unreleased development target until RC validation, tagging and npm publication complete.
|
|
8
8
|
|
|
@@ -40,63 +40,62 @@ Framework source and tests remain authoritative for runtime behavior.
|
|
|
40
40
|
| `0.2.12` | Transactional Outbox & Events |
|
|
41
41
|
| `0.2.13` | Realtime Platform |
|
|
42
42
|
| `0.2.14` | Testing Platform |
|
|
43
|
+
| `0.2.15` | Plugin & Module Platform |
|
|
44
|
+
| `0.2.16` | Cache Platform v2 |
|
|
43
45
|
|
|
44
|
-
## 0.2.
|
|
46
|
+
## 0.2.16 — Cache Platform v2
|
|
45
47
|
|
|
46
|
-
`0.2.
|
|
48
|
+
`0.2.16` extends the existing `bcp/cache` public entrypoint while keeping its original process-local APIs backward compatible.
|
|
47
49
|
|
|
48
|
-
Primary APIs:
|
|
50
|
+
Primary Cache Store v2 APIs:
|
|
49
51
|
|
|
50
52
|
```ts
|
|
51
53
|
import {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
createTestApp,
|
|
60
|
-
createTestAuthSession,
|
|
61
|
-
createWorkflowTestHarness,
|
|
62
|
-
expectResponse,
|
|
63
|
-
readSseEvents,
|
|
64
|
-
runTestMiddleware,
|
|
65
|
-
withTestTransaction,
|
|
66
|
-
} from "bcp/testing";
|
|
54
|
+
createCacheMetrics,
|
|
55
|
+
createCacheStore,
|
|
56
|
+
createMemoryCacheAdapter,
|
|
57
|
+
createMemoryCacheLockAdapter,
|
|
58
|
+
createRedisCacheAdapter,
|
|
59
|
+
createRedisCacheLockAdapter,
|
|
60
|
+
} from "bcp/cache";
|
|
67
61
|
```
|
|
68
62
|
|
|
69
|
-
|
|
63
|
+
Runtime model:
|
|
70
64
|
|
|
71
65
|
```text
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
Application
|
|
67
|
+
|
|
|
68
|
+
v
|
|
69
|
+
CacheStore
|
|
70
|
+
|
|
|
71
|
+
+-- CacheAdapter
|
|
72
|
+
| +-- memory
|
|
73
|
+
| +-- Redis-compatible
|
|
74
|
+
|
|
|
75
|
+
+-- CacheLockAdapter
|
|
76
|
+
| +-- memory
|
|
77
|
+
| +-- Redis-compatible
|
|
78
|
+
|
|
|
79
|
+
+-- local singleflight
|
|
80
|
+
+-- distributed cache-fill lease
|
|
81
|
+
+-- TTL / tags / paths
|
|
82
|
+
+-- metrics sink
|
|
84
83
|
```
|
|
85
84
|
|
|
86
|
-
|
|
85
|
+
`getOrSet()` deduplicates cache fills inside one process. With a shared lock adapter, multiple processes coordinate cache misses through owner-scoped leases, optional lock renewal and wait/poll behavior.
|
|
87
86
|
|
|
88
|
-
|
|
87
|
+
The Redis reference adapter uses the default hash-tagged namespace `bcp:{cache}` and does not install or own a Redis client.
|
|
89
88
|
|
|
90
89
|
New/updated sources:
|
|
91
90
|
|
|
92
91
|
| Source | Purpose |
|
|
93
92
|
| --- | --- |
|
|
94
|
-
| `
|
|
95
|
-
| `api-reference.md` | `bcp/
|
|
96
|
-
| `platform-manifest.json` |
|
|
97
|
-
| `api-manifest.json` | `bcp/
|
|
98
|
-
| `docs-web-manifest.json` |
|
|
99
|
-
| `releases/0.2.
|
|
93
|
+
| `cache-platform-v2.md` | Adapter contracts, Redis cache/locks, stampede protection, TTL/invalidation and metrics |
|
|
94
|
+
| `api-reference.md` | `bcp/cache` Cache Platform v2 APIs |
|
|
95
|
+
| `platform-manifest.json` | Cache v2 capability flags |
|
|
96
|
+
| `api-manifest.json` | Updated `bcp/cache` source/guide ownership |
|
|
97
|
+
| `docs-web-manifest.json` | Cache v2 docs navigation and `0.2.16` release route |
|
|
98
|
+
| `releases/0.2.16.md` | Cache Platform v2 release notes |
|
|
100
99
|
|
|
101
100
|
## Update rule
|
|
102
101
|
|
|
@@ -123,8 +122,10 @@ When framework behavior or public surface changes:
|
|
|
123
122
|
| `/docs/transactional-outbox-events` | `transactional-outbox-events.md` |
|
|
124
123
|
| `/docs/realtime-platform` | `realtime-platform.md` |
|
|
125
124
|
| `/docs/testing-platform` | `testing-platform.md` |
|
|
125
|
+
| `/docs/plugin-module-platform` | `plugin-module-platform.md` |
|
|
126
|
+
| `/docs/cache-platform-v2` | `cache-platform-v2.md` |
|
|
126
127
|
| `/docs/api-reference` | `api-reference.md` |
|
|
127
|
-
| `/releases/0.2.
|
|
128
|
+
| `/releases/0.2.16` | `releases/0.2.16.md` |
|
|
128
129
|
|
|
129
130
|
Every route/source pair is validated by unit tests.
|
|
130
131
|
|
|
@@ -144,6 +145,7 @@ bcp/workflow
|
|
|
144
145
|
bcp/events
|
|
145
146
|
bcp/realtime
|
|
146
147
|
bcp/testing
|
|
148
|
+
bcp/plugins
|
|
147
149
|
bcp/observability
|
|
148
150
|
bcp/server
|
|
149
151
|
bcp/server-only
|
|
@@ -154,7 +156,7 @@ The API-manifest entrypoint set must match the platform public-entrypoint set ex
|
|
|
154
156
|
|
|
155
157
|
## Release validation
|
|
156
158
|
|
|
157
|
-
Before publishing `0.2.
|
|
159
|
+
Before publishing `0.2.16`:
|
|
158
160
|
|
|
159
161
|
```bash
|
|
160
162
|
npm run typecheck
|
|
@@ -165,6 +167,6 @@ npm run test:package
|
|
|
165
167
|
npm run rc:check
|
|
166
168
|
```
|
|
167
169
|
|
|
168
|
-
|
|
170
|
+
Cache Platform v2 validation covers TTL/tag/path invalidation, local singleflight, cross-store distributed locking, lock timeout behavior, Redis command contracts, metrics integration, compiled `cache.mjs` package execution and docs/platform/API parity.
|
|
169
171
|
|
|
170
172
|
The final release tag must point to the exact commit that passed the complete RC sequence.
|
package/docs/api-manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"framework": "bcp",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.16",
|
|
5
5
|
"releaseState": "unreleased",
|
|
6
6
|
"coverage": "public-entrypoints",
|
|
7
7
|
"entrypoints": [
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"source": "packages/client/src/cache.ts",
|
|
27
27
|
"environment": "server-preferred",
|
|
28
28
|
"route": "/docs/api-reference#bcp-cache",
|
|
29
|
-
"summary": "Cache
|
|
30
|
-
"guides": ["/docs/caching"]
|
|
29
|
+
"summary": "Backward-compatible request/data caching plus Cache Platform v2 adapters, Redis-compatible distributed cache and locks, stampede protection, TTL/tag/path invalidation and metrics integration.",
|
|
30
|
+
"guides": ["/docs/caching", "/docs/cache-platform-v2", "/docs/observability"]
|
|
31
31
|
},
|
|
32
32
|
{
|
|
33
33
|
"package": "bcp/config",
|
|
@@ -106,16 +106,24 @@
|
|
|
106
106
|
"source": "packages/client/src/testing.ts",
|
|
107
107
|
"environment": "server",
|
|
108
108
|
"route": "/docs/api-reference#bcp-testing",
|
|
109
|
-
"summary": "Framework-native testing utilities for Request/Response handlers, signed auth sessions, rollback transactions, middleware, jobs, workflows, outbox delivery, realtime sockets and SSE.",
|
|
109
|
+
"summary": "Framework-native testing utilities for Request/Response handlers, signed auth sessions, rollback transactions, page/server execution, middleware, jobs, workflows, outbox delivery, realtime sockets and SSE.",
|
|
110
110
|
"guides": ["/docs/testing-platform", "/docs/authentication", "/docs/database", "/docs/durable-jobs", "/docs/workflow-orchestration", "/docs/transactional-outbox-events", "/docs/realtime-platform"]
|
|
111
111
|
},
|
|
112
|
+
{
|
|
113
|
+
"package": "bcp/plugins",
|
|
114
|
+
"source": "packages/client/src/plugins.ts",
|
|
115
|
+
"environment": "server",
|
|
116
|
+
"route": "/docs/api-reference#bcp-plugins",
|
|
117
|
+
"summary": "Plugin and module composition with dependency ordering, lifecycle hooks, typed config parsing, shared services and asynchronous extension hooks.",
|
|
118
|
+
"guides": ["/docs/plugin-module-platform", "/docs/configuration", "/docs/testing-platform", "/docs/observability"]
|
|
119
|
+
},
|
|
112
120
|
{
|
|
113
121
|
"package": "bcp/observability",
|
|
114
122
|
"source": "packages/client/src/observability.ts",
|
|
115
123
|
"environment": "server",
|
|
116
124
|
"route": "/docs/api-reference#bcp-observability",
|
|
117
125
|
"summary": "In-process metrics, Prometheus exposition, request metrics middleware and health/readiness checks.",
|
|
118
|
-
"guides": ["/docs/observability", "/docs/development-logging"]
|
|
126
|
+
"guides": ["/docs/observability", "/docs/development-logging", "/docs/cache-platform-v2"]
|
|
119
127
|
},
|
|
120
128
|
{
|
|
121
129
|
"package": "bcp/server",
|
package/docs/api-reference.md
CHANGED
|
@@ -26,9 +26,66 @@ Related guide: [Hydration](hydration.md).
|
|
|
26
26
|
|
|
27
27
|
## `bcp/cache`
|
|
28
28
|
|
|
29
|
-
Caching
|
|
29
|
+
Caching APIs include the original process-local request/data cache plus Cache Platform v2 provider contracts for shared production caches.
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
Legacy-compatible exports remain:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import {
|
|
35
|
+
cache,
|
|
36
|
+
clearCache,
|
|
37
|
+
dedupe,
|
|
38
|
+
getCacheStats,
|
|
39
|
+
revalidatePath,
|
|
40
|
+
revalidateTag,
|
|
41
|
+
} from "bcp/cache";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Cache Platform v2 adds:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import {
|
|
48
|
+
createCacheMetrics,
|
|
49
|
+
createCacheStore,
|
|
50
|
+
createMemoryCacheAdapter,
|
|
51
|
+
createMemoryCacheLockAdapter,
|
|
52
|
+
createRedisCacheAdapter,
|
|
53
|
+
createRedisCacheLockAdapter,
|
|
54
|
+
type CacheAdapter,
|
|
55
|
+
type CacheAdapterEntry,
|
|
56
|
+
type CacheAdapterSetOptions,
|
|
57
|
+
type CacheGetOrSetOptions,
|
|
58
|
+
type CacheLockAdapter,
|
|
59
|
+
type CacheMetricsRegistryLike,
|
|
60
|
+
type CacheMetricsSink,
|
|
61
|
+
type CacheStore,
|
|
62
|
+
type CacheStoreEvent,
|
|
63
|
+
type CacheStoreOptions,
|
|
64
|
+
type CacheStoreSetOptions,
|
|
65
|
+
type CacheStoreStats,
|
|
66
|
+
type MemoryCacheAdapter,
|
|
67
|
+
type MemoryCacheLockAdapter,
|
|
68
|
+
type RedisCacheAdapter,
|
|
69
|
+
type RedisCacheAdapterOptions,
|
|
70
|
+
type RedisCacheCommandClient,
|
|
71
|
+
type RedisCacheLockAdapter,
|
|
72
|
+
type RedisCacheLockAdapterOptions,
|
|
73
|
+
} from "bcp/cache";
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
`createCacheStore()` exposes async `get()`, `set()`, `delete()`, `clear()`, `revalidateTag()`, `revalidatePath()`, `getOrSet()`, `stats()` and `close()` operations.
|
|
77
|
+
|
|
78
|
+
`getOrSet()` always provides local singleflight deduplication. When a `CacheLockAdapter` is supplied, cache fills can also coordinate across multiple application instances with owner-scoped leases, optional renewal and configurable contention timeout behavior.
|
|
79
|
+
|
|
80
|
+
`createRedisCacheAdapter()` and `createRedisCacheLockAdapter()` use a minimal `sendCommand()` client contract. BCP does not install or own a Redis library/connection. The default namespace is `bcp:{cache}` for Redis Cluster hash-slot locality.
|
|
81
|
+
|
|
82
|
+
Cache Store v2 uses millisecond TTL (`ttlMs`), while the original `cache()` API keeps its existing `revalidate`-seconds contract.
|
|
83
|
+
|
|
84
|
+
`createCacheMetrics()` adapts cache events to the existing BCP `MetricsRegistry` shape without coupling the cache package directly to a specific exporter.
|
|
85
|
+
|
|
86
|
+
Prepared npm packages compile the runtime entrypoint to `packages/client/src/cache.mjs`.
|
|
87
|
+
|
|
88
|
+
Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md), [Observability Platform v2](observability.md).
|
|
32
89
|
|
|
33
90
|
## `bcp/config`
|
|
34
91
|
|
|
@@ -308,11 +365,59 @@ The package is server-only; the client boundary validator rejects `bcp/testing`
|
|
|
308
365
|
|
|
309
366
|
Related guides: [Testing Platform](testing-platform.md), [Authentication](authentication.md), [Database](database.md), [Durable Jobs](durable-jobs.md), [Workflow Orchestration](workflow-orchestration.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Realtime Platform](realtime-platform.md).
|
|
310
367
|
|
|
368
|
+
## `bcp/plugins`
|
|
369
|
+
|
|
370
|
+
Server-only Plugin & Module Platform APIs added in `0.2.15`.
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
import {
|
|
374
|
+
createPluginHookBus,
|
|
375
|
+
createPluginHost,
|
|
376
|
+
createPluginServiceRegistry,
|
|
377
|
+
defineModule,
|
|
378
|
+
definePlugin,
|
|
379
|
+
PluginDependencyError,
|
|
380
|
+
PluginLifecycleError,
|
|
381
|
+
type PluginConfigParser,
|
|
382
|
+
type PluginConfigSchema,
|
|
383
|
+
type PluginContext,
|
|
384
|
+
type PluginDefinition,
|
|
385
|
+
type PluginHookBus,
|
|
386
|
+
type PluginHookHandler,
|
|
387
|
+
type PluginHost,
|
|
388
|
+
type PluginHostOptions,
|
|
389
|
+
type PluginHostView,
|
|
390
|
+
type PluginModule,
|
|
391
|
+
type PluginRecord,
|
|
392
|
+
type PluginServiceKey,
|
|
393
|
+
type PluginServiceRegistry,
|
|
394
|
+
type PluginState,
|
|
395
|
+
} from "bcp/plugins";
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
`createPluginHost()` resolves required and optional plugin dependencies and starts plugins in topological order. `stop()` and `close()` shut them down/dispose them in reverse dependency order.
|
|
399
|
+
|
|
400
|
+
`defineModule()` groups reusable plugin definitions while preserving one global host dependency graph.
|
|
401
|
+
|
|
402
|
+
Plugin configuration can be parsed with a schema/parser during setup. Values from `PluginHostOptions.configs` override plugin-local defaults before parsing.
|
|
403
|
+
|
|
404
|
+
`PluginServiceRegistry` provides shared string/Symbol-keyed services. `PluginHookBus` provides awaited, in-process extension hooks in registration order.
|
|
405
|
+
|
|
406
|
+
Missing dependencies and dependency cycles throw `PluginDependencyError`. Setup/start failures surface `PluginLifecycleError`; startup failures roll back plugins that already started in the current transition.
|
|
407
|
+
|
|
408
|
+
`host.plugin()` and `host.plugins()` expose inspectable lifecycle records.
|
|
409
|
+
|
|
410
|
+
`bcp/plugins` is server-only and is rejected from page/client bundles.
|
|
411
|
+
|
|
412
|
+
Related guides: [Plugin & Module Platform](plugin-module-platform.md), [Configuration](configuration.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
|
|
413
|
+
|
|
311
414
|
## `bcp/observability`
|
|
312
415
|
|
|
313
416
|
Server-only Observability Platform v2 APIs for process-local counters, gauges, histograms, Prometheus exposition, request metrics middleware and health/readiness checks.
|
|
314
417
|
|
|
315
|
-
|
|
418
|
+
`Cache Platform v2` can connect to this registry through `createCacheMetrics()` from `bcp/cache`.
|
|
419
|
+
|
|
420
|
+
Related guides: [Observability Platform v2](observability.md), [Logging](development-logging.md), [Cache Platform v2](cache-platform-v2.md).
|
|
316
421
|
|
|
317
422
|
## `bcp/server`
|
|
318
423
|
|