@volter/supercode-teams 0.2.135 → 0.2.137

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 (2) hide show
  1. package/package.json +1 -1
  2. package/worker/index.mjs +23 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.2.135",
3
+ "version": "0.2.137",
4
4
  "type": "module",
5
5
  "description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
6
6
  "license": "MIT",
package/worker/index.mjs CHANGED
@@ -72,10 +72,33 @@ function durableSql(storage) {
72
72
  return { all, get, run, tx, exec: (query) => sql.exec(query) };
73
73
  }
74
74
 
75
+ /** Aggregate storage diagnostics only: no record contents or credentials. */
76
+ function logStorageBreakdown(sql) {
77
+ console.log(`storage: database_bytes=${sql.databaseSize}`);
78
+ try {
79
+ for (const row of sql.exec('SELECT name,SUM(pgsize) bytes,COUNT(*) pages FROM dbstat GROUP BY name ORDER BY SUM(pgsize) DESC')) console.log(`storage table: ${JSON.stringify(row)}`);
80
+ return;
81
+ } catch (error) { console.log(`storage: physical table allocation unavailable: ${error.message}`); }
82
+ // Some hosts omit dbstat. Logical payload lengths exclude indexes/page
83
+ // overhead; TEXT lengths count characters and BLOB lengths count bytes.
84
+ const quote = name => `"${name.replaceAll('"', '""')}"`;
85
+ for (const { name } of sql.exec("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'")) {
86
+ try {
87
+ const columns = [...sql.exec(`PRAGMA table_info(${quote(name)})`)];
88
+ const payload = columns.filter(column => /TEXT|BLOB/i.test(column.type)).map(column => `COALESCE(length(${quote(column.name)}),0)`);
89
+ const [row] = sql.exec(`SELECT COUNT(*) rows,COALESCE(SUM(${payload.join('+') || '0'}),0) payload_units FROM ${quote(name)}`);
90
+ console.log(`storage table logical: ${JSON.stringify({ name, ...row })}`);
91
+ } catch (error) { console.log(`storage table ${name}: ${error.message}`); }
92
+ }
93
+ }
94
+
75
95
  export class TeamsServer extends DurableObject {
76
96
  constructor(ctx, env) {
77
97
  super(ctx, env);
78
98
  this.ready = ctx.blockConcurrencyWhile(async () => {
99
+ // Read before migrations/maintenance: allocation failures must not hide
100
+ // the table responsible, including hosts with a lower storage limit.
101
+ logStorageBreakdown(ctx.storage.sql);
79
102
  const db = durableSql(ctx.storage);
80
103
  migrate({ exec: db.exec, tx: db.tx, version: () => ctx.storage.kv.get('schema_version') ?? 0, setVersion: (n) => ctx.storage.kv.put('schema_version', n) });
81
104
  this.api = createTeamsApi({ publicOrigin: normalizePublicOrigin(env.PUBLIC_ORIGIN), identityIssuer: env.VOLTER_ISSUER || null, identityOrganizations: identityOrganizationsFromEnv(env), delegatedIssuer: env.DELEGATED_ISSUER || null });