@chidchanun/bcp 0.2.15 → 0.2.17

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,14 +1,14 @@
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.
11
+ Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound` and loader/action/guard hooks.
12
12
 
13
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).
14
14
 
@@ -26,13 +26,37 @@ Related guide: [Hydration](hydration.md).
26
26
 
27
27
  ## `bcp/cache`
28
28
 
29
- Caching, deduplication, statistics and path/tag revalidation primitives.
29
+ Backward-compatible request/data caching plus Cache Platform v2 shared-store APIs.
30
30
 
31
- Related guide: [Caching](caching.md).
31
+ Legacy APIs:
32
+
33
+ ```text
34
+ cache
35
+ dedupe
36
+ clearCache
37
+ getCacheStats
38
+ revalidateTag
39
+ revalidatePath
40
+ ```
41
+
42
+ Cache Platform v2 APIs:
43
+
44
+ ```text
45
+ createCacheStore
46
+ createMemoryCacheAdapter
47
+ createMemoryCacheLockAdapter
48
+ createRedisCacheAdapter
49
+ createRedisCacheLockAdapter
50
+ createCacheMetrics
51
+ ```
52
+
53
+ Public contracts include `CacheAdapter`, `CacheLockAdapter`, `CacheStore`, cache statistics/options and Redis command-client adapter types.
54
+
55
+ Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md), [Observability Platform v3](observability-v3.md).
32
56
 
33
57
  ## `bcp/config`
34
58
 
35
- Typed framework configuration, application environment-schema validation and diagnostics APIs.
59
+ Typed BCP configuration, environment-schema validation and diagnostics APIs.
36
60
 
37
61
  Related guides: [Configuration](configuration.md), [Environment Validation](environment-validation.md).
38
62
 
@@ -50,321 +74,300 @@ Related guide: [Error Handling](error-handling.md).
50
74
 
51
75
  ## `bcp/database`
52
76
 
53
- Server-only Database Platform v2 APIs.
77
+ Server-only provider-neutral SQL APIs for MySQL, PostgreSQL and SQLite.
54
78
 
55
- 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.
79
+ Core capabilities include query/execute, transactions, lifecycle, migration stores and migration execution.
56
80
 
57
- Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Testing Platform](testing-platform.md).
81
+ Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
58
82
 
59
83
  ## `bcp/auth`
60
84
 
61
- Server-only authentication and authorization APIs.
85
+ Server-only Authentication Platform v2 and Authorization & Security v2 APIs.
62
86
 
63
- 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.
87
+ 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.
64
88
 
65
- 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).
89
+ 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).
66
90
 
67
91
  ## `bcp/jobs`
68
92
 
69
- Server-only Background Jobs, Job Scheduling and Durable Jobs APIs.
93
+ Server-only background jobs, scheduling and durable job APIs.
70
94
 
71
- Core queue APIs include `createJobQueue()`, `createMemoryJobQueueAdapter()`, queue/worker records, retry/backoff, visibility leases, heartbeat renewal, stale recovery, DLQ operations, retention cleanup and queue statistics.
95
+ Core queue APIs include:
72
96
 
73
- Scheduling APIs include `createJobScheduler()`, `createMemoryJobScheduleStore()`, `nextCronTime()` and `nextScheduleTime()`.
74
-
75
- Durable Redis-compatible APIs added in `0.2.10` include `createRedisJobQueueAdapter()` and `createRedisJobScheduleStore()`.
97
+ ```text
98
+ createJobQueue
99
+ createMemoryJobQueueAdapter
100
+ createRedisJobQueueAdapter
101
+ createJobScheduler
102
+ createMemoryJobScheduleStore
103
+ createRedisJobScheduleStore
104
+ nextCronTime
105
+ nextScheduleTime
106
+ ```
76
107
 
77
- BCP does not install a Redis library and does not create the connection. Applications own authentication, TLS, Cluster/Sentinel configuration and connection shutdown.
108
+ 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.
78
109
 
79
- The processing model is at-least-once. Handlers that perform non-idempotent external side effects should use application-level idempotency protection.
110
+ Processing remains at-least-once; non-repeatable external side effects should use application-level idempotency.
80
111
 
81
- 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).
112
+ Related guides: [Background Jobs](background-jobs.md), [Job Scheduling](job-scheduling.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
82
113
 
83
114
  ## `bcp/workflow`
84
115
 
85
- Server-only Workflow Orchestration APIs added in `0.2.11`.
86
-
87
- ```ts
88
- import {
89
- createMemoryWorkflowStore,
90
- createWorkflow,
91
- } from "bcp/workflow";
92
- ```
93
-
94
- `createWorkflow()` defines persistent server-side workflows with sequential steps, parallel groups, per-step retry policies, persisted delays and compensation handlers.
95
-
96
- Workflow controls include:
116
+ Server-only Workflow Orchestration APIs.
97
117
 
98
118
  ```text
