@proveanything/smartlinks 1.0.65 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -128,6 +128,49 @@ const content = await ai.generateContent('collectionId', {
128
128
  console.log(content)
129
129
  ```
130
130
 
131
+ ### Analytics (Actions & Broadcasts)
132
+
133
+ Track user actions and broadcast deliveries per collection. These endpoints live under admin and require valid auth (API key or bearer token).
134
+
135
+ ```ts
136
+ import { actions, broadcasts } from '@proveanything/smartlinks'
137
+
138
+ // List action events for a user
139
+ const actionEvents = await actions.byUser('collectionId', {
140
+ userId: 'user_123',
141
+ from: '2025-01-01T00:00:00Z',
142
+ to: '2025-12-31T23:59:59Z',
143
+ limit: 100,
144
+ })
145
+
146
+ // Outcome counts, optionally deduping latest per actor
147
+ const counts = await actions.countsByOutcome('collectionId', {
148
+ actionId: 'click',
149
+ dedupeLatest: true,
150
+ idField: 'userId',
151
+ })
152
+
153
+ // Append a single action event
154
+ await actions.append('collectionId', {
155
+ userId: 'user_123',
156
+ actionId: 'click',
157
+ outcome: 'success',
158
+ })
159
+
160
+ // Broadcast recipients and filters
161
+ const recipients = await broadcasts.recipientIds('collectionId', {
162
+ broadcastId: 'br_456',
163
+ idField: 'contactId',
164
+ })
165
+
166
+ // Append broadcast recipients in bulk (preferred shape)
167
+ await broadcasts.appendBulk('collectionId', {
168
+ params: { broadcastId: 'br_456', channel: 'email' },
169
+ ids: ['contact_1','contact_2'],
170
+ idField: 'contactId',
171
+ })
172
+ ```
173
+
131
174
  ## Browser and React
132
175
 
133
176
  The SDK works in modern browsers. Initialize once and call public endpoints without an API key; authenticate to access protected/admin endpoints.
@@ -0,0 +1,32 @@
1
+ import type { ActionQueryByUser, ActionCountsQuery, ActorIdsByActionQuery, AppendActionBody, OutcomeCount, ActorId, ActorWithOutcome, ActionEventRow, AdminByUserRequest, AdminCountsByOutcomeRequest, AdminActorIdsByActionRequest, PublicCountsByOutcomeRequest, PublicByUserRequest, CreateActionBody, UpdateActionBody, ListActionsQuery, ActionRecord, ActionList } from "../types/actions";
2
+ export declare namespace actions {
3
+ /**
4
+ * POST /admin/collection/:collectionId/actions/by-user
5
+ * Returns BigQuery action rows, newest first.
6
+ */
7
+ function byUser(collectionId: string, query?: AdminByUserRequest | ActionQueryByUser): Promise<ActionEventRow[]>;
8
+ /**
9
+ * POST /admin/collection/:collectionId/actions/counts-by-outcome
10
+ * Returns array of { outcome, count }.
11
+ */
12
+ function countsByOutcome(collectionId: string, query?: AdminCountsByOutcomeRequest | ActionCountsQuery): Promise<OutcomeCount[]>;
13
+ /**
14
+ * POST /admin/collection/:collectionId/actions/actor-ids/by-action
15
+ * Returns list of IDs, optionally with outcome when includeOutcome=true.
16
+ */
17
+ function actorIdsByAction(collectionId: string, query: AdminActorIdsByActionRequest | ActorIdsByActionQuery): Promise<ActorId[] | ActorWithOutcome[]>;
18
+ /**
19
+ * POST /admin/collection/:collectionId/actions/append
20
+ * Appends one action event.
21
+ */
22
+ function append(collectionId: string, body: AppendActionBody): Promise<{
23
+ success: true;
24
+ }>;
25
+ function create(collectionId: string, body: CreateActionBody): Promise<ActionRecord>;
26
+ function list(collectionId: string, query?: ListActionsQuery): Promise<ActionList>;
27
+ function get(collectionId: string, id: string): Promise<ActionRecord>;
28
+ function update(collectionId: string, id: string, patchBody: UpdateActionBody): Promise<ActionRecord>;
29
+ function remove(collectionId: string, id: string): Promise<void>;
30
+ function publicCountsByOutcome(collectionId: string, body: PublicCountsByOutcomeRequest, authToken?: string): Promise<OutcomeCount[]>;
31
+ function publicMyActions(collectionId: string, body: PublicByUserRequest, authToken?: string): Promise<ActionEventRow[]>;
32
+ }
@@ -0,0 +1,99 @@
1
+ // src/api/actions.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 actions;
19
+ (function (actions) {
20
+ /**
21
+ * POST /admin/collection/:collectionId/actions/by-user
22
+ * Returns BigQuery action rows, newest first.
23
+ */
24
+ async function byUser(collectionId, query = {}) {
25
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/by-user`;
26
+ return post(path, query);
27
+ }
28
+ actions.byUser = byUser;
29
+ /**
30
+ * POST /admin/collection/:collectionId/actions/counts-by-outcome
31
+ * Returns array of { outcome, count }.
32
+ */
33
+ async function countsByOutcome(collectionId, query = {}) {
34
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/counts-by-outcome`;
35
+ return post(path, query);
36
+ }
37
+ actions.countsByOutcome = countsByOutcome;
38
+ /**
39
+ * POST /admin/collection/:collectionId/actions/actor-ids/by-action
40
+ * Returns list of IDs, optionally with outcome when includeOutcome=true.
41
+ */
42
+ async function actorIdsByAction(collectionId, query) {
43
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/actor-ids/by-action`;
44
+ return post(path, query);
45
+ }
46
+ actions.actorIdsByAction = actorIdsByAction;
47
+ /**
48
+ * POST /admin/collection/:collectionId/actions/append
49
+ * Appends one action event.
50
+ */
51
+ async function append(collectionId, body) {
52
+ if (!body.userId && !body.contactId) {
53
+ throw new Error("AppendActionBody must include one of userId or contactId");
54
+ }
55
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/append`;
56
+ return post(path, body);
57
+ }
58
+ actions.append = append;
59
+ // CRUD: Actions (Postgres)
60
+ async function create(collectionId, body) {
61
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/`;
62
+ return post(path, body);
63
+ }
64
+ actions.create = create;
65
+ async function list(collectionId, query = {}) {
66
+ const qs = encodeQuery(query);
67
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/${qs}`;
68
+ return request(path);
69
+ }
70
+ actions.list = list;
71
+ async function get(collectionId, id) {
72
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/${encodeURIComponent(id)}`;
73
+ return request(path);
74
+ }
75
+ actions.get = get;
76
+ async function update(collectionId, id, patchBody) {
77
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/${encodeURIComponent(id)}`;
78
+ return patch(path, patchBody);
79
+ }
80
+ actions.update = update;
81
+ async function remove(collectionId, id) {
82
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/actions/${encodeURIComponent(id)}`;
83
+ return del(path);
84
+ }
85
+ actions.remove = remove;
86
+ // Public endpoints (permission-aware)
87
+ async function publicCountsByOutcome(collectionId, body, authToken) {
88
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/actions/counts-by-outcome`;
89
+ const headers = authToken ? { AUTHORIZATION: `Bearer ${authToken}` } : undefined;
90
+ return post(path, body, headers);
91
+ }
92
+ actions.publicCountsByOutcome = publicCountsByOutcome;
93
+ async function publicMyActions(collectionId, body, authToken) {
94
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/actions/by-user`;
95
+ const headers = authToken ? { AUTHORIZATION: `Bearer ${authToken}` } : undefined;
96
+ return post(path, body, headers);
97
+ }
98
+ actions.publicMyActions = publicMyActions;
99
+ })(actions || (actions = {}));
@@ -0,0 +1,8 @@
1
+ import type { ListBroadcastsQuery, BroadcastRecord, BroadcastList } from "../types/broadcasts";
2
+ export declare namespace broadcasts {
3
+ function create(collectionId: string, body: Omit<BroadcastRecord, 'id' | 'collectionId' | 'createdAt'>): Promise<BroadcastRecord>;
4
+ function list(collectionId: string, query?: ListBroadcastsQuery): Promise<BroadcastList>;
5
+ function get(collectionId: string, id: string): Promise<BroadcastRecord>;
6
+ function update(collectionId: string, id: string, body: Partial<Omit<BroadcastRecord, 'id' | 'collectionId' | 'createdAt'>>): Promise<BroadcastRecord>;
7
+ function remove(collectionId: string, id: string): Promise<void>;
8
+ }
@@ -0,0 +1,50 @@
1
+ // src/api/broadcasts.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 broadcasts;
19
+ (function (broadcasts) {
20
+ // CRUD: Create broadcast
21
+ async function create(collectionId, body) {
22
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/broadcasts/`;
23
+ return post(path, body);
24
+ }
25
+ broadcasts.create = create;
26
+ // CRUD: List broadcasts (GET with query)
27
+ async function list(collectionId, query = {}) {
28
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/broadcasts/${encodeQuery(query)}`;
29
+ return request(path);
30
+ }
31
+ broadcasts.list = list;
32
+ // CRUD: Get a single broadcast
33
+ async function get(collectionId, id) {
34
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/broadcasts/${encodeURIComponent(id)}`;
35
+ return request(path);
36
+ }
37
+ broadcasts.get = get;
38
+ // CRUD: Update a broadcast
39
+ async function update(collectionId, id, body) {
40
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/broadcasts/${encodeURIComponent(id)}`;
41
+ return patch(path, body);
42
+ }
43
+ broadcasts.update = update;
44
+ // CRUD: Delete a broadcast
45
+ async function remove(collectionId, id) {
46
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/broadcasts/${encodeURIComponent(id)}`;
47
+ return del(path);
48
+ }
49
+ broadcasts.remove = remove;
50
+ })(broadcasts || (broadcasts = {}));
@@ -1,4 +1,4 @@
1
- import type { SendNotificationRequest, SendNotificationResponse } from "../types/comms";
1
+ import type { SendNotificationRequest, SendNotificationResponse, CommunicationEvent, CommsQueryByUser, CommsRecipientIdsQuery, CommsRecipientsWithoutActionQuery, CommsRecipientsWithActionQuery, RecipientId, RecipientWithOutcome, LogCommunicationEventBody, LogBulkCommunicationEventsBody, AppendResult, AppendBulkResult } from "../types/comms";
2
2
  /**
3
3
  * Communications namespace for sending notifications and managing user communications
4
4
  */
@@ -44,4 +44,39 @@ export declare namespace comms {
44
44
  * ```
45
45
  */
46
46
  function sendNotification(collectionId: string, request: SendNotificationRequest): Promise<SendNotificationResponse>;
47
+ /**
48
+ * Analytics: Query communication events by user or contact.
49
+ * POST /admin/collection/:collectionId/comm/query/by-user
50
+ */
51
+ function queryByUser(collectionId: string, body?: CommsQueryByUser): Promise<CommunicationEvent[]>;
52
+ /**
53
+ * Analytics: Recipient IDs for a communication source.
54
+ * POST /admin/collection/:collectionId/comm/query/recipient-ids
55
+ */
56
+ function queryRecipientIds(collectionId: string, body: CommsRecipientIdsQuery): Promise<RecipientId[]>;
57
+ /**
58
+ * Analytics: Recipients who did not perform an action.
59
+ * POST /admin/collection/:collectionId/comm/query/recipients/without-action
60
+ */
61
+ function queryRecipientsWithoutAction(collectionId: string, body: CommsRecipientsWithoutActionQuery): Promise<RecipientId[]>;
62
+ /**
63
+ * Analytics: Recipients who performed an action, optionally with outcome.
64
+ * POST /admin/collection/:collectionId/comm/query/recipients/with-action
65
+ */
66
+ function queryRecipientsWithAction(collectionId: string, body: CommsRecipientsWithActionQuery): Promise<RecipientId[] | RecipientWithOutcome[]>;
67
+ /**
68
+ * Logging: Append a single communication event.
69
+ * POST /admin/collection/:collectionId/comm/log
70
+ */
71
+ function logCommunicationEvent(collectionId: string, body: LogCommunicationEventBody): Promise<AppendResult>;
72
+ /**
73
+ * Logging: Append many communication events for a list of IDs.
74
+ * POST /admin/collection/:collectionId/comm/log/bulk
75
+ */
76
+ function logBulkCommunicationEvents(collectionId: string, body: LogBulkCommunicationEventsBody | ({
77
+ sourceId: string;
78
+ ids: string[];
79
+ idField?: 'userId' | 'contactId';
80
+ [k: string]: any;
81
+ })): Promise<AppendBulkResult>;
47
82
  }
package/dist/api/comms.js CHANGED
@@ -51,4 +51,58 @@ export var comms;
51
51
  return post(path, request);
52
52
  }
53
53
  comms.sendNotification = sendNotification;
54
+ /**
55
+ * Analytics: Query communication events by user or contact.
56
+ * POST /admin/collection/:collectionId/comm/query/by-user
57
+ */
58
+ async function queryByUser(collectionId, body = {}) {
59
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/comm/query/by-user`;
60
+ return post(path, body);
61
+ }
62
+ comms.queryByUser = queryByUser;
63
+ /**
64
+ * Analytics: Recipient IDs for a communication source.
65
+ * POST /admin/collection/:collectionId/comm/query/recipient-ids
66
+ */
67
+ async function queryRecipientIds(collectionId, body) {
68
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/comm/query/recipient-ids`;
69
+ return post(path, body);
70
+ }
71
+ comms.queryRecipientIds = queryRecipientIds;
72
+ /**
73
+ * Analytics: Recipients who did not perform an action.
74
+ * POST /admin/collection/:collectionId/comm/query/recipients/without-action
75
+ */
76
+ async function queryRecipientsWithoutAction(collectionId, body) {
77
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/comm/query/recipients/without-action`;
78
+ return post(path, body);
79
+ }
80
+ comms.queryRecipientsWithoutAction = queryRecipientsWithoutAction;
81
+ /**
82
+ * Analytics: Recipients who performed an action, optionally with outcome.
83
+ * POST /admin/collection/:collectionId/comm/query/recipients/with-action
84
+ */
85
+ async function queryRecipientsWithAction(collectionId, body) {
86
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/comm/query/recipients/with-action`;
87
+ return post(path, body);
88
+ }
89
+ comms.queryRecipientsWithAction = queryRecipientsWithAction;
90
+ /**
91
+ * Logging: Append a single communication event.
92
+ * POST /admin/collection/:collectionId/comm/log
93
+ */
94
+ async function logCommunicationEvent(collectionId, body) {
95
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/comm/log`;
96
+ return post(path, body);
97
+ }
98
+ comms.logCommunicationEvent = logCommunicationEvent;
99
+ /**
100
+ * Logging: Append many communication events for a list of IDs.
101
+ * POST /admin/collection/:collectionId/comm/log/bulk
102
+ */
103
+ async function logBulkCommunicationEvents(collectionId, body) {
104
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/comm/log/bulk`;
105
+ return post(path, body);
106
+ }
107
+ comms.logBulkCommunicationEvents = logBulkCommunicationEvents;
54
108
  })(comms || (comms = {}));
