@proveanything/smartlinks 1.1.9 → 1.1.11

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.9 | Generated: 2025-12-24T13:18:43.320Z
3
+ Version: 1.1.11 | Generated: 2025-12-26T15:12:34.830Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -30,7 +30,7 @@ The Smartlinks SDK is organized into the following namespaces:
30
30
  - **segments** - Define dynamic/static audience segments; estimate and list recipients; schedule calculations.
31
31
 
32
32
  — Analytics & Events —
33
- - **actions** - Log and analyze actions/outcomes; aggregates and actor lists; action definition CRUD.
33
+ - **interactions** - Log and analyze interactions/outcomes; aggregates and actor lists; interaction definition CRUD.
34
34
 
35
35
  — Automation —
36
36
  - **journeys** - Configure automated flows triggered by events or schedules; steps, rules; full CRUD.
@@ -108,192 +108,6 @@ Sends a custom proxy message to the parent Smartlinks application when running i
108
108
 
109
109
  ## Types
110
110
 
111
- ### actions
112
-
113
- **AdminByUserRequest** (interface)
114
- ```typescript
115
- interface AdminByUserRequest {
116
- userId?: string
117
- contactId?: string
118
- appId?: string
119
- actionId?: string
120
- broadcastId?: string
121
- outcome?: string | null
122
- from?: string
123
- to?: string
124
- limit?: number
125
- }
126
- ```
127
-
128
- **AdminCountsByOutcomeRequest** (interface)
129
- ```typescript
130
- interface AdminCountsByOutcomeRequest {
131
- appId?: string
132
- actionId?: string
133
- from?: string
134
- to?: string
135
- limit?: number
136
- dedupeLatest?: boolean
137
- idField?: IdField
138
- }
139
- ```
140
-
141
- **AdminActorIdsByActionRequest** (interface)
142
- ```typescript
143
- interface AdminActorIdsByActionRequest {
144
- actionId: string
145
- idField?: IdField
146
- outcome?: string | null
147
- includeOutcome?: boolean
148
- from?: string
149
- to?: string
150
- limit?: number
151
- }
152
- ```
153
-
154
- **PublicCountsByOutcomeRequest** (interface)
155
- ```typescript
156
- interface PublicCountsByOutcomeRequest {
157
- appId: string
158
- actionId: string
159
- from?: string
160
- to?: string
161
- limit?: number
162
- }
163
- ```
164
-
165
- **PublicByUserRequest** (interface)
166
- ```typescript
167
- interface PublicByUserRequest {
168
- appId: string
169
- actionId: string
170
- from?: string
171
- to?: string
172
- limit?: number
173
- }
174
- ```
175
-
176
- **ActionEventRow** (interface)
177
- ```typescript
178
- interface ActionEventRow {
179
- orgId: string
180
- collectionId: string
181
- timestamp: string
182
- appId?: string
183
- actionId?: string
184
- broadcastId?: string
185
- userId?: string
186
- contactId?: string
187
- outcome?: string | null
188
- metadata?: Record<string, unknown>
189
- [k: string]: unknown
190
- }
191
- ```
192
-
193
- **OutcomeCount** (interface)
194
- ```typescript
195
- interface OutcomeCount {
196
- outcome: string | null; count: number
197
- }
198
- ```
199
-
200
- **ActorWithOutcome** (interface)
201
- ```typescript
202
- interface ActorWithOutcome {
203
- id: string; outcome: string | null
204
- }
205
- ```
206
-
207
- **AppendActionBody** (interface)
208
- ```typescript
209
- interface AppendActionBody {
210
- userId?: string
211
- contactId?: string
212
- actionId: string
213
- appId?: string
214
- broadcastId?: string
215
- outcome?: string
216
- timestamp?: string
217
- metadata?: Record<string, unknown>
218
- [k: string]: any
219
- }
220
- ```
221
-
222
- **ActionPermissions** (interface)
223
- ```typescript
224
- interface ActionPermissions {
225
- allowOwnRead?: boolean
226
- allowPublicSummary?: boolean
227
- allowAuthenticatedSummary?: boolean
228
- }
229
- ```
230
-
231
- **ActionRecord** (interface)
232
- ```typescript
233
- interface ActionRecord {
234
- id?: string
235
- collectionId: string
236
- appId: string
237
- permissions?: ActionPermissions
238
- data?: {
239
- display?: {
240
- title?: string
241
- description?: string
242
- icon?: string
243
- color?: string
244
- }
245
- actionType?: string
246
- [key: string]: unknown
247
- }
248
- createdAt: string
249
- }
250
- ```
251
-
252
- **ActionList** (interface)
253
- ```typescript
254
- interface ActionList {
255
- items: ActionRecord[]
256
- limit: number
257
- offset: number
258
- }
259
- ```
260
-
261
- **CreateActionBody** (interface)
262
- ```typescript
263
- interface CreateActionBody {
264
- id: string
265
- appId: string
266
- permissions?: ActionPermissions
267
- data?: Record<string, unknown>
268
- }
269
- ```
270
-
271
- **UpdateActionBody** (interface)
272
- ```typescript
273
- interface UpdateActionBody {
274
- appId?: string
275
- permissions?: ActionPermissions
276
- data?: Record<string, unknown>
277
- }
278
- ```
279
-
280
- **ListActionsQuery** (interface)
281
- ```typescript
282
- interface ListActionsQuery {
283
- appId?: string
284
- limit?: number
285
- offset?: number
286
- }
287
- ```
288
-
289
- **ActorId** = `string`
290
-
291
- **ActionQueryByUser** = `AdminByUserRequest`
292
-
293
- **ActionCountsQuery** = `AdminCountsByOutcomeRequest`
294
-
295
- **ActorIdsByActionQuery** = `AdminActorIdsByActionRequest`
296
-
297
111
  ### appConfiguration
