@friggframework/core 1.1.3--canary.296.b068936.0 → 1.1.4--canary.301.c782f0f.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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # v1.1.3 (Tue Apr 02 2024)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - test release [#296](https://github.com/friggframework/frigg/pull/296) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
6
+ - add a commit to fix canary and workaround auto bug ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
7
+ - bump to test release ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
8
+
9
+ #### Authors: 1
10
+
11
+ - [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
12
+
13
+ ---
14
+
1
15
  # v2.0.0 (Sat Mar 30 2024)
2
16
 
3
17
  #### 🚀 Enhancement
@@ -154,9 +154,33 @@ class IntegrationBase {
154
154
  return options;
155
155
  }
156
156
 
157
+ async refreshConfigOptions(params) {
158
+ const options = {
159
+ jsonSchema: {},
160
+ uiSchema: {},
161
+ }
162
+ return options
163
+ }
164
+
157
165
  async getUserActions() {
158
166
  return [];
159
167
  }
168
+
169
+ async getActionOptions() {
170
+ const options = {
171
+ jsonSchema: {},
172
+ uiSchema: {},
173
+ }
174
+ return options
175
+ }
176
+
177
+ async refreshActionOptions(params) {
178
+ const options = {
179
+ jsonSchema: {},
180
+ uiSchema: {},
181
+ }
182
+ return options
183
+ }
160
184
  }
161
185
 
162
186
  module.exports = { IntegrationBase };
@@ -155,7 +155,20 @@ function setIntegrationRoutes(router, factory, getUserId) {
155
155
  const integration =
156
156
  await integrationFactory.getInstanceFromIntegrationId(params);
157
157
  const results = await integration.getConfigOptions();
158
- // We could perhaps augment router with dynamic options? Haven't decided yet, but here may be the place
158
+ res.json(results);
159
+ })
160
+ );
161
+
162
+ router.route('/api/integrations/:integrationId/config/options/refresh').post(
163
+ catchAsyncError(async (req, res) => {
164
+ const params = checkRequiredParams(req.params, [
165
+ 'integrationId',
166
+ ]);
167
+ const integration =
168
+ await integrationFactory.getInstanceFromIntegrationId(params);
169
+ const results = await integration.refreshConfigOptions(
170
+ req.body
171
+ );
159
172
  res.json(results);
160
173
  })
161
174
  );
@@ -176,6 +189,23 @@ function setIntegrationRoutes(router, factory, getUserId) {
176
189
  })
177
190
  );
178
191
 
