@friggframework/core 2.0.0--canary.397.1b51778.0 → 2.0.0--canary.397.155fecd.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 (29) hide show
  1. package/README.md +933 -50
  2. package/core/create-handler.js +1 -0
  3. package/handlers/routers/auth.js +1 -15
  4. package/integrations/integration-router.js +11 -11
  5. package/integrations/tests/doubles/dummy-integration-class.js +90 -0
  6. package/integrations/tests/doubles/test-integration-repository.js +89 -0
  7. package/integrations/tests/use-cases/create-integration.test.js +124 -0
  8. package/integrations/tests/use-cases/delete-integration-for-user.test.js +143 -0
  9. package/integrations/tests/use-cases/get-integration-for-user.test.js +143 -0
  10. package/integrations/tests/use-cases/get-integration-instance.test.js +169 -0
  11. package/integrations/tests/use-cases/get-integrations-for-user.test.js +169 -0
  12. package/integrations/tests/use-cases/get-possible-integrations.test.js +188 -0
  13. package/integrations/tests/use-cases/update-integration-messages.test.js +142 -0
  14. package/integrations/tests/use-cases/update-integration-status.test.js +103 -0
  15. package/integrations/tests/use-cases/update-integration.test.js +134 -0
  16. package/integrations/use-cases/create-integration.js +19 -4
  17. package/integrations/use-cases/delete-integration-for-user.js +19 -0
  18. package/integrations/use-cases/get-integration-for-user.js +22 -6
  19. package/integrations/use-cases/get-integration-instance.js +14 -3
  20. package/integrations/use-cases/get-integrations-for-user.js +17 -3
  21. package/integrations/use-cases/get-possible-integrations.js +14 -0
  22. package/integrations/use-cases/update-integration-messages.js +17 -6
  23. package/integrations/use-cases/update-integration-status.js +16 -0
  24. package/integrations/use-cases/update-integration.js +17 -6
  25. package/modules/module-repository.js +2 -21
  26. package/modules/tests/doubles/test-module-factory.js +16 -0
  27. package/modules/tests/doubles/test-module-repository.js +19 -0
  28. package/package.json +5 -5
  29. package/integrations/test/integration-base.test.js +0 -144
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.397.1b51778.0",
4
+ "version": "2.0.0--canary.397.155fecd.0",
5
5
  "dependencies": {
6
6
  "@hapi/boom": "^10.0.1",
7
7
  "aws-sdk": "^2.1200.0",
@@ -22,9 +22,9 @@
22
22
  "uuid": "^9.0.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@friggframework/eslint-config": "2.0.0--canary.397.1b51778.0",
26
- "@friggframework/prettier-config": "2.0.0--canary.397.1b51778.0",
27
- "@friggframework/test": "2.0.0--canary.397.1b51778.0",
25
+ "@friggframework/eslint-config": "2.0.0--canary.397.155fecd.0",
26
+ "@friggframework/prettier-config": "2.0.0--canary.397.155fecd.0",
27
+ "@friggframework/test": "2.0.0--canary.397.155fecd.0",
28
28
  "@types/lodash": "4.17.15",
29
29
  "@typescript-eslint/eslint-plugin": "^8.0.0",
30
30
  "chai": "^4.3.6",
@@ -53,5 +53,5 @@
53
53
  },
54
54
  "homepage": "https://github.com/friggframework/frigg#readme",
55
55
  "description": "",
56
- "gitHead": "1b51778697149cbb26c6ba4de50e507461663f48"
56
+ "gitHead": "155fecdabd27d01d1c1001261e9ec4b824826411"
57
57
  }
