@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.
- package/LICENSE +21 -0
- package/README.md +243 -0
- package/dist/chunks/index-p4k4rjb7.js +15 -0
- package/dist/chunks/index-p4k4rjb7.js.map +10 -0
- package/dist/chunks/index-xhsw4xcz.js +119 -0
- package/dist/chunks/index-xhsw4xcz.js.map +10 -0
- package/dist/contract/checks.d.ts +27 -0
- package/dist/contract/checks.d.ts.map +1 -0
- package/dist/contract/queue-store.d.ts +60 -0
- package/dist/contract/queue-store.d.ts.map +1 -0
- package/dist/contract/types.d.ts +102 -0
- package/dist/contract/types.d.ts.map +1 -0
- package/dist/dsn/build.d.ts +35 -0
- package/dist/dsn/build.d.ts.map +1 -0
- package/dist/dsn/content.d.ts +18 -0
- package/dist/dsn/content.d.ts.map +1 -0
- package/dist/dsn/fields.d.ts +38 -0
- package/dist/dsn/fields.d.ts.map +1 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1089 -0
- package/dist/index.js.map +30 -0
- package/dist/memory/index.d.ts +2 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +121 -0
- package/dist/memory/index.js.map +10 -0
- package/dist/memory/store.d.ts +21 -0
- package/dist/memory/store.d.ts.map +1 -0
- package/dist/queue/deliver.d.ts +20 -0
- package/dist/queue/deliver.d.ts.map +1 -0
- package/dist/queue/envelope.d.ts +26 -0
- package/dist/queue/envelope.d.ts.map +1 -0
- package/dist/queue/events.d.ts +48 -0
- package/dist/queue/events.d.ts.map +1 -0
- package/dist/queue/limiter.d.ts +14 -0
- package/dist/queue/limiter.d.ts.map +1 -0
- package/dist/queue/notify.d.ts +19 -0
- package/dist/queue/notify.d.ts.map +1 -0
- package/dist/queue/options.d.ts +111 -0
- package/dist/queue/options.d.ts.map +1 -0
- package/dist/queue/outcome.d.ts +26 -0
- package/dist/queue/outcome.d.ts.map +1 -0
- package/dist/queue/queue.d.ts +43 -0
- package/dist/queue/queue.d.ts.map +1 -0
- package/dist/queue/retry.d.ts +16 -0
- package/dist/queue/retry.d.ts.map +1 -0
- package/dist/queue/route.d.ts +10 -0
- package/dist/queue/route.d.ts.map +1 -0
- package/dist/queue/settings/dsn.d.ts +8 -0
- package/dist/queue/settings/dsn.d.ts.map +1 -0
- package/dist/queue/settings/index.d.ts +25 -0
- package/dist/queue/settings/index.d.ts.map +1 -0
- package/dist/queue/settings/limits.d.ts +18 -0
- package/dist/queue/settings/limits.d.ts.map +1 -0
- package/dist/queue/settings/numbers.d.ts +7 -0
- package/dist/queue/settings/numbers.d.ts.map +1 -0
- package/dist/queue/settings/routes.d.ts +3 -0
- package/dist/queue/settings/routes.d.ts.map +1 -0
- package/dist/queue/settings/sessions.d.ts +5 -0
- package/dist/queue/settings/sessions.d.ts.map +1 -0
- package/dist/queue/settle.d.ts +21 -0
- package/dist/queue/settle.d.ts.map +1 -0
- package/dist/queue/worker.d.ts +27 -0
- package/dist/queue/worker.d.ts.map +1 -0
- package/dist/sqlite/index.d.ts +2 -0
- package/dist/sqlite/index.d.ts.map +1 -0
- package/dist/sqlite/index.js +288 -0
- package/dist/sqlite/index.js.map +13 -0
- package/dist/sqlite/open.d.ts +8 -0
- package/dist/sqlite/open.d.ts.map +1 -0
- package/dist/sqlite/options.d.ts +16 -0
- package/dist/sqlite/options.d.ts.map +1 -0
- package/dist/sqlite/rows.d.ts +28 -0
- package/dist/sqlite/rows.d.ts.map +1 -0
- package/dist/sqlite/schema.d.ts +14 -0
- package/dist/sqlite/schema.d.ts.map +1 -0
- package/dist/sqlite/store.d.ts +30 -0
- package/dist/sqlite/store.d.ts.map +1 -0
- package/dist/text.d.ts +14 -0
- package/dist/text.d.ts.map +1 -0
- package/docs/README.md +10 -0
- package/docs/guide.md +461 -0
- package/docs/roadmap.md +67 -0
- package/docs/troubleshooting.md +394 -0
- 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"}
|
package/dist/errors.d.ts
ADDED
|
@@ -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"}
|
package/dist/index.d.ts
ADDED
|
@@ -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"}
|