@friggframework/core 2.0.0--canary.396.9db9bf9.0 → 2.0.0--canary.396.6afd30a.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.
@@ -1,3 +1,5 @@
1
+ const { Options } = require('./options');
2
+
1
3
  /**
2
4
  * Integration Domain Entity
3
5
  * Represents a configured integration with its data and behavior
@@ -152,9 +154,13 @@ class Integration {
152
154
  return methodName in this || (this.behavior && methodName in this.behavior);
153
155
  }
154
156
 
155
- // getOptions() {
156
- // return this.getOptionDetails();
157
- // }
157
+ getOptionDetails() {
158
+ const options = new Options({
159
+ module: Object.values(this.integrationClass.Definition.modules)[0], // This is a placeholder until we revamp the frontend
160
+ ...this.integrationClass.Definition,
161
+ });
162
+ return options.get();
163
+ }
158
164
 
159
165
  /**
160
166
  * Custom JSON serializer to prevent circular references (e.g. Module → Api → delegate)
@@ -27,7 +27,7 @@ class CreateIntegration {
27
27
  }
28
28
 
29
29
  const integrationInstance = new Integration({
30
- id: integrationRecord.id,
30
+ id: integrationRecord._id.toString(),
31
31
  userId: integrationRecord.user,
32
32
  entities: integrationRecord.entities,
33
33
  config: integrationRecord.config,
@@ -42,9 +42,9 @@ class GetIntegrationForUser {
42
42
  }
43
43
 
44
44
  const integrationInstance = new Integration({
45
- id: integrationRecord.id,
45
+ id: integrationRecord._id.toString(),
46
46
  userId: integrationRecord.user,
47
- entities: integrationRecord.entities,
47
+ entities: integrationRecord.entities.map(e => ({ ...e, id: e._id.toString() })),
48
48
  config: integrationRecord.config,
49
49
  status: integrationRecord.status,
50
50
  version: integrationRecord.version,
@@ -50,7 +50,7 @@ class GetIntegration {
50
50
 
51
51
  // 4. Create the Integration domain entity with modules
52
52
  const integrationInstance = new Integration({
53
- id: integrationRecord.id,
53
+ id: integrationRecord._id.toString(),
54
54
  userId: integrationRecord.user,
55
55
  entities: integrationRecord.entities,
56
56
  config: integrationRecord.config,
@@ -37,7 +37,7 @@ class GetIntegrationsForUser {
37
37
  }
38
38
 
39
39
  const integrationInstance = new Integration({
40
- id: integrationRecord.id,
40
+ id: integrationRecord._id.toString(),
41
41
  userId: integrationRecord.user,
42
42
  entities: integrationRecord.entities,
43
43
  config: integrationRecord.config,
@@ -2,7 +2,7 @@ const { Entity } = require('./entity');
2
2
 
3
3
  class ModuleRepository {
4
4
  async findEntityById(entityId) {
5
- const entity = await Entity.findById(entityId).populate('credential');
5
+ const entity = await Entity.findById(entityId, undefined, { lean: true }).populate('credential');
6
6
  if (!entity) {
7
7
  throw new Error(`Entity ${entityId} not found`);
8
8
  }
@@ -27,7 +27,7 @@ class ModuleService {
27
27
  );
28
28
  }
29
29
 
30
- const entityType = entity.toJSON().__t;
30
+ const entityType = entity.__t;
31
31
  const moduleDefinition = this.moduleDefinitions.find((def) => {
32
32
  const modelName = Module.getEntityModelFromDefinition(def).modelName;
33
33
  return entityType === modelName;
@@ -324,23 +324,6 @@ class Module extends Delegate {
324
324
  }
325
325
  }
326
326
  }
327
-
328
- /**
329
- * Custom JSON serializer for Module instances.
330
- * Omits heavy or circular properties such as `api`, `delegate`, `CredentialModel`, etc.
331
- * Returns only lightweight, non-sensitive data that might be useful in API responses.
332
- */
333
- toJSON() {
334
- return {
335
- name: this.name,
336
- userId: this.userId,
337
- entity: this.entity && typeof this.entity.toJSON === 'function'
338
- ? this.entity.toJSON()
339
- : this.entity,
340
- // Expose credential ID only (not full encrypted values)
341
- credentialId: this.credential?._id?.toString(),
342
- };
343
- }
344
327
  }
345
328
 
346
329
  module.exports = { Module };
@@ -6,10 +6,12 @@ function mapModuleClassToModuleDTO(moduleInstance) {
6
6
  if (!moduleInstance) return null;
7
7
 
8
8
  return {
9
+ id: moduleInstance.entity._id.toString(),
9
10
  name: moduleInstance.name,
10
11
  userId: moduleInstance.userId,
11
12
  entity: moduleInstance.entity,
12
13
  credentialId: moduleInstance.credential?._id?.toString(),
14
+ type: moduleInstance.getName()
13
15
  };
14
16
  }
15
17
 
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.396.9db9bf9.0",
4
+ "version": "2.0.0--canary.396.6afd30a.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.396.9db9bf9.0",
26
- "@friggframework/prettier-config": "2.0.0--canary.396.9db9bf9.0",
27
- "@friggframework/test": "2.0.0--canary.396.9db9bf9.0",
25
+ "@friggframework/eslint-config": "2.0.0--canary.396.6afd30a.0",
26
+ "@friggframework/prettier-config": "2.0.0--canary.396.6afd30a.0",
27
+ "@friggframework/test": "2.0.0--canary.396.6afd30a.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": "9db9bf93c54d3a842b2bba1eac2516ec1a0c8c43"
56
+ "gitHead": "6afd30ab7178ec917c10c2539da48b005cbecb37"
57
57
  }