@bumail/queue 0.9.0 → 0.11.0

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.
Files changed (57) hide show
  1. package/README.md +30 -2
  2. package/dist/chunks/{index-9yp15arf.js → index-t6q7zxgj.js} +27 -4
  3. package/dist/chunks/index-t6q7zxgj.js.map +14 -0
  4. package/dist/contract/checks.d.ts +4 -0
  5. package/dist/contract/checks.d.ts.map +1 -1
  6. package/dist/contract/dsn-checks.d.ts.map +1 -1
  7. package/dist/contract/queue-store.d.ts +15 -7
  8. package/dist/contract/queue-store.d.ts.map +1 -1
  9. package/dist/contract/types.d.ts +5 -0
  10. package/dist/contract/types.d.ts.map +1 -1
  11. package/dist/dsn/delivered.d.ts +2 -16
  12. package/dist/dsn/delivered.d.ts.map +1 -1
  13. package/dist/dsn/failed.d.ts +29 -0
  14. package/dist/dsn/failed.d.ts.map +1 -0
  15. package/dist/dsn/for.d.ts +26 -0
  16. package/dist/dsn/for.d.ts.map +1 -0
  17. package/dist/dsn/policy.d.ts +2 -0
  18. package/dist/dsn/policy.d.ts.map +1 -1
  19. package/dist/errors.d.ts +3 -1
  20. package/dist/errors.d.ts.map +1 -1
  21. package/dist/index.d.ts +3 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +99 -42
  24. package/dist/index.js.map +10 -8
  25. package/dist/memory/index.js +10 -6
  26. package/dist/memory/index.js.map +3 -3
  27. package/dist/memory/store.d.ts +2 -2
  28. package/dist/memory/store.d.ts.map +1 -1
  29. package/dist/postgres/complete.d.ts +13 -0
  30. package/dist/postgres/complete.d.ts.map +1 -0
  31. package/dist/postgres/index.js +85 -74
  32. package/dist/postgres/index.js.map +6 -5
  33. package/dist/postgres/store.d.ts +2 -2
  34. package/dist/postgres/store.d.ts.map +1 -1
  35. package/dist/queue/deliver.d.ts.map +1 -1
  36. package/dist/queue/notify.d.ts +35 -6
  37. package/dist/queue/notify.d.ts.map +1 -1
  38. package/dist/queue/settings/limits.d.ts.map +1 -1
  39. package/dist/redis/complete.d.ts +11 -0
  40. package/dist/redis/complete.d.ts.map +1 -0
  41. package/dist/redis/index.js +133 -110
  42. package/dist/redis/index.js.map +7 -6
  43. package/dist/redis/scripts.d.ts +8 -5
  44. package/dist/redis/scripts.d.ts.map +1 -1
  45. package/dist/redis/store.d.ts +2 -2
  46. package/dist/redis/store.d.ts.map +1 -1
  47. package/dist/sqlite/index.js +29 -20
  48. package/dist/sqlite/index.js.map +5 -4
  49. package/dist/sqlite/insert.d.ts +5 -0
  50. package/dist/sqlite/insert.d.ts.map +1 -0
  51. package/dist/sqlite/store.d.ts +2 -2
  52. package/dist/sqlite/store.d.ts.map +1 -1
  53. package/docs/guide.md +59 -0
  54. package/docs/roadmap.md +36 -10
  55. package/docs/troubleshooting.md +67 -3
  56. package/package.json +4 -4
  57. package/dist/chunks/index-9yp15arf.js.map +0 -14
package/README.md CHANGED
@@ -113,7 +113,8 @@ list, only those events. Upgrading a shared store: stop every old worker
113
113
  before starting a new one (an old worker that keeps running ignores the
114
114
  DSN parameters and drops them from the items it completes). `SUCCESS` with a next hop that does not offer DSN
115
115
  sends a `relayed` DSN. For a message the application delivered itself,
116
- `deliveredDsn()` writes the `delivered` one.
116
+ `deliveredDsn()` writes the `delivered` one, and `failedDsn()` the `failed`
117
+ one for a recipient it could not deliver.
117
118
 
118
119
  ## Routing
119
120
 
@@ -312,6 +313,31 @@ control character in it.
312
313
  - **It sends what you enqueue, to anyone.** The queue is not a relay
313
314
  policy: enqueue only what an authenticated user submitted, or what your
314
315
  own server writes, never what an unauthenticated client handed you.