99
- start()
100
- run()
101
- get()
102
- list()
103
- resume()
104
- retry()
105
- cancel()
106
- compensate()
107
- close()
119
+ createWorkflow
120
+ createMemoryWorkflowStore
108
121
  ```
109
122
 
110
- When an existing `BackgroundJobQueue` is supplied, workflow execution and delay continuation can run through `bcp/jobs`.
123
+ Workflow controls include `start`, `run`, `get`, `list`, `resume`, `retry`, `cancel`, `compensate` and `close`.
111
124
 
112
- `WorkflowStore.claim()` / `release()` form the run-level lease boundary for multi-instance stores.
125
+ Capabilities include sequential/parallel steps, per-step retry, persisted delays, compensation, run leases and optional execution through `bcp/jobs`.
113
126
 
114
- 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).
127
+ Related guides: [Workflow Orchestration](workflow-orchestration.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
115
128
 
116
129
  ## `bcp/events`
117
130
 
118
- Server-only Transactional Outbox & Events APIs added in `0.2.12`.
131
+ Server-only Transactional Outbox & Events APIs.
119
132
 
120
- ```ts
121
- import {
122
- createEventBus,
123
- createMemoryOutboxStore,
124
- createOutboxDispatcher,
125
- createOutboxMigrationSql,
126
- createSqlOutboxStore,
127
- createTransactionalOutbox,
128
- } from "bcp/events";
133
+ ```text
134
+ createTransactionalOutbox
135
+ createMemoryOutboxStore
136
+ createSqlOutboxStore
137
+ createOutboxMigrationSql
138
+ createOutboxDispatcher
139
+ createEventBus
129
140
  ```
130
141
 
131
- `createTransactionalOutbox()` writes an event through the same `TransactionDatabase` used by `db.transaction()`, allowing business rows and outbox rows to commit or roll back together.
132
-
133
- `createSqlOutboxStore()` supports MySQL, PostgreSQL and SQLite. `createOutboxMigrationSql()` generates the outbox table/index DDL.
142
+ 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.
134
143
 
