@chidchanun/bcp 0.2.18 → 0.3.0

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,39 +1,33 @@
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, deployment lifecycle, uploads, storage and standalone Node.js deployment.
3
+ BCP Framework is a React full-stack application framework for file-based routing, SSR, server data, APIs, authentication, SQL databases, jobs, workflows, transactional events, realtime, caching, observability, plugins, deployment lifecycle and standalone Node.js production builds.
4
4
 
5
- > **Development target:** `0.2.18Deployment Platform v2`
5
+ > **Development target:** `0.3.0BCP Application Platform`
6
6
  >
7
- > `0.2.18` remains unreleased until local validation, RC checks, tagging and npm publication complete.
7
+ > `0.3.0` remains unreleased until local validation, RC checks, tagging and npm publication complete.
8
8
 
9
9
  ## Current platform
10
10
 
11
11
  | Area | Capability |
12
12
  | --- | --- |
13
- | Application | React SSR, hydration, layouts, metadata and SPA navigation |
13
+ | Application runtime | `defineApp()` / `createApp()`, typed config, shared services, plugins/modules, resource lifecycle, readiness and diagnostics |
14
14
  | Routing | Static, dynamic, catch-all, optional catch-all and route groups |
15
- | Server data | Route loaders and request-scoped server APIs |
16
- | Mutations | Route-owned actions and `<Form>` |
17
- | Authentication | JWT cookie sessions, optional server-side stores, revocation, logout-all and idle timeout |
15
+ | Rendering | React SSR, hydration, layouts, metadata and SPA navigation |
16
+ | Server data | Route loaders, guards, actions and request-scoped server APIs |
17
+ | Authentication | JWT cookie sessions, revocation, logout-all and idle timeout |
18
18
  | Authorization | Auth/guest/role/permission guards and resource-aware policies |
19
- | Security | Same-origin validation and signed CSRF tokens |
20
- | Middleware | Middleware System v2 with onion execution |
21
19
  | 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 |
20
+ | Jobs | Delay, retries, scheduling, Redis-compatible durable queues, heartbeat, recovery and DLQ |
25
21
  | 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 | 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
- | Deployment | Resource lifecycle, readiness, diagnostics, runtime identity, signal handling and graceful shutdown |
33
- | Uploads & storage | Multipart streaming, Local/S3-compatible storage and signed URLs |
34
- | Configuration | Typed config/environment validation and diagnostics |
35
- | Production | Standalone Node.js build, compiled server entrypoints, packaging, dependency pruning and Docker starter |
36
- | Documentation | Manifest-driven docs, platform metadata and API reference |
22
+ | Events | Transactional outbox, SQL persistence, dispatcher leases and durable handoff |
23
+ | Realtime | Channels, presence, broker delivery, WebSocket adapter contract, SSE and heartbeat |
24
+ | Plugins | Dependency ordering, lifecycle, config parsing, services and async hooks |
25
+ | Cache | Redis-compatible adapters/locks, stampede protection, TTL/tag/path invalidation and metrics |
26
+ | Observability | Prometheus metrics, health/readiness, distributed tracing, W3C context and correlation IDs |
27
+ | Deployment | Resource lifecycle, readiness, diagnostics, runtime identity and graceful shutdown |
28
+ | Testing | Request/route/page/auth/database/middleware/jobs/workflow/outbox/realtime/SSE harnesses |
29
+ | Stability | API baseline snapshot, package-export parity and release-readiness gates |
30
+ | Production | Standalone Node.js build, compiled server runtimes, dependency pruning and Docker starter |
37
31
 
38
32
  ## Requirements
39
33
 
@@ -67,149 +61,178 @@ Generated projects normally use one framework dependency:
67
61
  }
68
62
  ```
69
63
 
70
- ## Core backend entrypoints
64
+ ## BCP Application Platform — 0.3.0
65
+
66
+ `0.3.0` adds the server-only `bcp/application` composition root.
71
67
 
72
68
  ```ts
