@friggframework/core 2.0.0--canary.463.62579dd.0 → 2.0.0--canary.461.84ff4f5.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.
- package/README.md +28 -0
- package/database/prisma.js +2 -2
- package/database/use-cases/run-database-migration-use-case.js +137 -0
- package/database/use-cases/run-database-migration-use-case.test.js +310 -0
- package/database/utils/prisma-runner.js +377 -0
- package/database/utils/prisma-runner.test.js +486 -0
- package/handlers/backend-utils.js +29 -41
- package/handlers/workers/db-migration.js +208 -0
- package/handlers/workers/db-migration.test.js +437 -0
- package/integrations/repositories/process-repository-postgres.js +2 -2
- package/package.json +18 -9
- package/prisma-mongodb/schema.prisma +22 -20
- package/prisma-postgresql/schema.prisma +16 -14
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.
|
|
4
|
+
"version": "2.0.0--canary.461.84ff4f5.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
|
-
"@prisma/client": "^6.16.3",
|
|
8
7
|
"bcryptjs": "^2.4.3",
|
|
9
8
|
"body-parser": "^1.20.2",
|
|
9
|
+
"chalk": "^4.1.2",
|
|
10
10
|
"common-tags": "^1.8.2",
|
|
11
11
|
"cors": "^2.8.5",
|
|
12
12
|
"dotenv": "^16.4.7",
|
|
@@ -22,17 +22,26 @@
|
|
|
22
22
|
"uuid": "^9.0.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"
|
|
25
|
+
"@prisma/client": "^6.16.3",
|
|
26
|
+
"aws-sdk": "^2.1200.0",
|
|
27
|
+
"prisma": "^6.16.3"
|
|
26
28
|
},
|
|
27
29
|
"peerDependenciesMeta": {
|
|
30
|
+
"@prisma/client": {
|
|
31
|
+
"optional": true
|
|
32
|
+
},
|
|
33
|
+
"prisma": {
|
|
34
|
+
"optional": true
|
|
35
|
+
},
|
|
28
36
|
"aws-sdk": {
|
|
29
37
|
"optional": true
|
|
30
38
|
}
|
|
31
39
|
},
|
|
32
40
|
"devDependencies": {
|
|
33
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
34
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
35
|
-
"@friggframework/test": "2.0.0--canary.
|
|
41
|
+
"@friggframework/eslint-config": "2.0.0--canary.461.84ff4f5.0",
|
|
42
|
+
"@friggframework/prettier-config": "2.0.0--canary.461.84ff4f5.0",
|
|
43
|
+
"@friggframework/test": "2.0.0--canary.461.84ff4f5.0",
|
|
44
|
+
"@prisma/client": "^6.17.0",
|
|
36
45
|
"@types/lodash": "4.17.15",
|
|
37
46
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
38
47
|
"chai": "^4.3.6",
|
|
@@ -42,7 +51,7 @@
|
|
|
42
51
|
"eslint-plugin-promise": "^7.0.0",
|
|
43
52
|
"jest": "^29.7.0",
|
|
44
53
|
"prettier": "^2.7.1",
|
|
45
|
-
"prisma": "^6.
|
|
54
|
+
"prisma": "^6.17.0",
|
|
46
55
|
"sinon": "^16.1.1",
|
|
47
56
|
"typescript": "^5.0.2"
|
|
48
57
|
},
|
|
@@ -54,7 +63,7 @@
|
|
|
54
63
|
"prisma:generate": "npm run prisma:generate:mongo && npm run prisma:generate:postgres",
|
|
55
64
|
"prisma:push:mongo": "npx prisma db push --schema ./prisma-mongodb/schema.prisma",
|
|
56
65
|
"prisma:migrate:postgres": "npx prisma migrate dev --schema ./prisma-postgresql/schema.prisma",
|
|
57
|
-
"
|
|
66
|
+
"prepublishOnly": "npm run prisma:generate"
|
|
58
67
|
},
|
|
59
68
|
"author": "",
|
|
60
69
|
"license": "MIT",
|
|
@@ -71,5 +80,5 @@
|
|
|
71
80
|
"publishConfig": {
|
|
72
81
|
"access": "public"
|
|
73
82
|
},
|
|
74
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "84ff4f5a8ab85a143a491d4337965e534c1a73fb"
|
|
75
84
|
}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
// Migration from Mongoose ODM to Prisma ORM
|
|
4
4
|
|
|
5
5
|
generator client {
|
|
6
|
-
provider
|
|
7
|
-
output
|
|
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)
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
datasource db {
|
|
@@ -19,8 +21,8 @@ datasource db {
|
|
|
19
21
|
/// User model with discriminator pattern support
|
|
20
22
|
/// Replaces Mongoose discriminators (IndividualUser, OrganizationUser)
|
|
21
23
|
model User {
|
|
22
|
-
id
|
|
23
|
-
type
|
|
24
|
+
id String @id @default(auto()) @map("_id") @db.ObjectId
|
|
25
|
+
type UserType
|
|
24
26
|
|
|
25
27
|
// Timestamps
|
|
26
28
|
createdAt DateTime @default(now())
|
|
@@ -87,12 +89,12 @@ model Token {
|
|
|
87
89
|
/// OAuth credentials and API tokens
|
|
88
90
|
/// All sensitive data encrypted with KMS at rest
|
|
89
91
|
model Credential {
|
|
90
|
-
id
|
|
91
|
-
userId
|
|
92
|
-
user
|
|
93
|
-
subType
|
|
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?
|
|
94
96
|
authIsValid Boolean?
|
|
95
|
-
externalId
|
|
97
|
+
externalId String?
|
|
96
98
|
|
|
97
99
|
// Dynamic OAuth fields stored as JSON (encrypted via Prisma middleware)
|
|
98
100
|
// Contains: access_token, refresh_token, domain, expires_in, token_type, etc.
|
|
@@ -125,11 +127,11 @@ model Entity {
|
|
|
125
127
|
updatedAt DateTime @updatedAt
|
|
126
128
|
|
|
127
129
|
// Relations - many-to-many with scalar lists
|
|
128
|
-
integrations
|
|
129
|
-
integrationIds
|
|
130
|
+
integrations Integration[] @relation("IntegrationEntities", fields: [integrationIds], references: [id])
|
|
131
|
+
integrationIds String[] @db.ObjectId
|
|
130
132
|
|
|
131
|
-
syncs
|
|
132
|
-
syncIds
|
|
133
|
+
syncs Sync[] @relation("SyncEntities", fields: [syncIds], references: [id])
|
|
134
|
+
syncIds String[] @db.ObjectId
|
|
133
135
|
|
|
134
136
|
dataIdentifiers DataIdentifier[]
|
|
135
137
|
associationObjects AssociationObject[]
|
|
@@ -153,7 +155,7 @@ model Integration {
|
|
|
153
155
|
status IntegrationStatus @default(ENABLED)
|
|
154
156
|
|
|
155
157
|
// Configuration and version
|
|
156
|
-
config Json?
|
|
158
|
+
config Json? // Integration configuration object
|
|
157
159
|
version String?
|
|
158
160
|
|
|
159
161
|
// Entity references (many-to-many via explicit scalar list)
|
|
@@ -320,11 +322,11 @@ model Association {
|
|
|
320
322
|
/// Association object entry
|
|
321
323
|
/// Replaces nested array structure in Mongoose
|
|
322
324
|
model AssociationObject {
|
|
323
|
-
id String
|
|
324
|
-
associationId String
|
|
325
|
-
association Association
|
|
326
|
-
entityId String
|
|
327
|
-
entity Entity
|
|
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)
|
|
328
330
|
objectType String
|
|
329
331
|
objId String
|
|
330
332
|
metadata Json? // Optional metadata
|
|
@@ -359,4 +361,4 @@ model WebsocketConnection {
|
|
|
359
361
|
|
|
360
362
|
@@index([connectionId])
|
|
361
363
|
@@map("WebsocketConnection")
|
|
362
|
-
}
|
|
364
|
+
}
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
// Converted from MongoDB schema for relational database support
|
|
4
4
|
|
|
5
5
|
generator client {
|
|
6
|
-
provider
|
|
7
|
-
output
|
|
6
|
+
provider = "prisma-client-js"
|
|
7
|
+
output = "../generated/prisma-postgresql"
|
|
8
|
+
binaryTargets = ["native", "rhel-openssl-3.0.x"] // native for local dev, rhel for Lambda deployment
|
|
9
|
+
engineType = "binary" // Use binary engines (smaller size)
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
datasource db {
|
|
@@ -19,8 +21,8 @@ datasource db {
|
|
|
19
21
|
/// User model with discriminator pattern support
|
|
20
22
|
/// Replaces Mongoose discriminators (IndividualUser, OrganizationUser)
|
|
21
23
|
model User {
|
|
22
|
-
id
|
|
23
|
-
type
|
|
24
|
+
id Int @id @default(autoincrement())
|
|
25
|
+
type UserType
|
|
24
26
|
|
|
25
27
|
// Timestamps
|
|
26
28
|
createdAt DateTime @default(now())
|
|
@@ -85,12 +87,12 @@ model Token {
|
|
|
85
87
|
/// OAuth credentials and API tokens
|
|
86
88
|
/// All sensitive data encrypted with KMS at rest
|
|
87
89
|
model Credential {
|
|
88
|
-
id
|
|
89
|
-
userId
|
|
90
|
-
user
|
|
91
|
-
subType
|
|
90
|
+
id Int @id @default(autoincrement())
|
|
91
|
+
userId Int?
|
|
92
|
+
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
93
|
+
subType String?
|
|
92
94
|
authIsValid Boolean?
|
|
93
|
-
externalId
|
|
95
|
+
externalId String?
|
|
94
96
|
|
|
95
97
|
// Dynamic OAuth fields stored as JSON (encrypted via Prisma middleware)
|
|
96
98
|
// Contains: access_token, refresh_token, domain, expires_in, token_type, etc.
|
|
@@ -146,7 +148,7 @@ model Integration {
|
|
|
146
148
|
status IntegrationStatus @default(ENABLED)
|
|
147
149
|
|
|
148
150
|
// Configuration and version
|
|
149
|
-
config Json?
|
|
151
|
+
config Json? // Integration configuration object
|
|
150
152
|
version String?
|
|
151
153
|
|
|
152
154
|
// Entity references (many-to-many via implicit join table)
|
|
@@ -225,11 +227,11 @@ model Sync {
|
|
|
225
227
|
/// Data identifier for sync operations
|
|
226
228
|
/// Replaces nested array structure in Mongoose
|
|
227
229
|
model DataIdentifier {
|
|
228
|
-
id Int
|
|
230
|
+
id Int @id @default(autoincrement())
|
|
229
231
|
syncId Int?
|
|
230
|
-
sync Sync?
|
|
232
|
+
sync Sync? @relation(fields: [syncId], references: [id], onDelete: Cascade)
|
|
231
233
|
entityId Int
|
|
232
|
-
entity Entity
|
|
234
|
+
entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
|
|
233
235
|
|
|
234
236
|
// Identifier data (can be any structure)
|
|
235
237
|
idData Json
|
|
@@ -332,7 +334,7 @@ model Process {
|
|
|
332
334
|
|
|
333
335
|
/// Generic state storage
|
|
334
336
|
model State {
|
|
335
|
-
id Int
|
|
337
|
+
id Int @id @default(autoincrement())
|
|
336
338
|
state Json?
|
|
337
339
|
}
|
|
338
340
|
|