@chidchanun/bcp 0.2.17 → 0.2.19

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.
@@ -10,25 +10,15 @@ Universal React application APIs for routing, navigation, layouts, metadata, loa
10
10
 
11
11
  Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound` and loader/action/guard hooks.
12
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).
14
-
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
19
  Backward-compatible request/data caching plus Cache Platform v2 shared-store APIs.
30
20
 
31
- Legacy APIs:
21
+ Important exports:
32
22
 
33
23
  ```text
34
24
  cache
@@ -37,11 +27,6 @@ clearCache
37
27
  getCacheStats
38
28
  revalidateTag
39
29
  revalidatePath
40
- ```
41
-
42
- Cache Platform v2 APIs:
43
-
44
- ```text
45
30
  createCacheStore
46
31
  createMemoryCacheAdapter
47
32
  createMemoryCacheLockAdapter
@@ -52,33 +37,31 @@ createCacheMetrics
52
37
 
53
38
  Public contracts include `CacheAdapter`, `CacheLockAdapter`, `CacheStore`, cache statistics/options and Redis command-client adapter types.
54
39
 
55
- Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md), [Observability Platform v3](observability-v3.md).
40
+ Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md).
56
41
 
57
42
  ## `bcp/config`
58
43
 
59
44
  Typed BCP configuration, environment-schema validation and diagnostics APIs.
60
45
 
61
- 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).
62
49
 
63
50
  ## `bcp/validation`
64
51
 
65
52
  Typed validation primitives, parse helpers and `ValidationError`.
66
53
 
67
- Related guide: [Validation](validation.md).
68
-
69
54
  ## `bcp/error`
70
55
 
71
56
  Structured HTTP error helpers and response classification.
72
57
 
73
- Related guide: [Error Handling](error-handling.md).
74
-
75
58
  ## `bcp/database`
76
59
 
77
60
  Server-only provider-neutral SQL APIs for MySQL, PostgreSQL and SQLite.
78
61
 
79
- Core capabilities include query/execute, transactions, lifecycle, migration stores and migration execution.
62
+ Core capabilities include query/execute, transactions, lifecycle and migrations.
80
63
 
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).
64
+ Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md).
82
65
 
83
66
  ## `bcp/auth`
84
67
 
@@ -86,13 +69,13 @@ Server-only Authentication Platform v2 and Authorization & Security v2 APIs.
86
69
 
87
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.
88
71
 
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).
72
+ Prepared npm packages resolve the runtime to compiled `auth.mjs` in `0.2.18+`.
90
73
 
91
74
  ## `bcp/jobs`
92
75
 
93
76
  Server-only background jobs, scheduling and durable job APIs.
94
77
 
95
- Core queue APIs include:
78
+ Important exports:
96
79
 
97
80
  ```text
98
81
  createJobQueue
@@ -109,8 +92,6 @@ Capabilities include delay, retry/backoff, worker concurrency, cancellation, vis
109
92
 
110
93
  Processing remains at-least-once; non-repeatable external side effects should use application-level idempotency.
111
94
 
112
- Related guides: [Background Jobs](background-jobs.md), [Job Scheduling](job-scheduling.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
113
-
114
95
  ## `bcp/workflow`
115
96
 
116
97
  Server-only Workflow Orchestration APIs.
@@ -124,8 +105,6 @@ Workflow controls include `start`, `run`, `get`, `list`, `resume`, `retry`, `can
124
105
 
125
106
  Capabilities include sequential/parallel steps, per-step retry, persisted delays, compensation, run leases and optional execution through `bcp/jobs`.
126
107
 
