eggi-ai-db-schema-2 0.1.1

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.
Files changed (188) hide show
  1. package/CHANGELOG.md +750 -0
  2. package/README.md +660 -0
  3. package/dist/config/database.d.ts +28 -0
  4. package/dist/config/database.d.ts.map +1 -0
  5. package/dist/config/database.js +72 -0
  6. package/dist/config/database.js.map +1 -0
  7. package/dist/index.d.ts +28 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +199 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/lib/database-service.d.ts +714 -0
  12. package/dist/lib/database-service.d.ts.map +1 -0
  13. package/dist/lib/database-service.js +1394 -0
  14. package/dist/lib/database-service.js.map +1 -0
  15. package/dist/lib/db-types.d.ts +167 -0
  16. package/dist/lib/db-types.d.ts.map +1 -0
  17. package/dist/lib/db-types.js +28 -0
  18. package/dist/lib/db-types.js.map +1 -0
  19. package/dist/lib/db.d.ts +58 -0
  20. package/dist/lib/db.d.ts.map +1 -0
  21. package/dist/lib/db.js +292 -0
  22. package/dist/lib/db.js.map +1 -0
  23. package/dist/lib/index.d.ts +11 -0
  24. package/dist/lib/index.d.ts.map +1 -0
  25. package/dist/lib/index.js +26 -0
  26. package/dist/lib/index.js.map +1 -0
  27. package/dist/lib/pg-client.d.ts +50 -0
  28. package/dist/lib/pg-client.d.ts.map +1 -0
  29. package/dist/lib/pg-client.js +106 -0
  30. package/dist/lib/pg-client.js.map +1 -0
  31. package/dist/lib/schema.d.ts +298 -0
  32. package/dist/lib/schema.d.ts.map +1 -0
  33. package/dist/lib/schema.js +12 -0
  34. package/dist/lib/schema.js.map +1 -0
  35. package/dist/migration-manager.d.ts +49 -0
  36. package/dist/migration-manager.d.ts.map +1 -0
  37. package/dist/migration-manager.js +282 -0
  38. package/dist/migration-manager.js.map +1 -0
  39. package/dist/queries/minimal-connections.d.ts +31 -0
  40. package/dist/queries/minimal-connections.d.ts.map +1 -0
  41. package/dist/queries/minimal-connections.js +143 -0
  42. package/dist/queries/minimal-connections.js.map +1 -0
  43. package/dist/schema.ts +340 -0
  44. package/dist/seed.d.ts +8 -0
  45. package/dist/seed.d.ts.map +1 -0
  46. package/dist/seed.js +40 -0
  47. package/dist/seed.js.map +1 -0
  48. package/dist/types/index.d.ts +7 -0
  49. package/dist/types/index.d.ts.map +1 -0
  50. package/dist/types/index.js +23 -0
  51. package/dist/types/index.js.map +1 -0
  52. package/dist/types/types.d.ts +77 -0
  53. package/dist/types/types.d.ts.map +1 -0
  54. package/dist/types/types.js +3 -0
  55. package/dist/types/types.js.map +1 -0
  56. package/dist/utils/authenticated-user-operations.d.ts +110 -0
  57. package/dist/utils/authenticated-user-operations.d.ts.map +1 -0
  58. package/dist/utils/authenticated-user-operations.js +292 -0
  59. package/dist/utils/authenticated-user-operations.js.map +1 -0
  60. package/dist/utils/authentication-operations.d.ts +48 -0
  61. package/dist/utils/authentication-operations.d.ts.map +1 -0
  62. package/dist/utils/authentication-operations.js +172 -0
  63. package/dist/utils/authentication-operations.js.map +1 -0
  64. package/dist/utils/company-mapping-job-operations.d.ts +103 -0
  65. package/dist/utils/company-mapping-job-operations.d.ts.map +1 -0
  66. package/dist/utils/company-mapping-job-operations.js +413 -0
  67. package/dist/utils/company-mapping-job-operations.js.map +1 -0
  68. package/dist/utils/company-sheet-upload-operations.d.ts +53 -0
  69. package/dist/utils/company-sheet-upload-operations.d.ts.map +1 -0
  70. package/dist/utils/company-sheet-upload-operations.js +135 -0
  71. package/dist/utils/company-sheet-upload-operations.js.map +1 -0
  72. package/dist/utils/contact-operations.d.ts +70 -0
  73. package/dist/utils/contact-operations.d.ts.map +1 -0
  74. package/dist/utils/contact-operations.js +294 -0
  75. package/dist/utils/contact-operations.js.map +1 -0
  76. package/dist/utils/forager-linkedin-operations.d.ts +74 -0
  77. package/dist/utils/forager-linkedin-operations.d.ts.map +1 -0
  78. package/dist/utils/forager-linkedin-operations.js +778 -0
  79. package/dist/utils/forager-linkedin-operations.js.map +1 -0
  80. package/dist/utils/ghost-genius-linkedin-operations.d.ts +23 -0
  81. package/dist/utils/ghost-genius-linkedin-operations.d.ts.map +1 -0
  82. package/dist/utils/ghost-genius-linkedin-operations.js +282 -0
  83. package/dist/utils/ghost-genius-linkedin-operations.js.map +1 -0
  84. package/dist/utils/index.d.ts +29 -0
  85. package/dist/utils/index.d.ts.map +1 -0
  86. package/dist/utils/index.js +77 -0
  87. package/dist/utils/index.js.map +1 -0
  88. package/dist/utils/introduction-request-operations.d.ts +160 -0
  89. package/dist/utils/introduction-request-operations.d.ts.map +1 -0
  90. package/dist/utils/introduction-request-operations.js +492 -0
  91. package/dist/utils/introduction-request-operations.js.map +1 -0
  92. package/dist/utils/invitation-operations.d.ts +141 -0
  93. package/dist/utils/invitation-operations.d.ts.map +1 -0
  94. package/dist/utils/invitation-operations.js +749 -0
  95. package/dist/utils/invitation-operations.js.map +1 -0
  96. package/dist/utils/linkedin-account-operations.d.ts +45 -0
  97. package/dist/utils/linkedin-account-operations.d.ts.map +1 -0
  98. package/dist/utils/linkedin-account-operations.js +279 -0
  99. package/dist/utils/linkedin-account-operations.js.map +1 -0
  100. package/dist/utils/linkedin-account-relationship-operations.d.ts +77 -0
  101. package/dist/utils/linkedin-account-relationship-operations.d.ts.map +1 -0
  102. package/dist/utils/linkedin-account-relationship-operations.js +274 -0
  103. package/dist/utils/linkedin-account-relationship-operations.js.map +1 -0
  104. package/dist/utils/linkedin-data-operations.d.ts +102 -0
  105. package/dist/utils/linkedin-data-operations.d.ts.map +1 -0
  106. package/dist/utils/linkedin-data-operations.js +613 -0
  107. package/dist/utils/linkedin-data-operations.js.map +1 -0
  108. package/dist/utils/linkedin-identifier-utils.d.ts +31 -0
  109. package/dist/utils/linkedin-identifier-utils.d.ts.map +1 -0
  110. package/dist/utils/linkedin-identifier-utils.js +63 -0
  111. package/dist/utils/linkedin-identifier-utils.js.map +1 -0
  112. package/dist/utils/linkedin-profile-cache.d.ts +131 -0
  113. package/dist/utils/linkedin-profile-cache.d.ts.map +1 -0
  114. package/dist/utils/linkedin-profile-cache.js +418 -0
  115. package/dist/utils/linkedin-profile-cache.js.map +1 -0
  116. package/dist/utils/llm-inference-job-operations.d.ts +116 -0
  117. package/dist/utils/llm-inference-job-operations.d.ts.map +1 -0
  118. package/dist/utils/llm-inference-job-operations.js +267 -0
  119. package/dist/utils/llm-inference-job-operations.js.map +1 -0
  120. package/dist/utils/mapping-job-operations.d.ts +272 -0
  121. package/dist/utils/mapping-job-operations.d.ts.map +1 -0
  122. package/dist/utils/mapping-job-operations.js +833 -0
  123. package/dist/utils/mapping-job-operations.js.map +1 -0
  124. package/dist/utils/mapping-operations.d.ts +80 -0
  125. package/dist/utils/mapping-operations.d.ts.map +1 -0
  126. package/dist/utils/mapping-operations.js +318 -0
  127. package/dist/utils/mapping-operations.js.map +1 -0
  128. package/dist/utils/on-demand-mapping-operations.d.ts +199 -0
  129. package/dist/utils/on-demand-mapping-operations.d.ts.map +1 -0
  130. package/dist/utils/on-demand-mapping-operations.js +728 -0
  131. package/dist/utils/on-demand-mapping-operations.js.map +1 -0
  132. package/dist/utils/onboarding-operations.d.ts +53 -0
  133. package/dist/utils/onboarding-operations.d.ts.map +1 -0
  134. package/dist/utils/onboarding-operations.js +223 -0
  135. package/dist/utils/onboarding-operations.js.map +1 -0
  136. package/dist/utils/organization-assignment-job-operations.d.ts +258 -0
  137. package/dist/utils/organization-assignment-job-operations.d.ts.map +1 -0
  138. package/dist/utils/organization-assignment-job-operations.js +881 -0
  139. package/dist/utils/organization-assignment-job-operations.js.map +1 -0
  140. package/dist/utils/organization-assignment-operations.d.ts +59 -0
  141. package/dist/utils/organization-assignment-operations.d.ts.map +1 -0
  142. package/dist/utils/organization-assignment-operations.js +130 -0
  143. package/dist/utils/organization-assignment-operations.js.map +1 -0
  144. package/dist/utils/organization-operations.d.ts +284 -0
  145. package/dist/utils/organization-operations.d.ts.map +1 -0
  146. package/dist/utils/organization-operations.js +1030 -0
  147. package/dist/utils/organization-operations.js.map +1 -0
  148. package/dist/utils/organization-relationship-operations.d.ts +79 -0
  149. package/dist/utils/organization-relationship-operations.d.ts.map +1 -0
  150. package/dist/utils/organization-relationship-operations.js +294 -0
  151. package/dist/utils/organization-relationship-operations.js.map +1 -0
  152. package/dist/utils/quota-operations.d.ts +107 -0
  153. package/dist/utils/quota-operations.d.ts.map +1 -0
  154. package/dist/utils/quota-operations.js +692 -0
  155. package/dist/utils/quota-operations.js.map +1 -0
  156. package/dist/utils/recursive-mapping-job-operations.d.ts +42 -0
  157. package/dist/utils/recursive-mapping-job-operations.d.ts.map +1 -0
  158. package/dist/utils/recursive-mapping-job-operations.js +169 -0
  159. package/dist/utils/recursive-mapping-job-operations.js.map +1 -0
  160. package/dist/utils/relationship-operations.d.ts +130 -0
  161. package/dist/utils/relationship-operations.d.ts.map +1 -0
  162. package/dist/utils/relationship-operations.js +329 -0
  163. package/dist/utils/relationship-operations.js.map +1 -0
  164. package/dist/utils/sales-pipeline-operations.d.ts +163 -0
  165. package/dist/utils/sales-pipeline-operations.d.ts.map +1 -0
  166. package/dist/utils/sales-pipeline-operations.js +725 -0
  167. package/dist/utils/sales-pipeline-operations.js.map +1 -0
  168. package/dist/utils/skills-operations.d.ts +117 -0
  169. package/dist/utils/skills-operations.d.ts.map +1 -0
  170. package/dist/utils/skills-operations.js +487 -0
  171. package/dist/utils/skills-operations.js.map +1 -0
  172. package/dist/utils/subscription-operations.d.ts +123 -0
  173. package/dist/utils/subscription-operations.d.ts.map +1 -0
  174. package/dist/utils/subscription-operations.js +391 -0
  175. package/dist/utils/subscription-operations.js.map +1 -0
  176. package/dist/utils/unipile-account-operations.d.ts +96 -0
  177. package/dist/utils/unipile-account-operations.d.ts.map +1 -0
  178. package/dist/utils/unipile-account-operations.js +255 -0
  179. package/dist/utils/unipile-account-operations.js.map +1 -0
  180. package/dist/utils/user-industry-operations.d.ts +80 -0
  181. package/dist/utils/user-industry-operations.d.ts.map +1 -0
  182. package/dist/utils/user-industry-operations.js +237 -0
  183. package/dist/utils/user-industry-operations.js.map +1 -0
  184. package/dist/utils/user-operations.d.ts +87 -0
  185. package/dist/utils/user-operations.d.ts.map +1 -0
  186. package/dist/utils/user-operations.js +212 -0
  187. package/dist/utils/user-operations.js.map +1 -0
  188. package/package.json +98 -0
