@remit/data-ports 0.0.40 → 0.0.41

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/data-ports",
3
- "version": "0.0.40",
3
+ "version": "0.0.41",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -37,6 +37,10 @@
37
37
  "types": "./src/folder-role.ts",
38
38
  "default": "./src/folder-role.ts"
39
39
  },
40
+ "./mutation-events": {
41
+ "types": "./src/mutation-events.ts",
42
+ "default": "./src/mutation-events.ts"
43
+ },
40
44
  "./mailbox-name": {
41
45
  "types": "./src/mailbox-name.ts",
42
46
  "default": "./src/mailbox-name.ts"
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The contract version the mail-destroying queue events are minted under.
3
+ *
4
+ * It lives here because the producer (`MessageMoveService`) and the consumer
5
+ * (the imap-worker's handlers) sit in packages that cannot import each other,
6
+ * and a version the two sides disagree about is worse than no version at all.
7
+ * Bump it whenever a handler starts relying on a field an older producer never
8
+ * set.
9
+ */
10
+ export const MUTATION_EVENT_SCHEMA_VERSION = 2;
11
+
12
+ /**
13
+ * Queue payloads are `JSON.parse`d and cast with no validation, so the declared
14
+ * type is a promise the queue cannot keep. A handler that cannot vouch for an
15
+ * event's shape abandons it — treating a missing field as "skip the check"
16
+ * makes the unverified expunge the default for every event we cannot vouch for,
17
+ * including any future producer that forgets the field.
18
+ */
19
+ export const isCurrentSchemaVersion = (value: unknown): boolean =>
20
+ value === MUTATION_EVENT_SCHEMA_VERSION;