@ts-cloud/core 0.2.3 → 0.2.5

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 (226) hide show
  1. package/dist/advanced-features.test.d.ts +1 -0
  2. package/dist/aws/cloudformation.d.ts +136 -0
  3. package/dist/aws/cloudfront.d.ts +45 -0
  4. package/dist/aws/credentials.d.ts +77 -0
  5. package/dist/aws/credentials.test.d.ts +4 -0
  6. package/dist/aws/index.d.ts +10 -0
  7. package/dist/aws/s3.d.ts +256 -0
  8. package/dist/aws/s3.test.d.ts +4 -0
  9. package/dist/aws/signature.d.ts +142 -0
  10. package/dist/aws/signature.test.d.ts +4 -0
  11. package/dist/backup/disaster-recovery.d.ts +140 -0
  12. package/dist/backup/disaster-recovery.test.d.ts +1 -0
  13. package/dist/backup/index.d.ts +8 -0
  14. package/dist/backup/manager.d.ts +172 -0
  15. package/dist/backup/manager.test.d.ts +1 -0
  16. package/dist/cicd/circleci.d.ts +50 -0
  17. package/dist/cicd/github-actions.d.ts +62 -0
  18. package/dist/cicd/gitlab-ci.d.ts +50 -0
  19. package/dist/cicd/index.d.ts +7 -0
  20. package/dist/cli/history.d.ts +137 -0
  21. package/dist/cli/index.d.ts +9 -0
  22. package/dist/cli/progress.d.ts +193 -0
  23. package/dist/cli/repl.d.ts +148 -0
  24. package/dist/cli/suggestions.d.ts +74 -0
  25. package/dist/cli/table.d.ts +73 -0
  26. package/dist/cli/table.test.d.ts +1 -0
  27. package/dist/cloudformation/builder.d.ts +93 -0
  28. package/dist/cloudformation/builder.test.d.ts +4 -0
  29. package/dist/cloudformation/builders/api-gateway.d.ts +30 -0
  30. package/dist/cloudformation/builders/cache.d.ts +35 -0
  31. package/dist/cloudformation/builders/cdn.d.ts +34 -0
  32. package/dist/cloudformation/builders/compute.d.ts +68 -0
  33. package/dist/cloudformation/builders/database.d.ts +61 -0
  34. package/dist/cloudformation/builders/functions.d.ts +32 -0
  35. package/dist/cloudformation/builders/messaging.d.ts +17 -0
  36. package/dist/cloudformation/builders/monitoring.d.ts +39 -0
  37. package/dist/cloudformation/builders/network.d.ts +14 -0
  38. package/dist/cloudformation/builders/queue.d.ts +16 -0
  39. package/dist/cloudformation/builders/security.d.ts +31 -0
  40. package/dist/cloudformation/builders/storage.d.ts +36 -0
  41. package/dist/cloudformation/index.d.ts +10 -0
  42. package/dist/cloudformation/types.d.ts +200 -0
  43. package/dist/compliance/aws-config.d.ts +175 -0
  44. package/dist/compliance/cloudtrail.d.ts +132 -0
  45. package/dist/compliance/compliance.test.d.ts +1 -0
  46. package/dist/compliance/guardduty.d.ts +176 -0
  47. package/dist/compliance/index.d.ts +12 -0
  48. package/dist/compliance/security-hub.d.ts +178 -0
  49. package/dist/containers/build-optimization.d.ts +155 -0
  50. package/dist/containers/containers.test.d.ts +1 -0
  51. package/dist/containers/image-scanning.d.ts +144 -0
  52. package/dist/containers/index.d.ts +8 -0
  53. package/dist/containers/registry.d.ts +129 -0
  54. package/dist/containers/service-mesh.d.ts +254 -0
  55. package/dist/database/database.test.d.ts +1 -0
  56. package/dist/database/index.d.ts +8 -0
  57. package/dist/database/migrations.d.ts +153 -0
  58. package/dist/database/performance.d.ts +219 -0
  59. package/dist/database/replicas.d.ts +218 -0
  60. package/dist/database/users.d.ts +165 -0
  61. package/dist/dependency-graph.d.ts +37 -0
  62. package/dist/deployment/ab-testing.d.ts +165 -0
  63. package/dist/deployment/blue-green.d.ts +140 -0
  64. package/dist/deployment/canary.d.ts +165 -0
  65. package/dist/deployment/deployment.test.d.ts +1 -0
  66. package/dist/deployment/index.d.ts +12 -0
  67. package/dist/deployment/progressive.d.ts +50 -0
  68. package/dist/dns/dns.test.d.ts +1 -0
  69. package/dist/dns/dnssec.d.ts +120 -0
  70. package/dist/dns/index.d.ts +7 -0
  71. package/dist/dns/resolver.d.ts +216 -0
  72. package/dist/dns/routing.d.ts +277 -0
  73. package/dist/email/advanced/analytics.d.ts +107 -0
  74. package/dist/email/advanced/index.d.ts +10 -0
  75. package/dist/email/advanced/rules.d.ts +131 -0
  76. package/dist/email/advanced/scheduling.d.ts +81 -0
  77. package/dist/email/advanced/search.d.ts +91 -0
  78. package/dist/email/advanced/shared-mailboxes.d.ts +109 -0
  79. package/dist/email/advanced/templates.d.ts +95 -0
  80. package/dist/email/advanced/threading.d.ts +65 -0
  81. package/dist/email/analytics.d.ts +189 -0
  82. package/dist/email/bounce-handling.d.ts +171 -0
  83. package/dist/email/email.test.d.ts +1 -0
  84. package/dist/email/handlers/__tests__/inbound.test.d.ts +1 -0
  85. package/dist/email/handlers/__tests__/outbound.test.d.ts +1 -0
  86. package/dist/email/handlers/converter.d.ts +11 -0
  87. package/dist/email/handlers/feedback.d.ts +11 -0
  88. package/dist/email/handlers/inbound.d.ts +13 -0
  89. package/dist/email/handlers/outbound.d.ts +13 -0
  90. package/dist/email/index.d.ts +10 -0
  91. package/dist/email/reputation.d.ts +133 -0
  92. package/dist/email/templates.d.ts +124 -0
  93. package/dist/errors/index.d.ts +177 -0
  94. package/dist/errors/index.test.d.ts +4 -0
  95. package/dist/health-checks/index.d.ts +35 -0
  96. package/dist/index.d.ts +15 -256
  97. package/dist/index.js +228 -80
  98. package/dist/intrinsic-functions.d.ts +77 -0
  99. package/dist/lambda/concurrency.d.ts +146 -0
  100. package/dist/lambda/destinations.d.ts +141 -0
  101. package/dist/lambda/dlq.d.ts +160 -0
  102. package/dist/lambda/index.d.ts +10 -0
  103. package/dist/lambda/lambda.test.d.ts +1 -0
  104. package/dist/lambda/layers.d.ts +117 -0
  105. package/dist/lambda/versions.d.ts +145 -0
  106. package/dist/lambda/vpc.d.ts +164 -0
  107. package/dist/local/config.d.ts +44 -0
  108. package/dist/local/index.d.ts +5 -0
  109. package/dist/local/mock-aws.d.ts +69 -0
  110. package/dist/modules/ai.d.ts +108 -0
  111. package/dist/modules/api.d.ts +157 -0
  112. package/dist/modules/auth.d.ts +262 -0
  113. package/dist/modules/cache.d.ts +108 -0
  114. package/dist/modules/cdn.d.ts +305 -0
  115. package/dist/modules/communication.d.ts +117 -0
  116. package/dist/modules/compute.d.ts +1376 -0
  117. package/dist/modules/database.d.ts +144 -0
  118. package/dist/modules/deployment.d.ts +372 -0
  119. package/dist/modules/dns.d.ts +143 -0
  120. package/dist/modules/email.d.ts +314 -0
  121. package/dist/modules/filesystem.d.ts +132 -0
  122. package/dist/modules/index.d.ts +31 -0
  123. package/dist/modules/messaging.d.ts +210 -0
  124. package/dist/modules/monitoring.d.ts +574 -0
  125. package/dist/modules/network.d.ts +148 -0
  126. package/dist/modules/parameter-store.d.ts +143 -0
  127. package/dist/modules/permissions.d.ts +245 -0
  128. package/dist/modules/phone.d.ts +125 -0
  129. package/dist/modules/queue.d.ts +411 -0
  130. package/dist/modules/redirects.d.ts +140 -0
  131. package/dist/modules/registry.d.ts +189 -0
  132. package/dist/modules/search.d.ts +135 -0
  133. package/dist/modules/secrets.d.ts +149 -0
  134. package/dist/modules/security.d.ts +219 -0
  135. package/dist/modules/sms.d.ts +130 -0
  136. package/dist/modules/storage.d.ts +344 -0
  137. package/dist/modules/workflow.d.ts +288 -0
  138. package/dist/multi-account/config.d.ts +166 -0
  139. package/dist/multi-account/index.d.ts +6 -0
  140. package/dist/multi-account/manager.d.ts +181 -0
  141. package/dist/multi-region/cross-region.d.ts +204 -0
  142. package/dist/multi-region/index.d.ts +7 -0
  143. package/dist/multi-region/manager.d.ts +136 -0
  144. package/dist/multi-region/regions.d.ts +98 -0
  145. package/dist/network-security/index.d.ts +55 -0
  146. package/dist/observability/index.d.ts +8 -0
  147. package/dist/observability/logs.d.ts +213 -0
  148. package/dist/observability/metrics.d.ts +187 -0
  149. package/dist/observability/observability.test.d.ts +1 -0
  150. package/dist/observability/synthetics.d.ts +189 -0
  151. package/dist/observability/xray.d.ts +193 -0
  152. package/dist/phone/advanced/analytics.d.ts +83 -0
  153. package/dist/phone/advanced/callbacks.d.ts +67 -0
  154. package/dist/phone/advanced/index.d.ts +7 -0
  155. package/dist/phone/advanced/ivr-builder.d.ts +130 -0
  156. package/dist/phone/advanced/recording.d.ts +62 -0
  157. package/dist/phone/handlers/__tests__/incoming-call.test.d.ts +1 -0
  158. package/dist/phone/handlers/incoming-call.d.ts +10 -0
  159. package/dist/phone/handlers/missed-call.d.ts +9 -0
  160. package/dist/phone/handlers/voicemail.d.ts +10 -0
  161. package/dist/phone/index.d.ts +5 -0
  162. package/dist/presets/api-backend.d.ts +11 -0
  163. package/dist/presets/data-pipeline.d.ts +11 -0
  164. package/dist/presets/extend.d.ts +194 -0
  165. package/dist/presets/extend.test.d.ts +4 -0
  166. package/dist/presets/fullstack-app.d.ts +12 -0
  167. package/dist/presets/index.d.ts +13 -0
  168. package/dist/presets/jamstack.d.ts +12 -0
  169. package/dist/presets/microservices.d.ts +18 -0
  170. package/dist/presets/ml-api.d.ts +13 -0
  171. package/dist/presets/nodejs-server.d.ts +14 -0
  172. package/dist/presets/nodejs-serverless.d.ts +14 -0
  173. package/dist/presets/realtime-app.d.ts +11 -0
  174. package/dist/presets/static-site.d.ts +12 -0
  175. package/dist/presets/traditional-web-app.d.ts +16 -0
  176. package/dist/presets/wordpress.d.ts +12 -0
  177. package/dist/preview/github.d.ts +32 -0
  178. package/dist/preview/github.test.d.ts +1 -0
  179. package/dist/preview/index.d.ts +10 -0
  180. package/dist/preview/manager.d.ts +101 -0
  181. package/dist/preview/manager.test.d.ts +1 -0
  182. package/dist/preview/notifications.d.ts +89 -0
  183. package/dist/preview/notifications.test.d.ts +1 -0
  184. package/dist/queue/batch-processing.d.ts +138 -0
  185. package/dist/queue/dlq-monitoring.d.ts +143 -0
  186. package/dist/queue/fifo.d.ts +131 -0
  187. package/dist/queue/index.d.ts +8 -0
  188. package/dist/queue/management.d.ts +162 -0
  189. package/dist/queue/queue.test.d.ts +1 -0
  190. package/dist/resource-mgmt/index.d.ts +44 -0
  191. package/dist/resource-naming.d.ts +26 -0
  192. package/dist/s3/index.d.ts +227 -0
  193. package/dist/schema/index.d.ts +12 -0
  194. package/dist/security/certificate-manager.d.ts +184 -0
  195. package/dist/security/index.d.ts +8 -0
  196. package/dist/security/scanning.d.ts +196 -0
  197. package/dist/security/secrets-manager.d.ts +204 -0
  198. package/dist/security/secrets-rotation.d.ts +167 -0
  199. package/dist/security/security.test.d.ts +1 -0
  200. package/dist/sms/advanced/ab-testing.d.ts +74 -0
  201. package/dist/sms/advanced/analytics.d.ts +75 -0
  202. package/dist/sms/advanced/campaigns.d.ts +96 -0
  203. package/dist/sms/advanced/chatbot.d.ts +67 -0
  204. package/dist/sms/advanced/index.d.ts +9 -0
  205. package/dist/sms/advanced/link-tracking.d.ts +60 -0
  206. package/dist/sms/advanced/mms.d.ts +60 -0
  207. package/dist/sms/handlers/__tests__/send.test.d.ts +1 -0
  208. package/dist/sms/handlers/delivery-status.d.ts +10 -0
  209. package/dist/sms/handlers/receive.d.ts +10 -0
  210. package/dist/sms/handlers/send.d.ts +10 -0
  211. package/dist/sms/index.d.ts +5 -0
  212. package/dist/stack-diff.d.ts +38 -0
  213. package/dist/static-site/index.d.ts +49 -0
  214. package/dist/template-builder.d.ts +42 -0
  215. package/dist/template-validator.d.ts +28 -0
  216. package/dist/types.d.ts +2514 -0
  217. package/dist/utils/cache.d.ts +117 -0
  218. package/dist/utils/diff.d.ts +52 -0
  219. package/dist/utils/hash.d.ts +73 -0
  220. package/dist/utils/index.d.ts +7 -0
  221. package/dist/utils/parallel.d.ts +78 -0
  222. package/dist/validators/credentials.d.ts +30 -0
  223. package/dist/validators/credentials.test.d.ts +4 -0
  224. package/dist/validators/quotas.d.ts +64 -0
  225. package/dist/validators/quotas.test.d.ts +4 -0
  226. package/package.json +2 -2
