@vectoriox/iox-ui 5.130.1 → 5.131.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.
@@ -0,0 +1,188 @@
1
+ /**
2
+ * IOX Mail's words (iox-mail-plan ML1/ML2). ONE spelling for the relay (iox-control-plane), the studio (iox-cms) and
3
+ * the admin — none of them re-spells a value.
4
+ */
5
+ /** Set by the sender, never guessed (iox-mail-plan §2): reminders are marketing, everything else transactional. */
6
+ var MailKind;
7
+ (function (MailKind) {
8
+ MailKind["Transactional"] = "transactional";
9
+ MailKind["Marketing"] = "marketing";
10
+ })(MailKind || (MailKind = {}));
11
+ /** How a studio's mail goes (ML-D9): IOX's relay, or the studio's own Mailjet keys. */
12
+ var MailMode;
13
+ (function (MailMode) {
14
+ MailMode["Iox"] = "iox";
15
+ MailMode["Own"] = "own";
16
+ })(MailMode || (MailMode = {}));
17
+ /**
18
+ * Every place a studio sends mail from (iox-mail-plan §1: the seven senders). A message names its sender; its kind,
19
+ * and anything else that follows from who sent it, is read from the tables below — never decided at the call site.
20
+ */
21
+ var MailSender;
22
+ (function (MailSender) {
23
+ /** a team invite (users) */
24
+ MailSender["Invite"] = "invite";
25
+ /** "Forgot it?" — a team member's reset link */
26
+ MailSender["PasswordReset"] = "password-reset";
27
+ /** a buyer's sign-in code (commerce E3) */
28
+ MailSender["SignInCode"] = "sign-in-code";
29
+ /** an order email — confirmation, payment, shipping (commerce E1/E2) */
30
+ MailSender["Order"] = "order";
31
+ /** a checkout recovery reminder (commerce E4) */
32
+ MailSender["Reminder"] = "reminder";
33
+ /** a form's "email me" delivery to the owner */
34
+ MailSender["FormDelivery"] = "form-delivery";
35
+ /** the `sendEmail` element action — to the author's fixed address */
36
+ MailSender["SendEmailAction"] = "send-email-action";
37
+ })(MailSender || (MailSender = {}));
38
+ /** ONE table: what kind of mail each sender sends (R-ML1). Only reminders are marketing. */
39
+ const MAIL_KIND_OF_SENDER = {
40
+ [MailSender.Invite]: MailKind.Transactional,
41
+ [MailSender.PasswordReset]: MailKind.Transactional,
42
+ [MailSender.SignInCode]: MailKind.Transactional,
43
+ [MailSender.Order]: MailKind.Transactional,
44
+ [MailSender.Reminder]: MailKind.Marketing,
45
+ [MailSender.FormDelivery]: MailKind.Transactional,
46
+ [MailSender.SendEmailAction]: MailKind.Transactional,
47
+ };
48
+ function mailKindOf(sender) {
49
+ return MAIL_KIND_OF_SENDER[sender];
50
+ }
51
+ /** What became of one relayed message. */
52
+ var MailResultStatus;
53
+ (function (MailResultStatus) {
54
+ MailResultStatus["Sent"] = "sent";
55
+ MailResultStatus["Refused"] = "refused";
56
+ })(MailResultStatus || (MailResultStatus = {}));
57
+ /** Why a message was not sent — iox-cms records the reason and says it to the owner (R-ML4). */
58
+ var MailRefusal;
59
+ (function (MailRefusal) {
60
+ /** the message itself is malformed (`detail` names the field) */
61
+ MailRefusal["Invalid"] = "invalid";
62
+ /** it asked a From that is not the studio's IOX address for its stream, nor its own verified domain (R-ML3) */
63
+ MailRefusal["From"] = "from";
64
+ /** the address bounced hard, complained, or unsubscribed from this studio's marketing (R-ML5) */
65
+ MailRefusal["Suppressed"] = "suppressed";
66
+ /** this studio's marketing is paused — too many complaints or hard bounces, or the operator (ML-D7) */
67
+ MailRefusal["Paused"] = "paused";
68
+ /** marketing past 100% of the month's emails (ML-D5) */
69
+ MailRefusal["Quota"] = "quota";
70
+ /** transactional past twice the month's emails — the abuse ceiling (ML-D5) */
71
+ MailRefusal["Ceiling"] = "ceiling";
72
+ /** the same message id is being sent by another call right now — retry later */
73
+ MailRefusal["InProgress"] = "in-progress";
74
+ /** Mailjet refused this message (an address it will not take, a field it rejects) — not retried */
75
+ MailRefusal["Rejected"] = "rejected";
76
+ /** Mailjet could not be reached or failed — nothing was sent and nothing counted; retry */
77
+ MailRefusal["Upstream"] = "upstream";
78
+ })(MailRefusal || (MailRefusal = {}));
79
+ /** The refusals worth retrying later as they are. */
80
+ const RETRYABLE_REFUSALS = new Set([MailRefusal.InProgress, MailRefusal.Upstream]);
81
+ function isRetryableRefusal(reason) {
82
+ return RETRYABLE_REFUSALS.has(reason);
83
+ }
84
+ /** A whole call the relay cannot take (the HTTP answer carries it as `code`). */
85
+ var MailRelayCode;
86
+ (function (MailRelayCode) {
87
+ /** no Mailjet key in the control plane yet (ML0) — 503 */
88
+ MailRelayCode["NotConfigured"] = "not-configured";
89
+ /** the studio's plan has no IOX mail — 403 */
90
+ MailRelayCode["NotEnabled"] = "not-enabled";
91
+ })(MailRelayCode || (MailRelayCode = {}));
92
+ /** Which of a studio's streams a suppression closes. */
93
+ var MailStream;
94
+ (function (MailStream) {
95
+ MailStream["All"] = "all";
96
+ MailStream["Marketing"] = "marketing";
97
+ })(MailStream || (MailStream = {}));
98
+ /** Why an address is suppressed for a studio (ML-D7). */
99
+ var SuppressionReason;
100
+ (function (SuppressionReason) {
101
+ SuppressionReason["HardBounce"] = "hard_bounce";
102
+ SuppressionReason["Spam"] = "spam";
103
+ SuppressionReason["Unsubscribed"] = "unsubscribed";
104
+ })(SuppressionReason || (SuppressionReason = {}));
105
+ /** Why a studio's marketing is paused. */
106
+ var MarketingPauseReason;
107
+ (function (MarketingPauseReason) {
108
+ MarketingPauseReason["Complaints"] = "complaints";
109
+ MarketingPauseReason["Bounces"] = "bounces";
110
+ MarketingPauseReason["Operator"] = "operator";
111
+ })(MarketingPauseReason || (MarketingPauseReason = {}));
112
+ /** What the relay says about the studio's sender (ML-D10 reads it). */
113
+ var MailSenderState;
114
+ (function (MailSenderState) {
115
+ /** the platform key is set and the plan has IOX mail — IOX's verified domains send */
116
+ MailSenderState["Ready"] = "ready";
117
+ MailSenderState["NotConfigured"] = "not-configured";
118
+ MailSenderState["NotEnabled"] = "not-enabled";
119
+ })(MailSenderState || (MailSenderState = {}));
120
+
121
+ /**
122
+ * The relay's wire (iox-control-plane `src/mail/`, its `openapi.json` tag `instances`). The studio calls back with its
123
+ * instance token: `Authorization: Bearer <INSTANCE_TOKEN>`.
124
+ */
125
+ const RELAY_MAIL_PATH = '/instances/me/mail';
126
+ const RELAY_MAIL_USAGE_PATH = '/instances/me/mail/usage';
127
+ /** At most this many messages a call. */
128
+ const RELAY_MAX_MESSAGES = 50;
129
+ /** RFC 8058 one-click unsubscribe — the only headers a relayed message may carry. */
130
+ const RELAY_ALLOWED_HEADERS = ['List-Unsubscribe', 'List-Unsubscribe-Post'];
131
+
132
+ /** The studio's own Mailjet keys — the three an own mailer needs (the MAILER connector's `requiredKeys`, ML-D9). */
133
+ const OWN_MAILER_KEYS = ['publicKey', 'secretKey', 'originatorEmail'];
134
+ /** Where one org's mail goes now. */
135
+ var MailRoute;
136
+ (function (MailRoute) {
137
+ /** its own active mailer row — ML-D8: own wins */
138
+ MailRoute["Own"] = "own";
139
+ /** IOX's relay */
140
+ MailRoute["Iox"] = "iox";
141
+ /** nowhere: no usable own row and no IOX mail in the plan */
142
+ MailRoute["None"] = "none";
143
+ })(MailRoute || (MailRoute = {}));
144
+ const filled = (value) => typeof value === 'string' && value.trim().length > 0;
145
+ /** True when the row holds every key an own mailer needs. */
146
+ function hasOwnMailerKeys(row) {
147
+ return !!row && OWN_MAILER_KEYS.every((key) => filled(row[key]));
148
+ }
149
+ /**
150
+ * A row's mode (ML-D9): the one it names; a row that names none is `own` when it holds its keys (every row stored
151
+ * before IOX mail — its owner brought Mailjet), else `iox`. No row at all is `iox`.
152
+ */
153
+ function mailModeOf(row) {
154
+ const asked = typeof row?.mode === 'string' ? row.mode.trim().toLowerCase() : '';
155
+ if (asked === MailMode.Own || asked === MailMode.Iox)
156
+ return asked;
157
+ return hasOwnMailerKeys(row) ? MailMode.Own : MailMode.Iox;
158
+ }
159
+ /** The keys a row needs to count as configured: its own keys in own mode, none in IOX mode (E1). */
160
+ function requiredMailerKeys(row) {
161
+ return mailModeOf(row) === MailMode.Own ? [...OWN_MAILER_KEYS] : [];
162
+ }
163
+ /**
164
+ * THE route rule (ML-D8, R-ML1): an active row in own mode with its keys sends as today; anything else — no row, a row
165
+ * turned off, a row set to IOX, a row still missing a key — goes through IOX mail when the plan has it, else nowhere.
166
+ */
167
+ function planMailRoute(facts) {
168
+ const row = facts.activeRow;
169
+ if (row && mailModeOf(row) === MailMode.Own && hasOwnMailerKeys(row))
170
+ return MailRoute.Own;
171
+ return facts.ioxMail ? MailRoute.Iox : MailRoute.None;
172
+ }
173
+
174
+ /**
175
+ * @vectoriox/iox-ui/mail-core — IOX Mail's shared, FRAMEWORK-FREE vocabulary (iox-mail-plan ML2): a message's kind,
176
+ * who sends it, the relay's wire (`POST /instances/me/mail`, its usage) and refusals, and the ONE route rule — the
177
+ * studio's own active mailer wins, else IOX mail when the plan has it. The control plane (the relay), iox-cms (the
178
+ * transport and the MAILER connector) and the admin (Settings ▸ Email, ML3) speak it. It imports nothing.
179
+ * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets, jest
180
+ * moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.
181
+ */
182
+
183
+ /**
184
+ * Generated bundle index. Do not edit.
185
+ */
186
+
187
+ export { MAIL_KIND_OF_SENDER, MailKind, MailMode, MailRefusal, MailRelayCode, MailResultStatus, MailRoute, MailSender, MailSenderState, MailStream, MarketingPauseReason, OWN_MAILER_KEYS, RELAY_ALLOWED_HEADERS, RELAY_MAIL_PATH, RELAY_MAIL_USAGE_PATH, RELAY_MAX_MESSAGES, RETRYABLE_REFUSALS, SuppressionReason, hasOwnMailerKeys, isRetryableRefusal, mailKindOf, mailModeOf, planMailRoute, requiredMailerKeys };
188
+ //# sourceMappingURL=vectoriox-iox-ui-mail-core.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vectoriox-iox-ui-mail-core.mjs","sources":["../../../projects/iox-ui/src/mail-core/mail-vocabulary.ts","../../../projects/iox-ui/src/mail-core/mail-wire.ts","../../../projects/iox-ui/src/mail-core/mail-route.ts","../../../projects/iox-ui/src/mail-core/public-api.ts","../../../projects/iox-ui/src/mail-core/vectoriox-iox-ui-mail-core.ts"],"sourcesContent":["/**\n * IOX Mail's words (iox-mail-plan ML1/ML2). ONE spelling for the relay (iox-control-plane), the studio (iox-cms) and\n * the admin — none of them re-spells a value.\n */\n\n/** Set by the sender, never guessed (iox-mail-plan §2): reminders are marketing, everything else transactional. */\nexport enum MailKind {\n Transactional = 'transactional',\n Marketing = 'marketing',\n}\n\n/** How a studio's mail goes (ML-D9): IOX's relay, or the studio's own Mailjet keys. */\nexport enum MailMode {\n Iox = 'iox',\n Own = 'own',\n}\n\n/**\n * Every place a studio sends mail from (iox-mail-plan §1: the seven senders). A message names its sender; its kind,\n * and anything else that follows from who sent it, is read from the tables below — never decided at the call site.\n */\nexport enum MailSender {\n /** a team invite (users) */\n Invite = 'invite',\n /** \"Forgot it?\" — a team member's reset link */\n PasswordReset = 'password-reset',\n /** a buyer's sign-in code (commerce E3) */\n SignInCode = 'sign-in-code',\n /** an order email — confirmation, payment, shipping (commerce E1/E2) */\n Order = 'order',\n /** a checkout recovery reminder (commerce E4) */\n Reminder = 'reminder',\n /** a form's \"email me\" delivery to the owner */\n FormDelivery = 'form-delivery',\n /** the `sendEmail` element action — to the author's fixed address */\n SendEmailAction = 'send-email-action',\n}\n\n/** ONE table: what kind of mail each sender sends (R-ML1). Only reminders are marketing. */\nexport const MAIL_KIND_OF_SENDER: Readonly<Record<MailSender, MailKind>> = {\n [MailSender.Invite]: MailKind.Transactional,\n [MailSender.PasswordReset]: MailKind.Transactional,\n [MailSender.SignInCode]: MailKind.Transactional,\n [MailSender.Order]: MailKind.Transactional,\n [MailSender.Reminder]: MailKind.Marketing,\n [MailSender.FormDelivery]: MailKind.Transactional,\n [MailSender.SendEmailAction]: MailKind.Transactional,\n};\n\nexport function mailKindOf(sender: MailSender): MailKind {\n return MAIL_KIND_OF_SENDER[sender];\n}\n\n/** What became of one relayed message. */\nexport enum MailResultStatus {\n Sent = 'sent',\n Refused = 'refused',\n}\n\n/** Why a message was not sent — iox-cms records the reason and says it to the owner (R-ML4). */\nexport enum MailRefusal {\n /** the message itself is malformed (`detail` names the field) */\n Invalid = 'invalid',\n /** it asked a From that is not the studio's IOX address for its stream, nor its own verified domain (R-ML3) */\n From = 'from',\n /** the address bounced hard, complained, or unsubscribed from this studio's marketing (R-ML5) */\n Suppressed = 'suppressed',\n /** this studio's marketing is paused — too many complaints or hard bounces, or the operator (ML-D7) */\n Paused = 'paused',\n /** marketing past 100% of the month's emails (ML-D5) */\n Quota = 'quota',\n /** transactional past twice the month's emails — the abuse ceiling (ML-D5) */\n Ceiling = 'ceiling',\n /** the same message id is being sent by another call right now — retry later */\n InProgress = 'in-progress',\n /** Mailjet refused this message (an address it will not take, a field it rejects) — not retried */\n Rejected = 'rejected',\n /** Mailjet could not be reached or failed — nothing was sent and nothing counted; retry */\n Upstream = 'upstream',\n}\n\n/** The refusals worth retrying later as they are. */\nexport const RETRYABLE_REFUSALS: ReadonlySet<MailRefusal> = new Set([MailRefusal.InProgress, MailRefusal.Upstream]);\n\nexport function isRetryableRefusal(reason: MailRefusal | string | null | undefined): boolean {\n return RETRYABLE_REFUSALS.has(reason as MailRefusal);\n}\n\n/** A whole call the relay cannot take (the HTTP answer carries it as `code`). */\nexport enum MailRelayCode {\n /** no Mailjet key in the control plane yet (ML0) — 503 */\n NotConfigured = 'not-configured',\n /** the studio's plan has no IOX mail — 403 */\n NotEnabled = 'not-enabled',\n}\n\n/** Which of a studio's streams a suppression closes. */\nexport enum MailStream {\n All = 'all',\n Marketing = 'marketing',\n}\n\n/** Why an address is suppressed for a studio (ML-D7). */\nexport enum SuppressionReason {\n HardBounce = 'hard_bounce',\n Spam = 'spam',\n Unsubscribed = 'unsubscribed',\n}\n\n/** Why a studio's marketing is paused. */\nexport enum MarketingPauseReason {\n Complaints = 'complaints',\n Bounces = 'bounces',\n Operator = 'operator',\n}\n\n/** What the relay says about the studio's sender (ML-D10 reads it). */\nexport enum MailSenderState {\n /** the platform key is set and the plan has IOX mail — IOX's verified domains send */\n Ready = 'ready',\n NotConfigured = 'not-configured',\n NotEnabled = 'not-enabled',\n}\n","import { MailKind, MailRefusal, MailResultStatus, MailSenderState, MarketingPauseReason } from './mail-vocabulary';\n\n/**\n * The relay's wire (iox-control-plane `src/mail/`, its `openapi.json` tag `instances`). The studio calls back with its\n * instance token: `Authorization: Bearer <INSTANCE_TOKEN>`.\n */\nexport const RELAY_MAIL_PATH = '/instances/me/mail';\nexport const RELAY_MAIL_USAGE_PATH = '/instances/me/mail/usage';\n\n/** At most this many messages a call. */\nexport const RELAY_MAX_MESSAGES = 50;\n\n/** RFC 8058 one-click unsubscribe — the only headers a relayed message may carry. */\nexport const RELAY_ALLOWED_HEADERS: readonly string[] = ['List-Unsubscribe', 'List-Unsubscribe-Post'];\n\nexport interface RelayAddress {\n email: string;\n name?: string;\n}\n\n/** One message as the studio asks it to be sent. ONE recipient a message. */\nexport interface RelayMessage {\n /** the studio's message id (its outbox row) — the relay sends one id at most once */\n id: string;\n kind: MailKind;\n to: RelayAddress;\n subject: string;\n text?: string;\n html?: string;\n /** absent = the studio's owner */\n replyTo?: RelayAddress;\n /** the From it expects — absent = the studio's stamped address */\n from?: string;\n /** the organization's name — the From's display name (else the studio's label) */\n fromName?: string;\n headers?: Record<string, string>;\n}\n\nexport interface RelayRequest {\n messages: RelayMessage[];\n}\n\nexport interface RelayResult {\n id: string;\n status: MailResultStatus;\n reason: MailRefusal | null;\n retryable: boolean;\n /** the field a malformed message got wrong, or Mailjet's words for a message it refused */\n detail: string | null;\n /** true when this id was already sent by an earlier call — nothing was sent twice */\n duplicate: boolean;\n messageUuid: string | null;\n}\n\n/** This month's counts — what the quota counts is `total`, both kinds. */\nexport interface RelayMonth {\n total: number;\n transactional: number;\n marketing: number;\n /** refusals this month by reason */\n refused: Partial<Record<MailRefusal | string, number>>;\n hardBounced: number;\n softBounced: number;\n blocked: number;\n complained: number;\n unsubscribed: number;\n}\n\n/** `GET /instances/me/mail/usage` (and every send's `usage`). Dates are ISO strings on the wire. */\nexport interface RelayUsage {\n /** the plan has IOX mail (`ioxMail`) */\n enabled: boolean;\n /** the control plane holds a Mailjet key */\n configured: boolean;\n senderState: MailSenderState;\n transactionalFrom: { email: string; name: string };\n marketingFrom: { email: string; name: string };\n defaultReplyTo: string;\n periodStart: string;\n periodEnd: string;\n /** `emailsPerMonth`; null = unlimited */\n quota: number | null;\n /** where transactional stops (2× the quota); null = unlimited */\n ceiling: number | null;\n month: RelayMonth;\n suppressions: number;\n marketingPaused: { at: string; reason: MarketingPauseReason | string } | null;\n}\n\nexport interface RelayResponse {\n results: RelayResult[];\n usage: RelayUsage;\n}\n","import { MailMode } from './mail-vocabulary';\n\n/** The studio's own Mailjet keys — the three an own mailer needs (the MAILER connector's `requiredKeys`, ML-D9). */\nexport const OWN_MAILER_KEYS: readonly string[] = ['publicKey', 'secretKey', 'originatorEmail'];\n\n/** Where one org's mail goes now. */\nexport enum MailRoute {\n /** its own active mailer row — ML-D8: own wins */\n Own = 'own',\n /** IOX's relay */\n Iox = 'iox',\n /** nowhere: no usable own row and no IOX mail in the plan */\n None = 'none',\n}\n\n/** A mailer row's settings, as the route reads them (decrypted; only presence is read). */\nexport interface MailerRowLike {\n mode?: unknown;\n publicKey?: unknown;\n secretKey?: unknown;\n originatorEmail?: unknown;\n}\n\nconst filled = (value: unknown): boolean => typeof value === 'string' && value.trim().length > 0;\n\n/** True when the row holds every key an own mailer needs. */\nexport function hasOwnMailerKeys(row: MailerRowLike | null | undefined): boolean {\n return !!row && OWN_MAILER_KEYS.every((key) => filled((row as Record<string, unknown>)[key]));\n}\n\n/**\n * A row's mode (ML-D9): the one it names; a row that names none is `own` when it holds its keys (every row stored\n * before IOX mail — its owner brought Mailjet), else `iox`. No row at all is `iox`.\n */\nexport function mailModeOf(row: MailerRowLike | null | undefined): MailMode {\n const asked = typeof row?.mode === 'string' ? row.mode.trim().toLowerCase() : '';\n if (asked === MailMode.Own || asked === MailMode.Iox) return asked as MailMode;\n return hasOwnMailerKeys(row) ? MailMode.Own : MailMode.Iox;\n}\n\n/** The keys a row needs to count as configured: its own keys in own mode, none in IOX mode (E1). */\nexport function requiredMailerKeys(row: MailerRowLike | null | undefined): string[] {\n return mailModeOf(row) === MailMode.Own ? [...OWN_MAILER_KEYS] : [];\n}\n\nexport interface MailRouteFacts {\n /** the org's ACTIVE mailer row, decrypted — null when it has none (or none is on) */\n activeRow: MailerRowLike | null;\n /** the plan has IOX mail (`features.ioxMail`) */\n ioxMail: boolean;\n}\n\n/**\n * THE route rule (ML-D8, R-ML1): an active row in own mode with its keys sends as today; anything else — no row, a row\n * turned off, a row set to IOX, a row still missing a key — goes through IOX mail when the plan has it, else nowhere.\n */\nexport function planMailRoute(facts: MailRouteFacts): MailRoute {\n const row = facts.activeRow;\n if (row && mailModeOf(row) === MailMode.Own && hasOwnMailerKeys(row)) return MailRoute.Own;\n return facts.ioxMail ? MailRoute.Iox : MailRoute.None;\n}\n","/**\n * @vectoriox/iox-ui/mail-core — IOX Mail's shared, FRAMEWORK-FREE vocabulary (iox-mail-plan ML2): a message's kind,\n * who sends it, the relay's wire (`POST /instances/me/mail`, its usage) and refusals, and the ONE route rule — the\n * studio's own active mailer wins, else IOX mail when the plan has it. The control plane (the relay), iox-cms (the\n * transport and the MAILER connector) and the admin (Settings ▸ Email, ML3) speak it. It imports nothing.\n * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets, jest\n * moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.\n */\nexport * from './mail-vocabulary';\nexport * from './mail-wire';\nexport * from './mail-route';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":"AAAA;;;AAGG;AAEH;IACY;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAChB,IAAA,QAAA,CAAA,eAAA,CAAA,GAAA,eAA+B;AAC/B,IAAA,QAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AAC3B,CAAC,EAHW,QAAQ,KAAR,QAAQ,GAAA,E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AC,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC;QAAE,OAAO,SAAS,CAAC,GAAG;AAC1F,IAAA,OAAO,KAAK,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,GAAG,SAAS,CAAC,IAAI;AACzD;;AC5DA;;;;;;;AAOG;;ACPH;;AAEG;;;;"}
@@ -0,0 +1,231 @@
1
+ /**
2
+ * IOX Mail's words (iox-mail-plan ML1/ML2). ONE spelling for the relay (iox-control-plane), the studio (iox-cms) and
3
+ * the admin — none of them re-spells a value.
4
+ */
5
+ /** Set by the sender, never guessed (iox-mail-plan §2): reminders are marketing, everything else transactional. */
6
+ declare enum MailKind {
7
+ Transactional = "transactional",
8
+ Marketing = "marketing"
9
+ }
10
+ /** How a studio's mail goes (ML-D9): IOX's relay, or the studio's own Mailjet keys. */
11
+ declare enum MailMode {
12
+ Iox = "iox",
13
+ Own = "own"
14
+ }
15
+ /**
16
+ * Every place a studio sends mail from (iox-mail-plan §1: the seven senders). A message names its sender; its kind,
17
+ * and anything else that follows from who sent it, is read from the tables below — never decided at the call site.
18
+ */
19
+ declare enum MailSender {
20
+ /** a team invite (users) */
21
+ Invite = "invite",
22
+ /** "Forgot it?" — a team member's reset link */
23
+ PasswordReset = "password-reset",
24
+ /** a buyer's sign-in code (commerce E3) */
25
+ SignInCode = "sign-in-code",
26
+ /** an order email — confirmation, payment, shipping (commerce E1/E2) */
27
+ Order = "order",
28
+ /** a checkout recovery reminder (commerce E4) */
29
+ Reminder = "reminder",
30
+ /** a form's "email me" delivery to the owner */
31
+ FormDelivery = "form-delivery",
32
+ /** the `sendEmail` element action — to the author's fixed address */
33
+ SendEmailAction = "send-email-action"
34
+ }
35
+ /** ONE table: what kind of mail each sender sends (R-ML1). Only reminders are marketing. */
36
+ declare const MAIL_KIND_OF_SENDER: Readonly<Record<MailSender, MailKind>>;
37
+ declare function mailKindOf(sender: MailSender): MailKind;
38
+ /** What became of one relayed message. */
39
+ declare enum MailResultStatus {
40
+ Sent = "sent",
41
+ Refused = "refused"
42
+ }
43
+ /** Why a message was not sent — iox-cms records the reason and says it to the owner (R-ML4). */
44
+ declare enum MailRefusal {
45
+ /** the message itself is malformed (`detail` names the field) */
46
+ Invalid = "invalid",
47
+ /** it asked a From that is not the studio's IOX address for its stream, nor its own verified domain (R-ML3) */
48
+ From = "from",
49
+ /** the address bounced hard, complained, or unsubscribed from this studio's marketing (R-ML5) */
50
+ Suppressed = "suppressed",
51
+ /** this studio's marketing is paused — too many complaints or hard bounces, or the operator (ML-D7) */
52
+ Paused = "paused",
53
+ /** marketing past 100% of the month's emails (ML-D5) */
54
+ Quota = "quota",
55
+ /** transactional past twice the month's emails — the abuse ceiling (ML-D5) */
56
+ Ceiling = "ceiling",
57
+ /** the same message id is being sent by another call right now — retry later */
58
+ InProgress = "in-progress",
59
+ /** Mailjet refused this message (an address it will not take, a field it rejects) — not retried */
60
+ Rejected = "rejected",
61
+ /** Mailjet could not be reached or failed — nothing was sent and nothing counted; retry */
62
+ Upstream = "upstream"
63
+ }
64
+ /** The refusals worth retrying later as they are. */
65
+ declare const RETRYABLE_REFUSALS: ReadonlySet<MailRefusal>;
66
+ declare function isRetryableRefusal(reason: MailRefusal | string | null | undefined): boolean;
67
+ /** A whole call the relay cannot take (the HTTP answer carries it as `code`). */
68
+ declare enum MailRelayCode {
69
+ /** no Mailjet key in the control plane yet (ML0) — 503 */
70
+ NotConfigured = "not-configured",
71
+ /** the studio's plan has no IOX mail — 403 */
72
+ NotEnabled = "not-enabled"
73
+ }
74
+ /** Which of a studio's streams a suppression closes. */
75
+ declare enum MailStream {
76
+ All = "all",
77
+ Marketing = "marketing"
78
+ }
79
+ /** Why an address is suppressed for a studio (ML-D7). */
80
+ declare enum SuppressionReason {
81
+ HardBounce = "hard_bounce",
82
+ Spam = "spam",
83
+ Unsubscribed = "unsubscribed"
84
+ }
85
+ /** Why a studio's marketing is paused. */
86
+ declare enum MarketingPauseReason {
87
+ Complaints = "complaints",
88
+ Bounces = "bounces",
89
+ Operator = "operator"
90
+ }
91
+ /** What the relay says about the studio's sender (ML-D10 reads it). */
92
+ declare enum MailSenderState {
93
+ /** the platform key is set and the plan has IOX mail — IOX's verified domains send */
94
+ Ready = "ready",
95
+ NotConfigured = "not-configured",
96
+ NotEnabled = "not-enabled"
97
+ }
98
+
99
+ /**
100
+ * The relay's wire (iox-control-plane `src/mail/`, its `openapi.json` tag `instances`). The studio calls back with its
101
+ * instance token: `Authorization: Bearer <INSTANCE_TOKEN>`.
102
+ */
103
+ declare const RELAY_MAIL_PATH = "/instances/me/mail";
104
+ declare const RELAY_MAIL_USAGE_PATH = "/instances/me/mail/usage";
105
+ /** At most this many messages a call. */
106
+ declare const RELAY_MAX_MESSAGES = 50;
107
+ /** RFC 8058 one-click unsubscribe — the only headers a relayed message may carry. */
108
+ declare const RELAY_ALLOWED_HEADERS: readonly string[];
109
+ interface RelayAddress {
110
+ email: string;
111
+ name?: string;
112
+ }
113
+ /** One message as the studio asks it to be sent. ONE recipient a message. */
114
+ interface RelayMessage {
115
+ /** the studio's message id (its outbox row) — the relay sends one id at most once */
116
+ id: string;
117
+ kind: MailKind;
118
+ to: RelayAddress;
119
+ subject: string;
120
+ text?: string;
121
+ html?: string;
122
+ /** absent = the studio's owner */
123
+ replyTo?: RelayAddress;
124
+ /** the From it expects — absent = the studio's stamped address */
125
+ from?: string;
126
+ /** the organization's name — the From's display name (else the studio's label) */
127
+ fromName?: string;
128
+ headers?: Record<string, string>;
129
+ }
130
+ interface RelayRequest {
131
+ messages: RelayMessage[];
132
+ }
133
+ interface RelayResult {
134
+ id: string;
135
+ status: MailResultStatus;
136
+ reason: MailRefusal | null;
137
+ retryable: boolean;
138
+ /** the field a malformed message got wrong, or Mailjet's words for a message it refused */
139
+ detail: string | null;
140
+ /** true when this id was already sent by an earlier call — nothing was sent twice */
141
+ duplicate: boolean;
142
+ messageUuid: string | null;
143
+ }
144
+ /** This month's counts — what the quota counts is `total`, both kinds. */
145
+ interface RelayMonth {
146
+ total: number;
147
+ transactional: number;
148
+ marketing: number;
149
+ /** refusals this month by reason */
150
+ refused: Partial<Record<MailRefusal | string, number>>;
151
+ hardBounced: number;
152
+ softBounced: number;
153
+ blocked: number;
154
+ complained: number;
155
+ unsubscribed: number;
156
+ }
157
+ /** `GET /instances/me/mail/usage` (and every send's `usage`). Dates are ISO strings on the wire. */
158
+ interface RelayUsage {
159
+ /** the plan has IOX mail (`ioxMail`) */
160
+ enabled: boolean;
161
+ /** the control plane holds a Mailjet key */
162
+ configured: boolean;
163
+ senderState: MailSenderState;
164
+ transactionalFrom: {
165
+ email: string;
166
+ name: string;
167
+ };
168
+ marketingFrom: {
169
+ email: string;
170
+ name: string;
171
+ };
172
+ defaultReplyTo: string;
173
+ periodStart: string;
174
+ periodEnd: string;
175
+ /** `emailsPerMonth`; null = unlimited */
176
+ quota: number | null;
177
+ /** where transactional stops (2× the quota); null = unlimited */
178
+ ceiling: number | null;
179
+ month: RelayMonth;
180
+ suppressions: number;
181
+ marketingPaused: {
182
+ at: string;
183
+ reason: MarketingPauseReason | string;
184
+ } | null;
185
+ }
186
+ interface RelayResponse {
187
+ results: RelayResult[];
188
+ usage: RelayUsage;
189
+ }
190
+
191
+ /** The studio's own Mailjet keys — the three an own mailer needs (the MAILER connector's `requiredKeys`, ML-D9). */
192
+ declare const OWN_MAILER_KEYS: readonly string[];
193
+ /** Where one org's mail goes now. */
194
+ declare enum MailRoute {
195
+ /** its own active mailer row — ML-D8: own wins */
196
+ Own = "own",
197
+ /** IOX's relay */
198
+ Iox = "iox",
199
+ /** nowhere: no usable own row and no IOX mail in the plan */
200
+ None = "none"
201
+ }
202
+ /** A mailer row's settings, as the route reads them (decrypted; only presence is read). */
203
+ interface MailerRowLike {
204
+ mode?: unknown;
205
+ publicKey?: unknown;
206
+ secretKey?: unknown;
207
+ originatorEmail?: unknown;
208
+ }
209
+ /** True when the row holds every key an own mailer needs. */
210
+ declare function hasOwnMailerKeys(row: MailerRowLike | null | undefined): boolean;
211
+ /**
212
+ * A row's mode (ML-D9): the one it names; a row that names none is `own` when it holds its keys (every row stored
213
+ * before IOX mail — its owner brought Mailjet), else `iox`. No row at all is `iox`.
214
+ */
215
+ declare function mailModeOf(row: MailerRowLike | null | undefined): MailMode;
216
+ /** The keys a row needs to count as configured: its own keys in own mode, none in IOX mode (E1). */
217
+ declare function requiredMailerKeys(row: MailerRowLike | null | undefined): string[];
218
+ interface MailRouteFacts {
219
+ /** the org's ACTIVE mailer row, decrypted — null when it has none (or none is on) */
220
+ activeRow: MailerRowLike | null;
221
+ /** the plan has IOX mail (`features.ioxMail`) */
222
+ ioxMail: boolean;
223
+ }
224
+ /**
225
+ * THE route rule (ML-D8, R-ML1): an active row in own mode with its keys sends as today; anything else — no row, a row
226
+ * turned off, a row set to IOX, a row still missing a key — goes through IOX mail when the plan has it, else nowhere.
227
+ */
228
+ declare function planMailRoute(facts: MailRouteFacts): MailRoute;
229
+
230
+ export { MAIL_KIND_OF_SENDER, MailKind, MailMode, MailRefusal, MailRelayCode, MailResultStatus, MailRoute, MailSender, MailSenderState, MailStream, MarketingPauseReason, OWN_MAILER_KEYS, RELAY_ALLOWED_HEADERS, RELAY_MAIL_PATH, RELAY_MAIL_USAGE_PATH, RELAY_MAX_MESSAGES, RETRYABLE_REFUSALS, SuppressionReason, hasOwnMailerKeys, isRetryableRefusal, mailKindOf, mailModeOf, planMailRoute, requiredMailerKeys };
231
+ export type { MailRouteFacts, MailerRowLike, RelayAddress, RelayMessage, RelayMonth, RelayRequest, RelayResponse, RelayResult, RelayUsage };
@@ -0,0 +1,3 @@
1
+ {
2
+ "module": "../fesm2022/vectoriox-iox-ui-mail-core.mjs"
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectoriox/iox-ui",
3
- "version": "5.130.1",
3
+ "version": "5.131.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=20.0.0",
6
6
  "@angular/core": ">=20.0.0",
@@ -63,6 +63,10 @@
63
63
  "types": "./identity-core/index.d.ts",
64
64
  "default": "./fesm2022/vectoriox-iox-ui-identity-core.mjs"
65
65
  },
