@rocicorp/zero 0.25.0-canary.13 → 0.25.0-canary.15

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 (169) hide show
  1. package/out/shared/src/record-proxy.d.ts +13 -0
  2. package/out/shared/src/record-proxy.d.ts.map +1 -0
  3. package/out/shared/src/record-proxy.js +59 -0
  4. package/out/shared/src/record-proxy.js.map +1 -0
  5. package/out/zero/package.json.js +1 -1
  6. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  7. package/out/zero-cache/src/auth/write-authorizer.js +20 -13
  8. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  9. package/out/zero-cache/src/config/zero-config.d.ts +8 -0
  10. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  11. package/out/zero-cache/src/config/zero-config.js +12 -0
  12. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  13. package/out/zero-cache/src/server/otel-start.d.ts.map +1 -1
  14. package/out/zero-cache/src/server/otel-start.js +1 -5
  15. package/out/zero-cache/src/server/otel-start.js.map +1 -1
  16. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  17. package/out/zero-cache/src/server/syncer.js +6 -1
  18. package/out/zero-cache/src/server/syncer.js.map +1 -1
  19. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +8 -9
  20. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  21. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +17 -11
  22. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  23. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +2 -2
  24. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
  25. package/out/zero-cache/src/services/view-syncer/snapshotter.js +19 -4
  26. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  27. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  28. package/out/zero-cache/src/services/view-syncer/view-syncer.js +1 -7
  29. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  30. package/out/zero-client/src/client/crud.d.ts +3 -3
  31. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  32. package/out/zero-client/src/client/crud.js +23 -13
  33. package/out/zero-client/src/client/crud.js.map +1 -1
  34. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  35. package/out/zero-client/src/client/custom.js +4 -11
  36. package/out/zero-client/src/client/custom.js.map +1 -1
  37. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  38. package/out/zero-client/src/client/ivm-branch.js +20 -13
  39. package/out/zero-client/src/client/ivm-branch.js.map +1 -1
  40. package/out/zero-client/src/client/make-mutate-property.d.ts +1 -1
  41. package/out/zero-client/src/client/make-mutate-property.d.ts.map +1 -1
  42. package/out/zero-client/src/client/make-mutate-property.js.map +1 -1
  43. package/out/zero-client/src/client/make-replicache-mutators.d.ts.map +1 -1
  44. package/out/zero-client/src/client/make-replicache-mutators.js +10 -6
  45. package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
  46. package/out/zero-client/src/client/version.js +1 -1
  47. package/out/zero-client/src/client/zero.js +1 -1
  48. package/out/zero-client/src/client/zero.js.map +1 -1
  49. package/out/zero-server/src/custom.d.ts +2 -2
  50. package/out/zero-server/src/custom.d.ts.map +1 -1
  51. package/out/zero-server/src/custom.js +52 -32
  52. package/out/zero-server/src/custom.js.map +1 -1
  53. package/out/zero-server/src/zql-database.d.ts.map +1 -1
  54. package/out/zero-server/src/zql-database.js +1 -5
  55. package/out/zero-server/src/zql-database.js.map +1 -1
  56. package/out/zero-solid/src/solid-view.d.ts +1 -1
  57. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  58. package/out/zero-solid/src/solid-view.js +2 -0
  59. package/out/zero-solid/src/solid-view.js.map +1 -1
  60. package/out/zero-types/src/schema.d.ts +4 -4
  61. package/out/zql/src/builder/builder.d.ts.map +1 -1
  62. package/out/zql/src/builder/builder.js +1 -11
  63. package/out/zql/src/builder/builder.js.map +1 -1
  64. package/out/zql/src/error.js +1 -10
  65. package/out/zql/src/error.js.map +1 -1
  66. package/out/zql/src/ivm/array-view.d.ts +1 -1
  67. package/out/zql/src/ivm/array-view.d.ts.map +1 -1
  68. package/out/zql/src/ivm/array-view.js +2 -0
  69. package/out/zql/src/ivm/array-view.js.map +1 -1
  70. package/out/zql/src/ivm/exists.d.ts +3 -2
  71. package/out/zql/src/ivm/exists.d.ts.map +1 -1
  72. package/out/zql/src/ivm/exists.js +25 -23
  73. package/out/zql/src/ivm/exists.js.map +1 -1
  74. package/out/zql/src/ivm/fan-in.d.ts +3 -3
  75. package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
  76. package/out/zql/src/ivm/fan-in.js +6 -5
  77. package/out/zql/src/ivm/fan-in.js.map +1 -1
  78. package/out/zql/src/ivm/fan-out.d.ts +2 -2
  79. package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
  80. package/out/zql/src/ivm/fan-out.js +5 -5
  81. package/out/zql/src/ivm/fan-out.js.map +1 -1
  82. package/out/zql/src/ivm/filter-operators.d.ts +5 -5
  83. package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
  84. package/out/zql/src/ivm/filter-operators.js +8 -8
  85. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  86. package/out/zql/src/ivm/filter-push.d.ts +2 -1
  87. package/out/zql/src/ivm/filter-push.d.ts.map +1 -1
  88. package/out/zql/src/ivm/filter-push.js +5 -5
  89. package/out/zql/src/ivm/filter-push.js.map +1 -1
  90. package/out/zql/src/ivm/filter.d.ts +2 -2
  91. package/out/zql/src/ivm/filter.d.ts.map +1 -1
  92. package/out/zql/src/ivm/filter.js +4 -4
  93. package/out/zql/src/ivm/filter.js.map +1 -1
  94. package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
  95. package/out/zql/src/ivm/flipped-join.js +100 -83
  96. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  97. package/out/zql/src/ivm/join.d.ts.map +1 -1
  98. package/out/zql/src/ivm/join.js +52 -50
  99. package/out/zql/src/ivm/join.js.map +1 -1
  100. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
  101. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
  102. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +4 -4
  103. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  104. package/out/zql/src/ivm/memory-source.d.ts +3 -3
  105. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  106. package/out/zql/src/ivm/memory-source.js +7 -4
  107. package/out/zql/src/ivm/memory-source.js.map +1 -1
  108. package/out/zql/src/ivm/operator.d.ts +10 -3
  109. package/out/zql/src/ivm/operator.d.ts.map +1 -1
  110. package/out/zql/src/ivm/operator.js.map +1 -1
  111. package/out/zql/src/ivm/push-accumulated.d.ts +1 -1
  112. package/out/zql/src/ivm/push-accumulated.d.ts.map +1 -1
  113. package/out/zql/src/ivm/push-accumulated.js +8 -8
  114. package/out/zql/src/ivm/push-accumulated.js.map +1 -1
  115. package/out/zql/src/ivm/skip.d.ts +1 -1
  116. package/out/zql/src/ivm/skip.d.ts.map +1 -1
  117. package/out/zql/src/ivm/skip.js +8 -3
  118. package/out/zql/src/ivm/skip.js.map +1 -1
  119. package/out/zql/src/ivm/source.d.ts +15 -7
  120. package/out/zql/src/ivm/source.d.ts.map +1 -1
  121. package/out/zql/src/ivm/stream.d.ts +2 -0
  122. package/out/zql/src/ivm/stream.d.ts.map +1 -1
  123. package/out/zql/src/ivm/stream.js +5 -14
  124. package/out/zql/src/ivm/stream.js.map +1 -1
  125. package/out/zql/src/ivm/take.d.ts +1 -1
  126. package/out/zql/src/ivm/take.d.ts.map +1 -1
  127. package/out/zql/src/ivm/take.js +164 -147
  128. package/out/zql/src/ivm/take.js.map +1 -1
  129. package/out/zql/src/ivm/union-fan-in.d.ts +2 -2
  130. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
  131. package/out/zql/src/ivm/union-fan-in.js +7 -7
  132. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  133. package/out/zql/src/ivm/union-fan-out.d.ts +1 -1
  134. package/out/zql/src/ivm/union-fan-out.d.ts.map +1 -1
  135. package/out/zql/src/ivm/union-fan-out.js +3 -3
  136. package/out/zql/src/ivm/union-fan-out.js.map +1 -1
  137. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  138. package/out/zql/src/mutate/mutator-registry.js +1 -0
  139. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  140. package/out/zql/src/mutate/mutator.d.ts +10 -0
  141. package/out/zql/src/mutate/mutator.d.ts.map +1 -1
  142. package/out/zql/src/mutate/mutator.js.map +1 -1
  143. package/out/zql/src/planner/planner-builder.d.ts +2 -1
  144. package/out/zql/src/planner/planner-builder.d.ts.map +1 -1
  145. package/out/zql/src/planner/planner-builder.js +5 -5
  146. package/out/zql/src/planner/planner-builder.js.map +1 -1
  147. package/out/zql/src/planner/planner-graph.d.ts +3 -1
  148. package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
  149. package/out/zql/src/planner/planner-graph.js +5 -5
  150. package/out/zql/src/planner/planner-graph.js.map +1 -1
  151. package/out/zql/src/query/create-builder.d.ts.map +1 -1
  152. package/out/zql/src/query/create-builder.js +7 -36
  153. package/out/zql/src/query/create-builder.js.map +1 -1
  154. package/out/zql/src/query/measure-push-operator.d.ts +1 -1
  155. package/out/zql/src/query/measure-push-operator.d.ts.map +1 -1
  156. package/out/zql/src/query/measure-push-operator.js +2 -2
  157. package/out/zql/src/query/measure-push-operator.js.map +1 -1
  158. package/out/zqlite/src/internal/sql-inline.d.ts +13 -0
  159. package/out/zqlite/src/internal/sql-inline.d.ts.map +1 -0
  160. package/out/zqlite/src/internal/sql-inline.js +45 -0
  161. package/out/zqlite/src/internal/sql-inline.js.map +1 -0
  162. package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -1
  163. package/out/zqlite/src/sqlite-cost-model.js +2 -2
  164. package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
  165. package/out/zqlite/src/table-source.d.ts +3 -2
  166. package/out/zqlite/src/table-source.d.ts.map +1 -1
  167. package/out/zqlite/src/table-source.js +5 -2
  168. package/out/zqlite/src/table-source.js.map +1 -1
  169. package/package.json +1 -1
