@powerhousedao/connect 1.0.0-dev.245 → 1.0.0-dev.247

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 (28) hide show
  1. package/dist/.env +0 -5
  2. package/dist/assets/{app-BH-6rUAk.js → app-Bjaniq_f.js} +14 -56
  3. package/dist/assets/{app-76Vr3j5e.css → app-D9QJBr8i.css} +1 -1
  4. package/dist/assets/{app-loader-CQdXsdrs.js → app-loader-CnDRDKWw.js} +500 -369
  5. package/dist/assets/{ccip-DzlgrM-Q.js → ccip-BIN6bp0k.js} +3 -3
  6. package/dist/assets/{content-CGSfY9bJ.js → content-CT8IEBqv.js} +3 -3
  7. package/dist/assets/{index-Boh2tg26.js → index-BaBnabbX.js} +4 -4
  8. package/dist/assets/{index-BR7pEetO.js → index-BeBd0Q5I.js} +3 -3
  9. package/dist/assets/{index-Ck0OHqQ0.js → index-CWxXMTAJ.js} +3 -3
  10. package/dist/assets/{main.PwF6jbJu.js → main.DonDJ7tf.js} +1 -1
  11. package/dist/external-packages.js +5 -0
  12. package/dist/hmr.js +4 -1
  13. package/dist/index.html +1 -4
  14. package/dist/modules/@powerhousedao/reactor-browser/{chunk-K62SYQYI.js → chunk-6MBHOHAA.js} +53 -5
  15. package/dist/modules/@powerhousedao/reactor-browser/{chunk-UIXXJKR2.js → chunk-IC6B3767.js} +1 -1
  16. package/dist/modules/@powerhousedao/reactor-browser/{chunk-4AV4NYOH.js → chunk-N5UNGAA6.js} +310 -223
  17. package/dist/modules/@powerhousedao/reactor-browser/{chunk-GZM7UEXF.js → chunk-OYYVE7RP.js} +1 -1
  18. package/dist/modules/@powerhousedao/reactor-browser/{chunk-QVHWUIBE.js → chunk-UDKYG6I4.js} +1 -1
  19. package/dist/modules/@powerhousedao/reactor-browser/context/index.js +2 -2
  20. package/dist/modules/@powerhousedao/reactor-browser/context/read-mode.js +2 -2
  21. package/dist/modules/@powerhousedao/reactor-browser/hooks/index.js +3 -3
  22. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActions.js +2 -2
  23. package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes.js +3 -3
  24. package/dist/modules/@powerhousedao/reactor-browser/index.js +5 -5
  25. package/dist/modules/@powerhousedao/reactor-browser/reactor.js +2 -2
  26. package/dist/swEnv.js +0 -3
  27. package/dist/vite-envs.sh +1 -28
  28. package/package.json +7 -7
@@ -688,140 +688,79 @@ var require_lib = __commonJS({
688
688
  }
689
689
  });
690
690
 
