@rocicorp/zero 0.17.2025032000 → 0.18.2025031800

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 (102) hide show
  1. package/out/{chunk-OI2PV2HL.js → chunk-FNFCFUNQ.js} +75 -88
  2. package/out/chunk-FNFCFUNQ.js.map +7 -0
  3. package/out/replicache/src/persist/refresh.d.ts.map +1 -1
  4. package/out/replicache/src/replicache-options.d.ts +1 -2
  5. package/out/replicache/src/replicache-options.d.ts.map +1 -1
  6. package/out/shared/src/custom-key-map.d.ts +2 -2
  7. package/out/shared/src/custom-key-map.d.ts.map +1 -1
  8. package/out/shared/src/custom-key-map.js.map +1 -1
  9. package/out/shared/src/custom-key-set.d.ts +2 -2
  10. package/out/shared/src/custom-key-set.d.ts.map +1 -1
  11. package/out/shared/src/custom-key-set.js.map +1 -1
  12. package/out/solid.js +1 -1
  13. package/out/zero-cache/src/auth/jwt.d.ts +5 -1
  14. package/out/zero-cache/src/auth/jwt.d.ts.map +1 -1
  15. package/out/zero-cache/src/auth/jwt.js +13 -0
  16. package/out/zero-cache/src/auth/jwt.js.map +1 -1
  17. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  18. package/out/zero-cache/src/config/zero-config.js +0 -2
  19. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  20. package/out/zero-cache/src/scripts/deploy-permissions.js +2 -2
  21. package/out/zero-cache/src/scripts/deploy-permissions.js.map +1 -1
  22. package/out/zero-cache/src/scripts/permissions.d.ts +23 -0
  23. package/out/zero-cache/src/scripts/permissions.d.ts.map +1 -1
  24. package/out/zero-cache/src/scripts/permissions.js +2 -0
  25. package/out/zero-cache/src/scripts/permissions.js.map +1 -1
  26. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
  27. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +3 -3
  28. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  29. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +1 -0
  30. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
  31. package/out/zero-cache/src/services/change-source/protocol/current/data.js +11 -0
  32. package/out/zero-cache/src/services/change-source/protocol/current/data.js.map +1 -1
  33. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +3 -0
  34. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
  35. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +1 -0
  36. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
  37. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +21 -3
  38. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  39. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +1 -0
  40. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
  41. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
  42. package/out/zero-cache/src/services/replicator/change-processor.js +19 -12
  43. package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
  44. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +1 -3
  45. package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
  46. package/out/zero-cache/src/services/view-syncer/client-handler.js +4 -23
  47. package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
  48. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +1 -1
  49. package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
  50. package/out/zero-cache/src/services/view-syncer/cvr-store.js +4 -6
  51. package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
  52. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +2 -2
  53. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  54. package/out/zero-cache/src/services/view-syncer/cvr.js +4 -4
  55. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  56. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  57. package/out/zero-cache/src/services/view-syncer/view-syncer.js +6 -7
  58. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  59. package/out/zero-cache/src/types/lite.d.ts +6 -3
  60. package/out/zero-cache/src/types/lite.d.ts.map +1 -1
  61. package/out/zero-cache/src/types/lite.js +9 -7
  62. package/out/zero-cache/src/types/lite.js.map +1 -1
  63. package/out/zero-cache/src/workers/syncer.d.ts +1 -1
  64. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  65. package/out/zero-cache/src/workers/syncer.js +0 -1
  66. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  67. package/out/zero-client/src/client/custom.d.ts +9 -13
  68. package/out/zero-client/src/client/custom.d.ts.map +1 -1
  69. package/out/zero-client/src/client/ivm-branch.d.ts +1 -2
  70. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  71. package/out/zero-client/src/client/zero-rep.d.ts +1 -2
  72. package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
  73. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  74. package/out/zero-protocol/src/down.d.ts +0 -1
  75. package/out/zero-protocol/src/down.d.ts.map +1 -1
  76. package/out/zero-protocol/src/poke.d.ts +0 -2
  77. package/out/zero-protocol/src/poke.d.ts.map +1 -1
  78. package/out/zero-protocol/src/poke.js +0 -2
  79. package/out/zero-protocol/src/poke.js.map +1 -1
  80. package/out/zero-protocol/src/protocol-version.d.ts +1 -8
  81. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  82. package/out/zero-protocol/src/protocol-version.js +4 -12
  83. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  84. package/out/zero-schema/src/builder/schema-builder.d.ts +1 -0
  85. package/out/zero-schema/src/builder/schema-builder.d.ts.map +1 -1
  86. package/out/zero-schema/src/builder/schema-builder.js.map +1 -1
  87. package/out/zero.js +1 -1
  88. package/out/zql/src/ivm/take.d.ts +0 -3
  89. package/out/zql/src/ivm/take.d.ts.map +1 -1
  90. package/out/zql/src/ivm/take.js +7 -33
  91. package/out/zql/src/ivm/take.js.map +1 -1
  92. package/out/zql/src/query/expression.d.ts +1 -1
  93. package/out/zql/src/query/expression.d.ts.map +1 -1
  94. package/out/zql/src/query/expression.js +1 -3
  95. package/out/zql/src/query/expression.js.map +1 -1
  96. package/out/zql/src/query/query-impl.d.ts +1 -1
  97. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  98. package/out/zql/src/query/query-impl.js.map +1 -1
  99. package/out/zql/src/query/query.d.ts +1 -1
  100. package/out/zql/src/query/query.d.ts.map +1 -1
  101. package/package.json +4 -3
  102. package/out/chunk-OI2PV2HL.js.map +0 -7
