@chidchanun/bcp 0.2.16 → 0.2.18
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 +150 -408
- package/docs/README.md +36 -38
- package/docs/api-manifest.json +27 -19
- package/docs/api-reference.md +257 -305
- package/docs/deployment-platform-v2.md +449 -0
- package/docs/docs-web-manifest.json +7 -3
- package/docs/observability-v3.md +402 -0
- package/docs/platform-manifest.json +30 -4
- package/docs/releases/0.2.17.md +166 -0
- package/docs/releases/0.2.18.md +136 -0
- package/package.json +11 -6
- package/packages/bundler/src/client-boundary.ts +1 -0
- package/packages/client/src/auth.mjs +1391 -0
- package/packages/client/src/config.mjs +1132 -0
- package/packages/client/src/deployment.mjs +609 -0
- package/packages/client/src/deployment.ts +20 -0
- package/packages/client/src/observability.mjs +1251 -0
- package/packages/client/src/observability.ts +37 -0
- package/packages/client/src/server.mjs +5615 -0
- package/packages/server/src/deployment.ts +936 -0
- package/packages/server/src/middleware.mjs +631 -0
- package/packages/server/src/observability-v3.ts +878 -0
package/docs/api-reference.md
CHANGED
|
@@ -1,429 +1,360 @@
|
|
|
1
1
|
# API Reference
|
|
2
2
|
|
|
3
|
-
BCP Framework exposes
|
|
3
|
+
BCP Framework exposes supported package entrypoints through the `bcp` package. Application code should import these public entrypoints instead of private implementation files under `packages/`.
|
|
4
4
|
|
|
5
5
|
The machine-readable source for this page is `docs/api-manifest.json`.
|
|
6
6
|
|
|
7
7
|
## `bcp`
|
|
8
8
|
|
|
9
|
-
Universal React application APIs.
|
|
9
|
+
Universal React application APIs for routing, navigation, layouts, metadata, loaders, route guards, form actions and islands.
|
|
10
10
|
|
|
11
|
-
Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound
|
|
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).
|
|
11
|
+
Common exports include `Form`, `Link`, `createIsland`, `navigate`, `notFound` and loader/action/guard hooks.
|
|
14
12
|
|
|
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
|
-
|
|
21
|
+
Important exports:
|
|
32
22
|
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```ts
|
|
47
|
-
import {
|
|
48
|
-
createCacheMetrics,
|
|
49
|
-
createCacheStore,
|
|
50
|
-
createMemoryCacheAdapter,
|
|
51
|
-
createMemoryCacheLockAdapter,
|
|
52
|
-
createRedisCacheAdapter,
|
|
53
|
-
createRedisCacheLockAdapter,
|
|
54
|
-
type CacheAdapter,
|
|
55
|
-
type CacheAdapterEntry,
|
|
56
|
-
type CacheAdapterSetOptions,
|
|
57
|
-
type CacheGetOrSetOptions,
|
|
58
|
-
type CacheLockAdapter,
|
|
59
|
-
type CacheMetricsRegistryLike,
|
|
60
|
-
type CacheMetricsSink,
|
|
61
|
-
type CacheStore,
|
|
62
|
-
type CacheStoreEvent,
|
|
63
|
-
type CacheStoreOptions,
|
|
64
|
-
type CacheStoreSetOptions,
|
|
65
|
-
type CacheStoreStats,
|
|
66
|
-
type MemoryCacheAdapter,
|
|
67
|
-
type MemoryCacheLockAdapter,
|
|
68
|
-
type RedisCacheAdapter,
|
|
69
|
-
type RedisCacheAdapterOptions,
|
|
70
|
-
type RedisCacheCommandClient,
|
|
71
|
-
type RedisCacheLockAdapter,
|
|
72
|
-
type RedisCacheLockAdapterOptions,
|
|
73
|
-
} from "bcp/cache";
|
|
23
|
+
```text
|
|
24
|
+
cache
|
|
25
|
+
dedupe
|
|
26
|
+
clearCache
|
|
27
|
+
getCacheStats
|
|
28
|
+
revalidateTag
|
|
29
|
+
revalidatePath
|
|
30
|
+
createCacheStore
|
|
31
|
+
createMemoryCacheAdapter
|
|
32
|
+
createMemoryCacheLockAdapter
|
|
33
|
+
createRedisCacheAdapter
|
|
34
|
+
createRedisCacheLockAdapter
|
|
35
|
+
createCacheMetrics
|
|
74
36
|
```
|
|
75
37
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
`getOrSet()` always provides local singleflight deduplication. When a `CacheLockAdapter` is supplied, cache fills can also coordinate across multiple application instances with owner-scoped leases, optional renewal and configurable contention timeout behavior.
|
|
79
|
-
|
|
80
|
-
`createRedisCacheAdapter()` and `createRedisCacheLockAdapter()` use a minimal `sendCommand()` client contract. BCP does not install or own a Redis library/connection. The default namespace is `bcp:{cache}` for Redis Cluster hash-slot locality.
|
|
81
|
-
|
|
82
|
-
Cache Store v2 uses millisecond TTL (`ttlMs`), while the original `cache()` API keeps its existing `revalidate`-seconds contract.
|
|
83
|
-
|
|
84
|
-
`createCacheMetrics()` adapts cache events to the existing BCP `MetricsRegistry` shape without coupling the cache package directly to a specific exporter.
|
|
85
|
-
|
|
86
|
-
Prepared npm packages compile the runtime entrypoint to `packages/client/src/cache.mjs`.
|
|
38
|
+
Public contracts include `CacheAdapter`, `CacheLockAdapter`, `CacheStore`, cache statistics/options and Redis command-client adapter types.
|
|
87
39
|
|
|
88
|
-
Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md)
|
|
40
|
+
Related guides: [Caching](caching.md), [Cache Platform v2](cache-platform-v2.md).
|
|
89
41
|
|
|
90
42
|
## `bcp/config`
|
|
91
43
|
|
|
92
|
-
Typed
|
|
44
|
+
Typed BCP configuration, environment-schema validation and diagnostics APIs.
|
|
93
45
|
|
|
94
|
-
|
|
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).
|
|
95
49
|
|
|
96
50
|
## `bcp/validation`
|
|
97
51
|
|
|
98
52
|
Typed validation primitives, parse helpers and `ValidationError`.
|
|
99
53
|
|
|
100
|
-
Related guide: [Validation](validation.md).
|
|
101
|
-
|
|
102
54
|
## `bcp/error`
|
|
103
55
|
|
|
104
56
|
Structured HTTP error helpers and response classification.
|
|
105
57
|
|
|
106
|
-
Related guide: [Error Handling](error-handling.md).
|
|
107
|
-
|
|
108
58
|
## `bcp/database`
|
|
109
59
|
|
|
110
|
-
Server-only
|
|
60
|
+
Server-only provider-neutral SQL APIs for MySQL, PostgreSQL and SQLite.
|
|
111
61
|
|
|
112
|
-
|
|
62
|
+
Core capabilities include query/execute, transactions, lifecycle and migrations.
|
|
113
63
|
|
|
114
|
-
Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md)
|
|
64
|
+
Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md).
|
|
115
65
|
|
|
116
66
|
## `bcp/auth`
|
|
117
67
|
|
|
118
|
-
Server-only
|
|
68
|
+
Server-only Authentication Platform v2 and Authorization & Security v2 APIs.
|
|
119
69
|
|
|
120
|
-
|
|
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.
|
|
121
71
|
|
|
122
|
-
|
|
72
|
+
Prepared npm packages resolve the runtime to compiled `auth.mjs` in `0.2.18+`.
|
|
123
73
|
|
|
124
74
|
## `bcp/jobs`
|
|
125
75
|
|
|
126
|
-
Server-only
|
|
76
|
+
Server-only background jobs, scheduling and durable job APIs.
|
|
127
77
|
|
|
128
|
-
|
|
78
|
+
Important exports:
|
|
129
79
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
80
|
+
```text
|
|
81
|
+
createJobQueue
|
|
82
|
+
createMemoryJobQueueAdapter
|
|
83
|
+
createRedisJobQueueAdapter
|
|
84
|
+
createJobScheduler
|
|
85
|
+
createMemoryJobScheduleStore
|
|
86
|
+
createRedisJobScheduleStore
|
|
87
|
+
nextCronTime
|
|
88
|
+
nextScheduleTime
|
|
89
|
+
```
|
|
135
90
|
|
|
136
|
-
|
|
91
|
+
Capabilities include delay, retry/backoff, worker concurrency, cancellation, visibility leases, heartbeat renewal, stale recovery, DLQ/requeue, retention cleanup, queue statistics and recurring interval/UTC cron schedules.
|
|
137
92
|
|
|
138
|
-
|
|
93
|
+
Processing remains at-least-once; non-repeatable external side effects should use application-level idempotency.
|
|
139
94
|
|
|
140
95
|
## `bcp/workflow`
|
|
141
96
|
|
|
142
|
-
Server-only Workflow Orchestration APIs
|
|
143
|
-
|
|
144
|
-
```ts
|
|
145
|
-
import {
|
|
146
|
-
createMemoryWorkflowStore,
|
|
147
|
-
createWorkflow,
|
|
148
|
-
} from "bcp/workflow";
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
`createWorkflow()` defines persistent server-side workflows with sequential steps, parallel groups, per-step retry policies, persisted delays and compensation handlers.
|
|
152
|
-
|
|
153
|
-
Workflow controls include:
|
|
97
|
+
Server-only Workflow Orchestration APIs.
|
|
154
98
|
|
|
155
99
|
```text
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
get()
|
|
159
|
-
list()
|
|
160
|
-
resume()
|
|
161
|
-
retry()
|
|
162
|
-
cancel()
|
|
163
|
-
compensate()
|
|
164
|
-
close()
|
|
100
|
+
createWorkflow
|
|
101
|
+
createMemoryWorkflowStore
|
|
165
102
|
```
|
|
166
103
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
`WorkflowStore.claim()` / `release()` form the run-level lease boundary for multi-instance stores.
|
|
104
|
+
Workflow controls include `start`, `run`, `get`, `list`, `resume`, `retry`, `cancel`, `compensate` and `close`.
|
|
170
105
|
|
|
171
|
-
|
|
106
|
+
Capabilities include sequential/parallel steps, per-step retry, persisted delays, compensation, run leases and optional execution through `bcp/jobs`.
|
|
172
107
|
|
|
173
108
|
## `bcp/events`
|
|
174
109
|
|
|
175
|
-
Server-only Transactional Outbox & Events APIs
|
|
110
|
+
Server-only Transactional Outbox & Events APIs.
|
|
176
111
|
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
createTransactionalOutbox,
|
|
185
|
-
} from "bcp/events";
|
|
112
|
+
```text
|
|
113
|
+
createTransactionalOutbox
|
|
114
|
+
createMemoryOutboxStore
|
|
115
|
+
createSqlOutboxStore
|
|
116
|
+
createOutboxMigrationSql
|
|
117
|
+
createOutboxDispatcher
|
|
118
|
+
createEventBus
|
|
186
119
|
```
|
|
187
120
|
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
`createSqlOutboxStore()` supports MySQL, PostgreSQL and SQLite. `createOutboxMigrationSql()` generates the outbox table/index DDL.
|
|
191
|
-
|
|
192
|
-
`createOutboxDispatcher()` supports batched claims, leases, stale recovery, retry/backoff, terminal failure, job-queue handoff, custom publishing, local event-bus delivery and runner lifecycle.
|
|
193
|
-
|
|
194
|
-
Delivery is at-least-once; consumers should use idempotency controls for non-repeatable side effects.
|
|
195
|
-
|
|
196
|
-
Related guides: [Transactional Outbox & Events](transactional-outbox-events.md), [Database](database.md), [Durable Jobs Platform](durable-jobs.md), [Realtime Platform](realtime-platform.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
|
|
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.
|
|
197
122
|
|
|
198
123
|
## `bcp/realtime`
|
|
199
124
|
|
|
200
|
-
Server-only
|
|
125
|
+
Server-only realtime APIs for channels/rooms, broker delivery, presence, channel authorization, socket adapters, heartbeat and Server-Sent Events.
|
|
201
126
|
|
|
202
|
-
```
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
createRealtimeSseResponse,
|
|
208
|
-
type RealtimeAuthenticate,
|
|
209
|
-
type RealtimeAuthorizeChannel,
|
|
210
|
-
type RealtimeBroker,
|
|
211
|
-
type RealtimeBroadcastOptions,
|
|
212
|
-
type RealtimeConnection,
|
|
213
|
-
type RealtimeEnvelope,
|
|
214
|
-
type RealtimeEventContext,
|
|
215
|
-
type RealtimeEventHandler,
|
|
216
|
-
type RealtimeHeartbeatOptions,
|
|
217
|
-
type RealtimeHeartbeatRunner,
|
|
218
|
-
type RealtimeHub,
|
|
219
|
-
type RealtimeJoinOptions,
|
|
220
|
-
type RealtimeOptions,
|
|
221
|
-
type RealtimePresenceMember,
|
|
222
|
-
type RealtimePresenceStore,
|
|
223
|
-
type RealtimeSocket,
|
|
224
|
-
type RealtimeSseOptions,
|
|
225
|
-
} from "bcp/realtime";
|
|
127
|
+
```text
|
|
128
|
+
createRealtime
|
|
129
|
+
createMemoryRealtimeBroker
|
|
130
|
+
createMemoryRealtimePresenceStore
|
|
131
|
+
createRealtimeSseResponse
|
|
226
132
|
```
|
|
227
133
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
`RealtimeBroker` is the cross-hub pub/sub boundary and `RealtimePresenceStore` is the channel-presence boundary. Built-in memory implementations are intended for tests/single-process use; shared deployments can supply provider adapters.
|
|
231
|
-
|
|
232
|
-
`RealtimeOptions.authenticate` can resolve identity from a Request/connection payload, while `authorizeChannel` runs before channel membership is accepted.
|
|
233
|
-
|
|
234
|
-
BCP does not install a WebSocket provider. `RealtimeSocket` defines the minimal transport surface consumed by `hub.attachSocket()`.
|
|
235
|
-
|
|
236
|
-
`hub.sse()` and `createRealtimeSseResponse()` expose Web-standard Server-Sent Events responses with abort, filtering, retry hint and keep-alive options.
|
|
237
|
-
|
|
238
|
-
Realtime delivery is transient. Use database/outbox/jobs/workflows for durable state and refetch durable state/history after reconnect when catch-up is required.
|
|
239
|
-
|
|
240
|
-
Related guides: [Realtime Platform](realtime-platform.md), [Authentication](authentication.md), [Testing Platform](testing-platform.md), [Observability Platform v2](observability.md).
|
|
134
|
+
BCP intentionally does not install a WebSocket server library. Applications adapt the selected provider through `RealtimeSocket`.
|
|
241
135
|
|
|
242
136
|
## `bcp/testing`
|
|
243
137
|
|
|
244
|
-
Server-only
|
|
138
|
+
Server-only framework-native testing utilities. BCP does not require Jest or Vitest.
|
|
245
139
|
|
|
246
|
-
|
|
247
|
-
import {
|
|
248
|
-
createFakeClock,
|
|
249
|
-
createJobTestHarness,
|
|
250
|
-
createOutboxTestHarness,
|
|
251
|
-
createRealtimeTestHarness,
|
|
252
|
-
createRealtimeTestSocket,
|
|
253
|
-
createRouteTestHandler,
|
|
254
|
-
createSequenceIdFactory,
|
|
255
|
-
createTestApp,
|
|
256
|
-
createTestAuthSession,
|
|
257
|
-
createTestFormData,
|
|
258
|
-
createWorkflowTestHarness,
|
|
259
|
-
expectResponse,
|
|
260
|
-
readSseEvents,
|
|
261
|
-
runTestMiddleware,
|
|
262
|
-
runTestPageAction,
|
|
263
|
-
runTestPageGuards,
|
|
264
|
-
runTestPageLoader,
|
|
265
|
-
withTestTransaction,
|
|
266
|
-
type CreateTestAuthSessionOptions,
|
|
267
|
-
type FakeClock,
|
|
268
|
-
type JobTestHarness,
|
|
269
|
-
type OutboxTestHarness,
|
|
270
|
-
type ParsedSseEvent,
|
|
271
|
-
type RealtimeTestConnection,
|
|
272
|
-
type RealtimeTestHarness,
|
|
273
|
-
type RealtimeTestSocket,
|
|
274
|
-
type TestApp,
|
|
275
|
-
type TestAppOptions,
|
|
276
|
-
type TestAuthSession,
|
|
277
|
-
type TestPageActionOptions,
|
|
278
|
-
type TestPageContextOptions,
|
|
279
|
-
type TestPageGuardOptions,
|
|
280
|
-
type TestRequestHandler,
|
|
281
|
-
type TestRequestOptions,
|
|
282
|
-
type TestResponseExpectation,
|
|
283
|
-
type TestRouteFunction,
|
|
284
|
-
type TestRouteHandlerOptions,
|
|
285
|
-
type TestRouteMethod,
|
|
286
|
-
type TestRouteModule,
|
|
287
|
-
type TestTransactionDatabase,
|
|
288
|
-
type WorkflowTestHarness,
|
|
289
|
-
} from "bcp/testing";
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
### Request application harness
|
|
140
|
+
Important APIs include:
|
|
293
141
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
142
|
+
```text
|
|
143
|
+
createTestApp
|
|
144
|
+
createRouteTestHandler
|
|
145
|
+
expectResponse
|
|
146
|
+
createTestAuthSession
|
|
147
|
+
withTestTransaction
|
|
148
|
+
runTestMiddleware
|
|
149
|
+
runTestPageLoader
|
|
150
|
+
runTestPageGuards
|
|
151
|
+
runTestPageAction
|
|
152
|
+
createFakeClock
|
|
153
|
+
createSequenceIdFactory
|
|
154
|
+
createJobTestHarness
|
|
155
|
+
createWorkflowTestHarness
|
|
156
|
+
createOutboxTestHarness
|
|
157
|
+
createRealtimeTestSocket
|
|
158
|
+
createRealtimeTestHarness
|
|
159
|
+
readSseEvents
|
|
160
|
+
```
|
|
297
161
|
|
|
298
|
-
|
|
162
|
+
## `bcp/plugins`
|
|
299
163
|
|
|
300
|
-
|
|
164
|
+
Server-only Plugin & Module Platform APIs.
|
|
301
165
|
|
|
302
|
-
|
|
166
|
+
```text
|
|
167
|
+
definePlugin
|
|
168
|
+
defineModule
|
|
169
|
+
createPluginHost
|
|
170
|
+
createPluginServiceRegistry
|
|
171
|
+
createPluginHookBus
|
|
172
|
+
```
|
|
303
173
|
|
|
304
|
-
|
|
174
|
+
Capabilities include required/optional dependency ordering, setup/start/stop/dispose lifecycle, startup rollback, typed configuration parsing, shared services and awaited in-process hooks.
|
|
305
175
|
|
|
306
|
-
|
|
176
|
+
## `bcp/observability`
|
|
307
177
|
|
|
308
|
-
|
|
178
|
+
Server-only metrics, health and tracing APIs.
|
|
309
179
|
|
|
310
|
-
|
|
180
|
+
Metrics/health APIs:
|
|
311
181
|
|
|
312
|
-
|
|
182
|
+
```text
|
|
183
|
+
createMetricsRegistry
|
|
184
|
+
createMetricsResponse
|
|
185
|
+
createRequestMetricsMiddleware
|
|
186
|
+
createHealthRegistry
|
|
187
|
+
```
|
|
313
188
|
|
|
314
|
-
|
|
189
|
+
Observability Platform v3 tracing APIs:
|
|
315
190
|
|
|
316
191
|
```text
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
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
|
|
322
206
|
```
|
|
323
207
|
|
|
324
|
-
|
|
208
|
+
Important tracing contracts include `Tracer`, `TraceContext`, `TraceCarrier`, `TraceSpan`, `TraceSpanRecord`, `TraceSpanExporter`, `TraceSpanKind` and `TraceSpanStatus`.
|
|
325
209
|
|
|
326
|
-
|
|
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.
|
|
327
211
|
|
|
328
|
-
|
|
212
|
+
Prepared npm packages expose compiled `observability.mjs`.
|
|
329
213
|
|
|
330
|
-
|
|
214
|
+
Related guides: [Observability Platform v2](observability.md), [Observability Platform v3](observability-v3.md).
|
|
331
215
|
|
|
332
|
-
|
|
216
|
+
## `bcp/deployment`
|
|
333
217
|
|
|
334
|
-
|
|
218
|
+
Server-only Deployment Platform v2 lifecycle APIs introduced in `0.2.18`.
|
|
335
219
|
|
|
336
|
-
|
|
220
|
+
Primary functions:
|
|
337
221
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
222
|
+
```ts
|
|
223
|
+
import {
|
|
224
|
+
createDeploymentDiagnosticsResponse,
|
|
225
|
+
createDeploymentReadinessResponse,
|
|
226
|
+
createDeploymentRuntime,
|
|
227
|
+
} from "bcp/deployment";
|
|
228
|
+
```
|
|
341
229
|
|
|
342
|
-
|
|
230
|
+
Important public types:
|
|
343
231
|
|
|
344
|
-
|
|
232
|
+
```text
|
|
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
|
|
247
|
+
```
|
|
345
248
|
|
|
346
|
-
|
|
249
|
+
Create a runtime:
|
|
347
250
|
|
|
348
|
-
|
|
251
|
+
```ts
|
|
252
|
+
const deployment =
|
|
253
|
+
createDeploymentRuntime({
|
|
254
|
+
serviceName: "orders-api",
|
|
255
|
+
version: "1.0.0",
|
|
256
|
+
});
|
|
257
|
+
```
|
|
349
258
|
|
|
350
|
-
|
|
259
|
+
Register resources:
|
|
351
260
|
|
|
352
|
-
|
|
261
|
+
```ts
|
|
262
|
+
deployment.addResource({
|
|
263
|
+
name: "database",
|
|
353
264
|
|
|
354
|
-
|
|
265
|
+
async start() {
|
|
266
|
+
await db.connect();
|
|
267
|
+
},
|
|
355
268
|
|
|
356
|
-
|
|
269
|
+
ready() {
|
|
270
|
+
return true;
|
|
271
|
+
},
|
|
357
272
|
|
|
358
|
-
|
|
273
|
+
async stop() {
|
|
274
|
+
await db.close();
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
```
|
|
359
278
|
|
|
360
|
-
|
|
279
|
+
Resources start in registration order and stop in reverse order. If startup fails, previously started resources are rolled back in reverse order.
|
|
361
280
|
|
|
362
|
-
|
|
281
|
+
Runtime states:
|
|
363
282
|
|
|
364
|
-
|
|
283
|
+
```text
|
|
284
|
+
idle
|
|
285
|
+
starting
|
|
286
|
+
ready
|
|
287
|
+
draining
|
|
288
|
+
stopped
|
|
289
|
+
failed
|
|
290
|
+
```
|
|
365
291
|
|
|
366
|
-
|
|
292
|
+
Readiness:
|
|
367
293
|
|
|
368
|
-
|
|
294
|
+
```ts
|
|
295
|
+
const report =
|
|
296
|
+
await deployment.readiness();
|
|
297
|
+
```
|
|
369
298
|
|
|
370
|
-
|
|
299
|
+
or:
|
|
371
300
|
|
|
372
301
|
```ts
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
createPluginServiceRegistry,
|
|
377
|
-
defineModule,
|
|
378
|
-
definePlugin,
|
|
379
|
-
PluginDependencyError,
|
|
380
|
-
PluginLifecycleError,
|
|
381
|
-
type PluginConfigParser,
|
|
382
|
-
type PluginConfigSchema,
|
|
383
|
-
type PluginContext,
|
|
384
|
-
type PluginDefinition,
|
|
385
|
-
type PluginHookBus,
|
|
386
|
-
type PluginHookHandler,
|
|
387
|
-
type PluginHost,
|
|
388
|
-
type PluginHostOptions,
|
|
389
|
-
type PluginHostView,
|
|
390
|
-
type PluginModule,
|
|
391
|
-
type PluginRecord,
|
|
392
|
-
type PluginServiceKey,
|
|
393
|
-
type PluginServiceRegistry,
|
|
394
|
-
type PluginState,
|
|
395
|
-
} from "bcp/plugins";
|
|
302
|
+
return createDeploymentReadinessResponse(
|
|
303
|
+
deployment
|
|
304
|
+
);
|
|
396
305
|
```
|
|
397
306
|
|
|
398
|
-
|
|
307
|
+
The response is `200` when the runtime and all resource checks are ready, otherwise `503`.
|
|
399
308
|
|
|
400
|
-
|
|
309
|
+
Diagnostics:
|
|
401
310
|
|
|
402
|
-
|
|
311
|
+
```ts
|
|
312
|
+
const report =
|
|
313
|
+
await deployment.diagnostics();
|
|
314
|
+
```
|
|
403
315
|
|
|
404
|
-
|
|
316
|
+
or:
|
|
405
317
|
|
|
406
|
-
|
|
318
|
+
```ts
|
|
319
|
+
return createDeploymentDiagnosticsResponse(
|
|
320
|
+
deployment
|
|
321
|
+
);
|
|
322
|
+
```
|
|
407
323
|
|
|
408
|
-
|
|
324
|
+
Metadata includes service/deployment identity, process ID, Node version, platform, architecture and startup time. Optional environment-backed identity fields use:
|
|
409
325
|
|
|
410
|
-
|
|
326
|
+
```text
|
|
327
|
+
BCP_DEPLOYMENT_ID
|
|
328
|
+
BCP_INSTANCE_ID
|
|
329
|
+
BCP_RELEASE
|
|
330
|
+
NODE_ENV
|
|
331
|
+
```
|
|
411
332
|
|
|
412
|
-
|
|
333
|
+
Install process signal handlers:
|
|
413
334
|
|
|
414
|
-
|
|
335
|
+
```ts
|
|
336
|
+
const remove =
|
|
337
|
+
deployment.installSignalHandlers();
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Defaults are `SIGTERM` and `SIGINT`.
|
|
341
|
+
|
|
342
|
+
Integrate with the framework shutdown-hook registry:
|
|
415
343
|
|
|
416
|
-
|
|
344
|
+
```ts
|
|
345
|
+
const unregister =
|
|
346
|
+
deployment.registerShutdownHook();
|
|
347
|
+
```
|
|
417
348
|
|
|
418
|
-
|
|
349
|
+
Prepared npm packages expose compiled `deployment.mjs`.
|
|
419
350
|
|
|
420
|
-
Related guides: [
|
|
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).
|
|
421
352
|
|
|
422
353
|
## `bcp/server`
|
|
423
354
|
|
|
424
|
-
Server request/runtime APIs including request context, cookies, CSRF
|
|
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.
|
|
425
356
|
|
|
426
|
-
|
|
357
|
+
Prepared npm packages resolve this runtime to compiled `server.mjs` in `0.2.18+`.
|
|
427
358
|
|
|
428
359
|
## `bcp/server-only`
|
|
429
360
|
|
|
@@ -433,16 +364,37 @@ Server-only module boundary marker.
|
|
|
433
364
|
import "bcp/server-only";
|
|
434
365
|
```
|
|
435
366
|
|
|
436
|
-
Related guide: [Application Modules](application-modules.md).
|
|
437
|
-
|
|
438
367
|
## `bcp/middleware`
|
|
439
368
|
|
|
440
|
-
Middleware System v2
|
|
369
|
+
Middleware System v2 request/response pipeline types and helpers.
|
|
370
|
+
|
|
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
|
+
```
|
|
441
393
|
|
|
442
|
-
|
|
394
|
+
Types remain sourced from the TypeScript public entrypoint files.
|
|
443
395
|
|
|
444
396
|
## Stability
|
|
445
397
|
|
|
446
|
-
Only
|
|
398
|
+
Only entrypoints listed in both `docs/platform-manifest.json` and `docs/api-manifest.json` are part of the documented platform surface.
|
|
447
399
|
|
|
448
|
-
Files under internal `packages/*` paths are
|
|
400
|
+
Files under internal `packages/*` paths are implementation details unless re-exported through a documented public package entrypoint.
|