create-bcp-app 0.2.12 → 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/README.md CHANGED
@@ -69,17 +69,17 @@ Select storage provider:
69
69
 
70
70
  New projects include `bcp.project.json`.
71
71
 
72
- Example for the `0.2.12` target:
72
+ Example for the `0.2.13` target:
73
73
 
74
74
  ```json
75
75
  {
76
76
  "schemaVersion": 1,
77
77
  "framework": "bcp",
78
78
  "projectName": "my-app",
79
- "frameworkPackage": "npm:@chidchanun/bcp@0.2.12",
79
+ "frameworkPackage": "npm:@chidchanun/bcp@0.2.13",
80
80
  "createdWith": {
81
81
  "package": "create-bcp-app",
82
- "version": "0.2.12"
82
+ "version": "0.2.13"
83
83
  },
84
84
  "packageManager": "npm",
85
85
  "presets": {
@@ -167,26 +167,6 @@ export const onboarding =
167
167
  Applications using the SQL Database Platform can persist integration events in the same transaction as business data:
168
168
 
169
169
  ```ts
170
- import {
171
- db,
172
- } from "bcp/database";
173
-
174
- import {
175
- createSqlOutboxStore,
176
- createTransactionalOutbox,
177
- } from "bcp/events";
178
-
179
- const outboxStore =
180
- createSqlOutboxStore({
181
- database: db,
182
- driver: "mysql",
183
- });
184
-
185
- const outbox =
186
- createTransactionalOutbox({
187
- store: outboxStore,
188
- });
189
-
190
170
  await db.transaction(
191
171
  async tx => {
192
172
  await tx.execute(
@@ -204,42 +184,78 @@ await db.transaction(
204
184
  );
205
185
  ```
206
186
 
207
- Create migration SQL with:
187
+ After commit, `createOutboxDispatcher()` can hand off events to durable jobs/custom publishers.
188
+
189
+ ## Realtime Platform — 0.2.13+
190
+
191
+ Generated applications can add server-side realtime channels without changing the scaffold preset model:
208
192
 
209
193
  ```ts
210
194
  import {
211
- createOutboxMigrationSql,
212
- } from "bcp/events";
195
+ createRealtime,
196
+ } from "bcp/realtime";
213
197
 
214
- const migrationSql =
215
- createOutboxMigrationSql(
216
- "mysql"
217
- );
198
+ export const realtime =
199
+ createRealtime();
218
200
  ```
219
201
 
220
- After commit, dispatch to the durable job queue:
202
+ Channel/room usage:
221
203
 
222
204
  ```ts
223
- import {
224
- createOutboxDispatcher,
225
- } from "bcp/events";
205
+ const connection =
206
+ await realtime.connect();
226
207
 
227
- const dispatcher =
228
- createOutboxDispatcher({
229
- store: outboxStore,
230
- queue: jobs,
231
- ownerId: "outbox-a",
232
- });
208
+ await connection.join(
209
+ "orders:42"
210
+ );
211
+
212
+ await realtime.broadcast(
213
+ "orders:42",
214
+ "order.updated",
215
+ {
216
+ status: "paid",
217
+ }
218
+ );
219
+ ```
220
+
221
+ Presence metadata can be attached during `join()` and read with `realtime.members(channel)`.
222
+
223
+ For private channels, configure `authenticate`, `getUserId` and `authorizeChannel` on `createRealtime()`.
233
224
 
234
- const runner =
235
- dispatcher.start();
225
+ ### WebSocket integration
226
+
227
+ BCP does not install a WebSocket library. Adapt your selected provider to `RealtimeSocket` and pass it to:
228
+
229
+ ```ts
230
+ await realtime.attachSocket(
231
+ socketAdapter,
232
+ {
233
+ request,
234
+ }
235
+ );
236
236
  ```
237
237
 
238
- Event type `order.created` is handed off to queue name `event.order.created`.
238
+ ### Server-Sent Events
239
+
240
+ SSE is available without another dependency:
241
+
242
+ ```ts
243
+ export function GET(
244
+ request: Request
245
+ ) {
246
+ return realtime.sse(
247
+ "jobs:42",
248
+ {
249
+ signal:
250
+ request.signal,
251
+ }
252
+ );
253
+ }
254
+ ```
239
255
 
240
- The outbox dispatcher supports leases, stale recovery, retry/backoff, custom publishers, a local EventBus, cleanup and statistics.
256
+ The memory broker/presence store are local-only. Multi-instance production deployments should provide shared `RealtimeBroker` and `RealtimePresenceStore` implementations.
241
257
 
242
- `bcp/events` is server-only. The SQL outbox protects the database-commit/external-publish boundary, but downstream delivery remains at-least-once, so non-repeatable side effects should use idempotency protection.
258
+ `bcp/realtime` is server-only and cannot be imported into page/client bundles.
243
259
 
244
260
  ## Storage providers
245
261
 
@@ -279,5 +295,5 @@ npm run generate -- migration create_users
279
295
  For prerelease/local package verification:
280
296
 
281
297
  ```bash
282
- npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.12.tgz
298
+ npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.13.tgz
283
299
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bcp-app",
3
- "version": "0.2.12",
3
+ "version": "0.2.13",
4
4
  "description": "Create a new BCP Framework application.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -112,26 +112,6 @@ Workflows support sequential/parallel steps, retries, persisted delays, compensa
112
112
  Use `bcp/events` when application data and an integration event must commit atomically in the same SQL transaction.
113
113
 
114
114
  ```ts
115
- import {
116
- db,
117
- } from "bcp/database";
118
-
119
- import {
120
- createSqlOutboxStore,
121
- createTransactionalOutbox,
122
- } from "bcp/events";
123
-
124
- const outboxStore =
125
- createSqlOutboxStore({
126
- database: db,
127
- driver: "mysql",
128
- });
129
-
130
- const outbox =
131
- createTransactionalOutbox({
132
- store: outboxStore,
133
- });
134
-
135
115
  await db.transaction(
136
116
  async tx => {
137
117
  await tx.execute(
@@ -149,42 +129,63 @@ await db.transaction(
149
129
  );
150
130
  ```
151
131
 
152
- Generate the required table SQL:
132
+ After commit, `createOutboxDispatcher()` can deliver through durable jobs or a custom publisher.
133
+
134
+ ## Realtime Platform — BCP 0.2.13+
135
+
136
+ Create a server-side realtime hub:
153
137
 
154
138
  ```ts
155
139
  import {
156
- createOutboxMigrationSql,
157
- } from "bcp/events";
140
+ createRealtime,
141
+ } from "bcp/realtime";
158
142
 
159
- const sql =
160
- createOutboxMigrationSql(
161
- "mysql"
162
- );
143
+ export const realtime =
144
+ createRealtime();
163
145
  ```
164
146
 
165
- Dispatch committed events to the durable queue:
147
+ Channels/rooms:
166
148
 
167
149
  ```ts
168
- import {
169
- createOutboxDispatcher,
170
- } from "bcp/events";
150
+ const connection =
151
+ await realtime.connect();
171
152
 
172
- const dispatcher =
173
- createOutboxDispatcher({
174
- store: outboxStore,
175
- queue: jobs,
176
- ownerId: "outbox-a",
177
- });
153
+ await connection.join(
154
+ "orders:42"
155
+ );
178
156
 
179
- const runner =
180
- dispatcher.start();
157
+ await realtime.broadcast(
158
+ "orders:42",
159
+ "order.updated",
160
+ {
161
+ status: "paid",
162
+ }
163
+ );
181
164
  ```
182
165
 
183
- Event `order.created` is queued as `event.order.created`.
166
+ Presence metadata can be supplied during `join()` and queried with `realtime.members(channel)`.
167
+
168
+ BCP does not install a WebSocket server dependency. Adapt the selected provider to `RealtimeSocket` and call `realtime.attachSocket(socketAdapter, { request })`.
169
+
170
+ SSE is built in:
171
+
172
+ ```ts
173
+ export function GET(
174
+ request: Request
175
+ ) {
176
+ return realtime.sse(
177
+ "jobs:42",
178
+ {
179
+ signal:
180
+ request.signal,
181
+ }
182
+ );
183
+ }
184
+ ```
184
185
 
185
- The dispatcher supports leases, stale recovery, retry/backoff, custom publishers, local EventBus delivery, retention cleanup and statistics.
186
+ For multi-instance deployment, replace the memory broker/presence store with shared `RealtimeBroker` and `RealtimePresenceStore` implementations.
186
187
 
187
- `bcp/events` is server-only. Outbox delivery remains at-least-once, so non-repeatable downstream side effects should use idempotency protection.
188
+ `bcp/realtime` is server-only and cannot be imported into page/client bundles.
188
189
 
189
190
  ## Generate framework files
190
191