@bumail/queue 0.1.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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +243 -0
  3. package/dist/chunks/index-p4k4rjb7.js +15 -0
  4. package/dist/chunks/index-p4k4rjb7.js.map +10 -0
  5. package/dist/chunks/index-xhsw4xcz.js +119 -0
  6. package/dist/chunks/index-xhsw4xcz.js.map +10 -0
  7. package/dist/contract/checks.d.ts +27 -0
  8. package/dist/contract/checks.d.ts.map +1 -0
  9. package/dist/contract/queue-store.d.ts +60 -0
  10. package/dist/contract/queue-store.d.ts.map +1 -0
  11. package/dist/contract/types.d.ts +102 -0
  12. package/dist/contract/types.d.ts.map +1 -0
  13. package/dist/dsn/build.d.ts +35 -0
  14. package/dist/dsn/build.d.ts.map +1 -0
  15. package/dist/dsn/content.d.ts +18 -0
  16. package/dist/dsn/content.d.ts.map +1 -0
  17. package/dist/dsn/fields.d.ts +38 -0
  18. package/dist/dsn/fields.d.ts.map +1 -0
  19. package/dist/errors.d.ts +17 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/index.d.ts +8 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +1089 -0
  24. package/dist/index.js.map +30 -0
  25. package/dist/memory/index.d.ts +2 -0
  26. package/dist/memory/index.d.ts.map +1 -0
  27. package/dist/memory/index.js +121 -0
  28. package/dist/memory/index.js.map +10 -0
  29. package/dist/memory/store.d.ts +21 -0
  30. package/dist/memory/store.d.ts.map +1 -0
  31. package/dist/queue/deliver.d.ts +20 -0
  32. package/dist/queue/deliver.d.ts.map +1 -0
  33. package/dist/queue/envelope.d.ts +26 -0
  34. package/dist/queue/envelope.d.ts.map +1 -0
  35. package/dist/queue/events.d.ts +48 -0
  36. package/dist/queue/events.d.ts.map +1 -0
  37. package/dist/queue/limiter.d.ts +14 -0
  38. package/dist/queue/limiter.d.ts.map +1 -0
  39. package/dist/queue/notify.d.ts +19 -0
  40. package/dist/queue/notify.d.ts.map +1 -0
  41. package/dist/queue/options.d.ts +111 -0
  42. package/dist/queue/options.d.ts.map +1 -0
  43. package/dist/queue/outcome.d.ts +26 -0
  44. package/dist/queue/outcome.d.ts.map +1 -0
  45. package/dist/queue/queue.d.ts +43 -0
  46. package/dist/queue/queue.d.ts.map +1 -0
  47. package/dist/queue/retry.d.ts +16 -0
  48. package/dist/queue/retry.d.ts.map +1 -0
  49. package/dist/queue/route.d.ts +10 -0
  50. package/dist/queue/route.d.ts.map +1 -0
  51. package/dist/queue/settings/dsn.d.ts +8 -0
  52. package/dist/queue/settings/dsn.d.ts.map +1 -0
  53. package/dist/queue/settings/index.d.ts +25 -0
  54. package/dist/queue/settings/index.d.ts.map +1 -0
  55. package/dist/queue/settings/limits.d.ts +18 -0
  56. package/dist/queue/settings/limits.d.ts.map +1 -0
  57. package/dist/queue/settings/numbers.d.ts +7 -0
  58. package/dist/queue/settings/numbers.d.ts.map +1 -0
  59. package/dist/queue/settings/routes.d.ts +3 -0
  60. package/dist/queue/settings/routes.d.ts.map +1 -0
  61. package/dist/queue/settings/sessions.d.ts +5 -0
  62. package/dist/queue/settings/sessions.d.ts.map +1 -0
  63. package/dist/queue/settle.d.ts +21 -0
  64. package/dist/queue/settle.d.ts.map +1 -0
  65. package/dist/queue/worker.d.ts +27 -0
  66. package/dist/queue/worker.d.ts.map +1 -0
  67. package/dist/sqlite/index.d.ts +2 -0
  68. package/dist/sqlite/index.d.ts.map +1 -0
  69. package/dist/sqlite/index.js +288 -0
  70. package/dist/sqlite/index.js.map +13 -0
  71. package/dist/sqlite/open.d.ts +8 -0
  72. package/dist/sqlite/open.d.ts.map +1 -0
  73. package/dist/sqlite/options.d.ts +16 -0
  74. package/dist/sqlite/options.d.ts.map +1 -0
  75. package/dist/sqlite/rows.d.ts +28 -0
  76. package/dist/sqlite/rows.d.ts.map +1 -0
  77. package/dist/sqlite/schema.d.ts +14 -0
  78. package/dist/sqlite/schema.d.ts.map +1 -0
  79. package/dist/sqlite/store.d.ts +30 -0
  80. package/dist/sqlite/store.d.ts.map +1 -0
  81. package/dist/text.d.ts +14 -0
  82. package/dist/text.d.ts.map +1 -0
  83. package/docs/README.md +10 -0
  84. package/docs/guide.md +461 -0
  85. package/docs/roadmap.md +67 -0
  86. package/docs/troubleshooting.md +394 -0
  87. package/package.json +71 -0
