@remit/data-ports 0.0.86 → 0.0.87

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
@@ -29,7 +29,7 @@ export { holdsRoom } from "./interfaces/outbox-attachment.js";
29
29
  export type { IOutboxMessageRepository } from "./interfaces/outbox-message.js";
30
30
  export { APPENDED_UID_NONE, APPENDED_UID_UNREPORTED, isSentCopyFiled, } from "./interfaces/outbox-message.js";
31
31
  export type { IQuarantineRepository } from "./interfaces/quarantine.js";
32
- export { type FifoQueueMessage, type FifoQueueProducer, type GroupedQueueMessage, type GroupedQueueProducer, QUEUE_BATCH_LIMIT, type QueueBatchResult, type QueueMessage, type QueueProducer, } from "./interfaces/queue.js";
32
+ export { type FifoQueueMessage, type FifoQueueProducer, type GroupedQueueMessage, type GroupedQueueProducer, QUEUE_BATCH_LIMIT, type QueueBatchResult, type QueueKind, type QueueMessage, type QueueProducer, type QueueProducerOf, } from "./interfaces/queue.js";
33
33
  export type { ISenderSignerStandingRepository } from "./interfaces/sender-signer-standing.js";
34
34
  export type { ISyncWarningRepository, SurfacedSyncWarnings, } from "./interfaces/sync-warning.js";
35
35
  export type { IThreadMessageRepository } from "./interfaces/thread-message.js";
@@ -1,6 +1,5 @@
1
1
  export interface QueueMessage<T> {
2
2
  readonly body: T;
3
- readonly delaySeconds?: number;
4
3
  }
5
4
  export interface GroupedQueueMessage<T> extends QueueMessage<T> {
6
5
  readonly groupId: string;
@@ -12,9 +11,12 @@ export interface QueueBatchResult {
12
11
  readonly refused: ReadonlySet<number>;
13
12
  }
14
13
  export declare const QUEUE_BATCH_LIMIT = 10;
15
- export interface QueueProducer<T, M extends QueueMessage<T> = QueueMessage<T>> {
14
+ export type QueueKind = "Standard" | "Grouped" | "Fifo";
15
+ export interface QueueProducerOf<K extends QueueKind, M> {
16
+ readonly kind: K;
16
17
  readonly send: (message: M) => Promise<void>;
17
18
  readonly sendBatch: (messages: readonly M[]) => Promise<QueueBatchResult>;
18
19
  }
19
- export type FifoQueueProducer<T> = QueueProducer<T, FifoQueueMessage<T>>;
20
- export type GroupedQueueProducer<T> = QueueProducer<T, GroupedQueueMessage<T>>;
20
+ export type QueueProducer<T> = QueueProducerOf<"Standard", QueueMessage<T>>;
21
+ export type GroupedQueueProducer<T> = QueueProducerOf<"Grouped", GroupedQueueMessage<T>>;
22
+ export type FifoQueueProducer<T> = QueueProducerOf<"Fifo", FifoQueueMessage<T>>;
@@ -1,10 +1,12 @@
1
- import type { QueueProducer } from "./interfaces/queue.js";
1
+ import type { FifoQueueProducer, GroupedQueueProducer, QueueProducer } from "./interfaces/queue.js";
2
2
  export interface RecordedMessage {
3
3
  body: Record<string, unknown>;
4
4
  groupId: string | undefined;
5
5
  deduplicationId: string | undefined;
6
6
  }
7
7
  export interface RecordingQueue extends QueueProducer<unknown> {
8
+ readonly fifo: FifoQueueProducer<unknown>;
9
+ readonly grouped: GroupedQueueProducer<unknown>;
8
10
  readonly sent: RecordedMessage[];
9
11
  readonly answer: (next: () => Promise<unknown>) => void;
10
12
  readonly refuse: (positions: readonly number[]) => void;
@@ -17,7 +17,19 @@ export const recordingQueue = () => {
17
17
  const sent = [];
18
18
  let answer = async () => ({});
19
19
  let refused = new Set();
20
+ const send = async (message) => {
21
+ sent.push(recorded(message));
22
+ await answer();
23
+ };
24
+ const sendBatch = async (messages) => {
25
+ sent.push(...messages.map(recorded));
26
+ await answer();
27
+ return { refused };
28
+ };
20
29
  return {
30
+ kind: "Standard",
31
+ fifo: { kind: "Fifo", send, sendBatch },
32
+ grouped: { kind: "Grouped", send, sendBatch },
21
33
  sent,
22
34
  answer: (next) => {
23
35
  answer = next;
@@ -25,15 +37,8 @@ export const recordingQueue = () => {
25
37
  refuse: (positions) => {
26
38
  refused = new Set(positions);
27
39
  },
28
- send: async (message) => {
29
- sent.push(recorded(message));
30
- await answer();
31
- },
32
- sendBatch: async (messages) => {
33
- sent.push(...messages.map(recorded));
34
- await answer();
35
- return { refused };
36
- },
40
+ send,
41
+ sendBatch,
37
42
  };
38
43
  };
39
44
  export const failingQueue = (error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/data-ports",
3
- "version": "0.0.86",
3
+ "version": "0.0.87",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",