@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.
- package/bump0.txt +1 -0
- package/encrypt/encrypt.test.js +1 -1
- package/errors/fetch-error.js +5 -1
- package/index.js +1 -7
- package/integrations/jest-setup.js +1 -1
- package/integrations/jest-teardown.js +1 -1
- package/logs/logger.test.js +1 -1
- package/module-plugin/jest-setup.js +1 -1
- package/module-plugin/jest-teardown.js +1 -1
- package/module-plugin/requester/requester.js +2 -1
- package/package.json +5 -14
- package/bump.txt +0 -1
- package/eslint-config/.eslintrc.json +0 -3
- package/eslint-config/CHANGELOG.md +0 -17
- package/eslint-config/LICENSE.md +0 -9
- package/eslint-config/README.md +0 -3
- package/eslint-config/bump3.txt +0 -0
- package/eslint-config/index.js +0 -38
- package/migrations/README.md +0 -3
- package/migrations/bump3.txt +0 -0
- package/migrations/index.js +0 -9
- package/migrations/jest.config.js +0 -3
- package/migrations/manager.js +0 -33
- package/migrations/migrator.js +0 -170
- package/migrations/options.js +0 -28
- package/prettier-config/.eslintrc.json +0 -3
- package/prettier-config/CHANGELOG.md +0 -17
- package/prettier-config/LICENSE.md +0 -9
- package/prettier-config/README.md +0 -3
- package/prettier-config/bump3.txt +0 -0
- package/prettier-config/index.js +0 -6
- package/test-environment/.eslintrc.json +0 -3
- package/test-environment/Authenticator.js +0 -73
- package/test-environment/CHANGELOG.md +0 -46
- package/test-environment/LICENSE.md +0 -9
- package/test-environment/README.md +0 -3
- package/test-environment/auther-definition-method-tester.js +0 -45
- package/test-environment/auther-definition-tester.js +0 -104
- package/test-environment/bump3.txt +0 -0
- package/test-environment/index.js +0 -24
- package/test-environment/integration-validator.js +0 -2
- package/test-environment/jest-global-setup.js +0 -6
- package/test-environment/jest-global-teardown.js +0 -3
- package/test-environment/jest-preset.js +0 -14
- package/test-environment/mock-api-readme.md +0 -102
- package/test-environment/mock-api.js +0 -284
- package/test-environment/mock-integration.js +0 -82
- package/test-environment/mongodb.js +0 -22
- 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 };
|