@chidchanun/bcp 0.2.11 → 0.2.13

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,14 +2,12 @@
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.11Workflow Orchestration`
5
+ > **Documentation target:** BCP Framework `0.2.13Realtime Platform`
6
6
  >
7
7
  > **Release state:** unreleased development target until RC validation, tagging and npm publication complete.
8
8
 
9
9
  ## Documentation architecture
10
10
 
11
- BCP uses three machine-readable documentation contracts:
12
-
13
11
  ```text
14
12
  docs/docs-web-manifest.json
15
13
  -> website navigation, routes, Markdown sources and release routes
@@ -39,53 +37,58 @@ Framework source and tests remain authoritative for runtime behavior.
39
37
  | `0.2.9` | Job Scheduling Platform |
40
38
  | `0.2.10` | Durable Jobs Platform |
41
39
  | `0.2.11` | Workflow Orchestration |
40
+ | `0.2.12` | Transactional Outbox & Events |
41
+ | `0.2.13` | Realtime Platform |
42
42
 
43
- ## 0.2.11Workflow Orchestration
44
-
45
- `0.2.11` adds a new server-only `bcp/workflow` public entrypoint for persistent multi-step backend orchestration.
43
+ ## 0.2.13Realtime Platform
46
44
 
47
- New/updated documentation sources:
48
-
49
- | Source | Purpose |
50
- | --- | --- |
51
- | `workflow-orchestration.md` | Workflow definition, persistence, delays, retries, queue execution and compensation |
52
- | `durable-jobs.md` | Durable execution layer used by queue-backed workflows |
53
- | `api-reference.md` | Public `bcp/workflow` APIs |
54
- | `platform-manifest.json` | Workflow capability flags and public entrypoint |
55
- | `api-manifest.json` | `bcp/workflow` source/guide ownership |
56
- | `docs-web-manifest.json` | Workflow docs navigation and `0.2.11` release route |
57
- | `releases/0.2.11.md` | Workflow Orchestration release notes |
45
+ `0.2.13` adds the server-only `bcp/realtime` public entrypoint.
58
46
 
59
47
  Primary APIs:
60
48
 
61
49
  ```ts
62
50
  import {
63
- createMemoryWorkflowStore,
64
- createWorkflow,
65
- } from "bcp/workflow";
51
+ createMemoryRealtimeBroker,
52
+ createMemoryRealtimePresenceStore,
53
+ createRealtime,
54
+ createRealtimeSseResponse,
55
+ } from "bcp/realtime";
66
56
  ```
67
57
 
68
58
  Runtime model:
69
59
 
70
60
  ```text
71
- application / API
72
- |
73
- v
74
- WorkflowStore
75
- |
76
- v
77
- BCP Workflow
78
- |
79
- +--> sequential steps
80
- +--> parallel groups
81
- +--> retry / delay
82
- +--> compensation
83
- |
84
- v
85
- optional durable bcp/jobs queue
61
+ client connection
62
+ |
63
+ v
64
+ RealtimeHub
65
+ |
66
+ +-- channels / rooms
67
+ +-- auth / channel authorization
68
+ +-- presence
69
+ +-- heartbeat
70
+ |
71
+ +-- RealtimeBroker
72
+ | -> cross-hub delivery
73
+ |
74
+ +-- RealtimeSocket
75
+ | -> WebSocket provider adapter
76
+ |
77
+ +-- SSE Response
86
78
  ```
87
79
 
88
- The memory workflow store is local-only. Multi-instance deployments should implement a shared durable `WorkflowStore` whose `claim()` method atomically leases one run to one executor.
80
+ The memory broker/presence store are process-local. Multi-instance deployments should provide shared implementations.
81
+
82
+ New/updated sources:
83
+
84
+ | Source | Purpose |
85
+ | --- | --- |
86
+ | `realtime-platform.md` | Channels, presence, WebSocket adapter, SSE, heartbeat and broker model |
87
+ | `api-reference.md` | `bcp/realtime` public APIs |
88
+ | `platform-manifest.json` | Realtime capability flags and public entrypoint |
89
+ | `api-manifest.json` | `bcp/realtime` source/guide ownership |
90
+ | `docs-web-manifest.json` | Realtime docs navigation and `0.2.13` release route |
91
+ | `releases/0.2.13.md` | Realtime Platform release notes |
89
92
 
