@segmentstream/ontology 0.111.0 → 0.113.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 (47) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +9 -3
  3. package/dist/analyze.d.ts +8 -4
  4. package/dist/analyze.js +72 -27
  5. package/dist/chat-channel.d.ts +27 -2
  6. package/dist/chat-channel.js +36 -2
  7. package/dist/email-html.d.ts +23 -0
  8. package/dist/email-html.js +249 -0
  9. package/dist/emails.d.ts +38 -6
  10. package/dist/emails.js +71 -2
  11. package/dist/index.d.ts +5 -3
  12. package/dist/index.js +3 -1
  13. package/dist/manifest.d.ts +208 -52
  14. package/dist/manifest.js +32 -6
  15. package/dist/migrate/model.d.ts +98 -34
  16. package/dist/runtime/resolve-agent-identity.js +4 -1
  17. package/dist/service/agent/protocol.d.ts +4 -1
  18. package/dist/service/agent/protocol.js +7 -3
  19. package/dist/service/agent/server.js +8 -2
  20. package/dist/service/authentication.d.ts +2 -1
  21. package/dist/service/authentication.js +13 -3
  22. package/dist/service/chat/delivery.d.ts +10 -1
  23. package/dist/service/chat/delivery.js +21 -3
  24. package/dist/service/chat/envelope.d.ts +2 -2
  25. package/dist/service/chat/providers/custom.d.ts +13 -0
  26. package/dist/service/chat/providers/custom.js +103 -0
  27. package/dist/service/chat/providers/index.d.ts +1 -0
  28. package/dist/service/chat/providers/index.js +12 -3
  29. package/dist/service/chat/providers/provider.d.ts +19 -0
  30. package/dist/service/chat/reads.d.ts +1 -1
  31. package/dist/service/chat/reads.js +2 -2
  32. package/dist/service/chat/resolve.d.ts +2 -1
  33. package/dist/service/chat/resolve.js +6 -2
  34. package/dist/service/chat/review-delivery.d.ts +3 -0
  35. package/dist/service/chat/review-delivery.js +9 -3
  36. package/dist/service/chat/schemas.d.ts +2 -2
  37. package/dist/service/chat/schemas.js +2 -2
  38. package/dist/service/config.d.ts +6 -2
  39. package/dist/service/schemas.d.ts +30 -8
  40. package/dist/service/service.js +6 -1
  41. package/dist/sign-in.d.ts +22 -1
  42. package/dist/sign-in.js +3 -1
  43. package/dist/storage/tables.d.ts +4 -3
  44. package/dist/storage/tables.js +11 -3
  45. package/dist/workspace-channel.d.ts +54 -0
  46. package/dist/workspace-channel.js +36 -0
  47. package/package.json +5 -1
