@chidchanun/bcp 0.2.19 → 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,36 +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.19Stability & API Freeze`
5
+ > **Development target:** `0.3.0BCP Application Platform`
6
6
  >
7
- > `0.2.19` 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
- | Jobs | Delay, retries, scheduling, Redis-compatible durable queues, heartbeat, stale recovery and DLQ |
20
+ | Jobs | Delay, retries, scheduling, Redis-compatible durable queues, heartbeat, recovery and DLQ |
23
21
  | Workflows | Sequential/parallel steps, retries, persisted delays, compensation and run leases |
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 |
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 |
26
28
  | 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 |
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 |
34
31
 
35
32
  ## Requirements
36
33
 
@@ -64,77 +61,165 @@ Generated projects normally use one framework dependency:
64
61
  }
65
62
  ```
66
63
 
67
- ## Public entrypointsfrozen for 0.2.19
64
+ ## BCP Application Platform — 0.3.0
65
+
66
+ `0.3.0` adds the server-only `bcp/application` composition root.
67
+
68
+ ```ts
69
+ import {
70
+ createApp,
71
+ } from "bcp/application";
72
+
73
+ export const app =
74
+ createApp({
75
+ name: "orders-api",
76
+ version: "1.0.0",
77
+ });
78
+ ```
79
+
80
+ The runtime exposes one shared application context:
68
81
 
69
82
  ```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
83
+ app.config
84
+ app.services
85
+ app.hooks
86
+ app.plugins
87
+ app.deployment
89
88
  ```
90
89
 
91
- Application code should use these public entrypoints instead of private `packages/*` implementation files.
90
+ Existing BCP subsystem APIs remain independent. Application Platform coordinates them; it does not replace them.
92
91
 
93
- ## Stability & API Freeze — 0.2.19
92
+ ### Shared services
94
93
 
95
- The committed freeze contract is:
94
+ ```ts
95
+ app.provide(
96
+ "database",
97
+ database
98
+ );
99
+
100
+ app.provide(
101
+ "cache",
102
+ cache
103
+ );
104
+ ```
96
105
 
97
- ```text
98
- docs/api-freeze-snapshot.json
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
+ ],
115
+ });
99
116
  ```
100
117
 
101
- It locks the current public entrypoint set, CLI command set, API ownership and exact prepared npm export targets.
118
+ ### Infrastructure lifecycle
119
+
120
+ ```ts
121
+ app.addResource({
122
+ name: "database",
102
123
 
103
- Check compatibility:
124
+ start() {
125
+ return database.connect();
126
+ },
104
127
 
105
- ```bash
106
- npm run api:check
128
+ ready() {
129
+ return database.ready;
130
+ },
131
+
132
+ stop() {
133
+ return database.close();
134
+ },
135
+ });
107
136
  ```
108
137
 
109
- Regenerate the snapshot only when an intentional platform-baseline change is reviewed:
138
+ Startup is deterministic:
110
139
 
111
- ```bash
112
- npm run api:snapshot
140
+ ```text
141
+ application.setup()
142
+
143
+ plugin setup/start
144
+
145
+ resources start
146
+
147
+ application.start()
148
+
149
+ ready
113
150
  ```
114
151
 
115
- Release metadata readiness:
152
+ Shutdown reverses dependencies:
116
153
 
117
- ```bash
118
- npm run release:readiness
154
+ ```text
155
+ application.stop()
156
+
157
+ resources stop (reverse order)
158
+
159
+ plugin stop/dispose
160
+
161
+ application.dispose()
119
162
  ```
120
163
 
121
- Persist a local machine-readable report:
164
+ Start failures roll back already-started resources using Deployment Platform semantics.
122
165
 
123
- ```bash
124
- npm run release:readiness:report
166
+ ### Readiness and diagnostics
167
+
168
+ ```ts
169
+ const readiness =
170
+ await app.readiness();
171
+
172
+ const diagnostics =
173
+ await app.diagnostics();
125
174
  ```
126
175
 
127
- Output:
176
+ Graceful signal handling:
177
+
178
+ ```ts
179
+ const removeSignals =
180
+ app.installSignalHandlers();
181
+ ```
182
+
183
+ Framework shutdown registry:
184
+
185
+ ```ts
186
+ const unregister =
187
+ app.registerShutdownHook();
188
+ ```
189
+
190
+ Read more: [Application Platform](docs/application-platform.md) and [Migrating to 0.3.0](docs/migration-0.3.md).
191
+
192
+ ## Public entrypoints — 0.3.0 baseline
128
193
 
