@proveanything/smartlinks 1.1.20 → 1.1.22

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.20 | Generated: 2026-01-05T11:30:32.718Z
3
+ Version: 1.1.22 | Generated: 2026-01-07T12:13:29.397Z
4
4
 
5
5
  This is a concise summary of all available API functions and types.
6
6
 
@@ -46,7 +46,9 @@ The Smartlinks SDK is organized into the following namespaces:
46
46
  - **serialNumber** - Assign, lookup, and manage serial numbers across scopes.
47
47
 
48
48
  — Other —
49
+ - **async** - Functions for async operations
49
50
  - **attestation** - Functions for attestation operations
51
+ - **jobs** - Functions for jobs operations
50
52
  - **journeysAnalytics** - Functions for journeysAnalytics operations
51
53
  - **location** - Functions for location operations
52
54
  - **template** - Functions for template operations
@@ -1056,6 +1058,71 @@ interface ListInteractionTypesQuery {
1056
1058
  }
1057
1059
  ```
1058
1060
 
1061
+ ### jobs
1062
+
1063
+ **Job** (interface)
1064
+ ```typescript
1065
+ interface Job {
1066
+ id: number
1067
+ task: string
1068
+ payload: any
1069
+ priority: number
1070
+ runAt: string | null
1071
+ createdAt: string
1072
+ attempts: number
1073
+ lastError: string | null
1074
+ lockedAt: string | null
1075
+ key: string | null
1076
+ queueName: string | null
1077
+ status: JobStatus
1078
+ }
1079
+ ```
1080
+
1081
+ **ListJobsQuery** (interface)
1082
+ ```typescript
1083
+ interface ListJobsQuery {
1084
+ state?: JobStatus
1085
+ task?: string
1086
+ limit?: number
1087
+ offset?: number
1088
+ from?: string
1089
+ to?: string
1090
+ }
1091
+ ```
1092
+
1093
+ **JobsPage** (interface)
1094
+ ```typescript
1095
+ interface JobsPage {
1096
+ items: Job[]
1097
+ limit: number
1098
+ offset: number
1099
+ }
1100
+ ```
1101
+
1102
+ **EnqueueAsyncJobRequest** (interface)
1103
+ ```typescript
1104
+ interface EnqueueAsyncJobRequest {
1105
+ task: string
1106
+ payload?: Record<string, any>
1107
+ runAt?: string | Date
1108
+ priority?: number
1109
+ key?: string
1110
+ queueName?: string
1111
+ }
1112
+ ```
1113
+
1114
+ **EnqueueAsyncJobResponse** (interface)
1115
+ ```typescript
1116
+ interface EnqueueAsyncJobResponse {
1117
+ id: number
1118
+ task: string
1119
+ runAt?: string
1120
+ key?: string
1121
+ }
1122
+ ```
1123
+
1124
+ **JobStatus** = `'queued' | 'running' | 'errored'`
1125
+
1059
1126
  ### journeys
1060
1127
 
1061
1128
  **JourneyRecord** (interface)
@@ -1723,6 +1790,16 @@ Post a chat message to the AI (admin or public)
1723
1790
  onProgress?: (percent: number) → `void`
1724
1791
  Uploads an asset file to a proof, with optional extraData as JSON. Supports progress reporting via onProgress callback (browser only).
1725
1792
 
1793
+ ### async
1794
+
1795
+ **enqueueAsyncJob**(collectionId: string,
1796
+ params: EnqueueAsyncJobRequest) → `Promise<EnqueueAsyncJobResponse>`
1797
+ Enqueue a background job for a collection POST /admin/collection/:collectionId/async/jobs (202)
1798
+
1799
+ **getAsyncJobStatus**(collectionId: string,
1800
+ jobId: number) → `Promise<Job>`
1801
+ Get job status by ID (may return 404 if completed/removed) GET /admin/collection/:collectionId/async/jobs/:jobId
1802
+
1726
1803
  ### attestation
1727
1804
 
1728
1805
  **list**(collectionId: string,
@@ -1937,6 +2014,10 @@ Look up a serial number by code for a batch (admin only).
1937
2014
  id: string,
1938
2015
  body: BroadcastPreviewRequest) → `Promise<BroadcastPreviewResponse>`
1939
2016
 
2017
+ **send**(collectionId: string,
2018
+ id: string,
2019
+ body: { pageSize?: number; maxPages?: number; sharedContext?: Record<string, any>; subject?: string } = {}) → `Promise<`
2020
+
1940
2021
  **sendTest**(collectionId: string,
1941
2022
  id: string,
1942
2023
  body: BroadcastSendTestRequest) → `Promise<BroadcastSendTestResponse>`
@@ -2177,6 +2258,24 @@ Appends one interaction event from a public source.
2177
2258
  authToken?: string) → `Promise<InteractionEventRow[]>`
2178
2259
  Appends one interaction event from a public source.
2179
2260
 
2261
+ **publicList**(collectionId: string,
2262
+ query: ListInteractionTypesQuery = {}) → `Promise<InteractionTypeList>`
2263
+ Appends one interaction event from a public source.
2264
+
2265
+ **publicGet**(collectionId: string,
2266
+ id: string) → `Promise<InteractionTypeRecord>`
2267
+ Appends one interaction event from a public source.
2268
+
2269
+ ### jobs
2270
+
2271
+ **listJobs**(collectionId: string,
2272
+ query: ListJobsQuery = {}) → `Promise<JobsPage>`
2273
+ List visible jobs for a collection GET /admin/collection/:collectionId/jobs
2274
+
2275
+ **getJob**(collectionId: string,
2276
+ jobId: number) → `Promise<Job>`
2277
+ Get a single job GET /admin/collection/:collectionId/jobs/:jobId
2278
+
2180
2279
  ### journeys
2181
2280
 
2182
2281
  **create**(collectionId: string,
package/README.md CHANGED
@@ -171,6 +171,60 @@ await broadcasts.appendBulk('collectionId', {
171
171
  })
172
172
  ```