90
93
  ## Update rule
91
94
 
@@ -94,36 +97,30 @@ When framework behavior or public surface changes:
94
97
  1. Update framework source.
95
98
  2. Add/update regression tests.
96
99
  3. Update the matching Markdown guide.
97
- 4. Update `platform-manifest.json` when runtime/public-entrypoint/capability metadata changes.
98
- 5. Update `api-manifest.json` when public API ownership/guide mapping changes.
99
- 6. Update `docs-web-manifest.json` when website routes/navigation change.
100
+ 4. Update `platform-manifest.json` for runtime/public-entrypoint/capability changes.
101
+ 5. Update `api-manifest.json` for public API ownership/guide changes.
102
+ 6. Update `docs-web-manifest.json` for website route/navigation changes.
100
103
  7. Update `docs/releases/<version>.md`.
101
104
  8. Change release state only after the release workflow reaches that state.
102
105
 
103
- ## Docs-web navigation
104
-
105
- Important current routes:
106
+ ## Important docs-web routes
106
107
 
107
108
  | Website route | Markdown source |
108
109
  | --- | --- |
109
110
  | `/docs/authentication` | `authentication.md` |
110
- | `/docs/authorization-security` | `authorization-security.md` |
111
111
  | `/docs/observability` | `observability.md` |
112
112
  | `/docs/background-jobs` | `background-jobs.md` |
113
- | `/docs/job-scheduling` | `job-scheduling.md` |
114
113
  | `/docs/durable-jobs` | `durable-jobs.md` |
115
114
  | `/docs/workflow-orchestration` | `workflow-orchestration.md` |
116
- | `/docs/application-packaging` | `application-packaging.md` |
117
- | `/docs/database` | `database.md` |
115
+ | `/docs/transactional-outbox-events` | `transactional-outbox-events.md` |
116
+ | `/docs/realtime-platform` | `realtime-platform.md` |
118
117
  | `/docs/api-reference` | `api-reference.md` |
119
- | `/releases/0.2.11` | `releases/0.2.11.md` |
118
+ | `/releases/0.2.13` | `releases/0.2.13.md` |
120
119
 
121
120
  Every route/source pair is validated by unit tests.
122
121
 
123
122
  ## Public entrypoints
124
123
 
125
- Current documented entrypoints:
126
-
127
124
  ```text
128
125
  bcp
129
126
  bcp/island
@@ -135,6 +132,8 @@ bcp/database
135
132
  bcp/auth
136
133
  bcp/jobs
137
134
  bcp/workflow
135
+ bcp/events
136
+ bcp/realtime
138
137
  bcp/observability
139
138
  bcp/server
140
139
  bcp/server-only
@@ -145,33 +144,17 @@ The API-manifest entrypoint set must match the platform public-entrypoint set ex
145
144
 
146
145
  ## Release validation
147
146
 
148
- Before publishing `0.2.11`:
147
+ Before publishing `0.2.13`:
149
148
 
150
149
  ```bash
151
150
  npm run typecheck
152
151
  npm run test:unit
153
152
  npm run test:integration
154
- npm run test:package
155
153
  npm run test:e2e
154
+ npm run test:package
156
155
  npm run rc:check
