@chidchanun/bcp 0.2.1 → 0.2.2

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/docs/README.md CHANGED
@@ -2,11 +2,11 @@
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.1`
5
+ > **Documentation target:** BCP Framework `0.2.2`
6
6
  >
7
- > **Release state:** unreleased development target. Do not label `0.2.1` as published until RC validation, tagging and npm publication complete.
7
+ > **Release state:** unreleased development target. Do not label `0.2.2` as published until RC validation, tagging and npm publication complete.
8
8
 
9
- ## Documentation architecture — 0.2.1
9
+ ## Documentation architecture
10
10
 
11
11
  BCP uses three machine-readable documentation contracts:
12
12
 
@@ -41,20 +41,31 @@ manifest-driven sync
41
41
 
42
42
  Framework source and tests remain authoritative for runtime behavior.
43
43
 
44
- ## Documentation Platform
44
+ ## 0.2.2 — Configuration & Environment v2
45
45
 
46
- `0.2.1` adds a versioned contract between the framework repository and the documentation website.
46
+ `0.2.2` adds an optional typed application environment schema while preserving the established framework configuration precedence.
47
47
 
48
- New sources:
48
+ New/updated documentation sources:
49
49
 
50
50
  | Source | Purpose |
51
51
  | --- | --- |
52
- | `api-manifest.json` | Public API entrypoint metadata |
53
- | `api-reference.md` | Human-readable public package entrypoint reference |
54
- | `documentation-platform.md` | Docs-web synchronization/versioning contract |
55
- | `releases/0.2.1.md` | Documentation Platform release notes |
52
+ | `environment-validation.md` | `bcp.environment.*`, validation rules, CLI checks and secret/public boundaries |
53
+ | `configuration.md` | Framework configuration precedence and diagnostics workflow |
54
+ | `platform-manifest.json` | Declares typed environment/config diagnostics capabilities |
55
+ | `api-manifest.json` | Maps `bcp/config` to configuration and environment guides |
56
+ | `releases/0.2.2.md` | Configuration & Environment v2 release notes |
56
57
 
57
- The website should not maintain a second hard-coded list of framework pages when those pages exist in `docs-web-manifest.json`.
58
+ Primary command:
59
+
60
+ ```bash
61
+ bcp config check
62
+ ```
63
+
64
+ JSON diagnostics:
65
+
66
+ ```bash
67
+ bcp config check --json
68
+ ```
58
69
 
59
70
  ## Update rule
60
71
 
@@ -64,14 +75,14 @@ When framework behavior or public surface changes:
64
75
  2. Add/update regression tests.
65
76
  3. Update the matching Markdown guide.
66
77
  4. Update `platform-manifest.json` when runtime/public-entrypoint/capability metadata changes.
67
- 5. Update `api-manifest.json` when public API entrypoint ownership changes.
78
+ 5. Update `api-manifest.json` when public API ownership/guide mapping changes.
68
79
  6. Update `docs-web-manifest.json` when website routes/navigation change.
69
80
  7. Update `docs/releases/<version>.md`.
70
81
  8. Change release state only after the release workflow reaches that state.
71
82
 
72
83
  ## Docs-web navigation
73
84
 
74
- `docs/docs-web-manifest.json` is the ordered navigation contract.
85
+ `docs/docs-web-manifest.json` is the authoritative ordered navigation contract.
75
86
 
76
87
  Current sections:
77
88
 
@@ -88,46 +99,104 @@ API Reference
88
99
  Releases
89
100
  ```
90
101
 
91
- Important `0.2.1` routes:
102
+ Important current routes:
92
103
 
93
104
  | Website route | Markdown source |
94
105
  | --- | --- |
106
+ | `/docs/configuration` | `configuration.md` |
107
+ | `/docs/environment-validation` | `environment-validation.md` |
95
108
  | `/docs/platform-contract` | `platform-contract.md` |
96
109
  | `/docs/documentation-platform` | `documentation-platform.md` |