173
173
 
174
+ ### Broadcast sending and previews
175
+
176
+ ```ts
177
+ import { broadcasts } from '@proveanything/smartlinks'
178
+
179
+ // Preview a broadcast (HTML)
180
+ const preview = await broadcasts.preview('collectionId', 'broadcastId', {
181
+ contactId: 'contact_123',
182
+ props: { firstName: 'Sam' },
183
+ })
184
+
185
+ // Send a test email
186
+ await broadcasts.sendTest('collectionId', 'broadcastId', {
187
+ to: 'test@example.com',
188
+ subject: 'Test subject',
189
+ props: { foo: 'bar' },
190
+ })
191
+
192
+ // Enqueue broadcast sending (background)
193
+ await broadcasts.send('collectionId', 'broadcastId', {
194
+ pageSize: 100,
195
+ sharedContext: { campaign: 'summer' },
196
+ })
197
+
198
+ // Manual page send (for testing/UX)
199
+ const manual = await broadcasts.sendManual('collectionId', 'broadcastId', {
200
+ limit: 50,
201
+ dryRun: true,
202
+ })
203
+ ```
204
+
205
+ ### Async jobs
206
+
207
+ ```ts
208
+ import { async as slAsync, jobs } from '@proveanything/smartlinks'
209
+
210
+ // Enqueue an async job
211
+ const queued = await slAsync.enqueueAsyncJob('collectionId', {
212
+ task: 'email:daily-digest',
213
+ payload: { segmentId: 'seg_1' },
214
+ priority: 5,
215
+ key: 'digest:seg_1',
216
+ })
217
+
218
+ // Check job status
219
+ const status = await slAsync.getAsyncJobStatus('collectionId', queued.id)
220
+
221
+ // List recent jobs
222
+ const recent = await jobs.listJobs('collectionId', { state: 'queued', limit: 20 })
223
+
224
+ // Get a single job
225
+ const job = await jobs.getJob('collectionId', queued.id)
226
+ ```
227
+
174
228
  ## Browser and React
175
229
 
176
230
  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,13 @@
1
+ import type { EnqueueAsyncJobRequest, EnqueueAsyncJobResponse, Job } from "../types/jobs";
2
+ export declare namespace async {
3
+ /**
4
+ * Enqueue a background job for a collection
5
+ * POST /admin/collection/:collectionId/async/jobs (202)
6
+ */
7
+ function enqueueAsyncJob(collectionId: string, params: EnqueueAsyncJobRequest): Promise<EnqueueAsyncJobResponse>;
8
+ /**
9
+ * Get job status by ID (may return 404 if completed/removed)
10
+ * GET /admin/collection/:collectionId/async/jobs/:jobId
11
+ */
12
+ function getAsyncJobStatus(collectionId: string, jobId: number): Promise<Job>;
13
+ }
@@ -0,0 +1,24 @@
1
+ // src/api/async.ts
2
+ import { request, post } from "../http";
3
+ function enc(v) { return encodeURIComponent(v); }
4
+ export var async;
5
+ (function (async) {
6
+ /**
7
+ * Enqueue a background job for a collection
8
+ * POST /admin/collection/:collectionId/async/jobs (202)
9
+ */
10
+ async function enqueueAsyncJob(collectionId, params) {
11
+ const path = `/admin/collection/${enc(collectionId)}/async/jobs`;
12
+ return post(path, params);
13
+ }
14
+ async.enqueueAsyncJob = enqueueAsyncJob;
15
+ /**
16
+ * Get job status by ID (may return 404 if completed/removed)
17
+ * GET /admin/collection/:collectionId/async/jobs/:jobId
18
+ */
19
+ async function getAsyncJobStatus(collectionId, jobId) {
20
+ const path = `/admin/collection/${enc(collectionId)}/async/jobs/${jobId}`;
21
+ return request(path);
22
+ }
23
+ async.getAsyncJobStatus = getAsyncJobStatus;
24
+ })(async || (async = {}));
@@ -11,6 +11,16 @@ export declare namespace broadcasts {
11
11
  offset?: number;
12
12
  }): Promise<BroadcastRecipientsResponse>;
