@clipboard-health/notifications 1.2.0 → 1.2.1
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/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clipboard-health/notifications",
|
|
3
3
|
"description": "Send notifications through third-party providers.",
|
|
4
|
-
"version": "1.2.
|
|
4
|
+
"version": "1.2.1",
|
|
5
5
|
"bugs": "https://github.com/ClipboardHealth/core-utils/issues",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@clipboard-health/background-jobs-adapter": "0.5.
|
|
8
|
-
"@clipboard-health/phone-number": "0.9.
|
|
9
|
-
"@clipboard-health/util-ts": "3.18.
|
|
7
|
+
"@clipboard-health/background-jobs-adapter": "0.5.1",
|
|
8
|
+
"@clipboard-health/phone-number": "0.9.1",
|
|
9
|
+
"@clipboard-health/util-ts": "3.18.1",
|
|
10
10
|
"@knocklabs/node": "1.20.0",
|
|
11
11
|
"tslib": "2.8.1"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@clipboard-health/testing-core": "0.27.
|
|
14
|
+
"@clipboard-health/testing-core": "0.27.1",
|
|
15
15
|
"type-fest": "5.0.1"
|
|
16
16
|
},
|
|
17
17
|
"keywords": [],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type BackgroundJobsAdapter } from "@clipboard-health/background-jobs-adapter";
|
|
1
|
+
import { type BackgroundJobsAdapter, type MongoEnqueueOptions, type PostgresEnqueueOptions } from "@clipboard-health/background-jobs-adapter";
|
|
2
2
|
import { type TriggerIdempotencyKey } from "./triggerIdempotencyKey";
|
|
3
3
|
type EnqueueParameters = Parameters<BackgroundJobsAdapter["enqueue"]>;
|
|
4
4
|
export interface IdempotencyKey {
|
|
@@ -76,6 +76,14 @@ export interface NotificationData<T> {
|
|
|
76
76
|
Job: NotificationJobData & T;
|
|
77
77
|
Enqueue: NotificationEnqueueData & T;
|
|
78
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* `enqueueOneOrMore` sets `idempotencyKey`/`unique` automatically, so it's not accepted here.
|
|
81
|
+
*
|
|
82
|
+
* `startAt` is also not accepted. To prevent stale recipient lists, notification jobs shouldn't
|
|
83
|
+
* start in the future. Use `startAt` to schedule a normal job in the future that, when executed,
|
|
84
|
+
* looks up recipients and queues a notification job that runs immediately.
|
|
85
|
+
*/
|
|
86
|
+
export type EnqueueOneOrMoreOptions = Pick<MongoEnqueueOptions, "session"> | Pick<PostgresEnqueueOptions, "transaction">;
|
|
79
87
|
interface NotificationJobEnqueuerParams {
|
|
80
88
|
adapter: BackgroundJobsAdapter;
|
|
81
89
|
}
|
|
@@ -150,6 +158,6 @@ export declare class NotificationJobEnqueuer {
|
|
|
150
158
|
*
|
|
151
159
|
* </embedex>
|
|
152
160
|
*/
|
|
153
|
-
enqueueOneOrMore<TEnqueueData extends NotificationEnqueueData>(handlerClassOrInstance: EnqueueParameters[0], data: TEnqueueData, options?:
|
|
161
|
+
enqueueOneOrMore<TEnqueueData extends NotificationEnqueueData>(handlerClassOrInstance: EnqueueParameters[0], data: TEnqueueData, options?: EnqueueOneOrMoreOptions): Promise<void>;
|
|
154
162
|
}
|
|
155
163
|
export {};
|
|
@@ -79,9 +79,7 @@ class NotificationJobEnqueuer {
|
|
|
79
79
|
*
|
|
80
80
|
* </embedex>
|
|
81
81
|
*/
|
|
82
|
-
async enqueueOneOrMore(handlerClassOrInstance, data,
|
|
83
|
-
// The job's idempotency/unique key is set automatically.
|
|
84
|
-
options) {
|
|
82
|
+
async enqueueOneOrMore(handlerClassOrInstance, data, options) {
|
|
85
83
|
await Promise.all((0, chunkRecipients_1.chunkRecipients)({ recipients: data.recipients }).map(async ({ number, recipients }) => {
|
|
86
84
|
const idempotencyKeyParams = {
|
|
87
85
|
...data.idempotencyKey,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notificationJobEnqueuer.js","sourceRoot":"","sources":["../../../../../packages/notifications/src/lib/notificationJobEnqueuer.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"notificationJobEnqueuer.js","sourceRoot":"","sources":["../../../../../packages/notifications/src/lib/notificationJobEnqueuer.ts"],"names":[],"mappings":";;;AAAA,uFAKmD;AAEnD,gEAA6D;AAC7D,oGAAiG;AACjG,mEAIiC;AA4GjC,MAAa,uBAAuB;IACjB,OAAO,CAA2C;IAEnE,YAAY,MAAqC;QAC/C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;QAE3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmEG;IACH,KAAK,CAAC,gBAAgB,CACpB,sBAA4C,EAC5C,IAAkB,EAClB,OAAiC;QAEjC,MAAM,OAAO,CAAC,GAAG,CACf,IAAA,iCAAe,EAAC,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE;YACpF,MAAM,oBAAoB,GAAgC;gBACxD,GAAG,IAAI,CAAC,cAAc;gBACtB,KAAK,EAAE,MAAM;gBACb,UAAU;gBACV,WAAW,EAAE,IAAI,CAAC,WAAW;aAC9B,CAAC;YAEF,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CACxB,sBAAsB,EACtB;gBACE,GAAG,IAAI;gBACP,UAAU;gBACV,cAAc,EAAE,IAAA,yDAAiC,EAAC,oBAAoB,CAAC;aACxE,EACD;gBACE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClC,CAAC,6CAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,EAC/D,IAAA,qEAAiC,EAAC,oBAAoB,CAAC;aAC1D,CACF,CAAC;QACJ,CAAC,CAAC,CACH,CAAC;IACJ,CAAC;CACF;AA3GD,0DA2GC"}
|