66
+ "./mail-core": {
67
+ "types": "./mail-core/index.d.ts",
68
+ "default": "./fesm2022/vectoriox-iox-ui-mail-core.mjs"
69
+ },
66
70
  "./media-core": {
67
71
  "types": "./media-core/index.d.ts",
68
72
  "default": "./fesm2022/vectoriox-iox-ui-media-core.mjs"
@@ -0,0 +1,61 @@
1
+ import { MailMode } from './mail-vocabulary';
2
+
3
+ /** The studio's own Mailjet keys — the three an own mailer needs (the MAILER connector's `requiredKeys`, ML-D9). */
4
+ export const OWN_MAILER_KEYS: readonly string[] = ['publicKey', 'secretKey', 'originatorEmail'];
5
+
6
+ /** Where one org's mail goes now. */
7
+ export enum MailRoute {
8
+ /** its own active mailer row — ML-D8: own wins */
9
+ Own = 'own',
10
+ /** IOX's relay */
11
+ Iox = 'iox',
12
+ /** nowhere: no usable own row and no IOX mail in the plan */
13
+ None = 'none',
14
+ }
15
+
16
+ /** A mailer row's settings, as the route reads them (decrypted; only presence is read). */
17
+ export interface MailerRowLike {
18
+ mode?: unknown;
19
+ publicKey?: unknown;
20
+ secretKey?: unknown;
21
+ originatorEmail?: unknown;
22
+ }
23
+
24
+ const filled = (value: unknown): boolean => typeof value === 'string' && value.trim().length > 0;
25
+
26
+ /** True when the row holds every key an own mailer needs. */
27
+ export function hasOwnMailerKeys(row: MailerRowLike | null | undefined): boolean {
28
+ return !!row && OWN_MAILER_KEYS.every((key) => filled((row as Record<string, unknown>)[key]));
29
+ }
30
+
31
+ /**
32
+ * A row's mode (ML-D9): the one it names; a row that names none is `own` when it holds its keys (every row stored
33
+ * before IOX mail — its owner brought Mailjet), else `iox`. No row at all is `iox`.
34
+ */
35
+ export function mailModeOf(row: MailerRowLike | null | undefined): MailMode {
36
+ const asked = typeof row?.mode === 'string' ? row.mode.trim().toLowerCase() : '';
37
+ if (asked === MailMode.Own || asked === MailMode.Iox) return asked as MailMode;
38
+ return hasOwnMailerKeys(row) ? MailMode.Own : MailMode.Iox;
39
+ }
40
+
41
+ /** The keys a row needs to count as configured: its own keys in own mode, none in IOX mode (E1). */
42
+ export function requiredMailerKeys(row: MailerRowLike | null | undefined): string[] {
43
+ return mailModeOf(row) === MailMode.Own ? [...OWN_MAILER_KEYS] : [];
44
+ }
45
+
46
+ export interface MailRouteFacts {
47
+ /** the org's ACTIVE mailer row, decrypted — null when it has none (or none is on) */
48
+ activeRow: MailerRowLike | null;
49
+ /** the plan has IOX mail (`features.ioxMail`) */
50
+ ioxMail: boolean;
51
+ }
52
+
53
+ /**
54
+ * THE route rule (ML-D8, R-ML1): an active row in own mode with its keys sends as today; anything else — no row, a row
55
+ * turned off, a row set to IOX, a row still missing a key — goes through IOX mail when the plan has it, else nowhere.
56
+ */
57
+ export function planMailRoute(facts: MailRouteFacts): MailRoute {
58
+ const row = facts.activeRow;
59
+ if (row && mailModeOf(row) === MailMode.Own && hasOwnMailerKeys(row)) return MailRoute.Own;
60
+ return facts.ioxMail ? MailRoute.Iox : MailRoute.None;
61
+ }
@@ -0,0 +1,123 @@
1
+ /**
2
+ * IOX Mail's words (iox-mail-plan ML1/ML2). ONE spelling for the relay (iox-control-plane), the studio (iox-cms) and
3
+ * the admin — none of them re-spells a value.
4
+ */
5
+
6
+ /** Set by the sender, never guessed (iox-mail-plan §2): reminders are marketing, everything else transactional. */
7
+ export enum MailKind {
8
+ Transactional = 'transactional',
9
+ Marketing = 'marketing',
10
+ }
11
+
12
+ /** How a studio's mail goes (ML-D9): IOX's relay, or the studio's own Mailjet keys. */
13
+ export enum MailMode {
14
+ Iox = 'iox',
15
+ Own = 'own',
16
+ }
17
+
18
+ /**
19
+ * Every place a studio sends mail from (iox-mail-plan §1: the seven senders). A message names its sender; its kind,
20
+ * and anything else that follows from who sent it, is read from the tables below — never decided at the call site.
21
+ */
22
+ export enum MailSender {
23
+ /** a team invite (users) */
24
+ Invite = 'invite',
25
+ /** "Forgot it?" — a team member's reset link */
26
+ PasswordReset = 'password-reset',
27
+ /** a buyer's sign-in code (commerce E3) */
28
+ SignInCode = 'sign-in-code',
29
+ /** an order email — confirmation, payment, shipping (commerce E1/E2) */
30
+ Order = 'order',
31
+ /** a checkout recovery reminder (commerce E4) */
32
+ Reminder = 'reminder',
33
+ /** a form's "email me" delivery to the owner */
34
+ FormDelivery = 'form-delivery',
35
+ /** the `sendEmail` element action — to the author's fixed address */
36
+ SendEmailAction = 'send-email-action',
37
+ }
38
+
39
+ /** ONE table: what kind of mail each sender sends (R-ML1). Only reminders are marketing. */
40
+ export const MAIL_KIND_OF_SENDER: Readonly<Record<MailSender, MailKind>> = {
41
+ [MailSender.Invite]: MailKind.Transactional,
42
+ [MailSender.PasswordReset]: MailKind.Transactional,
43
+ [MailSender.SignInCode]: MailKind.Transactional,
44
+ [MailSender.Order]: MailKind.Transactional,
45
+ [MailSender.Reminder]: MailKind.Marketing,
46
+ [MailSender.FormDelivery]: MailKind.Transactional,
47
+ [MailSender.SendEmailAction]: MailKind.Transactional,
48
+ };
49
+
50
+ export function mailKindOf(sender: MailSender): MailKind {
51
+ return MAIL_KIND_OF_SENDER[sender];
52
+ }
53
+
54
+ /** What became of one relayed message. */
55
+ export enum MailResultStatus {
56
+ Sent = 'sent',
57
+ Refused = 'refused',
58
+ }
59
+
60
+ /** Why a message was not sent — iox-cms records the reason and says it to the owner (R-ML4). */
61
+ export enum MailRefusal {
62
+ /** the message itself is malformed (`detail` names the field) */
63
+ Invalid = 'invalid',
64
+ /** it asked a From that is not the studio's IOX address for its stream, nor its own verified domain (R-ML3) */
65
+ From = 'from',
66
+ /** the address bounced hard, complained, or unsubscribed from this studio's marketing (R-ML5) */
67
+ Suppressed = 'suppressed',
68
+ /** this studio's marketing is paused — too many complaints or hard bounces, or the operator (ML-D7) */
69
+ Paused = 'paused',
70
+ /** marketing past 100% of the month's emails (ML-D5) */
71
+ Quota = 'quota',
72
+ /** transactional past twice the month's emails — the abuse ceiling (ML-D5) */
73
+ Ceiling = 'ceiling',
74
+ /** the same message id is being sent by another call right now — retry later */
75
+ InProgress = 'in-progress',
76
+ /** Mailjet refused this message (an address it will not take, a field it rejects) — not retried */
77
+ Rejected = 'rejected',
78
+ /** Mailjet could not be reached or failed — nothing was sent and nothing counted; retry */
79
+ Upstream = 'upstream',
80
+ }
81
+
82
+ /** The refusals worth retrying later as they are. */
83
+ export const RETRYABLE_REFUSALS: ReadonlySet<MailRefusal> = new Set([MailRefusal.InProgress, MailRefusal.Upstream]);
84
+
85
+ export function isRetryableRefusal(reason: MailRefusal | string | null | undefined): boolean {
86
+ return RETRYABLE_REFUSALS.has(reason as MailRefusal);
87
+ }
88
+
89
+ /** A whole call the relay cannot take (the HTTP answer carries it as `code`). */
90
+ export enum MailRelayCode {
91
+ /** no Mailjet key in the control plane yet (ML0) — 503 */
92
+ NotConfigured = 'not-configured',
93
+ /** the studio's plan has no IOX mail — 403 */
94
+ NotEnabled = 'not-enabled',
95
+ }
96
+
97
+ /** Which of a studio's streams a suppression closes. */
98
+ export enum MailStream {
99
+ All = 'all',
100
+ Marketing = 'marketing',
101
+ }
102
+
103
+ /** Why an address is suppressed for a studio (ML-D7). */
104
+ export enum SuppressionReason {
105
+ HardBounce = 'hard_bounce',
106
+ Spam = 'spam',
107
+ Unsubscribed = 'unsubscribed',
108
+ }
109
+
110
+ /** Why a studio's marketing is paused. */
111
+ export enum MarketingPauseReason {
112
+ Complaints = 'complaints',
113
+ Bounces = 'bounces',
114
+ Operator = 'operator',
115
+ }
116
+
117
+ /** What the relay says about the studio's sender (ML-D10 reads it). */
118
+ export enum MailSenderState {
119
+ /** the platform key is set and the plan has IOX mail — IOX's verified domains send */
120
+ Ready = 'ready',
121
+ NotConfigured = 'not-configured',
122
+ NotEnabled = 'not-enabled',
123
+ }
@@ -0,0 +1,93 @@
1
+ import { MailKind, MailRefusal, MailResultStatus, MailSenderState, MarketingPauseReason } from './mail-vocabulary';
2
+
3
+ /**
4
+ * The relay's wire (iox-control-plane `src/mail/`, its `openapi.json` tag `instances`). The studio calls back with its
5
+ * instance token: `Authorization: Bearer <INSTANCE_TOKEN>`.
6
+ */
7
+ export const RELAY_MAIL_PATH = '/instances/me/mail';
8
+ export const RELAY_MAIL_USAGE_PATH = '/instances/me/mail/usage';
9
+
10
+ /** At most this many messages a call. */
11
+ export const RELAY_MAX_MESSAGES = 50;
12
+
13
+ /** RFC 8058 one-click unsubscribe — the only headers a relayed message may carry. */
14
+ export const RELAY_ALLOWED_HEADERS: readonly string[] = ['List-Unsubscribe', 'List-Unsubscribe-Post'];
15
+
16
+ export interface RelayAddress {
17
+ email: string;
18
+ name?: string;
19
+ }
20
+
21
+ /** One message as the studio asks it to be sent. ONE recipient a message. */
22
+ export interface RelayMessage {
23
+ /** the studio's message id (its outbox row) — the relay sends one id at most once */
24
+ id: string;
25
+ kind: MailKind;
26
+ to: RelayAddress;
27
+ subject: string;
28
+ text?: string;
29
+ html?: string;
30
+ /** absent = the studio's owner */
31
+ replyTo?: RelayAddress;
32
+ /** the From it expects — absent = the studio's stamped address */
33
+ from?: string;
34
+ /** the organization's name — the From's display name (else the studio's label) */
35
+ fromName?: string;
36
+ headers?: Record<string, string>;
37
+ }
38
+
39
+ export interface RelayRequest {
40
+ messages: RelayMessage[];
41
+ }
42
+
43
+ export interface RelayResult {
44
+ id: string;
45
+ status: MailResultStatus;
46
+ reason: MailRefusal | null;
47
+ retryable: boolean;
48
+ /** the field a malformed message got wrong, or Mailjet's words for a message it refused */
49
+ detail: string | null;
50
+ /** true when this id was already sent by an earlier call — nothing was sent twice */
51
+ duplicate: boolean;
52
+ messageUuid: string | null;
53
+ }
54
+
55
+ /** This month's counts — what the quota counts is `total`, both kinds. */
56
+ export interface RelayMonth {
57
+ total: number;
58
+ transactional: number;
59
+ marketing: number;
60
+ /** refusals this month by reason */
61
+ refused: Partial<Record<MailRefusal | string, number>>;
62
+ hardBounced: number;
63
+ softBounced: number;
64
+ blocked: number;
65
+ complained: number;
66
+ unsubscribed: number;
67
+ }
68
+
69
+ /** `GET /instances/me/mail/usage` (and every send's `usage`). Dates are ISO strings on the wire. */
70
+ export interface RelayUsage {
71
+ /** the plan has IOX mail (`ioxMail`) */
72
+ enabled: boolean;
73
+ /** the control plane holds a Mailjet key */
74
+ configured: boolean;
75
+ senderState: MailSenderState;
76
+ transactionalFrom: { email: string; name: string };
77
+ marketingFrom: { email: string; name: string };
78
+ defaultReplyTo: string;
79
+ periodStart: string;
80
+ periodEnd: string;
81
+ /** `emailsPerMonth`; null = unlimited */
82
+ quota: number | null;
83
+ /** where transactional stops (2× the quota); null = unlimited */
84
+ ceiling: number | null;
85
+ month: RelayMonth;
86
+ suppressions: number;
87
+ marketingPaused: { at: string; reason: MarketingPauseReason | string } | null;
88
+ }
89
+
90
+ export interface RelayResponse {
91
+ results: RelayResult[];
92
+ usage: RelayUsage;
93
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @vectoriox/iox-ui/mail-core — IOX Mail's shared, FRAMEWORK-FREE vocabulary (iox-mail-plan ML2): a message's kind,
3
+ * who sends it, the relay's wire (`POST /instances/me/mail`, its usage) and refusals, and the ONE route rule — the
4
+ * studio's own active mailer wins, else IOX mail when the plan has it. The control plane (the relay), iox-cms (the
5
+ * transport and the MAILER connector) and the admin (Settings ▸ Email, ML3) speak it. It imports nothing.
6
+ * ⚠️ Not re-exported from the main entry. Consumers wire the usual trio — ng-package raw-ts assets, jest
7
+ * moduleNameMapper, tsconfig paths — or `nest start` dies with ERR_REQUIRE_ESM.
8
+ */
9
+ export * from './mail-vocabulary';
10
+ export * from './mail-wire';
11
+ export * from './mail-route';