@@ -0,0 +1,35 @@
1
+ import { type DsnKind, type DsnRecipient } from './fields';
2
+ export type { DsnKind, DsnRecipient } from './fields';
3
+ /** What a DSN says, about which message, to whom. */
4
+ export interface DsnInput {
5
+ readonly kind: DsnKind;
6
+ /** This server's public name: the Reporting-MTA, and the Message-ID's domain. */
7
+ readonly reportingMta: string;
8
+ /** The DSN's From: the postmaster's address. */
9
+ readonly from: string;
10
+ /** The original's sender, to whom the DSN goes. */
11
+ readonly to: string;
12
+ /** When the original was enqueued. */
13
+ readonly arrival: Date;
14
+ /** When the DSN is written. */
15
+ readonly date: Date;
16
+ readonly recipients: readonly DsnRecipient[];
17
+ /** With `delayed`: when the queue gives up. */
18
+ readonly willRetryUntil?: Date;
19
+ /** The original message, as enqueued. */
20
+ readonly original: Uint8Array;
21
+ readonly returnContent: 'headers' | 'full';
22
+ /** The most bytes of the original returned. */
23
+ readonly maxReturn: number;
24
+ }
25
+ /**
26
+ * A delivery status notification (RFC 3464): a `multipart/report`
27
+ * (RFC 6522) of `report-type=delivery-status` holding the text a person
28
+ * reads, the `message/delivery-status` fields a program reads, and the
29
+ * original's header fields (or the whole original, when asked and small
30
+ * enough), bounded by `maxReturn`. Nothing from the remote server or the
31
+ * envelope reaches a header field raw: control characters, CR and LF are
32
+ * taken out first.
33
+ */
34
+ export declare function buildDsn(input: DsnInput): Uint8Array;
35
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/dsn/build.ts"],"names":[],"mappings":"AAQA,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,YAAY,EAGjB,MAAM,UAAU,CAAC;AAElB,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtD,qDAAqD;AACrD,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,iFAAiF;IACjF,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,CAAC;IAC7C,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC;IAC/B,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,SAAS,GAAG,MAAM,CAAC;IAC3C,+CAA+C;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC3B;AAkFD;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,UAAU,CAwCpD"}
@@ -0,0 +1,18 @@
1
+ /** The part of a DSN that returns the original message (RFC 3464 §2, RFC 6522 §3). */
2
+ /** RFC 5322 §2.1.1: a line is at most 998 characters, its CRLF aside. */
3
+ export declare const MAX_LINE = 998;
4
+ export interface Returned {
5
+ /** `text/rfc822-headers` or `message/rfc822`. */
6
+ readonly type: string;
7
+ /** Lines ending in CRLF, the last one included. */
8
+ readonly body: Uint8Array;
9
+ /** It holds a byte past ASCII: the part says `8bit`. */
10
+ readonly eightBit: boolean;
11
+ }
12
+ /**
13
+ * The original as a DSN returns it: the whole message when asked and it
14
+ * fits `max` bytes, else its header fields, cut after the last whole line
15
+ * that fits. Never more than `max` bytes.
16
+ */
17
+ export declare function returned(original: Uint8Array, mode: 'headers' | 'full', max: number): Returned;
18
+ //# sourceMappingURL=content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/dsn/content.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAKtF,yEAAyE;AACzE,eAAO,MAAM,QAAQ,MAAM,CAAC;AA0D5B,MAAM,WAAW,QAAQ;IACxB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,mDAAmD;IACnD,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACvB,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,SAAS,GAAG,MAAM,EACxB,GAAG,EAAE,MAAM,GACT,QAAQ,CAYV"}
@@ -0,0 +1,38 @@
1
+ import type { Diagnostic } from '../contract/types';
2
+ /** One recipient a DSN reports on. */
3
+ export interface DsnRecipient {
4
+ readonly address: string;
5
+ readonly reply?: Diagnostic;
6
+ /** When it was last tried. */
7
+ readonly lastAttempt: Date;
8
+ }
9
+ export type DsnKind = 'delayed' | 'failed';
10
+ /** What a delivery-status part reports: who reports, on what, and each recipient. */
11
+ export interface StatusReport {
12
+ readonly kind: DsnKind;
13
+ /** This server's name. */
14
+ readonly reportingMta: string;
15
+ /** When the message was enqueued. */
16
+ readonly arrival: Date;
17
+ readonly recipients: readonly DsnRecipient[];
18
+ /** With `delayed`: when the queue gives up. */
19
+ readonly willRetryUntil?: Date;
20
+ }
21
+ /**
22
+ * An address as a delivery-status field types it: `rfc822; addr` when it
23
+ * is ASCII; otherwise `utf-8;` with each non-ASCII character as
24
+ * `\x{HEX}` (RFC 6533 §3, utf-8-addr-xtext), so the part stays 7-bit,
25
+ * cut at 900 characters so it always fits a header line.
26
+ */
27
+ export declare function typedAddress(address: string): string;
28
+ /**
29
+ * The status (RFC 3463) of a recipient: the reply's enhanced code; else
30
+ * its class from the reply code; else, with nothing at all, the kind's.
31
+ */
32
+ export declare function statusOf(kind: DsnKind, reply?: Diagnostic): string;
33
+ /**
34
+ * The body of a `message/delivery-status` part (RFC 3464 §2.1): the
35
+ * per-message fields, then each recipient's, a blank line between, CRLF.
36
+ */
37
+ export declare function deliveryStatus(report: StatusReport): string;
38
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/dsn/fields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGpD,sCAAsC;AACtC,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAC5B,8BAA8B;IAC9B,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC;CAC3B;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE3C,qFAAqF;AACrF,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,0BAA0B;IAC1B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,SAAS,YAAY,EAAE,CAAC;IAC7C,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,CAAC,EAAE,IAAI,CAAC;CAC/B;AAQD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAapD;AAMD;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,UAAU,GAAG,MAAM,CAMlE;AA8BD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAS3D"}
@@ -0,0 +1,17 @@
1
+ /**
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
4
+ * `QUEUE_FULL`: a limit `enqueue` enforces. `CLOSED`: a store used after
5
+ * `close()`. `LEASE_LOST`: given to the `error` event when another worker
6
+ * took an item before its outcome was recorded.
7
+ */
8
+ export type QueueErrorCode = 'INVALID' | 'MESSAGE_TOO_BIG' | 'TOO_MANY_RECIPIENTS' | 'QUEUE_FULL' | 'CLOSED' | 'LEASE_LOST';
9
+ /** Thrown by the queue and by every store, whichever answers the contract, with the same codes. */
10
+ export declare class QueueError extends Error {
11
+ readonly name = "QueueError";
12
+ readonly code: QueueErrorCode;
13
+ constructor(code: QueueErrorCode, message: string);
14
+ }
15
+ /** `INVALID`, for an option or an argument. */
16
+ export declare const invalid: (message: string) => QueueError;
17
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GACvB,SAAS,GACT,iBAAiB,GACjB,qBAAqB,GACrB,YAAY,GACZ,QAAQ,GACR,YAAY,CAAC;AAEhB,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"}
@@ -0,0 +1,8 @@
1
+ export type { QueueStore } from './contract/queue-store';
2
+ export type { AddOptions, AttemptResult, ClaimRequest, Diagnostic, FinalStatus, Lease, NewQueueItem, QueueItem, QueueListOptions, RecipientState, RecipientStatus, RecipientUpdate, } from './contract/types';
3
+ export { QueueError, type QueueErrorCode } from './errors';
4
+ export type { MessageSource, QueueEnvelope } from './queue/envelope';
5
+ export type { DeferredEvent, DsnEvent, QueueErrorEvent, QueueEvents, QueueListener, RecipientEvent, } from './queue/events';
6
+ export type { Clock, DsnOptions, QueueLimits, QueueOptions, RetrySchedule, Route, Sender, Smarthost, } from './queue/options';
7
+ export { createQueue, type Queue } from './queue/queue';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,GACf,MAAM,kBAAkB,CAAC;AAC1B,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"}