Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -0,0 +1,104 @@
import type { VMState } from "../index.js";
/**
* AK-P14a · Sending-domain view-model. Pure functions — no React, no Prisma, no
* app imports. Maps a TenantSendingDomain (+ its BCC-logging inbound address)
* into the settings screen: DNS record cards with copy values, the verification
* status ampel (pending/verifying/verified/failed) with a tone token, the 7-day
* Klartext failure surface, and the BCC-logging toggle.
*/
export type SendingDomainStatusVM = "pending" | "verifying" | "verified" | "failed";
export type DnsRecordKind = "dkim" | "spf" | "dmarc";
export interface DnsRecordCard {
readonly kind: DnsRecordKind;
/** i18n label key, e.g. `email.domain.record.dkim`. */
readonly labelKey: string;
/** Host/name the tenant publishes the record at (may be null until provisioned). */
readonly host: string | null;
/** The record value to copy (null until Mailjet returns it). */
readonly value: string | null;
}
export interface SendingDomainData {
readonly hasDomain: boolean;
readonly id: string | null;
readonly domain: string | null;
readonly status: SendingDomainStatusVM;
/** i18n key for the status pill, e.g. `email.domain.status.verified`. */
readonly statusLabelKey: string;
readonly statusTone: "success" | "warning" | "danger" | "neutral";
readonly records: readonly DnsRecordCard[];
/** True once the domain has failed (incomplete > 7 days) → show Klartext error. */
readonly showFailure: boolean;
/** i18n key carrying the Klartext failure detail, or null. */
readonly errorMessageKey: string | null;
/** Whether sending is unlocked (verified) — gates the marketing send (AK-P14b). */
readonly canSend: boolean;
readonly bccAddress: string | null;
readonly bccEnabled: boolean;
readonly canManage: boolean;
readonly emptyHeadlineKey: string;
readonly emptyBodyKey: string;
}
export type SendingDomainVM = VMState<SendingDomainData>;
const STATUS_TONE: Record<SendingDomainStatusVM, SendingDomainData["statusTone"]> = {
pending: "neutral",
verifying: "warning",
verified: "success",
failed: "danger",
};
export interface BuildSendingDomainVMInput {
readonly domain: {
readonly id: string;
readonly domain: string;
readonly status: SendingDomainStatusVM;
readonly dkimSelector: string | null;
readonly dkimRecord: string | null;
readonly spfRecord: string | null;
readonly dmarcRecord: string | null;
readonly errorMessageKey: string | null;
} | null;
readonly bccAddress: string | null;
readonly bccEnabled: boolean;
readonly canManage: boolean;
}
export function buildSendingDomainVM(input: BuildSendingDomainVMInput): SendingDomainVM {
if (!input.domain) {
return {
status: "empty",
};
}
const d = input.domain;
const records: DnsRecordCard[] = [
{ kind: "dkim", labelKey: "email.domain.record.dkim", host: d.dkimSelector, value: d.dkimRecord },
{ kind: "spf", labelKey: "email.domain.record.spf", host: d.domain, value: d.spfRecord },
{ kind: "dmarc", labelKey: "email.domain.record.dmarc", host: `_dmarc.${d.domain}`, value: d.dmarcRecord },
];
return {
status: "ready",
data: {
hasDomain: true,
id: d.id,
domain: d.domain,
status: d.status,
statusLabelKey: `email.domain.status.${d.status}`,
statusTone: STATUS_TONE[d.status],
records,
showFailure: d.status === "failed",
errorMessageKey: d.status === "failed" ? d.errorMessageKey ?? "email.domain.error.notVerifiedAfter7Days" : null,
canSend: d.status === "verified",
bccAddress: input.bccAddress,
bccEnabled: input.bccEnabled,
canManage: input.canManage,
emptyHeadlineKey: "email.domain.empty.headline",
emptyBodyKey: "email.domain.empty.body",
},
};
}