@friggframework/devtools 2.0.0--canary.461.ec909cf.0 → 2.0.0--canary.461.7b36f0f.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 (70) hide show
  1. package/frigg-cli/__tests__/unit/commands/build.test.js +6 -6
  2. package/frigg-cli/build-command/index.js +1 -1
  3. package/frigg-cli/deploy-command/index.js +6 -6
  4. package/frigg-cli/generate-command/index.js +2 -2
  5. package/frigg-cli/generate-iam-command.js +10 -10
  6. package/frigg-cli/start-command/index.js +1 -1
  7. package/frigg-cli/start-command/start-command.test.js +3 -3
  8. package/frigg-cli/utils/database-validator.js +14 -21
  9. package/infrastructure/REFACTOR.md +532 -0
  10. package/infrastructure/TRANSFORMATION-VISUAL.md +239 -0
  11. package/infrastructure/__tests__/postgres-config.test.js +1 -1
  12. package/infrastructure/create-frigg-infrastructure.js +1 -1
  13. package/infrastructure/{DEPLOYMENT-INSTRUCTIONS.md → docs/deployment-instructions.md} +3 -3
  14. package/infrastructure/{IAM-POLICY-TEMPLATES.md → docs/iam-policy-templates.md} +9 -10
  15. package/infrastructure/domains/database/aurora-discovery.js +81 -0
  16. package/infrastructure/domains/database/aurora-discovery.test.js +188 -0
  17. package/infrastructure/domains/integration/integration-builder.js +178 -0
  18. package/infrastructure/domains/integration/integration-builder.test.js +362 -0
  19. package/infrastructure/domains/integration/websocket-builder.js +69 -0
  20. package/infrastructure/domains/integration/websocket-builder.test.js +195 -0
  21. package/infrastructure/domains/networking/vpc-discovery.test.js +257 -0
  22. package/infrastructure/domains/parameters/ssm-builder.js +79 -0
  23. package/infrastructure/domains/parameters/ssm-builder.test.js +188 -0
  24. package/infrastructure/domains/parameters/ssm-discovery.js +84 -0
  25. package/infrastructure/domains/parameters/ssm-discovery.test.js +210 -0
  26. package/infrastructure/{iam-generator.js → domains/security/iam-generator.js} +2 -2
  27. package/infrastructure/domains/security/kms-builder.js +169 -0
  28. package/infrastructure/domains/security/kms-builder.test.js +354 -0
  29. package/infrastructure/domains/security/kms-discovery.js +80 -0
  30. package/infrastructure/domains/security/kms-discovery.test.js +176 -0
  31. package/infrastructure/domains/shared/base-builder.js +112 -0
  32. package/infrastructure/domains/shared/builder-orchestrator.js +212 -0
  33. package/infrastructure/domains/shared/builder-orchestrator.test.js +213 -0
  34. package/infrastructure/domains/shared/environment-builder.js +118 -0
  35. package/infrastructure/domains/shared/environment-builder.test.js +246 -0
  36. package/infrastructure/domains/shared/providers/aws-provider-adapter.test.js +366 -0
  37. package/infrastructure/domains/shared/providers/azure-provider-adapter.stub.js +93 -0
  38. package/infrastructure/domains/shared/providers/cloud-provider-adapter.js +136 -0
  39. package/infrastructure/domains/shared/providers/gcp-provider-adapter.stub.js +82 -0
  40. package/infrastructure/domains/shared/providers/provider-factory.js +108 -0
  41. package/infrastructure/domains/shared/providers/provider-factory.test.js +170 -0
  42. package/infrastructure/domains/shared/resource-discovery.js +132 -0
  43. package/infrastructure/domains/shared/resource-discovery.test.js +410 -0
  44. package/infrastructure/domains/shared/utilities/base-definition-factory.js.bak +338 -0
  45. package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +248 -0
  46. package/infrastructure/domains/shared/utilities/handler-path-resolver.test.js +259 -0
  47. package/infrastructure/domains/shared/utilities/prisma-layer-manager.js +55 -0
  48. package/infrastructure/domains/shared/utilities/prisma-layer-manager.test.js +134 -0
  49. package/infrastructure/domains/shared/validation/env-validator.test.js +173 -0
  50. package/infrastructure/esbuild.config.js +53 -0
  51. package/infrastructure/infrastructure-composer.js +85 -0
  52. package/infrastructure/scripts/build-prisma-layer.js +60 -47
  53. package/infrastructure/{build-time-discovery.test.js → scripts/build-time-discovery.test.js} +5 -4
  54. package/layers/prisma/nodejs/package.json +8 -0
  55. package/management-ui/server/utils/environment/awsParameterStore.js +29 -18
  56. package/package.json +8 -8
  57. package/infrastructure/aws-discovery.js +0 -1704
  58. package/infrastructure/aws-discovery.test.js +0 -1666
  59. package/infrastructure/serverless-template.js +0 -2804
  60. package/infrastructure/serverless-template.test.js +0 -1897
  61. /package/infrastructure/{POSTGRES-CONFIGURATION.md → docs/POSTGRES-CONFIGURATION.md} +0 -0
  62. /package/infrastructure/{WEBSOCKET-CONFIGURATION.md → docs/WEBSOCKET-CONFIGURATION.md} +0 -0
  63. /package/infrastructure/{GENERATE-IAM-DOCS.md → docs/generate-iam-command.md} +0 -0
  64. /package/infrastructure/{iam-generator.test.js → domains/security/iam-generator.test.js} +0 -0
  65. /package/infrastructure/{frigg-deployment-iam-stack.yaml → domains/security/templates/frigg-deployment-iam-stack.yaml} +0 -0
  66. /package/infrastructure/{iam-policy-basic.json → domains/security/templates/iam-policy-basic.json} +0 -0
  67. /package/infrastructure/{iam-policy-full.json → domains/security/templates/iam-policy-full.json} +0 -0
  68. /package/infrastructure/{env-validator.js → domains/shared/validation/env-validator.js} +0 -0
  69. /package/infrastructure/{build-time-discovery.js → scripts/build-time-discovery.js} +0 -0
  70. /package/infrastructure/{run-discovery.js → scripts/run-discovery.js} +0 -0
