@proveanything/smartlinks 1.2.0 → 1.2.2

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.2.0 | Generated: 2026-01-21T15:47:06.455Z
3
+ Version: 1.2.2 | Generated: 2026-01-23T13:52:47.824Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -454,13 +454,13 @@ interface BroadcastRecord {
454
454
  }
455
455
  broadcastType?: string
456
456
  topic: string
457
+ templateParams?: Record<string, unknown>;
457
458
  channelSettings?: {
458
459
  mode?: 'preferred' | 'channels' | 'all'
459
460
  channels?: Array<{
460
- channel: import('./broadcasts').BroadcastChannel
461
+ channel: BroadcastChannel
461
462
  enabled?: boolean
462
463
  priority?: number
463
- templateId?: string
464
464
  }>
465
465
  }
466
466
  [key: string]: unknown
@@ -823,26 +823,6 @@ interface PushSubscriptionJSON {
823
823
  }
824
824
  ```
825
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
826
  **PushVapidResponse** (interface)
847
827
  ```typescript
848
828
  interface PushVapidResponse {
@@ -857,6 +837,16 @@ interface PushSubscribeResponse {
857
837
  }
858
838
  ```
859
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
+
860
850
  **CommsSettings** (interface)
861
851
  ```typescript
862
852
  interface CommsSettings {
@@ -876,9 +866,12 @@ interface TopicConfig {
876
866
  label?: string
877
867
  description?: string
878
868
  labels?: string[]
869
+ classification?: 'transactional' | 'marketing'
879
870
  defaults?: {
880
871
  channels?: Partial<Record<BroadcastChannel, boolean>>
881
872
  topics?: Record<string, boolean | undefined>
873
+ policy?: 'opt-in' | 'opt-out'
874
+ byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>
882
875
  }
883
876
  rules?: {
884
877
  allowChannels?: BroadcastChannel[]
@@ -1203,6 +1196,33 @@ interface CommsState {
1203
1196
  }
1204
1197
  ```
1205
1198
 
1199
+ **BaseField** (interface)
1200
+ ```typescript
1201
+ interface BaseField {
1202
+ key: string
1203
+ label: string
1204
+ type: FieldType
1205
+ widget: FieldWidget
1206
+ visible: boolean
1207
+ editable: boolean
1208
+ readOnly: boolean
1209
+ }
1210
+ ```
1211
+
1212
+ **ContactSchema** (interface)
1213
+ ```typescript
1214
+ interface ContactSchema {
1215
+ version: number // 1
1216
+ fields: CoreField[] // core fields
1217
+ customFields: CustomField[]
1218
+ settings: {
1219
+ publicVisibleFields: string[]
1220
+ publicEditableFields: string[]
1221
+ customFieldsVersion: number
1222
+ }
1223
+ }
1224
+ ```
1225
+
1206
1226
  **ContactCustomFields** = `Record<string, any>`
1207
1227
 
1208
1228
  **ContactResponse** = `Contact`
@@ -1219,6 +1239,10 @@ interface CommsState {
1219
1239
 
1220
1240
  **SubjectType** = `'product' | 'proof' | 'batch'`
1221
1241
 
1242
+ **FieldWidget** = `'text' | 'email' | 'tel' | 'select' | 'checkbox'`
1243
+
1244
+ **FieldType** = ``
1245
+
1222
1246
  ### error
1223
1247
 
1224
1248
  **ErrorResponse** (interface)
@@ -1888,6 +1912,7 @@ interface TemplateBase {
1888
1912
  push: { title: string; body: string, url?: string, iconUrl?: string },
1889
1913
  wallet?: { header: string; body: string; imageUri?: string }
1890
1914
  }
1915
+ parameters: TemplateParameterSchema[]
1891
1916
  subject?: string
1892
1917
  body?: string
1893
1918
  css?: string
@@ -2604,6 +2629,8 @@ Logging: Append many communication events for a list of IDs. POST /admin/collect
2604
2629
  **publicUpdateMine**(collectionId: string,
2605
2630
  data: ContactPatch) → `Promise<PublicUpdateMyContactResponse>`
2606
2631
 
2632
+ **publicGetSchema**(collectionId: string) → `Promise<ContactSchema>`
2633
+
2607
2634
  **erase**(collectionId: string, contactId: string, body?: any) → `Promise<ContactResponse>`
2608
2635
 
2609
2636
  **getUser**(collectionId: string,
@@ -13,7 +13,7 @@ export declare namespace comms {
13
13
  * Public: Register a Web Push subscription under unified comms.
14
14
  * POST /public/collection/:collectionId/comm/push/register
15
15
  */
16
- function registerPush(collectionId: string, body: import("../types/comms").PushSubscribeRequest): Promise<import("../types/comms").PushSubscribeResponse>;
16
+ function registerPush(collectionId: string, body: import("../types/comms").RegisterPushMethodRequest): Promise<import("../types/comms").PushSubscribeResponse>;
17
17
  /**
18
18
  * Admin: Get current comms settings for a collection.
19
19
  * GET /admin/collection/:collectionId/comm.settings
@@ -1,4 +1,4 @@
1
- import { ContactResponse, ContactCreateRequest, ContactUpdateRequest, ContactListResponse, PublicContactUpsertRequest, PublicContactUpsertResponse, UserSearchResponse, ContactPatch, PublicGetMyContactResponse, PublicUpdateMyContactResponse } from "../types";
1
+ import { ContactResponse, ContactCreateRequest, ContactUpdateRequest, ContactListResponse, PublicContactUpsertRequest, PublicContactUpsertResponse, UserSearchResponse, ContactPatch, PublicGetMyContactResponse, PublicUpdateMyContactResponse, ContactSchema } from "../types";
2
2
  export declare namespace contact {
3
3
  function create(collectionId: string, data: ContactCreateRequest): Promise<ContactResponse>;
4
4
  function list(collectionId: string, params?: {
@@ -19,6 +19,7 @@ export declare namespace contact {
19
19
  function publicUpsert(collectionId: string, data: PublicContactUpsertRequest): Promise<PublicContactUpsertResponse>;
20
20
  function publicGetMine(collectionId: string): Promise<PublicGetMyContactResponse>;
21
21
  function publicUpdateMine(collectionId: string, data: ContactPatch): Promise<PublicUpdateMyContactResponse>;
22
+ function publicGetSchema(collectionId: string): Promise<ContactSchema>;
22
23
  function erase(collectionId: string, contactId: string, body?: any): Promise<ContactResponse>;
23
24
  function getUser(collectionId: string, userId: string): Promise<UserSearchResponse>;
24
25
  }
@@ -71,6 +71,12 @@ export var contact;
71
71
  return patch(path, data);
72
72
  }
73
73
  contact.publicUpdateMine = publicUpdateMine;
74
+ // Public: Get contact update schema for a collection
75
+ async function publicGetSchema(collectionId) {
76
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/contacts/schema`;
77
+ return request(path);
78
+ }
79
+ contact.publicGetSchema = publicGetSchema;
74
80
  async function erase(collectionId, contactId, body) {
75
81
  const path = `/admin/collection/${encodeURIComponent(collectionId)}/contacts/${encodeURIComponent(contactId)}/erase`;
76
82
  return post(path, body || {});
@@ -3,6 +3,7 @@ export interface ListBroadcastsQuery {
3
3
  offset?: number;
4
4
  appId?: string;
5
5
  }
6
+ export type BroadcastChannel = 'email' | 'push' | 'sms' | 'wallet';
6
7
  export interface BroadcastRecord {
7
8
  id: string;
8
9
  collectionId: string;
@@ -22,14 +23,15 @@ export interface BroadcastRecord {
22
23
  broadcastType?: string;
23
24
  /** Required topic key for consent enforcement (e.g. newsletter, marketing, critical) */
24
25
  topic: string;
26
+ /** Required topic key for consent enforcement (e.g. newsletter, marketing, critical) */
27
+ templateParams?: Record<string, unknown>;
25
28
  /** Per-channel enablement/priority and optional template overrides */
26
29
  channelSettings?: {
27
30
  mode?: 'preferred' | 'channels' | 'all';
28
31
  channels?: Array<{
29
- channel: import('./broadcasts').BroadcastChannel;
32
+ channel: BroadcastChannel;
30
33
  enabled?: boolean;
31
34
  priority?: number;
32
- templateId?: string;
33
35
  }>;
34
36
  };
35
37
  [key: string]: unknown;
@@ -48,7 +50,6 @@ export interface BroadcastRecipientsResponse {
48
50
  offset: number;
49
51
  note?: string;
50
52
  }
51
- export type BroadcastChannel = 'email' | 'push' | 'sms' | 'wallet';
52
53
  export interface BroadcastPreviewRequest {
53
54
  contactId?: string;
54
55
  email?: string;
@@ -108,25 +108,6 @@ export interface PushSubscriptionJSON {
108
108
  auth?: string;
109
109
  };
110
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
111
  export interface PushVapidResponse {
131
112
  publicKey: string;
132
113
  }
@@ -134,6 +115,15 @@ export interface PushSubscribeResponse {
134
115
  ok: true;
135
116
  id: string;
136
117
  }
118
+ export interface RegisterPushMethodRequest {
119
+ contactId: string;
120
+ endpoint: string;
121
+ keys: {
122
+ p256dh: string;
123
+ auth: string;
124
+ };
125
+ meta?: Record<string, any>;
126
+ }
137
127
  export interface CommsSettings {
138
128
  unsub?: {
139
129
  requireToken?: boolean;
@@ -151,9 +141,15 @@ export interface TopicConfig {
151
141
  description?: string;
152
142
  /** Optional UI-only grouping labels */
153
143
  labels?: string[];
144
+ /** Classification for UI and default policy guidance */
145
+ classification?: 'transactional' | 'marketing';
154
146
  defaults?: {
155
147
  channels?: Partial<Record<BroadcastChannel, boolean>>;
156
148
  topics?: Record<string, boolean | undefined>;
149
+ /** Default consent policy when explicit preferences are absent */
150
+ policy?: 'opt-in' | 'opt-out';
151
+ /** Per-channel default policy (overrides policy when present) */
152
+ byChannel?: Partial<Record<BroadcastChannel, 'opt-in' | 'opt-out'>>;
157
153
  };
158
154
  rules?: {
159
155
  allowChannels?: BroadcastChannel[];
@@ -129,3 +129,32 @@ export interface CommsState {
129
129
  /** Keyed by `_default` or `${type}_${id}` */
130
130
  preferences?: Record<string, PreferenceEntry>;
131
131
  }
132
+ export type FieldWidget = 'text' | 'email' | 'tel' | 'select' | 'checkbox';
133
+ export type FieldType = 'string' | 'url' | 'email' | 'tel' | 'text' | 'select' | 'checkbox' | 'boolean';
134
+ export interface BaseField {
135
+ key: string;
136
+ label: string;
137
+ type: FieldType;
138
+ widget: FieldWidget;
139
+ visible: boolean;
140
+ editable: boolean;
141
+ readOnly: boolean;
142
+ }
143
+ export interface CoreField extends BaseField {
144
+ }
145
+ export interface CustomField extends BaseField {
146
+ path: string;
147
+ required: boolean;
148
+ order?: number;
149
+ options?: string[];
150
+ }
151
+ export interface ContactSchema {
152
+ version: number;
153
+ fields: CoreField[];
154
+ customFields: CustomField[];
155
+ settings: {
156
+ publicVisibleFields: string[];
157
+ publicEditableFields: string[];
158
+ customFieldsVersion: number;
159
+ };
160
+ }
@@ -1,3 +1,10 @@
1
+ interface TemplateParameterSchema {
2
+ key: string;
3
+ label?: string;
4
+ type?: string;
5
+ required?: boolean;
6
+ defaultValue?: string;
7
+ }
1
8
  export interface TemplateBase {
2
9
  id: string;
3
10
  collectionId: string;
@@ -31,6 +38,7 @@ export interface TemplateBase {
31
38
  imageUri?: string;
32
39
  };
33
40
  };
41
+ parameters: TemplateParameterSchema[];
34
42
  subject?: string;
35
43
  body?: string;
36
44
  css?: string;
@@ -65,3 +73,4 @@ export interface TemplateRenderSourceResponse {
65
73
  ok: boolean;
66
74
  html: string;
67
75
  }
76
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",