@remit/mailbox-service 0.0.44 → 0.0.45
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 +1 -1
- package/src/outbox-queue.ts +14 -10
package/package.json
CHANGED
package/src/outbox-queue.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type {
|
|
|
5
5
|
IOutboxMessageRepository,
|
|
6
6
|
OutboxMessageItem,
|
|
7
7
|
} from "@remit/data-ports";
|
|
8
|
+
import { ConflictError } from "@remit/data-ports/errors";
|
|
8
9
|
import { OutboxMessageStatus } from "@remit/domain-enums";
|
|
9
10
|
import { createQueueProducer } from "@remit/sqs-client/producer";
|
|
10
11
|
|
|
@@ -31,6 +32,7 @@ export interface OutboxQueueConfig {
|
|
|
31
32
|
accountService: IAccountRepository;
|
|
32
33
|
sqsSmtpQueueUrl: string;
|
|
33
34
|
sqsEndpoint?: string;
|
|
35
|
+
sqsClient?: SQSClient;
|
|
34
36
|
logger?: OutboxQueueLogger;
|
|
35
37
|
}
|
|
36
38
|
|
|
@@ -91,10 +93,12 @@ export class OutboxQueueService {
|
|
|
91
93
|
this.queueUrl = sqsSmtpQueueUrl;
|
|
92
94
|
this.log = config.logger ?? noopLogger;
|
|
93
95
|
|
|
94
|
-
this.sqs =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
this.sqs =
|
|
97
|
+
config.sqsClient ??
|
|
98
|
+
createQueueProducer({
|
|
99
|
+
queueUrl: sqsSmtpQueueUrl,
|
|
100
|
+
endpoint: sqsEndpoint,
|
|
101
|
+
});
|
|
98
102
|
}
|
|
99
103
|
|
|
100
104
|
createDraft = async (input: CreateDraftInput): Promise<OutboxMessageItem> => {
|
|
@@ -137,8 +141,8 @@ export class OutboxQueueService {
|
|
|
137
141
|
"act",
|
|
138
142
|
);
|
|
139
143
|
if (existing.status !== OutboxMessageStatus.draft) {
|
|
140
|
-
throw new
|
|
141
|
-
`
|
|
144
|
+
throw new ConflictError(
|
|
145
|
+
`This message is already ${existing.status} and can no longer be edited as a draft. Start a new message to change it.`,
|
|
142
146
|
);
|
|
143
147
|
}
|
|
144
148
|
|
|
@@ -184,8 +188,8 @@ export class OutboxQueueService {
|
|
|
184
188
|
existing.status !== OutboxMessageStatus.failed &&
|
|
185
189
|
existing.status !== OutboxMessageStatus.blocked
|
|
186
190
|
) {
|
|
187
|
-
throw new
|
|
188
|
-
`
|
|
191
|
+
throw new ConflictError(
|
|
192
|
+
`This message is already ${existing.status} and cannot be sent again. Open the Outbox to see where it stands.`,
|
|
189
193
|
);
|
|
190
194
|
}
|
|
191
195
|
|
|
@@ -252,8 +256,8 @@ export class OutboxQueueService {
|
|
|
252
256
|
existing.status !== OutboxMessageStatus.failed &&
|
|
253
257
|
existing.status !== OutboxMessageStatus.blocked
|
|
254
258
|
) {
|
|
255
|
-
throw new
|
|
256
|
-
`
|
|
259
|
+
throw new ConflictError(
|
|
260
|
+
`This message is already ${existing.status} and can no longer be discarded. Open the Outbox to see where it stands.`,
|
|
257
261
|
);
|
|
258
262
|
}
|
|
259
263
|
|