@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.
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # BCP Framework
2
2
 
3
- BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, API routes, authentication, authorization, SQL databases, background jobs, scheduling, workflow orchestration, transactional events, realtime delivery, framework-native testing, plugin/module composition, distributed caching, observability, uploads, storage and standalone Node.js deployment.
3
+ BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, API routes, authentication, authorization, SQL databases, background jobs, scheduling, workflow orchestration, transactional events, realtime delivery, framework-native testing, plugin/module composition, distributed caching, observability, deployment lifecycle, uploads, storage and standalone Node.js deployment.
4
4
 
5
- > **Development target:** `0.2.17Observability Platform v3`
5
+ > **Development target:** `0.2.19Stability & API Freeze`
6
6
  >
7
- > `0.2.17` remains unreleased until local validation, RC checks, tagging and npm publication complete.
7
+ > `0.2.19` remains unreleased until local validation, RC checks, tagging and npm publication complete.
8
8
 
9
9
  ## Current platform
10
10
 
@@ -19,20 +19,18 @@ BCP Framework is a React full-stack framework for file-based routing, SSR, SPA n
19
19
  | Security | Same-origin validation and signed CSRF tokens |
20
20
  | Middleware | Middleware System v2 with onion execution |
21
21
  | Database | MySQL, PostgreSQL and SQLite adapters, transactions, lifecycle and migrations |
22
- | Background jobs | Delay, retry/backoff, cancellation and concurrent workers |
23
- | Scheduling | Interval/UTC cron schedules and scheduler leases |
24
- | Durable jobs | Redis-compatible queue/schedule adapters, visibility timeout, heartbeat, stale recovery and DLQ |
22
+ | Jobs | Delay, retries, scheduling, Redis-compatible durable queues, heartbeat, stale recovery and DLQ |
25
23
  | Workflows | Sequential/parallel steps, retries, persisted delays, compensation and run leases |
26
- | Events | Transactional outbox, SQL persistence, dispatcher leases, retries, event bus and durable queue handoff |
27
- | Realtime | Channels/rooms, presence, broker delivery, WebSocket adapter contract, SSE and heartbeat |
28
- | Testing | Request/route/page/auth/database/middleware/jobs/workflow/outbox/realtime/SSE test harnesses |
29
- | Plugins & modules | Dependency ordering, lifecycle hooks, config parsing, service registry and async extension hooks |
30
- | Caching | Legacy request/data cache plus Cache Platform v2 adapters, Redis-compatible cache/locks, stampede protection, TTL/tag/path invalidation and metrics |
31
- | Observability | Metrics, Prometheus, health/readiness, distributed tracing, W3C trace context and correlation IDs |
32
- | Uploads & storage | Multipart streaming, Local/S3-compatible storage and signed URLs |
33
- | Configuration | Typed config/environment validation and diagnostics |
34
- | Production | Standalone Node.js build, packaging, dependency pruning, Docker starter and graceful shutdown |
35
- | Documentation | Manifest-driven docs, platform metadata and API reference |
24
+ | Events | Transactional outbox, SQL persistence, dispatcher leases, retries and durable queue handoff |
25
+ | Realtime | Channels/rooms, presence, broker delivery, socket adapter contract, SSE and heartbeat |
26
+ | Testing | Request/route/page/auth/database/middleware/jobs/workflow/outbox/realtime/SSE harnesses |
27
+ | Plugins & modules | Dependency ordering, lifecycle hooks, config parsing, shared services and async hooks |
28
+ | Caching | Redis-compatible adapters/locks, stampede protection, TTL/tag/path invalidation and metrics |
29
+ | Observability | Prometheus metrics, health/readiness, distributed tracing, W3C trace context and correlation IDs |
30
+ | Deployment | Resource lifecycle, readiness, diagnostics, runtime identity, signal handling and graceful shutdown |
31
+ | Stability | Frozen public/CLI/package contract, compatibility gate and release-readiness report |
32
+ | Production | Standalone Node.js build, compiled server entrypoints, dependency pruning and Docker starter |
33
+ | Documentation | Manifest-driven docs, API/platform metadata and release contracts |
36
34
 
37
35
  ## Requirements
38
36
 
@@ -66,382 +64,138 @@ Generated projects normally use one framework dependency:
66
64
  }