135
- `createOutboxDispatcher()` supports batched claims, leases, stale recovery, retry/backoff, terminal failure, job-queue handoff, custom publishing, local event-bus delivery and runner lifecycle.
136
-
137
- Delivery is at-least-once; consumers should use idempotency controls for non-repeatable side effects.
138
-
139
- 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).
144
+ Related guides: [Transactional Outbox & Events](transactional-outbox-events.md), [Database](database.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
140
145
 
141
146
  ## `bcp/realtime`
142
147
 
143
- Server-only Realtime Platform APIs added in `0.2.13`.
148
+ Server-only realtime APIs for channels/rooms, broker delivery, presence, channel authorization, socket adapters, heartbeat and Server-Sent Events.
144
149
 
145
- ```ts
146
- import {
147
- createMemoryRealtimeBroker,
148
- createMemoryRealtimePresenceStore,
149
- createRealtime,
150
- createRealtimeSseResponse,
151
- type RealtimeAuthenticate,
152
- type RealtimeAuthorizeChannel,
153
- type RealtimeBroker,
154
- type RealtimeBroadcastOptions,
155
- type RealtimeConnection,
156
- type RealtimeEnvelope,
157
- type RealtimeEventContext,
158
- type RealtimeEventHandler,
159
- type RealtimeHeartbeatOptions,
160
- type RealtimeHeartbeatRunner,
161
- type RealtimeHub,
162
- type RealtimeJoinOptions,
163
- type RealtimeOptions,
164
- type RealtimePresenceMember,
165
- type RealtimePresenceStore,
166
- type RealtimeSocket,
167
- type RealtimeSseOptions,
168
- } from "bcp/realtime";
150
+ ```text
151
+ createRealtime
152
+ createMemoryRealtimeBroker
153
+ createMemoryRealtimePresenceStore
154
+ createRealtimeSseResponse
169
155
  ```
170
156
 
171
- `createRealtime()` creates a server-side hub. Connections can `join()`, `leave()`, `emit()`, `send()`, `touch()` and `disconnect()`.
172
-
173
- `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.
174
-
175
- `RealtimeOptions.authenticate` can resolve identity from a Request/connection payload, while `authorizeChannel` runs before channel membership is accepted.
176
-
177
- BCP does not install a WebSocket provider. `RealtimeSocket` defines the minimal transport surface consumed by `hub.attachSocket()`.
157
+ BCP intentionally does not install a WebSocket server library. Applications adapt the selected provider through `RealtimeSocket`.
178
158
 
179
- `hub.sse()` and `createRealtimeSseResponse()` expose Web-standard Server-Sent Events responses with abort, filtering, retry hint and keep-alive options.
180
-
181
- Realtime delivery is transient. Use database/outbox/jobs/workflows for durable state and refetch durable state/history after reconnect when catch-up is required.
182
-
183
- Related guides: [Realtime Platform](realtime-platform.md), [Authentication](authentication.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
159
+ Related guides: [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
184
160
 
185
161
  ## `bcp/testing`
186
162
 
187
- Server-only Testing Platform APIs added in `0.2.14`.
163
+ Server-only framework-native testing utilities. BCP does not require Jest or Vitest.
188
164
 
189
- ```ts
190
- import {
191
- createFakeClock,
192
- createJobTestHarness,
193
- createOutboxTestHarness,
194
- createRealtimeTestHarness,
195
- createRealtimeTestSocket,
196
- createRouteTestHandler,
197
- createSequenceIdFactory,
198
- createTestApp,
199
- createTestAuthSession,
200
- createTestFormData,
201
- createWorkflowTestHarness,
202
- expectResponse,
203
- readSseEvents,
204
- runTestMiddleware,
205
- runTestPageAction,
206
- runTestPageGuards,
207
- runTestPageLoader,
208
- withTestTransaction,
209
- type CreateTestAuthSessionOptions,
210
- type FakeClock,
211
- type JobTestHarness,
212
- type OutboxTestHarness,
213
- type ParsedSseEvent,
214
- type RealtimeTestConnection,
215
- type RealtimeTestHarness,
216
- type RealtimeTestSocket,
217
- type TestApp,
218
- type TestAppOptions,
219
- type TestAuthSession,
220
- type TestPageActionOptions,
221
- type TestPageContextOptions,
222
- type TestPageGuardOptions,
223
- type TestRequestHandler,
224
- type TestRequestOptions,
225
- type TestResponseExpectation,
226
- type TestRouteFunction,
227
- type TestRouteHandlerOptions,
228
- type TestRouteMethod,
229
- type TestRouteModule,
230
- type TestTransactionDatabase,
231
- type WorkflowTestHarness,
232
- } from "bcp/testing";
233
- ```
234
-
235
- ### Request application harness
165
+ Important APIs include:
236
166
 
237
- `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.
167
+ ```text
168
+ createTestApp
169
+ createRouteTestHandler
170
+ expectResponse
171
+ createTestAuthSession
172
+ withTestTransaction
173
+ runTestMiddleware
174
+ runTestPageLoader
175
+ runTestPageGuards
176
+ runTestPageAction
177
+ createFakeClock
178
+ createSequenceIdFactory
179
+ createJobTestHarness
180
+ createWorkflowTestHarness
181
+ createOutboxTestHarness
182
+ createRealtimeTestSocket
183
+ createRealtimeTestHarness
184
+ readSseEvents
185
+ ```
238
186
 
239
- ### API route module testing
187
+ Related guide: [Testing Platform](testing-platform.md).
240
188
 
241
- `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.
189
+ ## `bcp/plugins`
242
190
 
243
- Return values are normalized for tests: Response is preserved, strings become text Responses, null/undefined become 204, and other values become JSON.
191
+ Server-only Plugin & Module Platform APIs.
244
192
 
245
- ### Page loader, guard and form action testing
193
+ ```text
194
+ definePlugin
195
+ defineModule
196
+ createPluginHost
197
+ createPluginServiceRegistry
198
+ createPluginHookBus
199
+ ```
246
200
 
247
- `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.
201
+ Capabilities include required/optional dependency ordering, setup/start/stop/dispose lifecycle, startup rollback, typed configuration parsing, shared services and awaited in-process hooks.
248
202
 
249
- `runTestPageLoader()` invokes the production `executePageLoaderFunction()` path with test params, URL/search params and optional guard data. The returned value is the normal `PageLoaderExecution` contract.
203
+ Related guides: [Plugin & Module Platform](plugin-module-platform.md), [Configuration](configuration.md), [Observability Platform v3](observability-v3.md).
250
204
 
251
- `runTestPageAction()` invokes the production `executePageActionFunction()` path, including action-name/method validation, guard data, FormData and Response/data handling.
205
+ ## `bcp/observability`
252
206
 
253
- `createTestFormData()` creates a FormData object from string/Blob fields and supports repeated values.
207
+ Server-only metrics, health and tracing APIs.
254
208
 
255
- ### Response assertions
209
+ ### Observability Platform v2
256
210
 
257
- `expectResponse()` exposes lightweight runner-neutral assertions:
211
+ Existing APIs remain supported:
258
212
 
259
213
  ```text
260
- status()
261
- header()
262
- text()
263
- json()
264
- jsonMatches()
214
+ createMetricsRegistry
215
+ createMetricsResponse
216
+ createRequestMetricsMiddleware
217
+ createHealthRegistry
265
218
  ```
266
219
 
267
- BCP does not require Jest/Vitest assertion APIs.
268
-
269
- ### Auth testing
220
+ The metrics registry provides counters, gauges, histograms and Prometheus exposition. Health checks provide readiness/liveness-style reports with timeout support.
270
221
 
271
- `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`.
222
+ ### Observability Platform v3 0.2.17
272
223
 
273
- This allows route/auth tests to use a real BCP session cookie instead of introducing a test-only identity header.
224
+ Tracing APIs:
274
225
 
275
- ### Database rollback testing
276
-
277
- `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.
226
+ ```ts
227
+ import {
228
+ createCompositeTraceSpanExporter,
229
+ createMemoryTraceSpanExporter,
230
+ createRequestTracingMiddleware,
231
+ createTraceCarrier,
232
+ createTraceMetricsExporter,
233
+ createTracer,
234
+ currentTraceContext,
235
+ extractTraceCarrier,
236
+ extractTraceHeaders,
237
+ formatTraceparent,
238
+ getTraceLogFields,
239
+ injectTraceHeaders,
240
+ parseTraceparent,
241
+ runWithTraceCarrier,
242
+ runWithTraceContext,
243
+ } from "bcp/observability";
244
+ ```
278
245
 
279
- Application callback errors remain unchanged and are not swallowed.
246
+ Important public types:
280
247
 
281
- ### Middleware testing
248
+ ```text
249
+ Tracer
250
+ TracerOptions
251
+ TraceContext
252
+ TraceCarrier
253
+ TraceSpan
254
+ TraceSpanRecord
255
+ TraceSpanEvent
256
+ TraceSpanExporter
257
+ TraceSpanKind
258
+ TraceSpanStatus
259
+ TraceAttributes
260
+ TraceIdFactory
261
+ StartTraceSpanOptions
262
+ RequestTracingOptions
263
+ TraceMetricsOptions
264
+ ```
282
265
 
283
- `runTestMiddleware()` invokes the actual Middleware System v2 onion pipeline through `executeMiddlewarePipeline()` and supports a custom downstream Request handler.
266
+ `createTracer()` creates root/child spans. Active context is stored with Node `AsyncLocalStorage`, allowing nested awaited operations to inherit the current `traceId`, `correlationId` and parent span.
284
267
 
285
- ### Deterministic utilities
268
+ ```ts
269
+ await tracer.withSpan(
270
+ "order.checkout",
271
+ async () => {
272
+ await tracer.withSpan(
273
+ "database.insert",
274
+ createOrder,
275
+ {
276
+ kind: "client",
277
+ }
278
+ );
279
+ }
280
+ );
281
+ ```
286
282
 
287
- `createFakeClock()` exposes `now()`, `set()`, `advance()` and `reset()` for time-sensitive queues/workflows/schedulers.
283
+ Supported span kinds:
288
284
 
289
- `createSequenceIdFactory()` creates deterministic IDs for stable assertions.
285
+ ```text
286
+ internal
287
+ server
288
+ client
289
+ producer
290
+ consumer
291
+ ```
290
292
 
291
- ### Infrastructure harnesses
293
+ Failed `withSpan()` callbacks are marked `error`, receive an `exception` event and rethrow the original application error.
292
294
 
293
- `createJobTestHarness()` drains currently eligible work through the real `BackgroundJobQueue.processNext()` API and exposes record/count assertions.
295
+ ### W3C propagation
294
296
 
295
- `createWorkflowTestHarness()` can start/run workflows until terminal or waiting state and optionally force persisted delays to resume.
297
+ `formatTraceparent()` / `parseTraceparent()` support W3C version `00` trace headers.
296
298
 
297
- `createOutboxTestHarness()` dispatches through the actual `OutboxDispatcher` and exposes event/state/statistics helpers.
299
+ ```ts
300
+ const headers =
301
+ new Headers();
298
302
 
299
- `createRealtimeTestSocket()` implements the `RealtimeSocket` adapter contract entirely in memory. `createRealtimeTestHarness()` connects that socket to a real `RealtimeHub` and can assert server-sent channel events.
303
+ injectTraceHeaders(
304
+ headers
305
+ );
306
+ ```
300
307
 
301
- `readSseEvents()` reads event-stream Responses, ignores comment/retry frames and JSON-decodes `data:` payloads when possible.
308
+ `extractTraceHeaders()` reads `traceparent`, optional `tracestate` and `x-correlation-id`.
302
309
 
303
- ### Runner neutrality and boundary
310
+ ### Middleware tracing
304
311
 
305
- `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.
312
+ ```ts
313
+ export const middleware =
314
+ createRequestTracingMiddleware(
315
+ tracer
316
+ );
317
+ ```
306
318
 
307
- The package is server-only; the client boundary validator rejects `bcp/testing` from pages/client islands.
319
+ The middleware continues a valid incoming trace and adds active trace/correlation headers to the response.
308
320
 
309
- 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).
321
+ ### Non-HTTP propagation
310
322
 
311
- ## `bcp/plugins`
323
+ ```ts
324
+ const trace =
325
+ createTraceCarrier();
326
+ ```
312
327
 
313
- Server-only Plugin & Module Platform APIs added in `0.2.15`.
328
+ Transport that carrier through job payloads, workflow input, event metadata or realtime payloads, then restore it with:
314
329
 
315
330
  ```ts
316
- import {
317
- createPluginHookBus,
318
- createPluginHost,
319
- createPluginServiceRegistry,
320
- defineModule,
321
- definePlugin,
322
- PluginDependencyError,
323
- PluginLifecycleError,
324
- type PluginConfigParser,
325
- type PluginConfigSchema,
326
- type PluginContext,
327
- type PluginDefinition,
328
- type PluginHookBus,
329
- type PluginHookHandler,
330
- type PluginHost,
331
- type PluginHostOptions,
332
- type PluginHostView,
333
- type PluginModule,
334
- type PluginRecord,
335
- type PluginServiceKey,
336
- type PluginServiceRegistry,
337
- type PluginState,
338
- } from "bcp/plugins";
331
+ runWithTraceCarrier(
332
+ payload.trace,
333
+ handler
334
+ );
339
335
  ```
340
336
 
341
- `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.
337
+ BCP does not automatically mutate persisted job/workflow/event schemas in `0.2.17`.
342
338
 
343
- `defineModule()` groups reusable plugin definitions while preserving one global host dependency graph.
339
+ ### Exporters and metrics
344
340
 
345
- Plugin configuration can be parsed with a schema/parser during setup. Values from `PluginHostOptions.configs` override plugin-local defaults before parsing.
341
+ `TraceSpanExporter` is provider-neutral. BCP supplies an in-memory exporter and a composite exporter.
346
342
 
347
- `PluginServiceRegistry` provides shared string/Symbol-keyed services. `PluginHookBus` provides awaited, in-process extension hooks in registration order.
343
+ `createTraceMetricsExporter()` converts completed spans into the existing metrics registry:
348
344
 
349
- Missing dependencies and dependency cycles throw `PluginDependencyError`. Setup/start failures surface `PluginLifecycleError`; startup failures roll back plugins that already started in the current transition.
345
+ ```text
346
+ bcp_trace_spans_total
347
+ bcp_trace_span_duration_seconds
348
+ ```
350
349
 
351
- `host.plugin()` and `host.plugins()` expose inspectable lifecycle records.
350
+ Default labels are `kind` and `status`. Span names are opt-in to reduce accidental high cardinality.
352
351
 
353
- `bcp/plugins` is server-only and is rejected from page/client bundles.
352
+ `getTraceLogFields()` returns:
354
353
 
355
- Related guides: [Plugin & Module Platform](plugin-module-platform.md), [Configuration](configuration.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
354
+ ```text
355
+ traceId
356
+ spanId
357
+ correlationId
358
+ ```
356
359
 
357
- ## `bcp/observability`
360
+ for structured log enrichment.
358
361
 
359
- Server-only Observability Platform v2 APIs for process-local counters, gauges, histograms, Prometheus exposition, request metrics middleware and health/readiness checks.
362
+ Prepared npm packages expose compiled `observability.mjs` as the runtime default for `bcp/observability`.
360
363
 
361
- Related guides: [Observability Platform v2](observability.md), [Logging](development-logging.md).
364
+ Related guides: [Observability Platform v2](observability.md), [Observability Platform v3](observability-v3.md), [Logging](development-logging.md), [Cache Platform v2](cache-platform-v2.md).
362
365
 
363
366
  ## `bcp/server`
364
367
 
365
- 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.
368
+ 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.
366
369
 
367
- 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).
370
+ Related guides: [Server Request APIs](server-request-apis.md), [Authorization & Security v2](authorization-security.md), [File Upload](file-upload.md), [Storage](storage.md), [Production Hardening](production-hardening.md), [Observability Platform v3](observability-v3.md).
368
371
 
369
372
  ## `bcp/server-only`
370
373
 
@@ -374,16 +377,14 @@ Server-only module boundary marker.
374
377
  import "bcp/server-only";
375
378
  ```
376
379
 
377
- Related guide: [Application Modules](application-modules.md).
378
-
379
380
  ## `bcp/middleware`
380
381
 
381
- Middleware System v2 APIs and types.
382
+ Middleware System v2 request/response pipeline types and helpers.
382
383
 
383
- Related guides: [Middleware](middleware.md), [Testing Platform](testing-platform.md).
384
+ Related guides: [Middleware](middleware.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
384
385
 
385
386
  ## Stability
386
387
 
387
- Only package entrypoints listed in both `docs/platform-manifest.json` and `docs/api-manifest.json` are part of the documented platform surface.
388
+ Only entrypoints listed in both `docs/platform-manifest.json` and `docs/api-manifest.json` are part of the documented platform surface.
388
389
 
389
- Files under internal `packages/*` paths are framework implementation details unless re-exported through a documented public package entrypoint.
390
+ Files under internal `packages/*` paths are implementation details unless re-exported through a documented public package entrypoint.