@@ -6315,7 +6315,7 @@ async function persistDD31(lc, clientID, memdag, perdag, mutators, closed, forma
6315
6315
  return;
6316
6316
  }
6317
6317
  let memdagBaseSnapshotPersisted = false;
6318
- const zeroDataForMemdagBaseSnapshot = getZeroData && await getZeroData("rebase", memdagBaseSnapshot.chunk.hash);
6318
+ const zeroDataForMemdagBaseSnapshot = getZeroData && await getZeroData(memdagBaseSnapshot.chunk.hash);
6319
6319
  await withWrite(perdag, async (perdagWrite) => {
6320
6320
  const [mainClientGroup, latestPerdagMainClientGroupHeadCommit] = await getClientGroupInfo(perdagWrite, mainClientGroupID);
6321
6321
  let newMainClientGroupHeadHash = latestPerdagMainClientGroupHeadCommit.chunk.hash;
@@ -6368,7 +6368,7 @@ async function persistDD31(lc, clientID, memdag, perdag, mutators, closed, forma
6368
6368
  }
6369
6369
  let zeroDataForPerdagHeadCommit;
6370
6370
  if (!memdagBaseSnapshotPersisted) {
6371
- zeroDataForPerdagHeadCommit = getZeroData && await getZeroData("rebase", newMainClientGroupHeadHash, {
6371
+ zeroDataForPerdagHeadCommit = getZeroData && await getZeroData(newMainClientGroupHeadHash, {
6372
6372
  openLazySourceRead: perdagWrite
6373
6373
  });
6374
6374
  }
@@ -6575,13 +6575,9 @@ async function refresh(lc, memdag, perdag, clientID, mutators, diffConfig, close
6575
6575
  await Promise.all(ps);
6576
6576
  let newMemdagHeadHash = perdagClientGroupHeadHash;
6577
6577
  if (newMemdagMutations.length > 0) {
6578
- const zeroData2 = await zero?.getTxData?.(
6579
- "rebase",
6580
- newMemdagHeadHash,
6581
- {
6582
- openLazyRead: memdagWrite
6583
- }
6584
- );
6578
+ const zeroData2 = await zero?.getTxData?.(newMemdagHeadHash, {
6579
+ openLazyRead: memdagWrite
6580
+ });
6585
6581
  for (let i = newMemdagMutations.length - 1; i >= 0; i--) {
6586
6582
  newMemdagHeadHash = (await rebaseMutationAndPutCommit(
6587
6583
  newMemdagMutations[i],
@@ -7624,7 +7620,7 @@ var ReplicacheImpl = class {
7624
7620
  void this.#schedulePersist();
7625
7621
  return;
7626
7622
  }
7627
- const zeroData2 = await this.#zero?.getTxData?.("rebase", syncHead);
7623
+ const zeroData2 = await this.#zero?.getTxData?.(syncHead);
7628
7624
  for (const mutation of replayMutations) {
7629
7625
  if (this.#subscriptions.hasPendingSubscriptionRuns) {
7630
7626
  await Promise.resolve();
@@ -8190,7 +8186,7 @@ var ReplicacheImpl = class {
8190
8186
  clientID,
8191
8187
  await dbWrite.getMutationID(),
8192
8188
  "initial",
8193
- await this.#zero?.getTxData("initial", headHash, {
8189
+ await this.#zero?.getTxData(headHash, {
8194
8190
  openLazyRead: dagWrite
8195
8191
  }),
8196
8192
  dbWrite,
@@ -10132,8 +10128,6 @@ var Take = class {
10132
10128
  #limit;
10133
10129
  #partitionKey;
10134
10130
  #partitionKeyComparator;
10135
- // Fetch overlay needed for some split push cases.
10136
- #rowHiddenFromFetch;
10137
10131
  #output = throwOutput;
10138
10132
  constructor(input, storage, limit, partitionKey) {
10139
10133
  assert(limit >= 0);
@@ -10169,12 +10163,6 @@ var Take = class {
10169
10163
  if (this.getSchema().compareRows(takeState.bound, inputNode.row) < 0) {
10170
10164
  return;
10171
10165
  }
10172
- if (this.#rowHiddenFromFetch && this.getSchema().compareRows(
10173
- this.#rowHiddenFromFetch,
10174
- inputNode.row
10175
- ) === 0) {
10176
- continue;
10177
- }
10178
10166
  yield inputNode;
10179
10167
  }
10180
10168
  return;
@@ -10317,16 +10305,14 @@ var Take = class {
10317
10305
  type: "remove",
10318
10306
  node: boundNode
10319
10307
  };
10308
+ this.#output.push(change);
10320
10309
  this.#setTakeState(
10321
10310
  takeStateKey,
10322
10311
  takeState.size,
10323
10312
  beforeBoundNode === void 0 || compareRows(change.node.row, beforeBoundNode.row) > 0 ? change.node.row : beforeBoundNode.row,
10324
10313
  maxBound
10325
10314
  );
10326
- this.#withRowHiddenFromFetch(change.node.row, () => {
10327
- this.#output.push(removeChange);
10328
- });
10329
- this.#output.push(change);
10315
+ this.#output.push(removeChange);
10330
10316
  } else if (change.type === "remove") {
10331
10317
  if (takeState.bound === void 0) {
10332
10318
  return;
@@ -10497,21 +10483,19 @@ var Take = class {
10497
10483
  }),
10498
10484
  2
10499
10485
  );
10486
+ this.#output.push({
10487
+ type: "add",
10488
+ node: change.node
10489
+ });
10500
10490
  this.#setTakeState(
10501
10491
  takeStateKey,
10502
10492
  takeState.size,
10503
10493
  newBoundNode.row,
10504
10494
  maxBound
10505
10495
  );
10506
- this.#withRowHiddenFromFetch(change.node.row, () => {
10507
- this.#output.push({
10508
- type: "remove",
10509
- node: oldBoundNode
10510
- });
10511
- });
10512
10496
  this.#output.push({