67
65
  ```
68
66
 
69
- ## Core backend entrypoints
67
+ ## Public entrypoints — frozen for 0.2.19
70
68
 
71
- ```ts
72
- import { createCacheStore } from "bcp/cache";
73
- import { db } from "bcp/database";
74
- import { createAuth } from "bcp/auth";
75
- import { createJobQueue } from "bcp/jobs";
76
- import { createWorkflow } from "bcp/workflow";
77
- import { createTransactionalOutbox } from "bcp/events";
78
- import { createRealtime } from "bcp/realtime";
79
- import { createTestApp } from "bcp/testing";
80
- import { createPluginHost } from "bcp/plugins";
81
- import {
82
- createMetricsRegistry,
83
- createTracer,
84
- } from "bcp/observability";
69
+ ```text
70
+ bcp
71
+ bcp/island
72
+ bcp/cache
73
+ bcp/config
74
+ bcp/validation
75
+ bcp/error
76
+ bcp/database
77
+ bcp/auth
78
+ bcp/jobs
79
+ bcp/workflow
80
+ bcp/events
81
+ bcp/realtime
82
+ bcp/testing
83
+ bcp/plugins
84
+ bcp/observability
85
+ bcp/deployment
86
+ bcp/server
87
+ bcp/server-only
88
+ bcp/middleware
85
89
  ```
86
90
 
87
- ## Durable jobs and scheduling
91
+ Application code should use these public entrypoints instead of private `packages/*` implementation files.
88
92
 
89
- ```ts
90
- import {
91
- createJobQueue,
92
- createJobScheduler,
93
- } from "bcp/jobs";
93
+ ## Stability & API Freeze — 0.2.19
94
94
 
95
- export const jobs =
96
- createJobQueue();
95
+ The committed freeze contract is:
97
96
 
98
- export const scheduler =
99
- createJobScheduler({
100
- queue: jobs,
101
- });
97
+ ```text
98
+ docs/api-freeze-snapshot.json
102
99
  ```
103
100
 
104
- Production adapters can provide Redis-compatible durable queue/schedule storage without BCP owning the Redis connection.
101
+ It locks the current public entrypoint set, CLI command set, API ownership and exact prepared npm export targets.
105
102
 
106
- ## Workflow Orchestration — 0.2.11
103
+ Check compatibility:
107
104
 
108
- ```ts
109
- import {
110
- createWorkflow,
111
- } from "bcp/workflow";
112
-
113
- export const onboarding =
114
- createWorkflow<{
115
- userId: number;
116
- }>(
117
- "user.onboarding",
118
- workflow => {
119
- workflow.step(
120
- "profile",
121
- createProfile
122
- );
123
- workflow.parallel(
124
- "initialize",
125
- parallel => {
126
- parallel.step(
127
- "preferences",
128
- createPreferences
129
- );
130
- parallel.step(
131
- "workspace",
132
- createWorkspace
133
- );
134
- }
135
- );
136
- workflow.delay(
137
- "cooldown",
138
- 1_000
139
- );
140
- }
141
- );
105
+ ```bash
106
+ npm run api:check
142
107
  ```
143
108
 
144
- Workflows support retries, compensation, persisted delays and optional durable queue execution.
145
-
146
- ## Transactional Outbox & Events — 0.2.12
147
-
148
- Use the same SQL transaction for business data and its outbox event:
109
+ Regenerate the snapshot only when an intentional platform-baseline change is reviewed:
149
110
 
150
- ```ts
151
- await db.transaction(
152
- async tx => {
153
- await tx.execute(
154
- "INSERT INTO orders ..."
155
- );
156
-
157
- await outbox.publish(
158
- tx,
159
- "order.created",
160
- {
161
- orderId: 42,
162
- }
163
- );
164
- }
165
- );
111
+ ```bash
112
+ npm run api:snapshot
166
113
  ```
167
114
 
168
- After commit, an outbox dispatcher can deliver through `bcp/jobs`, a custom publisher or the local event bus.
169
-
170
- Read more: [Transactional Outbox & Events](docs/transactional-outbox-events.md)
171
-
172
- ## Realtime Platform — 0.2.13
115
+ Release metadata readiness:
173
116
 
174
- ```ts
175
- import {
176
- createRealtime,
177
- } from "bcp/realtime";
178
-
179
- export const realtime =
180
- createRealtime();
117
+ ```bash
118
+ npm run release:readiness
181
119
  ```
182
120
 
183
- BCP intentionally does not install a WebSocket server library. Applications adapt `ws`, uWebSockets.js or another transport to `RealtimeSocket`. SSE is built in through Web `Response`.
184
-
185
- Read more: [Realtime Platform](docs/realtime-platform.md)
121
+ Persist a local machine-readable report:
186
122
 