157
156
  ```
158
157
 
159
- Workflow Orchestration validation covers:
160
-
161
- - sequential step execution,
162
- - step retries,
163
- - parallel child execution/state,
164
- - persisted delay/resume behavior,
165
- - manual retry,
166
- - reverse-order compensation,
167
- - queue-backed execution and delayed continuation,
168
- - workflow store run leases,
169
- - server-only client boundary enforcement,
170
- - compiled `workflow.mjs` package execution,
171
- - docs/platform/API version parity.
158
+ Realtime validation covers broker broadcasts, presence, authentication/channel authorization, socket protocol, heartbeat cleanup, SSE streaming, server-only boundaries, compiled `realtime.mjs` package execution and docs/platform/API parity.
172
159
 
173
160
  The final release tag must point to the exact commit that passed the complete RC sequence.
174
-
175
- ## Repository authority
176
-
177
- The framework repository remains authoritative for source, public exports, tests, Markdown docs, manifests and release notes. `bcp-docs-web` remains the presentation/search/navigation layer.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "framework": "bcp",
4
- "version": "0.2.11",
4
+ "version": "0.2.13",
5
5
  "releaseState": "unreleased",
6
6
  "coverage": "public-entrypoints",
7
7
  "entrypoints": [
@@ -11,12 +11,7 @@
11
11
  "environment": "universal",
12
12
  "route": "/docs/api-reference#bcp",
13
13
  "summary": "React application APIs for routing, links, forms, loader/guard data, islands, metadata and route error handling.",
14
- "guides": [
15
- "/docs/routing",
16
- "/docs/server-data-loaders",
17
- "/docs/route-guards",
18
- "/docs/form-actions"
19
- ]
14
+ "guides": ["/docs/routing", "/docs/server-data-loaders", "/docs/route-guards", "/docs/form-actions"]
20
15
  },
21
16
  {
22
17
  "package": "bcp/island",
@@ -24,9 +19,7 @@
24
19
  "environment": "universal",
25
20
  "route": "/docs/api-reference#bcp-island",
26
21
  "summary": "Partial-hydration island creation and island loading strategy types.",
27
- "guides": [
28
- "/docs/hydration"
29
- ]
22
+ "guides": ["/docs/hydration"]
30
23
  },
31
24
  {
32
25
  "package": "bcp/cache",
@@ -34,9 +27,7 @@
34
27
  "environment": "server-preferred",
35
28
  "route": "/docs/api-reference#bcp-cache",
36
29
  "summary": "Cache, deduplication, statistics and path/tag revalidation primitives.",
37
- "guides": [
38
- "/docs/caching"
39
- ]
30
+ "guides": ["/docs/caching"]
40
31
  },
41
32
  {
42
33
  "package": "bcp/config",
@@ -44,10 +35,7 @@
44
35
  "environment": "server",
45
36
  "route": "/docs/api-reference#bcp-config",
46
37
  "summary": "Typed BCP configuration, environment-schema validation and configuration diagnostics APIs.",
47
- "guides": [
48
- "/docs/configuration",
49
- "/docs/environment-validation"
50
- ]
38
+ "guides": ["/docs/configuration", "/docs/environment-validation"]
51
39
  },
52
40
  {
53
41
  "package": "bcp/validation",
@@ -55,9 +43,7 @@
55
43
  "environment": "universal",
56
44
  "route": "/docs/api-reference#bcp-validation",
57
45
  "summary": "Typed validators, parse helpers and structured validation errors.",
58
- "guides": [
59
- "/docs/validation"
60
- ]
46
+ "guides": ["/docs/validation"]
61
47
  },
62
48
  {
63
49
  "package": "bcp/error",
@@ -65,9 +51,7 @@
65
51
  "environment": "universal",
66
52
  "route": "/docs/api-reference#bcp-error",
67
53
  "summary": "Structured HTTP error creation, classification and response helpers.",
68
- "guides": [
69
- "/docs/error-handling"
70
- ]
54
+ "guides": ["/docs/error-handling"]
71
55
  },
72
56
  {
73
57
  "package": "bcp/database",
@@ -75,10 +59,7 @@
75
59
  "environment": "server",
76
60
  "route": "/docs/api-reference#bcp-database",
77
61
  "summary": "Provider-neutral MySQL, PostgreSQL and SQLite query, transaction, lifecycle and migration primitives.",
78
- "guides": [
79
- "/docs/database",
80
- "/docs/database-migrations"
81
- ]
62
+ "guides": ["/docs/database", "/docs/database-migrations", "/docs/transactional-outbox-events"]
82
63
  },
83
64
  {
84
65
  "package": "bcp/auth",
@@ -86,13 +67,7 @@
86
67
  "environment": "server",
87
68
  "route": "/docs/api-reference#bcp-auth",
88
69
  "summary": "Authentication Platform v2 plus permission checks, authorization policies and auth/guest/role/permission route guards.",
89
- "guides": [
90
- "/docs/authentication",
91
- "/docs/auth-session-store",
92
- "/docs/auth-route-guards",
93
- "/docs/authorization-security",
94
- "/docs/session-auth"
95
- ]
70
+ "guides": ["/docs/authentication", "/docs/auth-session-store", "/docs/auth-route-guards", "/docs/authorization-security", "/docs/session-auth"]
96
71
  },
97
72
  {
98
73
  "package": "bcp/jobs",
@@ -100,12 +75,7 @@
100
75
  "environment": "server",
101
76
  "route": "/docs/api-reference#bcp-jobs",
102
77
  "summary": "Background queues and schedules with visibility leases, heartbeats, stale recovery, DLQ maintenance and Redis-compatible durable adapters.",
103
- "guides": [
104
- "/docs/background-jobs",
105
- "/docs/job-scheduling",
106
- "/docs/durable-jobs",
107
- "/docs/observability"
108
- ]
78
+ "guides": ["/docs/background-jobs", "/docs/job-scheduling", "/docs/durable-jobs", "/docs/transactional-outbox-events", "/docs/realtime-platform", "/docs/observability"]
109
79
  },
110
80
  {
111
81
  "package": "bcp/workflow",
@@ -113,11 +83,23 @@
113
83
  "environment": "server",
114
84
  "route": "/docs/api-reference#bcp-workflow",
115
85
  "summary": "Persistent workflow orchestration with sequential and parallel steps, retries, delays, compensation, run leases and optional durable queue execution.",
116
- "guides": [
117
- "/docs/workflow-orchestration",
118
- "/docs/durable-jobs",
119
- "/docs/observability"
120
- ]
86
+ "guides": ["/docs/workflow-orchestration", "/docs/durable-jobs", "/docs/realtime-platform", "/docs/observability"]
87
+ },
88
+ {
89
+ "package": "bcp/events",
90
+ "source": "packages/client/src/events.ts",
91
+ "environment": "server",
92
+ "route": "/docs/api-reference#bcp-events",
93
+ "summary": "Transactional outbox and event delivery APIs with SQL persistence, dispatcher leases, retries, stale recovery, queue handoff and in-process event bus delivery.",
94
+ "guides": ["/docs/transactional-outbox-events", "/docs/database", "/docs/durable-jobs", "/docs/realtime-platform", "/docs/observability"]
95
+ },
96
+ {
97
+ "package": "bcp/realtime",
98
+ "source": "packages/client/src/realtime.ts",
99
+ "environment": "server",
100
+ "route": "/docs/api-reference#bcp-realtime",
101
+ "summary": "Realtime channels, cross-hub broker delivery, presence, channel authorization, WebSocket adapter integration, heartbeat handling and built-in Server-Sent Events responses.",
102
+ "guides": ["/docs/realtime-platform", "/docs/authentication", "/docs/observability"]
121
103
  },
122
104
  {
123
105
  "package": "bcp/observability",
@@ -125,10 +107,7 @@
125
107
  "environment": "server",
126
108
  "route": "/docs/api-reference#bcp-observability",
127
109
  "summary": "In-process metrics, Prometheus exposition, request metrics middleware and health/readiness checks.",
128
- "guides": [
129
- "/docs/observability",
130
- "/docs/development-logging"
131
- ]
110
+ "guides": ["/docs/observability", "/docs/development-logging"]
132
111
  },
133
112
  {
134
113
  "package": "bcp/server",
@@ -136,14 +115,7 @@
136
115
  "environment": "server",
137
116
  "route": "/docs/api-reference#bcp-server",
138
117
  "summary": "Request context, cookies, CSRF/same-origin protection, logging, production hardening, upload, storage, response and session APIs.",
139
- "guides": [
140
- "/docs/server-request-apis",
141
- "/docs/authorization-security",
142
- "/docs/file-upload",
143
- "/docs/storage",
144
- "/docs/storage-ecosystem",
145
- "/docs/production-hardening"
146
- ]
118
+ "guides": ["/docs/server-request-apis", "/docs/authorization-security", "/docs/file-upload", "/docs/storage", "/docs/storage-ecosystem", "/docs/production-hardening"]
147
119
  },
148
120
  {
149
121
  "package": "bcp/server-only",
@@ -151,9 +123,7 @@
151
123
  "environment": "server-marker",
152
124
  "route": "/docs/api-reference#bcp-server-only",
153
125
  "summary": "Server-only module boundary marker that prevents accidental browser inclusion.",
154
- "guides": [
155
- "/docs/application-modules"
156
- ]
126
+ "guides": ["/docs/application-modules"]
157
127
  },
158
128
  {
159
129
  "package": "bcp/middleware",
@@ -161,9 +131,7 @@
161
131
  "environment": "server",
162
132
  "route": "/docs/api-reference#bcp-middleware",
163
133
  "summary": "Middleware System v2 request/response pipeline types and helpers.",
164
- "guides": [
165
- "/docs/middleware"
166
- ]
134
+ "guides": ["/docs/middleware"]
167
135
  }
168
136
  ]
169
137
  }
@@ -54,7 +54,7 @@ Server-only Database Platform v2 APIs.
54
54
 
55
55
  Built-in SQL providers are MySQL, PostgreSQL and SQLite. `BcpDatabase` instances expose lazy query/execute/transaction operations plus explicit `connect()`, `disconnect()` and backward-compatible `close()` lifecycle methods.
56
56
 
57
- Related guides: [Database](database.md), [Database Migrations](database-migrations.md).
57
+ Related guides: [Database](database.md), [Database Migrations](database-migrations.md), [Transactional Outbox & Events](transactional-outbox-events.md).
58
58
 
59
59
  ## `bcp/auth`
60
60
 
@@ -68,104 +68,17 @@ Related guides: [Authentication](authentication.md), [Auth Session Stores](auth-
68
68
 
69
69
  Server-only Background Jobs, Job Scheduling and Durable Jobs APIs.
70
70
 
71
- Core queue APIs:
71
+ Core queue APIs include `createJobQueue()`, `createMemoryJobQueueAdapter()`, queue/worker records, retry/backoff, visibility leases, heartbeat renewal, stale recovery, DLQ operations, retention cleanup and queue statistics.
72
72
 
73
- ```ts
74
- import {
75
- createJobQueue,
76
- createMemoryJobQueueAdapter,
77
- type BackgroundJobQueue,
78
- type CleanupJobsOptions,
79
- type DeadLetterJobRecord,
80
- type EnqueueJobOptions,
81
- type HeartbeatJobOptions,
82
- type JobHandler,
83
- type JobHandlerContext,
84
- type JobQueueAdapter,
85
- type JobQueueOptions,
86
- type JobQueueStats,
87
- type JobRecord,
88
- type JobRetryDelay,
89
- type JobState,
90
- type JobWorker,
91
- type MemoryJobQueueAdapter,
92
- type ProcessNextJobOptions,
93
- type RecoverStaleJobsOptions,
94
- type RequeueDeadLetterOptions,
95
- type ReserveJobOptions,
96
- type StartJobWorkerOptions,
97
- } from "bcp/jobs";
98
- ```
99
-
100
- Scheduling APIs:
101
-
102
- ```ts
103
- import {
104
- createJobScheduler,
105
- createMemoryJobScheduleStore,
106
- nextCronTime,
107
- nextScheduleTime,
108
- type JobSchedule,
109
- type JobScheduleRecord,
110
- type JobScheduleStore,
111
- type JobScheduler,
112
- type JobSchedulerOptions,
113
- type JobSchedulerRunner,
114
- type MemoryJobScheduleStore,
115
- type RunDueSchedulesOptions,
116
- type ScheduleJobOptions,
117
- type StartJobSchedulerOptions,
118
- } from "bcp/jobs";
119
- ```
120
-
121
- Durable Redis-compatible APIs added in `0.2.10`:
122
-
123
- ```ts
124
- import {
125
- createRedisJobQueueAdapter,
126
- createRedisJobScheduleStore,
127
- type RedisCommandClient,
128
- type RedisJobQueueAdapter,
129
- type RedisJobsAdapterOptions,
130
- type RedisJobScheduleStore,
131
- } from "bcp/jobs";
132
- ```
133
-
134
- ### Queue lifecycle
135
-
136
- `createJobQueue()` supports immediate/delayed enqueue, retry/backoff, cancellation, manual `processNext()`, worker concurrency, visibility timeout, heartbeat lease renewal, stale-running recovery, DLQ inspection/requeue, terminal retention cleanup and queue statistics.
137
-
138
- Durable adapter methods such as `heartbeat()`, `recoverStale()`, `listDeadLetters()`, `requeueDeadLetter()`, `cleanup()` and `stats()` are optional so earlier `JobQueueAdapter` implementations remain compatible.
73
+ Scheduling APIs include `createJobScheduler()`, `createMemoryJobScheduleStore()`, `nextCronTime()` and `nextScheduleTime()`.
139
74
 
140
- `reserve()` receives an optional second `ReserveJobOptions` argument containing `ownerId` and `visibilityTimeoutMs`. Production durable adapters should use it to create an atomic visibility lease.
141
-
142
- ### Scheduling
143
-
144
- `createJobScheduler()` supports recurring interval and UTC five-field cron schedules.
145
-
146
- The scheduler leases due records from `JobScheduleStore`, then enqueues normal jobs using deterministic occurrence IDs. `nextCronTime()` and `nextScheduleTime()` are available for tooling and tests.
147
-
148
- ### Redis-compatible durable adapters
149
-
150
- `createRedisJobQueueAdapter()` implements the queue contract on a shared Redis-compatible command client.
151
-
152
- `createRedisJobScheduleStore()` implements the schedule-store contract using the same minimal client shape:
153
-
154
- ```ts
155
- interface RedisCommandClient {
156
- sendCommand(
157
- command: string[]
158
- ): Promise<unknown>;
159
- }
160
- ```
75
+ Durable Redis-compatible APIs added in `0.2.10` include `createRedisJobQueueAdapter()` and `createRedisJobScheduleStore()`.
161
76
 
162
77
  BCP does not install a Redis library and does not create the connection. Applications own authentication, TLS, Cluster/Sentinel configuration and connection shutdown.
163
78
 
164
- The reference adapters use atomic Lua state transitions. The default namespace `bcp:{jobs}` uses a Redis Cluster hash tag so all job/schedule keys share one slot.
165
-
166
79
  The processing model is at-least-once. Handlers that perform non-idempotent external side effects should use application-level idempotency protection.
167
80
 
168
- Related guides: [Background Jobs Platform](background-jobs.md), [Job Scheduling Platform](job-scheduling.md), [Durable Jobs Platform](durable-jobs.md), [Observability Platform v2](observability.md).
81
+ Related guides: [Background Jobs Platform](background-jobs.md), [Job Scheduling Platform](job-scheduling.md), [Durable Jobs Platform](durable-jobs.md), [Transactional Outbox & Events](transactional-outbox-events.md), [Realtime Platform](realtime-platform.md), [Observability Platform v2](observability.md).
169
82
 
170
83
  ## `bcp/workflow`
171
84
 
@@ -175,29 +88,10 @@ Server-only Workflow Orchestration APIs added in `0.2.11`.
175
88
  import {
176
89
  createMemoryWorkflowStore,
177
90
  createWorkflow,
178
- type CancelWorkflowOptions,
179
- type MemoryWorkflowStore,
180
- type ResumeWorkflowOptions,
181
- type StartWorkflowOptions,
182
- type Workflow,
183
- type WorkflowBuilder,
184
- type WorkflowCompensationHandler,
185
- type WorkflowOptions,
186
- type WorkflowParallelBuilder,
187
- type WorkflowRetryDelay,
188
- type WorkflowRunRecord,
189
- type WorkflowRunState,
190
- type WorkflowStepContext,
191
- type WorkflowStepHandler,
192
- type WorkflowStepKind,
193
- type WorkflowStepOptions,
194
- type WorkflowStepRecord,
195
- type WorkflowStepState,
196
- type WorkflowStore,
197
91
  } from "bcp/workflow";
198
92
  ```
