@friggframework/core 2.0.0--canary.461.61382d8.0 → 2.0.0--canary.461.5767fa4.0

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 (118) hide show
  1. package/generated/prisma-mongodb/client.d.ts +1 -0
  2. package/generated/prisma-mongodb/client.js +4 -0
  3. package/generated/prisma-mongodb/default.d.ts +1 -0
  4. package/generated/prisma-mongodb/default.js +4 -0
  5. package/generated/prisma-mongodb/edge.d.ts +1 -0
  6. package/generated/prisma-mongodb/edge.js +336 -0
  7. package/generated/prisma-mongodb/index-browser.js +318 -0
  8. package/generated/prisma-mongodb/index.d.ts +22993 -0
  9. package/generated/prisma-mongodb/index.js +361 -0
  10. package/generated/prisma-mongodb/package.json +183 -0
  11. package/generated/prisma-mongodb/query-engine-debian-openssl-3.0.x +0 -0
  12. package/generated/prisma-mongodb/query-engine-rhel-openssl-3.0.x +0 -0
  13. package/generated/prisma-mongodb/runtime/binary.d.ts +1 -0
  14. package/generated/prisma-mongodb/runtime/binary.js +289 -0
  15. package/generated/prisma-mongodb/runtime/edge-esm.js +34 -0
  16. package/generated/prisma-mongodb/runtime/edge.js +34 -0
  17. package/generated/prisma-mongodb/runtime/index-browser.d.ts +370 -0
  18. package/generated/prisma-mongodb/runtime/index-browser.js +16 -0
  19. package/generated/prisma-mongodb/runtime/library.d.ts +3977 -0
  20. package/generated/prisma-mongodb/runtime/react-native.js +83 -0
  21. package/generated/prisma-mongodb/runtime/wasm-compiler-edge.js +84 -0
  22. package/generated/prisma-mongodb/runtime/wasm-engine-edge.js +36 -0
  23. package/generated/prisma-mongodb/schema.prisma +364 -0
  24. package/generated/prisma-mongodb/wasm-edge-light-loader.mjs +4 -0
  25. package/generated/prisma-mongodb/wasm-worker-loader.mjs +4 -0
  26. package/generated/prisma-mongodb/wasm.d.ts +1 -0
  27. package/generated/prisma-mongodb/wasm.js +343 -0
  28. package/generated/prisma-postgresql/client.d.ts +1 -0
  29. package/generated/prisma-postgresql/client.js +4 -0
  30. package/generated/prisma-postgresql/default.d.ts +1 -0
  31. package/generated/prisma-postgresql/default.js +4 -0
  32. package/generated/prisma-postgresql/edge.d.ts +1 -0
  33. package/generated/prisma-postgresql/edge.js +358 -0
  34. package/generated/prisma-postgresql/index-browser.js +340 -0
  35. package/generated/prisma-postgresql/index.d.ts +25171 -0
  36. package/generated/prisma-postgresql/index.js +383 -0
  37. package/generated/prisma-postgresql/package.json +183 -0
  38. package/generated/prisma-postgresql/query-engine-debian-openssl-3.0.x +0 -0
  39. package/generated/prisma-postgresql/query-engine-rhel-openssl-3.0.x +0 -0
  40. package/generated/prisma-postgresql/query_engine_bg.js +2 -0
  41. package/generated/prisma-postgresql/query_engine_bg.wasm +0 -0
  42. package/generated/prisma-postgresql/runtime/binary.d.ts +1 -0
  43. package/generated/prisma-postgresql/runtime/binary.js +289 -0
  44. package/generated/prisma-postgresql/runtime/edge-esm.js +34 -0
  45. package/generated/prisma-postgresql/runtime/edge.js +34 -0
  46. package/generated/prisma-postgresql/runtime/index-browser.d.ts +370 -0
  47. package/generated/prisma-postgresql/runtime/index-browser.js +16 -0
  48. package/generated/prisma-postgresql/runtime/library.d.ts +3977 -0
  49. package/generated/prisma-postgresql/runtime/react-native.js +83 -0
  50. package/generated/prisma-postgresql/runtime/wasm-compiler-edge.js +84 -0
  51. package/generated/prisma-postgresql/runtime/wasm-engine-edge.js +36 -0
  52. package/generated/prisma-postgresql/schema.prisma +347 -0
  53. package/generated/prisma-postgresql/wasm-edge-light-loader.mjs +4 -0
  54. package/generated/prisma-postgresql/wasm-worker-loader.mjs +4 -0
  55. package/generated/prisma-postgresql/wasm.d.ts +1 -0
  56. package/generated/prisma-postgresql/wasm.js +365 -0
  57. package/package.json +5 -5
  58. package/application/commands/integration-commands.test.js +0 -123
  59. package/core/Worker.test.js +0 -159
  60. package/database/encryption/encryption-integration.test.js +0 -553
  61. package/database/encryption/encryption-schema-registry.test.js +0 -392
  62. package/database/encryption/field-encryption-service.test.js +0 -525
  63. package/database/encryption/mongo-decryption-fix-verification.test.js +0 -348
  64. package/database/encryption/postgres-decryption-fix-verification.test.js +0 -371
  65. package/database/encryption/postgres-relation-decryption.test.js +0 -245
  66. package/database/encryption/prisma-encryption-extension.test.js +0 -439
  67. package/database/repositories/migration-status-repository-s3.test.js +0 -158
  68. package/database/use-cases/check-encryption-health-use-case.test.js +0 -192
  69. package/database/use-cases/get-migration-status-use-case.test.js +0 -171
  70. package/database/use-cases/run-database-migration-use-case.test.js +0 -310
  71. package/database/use-cases/trigger-database-migration-use-case.test.js +0 -250
  72. package/database/utils/prisma-runner.test.js +0 -486
  73. package/encrypt/Cryptor.test.js +0 -144
  74. package/errors/base-error.test.js +0 -32
  75. package/errors/fetch-error.test.js +0 -79
  76. package/errors/halt-error.test.js +0 -11
  77. package/errors/validation-errors.test.js +0 -120
  78. package/handlers/auth-flow.integration.test.js +0 -147
  79. package/handlers/integration-event-dispatcher.test.js +0 -209
  80. package/handlers/routers/db-migration.test.js +0 -51
  81. package/handlers/routers/health.test.js +0 -210
  82. package/handlers/routers/integration-webhook-routers.test.js +0 -126
  83. package/handlers/use-cases/check-integrations-health-use-case.test.js +0 -125
  84. package/handlers/webhook-flow.integration.test.js +0 -356
  85. package/handlers/workers/db-migration.test.js +0 -50
  86. package/handlers/workers/integration-defined-workers.test.js +0 -184
  87. package/integrations/tests/integration-router-multi-auth.test.js +0 -369
  88. package/integrations/tests/use-cases/create-integration.test.js +0 -131
  89. package/integrations/tests/use-cases/delete-integration-for-user.test.js +0 -150
  90. package/integrations/tests/use-cases/find-integration-context-by-external-entity-id.test.js +0 -92
  91. package/integrations/tests/use-cases/get-integration-for-user.test.js +0 -150
  92. package/integrations/tests/use-cases/get-integration-instance.test.js +0 -176
  93. package/integrations/tests/use-cases/get-integrations-for-user.test.js +0 -176
  94. package/integrations/tests/use-cases/get-possible-integrations.test.js +0 -188
  95. package/integrations/tests/use-cases/update-integration-messages.test.js +0 -142
  96. package/integrations/tests/use-cases/update-integration-status.test.js +0 -103
  97. package/integrations/tests/use-cases/update-integration.test.js +0 -141
  98. package/integrations/use-cases/create-process.test.js +0 -178
  99. package/integrations/use-cases/get-process.test.js +0 -190
  100. package/integrations/use-cases/load-integration-context-full.test.js +0 -329
  101. package/integrations/use-cases/load-integration-context.test.js +0 -114
  102. package/integrations/use-cases/update-process-metrics.test.js +0 -308
  103. package/integrations/use-cases/update-process-state.test.js +0 -256
  104. package/lambda/TimeoutCatcher.test.js +0 -68
  105. package/logs/logger.test.js +0 -76
  106. package/modules/module-hydration.test.js +0 -205
  107. package/modules/requester/requester.test.js +0 -28
  108. package/queues/queuer-util.test.js +0 -132
  109. package/user/tests/use-cases/create-individual-user.test.js +0 -24
  110. package/user/tests/use-cases/create-organization-user.test.js +0 -28
  111. package/user/tests/use-cases/create-token-for-user-id.test.js +0 -19
  112. package/user/tests/use-cases/get-user-from-adopter-jwt.test.js +0 -113
  113. package/user/tests/use-cases/get-user-from-bearer-token.test.js +0 -64
  114. package/user/tests/use-cases/get-user-from-x-frigg-headers.test.js +0 -346
  115. package/user/tests/use-cases/login-user.test.js +0 -220
  116. package/user/tests/user-password-encryption-isolation.test.js +0 -237
  117. package/user/tests/user-password-hashing.test.js +0 -235
  118. package/websocket/repositories/websocket-connection-repository.test.js +0 -227