10513
- type: "add",
10514
- node: change.node
10497
+ type: "remove",
10498
+ node: oldBoundNode
10515
10499
  });
10516
10500
  return;
10517
10501
  }
@@ -10555,14 +10539,6 @@ var Take = class {
10555
10539
  }
10556
10540
  unreachable();
10557
10541
  }
10558
- #withRowHiddenFromFetch(row, fn) {
10559
- this.#rowHiddenFromFetch = row;
10560
- try {
10561
- fn();
10562
- } finally {
10563
- this.#rowHiddenFromFetch = void 0;
10564
- }
10565
- }
10566
10542
  #setTakeState(takeStateKey, size, bound, maxBound) {
10567
10543
  this.#storage.set(takeStateKey, {
10568
10544
  size,
@@ -11189,9 +11165,7 @@ var ExpressionBuilder = class {
11189
11165
  and = and;
11190
11166
  or = or;
11191
11167
  not = not2;
11192
- exists(relationship, cb) {
11193
- return this.#exists(relationship, cb);
11194
- }
11168
+ exists = (relationship, cb) => this.#exists(relationship, cb);
11195
11169
  };
11196
11170
  function and(...conditions) {
11197
11171
  const expressions = filterTrue(filterUndefined(conditions));
@@ -12338,8 +12312,6 @@ var pokeStartBodySchema = valita_exports.object({
12338
12312
  // with initial cookie `null`, before the first request. So we have to be
12339
12313
  // able to send a base cookie with value `null` to match that state.
12340
12314
  baseCookie: nullableVersionSchema,
12341
- // Deprecated: Replaced by pokeEnd.cookie.
12342
- cookie: versionSchema.optional(),
12343
12315
  /**
12344
12316
  * This field is always set if the poke contains a `rowsPatch`.
12345
12317
  * It may be absent for patches that only update clients and queries.
@@ -12435,10 +12407,8 @@ var Custom = "custom";
12435
12407
 
12436
12408
  // ../zero-protocol/src/protocol-version.ts
12437
12409
  var PROTOCOL_VERSION = 7;
12438
- var MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 2;
12410
+ var MIN_SERVER_SUPPORTED_SYNC_PROTOCOL = 6;
12439
12411
  assert(MIN_SERVER_SUPPORTED_SYNC_PROTOCOL < PROTOCOL_VERSION);
12440
- var MIN_SERVER_SUPPORTED_PERMISSIONS_PROTOCOL = 4;
12441
- assert(MIN_SERVER_SUPPORTED_PERMISSIONS_PROTOCOL < PROTOCOL_VERSION);
12442
12412
 
12443
12413
  // ../zero-protocol/src/push.ts
12444
12414
  var CRUD_MUTATION_NAME = "_zero_crud";
@@ -13697,14 +13667,7 @@ var IVMSourceBranch = class _IVMSourceBranch {
13697
13667
  /**
13698
13668
  * Fork the branch and patch it up to match the desired head.
13699
13669
  */
13700
- async forkToHead(reason, store, desiredHead, readOptions) {
13701
- if (reason === "initial") {
13702
- assert(
13703
- this.hash === desiredHead,
13704
- "main branch must be at desired head for `initial`"
13705
- );
13706
- return this;
13707
- }
13670
+ async forkToHead(store, desiredHead, readOptions) {
13708
13671
  const fork = this.fork();
13709
13672
  if (fork.hash === desiredHead) {
13710
13673
  return fork;
@@ -14125,12 +14088,7 @@ var TransactionImpl = class {
14125
14088
  this.mutate = makeSchemaCRUD(
14126
14089
  schema,
14127
14090
  repTx,
14128
- // CRUD operators should not mutate the IVM store directly
14129
- // for `initial`. The IVM store will be updated via calls to `advance`
14130
- // after the transaction has been committed to the Replicache b-tree.
14131
- // Mutating the IVM store in the mutator would cause us to synchronously
14132
- // notify listeners of IVM while we're inside of the Replicache DB transaction.
14133
- repTx.reason === "initial" ? void 0 : must(
14091
+ must(
14134
14092
  castedRepTx[zeroData],
14135
14093
  "zero was not set on replicache internal options!"
14136
14094
  )
@@ -14526,7 +14484,7 @@ function makeMessage(message, context, logLevel) {
14526
14484
  }
14527
14485
 
14528
14486
  // ../zero-client/src/client/version.ts
14529
- var version2 = "0.17.2025032000";
14487
+ var version2 = "0.18.2025031800";
14530
14488
 
14531
14489
  // ../zero-client/src/client/log-options.ts
14532
14490
  var LevelFilterLogSink = class {
@@ -15478,12 +15436,11 @@ var ZeroRep = class {
15478
15436
  this.#store = store;
15479
15437
  this.#context.processChanges(void 0, hash2, diffs);
15480
15438
  }
15481
- getTxData = (reason, desiredHead, readOptions) => {
15439
+ getTxData = (desiredHead, readOptions) => {
15482
15440
  if (!this.#customMutatorsEnabled) {
15483
15441
  return;
15484
15442
  }
15485
15443
  return this.#ivmMain.forkToHead(
15486
- reason,
15487
15444
  must(this.#store),
15488
15445
  desiredHead,
15489
15446
  readOptions
@@ -15684,19 +15641,45 @@ var Zero = class {
15684
15641
  [CRUD_MUTATION_NAME]: makeCRUDMutator(schema)
15685
15642
  };
15686
15643
  this.#ivmMain = new IVMSourceBranch(schema.tables);
15644
+ function assertUnique(key) {
15645
+ assert(
15646
+ replicacheMutators[key] === void 0,
15647
+ `A mutator, or mutator namespace, has already been defined for ${key}`
15648
+ );
15649
+ }
15687
15650
  const lc = new LogContext4(logOptions.logLevel, {}, logOptions.logSink);
15688
- for (const [namespace, mutatorsForNamespace] of Object.entries(
15689
- options.mutators ?? {}
15690
- )) {
15691
- for (const [name, mutator] of Object.entries(
15692
- mutatorsForNamespace
15651
+ if (options.mutators) {
15652
+ for (const [namespaceOrKey, mutatorOrMutators] of Object.entries(
15653
+ options.mutators
15693
15654
  )) {
15694
- replicacheMutators[customMutatorKey(namespace, name)] = makeReplicacheMutator(
15695
- lc,
15696
- mutator,
15697
- schema,
15698
- slowMaterializeThreshold
15699
- );
15655
+ if (typeof mutatorOrMutators === "function") {
15656
+ const key = namespaceOrKey;
15657
+ assertUnique(key);
15658
+ replicacheMutators[key] = makeReplicacheMutator(
15659
+ lc,
15660
+ mutatorOrMutators,
15661
+ schema,
15662
+ slowMaterializeThreshold
15663
+ );
15664
+ continue;
15665
+ }
15666
+ if (typeof mutatorOrMutators === "object") {
15667
+ for (const [name, mutator] of Object.entries(mutatorOrMutators)) {
15668
+ const key = customMutatorKey(
15669
+ namespaceOrKey,
15670
+ name
15671
+ );
15672
+ assertUnique(key);
15673
+ replicacheMutators[key] = makeReplicacheMutator(
15674
+ lc,
15675
+ mutator,
15676
+ schema,
15677
+ slowMaterializeThreshold
15678
+ );
15679
+ }
15680
+ continue;
15681
+ }
15682
+ unreachable(mutatorOrMutators);
15700
15683
  }
15701
15684
  }
15702
15685
  this.storageKey = storageKey ?? "";
@@ -15770,19 +15753,23 @@ var Zero = class {
15770
15753
  if (options.mutators) {
15771
15754
  mutate = {};
15772
15755
  mutateBatch = void 0;
15773
- }
15774
- for (const [namespace, mutatorsForNamespace] of Object.entries(
15775
- options.mutators ?? {}
15776
- )) {
15777
- let existing = mutate[namespace];
15778
- if (existing === void 0) {
15779
- existing = {};
15780
- mutate[namespace] = existing;
15781
- }
15782
- for (const name of Object.keys(
15783
- mutatorsForNamespace
15756
+ for (const [namespaceOrKey, mutatorsOrMutator] of Object.entries(
15757
+ options.mutators
15784
15758
  )) {
15785
- existing[name] = must(rep.mutate[customMutatorKey(namespace, name)]);
15759
+ if (typeof mutatorsOrMutator === "function") {
15760
+ mutate[namespaceOrKey] = must(rep.mutate[namespaceOrKey]);
15761
+ continue;
15762
+ }
15763
+ let existing = mutate[namespaceOrKey];
15764
+ if (existing === void 0) {
15765
+ existing = {};
15766
+ mutate[namespaceOrKey] = existing;
15767
+ }
15768
+ for (const name of Object.keys(mutatorsOrMutator)) {
15769
+ existing[name] = must(
15770
+ rep.mutate[customMutatorKey(namespaceOrKey, name)]
15771
+ );
15772
+ }
15786
15773
  }
15787
15774
  }
15788
15775
  this.mutate = mutate;
@@ -16802,4 +16789,4 @@ export {
16802
16789
  escapeLike,
16803
16790
  Zero
16804
16791
  };
16805
- //# sourceMappingURL=chunk-OI2PV2HL.js.map
16792
+ //# sourceMappingURL=chunk-FNFCFUNQ.js.map