@segmentstream/ontology 0.106.1 → 0.106.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.106.2
4
+
5
+ `emailReplyMessage` from `@segmentstream/ontology/email` takes two more options:
6
+
7
+ - `autoSubmitted` marks the reply `Auto-Submitted: auto-replied`. Another agent's mail channel, an
8
+ autoresponder or a mailing list then never answers it.
9
+ - `replyKey` names the reply in an `X-SegmentStream-Reply` header. A sender that retries after an
10
+ uncertain failure can then find the reply in the thread instead of sending it twice.
11
+
3
12
  ## 0.106.1
4
13
 
5
14
  Workflow maps read more workflows in full. A promise's `.catch(…)` or `.finally(…)` now reads as a
package/dist/email.d.ts CHANGED
@@ -20,7 +20,20 @@ export interface EmailReply {
20
20
  /** The reply as plain text, and the same reply as HTML. */
21
21
  readonly text: string;
22
22
  readonly html: string;
23
+ /**
24
+ * Marks the reply `Auto-Submitted: auto-replied` (RFC 3834), as a reply a program sent: another
25
+ * agent's mail channel, an autoresponder or a mailing list then never answers it, so two agents
26
+ * cannot reply to each other without end.
27
+ */
28
+ readonly autoSubmitted?: boolean;
29
+ /**
30
+ * Names this reply (`X-SegmentStream-Reply`), so a sender that retries after an uncertain
31
+ * failure can find it in the thread instead of sending it twice. Letters, digits, `-` and `_`.
32
+ */
33
+ readonly replyKey?: string;
23
34
  }
35
+ /** The header that names a reply, as {@link EmailReply.replyKey} sets it. */
36
+ export declare const REPLY_KEY_HEADER = "X-SegmentStream-Reply";
24
37
  /**
25
38
  * The reply as an RFC 5322 message with a plain-text and an HTML part, for a mailbox to send in
26
39
  * the same thread. It names no sender: the mailbox sends from its own address.
package/dist/email.js CHANGED
@@ -48,6 +48,8 @@ function base64Lines(text) {
48
48
  .match(/.{1,76}/g)
49
49
  ?.join("\r\n") ?? "");
50
50
  }
51
+ /** The header that names a reply, as {@link EmailReply.replyKey} sets it. */
52
+ export const REPLY_KEY_HEADER = "X-SegmentStream-Reply";
51
53
  /**
52
54
  * The reply as an RFC 5322 message with a plain-text and an HTML part, for a mailbox to send in
53
55
  * the same thread. It names no sender: the mailbox sends from its own address.
@@ -56,6 +58,9 @@ export function emailReplyMessage(reply) {
56
58
  if (!/^[^\s<>@,;:"]+@[^\s<>@,;:"]+$/.test(reply.to)) {
57
59
  throw new Error("The reply's recipient is not a plain address.");
58
60
  }
61
+ if (reply.replyKey !== undefined && !/^[A-Za-z0-9_-]{1,128}$/.test(reply.replyKey)) {
62
+ throw new Error("The reply's key holds characters a header cannot carry.");
63
+ }
59
64
  const boundary = `segmentstream-${crypto.randomUUID()}`;
60
65
  const parent = messageId(reply.inReplyTo);
61
66
  const references = [
@@ -71,6 +76,8 @@ export function emailReplyMessage(reply) {
71
76
  `Subject: ${headerText(replySubject(reply.subject))}`,
72
77
  ...(parent === undefined ? [] : [`In-Reply-To: ${parent}`]),
73
78
  ...(references.length === 0 ? [] : [`References: ${[...new Set(references)].join(" ")}`]),
79
+ ...(reply.autoSubmitted === true ? ["Auto-Submitted: auto-replied"] : []),
80
+ ...(reply.replyKey === undefined ? [] : [`${REPLY_KEY_HEADER}: ${reply.replyKey}`]),
74
81
  "MIME-Version: 1.0",
75
82
  `Content-Type: multipart/alternative; boundary="${boundary}"`,
76
83
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@segmentstream/ontology",
3
- "version": "0.106.1",
3
+ "version": "0.106.2",
4
4
  "description": "Define a SegmentStream workspace app's ontology: entities, relationships, roles and actions, written with Effect.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "SegmentStream",