129
194
  ```text
130
- .bcp-framework/release-readiness.json
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
131
215
  ```
132
216
 
133
- Read more: [Stability & API Freeze](docs/stability-api-freeze.md)
217
+ Application code should use public entrypoints rather than private `packages/*` files.
134
218
 
135
- ## Core backend entrypoints
219
+ ## Core backend composition
136
220
 
137
221
  ```ts
222
+ import { createApp } from "bcp/application";
138
223
  import { createCacheStore } from "bcp/cache";
139
224
  import { db } from "bcp/database";
140
225
  import { createAuth } from "bcp/auth";
@@ -142,37 +227,12 @@ import { createJobQueue } from "bcp/jobs";
142
227
  import { createWorkflow } from "bcp/workflow";
143
228
  import { createTransactionalOutbox } from "bcp/events";
144
229
  import { createRealtime } from "bcp/realtime";
145
- import { createTestApp } from "bcp/testing";
146
230
  import { createPluginHost } from "bcp/plugins";
147
231
  import { createTracer } from "bcp/observability";
148
232
  import { createDeploymentRuntime } from "bcp/deployment";
149
233
  ```
150
234
 
151
- ## Deployment lifecycle
152
-
153
- ```ts
154
- import {
155
- createDeploymentRuntime,
156
- } from "bcp/deployment";
157
-
158
- const deployment =
159
- createDeploymentRuntime({
160
- serviceName: "orders-api",
161
- });
162
-
163
- deployment.addResource({
164
- name: "database",
165
- start: () => db.connect(),
166
- ready: () => db.status === "ready",
167
- stop: () => db.close(),
168
- });
169
-
170
- await deployment.start();
171
- ```
172
-
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.
174
-
175
- Read more: [Deployment Platform v2](docs/deployment-platform-v2.md)
235
+ You may use these systems independently or compose selected instances through `createApp()`.
176
236
 
177
237
  ## Compiled production entrypoints
178
238
 
@@ -191,11 +251,12 @@ bcp/testing -> testing.mjs
191
251
  bcp/plugins -> plugins.mjs
192
252
  bcp/observability -> observability.mjs
193
253
  bcp/deployment -> deployment.mjs
254
+ bcp/application -> application.mjs
194
255
  bcp/server -> server.mjs
195
256
  bcp/middleware -> middleware.mjs
196
257
  ```
197
258
 
198
- The exact prepared export map is now part of the API freeze contract.
259
+ The reviewed prepared export map is recorded in `docs/api-freeze-snapshot.json` and validated by `npm run api:check`.
199
260
 
200
261
  ## CLI
201
262
 
@@ -230,14 +291,39 @@ bcp generate middleware
230
291
  bcp generate migration create_users
231
292
  ```
232
293
 
233
- ## Packaging
294
+ ## API baseline and release readiness
295
+
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:
234
299
 
235
300
  ```bash
236
- npm run build
237
- bcp package
301
+ npm run api:check
302
+ ```
303
+
304
+ Regenerate the snapshot only for an intentional reviewed platform-baseline change:
305
+
306
+ ```bash
307
+ npm run api:snapshot
308
+ ```
309
+
310
+ Release metadata readiness:
311
+
312
+ ```bash
313
+ npm run release:readiness
238
314
  ```
239
315
 
240
- Application packages include production dependency manifests, deployment/environment metadata, file-integrity metadata and a Docker starter while excluding `.env` secrets and application devDependencies.
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
+ ```
241
327
 
242
328
  ## Machine-readable contracts
243
329
 
@@ -250,7 +336,7 @@ docs/api-freeze-snapshot.json
250
336
 
251
337
  ## Release validation
252
338
 
253
- Before publishing `0.2.19`:
339
+ Before publishing `0.3.0`:
254
340
 
255
341
  ```bash
256
342
  npm run typecheck
@@ -263,9 +349,7 @@ npm run release:readiness
263
349
  npm run rc:check