@@ -1,8 +1,12 @@
1
+ import { consume } from "../../../zql/src/ivm/stream.js";
1
2
  import { must } from "../../../shared/src/must.js";
2
3
  import { promiseVoid } from "../../../shared/src/resolved-promises.js";
3
4
  import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/push.js";
4
5
  import { toPrimaryKeyString } from "./keys.js";
5
6
  function makeCRUDMutate(schema, repMutate, mutate) {
7
+ if (schema.enableLegacyMutators !== true) {
8
+ return void 0;
9
+ }
6
10
  const { [CRUD_MUTATION_NAME]: zeroCRUD } = repMutate;
7
11
  const mutateBatch = async (body) => {
8
12
  const ops = [];
@@ -150,10 +154,12 @@ async function insertImpl(tx, arg, schema, ivmBranch) {
150
154
  );
151
155
  await tx.set(key, val);
152
156
  if (ivmBranch) {
153
- must(ivmBranch.getSource(arg.tableName)).push({
154
- type: "add",
155
- row: arg.value
156
- });
157
+ consume(
158
+ must(ivmBranch.getSource(arg.tableName)).push({
159
+ type: "add",
160
+ row: arg.value
161
+ })
162
+ );
157
163
  }
158
164
  }
159
165
  }
@@ -188,11 +194,13 @@ async function updateImpl(tx, arg, schema, ivmBranch) {
188
194
  }
189
195
  await tx.set(key, next);
190
196
  if (ivmBranch) {
191
- must(ivmBranch.getSource(arg.tableName)).push({
192
- type: "edit",
193
- oldRow: prev,
194
- row: next
195
- });
197
+ consume(
198
+ must(ivmBranch.getSource(arg.tableName)).push({
199
+ type: "edit",
200
+ oldRow: prev,
201
+ row: next
202
+ })
203
+ );
196
204
  }
197
205
  }
198
206
  async function deleteImpl(tx, arg, schema, ivmBranch) {
@@ -207,10 +215,12 @@ async function deleteImpl(tx, arg, schema, ivmBranch) {
207
215
  }
208
216
  await tx.del(key);
209
217
  if (ivmBranch) {
210
- must(ivmBranch.getSource(arg.tableName)).push({
211
- type: "remove",
212
- row: prev
213
- });
218
+ consume(
219
+ must(ivmBranch.getSource(arg.tableName)).push({
220
+ type: "remove",
221
+ row: prev
222
+ })
223
+ );
214
224
  }
215
225
  }
