@chidchanun/bcp 0.2.16 → 0.2.18

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.
@@ -1,429 +1,360 @@
1
1
  # API Reference
2
2
 
3
- BCP Framework exposes a small set of supported package entrypoints. Import application APIs through these entrypoints instead of private files under `packages/`.
3
+ BCP Framework exposes supported package entrypoints through the `bcp` package. Application code should import these public entrypoints instead of private implementation files under `packages/`.
4
4
 
5
5
  The machine-readable source for this page is `docs/api-manifest.json`.
6
6
 
7
7
  ## `bcp`
8
8
 
9
- Universal React application APIs.
9
+ Universal React application APIs for routing, navigation, layouts, metadata, loaders, route guards, form actions and islands.
10
10
 
11
- Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound`, loader/action/guard hooks and router/navigation APIs.
12
-
13
- Related guides: [Routing](routing.md), [Server Data Loaders](server-data-loaders.md), [Route Guards](route-guards.md), [Form Actions](form-actions.md), [Testing Platform](testing-platform.md).
11
+ Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound` and loader/action/guard hooks.
14
12
 
15
13
  ## `bcp/island`
16
14
 
17
- Partial-hydration island APIs.
18
-
19
- ```ts
20
- import {
21
- createIsland,
22
- } from "bcp/island";
23
- ```
24
-
25
- Related guide: [Hydration](hydration.md).
15
+ Partial-hydration island APIs including `createIsland` and island loading strategy types.
26
16
 
27
17
  ## `bcp/cache`
28
18
 
29
- Caching APIs include the original process-local request/data cache plus Cache Platform v2 provider contracts for shared production caches.
19
+ Backward-compatible request/data caching plus Cache Platform v2 shared-store APIs.
30
20
 
31
- Legacy-compatible exports remain:
21
+ Important exports:
32
22
 
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";
23
+ ```text
24
+ cache
25
+ dedupe
26
+ clearCache
27
+ getCacheStats
28
+ revalidateTag
29
+ revalidatePath
30
+ createCacheStore
31
+ createMemoryCacheAdapter
32
+ createMemoryCacheLockAdapter
33
+ createRedisCacheAdapter
34
+ createRedisCacheLockAdapter
35
+ createCacheMetrics
74
36
  ```
