jazz-tools 2.0.0-alpha.30 → 2.0.0-alpha.33

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.
Files changed (148) hide show
  1. package/bin/docs-index.db +0 -0
  2. package/bin/docs-index.txt +203 -71
  3. package/bin/jazz-tools.js +2 -1
  4. package/bin/native/jazz-tools-darwin-arm64 +0 -0
  5. package/bin/native/jazz-tools-darwin-x64 +0 -0
  6. package/bin/native/jazz-tools-linux-arm64 +0 -0
  7. package/bin/native/jazz-tools-linux-x64 +0 -0
  8. package/dist/backend/create-jazz-context.d.ts +1 -1
  9. package/dist/backend/create-jazz-context.d.ts.map +1 -1
  10. package/dist/backend/create-jazz-context.js +13 -7
  11. package/dist/backend/create-jazz-context.js.map +1 -1
  12. package/dist/cli.d.ts +8 -1
  13. package/dist/cli.d.ts.map +1 -1
  14. package/dist/cli.js +85 -25
  15. package/dist/cli.js.map +1 -1
  16. package/dist/cli.test.js +260 -41
  17. package/dist/cli.test.js.map +1 -1
  18. package/dist/dev-tools/dev-tools.test.js +3 -3
  19. package/dist/dev-tools/dev-tools.test.js.map +1 -1
  20. package/dist/dev-tools/extension-panel.d.ts.map +1 -1
  21. package/dist/dev-tools/extension-panel.js +0 -2
  22. package/dist/dev-tools/extension-panel.js.map +1 -1
  23. package/dist/ir.d.ts +4 -0
  24. package/dist/ir.d.ts.map +1 -1
  25. package/dist/mcp/build-index.test.js +9 -6
  26. package/dist/mcp/build-index.test.js.map +1 -1
  27. package/dist/permissions/index.d.ts +15 -4
  28. package/dist/permissions/index.d.ts.map +1 -1
  29. package/dist/permissions/index.js +259 -40
  30. package/dist/permissions/index.js.map +1 -1
  31. package/dist/permissions/index.test.js +195 -0
  32. package/dist/permissions/index.test.js.map +1 -1
  33. package/dist/permissions/type-inference.test.js +3 -0
  34. package/dist/permissions/type-inference.test.js.map +1 -1
  35. package/dist/react-native/db.js +2 -2
  36. package/dist/react-native/db.js.map +1 -1
  37. package/dist/react-native/db.test.js +1 -1
  38. package/dist/react-native/db.test.js.map +1 -1
  39. package/dist/react-native/jazz-rn-runtime-adapter.js +2 -2
  40. package/dist/react-native/jazz-rn-runtime-adapter.js.map +1 -1
  41. package/dist/react-native/jazz-rn-runtime-adapter.test.js +8 -8
  42. package/dist/react-native/jazz-rn-runtime-adapter.test.js.map +1 -1
  43. package/dist/runtime/auth-secret-store.d.ts +12 -5
  44. package/dist/runtime/auth-secret-store.d.ts.map +1 -1
  45. package/dist/runtime/auth-secret-store.js +56 -14
  46. package/dist/runtime/auth-secret-store.js.map +1 -1
  47. package/dist/runtime/auth-secret-store.test.js +41 -0
  48. package/dist/runtime/auth-secret-store.test.js.map +1 -1
  49. package/dist/runtime/auth-state.d.ts +7 -2
  50. package/dist/runtime/auth-state.d.ts.map +1 -1
  51. package/dist/runtime/auth-state.js +27 -2
  52. package/dist/runtime/auth-state.js.map +1 -1
  53. package/dist/runtime/client-session.d.ts +2 -1
  54. package/dist/runtime/client-session.d.ts.map +1 -1
  55. package/dist/runtime/client-session.js +6 -18
  56. package/dist/runtime/client-session.js.map +1 -1
  57. package/dist/runtime/client-session.test.js +18 -0
  58. package/dist/runtime/client-session.test.js.map +1 -1
  59. package/dist/runtime/client.d.ts +167 -16
  60. package/dist/runtime/client.d.ts.map +1 -1
  61. package/dist/runtime/client.for-request.test.js +23 -3
  62. package/dist/runtime/client.for-request.test.js.map +1 -1
  63. package/dist/runtime/client.js +471 -53
  64. package/dist/runtime/client.js.map +1 -1
  65. package/dist/runtime/client.mutations.test.js +61 -0
  66. package/dist/runtime/client.mutations.test.js.map +1 -1
  67. package/dist/runtime/client.test.js +40 -1
  68. package/dist/runtime/client.test.js.map +1 -1
  69. package/dist/runtime/context.d.ts +7 -2
  70. package/dist/runtime/context.d.ts.map +1 -1
  71. package/dist/runtime/db.auth-state.test.js +123 -0
  72. package/dist/runtime/db.auth-state.test.js.map +1 -1
  73. package/dist/runtime/db.browser-storage-scope.test.d.ts +2 -0
  74. package/dist/runtime/db.browser-storage-scope.test.d.ts.map +1 -0
  75. package/dist/runtime/db.browser-storage-scope.test.js +49 -0
  76. package/dist/runtime/db.browser-storage-scope.test.js.map +1 -0
  77. package/dist/runtime/db.d.ts +119 -13
  78. package/dist/runtime/db.d.ts.map +1 -1
  79. package/dist/runtime/db.dev-mode.test.js +1 -1
  80. package/dist/runtime/db.dev-mode.test.js.map +1 -1
  81. package/dist/runtime/db.js +809 -71
  82. package/dist/runtime/db.js.map +1 -1
  83. package/dist/runtime/db.local-first-auth.test.js +12 -0
  84. package/dist/runtime/db.local-first-auth.test.js.map +1 -1
  85. package/dist/runtime/db.persisted.test.d.ts +2 -0
  86. package/dist/runtime/db.persisted.test.d.ts.map +1 -0
  87. package/dist/runtime/db.persisted.test.js +164 -0
  88. package/dist/runtime/db.persisted.test.js.map +1 -0
  89. package/dist/runtime/db.schema-order.test.js +93 -1
  90. package/dist/runtime/db.schema-order.test.js.map +1 -1
  91. package/dist/runtime/db.transaction.test.d.ts +2 -0
  92. package/dist/runtime/db.transaction.test.d.ts.map +1 -0
  93. package/dist/runtime/db.transaction.test.js +380 -0
  94. package/dist/runtime/db.transaction.test.js.map +1 -0
  95. package/dist/runtime/db.worker-bootstrap.test.js +32 -4
  96. package/dist/runtime/db.worker-bootstrap.test.js.map +1 -1
  97. package/dist/runtime/file-storage.test.js +1 -1
  98. package/dist/runtime/file-storage.test.js.map +1 -1
  99. package/dist/runtime/index.d.ts +2 -2
  100. package/dist/runtime/index.d.ts.map +1 -1
  101. package/dist/runtime/index.js +2 -2
  102. package/dist/runtime/index.js.map +1 -1
  103. package/dist/runtime/napi.for-request.test.js +1 -1
  104. package/dist/runtime/napi.for-request.test.js.map +1 -1
  105. package/dist/runtime/napi.integration.test.js +7 -7
  106. package/dist/runtime/napi.integration.test.js.map +1 -1
  107. package/dist/runtime/permissions.repro.test.d.ts +2 -0
  108. package/dist/runtime/permissions.repro.test.d.ts.map +1 -0
  109. package/dist/runtime/permissions.repro.test.js +143 -0
  110. package/dist/runtime/permissions.repro.test.js.map +1 -0
  111. package/dist/runtime/query-adapter.d.ts.map +1 -1
  112. package/dist/runtime/query-adapter.js +69 -6
  113. package/dist/runtime/query-adapter.js.map +1 -1
  114. package/dist/runtime/query-adapter.test.js +134 -0
  115. package/dist/runtime/query-adapter.test.js.map +1 -1
  116. package/dist/runtime/query-builder-shape.d.ts +10 -0
  117. package/dist/runtime/query-builder-shape.d.ts.map +1 -1
  118. package/dist/runtime/query-builder-shape.js +20 -0
  119. package/dist/runtime/query-builder-shape.js.map +1 -1
  120. package/dist/runtime/schema-fetch.d.ts +9 -0
  121. package/dist/runtime/schema-fetch.d.ts.map +1 -1
  122. package/dist/runtime/schema-fetch.js +21 -0
  123. package/dist/runtime/schema-fetch.js.map +1 -1
  124. package/dist/runtime/schema-fetch.test.js +27 -1
  125. package/dist/runtime/schema-fetch.test.js.map +1 -1
  126. package/dist/runtime/worker-bridge.d.ts +1 -0
  127. package/dist/runtime/worker-bridge.d.ts.map +1 -1
  128. package/dist/runtime/worker-bridge.js +1 -0
  129. package/dist/runtime/worker-bridge.js.map +1 -1
  130. package/dist/schema-permissions.d.ts.map +1 -1
  131. package/dist/schema-permissions.js +7 -0
  132. package/dist/schema-permissions.js.map +1 -1
  133. package/dist/testing/relation-ir-test-helpers.d.ts.map +1 -1
  134. package/dist/testing/relation-ir-test-helpers.js +7 -0
  135. package/dist/testing/relation-ir-test-helpers.js.map +1 -1
  136. package/dist/typed-app.d.ts +33 -3
  137. package/dist/typed-app.d.ts.map +1 -1
  138. package/dist/typed-app.js +91 -28
  139. package/dist/typed-app.js.map +1 -1
  140. package/dist/vue/use-all.test.js +3 -3
  141. package/dist/vue/use-all.test.js.map +1 -1
  142. package/dist/worker/jazz-worker.d.ts.map +1 -1
  143. package/dist/worker/jazz-worker.js +3 -3
  144. package/dist/worker/jazz-worker.js.map +1 -1
  145. package/dist/worker/jazz-worker.ts +5 -4
  146. package/dist/worker/worker-protocol.d.ts +2 -0
  147. package/dist/worker/worker-protocol.d.ts.map +1 -1
  148. package/package.json +4 -4