216
226
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"crud.js","sources":["../../../../../zero-client/src/client/crud.ts"],"sourcesContent":["import type {ReadonlyJSONObject} from '../../../shared/src/json.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {promiseVoid} from '../../../shared/src/resolved-promises.ts';\nimport type {MaybePromise} from '../../../shared/src/types.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport {\n CRUD_MUTATION_NAME,\n type CRUDMutationArg,\n type CRUDOp,\n type DeleteOp,\n type InsertOp,\n type UpdateOp,\n type UpsertOp,\n} from '../../../zero-protocol/src/push.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {\n DeleteID,\n InsertValue,\n UpdateValue,\n UpsertValue,\n} from '../../../zql/src/mutate/custom.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport {toPrimaryKeyString} from './keys.ts';\nimport type {MutatorDefs, WriteTransaction} from './replicache-types.ts';\n\n/**\n * This is the type of the generated mutate.<name>.<verb> function.\n */\nexport type TableMutator<S extends TableSchema> = {\n /**\n * Writes a row if a row with the same primary key doesn't already exists.\n * Non-primary-key fields that are 'optional' can be omitted or set to\n * `undefined`. Such fields will be assigned the value `null` optimistically\n * and then the default value as defined by the server.\n */\n insert: (value: InsertValue<S>) => Promise<void>;\n\n /**\n * Writes a row unconditionally, overwriting any existing row with the same\n * primary key. Non-primary-key fields that are 'optional' can be omitted or\n * set to `undefined`. Such fields will be assigned the value `null`\n * optimistically and then the default value as defined by the server.\n */\n upsert: (value: UpsertValue<S>) => Promise<void>;\n\n /**\n * Updates a row with the same primary key. If no such row exists, this\n * function does nothing. All non-primary-key fields can be omitted or set to\n * `undefined`. Such fields will be left unchanged from previous value.\n */\n update: (value: UpdateValue<S>) => Promise<void>;\n\n /**\n * Deletes the row with the specified primary key. If no such row exists, this\n * function does nothing.\n */\n delete: (id: DeleteID<S>) => Promise<void>;\n};\n\nexport type DBMutator<S extends Schema> =\n S['enableLegacyMutators'] extends false\n ? {} // {} is needed here for intersection type identity\n : {\n [K in keyof S['tables']]: TableMutator<S['tables'][K]>;\n };\n\nexport type BatchMutator<S extends Schema> = <R>(\n body: (m: DBMutator<S>) => MaybePromise<R>,\n) => Promise<R>;\n\ntype ZeroCRUDMutate = {\n [CRUD_MUTATION_NAME]: CRUDMutate;\n};\n\n/**\n * This is the zero.mutate object part representing the CRUD operations. If the\n * tables are `issue` and `label`, then this object will have `issue` and\n * `label` properties.\n *\n * @param schema - The schema defining the tables\n * @param repMutate - The replicache mutate object with the CRUD mutation\n * @param mutate - The object to use as the mutate object. Properties for each\n * table will be assigned to this object.\n */\nexport function makeCRUDMutate<const S extends Schema>(\n schema: S,\n repMutate: ZeroCRUDMutate,\n mutate: object,\n): BatchMutator<S> {\n const {[CRUD_MUTATION_NAME]: zeroCRUD} = repMutate;\n\n const mutateBatch = async <R>(body: (m: DBMutator<S>) => R): Promise<R> => {\n const ops: CRUDOp[] = [];\n const m = {} as Record<string, unknown>;\n for (const name of Object.keys(schema.tables)) {\n m[name] = makeBatchCRUDMutate(name, schema, ops);\n }\n\n const rv = await body(m as DBMutator<S>);\n await zeroCRUD({ops});\n return rv;\n };\n\n for (const [name, tableSchema] of Object.entries(schema.tables)) {\n (mutate as Record<string, unknown>)[name] = makeEntityCRUDMutate(\n name,\n tableSchema.primaryKey,\n zeroCRUD,\n );\n }\n return mutateBatch as BatchMutator<S>;\n}\n\n/**\n * Creates the `{insert, upsert, update, delete}` object for use outside a\n * batch.\n */\nfunction makeEntityCRUDMutate<S extends TableSchema>(\n tableName: string,\n primaryKey: S['primaryKey'],\n zeroCRUD: CRUDMutate,\n): TableMutator<S> {\n return {\n insert: (value: InsertValue<S>) => {\n const op: InsertOp = {\n op: 'insert',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n upsert: (value: UpsertValue<S>) => {\n const op: UpsertOp = {\n op: 'upsert',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n update: (value: UpdateValue<S>) => {\n const op: UpdateOp = {\n op: 'update',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n delete: (id: DeleteID<S>) => {\n const op: DeleteOp = {\n op: 'delete',\n tableName,\n primaryKey,\n value: id,\n };\n return zeroCRUD({ops: [op]});\n },\n };\n}\n\n/**\n * Creates the `{inesrt, upsert, update, delete}` object for use inside a\n * batch.\n */\nexport function makeBatchCRUDMutate<S extends TableSchema>(\n tableName: string,\n schema: Schema,\n ops: CRUDOp[],\n): TableMutator<S> {\n const {primaryKey} = schema.tables[tableName];\n return {\n insert: (value: InsertValue<S>) => {\n const op: InsertOp = {\n op: 'insert',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n upsert: (value: UpsertValue<S>) => {\n const op: UpsertOp = {\n op: 'upsert',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n update: (value: UpdateValue<S>) => {\n const op: UpdateOp = {\n op: 'update',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n delete: (id: DeleteID<S>) => {\n const op: DeleteOp = {\n op: 'delete',\n tableName,\n primaryKey,\n value: id,\n };\n ops.push(op);\n return promiseVoid;\n },\n };\n}\n\nexport type WithCRUD<MD extends MutatorDefs> = MD & {\n [CRUD_MUTATION_NAME]: CRUDMutator;\n};\n\nexport type CRUDMutate = (crudArg: CRUDMutationArg) => Promise<void>;\n\nexport type CRUDMutator = (\n tx: WriteTransaction,\n crudArg: CRUDMutationArg,\n) => Promise<void>;\n\n// Zero crud mutators cannot function at the same\n// time as custom mutators as the rebase of crud mutators will not\n// update the IVM branch. That's ok, we're removing crud mutators\n// in favor of custom mutators.\nexport function makeCRUDMutator(schema: Schema): CRUDMutator {\n return async function zeroCRUDMutator(\n tx: WriteTransaction,\n crudArg: CRUDMutationArg,\n ): Promise<void> {\n for (const op of crudArg.ops) {\n switch (op.op) {\n case 'insert':\n await insertImpl(tx, op, schema, undefined);\n break;\n case 'upsert':\n await upsertImpl(tx, op, schema, undefined);\n break;\n case 'update':\n await updateImpl(tx, op, schema, undefined);\n break;\n case 'delete':\n await deleteImpl(tx, op, schema, undefined);\n break;\n }\n }\n };\n}\n\nfunction defaultOptionalFieldsToNull(\n schema: TableSchema,\n value: ReadonlyJSONObject,\n): ReadonlyJSONObject {\n let rv = value;\n for (const name in schema.columns) {\n if (rv[name] === undefined) {\n rv = {...rv, [name]: null};\n }\n }\n return rv;\n}\n\nexport async function insertImpl(\n tx: WriteTransaction,\n arg: InsertOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n if (!(await tx.has(key))) {\n const val = defaultOptionalFieldsToNull(\n schema.tables[arg.tableName],\n arg.value,\n );\n await tx.set(key, val);\n if (ivmBranch) {\n must(ivmBranch.getSource(arg.tableName)).push({\n type: 'add',\n row: arg.value,\n });\n }\n }\n}\n\nexport async function upsertImpl(\n tx: WriteTransaction,\n arg: InsertOp | UpsertOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n if (await tx.has(key)) {\n await updateImpl(tx, {...arg, op: 'update'}, schema, ivmBranch);\n } else {\n await insertImpl(tx, {...arg, op: 'insert'}, schema, ivmBranch);\n }\n}\n\nexport async function updateImpl(\n tx: WriteTransaction,\n arg: UpdateOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n const prev = await tx.get(key);\n if (prev === undefined) {\n return;\n }\n const update = arg.value;\n const next = {...(prev as ReadonlyJSONObject)};\n for (const k in update) {\n if (update[k] !== undefined) {\n next[k] = update[k];\n }\n }\n await tx.set(key, next);\n if (ivmBranch) {\n must(ivmBranch.getSource(arg.tableName)).push({\n type: 'edit',\n oldRow: prev as Row,\n row: next,\n });\n }\n}\n\nexport async function deleteImpl(\n tx: WriteTransaction,\n arg: DeleteOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n const prev = await tx.get(key);\n if (prev === undefined) {\n return;\n }\n await tx.del(key);\n if (ivmBranch) {\n must(ivmBranch.getSource(arg.tableName)).push({\n type: 'remove',\n row: prev as Row,\n });\n }\n}\n"],"names":[],"mappings":";;;;AAqFO,SAAS,eACd,QACA,WACA,QACiB;AACjB,QAAM,EAAC,CAAC,kBAAkB,GAAG,aAAY;AAEzC,QAAM,cAAc,OAAU,SAA6C;AACzE,UAAM,MAAgB,CAAA;AACtB,UAAM,IAAI,CAAA;AACV,eAAW,QAAQ,OAAO,KAAK,OAAO,MAAM,GAAG;AAC7C,QAAE,IAAI,IAAI,oBAAoB,MAAM,QAAQ,GAAG;AAAA,IACjD;AAEA,UAAM,KAAK,MAAM,KAAK,CAAiB;AACvC,UAAM,SAAS,EAAC,KAAI;AACpB,WAAO;AAAA,EACT;AAEA,aAAW,CAAC,MAAM,WAAW,KAAK,OAAO,QAAQ,OAAO,MAAM,GAAG;AAC9D,WAAmC,IAAI,IAAI;AAAA,MAC1C;AAAA,MACA,YAAY;AAAA,MACZ;AAAA,IAAA;AAAA,EAEJ;AACA,SAAO;AACT;AAMA,SAAS,qBAC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AI;AAAA,EAAA;AAEN,QAAM,OAAO,MAAM,GAAG,IAAI,GAAG;AAC7B,MAAI,SAAS,QAAW;AACtB;AAAA,EACF;AACA,QAAM,GAAG,IAAI,GAAG;AAChB,MAAI,WAAW;AACb,SAAK,UAAU,UAAU,IAAI,SAAS,CAAC,EAAE,KAAK;AAAA,MAC5C,MAAM;AAAA,MACN,KAAK;AAAA,IAAA,CACN;AAAA,EACH;AACF;"}
1
+ {"version":3,"file":"crud.js","sources":["../../../../../zero-client/src/client/crud.ts"],"sourcesContent":["import type {ReadonlyJSONObject} from '../../../shared/src/json.ts';\nimport {consume} from '../../../zql/src/ivm/stream.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {promiseVoid} from '../../../shared/src/resolved-promises.ts';\nimport type {MaybePromise} from '../../../shared/src/types.ts';\nimport type {Row} from '../../../zero-protocol/src/data.ts';\nimport {\n CRUD_MUTATION_NAME,\n type CRUDMutationArg,\n type CRUDOp,\n type DeleteOp,\n type InsertOp,\n type UpdateOp,\n type UpsertOp,\n} from '../../../zero-protocol/src/push.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {\n DeleteID,\n InsertValue,\n UpdateValue,\n UpsertValue,\n} from '../../../zql/src/mutate/custom.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport {toPrimaryKeyString} from './keys.ts';\nimport type {MutatorDefs, WriteTransaction} from './replicache-types.ts';\n\n/**\n * This is the type of the generated mutate.<name>.<verb> function.\n */\nexport type TableMutator<S extends TableSchema> = {\n /**\n * Writes a row if a row with the same primary key doesn't already exists.\n * Non-primary-key fields that are 'optional' can be omitted or set to\n * `undefined`. Such fields will be assigned the value `null` optimistically\n * and then the default value as defined by the server.\n */\n insert: (value: InsertValue<S>) => Promise<void>;\n\n /**\n * Writes a row unconditionally, overwriting any existing row with the same\n * primary key. Non-primary-key fields that are 'optional' can be omitted or\n * set to `undefined`. Such fields will be assigned the value `null`\n * optimistically and then the default value as defined by the server.\n */\n upsert: (value: UpsertValue<S>) => Promise<void>;\n\n /**\n * Updates a row with the same primary key. If no such row exists, this\n * function does nothing. All non-primary-key fields can be omitted or set to\n * `undefined`. Such fields will be left unchanged from previous value.\n */\n update: (value: UpdateValue<S>) => Promise<void>;\n\n /**\n * Deletes the row with the specified primary key. If no such row exists, this\n * function does nothing.\n */\n delete: (id: DeleteID<S>) => Promise<void>;\n};\n\nexport type DBMutator<S extends Schema> = S['enableLegacyMutators'] extends true\n ? {\n [K in keyof S['tables']]: TableMutator<S['tables'][K]>;\n }\n : {}; // {} is needed here for intersection type identity\n\nexport type BatchMutator<S extends Schema> =\n S['enableLegacyMutators'] extends true\n ? <R>(body: (m: DBMutator<S>) => MaybePromise<R>) => Promise<R>\n : undefined;\n\ntype ZeroCRUDMutate = {\n [CRUD_MUTATION_NAME]: CRUDMutate;\n};\n\n/**\n * This is the zero.mutate object part representing the CRUD operations. If the\n * tables are `issue` and `label`, then this object will have `issue` and\n * `label` properties.\n *\n * @param schema - The schema defining the tables\n * @param repMutate - The replicache mutate object with the CRUD mutation\n * @param mutate - The object to use as the mutate object. Properties for each\n * table will be assigned to this object.\n */\nexport function makeCRUDMutate<const S extends Schema>(\n schema: S,\n repMutate: ZeroCRUDMutate,\n mutate: object,\n): BatchMutator<S> {\n if (schema.enableLegacyMutators !== true) {\n return undefined as BatchMutator<S>;\n }\n\n const {[CRUD_MUTATION_NAME]: zeroCRUD} = repMutate;\n\n const mutateBatch = async <R>(body: (m: DBMutator<S>) => R): Promise<R> => {\n const ops: CRUDOp[] = [];\n const m = {} as Record<string, unknown>;\n for (const name of Object.keys(schema.tables)) {\n m[name] = makeBatchCRUDMutate(name, schema, ops);\n }\n\n const rv = await body(m as DBMutator<S>);\n await zeroCRUD({ops});\n return rv;\n };\n\n for (const [name, tableSchema] of Object.entries(schema.tables)) {\n (mutate as Record<string, unknown>)[name] = makeEntityCRUDMutate(\n name,\n tableSchema.primaryKey,\n zeroCRUD,\n );\n }\n return mutateBatch as BatchMutator<S>;\n}\n\n/**\n * Creates the `{insert, upsert, update, delete}` object for use outside a\n * batch.\n */\nfunction makeEntityCRUDMutate<S extends TableSchema>(\n tableName: string,\n primaryKey: S['primaryKey'],\n zeroCRUD: CRUDMutate,\n): TableMutator<S> {\n return {\n insert: (value: InsertValue<S>) => {\n const op: InsertOp = {\n op: 'insert',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n upsert: (value: UpsertValue<S>) => {\n const op: UpsertOp = {\n op: 'upsert',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n update: (value: UpdateValue<S>) => {\n const op: UpdateOp = {\n op: 'update',\n tableName,\n primaryKey,\n value,\n };\n return zeroCRUD({ops: [op]});\n },\n delete: (id: DeleteID<S>) => {\n const op: DeleteOp = {\n op: 'delete',\n tableName,\n primaryKey,\n value: id,\n };\n return zeroCRUD({ops: [op]});\n },\n };\n}\n\n/**\n * Creates the `{inesrt, upsert, update, delete}` object for use inside a\n * batch.\n */\nexport function makeBatchCRUDMutate<S extends TableSchema>(\n tableName: string,\n schema: Schema,\n ops: CRUDOp[],\n): TableMutator<S> {\n const {primaryKey} = schema.tables[tableName];\n return {\n insert: (value: InsertValue<S>) => {\n const op: InsertOp = {\n op: 'insert',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n upsert: (value: UpsertValue<S>) => {\n const op: UpsertOp = {\n op: 'upsert',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n update: (value: UpdateValue<S>) => {\n const op: UpdateOp = {\n op: 'update',\n tableName,\n primaryKey,\n value,\n };\n ops.push(op);\n return promiseVoid;\n },\n delete: (id: DeleteID<S>) => {\n const op: DeleteOp = {\n op: 'delete',\n tableName,\n primaryKey,\n value: id,\n };\n ops.push(op);\n return promiseVoid;\n },\n };\n}\n\nexport type WithCRUD<MD extends MutatorDefs> = MD & {\n [CRUD_MUTATION_NAME]: CRUDMutator;\n};\n\nexport type CRUDMutate = (crudArg: CRUDMutationArg) => Promise<void>;\n\nexport type CRUDMutator = (\n tx: WriteTransaction,\n crudArg: CRUDMutationArg,\n) => Promise<void>;\n\n// Zero crud mutators cannot function at the same\n// time as custom mutators as the rebase of crud mutators will not\n// update the IVM branch. That's ok, we're removing crud mutators\n// in favor of custom mutators.\nexport function makeCRUDMutator(schema: Schema): CRUDMutator {\n return async function zeroCRUDMutator(\n tx: WriteTransaction,\n crudArg: CRUDMutationArg,\n ): Promise<void> {\n for (const op of crudArg.ops) {\n switch (op.op) {\n case 'insert':\n await insertImpl(tx, op, schema, undefined);\n break;\n case 'upsert':\n await upsertImpl(tx, op, schema, undefined);\n break;\n case 'update':\n await updateImpl(tx, op, schema, undefined);\n break;\n case 'delete':\n await deleteImpl(tx, op, schema, undefined);\n break;\n }\n }\n };\n}\n\nfunction defaultOptionalFieldsToNull(\n schema: TableSchema,\n value: ReadonlyJSONObject,\n): ReadonlyJSONObject {\n let rv = value;\n for (const name in schema.columns) {\n if (rv[name] === undefined) {\n rv = {...rv, [name]: null};\n }\n }\n return rv;\n}\n\nexport async function insertImpl(\n tx: WriteTransaction,\n arg: InsertOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n if (!(await tx.has(key))) {\n const val = defaultOptionalFieldsToNull(\n schema.tables[arg.tableName],\n arg.value,\n );\n await tx.set(key, val);\n if (ivmBranch) {\n consume(\n must(ivmBranch.getSource(arg.tableName)).push({\n type: 'add',\n row: arg.value,\n }),\n );\n }\n }\n}\n\nexport async function upsertImpl(\n tx: WriteTransaction,\n arg: InsertOp | UpsertOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n if (await tx.has(key)) {\n await updateImpl(tx, {...arg, op: 'update'}, schema, ivmBranch);\n } else {\n await insertImpl(tx, {...arg, op: 'insert'}, schema, ivmBranch);\n }\n}\n\nexport async function updateImpl(\n tx: WriteTransaction,\n arg: UpdateOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n const prev = await tx.get(key);\n if (prev === undefined) {\n return;\n }\n const update = arg.value;\n const next = {...(prev as ReadonlyJSONObject)};\n for (const k in update) {\n if (update[k] !== undefined) {\n next[k] = update[k];\n }\n }\n await tx.set(key, next);\n if (ivmBranch) {\n consume(\n must(ivmBranch.getSource(arg.tableName)).push({\n type: 'edit',\n oldRow: prev as Row,\n row: next,\n }),\n );\n }\n}\n\nexport async function deleteImpl(\n tx: WriteTransaction,\n arg: DeleteOp,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): Promise<void> {\n const key = toPrimaryKeyString(\n arg.tableName,\n schema.tables[arg.tableName].primaryKey,\n arg.value,\n );\n const prev = await tx.get(key);\n if (prev === undefined) {\n return;\n }\n await tx.del(key);\n if (ivmBranch) {\n consume(\n must(ivmBranch.getSource(arg.tableName)).push({\n type: 'remove',\n row: prev as Row,\n }),\n );\n }\n}\n"],"names":[],"mappings":";;;;;AAsFO,SAAS,eACd,QACA,WACA,QACiB;AACjB,MAAI,OAAO,yBAAyB,MAAM;AACxC,WAAO;AAAA,EACT;AAEA,QAAM,EAAC,CAAC,kBAAkB,GAAG,aAAY;AAEzC,QAAM,cAAc,OAAU,SAA6C;AACzE,UAAM,MAAgB,CAAA;AACtB,UAAM,IAAI,CAAA;AACV,eAAW,QAAQ,OAAO,KAAK,OAAO,MAAM,GAAG;AAC7C,QAAE,IAAI,IAAI,oBAAoB,MAAM,QAAQ,GAAG;AAAA,IACjD;AAEA,UAAM,KAAK,MAAM,KAAK,CAAiB;AACvC,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AU,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,EAAE,OAAO;IAoBpE,IAAI,QAAQ,IAAI,QAAQ,CAEvB;IAED,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,IAAI,MAAM,IAAI,YAAY,GAAG,QAAQ,CAEpC;IAED,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,GAAG,CAAC,MAAM,SAAS,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,MAAM,EAAE,OAAO,EAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,EACtC,OAAO,CAAC,EAAE,UAAU,GACnB,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;CAGnC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,UAAU,CAMjE;AAED,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,MAAM,EAChB,mBAAmB,EACnB,OAAO,EAEP,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,mBAAmB,CAAC,EAClD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,OAAO,GACf,CAAC,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,CAQrE"}
@@ -1,6 +1,7 @@
1
1
  import { zeroData } from "../../../replicache/src/transactions.js";
