@voltro/plugin-notifications 0.24.0 → 0.26.0

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.d.ts CHANGED
@@ -127,6 +127,8 @@ export declare interface InboxItem {
127
127
  readonly body: string;
128
128
  readonly data: Record<string, unknown>;
129
129
  readonly readAt: string | null;
130
+ /** When the user cleared it out of the inbox. A different state from read. */
131
+ readonly archivedAt: string | null;
130
132
  readonly createdAt: string;
131
133
  readonly tenantId: string | null;
132
134
  }
@@ -139,6 +141,17 @@ export declare const inboxTable: Table<"_voltro_notification_inbox", FieldDefini
139
141
  readonly body: ColumnBuilder<string, "text", boolean>;
140
142
  readonly data: ColumnBuilder<Record<string, unknown>, "json", boolean>;
141
143
  readonly readAt: ColumnBuilder<Date | null, "timestamp", boolean>;
144
+ /**
145
+ * ARCHIVED is a different state from READ, and for a user the more important
146
+ * one: it is what empties the inbox.
147
+ *
148
+ * Reported as the reason an app could not adopt this plugin. `readAt` covers
149
+ * read and `status` on the delivery table is the delivery outcome
150
+ * ('sent' | 'failed' | 'skipped') — neither is an archive, and the word did
151
+ * not appear anywhere in this plugin's types. An inbox a user cannot clear is
152
+ * one they stop opening.
153
+ */
154
+ readonly archivedAt: ColumnBuilder<Date | null, "timestamp", boolean>;
142
155
  readonly createdAt: ColumnBuilder<Date, "timestamp", true>;
143
156
  readonly tenantId: ColumnBuilder<string | null, "text", boolean>;
144
157
  }>, true, "byInboxSubject">;
@@ -166,6 +179,13 @@ export declare interface NotificationServiceShape {
166
179
  }) => Promise<ReadonlyArray<InboxItem>>;
167
180
  readonly unreadCount: (subjectId: string) => Promise<number>;
168
181
  readonly markRead: (id: string, subjectId: string) => Promise<boolean>;
182
+ /** Undo a read. An inbox without the way back is a one-way ratchet. */
183
+ readonly markUnread: (id: string, subjectId: string) => Promise<boolean>;
184
+ /** Read everything; returns how many rows changed. */
185
+ readonly markAllRead: (subjectId: string) => Promise<number>;
186
+ /** Archive / unarchive. A different state from read — and the one that
187
+ * empties the inbox, which is why it matters more to a user. */
188
+ readonly setArchived: (id: string, subjectId: string, archived: boolean) => Promise<boolean>;
169
189
  readonly getPreferences: (subjectId: string) => Promise<ReadonlyArray<ChannelPreference>>;
170
190
  readonly setPreference: (pref: ChannelPreference) => Promise<void>;
171
191
  readonly subscribe: (topic: string, subjectId: string, tenantId?: string | null) => Promise<void>;
@@ -198,7 +218,7 @@ export declare interface NotificationsPluginOptions {
198
218
  }
199
219
 
200
220
  export declare interface NotificationStore {
201
- readonly addInbox: (item: Omit<InboxItem, 'id' | 'readAt' | 'createdAt'> & {
221
+ readonly addInbox: (item: Omit<InboxItem, 'id' | 'readAt' | 'archivedAt' | 'createdAt'> & {
202
222
  id: string;
203
223
  createdAt: string;
204
224
  }) => Promise<void>;
@@ -207,6 +227,13 @@ export declare interface NotificationStore {
207
227
  limit?: number;
208
228
  }) => Promise<ReadonlyArray<InboxItem>>;
209
229
  readonly markRead: (id: string, subjectId: string) => Promise<boolean>;
230
+ /** Clear the read stamp — an inbox needs the way back, not just forward. */
231
+ readonly markUnread: (id: string, subjectId: string) => Promise<boolean>;
232
+ /** Read EVERYTHING for this subject. Returns how many rows changed. */
233
+ readonly markAllRead: (subjectId: string) => Promise<number>;
234
+ /** Archive / unarchive — a different state from read, and the one that
235
+ * actually empties the inbox. */
236
+ readonly setArchived: (id: string, subjectId: string, archived: boolean) => Promise<boolean>;
210
237
  readonly unreadCount: (subjectId: string) => Promise<number>;
211
238
  readonly getPreferences: (subjectId: string) => Promise<ReadonlyArray<ChannelPreference>>;
212
239
  readonly setPreference: (pref: ChannelPreference) => Promise<void>;