package/bin/docs-index.db CHANGED
Binary file
@@ -110,6 +110,7 @@ On a live client, `db.updateAuthToken(jwt)` is only for replacing the bearer tok
110
110
  the same principal:
111
111
 
112
112
  - `db.updateAuthToken(jwt)` refreshes bearer auth for the same principal on the live client.
113
+ - Backend-scoped wrappers from `createJazzContext().asBackend()`, `.forRequest()`, and `.forSession()` do not own shared bearer auth and ignore `updateAuthToken(...)`.
113
114
  - Do not use `db.updateAuthToken(null)` for logout or local-first fallback on a live client.
114
115
  - Switching from one principal to another, like `alice -> bob`, is not supported on a live `Db`.
115
116
  Recreate `Db` or `JazzProvider` when the authenticated user changes.
@@ -167,6 +168,7 @@ NODE_ENV=production \
167
168
  jazz-tools server "$JAZZ_APP_ID" \
168
169
  --port 1625 \
169
170
  --data-dir ./data \
171
+ --allow-local-first-auth \
170
172
  --jwks-url https://auth.example.com/.well-known/jwks.json \
171
173
  --backend-secret "$JAZZ_BACKEND_SECRET" \
172
174
  --admin-secret "$JAZZ_ADMIN_SECRET"
@@ -199,7 +201,7 @@ Users on local-first auth can sign up with an external provider and keep the sam
199
201
  TITLE:Local-first auth
200
202
  DESCRIPTION:"Authenticate users without a server using self-signed tokens, and optionally upgrade to an external provider while preserving identity."
201
203
 