127
- Related guides: [Workflow Orchestration](workflow-orchestration.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
128
-
129
108
  ## `bcp/events`
130
109
 
131
110
  Server-only Transactional Outbox & Events APIs.
@@ -141,8 +120,6 @@ createEventBus
141
120
 
142
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.
143
122
 
144
- Related guides: [Transactional Outbox & Events](transactional-outbox-events.md), [Database](database.md), [Durable Jobs](durable-jobs.md), [Observability Platform v3](observability-v3.md).
145
-
146
123
  ## `bcp/realtime`
147
124
 
148
125
  Server-only realtime APIs for channels/rooms, broker delivery, presence, channel authorization, socket adapters, heartbeat and Server-Sent Events.
@@ -156,8 +133,6 @@ createRealtimeSseResponse
156
133
 
157
134
  BCP intentionally does not install a WebSocket server library. Applications adapt the selected provider through `RealtimeSocket`.
158
135
 
159
- Related guides: [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
160
-
161
136
  ## `bcp/testing`
162
137
 
163
138
  Server-only framework-native testing utilities. BCP does not require Jest or Vitest.
@@ -184,8 +159,6 @@ createRealtimeTestHarness
184
159
  readSseEvents
185
160
  ```
186
161
 
187
- Related guide: [Testing Platform](testing-platform.md).
188
-
189
162
  ## `bcp/plugins`
190
163
 
191
164
  Server-only Plugin & Module Platform APIs.
@@ -200,15 +173,11 @@ createPluginHookBus
200
173
 
201
174
  Capabilities include required/optional dependency ordering, setup/start/stop/dispose lifecycle, startup rollback, typed configuration parsing, shared services and awaited in-process hooks.
202
175
 
203
- Related guides: [Plugin & Module Platform](plugin-module-platform.md), [Configuration](configuration.md), [Observability Platform v3](observability-v3.md).
204
-
205
176
  ## `bcp/observability`
206
177
 
207
178
  Server-only metrics, health and tracing APIs.
208
179
 
209
- ### Observability Platform v2
210
-
211
- Existing APIs remain supported:
180
+ Metrics/health APIs:
212
181
 
213
182
  ```text
214
183
  createMetricsRegistry
@@ -217,157 +186,175 @@ createRequestMetricsMiddleware
217
186
  createHealthRegistry
218
187
  ```
219
188
 
220
- The metrics registry provides counters, gauges, histograms and Prometheus exposition. Health checks provide readiness/liveness-style reports with timeout support.
189
+ Observability Platform v3 tracing APIs:
190
+
191
+ ```text
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
206
+ ```
207
+
208
+ Important tracing contracts include `Tracer`, `TraceContext`, `TraceCarrier`, `TraceSpan`, `TraceSpanRecord`, `TraceSpanExporter`, `TraceSpanKind` and `TraceSpanStatus`.
209
+
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.
211
+
212
+ Prepared npm packages expose compiled `observability.mjs`.
213
+
214
+ Related guides: [Observability Platform v2](observability.md), [Observability Platform v3](observability-v3.md).
215
+
216
+ ## `bcp/deployment`
221
217
 
222
- ### Observability Platform v3 0.2.17
218
+ Server-only Deployment Platform v2 lifecycle APIs introduced in `0.2.18`.
223
219
 
224
- Tracing APIs:
220
+ Primary functions:
225
221
 
226
222
  ```ts
227
223
  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";
224
+ createDeploymentDiagnosticsResponse,
225
+ createDeploymentReadinessResponse,
226
+ createDeploymentRuntime,
227
+ } from "bcp/deployment";
244
228
  ```
245
229
 
246
230
  Important public types:
247
231
 
248
232
  ```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
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
264
247
  ```
265
248
 
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.
249
+ Create a runtime:
267
250
 
268
251
  ```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
- );
252
+ const deployment =
253
+ createDeploymentRuntime({
254
+ serviceName: "orders-api",
255
+ version: "1.0.0",
256
+ });
281
257
  ```
282
258
 
283
- Supported span kinds:
259
+ Register resources:
284
260
 
285
- ```text
286
- internal
287
- server
288
- client
289
- producer
290
- consumer
291
- ```
261
+ ```ts
262
+ deployment.addResource({
263
+ name: "database",
292
264
 
293
- Failed `withSpan()` callbacks are marked `error`, receive an `exception` event and rethrow the original application error.
265
+ async start() {
266
+ await db.connect();
267
+ },
294
268
 
295
- ### W3C propagation
269
+ ready() {
270
+ return true;
271
+ },
296
272
 
297
- `formatTraceparent()` / `parseTraceparent()` support W3C version `00` trace headers.
273
+ async stop() {
274
+ await db.close();
275
+ },
276
+ });
277
+ ```
298
278
 
299
- ```ts
300
- const headers =
301
- new Headers();
279
+ Resources start in registration order and stop in reverse order. If startup fails, previously started resources are rolled back in reverse order.
302
280
 