75
37
 
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`.
38
+ Public contracts include `CacheAdapter`, `CacheLockAdapter`, `CacheStore`, cache statistics/options and Redis command-client adapter types.
87
39
 
88
- Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md), [Observability Platform v2](observability.md).
40
+ Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md).
89
41
 
90
42
  ## `bcp/config`
91
43
 
92
- Typed framework configuration, application environment-schema validation and diagnostics APIs.
44
+ Typed BCP configuration, environment-schema validation and diagnostics APIs.
93
45
 
94
- Related guides: [Configuration](configuration.md), [Environment Validation](environment-validation.md).
46
+ Prepared npm packages resolve the production runtime to compiled `config.mjs` in `0.2.18+`.
47
+
48
+ Related guides: [Configuration](configuration.md), [Environment Validation](environment-validation.md), [Deployment Platform v2](deployment-platform-v2.md).
95
49
 
96
50
  ## `bcp/validation`
97
51
 
98
52
  Typed validation primitives, parse helpers and `ValidationError`.
99
53
 
100
- Related guide: [Validation](validation.md).
101
-
102
54
  ## `bcp/error`
103
55
 
104
56
  Structured HTTP error helpers and response classification.
105
57
 
106
- Related guide: [Error Handling](error-handling.md).
107
-
108
58
  ## `bcp/database`
109
59
 
110
- Server-only Database Platform v2 APIs.
60
+ Server-only provider-neutral SQL APIs for MySQL, PostgreSQL and SQLite.
111
61
 
112
- Built-in SQL providers are MySQL, PostgreSQL and SQLite. `BcpDatabase` instances expose lazy query/execute/transaction operations plus explicit `connect()`, `disconnect()` and backward-compatible `close()` lifecycle methods.
62
+ Core capabilities include query/execute, transactions, lifecycle and migrations.
113
63
 
114
- Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Testing Platform](testing-platform.md).
64
+ Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md).
115
65
 
116
66
  ## `bcp/auth`
117
67
 
118
- Server-only authentication and authorization APIs.
68
+ Server-only Authentication Platform v2 and Authorization & Security v2 APIs.
119
69
 
120
- The default authentication mode remains stateless signed JWT-cookie authentication. Applications may opt into server-side session stores, revocation, logout-all, idle timeout, role/permission guards and resource-aware authorization policies.
70
+ Capabilities include JWT-cookie sessions, optional server-side session stores, revocation, logout-all, idle timeout, role/permission guards, policies, same-origin protection and auth/guest guards.
121
71
 
122
- Related guides: [Authentication](authentication.md), [Auth Session Stores](auth-session-store.md), [Auth Route Guards](auth-route-guards.md), [Authorization & Security v2](authorization-security.md), [JWT Sessions](session-auth.md), [Testing Platform](testing-platform.md).
72
+ Prepared npm packages resolve the runtime to compiled `auth.mjs` in `0.2.18+`.
123
73
 
124
74
  ## `bcp/jobs`
125
75
 
126
- Server-only Background Jobs, Job Scheduling and Durable Jobs APIs.
76
+ Server-only background jobs, scheduling and durable job APIs.
127
77
 
128
- Core queue APIs include `createJobQueue()`, `createMemoryJobQueueAdapter()`, queue/worker records, retry/backoff, visibility leases, heartbeat renewal, stale recovery, DLQ operations, retention cleanup and queue statistics.
78
+ Important exports:
129
79
 
130
- Scheduling APIs include `createJobScheduler()`, `createMemoryJobScheduleStore()`, `nextCronTime()` and `nextScheduleTime()`.
131
-
132
- Durable Redis-compatible APIs added in `0.2.10` include `createRedisJobQueueAdapter()` and `createRedisJobScheduleStore()`.
133
-
134
- BCP does not install a Redis library and does not create the connection. Applications own authentication, TLS, Cluster/Sentinel configuration and connection shutdown.
80
+ ```text
81
+ createJobQueue
82
+ createMemoryJobQueueAdapter
83
+ createRedisJobQueueAdapter
84
+ createJobScheduler
85
+ createMemoryJobScheduleStore
86
+ createRedisJobScheduleStore
87
+ nextCronTime
88
+ nextScheduleTime
89
+ ```
135
90
 
136
- The processing model is at-least-once. Handlers that perform non-idempotent external side effects should use application-level idempotency protection.
91
+ Capabilities include delay, retry/backoff, worker concurrency, cancellation, visibility leases, heartbeat renewal, stale recovery, DLQ/requeue, retention cleanup, queue statistics and recurring interval/UTC cron schedules.
137
92
 
138
- Related guides: [Background Jobs Platform](background-jobs.md), [Job Scheduling Platform](job-scheduling.md), [Durable Jobs Platform](durable-jobs.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
93
+ Processing remains at-least-once; non-repeatable external side effects should use application-level idempotency.
139
94
 
140
95
  ## `bcp/workflow`
141
96
 
142
- Server-only Workflow Orchestration APIs added in `0.2.11`.
143
-
144
- ```ts
145
- import {
146
- createMemoryWorkflowStore,
147
- createWorkflow,
148
- } from "bcp/workflow";
149
- ```
150
-
151
- `createWorkflow()` defines persistent server-side workflows with sequential steps, parallel groups, per-step retry policies, persisted delays and compensation handlers.
152
-
153
- Workflow controls include:
97
+ Server-only Workflow Orchestration APIs.
154
98
 
155
99
  ```text