2
2
  import { assert } from "../../../shared/src/asserts.js";
3
3
  import { must } from "../../../shared/src/must.js";
4
+ import { recordProxy } from "../../../shared/src/record-proxy.js";
4
5
  import { emptyFunction } from "../../../shared/src/sentinels.js";
5
6
  import { createRunnableBuilder } from "../../../zql/src/query/create-builder.js";
6
7
  import "../../../zero-protocol/src/ast.js";
@@ -58,17 +59,9 @@ function makeReplicacheMutator(lc, mutator, schema, context) {
58
59
  };
59
60
  }
60
61
  function makeSchemaCRUD(schema, tx, ivmBranch) {
61
- return new Proxy(
62
- {},
63
- {
64
- get(target, prop) {
65
- if (prop in target) {
66
- return target[prop];
67
- }
68
- target[prop] = makeTableCRUD(schema, prop, tx, ivmBranch);
69
- return target[prop];
70
- }
71
- }
62
+ return recordProxy(
63
+ schema.tables,
64
+ (_tableSchema, tableName) => makeTableCRUD(schema, tableName, tx, ivmBranch)
72
65
  );
73
66
  }
74
67
  function assertValidRunOptions(options) {
@@ -1 +1 @@
1
- {"version":3,"file":"custom.js","sources":["../../../../../zero-client/src/client/custom.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {ZeroTxData} from '../../../replicache/src/replicache-options.ts';\nimport type {WriteTransactionImpl} from '../../../replicache/src/transactions.ts';\nimport {zeroData} from '../../../replicache/src/transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {emptyFunction} from '../../../shared/src/sentinels.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport type {DefaultSchema} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {\n ClientTransaction,\n DeleteID,\n InsertValue,\n SchemaCRUD,\n TableCRUD,\n Transaction,\n UpdateValue,\n UpsertValue,\n} from '../../../zql/src/mutate/custom.ts';\nimport {createRunnableBuilder} from '../../../zql/src/query/create-builder.ts';\nimport {\n type HumanReadable,\n type Query,\n type RunOptions,\n} from '../../../zql/src/query/query.ts';\nimport type {SchemaQuery} from '../../../zql/src/query/schema-query.ts';\nimport type {ClientID} from '../types/client-state.ts';\nimport {ZeroContext} from './context.ts';\nimport {deleteImpl, insertImpl, updateImpl, upsertImpl} from './crud.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\n/**\n * The shape which a user's custom mutator definitions must conform to.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type CustomMutatorDefs = {\n // oxlint-disable-next-line no-explicit-any\n [namespaceOrKey: string]: CustomMutatorImpl<any> | CustomMutatorDefs;\n};\n\nexport type MutatorResultDetails =\n | {\n readonly type: 'success';\n }\n | {\n readonly type: 'error';\n readonly error:\n | {\n readonly type: 'app';\n readonly message: string;\n readonly details: ReadonlyJSONValue | undefined;\n }\n | {\n readonly type: 'zero';\n readonly message: string;\n };\n };\n\nexport type MutatorResultSuccessDetails = Extract<\n MutatorResultDetails,\n {type: 'success'}\n>;\nexport type MutatorResultErrorDetails = Extract<\n MutatorResultDetails,\n {type: 'error'}\n>;\n\nexport type MutatorResult = {\n client: Promise<MutatorResultDetails & {}>;\n server: Promise<MutatorResultDetails & {}>;\n} & {};\n\nexport type CustomMutatorImpl<\n S extends Schema,\n TWrappedTransaction = unknown,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs = any,\n Context = unknown,\n> = (\n tx: Transaction<S, TWrappedTransaction>,\n // TODO: many args. See commit: 52657c2f934b4a458d628ea77e56ce92b61eb3c6 which did have many args.\n // The issue being that it will be a protocol change to support varargs.\n args: TArgs,\n ctx: Context,\n) => Promise<void>;\n\n/**\n * The shape exposed on the `Zero.mutate` instance.\n * The signature of a custom mutator takes a `transaction` as its first arg\n * but the user does not provide this arg when calling the mutator.\n *\n * This utility strips the `tx` arg from the user's custom mutator signatures.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type MakeCustomMutatorInterfaces<\n S extends Schema,\n MD extends CustomMutatorDefs,\n TContext,\n> = {\n readonly [NamespaceOrName in keyof MD]: MD[NamespaceOrName] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[NamespaceOrName] extends CustomMutatorDefs\n ? MakeCustomMutatorInterfaces<S, MD[NamespaceOrName], TContext>\n : never;\n};\n\nexport type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (\n tx: ClientTransaction<TSchema>,\n ...args: infer Args\n) => Promise<void>\n ? (...args: Args) => MutatorResult\n : never;\n\nexport class TransactionImpl<TSchema extends Schema = DefaultSchema>\n implements ClientTransaction<TSchema>\n{\n readonly location = 'client';\n readonly mutate: SchemaCRUD<TSchema>;\n readonly query: SchemaQuery<TSchema>;\n readonly #repTx: WriteTransaction;\n readonly #zeroContext: ZeroContext;\n\n constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema) {\n must(repTx.reason === 'initial' || repTx.reason === 'rebase');\n const txData = getZeroTxData(repTx);\n\n this.#repTx = repTx;\n this.mutate = makeSchemaCRUD(\n schema,\n repTx,\n txData.ivmSources as IVMSourceBranch,\n );\n\n const zeroContext = newZeroContext(\n lc,\n txData.ivmSources as IVMSourceBranch,\n );\n\n this.query = createRunnableBuilder(zeroContext, schema);\n this.#zeroContext = zeroContext;\n }\n\n get clientID(): ClientID {\n return this.#repTx.clientID;\n }\n\n get mutationID(): number {\n return this.#repTx.mutationID;\n }\n\n get reason(): 'optimistic' | 'rebase' {\n return this.#repTx.reason === 'initial' ? 'optimistic' : 'rebase';\n }\n\n get token(): string | undefined {\n return (this.#repTx as WriteTransactionImpl)[zeroData]?.token;\n }\n\n run<TTable extends keyof TSchema['tables'] & string, TReturn>(\n query: Query<TTable, TSchema, TReturn>,\n options?: RunOptions,\n ): Promise<HumanReadable<TReturn>> {\n return this.#zeroContext.run(query, options);\n }\n}\n\nexport function getZeroTxData(repTx: WriteTransaction): ZeroTxData {\n const txData = must(\n (repTx as WriteTransactionImpl)[zeroData],\n 'zero was not set on replicache internal options!',\n );\n return txData as ZeroTxData;\n}\n\nexport function makeReplicacheMutator<\n S extends Schema,\n TWrappedTransaction,\n Context,\n>(\n lc: LogContext,\n mutator: CustomMutatorImpl<S, TWrappedTransaction>,\n schema: S,\n context: Context,\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 await mutator(tx, args, context);\n };\n}\n\nfunction makeSchemaCRUD<S extends Schema>(\n schema: S,\n tx: WriteTransaction,\n ivmBranch: IVMSourceBranch,\n) {\n // Only creates the CRUD mutators on demand\n // rather than creating them all up-front for each mutation.\n return new Proxy(\n {},\n {\n get(target: Record<string, TableCRUD<TableSchema>>, prop: string) {\n if (prop in target) {\n return target[prop];\n }\n\n target[prop] = makeTableCRUD(schema, prop, tx, ivmBranch);\n return target[prop];\n },\n },\n ) as SchemaCRUD<S>;\n}\n\nfunction assertValidRunOptions(options: RunOptions | undefined): void {\n // TODO(arv): We should enforce this with the type system too.\n assert(\n options?.type !== 'complete',\n 'Cannot wait for complete results in custom mutations',\n );\n}\n\nfunction newZeroContext(lc: LogContext, ivmBranch: IVMSourceBranch) {\n return new ZeroContext(\n lc,\n ivmBranch,\n () => emptyFunction,\n () => emptyFunction,\n emptyFunction,\n emptyFunction,\n emptyFunction,\n applyViewUpdates => applyViewUpdates(),\n emptyFunction,\n assertValidRunOptions,\n );\n}\n\nfunction makeTableCRUD(\n schema: Schema,\n tableName: string,\n tx: WriteTransaction,\n ivmBranch: IVMSourceBranch,\n) {\n const table = must(schema.tables[tableName]);\n const {primaryKey} = table;\n return {\n insert: (value: InsertValue<TableSchema>) =>\n insertImpl(\n tx,\n {op: 'insert', tableName, primaryKey, value},\n schema,\n ivmBranch,\n ),\n upsert: (value: UpsertValue<TableSchema>) =>\n upsertImpl(\n tx,\n {op: 'upsert', tableName, primaryKey, value},\n schema,\n ivmBranch,\n ),\n update: (value: UpdateValue<TableSchema>) =>\n updateImpl(\n tx,\n {op: 'update', tableName, primaryKey, value},\n schema,\n ivmBranch,\n ),\n delete: (id: DeleteID<TableSchema>) =>\n deleteImpl(\n tx,\n {op: 'delete', tableName, primaryKey, value: id},\n schema,\n ivmBranch,\n ),\n };\n}\n"],"names":[],"mappings":";;;;;;;;AAuHO,MAAM,gBAEb;AAAA,EACW,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,IAAgB,OAAyB,QAA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,EACF;AAEJ;AAEA,SAAS,sBAAsB,SAAuC;AAEpE;AAAA,IACE,SAAS,SAAS;AAAA,IAClB;AAAA,EAAA;AAEJ;AAEA,SAAS,eAAe,IAAgB,WAA4B;AAClE,SAAO,IAAI;AAAA,IACT;AAAA,IACA;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,IACA,sBAAoB,iBAAA;AAAA,IACpB;AAAA,IACA;AAAA,EAAA;AAEJ;AAEA,SAAS,cACP,QACA,WACA,IACA,WACA;AACA,QAAM,QAAQ,KAAK,OAAO,OAAO,SAAS,CAAC;AAC3C,QAAM,EAAC,eAAc;AACrB,SAAO;AAAA,IACL,QAAQ,CAAC,UACP;AAAA,MACE;AAAA,MACA,EAAe,WAAuB,MAAA;AAAA,MACtC;AAAA,MACA;AAAA,IAAA;AAAA,IAEJ,QAAQ,CAAC,UACP;AAAA,MACE;AAAA,MACA,EAAC,IAAI,UAAU,WAAW,YAAY,MAAA;AAAA,MACtC;AAAA,MACA;AAAA,IAAA;AAAA,IAEJ,QAAQ,CAAC,UACP;AAAA,MACE;AAAA,MACA,EAAe,WAAuB,MAAA;AAAA,MACtC;AAAA,MACA;AAAA,IAAA;AAAA,IAEJ,QAAQ,CAAC,OACP;AAAA,MACE;AAAA,MACA,EAAe,WAAuB,OAAO,GAAA;AAAA,MAC7C;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAEN;"}
1
+ {"version":3,"file":"custom.js","sources":["../../../../../zero-client/src/client/custom.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {ZeroTxData} from '../../../replicache/src/replicache-options.ts';\nimport type {WriteTransactionImpl} from '../../../replicache/src/transactions.ts';\nimport {zeroData} from '../../../replicache/src/transactions.ts';\nimport {assert} from '../../../shared/src/asserts.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {must} from '../../../shared/src/must.ts';\nimport {recordProxy} from '../../../shared/src/record-proxy.ts';\nimport {emptyFunction} from '../../../shared/src/sentinels.ts';\nimport type {TableSchema} from '../../../zero-schema/src/table-schema.ts';\nimport type {DefaultSchema} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport type {\n ClientTransaction,\n DeleteID,\n InsertValue,\n SchemaCRUD,\n Transaction,\n UpdateValue,\n UpsertValue,\n} from '../../../zql/src/mutate/custom.ts';\nimport {createRunnableBuilder} from '../../../zql/src/query/create-builder.ts';\nimport {\n type HumanReadable,\n type Query,\n type RunOptions,\n} from '../../../zql/src/query/query.ts';\nimport type {SchemaQuery} from '../../../zql/src/query/schema-query.ts';\nimport type {ClientID} from '../types/client-state.ts';\nimport {ZeroContext} from './context.ts';\nimport {deleteImpl, insertImpl, updateImpl, upsertImpl} from './crud.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\n/**\n * The shape which a user's custom mutator definitions must conform to.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type CustomMutatorDefs = {\n // oxlint-disable-next-line no-explicit-any\n [namespaceOrKey: string]: CustomMutatorImpl<any> | CustomMutatorDefs;\n};\n\nexport type MutatorResultDetails =\n | {\n readonly type: 'success';\n }\n | {\n readonly type: 'error';\n readonly error:\n | {\n readonly type: 'app';\n readonly message: string;\n readonly details: ReadonlyJSONValue | undefined;\n }\n | {\n readonly type: 'zero';\n readonly message: string;\n };\n };\n\nexport type MutatorResultSuccessDetails = Extract<\n MutatorResultDetails,\n {type: 'success'}\n>;\nexport type MutatorResultErrorDetails = Extract<\n MutatorResultDetails,\n {type: 'error'}\n>;\n\nexport type MutatorResult = {\n client: Promise<MutatorResultDetails & {}>;\n server: Promise<MutatorResultDetails & {}>;\n} & {};\n\nexport type CustomMutatorImpl<\n S extends Schema,\n TWrappedTransaction = unknown,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n TArgs = any,\n Context = unknown,\n> = (\n tx: Transaction<S, TWrappedTransaction>,\n // TODO: many args. See commit: 52657c2f934b4a458d628ea77e56ce92b61eb3c6 which did have many args.\n // The issue being that it will be a protocol change to support varargs.\n args: TArgs,\n ctx: Context,\n) => Promise<void>;\n\n/**\n * The shape exposed on the `Zero.mutate` instance.\n * The signature of a custom mutator takes a `transaction` as its first arg\n * but the user does not provide this arg when calling the mutator.\n *\n * This utility strips the `tx` arg from the user's custom mutator signatures.\n * Supports arbitrary depth nesting of namespaces.\n */\nexport type MakeCustomMutatorInterfaces<\n S extends Schema,\n MD extends CustomMutatorDefs,\n TContext,\n> = {\n readonly [NamespaceOrName in keyof MD]: MD[NamespaceOrName] extends (\n tx: Transaction<S>,\n ...args: infer Args\n ) => Promise<void>\n ? (...args: Args) => MutatorResult\n : MD[NamespaceOrName] extends CustomMutatorDefs\n ? MakeCustomMutatorInterfaces<S, MD[NamespaceOrName], TContext>\n : never;\n};\n\nexport type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (\n tx: ClientTransaction<TSchema>,\n ...args: infer Args\n) => Promise<void>\n ? (...args: Args) => MutatorResult\n : never;\n\nexport class TransactionImpl<TSchema extends Schema = DefaultSchema>\n implements ClientTransaction<TSchema>\n{\n readonly location = 'client';\n readonly mutate: SchemaCRUD<TSchema>;\n readonly query: SchemaQuery<TSchema>;\n readonly #repTx: WriteTransaction;\n readonly #zeroContext: ZeroContext;\n\n constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema) {\n must(repTx.reason === 'initial' || repTx.reason === 'rebase');\n const txData = getZeroTxData(repTx);\n\n this.#repTx = repTx;\n this.mutate = makeSchemaCRUD(\n schema,\n repTx,\n txData.ivmSources as IVMSourceBranch,\n );\n\n const zeroContext = newZeroContext(\n lc,\n txData.ivmSources as IVMSourceBranch,\n );\n\n this.query = createRunnableBuilder(zeroContext, schema);\n this.#zeroContext = zeroContext;\n }\n\n get clientID(): ClientID {\n return this.#repTx.clientID;\n }\n\n get mutationID(): number {\n return this.#repTx.mutationID;\n }\n\n get reason(): 'optimistic' | 'rebase' {\n return this.#repTx.reason === 'initial' ? 'optimistic' : 'rebase';\n }\n\n get token(): string | undefined {\n return (this.#repTx as WriteTransactionImpl)[zeroData]?.token;\n }\n\n run<TTable extends keyof TSchema['tables'] & string, TReturn>(\n query: Query<TTable, TSchema, TReturn>,\n options?: RunOptions,\n ): Promise<HumanReadable<TReturn>> {\n return this.#zeroContext.run(query, options);\n }\n}\n\nexport function getZeroTxData(repTx: WriteTransaction): ZeroTxData {\n const txData = must(\n (repTx as WriteTransactionImpl)[zeroData],\n 'zero was not set on replicache internal options!',\n );\n return txData as ZeroTxData;\n}\n\nexport function makeReplicacheMutator<\n S extends Schema,\n TWrappedTransaction,\n Context,\n>(\n lc: LogContext,\n mutator: CustomMutatorImpl<S, TWrappedTransaction>,\n schema: S,\n context: Context,\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 await mutator(tx, args, context);\n };\n}\n\nfunction makeSchemaCRUD<S extends Schema>(\n schema: S,\n tx: WriteTransaction,\n ivmBranch: IVMSourceBranch,\n) {\n // Only creates the CRUD mutators on demand\n // rather than creating them all up-front for each mutation.\n return recordProxy(schema.tables, (_tableSchema, tableName) =>\n makeTableCRUD(schema, tableName, tx, ivmBranch),\n ) as SchemaCRUD<S>;\n}\n\nfunction assertValidRunOptions(options: RunOptions | undefined): void {\n // TODO(arv): We should enforce this with the type system too.\n assert(\n options?.type !== 'complete',\n 'Cannot wait for complete results in custom mutations',\n );\n}\n\nfunction newZeroContext(lc: LogContext, ivmBranch: IVMSourceBranch) {\n return new ZeroContext(\n lc,\n ivmBranch,\n () => emptyFunction,\n () => emptyFunction,\n emptyFunction,\n emptyFunction,\n emptyFunction,\n applyViewUpdates => applyViewUpdates(),\n emptyFunction,\n assertValidRunOptions,\n );\n}\n\nfunction makeTableCRUD(\n schema: Schema,\n tableName: string,\n tx: WriteTransaction,\n ivmBranch: IVMSourceBranch,\n) {\n const table = must(schema.tables[tableName]);\n const {primaryKey} = table;\n return {\n insert: (value: InsertValue<TableSchema>) =>\n insertImpl(\n tx,\n {op: 'insert', tableName, primaryKey, value},\n schema,\n ivmBranch,\n ),\n upsert: (value: UpsertValue<TableSchema>) =>\n upsertImpl(\n tx,\n {op: 'upsert', tableName, primaryKey, value},\n schema,\n ivmBranch,\n ),\n update: (value: UpdateValue<TableSchema>) =>\n updateImpl(\n tx,\n {op: 'update', tableName, primaryKey, value},\n schema,\n ivmBranch,\n ),\n delete: (id: DeleteID<TableSchema>) =>\n deleteImpl(\n tx,\n {op: 'delete', tableName, primaryKey, value: id},\n schema,\n ivmBranch,\n ),\n };\n}\n"],"names":[],"mappings":";;;;;;;;;AAuHO,MAAM,gBAEb;AAAA,EACW,WAAW;AAAA,EACX;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,IAAgB,OAAyB,QAAiB;AACpE,SAAK,MAAM,WAAW,aAAa,MAAM,WAAW,QAAQ;AAC5D,UAAM,SAAS,cAAc,KAAK;AAElC,SAAK,SAAS;AACd,SAAK,SAAS;AAAA,MACZ;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IAAA;AAGT,UAAM,cAAc;AAAA,MAClB;AAAA,MACA,OAAO;AAAA,IAAA;AAGT,SAAK,QAAQ,sBAAsB,aAAa,MAAM;AACtD,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,IAAI,WAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,aAAqB;AACvB,WAAO,KAAK,OAAO;AAAA,EACrB;AAAA,EAEA,IAAI,SAAkC;AACpC,WAAO,KAAK,OAAO,WAAW,YAAY,eAAe;AAAA,EAC3D;AAAA,EAEA,IAAI,QAA4B;AAC9B,WAAQ,KAAK,OAAgC,QAAQ,GAAG;AAAA,EAC1D;AAAA,EAEA,IACE,OACA,SACiC;AACjC,WAAO,K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AAE,IAAI,EACV,KAAK,EAAE,KAAK,iBAkBb"}
@@ -9,6 +9,7 @@ import { using, withRead } from "../../../replicache/src/with-transactions.js";
9
9
  import { wrapIterable } from "../../../shared/src/iterables.js";
10
10
  import { must } from "../../../shared/src/must.js";
11
11
  import { MemorySource } from "../../../zql/src/ivm/memory-source.js";
12
+ import { consume } from "../../../zql/src/ivm/stream.js";
12
13
  import { ENTITIES_KEY_PREFIX, sourceNameFromKey } from "./keys.js";
13
14
  class IVMSourceBranch {
14
15
  #sources;
@@ -122,23 +123,29 @@ function applyDiffs(diffs, branch) {
122
123
  const source = must(branch.getSource(name));
123
124
  switch (diff2.op) {
124
125
  case "del":
125
- source.push({
126
- type: "remove",
127
- row: diff2.oldValue
128
- });
126
+ consume(
127
+ source.push({
128
+ type: "remove",
129
+ row: diff2.oldValue
130
+ })
131
+ );
129
132
  break;
130
133
  case "add":
131
- source.push({
132
- type: "add",
133
- row: diff2.newValue
134
- });
134
+ consume(
135
+ source.push({
136
+ type: "add",
137
+ row: diff2.newValue
138
+ })
139
+ );
135
140
  break;
136
141
  case "change":
137
- source.push({
138
- type: "edit",
139
- row: diff2.newValue,
140
- oldRow: diff2.oldValue
141
- });
142
+ consume(
143
+ source.push({
144
+ type: "edit",
145
+ row: diff2.newValue,
146
+ oldRow: diff2.oldValue
147
+ })
148
+ );
142
149
  break;
143
150
  }
144
151
  }
@@ -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,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,UAAU,MAAwC;AAChD,QAAI,KAAK,SAAS,IAAI,IAAI,GAAG;AAC3B,aAAO,KAAK,SAAS,IAAI,IAAI;AAAA,IAC/B;AAEA,UAAM,SAAS,KAAK,QAAQ,IAAI;AAChC,UAAM,SAAS,SACX,IAAI,aAAa,MAAM,OAAO,SAAS,OAAO,UAAU,IACxD;AACJ,SAAK,SAAS,IAAI,MAAM,MAAM;AAC9B,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ;AACN,S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a,oBAAoB;AACnC,YAAQ,MAAM,MAAM,MAAM,KAAK,YAAY,kBAAkB,GAAG,MAAM;AAAA,EACxE,WAAW,aAAa,cAAc;AACpC,YAAQ,MAAM,OAAO,YAAY,YAAY;AAAA,EAC/C,OAAO;AACL,YAAQ,MAAM,SAAS,OAAO,MAAM;AAAA,EACtC;AAEA,SAAO,MAAM,IAAI,EAAE;AACrB;AAEA,SAAS,WAAW,OAAoB,QAAyB;AAC/D,WACM,IAAI,iBAAiB,OAAO,qBAAqB,CAAAC,UAAQA,MAAK,GAAG,GACrE,IAAI,MAAM,QACV,KACA;AACA,UAAMA,QAAO,MAAM,CAAC;AACpB,UAAM,EAAC,QAAOA;AACd,QAAI,CAAC,IAAI,WAAW,mBAAmB,GAAG;AACxC;AAAA,IACF;AACA,UAAM,OAAO,kBAAkB,GAAG;AAClC,UAAM,SAAS,KAAK,OAAO,UAAU,IAAI,CAAC;AAC1C,YAAQA,MAAK,IAAA;AAAA,MACX,KAAK;AACH,eAAO,KAAK;AAAA,UACV,MAAM;AAAA,UACN,KAAKA,MAAK;AAAA,QAAA,CACX;AACD;AAAA,MACF,KAAK;AACH,eAAO,KAAK;AAAA,UACV,MAAM;AAAA,UACN,KAAKA,MAAK;AAAA,QAAA,CACX;AACD;AAAA,MACF,KAAK;AACH,eAAO,KAAK;AAAA,UACV,MAAM;AAAA,UACN,KAAKA,MAAK;AAAA,UACV,QAAQA,MAAK;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":";;;;;;;;;;;;;AAwCO,MAAM,gBAAgB;AAAA,EAClB;AAAA,EACA;AAAA,EACT;AAAA,EAEA,YACE,QACA,MACA,UAAiD,oBAAI,OACrD;AACA,SAAK,UAAU;AACf,SAAK,WAAW;AAChB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,UAAU,MAAwC;AAChD,QAAI,KAAK,SAAS,IAAI,IAAI,GAAG;AAC3B,aAAO,KAAK,SAAS,IAAI,IAAI;AAAA,IAC/B;AAEA,UAAM,SAAS,KAAK,QAAQ,IAAI;AAChC,UAAM,SAAS,SACX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E,oBAAoB,MAAM;AAAA,MAC1B,2BAA2B,OAAO;AAChC,eAAO;AAAA,MACT;AAAA,IAAA;AAAA,IAEFA;AAAAA,EAAc;AAGlB,MAAI;AACJ,MAAI,aAAa,oBAAoB;AACnC,YAAQ,MAAM,MAAM,MAAM,KAAK,YAAY,kBAAkB,GAAG,MAAM;AAAA,EACxE,WAAW,aAAa,cAAc;AACpC,YAAQ,MAAM,OAAO,YAAY,YAAY;AAAA,EAC/C,OAAO;AACL,YAAQ,MAAM,SAAS,OAAO,MAAM;AAAA,EACtC;AAEA,SAAO,MAAM,IAAI,EAAE;AACrB;AAEA,SAAS,WAAW,OAAoB,QAAyB;AAC/D,WACM,IAAI,iBAAiB,OAAO,qBAAqB,CAAAC,UAAQA,MAAK,GAAG,GACrE,IAAI,MAAM,QACV,KACA;AACA,UAAMA,QAAO,MAAM,CAAC;AACpB,UAAM,EAAC,QAAOA;AACd,QAAI,CAAC,IAAI,WAAW,mBAAmB,GAAG;AACxC;AAAA,IACF;AACA,UAAM,OAAO,kBAAkB,GAAG;AAClC,UAAM,SAAS,KAAK,OAAO,UAAU,IAAI,CAAC;AAC1C,YAAQA,MAAK,IAAA;AAAA,MACX,KAAK;AACH;AAAA,UACE,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,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;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,KAAK,GACrC,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,GACpC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,0BAA0B,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,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,W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
@@ -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,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,CAsCzC"}
@@ -45,13 +45,17 @@ function makeReplicacheMutator(lc, mutator, schema, context) {
45
45
  };
46
46
  }
47
47
  function makeReplicacheMutators(schema, mutators, context, lc) {
48
- const { enableLegacyMutators = true } = schema;
48
+ const { enableLegacyMutators = false } = schema;
49
49
  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
- })
50
+ [CRUD_MUTATION_NAME]: enableLegacyMutators ? makeCRUDMutator(schema) : (
51
+ // TODO(arv): This code is unreachable since the public API prevents
52
+ // calling CRUD mutators when enableLegacyMutators is false. Remove this.
53
+ (() => Promise.reject(
54
+ new ClientError({
55
+ kind: Internal,
56
+ message: "Zero CRUD mutators are not enabled."
57
+ })
58
+ ))
55
59
  )
56
60
  };
57
61
  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,IAC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ACL;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
+ {"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 = 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","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;AAAA,MAEJ,OAAO;AACL,wBAAgB,SAAS,IAAI;AAAA,MAC/B;AACA,WAAK,IAAA;AAAA,IACP;AAAA,EACF;AAEA,kBAAgB,UAAU,EAAE;AAC9B;AAEA,SAAS,sBAMP,IACA,SACA,QACA,SACqE;AACrE,SAAO,OACL,OACA,SACkB;AAClB,UAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAEhD,UAAM,QAAQ,GAAG;AAAA,MACf;AAAA,MACA,K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@@ -1,4 +1,4 @@
1
- const version = "0.25.0-canary.13";
1
+ const version = "0.25.0-canary.15";
2
2
  export {
3
3
  version
4
4
  };
@@ -273,7 +273,7 @@ class Zero {
273
273
  (error) => this.#disconnect(lc, error)
274
274
  );
275
275
  this.#ivmMain = new IVMSourceBranch(schema.tables);
276
- const { enableLegacyQueries = true } = schema;
276
+ const { enableLegacyQueries = false } = schema;
277
277
  const replicacheMutators = makeReplicacheMutators(
278
278
  schema,
279
279
  options.mutators,