@stacksjs/ts-cloud-core 0.1.7 → 0.1.9
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/package.json +7 -6
- package/src/advanced-features.test.ts +465 -0
- package/src/aws/cloudformation.ts +421 -0
- package/src/aws/cloudfront.ts +158 -0
- package/src/aws/credentials.test.ts +132 -0
- package/src/aws/credentials.ts +545 -0
- package/src/aws/index.ts +87 -0
- package/src/aws/s3.test.ts +188 -0
- package/src/aws/s3.ts +1088 -0
- package/src/aws/signature.test.ts +670 -0
- package/src/aws/signature.ts +1155 -0
- package/src/backup/disaster-recovery.test.ts +726 -0
- package/src/backup/disaster-recovery.ts +500 -0
- package/src/backup/index.ts +34 -0
- package/src/backup/manager.test.ts +498 -0
- package/src/backup/manager.ts +432 -0
- package/src/cicd/circleci.ts +430 -0
- package/src/cicd/github-actions.ts +424 -0
- package/src/cicd/gitlab-ci.ts +255 -0
- package/src/cicd/index.ts +8 -0
- package/src/cli/history.ts +396 -0
- package/src/cli/index.ts +10 -0
- package/src/cli/progress.ts +458 -0
- package/src/cli/repl.ts +454 -0
- package/src/cli/suggestions.ts +327 -0
- package/src/cli/table.test.ts +319 -0
- package/src/cli/table.ts +332 -0
- package/src/cloudformation/builder.test.ts +327 -0
- package/src/cloudformation/builder.ts +378 -0
- package/src/cloudformation/builders/api-gateway.ts +449 -0
- package/src/cloudformation/builders/cache.ts +334 -0
- package/src/cloudformation/builders/cdn.ts +278 -0
- package/src/cloudformation/builders/compute.ts +485 -0
- package/src/cloudformation/builders/database.ts +392 -0
- package/src/cloudformation/builders/functions.ts +343 -0
- package/src/cloudformation/builders/messaging.ts +140 -0
- package/src/cloudformation/builders/monitoring.ts +300 -0
- package/src/cloudformation/builders/network.ts +264 -0
- package/src/cloudformation/builders/queue.ts +147 -0
- package/src/cloudformation/builders/security.ts +399 -0
- package/src/cloudformation/builders/storage.ts +285 -0
- package/src/cloudformation/index.ts +30 -0
- package/src/cloudformation/types.ts +173 -0
- package/src/compliance/aws-config.ts +543 -0
- package/src/compliance/cloudtrail.ts +376 -0
- package/src/compliance/compliance.test.ts +423 -0
- package/src/compliance/guardduty.ts +446 -0
- package/src/compliance/index.ts +66 -0
- package/src/compliance/security-hub.ts +456 -0
- package/src/containers/build-optimization.ts +416 -0
- package/src/containers/containers.test.ts +508 -0
- package/src/containers/image-scanning.ts +360 -0
- package/src/containers/index.ts +9 -0
- package/src/containers/registry.ts +293 -0
- package/src/containers/service-mesh.ts +520 -0
- package/src/database/database.test.ts +762 -0
- package/src/database/index.ts +9 -0
- package/src/database/migrations.ts +444 -0
- package/src/database/performance.ts +528 -0
- package/src/database/replicas.ts +534 -0
- package/src/database/users.ts +494 -0
- package/src/dependency-graph.ts +143 -0
- package/src/deployment/ab-testing.ts +582 -0
- package/src/deployment/blue-green.ts +452 -0
- package/src/deployment/canary.ts +500 -0
- package/src/deployment/deployment.test.ts +526 -0
- package/src/deployment/index.ts +61 -0
- package/src/deployment/progressive.ts +62 -0
- package/src/dns/dns.test.ts +641 -0
- package/src/dns/dnssec.ts +315 -0
- package/src/dns/index.ts +8 -0
- package/src/dns/resolver.ts +496 -0
- package/src/dns/routing.ts +593 -0
- package/src/email/advanced/analytics.ts +445 -0
- package/src/email/advanced/index.ts +11 -0
- package/src/email/advanced/rules.ts +465 -0
- package/src/email/advanced/scheduling.ts +352 -0
- package/src/email/advanced/search.ts +412 -0
- package/src/email/advanced/shared-mailboxes.ts +404 -0
- package/src/email/advanced/templates.ts +455 -0
- package/src/email/advanced/threading.ts +281 -0
- package/src/email/analytics.ts +467 -0
- package/src/email/bounce-handling.ts +425 -0
- package/src/email/email.test.ts +431 -0
- package/src/email/handlers/__tests__/inbound.test.ts +38 -0
- package/src/email/handlers/__tests__/outbound.test.ts +37 -0
- package/src/email/handlers/converter.ts +227 -0
- package/src/email/handlers/feedback.ts +228 -0
- package/src/email/handlers/inbound.ts +169 -0
- package/src/email/handlers/outbound.ts +178 -0
- package/src/email/index.ts +15 -0
- package/src/email/reputation.ts +303 -0
- package/src/email/templates.ts +352 -0
- package/src/errors/index.test.ts +434 -0
- package/src/errors/index.ts +416 -0
- package/src/health-checks/index.ts +40 -0
- package/src/index.ts +360 -0
- package/src/intrinsic-functions.ts +118 -0
- package/src/lambda/concurrency.ts +330 -0
- package/src/lambda/destinations.ts +345 -0
- package/src/lambda/dlq.ts +425 -0
- package/src/lambda/index.ts +11 -0
- package/src/lambda/lambda.test.ts +840 -0
- package/src/lambda/layers.ts +263 -0
- package/src/lambda/versions.ts +376 -0
- package/src/lambda/vpc.ts +399 -0
- package/src/local/config.ts +114 -0
- package/src/local/index.ts +6 -0
- package/src/local/mock-aws.ts +351 -0
- package/src/modules/ai.ts +340 -0
- package/src/modules/api.ts +478 -0
- package/src/modules/auth.ts +805 -0
- package/src/modules/cache.ts +417 -0
- package/src/modules/cdn.ts +1062 -0
- package/src/modules/communication.ts +1094 -0
- package/src/modules/compute.ts +3348 -0
- package/src/modules/database.ts +554 -0
- package/src/modules/deployment.ts +1079 -0
- package/src/modules/dns.ts +337 -0
- package/src/modules/email.ts +1538 -0
- package/src/modules/filesystem.ts +515 -0
- package/src/modules/index.ts +32 -0
- package/src/modules/messaging.ts +486 -0
- package/src/modules/monitoring.ts +2086 -0
- package/src/modules/network.ts +664 -0
- package/src/modules/parameter-store.ts +325 -0
- package/src/modules/permissions.ts +1081 -0
- package/src/modules/phone.ts +494 -0
- package/src/modules/queue.ts +1260 -0
- package/src/modules/redirects.ts +464 -0
- package/src/modules/registry.ts +699 -0
- package/src/modules/search.ts +401 -0
- package/src/modules/secrets.ts +416 -0
- package/src/modules/security.ts +731 -0
- package/src/modules/sms.ts +389 -0
- package/src/modules/storage.ts +1120 -0
- package/src/modules/workflow.ts +680 -0
- package/src/multi-account/config.ts +521 -0
- package/src/multi-account/index.ts +7 -0
- package/src/multi-account/manager.ts +427 -0
- package/src/multi-region/cross-region.ts +410 -0
- package/src/multi-region/index.ts +8 -0
- package/src/multi-region/manager.ts +483 -0
- package/src/multi-region/regions.ts +435 -0
- package/src/network-security/index.ts +48 -0
- package/src/observability/index.ts +9 -0
- package/src/observability/logs.ts +522 -0
- package/src/observability/metrics.ts +460 -0
- package/src/observability/observability.test.ts +782 -0
- package/src/observability/synthetics.ts +568 -0
- package/src/observability/xray.ts +358 -0
- package/src/phone/advanced/analytics.ts +349 -0
- package/src/phone/advanced/callbacks.ts +428 -0
- package/src/phone/advanced/index.ts +8 -0
- package/src/phone/advanced/ivr-builder.ts +504 -0
- package/src/phone/advanced/recording.ts +310 -0
- package/src/phone/handlers/__tests__/incoming-call.test.ts +40 -0
- package/src/phone/handlers/incoming-call.ts +117 -0
- package/src/phone/handlers/missed-call.ts +116 -0
- package/src/phone/handlers/voicemail.ts +179 -0
- package/src/phone/index.ts +9 -0
- package/src/presets/api-backend.ts +134 -0
- package/src/presets/data-pipeline.ts +204 -0
- package/src/presets/extend.test.ts +295 -0
- package/src/presets/extend.ts +297 -0
- package/src/presets/fullstack-app.ts +144 -0
- package/src/presets/index.ts +27 -0
- package/src/presets/jamstack.ts +135 -0
- package/src/presets/microservices.ts +167 -0
- package/src/presets/ml-api.ts +208 -0
- package/src/presets/nodejs-server.ts +104 -0
- package/src/presets/nodejs-serverless.ts +114 -0
- package/src/presets/realtime-app.ts +184 -0
- package/src/presets/static-site.ts +64 -0
- package/src/presets/traditional-web-app.ts +339 -0
- package/src/presets/wordpress.ts +138 -0
- package/src/preview/github.test.ts +249 -0
- package/src/preview/github.ts +297 -0
- package/src/preview/index.ts +37 -0
- package/src/preview/manager.test.ts +440 -0
- package/src/preview/manager.ts +326 -0
- package/src/preview/notifications.test.ts +582 -0
- package/src/preview/notifications.ts +341 -0
- package/src/queue/batch-processing.ts +402 -0
- package/src/queue/dlq-monitoring.ts +402 -0
- package/src/queue/fifo.ts +342 -0
- package/src/queue/index.ts +9 -0
- package/src/queue/management.ts +428 -0
- package/src/queue/queue.test.ts +429 -0
- package/src/resource-mgmt/index.ts +39 -0
- package/src/resource-naming.ts +62 -0
- package/src/s3/index.ts +523 -0
- package/src/schema/cloud-config.schema.json +554 -0
- package/src/schema/index.ts +68 -0
- package/src/security/certificate-manager.ts +492 -0
- package/src/security/index.ts +9 -0
- package/src/security/scanning.ts +545 -0
- package/src/security/secrets-manager.ts +476 -0
- package/src/security/secrets-rotation.ts +456 -0
- package/src/security/security.test.ts +738 -0
- package/src/sms/advanced/ab-testing.ts +389 -0
- package/src/sms/advanced/analytics.ts +336 -0
- package/src/sms/advanced/campaigns.ts +523 -0
- package/src/sms/advanced/chatbot.ts +224 -0
- package/src/sms/advanced/index.ts +10 -0
- package/src/sms/advanced/link-tracking.ts +248 -0
- package/src/sms/advanced/mms.ts +308 -0
- package/src/sms/handlers/__tests__/send.test.ts +40 -0
- package/src/sms/handlers/delivery-status.ts +133 -0
- package/src/sms/handlers/receive.ts +162 -0
- package/src/sms/handlers/send.ts +174 -0
- package/src/sms/index.ts +9 -0
- package/src/stack-diff.ts +389 -0
- package/src/static-site/index.ts +85 -0
- package/src/template-builder.ts +110 -0
- package/src/template-validator.ts +574 -0
- package/src/utils/cache.ts +291 -0
- package/src/utils/diff.ts +269 -0
- package/src/utils/hash.ts +227 -0
- package/src/utils/index.ts +8 -0
- package/src/utils/parallel.ts +294 -0
- package/src/validators/credentials.test.ts +274 -0
- package/src/validators/credentials.ts +233 -0
- package/src/validators/quotas.test.ts +434 -0
- package/src/validators/quotas.ts +217 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ts-cloud-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core CloudFormation generation library for ts-cloud",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.com>",
|
|
@@ -15,15 +15,16 @@
|
|
|
15
15
|
},
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"
|
|
19
|
-
"
|
|
18
|
+
"import": "./dist/index.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"main": "./dist/index.js",
|
|
23
23
|
"module": "./dist/index.js",
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
25
|
"files": [
|
|
26
|
-
"dist"
|
|
26
|
+
"dist",
|
|
27
|
+
"src"
|
|
27
28
|
],
|
|
28
29
|
"scripts": {
|
|
29
30
|
"build": "bun --bun build.ts",
|
|
@@ -31,8 +32,8 @@
|
|
|
31
32
|
"typecheck": "tsc --noEmit"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
34
|
-
"@stacksjs/ts-cloud-types": "0.1.
|
|
35
|
-
"@stacksjs/ts-cloud-aws-types": "0.1.
|
|
35
|
+
"@stacksjs/ts-cloud-types": "0.1.9",
|
|
36
|
+
"@stacksjs/ts-cloud-aws-types": "0.1.9"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"typescript": "^5.9.3"
|
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import { describe, expect, it, beforeEach } from 'bun:test'
|
|
2
|
+
import { StaticSiteManager, staticSiteManager } from './static-site'
|
|
3
|
+
import { StorageAdvancedManager, storageAdvancedManager } from './s3'
|
|
4
|
+
import { HealthCheckManager, healthCheckManager } from './health-checks'
|
|
5
|
+
import { NetworkSecurityManager, networkSecurityManager } from './network-security'
|
|
6
|
+
import type { ContinuousBackup } from './backup/manager'
|
|
7
|
+
import { BackupManager, backupManager } from './backup/manager'
|
|
8
|
+
import { ResourceManagementManager, resourceManagementManager } from './resource-mgmt'
|
|
9
|
+
import { ProgressiveDeploymentManager, progressiveDeploymentManager } from './deployment/progressive'
|
|
10
|
+
import { XRayManager, xrayManager } from './observability/xray'
|
|
11
|
+
import { MetricsManager, metricsManager } from './observability/metrics'
|
|
12
|
+
import { LogsManager, logsManager } from './observability/logs'
|
|
13
|
+
|
|
14
|
+
describe('Static Site Manager', () => {
|
|
15
|
+
let manager: StaticSiteManager
|
|
16
|
+
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
manager = new StaticSiteManager()
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
it('should create asset optimization', () => {
|
|
22
|
+
const opt = manager.createAssetOptimization({
|
|
23
|
+
name: 'prod-assets',
|
|
24
|
+
minify: true,
|
|
25
|
+
compress: true,
|
|
26
|
+
compressionType: 'brotli',
|
|
27
|
+
sourceMaps: false,
|
|
28
|
+
cacheControl: 'max-age=31536000',
|
|
29
|
+
})
|
|
30
|
+
expect(opt.id).toContain('asset-opt')
|
|
31
|
+
expect(opt.compressionType).toBe('brotli')
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('should create image optimization', () => {
|
|
35
|
+
const opt = manager.createImageOptimization({
|
|
36
|
+
formats: ['webp', 'avif'],
|
|
37
|
+
quality: 80,
|
|
38
|
+
responsive: true,
|
|
39
|
+
lazy: true,
|
|
40
|
+
sizes: [320, 640, 1024],
|
|
41
|
+
})
|
|
42
|
+
expect(opt.formats).toContain('webp')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('should use global instance', () => {
|
|
46
|
+
expect(staticSiteManager).toBeInstanceOf(StaticSiteManager)
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
describe('S3 Advanced Manager', () => {
|
|
51
|
+
let manager: StorageAdvancedManager
|
|
52
|
+
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
manager = new StorageAdvancedManager()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should create lifecycle policy', () => {
|
|
58
|
+
const policy = manager.createLifecyclePolicy([
|
|
59
|
+
{ days: 30, storageClass: 'STANDARD_IA' },
|
|
60
|
+
{ days: 90, storageClass: 'GLACIER' },
|
|
61
|
+
], 365)
|
|
62
|
+
expect(policy.transitions).toHaveLength(2)
|
|
63
|
+
expect(policy.expiration).toBe(365)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('should enable versioning', () => {
|
|
67
|
+
const config = manager.enableVersioning(true)
|
|
68
|
+
expect(config.enabled).toBe(true)
|
|
69
|
+
expect(config.mfaDelete).toBe(true)
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
it('should create replication rule', () => {
|
|
73
|
+
const rule = manager.createReplicationRule('us-east-1', 'us-west-2', 'backup-bucket')
|
|
74
|
+
expect(rule.destRegion).toBe('us-west-2')
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('should enable object lock in compliance mode', () => {
|
|
78
|
+
const lock = manager.enableObjectLock({
|
|
79
|
+
bucketName: 'compliance-bucket',
|
|
80
|
+
mode: 'COMPLIANCE',
|
|
81
|
+
retentionDays: 90,
|
|
82
|
+
legalHoldEnabled: true,
|
|
83
|
+
})
|
|
84
|
+
expect(lock.mode).toBe('COMPLIANCE')
|
|
85
|
+
expect(lock.retentionDays).toBe(90)
|
|
86
|
+
expect(lock.legalHoldEnabled).toBe(true)
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('should enable object lock in governance mode', () => {
|
|
90
|
+
const lock = manager.enableObjectLock({
|
|
91
|
+
bucketName: 'governance-bucket',
|
|
92
|
+
mode: 'GOVERNANCE',
|
|
93
|
+
retentionYears: 7,
|
|
94
|
+
})
|
|
95
|
+
expect(lock.mode).toBe('GOVERNANCE')
|
|
96
|
+
expect(lock.retentionYears).toBe(7)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should enable transfer acceleration', () => {
|
|
100
|
+
const config = manager.enableTransferAcceleration('my-bucket')
|
|
101
|
+
expect(config.enabled).toBe(true)
|
|
102
|
+
expect(config.endpoint).toBe('my-bucket.s3-accelerate.amazonaws.com')
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
it('should create access point', () => {
|
|
106
|
+
const accessPoint = manager.createAccessPoint({
|
|
107
|
+
name: 'my-access-point',
|
|
108
|
+
bucketName: 'my-bucket',
|
|
109
|
+
publicAccessBlock: true,
|
|
110
|
+
})
|
|
111
|
+
expect(accessPoint.name).toBe('my-access-point')
|
|
112
|
+
expect(accessPoint.publicAccessBlock).toBe(true)
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('should create VPC access point', () => {
|
|
116
|
+
const accessPoint = manager.createAccessPoint({
|
|
117
|
+
name: 'vpc-access-point',
|
|
118
|
+
bucketName: 'my-bucket',
|
|
119
|
+
vpcId: 'vpc-12345',
|
|
120
|
+
publicAccessBlock: true,
|
|
121
|
+
})
|
|
122
|
+
expect(accessPoint.vpcId).toBe('vpc-12345')
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it('should create glacier deep archive configuration', () => {
|
|
126
|
+
const glacier = manager.createGlacierArchive({
|
|
127
|
+
bucketName: 'archive-bucket',
|
|
128
|
+
archiveType: 'DEEP_ARCHIVE',
|
|
129
|
+
transitionDays: 90,
|
|
130
|
+
restoreTier: 'Bulk',
|
|
131
|
+
restoreDays: 14,
|
|
132
|
+
})
|
|
133
|
+
expect(glacier.archiveType).toBe('DEEP_ARCHIVE')
|
|
134
|
+
expect(glacier.transitionDays).toBe(90)
|
|
135
|
+
expect(glacier.restoreConfig?.tier).toBe('Bulk')
|
|
136
|
+
expect(glacier.restoreConfig?.days).toBe(14)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
it('should create standard glacier configuration', () => {
|
|
140
|
+
const glacier = manager.createGlacierArchive({
|
|
141
|
+
bucketName: 'archive-bucket',
|
|
142
|
+
archiveType: 'GLACIER',
|
|
143
|
+
transitionDays: 30,
|
|
144
|
+
})
|
|
145
|
+
expect(glacier.archiveType).toBe('GLACIER')
|
|
146
|
+
expect(glacier.transitionDays).toBe(30)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('should create inventory configuration', () => {
|
|
150
|
+
const inventory = manager.createInventory({
|
|
151
|
+
sourceBucket: 'source-bucket',
|
|
152
|
+
destinationBucket: 'inventory-bucket',
|
|
153
|
+
schedule: 'Daily',
|
|
154
|
+
format: 'Parquet',
|
|
155
|
+
includedFields: ['Size', 'LastModifiedDate', 'StorageClass', 'ETag', 'ReplicationStatus'],
|
|
156
|
+
prefix: 'documents/',
|
|
157
|
+
})
|
|
158
|
+
expect(inventory.schedule).toBe('Daily')
|
|
159
|
+
expect(inventory.format).toBe('Parquet')
|
|
160
|
+
expect(inventory.includedFields).toContain('ReplicationStatus')
|
|
161
|
+
expect(inventory.prefix).toBe('documents/')
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
it('should create batch operation', () => {
|
|
165
|
+
const batchOp = manager.createBatchOperation({
|
|
166
|
+
operation: 'Copy',
|
|
167
|
+
manifestBucket: 'manifest-bucket',
|
|
168
|
+
manifestKey: 'manifest.csv',
|
|
169
|
+
priority: 5,
|
|
170
|
+
})
|
|
171
|
+
expect(batchOp.operation).toBe('Copy')
|
|
172
|
+
expect(batchOp.priority).toBe(5)
|
|
173
|
+
expect(batchOp.status).toBe('pending')
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
it('should execute batch operation', () => {
|
|
177
|
+
const batchOp = manager.createBatchOperation({
|
|
178
|
+
operation: 'Delete',
|
|
179
|
+
manifestBucket: 'manifest-bucket',
|
|
180
|
+
manifestKey: 'delete-list.csv',
|
|
181
|
+
})
|
|
182
|
+
const executed = manager.executeBatchOperation(batchOp.id)
|
|
183
|
+
expect(executed.status).toBe('in_progress')
|
|
184
|
+
expect(executed.totalObjects).toBeDefined()
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
it('should create Lambda event notification', () => {
|
|
188
|
+
const notification = manager.createLambdaNotification({
|
|
189
|
+
bucketName: 'event-bucket',
|
|
190
|
+
lambdaArn: 'arn:aws:lambda:us-east-1:123:function:processor',
|
|
191
|
+
events: ['s3:ObjectCreated:*'],
|
|
192
|
+
prefix: 'uploads/',
|
|
193
|
+
suffix: '.jpg',
|
|
194
|
+
})
|
|
195
|
+
expect(notification.destination.type).toBe('Lambda')
|
|
196
|
+
expect(notification.events).toContain('s3:ObjectCreated:*')
|
|
197
|
+
expect(notification.filter?.prefix).toBe('uploads/')
|
|
198
|
+
expect(notification.filter?.suffix).toBe('.jpg')
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
it('should create SQS event notification', () => {
|
|
202
|
+
const notification = manager.createSQSNotification({
|
|
203
|
+
bucketName: 'event-bucket',
|
|
204
|
+
queueArn: 'arn:aws:sqs:us-east-1:123:queue:events',
|
|
205
|
+
events: ['s3:ObjectRemoved:*'],
|
|
206
|
+
})
|
|
207
|
+
expect(notification.destination.type).toBe('SQS')
|
|
208
|
+
expect(notification.events).toContain('s3:ObjectRemoved:*')
|
|
209
|
+
})
|
|
210
|
+
|
|
211
|
+
it('should create SNS event notification', () => {
|
|
212
|
+
const notification = manager.createSNSNotification({
|
|
213
|
+
bucketName: 'event-bucket',
|
|
214
|
+
topicArn: 'arn:aws:sns:us-east-1:123:topic:s3-events',
|
|
215
|
+
events: ['s3:ObjectRestore:*', 's3:Replication:*'],
|
|
216
|
+
prefix: 'important/',
|
|
217
|
+
})
|
|
218
|
+
expect(notification.destination.type).toBe('SNS')
|
|
219
|
+
expect(notification.events).toHaveLength(2)
|
|
220
|
+
expect(notification.filter?.prefix).toBe('important/')
|
|
221
|
+
})
|
|
222
|
+
|
|
223
|
+
it('should generate CloudFormation for object lock', () => {
|
|
224
|
+
const lock = manager.enableObjectLock({
|
|
225
|
+
bucketName: 'compliance-bucket',
|
|
226
|
+
mode: 'COMPLIANCE',
|
|
227
|
+
retentionDays: 90,
|
|
228
|
+
})
|
|
229
|
+
const cf = manager.generateObjectLockCF(lock)
|
|
230
|
+
expect(cf.ObjectLockEnabled).toBe('Enabled')
|
|
231
|
+
expect(cf.ObjectLockConfiguration.Rule.DefaultRetention.Mode).toBe('COMPLIANCE')
|
|
232
|
+
expect(cf.ObjectLockConfiguration.Rule.DefaultRetention.Days).toBe(90)
|
|
233
|
+
})
|
|
234
|
+
|
|
235
|
+
it('should generate CloudFormation for access point', () => {
|
|
236
|
+
const accessPoint = manager.createAccessPoint({
|
|
237
|
+
name: 'my-access-point',
|
|
238
|
+
bucketName: 'my-bucket',
|
|
239
|
+
vpcId: 'vpc-12345',
|
|
240
|
+
})
|
|
241
|
+
const cf = manager.generateAccessPointCF(accessPoint)
|
|
242
|
+
expect(cf.Type).toBe('AWS::S3::AccessPoint')
|
|
243
|
+
expect(cf.Properties.Name).toBe('my-access-point')
|
|
244
|
+
expect(cf.Properties.VpcConfiguration.VpcId).toBe('vpc-12345')
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
it('should use global instance', () => {
|
|
248
|
+
expect(storageAdvancedManager).toBeInstanceOf(StorageAdvancedManager)
|
|
249
|
+
})
|
|
250
|
+
})
|
|
251
|
+
|
|
252
|
+
describe('Health Check Manager', () => {
|
|
253
|
+
let manager: HealthCheckManager
|
|
254
|
+
|
|
255
|
+
beforeEach(() => {
|
|
256
|
+
manager = new HealthCheckManager()
|
|
257
|
+
})
|
|
258
|
+
|
|
259
|
+
it('should create health check', () => {
|
|
260
|
+
const check = manager.createHealthCheck('https://example.com/health', 60, 5)
|
|
261
|
+
expect(check.url).toBe('https://example.com/health')
|
|
262
|
+
expect(check.interval).toBe(60)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('should create synthetic monitor', () => {
|
|
266
|
+
const monitor = manager.createSyntheticMonitor('API Test', 'script.js', 300, ['us-east-1', 'eu-west-1'])
|
|
267
|
+
expect(monitor.locations).toHaveLength(2)
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
it('should track uptime', () => {
|
|
271
|
+
const tracker = manager.trackUptime('api-server', 86000, 400)
|
|
272
|
+
expect(tracker.availability).toBeGreaterThan(99)
|
|
273
|
+
})
|
|
274
|
+
|
|
275
|
+
it('should use global instance', () => {
|
|
276
|
+
expect(healthCheckManager).toBeInstanceOf(HealthCheckManager)
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
describe('Network Security Manager', () => {
|
|
281
|
+
let manager: NetworkSecurityManager
|
|
282
|
+
|
|
283
|
+
beforeEach(() => {
|
|
284
|
+
manager = new NetworkSecurityManager()
|
|
285
|
+
})
|
|
286
|
+
|
|
287
|
+
it('should create WAF rule', () => {
|
|
288
|
+
const rule = manager.createWAFRule('block-sql-injection', 100, 'block', ['sql-injection'])
|
|
289
|
+
expect(rule.action).toBe('block')
|
|
290
|
+
expect(rule.priority).toBe(100)
|
|
291
|
+
})
|
|
292
|
+
|
|
293
|
+
it('should enable Shield', () => {
|
|
294
|
+
const protection = manager.enableShield('arn:aws:elasticloadbalancing:us-east-1:123:loadbalancer/app/my-lb', 'advanced')
|
|
295
|
+
expect(protection.protectionType).toBe('advanced')
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
it('should create security group', () => {
|
|
299
|
+
const sg = manager.createSecurityGroup('web-sg', 'vpc-123', [
|
|
300
|
+
{ protocol: 'tcp', port: 443, source: '0.0.0.0/0' },
|
|
301
|
+
])
|
|
302
|
+
expect(sg.rules).toHaveLength(1)
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('should use global instance', () => {
|
|
306
|
+
expect(networkSecurityManager).toBeInstanceOf(NetworkSecurityManager)
|
|
307
|
+
})
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
describe('Backup Advanced Manager', () => {
|
|
311
|
+
let manager: BackupManager
|
|
312
|
+
|
|
313
|
+
beforeEach(() => {
|
|
314
|
+
manager = new BackupManager()
|
|
315
|
+
})
|
|
316
|
+
|
|
317
|
+
it('should enable continuous backup', () => {
|
|
318
|
+
const backup = manager.enableContinuousBackup('db-instance-1', 30)
|
|
319
|
+
expect(backup.enabled).toBe(true)
|
|
320
|
+
expect(backup.retentionDays).toBe(30)
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
it('should enable PITR', () => {
|
|
324
|
+
const pitr = manager.enablePointInTimeRecovery('arn:aws:rds:us-east-1:123:db:table-1', 'rds')
|
|
325
|
+
expect(pitr.enabled).toBe(true)
|
|
326
|
+
expect(pitr.earliestRestorableTime).toBeDefined()
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
it('should create backup vault', () => {
|
|
330
|
+
const vault = { name: 'production-vault', region: 'us-east-1', encryptionKeyArn: 'arn:aws:kms:us-east-1:123:key/abc' }
|
|
331
|
+
manager.createVault(vault)
|
|
332
|
+
expect(manager.getVault('production-vault')?.name).toBe('production-vault')
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
it('should use global instance', () => {
|
|
336
|
+
expect(backupManager).toBeInstanceOf(BackupManager)
|
|
337
|
+
})
|
|
338
|
+
})
|
|
339
|
+
|
|
340
|
+
describe('Resource Management Manager', () => {
|
|
341
|
+
let manager: ResourceManagementManager
|
|
342
|
+
|
|
343
|
+
beforeEach(() => {
|
|
344
|
+
manager = new ResourceManagementManager()
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
it('should create tagging strategy', () => {
|
|
348
|
+
const strategy = manager.createTaggingStrategy(
|
|
349
|
+
{ Environment: 'production', Team: 'platform' },
|
|
350
|
+
['resource-1', 'resource-2']
|
|
351
|
+
)
|
|
352
|
+
expect(strategy.tags.Environment).toBe('production')
|
|
353
|
+
})
|
|
354
|
+
|
|
355
|
+
it('should create cost allocation', () => {
|
|
356
|
+
const allocation = manager.createCostAllocation('Environment', [
|
|
357
|
+
{ tagValue: 'production', cost: 5000 },
|
|
358
|
+
{ tagValue: 'staging', cost: 1000 },
|
|
359
|
+
])
|
|
360
|
+
expect(allocation.allocations).toHaveLength(2)
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
it('should create resource group', () => {
|
|
364
|
+
const group = manager.createResourceGroup('web-servers', ['AWS::EC2::Instance'], [
|
|
365
|
+
{ key: 'Environment', values: ['production'] },
|
|
366
|
+
])
|
|
367
|
+
expect(group.name).toBe('web-servers')
|
|
368
|
+
})
|
|
369
|
+
|
|
370
|
+
it('should use global instance', () => {
|
|
371
|
+
expect(resourceManagementManager).toBeInstanceOf(ResourceManagementManager)
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
describe('Deployment Advanced Manager', () => {
|
|
376
|
+
let manager: ProgressiveDeploymentManager
|
|
377
|
+
|
|
378
|
+
beforeEach(() => {
|
|
379
|
+
manager = new ProgressiveDeploymentManager()
|
|
380
|
+
})
|
|
381
|
+
|
|
382
|
+
it('should create progressive rollout', () => {
|
|
383
|
+
const rollout = manager.createProgressiveRollout('gradual-deploy', [
|
|
384
|
+
{ percentage: 10, durationMinutes: 10 },
|
|
385
|
+
{ percentage: 50, durationMinutes: 30 },
|
|
386
|
+
{ percentage: 100, durationMinutes: 60 },
|
|
387
|
+
])
|
|
388
|
+
expect(rollout.stages).toHaveLength(3)
|
|
389
|
+
expect(rollout.currentStage).toBe(0)
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
it('should create feature flag', () => {
|
|
393
|
+
const flag = manager.createFeatureFlag('new-ui', 25)
|
|
394
|
+
expect(flag.rolloutPercentage).toBe(25)
|
|
395
|
+
expect(flag.enabled).toBe(false)
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
it('should create deployment gate', () => {
|
|
399
|
+
const gate = manager.createDeploymentGate('production-approval', 'manual', ['admin@example.com'])
|
|
400
|
+
expect(gate.type).toBe('manual')
|
|
401
|
+
expect(gate.approvers).toContain('admin@example.com')
|
|
402
|
+
})
|
|
403
|
+
|
|
404
|
+
it('should use global instance', () => {
|
|
405
|
+
expect(progressiveDeploymentManager).toBeInstanceOf(ProgressiveDeploymentManager)
|
|
406
|
+
})
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
describe('Observability Advanced - Distributed Tracing', () => {
|
|
410
|
+
let manager: XRayManager
|
|
411
|
+
|
|
412
|
+
beforeEach(() => {
|
|
413
|
+
manager = new XRayManager()
|
|
414
|
+
})
|
|
415
|
+
|
|
416
|
+
it('should create distributed trace', () => {
|
|
417
|
+
const trace = manager.createTrace('trace-123', [
|
|
418
|
+
{ spanId: 'span-1', name: 'api-call', duration: 100, tags: { service: 'api' } },
|
|
419
|
+
{ spanId: 'span-2', name: 'db-query', duration: 50, tags: { service: 'db' } },
|
|
420
|
+
])
|
|
421
|
+
expect(trace.spans).toHaveLength(2)
|
|
422
|
+
})
|
|
423
|
+
|
|
424
|
+
it('should use global instance', () => {
|
|
425
|
+
expect(xrayManager).toBeInstanceOf(XRayManager)
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
describe('Observability Advanced - Custom Metrics', () => {
|
|
430
|
+
let manager: MetricsManager
|
|
431
|
+
|
|
432
|
+
beforeEach(() => {
|
|
433
|
+
manager = new MetricsManager()
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
it('should publish custom metric', () => {
|
|
437
|
+
const metric = manager.publishCustomMetric('MyApp', 'RequestCount', 100, { Environment: 'production' })
|
|
438
|
+
expect(metric.value).toBe(100)
|
|
439
|
+
expect(metric.namespace).toBe('MyApp')
|
|
440
|
+
})
|
|
441
|
+
|
|
442
|
+
it('should use global instance', () => {
|
|
443
|
+
expect(metricsManager).toBeInstanceOf(MetricsManager)
|
|
444
|
+
})
|
|
445
|
+
})
|
|
446
|
+
|
|
447
|
+
describe('Observability Advanced - Log Aggregation', () => {
|
|
448
|
+
let manager: LogsManager
|
|
449
|
+
|
|
450
|
+
beforeEach(() => {
|
|
451
|
+
manager = new LogsManager()
|
|
452
|
+
})
|
|
453
|
+
|
|
454
|
+
it('should create log aggregation', () => {
|
|
455
|
+
const aggregation = manager.createLogAggregation('/aws/lambda/my-function', [
|
|
456
|
+
{ pattern: 'ERROR', metric: 'ErrorCount' },
|
|
457
|
+
], 14)
|
|
458
|
+
expect(aggregation.filters).toHaveLength(1)
|
|
459
|
+
expect(aggregation.retention).toBe(14)
|
|
460
|
+
})
|
|
461
|
+
|
|
462
|
+
it('should use global instance', () => {
|
|
463
|
+
expect(logsManager).toBeInstanceOf(LogsManager)
|
|
464
|
+
})
|
|
465
|
+
})
|