@massalabs/gossip-sdk 0.0.2-dev.20260325152907 → 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.
package/dist/db/db.d.ts CHANGED
@@ -145,6 +145,7 @@ export interface Discussion {
145
145
  pinned: boolean;
146
146
  messageRetentionDuration: number | null;
147
147
  retentionPolicySetAt: number | null;
148
+ mutedNotifications: boolean;
148
149
  killedNextRetryAt?: Date | null;
149
150
  saturatedRetryAt?: Date | null;
150
151
  saturatedRetryDone: boolean;
@@ -63,4 +63,12 @@ export const MIGRATIONS = [
63
63
  'ALTER TABLE `discussions` ADD COLUMN `retentionPolicySetAt` integer;',
64
64
  ],
65
65
  },
66
+ {
67
+ idx: 5,
68
+ tag: '0005_discussions_muted',
69
+ when: 1744000000000,
70
+ statements: [
71
+ 'ALTER TABLE `discussions` ADD COLUMN `mutedNotifications` integer NOT NULL DEFAULT 0;',
72
+ ],
73
+ },
66
74
  ];
@@ -362,6 +362,23 @@ export declare const discussions: import("drizzle-orm/sqlite-core").SQLiteTableW
362
362
  identity: undefined;
363
363
  generated: undefined;
364
364
  }, {}, {}>;
365
+ mutedNotifications: import("drizzle-orm/sqlite-core").SQLiteColumn<{
366
+ name: "mutedNotifications";
367
+ tableName: "discussions";
368
+ dataType: "boolean";
369
+ columnType: "SQLiteBoolean";
370
+ data: boolean;
371
+ driverParam: number;
372
+ notNull: true;
373
+ hasDefault: true;
374
+ isPrimaryKey: false;
375
+ isAutoincrement: false;
376
+ hasRuntimeDefault: false;
377
+ enumValues: undefined;
378
+ baseColumn: never;
379
+ identity: undefined;
380
+ generated: undefined;
381
+ }, {}, {}>;
365
382
  saturatedRetryDone: import("drizzle-orm/sqlite-core").SQLiteColumn<{
366
383
  name: "saturatedRetryDone";
367
384
  tableName: "discussions";
@@ -27,6 +27,9 @@ export const discussions = sqliteTable('discussions', {
27
27
  saturatedRetryAt: integer('saturatedRetryAt', { mode: 'timestamp_ms' }),
28
28
  messageRetentionDuration: integer('messageRetentionDuration'),
29
29
  retentionPolicySetAt: integer('retentionPolicySetAt'), // nullable, ms timestamp when policy was last configured
30
+ mutedNotifications: integer('mutedNotifications', { mode: 'boolean' })
31
+ .notNull()
32
+ .default(false),
30
33
  saturatedRetryDone: integer('saturatedRetryDone', { mode: 'boolean' })
31
34
  .notNull()
32
35
  .default(false),
@@ -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) {
@@ -106,6 +106,8 @@ export declare class DiscussionService {
106
106
  success: boolean;
107
107
  message?: string;
108
108
  }>;
109
+ /** Mute or unmute notifications for a discussion */
110
+ setMuted(discussionId: number, muted: boolean): Promise<void>;
109
111
  /**
110
112
  * Set the auto-delete retention policy for a discussion.
111
113
  * Updates the local DB and sends a control message to the peer so both sides
@@ -334,6 +334,13 @@ export class DiscussionService {
334
334
  pin(discussionId, pinned) {
335
335
  return updateDiscussionPin(discussionId, pinned, this.queries);
336
336
  }
337
+ /** Mute or unmute notifications for a discussion */
338
+ async setMuted(discussionId, muted) {
339
+ await this.queries.discussions.updateById(discussionId, {
340
+ mutedNotifications: muted,
341
+ });
342
+ await this.refreshService?.stateUpdate();
343
+ }
337
344
  /**
338
345
  * Set the auto-delete retention policy for a discussion.
339
346
  * Updates the local DB and sends a control message to the peer so both sides
@@ -347,7 +354,7 @@ export class DiscussionService {
347
354
  // Update local DB
348
355
  await this.queries.discussions.updateByOwnerAndContact(ownerUserId, contactUserId, {
349
356
  messageRetentionDuration: durationSeconds,
350
- retentionPolicySetAt: durationSeconds ? Date.now() : null,
357
+ retentionPolicySetAt: Date.now(),
351
358
  });
352
359
  // Send control message to peer so they apply the same policy
353
360
  if (this.messageService) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/gossip-sdk",
3
- "version": "0.0.2-dev.20260325152907",
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",