vintasend 0.8.0 → 0.8.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.
- package/README.md +51 -0
- package/dist/services/notification-backends/base-notification-backend.d.ts +12 -1
- package/dist/services/notification-backends/base-notification-backend.js +5 -0
- package/dist/services/notification-service.d.ts +7 -2
- package/dist/services/notification-service.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -159,6 +159,57 @@ const backendStats = await vintasend.getBackendSyncStats();
|
|
|
159
159
|
- Additional backend replication failures are logged and do not fail the primary operation.
|
|
160
160
|
- This keeps primary workflows available while still enabling redundancy.
|
|
161
161
|
|
|
162
|
+
## Filtering and Ordering Notifications
|
|
163
|
+
|
|
164
|
+
Use `filterNotifications` to query notifications with pagination and optional ordering.
|
|
165
|
+
|
|
166
|
+
```typescript
|
|
167
|
+
const notifications = await vintasend.filterNotifications(
|
|
168
|
+
{
|
|
169
|
+
status: 'PENDING_SEND',
|
|
170
|
+
},
|
|
171
|
+
1,
|
|
172
|
+
25,
|
|
173
|
+
{
|
|
174
|
+
field: 'createdAt',
|
|
175
|
+
direction: 'desc',
|
|
176
|
+
},
|
|
177
|
+
);
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### `orderBy` shape
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
type NotificationOrderBy = {
|
|
184
|
+
field: 'sendAfter' | 'sentAt' | 'readAt' | 'createdAt' | 'updatedAt';
|
|
185
|
+
direction: 'asc' | 'desc';
|
|
186
|
+
};
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Examples:
|
|
190
|
+
- `{ field: 'createdAt', direction: 'desc' }`
|
|
191
|
+
- `{ field: 'sendAfter', direction: 'asc' }`
|
|
192
|
+
|
|
193
|
+
### Checking backend support
|
|
194
|
+
|
|
195
|
+
Use `getBackendSupportedFilterCapabilities()` to detect support gaps per backend.
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
const capabilities = await vintasend.getBackendSupportedFilterCapabilities();
|
|
199
|
+
|
|
200
|
+
if (!capabilities['orderBy.readAt']) {
|
|
201
|
+
// Fallback to another ordering field
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
When using multiple backends, you can check capabilities for a specific backend identifier:
|
|
206
|
+
|
|
207
|
+
```typescript
|
|
208
|
+
const replicaCapabilities = await vintasend.getBackendSupportedFilterCapabilities('replica-backend');
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
`vintasend-medplum` currently does not support `orderBy.readAt`, and reports `orderBy.readAt: false`.
|
|
212
|
+
|
|
162
213
|
## Attachment Support
|
|
163
214
|
|
|
164
215
|
VintaSend supports file attachments for notifications with an extensible architecture that allows you to choose your preferred storage backend.
|
|
@@ -18,6 +18,12 @@ export type StringFilterLookup = {
|
|
|
18
18
|
caseSensitive?: boolean;
|
|
19
19
|
};
|
|
20
20
|
export type StringFieldFilter = string | StringFilterLookup;
|
|
21
|
+
export type NotificationOrderByField = 'sendAfter' | 'sentAt' | 'readAt' | 'createdAt' | 'updatedAt';
|
|
22
|
+
export type NotificationOrderDirection = 'asc' | 'desc';
|
|
23
|
+
export type NotificationOrderBy = {
|
|
24
|
+
field: NotificationOrderByField;
|
|
25
|
+
direction: NotificationOrderDirection;
|
|
26
|
+
};
|
|
21
27
|
/**
|
|
22
28
|
* Flat dotted key capability map describing which filter features a backend supports.
|
|
23
29
|
* Use flat dotted keys for logical operators, fields, and negations:
|
|
@@ -85,6 +91,11 @@ export declare const DEFAULT_BACKEND_FILTER_CAPABILITIES: {
|
|
|
85
91
|
'stringLookups.endsWith': boolean;
|
|
86
92
|
'stringLookups.includes': boolean;
|
|
87
93
|
'stringLookups.caseInsensitive': boolean;
|
|
94
|
+
'orderBy.sendAfter': boolean;
|
|
95
|
+
'orderBy.sentAt': boolean;
|
|
96
|
+
'orderBy.readAt': boolean;
|
|
97
|
+
'orderBy.createdAt': boolean;
|
|
98
|
+
'orderBy.updatedAt': boolean;
|
|
88
99
|
};
|
|
89
100
|
export interface BaseNotificationBackend<Config extends BaseNotificationTypeConfig> {
|
|
90
101
|
/**
|
|
@@ -134,7 +145,7 @@ export interface BaseNotificationBackend<Config extends BaseNotificationTypeConf
|
|
|
134
145
|
* @param pageSize - Number of results per page
|
|
135
146
|
* @returns Matching notifications
|
|
136
147
|
*/
|
|
137
|
-
filterNotifications(filter: NotificationFilter<Config>, page: number, pageSize: number): Promise<AnyDatabaseNotification<Config>[]>;
|
|
148
|
+
filterNotifications(filter: NotificationFilter<Config>, page: number, pageSize: number, orderBy?: NotificationOrderBy): Promise<AnyDatabaseNotification<Config>[]>;
|
|
138
149
|
/**
|
|
139
150
|
* Get the filter capabilities supported by this backend.
|
|
140
151
|
* Returns an object with flat dotted keys indicating which filtering features are supported.
|
|
@@ -26,6 +26,11 @@ exports.DEFAULT_BACKEND_FILTER_CAPABILITIES = {
|
|
|
26
26
|
'stringLookups.endsWith': true,
|
|
27
27
|
'stringLookups.includes': true,
|
|
28
28
|
'stringLookups.caseInsensitive': true,
|
|
29
|
+
'orderBy.sendAfter': true,
|
|
30
|
+
'orderBy.sentAt': true,
|
|
31
|
+
'orderBy.readAt': true,
|
|
32
|
+
'orderBy.createdAt': true,
|
|
33
|
+
'orderBy.updatedAt': true,
|
|
29
34
|
};
|
|
30
35
|
/**
|
|
31
36
|
* Type guard to check if a filter is a field filter (leaf node).
|
|
@@ -6,7 +6,7 @@ import type { BaseAttachmentManager } from './attachment-manager/base-attachment
|
|
|
6
6
|
import type { BaseGitCommitShaProvider } from './git-commit-sha/base-git-commit-sha-provider';
|
|
7
7
|
import type { BaseLogger } from './loggers/base-logger';
|
|
8
8
|
import { type BaseNotificationAdapter } from './notification-adapters/base-notification-adapter';
|
|
9
|
-
import { type BaseNotificationBackend, type NotificationFilterFields } from './notification-backends/base-notification-backend';
|
|
9
|
+
import { type BaseNotificationBackend, type NotificationFilterFields, type NotificationOrderBy } from './notification-backends/base-notification-backend';
|
|
10
10
|
import type { BaseNotificationQueueService } from './notification-queue-service/base-notification-queue-service';
|
|
11
11
|
import type { EmailTemplate, EmailTemplateContent } from './notification-template-renderers/base-email-template-renderer';
|
|
12
12
|
import type { BaseNotificationTemplateRenderer } from './notification-template-renderers/base-notification-template-renderer';
|
|
@@ -145,7 +145,7 @@ export declare class VintaSend<Config extends BaseNotificationTypeConfig, Adapte
|
|
|
145
145
|
/**
|
|
146
146
|
* Filters notifications in the primary backend by default or in a specific backend.
|
|
147
147
|
*/
|
|
148
|
-
filterNotifications(filter: NotificationFilterFields<Config>, page: number, pageSize: number, backendIdentifier?: string): Promise<AnyDatabaseNotification<Config>[]>;
|
|
148
|
+
filterNotifications(filter: NotificationFilterFields<Config>, page: number, pageSize: number, orderBy?: NotificationOrderBy, backendIdentifier?: string): Promise<AnyDatabaseNotification<Config>[]>;
|
|
149
149
|
/**
|
|
150
150
|
* Returns the effective filter capabilities for the primary backend by default or for a specific backend.
|
|
151
151
|
*/
|
|
@@ -171,6 +171,11 @@ export declare class VintaSend<Config extends BaseNotificationTypeConfig, Adapte
|
|
|
171
171
|
'stringLookups.endsWith': boolean;
|
|
172
172
|
'stringLookups.includes': boolean;
|
|
173
173
|
'stringLookups.caseInsensitive': boolean;
|
|
174
|
+
'orderBy.sendAfter': boolean;
|
|
175
|
+
'orderBy.sentAt': boolean;
|
|
176
|
+
'orderBy.readAt': boolean;
|
|
177
|
+
'orderBy.createdAt': boolean;
|
|
178
|
+
'orderBy.updatedAt': boolean;
|
|
174
179
|
}>;
|
|
175
180
|
/**
|
|
176
181
|
* Gets a one-off notification by ID.
|
|
@@ -428,8 +428,8 @@ class VintaSend {
|
|
|
428
428
|
/**
|
|
429
429
|
* Filters notifications in the primary backend by default or in a specific backend.
|
|
430
430
|
*/
|
|
431
|
-
async filterNotifications(filter, page, pageSize, backendIdentifier) {
|
|
432
|
-
return this.getBackend(backendIdentifier).filterNotifications(filter, page, pageSize);
|
|
431
|
+
async filterNotifications(filter, page, pageSize, orderBy, backendIdentifier) {
|
|
432
|
+
return this.getBackend(backendIdentifier).filterNotifications(filter, page, pageSize, orderBy);
|
|
433
433
|
}
|
|
434
434
|
/**
|
|
435
435
|
* Returns the effective filter capabilities for the primary backend by default or for a specific backend.
|