691
- // ../../packages/document-drive/dist/src/utils/logger.js
692
- var LEVELS = {
693
- verbose: 1,
694
- debug: 2,
695
- info: 3,
696
- warn: 4,
697
- error: 5,
698
- silent: 6
691
+ // ../../packages/document-drive/dist/src/cache/util.js
692
+ var trimResultingState = (document) => {
693
+ const global2 = document.operations.global.map((e) => {
694
+ delete e.resultingState;
695
+ return e;
696
+ });
697
+ const local = document.operations.local.map((e) => {
698
+ delete e.resultingState;
699
+ return e;
700
+ });
701
+ return { ...document, operations: { global: global2, local } };
699
702
  };
700
- var ConsoleLogger = class {
701
- #tags;
702
- #levelString = "env";
703
- #errorHandler;
704
- constructor(tags, errorHandler2) {
705
- this.#tags = (tags || []).map((tag) => `[${tag}]`);
706
- this.#errorHandler = errorHandler2;
707
- this.log = this.log.bind(this);
708
- this.info = this.info.bind(this);
709
- this.warn = this.warn.bind(this);
710
- this.error = this.error.bind(this);
711
- this.debug = this.debug.bind(this);
712
- this.verbose = this.verbose.bind(this);
713
- }
714
- get level() {
715
- return this.#levelString;
716
- }
717
- set level(level) {
718
- this.#levelString = level;
719
- }
720
- get errorHandler() {
721
- return this.#errorHandler;
722
- }
723
- set errorHandler(handler) {
724
- this.#errorHandler = handler;
725
- }
726
- get #levelValue() {
727
- if (this.#levelString === "env") {
728
- const envLevel = typeof process !== "undefined" ? process.env.LOG_LEVEL : void 0;
729
- if (!envLevel) {
730
- return LEVELS.debug;
731
- }
732
- if (!(envLevel in LEVELS)) {
733
- return LEVELS.debug;
734
- }
735
- return LEVELS[envLevel];
736
- }
737
- return LEVELS[this.#levelString];
703
+
704
+ // ../../packages/document-drive/dist/src/cache/memory.js
705
+ var InMemoryCache = class {
706
+ idTodocument = /* @__PURE__ */ new Map();
707
+ idToDrive = /* @__PURE__ */ new Map();
708
+ slugToDriveId = /* @__PURE__ */ new Map();
709
+ clear() {
710
+ this.idTodocument.clear();
711
+ this.idToDrive.clear();
712
+ this.slugToDriveId.clear();
738
713
  }
739
- log(...data) {
740
- return this.debug(...data);
714
+ /////////////////////////////////////////////////////////////////////////////
715
+ // ICache
716
+ /////////////////////////////////////////////////////////////////////////////
717
+ async setDocument(documentId, document) {
718
+ const doc = trimResultingState(document);
719
+ this.idTodocument.set(documentId, doc);
741
720
  }
742
- verbose(...data) {
743
- if (this.#levelValue > LEVELS.verbose) {
744
- return;
745
- }
746
- return this.debug(...data);
721
+ async getDocument(documentId) {
722
+ return this.idTodocument.get(documentId);
747
723
  }
748
- debug(...data) {
749
- if (this.#levelValue > LEVELS.debug) {
750
- return;
751
- }
752
- return console.debug(...[...this.#tags, ...data]);
724
+ async deleteDocument(documentId) {
725
+ return this.idTodocument.delete(documentId);
753
726
  }
754
- info(...data) {
755
- if (this.#levelValue > LEVELS.info) {
756
- return;
757
- }
758
- return console.info(...[...this.#tags, ...data]);
727
+ async setDrive(driveId, drive) {
728
+ const doc = trimResultingState(drive);
729
+ this.idToDrive.set(driveId, doc);
759
730
  }
760
- warn(...data) {
761
- if (this.#levelValue > LEVELS.warn) {
762
- return;
763
- }
764
- return console.warn(...[...this.#tags, ...data]);
731
+ async getDrive(driveId) {
732
+ return this.idToDrive.get(driveId);
765
733
  }
766
- error(...data) {
767
- if (this.#levelValue > LEVELS.error) {
768
- return;
734
+ async deleteDrive(driveId) {
735
+ const drive = this.idToDrive.get(driveId);
736
+ if (!drive) {
737
+ return false;
769
738
  }
770
- if (this.#errorHandler) {
771
- this.#errorHandler(...data);
739
+ const slug = drive.state.global.slug;
740
+ if (slug) {
741
+ this.slugToDriveId.delete(slug);
772
742
  }
773
- return console.error(...[...this.#tags, ...data]);
743
+ return this.idToDrive.delete(driveId);
774
744
  }
775
- };
776
- var loggerInstance = new ConsoleLogger();
777
- var logLevel = "env";
778
- var errorHandler;
779
- loggerInstance.level = logLevel;
780
- loggerInstance.errorHandler = errorHandler;
781
- var logger = loggerInstance;
782
- var childLogger = (tags) => {
783
- const logger2 = new ConsoleLogger(tags);
784
- logger2.level = logLevel;
785
- logger2.errorHandler = errorHandler;
786
- return logger2;
787
- };
788
-
789
- // ../../packages/document-drive/dist/src/cache/memory.js
790
- var InMemoryCache = class {
791
- cache = /* @__PURE__ */ new Map();
792
- clear() {
793
- this.cache.clear();
745
+ async setDriveBySlug(slug, drive) {
746
+ const driveId = drive.state.global.id;
747
+ this.slugToDriveId.set(slug, driveId);
748
+ this.setDrive(driveId, drive);
794
749
  }
795
- async setDocument(drive, id, document) {
796
- const global2 = document.operations.global.map((e) => {
797
- delete e.resultingState;
798
- return e;
799
- });
800
- const local = document.operations.local.map((e) => {
801
- delete e.resultingState;
802
- return e;
803
- });
804
- const doc = { ...document, operations: { global: global2, local } };
805
- if (!this.cache.has(drive)) {
806
- this.cache.set(drive, /* @__PURE__ */ new Map());
750
+ async getDriveBySlug(slug) {
751
+ const driveId = this.slugToDriveId.get(slug);
752
+ if (!driveId) {
753
+ return void 0;
807
754
  }
808
- this.cache.get(drive)?.set(id, doc);
809
- return true;
810
- }
811
- async deleteDocument(drive, id) {
812
- return this.cache.get(drive)?.delete(id) ?? false;
813
- }
814
- async getDocument(drive, id) {
815
- return this.cache.get(drive)?.get(id);
755
+ return this.getDrive(driveId);
816
756
  }
817
- async getCachedOperations(drive, id) {
818
- try {
819
- const document = await this.getDocument(drive, id);
820
- return document?.operations;
821
- } catch (error) {
822
- logger.error(error);
823
- return void 0;
757
+ async deleteDriveBySlug(slug) {
758
+ const driveId = this.slugToDriveId.get(slug);
759
+ if (!driveId) {
760
+ return false;
824
761
  }
762
+ this.slugToDriveId.delete(slug);
763
+ return this.deleteDrive(driveId);
825
764
  }
826
765
  };
827
766
  var memory_default = InMemoryCache;
@@ -1187,6 +1126,104 @@ function handleTargetNameCollisions(params) {
1187
1126
  return targetName;
1188
1127
  }
1189
1128
 
1129
+ // ../../packages/document-drive/dist/src/utils/logger.js
1130
+ var LEVELS = {
1131
+ verbose: 1,
1132
+ debug: 2,
1133
+ info: 3,
1134
+ warn: 4,
1135
+ error: 5,
1136
+ silent: 6
1137
+ };
1138
+ var ConsoleLogger = class {
1139
+ #tags;
1140
+ #levelString = "env";
1141
+ #errorHandler;
1142
+ constructor(tags, errorHandler2) {
1143
+ this.#tags = (tags || []).map((tag) => `[${tag}]`);
1144
+ this.#errorHandler = errorHandler2;
1145
+ this.log = this.log.bind(this);
1146
+ this.info = this.info.bind(this);
1147
+ this.warn = this.warn.bind(this);
1148
+ this.error = this.error.bind(this);
1149
+ this.debug = this.debug.bind(this);
1150
+ this.verbose = this.verbose.bind(this);
1151
+ }
1152
+ get level() {
1153
+ return this.#levelString;
1154
+ }
1155
+ set level(level) {
1156
+ this.#levelString = level;
1157
+ }
1158
+ get errorHandler() {
1159
+ return this.#errorHandler;
1160
+ }
1161
+ set errorHandler(handler) {
1162
+ this.#errorHandler = handler;
1163
+ }
1164
+ get #levelValue() {
1165
+ if (this.#levelString === "env") {
1166
+ const envLevel = typeof process !== "undefined" ? process.env.LOG_LEVEL : void 0;
1167
+ if (!envLevel) {
1168
+ return LEVELS.debug;
1169
+ }
1170
+ if (!(envLevel in LEVELS)) {
1171
+ return LEVELS.debug;
1172
+ }
1173
+ return LEVELS[envLevel];
1174
+ }
1175
+ return LEVELS[this.#levelString];
1176
+ }
1177
+ log(...data) {
1178
+ return this.debug(...data);
1179
+ }
1180
+ verbose(...data) {
1181
+ if (this.#levelValue > LEVELS.verbose) {
1182
+ return;
1183
+ }
1184
+ return this.debug(...data);
1185
+ }
1186
+ debug(...data) {
1187
+ if (this.#levelValue > LEVELS.debug) {
1188
+ return;
1189
+ }
1190
+ return console.debug(...[...this.#tags, ...data]);
1191
+ }
1192
+ info(...data) {
1193
+ if (this.#levelValue > LEVELS.info) {
1194
+ return;
1195
+ }
1196
+ return console.info(...[...this.#tags, ...data]);
1197
+ }
1198
+ warn(...data) {
1199
+ if (this.#levelValue > LEVELS.warn) {
1200
+ return;
1201
+ }
1202
+ return console.warn(...[...this.#tags, ...data]);
1203
+ }
1204
+ error(...data) {
1205
+ if (this.#levelValue > LEVELS.error) {
1206
+ return;
1207
+ }
1208
+ if (this.#errorHandler) {
1209
+ this.#errorHandler(...data);
1210
+ }
1211
+ return console.error(...[...this.#tags, ...data]);
1212
+ }
1213
+ };
1214
+ var loggerInstance = new ConsoleLogger();
1215
+ var logLevel = "env";
1216
+ var errorHandler;
1217
+ loggerInstance.level = logLevel;
1218
+ loggerInstance.errorHandler = errorHandler;
1219
+ var logger = loggerInstance;
1220
+ var childLogger = (tags) => {
1221
+ const logger2 = new ConsoleLogger(tags);
1222
+ logger2.level = logLevel;
1223
+ logger2.errorHandler = errorHandler;
1224
+ return logger2;
1225
+ };
1226
+
1190
1227
  // ../../packages/document-drive/dist/src/drive-document-model/gen/constants.js
1191
1228
  var fileExtension = "phdd";
1192
1229
  var documentType = "powerhouse/document-drive";
@@ -1690,6 +1727,44 @@ var MemoryStorage = class {
1690
1727
  }
1691
1728
  return Promise.resolve(document);
1692
1729
  }
1730
+ async delete(documentId) {
1731
+ const drives = await this.getDrives();
1732
+ for (const driveId of drives) {
1733
+ if (driveId === documentId)
1734
+ continue;
1735
+ await this.removeChild(driveId, documentId);
1736
+ }
1737
+ delete this.driveManifests[documentId];
1738
+ if (this.documents[documentId]) {
1739
+ delete this.documents[documentId];
1740
+ return Promise.resolve(true);
1741
+ }
1742
+ return Promise.resolve(false);
1743
+ }
1744
+ async addChild(parentId, childId) {
1745
+ if (parentId === childId) {
1746
+ throw new Error("Cannot associate a document with itself");
1747
+ }
1748
+ const children = await this.getChildren(childId);
1749
+ if (children.includes(parentId)) {
1750
+ throw new Error("Cannot associate a document with its child");
1751
+ }
1752
+ const manifest = this.getManifest(parentId);
1753
+ manifest.documentIds.add(childId);
1754
+ this.updateDriveManifest(parentId, manifest);
1755
+ }
1756
+ async removeChild(parentId, childId) {
1757
+ const manifest = this.getManifest(parentId);
1758
+ if (manifest.documentIds.delete(childId)) {
1759
+ this.updateDriveManifest(parentId, manifest);
1760
+ return true;
1761
+ }
1762
+ return false;
1763
+ }
1764
+ async getChildren(parentId) {
1765
+ const manifest = this.getManifest(parentId);
1766
+ return [...manifest.documentIds];
1767
+ }
1693
1768
  ////////////////////////////////
1694
1769
  // IDriveStorage
1695
1770
  ////////////////////////////////
@@ -1697,7 +1772,7 @@ var MemoryStorage = class {
1697
1772
  return this.exists(id);
1698
1773
  }
1699
1774
  getDocuments(drive) {
1700
- const manifest = this.getDriveManifest(drive);
1775
+ const manifest = this.getManifest(drive);
1701
1776
  return Promise.resolve([...manifest.documentIds]);
1702
1777
  }
1703
1778
  getDocument(driveId, id) {
@@ -1709,7 +1784,7 @@ var MemoryStorage = class {
1709
1784
  }
1710
1785
  async createDocument(drive, id, document) {
1711
1786
  await this.create(id, document);
1712
- const manifest = this.getDriveManifest(drive);
1787
+ const manifest = this.getManifest(drive);
1713
1788
  manifest.documentIds.add(id);
1714
1789
  this.updateDriveManifest(drive, manifest);
1715
1790
  }
@@ -1726,15 +1801,7 @@ var MemoryStorage = class {
1726
1801
  };
1727
1802
  }
1728
1803
  async deleteDocument(drive, id) {
1729
- const drives = await this.getDrives();
1730
- for (const driveId of drives) {
1731
- const manifest = this.getDriveManifest(driveId);
1732
- if (manifest.documentIds.has(id)) {
1733
- manifest.documentIds.delete(id);
1734
- this.updateDriveManifest(driveId, manifest);
1735
- }
1736
- }
1737
- delete this.documents[id];
1804
+ this.delete(id);
1738
1805
  }
1739
1806
  async getDrives() {
1740
1807
  return Object.keys(this.driveManifests);
@@ -1780,14 +1847,14 @@ var MemoryStorage = class {
1780
1847
  };
1781
1848
  }
1782
1849
  async deleteDrive(id) {
1783
- const manifest = this.getDriveManifest(id);
1850
+ const manifest = this.getManifest(id);
1784
1851
  const drives = await this.getDrives();
1785
1852
  await Promise.all([...manifest.documentIds].map((docId) => {
1786
1853
  for (const driveId of drives) {
1787
1854
  if (driveId === id) {
1788
1855
  continue;
1789
1856
  }
1790
- const manifest2 = this.getDriveManifest(driveId);
1857
+ const manifest2 = this.getManifest(driveId);
1791
1858
  if (manifest2.documentIds.has(docId)) {
1792
1859
  return;
1793
1860
  }
@@ -1828,7 +1895,7 @@ var MemoryStorage = class {
1828
1895
  ////////////////////////////////
1829
1896
  // Private
1830
1897
  ////////////////////////////////
1831
- getDriveManifest(driveId) {
1898
+ getManifest(driveId) {
1832
1899
  if (!this.driveManifests[driveId]) {
1833
1900
  this.driveManifests[driveId] = { documentIds: /* @__PURE__ */ new Set() };
1834
1901
  }
@@ -12096,6 +12163,80 @@ var PullResponderTransmitter = class _PullResponderTransmitter {
12096
12163
  }
12097
12164
  };
12098
12165
 
12166
+ // ../../packages/document-drive/dist/src/server/listener/transmitter/switchboard-push.js
12167
+ var import_json_stringify_deterministic = __toESM(require_lib(), 1);
12168
+ var SYNC_OPS_BATCH_LIMIT = 10;
12169
+ var SwitchboardPushTransmitter = class {
12170
+ targetURL;
12171
+ logger = childLogger([
12172
+ "SwitchboardPushTransmitter",
12173
+ Math.floor(Math.random() * 999).toString()
12174
+ ]);
12175
+ constructor(targetURL) {
12176
+ this.targetURL = targetURL;
12177
+ }
12178
+ async transmit(strands, source) {
12179
+ if (source.type === "trigger" && source.trigger.data?.url === this.targetURL) {
12180
+ this.logger.verbose(`Cutting trigger loop from ${this.targetURL}.`);
12181
+ return strands.map((strand) => ({
12182
+ driveId: strand.driveId,
12183
+ documentId: strand.documentId,
12184
+ scope: strand.scope,
12185
+ branch: strand.branch,
12186
+ status: "SUCCESS",
12187
+ revision: strand.operations.at(-1)?.index ?? -1
12188
+ }));
12189
+ }
12190
+ const culledStrands = [];
12191
+ let opsCounter = 0;
12192
+ for (let s = 0; opsCounter <= SYNC_OPS_BATCH_LIMIT && s < strands.length; s++) {
12193
+ const currentStrand = strands.at(s);
12194
+ if (!currentStrand) {
12195
+ break;
12196
+ }
12197
+ const newOps = Math.min(SYNC_OPS_BATCH_LIMIT - opsCounter, currentStrand.operations.length);
12198
+ culledStrands.push({
12199
+ ...currentStrand,
12200
+ operations: currentStrand.operations.slice(0, newOps)
12201
+ });
12202
+ opsCounter += newOps;
12203
+ }
12204
+ this.logger.verbose(` Total update: [${strands.map((s) => s.operations.length).join(", ")}] operations`);
12205
+ this.logger.verbose(`Culled update: [${culledStrands.map((s) => s.operations.length).join(", ")}] operations`);
12206
+ try {
12207
+ const { pushUpdates } = await requestGraphql(this.targetURL, gql`
12208
+ mutation pushUpdates($strands: [InputStrandUpdate!]) {
12209
+ pushUpdates(strands: $strands) {
12210
+ driveId
12211
+ documentId
12212
+ scope
12213
+ branch
12214
+ status
12215
+ revision
12216
+ error
12217
+ }
12218
+ }
12219
+ `, {
12220
+ strands: culledStrands.map((strand) => ({
12221
+ ...strand,
12222
+ operations: strand.operations.map((op) => ({
12223
+ ...op,
12224
+ input: (0, import_json_stringify_deterministic.default)(op.input)
12225
+ }))
12226
+ }))
12227
+ });
12228
+ if (!pushUpdates) {
12229
+ throw new Error("Couldn't update listener revision");
12230
+ }
12231
+ return pushUpdates;
12232
+ } catch (e) {
12233
+ this.logger.error(e);
12234
+ throw e;
12235
+ }
12236
+ return [];
12237
+ }
12238
+ };
12239
+
12099
12240
  // ../../packages/document-drive/dist/src/server/types.js
12100
12241
  var TransmitterType;
12101
12242
  (function(TransmitterType2) {
@@ -12336,6 +12477,26 @@ var BaseDocumentDriveServer = class {
12336
12477
  if (this.shouldSyncRemoteDrive(drive)) {
12337
12478
  await this.startSyncRemoteDrive(driveId);
12338
12479
  }
12480
+ for (const zodListener of drive.state.local.listeners) {
12481
+ if (zodListener.callInfo?.transmitterType === "SwitchboardPush") {
12482
+ const transmitter = new SwitchboardPushTransmitter(zodListener.callInfo?.data ?? "");
12483
+ this.listenerManager.setListener(driveId, {
12484
+ block: zodListener.block,
12485
+ driveId: drive.state.global.id,
12486
+ filter: {
12487
+ branch: zodListener.filter?.branch ?? [],
12488
+ documentId: zodListener.filter?.documentId ?? [],
12489
+ documentType: zodListener.filter?.documentType ?? [],
12490
+ scope: zodListener.filter?.scope ?? []
12491
+ },
12492
+ listenerId: zodListener.listenerId,
12493
+ callInfo: zodListener.callInfo,
12494
+ system: zodListener.system,
12495
+ label: zodListener.label ?? "",
12496
+ transmitter
12497
+ });
12498
+ }
12499
+ }
12339
12500
  }
12340
12501
  // Delegate synchronization methods to synchronizationManager
12341
12502
  getSynchronizationUnits(driveId, documentId, scope, branch, documentType2) {
@@ -12377,7 +12538,7 @@ var BaseDocumentDriveServer = class {
12377
12538
  };
12378
12539
  await this.storage.createDrive(id, document);
12379
12540
  if (input.global.slug) {
12380
- await this.cache.deleteDocument("drives-slug", input.global.slug);
12541
+ await this.cache.deleteDriveBySlug(input.global.slug);
12381
12542
  }
12382
12543
  await this._initializeDrive(id);
12383
12544
  this.eventEmitter.emit("driveAdded", document);
@@ -12409,7 +12570,7 @@ var BaseDocumentDriveServer = class {
12409
12570
  const result = await Promise.allSettled([
12410
12571
  this.stopSyncRemoteDrive(driveId),
12411
12572
  this.listenerManager.removeDrive(driveId),
12412
- this.cache.deleteDocument("drives", driveId),
12573
+ this.cache.deleteDrive(driveId),
12413
12574
  this.storage.deleteDrive(driveId)
12414
12575
  ]);
12415
12576
  result.forEach((r) => {
@@ -12424,7 +12585,7 @@ var BaseDocumentDriveServer = class {
12424
12585
  async getDrive(driveId, options) {
12425
12586
  let document;
12426
12587
  try {
12427
- const cachedDocument = await this.cache.getDocument("drives", driveId);
12588
+ const cachedDocument = await this.cache.getDrive(driveId);
12428
12589
  if (cachedDocument && isDocumentDrive(cachedDocument)) {
12429
12590
  document = cachedDocument;
12430
12591
  if (isAtRevision(document, options?.revisions)) {
@@ -12440,16 +12601,16 @@ var BaseDocumentDriveServer = class {
12440
12601
  throw new Error(`Document with id ${driveId} is not a Document Drive`);
12441
12602
  } else {
12442
12603
  if (!options?.revisions) {
12443
- this.cache.setDocument("drives", driveId, result).catch(logger.error);
12604
+ this.cache.setDrive(driveId, result).catch(logger.error);
12444
12605
  }
12445
12606
  return result;
12446
12607
  }
12447
12608
  }
12448
12609
  async getDriveBySlug(slug, options) {
12449
12610
  try {
12450
- const document2 = await this.cache.getDocument("drives-slug", slug);
12451
- if (document2 && isDocumentDrive(document2)) {
12452
- return document2;
12611
+ const drive = await this.cache.getDriveBySlug(slug);
12612
+ if (drive) {
12613
+ return drive;
12453
12614
  }
12454
12615
  } catch (e) {
12455
12616
  logger.error("Error getting drive from cache", e);
@@ -12459,14 +12620,14 @@ var BaseDocumentDriveServer = class {
12459
12620
  if (!isDocumentDrive(document)) {
12460
12621
  throw new Error(`Document with slug ${slug} is not a Document Drive`);
12461
12622
  } else {
12462
- this.cache.setDocument("drives-slug", slug, document).catch(logger.error);
12623
+ this.cache.setDriveBySlug(slug, document).catch(logger.error);
12463
12624
  return document;
12464
12625
  }
12465
12626
  }
12466
12627
  async getDocument(driveId, documentId, options) {
12467
12628
  let cachedDocument;
12468
12629
  try {
12469
- cachedDocument = await this.cache.getDocument(driveId, documentId);
12630
+ cachedDocument = await this.cache.getDocument(documentId);
12470
12631
  if (cachedDocument && isAtRevision(cachedDocument, options?.revisions)) {
12471
12632
  return cachedDocument;
12472
12633
  }
@@ -12476,7 +12637,7 @@ var BaseDocumentDriveServer = class {
12476
12637
  const documentStorage = cachedDocument ?? await this.storage.getDocument(driveId, documentId);
12477
12638
  const document = this._buildDocument(documentStorage, options);
12478
12639
  if (!options?.revisions) {
12479
- this.cache.setDocument(driveId, documentId, document).catch(logger.error);
12640
+ this.cache.setDocument(documentId, document).catch(logger.error);
12480
12641
  }
12481
12642
  return document;
12482
12643
  }
@@ -12533,7 +12694,7 @@ var BaseDocumentDriveServer = class {
12533
12694
  } catch (error) {
12534
12695
  logger.warn("Error deleting document", error);
12535
12696
  }
12536
- await this.cache.deleteDocument(driveId, documentId);
12697
+ await this.cache.deleteDocument(documentId);
12537
12698
  return this.storage.deleteDocument(driveId, documentId);
12538
12699
  }
12539
12700
  async _processOperations(driveId, documentId, documentStorage, operations) {
@@ -12821,7 +12982,7 @@ var BaseDocumentDriveServer = class {
12821
12982
  };
12822
12983
  });
12823
12984
  if (document) {
12824
- this.cache.setDocument(driveId, documentId, document).catch(logger.error);
12985
+ this.cache.setDocument(documentId, document).catch(logger.error);
12825
12986
  }
12826
12987
  const { scopes, branches } = operationsApplied.reduce((acc, operation) => {
12827
12988
  if (!acc.scopes.includes(operation.scope)) {
@@ -12983,7 +13144,7 @@ var BaseDocumentDriveServer = class {
12983
13144
  if (!document || !isDocumentDrive(document)) {
12984
13145
  throw error ?? new Error("Invalid Document Drive document");
12985
13146
  }
12986
- this.cache.setDocument("drives", driveId, document).catch(logger.error);
13147
+ this.cache.setDrive(driveId, document).catch(logger.error);
12987
13148
  const lastOperation = operationsApplied.filter((op) => op.scope === "global").slice().pop();
12988
13149
  if (lastOperation) {
12989
13150
  const newOp = operationsApplied.find((appliedOp) => !operations.find((o) => o.id === appliedOp.id && o.index === appliedOp.index && o.skip === appliedOp.skip && o.hash === appliedOp.hash));
@@ -13516,80 +13677,6 @@ var ListenerManager = class _ListenerManager {
13516
13677
  }
13517
13678
  };
13518
13679
 
13519
- // ../../packages/document-drive/dist/src/server/listener/transmitter/switchboard-push.js
13520
- var import_json_stringify_deterministic = __toESM(require_lib(), 1);
13521
- var SYNC_OPS_BATCH_LIMIT = 10;
13522
- var SwitchboardPushTransmitter = class {
13523
- targetURL;
13524
- logger = childLogger([
13525
- "SwitchboardPushTransmitter",
13526
- Math.floor(Math.random() * 999).toString()
13527
- ]);
13528
- constructor(targetURL) {
13529
- this.targetURL = targetURL;
13530
- }
13531
- async transmit(strands, source) {
13532
- if (source.type === "trigger" && source.trigger.data?.url === this.targetURL) {
13533
- this.logger.verbose(`Cutting trigger loop from ${this.targetURL}.`);
13534
- return strands.map((strand) => ({
13535
- driveId: strand.driveId,
13536
- documentId: strand.documentId,
13537
- scope: strand.scope,
13538
- branch: strand.branch,
13539
- status: "SUCCESS",
13540
- revision: strand.operations.at(-1)?.index ?? -1
13541
- }));
13542
- }
13543
- const culledStrands = [];
13544
- let opsCounter = 0;
13545
- for (let s = 0; opsCounter <= SYNC_OPS_BATCH_LIMIT && s < strands.length; s++) {
13546
- const currentStrand = strands.at(s);
13547
- if (!currentStrand) {
13548
- break;
13549
- }
13550
- const newOps = Math.min(SYNC_OPS_BATCH_LIMIT - opsCounter, currentStrand.operations.length);
13551
- culledStrands.push({
13552
- ...currentStrand,
13553
- operations: currentStrand.operations.slice(0, newOps)
13554
- });
13555
- opsCounter += newOps;
13556
- }
13557
- this.logger.verbose(` Total update: [${strands.map((s) => s.operations.length).join(", ")}] operations`);
13558
- this.logger.verbose(`Culled update: [${culledStrands.map((s) => s.operations.length).join(", ")}] operations`);
13559
- try {
13560
- const { pushUpdates } = await requestGraphql(this.targetURL, gql`
13561
- mutation pushUpdates($strands: [InputStrandUpdate!]) {
13562
- pushUpdates(strands: $strands) {
13563
- driveId
13564
- documentId
13565
- scope
13566
- branch
13567
- status
13568
- revision
13569
- error
13570
- }
13571
- }
13572
- `, {
13573
- strands: culledStrands.map((strand) => ({
13574
- ...strand,
13575
- operations: strand.operations.map((op) => ({
13576
- ...op,
13577
- input: (0, import_json_stringify_deterministic.default)(op.input)
13578
- }))
13579
- }))
13580
- });
13581
- if (!pushUpdates) {
13582
- throw new Error("Couldn't update listener revision");
13583
- }
13584
- return pushUpdates;
13585
- } catch (e) {
13586
- this.logger.error(e);
13587
- throw e;
13588
- }
13589
- return [];
13590
- }
13591
- };
13592
-
13593
13680
  // ../../packages/document-drive/dist/src/server/listener/transmitter/factory.js
13594
13681
  var TransmitterFactory = class {
13595
13682
  listenerManager;
@@ -13733,7 +13820,7 @@ var SynchronizationManager = class {
13733
13820
  }
13734
13821
  async getDrive(driveId) {
13735
13822
  try {
13736
- const cachedDocument = await this.cache.getDocument("drives", driveId);
13823
+ const cachedDocument = await this.cache.getDrive(driveId);
13737
13824
  if (cachedDocument && isDocumentDrive(cachedDocument)) {
13738
13825
  return cachedDocument;
13739
13826
  }
@@ -13749,7 +13836,7 @@ var SynchronizationManager = class {
13749
13836
  }
13750
13837
  async getDocument(driveId, documentId) {
13751
13838
  try {
13752
- const cachedDocument = await this.cache.getDocument(driveId, documentId);
13839
+ const cachedDocument = await this.cache.getDocument(documentId);
13753
13840
  if (cachedDocument) {
13754
13841
  return cachedDocument;
13755
13842
  }