@yaks/mail 0.0.0-stage → 0.2.36

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 (131) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +676 -2
  3. package/_dist/addr.d.ts +40 -0
  4. package/_dist/addr.d.ts.map +1 -0
  5. package/_dist/answers.d.ts +18 -0
  6. package/_dist/answers.d.ts.map +1 -0
  7. package/_dist/arrive.d.ts +64 -0
  8. package/_dist/arrive.d.ts.map +1 -0
  9. package/_dist/capture.d.ts +22 -0
  10. package/_dist/capture.d.ts.map +1 -0
  11. package/_dist/comp.d.ts +27 -0
  12. package/_dist/comp.d.ts.map +1 -0
  13. package/_dist/effects.d.ts +9 -0
  14. package/_dist/effects.d.ts.map +1 -0
  15. package/_dist/gmail.d.ts +16 -0
  16. package/_dist/gmail.d.ts.map +1 -0
  17. package/_dist/graph.d.ts +9 -0
  18. package/_dist/graph.d.ts.map +1 -0
  19. package/_dist/inbound.d.ts +105 -0
  20. package/_dist/inbound.d.ts.map +1 -0
  21. package/_dist/invite.d.ts +69 -0
  22. package/_dist/invite.d.ts.map +1 -0
  23. package/_dist/md.d.ts +34 -0
  24. package/_dist/md.d.ts.map +1 -0
  25. package/_dist/mod.d.ts +109 -0
  26. package/_dist/mod.d.ts.map +1 -0
  27. package/_dist/options.d.ts +38 -0
  28. package/_dist/options.d.ts.map +1 -0
  29. package/_dist/plugin.d.ts +38 -0
  30. package/_dist/plugin.d.ts.map +1 -0
  31. package/_dist/pull.d.ts +99 -0
  32. package/_dist/pull.d.ts.map +1 -0
  33. package/_dist/receipts.d.ts +8 -0
  34. package/_dist/receipts.d.ts.map +1 -0
  35. package/_dist/recipient.d.ts +24 -0
  36. package/_dist/recipient.d.ts.map +1 -0
  37. package/_dist/routes.d.ts +19 -0
  38. package/_dist/routes.d.ts.map +1 -0
  39. package/_dist/send.d.ts +80 -0
  40. package/_dist/send.d.ts.map +1 -0
  41. package/_dist/service.d.ts +14 -0
  42. package/_dist/service.d.ts.map +1 -0
  43. package/_dist/stash.d.ts +23 -0
  44. package/_dist/stash.d.ts.map +1 -0
  45. package/_dist/tools.d.ts +27 -0
  46. package/_dist/tools.d.ts.map +1 -0
  47. package/_dist/transport.d.ts +6 -0
  48. package/_dist/transport.d.ts.map +1 -0
  49. package/_dist/vocab.d.ts +7 -0
  50. package/_dist/vocab.d.ts.map +1 -0
  51. package/addr.js +92 -0
  52. package/addr.js.map +1 -0
  53. package/addr.ts +106 -0
  54. package/answers.js +71 -0
  55. package/answers.js.map +1 -0
  56. package/answers.ts +95 -0
  57. package/arrive.js +122 -0
  58. package/arrive.js.map +1 -0
  59. package/arrive.ts +198 -0
  60. package/capture.js +21 -0
  61. package/capture.js.map +1 -0
  62. package/capture.ts +43 -0
  63. package/comp.js +76 -0
  64. package/comp.js.map +1 -0
  65. package/comp.ts +91 -0
  66. package/deno.json +1 -0
  67. package/effects.js +90 -0
  68. package/effects.js.map +1 -0
  69. package/effects.ts +90 -0
  70. package/gmail.js +262 -0
  71. package/gmail.js.map +1 -0
  72. package/gmail.ts +314 -0
  73. package/graph.js +26 -0
  74. package/graph.js.map +1 -0
  75. package/graph.ts +30 -0
  76. package/inbound.js +206 -0
  77. package/inbound.js.map +1 -0
  78. package/inbound.ts +238 -0
  79. package/invite.js +102 -0
  80. package/invite.js.map +1 -0
  81. package/invite.ts +143 -0
  82. package/md.js +188 -0
  83. package/md.js.map +1 -0
  84. package/md.ts +245 -0
  85. package/mod.js +109 -0
  86. package/mod.js.map +1 -0
  87. package/mod.ts +111 -0
  88. package/options.js +24 -0
  89. package/options.js.map +1 -0
  90. package/options.ts +83 -0
  91. package/package.json +66 -4
  92. package/plugin.js +97 -0
  93. package/plugin.js.map +1 -0
  94. package/plugin.ts +88 -0
  95. package/pull.js +344 -0
  96. package/pull.js.map +1 -0
  97. package/pull.ts +443 -0
  98. package/readings.js +24 -0
  99. package/readings.js.map +1 -0
  100. package/readings.ts +34 -0
  101. package/receipts.js +45 -0
  102. package/receipts.js.map +1 -0
  103. package/receipts.ts +45 -0
  104. package/recipient.js +92 -0
  105. package/recipient.js.map +1 -0
  106. package/recipient.ts +89 -0
  107. package/routes.js +103 -0
  108. package/routes.js.map +1 -0
  109. package/routes.ts +125 -0
  110. package/send.js +284 -0
  111. package/send.js.map +1 -0
  112. package/send.ts +325 -0
  113. package/service.js +64 -0
  114. package/service.js.map +1 -0
  115. package/service.ts +75 -0
  116. package/stash.js +29 -0
  117. package/stash.js.map +1 -0
  118. package/stash.ts +49 -0
  119. package/tools.js +343 -0
  120. package/tools.js.map +1 -0
  121. package/tools.ts +416 -0
  122. package/transport.js +23 -0
  123. package/transport.js.map +1 -0
  124. package/transport.ts +24 -0
  125. package/vocab.js +14 -0
  126. package/vocab.js.map +1 -0
  127. package/vocab.json +415 -0
  128. package/vocab.ts +16 -0
  129. package/work.js +121 -0
  130. package/work.js.map +1 -0
  131. package/work.ts +134 -0
