@proteos/sdk 0.92.0 → 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/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +94 -2
- package/dist/index.d.ts +94 -2
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/conversation/index.ts +24 -0
- package/src/conversation/types.ts +72 -1
- package/src/index.ts +5 -0
package/package.json
CHANGED
|
@@ -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,
|
|
@@ -95,6 +96,7 @@ import type {
|
|
|
95
96
|
ListMessagesQuery,
|
|
96
97
|
ListMessageTemplatesQuery,
|
|
97
98
|
ListMistranscribedTermsQuery,
|
|
99
|
+
ListPermissionEventsResponse,
|
|
98
100
|
ListReactionsResponse,
|
|
99
101
|
ListResponse,
|
|
100
102
|
ListRoomsQuery,
|
|
@@ -619,7 +621,15 @@ export interface ContactService {
|
|
|
619
621
|
unlinkRecord(linkId: string): Promise<void>
|
|
620
622
|
/** Fold source_contact_id into contactId (contactId wins). */
|
|
621
623
|
merge(contactId: string, request: MergeContactsRequest): Promise<Contact>
|
|
624
|
+
/** The contact's permission ledger, newest first, with per-purpose consent. */
|
|
625
|
+
listPermissionEvents(contactId: string): Promise<ListPermissionEventsResponse>
|
|
622
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>
|
|
623
633
|
block(contactId: string, request?: BlockContactRequest): Promise<Contact>
|
|
624
634
|
unblock(contactId: string, request?: BlockContactRequest): Promise<Contact>
|
|
625
635
|
requestErasure(contactId: string): Promise<ContactErasureRequest>
|
|
@@ -708,6 +718,13 @@ class ContactServiceImpl implements ContactService {
|
|
|
708
718
|
)
|
|
709
719
|
}
|
|
710
720
|
|
|
721
|
+
listPermissionEvents(contactId: string): Promise<ListPermissionEventsResponse> {
|
|
722
|
+
return this.client.request(
|
|
723
|
+
'GET',
|
|
724
|
+
`${CONVERSATION_BASE_PATH}/contacts/${encodeURIComponent(contactId)}/permission-events`,
|
|
725
|
+
)
|
|
726
|
+
}
|
|
727
|
+
|
|
711
728
|
recordPermissionEvent(
|
|
712
729
|
contactId: string,
|
|
713
730
|
request: RecordPermissionEventRequest,
|
|
@@ -719,6 +736,13 @@ class ContactServiceImpl implements ContactService {
|
|
|
719
736
|
)
|
|
720
737
|
}
|
|
721
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
|
+
|
|
722
746
|
block(contactId: string, request: BlockContactRequest = {}): Promise<Contact> {
|
|
723
747
|
return this.client.request(
|
|
724
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,13 @@ 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
|
-
|
|
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'
|
|
2550
|
+
/**
|
|
2551
|
+
* Why a message is sent — the unit a person consents to. A fixed set.
|
|
2552
|
+
* `transactional` is never consent-gated (only blocks and erasure stop it).
|
|
2553
|
+
*/
|
|
2554
|
+
export type Purpose = 'transactional' | 'service' | 'sales' | 'marketing' | 'newsletter'
|
|
2534
2555
|
/**
|
|
2535
2556
|
* Where a permission event came from. `provider` = the sending platform
|
|
2536
2557
|
* observed it (its unsubscribe link, a spam complaint relayed by the mailbox
|
|
@@ -2631,6 +2652,8 @@ export interface ContactPermissionEvent {
|
|
|
2631
2652
|
/** Scopes the event to one address; absent/empty = contact-level. */
|
|
2632
2653
|
contact_address_id?: string
|
|
2633
2654
|
event: PermissionEventType
|
|
2655
|
+
/** Narrows a consent event to one purpose; absent = all purposes. */
|
|
2656
|
+
purpose?: Purpose
|
|
2634
2657
|
basis?: string
|
|
2635
2658
|
source: PermissionEventSource
|
|
2636
2659
|
occurred_at: string
|
|
@@ -2640,6 +2663,46 @@ export interface ContactPermissionEvent {
|
|
|
2640
2663
|
created_by: UserRef
|
|
2641
2664
|
}
|
|
2642
2665
|
|
|
2666
|
+
/** A contact's consent for one purpose, derived from the ledger (not stored). */
|
|
2667
|
+
export interface ContactPurposeStatus {
|
|
2668
|
+
purpose: Exclude<Purpose, 'transactional'>
|
|
2669
|
+
status: ConsentStatus
|
|
2670
|
+
/** The ledger event that set `status`; absent when unknown. */
|
|
2671
|
+
decided_by_event_id?: string
|
|
2672
|
+
/** True when that event applies to all purposes. */
|
|
2673
|
+
is_inherited: boolean
|
|
2674
|
+
/** Addresses opted out of this purpose (or all) on their own scope. */
|
|
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
|
|
2698
|
+
}
|
|
2699
|
+
|
|
2700
|
+
/** A contact's ledger, newest first, with the per-purpose consent. */
|
|
2701
|
+
export interface ListPermissionEventsResponse {
|
|
2702
|
+
data: ContactPermissionEvent[]
|
|
2703
|
+
purposes: ContactPurposeStatus[]
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2643
2706
|
/** One candidate duplicate pair awaiting review. */
|
|
2644
2707
|
export interface ContactMergeProposal {
|
|
2645
2708
|
id: string
|
|
@@ -2818,6 +2881,8 @@ export interface RecordPermissionEventRequest {
|
|
|
2818
2881
|
*/
|
|
2819
2882
|
address?: string
|
|
2820
2883
|
event: PermissionEventType
|
|
2884
|
+
/** One purpose; absent = all purposes. Consent events only; never `transactional`. */
|
|
2885
|
+
purpose?: Purpose
|
|
2821
2886
|
basis?: string
|
|
2822
2887
|
source?: PermissionEventSource
|
|
2823
2888
|
occurred_at?: string
|
|
@@ -3442,6 +3507,8 @@ export interface MessageTemplate {
|
|
|
3442
3507
|
channel?: Channel
|
|
3443
3508
|
/** The language it is written in, such as `de` or `en-GB`. */
|
|
3444
3509
|
language?: string
|
|
3510
|
+
/** Why messages from it are sent; a send of it that names no purpose takes this one. */
|
|
3511
|
+
purpose?: Purpose
|
|
3445
3512
|
tags: string[]
|
|
3446
3513
|
/** A snippet has none. */
|
|
3447
3514
|
subject?: string
|
|
@@ -3470,6 +3537,8 @@ export interface CreateMessageTemplateRequest {
|
|
|
3470
3537
|
/** Empty or omitted writes it for any channel. */
|
|
3471
3538
|
channel?: Channel | ''
|
|
3472
3539
|
language?: string
|
|
3540
|
+
/** Empty or omitted leaves it unsaid. */
|
|
3541
|
+
purpose?: Purpose | ''
|
|
3473
3542
|
tags?: string[]
|
|
3474
3543
|
subject?: string
|
|
3475
3544
|
/** `html` or `text` is required. */
|
|
@@ -3621,6 +3690,8 @@ export interface SendEligibilityRequest {
|
|
|
3621
3690
|
* message.
|
|
3622
3691
|
*/
|
|
3623
3692
|
action_type?: ChannelActionType
|
|
3693
|
+
/** The purpose the send would have; consent is checked for it. */
|
|
3694
|
+
purpose?: Purpose
|
|
3624
3695
|
}
|
|
3625
3696
|
|
|
3626
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,
|
|
@@ -333,6 +334,8 @@ export type {
|
|
|
333
334
|
ContactGroupService,
|
|
334
335
|
ContactGroupSource,
|
|
335
336
|
ContactMergeProposal,
|
|
337
|
+
ContactPermissionEvent,
|
|
338
|
+
ContactPurposeStatus,
|
|
336
339
|
ContactRecordLink,
|
|
337
340
|
ContactRecordLinkSource,
|
|
338
341
|
ContactRef,
|
|
@@ -482,6 +485,7 @@ export type {
|
|
|
482
485
|
ListMessagesQuery,
|
|
483
486
|
ListMessageTemplatesQuery,
|
|
484
487
|
ListMistranscribedTermsQuery,
|
|
488
|
+
ListPermissionEventsResponse,
|
|
485
489
|
// Conversation-local page envelope ({meta, data}) — distinct from the
|
|
486
490
|
// PageIterator-based ListResult used by the other modules.
|
|
487
491
|
ListResponse,
|
|
@@ -526,6 +530,7 @@ export type {
|
|
|
526
530
|
PhoneNumberRouting,
|
|
527
531
|
PhoneNumberStatus,
|
|
528
532
|
ProfileVisitParams,
|
|
533
|
+
Purpose,
|
|
529
534
|
Reaction,
|
|
530
535
|
ReactionCapability,
|
|
531
536
|
ReactionOption,
|