187
- ## Testing Platform — 0.2.14
188
-
189
- `bcp/testing` provides runner-neutral request/route/page/auth/database/middleware/jobs/workflow/outbox/realtime/SSE test helpers.
190
-
191
- ```ts
192
- import {
193
- createRouteTestHandler,
194
- createTestApp,
195
- expectResponse,
196
- } from "bcp/testing";
197
-
198
- const app =
199
- createTestApp({
200
- handler:
201
- createRouteTestHandler({
202
- GET() {
203
- return {
204
- ok: true,
205
- };
206
- },
207
- }),
208
- });
209
-
210
- await expectResponse(
211
- await app.get("/api/health")
212
- )
213
- .status(200)
214
- .json({
215
- ok: true,
216
- });
123
+ ```bash
124
+ npm run release:readiness:report
217
125
  ```
218
126
 
219
- Read more: [Testing Platform](docs/testing-platform.md)
220
-
221
- ## Plugin & Module Platform — 0.2.15
222
-
223
- ```ts
224
- import {
225
- createPluginHost,
226
- definePlugin,
227
- } from "bcp/plugins";
228
-
229
- const databasePlugin =
230
- definePlugin({
231
- name: "database",
232
- setup(context) {
233
- context.services.provide(
234
- "database",
235
- db
236
- );
237
- },
238
- });
127
+ Output:
239
128
 
240
- const jobsPlugin =
241
- definePlugin({
242
- name: "jobs",
243
- requires: [
244
- "database",
245
- ],
246
- });
247
-
248
- export const plugins =
249
- createPluginHost({
250
- plugins: [
251
- jobsPlugin,
252
- databasePlugin,
253
- ],
254
- });
129
+ ```text
130
+ .bcp-framework/release-readiness.json
255
131
  ```
256
132
 
257
- Startup follows dependency order; stop/dispose runs in reverse order. Modules, config parsing, shared services and async hook buses are supported.
133
+ Read more: [Stability & API Freeze](docs/stability-api-freeze.md)
258
134
 
259
- Read more: [Plugin & Module Platform](docs/plugin-module-platform.md)
260
-
261
- ## Cache Platform v2 — 0.2.16
262
-
263
- `0.2.16` keeps the original `cache()` / `dedupe()` APIs and adds provider-neutral asynchronous cache stores.
135
+ ## Core backend entrypoints
264
136
 
265
137
  ```ts
266
- import {
267
- createCacheStore,
268
- createRedisCacheAdapter,
269
- createRedisCacheLockAdapter,
270
- } from "bcp/cache";
271
-
272
- export const cache =
273
- createCacheStore({
274
- adapter:
275
- createRedisCacheAdapter({
276
- client: redisClient,
277
- }),
278
- lock:
279
- createRedisCacheLockAdapter({
280
- client: redisClient,
281
- }),
282
- });
138
+ import { createCacheStore } from "bcp/cache";
139
+ import { db } from "bcp/database";
140
+ import { createAuth } from "bcp/auth";
141
+ import { createJobQueue } from "bcp/jobs";
142
+ import { createWorkflow } from "bcp/workflow";
143
+ import { createTransactionalOutbox } from "bcp/events";
144
+ import { createRealtime } from "bcp/realtime";
145
+ import { createTestApp } from "bcp/testing";
146
+ import { createPluginHost } from "bcp/plugins";
147
+ import { createTracer } from "bcp/observability";
148
+ import { createDeploymentRuntime } from "bcp/deployment";
283
149
  ```
284
150
 
285
- Distributed `getOrSet()` supports local singleflight, owner-scoped lock leases, heartbeat renewal, double-check-after-lock and contention wait/poll.
286
-
287
- Read more: [Cache Platform v2](docs/cache-platform-v2.md)
288
-
289
- ## Observability Platform v3 — 0.2.17
290
-
291
- `0.2.17` keeps the metrics/Prometheus/health APIs from Observability v2 and adds provider-neutral tracing and correlation.
292
-
293
- Create a tracer:
151
+ ## Deployment lifecycle
294
152
 
295
153
  ```ts
296
154
  import {
297
- createMemoryTraceSpanExporter,
298
- createTracer,
299
- } from "bcp/observability";
155
+ createDeploymentRuntime,
156
+ } from "bcp/deployment";
300
157
 
301
- const traces =
302
- createMemoryTraceSpanExporter();
303
-
304
- export const tracer =
305
- createTracer({
306
- exporter: traces,
307
- serviceName: "api",
158
+ const deployment =
159
+ createDeploymentRuntime({
160
+ serviceName: "orders-api",
308
161
  });
309
- ```
310
162
 
