@easybits.cloud/mailmask 0.4.2 → 0.4.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.cjs CHANGED
@@ -75,6 +75,9 @@ var MailMask = class {
75
75
  this.members = new MembersResource(req);
76
76
  this.signature = new SignatureResource(req);
77
77
  this.canned = new CannedResource(req);
78
+ this.account = new AccountResource(req);
79
+ this.inbox = new InboxResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
80
+ this.referrals = new ReferralsResource(req);
78
81
  }
79
82
  };
80
83
  var DomainsResource = class {
@@ -103,6 +106,19 @@ var DomainsResource = class {
103
106
  dnsSetup(id, opts) {
104
107
  return this.req(`/api/domains/${id}/dns-setup${opts?.live ? "?live=1" : ""}`);
105
108
  }
109
+ /** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
110
+ setLogo(id, file, filename = "logo") {
111
+ const form = new FormData();
112
+ form.append("file", file, filename);
113
+ return this.req(`/api/domains/${id}/logo`, { method: "POST", body: form });
114
+ }
115
+ /** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
116
+ setLogoFromUrl(id, url) {
117
+ return this.req(`/api/domains/${id}/logo`, { method: "POST", body: JSON.stringify({ fromUrl: url }) });
118
+ }
119
+ removeLogo(id) {
120
+ return this.req(`/api/domains/${id}/logo`, { method: "DELETE" });
121
+ }
106
122
  };
107
123
  var DnsResource = class {
108
124
  constructor(req) {
@@ -223,6 +239,10 @@ var AttachmentsResource = class {
223
239
  form.append("file", blob, input.filename);
224
240
  return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: form });
225
241
  }
242
+ /** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
243
+ uploadFromUrl(domainId, url, filename) {
244
+ return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: JSON.stringify({ fromUrl: url, filename }) });
245
+ }
226
246
  };
227
247
  var SuppressionsResource = class {
228
248
  constructor(req) {
@@ -305,7 +325,19 @@ var BillingResource = class {
305
325
  * El usuario la abre y paga; hasta entonces no cambia nada.
306
326
  */
307
327
  checkout(domainId, kind = "domain", opts) {
308
- return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail }) });
328
+ return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail, period: opts?.period }) });
329
+ }
330
+ /** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
331
+ cancelAddon(addonId) {
332
+ return this.req(`/api/addons/${addonId}/cancel`, { method: "POST" });
333
+ }
334
+ /** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
335
+ orders(opts) {
336
+ const qs = new URLSearchParams();
337
+ if (opts?.limit) qs.set("limit", String(opts.limit));
338
+ if (opts?.before) qs.set("before", opts.before);
339
+ const q = qs.toString();
340
+ return this.req(`/api/billing/orders${q ? `?${q}` : ""}`);
309
341
  }
310
342
  };
311
343
  var RegistrationsResource = class {
@@ -333,6 +365,10 @@ var RegistrationsResource = class {
333
365
  renewal(regId, opts) {
334
366
  return this.req(`/api/domains/registrations/${regId}/renewal`, { method: "POST", body: JSON.stringify({ payerEmail: opts?.payerEmail }) });
335
367
  }
368
+ /** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
369
+ cancelRenewal(regId) {
370
+ return this.req(`/api/domains/registrations/${regId}/renewal/cancel`, { method: "POST" });
371
+ }
336
372
  };
337
373
  var TransfersResource = class {
338
374
  constructor(req) {
@@ -400,6 +436,102 @@ var CannedResource = class {
400
436
  return this.req(`/api/domains/${domainId}/canned/${cannedId}`, { method: "DELETE" });
401
437
  }
402
438
  };
439
+ var AccountResource = class {
440
+ constructor(req) {
441
+ this.req = req;
442
+ }
443
+ getProfile() {
444
+ return this.req("/api/profile");
445
+ }
446
+ /** Nombre visible (máx. 60 caracteres). Cadena vacía lo borra. */
447
+ updateProfile(input) {
448
+ return this.req("/api/profile", { method: "PUT", body: JSON.stringify(input) });
449
+ }
450
+ /** Foto desde un adjunto que el usuario subió al asistente (URL firmada de `/api/asistente/files/*`). */
451
+ setAvatarFromUrl(url) {
452
+ return this.req("/api/profile/avatar", { method: "POST", body: JSON.stringify({ fromUrl: url }) });
453
+ }
454
+ /** Foto desde bytes (PNG, JPG o WebP; máx. 2 MB). */
455
+ setAvatar(file, filename = "avatar") {
456
+ const form = new FormData();
457
+ form.append("file", file, filename);
458
+ return this.req("/api/profile/avatar", { method: "POST", body: form });
459
+ }
460
+ removeAvatar() {
461
+ return this.req("/api/profile/avatar", { method: "DELETE" });
462
+ }
463
+ };
464
+ var InboxResource = class {
465
+ constructor(req, raw) {
466
+ this.req = req;
467
+ this.raw = raw;
468
+ }
469
+ list(domainId, opts) {
470
+ const qs = new URLSearchParams({ domainId });
471
+ for (const [k, v] of Object.entries(opts ?? {})) if (v !== void 0 && v !== "") qs.set(k, String(v));
472
+ return this.req(`/api/bandeja/conversations?${qs}`);
473
+ }
474
+ /** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
475
+ get(domainId, conversationId, opts) {
476
+ const qs = new URLSearchParams({ domainId });
477
+ if (opts?.before) qs.set("before", opts.before);
478
+ return this.req(`/api/bandeja/conversations/${conversationId}?${qs}`);
479
+ }
480
+ /** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
481
+ compose(domainId, input) {
482
+ return this.req("/api/bandeja/conversations", { method: "POST", body: JSON.stringify({ ...input, domainId }) });
483
+ }
484
+ /** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
485
+ reply(domainId, conversationId, input) {
486
+ return this.req(`/api/bandeja/conversations/${conversationId}/reply`, { method: "POST", body: JSON.stringify({ ...input, domainId }) });
487
+ }
488
+ update(domainId, conversationId, input) {
489
+ return this.req(`/api/bandeja/conversations/${conversationId}`, { method: "PATCH", body: JSON.stringify({ ...input, domainId }) });
490
+ }
491
+ markRead(domainId, conversationId) {
492
+ return this.req(`/api/bandeja/conversations/${conversationId}/read`, { method: "POST", body: JSON.stringify({ domainId }) });
493
+ }
494
+ /** Sin `assignedTo` la deja sin asignar. */
495
+ assign(domainId, conversationId, assignedTo) {
496
+ return this.req(`/api/bandeja/conversations/${conversationId}/assign`, { method: "POST", body: JSON.stringify({ domainId, assignedTo }) });
497
+ }
498
+ /** Nota interna: la ve el equipo, nunca el contacto. */
499
+ addNote(domainId, conversationId, body) {
500
+ return this.req(`/api/bandeja/conversations/${conversationId}/note`, { method: "POST", body: JSON.stringify({ domainId, body }) });
501
+ }
502
+ /** A la papelera (se puede restaurar). Máx. 200 por llamada. */
503
+ delete(domainId, conversationIds) {
504
+ return this.req("/api/bandeja/conversations/bulk-delete", { method: "POST", body: JSON.stringify({ domainId, ids: conversationIds }) });
505
+ }
506
+ restore(domainId, conversationId) {
507
+ return this.req(`/api/bandeja/conversations/${conversationId}/restore`, { method: "POST", body: JSON.stringify({ domainId }) });
508
+ }
509
+ metrics(domainId, opts) {
510
+ const qs = new URLSearchParams({ domainId });
511
+ if (opts?.days) qs.set("days", String(opts.days));
512
+ return this.req(`/api/bandeja/metrics?${qs}`);
513
+ }
514
+ /** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
515
+ attachment(domainId, conversationId, messageId, index) {
516
+ return this.raw(`/api/bandeja/conversations/${conversationId}/attachments/${messageId}/${index}?domainId=${encodeURIComponent(domainId)}`);
517
+ }
518
+ };
519
+ var ReferralsResource = class {
520
+ constructor(req) {
521
+ this.req = req;
522
+ }
523
+ get() {
524
+ return this.req("/api/referrals");
525
+ }
526
+ /** 3-30 caracteres: minúsculas, números y guiones. */
527
+ setSlug(slug) {
528
+ return this.req("/api/referrals/slug", { method: "PUT", body: JSON.stringify({ slug }) });
529
+ }
530
+ /** Nombre que ven los invitados (2-40 caracteres). */
531
+ setName(name) {
532
+ return this.req("/api/referrals/name", { method: "PUT", body: JSON.stringify({ name }) });
533
+ }
534
+ };
403
535
 