@@ -0,0 +1,364 @@
1
+ // Frigg Framework - Prisma Schema
2
+ // MongoDB database schema for enterprise integration platform
3
+ // Migration from Mongoose ODM to Prisma ORM
4
+
5
+ generator client {
6
+ provider = "prisma-client-js"
7
+ output = "../generated/prisma-mongodb"
8
+ binaryTargets = ["native", "rhel-openssl-3.0.x"] // native for local dev, rhel for Lambda deployment
9
+ engineType = "binary" // Use binary engines (smaller size)
10
+ }
11
+
12
+ datasource db {
13
+ provider = "mongodb"
14
+ url = env("DATABASE_URL")
15
+ }
16
+
17
+ // ============================================================================
18
+ // USER MODELS
19
+ // ============================================================================
20
+
21
+ /// User model with discriminator pattern support
22
+ /// Replaces Mongoose discriminators (IndividualUser, OrganizationUser)
23
+ model User {
24
+ id String @id @default(auto()) @map("_id") @db.ObjectId
25
+ type UserType
26
+
27
+ // Timestamps
28
+ createdAt DateTime @default(now())
29
+ updatedAt DateTime @updatedAt
30
+
31
+ // IndividualUser fields (nullable for organizations)
32
+ email String?
33
+ username String?
34
+ hashword String? // Bcrypt hashed password (handled in application layer)
35
+ appUserId String?
36
+ organizationId String? @db.ObjectId
37
+
38
+ // Self-referential relation for organization membership
39
+ organization User? @relation("OrgMembers", fields: [organizationId], references: [id], onDelete: NoAction, onUpdate: NoAction)
40
+ members User[] @relation("OrgMembers")
41
+
42
+ // OrganizationUser fields (nullable for individuals)
43
+ appOrgId String?
44
+ name String?
45
+
46
+ // Relations
47
+ tokens Token[]
48
+ credentials Credential[]
49
+ entities Entity[]
50
+ integrations Integration[]
51
+ processes Process[]
52
+
53
+ @@unique([email])
54
+ @@unique([username])
55
+ @@unique([appOrgId])
56
+ @@index([type])
57
+ @@index([appUserId])
58
+ @@map("User")
59
+ }
60
+
61
+ enum UserType {
62
+ INDIVIDUAL
63
+ ORGANIZATION
64
+ }
65
+
66
+ // ============================================================================
67
+ // AUTHENTICATION MODELS
68
+ // ============================================================================
69
+
70
+ /// Authentication tokens with expiration
71
+ /// Bcrypt hashed tokens stored (handled in application layer)
72
+ model Token {
73
+ id String @id @default(auto()) @map("_id") @db.ObjectId
74
+ token String // Bcrypt hashed
75
+ created DateTime @default(now())
76
+ expires DateTime?
77
+ userId String @db.ObjectId
78
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
79
+
80
+ @@index([userId])
81
+ @@index([expires])
82
+ @@map("Token")
83
+ }
84
+
85
+ // ============================================================================
86
+ // CREDENTIAL & ENTITY MODELS
87
+ // ============================================================================
88
+
89
+ /// OAuth credentials and API tokens
90
+ /// All sensitive data encrypted with KMS at rest
91
+ model Credential {
92
+ id String @id @default(auto()) @map("_id") @db.ObjectId
93
+ userId String? @db.ObjectId
94
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
95
+ subType String?
96
+ authIsValid Boolean?
97
+ externalId String?
98
+
99
+ // Dynamic OAuth fields stored as JSON (encrypted via Prisma middleware)
100
+ // Contains: access_token, refresh_token, domain, expires_in, token_type, etc.
101
+ data Json @default("{}")
102
+
103
+ createdAt DateTime @default(now())
104
+ updatedAt DateTime @updatedAt
105
+
106
+ // Relations
107
+ entities Entity[]
108
+
109
+ @@index([userId])
110
+ @@index([externalId])
111
+ @@map("Credential")
112
+ }
113
+
114
+ /// External service entities (API connections)
115
+ model Entity {
116
+ id String @id @default(auto()) @map("_id") @db.ObjectId
117
+ credentialId String? @db.ObjectId
118
+ credential Credential? @relation(fields: [credentialId], references: [id], onDelete: SetNull)
119
+ subType String?
120
+ userId String? @db.ObjectId
121
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
122
+ name String?
123
+ moduleName String?
124
+ externalId String?
125
+
126
+ createdAt DateTime @default(now())
127
+ updatedAt DateTime @updatedAt
128
+
129
+ // Relations - many-to-many with scalar lists
130
+ integrations Integration[] @relation("IntegrationEntities", fields: [integrationIds], references: [id])
131
+ integrationIds String[] @db.ObjectId
132
+
133
+ syncs Sync[] @relation("SyncEntities", fields: [syncIds], references: [id])
134
+ syncIds String[] @db.ObjectId
135
+
136
+ dataIdentifiers DataIdentifier[]
137
+ associationObjects AssociationObject[]
138
+
139
+ @@index([userId])
140
+ @@index([externalId])
141
+ @@index([moduleName])
142
+ @@index([credentialId])
143
+ @@map("Entity")
144
+ }
145
+
146
+ // ============================================================================
147
+ // INTEGRATION MODELS
148
+ // ============================================================================
149
+
150
+ /// Main integration configuration and state
151
+ model Integration {
152
+ id String @id @default(auto()) @map("_id") @db.ObjectId
153
+ userId String? @db.ObjectId
154
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
155
+ status IntegrationStatus @default(ENABLED)
156
+
157
+ // Configuration and version
158
+ config Json? // Integration configuration object
159
+ version String?
160
+
161
+ // Entity references (many-to-many via explicit scalar list)
162
+ entities Entity[] @relation("IntegrationEntities", fields: [entityIds], references: [id])
163
+ entityIds String[] @db.ObjectId
164
+
165
+ // Message arrays (stored as JSON)
166
+ errors Json @default("[]")
167
+ warnings Json @default("[]")
168
+ info Json @default("[]")
169
+ logs Json @default("[]")
170
+
171
+ createdAt DateTime @default(now())
172
+ updatedAt DateTime @updatedAt
173
+
174
+ // Relations
175
+ associations Association[]
176
+ syncs Sync[]
177
+ mappings IntegrationMapping[]
178
+ processes Process[]
179
+
180
+ @@index([userId])
181
+ @@index([status])
182
+ @@map("Integration")
183
+ }
184
+
185
+ enum IntegrationStatus {
186
+ ENABLED
187
+ NEEDS_CONFIG
188
+ PROCESSING
189
+ DISABLED
190
+ ERROR
191
+ }
192
+
193
+ /// Integration-specific data mappings
194
+ /// All mapping data encrypted with KMS
195
+ model IntegrationMapping {
196
+ id String @id @default(auto()) @map("_id") @db.ObjectId
197
+ integrationId String @db.ObjectId
198
+ integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)
199
+ sourceId String?
200
+
201
+ // Encrypted mapping data (handled via Prisma middleware)
202
+ mapping Json?
203
+
204
+ createdAt DateTime @default(now())
205
+ updatedAt DateTime @updatedAt
206
+
207
+ @@unique([integrationId, sourceId])
208
+ @@index([integrationId])
209
+ @@index([sourceId])
210
+ @@map("IntegrationMapping")
211
+ }
212
+
213
+ // ============================================================================
214
+ // PROCESS MODELS
215
+ // ============================================================================
216
+
217
+ /// Generic Process Model - tracks any long-running operation
218
+ /// Used for: CRM syncs, data migrations, bulk operations, etc.
219
+ model Process {
220
+ id String @id @default(auto()) @map("_id") @db.ObjectId
221
+
222
+ // Core references
223
+ userId String @db.ObjectId
224
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
225
+ integrationId String @db.ObjectId
226
+ integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)
227
+
228
+ // Process identification
229
+ name String // e.g., "zoho-crm-contact-sync", "pipedrive-lead-sync"
230
+ type String // e.g., "CRM_SYNC", "DATA_MIGRATION", "BULK_OPERATION"
231
+
232
+ // State machine
233
+ state String // Current state (integration-defined states)
234
+
235
+ // Flexible storage
236
+ context Json @default("{}") // Process-specific data (pagination, metadata, etc.)
237
+ results Json @default("{}") // Process results and metrics
238
+
239
+ // Hierarchy support
240
+ childProcesses String[] @db.ObjectId
241
+ parentProcessId String? @db.ObjectId
242
+
243
+ // Timestamps
244
+ createdAt DateTime @default(now())
245
+ updatedAt DateTime @updatedAt
246
+
247
+ @@index([userId])
248
+ @@index([integrationId])
249
+ @@index([type])
250
+ @@index([state])
251
+ @@index([name])
252
+ @@map("Process")
253
+ }
254
+
255
+ // ============================================================================
256
+ // SYNC MODELS
257
+ // ============================================================================
258
+
259
+ /// Bidirectional data synchronization tracking
260
+ model Sync {
261
+ id String @id @default(auto()) @map("_id") @db.ObjectId
262
+ integrationId String? @db.ObjectId
263
+ integration Integration? @relation(fields: [integrationId], references: [id], onDelete: Cascade)
264
+
265
+ // Entity references (many-to-many via explicit scalar list)
266
+ entities Entity[] @relation("SyncEntities", fields: [entityIds], references: [id])
267
+ entityIds String[] @db.ObjectId
268
+
269
+ hash String
270
+ name String
271
+
272
+ // Data identifiers (extracted to separate model)
273
+ dataIdentifiers DataIdentifier[]
274
+
275
+ @@index([integrationId])
276
+ @@index([hash])
277
+ @@index([name])
278
+ @@map("Sync")
279
+ }
280
+
281
+ /// Data identifier for sync operations
282
+ /// Replaces nested array structure in Mongoose
283
+ model DataIdentifier {
284
+ id String @id @default(auto()) @map("_id") @db.ObjectId
285
+ syncId String? @db.ObjectId
286
+ sync Sync? @relation(fields: [syncId], references: [id], onDelete: Cascade)
287
+ entityId String @db.ObjectId
288
+ entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
289
+
290
+ // Identifier data (can be any structure)
291
+ idData Json
292
+
293
+ hash String
294
+
295
+ @@index([syncId])
296
+ @@index([entityId])
297
+ @@index([hash])
298
+ @@map("DataIdentifier")
299
+ }
300
+
301
+ // ============================================================================
302
+ // ASSOCIATION MODELS
303
+ // ============================================================================
304
+
305
+ /// Entity associations with cardinality tracking
306
+ model Association {
307
+ id String @id @default(auto()) @map("_id") @db.ObjectId
308
+ integrationId String @db.ObjectId
309
+ integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)
310
+ name String
311
+ type AssociationType
312
+ primaryObject String
313
+
314
+ // Associated objects (extracted to separate model)
315
+ objects AssociationObject[]
316
+
317
+ @@index([integrationId])
318
+ @@index([name])
319
+ @@map("Association")
320
+ }
321
+
322
+ /// Association object entry
323
+ /// Replaces nested array structure in Mongoose
324
+ model AssociationObject {
325
+ id String @id @default(auto()) @map("_id") @db.ObjectId
326
+ associationId String @db.ObjectId
327
+ association Association @relation(fields: [associationId], references: [id], onDelete: Cascade)
328
+ entityId String @db.ObjectId
329
+ entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
330
+ objectType String
331
+ objId String
332
+ metadata Json? // Optional metadata
333
+
334
+ @@index([associationId])
335
+ @@index([entityId])
336
+ @@map("AssociationObject")
337
+ }
338
+
339
+ enum AssociationType {
340
+ ONE_TO_MANY
341
+ ONE_TO_ONE
342
+ MANY_TO_ONE
343
+ }
344
+
345
+ // ============================================================================
346
+ // UTILITY MODELS
347
+ // ============================================================================
348
+
349
+ /// Generic state storage
350
+ model State {
351
+ id String @id @default(auto()) @map("_id") @db.ObjectId
352
+ state Json?
353
+
354
+ @@map("State")
355
+ }
356
+
357
+ /// AWS API Gateway WebSocket connection tracking
358
+ model WebsocketConnection {
359
+ id String @id @default(auto()) @map("_id") @db.ObjectId
360
+ connectionId String?
361
+
362
+ @@index([connectionId])
363
+ @@map("WebsocketConnection")
364
+ }
@@ -0,0 +1,4 @@
1
+
2
+ /* !!! This is code generated by Prisma. Do not edit directly. !!!
3
+ /* eslint-disable */
4
+ export default import('./query_engine_bg.wasm?module')
@@ -0,0 +1,4 @@
1
+
2
+ /* !!! This is code generated by Prisma. Do not edit directly. !!!
3
+ /* eslint-disable */
4
+ export default import('./query_engine_bg.wasm')
@@ -0,0 +1 @@
1
+ export * from "./default"