311
- Create root/child spans:
163
+ deployment.addResource({
164
+ name: "database",
165
+ start: () => db.connect(),
166
+ ready: () => db.status === "ready",
167
+ stop: () => db.close(),
168
+ });
312
169
 
313
- ```ts
314
- await tracer.withSpan(
315
- "order.checkout",
316
- async () => {
317
- await tracer.withSpan(
318
- "database.order.insert",
319
- createOrder,
320
- {
321
- kind: "client",
322
- }
323
- );
324
- }
325
- );
170
+ await deployment.start();
326
171
  ```
327
172
 
328
- Tracing context flows through normal awaited async work via Node `AsyncLocalStorage`.
173
+ Startup follows registration order. Shutdown runs in reverse order. Repeated/concurrent start while active and repeated/concurrent shutdown are covered by the `0.2.19` stability suite.
329
174
 
330
- ### HTTP tracing
175
+ Read more: [Deployment Platform v2](docs/deployment-platform-v2.md)
331
176
 
332
- ```ts
333
- import {
334
- createRequestTracingMiddleware,
335
- } from "bcp/observability";
336
-
337
- export const middleware =
338
- createRequestTracingMiddleware(
339
- tracer
340
- );
341
- ```
342
-
343
- The middleware continues valid W3C `traceparent` headers, preserves `x-correlation-id`, creates a server span and returns current trace headers on the response.
344
-
345
- ### Jobs / workflow / events / realtime propagation
346
-
347
- ```ts
348
- import {
349
- createTraceCarrier,
350
- runWithTraceCarrier,
351
- } from "bcp/observability";
352
-
353
- const trace =
354
- createTraceCarrier();
355
-
356
- await jobs.enqueue(
357
- "order.process",
358
- {
359
- orderId,
360
- trace,
361
- }
362
- );
363
- ```
177
+ ## Compiled production entrypoints
364
178
 
365
- Consumer:
366
-
367
- ```ts
368
- await runWithTraceCarrier(
369
- payload.trace,
370
- () =>
371
- tracer.withSpan(
372
- "job order.process",
373
- handler,
374
- {
375
- kind: "consumer",
376
- }
377
- )
378
- );
379
- ```
380
-
381
- The same carrier can be placed in workflow input, outbox/event metadata and realtime payloads when trace continuity is needed across those boundaries.
382
-
383
- ### Trace-to-metrics and logs
384
-
385
- ```ts
386
- import {
387
- createCompositeTraceSpanExporter,
388
- createMetricsRegistry,
389
- createTraceMetricsExporter,
390
- getTraceLogFields,
391
- } from "bcp/observability";
392
-
393
- const metrics =
394
- createMetricsRegistry();
395
-
396
- const exporter =
397
- createCompositeTraceSpanExporter([
398
- createTraceMetricsExporter(
399
- metrics
400
- ),
401
- productionTraceExporter,
402
- ]);
403
-
404
- logger.info(
405
- "order created",
406
- {
407
- ...getTraceLogFields(),
408
- orderId,
409
- }
410
- );
411
- ```
412
-
413
- Default trace metrics use low-cardinality `kind` and `status` labels. Span-name labels are opt-in.
414
-
415
- BCP does not install an OpenTelemetry SDK or vendor APM package; production exporters remain application-owned through `TraceSpanExporter`.
416
-
417
- Prepared npm packages compile `bcp/observability` to `observability.mjs` for standalone Node runtime use.
418
-
419
- Read more: [Observability Platform v3](docs/observability-v3.md)
420
-
421
- ## Public entrypoints
179
+ Prepared npm packages use compiled ESM for the main server runtime surfaces:
422
180
 
423
181
  ```text
424
- bcp
425
- bcp/island
426
- bcp/cache
427
- bcp/config
428
- bcp/validation
429
- bcp/error
430
- bcp/database
431
- bcp/auth
432
- bcp/jobs
433
- bcp/workflow
434
- bcp/events
435
- bcp/realtime
436
- bcp/testing
437
- bcp/plugins
438
- bcp/observability
439
- bcp/server
440
- bcp/server-only
441
- bcp/middleware
182
+ bcp/cache -> cache.mjs
183
+ bcp/config -> config.mjs
184
+ bcp/database -> database.mjs
185
+ bcp/auth -> auth.mjs
186
+ bcp/jobs -> jobs.mjs
187
+ bcp/workflow -> workflow.mjs
188
+ bcp/events -> events.mjs
189
+ bcp/realtime -> realtime.mjs
190
+ bcp/testing -> testing.mjs
191
+ bcp/plugins -> plugins.mjs
192
+ bcp/observability -> observability.mjs
193
+ bcp/deployment -> deployment.mjs
194
+ bcp/server -> server.mjs
195
+ bcp/middleware -> middleware.mjs
442
196
  ```
