@stacksjs/ts-cloud-core 0.1.2 → 0.1.6
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/README.md +98 -13
- package/package.json +12 -3
- package/src/advanced-features.test.ts +0 -465
- package/src/aws/cloudformation.ts +0 -421
- package/src/aws/cloudfront.ts +0 -158
- package/src/aws/credentials.test.ts +0 -132
- package/src/aws/credentials.ts +0 -545
- package/src/aws/index.ts +0 -87
- package/src/aws/s3.test.ts +0 -188
- package/src/aws/s3.ts +0 -1088
- package/src/aws/signature.test.ts +0 -670
- package/src/aws/signature.ts +0 -1155
- package/src/backup/disaster-recovery.test.ts +0 -726
- package/src/backup/disaster-recovery.ts +0 -500
- package/src/backup/index.ts +0 -34
- package/src/backup/manager.test.ts +0 -498
- package/src/backup/manager.ts +0 -432
- package/src/cicd/circleci.ts +0 -430
- package/src/cicd/github-actions.ts +0 -424
- package/src/cicd/gitlab-ci.ts +0 -255
- package/src/cicd/index.ts +0 -8
- package/src/cli/history.ts +0 -396
- package/src/cli/index.ts +0 -10
- package/src/cli/progress.ts +0 -458
- package/src/cli/repl.ts +0 -454
- package/src/cli/suggestions.ts +0 -327
- package/src/cli/table.test.ts +0 -319
- package/src/cli/table.ts +0 -332
- package/src/cloudformation/builder.test.ts +0 -327
- package/src/cloudformation/builder.ts +0 -378
- package/src/cloudformation/builders/api-gateway.ts +0 -449
- package/src/cloudformation/builders/cache.ts +0 -334
- package/src/cloudformation/builders/cdn.ts +0 -278
- package/src/cloudformation/builders/compute.ts +0 -485
- package/src/cloudformation/builders/database.ts +0 -392
- package/src/cloudformation/builders/functions.ts +0 -343
- package/src/cloudformation/builders/messaging.ts +0 -140
- package/src/cloudformation/builders/monitoring.ts +0 -300
- package/src/cloudformation/builders/network.ts +0 -264
- package/src/cloudformation/builders/queue.ts +0 -147
- package/src/cloudformation/builders/security.ts +0 -399
- package/src/cloudformation/builders/storage.ts +0 -285
- package/src/cloudformation/index.ts +0 -30
- package/src/cloudformation/types.ts +0 -173
- package/src/compliance/aws-config.ts +0 -543
- package/src/compliance/cloudtrail.ts +0 -376
- package/src/compliance/compliance.test.ts +0 -423
- package/src/compliance/guardduty.ts +0 -446
- package/src/compliance/index.ts +0 -66
- package/src/compliance/security-hub.ts +0 -456
- package/src/containers/build-optimization.ts +0 -416
- package/src/containers/containers.test.ts +0 -508
- package/src/containers/image-scanning.ts +0 -360
- package/src/containers/index.ts +0 -9
- package/src/containers/registry.ts +0 -293
- package/src/containers/service-mesh.ts +0 -520
- package/src/database/database.test.ts +0 -762
- package/src/database/index.ts +0 -9
- package/src/database/migrations.ts +0 -444
- package/src/database/performance.ts +0 -528
- package/src/database/replicas.ts +0 -534
- package/src/database/users.ts +0 -494
- package/src/dependency-graph.ts +0 -143
- package/src/deployment/ab-testing.ts +0 -582
- package/src/deployment/blue-green.ts +0 -452
- package/src/deployment/canary.ts +0 -500
- package/src/deployment/deployment.test.ts +0 -526
- package/src/deployment/index.ts +0 -61
- package/src/deployment/progressive.ts +0 -62
- package/src/dns/dns.test.ts +0 -641
- package/src/dns/dnssec.ts +0 -315
- package/src/dns/index.ts +0 -8
- package/src/dns/resolver.ts +0 -496
- package/src/dns/routing.ts +0 -593
- package/src/email/advanced/analytics.ts +0 -445
- package/src/email/advanced/index.ts +0 -11
- package/src/email/advanced/rules.ts +0 -465
- package/src/email/advanced/scheduling.ts +0 -352
- package/src/email/advanced/search.ts +0 -412
- package/src/email/advanced/shared-mailboxes.ts +0 -404
- package/src/email/advanced/templates.ts +0 -455
- package/src/email/advanced/threading.ts +0 -281
- package/src/email/analytics.ts +0 -467
- package/src/email/bounce-handling.ts +0 -425
- package/src/email/email.test.ts +0 -431
- package/src/email/handlers/__tests__/inbound.test.ts +0 -38
- package/src/email/handlers/__tests__/outbound.test.ts +0 -37
- package/src/email/handlers/converter.ts +0 -227
- package/src/email/handlers/feedback.ts +0 -228
- package/src/email/handlers/inbound.ts +0 -169
- package/src/email/handlers/outbound.ts +0 -178
- package/src/email/index.ts +0 -15
- package/src/email/reputation.ts +0 -303
- package/src/email/templates.ts +0 -352
- package/src/errors/index.test.ts +0 -434
- package/src/errors/index.ts +0 -416
- package/src/health-checks/index.ts +0 -40
- package/src/index.ts +0 -360
- package/src/intrinsic-functions.ts +0 -118
- package/src/lambda/concurrency.ts +0 -330
- package/src/lambda/destinations.ts +0 -345
- package/src/lambda/dlq.ts +0 -425
- package/src/lambda/index.ts +0 -11
- package/src/lambda/lambda.test.ts +0 -840
- package/src/lambda/layers.ts +0 -263
- package/src/lambda/versions.ts +0 -376
- package/src/lambda/vpc.ts +0 -399
- package/src/local/config.ts +0 -114
- package/src/local/index.ts +0 -6
- package/src/local/mock-aws.ts +0 -351
- package/src/modules/ai.ts +0 -340
- package/src/modules/api.ts +0 -478
- package/src/modules/auth.ts +0 -805
- package/src/modules/cache.ts +0 -417
- package/src/modules/cdn.ts +0 -1062
- package/src/modules/communication.ts +0 -1094
- package/src/modules/compute.ts +0 -3348
- package/src/modules/database.ts +0 -554
- package/src/modules/deployment.ts +0 -1079
- package/src/modules/dns.ts +0 -337
- package/src/modules/email.ts +0 -1538
- package/src/modules/filesystem.ts +0 -515
- package/src/modules/index.ts +0 -32
- package/src/modules/messaging.ts +0 -486
- package/src/modules/monitoring.ts +0 -2086
- package/src/modules/network.ts +0 -664
- package/src/modules/parameter-store.ts +0 -325
- package/src/modules/permissions.ts +0 -1081
- package/src/modules/phone.ts +0 -494
- package/src/modules/queue.ts +0 -1260
- package/src/modules/redirects.ts +0 -464
- package/src/modules/registry.ts +0 -699
- package/src/modules/search.ts +0 -401
- package/src/modules/secrets.ts +0 -416
- package/src/modules/security.ts +0 -731
- package/src/modules/sms.ts +0 -389
- package/src/modules/storage.ts +0 -1120
- package/src/modules/workflow.ts +0 -680
- package/src/multi-account/config.ts +0 -521
- package/src/multi-account/index.ts +0 -7
- package/src/multi-account/manager.ts +0 -427
- package/src/multi-region/cross-region.ts +0 -410
- package/src/multi-region/index.ts +0 -8
- package/src/multi-region/manager.ts +0 -483
- package/src/multi-region/regions.ts +0 -435
- package/src/network-security/index.ts +0 -48
- package/src/observability/index.ts +0 -9
- package/src/observability/logs.ts +0 -522
- package/src/observability/metrics.ts +0 -460
- package/src/observability/observability.test.ts +0 -782
- package/src/observability/synthetics.ts +0 -568
- package/src/observability/xray.ts +0 -358
- package/src/phone/advanced/analytics.ts +0 -349
- package/src/phone/advanced/callbacks.ts +0 -428
- package/src/phone/advanced/index.ts +0 -8
- package/src/phone/advanced/ivr-builder.ts +0 -504
- package/src/phone/advanced/recording.ts +0 -310
- package/src/phone/handlers/__tests__/incoming-call.test.ts +0 -40
- package/src/phone/handlers/incoming-call.ts +0 -117
- package/src/phone/handlers/missed-call.ts +0 -116
- package/src/phone/handlers/voicemail.ts +0 -179
- package/src/phone/index.ts +0 -9
- package/src/presets/api-backend.ts +0 -134
- package/src/presets/data-pipeline.ts +0 -204
- package/src/presets/extend.test.ts +0 -295
- package/src/presets/extend.ts +0 -297
- package/src/presets/fullstack-app.ts +0 -144
- package/src/presets/index.ts +0 -27
- package/src/presets/jamstack.ts +0 -135
- package/src/presets/microservices.ts +0 -167
- package/src/presets/ml-api.ts +0 -208
- package/src/presets/nodejs-server.ts +0 -104
- package/src/presets/nodejs-serverless.ts +0 -114
- package/src/presets/realtime-app.ts +0 -184
- package/src/presets/static-site.ts +0 -64
- package/src/presets/traditional-web-app.ts +0 -339
- package/src/presets/wordpress.ts +0 -138
- package/src/preview/github.test.ts +0 -249
- package/src/preview/github.ts +0 -297
- package/src/preview/index.ts +0 -37
- package/src/preview/manager.test.ts +0 -440
- package/src/preview/manager.ts +0 -326
- package/src/preview/notifications.test.ts +0 -582
- package/src/preview/notifications.ts +0 -341
- package/src/queue/batch-processing.ts +0 -402
- package/src/queue/dlq-monitoring.ts +0 -402
- package/src/queue/fifo.ts +0 -342
- package/src/queue/index.ts +0 -9
- package/src/queue/management.ts +0 -428
- package/src/queue/queue.test.ts +0 -429
- package/src/resource-mgmt/index.ts +0 -39
- package/src/resource-naming.ts +0 -62
- package/src/s3/index.ts +0 -523
- package/src/schema/cloud-config.schema.json +0 -554
- package/src/schema/index.ts +0 -68
- package/src/security/certificate-manager.ts +0 -492
- package/src/security/index.ts +0 -9
- package/src/security/scanning.ts +0 -545
- package/src/security/secrets-manager.ts +0 -476
- package/src/security/secrets-rotation.ts +0 -456
- package/src/security/security.test.ts +0 -738
- package/src/sms/advanced/ab-testing.ts +0 -389
- package/src/sms/advanced/analytics.ts +0 -336
- package/src/sms/advanced/campaigns.ts +0 -523
- package/src/sms/advanced/chatbot.ts +0 -224
- package/src/sms/advanced/index.ts +0 -10
- package/src/sms/advanced/link-tracking.ts +0 -248
- package/src/sms/advanced/mms.ts +0 -308
- package/src/sms/handlers/__tests__/send.test.ts +0 -40
- package/src/sms/handlers/delivery-status.ts +0 -133
- package/src/sms/handlers/receive.ts +0 -162
- package/src/sms/handlers/send.ts +0 -174
- package/src/sms/index.ts +0 -9
- package/src/stack-diff.ts +0 -389
- package/src/static-site/index.ts +0 -85
- package/src/template-builder.ts +0 -110
- package/src/template-validator.ts +0 -574
- package/src/utils/cache.ts +0 -291
- package/src/utils/diff.ts +0 -269
- package/src/utils/hash.ts +0 -227
- package/src/utils/index.ts +0 -8
- package/src/utils/parallel.ts +0 -294
- package/src/validators/credentials.test.ts +0 -274
- package/src/validators/credentials.ts +0 -233
- package/src/validators/quotas.test.ts +0 -434
- package/src/validators/quotas.ts +0 -217
- package/test/ai.test.ts +0 -327
- package/test/api.test.ts +0 -511
- package/test/auth.test.ts +0 -632
- package/test/cache.test.ts +0 -406
- package/test/cdn.test.ts +0 -247
- package/test/compute.test.ts +0 -861
- package/test/database.test.ts +0 -523
- package/test/deployment.test.ts +0 -499
- package/test/dns.test.ts +0 -270
- package/test/email.test.ts +0 -439
- package/test/filesystem.test.ts +0 -382
- package/test/integration.test.ts +0 -350
- package/test/messaging.test.ts +0 -514
- package/test/monitoring.test.ts +0 -634
- package/test/network.test.ts +0 -425
- package/test/permissions.test.ts +0 -488
- package/test/queue.test.ts +0 -484
- package/test/registry.test.ts +0 -306
- package/test/security.test.ts +0 -462
- package/test/storage.test.ts +0 -463
- package/test/template-validator.test.ts +0 -559
- package/test/workflow.test.ts +0 -592
- package/tsconfig.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
<!-- [![npm downloads][npm-downloads-src]][npm-downloads-href] -->
|
|
7
7
|
<!-- [![Codecov][codecov-src]][codecov-href] -->
|
|
8
8
|
|
|
9
|
-
# ts-cloud
|
|
9
|
+
# @stacksjs/ts-cloud
|
|
10
10
|
|
|
11
11
|
> Zero-dependency AWS infrastructure as TypeScript. Deploy production-ready cloud infrastructure without AWS SDK or CLI.
|
|
12
12
|
|
|
13
13
|
## Overview
|
|
14
14
|
|
|
15
|
-
ts-cloud is a modern infrastructure-as-code framework that lets you define AWS infrastructure using TypeScript configuration files. Unlike AWS CDK or Terraform, ts-cloud:
|
|
15
|
+
@stacksjs/ts-cloud is a modern infrastructure-as-code framework that lets you define AWS infrastructure using TypeScript configuration files. Unlike AWS CDK or Terraform, @stacksjs/ts-cloud:
|
|
16
16
|
|
|
17
17
|
- **Zero AWS Dependencies** - No AWS SDK, no AWS CLI. Direct AWS API calls only.
|
|
18
18
|
- **Type-Safe Configuration** - Full TypeScript types for all AWS resources
|
|
@@ -55,6 +55,23 @@ Complete CloudFormation template builders for:
|
|
|
55
55
|
- **Monitoring** - CloudWatch dashboards, alarms, and log groups
|
|
56
56
|
- **Security** - ACM certificates, WAF rules, security groups
|
|
57
57
|
|
|
58
|
+
### 🔒 Pre-Deployment Security Scanning
|
|
59
|
+
|
|
60
|
+
Built-in secret detection to prevent accidental credential exposure:
|
|
61
|
+
|
|
62
|
+
- **35+ Secret Patterns** - AWS keys, API tokens, private keys, database credentials
|
|
63
|
+
- **Automatic Scanning** - Runs before every deployment
|
|
64
|
+
- **Configurable Severity** - Block on critical, high, medium, or low findings
|
|
65
|
+
- **CI/CD Ready** - Integrate security checks into your pipeline
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Scan for secrets before deploying
|
|
69
|
+
cloud deploy:security-scan --source ./dist
|
|
70
|
+
|
|
71
|
+
# Deploy with automatic security scanning
|
|
72
|
+
cloud deploy # Scans automatically before deployment
|
|
73
|
+
```
|
|
74
|
+
|
|
58
75
|
### ☁️ Direct AWS Integration
|
|
59
76
|
|
|
60
77
|
No SDK, no CLI - pure AWS Signature V4 API calls:
|
|
@@ -69,7 +86,7 @@ No SDK, no CLI - pure AWS Signature V4 API calls:
|
|
|
69
86
|
### Installation
|
|
70
87
|
|
|
71
88
|
```bash
|
|
72
|
-
bun add ts-cloud
|
|
89
|
+
bun add @stacksjs/ts-cloud
|
|
73
90
|
```
|
|
74
91
|
|
|
75
92
|
### Your First Deployment
|
|
@@ -77,7 +94,7 @@ bun add ts-cloud
|
|
|
77
94
|
Create a `cloud.config.ts`:
|
|
78
95
|
|
|
79
96
|
```typescript
|
|
80
|
-
import { createStaticSitePreset } from 'ts-cloud/presets'
|
|
97
|
+
import { createStaticSitePreset } from '@stacksjs/ts-cloud/presets'
|
|
81
98
|
|
|
82
99
|
export default createStaticSitePreset({
|
|
83
100
|
name: 'My Website',
|
|
@@ -104,7 +121,7 @@ That's it! You now have:
|
|
|
104
121
|
#### Full-Stack Application
|
|
105
122
|
|
|
106
123
|
```typescript
|
|
107
|
-
import { createFullStackAppPreset } from 'ts-cloud/presets'
|
|
124
|
+
import { createFullStackAppPreset } from '@stacksjs/ts-cloud/presets'
|
|
108
125
|
|
|
109
126
|
export default createFullStackAppPreset({
|
|
110
127
|
name: 'My App',
|
|
@@ -125,7 +142,7 @@ Includes:
|
|
|
125
142
|
#### Serverless API
|
|
126
143
|
|
|
127
144
|
```typescript
|
|
128
|
-
import { createApiBackendPreset } from 'ts-cloud/presets'
|
|
145
|
+
import { createApiBackendPreset } from '@stacksjs/ts-cloud/presets'
|
|
129
146
|
|
|
130
147
|
export default createApiBackendPreset({
|
|
131
148
|
name: 'My API',
|
|
@@ -148,7 +165,7 @@ Includes:
|
|
|
148
165
|
You can extend any preset with custom configuration:
|
|
149
166
|
|
|
150
167
|
```typescript
|
|
151
|
-
import { createNodeJsServerPreset, extendPreset } from 'ts-cloud/presets'
|
|
168
|
+
import { createNodeJsServerPreset, extendPreset } from '@stacksjs/ts-cloud/presets'
|
|
152
169
|
|
|
153
170
|
export default extendPreset(
|
|
154
171
|
createNodeJsServerPreset({
|
|
@@ -175,7 +192,7 @@ export default extendPreset(
|
|
|
175
192
|
Combine multiple presets:
|
|
176
193
|
|
|
177
194
|
```typescript
|
|
178
|
-
import { composePresets, createStaticSitePreset, createApiBackendPreset } from 'ts-cloud/presets'
|
|
195
|
+
import { composePresets, createStaticSitePreset, createApiBackendPreset } from '@stacksjs/ts-cloud/presets'
|
|
179
196
|
|
|
180
197
|
export default composePresets(
|
|
181
198
|
createStaticSitePreset({ name: 'Frontend', slug: 'frontend', domain: 'example.com' }),
|
|
@@ -198,7 +215,7 @@ export default composePresets(
|
|
|
198
215
|
Generate templates programmatically:
|
|
199
216
|
|
|
200
217
|
```typescript
|
|
201
|
-
import { CloudFormationBuilder } from 'ts-cloud/cloudformation'
|
|
218
|
+
import { CloudFormationBuilder } from '@stacksjs/ts-cloud/cloudformation'
|
|
202
219
|
|
|
203
220
|
const builder = new CloudFormationBuilder(config)
|
|
204
221
|
const template = builder.build()
|
|
@@ -211,7 +228,7 @@ console.log(JSON.stringify(template, null, 2))
|
|
|
211
228
|
Use the AWS clients directly:
|
|
212
229
|
|
|
213
230
|
```typescript
|
|
214
|
-
import { CloudFormationClient, S3Client, CloudFrontClient } from 'ts-cloud/aws'
|
|
231
|
+
import { CloudFormationClient, S3Client, CloudFrontClient } from '@stacksjs/ts-cloud/aws'
|
|
215
232
|
|
|
216
233
|
// CloudFormation
|
|
217
234
|
const cfn = new CloudFormationClient('us-east-1')
|
|
@@ -236,6 +253,74 @@ await cloudfront.createInvalidation({
|
|
|
236
253
|
})
|
|
237
254
|
```
|
|
238
255
|
|
|
256
|
+
## DNS Providers
|
|
257
|
+
|
|
258
|
+
@stacksjs/ts-cloud supports multiple DNS providers for domain management and SSL certificate validation:
|
|
259
|
+
|
|
260
|
+
### Cloudflare
|
|
261
|
+
|
|
262
|
+
1. Log in to your [Cloudflare Dashboard](https://dash.cloudflare.com/)
|
|
263
|
+
2. Go to **My Profile** → **API Tokens** (or visit https://dash.cloudflare.com/profile/api-tokens)
|
|
264
|
+
3. Click **Create Token**
|
|
265
|
+
4. Use the **Edit zone DNS** template, or create a custom token with:
|
|
266
|
+
- **Permissions**: Zone → DNS → Edit
|
|
267
|
+
- **Zone Resources**: Include → All zones (or specific zones)
|
|
268
|
+
5. Copy the generated token
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
export CLOUDFLARE_API_TOKEN="your-api-token-here"
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Porkbun
|
|
275
|
+
|
|
276
|
+
1. Log in to your [Porkbun Dashboard](https://porkbun.com/account/api)
|
|
277
|
+
2. Enable API access for your domain(s)
|
|
278
|
+
3. Generate an API key pair
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
export PORKBUN_API_KEY="your-api-key"
|
|
282
|
+
export PORKBUN_SECRET_KEY="your-secret-key"
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### GoDaddy
|
|
286
|
+
|
|
287
|
+
1. Log in to [GoDaddy Developer Portal](https://developer.godaddy.com/)
|
|
288
|
+
2. Create a new API key
|
|
289
|
+
3. Note both the key and secret
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
export GODADDY_API_KEY="your-api-key"
|
|
293
|
+
export GODADDY_API_SECRET="your-api-secret"
|
|
294
|
+
export GODADDY_ENVIRONMENT="production" # or "ote" for testing
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
### Route53
|
|
298
|
+
|
|
299
|
+
Uses AWS credentials from environment or ~/.aws/credentials:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
export AWS_ACCESS_KEY_ID="your-access-key"
|
|
303
|
+
export AWS_SECRET_ACCESS_KEY="your-secret-key"
|
|
304
|
+
export AWS_REGION="us-east-1"
|
|
305
|
+
export AWS_HOSTED_ZONE_ID="Z1234567890" # Optional
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### CLI Usage
|
|
309
|
+
|
|
310
|
+
```bash
|
|
311
|
+
# List domains
|
|
312
|
+
cloud domain:list --provider cloudflare
|
|
313
|
+
|
|
314
|
+
# List DNS records
|
|
315
|
+
cloud dns:records example.com --provider cloudflare
|
|
316
|
+
|
|
317
|
+
# Add a DNS record
|
|
318
|
+
cloud dns:add example.com A 192.168.1.1 --name api --provider cloudflare
|
|
319
|
+
|
|
320
|
+
# Generate SSL certificate with DNS validation
|
|
321
|
+
cloud domain:ssl example.com --provider cloudflare
|
|
322
|
+
```
|
|
323
|
+
|
|
239
324
|
## Development
|
|
240
325
|
|
|
241
326
|
```bash
|
|
@@ -264,7 +349,7 @@ bun run typecheck
|
|
|
264
349
|
|
|
265
350
|
### No Dependencies
|
|
266
351
|
|
|
267
|
-
ts-cloud uses **zero external dependencies** for AWS operations:
|
|
352
|
+
@stacksjs/ts-cloud uses **zero external dependencies** for AWS operations:
|
|
268
353
|
|
|
269
354
|
- **AWS Signature V4** - Manual request signing for authentication
|
|
270
355
|
- **Direct HTTPS** - Native `fetch()` for API calls
|
|
@@ -312,8 +397,8 @@ The MIT License (MIT). Please see [LICENSE](LICENSE.md) for more information.
|
|
|
312
397
|
Made with 💙
|
|
313
398
|
|
|
314
399
|
<!-- Badges -->
|
|
315
|
-
[npm-version-src]: https://img.shields.io/npm/v/ts-cloud?style=flat-square
|
|
316
|
-
[npm-version-href]: https://npmjs.com/package/ts-cloud
|
|
400
|
+
[npm-version-src]: https://img.shields.io/npm/v/@stacksjs/ts-cloud?style=flat-square
|
|
401
|
+
[npm-version-href]: https://npmjs.com/package/@stacksjs/ts-cloud
|
|
317
402
|
[github-actions-src]: https://img.shields.io/github/actions/workflow/status/stacksjs/ts-cloud/ci.yml?style=flat-square&branch=main
|
|
318
403
|
[github-actions-href]: https://github.com/stacksjs/ts-cloud/actions?query=workflow%3Aci
|
|
319
404
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/ts-cloud-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core CloudFormation generation library for ts-cloud",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/stacksjs/ts-cloud#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/stacksjs/ts-cloud.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/stacksjs/ts-cloud/issues"
|
|
15
|
+
},
|
|
8
16
|
"exports": {
|
|
9
17
|
".": {
|
|
10
18
|
"types": "./dist/index.d.ts",
|
|
@@ -19,11 +27,12 @@
|
|
|
19
27
|
],
|
|
20
28
|
"scripts": {
|
|
21
29
|
"build": "bun build src/index.ts --outdir dist --target bun",
|
|
30
|
+
"prepublishOnly": "bun --bun run build",
|
|
22
31
|
"typecheck": "tsc --noEmit"
|
|
23
32
|
},
|
|
24
33
|
"dependencies": {
|
|
25
|
-
"@stacksjs/ts-cloud-types": "
|
|
26
|
-
"@stacksjs/ts-cloud-aws-types": "
|
|
34
|
+
"@stacksjs/ts-cloud-types": "0.1.6",
|
|
35
|
+
"@stacksjs/ts-cloud-aws-types": "0.1.6"
|
|
27
36
|
},
|
|
28
37
|
"devDependencies": {
|
|
29
38
|
"typescript": "^5.9.3"
|
|
@@ -1,465 +0,0 @@
|
|
|
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
|
-
})
|