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
package/dist/schema.ts ADDED
@@ -0,0 +1,340 @@
1
+ /**
2
+ * =============================================================================
3
+ * SCHEMA TYPE DEFINITIONS - Native PostgreSQL
4
+ * =============================================================================
5
+ * Type definitions for database entities
6
+ *
7
+ * This file provides TypeScript interfaces for all database tables
8
+ * to maintain type safety with native PostgreSQL queries.
9
+ */
10
+
11
+ // Core type exports for backward compatibility
12
+ export interface User {
13
+ id: number;
14
+ givenName: string | null;
15
+ familyName: string | null;
16
+ summary: string | null;
17
+ embeddingSummary: string | null;
18
+ embedding: any;
19
+ createdAt: Date;
20
+ }
21
+
22
+ export interface AuthenticatedUser {
23
+ id: number;
24
+ userId: number | null;
25
+ cognitoUserId: string;
26
+ authProvider: string;
27
+ createdAt: Date;
28
+ contactInfoId: number | null;
29
+ isAdmin: boolean;
30
+ }
31
+
32
+ export interface ContactInfo {
33
+ id: number;
34
+ userId: number;
35
+ type: ContactInfoType;
36
+ value: string;
37
+ source: ContactInfoSource;
38
+ metadata: Record<string, any>;
39
+ createdAt: Date;
40
+ }
41
+
42
+ export type ContactInfoType = "EMAIL" | "PHONE" | "LINKEDIN_PROFILE_URL" | "WEBSITE" | "OTHER";
43
+ export type ContactInfoSource = "LINKEDIN" | "GOOGLE" | "MANUAL" | "FORAGER" | "SIGNUP" | "OTHER";
44
+
45
+ export interface LinkedinAccount {
46
+ id: number;
47
+ userId: number | null;
48
+ linkedinIdentifierAcoa: string; // NOT NULL - always required (Ghost Genius always returns ACoA)
49
+ publicIdentifier: string | null;
50
+ foragerId: number | null;
51
+ firstName: string | null;
52
+ lastName: string | null;
53
+ headline: string | null;
54
+ summary: string | null;
55
+ location: string | null;
56
+ profilePictureUrl: string | null;
57
+ profileImageCloudFrontUrl: string | null;
58
+ followerCount: number | null;
59
+ connectionsCount: number | null;
60
+ profilesUpdatedAt: Date | null;
61
+ createdAt: Date;
62
+ }
63
+
64
+ export interface UnipileAccount {
65
+ id: number;
66
+ linkedinAccountId: number;
67
+ unipileAccountId: string;
68
+ accountType: SocialPlatformType | null;
69
+ isActive: boolean;
70
+ connectedAt: Date | null;
71
+ lastSyncedAt: Date | null;
72
+ metadata: Record<string, any>;
73
+ createdAt: Date;
74
+ updatedAt: Date;
75
+ }
76
+
77
+ export type SocialPlatformType = "LINKEDIN" | "TWITTER" | "FACEBOOK" | "INSTAGRAM" | "OTHER";
78
+
79
+ export interface Organization {
80
+ id: number;
81
+ name: string;
82
+ workspaceType: WorkspaceType;
83
+ subscriptionTier: SubscriptionTier;
84
+ createdByUserId: number | null; // null = system-created organization
85
+ imageUrl: string | null;
86
+ createdAt: Date;
87
+ }
88
+
89
+ export type WorkspaceType = "INDIVIDUALS" | "BUSINESS";
90
+ export type SubscriptionTier = "PRO_VERSION" | "WAITING_FOR_SUBSCRIPTION_SELECTION";
91
+
92
+ export interface OrganizationMember {
93
+ id: number;
94
+ organizationId: number;
95
+ userId: number;
96
+ contributionRole: ContributionRole;
97
+ permissionsRole: PermissionsRole;
98
+ createdAt: Date;
99
+ }
100
+
101
+ export type ContributionRole = "VISITOR" | "CONTRIBUTOR";
102
+ export type PermissionsRole = "REGULAR" | "ADMIN";
103
+
104
+ export interface OrganizationUserRelationshipsAssignment {
105
+ id: number;
106
+ organizationId: number;
107
+ linkedinRelationshipId: number;
108
+ createdAt: Date;
109
+ }
110
+
111
+ export interface LinkedinRelationship {
112
+ id: number;
113
+ linkedinAccountIdA: number;
114
+ linkedinAccountIdB: number;
115
+ score: number;
116
+ modelVersion: string;
117
+ analysisType: string;
118
+ mappingJobId: number;
119
+ metadata: Record<string, any>;
120
+ createdAt: Date;
121
+ }
122
+
123
+ export interface MappingJob {
124
+ id: number;
125
+ linkedinAccountId: number;
126
+ companyMappingJobId: number | null;
127
+ recursiveMappingJobId: number | null;
128
+ metadata: Record<string, any>;
129
+ createdAt: Date;
130
+ queuedAt: Date | null;
131
+ startedAt: Date | null;
132
+ completedAt: Date | null;
133
+ }
134
+
135
+ export interface LlmInferenceJob {
136
+ id: number;
137
+ mappingJobId: number;
138
+ metadata: Record<string, any>;
139
+ createdAt: Date;
140
+ queuedAt: Date | null;
141
+ startedAt: Date | null;
142
+ completedAt: Date | null;
143
+ failedAt: Date | null;
144
+ status: string | null;
145
+ }
146
+
147
+ export interface SalesPipeline {
148
+ id: number;
149
+ organizationId: number;
150
+ linkedinRelationshipId: number;
151
+ createdAt: Date;
152
+ }
153
+
154
+ export interface SalesPipelineAssignment {
155
+ id: number;
156
+ salesPipelineId: number;
157
+ organizationUserRelationshipAssignmentId: number;
158
+ stage: SalesStage;
159
+ createdAt: Date;
160
+ updatedAt: Date;
161
+ }
162
+
163
+ export type SalesStage =
164
+ | "prospect"
165
+ | "qualified"
166
+ | "proposal"
167
+ | "negotiation"
168
+ | "closed_won"
169
+ | "closed_lost";
170
+
171
+ export interface OrganizationAssignmentJob {
172
+ id: number;
173
+ organizationId: number;
174
+ mappingJobId: number;
175
+ metadata: Record<string, any>;
176
+ createdAt: Date;
177
+ startedAt: Date | null;
178
+ completedAt: Date | null;
179
+ }
180
+
181
+ export interface OnboardingJob {
182
+ id: number;
183
+ userId: number;
184
+ currentStep: string;
185
+ nextStep: string | null;
186
+ createdAt: Date;
187
+ updatedAt: Date;
188
+ completedAt: Date | null;
189
+ metadata: Record<string, any>;
190
+ }
191
+
192
+ export interface LinkedinWorkExperience {
193
+ id: number;
194
+ linkedinAccountId: number;
195
+ companyName: string;
196
+ companyLinkedinUrl: string | null;
197
+ title: string | null;
198
+ description: string | null;
199
+ location: string | null;
200
+ startDate: Date | null;
201
+ endDate: Date | null;
202
+ isCurrent: boolean;
203
+ createdAt: Date;
204
+ }
205
+
206
+ export interface LinkedinEducation {
207
+ id: number;
208
+ linkedinAccountId: number;
209
+ schoolName: string;
210
+ schoolLinkedinUrl: string | null;
211
+ degree: string | null;
212
+ fieldOfStudy: string | null;
213
+ startDate: Date | null;
214
+ endDate: Date | null;
215
+ grade: string | null;
216
+ activitiesAndSocieties: string | null;
217
+ description: string | null;
218
+ createdAt: Date;
219
+ }
220
+
221
+ export interface LinkedinCertification {
222
+ id: number;
223
+ linkedinAccountId: number;
224
+ certificationName: string;
225
+ authority: string | null;
226
+ licenseNumber: string | null;
227
+ url: string | null;
228
+ startDate: Date | null;
229
+ endDate: Date | null;
230
+ createdAt: Date;
231
+ }
232
+
233
+ export interface LinkedinProject {
234
+ id: number;
235
+ linkedinAccountId: number;
236
+ title: string;
237
+ description: string | null;
238
+ url: string | null;
239
+ startDate: Date | null;
240
+ endDate: Date | null;
241
+ createdAt: Date;
242
+ }
243
+
244
+ export interface Skill {
245
+ id: number;
246
+ name: string;
247
+ normalizedName: string;
248
+ createdAt: Date;
249
+ }
250
+
251
+ export interface LinkedinProfileSkill {
252
+ id: number;
253
+ linkedinAccountId: number;
254
+ skillId: number;
255
+ displayName: string;
256
+ createdAt: Date;
257
+ }
258
+
259
+ export interface LinkedinWorkExperienceSkill {
260
+ id: number;
261
+ workExperienceId: number;
262
+ skillId: number;
263
+ displayName: string;
264
+ createdAt: Date;
265
+ }
266
+
267
+ export interface LinkedinEducationSkill {
268
+ id: number;
269
+ educationId: number;
270
+ skillId: number;
271
+ displayName: string;
272
+ createdAt: Date;
273
+ }
274
+
275
+ export interface IntroductionRequest {
276
+ id: number;
277
+ requesterUserId: number;
278
+ requesterLinkedinAccountId: number;
279
+ facilitatorUserId: number;
280
+ facilitatorLinkedinAccountId: number;
281
+ targetLinkedinAccountId: number;
282
+ message: string | null;
283
+ context: string | null;
284
+ status: IntroductionRequestStatus;
285
+ createdAt: Date;
286
+ updatedAt: Date;
287
+ respondedAt: Date | null;
288
+ seenAt: Date | null;
289
+ }
290
+
291
+ export type IntroductionRequestStatus = "PENDING" | "ACCEPTED" | "REJECTED" | "CANCELLED";
292
+
293
+ export interface Invitation {
294
+ id: number;
295
+ organizationId: number;
296
+ inviterUserId: number;
297
+ inviteeName: string;
298
+ inviteeEmail: string;
299
+ inviteeRole: string;
300
+ token: string;
301
+ status: InvitationStatus;
302
+ expiresAt: Date;
303
+ usedAt: Date | null;
304
+ usedByUserId: number | null;
305
+ shadowUserId: number | null;
306
+ createdAt: Date;
307
+ updatedAt: Date;
308
+ }
309
+
310
+ export type InvitationStatus = "PENDING" | "ACCEPTED" | "EXPIRED" | "REVOKED";
311
+
312
+ export interface Industry {
313
+ id: number;
314
+ name: string;
315
+ createdAt: Date;
316
+ }
317
+
318
+ export interface UserIndustryAssignment {
319
+ id: number;
320
+ userId: number;
321
+ industryId: number;
322
+ createdAt: Date;
323
+ }
324
+
325
+ // New type exports (previously generated by Drizzle)
326
+ export type NewUser = Omit<User, "id" | "createdAt">;
327
+ export type NewAuthenticatedUser = Omit<AuthenticatedUser, "id" | "createdAt">;
328
+ export type NewContactInfo = Omit<ContactInfo, "id" | "createdAt">;
329
+ export type NewLinkedinAccount = Omit<LinkedinAccount, "id" | "createdAt">;
330
+ export type NewUnipileAccount = Omit<UnipileAccount, "id" | "createdAt" | "updatedAt">;
331
+ export type NewOrganization = Omit<Organization, "id" | "createdAt">;
332
+ export type NewOrganizationMember = Omit<OrganizationMember, "id" | "createdAt">;
333
+ export type NewLinkedinRelationship = Omit<LinkedinRelationship, "id" | "createdAt">;
334
+ export type NewMappingJob = Omit<MappingJob, "id" | "createdAt">;
335
+ export type NewLlmInferenceJob = Omit<LlmInferenceJob, "id" | "createdAt">;
336
+ export type NewOnboardingJob = Omit<OnboardingJob, "id" | "createdAt" | "updatedAt">;
337
+ export type NewLinkedinWorkExperience = Omit<LinkedinWorkExperience, "id" | "createdAt">;
338
+ export type NewLinkedinEducation = Omit<LinkedinEducation, "id" | "createdAt">;
339
+ export type NewIntroductionRequest = Omit<IntroductionRequest, "id" | "createdAt" | "updatedAt">;
340
+ export type NewInvitation = Omit<Invitation, "id" | "createdAt" | "updatedAt">;
package/dist/seed.d.ts ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * =============================================================================
3
+ * DATABASE SEED SCRIPT
4
+ * =============================================================================
5
+ * Seed script - currently empty
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=seed.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.d.ts","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
package/dist/seed.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * =============================================================================
4
+ * DATABASE SEED SCRIPT
5
+ * =============================================================================
6
+ * Seed script - currently empty
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const database_service_1 = require("./lib/database-service");
10
+ async function main() {
11
+ console.log("🌱 Database seed script (empty)");
12
+ try {
13
+ // Initialize database service with environment variable for development
14
+ if (!process.env.DATABASE_URL) {
15
+ throw new Error("DATABASE_URL environment variable is required for seeding");
16
+ }
17
+ await database_service_1.dbService.initialize({
18
+ connection: {
19
+ databaseUrl: process.env.DATABASE_URL,
20
+ },
21
+ });
22
+ // No seeding logic - add your own data seeding here if needed
23
+ // const db = await dbService.getDb(); // Uncomment when adding actual seeding logic
24
+ console.log("✅ No seeding performed");
25
+ }
26
+ catch (error) {
27
+ console.error("❌ Seed failed:", error);
28
+ throw error;
29
+ }
30
+ }
31
+ main()
32
+ .then(() => {
33
+ console.log("✨ Seed completed!");
34
+ process.exit(0);
35
+ })
36
+ .catch(error => {
37
+ console.error("💥 Seed error:", error);
38
+ process.exit(1);
39
+ });
40
+ //# sourceMappingURL=seed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"seed.js","sourceRoot":"","sources":["../src/seed.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAEH,6DAAmD;AAEnD,KAAK,UAAU,IAAI;IACjB,OAAO,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;IAE/C,IAAI,CAAC;QACH,wEAAwE;QACxE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QAED,MAAM,4BAAS,CAAC,UAAU,CAAC;YACzB,UAAU,EAAE;gBACV,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,YAAY;aACtC;SACF,CAAC,CAAC;QAEH,8DAA8D;QAC9D,oFAAoF;QACpF,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACxC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;QACvC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,IAAI,EAAE;KACH,IAAI,CAAC,GAAG,EAAE;IACT,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC;KACD,KAAK,CAAC,KAAK,CAAC,EAAE;IACb,OAAO,CAAC,KAAK,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;IACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * =============================================================================
3
+ * TYPE EXPORTS - TypeScript Type Definitions
4
+ * =============================================================================
5
+ */
6
+ export * from "./types";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ /**
3
+ * =============================================================================
4
+ * TYPE EXPORTS - TypeScript Type Definitions
5
+ * =============================================================================
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ __exportStar(require("./types"), exports);
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAEH,0CAAwB"}
@@ -0,0 +1,77 @@
1
+ import type { AuthenticatedUser, UnipileAccount, SocialPlatformType } from "../lib/schema";
2
+ /**
3
+ * Type for authenticated user with their social accounts
4
+ */
5
+ export type UserWithAccounts = AuthenticatedUser & {
6
+ unipileAccounts: UnipileAccount[];
7
+ };
8
+ /**
9
+ * Type for active social accounts only
10
+ */
11
+ export type ActiveUnipileAccount = UnipileAccount & {
12
+ isActive: true;
13
+ };
14
+ /**
15
+ * Platform statistics type
16
+ */
17
+ export interface PlatformStats {
18
+ platformType: SocialPlatformType;
19
+ totalAccounts: number;
20
+ activeAccounts: number;
21
+ }
22
+ /**
23
+ * User creation input
24
+ */
25
+ export interface CreateUserInput {
26
+ cognitoUserId: string;
27
+ email: string;
28
+ name: string;
29
+ }
30
+ /**
31
+ * Social account connection input
32
+ */
33
+ export interface ConnectAccountInput {
34
+ userId: number;
35
+ unipileAccountId: string;
36
+ platformType: SocialPlatformType;
37
+ accountIdentifier?: string;
38
+ metadata?: Record<string, any>;
39
+ }
40
+ /**
41
+ * Account metadata types for different platforms
42
+ */
43
+ export interface LinkedInMetadata {
44
+ profileUrl?: string;
45
+ connections?: number;
46
+ premium?: boolean;
47
+ industry?: string;
48
+ }
49
+ export interface WhatsAppMetadata {
50
+ businessAccount?: boolean;
51
+ verified?: boolean;
52
+ phoneNumber?: string;
53
+ }
54
+ export interface TwitterMetadata {
55
+ followers?: number;
56
+ following?: number;
57
+ verified?: boolean;
58
+ handle?: string;
59
+ }
60
+ export interface InstagramMetadata {
61
+ followers?: number;
62
+ following?: number;
63
+ posts?: number;
64
+ businessAccount?: boolean;
65
+ verified?: boolean;
66
+ }
67
+ export interface FacebookMetadata {
68
+ friends?: number;
69
+ pageId?: string;
70
+ businessAccount?: boolean;
71
+ verified?: boolean;
72
+ }
73
+ /**
74
+ * Union type for all platform metadata
75
+ */
76
+ export type PlatformMetadata = LinkedInMetadata | WhatsAppMetadata | TwitterMetadata | InstagramMetadata | FacebookMetadata;
77
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3F;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,iBAAiB,GAAG;IACjD,eAAe,EAAE,cAAc,EAAE,CAAC;CACnC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,cAAc,GAAG;IAClD,QAAQ,EAAE,IAAI,CAAC;CAChB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,kBAAkB,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAA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AM,MAAM,gBAAgB,GACxB,gBAAgB,GAChB,gBAAgB,GAChB,eAAe,GACf,iBAAiB,GACjB,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,110 @@
1
+ /**
2
+ * =============================================================================
3
+ * AUTHENTICATED USER OPERATIONS UTILITIES
4
+ * =============================================================================
5
+ * Utility functions for managing authenticated users table operations
6
+ */
7
+ import { Pool, PoolClient } from "pg";
8
+ import type { Database } from "../lib/db";
9
+ import { type AuthenticatedUser } from "../lib/schema";
10
+ /**
11
+ * Finds an authenticated user record by Cognito User ID
12
+ *
13
+ * This function queries the authenticated_users table specifically and returns
14
+ * the authenticated user record which contains:
15
+ * - id: Primary key of authenticated_users table
16
+ * - userId: Foreign key linking to the users table (use this for social accounts)
17
+ * - cognitoUserId: The Cognito ID for authentication
18
+ *
19
+ * @param cognitoUserId - The Cognito User ID to search for
20
+ * @returns Promise resolving to authenticated user record or null if not found
21
+ */
22
+ export declare function findAuthenticatedUserByCognitoId(db: Database | Pool | PoolClient, cognitoUserId: string): Promise<AuthenticatedUser | null>;
23
+ /**
24
+ * Finds an authenticated user record by authenticated user ID
25
+ *
26
+ * @param authenticatedUserId - The authenticated_users.id to search for
27
+ * @returns Promise resolving to authenticated user record or null if not found
28
+ */
29
+ export declare function findAuthenticatedUserById(db: Database | Pool | PoolClient, authenticatedUserId: number): Promise<AuthenticatedUser | null>;
30
+ /**
31
+ * Finds an authenticated user record by user ID (foreign key to users table)
32
+ *
33
+ * @param userId - The authenticated_users.user_id to search for
34
+ * @returns Promise resolving to authenticated user record or null if not found
35
+ */
36
+ export declare function findAuthenticatedUserByUserId(db: Database | Pool | PoolClient, userId: number): Promise<AuthenticatedUser | null>;
37
+ /**
38
+ * Finds an authenticated user by Forager ID (Primary method)
39
+ *
40
+ * This function performs the complete chain lookup:
41
+ * Forager ID → linkedin_account → user → authenticated_user
42
+ *
43
+ * Used by pre-signup validation to prevent duplicate accounts when a user
44
+ * already has an authenticated account linked to their LinkedIn profile.
45
+ *
46
+ * @param foragerId - Forager ID (integer)
47
+ * @returns Promise resolving to authenticated user details or null if not found
48
+ */
49
+ export declare function findAuthenticatedUserByForagerId(db: Database, foragerId: number): Promise<{
50
+ user_id: number;
51
+ linkedin_account_id: number;
52
+ cognito_user_id: string;
53
+ } | null>;
54
+ /**
55
+ * Finds an authenticated user by public identifier (Fallback method)
56
+ *
57
+ * This function performs the complete chain lookup:
58
+ * Public identifier → linkedin_account → user → authenticated_user
59
+ *
60
+ * @param publicIdentifier - LinkedIn public identifier (e.g., "martin-mohammed-eggi")
61
+ * @returns Promise resolving to authenticated user details or null if not found
62
+ */
63
+ export declare function findAuthenticatedUserByPublicIdentifier(db: Database, publicIdentifier: string): Promise<{
64
+ user_id: number;
65
+ linkedin_account_id: number;
66
+ cognito_user_id: string;
67
+ } | null>;
68
+ /**
69
+ * Finds an authenticated user by any identifier (Forager ID, public identifier, or ACoA)
70
+ * Priority: forager_id > public_identifier > linkedin_identifier_acoa
71
+ *
72
+ * @param identifier - Forager ID (number), public identifier (string), or ACoA (string)
73
+ * @returns Promise resolving to authenticated user details or null if not found
74
+ */
75
+ export declare function findAuthenticatedUserByAnyIdentifier(db: Database, identifier: string | number): Promise<{
76
+ user_id: number;
77
+ linkedin_account_id: number;
78
+ cognito_user_id: string;
79
+ } | null>;
80
+ /**
81
+ * Creates a new authenticated user record
82
+ *
83
+ * @param db - Database connection
84
+ * @param params - Parameters for creating authenticated user
85
+ * @returns Promise resolving to the created authenticated user record
86
+ */
87
+ export declare function createAuthenticatedUser(db: Database, params: {
88
+ userId?: number;
89
+ cognitoUserId: string;
90
+ contactInfoId?: number;
91
+ authProvider?: string;
92
+ }): Promise<AuthenticatedUser>;
93
+ /**
94
+ * Updates the admin status for an authenticated user
95
+ *
96
+ * @param db - Database connection
97
+ * @param cognitoUserId - The Cognito User ID to update
98
+ * @param isAdmin - The new admin status (true/false)
99
+ * @returns Promise resolving to the updated authenticated user record or null if not found
100
+ */
101
+ export declare function updateAuthenticatedUserAdminStatus(db: Database | Pool | PoolClient, cognitoUserId: string, isAdmin: boolean): Promise<AuthenticatedUser | null>;
102
+ /**
103
+ * Gets all admin users (users with is_admin = true and user_id is not null)
104
+ * Used for automatically assigning admins to newly created organizations
105
+ *
106
+ * @param db - Database connection
107
+ * @returns Promise resolving to array of authenticated user records with user_id
108
+ */
109
+ export declare function getAllAdminUsers(db: Database | Pool | PoolClient): Promise<AuthenticatedUser[]>;
110
+ //# sourceMappingURL=authenticated-user-operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authenticated-user-operations.d.ts","sourceRoot":"","sources":["../../src/utils/authenticated-user-operations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAEtC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAiBvD;;;;;;;;;;;GAWG;AACH,wBAAsB,gCAAgC,CACpD,EAAE,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,EAChC,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAUnC;AAED;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,EAChC,mBAAmB,EAAE,MAAM,GAC1B,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAUnC;AAED;;;;;GAKG;AACH,wBAAsB,6BAA6B,CACjD,EAAE,EAAE,QAAQ,GAAG,IAAI,GAAG,UAAU,EAChC,MAAM,EAAE,MAAM,GACb,O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