@friggframework/devtools 2.0.0--canary.474.28f4860.0 → 2.0.0--canary.474.97bfcf0.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.
- package/infrastructure/domains/health/domain/entities/property-mismatch.js +105 -0
- package/infrastructure/domains/health/domain/entities/property-mismatch.test.js +251 -0
- package/infrastructure/domains/health/domain/value-objects/health-score.js +138 -0
- package/infrastructure/domains/health/domain/value-objects/health-score.test.js +267 -0
- package/infrastructure/domains/health/domain/value-objects/property-mutability.js +161 -0
- package/infrastructure/domains/health/domain/value-objects/property-mutability.test.js +198 -0
- package/infrastructure/domains/health/domain/value-objects/resource-state.js +167 -0
- package/infrastructure/domains/health/domain/value-objects/resource-state.test.js +196 -0
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.js +179 -0
- package/infrastructure/domains/health/domain/value-objects/stack-identifier.test.js +233 -0
- package/infrastructure/domains/security/kms-builder.js +10 -1
- package/package.json +6 -6
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for StackIdentifier Value Object
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const StackIdentifier = require('./stack-identifier');
|
|
6
|
+
|
|
7
|
+
describe('StackIdentifier', () => {
|
|
8
|
+
describe('constructor', () => {
|
|
9
|
+
it('should create a valid stack identifier', () => {
|
|
10
|
+
const identifier = new StackIdentifier({
|
|
11
|
+
stackName: 'my-app-prod',
|
|
12
|
+
region: 'us-east-1',
|
|
13
|
+
accountId: '123456789012',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
expect(identifier.stackName).toBe('my-app-prod');
|
|
17
|
+
expect(identifier.region).toBe('us-east-1');
|
|
18
|
+
expect(identifier.accountId).toBe('123456789012');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should require stackName', () => {
|
|
22
|
+
expect(() => {
|
|
23
|
+
new StackIdentifier({
|
|
24
|
+
region: 'us-east-1',
|
|
25
|
+
accountId: '123456789012',
|
|
26
|
+
});
|
|
27
|
+
}).toThrow('stackName is required');
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should require region', () => {
|
|
31
|
+
expect(() => {
|
|
32
|
+
new StackIdentifier({
|
|
33
|
+
stackName: 'my-app-prod',
|
|
34
|
+
accountId: '123456789012',
|
|
35
|
+
});
|
|
36
|
+
}).toThrow('region is required');
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should allow accountId to be optional', () => {
|
|
40
|
+
const identifier = new StackIdentifier({
|
|
41
|
+
stackName: 'my-app-prod',
|
|
42
|
+
region: 'us-east-1',
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
expect(identifier.stackName).toBe('my-app-prod');
|
|
46
|
+
expect(identifier.region).toBe('us-east-1');
|
|
47
|
+
expect(identifier.accountId).toBeNull();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('should validate stackName format', () => {
|
|
51
|
+
expect(() => {
|
|
52
|
+
new StackIdentifier({
|
|
53
|
+
stackName: '',
|
|
54
|
+
region: 'us-east-1',
|
|
55
|
+
});
|
|
56
|
+
}).toThrow('stackName cannot be empty');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should validate region format', () => {
|
|
60
|
+
expect(() => {
|
|
61
|
+
new StackIdentifier({
|
|
62
|
+
stackName: 'my-app-prod',
|
|
63
|
+
region: 'invalid-region',
|
|
64
|
+
});
|
|
65
|
+
}).toThrow('region must be a valid AWS region');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should validate accountId format when provided', () => {
|
|
69
|
+
expect(() => {
|
|
70
|
+
new StackIdentifier({
|
|
71
|
+
stackName: 'my-app-prod',
|
|
72
|
+
region: 'us-east-1',
|
|
73
|
+
accountId: '123',
|
|
74
|
+
});
|
|
75
|
+
}).toThrow('accountId must be a 12-digit number');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should accept valid AWS regions', () => {
|
|
79
|
+
const validRegions = [
|
|
80
|
+
'us-east-1',
|
|
81
|
+
'us-east-2',
|
|
82
|
+
'us-west-1',
|
|
83
|
+
'us-west-2',
|
|
84
|
+
'eu-west-1',
|
|
85
|
+
'eu-central-1',
|
|
86
|
+
'ap-southeast-1',
|
|
87
|
+
'ap-northeast-1',
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
validRegions.forEach(region => {
|
|
91
|
+
expect(() => {
|
|
92
|
+
new StackIdentifier({
|
|
93
|
+
stackName: 'my-app-prod',
|
|
94
|
+
region,
|
|
95
|
+
});
|
|
96
|
+
}).not.toThrow();
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe('equals', () => {
|
|
102
|
+
it('should return true for identical identifiers', () => {
|
|
103
|
+
const id1 = new StackIdentifier({
|
|
104
|
+
stackName: 'my-app-prod',
|
|
105
|
+
region: 'us-east-1',
|
|
106
|
+
accountId: '123456789012',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const id2 = new StackIdentifier({
|
|
110
|
+
stackName: 'my-app-prod',
|
|
111
|
+
region: 'us-east-1',
|
|
112
|
+
accountId: '123456789012',
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(id1.equals(id2)).toBe(true);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('should return false for different stack names', () => {
|
|
119
|
+
const id1 = new StackIdentifier({
|
|
120
|
+
stackName: 'my-app-prod',
|
|
121
|
+
region: 'us-east-1',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const id2 = new StackIdentifier({
|
|
125
|
+
stackName: 'my-app-dev',
|
|
126
|
+
region: 'us-east-1',
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
expect(id1.equals(id2)).toBe(false);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should return false for different regions', () => {
|
|
133
|
+
const id1 = new StackIdentifier({
|
|
134
|
+
stackName: 'my-app-prod',
|
|
135
|
+
region: 'us-east-1',
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const id2 = new StackIdentifier({
|
|
139
|
+
stackName: 'my-app-prod',
|
|
140
|
+
region: 'us-west-2',
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(id1.equals(id2)).toBe(false);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('should return false for different account IDs', () => {
|
|
147
|
+
const id1 = new StackIdentifier({
|
|
148
|
+
stackName: 'my-app-prod',
|
|
149
|
+
region: 'us-east-1',
|
|
150
|
+
accountId: '123456789012',
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const id2 = new StackIdentifier({
|
|
154
|
+
stackName: 'my-app-prod',
|
|
155
|
+
region: 'us-east-1',
|
|
156
|
+
accountId: '987654321098',
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
expect(id1.equals(id2)).toBe(false);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('should handle null accountId comparison', () => {
|
|
163
|
+
const id1 = new StackIdentifier({
|
|
164
|
+
stackName: 'my-app-prod',
|
|
165
|
+
region: 'us-east-1',
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
const id2 = new StackIdentifier({
|
|
169
|
+
stackName: 'my-app-prod',
|
|
170
|
+
region: 'us-east-1',
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
expect(id1.equals(id2)).toBe(true);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
describe('toString', () => {
|
|
178
|
+
it('should return string representation with account ID', () => {
|
|
179
|
+
const identifier = new StackIdentifier({
|
|
180
|
+
stackName: 'my-app-prod',
|
|
181
|
+
region: 'us-east-1',
|
|
182
|
+
accountId: '123456789012',
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
expect(identifier.toString()).toBe('my-app-prod (us-east-1, 123456789012)');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it('should return string representation without account ID', () => {
|
|
189
|
+
const identifier = new StackIdentifier({
|
|
190
|
+
stackName: 'my-app-prod',
|
|
191
|
+
region: 'us-east-1',
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
expect(identifier.toString()).toBe('my-app-prod (us-east-1)');
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
describe('immutability', () => {
|
|
199
|
+
it('should not allow modification of stackName', () => {
|
|
200
|
+
const identifier = new StackIdentifier({
|
|
201
|
+
stackName: 'my-app-prod',
|
|
202
|
+
region: 'us-east-1',
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
expect(() => {
|
|
206
|
+
identifier.stackName = 'modified';
|
|
207
|
+
}).toThrow();
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
it('should not allow modification of region', () => {
|
|
211
|
+
const identifier = new StackIdentifier({
|
|
212
|
+
stackName: 'my-app-prod',
|
|
213
|
+
region: 'us-east-1',
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
expect(() => {
|
|
217
|
+
identifier.region = 'us-west-2';
|
|
218
|
+
}).toThrow();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('should not allow modification of accountId', () => {
|
|
222
|
+
const identifier = new StackIdentifier({
|
|
223
|
+
stackName: 'my-app-prod',
|
|
224
|
+
region: 'us-east-1',
|
|
225
|
+
accountId: '123456789012',
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
expect(() => {
|
|
229
|
+
identifier.accountId = '987654321098';
|
|
230
|
+
}).toThrow();
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
@@ -121,7 +121,10 @@ class KmsBuilder extends InfrastructureBuilder {
|
|
|
121
121
|
|
|
122
122
|
// Infer logical IDs from physical IDs if needed
|
|
123
123
|
if (hasExistingStackResources && existingLogicalIds.length === 0) {
|
|
124
|
-
if (flatDiscovery.defaultKmsKeyId)
|
|
124
|
+
if (flatDiscovery.defaultKmsKeyId) {
|
|
125
|
+
existingLogicalIds.push('FriggKMSKey');
|
|
126
|
+
existingLogicalIds.push('FriggKMSKeyAlias');
|
|
127
|
+
}
|
|
125
128
|
}
|
|
126
129
|
|
|
127
130
|
existingLogicalIds.forEach(logicalId => {
|
|
@@ -131,6 +134,12 @@ class KmsBuilder extends InfrastructureBuilder {
|
|
|
131
134
|
if (logicalId === 'FriggKMSKey') {
|
|
132
135
|
resourceType = 'AWS::KMS::Key';
|
|
133
136
|
physicalId = flatDiscovery.defaultKmsKeyId;
|
|
137
|
+
} else if (logicalId === 'FriggKMSKeyAlias') {
|
|
138
|
+
resourceType = 'AWS::KMS::Alias';
|
|
139
|
+
// Extract alias name from KMS key ARN or use default pattern
|
|
140
|
+
const stackName = flatDiscovery.stackName || 'unknown';
|
|
141
|
+
const stage = appDefinition.stage || 'dev';
|
|
142
|
+
physicalId = `alias/${stackName.replace(`-${stage}`, '')}-${stage}-frigg-kms`;
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
if (physicalId && typeof physicalId === 'string') {
|
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.474.
|
|
4
|
+
"version": "2.0.0--canary.474.97bfcf0.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@aws-sdk/client-ec2": "^3.835.0",
|
|
7
7
|
"@aws-sdk/client-kms": "^3.835.0",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"@babel/eslint-parser": "^7.18.9",
|
|
12
12
|
"@babel/parser": "^7.25.3",
|
|
13
13
|
"@babel/traverse": "^7.25.3",
|
|
14
|
-
"@friggframework/schemas": "2.0.0--canary.474.
|
|
15
|
-
"@friggframework/test": "2.0.0--canary.474.
|
|
14
|
+
"@friggframework/schemas": "2.0.0--canary.474.97bfcf0.0",
|
|
15
|
+
"@friggframework/test": "2.0.0--canary.474.97bfcf0.0",
|
|
16
16
|
"@hapi/boom": "^10.0.1",
|
|
17
17
|
"@inquirer/prompts": "^5.3.8",
|
|
18
18
|
"axios": "^1.7.2",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"serverless-http": "^2.7.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@friggframework/eslint-config": "2.0.0--canary.474.
|
|
38
|
-
"@friggframework/prettier-config": "2.0.0--canary.474.
|
|
37
|
+
"@friggframework/eslint-config": "2.0.0--canary.474.97bfcf0.0",
|
|
38
|
+
"@friggframework/prettier-config": "2.0.0--canary.474.97bfcf0.0",
|
|
39
39
|
"aws-sdk-client-mock": "^4.1.0",
|
|
40
40
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
41
41
|
"jest": "^30.1.3",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"publishConfig": {
|
|
71
71
|
"access": "public"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "97bfcf0665c0e5d99e5f129de468a77e21fbe227"
|
|
74
74
|
}
|