@rocicorp/zero 0.25.0-canary.14 → 0.25.0-canary.17

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 (233) hide show
  1. package/out/shared/src/deep-merge.d.ts +6 -4
  2. package/out/shared/src/deep-merge.d.ts.map +1 -1
  3. package/out/shared/src/deep-merge.js +2 -1
  4. package/out/shared/src/deep-merge.js.map +1 -1
  5. package/out/shared/src/record-proxy.d.ts +13 -0
  6. package/out/shared/src/record-proxy.d.ts.map +1 -0
  7. package/out/shared/src/record-proxy.js +59 -0
  8. package/out/shared/src/record-proxy.js.map +1 -0
  9. package/out/z2s/src/compiler.d.ts.map +1 -1
  10. package/out/z2s/src/compiler.js +4 -2
  11. package/out/z2s/src/compiler.js.map +1 -1
  12. package/out/zero/package.json.js +1 -1
  13. package/out/zero/src/pg.js +4 -3
  14. package/out/zero/src/server.js +4 -3
  15. package/out/zero/src/zero.js +11 -3
  16. package/out/zero/src/zero.js.map +1 -1
  17. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  18. package/out/zero-cache/src/auth/write-authorizer.js +20 -13
  19. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  20. package/out/zero-cache/src/config/zero-config.d.ts +16 -0
  21. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  22. package/out/zero-cache/src/config/zero-config.js +28 -0
  23. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  24. package/out/zero-cache/src/server/otel-diag-logger.d.ts.map +1 -1
  25. package/out/zero-cache/src/server/otel-diag-logger.js +1 -22
  26. package/out/zero-cache/src/server/otel-diag-logger.js.map +1 -1
  27. package/out/zero-cache/src/server/otel-start.d.ts.map +1 -1
  28. package/out/zero-cache/src/server/otel-start.js +1 -5
  29. package/out/zero-cache/src/server/otel-start.js.map +1 -1
  30. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  31. package/out/zero-cache/src/server/syncer.js +6 -1
  32. package/out/zero-cache/src/server/syncer.js.map +1 -1
  33. package/out/zero-cache/src/services/litestream/commands.js +3 -2
  34. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  35. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +8 -9
  36. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  37. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +17 -11
  38. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  39. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +2 -2
  40. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
  41. package/out/zero-cache/src/services/view-syncer/snapshotter.js +19 -4
  42. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  43. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  44. package/out/zero-cache/src/services/view-syncer/view-syncer.js +1 -7
  45. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  46. package/out/zero-client/src/client/crud-impl.d.ts +11 -0
  47. package/out/zero-client/src/client/crud-impl.d.ts.map +1 -0
  48. package/out/zero-client/src/client/crud-impl.js +102 -0
  49. package/out/zero-client/src/client/crud-impl.js.map +1 -0
  50. package/out/zero-client/src/client/crud.d.ts +7 -40
  51. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  52. package/out/zero-client/src/client/crud.js +21 -107
  53. package/out/zero-client/src/client/crud.js.map +1 -1
  54. package/out/zero-client/src/client/custom.d.ts +2 -2
  55. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  56. package/out/zero-client/src/client/custom.js +5 -50
  57. package/out/zero-client/src/client/custom.js.map +1 -1
  58. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  59. package/out/zero-client/src/client/ivm-branch.js +20 -13
  60. package/out/zero-client/src/client/ivm-branch.js.map +1 -1
  61. package/out/zero-client/src/client/make-mutate-property.d.ts +1 -1
  62. package/out/zero-client/src/client/make-mutate-property.d.ts.map +1 -1
  63. package/out/zero-client/src/client/make-mutate-property.js.map +1 -1
  64. package/out/zero-client/src/client/make-replicache-mutators.d.ts.map +1 -1
  65. package/out/zero-client/src/client/make-replicache-mutators.js +14 -7
  66. package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
  67. package/out/zero-client/src/client/version.js +1 -1
  68. package/out/zero-client/src/client/zero.d.ts +9 -7
  69. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  70. package/out/zero-client/src/client/zero.js +11 -4
  71. package/out/zero-client/src/client/zero.js.map +1 -1
  72. package/out/zero-client/src/mod.d.ts +7 -6
  73. package/out/zero-client/src/mod.d.ts.map +1 -1
  74. package/out/zero-react/src/use-query.d.ts +6 -4
  75. package/out/zero-react/src/use-query.d.ts.map +1 -1
  76. package/out/zero-react/src/use-query.js +2 -1
  77. package/out/zero-react/src/use-query.js.map +1 -1
  78. package/out/zero-server/src/custom.d.ts +44 -5
  79. package/out/zero-server/src/custom.d.ts.map +1 -1
  80. package/out/zero-server/src/custom.js +98 -35
  81. package/out/zero-server/src/custom.js.map +1 -1
  82. package/out/zero-server/src/zql-database.d.ts +1 -1
  83. package/out/zero-server/src/zql-database.d.ts.map +1 -1
  84. package/out/zero-server/src/zql-database.js +5 -13
  85. package/out/zero-server/src/zql-database.js.map +1 -1
  86. package/out/zero-solid/src/solid-view.d.ts +7 -2
  87. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  88. package/out/zero-solid/src/solid-view.js +3 -32
  89. package/out/zero-solid/src/solid-view.js.map +1 -1
  90. package/out/zero-solid/src/use-query.d.ts +5 -3
  91. package/out/zero-solid/src/use-query.d.ts.map +1 -1
  92. package/out/zero-solid/src/use-query.js +5 -1
  93. package/out/zero-solid/src/use-query.js.map +1 -1
  94. package/out/zero-types/src/schema.d.ts +4 -4
  95. package/out/zql/src/builder/builder.d.ts.map +1 -1
  96. package/out/zql/src/builder/builder.js +1 -11
  97. package/out/zql/src/builder/builder.js.map +1 -1
  98. package/out/zql/src/error.js +1 -10
  99. package/out/zql/src/error.js.map +1 -1
  100. package/out/zql/src/ivm/array-view.d.ts +1 -1
  101. package/out/zql/src/ivm/array-view.d.ts.map +1 -1
  102. package/out/zql/src/ivm/array-view.js +2 -0
  103. package/out/zql/src/ivm/array-view.js.map +1 -1
  104. package/out/zql/src/ivm/exists.d.ts +3 -2
  105. package/out/zql/src/ivm/exists.d.ts.map +1 -1
  106. package/out/zql/src/ivm/exists.js +25 -23
  107. package/out/zql/src/ivm/exists.js.map +1 -1
  108. package/out/zql/src/ivm/fan-in.d.ts +3 -3
  109. package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
  110. package/out/zql/src/ivm/fan-in.js +6 -5
  111. package/out/zql/src/ivm/fan-in.js.map +1 -1
  112. package/out/zql/src/ivm/fan-out.d.ts +2 -2
  113. package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
  114. package/out/zql/src/ivm/fan-out.js +5 -5
  115. package/out/zql/src/ivm/fan-out.js.map +1 -1
  116. package/out/zql/src/ivm/filter-operators.d.ts +5 -5
  117. package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
  118. package/out/zql/src/ivm/filter-operators.js +8 -8
  119. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  120. package/out/zql/src/ivm/filter-push.d.ts +2 -1
  121. package/out/zql/src/ivm/filter-push.d.ts.map +1 -1
  122. package/out/zql/src/ivm/filter-push.js +5 -5
  123. package/out/zql/src/ivm/filter-push.js.map +1 -1
  124. package/out/zql/src/ivm/filter.d.ts +2 -2
  125. package/out/zql/src/ivm/filter.d.ts.map +1 -1
  126. package/out/zql/src/ivm/filter.js +4 -4
  127. package/out/zql/src/ivm/filter.js.map +1 -1
  128. package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
  129. package/out/zql/src/ivm/flipped-join.js +100 -83
  130. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  131. package/out/zql/src/ivm/join.d.ts.map +1 -1
  132. package/out/zql/src/ivm/join.js +52 -50
  133. package/out/zql/src/ivm/join.js.map +1 -1
  134. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
  135. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
  136. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +4 -4
  137. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  138. package/out/zql/src/ivm/memory-source.d.ts +3 -3
  139. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  140. package/out/zql/src/ivm/memory-source.js +7 -4
  141. package/out/zql/src/ivm/memory-source.js.map +1 -1
  142. package/out/zql/src/ivm/operator.d.ts +10 -3
  143. package/out/zql/src/ivm/operator.d.ts.map +1 -1
  144. package/out/zql/src/ivm/operator.js.map +1 -1
  145. package/out/zql/src/ivm/push-accumulated.d.ts +1 -1
  146. package/out/zql/src/ivm/push-accumulated.d.ts.map +1 -1
  147. package/out/zql/src/ivm/push-accumulated.js +8 -8
  148. package/out/zql/src/ivm/push-accumulated.js.map +1 -1
  149. package/out/zql/src/ivm/skip.d.ts +1 -1
  150. package/out/zql/src/ivm/skip.d.ts.map +1 -1
  151. package/out/zql/src/ivm/skip.js +8 -3
  152. package/out/zql/src/ivm/skip.js.map +1 -1
  153. package/out/zql/src/ivm/source.d.ts +15 -7
  154. package/out/zql/src/ivm/source.d.ts.map +1 -1
  155. package/out/zql/src/ivm/stream.d.ts +2 -0
  156. package/out/zql/src/ivm/stream.d.ts.map +1 -1
  157. package/out/zql/src/ivm/stream.js +5 -14
  158. package/out/zql/src/ivm/stream.js.map +1 -1
  159. package/out/zql/src/ivm/take.d.ts +1 -1
  160. package/out/zql/src/ivm/take.d.ts.map +1 -1
  161. package/out/zql/src/ivm/take.js +164 -147
  162. package/out/zql/src/ivm/take.js.map +1 -1
  163. package/out/zql/src/ivm/union-fan-in.d.ts +2 -2
  164. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
  165. package/out/zql/src/ivm/union-fan-in.js +7 -7
  166. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  167. package/out/zql/src/ivm/union-fan-out.d.ts +1 -1
  168. package/out/zql/src/ivm/union-fan-out.d.ts.map +1 -1
  169. package/out/zql/src/ivm/union-fan-out.js +3 -3
  170. package/out/zql/src/ivm/union-fan-out.js.map +1 -1
  171. package/out/zql/src/mutate/crud.d.ts +139 -0
  172. package/out/zql/src/mutate/crud.d.ts.map +1 -0
  173. package/out/zql/src/mutate/crud.js +53 -0
  174. package/out/zql/src/mutate/crud.js.map +1 -0
  175. package/out/zql/src/mutate/custom.d.ts +12 -53
  176. package/out/zql/src/mutate/custom.d.ts.map +1 -1
  177. package/out/zql/src/mutate/custom.js +1 -5
  178. package/out/zql/src/mutate/custom.js.map +1 -1
  179. package/out/zql/src/mutate/mutator-registry.d.ts +33 -32
  180. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  181. package/out/zql/src/mutate/mutator-registry.js +26 -25
  182. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  183. package/out/zql/src/mutate/mutator.d.ts +48 -58
  184. package/out/zql/src/mutate/mutator.d.ts.map +1 -1
  185. package/out/zql/src/mutate/mutator.js +12 -8
  186. package/out/zql/src/mutate/mutator.js.map +1 -1
  187. package/out/zql/src/planner/planner-builder.d.ts +2 -1
  188. package/out/zql/src/planner/planner-builder.d.ts.map +1 -1
  189. package/out/zql/src/planner/planner-builder.js +5 -5
  190. package/out/zql/src/planner/planner-builder.js.map +1 -1
  191. package/out/zql/src/planner/planner-graph.d.ts +3 -1
  192. package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
  193. package/out/zql/src/planner/planner-graph.js +5 -5
  194. package/out/zql/src/planner/planner-graph.js.map +1 -1
  195. package/out/zql/src/query/abstract-query.d.ts +2 -3
  196. package/out/zql/src/query/abstract-query.d.ts.map +1 -1
  197. package/out/zql/src/query/abstract-query.js +0 -3
  198. package/out/zql/src/query/abstract-query.js.map +1 -1
  199. package/out/zql/src/query/create-builder.d.ts.map +1 -1
  200. package/out/zql/src/query/create-builder.js +7 -36
  201. package/out/zql/src/query/create-builder.js.map +1 -1
  202. package/out/zql/src/query/measure-push-operator.d.ts +1 -1
  203. package/out/zql/src/query/measure-push-operator.d.ts.map +1 -1
  204. package/out/zql/src/query/measure-push-operator.js +2 -2
  205. package/out/zql/src/query/measure-push-operator.js.map +1 -1
  206. package/out/zql/src/query/query-impl.d.ts +2 -2
  207. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  208. package/out/zql/src/query/query-impl.js.map +1 -1
  209. package/out/zql/src/query/query-registry.d.ts +87 -79
  210. package/out/zql/src/query/query-registry.d.ts.map +1 -1
  211. package/out/zql/src/query/query-registry.js +44 -38
  212. package/out/zql/src/query/query-registry.js.map +1 -1
  213. package/out/zql/src/query/query.d.ts +3 -18
  214. package/out/zql/src/query/query.d.ts.map +1 -1
  215. package/out/zql/src/query/runnable-query-impl.d.ts +2 -2
  216. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  217. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  218. package/out/zql/src/query/static-query.d.ts +1 -0
  219. package/out/zql/src/query/static-query.d.ts.map +1 -1
  220. package/out/zql/src/query/static-query.js +2 -2
  221. package/out/zql/src/query/static-query.js.map +1 -1
  222. package/out/zqlite/src/internal/sql-inline.d.ts +13 -0
  223. package/out/zqlite/src/internal/sql-inline.d.ts.map +1 -0
  224. package/out/zqlite/src/internal/sql-inline.js +45 -0
  225. package/out/zqlite/src/internal/sql-inline.js.map +1 -0
  226. package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -1
  227. package/out/zqlite/src/sqlite-cost-model.js +2 -2
  228. package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
  229. package/out/zqlite/src/table-source.d.ts +3 -2
  230. package/out/zqlite/src/table-source.d.ts.map +1 -1
  231. package/out/zqlite/src/table-source.js +5 -2
  232. package/out/zqlite/src/table-source.js.map +1 -1
  233. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ivm-branch.js","sources":["../../../../../zero-client/src/client/ivm-branch.ts"],"sourcesContent":["import type {\n InternalDiff,\n InternalDiffOperation,\n NoIndexDiff,\n} from '../../../replicache/src/btree/node.ts';\nimport type {LazyStore} from '../../../replicache/src/dag/lazy-store.ts';\nimport {type Read, type Store} from '../../../replicache/src/dag/store.ts';\nimport {readFromHash} from '../../../replicache/src/db/read.ts';\nimport * as FormatVersion from '../../../replicache/src/format-version-enum.ts';\nimport type {Hash} from '../../../replicache/src/hash.ts';\nimport type {ZeroReadOptions} from '../../../replicache/src/replicache-options.ts';\nimport {diffBinarySearch} from '../../../replicache/src/subscriptions.ts';\nimport type {DiffsMap} from '../../../replicache/src/sync/diff.ts';\nimport {diff} from '../../../replicache/src/sync/diff.ts';\nimport {using, withRead} from '../../../replicache/src/with-transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport {wrapIterable} from '../../../shared/src/iterables.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport {MemorySource} from '../../../zql/src/ivm/memory-source.ts';\nimport {ENTITIES_KEY_PREFIX, sourceNameFromKey} from './keys.ts';\n\n/**\n * Replicache needs to rebase mutations onto different\n * commits of it's b-tree. These mutations can have reads\n * in them and those reads must be run against the IVM sources.\n *\n * To ensure the reads get the correct state, the IVM\n * sources need to reflect the state of the commit\n * being rebased onto. `IVMSourceBranch` allows us to:\n * 1. fork the IVM sources\n * 2. patch them up to match the desired head\n * 3. run the reads against the forked sources\n *\n * (2) is expected to be a cheap operation as there should only\n * ever be a few outstanding diffs to apply given Zero is meant\n * to be run in a connected state.\n */\nexport class IVMSourceBranch {\n readonly #sources: Map<string, MemorySource | undefined>;\n readonly #tables: Record<string, TableSchema>;\n hash: Hash | undefined;\n\n constructor(\n tables: Record<string, TableSchema>,\n hash?: Hash,\n sources: Map<string, MemorySource | undefined> = new Map(),\n ) {\n this.#tables = tables;\n this.#sources = sources;\n this.hash = hash;\n }\n\n getSource(name: string): MemorySource | undefined {\n if (this.#sources.has(name)) {\n return this.#sources.get(name);\n }\n\n const schema = this.#tables[name];\n const source = schema\n ? new MemorySource(name, schema.columns, schema.primaryKey)\n : undefined;\n this.#sources.set(name, source);\n return source;\n }\n\n clear() {\n this.#sources.clear();\n }\n\n /**\n * Mutates the current branch, advancing it to the new head\n * by applying the given diffs.\n */\n advance(expectedHead: Hash | undefined, newHead: Hash, diffs: NoIndexDiff) {\n assert(\n this.hash === expectedHead,\n () =>\n `Expected head must match the main head. Got: ${this.hash}, expected: ${expectedHead}`,\n );\n\n applyDiffs(diffs, this);\n this.hash = newHead;\n }\n\n /**\n * Fork the branch and patch it up to match the desired head.\n */\n async forkToHead(\n store: LazyStore,\n desiredHead: Hash,\n readOptions?: ZeroReadOptions,\n ): Promise<IVMSourceBranch> {\n const fork = this.fork();\n\n if (fork.hash === desiredHead) {\n return fork;\n }\n\n await patchBranch(desiredHead, store, fork, readOptions);\n fork.hash = desiredHead;\n return fork;\n }\n\n /**\n * Creates a new IVMSourceBranch that is a copy of the current one.\n * This is a cheap operation since the b-trees are shared until a write is performed\n * and then only the modified nodes are copied.\n *\n * IVM branches are forked when we need to rebase mutations.\n * The mutations modify the fork rather than original branch.\n */\n fork() {\n return new IVMSourceBranch(\n this.#tables,\n this.hash,\n new Map(\n wrapIterable(this.#sources.entries()).map(([name, source]) => [\n name,\n source?.fork(),\n ]),\n ),\n );\n }\n}\n\nexport async function initFromStore(\n branch: IVMSourceBranch,\n hash: Hash,\n store: Store,\n) {\n const diffs: InternalDiffOperation[] = [];\n await withRead(store, async dagRead => {\n const read = await readFromHash(hash, dagRead, FormatVersion.Latest);\n for await (const entry of read.map.scan(ENTITIES_KEY_PREFIX)) {\n if (!entry[0].startsWith(ENTITIES_KEY_PREFIX)) {\n break;\n }\n diffs.push({\n op: 'add',\n key: entry[0],\n newValue: entry[1],\n });\n }\n });\n\n branch.advance(undefined, hash, diffs);\n}\n\nasync function patchBranch(\n desiredHead: Hash,\n store: LazyStore,\n fork: IVMSourceBranch,\n readOptions: ZeroReadOptions | undefined,\n) {\n const diffs = await computeDiffs(\n must(fork.hash),\n desiredHead,\n store,\n readOptions,\n );\n if (!diffs) {\n return;\n }\n applyDiffs(diffs, fork);\n}\n\nasync function computeDiffs(\n startHash: Hash,\n endHash: Hash,\n store: LazyStore,\n readOptions: ZeroReadOptions | undefined,\n): Promise<InternalDiff | undefined> {\n const readFn = (dagRead: Read) =>\n diff(\n startHash,\n endHash,\n dagRead,\n {\n shouldComputeDiffs: () => true,\n shouldComputeDiffsForIndex(_name) {\n return false;\n },\n },\n FormatVersion.Latest,\n );\n\n let diffs: DiffsMap;\n if (readOptions?.openLazySourceRead) {\n diffs = await using(store.read(readOptions.openLazySourceRead), readFn);\n } else if (readOptions?.openLazyRead) {\n diffs = await readFn(readOptions.openLazyRead);\n } else {\n diffs = await withRead(store, readFn);\n }\n\n return diffs.get('');\n}\n\nfunction applyDiffs(diffs: NoIndexDiff, branch: IVMSourceBranch) {\n for (\n let i = diffBinarySearch(diffs, ENTITIES_KEY_PREFIX, diff => diff.key);\n i < diffs.length;\n i++\n ) {\n const diff = diffs[i];\n const {key} = diff;\n if (!key.startsWith(ENTITIES_KEY_PREFIX)) {\n break;\n }\n const name = sourceNameFromKey(key);\n const source = must(branch.getSource(name));\n switch (diff.op) {\n case 'del':\n source.push({\n type: 'remove',\n row: diff.oldValue as Row,\n });\n break;\n case 'add':\n source.push({\n type: 'add',\n row: diff.newValue as Row,\n });\n break;\n case 'change':\n source.push({\n type: 'edit',\n row: diff.newValue as Row,\n oldRow: diff.oldValue as Row,\n });\n break;\n }\n }\n}\n"],"names":["FormatVersion.Latest","diff"],"mappings":";;;;;;;;;;;;AAuCO,MAAM,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,EACT;AAAA,EAEA,YACE,QACA,MACA,UAAiD,oBAAI,OACrD;AACA,SAAK,UAAU;AACf,SA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AK;AAAA,QAAA,CACd;AACD;AAAA,IAAA;AAAA,EAEN;AACF;"}
1
+ {"version":3,"file":"ivm-branch.js","sources":["../../../../../zero-client/src/client/ivm-branch.ts"],"sourcesContent":["import type {\n InternalDiff,\n InternalDiffOperation,\n NoIndexDiff,\n} from '../../../replicache/src/btree/node.ts';\nimport type {LazyStore} from '../../../replicache/src/dag/lazy-store.ts';\nimport {type Read, type Store} from '../../../replicache/src/dag/store.ts';\nimport {readFromHash} from '../../../replicache/src/db/read.ts';\nimport * as FormatVersion from '../../../replicache/src/format-version-enum.ts';\nimport type {Hash} from '../../../replicache/src/hash.ts';\nimport type {ZeroReadOptions} from '../../../replicache/src/replicache-options.ts';\nimport {diffBinarySearch} from '../../../replicache/src/subscriptions.ts';\nimport type {DiffsMap} from '../../../replicache/src/sync/diff.ts';\nimport {diff} from '../../../replicache/src/sync/diff.ts';\nimport {using, withRead} from '../../../replicache/src/with-transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport {wrapIterable} from '../../../shared/src/iterables.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport {MemorySource} from '../../../zql/src/ivm/memory-source.ts';\nimport {consume} from '../../../zql/src/ivm/stream.ts';\nimport {ENTITIES_KEY_PREFIX, sourceNameFromKey} from './keys.ts';\n\n/**\n * Replicache needs to rebase mutations onto different\n * commits of it's b-tree. These mutations can have reads\n * in them and those reads must be run against the IVM sources.\n *\n * To ensure the reads get the correct state, the IVM\n * sources need to reflect the state of the commit\n * being rebased onto. `IVMSourceBranch` allows us to:\n * 1. fork the IVM sources\n * 2. patch them up to match the desired head\n * 3. run the reads against the forked sources\n *\n * (2) is expected to be a cheap operation as there should only\n * ever be a few outstanding diffs to apply given Zero is meant\n * to be run in a connected state.\n */\nexport class IVMSourceBranch {\n readonly #sources: Map<string, MemorySource | undefined>;\n readonly #tables: Record<string, TableSchema>;\n hash: Hash | undefined;\n\n constructor(\n tables: Record<string, TableSchema>,\n hash?: Hash,\n sources: Map<string, MemorySource | undefined> = new Map(),\n ) {\n this.#tables = tables;\n this.#sources = sources;\n this.hash = hash;\n }\n\n getSource(name: string): MemorySource | undefined {\n if (this.#sources.has(name)) {\n return this.#sources.get(name);\n }\n\n const schema = this.#tables[name];\n const source = schema\n ? new MemorySource(name, schema.columns, schema.primaryKey)\n : undefined;\n this.#sources.set(name, source);\n return source;\n }\n\n clear() {\n this.#sources.clear();\n }\n\n /**\n * Mutates the current branch, advancing it to the new head\n * by applying the given diffs.\n */\n advance(expectedHead: Hash | undefined, newHead: Hash, diffs: NoIndexDiff) {\n assert(\n this.hash === expectedHead,\n () =>\n `Expected head must match the main head. Got: ${this.hash}, expected: ${expectedHead}`,\n );\n\n applyDiffs(diffs, this);\n this.hash = newHead;\n }\n\n /**\n * Fork the branch and patch it up to match the desired head.\n */\n async forkToHead(\n store: LazyStore,\n desiredHead: Hash,\n readOptions?: ZeroReadOptions,\n ): Promise<IVMSourceBranch> {\n const fork = this.fork();\n\n if (fork.hash === desiredHead) {\n return fork;\n }\n\n await patchBranch(desiredHead, store, fork, readOptions);\n fork.hash = desiredHead;\n return fork;\n }\n\n /**\n * Creates a new IVMSourceBranch that is a copy of the current one.\n * This is a cheap operation since the b-trees are shared until a write is performed\n * and then only the modified nodes are copied.\n *\n * IVM branches are forked when we need to rebase mutations.\n * The mutations modify the fork rather than original branch.\n */\n fork() {\n return new IVMSourceBranch(\n this.#tables,\n this.hash,\n new Map(\n wrapIterable(this.#sources.entries()).map(([name, source]) => [\n name,\n source?.fork(),\n ]),\n ),\n );\n }\n}\n\nexport async function initFromStore(\n branch: IVMSourceBranch,\n hash: Hash,\n store: Store,\n) {\n const diffs: InternalDiffOperation[] = [];\n await withRead(store, async dagRead => {\n const read = await readFromHash(hash, dagRead, FormatVersion.Latest);\n for await (const entry of read.map.scan(ENTITIES_KEY_PREFIX)) {\n if (!entry[0].startsWith(ENTITIES_KEY_PREFIX)) {\n break;\n }\n diffs.push({\n op: 'add',\n key: entry[0],\n newValue: entry[1],\n });\n }\n });\n\n branch.advance(undefined, hash, diffs);\n}\n\nasync function patchBranch(\n desiredHead: Hash,\n store: LazyStore,\n fork: IVMSourceBranch,\n readOptions: ZeroReadOptions | undefined,\n) {\n const diffs = await computeDiffs(\n must(fork.hash),\n desiredHead,\n store,\n readOptions,\n );\n if (!diffs) {\n return;\n }\n applyDiffs(diffs, fork);\n}\n\nasync function computeDiffs(\n startHash: Hash,\n endHash: Hash,\n store: LazyStore,\n readOptions: ZeroReadOptions | undefined,\n): Promise<InternalDiff | undefined> {\n const readFn = (dagRead: Read) =>\n diff(\n startHash,\n endHash,\n dagRead,\n {\n shouldComputeDiffs: () => true,\n shouldComputeDiffsForIndex(_name) {\n return false;\n },\n },\n FormatVersion.Latest,\n );\n\n let diffs: DiffsMap;\n if (readOptions?.openLazySourceRead) {\n diffs = await using(store.read(readOptions.openLazySourceRead), readFn);\n } else if (readOptions?.openLazyRead) {\n diffs = await readFn(readOptions.openLazyRead);\n } else {\n diffs = await withRead(store, readFn);\n }\n\n return diffs.get('');\n}\n\nfunction applyDiffs(diffs: NoIndexDiff, branch: IVMSourceBranch) {\n for (\n let i = diffBinarySearch(diffs, ENTITIES_KEY_PREFIX, diff => diff.key);\n i < diffs.length;\n i++\n ) {\n const diff = diffs[i];\n const {key} = diff;\n if (!key.startsWith(ENTITIES_KEY_PREFIX)) {\n break;\n }\n const name = sourceNameFromKey(key);\n const source = must(branch.getSource(name));\n switch (diff.op) {\n case 'del':\n consume(\n source.push({\n type: 'remove',\n row: diff.oldValue as Row,\n }),\n );\n break;\n case 'add':\n consume(\n source.push({\n type: 'add',\n row: diff.newValue as Row,\n }),\n );\n break;\n case 'change':\n consume(\n source.push({\n type: 'edit',\n row: diff.newValue as Row,\n oldRow: diff.oldValue as Row,\n }),\n );\n break;\n }\n }\n}\n"],"names":["FormatVersion.Latest","diff"],"mappings":";;;;;;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OAAO,KAAK;AAAA,YACV,MAAM;AAAA,YACN,KAAKA,MAAK;AAAA,UAAA,CACX;AAAA,QAAA;AAEH;AAAA,MACF,KAAK;AACH;AAAA,UACE,OAAO,KAAK;AAAA,YACV,MAAM;AAAA,YACN,KAAKA,MAAK;AAAA,YACV,QAAQA,MAAK;AAAA,UAAA,CACd;AAAA,QAAA;AAEH;AAAA,IAAA;AAAA,EAEN;AACF;"}
@@ -35,6 +35,6 @@ export declare function makeMutateProperty(mutators: CustomMutatorDefs, mutatorP
35
35
  type MakeFromMutatorDefinitions<S extends Schema, MD extends CustomMutatorDefs, C> = {
36
36
  readonly [K in keyof MD]: MD[K] extends (tx: Transaction<S>, ...args: infer Args) => Promise<void> ? (...args: Args) => MutatorResult : MD[K] extends CustomMutatorDefs ? MakeFromMutatorDefinitions<S, MD[K], C> : never;
37
37
  };
38
- export type MakeMutatePropertyType<S extends Schema, MD extends CustomMutatorDefs | undefined, C> = MD extends CustomMutatorDefs ? S['enableLegacyMutators'] extends false ? MakeFromMutatorDefinitions<S, MD, C> : DeepMerge<DBMutator<S>, MakeFromMutatorDefinitions<S, MD, C>> : DBMutator<S>;
38
+ export type MakeMutatePropertyType<S extends Schema, MD extends CustomMutatorDefs | undefined, C> = MD extends CustomMutatorDefs ? S['enableLegacyMutators'] extends true ? DeepMerge<DBMutator<S>, MakeFromMutatorDefinitions<S, MD, C>> : MakeFromMutatorDefinitions<S, MD, C> : DBMutator<S>;
39
39
  export {};
40
40
  //# sourceMappingURL=make-mutate-property.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"make-mutate-property.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/make-mutate-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAEjE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,mCAAmC,CAAC;AAC3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,GAC/D,SAAS,CAAC,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"make-mutate-property.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/make-mutate-property.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,mCAAmC,CAAC;AAEjE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,iBAAiB,EAC3B,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACxC,IAAI,CAkCN;AAED;;;GAGG;AACH,KAAK,0BAA0B,CAC7B,CAAC,SAAS,MAAM,EAChB,EAAE,SAAS,iBAAiB,EAC5B,CAAC,IACC;IACF,QAAQ,EAAE,CAAC,IAAI,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,SAAS,CACtC,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC,EAClB,GAAG,IAAI,EAAE,MAAM,IAAI,KAChB,OAAO,CAAC,IAAI,CAAC,GACd,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,aAAa,GAChC,EAAE,CAAC,CAAC,CAAC,SAAS,iBAAiB,GAC7B,0BAA0B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GACvC,KAAK;CACZ,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAChC,CAAC,SAAS,MAAM,EAChB,EAAE,SAAS,iBAAiB,GAAG,SAAS,EACxC,CAAC,IACC,EAAE,SAAS,iBAAiB,GAC5B,CAAC,CAAC,sBAAsB,CAAC,SAAS,IAAI,GACpC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,GAC7D,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GACtC,SAAS,CAAC,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"make-mutate-property.js","sources":["../../../../../zero-client/src/client/make-mutate-property.ts"],"sourcesContent":["import type {DeepMerge} from '../../../shared/src/deep-merge.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {\n customMutatorKey,\n type Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport type {DBMutator} from './crud.ts';\nimport type {CustomMutatorDefs, MutatorResult} from './custom.ts';\nimport type {MutatorProxy} from './mutator-proxy.ts';\n\n/**\n * Creates and populates a mutate property object by processing mutator definitions recursively.\n *\n * This function traverses through mutator definitions (either schema-based or custom) and builds\n * a corresponding object structure where each mutator is wrapped by the mutator proxy. It handles\n * both flat mutator functions and nested mutator definition objects.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The context type used by mutators, defaults to unknown\n *\n * @param mutators - The mutator definitions to process, can be schema-based or custom mutator definitions\n * @param mutatorProxy - The proxy object responsible for wrapping mutators with additional functionality\n * @param mutateObject - The target object to populate with wrapped mutators\n * @param replicacheMutate - The source object containing the actual mutator implementations to wrap\n *\n * @returns void - This function mutates the mutateObject parameter directly\n *\n * @remarks\n * The function recursively processes nested mutator structures, creating corresponding nested objects\n * in the mutateObject. For leaf mutators (functions or mutator definitions), it generates a full key\n * using different separators ('.' for mutator definitions, '|' for custom functions) and wraps them\n * using the mutator proxy.\n */\nexport function makeMutateProperty(\n mutators: CustomMutatorDefs,\n mutatorProxy: MutatorProxy,\n mutateObject: Record<string, unknown>,\n replicacheMutate: Record<string, unknown>,\n): void {\n const processMutators = (\n mutators: CustomMutatorDefs,\n path: string[],\n mutateObject: Record<string, unknown>,\n ) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n path.push(key);\n if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[key] = mutatorProxy.wrapCustomMutator(\n fullKey,\n must(replicacheMutate[fullKey]) as unknown as (\n ...args: unknown[]\n ) => MutatorResult,\n );\n } else {\n // Nested namespace - recursive build and process.\n let existing = mutateObject[key];\n if (existing === undefined) {\n existing = {};\n mutateObject[key] = existing;\n }\n processMutators(\n mutator as CustomMutatorDefs,\n path,\n existing as Record<string, unknown>,\n );\n }\n path.pop();\n }\n };\n\n processMutators(mutators, [], mutateObject);\n}\n\n/**\n * Builds the mutate type from legacy CustomMutatorDefs, handling arbitrary nesting.\n * Each node can be either a CustomMutatorImpl function or a namespace containing more mutators.\n */\ntype MakeFromMutatorDefinitions<\n S extends Schema,\n MD extends CustomMutatorDefs,\n C,\n> = {\n readonly [K in keyof MD]: MD[K] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[K] extends CustomMutatorDefs\n ? MakeFromMutatorDefinitions<S, MD[K], C>\n : never;\n};\n\nexport type MakeMutatePropertyType<\n S extends Schema,\n MD extends CustomMutatorDefs | undefined,\n C,\n> = MD extends CustomMutatorDefs\n ? S['enableLegacyMutators'] extends false\n ? MakeFromMutatorDefinitions<S, MD, C>\n : DeepMerge<DBMutator<S>, MakeFromMutatorDefinitions<S, MD, C>>\n : DBMutator<S>;\n"],"names":["mutators","mutateObject"],"mappings":";;AAkCO,SAAS,mBACd,UACA,cACA,cACA,kBACM;AACN,QAAM,kBAAkB,CACtBA,WACA,MACAC,kBACG;AACH,eAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQD,SAAQ,GAAG;AACrD,WAAK,KAAK,GAAG;AACb,UAAI,OAAO,YAAY,YAAY;AACjC,cAAM,UAAU,iBAAiB,KAAK,IAAI;AAC1CC,sBAAa,GAAG,IAAI,aAAa;AAAA,UAC/B;AAAA,UACA,KAAK,iBAAiB,OAAO,CAAC;AAAA,QAAA;AAAA,MAIlC,OAAO;AAEL,YAAI,WAAWA,cAAa,GAAG;AAC/B,YAAI,aAAa,QAAW;AAC1B,qBAAW,CAAA;AACXA,wBAAa,GAAG,IAAI;AAAA,QACtB;AACA;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AACA,WAAK,IAAA;AAAA,IACP;AAAA,EACF;AAEA,kBAAgB,UAAU,CAAA,GAAI,YAAY;AAC5C;"}
1
+ {"version":3,"file":"make-mutate-property.js","sources":["../../../../../zero-client/src/client/make-mutate-property.ts"],"sourcesContent":["import type {DeepMerge} from '../../../shared/src/deep-merge.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {\n customMutatorKey,\n type Transaction,\n} from '../../../zql/src/mutate/custom.ts';\nimport type {DBMutator} from './crud.ts';\nimport type {CustomMutatorDefs, MutatorResult} from './custom.ts';\nimport type {MutatorProxy} from './mutator-proxy.ts';\n\n/**\n * Creates and populates a mutate property object by processing mutator definitions recursively.\n *\n * This function traverses through mutator definitions (either schema-based or custom) and builds\n * a corresponding object structure where each mutator is wrapped by the mutator proxy. It handles\n * both flat mutator functions and nested mutator definition objects.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The context type used by mutators, defaults to unknown\n *\n * @param mutators - The mutator definitions to process, can be schema-based or custom mutator definitions\n * @param mutatorProxy - The proxy object responsible for wrapping mutators with additional functionality\n * @param mutateObject - The target object to populate with wrapped mutators\n * @param replicacheMutate - The source object containing the actual mutator implementations to wrap\n *\n * @returns void - This function mutates the mutateObject parameter directly\n *\n * @remarks\n * The function recursively processes nested mutator structures, creating corresponding nested objects\n * in the mutateObject. For leaf mutators (functions or mutator definitions), it generates a full key\n * using different separators ('.' for mutator definitions, '|' for custom functions) and wraps them\n * using the mutator proxy.\n */\nexport function makeMutateProperty(\n mutators: CustomMutatorDefs,\n mutatorProxy: MutatorProxy,\n mutateObject: Record<string, unknown>,\n replicacheMutate: Record<string, unknown>,\n): void {\n const processMutators = (\n mutators: CustomMutatorDefs,\n path: string[],\n mutateObject: Record<string, unknown>,\n ) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n path.push(key);\n if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[key] = mutatorProxy.wrapCustomMutator(\n fullKey,\n must(replicacheMutate[fullKey]) as unknown as (\n ...args: unknown[]\n ) => MutatorResult,\n );\n } else {\n // Nested namespace - recursive build and process.\n let existing = mutateObject[key];\n if (existing === undefined) {\n existing = {};\n mutateObject[key] = existing;\n }\n processMutators(\n mutator as CustomMutatorDefs,\n path,\n existing as Record<string, unknown>,\n );\n }\n path.pop();\n }\n };\n\n processMutators(mutators, [], mutateObject);\n}\n\n/**\n * Builds the mutate type from legacy CustomMutatorDefs, handling arbitrary nesting.\n * Each node can be either a CustomMutatorImpl function or a namespace containing more mutators.\n */\ntype MakeFromMutatorDefinitions<\n S extends Schema,\n MD extends CustomMutatorDefs,\n C,\n> = {\n readonly [K in keyof MD]: MD[K] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[K] extends CustomMutatorDefs\n ? MakeFromMutatorDefinitions<S, MD[K], C>\n : never;\n};\n\nexport type MakeMutatePropertyType<\n S extends Schema,\n MD extends CustomMutatorDefs | undefined,\n C,\n> = MD extends CustomMutatorDefs\n ? S['enableLegacyMutators'] extends true\n ? DeepMerge<DBMutator<S>, MakeFromMutatorDefinitions<S, MD, C>>\n : MakeFromMutatorDefinitions<S, MD, C>\n : DBMutator<S>;\n"],"names":["mutators","mutateObject"],"mappings":";;AAkCO,SAAS,mBACd,UACA,cACA,cACA,kBACM;AACN,QAAM,kBAAkB,CACtBA,WACA,MACAC,kBACG;AACH,eAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQD,SAAQ,GAAG;AACrD,WAAK,KAAK,GAAG;AACb,UAAI,OAAO,YAAY,YAAY;AACjC,cAAM,UAAU,iBAAiB,KAAK,IAAI;AAC1CC,sBAAa,GAAG,IAAI,aAAa;AAAA,UAC/B;AAAA,UACA,KAAK,iBAAiB,OAAO,CAAC;AAAA,QAAA;AAAA,MAIlC,OAAO;AAEL,YAAI,WAAWA,cAAa,GAAG;AAC/B,YAAI,aAAa,QAAW;AAC1B,qBAAW,CAAA;AACXA,wBAAa,GAAG,IAAI;AAAA,QACtB;AACA;AAAA,UACE;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ;AACA,WAAK,IAAA;AAAA,IACP;AAAA,EACF;AAEA,kBAAgB,UAAU,CAAA,GAAI,YAAY;AAC5C;"}
@@ -1 +1 @@
1
- {"version":3,"file":"make-replicache-mutators.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAGlE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAkB,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAQtE,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC1D,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,kBAAkB,GAAG,iBAAiB,EAChD,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,IAAI,CA8BN;AA2BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC9D,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,EAC5D,OAAO,EAAE,CAAC,EACV,EAAE,EAAE,UAAU,GACb,WAAW,GAAG;IAAC,UAAU,EAAE,WAAW,CAAA;CAAC,CAoCzC"}
1
+ {"version":3,"file":"make-replicache-mutators.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAGlE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAkB,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAQtE,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC1D,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,kBAAkB,GAAG,iBAAiB,EAChD,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,IAAI,CAmCN;AA2BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC9D,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,EAC5D,OAAO,EAAE,CAAC,EACV,EAAE,EAAE,UAAU,GACb,WAAW,GAAG;IAAC,UAAU,EAAE,WAAW,CAAA;CAAC,CAsCzC"}
@@ -8,6 +8,9 @@ import { ClientError } from "./error.js";
8
8
  function extendReplicacheMutators(lc, context, mutators, schema, mutateObject) {
9
9
  const processMutators = (mutators2, path) => {
10
10
  for (const [key, mutator] of Object.entries(mutators2)) {
11
+ if (key === "~") {
12
+ continue;
13
+ }
11
14
  path.push(key);
12
15
  if (isMutator(mutator)) {
13
16
  const fullKey = customMutatorKey(".", path);
@@ -26,7 +29,7 @@ function extendReplicacheMutators(lc, context, mutators, schema, mutateObject) {
26
29
  schema,
27
30
  context
28
31
  );
29
- } else {
32
+ } else if (mutator !== null && typeof mutator === "object") {
30
33
  processMutators(mutator, path);
31
34
  }
32
35
  path.pop();
@@ -45,13 +48,17 @@ function makeReplicacheMutator(lc, mutator, schema, context) {
45
48
  };
46
49
  }
47
50
  function makeReplicacheMutators(schema, mutators, context, lc) {
48
- const { enableLegacyMutators = true } = schema;
51
+ const { enableLegacyMutators = false } = schema;
49
52
  const replicacheMutators = {
50
- [CRUD_MUTATION_NAME]: enableLegacyMutators ? makeCRUDMutator(schema) : () => Promise.reject(
51
- new ClientError({
52
- kind: Internal,
53
- message: "Zero CRUD mutators are not enabled."
54
- })
53
+ [CRUD_MUTATION_NAME]: enableLegacyMutators ? makeCRUDMutator(schema) : (
54
+ // TODO(arv): This code is unreachable since the public API prevents
55
+ // calling CRUD mutators when enableLegacyMutators is false. Remove this.
56
+ (() => Promise.reject(
57
+ new ClientError({
58
+ kind: Internal,
59
+ message: "Zero CRUD mutators are not enabled."
60
+ })
61
+ ))
55
62
  )
56
63
  };
57
64
  if (mutators) {
@@ -1 +1 @@
1
- {"version":3,"file":"make-replicache-mutators.js","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {MutatorDefs} from '../../../replicache/src/types.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {CRUD_MUTATION_NAME} from '../../../zero-protocol/src/push.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {customMutatorKey} from '../../../zql/src/mutate/custom.ts';\nimport {\n isMutatorRegistry,\n type AnyMutatorRegistry,\n} from '../../../zql/src/mutate/mutator-registry.ts';\nimport {type Mutator} from '../../../zql/src/mutate/mutator.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport {makeCRUDMutator, type CRUDMutator} from './crud.ts';\nimport type {CustomMutatorDefs, CustomMutatorImpl} from './custom.ts';\nimport {\n makeReplicacheMutator as makeReplicacheMutatorLegacy,\n TransactionImpl,\n} from './custom.ts';\nimport {ClientError} from './error.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\nexport function extendReplicacheMutators<S extends Schema, C>(\n lc: LogContext,\n context: C,\n mutators: AnyMutatorRegistry | CustomMutatorDefs,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n // Recursively process mutator definitions at arbitrary depth\n const processMutators = (mutators: object, path: string[]) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n path.push(key);\n if (isMutator(mutator)) {\n const fullKey = customMutatorKey('.', path);\n mutateObject[fullKey] = makeReplicacheMutator(\n lc,\n mutator,\n schema,\n context,\n );\n } else if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[fullKey] = makeReplicacheMutatorLegacy(\n lc,\n // oxlint-disable-next-line no-explicit-any\n mutator as CustomMutatorImpl<any>,\n schema,\n context,\n );\n } else {\n processMutators(mutator, path);\n }\n path.pop();\n }\n };\n\n processMutators(mutators, []);\n}\n\nfunction makeReplicacheMutator<\n TArgs extends ReadonlyJSONValue | undefined,\n TSchema extends Schema,\n TContext,\n TWrappedTransaction,\n>(\n lc: LogContext,\n mutator: Mutator<TArgs, TSchema, TContext, TWrappedTransaction>,\n schema: TSchema,\n context: TContext,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n // fn does input validation internally\n await mutator.fn({\n args: args as TArgs,\n ctx: context,\n tx: tx,\n });\n };\n}\n\n/**\n * Creates Replicache mutators from mutator definitions.\n *\n * This function processes mutator definitions at arbitrary depth, supporting both\n * new-style mutator definitions and legacy custom mutator implementations. It creates\n * a mutator object with the CRUD mutator and any provided custom mutators, with keys\n * generated based on their path in the mutator definition hierarchy.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The type of the context object passed to mutators\n *\n * @param schema - The schema instance used for validation and type checking\n * @param mutators - The mutator definitions to process, can be nested objects or custom mutator definitions\n * @param context - The context to be passed to mutators\n * @param lc - The log context used for logging operations\n *\n * @returns A mutator definitions object containing the CRUD mutator and any custom mutators\n *\n * @remarks\n * - New-style mutator definitions use '.' as a separator in their keys\n * - Legacy custom mutator implementations use '|' as a separator in their keys\n * - The CRUD mutator can be disabled by setting `enableLegacyMutators: false` in the schema\n */\nexport function makeReplicacheMutators<const S extends Schema, C>(\n schema: S,\n mutators: AnyMutatorRegistry | CustomMutatorDefs | undefined,\n context: C,\n lc: LogContext,\n): MutatorDefs & {_zero_crud: CRUDMutator} {\n const {enableLegacyMutators = true} = schema;\n\n const replicacheMutators = {\n [CRUD_MUTATION_NAME]: enableLegacyMutators\n ? makeCRUDMutator(schema)\n : () =>\n Promise.reject(\n new ClientError({\n kind: ClientErrorKind.Internal,\n message: 'Zero CRUD mutators are not enabled.',\n }),\n ),\n };\n\n if (mutators) {\n if (isMutatorRegistry(mutators)) {\n extendFromMutatorRegistry(\n lc,\n context,\n mutators,\n schema,\n replicacheMutators,\n );\n } else {\n extendReplicacheMutators(\n lc,\n context,\n mutators as CustomMutatorDefs,\n schema,\n replicacheMutators,\n );\n }\n }\n\n return replicacheMutators;\n}\n\n/**\n * Checks if a value is a Mutator (from MutatorRegistry).\n * Mutators have `mutatorName` and `fn` properties.\n */\nfunction isMutator(\n value: unknown,\n // oxlint-disable-next-line no-explicit-any\n): value is Mutator<any, any, any> {\n return (\n typeof value === 'function' &&\n 'mutatorName' in value &&\n typeof value.mutatorName === 'string' &&\n 'fn' in value &&\n typeof value.fn === 'function'\n );\n}\n\n/**\n * Extends replicache mutators from a MutatorRegistry.\n * Walks the registry tree and wraps each Mutator.fn for Replicache.\n */\nfunction extendFromMutatorRegistry<S extends Schema, C>(\n lc: LogContext,\n context: C,\n registry: AnyMutatorRegistry,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n const walk = (node: unknown) => {\n if (typeof node !== 'object' || node === null) {\n return;\n }\n for (const value of Object.values(node)) {\n if (isMutator(value)) {\n // Mutator.fn already handles validation internally\n mutateObject[value.mutatorName] = (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n return value.fn({args, ctx: context, tx});\n };\n } else if (typeof value === 'object' && value !== null) {\n // Nested namespace\n walk(value);\n }\n }\n };\n walk(registry);\n}\n"],"names":["mutators","makeReplicacheMutatorLegacy","ClientErrorKind.Internal"],"mappings":";;;;;;;AAqBO,SAAS,yBACd,IACA,SACA,UACA,QACA,cACM;AAEN,QAAM,kBAAkB,CAACA,WAAkB,SAAmB;AAC5D,eAAW,CAAC,KAAK,OAAO,KAAK,OAAO,QAAQA,SAAQ,GAAG;AACrD,WAAK,KAAK,GAAG;AACb,UAAI,UAAU,OAAO,GAAG;AACtB,cAAM,UAAU,iBAAiB,KAAK,IAAI;AAC1C,qBAAa,OAAO,IAAI;AAAA,UACtB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAAA,MAEJ,WAAW,OAAO,YAAY,YAAY;AACxC,cAAM,UAAU,iBAAiB,KAAK,IAAI;AAC1C,qBAAa,OAAO,IAAIC;AAAAA,UACtB;AAAA;AAAA,UAEA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;A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W,IAAI,CAChC,OACA,SACkB;AAClB,gBAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,iBAAO,MAAM,GAAG,EAAC,MAAM,KAAK,SAAS,IAAG;AAAA,QAC1C;AAAA,MACF,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AAEtD,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACA,OAAK,QAAQ;AACf;"}
1
+ {"version":3,"file":"make-replicache-mutators.js","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {MutatorDefs} from '../../../replicache/src/types.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {CRUD_MUTATION_NAME} from '../../../zero-protocol/src/push.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {customMutatorKey} from '../../../zql/src/mutate/custom.ts';\nimport {\n isMutatorRegistry,\n type AnyMutatorRegistry,\n} from '../../../zql/src/mutate/mutator-registry.ts';\nimport {type Mutator} from '../../../zql/src/mutate/mutator.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport {makeCRUDMutator, type CRUDMutator} from './crud.ts';\nimport type {CustomMutatorDefs, CustomMutatorImpl} from './custom.ts';\nimport {\n makeReplicacheMutator as makeReplicacheMutatorLegacy,\n TransactionImpl,\n} from './custom.ts';\nimport {ClientError} from './error.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\nexport function extendReplicacheMutators<S extends Schema, C>(\n lc: LogContext,\n context: C,\n mutators: AnyMutatorRegistry | CustomMutatorDefs,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n // Recursively process mutator definitions at arbitrary depth\n const processMutators = (mutators: object, path: string[]) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n if (key === '~') {\n // Skip phantom type\n continue;\n }\n\n path.push(key);\n if (isMutator(mutator)) {\n const fullKey = customMutatorKey('.', path);\n mutateObject[fullKey] = makeReplicacheMutator(\n lc,\n mutator,\n schema,\n context,\n );\n } else if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[fullKey] = makeReplicacheMutatorLegacy(\n lc,\n // oxlint-disable-next-line no-explicit-any\n mutator as CustomMutatorImpl<any>,\n schema,\n context,\n );\n } else if (mutator !== null && typeof mutator === 'object') {\n processMutators(mutator, path);\n }\n path.pop();\n }\n };\n\n processMutators(mutators, []);\n}\n\nfunction makeReplicacheMutator<\n TArgs extends ReadonlyJSONValue | undefined,\n TSchema extends Schema,\n TContext,\n TWrappedTransaction,\n>(\n lc: LogContext,\n mutator: Mutator<TArgs, TSchema, TContext, TWrappedTransaction>,\n schema: TSchema,\n context: TContext,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n // fn does input validation internally\n await mutator.fn({\n args: args as TArgs,\n ctx: context,\n tx: tx,\n });\n };\n}\n\n/**\n * Creates Replicache mutators from mutator definitions.\n *\n * This function processes mutator definitions at arbitrary depth, supporting both\n * new-style mutator definitions and legacy custom mutator implementations. It creates\n * a mutator object with the CRUD mutator and any provided custom mutators, with keys\n * generated based on their path in the mutator definition hierarchy.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The type of the context object passed to mutators\n *\n * @param schema - The schema instance used for validation and type checking\n * @param mutators - The mutator definitions to process, can be nested objects or custom mutator definitions\n * @param context - The context to be passed to mutators\n * @param lc - The log context used for logging operations\n *\n * @returns A mutator definitions object containing the CRUD mutator and any custom mutators\n *\n * @remarks\n * - New-style mutator definitions use '.' as a separator in their keys\n * - Legacy custom mutator implementations use '|' as a separator in their keys\n * - The CRUD mutator can be disabled by setting `enableLegacyMutators: false` in the schema\n */\nexport function makeReplicacheMutators<const S extends Schema, C>(\n schema: S,\n mutators: AnyMutatorRegistry | CustomMutatorDefs | undefined,\n context: C,\n lc: LogContext,\n): MutatorDefs & {_zero_crud: CRUDMutator} {\n const {enableLegacyMutators = false} = schema;\n\n const replicacheMutators = {\n [CRUD_MUTATION_NAME]: enableLegacyMutators\n ? makeCRUDMutator(schema)\n : // TODO(arv): This code is unreachable since the public API prevents\n // calling CRUD mutators when enableLegacyMutators is false. Remove this.\n () =>\n Promise.reject(\n new ClientError({\n kind: ClientErrorKind.Internal,\n message: 'Zero CRUD mutators are not enabled.',\n }),\n ),\n };\n\n if (mutators) {\n if (isMutatorRegistry(mutators)) {\n extendFromMutatorRegistry(\n lc,\n context,\n mutators,\n schema,\n replicacheMutators,\n );\n } else {\n extendReplicacheMutators(\n lc,\n context,\n mutators as CustomMutatorDefs,\n schema,\n replicacheMutators,\n );\n }\n }\n\n return replicacheMutators;\n}\n\n/**\n * Checks if a value is a Mutator (from MutatorRegistry).\n * Mutators have `mutatorName` and `fn` properties.\n */\nfunction isMutator(\n value: unknown,\n // oxlint-disable-next-line no-explicit-any\n): value is Mutator<any, any, any> {\n return (\n typeof value === 'function' &&\n 'mutatorName' in value &&\n typeof value.mutatorName === 'string' &&\n 'fn' in value &&\n typeof value.fn === 'function'\n );\n}\n\n/**\n * Extends replicache mutators from a MutatorRegistry.\n * Walks the registry tree and wraps each Mutator.fn for Replicache.\n */\nfunction extendFromMutatorRegistry<S extends Schema, C>(\n lc: LogContext,\n context: C,\n registry: AnyMutatorRegistry,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n const walk = (node: unknown) => {\n if (typeof node !== 'object' || node === null) {\n return;\n }\n for (const value of Object.values(node)) {\n if (isMutator(value)) {\n // Mutator.fn already handles validation internally\n mutateObject[value.mutatorName] = (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n return value.fn({args, ctx: context, tx});\n };\n } else if (typeof value === 'object' && value !== null) {\n // Nested namespace\n walk(value);\n }\n }\n };\n walk(registry);\n}\n"],"names":["mutators","makeReplicacheMutatorLegac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AAA,EACH;AAGR,MAAI,UAAU;AACZ,QAAI,kBAAkB,QAAQ,GAAG;AAC/B;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ,OAAO;AACL;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEA,SAAO;AACT;AAMA,SAAS,UACP,OAEiC;AACjC,SACE,OAAO,UAAU,cACjB,iBAAiB,SACjB,OAAO,MAAM,gBAAgB,YAC7B,QAAQ,SACR,OAAO,MAAM,OAAO;AAExB;AAMA,SAAS,0BACP,IACA,SACA,UACA,QACA,cACM;AACN,QAAM,OAAO,CAAC,SAAkB;AAC9B,QAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAC7C;AAAA,IACF;AACA,eAAW,SAAS,OAAO,OAAO,IAAI,GAAG;AACvC,UAAI,UAAU,KAAK,GAAG;AAEpB,qBAAa,MAAM,WAAW,IAAI,CAChC,OACA,SACkB;AAClB,gBAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,iBAAO,MAAM,GAAG,EAAC,MAAM,KAAK,SAAS,IAAG;AAAA,QAC1C;AAAA,MACF,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AAEtD,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACA,OAAK,QAAQ;AACf;"}
@@ -1,4 +1,4 @@
1
- const version = "0.25.0-canary.14";
1
+ const version = "0.25.0-canary.17";
2
2
  export {
3
3
  version
4
4
  };
@@ -5,6 +5,7 @@ import type { Puller } from '../../../replicache/src/puller.ts';
5
5
  import type { Pusher } from '../../../replicache/src/pusher.ts';
6
6
  import type { ClientGroupID, ClientID } from '../../../replicache/src/sync/ids.ts';
7
7
  import type { MutatorDefs } from '../../../replicache/src/types.ts';
8
+ import type { ReadonlyJSONValue } from '../../../shared/src/json.ts';
8
9
  import { Subscribable } from '../../../shared/src/subscribable.ts';
9
10
  import { type ClientSchema } from '../../../zero-protocol/src/client-schema.ts';
10
11
  import type { DeleteClientsBody } from '../../../zero-protocol/src/delete-clients.ts';
@@ -13,9 +14,10 @@ import type { NullableVersion } from '../../../zero-protocol/src/version.ts';
13
14
  import type { DefaultContext, DefaultSchema } from '../../../zero-types/src/default-types.ts';
14
15
  import type { Schema } from '../../../zero-types/src/schema.ts';
15
16
  import type { ViewFactory } from '../../../zql/src/ivm/view.ts';
16
- import type { MutationRequest } from '../../../zql/src/mutate/mutator.ts';
17
+ import type { MutateRequest } from '../../../zql/src/mutate/mutator.ts';
17
18
  import type { QueryDelegate } from '../../../zql/src/query/query-delegate.ts';
18
- import { type HumanReadable, type MaterializeOptions, type PreloadOptions, type PullRow, type RunOptions, type ToQuery } from '../../../zql/src/query/query.ts';
19
+ import { type QueryOrQueryRequest } from '../../../zql/src/query/query-registry.ts';
20
+ import { type HumanReadable, type MaterializeOptions, type PreloadOptions, type PullRow, type RunOptions } from '../../../zql/src/query/query.ts';
19
21
  import type { SchemaQuery } from '../../../zql/src/query/schema-query.ts';
20
22
  import type { TypedView } from '../../../zql/src/query/typed-view.ts';
21
23
  import { ActiveClientsManager } from './active-clients-manager.ts';
@@ -114,7 +116,7 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
114
116
  * // Now the data is cached and can be used immediately
115
117
  * ```
116
118
  */
117
- preload<TTable extends keyof S['tables'] & string, TReturn extends PullRow<TTable, S>>(query: ToQuery<TTable, S, TReturn, C>, options?: PreloadOptions): {
119
+ preload<TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn extends PullRow<TTable, S>>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, options?: PreloadOptions): {
118
120
  cleanup: () => void;
119
121
  complete: Promise<void>;
120
122
  };
@@ -138,7 +140,7 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
138
140
  * const cachedUsers = await zero.run(userQuery, {type: 'unknown'});
139
141
  * ```
140
142
  */
141
- run<TTable extends keyof S['tables'] & string, TReturn>(query: ToQuery<TTable, S, TReturn, C>, runOptions?: RunOptions): Promise<HumanReadable<TReturn>>;
143
+ run<TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, runOptions?: RunOptions): Promise<HumanReadable<TReturn>>;
142
144
  get context(): C;
143
145
  /**
144
146
  * Creates a materialized view of a query that stays synchronized with the database.
@@ -164,8 +166,8 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
164
166
  * const customView = zero.materialize(userQuery, (query) => new MyCustomView(query));
165
167
  * ```
166
168
  */
167
- materialize<TTable extends keyof S['tables'] & string, TReturn>(query: ToQuery<TTable, S, TReturn, C>, options?: MaterializeOptions): TypedView<HumanReadable<TReturn>>;
168
- materialize<T, TTable extends keyof S['tables'] & string, TReturn>(query: ToQuery<TTable, S, TReturn, C>, factory: ViewFactory<TTable, S, TReturn, T>, options?: MaterializeOptions): T;
169
+ materialize<TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, options?: MaterializeOptions): TypedView<HumanReadable<TReturn>>;
170
+ materialize<T, TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, factory: ViewFactory<TTable, S, TReturn, T>, options?: MaterializeOptions): T;
169
171
  /**
170
172
  * The server URL that this Zero instance is configured with.
171
173
  */
@@ -223,7 +225,7 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
223
225
  * await zero.mutate.issue.update({id: '1', title: 'Updated title'});
224
226
  * ```
225
227
  */
226
- readonly mutate: MakeMutatePropertyType<S, MD, C> & ((mr: MutationRequest<any, S, C, any>) => MutatorResult);
228
+ readonly mutate: MakeMutatePropertyType<S, MD, C> & ((mr: MutateRequest<any, S, C, any>) => MutatorResult);
227
229
  /**
228
230
  * Provides a way to batch multiple CRUD mutations together:
229
231
  *
@@ -1 +1 @@
1
- {"version":3,"file":"zero.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/zero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,KAAK,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,cAAc,EAEf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAE5E,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACT,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,kCAAkC,CAAC;AAc1C,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AAGjE,OAAO,EAAC,KAAK,YAAY,EAAC,MAAM,6CAA6C,CAAC;AAG9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,8CAA8C,CAAC;AA6BpF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,6CAA6C,CAAC;AAElF,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,uCAAuC,CAAC;AAO3E,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAC9D,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAK9D,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAO5C,OAA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,EAAE,MAAM,GAAG,SAAS,EAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3D,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,EACjE,eAAe,SAAW,GACzB,OAAO,CACR;IACE,SAAS;IACT,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS;IACzC,iBAAiB,GAAG,SAAS;CAC9B,CACF,CA+EA"}
@@ -29,6 +29,7 @@ import { clientToServer } from "../../../zero-schema/src/name-mapper.js";
29
29
  import { iterateMutators, isMutatorRegistry } from "../../../zql/src/mutate/mutator-registry.js";
30
30
  import { createRunnableBuilder } from "../../../zql/src/query/create-builder.js";
31
31
  import { isClientMetric } from "../../../zql/src/query/metrics-delegate.js";
32
+ import { addContextToQuery } from "../../../zql/src/query/query-registry.js";
32
33
  import "../../../zero-protocol/src/ast.js";
33
34
  import { nanoid } from "../util/nanoid.js";
34
35
  import { send } from "../util/socket.js";
@@ -273,7 +274,7 @@ class Zero {
273
274
  (error) => this.#disconnect(lc, error)
274
275
  );
275
276
  this.#ivmMain = new IVMSourceBranch(schema.tables);
276
- const { enableLegacyQueries = true } = schema;
277
+ const { enableLegacyQueries = false } = schema;
277
278
  const replicacheMutators = makeReplicacheMutators(
278
279
  schema,
279
280
  options.mutators,
@@ -525,7 +526,10 @@ class Zero {
525
526
  * ```
526
527
  */
527
528
  preload(query, options) {
528
- return this.#zeroContext.preload(query.toQuery(this.context), options);
529
+ return this.#zeroContext.preload(
530
+ addContextToQuery(query, this.context),
531
+ options
532
+ );
529
533
  }
530
534
  /**
531
535
  * Executes a query once and returns the results.
@@ -548,13 +552,16 @@ class Zero {
548
552
  * ```
549
553
  */
550
554
  run(query, runOptions) {
551
- return this.#zeroContext.run(query.toQuery(this.context), runOptions);
555
+ return this.#zeroContext.run(
556
+ addContextToQuery(query, this.context),
557
+ runOptions
558
+ );
552
559
  }
553
560
  get context() {
554
561
  return this.#options.context;
555
562
  }
556
563
  materialize(query, factoryOrOptions, maybeOptions) {
557
- const q = query.toQuery(this.context);
564
+ const q = addContextToQuery(query, this.context);
558
565
  let factory;
559
566
  let options;
560
567
  if (typeof factoryOrOptions === "function") {