@proveanything/smartlinks 1.1.26 → 1.2.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.
@@ -1,4 +1,5 @@
1
1
  import type { IdField } from './common';
2
+ import type { BroadcastChannel } from './broadcasts';
2
3
  /**
3
4
  * Target subject for notifications (product, collection, etc.)
4
5
  */
@@ -8,103 +9,6 @@ export interface NotificationSubjectTarget {
8
9
  /** ID of the target entity */
9
10
  id: string;
10
11
  }
11
- /**
12
- * Push notification template content
13
- */
14
- export interface PushNotificationTemplate {
15
- /** Notification title */
16
- title: string;
17
- /** Notification body text */
18
- body: string;
19
- /** Optional icon URL for the notification */
20
- icon?: string;
21
- }
22
- /**
23
- * Email notification template content
24
- */
25
- export interface EmailNotificationTemplate {
26
- /** Email subject line */
27
- subject: string;
28
- /** Email body content (plain text or HTML) */
29
- body: string;
30
- }
31
- /**
32
- * Wallet pass update template content
33
- */
34
- export interface WalletUpdateTemplate {
35
- textModulesData?: Array<{
36
- /** Module ID */
37
- id: string;
38
- /** Module header text */
39
- header: string;
40
- /** Module body text */
41
- body: string;
42
- }>;
43
- }
44
- /**
45
- * Notification template containing different delivery methods
46
- */
47
- export interface NotificationTemplate {
48
- /** Push notification content */
49
- push?: PushNotificationTemplate;
50
- /** Email notification content */
51
- email?: EmailNotificationTemplate;
52
- /** Wallet pass update content */
53
- walletUpdate?: WalletUpdateTemplate;
54
- }
55
- /**
56
- * Request payload for sending notifications
57
- */
58
- export interface SendNotificationRequest {
59
- /** Target subjects that should receive the notification */
60
- subjectTargets: NotificationSubjectTarget[];
61
- /** Severity level of the notification */
62
- severity: 'low' | 'normal' | 'important' | 'critical';
63
- /** Delivery channel mode preference */
64
- mode: 'preferred' | 'all';
65
- /** Specific channels to use for delivery */
66
- channels: ("push" | "email" | "wallet")[];
67
- /** Notification content templates for different delivery methods */
68
- template: NotificationTemplate;
69
- }
70
- /**
71
- * Response from sending notifications
72
- */
73
- export interface SendNotificationResponse {
74
- /** Whether the request was accepted */
75
- ok: boolean;
76
- /** Unique ID for this notification */
77
- notificationId: string;
78
- /** Basic counts for contacts and attempts */
79
- counts: {
80
- contacts: number;
81
- attempts: number;
82
- };
83
- /** Detailed status for the notification */
84
- status: {
85
- notification: {
86
- /** The notification ID (repeated for convenience) */
87
- notificationId: string;
88
- /** Current processing state */
89
- state: 'queued' | 'sent' | 'failed' | 'confirmed' | string;
90
- /** Targets this notification refers to */
91
- subjectTargets: NotificationSubjectTarget[];
92
- /** Severity of this notification */
93
- severity: 'low' | 'normal' | 'important' | 'critical' | string;
94
- /** Optional channel overrides used when sending */
95
- channelsOverride: Record<string, any>;
96
- /** The effective template used */
97
- template: NotificationTemplate;
98
- };
99
- /** Totals across all contacts */
100
- totals: {
101
- queued: number;
102
- sent: number;
103
- failed: number;
104
- confirmed: number;
105
- };
106
- };
107
- }
108
12
  export interface CommunicationEvent {
109
13
  orgId: string;
110
14
  broadcastId?: string;
@@ -197,3 +101,182 @@ export interface RecipientsPage {
197
101
  offset: number;
198
102
  note?: string;
199
103
  }
104
+ export interface PushSubscriptionJSON {
105
+ endpoint: string;
106
+ keys?: {
107
+ p256dh?: string;
108
+ auth?: string;
109
+ };
110
+ }
111
+ export interface PushSubscribeMeta {
112
+ /** Required collection scope */
113
+ collectionId: string;
114
+ /** Optional explicit contact ID */
115
+ contactId?: string;
116
+ /** Optional user ID; may be mapped to a contact like "user:{userId}" */
117
+ userId?: string;
118
+ /** Optional product scope */
119
+ productId?: string;
120
+ /** Optional labels and arbitrary metadata */
121
+ labels?: Record<string, string>;
122
+ [key: string]: any;
123
+ }
124
+ export interface PushSubscribeRequest {
125
+ /** Browser/service worker subscription payload */
126
+ subscription: PushSubscriptionJSON;
127
+ /** Metadata and scoping */
128
+ meta: PushSubscribeMeta;
129
+ }
130
+ export interface PushVapidResponse {
131
+ publicKey: string;
132
+ }
133
+ export interface PushSubscribeResponse {
134
+ ok: true;
135
+ id: string;
136
+ }
137
+ export interface CommsSettings {
138
+ unsub?: {
139
+ requireToken?: boolean;
140
+ /** Secret for token generation; omitted unless includeSecret=true */
141
+ secret?: string;
142
+ /** Convenience flag indicating a secret is set (masked responses) */
143
+ hasSecret?: boolean;
144
+ };
145
+ /** Map of topic keys to topic config */
146
+ topics?: Record<string, TopicConfig>;
147
+ [k: string]: any;
148
+ }
149
+ export interface TopicConfig {
150
+ label?: string;
151
+ description?: string;
152
+ /** Optional UI-only grouping labels */
153
+ labels?: string[];
154
+ defaults?: {
155
+ channels?: Partial<Record<BroadcastChannel, boolean>>;
156
+ topics?: Record<string, boolean | undefined>;
157
+ };
158
+ rules?: {
159
+ allowChannels?: BroadcastChannel[];
160
+ allowUnsubscribe?: boolean;
161
+ required?: boolean;
162
+ };
163
+ [k: string]: any;
164
+ }
165
+ export interface CommsSettingsGetResponse {
166
+ ok: true;
167
+ settings: CommsSettings;
168
+ }
169
+ export type CommsSettingsPatchBody = Partial<CommsSettings>;
170
+ export interface CommsPublicTopicsResponse {
171
+ ok: true;
172
+ topics: Record<string, TopicConfig>;
173
+ }
174
+ export interface UnsubscribeQuery {
175
+ contactId: string;
176
+ topic?: string;
177
+ channel?: BroadcastChannel;
178
+ token?: string;
179
+ }
180
+ export interface UnsubscribeResponse {
181
+ ok: true;
182
+ applied?: {
183
+ channels?: Record<string, boolean>;
184
+ topics?: Record<string, boolean>;
185
+ };
186
+ }
187
+ export type ConsentChannels = Partial<Record<BroadcastChannel, boolean>>;
188
+ type SubjectType = import('./contact').SubjectType;
189
+ export interface CommsConsentUpsertRequest {
190
+ contactId: string;
191
+ channels?: ConsentChannels;
192
+ topics?: Record<string, boolean>;
193
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>;
194
+ }
195
+ export interface CommsPreferencesUpsertRequest {
196
+ contactId: string;
197
+ subject?: {
198
+ type: SubjectType;
199
+ id: string;
200
+ productId?: string;
201
+ };
202
+ channels?: ConsentChannels;
203
+ topics?: Record<string, boolean>;
204
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>;
205
+ }
206
+ export interface CommsSubscribeRequest {
207
+ contactId: string;
208
+ subject: {
209
+ type: SubjectType;
210
+ id: string;
211
+ productId?: string;
212
+ };
213
+ subscribe: boolean;
214
+ source?: string;
215
+ }
216
+ export interface CommsSubscribeResponse {
217
+ ok: true;
218
+ subscriptionId: string;
219
+ }
220
+ export interface CommsSubscriptionCheckQuery {
221
+ contactId: string;
222
+ subjectType: SubjectType;
223
+ subjectId: string;
224
+ productId?: string;
225
+ }
226
+ export interface CommsSubscriptionCheckResponse {
227
+ ok: true;
228
+ subscribed: boolean;
229
+ }
230
+ export interface CommsListMethodsQuery {
231
+ contactId: string;
232
+ type?: BroadcastChannel;
233
+ }
234
+ export interface CommsListMethodsResponse {
235
+ ok: true;
236
+ methods: import('./contact').CommMethod[];
237
+ }
238
+ export interface RegisterEmailMethodRequest {
239
+ contactId?: string;
240
+ email?: string;
241
+ userId?: string;
242
+ }
243
+ export interface RegisterSmsMethodRequest {
244
+ contactId?: string;
245
+ phone?: string;
246
+ userId?: string;
247
+ }
248
+ export interface RegisterMethodResponse {
249
+ ok: true;
250
+ contactId: string;
251
+ }
252
+ export interface SubscriptionsResolveRequest {
253
+ subject: {
254
+ type: SubjectType;
255
+ id: string;
256
+ productId?: string;
257
+ };
258
+ hints: {
259
+ userId?: string;
260
+ pushEndpoint?: string;
261
+ email?: string;
262
+ walletObjectId?: string;
263
+ };
264
+ }
265
+ export interface SubscriptionsResolveResponse {
266
+ ok: true;
267
+ subject: {
268
+ type: SubjectType;
269
+ id: string;
270
+ productId?: string;
271
+ };
272
+ contacts: Array<{
273
+ contactId: string;
274
+ subscribed: boolean;
275
+ channels?: Partial<Record<BroadcastChannel, boolean>>;
276
+ walletForSubject?: boolean;
277
+ }>;
278
+ anySubscribed: boolean;
279
+ anyMethods: boolean;
280
+ anyWalletForSubject: boolean;
281
+ }
282
+ export {};
@@ -18,6 +18,8 @@ export interface Contact {
18
18
  locale?: string | null;
19
19
  timezone?: string | null;
20
20
  externalIds?: Record<string, any>;
21
+ /** First-party communications state (preferred). If absent, may exist under customFields.comms */
22
+ comms?: CommsState;
21
23
  customFields: ContactCustomFields;
22
24
  createdAt: string;
23
25
  updatedAt: string;
@@ -75,3 +77,55 @@ export interface PublicUpdateMyContactResponse {
75
77
  ok: boolean;
76
78
  contact: ContactPublic;
77
79
  }
80
+ export type ChannelName = import('./broadcasts').BroadcastChannel;
81
+ export type SubjectType = 'product' | 'proof' | 'batch';
82
+ /** Registered delivery method for a contact */
83
+ export interface CommMethodMeta {
84
+ pushEndpoint?: string;
85
+ p256dh?: string;
86
+ auth?: string;
87
+ phone?: string;
88
+ email?: string;
89
+ walletObjectId?: string;
90
+ subjectType?: SubjectType;
91
+ subjectId?: string;
92
+ productId?: string;
93
+ }
94
+ export interface CommMethod {
95
+ id?: string;
96
+ type: ChannelName;
97
+ meta?: CommMethodMeta;
98
+ verified?: boolean;
99
+ suppressed?: boolean;
100
+ createdAt?: string;
101
+ }
102
+ /** Subject-level opt-in linking contact to a subject (audience targeting) */
103
+ export interface Subscription {
104
+ id: string;
105
+ subjectType: SubjectType;
106
+ subjectId: string;
107
+ productId?: string | null;
108
+ contactId: string;
109
+ source?: string;
110
+ createdAt?: string;
111
+ deletedAt?: string | null;
112
+ }
113
+ /** Per-subject consent (or `_default` when no subject) */
114
+ export interface PreferenceEntry {
115
+ subjectType?: SubjectType | null;
116
+ subjectId?: string | null;
117
+ /** Channel-level toggles for delivery */
118
+ channels?: Partial<Record<ChannelName, boolean>>;
119
+ /** Topic-level toggles (apply across channels) */
120
+ topics?: Record<string, boolean>;
121
+ /** Optional per-channel topic preferences */
122
+ topicsByChannel?: Partial<Record<ChannelName, Record<string, boolean>>>;
123
+ updatedAt?: string;
124
+ }
125
+ /** Communications state embedded in contact customFields or first-party column */
126
+ export interface CommsState {
127
+ methods?: CommMethod[];
128
+ subscriptions?: Subscription[];
129
+ /** Keyed by `_default` or `${type}_${id}` */
130
+ preferences?: Record<string, PreferenceEntry>;
131
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.1.26",
3
+ "version": "1.2.0",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",