@friggframework/core 2.0.0-next.67 → 2.0.0-next.69

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.
@@ -42,12 +42,12 @@ class ModuleRepository extends ModuleRepositoryInterface {
42
42
 
43
43
  return {
44
44
  id: entity.id,
45
- accountId: entity.accountId,
46
45
  credential: entity.credential,
47
46
  userId: entity.userId,
48
47
  name: entity.name,
49
48
  externalId: entity.externalId,
50
49
  moduleName: entity.moduleName,
50
+ ...(entity.data || {}),
51
51
  };
52
52
  }
53
53
 
@@ -66,12 +66,12 @@ class ModuleRepository extends ModuleRepositoryInterface {
66
66
 
67
67
  return entities.map((e) => ({
68
68
  id: e.id,
69
- accountId: e.accountId,
70
69
  credential: e.credential,
71
70
  userId: e.userId,
72
71
  name: e.name,
73
72
  externalId: e.externalId,
74
73
  moduleName: e.moduleName,
74
+ ...(e.data || {}),
75
75
  }));
76
76
  }
77
77
 
@@ -90,12 +90,12 @@ class ModuleRepository extends ModuleRepositoryInterface {
90
90
 
91
91
  return entities.map((e) => ({
92
92
  id: e.id,
93
- accountId: e.accountId,
94
93
  credential: e.credential,
95
94
  userId: e.userId,
96
95
  name: e.name,
97
96
  externalId: e.externalId,
98
97
  moduleName: e.moduleName,
98
+ ...(e.data || {}),
99
99
  }));
100
100
  }
101
101
 
@@ -118,12 +118,12 @@ class ModuleRepository extends ModuleRepositoryInterface {
118
118
 
119
119
  return entities.map((e) => ({
120
120
  id: e.id,
121
- accountId: e.accountId,
122
121
  credential: e.credential,
123
122
  userId: e.userId,
124
123
  name: e.name,
125
124
  externalId: e.externalId,
126
125
  moduleName: e.moduleName,
126
+ ...(e.data || {}),
127
127
  }));
128
128
  }
129
129
 
@@ -163,12 +163,12 @@ class ModuleRepository extends ModuleRepositoryInterface {
163
163
 
164
164
  return {
165
165
  id: entity.id,
166
- accountId: entity.accountId,
167
166
  credential: entity.credential,
168
167
  userId: entity.userId,
169
168
  name: entity.name,
170
169
  externalId: entity.externalId,
171
170
  moduleName: entity.moduleName,
171
+ ...(entity.data || {}),
172
172
  };
173
173
  }
174
174
 