264
350
  ```
265
351
 
266
- `release:check` now runs the full tests, API compatibility gate, release-readiness gate and release metadata validation.
267
-
268
- Do not tag or publish until the exact final release commit passes the complete RC sequence.
352
+ Do not tag or publish until the exact final release commit passes the full RC sequence.
269
353
 
270
354
  ## Release history
271
355
 
@@ -297,12 +381,13 @@ Do not tag or publish until the exact final release commit passes the complete R
297
381
  | `0.2.17` | Observability Platform v3 |
298
382
  | `0.2.18` | Deployment Platform v2 |
299
383
  | `0.2.19` | Stability & API Freeze |
384
+ | `0.3.0` | BCP Application Platform |
300
385
 
301
386
  ## Roadmap
302
387
 
303
- `0.2.19` freezes the supported `0.2.x` application/runtime contract and becomes the compatibility reference for the next platform generation.
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.
304
389
 
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.
390
+ Later `0.3.x` milestones expand modules, typed APIs, SDK generation, identity/authorization, multi-tenancy, developer tooling and build/runtime targets.
306
391
 
307
392
  Native desktop/mobile compilation remains later roadmap work.
308
393
 
package/docs/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  The `docs/` directory is the documentation source of truth for BCP Framework and is organized for **`bcp-docs-web`**.
4
4
 
5
- > **Documentation target:** BCP Framework `0.2.19Stability & API Freeze`
5
+ > **Documentation target:** BCP Framework `0.3.0BCP Application Platform`
6
6
  >
7
7
  > **Release state:** unreleased development target until RC validation, tagging and npm publication complete.
8
8
 
@@ -19,12 +19,12 @@ docs/api-manifest.json
19
19
  -> public package entrypoints, source ownership and guide mapping
20
20
 
21
21
  docs/api-freeze-snapshot.json
22
- -> frozen public/CLI/prepared-package compatibility contract
22
+ -> reviewed public/CLI/prepared-package API baseline
23
23
  ```
24
24
 
25
25
  Framework source and tests remain authoritative for runtime behavior.
26
26
 
27
- ## Current 0.2.x milestones
27
+ ## Current platform milestones
28
28
 
29
29
  | Version | Milestone |
30
30
  | --- | --- |
@@ -48,40 +48,84 @@ Framework source and tests remain authoritative for runtime behavior.
48
48
  | `0.2.17` | Observability Platform v3 |
49
49
  | `0.2.18` | Deployment Platform v2 |
50
50
  | `0.2.19` | Stability & API Freeze |
51
+ | `0.3.0` | BCP Application Platform |
51
52
 
52
- ## 0.2.19Stability & API Freeze
53
+ ## 0.3.0BCP Application Platform
53
54
 
54
- `0.2.19` freezes the supported `0.2.x` public package and CLI contract without adding a new application subsystem.
55
+ `0.3.0` adds one server-only public composition root:
55
56
 
56
- Primary stability commands:
57
+ ```text
58
+ bcp/application
59
+ ```
60
+
61
+ Primary APIs:
62
+
63
+ ```ts
64
+ import {
65
+ createApp,
66
+ defineApp,
67
+ } from "bcp/application";
68
+ ```
69
+
70
+ The application runtime composes existing Plugin and Deployment platforms instead of duplicating them. It provides:
71
+
72
+ - typed application config parsing;
73
+ - a shared service registry and hook bus;
74
+ - existing plugin/module composition;
75
+ - application-owned deployment resources;
76
+ - deterministic startup/shutdown ordering;
77
+ - startup rollback;
78
+ - readiness and diagnostics;
79
+ - signal/shutdown-hook integration;
80
+ - compiled `application.mjs` production runtime.
81
+
82
+ Lifecycle:
83
+
84
+ ```text
85
+ application.setup
86
+
87
+ plugins
88
+
89
+ resources
90
+
91
+ application.start
92
+
93
+ ready
94
+
95
+ shutdown:
96
+ application.stop
97
+
98
+ resources (reverse)
99
+
100
+ plugins
101
+
102
+ application.dispose
103
+ ```
104
+
105
+ Read [Application Platform](application-platform.md) and [Migrating to 0.3.0](migration-0.3.md).
106
+
107
+ ## API baseline
108
+
109
+ `0.2.19` froze the final `0.2.x` public contract. `0.3.0` establishes the next reviewed baseline by adding `bcp/application` without intentionally removing existing `0.2.19` entrypoints.
110
+
111
+ Validate the current baseline:
57
112
 