97
110
  | `/docs/migration-0.2` | `migration-0.2.md` |
98
111
  | `/docs/api-reference` | `api-reference.md` |
99
- | `/releases/0.2.1` | `releases/0.2.1.md` |
112
+ | `/releases/0.2.2` | `releases/0.2.2.md` |
100
113
 
101
114
  Every route/source pair is validated by unit tests.
102
115
 
116
+ ## Configuration source model
117
+
118
+ Framework settings:
119
+
120
+ ```text
121
+ bcp.config.ts
122
+ bcp.config.mts
123
+ bcp.config.js
124
+ bcp.config.mjs
125
+ ```
126
+
127
+ Application environment schema:
128
+
129
+ ```text
130
+ bcp.environment.ts
131
+ bcp.environment.mts
132
+ bcp.environment.js
133
+ bcp.environment.mjs
134
+ ```
135
+
136
+ Only one file from each convention may exist at a time.
137
+
138
+ The environment schema is optional. Existing applications without `bcp.environment.*` continue to use the previous environment-loading behavior.
139
+
140
+ Configuration precedence remains:
141
+
142
+ ```text
143
+ CLI override
144
+
145
+ BCP_* environment
146
+
147
+ bcp.config.*
148
+
149
+ framework defaults
150
+ ```
151
+
152
+ See [Environment Validation](environment-validation.md).
153
+
154
+ ## Environment security boundary
155
+
156
+ `BCP_PUBLIC_*` values may be embedded into browser bundles. They must never contain credentials/private secrets.
157
+
158
+ A variable declared with:
159
+
160
+ ```ts
161
+ secret: true
162
+ ```
163
+
164
+ must not use the `BCP_PUBLIC_` prefix. The configuration validator treats that combination as an error.
165
+
166
+ `secret: true` is validation/tooling metadata and does not encrypt a value.
167
+
103
168
  ## Platform manifest
104
169
 
105
- `docs/platform-manifest.json` describes the supported framework baseline:
170
+ `docs/platform-manifest.json` describes the supported framework baseline, including:
106
171
 
107
172
  ```text
108
- schema version
109
173
  framework version/release state
110
174
  Node/React/runtime baseline
111
175
  production build target
112
176
  public package entrypoints
113
177
  CLI command families
114
- capabilities
115
- storage-provider families
116
- previous baseline compatibility intent
178
+ capability flags
179
+ previous-baseline compatibility intent
117
180
  documentation contract files
118
181
  ```
119
182
 
120
- Supported production target remains:
183
+ `0.2.2` declares the additional capabilities:
121
184
 
122
185
  ```text
123
- standalone-node
186
+ typedEnvironmentSchema
187
+ configurationDiagnostics
188
+ configCheckCli
124
189
  ```
125
190
 
126
- Native executable, desktop and mobile compilation remain future roadmap work.
191
+ The supported production target remains:
192
+
193
+ ```text
194
+ standalone-node
195
+ ```
127
196
 
128
197
  ## API manifest
129
198
 
130
- `docs/api-manifest.json` describes the public package entrypoints that documentation tooling may present as supported API surfaces.
199
+ `docs/api-manifest.json` describes the public package entrypoints documentation tooling may present as supported API surfaces.
131
200
 
132
201
  Current entrypoints:
133
202
 
@@ -145,24 +214,18 @@ bcp/server-only
145
214
  bcp/middleware
146
215
  ```
147
216
 
148
- Each API entry records:
217
+ `bcp/config` owns both:
149
218
 
150
219
  ```text
151
- package
152
- source file
153
- environment boundary
154
- reference route
155
- summary
156
- related guide routes
220
+ /docs/configuration
221
+ /docs/environment-validation
157
222
  ```
158
223
 
159
- The API-manifest entrypoint set must match the public-entrypoint set in `platform-manifest.json` exactly.
160
-
161
- See [API Reference](api-reference.md).
224
+ The API-manifest entrypoint set must match the platform public-entrypoint set exactly.
162
225
 
163
226
  ## bcp-docs-web synchronization
164
227
 
165
- The `bcp-docs-web` sync should load all three manifests first.
228
+ The docs website sync loads the manifests before Markdown content:
166
229
 
167
230
  ```text