298
112
 
299
113
  **AppConfigurationResponse** (interface)
@@ -963,6 +777,210 @@ interface ErrorResponse {
963
777
  }
964
778
  ```
965
779
 
780
+ ### interaction
781
+
782
+ **AdminInteractionsByUserRequest** (interface)
783
+ ```typescript
784
+ interface AdminInteractionsByUserRequest {
785
+ userId?: string
786
+ contactId?: string
787
+ appId?: string
788
+ interactionId?: string
789
+ broadcastId?: string
790
+ outcome?: string | null
791
+ from?: string
792
+ to?: string
793
+ limit?: number
794
+ }
795
+ ```
796
+
797
+ **AdminInteractionsCountsByOutcomeRequest** (interface)
798
+ ```typescript
799
+ interface AdminInteractionsCountsByOutcomeRequest {
800
+ appId?: string
801
+ interactionId?: string
802
+ from?: string
803
+ to?: string
804
+ limit?: number
805
+ dedupeLatest?: boolean
806
+ idField?: IdField
807
+ }
808
+ ```
809
+
810
+ **AdminActorIdsByInteractionRequest** (interface)
811
+ ```typescript
812
+ interface AdminActorIdsByInteractionRequest {
813
+ interactionId: string
814
+ idField?: IdField
815
+ outcome?: string | null
816
+ includeOutcome?: boolean
817
+ from?: string
818
+ to?: string
819
+ limit?: number
820
+ }
821
+ ```
822
+
823
+ **PublicInteractionsCountsByOutcomeRequest** (interface)
824
+ ```typescript
825
+ interface PublicInteractionsCountsByOutcomeRequest {
826
+ appId: string
827
+ interactionId: string
828
+ from?: string
829
+ to?: string
830
+ limit?: number
831
+ }
832
+ ```
833
+
834
+ **PublicInteractionsByUserRequest** (interface)
835
+ ```typescript
836
+ interface PublicInteractionsByUserRequest {
837
+ appId: string
838
+ interactionId: string
839
+ from?: string
840
+ to?: string
841
+ limit?: number
842
+ }
843
+ ```
844
+
845
+ **InteractionEventRow** (interface)
846
+ ```typescript
847
+ interface InteractionEventRow {
848
+ orgId: string
849
+ collectionId: string
850
+ timestamp: string
851
+ appId?: string
852
+ interactionId?: string
853
+ broadcastId?: string
854
+ userId?: string
855
+ contactId?: string
856
+ outcome?: string | null
857
+ metadata?: Record<string, unknown>
858
+ [k: string]: unknown
859
+ }
860
+ ```
861
+
862
+ **OutcomeCount** (interface)
863
+ ```typescript
864
+ interface OutcomeCount {
865
+ outcome: string | null; count: number
866
+ }
867
+ ```
868
+
869
+ **ActorWithOutcome** (interface)
870
+ ```typescript
871
+ interface ActorWithOutcome {
872
+ id: string; outcome: string | null
873
+ }
874
+ ```
875
+
876
+ **InteractionEventBase** (interface)
877
+ ```typescript
878
+ interface InteractionEventBase {
879
+ collectionId: string,
880
+ ordId: string,
881
+ userId?: string
882
+ contactId?: string
883
+ interactionId: string
884
+ appId?: string
885
+ broadcastId?: string
886
+ journeyId?: string
887
+ productId?: string
888
+ proofId?: string
889
+ variantId?: string
890
+ batchId?: string
891
+ source?: string,
892
+ eventType?: string
893
+ outcome?: string
894
+ timestamp?: string
895
+ metadata?: Record<string, unknown>
896
+ [k: string]: any
897
+ }
898
+ ```
899
+
900
+ **InteractionPermissions** (interface)
901
+ ```typescript
902
+ interface InteractionPermissions {
903
+ enabled?: boolean
904
+ requireAuth?: boolean
905
+ allowPublicSubmit?: boolean
906
+ allowAnonymousSubmit?: boolean
907
+ allowedOrigins?: string[]
908
+ startAt?: string
909
+ endAt?: string
910
+ * Enforce uniqueness per user: prevent duplicate submissions for this interaction.
911
+ * If true, optionally use `uniquePerUserWindowSeconds` to scope the window.
912
+ uniquePerUser?: boolean
913
+ uniquePerUserWindowSeconds?: number
914
+ uniqueOutcome?: string
915
+ * Public summary visibility (counts, aggregates) without auth.
916
+ * If false, summaries require `allowAuthenticatedSummary` + user auth.
917
+ allowPublicSummary?: boolean
918
+ * Authenticated summary visibility (counts, aggregates) when user is signed in.
919
+ allowAuthenticatedSummary?: boolean
920
+ allowOwnRead?: boolean
921
+ }
922
+ ```
923
+
924
+ **InteractionTypeRecord** (interface)
925
+ ```typescript
926
+ interface InteractionTypeRecord {
927
+ id?: string
928
+ collectionId: string
929
+ appId: string
930
+ permissions?: InteractionPermissions
931
+ data?: {
932
+ display?: {
933
+ title?: string
934
+ description?: string
935
+ icon?: string
936
+ color?: string
937
+ }
938
+ interactionType?: string
939
+ [key: string]: unknown
940
+ }
941
+ createdAt: string
942
+ }
943
+ ```
944
+
945
+ **InteractionTypeList** (interface)
946
+ ```typescript
947
+ interface InteractionTypeList {
948
+ items: InteractionTypeRecord[]
949
+ limit: number
950
+ offset: number
951
+ }
952
+ ```
953
+
954
+ **CreateInteractionTypeBody** (interface)
955
+ ```typescript
956
+ interface CreateInteractionTypeBody {
957
+ id: string
958
+ appId: string
959
+ permissions?: InteractionPermissions
960
+ data?: Record<string, unknown>
961
+ }
962
+ ```
963
+
964
+ **UpdateInteractionTypeBody** (interface)
965
+ ```typescript
966
+ interface UpdateInteractionTypeBody {
967
+ appId?: string
968
+ permissions?: InteractionPermissions
969
+ data?: Record<string, unknown>
970
+ }
971
+ ```
972
+
973
+ **ListInteractionTypesQuery** (interface)
974
+ ```typescript
975
+ interface ListInteractionTypesQuery {
976
+ appId?: string
977
+ limit?: number
978
+ offset?: number
979
+ }
980
+ ```
981
+
982
+ **ActorId** = `string`
983
+
966
984
  ### journeys
967
985
 
968
986
  **JourneyRecord** (interface)
@@ -1403,55 +1421,6 @@ type AccountInfoResponse = {
1403
1421
 
1404
1422
  ## API Functions
1405
1423
 
1406
- ### actions
1407
-
1408
- **byUser**(collectionId: string,
1409
- query: AdminByUserRequest | ActionQueryByUser = {}) → `Promise<ActionEventRow[]>`
1410
- POST /admin/collection/:collectionId/actions/by-user Returns BigQuery action rows, newest first.
1411
-
1412
- **countsByOutcome**(collectionId: string,
1413
- query: AdminCountsByOutcomeRequest | ActionCountsQuery = {}) → `Promise<OutcomeCount[]>`
1414
- POST /admin/collection/:collectionId/actions/counts-by-outcome Returns array of { outcome, count }.
1415
-
1416
- **actorIdsByAction**(collectionId: string,
1417
- query: AdminActorIdsByActionRequest | ActorIdsByActionQuery) → `Promise<ActorId[] | ActorWithOutcome[]>`
1418
- POST /admin/collection/:collectionId/actions/actor-ids/by-action Returns list of IDs, optionally with outcome when includeOutcome=true.
1419
-
1420
- **append**(collectionId: string,
1421
- body: AppendActionBody) → `Promise<`
1422
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1423
-
1424
- **create**(collectionId: string,
1425
- body: CreateActionBody) → `Promise<ActionRecord>`
1426
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1427
-
1428
- **list**(collectionId: string,
1429
- query: ListActionsQuery = {}) → `Promise<ActionList>`
1430
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1431
-
1432
- **get**(collectionId: string,
1433
- id: string) → `Promise<ActionRecord>`
1434
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1435
-
1436
- **update**(collectionId: string,
1437
- id: string,
1438
- patchBody: UpdateActionBody) → `Promise<ActionRecord>`
1439
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1440
-
1441
- **remove**(collectionId: string,
1442
- id: string) → `Promise<void>`
1443
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1444
-
1445
- **publicCountsByOutcome**(collectionId: string,
1446
- body: PublicCountsByOutcomeRequest,
1447
- authToken?: string) → `Promise<OutcomeCount[]>`
1448
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1449
-
1450
- **publicMyActions**(collectionId: string,
1451
- body: PublicByUserRequest,
1452
- authToken?: string) → `Promise<ActionEventRow[]>`
1453
- POST /admin/collection/:collectionId/actions/append Appends one action event.
1454
-
1455
1424
  ### ai
1456
1425
 
1457
1426
  **generateContent**(collectionId: string,
@@ -1909,6 +1878,63 @@ Update a form for a collection (admin only).
1909
1878
  **remove**(collectionId: string, formId: string) → `Promise<void>`
1910
1879
  Delete a form for a collection (admin only).
1911
1880
 
1881
+ ### interactions
1882
+
1883
+ **byUser**(collectionId: string,
1884
+ query: AdminInteractionsByUserRequest = {}) → `Promise<InteractionEventRow[]>`
1885
+ POST /admin/collection/:collectionId/interactions/by-user Returns BigQuery interaction rows, newest first.
1886
+
1887
+ **countsByOutcome**(collectionId: string,
1888
+ query: AdminInteractionsCountsByOutcomeRequest = {}) → `Promise<OutcomeCount[]>`
1889
+ POST /admin/collection/:collectionId/interactions/counts-by-outcome Returns array of { outcome, count }.
1890
+
1891
+ **actorIdsByInteraction**(collectionId: string,
1892
+ query: AdminActorIdsByInteractionRequest) → `Promise<ActorId[] | ActorWithOutcome[]>`
1893
+ POST /admin/collection/:collectionId/interactions/actor-ids/by-interaction Returns list of IDs, optionally with outcome when includeOutcome=true.
1894
+
1895
+ **appendEvent**(collectionId: string,
1896
+ body: AppendInteractionBody) → `Promise<`
1897
+ POST /admin/collection/:collectionId/interactions/append Appends one interaction event.
1898
+
1899
+ **updateEvent**(collectionId: string,
1900
+ body: UpdateInteractionBody) → `Promise<`
1901
+ POST /admin/collection/:collectionId/interactions/append Appends one interaction event.
1902
+
1903
+ **submitPublicEvent**(collectionId: string,
1904
+ body: AppendInteractionBody) → `Promise<`
1905
+ Appends one interaction event from a public source.
1906
+
1907
+ **create**(collectionId: string,
1908
+ body: CreateInteractionTypeBody) → `Promise<InteractionTypeRecord>`
1909
+ Appends one interaction event from a public source.
1910
+
1911
+ **list**(collectionId: string,
1912
+ query: ListInteractionTypesQuery = {}) → `Promise<InteractionTypeList>`
1913
+ Appends one interaction event from a public source.
1914
+
1915
+ **get**(collectionId: string,
1916
+ id: string) → `Promise<InteractionTypeRecord>`
1917
+ Appends one interaction event from a public source.
1918
+
1919
+ **update**(collectionId: string,
1920
+ id: string,
1921
+ patchBody: UpdateInteractionTypeBody) → `Promise<InteractionTypeRecord>`
1922
+ Appends one interaction event from a public source.
1923
+
1924
+ **remove**(collectionId: string,
1925
+ id: string) → `Promise<void>`
1926
+ Appends one interaction event from a public source.
1927
+
1928
+ **publicCountsByOutcome**(collectionId: string,
1929
+ body: PublicInteractionsCountsByOutcomeRequest,
1930
+ authToken?: string) → `Promise<OutcomeCount[]>`
1931
+ Appends one interaction event from a public source.
1932
+
1933
+ **publicMyInteractions**(collectionId: string,
1934
+ body: PublicInteractionsByUserRequest,
1935
+ authToken?: string) → `Promise<InteractionEventRow[]>`
1936
+ Appends one interaction event from a public source.
1937
+
1912
1938
  ### journeys
1913
1939
 
1914
1940
  **create**(collectionId: string,
@@ -16,10 +16,10 @@ export { ai } from "./ai";
16
16
  export { comms } from "./comms";
17
17
  export { nfc } from "./nfc";
18
18
  export { contact } from "./contact";
19
- export { actions } from "./actions";
20
19
  export { broadcasts } from "./broadcasts";
21
20
  export { segments } from "./segments";
22
21
  export { journeys } from "./journeys";
23
22
  export { qr } from "./qr";
24
23
  export { template } from "./template";
24
+ export { interactions } from "./interactions";
25
25
  export type { AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "./ai";
package/dist/api/index.js CHANGED
@@ -18,9 +18,9 @@ export { ai } from "./ai";
18
18
  export { comms } from "./comms";
19
19
  export { nfc } from "./nfc";
20
20
  export { contact } from "./contact";
21
- export { actions } from "./actions";
22
21
  export { broadcasts } from "./broadcasts";
23
22
  export { segments } from "./segments";
24
23
  export { journeys } from "./journeys";
25
24
  export { qr } from "./qr";
26
25
  export { template } from "./template";
26
+ export { interactions } from "./interactions";
@@ -0,0 +1,41 @@
1
+ import type { AdminInteractionsByUserRequest, AdminInteractionsCountsByOutcomeRequest, AdminActorIdsByInteractionRequest, AppendInteractionBody, UpdateInteractionBody, OutcomeCount, ActorId, ActorWithOutcome, InteractionEventRow, PublicInteractionsCountsByOutcomeRequest, PublicInteractionsByUserRequest, CreateInteractionTypeBody, UpdateInteractionTypeBody, ListInteractionTypesQuery, InteractionTypeRecord, InteractionTypeList } from "../types/interaction";
2
+ export declare namespace interactions {
3
+ /**
4
+ * POST /admin/collection/:collectionId/interactions/by-user
5
+ * Returns BigQuery interaction rows, newest first.
6
+ */
7
+ function byUser(collectionId: string, query?: AdminInteractionsByUserRequest): Promise<InteractionEventRow[]>;
8
+ /**
9
+ * POST /admin/collection/:collectionId/interactions/counts-by-outcome
10
+ * Returns array of { outcome, count }.
11
+ */
12
+ function countsByOutcome(collectionId: string, query?: AdminInteractionsCountsByOutcomeRequest): Promise<OutcomeCount[]>;
13
+ /**
14
+ * POST /admin/collection/:collectionId/interactions/actor-ids/by-interaction
15
+ * Returns list of IDs, optionally with outcome when includeOutcome=true.
16
+ */
17
+ function actorIdsByInteraction(collectionId: string, query: AdminActorIdsByInteractionRequest): Promise<ActorId[] | ActorWithOutcome[]>;
18
+ /**
19
+ * POST /admin/collection/:collectionId/interactions/append
20
+ * Appends one interaction event.
21
+ */
22
+ function appendEvent(collectionId: string, body: AppendInteractionBody): Promise<{
23
+ success: true;
24
+ }>;
25
+ function updateEvent(collectionId: string, body: UpdateInteractionBody): Promise<{
26
+ success: true;
27
+ }>;
28
+ /**
29
+ * Appends one interaction event from a public source.
30
+ */
31
+ function submitPublicEvent(collectionId: string, body: AppendInteractionBody): Promise<{
32
+ success: true;
33
+ }>;
34
+ function create(collectionId: string, body: CreateInteractionTypeBody): Promise<InteractionTypeRecord>;
35
+ function list(collectionId: string, query?: ListInteractionTypesQuery): Promise<InteractionTypeList>;
36
+ function get(collectionId: string, id: string): Promise<InteractionTypeRecord>;
37
+ function update(collectionId: string, id: string, patchBody: UpdateInteractionTypeBody): Promise<InteractionTypeRecord>;
38
+ function remove(collectionId: string, id: string): Promise<void>;
39
+ function publicCountsByOutcome(collectionId: string, body: PublicInteractionsCountsByOutcomeRequest, authToken?: string): Promise<OutcomeCount[]>;
40
+ function publicMyInteractions(collectionId: string, body: PublicInteractionsByUserRequest, authToken?: string): Promise<InteractionEventRow[]>;
41
+ }
@@ -0,0 +1,118 @@
1
+ // src/api/interactions.ts
2
+ import { request, post, patch, del } from "../http";
3
+ function encodeQuery(params) {
4
+ const search = new URLSearchParams();
5
+ for (const [key, value] of Object.entries(params)) {
6
+ if (value === undefined || value === null || value === "")
7
+ continue;
8
+ if (typeof value === "boolean") {
9
+ search.set(key, value ? "true" : "false");
10
+ }
11
+ else {
12
+ search.set(key, String(value));
13
+ }
14
+ }
15
+ const qs = search.toString();
16
+ return qs ? `?${qs}` : "";
17
+ }
18
+ export var interactions;
19
+ (function (interactions) {
20
+ /**
21
+ * POST /admin/collection/:collectionId/interactions/by-user
22
+ * Returns BigQuery interaction rows, newest first.
23
+ */
24
+ async function byUser(collectionId, query = {}) {
25
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/by-user`;
26
+ return post(path, query);
27
+ }
28
+ interactions.byUser = byUser;
29
+ /**
30
+ * POST /admin/collection/:collectionId/interactions/counts-by-outcome
31
+ * Returns array of { outcome, count }.
32
+ */
33
+ async function countsByOutcome(collectionId, query = {}) {
34
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/counts-by-outcome`;
35
+ return post(path, query);
36
+ }
37
+ interactions.countsByOutcome = countsByOutcome;
38
+ /**
39
+ * POST /admin/collection/:collectionId/interactions/actor-ids/by-interaction
40
+ * Returns list of IDs, optionally with outcome when includeOutcome=true.
41
+ */
42
+ async function actorIdsByInteraction(collectionId, query) {
43
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/actor-ids/by-interaction`;
44
+ return post(path, query);
45
+ }
46
+ interactions.actorIdsByInteraction = actorIdsByInteraction;
47
+ /**
48
+ * POST /admin/collection/:collectionId/interactions/append
49
+ * Appends one interaction event.
50
+ */
51
+ async function appendEvent(collectionId, body) {
52
+ if (!body.userId && !body.contactId) {
53
+ throw new Error("AppendInteractionBody must include one of userId or contactId");
54
+ }
55
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/append`;
56
+ return post(path, body);
57
+ }
58
+ interactions.appendEvent = appendEvent;
59
+ async function updateEvent(collectionId, body) {
60
+ if (!body.userId && !body.contactId) {
61
+ throw new Error("AppendInteractionBody must include one of userId or contactId");
62
+ }
63
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/append`;
64
+ return post(path, body);
65
+ }
66
+ interactions.updateEvent = updateEvent;
67
+ /**
68
+ * Appends one interaction event from a public source.
69
+ */
70
+ async function submitPublicEvent(collectionId, body) {
71
+ if (!body.userId && !body.contactId) {
72
+ throw new Error("AppendInteractionBody must include one of userId or contactId");
73
+ }
74
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/interactions/submit`;
75
+ return post(path, body);
76
+ }
77
+ interactions.submitPublicEvent = submitPublicEvent;
78
+ // CRUD: Interaction Types (Postgres)
79
+ async function create(collectionId, body) {
80
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/`;
81
+ return post(path, body);
82
+ }
83
+ interactions.create = create;
84
+ async function list(collectionId, query = {}) {
85
+ const qs = encodeQuery(query);
86
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/${qs}`;
87
+ return request(path);
88
+ }
89
+ interactions.list = list;
90
+ async function get(collectionId, id) {
91
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/${encodeURIComponent(id)}`;
92
+ return request(path);
93
+ }
94
+ interactions.get = get;
95
+ async function update(collectionId, id, patchBody) {
96
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/${encodeURIComponent(id)}`;
97
+ return patch(path, patchBody);
98
+ }
99
+ interactions.update = update;
100
+ async function remove(collectionId, id) {
101
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interactions/${encodeURIComponent(id)}`;
102
+ return del(path);
103
+ }
104
+ interactions.remove = remove;
105
+ // Public endpoints (permission-aware)
106
+ async function publicCountsByOutcome(collectionId, body, authToken) {
107
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/interactions/counts-by-outcome`;
108
+ const headers = authToken ? { AUTHORIZATION: `Bearer ${authToken}` } : undefined;
109
+ return post(path, body, headers);
110
+ }
111
+ interactions.publicCountsByOutcome = publicCountsByOutcome;
112
+ async function publicMyInteractions(collectionId, body, authToken) {
113
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/interactions/by-user`;
114
+ const headers = authToken ? { AUTHORIZATION: `Bearer ${authToken}` } : undefined;
115
+ return post(path, body, headers);
116
+ }
117
+ interactions.publicMyInteractions = publicMyInteractions;
118
+ })(interactions || (interactions = {}));
@@ -11,10 +11,10 @@ export * from "./auth";
11
11
  export * from "./comms";