58
113
  ```bash
59
114
  npm run api:check
60
- npm run api:snapshot
61
- npm run release:readiness
62
- npm run release:readiness:report
63
115
  ```
64
116
 
65
- The freeze snapshot captures:
117
+ Regenerate only when an intentional platform-baseline change is being reviewed:
66
118
 
67
- - public `bcp/*` entrypoints;
68
- - CLI command names;
69
- - prepared npm export targets;
70
- - browser poison boundaries;
71
- - API source/environment ownership;
72
- - compatibility with `0.2.18`.
73
-
74
- `npm run api:check` prepares the exact npm staging package and rejects drift from the committed snapshot.
119
+ ```bash
120
+ npm run api:snapshot
121
+ ```
75
122
 
76
- New/updated sources:
123
+ Release metadata readiness:
77
124
 
78
- | Source | Purpose |
79
- | --- | --- |
80
- | `stability-api-freeze.md` | Freeze policy, compatibility checks and release readiness |
81
- | `api-freeze-snapshot.json` | Frozen public/CLI/package contract |
82
- | `platform-manifest.json` | Stability capability flags and `0.2.18` compatibility baseline |
83
- | `docs-web-manifest.json` | Stability guide and `0.2.19` release route |
84
- | `releases/0.2.19.md` | Stability & API Freeze release notes |
125
+ ```bash
126
+ npm run release:readiness
127
+ npm run release:readiness:report
128
+ ```
85
129
 
86
130
  ## Update rule
87
131
 
@@ -93,7 +137,7 @@ When framework behavior or public surface changes:
93
137
  4. Update `platform-manifest.json` for runtime/public-entrypoint/capability changes.
94
138
  5. Update `api-manifest.json` for public API ownership/guide changes.
95
139
  6. Update `docs-web-manifest.json` for website route/navigation changes.
96
- 7. Review `api-freeze-snapshot.json`; do not regenerate it casually during `0.2.19`.
140
+ 7. Review the API baseline snapshot when public/package contracts change.
97
141
  8. Update `docs/releases/<version>.md`.
98
142
  9. Change release state only after the release workflow reaches that state.
99
143
 
@@ -101,6 +145,8 @@ When framework behavior or public surface changes:
101
145
 
102
146
  | Website route | Markdown source |
103
147
  | --- | --- |
148
+ | `/docs/application-platform` | `application-platform.md` |
149
+ | `/docs/migration-0.3` | `migration-0.3.md` |
104
150
  | `/docs/stability-api-freeze` | `stability-api-freeze.md` |
105
151
  | `/docs/observability-v3` | `observability-v3.md` |
106
152
  | `/docs/deployment-platform-v2` | `deployment-platform-v2.md` |
@@ -112,7 +158,7 @@ When framework behavior or public surface changes:
112
158
  | `/docs/plugin-module-platform` | `plugin-module-platform.md` |
113
159
  | `/docs/cache-platform-v2` | `cache-platform-v2.md` |
114
160
  | `/docs/api-reference` | `api-reference.md` |
115
- | `/releases/0.2.19` | `releases/0.2.19.md` |
161
+ | `/releases/0.3.0` | `releases/0.3.0.md` |
116
162
 
117
163
  Every route/source pair is validated by unit tests.
118
164
 
@@ -135,16 +181,17 @@ bcp/testing
135
181
  bcp/plugins
136
182
  bcp/observability
137
183
  bcp/deployment
184
+ bcp/application
138
185
  bcp/server
139
186
  bcp/server-only
140
187
  bcp/middleware
141
188
  ```
142
189
 
143
- The API-manifest entrypoint set, platform public-entrypoint set and freeze snapshot must remain aligned.
190
+ The API manifest, platform manifest and reviewed API baseline must remain aligned.
144
191
 
145
192
  ## Release validation
146
193
 
147
- Before publishing `0.2.19`:
194
+ Before publishing `0.3.0`:
148
195
 
149
196
  ```bash
150
197
  npm run typecheck
@@ -157,6 +204,4 @@ npm run release:readiness
157
204
  npm run rc:check
158
205
  ```
159
206
 
160
- Stability validation covers public/CLI/export parity, prepared-package browser/runtime boundaries, release metadata and deployment lifecycle idempotency in addition to all existing subsystem suites.
161
-
162
207
  The final release tag must point to the exact commit that passed the complete RC sequence.