@friggframework/devtools 2.0.0--canary.428.380d241.0 → 2.0.0--canary.395.eb0264e.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,7 +1,6 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs-extra');
3
3
  const { composeServerlessDefinition } = require('./serverless-template');
4
-
5
4
  const { findNearestBackendPackageJson } = require('@friggframework/core');
6
5
 
7
6
  async function createFriggInfrastructure() {
@@ -25,7 +24,6 @@ async function createFriggInfrastructure() {
25
24
  // ));
26
25
  const definition = await composeServerlessDefinition(
27
26
  appDefinition,
28
- backend.IntegrationFactory
29
27
  );
30
28
 
31
29
  return {
@@ -2,10 +2,19 @@ const path = require('path');
2
2
  const fs = require('fs');
3
3
  const { AWSDiscovery } = require('./aws-discovery');
4
4
 
5
- const shouldRunDiscovery = (AppDefinition) =>
6
- AppDefinition.vpc?.enable === true ||
7
- AppDefinition.encryption?.fieldLevelEncryptionMethod === 'kms' ||
8
- AppDefinition.ssm?.enable === true;
5
+ const shouldRunDiscovery = (AppDefinition) => {
6
+ // Check if we're running in offline mode (local development)
7
+ // Set IS_OFFLINE=true in your .env file for local development
8
+ if (process.env.IS_OFFLINE === 'true') {
9
+ console.log('⏭️ Skipping AWS discovery for local development (IS_OFFLINE=true)');
10
+ return false;
11
+ }
12
+
13
+ // Only run discovery if VPC, KMS encryption, or SSM is enabled
14
+ return AppDefinition.vpc?.enable === true ||
15
+ AppDefinition.encryption?.fieldLevelEncryptionMethod === 'kms' ||
16
+ AppDefinition.ssm?.enable === true;
17
+ };
9
18
 
10
19
  const getAppEnvironmentVars = (AppDefinition) => {
11
20
  const envVars = {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/devtools",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.428.380d241.0",
4
+ "version": "2.0.0--canary.395.eb0264e.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-ec2": "^3.835.0",
7
7
  "@aws-sdk/client-kms": "^3.835.0",
@@ -9,8 +9,8 @@
9
9
  "@babel/eslint-parser": "^7.18.9",
10
10
  "@babel/parser": "^7.25.3",
11
11
  "@babel/traverse": "^7.25.3",
12
- "@friggframework/schemas": "2.0.0--canary.428.380d241.0",
13
- "@friggframework/test": "2.0.0--canary.428.380d241.0",
12
+ "@friggframework/schemas": "2.0.0--canary.395.eb0264e.0",
13
+ "@friggframework/test": "2.0.0--canary.395.eb0264e.0",
14
14
  "@hapi/boom": "^10.0.1",
15
15
  "@inquirer/prompts": "^5.3.8",
16
16
  "axios": "^1.7.2",
@@ -32,8 +32,8 @@
32
32
  "serverless-http": "^2.7.0"
33
33
  },
34
34
  "devDependencies": {
35
- "@friggframework/eslint-config": "2.0.0--canary.428.380d241.0",
36
- "@friggframework/prettier-config": "2.0.0--canary.428.380d241.0",
35
+ "@friggframework/eslint-config": "2.0.0--canary.395.eb0264e.0",
36
+ "@friggframework/prettier-config": "2.0.0--canary.395.eb0264e.0",
37
37
  "aws-sdk-client-mock": "^4.1.0",
38
38
  "aws-sdk-client-mock-jest": "^4.1.0",
39
39
  "jest": "^30.1.3",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "380d2410148793513d51665dcc3b1ec7093dc784"
71
+ "gitHead": "eb0264e7fb4d26ee5fa81fb693905775609e5671"
72
72
  }
package/test/index.js CHANGED
@@ -1,11 +1,9 @@
1
- const {testDefinitionRequiredAuthMethods} = require('./auther-definition-method-tester');
2
- const {createMockIntegration, createMockApiObject} = require('./mock-integration');
3
- const { testAutherDefinition } = require('./auther-definition-tester');
1
+ const { testDefinitionRequiredAuthMethods } = require('./auther-definition-method-tester');
2
+ const { createMockIntegration, createMockApiObject } = require('./mock-integration');
4
3
 
5
4
 
6
5
  module.exports = {
7
6
  createMockIntegration,
8
7
  createMockApiObject,
9
8
  testDefinitionRequiredAuthMethods,
10
- testAutherDefinition,
11
9
  };
@@ -1,8 +1,4 @@
1
1
  const {
2
- Auther,
3
- Credential,
4
- Entity,
5
- IntegrationFactory,
6
2
  createObjectId,
7
3
  } = require('@friggframework/core');
8
4
 
@@ -11,7 +7,6 @@ async function createMockIntegration(
11
7
  userId = null,
12
8
  config = { type: IntegrationClass.Definition.name }
13
9
  ) {
14
- const integrationFactory = new IntegrationFactory([IntegrationClass]);
15
10
  userId = userId || createObjectId();
16
11
 
17
12
  const insertOptions = {
@@ -24,10 +19,8 @@ async function createMockIntegration(
24
19
  const entities = [];
25
20
  for (const moduleName in IntegrationClass.modules) {
26
21
  const ModuleDef = IntegrationClass.Definition.modules[moduleName];
27
- const module = await Auther.getInstance({
28
- definition: ModuleDef,
29
- userId: userId,
30
- });
22
+ // todo: create module using the new architecture
23
+ const module = {}
31
24
  const credential = await module.CredentialModel.findOneAndUpdate(
32
25
  user,
33
26
  { $set: user },
@@ -51,11 +44,8 @@ async function createMockIntegration(
51
44
  );
52
45
  }
53
46
 
54
- const integration = await integrationFactory.createIntegration(
55
- entities,
56
- userId,
57
- config
58
- );
47
+ // todo: create integration using the new architecture
48
+ const integration = {}
59
49
 
60
50
  integration.id = integration.record._id;
61
51
 
@@ -1,125 +0,0 @@
1
- const {
2
- Auther,
3
- ModuleConstants,
4
- createObjectId,
5
- connectToDatabase,
6
- disconnectFromDatabase,
7
- } = require('@friggframework/core');
8
- const { createMockApiObject } = require("./mock-integration");
9
-
10
-
11
- function testAutherDefinition(definition, mocks) {
12
- const getModule = async (params) => {
13
- const module = await Auther.getInstance({
14
- definition,
15
- userId: createObjectId(),
16
- ...params,
17
- });
18
- if (mocks.tokenResponse) {
19
- mocks.getTokenFrom = async function(code) {
20
- await this.setTokens(mocks.tokenResponse);
21
- return mocks.tokenResponse
22
- }
23
- mocks.getTokenFromCode = mocks.getTokenFromCode || mocks.getTokenFrom
24
- mocks.getTokenFromCodeBasicAuthHeader = mocks.getTokenFromCodeBasicAuthHeader || mocks.getTokenFrom
25
- mocks.getTokenFromClientCredentials = mocks.getTokenFromClientCredentials || mocks.getTokenFrom
26
- mocks.getTokenFromUsernamePassword = mocks.getTokenFromUsernamePassword || mocks.getTokenFrom
27
- }
28
- if (mocks.refreshResponse) {
29
- mocks.refreshAccessToken = async function(code) {
30
- await this.setTokens(mocks.refreshResponse);
31
- return mocks.refreshResponse
32
- }
33
- }
34
- module.api = createMockApiObject(jest, module.api, mocks);
35
- return module
36
- }
37
-
38
-
39
- describe(`${definition.moduleName} Module Tests`, () => {
40
- let module, authUrl;
41
- beforeAll(async () => {
42
- await connectToDatabase();
43
- module = await getModule();
44
- });
45
-
46
- afterAll(async () => {
47
- await disconnectFromDatabase();
48
- });
49
-
50
- let requirements, authCallbackParams;
51
- if (definition.API.requesterType === ModuleConstants.authType.oauth2) {
52
- authCallbackParams = mocks.authorizeResponse || mocks.authorizeParams;
53
- describe('getAuthorizationRequirements() test', () => {
54
- it('should return auth requirements', async () => {
55
- requirements = await module.getAuthorizationRequirements();
56
- expect(requirements).toBeDefined();
57
- expect(requirements.type).toEqual(ModuleConstants.authType.oauth2);
58
- expect(requirements.url).toBeDefined();
59
- authUrl = requirements.url;
60
- });
61
- });
62
- } else if (definition.API.requesterType === ModuleConstants.authType.basic) {
63
- // could also confirm authCallbackParams against the auth requirements
64
- authCallbackParams = mocks.authorizeParams
65
- describe('getAuthorizationRequirements() test', () => {
66
- it('should return auth requirements', async () => {
67
- requirements = module.getAuthorizationRequirements();
68
- expect(requirements).toBeDefined();
69
- expect(requirements.type).toEqual(ModuleConstants.authType.basic);
70
- });
71
- });
72
- } else if (definition.API.requesterType === ModuleConstants.authType.apiKey) {
73
- // could also confirm authCallbackParams against the auth requirements
74
- authCallbackParams = mocks.authorizeParams
75
- describe('getAuthorizationRequirements() test', () => {
76
- it('should return auth requirements', async () => {
77
- requirements = module.getAuthorizationRequirements();
78
- expect(requirements).toBeDefined();
79
- expect(requirements.type).toEqual(ModuleConstants.authType.apiKey);
80
- });
81
- });
82
- }
83
-
84
- describe('Authorization requests', () => {
85
- let firstRes;
86
- it('processAuthorizationCallback()', async () => {
87
- firstRes = await module.processAuthorizationCallback(authCallbackParams);
88
- expect(firstRes).toBeDefined();
89
- expect(firstRes.entity_id).toBeDefined();
90
- expect(firstRes.credential_id).toBeDefined();
91
- });
92
- it('retrieves existing entity on subsequent calls', async () => {
93
- const res = await module.processAuthorizationCallback(authCallbackParams);
94
- expect(res).toEqual(firstRes);
95
- });
96
- });
97
-
98
- describe('Test credential retrieval and module instantiation', () => {
99
- it('retrieve by entity id', async () => {
100
- const newModule = await getModule({
101
- userId: module.userId,
102
- entityId: module.entity.id
103
- });
104
- expect(newModule).toBeDefined();
105
- expect(newModule.entity).toBeDefined();
106
- expect(newModule.credential).toBeDefined();
107
- expect(await newModule.testAuth()).toBeTruthy();
108
-
109
- });
110
-
111
- it('retrieve by credential id', async () => {
112
- const newModule = await getModule({
113
- userId: module.userId,
114
- credentialId: module.credential.id
115
- });
116
- expect(newModule).toBeDefined();
117
- expect(newModule.credential).toBeDefined();
118
- expect(await newModule.testAuth()).toBeTruthy();
119
- });
120
- });
121
- });
122
- }
123
-
124
- module.exports = { testAutherDefinition }
125
-