@friggframework/core 2.0.0-next.60 → 2.0.0-next.61

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.
@@ -0,0 +1,81 @@
1
+ const { IntegrationBase } = require('../../integration-base');
2
+
3
+ class ConfigCapturingModule {
4
+ static definition = {
5
+ getName: () => 'config-capturing-module'
6
+ };
7
+ }
8
+
9
+ class ConfigCapturingIntegration extends IntegrationBase {
10
+ static Definition = {
11
+ name: 'config-capturing',
12
+ version: '1.0.0',
13
+ modules: {
14
+ primary: ConfigCapturingModule
15
+ },
16
+ display: {
17
+ label: 'Config Capturing Integration',
18
+ description: 'Test double for capturing config state during updates',
19
+ detailsUrl: 'https://example.com',
20
+ icon: 'test-icon'
21
+ }
22
+ };
23
+
24
+ static _capturedOnUpdateState = null;
25
+
26
+ static resetCaptures() {
27
+ this._capturedOnUpdateState = null;
28
+ }
29
+
30
+ static getCapturedOnUpdateState() {
31
+ return this._capturedOnUpdateState;
32
+ }
33
+
34
+ constructor(params) {
35
+ super(params);
36
+ this.integrationRepository = {
37
+ updateIntegrationById: jest.fn().mockResolvedValue({}),
38
+ findIntegrationById: jest.fn().mockResolvedValue({}),
39
+ };
40
+ this.updateIntegrationStatus = {
41
+ execute: jest.fn().mockResolvedValue({})
42
+ };
43
+ this.updateIntegrationMessages = {
44
+ execute: jest.fn().mockResolvedValue({})
45
+ };
46
+ }
47
+
48
+ async initialize() {
49
+ this.registerEventHandlers();
50
+ }
51
+
52
+ async onUpdate(params) {
53
+ ConfigCapturingIntegration._capturedOnUpdateState = {
54
+ thisConfig: JSON.parse(JSON.stringify(this.config)),
55
+ paramsConfig: params.config
56
+ };
57
+
58
+ this.config = this._deepMerge(this.config, params.config);
59
+ }
60
+
61
+ _deepMerge(target, source) {
62
+ const result = { ...target };
63
+ for (const key of Object.keys(source)) {
64
+ if (
65
+ source[key] !== null &&
66
+ typeof source[key] === 'object' &&
67
+ !Array.isArray(source[key]) &&
68
+ target[key] !== null &&
69
+ typeof target[key] === 'object' &&
70
+ !Array.isArray(target[key])
71
+ ) {
72
+ result[key] = this._deepMerge(target[key], source[key]);
73
+ } else {
74
+ result[key] = source[key];
75
+ }
76
+ }
77
+ return result;
78
+ }
79
+ }
80
+
81
+ module.exports = { ConfigCapturingIntegration };
@@ -56,6 +56,9 @@ class DummyIntegration extends IntegrationBase {
56
56
  async send(event, data) {
57
57
  this.sendSpy(event, data);
58
58
  this.eventCallHistory.push({ event, data, timestamp: Date.now() });
59
+ if (event === 'ON_UPDATE') {
60
+ await this.onUpdate(data);
61
+ }
59
62
  return { event, data };
60
63
  }
61
64
 
@@ -68,7 +71,26 @@ class DummyIntegration extends IntegrationBase {
68
71
  }
69
72
 
70
73
  async onUpdate(params) {
71
- return;
74
+ this.config = this._deepMerge(this.config, params.config);
75
+ }
76
+
77
+ _deepMerge(target, source) {
78
+ const result = { ...target };
79
+ for (const key of Object.keys(source)) {
80
+ if (
81
+ source[key] !== null &&
82
+ typeof source[key] === 'object' &&
83
+ !Array.isArray(source[key]) &&
84
+ target[key] !== null &&
85
+ typeof target[key] === 'object' &&
86
+ !Array.isArray(target[key])
87
+ ) {
88
+ result[key] = this._deepMerge(target[key], source[key]);
89
+ } else {
90
+ result[key] = source[key];
91
+ }
92
+ }
93
+ return result;
72
94
  }
73
95
 
74
96
  async onDelete(params) {
@@ -1,4 +1,3 @@
1
- // Removed Integration wrapper - using IntegrationBase directly
2
1
  const {
3
2
  mapIntegrationClassToIntegrationDTO,
4
3
  } = require('../utils/map-integration-dto');
@@ -70,19 +69,19 @@ class UpdateIntegration {
70
69
  modules.push(moduleInstance);
71
70
  }
72
71
 
73
- // 4. Create the Integration domain entity with modules and updated config
72
+ // 4. Create the Integration domain entity with modules and existing config
74
73
  const integrationInstance = new integrationClass({
75
74
  id: integrationRecord.id,
76
75
  userId: integrationRecord.userId,
77
76
  entities: integrationRecord.entitiesIds,
78
- config: config,
77
+ config: integrationRecord.config,
79
78
  status: integrationRecord.status,
80
79
  version: integrationRecord.version,
81
80
  messages: integrationRecord.messages,
82
81
  modules,
83
82
  });
84
83
 
85
- // 6. Complete async initialization (load dynamic actions, register handlers)
84
+ // 5. Complete async initialization and trigger update event
86
85
  await integrationInstance.initialize();
87
86
  await integrationInstance.send('ON_UPDATE', { config });
88
87
 
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-next.60",
4
+ "version": "2.0.0-next.61",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "@friggframework/eslint-config": "2.0.0-next.60",
42
- "@friggframework/prettier-config": "2.0.0-next.60",
43
- "@friggframework/test": "2.0.0-next.60",
41
+ "@friggframework/eslint-config": "2.0.0-next.61",
42
+ "@friggframework/prettier-config": "2.0.0-next.61",
43
+ "@friggframework/test": "2.0.0-next.61",
44
44
  "@prisma/client": "^6.17.0",
45
45
  "@types/lodash": "4.17.15",
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "8fc85a629bedc7b17a9415ef8952dddb1daee1b5"
83
+ "gitHead": "41be237eff14a10a9379c687e5ce0a75cdf9b029"
84
84
  }