@friggframework/core 1.2.0-canary.293.50b9cd8.0 → 1.2.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 +141 -0
- package/README.md +80 -0
- package/encrypt/encrypt.test.js +1 -1
- package/errors/validation-errors.js +2 -2
- package/index.js +2 -6
- package/integrations/index.js +1 -1
- package/integrations/integration-base.js +24 -0
- package/integrations/integration-factory.js +0 -12
- package/integrations/integration-router.js +133 -53
- package/integrations/test/integration-base.test.js +2 -1
- package/jest-setup.js +2 -0
- package/jest-teardown.js +2 -0
- package/{module-plugin/jest.config.js → jest.config.js} +2 -1
- package/logs/logger.test.js +1 -1
- package/module-plugin/auther.js +14 -6
- package/module-plugin/requester/requester.js +15 -1
- package/package.json +12 -10
- package/assertions/CHANGELOG.md +0 -87
- package/assertions/LICENSE.md +0 -9
- package/assertions/README.md +0 -3
- package/assertions/bump.txt +0 -1
- package/assertions/bump3.txt +0 -0
- package/associations/LICENSE.md +0 -9
- package/associations/README.md +0 -3
- package/associations/bump3.txt +0 -0
- package/associations/jest.config.js +0 -5
- package/core/.eslintrc.json +0 -3
- package/core/CHANGELOG.md +0 -103
- package/core/LICENSE.md +0 -9
- package/core/README.md +0 -3
- package/core/bump3.txt +0 -0
- package/core/jest.config.js +0 -5
- package/database/.eslintrc.json +0 -3
- package/database/CHANGELOG.md +0 -97
- package/database/LICENSE.md +0 -9
- package/database/README.md +0 -3
- package/database/bump3.txt +0 -0
- package/encrypt/.eslintrc.json +0 -3
- package/encrypt/CHANGELOG.md +0 -78
- package/encrypt/LICENSE.md +0 -9
- package/encrypt/README.md +0 -13
- package/encrypt/bump3.txt +0 -0
- package/encrypt/jest.config.js +0 -5
- package/errors/.eslintrc.json +0 -3
- package/errors/CHANGELOG.md +0 -44
- package/errors/LICENSE.md +0 -9
- package/errors/README.md +0 -3
- package/errors/bump.txt +0 -1
- package/errors/bump3.txt +0 -0
- package/errors/jest.config.js +0 -5
- package/integrations/.eslintrc.json +0 -3
- package/integrations/CHANGELOG.md +0 -244
- package/integrations/LICENSE.md +0 -9
- package/integrations/README.md +0 -3
- package/integrations/bump3.txt +0 -0
- package/integrations/jest-setup.js +0 -2
- package/integrations/jest-teardown.js +0 -2
- package/integrations/jest.config.js +0 -12
- package/lambda/README.md +0 -3
- package/lambda/bump3.txt +0 -0
- package/lambda/jest.config.js +0 -3
- package/logs/CHANGELOG.md +0 -57
- package/logs/LICENSE.md +0 -9
- package/logs/README.md +0 -3
- package/logs/bump3.txt +0 -0
- package/logs/jest.config.js +0 -5
- package/module-plugin/.eslintrc.json +0 -3
- package/module-plugin/CHANGELOG.md +0 -224
- package/module-plugin/LICENSE.md +0 -9
- package/module-plugin/README.md +0 -3
- package/module-plugin/bump3.txt +0 -0
- package/module-plugin/jest-setup.js +0 -3
- package/module-plugin/jest-teardown.js +0 -2
- package/syncs/README.md +0 -3
- package/syncs/bump3.txt +0 -0
- package/syncs/jest.config.js +0 -5
- package/types/CHANGELOG.md +0 -49
- package/types/README.md +0 -24
- package/types/bump3.txt +0 -0
- /package/{assertions/.eslintrc.json → .eslintrc.json} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,144 @@
|
|
|
1
|
+
# v1.2.0 (Tue Aug 06 2024)
|
|
2
|
+
|
|
3
|
+
:tada: This release contains work from a new contributor! :tada:
|
|
4
|
+
|
|
5
|
+
Thank you, Daniel Klotz ([@d-klotz](https://github.com/d-klotz)), for all your work!
|
|
6
|
+
|
|
7
|
+
#### 🐛 Bug Fix
|
|
8
|
+
|
|
9
|
+
- Add READMEs that will need updating, but for version releasing [#324](https://github.com/friggframework/frigg/pull/324) ([@seanspeaks](https://github.com/seanspeaks))
|
|
10
|
+
- Add READMEs that will need updating, but for version releasing ([@seanspeaks](https://github.com/seanspeaks))
|
|
11
|
+
- small update to integration testing / tooling [#304](https://github.com/friggframework/frigg/pull/304) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
12
|
+
- chore: bump deprecated npm package versions [#323](https://github.com/friggframework/frigg/pull/323) ([@d-klotz](https://github.com/d-klotz) [@seanspeaks](https://github.com/seanspeaks))
|
|
13
|
+
- chore: bump deprecated package versions ([@d-klotz](https://github.com/d-klotz))
|
|
14
|
+
- Bump version to: v1.1.8 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
15
|
+
- remove comment ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
16
|
+
- use the factory methods for creating the mock integration so that everything is set up (mostly events and userActions) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
17
|
+
- fix imports to not inadvertently call loadInstalledModules ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
18
|
+
- Bump version to: v1.1.5 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
19
|
+
|
|
20
|
+
#### Authors: 3
|
|
21
|
+
|
|
22
|
+
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
23
|
+
- Daniel Klotz ([@d-klotz](https://github.com/d-klotz))
|
|
24
|
+
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# v1.1.8 (Thu Jul 18 2024)
|
|
29
|
+
|
|
30
|
+
#### 🐛 Bug Fix
|
|
31
|
+
|
|
32
|
+
- Revert open to support commonjs [#319](https://github.com/friggframework/frigg/pull/319) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
33
|
+
- Bump version to: v1.1.6 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
34
|
+
|
|
35
|
+
#### Authors: 2
|
|
36
|
+
|
|
37
|
+
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
38
|
+
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
# v1.1.7 (Mon Jul 15 2024)
|
|
43
|
+
|
|
44
|
+
#### 🐛 Bug Fix
|
|
45
|
+
|
|
46
|
+
- getAuthorizationRequirements() async [#318](https://github.com/friggframework/frigg/pull/318) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
47
|
+
- getAuthorizationRequirements should be async, though it will only occasionally need to make requests ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
48
|
+
- Bump version to: v1.1.6 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
49
|
+
|
|
50
|
+
#### Authors: 2
|
|
51
|
+
|
|
52
|
+
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
53
|
+
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
# v1.1.6 (Fri Apr 26 2024)
|
|
58
|
+
|
|
59
|
+
#### 🐛 Bug Fix
|
|
60
|
+
|
|
61
|
+
- Small fix to validation errors and cleanup [#307](https://github.com/friggframework/frigg/pull/307) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
62
|
+
- remove excess files to centralize jest config and cleanup ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
63
|
+
- Bump version to: v1.1.5 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
64
|
+
|
|
65
|
+
#### Authors: 2
|
|
66
|
+
|
|
67
|
+
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
68
|
+
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
# v1.1.5 (Tue Apr 09 2024)
|
|
73
|
+
|
|
74
|
+
#### 🐛 Bug Fix
|
|
75
|
+
|
|
76
|
+
- update router to include options and refresh [#301](https://github.com/friggframework/frigg/pull/301) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
77
|
+
- consistent spacing ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
78
|
+
- add back the /api/entity POST of a credential with a tentative adjustment to implementation ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
79
|
+
- be consistent about not using redundant variables for the response json ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
80
|
+
- remove accidental newline ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
81
|
+
- fixes to router and stubs ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
82
|
+
- update router to include options and refresh for entities, integration config, and integration user actions ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
83
|
+
- Bump version to: v1.1.4 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
84
|
+
- Bump version to: v1.1.3 \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
85
|
+
|
|
86
|
+
#### Authors: 2
|
|
87
|
+
|
|
88
|
+
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
89
|
+
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
# v1.1.4 (Fri Apr 05 2024)
|
|
94
|
+
|
|
95
|
+
#### 🐛 Bug Fix
|
|
96
|
+
|
|
97
|
+
- Socket hang up / ECONNRESET error retry for requester [#297](https://github.com/friggframework/frigg/pull/297) ([@seanspeaks](https://github.com/seanspeaks))
|
|
98
|
+
- Check linear task description for offending error. Unclear if this is the best approach. ([@seanspeaks](https://github.com/seanspeaks))
|
|
99
|
+
|
|
100
|
+
#### Authors: 1
|
|
101
|
+
|
|
102
|
+
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
# v1.1.3 (Tue Apr 02 2024)
|
|
107
|
+
|
|
108
|
+
#### 🐛 Bug Fix
|
|
109
|
+
|
|
110
|
+
- test release [#296](https://github.com/friggframework/frigg/pull/296) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
111
|
+
- add a commit to fix canary and workaround auto bug ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
112
|
+
- bump to test release ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
113
|
+
|
|
114
|
+
#### Authors: 1
|
|
115
|
+
|
|
116
|
+
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
# v2.0.0 (Sat Mar 30 2024)
|
|
121
|
+
|
|
122
|
+
#### 🚀 Enhancement
|
|
123
|
+
|
|
124
|
+
- Package redo [#294](https://github.com/friggframework/frigg/pull/294) ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
125
|
+
|
|
126
|
+
#### 🐛 Bug Fix
|
|
127
|
+
|
|
128
|
+
- update test related imports in core ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
129
|
+
- missed one ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
130
|
+
- create test, eslint-config and prettier-config packages as base shared dependencies ([@MichaelRyanWebber](https://github.com/MichaelRyanWebber))
|
|
131
|
+
- Publish ([@seanspeaks](https://github.com/seanspeaks))
|
|
132
|
+
- Bump node and npm version for the whole repo (Fix CI) [#274](https://github.com/friggframework/frigg/pull/274) ([@seanspeaks](https://github.com/seanspeaks))
|
|
133
|
+
- Bump independent versions \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
|
|
134
|
+
|
|
135
|
+
#### Authors: 2
|
|
136
|
+
|
|
137
|
+
- [@MichaelRyanWebber](https://github.com/MichaelRyanWebber)
|
|
138
|
+
- Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
|
|
139
|
+
|
|
140
|
+
---
|
|
141
|
+
|
|
1
142
|
# v1.1.0 (Wed Mar 20 2024)
|
|
2
143
|
|
|
3
144
|
:tada: This release contains work from new contributors! :tada:
|
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Frigg Core
|
|
2
|
+
|
|
3
|
+
The `frigg-core` package is the heart of the Frigg Framework. It contains the core functionality and essential modules required to build and maintain integrations at scale.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Introduction](#introduction)
|
|
8
|
+
- [Features](#features)
|
|
9
|
+
- [Installation](#installation)
|
|
10
|
+
- [Usage](#usage)
|
|
11
|
+
- [Modules](#modules)
|
|
12
|
+
- [Contributing](#contributing)
|
|
13
|
+
- [License](#license)
|
|
14
|
+
|
|
15
|
+
## Introduction
|
|
16
|
+
|
|
17
|
+
The Frigg Core package provides the foundational components and utilities for the Frigg Framework. It is designed to be modular, extensible, and easy to integrate with other packages in the Frigg ecosystem.
|
|
18
|
+
|
|
19
|
+
## Features
|
|
20
|
+
|
|
21
|
+
- **Associations**: Manage relationships between different entities.
|
|
22
|
+
- **Database**: Database utilities and connectors.
|
|
23
|
+
- **Encryption**: Secure data encryption and decryption.
|
|
24
|
+
- **Error Handling**: Standardized error handling mechanisms.
|
|
25
|
+
- **Integrations**: Tools for building and managing integrations.
|
|
26
|
+
- **Lambda**: Utilities for AWS Lambda functions.
|
|
27
|
+
- **Logging**: Structured logging utilities.
|
|
28
|
+
- **Module Plugin**: Plugin system for extending core functionality.
|
|
29
|
+
- **Syncs**: Synchronization utilities for data consistency.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
To install the `frigg-core` package, use npm or yarn:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npm install @friggframework/core
|
|
37
|
+
# or
|
|
38
|
+
yarn add @friggframework/core
|
|
39
|
+
```
|
|
40
|
+
## Usage
|
|
41
|
+
Here's a basic example of how to use the frigg-core package:
|
|
42
|
+
```javascript
|
|
43
|
+
const { encrypt, decrypt } = require('@friggframework/core/encrypt');
|
|
44
|
+
const { logInfo } = require('@friggframework/core/logs');
|
|
45
|
+
|
|
46
|
+
const secret = 'mySecret';
|
|
47
|
+
const encrypted = encrypt(secret);
|
|
48
|
+
const decrypted = decrypt(encrypted);
|
|
49
|
+
|
|
50
|
+
logInfo(`Encrypted: ${encrypted}`);
|
|
51
|
+
logInfo(`Decrypted: ${decrypted}`);
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Modules
|
|
55
|
+
|
|
56
|
+
The frigg-core package is organized into several modules:
|
|
57
|
+
|
|
58
|
+
- **Associations**: @friggframework/core/associations
|
|
59
|
+
- **Database**: @friggframework/core/database
|
|
60
|
+
- **Encryption**: @friggframework/core/encrypt
|
|
61
|
+
- **Errors**: @friggframework/core/errors
|
|
62
|
+
- **Integrations**: @friggframework/core/integrations
|
|
63
|
+
- **Lambda**: @friggframework/core/lambda
|
|
64
|
+
- **Logs**: @friggframework/core/logs
|
|
65
|
+
- **Module Plugin**: @friggframework/core/module-plugin
|
|
66
|
+
- **Syncs**: @friggframework/core/syncs
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
Each module provides specific functionality and can be imported individually as needed.
|
|
70
|
+
|
|
71
|
+
## Contributing
|
|
72
|
+
|
|
73
|
+
We welcome contributions from the community! Please read our contributing guide to get started. Make sure to follow our code of conduct and use the provided pull request template.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
This project is licensed under the MIT License. See the LICENSE.md file for details.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
Thank you for using Frigg Core! If you have any questions or need further assistance, feel free to reach out to our community on Slack or check out our GitHub issues page.
|
package/encrypt/encrypt.test.js
CHANGED
|
@@ -8,7 +8,7 @@ const {
|
|
|
8
8
|
createModel,
|
|
9
9
|
saveTestDocument,
|
|
10
10
|
} = require('./test-encrypt');
|
|
11
|
-
const { TestMongo } = require('
|
|
11
|
+
const { TestMongo } = require('@friggframework/test');
|
|
12
12
|
|
|
13
13
|
const testMongo = new TestMongo();
|
|
14
14
|
const originalEnv = process.env;
|
|
@@ -3,7 +3,7 @@ const { BaseError } = require('./base-error');
|
|
|
3
3
|
class RequiredPropertyError extends BaseError {
|
|
4
4
|
constructor(options = {}, ...parentOptions) {
|
|
5
5
|
const { parent, key = '' } = options;
|
|
6
|
-
const parentText = parent ? `(${parent.name}) ` : '';
|
|
6
|
+
const parentText = parent?.name ? `(${parent.name}) ` : '';
|
|
7
7
|
const message = `${parentText}Key "${key}" is a required parameter.`;
|
|
8
8
|
super(message, ...parentOptions);
|
|
9
9
|
}
|
|
@@ -12,7 +12,7 @@ class RequiredPropertyError extends BaseError {
|
|
|
12
12
|
class ParameterTypeError extends BaseError {
|
|
13
13
|
constructor(options = {}, ...parentOptions) {
|
|
14
14
|
const { parent, key = '', value = '', expectedType } = options;
|
|
15
|
-
const parentText = parent ? `(${parent.name}) ` : '';
|
|
15
|
+
const parentText = parent?.name ? `(${parent.name}) ` : '';
|
|
16
16
|
const keyText = key ? `key "${key}" with ` : '';
|
|
17
17
|
const typeName = expectedType?.name ?? '';
|
|
18
18
|
const message = `${parentText}Expected ${keyText}value "${value}" to be of type "${typeName}"`;
|
package/index.js
CHANGED
|
@@ -36,9 +36,7 @@ const {
|
|
|
36
36
|
IntegrationHelper,
|
|
37
37
|
createIntegrationRouter,
|
|
38
38
|
checkRequiredParams,
|
|
39
|
-
createFriggBackend
|
|
40
|
-
createMockIntegration,
|
|
41
|
-
createMockApiObject
|
|
39
|
+
createFriggBackend
|
|
42
40
|
} = require('./integrations/index');
|
|
43
41
|
const { TimeoutCatcher } = require('./lambda/index');
|
|
44
42
|
const {
|
|
@@ -57,9 +55,7 @@ const {
|
|
|
57
55
|
Requester,
|
|
58
56
|
ModuleConstants,
|
|
59
57
|
ModuleFactory,
|
|
60
|
-
Auther
|
|
61
|
-
testAutherDefinition,
|
|
62
|
-
testDefinitionRequiredAuthMethods
|
|
58
|
+
Auther
|
|
63
59
|
} = require('./module-plugin/index');
|
|
64
60
|
|
|
65
61
|
// const {Sync } = require('./syncs/model');
|
package/integrations/index.js
CHANGED
|
@@ -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 };
|
|
@@ -87,18 +87,6 @@ class IntegrationFactory {
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
async createIntegration(entities, userId, config) {
|
|
90
|
-
// verify entity ids belong to the user
|
|
91
|
-
// for (const id of entities) {
|
|
92
|
-
// const entity = await Entity.findById(id);
|
|
93
|
-
// if (!entity) {
|
|
94
|
-
// throw new Error(`Entity with ID ${id} does not exist.`);
|
|
95
|
-
// }
|
|
96
|
-
// if (entity.user.toString() !== userId.toString()) {
|
|
97
|
-
// throw new Error('one or more the entities do not belong to the user');
|
|
98
|
-
// }
|
|
99
|
-
// }
|
|
100
|
-
|
|
101
|
-
// build integration
|
|
102
90
|
const integrationRecord = await IntegrationModel.create({
|
|
103
91
|
entities: entities,
|
|
104
92
|
user: userId,
|
|
@@ -80,7 +80,6 @@ function setIntegrationRoutes(router, factory, getUserId) {
|
|
|
80
80
|
params.entities,
|
|
81
81
|
getUserId(req),
|
|
82
82
|
params.config,
|
|
83
|
-
moduleFactory
|
|
84
83
|
);
|
|
85
84
|
|
|
86
85
|
// post integration initialization
|
|
@@ -89,12 +88,9 @@ function setIntegrationRoutes(router, factory, getUserId) {
|
|
|
89
88
|
);
|
|
90
89
|
await integration.onCreate();
|
|
91
90
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
integration.record
|
|
91
|
+
res.status(201).json(
|
|
92
|
+
await IntegrationHelper.getFormattedIntegration(integration.record)
|
|
95
93
|
);
|
|
96
|
-
res.status(201);
|
|
97
|
-
res.json(response);
|
|
98
94
|
})
|
|
99
95
|
);
|
|
100
96
|
|
|
@@ -114,11 +110,9 @@ function setIntegrationRoutes(router, factory, getUserId) {
|
|
|
114
110
|
);
|
|
115
111
|
await integration.onUpdate(params);
|
|
116
112
|
|
|
117
|
-
|
|
118
|
-
integration.record
|
|
113
|
+
res.json(
|
|
114
|
+
await IntegrationHelper.getFormattedIntegration(integration.record)
|
|
119
115
|
);
|
|
120
|
-
|
|
121
|
-
res.json(response);
|
|
122
116
|
})
|
|
123
117
|
);
|
|
124
118
|
|
|
@@ -142,8 +136,7 @@ function setIntegrationRoutes(router, factory, getUserId) {
|
|
|
142
136
|
params.integrationId
|
|
143
137
|
);
|
|
144
138
|
|
|
145
|
-
res.status(201);
|
|
146
|
-
res.json({});
|
|
139
|
+
res.status(201).json({});
|
|
147
140
|
})
|
|
148
141
|
);
|
|
149
142
|
|
|
@@ -154,9 +147,21 @@ function setIntegrationRoutes(router, factory, getUserId) {
|
|
|
154
147
|
]);
|
|
155
148
|
const integration =
|
|
156
149
|
await integrationFactory.getInstanceFromIntegrationId(params);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
150
|
+
res.json(await integration.getConfigOptions());
|
|
151
|
+
})
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
router.route('/api/integrations/:integrationId/config/options/refresh').post(
|
|
155
|
+
catchAsyncError(async (req, res) => {
|
|
156
|
+
const params = checkRequiredParams(req.params, [
|
|
157
|
+
'integrationId',
|
|
158
|
+
]);
|
|
159
|
+
const integration =
|
|
160
|
+
await integrationFactory.getInstanceFromIntegrationId(params);
|
|
161
|
+
|
|
162
|
+
res.json(
|
|
163
|
+
await integration.refreshConfigOptions(req.body)
|
|
164
|
+
);
|
|
160
165
|
})
|
|
161
166
|
);
|
|
162
167
|
|
|
@@ -168,11 +173,25 @@ function setIntegrationRoutes(router, factory, getUserId) {
|
|
|
168
173
|
]);
|
|
169
174
|
const integration =
|
|
170
175
|
await integrationFactory.getInstanceFromIntegrationId(params);
|
|
171
|
-
|
|
172
|
-
|
|
176
|
+
|
|
177
|
+
res.json(
|
|
178
|
+
await integration.getActionOptions(params.actionId)
|
|
179
|
+
);
|
|
180
|
+
})
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
router.route('/api/integrations/:integrationId/actions/:actionId/options/refresh').post(
|
|
184
|
+
catchAsyncError(async (req, res) => {
|
|
185
|
+
const params = checkRequiredParams(req.params, [
|
|
186
|
+
'integrationId',
|
|
187
|
+
'actionId'
|
|
188
|
+
]);
|
|
189
|
+
const integration =
|
|
190
|
+
await integrationFactory.getInstanceFromIntegrationId(params);
|
|
191
|
+
|
|
192
|
+
res.json(
|
|
193
|
+
await integration.refreshActionOptions(params.actionId, req.body)
|
|
173
194
|
);
|
|
174
|
-
// We could perhaps augment router with dynamic options? Haven't decided yet, but here may be the place
|
|
175
|
-
res.json(results);
|
|
176
195
|
})
|
|
177
196
|
);
|
|
178
197
|
|
|
@@ -184,14 +203,12 @@ function setIntegrationRoutes(router, factory, getUserId) {
|
|
|
184
203
|
]);
|
|
185
204
|
const integration =
|
|
186
205
|
await integrationFactory.getInstanceFromIntegrationId(params);
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
req.body
|
|
206
|
+
|
|
207
|
+
res.json(
|
|
208
|
+
await integration.notify(params.actionId, req.body)
|
|
190
209
|
);
|
|
191
|
-
// We could perhaps augment router with dynamic options? Haven't decided yet, but here may be the place
|
|
192
|
-
res.json(results);
|
|
193
210
|
})
|
|
194
|
-
)
|
|
211
|
+
);
|
|
195
212
|
|
|
196
213
|
router.route('/api/integrations/:integrationId').get(
|
|
197
214
|
catchAsyncError(async (req, res) => {
|
|
@@ -268,6 +285,7 @@ function setEntityRoutes(router, factory, getUserId) {
|
|
|
268
285
|
`Error: EntityManager of type ${params.entityType} requires a valid url`
|
|
269
286
|
);
|
|
270
287
|
}
|
|
288
|
+
|
|
271
289
|
res.json(await module.getAuthorizationRequirements());
|
|
272
290
|
})
|
|
273
291
|
);
|
|
@@ -278,35 +296,14 @@ function setEntityRoutes(router, factory, getUserId) {
|
|
|
278
296
|
'entityType',
|
|
279
297
|
'data',
|
|
280
298
|
]);
|
|
281
|
-
console.log('post authorize', params);
|
|
282
299
|
const module = await getModuleInstance(req, params.entityType);
|
|
283
|
-
console.log('post authorize module', module);
|
|
284
|
-
const results = await module.processAuthorizationCallback({
|
|
285
|
-
userId: getUserId(req),
|
|
286
|
-
data: params.data,
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
res.json(results);
|
|
290
|
-
})
|
|
291
|
-
);
|
|
292
300
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
req.params.credentialId
|
|
301
|
+
res.json(
|
|
302
|
+
await module.processAuthorizationCallback({
|
|
303
|
+
userId: getUserId(req),
|
|
304
|
+
data: params.data,
|
|
305
|
+
})
|
|
299
306
|
);
|
|
300
|
-
if (credential.user._id.toString() !== getUserId(req)) {
|
|
301
|
-
throw Boom.forbidden('Credential does not belong to user');
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
const params = checkRequiredParams(req.query, [
|
|
305
|
-
'entityType',
|
|
306
|
-
]);
|
|
307
|
-
const module = await getModuleInstance(req, params.entityType);
|
|
308
|
-
|
|
309
|
-
res.json(await module.getEntityOptions());
|
|
310
307
|
})
|
|
311
308
|
);
|
|
312
309
|
|
|
@@ -328,7 +325,36 @@ function setEntityRoutes(router, factory, getUserId) {
|
|
|
328
325
|
}
|
|
329
326
|
|
|
330
327
|
const module = await getModuleInstance(req, params.entityType);
|
|
331
|
-
|
|
328
|
+
const entityDetails = await module.getEntityDetails(
|
|
329
|
+
module.api,
|
|
330
|
+
null,
|
|
331
|
+
null,
|
|
332
|
+
getUserId(req)
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
res.json(
|
|
336
|
+
await module.findOrCreateEntity(entityDetails)
|
|
337
|
+
);
|
|
338
|
+
})
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
router.route('/api/entity/options/:credentialId').get(
|
|
342
|
+
catchAsyncError(async (req, res) => {
|
|
343
|
+
// TODO May want to pass along the user ID as well so credential ID's can't be fished???
|
|
344
|
+
// TODO **flagging this for review** -MW
|
|
345
|
+
const credential = await IntegrationHelper.getCredentialById(
|
|
346
|
+
req.params.credentialId
|
|
347
|
+
);
|
|
348
|
+
if (credential.user._id.toString() !== getUserId(req)) {
|
|
349
|
+
throw Boom.forbidden('Credential does not belong to user');
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const params = checkRequiredParams(req.query, [
|
|
353
|
+
'entityType',
|
|
354
|
+
]);
|
|
355
|
+
const module = await getModuleInstance(req, params.entityType);
|
|
356
|
+
|
|
357
|
+
res.json(await module.getEntityOptions());
|
|
332
358
|
})
|
|
333
359
|
);
|
|
334
360
|
|
|
@@ -352,7 +378,7 @@ function setEntityRoutes(router, factory, getUserId) {
|
|
|
352
378
|
errors: [
|
|
353
379
|
{
|
|
354
380
|
title: 'Authentication Error',
|
|
355
|
-
message: `There was an error with your ${module.
|
|
381
|
+
message: `There was an error with your ${module.getName()} Entity. Please reconnect/re-authenticate, or reach out to Support for assistance.`,
|
|
356
382
|
timestamp: Date.now(),
|
|
357
383
|
},
|
|
358
384
|
],
|
|
@@ -362,6 +388,60 @@ function setEntityRoutes(router, factory, getUserId) {
|
|
|
362
388
|
}
|
|
363
389
|
})
|
|
364
390
|
);
|
|
391
|
+
|
|
392
|
+
router.route('/api/entities/:entityId').get(
|
|
393
|
+
catchAsyncError(async (req, res) => {
|
|
394
|
+
const params = checkRequiredParams(req.params, ['entityId']);
|
|
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(module.entity);
|
|
405
|
+
})
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
router.route('/api/entities/:entityId/options').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.getEntityOptions());
|
|
424
|
+
})
|
|
425
|
+
);
|
|
426
|
+
|
|
427
|
+
router.route('/api/entities/:entityId/options/refresh').post(
|
|
428
|
+
catchAsyncError(async (req, res) => {
|
|
429
|
+
const params = checkRequiredParams(req.params, [
|
|
430
|
+
'entityId',
|
|
431
|
+
getUserId(req)
|
|
432
|
+
]);
|
|
433
|
+
const module = await moduleFactory.getModuleInstanceFromEntityId(
|
|
434
|
+
params.entityId,
|
|
435
|
+
getUserId(req)
|
|
436
|
+
);
|
|
437
|
+
|
|
438
|
+
if (!module) {
|
|
439
|
+
throw Boom.notFound();
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
res.json(await module.refreshEntityOptions(req.body));
|
|
443
|
+
})
|
|
444
|
+
);
|
|
365
445
|
}
|
|
366
446
|
|
|
367
447
|
module.exports = { createIntegrationRouter, checkRequiredParams };
|
|
@@ -2,7 +2,8 @@ const _ = require('lodash');
|
|
|
2
2
|
const { mongoose } = require('../../database/mongoose');
|
|
3
3
|
const { expect } = require('chai');
|
|
4
4
|
const { IntegrationBase } = require("../integration-base");
|
|
5
|
-
const {Credential
|
|
5
|
+
const {Credential} = require('../../module-plugin/credential');
|
|
6
|
+
const {Entity} = require('../../module-plugin/entity');
|
|
6
7
|
const { IntegrationMapping } = require('../integration-mapping')
|
|
7
8
|
const {IntegrationModel} = require("../integration-model");
|
|
8
9
|
|
package/jest-setup.js
ADDED
package/jest-teardown.js
ADDED
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* For a detailed explanation regarding each configuration property, visit:
|
|
3
3
|
* https://jestjs.io/docs/configuration
|
|
4
4
|
*/
|
|
5
|
+
|
|
5
6
|
module.exports = {
|
|
6
|
-
// preset: '@friggframework/test
|
|
7
|
+
// preset: '@friggframework/test',
|
|
7
8
|
coverageThreshold: {
|
|
8
9
|
global: {
|
|
9
10
|
statements: 13,
|