lumnisai 0.1.14 → 0.1.16
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 +76 -43
- package/dist/index.d.cts +33 -3
- package/dist/index.d.mts +33 -3
- package/dist/index.d.ts +33 -3
- package/dist/index.mjs +76 -43
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -416,42 +416,6 @@ class MCPServersResource {
|
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
|
|
419
|
-
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
420
|
-
function isUUID(s) {
|
|
421
|
-
return UUID_PATTERN.test(s);
|
|
422
|
-
}
|
|
423
|
-
function toCamel(s) {
|
|
424
|
-
if (isUUID(s))
|
|
425
|
-
return s;
|
|
426
|
-
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
427
|
-
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
428
|
-
});
|
|
429
|
-
}
|
|
430
|
-
function toSnake(s) {
|
|
431
|
-
if (isUUID(s))
|
|
432
|
-
return s;
|
|
433
|
-
return s.replace(/[A-Z]/g, (letter, index) => {
|
|
434
|
-
return index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`;
|
|
435
|
-
});
|
|
436
|
-
}
|
|
437
|
-
function convertCase(obj, converter) {
|
|
438
|
-
if (Array.isArray(obj)) {
|
|
439
|
-
return obj.map((v) => convertCase(v, converter));
|
|
440
|
-
} else if (obj !== null && typeof obj === "object") {
|
|
441
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
442
|
-
acc[converter(key)] = convertCase(obj[key], converter);
|
|
443
|
-
return acc;
|
|
444
|
-
}, {});
|
|
445
|
-
}
|
|
446
|
-
return obj;
|
|
447
|
-
}
|
|
448
|
-
function toCamelCase(obj) {
|
|
449
|
-
return convertCase(obj, toCamel);
|
|
450
|
-
}
|
|
451
|
-
function toSnakeCase(obj) {
|
|
452
|
-
return convertCase(obj, toSnake);
|
|
453
|
-
}
|
|
454
|
-
|
|
455
419
|
class LumnisError extends Error {
|
|
456
420
|
code;
|
|
457
421
|
statusCode;
|
|
@@ -556,6 +520,42 @@ class MessagingConnectionError extends MessagingAPIError {
|
|
|
556
520
|
}
|
|
557
521
|
}
|
|
558
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
|
+
|
|
559
559
|
class MessagingResource {
|
|
560
560
|
constructor(http) {
|
|
561
561
|
this.http = http;
|
|
@@ -761,6 +761,34 @@ class MessagingResource {
|
|
|
761
761
|
request
|
|
762
762
|
);
|
|
763
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
|
+
}
|
|
764
792
|
/**
|
|
765
793
|
* Create drafts for multiple prospects with AI generation
|
|
766
794
|
*/
|
|
@@ -922,7 +950,7 @@ class MessagingResource {
|
|
|
922
950
|
break;
|
|
923
951
|
}
|
|
924
952
|
}
|
|
925
|
-
} catch
|
|
953
|
+
} catch {
|
|
926
954
|
continue;
|
|
927
955
|
}
|
|
928
956
|
}
|
|
@@ -1049,7 +1077,7 @@ class MessagingResource {
|
|
|
1049
1077
|
errorDetails: completeData.errorDetails || []
|
|
1050
1078
|
};
|
|
1051
1079
|
}
|
|
1052
|
-
} catch
|
|
1080
|
+
} catch {
|
|
1053
1081
|
continue;
|
|
1054
1082
|
}
|
|
1055
1083
|
}
|
|
@@ -1195,10 +1223,14 @@ class MessagingResource {
|
|
|
1195
1223
|
const queryParams = new URLSearchParams();
|
|
1196
1224
|
queryParams.append("user_id", userId);
|
|
1197
1225
|
const payload = {};
|
|
1198
|
-
if (request.email)
|
|
1199
|
-
|
|
1200
|
-
if (request.
|
|
1201
|
-
|
|
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;
|
|
1202
1234
|
if (request.messageLimit !== void 0 && request.messageLimit !== null) {
|
|
1203
1235
|
payload.message_limit = request.messageLimit;
|
|
1204
1236
|
}
|
|
@@ -1266,7 +1298,8 @@ class MessagingResource {
|
|
|
1266
1298
|
provider_id: p.providerId || void 0
|
|
1267
1299
|
}))
|
|
1268
1300
|
};
|
|
1269
|
-
if (request.channels)
|
|
1301
|
+
if (request.channels)
|
|
1302
|
+
payload.channels = request.channels;
|
|
1270
1303
|
if (request.messageLimit !== void 0 && request.messageLimit !== null) {
|
|
1271
1304
|
payload.message_limit = request.messageLimit;
|
|
1272
1305
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -516,10 +516,12 @@ interface ModelOverrides {
|
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* Available specialized agents
|
|
519
|
+
* Using a union type that can be extended with any string to support future agents
|
|
519
520
|
*/
|
|
520
|
-
type SpecializedAgentType = 'quick_people_search';
|
|
521
|
+
type SpecializedAgentType = 'quick_people_search' | 'deep_people_search' | (string & {});
|
|
521
522
|
/**
|
|
522
523
|
* Parameters for specialized agent execution
|
|
524
|
+
* This is a flexible interface that supports any agent-specific parameters
|
|
523
525
|
*/
|
|
524
526
|
interface SpecializedAgentParams {
|
|
525
527
|
/**
|
|
@@ -527,11 +529,21 @@ interface SpecializedAgentParams {
|
|
|
527
529
|
* Agent-specific: For quick_people_search, limits the number of candidates returned
|
|
528
530
|
*/
|
|
529
531
|
limit?: number;
|
|
532
|
+
/**
|
|
533
|
+
* Number of candidates requested (for deep_people_search)
|
|
534
|
+
* Range: 1-1000
|
|
535
|
+
*/
|
|
536
|
+
requestedCandidates?: number;
|
|
530
537
|
/**
|
|
531
538
|
* Specific data sources to use (agent-specific)
|
|
532
|
-
* For
|
|
539
|
+
* For people search agents: ["PDL", "CORESIGNAL", "CRUST_DATA"]
|
|
533
540
|
*/
|
|
534
541
|
dataSources?: string[];
|
|
542
|
+
/**
|
|
543
|
+
* Additional parameters for any specialized agent
|
|
544
|
+
* This allows flexibility for future agents without SDK updates
|
|
545
|
+
*/
|
|
546
|
+
[key: string]: any;
|
|
535
547
|
}
|
|
536
548
|
interface CreateResponseRequest {
|
|
537
549
|
threadId?: UUID;
|
|
@@ -545,7 +557,8 @@ interface CreateResponseRequest {
|
|
|
545
557
|
modelOverrides?: ModelOverrides;
|
|
546
558
|
/**
|
|
547
559
|
* Route to a specialized agent instead of the main Lumnis agent
|
|
548
|
-
*
|
|
560
|
+
* Known agents: 'quick_people_search', 'deep_people_search'
|
|
561
|
+
* Accepts any string to support future agents without SDK updates
|
|
549
562
|
*/
|
|
550
563
|
specializedAgent?: SpecializedAgentType;
|
|
551
564
|
/**
|
|
@@ -1588,6 +1601,8 @@ interface DraftResponse {
|
|
|
1588
1601
|
conversationId?: string | null;
|
|
1589
1602
|
/** Outreach method used for this draft: 'connection_request' | 'direct_message' | 'inmail' | 'email' */
|
|
1590
1603
|
outreachMethod?: 'direct_message' | 'connection_request' | 'inmail' | 'email' | null;
|
|
1604
|
+
/** Subject line for email drafts (optional) */
|
|
1605
|
+
subject?: string | null;
|
|
1591
1606
|
}
|
|
1592
1607
|
/**
|
|
1593
1608
|
* Response from batch draft creation
|
|
@@ -1919,6 +1934,21 @@ declare class MessagingResource {
|
|
|
1919
1934
|
* Create a single draft message
|
|
1920
1935
|
*/
|
|
1921
1936
|
createDraft(userId: string, request: CreateDraftRequest): Promise<DraftResponse>;
|
|
1937
|
+
/**
|
|
1938
|
+
* Get a draft by ID.
|
|
1939
|
+
*
|
|
1940
|
+
* @param userId - User ID or email
|
|
1941
|
+
* @param draftId - Draft UUID
|
|
1942
|
+
* @returns Promise resolving to DraftResponse
|
|
1943
|
+
* @throws MessagingNotFoundError if draft not found (404) or other API error
|
|
1944
|
+
*
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```typescript
|
|
1947
|
+
* const draft = await client.messaging.getDraft('user@example.com', 'draft-uuid');
|
|
1948
|
+
* console.log(draft.content);
|
|
1949
|
+
* ```
|
|
1950
|
+
*/
|
|
1951
|
+
getDraft(userId: string, draftId: string): Promise<DraftResponse>;
|
|
1922
1952
|
/**
|
|
1923
1953
|
* Create drafts for multiple prospects with AI generation
|
|
1924
1954
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -516,10 +516,12 @@ interface ModelOverrides {
|
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* Available specialized agents
|
|
519
|
+
* Using a union type that can be extended with any string to support future agents
|
|
519
520
|
*/
|
|
520
|
-
type SpecializedAgentType = 'quick_people_search';
|
|
521
|
+
type SpecializedAgentType = 'quick_people_search' | 'deep_people_search' | (string & {});
|
|
521
522
|
/**
|
|
522
523
|
* Parameters for specialized agent execution
|
|
524
|
+
* This is a flexible interface that supports any agent-specific parameters
|
|
523
525
|
*/
|
|
524
526
|
interface SpecializedAgentParams {
|
|
525
527
|
/**
|
|
@@ -527,11 +529,21 @@ interface SpecializedAgentParams {
|
|
|
527
529
|
* Agent-specific: For quick_people_search, limits the number of candidates returned
|
|
528
530
|
*/
|
|
529
531
|
limit?: number;
|
|
532
|
+
/**
|
|
533
|
+
* Number of candidates requested (for deep_people_search)
|
|
534
|
+
* Range: 1-1000
|
|
535
|
+
*/
|
|
536
|
+
requestedCandidates?: number;
|
|
530
537
|
/**
|
|
531
538
|
* Specific data sources to use (agent-specific)
|
|
532
|
-
* For
|
|
539
|
+
* For people search agents: ["PDL", "CORESIGNAL", "CRUST_DATA"]
|
|
533
540
|
*/
|
|
534
541
|
dataSources?: string[];
|
|
542
|
+
/**
|
|
543
|
+
* Additional parameters for any specialized agent
|
|
544
|
+
* This allows flexibility for future agents without SDK updates
|
|
545
|
+
*/
|
|
546
|
+
[key: string]: any;
|
|
535
547
|
}
|
|
536
548
|
interface CreateResponseRequest {
|
|
537
549
|
threadId?: UUID;
|
|
@@ -545,7 +557,8 @@ interface CreateResponseRequest {
|
|
|
545
557
|
modelOverrides?: ModelOverrides;
|
|
546
558
|
/**
|
|
547
559
|
* Route to a specialized agent instead of the main Lumnis agent
|
|
548
|
-
*
|
|
560
|
+
* Known agents: 'quick_people_search', 'deep_people_search'
|
|
561
|
+
* Accepts any string to support future agents without SDK updates
|
|
549
562
|
*/
|
|
550
563
|
specializedAgent?: SpecializedAgentType;
|
|
551
564
|
/**
|
|
@@ -1588,6 +1601,8 @@ interface DraftResponse {
|
|
|
1588
1601
|
conversationId?: string | null;
|
|
1589
1602
|
/** Outreach method used for this draft: 'connection_request' | 'direct_message' | 'inmail' | 'email' */
|
|
1590
1603
|
outreachMethod?: 'direct_message' | 'connection_request' | 'inmail' | 'email' | null;
|
|
1604
|
+
/** Subject line for email drafts (optional) */
|
|
1605
|
+
subject?: string | null;
|
|
1591
1606
|
}
|
|
1592
1607
|
/**
|
|
1593
1608
|
* Response from batch draft creation
|
|
@@ -1919,6 +1934,21 @@ declare class MessagingResource {
|
|
|
1919
1934
|
* Create a single draft message
|
|
1920
1935
|
*/
|
|
1921
1936
|
createDraft(userId: string, request: CreateDraftRequest): Promise<DraftResponse>;
|
|
1937
|
+
/**
|
|
1938
|
+
* Get a draft by ID.
|
|
1939
|
+
*
|
|
1940
|
+
* @param userId - User ID or email
|
|
1941
|
+
* @param draftId - Draft UUID
|
|
1942
|
+
* @returns Promise resolving to DraftResponse
|
|
1943
|
+
* @throws MessagingNotFoundError if draft not found (404) or other API error
|
|
1944
|
+
*
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```typescript
|
|
1947
|
+
* const draft = await client.messaging.getDraft('user@example.com', 'draft-uuid');
|
|
1948
|
+
* console.log(draft.content);
|
|
1949
|
+
* ```
|
|
1950
|
+
*/
|
|
1951
|
+
getDraft(userId: string, draftId: string): Promise<DraftResponse>;
|
|
1922
1952
|
/**
|
|
1923
1953
|
* Create drafts for multiple prospects with AI generation
|
|
1924
1954
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -516,10 +516,12 @@ interface ModelOverrides {
|
|
|
516
516
|
}
|
|
517
517
|
/**
|
|
518
518
|
* Available specialized agents
|
|
519
|
+
* Using a union type that can be extended with any string to support future agents
|
|
519
520
|
*/
|
|
520
|
-
type SpecializedAgentType = 'quick_people_search';
|
|
521
|
+
type SpecializedAgentType = 'quick_people_search' | 'deep_people_search' | (string & {});
|
|
521
522
|
/**
|
|
522
523
|
* Parameters for specialized agent execution
|
|
524
|
+
* This is a flexible interface that supports any agent-specific parameters
|
|
523
525
|
*/
|
|
524
526
|
interface SpecializedAgentParams {
|
|
525
527
|
/**
|
|
@@ -527,11 +529,21 @@ interface SpecializedAgentParams {
|
|
|
527
529
|
* Agent-specific: For quick_people_search, limits the number of candidates returned
|
|
528
530
|
*/
|
|
529
531
|
limit?: number;
|
|
532
|
+
/**
|
|
533
|
+
* Number of candidates requested (for deep_people_search)
|
|
534
|
+
* Range: 1-1000
|
|
535
|
+
*/
|
|
536
|
+
requestedCandidates?: number;
|
|
530
537
|
/**
|
|
531
538
|
* Specific data sources to use (agent-specific)
|
|
532
|
-
* For
|
|
539
|
+
* For people search agents: ["PDL", "CORESIGNAL", "CRUST_DATA"]
|
|
533
540
|
*/
|
|
534
541
|
dataSources?: string[];
|
|
542
|
+
/**
|
|
543
|
+
* Additional parameters for any specialized agent
|
|
544
|
+
* This allows flexibility for future agents without SDK updates
|
|
545
|
+
*/
|
|
546
|
+
[key: string]: any;
|
|
535
547
|
}
|
|
536
548
|
interface CreateResponseRequest {
|
|
537
549
|
threadId?: UUID;
|
|
@@ -545,7 +557,8 @@ interface CreateResponseRequest {
|
|
|
545
557
|
modelOverrides?: ModelOverrides;
|
|
546
558
|
/**
|
|
547
559
|
* Route to a specialized agent instead of the main Lumnis agent
|
|
548
|
-
*
|
|
560
|
+
* Known agents: 'quick_people_search', 'deep_people_search'
|
|
561
|
+
* Accepts any string to support future agents without SDK updates
|
|
549
562
|
*/
|
|
550
563
|
specializedAgent?: SpecializedAgentType;
|
|
551
564
|
/**
|
|
@@ -1588,6 +1601,8 @@ interface DraftResponse {
|
|
|
1588
1601
|
conversationId?: string | null;
|
|
1589
1602
|
/** Outreach method used for this draft: 'connection_request' | 'direct_message' | 'inmail' | 'email' */
|
|
1590
1603
|
outreachMethod?: 'direct_message' | 'connection_request' | 'inmail' | 'email' | null;
|
|
1604
|
+
/** Subject line for email drafts (optional) */
|
|
1605
|
+
subject?: string | null;
|
|
1591
1606
|
}
|
|
1592
1607
|
/**
|
|
1593
1608
|
* Response from batch draft creation
|
|
@@ -1919,6 +1934,21 @@ declare class MessagingResource {
|
|
|
1919
1934
|
* Create a single draft message
|
|
1920
1935
|
*/
|
|
1921
1936
|
createDraft(userId: string, request: CreateDraftRequest): Promise<DraftResponse>;
|
|
1937
|
+
/**
|
|
1938
|
+
* Get a draft by ID.
|
|
1939
|
+
*
|
|
1940
|
+
* @param userId - User ID or email
|
|
1941
|
+
* @param draftId - Draft UUID
|
|
1942
|
+
* @returns Promise resolving to DraftResponse
|
|
1943
|
+
* @throws MessagingNotFoundError if draft not found (404) or other API error
|
|
1944
|
+
*
|
|
1945
|
+
* @example
|
|
1946
|
+
* ```typescript
|
|
1947
|
+
* const draft = await client.messaging.getDraft('user@example.com', 'draft-uuid');
|
|
1948
|
+
* console.log(draft.content);
|
|
1949
|
+
* ```
|
|
1950
|
+
*/
|
|
1951
|
+
getDraft(userId: string, draftId: string): Promise<DraftResponse>;
|
|
1922
1952
|
/**
|
|
1923
1953
|
* Create drafts for multiple prospects with AI generation
|
|
1924
1954
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -408,42 +408,6 @@ class MCPServersResource {
|
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
|
|
411
|
-
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
412
|
-
function isUUID(s) {
|
|
413
|
-
return UUID_PATTERN.test(s);
|
|
414
|
-
}
|
|
415
|
-
function toCamel(s) {
|
|
416
|
-
if (isUUID(s))
|
|
417
|
-
return s;
|
|
418
|
-
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
419
|
-
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
420
|
-
});
|
|
421
|
-
}
|
|
422
|
-
function toSnake(s) {
|
|
423
|
-
if (isUUID(s))
|
|
424
|
-
return s;
|
|
425
|
-
return s.replace(/[A-Z]/g, (letter, index) => {
|
|
426
|
-
return index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`;
|
|
427
|
-
});
|
|
428
|
-
}
|
|
429
|
-
function convertCase(obj, converter) {
|
|
430
|
-
if (Array.isArray(obj)) {
|
|
431
|
-
return obj.map((v) => convertCase(v, converter));
|
|
432
|
-
} else if (obj !== null && typeof obj === "object") {
|
|
433
|
-
return Object.keys(obj).reduce((acc, key) => {
|
|
434
|
-
acc[converter(key)] = convertCase(obj[key], converter);
|
|
435
|
-
return acc;
|
|
436
|
-
}, {});
|
|
437
|
-
}
|
|
438
|
-
return obj;
|
|
439
|
-
}
|
|
440
|
-
function toCamelCase(obj) {
|
|
441
|
-
return convertCase(obj, toCamel);
|
|
442
|
-
}
|
|
443
|
-
function toSnakeCase(obj) {
|
|
444
|
-
return convertCase(obj, toSnake);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
411
|
class LumnisError extends Error {
|
|
448
412
|
code;
|
|
449
413
|
statusCode;
|
|
@@ -548,6 +512,42 @@ class MessagingConnectionError extends MessagingAPIError {
|
|
|
548
512
|
}
|
|
549
513
|
}
|
|
550
514
|
|
|
515
|
+
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
516
|
+
function isUUID(s) {
|
|
517
|
+
return UUID_PATTERN.test(s);
|
|
518
|
+
}
|
|
519
|
+
function toCamel(s) {
|
|
520
|
+
if (isUUID(s))
|
|
521
|
+
return s;
|
|
522
|
+
return s.replace(/([-_][a-z])/gi, ($1) => {
|
|
523
|
+
return $1.toUpperCase().replace("-", "").replace("_", "");
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
function toSnake(s) {
|
|
527
|
+
if (isUUID(s))
|
|
528
|
+
return s;
|
|
529
|
+
return s.replace(/[A-Z]/g, (letter, index) => {
|
|
530
|
+
return index === 0 ? letter.toLowerCase() : `_${letter.toLowerCase()}`;
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
function convertCase(obj, converter) {
|
|
534
|
+
if (Array.isArray(obj)) {
|
|
535
|
+
return obj.map((v) => convertCase(v, converter));
|
|
536
|
+
} else if (obj !== null && typeof obj === "object") {
|
|
537
|
+
return Object.keys(obj).reduce((acc, key) => {
|
|
538
|
+
acc[converter(key)] = convertCase(obj[key], converter);
|
|
539
|
+
return acc;
|
|
540
|
+
}, {});
|
|
541
|
+
}
|
|
542
|
+
return obj;
|
|
543
|
+
}
|
|
544
|
+
function toCamelCase(obj) {
|
|
545
|
+
return convertCase(obj, toCamel);
|
|
546
|
+
}
|
|
547
|
+
function toSnakeCase(obj) {
|
|
548
|
+
return convertCase(obj, toSnake);
|
|
549
|
+
}
|
|
550
|
+
|
|
551
551
|
class MessagingResource {
|
|
552
552
|
constructor(http) {
|
|
553
553
|
this.http = http;
|
|
@@ -753,6 +753,34 @@ class MessagingResource {
|
|
|
753
753
|
request
|
|
754
754
|
);
|
|
755
755
|
}
|
|
756
|
+
/**
|
|
757
|
+
* Get a draft by ID.
|
|
758
|
+
*
|
|
759
|
+
* @param userId - User ID or email
|
|
760
|
+
* @param draftId - Draft UUID
|
|
761
|
+
* @returns Promise resolving to DraftResponse
|
|
762
|
+
* @throws MessagingNotFoundError if draft not found (404) or other API error
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* ```typescript
|
|
766
|
+
* const draft = await client.messaging.getDraft('user@example.com', 'draft-uuid');
|
|
767
|
+
* console.log(draft.content);
|
|
768
|
+
* ```
|
|
769
|
+
*/
|
|
770
|
+
async getDraft(userId, draftId) {
|
|
771
|
+
try {
|
|
772
|
+
const queryParams = new URLSearchParams();
|
|
773
|
+
queryParams.append("user_id", userId);
|
|
774
|
+
return await this.http.get(
|
|
775
|
+
`/messaging/drafts/${encodeURIComponent(draftId)}?${queryParams.toString()}`
|
|
776
|
+
);
|
|
777
|
+
} catch (error) {
|
|
778
|
+
if (error instanceof NotFoundError) {
|
|
779
|
+
throw new MessagingNotFoundError(`Draft not found: ${draftId}`);
|
|
780
|
+
}
|
|
781
|
+
throw error;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
756
784
|
/**
|
|
757
785
|
* Create drafts for multiple prospects with AI generation
|
|
758
786
|
*/
|
|
@@ -914,7 +942,7 @@ class MessagingResource {
|
|
|
914
942
|
break;
|
|
915
943
|
}
|
|
916
944
|
}
|
|
917
|
-
} catch
|
|
945
|
+
} catch {
|
|
918
946
|
continue;
|
|
919
947
|
}
|
|
920
948
|
}
|
|
@@ -1041,7 +1069,7 @@ class MessagingResource {
|
|
|
1041
1069
|
errorDetails: completeData.errorDetails || []
|
|
1042
1070
|
};
|
|
1043
1071
|
}
|
|
1044
|
-
} catch
|
|
1072
|
+
} catch {
|
|
1045
1073
|
continue;
|
|
1046
1074
|
}
|
|
1047
1075
|
}
|
|
@@ -1187,10 +1215,14 @@ class MessagingResource {
|
|
|
1187
1215
|
const queryParams = new URLSearchParams();
|
|
1188
1216
|
queryParams.append("user_id", userId);
|
|
1189
1217
|
const payload = {};
|
|
1190
|
-
if (request.email)
|
|
1191
|
-
|
|
1192
|
-
if (request.
|
|
1193
|
-
|
|
1218
|
+
if (request.email)
|
|
1219
|
+
payload.email = request.email;
|
|
1220
|
+
if (request.linkedinUrl)
|
|
1221
|
+
payload.linkedin_url = request.linkedinUrl;
|
|
1222
|
+
if (request.providerId)
|
|
1223
|
+
payload.provider_id = request.providerId;
|
|
1224
|
+
if (request.channels)
|
|
1225
|
+
payload.channels = request.channels;
|
|
1194
1226
|
if (request.messageLimit !== void 0 && request.messageLimit !== null) {
|
|
1195
1227
|
payload.message_limit = request.messageLimit;
|
|
1196
1228
|
}
|
|
@@ -1258,7 +1290,8 @@ class MessagingResource {
|
|
|
1258
1290
|
provider_id: p.providerId || void 0
|
|
1259
1291
|
}))
|
|
1260
1292
|
};
|
|
1261
|
-
if (request.channels)
|
|
1293
|
+
if (request.channels)
|
|
1294
|
+
payload.channels = request.channels;
|
|
1262
1295
|
if (request.messageLimit !== void 0 && request.messageLimit !== null) {
|
|
1263
1296
|
payload.message_limit = request.messageLimit;
|
|
1264
1297
|
}
|