@sparkvault/sdk-js 8.9.1 → 8.9.2

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.
@@ -13520,6 +13520,79 @@ class EntropyModule {
13520
13520
  }
13521
13521
  }
13522
13522
 
13523
+ /**
13524
+ * Notify Module
13525
+ *
13526
+ * The signed-in user's first-party Notify surface: their own metadata-only
13527
+ * inbox. The recipient is ALWAYS derived from the session on the server — no
13528
+ * method takes a `recipient_id`, and any account/recipient a caller might try
13529
+ * to supply is ignored. This mirrors `@sparkvault/sdk-mobile`'s notify client;
13530
+ * device push registration is intentionally omitted (Expo-only on mobile).
13531
+ */
13532
+ const MARK_STATES = ['seen', 'read', 'archived'];
13533
+ class NotifyModule {
13534
+ constructor(http) {
13535
+ this.http = http;
13536
+ }
13537
+ /**
13538
+ * The caller's own inbox feed (newest first). Follow `cursor` to page — a
13539
+ * page can come back short of `limit` yet still carry a non-null cursor.
13540
+ *
13541
+ * @example
13542
+ * const { notifications, cursor } = await sv.notify.getInbox({ state: 'unread' });
13543
+ */
13544
+ async getInbox(options = {}) {
13545
+ const params = new URLSearchParams();
13546
+ if (options.state)
13547
+ params.set('state', options.state);
13548
+ if (options.limit)
13549
+ params.set('limit', String(options.limit));
13550
+ if (options.cursor)
13551
+ params.set('cursor', options.cursor);
13552
+ const query = params.toString();
13553
+ const response = await this.http.get(query ? `/v1/me/notifications?${query}` : '/v1/me/notifications');
13554
+ return response.data;
13555
+ }
13556
+ /**
13557
+ * Bounded unseen badge count for the caller's own inbox. `capped` true means
13558
+ * the true count is at/beyond the ceiling — render "N+".
13559
+ *
13560
+ * @example
13561
+ * const { unread_count, capped } = await sv.notify.getUnreadCount();
13562
+ */
13563
+ async getUnreadCount() {
13564
+ const response = await this.http.get('/v1/me/notifications/unread-count');
13565
+ return response.data;
13566
+ }
13567
+ /**
13568
+ * Apply a terminal display state to one of the caller's own rows (idempotent).
13569
+ * `createdAt` MUST be the row's own `created_at` (round-tripped from the list
13570
+ * row) — the id alone cannot address the row.
13571
+ *
13572
+ * @example
13573
+ * await sv.notify.markState('ntf_abc', { createdAt: row.created_at, state: 'read' });
13574
+ */
13575
+ async markState(notificationId, options) {
13576
+ if (!notificationId || typeof notificationId !== 'string') {
13577
+ throw new ValidationError('notificationId is required', { field: 'notificationId' });
13578
+ }
13579
+ if (!Number.isFinite(options?.createdAt)) {
13580
+ throw new ValidationError('createdAt (the row\'s created_at) is required', {
13581
+ field: 'createdAt',
13582
+ received: options?.createdAt,
13583
+ });
13584
+ }
13585
+ if (!MARK_STATES.includes(options.state)) {
13586
+ throw new ValidationError(`state must be one of ${MARK_STATES.join(', ')}`, {
13587
+ field: 'state',
13588
+ received: options.state,
13589
+ });
13590
+ }
13591
+ const response = await this.http.post(`/v1/me/notifications/${encodeURIComponent(notificationId)}/state`, { created_at: options.createdAt, state: options.state });
13592
+ return response.data;
13593
+ }
13594
+ }
13595
+
13523
13596
  /**
13524
13597
  * SparkVault Debug Logger
13525
13598
  *
@@ -13708,6 +13781,7 @@ class SparkVault {
13708
13781
  this.folders = new FoldersModule(http);
13709
13782
  this.sparks = new SparksModule(http);
13710
13783
  this.entropy = new EntropyModule(http);
13784
+ this.notify = new NotifyModule(http);
13711
13785
  this.health = new HealthModule(this.config);
13712
13786
  }
13713
13787
  /**
@@ -13747,5 +13821,5 @@ if (typeof window !== 'undefined') {
13747
13821
  window.SparkVault = instance ?? SparkVault;
13748
13822
  }
13749
13823
 
13750
- export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NetworkError, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, SparkVault as default, logger, setDebugMode };
13824
+ export { AuthenticationError, AuthorizationError, EntropyModule, FoldersModule, IdentityModule, IngotsModule, NetworkError, NotifyModule, PlanRequiredError, PopupBlockedError, ProductsModule, QuotaExceededError, SparkVault, SparkVaultError, SparksModule, TimeoutError, UserCancelledError, ValidationError, VaultsModule, SparkVault as default, logger, setDebugMode };
13751
13825
  //# sourceMappingURL=sparkvault.esm.js.map