@massalabs/gossip-sdk 0.0.2-dev.20260330112729 → 0.0.2-dev.20260330150645

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.
@@ -55,5 +55,7 @@ export declare class DatabaseConnection {
55
55
  withTransaction<T>(fn: () => Promise<T>): Promise<T>;
56
56
  close(): Promise<void>;
57
57
  clearAllTables(): Promise<void>;
58
+ /** Delete only the data belonging to a specific account. */
59
+ clearAccountData(userId: string): Promise<void>;
58
60
  clearConversationTables(): Promise<void>;
59
61
  }
package/dist/db/sqlite.js CHANGED
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';
15
15
  import * as SQLite from 'wa-sqlite';
16
+ import { eq } from 'drizzle-orm';
16
17
  import { drizzle } from 'drizzle-orm/sqlite-proxy';
17
18
  import * as schema from './schema/index.js';
18
19
  import { runMigrations } from './migrate.js';
@@ -261,6 +262,33 @@ export class DatabaseConnection {
261
262
  await this.db.delete(schema.announcementCursors);
262
263
  });
263
264
  }
265
+ /** Delete only the data belonging to a specific account. */
266
+ async clearAccountData(userId) {
267
+ await this.withTransaction(async () => {
268
+ // Tables with ownerUserId
269
+ await this.db
270
+ .delete(schema.messages)
271
+ .where(eq(schema.messages.ownerUserId, userId));
272
+ await this.db
273
+ .delete(schema.discussions)
274
+ .where(eq(schema.discussions.ownerUserId, userId));
275
+ await this.db
276
+ .delete(schema.contacts)
277
+ .where(eq(schema.contacts.ownerUserId, userId));
278
+ // Profile table keyed by userId
279
+ await this.db
280
+ .delete(schema.userProfile)
281
+ .where(eq(schema.userProfile.userId, userId));
282
+ // Announcement cursor keyed by userId
283
+ await this.db
284
+ .delete(schema.announcementCursors)
285
+ .where(eq(schema.announcementCursors.userId, userId));
286
+ // Session-specific tables (no user column — safe to clear for current session)
287
+ await this.db.delete(schema.pendingEncryptedMessages);
288
+ await this.db.delete(schema.pendingAnnouncements);
289
+ await this.db.delete(schema.activeSeekers);
290
+ });
291
+ }
264
292
  async clearConversationTables() {
265
293
  await this.withTransaction(async () => {
266
294
  await this.db.delete(schema.messages);
package/dist/gossip.d.ts CHANGED
@@ -87,6 +87,8 @@ declare class GossipSdk {
87
87
  get queries(): Queries;
88
88
  /** Clear all database tables. */
89
89
  clearAllTables(): Promise<void>;
90
+ /** Delete only the data belonging to a specific account. */
91
+ clearAccountData(userId: string): Promise<void>;
90
92
  /** Clear only conversation-related tables (messages, discussions, contacts). */
91
93
  clearConversationTables(): Promise<void>;
92
94
  /**
package/dist/gossip.js CHANGED
@@ -356,6 +356,13 @@ class GossipSdk {
356
356
  }
357
357
  await this._conn.clearAllTables();
358
358
  }
359
+ /** Delete only the data belonging to a specific account. */
360
+ async clearAccountData(userId) {
361
+ if (!this._conn) {
362
+ throw new Error('SDK not initialized. Call init() first.');
363
+ }
364
+ await this._conn.clearAccountData(userId);
365
+ }
359
366
  /** Clear only conversation-related tables (messages, discussions, contacts). */
360
367
  async clearConversationTables() {
361
368
  if (!this._conn) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/gossip-sdk",
3
- "version": "0.0.2-dev.20260330112729",
3
+ "version": "0.0.2-dev.20260330150645",
4
4
  "description": "Gossip SDK for automation, chatbot, and integration use cases",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",