@@ -180,14 +180,24 @@ class ModuleRepository extends ModuleRepositoryInterface {
180
180
  * @returns {Promise<Object>} Created entity object
181
181
  */
182
182
  async createEntity(entityData) {
183
- // Convert Mongoose-style fields to Prisma
183
+ const {
184
+ user,
185
+ userId,
186
+ credential,
187
+ credentialId,
188
+ name,
189
+ moduleName,
190
+ externalId,
191
+ ...dynamicData
192
+ } = entityData;
193
+
184
194
  const data = {
185
- userId: entityData.user || entityData.userId,
186
- credentialId: entityData.credential || entityData.credentialId,
187
- name: entityData.name,
188
- moduleName: entityData.moduleName,
189
- externalId: entityData.externalId,
190
- accountId: entityData.accountId,
195
+ userId: userId || user,
196
+ credentialId: credentialId || credential,
197
+ name,
198
+ moduleName,
199
+ externalId,
200
+ data: dynamicData,
191
201
  };
192
202
 
193
203
  const entity = await this.prisma.entity.create({
@@ -197,12 +207,12 @@ class ModuleRepository extends ModuleRepositoryInterface {
197
207
 
198
208
  return {
199
209
  id: entity.id,
200
- accountId: entity.accountId,
201
210
  credential: entity.credential,
202
211
  userId: entity.userId,
203
212
  name: entity.name,
204
213
  externalId: entity.externalId,
205
214
  moduleName: entity.moduleName,
215
+ ...(entity.data || {}),
206
216
  };
207
217
  }
208
218
 
@@ -215,36 +225,55 @@ class ModuleRepository extends ModuleRepositoryInterface {
215
225
  * @returns {Promise<Object|null>} Updated entity object or null if not found
216
226
  */
217
227
  async updateEntity(entityId, updates) {
218
- // Convert Mongoose-style fields to Prisma
219
- const data = {};
220
- if (updates.user !== undefined) data.userId = updates.user;
221
- if (updates.userId !== undefined) data.userId = updates.userId;
222
- if (updates.credential !== undefined)
223
- data.credentialId = updates.credential;
224
- if (updates.credentialId !== undefined)
225
- data.credentialId = updates.credentialId;
226
- if (updates.name !== undefined) data.name = updates.name;
227
- if (updates.moduleName !== undefined)
228
- data.moduleName = updates.moduleName;
229
- if (updates.externalId !== undefined)
230
- data.externalId = updates.externalId;
231
- if (updates.accountId !== undefined) data.accountId = updates.accountId;
228
+ const existing = await this.prisma.entity.findUnique({
229
+ where: { id: entityId },
230
+ });
231
+
232
+ if (!existing) {
233
+ return null;
234
+ }
235
+
236
+ const {
237
+ user,
238
+ userId,
239
+ credential,
240
+ credentialId,
241
+ name,
242
+ moduleName,
243
+ externalId,
244
+ ...dynamicData
245
+ } = updates;
246
+
247
+ const schemaUpdates = {};
248
+ if (user !== undefined || userId !== undefined) {
249
+ schemaUpdates.userId = userId || user;
250
+ }
251
+ if (credential !== undefined || credentialId !== undefined) {
252
+ schemaUpdates.credentialId = credentialId || credential;
253
+ }
254
+ if (name !== undefined) schemaUpdates.name = name;
255
+ if (moduleName !== undefined) schemaUpdates.moduleName = moduleName;
256
+ if (externalId !== undefined) schemaUpdates.externalId = externalId;
257
+
258
+ if (Object.keys(dynamicData).length > 0) {
259
+ schemaUpdates.data = { ...(existing.data || {}), ...dynamicData };
260
+ }
232
261
 
233
262
  try {
234
263
  const entity = await this.prisma.entity.update({
235
264
  where: { id: entityId },
236
- data,
265
+ data: schemaUpdates,
237
266
  include: { credential: true },
238
267
  });
239
268
 
240
269
  return {
241
270
  id: entity.id,
242
- accountId: entity.accountId,
243
271
  credential: entity.credential,
244
272
  userId: entity.userId,
245
273
  name: entity.name,
246
274
  externalId: entity.externalId,
247
275
  moduleName: entity.moduleName,
276
+ ...(entity.data || {}),
248
277
  };
249
278
  } catch (error) {
250
279
  if (error.code === 'P2025') {
@@ -279,6 +279,15 @@ class OAuth2Requester extends Requester {
279
279
  */
280
280
  async refreshAuth() {
281
281
  try {
282
+ console.log('[OAuth2Requester.refreshAuth] Starting token refresh', {
283
+ grant_type: this.grant_type,
284
+ has_refresh_token: !!this.refresh_token,
285
+ has_client_id: !!this.client_id,
286
+ has_client_secret: !!this.client_secret,
287
+ has_token_uri: !!this.tokenUri,
288
+ tokenUri: this.tokenUri,
289
+ });
290
+
282
291
  if (this.grant_type !== 'client_credentials') {
283
292
  await this.refreshAccessToken({
284
293
  refresh_token: this.refresh_token,
@@ -286,8 +295,15 @@ class OAuth2Requester extends Requester {
286
295
  } else {
287
296
  await this.getTokenFromClientCredentials();
288
297
  }
298
+ console.log('[OAuth2Requester.refreshAuth] Token refresh succeeded');
289
299
  return true;
290
- } catch {
300
+ } catch (error) {
301
+ console.error('[OAuth2Requester.refreshAuth] Token refresh failed', {
302
+ error_message: error?.message,
303
+ error_name: error?.name,
304
+ response_status: error?.response?.status,
305
+ response_data: error?.response?.data,
306
+ });
291
307
  await this.notify(this.DLGT_INVALID_AUTH);
292
308
  return false;
293
309
  }
@@ -20,7 +20,7 @@ const Definition = {
20
20
  getEntityDetails: async function (api, callbackParams, tokenResponse, userId) {
21
21
  const userDetails = await api.getUserDetails();
22
22
  return {
23
- identifiers: { externalId: userDetails.portalId, user: userId },
23
+ identifiers: { externalId: userDetails.portalId, userId },
24
24
  details: { name: userDetails.hub_domain },
25
25
  }
26
26
  },
@@ -33,7 +33,7 @@ const Definition = {
33
33
  getCredentialDetails: async function (api, userId) {
34
34
  const userDetails = await api.getUserDetails();
35
35
  return {
36
- identifiers: { externalId: userDetails.portalId, user: userId },
36
+ identifiers: { externalId: userDetails.portalId, userId },
37
37
  details: {}
38
38
  };
39
39
  },
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.67",
4
+ "version": "2.0.0-next.69",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "@friggframework/eslint-config": "2.0.0-next.67",
42
- "@friggframework/prettier-config": "2.0.0-next.67",
43
- "@friggframework/test": "2.0.0-next.67",
41
+ "@friggframework/eslint-config": "2.0.0-next.69",
42
+ "@friggframework/prettier-config": "2.0.0-next.69",
43
+ "@friggframework/test": "2.0.0-next.69",
44
44
  "@prisma/client": "^6.17.0",
45
45
  "@types/lodash": "4.17.15",
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "6b324d858e2593833a79f66c00b700272013a8cf"
83
+ "gitHead": "018c93f98b5f14786d016a4f621adef10ad27597"
84
84
  }
@@ -119,6 +119,8 @@ model Entity {
119
119
  moduleName String?
120
120
  externalId String?
121
121
 
122
+ data Json @default("{}")
123
+
122
124
  createdAt DateTime @default(now())
123
125
  updatedAt DateTime @updatedAt
124
126
 
@@ -116,6 +116,8 @@ model Entity {
116
116
  moduleName String?
117
117
  externalId String?
118
118
 
119
+ data Json @default("{}")
120
+
119
121
  createdAt DateTime @default(now())
120
122
  updatedAt DateTime @updatedAt
121
123