@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.
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.0 | Generated: 2026-01-21T15:47:06.455Z
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,239 @@ 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
+ **PushSubscribeMeta** (interface)
827
+ ```typescript
828
+ interface PushSubscribeMeta {
829
+ collectionId: string
830
+ contactId?: string
831
+ userId?: string
832
+ productId?: string
833
+ labels?: Record<string, string>
834
+ [key: string]: any
835
+ }
836
+ ```
837
+
838
+ **PushSubscribeRequest** (interface)
839
+ ```typescript
840
+ interface PushSubscribeRequest {
841
+ subscription: PushSubscriptionJSON
842
+ meta: PushSubscribeMeta
843
+ }
844
+ ```
845
+
846
+ **PushVapidResponse** (interface)
847
+ ```typescript
848
+ interface PushVapidResponse {
849
+ publicKey: string
850
+ }
851
+ ```
852
+
853
+ **PushSubscribeResponse** (interface)
854
+ ```typescript
855
+ interface PushSubscribeResponse {
856
+ ok: true; id: string
857
+ }
858
+ ```
859
+
860
+ **CommsSettings** (interface)
861
+ ```typescript
862
+ interface CommsSettings {
863
+ unsub?: {
864
+ requireToken?: boolean
865
+ secret?: string
866
+ hasSecret?: boolean
867
+ }
868
+ topics?: Record<string, TopicConfig>
869
+ [k: string]: any
870
+ }
871
+ ```
872
+
873
+ **TopicConfig** (interface)
874
+ ```typescript
875
+ interface TopicConfig {
876
+ label?: string
877
+ description?: string
878
+ labels?: string[]
879
+ defaults?: {
880
+ channels?: Partial<Record<BroadcastChannel, boolean>>
881
+ topics?: Record<string, boolean | undefined>
882
+ }
883
+ rules?: {
884
+ allowChannels?: BroadcastChannel[]
885
+ allowUnsubscribe?: boolean
886
+ required?: boolean
887
+ }
888
+ [k: string]: any
889
+ }
890
+ ```
891
+
892
+ **CommsSettingsGetResponse** (interface)
893
+ ```typescript
894
+ interface CommsSettingsGetResponse {
895
+ ok: true
896
+ settings: CommsSettings
897
+ }
898
+ ```
899
+
900
+ **CommsPublicTopicsResponse** (interface)
901
+ ```typescript
902
+ interface CommsPublicTopicsResponse {
903
+ ok: true; topics: Record<string, TopicConfig>
904
+ }
905
+ ```
906
+
907
+ **UnsubscribeQuery** (interface)
908
+ ```typescript
909
+ interface UnsubscribeQuery {
910
+ contactId: string
911
+ topic?: string
912
+ channel?: BroadcastChannel
913
+ token?: string
914
+ }
915
+ ```
916
+
917
+ **UnsubscribeResponse** (interface)
918
+ ```typescript
919
+ interface UnsubscribeResponse {
920
+ ok: true; applied?: { channels?: Record<string, boolean>; topics?: Record<string, boolean> }
921
+ }
922
+ ```
923
+
924
+ **CommsConsentUpsertRequest** (interface)
925
+ ```typescript
926
+ interface CommsConsentUpsertRequest {
927
+ contactId: string
928
+ channels?: ConsentChannels
929
+ topics?: Record<string, boolean>
930
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
931
+ }
932
+ ```
933
+
934
+ **CommsPreferencesUpsertRequest** (interface)
935
+ ```typescript
936
+ interface CommsPreferencesUpsertRequest {
937
+ contactId: string
938
+ subject?: { type: SubjectType; id: string; productId?: string }
939
+ channels?: ConsentChannels
940
+ topics?: Record<string, boolean>
941
+ topicsByChannel?: Partial<Record<BroadcastChannel, Record<string, boolean>>>
942
+ }
943
+ ```
944
+
945
+ **CommsSubscribeRequest** (interface)
946
+ ```typescript
947
+ interface CommsSubscribeRequest {
948
+ contactId: string
949
+ subject: { type: SubjectType; id: string; productId?: string }
950
+ subscribe: boolean
951
+ source?: string
952
+ }
953
+ ```
954
+
955
+ **CommsSubscribeResponse** (interface)
956
+ ```typescript
957
+ interface CommsSubscribeResponse {
958
+ ok: true; subscriptionId: string
959
+ }
960
+ ```
961
+
962
+ **CommsSubscriptionCheckQuery** (interface)
963
+ ```typescript
964
+ interface CommsSubscriptionCheckQuery {
965
+ contactId: string
966
+ subjectType: SubjectType
967
+ subjectId: string
968
+ productId?: string
969
+ }
970
+ ```
971
+
972
+ **CommsSubscriptionCheckResponse** (interface)
973
+ ```typescript
974
+ interface CommsSubscriptionCheckResponse {
975
+ ok: true; subscribed: boolean
976
+ }
977
+ ```
978
+
979
+ **CommsListMethodsQuery** (interface)
980
+ ```typescript
981
+ interface CommsListMethodsQuery {
982
+ contactId: string
983
+ type?: BroadcastChannel
984
+ }
985
+ ```
986
+
987
+ **CommsListMethodsResponse** (interface)
988
+ ```typescript
989
+ interface CommsListMethodsResponse {
990
+ ok: true; methods: import('./contact').CommMethod[]
991
+ }
992
+ ```
993
+
994
+ **RegisterEmailMethodRequest** (interface)
995
+ ```typescript
996
+ interface RegisterEmailMethodRequest {
997
+ contactId?: string; email?: string; userId?: string
998
+ }
999
+ ```
1000
+
1001
+ **RegisterSmsMethodRequest** (interface)
1002
+ ```typescript
1003
+ interface RegisterSmsMethodRequest {
1004
+ contactId?: string; phone?: string; userId?: string
1005
+ }
1006
+ ```
1007
+
1008
+ **RegisterMethodResponse** (interface)
1009
+ ```typescript
1010
+ interface RegisterMethodResponse {
1011
+ ok: true; contactId: string
1012
+ }
1013
+ ```
1014
+
1015
+ **SubscriptionsResolveRequest** (interface)
1016
+ ```typescript
1017
+ interface SubscriptionsResolveRequest {
1018
+ subject: { type: SubjectType; id: string; productId?: string }
1019
+ hints: { userId?: string; pushEndpoint?: string; email?: string; walletObjectId?: string }
1020
+ }
1021
+ ```
1022
+
1023
+ **SubscriptionsResolveResponse** (interface)
1024
+ ```typescript
1025
+ interface SubscriptionsResolveResponse {
1026
+ ok: true
1027
+ subject: { type: SubjectType; id: string; productId?: string }
1028
+ contacts: Array<{
1029
+ contactId: string
1030
+ subscribed: boolean
1031
+ channels?: Partial<Record<BroadcastChannel, boolean>>
1032
+ walletForSubject?: boolean
1033
+ }>
1034
+ anySubscribed: boolean
1035
+ anyMethods: boolean
1036
+ anyWalletForSubject: boolean
1037
+ }
1038
+ ```
1039
+
864
1040
  **RecipientId** = `string`