168
231
  selected framework ref
@@ -173,41 +236,19 @@ api-manifest.json
173
236
 
174
237
  validate version/release/API parity
175
238
 
176
- load only referenced Markdown
177
-
178
- rewrite internal Markdown links to website routes
239
+ load referenced Markdown
179
240
 
180
241
  synchronize CMS/search/navigation
181
242
  ```
182
243
 
183
- The matching docs-web implementation supports local framework source or a selected Git ref.
184
-
185
- Examples:
244
+ Examples from the docs-web project:
186
245
 
187
246
  ```powershell
188
247
  npm run docs:sync -- --dry-run
189
248
  npm run docs:sync -- --publish-new
190
- npm run docs:sync -- --ref=v0.2.0
249
+ npm run docs:sync -- --ref=v0.2.1
191
250
  ```
192
251
 
193
- Using a tag/ref is the foundation for historical/versioned documentation without manually copying current Markdown into another source tree.
194
-
195
- ## Public API guide ownership
196
-
197
- | Entrypoint | Primary guides |
198
- | --- | --- |
199
- | `bcp` | `routing.md`, `server-data-loaders.md`, `route-guards.md`, `form-actions.md` |
200
- | `bcp/island` | `hydration.md` |
201
- | `bcp/cache` | `caching.md` |
202
- | `bcp/config` | `configuration.md` |
203
- | `bcp/validation` | `validation.md` |
204
- | `bcp/error` | `error-handling.md` |
205
- | `bcp/database` | `database.md`, `database-migrations.md` |
206
- | `bcp/auth` | `authentication.md`, `auth-route-guards.md`, `session-auth.md` |
207
- | `bcp/server` | `server-request-apis.md`, `file-upload.md`, `storage.md`, `storage-ecosystem.md`, `production-hardening.md` |
208
- | `bcp/server-only` | `application-modules.md` |
209
- | `bcp/middleware` | `middleware.md` |
210
-
211
252
  ## Source conventions
212
253
 
213
254
  - one H1 per Markdown page,
@@ -220,15 +261,9 @@ Using a tag/ref is the foundation for historical/versioned documentation without
220
261
  - no framework-internal module presented as public API,
221
262
  - no secrets/runtime `.env` values in public documentation metadata.
222
263
 
223
- ## Search and previous/next
224
-
225
- Search should index Markdown content and headings. Manifest titles/categories/API summaries may be used as metadata.
226
-
227
- Sidebar and previous/next ordering should follow `docs-web-manifest.json` order so navigation surfaces cannot drift from each other.
228
-
229
264
  ## Release validation
230
265
 
231
- Before publishing `0.2.1`:
266
+ Before publishing `0.2.2`:
232
267
 
233
268
  ```bash
234
269
  npm run typecheck
@@ -239,14 +274,17 @@ npm run test:e2e
239
274
  npm run rc:check
240
275
  ```
241
276
 
242
- Documentation Platform validation covers:
277
+ Configuration & Environment v2 validation covers:
243
278
 
244
- - every Markdown source exists,
245
- - every docs/release route is unique,
246
- - package/platform/docs/API versions match,
247
- - API entrypoints match the platform public-entrypoint set,
248
- - API guide routes exist,
249
- - prepared npm packages contain the three manifests, API reference and Documentation Platform guide.
279
+ - typed environment rules/defaults,
280
+ - project `bcp.environment.*` loading,
281
+ - public/secret safety boundary,
282
+ - production diagnostics,
283
+ - `bcp config check` CLI parsing,
284
+ - dev schema watching,
285
+ - public `bcp/config` exports,
286
+ - prepared npm package files,
287
+ - docs/platform/API version parity.
250
288
 
251
289
  The final release tag must point to the exact commit that passed the complete RC sequence.
252
290
 
@@ -272,12 +310,13 @@ release notes
272
310
  Planned next milestone:
273
311
 
274
312
  ```text