@@ -0,0 +1,93 @@
1
+ /**
2
+ * FUTURE: Microsoft Azure Provider Adapter
3
+ *
4
+ * This file serves as a placeholder for future Azure support.
5
+ *
6
+ * Implementation will use:
7
+ * - @azure/arm-network for Virtual Network discovery
8
+ * - @azure/keyvault-keys for Key Vault key management
9
+ * - @azure/arm-sql for Azure SQL database discovery
10
+ * - @azure/keyvault-secrets for secrets management
11
+ * - @azure/arm-resources for resource group management
12
+ *
13
+ * Resources:
14
+ * - Azure SDK for JavaScript: https://docs.microsoft.com/en-us/javascript/azure/
15
+ * - ARM Network API: https://docs.microsoft.com/en-us/javascript/api/@azure/arm-network
16
+ * - Key Vault API: https://docs.microsoft.com/en-us/javascript/api/@azure/keyvault-keys
17
+ * - Azure SQL API: https://docs.microsoft.com/en-us/javascript/api/@azure/arm-sql
18
+ *
19
+ * Architecture mapping:
20
+ * - AWS VPC → Azure Virtual Network (VNet)
21
+ * - AWS KMS → Azure Key Vault
22
+ * - AWS RDS Aurora → Azure SQL Database / Azure Database for PostgreSQL
23
+ * - AWS SSM Parameter Store → Azure Key Vault Secrets
24
+ * - AWS Lambda → Azure Functions
25
+ *
26
+ * Example structure:
27
+ *
28
+ * const { NetworkManagementClient } = require('@azure/arm-network');
29
+ * const { KeyClient } = require('@azure/keyvault-keys');
30
+ * const { DefaultAzureCredential } = require('@azure/identity');
31
+ * const { CloudProviderAdapter } = require('./cloud-provider-adapter');
32
+ *
33
+ * class AzureProviderAdapter extends CloudProviderAdapter {
34
+ * constructor(region, credentials = {}) {
35
+ * super();
36
+ * this.region = region || 'eastus';
37
+ * this.subscriptionId = credentials.subscriptionId || process.env.AZURE_SUBSCRIPTION_ID;
38
+ * this.credential = new DefaultAzureCredential();
39
+ *
40
+ * this.networkClient = new NetworkManagementClient(
41
+ * this.credential,
42
+ * this.subscriptionId
43
+ * );
44
+ * }
45
+ *
46
+ * getName() {
47
+ * return 'azure';
48
+ * }
49
+ *
50
+ * getSupportedRegions() {
51
+ * return [
52
+ * 'eastus', 'eastus2', 'westus', 'westus2',
53
+ * 'northeurope', 'westeurope', 'southeastasia'
54
+ * ];
55
+ * }
56
+ *
57
+ * async discoverVpc(config) {
58
+ * // Discover Azure Virtual Networks
59
+ * const vnets = [];
60
+ * for await (const vnet of this.networkClient.virtualNetworks.listAll()) {
61
+ * vnets.push(vnet);
62
+ * }
63
+ * // ... implementation
64
+ * }
65
+ *
66
+ * async discoverKmsKeys(config) {
67
+ * // Discover Azure Key Vault keys
68
+ * const keyVaultUrl = `https://${config.keyVaultName}.vault.azure.net`;
69
+ * const keyClient = new KeyClient(keyVaultUrl, this.credential);
70
+ * const keys = [];
71
+ * for await (const key of keyClient.listPropertiesOfKeys()) {
72
+ * keys.push(key);
73
+ * }
74
+ * // ... implementation
75
+ * }
76
+ *
77
+ * async discoverDatabase(config) {
78
+ * // Discover Azure SQL databases
79
+ * // ... implementation
80
+ * }
81
+ *
82
+ * async discoverParameters(config) {
83
+ * // Discover Azure Key Vault secrets
84
+ * // ... implementation
85
+ * }
86
+ * }
87
+ *
88
+ * module.exports = { AzureProviderAdapter };
89
+ */
90
+
91
+ // Placeholder export to prevent import errors
92
+ module.exports = {};
93
+
@@ -0,0 +1,136 @@
1
+ /**
2
+ * Cloud Provider Adapter (Abstract Base Class)
3
+ *
4
+ * Port - Hexagonal Architecture
5
+ *
6
+ * Defines the contract for cloud provider implementations.
7
+ * This abstraction enables multi-cloud support by providing a consistent
8
+ * interface for AWS, GCP, Azure, and other cloud providers.
9
+ *
10
+ * Benefits:
11
+ * - Cloud-agnostic infrastructure code
12
+ * - Easy to add new providers (just implement this interface)
13
+ * - Testable with mock providers
14
+ * - Clear separation between cloud-specific and business logic
15
+ */
16
+
17
+ class CloudProviderAdapter {
18
+ /**
19
+ * Get provider name
20
+ * @returns {string} Provider name ('aws', 'gcp', 'azure', etc.)
21
+ */
22
+ getName() {
23
+ throw new Error('CloudProviderAdapter.getName() must be implemented by subclass');
24
+ }
25
+
26
+ /**
27
+ * Get supported regions for this provider
28
+ * @returns {Array<string>} List of supported region identifiers
29
+ */
30
+ getSupportedRegions() {
31
+ throw new Error('CloudProviderAdapter.getSupportedRegions() must be implemented by subclass');
32
+ }
33
+
34
+ // ==================== Discovery Methods ====================
35
+
36
+ /**
37
+ * Discover VPC/network resources
38
+ *
39
+ * @param {Object} config - Discovery configuration
40
+ * @param {string} [config.vpcId] - Specific VPC ID to discover
41
+ * @param {string} [config.vpcName] - VPC name pattern to search for
42
+ * @param {boolean} [config.includeSubnets] - Whether to include subnet details
43
+ * @returns {Promise<Object>} Discovered VPC resources
44
+ * @returns {Promise<Object>} result.vpcId - VPC identifier
45
+ * @returns {Promise<Object>} result.vpcCidr - VPC CIDR block
46
+ * @returns {Promise<Object>} result.subnets - Array of subnet objects
47
+ * @returns {Promise<Object>} result.securityGroups - Array of security group objects
48
+ * @returns {Promise<Object>} result.routeTables - Array of route table objects
49
+ */
50
+ async discoverVpc(config) {
51
+ throw new Error('CloudProviderAdapter.discoverVpc() must be implemented by subclass');
52
+ }
53
+
54
+ /**
55
+ * Discover encryption keys (KMS, Cloud KMS, Azure Key Vault, etc.)
56
+ *
57
+ * @param {Object} config - Discovery configuration
58
+ * @param {string} [config.keyId] - Specific key ID to discover
59
+ * @param {string} [config.keyAlias] - Key alias to search for
60
+ * @returns {Promise<Object>} Discovered encryption key resources
61
+ * @returns {Promise<Object>} result.keyId - Key identifier
62
+ * @returns {Promise<Object>} result.keyArn - Key ARN/resource name
63
+ * @returns {Promise<Object>} result.aliases - Array of key aliases
64
+ */
65
+ async discoverKmsKeys(config) {
66
+ throw new Error('CloudProviderAdapter.discoverKmsKeys() must be implemented by subclass');
67
+ }
68
+
69
+ /**
70
+ * Discover database resources (RDS, Cloud SQL, Azure SQL, etc.)
71
+ *
72
+ * @param {Object} config - Discovery configuration
73
+ * @param {string} [config.databaseId] - Specific database instance/cluster ID
74
+ * @param {string} [config.engine] - Database engine filter ('postgresql', 'mysql', etc.)
75
+ * @returns {Promise<Object>} Discovered database resources
76
+ * @returns {Promise<Object>} result.endpoint - Database connection endpoint
77
+ * @returns {Promise<Object>} result.port - Database port
78
+ * @returns {Promise<Object>} result.engine - Database engine type
79
+ * @returns {Promise<Object>} result.version - Database version
80
+ */
81
+ async discoverDatabase(config) {
82
+ throw new Error('CloudProviderAdapter.discoverDatabase() must be implemented by subclass');
83
+ }
84
+
85
+ /**
86
+ * Discover parameter store/secret manager resources
87
+ *
88
+ * @param {Object} config - Discovery configuration
89
+ * @param {string} [config.parameterPath] - Parameter path prefix to search
90
+ * @param {string} [config.secretName] - Specific secret name to discover
91
+ * @returns {Promise<Object>} Discovered parameter/secret resources
92
+ * @returns {Promise<Object>} result.parameters - Array of parameter objects
93
+ * @returns {Promise<Object>} result.secrets - Array of secret objects
94
+ */
95
+ async discoverParameters(config) {
96
+ throw new Error('CloudProviderAdapter.discoverParameters() must be implemented by subclass');
97
+ }
98
+
99
+ // ==================== Provisioning Methods (Future) ====================
100
+ // These will be used for Terraform/Pulumi/CloudFormation generation
101
+
102
+ /**
103
+ * Generate VPC provisioning configuration
104
+ *
105
+ * @param {Object} config - VPC configuration
106
+ * @returns {Promise<Object>} Infrastructure-as-code configuration
107
+ */
108
+ async provisionVpc(config) {
109
+ throw new Error('CloudProviderAdapter.provisionVpc() not yet implemented. Future feature for IaC generation.');
110
+ }
111
+
112
+ /**
113
+ * Generate encryption key provisioning configuration
114
+ *
115
+ * @param {Object} config - Key configuration
116
+ * @returns {Promise<Object>} Infrastructure-as-code configuration
117
+ */
118
+ async provisionKmsKey(config) {
119
+ throw new Error('CloudProviderAdapter.provisionKmsKey() not yet implemented. Future feature for IaC generation.');
120
+ }
121
+
122
+ /**
123
+ * Generate database provisioning configuration
124
+ *
125
+ * @param {Object} config - Database configuration
126
+ * @returns {Promise<Object>} Infrastructure-as-code configuration
127
+ */
128
+ async provisionDatabase(config) {
129
+ throw new Error('CloudProviderAdapter.provisionDatabase() not yet implemented. Future feature for IaC generation.');
130
+ }
131
+ }
132
+
133
+ module.exports = {
134
+ CloudProviderAdapter,
135
+ };
136
+
@@ -0,0 +1,82 @@
1
+ /**
2
+ * FUTURE: Google Cloud Platform Provider Adapter
3
+ *
4
+ * This file serves as a placeholder for future GCP support.
5
+ *
6
+ * Implementation will use:
7
+ * - @google-cloud/compute for VPC/network discovery
8
+ * - @google-cloud/kms for encryption key management
9
+ * - @google-cloud/sql for Cloud SQL database discovery
10
+ * - @google-cloud/secret-manager for secrets management
11
+ *
12
+ * Resources:
13
+ * - GCP Node.js SDK: https://cloud.google.com/nodejs/docs/reference
14
+ * - Compute Engine API: https://cloud.google.com/compute/docs/reference/rest/v1
15
+ * - Cloud KMS API: https://cloud.google.com/kms/docs/reference/rest
16
+ * - Cloud SQL API: https://cloud.google.com/sql/docs/mysql/admin-api
17
+ *
18
+ * Architecture mapping:
19
+ * - AWS VPC → GCP VPC Network
20
+ * - AWS KMS → GCP Cloud KMS
21
+ * - AWS RDS Aurora → GCP Cloud SQL
22
+ * - AWS SSM Parameter Store → GCP Secret Manager
23
+ * - AWS Lambda → GCP Cloud Functions / Cloud Run
24
+ *
25
+ * Example structure:
26
+ *
27
+ * const { Compute } = require('@google-cloud/compute');
28
+ * const { KeyManagementServiceClient } = require('@google-cloud/kms');
29
+ * const { CloudProviderAdapter } = require('./cloud-provider-adapter');
30
+ *
31
+ * class GCPProviderAdapter extends CloudProviderAdapter {
32
+ * constructor(region, credentials = {}) {
33
+ * super();
34
+ * this.region = region || 'us-central1';
35
+ * this.projectId = credentials.projectId || process.env.GCP_PROJECT_ID;
36
+ *
37
+ * this.compute = new Compute({ projectId: this.projectId });
38
+ * this.kms = new KeyManagementServiceClient();
39
+ * }
40
+ *
41
+ * getName() {
42
+ * return 'gcp';
43
+ * }
44
+ *
45
+ * getSupportedRegions() {
46
+ * return [
47
+ * 'us-central1', 'us-east1', 'us-west1',
48
+ * 'europe-west1', 'asia-east1', 'asia-northeast1'
49
+ * ];
50
+ * }
51
+ *
52
+ * async discoverVpc(config) {
53
+ * // Discover GCP VPC networks
54
+ * const [networks] = await this.compute.getNetworks();
55
+ * // ... implementation
56
+ * }
57
+ *
58
+ * async discoverKmsKeys(config) {
59
+ * // Discover GCP Cloud KMS keys
60
+ * const [keyRings] = await this.kms.listKeyRings({
61
+ * parent: `projects/${this.projectId}/locations/${this.region}`
62
+ * });
63
+ * // ... implementation
64
+ * }
65
+ *
66
+ * async discoverDatabase(config) {
67
+ * // Discover GCP Cloud SQL instances
68
+ * // ... implementation
69
+ * }
70
+ *
71
+ * async discoverParameters(config) {
72
+ * // Discover GCP Secret Manager secrets
73
+ * // ... implementation
74
+ * }
75
+ * }
76
+ *
77
+ * module.exports = { GCPProviderAdapter };
78
+ */
79
+
80
+ // Placeholder export to prevent import errors
81
+ module.exports = {};
82
+
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Cloud Provider Factory
3
+ *
4
+ * Factory Pattern - Hexagonal Architecture
5
+ *
6
+ * Creates appropriate cloud provider adapter instances based on configuration.
7
+ * This enables runtime provider selection and makes it easy to add new providers.
8
+ */
9
+
10
+ const { CloudProviderAdapter } = require('./cloud-provider-adapter');
11
+ const { AWSProviderAdapter } = require('./aws-provider-adapter');
12
+
13
+ class CloudProviderFactory {
14
+ /**
15
+ * Create cloud provider adapter instance
16
+ *
17
+ * @param {string} providerName - Provider name ('aws', 'gcp', 'azure')
18
+ * @param {string} region - Provider region
19
+ * @param {Object} [credentials] - Optional credential configuration
20
+ * @returns {CloudProviderAdapter} Provider adapter instance
21
+ * @throws {Error} If provider is not supported
22
+ */
23
+ static create(providerName, region, credentials = {}) {
24
+ const normalizedProvider = (providerName || 'aws').toLowerCase();
25
+
26
+ switch (normalizedProvider) {
27
+ case 'aws':
28
+ return new AWSProviderAdapter(region, credentials);
29
+
30
+ case 'gcp':
31
+ case 'google':
32
+ throw new Error(
33
+ 'GCP provider not yet implemented. ' +
34
+ 'AWS is currently the only supported cloud provider. ' +
35
+ 'GCP support is planned for future releases.'
36
+ );
37
+
38
+ case 'azure':
39
+ case 'microsoft':
40
+ throw new Error(
41
+ 'Azure provider not yet implemented. ' +
42
+ 'AWS is currently the only supported cloud provider. ' +
43
+ 'Azure support is planned for future releases.'
44
+ );
45
+
46
+ default:
47
+ throw new Error(
48
+ `Unknown cloud provider: "${providerName}". ` +
49
+ `Supported providers: aws (gcp and azure coming soon)`
50
+ );
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Get list of supported providers
56
+ *
57
+ * @returns {Array<Object>} List of provider metadata
58
+ */
59
+ static getSupportedProviders() {
60
+ return [
61
+ {
62
+ name: 'aws',
63
+ displayName: 'Amazon Web Services',
64
+ status: 'available',
65
+ description: 'AWS cloud provider with support for Lambda, VPC, RDS, KMS, etc.',
66
+ },
67
+ {
68
+ name: 'gcp',
69
+ displayName: 'Google Cloud Platform',
70
+ status: 'planned',
71
+ description: 'GCP cloud provider support coming soon',
72
+ },
73
+ {
74
+ name: 'azure',
75
+ displayName: 'Microsoft Azure',
76
+ status: 'planned',
77
+ description: 'Azure cloud provider support coming soon',
78
+ },
79
+ ];
80
+ }
81
+
82
+ /**
83
+ * Check if a provider is supported
84
+ *
85
+ * @param {string} providerName - Provider name to check
86
+ * @returns {boolean} True if provider is supported
87
+ */
88
+ static isSupported(providerName) {
89
+ const normalized = (providerName || '').toLowerCase();
90
+ return ['aws', 'gcp', 'google', 'azure', 'microsoft'].includes(normalized);
91
+ }
92
+
93
+ /**
94
+ * Check if a provider is available (implemented)
95
+ *
96
+ * @param {string} providerName - Provider name to check
97
+ * @returns {boolean} True if provider is implemented
98
+ */
99
+ static isAvailable(providerName) {
100
+ const normalized = (providerName || '').toLowerCase();
101
+ return normalized === 'aws';
102
+ }
103
+ }
104
+
105
+ module.exports = {
106
+ CloudProviderFactory,
107
+ };
108
+
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Tests for CloudProviderFactory
3
+ *
4
+ * Verifies provider instantiation, error handling, and factory patterns
5
+ */
6
+
7
+ const { CloudProviderFactory } = require('./provider-factory');
8
+ const { AWSProviderAdapter } = require('./aws-provider-adapter');
9
+
10
+ describe('CloudProviderFactory', () => {
11
+ describe('create()', () => {
12
+ it('should create AWS provider when provider is "aws"', () => {
13
+ const provider = CloudProviderFactory.create('aws', 'us-east-1');
14
+
15
+ expect(provider).toBeInstanceOf(AWSProviderAdapter);
16
+ expect(provider.getName()).toBe('aws');
17
+ expect(provider.region).toBe('us-east-1');
18
+ });
19
+
20
+ it('should default to AWS provider when no provider specified', () => {
21
+ const provider = CloudProviderFactory.create(null, 'us-west-2');
22
+
23
+ expect(provider).toBeInstanceOf(AWSProviderAdapter);
24
+ expect(provider.region).toBe('us-west-2');
25
+ });
26
+
27
+ it('should be case-insensitive for provider names', () => {
28
+ const provider = CloudProviderFactory.create('AWS', 'eu-west-1');
29
+
30
+ expect(provider).toBeInstanceOf(AWSProviderAdapter);
31
+ });
32
+
33
+ it('should throw error for GCP (not yet implemented)', () => {
34
+ expect(() => {
35
+ CloudProviderFactory.create('gcp', 'us-central1');
36
+ }).toThrow('GCP provider not yet implemented');
37
+ });
38
+
39
+ it('should throw error for Azure (not yet implemented)', () => {
40
+ expect(() => {
41
+ CloudProviderFactory.create('azure', 'eastus');
42
+ }).toThrow('Azure provider not yet implemented');
43
+ });
44
+
45
+ it('should handle "google" alias for GCP', () => {
46
+ expect(() => {
47
+ CloudProviderFactory.create('google', 'us-central1');
48
+ }).toThrow('GCP provider not yet implemented');
49
+ });
50
+
51
+ it('should handle "microsoft" alias for Azure', () => {
52
+ expect(() => {
53
+ CloudProviderFactory.create('microsoft', 'eastus');
54
+ }).toThrow('Azure provider not yet implemented');
55
+ });
56
+
57
+ it('should throw error for unknown provider', () => {
58
+ expect(() => {
59
+ CloudProviderFactory.create('unknown-cloud', 'region-1');
60
+ }).toThrow('Unknown cloud provider: "unknown-cloud"');
61
+ });
62
+
63
+ it('should pass credentials to provider', () => {
64
+ const credentials = {
65
+ accessKeyId: 'test-key',
66
+ secretAccessKey: 'test-secret',
67
+ };
68
+
69
+ const provider = CloudProviderFactory.create('aws', 'us-east-1', credentials);
70
+
71
+ expect(provider.credentials).toEqual(credentials);
72
+ });
73
+ });
74
+
75
+ describe('getSupportedProviders()', () => {
76
+ it('should return list of supported providers', () => {
77
+ const providers = CloudProviderFactory.getSupportedProviders();
78
+
79
+ expect(Array.isArray(providers)).toBe(true);
80
+ expect(providers.length).toBeGreaterThanOrEqual(3);
81
+ });
82
+
83
+ it('should include AWS as available', () => {
84
+ const providers = CloudProviderFactory.getSupportedProviders();
85
+ const aws = providers.find(p => p.name === 'aws');
86
+
87
+ expect(aws).toBeDefined();
88
+ expect(aws.status).toBe('available');
89
+ expect(aws.displayName).toBe('Amazon Web Services');
90
+ });
91
+
92
+ it('should include GCP as planned', () => {
93
+ const providers = CloudProviderFactory.getSupportedProviders();
94
+ const gcp = providers.find(p => p.name === 'gcp');
95
+
96
+ expect(gcp).toBeDefined();
97
+ expect(gcp.status).toBe('planned');
98
+ expect(gcp.displayName).toBe('Google Cloud Platform');
99
+ });
100
+
101
+ it('should include Azure as planned', () => {
102
+ const providers = CloudProviderFactory.getSupportedProviders();
103
+ const azure = providers.find(p => p.name === 'azure');
104
+
105
+ expect(azure).toBeDefined();
106
+ expect(azure.status).toBe('planned');
107
+ expect(azure.displayName).toBe('Microsoft Azure');
108
+ });
109
+ });
110
+
111
+ describe('isSupported()', () => {
112
+ it('should return true for aws', () => {
113
+ expect(CloudProviderFactory.isSupported('aws')).toBe(true);
114
+ });
115
+
116
+ it('should return true for gcp', () => {
117
+ expect(CloudProviderFactory.isSupported('gcp')).toBe(true);
118
+ });
119
+
120
+ it('should return true for azure', () => {
121
+ expect(CloudProviderFactory.isSupported('azure')).toBe(true);
122
+ });
123
+
124
+ it('should return true for google (gcp alias)', () => {
125
+ expect(CloudProviderFactory.isSupported('google')).toBe(true);
126
+ });
127
+
128
+ it('should return true for microsoft (azure alias)', () => {
129
+ expect(CloudProviderFactory.isSupported('microsoft')).toBe(true);
130
+ });
131
+
132
+ it('should return false for unknown provider', () => {
133
+ expect(CloudProviderFactory.isSupported('unknown')).toBe(false);
134
+ });
135
+
136
+ it('should be case-insensitive', () => {
137
+ expect(CloudProviderFactory.isSupported('AWS')).toBe(true);
138
+ expect(CloudProviderFactory.isSupported('GCP')).toBe(true);
139
+ });
140
+
141
+ it('should handle null/undefined gracefully', () => {
142
+ expect(CloudProviderFactory.isSupported(null)).toBe(false);
143
+ expect(CloudProviderFactory.isSupported(undefined)).toBe(false);
144
+ });
145
+ });
146
+
147
+ describe('isAvailable()', () => {
148
+ it('should return true only for aws', () => {
149
+ expect(CloudProviderFactory.isAvailable('aws')).toBe(true);
150
+ });
151
+
152
+ it('should return false for gcp (not yet implemented)', () => {
153
+ expect(CloudProviderFactory.isAvailable('gcp')).toBe(false);
154
+ });
155
+
156
+ it('should return false for azure (not yet implemented)', () => {
157
+ expect(CloudProviderFactory.isAvailable('azure')).toBe(false);
158
+ });
159
+
160
+ it('should return false for unknown provider', () => {
161
+ expect(CloudProviderFactory.isAvailable('unknown')).toBe(false);
162
+ });
163
+
164
+ it('should be case-insensitive', () => {
165
+ expect(CloudProviderFactory.isAvailable('AWS')).toBe(true);
166
+ expect(CloudProviderFactory.isAvailable('GCP')).toBe(false);
167
+ });
168
+ });
169
+ });
170
+