@@ -0,0 +1,2514 @@
1
+ /**
2
+ * AWS-specific configuration
3
+ */
4
+ export interface AwsConfig {
5
+ /**
6
+ * AWS region for deployment
7
+ */
8
+ region?: string;
9
+ /**
10
+ * AWS CLI profile to use
11
+ */
12
+ profile?: string;
13
+ /**
14
+ * AWS account ID
15
+ */
16
+ accountId?: string;
17
+ }
18
+ export interface CloudConfig {
19
+ project: ProjectConfig;
20
+ mode?: DeploymentMode;
21
+ environments: Record<string, EnvironmentConfig>;
22
+ infrastructure?: InfrastructureConfig;
23
+ sites?: Record<string, SiteConfig>;
24
+ /**
25
+ * AWS-specific configuration
26
+ */
27
+ aws?: AwsConfig;
28
+ /**
29
+ * Feature flags to enable/disable resources conditionally
30
+ * Example: { enableCache: true, enableMonitoring: false }
31
+ */
32
+ features?: Record<string, boolean>;
33
+ /**
34
+ * Deployment hooks for custom logic
35
+ */
36
+ hooks?: {
37
+ beforeDeploy?: string | ((_config: CloudConfig) => Promise<void>);
38
+ afterDeploy?: string | ((_config: CloudConfig) => Promise<void>);
39
+ beforeBuild?: string | ((_config: CloudConfig) => Promise<void>);
40
+ afterBuild?: string | ((_config: CloudConfig) => Promise<void>);
41
+ };
42
+ /**
43
+ * Cost optimization preset
44
+ * Automatically adjusts resource sizes based on budget
45
+ */
46
+ costPreset?: 'minimal' | 'balanced' | 'performance' | 'custom';
47
+ /**
48
+ * Tags applied to all resources
49
+ */
50
+ tags?: Record<string, string>;
51
+ }
52
+ export type CloudOptions = Partial<CloudConfig>;
53
+ export interface ProjectConfig {
54
+ name: string;
55
+ slug: string;
56
+ region: string;
57
+ }
58
+ /**
59
+ * Deployment mode (optional)
60
+ * @deprecated Mode is now auto-detected from your infrastructure configuration.
61
+ * Simply define the resources you need (functions, servers, storage, etc.) and
62
+ * ts-cloud will deploy them accordingly. No need to specify a mode.
63
+ */
64
+ export type DeploymentMode = 'server' | 'serverless' | 'hybrid';
65
+ export type EnvironmentType = 'production' | 'staging' | 'development';
66
+ export interface EnvironmentConfig {
67
+ type: EnvironmentType;
68
+ region?: string;
69
+ variables?: Record<string, string>;
70
+ /**
71
+ * Custom domain for this environment
72
+ * Example: 'example.com' for production, 'staging.example.com' for staging
73
+ */
74
+ domain?: string;
75
+ /**
76
+ * Environment-specific infrastructure overrides
77
+ * Allows different infrastructure per environment
78
+ * Example: smaller instances in dev, larger in production
79
+ */
80
+ infrastructure?: Partial<InfrastructureConfig>;
81
+ }
82
+ /**
83
+ * Network/VPC configuration
84
+ */
85
+ export interface NetworkConfig {
86
+ cidr?: string;
87
+ vpc?: VpcConfig;
88
+ subnets?: {
89
+ public?: number;
90
+ private?: number;
91
+ };
92
+ natGateway?: boolean | 'single' | 'perAz';
93
+ }
94
+ /**
95
+ * API Gateway configuration
96
+ */
97
+ export interface ApiGatewayConfig {
98
+ type?: 'REST' | 'HTTP' | 'websocket';
99
+ name?: string;
100
+ description?: string;
101
+ stageName?: string;
102
+ cors?: boolean | {
103
+ allowOrigins?: string[];
104
+ allowMethods?: string[];
105
+ allowHeaders?: string[];
106
+ maxAge?: number;
107
+ };
108
+ authorization?: 'NONE' | 'IAM' | 'COGNITO' | 'LAMBDA';
109
+ throttling?: {
110
+ rateLimit?: number;
111
+ burstLimit?: number;
112
+ };
113
+ customDomain?: {
114
+ domain?: string;
115
+ certificateArn?: string;
116
+ };
117
+ authorizer?: {
118
+ type?: string;
119
+ identitySource?: string;
120
+ audience?: string[];
121
+ };
122
+ routes?: Array<{
123
+ path?: string;
124
+ method?: string;
125
+ integration?: string | {
126
+ type?: string;
127
+ service?: string;
128
+ };
129
+ authorizer?: string;
130
+ }> | Record<string, {
131
+ path?: string;
132
+ method?: string;
133
+ integration?: string | {
134
+ type?: string;
135
+ service?: string;
136
+ };
137
+ }>;
138
+ }
139
+ /**
140
+ * Messaging (SNS) configuration
141
+ */
142
+ export interface MessagingConfig {
143
+ topics?: Record<string, {
144
+ name?: string;
145
+ displayName?: string;
146
+ subscriptions?: Array<{
147
+ protocol: 'email' | 'sqs' | 'lambda' | 'http' | 'https';
148
+ endpoint: string;
149
+ filterPolicy?: Record<string, string[]>;
150
+ }>;
151
+ }>;
152
+ }
153
+ export interface InfrastructureConfig {
154
+ vpc?: VpcConfig;
155
+ /**
156
+ * Network/VPC configuration
157
+ * Defines the network infrastructure including VPC, subnets, and NAT gateways
158
+ */
159
+ network?: NetworkConfig;
160
+ /**
161
+ * Compute/EC2 configuration
162
+ * Defines the EC2 instances running your Stacks/Bun application
163
+ *
164
+ * @example
165
+ * // Single instance (no load balancer needed)
166
+ * compute: {
167
+ * instances: 1,
168
+ * instanceType: 't3.micro',
169
+ * }
170
+ *
171
+ * @example
172
+ * // Multiple instances (load balancer auto-enabled)
173
+ * compute: {
174
+ * instances: 3,
175
+ * instanceType: 't3.small',
176
+ * autoScaling: {
177
+ * min: 2,
178
+ * max: 10,
179
+ * scaleUpThreshold: 70,
180
+ * },
181
+ * }
182
+ */
183
+ compute?: ComputeConfig;
184
+ /**
185
+ * Container configuration (ECS Fargate)
186
+ * Defines containerized services for serverless deployment mode
187
+ *
188
+ * @example
189
+ * containers: {
190
+ * api: {
191
+ * cpu: 512,
192
+ * memory: 1024,
193
+ * port: 3000,
194
+ * healthCheck: '/health',
195
+ * desiredCount: 2,
196
+ * autoScaling: { min: 1, max: 10, targetCpuUtilization: 70 },
197
+ * }
198
+ * }
199
+ */
200
+ containers?: Record<string, ContainerItemConfig>;
201
+ storage?: Record<string, StorageItemConfig & ResourceConditions>;
202
+ functions?: Record<string, FunctionConfig & ResourceConditions>;
203
+ /** @deprecated Use `compute` instead for EC2 configuration */
204
+ servers?: Record<string, ServerItemConfig & ResourceConditions>;
205
+ databases?: Record<string, DatabaseItemConfig & ResourceConditions>;
206
+ /**
207
+ * Single-database shorthand (Forge-style). Use this for the common case
208
+ * of "I have one app and one database." For multiple named databases,
209
+ * use `databases` (plural) instead.
210
+ *
211
+ * - `'sqlite'` → installed on the EC2 box, file lives at /var/www/app/data.db
212
+ * - `'mysql'` → RDS MySQL with sane defaults, DATABASE_URL injected into env
213
+ * - `'postgres'` → RDS Postgres with sane defaults, DATABASE_URL injected into env
214
+ */
215
+ database?: 'sqlite' | 'mysql' | 'postgres';
216
+ cache?: CacheConfig;
217
+ cdn?: Record<string, CdnItemConfig & ResourceConditions> | CdnItemConfig;
218
+ /**
219
+ * Elastic File System (EFS) configuration
220
+ * For shared file storage across multiple instances
221
+ */
222
+ fileSystem?: Record<string, FileSystemItemConfig>;
223
+ /**
224
+ * API Gateway configuration
225
+ * Defines the API Gateway for routing HTTP requests to Lambda functions
226
+ */
227
+ apiGateway?: ApiGatewayConfig;
228
+ /**
229
+ * Messaging (SNS) configuration
230
+ * Defines SNS topics for pub/sub messaging patterns
231
+ */
232
+ messaging?: MessagingConfig;
233
+ /**
234
+ * Queue (SQS) configuration
235
+ * Defines message queues for async processing, background jobs, and event-driven architectures
236
+ *
237
+ * @example
238
+ * queues: {
239
+ * // Standard queue for background jobs
240
+ * jobs: {
241
+ * visibilityTimeout: 120,
242
+ * deadLetterQueue: true,
243
+ * },
244
+ * // FIFO queue for ordered processing
245
+ * orders: {
246
+ * fifo: true,
247
+ * contentBasedDeduplication: true,
248
+ * },
249
+ * // High-throughput events queue
250
+ * events: {
251
+ * receiveMessageWaitTime: 20,
252
+ * },
253
+ * }
254
+ */
255
+ queues?: Record<string, QueueItemConfig & ResourceConditions>;
256
+ /**
257
+ * Realtime (WebSocket) configuration
258
+ * Laravel Echo / Pusher-compatible broadcasting for Stacks.js
259
+ *
260
+ * @example
261
+ * realtime: {
262
+ * enabled: true,
263
+ * channels: { public: true, private: true, presence: true },
264
+ * auth: { functionName: 'authorizeChannel' },
265
+ * }
266
+ *
267
+ * @example Using presets
268
+ * realtime: RealtimePresets.production
269
+ */
270
+ realtime?: RealtimeConfig;
271
+ dns?: DnsConfig;
272
+ security?: SecurityConfig;
273
+ monitoring?: MonitoringConfig;
274
+ api?: ApiConfig;
275
+ loadBalancer?: LoadBalancerConfig;
276
+ ssl?: SslConfig;
277
+ /**
278
+ * Domain and path redirect configuration
279
+ *
280
+ * Domain redirects create S3 buckets that redirect all traffic to a target domain.
281
+ * Path redirects create CloudFront Functions for URL-level rewrites.
282
+ *
283
+ * @example
284
+ * // Simple domain redirects (redirect these domains to your primary domain)
285
+ * redirects: {
286
+ * domains: ['www.stacksjs.com', 'stacks.dev'],
287
+ * target: 'stacksjs.com',
288
+ * }
289
+ *
290
+ * @example
291
+ * // Domain + path redirects
292
+ * redirects: {
293
+ * domains: ['old-domain.com'],
294
+ * target: 'new-domain.com',
295
+ * paths: {
296
+ * '/old-blog': '/blog',
297
+ * '/legacy/api': '/api/v2',
298
+ * },
299
+ * }
300
+ */
301
+ redirects?: RedirectsConfig;
302
+ streaming?: Record<string, {
303
+ name?: string;
304
+ shardCount?: number;
305
+ retentionPeriod?: number;
306
+ encryption?: boolean | string;
307
+ }>;
308
+ machineLearning?: {
309
+ sagemakerEndpoint?: string;
310
+ modelBucket?: string;
311
+ sagemaker?: {
312
+ endpointName?: string;
313
+ instanceType?: string;
314
+ endpoints?: Array<{
315
+ name?: string;
316
+ modelName?: string;
317
+ modelS3Path?: string;
318
+ instanceType?: string;
319
+ instanceCount?: number;
320
+ initialInstanceCount?: number;
321
+ autoScaling?: {
322
+ minInstances?: number;
323
+ maxInstances?: number;
324
+ targetInvocationsPerInstance?: number;
325
+ };
326
+ }>;
327
+ trainingJobs?: Array<{
328
+ name?: string;
329
+ algorithmSpecification?: {
330
+ trainingImage?: string;
331
+ trainingInputMode?: string;
332
+ };
333
+ instanceType?: string;
334
+ instanceCount?: number;
335
+ volumeSizeInGB?: number;
336
+ maxRuntimeInSeconds?: number;
337
+ }>;
338
+ };
339
+ };
340
+ analytics?: {
341
+ enabled?: boolean;
342
+ firehose?: Record<string, {
343
+ name?: string;
344
+ destination?: string;
345
+ bufferSize?: number;
346
+ bufferInterval?: number;
347
+ }>;
348
+ athena?: {
349
+ database?: string;
350
+ workgroup?: string;
351
+ outputLocation?: string;
352
+ outputBucket?: string;
353
+ tables?: Array<{
354
+ name?: string;
355
+ location?: string;
356
+ format?: string;
357
+ partitionKeys?: string[];
358
+ }>;
359
+ };
360
+ glue?: {
361
+ crawlers?: Array<{
362
+ name?: string;
363
+ databaseName?: string;
364
+ s3Targets?: string[];
365
+ schedule?: string;
366
+ }>;
367
+ jobs?: Array<{
368
+ name?: string;
369
+ scriptLocation?: string;
370
+ role?: string;
371
+ maxCapacity?: number;
372
+ timeout?: number;
373
+ }>;
374
+ };
375
+ };
376
+ workflow?: {
377
+ pipelines?: Array<{
378
+ name?: string;
379
+ type?: 'stepFunctions' | string;
380
+ definition?: Record<string, unknown>;
381
+ schedule?: string;
382
+ }>;
383
+ };
384
+ /**
385
+ * Jump Box / Bastion Host configuration
386
+ * Provides SSH access to private resources in your VPC
387
+ *
388
+ * Set to `true` for a default jump box, or provide a config object.
389
+ *
390
+ * @example
391
+ * // Simple — default t3.micro jump box
392
+ * jumpBox: true
393
+ *
394
+ * @example
395
+ * // With EFS mount for file access
396
+ * jumpBox: {
397
+ * enabled: true,
398
+ * size: 'micro',
399
+ * mountEfs: true,
400
+ * }
401
+ *
402
+ * @example
403
+ * // Restrict SSH to a specific IP
404
+ * jumpBox: {
405
+ * enabled: true,
406
+ * allowedCidrs: ['203.0.113.0/32'],
407
+ * }
408
+ */
409
+ jumpBox?: boolean | JumpBoxConfig;
410
+ /**
411
+ * Email (SES) configuration
412
+ * Configures Amazon SES for sending/receiving email
413
+ *
414
+ * @example
415
+ * email: {
416
+ * domain: 'stacksjs.com',
417
+ * configurationSet: true,
418
+ * }
419
+ */
420
+ email?: EmailInfraConfig;
421
+ /**
422
+ * Search (OpenSearch) configuration
423
+ * Configures an OpenSearch domain for full-text search
424
+ *
425
+ * @example
426
+ * search: {
427
+ * instanceType: 't3.small.search',
428
+ * volumeSize: 10,
429
+ * }
430
+ */
431
+ search?: SearchInfraConfig;
432
+ /**
433
+ * AI (Bedrock) configuration
434
+ * Configures IAM roles and policies for Amazon Bedrock model access
435
+ *
436
+ * @example
437
+ * ai: {
438
+ * models: ['anthropic.claude-3-5-sonnet-20241022-v2:0'],
439
+ * allowStreaming: true,
440
+ * }
441
+ */
442
+ ai?: AIInfraConfig;
443
+ }
444
+ /**
445
+ * Jump Box (Bastion Host) configuration
446
+ */
447
+ export interface JumpBoxConfig {
448
+ /**
449
+ * Enable the jump box
450
+ * @default true
451
+ */
452
+ enabled?: boolean;
453
+ /**
454
+ * Instance size or direct instance type
455
+ * @default 'micro'
456
+ */
457
+ size?: InstanceSize;
458
+ /**
459
+ * SSH key pair name
460
+ */
461
+ keyName?: string;
462
+ /**
463
+ * CIDR blocks allowed to SSH into the jump box
464
+ * @default ['0.0.0.0/0']
465
+ */
466
+ allowedCidrs?: string[];
467
+ /**
468
+ * Mount an EFS file system on the jump box
469
+ * Set to `true` to auto-detect from infrastructure.fileSystem, or provide an EFS ID
470
+ */
471
+ mountEfs?: boolean | string;
472
+ /**
473
+ * EFS mount path
474
+ * @default '/mnt/efs'
475
+ */
476
+ mountPath?: string;
477
+ /**
478
+ * Install database CLI tools (psql, mysql, redis-cli)
479
+ * @default false
480
+ */
481
+ databaseTools?: boolean;
482
+ }
483
+ /**
484
+ * Redirect configuration for domain and path-level redirects
485
+ */
486
+ export interface RedirectsConfig {
487
+ /**
488
+ * Source domains to redirect (e.g. 'www.stacksjs.com', 'old-domain.com')
489
+ * Each domain gets an S3 redirect bucket pointing to the target
490
+ */
491
+ domains?: string[];
492
+ /**
493
+ * Target domain all redirects point to
494
+ * @example 'stacksjs.com'
495
+ */
496
+ target?: string;
497
+ /**
498
+ * Protocol for the redirect target
499
+ * @default 'https'
500
+ */
501
+ protocol?: 'http' | 'https';
502
+ /**
503
+ * Path-level redirects (CloudFront Function)
504
+ * Keys are source paths, values are target paths
505
+ * @example { '/old-page': '/new-page', '/blog/old-post': '/blog/new-post' }
506
+ */
507
+ paths?: Record<string, string>;
508
+ /**
509
+ * Status code for path redirects
510
+ * @default 301
511
+ */
512
+ statusCode?: 301 | 302 | 307 | 308;
513
+ }
514
+ /**
515
+ * Email (SES) infrastructure configuration
516
+ */
517
+ export interface EmailInfraConfig {
518
+ /** Domain to verify for sending email */
519
+ domain?: string;
520
+ /** Create a SES configuration set for tracking */
521
+ configurationSet?: boolean;
522
+ /** Hosted zone ID for DNS records (DKIM, SPF, DMARC) */
523
+ hostedZoneId?: string;
524
+ /** DMARC reporting email */
525
+ dmarcReportingEmail?: string;
526
+ /** Enable DKIM signing */
527
+ enableDkim?: boolean;
528
+ /** DKIM key length */
529
+ dkimKeyLength?: 'RSA_1024_BIT' | 'RSA_2048_BIT';
530
+ /** Inbound email server configuration */
531
+ server?: {
532
+ enabled?: boolean;
533
+ };
534
+ }
535
+ /**
536
+ * Search (OpenSearch) infrastructure configuration
537
+ */
538
+ export interface SearchInfraConfig {
539
+ /** OpenSearch engine version */
540
+ engineVersion?: string;
541
+ /** Instance type for data nodes */
542
+ instanceType?: string;
543
+ /** Number of data node instances */
544
+ instanceCount?: number;
545
+ /** EBS volume size in GB */
546
+ volumeSize?: number;
547
+ /** EBS volume type */
548
+ volumeType?: 'gp2' | 'gp3' | 'io1';
549
+ /** Enable dedicated master nodes */
550
+ dedicatedMaster?: boolean;
551
+ /** Instance type for dedicated master nodes */
552
+ dedicatedMasterType?: string;
553
+ /** Number of dedicated master nodes */
554
+ dedicatedMasterCount?: number;
555
+ /** Enable multi-AZ deployment */
556
+ multiAz?: boolean;
557
+ /** Encryption configuration */
558
+ encryption?: {
559
+ atRest?: boolean;
560
+ nodeToNode?: boolean;
561
+ kmsKeyId?: string;
562
+ };
563
+ /** Fine-grained access control */
564
+ advancedSecurity?: {
565
+ enabled: boolean;
566
+ internalUserDatabase?: boolean;
567
+ masterUserName?: string;
568
+ masterUserPassword?: string;
569
+ };
570
+ /** Auto-tune for performance optimization */
571
+ autoTune?: boolean;
572
+ /** Deploy inside VPC */
573
+ vpc?: boolean;
574
+ }
575
+ /**
576
+ * AI (Bedrock) infrastructure configuration
577
+ */
578
+ export interface AIInfraConfig {
579
+ /** Bedrock model IDs to allow access to (default: ['*'] for all models) */
580
+ models?: string[];
581
+ /** Allow streaming responses */
582
+ allowStreaming?: boolean;
583
+ /** Allow async invocation */
584
+ allowAsync?: boolean;
585
+ /** Service to grant access: 'ecs', 'ec2', 'lambda', or custom principal */
586
+ service?: 'ecs' | 'ec2' | 'lambda' | string;
587
+ }
588
+ /**
589
+ * Conditions that determine if a resource should be deployed
590
+ */
591
+ export interface ResourceConditions {
592
+ /**
593
+ * Only deploy in these environments
594
+ * Example: ['production', 'staging']
595
+ */
596
+ environments?: EnvironmentType[];
597
+ /**
598
+ * Only deploy if these features are enabled
599
+ * Example: ['enableDatabase', 'enableCache']
600
+ */
601
+ requiresFeatures?: string[];
602
+ /**
603
+ * Only deploy in these regions
604
+ */
605
+ regions?: string[];
606
+ /**
607
+ * Custom condition function
608
+ */
609
+ condition?: (config: CloudConfig, env: EnvironmentType) => boolean;
610
+ }
611
+ export interface SiteConfig {
612
+ /**
613
+ * Directory to deploy.
614
+ * - For static sites: the built static files to upload to S3 (e.g., 'dist').
615
+ * - For SSR sites: the build output to tar+ship to EC2 (e.g., '.output').
616
+ */
617
+ root: string;
618
+ /** Path prefix for deployment (usually '/') */
619
+ path?: string;
620
+ /** Custom domain for the site (e.g., 'stage.easyotc.com') */
621
+ domain?: string;
622
+ /** S3 bucket name (auto-generated from domain if not provided) */
623
+ bucket?: string;
624
+ /** SSL certificate ARN (auto-created if not provided) */
625
+ certificateArn?: string;
626
+ /** Build command to run before deployment (e.g., 'bun run generate', 'npm run build') */
627
+ build?: string;
628
+ /**
629
+ * Path to a shell script to serve at the root URL.
630
+ * Enables `curl -fsSL https://your-domain.com | bash` installs.
631
+ * When set, the script is served as the default document with `text/plain`
632
+ * content type and the URL rewrite function is disabled.
633
+ */
634
+ installScript?: string;
635
+ /**
636
+ * Command the systemd service runs (becomes ExecStart).
637
+ * Presence of this field is the discriminator: set => SSR (deploy to EC2),
638
+ * unset => static (deploy to S3+CloudFront).
639
+ *
640
+ * Example: 'bun run server.ts'
641
+ */
642
+ start?: string;
643
+ /**
644
+ * Port the SSR app listens on. Required when `start` is set.
645
+ * Two SSR sites on the same EC2 instance must use different ports.
646
+ */
647
+ port?: number;
648
+ /**
649
+ * Environment variables written to the per-site systemd EnvironmentFile
650
+ * (`/var/www/<site>/.env`). Available as process.env.* inside the running app.
651
+ */
652
+ env?: Record<string, string>;
653
+ }
654
+ export interface VpcConfig {
655
+ cidr?: string;
656
+ zones?: number;
657
+ availabilityZones?: number;
658
+ natGateway?: boolean;
659
+ natGateways?: number | boolean;
660
+ }
661
+ export interface StorageConfig {
662
+ buckets?: BucketConfig[];
663
+ }
664
+ export interface BucketConfig {
665
+ name: string;
666
+ public?: boolean;
667
+ versioning?: boolean;
668
+ website?: boolean;
669
+ encryption?: boolean;
670
+ }
671
+ export interface DatabaseConfig {
672
+ type?: 'rds' | 'dynamodb';
673
+ engine?: 'postgres' | 'mysql';
674
+ instanceType?: string;
675
+ }
676
+ export interface CacheConfig {
677
+ type?: 'redis' | 'memcached';
678
+ nodeType?: string;
679
+ /**
680
+ * Redis-specific configuration
681
+ */
682
+ redis?: {
683
+ nodeType?: string;
684
+ numCacheNodes?: number;
685
+ engine?: string;
686
+ engineVersion?: string;
687
+ port?: number;
688
+ parameterGroup?: Record<string, string>;
689
+ snapshotRetentionLimit?: number;
690
+ snapshotWindow?: string;
691
+ automaticFailoverEnabled?: boolean;
692
+ };
693
+ /**
694
+ * ElastiCache configuration
695
+ */
696
+ elasticache?: {
697
+ nodeType?: string;
698
+ numCacheNodes?: number;
699
+ engine?: string;
700
+ engineVersion?: string;
701
+ };
702
+ }
703
+ export interface CdnConfig {
704
+ enabled?: boolean;
705
+ customDomain?: string;
706
+ certificateArn?: string;
707
+ }
708
+ export interface DnsConfig {
709
+ domain?: string;
710
+ hostedZoneId?: string;
711
+ /**
712
+ * External DNS provider configuration
713
+ * When set, DNS records will be managed via the external provider API
714
+ * instead of Route53
715
+ */
716
+ provider?: 'route53' | 'cloudflare' | 'porkbun' | 'godaddy';
717
+ }
718
+ export interface SecurityConfig {
719
+ waf?: WafConfig;
720
+ kms?: boolean;
721
+ /**
722
+ * SSL/TLS Certificate configuration
723
+ */
724
+ certificate?: {
725
+ domain: string;
726
+ subdomains?: string[];
727
+ validationMethod?: 'DNS' | 'EMAIL';
728
+ };
729
+ /**
730
+ * Security groups configuration
731
+ */
732
+ securityGroups?: Record<string, {
733
+ ingress?: Array<{
734
+ port: number;
735
+ protocol: string;
736
+ cidr?: string;
737
+ source?: string;
738
+ }>;
739
+ egress?: Array<{
740
+ port: number;
741
+ protocol: string;
742
+ cidr?: string;
743
+ destination?: string;
744
+ }>;
745
+ }>;
746
+ }
747
+ export interface WafConfig {
748
+ enabled?: boolean;
749
+ blockCountries?: string[];
750
+ blockIps?: string[];
751
+ rateLimit?: number;
752
+ /**
753
+ * WAF rules to enable
754
+ * @example ['rateLimit', 'sqlInjection', 'xss']
755
+ */
756
+ rules?: string[];
757
+ }
758
+ export interface MonitoringConfig {
759
+ alarms?: Record<string, AlarmItemConfig> | AlarmItemConfig[];
760
+ dashboards?: boolean;
761
+ /**
762
+ * Dashboard configuration
763
+ */
764
+ dashboard?: {
765
+ name?: string;
766
+ widgets?: Array<{
767
+ type?: string;
768
+ metrics?: string[] | Array<{
769
+ service?: string;
770
+ metric?: string;
771
+ }>;
772
+ }>;
773
+ };
774
+ /**
775
+ * Log configuration
776
+ */
777
+ logs?: {
778
+ retention?: number;
779
+ groups?: string[];
780
+ };
781
+ }
782
+ export interface AlarmConfig {
783
+ name: string;
784
+ metric: string;
785
+ threshold: number;
786
+ }
787
+ export interface AlarmItemConfig {
788
+ /**
789
+ * Name of the alarm (optional, auto-generated if not provided)
790
+ */
791
+ name?: string;
792
+ /**
793
+ * Metric name (short form)
794
+ */
795
+ metric?: string;
796
+ metricName?: string;
797
+ namespace?: string;
798
+ threshold: number;
799
+ comparisonOperator?: string;
800
+ /**
801
+ * Period in seconds for metric aggregation
802
+ */
803
+ period?: number;
804
+ /**
805
+ * Number of periods to evaluate
806
+ */
807
+ evaluationPeriods?: number;
808
+ /**
809
+ * Service name for service-specific alarms
810
+ */
811
+ service?: string;
812
+ }
813
+ export interface StorageItemConfig {
814
+ /**
815
+ * Make bucket publicly accessible
816
+ */
817
+ public?: boolean;
818
+ versioning?: boolean;
819
+ encryption?: boolean;
820
+ encrypted?: boolean;
821
+ website?: boolean | {
822
+ indexDocument?: string;
823
+ errorDocument?: string;
824
+ };
825
+ /**
826
+ * Explicit CloudFront distribution aliases for this bucket.
827
+ * Overrides the default alias logic based on bucket name.
828
+ * Example: ['example.com', 'www.example.com']
829
+ */
830
+ aliases?: string[];
831
+ /**
832
+ * Whether this bucket serves a single-page application (SPA).
833
+ * When true: 403/404 errors return index.html with status 200 (for client-side routing).
834
+ * When false (default): A CloudFront Function rewrites extensionless URLs to .html files,
835
+ * and 403/404 errors return a proper 404 page. This is correct for multi-page SSG sites.
836
+ */
837
+ spa?: boolean;
838
+ /**
839
+ * Root directory containing the built static files to upload (e.g., 'dist', '.output/public').
840
+ * When set, `cloud deploy` will auto-upload files from this directory to the S3 bucket
841
+ * after the CloudFormation stack reaches a COMPLETE status, and invalidate CloudFront cache.
842
+ */
843
+ root?: string;
844
+ /**
845
+ * Storage type (for special storage like EFS)
846
+ */
847
+ type?: 'efs' | 's3';
848
+ /**
849
+ * Enable Intelligent Tiering for cost optimization
850
+ */
851
+ intelligentTiering?: boolean;
852
+ /**
853
+ * CORS configuration
854
+ */
855
+ cors?: Array<{
856
+ allowedOrigins?: string[];
857
+ allowedMethods?: string[];
858
+ allowedHeaders?: string[];
859
+ maxAge?: number;
860
+ }>;
861
+ /**
862
+ * Lifecycle rules for automatic transitions/deletions
863
+ */
864
+ lifecycleRules?: Array<{
865
+ id?: string;
866
+ enabled?: boolean;
867
+ expirationDays?: number;
868
+ transitions?: Array<{
869
+ days?: number;
870
+ storageClass?: string;
871
+ }>;
872
+ }>;
873
+ /**
874
+ * Performance mode (for EFS)
875
+ */
876
+ performanceMode?: string;
877
+ /**
878
+ * Throughput mode (for EFS)
879
+ */
880
+ throughputMode?: string;
881
+ /**
882
+ * Lifecycle policy (for EFS)
883
+ */
884
+ lifecyclePolicy?: {
885
+ transitionToIA?: number;
886
+ };
887
+ }
888
+ export interface FunctionConfig {
889
+ handler?: string;
890
+ runtime?: string;
891
+ code?: string;
892
+ timeout?: number;
893
+ memorySize?: number;
894
+ memory?: number;
895
+ events?: Array<{
896
+ type?: string;
897
+ path?: string;
898
+ method?: string;
899
+ queueName?: string;
900
+ streamName?: string;
901
+ tableName?: string;
902
+ expression?: string;
903
+ batchSize?: number;
904
+ startingPosition?: string;
905
+ parallelizationFactor?: number;
906
+ bucket?: string;
907
+ prefix?: string;
908
+ suffix?: string;
909
+ }>;
910
+ environment?: Record<string, string>;
911
+ }
912
+ /**
913
+ * Elastic File System (EFS) configuration
914
+ */
915
+ export interface FileSystemItemConfig {
916
+ /**
917
+ * Performance mode
918
+ */
919
+ performanceMode?: 'generalPurpose' | 'maxIO';
920
+ /**
921
+ * Throughput mode
922
+ */
923
+ throughputMode?: 'bursting' | 'provisioned' | 'elastic';
924
+ /**
925
+ * Enable encryption
926
+ */
927
+ encrypted?: boolean;
928
+ /**
929
+ * Lifecycle policy
930
+ */
931
+ lifecyclePolicy?: {
932
+ transitionToIA?: number;
933
+ };
934
+ /**
935
+ * Mount path
936
+ */
937
+ mountPath?: string;
938
+ }
939
+ /**
940
+ * Instance size presets
941
+ * Provider-agnostic sizing that maps to appropriate instance types
942
+ */
943
+ export type InstanceSize = 'nano' | 'micro' | 'small' | 'medium' | 'large' | 'xlarge' | '2xlarge' | (string & {});
944
+ /**
945
+ * Server/VM Instance Configuration
946
+ */
947
+ export interface ServerItemConfig {
948
+ /**
949
+ * Instance size or provider-specific type
950
+ * @example 'small', 'medium', 'large' or 't3.micro'
951
+ * @default 'micro'
952
+ */
953
+ size?: InstanceSize;
954
+ /**
955
+ * Custom machine image (optional)
956
+ * If not specified, uses the provider's default Linux image
957
+ */
958
+ image?: string;
959
+ /**
960
+ * Custom startup script
961
+ */
962
+ startupScript?: string;
963
+ /**
964
+ * Human-readable server name
965
+ * @example 'app-server-1'
966
+ */
967
+ name?: string;
968
+ /**
969
+ * Domain associated with this server
970
+ * @example 'stacksjs.com'
971
+ */
972
+ domain?: string;
973
+ /**
974
+ * AWS region for this server
975
+ * @example 'us-east-1'
976
+ */
977
+ region?: string;
978
+ /**
979
+ * Server role type
980
+ * @example 'app', 'web', 'worker', 'cache', 'search'
981
+ */
982
+ type?: 'app' | 'web' | 'worker' | 'cache' | 'search' | (string & {});
983
+ /**
984
+ * Disk size in GB
985
+ * @default 20
986
+ */
987
+ diskSize?: number;
988
+ /**
989
+ * Existing VPC ID or 'create' to provision a new one
990
+ * @example 'vpc-123456789' or 'create'
991
+ */
992
+ privateNetwork?: string;
993
+ /**
994
+ * Existing subnet ID
995
+ * @example 'subnet-123456789'
996
+ */
997
+ subnet?: string;
998
+ /**
999
+ * Server OS image identifier
1000
+ * @example 'ubuntu-20-lts-x86_64'
1001
+ */
1002
+ serverOS?: string;
1003
+ /**
1004
+ * Bun runtime version to install
1005
+ * @example '1.1.26'
1006
+ */
1007
+ bunVersion?: string;
1008
+ /**
1009
+ * Database engine to install clients for
1010
+ * @example 'sqlite', 'postgres'
1011
+ */
1012
+ database?: string;
1013
+ /**
1014
+ * Database name to create
1015
+ * @example 'stacks'
1016
+ */
1017
+ databaseName?: string;
1018
+ /**
1019
+ * Post-provision script (alias for startupScript)
1020
+ */
1021
+ userData?: string;
1022
+ /**
1023
+ * Direct AWS instance type override
1024
+ * @example 't3.micro', 'm6i.large'
1025
+ */
1026
+ instanceType?: string;
1027
+ /**
1028
+ * SSH key pair name for instance access
1029
+ */
1030
+ keyName?: string;
1031
+ }
1032
+ /**
1033
+ * Instance configuration for mixed instance fleets
1034
+ */
1035
+ export interface InstanceConfig {
1036
+ /**
1037
+ * Instance size or provider-specific type
1038
+ * @example 'small', 'medium', 'large' or 't3.micro'
1039
+ */
1040
+ size: InstanceSize;
1041
+ /**
1042
+ * Weight for this instance type in auto scaling
1043
+ * Higher weight = more capacity per instance
1044
+ * @default 1
1045
+ */
1046
+ weight?: number;
1047
+ /**
1048
+ * Use spot/preemptible instances for cost savings
1049
+ * @default false
1050
+ */
1051
+ spot?: boolean;
1052
+ /**
1053
+ * Maximum price for spot instances (per hour)
1054
+ * Only used when spot: true
1055
+ */
1056
+ maxPrice?: string;
1057
+ }
1058
+ /**
1059
+ * Compute Configuration
1060
+ * Defines the virtual machines/instances for your application
1061
+ *
1062
+ * @example Single instance
1063
+ * compute: {
1064
+ * instances: 1,
1065
+ * size: 'small',
1066
+ * }
1067
+ *
1068
+ * @example Multiple instances (auto-enables load balancer)
1069
+ * compute: {
1070
+ * instances: 3,
1071
+ * size: 'medium',
1072
+ * autoScaling: { min: 2, max: 10 },
1073
+ * }
1074
+ *
1075
+ * @example Mixed instance fleet for cost optimization
1076
+ * compute: {
1077
+ * instances: 3,
1078
+ * fleet: [
1079
+ * { size: 'small', weight: 1 },
1080
+ * { size: 'medium', weight: 2 },
1081
+ * { size: 'small', weight: 1, spot: true },
1082
+ * ],
1083
+ * }
1084
+ */
1085
+ export interface ContainerItemConfig {
1086
+ cpu?: number;
1087
+ memory?: number;
1088
+ port?: number;
1089
+ healthCheck?: string;
1090
+ desiredCount?: number;
1091
+ autoScaling?: {
1092
+ min?: number;
1093
+ max?: number;
1094
+ targetCpuUtilization?: number;
1095
+ targetMemoryUtilization?: number;
1096
+ };
1097
+ }
1098
+ export interface ComputeConfig {
1099
+ /**
1100
+ * Compute mode: 'server' for EC2, 'serverless' for Fargate/Lambda
1101
+ */
1102
+ mode?: 'server' | 'serverless';
1103
+ /**
1104
+ * Number of instances to run
1105
+ * When > 1, load balancer is automatically enabled
1106
+ * @default 1
1107
+ */
1108
+ instances?: number;
1109
+ /**
1110
+ * Instance size (simple configuration)
1111
+ * Use this OR fleet, not both
1112
+ * @default 'micro'
1113
+ */
1114
+ size?: InstanceSize;
1115
+ /**
1116
+ * Mixed instance fleet for cost optimization
1117
+ * Allows combining different sizes and spot instances
1118
+ *
1119
+ * @example
1120
+ * fleet: [
1121
+ * { size: 'small', weight: 1 },
1122
+ * { size: 'medium', weight: 2 },
1123
+ * { size: 'small', weight: 1, spot: true },
1124
+ * ]
1125
+ */
1126
+ fleet?: InstanceConfig[];
1127
+ /**
1128
+ * Custom machine image (optional)
1129
+ * If not specified, uses the provider's default Linux image
1130
+ */
1131
+ image?: string;
1132
+ /**
1133
+ * Server mode (EC2) configuration
1134
+ */
1135
+ server?: {
1136
+ instanceType?: string;
1137
+ ami?: string;
1138
+ keyPair?: string;
1139
+ autoScaling?: {
1140
+ min?: number;
1141
+ max?: number;
1142
+ desired?: number;
1143
+ targetCPU?: number;
1144
+ scaleUpCooldown?: number;
1145
+ scaleDownCooldown?: number;
1146
+ };
1147
+ loadBalancer?: {
1148
+ type?: string;
1149
+ healthCheck?: {
1150
+ path?: string;
1151
+ interval?: number;
1152
+ timeout?: number;
1153
+ healthyThreshold?: number;
1154
+ unhealthyThreshold?: number;
1155
+ };
1156
+ stickySession?: {
1157
+ enabled?: boolean;
1158
+ duration?: number;
1159
+ };
1160
+ };
1161
+ userData?: string | {
1162
+ packages?: string[];
1163
+ commands?: string[];
1164
+ };
1165
+ };
1166
+ /**
1167
+ * Serverless configuration (ECS/Lambda)
1168
+ */
1169
+ serverless?: {
1170
+ cpu?: number;
1171
+ memory?: number;
1172
+ desiredCount?: number;
1173
+ };
1174
+ /**
1175
+ * Fargate configuration
1176
+ */
1177
+ fargate?: {
1178
+ taskDefinition?: {
1179
+ cpu?: string;
1180
+ memory?: string;
1181
+ containerDefinitions?: Array<{
1182
+ name?: string;
1183
+ image?: string;
1184
+ portMappings?: Array<{
1185
+ containerPort?: number;
1186
+ }>;
1187
+ environment?: unknown[];
1188
+ secrets?: unknown[];
1189
+ }>;
1190
+ };
1191
+ service?: {
1192
+ desiredCount?: number;
1193
+ healthCheck?: {
1194
+ path?: string;
1195
+ interval?: number;
1196
+ timeout?: number;
1197
+ healthyThreshold?: number;
1198
+ unhealthyThreshold?: number;
1199
+ };
1200
+ serviceDiscovery?: {
1201
+ enabled?: boolean;
1202
+ namespace?: string;
1203
+ };
1204
+ autoScaling?: {
1205
+ min?: number;
1206
+ max?: number;
1207
+ targetCPU?: number;
1208
+ targetMemory?: number;
1209
+ };
1210
+ };
1211
+ loadBalancer?: {
1212
+ type?: string;
1213
+ customDomain?: {
1214
+ domain?: string;
1215
+ certificateArn?: string;
1216
+ };
1217
+ };
1218
+ };
1219
+ /**
1220
+ * Microservices configuration
1221
+ */
1222
+ services?: Array<{
1223
+ name: string;
1224
+ type?: string;
1225
+ taskDefinition?: {
1226
+ cpu?: string;
1227
+ memory?: string;
1228
+ containerDefinitions?: Array<{
1229
+ name?: string;
1230
+ image?: string;
1231
+ portMappings?: Array<{
1232
+ containerPort?: number;
1233
+ }>;
1234
+ healthCheck?: {
1235
+ command?: string[];
1236
+ interval?: number;
1237
+ timeout?: number;
1238
+ retries?: number;
1239
+ };
1240
+ }>;
1241
+ };
1242
+ service?: {
1243
+ desiredCount?: number;
1244
+ serviceDiscovery?: {
1245
+ enabled?: boolean;
1246
+ namespace?: string;
1247
+ };
1248
+ autoScaling?: {
1249
+ min?: number;
1250
+ max?: number;
1251
+ targetCPU?: number;
1252
+ };
1253
+ };
1254
+ }>;
1255
+ /**
1256
+ * Auto Scaling configuration
1257
+ */
1258
+ autoScaling?: {
1259
+ /** Minimum number of instances @default 1 */
1260
+ min?: number;
1261
+ /** Maximum number of instances @default instances value */
1262
+ max?: number;
1263
+ /** Desired number of instances @default instances value */
1264
+ desired?: number;
1265
+ /** CPU threshold to scale up (%) @default 70 */
1266
+ scaleUpThreshold?: number;
1267
+ /** CPU threshold to scale down (%) @default 30 */
1268
+ scaleDownThreshold?: number;
1269
+ /** Cooldown in seconds @default 300 */
1270
+ cooldown?: number;
1271
+ };
1272
+ /**
1273
+ * Root disk configuration
1274
+ */
1275
+ disk?: {
1276
+ /** Size in GB @default 20 */
1277
+ size?: number;
1278
+ /** Disk type @default 'ssd' */
1279
+ type?: 'standard' | 'ssd' | 'premium';
1280
+ /** Enable encryption @default true */
1281
+ encrypted?: boolean;
1282
+ };
1283
+ /**
1284
+ * SSH key name for instance access
1285
+ */
1286
+ sshKey?: string;
1287
+ /**
1288
+ * Enable detailed monitoring
1289
+ * @default false
1290
+ */
1291
+ monitoring?: boolean;
1292
+ /**
1293
+ * Spot/preemptible instance settings (when using fleet)
1294
+ */
1295
+ spotConfig?: {
1296
+ /** Base capacity that must be on-demand @default 1 */
1297
+ baseCapacity?: number;
1298
+ /** % of instances above base that are on-demand @default 100 */
1299
+ onDemandPercentage?: number;
1300
+ /** Allocation strategy @default 'capacity-optimized' */
1301
+ strategy?: 'lowest-price' | 'capacity-optimized';
1302
+ };
1303
+ /**
1304
+ * Application runtime to install on the instance.
1305
+ * Shared by every site that gets deployed to this compute.
1306
+ */
1307
+ runtime?: 'bun' | 'node' | 'deno';
1308
+ /**
1309
+ * Pinned runtime version (e.g. '1.3.13'). Defaults to 'latest'.
1310
+ */
1311
+ runtimeVersion?: string;
1312
+ /**
1313
+ * Extra OS packages to install at bootstrap (dnf/apt names).
1314
+ * Latest available version is always installed — no pinning.
1315
+ * Example: ['sqlite', 'imagemagick']
1316
+ */
1317
+ systemPackages?: string[];
1318
+ /**
1319
+ * Open port 22 (SSH) to 0.0.0.0/0 in the instance security group.
1320
+ * Default is `false` — deploys use SSM Run Command (no SSH needed) and
1321
+ * shell access can be obtained via SSM Session Manager
1322
+ * (`aws ssm start-session --target <instance-id>`), so SSH is only
1323
+ * useful for legacy tooling.
1324
+ *
1325
+ * Set to `true` only if you need traditional SSH access.
1326
+ */
1327
+ allowSsh?: boolean;
1328
+ }
1329
+ export interface DatabaseItemConfig {
1330
+ engine?: 'dynamodb' | 'postgres' | 'mysql';
1331
+ partitionKey?: string | {
1332
+ name: string;
1333
+ type: string;
1334
+ };
1335
+ sortKey?: string | {
1336
+ name: string;
1337
+ type: string;
1338
+ };
1339
+ username?: string;
1340
+ password?: string;
1341
+ storage?: number;
1342
+ instanceClass?: string;
1343
+ version?: string;
1344
+ allocatedStorage?: number;
1345
+ maxAllocatedStorage?: number;
1346
+ multiAZ?: boolean;
1347
+ backupRetentionDays?: number;
1348
+ preferredBackupWindow?: string;
1349
+ preferredMaintenanceWindow?: string;
1350
+ deletionProtection?: boolean;
1351
+ streamEnabled?: boolean;
1352
+ pointInTimeRecovery?: boolean;
1353
+ billingMode?: string;
1354
+ parameters?: Record<string, string | number>;
1355
+ databaseName?: string;
1356
+ enablePerformanceInsights?: boolean;
1357
+ performanceInsightsRetention?: number;
1358
+ tables?: Record<string, {
1359
+ name?: string;
1360
+ partitionKey?: string | {
1361
+ name: string;
1362
+ type: string;
1363
+ };
1364
+ sortKey?: string | {
1365
+ name: string;
1366
+ type: string;
1367
+ };
1368
+ billing?: string;
1369
+ billingMode?: string;
1370
+ streamEnabled?: boolean;
1371
+ pointInTimeRecovery?: boolean;
1372
+ globalSecondaryIndexes?: Array<{
1373
+ name: string;
1374
+ partitionKey: {
1375
+ name: string;
1376
+ type: string;
1377
+ };
1378
+ sortKey?: {
1379
+ name: string;
1380
+ type: string;
1381
+ };
1382
+ projection: string;
1383
+ }>;
1384
+ }>;
1385
+ }
1386
+ export interface CdnItemConfig {
1387
+ origin?: string;
1388
+ customDomain?: string | {
1389
+ domain: string;
1390
+ certificateArn?: string;
1391
+ };
1392
+ certificateArn?: string;
1393
+ /**
1394
+ * Custom domain configuration
1395
+ */
1396
+ domain?: string;
1397
+ /**
1398
+ * Enable CDN
1399
+ */
1400
+ enabled?: boolean;
1401
+ /**
1402
+ * Cache policy configuration
1403
+ */
1404
+ cachePolicy?: {
1405
+ minTTL?: number;
1406
+ defaultTTL?: number;
1407
+ maxTTL?: number;
1408
+ };
1409
+ /**
1410
+ * TTL settings
1411
+ */
1412
+ minTTL?: number;
1413
+ defaultTTL?: number;
1414
+ maxTTL?: number;
1415
+ /**
1416
+ * Enable compression
1417
+ */
1418
+ compress?: boolean;
1419
+ /**
1420
+ * Enable HTTP/3
1421
+ */
1422
+ http3?: boolean;
1423
+ /**
1424
+ * Custom error pages
1425
+ */
1426
+ errorPages?: Record<number | string, string>;
1427
+ /**
1428
+ * Origins configuration
1429
+ */
1430
+ origins?: Array<{
1431
+ type?: string;
1432
+ pathPattern?: string;
1433
+ domainName?: string;
1434
+ originId?: string;
1435
+ }>;
1436
+ /**
1437
+ * Edge functions for Lambda@Edge
1438
+ */
1439
+ edgeFunctions?: Array<{
1440
+ eventType?: string;
1441
+ functionArn?: string;
1442
+ name?: string;
1443
+ }>;
1444
+ }
1445
+ /**
1446
+ * Lambda trigger configuration for SQS queues
1447
+ */
1448
+ export interface QueueLambdaTrigger {
1449
+ /**
1450
+ * Name of the Lambda function to trigger (references functions config)
1451
+ * @example 'processOrders' - references infrastructure.functions.processOrders
1452
+ */
1453
+ functionName: string;
1454
+ /**
1455
+ * Number of messages to process in each batch
1456
+ * @default 10
1457
+ */
1458
+ batchSize?: number;
1459
+ /**
1460
+ * Maximum time to gather messages before invoking (0-300 seconds)
1461
+ * Helps reduce Lambda invocations for low-traffic queues
1462
+ * @default 0
1463
+ */
1464
+ batchWindow?: number;
1465
+ /**
1466
+ * Enable partial batch responses (report individual failures)
1467
+ * @default true
1468
+ */
1469
+ reportBatchItemFailures?: boolean;
1470
+ /**
1471
+ * Maximum concurrency for Lambda invocations (2-1000)
1472
+ * Limits how many concurrent Lambda instances process this queue
1473
+ */
1474
+ maxConcurrency?: number;
1475
+ /**
1476
+ * Filter pattern to selectively process messages
1477
+ * @example { body: { type: ['order'] } }
1478
+ */
1479
+ filterPattern?: Record<string, unknown>;
1480
+ }
1481
+ /**
1482
+ * CloudWatch alarm configuration for SQS queues
1483
+ */
1484
+ export interface QueueAlarms {
1485
+ /**
1486
+ * Enable all default alarms
1487
+ * @default false
1488
+ */
1489
+ enabled?: boolean;
1490
+ /**
1491
+ * Alarm when queue depth exceeds this threshold
1492
+ * @default 1000
1493
+ */
1494
+ queueDepthThreshold?: number;
1495
+ /**
1496
+ * Alarm when oldest message age exceeds this (in seconds)
1497
+ * @default 3600 (1 hour)
1498
+ */
1499
+ messageAgeThreshold?: number;
1500
+ /**
1501
+ * Alarm when DLQ has any messages
1502
+ * @default true when deadLetterQueue is enabled
1503
+ */
1504
+ dlqAlarm?: boolean;
1505
+ /**
1506
+ * SNS topic ARN for alarm notifications
1507
+ */
1508
+ notificationTopicArn?: string;
1509
+ /**
1510
+ * Email addresses to notify (creates SNS topic automatically)
1511
+ */
1512
+ notificationEmails?: string[];
1513
+ }
1514
+ /**
1515
+ * SNS subscription configuration for SQS queues
1516
+ */
1517
+ export interface QueueSnsSubscription {
1518
+ /**
1519
+ * SNS topic ARN to subscribe to
1520
+ */
1521
+ topicArn?: string;
1522
+ /**
1523
+ * SNS topic name (references infrastructure or creates new)
1524
+ */
1525
+ topicName?: string;
1526
+ /**
1527
+ * Filter policy for selective message delivery
1528
+ * @example { eventType: ['order.created', 'order.updated'] }
1529
+ */
1530
+ filterPolicy?: Record<string, string[]>;
1531
+ /**
1532
+ * Apply filter to message attributes (default) or body
1533
+ * @default 'MessageAttributes'
1534
+ */
1535
+ filterPolicyScope?: 'MessageAttributes' | 'MessageBody';
1536
+ /**
1537
+ * Enable raw message delivery (no SNS envelope)
1538
+ * @default false
1539
+ */
1540
+ rawMessageDelivery?: boolean;
1541
+ }
1542
+ /**
1543
+ * Queue (SQS) Configuration
1544
+ * Defines message queue settings for async processing
1545
+ *
1546
+ * @example Standard queue with Lambda trigger
1547
+ * queues: {
1548
+ * orders: {
1549
+ * visibilityTimeout: 60,
1550
+ * deadLetterQueue: true,
1551
+ * trigger: {
1552
+ * functionName: 'processOrders',
1553
+ * batchSize: 10,
1554
+ * },
1555
+ * }
1556
+ * }
1557
+ *
1558
+ * @example FIFO queue with alarms
1559
+ * queues: {
1560
+ * transactions: {
1561
+ * fifo: true,
1562
+ * contentBasedDeduplication: true,
1563
+ * alarms: {
1564
+ * enabled: true,
1565
+ * queueDepthThreshold: 500,
1566
+ * notificationEmails: ['ops@example.com'],
1567
+ * },
1568
+ * }
1569
+ * }
1570
+ *
1571
+ * @example Queue subscribed to SNS topic
1572
+ * queues: {
1573
+ * notifications: {
1574
+ * subscribe: {
1575
+ * topicArn: 'arn:aws:sns:us-east-1:123456789:events',
1576
+ * filterPolicy: { eventType: ['user.created'] },
1577
+ * },
1578
+ * }
1579
+ * }
1580
+ */
1581
+ export interface QueueItemConfig {
1582
+ /**
1583
+ * Enable FIFO (First-In-First-Out) queue
1584
+ * FIFO queues guarantee message ordering and exactly-once processing
1585
+ * @default false
1586
+ */
1587
+ fifo?: boolean;
1588
+ /**
1589
+ * Time (in seconds) a message is invisible after being received
1590
+ * Should be long enough for your consumer to process the message
1591
+ * @default 30
1592
+ */
1593
+ visibilityTimeout?: number;
1594
+ /**
1595
+ * Time (in seconds) messages are retained in the queue
1596
+ * Valid range: 60 (1 minute) to 1209600 (14 days)
1597
+ * @default 345600 (4 days)
1598
+ */
1599
+ messageRetentionPeriod?: number;
1600
+ /**
1601
+ * Time (in seconds) to delay message delivery
1602
+ * Useful for scheduling or rate limiting
1603
+ * Valid range: 0 to 900 (15 minutes)
1604
+ * @default 0
1605
+ */
1606
+ delaySeconds?: number;
1607
+ /**
1608
+ * Maximum message size in bytes
1609
+ * Valid range: 1024 (1 KB) to 262144 (256 KB)
1610
+ * @default 262144 (256 KB)
1611
+ */
1612
+ maxMessageSize?: number;
1613
+ /**
1614
+ * Time (in seconds) to wait for messages when polling
1615
+ * Use 1-20 for long polling (recommended), 0 for short polling
1616
+ * Long polling reduces costs and improves responsiveness
1617
+ * @default 0
1618
+ */
1619
+ receiveMessageWaitTime?: number;
1620
+ /**
1621
+ * Enable dead letter queue for failed messages
1622
+ * Messages that fail processing will be moved to a DLQ
1623
+ * @default false
1624
+ */
1625
+ deadLetterQueue?: boolean;
1626
+ /**
1627
+ * Number of times a message can be received before going to DLQ
1628
+ * Only used when deadLetterQueue is true
1629
+ * @default 3
1630
+ */
1631
+ maxReceiveCount?: number;
1632
+ /**
1633
+ * Enable content-based deduplication (FIFO queues only)
1634
+ * Uses SHA-256 hash of message body as deduplication ID
1635
+ * @default false
1636
+ */
1637
+ contentBasedDeduplication?: boolean;
1638
+ /**
1639
+ * Enable server-side encryption
1640
+ * @default true
1641
+ */
1642
+ encrypted?: boolean;
1643
+ /**
1644
+ * Custom KMS key ID for encryption
1645
+ * If not specified, uses AWS managed key
1646
+ */
1647
+ kmsKeyId?: string;
1648
+ /**
1649
+ * Lambda function trigger configuration
1650
+ * Automatically invokes a Lambda when messages arrive
1651
+ *
1652
+ * @example
1653
+ * trigger: {
1654
+ * functionName: 'processOrders',
1655
+ * batchSize: 10,
1656
+ * batchWindow: 30,
1657
+ * }
1658
+ */
1659
+ trigger?: QueueLambdaTrigger;
1660
+ /**
1661
+ * CloudWatch alarms for queue monitoring
1662
+ * Creates alarms for queue depth, message age, and DLQ
1663
+ *
1664
+ * @example
1665
+ * alarms: {
1666
+ * enabled: true,
1667
+ * queueDepthThreshold: 500,
1668
+ * notificationEmails: ['ops@example.com'],
1669
+ * }
1670
+ */
1671
+ alarms?: QueueAlarms;
1672
+ /**
1673
+ * Subscribe this queue to an SNS topic
1674
+ * Enables fan-out patterns where one message reaches multiple queues
1675
+ *
1676
+ * @example
1677
+ * subscribe: {
1678
+ * topicArn: 'arn:aws:sns:us-east-1:123456789:events',
1679
+ * filterPolicy: { eventType: ['order.created'] },
1680
+ * }
1681
+ */
1682
+ subscribe?: QueueSnsSubscription;
1683
+ /**
1684
+ * Custom tags for the queue
1685
+ * Useful for cost allocation and organization
1686
+ */
1687
+ tags?: Record<string, string>;
1688
+ }
1689
+ /**
1690
+ * Queue configuration presets for common use cases
1691
+ * Use these to quickly configure queues with sensible defaults
1692
+ *
1693
+ * @example Basic usage
1694
+ * import { QueuePresets } from '@ts-cloud/core'
1695
+ *
1696
+ * queues: {
1697
+ * jobs: QueuePresets.backgroundJobs,
1698
+ * orders: QueuePresets.fifo,
1699
+ * events: QueuePresets.highThroughput,
1700
+ * }
1701
+ *
1702
+ * @example With Lambda trigger
1703
+ * queues: {
1704
+ * orders: {
1705
+ * ...QueuePresets.backgroundJobs,
1706
+ * trigger: { functionName: 'processOrders' },
1707
+ * },
1708
+ * }
1709
+ *
1710
+ * @example With monitoring
1711
+ * queues: {
1712
+ * critical: {
1713
+ * ...QueuePresets.monitored,
1714
+ * alarms: {
1715
+ * ...QueuePresets.monitored.alarms,
1716
+ * notificationEmails: ['ops@example.com'],
1717
+ * },
1718
+ * },
1719
+ * }
1720
+ */
1721
+ export declare const QueuePresets: {
1722
+ backgroundJobs: QueueItemConfig;
1723
+ fifo: QueueItemConfig;
1724
+ highThroughput: QueueItemConfig;
1725
+ delayed: QueueItemConfig;
1726
+ longRunning: QueueItemConfig;
1727
+ monitored: QueueItemConfig;
1728
+ lambdaOptimized: QueueItemConfig;
1729
+ fanOut: QueueItemConfig;
1730
+ };
1731
+ /**
1732
+ * Realtime deployment mode
1733
+ * - 'serverless': Uses API Gateway WebSocket + Lambda (auto-scales, pay-per-use)
1734
+ * - 'server': Uses ts-broadcasting Bun WebSocket server on EC2/ECS (lowest latency)
1735
+ */
1736
+ export type RealtimeMode = 'serverless' | 'server';
1737
+ /**
1738
+ * Server mode configuration (ts-broadcasting)
1739
+ * High-performance Bun WebSocket server for EC2/ECS deployments
1740
+ */
1741
+ export interface RealtimeServerConfig {
1742
+ /**
1743
+ * Server host binding
1744
+ * @default '0.0.0.0'
1745
+ */
1746
+ host?: string;
1747
+ /**
1748
+ * Server port
1749
+ * @default 6001
1750
+ */
1751
+ port?: number;
1752
+ /**
1753
+ * WebSocket scheme
1754
+ * @default 'wss' in production, 'ws' in development
1755
+ */
1756
+ scheme?: 'ws' | 'wss';
1757
+ /**
1758
+ * Driver to use
1759
+ * @default 'bun'
1760
+ */
1761
+ driver?: 'bun' | 'reverb' | 'pusher' | 'ably';
1762
+ /**
1763
+ * Idle connection timeout in seconds
1764
+ * @default 120
1765
+ */
1766
+ idleTimeout?: number;
1767
+ /**
1768
+ * Maximum message payload size in bytes
1769
+ * @default 16777216 (16 MB)
1770
+ */
1771
+ maxPayloadLength?: number;
1772
+ /**
1773
+ * Backpressure limit in bytes
1774
+ * @default 1048576 (1 MB)
1775
+ */
1776
+ backpressureLimit?: number;
1777
+ /**
1778
+ * Close connection when backpressure limit is reached
1779
+ * @default false
1780
+ */
1781
+ closeOnBackpressureLimit?: boolean;
1782
+ /**
1783
+ * Send WebSocket ping frames
1784
+ * @default true
1785
+ */
1786
+ sendPings?: boolean;
1787
+ /**
1788
+ * Enable per-message deflate compression
1789
+ * @default true
1790
+ */
1791
+ perMessageDeflate?: boolean;
1792
+ /**
1793
+ * Redis configuration for horizontal scaling
1794
+ * Enables multiple server instances to share state
1795
+ */
1796
+ redis?: RealtimeRedisConfig;
1797
+ /**
1798
+ * Rate limiting configuration
1799
+ */
1800
+ rateLimit?: RealtimeRateLimitConfig;
1801
+ /**
1802
+ * Message encryption configuration
1803
+ */
1804
+ encryption?: RealtimeEncryptionConfig;
1805
+ /**
1806
+ * Webhook notifications configuration
1807
+ */
1808
+ webhooks?: RealtimeWebhooksConfig;
1809
+ /**
1810
+ * Queue configuration for background jobs
1811
+ */
1812
+ queue?: RealtimeQueueConfig;
1813
+ /**
1814
+ * Load management configuration
1815
+ */
1816
+ loadManagement?: RealtimeLoadConfig;
1817
+ /**
1818
+ * Prometheus metrics endpoint
1819
+ * @default false
1820
+ */
1821
+ metrics?: boolean | {
1822
+ enabled: boolean;
1823
+ path?: string;
1824
+ };
1825
+ /**
1826
+ * Health check endpoint path
1827
+ * @default '/health'
1828
+ */
1829
+ healthCheckPath?: string;
1830
+ /**
1831
+ * Number of server instances to run
1832
+ * Used when deploying to EC2/ECS
1833
+ * @default 1
1834
+ */
1835
+ instances?: number;
1836
+ /**
1837
+ * Auto-scaling configuration for EC2/ECS
1838
+ */
1839
+ autoScaling?: {
1840
+ min?: number;
1841
+ max?: number;
1842
+ targetCPU?: number;
1843
+ targetConnections?: number;
1844
+ };
1845
+ }
1846
+ /**
1847
+ * Redis configuration for ts-broadcasting horizontal scaling
1848
+ */
1849
+ export interface RealtimeRedisConfig {
1850
+ /**
1851
+ * Enable Redis adapter
1852
+ * @default false
1853
+ */
1854
+ enabled?: boolean;
1855
+ /**
1856
+ * Redis host
1857
+ * @default 'localhost'
1858
+ */
1859
+ host?: string;
1860
+ /**
1861
+ * Redis port
1862
+ * @default 6379
1863
+ */
1864
+ port?: number;
1865
+ /**
1866
+ * Redis password
1867
+ */
1868
+ password?: string;
1869
+ /**
1870
+ * Redis database number
1871
+ * @default 0
1872
+ */
1873
+ database?: number;
1874
+ /**
1875
+ * Redis connection URL (overrides host/port)
1876
+ * @example 'redis://user:pass@localhost:6379/0'
1877
+ */
1878
+ url?: string;
1879
+ /**
1880
+ * Key prefix for Redis keys
1881
+ * @default 'broadcasting:'
1882
+ */
1883
+ keyPrefix?: string;
1884
+ /**
1885
+ * Use existing ElastiCache from cache config
1886
+ * References infrastructure.cache
1887
+ */
1888
+ useElastiCache?: boolean;
1889
+ }
1890
+ /**
1891
+ * Rate limiting for WebSocket connections
1892
+ */
1893
+ export interface RealtimeRateLimitConfig {
1894
+ /**
1895
+ * Enable rate limiting
1896
+ * @default true
1897
+ */
1898
+ enabled?: boolean;
1899
+ /**
1900
+ * Maximum messages per window
1901
+ * @default 100
1902
+ */
1903
+ max?: number;
1904
+ /**
1905
+ * Time window in milliseconds
1906
+ * @default 60000 (1 minute)
1907
+ */
1908
+ window?: number;
1909
+ /**
1910
+ * Apply rate limit per channel
1911
+ * @default true
1912
+ */
1913
+ perChannel?: boolean;
1914
+ /**
1915
+ * Apply rate limit per user
1916
+ * @default true
1917
+ */
1918
+ perUser?: boolean;
1919
+ }
1920
+ /**
1921
+ * Message encryption configuration
1922
+ */
1923
+ export interface RealtimeEncryptionConfig {
1924
+ /**
1925
+ * Enable message encryption
1926
+ * @default false
1927
+ */
1928
+ enabled?: boolean;
1929
+ /**
1930
+ * Encryption algorithm
1931
+ * @default 'aes-256-gcm'
1932
+ */
1933
+ algorithm?: 'aes-256-gcm' | 'aes-128-gcm';
1934
+ /**
1935
+ * Key rotation interval in milliseconds
1936
+ * @default 86400000 (24 hours)
1937
+ */
1938
+ keyRotationInterval?: number;
1939
+ }
1940
+ /**
1941
+ * Webhook notifications for realtime events
1942
+ */
1943
+ export interface RealtimeWebhooksConfig {
1944
+ /**
1945
+ * Enable webhooks
1946
+ * @default false
1947
+ */
1948
+ enabled?: boolean;
1949
+ /**
1950
+ * Webhook endpoints for different events
1951
+ */
1952
+ endpoints?: {
1953
+ /**
1954
+ * Called when a client connects
1955
+ */
1956
+ connection?: string;
1957
+ /**
1958
+ * Called when a client subscribes to a channel
1959
+ */
1960
+ subscribe?: string;
1961
+ /**
1962
+ * Called when a client unsubscribes
1963
+ */
1964
+ unsubscribe?: string;
1965
+ /**
1966
+ * Called when a client disconnects
1967
+ */
1968
+ disconnect?: string;
1969
+ /**
1970
+ * Custom event webhooks
1971
+ */
1972
+ [event: string]: string | undefined;
1973
+ };
1974
+ }
1975
+ /**
1976
+ * Queue configuration for background broadcasting
1977
+ */
1978
+ export interface RealtimeQueueConfig {
1979
+ /**
1980
+ * Enable queue for broadcast operations
1981
+ * @default false
1982
+ */
1983
+ enabled?: boolean;
1984
+ /**
1985
+ * Default queue name
1986
+ * @default 'broadcasts'
1987
+ */
1988
+ defaultQueue?: string;
1989
+ /**
1990
+ * Retry configuration
1991
+ */
1992
+ retry?: {
1993
+ attempts?: number;
1994
+ backoff?: {
1995
+ type: 'fixed' | 'exponential';
1996
+ delay: number;
1997
+ };
1998
+ };
1999
+ /**
2000
+ * Dead letter queue for failed broadcasts
2001
+ */
2002
+ deadLetter?: {
2003
+ enabled?: boolean;
2004
+ maxRetries?: number;
2005
+ };
2006
+ }
2007
+ /**
2008
+ * Load management for server mode
2009
+ */
2010
+ export interface RealtimeLoadConfig {
2011
+ /**
2012
+ * Enable load management
2013
+ * @default true
2014
+ */
2015
+ enabled?: boolean;
2016
+ /**
2017
+ * Maximum concurrent connections
2018
+ * @default 10000
2019
+ */
2020
+ maxConnections?: number;
2021
+ /**
2022
+ * Maximum subscriptions per connection
2023
+ * @default 100
2024
+ */
2025
+ maxSubscriptionsPerConnection?: number;
2026
+ /**
2027
+ * CPU threshold to start shedding load (0-1)
2028
+ * @default 0.8
2029
+ */
2030
+ shedLoadThreshold?: number;
2031
+ }
2032
+ /**
2033
+ * Channel authorization configuration
2034
+ */
2035
+ export interface RealtimeChannelAuth {
2036
+ /**
2037
+ * Lambda function name for channel authorization
2038
+ * Called when clients join private/presence channels
2039
+ * @example 'authorizeChannel'
2040
+ */
2041
+ functionName?: string;
2042
+ /**
2043
+ * Authorization endpoint URL (if using external auth)
2044
+ * @example 'https://api.example.com/broadcasting/auth'
2045
+ */
2046
+ endpoint?: string;
2047
+ /**
2048
+ * JWT secret for token validation
2049
+ * Can reference Secrets Manager: '{{resolve:secretsmanager:my-secret}}'
2050
+ */
2051
+ jwtSecret?: string;
2052
+ /**
2053
+ * Token expiration time in seconds
2054
+ * @default 3600
2055
+ */
2056
+ tokenExpiration?: number;
2057
+ }
2058
+ /**
2059
+ * Presence channel configuration
2060
+ */
2061
+ export interface RealtimePresenceConfig {
2062
+ /**
2063
+ * Enable presence channels (who's online)
2064
+ * @default true
2065
+ */
2066
+ enabled?: boolean;
2067
+ /**
2068
+ * Maximum members per presence channel
2069
+ * @default 100
2070
+ */
2071
+ maxMembers?: number;
2072
+ /**
2073
+ * How often to send presence heartbeats (seconds)
2074
+ * @default 30
2075
+ */
2076
+ heartbeatInterval?: number;
2077
+ /**
2078
+ * Time before considering a member offline (seconds)
2079
+ * @default 60
2080
+ */
2081
+ inactivityTimeout?: number;
2082
+ }
2083
+ /**
2084
+ * Connection storage configuration
2085
+ */
2086
+ export interface RealtimeStorageConfig {
2087
+ /**
2088
+ * Storage type for connection management
2089
+ * - 'dynamodb': DynamoDB tables (recommended, auto-scales)
2090
+ * - 'elasticache': Redis cluster (lowest latency)
2091
+ * @default 'dynamodb'
2092
+ */
2093
+ type?: 'dynamodb' | 'elasticache';
2094
+ /**
2095
+ * DynamoDB table configuration
2096
+ */
2097
+ dynamodb?: {
2098
+ /**
2099
+ * Billing mode for DynamoDB
2100
+ * @default 'PAY_PER_REQUEST'
2101
+ */
2102
+ billingMode?: 'PAY_PER_REQUEST' | 'PROVISIONED';
2103
+ /**
2104
+ * Read capacity units (only for PROVISIONED)
2105
+ * @default 5
2106
+ */
2107
+ readCapacity?: number;
2108
+ /**
2109
+ * Write capacity units (only for PROVISIONED)
2110
+ * @default 5
2111
+ */
2112
+ writeCapacity?: number;
2113
+ /**
2114
+ * Enable point-in-time recovery
2115
+ * @default false
2116
+ */
2117
+ pointInTimeRecovery?: boolean;
2118
+ /**
2119
+ * TTL for connection records (seconds)
2120
+ * @default 86400 (24 hours)
2121
+ */
2122
+ connectionTTL?: number;
2123
+ };
2124
+ /**
2125
+ * ElastiCache configuration (if using Redis)
2126
+ */
2127
+ elasticache?: {
2128
+ /**
2129
+ * Node type for Redis cluster
2130
+ * @default 'cache.t3.micro'
2131
+ */
2132
+ nodeType?: string;
2133
+ /**
2134
+ * Number of cache nodes
2135
+ * @default 1
2136
+ */
2137
+ numNodes?: number;
2138
+ };
2139
+ }
2140
+ /**
2141
+ * WebSocket scaling configuration
2142
+ */
2143
+ export interface RealtimeScalingConfig {
2144
+ /**
2145
+ * Maximum concurrent connections
2146
+ * @default 10000
2147
+ */
2148
+ maxConnections?: number;
2149
+ /**
2150
+ * Message throughput limit per second
2151
+ * @default 1000
2152
+ */
2153
+ messagesPerSecond?: number;
2154
+ /**
2155
+ * Lambda memory for WebSocket handlers (MB)
2156
+ * @default 256
2157
+ */
2158
+ handlerMemory?: number;
2159
+ /**
2160
+ * Lambda timeout for WebSocket handlers (seconds)
2161
+ * @default 30
2162
+ */
2163
+ handlerTimeout?: number;
2164
+ /**
2165
+ * Enable Lambda provisioned concurrency for low latency
2166
+ */
2167
+ provisionedConcurrency?: number;
2168
+ }
2169
+ /**
2170
+ * Realtime monitoring and alarms
2171
+ */
2172
+ export interface RealtimeMonitoringConfig {
2173
+ /**
2174
+ * Enable CloudWatch alarms
2175
+ * @default false
2176
+ */
2177
+ enabled?: boolean;
2178
+ /**
2179
+ * Alert when concurrent connections exceed threshold
2180
+ * @default 8000
2181
+ */
2182
+ connectionThreshold?: number;
2183
+ /**
2184
+ * Alert when message errors exceed threshold per minute
2185
+ * @default 100
2186
+ */
2187
+ errorThreshold?: number;
2188
+ /**
2189
+ * Alert when latency exceeds threshold (ms)
2190
+ * @default 1000
2191
+ */
2192
+ latencyThreshold?: number;
2193
+ /**
2194
+ * SNS topic ARN for alarm notifications
2195
+ */
2196
+ notificationTopicArn?: string;
2197
+ /**
2198
+ * Email addresses for alarm notifications
2199
+ */
2200
+ notificationEmails?: string[];
2201
+ }
2202
+ /**
2203
+ * Realtime event hooks
2204
+ */
2205
+ export interface RealtimeHooksConfig {
2206
+ /**
2207
+ * Lambda function called on new connections
2208
+ * Receives: { connectionId, requestContext }
2209
+ */
2210
+ onConnect?: string;
2211
+ /**
2212
+ * Lambda function called on disconnections
2213
+ * Receives: { connectionId, requestContext }
2214
+ */
2215
+ onDisconnect?: string;
2216
+ /**
2217
+ * Lambda function called for incoming messages
2218
+ * Receives: { connectionId, body, requestContext }
2219
+ */
2220
+ onMessage?: string;
2221
+ /**
2222
+ * Lambda function called when clients subscribe to channels
2223
+ * Receives: { connectionId, channel, auth }
2224
+ */
2225
+ onSubscribe?: string;
2226
+ /**
2227
+ * Lambda function called when clients unsubscribe
2228
+ * Receives: { connectionId, channel }
2229
+ */
2230
+ onUnsubscribe?: string;
2231
+ }
2232
+ /**
2233
+ * Realtime (WebSocket) Configuration
2234
+ * Provides Laravel Echo / Pusher-compatible broadcasting
2235
+ *
2236
+ * @example Serverless mode (API Gateway WebSocket)
2237
+ * realtime: {
2238
+ * enabled: true,
2239
+ * mode: 'serverless',
2240
+ * channels: { public: true, private: true, presence: true },
2241
+ * }
2242
+ *
2243
+ * @example Server mode (ts-broadcasting on EC2/ECS)
2244
+ * realtime: {
2245
+ * enabled: true,
2246
+ * mode: 'server',
2247
+ * server: {
2248
+ * port: 6001,
2249
+ * redis: { enabled: true, host: 'redis.example.com' },
2250
+ * rateLimit: { max: 100, window: 60000 },
2251
+ * },
2252
+ * }
2253
+ *
2254
+ * @example Production server mode with clustering
2255
+ * realtime: {
2256
+ * enabled: true,
2257
+ * mode: 'server',
2258
+ * server: {
2259
+ * port: 6001,
2260
+ * instances: 3,
2261
+ * redis: { enabled: true, useElastiCache: true },
2262
+ * autoScaling: { min: 2, max: 10, targetCPU: 70 },
2263
+ * metrics: true,
2264
+ * },
2265
+ * channels: { public: true, private: true, presence: true },
2266
+ * }
2267
+ *
2268
+ * @example Integration with Stacks.js
2269
+ * // In your Stacks app:
2270
+ * import { Broadcast } from '@stacksjs/broadcast'
2271
+ *
2272
+ * // Broadcast to a channel
2273
+ * Broadcast.channel('orders').emit('order.created', { id: 123 })
2274
+ *
2275
+ * // Client-side (similar to Laravel Echo)
2276
+ * Echo.channel('orders').listen('order.created', (e) => {
2277
+ * console.log('New order:', e.id)
2278
+ * })
2279
+ *
2280
+ * // Private channel
2281
+ * Echo.private(`user.${userId}`).listen('notification', (e) => {
2282
+ * console.log('Private notification:', e)
2283
+ * })
2284
+ *
2285
+ * // Presence channel
2286
+ * Echo.join('chat-room')
2287
+ * .here((users) => console.log('Online:', users))
2288
+ * .joining((user) => console.log('Joined:', user))
2289
+ * .leaving((user) => console.log('Left:', user))
2290
+ */
2291
+ export interface RealtimeConfig {
2292
+ /**
2293
+ * Enable realtime/WebSocket support
2294
+ * @default false
2295
+ */
2296
+ enabled?: boolean;
2297
+ /**
2298
+ * Deployment mode
2299
+ * - 'serverless': API Gateway WebSocket + Lambda (auto-scales, pay-per-use)
2300
+ * - 'server': ts-broadcasting Bun WebSocket on EC2/ECS (lowest latency)
2301
+ * @default 'serverless'
2302
+ */
2303
+ mode?: RealtimeMode;
2304
+ /**
2305
+ * Custom WebSocket API/server name
2306
+ */
2307
+ name?: string;
2308
+ /**
2309
+ * Server mode configuration (ts-broadcasting)
2310
+ * Only used when mode is 'server'
2311
+ */
2312
+ server?: RealtimeServerConfig;
2313
+ /**
2314
+ * Channel configuration
2315
+ */
2316
+ channels?: {
2317
+ /**
2318
+ * Enable public channels (no auth required)
2319
+ * @default true
2320
+ */
2321
+ public?: boolean;
2322
+ /**
2323
+ * Enable private channels (requires auth)
2324
+ * @default true
2325
+ */
2326
+ private?: boolean;
2327
+ /**
2328
+ * Enable presence channels (track online users)
2329
+ * @default false
2330
+ */
2331
+ presence?: boolean | RealtimePresenceConfig;
2332
+ };
2333
+ /**
2334
+ * Channel authorization configuration
2335
+ */
2336
+ auth?: RealtimeChannelAuth;
2337
+ /**
2338
+ * Connection storage configuration
2339
+ */
2340
+ storage?: RealtimeStorageConfig;
2341
+ /**
2342
+ * Scaling configuration
2343
+ */
2344
+ scaling?: RealtimeScalingConfig;
2345
+ /**
2346
+ * Monitoring and alarms
2347
+ */
2348
+ monitoring?: RealtimeMonitoringConfig;
2349
+ /**
2350
+ * Event hooks (Lambda functions)
2351
+ */
2352
+ hooks?: RealtimeHooksConfig;
2353
+ /**
2354
+ * Custom domain for WebSocket endpoint
2355
+ * @example 'ws.example.com'
2356
+ */
2357
+ customDomain?: string;
2358
+ /**
2359
+ * ACM certificate ARN for custom domain
2360
+ */
2361
+ certificateArn?: string;
2362
+ /**
2363
+ * Enable connection keep-alive pings
2364
+ * @default true
2365
+ */
2366
+ keepAlive?: boolean;
2367
+ /**
2368
+ * Keep-alive interval in seconds
2369
+ * @default 30
2370
+ */
2371
+ keepAliveInterval?: number;
2372
+ /**
2373
+ * Idle connection timeout in seconds
2374
+ * @default 600 (10 minutes)
2375
+ */
2376
+ idleTimeout?: number;
2377
+ /**
2378
+ * Maximum message size in bytes
2379
+ * @default 32768 (32 KB)
2380
+ */
2381
+ maxMessageSize?: number;
2382
+ /**
2383
+ * Enable message compression
2384
+ * @default false
2385
+ */
2386
+ compression?: boolean;
2387
+ /**
2388
+ * Custom tags for all realtime resources
2389
+ */
2390
+ tags?: Record<string, string>;
2391
+ }
2392
+ /**
2393
+ * Realtime configuration presets
2394
+ *
2395
+ * @example Serverless presets
2396
+ * import { RealtimePresets } from '@ts-cloud/core'
2397
+ * realtime: RealtimePresets.serverless.production
2398
+ *
2399
+ * @example Server presets (ts-broadcasting)
2400
+ * realtime: RealtimePresets.server.production
2401
+ */
2402
+ export declare const RealtimePresets: {
2403
+ serverless: {
2404
+ development: RealtimeConfig;
2405
+ production: RealtimeConfig;
2406
+ notifications: RealtimeConfig;
2407
+ };
2408
+ server: {
2409
+ development: RealtimeConfig;
2410
+ production: RealtimeConfig;
2411
+ highPerformance: RealtimeConfig;
2412
+ chat: RealtimeConfig;
2413
+ gaming: RealtimeConfig;
2414
+ single: RealtimeConfig;
2415
+ };
2416
+ };
2417
+ export interface ApiConfig {
2418
+ enabled?: boolean;
2419
+ name?: string;
2420
+ }
2421
+ /**
2422
+ * Load Balancer Configuration
2423
+ * Controls whether and how traffic is load balanced
2424
+ */
2425
+ export interface LoadBalancerConfig {
2426
+ /**
2427
+ * Enable Application Load Balancer
2428
+ * When false, traffic goes directly to EC2 instances
2429
+ * @default true for production with SSL
2430
+ */
2431
+ enabled?: boolean;
2432
+ /**
2433
+ * Load balancer type
2434
+ * - 'application': HTTP/HTTPS traffic (ALB)
2435
+ * - 'network': TCP/UDP traffic (NLB)
2436
+ * @default 'application'
2437
+ */
2438
+ type?: 'application' | 'network';
2439
+ /**
2440
+ * Health check configuration
2441
+ */
2442
+ healthCheck?: {
2443
+ path?: string;
2444
+ interval?: number;
2445
+ timeout?: number;
2446
+ healthyThreshold?: number;
2447
+ unhealthyThreshold?: number;
2448
+ };
2449
+ /**
2450
+ * Idle timeout in seconds
2451
+ * @default 60
2452
+ */
2453
+ idleTimeout?: number;
2454
+ /**
2455
+ * Enable access logs
2456
+ */
2457
+ accessLogs?: {
2458
+ enabled?: boolean;
2459
+ bucket?: string;
2460
+ prefix?: string;
2461
+ };
2462
+ }
2463
+ /**
2464
+ * SSL/TLS Configuration
2465
+ * Supports both AWS ACM certificates and Let's Encrypt
2466
+ */
2467
+ export interface SslConfig {
2468
+ /**
2469
+ * Enable HTTPS
2470
+ * @default true for production
2471
+ */
2472
+ enabled?: boolean;
2473
+ /**
2474
+ * SSL certificate provider
2475
+ * - 'acm': AWS Certificate Manager (requires ALB or CloudFront)
2476
+ * - 'letsencrypt': Free certificates from Let's Encrypt (works without ALB)
2477
+ * @default 'acm' if loadBalancer.enabled, otherwise 'letsencrypt'
2478
+ */
2479
+ provider?: 'acm' | 'letsencrypt';
2480
+ /**
2481
+ * ACM certificate ARN (if using ACM)
2482
+ * If not provided, a certificate will be automatically requested
2483
+ */
2484
+ certificateArn?: string;
2485
+ /**
2486
+ * Domain names for the certificate
2487
+ * If not provided, uses the primary domain from dns config
2488
+ */
2489
+ domains?: string[];
2490
+ /**
2491
+ * Redirect HTTP to HTTPS
2492
+ * @default true when SSL is enabled
2493
+ */
2494
+ redirectHttp?: boolean;
2495
+ /**
2496
+ * Let's Encrypt specific options
2497
+ */
2498
+ letsEncrypt?: {
2499
+ /**
2500
+ * Email for Let's Encrypt notifications
2501
+ */
2502
+ email?: string;
2503
+ /**
2504
+ * Use staging server for testing
2505
+ * @default false
2506
+ */
2507
+ staging?: boolean;
2508
+ /**
2509
+ * Auto-renew certificates
2510
+ * @default true
2511
+ */
2512
+ autoRenew?: boolean;
2513
+ };
2514
+ }