@@ -0,0 +1,40 @@
1
+ /** An address split at its one `@`, or `null` when it has none or several. */ export declare let parts: (address: string) => [string, string] | null;
2
+ /**
3
+ * Whether a typed address is one a letter can be sent to, as a provider such
4
+ * as Resend checks it before taking a letter. Ask before sending, so a typo
5
+ * is the writer's to fix rather than a send that fails.
6
+ *
7
+ * ```ts
8
+ * import { sendable } from '@yaks/mail'
9
+ * sendable('ana@books.example') // true
10
+ * sendable('ana@books') // false
11
+ * sendable('ana@@books.example') // false
12
+ * ```
13
+ */ export declare let sendable: (address: string) => boolean;
14
+ /** An address at a domain: `address('ana', 'books.example')`. */ export declare let address: (local: string, domain: string) => string;
15
+ /**
16
+ * The local part of an address at `domain`, or `null` for an address anywhere
17
+ * else. The domain is compared case-insensitively; the local part comes back
18
+ * as it was written.
19
+ *
20
+ * ```ts
21
+ * import { local } from '@yaks/mail'
22
+ * local('books.example')('Ana@Books.Example') // 'Ana'
23
+ * local('books.example')('ana@elsewhere.com') // null
24
+ * ```
25
+ */ export declare let local: (domain: string) => (address: string) => string | null;
26
+ /** Whether an address is at `domain`. */ export declare let at: (domain: string) => (address: string) => boolean;
27
+ /**
28
+ * The canonical, deliverable form of an address at `domain`: the local part
29
+ * lowercased with its underscores dropped, at the domain as configured. An
30
+ * address at any other domain is returned as it was given — canonicalizing
31
+ * somebody else's domain is a guess, and a guess here misdelivers mail.
32
+ *
33
+ * ```ts
34
+ * import { canon } from '@yaks/mail'
35
+ * let mine = canon('books.example')
36
+ * mine('Book_Club@Books.Example') // 'bookclub@books.example'
37
+ * mine('ana@elsewhere.com') // 'ana@elsewhere.com'
38
+ * ```
39
+ */ export declare let canon: (domain: string) => (raw: string) => string;
40
+ //# sourceMappingURL=addr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addr.d.ts","sources":["../addr.ts"],"names":[],"mappings":"AAqBA,4EAA4E,GAC5E,OAAO,YAAI,QAAS,SAAS,MAAM,MAAI,MAAM,EAAE,MAAM,IAAI,IAAI,CAG5D;AASD;;;;;;;;;;;CAWC,GACD,OAAO,YAAI,WAAY,SAAS,MAAM,KAAG,OAAO,CAM/C;AAED,+DAA+D,GAC/D,OAAO,YAAI,UAAW,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,CACtC;AAEtB;;;;;;;;;;CAUC,GACD,OAAO,YAAI,QAAS,QAAQ,MAAM,MAAI,SAAS,MAAM,KAAK,MAAM,GAAG,IAAI,CAMtE;AAED,uCAAuC,GACvC,OAAO,YAAI,KAAM,QAAQ,MAAM,MAAI,SAAS,MAAM,KAAK,OAAO,CAG7D;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,QAAS,QAAQ,MAAM,MAAI,KAAK,MAAM,KAAK,MAAM,CAS3D"}
@@ -0,0 +1,18 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import { type Built } from "@yaks/query";
3
+ /** Where an answer to a letter that arrived goes, lowercased. */ export declare let sender: (letter: Bundle) => string;
4
+ /** Whether an address is a machine's: a no-reply, a bounce or a notifier,
5
+ * which nobody reads an answer at. */ export declare let automated: (address: string) => boolean;
6
+ /** When a letter that left was delivered; NaN while it has not. */ export declare let left: (sent: Bundle) => number;
7
+ /** When a letter arrived. */ export declare let arrived: (letter: Bundle) => number;
8
+ /** The letters a letter we sent answers: the one it replies to and the one it
9
+ * is about. The one definition of an answer, for whatever reads them. */ export declare let answering: (sent: Bundle) => string[];
10
+ /** The query for letters we sent that may answer one, delivered since
11
+ * `from`: every letter {@link answering} reads something from. */ export declare let answersSince: (from: string) => Built;
12
+ export type Answered = {
13
+ letter: Bundle;
14
+ /** the first delivered reply to it, if one has left */ answer?: Bundle;
15
+ /** from its arrival to that answer's delivery */ ms?: number;
16
+ };
17
+ /** Each letter with the first delivered reply to it. */ export declare let answers: (letters: Bundle[], sent: Bundle[]) => Answered[];
18
+ //# sourceMappingURL=answers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answers.d.ts","sources":["../answers.ts"],"names":[],"mappings":"AAOA,cAAc,MAAM,2BAAsC;AAC1D,SAAS,KAAK,KAAK,2BAAsC;AAWzD,+DAA+D,GAC/D,OAAO,YAAI,SAAU,QAAQ,WAAS,MAAM,CACmC;AAO/E;oCACoC,GACpC,OAAO,YAAI,YAAa,SAAS,MAAM,KAAG,OAAO,CAGY;AAE7D,iEAAiE,GACjE,OAAO,YAAI,OAAQ,MAAM,WAAS,MAAM,CAAoC;AAE5E,2BAA2B,GAC3B,OAAO,YAAI,UAAW,QAAQ,WAAS,MAAM,CAAiC;AAM9E;uEACuE,GACvE,OAAO,YAAI,YAAa,MAAM,WAAS,MAAM,GAI5C;AAED;gEACgE,GAChE,OAAO,YAAI,eAAgB,MAAM,MAAM,KAAG,MACqC;AAE/E,YAAY;EACV,QAAQ;EACR,qDAAqD,GACrD,SAAS;EACT,+CAA+C,GAC/C,KAAK,MAAM;;AAgBb,sDAAsD,GACtD,OAAO,YAAI,UAAW,SAAS,UAAU,MAAM,aAAW,WAczD"}
@@ -0,0 +1,64 @@
1
+ import type { Bundle, Eid, Graph } from "@yaks/graph";
2
+ import { type Arrival, type Received } from "./inbound.js";
3
+ /** A graph as this file uses one: a read, and the call that resolves an id a
4
+ * caller typed. Nothing here writes — the bundles are returned to the
5
+ * caller. */ export type Book = Pick<Graph, 'read' | 'address'>;
6
+ /**
7
+ * Which entity has this address, or nobody.
8
+ *
9
+ * Case and punctuation are the address book's own: the canonicalizer in the
10
+ * `normalize` phase (./plugin.ts) means a stored address is already in one
11
+ * form, so a lookup canonicalizes the same way before it queries.
12
+ */ export declare let wearer: (graph: Book, address: string, domain?: string) => Promise<Eid | null>;
13
+ /** The entity an id-shaped address at `domain` names, or none: `S-31@yours`
14
+ * is S-31. Only your own domain — everywhere else, a local part is a mailbox
15
+ * name and reading it as an id would misdeliver. */ export declare let named: (graph: Book, address: string, domain: string) => Promise<Eid | null>;
16
+ /** The letter other mail systems know by this Message-ID, or none — what
17
+ * threading resolves against, and what makes an arrival idempotent. */ export declare let known: (graph: Book, id: string) => Promise<Eid | null>;
18
+ /** Whom a letter to this address is for: whoever has that address, else the
19
+ * entity its id names, else nobody. */ export declare let routed: (graph: Book, address: string, domain?: string) => Promise<Eid | null>;
20
+ /** One arrival, as another package reads it: the message whole (its headers
21
+ * are only here), the letter as mail records it, and the lookups mail
22
+ * answered. */ export type Read = {
23
+ /** the graph to query */ graph: Book;
24
+ /** the message as it arrived */ message: Received;
25
+ /** what the caller knew beside it: the parsed text, a target it named */ arrival: Arrival;
26
+ /** the letter as mail records it, its `$actor` included */ letter: Bundle;
27
+ /** the letter it answers, where this graph has it */ reply: Eid | null;
28
+ /** who wrote it, where the address book knows them */ by: Eid | null;
29
+ /** an address in the form this graph stores addresses in */ canonical: (address: string) => string;
30
+ };
31
+ /** What a package makes of an arrival: the bundles to record in place of the
32
+ * letter alone (the letter, perhaps with more on it, and whatever else it
33
+ * means), or nothing to leave it a letter. A package offers one from its
34
+ * `./mail` facet (./readings.ts). */ export type Reading = (read: Read) => Bundle[] | undefined | Promise<Bundle[] | undefined>;
35
+ /** What the receiving half needs, besides the message. */ export type Arrivals = {
36
+ /** the graph to query */ graph: Book;
37
+ /** your own mail domain: the one whose addresses this graph can resolve.
38
+ * Without it, every address belongs to somebody else and a letter is
39
+ * recorded against whatever the address book already knows. */ domain?: string;
40
+ /** where a letter addressed to nobody here lands — the triage entity */ triage?: Eid;
41
+ /** what other packages make of an arrival, asked in order; the first that
42
+ * answers decides what is recorded */ readings?: Reading[];
43
+ };
44
+ /**
45
+ * A received message → the bundles that record it, with the two lookups
46
+ * answered: whom it is for and which letter it answers. `receive` is
47
+ * `arrived({ graph, domain, triage })`, and `graph.apply(await receive(message,
48
+ * { text }))` records the letter; the README shows it whole.
49
+ *
50
+ * An empty array of bundles means the letter is already here: the Message-ID
51
+ * is the one identity a letter carries between mail systems, so recording it
52
+ * twice would be the error, not the second delivery.
53
+ *
54
+ * The letter is written by its author, found as a recipient is (`routed`),
55
+ * where the edge vouched for its From address (`Arrival.vouched`), and by
56
+ * nobody where it did not or nobody here has that address: its `$actor` is then
57
+ * empty, so the graph does not sign it as its owner's. An unattributed write
58
+ * is the truth about a stranger's letter, and far better than the mailbox's
59
+ * owner appearing to have written it.
60
+ *
61
+ * What else a letter means is not mail's to say: each of `readings` is asked
62
+ * in turn, and the first that answers says what is recorded instead.
63
+ */ export declare let arrived: ({}: Arrivals) => (m: Received, arrival?: Arrival) => Promise<Bundle[]>;
64
+ //# sourceMappingURL=arrive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arrive.d.ts","sources":["../arrive.ts"],"names":[],"mappings":"AA0BA,cAAc,MAAM,EAAE,GAAG,EAAE,KAAK,2BAAgC;AAKhE,SACE,KAAK,OAAO,EAIZ,KAAK,QAAQ,uBAEM;AAErB;;WAEW,GACX,YAAY,OAAO,KAAK,OAAO,SAAS;AAOxC;;;;;;CAMC,GACD,OAAO,YAAI,SACT,OAAO,MACP,SAAS,MAAM,EACf,SAAS,MAAM,KACd,QAAQ,MAAM,IAAI,EAC0D;AAE/E;;kDAEkD,GAClD,OAAO,YAAI,QACT,OAAO,MACP,SAAS,MAAM,EACf,QAAQ,MAAM,KACb,QAAQ,MAAM,IAAI,EAYpB;AAID;qEACqE,GACrE,OAAO,YAAI,QAAS,OAAO,MAAM,IAAI,MAAM,KAAG,QAAQ,MAAM,IAAI,EACR;AAExD;qCACqC,GACrC,OAAO,YAAI,SACT,OAAO,MACP,SAAS,MAAM,EACf,SAAS,MAAM,KACd,QAAQ,MAAM,IAAI,EAEoC;AAEzD;;aAEa,GACb,YAAY;EACV,uBAAuB,GACvB,OAAO;EACP,8BAA8B,GAC9B,SAAS;EACT,uEAAuE,GACvE,SAAS;EACT,yDAAyD,GACzD,QAAQ;EACR,mDAAmD,GACnD,OAAO,MAAM,IAAI;EACjB,oDAAoD,GACpD,IAAI,MAAM,IAAI;EACd,0DAA0D,GAC1D,YAAY,SAAS,MAAM,KAAK,MAAM;;AAGxC;;;mCAGmC,GACnC,YAAY,WACV,MAAM,SACH,WAAW,SAAS,GAAG,QAAQ,WAAW,SAAS;AAExD,wDAAwD,GACxD,YAAY;EACV,uBAAuB,GACvB,OAAO;EACP;;+DAE6D,GAC7D,SAAS,MAAM;EACf,sEAAsE,GACtE,SAAS;EACT;sCACoC,GACpC,WAAW;;AAGb;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,UACT,IAA0C,QAAQ,MAChD,GAAG,UAAU,UAAU,YAAY,QAAQ,UA8B9C"}
@@ -0,0 +1,22 @@
1
+ import type { Incoming, MailSource } from "@yaks/host/senders";
2
+ type Part = {
3
+ name: string;
4
+ type: string;
5
+ base64: string;
6
+ };
7
+ /** A complete delivery: the neutral envelope and original provider bytes. */ export type Capture<File = Part> = {
8
+ from: string;
9
+ to: string;
10
+ name?: string;
11
+ headers: [string, string][];
12
+ text: string;
13
+ html?: string;
14
+ verified?: boolean;
15
+ vouched?: boolean;
16
+ attachments: File[];
17
+ sources: File[];
18
+ };
19
+ /** Describe a delivery with its files encoded by the caller, such as private byte references. */ export declare let capturing: <File>({}: Incoming, file: (source: MailSource) => File) => Capture<File>;
20
+ /** Keep all bytes before projecting a delivery into a letter or an upload. */ export declare let capture: (mail: Incoming) => Capture;
21
+ /** Read original files from a capture, including ones an app could not take. */ export declare let captured: (parts: Part[]) => MailSource[];
22
+ //# sourceMappingURL=capture.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture.d.ts","sources":["../capture.ts"],"names":[],"mappings":"AAGA,cAAc,QAAQ,EAAE,UAAU,kCAAuC;KAEpE;EAAS,MAAM,MAAM;EAAE,MAAM,MAAM;EAAE,QAAQ,MAAM;;AAExD,2EAA2E,GAC3E,YAAY,QAAQ,OAAO;EACzB,MAAM,MAAM;EACZ,IAAI,MAAM;EACV,OAAO,MAAM;EACb,UAAU,MAAM,EAAE,MAAM;EACxB,MAAM,MAAM;EACZ,OAAO,MAAM;EACb,WAAW,OAAO;EAClB,UAAU,OAAO;EACjB,aAAa;EACb,SAAS;;AAQX,+FAA+F,GAC/F,OAAO,YAAI,YAAa,MACtB,IAA4C,QAAQ,EACpD,OAAO,QAAQ,eAAe,SAC7B,QAAQ,MAKT;AAEF,4EAA4E,GAC5E,OAAO,YAAI,UAAW,MAAM,aAAW,QAAgC;AAEvE,8EAA8E,GAC9E,OAAO,YAAI,WAAY,OAAO,WAAS,aACuC"}
@@ -0,0 +1,27 @@
1
+ import type { VocabDoc } from "@yaks/vocab";
2
+ /** The component naming one letter. */ export declare let MAIL: string;
3
+ /** The component naming an address as an entity of its own. */ export declare let EMAIL: string;
4
+ /** The component keeping an address only a letter names to those who may read
5
+ * the letters. */ export declare let RECIPIENT: string;
6
+ /** The component naming who a letter is for, as an entity. */ export declare let DELIVER: string;
7
+ /** The component stamped on a letter that left. */ export declare let DELIVERED: string;
8
+ /** The component stamped on a letter that did not. */ export declare let BOUNCED: string;
9
+ /** The component stamped when a recipient was told. */ export declare let NOTIFIED: string;
10
+ /**
11
+ * The mail vocabulary document, to load beside
12
+ * {@link https://jsr.io/@yaks/doc | @yaks/doc}'s and your own:
13
+ * `loadVocab([docDoc, mailDoc, ...mine])`. It declares nothing about what a
14
+ * person or a club is — those are plain entities in your own vocabulary — only
15
+ * the envelope of a letter, who it is for, and what became of it. The subject
16
+ * and the body are `doc.title` and `doc.body`.
17
+ *
18
+ * The `prefix` keywords are {@link https://jsr.io/@yaks/id | @yaks/id}'s: load
19
+ * that package's keywords and a letter reads back as `E-7`, an address as
20
+ * `A-3`. A loader that never registers them simply drops both.
21
+ *
22
+ * `mail` declares `before: ['doc']` — an entity carrying both is a letter,
23
+ * not the `doc` it also carries, so `mail` sorts first. The component it sorts
24
+ * against is @yaks/doc's, which is why this document is never loaded without
25
+ * it.
26
+ */ export declare let mailDoc: VocabDoc;
27
+ //# sourceMappingURL=comp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"comp.d.ts","sources":["../comp.ts"],"names":[],"mappings":"AAgDA,cAAc,QAAQ,2BAAgC;AAGtD,qCAAqC,GACrC,OAAO,YAAI,aAAa;AAExB,6DAA6D,GAC7D,OAAO,YAAI,cAAe;AAE1B;gBACgB,GAChB,OAAO,YAAI,kBAAuB;AAElC,4DAA4D,GAC5D,OAAO,YAAI,gBAAmB;AAE9B,iDAAiD,GACjD,OAAO,YAAI,kBAAuB;AAElC,oDAAoD,GACpD,OAAO,YAAI,gBAAmB;AAE9B,qDAAqD,GACrD,OAAO,YAAI,iBAAqB;AAEhC;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,SAAS,SAAc"}
@@ -0,0 +1,9 @@
1
+ import type { Handler, Handlers } from "@yaks/effects";
2
+ import type { Host } from "@yaks/host";
3
+ import type { Options } from "./options.js";
4
+ export { post } from "./transport.js";
5
+ /** Keep the request owed while its sender is unavailable. */ export declare let waiting: (reason: string) => Handler;
6
+ /** The outbound half: `mail_post`, wherever a sender was named. Where the
7
+ * sender cannot be built, nothing is sent and the letters wait in the graph
8
+ * rather than the server refusing to start. */ export declare let effects: (host?: Pick<Host, 'senders'> & Partial<Pick<Host, 'vocab'>> | null, options?: Options) => Handlers;
9
+ //# sourceMappingURL=effects.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.d.ts","sources":["../effects.ts"],"names":[],"mappings":"AAgBA,cAAc,OAAO,EAAE,QAAQ,6BAAkC;AAKjE,cAAc,IAAI,0BAA+B;AAEjD,cAAc,OAAO,uBAAsB;AAK3C,SAAS,IAAI,yBAAwB;AAGrC,2DAA2D,GAC3D,OAAO,YAAI,UAAW,QAAQ,MAAM,KAAG,QAwBnC;AAEJ;;6CAE6C,GAC7C,OAAO,YAAI,UACT,OAAO,KAAK,MAAM,aAAa,QAAQ,KAAK,MAAM,YAAY,IAAI,EAClE,UAAS,YACR,SAyBF"}
@@ -0,0 +1,16 @@
1
+ import { type Incoming, type Message, type Sender } from "@yaks/host/senders";
2
+ export declare let GMAIL_MAILBOX: string;
3
+ /** The raw MIME Gmail sends, including the headers used to thread replies. */ export declare let gmailLetter: (m: Message, id?: string) => string;
4
+ type Call = (req: Request) => Promise<Response>;
5
+ /** The mailbox identity and the Gmail history position from which new mail starts. */ export declare let gmailProfile: (call: Call, expected: string) => Promise<string>;
6
+ /** Gmail's accepted addresses, after checking that this is the selected account. */ export declare let gmailAddresses: (call: Call, expected: string) => Promise<Set<string>>;
7
+ export declare let gmailSender: (call: Call, expected: string) => Sender;
8
+ /** The activation time is the lower bound even if Gmail expires a history ID. */ export type GmailCursor = {
9
+ history: string;
10
+ since: string;
11
+ through: string;
12
+ };
13
+ export declare let gmailStart: (call: Call, primary: string, started: string) => Promise<GmailCursor>;
14
+ /** A poll reads message content only after Gmail's delivery time and labels
15
+ * have been checked. Advance the cursor only once every arrival is filed. */ export declare let gmailPoll: (call: Call, primary: string, cursor: GmailCursor, started: string, file: (id: string, mail: Incoming) => Promise<unknown>) => Promise<GmailCursor>;
16
+ //# sourceMappingURL=gmail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gmail.d.ts","sources":["../gmail.ts"],"names":[],"mappings":"AAEA,SACE,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,MAAM,kCAGyB;AAEtC,OAAO,YAAI,sBAA+B;AAW1C,4EAA4E,GAC5E,OAAO,YAAI,cAAe,GAAG,SAAS,KAAK,MAAM,KAAG,MAAM,CAqCzD;KAEI,QAAQ,KAAK,YAAY,QAAQ;AAyCtC,oFAAoF,GACpF,OAAO,YAAI,eACT,MAAM,MACN,UAAU,MAAM,KACf,QAAQ,MAAM,EAShB;AAQD,kFAAkF,GAClF,OAAO,YAAI,iBACT,MAAM,MACN,UAAU,MAAM,KACf,QAAQ,IAAI,MAAM,GAcpB;AAED,OAAO,YAAI,cAAe,MAAM,MAAM,UAAU,MAAM,KAAG,OA2BvD;AAwDF,+EAA+E,GAC/E,YAAY;EAAgB,SAAS,MAAM;EAAE,OAAO,MAAM;EAAE,SAAS,MAAM;;AAC3E,OAAO,YAAI,aACT,MAAM,MACN,SAAS,MAAM,EACf,SAAS,MAAM,KACd,QAAQ,aAIT;AAEF;2EAC2E,GAC3E,OAAO,YAAI,YACT,MAAM,MACN,SAAS,MAAM,EACf,QAAQ,aACR,SAAS,MAAM,EACf,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,QAAQ,OAAO,MACpD,QAAQ,aAmEV"}
@@ -0,0 +1,9 @@
1
+ import type { Plugin } from "@yaks/graph";
2
+ import type { Vocab } from "@yaks/vocab";
3
+ import type { Options } from "./options.js";
4
+ /** The letter components, the address canonicalizer the domain implies, and
5
+ * the mark that keeps an address only a letter names with the letters, where
6
+ * the store speaks the words it is written in. */ export declare let plugins: ({}: {
7
+ vocab: Vocab;
8
+ }, options?: Options) => Plugin[];
9
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAUA,cAAc,MAAM,2BAAgC;AACpD,cAAc,KAAK,2BAAgC;AAGnD,cAAc,OAAO,uBAAsB;AAE3C;;gDAEgD,GAChD,OAAO,YAAI,UACT;EAAa,OAAO;CAAO,EAC3B,UAAS,YACR,SAOF"}
@@ -0,0 +1,105 @@
1
+ import type { Bundle, Eid } from "@yaks/graph";
2
+ /** The head of a received message — a web `Headers` satisfies this. */ export type Head = {
3
+ get: (name: string) => string | null;
4
+ };
5
+ /** A received message: the slice of an Email Workers message this reads. */ export type Received = {
6
+ /** the envelope sender — SMTP plumbing, often a bounce address */ from: string;
7
+ /** the address it was delivered to */ to: string;
8
+ /** its headers */ headers: Head;
9
+ };
10
+ /** What the caller knows and the message does not. */ export type Arrival = {
11
+ /** the body as text, once something has parsed the MIME */ text?: string;
12
+ /** the id to record it under (default: a fresh uuid) */ eid?: Eid;
13
+ /** the entity the letter is about — the recipient, a thread, a task */ target?: Eid;
14
+ /** the letter this one answers, once something has looked up which letter
15
+ * the `in-reply-to` header names (./arrive.ts `known`) */ reply?: Eid;
16
+ /** when it arrived (default: the Date header, else now) */ at?: string;
17
+ /**
18
+ * whether the sending domain signed for it — the receiving MTA's verdict,
19
+ * which only the caller has. Left out, the letter records none; `false` is
20
+ * recorded and never a reason to drop the letter (see {@link verdict}).
21
+ */ verified?: boolean;
22
+ /** the receiving edge authenticated the From address itself: DMARC, or
23
+ * DKIM by the From domain, aligned with it. Only this names the letter's
24
+ * author (./arrive.ts); a From header alone is anyone's to write. */ vouched?: boolean;
25
+ };
26
+ /**
27
+ * The DKIM verdict off an `Authentication-Results` header, as every receiving
28
+ * MTA writes one: `true` only where the header says `dkim=pass`, `null` where
29
+ * there is no header to read at all — nobody checked, which is not the same as
30
+ * a check that failed.
31
+ *
32
+ * ```ts
33
+ * import { verdict } from '@yaks/mail'
34
+ * let head = (v: string | null) => ({ get: () => v })
35
+ * verdict(head('mx.example; dkim=pass header.i=@books.example; spf=pass')) // true
36
+ * verdict(head('mx.example; dkim=fail; spf=pass')) // false
37
+ * verdict(head(null)) // null
38
+ * ```
39
+ */ export declare let verdict: (m: Head) => boolean | null;
40
+ /**
41
+ * Who wrote the letter, from the `From:` header.
42
+ *
43
+ * The envelope `from` is not the author: a relay stamps its own bounce address
44
+ * there, so a reply aimed at it reaches a bounce sink rather than a person.
45
+ * The header is the author, in either of its two shapes — `Ana <ana@x.example>`
46
+ * or a bare address — and the envelope is the fallback when there is no header
47
+ * at all.
48
+ */ export declare let author: (m: Received) => string;
49
+ /**
50
+ * Whom an answer goes to, from the `Reply-To:` header: the first address it
51
+ * names, or `''` when it names none. A relay (a feedback form, a list) writes
52
+ * for somebody else, so its `From:` is the relay and this is the person. A
53
+ * list's first reader is enough, the way a mail client's Reply answers one.
54
+ *
55
+ * ```ts
56
+ * import { answerer } from '@yaks/mail'
57
+ * let said = (v: string | null) => ({ from: '', to: '', headers: { get: () => v } })
58
+ * answerer(said('Ana <ana@x.example>, bo@x.example')) // 'ana@x.example'
59
+ * answerer(said('ana@x.example')) // 'ana@x.example'
60
+ * answerer(said(null)) // ''
61
+ * ```
62
+ */ export declare let answerer: (m: Received) => string;
63
+ /**
64
+ * The words a letter's author wrote: its text without the quote of somebody
65
+ * else's letter, which a mail client sets below a reply (or between its
66
+ * lines). A person's letter then never carries another's words as theirs; the
67
+ * letter it quotes is the one its `in-reply-to` names, kept where it was.
68
+ *
69
+ * A quote is known by the line a client introduces it with: `On <date>,
70
+ * <name> <address> wrote:` (which some clients wrap over two lines), or an
71
+ * Outlook header block, `From:` then `Sent:` or `Date:`, or `-----Original
72
+ * Message-----`. Where that line names the author, the quote is their own
73
+ * earlier letter and stays. Otherwise the quote goes: its `>` lines, wherever
74
+ * they fall after it, or everything after it where its lines carry no `>` (an
75
+ * html letter read as text, an Outlook reply). A letter with no such line is
76
+ * its author's, `>` lines and all.
77
+ *
78
+ * ```ts
79
+ * import { own } from '@yaks/mail'
80
+ * own('ok\n\nOn Fri, Bo <bo@x.example> wrote:\n> Send the keys.', 'ana@x.example')
81
+ * // 'ok'
82
+ * own('ok\n\nOn Fri, Ana <ana@x.example> wrote:\n> My list.', 'ana@x.example')
83
+ * // 'ok\n\nOn Fri, Ana <ana@x.example> wrote:\n> My list.'
84
+ * ```
85
+ */ export declare let own: (text: string, author: string) => string;
86
+ /** The unbracketed Message-ID of a received letter, or `''`. */ export declare let messageId: (m: Received) => string;
87
+ /**
88
+ * A received message → the bundles that record it: one entity carrying the
89
+ * envelope it arrived in (`mail`) and the words it carried
90
+ * ({@link https://jsr.io/@yaks/doc | @yaks/doc}'s `doc{title, body}`).
91
+ *
92
+ * ```ts
93
+ * import { inbound } from '@yaks/mail'
94
+ * // in a Worker's email() handler:
95
+ * // let text = await parse(message.raw)
96
+ * // await graph.apply(inbound(message, { text, target: club }))
97
+ * ```
98
+ *
99
+ * Threading is a lookup, so the caller passes in the answer rather than the
100
+ * question: read the `in-reply-to` header, find the letter whose `message_id`
101
+ * matches, and pass it as `reply`. Same for `target` when the recipient
102
+ * address names an entity — query `email.address`, and pass what you find.
103
+ * Both lookups live in ./arrive.ts, which has a graph to query.
104
+ */ export declare let inbound: (m: Received, arrival?: Arrival) => Bundle[];
105
+ //# sourceMappingURL=inbound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound.d.ts","sources":["../inbound.ts"],"names":[],"mappings":"AAwBA,cAAc,MAAM,EAAE,GAAG,2BAAgC;AAIzD,qEAAqE,GACrE,YAAY;EAAS,MAAM,MAAM,MAAM,KAAK,MAAM,GAAG,IAAI;;AAEzD,0EAA0E,GAC1E,YAAY;EACV,gEAAgE,GAChE,MAAM,MAAM;EACZ,oCAAoC,GACpC,IAAI,MAAM;EACV,gBAAgB,GAChB,SAAS;;AAGX,oDAAoD,GACpD,YAAY;EACV,yDAAyD,GACzD,OAAO,MAAM;EACb,sDAAsD,GACtD,MAAM;EACN,qEAAqE,GACrE,SAAS;EACT;0DACwD,GACxD,QAAQ;EACR,yDAAyD,GACzD,KAAK,MAAM;EACX;;;;GAIC,GACD,WAAW,OAAO;EAClB;;qEAEmE,GACnE,UAAU,OAAO;;AAGnB;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,UAAW,GAAG,SAAO,OAAO,GAAG,IAAI,CAG7C;AAED;;;;;;;;CAQC,GACD,OAAO,YAAI,SAAU,GAAG,aAAW,MAAM,CACG;AAE5C;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,WAAY,GAAG,aAAW,MAAM,CACU;AASrD;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,YAAI,MAAO,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,CAoBtD;AA2BD,8DAA8D,GAC9D,OAAO,YAAI,YAAa,GAAG,aAAW,MAAM,CACqB;AAEjE;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,YAAI,UAAW,GAAG,UAAU,UAAS,YAAe,SAwB1D"}
@@ -0,0 +1,69 @@
1
+ import type { Bundle, Comp, Eid } from "@yaks/graph";
2
+ import type { Handler } from "@yaks/effects";
3
+ /** The roster row that was just written, as the letter's author sees it. */ export type Seat = {
4
+ /** the roster row's own entity id */ eid: Eid;
5
+ /** who joined */ person: Eid;
6
+ /** what they joined */ space: Eid;
7
+ /** what they joined as — whatever your roster's role property holds */ role: string;
8
+ /** the whole `member` component, for a roster with more properties than
9
+ * these */ member: Comp;
10
+ };
11
+ /** The letter to send about a new roster row, or `null` to send none. */ export type Welcome = (seat: Seat) => {
12
+ /** the address it comes from */ from: string;
13
+ /** the subject line */ subject: string;
14
+ /** the body, as markdown */ body: string;
15
+ } | null;
16
+ /** How the handler is built. */ export type Invite = {
17
+ /** compose the letter (or decline to) */ welcome: Welcome;
18
+ /** the graph's own `apply` — the letter goes through the full pipeline */ apply: (bundles: Bundle[]) => unknown;
19
+ /** the id for the new letter (default: a fresh uuid) */ eid?: () => Eid;
20
+ /** the clock, passed in so a test can hold it still (default: now) */ now?: () => string;
21
+ };
22
+ /**
23
+ * The `created(member)` handler: write an invitation to whoever just joined.
24
+ *
25
+ * ```ts
26
+ * import { assertEquals } from '@std/assert'
27
+ * import { effects } from '@yaks/effects'
28
+ * import { graph } from '@yaks/graph'
29
+ * import { ram } from '@yaks/ram'
30
+ * import { loadVocab } from '@yaks/vocab'
31
+ * import { docDoc, docs } from '@yaks/doc'
32
+ * import { memberDoc } from '@yaks/member'
33
+ * import { invited, mailbox, mailDoc, stash } from '@yaks/mail'
34
+ *
35
+ * let vocab = loadVocab([docDoc, mailDoc, memberDoc])
36
+ * let fx = effects(vocab, { write: (b) => club.apply(b, { trusted: true }) })
37
+ * let post = stash()
38
+ * let club = graph({
39
+ * storage: ram(vocab),
40
+ * vocab,
41
+ * plugins: [fx, docs(), mailbox({ sender: post, effects: fx })],
42
+ * })
43
+ * fx.created('member', invited({
44
+ * apply: (bundles) => club.apply(bundles),
45
+ * welcome: () => ({
46
+ * from: 'hello@books.example',
47
+ * subject: 'You are in the book club',
48
+ * body: 'Welcome. We meet Thursdays.',
49
+ * }),
50
+ * }))
51
+ *
52
+ * await club.apply([
53
+ * { entity: { eid: 'club' }, doc: { title: 'Book club' } },
54
+ * { entity: { eid: 'ana' }, email: { address: 'ana@books.example' } },
55
+ * {
56
+ * entity: { eid: 'm1' },
57
+ * member: { space: 'club', person: 'ana', role: 'member' },
58
+ * },
59
+ * ])
60
+ * assertEquals(post.last()?.to, 'ana@books.example')
61
+ * ```
62
+ *
63
+ * The letter is addressed to the person as an entity (`deliver.to`), not to a
64
+ * string, so the address it actually goes to is whatever their `email`
65
+ * component holds at the moment it leaves — and a person with no address on
66
+ * file gets a letter stamped `bounced` saying exactly that, rather than
67
+ * silence.
68
+ */ export declare let invited: ({}: Invite) => Handler;
69
+ //# sourceMappingURL=invite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invite.d.ts","sources":["../invite.ts"],"names":[],"mappings":"AAiBA,cAAc,MAAM,EAAE,IAAI,EAAE,GAAG,2BAAgC;AAC/D,cAAc,OAAO,6BAAkC;AAIvD,0EAA0E,GAC1E,YAAY;EACV,mCAAmC,GACnC,KAAK;EACL,eAAe,GACf,QAAQ;EACR,qBAAqB,GACrB,OAAO;EACP,qEAAqE,GACrE,MAAM,MAAM;EACZ;WACS,GACT,QAAQ;;AAGV,uEAAuE,GACvE,YAAY,WAAW,MAAM;EAC3B,8BAA8B,GAC9B,MAAM,MAAM;EACZ,qBAAqB,GACrB,SAAS,MAAM;EACf,0BAA0B,GAC1B,MAAM,MAAM;IACV,IAAI;AAER,8BAA8B,GAC9B,YAAY;EACV,uCAAuC,GACvC,SAAS;EACT,wEAAwE,GACxE,QAAQ,SAAS,aAAa,OAAO;EACrC,sDAAsD,GACtD,YAAY;EACZ,oEAAoE,GACpE,YAAY,MAAM;;AAKpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CC,GACD,OAAO,YAAI,UACT,IAKG,MAAM,KACR,QA2BF"}
package/_dist/md.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ /** One piece of a body: a run of words, or the markup that decorates it. */ export type Token = {
2
+ /** what it is */ kind: 'text' | 'link' | 'code' | 'strong' | 'em' | 'ref';
3
+ /** the words it carries */ text: string;
4
+ /** where a link points */ href?: string;
5
+ };
6
+ /** What a letter calls an entity its body holds the eid of: its id, and the
7
+ * page a reader opens it at, where it has one. */ export type Named = {
8
+ id: string;
9
+ href?: string;
10
+ };
11
+ /** What the sender calls each eid a body holds, or nothing for one it does not
12
+ * know, which then stays as written. */ export type Names = (eid: string) => Named | undefined;
13
+ /** A line of markdown → the tokens it is made of, in order. */ export declare let tokens: (line: string) => Token[];
14
+ /** The eids a body names, written bare or as a link's target, once each and
15
+ * in lower case: what the sender is asked to name. Code keeps its ids literal,
16
+ * so none in it is listed. */ export declare let eids: (body: string) => string[];
17
+ /** Whether an href may become an anchor: absolute, and one of four schemes. */ export declare let linkable: (href: string) => boolean;
18
+ /** `&` first, or the escapes escape. */ export declare let escape: (s: string) => string;
19
+ /**
20
+ * A markdown body → safe HTML for the message's HTML part. Everything the body
21
+ * wrote is escaped; the only markup in the result is this file's own.
22
+ *
23
+ * ```ts
24
+ * import { html } from '@yaks/mail'
25
+ * html('Potluck **Friday** — [sign up](https://books.example/potluck)')
26
+ * // '<p>Potluck <strong>Friday</strong> — <a href="…">sign up</a></p>'
27
+ * ```
28
+ */ export declare let html: (body: string, names?: Names) => string;
29
+ /**
30
+ * The same body as plain text, for the message's text part: the markup goes,
31
+ * the words stay, and a link keeps its address in parentheses so a reader with
32
+ * no HTML can still follow it.
33
+ */ export declare let text: (body: string, names?: Names) => string;
34
+ //# sourceMappingURL=md.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"md.d.ts","sources":["../md.ts"],"names":[],"mappings":"AA8BA,0EAA0E,GAC1E,YAAY;EACV,eAAe,GACf,MAAM,SAAS,SAAS,SAAS,WAAW,OAAO;EACnD,yBAAyB,GACzB,MAAM,MAAM;EACZ,wBAAwB,GACxB,OAAO,MAAM;;AAGf;gDACgD,GAChD,YAAY;EAAU,IAAI,MAAM;EAAE,OAAO,MAAM;;AAE/C;sCACsC,GACtC,YAAY,SAAS,KAAK,MAAM,KAAK,QAAQ,SAAS;AAatD,6DAA6D,GAC7D,OAAO,YAAI,SAAU,MAAM,MAAM,KAAG,QAenC;AAED;;4BAE4B,GAC5B,OAAO,YAAI,OAAQ,MAAM,MAAM,KAAG,MAAM,GAUvC;AAqBD,6EAA6E,GAC7E,OAAO,YAAI,WAAY,MAAM,MAAM,KAAG,OAAO,CACW;AAExD,sCAAsC,GACtC,OAAO,YAAI,SAAU,GAAG,MAAM,KAAG,MAAM,CAEX;AA4F5B;;;;;;;;;CASC,GACD,OAAO,YAAI,OAAQ,MAAM,MAAM,EAAE,QAAQ,UAAQ,MAAM,CACM;AAE7D;;;;CAIC,GACD,OAAO,YAAI,OAAQ,MAAM,MAAM,EAAE,QAAQ,UAAQ,MAAM,CAgBtC"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,109 @@
1
+ /**
2
+ * @yaks/mail — letters, in the graph: the mail components for a
3
+ * {@link https://jsr.io/@yaks/graph | @yaks/graph}.
4
+ *
5
+ * Say a book club runs on a graph. It has people, a reading list, a potluck
6
+ * sign-up. Sooner or later it has to write to somebody — an invitation, a
7
+ * reminder, an answer to a question that arrived by email — and that is this
8
+ * package: a letter is an entity like everything else, so it is queryable,
9
+ * attributable, and hangs off the thing it is about.
10
+ *
11
+ * ## A letter is an entity
12
+ * ```ts
13
+ * import { mailDoc } from '@yaks/mail'
14
+ * // { entity: { eid: 'e1' },
15
+ * // doc: { title: 'Potluck Friday', body: 'Bring a dish.' },
16
+ * // mail: { from: 'hello@books.example', target: potluck },
17
+ * // deliver: { to: ana } }
18
+ * ```
19
+ * `mail` is the envelope, `deliver` is the request to send it, and `target` is
20
+ * what it is about — any entity at all. Because the recipient is an entity
21
+ * rather than a string, the address it goes to is whatever their
22
+ * {@link mailDoc | `email`} component holds at the moment it leaves.
23
+ *
24
+ * ## The subject and the body are a `doc` They are `doc{title, body}`, from
25
+ * {@link https://jsr.io/@yaks/doc | @yaks/doc}, which this package depends on.
26
+ * The words a person reads belong in the one component every readable thing
27
+ * has, so a letter is searched, rendered and edited by whatever already handles
28
+ * a `doc` — instead of by a second copy of the same two properties.
29
+ *
30
+ * Compose `docs()` beside {@link mailbox}, never inside it: a vocabulary
31
+ * rejects a component declared twice, so an application that already declares
32
+ * `doc` is not fought over it.
33
+ *
34
+ * ## Sending is an effect, not a write
35
+ * Nothing in `apply()` talks to a mail server. {@link sending} is a
36
+ * `created(mail)` handler on {@link https://jsr.io/@yaks/effects | @yaks/effects}:
37
+ * it runs after the transaction commits, hands the letter to the
38
+ * {@link Sender} the caller supplied, and writes back what happened —
39
+ * `delivered{at}` or `bounced{at, reason}`. So the write cannot fail
40
+ * because a mail server is down, and "what became of that letter?" is a query.
41
+ *
42
+ * {@link post} selects a sender by name from those the host lends: a
43
+ * provider's, lent by its own plugin (@yaks/resend, @yaks/cloudflare-mail),
44
+ * or the host's own. {@link stash} is built in, for tests and development.
45
+ *
46
+ * ## Receiving is a pure function {@link inbound} turns a message as an Email
47
+ * Worker receives it into the bundles that record it. It queries the graph for
48
+ * nothing, so it can be tested without one. The two properties that are lookups
49
+ * — whom the letter is about, which letter it answers — are answered by {@link
50
+ * arrived} one file over, where there is a graph to query, and
51
+ * `@yaks/mail/routes` exports the HTTP route a mail edge posts a letter on.
52
+ *
53
+ * ## The worked example
54
+ * {@link invited} fills the `created(member)` handler slot
55
+ * {@link https://jsr.io/@yaks/member | @yaks/member} documents and leaves
56
+ * empty: somebody joins the club, and an invitation is written — the sending
57
+ * effect carries it like any other letter.
58
+ *
59
+ * ```ts
60
+ * import { graph } from '@yaks/graph'
61
+ * import { effects } from '@yaks/effects'
62
+ * import { ram } from '@yaks/ram'
63
+ * import { loadVocab } from '@yaks/vocab'
64
+ * import { docDoc, docs } from '@yaks/doc'
65
+ * import { memberDoc } from '@yaks/member'
66
+ * import { invited, mailbox, mailDoc, stash } from '@yaks/mail'
67
+ *
68
+ * let vocab = loadVocab([docDoc, mailDoc, memberDoc])
69
+ * let fx = effects(vocab, { write: (b) => g.apply(b, { trusted: true }) })
70
+ * let post = stash()
71
+ * let box = mailbox({ domain: 'books.example', sender: post, effects: fx })
72
+ * let g = graph({ storage: ram(vocab), vocab, plugins: [fx, docs(), box] })
73
+ *
74
+ * fx.created('member', invited({
75
+ * apply: (bundles) => g.apply(bundles),
76
+ * welcome: () => ({
77
+ * from: 'hello@books.example',
78
+ * subject: 'You are in the book club',
79
+ * body: 'Welcome. We meet Thursdays.',
80
+ * }),
81
+ * }))
82
+ * ```
83
+ *
84
+ * ## What is deliberately not here
85
+ * MIME parsing (pass {@link inbound} the text — a parser is a parser's job),
86
+ * queues and retries (a bounced letter is data; writing a fresh one is the
87
+ * retry), and any credential of any kind.
88
+ *
89
+ * The core — the vocabulary, {@link canon}, {@link inbound}, {@link sending} —
90
+ * imports no platform API, so it runs on a server, in a Worker, and in a
91
+ * browser tab. No mail provider lives here.
92
+ *
93
+ * @module
94
+ */ export * from "./comp.js";
95
+ export * from "./addr.js";
96
+ export * from "./md.js";
97
+ export * from "./send.js";
98
+ export * from "./stash.js";
99
+ export * from "./transport.js";
100
+ export * from "./inbound.js";
101
+ export * from "./arrive.js";
102
+ export * from "./invite.js";
103
+ export * from "./plugin.js";
104
+ export * from "./recipient.js";
105
+ export * from "./options.js";
106
+ export * from "./pull.js";
107
+ export * from "./capture.js";
108
+ export { deliveryField, receipted } from "./receipts.js";
109
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FC,GAED,0BAAyB;AACzB,0BAAyB;AACzB,wBAAuB;AACvB,0BAAyB;AACzB,2BAA0B;AAC1B,+BAA8B;AAC9B,6BAA4B;AAC5B,4BAA2B;AAC3B,4BAA2B;AAC3B,4BAA2B;AAC3B,+BAA8B;AAC9B,6BAA4B;AAC5B,0BAAyB;AACzB,6BAA4B;AAE5B,SAAS,aAAa,EAAE,SAAS,wBAAuB"}
@@ -0,0 +1,38 @@
1
+ import type { Eid } from "@yaks/graph";
2
+ /** What a config passes to @yaks/mail. */ export type Options = {
3
+ /** the sender address a host supplies for an app's own mailbox */ from?: () => string | null;
4
+ /** your own mail domain — the addresses this graph canonicalizes on write */ domain?: string;
5
+ /** whether `domain` belongs to this graph rather than to a mail server: a
6
+ * letter to an address there is delivered by writing it, never handed to the
7
+ * transport. True where the addresses at your domain are entities here (an
8
+ * agent, a project); false where somebody reads them in a mail client. */ local?: boolean;
9
+ /** where a letter addressed to nobody this graph knows lands — the triage
10
+ * entity, for letters posted to the door and letters pulled from an edge
11
+ * alike. With none, such a letter is recorded with no target. */ triage?: Eid;
12
+ /** where an entity a letter names opens: an address with `{id}` where its
13
+ * id goes (`https://tasks.yak.sh/{id}`). Each entity a body names then reads
14
+ * as its id linked there; with none, as its id alone. */ mentions?: string;
15
+ /** the transport outbound letters go through; with none, none are sent */ sender?: Transport;
16
+ /** where letters arrive, and who may post one to this graph */ door?: Door;
17
+ /** the edge this graph pulls arrivals from, where the edge cannot reach the
18
+ * graph to post them; with none, nothing is pulled */ pull?: Pull;
19
+ };
20
+ /** The sender outbound letters go through, by the name the host lends it
21
+ * under: a provider plugin's (`resend`, `cloudflare`), the host's own, or the
22
+ * built-in `stash`. */ export type Transport = {
23
+ /** a name in Host.senders, or `stash` */ via: string;
24
+ };
25
+ /** The arrival endpoint: where a mail edge posts a letter, and what it must
26
+ * present. */ export type Door = {
27
+ /** the path it answers on (default `/mail/inbound`) */ path?: string;
28
+ /** the bearer token the mail edge presents. Set none and the endpoint
29
+ * takes no letter. */ secret?: string;
30
+ };
31
+ /** The edge arrivals are pulled from (./pull.ts): the letters that came to
32
+ * your domain, and the requests posted to its hook paths, held until this
33
+ * graph takes them. */ export type Pull = {
34
+ /** the edge's API root */ url: string;
35
+ /** the bearer token it asks for — `{"secret": "…"}` in the config */ token: string;
36
+ /** how long to wait between pulls, in milliseconds (default ten seconds) */ every?: number;
37
+ };
38
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sources":["../options.ts"],"names":[],"mappings":"AAwBA,cAAc,GAAG,2BAAgC;AAEjD,wCAAwC,GACxC,YAAY;EACV,gEAAgE,GAChE,aAAa,MAAM,GAAG,IAAI;EAC1B,2EAA2E,GAC3E,SAAS,MAAM;EACf;;;0EAGwE,GACxE,QAAQ,OAAO;EACf;;iEAE+D,GAC/D,SAAS;EACT;;yDAEuD,GACvD,WAAW,MAAM;EACjB,wEAAwE,GACxE,SAAS;EACT,6DAA6D,GAC7D,OAAO;EACP;sDACoD,GACpD,OAAO;;AAGT;;qBAEqB,GACrB,YAAY;EACV,uCAAuC,GACvC,KAAK,MAAM;;AAGb;YACY,GACZ,YAAY;EACV,qDAAqD,GACrD,OAAO,MAAM;EACb;sBACoB,GACpB,SAAS,MAAM;;AAGjB;;qBAEqB,GACrB,YAAY;EACV,wBAAwB,GACxB,KAAK,MAAM;EACX,mEAAmE,GACnE,OAAO,MAAM;EACb,0EAA0E,GAC1E,QAAQ,MAAM"}