@klum-db/lobby 0.2.0-pre.27 → 0.2.0-pre.28

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.
package/dist/index.js CHANGED
@@ -1988,6 +1988,68 @@ var DockedUnit = class {
1988
1988
  }
1989
1989
  };
1990
1990
 
1991
+ // src/federation/group-inspector.ts
1992
+ function groupInspector(group) {
1993
+ let shardIds = /* @__PURE__ */ new Set();
1994
+ const refresh = async () => {
1995
+ const rows = await group.allRows();
1996
+ shardIds = new Set(rows.map((r) => r.vaultId));
1997
+ return rows;
1998
+ };
1999
+ return {
2000
+ async listAccessibleVaults() {
2001
+ const rows = await refresh();
2002
+ return rows.map((r) => ({ id: r.vaultId, role: "owner" }));
2003
+ },
2004
+ async openVault(name) {
2005
+ const vault = await group.db.openVault(name);
2006
+ group.template.configure(vault);
2007
+ return vault;
2008
+ },
2009
+ onAfterWrite(handler) {
2010
+ return group.db.onAfterWrite((event) => {
2011
+ if (shardIds.has(event.vault)) return handler(event);
2012
+ });
2013
+ },
2014
+ onWriteConflict(handler) {
2015
+ return group.db.onWriteConflict((c) => {
2016
+ if (shardIds.has(c.vault)) handler(c);
2017
+ });
2018
+ },
2019
+ get writeQueue() {
2020
+ return group.db.writeQueue;
2021
+ }
2022
+ };
2023
+ }
2024
+
2025
+ // src/federation/meter-group.ts
2026
+ async function meterGroup(group, opts = {}) {
2027
+ const { eligible, skipped } = await group.resolveEligible(
2028
+ opts.minVersion !== void 0 ? { minVersion: opts.minVersion } : {}
2029
+ );
2030
+ const perShard = [];
2031
+ const names = /* @__PURE__ */ new Set();
2032
+ let records = 0;
2033
+ for (const row of eligible) {
2034
+ const vault = await group.shard(row.partitionKey);
2035
+ const collNames = await vault.collections();
2036
+ let shardRecords = 0;
2037
+ for (const n of collNames) {
2038
+ names.add(n);
2039
+ shardRecords += await vault.collection(n).count();
2040
+ }
2041
+ records += shardRecords;
2042
+ perShard.push({
2043
+ vaultId: row.vaultId,
2044
+ partitionKey: row.partitionKey,
2045
+ schemaVersion: row.schemaVersion,
2046
+ collections: collNames.length,
2047
+ records: shardRecords
2048
+ });
2049
+ }
2050
+ return { vaults: eligible.length, collections: names.size, records, perShard, skipped };
2051
+ }
2052
+
1991
2053
  // src/index.ts
1992
2054
  init_multi_bundle();
1993
2055
  init_extract_cross_vault();
@@ -2224,6 +2286,7 @@ export {
2224
2286
  encodeMultiBundle,
2225
2287
  exportSurface,
2226
2288
  extractCrossVaultPartition,
2289
+ groupInspector,
2227
2290
  isDeedVault,
2228
2291
  isSurfaceDue,
2229
2292
  liberateVault,
@@ -2232,6 +2295,7 @@ export {
2232
2295
  markSynced,
2233
2296
  mergeCompartment,
2234
2297
  mergeDecryptedRecords,
2298
+ meterGroup,
2235
2299
  migrateThenMerge,
2236
2300
  proposeSurface,
2237
2301
  readMultiVaultBundleCompartment,