192
+ router.route('/api/integrations/:integrationId/actions/:actionId/options/refresh').post(
193
+ catchAsyncError(async (req, res) => {
194
+ const params = checkRequiredParams(req.params, [
195
+ 'integrationId',
196
+ 'actionId'
197
+ ]);
198
+ const integration =
199
+ await integrationFactory.getInstanceFromIntegrationId(params);
200
+ const results = await integration.refreshActionOptions(
201
+ params.actionId,
202
+ req.body
203
+ );
204
+ // We could perhaps augment router with dynamic options? Haven't decided yet, but here may be the place
205
+ res.json(results);
206
+ })
207
+ );
208
+
179
209
  router.route('/api/integrations/:integrationId/actions/:actionId').post(
180
210
  catchAsyncError(async (req, res) => {
181
211
  const params = checkRequiredParams(req.params, [
@@ -310,28 +340,6 @@ function setEntityRoutes(router, factory, getUserId) {
310
340
  })
311
341
  );
312
342
 
313
- router.route('/api/entity').post(
314
- catchAsyncError(async (req, res) => {
315
- const params = checkRequiredParams(req.body, [
316
- 'entityType',
317
- 'data',
318
- ]);
319
- checkRequiredParams(req.body.data, ['credential_id']);
320
-
321
- // May want to pass along the user ID as well so credential ID's can't be fished???
322
- const credential = await IntegrationHelper.getCredentialById(
323
- params.data.credential_id
324
- );
325
-
326
- if (!credential) {
327
- throw Boom.badRequest('Invalid credential ID');
328
- }
329
-
330
- const module = await getModuleInstance(req, params.entityType);
331
- res.json(await module.findOrCreateEntity(params.data));
332
- })
333
- );
334
-
335
343
  router.route('/api/entities/:entityId/test-auth').get(
336
344
  catchAsyncError(async (req, res) => {
337
345
  const params = checkRequiredParams(req.params, ['entityId']);
@@ -352,7 +360,7 @@ function setEntityRoutes(router, factory, getUserId) {
352
360
  errors: [
353
361
  {
354
362
  title: 'Authentication Error',
355
- message: `There was an error with your ${module.constructor.getName()} Entity. Please reconnect/re-authenticate, or reach out to Support for assistance.`,
363
+ message: `There was an error with your ${module.getName()} Entity. Please reconnect/re-authenticate, or reach out to Support for assistance.`,
356
364
  timestamp: Date.now(),
357
365
  },
358
366
  ],
@@ -362,6 +370,59 @@ function setEntityRoutes(router, factory, getUserId) {
362
370
  }
363
371
  })
364
372
  );
373
+
374
+ router.route('/api/entities/:entityId').get(
375
+ catchAsyncError(async (req, res) => {
376
+ const params = checkRequiredParams(req.params, ['entityId']);
377
+ const module = await moduleFactory.getModuleInstanceFromEntityId(
378
+ params.entityId,
379
+ getUserId(req)
380
+ );
381
+
382
+ if (!module) {
383
+ throw Boom.notFound();
384
+ }
385
+ res.json(module.entity);
386
+ })
387
+ );
388
+
389
+ router.route('/api/entities/:entityId/options').post(
390
+ catchAsyncError(async (req, res) => {
391
+ const params = checkRequiredParams(req.params, [
392
+ 'entityId',
393
+ getUserId(req)
394
+ ]);
395
+ const module = await moduleFactory.getModuleInstanceFromEntityId(
396
+ params.entityId,
397
+ getUserId(req)
398
+ );
399
+
400
+ if (!module) {
401
+ throw Boom.notFound();
402
+ }
403
+
404
+ res.json(await module.getEntityOptions());
405
+ })
406
+ );
407
+
408
+ router.route('/api/entities/:entityId/options/refresh').post(
409
+ catchAsyncError(async (req, res) => {
410
+ const params = checkRequiredParams(req.params, [
411
+ 'entityId',
412
+ getUserId(req)
413
+ ]);
414
+ const module = await moduleFactory.getModuleInstanceFromEntityId(
415
+ params.entityId,
416
+ getUserId(req)
417
+ );
418
+
419
+ if (!module) {
420
+ throw Boom.notFound();
421
+ }
422
+
423
+ res.json(await module.refreshEntityOptions(req.body));
424
+ })
425
+ );
365
426
  }
366
427
 
367
428
  module.exports = { createIntegrationRouter, checkRequiredParams };
@@ -88,6 +88,12 @@ class Auther extends Delegate {
88
88
  const definition = get(params, 'definition');
89
89
  Auther.validateDefinition(definition);
90
90
  Object.assign(this, definition.requiredAuthMethods);
91
+ if (definition.getEntityOptions) {
92
+ this.getEntityOptions = definition.getEntityOptions;
93
+ }
94
+ if (definition.refreshEntityOptions) {
95
+ this.refreshEntityOptions = definition.refreshEntityOptions;
96
+ }
91
97
  this.name = definition.moduleName;
92
98
  this.modelName = definition.modelName;
93
99
  this.apiClass = definition.API;
@@ -263,12 +269,14 @@ class Auther extends Delegate {
263
269
  }
264
270
 
265
271
  async getEntityOptions() {
266
- // May not be needed if the callback already creates the entity, such as in situations
267
- // like HubSpot where the account is determined in the authorization flow.
268
- // This should only be used in situations such as FreshBooks where the user needs to make
269
- // an account decision on the front end.
270
272
  throw new Error(
271
- 'Entity requirement method getEntityOptions() is not defined in the class'
273
+ 'Method getEntityOptions() is not defined in the class'
274
+ );
275
+ }
276
+
277
+ async refreshEntityOptions() {
278
+ throw new Error(
279
+ 'Method refreshEntityOptions() is not defined in the class'
272
280
  );
273
281
  }
274
282
 
@@ -16,6 +16,7 @@ class Requester extends Delegate {
16
16
  // Allow passing in the fetch function
17
17
  // Instance methods can use this.fetch without differentiating
18
18
  this.fetch = get(params, 'fetch', fetch);
19
+
19
20
  }
20
21
 
21
22
  parsedBody = async (resp) => {
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.3--canary.296.b068936.0",
4
+ "version": "1.1.4--canary.301.c782f0f.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.3--canary.296.b068936.0",
19
- "@friggframework/prettier-config": "1.1.3--canary.296.b068936.0",
20
- "@friggframework/test": "1.1.3--canary.296.b068936.0",
18
+ "@friggframework/eslint-config": "1.1.4--canary.301.c782f0f.0",
19
+ "@friggframework/prettier-config": "1.1.4--canary.301.c782f0f.0",
20
+ "@friggframework/test": "1.1.4--canary.301.c782f0f.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": "b0689366e283ca192f43cb6d03e0181bd3bb11c3"
52
+ "gitHead": "c782f0f412bf9bd865a62360ac7ce7ef444f4d12"
53
53
  }