@adatechnology/notification-contracts 0.1.0-rc.2 → 0.1.0-rc.4

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/dist/index.d.cts CHANGED
@@ -13,6 +13,15 @@ declare const NOTIFICATION_CHANNEL: {
13
13
  type NotificationChannel = (typeof NOTIFICATION_CHANNEL)[keyof typeof NOTIFICATION_CHANNEL];
14
14
  /** Canais que interrompem o destinatário e por isso respeitam quiet hours (ver spec §10.4). */
15
15
  declare const INTRUSIVE_CHANNELS: readonly NotificationChannel[];
16
+ /**
17
+ * O teto de canais da empresa por categoria, acima da preferência do usuário. Linha ausente
18
+ * significa permitido — fechar por omissão calaria toda categoria existente.
19
+ */
20
+ type NotificationCategoryPolicy = {
21
+ readonly category: string;
22
+ readonly channel: NotificationChannel;
23
+ readonly enabled: boolean;
24
+ };
16
25
  declare const NOTIFICATION_STATUS: {
17
26
  readonly PENDING: "pending";
18
27
  readonly SCHEDULED: "scheduled";
@@ -173,22 +182,48 @@ type DeliveryReceipt = {
173
182
 
174
183
  /**
175
184
  * Copyright (c) 2026 Ada Technology. MIT License.
185
+ *
186
+ * Anexo de e-mail — por REFERÊNCIA, nunca por conteúdo.
187
+ *
188
+ * O template é linha versionada no Postgres e o job é payload no Redis. Um PDF em qualquer um dos
189
+ * dois é blob replicado a cada versão e a cada tentativa, e uma nota fiscal é dado pessoal — o
190
+ * `security.md` §6 já manda o payload de fila carregar referência, e o §7 manda entregar arquivo por
191
+ * URL assinada de vida curta. Anexo segue a mesma regra: o que trafega é onde o arquivo está.
192
+ *
193
+ * Quem baixa é o DRIVER, no momento do envio, e é ele que aplica o teto de tamanho. Baixar antes
194
+ * (no módulo) seria carregar bytes na memória de um processo que pode nem chegar a enviar.
176
195
  */
177
-
178
196
  /**
179
- * Resultado de UMA tentativa de entrega, classificado **pelo driver** — nunca pelo módulo.
180
- *
181
- * Só o driver sabe que `DeviceNotRegistered` (Expo) e `registration-token-not-registered` (FCM)
182
- * significam "apaga o token", e que 429/5xx significa "tenta de novo". Deixar essa leitura no
183
- * módulo o obrigaria a conhecer o vocabulário de erro de cada provedor — e foi assim que, no
184
- * modelo antigo, token morto ficava vivo para sempre e erro permanente entrava em retry infinito.
197
+ * 25MB é o teto prático: Gmail e Outlook recusam acima disso, e o SES conta o MIME inteiro já em
198
+ * base64 — que infla ~33%. O driver reprova ANTES de montar a mensagem, senão o erro vem do
199
+ * provedor como uma falha genérica de envio.
200
+ */
201
+ declare const EMAIL_ATTACHMENT_MAX_BYTES: number;
202
+ /** Um e-mail com trinta anexos é engano de laço, não um caso de uso. */
203
+ declare const EMAIL_ATTACHMENT_MAX_COUNT = 10;
204
+ type EmailAttachment = {
205
+ /** O nome que o destinatário vê. Sem caminho: `../` num nome de anexo é travessia de diretório. */
206
+ readonly filename: string;
207
+ /**
208
+ * URL de onde o driver baixa no momento do envio. Assinada e de vida curta quando o arquivo for
209
+ * privado — o driver não autentica, ele só faz `GET`.
210
+ */
211
+ readonly url: string;
212
+ /** Declarado pelo produto, e não adivinhado da extensão: extensão mente, e cliente de e-mail confia. */
213
+ readonly contentType: string;
214
+ };
215
+ /**
216
+ * Recusa o que não pode virar anexo antes de qualquer rede.
185
217
  *
186
- * O módulo age sobre o discriminante:
187
- * - `sent` grava `providerMessageId`;
188
- * - `invalid_target` desativa o device ou cria supressão, **sem** retry;
189
- * - `retriable` reagenda com backoff exponencial + jitter até esgotar `attempts`;
190
- * - `permanent` finaliza como `failed` na primeira tentativa.
218
+ * Devolve o motivo em vez de lançar: o chamador é um driver, e uma tentativa de entrega registra o
219
+ * porquê da recusa na `delivery` — `throw` viraria erro genérico e o operador ficaria sem a causa.
220
+ */
221
+ declare function checkEmailAttachment(attachment: EmailAttachment): string | undefined;
222
+
223
+ /**
224
+ * Copyright (c) 2026 Ada Technology. MIT License.
191
225
  */
226
+
192
227
  type DeliveryAttemptResult = {
193
228
  readonly outcome: 'sent';
194
229
  readonly providerMessageId?: string;
@@ -222,6 +257,11 @@ type SendEmailParams = {
222
257
  readonly html: string;
223
258
  readonly text: string;
224
259
  readonly replyTo?: string;
260
+ /**
261
+ * Anexos por REFERÊNCIA: o driver baixa de `url` no momento do envio. Ver `emailAttachment.ts`
262
+ * para por que o conteúdo não trafega aqui.
263
+ */
264
+ readonly attachments?: readonly EmailAttachment[];
225
265
  /** Correlaciona o recibo assíncrono (bounce/complaint) com a `delivery` que o originou. */
226
266
  readonly idempotencyKey?: string;
227
267
  };
@@ -558,6 +598,59 @@ declare const updatePreferencesSchema: z.ZodObject<{
558
598
  }[];
559
599
  }>;
560
600
  type UpdatePreferencesBody = z.infer<typeof updatePreferencesSchema>;
601
+ declare const categoryPolicyEntrySchema: z.ZodObject<{
602
+ category: z.ZodString;
603
+ channel: z.ZodNativeEnum<{
604
+ readonly INBOX: "inbox";
605
+ readonly PUSH: "push";
606
+ readonly EMAIL: "email";
607
+ readonly WHATSAPP: "whatsapp";
608
+ readonly SMS: "sms";
609
+ }>;
610
+ enabled: z.ZodBoolean;
611
+ }, "strip", z.ZodTypeAny, {
612
+ category: string;
613
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
614
+ enabled: boolean;
615
+ }, {
616
+ category: string;
617
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
618
+ enabled: boolean;
619
+ }>;
620
+ declare const updateCategoryPoliciesSchema: z.ZodObject<{
621
+ policies: z.ZodArray<z.ZodObject<{
622
+ category: z.ZodString;
623
+ channel: z.ZodNativeEnum<{
624
+ readonly INBOX: "inbox";
625
+ readonly PUSH: "push";
626
+ readonly EMAIL: "email";
627
+ readonly WHATSAPP: "whatsapp";
628
+ readonly SMS: "sms";
629
+ }>;
630
+ enabled: z.ZodBoolean;
631
+ }, "strip", z.ZodTypeAny, {
632
+ category: string;
633
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
634
+ enabled: boolean;
635
+ }, {
636
+ category: string;
637
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
638
+ enabled: boolean;
639
+ }>, "many">;
640
+ }, "strip", z.ZodTypeAny, {
641
+ policies: {
642
+ category: string;
643
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
644
+ enabled: boolean;
645
+ }[];
646
+ }, {
647
+ policies: {
648
+ category: string;
649
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
650
+ enabled: boolean;
651
+ }[];
652
+ }>;
653
+ type UpdateCategoryPoliciesBody = z.infer<typeof updateCategoryPoliciesSchema>;
561
654
  declare const upsertTemplateSchema: z.ZodObject<{
562
655
  key: z.ZodString;
563
656
  channel: z.ZodNativeEnum<{
@@ -762,7 +855,25 @@ declare const NOTIFICATION_ERROR_CODES: {
762
855
  readonly DEVICE_NOT_FOUND: "NOTIFICATION_DEVICE_NOT_FOUND";
763
856
  readonly THROTTLED: "NOTIFICATION_THROTTLED";
764
857
  readonly CONFIG_MISSING: "NOTIFICATION_CONFIG_MISSING";
858
+ readonly TEMPLATE_UNKNOWN_VARIABLE: "NOTIFICATION_TEMPLATE_UNKNOWN_VARIABLE";
765
859
  };
860
+ /** Busca por id, e não por identidade — o painel remove pela linha que listou. */
861
+ declare class TemplateIdNotFoundError extends NotificationError {
862
+ readonly templateId: string;
863
+ constructor(templateId: string);
864
+ }
865
+ /**
866
+ * O template referencia `{{campo}}` que o produto não promete enviar. Renderizaria vazio para
867
+ * sempre, sem log e sem erro — daí ser recusa na gravação, e não aviso.
868
+ *
869
+ * `details.fields` traz TODAS as desconhecidas, não a primeira: corrigir uma por vez transforma o
870
+ * salvamento em tentativa e erro (`apis.md`, Validação).
871
+ */
872
+ declare class UnknownTemplateVariablesError extends NotificationError {
873
+ readonly templateKey: string;
874
+ readonly fields: readonly string[];
875
+ constructor(templateKey: string, fields: readonly string[]);
876
+ }
766
877
  declare class TemplateNotFoundError extends NotificationError {
767
878
  readonly templateKey: string;
768
879
  readonly channel: NotificationChannel;
@@ -850,6 +961,43 @@ type WhatsAppSendingChannel = {
850
961
  };
851
962
  declare function createWhatsAppDriverFromChannel(channel: WhatsAppSendingChannel): WhatsAppDriverPort;
852
963
 
964
+ /**
965
+ * Copyright (c) 2026 Ada Technology. MIT License.
966
+ *
967
+ * Larguras e limites do preview, por canal.
968
+ *
969
+ * Moram aqui, e não no CSS da UI, porque o host que consome a camada headless precisa deles para
970
+ * desenhar o próprio preview — e porque o limite de caracteres não é decoração de tela: ele é a
971
+ * regra do canal, e o editor avisa com ela antes de salvar.
972
+ */
973
+
974
+ declare const PREVIEW_VIEWPORT: {
975
+ readonly DESKTOP: "desktop";
976
+ readonly MOBILE: "mobile";
977
+ };
978
+ type PreviewViewport = (typeof PREVIEW_VIEWPORT)[keyof typeof PREVIEW_VIEWPORT];
979
+ type PreviewViewportSpec = {
980
+ readonly viewport: PreviewViewport;
981
+ readonly width: number;
982
+ };
983
+ /**
984
+ * `email` em 600px é a largura clássica de corpo de e-mail; os demais aproximam o container em que
985
+ * a mensagem aparece no desktop. `sms` não tem desktop — a mensagem é a mesma no aparelho e ponto.
986
+ */
987
+ declare const PREVIEW_VIEWPORT_BY_CHANNEL: Readonly<Record<NotificationChannel, readonly PreviewViewportSpec[]>>;
988
+ type TemplateConstraintField = 'title' | 'body';
989
+ type TemplateConstraintLimits = {
990
+ readonly title?: number;
991
+ readonly body?: number;
992
+ };
993
+ /**
994
+ * Onde o canal corta de verdade. `email.title` são os ~78 caracteres que a lista da caixa de
995
+ * entrada mostra no celular; `push` segue o teto prático do Android; `sms` é o segmento de 160,
996
+ * depois do qual a operadora cobra outra mensagem; `whatsapp.body` é o teto de corpo de template
997
+ * da Meta. `inbox` acompanha o `deriveTitleFromBody`.
998
+ */
999
+ declare const TEMPLATE_CONSTRAINTS_BY_CHANNEL: Readonly<Record<NotificationChannel, TemplateConstraintLimits>>;
1000
+
853
1001
  /**
854
1002
  * Copyright (c) 2026 Ada Technology. MIT License.
855
1003
  *
@@ -863,16 +1011,29 @@ declare function createWhatsAppDriverFromChannel(channel: WhatsAppSendingChannel
863
1011
  * Com a função aqui, o `notification-module` renderiza para enviar e a UI renderiza para mostrar,
864
1012
  * lendo o MESMO código. Divergência deixa de ser possível em vez de ser improvável.
865
1013
  */
1014
+
866
1015
  declare function escapeTemplateHtml(text: string): string;
867
1016
  /** `{{campo}}` → valor do payload. Campo ausente vira string vazia, nunca o literal `{{campo}}`. */
868
1017
  declare function interpolateTemplate(template: string, payload: Readonly<Record<string, unknown>>): string;
869
1018
  declare function deriveTitleFromBody(body: string): string;
870
1019
  /** Os nomes de campo que um template referencia — o que a tela de configuração precisa pedir. */
871
1020
  declare function extractTemplatePlaceholders(template: string): readonly string[];
1021
+ type TemplateConstraintCheck = {
1022
+ readonly field: TemplateConstraintField;
1023
+ readonly limit: number;
1024
+ readonly actual: number;
1025
+ readonly exceeded: boolean;
1026
+ };
872
1027
  type RenderedTemplatePreview = {
873
1028
  readonly title: string;
874
1029
  readonly body: string;
875
1030
  readonly html?: string;
1031
+ /**
1032
+ * O que o canal corta. Vazio quando o canal não declara limite. O editor usa isto para avisar
1033
+ * antes de salvar, e o preview para marcar onde o texto some — sem isso, dois quadros de
1034
+ * larguras diferentes só provariam que CSS quebra linha.
1035
+ */
1036
+ readonly constraints: readonly TemplateConstraintCheck[];
876
1037
  };
877
1038
  /**
878
1039
  * Mesma saída que o envio produz. `channel` importa porque só e-mail ganha a versão HTML — mostrar
@@ -885,4 +1046,77 @@ declare function renderTemplate(params: {
885
1046
  readonly payload: Readonly<Record<string, unknown>>;
886
1047
  }): RenderedTemplatePreview;
887
1048
 
888
- export { type CachePort, type ChannelDrivers, ChannelNotConfiguredError, type ClockPort, type CompanyId, ConfigMissingError, DELIVERY_STATUS, DEVICE_PLATFORM, type DeliveryAttemptResult, type DeliveryBouncedEvent, type DeliveryFailedEvent, type DeliveryReceipt, type DeliverySentEvent, type DeliveryStatus, type DeliverySummary, type DeliveryWebhookBody, type DeviceInvalidatedEvent, DeviceNotFoundError, type DevicePlatform, type DeviceRegisteredEvent, type DeviceRegistration, DuplicateWebhookDeliveryError, EMAIL_DRIVER, type EmailDriver, type EmailDriverPort, INTRUSIVE_CHANNELS, InvalidWebhookSignatureError, type ListNotificationsParams, type ListNotificationsQuery, type ListNotificationsResult, type LogMeta, type LoggerPort, type MetricsPort, NOTIFICATION_CATEGORY_HINT, NOTIFICATION_CHANNEL, NOTIFICATION_ERROR_CODES, NOTIFICATION_EVENT, NOTIFICATION_STATUS, type NotificationChannel, type NotificationCreatedEvent, type NotificationDispatchedEvent, NotificationError, type NotificationEvent, type NotificationHooks, type NotificationId, type NotificationJob, NotificationNotFoundError, type NotificationPreference, type NotificationReadEvent, type NotificationStatus, type NotificationSummary, type NotificationTemplate, PUSH_DRIVER, type PreferencesUpdatedEvent, type PushDriver, type PushDriverPort, type QueuePort, type RealtimeEvent, type RealtimeNotifierPort, type RealtimeSubscription, type RecipientResolverPort, RecipientUnresolvedError, type RegisterDeviceBody, type RenderTemplateParams, type RenderedTemplate, type RenderedTemplatePreview, type ResolvedRecipient, SUPPRESSION_REASON, type SendEmailParams, type SendNotificationBody, type SendNotificationParams, type SendNotificationResult, type SendPushParams, type SendSmsParams, type SendWhatsAppParams, type SendWhatsAppTemplateParams, type SmsDriverPort, SuppressedTargetError, type SuppressionReason, TemplateNotFoundError, type TemplateRendererPort, ThrottledError, type UpdatePreferencesBody, type UpsertTemplateBody, type UserId, type WhatsAppDriverPort, type WhatsAppSendingChannel, createWhatsAppDriverFromChannel, deliveryWebhookSchema, deriveTitleFromBody, escapeTemplateHtml, extractTemplatePlaceholders, interpolateTemplate, listNotificationsQuerySchema, preferenceEntrySchema, registerDeviceSchema, renderTemplate, sendNotificationSchema, updatePreferencesSchema, upsertTemplateSchema };
1049
+ /**
1050
+ * Copyright (c) 2026 Ada Technology. MIT License.
1051
+ *
1052
+ * O catálogo de variáveis de um template, e a diferença entre o que ele declara e o que o texto
1053
+ * usa.
1054
+ *
1055
+ * Existe porque `{{campo}}` desconhecido não falha: `interpolateTemplate` devolve string vazia, que
1056
+ * é o comportamento correto no envio — mensagem com buraco é melhor que mensagem com `{{campo}}`
1057
+ * cru. O preço é que um erro de digitação no painel some sem log e sem erro, e só aparece quando o
1058
+ * cliente recebe "Olá , seu pedido". Com um painel, isso deixa de ser raro.
1059
+ *
1060
+ * A função é pura e mora aqui, e não no módulo, pelo mesmo motivo do `renderTemplate`: a validação
1061
+ * do servidor e o aviso da tela precisam da MESMA regra, e o frontend não pode importar o módulo
1062
+ * (carrega Drizzle). Duas implementações divergiriam, e a tela passaria a aprovar o que a rota
1063
+ * recusa.
1064
+ */
1065
+ /**
1066
+ * `text` entra no corpo por interpolação; `attachment` NÃO — ele viaja ao lado da mensagem.
1067
+ *
1068
+ * A distinção existe porque as duas regras de validação são opostas: variável de texto declarada e
1069
+ * ausente do corpo é um aviso, e variável de anexo ausente do corpo é o normal. Sem o tipo, todo
1070
+ * anexo obrigatório apareceria eternamente como "faltando no texto".
1071
+ */
1072
+ declare const TEMPLATE_VARIABLE_KIND: {
1073
+ readonly TEXT: "text";
1074
+ readonly ATTACHMENT: "attachment";
1075
+ };
1076
+ type TemplateVariableKind = (typeof TEMPLATE_VARIABLE_KIND)[keyof typeof TEMPLATE_VARIABLE_KIND];
1077
+ type TemplateVariableDefinition = {
1078
+ readonly name: string;
1079
+ /** Ausente é `text`: todo catálogo escrito antes disto continua valendo sem alteração. */
1080
+ readonly kind?: TemplateVariableKind;
1081
+ /** Valor de exemplo — alimenta o preview. Só o produto sabe que `orderNumber` é "QC-1042". */
1082
+ readonly example: string;
1083
+ /** `true` avisa quando o texto não usa a variável; nunca bloqueia (ver `diffTemplateVariables`). */
1084
+ readonly required: boolean;
1085
+ /** Chave de i18n do rótulo na tela. Ausente, a tela mostra o próprio `name`. */
1086
+ readonly labelKey?: string;
1087
+ };
1088
+ /** `templateKey` → variáveis que o produto promete enviar no payload daquela notificação. */
1089
+ type TemplateVariableCatalog = Readonly<Record<string, readonly TemplateVariableDefinition[]>>;
1090
+ type TemplateVariableDiff = {
1091
+ /** Placeholders que o texto referencia, na ordem em que aparecem. */
1092
+ readonly used: readonly string[];
1093
+ /** Referenciados e não declarados — renderizariam vazio para sempre. */
1094
+ readonly unknown: readonly string[];
1095
+ /** Declarados como `required` e ausentes do texto. Só variáveis de texto entram aqui. */
1096
+ readonly missingRequired: readonly string[];
1097
+ /**
1098
+ * Anexos referenciados DENTRO do texto — quase sempre engano.
1099
+ *
1100
+ * `{{nota}}` no corpo de um anexo renderiza a URL crua no meio da frase, e não anexa nada. Se a
1101
+ * intenção era mandar o link, a variável devia ser de texto; se era anexar, ela não pertence ao
1102
+ * corpo. Aviso e não erro: link para o arquivo é uma escolha legítima, só não é esta.
1103
+ */
1104
+ readonly attachmentsInText: readonly string[];
1105
+ };
1106
+ type DiffTemplateVariablesParams = {
1107
+ readonly body: string;
1108
+ readonly subject?: string | undefined;
1109
+ /**
1110
+ * Ausente significa catálogo não declarado para esta `key`, e não catálogo vazio: nesse caso
1111
+ * nada é desconhecido. Fechar por omissão quebraria todo host que já usa o módulo sem catálogo.
1112
+ */
1113
+ readonly variables?: readonly TemplateVariableDefinition[] | undefined;
1114
+ };
1115
+ declare function diffTemplateVariables(params: DiffTemplateVariablesParams): TemplateVariableDiff;
1116
+ /**
1117
+ * O payload de preview sai do próprio catálogo. Um mapa `key → exemplo` mantido em paralelo
1118
+ * divergiria do catálogo na primeira variável nova, e o preview voltaria a mentir.
1119
+ */
1120
+ declare function buildPreviewPayload(variables: readonly TemplateVariableDefinition[] | undefined): Readonly<Record<string, string>>;
1121
+
1122
+ export { type CachePort, type ChannelDrivers, ChannelNotConfiguredError, type ClockPort, type CompanyId, ConfigMissingError, DELIVERY_STATUS, DEVICE_PLATFORM, type DeliveryAttemptResult, type DeliveryBouncedEvent, type DeliveryFailedEvent, type DeliveryReceipt, type DeliverySentEvent, type DeliveryStatus, type DeliverySummary, type DeliveryWebhookBody, type DeviceInvalidatedEvent, DeviceNotFoundError, type DevicePlatform, type DeviceRegisteredEvent, type DeviceRegistration, type DiffTemplateVariablesParams, DuplicateWebhookDeliveryError, EMAIL_ATTACHMENT_MAX_BYTES, EMAIL_ATTACHMENT_MAX_COUNT, EMAIL_DRIVER, type EmailAttachment, type EmailDriver, type EmailDriverPort, INTRUSIVE_CHANNELS, InvalidWebhookSignatureError, type ListNotificationsParams, type ListNotificationsQuery, type ListNotificationsResult, type LogMeta, type LoggerPort, type MetricsPort, NOTIFICATION_CATEGORY_HINT, NOTIFICATION_CHANNEL, NOTIFICATION_ERROR_CODES, NOTIFICATION_EVENT, NOTIFICATION_STATUS, type NotificationCategoryPolicy, type NotificationChannel, type NotificationCreatedEvent, type NotificationDispatchedEvent, NotificationError, type NotificationEvent, type NotificationHooks, type NotificationId, type NotificationJob, NotificationNotFoundError, type NotificationPreference, type NotificationReadEvent, type NotificationStatus, type NotificationSummary, type NotificationTemplate, PREVIEW_VIEWPORT, PREVIEW_VIEWPORT_BY_CHANNEL, PUSH_DRIVER, type PreferencesUpdatedEvent, type PreviewViewport, type PreviewViewportSpec, type PushDriver, type PushDriverPort, type QueuePort, type RealtimeEvent, type RealtimeNotifierPort, type RealtimeSubscription, type RecipientResolverPort, RecipientUnresolvedError, type RegisterDeviceBody, type RenderTemplateParams, type RenderedTemplate, type RenderedTemplatePreview, type ResolvedRecipient, SUPPRESSION_REASON, type SendEmailParams, type SendNotificationBody, type SendNotificationParams, type SendNotificationResult, type SendPushParams, type SendSmsParams, type SendWhatsAppParams, type SendWhatsAppTemplateParams, type SmsDriverPort, SuppressedTargetError, type SuppressionReason, TEMPLATE_CONSTRAINTS_BY_CHANNEL, TEMPLATE_VARIABLE_KIND, type TemplateConstraintCheck, type TemplateConstraintField, type TemplateConstraintLimits, TemplateIdNotFoundError, TemplateNotFoundError, type TemplateRendererPort, type TemplateVariableCatalog, type TemplateVariableDefinition, type TemplateVariableDiff, type TemplateVariableKind, ThrottledError, UnknownTemplateVariablesError, type UpdateCategoryPoliciesBody, type UpdatePreferencesBody, type UpsertTemplateBody, type UserId, type WhatsAppDriverPort, type WhatsAppSendingChannel, buildPreviewPayload, categoryPolicyEntrySchema, checkEmailAttachment, createWhatsAppDriverFromChannel, deliveryWebhookSchema, deriveTitleFromBody, diffTemplateVariables, escapeTemplateHtml, extractTemplatePlaceholders, interpolateTemplate, listNotificationsQuerySchema, preferenceEntrySchema, registerDeviceSchema, renderTemplate, sendNotificationSchema, updateCategoryPoliciesSchema, updatePreferencesSchema, upsertTemplateSchema };
package/dist/index.d.ts CHANGED
@@ -13,6 +13,15 @@ declare const NOTIFICATION_CHANNEL: {
13
13
  type NotificationChannel = (typeof NOTIFICATION_CHANNEL)[keyof typeof NOTIFICATION_CHANNEL];
14
14
  /** Canais que interrompem o destinatário e por isso respeitam quiet hours (ver spec §10.4). */
15
15
  declare const INTRUSIVE_CHANNELS: readonly NotificationChannel[];
16
+ /**
17
+ * O teto de canais da empresa por categoria, acima da preferência do usuário. Linha ausente
18
+ * significa permitido — fechar por omissão calaria toda categoria existente.
19
+ */
20
+ type NotificationCategoryPolicy = {
21
+ readonly category: string;
22
+ readonly channel: NotificationChannel;
23
+ readonly enabled: boolean;
24
+ };
16
25
  declare const NOTIFICATION_STATUS: {
17
26
  readonly PENDING: "pending";
18
27
  readonly SCHEDULED: "scheduled";
@@ -173,22 +182,48 @@ type DeliveryReceipt = {
173
182
 
174
183
  /**
175
184
  * Copyright (c) 2026 Ada Technology. MIT License.
185
+ *
186
+ * Anexo de e-mail — por REFERÊNCIA, nunca por conteúdo.
187
+ *
188
+ * O template é linha versionada no Postgres e o job é payload no Redis. Um PDF em qualquer um dos
189
+ * dois é blob replicado a cada versão e a cada tentativa, e uma nota fiscal é dado pessoal — o
190
+ * `security.md` §6 já manda o payload de fila carregar referência, e o §7 manda entregar arquivo por
191
+ * URL assinada de vida curta. Anexo segue a mesma regra: o que trafega é onde o arquivo está.
192
+ *
193
+ * Quem baixa é o DRIVER, no momento do envio, e é ele que aplica o teto de tamanho. Baixar antes
194
+ * (no módulo) seria carregar bytes na memória de um processo que pode nem chegar a enviar.
176
195
  */
177
-
178
196
  /**
179
- * Resultado de UMA tentativa de entrega, classificado **pelo driver** — nunca pelo módulo.
180
- *
181
- * Só o driver sabe que `DeviceNotRegistered` (Expo) e `registration-token-not-registered` (FCM)
182
- * significam "apaga o token", e que 429/5xx significa "tenta de novo". Deixar essa leitura no
183
- * módulo o obrigaria a conhecer o vocabulário de erro de cada provedor — e foi assim que, no
184
- * modelo antigo, token morto ficava vivo para sempre e erro permanente entrava em retry infinito.
197
+ * 25MB é o teto prático: Gmail e Outlook recusam acima disso, e o SES conta o MIME inteiro já em
198
+ * base64 — que infla ~33%. O driver reprova ANTES de montar a mensagem, senão o erro vem do
199
+ * provedor como uma falha genérica de envio.
200
+ */
201
+ declare const EMAIL_ATTACHMENT_MAX_BYTES: number;
202
+ /** Um e-mail com trinta anexos é engano de laço, não um caso de uso. */
203
+ declare const EMAIL_ATTACHMENT_MAX_COUNT = 10;
204
+ type EmailAttachment = {
205
+ /** O nome que o destinatário vê. Sem caminho: `../` num nome de anexo é travessia de diretório. */
206
+ readonly filename: string;
207
+ /**
208
+ * URL de onde o driver baixa no momento do envio. Assinada e de vida curta quando o arquivo for
209
+ * privado — o driver não autentica, ele só faz `GET`.
210
+ */
211
+ readonly url: string;
212
+ /** Declarado pelo produto, e não adivinhado da extensão: extensão mente, e cliente de e-mail confia. */
213
+ readonly contentType: string;
214
+ };
215
+ /**
216
+ * Recusa o que não pode virar anexo antes de qualquer rede.
185
217
  *
186
- * O módulo age sobre o discriminante:
187
- * - `sent` grava `providerMessageId`;
188
- * - `invalid_target` desativa o device ou cria supressão, **sem** retry;
189
- * - `retriable` reagenda com backoff exponencial + jitter até esgotar `attempts`;
190
- * - `permanent` finaliza como `failed` na primeira tentativa.
218
+ * Devolve o motivo em vez de lançar: o chamador é um driver, e uma tentativa de entrega registra o
219
+ * porquê da recusa na `delivery` — `throw` viraria erro genérico e o operador ficaria sem a causa.
220
+ */
221
+ declare function checkEmailAttachment(attachment: EmailAttachment): string | undefined;
222
+
223
+ /**
224
+ * Copyright (c) 2026 Ada Technology. MIT License.
191
225
  */
226
+
192
227
  type DeliveryAttemptResult = {
193
228
  readonly outcome: 'sent';
194
229
  readonly providerMessageId?: string;
@@ -222,6 +257,11 @@ type SendEmailParams = {
222
257
  readonly html: string;
223
258
  readonly text: string;
224
259
  readonly replyTo?: string;
260
+ /**
261
+ * Anexos por REFERÊNCIA: o driver baixa de `url` no momento do envio. Ver `emailAttachment.ts`
262
+ * para por que o conteúdo não trafega aqui.
263
+ */
264
+ readonly attachments?: readonly EmailAttachment[];
225
265
  /** Correlaciona o recibo assíncrono (bounce/complaint) com a `delivery` que o originou. */
226
266
  readonly idempotencyKey?: string;
227
267
  };
@@ -558,6 +598,59 @@ declare const updatePreferencesSchema: z.ZodObject<{
558
598
  }[];
559
599
  }>;
560
600
  type UpdatePreferencesBody = z.infer<typeof updatePreferencesSchema>;
601
+ declare const categoryPolicyEntrySchema: z.ZodObject<{
602
+ category: z.ZodString;
603
+ channel: z.ZodNativeEnum<{
604
+ readonly INBOX: "inbox";
605
+ readonly PUSH: "push";
606
+ readonly EMAIL: "email";
607
+ readonly WHATSAPP: "whatsapp";
608
+ readonly SMS: "sms";
609
+ }>;
610
+ enabled: z.ZodBoolean;
611
+ }, "strip", z.ZodTypeAny, {
612
+ category: string;
613
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
614
+ enabled: boolean;
615
+ }, {
616
+ category: string;
617
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
618
+ enabled: boolean;
619
+ }>;
620
+ declare const updateCategoryPoliciesSchema: z.ZodObject<{
621
+ policies: z.ZodArray<z.ZodObject<{
622
+ category: z.ZodString;
623
+ channel: z.ZodNativeEnum<{
624
+ readonly INBOX: "inbox";
625
+ readonly PUSH: "push";
626
+ readonly EMAIL: "email";
627
+ readonly WHATSAPP: "whatsapp";
628
+ readonly SMS: "sms";
629
+ }>;
630
+ enabled: z.ZodBoolean;
631
+ }, "strip", z.ZodTypeAny, {
632
+ category: string;
633
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
634
+ enabled: boolean;
635
+ }, {
636
+ category: string;
637
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
638
+ enabled: boolean;
639
+ }>, "many">;
640
+ }, "strip", z.ZodTypeAny, {
641
+ policies: {
642
+ category: string;
643
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
644
+ enabled: boolean;
645
+ }[];
646
+ }, {
647
+ policies: {
648
+ category: string;
649
+ channel: "inbox" | "push" | "email" | "whatsapp" | "sms";
650
+ enabled: boolean;
651
+ }[];
652
+ }>;
653
+ type UpdateCategoryPoliciesBody = z.infer<typeof updateCategoryPoliciesSchema>;
561
654
  declare const upsertTemplateSchema: z.ZodObject<{
562
655
  key: z.ZodString;
563
656
  channel: z.ZodNativeEnum<{
@@ -762,7 +855,25 @@ declare const NOTIFICATION_ERROR_CODES: {
762
855
  readonly DEVICE_NOT_FOUND: "NOTIFICATION_DEVICE_NOT_FOUND";
763
856
  readonly THROTTLED: "NOTIFICATION_THROTTLED";
764
857
  readonly CONFIG_MISSING: "NOTIFICATION_CONFIG_MISSING";
858
+ readonly TEMPLATE_UNKNOWN_VARIABLE: "NOTIFICATION_TEMPLATE_UNKNOWN_VARIABLE";
765
859
  };
860
+ /** Busca por id, e não por identidade — o painel remove pela linha que listou. */
861
+ declare class TemplateIdNotFoundError extends NotificationError {
862
+ readonly templateId: string;
863
+ constructor(templateId: string);
864
+ }
865
+ /**
866
+ * O template referencia `{{campo}}` que o produto não promete enviar. Renderizaria vazio para
867
+ * sempre, sem log e sem erro — daí ser recusa na gravação, e não aviso.
868
+ *
869
+ * `details.fields` traz TODAS as desconhecidas, não a primeira: corrigir uma por vez transforma o
870
+ * salvamento em tentativa e erro (`apis.md`, Validação).
871
+ */
872
+ declare class UnknownTemplateVariablesError extends NotificationError {
873
+ readonly templateKey: string;
874
+ readonly fields: readonly string[];
875
+ constructor(templateKey: string, fields: readonly string[]);
876
+ }
766
877
  declare class TemplateNotFoundError extends NotificationError {
767
878
  readonly templateKey: string;
768
879
  readonly channel: NotificationChannel;
@@ -850,6 +961,43 @@ type WhatsAppSendingChannel = {
850
961
  };
851
962
  declare function createWhatsAppDriverFromChannel(channel: WhatsAppSendingChannel): WhatsAppDriverPort;
852
963
 
964
+ /**
965
+ * Copyright (c) 2026 Ada Technology. MIT License.
966
+ *
967
+ * Larguras e limites do preview, por canal.
968
+ *
969
+ * Moram aqui, e não no CSS da UI, porque o host que consome a camada headless precisa deles para
970
+ * desenhar o próprio preview — e porque o limite de caracteres não é decoração de tela: ele é a
971
+ * regra do canal, e o editor avisa com ela antes de salvar.
972
+ */
973
+
974
+ declare const PREVIEW_VIEWPORT: {
975
+ readonly DESKTOP: "desktop";
976
+ readonly MOBILE: "mobile";
977
+ };
978
+ type PreviewViewport = (typeof PREVIEW_VIEWPORT)[keyof typeof PREVIEW_VIEWPORT];
979
+ type PreviewViewportSpec = {
980
+ readonly viewport: PreviewViewport;
981
+ readonly width: number;
982
+ };
983
+ /**
984
+ * `email` em 600px é a largura clássica de corpo de e-mail; os demais aproximam o container em que
985
+ * a mensagem aparece no desktop. `sms` não tem desktop — a mensagem é a mesma no aparelho e ponto.
986
+ */
987
+ declare const PREVIEW_VIEWPORT_BY_CHANNEL: Readonly<Record<NotificationChannel, readonly PreviewViewportSpec[]>>;
988
+ type TemplateConstraintField = 'title' | 'body';
989
+ type TemplateConstraintLimits = {
990
+ readonly title?: number;
991
+ readonly body?: number;
992
+ };
993
+ /**
994
+ * Onde o canal corta de verdade. `email.title` são os ~78 caracteres que a lista da caixa de
995
+ * entrada mostra no celular; `push` segue o teto prático do Android; `sms` é o segmento de 160,
996
+ * depois do qual a operadora cobra outra mensagem; `whatsapp.body` é o teto de corpo de template
997
+ * da Meta. `inbox` acompanha o `deriveTitleFromBody`.
998
+ */
999
+ declare const TEMPLATE_CONSTRAINTS_BY_CHANNEL: Readonly<Record<NotificationChannel, TemplateConstraintLimits>>;
1000
+
853
1001
  /**
854
1002
  * Copyright (c) 2026 Ada Technology. MIT License.
855
1003
  *
@@ -863,16 +1011,29 @@ declare function createWhatsAppDriverFromChannel(channel: WhatsAppSendingChannel
863
1011
  * Com a função aqui, o `notification-module` renderiza para enviar e a UI renderiza para mostrar,
864
1012
  * lendo o MESMO código. Divergência deixa de ser possível em vez de ser improvável.
865
1013
  */
1014
+
866
1015
  declare function escapeTemplateHtml(text: string): string;
867
1016
  /** `{{campo}}` → valor do payload. Campo ausente vira string vazia, nunca o literal `{{campo}}`. */
868
1017
  declare function interpolateTemplate(template: string, payload: Readonly<Record<string, unknown>>): string;
869
1018
  declare function deriveTitleFromBody(body: string): string;
870
1019
  /** Os nomes de campo que um template referencia — o que a tela de configuração precisa pedir. */
871
1020
  declare function extractTemplatePlaceholders(template: string): readonly string[];
1021
+ type TemplateConstraintCheck = {
1022
+ readonly field: TemplateConstraintField;
1023
+ readonly limit: number;
1024
+ readonly actual: number;
1025
+ readonly exceeded: boolean;
1026
+ };
872
1027
  type RenderedTemplatePreview = {
873
1028
  readonly title: string;
874
1029
  readonly body: string;
875
1030
  readonly html?: string;
1031
+ /**
1032
+ * O que o canal corta. Vazio quando o canal não declara limite. O editor usa isto para avisar
1033
+ * antes de salvar, e o preview para marcar onde o texto some — sem isso, dois quadros de
1034
+ * larguras diferentes só provariam que CSS quebra linha.
1035
+ */
1036
+ readonly constraints: readonly TemplateConstraintCheck[];
876
1037
  };
877
1038
  /**
878
1039
  * Mesma saída que o envio produz. `channel` importa porque só e-mail ganha a versão HTML — mostrar
@@ -885,4 +1046,77 @@ declare function renderTemplate(params: {
885
1046
  readonly payload: Readonly<Record<string, unknown>>;
886
1047
  }): RenderedTemplatePreview;
887
1048
 
888
- export { type CachePort, type ChannelDrivers, ChannelNotConfiguredError, type ClockPort, type CompanyId, ConfigMissingError, DELIVERY_STATUS, DEVICE_PLATFORM, type DeliveryAttemptResult, type DeliveryBouncedEvent, type DeliveryFailedEvent, type DeliveryReceipt, type DeliverySentEvent, type DeliveryStatus, type DeliverySummary, type DeliveryWebhookBody, type DeviceInvalidatedEvent, DeviceNotFoundError, type DevicePlatform, type DeviceRegisteredEvent, type DeviceRegistration, DuplicateWebhookDeliveryError, EMAIL_DRIVER, type EmailDriver, type EmailDriverPort, INTRUSIVE_CHANNELS, InvalidWebhookSignatureError, type ListNotificationsParams, type ListNotificationsQuery, type ListNotificationsResult, type LogMeta, type LoggerPort, type MetricsPort, NOTIFICATION_CATEGORY_HINT, NOTIFICATION_CHANNEL, NOTIFICATION_ERROR_CODES, NOTIFICATION_EVENT, NOTIFICATION_STATUS, type NotificationChannel, type NotificationCreatedEvent, type NotificationDispatchedEvent, NotificationError, type NotificationEvent, type NotificationHooks, type NotificationId, type NotificationJob, NotificationNotFoundError, type NotificationPreference, type NotificationReadEvent, type NotificationStatus, type NotificationSummary, type NotificationTemplate, PUSH_DRIVER, type PreferencesUpdatedEvent, type PushDriver, type PushDriverPort, type QueuePort, type RealtimeEvent, type RealtimeNotifierPort, type RealtimeSubscription, type RecipientResolverPort, RecipientUnresolvedError, type RegisterDeviceBody, type RenderTemplateParams, type RenderedTemplate, type RenderedTemplatePreview, type ResolvedRecipient, SUPPRESSION_REASON, type SendEmailParams, type SendNotificationBody, type SendNotificationParams, type SendNotificationResult, type SendPushParams, type SendSmsParams, type SendWhatsAppParams, type SendWhatsAppTemplateParams, type SmsDriverPort, SuppressedTargetError, type SuppressionReason, TemplateNotFoundError, type TemplateRendererPort, ThrottledError, type UpdatePreferencesBody, type UpsertTemplateBody, type UserId, type WhatsAppDriverPort, type WhatsAppSendingChannel, createWhatsAppDriverFromChannel, deliveryWebhookSchema, deriveTitleFromBody, escapeTemplateHtml, extractTemplatePlaceholders, interpolateTemplate, listNotificationsQuerySchema, preferenceEntrySchema, registerDeviceSchema, renderTemplate, sendNotificationSchema, updatePreferencesSchema, upsertTemplateSchema };
1049
+ /**
1050
+ * Copyright (c) 2026 Ada Technology. MIT License.
1051
+ *
1052
+ * O catálogo de variáveis de um template, e a diferença entre o que ele declara e o que o texto
1053
+ * usa.
1054
+ *
1055
+ * Existe porque `{{campo}}` desconhecido não falha: `interpolateTemplate` devolve string vazia, que
1056
+ * é o comportamento correto no envio — mensagem com buraco é melhor que mensagem com `{{campo}}`
1057
+ * cru. O preço é que um erro de digitação no painel some sem log e sem erro, e só aparece quando o
1058
+ * cliente recebe "Olá , seu pedido". Com um painel, isso deixa de ser raro.
1059
+ *
1060
+ * A função é pura e mora aqui, e não no módulo, pelo mesmo motivo do `renderTemplate`: a validação
1061
+ * do servidor e o aviso da tela precisam da MESMA regra, e o frontend não pode importar o módulo
1062
+ * (carrega Drizzle). Duas implementações divergiriam, e a tela passaria a aprovar o que a rota
1063
+ * recusa.
1064
+ */
1065
+ /**
1066
+ * `text` entra no corpo por interpolação; `attachment` NÃO — ele viaja ao lado da mensagem.
1067
+ *
1068
+ * A distinção existe porque as duas regras de validação são opostas: variável de texto declarada e
1069
+ * ausente do corpo é um aviso, e variável de anexo ausente do corpo é o normal. Sem o tipo, todo
1070
+ * anexo obrigatório apareceria eternamente como "faltando no texto".
1071
+ */
1072
+ declare const TEMPLATE_VARIABLE_KIND: {
1073
+ readonly TEXT: "text";
1074
+ readonly ATTACHMENT: "attachment";
1075
+ };
1076
+ type TemplateVariableKind = (typeof TEMPLATE_VARIABLE_KIND)[keyof typeof TEMPLATE_VARIABLE_KIND];
1077
+ type TemplateVariableDefinition = {
1078
+ readonly name: string;
1079
+ /** Ausente é `text`: todo catálogo escrito antes disto continua valendo sem alteração. */
1080
+ readonly kind?: TemplateVariableKind;
1081
+ /** Valor de exemplo — alimenta o preview. Só o produto sabe que `orderNumber` é "QC-1042". */
1082
+ readonly example: string;
1083
+ /** `true` avisa quando o texto não usa a variável; nunca bloqueia (ver `diffTemplateVariables`). */
1084
+ readonly required: boolean;
1085
+ /** Chave de i18n do rótulo na tela. Ausente, a tela mostra o próprio `name`. */
1086
+ readonly labelKey?: string;
1087
+ };
1088
+ /** `templateKey` → variáveis que o produto promete enviar no payload daquela notificação. */
1089
+ type TemplateVariableCatalog = Readonly<Record<string, readonly TemplateVariableDefinition[]>>;
1090
+ type TemplateVariableDiff = {
1091
+ /** Placeholders que o texto referencia, na ordem em que aparecem. */
1092
+ readonly used: readonly string[];
1093
+ /** Referenciados e não declarados — renderizariam vazio para sempre. */
1094
+ readonly unknown: readonly string[];
1095
+ /** Declarados como `required` e ausentes do texto. Só variáveis de texto entram aqui. */
1096
+ readonly missingRequired: readonly string[];
1097
+ /**
1098
+ * Anexos referenciados DENTRO do texto — quase sempre engano.
1099
+ *
1100
+ * `{{nota}}` no corpo de um anexo renderiza a URL crua no meio da frase, e não anexa nada. Se a
1101
+ * intenção era mandar o link, a variável devia ser de texto; se era anexar, ela não pertence ao
1102
+ * corpo. Aviso e não erro: link para o arquivo é uma escolha legítima, só não é esta.
1103
+ */
1104
+ readonly attachmentsInText: readonly string[];
1105
+ };
1106
+ type DiffTemplateVariablesParams = {
1107
+ readonly body: string;
1108
+ readonly subject?: string | undefined;
1109
+ /**
1110
+ * Ausente significa catálogo não declarado para esta `key`, e não catálogo vazio: nesse caso
1111
+ * nada é desconhecido. Fechar por omissão quebraria todo host que já usa o módulo sem catálogo.
1112
+ */
1113
+ readonly variables?: readonly TemplateVariableDefinition[] | undefined;
1114
+ };
1115
+ declare function diffTemplateVariables(params: DiffTemplateVariablesParams): TemplateVariableDiff;
1116
+ /**
1117
+ * O payload de preview sai do próprio catálogo. Um mapa `key → exemplo` mantido em paralelo
1118
+ * divergiria do catálogo na primeira variável nova, e o preview voltaria a mentir.
1119
+ */
1120
+ declare function buildPreviewPayload(variables: readonly TemplateVariableDefinition[] | undefined): Readonly<Record<string, string>>;
1121
+
1122
+ export { type CachePort, type ChannelDrivers, ChannelNotConfiguredError, type ClockPort, type CompanyId, ConfigMissingError, DELIVERY_STATUS, DEVICE_PLATFORM, type DeliveryAttemptResult, type DeliveryBouncedEvent, type DeliveryFailedEvent, type DeliveryReceipt, type DeliverySentEvent, type DeliveryStatus, type DeliverySummary, type DeliveryWebhookBody, type DeviceInvalidatedEvent, DeviceNotFoundError, type DevicePlatform, type DeviceRegisteredEvent, type DeviceRegistration, type DiffTemplateVariablesParams, DuplicateWebhookDeliveryError, EMAIL_ATTACHMENT_MAX_BYTES, EMAIL_ATTACHMENT_MAX_COUNT, EMAIL_DRIVER, type EmailAttachment, type EmailDriver, type EmailDriverPort, INTRUSIVE_CHANNELS, InvalidWebhookSignatureError, type ListNotificationsParams, type ListNotificationsQuery, type ListNotificationsResult, type LogMeta, type LoggerPort, type MetricsPort, NOTIFICATION_CATEGORY_HINT, NOTIFICATION_CHANNEL, NOTIFICATION_ERROR_CODES, NOTIFICATION_EVENT, NOTIFICATION_STATUS, type NotificationCategoryPolicy, type NotificationChannel, type NotificationCreatedEvent, type NotificationDispatchedEvent, NotificationError, type NotificationEvent, type NotificationHooks, type NotificationId, type NotificationJob, NotificationNotFoundError, type NotificationPreference, type NotificationReadEvent, type NotificationStatus, type NotificationSummary, type NotificationTemplate, PREVIEW_VIEWPORT, PREVIEW_VIEWPORT_BY_CHANNEL, PUSH_DRIVER, type PreferencesUpdatedEvent, type PreviewViewport, type PreviewViewportSpec, type PushDriver, type PushDriverPort, type QueuePort, type RealtimeEvent, type RealtimeNotifierPort, type RealtimeSubscription, type RecipientResolverPort, RecipientUnresolvedError, type RegisterDeviceBody, type RenderTemplateParams, type RenderedTemplate, type RenderedTemplatePreview, type ResolvedRecipient, SUPPRESSION_REASON, type SendEmailParams, type SendNotificationBody, type SendNotificationParams, type SendNotificationResult, type SendPushParams, type SendSmsParams, type SendWhatsAppParams, type SendWhatsAppTemplateParams, type SmsDriverPort, SuppressedTargetError, type SuppressionReason, TEMPLATE_CONSTRAINTS_BY_CHANNEL, TEMPLATE_VARIABLE_KIND, type TemplateConstraintCheck, type TemplateConstraintField, type TemplateConstraintLimits, TemplateIdNotFoundError, TemplateNotFoundError, type TemplateRendererPort, type TemplateVariableCatalog, type TemplateVariableDefinition, type TemplateVariableDiff, type TemplateVariableKind, ThrottledError, UnknownTemplateVariablesError, type UpdateCategoryPoliciesBody, type UpdatePreferencesBody, type UpsertTemplateBody, type UserId, type WhatsAppDriverPort, type WhatsAppSendingChannel, buildPreviewPayload, categoryPolicyEntrySchema, checkEmailAttachment, createWhatsAppDriverFromChannel, deliveryWebhookSchema, deriveTitleFromBody, diffTemplateVariables, escapeTemplateHtml, extractTemplatePlaceholders, interpolateTemplate, listNotificationsQuerySchema, preferenceEntrySchema, registerDeviceSchema, renderTemplate, sendNotificationSchema, updateCategoryPoliciesSchema, updatePreferencesSchema, upsertTemplateSchema };