unitpost 0.1.0 → 0.2.1

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.ts CHANGED
@@ -434,7 +434,7 @@ type DomainUpdate = {
434
434
  tls?: "opportunistic" | "enforced";
435
435
  tracking_subdomain?: string | null;
436
436
  };
437
- type Email = {
437
+ type Email$1 = {
438
438
  object: "email";
439
439
  id: string;
440
440
  to: Array<string>;
@@ -2204,7 +2204,6 @@ type models_ContactUpdate = ContactUpdate;
2204
2204
  type models_Domain = Domain;
2205
2205
  type models_DomainCreate = DomainCreate;
2206
2206
  type models_DomainUpdate = DomainUpdate;
2207
- type models_Email = Email;
2208
2207
  type models_EmailPatch = EmailPatch;
2209
2208
  type models_EmailStats = EmailStats;
2210
2209
  type models_ReceivedAttachmentUrl = ReceivedAttachmentUrl;
@@ -2232,7 +2231,7 @@ type models_WebhookCreated = WebhookCreated;
2232
2231
  type models_WebhookTestResult = WebhookTestResult;
2233
2232
  type models_WebhookUpdate = WebhookUpdate;
2234
2233
  declare namespace models {
2235
- export type { models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandKit as BrandKit, models_BrandKitList as BrandKitList, models_Campaign as Campaign, models_CampaignCreate as CampaignCreate, models_CampaignReschedule as CampaignReschedule, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactCreate as ContactCreate, models_ContactField as ContactField, models_ContactFieldCreate as ContactFieldCreate, models_ContactFieldRename as ContactFieldRename, models_ContactFieldUpdate as ContactFieldUpdate, models_ContactImport as ContactImport, models_ContactImportCreate as ContactImportCreate, models_ContactTopic as ContactTopic, models_ContactTopicSet as ContactTopicSet, models_ContactUpdate as ContactUpdate, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainUpdate as DomainUpdate, models_Email as Email, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, Error$1 as Error, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailSummary as ReceivedEmailSummary, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateUpdate as TemplateUpdate, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate };
2234
+ export type { models_ApiKey as ApiKey, models_ApiKeyCreate as ApiKeyCreate, models_ApiKeyCreated as ApiKeyCreated, models_Batch as Batch, models_BatchSend as BatchSend, models_BatchSendResult as BatchSendResult, models_BrandKit as BrandKit, models_BrandKitList as BrandKitList, models_Campaign as Campaign, models_CampaignCreate as CampaignCreate, models_CampaignReschedule as CampaignReschedule, models_CampaignUpdate as CampaignUpdate, models_Contact as Contact, models_ContactCreate as ContactCreate, models_ContactField as ContactField, models_ContactFieldCreate as ContactFieldCreate, models_ContactFieldRename as ContactFieldRename, models_ContactFieldUpdate as ContactFieldUpdate, models_ContactImport as ContactImport, models_ContactImportCreate as ContactImportCreate, models_ContactTopic as ContactTopic, models_ContactTopicSet as ContactTopicSet, models_ContactUpdate as ContactUpdate, models_Domain as Domain, models_DomainCreate as DomainCreate, models_DomainUpdate as DomainUpdate, Email$1 as Email, models_EmailPatch as EmailPatch, models_EmailStats as EmailStats, Error$1 as Error, models_ReceivedAttachmentUrl as ReceivedAttachmentUrl, models_ReceivedEmail as ReceivedEmail, models_ReceivedEmailSummary as ReceivedEmailSummary, models_Segment as Segment, models_SegmentCreate as SegmentCreate, models_SegmentMember as SegmentMember, models_SegmentMemberAdd as SegmentMemberAdd, models_SegmentUpdate as SegmentUpdate, models_SendEmail as SendEmail, models_SendResult as SendResult, models_Suppression as Suppression, models_SuppressionBulkResult as SuppressionBulkResult, models_SuppressionCreate as SuppressionCreate, models_Template as Template, models_TemplateCreate as TemplateCreate, models_TemplateUpdate as TemplateUpdate, models_Topic as Topic, models_TopicCreate as TopicCreate, models_TopicUpdate as TopicUpdate, Usage$1 as Usage, models_Webhook as Webhook, models_WebhookCreate as WebhookCreate, models_WebhookCreated as WebhookCreated, models_WebhookTestResult as WebhookTestResult, models_WebhookUpdate as WebhookUpdate };
2236
2235
  }
2237
2236
 
2238
2237
  type Result<T> = Promise<{
@@ -2246,7 +2245,12 @@ declare class Resource {
2246
2245
  protected readonly http: HttpClient;
2247
2246
  constructor(http: HttpClient);
2248
2247
  }
2249
- declare class Emails extends Resource {
2248
+ declare class Email extends Resource {
2249
+ readonly topics: Topics;
2250
+ readonly campaigns: Campaigns;
2251
+ readonly templates: Templates;
2252
+ readonly domains: Domains;
2253
+ constructor(http: HttpClient);
2250
2254
  /**
2251
2255
  * Send or schedule a transactional email.
2252
2256
  *
@@ -2273,13 +2277,13 @@ declare class Emails extends Resource {
2273
2277
  status?: string;
2274
2278
  campaign_id?: string;
2275
2279
  batch_id?: string;
2276
- }): Result<ListResponse<Email>>;
2280
+ }): Result<ListResponse<Email$1>>;
2277
2281
  /** Async-iterate every sent/scheduled email. */
2278
- listAll(params?: ListParams): AsyncGenerator<Email, void, void>;
2282
+ listAll(params?: ListParams): AsyncGenerator<Email$1, void, void>;
2279
2283
  /** Retrieve a sent or scheduled email. */
2280
- get(id: string): Result<Email>;
2284
+ get(id: string): Result<Email$1>;
2281
2285
  /** Cancel or reschedule a scheduled/queued email. */
2282
- update(id: string, body: EmailPatch): Result<Email>;
2286
+ update(id: string, body: EmailPatch): Result<Email$1>;
2283
2287
  /**
2284
2288
  * Deliverability / engagement stats over a rolling window.
2285
2289
  *
@@ -2437,15 +2441,11 @@ declare class Usage extends Resource {
2437
2441
  }
2438
2442
 
2439
2443
  declare class Unitpost {
2440
- readonly emails: Emails;
2444
+ readonly email: Email;
2441
2445
  readonly contacts: Contacts;
2442
2446
  readonly contactFields: ContactFields;
2443
2447
  readonly segments: Segments;
2444
- readonly topics: Topics;
2445
- readonly campaigns: Campaigns;
2446
- readonly templates: Templates;
2447
2448
  readonly brandKits: BrandKits;
2448
- readonly domains: Domains;
2449
2449
  readonly webhooks: Webhooks;
2450
2450
  readonly apiKeys: ApiKeys;
2451
2451
  readonly suppressions: Suppressions;
package/dist/index.js CHANGED
@@ -259,7 +259,18 @@ var Resource = class {
259
259
  }
260
260
  http;
261
261
  };
262
- var Emails = class extends Resource {
262
+ var Email = class extends Resource {
263
+ topics;
264
+ campaigns;
265
+ templates;
266
+ domains;
267
+ constructor(http) {
268
+ super(http);
269
+ this.topics = new Topics(http);
270
+ this.campaigns = new Campaigns(http);
271
+ this.templates = new Templates(http);
272
+ this.domains = new Domains(http);
273
+ }
263
274
  /**
264
275
  * Send or schedule a transactional email.
265
276
  *
@@ -270,7 +281,7 @@ var Emails = class extends Resource {
270
281
  send(body, opts = {}) {
271
282
  return this.http.request({
272
283
  method: "POST",
273
- path: "/emails",
284
+ path: "/email",
274
285
  body,
275
286
  idempotencyKey: opts.idempotencyKey ?? randomUUID()
276
287
  });
@@ -286,34 +297,34 @@ var Emails = class extends Resource {
286
297
  batch(body, opts = {}) {
287
298
  return this.http.request({
288
299
  method: "POST",
289
- path: "/emails/batch",
300
+ path: "/email/batch",
290
301
  body,
291
302
  idempotencyKey: opts.idempotencyKey ?? randomUUID()
292
303
  });
293
304
  }
294
305
  /** Retrieve a batch by id. */
295
306
  getBatch(id) {
296
- return this.http.request({ method: "GET", path: `/emails/batches/${enc(id)}` });
307
+ return this.http.request({ method: "GET", path: `/email/batches/${enc(id)}` });
297
308
  }
298
309
  /** Cancel every still-cancelable message in a batch. */
299
310
  cancelBatch(id) {
300
- return this.http.request({ method: "POST", path: `/emails/batches/${enc(id)}/cancel` });
311
+ return this.http.request({ method: "POST", path: `/email/batches/${enc(id)}/cancel` });
301
312
  }
302
313
  /** List sent/scheduled emails (cursor-paginated). */
303
314
  list(params = {}) {
304
- return this.http.request({ method: "GET", path: "/emails", query: params });
315
+ return this.http.request({ method: "GET", path: "/email", query: params });
305
316
  }
306
317
  /** Async-iterate every sent/scheduled email. */
307
318
  listAll(params = {}) {
308
- return paginate(this.http, "/emails", params);
319
+ return paginate(this.http, "/email", params);
309
320
  }
310
321
  /** Retrieve a sent or scheduled email. */
311
322
  get(id) {
312
- return this.http.request({ method: "GET", path: `/emails/${enc(id)}` });
323
+ return this.http.request({ method: "GET", path: `/email/${enc(id)}` });
313
324
  }
314
325
  /** Cancel or reschedule a scheduled/queued email. */
315
326
  update(id, body) {
316
- return this.http.request({ method: "PATCH", path: `/emails/${enc(id)}`, body });
327
+ return this.http.request({ method: "PATCH", path: `/email/${enc(id)}`, body });
317
328
  }
318
329
  /**
319
330
  * Deliverability / engagement stats over a rolling window.
@@ -321,17 +332,17 @@ var Emails = class extends Resource {
321
332
  * `days` is the window size (1–365); defaults to 30 server-side.
322
333
  */
323
334
  stats(params = {}) {
324
- return this.http.request({ method: "GET", path: "/emails/stats", query: params });
335
+ return this.http.request({ method: "GET", path: "/email/stats", query: params });
325
336
  }
326
337
  // --- Inbound (received) emails ---
327
338
  receivedList(params = {}) {
328
- return this.http.request({ method: "GET", path: "/emails/received", query: params });
339
+ return this.http.request({ method: "GET", path: "/email/received", query: params });
329
340
  }
330
341
  receivedGet(id) {
331
- return this.http.request({ method: "GET", path: `/emails/received/${enc(id)}` });
342
+ return this.http.request({ method: "GET", path: `/email/received/${enc(id)}` });
332
343
  }
333
344
  receivedAttachmentUrl(id, attachmentId) {
334
- return this.http.request({ method: "GET", path: `/emails/received/${enc(id)}/attachments/${enc(attachmentId)}` });
345
+ return this.http.request({ method: "GET", path: `/email/received/${enc(id)}/attachments/${enc(attachmentId)}` });
335
346
  }
336
347
  };
337
348
  var Contacts = class extends Resource {
@@ -421,22 +432,22 @@ var Segments = class extends Resource {
421
432
  };
422
433
  var Topics = class extends Resource {
423
434
  list(params = {}) {
424
- return this.http.request({ method: "GET", path: "/topics", query: params });
435
+ return this.http.request({ method: "GET", path: "/email/topics", query: params });
425
436
  }
426
437
  listAll(params = {}) {
427
- return paginate(this.http, "/topics", params);
438
+ return paginate(this.http, "/email/topics", params);
428
439
  }
429
440
  create(body) {
430
- return this.http.request({ method: "POST", path: "/topics", body });
441
+ return this.http.request({ method: "POST", path: "/email/topics", body });
431
442
  }
432
443
  get(id) {
433
- return this.http.request({ method: "GET", path: `/topics/${enc(id)}` });
444
+ return this.http.request({ method: "GET", path: `/email/topics/${enc(id)}` });
434
445
  }
435
446
  update(id, body) {
436
- return this.http.request({ method: "PATCH", path: `/topics/${enc(id)}`, body });
447
+ return this.http.request({ method: "PATCH", path: `/email/topics/${enc(id)}`, body });
437
448
  }
438
449
  delete(id) {
439
- return this.http.request({ method: "DELETE", path: `/topics/${enc(id)}` });
450
+ return this.http.request({ method: "DELETE", path: `/email/topics/${enc(id)}` });
440
451
  }
441
452
  /** List a contact's effective topic subscriptions. */
442
453
  listTopics(contactId, params = {}) {
@@ -449,63 +460,63 @@ var Topics = class extends Resource {
449
460
  };
450
461
  var Campaigns = class extends Resource {
451
462
  list(params = {}) {
452
- return this.http.request({ method: "GET", path: "/campaigns", query: params });
463
+ return this.http.request({ method: "GET", path: "/email/campaigns", query: params });
453
464
  }
454
465
  listAll(params = {}) {
455
- return paginate(this.http, "/campaigns", params);
466
+ return paginate(this.http, "/email/campaigns", params);
456
467
  }
457
468
  create(body) {
458
- return this.http.request({ method: "POST", path: "/campaigns", body });
469
+ return this.http.request({ method: "POST", path: "/email/campaigns", body });
459
470
  }
460
471
  get(id) {
461
- return this.http.request({ method: "GET", path: `/campaigns/${enc(id)}` });
472
+ return this.http.request({ method: "GET", path: `/email/campaigns/${enc(id)}` });
462
473
  }
463
474
  update(id, body) {
464
- return this.http.request({ method: "PATCH", path: `/campaigns/${enc(id)}`, body });
475
+ return this.http.request({ method: "PATCH", path: `/email/campaigns/${enc(id)}`, body });
465
476
  }
466
477
  delete(id) {
467
- return this.http.request({ method: "DELETE", path: `/campaigns/${enc(id)}` });
478
+ return this.http.request({ method: "DELETE", path: `/email/campaigns/${enc(id)}` });
468
479
  }
469
480
  send(id) {
470
- return this.http.request({ method: "POST", path: `/campaigns/${enc(id)}/send` });
481
+ return this.http.request({ method: "POST", path: `/email/campaigns/${enc(id)}/send` });
471
482
  }
472
483
  cancel(id) {
473
- return this.http.request({ method: "POST", path: `/campaigns/${enc(id)}/cancel` });
484
+ return this.http.request({ method: "POST", path: `/email/campaigns/${enc(id)}/cancel` });
474
485
  }
475
486
  /** Pause a scheduled/sending campaign; already-sent messages are untouched. */
476
487
  pause(id) {
477
- return this.http.request({ method: "POST", path: `/campaigns/${enc(id)}/pause` });
488
+ return this.http.request({ method: "POST", path: `/email/campaigns/${enc(id)}/pause` });
478
489
  }
479
490
  /** Resume a paused campaign; sending continues with the remaining recipients. */
480
491
  resume(id) {
481
- return this.http.request({ method: "POST", path: `/campaigns/${enc(id)}/resume` });
492
+ return this.http.request({ method: "POST", path: `/email/campaigns/${enc(id)}/resume` });
482
493
  }
483
494
  reschedule(id, body) {
484
- return this.http.request({ method: "POST", path: `/campaigns/${enc(id)}/reschedule`, body });
495
+ return this.http.request({ method: "POST", path: `/email/campaigns/${enc(id)}/reschedule`, body });
485
496
  }
486
497
  /** Non-mutating pre-send validation report. */
487
498
  validate(id) {
488
- return this.http.request({ method: "GET", path: `/campaigns/${enc(id)}/validate` });
499
+ return this.http.request({ method: "GET", path: `/email/campaigns/${enc(id)}/validate` });
489
500
  }
490
501
  };
491
502
  var Templates = class extends Resource {
492
503
  list(params = {}) {
493
- return this.http.request({ method: "GET", path: "/templates", query: params });
504
+ return this.http.request({ method: "GET", path: "/email/templates", query: params });
494
505
  }
495
506
  listAll(params = {}) {
496
- return paginate(this.http, "/templates", params);
507
+ return paginate(this.http, "/email/templates", params);
497
508
  }
498
509
  create(body) {
499
- return this.http.request({ method: "POST", path: "/templates", body });
510
+ return this.http.request({ method: "POST", path: "/email/templates", body });
500
511
  }
501
512
  get(id) {
502
- return this.http.request({ method: "GET", path: `/templates/${enc(id)}` });
513
+ return this.http.request({ method: "GET", path: `/email/templates/${enc(id)}` });
503
514
  }
504
515
  update(id, body) {
505
- return this.http.request({ method: "PATCH", path: `/templates/${enc(id)}`, body });
516
+ return this.http.request({ method: "PATCH", path: `/email/templates/${enc(id)}`, body });
506
517
  }
507
518
  delete(id) {
508
- return this.http.request({ method: "DELETE", path: `/templates/${enc(id)}` });
519
+ return this.http.request({ method: "DELETE", path: `/email/templates/${enc(id)}` });
509
520
  }
510
521
  };
511
522
  var BrandKits = class extends Resource {
@@ -520,26 +531,26 @@ var BrandKits = class extends Resource {
520
531
  };
521
532
  var Domains = class extends Resource {
522
533
  list(params = {}) {
523
- return this.http.request({ method: "GET", path: "/domains", query: params });
534
+ return this.http.request({ method: "GET", path: "/email/domains", query: params });
524
535
  }
525
536
  listAll(params = {}) {
526
- return paginate(this.http, "/domains", params);
537
+ return paginate(this.http, "/email/domains", params);
527
538
  }
528
539
  create(body) {
529
- return this.http.request({ method: "POST", path: "/domains", body });
540
+ return this.http.request({ method: "POST", path: "/email/domains", body });
530
541
  }
531
542
  get(id) {
532
- return this.http.request({ method: "GET", path: `/domains/${enc(id)}` });
543
+ return this.http.request({ method: "GET", path: `/email/domains/${enc(id)}` });
533
544
  }
534
545
  delete(id) {
535
- return this.http.request({ method: "DELETE", path: `/domains/${enc(id)}` });
546
+ return this.http.request({ method: "DELETE", path: `/email/domains/${enc(id)}` });
536
547
  }
537
548
  update(id, body) {
538
- return this.http.request({ method: "PATCH", path: `/domains/${enc(id)}`, body });
549
+ return this.http.request({ method: "PATCH", path: `/email/domains/${enc(id)}`, body });
539
550
  }
540
551
  /** Run an on-demand DNS/SES verification check. */
541
552
  verify(id) {
542
- return this.http.request({ method: "POST", path: `/domains/${enc(id)}/verify` });
553
+ return this.http.request({ method: "POST", path: `/email/domains/${enc(id)}/verify` });
543
554
  }
544
555
  };
545
556
  var Webhooks = class extends Resource {
@@ -632,15 +643,11 @@ function enc(segment) {
632
643
 
633
644
  // src/client.ts
634
645
  var Unitpost = class {
635
- emails;
646
+ email;
636
647
  contacts;
637
648
  contactFields;
638
649
  segments;
639
- topics;
640
- campaigns;
641
- templates;
642
650
  brandKits;
643
- domains;
644
651
  webhooks;
645
652
  apiKeys;
646
653
  suppressions;
@@ -650,15 +657,11 @@ var Unitpost = class {
650
657
  constructor(apiKeyOrOptions) {
651
658
  const options = typeof apiKeyOrOptions === "string" ? { apiKey: apiKeyOrOptions } : apiKeyOrOptions ?? {};
652
659
  const http = new HttpClient(options);
653
- this.emails = new Emails(http);
660
+ this.email = new Email(http);
654
661
  this.contacts = new Contacts(http);
655
662
  this.contactFields = new ContactFields(http);
656
663
  this.segments = new Segments(http);
657
- this.topics = new Topics(http);
658
- this.campaigns = new Campaigns(http);
659
- this.templates = new Templates(http);
660
664
  this.brandKits = new BrandKits(http);
661
- this.domains = new Domains(http);
662
665
  this.webhooks = new Webhooks(http);
663
666
  this.apiKeys = new ApiKeys(http);
664
667
  this.suppressions = new Suppressions(http);