@@ -16,4 +16,8 @@ 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
+ export { broadcasts } from "./broadcasts";
21
+ export { segments } from "./segments";
22
+ export { journeys } from "./journeys";
19
23
  export type { AIGenerateContentRequest, AIGenerateImageRequest, AISearchPhotosRequest, AISearchPhotosPhoto } from "./ai";
package/dist/api/index.js CHANGED
@@ -18,3 +18,7 @@ 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
+ export { broadcasts } from "./broadcasts";
23
+ export { segments } from "./segments";
24
+ export { journeys } from "./journeys";
@@ -0,0 +1,8 @@
1
+ import type { JourneyRecord, JourneyList, ListJourneysQuery, CreateJourneyBody, UpdateJourneyBody } from "../types/journeys";
2
+ export declare namespace journeys {
3
+ function create(collectionId: string, body: CreateJourneyBody): Promise<JourneyRecord>;
4
+ function list(collectionId: string, query?: ListJourneysQuery): Promise<JourneyList>;
5
+ function get(collectionId: string, id: string): Promise<JourneyRecord>;
6
+ function update(collectionId: string, id: string, body: UpdateJourneyBody): Promise<JourneyRecord>;
7
+ function remove(collectionId: string, id: string): Promise<void>;
8
+ }
@@ -0,0 +1,48 @@
1
+ // src/api/journeys.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
+ else
11
+ search.set(key, String(value));
12
+ }
13
+ const qs = search.toString();
14
+ return qs ? `?${qs}` : "";
15
+ }
16
+ export var journeys;
17
+ (function (journeys) {
18
+ // Create
19
+ async function create(collectionId, body) {
20
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/journeys/`;
21
+ return post(path, body);
22
+ }
23
+ journeys.create = create;
24
+ // List
25
+ async function list(collectionId, query = {}) {
26
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/journeys/${encodeQuery(query)}`;
27
+ return request(path);
28
+ }
29
+ journeys.list = list;
30
+ // Get
31
+ async function get(collectionId, id) {
32
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/journeys/${encodeURIComponent(id)}`;
33
+ return request(path);
34
+ }
35
+ journeys.get = get;
36
+ // Update
37
+ async function update(collectionId, id, body) {
38
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/journeys/${encodeURIComponent(id)}`;
39
+ return patch(path, body);
40
+ }
41
+ journeys.update = update;
42
+ // Delete
43
+ async function remove(collectionId, id) {
44
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/journeys/${encodeURIComponent(id)}`;
45
+ return del(path);
46
+ }
47
+ journeys.remove = remove;
48
+ })(journeys || (journeys = {}));
@@ -0,0 +1,13 @@
1
+ import type { SegmentRecord, ListSegmentsQuery, SegmentList, SegmentCalculateResult, SegmentRecipientsResponse } from "../types/segments";
2
+ export declare namespace segments {
3
+ function create(collectionId: string, body: Omit<SegmentRecord, 'id' | 'collectionId' | 'createdAt'>): Promise<SegmentRecord>;
4
+ function list(collectionId: string, query?: ListSegmentsQuery): Promise<SegmentList>;
5
+ function get(collectionId: string, id: string): Promise<SegmentRecord>;
6
+ function update(collectionId: string, id: string, body: Partial<Omit<SegmentRecord, 'id' | 'collectionId' | 'createdAt'>>): Promise<SegmentRecord>;
7
+ function remove(collectionId: string, id: string): Promise<void>;
8
+ function calculate(collectionId: string, id: string): Promise<SegmentCalculateResult>;
9
+ function recipients(collectionId: string, id: string, query?: {
10
+ limit?: number;
11
+ offset?: number;
12
+ }): Promise<SegmentRecipientsResponse>;
13
+ }
@@ -0,0 +1,60 @@
1
+ // src/api/segments.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
+ else
11
+ search.set(key, String(value));
12
+ }
13
+ const qs = search.toString();
14
+ return qs ? `?${qs}` : "";
15
+ }
16
+ export var segments;
17
+ (function (segments) {
18
+ // Create
19
+ async function create(collectionId, body) {
20
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/segments/`;
21
+ return post(path, body);
22
+ }
23
+ segments.create = create;
24
+ // List
25
+ async function list(collectionId, query = {}) {
26
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/segments/${encodeQuery(query)}`;
27
+ return request(path);
28
+ }
29
+ segments.list = list;
30
+ // Get
31
+ async function get(collectionId, id) {
32
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/segments/${encodeURIComponent(id)}`;
33
+ return request(path);
34
+ }
35
+ segments.get = get;
36
+ // Update
37
+ async function update(collectionId, id, body) {
38
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/segments/${encodeURIComponent(id)}`;
39
+ return patch(path, body);
40
+ }
41
+ segments.update = update;
42
+ // Delete
43
+ async function remove(collectionId, id) {
44
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/segments/${encodeURIComponent(id)}`;
45
+ return del(path);
46
+ }
47
+ segments.remove = remove;
48
+ // Stub: calculate
49
+ async function calculate(collectionId, id) {
50
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/segments/${encodeURIComponent(id)}/calculate`;
51
+ return post(path, {});
52
+ }
53
+ segments.calculate = calculate;
54
+ // Stub: recipients
55
+ async function recipients(collectionId, id, query = {}) {
56
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/segments/${encodeURIComponent(id)}/recipients${encodeQuery(query)}`;
57
+ return request(path);
58
+ }
59
+ segments.recipients = recipients;
60
+ })(segments || (segments = {}));
@@ -0,0 +1,120 @@
1
+ import type { IdField } from './common';
2
+ export interface AdminByUserRequest {
3
+ userId?: string;
4
+ contactId?: string;
5
+ appId?: string;
6
+ actionId?: string;
7
+ broadcastId?: string;
8
+ outcome?: string | null;
9
+ from?: string;
10
+ to?: string;
11
+ limit?: number;
12
+ }
13
+ export interface AdminCountsByOutcomeRequest {
14
+ appId?: string;
15
+ actionId?: string;
16
+ from?: string;
17
+ to?: string;
18
+ limit?: number;
19
+ dedupeLatest?: boolean;
20
+ idField?: IdField;
21
+ }
22
+ export interface AdminActorIdsByActionRequest {
23
+ actionId: string;
24
+ idField?: IdField;
25
+ outcome?: string | null;
26
+ includeOutcome?: boolean;
27
+ from?: string;
28
+ to?: string;
29
+ limit?: number;
30
+ }
31
+ export interface PublicCountsByOutcomeRequest {
32
+ appId: string;
33
+ actionId: string;
34
+ from?: string;
35
+ to?: string;
36
+ limit?: number;
37
+ }
38
+ export interface PublicByUserRequest {
39
+ appId: string;
40
+ actionId: string;
41
+ from?: string;
42
+ to?: string;
43
+ limit?: number;
44
+ }
45
+ export interface ActionEventRow {
46
+ orgId: string;
47
+ timestamp: string;
48
+ appId?: string;
49
+ actionId?: string;
50
+ broadcastId?: string;
51
+ userId?: string;
52
+ contactId?: string;
53
+ outcome?: string | null;
54
+ [k: string]: unknown;
55
+ }
56
+ export interface OutcomeCount {
57
+ outcome: string | null;
58
+ count: number;
59
+ }
60
+ export type ActorId = string;
61
+ export interface ActorWithOutcome {
62
+ id: string;
63
+ outcome: string | null;
64
+ }
65
+ export interface AppendActionBody {
66
+ userId?: string;
67
+ contactId?: string;
68
+ actionId: string;
69
+ appId?: string;
70
+ broadcastId?: string;
71
+ outcome?: string;
72
+ timestamp?: string;
73
+ [k: string]: any;
74
+ }
75
+ export interface ActionPermissions {
76
+ allowOwnRead?: boolean;
77
+ allowPublicSummary?: boolean;
78
+ allowAuthenticatedSummary?: boolean;
79
+ }
80
+ export interface ActionRecord {
81
+ id: string;
82
+ collectionId: string;
83
+ appId: string;
84
+ permissions?: ActionPermissions;
85
+ data?: {
86
+ display?: {
87
+ title?: string;
88
+ description?: string;
89
+ icon?: string;
90
+ color?: string;
91
+ };
92
+ actionType?: string;
93
+ [key: string]: unknown;
94
+ };
95
+ createdAt: string;
96
+ }
97
+ export interface ActionList {
98
+ items: ActionRecord[];
99
+ limit: number;
100
+ offset: number;
101
+ }
102
+ export interface CreateActionBody {
103
+ id: string;
104
+ appId: string;
105
+ permissions?: ActionPermissions;
106
+ data?: Record<string, unknown>;
107
+ }
108
+ export interface UpdateActionBody {
109
+ appId?: string;
110
+ permissions?: ActionPermissions;
111
+ data?: Record<string, unknown>;
112
+ }
113
+ export interface ListActionsQuery {
114
+ appId?: string;
115
+ limit?: number;
116
+ offset?: number;
117
+ }
118
+ export type ActionQueryByUser = AdminByUserRequest;
119
+ export type ActionCountsQuery = AdminCountsByOutcomeRequest;
120
+ export type ActorIdsByActionQuery = AdminActorIdsByActionRequest;
@@ -0,0 +1,2 @@
1
+ // src/types/actions.ts
2
+ export {};
File without changes
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // Deprecated: types moved to ./actions.ts and ./broadcasts.ts
3
+ // This file is intentionally left empty to avoid duplicate exports.
@@ -0,0 +1,31 @@
1
+ export interface ListBroadcastsQuery {
2
+ limit?: number;
3
+ offset?: number;
4
+ appId?: string;
5
+ }
6
+ export interface BroadcastRecord {
7
+ id: string;
8
+ collectionId: string;
9
+ appId: string;
10
+ templateId?: string | null;
11
+ segmentId?: string | null;
12
+ status?: string | null;
13
+ scheduledAt?: string | null;
14
+ sentAt?: string | null;
15
+ data?: {
16
+ display?: {
17
+ title?: string;
18
+ description?: string;
19
+ icon?: string;
20
+ color?: string;
21
+ };
22
+ broadcastType?: string;
23
+ [key: string]: unknown;
24
+ };
25
+ createdAt: string;
26
+ }
27
+ export interface BroadcastList {
28
+ items: BroadcastRecord[];
29
+ limit: number;
30
+ offset: number;
31
+ }
@@ -0,0 +1,2 @@
1
+ // src/types/broadcasts.ts
2
+ export {};
@@ -0,0 +1 @@
1
+ export type IdField = 'userId' | 'contactId';