@@ -0,0 +1,329 @@
1
+ "use strict";
2
+ /**
3
+ * =============================================================================
4
+ * RELATIONSHIP OPERATIONS UTILITIES - CONSOLIDATED SCHEMA
5
+ * =============================================================================
6
+ * Utility functions for querying relationship data for API endpoints
7
+ * Updated to work with the new consolidated linkedin.accounts schema
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.getTopClosestConnections = getTopClosestConnections;
11
+ exports.getRelationshipScoresBetweenAccounts = getRelationshipScoresBetweenAccounts;
12
+ exports.getRelationshipScoresForAccount = getRelationshipScoresForAccount;
13
+ exports.getRelationshipStatistics = getRelationshipStatistics;
14
+ exports.getStrongestRelationships = getStrongestRelationships;
15
+ exports.batchInsertRelationshipScores = batchInsertRelationshipScores;
16
+ exports.getTopClosestConnectionsLegacy = getTopClosestConnectionsLegacy;
17
+ const pg_client_1 = require("../lib/pg-client");
18
+ /**
19
+ * Gets the top closest connections for a specific user (for API responses)
20
+ * Includes LinkedIn profile information when available
21
+ *
22
+ * @param cognitoUserId - The Cognito user ID to find connections for
23
+ * @param modelVersion - Optional: filter by specific model version (defaults to latest)
24
+ * @param limit - Maximum number of connections to return (defaults to 10)
25
+ * @param sortOrder - Sort order for relationship scores: 'desc' for highest first, 'asc' for lowest first (defaults to 'desc')
26
+ * @returns Promise resolving to array of top connections with profile data
27
+ */
28
+ async function getTopClosestConnections(db, cognitoUserId, modelVersion, limit = 10, sortOrder = "desc") {
29
+ // First, find the user by Cognito ID
30
+ const userSql = `SELECT user_id FROM authentication.users WHERE cognito_user_id = $1 LIMIT 1`;
31
+ const authenticatedUser = await (0, pg_client_1.queryOne)(db, userSql, [cognitoUserId]);
32
+ if (!authenticatedUser || !authenticatedUser.user_id) {
33
+ return [];
34
+ }
35
+ // Find the user's LinkedIn account
36
+ const linkedinSql = `SELECT id FROM linkedin.accounts WHERE user_id = $1 LIMIT 1`;
37
+ const linkedinAccount = await (0, pg_client_1.queryOne)(db, linkedinSql, [authenticatedUser.user_id]);
38
+ if (!linkedinAccount) {
39
+ return [];
40
+ }
41
+ const userLinkedInAccountId = linkedinAccount.id;
42
+ // Query relationship scores with the "other" user's information
43
+ const relationshipSql = `
44
+ SELECT
45
+ r.score,
46
+ r.model_version,
47
+ r.created_at,
48
+ CASE
49
+ WHEN r.linkedin_account_id_a = $1
50
+ THEN r.linkedin_account_id_b
51
+ ELSE r.linkedin_account_id_a
52
+ END as other_user_id,
53
+ CASE
54
+ WHEN r.linkedin_account_id_a = $1
55
+ THEN account_b.first_name
56
+ ELSE account_a.first_name
57
+ END as other_user_given_name,
58
+ CASE
59
+ WHEN r.linkedin_account_id_a = $1
60
+ THEN account_b.last_name
61
+ ELSE account_a.last_name
62
+ END as other_user_family_name,
63
+ CASE
64
+ WHEN r.linkedin_account_id_a = $1
65
+ THEN account_b.linkedin_identifier_acoa
66
+ ELSE account_a.linkedin_identifier_acoa
67
+ END as other_user_linkedin_identifier,
68
+ CASE
69
+ WHEN r.linkedin_account_id_a = $1
70
+ THEN COALESCE(account_b.profile_image_cloudfront_url, account_b.profile_picture_url)
71
+ ELSE COALESCE(account_a.profile_image_cloudfront_url, account_a.profile_picture_url)
72
+ END as other_user_profile_image_url
73
+ FROM linkedin.relationships r
74
+ INNER JOIN linkedin.accounts account_a ON r.linkedin_account_id_a = account_a.id
75
+ INNER JOIN linkedin.accounts account_b ON r.linkedin_account_id_b = account_b.id
76
+ WHERE (r.linkedin_account_id_a = $1 OR r.linkedin_account_id_b = $1)
77
+ ${modelVersion !== undefined ? 'AND r.model_version = $2' : ''}
78
+ ORDER BY r.score ${sortOrder === 'asc' ? 'ASC' : 'DESC'}
79
+ LIMIT $${modelVersion !== undefined ? '3' : '2'}
80
+ `;
81
+ const params = modelVersion !== undefined
82
+ ? [userLinkedInAccountId, modelVersion.toString(), limit]
83
+ : [userLinkedInAccountId, limit];
84
+ const results = await (0, pg_client_1.query)(db, relationshipSql, params);
85
+ return results.map(result => ({
86
+ score: result.score,
87
+ modelVersion: result.model_version ? parseInt(result.model_version) : null,
88
+ createdAt: result.created_at,
89
+ otherUser: {
90
+ id: result.other_user_id,
91
+ givenName: result.other_user_given_name,
92
+ familyName: result.other_user_family_name,
93
+ linkedinIdentifier: result.other_user_linkedin_identifier,
94
+ profileImageUrl: result.other_user_profile_image_url,
95
+ },
96
+ }));
97
+ }
98
+ /**
99
+ * Gets relationship scores between two specific LinkedIn accounts
100
+ *
101
+ * @param linkedinAccountIdA - First LinkedIn account ID
102
+ * @param linkedinAccountIdB - Second LinkedIn account ID
103
+ * @param modelVersion - Optional: filter by specific model version
104
+ * @returns Promise resolving to array of relationship scores between the two accounts
105
+ */
106
+ async function getRelationshipScoresBetweenAccounts(db, linkedinAccountIdA, linkedinAccountIdB, modelVersion) {
107
+ const sql = `
108
+ SELECT score, model_version, analysis_type, mapping_job_id, metadata, created_at
109
+ FROM linkedin.relationships
110
+ WHERE (
111
+ (linkedin_account_id_a = $1 AND linkedin_account_id_b = $2)
112
+ OR (linkedin_account_id_a = $2 AND linkedin_account_id_b = $1)
113
+ )
114
+ ${modelVersion ? 'AND model_version = $3' : ''}
115
+ ORDER BY created_at DESC
116
+ `;
117
+ const params = modelVersion ? [linkedinAccountIdA, linkedinAccountIdB, modelVersion] : [linkedinAccountIdA, linkedinAccountIdB];
118
+ const results = await (0, pg_client_1.query)(db, sql, params);
119
+ return results.map(result => ({
120
+ score: result.score,
121
+ modelVersion: result.model_version,
122
+ analysisType: result.analysis_type,
123
+ mappingJobId: result.mapping_job_id,
124
+ metadata: result.metadata,
125
+ createdAt: result.created_at,
126
+ }));
127
+ }
128
+ /**
129
+ * Gets all relationship scores for a specific LinkedIn account
130
+ *
131
+ * @param linkedinAccountId - The LinkedIn account ID to find relationships for
132
+ * @param options - Query options
133
+ * @returns Promise resolving to array of relationship scores
134
+ */
135
+ async function getRelationshipScoresForAccount(db, linkedinAccountId, options) {
136
+ const { limit = 100, minScore, modelVersion, sortOrder = "desc" } = options || {};
137
+ const sql = `
138
+ SELECT
139
+ r.score,
140
+ r.model_version,
141
+ r.analysis_type,
142
+ r.mapping_job_id,
143
+ r.metadata,
144
+ r.created_at,
145
+ CASE
146
+ WHEN r.linkedin_account_id_a = $1
147
+ THEN r.linkedin_account_id_b
148
+ ELSE r.linkedin_account_id_a
149
+ END as other_account_id,
150
+ CASE
151
+ WHEN r.linkedin_account_id_a = $1
152
+ THEN account_b.linkedin_identifier_acoa
153
+ ELSE account_a.linkedin_identifier_acoa
154
+ END as other_account_linkedin_identifier_acoa,
155
+ CASE
156
+ WHEN r.linkedin_account_id_a = $1
157
+ THEN account_b.public_identifier
158
+ ELSE account_a.public_identifier
159
+ END as other_account_public_identifier,
160
+ CASE
161
+ WHEN r.linkedin_account_id_a = $1
162
+ THEN account_b.first_name
163
+ ELSE account_a.first_name
164
+ END as other_account_first_name,
165
+ CASE
166
+ WHEN r.linkedin_account_id_a = $1
167
+ THEN account_b.last_name
168
+ ELSE account_a.last_name
169
+ END as other_account_last_name,
170
+ CASE
171
+ WHEN r.linkedin_account_id_a = $1
172
+ THEN account_b.headline
173
+ ELSE account_a.headline
174
+ END as other_account_headline,
175
+ CASE
176
+ WHEN r.linkedin_account_id_a = $1
177
+ THEN account_b.profile_image_cloudfront_url
178
+ ELSE account_a.profile_image_cloudfront_url
179
+ END as other_account_profile_picture_url
180
+ FROM linkedin.relationships r
181
+ INNER JOIN linkedin.accounts account_a ON r.linkedin_account_id_a = account_a.id
182
+ INNER JOIN linkedin.accounts account_b ON r.linkedin_account_id_b = account_b.id
183
+ WHERE (r.linkedin_account_id_a = $1 OR r.linkedin_account_id_b = $1)
184
+ ${minScore !== undefined ? `AND r.score >= ${minScore}` : ''}
185
+ ${modelVersion ? `AND r.model_version = '${modelVersion}'` : ''}
186
+ ORDER BY r.score ${sortOrder === 'asc' ? 'ASC' : 'DESC'}
187
+ LIMIT $2
188
+ `;
189
+ const results = await (0, pg_client_1.query)(db, sql, [linkedinAccountId, limit]);
190
+ return results.map(result => ({
191
+ score: result.score,
192
+ modelVersion: result.model_version,
193
+ analysisType: result.analysis_type,
194
+ mappingJobId: result.mapping_job_id,
195
+ metadata: result.metadata,
196
+ createdAt: result.created_at,
197
+ otherAccount: {
198
+ id: result.other_account_id,
199
+ linkedinIdentifierAcoa: result.other_account_linkedin_identifier_acoa,
200
+ publicIdentifier: result.other_account_public_identifier,
201
+ firstName: result.other_account_first_name,
202
+ lastName: result.other_account_last_name,
203
+ headline: result.other_account_headline,
204
+ profilePictureUrl: result.other_account_profile_picture_url,
205
+ },
206
+ }));
207
+ }
208
+ /**
209
+ * Gets relationship statistics for a LinkedIn account
210
+ *
211
+ * @param linkedinAccountId - The LinkedIn account ID to get statistics for
212
+ * @returns Promise resolving to relationship statistics
213
+ */
214
+ async function getRelationshipStatistics(db, linkedinAccountId) {
215
+ const sql = `
216
+ SELECT
217
+ COUNT(*) as total_relationships,
218
+ AVG(score) as average_score,
219
+ COUNT(*) FILTER (WHERE score >= 80) as high_score_relationships,
220
+ COUNT(*) FILTER (WHERE score >= 50 AND score < 80) as medium_score_relationships,
221
+ COUNT(*) FILTER (WHERE score < 50) as low_score_relationships,
222
+ MAX(model_version) as latest_model_version
223
+ FROM linkedin.relationships
224
+ WHERE linkedin_account_id_a = $1 OR linkedin_account_id_b = $1
225
+ `;
226
+ const result = await (0, pg_client_1.queryOne)(db, sql, [linkedinAccountId]);
227
+ if (!result) {
228
+ return {
229
+ totalRelationships: 0,
230
+ averageScore: 0,
231
+ highScoreRelationships: 0,
232
+ mediumScoreRelationships: 0,
233
+ lowScoreRelationships: 0,
234
+ latestModelVersion: null,
235
+ };
236
+ }
237
+ return {
238
+ totalRelationships: parseInt(result.total_relationships) || 0,
239
+ averageScore: Math.round(parseFloat(result.average_score || '0')),
240
+ highScoreRelationships: parseInt(result.high_score_relationships) || 0,
241
+ mediumScoreRelationships: parseInt(result.medium_score_relationships) || 0,
242
+ lowScoreRelationships: parseInt(result.low_score_relationships) || 0,
243
+ latestModelVersion: result.latest_model_version,
244
+ };
245
+ }
246
+ /**
247
+ * Gets the strongest relationships for a LinkedIn account
248
+ *
249
+ * @param linkedinAccountId - The LinkedIn account ID to find strongest relationships for
250
+ * @param limit - Maximum number of relationships to return (defaults to 10)
251
+ * @returns Promise resolving to array of strongest relationships
252
+ */
253
+ async function getStrongestRelationships(db, linkedinAccountId, limit = 10) {
254
+ const results = await getRelationshipScoresForAccount(db, linkedinAccountId, {
255
+ limit,
256
+ sortOrder: "desc",
257
+ });
258
+ return results.map(result => ({
259
+ score: result.score,
260
+ otherAccount: {
261
+ id: result.otherAccount.id,
262
+ linkedinIdentifierAcoa: result.otherAccount.linkedinIdentifierAcoa,
263
+ firstName: result.otherAccount.firstName,
264
+ lastName: result.otherAccount.lastName,
265
+ headline: result.otherAccount.headline,
266
+ profilePictureUrl: result.otherAccount.profilePictureUrl,
267
+ },
268
+ }));
269
+ }
270
+ /**
271
+ * Batch insert relationship scores
272
+ *
273
+ * @param linkedinRelationshipsData - Array of relationship score data to insert
274
+ * @returns Promise resolving to array of inserted relationship scores
275
+ */
276
+ async function batchInsertRelationshipScores(db, linkedinRelationshipsData) {
277
+ if (linkedinRelationshipsData.length === 0) {
278
+ return [];
279
+ }
280
+ // Build VALUES clause for batch insert
281
+ const values = [];
282
+ const params = [];
283
+ let paramIndex = 1;
284
+ linkedinRelationshipsData.forEach((data) => {
285
+ values.push(`($${paramIndex}, $${paramIndex + 1}, $${paramIndex + 2}, $${paramIndex + 3}, $${paramIndex + 4}, $${paramIndex + 5}, $${paramIndex + 6}, NOW())`);
286
+ params.push(data.linkedinAccountIdA, data.linkedinAccountIdB, data.score, data.modelVersion, data.analysisType || 'MESSAGE_ANALYSER', data.mappingJobId, JSON.stringify(data.metadata || {}));
287
+ paramIndex += 7;
288
+ });
289
+ const sql = `
290
+ INSERT INTO linkedin.relationships (
291
+ linkedin_account_id_a,
292
+ linkedin_account_id_b,
293
+ score,
294
+ model_version,
295
+ analysis_type,
296
+ mapping_job_id,
297
+ metadata,
298
+ created_at
299
+ )
300
+ VALUES ${values.join(', ')}
301
+ ON CONFLICT (linkedin_account_id_a, linkedin_account_id_b, model_version, analysis_type, mapping_job_id)
302
+ DO UPDATE SET
303
+ score = EXCLUDED.score,
304
+ metadata = EXCLUDED.metadata
305
+ RETURNING
306
+ id,
307
+ linkedin_account_id_a,
308
+ linkedin_account_id_b,
309
+ score,
310
+ model_version,
311
+ analysis_type,
312
+ mapping_job_id,
313
+ metadata,
314
+ created_at
315
+ `;
316
+ return await (0, pg_client_1.query)(db, sql, params);
317
+ }
318
+ // =============================================================================
319
+ // LEGACY COMPATIBILITY (DEPRECATED)
320
+ // =============================================================================
321
+ /**
322
+ * @deprecated Use getTopClosestConnections instead
323
+ * This function used the old linkedin_accounts schema
324
+ */
325
+ async function getTopClosestConnectionsLegacy(db, cognitoUserId, modelVersion, limit = 10, sortOrder = "desc") {
326
+ console.warn("getTopClosestConnectionsLegacy is deprecated. Use getTopClosestConnections instead.");
327
+ return await getTopClosestConnections(db, cognitoUserId, modelVersion, limit, sortOrder);
328
+ }
329
+ //# sourceMappingURL=relationship-operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relationship-operations.js","sourceRoot":"","sources":["../../src/utils/relationship-operations.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAiBH,4DAyGC;AAUD,oFA6CC;AASD,0EAoHC;AAQD,8DAmDC;AASD,8DAiCC;AAQD,sEAgEC;AAUD,wEAWC;AA7eD,gDAAmD;AAInD;;;;;;;;;GASG;AACI,KAAK,UAAU,wBAAwB,CAC5C,EAAgC,EAChC,aAAqB,EACrB,YAAqB,EACrB,QAAgB,EAAE,EAClB,YAA4B,MAAM;IAelC,qCAAqC;IAC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,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG;;;;;;;;;;;aAWD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;GAe3B,CAAC;IAEF,OAAO,MAAM,IAAA,iBAAK,EAAuB,EAAuB,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AACjF,CAAC;AAED,gFAAgF;AAChF,oCAAoC;AACpC,gFAAgF;AAEhF;;;GAGG;AACI,KAAK,UAAU,8BAA8B,CAClD,EAAgC,EAChC,aAAqB,EACrB,YAAqB,EACrB,QAAgB,EAAE,EAClB,YAA4B,MAAM;IAElC,OAAO,CAAC,IAAI,CACV,qFAAqF,CACtF,CAAC;IACF,OAAO,MAAM,wBAAwB,CAAC,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAC3F,CAAC"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Sales Pipeline Operations
3
+ *
4
+ * Database operations for sales pipelines and user assignments.
5
+ * Organization-scoped pipelines shared by all users in the organization.
6
+ */
7
+ import { Pool, PoolClient } from "pg";
8
+ import type { Database } from "../lib/db";
9
+ /**
10
+ * Sales pipeline entry (organization-scoped)
11
+ */
12
+ export interface SalesPipeline {
13
+ id: number;
14
+ organizationId: number;
15
+ addedByOrganizationMemberId: number;
16
+ createdAt: Date;
17
+ }
18
+ /**
19
+ * Sales pipeline assignment (linked to organization relationship assignment)
20
+ */
21
+ export interface SalesPipelineAssignment {
22
+ id: number;
23
+ salesPipelineId: number;
24
+ organizationUserRelationshipAssignmentId: number;
25
+ stage: "prospect" | "qualified" | "proposal" | "negotiation" | "closed_won" | "closed_lost";
26
+ createdAt: Date;
27
+ updatedAt: Date;
28
+ }
29
+ /**
30
+ * Create or get a sales pipeline entry for an organization
31
+ * Checks for existing entry via organization_user_relationship_assignment_id
32
+ * If the pipeline entry already exists, returns the existing one
33
+ *
34
+ * @param db - Database instance
35
+ * @param organizationId - Organization ID
36
+ * @param organizationUserRelationshipAssignmentId - Organization relationship assignment ID
37
+ * @param addedByOrganizationMemberId - Organization member who added this to the pipeline
38
+ * @returns Sales pipeline entry
39
+ */
40
+ export declare function createOrGetSalesPipeline(db: Database | Pool | PoolClient, organizationId: number, organizationUserRelationshipAssignmentId: number, addedByOrganizationMemberId: number): Promise<SalesPipeline>;
41
+ /**
42
+ * Get or create an organization_user_relationships_assignments entry
43
+ *
44
+ * @param db - Database instance
45
+ * @param organizationId - Organization ID
46
+ * @param linkedinRelationshipId - LinkedIn relationship ID
47
+ * @param organizationMemberId - Organization member ID (the member whose LinkedIn account is part of the relationship)
48
+ * @returns Organization relationship assignment ID
49
+ */
50
+ export declare function getOrCreateOrganizationRelationshipAssignment(db: Database | Pool | PoolClient, organizationId: number, linkedinRelationshipId: number, organizationMemberId: number): Promise<number>;
51
+ /**
52
+ * Create or update a sales pipeline assignment
53
+ * If assignment exists, updates the stage; otherwise creates new assignment with default stage 'prospect'
54
+ *
55
+ * @param db - Database instance
56
+ * @param salesPipelineId - Sales pipeline ID
57
+ * @param organizationUserRelationshipAssignmentId - Organization relationship assignment ID
58
+ * @param stage - Sales stage (default: 'prospect')
59
+ * @returns Sales pipeline assignment
60
+ */
61
+ export declare function createOrUpdateSalesPipelineAssignment(db: Database | Pool | PoolClient, salesPipelineId: number, organizationUserRelationshipAssignmentId: number, stage?: "prospect" | "qualified" | "proposal" | "negotiation" | "closed_won" | "closed_lost"): Promise<SalesPipelineAssignment>;
62
+ /**
63
+ * Get a sales pipeline assignment by ID and validate it belongs to an organization
64
+ *
65
+ * @param db - Database instance
66
+ * @param assignmentId - Sales pipeline assignment ID
67
+ * @param organizationId - Organization ID to validate against
68
+ * @returns Sales pipeline assignment with pipeline info, or null if not found or doesn't belong to org
69
+ */
70
+ export declare function getSalesPipelineAssignmentWithValidation(db: Database | Pool | PoolClient, assignmentId: number, organizationId: number): Promise<{
71
+ assignment: SalesPipelineAssignment;
72
+ pipeline: SalesPipeline;
73
+ } | null>;
74
+ /**
75
+ * Add a relationship to the sales pipeline
76
+ * Creates or gets the pipeline entry and organization relationship assignment, then creates/updates the pipeline assignment with default stage 'prospect'
77
+ *
78
+ * @param db - Database instance
79
+ * @param organizationId - Organization ID
80
+ * @param linkedinRelationshipId - LinkedIn relationship ID
81
+ * @returns Sales pipeline assignment
82
+ */
83
+ export declare function addToSalesPipeline(db: Database | Pool | PoolClient, organizationId: number, linkedinRelationshipId: number, addedByOrganizationMemberId: number): Promise<SalesPipelineAssignment>;
84
+ /**
85
+ * Add a relationship to the sales pipeline using organization relationship assignment ID
86
+ * This is more efficient as it already contains the organization and relationship context
87
+ *
88
+ * @param db - Database instance
89
+ * @param organizationUserRelationshipAssignmentId - Organization relationship assignment ID
90
+ * @param addedByOrganizationMemberId - Organization member who added this entry
91
+ * @returns Sales pipeline assignment
92
+ */
93
+ export declare function addToSalesPipelineByAssignmentId(db: Database | Pool | PoolClient, organizationUserRelationshipAssignmentId: number, addedByOrganizationMemberId: number): Promise<SalesPipelineAssignment>;
94
+ /**
95
+ * Get a sales pipeline entry by ID
96
+ *
97
+ * @param db - Database instance
98
+ * @param salesPipelineId - Sales pipeline ID
99
+ * @returns Sales pipeline entry or null if not found
100
+ */
101
+ export declare function getSalesPipelineById(db: Database | Pool | PoolClient, salesPipelineId: number): Promise<SalesPipeline | null>;
102
+ /**
103
+ * Sales pipeline entry with relationship and profile data
104
+ */
105
+ export interface SalesPipelineEntryWithProfile {
106
+ assignment_id: number;
107
+ sales_pipeline_id: number;
108
+ organization_user_relationship_assignment_id: number;
109
+ stage: "prospect" | "qualified" | "proposal" | "negotiation" | "closed_won" | "closed_lost";
110
+ assignment_created_at: Date;
111
+ assignment_updated_at: Date;
112
+ linkedin_relationship_id: number;
113
+ connection_id: number;
114
+ full_name: string | null;
115
+ first_name: string | null;
116
+ last_name: string | null;
117
+ headline: string | null;
118
+ summary: string | null;
119
+ location: string | null;
120
+ profile_image_url: string | null;
121
+ linkedin_public_identifier: string | null;
122
+ linkedin_identifier_acoa: string | null;
123
+ connection_user_id: number | null;
124
+ connection_user_given_name: string | null;
125
+ connection_user_family_name: string | null;
126
+ introducer_linkedin_account_id: number | null;
127
+ introducer_full_name: string | null;
128
+ introducer_first_name: string | null;
129
+ introducer_last_name: string | null;
130
+ introducer_headline: string | null;
131
+ introducer_profile_image_url: string | null;
132
+ introducer_linkedin_public_identifier: string | null;
133
+ introducer_linkedin_identifier_acoa: string | null;
134
+ introducer_user_id: number | null;
135
+ introducer_user_given_name: string | null;
136
+ introducer_user_family_name: string | null;
137
+ added_by_organization_member_id: number | null;
138
+ added_by_user_id: number | null;
139
+ added_by_full_name: string | null;
140
+ added_by_given_name: string | null;
141
+ added_by_family_name: string | null;
142
+ added_by_profile_image_url: string | null;
143
+ }
144
+ /**
145
+ * Get all sales pipeline entries for an organization with profile data
146
+ * Returns all pipeline assignments, with full relationship and profile information
147
+ *
148
+ * @param db - Database instance
149
+ * @param organizationId - Organization ID
150
+ * @param linkedinAccountId - Optional: filter by specific LinkedIn account's relationships
151
+ * @returns Array of sales pipeline entries with profile data
152
+ */
153
+ export declare function getSalesPipelineForOrganization(db: Database | Pool | PoolClient, organizationId: number, linkedinAccountId?: number): Promise<SalesPipelineEntryWithProfile[]>;
154
+ /**
155
+ * Update the stage of a sales pipeline assignment
156
+ *
157
+ * @param db - Database instance
158
+ * @param assignmentId - Sales pipeline assignment ID
159
+ * @param newStage - New sales stage
160
+ * @returns Updated sales pipeline assignment
161
+ */
162
+ export declare function updateSalesPipelineAssignmentStage(db: Database | Pool | PoolClient, assignmentId: number, newStage: "prospect" | "qualified" | "proposal" | "negotiation" | "closed_won" | "closed_lost"): Promise<SalesPipelineAssignment>;
163
+ //# sourceMappingURL=sales-pipeline-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sales-pipeline-operations.d.ts","sourceRoot":"","sources":["../../src/utils/sales-pipeline-operations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAA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