@brickkit/core 0.8.2 → 0.9.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 +25 -0
- package/dist/chunks/client.d.ts +959 -3
- package/dist/chunks/client.d.ts.map +1 -1
- package/dist/chunks/client.js +2 -1
- package/dist/chunks/client.js.map +1 -1
- package/dist/index.d.ts +145 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +914 -6
- package/dist/index.js.map +1 -1
- package/dist/pg.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,6 +160,31 @@ app.all(
|
|
|
160
160
|
`brick dev` registers a provider and sends the spans to its dashboard, so apps
|
|
161
161
|
there need `telemetry: true` too.
|
|
162
162
|
|
|
163
|
+
## Events
|
|
164
|
+
|
|
165
|
+
Generated CRUD writes can record an event in the same transaction as the row, and
|
|
166
|
+
Brick delivers it to your listeners after the commit, retrying one that fails.
|
|
167
|
+
Add `outboxTable()` to the database, define a listener, and pass it to `brick()`.
|
|
168
|
+
|
|
169
|
+
```ts
|
|
170
|
+
import { brick, defineListener, outboxTable } from "@brickkit/core";
|
|
171
|
+
|
|
172
|
+
export const outbox = outboxTable("postgres");
|
|
173
|
+
|
|
174
|
+
const welcome = defineListener({
|
|
175
|
+
name: "welcome-email",
|
|
176
|
+
on: "user.create",
|
|
177
|
+
run: async ({ payload, deliveryId }) => {
|
|
178
|
+
await mailer.sendWelcome(payload.row.email, { idempotencyKey: deliveryId });
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
export default brick({ services, events: { listeners: [welcome] } });
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Delivery is at least once, so use `deliveryId` as an idempotency key. An app
|
|
186
|
+
without `events` behaves as before. See the [Events guide](https://brickkit.dev/docs/events).
|
|
187
|
+
|
|
163
188
|
## TanStack Query options
|
|
164
189
|
|
|
165
190
|
Install `@tanstack/query-core` v5 alongside your framework's TanStack Query package.
|