275
- 0.2.2Configuration & Environment v2
313
+ 0.2.3Database Platform v2
276
314
  ```
277
315
 
278
316
  Focus:
279
317
 
280
- - typed production configuration improvements,
281
- - environment validation,
282
- - startup configuration diagnostics,
283
- - configuration schema/inspection tooling.
318
+ - database adapter contract,
319
+ - PostgreSQL support,
320
+ - SQLite support,
321
+ - connection lifecycle improvements,
322
+ - provider-consistent migration workflows.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "framework": "bcp",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "releaseState": "unreleased",
6
6
  "coverage": "public-entrypoints",
7
7
  "entrypoints": [
@@ -43,9 +43,10 @@
43
43
  "source": "packages/client/src/config.ts",
44
44
  "environment": "server",
45
45
  "route": "/docs/api-reference#bcp-config",
46
- "summary": "Typed BCP configuration definition, loading and resolution APIs.",
46
+ "summary": "Typed BCP configuration, environment-schema validation and configuration diagnostics APIs.",
47
47
  "guides": [
48
- "/docs/configuration"
48
+ "/docs/configuration",
49
+ "/docs/environment-validation"
49
50
  ]
50
51
  },
51
52
  {
@@ -62,17 +62,27 @@ Related guide: [Caching](caching.md).
62
62
 
63
63
  ## `bcp/config`
64
64
 
65
- Typed configuration APIs.
65
+ Typed framework configuration, application environment-schema validation and diagnostics APIs.
66
66
 
67
67
  ```ts
68
68
  import {
69
+ applyEnvironmentDefaults,
69
70
  defineConfig,
71
+ defineEnvironment,
72
+ diagnoseBcpConfiguration,
73
+ getEnvironmentSchemaFileNames,
74
+ loadBcpEnvironmentSchema,
70
75
  readResolvedBcpConfig,
71
76
  resolveBcpConfig,
77
+ validateEnvironment,
72
78
  } from "bcp/config";