13
13
  function preview(collectionId: string, id: string, body: BroadcastPreviewRequest): Promise<BroadcastPreviewResponse>;
14
+ function send(collectionId: string, id: string, body?: {
15
+ pageSize?: number;
16
+ maxPages?: number;
17
+ sharedContext?: Record<string, any>;
18
+ subject?: string;
19
+ }): Promise<{
20
+ ok: true;
21
+ enqueued: true;
22
+ }>;
23
+ const sendBroadcast: typeof send;
14
24
  function sendTest(collectionId: string, id: string, body: BroadcastSendTestRequest): Promise<BroadcastSendTestResponse>;
15
25
  function sendManual(collectionId: string, id: string, body: BroadcastSendManualRequest): Promise<BroadcastSendManualResponse>;
16
26
  function append(collectionId: string, body: BroadcastAppendEventBody): Promise<AppendResult>;
@@ -60,6 +60,14 @@ export var broadcasts;
60
60
  return post(path, body);
61
61
  }
62
62
  broadcasts.preview = preview;
63
+ // Enqueue send for a broadcast (202 Accepted)
64
+ async function send(collectionId, id, body = {}) {
65
+ const path = `/admin/collection/${encodeURIComponent(collectionId)}/broadcasts/${encodeURIComponent(id)}/send`;
66
+ return post(path, body);
67
+ }
68
+ broadcasts.send = send;
69
+ // Alias for clarity with docs naming
70
+ broadcasts.sendBroadcast = send;
63
71
  // Send a single test email
64
72
  async function sendTest(collectionId, id, body) {
65
73
  const path = `/admin/collection/${encodeURIComponent(collectionId)}/broadcasts/${encodeURIComponent(id)}/send/test`;
@@ -17,6 +17,8 @@ export { comms } from "./comms";
17
17
  export { nfc } from "./nfc";
18
18
  export { contact } from "./contact";
19
19
  export { broadcasts } from "./broadcasts";
20
+ export { async } from "./async";
21
+ export { jobs } from "./jobs";
20
22
  export { segments } from "./segments";
21
23
  export { journeys } from "./journeys";
22
24
  export { journeysAnalytics } from "./journeysAnalytics";
package/dist/api/index.js CHANGED
@@ -19,6 +19,8 @@ export { comms } from "./comms";
19
19
  export { nfc } from "./nfc";
20
20
  export { contact } from "./contact";
21
21
  export { broadcasts } from "./broadcasts";
22
+ export { async } from "./async";
23
+ export { jobs } from "./jobs";
22
24
  export { segments } from "./segments";
23
25
  export { journeys } from "./journeys";
24
26
  export { journeysAnalytics } from "./journeysAnalytics";
@@ -33,4 +33,6 @@ export declare namespace interactions {
33
33
  function remove(collectionId: string, id: string): Promise<void>;
34
34
  function publicCountsByOutcome(collectionId: string, body: PublicInteractionsCountsByOutcomeRequest, authToken?: string): Promise<OutcomeCount[]>;
35
35
  function publicMyInteractions(collectionId: string, body: PublicInteractionsByUserRequest, authToken?: string): Promise<InteractionEventRow[]>;
36
+ function publicList(collectionId: string, query?: ListInteractionTypesQuery): Promise<InteractionTypeList>;
37
+ function publicGet(collectionId: string, id: string): Promise<InteractionTypeRecord>;
36
38
  }
@@ -107,4 +107,17 @@ export var interactions;
107
107
  return post(path, body, headers);
108
108
  }
109
109
  interactions.publicMyInteractions = publicMyInteractions;