73
- import { createCacheStore } from "bcp/cache";
74
- import { db } from "bcp/database";
75
- import { createAuth } from "bcp/auth";
76
- import { createJobQueue } from "bcp/jobs";
77
- import { createWorkflow } from "bcp/workflow";
78
- import { createTransactionalOutbox } from "bcp/events";
79
- import { createRealtime } from "bcp/realtime";
80
- import { createTestApp } from "bcp/testing";
81
- import { createPluginHost } from "bcp/plugins";
82
- import { createTracer } from "bcp/observability";
83
- import { createDeploymentRuntime } from "bcp/deployment";
84
- ```
69
+ import {
70
+ createApp,
71
+ } from "bcp/application";
85
72
 
86
- ## Durable application infrastructure
73
+ export const app =
74
+ createApp({
75
+ name: "orders-api",
76
+ version: "1.0.0",
77
+ });
78
+ ```
87
79
 
88
- BCP keeps durable application state separate from transient delivery:
80
+ The runtime exposes one shared application context:
89
81
 
90
82
  ```text
91
- HTTP / API
92
- |
93
- +-- Database
94
- | +-- Transactional Outbox
95
- |
96
- +-- Jobs / Scheduler
97
- | +-- Workflow
98
- |
99
- +-- Realtime
100
- |
101
- +-- Cache
102
- |
103
- +-- Observability
104
- |
105
- +-- Deployment lifecycle
83
+ app.config
84
+ app.services
85
+ app.hooks
86
+ app.plugins
87
+ app.deployment
106
88
  ```
107
89
 
108
- Database/outbox/jobs/workflows remain durable truth. Realtime is transient delivery. Cache is an optimization layer. Tracing correlates operations without replacing state contracts.
90
+ Existing BCP subsystem APIs remain independent. Application Platform coordinates them; it does not replace them.
109
91
 
110
- ## Deployment Platform v2 — 0.2.18
111
-
112
- `0.2.18` adds the server-only `bcp/deployment` entrypoint.
92
+ ### Shared services
113
93
 
114
94
  ```ts
115
- import {
116
- createDeploymentRuntime,
117
- } from "bcp/deployment";
95
+ app.provide(
96
+ "database",
97
+ database
98
+ );
99
+
100
+ app.provide(
101
+ "cache",
102
+ cache
103
+ );
104
+ ```
118
105
 