316
+ - **A custom `QueueStore` must port `complete` (0.11, breaking).**
317
+ `complete(id, owner, result, dsns)` takes the DSN items the outcome
318
+ calls for and returns `{ item, dsns }`, or `undefined` for a lost lease.
319
+ Store the outcome and the DSNs in one step, so a crash cannot leave one
320
+ without the other; a store that returns the bare item still works, but
321
+ the queue reports `Queue store outdated` on the `error` event and adds
322
+ each DSN with `add`, outside that step. The stores of this package are
323
+ atomic. DSNs ignore `limits.maxItems`: a full queue still bounces, and the
324
+ count may exceed the limit by the DSNs it holds. They are delivered at least once; see [Writing a
325
+ store](./docs/guide.md#writing-a-store). The `this.*` calls below are
326
+ your store's own helpers, a sketch.
327
+
328
+ ```ts
329
+ async complete(id, owner, result, dsns) {
330
+ // refuse a bad DSN (INVALID) before opening a connection or a transaction
331
+ for (const dsn of dsns) this.check(dsn);
332
+ return this.transaction(async () => {
333
+ const item = await this.apply(id, owner, result); // undefined on a lost lease
334
+ if (!item) return undefined; // writes no DSN
335
+ const stored = [];
336
+ for (const dsn of dsns) stored.push(await this.insert(dsn)); // in order
337
+ return { item, dsns: stored };
338
+ });
339
+ }
340
+ ```
315
341
 
316
342
  ## API
317
343
 
@@ -321,8 +347,10 @@ control character in it.
321
347
  | `QueueOptions` (`route`, `routes`, `fallback`), `Route`, `Smarthost`, `RetrySchedule`, `DsnOptions`, `QueueLimits`, `Clock`, `Sender` | what `createQueue` takes |
322
348
  | `MessageSource`, `QueueEnvelope` (`ret`, `envid`, `recipients`), `RecipientDsn`, `RecipientNotify`, `NotifyEvent`, `OriginalRecipient`, `RetMode` | what `enqueue` takes, with the DSN parameters |
323
349
  | `deliveredDsn(input)`, `DeliveredDsnInput`, `DeliveredRecipient` | the `delivered` DSN for a local delivery: the bytes to enqueue, or `undefined` when no recipient asked for `SUCCESS` |
350
+ | `failedDsn(input)`, `FailedDsnInput`, `FailedRecipient`, `DEFAULT_MAX_RETURN` | the `failed` DSN for a recipient the application could not deliver locally: the bytes to enqueue, or `undefined` for a null reverse-path or when no recipient asked for failures; `DEFAULT_MAX_RETURN` is the 64 KiB a DSN returns of the original by default |
324
351
  | `QueueEvents`, `QueueListener`, `RecipientEvent` (`route`, `fallback`, `mxReply`, `mayHaveReachedMx`, `mayHaveReachedFallback`), `DeferredEvent`, `DsnEvent`, `QueueErrorEvent` | the events |
325
- | `QueueStore` | the contract a store answers: `add`, `get`, `list`, `count`, `readMessage`, `claim`, `renew`, `complete`, `reschedule`, `cancel` |
352
+ | `QueueStore` | the contract a store answers: `add`, `get`, `list`, `count`, `readMessage`, `claim`, `renew`, `complete(id, owner, result, dsns)`, `reschedule`, `cancel` |
353
+ | `Completed` (`item`, `dsns`) | what `complete` returns: the item as it now stands, and the DSN items it stored in the same step, in the order given; `undefined` when the lease was lost |
326
354
  | `QueueItem`, `RecipientState`, `RecipientStatus`, `FinalStatus`, `Diagnostic`, `Lease` | an item, and where each recipient stands |
327
355
  | `NewQueueItem`, `AddOptions`, `ClaimRequest`, `AttemptResult`, `RecipientUpdate`, `QueueListOptions` | what a store takes |
328
356
  | `QueueError`, `QueueErrorCode` | `INVALID`, `MESSAGE_TOO_BIG`, `TOO_MANY_RECIPIENTS`, `QUEUE_FULL`, `CLOSED`, `LEASE_LOST`, `MESSAGE_UNREADABLE` |
@@ -53,6 +53,17 @@ function xtextLength(text) {
53
53
  }
54
54
  return length;
55
55
  }
