lumnisai 0.1.20 → 0.1.21
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/dist/index.cjs +116 -4
- package/dist/index.d.cts +172 -8
- package/dist/index.d.mts +172 -8
- package/dist/index.d.ts +172 -8
- package/dist/index.mjs +116 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1116,23 +1116,97 @@ class MessagingResource {
|
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
1118
|
/**
|
|
1119
|
-
* Create drafts for multiple prospects with AI generation
|
|
1119
|
+
* Create drafts for multiple prospects with AI generation.
|
|
1120
|
+
*
|
|
1121
|
+
* **Default behavior (async):**
|
|
1122
|
+
* Returns immediately with a job_id (202 response). Poll `getBatchDraftJobStatus()`
|
|
1123
|
+
* for progress and results. The job continues processing in the background even
|
|
1124
|
+
* if the client disconnects.
|
|
1125
|
+
*
|
|
1126
|
+
* **Legacy behavior (sync):**
|
|
1127
|
+
* Set `wait: true` to block until completion. Not recommended for large batches
|
|
1128
|
+
* as the request may timeout.
|
|
1129
|
+
*
|
|
1130
|
+
* @param userId - User ID or email
|
|
1131
|
+
* @param request - Batch draft creation request
|
|
1132
|
+
* @param options - Optional parameters
|
|
1133
|
+
* @param options.wait - If true, wait for completion (legacy behavior)
|
|
1134
|
+
* @returns BatchDraftJobResponse (async) or BatchDraftResponse (sync with wait=true)
|
|
1135
|
+
*
|
|
1136
|
+
* @example
|
|
1137
|
+
* ```typescript
|
|
1138
|
+
* // Async (recommended) - returns immediately with job_id
|
|
1139
|
+
* const job = await client.messaging.createBatchDrafts(userId, request);
|
|
1140
|
+
* if ('jobId' in job) {
|
|
1141
|
+
* // Poll for status
|
|
1142
|
+
* const status = await client.messaging.getBatchDraftJobStatus(userId, job.jobId);
|
|
1143
|
+
* }
|
|
1144
|
+
*
|
|
1145
|
+
* // Sync (legacy) - blocks until complete
|
|
1146
|
+
* const result = await client.messaging.createBatchDrafts(userId, request, { wait: true });
|
|
1147
|
+
* console.log(result.drafts); // All drafts available immediately
|
|
1148
|
+
* ```
|
|
1120
1149
|
*/
|
|
1121
|
-
async createBatchDrafts(userId, request) {
|
|
1150
|
+
async createBatchDrafts(userId, request, options) {
|
|
1122
1151
|
const queryParams = new URLSearchParams();
|
|
1123
1152
|
queryParams.append("user_id", userId);
|
|
1153
|
+
if (options?.wait) {
|
|
1154
|
+
queryParams.append("wait", "true");
|
|
1155
|
+
}
|
|
1124
1156
|
return this.http.post(
|
|
1125
1157
|
`/messaging/drafts/batch?${queryParams.toString()}`,
|
|
1126
1158
|
request
|
|
1127
1159
|
);
|
|
1128
1160
|
}
|
|
1161
|
+
/**
|
|
1162
|
+
* Get status and results of a batch draft job.
|
|
1163
|
+
*
|
|
1164
|
+
* Poll this endpoint to track progress and retrieve results for batch draft jobs
|
|
1165
|
+
* created via `createBatchDrafts()`. Jobs are retained for 24 hours after creation.
|
|
1166
|
+
*
|
|
1167
|
+
* @param userId - User ID or email
|
|
1168
|
+
* @param jobId - The job ID returned from createBatchDrafts()
|
|
1169
|
+
* @returns BatchDraftJobStatusResponse with progress and results
|
|
1170
|
+
* @throws NotFoundError if job not found or expired
|
|
1171
|
+
*
|
|
1172
|
+
* @example
|
|
1173
|
+
* ```typescript
|
|
1174
|
+
* // Create job
|
|
1175
|
+
* const job = await client.messaging.createBatchDrafts(userId, request);
|
|
1176
|
+
* if ('jobId' in job) {
|
|
1177
|
+
* // Poll until complete
|
|
1178
|
+
* let status;
|
|
1179
|
+
* do {
|
|
1180
|
+
* await new Promise(r => setTimeout(r, 1000)); // Wait 1 second
|
|
1181
|
+
* status = await client.messaging.getBatchDraftJobStatus(userId, job.jobId);
|
|
1182
|
+
* console.log(`Progress: ${status.progress.percentage}%`);
|
|
1183
|
+
* } while (status.status !== 'completed' && status.status !== 'failed');
|
|
1184
|
+
*
|
|
1185
|
+
* console.log(`Created ${status.drafts.length} drafts`);
|
|
1186
|
+
* }
|
|
1187
|
+
* ```
|
|
1188
|
+
*/
|
|
1189
|
+
async getBatchDraftJobStatus(userId, jobId) {
|
|
1190
|
+
const queryParams = new URLSearchParams();
|
|
1191
|
+
queryParams.append("user_id", userId);
|
|
1192
|
+
return this.http.get(
|
|
1193
|
+
`/messaging/drafts/batch/jobs/${encodeURIComponent(jobId)}?${queryParams.toString()}`
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1129
1196
|
/**
|
|
1130
1197
|
* Create drafts for multiple prospects with real-time progress updates via Server-Sent Events (SSE).
|
|
1131
1198
|
*
|
|
1132
1199
|
* This method provides real-time progress updates as drafts are being created, significantly
|
|
1133
1200
|
* improving user experience for large batch operations (30+ prospects).
|
|
1134
1201
|
*
|
|
1202
|
+
* **Resilience features:**
|
|
1203
|
+
* - Job state is stored in Redis and survives client disconnects
|
|
1204
|
+
* - Background task continues processing even if SSE connection drops
|
|
1205
|
+
* - Client can reconnect using `jobId` option to resume streaming
|
|
1206
|
+
* - Poll `getBatchDraftJobStatus()` as fallback
|
|
1207
|
+
*
|
|
1135
1208
|
* **Event Types:**
|
|
1209
|
+
* - `job_started`: First event with job_id for reconnection
|
|
1136
1210
|
* - `progress`: Progress update with percentage and current prospect
|
|
1137
1211
|
* - `draft_created`: Draft successfully created
|
|
1138
1212
|
* - `error`: Error occurred for a specific prospect
|
|
@@ -1140,6 +1214,8 @@ class MessagingResource {
|
|
|
1140
1214
|
*
|
|
1141
1215
|
* **Example:**
|
|
1142
1216
|
* ```typescript
|
|
1217
|
+
* let savedJobId: string | undefined;
|
|
1218
|
+
*
|
|
1143
1219
|
* const result = await client.messaging.createBatchDraftsStream(
|
|
1144
1220
|
* 'user@example.com',
|
|
1145
1221
|
* {
|
|
@@ -1148,6 +1224,9 @@ class MessagingResource {
|
|
|
1148
1224
|
* useAiGeneration: true
|
|
1149
1225
|
* },
|
|
1150
1226
|
* {
|
|
1227
|
+
* onJobStarted: (jobId) => {
|
|
1228
|
+
* savedJobId = jobId; // Save for reconnection if disconnected
|
|
1229
|
+
* },
|
|
1151
1230
|
* onProgress: (processed, total, percentage, prospectName) => {
|
|
1152
1231
|
* console.log(`${percentage}% - ${prospectName}`)
|
|
1153
1232
|
* },
|
|
@@ -1167,11 +1246,16 @@ class MessagingResource {
|
|
|
1167
1246
|
* @param userId - User ID or email
|
|
1168
1247
|
* @param request - Batch draft creation request
|
|
1169
1248
|
* @param callbacks - Optional callbacks for stream events
|
|
1249
|
+
* @param options - Optional parameters
|
|
1250
|
+
* @param options.jobId - Existing job ID to resume streaming (for reconnection)
|
|
1170
1251
|
* @returns Final result with created drafts and error details
|
|
1171
1252
|
*/
|
|
1172
|
-
async createBatchDraftsStream(userId, request, callbacks) {
|
|
1253
|
+
async createBatchDraftsStream(userId, request, callbacks, options) {
|
|
1173
1254
|
const queryParams = new URLSearchParams();
|
|
1174
1255
|
queryParams.append("user_id", userId);
|
|
1256
|
+
if (options?.jobId) {
|
|
1257
|
+
queryParams.append("job_id", options.jobId);
|
|
1258
|
+
}
|
|
1175
1259
|
const baseUrl = this.http.options.baseUrl;
|
|
1176
1260
|
const apiPrefix = this.http.options.apiPrefix || "";
|
|
1177
1261
|
const path = `/messaging/drafts/batch/stream?${queryParams.toString()}`;
|
|
@@ -1237,6 +1321,11 @@ class MessagingResource {
|
|
|
1237
1321
|
const eventData = JSON.parse(line.slice(6));
|
|
1238
1322
|
const { event, data } = eventData;
|
|
1239
1323
|
switch (event) {
|
|
1324
|
+
case "job_started": {
|
|
1325
|
+
const jobData = toCamelCase(data);
|
|
1326
|
+
callbacks?.onJobStarted?.(jobData.jobId || "");
|
|
1327
|
+
break;
|
|
1328
|
+
}
|
|
1240
1329
|
case "progress": {
|
|
1241
1330
|
const progressData = toCamelCase(data);
|
|
1242
1331
|
callbacks?.onProgress?.(
|
|
@@ -1291,8 +1380,15 @@ class MessagingResource {
|
|
|
1291
1380
|
*
|
|
1292
1381
|
* This method yields events as they arrive, providing more control over event handling.
|
|
1293
1382
|
*
|
|
1383
|
+
* **Resilience features:**
|
|
1384
|
+
* - Job state is stored in Redis and survives client disconnects
|
|
1385
|
+
* - First event is `job_started` with job_id for reconnection
|
|
1386
|
+
* - Client can reconnect using `jobId` option to resume streaming
|
|
1387
|
+
*
|
|
1294
1388
|
* **Example:**
|
|
1295
1389
|
* ```typescript
|
|
1390
|
+
* let savedJobId: string | undefined;
|
|
1391
|
+
*
|
|
1296
1392
|
* for await (const event of client.messaging.createBatchDraftsStreamGenerator(
|
|
1297
1393
|
* 'user@example.com',
|
|
1298
1394
|
* {
|
|
@@ -1302,6 +1398,9 @@ class MessagingResource {
|
|
|
1302
1398
|
* }
|
|
1303
1399
|
* )) {
|
|
1304
1400
|
* switch (event.event) {
|
|
1401
|
+
* case 'job_started':
|
|
1402
|
+
* savedJobId = event.data.jobId; // Save for reconnection
|
|
1403
|
+
* break;
|
|
1305
1404
|
* case 'progress':
|
|
1306
1405
|
* console.log(`Progress: ${event.data.percentage}%`)
|
|
1307
1406
|
* break
|
|
@@ -1320,12 +1419,17 @@ class MessagingResource {
|
|
|
1320
1419
|
*
|
|
1321
1420
|
* @param userId - User ID or email
|
|
1322
1421
|
* @param request - Batch draft creation request
|
|
1422
|
+
* @param options - Optional parameters
|
|
1423
|
+
* @param options.jobId - Existing job ID to resume streaming (for reconnection)
|
|
1323
1424
|
* @yields Stream events with 'event' and 'data' keys
|
|
1324
1425
|
* @returns Final result with created drafts and error details
|
|
1325
1426
|
*/
|
|
1326
|
-
async *createBatchDraftsStreamGenerator(userId, request) {
|
|
1427
|
+
async *createBatchDraftsStreamGenerator(userId, request, options) {
|
|
1327
1428
|
const queryParams = new URLSearchParams();
|
|
1328
1429
|
queryParams.append("user_id", userId);
|
|
1430
|
+
if (options?.jobId) {
|
|
1431
|
+
queryParams.append("job_id", options.jobId);
|
|
1432
|
+
}
|
|
1329
1433
|
const baseUrl = this.http.options.baseUrl;
|
|
1330
1434
|
const apiPrefix = this.http.options.apiPrefix || "";
|
|
1331
1435
|
const path = `/messaging/drafts/batch/stream?${queryParams.toString()}`;
|
|
@@ -2680,6 +2784,13 @@ var SyncJobStatus = /* @__PURE__ */ ((SyncJobStatus2) => {
|
|
|
2680
2784
|
SyncJobStatus2["FAILED"] = "failed";
|
|
2681
2785
|
return SyncJobStatus2;
|
|
2682
2786
|
})(SyncJobStatus || {});
|
|
2787
|
+
var BatchJobStatus = /* @__PURE__ */ ((BatchJobStatus2) => {
|
|
2788
|
+
BatchJobStatus2["PENDING"] = "pending";
|
|
2789
|
+
BatchJobStatus2["IN_PROGRESS"] = "in_progress";
|
|
2790
|
+
BatchJobStatus2["COMPLETED"] = "completed";
|
|
2791
|
+
BatchJobStatus2["FAILED"] = "failed";
|
|
2792
|
+
return BatchJobStatus2;
|
|
2793
|
+
})(BatchJobStatus || {});
|
|
2683
2794
|
var QueueItemStatus = /* @__PURE__ */ ((QueueItemStatus2) => {
|
|
2684
2795
|
QueueItemStatus2["QUEUED"] = "queued";
|
|
2685
2796
|
QueueItemStatus2["PROCESSING"] = "processing";
|
|
@@ -2815,6 +2926,7 @@ function verifyWebhookSignature(payload, signature, secret) {
|
|
|
2815
2926
|
|
|
2816
2927
|
exports.ACTION_DELAYS = ACTION_DELAYS;
|
|
2817
2928
|
exports.AuthenticationError = AuthenticationError;
|
|
2929
|
+
exports.BatchJobStatus = BatchJobStatus;
|
|
2818
2930
|
exports.ChannelType = ChannelType;
|
|
2819
2931
|
exports.ConversationStatus = ConversationStatus;
|
|
2820
2932
|
exports.DraftStatus = DraftStatus;
|
package/dist/index.d.cts
CHANGED
|
@@ -1407,6 +1407,15 @@ declare enum SyncJobStatus {
|
|
|
1407
1407
|
COMPLETED = "completed",
|
|
1408
1408
|
FAILED = "failed"
|
|
1409
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Batch job status types (for batch draft jobs)
|
|
1412
|
+
*/
|
|
1413
|
+
declare enum BatchJobStatus {
|
|
1414
|
+
PENDING = "pending",
|
|
1415
|
+
IN_PROGRESS = "in_progress",
|
|
1416
|
+
COMPLETED = "completed",
|
|
1417
|
+
FAILED = "failed"
|
|
1418
|
+
}
|
|
1410
1419
|
/**
|
|
1411
1420
|
* Queue item status types
|
|
1412
1421
|
*/
|
|
@@ -1557,6 +1566,18 @@ interface ProspectInfo {
|
|
|
1557
1566
|
outreachMethod?: 'direct_message' | 'connection_request' | 'inmail' | 'email' | null;
|
|
1558
1567
|
/** Whether the user is already connected to this prospect on LinkedIn */
|
|
1559
1568
|
isConnected?: boolean | null;
|
|
1569
|
+
/**
|
|
1570
|
+
* Override batch-level usePriorContact setting for this prospect.
|
|
1571
|
+
* - `true`: Check for prior contact and include in AI context
|
|
1572
|
+
* - `false`: Don't check for prior contact
|
|
1573
|
+
* - `null`/`undefined`: Use batch-level setting
|
|
1574
|
+
*/
|
|
1575
|
+
usePriorContact?: boolean | null;
|
|
1576
|
+
/**
|
|
1577
|
+
* Override/extend batch-level aiContext for this prospect.
|
|
1578
|
+
* Merged with batch context (prospect keys take precedence).
|
|
1579
|
+
*/
|
|
1580
|
+
aiContext?: Record<string, any> | null;
|
|
1560
1581
|
}
|
|
1561
1582
|
/**
|
|
1562
1583
|
* Request to create batch drafts
|
|
@@ -1569,6 +1590,13 @@ interface BatchDraftRequest {
|
|
|
1569
1590
|
subjectTemplate?: string | null;
|
|
1570
1591
|
contentTemplate?: string | null;
|
|
1571
1592
|
useAiGeneration?: boolean;
|
|
1593
|
+
/**
|
|
1594
|
+
* If true and useAiGeneration=true, check for prior contact with each prospect
|
|
1595
|
+
* and include conversation history in AI context for more personalized messages.
|
|
1596
|
+
* Can be overridden per-prospect via ProspectInfo.usePriorContact.
|
|
1597
|
+
* @default true
|
|
1598
|
+
*/
|
|
1599
|
+
usePriorContact?: boolean;
|
|
1572
1600
|
aiContext?: Record<string, any> | null;
|
|
1573
1601
|
organizationId?: string | null;
|
|
1574
1602
|
}
|
|
@@ -1787,7 +1815,7 @@ interface DraftResponse {
|
|
|
1787
1815
|
subject?: string | null;
|
|
1788
1816
|
}
|
|
1789
1817
|
/**
|
|
1790
|
-
* Response from batch draft creation
|
|
1818
|
+
* Response from batch draft creation (legacy synchronous mode)
|
|
1791
1819
|
*/
|
|
1792
1820
|
interface BatchDraftResponse {
|
|
1793
1821
|
drafts: DraftResponse[];
|
|
@@ -1795,6 +1823,48 @@ interface BatchDraftResponse {
|
|
|
1795
1823
|
errors: number;
|
|
1796
1824
|
errorDetails?: Array<Record<string, any>> | null;
|
|
1797
1825
|
}
|
|
1826
|
+
/**
|
|
1827
|
+
* Response when batch draft job is queued (async mode, 202 response).
|
|
1828
|
+
* Poll GET /drafts/batch/jobs/{jobId} for progress and results.
|
|
1829
|
+
*/
|
|
1830
|
+
interface BatchDraftJobResponse {
|
|
1831
|
+
jobId: string;
|
|
1832
|
+
status: string;
|
|
1833
|
+
totalProspects: number;
|
|
1834
|
+
pollUrl: string;
|
|
1835
|
+
message?: string;
|
|
1836
|
+
}
|
|
1837
|
+
/**
|
|
1838
|
+
* Progress information for a batch job
|
|
1839
|
+
*/
|
|
1840
|
+
interface BatchDraftJobProgress {
|
|
1841
|
+
processed: number;
|
|
1842
|
+
total: number;
|
|
1843
|
+
percentage: number;
|
|
1844
|
+
draftsCreated: number;
|
|
1845
|
+
errors: number;
|
|
1846
|
+
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Response for GET /drafts/batch/jobs/{jobId} (polling endpoint)
|
|
1849
|
+
*/
|
|
1850
|
+
interface BatchDraftJobStatusResponse {
|
|
1851
|
+
jobId: string;
|
|
1852
|
+
status: string;
|
|
1853
|
+
progress: BatchDraftJobProgress;
|
|
1854
|
+
drafts: DraftResponse[];
|
|
1855
|
+
errors: Array<Record<string, any>>;
|
|
1856
|
+
createdAt: string;
|
|
1857
|
+
startedAt?: string | null;
|
|
1858
|
+
completedAt?: string | null;
|
|
1859
|
+
errorMessage?: string | null;
|
|
1860
|
+
}
|
|
1861
|
+
/**
|
|
1862
|
+
* Job started event data from streaming batch draft creation.
|
|
1863
|
+
* First event emitted, contains job_id for reconnection.
|
|
1864
|
+
*/
|
|
1865
|
+
interface BatchDraftJobStartedData {
|
|
1866
|
+
jobId: string;
|
|
1867
|
+
}
|
|
1798
1868
|
/**
|
|
1799
1869
|
* Progress event data from streaming batch draft creation
|
|
1800
1870
|
*/
|
|
@@ -1822,6 +1892,7 @@ interface BatchDraftErrorData {
|
|
|
1822
1892
|
* Complete event data from streaming batch draft creation
|
|
1823
1893
|
*/
|
|
1824
1894
|
interface BatchDraftCompleteData {
|
|
1895
|
+
jobId?: string;
|
|
1825
1896
|
created: number;
|
|
1826
1897
|
errors: number;
|
|
1827
1898
|
drafts: DraftResponse[];
|
|
@@ -1829,22 +1900,25 @@ interface BatchDraftCompleteData {
|
|
|
1829
1900
|
prospect: string;
|
|
1830
1901
|
error: string;
|
|
1831
1902
|
}>;
|
|
1903
|
+
errorMessage?: string | null;
|
|
1832
1904
|
}
|
|
1833
1905
|
/**
|
|
1834
1906
|
* Stream event types for batch draft creation
|
|
1835
1907
|
*/
|
|
1836
|
-
type BatchDraftStreamEventType = 'progress' | 'draft_created' | 'error' | 'complete';
|
|
1908
|
+
type BatchDraftStreamEventType = 'job_started' | 'progress' | 'draft_created' | 'error' | 'complete';
|
|
1837
1909
|
/**
|
|
1838
1910
|
* Stream event from batch draft creation
|
|
1839
1911
|
*/
|
|
1840
1912
|
interface BatchDraftStreamEvent {
|
|
1841
1913
|
event: BatchDraftStreamEventType;
|
|
1842
|
-
data: BatchDraftProgressData | BatchDraftCreatedData | BatchDraftErrorData | BatchDraftCompleteData;
|
|
1914
|
+
data: BatchDraftJobStartedData | BatchDraftProgressData | BatchDraftCreatedData | BatchDraftErrorData | BatchDraftCompleteData;
|
|
1843
1915
|
}
|
|
1844
1916
|
/**
|
|
1845
1917
|
* Callbacks for batch draft streaming
|
|
1846
1918
|
*/
|
|
1847
1919
|
interface BatchDraftStreamCallbacks {
|
|
1920
|
+
/** Callback when job starts, provides job_id for reconnection if disconnected */
|
|
1921
|
+
onJobStarted?: (jobId: string) => void;
|
|
1848
1922
|
/** Callback for progress updates */
|
|
1849
1923
|
onProgress?: (processed: number, total: number, percentage: number, prospectName: string) => void;
|
|
1850
1924
|
/** Callback when a draft is created */
|
|
@@ -2191,16 +2265,83 @@ declare class MessagingResource {
|
|
|
2191
2265
|
*/
|
|
2192
2266
|
getDraft(userId: string, draftId: string): Promise<DraftResponse>;
|
|
2193
2267
|
/**
|
|
2194
|
-
* Create drafts for multiple prospects with AI generation
|
|
2268
|
+
* Create drafts for multiple prospects with AI generation.
|
|
2269
|
+
*
|
|
2270
|
+
* **Default behavior (async):**
|
|
2271
|
+
* Returns immediately with a job_id (202 response). Poll `getBatchDraftJobStatus()`
|
|
2272
|
+
* for progress and results. The job continues processing in the background even
|
|
2273
|
+
* if the client disconnects.
|
|
2274
|
+
*
|
|
2275
|
+
* **Legacy behavior (sync):**
|
|
2276
|
+
* Set `wait: true` to block until completion. Not recommended for large batches
|
|
2277
|
+
* as the request may timeout.
|
|
2278
|
+
*
|
|
2279
|
+
* @param userId - User ID or email
|
|
2280
|
+
* @param request - Batch draft creation request
|
|
2281
|
+
* @param options - Optional parameters
|
|
2282
|
+
* @param options.wait - If true, wait for completion (legacy behavior)
|
|
2283
|
+
* @returns BatchDraftJobResponse (async) or BatchDraftResponse (sync with wait=true)
|
|
2284
|
+
*
|
|
2285
|
+
* @example
|
|
2286
|
+
* ```typescript
|
|
2287
|
+
* // Async (recommended) - returns immediately with job_id
|
|
2288
|
+
* const job = await client.messaging.createBatchDrafts(userId, request);
|
|
2289
|
+
* if ('jobId' in job) {
|
|
2290
|
+
* // Poll for status
|
|
2291
|
+
* const status = await client.messaging.getBatchDraftJobStatus(userId, job.jobId);
|
|
2292
|
+
* }
|
|
2293
|
+
*
|
|
2294
|
+
* // Sync (legacy) - blocks until complete
|
|
2295
|
+
* const result = await client.messaging.createBatchDrafts(userId, request, { wait: true });
|
|
2296
|
+
* console.log(result.drafts); // All drafts available immediately
|
|
2297
|
+
* ```
|
|
2195
2298
|
*/
|
|
2196
|
-
createBatchDrafts(userId: string, request: BatchDraftRequest
|
|
2299
|
+
createBatchDrafts(userId: string, request: BatchDraftRequest, options?: {
|
|
2300
|
+
wait?: boolean;
|
|
2301
|
+
}): Promise<BatchDraftJobResponse | BatchDraftResponse>;
|
|
2302
|
+
/**
|
|
2303
|
+
* Get status and results of a batch draft job.
|
|
2304
|
+
*
|
|
2305
|
+
* Poll this endpoint to track progress and retrieve results for batch draft jobs
|
|
2306
|
+
* created via `createBatchDrafts()`. Jobs are retained for 24 hours after creation.
|
|
2307
|
+
*
|
|
2308
|
+
* @param userId - User ID or email
|
|
2309
|
+
* @param jobId - The job ID returned from createBatchDrafts()
|
|
2310
|
+
* @returns BatchDraftJobStatusResponse with progress and results
|
|
2311
|
+
* @throws NotFoundError if job not found or expired
|
|
2312
|
+
*
|
|
2313
|
+
* @example
|
|
2314
|
+
* ```typescript
|
|
2315
|
+
* // Create job
|
|
2316
|
+
* const job = await client.messaging.createBatchDrafts(userId, request);
|
|
2317
|
+
* if ('jobId' in job) {
|
|
2318
|
+
* // Poll until complete
|
|
2319
|
+
* let status;
|
|
2320
|
+
* do {
|
|
2321
|
+
* await new Promise(r => setTimeout(r, 1000)); // Wait 1 second
|
|
2322
|
+
* status = await client.messaging.getBatchDraftJobStatus(userId, job.jobId);
|
|
2323
|
+
* console.log(`Progress: ${status.progress.percentage}%`);
|
|
2324
|
+
* } while (status.status !== 'completed' && status.status !== 'failed');
|
|
2325
|
+
*
|
|
2326
|
+
* console.log(`Created ${status.drafts.length} drafts`);
|
|
2327
|
+
* }
|
|
2328
|
+
* ```
|
|
2329
|
+
*/
|
|
2330
|
+
getBatchDraftJobStatus(userId: string, jobId: string): Promise<BatchDraftJobStatusResponse>;
|
|
2197
2331
|
/**
|
|
2198
2332
|
* Create drafts for multiple prospects with real-time progress updates via Server-Sent Events (SSE).
|
|
2199
2333
|
*
|
|
2200
2334
|
* This method provides real-time progress updates as drafts are being created, significantly
|
|
2201
2335
|
* improving user experience for large batch operations (30+ prospects).
|
|
2202
2336
|
*
|
|
2337
|
+
* **Resilience features:**
|
|
2338
|
+
* - Job state is stored in Redis and survives client disconnects
|
|
2339
|
+
* - Background task continues processing even if SSE connection drops
|
|
2340
|
+
* - Client can reconnect using `jobId` option to resume streaming
|
|
2341
|
+
* - Poll `getBatchDraftJobStatus()` as fallback
|
|
2342
|
+
*
|
|
2203
2343
|
* **Event Types:**
|
|
2344
|
+
* - `job_started`: First event with job_id for reconnection
|
|
2204
2345
|
* - `progress`: Progress update with percentage and current prospect
|
|
2205
2346
|
* - `draft_created`: Draft successfully created
|
|
2206
2347
|
* - `error`: Error occurred for a specific prospect
|
|
@@ -2208,6 +2349,8 @@ declare class MessagingResource {
|
|
|
2208
2349
|
*
|
|
2209
2350
|
* **Example:**
|
|
2210
2351
|
* ```typescript
|
|
2352
|
+
* let savedJobId: string | undefined;
|
|
2353
|
+
*
|
|
2211
2354
|
* const result = await client.messaging.createBatchDraftsStream(
|
|
2212
2355
|
* 'user@example.com',
|
|
2213
2356
|
* {
|
|
@@ -2216,6 +2359,9 @@ declare class MessagingResource {
|
|
|
2216
2359
|
* useAiGeneration: true
|
|
2217
2360
|
* },
|
|
2218
2361
|
* {
|
|
2362
|
+
* onJobStarted: (jobId) => {
|
|
2363
|
+
* savedJobId = jobId; // Save for reconnection if disconnected
|
|
2364
|
+
* },
|
|
2219
2365
|
* onProgress: (processed, total, percentage, prospectName) => {
|
|
2220
2366
|
* console.log(`${percentage}% - ${prospectName}`)
|
|
2221
2367
|
* },
|
|
@@ -2235,16 +2381,27 @@ declare class MessagingResource {
|
|
|
2235
2381
|
* @param userId - User ID or email
|
|
2236
2382
|
* @param request - Batch draft creation request
|
|
2237
2383
|
* @param callbacks - Optional callbacks for stream events
|
|
2384
|
+
* @param options - Optional parameters
|
|
2385
|
+
* @param options.jobId - Existing job ID to resume streaming (for reconnection)
|
|
2238
2386
|
* @returns Final result with created drafts and error details
|
|
2239
2387
|
*/
|
|
2240
|
-
createBatchDraftsStream(userId: string, request: BatchDraftRequest, callbacks?: BatchDraftStreamCallbacks
|
|
2388
|
+
createBatchDraftsStream(userId: string, request: BatchDraftRequest, callbacks?: BatchDraftStreamCallbacks, options?: {
|
|
2389
|
+
jobId?: string;
|
|
2390
|
+
}): Promise<BatchDraftResponse>;
|
|
2241
2391
|
/**
|
|
2242
2392
|
* Create drafts with streaming events as an async generator.
|
|
2243
2393
|
*
|
|
2244
2394
|
* This method yields events as they arrive, providing more control over event handling.
|
|
2245
2395
|
*
|
|
2396
|
+
* **Resilience features:**
|
|
2397
|
+
* - Job state is stored in Redis and survives client disconnects
|
|
2398
|
+
* - First event is `job_started` with job_id for reconnection
|
|
2399
|
+
* - Client can reconnect using `jobId` option to resume streaming
|
|
2400
|
+
*
|
|
2246
2401
|
* **Example:**
|
|
2247
2402
|
* ```typescript
|
|
2403
|
+
* let savedJobId: string | undefined;
|
|
2404
|
+
*
|
|
2248
2405
|
* for await (const event of client.messaging.createBatchDraftsStreamGenerator(
|
|
2249
2406
|
* 'user@example.com',
|
|
2250
2407
|
* {
|
|
@@ -2254,6 +2411,9 @@ declare class MessagingResource {
|
|
|
2254
2411
|
* }
|
|
2255
2412
|
* )) {
|
|
2256
2413
|
* switch (event.event) {
|
|
2414
|
+
* case 'job_started':
|
|
2415
|
+
* savedJobId = event.data.jobId; // Save for reconnection
|
|
2416
|
+
* break;
|
|
2257
2417
|
* case 'progress':
|
|
2258
2418
|
* console.log(`Progress: ${event.data.percentage}%`)
|
|
2259
2419
|
* break
|
|
@@ -2272,10 +2432,14 @@ declare class MessagingResource {
|
|
|
2272
2432
|
*
|
|
2273
2433
|
* @param userId - User ID or email
|
|
2274
2434
|
* @param request - Batch draft creation request
|
|
2435
|
+
* @param options - Optional parameters
|
|
2436
|
+
* @param options.jobId - Existing job ID to resume streaming (for reconnection)
|
|
2275
2437
|
* @yields Stream events with 'event' and 'data' keys
|
|
2276
2438
|
* @returns Final result with created drafts and error details
|
|
2277
2439
|
*/
|
|
2278
|
-
createBatchDraftsStreamGenerator(userId: string, request: BatchDraftRequest
|
|
2440
|
+
createBatchDraftsStreamGenerator(userId: string, request: BatchDraftRequest, options?: {
|
|
2441
|
+
jobId?: string;
|
|
2442
|
+
}): AsyncGenerator<BatchDraftStreamEvent, BatchDraftResponse>;
|
|
2279
2443
|
/**
|
|
2280
2444
|
* Approve and send a single draft
|
|
2281
2445
|
*/
|
|
@@ -2985,4 +3149,4 @@ declare class ProgressTracker {
|
|
|
2985
3149
|
*/
|
|
2986
3150
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
2987
3151
|
|
|
2988
|
-
export { ACTION_DELAYS, type AgentConfig, type ApiKeyMode, type ApiKeyModeRequest, type ApiKeyModeResponse, type ApiProvider, type AppEnabledResponse, type AppliedFilters, type AppsListResponse, type ArtifactObject, type ArtifactsListResponse, AuthenticationError, type BaseResource, type BatchCheckConnectionRequest, type BatchCheckPriorContactRequest, type BatchCheckPriorContactResponse, type BatchConnectionRequest, type BatchConnectionResponse, type BatchConnectionStatus, type BatchConnectionStatusResponse, type BatchDraftCompleteData, type BatchDraftCreatedData, type BatchDraftErrorData, type BatchDraftProgressData, type BatchDraftRequest, type BatchDraftResponse, type BatchDraftStreamCallbacks, type BatchDraftStreamEvent, type BatchDraftStreamEventType, type BatchProspectIdentifier, type BatchSendRequest, type BatchSendResponse, type BillingStatus, type BulkDeleteRequest, type BulkDeleteResponse, type BulkUploadResponse, type CancelResponseResponse, type ChannelContactHistory, ChannelType, type CheckAppEnabledParams, type CheckLinkedInConnectionRequest, type CheckPriorContactRequest, type CheckPriorContactResponse, type ChunkingStrategy, type ConnectionAcceptedData, type ConnectionCallbackRequest, type ConnectionCallbackResponse, type ConnectionInfo, type ConnectionStatus, type ConnectionStatusResponse, type ConnectionSummary, type ContentType, type ConversationDetail, ConversationStatus, type ConversationSummary, type CreateDraftRequest, type CreateFeedbackRequest, type CreateFeedbackResponse, type CreateResponseRequest, type CreateResponseResponse, type CreateThreadRequest, type DatabaseStatus, type DeleteApiKeyResponse, type DeleteConversationResponse, type DeleteConversationsByProjectResponse, type DisconnectRequest, type DisconnectResponse, type DraftResponse, DraftStatus, type DuplicateHandling, type Email, type EmailThreadSummary, type ErrorResponse, ExternalAPIKeysResource, type ExternalApiKeyResponse, type FeedbackListResponse, type FeedbackObject, type FeedbackType, type FileAttachment, type FileChunk, type FileContentResponse, type FileListResponse, type FileMetadata, type FileScope, type FileScopeUpdateRequest, type FileSearchRequest, type FileSearchResponse, type FileSearchResult, type FileStatisticsResponse, type FileUploadResponse, FilesResource, type FilterLogic, type FilterValue, type GetConnectionStatusParams, type GetToolsRequest, type GetToolsResponse, type GetUserConnectionsParams, type InitiateConnectionRequest, type InitiateConnectionResponse, IntegrationsResource, InternalServerError, LINKEDIN_LIMITS, type LinkedInAccountInfoResponse, type LinkedInConnectionStatus, type LinkedInCreditsResponse, type LinkedInLimitSubscriptionType, type LinkedInLimits, type LinkedInSendRequest, type LinkedInSubscriptionInfo, LinkedInSubscriptionType, type ListProvidersResponse, LocalFileNotSupportedError, LumnisClient, type LumnisClientOptions, LumnisError, type LumnisErrorOptions, type MCPScope, type MCPServerCreateRequest, type MCPServerListResponse, type MCPServerResponse, type MCPServerUpdateRequest, MCPServersResource, type MCPToolListResponse, type MCPToolResponse, type MCPTransport, type Message, type MessageReceivedData, type MessageResponse, type MessageSentData, MessageType, MessagingAPIError, MessagingConnectionError, MessagingNotFoundError, MessagingResource, MessagingSendError, MessagingValidationError, type ModelAvailability, type ModelOverrides, type ModelPreferenceCreate, type ModelPreferencesBulkUpdate, ModelPreferencesResource, type ModelProvider, type ModelType, NetworkDistance, NoDataSourcesError, NotFoundError, OutreachMethod, type PaginationInfo, type PaginationParams, PeopleDataSource, PeopleResource, type PeopleSearchRequest, type PeopleSearchResponse, type PersonResult, type Plan, type PriorContactMessage, type ProcessingStatus, type ProcessingStatusResponse, type ProgressEntry, ProgressTracker, type ProspectConnectionCheck, type ProspectInfo, type ProspectPriorContactResult, type ProspectSyncIdentifier, type ProspectSyncResult, ProviderType, QueueItemStatus, type QuickPeopleSearchOutput, RATE_LIMIT_COOLDOWNS, RateLimitError, type RateLimitErrorOptions, type ResponseArtifact, type ResponseListResponse, type ResponseObject, type ResponseStatus, ResponsesResource, type SalaryRange, type Scope, type SelectedSkill, type SendMessageRequest, type SendMessageResponse, type SendReplyRequest, type SendResult, type SkillAnalyticsRequest, type SkillEffectivenessMetrics, type SkillGuidelineBase, type SkillGuidelineCreate, type SkillGuidelineListResponse, type SkillGuidelineResponse, type SkillGuidelineUpdate, type SkillRetrievalMetadata, type SkillUsageBase, type SkillUsageCreate, type SkillUsageListResponse, type SkillUsageResponse, type SkillUsageUpdate, SkillsResource, SourcesNotAvailableError, type SpecializedAgentParams, type SpecializedAgentType, type StoreApiKeyRequest, type SyncJobResponse, SyncJobStatus, type SyncProspectRequest, type SyncProspectResponse, type SyncRequest, type SyncStats, type TenantDetailsResponse, TenantInfoResource, type TenantModelPreference, type TenantModelPreferencesResponse, type TestConnectionResponse, type ThreadListResponse, type ThreadObject, type ThreadResponsesParams, ThreadsResource, type ToolInfo, UNIPILE_RATE_LIMIT_ERRORS, UNIPILE_SAFE_LIMITS, type UUID, type UnlinkConversationsResponse, type UpdateAppStatusParams, type UpdateAppStatusResponse, type UpdateLinkedInSubscriptionRequest, type UpdateThreadRequest, type UserConnectionsResponse, type UserCreateRequest, type UserDeleteResponse, type UserIdentifier, type UserListResponse, type UserResponse, type UserUpdateRequest, UsersResource, ValidationError, type WebhookEvent, type WebhookPayload, canSendInmail, displayProgress, formatProgressEntry, getBestSubscriptionForAction, getConnectionRequestLimit, getInmailAllowance, getLimits, getMessageLimit, hasOpenProfileMessages, verifyWebhookSignature };
|
|
3152
|
+
export { ACTION_DELAYS, type AgentConfig, type ApiKeyMode, type ApiKeyModeRequest, type ApiKeyModeResponse, type ApiProvider, type AppEnabledResponse, type AppliedFilters, type AppsListResponse, type ArtifactObject, type ArtifactsListResponse, AuthenticationError, type BaseResource, type BatchCheckConnectionRequest, type BatchCheckPriorContactRequest, type BatchCheckPriorContactResponse, type BatchConnectionRequest, type BatchConnectionResponse, type BatchConnectionStatus, type BatchConnectionStatusResponse, type BatchDraftCompleteData, type BatchDraftCreatedData, type BatchDraftErrorData, type BatchDraftJobProgress, type BatchDraftJobResponse, type BatchDraftJobStartedData, type BatchDraftJobStatusResponse, type BatchDraftProgressData, type BatchDraftRequest, type BatchDraftResponse, type BatchDraftStreamCallbacks, type BatchDraftStreamEvent, type BatchDraftStreamEventType, BatchJobStatus, type BatchProspectIdentifier, type BatchSendRequest, type BatchSendResponse, type BillingStatus, type BulkDeleteRequest, type BulkDeleteResponse, type BulkUploadResponse, type CancelResponseResponse, type ChannelContactHistory, ChannelType, type CheckAppEnabledParams, type CheckLinkedInConnectionRequest, type CheckPriorContactRequest, type CheckPriorContactResponse, type ChunkingStrategy, type ConnectionAcceptedData, type ConnectionCallbackRequest, type ConnectionCallbackResponse, type ConnectionInfo, type ConnectionStatus, type ConnectionStatusResponse, type ConnectionSummary, type ContentType, type ConversationDetail, ConversationStatus, type ConversationSummary, type CreateDraftRequest, type CreateFeedbackRequest, type CreateFeedbackResponse, type CreateResponseRequest, type CreateResponseResponse, type CreateThreadRequest, type DatabaseStatus, type DeleteApiKeyResponse, type DeleteConversationResponse, type DeleteConversationsByProjectResponse, type DisconnectRequest, type DisconnectResponse, type DraftResponse, DraftStatus, type DuplicateHandling, type Email, type EmailThreadSummary, type ErrorResponse, ExternalAPIKeysResource, type ExternalApiKeyResponse, type FeedbackListResponse, type FeedbackObject, type FeedbackType, type FileAttachment, type FileChunk, type FileContentResponse, type FileListResponse, type FileMetadata, type FileScope, type FileScopeUpdateRequest, type FileSearchRequest, type FileSearchResponse, type FileSearchResult, type FileStatisticsResponse, type FileUploadResponse, FilesResource, type FilterLogic, type FilterValue, type GetConnectionStatusParams, type GetToolsRequest, type GetToolsResponse, type GetUserConnectionsParams, type InitiateConnectionRequest, type InitiateConnectionResponse, IntegrationsResource, InternalServerError, LINKEDIN_LIMITS, type LinkedInAccountInfoResponse, type LinkedInConnectionStatus, type LinkedInCreditsResponse, type LinkedInLimitSubscriptionType, type LinkedInLimits, type LinkedInSendRequest, type LinkedInSubscriptionInfo, LinkedInSubscriptionType, type ListProvidersResponse, LocalFileNotSupportedError, LumnisClient, type LumnisClientOptions, LumnisError, type LumnisErrorOptions, type MCPScope, type MCPServerCreateRequest, type MCPServerListResponse, type MCPServerResponse, type MCPServerUpdateRequest, MCPServersResource, type MCPToolListResponse, type MCPToolResponse, type MCPTransport, type Message, type MessageReceivedData, type MessageResponse, type MessageSentData, MessageType, MessagingAPIError, MessagingConnectionError, MessagingNotFoundError, MessagingResource, MessagingSendError, MessagingValidationError, type ModelAvailability, type ModelOverrides, type ModelPreferenceCreate, type ModelPreferencesBulkUpdate, ModelPreferencesResource, type ModelProvider, type ModelType, NetworkDistance, NoDataSourcesError, NotFoundError, OutreachMethod, type PaginationInfo, type PaginationParams, PeopleDataSource, PeopleResource, type PeopleSearchRequest, type PeopleSearchResponse, type PersonResult, type Plan, type PriorContactMessage, type ProcessingStatus, type ProcessingStatusResponse, type ProgressEntry, ProgressTracker, type ProspectConnectionCheck, type ProspectInfo, type ProspectPriorContactResult, type ProspectSyncIdentifier, type ProspectSyncResult, ProviderType, QueueItemStatus, type QuickPeopleSearchOutput, RATE_LIMIT_COOLDOWNS, RateLimitError, type RateLimitErrorOptions, type ResponseArtifact, type ResponseListResponse, type ResponseObject, type ResponseStatus, ResponsesResource, type SalaryRange, type Scope, type SelectedSkill, type SendMessageRequest, type SendMessageResponse, type SendReplyRequest, type SendResult, type SkillAnalyticsRequest, type SkillEffectivenessMetrics, type SkillGuidelineBase, type SkillGuidelineCreate, type SkillGuidelineListResponse, type SkillGuidelineResponse, type SkillGuidelineUpdate, type SkillRetrievalMetadata, type SkillUsageBase, type SkillUsageCreate, type SkillUsageListResponse, type SkillUsageResponse, type SkillUsageUpdate, SkillsResource, SourcesNotAvailableError, type SpecializedAgentParams, type SpecializedAgentType, type StoreApiKeyRequest, type SyncJobResponse, SyncJobStatus, type SyncProspectRequest, type SyncProspectResponse, type SyncRequest, type SyncStats, type TenantDetailsResponse, TenantInfoResource, type TenantModelPreference, type TenantModelPreferencesResponse, type TestConnectionResponse, type ThreadListResponse, type ThreadObject, type ThreadResponsesParams, ThreadsResource, type ToolInfo, UNIPILE_RATE_LIMIT_ERRORS, UNIPILE_SAFE_LIMITS, type UUID, type UnlinkConversationsResponse, type UpdateAppStatusParams, type UpdateAppStatusResponse, type UpdateLinkedInSubscriptionRequest, type UpdateThreadRequest, type UserConnectionsResponse, type UserCreateRequest, type UserDeleteResponse, type UserIdentifier, type UserListResponse, type UserResponse, type UserUpdateRequest, UsersResource, ValidationError, type WebhookEvent, type WebhookPayload, canSendInmail, displayProgress, formatProgressEntry, getBestSubscriptionForAction, getConnectionRequestLimit, getInmailAllowance, getLimits, getMessageLimit, hasOpenProfileMessages, verifyWebhookSignature };
|