119
- export const deployment =
120
- createDeploymentRuntime({
121
- serviceName: "orders-api",
122
- version: "1.0.0",
106
+ Existing plugins/modules use the same service registry:
107
+
108
+ ```ts
109
+ const app =
110
+ createApp({
111
+ name: "orders-api",
112
+ modules: [
113
+ backendModule,
114
+ ],
123
115
  });
124
116
  ```
125
117
 
126
- Register resources in dependency order:
118
+ ### Infrastructure lifecycle
127
119
 
128
120
  ```ts
129
- deployment.addResource({
121
+ app.addResource({
130
122
  name: "database",
131
123
 
132
- async start() {
133
- await db.connect();
124
+ start() {
125
+ return database.connect();
134
126
  },
135
127
 
136
- async ready() {
137
- return db.status === "ready";
128
+ ready() {
129
+ return database.ready;
138
130
  },
139
131
 
140
- async stop() {
141
- await db.close();
132
+ stop() {
133
+ return database.close();
142
134
  },
143
135
  });
136
+ ```
144
137
 
145
- deployment.addResource({
146
- name: "workers",
138
+ Startup is deterministic:
147
139
 
148
- start() {
149
- worker = jobs.startWorker();
150
- },
140
+ ```text
141
+ application.setup()
142
+
143
+ plugin setup/start
144
+
145
+ resources start
146
+
147
+ application.start()
148
+
149
+ ready
150
+ ```
151
151
 
152
- async stop() {
153
- await worker.stop();
154
- },
155
- });
152
+ Shutdown reverses dependencies:
156
153
 
157
- await deployment.start();
154
+ ```text
155
+ application.stop()
156
+
157
+ resources stop (reverse order)
158
+
159
+ plugin stop/dispose
160
+
161
+ application.dispose()
158
162
  ```
159
163
 
160
- Startup follows registration order. Shutdown runs in reverse order, so workers can stop before their database/cache/Redis dependencies close. If startup fails midway, already-started resources are rolled back in reverse order.
164
+ Start failures roll back already-started resources using Deployment Platform semantics.
161
165
 
162
- Readiness:
166
+ ### Readiness and diagnostics
163
167
 
164
168
  ```ts
165
- import {
166
- createDeploymentReadinessResponse,
167
- } from "bcp/deployment";
169
+ const readiness =
170
+ await app.readiness();
168
171
 
169
- export function GET() {
170
- return createDeploymentReadinessResponse(
171
- deployment
172
- );
173
- }
172
+ const diagnostics =
173
+ await app.diagnostics();
174
174
  ```
175
175
 
176
- A ready runtime returns `200`; starting, draining, failed or unhealthy runtimes return `503`.
177
-
178
- Diagnostics:
176
+ Graceful signal handling:
179
177
 
180
178
  ```ts
181
- import {
182
- createDeploymentDiagnosticsResponse,
183
- } from "bcp/deployment";
179
+ const removeSignals =
180
+ app.installSignalHandlers();
184
181
  ```
185
182
 
186
- Deployment metadata can use:
183
+ Framework shutdown registry:
187
184
 
188
- ```text
189
- BCP_DEPLOYMENT_ID
190
- BCP_INSTANCE_ID
191
- BCP_RELEASE
192
- NODE_ENV
193
- BCP_SHUTDOWN_TIMEOUT_MS
185
+ ```ts
186
+ const unregister =
187
+ app.registerShutdownHook();
194
188
  ```
195
189
 
196
- Signal ownership is optional:
190
+ Read more: [Application Platform](docs/application-platform.md) and [Migrating to 0.3.0](docs/migration-0.3.md).
197
191
 
198
- ```ts
199
- const removeSignalHandlers =
200
- deployment.installSignalHandlers();
192
+ ## Public entrypoints — 0.3.0 baseline
193
+
194
+ ```text
195
+ bcp
196
+ bcp/island
197
+ bcp/cache
198
+ bcp/config
199
+ bcp/validation
200
+ bcp/error
201
+ bcp/database
202
+ bcp/auth
203
+ bcp/jobs
204
+ bcp/workflow
205
+ bcp/events
206
+ bcp/realtime
207
+ bcp/testing
208
+ bcp/plugins
209
+ bcp/observability
210
+ bcp/deployment
211
+ bcp/application
212
+ bcp/server
213
+ bcp/server-only
214
+ bcp/middleware
201
215
  ```
202
216
 
203
- Default signals are `SIGTERM` and `SIGINT`. BCP sets `process.exitCode` after graceful shutdown instead of immediately terminating the process.
217
+ Application code should use public entrypoints rather than private `packages/*` files.
204
218
 
205
- The runtime can also integrate with the existing framework shutdown registry:
219
+ ## Core backend composition
206
220
 
207
221
  ```ts
208
- const unregister =
209
- deployment.registerShutdownHook();
222
+ import { createApp } from "bcp/application";
223
+ import { createCacheStore } from "bcp/cache";
224
+ import { db } from "bcp/database";
225
+ import { createAuth } from "bcp/auth";
226
+ import { createJobQueue } from "bcp/jobs";
227
+ import { createWorkflow } from "bcp/workflow";
228
+ import { createTransactionalOutbox } from "bcp/events";
229
+ import { createRealtime } from "bcp/realtime";
230
+ import { createPluginHost } from "bcp/plugins";
231
+ import { createTracer } from "bcp/observability";
232
+ import { createDeploymentRuntime } from "bcp/deployment";
210
233
  ```
211
234
 
212
- Read more: [Deployment Platform v2](docs/deployment-platform-v2.md)
235
+ You may use these systems independently or compose selected instances through `createApp()`.
213
236
 
214
237
  ## Compiled production entrypoints
215
238
 
@@ -228,98 +251,12 @@ bcp/testing -> testing.mjs
228
251
  bcp/plugins -> plugins.mjs
229
252
  bcp/observability -> observability.mjs
230
253
  bcp/deployment -> deployment.mjs
254
+ bcp/application -> application.mjs
231
255
  bcp/server -> server.mjs
232
256
  bcp/middleware -> middleware.mjs
233
257
  ```
234
258
 
235
- TypeScript source remains the type surface, while prepared production runtime resolution points to compiled `.mjs` files.
236
-
237
- ## Observability Platform v3 — 0.2.17
238
-
239
- ```ts
240
- import {
241
- createTracer,
242
- } from "bcp/observability";
243
-
244
- export const tracer =
245
- createTracer({
246
- serviceName: "orders-api",
247
- });
248
- ```
249
-
250
- `bcp/observability` supports root/child spans, AsyncLocalStorage context, W3C `traceparent`, correlation IDs, request tracing, trace carriers, memory/composite exporters and trace-to-Prometheus metrics.
251
-
252
- Read more: [Observability Platform v3](docs/observability-v3.md)
253
-
254
- ## Cache Platform v2 — 0.2.16
255
-
256
- ```ts
257
- import {
258
- createCacheStore,
259
- createRedisCacheAdapter,
260
- createRedisCacheLockAdapter,
261
- } from "bcp/cache";
262
- ```
263
-
264
- Cache Store v2 supports local singleflight, distributed cache-fill leases, heartbeat renewal, TTL, tag/path invalidation and cache metrics while keeping the original `cache()` / `dedupe()` APIs available.
265
-
266
- Read more: [Cache Platform v2](docs/cache-platform-v2.md)
267
-
268
- ## Plugin & Module Platform — 0.2.15
269
-
270
- `bcp/plugins` supports dependency ordering, setup/start/stop/dispose lifecycle, modules, config parsing, shared services and async hooks.
271
-
272
- Read more: [Plugin & Module Platform](docs/plugin-module-platform.md)
273
-
274
- ## Testing Platform — 0.2.14
275
-
276
- `bcp/testing` provides runner-neutral request/route/page/auth/database/middleware/jobs/workflow/outbox/realtime/SSE test helpers.
277
-
278
- Read more: [Testing Platform](docs/testing-platform.md)
279
-
280
- ## Realtime Platform — 0.2.13
281
-
282
- `bcp/realtime` provides channels/rooms, presence, broker delivery, provider-neutral socket adapters, SSE and heartbeat handling.
283
-
284
- Read more: [Realtime Platform](docs/realtime-platform.md)
285
-
286
- ## Transactional Outbox & Events — 0.2.12
287
-
288
- Use `bcp/events` to persist integration events in the same SQL transaction as business data, then dispatch after commit through durable jobs or custom publishers.
289
-
290
- Read more: [Transactional Outbox & Events](docs/transactional-outbox-events.md)
291
-
292
- ## Workflow Orchestration — 0.2.11
293
-
294
- `bcp/workflow` supports sequential/parallel steps, retries, persisted delays, run leases, compensation and optional durable queue execution.
295
-
296
- Read more: [Workflow Orchestration](docs/workflow-orchestration.md)
297
-
298
- ## Public entrypoints
299
-
300
- ```text
301
- bcp
302
- bcp/island
303
- bcp/cache
304
- bcp/config
305
- bcp/validation
306
- bcp/error
307
- bcp/database
308
- bcp/auth
309
- bcp/jobs
310
- bcp/workflow
311
- bcp/events
312
- bcp/realtime
313
- bcp/testing
314
- bcp/plugins
315
- bcp/observability
316
- bcp/deployment
317
- bcp/server
318
- bcp/server-only
319
- bcp/middleware
320
- ```
321
-
322
- Application code should use public entrypoints instead of private `packages/*` implementation files.
259
+ The reviewed prepared export map is recorded in `docs/api-freeze-snapshot.json` and validated by `npm run api:check`.
323
260
 
324
261
  ## CLI
325
262
 
@@ -354,36 +291,52 @@ bcp generate middleware
354
291
  bcp generate migration create_users
355
292
  ```
356
293
 
357
- ## Packaging
294
+ ## API baseline and release readiness
358
295
 
359
- Build and run directly:
296
+ `0.2.19` froze the `0.2.x` public contract. `0.3.0` intentionally establishes the next additive baseline with `bcp/application` while preserving existing entrypoints.
297
+
298
+ Check the current baseline:
360
299
 
361
300
  ```bash
362
- npm run build
363
- npm start
301
+ npm run api:check
364
302
  ```
365
303
 
366
- Create a standalone deployment package:
304
+ Regenerate the snapshot only for an intentional reviewed platform-baseline change:
367
305
 
368
306
  ```bash
369
- bcp package
307
+ npm run api:snapshot
370
308
  ```
371
309
 
372
- Application packages include production dependency manifests, deployment/environment metadata, file integrity metadata and a Docker starter while excluding `.env` secrets and application devDependencies.
310
+ Release metadata readiness:
373
311
 
374
- ## Documentation Platform
312
+ ```bash
313
+ npm run release:readiness
314
+ ```
375
315
 
376
- Machine-readable contracts:
316
+ Optional machine-readable report:
317
+
318
+ ```bash
319
+ npm run release:readiness:report
320
+ ```
321
+
322
+ Output:
323
+
324
+ ```text
325
+ .bcp-framework/release-readiness.json
326
+ ```
327
+
328
+ ## Machine-readable contracts
377
329
 
378
330
  ```text
379
331
  docs/platform-manifest.json
380
332
  docs/docs-web-manifest.json
381
333
  docs/api-manifest.json
334
+ docs/api-freeze-snapshot.json
382
335
  ```
383
336
 
384
337
  ## Release validation
385
338
 
386
- Before publishing `0.2.18`:
339
+ Before publishing `0.3.0`:
387
340
 
388
341
  ```bash
389
342
  npm run typecheck
@@ -391,11 +344,11 @@ npm run test:unit
391
344
  npm run test:integration
392
345
  npm run test:e2e
393
346
  npm run test:package
347
+ npm run api:check
348
+ npm run release:readiness
394
349
  npm run rc:check
395
350
  ```
396
351
 
397
- `0.2.18` adds unit and prepared-package smoke coverage for deployment lifecycle ordering, startup rollback, readiness/diagnostics, runtime metadata, server-only boundaries and compiled config/auth/observability/deployment/server/middleware runtimes.
398
-
399
352
  Do not tag or publish until the exact final release commit passes the full RC sequence.
400
353
 
401
354
  ## Release history
@@ -427,14 +380,14 @@ Do not tag or publish until the exact final release commit passes the full RC se
427
380
  | `0.2.16` | Cache Platform v2 |
428
381
  | `0.2.17` | Observability Platform v3 |
429
382
  | `0.2.18` | Deployment Platform v2 |
383
+ | `0.2.19` | Stability & API Freeze |
384
+ | `0.3.0` | BCP Application Platform |
430
385
 
431
386
  ## Roadmap
432
387
 
433
- `0.2.18` establishes a consistent production lifecycle and compiled server runtime boundary for the current BCP 0.2.x platform.
434
-
435
- The next milestone is **`0.2.19 — Stability & API Freeze`**, focused on final API consistency, deprecation policy, performance/regression hardening, migration diagnostics and release-quality compatibility before `0.3.0`.
388
+ The next milestone is **`0.3.1 Dependency Injection & Service Container`**, building typed service tokens, singleton/scoped/transient lifetimes, request scopes, factories and testing overrides on top of the Application Platform service composition model.
436
389
 
437
- `0.3.0` is planned as the next BCP Application Platform baseline.
390
+ Later `0.3.x` milestones expand modules, typed APIs, SDK generation, identity/authorization, multi-tenancy, developer tooling and build/runtime targets.
438
391
 
439
392
  Native desktop/mobile compilation remains later roadmap work.
440
393