110
+ // Public: list interaction definitions (Postgres)
111
+ async function publicList(collectionId, query = {}) {
112
+ const qs = encodeQuery(query);
113
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/interactions/${qs}`;
114
+ return request(path);
115
+ }
116
+ interactions.publicList = publicList;
117
+ // Public: get a single interaction definition (Postgres)
118
+ async function publicGet(collectionId, id) {
119
+ const path = `/public/collection/${encodeURIComponent(collectionId)}/interactions/${encodeURIComponent(id)}`;
120
+ return request(path);
121
+ }
122
+ interactions.publicGet = publicGet;
110
123
  })(interactions || (interactions = {}));
@@ -0,0 +1,13 @@
1
+ import type { JobsPage, ListJobsQuery, Job } from "../types/jobs";
2
+ export declare namespace jobs {
3
+ /**
4
+ * List visible jobs for a collection
5
+ * GET /admin/collection/:collectionId/jobs
6
+ */
7
+ function listJobs(collectionId: string, query?: ListJobsQuery): Promise<JobsPage>;
8
+ /**
9
+ * Get a single job
10
+ * GET /admin/collection/:collectionId/jobs/:jobId
11
+ */
12
+ function getJob(collectionId: string, jobId: number): Promise<Job>;
13
+ }
@@ -0,0 +1,35 @@
1
+ // src/api/jobs.ts
2
+ import { request } from "../http";
3
+ function enc(v) { return encodeURIComponent(v); }
4
+ function encodeQuery(params = {}) {
5
+ const search = new URLSearchParams();
6
+ for (const [key, value] of Object.entries(params)) {
7
+ if (value === undefined || value === null || value === '')
8
+ continue;
9
+ search.set(key, String(value));
10
+ }
11
+ const qs = search.toString();
12
+ return qs ? `?${qs}` : '';
13
+ }
14
+ export var jobs;
15
+ (function (jobs) {
16
+ /**
17
+ * List visible jobs for a collection
18
+ * GET /admin/collection/:collectionId/jobs
19
+ */
20
+ async function listJobs(collectionId, query = {}) {
21
+ const qs = encodeQuery(query);
22
+ const path = `/admin/collection/${enc(collectionId)}/jobs${qs}`;
23
+ return request(path);
24
+ }
25
+ jobs.listJobs = listJobs;
26
+ /**
27
+ * Get a single job
28
+ * GET /admin/collection/:collectionId/jobs/:jobId
29
+ */
30
+ async function getJob(collectionId, jobId) {
31
+ const path = `/admin/collection/${enc(collectionId)}/jobs/${jobId}`;
32
+ return request(path);
33
+ }
34
+ jobs.getJob = getJob;
35
+ })(jobs || (jobs = {}));
@@ -20,3 +20,4 @@ export * from "./qr";
20
20
  export * from "./template";
21
21
  export * from "./interaction";
22
22
  export * from "./location";
23
+ export * from "./jobs";
@@ -22,3 +22,4 @@ export * from "./qr";
22
22
  export * from "./template";
23
23
  export * from "./interaction";
24
24
  export * from "./location";
25
+ export * from "./jobs";
@@ -0,0 +1,42 @@
1
+ export type JobStatus = 'queued' | 'running' | 'errored';
2
+ export interface Job {
3
+ id: number;
4
+ task: string;
5
+ payload: any;
6
+ priority: number;
7
+ runAt: string | null;
8
+ createdAt: string;
9
+ attempts: number;
10
+ lastError: string | null;
11
+ lockedAt: string | null;
12
+ key: string | null;
13
+ queueName: string | null;
14
+ status: JobStatus;
15
+ }
16
+ export interface ListJobsQuery {
17
+ state?: JobStatus;
18
+ task?: string;
19
+ limit?: number;
20
+ offset?: number;
21
+ from?: string;
22
+ to?: string;
23
+ }
24
+ export interface JobsPage {
25
+ items: Job[];
26
+ limit: number;
27
+ offset: number;
28
+ }
29
+ export interface EnqueueAsyncJobRequest {
30
+ task: string;
31
+ payload?: Record<string, any>;
32
+ runAt?: string | Date;
33
+ priority?: number;
34
+ key?: string;
35
+ queueName?: string;
36
+ }
37
+ export interface EnqueueAsyncJobResponse {
38
+ id: number;
39
+ task: string;
40
+ runAt?: string;
41
+ key?: string;
42
+ }
@@ -0,0 +1,2 @@
1
+ // src/types/jobs.ts
2
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proveanything/smartlinks",
3
- "version": "1.1.20",
3
+ "version": "1.1.22",
4
4
  "description": "Official JavaScript/TypeScript SDK for the Smartlinks API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",