@friggframework/core 1.1.4--canary.301.ffb9dc2.0 → 1.1.4--canary.301.19256e3.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.
@@ -308,6 +308,36 @@ function setEntityRoutes(router, factory, getUserId) {
308
308
  })
309
309
  );
310
310
 
311
+ router.route('/api/entity').post(
312
+ catchAsyncError(async (req, res) => {
313
+ const params = checkRequiredParams(req.body, [
314
+ 'entityType',
315
+ 'data',
316
+ ]);
317
+ checkRequiredParams(req.body.data, ['credential_id']);
318
+
319
+ // May want to pass along the user ID as well so credential ID's can't be fished???
320
+ const credential = await IntegrationHelper.getCredentialById(
321
+ params.data.credential_id
322
+ );
323
+
324
+ if (!credential) {
325
+ throw Boom.badRequest('Invalid credential ID');
326
+ }
327
+
328
+ const module = await getModuleInstance(req, params.entityType);
329
+ const entityDetails = await module.getEntityDetails(
330
+ module.api,
331
+ null,
332
+ null,
333
+ getUserId(req)
334
+ )
335
+ res.json(
336
+ await module.findOrCreateEntity(entityDetails)
337
+ );
338
+ })
339
+ );
340
+
311
341
  router.route('/api/entity/options/:credentialId').get(
312
342
  catchAsyncError(async (req, res) => {
313
343
  // TODO May want to pass along the user ID as well so credential ID's can't be fished???
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "1.1.4--canary.301.ffb9dc2.0",
4
+ "version": "1.1.4--canary.301.19256e3.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
7
  "aws-sdk": "^2.1200.0",
@@ -15,9 +15,9 @@
15
15
  "node-fetch": "^2.6.7"
16
16
  },
17
17
  "devDependencies": {
18
- "@friggframework/eslint-config": "1.1.4--canary.301.ffb9dc2.0",
19
- "@friggframework/prettier-config": "1.1.4--canary.301.ffb9dc2.0",
20
- "@friggframework/test": "1.1.4--canary.301.ffb9dc2.0",
18
+ "@friggframework/eslint-config": "1.1.4--canary.301.19256e3.0",
19
+ "@friggframework/prettier-config": "1.1.4--canary.301.19256e3.0",
20
+ "@friggframework/test": "1.1.4--canary.301.19256e3.0",
21
21
  "@types/lodash": "^4.14.191",
22
22
  "@typescript-eslint/eslint-plugin": "^5.55.0",
23
23
  "chai": "^4.3.6",
@@ -49,5 +49,5 @@
49
49
  },
50
50
  "homepage": "https://github.com/friggframework/frigg#readme",
51
51
  "description": "",
52
- "gitHead": "ffb9dc213cfb9e02635a17234c126a412f734039"
52
+ "gitHead": "19256e3241d018af6bfdd03f52521bc69621af28"
53
53
  }