@proveanything/smartlinks 1.1.26 → 1.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/API_SUMMARY.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Smartlinks API Summary
2
2
 
3
- Version: 1.1.26 | Generated: 2026-01-17T11:03:13.776Z
3
+ Version: 1.2.1 | Generated: 2026-01-21T17:11:59.946Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -453,6 +453,16 @@ interface BroadcastRecord {
453
453
  color?: string
454
454
  }
455
455
  broadcastType?: string
456
+ topic: string
457
+ channelSettings?: {
458
+ mode?: 'preferred' | 'channels' | 'all'
459
+ channels?: Array<{
460
+ channel: import('./broadcasts').BroadcastChannel
461
+ enabled?: boolean
462
+ priority?: number
463
+ templateId?: string
464
+ }>
465
+ }
456
466
  [key: string]: unknown
457
467
  }
458
468
  createdAt: string
@@ -484,30 +494,31 @@ interface BroadcastRecipientsResponse {
484
494
  interface BroadcastPreviewRequest {
485
495
  contactId?: string
486
496
  email?: string
497
+ phone?: string
487
498
  props?: Record<string, any>
488
- }
489
- ```
490
-
491
- **BroadcastPreviewResponse** (interface)
492
- ```typescript
493
- interface BroadcastPreviewResponse {
494
- ok: boolean; html: string
499
+ channelOverride?: BroadcastChannel
500
+ hydrate?: boolean
501
+ include?: { product?: boolean; proof?: boolean; user?: boolean; [k: string]: boolean | undefined }
495
502
  }
496
503
  ```
497
504
 
498
505
  **BroadcastSendTestRequest** (interface)
499
506
  ```typescript
500
507
  interface BroadcastSendTestRequest {
501
- to: string
502
- subject?: string
508
+ contactId?: string
509
+ email?: string
510
+ phone?: string
503
511
  props?: Record<string, any>
512
+ channelOverride?: BroadcastChannel
513
+ hydrate?: boolean
514
+ include?: { product?: boolean; proof?: boolean; user?: boolean; [k: string]: boolean | undefined }
504
515
  }
505
516
  ```
506
517
 
507
518
  **BroadcastSendTestResponse** (interface)
508
519
  ```typescript
509
520
  interface BroadcastSendTestResponse {
510
- ok: boolean; id?: string
521
+ ok: boolean; id?: string; channel?: BroadcastChannel
511
522
  }
512
523
  ```
513
524
 
@@ -537,12 +548,24 @@ interface BroadcastSendManualResponse {
537
548
  }
538
549
  ```
539
550
 
551
+ **BroadcastSendRequest** (interface)
552
+ ```typescript
553
+ interface BroadcastSendRequest {
554
+ pageSize?: number
555
+ maxPages?: number
556
+ sharedContext?: Record<string, any>
557
+ channel?: BroadcastChannel
558
+ hydrate?: boolean
559
+ include?: { product?: boolean; proof?: boolean; user?: boolean; [k: string]: boolean | undefined }
560
+ }
561
+ ```
562
+
540
563
  **BroadcastAppendEventBody** (interface)
541
564
  ```typescript
542
565
  interface BroadcastAppendEventBody {
543
566
  broadcastId: string
544
567
  contactId?: string
545
- channel?: 'email'
568
+ channel?: BroadcastChannel
546
569
  templateId?: string
547
570
  eventType: string
548
571
  outcome?: 'success' | 'failed'
@@ -560,6 +583,10 @@ interface BroadcastAppendBulkBody {
560
583
  }
561
584
  ```
562
585
 
586
+ **BroadcastChannel** = `'email' | 'push' | 'sms' | 'wallet'`
587
+
588
+ **BroadcastPreviewResponse** = ``
589
+
563
590
  ### claimSet
564
591
 
565
592
  **ClaimCodeRef** (interface)
@@ -657,82 +684,6 @@ interface NotificationSubjectTarget {
657
684
  }
658
685
  ```
659
686
 
660
- **PushNotificationTemplate** (interface)
661
- ```typescript
662
- interface PushNotificationTemplate {
663
- title: string
664
- body: string
665
- icon?: string
666
- }
667
- ```
668
-
669
- **EmailNotificationTemplate** (interface)
670
- ```typescript
671
- interface EmailNotificationTemplate {
672
- subject: string
673
- body: string
674
- }
675
- ```
676
-
677
- **WalletUpdateTemplate** (interface)
678
- ```typescript
679
- interface WalletUpdateTemplate {
680
- textModulesData?: Array<{
681
- id: string
682
- header: string
683
- body: string
684
- }>
685
- }
686
- ```
687
-
688
- **NotificationTemplate** (interface)
689
- ```typescript
690
- interface NotificationTemplate {
691
- push?: PushNotificationTemplate
692
- email?: EmailNotificationTemplate
693
- walletUpdate?: WalletUpdateTemplate
694
- }
695
- ```
696
-
697
- **SendNotificationRequest** (interface)
698
- ```typescript
699
- interface SendNotificationRequest {
700
- subjectTargets: NotificationSubjectTarget[]
701
- severity: 'low' | 'normal' | 'important' | 'critical'
702
- mode: 'preferred' | 'all'
703
- channels : ("push" | "email" | "wallet")[]
704
- template: NotificationTemplate
705
- }
706
- ```
707
-
708
- **SendNotificationResponse** (interface)
709
- ```typescript
710
- interface SendNotificationResponse {
711
- ok: boolean
712
- notificationId: string
713
- counts: {
714
- contacts: number
715
- attempts: number
716
- }
717
- status: {
718
- notification: {
719
- notificationId: string
720
- state: 'queued' | 'sent' | 'failed' | 'confirmed' | string
721
- subjectTargets: NotificationSubjectTarget[]
722
- severity: 'low' | 'normal' | 'important' | 'critical' | string
723
- channelsOverride: Record<string, any>
724
- template: NotificationTemplate
725
- }
726
- totals: {
727
- queued: number
728
- sent: number
729
- failed: number
730
- confirmed: number
731
- }
732
- }
733
- }
734
- ```
735
-
736
687
  **CommunicationEvent** (interface)
737
688
  ```typescript
738
689
  interface CommunicationEvent {
@@ -861,10 +812,229 @@ interface RecipientsPage {
861
812
  }
862
813
  ```
863
814
 
815
+ **PushSubscriptionJSON** (interface)
816
+ ```typescript
817
+ interface PushSubscriptionJSON {
818
+ endpoint: string
819
+ keys?: {
820
+ p256dh?: string
821
+ auth?: string
822
+ }
823
+ }
824
+ ```
825
+
826
+ **PushVapidResponse** (interface)
827
+ ```typescript
828
+ interface PushVapidResponse {
829
+ publicKey: string
830
+ }
831
+ ```
832
+
833
+ **PushSubscribeResponse** (interface)
834
+ ```typescript
835
+ interface PushSubscribeResponse {
836
+ ok: true; id: string
837
+ }
838
+ ```
839
+
840
+ **RegisterPushMethodRequest** (interface)
841
+ ```typescript
842
+ interface RegisterPushMethodRequest {
843
+ contactId: string
844
+ endpoint: string
845
+ keys: { p256dh: string; auth: string }
846
+ meta?: Record<string, any>
847
+ }
848
+ ```
849
+
850
+ **CommsSettings** (interface)
851
+ ```typescript
852
+ interface CommsSettings {
853
+ unsub?: {
854
+ requireToken?: boolean
855
+ secret?: string
856
+ hasSecret?: boolean
857
+ }
858
+ topics?: Record<string, TopicConfig>
859
+ [k: string]: any
860
+ }
861
+ ```
862
+
863
+ **TopicConfig** (interface)
864
+ ```typescript
865
+ interface TopicConfig {
866
+ label?: string
867
+ description?: string
868
+ labels?: string[]
869
+ defaults?: {
870
+ channels?: Partial<Record<BroadcastChannel, boolean>>
871
+ topics?: Record<string, boolean | undefined>
872
+ }
873
+ rules?: {
874
+ allowChannels?: BroadcastChannel[]
875
+ allowUnsubscribe?: boolean
876
+ required?: boolean
877
+ }
878
+ [k: string]: any
879
+ }
880
+ ```
881
+
882
+ **CommsSettingsGetResponse** (interface)
883
+ ```typescript
884
+ interface CommsSettingsGetResponse {
885
+ ok: true
886
+ settings: CommsSettings
887
+ }
888
+ ```
889
+
890
+ **CommsPublicTopicsResponse** (interface)
891
+ ```typescript
892
+ interface CommsPublicTopicsResponse {
893
+ ok: true; topics: Record<string, TopicConfig>
894
+ }
895
+ ```
896
+
897
+ **UnsubscribeQuery** (interface)
898
+ ```typescript
899
+ interface UnsubscribeQuery {
900
+ contactId: string
901
+ topic?: string
902
+ channel?: BroadcastChannel
903
+ token?: string
904
+ }
905
+ ```
906
+
907
+ **UnsubscribeResponse** (interface)
908
+ ```typescript
909
+ interface UnsubscribeResponse {
910
+ ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> }
911
+ }
912
+ ```
913
+
914
+ **CommsConsentUpsertRequest** (interface)
915
+ ```typescript
916
+ interface CommsConsentUpsertRequest {
917
+ contactId: string
918
+ channels?: ConsentChannels
919
+ topics?: Record<string, boolean>
920
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
921
+ }
922
+ ```
923
+
924
+ **CommsPreferencesUpsertRequest** (interface)
925
+ ```typescript
926
+ interface CommsPreferencesUpsertRequest {
927
+ contactId: string
928
+ subject?: { type: SubjectType; id: string; productId?: string }
929
+ channels?: ConsentChannels
930
+ topics?: Record<string, boolean>
931
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
932
+ }
933
+ ```
934
+
935
+ **CommsSubscribeRequest** (interface)
936
+ ```typescript
937
+ interface CommsSubscribeRequest {
938
+ contactId: string
939
+ subject: { type: SubjectType; id: string; productId?: string }
940
+ subscribe: boolean
941
+ source?: string
942
+ }
943
+ ```
944
+
945
+ **CommsSubscribeResponse** (interface)
946
+ ```typescript
947
+ interface CommsSubscribeResponse {
948
+ ok: true; subscriptionId: string
949
+ }
950
+ ```
951
+
952
+ **CommsSubscriptionCheckQuery** (interface)
953
+ ```typescript
954
+ interface CommsSubscriptionCheckQuery {
955
+ contactId: string
956
+ subjectType: SubjectType
957
+ subjectId: string
958
+ productId?: string
959
+ }
960
+ ```
961
+
962
+ **CommsSubscriptionCheckResponse** (interface)
963
+ ```typescript
964
+ interface CommsSubscriptionCheckResponse {
965
+ ok: true; subscribed: boolean
966
+ }
967
+ ```
968
+
969
+ **CommsListMethodsQuery** (interface)
970
+ ```typescript
971
+ interface CommsListMethodsQuery {
972
+ contactId: string
973
+ type?: BroadcastChannel
974
+ }
975
+ ```
976
+
977
+ **CommsListMethodsResponse** (interface)
978
+ ```typescript
979
+ interface CommsListMethodsResponse {
980
+ ok: true; methods: import('./contact').CommMethod[]
981
+ }
982
+ ```
983
+
984
+ **RegisterEmailMethodRequest** (interface)
985
+ ```typescript
986
+ interface RegisterEmailMethodRequest {
987
+ contactId?: string; email?: string; userId?: string
988
+ }
989
+ ```
990
+
991
+ **RegisterSmsMethodRequest** (interface)
992
+ ```typescript
993
+ interface RegisterSmsMethodRequest {
994
+ contactId?: string; phone?: string; userId?: string
995
+ }
996
+ ```
997
+
998
+ **RegisterMethodResponse** (interface)
999
+ ```typescript
1000
+ interface RegisterMethodResponse {
1001
+ ok: true; contactId: string
1002
+ }
1003
+ ```
1004
+
1005
+ **SubscriptionsResolveRequest** (interface)
1006
+ ```typescript
1007
+ interface SubscriptionsResolveRequest {
1008
+ subject: { type: SubjectType; id: string; productId?: string }
1009
+ hints: { userId?: string; pushEndpoint?: string; email?: string; walletObjectId?: string }
1010
+ }
1011
+ ```
1012
+
1013
+ **SubscriptionsResolveResponse** (interface)
1014
+ ```typescript
1015
+ interface SubscriptionsResolveResponse {
1016
+ ok: true
1017
+ subject: { type: SubjectType; id: string; productId?: string }
1018
+ contacts: Array<{
1019
+ contactId: string
1020
+ subscribed: boolean
1021
+ channels?: Partial<Record<BroadcastChannel, boolean>>
1022
+ walletForSubject?: boolean
1023
+ }>
1024
+ anySubscribed: boolean
1025
+ anyMethods: boolean
1026
+ anyWalletForSubject: boolean
1027
+ }
1028
+ ```
1029
+
864
1030
  **RecipientId** = `string`
865
1031
 
866
1032
  **Recipient** = `import('./contact').Contact`
867
1033
 
1034
+ **CommsSettingsPatchBody** = `Partial<CommsSettings>`
1035
+
1036
+ **ConsentChannels** = `Partial<Record<BroadcastChannel, boolean>>`
1037
+
868
1038
  ### contact
869
1039
 
870
1040
  **Contact** (interface)
@@ -888,6 +1058,7 @@ interface Contact {
888
1058
  locale?: string | null
889
1059
  timezone?: string | null
890
1060
  externalIds?: Record<string, any>
1061
+ comms?: CommsState
891
1062
  customFields: ContactCustomFields
892
1063
  createdAt: string
893
1064
  updatedAt: string
@@ -960,6 +1131,68 @@ interface PublicUpdateMyContactResponse {
960
1131
  }
961
1132
  ```
962
1133
 
1134
+ **CommMethodMeta** (interface)
1135
+ ```typescript
1136
+ interface CommMethodMeta {
1137
+ pushEndpoint?: string
1138
+ p256dh?: string
1139
+ auth?: string
1140
+ phone?: string
1141
+ email?: string
1142
+ walletObjectId?: string
1143
+ subjectType?: SubjectType
1144
+ subjectId?: string
1145
+ productId?: string
1146
+ }
1147
+ ```
1148
+
1149
+ **CommMethod** (interface)
1150
+ ```typescript
1151
+ interface CommMethod {
1152
+ id?: string
1153
+ type: ChannelName
1154
+ meta?: CommMethodMeta
1155
+ verified?: boolean
1156
+ suppressed?: boolean
1157
+ createdAt?: string
1158
+ }
1159
+ ```
1160
+
1161
+ **Subscription** (interface)
1162
+ ```typescript
1163
+ interface Subscription {
1164
+ id: string // canonical key derived from subject (opaque to clients)
1165
+ subjectType: SubjectType
1166
+ subjectId: string
1167
+ productId?: string | null
1168
+ contactId: string
1169
+ source?: string // e.g., 'api'
1170
+ createdAt?: string
1171
+ deletedAt?: string | null
1172
+ }
1173
+ ```
1174
+
1175
+ **PreferenceEntry** (interface)
1176
+ ```typescript
1177
+ interface PreferenceEntry {
1178
+ subjectType?: SubjectType | null
1179
+ subjectId?: string | null
1180
+ channels?: Partial<Record<ChannelName, boolean>>
1181
+ topics?: Record<string, boolean>
1182
+ topicsByChannel?: Partial<Record<ChannelName, Record<string, boolean>>>
1183
+ updatedAt?: string
1184
+ }
1185
+ ```
1186
+
1187
+ **CommsState** (interface)
1188
+ ```typescript
1189
+ interface CommsState {
1190
+ methods?: CommMethod[]
1191
+ subscriptions?: Subscription[]
1192
+ preferences?: Record<string, PreferenceEntry>
1193
+ }
1194
+ ```
1195
+
963
1196
  **ContactCustomFields** = `Record<string, any>`
964
1197
 
965
1198
  **ContactResponse** = `Contact`
@@ -972,6 +1205,10 @@ interface PublicUpdateMyContactResponse {
972
1205
 
973
1206
  **ContactPatch** = `Partial<`
974
1207
 
1208
+ **ChannelName** = `import('./broadcasts').BroadcastChannel`
1209
+
1210
+ **SubjectType** = `'product' | 'proof' | 'batch'`
1211
+
975
1212
  ### error
976
1213
 
977
1214
  **ErrorResponse** (interface)
@@ -2152,7 +2389,7 @@ Look up a serial number by code for a batch (admin only).
2152
2389
 
2153
2390
  **send**(collectionId: string,
2154
2391
  id: string,
2155
- body: { pageSize?: number; maxPages?: number; sharedContext?: Record<string, any>; subject?: string } = {}) → `Promise<`
2392
+ body: BroadcastSendRequest = {}) → `Promise<`
2156
2393
 
2157
2394
  **sendTest**(collectionId: string,
2158
2395
  id: string,
@@ -2248,9 +2485,59 @@ Assign a value to a serial number for a collection (admin only).
2248
2485
 
2249
2486
  ### comms
2250
2487
 
2251
- **sendNotification**(collectionId: string,
2252
- request: SendNotificationRequest) `Promise<SendNotificationResponse>`
2253
- Send a notification to specified targets within a collection. Supports multiple delivery methods including push notifications, email, and wallet pass updates. The notification will be delivered based on user preferences and the specified delivery mode. ```typescript const result = await comms.sendNotification('my-collection', { subjectTargets: [{ type: 'product', id: 'prod_123' }], severity: 'important', mode: 'preferred', template: { push: { title: 'Update available', body: 'We\'ve shipped an important update.', icon: 'https://cdn.example.com/brand/logo-128.png' }, email: { subject: 'Important update for your product', body: 'There\'s an important update. Open your pass or profile to learn more.' }, walletUpdate: { textModulesData: [ { id: 'notice', header: 'Update', body: 'Open your wallet pass for details.' } ] } } }) if (result.ok) { console.log('Notification queued:', result.notificationId) console.log('Totals:', result.status.totals) } ```
2488
+ **getPushVapidPublicKey**(collectionId: string) → `Promise<import("../types/comms").PushVapidResponse>`
2489
+ Public: Get VAPID public key used for Web Push subscriptions. GET /public/collection/:collectionId/comm/push/vapidPublicKey Note: Key may be global; path is collection-scoped for consistency.
2490
+
2491
+ **registerPush**(collectionId: string,
2492
+ body: import("../types/comms") → `void`
2493
+ Public: Register a Web Push subscription under unified comms. POST /public/collection/:collectionId/comm/push/register
2494
+
2495
+ **getSettings**(collectionId: string,
2496
+ opts: { includeSecret?: boolean } = {}) → `Promise<import("../types/comms").CommsSettingsGetResponse>`
2497
+ Admin: Get current comms settings for a collection. GET /admin/collection/:collectionId/comm.settings Optional query: includeSecret=true to include unsub.secret in response.
2498
+
2499
+ **patchSettings**(collectionId: string,
2500
+ body: import("../types/comms") → `void`
2501
+ Admin: Patch comms settings for a collection. PATCH /admin/collection/:collectionId/comm.settings
2502
+
2503
+ **getPublicTopics**(collectionId: string) → `Promise<import("../types/comms").CommsPublicTopicsResponse>`
2504
+ Public: Fetch configured topics for a collection. GET /public/collection/:collectionId/comm/topics
2505
+
2506
+ **unsubscribe**(collectionId: string,
2507
+ query: import("../types/comms") → `void`
2508
+ Public: Unsubscribe a contact from a category or channel. GET /public/collection/:collectionId/comm/unsubscribe
2509
+
2510
+ **upsertConsent**(collectionId: string,
2511
+ body: import("../types/comms") → `void`
2512
+ Public: Upsert default consent for a contact. POST /public/collection/:collectionId/comm/consent
2513
+
2514
+ **upsertPreferences**(collectionId: string,
2515
+ body: import("../types/comms") → `void`
2516
+ Public: Upsert preferences for a specific subject (or default if subject omitted). POST /public/collection/:collectionId/comm/preferences
2517
+
2518
+ **subscribe**(collectionId: string,
2519
+ body: import("../types/comms") → `void`
2520
+ Public: Subscribe/unsubscribe contact to a subject. POST /public/collection/:collectionId/comm/subscribe
2521
+
2522
+ **checkSubscription**(collectionId: string,
2523
+ query: import("../types/comms") → `void`
2524
+ Public: Check subscription status for a subject. GET /public/collection/:collectionId/comm/subscription/check
2525
+
2526
+ **listMethods**(collectionId: string,
2527
+ query: import("../types/comms") → `void`
2528
+ Public: List registered contact methods. GET /public/collection/:collectionId/comm/methods
2529
+
2530
+ **registerEmail**(collectionId: string,
2531
+ body: import("../types/comms") → `void`
2532
+ Public: Register email method for a contact. POST /public/collection/:collectionId/comm/email/register
2533
+
2534
+ **registerSms**(collectionId: string,
2535
+ body: import("../types/comms") → `void`
2536
+ Public: Register SMS method for a contact. POST /public/collection/:collectionId/comm/sms/register
2537
+
2538
+ **resolveSubscriptions**(collectionId: string,
2539
+ body: import("../types/comms") → `void`
2540
+ Public: Resolve contacts for a subject with identity hints. POST /public/collection/:collectionId/comm/subscriptions/resolve
2254
2541
 
2255
2542
  **queryByUser**(collectionId: string,
2256
2543
  body: CommsQueryByUser = {}) → `Promise<CommunicationEvent[]>`
package/README.md CHANGED
@@ -352,6 +352,10 @@ const manual = await broadcasts.sendManual('collectionId', 'broadcastId', {
352
352
  })
353
353
  ```
354
354
 
355
+ ## Communications Overview
356
+
357
+ End-to-end explainer covering comms settings (unsubscribe, types), Web Push registration, and multi-channel broadcasts with SDK examples: [src/docs/smartlinks/comms-explainer.md](src/docs/smartlinks/comms-explainer.md)
358
+
355
359
  ### Async jobs
356
360
 
357
361
  ```ts
@@ -1,4 +1,4 @@
1
- import type { ListBroadcastsQuery, BroadcastRecord, BroadcastList, BroadcastRecipientsResponse, BroadcastPreviewRequest, BroadcastPreviewResponse, BroadcastSendTestRequest, BroadcastSendTestResponse, BroadcastSendManualRequest, BroadcastSendManualResponse, BroadcastAppendEventBody, BroadcastAppendBulkBody } from "../types/broadcasts";
1
+ import type { ListBroadcastsQuery, BroadcastRecord, BroadcastList, BroadcastRecipientsResponse, BroadcastPreviewRequest, BroadcastPreviewResponse, BroadcastSendTestRequest, BroadcastSendTestResponse, BroadcastSendManualRequest, BroadcastSendManualResponse, BroadcastAppendEventBody, BroadcastAppendBulkBody, BroadcastSendRequest } from "../types/broadcasts";
2
2
  import type { AppendResult, AppendBulkResult } from "../types/comms";
3
3
  export declare namespace broadcasts {
4
4
  function create(collectionId: string, body: Omit<BroadcastRecord, 'id' | 'collectionId' | 'createdAt'>): Promise<BroadcastRecord>;
@@ -11,12 +11,7 @@ export declare namespace broadcasts {
11
11
  offset?: number;
12
12
  }): Promise<BroadcastRecipientsResponse>;
13
13
  function preview(collectionId: string, id: string, body: BroadcastPreviewRequest): Promise<BroadcastPreviewResponse>;
14
- function send(collectionId: string, id: string, body?: {
15
- pageSize?: number;
16
- maxPages?: number;
17
- sharedContext?: Record<string, any>;
18
- subject?: string;
19
- }): Promise<{
14
+ function send(collectionId: string, id: string, body?: BroadcastSendRequest): Promise<{
20
15
  ok: true;
21
16
  enqueued: true;
22
17
  }>;