156
- start()
157
- run()
158
- get()
159
- list()
160
- resume()
161
- retry()
162
- cancel()
163
- compensate()
164
- close()
100
+ createWorkflow
101
+ createMemoryWorkflowStore
165
102
  ```
166
103
 
167
- When an existing `BackgroundJobQueue` is supplied, workflow execution and delay continuation can run through `bcp/jobs`.
168
-
169
- `WorkflowStore.claim()` / `release()` form the run-level lease boundary for multi-instance stores.
104
+ Workflow controls include `start`, `run`, `get`, `list`, `resume`, `retry`, `cancel`, `compensate` and `close`.
170
105
 
171
- Related guides: [Workflow Orchestration](workflow-orchestration.md), [Durable Jobs Platform](durable-jobs.md), [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
106
+ Capabilities include sequential/parallel steps, per-step retry, persisted delays, compensation, run leases and optional execution through `bcp/jobs`.
172
107
 
173
108
  ## `bcp/events`
174
109
 
175
- Server-only Transactional Outbox & Events APIs added in `0.2.12`.
110
+ Server-only Transactional Outbox & Events APIs.
176
111
 
177
- ```ts
178
- import {
179
- createEventBus,
180
- createMemoryOutboxStore,
181
- createOutboxDispatcher,
182
- createOutboxMigrationSql,
183
- createSqlOutboxStore,
184
- createTransactionalOutbox,
185
- } from "bcp/events";
112
+ ```text
113
+ createTransactionalOutbox
114
+ createMemoryOutboxStore
115
+ createSqlOutboxStore
116
+ createOutboxMigrationSql
117
+ createOutboxDispatcher
118
+ createEventBus
186
119
  ```
187
120
 
