@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.
- package/README.md +184 -204
- package/docs/README.md +47 -34
- package/docs/api-manifest.json +14 -14
- package/docs/api-reference.md +232 -231
- package/docs/cache-platform-v2.md +487 -0
- package/docs/docs-web-manifest.json +7 -3
- package/docs/observability-v3.md +402 -0
- package/docs/platform-manifest.json +30 -4
- package/docs/releases/0.2.16.md +147 -0
- package/docs/releases/0.2.17.md +166 -0
- package/package.json +3 -3
- 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/observability.mjs +1251 -0
- package/packages/client/src/observability.ts +37 -0
- package/packages/server/src/observability-v3.ts +878 -0
package/docs/api-reference.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# API Reference
|
|
2
2
|
|
|
3
|
-
BCP Framework exposes
|
|
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
|
|
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
|
-
|
|
29
|
+
Backward-compatible request/data caching plus Cache Platform v2 shared-store APIs.
|
|
30
30
|
|
|
31
|
-
|
|
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
|
|
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
|
|
77
|
+
Server-only provider-neutral SQL APIs for MySQL, PostgreSQL and SQLite.
|
|
54
78
|
|
|
55
|
-
|
|
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
|
|
85
|
+
Server-only Authentication Platform v2 and Authorization & Security v2 APIs.
|
|
62
86
|
|
|
63
|
-
|
|
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)
|
|
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
|
|
93
|
+
Server-only background jobs, scheduling and durable job APIs.
|
|
70
94
|
|
|
71
|
-
Core queue APIs include
|
|
95
|
+
Core queue APIs include:
|
|
72
96
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
97
|
+
```text
|
|
98
|
+
createJobQueue
|
|
99
|
+
createMemoryJobQueueAdapter
|
|
100
|
+
createRedisJobQueueAdapter
|
|
101
|
+
createJobScheduler
|
|
102
|
+
createMemoryJobScheduleStore
|
|
103
|
+
createRedisJobScheduleStore
|
|
104
|
+
nextCronTime
|
|
105
|
+
nextScheduleTime
|
|
106
|
+
```
|
|
76
107
|
|
|
77
|
-
|
|
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
|
-
|
|
110
|
+
Processing remains at-least-once; non-repeatable external side effects should use application-level idempotency.
|
|
80
111
|
|
|
81
|
-
Related guides: [Background Jobs
|
|
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
|
|
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
|
-
|
|
100
|
-
|
|
101
|
-
get()
|
|
102
|
-
list()
|
|
103
|
-
resume()
|
|
104
|
-
retry()
|
|
105
|
-
cancel()
|
|
106
|
-
compensate()
|
|
107
|
-
close()
|
|
119
|
+
createWorkflow
|
|
120
|
+
createMemoryWorkflowStore
|
|
108
121
|
```
|
|
109
122
|
|
|
110
|
-
|
|
123
|
+
Workflow controls include `start`, `run`, `get`, `list`, `resume`, `retry`, `cancel`, `compensate` and `close`.
|
|
111
124
|
|
|
112
|
-
|
|
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
|
|
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
|
|
131
|
+
Server-only Transactional Outbox & Events APIs.
|
|
119
132
|
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
148
|
+
Server-only realtime APIs for channels/rooms, broker delivery, presence, channel authorization, socket adapters, heartbeat and Server-Sent Events.
|
|
144
149
|
|
|
145
|
-
```
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
163
|
+
Server-only framework-native testing utilities. BCP does not require Jest or Vitest.
|
|
188
164
|
|
|
189
|
-
|
|
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
|
-
|
|
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
|
-
|
|
187
|
+
Related guide: [Testing Platform](testing-platform.md).
|
|
240
188
|
|
|
241
|
-
|
|
189
|
+
## `bcp/plugins`
|
|
242
190
|
|
|
243
|
-
|
|
191
|
+
Server-only Plugin & Module Platform APIs.
|
|
244
192
|
|
|
245
|
-
|
|
193
|
+
```text
|
|
194
|
+
definePlugin
|
|
195
|
+
defineModule
|
|
196
|
+
createPluginHost
|
|
197
|
+
createPluginServiceRegistry
|
|
198
|
+
createPluginHookBus
|
|
199
|
+
```
|
|
246
200
|
|
|
247
|
-
|
|
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
|
-
|
|
203
|
+
Related guides: [Plugin & Module Platform](plugin-module-platform.md), [Configuration](configuration.md), [Observability Platform v3](observability-v3.md).
|
|
250
204
|
|
|
251
|
-
|
|
205
|
+
## `bcp/observability`
|
|
252
206
|
|
|
253
|
-
|
|
207
|
+
Server-only metrics, health and tracing APIs.
|
|
254
208
|
|
|
255
|
-
###
|
|
209
|
+
### Observability Platform v2
|
|
256
210
|
|
|
257
|
-
|
|
211
|
+
Existing APIs remain supported:
|
|
258
212
|
|
|
259
213
|
```text
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
jsonMatches()
|
|
214
|
+
createMetricsRegistry
|
|
215
|
+
createMetricsResponse
|
|
216
|
+
createRequestMetricsMiddleware
|
|
217
|
+
createHealthRegistry
|
|
265
218
|
```
|
|
266
219
|
|
|
267
|
-
|
|
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
|
-
|
|
222
|
+
### Observability Platform v3 — 0.2.17
|
|
272
223
|
|
|
273
|
-
|
|
224
|
+
Tracing APIs:
|
|
274
225
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
-
|
|
246
|
+
Important public types:
|
|
280
247
|
|
|
281
|
-
|
|
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
|
-
`
|
|
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
|
-
|
|
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
|
-
|
|
283
|
+
Supported span kinds:
|
|
288
284
|
|
|
289
|
-
|
|
285
|
+
```text
|
|
286
|
+
internal
|
|
287
|
+
server
|
|
288
|
+
client
|
|
289
|
+
producer
|
|
290
|
+
consumer
|
|
291
|
+
```
|
|
290
292
|
|
|
291
|
-
|
|
293
|
+
Failed `withSpan()` callbacks are marked `error`, receive an `exception` event and rethrow the original application error.
|
|
292
294
|
|
|
293
|
-
|
|
295
|
+
### W3C propagation
|
|
294
296
|
|
|
295
|
-
`
|
|
297
|
+
`formatTraceparent()` / `parseTraceparent()` support W3C version `00` trace headers.
|
|
296
298
|
|
|
297
|
-
|
|
299
|
+
```ts
|
|
300
|
+
const headers =
|
|
301
|
+
new Headers();
|
|
298
302
|
|
|
299
|
-
|
|
303
|
+
injectTraceHeaders(
|
|
304
|
+
headers
|
|
305
|
+
);
|
|
306
|
+
```
|
|
300
307
|
|
|
301
|
-
`
|
|
308
|
+
`extractTraceHeaders()` reads `traceparent`, optional `tracestate` and `x-correlation-id`.
|
|
302
309
|
|
|
303
|
-
###
|
|
310
|
+
### Middleware tracing
|
|
304
311
|
|
|
305
|
-
|
|
312
|
+
```ts
|
|
313
|
+
export const middleware =
|
|
314
|
+
createRequestTracingMiddleware(
|
|
315
|
+
tracer
|
|
316
|
+
);
|
|
317
|
+
```
|
|
306
318
|
|
|
307
|
-
The
|
|
319
|
+
The middleware continues a valid incoming trace and adds active trace/correlation headers to the response.
|
|
308
320
|
|
|
309
|
-
|
|
321
|
+
### Non-HTTP propagation
|
|
310
322
|
|
|
311
|
-
|
|
323
|
+
```ts
|
|
324
|
+
const trace =
|
|
325
|
+
createTraceCarrier();
|
|
326
|
+
```
|
|
312
327
|
|
|
313
|
-
|
|
328
|
+
Transport that carrier through job payloads, workflow input, event metadata or realtime payloads, then restore it with:
|
|
314
329
|
|
|
315
330
|
```ts
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
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
|
-
|
|
337
|
+
BCP does not automatically mutate persisted job/workflow/event schemas in `0.2.17`.
|
|
342
338
|
|
|
343
|
-
|
|
339
|
+
### Exporters and metrics
|
|
344
340
|
|
|
345
|
-
|
|
341
|
+
`TraceSpanExporter` is provider-neutral. BCP supplies an in-memory exporter and a composite exporter.
|
|
346
342
|
|
|
347
|
-
`
|
|
343
|
+
`createTraceMetricsExporter()` converts completed spans into the existing metrics registry:
|
|
348
344
|
|
|
349
|
-
|
|
345
|
+
```text
|
|
346
|
+
bcp_trace_spans_total
|
|
347
|
+
bcp_trace_span_duration_seconds
|
|
348
|
+
```
|
|
350
349
|
|
|
351
|
-
`
|
|
350
|
+
Default labels are `kind` and `status`. Span names are opt-in to reduce accidental high cardinality.
|
|
352
351
|
|
|
353
|
-
`
|
|
352
|
+
`getTraceLogFields()` returns:
|
|
354
353
|
|
|
355
|
-
|
|
354
|
+
```text
|
|
355
|
+
traceId
|
|
356
|
+
spanId
|
|
357
|
+
correlationId
|
|
358
|
+
```
|
|
356
359
|
|
|
357
|
-
|
|
360
|
+
for structured log enrichment.
|
|
358
361
|
|
|
359
|
-
|
|
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
|
|
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), [
|
|
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
|
|
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
|
|
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
|
|
390
|
+
Files under internal `packages/*` paths are implementation details unless re-exported through a documented public package entrypoint.
|