lumnisai 0.1.13 → 0.1.15
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 +361 -41
- package/dist/index.d.cts +159 -1
- package/dist/index.d.mts +159 -1
- package/dist/index.d.ts +159 -1
- package/dist/index.mjs +361 -41
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -520,6 +520,42 @@ class MessagingConnectionError extends MessagingAPIError {
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
524
|
+
function isUUID(s) {
|
|
525
|
+
return UUID_PATTERN.test(s);
|
|
526
|
+
}
|
|
527
|
+
function toCamel(s) {
|
|
528
|
+
if (isUUID(s))
|
|
529
|
+
return s;
|
|
530
|
+
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
531
|
+
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
function toSnake(s) {
|
|
535
|
+
if (isUUID(s))
|
|
536
|
+
return s;
|
|
537
|
+
return s.replace(/[A-Z]/g, (letter, index) => {
|
|
538
|
+
return index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`;
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
function convertCase(obj, converter) {
|
|
542
|
+
if (Array.isArray(obj)) {
|
|
543
|
+
return obj.map((v) => convertCase(v, converter));
|
|
544
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
545
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
546
|
+
acc[converter(key)] = convertCase(obj[key], converter);
|
|
547
|
+
return acc;
|
|
548
|
+
}, {});
|
|
549
|
+
}
|
|
550
|
+
return obj;
|
|
551
|
+
}
|
|
552
|
+
function toCamelCase(obj) {
|
|
553
|
+
return convertCase(obj, toCamel);
|
|
554
|
+
}
|
|
555
|
+
function toSnakeCase(obj) {
|
|
556
|
+
return convertCase(obj, toSnake);
|
|
557
|
+
}
|
|
558
|
+
|
|
523
559
|
class MessagingResource {
|
|
524
560
|
constructor(http) {
|
|
525
561
|
this.http = http;
|
|
@@ -725,6 +761,34 @@ class MessagingResource {
|
|
|
725
761
|
request
|
|
726
762
|
);
|
|
727
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* Get a draft by ID.
|
|
766
|
+
*
|
|
767
|
+
* @param userId - User ID or email
|
|
768
|
+
* @param draftId - Draft UUID
|
|
769
|
+
* @returns Promise resolving to DraftResponse
|
|
770
|
+
* @throws MessagingNotFoundError if draft not found (404) or other API error
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* ```typescript
|
|
774
|
+
* const draft = await client.messaging.getDraft('user@example.com', 'draft-uuid');
|
|
775
|
+
* console.log(draft.content);
|
|
776
|
+
* ```
|
|
777
|
+
*/
|
|
778
|
+
async getDraft(userId, draftId) {
|
|
779
|
+
try {
|
|
780
|
+
const queryParams = new URLSearchParams();
|
|
781
|
+
queryParams.append("user_id", userId);
|
|
782
|
+
return await this.http.get(
|
|
783
|
+
`/messaging/drafts/${encodeURIComponent(draftId)}?${queryParams.toString()}`
|
|
784
|
+
);
|
|
785
|
+
} catch (error) {
|
|
786
|
+
if (error instanceof NotFoundError) {
|
|
787
|
+
throw new MessagingNotFoundError(`Draft not found: ${draftId}`);
|
|
788
|
+
}
|
|
789
|
+
throw error;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
728
792
|
/**
|
|
729
793
|
* Create drafts for multiple prospects with AI generation
|
|
730
794
|
*/
|
|
@@ -736,6 +800,293 @@ class MessagingResource {
|
|
|
736
800
|
request
|
|
737
801
|
);
|
|
738
802
|
}
|
|
803
|
+
/**
|
|
804
|
+
* Create drafts for multiple prospects with real-time progress updates via Server-Sent Events (SSE).
|
|
805
|
+
*
|
|
806
|
+
* This method provides real-time progress updates as drafts are being created, significantly
|
|
807
|
+
* improving user experience for large batch operations (30+ prospects).
|
|
808
|
+
*
|
|
809
|
+
* **Event Types:**
|
|
810
|
+
* - `progress`: Progress update with percentage and current prospect
|
|
811
|
+
* - `draft_created`: Draft successfully created
|
|
812
|
+
* - `error`: Error occurred for a specific prospect
|
|
813
|
+
* - `complete`: Batch processing completed
|
|
814
|
+
*
|
|
815
|
+
* **Example:**
|
|
816
|
+
* ```typescript
|
|
817
|
+
* const result = await client.messaging.createBatchDraftsStream(
|
|
818
|
+
* 'user@example.com',
|
|
819
|
+
* {
|
|
820
|
+
* prospects: [...],
|
|
821
|
+
* channel: 'linkedin',
|
|
822
|
+
* useAiGeneration: true
|
|
823
|
+
* },
|
|
824
|
+
* {
|
|
825
|
+
* onProgress: (processed, total, percentage, prospectName) => {
|
|
826
|
+
* console.log(`${percentage}% - ${prospectName}`)
|
|
827
|
+
* },
|
|
828
|
+
* onDraftCreated: (draft) => {
|
|
829
|
+
* console.log(`Draft created: ${draft.id}`)
|
|
830
|
+
* },
|
|
831
|
+
* onError: (prospect, error) => {
|
|
832
|
+
* console.error(`Error for ${prospect}: ${error}`)
|
|
833
|
+
* },
|
|
834
|
+
* onComplete: (result) => {
|
|
835
|
+
* console.log(`Complete! Created: ${result.created}, Errors: ${result.errors}`)
|
|
836
|
+
* }
|
|
837
|
+
* }
|
|
838
|
+
* )
|
|
839
|
+
* ```
|
|
840
|
+
*
|
|
841
|
+
* @param userId - User ID or email
|
|
842
|
+
* @param request - Batch draft creation request
|
|
843
|
+
* @param callbacks - Optional callbacks for stream events
|
|
844
|
+
* @returns Final result with created drafts and error details
|
|
845
|
+
*/
|
|
846
|
+
async createBatchDraftsStream(userId, request, callbacks) {
|
|
847
|
+
const queryParams = new URLSearchParams();
|
|
848
|
+
queryParams.append("user_id", userId);
|
|
849
|
+
const baseUrl = this.http.options.baseUrl;
|
|
850
|
+
const apiPrefix = this.http.options.apiPrefix || "";
|
|
851
|
+
const path = `/messaging/drafts/batch/stream?${queryParams.toString()}`;
|
|
852
|
+
const url = `${baseUrl}${apiPrefix}${path}`;
|
|
853
|
+
const headers = {
|
|
854
|
+
"Content-Type": "application/json",
|
|
855
|
+
"Accept": "text/event-stream",
|
|
856
|
+
...this.http.options.headers
|
|
857
|
+
};
|
|
858
|
+
const body = JSON.stringify(toSnakeCase(request));
|
|
859
|
+
const response = await fetch(url, {
|
|
860
|
+
method: "POST",
|
|
861
|
+
headers,
|
|
862
|
+
body
|
|
863
|
+
});
|
|
864
|
+
if (!response.ok) {
|
|
865
|
+
const requestId = response.headers.get("x-request-id");
|
|
866
|
+
const contentType = response.headers.get("content-type") || "";
|
|
867
|
+
let detail = { raw: await response.text() };
|
|
868
|
+
try {
|
|
869
|
+
if (contentType.includes("application/json"))
|
|
870
|
+
detail = JSON.parse(detail.raw);
|
|
871
|
+
} catch {
|
|
872
|
+
}
|
|
873
|
+
const errorMsg = detail?.error?.message || `Server error: ${response.status}`;
|
|
874
|
+
if (response.status === 401) {
|
|
875
|
+
throw new AuthenticationError("Invalid or missing API key", { requestId, statusCode: 401, details: detail });
|
|
876
|
+
}
|
|
877
|
+
if (response.status === 403) {
|
|
878
|
+
throw new AuthenticationError("Forbidden - insufficient permissions", { requestId, statusCode: 403, details: detail });
|
|
879
|
+
}
|
|
880
|
+
if (response.status === 404) {
|
|
881
|
+
throw new NotFoundError("Resource not found", { requestId, statusCode: 404, details: detail });
|
|
882
|
+
}
|
|
883
|
+
if (response.status === 429) {
|
|
884
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
885
|
+
throw new RateLimitError({ requestId, statusCode: 429, details: detail, retryAfter });
|
|
886
|
+
}
|
|
887
|
+
if (response.status >= 400 && response.status < 500) {
|
|
888
|
+
throw new ValidationError(errorMsg, { requestId, statusCode: response.status, details: detail });
|
|
889
|
+
}
|
|
890
|
+
throw new LumnisError(`Server error: ${response.status}`, { requestId, statusCode: response.status, details: detail });
|
|
891
|
+
}
|
|
892
|
+
const reader = response.body?.getReader();
|
|
893
|
+
if (!reader) {
|
|
894
|
+
throw new Error("Response body reader not available");
|
|
895
|
+
}
|
|
896
|
+
const decoder = new TextDecoder();
|
|
897
|
+
let buffer = "";
|
|
898
|
+
let finalResult = null;
|
|
899
|
+
try {
|
|
900
|
+
while (true) {
|
|
901
|
+
const { done, value } = await reader.read();
|
|
902
|
+
if (done)
|
|
903
|
+
break;
|
|
904
|
+
buffer += decoder.decode(value, { stream: true });
|
|
905
|
+
const lines = buffer.split("\n");
|
|
906
|
+
buffer = lines.pop() || "";
|
|
907
|
+
for (const line of lines) {
|
|
908
|
+
if (!line.startsWith("data: "))
|
|
909
|
+
continue;
|
|
910
|
+
try {
|
|
911
|
+
const eventData = JSON.parse(line.slice(6));
|
|
912
|
+
const { event, data } = eventData;
|
|
913
|
+
switch (event) {
|
|
914
|
+
case "progress": {
|
|
915
|
+
const progressData = toCamelCase(data);
|
|
916
|
+
callbacks?.onProgress?.(
|
|
917
|
+
progressData.processed || 0,
|
|
918
|
+
progressData.total || 0,
|
|
919
|
+
progressData.percentage || 0,
|
|
920
|
+
progressData.currentProspect || ""
|
|
921
|
+
);
|
|
922
|
+
break;
|
|
923
|
+
}
|
|
924
|
+
case "draft_created": {
|
|
925
|
+
const draftData = toCamelCase(data);
|
|
926
|
+
const draft = draftData.draft;
|
|
927
|
+
if (draft) {
|
|
928
|
+
const convertedDraft = toCamelCase(draft);
|
|
929
|
+
callbacks?.onDraftCreated?.(convertedDraft);
|
|
930
|
+
}
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
933
|
+
case "error": {
|
|
934
|
+
const errorData = toCamelCase(data);
|
|
935
|
+
callbacks?.onError?.(
|
|
936
|
+
errorData.prospect || "Unknown",
|
|
937
|
+
errorData.error || ""
|
|
938
|
+
);
|
|
939
|
+
break;
|
|
940
|
+
}
|
|
941
|
+
case "complete": {
|
|
942
|
+
const completeData = toCamelCase(data);
|
|
943
|
+
finalResult = {
|
|
944
|
+
created: completeData.created || 0,
|
|
945
|
+
errors: completeData.errors || 0,
|
|
946
|
+
drafts: (completeData.drafts || []).map((d) => toCamelCase(d)),
|
|
947
|
+
errorDetails: completeData.errorDetails || []
|
|
948
|
+
};
|
|
949
|
+
callbacks?.onComplete?.(finalResult);
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
} catch {
|
|
954
|
+
continue;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
} finally {
|
|
959
|
+
reader.releaseLock();
|
|
960
|
+
}
|
|
961
|
+
return finalResult || { created: 0, errors: 0, drafts: [], errorDetails: [] };
|
|
962
|
+
}
|
|
963
|
+
/**
|
|
964
|
+
* Create drafts with streaming events as an async generator.
|
|
965
|
+
*
|
|
966
|
+
* This method yields events as they arrive, providing more control over event handling.
|
|
967
|
+
*
|
|
968
|
+
* **Example:**
|
|
969
|
+
* ```typescript
|
|
970
|
+
* for await (const event of client.messaging.createBatchDraftsStreamGenerator(
|
|
971
|
+
* 'user@example.com',
|
|
972
|
+
* {
|
|
973
|
+
* prospects: [...],
|
|
974
|
+
* channel: 'linkedin',
|
|
975
|
+
* useAiGeneration: true
|
|
976
|
+
* }
|
|
977
|
+
* )) {
|
|
978
|
+
* switch (event.event) {
|
|
979
|
+
* case 'progress':
|
|
980
|
+
* console.log(`Progress: ${event.data.percentage}%`)
|
|
981
|
+
* break
|
|
982
|
+
* case 'draft_created':
|
|
983
|
+
* console.log(`Draft: ${event.data.draft.id}`)
|
|
984
|
+
* break
|
|
985
|
+
* case 'error':
|
|
986
|
+
* console.error(`Error: ${event.data.error}`)
|
|
987
|
+
* break
|
|
988
|
+
* case 'complete':
|
|
989
|
+
* console.log(`Done! ${event.data.created} drafts created`)
|
|
990
|
+
* break
|
|
991
|
+
* }
|
|
992
|
+
* }
|
|
993
|
+
* ```
|
|
994
|
+
*
|
|
995
|
+
* @param userId - User ID or email
|
|
996
|
+
* @param request - Batch draft creation request
|
|
997
|
+
* @yields Stream events with 'event' and 'data' keys
|
|
998
|
+
* @returns Final result with created drafts and error details
|
|
999
|
+
*/
|
|
1000
|
+
async *createBatchDraftsStreamGenerator(userId, request) {
|
|
1001
|
+
const queryParams = new URLSearchParams();
|
|
1002
|
+
queryParams.append("user_id", userId);
|
|
1003
|
+
const baseUrl = this.http.options.baseUrl;
|
|
1004
|
+
const apiPrefix = this.http.options.apiPrefix || "";
|
|
1005
|
+
const path = `/messaging/drafts/batch/stream?${queryParams.toString()}`;
|
|
1006
|
+
const url = `${baseUrl}${apiPrefix}${path}`;
|
|
1007
|
+
const headers = {
|
|
1008
|
+
"Content-Type": "application/json",
|
|
1009
|
+
"Accept": "text/event-stream",
|
|
1010
|
+
...this.http.options.headers
|
|
1011
|
+
};
|
|
1012
|
+
const body = JSON.stringify(toSnakeCase(request));
|
|
1013
|
+
const response = await fetch(url, {
|
|
1014
|
+
method: "POST",
|
|
1015
|
+
headers,
|
|
1016
|
+
body
|
|
1017
|
+
});
|
|
1018
|
+
if (!response.ok) {
|
|
1019
|
+
const requestId = response.headers.get("x-request-id");
|
|
1020
|
+
const contentType = response.headers.get("content-type") || "";
|
|
1021
|
+
let detail = { raw: await response.text() };
|
|
1022
|
+
try {
|
|
1023
|
+
if (contentType.includes("application/json"))
|
|
1024
|
+
detail = JSON.parse(detail.raw);
|
|
1025
|
+
} catch {
|
|
1026
|
+
}
|
|
1027
|
+
const errorMsg = detail?.error?.message || `Server error: ${response.status}`;
|
|
1028
|
+
if (response.status === 401) {
|
|
1029
|
+
throw new AuthenticationError("Invalid or missing API key", { requestId, statusCode: 401, details: detail });
|
|
1030
|
+
}
|
|
1031
|
+
if (response.status === 403) {
|
|
1032
|
+
throw new AuthenticationError("Forbidden - insufficient permissions", { requestId, statusCode: 403, details: detail });
|
|
1033
|
+
}
|
|
1034
|
+
if (response.status === 404) {
|
|
1035
|
+
throw new NotFoundError("Resource not found", { requestId, statusCode: 404, details: detail });
|
|
1036
|
+
}
|
|
1037
|
+
if (response.status === 429) {
|
|
1038
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
1039
|
+
throw new RateLimitError({ requestId, statusCode: 429, details: detail, retryAfter });
|
|
1040
|
+
}
|
|
1041
|
+
if (response.status >= 400 && response.status < 500) {
|
|
1042
|
+
throw new ValidationError(errorMsg, { requestId, statusCode: response.status, details: detail });
|
|
1043
|
+
}
|
|
1044
|
+
throw new LumnisError(`Server error: ${response.status}`, { requestId, statusCode: response.status, details: detail });
|
|
1045
|
+
}
|
|
1046
|
+
const reader = response.body?.getReader();
|
|
1047
|
+
if (!reader) {
|
|
1048
|
+
throw new Error("Response body reader not available");
|
|
1049
|
+
}
|
|
1050
|
+
const decoder = new TextDecoder();
|
|
1051
|
+
let buffer = "";
|
|
1052
|
+
let finalResult = null;
|
|
1053
|
+
try {
|
|
1054
|
+
while (true) {
|
|
1055
|
+
const { done, value } = await reader.read();
|
|
1056
|
+
if (done)
|
|
1057
|
+
break;
|
|
1058
|
+
buffer += decoder.decode(value, { stream: true });
|
|
1059
|
+
const lines = buffer.split("\n");
|
|
1060
|
+
buffer = lines.pop() || "";
|
|
1061
|
+
for (const line of lines) {
|
|
1062
|
+
if (!line.startsWith("data: "))
|
|
1063
|
+
continue;
|
|
1064
|
+
try {
|
|
1065
|
+
const eventData = JSON.parse(line.slice(6));
|
|
1066
|
+
const camelEventData = {
|
|
1067
|
+
event: eventData.event,
|
|
1068
|
+
data: toCamelCase(eventData.data)
|
|
1069
|
+
};
|
|
1070
|
+
yield camelEventData;
|
|
1071
|
+
if (eventData.event === "complete") {
|
|
1072
|
+
const completeData = camelEventData.data;
|
|
1073
|
+
finalResult = {
|
|
1074
|
+
created: completeData.created || 0,
|
|
1075
|
+
errors: completeData.errors || 0,
|
|
1076
|
+
drafts: (completeData.drafts || []).map((d) => toCamelCase(d)),
|
|
1077
|
+
errorDetails: completeData.errorDetails || []
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
} catch {
|
|
1081
|
+
continue;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
} finally {
|
|
1086
|
+
reader.releaseLock();
|
|
1087
|
+
}
|
|
1088
|
+
return finalResult || { created: 0, errors: 0, drafts: [], errorDetails: [] };
|
|
1089
|
+
}
|
|
739
1090
|
/**
|
|
740
1091
|
* Approve and send a single draft
|
|
741
1092
|
*/
|
|
@@ -872,10 +1223,14 @@ class MessagingResource {
|
|
|
872
1223
|
const queryParams = new URLSearchParams();
|
|
873
1224
|
queryParams.append("user_id", userId);
|
|
874
1225
|
const payload = {};
|
|
875
|
-
if (request.email)
|
|
876
|
-
|
|
877
|
-
if (request.
|
|
878
|
-
|
|
1226
|
+
if (request.email)
|
|
1227
|
+
payload.email = request.email;
|
|
1228
|
+
if (request.linkedinUrl)
|
|
1229
|
+
payload.linkedin_url = request.linkedinUrl;
|
|
1230
|
+
if (request.providerId)
|
|
1231
|
+
payload.provider_id = request.providerId;
|
|
1232
|
+
if (request.channels)
|
|
1233
|
+
payload.channels = request.channels;
|
|
879
1234
|
if (request.messageLimit !== void 0 && request.messageLimit !== null) {
|
|
880
1235
|
payload.message_limit = request.messageLimit;
|
|
881
1236
|
}
|
|
@@ -943,7 +1298,8 @@ class MessagingResource {
|
|
|
943
1298
|
provider_id: p.providerId || void 0
|
|
944
1299
|
}))
|
|
945
1300
|
};
|
|
946
|
-
if (request.channels)
|
|
1301
|
+
if (request.channels)
|
|
1302
|
+
payload.channels = request.channels;
|
|
947
1303
|
if (request.messageLimit !== void 0 && request.messageLimit !== null) {
|
|
948
1304
|
payload.message_limit = request.messageLimit;
|
|
949
1305
|
}
|
|
@@ -1464,42 +1820,6 @@ class UsersResource {
|
|
|
1464
1820
|
}
|
|
1465
1821
|
}
|
|
1466
1822
|
|
|
1467
|
-
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1468
|
-
function isUUID(s) {
|
|
1469
|
-
return UUID_PATTERN.test(s);
|
|
1470
|
-
}
|
|
1471
|
-
function toCamel(s) {
|
|
1472
|
-
if (isUUID(s))
|
|
1473
|
-
return s;
|
|
1474
|
-
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
1475
|
-
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
function toSnake(s) {
|
|
1479
|
-
if (isUUID(s))
|
|
1480
|
-
return s;
|
|
1481
|
-
return s.replace(/[A-Z]/g, (letter, index) => {
|
|
1482
|
-
return index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`;
|
|
1483
|
-
});
|
|
1484
|
-
}
|
|
1485
|
-
function convertCase(obj, converter) {
|
|
1486
|
-
if (Array.isArray(obj)) {
|
|
1487
|
-
return obj.map((v) => convertCase(v, converter));
|
|
1488
|
-
} else if (obj !== null && typeof obj === "object") {
|
|
1489
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
1490
|
-
acc[converter(key)] = convertCase(obj[key], converter);
|
|
1491
|
-
return acc;
|
|
1492
|
-
}, {});
|
|
1493
|
-
}
|
|
1494
|
-
return obj;
|
|
1495
|
-
}
|
|
1496
|
-
function toCamelCase(obj) {
|
|
1497
|
-
return convertCase(obj, toCamel);
|
|
1498
|
-
}
|
|
1499
|
-
function toSnakeCase(obj) {
|
|
1500
|
-
return convertCase(obj, toSnake);
|
|
1501
|
-
}
|
|
1502
|
-
|
|
1503
1823
|
class Http {
|
|
1504
1824
|
options;
|
|
1505
1825
|
constructor(options) {
|
package/dist/index.d.cts
CHANGED
|
@@ -1588,6 +1588,8 @@ interface DraftResponse {
|
|
|
1588
1588
|
conversationId?: string | null;
|
|
1589
1589
|
/** Outreach method used for this draft: 'connection_request' | 'direct_message' | 'inmail' | 'email' */
|
|
1590
1590
|
outreachMethod?: 'direct_message' | 'connection_request' | 'inmail' | 'email' | null;
|
|
1591
|
+
/** Subject line for email drafts (optional) */
|
|
1592
|
+
subject?: string | null;
|
|
1591
1593
|
}
|
|
1592
1594
|
/**
|
|
1593
1595
|
* Response from batch draft creation
|
|
@@ -1598,6 +1600,65 @@ interface BatchDraftResponse {
|
|
|
1598
1600
|
errors: number;
|
|
1599
1601
|
errorDetails?: Array<Record<string, any>> | null;
|
|
1600
1602
|
}
|
|
1603
|
+
/**
|
|
1604
|
+
* Progress event data from streaming batch draft creation
|
|
1605
|
+
*/
|
|
1606
|
+
interface BatchDraftProgressData {
|
|
1607
|
+
processed: number;
|
|
1608
|
+
total: number;
|
|
1609
|
+
percentage: number;
|
|
1610
|
+
currentProspect: string;
|
|
1611
|
+
}
|
|
1612
|
+
/**
|
|
1613
|
+
* Draft created event data from streaming batch draft creation
|
|
1614
|
+
*/
|
|
1615
|
+
interface BatchDraftCreatedData {
|
|
1616
|
+
draft: DraftResponse;
|
|
1617
|
+
prospectExternalId?: string | null;
|
|
1618
|
+
}
|
|
1619
|
+
/**
|
|
1620
|
+
* Error event data from streaming batch draft creation
|
|
1621
|
+
*/
|
|
1622
|
+
interface BatchDraftErrorData {
|
|
1623
|
+
prospect: string;
|
|
1624
|
+
error: string;
|
|
1625
|
+
}
|
|
1626
|
+
/**
|
|
1627
|
+
* Complete event data from streaming batch draft creation
|
|
1628
|
+
*/
|
|
1629
|
+
interface BatchDraftCompleteData {
|
|
1630
|
+
created: number;
|
|
1631
|
+
errors: number;
|
|
1632
|
+
drafts: DraftResponse[];
|
|
1633
|
+
errorDetails: Array<{
|
|
1634
|
+
prospect: string;
|
|
1635
|
+
error: string;
|
|
1636
|
+
}>;
|
|
1637
|
+
}
|
|
1638
|
+
/**
|
|
1639
|
+
* Stream event types for batch draft creation
|
|
1640
|
+
*/
|
|
1641
|
+
type BatchDraftStreamEventType = 'progress' | 'draft_created' | 'error' | 'complete';
|
|
1642
|
+
/**
|
|
1643
|
+
* Stream event from batch draft creation
|
|
1644
|
+
*/
|
|
1645
|
+
interface BatchDraftStreamEvent {
|
|
1646
|
+
event: BatchDraftStreamEventType;
|
|
1647
|
+
data: BatchDraftProgressData | BatchDraftCreatedData | BatchDraftErrorData | BatchDraftCompleteData;
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Callbacks for batch draft streaming
|
|
1651
|
+
*/
|
|
1652
|
+
interface BatchDraftStreamCallbacks {
|
|
1653
|
+
/** Callback for progress updates */
|
|
1654
|
+
onProgress?: (processed: number, total: number, percentage: number, prospectName: string) => void;
|
|
1655
|
+
/** Callback when a draft is created */
|
|
1656
|
+
onDraftCreated?: (draft: DraftResponse) => void;
|
|
1657
|
+
/** Callback when an error occurs for a prospect */
|
|
1658
|
+
onError?: (prospect: string, error: string) => void;
|
|
1659
|
+
/** Callback when batch processing completes */
|
|
1660
|
+
onComplete?: (result: BatchDraftResponse) => void;
|
|
1661
|
+
}
|
|
1601
1662
|
/**
|
|
1602
1663
|
* Send result (returned by reply, linkedin/send, drafts endpoints)
|
|
1603
1664
|
*/
|
|
@@ -1860,10 +1921,107 @@ declare class MessagingResource {
|
|
|
1860
1921
|
* Create a single draft message
|
|
1861
1922
|
*/
|
|
1862
1923
|
createDraft(userId: string, request: CreateDraftRequest): Promise<DraftResponse>;
|
|
1924
|
+
/**
|
|
1925
|
+
* Get a draft by ID.
|
|
1926
|
+
*
|
|
1927
|
+
* @param userId - User ID or email
|
|
1928
|
+
* @param draftId - Draft UUID
|
|
1929
|
+
* @returns Promise resolving to DraftResponse
|
|
1930
|
+
* @throws MessagingNotFoundError if draft not found (404) or other API error
|
|
1931
|
+
*
|
|
1932
|
+
* @example
|
|
1933
|
+
* ```typescript
|
|
1934
|
+
* const draft = await client.messaging.getDraft('user@example.com', 'draft-uuid');
|
|
1935
|
+
* console.log(draft.content);
|
|
1936
|
+
* ```
|
|
1937
|
+
*/
|
|
1938
|
+
getDraft(userId: string, draftId: string): Promise<DraftResponse>;
|
|
1863
1939
|
/**
|
|
1864
1940
|
* Create drafts for multiple prospects with AI generation
|
|
1865
1941
|
*/
|
|
1866
1942
|
createBatchDrafts(userId: string, request: BatchDraftRequest): Promise<BatchDraftResponse>;
|
|
1943
|
+
/**
|
|
1944
|
+
* Create drafts for multiple prospects with real-time progress updates via Server-Sent Events (SSE).
|
|
1945
|
+
*
|
|
1946
|
+
* This method provides real-time progress updates as drafts are being created, significantly
|
|
1947
|
+
* improving user experience for large batch operations (30+ prospects).
|
|
1948
|
+
*
|
|
1949
|
+
* **Event Types:**
|
|
1950
|
+
* - `progress`: Progress update with percentage and current prospect
|
|
1951
|
+
* - `draft_created`: Draft successfully created
|
|
1952
|
+
* - `error`: Error occurred for a specific prospect
|
|
1953
|
+
* - `complete`: Batch processing completed
|
|
1954
|
+
*
|
|
1955
|
+
* **Example:**
|
|
1956
|
+
* ```typescript
|
|
1957
|
+
* const result = await client.messaging.createBatchDraftsStream(
|
|
1958
|
+
* 'user@example.com',
|
|
1959
|
+
* {
|
|
1960
|
+
* prospects: [...],
|
|
1961
|
+
* channel: 'linkedin',
|
|
1962
|
+
* useAiGeneration: true
|
|
1963
|
+
* },
|
|
1964
|
+
* {
|
|
1965
|
+
* onProgress: (processed, total, percentage, prospectName) => {
|
|
1966
|
+
* console.log(`${percentage}% - ${prospectName}`)
|
|
1967
|
+
* },
|
|
1968
|
+
* onDraftCreated: (draft) => {
|
|
1969
|
+
* console.log(`Draft created: ${draft.id}`)
|
|
1970
|
+
* },
|
|
1971
|
+
* onError: (prospect, error) => {
|
|
1972
|
+
* console.error(`Error for ${prospect}: ${error}`)
|
|
1973
|
+
* },
|
|
1974
|
+
* onComplete: (result) => {
|
|
1975
|
+
* console.log(`Complete! Created: ${result.created}, Errors: ${result.errors}`)
|
|
1976
|
+
* }
|
|
1977
|
+
* }
|
|
1978
|
+
* )
|
|
1979
|
+
* ```
|
|
1980
|
+
*
|
|
1981
|
+
* @param userId - User ID or email
|
|
1982
|
+
* @param request - Batch draft creation request
|
|
1983
|
+
* @param callbacks - Optional callbacks for stream events
|
|
1984
|
+
* @returns Final result with created drafts and error details
|
|
1985
|
+
*/
|
|
1986
|
+
createBatchDraftsStream(userId: string, request: BatchDraftRequest, callbacks?: BatchDraftStreamCallbacks): Promise<BatchDraftResponse>;
|
|
1987
|
+
/**
|
|
1988
|
+
* Create drafts with streaming events as an async generator.
|
|
1989
|
+
*
|
|
1990
|
+
* This method yields events as they arrive, providing more control over event handling.
|
|
1991
|
+
*
|
|
1992
|
+
* **Example:**
|
|
1993
|
+
* ```typescript
|
|
1994
|
+
* for await (const event of client.messaging.createBatchDraftsStreamGenerator(
|
|
1995
|
+
* 'user@example.com',
|
|
1996
|
+
* {
|
|
1997
|
+
* prospects: [...],
|
|
1998
|
+
* channel: 'linkedin',
|
|
1999
|
+
* useAiGeneration: true
|
|
2000
|
+
* }
|
|
2001
|
+
* )) {
|
|
2002
|
+
* switch (event.event) {
|
|
2003
|
+
* case 'progress':
|
|
2004
|
+
* console.log(`Progress: ${event.data.percentage}%`)
|
|
2005
|
+
* break
|
|
2006
|
+
* case 'draft_created':
|
|
2007
|
+
* console.log(`Draft: ${event.data.draft.id}`)
|
|
2008
|
+
* break
|
|
2009
|
+
* case 'error':
|
|
2010
|
+
* console.error(`Error: ${event.data.error}`)
|
|
2011
|
+
* break
|
|
2012
|
+
* case 'complete':
|
|
2013
|
+
* console.log(`Done! ${event.data.created} drafts created`)
|
|
2014
|
+
* break
|
|
2015
|
+
* }
|
|
2016
|
+
* }
|
|
2017
|
+
* ```
|
|
2018
|
+
*
|
|
2019
|
+
* @param userId - User ID or email
|
|
2020
|
+
* @param request - Batch draft creation request
|
|
2021
|
+
* @yields Stream events with 'event' and 'data' keys
|
|
2022
|
+
* @returns Final result with created drafts and error details
|
|
2023
|
+
*/
|
|
2024
|
+
createBatchDraftsStreamGenerator(userId: string, request: BatchDraftRequest): AsyncGenerator<BatchDraftStreamEvent, BatchDraftResponse>;
|
|
1867
2025
|
/**
|
|
1868
2026
|
* Approve and send a single draft
|
|
1869
2027
|
*/
|
|
@@ -2574,4 +2732,4 @@ declare class ProgressTracker {
|
|
|
2574
2732
|
declare function verifyWebhookSignature(payload: string, signature: string, secret: string): boolean;
|
|
2575
2733
|
|
|
2576
2734
|
export = LumnisClient;
|
|
2577
|
-
export { 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 BatchDraftRequest, type BatchDraftResponse, 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, type LinkedInConnectionStatus, type LinkedInCreditsResponse, type LinkedInSendRequest, 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, 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, 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, displayProgress, formatProgressEntry, verifyWebhookSignature };
|
|
2735
|
+
export { 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, type LinkedInConnectionStatus, type LinkedInCreditsResponse, type LinkedInSendRequest, 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, 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, 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, displayProgress, formatProgressEntry, verifyWebhookSignature };
|