199
93
 
200
- `createWorkflow()` defines a persistent server-side workflow with sequential steps, parallel groups, per-step retry policies, persisted delays and compensation handlers.
94
+ `createWorkflow()` defines persistent server-side workflows with sequential steps, parallel groups, per-step retry policies, persisted delays and compensation handlers.
201
95
 
202
96
  Workflow controls include:
203
97
 
@@ -213,17 +107,108 @@ compensate()
213
107
  close()
214
108
  ```
215
109
 
216
- Without a queue, workflow execution runs in the current process until it succeeds, fails, is cancelled or reaches a persisted delay.
110
+ When an existing `BackgroundJobQueue` is supplied, workflow execution and delay continuation can run through `bcp/jobs`.
111
+
112
+ `WorkflowStore.claim()` / `release()` form the run-level lease boundary for multi-instance stores.
113
+
114
+ Related guides: [Workflow Orchestration](workflow-orchestration.md), [Durable Jobs Platform](durable-jobs.md), [Realtime Platform](realtime-platform.md), [Observability Platform v2](observability.md).
115
+
116
+ ## `bcp/events`
117
+
118
+ Server-only Transactional Outbox & Events APIs added in `0.2.12`.
119
+
120
+ ```ts
121
+ import {
122
+ createEventBus,
123
+ createMemoryOutboxStore,
124
+ createOutboxDispatcher,
125
+ createOutboxMigrationSql,
126
+ createSqlOutboxStore,
127
+ createTransactionalOutbox,
128
+ } from "bcp/events";
129
+ ```
130
+
131
+ `createTransactionalOutbox()` writes an event through the same `TransactionDatabase` used by `db.transaction()`, allowing business rows and outbox rows to commit or roll back together.
132
+
133
+ `createSqlOutboxStore()` supports MySQL, PostgreSQL and SQLite. `createOutboxMigrationSql()` generates the outbox table/index DDL.
134
+
135
+ `createOutboxDispatcher()` supports batched claims, leases, stale recovery, retry/backoff, terminal failure, job-queue handoff, custom publishing, local event-bus delivery and runner lifecycle.
136
+
137
+ Delivery is at-least-once; consumers should use idempotency controls for non-repeatable side effects.
138
+
139
+ Related guides: [Transactional Outbox & Events](transactional-outbox-events.md), [Database](database.md), [Durable Jobs Platform](durable-jobs.md), [Realtime Platform](realtime-platform.md), [Observability Platform v2](observability.md).
140
+
141
+ ## `bcp/realtime`
142
+
143
+ Server-only Realtime Platform APIs added in `0.2.13`.
144
+
145
+ ```ts
146
+ import {
147
+ createMemoryRealtimeBroker,
148
+ createMemoryRealtimePresenceStore,
149
+ createRealtime,
150
+ createRealtimeSseResponse,
151
+ type RealtimeAuthenticate,
152
+ type RealtimeAuthorizeChannel,
153
+ type RealtimeBroker,
154
+ type RealtimeBroadcastOptions,
155
+ type RealtimeConnection,
156
+ type RealtimeEnvelope,
157
+ type RealtimeEventContext,
158
+ type RealtimeEventHandler,
159
+ type RealtimeHeartbeatOptions,
160
+ type RealtimeHeartbeatRunner,
161
+ type RealtimeHub,
162
+ type RealtimeJoinOptions,
163
+ type RealtimeOptions,
164
+ type RealtimePresenceMember,
165
+ type RealtimePresenceStore,
166
+ type RealtimeSocket,
167
+ type RealtimeSseOptions,
168
+ } from "bcp/realtime";
169
+ ```
170
+
171
+ ### Hub and channels
172
+
173
+ `createRealtime()` creates a server-side hub. Connections can `join()`, `leave()`, `emit()`, `send()`, `touch()` and `disconnect()`.
174
+
175
+ `hub.broadcast(channel, event, payload)` delivers through the configured broker and reaches connections that joined the channel.
176
+
177
+ ### Broker
178
+
179
+ `RealtimeBroker` is the cross-hub pub/sub boundary. The memory implementation is process-local; production multi-instance applications can provide a shared broker such as Redis Pub/Sub or NATS without changing the hub surface.
180
+
181
+ ### Presence
182
+
183
+ `RealtimePresenceStore` tracks per-channel connection presence. `hub.members(channel)` returns current presence records.
184
+
185
+ The memory store is intended for tests/single-process use. Shared deployments should use a shared presence adapter.
186
+
187
+ ### Authentication and channel authorization
188
+
189
+ `RealtimeOptions.authenticate` can resolve application user identity from a `Request`/connection data. `getUserId` maps that identity into presence records.
190
+
191
+ `RealtimeOptions.authorizeChannel` runs before `join()` completes and can enforce private-room access.
192
+
193
+ ### Socket adapter
194
+
195
+ BCP does not install a WebSocket provider. `RealtimeSocket` defines the minimal `send`, `close`, `onMessage`, `onClose` and optional `onError` surface consumed by `hub.attachSocket()`.
196
+
197
+ The built-in JSON protocol accepts `join`, `leave`, `event` and `ping` messages. `ping` receives a `realtime.pong` event.
198
+
199
+ ### Server-Sent Events
200
+
201
+ `hub.sse(channel, options)` and `createRealtimeSseResponse()` return Web-standard streaming `Response` objects using `text/event-stream`.
217
202
 
218
- When an existing `BackgroundJobQueue` is passed through `WorkflowOptions.queue`, workflow execution is submitted through `bcp/jobs`. Delay steps enqueue delayed continuation jobs instead of holding a long-running timer.
203
+ Options include abort signal integration, event filtering, retry hints, keep-alive timing and response headers.
219
204
 
220
- `WorkflowStore` is the workflow persistence boundary. Its `claim()` / `release()` methods form the run-level lease contract for shared multi-instance stores.
205
+ ### Heartbeat
221
206
 
222
- `createMemoryWorkflowStore()` is intended for development and deterministic tests. Production multi-instance applications should implement a shared durable store with atomic `claim()` behavior.
207
+ `hub.startHeartbeat()` sends `realtime.ping` messages and invokes stale connection cleanup. `hub.sweepStale()` is also public for deterministic infrastructure loops/tests.
223
208
 
224
- Compensation is saga-style and executes successful compensatable steps in reverse completion order. It does not turn external services into one distributed database transaction.
209
+ Realtime delivery is transient. Use database/outbox/jobs/workflows for durable state and refetch durable state/history after reconnect when catch-up is required.
225
210
 
226
- Related guides: [Workflow Orchestration](workflow-orchestration.md), [Durable Jobs Platform](durable-jobs.md), [Observability Platform v2](observability.md).
211
+ Related guides: [Realtime Platform](realtime-platform.md), [Authentication](authentication.md), [Observability Platform v2](observability.md).
227
212
 
228
213
  ## `bcp/observability`
229
214