@friggframework/core 1.0.1-v1-alpha-package-update.1 → 1.0.1-v1-alpha.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 (49) hide show
  1. package/bump0.txt +1 -0
  2. package/encrypt/encrypt.test.js +1 -1
  3. package/errors/fetch-error.js +5 -1
  4. package/index.js +1 -7
  5. package/integrations/jest-setup.js +1 -1
  6. package/integrations/jest-teardown.js +1 -1
  7. package/logs/logger.test.js +1 -1
  8. package/module-plugin/jest-setup.js +1 -1
  9. package/module-plugin/jest-teardown.js +1 -1
  10. package/module-plugin/requester/requester.js +2 -1
  11. package/package.json +5 -14
  12. package/bump.txt +0 -1
  13. package/eslint-config/.eslintrc.json +0 -3
  14. package/eslint-config/CHANGELOG.md +0 -17
  15. package/eslint-config/LICENSE.md +0 -9
  16. package/eslint-config/README.md +0 -3
  17. package/eslint-config/bump3.txt +0 -0
  18. package/eslint-config/index.js +0 -38
  19. package/migrations/README.md +0 -3
  20. package/migrations/bump3.txt +0 -0
  21. package/migrations/index.js +0 -9
  22. package/migrations/jest.config.js +0 -3
  23. package/migrations/manager.js +0 -33
  24. package/migrations/migrator.js +0 -170
  25. package/migrations/options.js +0 -28
  26. package/prettier-config/.eslintrc.json +0 -3
  27. package/prettier-config/CHANGELOG.md +0 -17
  28. package/prettier-config/LICENSE.md +0 -9
  29. package/prettier-config/README.md +0 -3
  30. package/prettier-config/bump3.txt +0 -0
  31. package/prettier-config/index.js +0 -6
  32. package/test-environment/.eslintrc.json +0 -3
  33. package/test-environment/Authenticator.js +0 -73
  34. package/test-environment/CHANGELOG.md +0 -46
  35. package/test-environment/LICENSE.md +0 -9
  36. package/test-environment/README.md +0 -3
  37. package/test-environment/auther-definition-method-tester.js +0 -45
  38. package/test-environment/auther-definition-tester.js +0 -104
  39. package/test-environment/bump3.txt +0 -0
  40. package/test-environment/index.js +0 -24
  41. package/test-environment/integration-validator.js +0 -2
  42. package/test-environment/jest-global-setup.js +0 -6
  43. package/test-environment/jest-global-teardown.js +0 -3
  44. package/test-environment/jest-preset.js +0 -14
  45. package/test-environment/mock-api-readme.md +0 -102
  46. package/test-environment/mock-api.js +0 -284
  47. package/test-environment/mock-integration.js +0 -82
  48. package/test-environment/mongodb.js +0 -22
  49. package/test-environment/override-environment.js +0 -11
@@ -1,82 +0,0 @@
1
- const { Auther, Credential, Entity } = require('../module-plugin');
2
- const { IntegrationModel } = require('../integrations');
3
- const { mongoose } = require('../database/mongoose');
4
-
5
- async function createMockIntegration(IntegrationClassDef, userId = null, config = {},) {
6
- const integration = new IntegrationClassDef();
7
- userId = userId || new mongoose.Types.ObjectId();
8
- integration.delegateTypes.push(...IntegrationClassDef.Config.events)
9
-
10
- const insertOptions = {
11
- new: true,
12
- upsert: true,
13
- setDefaultsOnInsert: true,
14
- }
15
- const user = {user: userId}
16
-
17
- const credential = await Credential.findOneAndUpdate(
18
- user,
19
- { $set: user },
20
- insertOptions
21
- );
22
- const entity1 = await Entity.findOneAndUpdate(
23
- user,
24
- {
25
- $set: {
26
- credential: credential.id,
27
- user: userId,
28
- name: 'Test user',
29
- externalId: '1234567890123456',
30
- },
31
- },
32
- insertOptions
33
- );
34
- const entity2 = await Entity.findOneAndUpdate(
35
- user,
36
- {
37
- $set: {
38
- credential: credential.id,
39
- user: userId,
40
- },
41
- },
42
- insertOptions
43
- );
44
-
45
- const entities = [entity1, entity2]
46
- integration.record = await IntegrationModel.create({
47
- entities,
48
- user: userId,
49
- config: {type: IntegrationClassDef.Config.name, ...config}
50
- })
51
-
52
- integration.id = integration.record._id
53
-
54
- for (const i in entities){
55
- const [moduleName, ModuleDef] = Object.entries(IntegrationClassDef.modules)[i];
56
- const module = Auther.getInstance({definition: ModuleDef, userId: userId})
57
- module.entity = entities[i];
58
- integration[moduleName] = module;
59
- }
60
-
61
- return integration
62
- }
63
-
64
- function createMockApiObject(jest, api = {}, mockMethodMap) {
65
- // take in an api class and object with keys that are method names
66
- // and values which are the mock response (or implementation)
67
- const clone = (data) => JSON.parse(JSON.stringify(data));
68
-
69
- for (const [methodName, mockDataOrImplementation] of Object.entries(mockMethodMap)) {
70
- if (mockDataOrImplementation instanceof Function) {
71
- api[methodName] = jest.fn(mockDataOrImplementation);
72
- }
73
- else if (api[methodName]?.constructor?.name === "AsyncFunction") {
74
- api[methodName] = jest.fn().mockResolvedValue(clone(mockDataOrImplementation));
75
- } else {
76
- api[methodName] = jest.fn().mockReturnValue(clone(mockDataOrImplementation));
77
- }
78
- }
79
- return api;
80
- }
81
-
82
- module.exports = {createMockIntegration, createMockApiObject};
@@ -1,22 +0,0 @@
1
- const { MongoMemoryServer } = require('mongodb-memory-server');
2
-
3
- class TestMongo {
4
- #mongoServer;
5
-
6
- // Start the in-memory mongo instance and set env variable for the app to use in its connection.
7
- async start() {
8
- this.#mongoServer = await MongoMemoryServer.create();
9
- process.env.MONGO_URI = this.#mongoServer.getUri();
10
- console.log('Started in memory mongo server', process.env.MONGO_URI);
11
- }
12
-
13
- async stop() {
14
- await this.#mongoServer.stop();
15
- process.env.MONGO_URI = undefined;
16
- this.#mongoServer = undefined;
17
- }
18
- }
19
-
20
- module.exports = {
21
- TestMongo,
22
- };
@@ -1,11 +0,0 @@
1
- const originalEnv = process.env;
2
-
3
- function overrideEnvironment(overrideByKey) {
4
- process.env = { ...process.env, ...overrideByKey };
5
- }
6
-
7
- function restoreEnvironment() {
8
- process.env = originalEnv;
9
- }
10
-
11
- module.exports = { overrideEnvironment, restoreEnvironment };