@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.
- package/credential/repositories/credential-repository-postgres.js +2 -6
- package/credential/repositories/credential-repository.js +19 -21
- package/generated/prisma-mongodb/edge.js +4 -3
- package/generated/prisma-mongodb/index-browser.js +1 -0
- package/generated/prisma-mongodb/index.d.ts +53 -1
- package/generated/prisma-mongodb/index.js +4 -3
- package/generated/prisma-mongodb/package.json +1 -1
- package/generated/prisma-mongodb/schema.prisma +2 -0
- package/generated/prisma-mongodb/wasm.js +4 -3
- package/generated/prisma-postgresql/edge.js +4 -3
- package/generated/prisma-postgresql/index-browser.js +1 -0
- package/generated/prisma-postgresql/index.d.ts +55 -1
- package/generated/prisma-postgresql/index.js +4 -3
- package/generated/prisma-postgresql/package.json +1 -1
- package/generated/prisma-postgresql/schema.prisma +2 -0
- package/generated/prisma-postgresql/wasm.js +4 -3
- package/modules/repositories/module-repository-documentdb.js +52 -24
- package/modules/repositories/module-repository-mongo.js +62 -31
- package/modules/repositories/module-repository-postgres.js +64 -37
- package/modules/repositories/module-repository.js +58 -29
- package/modules/requester/oauth-2.js +17 -1
- package/modules/test/mock-api/definition.js +2 -2
- package/package.json +5 -5
- package/prisma-mongodb/schema.prisma +2 -0
- package/prisma-postgresql/schema.prisma +2 -0
|
@@ -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
|
-
|
|
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:
|
|
186
|
-
credentialId:
|
|
187
|
-
name
|
|
188
|
-
moduleName
|
|
189
|
-
externalId
|
|
190
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
if (
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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,
|
|
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,
|
|
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.
|
|
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.
|
|
42
|
-
"@friggframework/prettier-config": "2.0.0-next.
|
|
43
|
-
"@friggframework/test": "2.0.0-next.
|
|
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": "
|
|
83
|
+
"gitHead": "018c93f98b5f14786d016a4f621adef10ad27597"
|
|
84
84
|
}
|