@plitzi/sdk-shared 0.35.4 → 0.35.5

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,11 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.35.5
4
+
5
+ ### Patch Changes
6
+
7
+ - v0.35.5
8
+
3
9
  ## 0.35.4
4
10
 
5
11
  ### Patch Changes
@@ -2,5 +2,7 @@ export { cronMatches, isKnownTimeZone, parseCron, zonedClock } from './cron';
2
2
  export { triggerAccess, triggerCacheMs, triggerHasStaleVerify, triggerInput, triggerVerify } from './triggerParams';
3
3
  export { actionName, actionTriggers, isActionEnabled } from './triggers';
4
4
  export { validateActionDocument } from './validateDocument';
5
+ export { isSingleEmailAddress, readSmtpCredential, SMTP_CREDENTIAL_KEYS } from './smtp';
5
6
  export type { CronExpression } from './cron';
7
+ export type { SmtpCredentialProblem, SmtpCredentialReading, SmtpSecurity, SmtpSettings } from './smtp';
6
8
  export type { ActionDocumentIssue, ActionDocumentReport } from './validateDocument';
@@ -2,4 +2,5 @@ import { cronMatches as e, isKnownTimeZone as t, parseCron as n, zonedClock as r
2
2
  import { triggerAccess as i, triggerCacheMs as a, triggerHasStaleVerify as o, triggerInput as s, triggerVerify as c } from "./triggerParams.mjs";
3
3
  import { actionName as l, actionTriggers as u, isActionEnabled as d } from "./triggers.mjs";
4
4
  import { validateActionDocument as f } from "./validateDocument.mjs";
5
- export { l as actionName, u as actionTriggers, e as cronMatches, d as isActionEnabled, t as isKnownTimeZone, n as parseCron, i as triggerAccess, a as triggerCacheMs, o as triggerHasStaleVerify, s as triggerInput, c as triggerVerify, f as validateActionDocument, r as zonedClock };
5
+ import { SMTP_CREDENTIAL_KEYS as p, isSingleEmailAddress as m, readSmtpCredential as h } from "./smtp.mjs";
6
+ export { p as SMTP_CREDENTIAL_KEYS, l as actionName, u as actionTriggers, e as cronMatches, d as isActionEnabled, t as isKnownTimeZone, m as isSingleEmailAddress, n as parseCron, h as readSmtpCredential, i as triggerAccess, a as triggerCacheMs, o as triggerHasStaleVerify, s as triggerInput, c as triggerVerify, f as validateActionDocument, r as zonedClock };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The SMTP server a space sends its flows' mail through, as its credential stores it — one rule for everybody who
3
+ * reads one: the editor saving it, the API accepting it, the check reporting on it and the `email.send` task using it.
4
+ *
5
+ * A credential is a bag of strings, so every value arrives as text and is judged here: a port that is not a port, a
6
+ * sender that is not one address, a password with no user to go with it. Each problem names the key it is about, so a
7
+ * form can put the sentence under the field.
8
+ */
9
+ export type SmtpSecurity = 'tls' | 'starttls' | 'none';
10
+ export type SmtpSettings = {
11
+ host: string;
12
+ port: number;
13
+ /** `tls` connects encrypted (usually 465); `starttls` upgrades a plain connection (usually 587); `none` never does. */
14
+ security: SmtpSecurity;
15
+ /** Empty with an empty password: a relay that authenticates by where the connection comes from. */
16
+ username: string;
17
+ password: string;
18
+ fromEmail: string;
19
+ fromName: string;
20
+ };
21
+ export type SmtpCredentialProblem = {
22
+ key: keyof SmtpSettings;
23
+ message: string;
24
+ };
25
+ export type SmtpCredentialReading = {
26
+ settings: SmtpSettings;
27
+ problems: [];
28
+ } | {
29
+ problems: SmtpCredentialProblem[];
30
+ };
31
+ /** The keys an SMTP credential holds, in the order an editor asks for them. */
32
+ export declare const SMTP_CREDENTIAL_KEYS: readonly (keyof SmtpSettings)[];
33
+ export declare const isSingleEmailAddress: (value: string) => boolean;
34
+ export declare const readSmtpCredential: (data: Record<string, unknown>) => SmtpCredentialReading;
@@ -0,0 +1,51 @@
1
+ //#region src/actions/smtp.ts
2
+ var e = [
3
+ "host",
4
+ "port",
5
+ "security",
6
+ "username",
7
+ "password",
8
+ "fromEmail",
9
+ "fromName"
10
+ ], t = [
11
+ "tls",
12
+ "starttls",
13
+ "none"
14
+ ], n = /^[A-Za-z0-9](?:[A-Za-z0-9.-]{0,251}[A-Za-z0-9])?$/, r = /^[^\s@,;<>"]+@[^\s@,;<>"]+\.[^\s@,;<>"]+$/, i = (e) => r.test(e), a = (e) => t.some((t) => t === e), o = (e, t) => {
15
+ let n = e[t];
16
+ return typeof n == "number" ? String(n) : typeof n == "string" ? n.trim() : "";
17
+ }, s = (e) => {
18
+ let t = o(e, "host"), r = Number(o(e, "port")), s = o(e, "security"), c = o(e, "username"), l = typeof e.password == "string" ? e.password : "", u = o(e, "fromEmail"), d = o(e, "fromName"), f = [];
19
+ return n.test(t) || f.push({
20
+ key: "host",
21
+ message: "A host name like smtp.example.com, with no scheme and no port"
22
+ }), (!Number.isInteger(r) || r < 1 || r > 65535) && f.push({
23
+ key: "port",
24
+ message: "A port number, usually 587 or 465"
25
+ }), a(s) || f.push({
26
+ key: "security",
27
+ message: "One of tls, starttls or none"
28
+ }), l !== "" && c === "" && f.push({
29
+ key: "username",
30
+ message: "A password needs the user it belongs to"
31
+ }), i(u) || f.push({
32
+ key: "fromEmail",
33
+ message: "The one address this server sends as"
34
+ }), (/[\r\n]/.test(d) || d.length > 100) && f.push({
35
+ key: "fromName",
36
+ message: "One line of at most 100 characters"
37
+ }), f.length > 0 || !a(s) ? { problems: f } : {
38
+ settings: {
39
+ host: t,
40
+ port: r,
41
+ security: s,
42
+ username: c,
43
+ password: l,
44
+ fromEmail: u,
45
+ fromName: d
46
+ },
47
+ problems: []
48
+ };
49
+ };
50
+ //#endregion
51
+ export { e as SMTP_CREDENTIAL_KEYS, i as isSingleEmailAddress, s as readSmtpCredential };
@@ -93,19 +93,19 @@ export declare const spaceEventSchemas: {
93
93
  selector: z.ZodString;
94
94
  path: z.ZodOptional<z.ZodCustom<StyleCategory, StyleCategory>>;
95
95
  type: z.ZodEnum<{
96
+ id: "id";
96
97
  class: "class";
97
98
  element: "element";
98
- id: "id";
99
99
  }>;
100
100
  style: z.ZodOptional<z.ZodCustom<import('..').StyleAttributes, import('..').StyleAttributes>>;
101
101
  params: z.ZodObject<{
102
102
  componentType: z.ZodOptional<z.ZodString>;
103
103
  styleSelector: z.ZodOptional<z.ZodString>;
104
104
  styleState: z.ZodOptional<z.ZodEnum<{
105
- disabled: "disabled";
106
105
  hover: "hover";
107
106
  active: "active";
108
107
  focus: "focus";
108
+ disabled: "disabled";
109
109
  checked: "checked";
110
110
  visited: "visited";
111
111
  }>>;
@@ -124,10 +124,10 @@ export declare const spaceEventSchemas: {
124
124
  params: z.ZodObject<{
125
125
  componentType: z.ZodOptional<z.ZodString>;
126
126
  styleState: z.ZodOptional<z.ZodEnum<{
127
- disabled: "disabled";
128
127
  hover: "hover";
129
128
  active: "active";
130
129
  focus: "focus";
130
+ disabled: "disabled";
131
131
  checked: "checked";
132
132
  visited: "visited";
133
133
  }>>;
@@ -281,9 +281,9 @@ export declare const spaceEventSchemas: {
281
281
  }>;
282
282
  selector: z.ZodString;
283
283
  type: z.ZodEnum<{
284
+ id: "id";
284
285
  class: "class";
285
286
  element: "element";
286
- id: "id";
287
287
  }>;
288
288
  path: z.ZodOptional<z.ZodCustom<StyleCategory, StyleCategory>>;
289
289
  style: z.ZodOptional<z.ZodCustom<import('..').StyleAttributes, import('..').StyleAttributes>>;
@@ -291,10 +291,10 @@ export declare const spaceEventSchemas: {
291
291
  componentType: z.ZodOptional<z.ZodString>;
292
292
  styleSelector: z.ZodOptional<z.ZodString>;
293
293
  styleState: z.ZodOptional<z.ZodEnum<{
294
- disabled: "disabled";
295
294
  hover: "hover";
296
295
  active: "active";
297
296
  focus: "focus";
297
+ disabled: "disabled";
298
298
  checked: "checked";
299
299
  visited: "visited";
300
300
  }>>;
@@ -314,10 +314,10 @@ export declare const spaceEventSchemas: {
314
314
  params: z.ZodObject<{
315
315
  componentType: z.ZodOptional<z.ZodString>;
316
316
  styleState: z.ZodOptional<z.ZodEnum<{
317
- disabled: "disabled";
318
317
  hover: "hover";
319
318
  active: "active";
320
319
  focus: "focus";
320
+ disabled: "disabled";
321
321
  checked: "checked";
322
322
  visited: "visited";
323
323
  }>>;