@friggframework/core 2.0.0-next.42 → 2.0.0-next.44

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.
@@ -93,7 +93,8 @@ class ProcessAuthorizationCallback {
93
93
  );
94
94
  credentialDetails.details.authIsValid = true;
95
95
 
96
- await this.credentialRepository.upsertCredential(credentialDetails);
96
+ const persisted = await this.credentialRepository.upsertCredential(credentialDetails);
97
+ module.credential = persisted;
97
98
  }
98
99
 
99
100
  async findOrCreateEntity(entityDetails, moduleName, credentialId) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0-next.42",
4
+ "version": "2.0.0-next.44",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
7
  "@prisma/client": "^6.16.3",
@@ -23,9 +23,9 @@
23
23
  "uuid": "^9.0.1"
24
24
  },
25
25
  "devDependencies": {
26
- "@friggframework/eslint-config": "2.0.0-next.42",
27
- "@friggframework/prettier-config": "2.0.0-next.42",
28
- "@friggframework/test": "2.0.0-next.42",
26
+ "@friggframework/eslint-config": "2.0.0-next.44",
27
+ "@friggframework/prettier-config": "2.0.0-next.44",
28
+ "@friggframework/test": "2.0.0-next.44",
29
29
  "@types/lodash": "4.17.15",
30
30
  "@typescript-eslint/eslint-plugin": "^8.0.0",
31
31
  "chai": "^4.3.6",
@@ -64,5 +64,5 @@
64
64
  "publishConfig": {
65
65
  "access": "public"
66
66
  },
67
- "gitHead": "9b956c72ec74f70bb5efd336782cf269c79c3d9b"
67
+ "gitHead": "87c8479d50810d28eb7dc73c347e0117d872273a"
68
68
  }
@@ -46,6 +46,7 @@ model User {
46
46
  credentials Credential[]
47
47
  entities Entity[]
48
48
  integrations Integration[]
49
+ processes Process[]
49
50
 
50
51
  @@unique([email])
51
52
  @@unique([username])
@@ -159,9 +160,6 @@ model Integration {
159
160
  entities Entity[] @relation("IntegrationEntities", fields: [entityIds], references: [id])
160
161
  entityIds String[] @db.ObjectId
161
162
 
162
- // Entity reference map (Map<String, String> stored as JSON)
163
- entityReferenceMap Json? @default("{}")
164
-
165
163
  // Message arrays (stored as JSON)
166
164
  errors Json @default("[]")
167
165
  warnings Json @default("[]")
@@ -175,6 +173,7 @@ model Integration {
175
173
  associations Association[]
176
174
  syncs Sync[]
177
175
  mappings IntegrationMapping[]
176
+ processes Process[]
178
177
 
179
178
  @@index([userId])
180
179
  @@index([status])
@@ -209,6 +208,48 @@ model IntegrationMapping {
209
208
  @@map("IntegrationMapping")
210
209
  }
211
210
 
211
+ // ============================================================================
212
+ // PROCESS MODELS
213
+ // ============================================================================
214
+
215
+ /// Generic Process Model - tracks any long-running operation
216
+ /// Used for: CRM syncs, data migrations, bulk operations, etc.
217
+ model Process {
218
+ id String @id @default(auto()) @map("_id") @db.ObjectId
219
+
220
+ // Core references
221
+ userId String @db.ObjectId
222
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
223
+ integrationId String @db.ObjectId
224
+ integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)
225
+
226
+ // Process identification
227
+ name String // e.g., "zoho-crm-contact-sync", "pipedrive-lead-sync"
228
+ type String // e.g., "CRM_SYNC", "DATA_MIGRATION", "BULK_OPERATION"
229
+
230
+ // State machine
231
+ state String // Current state (integration-defined states)
232
+
233
+ // Flexible storage
234
+ context Json @default("{}") // Process-specific data (pagination, metadata, etc.)
235
+ results Json @default("{}") // Process results and metrics
236
+
237
+ // Hierarchy support
238
+ childProcesses String[] @db.ObjectId
239
+ parentProcessId String? @db.ObjectId
240
+
241
+ // Timestamps
242
+ createdAt DateTime @default(now())
243
+ updatedAt DateTime @updatedAt
244
+
245
+ @@index([userId])
246
+ @@index([integrationId])
247
+ @@index([type])
248
+ @@index([state])
249
+ @@index([name])
250
+ @@map("Process")
251
+ }
252
+
212
253
  // ============================================================================
213
254
  // SYNC MODELS
214
255
  // ============================================================================
@@ -0,0 +1,3 @@
1
+ -- AlterTable
2
+ -- Remove unused entityReferenceMap field from Integration table
3
+ ALTER TABLE "Integration" DROP COLUMN "entityReferenceMap";
@@ -46,6 +46,7 @@ model User {
46
46
  credentials Credential[]
47
47
  entities Entity[]
48
48
  integrations Integration[]
49
+ processes Process[]
49
50
 
50
51
  @@unique([email])
51
52
  @@unique([username])
@@ -151,9 +152,6 @@ model Integration {
151
152
  // Entity references (many-to-many via implicit join table)
152
153
  entities Entity[]
153
154
 
154
- // Entity reference map (Map<String, String> stored as JSON)
155
- entityReferenceMap Json? @default("{}")
156
-
157
155
  // Message arrays (stored as JSON)
158
156
  errors Json @default("[]")
159
157
  warnings Json @default("[]")
@@ -167,6 +165,7 @@ model Integration {
167
165
  associations Association[]
168
166
  syncs Sync[]
169
167
  mappings IntegrationMapping[]
168
+ processes Process[]
170
169
 
171
170
  @@index([userId])
172
171
  @@index([status])
@@ -284,6 +283,49 @@ enum AssociationType {
284
283
  MANY_TO_ONE
285
284
  }
286
285
 
286
+ // ============================================================================
287
+ // PROCESS MODELS
288
+ // ============================================================================
289
+
290
+ /// Generic Process Model - tracks any long-running operation
291
+ /// Used for: CRM syncs, data migrations, bulk operations, etc.
292
+ model Process {
293
+ id Int @id @default(autoincrement())
294
+
295
+ // Core references
296
+ userId Int
297
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
298
+ integrationId Int
299
+ integration Integration @relation(fields: [integrationId], references: [id], onDelete: Cascade)
300
+
301
+ // Process identification
302
+ name String // e.g., "zoho-crm-contact-sync", "pipedrive-lead-sync"
303
+ type String // e.g., "CRM_SYNC", "DATA_MIGRATION", "BULK_OPERATION"
304
+
305
+ // State machine
306
+ state String // Current state (integration-defined states)
307
+
308
+ // Flexible storage
309
+ context Json @default("{}") // Process-specific data (pagination, metadata, etc.)
310
+ results Json @default("{}") // Process results and metrics
311
+
312
+ // Hierarchy support - self-referential relation
313
+ parentProcessId Int?
314
+ parentProcess Process? @relation("ProcessHierarchy", fields: [parentProcessId], references: [id], onDelete: SetNull)
315
+ childProcesses Process[] @relation("ProcessHierarchy")
316
+
317
+ // Timestamps
318
+ createdAt DateTime @default(now())
319
+ updatedAt DateTime @updatedAt
320
+
321
+ @@index([userId])
322
+ @@index([integrationId])
323
+ @@index([type])
324
+ @@index([state])
325
+ @@index([name])
326
+ @@index([parentProcessId])
327
+ }
328
+
287
329
  // ============================================================================
288
330
  // UTILITY MODELS
289
331
  // ============================================================================