188
- `createTransactionalOutbox()` writes an event through the same `TransactionDatabase` used by `db.transaction()`, allowing business rows and outbox rows to commit or roll back together.
189
-
190
- `createSqlOutboxStore()` supports MySQL, PostgreSQL and SQLite. `createOutboxMigrationSql()` generates the outbox table/index DDL.
191
-
192
- `createOutboxDispatcher()` supports batched claims, leases, stale recovery, retry/backoff, terminal failure, job-queue handoff, custom publishing, local event-bus delivery and runner lifecycle.
193
-
194
- Delivery is at-least-once; consumers should use idempotency controls for non-repeatable side effects.
195
-
196
- Related guides: [Transactional Outbox & Events](transactional-outbox-events.md), [Database](database.md), [Durable Jobs Platform](durable-jobs.md), [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
121
+ SQL outbox storage supports MySQL, PostgreSQL and SQLite. Dispatch supports batched claims, leases, stale recovery, retry/backoff, terminal failure, durable-job handoff and custom publishing.
197
122
 
198
123
  ## `bcp/realtime`
199
124
 
200
- Server-only Realtime Platform APIs added in `0.2.13`.
125
+ Server-only realtime APIs for channels/rooms, broker delivery, presence, channel authorization, socket adapters, heartbeat and Server-Sent Events.
201
126
 
202
- ```ts
203
- import {
204
- createMemoryRealtimeBroker,
205
- createMemoryRealtimePresenceStore,
206
- createRealtime,
207
- createRealtimeSseResponse,
208
- type RealtimeAuthenticate,
209
- type RealtimeAuthorizeChannel,
210
- type RealtimeBroker,
211
- type RealtimeBroadcastOptions,
212
- type RealtimeConnection,
213
- type RealtimeEnvelope,
214
- type RealtimeEventContext,
215
- type RealtimeEventHandler,
216
- type RealtimeHeartbeatOptions,
217
- type RealtimeHeartbeatRunner,
218
- type RealtimeHub,
219
- type RealtimeJoinOptions,
220
- type RealtimeOptions,
221
- type RealtimePresenceMember,
222
- type RealtimePresenceStore,
223
- type RealtimeSocket,
224
- type RealtimeSseOptions,
225
- } from "bcp/realtime";
127
+ ```text
128
+ createRealtime
129
+ createMemoryRealtimeBroker
130
+ createMemoryRealtimePresenceStore
131
+ createRealtimeSseResponse
226
132
  ```
227
133
 
228
- `createRealtime()` creates a server-side hub. Connections can `join()`, `leave()`, `emit()`, `send()`, `touch()` and `disconnect()`.
229
-
230
- `RealtimeBroker` is the cross-hub pub/sub boundary and `RealtimePresenceStore` is the channel-presence boundary. Built-in memory implementations are intended for tests/single-process use; shared deployments can supply provider adapters.
231
-
232
- `RealtimeOptions.authenticate` can resolve identity from a Request/connection payload, while `authorizeChannel` runs before channel membership is accepted.
233
-
234
- BCP does not install a WebSocket provider. `RealtimeSocket` defines the minimal transport surface consumed by `hub.attachSocket()`.
235
-
236
- `hub.sse()` and `createRealtimeSseResponse()` expose Web-standard Server-Sent Events responses with abort, filtering, retry hint and keep-alive options.
237
-
238
- Realtime delivery is transient. Use database/outbox/jobs/workflows for durable state and refetch durable state/history after reconnect when catch-up is required.
239
-
240
- Related guides: [Realtime Platform](realtime-platform.md), [Authentication](authentication.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
134
+ BCP intentionally does not install a WebSocket server library. Applications adapt the selected provider through `RealtimeSocket`.
241
135
 
242
136
  ## `bcp/testing`
243
137
 
244
- Server-only Testing Platform APIs added in `0.2.14`.
138
+ Server-only framework-native testing utilities. BCP does not require Jest or Vitest.
245
139
 
246
- ```ts
247
- import {
248
- createFakeClock,
249
- createJobTestHarness,
250
- createOutboxTestHarness,
251
- createRealtimeTestHarness,
252
- createRealtimeTestSocket,
253
- createRouteTestHandler,
254
- createSequenceIdFactory,
255
- createTestApp,
256
- createTestAuthSession,
257
- createTestFormData,
258
- createWorkflowTestHarness,
259
- expectResponse,
260
- readSseEvents,
261
- runTestMiddleware,
262
- runTestPageAction,
263
- runTestPageGuards,
264
- runTestPageLoader,
265
- withTestTransaction,
266
- type CreateTestAuthSessionOptions,
267
- type FakeClock,
268
- type JobTestHarness,
269
- type OutboxTestHarness,
270
- type ParsedSseEvent,
271
- type RealtimeTestConnection,
272
- type RealtimeTestHarness,
273
- type RealtimeTestSocket,
274
- type TestApp,
275
- type TestAppOptions,
276
- type TestAuthSession,
277
- type TestPageActionOptions,
278
- type TestPageContextOptions,
279
- type TestPageGuardOptions,
280
- type TestRequestHandler,
281
- type TestRequestOptions,
282
- type TestResponseExpectation,
283
- type TestRouteFunction,
284
- type TestRouteHandlerOptions,
285
- type TestRouteMethod,
286
- type TestRouteModule,
287
- type TestTransactionDatabase,
288
- type WorkflowTestHarness,
289
- } from "bcp/testing";
290
- ```
291
-
292
- ### Request application harness
140
+ Important APIs include:
293
141
 
294
- `createTestApp()` runs a Web-standard `Request -> Response` handler with convenience methods for GET/POST/PUT/PATCH/DELETE, JSON bodies, mutable default headers and an in-memory cookie jar that consumes `Set-Cookie` responses.
295
-
296
- ### API route module testing
142
+ ```text
143
+ createTestApp
144
+ createRouteTestHandler
145
+ expectResponse
146
+ createTestAuthSession
147
+ withTestTransaction
148
+ runTestMiddleware
149
+ runTestPageLoader
150
+ runTestPageGuards
151
+ runTestPageAction
152
+ createFakeClock
153
+ createSequenceIdFactory
154
+ createJobTestHarness
155
+ createWorkflowTestHarness
156
+ createOutboxTestHarness
157
+ createRealtimeTestSocket
158
+ createRealtimeTestHarness
159
+ readSseEvents
160
+ ```
297
161
 
298
- `createRouteTestHandler()` adapts BCP-style method exports (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD`, `OPTIONS`) to a Request handler. Missing methods return 405 with an `Allow` header.
162
+ ## `bcp/plugins`
299
163
 
300
- Return values are normalized for tests: Response is preserved, strings become text Responses, null/undefined become 204, and other values become JSON.
164
+ Server-only Plugin & Module Platform APIs.
301
165
 
302
- ### Page loader, guard and form action testing
166
+ ```text
167
+ definePlugin
168
+ defineModule
169
+ createPluginHost
170
+ createPluginServiceRegistry
171
+ createPluginHookBus
172
+ ```
303
173
 
304
- `runTestPageGuards()` executes one or more guards through the production `executePageGuardFunctions()` path. Guard data is chained in order and redirect/other Response short-circuits are preserved.
174
+ Capabilities include required/optional dependency ordering, setup/start/stop/dispose lifecycle, startup rollback, typed configuration parsing, shared services and awaited in-process hooks.
305
175
 
