@rocicorp/zero 0.24.3000000001-canary.19 → 0.24.3000000001-canary.21

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.
@@ -12750,16 +12750,25 @@ function makeTableCRUD(schema, tableName, tx, ivmBranch) {
12750
12750
  }
12751
12751
 
12752
12752
  // ../zero-client/src/client/delete-clients-manager.ts
12753
+ function filterAndAssert(deletedClients, clientGroupID, clientID, caller) {
12754
+ const clientIDs = deletedClients.filter((dc) => dc.clientGroupID === clientGroupID).map((dc) => dc.clientID);
12755
+ for (const cid of clientIDs) {
12756
+ assert(cid !== clientID, `cannot delete self in ${caller}`);
12757
+ }
12758
+ return clientIDs;
12759
+ }
12753
12760
  var DeleteClientsManager = class {
12754
12761
  #send;
12755
12762
  #lc;
12756
12763
  #dagStore;
12757
12764
  #clientGroupID;
12758
- constructor(send2, dagStore, lc, clientGroupID) {
12765
+ #clientID;
12766
+ constructor(send2, dagStore, lc, clientGroupID, clientID) {
12759
12767
  this.#send = send2;
12760
12768
  this.#dagStore = dagStore;
12761
12769
  this.#lc = lc;
12762
12770
  this.#clientGroupID = clientGroupID;
12771
+ this.#clientID = clientID;
12763
12772
  }
12764
12773
  /**
12765
12774
  * This gets called by Replicache when it deletes clients from the persistent
@@ -12768,10 +12777,16 @@ var DeleteClientsManager = class {
12768
12777
  async onClientsDeleted(deletedClients) {
12769
12778
  this.#lc.debug?.("DeletedClientsManager, send:", deletedClients);
12770
12779
  const clientGroupID = await this.#clientGroupID;
12780
+ const clientIDs = filterAndAssert(
12781
+ deletedClients,
12782
+ clientGroupID,
12783
+ this.#clientID,
12784
+ "onClientsDeleted"
12785
+ );
12771
12786
  this.#send([
12772
12787
  "deleteClients",
12773
12788
  {
12774
- clientIDs: deletedClients.filter((dc) => dc.clientGroupID === clientGroupID).map((dc) => dc.clientID)
12789
+ clientIDs
12775
12790
  }
12776
12791
  ]);
12777
12792
  }
@@ -12785,7 +12800,12 @@ var DeleteClientsManager = class {
12785
12800
  this.#dagStore,
12786
12801
  (dagRead) => getDeletedClients(dagRead)
12787
12802
  );
12788
- const clientIDs = deleted.filter((d) => d.clientGroupID === clientGroupID).map((d) => d.clientID);
12803
+ const clientIDs = filterAndAssert(
12804
+ deleted,
12805
+ clientGroupID,
12806
+ this.#clientID,
12807
+ "sendDeletedClientsToServer"
12808
+ );
12789
12809
  if (clientIDs.length > 0) {
12790
12810
  this.#send(["deleteClients", { clientIDs }]);
12791
12811
  this.#lc.debug?.("DeletedClientsManager, send:", deleted);
@@ -12811,6 +12831,12 @@ var DeleteClientsManager = class {
12811
12831
  (read) => getDeletedClients(read)
12812
12832
  );
12813
12833
  const clientGroupID = await this.#clientGroupID;
12834
+ filterAndAssert(
12835
+ deletedClients,
12836
+ clientGroupID,
12837
+ this.#clientID,
12838
+ "getDeletedClients"
12839
+ );
12814
12840
  return deletedClients.filter((d) => d.clientGroupID === clientGroupID);
12815
12841
  }
12816
12842
  };
@@ -13063,7 +13089,7 @@ function makeMessage(message, context, logLevel) {
13063
13089
  }
13064
13090
 
13065
13091
  // ../zero-client/src/client/version.ts
13066
- var version2 = "0.24.3000000001-canary.19";
13092
+ var version2 = "0.24.3000000001-canary.21";
13067
13093
 
13068
13094
  // ../zero-client/src/client/log-options.ts
13069
13095
  var LevelFilterLogSink = class {
@@ -14910,7 +14936,8 @@ var Zero = class _Zero {
14910
14936
  (msg) => this.#send(msg),
14911
14937
  rep.perdag,
14912
14938
  this.#lc,
14913
- this.#rep.clientGroupID
14939
+ this.#rep.clientGroupID,
14940
+ rep.clientID
14914
14941
  );
14915
14942
  this.query = this.#registerQueries(schema);
14916
14943
  reportReloadReason(this.#lc);
@@ -16049,4 +16076,4 @@ export {
16049
16076
  update_needed_reason_type_enum_exports,
16050
16077
  Zero
16051
16078
  };
16052
- //# sourceMappingURL=chunk-CF3YHCMZ.js.map
16079
+ //# sourceMappingURL=chunk-IV2VAOWR.js.map