@friggframework/devtools 1.0.1-v1-alpha-package-update.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.
Files changed (40) hide show
  1. package/LICENSE.md +9 -0
  2. package/eslint-config/.eslintrc.json +3 -0
  3. package/eslint-config/CHANGELOG.md +17 -0
  4. package/eslint-config/LICENSE.md +9 -0
  5. package/eslint-config/README.md +3 -0
  6. package/eslint-config/bump3.txt +0 -0
  7. package/eslint-config/index.js +38 -0
  8. package/index.js +9 -0
  9. package/migrations/README.md +3 -0
  10. package/migrations/bump3.txt +0 -0
  11. package/migrations/index.js +9 -0
  12. package/migrations/jest.config.js +3 -0
  13. package/migrations/manager.js +33 -0
  14. package/migrations/migrator.js +170 -0
  15. package/migrations/options.js +28 -0
  16. package/package.json +40 -0
  17. package/prettier-config/.eslintrc.json +3 -0
  18. package/prettier-config/CHANGELOG.md +17 -0
  19. package/prettier-config/LICENSE.md +9 -0
  20. package/prettier-config/README.md +3 -0
  21. package/prettier-config/bump3.txt +0 -0
  22. package/prettier-config/index.js +6 -0
  23. package/test-environment/.eslintrc.json +3 -0
  24. package/test-environment/Authenticator.js +73 -0
  25. package/test-environment/CHANGELOG.md +46 -0
  26. package/test-environment/LICENSE.md +9 -0
  27. package/test-environment/README.md +3 -0
  28. package/test-environment/auther-definition-method-tester.js +45 -0
  29. package/test-environment/auther-definition-tester.js +104 -0
  30. package/test-environment/bump3.txt +0 -0
  31. package/test-environment/index.js +24 -0
  32. package/test-environment/integration-validator.js +2 -0
  33. package/test-environment/jest-global-setup.js +6 -0
  34. package/test-environment/jest-global-teardown.js +3 -0
  35. package/test-environment/jest-preset.js +14 -0
  36. package/test-environment/mock-api-readme.md +102 -0
  37. package/test-environment/mock-api.js +284 -0
  38. package/test-environment/mock-integration.js +82 -0
  39. package/test-environment/mongodb.js +22 -0
  40. package/test-environment/override-environment.js +11 -0
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Left Hook Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@friggframework/eslint-config"
3
+ }
@@ -0,0 +1,17 @@
1
+ # v1.0.8 (Mon Jan 09 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Merge remote-tracking branch 'origin/main' into gitbook-updates [#48](https://github.com/friggframework/frigg/pull/48) ([@seanspeaks](https://github.com/seanspeaks))
6
+ - Bump independent versions \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
7
+ - Merge remote-tracking branch 'origin/main' into simplify-mongoose-models ([@seanspeaks](https://github.com/seanspeaks))
8
+ - Add READMEs for all packages and api-modules [#20](https://github.com/friggframework/frigg/pull/20) ([@seanspeaks](https://github.com/seanspeaks))
9
+ - Add READMEs for all packages and api-modules ([@seanspeaks](https://github.com/seanspeaks))
10
+
11
+ #### ⚠️ Pushed to `main`
12
+
13
+ - Refactored for more conventional naming (at least for packages) ([@seanspeaks](https://github.com/seanspeaks))
14
+
15
+ #### Authors: 1
16
+
17
+ - Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Left Hook Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # eslint-config
2
+
3
+ This package exports the default `eslint-config` settings used in [Frigg](https://friggframework.org). You can find its documentation [on Frigg's website](https://docs.friggframework.org/packages/eslint-config).
File without changes
@@ -0,0 +1,38 @@
1
+ module.exports = {
2
+ env: {
3
+ commonjs: true,
4
+ es2020: true,
5
+ jest: true,
6
+ },
7
+ extends: ['prettier', 'plugin:markdown/recommended'],
8
+ parser: '@babel/eslint-parser',
9
+ parserOptions: {
10
+ ecmaVersion: 11,
11
+ requireConfigFile: false,
12
+ },
13
+ plugins: ['no-only-tests'],
14
+ ignorePatterns: ['coverage/', '.nyc_output/'],
15
+ overrides: [
16
+ {
17
+ files: ['*.json'],
18
+ plugins: ['json'],
19
+ extends: ['plugin:json/recommended'],
20
+ },
21
+ {
22
+ files: ['*.yaml', '*.yml'],
23
+ plugins: ['yaml'],
24
+ extends: ['plugin:yaml/recommended'],
25
+ },
26
+ ],
27
+ rules: {
28
+ 'no-only-tests/no-only-tests': ['error', { fix: false }],
29
+ 'no-unused-vars': [
30
+ 'warn',
31
+ { vars: 'all', args: 'after-used', ignoreRestSiblings: false },
32
+ ],
33
+ 'no-console': ['warn'],
34
+ camelcase: ['warn'],
35
+ 'no-mixed-requires': ['warn'],
36
+ 'no-warning-comments': ['warn'],
37
+ },
38
+ };
package/index.js ADDED
@@ -0,0 +1,9 @@
1
+ const eslintConfig = require('./eslint-config')
2
+ const prettierConfig = require('./prettier-config')
3
+ const testEnvironment = require('./test-environment/index');
4
+
5
+ module.exports = {
6
+ eslintConfig,
7
+ prettierConfig,
8
+ ...testEnvironment
9
+ }
@@ -0,0 +1,3 @@
1
+ # migrations
2
+
3
+ This package exports the `migrations` class and functions used in [Frigg](https://friggframework.org). You can find its documentation [on Frigg's website](https://docs.friggframework.org/packages/migrations).
File without changes
@@ -0,0 +1,9 @@
1
+ const MigrationManager = require('./manager');
2
+ const Migrator = require('./migrator');
3
+ const MigrationOptions = require('./options');
4
+
5
+ module.exports = {
6
+ MigrationManager,
7
+ Migrator,
8
+ MigrationOptions
9
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = async () => {
2
+ preset: "@friggframework/test-environment";
3
+ };
@@ -0,0 +1,33 @@
1
+ const hubspotMigrator = require("./HubSpotMigrator");
2
+ const salesforceMigrator = require("./SalesforceMigrator");
3
+
4
+ class MigrationManager {
5
+ static migratorClasses = [hubspotMigrator, salesforceMigrator];
6
+
7
+ static integrationTypes = MigrationManager.migratorClasses.map(
8
+ (MigratorClass) => MigratorClass.getName()
9
+ );
10
+
11
+ constructor() {
12
+ // ...
13
+ }
14
+
15
+ static async getMigrator(params) {
16
+ const { integrationType, fromVersion, toVersion } = params;
17
+ const indexOfMigrator =
18
+ MigrationManager.integrationTypes.indexOf(integrationType);
19
+ if (indexOfMigrator < 0) {
20
+ throw new Error(
21
+ `Error: Invalid integration type of ${
22
+ params.integrationType
23
+ }, options are ${MigrationManager.integrationTypes.join(", ")}`
24
+ );
25
+ }
26
+ const instance = await MigrationManager.migratorClasses[
27
+ indexOfMigrator
28
+ ].getInstance();
29
+ return instance;
30
+ }
31
+ }
32
+
33
+ module.exports = MigrationManager;
@@ -0,0 +1,170 @@
1
+ const { Delegate } = require('../../core/core');
2
+ const { Integration } = require('../../core/integrations');
3
+ const { get } = require('../../core/assertions');
4
+
5
+ class Migrator extends Delegate {
6
+ constructor(params) {
7
+ super(params);
8
+ this.options = [];
9
+ }
10
+
11
+ static getInstance() {
12
+ const instance = new this();
13
+ return instance;
14
+ }
15
+
16
+ static getName() {
17
+ return this.integrationManager.getName();
18
+ }
19
+
20
+ async migrate(params) {
21
+ try {
22
+ const fromVersion = get(params, "fromVersion", null);
23
+ const toVersion = get(params, "toVersion");
24
+
25
+ console.log("Migrate called. First validating whether it can be done.");
26
+ if (
27
+ !this.integrationManager.Config.supportedVersions.some(
28
+ (version) => version === toVersion
29
+ )
30
+ ) {
31
+ return this.throwException(
32
+ `Attempting to migrate to an unsupported version. Current supported versions are ${this.integrationManager.Config.supportedVersions.join(
33
+ ", "
34
+ )}`,
35
+ "Migration Error"
36
+ );
37
+ }
38
+ const migrationOption = this.options
39
+ .map((val) => val.get())
40
+ .find(
41
+ (option) =>
42
+ option.fromVersion === fromVersion && option.toVersion === toVersion
43
+ );
44
+ if (!migrationOption)
45
+ return this.throwException(
46
+ `No migration option found for version ${fromVersion} to ${toVersion}`,
47
+ "Migration Error"
48
+ );
49
+ // Run all general functions
50
+ for (const generalFunct of migrationOption.generalFunctions) {
51
+ console.log("Running general functions first");
52
+ const res = await generalFunct();
53
+ console.log(res);
54
+ }
55
+ // Get all integration records based on fromVersion
56
+ const filter = {
57
+ "config.type": this.integrationManager.getName(),
58
+ };
59
+ console.log(
60
+ `Retrieved all ${this.integrationManager.getName()} integrations`
61
+ );
62
+
63
+ const integrations = await Integration.find(filter);
64
+ const filteredIntegrations = integrations.filter((int) => {
65
+ const isNotToVersion = int.version !== toVersion;
66
+ let isFromVersion = true;
67
+ if (fromVersion && fromVersion !== "*") {
68
+ isFromVersion = int.version === fromVersion;
69
+ }
70
+ return isNotToVersion && isFromVersion;
71
+ });
72
+ const results = {
73
+ integrationType: this.integrationManager.getName(),
74
+ totalIntegrations: integrations.length,
75
+ versionReport: {
76
+ startVersions: {},
77
+ endVersions: {},
78
+ },
79
+ statusReport: {
80
+ startStatuses: {},
81
+ endStatuses: {},
82
+ },
83
+ toMigrate: filteredIntegrations.length,
84
+ migrationResults: {
85
+ success: 0,
86
+ needsConfig: 0,
87
+ error: 0,
88
+ },
89
+ };
90
+
91
+ for (const integration of integrations) {
92
+ if (results.versionReport.startVersions[integration.version]) {
93
+ results.versionReport.startVersions[integration.version] += 1;
94
+ } else {
95
+ results.versionReport.startVersions[integration.version] = 1;
96
+ }
97
+ if (results.statusReport.startStatuses[integration.status]) {
98
+ results.statusReport.startStatuses[integration.status] += 1;
99
+ } else {
100
+ results.statusReport.startStatuses[integration.status] = 1;
101
+ }
102
+ }
103
+
104
+ // Instantiate the integrationManager based on integration ID, run all specific functions for each integration
105
+ for (const integration of filteredIntegrations) {
106
+ let integrationManagerInstance;
107
+ try {
108
+ integrationManagerInstance =
109
+ await this.integrationManager.getInstanceFromIntegrationId({
110
+ integrationId: integration.id,
111
+ userId: integration.user.id,
112
+ });
113
+ } catch (e) {
114
+ console.log(e);
115
+ }
116
+ // Test Auth
117
+ if (integrationManagerInstance) {
118
+ await integrationManagerInstance.testAuth();
119
+
120
+ // Run functions
121
+ if (integrationManagerInstance.integration.status !== "ERROR") {
122
+ for (const func of migrationOption.perIntegrationFunctions) {
123
+ const res = await func(integrationManagerInstance);
124
+ console.log(res);
125
+ }
126
+ }
127
+
128
+ // Validate Config
129
+ if (integrationManagerInstance.integration.status !== "ERROR") {
130
+ await integrationManagerInstance.validateConfig();
131
+ }
132
+
133
+ // Add to results tally
134
+ const currentStatus = integrationManagerInstance.integration.status;
135
+ if (currentStatus === "ENABLED") {
136
+ integrationManagerInstance.integration.version = toVersion;
137
+ await integrationManagerInstance.integration.save();
138
+ results.migrationResults.success += 1;
139
+ }
140
+ if (currentStatus === "NEEDS_CONFIG") {
141
+ integrationManagerInstance.integration.version = toVersion;
142
+ await integrationManagerInstance.integration.save();
143
+ results.migrationResults.needsConfig += 1;
144
+ }
145
+ if (currentStatus === "ERROR") results.migrationResults.error += 1;
146
+ }
147
+ }
148
+
149
+ const freshRetrieve = await Integration.find(filter);
150
+ for (const int of freshRetrieve) {
151
+ if (results.versionReport.endVersions[int.version]) {
152
+ results.versionReport.endVersions[int.version] += 1;
153
+ } else {
154
+ results.versionReport.endVersions[int.version] = 1;
155
+ }
156
+ if (results.statusReport.endStatuses[int.status]) {
157
+ results.statusReport.endStatuses[int.status] += 1;
158
+ } else {
159
+ results.statusReport.endStatuses[int.status] = 1;
160
+ }
161
+ }
162
+
163
+ return results;
164
+ } catch (e) {
165
+ this.throwException(e.message, "Migrate Error");
166
+ }
167
+ }
168
+ }
169
+
170
+ module.exports = Migrator;
@@ -0,0 +1,28 @@
1
+ const IntegrationManager = require('../../core/integrations');
2
+ const { get, getAndVerifyType } = require('../../core/assertions');
3
+
4
+ class Options {
5
+ constructor(params) {
6
+ this.integrationManager = getAndVerifyType(
7
+ params,
8
+ "integrationManager",
9
+ IntegrationManager
10
+ );
11
+ this.fromVersion = get(params, "fromVersion");
12
+ this.toVersion = get(params, "toVersion");
13
+ this.generalFunctions = get(params, "generalFunctions", []);
14
+ this.perIntegrationFunctions = get(params, "perIntegrationFunctions", []);
15
+ }
16
+
17
+ get() {
18
+ return {
19
+ type: this.integrationManager.getName(),
20
+ fromVersion: this.fromVersion,
21
+ toVersion: this.toVersion,
22
+ generalFunctions: this.generalFunctions,
23
+ perIntegrationFunctions: this.perIntegrationFunctions,
24
+ };
25
+ }
26
+ }
27
+
28
+ module.exports = Options;
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@friggframework/devtools",
3
+ "prettier": "@friggframework/prettier-config",
4
+ "version": "1.0.1-v1-alpha-package-update.0",
5
+ "dependencies": {
6
+ "@babel/eslint-parser": "^7.18.9",
7
+ "eslint": "^8.22.0",
8
+ "eslint-config-prettier": "^8.5.0",
9
+ "eslint-plugin-json": "^3.1.0",
10
+ "eslint-plugin-markdown": "^3.0.0",
11
+ "eslint-plugin-no-only-tests": "^3.0.0",
12
+ "eslint-plugin-yaml": "^0.5.0",
13
+ "jest-runner-groups": "^2.2.0",
14
+ "mongodb-memory-server": "^8.9.0"
15
+ },
16
+ "devDependencies": {
17
+ "jest": "^28.1.3",
18
+ "prettier": "^2.7.1"
19
+ },
20
+ "scripts": {
21
+ "lint:fix": "prettier --write --loglevel error . && eslint . --fix",
22
+ "test": "jest --passWithNoTests # TODO"
23
+ },
24
+ "author": "",
25
+ "license": "MIT",
26
+ "main": "index.js",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/friggframework/frigg.git"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/friggframework/frigg/issues"
33
+ },
34
+ "homepage": "https://github.com/friggframework/frigg#readme",
35
+ "description": "",
36
+ "publishConfig": {
37
+ "access": "public"
38
+ },
39
+ "gitHead": "2f565b1c08c09828c97f07c351a40ae6e4480186"
40
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@friggframework/eslint-config"
3
+ }
@@ -0,0 +1,17 @@
1
+ # v1.0.6 (Mon Jan 09 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Merge remote-tracking branch 'origin/main' into gitbook-updates [#48](https://github.com/friggframework/frigg/pull/48) ([@seanspeaks](https://github.com/seanspeaks))
6
+ - Bump independent versions \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
7
+ - Merge remote-tracking branch 'origin/main' into simplify-mongoose-models ([@seanspeaks](https://github.com/seanspeaks))
8
+ - Add READMEs for all packages and api-modules [#20](https://github.com/friggframework/frigg/pull/20) ([@seanspeaks](https://github.com/seanspeaks))
9
+ - Add READMEs for all packages and api-modules ([@seanspeaks](https://github.com/seanspeaks))
10
+
11
+ #### ⚠️ Pushed to `main`
12
+
13
+ - Refactored for more conventional naming (at least for packages) ([@seanspeaks](https://github.com/seanspeaks))
14
+
15
+ #### Authors: 1
16
+
17
+ - Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Left Hook Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # prettier-config
2
+
3
+ This package exports the `prettier-config` default used in [Frigg](https://friggframework.org). You can find its documentation [on Frigg's website](https://docs.friggframework.org/packages/prettier-config).
File without changes
@@ -0,0 +1,6 @@
1
+ module.exports = {
2
+ semi: true,
3
+ tabWidth: 4,
4
+ singleQuote: true,
5
+ useTabs: false,
6
+ };
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "@friggframework/eslint-config"
3
+ }
@@ -0,0 +1,73 @@
1
+ // "use strict";
2
+ const http = require('http');
3
+ const url = require('url');
4
+ const open = require('open');
5
+
6
+ class Authenticator {
7
+ static searchParamsToDictionary(params) {
8
+ const entries = params.entries();
9
+ const result = {};
10
+ for (const entry of entries) {
11
+ const [key, value] = entry;
12
+ result[key] = value;
13
+ }
14
+ return result;
15
+ }
16
+
17
+ static async oauth2(authorizeUrl, port = 3000) {
18
+ return new Promise((resolve, reject) => {
19
+ const server = http
20
+ .createServer(async (req, res) => {
21
+ try {
22
+ const qs = new url.URL(
23
+ req.url,
24
+ `http://localhost:${port}`
25
+ ).searchParams;
26
+
27
+ // gets the last parameter in the slash
28
+ const urlPostfix = req.url.split('?')[0];
29
+
30
+ const params =
31
+ Authenticator.searchParamsToDictionary(qs);
32
+
33
+ res.end(
34
+ `<h1 style="position: absolute;top: 50%;left: 50%;transform: translate(-50%, -50%);">Feel free to close the Brow Brow now</h1>
35
+ <style>@media (prefers-color-scheme: dark) {
36
+ body {
37
+ color: #b0b0b0;
38
+ background-color: #101010;
39
+ }
40
+ </style>`
41
+ );
42
+ server.close();
43
+ resolve({
44
+ base: urlPostfix,
45
+ data: params,
46
+ });
47
+ } catch (e) {
48
+ reject(e);
49
+ }
50
+ })
51
+ .listen(port, () => {
52
+ // open the browser to the authorize url to start the workflow
53
+ open(authorizeUrl).then((childProcess) => {
54
+ childProcess.unref();
55
+ clearTimeout(timeoutId);
56
+ });
57
+ });
58
+
59
+ const timeoutId = setTimeout(() => {
60
+ if (server.listening) {
61
+ try {
62
+ server.close();
63
+ } finally {
64
+ throw new Error(
65
+ 'Authenticator timed out before authentication completed in the browser.'
66
+ );
67
+ }
68
+ }
69
+ }, 59_000);
70
+ });
71
+ }
72
+ }
73
+ module.exports = Authenticator;
@@ -0,0 +1,46 @@
1
+ # v1.1.6 (Tue Jan 31 2023)
2
+
3
+ #### 🐛 Bug Fix
4
+
5
+ - Updates/api module yotpo [#108](https://github.com/friggframework/frigg/pull/108) ([@seanspeaks](https://github.com/seanspeaks))
6
+ - # mock-api.js Work in Progress ([@seanspeaks](https://github.com/seanspeaks))
7
+ - Bump independent versions \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
8
+
9
+ #### Authors: 1
10
+
11
+ - Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
12
+
13
+ ---
14
+
15
+ # v1.1.5 (Mon Jan 09 2023)
16
+
17
+ #### 🐛 Bug Fix
18
+
19
+ - Merge remote-tracking branch 'origin/main' into gitbook-updates [#48](https://github.com/friggframework/frigg/pull/48) ([@seanspeaks](https://github.com/seanspeaks))
20
+ - Bump independent versions \[skip ci\] ([@seanspeaks](https://github.com/seanspeaks))
21
+ - Merge remote-tracking branch 'origin/main' into simplify-mongoose-models ([@seanspeaks](https://github.com/seanspeaks))
22
+ - Add READMEs for all packages and api-modules [#20](https://github.com/friggframework/frigg/pull/20) ([@seanspeaks](https://github.com/seanspeaks))
23
+ - Add READMEs for all packages and api-modules ([@seanspeaks](https://github.com/seanspeaks))
24
+
25
+ #### ⚠️ Pushed to `main`
26
+
27
+ - Merge branch 'main' into gitbook-updates ([@seanspeaks](https://github.com/seanspeaks))
28
+ - Refactored for more conventional naming (at least for packages) ([@seanspeaks](https://github.com/seanspeaks))
29
+
30
+ #### Authors: 1
31
+
32
+ - Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
33
+
34
+ ---
35
+
36
+ # v1.1.4 (Mon Sep 19 2022)
37
+
38
+ #### 🐛 Bug Fix
39
+
40
+ - Test environment setup for all modules [#49](https://github.com/friggframework/frigg/pull/49) ([@seanspeaks](https://github.com/seanspeaks))
41
+ - Test environment setup for all modules ([@seanspeaks](https://github.com/seanspeaks))
42
+ - Merge remote-tracking branch 'origin/main' into gitbook-updates [#48](https://github.com/friggframework/frigg/pull/48) ([@seanspeaks](https://github.com/seanspeaks))
43
+
44
+ #### Authors: 1
45
+
46
+ - Sean Matthews ([@seanspeaks](https://github.com/seanspeaks))
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Left Hook Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # test-environment
2
+
3
+ This package exports the `test-environment` defaults used in [Frigg](https://friggframework.org). You can find its documentation [on Frigg's website](https://docs.friggframework.org/packages/test-environment).
@@ -0,0 +1,45 @@
1
+ const {flushDebugLog} = require('../../core/logs');
2
+
3
+ async function testDefinitionRequiredAuthMethods(api, definition, authCallbackParams, tokenResponse, userId) {
4
+
5
+ // const response = await definition.getToken(api, authCallbackParams);
6
+ // expect(api.setTokens).toHaveBeenCalled();
7
+ // if (tokenResponse) {
8
+ // expect(response).toMatchObject(tokenResponse);
9
+ // }
10
+
11
+ const entityDetails = await definition.requiredAuthMethods.getEntityDetails(api, authCallbackParams, tokenResponse, userId);
12
+ expect(entityDetails).toHaveProperty('identifiers');
13
+ expect(Object.values(entityDetails.identifiers).length).toBeGreaterThan(0);
14
+ for (const key of Object.keys(entityDetails.identifiers)){
15
+ expect(key).toBeDefined();
16
+ expect(entityDetails.identifiers[key]).toBeDefined();
17
+ }
18
+
19
+
20
+ const credentialDetails = await definition.requiredAuthMethods.getCredentialDetails(api);
21
+ expect(credentialDetails).toHaveProperty('identifiers');
22
+ expect(Object.values(entityDetails.identifiers).length).toBeGreaterThan(0);
23
+ for (const key of Object.keys(entityDetails.identifiers)){
24
+ expect(key).toBeDefined();
25
+ expect(entityDetails.identifiers[key]).toBeDefined();
26
+ }
27
+
28
+ const successResponse = await definition.requiredAuthMethods.testAuthRequest(api);
29
+ expect(successResponse).toBeTruthy();
30
+ const savedKeys = {};
31
+ for (const key of definition.requiredAuthMethods.apiPropertiesToPersist.credential){
32
+ savedKeys[key] = api[key];
33
+ delete api[key];
34
+ }
35
+ let validAuth = false;
36
+ try {
37
+ if (await definition.requiredAuthMethods.testAuthRequest(api)) validAuth = true;
38
+ } catch (e) {
39
+ flushDebugLog(e);
40
+ }
41
+ expect(validAuth).not.toBeTruthy();
42
+ Object.assign(api, savedKeys);
43
+ }
44
+
45
+ module.exports = { testDefinitionRequiredAuthMethods }