@proteos/sdk 0.92.1 → 0.93.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proteos/sdk",
3
- "version": "0.92.1",
3
+ "version": "0.93.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "TypeScript SDK for the Proteos platform",
6
6
  "repository": {
@@ -11,6 +11,7 @@ import type {
11
11
  ChannelEvent,
12
12
  Connection,
13
13
  ConnectorCatalogEntry,
14
+ ConsentRequest,
14
15
  Contact,
15
16
  ContactAddress,
16
17
  ContactErasureRequest,
@@ -623,6 +624,12 @@ export interface ContactService {
623
624
  /** The contact's permission ledger, newest first, with per-purpose consent. */
624
625
  listPermissionEvents(contactId: string): Promise<ListPermissionEventsResponse>
625
626
  recordPermissionEvent(contactId: string, request: RecordPermissionEventRequest): Promise<Contact>
627
+ /**
628
+ * Send a new confirmation for a double opt-in that was not confirmed (new
629
+ * link and expiry, same mailbox, address and purpose); 409
630
+ * consent_request_confirmed once it was.
631
+ */
632
+ resendConsentRequest(requestId: string): Promise<ConsentRequest>
626
633
  block(contactId: string, request?: BlockContactRequest): Promise<Contact>
627
634
  unblock(contactId: string, request?: BlockContactRequest): Promise<Contact>
628
635
  requestErasure(contactId: string): Promise<ContactErasureRequest>
@@ -729,6 +736,13 @@ class ContactServiceImpl implements ContactService {
729
736
  )
730
737
  }
731
738
 
739
+ resendConsentRequest(requestId: string): Promise<ConsentRequest> {
740
+ return this.client.request(
741
+ 'POST',
742
+ `${CONVERSATION_BASE_PATH}/consent-requests/${encodeURIComponent(requestId)}/resend`,
743
+ )
744
+ }
745
+
732
746
  block(contactId: string, request: BlockContactRequest = {}): Promise<Contact> {
733
747
  return this.client.request(
734
748
  'POST',
@@ -566,6 +566,11 @@ export interface Message {
566
566
  * or nothing.
567
567
  */
568
568
  has_unsubscribe_link?: boolean
569
+ /**
570
+ * Why the message is sent: the purpose the recipients' consent was checked
571
+ * for. Absent when the sender did not say.
572
+ */
573
+ purpose?: Purpose
569
574
  /** The layout chosen for this email (a message template of kind `layout`). Absent means none. May no longer resolve, which fails the send. */
570
575
  layout_id?: string
571
576
  /**
@@ -791,6 +796,14 @@ export interface SendMessageRequest {
791
796
  * refused with 400 `unsubscribe_not_possible`.
792
797
  */
793
798
  unsubscribe?: UnsubscribeChoice
799
+ /**
800
+ * Why the message is sent. The recipients' consent is checked for it: one
801
+ * who opted out of it (or of everything) is refused with 403
802
+ * `contact_opted_out`. Omitted takes the template's purpose, else none, and
803
+ * then only an opt-out from everything stops the send. `transactional`
804
+ * skips consent and cannot carry an unsubscribe link.
805
+ */
806
+ purpose?: Purpose
794
807
  /**
795
808
  * Wraps the body in a stored layout when the email is sent: the id or key
796
809
  * of a message template of kind `layout`, `none` (or omitted) for no layout.
@@ -921,6 +934,8 @@ export interface UpdateDraftRequest {
921
934
  signature?: SignatureChoice
922
935
  /** Replaces the draft's unsubscribe choice. Omit to keep it. */
923
936
  unsubscribe?: UnsubscribeChoice
937
+ /** Replaces the draft's purpose; `''` clears it. Omit to keep it. */
938
+ purpose?: Purpose | ''
924
939
  /** Replaces the draft's layout: `none`, or a layout's id or key. Omit to keep it. */
925
940
  layout?: string
926
941
  /** What this edit is in the draft's history. Defaults to `edited`. */
@@ -2530,7 +2545,8 @@ export type ContactAddressSource = 'sync' | 'ingest' | 'manual' | 'merge'
2530
2545
  export type ContactSource = 'sync' | 'ingest' | 'manual' | 'merge'
2531
2546
  export type ContactStatus = 'active' | 'merged' | 'archived' | 'erased'
2532
2547
  export type ConsentStatus = 'unknown' | 'opted_in' | 'opted_out'
2533
- export type PermissionEventType = 'opt_in' | 'opt_out' | 'block' | 'unblock'
2548
+ /** `opt_in_requested`: a double opt-in waits for confirmation; it changes no consent. */
2549
+ export type PermissionEventType = 'opt_in' | 'opt_out' | 'block' | 'unblock' | 'opt_in_requested'
2534
2550
  /**
2535
2551
  * Why a message is sent — the unit a person consents to. A fixed set.
2536
2552
  * `transactional` is never consent-gated (only blocks and erasure stop it).
@@ -2657,6 +2673,28 @@ export interface ContactPurposeStatus {
2657
2673
  is_inherited: boolean
2658
2674
  /** Addresses opted out of this purpose (or all) on their own scope. */
2659
2675
  opted_out_address_ids: string[]
2676
+ /** Addresses with a double opt-in for this purpose waiting to be confirmed. */
2677
+ pending_address_ids: string[]
2678
+ /** Addresses whose double opt-in for this purpose was not confirmed in time. */
2679
+ expired_address_ids: string[]
2680
+ }
2681
+
2682
+ /** One double opt-in: a confirmation email asking one address for one purpose. */
2683
+ export interface ConsentRequest {
2684
+ id: string
2685
+ org_id: string
2686
+ contact_id: string
2687
+ address: string
2688
+ purpose: Exclude<Purpose, 'transactional'>
2689
+ /** The mailbox the confirmation went out from. */
2690
+ connection_id: string
2691
+ message_id?: string
2692
+ /** The opt_in_requested event in the contact's ledger. */
2693
+ requested_event_id?: string
2694
+ evidence?: Record<string, unknown>
2695
+ expires_at: string
2696
+ confirmed_at?: string
2697
+ created_at: string
2660
2698
  }
2661
2699
 
2662
2700
  /** A contact's ledger, newest first, with the per-purpose consent. */
@@ -3469,6 +3507,8 @@ export interface MessageTemplate {
3469
3507
  channel?: Channel
3470
3508
  /** The language it is written in, such as `de` or `en-GB`. */
3471
3509
  language?: string
3510
+ /** Why messages from it are sent; a send of it that names no purpose takes this one. */
3511
+ purpose?: Purpose
3472
3512
  tags: string[]
3473
3513
  /** A snippet has none. */
3474
3514
  subject?: string
@@ -3497,6 +3537,8 @@ export interface CreateMessageTemplateRequest {
3497
3537
  /** Empty or omitted writes it for any channel. */
3498
3538
  channel?: Channel | ''
3499
3539
  language?: string
3540
+ /** Empty or omitted leaves it unsaid. */
3541
+ purpose?: Purpose | ''
3500
3542
  tags?: string[]
3501
3543
  subject?: string
3502
3544
  /** `html` or `text` is required. */
@@ -3648,6 +3690,8 @@ export interface SendEligibilityRequest {
3648
3690
  * message.
3649
3691
  */
3650
3692
  action_type?: ChannelActionType
3693
+ /** The purpose the send would have; consent is checked for it. */
3694
+ purpose?: Purpose
3651
3695
  }
3652
3696
 
3653
3697
  /**
package/src/index.ts CHANGED
@@ -322,6 +322,7 @@ export type {
322
322
  ConnectorCatalogEntry,
323
323
  ConnectorKey,
324
324
  ConnectorProvider,
325
+ ConsentRequest,
325
326
  ConsentStatus,
326
327
  Contact,
327
328
  ContactAddress,