443
197
 
444
- Application code should use public entrypoints instead of private `packages/*` implementation files.
198
+ The exact prepared export map is now part of the API freeze contract.
445
199
 
446
200
  ## CLI
447
201
 
@@ -476,54 +230,27 @@ bcp generate middleware
476
230
  bcp generate migration create_users
477
231
  ```
478
232
 
479
- ## Production model
480
-
481
- ```text
482
- Browser / API / Realtime clients
483
- |
484
- tracing + security
485
- |
486
- Plugin Host
487
- / | \
488
- database workflows realtime
489
- | | ^
490
- outbox jobs |
491
- \__________|_________/
492
- durable state
493
- |
494
- shared cache layer
495
- |
496
- metrics + trace export
497
- ```
498
-
499
- Cache remains an optimization layer. Database/outbox/jobs/workflows remain the durable truth. Realtime remains transient delivery. Tracing correlates those operations without replacing their state contracts.
500
-
501
233
  ## Packaging
502
234
 
503
235
  ```bash
504
236
  npm run build
505
- npm start
506
- ```
507
-
508
- Deployment package:
509
-
510
- ```bash
511
237
  bcp package
512
238
  ```
513
239
 
514
- ## Documentation Platform
240
+ Application packages include production dependency manifests, deployment/environment metadata, file-integrity metadata and a Docker starter while excluding `.env` secrets and application devDependencies.
515
241
 
516
- Machine-readable contracts:
242
+ ## Machine-readable contracts
517
243
 
518
244
  ```text
519
245
  docs/platform-manifest.json
520
246
  docs/docs-web-manifest.json
521
247
  docs/api-manifest.json
248
+ docs/api-freeze-snapshot.json
522
249
  ```
523
250
 
524
251
  ## Release validation
525
252
 
526
- Before publishing `0.2.17`:
253
+ Before publishing `0.2.19`:
527
254
 
528
255
  ```bash
529
256
  npm run typecheck
@@ -531,12 +258,14 @@ npm run test:unit
531
258
  npm run test:integration
532
259
  npm run test:e2e
533
260
  npm run test:package
261
+ npm run api:check
262
+ npm run release:readiness
534
263
  npm run rc:check
535
264
  ```
536
265
 
537
- `0.2.17` adds unit and prepared-package smoke coverage for root/child spans, async context propagation, W3C trace headers, correlation carriers, request tracing, error spans, trace metrics and compiled `observability.mjs` execution.
266
+ `release:check` now runs the full tests, API compatibility gate, release-readiness gate and release metadata validation.
538
267
 
539
- Do not tag or publish until the exact final release commit passes the full RC sequence.
268
+ Do not tag or publish until the exact final release commit passes the complete RC sequence.
540
269
 
541
270
  ## Release history
542
271
 
@@ -566,14 +295,14 @@ Do not tag or publish until the exact final release commit passes the full RC se
566
295
  | `0.2.15` | Plugin & Module Platform |
567
296
  | `0.2.16` | Cache Platform v2 |
568
297
  | `0.2.17` | Observability Platform v3 |
298
+ | `0.2.18` | Deployment Platform v2 |
299
+ | `0.2.19` | Stability & API Freeze |
569
300
 
570
301
  ## Roadmap
571
302
 
572
- `0.2.17` establishes trace/correlation continuity across the current server platform without coupling BCP to a specific telemetry vendor.
573
-
574
- The next logical milestone is **`0.2.18 — Deployment Platform v2`**, focused on completing compiled production entrypoints, deployment/runtime adapters, process lifecycle integration, container/runtime metadata and production diagnostics.
303
+ `0.2.19` freezes the supported `0.2.x` application/runtime contract and becomes the compatibility reference for the next platform generation.
575
304
 
576
- `0.2.19` is planned as the stabilization/API-freeze pass before the next `0.3.0` platform baseline.
305
+ The next planned milestone is **`0.3.0 BCP Application Platform`**. Intentional public API changes should be made there with explicit migration documentation and compatibility metadata.
577
306
 
578
307
  Native desktop/mobile compilation remains later roadmap work.
579
308