202
- Local-first auth lets users start using your app immediately — no sign-up, no server round-trip. Jazz generates a stable identity from a secret stored on the device. Users can later sign up with an external provider like [BetterAuth](https://www.better-auth.com/) and keep the same identity.
204
+ Local-first auth lets users start using your app immediately — no sign-up, no server round-trip. Jazz generates a stable identity from a secret stored on the device. Without a recovery mechanism, that identity lives only on the device — if the secret is lost, it's gone. Linking to an external provider at sign-up is one way to make the identity durable and recoverable.
203
205
 
204
206
  | Mode | Identity source | Server needed? | Best for |
205
207
  | ------------- | ----------------------- | -------------- | ------------------------------------------------------ |
@@ -400,6 +402,43 @@ You can restrict what local-first users can do until they sign up. Define an `is
400
402
  });
401
403
  ```
402
404
 
405
+ ## Signing up with other providers
406
+
407
+ The BetterAuth example above uses a framework-specific middleware hook. With any other provider the pattern is the same — you need a server endpoint that:
408
+
409
+ 1. Accepts `proofToken` alongside the sign-up credentials
410
+ 2. Verifies it with `verifyLocalFirstIdentityProof` from `jazz-napi`
411
+ 3. Stores the proven Jazz user ID linked to the new user account
412
+ 4. Issues JWTs with either `sub: jazzId` or `jazz_principal_id: jazzId`
413
+
414
+ ```ts title="server.ts"
415
+
416
+ // POST /signup
417
+ app.post("/signup", async (req, res) => {
418
+ const { email, password, proofToken } = req.body;
419
+
420
+ const {
421
+ ok,
422
+ id: jazzUserId,
423
+ error,
424
+ } = verifyLocalFirstIdentityProof(
425
+ proofToken,
426
+ "my-app-signup", // must match the audience used on the client
427
+ );
428
+ if (!ok) return res.status(400).json({ error });
429
+
430
+ // Store jazzUserId so you can include it in future JWTs as `sub`
431
+ // or, for managed providers with provider-owned `sub`, as `jazz_principal_id`
432
+ const user = await db.users.create({ email, password, jazzId: jazzUserId });
433
+
434
+ res.json({ token: issueJwt({ sub: user.jazzId /* ... */ }) });
435
+ });
436
+ ```
437
+
438
+ The `audience` string on the client and server must match. `jazz-napi` normalizes it internally, so any consistent string works.
439
+
440
+ If your provider lets you control the JWT subject, you can set `sub` directly to the Jazz ID. Many managed providers keep `sub` fixed to their own user ID. In that case, call a dedicated `/link-jazz-identity` endpoint immediately after sign-up, store the Jazz ID in provider metadata or your own database, and mint or refresh JWTs with `jazz_principal_id: <jazzId>`. Jazz uses `jazz_principal_id` as `session.user_id` when present and falls back to `sub` otherwise.
441
+
403
442
  ## Under the hood
404
443
 
405
444
  Local-first auth uses Ed25519 cryptography to derive a stable identity from a secret:
@@ -430,6 +469,11 @@ DESCRIPTION:Jazz's approach to row-level security using relationship-based acces
430
469
 
431
470
  Permissions control who can read, insert, update, and delete rows. Jazz enforces them server-side using row-level policies defined in `permissions.ts`. Clients that fail a policy check have their writes rejected and their reads filtered.
432
471
 
472
+ Locally, Jazz distinguishes between two runtime states:
473
+
474
+ - no compiled policy bundle loaded: local session-scoped reads and writes stay permissive
475
+ - compiled policy bundle loaded: every read, insert, update, and delete needs an explicit grant, or it is denied
476
+
433
477
  ## Authoring workflow
434
478
 
435
479
  Permissions are authored in TypeScript.
@@ -470,11 +514,11 @@ We can define permissions in `permissions.ts`:
470
514
 
471
515
  ```
472
516
 
473
- Write your permissions policies in `permissions.ts` at the root of your project (next to `schema.ts`).
517
+ Write your permissions policies in `permissions.ts` next to `schema.ts`. By default Jazz looks for both files at your project root — except in SvelteKit projects, where they should live in `src/lib/` (the standard location for shared app code).
474
518
 
475
- Run `npx jazz-tools@alpha validate` before publishing to identify any issues. You do not need to write a schema migration to update permissions policies. Push the updated policies by running `npx jazz-tools@alpha permissions push`.
519
+ Run `npx jazz-tools@alpha validate` before publishing to identify any issues. You do not need to write a schema migration to update permissions policies. Push the updated policies by running `npx jazz-tools@alpha deploy`.
476
520
 
477
- Apps that do not need user-scoped filtering can still define explicit allow-all policies (`policy.todos.allowRead.always()` or `policy.todos.allowRead.where({})`).
521
+ Apps that do not need user-scoped filtering should still declare explicit grants (`policy.todos.allowRead.always()` or `policy.todos.allowRead.where({})`) once a compiled bundle is loaded.
478
522
 
479
523
  ## Basic policies
480
524
 
@@ -639,9 +683,9 @@ Every policy is evaluated against a session. On the frontend, this is the authen
639
683
 
640
684
  See [Server Setup](/docs/getting-started/server-setup#backend-context-setup) for backend context setup details.
641
685
 
642
- Policies are enforced on the sync server, not on the client. A client can write any data locally,
643
- but the server will reject writes that violate policies when they sync. Reads are filtered
644
- server-side before data is sent to the client.
686
+ Structural-only client runtimes stay permissive locally so offline reads and writes keep working.
687
+ Once a compiled bundle is loaded, Jazz enforces explicit grants locally too. Sync servers still
688
+ reject violating writes, and server-scoped reads are filtered before data is sent to the client.
645
689
 
646
690
  ## Magic columns
647
691
 
@@ -1038,13 +1082,13 @@ Jazz sync runs across three tiers:
1038
1082
  ```mermaid
1039
1083
  graph TD
1040
1084
  G["Global\n(global core)"] --- E1["Edge\n(sync server)"] & E2["Edge\n(sync server)"]
1041
- E1 --- W1["Worker"] & W2["Worker"]
1042
- E2 --- W3["Worker"]
1085
+ E1 --- W1["Local"] & W2["Local"]
1086
+ E2 --- W3["Local"]
1043
1087
  ```
1044
1088
 
1045
- **Worker** runs on the client itself, making it the first tier to respond to queries. The worker
1046
- keeps the locally durable copy of subscribed data so it can respond immediately while updates from
1047
- higher tiers stream in.
1089
+ **Local** is the first tier on the client itself. In browser persistent mode, a dedicated worker
1090
+ hosts that local durable copy in OPFS so it can respond immediately while updates from higher tiers
1091
+ stream in.
1048
1092
 
1049
1093
  **Edge** is the first server hop after the client. In cloud configurations it is usually a nearby
1050
1094
  node. Edge servers hold the data needed to serve the queries currently flowing through them.
@@ -1057,7 +1101,7 @@ updates eventually spread to every subscribed client.
1057
1101
  Writes flow **upward**:
1058
1102
 
1059
1103
  ```text
1060
- app -> worker -> edge -> global
1104
+ app -> local -> edge -> global
1061
1105
  ```
1062
1106
 
1063
1107
  As a write flows through the network, each tier can confirm that it has durably received it. That
@@ -1072,10 +1116,10 @@ them. As a rough guide:
1072
1116
 
1073
1117
  - waiting for the global core is only necessary if you want the strongest cross-region visibility
1074
1118
  - waiting for edge is useful when you want to know data has left the user's device
1075
- - the default worker tier is right for most local-first interactions
1119
+ - the default local tier is right for most local-first interactions
1076
1120
 
1077
1121
  Sync happens whenever a node is online. Writes keep propagating upward even if your promise
1078
- resolves at the worker tier. Reads similarly propagate downward as each tier registers the query
1122
+ resolves at the local tier. Reads similarly propagate downward as each tier registers the query
1079
1123
  with the next one up. If higher tiers have newer rows, they stream down automatically.
1080
1124
 
1081
1125
  ## Consistency model
@@ -1085,7 +1129,7 @@ replicated upward, and contributes to the current visible state for that row.
1085
1129
 
1086
1130
  Because sync is local-first, different tiers can temporarily disagree:
1087
1131
 
1088
- - your worker may already have a newer row version than edge
1132
+ - your local tier may already have a newer row version than edge
1089
1133
  - one edge may have data another edge has not fetched yet
1090
1134
  - another client may have its own concurrent local write
1091
1135
 
@@ -1445,16 +1489,16 @@ npx jazz-tools@alpha server "$JAZZ_APP_ID" \
1445
1489
 
1446
1490
  `jazz-tools server ` currently supports:
1447
1491
 
1448
- | Option | Purpose | Environment variable | Default |
1449
- | ----------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | ------------------------- |
1450
- | `` (positional) | App namespace identifier (required) | - | - |
1451
- | `-p, --port ` | Listen port | - | `1625` |
1452
- | `-d, --data-dir ` | Persistent storage directory | - | `./data` |
1453
- | `--in-memory` | Use in-memory storage instead of files; data is lost when the process exits | - | off |
1454
- | `--jwks-url ` | JWKS endpoint for external JWT validation | `JAZZ_JWKS_URL` | unset |
1455
- | `--allow-local-first-auth` | Allow local-first auth (`Authorization: Bearer <self-signed Jazz JWT>`) | `JAZZ_ALLOW_LOCAL_FIRST_AUTH` | see `NODE_ENV` note below |
1456
- | `--backend-secret ` | Enable backend session impersonation | `JAZZ_BACKEND_SECRET` | unset |
1457
- | `--admin-secret ` | Required for `permissions push`, `migrations push`, and schema catalogue reads. In development mode, structural schema auto-sync works without it. | `JAZZ_ADMIN_SECRET` | unset |
1492
+ | Option | Purpose | Environment variable | Default |
1493
+ | ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | ------------------------- |
1494
+ | `` (positional) | App namespace identifier (required) | - | - |
1495
+ | `-p, --port ` | Listen port | - | `1625` |
1496
+ | `-d, --data-dir ` | Persistent storage directory | - | `./data` |
1497
+ | `--in-memory` | Use in-memory storage instead of files; data is lost when the process exits | - | off |
1498
+ | `--jwks-url ` | JWKS endpoint for external JWT validation | `JAZZ_JWKS_URL` | unset |
1499
+ | `--allow-local-first-auth` | Allow local-first auth (`Authorization: Bearer <self-signed Jazz JWT>`) | `JAZZ_ALLOW_LOCAL_FIRST_AUTH` | see `NODE_ENV` note below |
1500
+ | `--backend-secret ` | Enable backend session impersonation | `JAZZ_BACKEND_SECRET` | unset |
1501
+ | `--admin-secret ` | Required for `deploy`, `migrations push`, and schema catalogue reads. In development mode, structural schema auto-sync works without it. | `JAZZ_ADMIN_SECRET` | unset |
1458
1502
 
1459
1503
  Local-first auth is enabled by default in development and requires `--allow-local-first-auth` in production. External JWT auth requires `--jwks-url`.
1460
1504
 
@@ -1689,7 +1733,7 @@ Start with a fresh app. If you already have one, skip to [Install](#install).
1689
1733
 
1690
1734
  ## Define your schema
1691
1735
 
1692
- Create `schema.ts` at the root of your project. This is the source of truth for your data model.
1736
+ Create `schema.ts` at the root of your project (or `src/lib/schema.ts` for SvelteKit). This is the source of truth for your data model.
1693
1737
 
1694
1738
  ```ts
1695
1739
 
@@ -2149,7 +2193,7 @@ The server rejects all reads and writes unless you define [permissions](/docs/au
2149
2193
  Then publish the permissions bundle:
2150
2194
 
2151
2195
  ```bash title="Terminal"
2152
- npx jazz-tools@alpha permissions push \
2196
+ npx jazz-tools@alpha deploy \
2153
2197
  --server-url http://127.0.0.1:1625 \
2154
2198
  --admin-secret secret
2155
2199
  ```
@@ -2168,7 +2212,7 @@ Update your client config to use the same app ID, and add `serverUrl`:
2168
2212
 
2169
2213
  Clients pick up the schema from the server when they connect. If you update `schema.ts` you need to [create and push a migration to the new schema](/docs/schemas/migrations) so that clients can understand existing data with the new schema.
2170
2214
 
2171
- Permissions can be updated without adding a new schema by using `npx jazz-tools@alpha permissions push`.
2215
+ Permissions can be updated without adding a new schema by using `npx jazz-tools@alpha deploy`.
2172
2216
 
2173
2217
  For production deployment and hosting options, see [Server Setup](/docs/getting-started/server-setup).
2174
2218
 
@@ -2209,7 +2253,7 @@ pnpm add -D typescript tsx
2209
2253
 
2210
2254
  ## Define your schema
2211
2255
 
2212
- Create `schema.ts` at the root of your project. This is the source of truth for your data model.
2256
+ Create `schema.ts` at the root of your project (or `src/lib/schema.ts` for SvelteKit). This is the source of truth for your data model.
2213
2257
 
2214
2258
  ```ts
2215
2259
 
@@ -2743,6 +2787,52 @@ pub fn composing_queries() {
2743
2787
 
2744
2788
  See [Filters & Sorting](/docs/reading/filters-and-sorting) for the full list of `where` operators, `orderBy`, `limit`, and `offset`.
2745
2789
 
2790
+ ## Read durability
2791
+
2792
+ Queries and subscriptions return results as soon as they are available locally by default. Local reads are effectively instant, and remote updates stream in as they arrive, which is normally a good default. When you need a stronger guarantee for the first result, pass a `tier` option to fetch data from a different tier before returning.
2793
+
2794
+ For background on how data flows between tiers, see [How Sync Works](/docs/concepts/how-sync-works#infrastructure-tiers).
2795
+
2796
+ ### Choosing a tier
2797
+
2798
+ Pass a tier when you need the first result to be authoritative at a specific level&hairsp;—&hairsp;for example, when a user has just navigated to a page and a stale local snapshot would mislead them.
2799
+
2800
+ - `"local"`&hairsp;—&hairsp;Local storage only. The default on browsers and clients. Fastest, but reflects only what this device has already synced.
2801
+ - `"edge"`&hairsp;—&hairsp;Wait for the nearest sync server to respond. The default on backends and servers. A good middle ground when you want confirmation that the query has fetched data from the network.
2802
+ - `"global"`&hairsp;—&hairsp;Wait for the central server. Use when you need a globally-consistent snapshot, accepting the extra round-trip latency.
2803
+
2804
+ ```ts
2805
+
2806
+ return db.all(app.todos.where({ done: false }), { tier: "edge", localUpdates: "immediate" });
2807
+ }
2808
+ ```
2809
+
2810
+ ```rs
2811
+ pub async fn read_todos_at_edge_durability(client: &JazzClient) -> jazz_tools::Result<usize> {
2812
+ let query = QueryBuilder::new("todos").build();
2813
+ let rows = client
2814
+ .query(query, Some(DurabilityTier::EdgeServer))
2815
+ .await?;
2816
+ Ok(rows.len())
2817
+ }
2818
+ ```
2819
+
2820
+ The read tier gates the **first** delivery of a subscription only. After the initial snapshot
2821
+ arrives at the requested tier, subsequent updates are delivered as they reach the local node,
2822
+ regardless of which tier they've propagated to. For example, a subscription with `tier: "global"`
2823
+ guarantees a globally-consistent initial snapshot, but later incremental updates from other
2824
+ clients may arrive through edge tiers before being globally available **even if the durability of
2825
+ the write is set to `"global"`**.
2826
+
2827
+ ### Local updates and propagation
2828
+
2829
+ Two additional options control how the subscription interacts with local writes and upstream servers:
2830
+
2831
+ - `localUpdates` (`"immediate"` \| `"deferred"`, default `"immediate"`)&hairsp;—&hairsp;With `"immediate"`, your own local writes appear in the subscription while it's still waiting for the tier to confirm the initial snapshot (only once the subscription has settled at least once). With `"deferred"`, all delivery is held until the tier confirms.
2832
+ - `propagation` (`"full"` \| `"local-only"`, default `"full"`)&hairsp;—&hairsp;With `"full"`, the subscription is sent to upstream servers, which push matching data back. With `"local-only"`, only local storage is queried and no server communication happens.
2833
+
2834
+ See [Durability Tiers](/docs/reference/durability-tiers) for the full reference, including which APIs accept these options and how they compose.
2835
+
2746
2836
  ## Magic columns
2747
2837
 
2748
2838
  You can select and filter on Jazz's magic columns just like other columns. They are omitted from
@@ -2840,8 +2930,8 @@ const todos = useAll(app.todos);
2840
2930
  ```
2841
2931
 
2842
2932
  You're unlikely to see `undefined` in practice unless you're awaiting a more [durable
2843
- tier](/docs/reference/durability-tiers). Local storage reads are effectively instant and resolve
2844
- to `[]` if no data exists yet.
2933
+ tier](#read-durability). Local storage reads are effectively instant and resolve to `[]` if no
2934
+ data exists yet.
2845
2935
 
2846
2936
  ### Conditional queries
2847
2937
 
@@ -2896,33 +2986,6 @@ const filtered = useAll(query);
2896
2986
 
2897
2987
  ```
2898
2988
 
2899
- ### Read durability
2900
-
2901
- By default, queries deliver results from local storage immediately. Pass a `tier` option to wait for
2902
- a specific durability level before the first result arrives.
2903
-
2904
- ```ts
2905
-
2906
- return db.all(app.todos.where({ done: false }), { tier: "edge", localUpdates: "immediate" });
2907
- }
2908
- ```
2909
-
2910
- ```rs
2911
- pub async fn read_todos_at_edge_durability(client: &JazzClient) -> jazz_tools::Result<usize> {
2912
- let query = QueryBuilder::new("todos").build();
2913
- let rows = client
2914
- .query(query, Some(DurabilityTier::EdgeServer))
2915
- .await?;
2916
- Ok(rows.len())
2917
- }
2918
- ```
2919
-
2920
- For subscriptions, the durability tier applies only to the first result. After that, updates
2921
- stream in as they become available and are not guaranteed to have reached any particular tier.
2922
-
2923
- See [Durability Tiers](/docs/reference/durability-tiers) for the full reference, including
2924
- `localUpdates`, `propagation`, and how tiers interact with subscriptions.
2925
-
2926
2989
  ### React Suspense and Transitions
2927
2990
 
2928
2991
  `useAllSuspense` is a React-specific variant that suspends instead of returning `undefined`, keeping the previous result visible while the next one loads.
@@ -3040,7 +3103,7 @@ Jazz supports external JWT-based authentication for production use. This recipe
3040
3103
  1. The user signs in with your auth provider and gets a JWT.
3041
3104
  2. Your client passes that JWT to Jazz.
3042
3105
  3. The Jazz server validates the JWT signature against the provider's JWKS endpoint.
3043
- 4. On success, Jazz derives `session.user_id` from the JWT's `sub` claim and issuer.
3106
+ 4. On success, Jazz derives `session.user_id` from `jazz_principal_id` when present, otherwise from the JWT's `sub` claim.
3044
3107
 
3045
3108
  If you're unfamiliar with JWTs and JWKS, see the [explainer on the Authentication page](/docs/auth/authentication#external-auth-for-production).
3046
3109
 
@@ -3187,7 +3250,7 @@ Any provider that issues JWTs and exposes a JWKS endpoint will work. The key pat
3187
3250
  | Auth0 | `https://<tenant>.auth0.com/.well-known/jwks.json` | `auth0\|<id>` |