73
79
  ```
74
80
 
75
- Related guide: [Configuration](configuration.md).
81
+ Use `defineConfig()` for framework runtime/build settings and `defineEnvironment()` for the optional `bcp.environment.*` application-variable schema.
82
+
83
+ `validateEnvironment()` returns parsed declared values and structured issues. `applyEnvironmentDefaults()` fills only missing environment keys and does not overwrite values already supplied by the environment/runtime.
84
+
85
+ Related guides: [Configuration](configuration.md), [Environment Validation](environment-validation.md).
76
86
 
77
87
  ## `bcp/validation`
78
88
 
@@ -92,6 +92,101 @@ BCP_EXPERIMENTAL_ISLANDS
92
92
 
93
93
  Application environment variables prefixed with `BCP_PUBLIC_` may be embedded into browser bundles. Other application variables remain server-side.
94
94
 
95
+ ## Configuration & Environment v2
96
+
97
+ BCP `0.2.2` adds an optional application environment schema in one of:
98
+
99
+ ```text
100
+ bcp.environment.ts
101
+ bcp.environment.mts
102
+ bcp.environment.js
103
+ bcp.environment.mjs
104
+ ```
105
+
106
+ The schema validates application-specific values after `.env` files are loaded.
107
+
108
+ Example:
109
+
110
+ ```ts
111
+ import {
112
+ defineEnvironment,
113
+ } from "bcp/config";
114
+
115
+ export default defineEnvironment({
116
+ DATABASE_URL: {
117
+ type: "string",
118
+ required: true,
119
+ },
120
+ SESSION_SECRET: {
121
+ type: "string",
122
+ required: true,
123
+ secret: true,
124
+ minLength: 32,
125
+ },
126
+ BCP_PUBLIC_API_URL: {
127
+ type: "url",
128
+ required: true,
129
+ },
130
+ });
131
+ ```
132
+
133
+ This schema is additive. Projects without `bcp.environment.*` continue to use the existing environment behavior.
134
+
135
+ Read more: [Environment Validation](environment-validation.md)
136
+
137
+ ## Configuration check
138
+
139
+ Validate the current project without starting the application:
140
+
141
+ ```bash
142
+ bcp config check
143
+ ```
144
+
145
+ JSON diagnostics:
146
+
147
+ ```bash
148
+ bcp config check --json
149
+ ```
150
+
151
+ Windows project-local form:
152
+
153
+ ```powershell
154
+ npm exec -- bcp-framework config check
155
+ ```
156
+
157
+ The check reports the selected config file, environment files, environment schema, resolved server/build settings and diagnostics. Raw environment values are not printed.
158
+
159
+ For production-mode warnings in PowerShell:
160
+
161
+ ```powershell
162
+ $env:NODE_ENV = "production"
163
+ npm exec -- bcp-framework config check
164
+ Remove-Item Env:NODE_ENV
165
+ ```
166
+
167
+ ## Startup diagnostics
168
+
169
+ `bcp dev` and `bcp build` run the environment-schema diagnostics before the application starts/builds.
170
+
171
+ Schema errors stop startup/build early. Production safety warnings do not fail the build by themselves.
172
+
173
+ Examples of production warnings include:
174
+
175
+ - source maps enabled,
176
+ - powered-by header enabled,
177
+ - Content-Security-Policy disabled,
178
+ - trusted proxy mode enabled.
179
+
180
+ Trusted proxy mode should only be enabled when untrusted clients cannot bypass the trusted proxy/load balancer.
181
+
95
182
  ## Config reload in development
96
183
 
97
- Changes to supported `.env*` files or `bcp.config.*` restart the development worker so the new resolved configuration is applied without restarting the parent CLI manually.
184
+ Changes to these configuration sources restart the development worker automatically:
185
+
186
+ ```text
187
+ .env*
188
+ bcp.config.*
189
+ bcp.environment.*
190
+ ```
191
+
192
+ The parent development supervisor stays running while the worker reloads the new configuration/environment state.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "framework": "bcp",
4
- "versionTarget": "0.2.1",
4
+ "versionTarget": "0.2.2",
5
5
  "releaseState": "unreleased",
6
6
  "sections": [
7
7
  {
@@ -11,6 +11,7 @@
11
11
  "pages": [
12
12
  { "route": "/docs/getting-started", "source": "getting-started.md", "title": "Getting Started" },
13
13
  { "route": "/docs/configuration", "source": "configuration.md", "title": "Configuration" },
14
+ { "route": "/docs/environment-validation", "source": "environment-validation.md", "title": "Environment Validation" },
14
15
  { "route": "/docs/application-modules", "source": "application-modules.md", "title": "Application Modules" },
15
16
  { "route": "/docs/project-metadata", "source": "project-metadata.md", "title": "Project Metadata" },
16
17
  { "route": "/docs/deployment", "source": "deployment.md", "title": "Deployment" },
@@ -103,7 +104,8 @@
103
104
  }
104
105
  ],
105
106
  "releases": [
106
- { "route": "/releases/0.2.1", "source": "releases/0.2.1.md", "version": "0.2.1", "state": "unreleased" },
107
+ { "route": "/releases/0.2.2", "source": "releases/0.2.2.md", "version": "0.2.2", "state": "unreleased" },
108
+ { "route": "/releases/0.2.1", "source": "releases/0.2.1.md", "version": "0.2.1" },
107
109
  { "route": "/releases/0.2.0", "source": "releases/0.2.0.md", "version": "0.2.0" },
108
110
  { "route": "/releases/0.1.29", "source": "releases/0.1.29.md", "version": "0.1.29" },
109
111
  { "route": "/releases/0.1.28", "source": "releases/0.1.28.md", "version": "0.1.28" },