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

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 (100) hide show
  1. package/out/shared/src/deep-merge.d.ts +6 -4
  2. package/out/shared/src/deep-merge.d.ts.map +1 -1
  3. package/out/shared/src/deep-merge.js +2 -1
  4. package/out/shared/src/deep-merge.js.map +1 -1
  5. package/out/z2s/src/compiler.d.ts.map +1 -1
  6. package/out/z2s/src/compiler.js +4 -2
  7. package/out/z2s/src/compiler.js.map +1 -1
  8. package/out/zero/package.json.js +1 -1
  9. package/out/zero/src/pg.js +4 -3
  10. package/out/zero/src/server.js +4 -3
  11. package/out/zero/src/zero.js +11 -3
  12. package/out/zero/src/zero.js.map +1 -1
  13. package/out/zero-cache/src/config/zero-config.d.ts +8 -0
  14. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  15. package/out/zero-cache/src/config/zero-config.js +16 -0
  16. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  17. package/out/zero-cache/src/server/otel-diag-logger.d.ts.map +1 -1
  18. package/out/zero-cache/src/server/otel-diag-logger.js +1 -22
  19. package/out/zero-cache/src/server/otel-diag-logger.js.map +1 -1
  20. package/out/zero-cache/src/services/litestream/commands.js +3 -2
  21. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  22. package/out/zero-client/src/client/crud-impl.d.ts +11 -0
  23. package/out/zero-client/src/client/crud-impl.d.ts.map +1 -0
  24. package/out/zero-client/src/client/crud-impl.js +102 -0
  25. package/out/zero-client/src/client/crud-impl.js.map +1 -0
  26. package/out/zero-client/src/client/crud.d.ts +4 -37
  27. package/out/zero-client/src/client/crud.d.ts.map +1 -1
  28. package/out/zero-client/src/client/crud.js +18 -114
  29. package/out/zero-client/src/client/crud.js.map +1 -1
  30. package/out/zero-client/src/client/custom.d.ts +2 -2
  31. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  32. package/out/zero-client/src/client/custom.js +5 -43
  33. package/out/zero-client/src/client/custom.js.map +1 -1
  34. package/out/zero-client/src/client/make-replicache-mutators.d.ts.map +1 -1
  35. package/out/zero-client/src/client/make-replicache-mutators.js +4 -1
  36. package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
  37. package/out/zero-client/src/client/version.js +1 -1
  38. package/out/zero-client/src/client/zero.d.ts +9 -7
  39. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  40. package/out/zero-client/src/client/zero.js +10 -3
  41. package/out/zero-client/src/client/zero.js.map +1 -1
  42. package/out/zero-client/src/mod.d.ts +7 -6
  43. package/out/zero-client/src/mod.d.ts.map +1 -1
  44. package/out/zero-react/src/use-query.d.ts +6 -4
  45. package/out/zero-react/src/use-query.d.ts.map +1 -1
  46. package/out/zero-react/src/use-query.js +2 -1
  47. package/out/zero-react/src/use-query.js.map +1 -1
  48. package/out/zero-server/src/custom.d.ts +44 -5
  49. package/out/zero-server/src/custom.d.ts.map +1 -1
  50. package/out/zero-server/src/custom.js +96 -17
  51. package/out/zero-server/src/custom.js.map +1 -1
  52. package/out/zero-server/src/zql-database.d.ts +1 -1
  53. package/out/zero-server/src/zql-database.d.ts.map +1 -1
  54. package/out/zero-server/src/zql-database.js +5 -13
  55. package/out/zero-server/src/zql-database.js.map +1 -1
  56. package/out/zero-solid/src/solid-view.d.ts +6 -1
  57. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  58. package/out/zero-solid/src/solid-view.js +1 -32
  59. package/out/zero-solid/src/solid-view.js.map +1 -1
  60. package/out/zero-solid/src/use-query.d.ts +5 -3
  61. package/out/zero-solid/src/use-query.d.ts.map +1 -1
  62. package/out/zero-solid/src/use-query.js +5 -1
  63. package/out/zero-solid/src/use-query.js.map +1 -1
  64. package/out/zql/src/mutate/crud.d.ts +139 -0
  65. package/out/zql/src/mutate/crud.d.ts.map +1 -0
  66. package/out/zql/src/mutate/crud.js +53 -0
  67. package/out/zql/src/mutate/crud.js.map +1 -0
  68. package/out/zql/src/mutate/custom.d.ts +12 -53
  69. package/out/zql/src/mutate/custom.d.ts.map +1 -1
  70. package/out/zql/src/mutate/custom.js +1 -5
  71. package/out/zql/src/mutate/custom.js.map +1 -1
  72. package/out/zql/src/mutate/mutator-registry.d.ts +33 -32
  73. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  74. package/out/zql/src/mutate/mutator-registry.js +25 -25
  75. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  76. package/out/zql/src/mutate/mutator.d.ts +42 -62
  77. package/out/zql/src/mutate/mutator.d.ts.map +1 -1
  78. package/out/zql/src/mutate/mutator.js +12 -8
  79. package/out/zql/src/mutate/mutator.js.map +1 -1
  80. package/out/zql/src/query/abstract-query.d.ts +2 -3
  81. package/out/zql/src/query/abstract-query.d.ts.map +1 -1
  82. package/out/zql/src/query/abstract-query.js +0 -3
  83. package/out/zql/src/query/abstract-query.js.map +1 -1
  84. package/out/zql/src/query/query-impl.d.ts +2 -2
  85. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  86. package/out/zql/src/query/query-impl.js.map +1 -1
  87. package/out/zql/src/query/query-registry.d.ts +87 -79
  88. package/out/zql/src/query/query-registry.d.ts.map +1 -1
  89. package/out/zql/src/query/query-registry.js +44 -38
  90. package/out/zql/src/query/query-registry.js.map +1 -1
  91. package/out/zql/src/query/query.d.ts +3 -18
  92. package/out/zql/src/query/query.d.ts.map +1 -1
  93. package/out/zql/src/query/runnable-query-impl.d.ts +2 -2
  94. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  95. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  96. package/out/zql/src/query/static-query.d.ts +1 -0
  97. package/out/zql/src/query/static-query.d.ts.map +1 -1
  98. package/out/zql/src/query/static-query.js +2 -2
  99. package/out/zql/src/query/static-query.js.map +1 -1
  100. package/package.json +1 -1
