@friggframework/core 2.0.0--canary.454.1b45c13.0 → 2.0.0--canary.454.29d031a.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 CHANGED
@@ -62,6 +62,34 @@ npm install @friggframework/core
62
62
  yarn add @friggframework/core
63
63
  ```
64
64
 
65
+ ### Prisma Support (Optional)
66
+
67
+ `@friggframework/core` supports both MongoDB and PostgreSQL via Prisma ORM. **Prisma is an optional peer dependency** - you only need to install it if you're using database features that require migrations or schema generation.
68
+
69
+ **When you need Prisma:**
70
+ - Running database migrations (`prisma migrate`, `prisma db push`)
71
+ - Generating Prisma clients for your application
72
+ - Using the migration Lambda function (`dbMigrate`)
73
+
74
+ **Installation:**
75
+ ```bash
76
+ # Install Prisma CLI and Client as dev dependencies
77
+ npm install --save-dev prisma @prisma/client
78
+
79
+ # Or with yarn
80
+ yarn add -D prisma @prisma/client
81
+ ```
82
+
83
+ **Generate Prisma Clients:**
84
+ ```bash
85
+ # From @friggframework/core directory
86
+ npm run prisma:generate:mongo # MongoDB only
87
+ npm run prisma:generate:postgres # PostgreSQL only
88
+ npm run prisma:generate # Both databases
89
+ ```
90
+
91
+ **Note:** The published npm package includes pre-generated Prisma clients, so you don't need to install Prisma just to use `@friggframework/core` in production. Prisma is only required if you're actively developing migrations or running the migration Lambda function.
92
+
65
93
  ### Prerequisites
66
94
 
67
95
  - Node.js 16+
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.454.1b45c13.0",
4
+ "version": "2.0.0--canary.454.29d031a.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
+ "@prisma/client": "^6.16.3",
7
8
  "aws-sdk": "^2.1200.0",
8
9
  "bcryptjs": "^2.4.3",
9
10
  "body-parser": "^1.20.2",
@@ -19,13 +20,14 @@
19
20
  "lodash.get": "^4.4.2",
20
21
  "mongoose": "6.11.6",
21
22
  "node-fetch": "^2.6.7",
23
+ "prisma": "^6.16.3",
22
24
  "serverless-http": "^2.7.0",
23
25
  "uuid": "^9.0.1"
24
26
  },
25
27
  "devDependencies": {
26
- "@friggframework/eslint-config": "2.0.0--canary.454.1b45c13.0",
27
- "@friggframework/prettier-config": "2.0.0--canary.454.1b45c13.0",
28
- "@friggframework/test": "2.0.0--canary.454.1b45c13.0",
28
+ "@friggframework/eslint-config": "2.0.0--canary.454.29d031a.0",
29
+ "@friggframework/prettier-config": "2.0.0--canary.454.29d031a.0",
30
+ "@friggframework/test": "2.0.0--canary.454.29d031a.0",
29
31
  "@prisma/client": "^6.16.3",
30
32
  "@types/lodash": "4.17.15",
31
33
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -47,7 +49,8 @@
47
49
  "prisma:generate:postgres": "npx prisma generate --schema ./prisma-postgresql/schema.prisma",
48
50
  "prisma:generate": "npm run prisma:generate:mongo && npm run prisma:generate:postgres",
49
51
  "prisma:push:mongo": "npx prisma db push --schema ./prisma-mongodb/schema.prisma",
50
- "prisma:migrate:postgres": "npx prisma migrate dev --schema ./prisma-postgresql/schema.prisma"
52
+ "prisma:migrate:postgres": "npx prisma migrate dev --schema ./prisma-postgresql/schema.prisma",
53
+ "prepublishOnly": "npm run prisma:generate"
51
54
  },
52
55
  "author": "",
53
56
  "license": "MIT",
@@ -64,5 +67,5 @@
64
67
  "publishConfig": {
65
68
  "access": "public"
66
69
  },
67
- "gitHead": "1b45c13320a222b9f9bbd1d74db27b6e46db5dfa"
70
+ "gitHead": "29d031ab64d766581afe99c850652bc3f06408c1"
68
71
  }
@@ -3,8 +3,10 @@
3
3
  // Migration from Mongoose ODM to Prisma ORM
4
4
 
5
5
  generator client {
6
- provider = "prisma-client-js"
7
- output = "../node_modules/@prisma-mongodb/client"
6
+ provider = "prisma-client-js"
7
+ output = "../node_modules/@prisma-mongodb/client"
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 String @id @default(auto()) @map("_id") @db.ObjectId
23
- type UserType
24
+ id String @id @default(auto()) @map("_id") @db.ObjectId
25
+ type UserType
24
26
 
25
27
  // Timestamps
26
28
  createdAt DateTime @default(now())
@@ -86,12 +88,12 @@ model Token {
86
88
  /// OAuth credentials and API tokens
87
89
  /// All sensitive data encrypted with KMS at rest
88
90
  model Credential {
89
- id String @id @default(auto()) @map("_id") @db.ObjectId
90
- userId String? @db.ObjectId
91
- user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
92
- subType String?
91
+ id String @id @default(auto()) @map("_id") @db.ObjectId
92
+ userId String? @db.ObjectId
93
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
94
+ subType String?
93
95
  authIsValid Boolean?
94
- externalId String?
96
+ externalId String?
95
97
 
96
98
  // Dynamic OAuth fields stored as JSON (encrypted via Prisma middleware)
97
99
  // Contains: access_token, refresh_token, domain, expires_in, token_type, etc.
@@ -124,11 +126,11 @@ model Entity {
124
126
  updatedAt DateTime @updatedAt
125
127
 
126
128
  // Relations - many-to-many with scalar lists
127
- integrations Integration[] @relation("IntegrationEntities", fields: [integrationIds], references: [id])
128
- integrationIds String[] @db.ObjectId
129
+ integrations Integration[] @relation("IntegrationEntities", fields: [integrationIds], references: [id])
130
+ integrationIds String[] @db.ObjectId
129
131
 
130
- syncs Sync[] @relation("SyncEntities", fields: [syncIds], references: [id])
131
- syncIds String[] @db.ObjectId
132
+ syncs Sync[] @relation("SyncEntities", fields: [syncIds], references: [id])
133
+ syncIds String[] @db.ObjectId
132
134
 
133
135
  dataIdentifiers DataIdentifier[]
134
136
  associationObjects AssociationObject[]
@@ -152,7 +154,7 @@ model Integration {
152
154
  status IntegrationStatus @default(ENABLED)
153
155
 
154
156
  // Configuration and version
155
- config Json? // Integration configuration object
157
+ config Json? // Integration configuration object
156
158
  version String?
157
159
 
158
160
  // Entity references (many-to-many via explicit scalar list)
@@ -279,11 +281,11 @@ model Association {
279
281
  /// Association object entry
280
282
  /// Replaces nested array structure in Mongoose
281
283
  model AssociationObject {
282
- id String @id @default(auto()) @map("_id") @db.ObjectId
283
- associationId String @db.ObjectId
284
- association Association @relation(fields: [associationId], references: [id], onDelete: Cascade)
285
- entityId String @db.ObjectId
286
- entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
284
+ id String @id @default(auto()) @map("_id") @db.ObjectId
285
+ associationId String @db.ObjectId
286
+ association Association @relation(fields: [associationId], references: [id], onDelete: Cascade)
287
+ entityId String @db.ObjectId
288
+ entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
287
289
  objectType String
288
290
  objId String
289
291
  metadata Json? // Optional metadata
@@ -318,4 +320,4 @@ model WebsocketConnection {
318
320
 
319
321
  @@index([connectionId])
320
322
  @@map("WebsocketConnection")
321
- }
323
+ }
@@ -3,8 +3,10 @@
3
3
  // Converted from MongoDB schema for relational database support
4
4
 
5
5
  generator client {
6
- provider = "prisma-client-js"
7
- output = "../node_modules/@prisma-postgresql/client"
6
+ provider = "prisma-client-js"
7
+ output = "../node_modules/@prisma-postgresql/client"
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 Int @id @default(autoincrement())
23
- type UserType
24
+ id Int @id @default(autoincrement())
25
+ type UserType
24
26
 
25
27
  // Timestamps
26
28
  createdAt DateTime @default(now())
@@ -84,12 +86,12 @@ model Token {
84
86
  /// OAuth credentials and API tokens
85
87
  /// All sensitive data encrypted with KMS at rest
86
88
  model Credential {
87
- id Int @id @default(autoincrement())
88
- userId Int?
89
- user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
90
- subType String?
89
+ id Int @id @default(autoincrement())
90
+ userId Int?
91
+ user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
92
+ subType String?
91
93
  authIsValid Boolean?
92
- externalId String?
94
+ externalId String?
93
95
 
94
96
  // Dynamic OAuth fields stored as JSON (encrypted via Prisma middleware)
95
97
  // Contains: access_token, refresh_token, domain, expires_in, token_type, etc.
@@ -145,7 +147,7 @@ model Integration {
145
147
  status IntegrationStatus @default(ENABLED)
146
148
 
147
149
  // Configuration and version
148
- config Json? // Integration configuration object
150
+ config Json? // Integration configuration object
149
151
  version String?
150
152
 
151
153
  // Entity references (many-to-many via implicit join table)
@@ -226,11 +228,11 @@ model Sync {
226
228
  /// Data identifier for sync operations
227
229
  /// Replaces nested array structure in Mongoose
228
230
  model DataIdentifier {
229
- id Int @id @default(autoincrement())
231
+ id Int @id @default(autoincrement())
230
232
  syncId Int?
231
- sync Sync? @relation(fields: [syncId], references: [id], onDelete: Cascade)
233
+ sync Sync? @relation(fields: [syncId], references: [id], onDelete: Cascade)
232
234
  entityId Int
233
- entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
235
+ entity Entity @relation(fields: [entityId], references: [id], onDelete: Cascade)
234
236
 
235
237
  // Identifier data (can be any structure)
236
238
  idData Json
@@ -290,7 +292,7 @@ enum AssociationType {
290
292
 
291
293
  /// Generic state storage
292
294
  model State {
293
- id Int @id @default(autoincrement())
295
+ id Int @id @default(autoincrement())
294
296
  state Json?
295
297
  }
296
298