56
+ function utf8OrcptLength(text) {
57
+ let length = 0;
58
+ for (const char of text) {
59
+ const code = char.codePointAt(0);
60
+ if (code > 127)
61
+ length += new TextEncoder().encode(char).length;
62
+ else
63
+ length += code >= 33 && code !== 92 && code !== 43 && code !== 61 && code < 127 ? 1 : 6;
64
+ }
65
+ return length;
66
+ }
56
67
  function checkRecipientDsn(entry, to) {
57
68
  const { address, notify, orcpt } = entry ?? {};
58
69
  if (typeof address !== "string" || !to.includes(address)) {
@@ -69,7 +80,8 @@ function checkRecipientDsn(entry, to) {
69
80
  if (typeof orcpt !== "object" || orcpt === null || typeof orcpt.type !== "string" || !/^[A-Za-z0-9-]+$/.test(orcpt.type) || typeof orcpt.address !== "string" || orcpt.address === "") {
70
81
  throw invalid(`orcpt of ${address} must be { type, address }`);
71
82
  }
72
- if (orcpt.type.length + 1 + xtextLength(orcpt.address) > 500) {
83
+ const encoded = orcpt.type.toLowerCase() === "utf-8" ? utf8OrcptLength(orcpt.address) : xtextLength(orcpt.address);
84
+ if (orcpt.type.length + 1 + encoded > 500) {
73
85
  throw invalid(`orcpt of ${address} is over 500 characters once encoded`);
74
86
  }
75
87
  checkStorable("orcpt.type", orcpt.type);
@@ -136,6 +148,17 @@ function checkUpdate(update) {
136
148
  checkStorable(`reply.${name}`, value);
137
149
  }
138
150
  }
151
+ function checkDsns(dsns) {
152
+ if (!Array.isArray(dsns))
153
+ throw invalid("dsns must be an array");
154
+ for (const dsn of dsns)
155
+ checkNewItem(dsn);
156
+ }
157
+ function checkComplete(owner, result, dsns) {
158
+ checkOwner(owner);
159
+ checkResult(result);
160
+ checkDsns(dsns);
161
+ }
139
162
  function checkNewItem(item) {
140
163
  if (typeof item !== "object" || item === null) {
141
164
  throw invalid("A new item is an object");
@@ -255,7 +278,7 @@ function newItem(id, item) {
255
278
  }
256
279
  var claimable = (item, now) => item.nextAttemptAt <= now && (item.lease === undefined || item.lease.expiresAt <= now);
257
280
 
258
- export { hasControl, replaceControls, cleanText, isStorable, asciiText, QueueError2, invalid, checkTime, checkOwner, checkNewItem, checkMaxItems, checkClaim, checkResult, checkList, isDone, applyAttempt, newItem, claimable };
281
+ export { hasControl, replaceControls, cleanText, isStorable, asciiText, QueueError2, invalid, checkTime, checkOwner, checkComplete, checkNewItem, checkMaxItems, checkClaim, checkList, isDone, applyAttempt, newItem, claimable };
259
282
 
260
- //# debugId=C41FD2A676DEB7AF64756E2164756E21
261
- //# sourceMappingURL=index-9yp15arf.js.map
283
+ //# debugId=17F888FDC5191A2364756E2164756E21
284
+ //# sourceMappingURL=index-t6q7zxgj.js.map
@@ -0,0 +1,14 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/text.ts", "../src/errors.ts", "../src/contract/storable.ts", "../src/contract/dsn-checks.ts", "../src/contract/checks.ts"],
4
+ "sourcesContent": [
5
+ "/** Text from the other side, made safe to keep and to write in a header field. */\n\n/** C0, DEL and C1: every control character, CR, LF and TAB included. */\nconst isControl = (code: number) =>\n\tcode < 0x20 || (code >= 0x7f && code <= 0x9f);\n\n/** Whether the text holds a control character. */\nexport function hasControl(text: string): boolean {\n\tfor (let i = 0; i < text.length; i++) {\n\t\tif (isControl(text.charCodeAt(i))) return true;\n\t}\n\treturn false;\n}\n\n/** Each control character replaced by `by`. */\nexport function replaceControls(text: string, by: string): string {\n\tlet out = '';\n\tfor (let i = 0; i < text.length; i++) {\n\t\tout += isControl(text.charCodeAt(i)) ? by : (text[i] as string);\n\t}\n\treturn out;\n}\n\n/**\n * Every control character (CR and LF included) as a space, a lone\n * surrogate as U+FFFD, runs of space as one, cut at `max` characters with\n * `...`, never inside a surrogate pair: what a reply leaves in an item,\n * an event and a DSN.\n */\nexport function cleanText(text: string, max: number): string {\n\tconst clean = replaceControls(text.toWellFormed(), ' ')\n\t\t.replace(/ {2,}/g, ' ')\n\t\t.trim();\n\treturn clean.length > max ? `${cut(clean, max - 3)}...` : clean;\n}\n\n/**\n * The first `length` UTF-16 units, never ending inside a surrogate pair:\n * a lone surrogate is text no store can keep (PostgreSQL's `jsonb` refuses\n * it), nor any UTF-8 encode.\n */\nfunction cut(text: string, length: number): string {\n\tconst head = text.slice(0, length);\n\tconst last = head.charCodeAt(head.length - 1);\n\treturn last >= 0xd800 && last <= 0xdbff ? head.slice(0, -1) : head;\n}\n\n/**\n * Text every store can keep: no NUL (PostgreSQL's `text` and `jsonb` hold\n * none) and no lone surrogate. `cleanText`'s output always is.\n */\nexport const isStorable = (text: string): boolean =>\n\ttext.isWellFormed() && !text.includes('\\0');\n\n/** `cleanText`, then anything not printable ASCII as `?`: for a `message/delivery-status` field. */\nexport const asciiText = (text: string, max: number): string =>\n\tcleanText(text, max).replace(/[^ -~]/g, '?');\n",
6
+ "/**\n * Why the queue or a store refused a call. `INVALID`: an option or an\n * argument it cannot take, or, given to the `error` event, a store that\n * answers an older contract (`complete` returning the item alone, without\n * the DSNs). `MESSAGE_TOO_BIG`, `TOO_MANY_RECIPIENTS` and\n * `QUEUE_FULL`: a limit `enqueue` enforces. `CLOSED`: a store used after\n * `close()`. `LEASE_LOST`: given to the `error` event when another worker\n * took an item before its outcome was recorded — or, once the lease's\n * expiry passed, when the item is gone: lost or cancelled.\n * `MESSAGE_UNREADABLE`: given to the `error` event when the store holds an\n * item but not its message, whose pending recipients then fail.\n */\nexport type QueueErrorCode =\n\t| 'INVALID'\n\t| 'MESSAGE_TOO_BIG'\n\t| 'TOO_MANY_RECIPIENTS'\n\t| 'QUEUE_FULL'\n\t| 'CLOSED'\n\t| 'LEASE_LOST'\n\t| 'MESSAGE_UNREADABLE';\n\n/** Thrown by the queue and by every store, whichever answers the contract, with the same codes. */\nexport class QueueError extends Error {\n\toverride readonly name = 'QueueError';\n\treadonly code: QueueErrorCode;\n\n\tconstructor(code: QueueErrorCode, message: string) {\n\t\tsuper(message);\n\t\tthis.code = code;\n\t}\n}\n\n/** `INVALID`, for an option or an argument. */\nexport const invalid = (message: string) => new QueueError('INVALID', message);\n",
7
+ "import { invalid } from '../errors';\nimport { isStorable } from '../text';\n\n/**\n * Text a store keeps: refused, the same way by every store, when it holds\n * a NUL or a lone surrogate, which PostgreSQL cannot keep and no UTF-8\n * encode can carry.\n */\nexport function checkStorable(name: string, text: string): void {\n\tif (!isStorable(text)) {\n\t\tthrow invalid(\n\t\t\t`${name} holds a NUL or a lone surrogate, which a store cannot keep`,\n\t\t);\n\t}\n}\n",
8
+ "// The value rules (and utf8OrcptLength, RFC 6533) repeat packages/smtp/src/server/dsn-params.ts, packages/smtp/src/client/dsn.ts and\n// packages/jmap/src/submission/dsn.ts (AGENTS.md, Deliberate duplications); this copy guards the contract.\nimport { invalid } from '../errors';\nimport { checkStorable } from './storable';\nimport type { NewQueueItem, RecipientDsn } from './types';\n\nconst EVENTS: readonly unknown[] = ['SUCCESS', 'FAILURE', 'DELAY'];\n\n/**\n * The length the xtext of `text` takes on the wire (RFC 3461 §4): one\n * character for each byte of its UTF-8 form in `!` to `~` but `+` and `=`,\n * three for any other.\n */\nfunction xtextLength(text: string): number {\n\tlet length = 0;\n\tfor (const byte of new TextEncoder().encode(text)) {\n\t\tlength +=\n\t\t\tbyte >= 33 && byte <= 126 && byte !== 0x2b && byte !== 0x3d ? 1 : 3;\n\t}\n\treturn length;\n}\n\n/**\n * The length of a `utf-8` ORCPT address in its `utf-8-addr-unitext` form (RFC\n * 6533 §3), the shortest one: raw UTF-8 octets for a non-ASCII character, one\n * for printable ASCII but `\\`, `+` and `=`, and `\\x{HH}` (6) for the rest.\n * The SMTP server counts the value as sent, which is this for a unitext one.\n */\nfunction utf8OrcptLength(text: string): number {\n\tlet length = 0;\n\tfor (const char of text) {\n\t\tconst code = char.codePointAt(0) as number;\n\t\tif (code > 0x7f) length += new TextEncoder().encode(char).length;\n\t\telse\n\t\t\tlength +=\n\t\t\t\tcode >= 0x21 &&\n\t\t\t\tcode !== 0x5c &&\n\t\t\t\tcode !== 0x2b &&\n\t\t\t\tcode !== 0x3d &&\n\t\t\t\tcode < 0x7f\n\t\t\t\t\t? 1\n\t\t\t\t\t: 6;\n\t}\n\treturn length;\n}\n\n/** One recipient's `NOTIFY` (RFC 3461 §4.1) and `ORCPT` (§4.2). */\nfunction checkRecipientDsn(entry: RecipientDsn, to: readonly string[]): void {\n\tconst { address, notify, orcpt } = entry ?? {};\n\tif (typeof address !== 'string' || !to.includes(address)) {\n\t\tthrow invalid(\n\t\t\t`recipients names ${JSON.stringify(address)}, which is not in to`,\n\t\t);\n\t}\n\tif (notify !== undefined && notify !== 'NEVER') {\n\t\tconst events: readonly unknown[] = Array.isArray(notify) ? notify : [];\n\t\tif (\n\t\t\tevents.length === 0 ||\n\t\t\tevents.some((e, i) => !EVENTS.includes(e) || events.indexOf(e) !== i)\n\t\t) {\n\t\t\tthrow invalid(\n\t\t\t\t`notify of ${address} must be 'NEVER' or a list of 'SUCCESS', 'FAILURE', 'DELAY', each once`,\n\t\t\t);\n\t\t}\n\t}\n\tif (orcpt === undefined) return;\n\tif (\n\t\ttypeof orcpt !== 'object' ||\n\t\torcpt === null ||\n\t\ttypeof orcpt.type !== 'string' ||\n\t\t!/^[A-Za-z0-9-]+$/.test(orcpt.type) ||\n\t\ttypeof orcpt.address !== 'string' ||\n\t\torcpt.address === ''\n\t) {\n\t\tthrow invalid(`orcpt of ${address} must be { type, address }`);\n\t}\n\t// RFC 3461 §4.2: \"The entire ORCPT parameter MAY be up to 500 characters in length\", as sent.\n\tconst encoded =\n\t\torcpt.type.toLowerCase() === 'utf-8'\n\t\t\t? utf8OrcptLength(orcpt.address)\n\t\t\t: xtextLength(orcpt.address);\n\tif (orcpt.type.length + 1 + encoded > 500) {\n\t\tthrow invalid(`orcpt of ${address} is over 500 characters once encoded`);\n\t}\n\tcheckStorable('orcpt.type', orcpt.type);\n\tcheckStorable('orcpt.address', orcpt.address);\n}\n\n/** `ret`, `envid` and `recipients` of a new item. */\nexport function checkDsnParams(item: NewQueueItem): void {\n\tconst { ret, envid, recipients } = item;\n\tif (ret !== undefined && ret !== 'FULL' && ret !== 'HDRS') {\n\t\tthrow invalid(`ret must be 'FULL' or 'HDRS', not ${String(ret)}`);\n\t}\n\tif (\n\t\tenvid !== undefined &&\n\t\t(typeof envid !== 'string' ||\n\t\t\t!/^[ -~]{1,100}$/.test(envid) ||\n\t\t\t// RFC 3461 §4.4: \"The ENVID parameter MAY be up to 100 characters in length\", as sent.\n\t\t\txtextLength(envid) > 100)\n\t) {\n\t\tthrow invalid(\n\t\t\t'envid must be 1 to 100 printable ASCII characters, at most 100 once encoded as xtext',\n\t\t);\n\t}\n\tif (recipients === undefined) return;\n\tif (!Array.isArray(recipients)) {\n\t\tthrow invalid('recipients must be an array of { address, notify, orcpt }');\n\t}\n\tconst seen = new Set<string>();\n\tfor (const entry of recipients) {\n\t\tcheckRecipientDsn(entry, item.to);\n\t\tif (seen.has(entry.address)) {\n\t\t\tthrow invalid(`recipients names ${entry.address} twice`);\n\t\t}\n\t\tseen.add(entry.address);\n\t}\n}\n",
9
+ "import { invalid } from '../errors';\nimport { checkDsnParams } from './dsn-checks';\nimport { checkStorable } from './storable';\n\nexport { checkStorable };\n\nimport type {\n\tAttemptResult,\n\tClaimRequest,\n\tDiagnostic,\n\tNewQueueItem,\n\tQueueItem,\n\tQueueListOptions,\n\tRecipientState,\n\tRecipientUpdate,\n} from './types';\n\n/** What every store checks the same way, so each refuses the same input with the same error. */\n\nconst isTime = (value: unknown): value is number =>\n\ttypeof value === 'number' && Number.isFinite(value);\n\n/** A time in milliseconds since the epoch, or `INVALID` naming it. */\nexport function checkTime(name: string, value: unknown): number {\n\tif (!isTime(value)) throw invalid(`${name} must be a finite number`);\n\treturn value;\n}\n\n/** A lease owner: a non-empty string. */\nexport function checkOwner(owner: unknown): string {\n\tif (typeof owner !== 'string' || owner === '') {\n\t\tthrow invalid('owner must be a non-empty string');\n\t}\n\tcheckStorable('owner', owner);\n\treturn owner;\n}\n\n/** Every text of a recipient's outcome. */\nfunction checkUpdate(update: RecipientUpdate): void {\n\tcheckStorable('A recipient', update.address);\n\tfor (const key of ['mayHaveReachedMx', 'mayHaveReachedFallback'] as const) {\n\t\tconst mark = update[key] as unknown;\n\t\tif (mark !== undefined && mark !== true) {\n\t\t\tthrow invalid(`${key} must be true or absent`);\n\t\t}\n\t}\n\tconst reply = update.reply as Partial<Diagnostic> | undefined;\n\tif (reply === undefined) return;\n\tif (\n\t\ttypeof reply !== 'object' ||\n\t\treply === null ||\n\t\ttypeof reply.text !== 'string'\n\t) {\n\t\tthrow invalid('A reply is an object with a text');\n\t}\n\tcheckStorable('reply.text', reply.text);\n\tfor (const name of ['status', 'host'] as const) {\n\t\tconst value = reply[name];\n\t\tif (value === undefined) continue;\n\t\tif (typeof value !== 'string')\n\t\t\tthrow invalid(`reply.${name} must be a string`);\n\t\tcheckStorable(`reply.${name}`, value);\n\t}\n}\n\n/** The DSN items `complete` takes: an array, each as `add` checks an item. */\nexport function checkDsns(dsns: readonly NewQueueItem[]): void {\n\tif (!Array.isArray(dsns)) throw invalid('dsns must be an array');\n\tfor (const dsn of dsns) checkNewItem(dsn);\n}\n\n/** What `complete` checks before any I/O, in this order: the owner, the result, the DSNs. */\nexport function checkComplete(\n\towner: unknown,\n\tresult: AttemptResult,\n\tdsns: readonly NewQueueItem[],\n): void {\n\tcheckOwner(owner);\n\tcheckResult(result);\n\tcheckDsns(dsns);\n}\n\nexport function checkNewItem(item: NewQueueItem): void {\n\tif (typeof item !== 'object' || item === null) {\n\t\tthrow invalid('A new item is an object');\n\t}\n\tif (typeof item.from !== 'string') throw invalid('from must be a string');\n\tcheckStorable('from', item.from);\n\tconst to = item.to as unknown;\n\tif (\n\t\t!Array.isArray(to) ||\n\t\tto.length === 0 ||\n\t\t!to.every((a) => typeof a === 'string' && a !== '')\n\t) {\n\t\tthrow invalid('to must be a non-empty array of addresses');\n\t}\n\tfor (const address of to as string[]) checkStorable('A recipient', address);\n\tif (!(item.message instanceof Uint8Array)) {\n\t\tthrow invalid('message must be a Uint8Array');\n\t}\n\tcheckTime('createdAt', item.createdAt);\n\tcheckDsnParams(item);\n}\n\n/** `maxItems`: a positive integer, or nothing. */\nexport function checkMaxItems(max: unknown): number | undefined {\n\tif (max === undefined) return undefined;\n\tif (typeof max !== 'number' || !Number.isInteger(max) || max < 1) {\n\t\tthrow invalid(`maxItems must be an integer of at least 1, not ${max}`);\n\t}\n\treturn max;\n}\n\nexport function checkClaim(request: ClaimRequest): void {\n\tif (typeof request !== 'object' || request === null) {\n\t\tthrow invalid('A claim is an object');\n\t}\n\tcheckOwner(request.owner);\n\tcheckTime('now', request.now);\n\tif (!isTime(request.leaseMs) || request.leaseMs <= 0) {\n\t\tthrow invalid('leaseMs must be a positive number');\n\t}\n}\n\nexport function checkResult(result: AttemptResult): void {\n\tif (typeof result !== 'object' || result === null) {\n\t\tthrow invalid('An attempt result is an object');\n\t}\n\tcheckTime('now', result.now);\n\tcheckTime('nextAttemptAt', result.nextAttemptAt);\n\tif (!Number.isInteger(result.attempts) || result.attempts < 0) {\n\t\tthrow invalid('attempts must be an integer of at least 0');\n\t}\n\tif (typeof result.delayNotified !== 'boolean') {\n\t\tthrow invalid('delayNotified must be true or false');\n\t}\n\tconst statuses = ['delivered', 'deferred', 'failed'];\n\tif (\n\t\t!Array.isArray(result.recipients) ||\n\t\t!result.recipients.every(\n\t\t\t(u) => typeof u?.address === 'string' && statuses.includes(u.status),\n\t\t)\n\t) {\n\t\tthrow invalid(\n\t\t\t'recipients must be an array of { address, status: delivered, deferred or failed }',\n\t\t);\n\t}\n\tfor (const update of result.recipients) checkUpdate(update);\n}\n\n/** The offset and limit of a list: integers, the limit 1 to 1000. */\nexport function checkList(options: QueueListOptions = {}): {\n\toffset: number;\n\tlimit: number;\n} {\n\tconst offset = options.offset ?? 0;\n\tconst limit = options.limit ?? 100;\n\tif (!Number.isInteger(offset) || offset < 0) {\n\t\tthrow invalid(`offset must be an integer of at least 0, not ${offset}`);\n\t}\n\tif (!Number.isInteger(limit) || limit < 1 || limit > 1000) {\n\t\tthrow invalid(`limit must be an integer from 1 to 1000, not ${limit}`);\n\t}\n\treturn { offset, limit };\n}\n\n/** Every recipient is `delivered` or `failed`. */\nexport const isDone = (item: Pick<QueueItem, 'recipients'>): boolean =>\n\titem.recipients.every(\n\t\t(r) => r.status === 'delivered' || r.status === 'failed',\n\t);\n\n/**\n * The item once an attempt is recorded: its recipients' outcomes, a final\n * state never changed again, the schedule, and no lease.\n */\nexport function applyAttempt(\n\titem: QueueItem,\n\tresult: AttemptResult,\n): QueueItem {\n\tconst updates = new Map(result.recipients.map((u) => [u.address, u]));\n\tconst recipients = item.recipients.map((r): RecipientState => {\n\t\tconst update = updates.get(r.address);\n\t\tif (!update || r.status === 'delivered' || r.status === 'failed') return r;\n\t\treturn {\n\t\t\taddress: r.address,\n\t\t\tstatus: update.status,\n\t\t\t...(r.notify === undefined ? {} : { notify: r.notify }),\n\t\t\t...(r.orcpt === undefined ? {} : { orcpt: r.orcpt }),\n\t\t\t...(update.reply ? { reply: update.reply } : {}),\n\t\t\tupdatedAt: result.now,\n\t\t\t...(r.mayHaveReachedMx || update.mayHaveReachedMx\n\t\t\t\t? { mayHaveReachedMx: true as const }\n\t\t\t\t: {}),\n\t\t\t...(r.mayHaveReachedFallback || update.mayHaveReachedFallback\n\t\t\t\t? { mayHaveReachedFallback: true as const }\n\t\t\t\t: {}),\n\t\t};\n\t});\n\tconst { lease: _, ...rest } = item;\n\treturn {\n\t\t...rest,\n\t\trecipients,\n\t\tnextAttemptAt: result.nextAttemptAt,\n\t\tattempts: result.attempts,\n\t\tdelayNotified: result.delayNotified,\n\t};\n}\n\n/** A new item as a store first keeps it. */\nexport function newItem(id: string, item: NewQueueItem): QueueItem {\n\tconst dsn = new Map(item.recipients?.map((r) => [r.address, r]));\n\treturn {\n\t\tid,\n\t\tfrom: item.from,\n\t\trecipients: item.to.map((address): RecipientState => {\n\t\t\tconst { notify, orcpt } = dsn.get(address) ?? {};\n\t\t\treturn {\n\t\t\t\taddress,\n\t\t\t\tstatus: 'pending',\n\t\t\t\t...(notify === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { notify: notify === 'NEVER' ? notify : [...notify] }),\n\t\t\t\t...(orcpt === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { orcpt: { type: orcpt.type, address: orcpt.address } }),\n\t\t\t};\n\t\t}),\n\t\tsize: item.message.length,\n\t\tcreatedAt: item.createdAt,\n\t\tnextAttemptAt: item.createdAt,\n\t\tattempts: 0,\n\t\tdelayNotified: false,\n\t\t...(item.ret === undefined ? {} : { ret: item.ret }),\n\t\t...(item.envid === undefined ? {} : { envid: item.envid }),\n\t};\n}\n\n/** Whether a lease, if any, leaves the item free to claim at `now`. */\nexport const claimable = (item: QueueItem, now: number): boolean =>\n\titem.nextAttemptAt <= now &&\n\t(item.lease === undefined || item.lease.expiresAt <= now);\n"
10
+ ],
11
+ "mappings": ";AAGA,IAAM,YAAY,CAAC,SAClB,OAAO,MAAS,QAAQ,OAAQ,QAAQ;AAGlC,SAAS,UAAU,CAAC,MAAuB;AAAA,EACjD,SAAS,IAAI,EAAG,IAAI,KAAK,Q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AQ,QAAQ,UAAU,IAAI,IAAI,OAAO,KAAK,CAAC;AAAA,MAC/C,OAAO;AAAA,QACN;AAAA,QACA,QAAQ;AAAA,WACJ,WAAW,YACZ,CAAC,IACD,EAAE,QAAQ,WAAW,UAAU,SAAS,CAAC,GAAG,MAAM,EAAE;AAAA,WACnD,UAAU,YACX,CAAC,IACD,EAAE,OAAO,EAAE,MAAM,MAAM,MAAM,SAAS,MAAM,QAAQ,EAAE;AAAA,MAC1D;AAAA,KACA;AAAA,IACD,MAAM,KAAK,QAAQ;AAAA,IACnB,WAAW,KAAK;AAAA,IAChB,eAAe,KAAK;AAAA,IACpB,UAAU;AAAA,IACV,eAAe;AAAA,OACX,KAAK,QAAQ,YAAY,CAAC,IAAI,EAAE,KAAK,KAAK,IAAI;AAAA,OAC9C,KAAK,UAAU,YAAY,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM;AAAA,EACzD;AAAA;AAIM,IAAM,YAAY,CAAC,MAAiB,QAC1C,KAAK,iBAAiB,QACrB,KAAK,UAAU,aAAa,KAAK,MAAM,aAAa;",
12
+ "debugId": "17F888FDC5191A2364756E2164756E21",
13
+ "names": []
14
+ }
@@ -5,6 +5,10 @@ import type { AttemptResult, ClaimRequest, NewQueueItem, QueueItem, QueueListOpt
5
5
  export declare function checkTime(name: string, value: unknown): number;
6
6
  /** A lease owner: a non-empty string. */
7
7
  export declare function checkOwner(owner: unknown): string;
8
+ /** The DSN items `complete` takes: an array, each as `add` checks an item. */
9
+ export declare function checkDsns(dsns: readonly NewQueueItem[]): void;
10
+ /** What `complete` checks before any I/O, in this order: the owner, the result, the DSNs. */
11
+ export declare function checkComplete(owner: unknown, result: AttemptResult, dsns: readonly NewQueueItem[]): void;
8
12
  export declare function checkNewItem(item: NewQueueItem): void;
9
13
  /** `maxItems`: a positive integer, or nothing. */
10
14
  export declare function checkMaxItems(max: unknown): number | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../../src/contract/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,EACf,MAAM,EAAE,aAAa,GACnB,SAAS,CA4BX;AAED,4CAA4C;AAC5C,wBAAgB,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,SAAS,CA0BjE;AAED,uEAAuE;AACvE,eAAO,MAAM,SAAS,GAAI,MAAM,SAAS,EAAE,KAAK,MAAM,KAAG,OAEC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"dsn-checks.d.ts","sourceRoot":"","sources":["../../src/contract/dsn-checks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,SAAS,CAAC;AAwD1D,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CA4BvD"}
1
+ {"version":3,"file":"dsn-checks.d.ts","sourceRoot":"","sources":["../../src/contract/dsn-checks.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,SAAS,CAAC;AAoF1D,qDAAqD;AACrD,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CA4BvD"}
@@ -1,4 +1,4 @@
1
- import type { AddOptions, AttemptResult, ClaimRequest, NewQueueItem, QueueItem, QueueListOptions } from './types';
1
+ import type { AddOptions, AttemptResult, ClaimRequest, Completed, NewQueueItem, QueueItem, QueueListOptions } from './types';
2
2
  /**
3
3
  * Where the queue keeps its items, made for several workers, in one
4
4
  * process or many, sharing one store. A worker **claims** a due item: it
@@ -48,13 +48,21 @@ export interface QueueStore {
48
48
  renew(id: string, owner: string, expiresAt: number): Promise<boolean>;
49
49
  /**
50
50
  * Records an attempt: each recipient's outcome, the next attempt and the
51
- * count, and lets go of the lease — in one step, while `owner` holds it.
52
- * Returns the item as it now stands, done (every recipient final, and
53
- * the item dropped) or not; `undefined` when `owner` no longer holds it.
54
- * A recipient's `mayHaveReachedMx` and `mayHaveReachedFallback` marks, once
55
- * recorded, are kept.
51
+ * count, and lets go of the lease — and inserts `dsns`, the DSN items
52
+ * the outcome calls for — in one step, while `owner` holds it: the
53
+ * outcome and its DSNs are both stored, or neither is. Returns the item
54
+ * as it now stands, done (every recipient final, and the item dropped) or
55
+ * not, with the inserted DSN items in the order given; `undefined` when
56
+ * `owner` no longer holds the lease, and then nothing is inserted: the
57
+ * lease is the idempotency token, so a DSN is inserted once per outcome.
58
+ *
59
+ * The DSNs ignore `maxItems`: a full queue loses no bounce. Each goes
60
+ * through the checks of `add`; one that fails them refuses the whole call
61
+ * with `INVALID`, with nothing recorded. The store gives them their ids.
62
+ * A recipient's `mayHaveReachedMx` and `mayHaveReachedFallback` marks,
63
+ * once recorded, are kept.
56
64
  */
57
- complete(id: string, owner: string, result: AttemptResult): Promise<QueueItem | undefined>;
65
+ complete(id: string, owner: string, result: AttemptResult, dsns: readonly NewQueueItem[]): Promise<Completed | undefined>;
58
66
  /**
59
67
  * Moves the next attempt to `at`. With `owner`, only while that owner
60
68
  * holds the lease, which it lets go of: a worker giving an item back.
@@ -1 +1 @@
1
- {"version":3,"file":"queue-store.d.ts","sourceRoot":"","sources":["../../src/contract/queue-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,UAAU;IAC1B;;;;;;OAMG;IACH,GAAG,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAElE,gGAAgG;IAChG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAEhD,0DAA0D;IAC1D,IAAI,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAEvD,sCAAsC;IACtC,KAAK,IAAI,O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;IAEhD,0DAA0D;IAC1D,IAAI,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;IAEvD,sCAAsC;IACtC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAEzB;;;;OAIG;IACH,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAEzD;;;;;OAKG;IACH,KAAK,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAE7D;;;OAGG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtE;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CACP,EAAE,EAAE,MAAM,EACV,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,SAAS,YAAY,EAAE,GAC3B,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IAElC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAErE,0FAA0F;IAC1F,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;CACnD"}
@@ -101,6 +101,11 @@ export interface QueueItem {
101
101
  /** Present while a worker holds the item. */
102
102
  readonly lease?: Lease;
103
103
  }
104
+ /** What `complete` returns: the item as it now stands, and the DSN items it inserted in the same step, in the order given. */
105
+ export interface Completed {
106
+ readonly item: QueueItem;
107
+ readonly dsns: readonly QueueItem[];
108
+ }
104
109
  /** What `add` takes. */
105
110
  export interface NewQueueItem {
106
111
  readonly from: string;
@@ -1 +1 @@
1
- {"version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B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oCAAoC;IACpC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,iDAAiD;IACjD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CACzB;AAED,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;IACrD,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC5B,8FAA8F;IAC9F,QAAQ,CAAC,gBAAgB,CAAC,EAAE,IAAI,CAAC;IACjC,oGAAoG;IACpG,QAAQ,CAAC,sBAAsB,CAAC,EAAE,IAAI,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC7B,kEAAkE;IAClE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,gBAAgB;IAChC,iBAAiB;IACjB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB;IACnB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACxB"}
@@ -1,4 +1,5 @@
1
1
  import type { OriginalRecipient, RecipientNotify } from '../contract/types';
2
+ import { type LocalDsnInput } from './for';
2
3
  /** One recipient the application put in a local mailbox. */
3
4
  export interface DeliveredRecipient {
4
5
  /** `local@domain`, the mailbox it was delivered to. */
@@ -9,23 +10,8 @@ export interface DeliveredRecipient {
9
10
  readonly orcpt?: OriginalRecipient;
10
11
  }
11
12
  /** What `deliveredDsn` takes. */
12
- export interface DeliveredDsnInput {
13
- /** This server's public name: the Reporting-MTA. */
14
- readonly reportingMta: string;
15
- /** The DSN's From: the postmaster's address. */
16
- readonly from: string;
17
- /** The original's reverse-path; `''` (the null sender) gets no DSN. */
18
- readonly to: string;
19
- /** When the original was received. */
20
- readonly arrival: Date;
21
- /** When it was delivered. Default: now. */
22
- readonly date?: Date;
13
+ export interface DeliveredDsnInput extends LocalDsnInput {
23
14
  readonly recipients: readonly DeliveredRecipient[];
24
- readonly envid?: string;
25
- /** The original as received; without it the DSN returns nothing of it. */
26
- readonly original?: Uint8Array;
27
- /** The most bytes of the original returned. Default 64 KiB. */
28
- readonly maxReturn?: number;
29
15
  }
30
16
  /**
31
17
  * The `delivered` DSN (RFC 3464 `Action: delivered`, RFC 3461 §5.2.3) for a
@@ -1 +1 @@
1
- {"version":3,"file":"delivered.d.ts","sourceRoot":"","sources":["../../src/dsn/delivered.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAI5E,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IAClC,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,iCAAiC;AACjC,MAAM,WAAW,iBAAiB;IACjC,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC/B,+DAA+D;IAC/D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,SAAS,CAsB7E"}
1
+ {"version":3,"file":"delivered.d.ts","sourceRoot":"","sources":["../../src/dsn/delivered.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGnD,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IAClC,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,iCAAiC;AACjC,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACvD,QAAQ,CAAC,UAAU,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACnD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,GAAG,SAAS,CAc7E"}
@@ -0,0 +1,29 @@
1
+ import type { Diagnostic, OriginalRecipient, RecipientNotify, RetMode } from '../contract/types';
2
+ import { type LocalDsnInput } from './for';
3
+ /** One recipient the application could not deliver here. */
4
+ export interface FailedRecipient {
5
+ /** `local@domain`, as the sender named it. */
6
+ readonly address: string;
7
+ /** Its `NOTIFY`; a `failed` DSN goes unless `NEVER` or a list without `FAILURE` (RFC 3461 §4.1). */
8
+ readonly notify?: RecipientNotify;
9
+ /** Its `ORCPT`, echoed as `Original-Recipient`. */
10
+ readonly orcpt?: OriginalRecipient;
11
+ /** Why: the enhanced status and the text. */
12
+ readonly reply: Diagnostic;
13
+ }
14
+ /** What `failedDsn` takes. */
15
+ export interface FailedDsnInput extends LocalDsnInput {
16
+ readonly recipients: readonly FailedRecipient[];
17
+ /** `RET` of the original: what the DSN returns of it (RFC 3461 §4.3). Default: the headers. With `FULL`, give the whole message as `original`. */
18
+ readonly ret?: RetMode;
19
+ }
20
+ /**
21
+ * The `failed` DSN (RFC 3464 `Action: failed`) for a message the application
22
+ * could not put in a local mailbox: the bytes to `enqueue` from the null
23
+ * sender to `to`, or `undefined` when there is nothing to send — the
24
+ * original came from the null sender, or no recipient asked for failures
25
+ * (the default, unless `NOTIFY=NEVER` or a list without `FAILURE`). Only the
26
+ * recipients that asked are listed.
27
+ */
28
+ export declare function failedDsn(input: FailedDsnInput): Uint8Array | undefined;
29
+ //# sourceMappingURL=failed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"failed.d.ts","sourceRoot":"","sources":["../../src/dsn/failed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,OAAO,EACP,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAU,KAAK,aAAa,EAAE,MAAM,OAAO,CAAC;AAGnD,4DAA4D;AAC5D,MAAM,WAAW,eAAe;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oGAAoG;IACpG,QAAQ,CAAC,MAAM,CAAC,EAAE,eAAe,CAAC;IAClC,mDAAmD;IACnD,QAAQ,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC;IACnC,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;CAC3B;AAED,8BAA8B;AAC9B,MAAM,WAAW,cAAe,SAAQ,aAAa;IACpD,QAAQ,CAAC,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;IAChD,kJAAkJ;IAClJ,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,UAAU,GAAG,SAAS,CAcvE"}
@@ -0,0 +1,26 @@
1
+ import { type DsnKind, type DsnRecipient } from './build';
2
+ /** What the DSNs of a local delivery share. */
3
+ export interface LocalDsnInput {
4
+ /** This server's public name: the Reporting-MTA. */
5
+ readonly reportingMta: string;
6
+ /** The DSN's From: the postmaster's address. */
7
+ readonly from: string;
8
+ /** The original's reverse-path; `''` (the null sender) gets no DSN. */
9
+ readonly to: string;
10
+ /** When the original was received. */
11
+ readonly arrival: Date;
12
+ /** When the DSN is written. Default: now. */
13
+ readonly date?: Date;
14
+ readonly envid?: string;
15
+ /** The original as received; without it the DSN returns nothing of it. */
16
+ readonly original?: Uint8Array;
17
+ /** The most bytes of the original returned. Default `DEFAULT_MAX_RETURN`. */
18
+ readonly maxReturn?: number;
19
+ }
20
+ /**
21
+ * The DSN of `kind` for `recipients` (already filtered by `NOTIFY`), or
22
+ * `undefined` when there is nobody to tell: the null sender, or no
23
+ * recipient.
24
+ */
25
+ export declare function dsnFor(kind: DsnKind, input: LocalDsnInput, recipients: readonly DsnRecipient[], returnContent: 'headers' | 'full'): Uint8Array | undefined;
26
+ //# sourceMappingURL=for.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"for.d.ts","sourceRoot":"","sources":["../../src/dsn/for.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAGpE,+CAA+C;AAC/C,MAAM,WAAW,aAAa;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,0EAA0E;IAC1E,QAAQ,CAAC,QAAQ,CAAC,EAAE,UAAU,CAAC;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CACrB,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,aAAa,EACpB,UAAU,EAAE,SAAS,YAAY,EAAE,EACnC,aAAa,EAAE,SAAS,GAAG,MAAM,GAC/B,UAAU,GAAG,SAAS,CAexB"}
@@ -14,4 +14,6 @@ export declare function asked(kind: DsnKind, notify: RecipientNotify | undefined
14
14
  * setting.
15
15
  */
16
16
  export declare const returnOf: (ret: RetMode | undefined, fallback: "headers" | "full") => "headers" | "full";
17
+ /** The most bytes of the original a DSN returns, unless `maxReturn` or `limits.maxDsnReturn` says otherwise. */
18
+ export declare const DEFAULT_MAX_RETURN: number;
17
19
  //# sourceMappingURL=policy.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/dsn/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,SAAS,WAUvE;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GACpB,KAAK,OAAO,GAAG,SAAS,EACxB,UAAU,SAAS,GAAG,MAAM,KAC1B,SAAS,GAAG,MACiD,CAAC"}
1
+ {"version":3,"file":"policy.d.ts","sourceRoot":"","sources":["../../src/dsn/policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExC;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,GAAG,SAAS,WAUvE;AAED;;;;GAIG;AACH,eAAO,MAAM,QAAQ,GACpB,KAAK,OAAO,GAAG,SAAS,EACxB,UAAU,SAAS,GAAG,MAAM,KAC1B,SAAS,GAAG,MACiD,CAAC;AAEjE,gHAAgH;AAChH,eAAO,MAAM,kBAAkB,QAAY,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Why the queue or a store refused a call. `INVALID`: an option or an
3
- * argument it cannot take. `MESSAGE_TOO_BIG`, `TOO_MANY_RECIPIENTS` and
3
+ * argument it cannot take, or, given to the `error` event, a store that
4
+ * answers an older contract (`complete` returning the item alone, without
5
+ * the DSNs). `MESSAGE_TOO_BIG`, `TOO_MANY_RECIPIENTS` and
4
6
  * `QUEUE_FULL`: a limit `enqueue` enforces. `CLOSED`: a store used after
5
7
  * `close()`. `LEASE_LOST`: given to the `error` event when another worker
6
8
  * took an item before its outcome was recorded — or, once the lease's
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GACvB,SAAS,GACT,iBAAiB,GACjB,qBAAqB,GACrB,YAAY,GACZ,QAAQ,GACR,YAAY,GACZ,oBAAoB,CAAC;AAExB,mGAAmG;AACnG,qBAAa,UAAW,SAAQ,KAAK;IACpC,SAAkB,IAAI,gBAAgB;IACtC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;gBAElB,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;CAIjD;AAED,+CAA+C;AAC/C,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,eAAuC,CAAC"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,cAAc,GACvB,SAAS,GACT,iBAAiB,GACjB,qBAAqB,GACrB,YAAY,GACZ,QAAQ,GACR,YAAY,GACZ,oBAAoB,CAAC;AAExB,mGAAmG;AACnG,qBAAa,UAAW,SAAQ,KAAK;IACpC,SAAkB,IAAI,gBAAgB;IACtC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;gBAElB,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM;CAIjD;AAED,+CAA+C;AAC/C,eAAO,MAAM,OAAO,GAAI,SAAS,MAAM,eAAuC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export type { QueueStore } from './contract/queue-store';
2
- export type { AddOptions, AttemptResult, ClaimRequest, Diagnostic, FinalStatus, Lease, NewQueueItem, NotifyEvent, OriginalRecipient, QueueItem, QueueListOptions, RecipientDsn, RecipientNotify, RecipientState, RecipientStatus, RecipientUpdate, RetMode, } from './contract/types';
2
+ export type { AddOptions, AttemptResult, ClaimRequest, Completed, Diagnostic, FinalStatus, Lease, NewQueueItem, NotifyEvent, OriginalRecipient, QueueItem, QueueListOptions, RecipientDsn, RecipientNotify, RecipientState, RecipientStatus, RecipientUpdate, RetMode, } from './contract/types';
3
3
  export { type DeliveredDsnInput, type DeliveredRecipient, deliveredDsn, } from './dsn/delivered';
4
+ export { type FailedDsnInput, type FailedRecipient, failedDsn, } from './dsn/failed';
5
+ export { DEFAULT_MAX_RETURN } from './dsn/policy';
4
6
  export { QueueError, type QueueErrorCode } from './errors';
5
7
  export type { MessageSource, QueueEnvelope } from './queue/envelope';
6
8
  export type { DeferredEvent, DsnEvent, QueueErrorEvent, QueueEvents, QueueListener, RecipientEvent, } from './queue/events';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,WAAW,EACX,KAAK,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,OAAO,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,YAAY,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,KAAK,EACL,MAAM,EACN,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,YAAY,EACX,UAAU,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,UAAU,EACV,WAAW,EACX,KAAK,EACL,YAAY,EACZ,WAAW,EACX,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,cAAc,EACd,eAAe,EACf,eAAe,EACf,OAAO,GACP,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,YAAY,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,SAAS,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,UAAU,CAAC;AAC3D,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACrE,YAAY,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,WAAW,EACX,aAAa,EACb,cAAc,GACd,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,KAAK,EACL,MAAM,EACN,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC"}