@stacksjs/ts-cloud-types 0.1.6 → 0.1.7

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