@proveanything/smartlinks 1.1.21 → 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 +92 -1
- package/README.md +54 -0
- package/dist/api/async.d.ts +13 -0
- package/dist/api/async.js +24 -0
- package/dist/api/broadcasts.d.ts +10 -0
- package/dist/api/broadcasts.js +8 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +2 -0
- package/dist/api/jobs.d.ts +13 -0
- package/dist/api/jobs.js +35 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/jobs.d.ts +42 -0
- package/dist/types/jobs.js +2 -0
- package/package.json +1 -1
package/API_SUMMARY.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Smartlinks API Summary
|
|
2
2
|
|
|
3
|
-
Version: 1.1.
|
|
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>`
|
|
@@ -2185,6 +2266,16 @@ Appends one interaction event from a public source.
|
|
|
2185
2266
|
id: string) → `Promise<InteractionTypeRecord>`
|
|
2186
2267
|
Appends one interaction event from a public source.
|
|
2187
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
|
+
|
|
2188
2279
|
### journeys
|
|
2189
2280
|
|
|
2190
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 = {}));
|
package/dist/api/broadcasts.d.ts
CHANGED
|
@@ -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>;
|
package/dist/api/broadcasts.js
CHANGED
|
@@ -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`;
|
package/dist/api/index.d.ts
CHANGED
|
@@ -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";
|
|
@@ -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
|
+
}
|
package/dist/api/jobs.js
ADDED
|
@@ -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 = {}));
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -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
|
+
}
|