@proveanything/smartlinks 1.1.9 → 1.1.10

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.10 | Generated: 2025-12-24T21:01:46.345Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -29,9 +29,6 @@ The Smartlinks SDK is organized into the following namespaces:
29
29
  - **broadcasts** - Define broadcast campaigns; append recipients/events; analytics and CRUD.
30
30
  - **segments** - Define dynamic/static audience segments; estimate and list recipients; schedule calculations.
31
31
 
32
- — Analytics & Events —
33
- - **actions** - Log and analyze actions/outcomes; aggregates and actor lists; action definition CRUD.
34
-
35
32
  — Automation —
36
33
  - **journeys** - Configure automated flows triggered by events or schedules; steps, rules; full CRUD.
37
34
 
@@ -47,6 +44,7 @@ The Smartlinks SDK is organized into the following namespaces:
47
44
 
48
45
  — Other —
49
46
  - **attestation** - Functions for attestation operations
47
+ - **interactions** - Functions for interactions operations
50
48
  - **template** - Functions for template operations
51
49
 
52
50
  ## HTTP Utilities
@@ -108,192 +106,6 @@ Sends a custom proxy message to the parent Smartlinks application when running i
108
106
 
109
107
  ## Types
110
108
 
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
109
  ### appConfiguration
298
110
 
299
111
  **AppConfigurationResponse** (interface)
@@ -963,6 +775,210 @@ interface ErrorResponse {
963
775
  }