@@ -1,8 +1,6 @@
1
- import { consume } from "../../../zql/src/ivm/stream.js";
2
- import { must } from "../../../shared/src/must.js";
3
1
  import { promiseVoid } from "../../../shared/src/resolved-promises.js";
4
2
  import { CRUD_MUTATION_NAME } from "../../../zero-protocol/src/push.js";
5
- import { toPrimaryKeyString } from "./keys.js";
3
+ import * as crudImpl from "./crud-impl.js";
6
4
  function makeCRUDMutate(schema, repMutate, mutate) {
7
5
  if (schema.enableLegacyMutators !== true) {
8
6
  return void 0;
@@ -112,124 +110,30 @@ function makeBatchCRUDMutate(tableName, schema, ops) {
112
110
  }
113
111
  };
114
112
  }
113
+ function makeCRUDExecutor(tx, schema, ivmBranch) {
114
+ return (tableName, kind, value) => {
115
+ const { primaryKey } = schema.tables[tableName];
116
+ return crudImpl[kind](
117
+ tx,
118
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
119
+ { op: kind, tableName, primaryKey, value },
120
+ schema,
121
+ ivmBranch
122
+ );
123
+ };
124
+ }
115
125
  function makeCRUDMutator(schema) {
116
- return async function zeroCRUDMutator(tx, crudArg) {
126
+ return async (tx, crudArg) => {
127
+ const executor = makeCRUDExecutor(tx, schema, void 0);
117
128
  for (const op of crudArg.ops) {
118
- switch (op.op) {
119
- case "insert":
120
- await insertImpl(tx, op, schema, void 0);
121
- break;
122
- case "upsert":
123
- await upsertImpl(tx, op, schema, void 0);
124
- break;
125
- case "update":
126
- await updateImpl(tx, op, schema, void 0);
127
- break;
128
- case "delete":
129
- await deleteImpl(tx, op, schema, void 0);
130
- break;
131
- }
129
+ await executor(op.tableName, op.op, op.value);
132
130
  }
133
131
  };
134
132
  }
135
- function defaultOptionalFieldsToNull(schema, value) {
136
- let rv = value;
137
- for (const name in schema.columns) {
138
- if (rv[name] === void 0) {
139
- rv = { ...rv, [name]: null };
140
- }
141
- }
142
- return rv;
143
- }
144
- async function insertImpl(tx, arg, schema, ivmBranch) {
145
- const key = toPrimaryKeyString(
146
- arg.tableName,
147
- schema.tables[arg.tableName].primaryKey,
148
- arg.value
149
- );
150
- if (!await tx.has(key)) {
151
- const val = defaultOptionalFieldsToNull(
152
- schema.tables[arg.tableName],
153
- arg.value
154
- );
155
- await tx.set(key, val);
156
- if (ivmBranch) {
157
- consume(
158
- must(ivmBranch.getSource(arg.tableName)).push({
159
- type: "add",
160
- row: arg.value
161
- })
162
- );
163
- }
164
- }
165
- }
166
- async function upsertImpl(tx, arg, schema, ivmBranch) {
167
- const key = toPrimaryKeyString(
168
- arg.tableName,
169
- schema.tables[arg.tableName].primaryKey,
170
- arg.value
171
- );
172
- if (await tx.has(key)) {
173
- await updateImpl(tx, { ...arg }, schema, ivmBranch);
174
- } else {
175
- await insertImpl(tx, { ...arg }, schema, ivmBranch);
176
- }
177
- }
178
- async function updateImpl(tx, arg, schema, ivmBranch) {
179
- const key = toPrimaryKeyString(
180
- arg.tableName,
181
- schema.tables[arg.tableName].primaryKey,
182
- arg.value
183
- );
184
- const prev = await tx.get(key);
185
- if (prev === void 0) {
186
- return;
187
- }
188
- const update = arg.value;
189
- const next = { ...prev };
190
- for (const k in update) {
191
- if (update[k] !== void 0) {
192
- next[k] = update[k];
193
- }
194
- }
195
- await tx.set(key, next);
196
- if (ivmBranch) {
197
- consume(
198
- must(ivmBranch.getSource(arg.tableName)).push({
199
- type: "edit",
200
- oldRow: prev,
201
- row: next
202
- })
203
- );
204
- }
205
- }
206
- async function deleteImpl(tx, arg, schema, ivmBranch) {
207
- const key = toPrimaryKeyString(
208
- arg.tableName,
209
- schema.tables[arg.tableName].primaryKey,
210
- arg.value
211
- );
212
- const prev = await tx.get(key);
213
- if (prev === void 0) {
214
- return;
215
- }
216
- await tx.del(key);
217
- if (ivmBranch) {
218
- consume(
219
- must(ivmBranch.getSource(arg.tableName)).push({
220
- type: "remove",
221
- row: prev
222
- })
223
- );
224
- }
225
- }
226
133
  export {
227
- deleteImpl,
228
- insertImpl,
229
134
  makeBatchCRUDMutate,
135
+ makeCRUDExecutor,
230
136
  makeCRUDMutate,
231
- makeCRUDMutator,
232
- updateImpl,
233
- upsertImpl
137
+ makeCRUDMutator
234
138
  };
235
139
  //# sourceMappingURL=crud.js.map
@@ -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 {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,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,qBACP,WACA,YACA,UAC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IAAI,SAAS,EAAE;AAAA,IAC7B,IAAI;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;AAAA,MACE,KAAK,UAAU,UAAU,IAAI,SAAS,CAAC,EAAE,KAAK;AAAA,QAC5C,MAAM;AAAA,QACN,KAAK;AAAA,MAAA,CACN;AAAA,IAAA;AAAA,EAEL;AACF;"}
1
+ {"version":3,"file":"crud.js","sources":["../../../../../zero-client/src/client/crud.ts"],"sourcesContent":["import {promiseVoid} from '../../../shared/src/resolved-promises.ts';\nimport type {MaybePromise} from '../../../shared/src/types.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 {CRUDExecutor, TableMutator} from '../../../zql/src/mutate/crud.ts';\nimport type {\n DeleteID,\n InsertValue,\n UpdateValue,\n UpsertValue,\n} from '../../../zql/src/mutate/custom.ts';\nimport * as crudImpl from './crud-impl.ts';\nimport type {IVMSourceBranch} from './ivm-branch.ts';\nimport type {MutatorDefs, WriteTransaction} from './replicache-types.ts';\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 `{insert, 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\nexport function makeCRUDExecutor(\n tx: WriteTransaction,\n schema: Schema,\n ivmBranch: IVMSourceBranch | undefined,\n): CRUDExecutor {\n return (tableName, kind, value) => {\n const {primaryKey} = schema.tables[tableName];\n return crudImpl[kind](\n tx,\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n {op: kind, tableName, primaryKey, value} as any,\n schema,\n ivmBranch,\n );\n };\n}\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 (\n tx: WriteTransaction,\n crudArg: CRUDMutationArg,\n ): Promise<void> => {\n const executor = makeCRUDExecutor(tx, schema, undefined);\n for (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AAgB,QAA6B;AAC3D,SAAO,OACL,IACA,YACkB;AAClB,UAAM,WAAW,iBAAiB,IAAI,QAAQ,MAAS;AACvD,eAAW,MAAM,QAAQ,KAAK;AAC5B,YAAM,SAAS,GAAG,WAAW,GAAG,IAAI,GAAG,KAAK;AAAA,IAC9C;AAAA,EACF;AACF;"}
@@ -3,7 +3,7 @@ import type { ZeroTxData } from '../../../replicache/src/replicache-options.ts';
3
3
  import type { ReadonlyJSONValue } from '../../../shared/src/json.ts';
4
4
  import type { DefaultSchema } from '../../../zero-types/src/default-types.ts';
5
5
  import type { Schema } from '../../../zero-types/src/schema.ts';
6
- import type { ClientTransaction, SchemaCRUD, Transaction } from '../../../zql/src/mutate/custom.ts';
6
+ import type { ClientTransaction, MutateCRUD, Transaction } from '../../../zql/src/mutate/custom.ts';
7
7
  import { type HumanReadable, type Query, type RunOptions } from '../../../zql/src/query/query.ts';
8
8
  import type { SchemaQuery } from '../../../zql/src/query/schema-query.ts';
9
9
  import type { ClientID } from '../types/client-state.ts';
@@ -54,7 +54,7 @@ export type MakeCustomMutatorInterface<TSchema extends Schema, F> = F extends (t
54
54
  export declare class TransactionImpl<TSchema extends Schema = DefaultSchema> implements ClientTransaction<TSchema> {
55
55
  #private;
56
56
  readonly location = "client";
57
- readonly mutate: SchemaCRUD<TSchema>;
57
+ readonly mutate: MutateCRUD<TSchema>;
58
58
  readonly query: SchemaQuery<TSchema>;
59
59
  constructor(lc: LogContext, repTx: WriteTransaction, schema: TSchema);
60
60
  get clientID(): ClientID;
@@ -1 +1 @@
1
- {"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/custom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,+CAA+C,CAAC;AAI9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAKnE,OAAO,KAAK,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ache/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";
5
4
  import { emptyFunction } from "../../../shared/src/sentinels.js";
5
+ import { makeMutateCRUDFunction } from "../../../zql/src/mutate/crud.js";
6
6
  import { createRunnableBuilder } from "../../../zql/src/query/create-builder.js";
7
7
  import "../../../zero-protocol/src/ast.js";
8
8
  import { ZeroContext } from "./context.js";
9
- import { deleteImpl, updateImpl, upsertImpl, insertImpl } from "./crud.js";
9
+ import { makeCRUDExecutor } from "./crud.js";
10
10
  class TransactionImpl {
11
11
  location = "client";
12
12
  mutate;
@@ -16,12 +16,10 @@ class TransactionImpl {
16
16
  constructor(lc, repTx, schema) {
17
17
  must(repTx.reason === "initial" || repTx.reason === "rebase");
18
18
  const txData = getZeroTxData(repTx);
19
+ const ivmBranch = txData.ivmSources;
19
20
  this.#repTx = repTx;
20
- this.mutate = makeSchemaCRUD(
21
- schema,
22
- repTx,
23
- txData.ivmSources
24
- );
21
+ const executor = makeCRUDExecutor(repTx, schema, ivmBranch);
22
+ this.mutate = makeMutateCRUDFunction(schema, executor);
25
23
  const zeroContext = newZeroContext(
26
24
  lc,
27
25
  txData.ivmSources
@@ -58,12 +56,6 @@ function makeReplicacheMutator(lc, mutator, schema, context) {
58
56
  await mutator(tx, args, context);
59
57
  };
60
58
  }
61
- function makeSchemaCRUD(schema, tx, ivmBranch) {
62
- return recordProxy(
63
- schema.tables,
64
- (_tableSchema, tableName) => makeTableCRUD(schema, tableName, tx, ivmBranch)
65
- );
66
- }
67
59
  function assertValidRunOptions(options) {
68
60
  assert(
69
61
  options?.type !== "complete",
@@ -84,36 +76,6 @@ function newZeroContext(lc, ivmBranch) {
84
76
  assertValidRunOptions
85
77
  );
86
78
  }
87
- function makeTableCRUD(schema, tableName, tx, ivmBranch) {
88
- const table = must(schema.tables[tableName]);
89
- const { primaryKey } = table;
90
- return {
91
- insert: (value) => insertImpl(
92
- tx,
93
- { tableName, value },
94
- schema,
95
- ivmBranch
96
- ),
97
- upsert: (value) => upsertImpl(
98
- tx,
99
- { op: "upsert", tableName, primaryKey, value },
100
- schema,
101
- ivmBranch
102
- ),
103
- update: (value) => updateImpl(
104
- tx,
105
- { tableName, value },
106
- schema,
107
- ivmBranch
108
- ),
109
- delete: (id) => deleteImpl(
110
- tx,
111
- { tableName, value: id },
112
- schema,
113
- ivmBranch
114
- )
115
- };
116
- }
117
79
  export {
118
80
  TransactionImpl,
119
81
  getZeroTxData,
@@ -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 {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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AA;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 {emptyFunction} from '../../../shared/src/sentinels.ts';\nimport type {DefaultSchema} from '../../../zero-types/src/default-types.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {makeMutateCRUDFunction} from '../../../zql/src/mutate/crud.ts';\nimport type {\n ClientTransaction,\n MutateCRUD,\n Transaction,\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 {makeCRUDExecutor} 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: MutateCRUD<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 const ivmBranch = txData.ivmSources as IVMSourceBranch;\n\n this.#repTx = repTx;\n\n const executor = makeCRUDExecutor(repTx, schema, ivmBranch);\n this.mutate = makeMutateCRUDFunction(schema, executor);\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 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"],"names":[],"mappings":";;;;;;;;;AAkHO,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;AAClC,UAAM,YAAY,OAAO;AAEzB,SAAK,SAAS;AAEd,UAAM,WAAW,iBAAiB,OAAO,QAAQ,SAAS;AAC1D,SAAK,SAAS,uBAAuB,QAAQ,QAAQ;AAErD,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,KAAK,aAAa,IAAI,OAAO,OAAO;AAAA,EAC7C;AACF;AAEO,SAAS,cAAc,OAAqC;AACjE,QAAM,SAAS;AAAA,IACZ,MAA+B,QAAQ;AAAA,IACxC;AAAA,EAAA;AAEF,SAAO;AACT;AAEO,SAAS,sBAKd,IACA,SACA,QACA,SACqE;AACrE,SAAO,OACL,OACA,SACkB;AAClB,UAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,UAAM,QAAQ,IAAI,MAAM,OAAO;AAAA,EACjC;AACF;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;"}
@@ -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,CAsCzC"}
1
+ {"version":3,"file":"make-replicache-mutators.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AACjD,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,kCAAkC,CAAC;AAGlE,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAkB,KAAK,WAAW,EAAC,MAAM,WAAW,CAAC;AAC5D,OAAO,KAAK,EAAC,iBAAiB,EAAoB,MAAM,aAAa,CAAC;AAQtE,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC1D,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,CAAC,EACV,QAAQ,EAAE,kBAAkB,GAAG,iBAAiB,EAChD,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACpC,IAAI,CAmCN;AA2BD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAC9D,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,kBAAkB,GAAG,iBAAiB,GAAG,SAAS,EAC5D,OAAO,EAAE,CAAC,EACV,EAAE,EAAE,UAAU,GACb,WAAW,GAAG;IAAC,UAAU,EAAE,WAAW,CAAA;CAAC,CAsCzC"}
@@ -8,6 +8,9 @@ import { ClientError } from "./error.js";
8
8
  function extendReplicacheMutators(lc, context, mutators, schema, mutateObject) {
9
9
  const processMutators = (mutators2, path) => {
10
10
  for (const [key, mutator] of Object.entries(mutators2)) {
11
+ if (key === "~") {
12
+ continue;
13
+ }
11
14
  path.push(key);
12
15
  if (isMutator(mutator)) {
13
16
  const fullKey = customMutatorKey(".", path);
@@ -26,7 +29,7 @@ function extendReplicacheMutators(lc, context, mutators, schema, mutateObject) {
26
29
  schema,
27
30
  context
28
31
  );
29
- } else {
32
+ } else if (mutator !== null && typeof mutator === "object") {
30
33
  processMutators(mutator, path);
31
34
  }
32
35
  path.pop();
@@ -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 = 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;AAA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B;AAClB,gBAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,iBAAO,MAAM,GAAG,EAAC,MAAM,KAAK,SAAS,IAAG;AAAA,QAC1C;AAAA,MACF,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AAEtD,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACA,OAAK,QAAQ;AACf;"}
1
+ {"version":3,"file":"make-replicache-mutators.js","sources":["../../../../../zero-client/src/client/make-replicache-mutators.ts"],"sourcesContent":["import type {LogContext} from '@rocicorp/logger';\nimport type {MutatorDefs} from '../../../replicache/src/types.ts';\nimport type {ReadonlyJSONValue} from '../../../shared/src/json.ts';\nimport {CRUD_MUTATION_NAME} from '../../../zero-protocol/src/push.ts';\nimport type {Schema} from '../../../zero-types/src/schema.ts';\nimport {customMutatorKey} from '../../../zql/src/mutate/custom.ts';\nimport {\n isMutatorRegistry,\n type AnyMutatorRegistry,\n} from '../../../zql/src/mutate/mutator-registry.ts';\nimport {type Mutator} from '../../../zql/src/mutate/mutator.ts';\nimport {ClientErrorKind} from './client-error-kind.ts';\nimport {makeCRUDMutator, type CRUDMutator} from './crud.ts';\nimport type {CustomMutatorDefs, CustomMutatorImpl} from './custom.ts';\nimport {\n makeReplicacheMutator as makeReplicacheMutatorLegacy,\n TransactionImpl,\n} from './custom.ts';\nimport {ClientError} from './error.ts';\nimport type {WriteTransaction} from './replicache-types.ts';\n\nexport function extendReplicacheMutators<S extends Schema, C>(\n lc: LogContext,\n context: C,\n mutators: AnyMutatorRegistry | CustomMutatorDefs,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n // Recursively process mutator definitions at arbitrary depth\n const processMutators = (mutators: object, path: string[]) => {\n for (const [key, mutator] of Object.entries(mutators)) {\n if (key === '~') {\n // Skip phantom type\n continue;\n }\n\n path.push(key);\n if (isMutator(mutator)) {\n const fullKey = customMutatorKey('.', path);\n mutateObject[fullKey] = makeReplicacheMutator(\n lc,\n mutator,\n schema,\n context,\n );\n } else if (typeof mutator === 'function') {\n const fullKey = customMutatorKey('|', path);\n mutateObject[fullKey] = makeReplicacheMutatorLegacy(\n lc,\n // oxlint-disable-next-line no-explicit-any\n mutator as CustomMutatorImpl<any>,\n schema,\n context,\n );\n } else if (mutator !== null && typeof mutator === 'object') {\n processMutators(mutator, path);\n }\n path.pop();\n }\n };\n\n processMutators(mutators, []);\n}\n\nfunction makeReplicacheMutator<\n TArgs extends ReadonlyJSONValue | undefined,\n TSchema extends Schema,\n TContext,\n TWrappedTransaction,\n>(\n lc: LogContext,\n mutator: Mutator<TArgs, TSchema, TContext, TWrappedTransaction>,\n schema: TSchema,\n context: TContext,\n): (repTx: WriteTransaction, args: ReadonlyJSONValue) => Promise<void> {\n return async (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n // fn does input validation internally\n await mutator.fn({\n args: args as TArgs,\n ctx: context,\n tx: tx,\n });\n };\n}\n\n/**\n * Creates Replicache mutators from mutator definitions.\n *\n * This function processes mutator definitions at arbitrary depth, supporting both\n * new-style mutator definitions and legacy custom mutator implementations. It creates\n * a mutator object with the CRUD mutator and any provided custom mutators, with keys\n * generated based on their path in the mutator definition hierarchy.\n *\n * @template S - The schema type that defines the structure of the data\n * @template C - The type of the context object passed to mutators\n *\n * @param schema - The schema instance used for validation and type checking\n * @param mutators - The mutator definitions to process, can be nested objects or custom mutator definitions\n * @param context - The context to be passed to mutators\n * @param lc - The log context used for logging operations\n *\n * @returns A mutator definitions object containing the CRUD mutator and any custom mutators\n *\n * @remarks\n * - New-style mutator definitions use '.' as a separator in their keys\n * - Legacy custom mutator implementations use '|' as a separator in their keys\n * - The CRUD mutator can be disabled by setting `enableLegacyMutators: false` in the schema\n */\nexport function makeReplicacheMutators<const S extends Schema, C>(\n schema: S,\n mutators: AnyMutatorRegistry | CustomMutatorDefs | undefined,\n context: C,\n lc: LogContext,\n): MutatorDefs & {_zero_crud: CRUDMutator} {\n const {enableLegacyMutators = false} = schema;\n\n const replicacheMutators = {\n [CRUD_MUTATION_NAME]: enableLegacyMutators\n ? makeCRUDMutator(schema)\n : // TODO(arv): This code is unreachable since the public API prevents\n // calling CRUD mutators when enableLegacyMutators is false. Remove this.\n () =>\n Promise.reject(\n new ClientError({\n kind: ClientErrorKind.Internal,\n message: 'Zero CRUD mutators are not enabled.',\n }),\n ),\n };\n\n if (mutators) {\n if (isMutatorRegistry(mutators)) {\n extendFromMutatorRegistry(\n lc,\n context,\n mutators,\n schema,\n replicacheMutators,\n );\n } else {\n extendReplicacheMutators(\n lc,\n context,\n mutators as CustomMutatorDefs,\n schema,\n replicacheMutators,\n );\n }\n }\n\n return replicacheMutators;\n}\n\n/**\n * Checks if a value is a Mutator (from MutatorRegistry).\n * Mutators have `mutatorName` and `fn` properties.\n */\nfunction isMutator(\n value: unknown,\n // oxlint-disable-next-line no-explicit-any\n): value is Mutator<any, any, any> {\n return (\n typeof value === 'function' &&\n 'mutatorName' in value &&\n typeof value.mutatorName === 'string' &&\n 'fn' in value &&\n typeof value.fn === 'function'\n );\n}\n\n/**\n * Extends replicache mutators from a MutatorRegistry.\n * Walks the registry tree and wraps each Mutator.fn for Replicache.\n */\nfunction extendFromMutatorRegistry<S extends Schema, C>(\n lc: LogContext,\n context: C,\n registry: AnyMutatorRegistry,\n schema: S,\n mutateObject: Record<string, unknown>,\n): void {\n const walk = (node: unknown) => {\n if (typeof node !== 'object' || node === null) {\n return;\n }\n for (const value of Object.values(node)) {\n if (isMutator(value)) {\n // Mutator.fn already handles validation internally\n mutateObject[value.mutatorName] = (\n repTx: WriteTransaction,\n args: ReadonlyJSONValue,\n ): Promise<void> => {\n const tx = new TransactionImpl(lc, repTx, schema);\n return value.fn({args, ctx: context, tx});\n };\n } else if (typeof value === 'object' && value !== null) {\n // Nested namespace\n walk(value);\n }\n }\n };\n walk(registry);\n}\n"],"names":["mutators","makeReplicacheMutatorLegacy","ClientErrorKind.Internal"],"mapp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AAU;AACZ,QAAI,kBAAkB,QAAQ,GAAG;AAC/B;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ,OAAO;AACL;AAAA,QACE;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAAA,IAEJ;AAAA,EACF;AAEA,SAAO;AACT;AAMA,SAAS,UACP,OAEiC;AACjC,SACE,OAAO,UAAU,cACjB,iBAAiB,SACjB,OAAO,MAAM,gBAAgB,YAC7B,QAAQ,SACR,OAAO,MAAM,OAAO;AAExB;AAMA,SAAS,0BACP,IACA,SACA,UACA,QACA,cACM;AACN,QAAM,OAAO,CAAC,SAAkB;AAC9B,QAAI,OAAO,SAAS,YAAY,SAAS,MAAM;AAC7C;AAAA,IACF;AACA,eAAW,SAAS,OAAO,OAAO,IAAI,GAAG;AACvC,UAAI,UAAU,KAAK,GAAG;AAEpB,qBAAa,MAAM,WAAW,IAAI,CAChC,OACA,SACkB;AAClB,gBAAM,KAAK,IAAI,gBAAgB,IAAI,OAAO,MAAM;AAChD,iBAAO,MAAM,GAAG,EAAC,MAAM,KAAK,SAAS,IAAG;AAAA,QAC1C;AAAA,MACF,WAAW,OAAO,UAAU,YAAY,UAAU,MAAM;AAEtD,aAAK,KAAK;AAAA,MACZ;AAAA,IACF;AAAA,EACF;AACA,OAAK,QAAQ;AACf;"}
@@ -1,4 +1,4 @@
1
- const version = "0.25.0-canary.15";
1
+ const version = "0.25.0-canary.18";
2
2
  export {
3
3
  version
4
4
  };
@@ -5,6 +5,7 @@ import type { Puller } from '../../../replicache/src/puller.ts';
5
5
  import type { Pusher } from '../../../replicache/src/pusher.ts';
6
6
  import type { ClientGroupID, ClientID } from '../../../replicache/src/sync/ids.ts';
7
7
  import type { MutatorDefs } from '../../../replicache/src/types.ts';
8
+ import type { ReadonlyJSONValue } from '../../../shared/src/json.ts';
8
9
  import { Subscribable } from '../../../shared/src/subscribable.ts';
9
10
  import { type ClientSchema } from '../../../zero-protocol/src/client-schema.ts';
10
11
  import type { DeleteClientsBody } from '../../../zero-protocol/src/delete-clients.ts';
@@ -13,9 +14,10 @@ import type { NullableVersion } from '../../../zero-protocol/src/version.ts';
13
14
  import type { DefaultContext, DefaultSchema } from '../../../zero-types/src/default-types.ts';
14
15
  import type { Schema } from '../../../zero-types/src/schema.ts';
15
16
  import type { ViewFactory } from '../../../zql/src/ivm/view.ts';
16
- import type { MutationRequest } from '../../../zql/src/mutate/mutator.ts';
17
+ import type { MutateRequest } from '../../../zql/src/mutate/mutator.ts';
17
18
  import type { QueryDelegate } from '../../../zql/src/query/query-delegate.ts';
18
- import { type HumanReadable, type MaterializeOptions, type PreloadOptions, type PullRow, type RunOptions, type ToQuery } from '../../../zql/src/query/query.ts';
19
+ import { type QueryOrQueryRequest } from '../../../zql/src/query/query-registry.ts';
20
+ import { type HumanReadable, type MaterializeOptions, type PreloadOptions, type PullRow, type RunOptions } from '../../../zql/src/query/query.ts';
19
21
  import type { SchemaQuery } from '../../../zql/src/query/schema-query.ts';
20
22
  import type { TypedView } from '../../../zql/src/query/typed-view.ts';
21
23
  import { ActiveClientsManager } from './active-clients-manager.ts';
@@ -114,7 +116,7 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
114
116
  * // Now the data is cached and can be used immediately
115
117
  * ```
116
118
  */
117
- preload<TTable extends keyof S['tables'] & string, TReturn extends PullRow<TTable, S>>(query: ToQuery<TTable, S, TReturn, C>, options?: PreloadOptions): {
119
+ preload<TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn extends PullRow<TTable, S>>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, options?: PreloadOptions): {
118
120
  cleanup: () => void;
119
121
  complete: Promise<void>;
120
122
  };
@@ -138,7 +140,7 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
138
140
  * const cachedUsers = await zero.run(userQuery, {type: 'unknown'});
139
141
  * ```
140
142
  */
141
- run<TTable extends keyof S['tables'] & string, TReturn>(query: ToQuery<TTable, S, TReturn, C>, runOptions?: RunOptions): Promise<HumanReadable<TReturn>>;
143
+ run<TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, runOptions?: RunOptions): Promise<HumanReadable<TReturn>>;
142
144
  get context(): C;
143
145
  /**
144
146
  * Creates a materialized view of a query that stays synchronized with the database.
@@ -164,8 +166,8 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
164
166
  * const customView = zero.materialize(userQuery, (query) => new MyCustomView(query));
165
167
  * ```
166
168
  */
167
- materialize<TTable extends keyof S['tables'] & string, TReturn>(query: ToQuery<TTable, S, TReturn, C>, options?: MaterializeOptions): TypedView<HumanReadable<TReturn>>;
168
- materialize<T, TTable extends keyof S['tables'] & string, TReturn>(query: ToQuery<TTable, S, TReturn, C>, factory: ViewFactory<TTable, S, TReturn, T>, options?: MaterializeOptions): T;
169
+ materialize<TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, options?: MaterializeOptions): TypedView<HumanReadable<TReturn>>;
170
+ materialize<T, TTable extends keyof S['tables'] & string, TInput extends ReadonlyJSONValue | undefined, TOutput extends ReadonlyJSONValue | undefined, TReturn>(query: QueryOrQueryRequest<TTable, TInput, TOutput, S, TReturn, C>, factory: ViewFactory<TTable, S, TReturn, T>, options?: MaterializeOptions): T;
169
171
  /**
170
172
  * The server URL that this Zero instance is configured with.
171
173
  */
@@ -223,7 +225,7 @@ export declare class Zero<const S extends Schema = DefaultSchema, MD extends Cus
223
225
  * await zero.mutate.issue.update({id: '1', title: 'Updated title'});
224
226
  * ```
225
227
  */
226
- readonly mutate: MakeMutatePropertyType<S, MD, C> & ((mr: MutationRequest<any, S, C, any>) => MutatorResult);
228
+ readonly mutate: MakeMutatePropertyType<S, MD, C> & ((mr: MutateRequest<any, S, C, any>) => MutatorResult);
227
229
  /**
228
230
  * Provides a way to batch multiple CRUD mutations together:
229
231
  *
@@ -1 +1 @@
1
- {"version":3,"file":"zero.d.ts","sourceRoot":"","sources":["../../../../../zero-client/src/client/zero.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAC,KAAK,QAAQ,EAAW,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EACL,cAAc,EAEf,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAC5E,OAAO,KAAK,EAAC,MAAM,EAAe,MAAM,mCAAmC,CAAC;AAE5E,OAAO,KAAK,EACV,aAAa,EACb,QAAQ,EACT,MAAM,qCAAqC,CAAC;AAG7C,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,kCAAkC,CAAC;AAc1C,OAAO,EAAC,YAAY,EAAC,MAAM,qCAAqC,CAAC;AAGjE,OAAO,EAAC,KAAK,YAAY,EAAC,MAAM,6CAA6C,CAAC;AAG9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,8CAA8C,CAAC;AA6BpF,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,6CAA6C,CAAC;AAElF,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,uCAAuC,CAAC;AAO3E,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACd,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,mCAAmC,CAAC;AAC9D,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAK9D,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,oCAAoC,CAAC;AAO5C,OAAO,KAAK,EAAC,aAAa,EA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S,EAC/B,YAAY,EAAE,MAAM,GAAG,SAAS,EAChC,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3D,oBAAoB,EAAE,IAAI,CAAC,oBAAoB,EAAE,eAAe,CAAC,EACjE,eAAe,SAAW,GACzB,OAAO,CACR;IACE,SAAS;IACT,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,GAAG,SAAS;IACzC,iBAAiB,GAAG,SAAS;CAC9B,CACF,CA+EA"}
@@ -29,6 +29,7 @@ import { clientToServer } from "../../../zero-schema/src/name-mapper.js";
29
29
  import { iterateMutators, isMutatorRegistry } from "../../../zql/src/mutate/mutator-registry.js";
30
30
  import { createRunnableBuilder } from "../../../zql/src/query/create-builder.js";
31
31
  import { isClientMetric } from "../../../zql/src/query/metrics-delegate.js";
32
+ import { addContextToQuery } from "../../../zql/src/query/query-registry.js";
32
33
  import "../../../zero-protocol/src/ast.js";
33
34
  import { nanoid } from "../util/nanoid.js";
34
35
  import { send } from "../util/socket.js";
@@ -525,7 +526,10 @@ class Zero {
525
526
  * ```
526
527
  */
527
528
  preload(query, options) {
528
- return this.#zeroContext.preload(query.toQuery(this.context), options);
529
+ return this.#zeroContext.preload(
530
+ addContextToQuery(query, this.context),
531
+ options
532
+ );
529
533
  }
530
534
  /**
531
535
  * Executes a query once and returns the results.
@@ -548,13 +552,16 @@ class Zero {
548
552
  * ```
549
553
  */
550
554
  run(query, runOptions) {
551
- return this.#zeroContext.run(query.toQuery(this.context), runOptions);
555
+ return this.#zeroContext.run(
556
+ addContextToQuery(query, this.context),
557
+ runOptions
558
+ );
552
559
  }
553
560
  get context() {
554
561
  return this.#options.context;
555
562
  }
556
563
  materialize(query, factoryOrOptions, maybeOptions) {
557
- const q = query.toQuery(this.context);
564
+ const q = addContextToQuery(query, this.context);
558
565
  let factory;
559
566
  let options;
560
567
  if (typeof factoryOrOptions === "function") {