@stacksjs/ts-cloud-core 0.1.3 → 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.
Files changed (250) hide show
  1. package/README.md +98 -13
  2. package/package.json +12 -3
  3. package/src/advanced-features.test.ts +0 -465
  4. package/src/aws/cloudformation.ts +0 -421
  5. package/src/aws/cloudfront.ts +0 -158
  6. package/src/aws/credentials.test.ts +0 -132
  7. package/src/aws/credentials.ts +0 -545
  8. package/src/aws/index.ts +0 -87
  9. package/src/aws/s3.test.ts +0 -188
  10. package/src/aws/s3.ts +0 -1088
  11. package/src/aws/signature.test.ts +0 -670
  12. package/src/aws/signature.ts +0 -1155
  13. package/src/backup/disaster-recovery.test.ts +0 -726
  14. package/src/backup/disaster-recovery.ts +0 -500
  15. package/src/backup/index.ts +0 -34
  16. package/src/backup/manager.test.ts +0 -498
  17. package/src/backup/manager.ts +0 -432
  18. package/src/cicd/circleci.ts +0 -430
  19. package/src/cicd/github-actions.ts +0 -424
  20. package/src/cicd/gitlab-ci.ts +0 -255
  21. package/src/cicd/index.ts +0 -8
  22. package/src/cli/history.ts +0 -396
  23. package/src/cli/index.ts +0 -10
  24. package/src/cli/progress.ts +0 -458
  25. package/src/cli/repl.ts +0 -454
  26. package/src/cli/suggestions.ts +0 -327
  27. package/src/cli/table.test.ts +0 -319
  28. package/src/cli/table.ts +0 -332
  29. package/src/cloudformation/builder.test.ts +0 -327
  30. package/src/cloudformation/builder.ts +0 -378
  31. package/src/cloudformation/builders/api-gateway.ts +0 -449
  32. package/src/cloudformation/builders/cache.ts +0 -334
  33. package/src/cloudformation/builders/cdn.ts +0 -278
  34. package/src/cloudformation/builders/compute.ts +0 -485
  35. package/src/cloudformation/builders/database.ts +0 -392
  36. package/src/cloudformation/builders/functions.ts +0 -343
  37. package/src/cloudformation/builders/messaging.ts +0 -140
  38. package/src/cloudformation/builders/monitoring.ts +0 -300
  39. package/src/cloudformation/builders/network.ts +0 -264
  40. package/src/cloudformation/builders/queue.ts +0 -147
  41. package/src/cloudformation/builders/security.ts +0 -399
  42. package/src/cloudformation/builders/storage.ts +0 -285
  43. package/src/cloudformation/index.ts +0 -30
  44. package/src/cloudformation/types.ts +0 -173
  45. package/src/compliance/aws-config.ts +0 -543
  46. package/src/compliance/cloudtrail.ts +0 -376
  47. package/src/compliance/compliance.test.ts +0 -423
  48. package/src/compliance/guardduty.ts +0 -446
  49. package/src/compliance/index.ts +0 -66
  50. package/src/compliance/security-hub.ts +0 -456
  51. package/src/containers/build-optimization.ts +0 -416
  52. package/src/containers/containers.test.ts +0 -508
  53. package/src/containers/image-scanning.ts +0 -360
  54. package/src/containers/index.ts +0 -9
  55. package/src/containers/registry.ts +0 -293
  56. package/src/containers/service-mesh.ts +0 -520
  57. package/src/database/database.test.ts +0 -762
  58. package/src/database/index.ts +0 -9
  59. package/src/database/migrations.ts +0 -444
  60. package/src/database/performance.ts +0 -528
  61. package/src/database/replicas.ts +0 -534
  62. package/src/database/users.ts +0 -494
  63. package/src/dependency-graph.ts +0 -143
  64. package/src/deployment/ab-testing.ts +0 -582
  65. package/src/deployment/blue-green.ts +0 -452
  66. package/src/deployment/canary.ts +0 -500
  67. package/src/deployment/deployment.test.ts +0 -526
  68. package/src/deployment/index.ts +0 -61
  69. package/src/deployment/progressive.ts +0 -62
  70. package/src/dns/dns.test.ts +0 -641
  71. package/src/dns/dnssec.ts +0 -315
  72. package/src/dns/index.ts +0 -8
  73. package/src/dns/resolver.ts +0 -496
  74. package/src/dns/routing.ts +0 -593
  75. package/src/email/advanced/analytics.ts +0 -445
  76. package/src/email/advanced/index.ts +0 -11
  77. package/src/email/advanced/rules.ts +0 -465
  78. package/src/email/advanced/scheduling.ts +0 -352
  79. package/src/email/advanced/search.ts +0 -412
  80. package/src/email/advanced/shared-mailboxes.ts +0 -404
  81. package/src/email/advanced/templates.ts +0 -455
  82. package/src/email/advanced/threading.ts +0 -281
  83. package/src/email/analytics.ts +0 -467
  84. package/src/email/bounce-handling.ts +0 -425
  85. package/src/email/email.test.ts +0 -431
  86. package/src/email/handlers/__tests__/inbound.test.ts +0 -38
  87. package/src/email/handlers/__tests__/outbound.test.ts +0 -37
  88. package/src/email/handlers/converter.ts +0 -227
  89. package/src/email/handlers/feedback.ts +0 -228
  90. package/src/email/handlers/inbound.ts +0 -169
  91. package/src/email/handlers/outbound.ts +0 -178
  92. package/src/email/index.ts +0 -15
  93. package/src/email/reputation.ts +0 -303
  94. package/src/email/templates.ts +0 -352
  95. package/src/errors/index.test.ts +0 -434
  96. package/src/errors/index.ts +0 -416
  97. package/src/health-checks/index.ts +0 -40
  98. package/src/index.ts +0 -360
  99. package/src/intrinsic-functions.ts +0 -118
  100. package/src/lambda/concurrency.ts +0 -330
  101. package/src/lambda/destinations.ts +0 -345
  102. package/src/lambda/dlq.ts +0 -425
  103. package/src/lambda/index.ts +0 -11
  104. package/src/lambda/lambda.test.ts +0 -840
  105. package/src/lambda/layers.ts +0 -263
  106. package/src/lambda/versions.ts +0 -376
  107. package/src/lambda/vpc.ts +0 -399
  108. package/src/local/config.ts +0 -114
  109. package/src/local/index.ts +0 -6
  110. package/src/local/mock-aws.ts +0 -351
  111. package/src/modules/ai.ts +0 -340
  112. package/src/modules/api.ts +0 -478
  113. package/src/modules/auth.ts +0 -805
  114. package/src/modules/cache.ts +0 -417
  115. package/src/modules/cdn.ts +0 -1062
  116. package/src/modules/communication.ts +0 -1094
  117. package/src/modules/compute.ts +0 -3348
  118. package/src/modules/database.ts +0 -554
  119. package/src/modules/deployment.ts +0 -1079
  120. package/src/modules/dns.ts +0 -337
  121. package/src/modules/email.ts +0 -1538
  122. package/src/modules/filesystem.ts +0 -515
  123. package/src/modules/index.ts +0 -32
  124. package/src/modules/messaging.ts +0 -486
  125. package/src/modules/monitoring.ts +0 -2086
  126. package/src/modules/network.ts +0 -664
  127. package/src/modules/parameter-store.ts +0 -325
  128. package/src/modules/permissions.ts +0 -1081
  129. package/src/modules/phone.ts +0 -494
  130. package/src/modules/queue.ts +0 -1260
  131. package/src/modules/redirects.ts +0 -464
  132. package/src/modules/registry.ts +0 -699
  133. package/src/modules/search.ts +0 -401
  134. package/src/modules/secrets.ts +0 -416
  135. package/src/modules/security.ts +0 -731
  136. package/src/modules/sms.ts +0 -389
  137. package/src/modules/storage.ts +0 -1120
  138. package/src/modules/workflow.ts +0 -680
  139. package/src/multi-account/config.ts +0 -521
  140. package/src/multi-account/index.ts +0 -7
  141. package/src/multi-account/manager.ts +0 -427
  142. package/src/multi-region/cross-region.ts +0 -410
  143. package/src/multi-region/index.ts +0 -8
  144. package/src/multi-region/manager.ts +0 -483
  145. package/src/multi-region/regions.ts +0 -435
  146. package/src/network-security/index.ts +0 -48
  147. package/src/observability/index.ts +0 -9
  148. package/src/observability/logs.ts +0 -522
  149. package/src/observability/metrics.ts +0 -460
  150. package/src/observability/observability.test.ts +0 -782
  151. package/src/observability/synthetics.ts +0 -568
  152. package/src/observability/xray.ts +0 -358
  153. package/src/phone/advanced/analytics.ts +0 -349
  154. package/src/phone/advanced/callbacks.ts +0 -428
  155. package/src/phone/advanced/index.ts +0 -8
  156. package/src/phone/advanced/ivr-builder.ts +0 -504
  157. package/src/phone/advanced/recording.ts +0 -310
  158. package/src/phone/handlers/__tests__/incoming-call.test.ts +0 -40
  159. package/src/phone/handlers/incoming-call.ts +0 -117
  160. package/src/phone/handlers/missed-call.ts +0 -116
  161. package/src/phone/handlers/voicemail.ts +0 -179
  162. package/src/phone/index.ts +0 -9
  163. package/src/presets/api-backend.ts +0 -134
  164. package/src/presets/data-pipeline.ts +0 -204
  165. package/src/presets/extend.test.ts +0 -295
  166. package/src/presets/extend.ts +0 -297
  167. package/src/presets/fullstack-app.ts +0 -144
  168. package/src/presets/index.ts +0 -27
  169. package/src/presets/jamstack.ts +0 -135
  170. package/src/presets/microservices.ts +0 -167
  171. package/src/presets/ml-api.ts +0 -208
  172. package/src/presets/nodejs-server.ts +0 -104
  173. package/src/presets/nodejs-serverless.ts +0 -114
  174. package/src/presets/realtime-app.ts +0 -184
  175. package/src/presets/static-site.ts +0 -64
  176. package/src/presets/traditional-web-app.ts +0 -339
  177. package/src/presets/wordpress.ts +0 -138
  178. package/src/preview/github.test.ts +0 -249
  179. package/src/preview/github.ts +0 -297
  180. package/src/preview/index.ts +0 -37
  181. package/src/preview/manager.test.ts +0 -440
  182. package/src/preview/manager.ts +0 -326
  183. package/src/preview/notifications.test.ts +0 -582
  184. package/src/preview/notifications.ts +0 -341
  185. package/src/queue/batch-processing.ts +0 -402
  186. package/src/queue/dlq-monitoring.ts +0 -402
  187. package/src/queue/fifo.ts +0 -342
  188. package/src/queue/index.ts +0 -9
  189. package/src/queue/management.ts +0 -428
  190. package/src/queue/queue.test.ts +0 -429
  191. package/src/resource-mgmt/index.ts +0 -39
  192. package/src/resource-naming.ts +0 -62
  193. package/src/s3/index.ts +0 -523
  194. package/src/schema/cloud-config.schema.json +0 -554
  195. package/src/schema/index.ts +0 -68
  196. package/src/security/certificate-manager.ts +0 -492
  197. package/src/security/index.ts +0 -9
  198. package/src/security/scanning.ts +0 -545
  199. package/src/security/secrets-manager.ts +0 -476
  200. package/src/security/secrets-rotation.ts +0 -456
  201. package/src/security/security.test.ts +0 -738
  202. package/src/sms/advanced/ab-testing.ts +0 -389
  203. package/src/sms/advanced/analytics.ts +0 -336
  204. package/src/sms/advanced/campaigns.ts +0 -523
  205. package/src/sms/advanced/chatbot.ts +0 -224
  206. package/src/sms/advanced/index.ts +0 -10
  207. package/src/sms/advanced/link-tracking.ts +0 -248
  208. package/src/sms/advanced/mms.ts +0 -308
  209. package/src/sms/handlers/__tests__/send.test.ts +0 -40
  210. package/src/sms/handlers/delivery-status.ts +0 -133
  211. package/src/sms/handlers/receive.ts +0 -162
  212. package/src/sms/handlers/send.ts +0 -174
  213. package/src/sms/index.ts +0 -9
  214. package/src/stack-diff.ts +0 -389
  215. package/src/static-site/index.ts +0 -85
  216. package/src/template-builder.ts +0 -110
  217. package/src/template-validator.ts +0 -574
  218. package/src/utils/cache.ts +0 -291
  219. package/src/utils/diff.ts +0 -269
  220. package/src/utils/hash.ts +0 -227
  221. package/src/utils/index.ts +0 -8
  222. package/src/utils/parallel.ts +0 -294
  223. package/src/validators/credentials.test.ts +0 -274
  224. package/src/validators/credentials.ts +0 -233
  225. package/src/validators/quotas.test.ts +0 -434
  226. package/src/validators/quotas.ts +0 -217
  227. package/test/ai.test.ts +0 -327
  228. package/test/api.test.ts +0 -511
  229. package/test/auth.test.ts +0 -632
  230. package/test/cache.test.ts +0 -406
  231. package/test/cdn.test.ts +0 -247
  232. package/test/compute.test.ts +0 -861
  233. package/test/database.test.ts +0 -523
  234. package/test/deployment.test.ts +0 -499
  235. package/test/dns.test.ts +0 -270
  236. package/test/email.test.ts +0 -439
  237. package/test/filesystem.test.ts +0 -382
  238. package/test/integration.test.ts +0 -350
  239. package/test/messaging.test.ts +0 -514
  240. package/test/monitoring.test.ts +0 -634
  241. package/test/network.test.ts +0 -425
  242. package/test/permissions.test.ts +0 -488
  243. package/test/queue.test.ts +0 -484
  244. package/test/registry.test.ts +0 -306
  245. package/test/security.test.ts +0 -462
  246. package/test/storage.test.ts +0 -463
  247. package/test/template-validator.test.ts +0 -559
  248. package/test/workflow.test.ts +0 -592
  249. package/tsconfig.json +0 -16
  250. 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",
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": "workspace:*",
26
- "@stacksjs/ts-cloud-aws-types": "workspace:*"
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
- })