@@ -0,0 +1,249 @@
1
+ /**
2
+ * The safety rules of an email the workspace lays out itself, applied to its HTML as a browser
3
+ * reads it. A small tokenizer follows the HTML standard's tag, attribute, comment and raw-text
4
+ * states, so markup cannot hide a tag or an attribute from the check (an apostrophe in an unquoted
5
+ * value, a `/` between attributes, a missing space after a quote).
6
+ */
7
+ const PLACEHOLDER = /\{\{\s*([^{}]*?)\s*\}\}/g;
8
+ /**
9
+ * The values that may stand inside a tag, such as in an `href`: the platform's own addresses and
10
+ * the workspace's name. Every other value (the recipient's name, the code, what an action passes)
11
+ * stands only in text, where escaping keeps it text, so it can never become an address or add an
12
+ * attribute.
13
+ */
14
+ export const EMAIL_MARKUP_VALUES = ["link", "app.url", "app.mcpUrl", "workspace.name"];
15
+ /** Elements an email may not hold: they run code, embed other pages or post forms. */
16
+ const UNSAFE_ELEMENTS = new Set([
17
+ "script",
18
+ "iframe",
19
+ "frame",
20
+ "frameset",
21
+ "object",
22
+ "embed",
23
+ "applet",
24
+ "form",
25
+ "input",
26
+ "button",
27
+ "select",
28
+ "textarea",
29
+ "base",
30
+ "noscript",
31
+ ]);
32
+ /**
33
+ * Foreign content and plain text, which a browser reads by other rules: inside `<svg>` or `<math>`
34
+ * a `<title>` or `<style>` holds real markup, and after `<plaintext>` nothing is markup. Emails
35
+ * need none of them, so refusing them keeps every tag readable by the rules below.
36
+ */
37
+ const FOREIGN_ELEMENTS = new Set(["svg", "math", "plaintext"]);
38
+ /** Elements whose content a browser reads as raw text up to their end tag. */
39
+ const RAW_TEXT = new Set(["style", "xmp", "noembed", "noframes"]);
40
+ /** Elements whose content is text, with character references, up to their end tag. */
41
+ const ESCAPABLE_RAW_TEXT = new Set(["title"]);
42
+ const URL_ATTRIBUTES = new Set([
43
+ "href",
44
+ "src",
45
+ "action",
46
+ "formaction",
47
+ "background",
48
+ "poster",
49
+ "srcset",
50
+ "xlink:href",
51
+ "lowsrc",
52
+ "dynsrc",
53
+ "cite",
54
+ "longdesc",
55
+ "usemap",
56
+ ]);
57
+ const SAFE_URL = /^(?:https:\/\/|mailto:|tel:|#|\{\{\s*(?:link|app\.url|app\.mcpUrl)\s*\}\})/i;
58
+ const WHITESPACE = /[\t\n\f\r ]/;
59
+ const ALPHA = /[A-Za-z]/;
60
+ /** Reads one tag from `<` at `start`; undefined when the HTML ends inside it. */
61
+ function readTag(html, start) {
62
+ let at = start + 1;
63
+ const end = html[at] === "/";
64
+ if (end) {
65
+ at += 1;
66
+ }
67
+ let name = "";
68
+ while (at < html.length && !WHITESPACE.test(html[at]) && html[at] !== "/" && html[at] !== ">") {
69
+ name += html[at];
70
+ at += 1;
71
+ }
72
+ const attributes = [];
73
+ for (;;) {
74
+ while (at < html.length && (WHITESPACE.test(html[at]) || html[at] === "/")) {
75
+ at += 1;
76
+ }
77
+ if (at >= html.length) {
78
+ return undefined;
79
+ }
80
+ if (html[at] === ">") {
81
+ break;
82
+ }
83
+ // An attribute name runs to whitespace, /, > or =; a leading = belongs to the name.
84
+ let attribute = html[at];
85
+ at += 1;
86
+ while (at < html.length &&
87
+ !WHITESPACE.test(html[at]) &&
88
+ html[at] !== "/" &&
89
+ html[at] !== ">" &&
90
+ html[at] !== "=") {
91
+ attribute += html[at];
92
+ at += 1;
93
+ }
94
+ while (at < html.length && WHITESPACE.test(html[at])) {
95
+ at += 1;
96
+ }
97
+ let value = "";
98
+ let quoted = false;
99
+ if (html[at] === "=") {
100
+ at += 1;
101
+ while (at < html.length && WHITESPACE.test(html[at])) {
102
+ at += 1;
103
+ }
104
+ const quote = html[at];
105
+ if (quote === '"' || quote === "'") {
106
+ const close = html.indexOf(quote, at + 1);
107
+ if (close < 0) {
108
+ return undefined;
109
+ }
110
+ value = html.slice(at + 1, close);
111
+ quoted = true;
112
+ at = close + 1;
113
+ }
114
+ else {
115
+ // Unquoted: up to whitespace or >; quotes, = and < here are part of the value.
116
+ while (at < html.length && !WHITESPACE.test(html[at]) && html[at] !== ">") {
117
+ value += html[at];
118
+ at += 1;
119
+ }
120
+ }
121
+ }
122
+ attributes.push([attribute.toLowerCase(), value.trim(), quoted]);
123
+ }
124
+ return {
125
+ tag: { name, end, attributes, source: html.slice(start, at + 1) },
126
+ next: at + 1,
127
+ };
128
+ }
129
+ /** The HTML's tags, comments and raw-text contents, as a browser's tokenizer finds them. */
130
+ function partsOf(html) {
131
+ const parts = [];
132
+ let at = 0;
133
+ while (at < html.length) {
134
+ const open = html.indexOf("<", at);
135
+ if (open < 0) {
136
+ break;
137
+ }
138
+ const next = html[open + 1] ?? "";
139
+ const after = html[open + 2] ?? "";
140
+ if (html.startsWith("<!--", open)) {
141
+ // A comment ends at -->, or --!>; <!--> and <!---> end at once.
142
+ const body = open + 4;
143
+ const close = html.startsWith(">", body)
144
+ ? body + 1
145
+ : html.startsWith("->", body)
146
+ ? body + 2
147
+ : Math.min(...[html.indexOf("-->", body), html.indexOf("--!>", body)]
148
+ .filter((index) => index >= 0)
149
+ .map((index) => index + (html.startsWith("--!>", index) ? 4 : 3)), html.length);
150
+ parts.push({ kind: "comment", source: html.slice(open, close) });
151
+ at = close;
152
+ }
153
+ else if (next === "!" ||
154
+ next === "?" ||
155
+ (next === "/" && !ALPHA.test(after) && after !== ">")) {
156
+ // A declaration or bogus comment runs to the next >.
157
+ const close = html.indexOf(">", open);
158
+ const stop = close < 0 ? html.length : close + 1;
159
+ parts.push({ kind: "comment", source: html.slice(open, stop) });
160
+ at = stop;
161
+ }
162
+ else if (next === "/" && after === ">") {
163
+ at = open + 3;
164
+ }
165
+ else if (ALPHA.test(next) || (next === "/" && ALPHA.test(after))) {
166
+ const read = readTag(html, open);
167
+ if (read === undefined) {
168
+ parts.push({ kind: "unclosed", source: html.slice(open) });
169
+ break;
170
+ }
171
+ parts.push({ kind: "tag", tag: read.tag });
172
+ at = read.next;
173
+ const name = read.tag.name.toLowerCase();
174
+ if (!read.tag.end && (RAW_TEXT.has(name) || ESCAPABLE_RAW_TEXT.has(name))) {
175
+ // Raw text runs to the element's own end tag, whatever looks like markup inside.
176
+ const closing = new RegExp(`</${name}(?=[\\t\\n\\f\\r />])`, "i").exec(html.slice(at));
177
+ const stop = closing === null ? html.length : at + closing.index;
178
+ parts.push({ kind: "raw", element: name, source: html.slice(at, stop) });
179
+ at = stop;
180
+ }
181
+ }
182
+ else {
183
+ at = open + 1;
184
+ }
185
+ }
186
+ return parts;
187
+ }
188
+ const outsideMarkup = (source) => [...source.matchAll(PLACEHOLDER)]
189
+ .map((match) => match[1])
190
+ .find((name) => !EMAIL_MARKUP_VALUES.includes(name));
191
+ /**
192
+ * Why an email's HTML is unsafe to send, or undefined: an element that runs code, embeds a page or
193
+ * posts a form; `<svg>`, `<math>` or `<plaintext>`; an event handler; a `<meta http-equiv>`; a
194
+ * value other than {@link EMAIL_MARKUP_VALUES} inside a tag, a comment or a `<style>`, or any value
195
+ * outside a quoted attribute value of a tag or right after `<`; a tag the HTML leaves unclosed; or
196
+ * an address that is not `https:`, `mailto:`, `tel:`, an anchor or the app's own `{{link}}`,
197
+ * `{{app.url}}` or `{{app.mcpUrl}}`. The platform applies the same rules to every deployed email
198
+ * before it sends one.
199
+ */
200
+ export function unsafeEmailHtml(html) {
201
+ // A value right after <, </, <! or <? would start a tag of its own.
202
+ const opening = /<[/!?]?\{\{/.exec(html);
203
+ if (opening !== null) {
204
+ return `${html.slice(opening.index, opening.index + 20)} lets a value start a tag`;
205
+ }
206
+ for (const part of partsOf(html)) {
207
+ if (part.kind === "unclosed") {
208
+ return `${part.source.slice(0, 60)} is a tag the HTML never closes`;
209
+ }
210
+ if (part.kind === "raw" || part.kind === "comment") {
211
+ const value = part.kind === "raw" && part.element === "title" ? undefined : outsideMarkup(part.source);
212
+ if (value !== undefined) {
213
+ return `{{${value}}} stands in ${part.kind === "raw" ? `a <${part.element}>` : "a comment"}; values go in text`;
214
+ }
215
+ continue;
216
+ }
217
+ const { tag } = part;
218
+ const tagName = tag.name.toLowerCase();
219
+ if (UNSAFE_ELEMENTS.has(tagName)) {
220
+ return `<${tagName}> runs code, embeds a page or posts a form`;
221
+ }
222
+ if (FOREIGN_ELEMENTS.has(tagName)) {
223
+ return `<${tagName}> is read by rules of its own, which hide markup from this check`;
224
+ }
225
+ // Even the values that may stand in a tag stand only inside a quoted attribute value.
226
+ if (tag.name.includes("{{") ||
227
+ tag.attributes.some(([attribute, content, quoted]) => attribute.includes("{{") || (!quoted && content.includes("{{")))) {
228
+ return `${tag.source.slice(0, 60)} has a {{value}} outside a quoted attribute value`;
229
+ }
230
+ const value = outsideMarkup(tag.source);
231
+ if (value !== undefined) {
232
+ return (`{{${value}}} stands in the tag ${tag.source.slice(0, 60)}; only ` +
233
+ `${EMAIL_MARKUP_VALUES.map((name) => `{{${name}}}`).join(", ")} may, and other values go in text`);
234
+ }
235
+ for (const [attribute, content] of tag.attributes) {
236
+ if (attribute.startsWith("on")) {
237
+ return `${attribute} runs code`;
238
+ }
239
+ if (tagName === "meta" && attribute === "http-equiv") {
240
+ return "<meta http-equiv> can redirect the reader";
241
+ }
242
+ if (URL_ATTRIBUTES.has(attribute) && !SAFE_URL.test(content)) {
243
+ return (`${attribute}="${content.slice(0, 60)}" is not an https:, mailto: or tel: address, an ` +
244
+ "anchor or {{link}}, {{app.url}} or {{app.mcpUrl}}");
245
+ }
246
+ }
247
+ }
248
+ return undefined;
249
+ }
package/dist/emails.d.ts CHANGED
@@ -1,14 +1,21 @@
1
1
  import type { Diagnostic } from "./diagnostics.js";
2
+ export { EMAIL_MARKUP_VALUES, unsafeEmailHtml } from "./email-html.js";
2
3
  /**
3
4
  * An email the workspace writes and the platform sends with a sign-in link, named by
4
- * `User.sendSignInLink` or by `signIn.invitationEmail`. Every field is plain text, in which
5
+ * `User.sendSignInLink` or by `signIn` as its invitation, sign-in link or sign-in code email
6
+ * (`invitationEmail`, `linkEmail`, `codeEmail`): either fields the platform lays out
7
+ * ({@link EmailLayout}) or a whole document of the workspace's own ({@link EmailDocument}).
8
+ */
9
+ export type EmailTemplate = EmailLayout | EmailDocument;
10
+ /**
11
+ * An email as fields the platform lays out in its neutral design. Every field is plain text, in which
5
12
  * `{{name}}` stands for a value the action passes, and `{{member.name}}`, `{{member.firstName}}`,
6
13
  * `{{workspace.name}}`, `{{app.url}}` and `{{app.mcpUrl}}` for the recipient, the workspace, the
7
14
  * app's address and its MCP server's. The platform lays the fields out, escapes them and adds the
8
15
  * plain-text part; `action` labels the one button, which signs the person in and opens the path
9
16
  * the action names. A field whose text is empty once filled in is left out.
10
17
  */
11
- export interface EmailTemplate {
18
+ export interface EmailLayout {
12
19
  readonly subject: string;
13
20
  /** A short line above the heading, such as "Review requested". */
14
21
  readonly eyebrow?: string;
@@ -34,6 +41,25 @@ export interface EmailTemplate {
34
41
  */
35
42
  readonly replyTo?: string;
36
43
  }
44
+ /**
45
+ * An email the workspace lays out entirely itself: its subject, its HTML and its plain-text part,
46
+ * with `{{value}}` placeholders the platform fills and nothing else of the platform's. The HTML
47
+ * links to `{{link}}`, the sign-in link, which is what the email is for; values are escaped in the
48
+ * HTML and kept as they are in the text. Inside its tags only `{{link}}`, `{{app.url}}`,
49
+ * `{{app.mcpUrl}}` and `{{workspace.name}}` may stand: every other value goes in text, so no value
50
+ * an action passes becomes an address or an attribute. The HTML may not run code or post forms,
51
+ * and it links only to `https:`, `mailto:` and `tel:` addresses, `#` anchors, or the app's own
52
+ * addresses.
53
+ */
54
+ export interface EmailDocument {
55
+ readonly subject: string;
56
+ readonly html: string;
57
+ readonly text: string;
58
+ /** As for {@link EmailLayout.replyTo}. */
59
+ readonly replyTo?: string;
60
+ }
61
+ /** Whether the workspace lays the email out itself. */
62
+ export declare function isEmailDocument(template: EmailTemplate): template is EmailDocument;
37
63
  /**
38
64
  * A box below an email's button: a title, a line of text, a value to copy shown large in a
39
65
  * monospace box, such as an address, labelled items with text or a command, and a closing note.
@@ -56,10 +82,13 @@ export interface EmailSectionItem {
56
82
  readonly code?: string;
57
83
  }
58
84
  /**
59
- * The values every email may use besides those the action passes: the recipient, the workspace,
60
- * the app's production address and its MCP server's address, `/mcp` on the same domain.
85
+ * The values every email may use besides those the action passes: the sign-in link the email is
86
+ * for, the recipient, the workspace, the app's production address and its MCP server's address,
87
+ * `/mcp` on the same domain.
61
88
  */
62
- export declare const BUILT_IN_EMAIL_VALUES: readonly ["member.name", "member.firstName", "workspace.name", "app.url", "app.mcpUrl"];
89
+ export declare const BUILT_IN_EMAIL_VALUES: readonly ["link", "member.name", "member.firstName", "workspace.name", "app.url", "app.mcpUrl"];
90
+ /** The value only the sign-in code email (`signIn.codeEmail`) has besides the built-in ones. */
91
+ export declare const SIGN_IN_CODE_VALUE = "code";
63
92
  /**
64
93
  * The query parameter of the callback a sign-in link is requested with, naming the queued email it
65
94
  * delivers. The platform reads it from Neon Auth's link and leaves it out of the path the person
@@ -78,6 +107,10 @@ export declare const MAX_EMAIL_PARAGRAPHS = 20;
78
107
  export declare const MAX_EMAIL_VALUES = 50;
79
108
  /** The longest path a sign-in link returns to. */
80
109
  export declare const MAX_RETURN_PATH = 1024;
110
+ /** The longest HTML of an email the workspace lays out itself, in characters. */
111
+ export declare const MAX_EMAIL_HTML = 100000;
112
+ /** The longest plain-text part of such an email, in characters. */
113
+ export declare const MAX_EMAIL_DOCUMENT_TEXT = 20000;
81
114
  /** The most sections of one email. */
82
115
  export declare const MAX_EMAIL_SECTIONS = 5;
83
116
  /** The most items of one section. */
@@ -98,4 +131,3 @@ export declare function appReturnPath(value: string): string | undefined;
98
131
  * round-trip.
99
132
  */
100
133
  export declare function emailOptions(value: unknown, report: Report, wireName: (name: string, path: string) => string | undefined): Readonly<Record<string, EmailTemplate>>;
101
- export {};
package/dist/emails.js CHANGED
@@ -1,15 +1,25 @@
1
1
  import { isRecord } from "./authoring-names.js";
2
+ import { unsafeEmailHtml } from "./email-html.js";
3
+ export { EMAIL_MARKUP_VALUES, unsafeEmailHtml } from "./email-html.js";
4
+ /** Whether the workspace lays the email out itself. */
5
+ export function isEmailDocument(template) {
6
+ return "html" in template;
7
+ }
2
8
  /**
3
- * The values every email may use besides those the action passes: the recipient, the workspace,
4
- * the app's production address and its MCP server's address, `/mcp` on the same domain.
9
+ * The values every email may use besides those the action passes: the sign-in link the email is
10
+ * for, the recipient, the workspace, the app's production address and its MCP server's address,
11
+ * `/mcp` on the same domain.
5
12
  */
6
13
  export const BUILT_IN_EMAIL_VALUES = [
14
+ "link",
7
15
  "member.name",
8
16
  "member.firstName",
9
17
  "workspace.name",
10
18
  "app.url",
11
19
  "app.mcpUrl",
12
20
  ];
21
+ /** The value only the sign-in code email (`signIn.codeEmail`) has besides the built-in ones. */
22
+ export const SIGN_IN_CODE_VALUE = "code";
13
23
  /**
14
24
  * The query parameter of the callback a sign-in link is requested with, naming the queued email it
15
25
  * delivers. The platform reads it from Neon Auth's link and leaves it out of the path the person
@@ -28,6 +38,10 @@ export const MAX_EMAIL_PARAGRAPHS = 20;
28
38
  export const MAX_EMAIL_VALUES = 50;
29
39
  /** The longest path a sign-in link returns to. */
30
40
  export const MAX_RETURN_PATH = 1024;
41
+ /** The longest HTML of an email the workspace lays out itself, in characters. */
42
+ export const MAX_EMAIL_HTML = 100_000;
43
+ /** The longest plain-text part of such an email, in characters. */
44
+ export const MAX_EMAIL_DOCUMENT_TEXT = 20_000;
31
45
  /** The most sections of one email. */
32
46
  export const MAX_EMAIL_SECTIONS = 5;
33
47
  /** The most items of one section. */
@@ -56,6 +70,13 @@ function isBuiltIn(name) {
56
70
  }
57
71
  /** Every text of an email, with the path of its field. */
58
72
  function emailTexts(template) {
73
+ if (isEmailDocument(template)) {
74
+ return [
75
+ ["subject", template.subject],
76
+ ["html", template.html],
77
+ ["text", template.text],
78
+ ];
79
+ }
59
80
  return [
60
81
  ["subject", template.subject],
61
82
  ...(template.eyebrow === undefined ? [] : [["eyebrow", template.eyebrow]]),
@@ -149,7 +170,55 @@ function checkText(text, path, limit, report) {
149
170
  }
150
171
  return valid;
151
172
  }
173
+ const DOCUMENT_FIELDS = ["subject", "html", "text", "replyTo"];
174
+ /** An email the workspace lays out itself, checked: its fields, their sizes, its HTML's safety. */
175
+ function emailDocument(value, path, report) {
176
+ let valid = true;
177
+ for (const key of Object.keys(value)) {
178
+ if (!DOCUMENT_FIELDS.includes(key)) {
179
+ report("invalid-email", `${path}.${key}`, `Unknown email field ${key}; an email with html has ${DOCUMENT_FIELDS.join(", ")}.`);
180
+ valid = false;
181
+ }
182
+ }
183
+ valid = checkText(value.subject, `${path}.subject`, MAX_EMAIL_SUBJECT, report) && valid;
184
+ valid = checkText(value.text, `${path}.text`, MAX_EMAIL_DOCUMENT_TEXT, report) && valid;
185
+ if (checkText(value.html, `${path}.html`, MAX_EMAIL_HTML, report)) {
186
+ const unsafe = unsafeEmailHtml(value.html);
187
+ if (unsafe !== undefined) {
188
+ report("invalid-email", `${path}.html`, `The HTML may not be sent: ${unsafe}.`);
189
+ valid = false;
190
+ }
191
+ if (!placeholders(value.html).includes("link")) {
192
+ report("invalid-email", `${path}.html`, 'The HTML links to {{link}}, the sign-in link the email is for, as in <a href="{{link}}">.');
193
+ valid = false;
194
+ }
195
+ }
196
+ else {
197
+ valid = false;
198
+ }
199
+ valid = checkReplyTo(value.replyTo, path, report) && valid;
200
+ if (!valid) {
201
+ return undefined;
202
+ }
203
+ return {
204
+ subject: value.subject,
205
+ html: value.html,
206
+ text: value.text,
207
+ ...(value.replyTo === undefined ? {} : { replyTo: value.replyTo }),
208
+ };
209
+ }
210
+ function checkReplyTo(replyTo, path, report) {
211
+ if (replyTo !== undefined &&
212
+ (typeof replyTo !== "string" || replyTo.length > 254 || !EMAIL_ADDRESS.test(replyTo))) {
213
+ report("invalid-email", `${path}.replyTo`, "replyTo is one email address, such as legal@example.com, without a name.");
214
+ return false;
215
+ }
216
+ return true;
217
+ }
152
218
  function emailTemplate(value, path, report) {
219
+ if (isRecord(value) && "html" in value) {
220
+ return emailDocument(value, path, report);
221
+ }
153
222
  if (!isRecord(value)) {
154
223
  report("invalid-email", path, "An email is { subject, heading, action, … } in plain text.");
155
224
  return undefined;
package/dist/index.d.ts CHANGED
@@ -50,7 +50,9 @@ export type { WebhookDelivery, WebhookSignatureScheme } from "./webhooks.js";
50
50
  export type { ActionEvent, ActionTrigger, AfterOptions, AnyActionHandle, AnyWorkflow, ChangedBounds, CronOptions, CronProblem, CronTrigger, TriggerFunction, TriggerRecord, WebhookOptions, WebhookSignature, WebhookVerification, WebhookTrigger, Workflow, WorkflowFunction, WorkflowOptions, WorkflowRunContext, WorkflowTrigger, } from "./workflow.js";
51
51
  export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_BOT_CHECK_SCHEMES, GUEST_CHANNELS, matchesWebsite, signUpOrigin, websiteOrigin, } from "./sign-in.js";
52
52
  export type { ChannelProvider, GuestBotCheck, GuestBotCheckScheme, GuestChannel, GuestOptions, ResolvedGuest, ResolvedSignInOptions, ResolvedSignUp, SignInCheck, SignInMethod, SignInOptions, SignInPolicy, SignUpChannel, SignUpOptions, } from "./sign-in.js";
53
- export type { EmailSection, EmailSectionItem, EmailTemplate } from "./emails.js";
53
+ export { SIGN_IN_CODE_VALUE } from "./emails.js";
54
+ export type { EmailDocument, EmailLayout, EmailSection, EmailSectionItem, EmailTemplate, } from "./emails.js";
55
+ export { EMAIL_MARKUP_VALUES, isEmailDocument, unsafeEmailHtml } from "./emails.js";
54
56
  export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
55
57
  export type { ActionRunOptions } from "./runtime.js";
56
58
  export type { BatchOptions, BatchRecordResult, BatchResult, BatchReturning, BatchSummaryResult, ChatProvenance, CreateManyInput, FieldCondition, OntologyRuntimeService, FindOptions, FreshMetricQueryOptions, GetOptions, Principal, RecordWhere, StoredRecord, StoredValues, UpsertResult, UpdateManyInput, UpsertManyInput, } from "./runtime.js";
@@ -62,8 +64,8 @@ export { ATTACHABLE_IDENTITY_PROVIDERS, UserIdentity, USER_IDENTITY_ORIGINS, } f
62
64
  export type { AttachableIdentityProvider, UserIdentityOrigin } from "./user-identity.js";
63
65
  export { AppFeedback, AppFeedbackFile, APP_FEEDBACK_ENTITIES, APP_FEEDBACK_FILE_MAX_BYTES, } from "./app-feedback.js";
64
66
  export { ChatDelivery, ChatPostInput, ChatPostResult } from "./chat.js";
65
- export { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME } from "./chat-channel.js";
66
- export type { ChatChannelKind } from "./chat-channel.js";
67
+ export { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME, CHAT_KINDS, WORKSPACE_CHANNEL_KIND, channelIdentityProvider, } from "./chat-channel.js";
68
+ export type { ChatChannelKind, ChatKind } from "./chat-channel.js";
67
69
  export type { ReviewSendInput, ReviewSendResult } from "./chat.js";
68
70
  export { DEFAULT_QUERY_LIMIT, entityQueryResultSchema, entityQuerySchema, entityQuerySchemas, entityRecordSchema, FILTER_OPERATORS, LIST_FILTER_OPERATORS, MANY_QUANTIFIERS, MAX_IN_VALUES, MAX_QUERY_LIMIT, OrderBy, Query, queryFields, queryJsonSchema, queryLinks, QueryResult, queryResultJsonSchema, queryResultSchema, SortDirection, WHERE_COMBINATORS, } from "./query.js";
69
71
  export type { EntityQuerySchemas, FieldFilter, FilterOperator, JsonRecord, ListFilterOperator, ManyFilter, QueryField, QueryLink, StorageType, Where, } from "./query.js";
package/dist/index.js CHANGED
@@ -29,6 +29,8 @@ export { MAX_WEBHOOK_BODY_BYTES, MAX_META_WEBHOOK_BODY_BYTES, MAX_WEBHOOK_HEADER
29
29
  export { CHANNEL_PROVIDERS, DEFAULT_SIGN_IN_POLICY, SIGN_IN_METHODS, SIGN_IN_POLICIES, SIGN_UP_CHANNELS, GUEST_BOT_CHECK_SCHEMES, GUEST_CHANNELS, matchesWebsite,
30
30
  // @legacy ontology.sign-up-origin-name
31
31
  signUpOrigin, websiteOrigin, } from "./sign-in.js";
32
+ export { SIGN_IN_CODE_VALUE } from "./emails.js";
33
+ export { EMAIL_MARKUP_VALUES, isEmailDocument, unsafeEmailHtml } from "./emails.js";
32
34
  export { OntologyActions, OntologyReads, OntologyRuntime, OntologyWrites } from "./runtime.js";
33
35
  export { User } from "./user.js";
34
36
  export { AgentChat } from "./agent-chat.js";
@@ -36,7 +38,7 @@ export { AgentReview, AGENT_REVIEW_MODES, AGENT_REVIEW_STATUSES, AGENT_REVIEW_TE
36
38
  export { ATTACHABLE_IDENTITY_PROVIDERS, UserIdentity, USER_IDENTITY_ORIGINS, } from "./user-identity.js";
37
39
  export { AppFeedback, AppFeedbackFile, APP_FEEDBACK_ENTITIES, APP_FEEDBACK_FILE_MAX_BYTES, } from "./app-feedback.js";
38
40
  export { ChatDelivery, ChatPostInput, ChatPostResult } from "./chat.js";
39
- export { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME } from "./chat-channel.js";
41
+ export { CHAT_CHANNEL_KINDS, CHAT_CHANNEL_NAME, CHAT_KINDS, WORKSPACE_CHANNEL_KIND, channelIdentityProvider, } from "./chat-channel.js";
40
42
  // The query language of `find` and of the service's list, query and traversal routes.
41
43
  export { DEFAULT_QUERY_LIMIT, entityQueryResultSchema, entityQuerySchema, entityQuerySchemas, entityRecordSchema, FILTER_OPERATORS, LIST_FILTER_OPERATORS, MANY_QUANTIFIERS, MAX_IN_VALUES, MAX_QUERY_LIMIT, OrderBy, Query, queryFields, queryJsonSchema, queryLinks, QueryResult, queryResultJsonSchema, queryResultSchema, SortDirection, WHERE_COMBINATORS, } from "./query.js";
42
44
  // The SQL runtime: data access, the action pipeline, generated actions, history and principals.