@stacksjs/ts-cloud-types 0.1.6 → 0.1.8

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.
@@ -0,0 +1,1242 @@
1
+ /**
2
+ * Queue configuration presets for common use cases
3
+ * Use these to quickly configure queues with sensible defaults
4
+ *
5
+ * @example Basic usage
6
+ * import { QueuePresets } from '@stacksjs/ts-cloud-types'
7
+ *
8
+ * queues: {
9
+ * jobs: QueuePresets.backgroundJobs,
10
+ * orders: QueuePresets.fifo,
11
+ * events: QueuePresets.highThroughput,
12
+ * }
13
+ *
14
+ * @example With Lambda trigger
15
+ * queues: {
16
+ * orders: {
17
+ * ...QueuePresets.backgroundJobs,
18
+ * trigger: { functionName: 'processOrders' },
19
+ * },
20
+ * }
21
+ *
22
+ * @example With monitoring
23
+ * queues: {
24
+ * critical: {
25
+ * ...QueuePresets.monitored,
26
+ * alarms: {
27
+ * ...QueuePresets.monitored.alarms,
28
+ * notificationEmails: ['ops@example.com'],
29
+ * },
30
+ * },
31
+ * }
32
+ */
33
+ export declare const QueuePresets: {
34
+ backgroundJobs: QueueItemConfig
35
+ fifo: QueueItemConfig
36
+ highThroughput: QueueItemConfig
37
+ delayed: QueueItemConfig
38
+ longRunning: QueueItemConfig
39
+ monitored: QueueItemConfig
40
+ lambdaOptimized: QueueItemConfig
41
+ fanOut: QueueItemConfig
42
+ };
43
+ /**
44
+ * Realtime configuration presets
45
+ *
46
+ * @example Serverless presets
47
+ * import { RealtimePresets } from '@stacksjs/ts-cloud-types'
48
+ * realtime: RealtimePresets.serverless.production
49
+ *
50
+ * @example Server presets (ts-broadcasting)
51
+ * realtime: RealtimePresets.server.production
52
+ */
53
+ export declare const RealtimePresets: {
54
+ serverless: {
55
+ development: RealtimeConfig
56
+ production: RealtimeConfig
57
+ notifications: RealtimeConfig
58
+ }
59
+ server: {
60
+ development: RealtimeConfig
61
+ production: RealtimeConfig
62
+ highPerformance: RealtimeConfig
63
+ chat: RealtimeConfig
64
+ gaming: RealtimeConfig
65
+ single: RealtimeConfig
66
+ }
67
+ };
68
+ /**
69
+ * AWS-specific configuration
70
+ */
71
+ export declare interface AwsConfig {
72
+ region?: string
73
+ profile?: string
74
+ accountId?: string
75
+ }
76
+ // Core configuration types
77
+ export declare interface CloudConfig {
78
+ project: ProjectConfig
79
+ mode?: DeploymentMode
80
+ environments: Record<string, EnvironmentConfig>
81
+ infrastructure?: InfrastructureConfig
82
+ sites?: Record<string, SiteConfig>
83
+ aws?: AwsConfig
84
+ features?: Record<string, boolean>
85
+ hooks?: {
86
+ beforeDeploy?: string | ((config: CloudConfig) => Promise<void>)
87
+ afterDeploy?: string | ((config: CloudConfig) => Promise<void>)
88
+ beforeBuild?: string | ((config: CloudConfig) => Promise<void>)
89
+ afterBuild?: string | ((config: CloudConfig) => Promise<void>)
90
+ }
91
+ costPreset?: 'minimal' | 'balanced' | 'performance' | 'custom'
92
+ tags?: Record<string, string>
93
+ }
94
+ export declare interface ProjectConfig {
95
+ name: string
96
+ slug: string
97
+ region: string
98
+ }
99
+ export declare interface EnvironmentConfig {
100
+ type: EnvironmentType
101
+ region?: string
102
+ variables?: Record<string, string>
103
+ domain?: string
104
+ infrastructure?: Partial<InfrastructureConfig>
105
+ }
106
+ /**
107
+ * Network/VPC configuration
108
+ */
109
+ export declare interface NetworkConfig {
110
+ vpc?: VpcConfig
111
+ subnets?: {
112
+ public?: number
113
+ private?: number
114
+ }
115
+ natGateway?: boolean | 'single' | 'perAz'
116
+ }
117
+ /**
118
+ * API Gateway configuration
119
+ */
120
+ export declare interface ApiGatewayConfig {
121
+ type?: 'REST' | 'HTTP' | 'websocket'
122
+ name?: string
123
+ description?: string
124
+ stageName?: string
125
+ cors?: boolean | {
126
+ allowOrigins?: string[]
127
+ allowMethods?: string[]
128
+ allowHeaders?: string[]
129
+ maxAge?: number
130
+ }
131
+ authorization?: 'NONE' | 'IAM' | 'COGNITO' | 'LAMBDA'
132
+ throttling?: {
133
+ rateLimit?: number
134
+ burstLimit?: number
135
+ }
136
+ customDomain?: {
137
+ domain?: string
138
+ certificateArn?: string
139
+ }
140
+ authorizer?: {
141
+ type?: string
142
+ identitySource?: string
143
+ audience?: string[]
144
+ }
145
+ routes?: Array<{
146
+ path?: string
147
+ method?: string
148
+ integration?: string | { type?: string; service?: string }
149
+ authorizer?: string
150
+ }> | Record<string, {
151
+ path?: string
152
+ method?: string
153
+ integration?: string | { type?: string; service?: string }
154
+ }>
155
+ }
156
+ /**
157
+ * Messaging (SNS) configuration
158
+ */
159
+ export declare interface MessagingConfig {
160
+ topics?: Record<string, {
161
+ name?: string
162
+ displayName?: string
163
+ subscriptions?: Array<{
164
+ protocol: 'email' | 'sqs' | 'lambda' | 'http' | 'https'
165
+ endpoint: string
166
+ filterPolicy?: Record<string, string[]>
167
+ }>
168
+ }>
169
+ }
170
+ export declare interface InfrastructureConfig {
171
+ vpc?: VpcConfig
172
+ network?: NetworkConfig
173
+ compute?: ComputeConfig
174
+ containers?: Record<string, ContainerItemConfig>
175
+ storage?: Record<string, StorageItemConfig & ResourceConditions>
176
+ functions?: Record<string, FunctionConfig & ResourceConditions>
177
+ servers?: Record<string, ServerItemConfig & ResourceConditions>
178
+ databases?: Record<string, DatabaseItemConfig & ResourceConditions>
179
+ cache?: CacheConfig
180
+ cdn?: Record<string, CdnItemConfig & ResourceConditions> | CdnItemConfig
181
+ fileSystem?: Record<string, FileSystemItemConfig>
182
+ apiGateway?: ApiGatewayConfig
183
+ messaging?: MessagingConfig
184
+ queues?: Record<string, QueueItemConfig & ResourceConditions>
185
+ realtime?: RealtimeConfig
186
+ dns?: DnsConfig
187
+ security?: SecurityConfig
188
+ monitoring?: MonitoringConfig
189
+ api?: ApiConfig
190
+ loadBalancer?: LoadBalancerConfig
191
+ ssl?: SslConfig
192
+ streaming?: Record<string, {
193
+ name?: string
194
+ shardCount?: number
195
+ retentionPeriod?: number
196
+ encryption?: boolean | string
197
+ }>
198
+ machineLearning?: {
199
+ sagemakerEndpoint?: string
200
+ modelBucket?: string
201
+ sagemaker?: {
202
+ endpointName?: string
203
+ instanceType?: string
204
+ endpoints?: Array<{
205
+ name?: string
206
+ modelName?: string
207
+ modelS3Path?: string
208
+ instanceType?: string
209
+ instanceCount?: number
210
+ initialInstanceCount?: number
211
+ autoScaling?: {
212
+ minInstances?: number
213
+ maxInstances?: number
214
+ targetInvocationsPerInstance?: number
215
+ }
216
+ }>
217
+ trainingJobs?: Array<{
218
+ name?: string
219
+ algorithmSpecification?: {
220
+ trainingImage?: string
221
+ trainingInputMode?: string
222
+ }
223
+ instanceType?: string
224
+ instanceCount?: number
225
+ volumeSizeInGB?: number
226
+ maxRuntimeInSeconds?: number
227
+ }>
228
+ }
229
+ }
230
+ analytics?: {
231
+ enabled?: boolean
232
+ firehose?: Record<string, {
233
+ name?: string
234
+ destination?: string
235
+ bufferSize?: number
236
+ bufferInterval?: number
237
+ }>
238
+ athena?: {
239
+ database?: string
240
+ workgroup?: string
241
+ outputLocation?: string
242
+ outputBucket?: string
243
+ tables?: Array<{
244
+ name?: string
245
+ location?: string
246
+ format?: string
247
+ partitionKeys?: string[]
248
+ }>
249
+ }
250
+ glue?: {
251
+ crawlers?: Array<{
252
+ name?: string
253
+ databaseName?: string
254
+ s3Targets?: string[]
255
+ schedule?: string
256
+ }>
257
+ jobs?: Array<{
258
+ name?: string
259
+ scriptLocation?: string
260
+ role?: string
261
+ maxCapacity?: number
262
+ timeout?: number
263
+ }>
264
+ }
265
+ }
266
+ workflow?: {
267
+ pipelines?: Array<{
268
+ name?: string
269
+ type?: 'stepFunctions' | string
270
+ definition?: Record<string, unknown>
271
+ schedule?: string
272
+ }>
273
+ }
274
+ }
275
+ /**
276
+ * Conditions that determine if a resource should be deployed
277
+ */
278
+ export declare interface ResourceConditions {
279
+ environments?: EnvironmentType[]
280
+ requiresFeatures?: string[]
281
+ regions?: string[]
282
+ condition?: (config: CloudConfig, env: EnvironmentType) => boolean
283
+ }
284
+ export declare interface SiteConfig {
285
+ root: string
286
+ path?: string
287
+ domain?: string
288
+ certificateArn?: string
289
+ build?: string
290
+ }
291
+ export declare interface VpcConfig {
292
+ cidr?: string
293
+ zones?: number
294
+ availabilityZones?: number
295
+ natGateway?: boolean
296
+ natGateways?: number | boolean
297
+ }
298
+ export declare interface StorageConfig {
299
+ buckets?: BucketConfig[]
300
+ }
301
+ export declare interface BucketConfig {
302
+ name: string
303
+ public?: boolean
304
+ versioning?: boolean
305
+ website?: boolean
306
+ encryption?: boolean
307
+ }
308
+ export declare interface DatabaseConfig {
309
+ type?: 'rds' | 'dynamodb'
310
+ engine?: 'postgres' | 'mysql'
311
+ instanceType?: string
312
+ }
313
+ export declare interface CacheConfig {
314
+ type?: 'redis' | 'memcached'
315
+ nodeType?: string
316
+ redis?: {
317
+ nodeType?: string
318
+ numCacheNodes?: number
319
+ engine?: string
320
+ engineVersion?: string
321
+ port?: number
322
+ parameterGroup?: Record<string, string>
323
+ snapshotRetentionLimit?: number
324
+ snapshotWindow?: string
325
+ automaticFailoverEnabled?: boolean
326
+ }
327
+ elasticache?: {
328
+ nodeType?: string
329
+ numCacheNodes?: number
330
+ engine?: string
331
+ engineVersion?: string
332
+ }
333
+ }
334
+ export declare interface CdnConfig {
335
+ enabled?: boolean
336
+ customDomain?: string
337
+ certificateArn?: string
338
+ }
339
+ export declare interface DnsConfig {
340
+ domain?: string
341
+ hostedZoneId?: string
342
+ provider?: 'route53' | 'cloudflare' | 'porkbun' | 'godaddy'
343
+ }
344
+ export declare interface SecurityConfig {
345
+ waf?: WafConfig
346
+ kms?: boolean
347
+ certificate?: {
348
+ domain: string
349
+ subdomains?: string[]
350
+ validationMethod?: 'DNS' | 'EMAIL'
351
+ }
352
+ securityGroups?: Record<string, {
353
+ ingress?: Array<{
354
+ port: number
355
+ protocol: string
356
+ cidr?: string
357
+ source?: string
358
+ }>
359
+ egress?: Array<{
360
+ port: number
361
+ protocol: string
362
+ cidr?: string
363
+ destination?: string
364
+ }>
365
+ }>
366
+ }
367
+ export declare interface WafConfig {
368
+ enabled?: boolean
369
+ blockCountries?: string[]
370
+ blockIps?: string[]
371
+ rateLimit?: number
372
+ rules?: string[]
373
+ }
374
+ export declare interface MonitoringConfig {
375
+ alarms?: Record<string, AlarmItemConfig> | AlarmItemConfig[]
376
+ dashboards?: boolean
377
+ dashboard?: {
378
+ name?: string
379
+ widgets?: Array<{
380
+ type?: string
381
+ metrics?: string[] | Array<{
382
+ service?: string
383
+ metric?: string
384
+ }>
385
+ }>
386
+ }
387
+ logs?: {
388
+ retention?: number
389
+ groups?: string[]
390
+ }
391
+ }
392
+ export declare interface AlarmConfig {
393
+ name: string
394
+ metric: string
395
+ threshold: number
396
+ }
397
+ export declare interface AlarmItemConfig {
398
+ name?: string
399
+ metric?: string
400
+ metricName?: string
401
+ namespace?: string
402
+ threshold: number
403
+ comparisonOperator?: string
404
+ period?: number
405
+ evaluationPeriods?: number
406
+ service?: string
407
+ }
408
+ export declare interface StorageItemConfig {
409
+ public?: boolean
410
+ versioning?: boolean
411
+ encryption?: boolean
412
+ encrypted?: boolean
413
+ website?: boolean | {
414
+ indexDocument?: string
415
+ errorDocument?: string
416
+ }
417
+ type?: 'efs' | 's3'
418
+ intelligentTiering?: boolean
419
+ cors?: Array<{
420
+ allowedOrigins?: string[]
421
+ allowedMethods?: string[]
422
+ allowedHeaders?: string[]
423
+ maxAge?: number
424
+ }>
425
+ lifecycleRules?: Array<{
426
+ id?: string
427
+ enabled?: boolean
428
+ expirationDays?: number
429
+ transitions?: Array<{
430
+ days?: number
431
+ storageClass?: string
432
+ }>
433
+ }>
434
+ performanceMode?: string
435
+ throughputMode?: string
436
+ lifecyclePolicy?: {
437
+ transitionToIA?: number
438
+ }
439
+ }
440
+ export declare interface FunctionConfig {
441
+ handler?: string
442
+ runtime?: string
443
+ code?: string
444
+ timeout?: number
445
+ memorySize?: number
446
+ memory?: number
447
+ events?: Array<{
448
+ type?: string
449
+ path?: string
450
+ method?: string
451
+ queueName?: string
452
+ streamName?: string
453
+ tableName?: string
454
+ expression?: string
455
+ batchSize?: number
456
+ startingPosition?: string
457
+ parallelizationFactor?: number
458
+ bucket?: string
459
+ prefix?: string
460
+ suffix?: string
461
+ }>
462
+ environment?: Record<string, string>
463
+ }
464
+ /**
465
+ * Elastic File System (EFS) configuration
466
+ */
467
+ export declare interface FileSystemItemConfig {
468
+ performanceMode?: 'generalPurpose' | 'maxIO' | string
469
+ throughputMode?: 'bursting' | 'provisioned' | string
470
+ encrypted?: boolean
471
+ lifecyclePolicy?: {
472
+ transitionToIA?: number
473
+ }
474
+ mountPath?: string
475
+ }
476
+ /**
477
+ * Server/VM Instance Configuration
478
+ */
479
+ export declare interface ServerItemConfig {
480
+ size?: InstanceSize
481
+ image?: string
482
+ startupScript?: string
483
+ }
484
+ /**
485
+ * Instance configuration for mixed instance fleets
486
+ */
487
+ export declare interface InstanceConfig {
488
+ size: InstanceSize
489
+ weight?: number
490
+ spot?: boolean
491
+ maxPrice?: string
492
+ }
493
+ /**
494
+ * Compute Configuration
495
+ * Defines the virtual machines/instances for your application
496
+ *
497
+ * @example Single instance
498
+ * compute: {
499
+ * instances: 1,
500
+ * size: 'small',
501
+ * }
502
+ *
503
+ * @example Multiple instances (auto-enables load balancer)
504
+ * compute: {
505
+ * instances: 3,
506
+ * size: 'medium',
507
+ * autoScaling: { min: 2, max: 10 },
508
+ * }
509
+ *
510
+ * @example Mixed instance fleet for cost optimization
511
+ * compute: {
512
+ * instances: 3,
513
+ * fleet: [
514
+ * { size: 'small', weight: 1 },
515
+ * { size: 'medium', weight: 2 },
516
+ * { size: 'small', weight: 1, spot: true },
517
+ * ],
518
+ * }
519
+ */
520
+ export declare interface ContainerItemConfig {
521
+ cpu?: number
522
+ memory?: number
523
+ port?: number
524
+ healthCheck?: string
525
+ desiredCount?: number
526
+ autoScaling?: {
527
+ min?: number
528
+ max?: number
529
+ targetCpuUtilization?: number
530
+ targetMemoryUtilization?: number
531
+ }
532
+ }
533
+ export declare interface ComputeConfig {
534
+ mode?: 'server' | 'serverless'
535
+ instances?: number
536
+ size?: InstanceSize
537
+ fleet?: InstanceConfig[]
538
+ image?: string
539
+ server?: {
540
+ instanceType?: string
541
+ ami?: string
542
+ keyPair?: string
543
+ autoScaling?: {
544
+ min?: number
545
+ max?: number
546
+ desired?: number
547
+ targetCPU?: number
548
+ scaleUpCooldown?: number
549
+ scaleDownCooldown?: number
550
+ }
551
+ loadBalancer?: {
552
+ type?: string
553
+ healthCheck?: {
554
+ path?: string
555
+ interval?: number
556
+ timeout?: number
557
+ healthyThreshold?: number
558
+ unhealthyThreshold?: number
559
+ }
560
+ stickySession?: {
561
+ enabled?: boolean
562
+ duration?: number
563
+ }
564
+ }
565
+ userData?: string | {
566
+ packages?: string[]
567
+ commands?: string[]
568
+ }
569
+ }
570
+ serverless?: {
571
+ cpu?: number
572
+ memory?: number
573
+ desiredCount?: number
574
+ }
575
+ fargate?: {
576
+ taskDefinition?: {
577
+ cpu?: string
578
+ memory?: string
579
+ containerDefinitions?: Array<{
580
+ name?: string
581
+ image?: string
582
+ portMappings?: Array<{
583
+ containerPort?: number
584
+ }>
585
+ environment?: unknown[]
586
+ secrets?: unknown[]
587
+ }>
588
+ }
589
+ service?: {
590
+ desiredCount?: number
591
+ healthCheck?: {
592
+ path?: string
593
+ interval?: number
594
+ timeout?: number
595
+ healthyThreshold?: number
596
+ unhealthyThreshold?: number
597
+ }
598
+ serviceDiscovery?: {
599
+ enabled?: boolean
600
+ namespace?: string
601
+ }
602
+ autoScaling?: {
603
+ min?: number
604
+ max?: number
605
+ targetCPU?: number
606
+ targetMemory?: number
607
+ }
608
+ }
609
+ loadBalancer?: {
610
+ type?: string
611
+ customDomain?: {
612
+ domain?: string
613
+ certificateArn?: string
614
+ }
615
+ }
616
+ }
617
+ services?: Array<{
618
+ name: string
619
+ type?: string
620
+ taskDefinition?: {
621
+ cpu?: string
622
+ memory?: string
623
+ containerDefinitions?: Array<{
624
+ name?: string
625
+ image?: string
626
+ portMappings?: Array<{
627
+ containerPort?: number
628
+ }>
629
+ healthCheck?: {
630
+ command?: string[]
631
+ interval?: number
632
+ timeout?: number
633
+ retries?: number
634
+ }
635
+ }>
636
+ }
637
+ service?: {
638
+ desiredCount?: number
639
+ serviceDiscovery?: {
640
+ enabled?: boolean
641
+ namespace?: string
642
+ }
643
+ autoScaling?: {
644
+ min?: number
645
+ max?: number
646
+ targetCPU?: number
647
+ }
648
+ }
649
+ }>
650
+ autoScaling?: {
651
+ /** Minimum number of instances @default 1 */
652
+ min?: number
653
+ /** Maximum number of instances @default instances value */
654
+ max?: number
655
+ /** Desired number of instances @default instances value */
656
+ desired?: number
657
+ /** CPU threshold to scale up (%) @default 70 */
658
+ scaleUpThreshold?: number
659
+ /** CPU threshold to scale down (%) @default 30 */
660
+ scaleDownThreshold?: number
661
+ /** Cooldown in seconds @default 300 */
662
+ cooldown?: number
663
+ }
664
+ disk?: {
665
+ /** Size in GB @default 20 */
666
+ size?: number
667
+ /** Disk type @default 'ssd' */
668
+ type?: 'standard' | 'ssd' | 'premium'
669
+ /** Enable encryption @default true */
670
+ encrypted?: boolean
671
+ }
672
+ sshKey?: string
673
+ monitoring?: boolean
674
+ spotConfig?: {
675
+ /** Base capacity that must be on-demand @default 1 */
676
+ baseCapacity?: number
677
+ /** % of instances above base that are on-demand @default 100 */
678
+ onDemandPercentage?: number
679
+ /** Allocation strategy @default 'capacity-optimized' */
680
+ strategy?: 'lowest-price' | 'capacity-optimized'
681
+ }
682
+ }
683
+ export declare interface DatabaseItemConfig {
684
+ engine?: 'dynamodb' | 'postgres' | 'mysql'
685
+ partitionKey?: string | { name: string; type: string }
686
+ sortKey?: string | { name: string; type: string }
687
+ username?: string
688
+ password?: string
689
+ storage?: number
690
+ instanceClass?: string
691
+ version?: string
692
+ allocatedStorage?: number
693
+ maxAllocatedStorage?: number
694
+ multiAZ?: boolean
695
+ backupRetentionDays?: number
696
+ preferredBackupWindow?: string
697
+ preferredMaintenanceWindow?: string
698
+ deletionProtection?: boolean
699
+ streamEnabled?: boolean
700
+ pointInTimeRecovery?: boolean
701
+ billingMode?: string
702
+ parameters?: Record<string, string | number>
703
+ databaseName?: string
704
+ enablePerformanceInsights?: boolean
705
+ performanceInsightsRetention?: number
706
+ tables?: Record<string, {
707
+ name?: string
708
+ partitionKey?: string | { name: string; type: string }
709
+ sortKey?: string | { name: string; type: string }
710
+ billing?: string
711
+ billingMode?: string
712
+ streamEnabled?: boolean
713
+ pointInTimeRecovery?: boolean
714
+ globalSecondaryIndexes?: Array<{
715
+ name: string
716
+ partitionKey: { name: string; type: string }
717
+ sortKey?: { name: string; type: string }
718
+ projection: string
719
+ }>
720
+ }>
721
+ }
722
+ export declare interface CdnItemConfig {
723
+ origin?: string
724
+ customDomain?: string | {
725
+ domain: string
726
+ certificateArn?: string
727
+ }
728
+ certificateArn?: string
729
+ domain?: string
730
+ enabled?: boolean
731
+ cachePolicy?: {
732
+ minTTL?: number
733
+ defaultTTL?: number
734
+ maxTTL?: number
735
+ }
736
+ minTTL?: number
737
+ defaultTTL?: number
738
+ maxTTL?: number
739
+ compress?: boolean
740
+ http3?: boolean
741
+ errorPages?: Record<number | string, string>
742
+ origins?: Array<{
743
+ type?: string
744
+ pathPattern?: string
745
+ domainName?: string
746
+ originId?: string
747
+ }>
748
+ edgeFunctions?: Array<{
749
+ eventType?: string
750
+ functionArn?: string
751
+ name?: string
752
+ }>
753
+ }
754
+ /**
755
+ * Lambda trigger configuration for SQS queues
756
+ */
757
+ export declare interface QueueLambdaTrigger {
758
+ functionName: string
759
+ batchSize?: number
760
+ batchWindow?: number
761
+ reportBatchItemFailures?: boolean
762
+ maxConcurrency?: number
763
+ filterPattern?: Record<string, unknown>
764
+ }
765
+ /**
766
+ * CloudWatch alarm configuration for SQS queues
767
+ */
768
+ export declare interface QueueAlarms {
769
+ enabled?: boolean
770
+ queueDepthThreshold?: number
771
+ messageAgeThreshold?: number
772
+ dlqAlarm?: boolean
773
+ notificationTopicArn?: string
774
+ notificationEmails?: string[]
775
+ }
776
+ /**
777
+ * SNS subscription configuration for SQS queues
778
+ */
779
+ export declare interface QueueSnsSubscription {
780
+ topicArn?: string
781
+ topicName?: string
782
+ filterPolicy?: Record<string, string[]>
783
+ filterPolicyScope?: 'MessageAttributes' | 'MessageBody'
784
+ rawMessageDelivery?: boolean
785
+ }
786
+ /**
787
+ * Queue (SQS) Configuration
788
+ * Defines message queue settings for async processing
789
+ *
790
+ * @example Standard queue with Lambda trigger
791
+ * queues: {
792
+ * orders: {
793
+ * visibilityTimeout: 60,
794
+ * deadLetterQueue: true,
795
+ * trigger: {
796
+ * functionName: 'processOrders',
797
+ * batchSize: 10,
798
+ * },
799
+ * }
800
+ * }
801
+ *
802
+ * @example FIFO queue with alarms
803
+ * queues: {
804
+ * transactions: {
805
+ * fifo: true,
806
+ * contentBasedDeduplication: true,
807
+ * alarms: {
808
+ * enabled: true,
809
+ * queueDepthThreshold: 500,
810
+ * notificationEmails: ['ops@example.com'],
811
+ * },
812
+ * }
813
+ * }
814
+ *
815
+ * @example Queue subscribed to SNS topic
816
+ * queues: {
817
+ * notifications: {
818
+ * subscribe: {
819
+ * topicArn: 'arn:aws:sns:us-east-1:123456789:events',
820
+ * filterPolicy: { eventType: ['user.created'] },
821
+ * },
822
+ * }
823
+ * }
824
+ */
825
+ export declare interface QueueItemConfig {
826
+ fifo?: boolean
827
+ visibilityTimeout?: number
828
+ messageRetentionPeriod?: number
829
+ delaySeconds?: number
830
+ maxMessageSize?: number
831
+ receiveMessageWaitTime?: number
832
+ deadLetterQueue?: boolean
833
+ maxReceiveCount?: number
834
+ contentBasedDeduplication?: boolean
835
+ encrypted?: boolean
836
+ kmsKeyId?: string
837
+ trigger?: QueueLambdaTrigger
838
+ alarms?: QueueAlarms
839
+ subscribe?: QueueSnsSubscription
840
+ tags?: Record<string, string>
841
+ }
842
+ /**
843
+ * Server mode configuration (ts-broadcasting)
844
+ * High-performance Bun WebSocket server for EC2/ECS deployments
845
+ */
846
+ export declare interface RealtimeServerConfig {
847
+ host?: string
848
+ port?: number
849
+ scheme?: 'ws' | 'wss'
850
+ driver?: 'bun' | 'reverb' | 'pusher' | 'ably'
851
+ idleTimeout?: number
852
+ maxPayloadLength?: number
853
+ backpressureLimit?: number
854
+ closeOnBackpressureLimit?: boolean
855
+ sendPings?: boolean
856
+ perMessageDeflate?: boolean
857
+ redis?: RealtimeRedisConfig
858
+ rateLimit?: RealtimeRateLimitConfig
859
+ encryption?: RealtimeEncryptionConfig
860
+ webhooks?: RealtimeWebhooksConfig
861
+ queue?: RealtimeQueueConfig
862
+ loadManagement?: RealtimeLoadConfig
863
+ metrics?: boolean | {
864
+ enabled: boolean
865
+ path?: string
866
+ }
867
+ healthCheckPath?: string
868
+ instances?: number
869
+ autoScaling?: {
870
+ min?: number
871
+ max?: number
872
+ targetCPU?: number
873
+ targetConnections?: number
874
+ }
875
+ }
876
+ /**
877
+ * Redis configuration for ts-broadcasting horizontal scaling
878
+ */
879
+ export declare interface RealtimeRedisConfig {
880
+ enabled?: boolean
881
+ host?: string
882
+ port?: number
883
+ password?: string
884
+ database?: number
885
+ url?: string
886
+ keyPrefix?: string
887
+ useElastiCache?: boolean
888
+ }
889
+ /**
890
+ * Rate limiting for WebSocket connections
891
+ */
892
+ export declare interface RealtimeRateLimitConfig {
893
+ enabled?: boolean
894
+ max?: number
895
+ window?: number
896
+ perChannel?: boolean
897
+ perUser?: boolean
898
+ }
899
+ /**
900
+ * Message encryption configuration
901
+ */
902
+ export declare interface RealtimeEncryptionConfig {
903
+ enabled?: boolean
904
+ algorithm?: 'aes-256-gcm' | 'aes-128-gcm'
905
+ keyRotationInterval?: number
906
+ }
907
+ /**
908
+ * Webhook notifications for realtime events
909
+ */
910
+ export declare interface RealtimeWebhooksConfig {
911
+ enabled?: boolean
912
+ endpoints?: {
913
+ /**
914
+ * Called when a client connects
915
+ */
916
+ connection?: string
917
+
918
+ /**
919
+ * Called when a client subscribes to a channel
920
+ */
921
+ subscribe?: string
922
+
923
+ /**
924
+ * Called when a client unsubscribes
925
+ */
926
+ unsubscribe?: string
927
+
928
+ /**
929
+ * Called when a client disconnects
930
+ */
931
+ disconnect?: string
932
+
933
+ /**
934
+ * Custom event webhooks
935
+ */
936
+ [event: string]: string | undefined
937
+ }
938
+ }
939
+ /**
940
+ * Queue configuration for background broadcasting
941
+ */
942
+ export declare interface RealtimeQueueConfig {
943
+ enabled?: boolean
944
+ defaultQueue?: string
945
+ retry?: {
946
+ attempts?: number
947
+ backoff?: {
948
+ type: 'fixed' | 'exponential'
949
+ delay: number
950
+ }
951
+ }
952
+ deadLetter?: {
953
+ enabled?: boolean
954
+ maxRetries?: number
955
+ }
956
+ }
957
+ /**
958
+ * Load management for server mode
959
+ */
960
+ export declare interface RealtimeLoadConfig {
961
+ enabled?: boolean
962
+ maxConnections?: number
963
+ maxSubscriptionsPerConnection?: number
964
+ shedLoadThreshold?: number
965
+ }
966
+ /**
967
+ * Channel authorization configuration
968
+ */
969
+ export declare interface RealtimeChannelAuth {
970
+ functionName?: string
971
+ endpoint?: string
972
+ jwtSecret?: string
973
+ tokenExpiration?: number
974
+ }
975
+ /**
976
+ * Presence channel configuration
977
+ */
978
+ export declare interface RealtimePresenceConfig {
979
+ enabled?: boolean
980
+ maxMembers?: number
981
+ heartbeatInterval?: number
982
+ inactivityTimeout?: number
983
+ }
984
+ /**
985
+ * Connection storage configuration
986
+ */
987
+ export declare interface RealtimeStorageConfig {
988
+ type?: 'dynamodb' | 'elasticache'
989
+ dynamodb?: {
990
+ /**
991
+ * Billing mode for DynamoDB
992
+ * @default 'PAY_PER_REQUEST'
993
+ */
994
+ billingMode?: 'PAY_PER_REQUEST' | 'PROVISIONED'
995
+
996
+ /**
997
+ * Read capacity units (only for PROVISIONED)
998
+ * @default 5
999
+ */
1000
+ readCapacity?: number
1001
+
1002
+ /**
1003
+ * Write capacity units (only for PROVISIONED)
1004
+ * @default 5
1005
+ */
1006
+ writeCapacity?: number
1007
+
1008
+ /**
1009
+ * Enable point-in-time recovery
1010
+ * @default false
1011
+ */
1012
+ pointInTimeRecovery?: boolean
1013
+
1014
+ /**
1015
+ * TTL for connection records (seconds)
1016
+ * @default 86400 (24 hours)
1017
+ */
1018
+ connectionTTL?: number
1019
+ }
1020
+ elasticache?: {
1021
+ /**
1022
+ * Node type for Redis cluster
1023
+ * @default 'cache.t3.micro'
1024
+ */
1025
+ nodeType?: string
1026
+
1027
+ /**
1028
+ * Number of cache nodes
1029
+ * @default 1
1030
+ */
1031
+ numNodes?: number
1032
+ }
1033
+ }
1034
+ /**
1035
+ * WebSocket scaling configuration
1036
+ */
1037
+ export declare interface RealtimeScalingConfig {
1038
+ maxConnections?: number
1039
+ messagesPerSecond?: number
1040
+ handlerMemory?: number
1041
+ handlerTimeout?: number
1042
+ provisionedConcurrency?: number
1043
+ }
1044
+ /**
1045
+ * Realtime monitoring and alarms
1046
+ */
1047
+ export declare interface RealtimeMonitoringConfig {
1048
+ enabled?: boolean
1049
+ connectionThreshold?: number
1050
+ errorThreshold?: number
1051
+ latencyThreshold?: number
1052
+ notificationTopicArn?: string
1053
+ notificationEmails?: string[]
1054
+ }
1055
+ /**
1056
+ * Realtime event hooks
1057
+ */
1058
+ export declare interface RealtimeHooksConfig {
1059
+ onConnect?: string
1060
+ onDisconnect?: string
1061
+ onMessage?: string
1062
+ onSubscribe?: string
1063
+ onUnsubscribe?: string
1064
+ }
1065
+ /**
1066
+ * Realtime (WebSocket) Configuration
1067
+ * Provides Laravel Echo / Pusher-compatible broadcasting
1068
+ *
1069
+ * @example Serverless mode (API Gateway WebSocket)
1070
+ * realtime: {
1071
+ * enabled: true,
1072
+ * mode: 'serverless',
1073
+ * channels: { public: true, private: true, presence: true },
1074
+ * }
1075
+ *
1076
+ * @example Server mode (ts-broadcasting on EC2/ECS)
1077
+ * realtime: {
1078
+ * enabled: true,
1079
+ * mode: 'server',
1080
+ * server: {
1081
+ * port: 6001,
1082
+ * redis: { enabled: true, host: 'redis.example.com' },
1083
+ * rateLimit: { max: 100, window: 60000 },
1084
+ * },
1085
+ * }
1086
+ *
1087
+ * @example Production server mode with clustering
1088
+ * realtime: {
1089
+ * enabled: true,
1090
+ * mode: 'server',
1091
+ * server: {
1092
+ * port: 6001,
1093
+ * instances: 3,
1094
+ * redis: { enabled: true, useElastiCache: true },
1095
+ * autoScaling: { min: 2, max: 10, targetCPU: 70 },
1096
+ * metrics: true,
1097
+ * },
1098
+ * channels: { public: true, private: true, presence: true },
1099
+ * }
1100
+ *
1101
+ * @example Integration with Stacks.js
1102
+ * // In your Stacks app:
1103
+ * import { Broadcast } from '@stacksjs/broadcast'
1104
+ *
1105
+ * // Broadcast to a channel
1106
+ * Broadcast.channel('orders').emit('order.created', { id: 123 })
1107
+ *
1108
+ * // Client-side (similar to Laravel Echo)
1109
+ * Echo.channel('orders').listen('order.created', (e) => {
1110
+ * console.log('New order:', e.id)
1111
+ * })
1112
+ *
1113
+ * // Private channel
1114
+ * Echo.private(`user.${userId}`).listen('notification', (e) => {
1115
+ * console.log('Private notification:', e)
1116
+ * })
1117
+ *
1118
+ * // Presence channel
1119
+ * Echo.join('chat-room')
1120
+ * .here((users) => console.log('Online:', users))
1121
+ * .joining((user) => console.log('Joined:', user))
1122
+ * .leaving((user) => console.log('Left:', user))
1123
+ */
1124
+ export declare interface RealtimeConfig {
1125
+ enabled?: boolean
1126
+ mode?: RealtimeMode
1127
+ name?: string
1128
+ server?: RealtimeServerConfig
1129
+ channels?: {
1130
+ /**
1131
+ * Enable public channels (no auth required)
1132
+ * @default true
1133
+ */
1134
+ public?: boolean
1135
+
1136
+ /**
1137
+ * Enable private channels (requires auth)
1138
+ * @default true
1139
+ */
1140
+ private?: boolean
1141
+
1142
+ /**
1143
+ * Enable presence channels (track online users)
1144
+ * @default false
1145
+ */
1146
+ presence?: boolean | RealtimePresenceConfig
1147
+ }
1148
+ auth?: RealtimeChannelAuth
1149
+ storage?: RealtimeStorageConfig
1150
+ scaling?: RealtimeScalingConfig
1151
+ monitoring?: RealtimeMonitoringConfig
1152
+ hooks?: RealtimeHooksConfig
1153
+ customDomain?: string
1154
+ certificateArn?: string
1155
+ keepAlive?: boolean
1156
+ keepAliveInterval?: number
1157
+ idleTimeout?: number
1158
+ maxMessageSize?: number
1159
+ compression?: boolean
1160
+ tags?: Record<string, string>
1161
+ }
1162
+ export declare interface ApiConfig {
1163
+ enabled?: boolean
1164
+ name?: string
1165
+ }
1166
+ /**
1167
+ * Load Balancer Configuration
1168
+ * Controls whether and how traffic is load balanced
1169
+ */
1170
+ export declare interface LoadBalancerConfig {
1171
+ enabled?: boolean
1172
+ type?: 'application' | 'network'
1173
+ healthCheck?: {
1174
+ path?: string
1175
+ interval?: number
1176
+ timeout?: number
1177
+ healthyThreshold?: number
1178
+ unhealthyThreshold?: number
1179
+ }
1180
+ idleTimeout?: number
1181
+ accessLogs?: {
1182
+ enabled?: boolean
1183
+ bucket?: string
1184
+ prefix?: string
1185
+ }
1186
+ }
1187
+ /**
1188
+ * SSL/TLS Configuration
1189
+ * Supports both AWS ACM certificates and Let's Encrypt
1190
+ */
1191
+ export declare interface SslConfig {
1192
+ enabled?: boolean
1193
+ provider?: 'acm' | 'letsencrypt'
1194
+ certificateArn?: string
1195
+ domains?: string[]
1196
+ redirectHttp?: boolean
1197
+ letsEncrypt?: {
1198
+ /**
1199
+ * Email for Let's Encrypt notifications
1200
+ */
1201
+ email?: string
1202
+
1203
+ /**
1204
+ * Use staging server for testing
1205
+ * @default false
1206
+ */
1207
+ staging?: boolean
1208
+
1209
+ /**
1210
+ * Auto-renew certificates
1211
+ * @default true
1212
+ */
1213
+ autoRenew?: boolean
1214
+ }
1215
+ }
1216
+ export type CloudOptions = Partial<CloudConfig>
1217
+ /**
1218
+ * Deployment mode (optional)
1219
+ * @deprecated Mode is now auto-detected from your infrastructure configuration.
1220
+ * Simply define the resources you need (functions, servers, storage, etc.) and
1221
+ * ts-cloud will deploy them accordingly. No need to specify a mode.
1222
+ */
1223
+ export type DeploymentMode = 'server' | 'serverless' | 'hybrid'
1224
+ export type EnvironmentType = 'production' | 'staging' | 'development'
1225
+ /**
1226
+ * Instance size presets
1227
+ * Provider-agnostic sizing that maps to appropriate instance types
1228
+ */
1229
+ export type InstanceSize = | 'nano' // ~0.5 vCPU, 0.5GB RAM
1230
+ | 'micro' // ~1 vCPU, 1GB RAM
1231
+ | 'small' // ~1 vCPU, 2GB RAM
1232
+ | 'medium' // ~2 vCPU, 4GB RAM
1233
+ | 'large' // ~2 vCPU, 8GB RAM
1234
+ | 'xlarge' // ~4 vCPU, 16GB RAM
1235
+ | '2xlarge' // ~8 vCPU, 32GB RAM
1236
+ | (string & {})
1237
+ /**
1238
+ * Realtime deployment mode
1239
+ * - 'serverless': Uses API Gateway WebSocket + Lambda (auto-scales, pay-per-use)
1240
+ * - 'server': Uses ts-broadcasting Bun WebSocket server on EC2/ECS (lowest latency)
1241
+ */
1242
+ export type RealtimeMode = 'serverless' | 'server'