865
1041
 
866
1042
  **Recipient** = `import('./contact').Contact`
867
1043
 
1044
+ **CommsSettingsPatchBody** = `Partial<CommsSettings>`
1045
+
1046
+ **ConsentChannels** = `Partial<Record<BroadcastChannel, boolean>>`
1047
+
868
1048
  ### contact
869
1049
 
870
1050
  **Contact** (interface)
@@ -888,6 +1068,7 @@ interface Contact {
888
1068
  locale?: string | null
889
1069
  timezone?: string | null
890
1070
  externalIds?: Record<string, any>
1071
+ comms?: CommsState
891
1072
  customFields: ContactCustomFields
892
1073
  createdAt: string
893
1074
  updatedAt: string
@@ -960,6 +1141,68 @@ interface PublicUpdateMyContactResponse {
960
1141
  }
961
1142
  ```
962
1143
 
1144
+ **CommMethodMeta** (interface)
1145
+ ```typescript
1146
+ interface CommMethodMeta {
1147
+ pushEndpoint?: string
1148
+ p256dh?: string
1149
+ auth?: string
1150
+ phone?: string
1151
+ email?: string
1152
+ walletObjectId?: string
1153
+ subjectType?: SubjectType
1154
+ subjectId?: string
1155
+ productId?: string
1156
+ }
1157
+ ```
1158
+
1159
+ **CommMethod** (interface)
1160
+ ```typescript
1161
+ interface CommMethod {
1162
+ id?: string
1163
+ type: ChannelName
1164
+ meta?: CommMethodMeta
1165
+ verified?: boolean
1166
+ suppressed?: boolean
1167
+ createdAt?: string
1168
+ }
1169
+ ```
1170
+
1171
+ **Subscription** (interface)
1172
+ ```typescript
1173
+ interface Subscription {
1174
+ id: string // canonical key derived from subject (opaque to clients)
1175
+ subjectType: SubjectType
1176
+ subjectId: string
1177
+ productId?: string | null
1178
+ contactId: string
1179
+ source?: string // e.g., 'api'
1180
+ createdAt?: string
1181
+ deletedAt?: string | null
1182
+ }
1183
+ ```
1184
+
1185
+ **PreferenceEntry** (interface)
1186
+ ```typescript
1187
+ interface PreferenceEntry {
1188
+ subjectType?: SubjectType | null
1189
+ subjectId?: string | null
1190
+ channels?: Partial<Record<ChannelName, boolean>>
1191
+ topics?: Record<string, boolean>
1192
+ topicsByChannel?: Partial<Record<ChannelName, Record<string, boolean>>>
1193
+ updatedAt?: string
1194
+ }
1195
+ ```
1196
+
1197
+ **CommsState** (interface)
1198
+ ```typescript
1199
+ interface CommsState {
1200
+ methods?: CommMethod[]
1201
+ subscriptions?: Subscription[]
1202
+ preferences?: Record<string, PreferenceEntry>
1203
+ }
1204
+ ```
1205
+
963
1206
  **ContactCustomFields** = `Record<string, any>`
964
1207
 
965
1208
  **ContactResponse** = `Contact`
@@ -972,6 +1215,10 @@ interface PublicUpdateMyContactResponse {
972
1215
 
973
1216
  **ContactPatch** = `Partial<`
974
1217
 
1218
+ **ChannelName** = `import('./broadcasts').BroadcastChannel`
1219
+
1220
+ **SubjectType** = `'product' | 'proof' | 'batch'`
1221
+
975
1222
  ### error
976
1223
 
977
1224
  **ErrorResponse** (interface)
@@ -2152,7 +2399,7 @@ Look up a serial number by code for a batch (admin only).
2152
2399
 
2153
2400
  **send**(collectionId: string,
2154
2401
  id: string,
2155
- body: { pageSize?: number; maxPages?: number; sharedContext?: Record<string, any>; subject?: string } = {}) → `Promise<`
2402
+ body: BroadcastSendRequest = {}) → `Promise<`
2156
2403
 
2157
2404
  **sendTest**(collectionId: string,
2158
2405
  id: string,
@@ -2248,9 +2495,59 @@ Assign a value to a serial number for a collection (admin only).
2248
2495
 
2249
2496
  ### comms
2250
2497
 
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) } ```
2498
+ **getPushVapidPublicKey**(collectionId: string) → `Promise<import("../types/comms").PushVapidResponse>`
2499
+ 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.
2500
+
2501
+ **registerPush**(collectionId: string,
2502
+ body: import("../types/comms") → `void`
2503
+ Public: Register a Web Push subscription under unified comms. POST /public/collection/:collectionId/comm/push/register
2504
+
2505
+ **getSettings**(collectionId: string,
2506
+ opts: { includeSecret?: boolean } = {}) → `Promise<import("../types/comms").CommsSettingsGetResponse>`
2507
+ Admin: Get current comms settings for a collection. GET /admin/collection/:collectionId/comm.settings Optional query: includeSecret=true to include unsub.secret in response.
2508
+
2509
+ **patchSettings**(collectionId: string,
2510
+ body: import("../types/comms") → `void`
2511
+ Admin: Patch comms settings for a collection. PATCH /admin/collection/:collectionId/comm.settings
2512
+
2513
+ **getPublicTopics**(collectionId: string) → `Promise<import("../types/comms").CommsPublicTopicsResponse>`
2514
+ Public: Fetch configured topics for a collection. GET /public/collection/:collectionId/comm/topics
2515
+
2516
+ **unsubscribe**(collectionId: string,
2517
+ query: import("../types/comms") → `void`
2518
+ Public: Unsubscribe a contact from a category or channel. GET /public/collection/:collectionId/comm/unsubscribe
2519
+
2520
+ **upsertConsent**(collectionId: string,
2521
+ body: import("../types/comms") → `void`
2522
+ Public: Upsert default consent for a contact. POST /public/collection/:collectionId/comm/consent
2523
+
2524
+ **upsertPreferences**(collectionId: string,
2525
+ body: import("../types/comms") → `void`
2526
+ Public: Upsert preferences for a specific subject (or default if subject omitted). POST /public/collection/:collectionId/comm/preferences
2527
+
2528
+ **subscribe**(collectionId: string,
2529
+ body: import("../types/comms") → `void`
2530
+ Public: Subscribe/unsubscribe contact to a subject. POST /public/collection/:collectionId/comm/subscribe
2531
+
2532
+ **checkSubscription**(collectionId: string,
2533
+ query: import("../types/comms") → `void`
2534
+ Public: Check subscription status for a subject. GET /public/collection/:collectionId/comm/subscription/check
2535
+
2536
+ **listMethods**(collectionId: string,
2537
+ query: import("../types/comms") → `void`
2538
+ Public: List registered contact methods. GET /public/collection/:collectionId/comm/methods
2539
+
2540
+ **registerEmail**(collectionId: string,
2541
+ body: import("../types/comms") → `void`
2542
+ Public: Register email method for a contact. POST /public/collection/:collectionId/comm/email/register
2543
+
2544
+ **registerSms**(collectionId: string,
2545
+ body: import("../types/comms") → `void`
2546
+ Public: Register SMS method for a contact. POST /public/collection/:collectionId/comm/sms/register
2547
+
2548
+ **resolveSubscriptions**(collectionId: string,
2549
+ body: import("../types/comms") → `void`
2550
+ Public: Resolve contacts for a subject with identity hints. POST /public/collection/:collectionId/comm/subscriptions/resolve
2254
2551
 
2255
2552
  **queryByUser**(collectionId: string,
2256
2553
  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
  }>;