306
- `runTestPageLoader()` invokes the production `executePageLoaderFunction()` path with test params, URL/search params and optional guard data. The returned value is the normal `PageLoaderExecution` contract.
176
+ ## `bcp/observability`
307
177
 
308
- `runTestPageAction()` invokes the production `executePageActionFunction()` path, including action-name/method validation, guard data, FormData and Response/data handling.
178
+ Server-only metrics, health and tracing APIs.
309
179
 
310
- `createTestFormData()` creates a FormData object from string/Blob fields and supports repeated values.
180
+ Metrics/health APIs:
311
181
 
312
- ### Response assertions
182
+ ```text
183
+ createMetricsRegistry
184
+ createMetricsResponse
185
+ createRequestMetricsMiddleware
186
+ createHealthRegistry
187
+ ```
313
188
 
314
- `expectResponse()` exposes lightweight runner-neutral assertions:
189
+ Observability Platform v3 tracing APIs:
315
190
 
316
191
  ```text
317
- status()
318
- header()
319
- text()
320
- json()
321
- jsonMatches()
192
+ createTracer
193
+ createRequestTracingMiddleware
194
+ createTraceCarrier
195
+ runWithTraceCarrier
196
+ runWithTraceContext
197
+ currentTraceContext
198
+ injectTraceHeaders
199
+ extractTraceHeaders
200
+ formatTraceparent
201
+ parseTraceparent
202
+ createMemoryTraceSpanExporter
203
+ createCompositeTraceSpanExporter
204
+ createTraceMetricsExporter
205
+ getTraceLogFields
322
206
  ```
323
207
 
324
- BCP does not require Jest/Vitest assertion APIs.
208
+ Important tracing contracts include `Tracer`, `TraceContext`, `TraceCarrier`, `TraceSpan`, `TraceSpanRecord`, `TraceSpanExporter`, `TraceSpanKind` and `TraceSpanStatus`.
325
209
 
326
- ### Auth testing
210
+ Active trace context uses Node `AsyncLocalStorage`. W3C `traceparent`, optional `tracestate` and `x-correlation-id` can cross HTTP boundaries, while trace carriers can be stored in application-owned job/workflow/event/realtime payload metadata.
327
211
 
328
- `createTestAuthSession()` uses the production `createSessionToken()` implementation, including HS256 signature, issuer/audience and expiration semantics. It can also register the matching server-side record in an `AuthSessionStore`.
212
+ Prepared npm packages expose compiled `observability.mjs`.
329
213
 
330
- This allows route/auth tests to use a real BCP session cookie instead of introducing a test-only identity header.
214
+ Related guides: [Observability Platform v2](observability.md), [Observability Platform v3](observability-v3.md).
331
215
 
332
- ### Database rollback testing
216
+ ## `bcp/deployment`
333
217
 
334
- `withTestTransaction()` executes a callback in a real BCP database transaction and deliberately rejects the transaction with an internal rollback sentinel after the test callback succeeds. The callback result is returned to the test while the transaction is rolled back.
218
+ Server-only Deployment Platform v2 lifecycle APIs introduced in `0.2.18`.
335
219
 
336
- Application callback errors remain unchanged and are not swallowed.
220
+ Primary functions:
337
221
 
338
- ### Middleware testing
339
-
340
- `runTestMiddleware()` invokes the actual Middleware System v2 onion pipeline through `executeMiddlewarePipeline()` and supports a custom downstream Request handler.
222
+ ```ts
223
+ import {
224
+ createDeploymentDiagnosticsResponse,
225
+ createDeploymentReadinessResponse,
226
+ createDeploymentRuntime,
227
+ } from "bcp/deployment";
228
+ ```
341
229
 
342
- ### Deterministic utilities
230
+ Important public types:
343
231
 
344
- `createFakeClock()` exposes `now()`, `set()`, `advance()` and `reset()` for time-sensitive queues/workflows/schedulers.
232
+ ```text
233
+ DeploymentRuntime
234
+ DeploymentRuntimeOptions
235
+ DeploymentRuntimeState
236
+ DeploymentResource
237
+ DeploymentResourceContext
238
+ DeploymentResourceStatus
239
+ DeploymentReadinessResult
240
+ DeploymentReadinessReport
241
+ DeploymentReadinessItem
242
+ DeploymentDiagnosticsReport
243
+ DeploymentDiagnosticsResource
244
+ DeploymentMetadata
245
+ DeploymentSignalOptions
246
+ DeploymentShutdownOptions
247
+ ```
345
248
 