12
12
  export * from "./nfc";
13
13
  export * from "./contact";
14
- export * from "./actions";
15
14
  export * from "./broadcasts";
16
15
  export * from "./segments";
17
16
  export * from "./common";
18
17
  export * from "./journeys";
19
18
  export * from "./qr";
20
19
  export * from "./template";
20
+ export * from "./interaction";
@@ -13,10 +13,10 @@ export * from "./auth";
13
13
  export * from "./comms";
14
14
  export * from "./nfc";
15
15
  export * from "./contact";
16
- export * from "./actions";
17
16
  export * from "./broadcasts";
18
17
  export * from "./segments";
19
18
  export * from "./common";
20
19
  export * from "./journeys";
21
20
  export * from "./qr";
22
21
  export * from "./template";
22
+ export * from "./interaction";
@@ -0,0 +1,172 @@
1
+ import type { IdField } from './common';
2
+ export interface AdminInteractionsByUserRequest {
3
+ userId?: string;
4
+ contactId?: string;
5
+ appId?: string;
6
+ interactionId?: string;
7
+ broadcastId?: string;
8
+ outcome?: string | null;
9
+ from?: string;
10
+ to?: string;
11
+ limit?: number;
12
+ }
13
+ export interface AdminInteractionsCountsByOutcomeRequest {
14
+ appId?: string;
15
+ interactionId?: string;
16
+ from?: string;
17
+ to?: string;
18
+ limit?: number;
19
+ dedupeLatest?: boolean;
20
+ idField?: IdField;
21
+ }
22
+ export interface AdminActorIdsByInteractionRequest {
23
+ interactionId: string;
24
+ idField?: IdField;
25
+ outcome?: string | null;
26
+ includeOutcome?: boolean;
27
+ from?: string;
28
+ to?: string;
29
+ limit?: number;
30
+ }
31
+ export interface PublicInteractionsCountsByOutcomeRequest {
32
+ appId: string;
33
+ interactionId: string;
34
+ from?: string;
35
+ to?: string;
36
+ limit?: number;
37
+ }
38
+ export interface PublicInteractionsByUserRequest {
39
+ appId: string;
40
+ interactionId: string;
41
+ from?: string;
42
+ to?: string;
43
+ limit?: number;
44
+ }
45
+ export interface InteractionEventRow {
46
+ orgId: string;
47
+ collectionId: string;
48
+ timestamp: string;
49
+ appId?: string;
50
+ interactionId?: string;
51
+ broadcastId?: string;
52
+ userId?: string;
53
+ contactId?: string;
54
+ outcome?: string | null;
55
+ metadata?: Record<string, unknown>;
56
+ [k: string]: unknown;
57
+ }
58
+ export interface OutcomeCount {
59
+ outcome: string | null;
60
+ count: number;
61
+ }
62
+ export type ActorId = string;
63
+ export interface ActorWithOutcome {
64
+ id: string;
65
+ outcome: string | null;
66
+ }
67
+ export interface InteractionEventBase {
68
+ collectionId: string;
69
+ ordId: string;
70
+ userId?: string;
71
+ contactId?: string;
72
+ interactionId: string;
73
+ appId?: string;
74
+ broadcastId?: string;
75
+ journeyId?: string;
76
+ productId?: string;
77
+ proofId?: string;
78
+ variantId?: string;
79
+ batchId?: string;
80
+ source?: string;
81
+ eventType?: string;
82
+ outcome?: string;
83
+ timestamp?: string;
84
+ metadata?: Record<string, unknown>;
85
+ [k: string]: any;
86
+ }
87
+ export interface AppendInteractionBody extends InteractionEventBase {
88
+ }
89
+ export interface UpdateInteractionBody extends InteractionEventBase {
90
+ eventId: string;
91
+ status?: 'active' | 'deleted';
92
+ }
93
+ /**
94
+ * InteractionPermissions: configuration for public + authenticated interaction behavior.
95
+ *
96
+ * Stored under the `permissions` JSON for an interaction definition (Postgres `interactions` table).
97
+ * These keys control whether submissions are allowed, visibility of summaries, and guardrails.
98
+ */
99
+ export interface InteractionPermissions {
100
+ /** Enable/disable submissions globally for this interaction (default: enabled). */
101
+ enabled?: boolean;
102
+ /** Require an authenticated user to submit. If true, anonymous/public submissions are blocked. */
103
+ requireAuth?: boolean;
104
+ /** Allow public (non-auth) submissions in general. */
105
+ allowPublicSubmit?: boolean;
106
+ /** Allow anonymous submissions even without a session (subset of public). */
107
+ allowAnonymousSubmit?: boolean;
108
+ /** Restrict submissions to matching origins (e.g., site domains). Uses substring match. */
109
+ allowedOrigins?: string[];
110
+ /** ISO datetime: submissions allowed at or after this time. */
111
+ startAt?: string;
112
+ /** ISO datetime: submissions allowed up to and including this time. */
113
+ endAt?: string;
114
+ /**
115
+ * Enforce uniqueness per user: prevent duplicate submissions for this interaction.
116
+ * If true, optionally use `uniquePerUserWindowSeconds` to scope the window.
117
+ */
118
+ uniquePerUser?: boolean;
119
+ /** Time window in seconds for uniqueness checks (e.g., 86400 for one day). */
120
+ uniquePerUserWindowSeconds?: number;
121
+ /** Optional outcome tag used when checking duplicates (e.g., "submitted"). */
122
+ uniqueOutcome?: string;
123
+ /**
124
+ * Public summary visibility (counts, aggregates) without auth.
125
+ * If false, summaries require `allowAuthenticatedSummary` + user auth.
126
+ */
127
+ allowPublicSummary?: boolean;
128
+ /**
129
+ * Authenticated summary visibility (counts, aggregates) when user is signed in.
130
+ */
131
+ allowAuthenticatedSummary?: boolean;
132
+ /** Allow an authenticated user to read their own interaction history via the public API. */
133
+ allowOwnRead?: boolean;
134
+ }
135
+ export interface InteractionTypeRecord {
136
+ id?: string;
137
+ collectionId: string;
138
+ appId: string;
139
+ permissions?: InteractionPermissions;
140
+ data?: {
141
+ display?: {
142
+ title?: string;
143
+ description?: string;
144
+ icon?: string;
145
+ color?: string;
146
+ };
147
+ interactionType?: string;
148
+ [key: string]: unknown;
149
+ };
150
+ createdAt: string;
151
+ }
152
+ export interface InteractionTypeList {
153
+ items: InteractionTypeRecord[];
154
+ limit: number;
155
+ offset: number;
156
+ }
157
+ export interface CreateInteractionTypeBody {
158
+ id: string;
159
+ appId: string;
160
+ permissions?: InteractionPermissions;
161
+ data?: Record<string, unknown>;
162
+ }
163
+ export interface UpdateInteractionTypeBody {
164
+ appId?: string;
165
+ permissions?: InteractionPermissions;
166
+ data?: Record<string, unknown>;
167
+ }
168
+ export interface ListInteractionTypesQuery {
169
+ appId?: string;
170
+ limit?: number;
171
+ offset?: number;
172
+ }
@@ -0,0 +1,2 @@
1
+ // src/types/interaction.ts
2
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.1.9",
3
+ "version": "1.1.11",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",