303
- injectTraceHeaders(
304
- headers
305
- );
281
+ Runtime states:
282
+
283
+ ```text
284
+ idle
285
+ starting
286
+ ready
287
+ draining
288
+ stopped
289
+ failed
306
290
  ```
307
291
 
308
- `extractTraceHeaders()` reads `traceparent`, optional `tracestate` and `x-correlation-id`.
292
+ Readiness:
309
293
 
310
- ### Middleware tracing
294
+ ```ts
295
+ const report =
296
+ await deployment.readiness();
297
+ ```
298
+
299
+ or:
311
300
 
312
301
  ```ts
313
- export const middleware =
314
- createRequestTracingMiddleware(
315
- tracer
316
- );
302
+ return createDeploymentReadinessResponse(
303
+ deployment
304
+ );
317
305
  ```
318
306
 
319
- The middleware continues a valid incoming trace and adds active trace/correlation headers to the response.
307
+ The response is `200` when the runtime and all resource checks are ready, otherwise `503`.
320
308
 
321
- ### Non-HTTP propagation
309
+ Diagnostics:
322
310
 
323
311
  ```ts
324
- const trace =
325
- createTraceCarrier();
312
+ const report =
313
+ await deployment.diagnostics();
326
314
  ```
327
315
 
328
- Transport that carrier through job payloads, workflow input, event metadata or realtime payloads, then restore it with:
316
+ or:
329
317
 
330
318
  ```ts
331
- runWithTraceCarrier(
332
- payload.trace,
333
- handler
319
+ return createDeploymentDiagnosticsResponse(
320
+ deployment
334
321
  );
335
322
  ```
336
323
 
337
- BCP does not automatically mutate persisted job/workflow/event schemas in `0.2.17`.
338
-
339
- ### Exporters and metrics
324
+ Metadata includes service/deployment identity, process ID, Node version, platform, architecture and startup time. Optional environment-backed identity fields use:
340
325
 
341
- `TraceSpanExporter` is provider-neutral. BCP supplies an in-memory exporter and a composite exporter.
326
+ ```text
327
+ BCP_DEPLOYMENT_ID
328
+ BCP_INSTANCE_ID
329
+ BCP_RELEASE
330
+ NODE_ENV
331
+ ```
342
332
 
343
- `createTraceMetricsExporter()` converts completed spans into the existing metrics registry:
333
+ Install process signal handlers:
344
334
 
345
- ```text
346
- bcp_trace_spans_total
347
- bcp_trace_span_duration_seconds
335
+ ```ts
336
+ const remove =
337
+ deployment.installSignalHandlers();
348
338
  ```
349
339
 
350
- Default labels are `kind` and `status`. Span names are opt-in to reduce accidental high cardinality.
340
+ Defaults are `SIGTERM` and `SIGINT`.
351
341
 
352
- `getTraceLogFields()` returns:
342
+ Integrate with the framework shutdown-hook registry:
353
343
 
354
- ```text
355
- traceId
356
- spanId
357
- correlationId
344
+ ```ts
345
+ const unregister =
346
+ deployment.registerShutdownHook();
358
347
  ```
359
348
 
360
- for structured log enrichment.
361
-
362
- Prepared npm packages expose compiled `observability.mjs` as the runtime default for `bcp/observability`.
349
+ Prepared npm packages expose compiled `deployment.mjs`.
363
350
 
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).
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).
365
352
 
366
353
  ## `bcp/server`
367
354
 
368
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.
369
356
 
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).
357
+ Prepared npm packages resolve this runtime to compiled `server.mjs` in `0.2.18+`.
371
358
 
372
359
  ## `bcp/server-only`
373
360
 
@@ -381,7 +368,30 @@ import "bcp/server-only";
381
368
 
382
369
  Middleware System v2 request/response pipeline types and helpers.
383
370
 
384
- Related guides: [Middleware](middleware.md), [Testing Platform](testing-platform.md), [Observability Platform v3](observability-v3.md).
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
+ ```
393
+
394
+ Types remain sourced from the TypeScript public entrypoint files.
385
395
 
386
396
  ## Stability
387
397