404
536
  // src/verify.ts
405
537
  function hex(buf) {
package/dist/index.d.cts CHANGED
@@ -494,6 +494,9 @@ interface DomainMember {
494
494
  name: string;
495
495
  role: "admin" | "agent";
496
496
  createdAt: string;
497
+ /** Del perfil de su cuenta de MailMask, si lo llenó. */
498
+ displayName?: string | null;
499
+ avatarUrl?: string | null;
497
500
  }
498
501
  interface DomainInvite {
499
502
  token: string;
@@ -511,6 +514,146 @@ interface CannedReply {
511
514
  body: string;
512
515
  createdAt: string;
513
516
  }
517
+ /** Perfil de la cuenta de MailMask (el usuario, no una máscara). */
518
+ interface AccountProfile {
519
+ email: string;
520
+ displayName: string | null;
521
+ /** Ruta relativa al host de MailMask (`/api/avatar/...`), o null sin foto. */
522
+ avatarUrl: string | null;
523
+ }
524
+ type InboxStatus = "open" | "snoozed" | "closed";
525
+ interface InboxConversation {
526
+ id: string;
527
+ domainId: string;
528
+ /** El contacto externo (en un hilo que inició el dominio, el destinatario). */
529
+ from: string;
530
+ /** La máscara del dominio por la que va el hilo (`ventas@tudominio.com`). */
531
+ to: string;
532
+ subject: string;
533
+ status: InboxStatus;
534
+ assignedTo?: string;
535
+ priority: "normal" | "urgent";
536
+ lastMessageAt: string;
537
+ messageCount: number;
538
+ tags: string[];
539
+ deletedAt?: string;
540
+ snoozedUntil?: string;
541
+ /** Para quien pregunta: hay mensajes que no ha visto. */
542
+ unread?: boolean;
543
+ /** Sólo en búsqueda: fragmento con la coincidencia. */
544
+ snippet?: string;
545
+ [k: string]: unknown;
546
+ }
547
+ interface InboxListOptions {
548
+ /** `open`, `snoozed`, `closed`, `unread` (de quien pregunta) o `deleted` (papelera). */
549
+ status?: InboxStatus | "unread" | "deleted";
550
+ /** Dirección completa de la máscara (`ventas@tudominio.com`). */
551
+ to?: string;
552
+ assignedTo?: string;
553
+ /** Búsqueda en asunto, remitente y cuerpo. Con `q` no hay paginación (tope 50). */
554
+ q?: string;
555
+ /** Máx. 100. */
556
+ limit?: number;
557
+ cursor?: string;
558
+ }
559
+ interface InboxPage {
560
+ items: InboxConversation[];
561
+ nextCursor: string | null;
562
+ /** Máscaras con conversaciones (sólo en la primera página). */
563
+ aliases?: string[];
564
+ mode: "list" | "search" | "search-degraded";
565
+ unreadCount?: number;
566
+ [k: string]: unknown;
567
+ }
568
+ interface InboxAttachment {
569
+ index: number;
570
+ filename: string;
571
+ contentType: string;
572
+ size: number;
573
+ }
574
+ interface InboxMessage {
575
+ id: string;
576
+ conversationId: string;
577
+ from: string;
578
+ /** Texto plano. */
579
+ body?: string;
580
+ html?: string;
581
+ direction: "inbound" | "outbound";
582
+ createdAt: string;
583
+ messageId?: string;
584
+ deliveryStatus?: "sent" | "delivered" | "bounced" | "complained";
585
+ attachments?: InboxAttachment[];
586
+ /** El original ya no está (retención de 90 días o pérdida): `body` puede venir del índice. */
587
+ bodyDegraded?: string;
588
+ }
589
+ interface InboxNote {
590
+ id: string;
591
+ conversationId: string;
592
+ author: string;
593
+ body: string;
594
+ createdAt: string;
595
+ }
596
+ interface InboxConversationDetail extends InboxConversation {
597
+ messages: InboxMessage[];
598
+ notes: InboxNote[];
599
+ totalMessages: number;
600
+ hasMore: boolean;
601
+ }
602
+ interface InboxComposeInput {
603
+ /** Parte local (o dirección completa) de una máscara activa del dominio. */
604
+ fromAlias: string;
605
+ to: string;
606
+ subject: string;
607
+ markdown?: string;
608
+ html?: string;
609
+ body?: string;
610
+ cc?: string[];
611
+ bcc?: string[];
612
+ attachments?: AttachmentRef[];
613
+ }
614
+ interface InboxReplyInput {
615
+ markdown?: string;
616
+ html?: string;
617
+ body?: string;
618
+ cc?: string[];
619
+ bcc?: string[];
620
+ /** Cita el último mensaje recibido (por omisión true; sólo con markdown). */
621
+ quote?: boolean;
622
+ attachments?: AttachmentRef[];
623
+ }
624
+ interface InboxUpdateInput {
625
+ status?: InboxStatus;
626
+ /** ISO, futura y a menos de 90 días. Obligatoria con `status: "snoozed"`. */
627
+ snoozedUntil?: string;
628
+ tags?: string[];
629
+ priority?: "normal" | "urgent";
630
+ }
631
+ interface Order {
632
+ id: string;
633
+ number: string;
634
+ date: string;
635
+ kind: string;
636
+ concept: string;
637
+ subject: string | null;
638
+ amountCents: number;
639
+ listPriceCents: number | null;
640
+ currency: string;
641
+ periodStart: string | null;
642
+ periodEnd: string | null;
643
+ failureReason: string | null;
644
+ note: string | null;
645
+ reference: string | null;
646
+ }
647
+ interface OrdersPage {
648
+ orders: Order[];
649
+ nextCursor: string | null;
650
+ invoiceNote: string;
651
+ }
652
+ interface ReferralStats {
653
+ slug?: string | null;
654
+ referrals: unknown[];
655
+ [k: string]: unknown;
656
+ }
514
657
 
515
658
  declare class MailMaskError extends Error {
516
659
  status: number;
@@ -536,6 +679,9 @@ declare class MailMask {
536
679
  members: MembersResource;
537
680
  signature: SignatureResource;
538
681
  canned: CannedResource;
682
+ account: AccountResource;
683
+ inbox: InboxResource;
684
+ referrals: ReferralsResource;
539
685
  constructor(config: MailMaskConfig);
540
686
  }
541
687
  type Req = <T>(path: string, opts?: RequestInit) => Promise<T>;
@@ -554,6 +700,19 @@ declare class DomainsResource {
554
700
  dnsSetup(id: string, opts?: {
555
701
  live?: boolean;
556
702
  }): Promise<DnsSetup>;
703
+ /** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
704
+ setLogo(id: string, file: Blob, filename?: string): Promise<{
705
+ ok: boolean;
706
+ logoUrl: string;
707
+ }>;
708
+ /** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
709
+ setLogoFromUrl(id: string, url: string): Promise<{
710
+ ok: boolean;
711
+ logoUrl: string;
712
+ }>;
713
+ removeLogo(id: string): Promise<{
714
+ ok: boolean;
715
+ }>;
557
716
  }
558
717
  declare class DnsResource {
559
718
  private req;
@@ -634,6 +793,8 @@ declare class AttachmentsResource {
634
793
  constructor(req: Req);
635
794
  /** Máx. 5 MB. Ejecutables bloqueados (415). La llave vale hasta que se envía. */
636
795
  upload(domainId: string, input: UploadAttachmentInput): Promise<UploadedAttachment>;
796
+ /** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
797
+ uploadFromUrl(domainId: string, url: string, filename?: string): Promise<UploadedAttachment>;
637
798
  }
638
799
  declare class SuppressionsResource {
639
800
  private req;
@@ -691,7 +852,18 @@ declare class BillingResource {
691
852
  */
692
853
  checkout(domainId: string, kind?: "domain" | "storage50" | "sends100", opts?: {
693
854
  payerEmail?: string;
855
+ period?: "monthly" | "annual";
694
856
  }): Promise<CheckoutLink>;
857
+ /** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
858
+ cancelAddon(addonId: string): Promise<{
859
+ ok: boolean;
860
+ activeUntil: string | null;
861
+ }>;
862
+ /** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
863
+ orders(opts?: {
864
+ limit?: number;
865
+ before?: string;
866
+ }): Promise<OrdersPage>;
695
867
  }
696
868
  declare class RegistrationsResource {
697
869
  private req;
@@ -710,6 +882,11 @@ declare class RegistrationsResource {
710
882
  renewal(regId: string, opts?: {
711
883
  payerEmail?: string;
712
884
  }): Promise<RenewalLink>;
885
+ /** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
886
+ cancelRenewal(regId: string): Promise<{
887
+ ok: boolean;
888
+ aviso: string;
889
+ }>;
713
890
  }
714
891
  declare class TransfersResource {
715
892
  private req;
@@ -779,6 +956,87 @@ declare class CannedResource {
779
956
  ok: boolean;
780
957
  }>;
781
958
  }
959
+ declare class AccountResource {
960
+ private req;
961
+ constructor(req: Req);
962
+ getProfile(): Promise<AccountProfile>;
963
+ /** Nombre visible (máx. 60 caracteres). Cadena vacía lo borra. */
964
+ updateProfile(input: {
965
+ displayName: string | null;
966
+ }): Promise<AccountProfile>;
967
+ /** Foto desde un adjunto que el usuario subió al asistente (URL firmada de `/api/asistente/files/*`). */
968
+ setAvatarFromUrl(url: string): Promise<AccountProfile & {
969
+ ok: boolean;
970
+ }>;
971
+ /** Foto desde bytes (PNG, JPG o WebP; máx. 2 MB). */
972
+ setAvatar(file: Blob, filename?: string): Promise<AccountProfile & {
973
+ ok: boolean;
974
+ }>;
975
+ removeAvatar(): Promise<AccountProfile & {
976
+ ok: boolean;
977
+ }>;
978
+ }
979
+ /**
980
+ * La Bandeja: conversaciones del dominio. Todo pasa por los mismos permisos que la app
981
+ * (dueño, admin o agente invitado) y los mismos topes de envío.
982
+ */
983
+ declare class InboxResource {
984
+ private req;
985
+ private raw;
986
+ constructor(req: Req, raw: (path: string) => Promise<Response>);
987
+ list(domainId: string, opts?: InboxListOptions): Promise<InboxPage>;
988
+ /** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
989
+ get(domainId: string, conversationId: string, opts?: {
990
+ before?: string;
991
+ }): Promise<InboxConversationDetail>;
992
+ /** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
993
+ compose(domainId: string, input: InboxComposeInput): Promise<{
994
+ ok: boolean;
995
+ conversationId: string;
996
+ messageId: string;
997
+ }>;
998
+ /** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
999
+ reply(domainId: string, conversationId: string, input: InboxReplyInput): Promise<{
1000
+ ok: boolean;
1001
+ messageId: string;
1002
+ }>;
1003
+ update(domainId: string, conversationId: string, input: InboxUpdateInput): Promise<InboxConversation>;
1004
+ markRead(domainId: string, conversationId: string): Promise<{
1005
+ ok: boolean;
1006
+ unreadCount: number;
1007
+ }>;
1008
+ /** Sin `assignedTo` la deja sin asignar. */
1009
+ assign(domainId: string, conversationId: string, assignedTo?: string): Promise<InboxConversation>;
1010
+ /** Nota interna: la ve el equipo, nunca el contacto. */
1011
+ addNote(domainId: string, conversationId: string, body: string): Promise<InboxNote>;
1012
+ /** A la papelera (se puede restaurar). Máx. 200 por llamada. */
1013
+ delete(domainId: string, conversationIds: string[]): Promise<{
1014
+ ok: boolean;
1015
+ deleted: number;
1016
+ }>;
1017
+ restore(domainId: string, conversationId: string): Promise<{
1018
+ ok: boolean;
1019
+ }>;
1020
+ metrics(domainId: string, opts?: {
1021
+ days?: number;
1022
+ }): Promise<Record<string, unknown>>;
1023
+ /** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
1024
+ attachment(domainId: string, conversationId: string, messageId: string, index: number): Promise<Response>;
1025
+ }
1026
+ declare class ReferralsResource {
1027
+ private req;
1028
+ constructor(req: Req);
1029
+ get(): Promise<ReferralStats>;
1030
+ /** 3-30 caracteres: minúsculas, números y guiones. */
1031
+ setSlug(slug: string): Promise<{
1032
+ ok: boolean;
1033
+ slug: string;
1034
+ }>;
1035
+ /** Nombre que ven los invitados (2-40 caracteres). */
1036
+ setName(name: string): Promise<{
1037
+ ok: boolean;
1038
+ }>;
1039
+ }
782
1040
 
783
1041
  interface WebhookSignatureHeaders {
784
1042
  /** Header `X-MailMask-Signature`, con forma `sha256=<hex>`. */
@@ -793,4 +1051,4 @@ interface WebhookSignatureHeaders {
793
1051
  */
794
1052
  declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
795
1053
 
796
- export { type Addon, type AddonsResponse, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
1054
+ export { type AccountProfile, type Addon, type AddonsResponse, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, type InboxAttachment, type InboxComposeInput, type InboxConversation, type InboxConversationDetail, type InboxListOptions, type InboxMessage, type InboxNote, type InboxPage, type InboxReplyInput, type InboxStatus, type InboxUpdateInput, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type Order, type OrdersPage, type ReferralStats, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -494,6 +494,9 @@ interface DomainMember {
494
494
  name: string;
495
495
  role: "admin" | "agent";
496
496
  createdAt: string;
497
+ /** Del perfil de su cuenta de MailMask, si lo llenó. */
498
+ displayName?: string | null;
499
+ avatarUrl?: string | null;
497
500
  }
498
501
  interface DomainInvite {
499
502
  token: string;
@@ -511,6 +514,146 @@ interface CannedReply {
511
514
  body: string;
512
515
  createdAt: string;
513
516
  }
517
+ /** Perfil de la cuenta de MailMask (el usuario, no una máscara). */
518
+ interface AccountProfile {
519
+ email: string;
520
+ displayName: string | null;
521
+ /** Ruta relativa al host de MailMask (`/api/avatar/...`), o null sin foto. */
522
+ avatarUrl: string | null;
523
+ }
524
+ type InboxStatus = "open" | "snoozed" | "closed";
525
+ interface InboxConversation {
526
+ id: string;
527
+ domainId: string;
528
+ /** El contacto externo (en un hilo que inició el dominio, el destinatario). */
529
+ from: string;
530
+ /** La máscara del dominio por la que va el hilo (`ventas@tudominio.com`). */
531
+ to: string;
532
+ subject: string;
533
+ status: InboxStatus;
534
+ assignedTo?: string;
535
+ priority: "normal" | "urgent";
536
+ lastMessageAt: string;
537
+ messageCount: number;
538
+ tags: string[];
539
+ deletedAt?: string;
540
+ snoozedUntil?: string;
541
+ /** Para quien pregunta: hay mensajes que no ha visto. */
542
+ unread?: boolean;
543
+ /** Sólo en búsqueda: fragmento con la coincidencia. */
544
+ snippet?: string;
545
+ [k: string]: unknown;
546
+ }
547
+ interface InboxListOptions {
548
+ /** `open`, `snoozed`, `closed`, `unread` (de quien pregunta) o `deleted` (papelera). */
549
+ status?: InboxStatus | "unread" | "deleted";
550
+ /** Dirección completa de la máscara (`ventas@tudominio.com`). */
551
+ to?: string;
552
+ assignedTo?: string;
553
+ /** Búsqueda en asunto, remitente y cuerpo. Con `q` no hay paginación (tope 50). */
554
+ q?: string;
555
+ /** Máx. 100. */
556
+ limit?: number;
557
+ cursor?: string;
558
+ }
559
+ interface InboxPage {
560
+ items: InboxConversation[];
561
+ nextCursor: string | null;
562
+ /** Máscaras con conversaciones (sólo en la primera página). */
563
+ aliases?: string[];
564
+ mode: "list" | "search" | "search-degraded";
565
+ unreadCount?: number;
566
+ [k: string]: unknown;
567
+ }
568
+ interface InboxAttachment {
569
+ index: number;
570
+ filename: string;
571
+ contentType: string;
572
+ size: number;
573
+ }
574
+ interface InboxMessage {
575
+ id: string;
576
+ conversationId: string;
577
+ from: string;
578
+ /** Texto plano. */
579
+ body?: string;
580
+ html?: string;
581
+ direction: "inbound" | "outbound";
582
+ createdAt: string;
583
+ messageId?: string;
584
+ deliveryStatus?: "sent" | "delivered" | "bounced" | "complained";
585
+ attachments?: InboxAttachment[];
586
+ /** El original ya no está (retención de 90 días o pérdida): `body` puede venir del índice. */
587
+ bodyDegraded?: string;
588
+ }
589
+ interface InboxNote {
590
+ id: string;
591
+ conversationId: string;
592
+ author: string;
593
+ body: string;
594
+ createdAt: string;
595
+ }
596
+ interface InboxConversationDetail extends InboxConversation {
597
+ messages: InboxMessage[];
598
+ notes: InboxNote[];
599
+ totalMessages: number;
600
+ hasMore: boolean;
601
+ }
602
+ interface InboxComposeInput {
603
+ /** Parte local (o dirección completa) de una máscara activa del dominio. */
604
+ fromAlias: string;
605
+ to: string;
606
+ subject: string;
607
+ markdown?: string;
608
+ html?: string;
609
+ body?: string;
610
+ cc?: string[];
611
+ bcc?: string[];
612
+ attachments?: AttachmentRef[];
613
+ }
614
+ interface InboxReplyInput {
615
+ markdown?: string;
616
+ html?: string;
617
+ body?: string;
618
+ cc?: string[];
619
+ bcc?: string[];
620
+ /** Cita el último mensaje recibido (por omisión true; sólo con markdown). */
621
+ quote?: boolean;
622
+ attachments?: AttachmentRef[];
623
+ }
624
+ interface InboxUpdateInput {
625
+ status?: InboxStatus;
626
+ /** ISO, futura y a menos de 90 días. Obligatoria con `status: "snoozed"`. */
627
+ snoozedUntil?: string;
628
+ tags?: string[];
629
+ priority?: "normal" | "urgent";
630
+ }
631
+ interface Order {
632
+ id: string;
633
+ number: string;
634
+ date: string;
635
+ kind: string;
636
+ concept: string;
637
+ subject: string | null;
638
+ amountCents: number;
639
+ listPriceCents: number | null;
640
+ currency: string;
641
+ periodStart: string | null;
642
+ periodEnd: string | null;
643
+ failureReason: string | null;
644
+ note: string | null;
645
+ reference: string | null;
646
+ }
647
+ interface OrdersPage {
648
+ orders: Order[];
649
+ nextCursor: string | null;
650
+ invoiceNote: string;
651
+ }
652
+ interface ReferralStats {
653
+ slug?: string | null;
654
+ referrals: unknown[];
655
+ [k: string]: unknown;
656
+ }
514
657
 
515
658
  declare class MailMaskError extends Error {
516
659
  status: number;
@@ -536,6 +679,9 @@ declare class MailMask {
536
679
  members: MembersResource;
537
680
  signature: SignatureResource;
538
681
  canned: CannedResource;
682
+ account: AccountResource;
683
+ inbox: InboxResource;
684
+ referrals: ReferralsResource;
539
685
  constructor(config: MailMaskConfig);
540
686
  }
541
687
  type Req = <T>(path: string, opts?: RequestInit) => Promise<T>;
@@ -554,6 +700,19 @@ declare class DomainsResource {
554
700
  dnsSetup(id: string, opts?: {
555
701
  live?: boolean;
556
702
  }): Promise<DnsSetup>;
703
+ /** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
704
+ setLogo(id: string, file: Blob, filename?: string): Promise<{
705
+ ok: boolean;
706
+ logoUrl: string;
707
+ }>;
708
+ /** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
709
+ setLogoFromUrl(id: string, url: string): Promise<{
710
+ ok: boolean;
711
+ logoUrl: string;
712
+ }>;
713
+ removeLogo(id: string): Promise<{
714
+ ok: boolean;
715
+ }>;
557
716
  }
558
717
  declare class DnsResource {
559
718
  private req;
@@ -634,6 +793,8 @@ declare class AttachmentsResource {
634
793
  constructor(req: Req);
635
794
  /** Máx. 5 MB. Ejecutables bloqueados (415). La llave vale hasta que se envía. */
636
795
  upload(domainId: string, input: UploadAttachmentInput): Promise<UploadedAttachment>;
796
+ /** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
797
+ uploadFromUrl(domainId: string, url: string, filename?: string): Promise<UploadedAttachment>;
637
798
  }
638
799
  declare class SuppressionsResource {
639
800
  private req;
@@ -691,7 +852,18 @@ declare class BillingResource {
691
852
  */
692
853
  checkout(domainId: string, kind?: "domain" | "storage50" | "sends100", opts?: {
693
854
  payerEmail?: string;
855
+ period?: "monthly" | "annual";
694
856
  }): Promise<CheckoutLink>;
857
+ /** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
858
+ cancelAddon(addonId: string): Promise<{
859
+ ok: boolean;
860
+ activeUntil: string | null;
861
+ }>;
862
+ /** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
863
+ orders(opts?: {
864
+ limit?: number;
865
+ before?: string;
866
+ }): Promise<OrdersPage>;
695
867
  }
696
868
  declare class RegistrationsResource {
697
869
  private req;
@@ -710,6 +882,11 @@ declare class RegistrationsResource {
710
882
  renewal(regId: string, opts?: {
711
883
  payerEmail?: string;
712
884
  }): Promise<RenewalLink>;
885
+ /** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
886
+ cancelRenewal(regId: string): Promise<{
887
+ ok: boolean;
888
+ aviso: string;
889
+ }>;
713
890
  }
714
891
  declare class TransfersResource {
715
892
  private req;
@@ -779,6 +956,87 @@ declare class CannedResource {
779
956
  ok: boolean;
780
957
  }>;
781
958
  }
959
+ declare class AccountResource {
960
+ private req;
961
+ constructor(req: Req);
962
+ getProfile(): Promise<AccountProfile>;
963
+ /** Nombre visible (máx. 60 caracteres). Cadena vacía lo borra. */
964
+ updateProfile(input: {
965
+ displayName: string | null;
966
+ }): Promise<AccountProfile>;
967
+ /** Foto desde un adjunto que el usuario subió al asistente (URL firmada de `/api/asistente/files/*`). */
968
+ setAvatarFromUrl(url: string): Promise<AccountProfile & {
969
+ ok: boolean;
970
+ }>;
971
+ /** Foto desde bytes (PNG, JPG o WebP; máx. 2 MB). */
972
+ setAvatar(file: Blob, filename?: string): Promise<AccountProfile & {
973
+ ok: boolean;
974
+ }>;
975
+ removeAvatar(): Promise<AccountProfile & {
976
+ ok: boolean;
977
+ }>;
978
+ }
979
+ /**
980
+ * La Bandeja: conversaciones del dominio. Todo pasa por los mismos permisos que la app
981
+ * (dueño, admin o agente invitado) y los mismos topes de envío.
982
+ */
983
+ declare class InboxResource {
984
+ private req;
985
+ private raw;
986
+ constructor(req: Req, raw: (path: string) => Promise<Response>);
987
+ list(domainId: string, opts?: InboxListOptions): Promise<InboxPage>;
988
+ /** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
989
+ get(domainId: string, conversationId: string, opts?: {
990
+ before?: string;
991
+ }): Promise<InboxConversationDetail>;
992
+ /** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
993
+ compose(domainId: string, input: InboxComposeInput): Promise<{
994
+ ok: boolean;
995
+ conversationId: string;
996
+ messageId: string;
997
+ }>;
998
+ /** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
999
+ reply(domainId: string, conversationId: string, input: InboxReplyInput): Promise<{
1000
+ ok: boolean;
1001
+ messageId: string;
1002
+ }>;
1003
+ update(domainId: string, conversationId: string, input: InboxUpdateInput): Promise<InboxConversation>;
1004
+ markRead(domainId: string, conversationId: string): Promise<{
1005
+ ok: boolean;
1006
+ unreadCount: number;
1007
+ }>;
1008
+ /** Sin `assignedTo` la deja sin asignar. */
1009
+ assign(domainId: string, conversationId: string, assignedTo?: string): Promise<InboxConversation>;
1010
+ /** Nota interna: la ve el equipo, nunca el contacto. */
1011
+ addNote(domainId: string, conversationId: string, body: string): Promise<InboxNote>;
1012
+ /** A la papelera (se puede restaurar). Máx. 200 por llamada. */
1013
+ delete(domainId: string, conversationIds: string[]): Promise<{
1014
+ ok: boolean;
1015
+ deleted: number;
1016
+ }>;
1017
+ restore(domainId: string, conversationId: string): Promise<{
1018
+ ok: boolean;
1019
+ }>;
1020
+ metrics(domainId: string, opts?: {
1021
+ days?: number;
1022
+ }): Promise<Record<string, unknown>>;
1023
+ /** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
1024
+ attachment(domainId: string, conversationId: string, messageId: string, index: number): Promise<Response>;
1025
+ }
1026
+ declare class ReferralsResource {
1027
+ private req;
1028
+ constructor(req: Req);
1029
+ get(): Promise<ReferralStats>;
1030
+ /** 3-30 caracteres: minúsculas, números y guiones. */
1031
+ setSlug(slug: string): Promise<{
1032
+ ok: boolean;
1033
+ slug: string;
1034
+ }>;
1035
+ /** Nombre que ven los invitados (2-40 caracteres). */
1036
+ setName(name: string): Promise<{
1037
+ ok: boolean;
1038
+ }>;
1039
+ }
782
1040
 
783
1041
  interface WebhookSignatureHeaders {
784
1042
  /** Header `X-MailMask-Signature`, con forma `sha256=<hex>`. */
@@ -793,4 +1051,4 @@ interface WebhookSignatureHeaders {
793
1051
  */
794
1052
  declare function verifyWebhookSignature(secret: string, headers: WebhookSignatureHeaders, rawBody: string, toleranceMs?: number): Promise<boolean>;
795
1053
 
796
- export { type Addon, type AddonsResponse, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
1054
+ export { type AccountProfile, type Addon, type AddonsResponse, type Alias, type AliasCreated, type ApiKey, type AttachmentRef, type BillingStatus, type BulkJob, type BulkJobCreated, type BulkSendInput, type CannedReply, type CheckoutLink, type CreateAliasInput, type CreateRuleInput, type CreateWebhookInput, type DnsChangeResult, type DnsDelegation, type DnsImportResult, type DnsListResponse, type DnsPreset, type DnsRRSet, type DnsRRSetAnotado, type DnsRecord, type DnsRecordType, type DnsSetup, type DnsSetupRecord, type DnsZoneCreated, type DnsZoneState, type Domain, type DomainCreated, type DomainInvite, type DomainMember, type DomainRegistration, type DomainRegistrationCreated, type DomainSearchResult, type DomainVerification, type EmailLog, type InboxAttachment, type InboxComposeInput, type InboxConversation, type InboxConversationDetail, type InboxListOptions, type InboxMessage, type InboxNote, type InboxPage, type InboxReplyInput, type InboxStatus, type InboxUpdateInput, MailMask, type MailMaskConfig, MailMaskError, type MailboxCreated, type Order, type OrdersPage, type ReferralStats, type RenewalLink, type Rule, type RuleAction, type RuleField, type RuleMatch, type SendEmailInput, type SendOptions, type SmtpCredential, type SmtpCredentialCreated, type Suppression, type TldPrice, type TransferCheck, type TransferDnsInventory, type TransferRequirement, type UpdateAliasInput, type UpdateRuleInput, type UpdateWebhookInput, type UploadAttachmentInput, type UploadedAttachment, type Webhook, type WebhookCreated, type WebhookDelivery, type WebhookEvent, type WebhookPayload, type WebhookSignatureHeaders, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -47,6 +47,9 @@ var MailMask = class {
47
47
  this.members = new MembersResource(req);
48
48
  this.signature = new SignatureResource(req);
49
49
  this.canned = new CannedResource(req);
50
+ this.account = new AccountResource(req);
51
+ this.inbox = new InboxResource(req, (path) => requestRaw(this.baseUrl, this.apiKey, path, doFetch));
52
+ this.referrals = new ReferralsResource(req);
50
53
  }
51
54
  };
52
55
  var DomainsResource = class {
@@ -75,6 +78,19 @@ var DomainsResource = class {
75
78
  dnsSetup(id, opts) {
76
79
  return this.req(`/api/domains/${id}/dns-setup${opts?.live ? "?live=1" : ""}`);
77
80
  }
81
+ /** Logo de la firma (PNG, JPG o WebP; máx. 500 KB). Se ve en todo correo en markdown. */
82
+ setLogo(id, file, filename = "logo") {
83
+ const form = new FormData();
84
+ form.append("file", file, filename);
85
+ return this.req(`/api/domains/${id}/logo`, { method: "POST", body: form });
86
+ }
87
+ /** Logo desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
88
+ setLogoFromUrl(id, url) {
89
+ return this.req(`/api/domains/${id}/logo`, { method: "POST", body: JSON.stringify({ fromUrl: url }) });
90
+ }
91
+ removeLogo(id) {
92
+ return this.req(`/api/domains/${id}/logo`, { method: "DELETE" });
93
+ }
78
94
  };
79
95
  var DnsResource = class {
80
96
  constructor(req) {
@@ -195,6 +211,10 @@ var AttachmentsResource = class {
195
211
  form.append("file", blob, input.filename);
196
212
  return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: form });
197
213
  }
214
+ /** Desde un adjunto del chat del asistente (URL firmada de `/api/asistente/files/*`). */
215
+ uploadFromUrl(domainId, url, filename) {
216
+ return this.req(`/api/domains/${domainId}/attachments`, { method: "POST", body: JSON.stringify({ fromUrl: url, filename }) });
217
+ }
198
218
  };
199
219
  var SuppressionsResource = class {
200
220
  constructor(req) {
@@ -277,7 +297,19 @@ var BillingResource = class {
277
297
  * El usuario la abre y paga; hasta entonces no cambia nada.
278
298
  */
279
299
  checkout(domainId, kind = "domain", opts) {
280
- return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail }) });
300
+ return this.req("/api/addons/checkout", { method: "POST", body: JSON.stringify({ kind, domainId, payerEmail: opts?.payerEmail, period: opts?.period }) });
301
+ }
302
+ /** Cancela la suscripción de un add-on; el cupo sigue hasta el fin del periodo pagado. */
303
+ cancelAddon(addonId) {
304
+ return this.req(`/api/addons/${addonId}/cancel`, { method: "POST" });
305
+ }
306
+ /** Historial de cobros, cortesías y cancelaciones (más reciente primero). */
307
+ orders(opts) {
308
+ const qs = new URLSearchParams();
309
+ if (opts?.limit) qs.set("limit", String(opts.limit));
310
+ if (opts?.before) qs.set("before", opts.before);
311
+ const q = qs.toString();
312
+ return this.req(`/api/billing/orders${q ? `?${q}` : ""}`);
281
313
  }
282
314
  };
283
315
  var RegistrationsResource = class {
@@ -305,6 +337,10 @@ var RegistrationsResource = class {
305
337
  renewal(regId, opts) {
306
338
  return this.req(`/api/domains/registrations/${regId}/renewal`, { method: "POST", body: JSON.stringify({ payerEmail: opts?.payerEmail }) });
307
339
  }
340
+ /** Deja de cobrar la renovación anual. El dominio sigue vigente hasta su vencimiento. */
341
+ cancelRenewal(regId) {
342
+ return this.req(`/api/domains/registrations/${regId}/renewal/cancel`, { method: "POST" });
343
+ }
308
344
  };
309
345
  var TransfersResource = class {
310
346
  constructor(req) {
@@ -372,6 +408,102 @@ var CannedResource = class {
372
408
  return this.req(`/api/domains/${domainId}/canned/${cannedId}`, { method: "DELETE" });
373
409
  }
374
410
  };
411
+ var AccountResource = class {
412
+ constructor(req) {
413
+ this.req = req;
414
+ }
415
+ getProfile() {
416
+ return this.req("/api/profile");
417
+ }
418
+ /** Nombre visible (máx. 60 caracteres). Cadena vacía lo borra. */
419
+ updateProfile(input) {
420
+ return this.req("/api/profile", { method: "PUT", body: JSON.stringify(input) });
421
+ }
422
+ /** Foto desde un adjunto que el usuario subió al asistente (URL firmada de `/api/asistente/files/*`). */
423
+ setAvatarFromUrl(url) {
424
+ return this.req("/api/profile/avatar", { method: "POST", body: JSON.stringify({ fromUrl: url }) });
425
+ }
426
+ /** Foto desde bytes (PNG, JPG o WebP; máx. 2 MB). */
427
+ setAvatar(file, filename = "avatar") {
428
+ const form = new FormData();
429
+ form.append("file", file, filename);
430
+ return this.req("/api/profile/avatar", { method: "POST", body: form });
431
+ }
432
+ removeAvatar() {
433
+ return this.req("/api/profile/avatar", { method: "DELETE" });
434
+ }
435
+ };
436
+ var InboxResource = class {
437
+ constructor(req, raw) {
438
+ this.req = req;
439
+ this.raw = raw;
440
+ }
441
+ list(domainId, opts) {
442
+ const qs = new URLSearchParams({ domainId });
443
+ for (const [k, v] of Object.entries(opts ?? {})) if (v !== void 0 && v !== "") qs.set(k, String(v));
444
+ return this.req(`/api/bandeja/conversations?${qs}`);
445
+ }
446
+ /** Conversación con sus mensajes (los 30 más recientes, o anteriores a `before`). Abrirla la marca leída. */
447
+ get(domainId, conversationId, opts) {
448
+ const qs = new URLSearchParams({ domainId });
449
+ if (opts?.before) qs.set("before", opts.before);
450
+ return this.req(`/api/bandeja/conversations/${conversationId}?${qs}`);
451
+ }
452
+ /** Un correo nuevo desde una máscara: abre un hilo. Gasta cuota de envío (dominio activado). */
453
+ compose(domainId, input) {
454
+ return this.req("/api/bandeja/conversations", { method: "POST", body: JSON.stringify({ ...input, domainId }) });
455
+ }
456
+ /** Responde en el hilo desde la máscara del hilo. No gasta cuota de envío. */
457
+ reply(domainId, conversationId, input) {
458
+ return this.req(`/api/bandeja/conversations/${conversationId}/reply`, { method: "POST", body: JSON.stringify({ ...input, domainId }) });
459
+ }
460
+ update(domainId, conversationId, input) {
461
+ return this.req(`/api/bandeja/conversations/${conversationId}`, { method: "PATCH", body: JSON.stringify({ ...input, domainId }) });
462
+ }
463
+ markRead(domainId, conversationId) {
464
+ return this.req(`/api/bandeja/conversations/${conversationId}/read`, { method: "POST", body: JSON.stringify({ domainId }) });
465
+ }
466
+ /** Sin `assignedTo` la deja sin asignar. */
467
+ assign(domainId, conversationId, assignedTo) {
468
+ return this.req(`/api/bandeja/conversations/${conversationId}/assign`, { method: "POST", body: JSON.stringify({ domainId, assignedTo }) });
469
+ }
470
+ /** Nota interna: la ve el equipo, nunca el contacto. */
471
+ addNote(domainId, conversationId, body) {
472
+ return this.req(`/api/bandeja/conversations/${conversationId}/note`, { method: "POST", body: JSON.stringify({ domainId, body }) });
473
+ }
474
+ /** A la papelera (se puede restaurar). Máx. 200 por llamada. */
475
+ delete(domainId, conversationIds) {
476
+ return this.req("/api/bandeja/conversations/bulk-delete", { method: "POST", body: JSON.stringify({ domainId, ids: conversationIds }) });
477
+ }
478
+ restore(domainId, conversationId) {
479
+ return this.req(`/api/bandeja/conversations/${conversationId}/restore`, { method: "POST", body: JSON.stringify({ domainId }) });
480
+ }
481
+ metrics(domainId, opts) {
482
+ const qs = new URLSearchParams({ domainId });
483
+ if (opts?.days) qs.set("days", String(opts.days));
484
+ return this.req(`/api/bandeja/metrics?${qs}`);
485
+ }
486
+ /** Bytes de un adjunto de un mensaje (id del mensaje e índice de `attachments`). */
487
+ attachment(domainId, conversationId, messageId, index) {
488
+ return this.raw(`/api/bandeja/conversations/${conversationId}/attachments/${messageId}/${index}?domainId=${encodeURIComponent(domainId)}`);
489
+ }
490
+ };
491
+ var ReferralsResource = class {
492
+ constructor(req) {
493
+ this.req = req;
494
+ }
495
+ get() {
496
+ return this.req("/api/referrals");
497
+ }
498
+ /** 3-30 caracteres: minúsculas, números y guiones. */
499
+ setSlug(slug) {
500
+ return this.req("/api/referrals/slug", { method: "PUT", body: JSON.stringify({ slug }) });
501
+ }
502
+ /** Nombre que ven los invitados (2-40 caracteres). */
503
+ setName(name) {
504
+ return this.req("/api/referrals/name", { method: "PUT", body: JSON.stringify({ name }) });
505
+ }
506
+ };
375
507
 
376
508
  // src/verify.ts
377
509
  function hex(buf) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easybits.cloud/mailmask",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Official SDK for the MailMask email alias/forwarding API",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",