346
- `createSequenceIdFactory()` creates deterministic IDs for stable assertions.
249
+ Create a runtime:
347
250
 
348
- ### Infrastructure harnesses
251
+ ```ts
252
+ const deployment =
253
+ createDeploymentRuntime({
254
+ serviceName: "orders-api",
255
+ version: "1.0.0",
256
+ });
257
+ ```
349
258
 
350
- `createJobTestHarness()` drains currently eligible work through the real `BackgroundJobQueue.processNext()` API and exposes record/count assertions.
259
+ Register resources:
351
260
 
352
- `createWorkflowTestHarness()` can start/run workflows until terminal or waiting state and optionally force persisted delays to resume.
261
+ ```ts
262
+ deployment.addResource({
263
+ name: "database",
353
264
 
354
- `createOutboxTestHarness()` dispatches through the actual `OutboxDispatcher` and exposes event/state/statistics helpers.
265
+ async start() {
266
+ await db.connect();
267
+ },
355
268
 
356
- `createRealtimeTestSocket()` implements the `RealtimeSocket` adapter contract entirely in memory. `createRealtimeTestHarness()` connects that socket to a real `RealtimeHub` and can assert server-sent channel events.
269
+ ready() {
270
+ return true;
271
+ },
357
272
 
358
- `readSseEvents()` reads event-stream Responses, ignores comment/retry frames and JSON-decodes `data:` payloads when possible.
273
+ async stop() {
274
+ await db.close();
275
+ },
276
+ });
277
+ ```
359
278
 
360
- ### Runner neutrality and boundary
279
+ Resources start in registration order and stop in reverse order. If startup fails, previously started resources are rolled back in reverse order.
361
280
 
362
- `bcp/testing` has no dependency on Jest or Vitest. BCP's own suite uses Node `node:test`, but the helpers can be called from another runner.
281
+ Runtime states:
363
282
 
364
- The package is server-only; the client boundary validator rejects `bcp/testing` from pages/client islands.
283
+ ```text
284
+ idle
285
+ starting
286
+ ready
287
+ draining
288
+ stopped
289
+ failed
290
+ ```
365
291
 
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).
292
+ Readiness:
367
293
 
368
- ## `bcp/plugins`
294
+ ```ts
295
+ const report =
296
+ await deployment.readiness();
297
+ ```
369
298
 
370
- Server-only Plugin & Module Platform APIs added in `0.2.15`.
299
+ or:
371
300
 
372
301
  ```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";
302
+ return createDeploymentReadinessResponse(
303
+ deployment
304
+ );
396
305
  ```
397
306
 
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.
307
+ The response is `200` when the runtime and all resource checks are ready, otherwise `503`.
399
308
 
400
- `defineModule()` groups reusable plugin definitions while preserving one global host dependency graph.
309
+ Diagnostics:
401
310
 
402
- Plugin configuration can be parsed with a schema/parser during setup. Values from `PluginHostOptions.configs` override plugin-local defaults before parsing.
311
+ ```ts
312
+ const report =
313
+ await deployment.diagnostics();
314
+ ```
403
315
 
404
- `PluginServiceRegistry` provides shared string/Symbol-keyed services. `PluginHookBus` provides awaited, in-process extension hooks in registration order.
316
+ or:
405
317
 
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.
318
+ ```ts
319
+ return createDeploymentDiagnosticsResponse(
320
+ deployment
321
+ );
322
+ ```
407
323
 
408
- `host.plugin()` and `host.plugins()` expose inspectable lifecycle records.
324
+ Metadata includes service/deployment identity, process ID, Node version, platform, architecture and startup time. Optional environment-backed identity fields use:
409
325
 
410
- `bcp/plugins` is server-only and is rejected from page/client bundles.
326
+ ```text
327
+ BCP_DEPLOYMENT_ID
328
+ BCP_INSTANCE_ID
329
+ BCP_RELEASE
330
+ NODE_ENV
331
+ ```
411
332
 