964
776
  ```
965
777
 
778
+ ### interaction
779
+
780
+ **AdminInteractionsByUserRequest** (interface)
781
+ ```typescript
782
+ interface AdminInteractionsByUserRequest {
783
+ userId?: string
784
+ contactId?: string
785
+ appId?: string
786
+ interactionId?: string
787
+ broadcastId?: string
788
+ outcome?: string | null
789
+ from?: string
790
+ to?: string
791
+ limit?: number
792
+ }
793
+ ```
794
+
795
+ **AdminInteractionsCountsByOutcomeRequest** (interface)
796
+ ```typescript
797
+ interface AdminInteractionsCountsByOutcomeRequest {
798
+ appId?: string
799
+ interactionId?: string
800
+ from?: string
801
+ to?: string
802
+ limit?: number
803
+ dedupeLatest?: boolean
804
+ idField?: IdField
805
+ }
806
+ ```
807
+
808
+ **AdminActorIdsByInteractionRequest** (interface)
809
+ ```typescript
810
+ interface AdminActorIdsByInteractionRequest {
811
+ interactionId: string
812
+ idField?: IdField
813
+ outcome?: string | null
814
+ includeOutcome?: boolean
815
+ from?: string
816
+ to?: string
817
+ limit?: number
818
+ }
819
+ ```
820
+
821
+ **PublicInteractionsCountsByOutcomeRequest** (interface)
822
+ ```typescript
823
+ interface PublicInteractionsCountsByOutcomeRequest {
824
+ appId: string
825
+ interactionId: string
826
+ from?: string
827
+ to?: string
828
+ limit?: number
829
+ }
830
+ ```
831
+
832
+ **PublicInteractionsByUserRequest** (interface)
833
+ ```typescript
834
+ interface PublicInteractionsByUserRequest {
835
+ appId: string
836
+ interactionId: string
837
+ from?: string
838
+ to?: string
839
+ limit?: number
840
+ }
841
+ ```
842
+
843
+ **InteractionEventRow** (interface)
844
+ ```typescript
845
+ interface InteractionEventRow {
846
+ orgId: string
847
+ collectionId: string
848
+ timestamp: string
849
+ appId?: string
850
+ interactionId?: string
851
+ broadcastId?: string
852
+ userId?: string
853
+ contactId?: string
854
+ outcome?: string | null
855
+ metadata?: Record<string, unknown>
856
+ [k: string]: unknown
857
+ }
858
+ ```
859
+
860
+ **OutcomeCount** (interface)
861
+ ```typescript
862
+ interface OutcomeCount {
863
+ outcome: string | null; count: number
864
+ }
865
+ ```
866
+
867
+ **ActorWithOutcome** (interface)
868
+ ```typescript
869
+ interface ActorWithOutcome {
870
+ id: string; outcome: string | null
871
+ }
872
+ ```
873
+
874
+ **InteractionEventBase** (interface)
875
+ ```typescript
876
+ interface InteractionEventBase {
877
+ collectionId: string,
878
+ ordId: string,
879
+ userId?: string
880
+ contactId?: string
881
+ interactionId: string
882
+ appId?: string
883
+ broadcastId?: string
884
+ journeyId?: string
885
+ productId?: string
886
+ proofId?: string
887
+ variantId?: string
888
+ batchId?: string
889
+ source?: string,
890
+ eventType?: string
891
+ outcome?: string
892
+ timestamp?: string
893
+ metadata?: Record<string, unknown>
894
+ [k: string]: any
895
+ }
896
+ ```
897
+
898
+ **InteractionPermissions** (interface)
899
+ ```typescript
900
+ interface InteractionPermissions {
901
+ enabled?: boolean
902
+ requireAuth?: boolean
903
+ allowPublicSubmit?: boolean
904
+ allowAnonymousSubmit?: boolean
905
+ allowedOrigins?: string[]
906
+ startAt?: string
907
+ endAt?: string
908
+ * Enforce uniqueness per user: prevent duplicate submissions for this interaction.
909
+ * If true, optionally use `uniquePerUserWindowSeconds` to scope the window.
910
+ uniquePerUser?: boolean
911
+ uniquePerUserWindowSeconds?: number
912
+ uniqueOutcome?: string
913
+ * Public summary visibility (counts, aggregates) without auth.
914
+ * If false, summaries require `allowAuthenticatedSummary` + user auth.
915
+ allowPublicSummary?: boolean
916
+ * Authenticated summary visibility (counts, aggregates) when user is signed in.
917
+ allowAuthenticatedSummary?: boolean
918
+ allowOwnRead?: boolean
919
+ }
920
+ ```
921
+
922
+ **InteractionTypeRecord** (interface)
923
+ ```typescript
924
+ interface InteractionTypeRecord {
925
+ id?: string
926
+ collectionId: string
927
+ appId: string
928
+ permissions?: InteractionPermissions
929
+ data?: {
930
+ display?: {
931
+ title?: string
932
+ description?: string
933
+ icon?: string
934
+ color?: string
935
+ }
936
+ interactionType?: string
937
+ [key: string]: unknown
938
+ }
939
+ createdAt: string
940
+ }
941
+ ```
942
+
943
+ **InteractionTypeList** (interface)
944
+ ```typescript
945
+ interface InteractionTypeList {
946
+ items: InteractionTypeRecord[]
947
+ limit: number
948
+ offset: number
949
+ }
950
+ ```
951
+
952
+ **CreateInteractionTypeBody** (interface)
953
+ ```typescript
954
+ interface CreateInteractionTypeBody {
955
+ id: string
956
+ appId: string
957
+ permissions?: InteractionPermissions
958
+ data?: Record<string, unknown>
959
+ }
960
+ ```
961
+
962
+ **UpdateInteractionTypeBody** (interface)
963
+ ```typescript
964
+ interface UpdateInteractionTypeBody {
965
+ appId?: string
966
+ permissions?: InteractionPermissions
967
+ data?: Record<string, unknown>
968
+ }
969
+ ```
970
+
971
+ **ListInteractionTypesQuery** (interface)
972
+ ```typescript
973
+ interface ListInteractionTypesQuery {
974
+ appId?: string
975
+ limit?: number
976
+ offset?: number
977
+ }
978
+ ```
979
+
980
+ **ActorId** = `string`
981
+
966
982
  ### journeys
967
983
 
968
984
  **JourneyRecord** (interface)
@@ -1403,55 +1419,6 @@ type AccountInfoResponse = {
1403
1419
 
1404
1420
  ## API Functions
1405
1421
 
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
1422
  ### ai
1456
1423
 
1457
1424
  **generateContent**(collectionId: string,
@@ -1909,6 +1876,63 @@ Update a form for a collection (admin only).
1909
1876
  **remove**(collectionId: string, formId: string) → `Promise<void>`
1910
1877
  Delete a form for a collection (admin only).
1911
1878
 
1879
+ ### interactions
1880
+
1881
+ **byUser**(collectionId: string,
1882
+ query: AdminInteractionsByUserRequest = {}) → `Promise<InteractionEventRow[]>`
1883
+ POST /admin/collection/:collectionId/interaction/by-user Returns BigQuery interaction rows, newest first.
1884
+
1885
+ **countsByOutcome**(collectionId: string,
1886
+ query: AdminInteractionsCountsByOutcomeRequest = {}) → `Promise<OutcomeCount[]>`
1887
+ POST /admin/collection/:collectionId/interaction/counts-by-outcome Returns array of { outcome, count }.
1888
+
1889
+ **actorIdsByInteraction**(collectionId: string,
1890
+ query: AdminActorIdsByInteractionRequest) → `Promise<ActorId[] | ActorWithOutcome[]>`
1891
+ POST /admin/collection/:collectionId/interaction/actor-ids/by-interaction Returns list of IDs, optionally with outcome when includeOutcome=true.
1892
+
1893
+ **appendEvent**(collectionId: string,
1894
+ body: AppendInteractionBody) → `Promise<`
1895
+ POST /admin/collection/:collectionId/interaction/append Appends one interaction event.
1896
+
1897
+ **updateEvent**(collectionId: string,
1898
+ body: UpdateInteractionBody) → `Promise<`
1899
+ POST /admin/collection/:collectionId/interaction/append Appends one interaction event.
1900
+
1901
+ **submitPublicEvent**(collectionId: string,
1902
+ body: AppendInteractionBody) → `Promise<`
1903
+ Appends one interaction event from a public source.
1904
+
1905
+ **create**(collectionId: string,
1906
+ body: CreateInteractionTypeBody) → `Promise<InteractionTypeRecord>`
1907
+ Appends one interaction event from a public source.
1908
+
1909
+ **list**(collectionId: string,
1910
+ query: ListInteractionTypesQuery = {}) → `Promise<InteractionTypeList>`
1911
+ Appends one interaction event from a public source.
1912
+
1913
+ **get**(collectionId: string,
1914
+ id: string) → `Promise<InteractionTypeRecord>`
1915
+ Appends one interaction event from a public source.
1916
+
1917
+ **update**(collectionId: string,
1918
+ id: string,
1919
+ patchBody: UpdateInteractionTypeBody) → `Promise<InteractionTypeRecord>`
1920
+ Appends one interaction event from a public source.
1921
+
1922
+ **remove**(collectionId: string,
1923
+ id: string) → `Promise<void>`
1924
+ Appends one interaction event from a public source.
1925
+
1926
+ **publicCountsByOutcome**(collectionId: string,
1927
+ body: PublicInteractionsCountsByOutcomeRequest,
1928
+ authToken?: string) → `Promise<OutcomeCount[]>`
1929
+ Appends one interaction event from a public source.
1930
+
1931
+ **publicMyInteractions**(collectionId: string,
1932
+ body: PublicInteractionsByUserRequest,
1933
+ authToken?: string) → `Promise<InteractionEventRow[]>`
1934
+ Appends one interaction event from a public source.
1935
+
1912
1936
  ### journeys
1913
1937
 
1914
1938
  **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/interaction/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/interaction/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/interaction/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/interaction/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/interaction/by-user
22
+ * Returns BigQuery interaction rows, newest first.
23
+ */
24
+ async function byUser(collectionId, query = {}) {
25
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interaction/by-user`;
26
+ return post(path, query);
27
+ }
28
+ interactions.byUser = byUser;
29
+ /**
30
+ * POST /admin/collection/:collectionId/interaction/counts-by-outcome
31
+ * Returns array of { outcome, count }.
32
+ */
33
+ async function countsByOutcome(collectionId, query = {}) {
34
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interaction/counts-by-outcome`;
35
+ return post(path, query);
36
+ }
37
+ interactions.countsByOutcome = countsByOutcome;
38
+ /**
39
+ * POST /admin/collection/:collectionId/interaction/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)}/interaction/actor-ids/by-interaction`;
44
+ return post(path, query);
45
+ }
46
+ interactions.actorIdsByInteraction = actorIdsByInteraction;
47
+ /**
48
+ * POST /admin/collection/:collectionId/interaction/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)}/interaction/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)}/interaction/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)}/interaction/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)}/interaction/`;
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)}/interaction/${qs}`;
87
+ return request(path);
88
+ }
89
+ interactions.list = list;
90
+ async function get(collectionId, id) {
91
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/interaction/${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)}/interaction/${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)}/interaction/${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)}/interaction/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)}/interaction/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.10",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",