3188
3251
  | Firebase | `https://www.googleapis.com/service_accounts/v1/jwk/securetoken@system.gserviceaccount.com` | Firebase UID |
3189
3252
 
3190
- The `sub` claim identifies the user. Jazz derives `session.user_id` from it (combined with the JWT issuer when present).
3253
+ By default, the `sub` claim identifies the user. If your provider supports custom claims but keeps `sub` fixed to its own user ID, include `jazz_principal_id` in the JWT instead. Jazz uses `jazz_principal_id` as `session.user_id` when present and falls back to `sub` otherwise.
3191
3254
 
3192
3255
  Full working examples: [Better Auth chat](https://github.com/garden-co/jazz/tree/main/examples/auth-betterauth-chat), [WorkOS chat](https://github.com/garden-co/jazz/tree/main/examples/auth-workos-chat).
3193
3256
 
@@ -3564,7 +3627,7 @@ See [Defining tables](/docs/schemas/defining-tables) for the full schema DSL.
3564
3627
 
3565
3628
  ## Permissions
3566
3629
 
3567
- Match `$createdBy` to the `session.user_id` to validate whether the current user is the one who created the data. Because `$createdBy` is set automatically, we can allow all users to insert.
3630
+ Match `$createdBy` to the `session.user_id` to validate whether the current user is the one who created the data. Because `$createdBy` is set automatically, we can declare insert explicitly with `.always()`.
3568
3631
 
3569
3632
  ```ts
3570
3633
  s.definePermissions(app, ({ policy, session }) => {
@@ -3659,8 +3722,8 @@ For background on how data flows between tiers, see [How Sync Works](/docs/conce
3659
3722
 
3660
3723
  Options:
3661
3724
 
3662
- - `options.tier`: `"worker"` \| `"edge"` \| `"global"`
3663
- - Browser/client default: `"worker"`
3725
+ - `options.tier`: `"local"` \| `"edge"` \| `"global"`
3726
+ - Browser/client default: `"local"`
3664
3727
  - Backend/server default: `"edge"`
3665
3728
 
3666
3729
  See [Writing Data](/docs/writing/writing-data#write-durability-tiers) for detailed guidance on which tier to use and code examples.
@@ -3671,7 +3734,7 @@ Read durability controls when the **first result** of a query or subscription is
3671
3734
 
3672
3735
  | Option | Values | Default | What it does |
3673
3736
  | -------------- | ------------------------------------ | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3674
- | `tier` | `"worker"` \| `"edge"` \| `"global"` | Same as writes | How far the first result must come from before the query delivers. |
3737
+ | `tier` | `"local"` \| `"edge"` \| `"global"` | Same as writes | How far the first result must come from before the query delivers. |
3675
3738
  | `localUpdates` | `"immediate"` \| `"deferred"` | `"immediate"` | With `"immediate"`, your own local writes appear in the subscription while still waiting for the tier to confirm the initial snapshot. This only takes effect after the subscription has settled at least once. With `"deferred"`, all delivery is held until the tier confirms. |
3676
3739
  | `propagation` | `"full"` \| `"local-only"` | `"full"` | With `"full"`, the subscription is sent to upstream servers, which push matching data back. With `"local-only"`, only local storage is queried&hairsp;—&hairsp;no server communication. |
3677
3740
 
@@ -3748,7 +3811,7 @@ await db.deleteClientStorage();
3748
3811
  - Browser worker-backed `Db` only.
3749
3812
  - Must be called from the leader tab; otherwise it logs an error and returns without deleting. Close other tabs first.
3750
3813
  - Deletes OPFS storage only (`${namespace}.opfsbtree` for the active namespace).
3751
- - Does not clear `localStorage` auth/synthetic-user data.
3814
+ - Does not clear `localStorage` local-first auth data.
3752
3815
  - Reopens a clean worker runtime, so the same `db` instance remains usable.
3753
3816
 
3754
3817
  This is useful when iterating on your schema during development.
@@ -4222,7 +4285,7 @@ Jazz separates two durability questions:
4222
4285
  | `QuerySettled` | First read delivery | "Has the query result settled at tier T?" |
4223
4286
  | Write tier confirmation | Durable write completion | "Has this write been confirmed at tier T?" |
4224
4287
 
4225
- Both use the same tier lattice (`worker` < `edge` < `global`), but they answer different
4288
+ Both use the same tier lattice (`local` < `edge` < `global`), but they answer different
4226
4289
  questions. A query's first callback is held until `QuerySettled` reaches the requested tier. A
4227
4290
  durable write promise resolves when the requested tier confirms the write.
4228
4291
 
@@ -4607,8 +4670,18 @@ Traditional migration systems run a linear sequence and require peers to converg
4607
4670
  npx jazz-tools@alpha migrations push <fromHash> <toHash>
4608
4671
  ```
4609
4672
 
4673
+ If you also want to publish the current schema, the migration and permissions in one step, you can run:
4674
+
4675
+ ```bash
4676
+ npx jazz-tools@alpha deploy
4677
+ ```
4678
+
4679
+ `deploy` publishes the current schema if the server does not already know it, checks whether the
4680
+ previous permissions schema is connected to the new one on the server, pushes the local migration
4681
+ if needed, and then publishes the current permissions.
4682
+
4610
4683
  Permission-only changes in `permissions.ts` do not need migrations, but they do still require
4611
- `npx jazz-tools@alpha permissions push`. See [Permissions](/docs/auth/permissions) for details.
4684
+ `npx jazz-tools@alpha deploy`. See [Permissions](/docs/auth/permissions) for details.
4612
4685
 
4613
4686
  ## Generated stub
4614
4687
 
@@ -5162,6 +5235,12 @@ DESCRIPTION:Insert, update, and delete APIs with local-first execution, framewor
5162
5235
 
5163
5236
  All writes execute against the local database first. `insert`, `update`, and `delete` return immediately, while their `Durable` variants (`insertDurable`, `updateDurable`, `deleteDurable`) return a promise that resolves once the write reaches the requested [durability tier](#write-durability-tiers).
5164
5237
 
5238
+ For TypeScript callers that need a replayable handle instead of awaiting immediately, Jazz also exposes persisted-write helpers and explicit batch builders:
5239
+
5240
+ - `insertPersisted`, `updatePersisted`, `deletePersisted` return `DbPersistedWrite`
5241
+ - `beginTransaction(...)` returns `DbTransaction`
5242
+ - `beginDirectBatch(...)` returns `DbDirectBatch`
5243
+
5165
5244
  For browser `Blob`, `File`, or `ReadableStream` uploads, use `db.createFileFromBlob(...)`
5166
5245
  or `db.createFileFromStream(...)` and store the returned file ID on your own row.
5167
5246
 
@@ -5268,11 +5347,11 @@ pub async fn clear_nullable_fields(
5268
5347
 
5269
5348
  ## Write durability tiers
5270
5349
 
5271
- When using `insertDurable`, `updateDurable`, or `deleteDurable`, you can pass a tier option to control how far the mutation must propagate before the promise resolves: locally on the client (`worker`), the nearest edge server (`edge`), or the global core (`global`). If omitted, the tier defaults based on environment (see table).
5350
+ When using `insertDurable`, `updateDurable`, or `deleteDurable`, you can pass a tier option to control how far the mutation must propagate before the promise resolves: locally on the client (`local`), the nearest edge server (`edge`), or the global core (`global`). If omitted, the tier defaults based on environment (see table).
5272
5351
 
5273
5352
  | Tier | Resolves when | Default for |
5274
5353
  | -------- | ----------------------------------- | -------------- |
5275
- | `worker` | Persisted to local OPFS | Browser/client |
5354
+ | `local` | Persisted to local OPFS | Browser/client |
5276
5355
  | `edge` | Acknowledged by nearest sync server | Backend/server |
5277
5356
  | `global` | Propagated to global core | — |
5278
5357
 
@@ -5313,4 +5392,57 @@ pub async fn write_todo_with_default_durability(
5313
5392
 
5314
5393
  See [Durability Tiers](/docs/reference/durability-tiers) for the full reference, including read durability, data flow between tiers, and consistency semantics.
5315
5394
 
5316
- Need to clear local data during development? See [How do I reset browser storage?](/docs/reference/faq#reset-browser-storage)
5395
+ Need to clear local data during development? See [How do I reset browser storage?](/docs/reference/faq#reset-browser-storage)
5396
+
5397
+ ## Persisted write handles
5398
+
5399
+ Use the persisted variants when you want to keep a stable handle to a write after issuing it locally.
5400
+
5401
+ ```ts
5402
+ const pending = db.insertPersisted(app.todos, {
5403
+ title: "Ship review fixes",
5404
+ done: false,
5405
+ });
5406
+
5407
+ console.log(pending.batchId());
5408
+ console.log(pending.localBatchRecord());
5409
+
5410
+ try {
5411
+ const row = await pending.wait();
5412
+ console.log(row.id);
5413
+ } catch (error) {
5414
+ if (error instanceof PersistedWriteRejectedError) {
5415
+ console.error(error.code, error.reason);
5416
+ pending.acknowledgeRejectedBatch();
5417
+ }
5418
+ }
5419
+ ```
5420
+
5421
+ `wait()` resolves when the batch reaches the requested durability tier. If the batch is replayably rejected, it rejects with `PersistedWriteRejectedError` instead of hanging.
5422
+
5423
+ ## Explicit batches
5424
+
5425
+ Use an explicit transaction when several writes should settle together after an authority validates the sealed batch:
5426
+
5427
+ ```ts
5428
+ const tx = db.beginTransaction(app.todos);
5429
+
5430
+ tx.insert(app.todos, { title: "Draft copy", done: false });
5431
+ tx.update(app.todos, todoId, { done: true });
5432
+
5433
+ const batchId = tx.commit();
5434
+ console.log(batchId);
5435
+ ```
5436
+
5437
+ Use a direct batch when you want to group several ordinary writes under one batch id without sealing:
5438
+
5439
+ ```ts
5440
+ const batch = db.beginDirectBatch(app.todos);
5441
+
5442
+ batch.insert(app.todos, { title: "Grouped direct write", done: false });
5443
+ batch.update(app.todos, todoId, { done: true });
5444
+
5445
+ console.log(batch.batchId());
5446
+ ```
5447
+
5448
+ Both builders can also issue persisted writes, expose `localBatchRecord()` / `localBatchRecords()`, and let you acknowledge replayable rejections by batch id.
package/bin/jazz-tools.js CHANGED
@@ -101,8 +101,8 @@ function printWrapperHelp() {
101
101
  console.log(
102
102
  " schema export Print structural schema JSON from schema.ts or a schema hash",
103
103
  );
104
+ console.log(" deploy Publish the current schema and permissions to the server");
104
105
  console.log(" permissions status Show the current server permissions head for this app");
105
- console.log(" permissions push Publish the current permissions.ts with head-parent checks");
106
106
  console.log(
107
107
  " migrations create Generate a typed structural migration stub from snapshots or schema hashes",
108
108
  );
@@ -135,6 +135,7 @@ if (!command || command === "--help" || command === "-h") {
135
135
  fail("`jazz-tools build` has been renamed to `jazz-tools validate`.");
136
136
  } else if (
137
137
  command === "validate" ||
138
+ command === "deploy" ||
138
139
  command === "migrations" ||
139
140
  command === "permissions" ||
140
141
  command === "schema"
Binary file
Binary file
Binary file
Binary file
@@ -30,7 +30,7 @@ export type BackendContextConfig = Omit<AppContext, "schema" | "driver" | "clien
30
30
  /** Server runtime driver mode and storage location. */
31
31
  driver: BackendDriver;
32
32
  /** Optional node durability tier identity. */
33
- tier?: "worker" | "edge" | "global";
33
+ tier?: "local" | "edge" | "global";
34
34
  /** JWKS endpoint used to verify external bearer JWTs in `forRequest()`. */
35
35
  jwksUrl?: string;
36
36
  /** Whether local-first bearer JWTs are accepted in `forRequest()`. Defaults to `true`. */
@@ -1 +1 @@
1
- {"version":3,"file":"create-jazz-context.d.ts","sourceRoot":"","sources":["../../src/backend/create-jazz-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAsB,KAAK,EAAE,EAAiB,MAAM,kBAAkB,CAAC;AAI9E,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,UAAU,CAAC;CACxB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,UAAU,CAAC;CACrB;AAED,MAAM,MAAM,kBAAkB,GAAG,UAAU,GAAG,mBAAmB,GAAG,wBAAwB,CAAC;AAE7F,MAAM,MAAM,aAAa,GACrB;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEN,KAAK,0BAA0B,GAC3B;IACE,iDAAiD;IACjD,G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EAAE;IAI1C;;;OAGG;IACH,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,EAAE;IAMrE;;;OAGG;IACH,OAAO,CAAC,6BAA6B;YAYvB,qBAAqB;IAQnC;;OAEG;IACG,UAAU,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,EAAE,CAAC;IAOhF;;;OAGG;IACH,yBAAyB,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,EAAE;IAM5E;;;OAGG;IACG,yBAAyB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,OAAO,CAAC,EAAE,CAAC;IAI/F;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,kBAAkB,GAAG,EAAE;IAM7D;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAWhC;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,oBAAoB,GAAG,WAAW,CAE3E"}
@@ -113,8 +113,14 @@ export class JazzContext {
113
113
  adminSecret: this.config.adminSecret,
114
114
  };
115
115
  }
116
- wrapDb(client, session, attribution) {
117
- return createDbFromClient(this.buildDbConfig(), client, session, attribution);
116
+ wrapDb(client, session, attribution, backendScoped = false) {
117
+ return createDbFromClient(this.buildDbConfig(), client, session, attribution, backendScoped
118
+ ? {
119
+ status: "authenticated",
120
+ transport: "backend",
121
+ session: session ?? null,
122
+ }
123
+ : undefined);
118
124
  }
119
125
  /**
120
126
  * Get the shared Jazz client, lazily creating it on first access.
@@ -142,7 +148,7 @@ export class JazzContext {
142
148
  * Get a backend-scoped `Db` authenticated with `backendSecret`.
143
149
  */
144
150
  asBackend(source) {
145
- return this.wrapDb(this.getClient(source).asBackend());
151
+ return this.wrapDb(this.getClient(source).asBackend(), undefined, undefined, true);
146
152
  }
147
153
  /**
148
154
  * Build a backend-scoped `Db` that stamps write provenance as `principalId`
@@ -151,7 +157,7 @@ export class JazzContext {
151
157
  withAttribution(principalId, source) {
152
158
  const client = this.getClient(source);
153
159
  this.enableBackendSyncIfConfigured(client);
154
- return this.wrapDb(client, undefined, principalId);
160
+ return this.wrapDb(client, undefined, principalId, true);
155
161
  }
156
162
  /**
157
163
  * Enable backend-authenticated sync for a scoped `Db` when this context is connected
@@ -180,7 +186,7 @@ export class JazzContext {
180
186
  const client = this.getClient(source);
181
187
  const session = await this.resolveRequestSession(request);
182
188
  this.enableBackendSyncIfConfigured(client);
183
- return this.wrapDb(client, session);
189
+ return this.wrapDb(client, session, undefined, true);
184
190
  }
185
191
  /**
186
192
  * Build a backend-scoped `Db` that stamps write provenance using the
@@ -189,7 +195,7 @@ export class JazzContext {
189
195
  withAttributionForSession(session, source) {
190
196
  const client = this.getClient(source);
191
197
  this.enableBackendSyncIfConfigured(client);
192
- return this.wrapDb(client, undefined, session.user_id);
198
+ return this.wrapDb(client, undefined, session.user_id, true);
193
199
  }
194
200
  /**
195
201
  * Build a backend-scoped `Db` that stamps write provenance using the
@@ -204,7 +210,7 @@ export class JazzContext {
204
210
  forSession(session, source) {
205
211
  const client = this.getClient(source);
206
212
  this.enableBackendSyncIfConfigured(client);
207
- return this.wrapDb(client, session);
213
+ return this.wrapDb(client, session, undefined, true);
208
214
  }
209
215
  /**
210
216
  * Flush the underlying runtime if initialized.
@@ -1 +1 @@
1
- {"version":3,"file":"create-jazz-context.js","sourceRoot":"","sources":["../../src/backend/create-jazz-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAA0B,MAAM,kBAAkB,C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