412
- Related guides: [Plugin & Module Platform](plugin-module-platform.md), [Configuration](configuration.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
333
+ Install process signal handlers:
413
334
 
414
- ## `bcp/observability`
335
+ ```ts
336
+ const remove =
337
+ deployment.installSignalHandlers();
338
+ ```
339
+
340
+ Defaults are `SIGTERM` and `SIGINT`.
341
+
342
+ Integrate with the framework shutdown-hook registry:
415
343
 
416
- Server-only Observability Platform v2 APIs for process-local counters, gauges, histograms, Prometheus exposition, request metrics middleware and health/readiness checks.
344
+ ```ts
345
+ const unregister =
346
+ deployment.registerShutdownHook();
347
+ ```
417
348
 
418
- `Cache Platform v2` can connect to this registry through `createCacheMetrics()` from `bcp/cache`.
349
+ Prepared npm packages expose compiled `deployment.mjs`.
419
350
 
420
- Related guides: [Observability Platform v2](observability.md), [Logging](development-logging.md), [Cache Platform v2](cache-platform-v2.md).
351
+ Related guides: [Deployment Platform v2](deployment-platform-v2.md), [Application Packaging](application-packaging.md), [Production Hardening](production-hardening.md), [Observability Platform v3](observability-v3.md).
421
352
 
422
353
  ## `bcp/server`
423
354
 
424
- Server request/runtime APIs including request context, cookies, CSRF and same-origin protection, logging, graceful shutdown hooks, multipart upload helpers, storage adapters, file delivery, response helpers and low-level session primitives.
355
+ Server request/runtime APIs including request context, cookies, CSRF/same-origin protection, logging, graceful shutdown hooks, multipart upload helpers, storage adapters, file delivery, response helpers and low-level session primitives.
425
356
 
426
- Related guides: [Server Request APIs](server-request-apis.md), [Authorization & Security v2](authorization-security.md), [File Upload](file-upload.md), [Storage](storage.md), [Storage Ecosystem](storage-ecosystem.md), [Production Hardening](production-hardening.md), [Testing Platform](testing-platform.md).
357
+ Prepared npm packages resolve this runtime to compiled `server.mjs` in `0.2.18+`.
427
358
 
428
359
  ## `bcp/server-only`
429
360
 
@@ -433,16 +364,37 @@ Server-only module boundary marker.
433
364
  import "bcp/server-only";
434
365
  ```
435
366
 
436
- Related guide: [Application Modules](application-modules.md).
437
-
438
367
  ## `bcp/middleware`
439
368
 
440
- Middleware System v2 APIs and types.
369
+ Middleware System v2 request/response pipeline types and helpers.
370
+
371
+ Prepared npm packages resolve this runtime to compiled `middleware.mjs` in `0.2.18+`.
372
+
373
+ ## Prepared server runtime map
374
+
375
+ For `0.2.18`, the prepared npm package uses compiled ESM runtime defaults for:
376
+
377
+ ```text
378
+ bcp/cache -> cache.mjs
379
+ bcp/config -> config.mjs
380
+ bcp/database -> database.mjs
381
+ bcp/auth -> auth.mjs
382
+ bcp/jobs -> jobs.mjs
383
+ bcp/workflow -> workflow.mjs
384
+ bcp/events -> events.mjs
385
+ bcp/realtime -> realtime.mjs
386
+ bcp/testing -> testing.mjs
387
+ bcp/plugins -> plugins.mjs
388
+ bcp/observability -> observability.mjs
389
+ bcp/deployment -> deployment.mjs
390
+ bcp/server -> server.mjs
391
+ bcp/middleware -> middleware.mjs
392
+ ```
441
393
 
442
- Related guides: [Middleware](middleware.md), [Testing Platform](testing-platform.md).
394
+ Types remain sourced from the TypeScript public entrypoint files.
443
395
 
444
396
  ## Stability
445
397
 
446
- Only package entrypoints listed in both `docs/platform-manifest.json` and `docs/api-manifest.json` are part of the documented platform surface.
398
+ Only entrypoints listed in both `docs/platform-manifest.json` and `docs/api-manifest.json` are part of the documented platform surface.
447
399
 
448
- Files under internal `packages/*` paths are framework implementation details unless re-exported through a documented public package entrypoint.
400
+ Files under internal `packages/*` paths are implementation details unless re-exported through a documented public package entrypoint.