@@ -1,144 +0,0 @@
1
- const _ = require('lodash');
2
- const { mongoose } = require('../../database/mongoose');
3
- const { expect } = require('chai');
4
- const { IntegrationBase } = require("../integration-base");
5
- const {Credential} = require('../../module-plugin/credential');
6
- const {Entity} = require('../../module-plugin/entity');
7
- const { IntegrationMapping } = require('../integration-mapping')
8
- const {IntegrationModel} = require("../integration-model");
9
-
10
- describe(`Should fully test the IntegrationBase Class`, () => {
11
- let integrationRecord;
12
- let userId;
13
- const integration = new IntegrationBase;
14
-
15
- beforeAll(async () => {
16
- await mongoose.connect(process.env.MONGO_URI);
17
- userId = new mongoose.Types.ObjectId();
18
- const credential = await Credential.findOneAndUpdate(
19
- {
20
- user: this.userId,
21
- },
22
- { $set: { user: this.userId } },
23
- {
24
- new: true,
25
- upsert: true,
26
- setDefaultsOnInsert: true,
27
- }
28
- );
29
- const entity1 = await Entity.findOneAndUpdate(
30
- {
31
- user: this.userId,
32
- },
33
- {
34
- $set: {
35
- credential: credential.id,
36
- user: userId,
37
- },
38
- },
39
- {
40
- new: true,
41
- upsert: true,
42
- setDefaultsOnInsert: true,
43
- }
44
- );
45
- const entity2 = await Entity.findOneAndUpdate(
46
- {
47
- user: userId,
48
- },
49
- {
50
- $set: {
51
- credential: credential.id,
52
- user: userId,
53
- },
54
- },
55
- {
56
- new: true,
57
- upsert: true,
58
- setDefaultsOnInsert: true,
59
- }
60
- );
61
- integrationRecord = await IntegrationModel.create({
62
- entities: [entity1, entity2],
63
- user: userId
64
- });
65
- integration.record = integrationRecord;
66
- });
67
-
68
- afterAll(async () => {
69
- await Entity.deleteMany();
70
- await Credential.deleteMany();
71
- await IntegrationMapping.deleteMany();
72
- await IntegrationModel.deleteMany();
73
- await mongoose.disconnect();
74
- });
75
-
76
- beforeEach(() => {
77
- integration.record = integrationRecord;
78
- })
79
-
80
- describe('getIntegrationMapping()', () => {
81
- it('should return null if not found', async () => {
82
- const mappings = await integration.getMapping('badId');
83
- expect(mappings).to.be.null;
84
- });
85
-
86
- it('should return if valid ids', async () => {
87
- await integration.upsertMapping('validId', {});
88
- const mapping = await integration.getMapping('validId');
89
- expect(mapping).to.eql({})
90
- });
91
- })
92
-
93
- describe('upsertIntegrationMapping()', () => {
94
- it('should throw error if sourceId is null', async () => {
95
- try {
96
- await integration.upsertMapping( null, {});
97
- fail('should have thrown error')
98
- } catch(err) {
99
- expect(err.message).to.contain('sourceId must be set');
100
- }
101
- });
102
-
103
- it('should return for empty mapping', async () => {
104
- const mapping = await integration.upsertMapping( 'validId2', {});
105
- expect(_.pick(mapping, ['integration', 'sourceId', 'mapping'])).to.eql({
106
- integration: integrationRecord._id,
107
- sourceId: 'validId2',
108
- mapping: {}
109
- })
110
- });
111
-
112
- it('should return for filled mapping', async () => {
113
- const mapping = await integration.upsertMapping('validId3', {
114
- name: 'someName',
115
- value: 5
116
- });
117
- expect(_.pick(mapping, ['integration', 'sourceId', 'mapping'])).to.eql({
118
- integration: integrationRecord._id,
119
- sourceId: 'validId3',
120
- mapping: {
121
- name: 'someName',
122
- value: 5
123
- }
124
- })
125
- });
126
-
127
- it('should allow upserting to same id', async () => {
128
- await integration.upsertMapping('validId4', {});
129
- const mapping = await integration.upsertMapping('validId4', {
130
- name: 'trustMe',
131
- thisWorks: true,
132
- });
133
- expect(_.pick(mapping, ['integration', 'sourceId', 'mapping'])).to.eql({
134
- integration: integrationRecord._id,
135
- sourceId: 'validId4',
136
- mapping: {
137
- name: 'trustMe',
138
- thisWorks: true,
139
- }
140
- })
141
- });
142
- })
143
-
144
- });