@stacksjs/ts-cloud 0.1.3 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (187) hide show
  1. package/README.md +98 -13
  2. package/dist/aws/acm.d.ts +129 -0
  3. package/dist/aws/application-autoscaling.d.ts +282 -0
  4. package/dist/aws/bedrock.d.ts +2292 -0
  5. package/dist/aws/client.d.ts +79 -0
  6. package/dist/aws/cloudformation.d.ts +105 -0
  7. package/dist/aws/cloudfront.d.ts +265 -0
  8. package/dist/aws/cloudwatch-logs.d.ts +48 -0
  9. package/dist/aws/comprehend.d.ts +505 -0
  10. package/dist/aws/connect.d.ts +377 -0
  11. package/dist/aws/deploy-imap.d.ts +14 -0
  12. package/dist/aws/dynamodb.d.ts +176 -0
  13. package/dist/aws/ec2.d.ts +272 -0
  14. package/dist/aws/ecr.d.ts +149 -0
  15. package/dist/aws/ecs.d.ts +162 -0
  16. package/dist/aws/elasticache.d.ts +71 -0
  17. package/dist/aws/elbv2.d.ts +248 -0
  18. package/dist/aws/email.d.ts +175 -0
  19. package/dist/aws/eventbridge.d.ts +142 -0
  20. package/dist/aws/iam.d.ts +638 -0
  21. package/dist/aws/imap-server.d.ts +119 -0
  22. package/{src/aws/index.ts → dist/aws/index.d.ts} +62 -83
  23. package/{src/aws/kendra.ts → dist/aws/kendra.d.ts} +71 -386
  24. package/dist/aws/lambda.d.ts +232 -0
  25. package/dist/aws/opensearch.d.ts +87 -0
  26. package/dist/aws/personalize.d.ts +516 -0
  27. package/dist/aws/polly.d.ts +214 -0
  28. package/dist/aws/rds.d.ts +240 -0
  29. package/dist/aws/rekognition.d.ts +543 -0
  30. package/dist/aws/route53-domains.d.ts +113 -0
  31. package/dist/aws/route53.d.ts +215 -0
  32. package/dist/aws/s3.d.ts +212 -0
  33. package/dist/aws/scheduler.d.ts +140 -0
  34. package/dist/aws/secrets-manager.d.ts +170 -0
  35. package/dist/aws/ses.d.ts +288 -0
  36. package/dist/aws/setup-phone.d.ts +0 -0
  37. package/dist/aws/setup-sms.d.ts +115 -0
  38. package/dist/aws/sms.d.ts +304 -0
  39. package/dist/aws/smtp-server.d.ts +61 -0
  40. package/dist/aws/sns.d.ts +117 -0
  41. package/dist/aws/sqs.d.ts +65 -0
  42. package/dist/aws/ssm.d.ts +179 -0
  43. package/dist/aws/sts.d.ts +15 -0
  44. package/dist/aws/support.d.ts +104 -0
  45. package/dist/aws/test-imap.d.ts +0 -0
  46. package/dist/aws/textract.d.ts +403 -0
  47. package/dist/aws/transcribe.d.ts +60 -0
  48. package/dist/aws/translate.d.ts +358 -0
  49. package/dist/aws/voice.d.ts +219 -0
  50. package/dist/bin/cli.js +1724 -0
  51. package/dist/config.d.ts +7 -0
  52. package/dist/deploy/index.d.ts +2 -0
  53. package/dist/deploy/static-site-external-dns.d.ts +51 -0
  54. package/dist/deploy/static-site.d.ts +71 -0
  55. package/dist/dns/cloudflare.d.ts +52 -0
  56. package/dist/dns/godaddy.d.ts +38 -0
  57. package/dist/dns/index.d.ts +45 -0
  58. package/dist/dns/porkbun.d.ts +18 -0
  59. package/dist/dns/route53-adapter.d.ts +38 -0
  60. package/{src/dns/types.ts → dist/dns/types.d.ts} +26 -63
  61. package/dist/dns/validator.d.ts +78 -0
  62. package/dist/generators/index.d.ts +1 -0
  63. package/dist/generators/infrastructure.d.ts +30 -0
  64. package/{src/index.ts → dist/index.d.ts} +70 -93
  65. package/dist/index.js +7881 -0
  66. package/dist/push/apns.d.ts +60 -0
  67. package/dist/push/fcm.d.ts +117 -0
  68. package/dist/push/index.d.ts +14 -0
  69. package/dist/security/pre-deploy-scanner.d.ts +69 -0
  70. package/dist/ssl/acme-client.d.ts +67 -0
  71. package/dist/ssl/index.d.ts +2 -0
  72. package/dist/ssl/letsencrypt.d.ts +48 -0
  73. package/dist/types.d.ts +1 -0
  74. package/dist/utils/cli.d.ts +123 -0
  75. package/dist/validation/index.d.ts +1 -0
  76. package/dist/validation/template.d.ts +23 -0
  77. package/package.json +8 -8
  78. package/bin/cli.ts +0 -133
  79. package/bin/commands/analytics.ts +0 -328
  80. package/bin/commands/api.ts +0 -379
  81. package/bin/commands/assets.ts +0 -221
  82. package/bin/commands/audit.ts +0 -501
  83. package/bin/commands/backup.ts +0 -682
  84. package/bin/commands/cache.ts +0 -294
  85. package/bin/commands/cdn.ts +0 -281
  86. package/bin/commands/config.ts +0 -202
  87. package/bin/commands/container.ts +0 -105
  88. package/bin/commands/cost.ts +0 -208
  89. package/bin/commands/database.ts +0 -401
  90. package/bin/commands/deploy.ts +0 -674
  91. package/bin/commands/domain.ts +0 -397
  92. package/bin/commands/email.ts +0 -423
  93. package/bin/commands/environment.ts +0 -285
  94. package/bin/commands/events.ts +0 -424
  95. package/bin/commands/firewall.ts +0 -145
  96. package/bin/commands/function.ts +0 -116
  97. package/bin/commands/generate.ts +0 -280
  98. package/bin/commands/git.ts +0 -139
  99. package/bin/commands/iam.ts +0 -464
  100. package/bin/commands/index.ts +0 -48
  101. package/bin/commands/init.ts +0 -120
  102. package/bin/commands/logs.ts +0 -148
  103. package/bin/commands/network.ts +0 -579
  104. package/bin/commands/notify.ts +0 -489
  105. package/bin/commands/queue.ts +0 -407
  106. package/bin/commands/scheduler.ts +0 -370
  107. package/bin/commands/secrets.ts +0 -54
  108. package/bin/commands/server.ts +0 -629
  109. package/bin/commands/shared.ts +0 -97
  110. package/bin/commands/ssl.ts +0 -138
  111. package/bin/commands/stack.ts +0 -325
  112. package/bin/commands/status.ts +0 -385
  113. package/bin/commands/storage.ts +0 -450
  114. package/bin/commands/team.ts +0 -96
  115. package/bin/commands/tunnel.ts +0 -489
  116. package/bin/commands/utils.ts +0 -202
  117. package/build.ts +0 -15
  118. package/cloud +0 -2
  119. package/src/aws/acm.ts +0 -768
  120. package/src/aws/application-autoscaling.ts +0 -845
  121. package/src/aws/bedrock.ts +0 -4074
  122. package/src/aws/client.ts +0 -878
  123. package/src/aws/cloudformation.ts +0 -896
  124. package/src/aws/cloudfront.ts +0 -1531
  125. package/src/aws/cloudwatch-logs.ts +0 -154
  126. package/src/aws/comprehend.ts +0 -839
  127. package/src/aws/connect.ts +0 -1056
  128. package/src/aws/deploy-imap.ts +0 -384
  129. package/src/aws/dynamodb.ts +0 -340
  130. package/src/aws/ec2.ts +0 -1385
  131. package/src/aws/ecr.ts +0 -621
  132. package/src/aws/ecs.ts +0 -615
  133. package/src/aws/elasticache.ts +0 -301
  134. package/src/aws/elbv2.ts +0 -942
  135. package/src/aws/email.ts +0 -928
  136. package/src/aws/eventbridge.ts +0 -248
  137. package/src/aws/iam.ts +0 -1689
  138. package/src/aws/imap-server.ts +0 -2100
  139. package/src/aws/lambda.ts +0 -786
  140. package/src/aws/opensearch.ts +0 -158
  141. package/src/aws/personalize.ts +0 -977
  142. package/src/aws/polly.ts +0 -559
  143. package/src/aws/rds.ts +0 -888
  144. package/src/aws/rekognition.ts +0 -846
  145. package/src/aws/route53-domains.ts +0 -359
  146. package/src/aws/route53.ts +0 -1046
  147. package/src/aws/s3.ts +0 -2318
  148. package/src/aws/scheduler.ts +0 -571
  149. package/src/aws/secrets-manager.ts +0 -769
  150. package/src/aws/ses.ts +0 -1081
  151. package/src/aws/setup-phone.ts +0 -104
  152. package/src/aws/setup-sms.ts +0 -580
  153. package/src/aws/sms.ts +0 -1735
  154. package/src/aws/smtp-server.ts +0 -531
  155. package/src/aws/sns.ts +0 -758
  156. package/src/aws/sqs.ts +0 -382
  157. package/src/aws/ssm.ts +0 -807
  158. package/src/aws/sts.ts +0 -92
  159. package/src/aws/support.ts +0 -391
  160. package/src/aws/test-imap.ts +0 -86
  161. package/src/aws/textract.ts +0 -780
  162. package/src/aws/transcribe.ts +0 -108
  163. package/src/aws/translate.ts +0 -641
  164. package/src/aws/voice.ts +0 -1379
  165. package/src/config.ts +0 -35
  166. package/src/deploy/index.ts +0 -7
  167. package/src/deploy/static-site-external-dns.ts +0 -906
  168. package/src/deploy/static-site.ts +0 -1125
  169. package/src/dns/godaddy.ts +0 -412
  170. package/src/dns/index.ts +0 -183
  171. package/src/dns/porkbun.ts +0 -362
  172. package/src/dns/route53-adapter.ts +0 -414
  173. package/src/dns/validator.ts +0 -369
  174. package/src/generators/index.ts +0 -5
  175. package/src/generators/infrastructure.ts +0 -1660
  176. package/src/push/apns.ts +0 -452
  177. package/src/push/fcm.ts +0 -506
  178. package/src/push/index.ts +0 -58
  179. package/src/ssl/acme-client.ts +0 -478
  180. package/src/ssl/index.ts +0 -7
  181. package/src/ssl/letsencrypt.ts +0 -747
  182. package/src/types.ts +0 -2
  183. package/src/utils/cli.ts +0 -398
  184. package/src/validation/index.ts +0 -5
  185. package/src/validation/template.ts +0 -405
  186. package/test/index.test.ts +0 -128
  187. package/tsconfig.json +0 -18
package/src/aws/ses.ts DELETED
@@ -1,1081 +0,0 @@
1
- /**
2
- * AWS SES (Simple Email Service) Operations
3
- * Direct API calls without AWS SDK dependency
4
- */
5
-
6
- import { AWSClient } from './client'
7
-
8
- export interface EmailIdentity {
9
- IdentityType?: 'EMAIL_ADDRESS' | 'DOMAIN' | 'MANAGED_DOMAIN'
10
- IdentityName?: string
11
- SendingEnabled?: boolean
12
- VerificationStatus?: 'PENDING' | 'SUCCESS' | 'FAILED' | 'TEMPORARY_FAILURE' | 'NOT_STARTED'
13
- DkimAttributes?: {
14
- SigningEnabled?: boolean
15
- Status?: 'PENDING' | 'SUCCESS' | 'FAILED' | 'TEMPORARY_FAILURE' | 'NOT_STARTED'
16
- Tokens?: string[]
17
- SigningAttributesOrigin?: 'AWS_SES' | 'EXTERNAL'
18
- }
19
- MailFromAttributes?: {
20
- MailFromDomain?: string
21
- MailFromDomainStatus?: 'PENDING' | 'SUCCESS' | 'FAILED' | 'TEMPORARY_FAILURE'
22
- BehaviorOnMxFailure?: 'USE_DEFAULT_VALUE' | 'REJECT_MESSAGE'
23
- }
24
- }
25
-
26
- export interface SendEmailResult {
27
- MessageId?: string
28
- }
29
-
30
- /**
31
- * SES email service management using direct API calls
32
- */
33
- export class SESClient {
34
- private client: AWSClient
35
- private region: string
36
-
37
- constructor(region: string = 'us-east-1') {
38
- this.region = region
39
- this.client = new AWSClient()
40
- }
41
-
42
- /**
43
- * Create email identity (domain or email address)
44
- * Uses SES v2 API
45
- */
46
- async createEmailIdentity(params: {
47
- EmailIdentity: string
48
- DkimSigningAttributes?: {
49
- DomainSigningSelector?: string
50
- DomainSigningPrivateKey?: string
51
- }
52
- Tags?: Array<{ Key: string, Value: string }>
53
- }): Promise<{
54
- IdentityType?: string
55
- VerifiedForSendingStatus?: boolean
56
- DkimAttributes?: {
57
- SigningEnabled?: boolean
58
- Status?: string
59
- Tokens?: string[]
60
- SigningAttributesOrigin?: string
61
- }
62
- }> {
63
- const result = await this.client.request({
64
- service: 'email',
65
- region: this.region,
66
- method: 'POST',
67
- path: '/v2/email/identities',
68
- headers: {
69
- 'Content-Type': 'application/json',
70
- },
71
- body: JSON.stringify(params),
72
- })
73
-
74
- return result
75
- }
76
-
77
- /**
78
- * Get email identity details
79
- */
80
- async getEmailIdentity(emailIdentity: string): Promise<EmailIdentity> {
81
- const result = await this.client.request({
82
- service: 'email',
83
- region: this.region,
84
- method: 'GET',
85
- path: `/v2/email/identities/${encodeURIComponent(emailIdentity)}`,
86
- headers: {
87
- 'Content-Type': 'application/json',
88
- },
89
- })
90
-
91
- return {
92
- IdentityType: result.IdentityType,
93
- IdentityName: emailIdentity,
94
- SendingEnabled: result.VerifiedForSendingStatus,
95
- VerificationStatus: result.VerificationStatus,
96
- DkimAttributes: result.DkimAttributes,
97
- MailFromAttributes: result.MailFromAttributes,
98
- }
99
- }
100
-
101
- /**
102
- * Configure MAIL FROM domain for an email identity
103
- */
104
- async putEmailIdentityMailFromAttributes(emailIdentity: string, params: {
105
- MailFromDomain?: string
106
- BehaviorOnMxFailure?: 'USE_DEFAULT_VALUE' | 'REJECT_MESSAGE'
107
- }): Promise<void> {
108
- await this.client.request({
109
- service: 'email',
110
- region: this.region,
111
- method: 'PUT',
112
- path: `/v2/email/identities/${encodeURIComponent(emailIdentity)}/mail-from`,
113
- headers: {
114
- 'Content-Type': 'application/json',
115
- },
116
- body: JSON.stringify(params),
117
- })
118
- }
119
-
120
- /**
121
- * List email identities
122
- */
123
- async listEmailIdentities(params?: {
124
- PageSize?: number
125
- NextToken?: string
126
- }): Promise<{
127
- EmailIdentities?: Array<{
128
- IdentityType?: string
129
- IdentityName?: string
130
- SendingEnabled?: boolean
131
- }>
132
- NextToken?: string
133
- }> {
134
- let path = '/v2/email/identities'
135
- const queryParams: string[] = []
136
-
137
- if (params?.PageSize) {
138
- queryParams.push(`PageSize=${params.PageSize}`)
139
- }
140
- if (params?.NextToken) {
141
- queryParams.push(`NextToken=${encodeURIComponent(params.NextToken)}`)
142
- }
143
-
144
- if (queryParams.length > 0) {
145
- path += `?${queryParams.join('&')}`
146
- }
147
-
148
- const result = await this.client.request({
149
- service: 'email',
150
- region: this.region,
151
- method: 'GET',
152
- path,
153
- headers: {
154
- 'Content-Type': 'application/json',
155
- },
156
- })
157
-
158
- return {
159
- EmailIdentities: result.EmailIdentities,
160
- NextToken: result.NextToken,
161
- }
162
- }
163
-
164
- /**
165
- * Delete email identity
166
- */
167
- async deleteEmailIdentity(emailIdentity: string): Promise<void> {
168
- await this.client.request({
169
- service: 'email',
170
- region: this.region,
171
- method: 'DELETE',
172
- path: `/v2/email/identities/${encodeURIComponent(emailIdentity)}`,
173
- headers: {
174
- 'Content-Type': 'application/json',
175
- },
176
- })
177
- }
178
-
179
- /**
180
- * Enable/disable DKIM signing for identity
181
- */
182
- async putEmailIdentityDkimAttributes(params: {
183
- EmailIdentity: string
184
- SigningEnabled: boolean
185
- }): Promise<void> {
186
- await this.client.request({
187
- service: 'email',
188
- region: this.region,
189
- method: 'PUT',
190
- path: `/v2/email/identities/${encodeURIComponent(params.EmailIdentity)}/dkim`,
191
- headers: {
192
- 'Content-Type': 'application/json',
193
- },
194
- body: JSON.stringify({ SigningEnabled: params.SigningEnabled }),
195
- })
196
- }
197
-
198
- /**
199
- * Send email
200
- */
201
- async sendEmail(params: {
202
- FromEmailAddress: string
203
- Destination: {
204
- ToAddresses?: string[]
205
- CcAddresses?: string[]
206
- BccAddresses?: string[]
207
- }
208
- Content: {
209
- Simple?: {
210
- Subject: { Data: string, Charset?: string }
211
- Body: {
212
- Text?: { Data: string, Charset?: string }
213
- Html?: { Data: string, Charset?: string }
214
- }
215
- }
216
- Raw?: {
217
- Data: string // Base64 encoded
218
- }
219
- Template?: {
220
- TemplateName: string
221
- TemplateData?: string
222
- }
223
- }
224
- ReplyToAddresses?: string[]
225
- ConfigurationSetName?: string
226
- }): Promise<SendEmailResult> {
227
- const result = await this.client.request({
228
- service: 'email',
229
- region: this.region,
230
- method: 'POST',
231
- path: '/v2/email/outbound-emails',
232
- headers: {
233
- 'Content-Type': 'application/json',
234
- },
235
- body: JSON.stringify(params),
236
- })
237
-
238
- return {
239
- MessageId: result.MessageId,
240
- }
241
- }
242
-
243
- /**
244
- * Send bulk email
245
- */
246
- async sendBulkEmail(params: {
247
- FromEmailAddress: string
248
- BulkEmailEntries: Array<{
249
- Destination: {
250
- ToAddresses?: string[]
251
- CcAddresses?: string[]
252
- BccAddresses?: string[]
253
- }
254
- ReplacementEmailContent?: {
255
- ReplacementTemplate?: {
256
- ReplacementTemplateData?: string
257
- }
258
- }
259
- }>
260
- DefaultContent: {
261
- Template: {
262
- TemplateName: string
263
- TemplateData?: string
264
- }
265
- }
266
- ConfigurationSetName?: string
267
- }): Promise<{
268
- BulkEmailEntryResults?: Array<{
269
- Status?: string
270
- Error?: string
271
- MessageId?: string
272
- }>
273
- }> {
274
- const result = await this.client.request({
275
- service: 'email',
276
- region: this.region,
277
- method: 'POST',
278
- path: '/v2/email/outbound-bulk-emails',
279
- headers: {
280
- 'Content-Type': 'application/json',
281
- },
282
- body: JSON.stringify(params),
283
- })
284
-
285
- return {
286
- BulkEmailEntryResults: result.BulkEmailEntryResults,
287
- }
288
- }
289
-
290
- /**
291
- * Create email template
292
- */
293
- async createEmailTemplate(params: {
294
- TemplateName: string
295
- TemplateContent: {
296
- Subject?: string
297
- Text?: string
298
- Html?: string
299
- }
300
- }): Promise<void> {
301
- await this.client.request({
302
- service: 'email',
303
- region: this.region,
304
- method: 'POST',
305
- path: '/v2/email/templates',
306
- headers: {
307
- 'Content-Type': 'application/json',
308
- },
309
- body: JSON.stringify(params),
310
- })
311
- }
312
-
313
- /**
314
- * Get email template
315
- */
316
- async getEmailTemplate(templateName: string): Promise<{
317
- TemplateName?: string
318
- TemplateContent?: {
319
- Subject?: string
320
- Text?: string
321
- Html?: string
322
- }
323
- }> {
324
- const result = await this.client.request({
325
- service: 'email',
326
- region: this.region,
327
- method: 'GET',
328
- path: `/v2/email/templates/${encodeURIComponent(templateName)}`,
329
- headers: {
330
- 'Content-Type': 'application/json',
331
- },
332
- })
333
-
334
- return result
335
- }
336
-
337
- /**
338
- * Delete email template
339
- */
340
- async deleteEmailTemplate(templateName: string): Promise<void> {
341
- await this.client.request({
342
- service: 'email',
343
- region: this.region,
344
- method: 'DELETE',
345
- path: `/v2/email/templates/${encodeURIComponent(templateName)}`,
346
- headers: {
347
- 'Content-Type': 'application/json',
348
- },
349
- })
350
- }
351
-
352
- /**
353
- * List email templates
354
- */
355
- async listEmailTemplates(params?: {
356
- PageSize?: number
357
- NextToken?: string
358
- }): Promise<{
359
- TemplatesMetadata?: Array<{
360
- TemplateName?: string
361
- CreatedTimestamp?: string
362
- }>
363
- NextToken?: string
364
- }> {
365
- let path = '/v2/email/templates'
366
- const queryParams: string[] = []
367
-
368
- if (params?.PageSize) {
369
- queryParams.push(`PageSize=${params.PageSize}`)
370
- }
371
- if (params?.NextToken) {
372
- queryParams.push(`NextToken=${encodeURIComponent(params.NextToken)}`)
373
- }
374
-
375
- if (queryParams.length > 0) {
376
- path += `?${queryParams.join('&')}`
377
- }
378
-
379
- const result = await this.client.request({
380
- service: 'email',
381
- region: this.region,
382
- method: 'GET',
383
- path,
384
- headers: {
385
- 'Content-Type': 'application/json',
386
- },
387
- })
388
-
389
- return result
390
- }
391
-
392
- /**
393
- * Get sending statistics
394
- */
395
- async getSendStatistics(): Promise<{
396
- SendDataPoints?: Array<{
397
- Timestamp?: string
398
- DeliveryAttempts?: number
399
- Bounces?: number
400
- Complaints?: number
401
- Rejects?: number
402
- }>
403
- }> {
404
- // Use legacy v1 API for this
405
- const result = await this.client.request({
406
- service: 'ses',
407
- region: this.region,
408
- method: 'POST',
409
- path: '/',
410
- headers: {
411
- 'Content-Type': 'application/x-www-form-urlencoded',
412
- },
413
- body: 'Action=GetSendStatistics&Version=2010-12-01',
414
- })
415
-
416
- return {
417
- SendDataPoints: result.GetSendStatisticsResponse?.GetSendStatisticsResult?.SendDataPoints?.member,
418
- }
419
- }
420
-
421
- /**
422
- * Get sending quota
423
- */
424
- async getSendQuota(): Promise<{
425
- Max24HourSend?: number
426
- MaxSendRate?: number
427
- SentLast24Hours?: number
428
- }> {
429
- // Use legacy v1 API for this
430
- const result = await this.client.request({
431
- service: 'ses',
432
- region: this.region,
433
- method: 'POST',
434
- path: '/',
435
- headers: {
436
- 'Content-Type': 'application/x-www-form-urlencoded',
437
- },
438
- body: 'Action=GetSendQuota&Version=2010-12-01',
439
- })
440
-
441
- const quota = result.GetSendQuotaResponse?.GetSendQuotaResult
442
- return {
443
- Max24HourSend: quota?.Max24HourSend ? Number(quota.Max24HourSend) : undefined,
444
- MaxSendRate: quota?.MaxSendRate ? Number(quota.MaxSendRate) : undefined,
445
- SentLast24Hours: quota?.SentLast24Hours ? Number(quota.SentLast24Hours) : undefined,
446
- }
447
- }
448
-
449
- // Helper methods
450
-
451
- /**
452
- * Verify a domain identity
453
- */
454
- async verifyDomain(domain: string): Promise<{
455
- dkimTokens?: string[]
456
- verificationStatus?: string
457
- }> {
458
- const result = await this.createEmailIdentity({
459
- EmailIdentity: domain,
460
- })
461
-
462
- return {
463
- dkimTokens: result.DkimAttributes?.Tokens,
464
- verificationStatus: result.DkimAttributes?.Status,
465
- }
466
- }
467
-
468
- /**
469
- * Send a simple text email
470
- */
471
- async sendSimpleEmail(params: {
472
- from: string
473
- to: string | string[]
474
- subject: string
475
- text?: string
476
- html?: string
477
- replyTo?: string | string[]
478
- }): Promise<SendEmailResult> {
479
- const toAddresses = Array.isArray(params.to) ? params.to : [params.to]
480
- const replyToAddresses = params.replyTo
481
- ? (Array.isArray(params.replyTo) ? params.replyTo : [params.replyTo])
482
- : undefined
483
-
484
- const body: any = {}
485
- if (params.text) {
486
- body.Text = { Data: params.text }
487
- }
488
- if (params.html) {
489
- body.Html = { Data: params.html }
490
- }
491
-
492
- return this.sendEmail({
493
- FromEmailAddress: params.from,
494
- Destination: {
495
- ToAddresses: toAddresses,
496
- },
497
- Content: {
498
- Simple: {
499
- Subject: { Data: params.subject },
500
- Body: body,
501
- },
502
- },
503
- ReplyToAddresses: replyToAddresses,
504
- })
505
- }
506
-
507
- /**
508
- * Send a templated email
509
- */
510
- async sendTemplatedEmail(params: {
511
- from: string
512
- to: string | string[]
513
- templateName: string
514
- templateData: Record<string, any>
515
- replyTo?: string | string[]
516
- }): Promise<SendEmailResult> {
517
- const toAddresses = Array.isArray(params.to) ? params.to : [params.to]
518
- const replyToAddresses = params.replyTo
519
- ? (Array.isArray(params.replyTo) ? params.replyTo : [params.replyTo])
520
- : undefined
521
-
522
- return this.sendEmail({
523
- FromEmailAddress: params.from,
524
- Destination: {
525
- ToAddresses: toAddresses,
526
- },
527
- Content: {
528
- Template: {
529
- TemplateName: params.templateName,
530
- TemplateData: JSON.stringify(params.templateData),
531
- },
532
- },
533
- ReplyToAddresses: replyToAddresses,
534
- })
535
- }
536
-
537
- /**
538
- * Get DKIM DNS records for a domain
539
- */
540
- async getDkimRecords(domain: string): Promise<Array<{
541
- name: string
542
- type: string
543
- value: string
544
- }>> {
545
- const identity = await this.getEmailIdentity(domain)
546
-
547
- if (!identity.DkimAttributes?.Tokens) {
548
- return []
549
- }
550
-
551
- return identity.DkimAttributes.Tokens.map(token => ({
552
- name: `${token}._domainkey.${domain}`,
553
- type: 'CNAME',
554
- value: `${token}.dkim.amazonses.com`,
555
- }))
556
- }
557
-
558
- /**
559
- * Check if domain is verified
560
- */
561
- async isDomainVerified(domain: string): Promise<boolean> {
562
- try {
563
- const identity = await this.getEmailIdentity(domain)
564
- return identity.VerificationStatus === 'SUCCESS' && identity.SendingEnabled === true
565
- }
566
- catch {
567
- return false
568
- }
569
- }
570
-
571
- /**
572
- * Wait for domain verification
573
- */
574
- async waitForDomainVerification(
575
- domain: string,
576
- maxAttempts = 60,
577
- delayMs = 30000,
578
- ): Promise<boolean> {
579
- for (let i = 0; i < maxAttempts; i++) {
580
- const isVerified = await this.isDomainVerified(domain)
581
-
582
- if (isVerified) {
583
- return true
584
- }
585
-
586
- await new Promise(resolve => setTimeout(resolve, delayMs))
587
- }
588
-
589
- return false
590
- }
591
-
592
- // ============================================
593
- // SES v1 API - Receipt Rules (for inbound email)
594
- // Note: Receipt rules use the legacy SES v1 API
595
- // ============================================
596
-
597
- /**
598
- * Build form-encoded body for SES v1 API
599
- */
600
- private buildFormBody(params: Record<string, string | undefined>): string {
601
- const entries = Object.entries(params)
602
- .filter(([, value]) => value !== undefined)
603
- .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value!)}`)
604
- return entries.join('&')
605
- }
606
-
607
- /**
608
- * Create a receipt rule set
609
- * Uses SES v1 API
610
- */
611
- async createReceiptRuleSet(ruleSetName: string): Promise<void> {
612
- await this.client.request({
613
- service: 'ses',
614
- region: this.region,
615
- method: 'POST',
616
- path: '/',
617
- headers: {
618
- 'Content-Type': 'application/x-www-form-urlencoded',
619
- },
620
- body: this.buildFormBody({
621
- Action: 'CreateReceiptRuleSet',
622
- Version: '2010-12-01',
623
- RuleSetName: ruleSetName,
624
- }),
625
- })
626
- }
627
-
628
- /**
629
- * Delete a receipt rule set
630
- */
631
- async deleteReceiptRuleSet(ruleSetName: string): Promise<void> {
632
- await this.client.request({
633
- service: 'ses',
634
- region: this.region,
635
- method: 'POST',
636
- path: '/',
637
- headers: {
638
- 'Content-Type': 'application/x-www-form-urlencoded',
639
- },
640
- body: this.buildFormBody({
641
- Action: 'DeleteReceiptRuleSet',
642
- Version: '2010-12-01',
643
- RuleSetName: ruleSetName,
644
- }),
645
- })
646
- }
647
-
648
- /**
649
- * Set the active receipt rule set
650
- */
651
- async setActiveReceiptRuleSet(ruleSetName: string): Promise<void> {
652
- await this.client.request({
653
- service: 'ses',
654
- region: this.region,
655
- method: 'POST',
656
- path: '/',
657
- headers: {
658
- 'Content-Type': 'application/x-www-form-urlencoded',
659
- },
660
- body: this.buildFormBody({
661
- Action: 'SetActiveReceiptRuleSet',
662
- Version: '2010-12-01',
663
- RuleSetName: ruleSetName,
664
- }),
665
- })
666
- }
667
-
668
- /**
669
- * List receipt rule sets
670
- */
671
- async listReceiptRuleSets(nextToken?: string): Promise<{
672
- RuleSets?: Array<{ Name?: string, CreatedTimestamp?: string }>
673
- NextToken?: string
674
- }> {
675
- const formParams: Record<string, string | undefined> = {
676
- Action: 'ListReceiptRuleSets',
677
- Version: '2010-12-01',
678
- }
679
-
680
- if (nextToken) {
681
- formParams.NextToken = nextToken
682
- }
683
-
684
- const result = await this.client.request({
685
- service: 'ses',
686
- region: this.region,
687
- method: 'POST',
688
- path: '/',
689
- headers: {
690
- 'Content-Type': 'application/x-www-form-urlencoded',
691
- },
692
- body: this.buildFormBody(formParams),
693
- })
694
-
695
- // Handle both response formats (with and without Response wrapper)
696
- const ruleSetsResult = result?.ListReceiptRuleSetsResponse?.ListReceiptRuleSetsResult
697
- || result?.ListReceiptRuleSetsResult
698
- const ruleSets = ruleSetsResult?.RuleSets?.member
699
- return {
700
- RuleSets: Array.isArray(ruleSets) ? ruleSets : ruleSets ? [ruleSets] : [],
701
- NextToken: ruleSetsResult?.NextToken,
702
- }
703
- }
704
-
705
- /**
706
- * Describe a receipt rule set
707
- */
708
- async describeReceiptRuleSet(ruleSetName: string): Promise<{
709
- Metadata?: { Name?: string, CreatedTimestamp?: string }
710
- Rules?: Array<{
711
- Name?: string
712
- Enabled?: boolean
713
- Recipients?: string[]
714
- Actions?: Array<{
715
- S3Action?: { BucketName?: string, ObjectKeyPrefix?: string }
716
- LambdaAction?: { FunctionArn?: string, InvocationType?: string }
717
- SNSAction?: { TopicArn?: string }
718
- }>
719
- }>
720
- }> {
721
- const result = await this.client.request({
722
- service: 'ses',
723
- region: this.region,
724
- method: 'POST',
725
- path: '/',
726
- headers: {
727
- 'Content-Type': 'application/x-www-form-urlencoded',
728
- },
729
- body: this.buildFormBody({
730
- Action: 'DescribeReceiptRuleSet',
731
- Version: '2010-12-01',
732
- RuleSetName: ruleSetName,
733
- }),
734
- })
735
-
736
- // Handle both response formats (with and without Response wrapper)
737
- const response = result?.DescribeReceiptRuleSetResponse?.DescribeReceiptRuleSetResult
738
- || result?.DescribeReceiptRuleSetResult
739
- const rules = response?.Rules?.member
740
- return {
741
- Metadata: response?.Metadata,
742
- Rules: Array.isArray(rules) ? rules : rules ? [rules] : [],
743
- }
744
- }
745
-
746
- /**
747
- * Create a receipt rule
748
- */
749
- async createReceiptRule(params: {
750
- RuleSetName: string
751
- Rule: {
752
- Name: string
753
- Enabled?: boolean
754
- TlsPolicy?: 'Require' | 'Optional'
755
- Recipients?: string[]
756
- ScanEnabled?: boolean
757
- Actions: Array<{
758
- S3Action?: {
759
- BucketName: string
760
- ObjectKeyPrefix?: string
761
- KmsKeyArn?: string
762
- }
763
- LambdaAction?: {
764
- FunctionArn: string
765
- InvocationType?: 'Event' | 'RequestResponse'
766
- }
767
- SNSAction?: {
768
- TopicArn: string
769
- Encoding?: 'UTF-8' | 'Base64'
770
- }
771
- StopAction?: {
772
- Scope: 'RuleSet'
773
- TopicArn?: string
774
- }
775
- }>
776
- }
777
- After?: string
778
- }): Promise<void> {
779
- const formParams: Record<string, string | undefined> = {
780
- Action: 'CreateReceiptRule',
781
- Version: '2010-12-01',
782
- RuleSetName: params.RuleSetName,
783
- 'Rule.Name': params.Rule.Name,
784
- 'Rule.Enabled': params.Rule.Enabled !== false ? 'true' : 'false',
785
- }
786
-
787
- if (params.Rule.TlsPolicy) {
788
- formParams['Rule.TlsPolicy'] = params.Rule.TlsPolicy
789
- }
790
-
791
- if (params.Rule.ScanEnabled !== undefined) {
792
- formParams['Rule.ScanEnabled'] = params.Rule.ScanEnabled ? 'true' : 'false'
793
- }
794
-
795
- if (params.After) {
796
- formParams.After = params.After
797
- }
798
-
799
- // Add recipients
800
- if (params.Rule.Recipients) {
801
- params.Rule.Recipients.forEach((recipient, index) => {
802
- formParams[`Rule.Recipients.member.${index + 1}`] = recipient
803
- })
804
- }
805
-
806
- // Add actions
807
- params.Rule.Actions.forEach((action, index) => {
808
- const actionNum = index + 1
809
-
810
- if (action.S3Action) {
811
- formParams[`Rule.Actions.member.${actionNum}.S3Action.BucketName`] = action.S3Action.BucketName
812
- if (action.S3Action.ObjectKeyPrefix) {
813
- formParams[`Rule.Actions.member.${actionNum}.S3Action.ObjectKeyPrefix`] = action.S3Action.ObjectKeyPrefix
814
- }
815
- if (action.S3Action.KmsKeyArn) {
816
- formParams[`Rule.Actions.member.${actionNum}.S3Action.KmsKeyArn`] = action.S3Action.KmsKeyArn
817
- }
818
- }
819
-
820
- if (action.LambdaAction) {
821
- formParams[`Rule.Actions.member.${actionNum}.LambdaAction.FunctionArn`] = action.LambdaAction.FunctionArn
822
- formParams[`Rule.Actions.member.${actionNum}.LambdaAction.InvocationType`] = action.LambdaAction.InvocationType || 'Event'
823
- }
824
-
825
- if (action.SNSAction) {
826
- formParams[`Rule.Actions.member.${actionNum}.SNSAction.TopicArn`] = action.SNSAction.TopicArn
827
- if (action.SNSAction.Encoding) {
828
- formParams[`Rule.Actions.member.${actionNum}.SNSAction.Encoding`] = action.SNSAction.Encoding
829
- }
830
- }
831
-
832
- if (action.StopAction) {
833
- formParams[`Rule.Actions.member.${actionNum}.StopAction.Scope`] = action.StopAction.Scope
834
- if (action.StopAction.TopicArn) {
835
- formParams[`Rule.Actions.member.${actionNum}.StopAction.TopicArn`] = action.StopAction.TopicArn
836
- }
837
- }
838
- })
839
-
840
- await this.client.request({
841
- service: 'ses',
842
- region: this.region,
843
- method: 'POST',
844
- path: '/',
845
- headers: {
846
- 'Content-Type': 'application/x-www-form-urlencoded',
847
- },
848
- body: this.buildFormBody(formParams),
849
- })
850
- }
851
-
852
- /**
853
- * Delete a receipt rule
854
- */
855
- async deleteReceiptRule(ruleSetName: string, ruleName: string): Promise<void> {
856
- await this.client.request({
857
- service: 'ses',
858
- region: this.region,
859
- method: 'POST',
860
- path: '/',
861
- headers: {
862
- 'Content-Type': 'application/x-www-form-urlencoded',
863
- },
864
- body: this.buildFormBody({
865
- Action: 'DeleteReceiptRule',
866
- Version: '2010-12-01',
867
- RuleSetName: ruleSetName,
868
- RuleName: ruleName,
869
- }),
870
- })
871
- }
872
-
873
- /**
874
- * Check if receipt rule set exists
875
- */
876
- async receiptRuleSetExists(ruleSetName: string): Promise<boolean> {
877
- try {
878
- await this.describeReceiptRuleSet(ruleSetName)
879
- return true
880
- }
881
- catch (error: any) {
882
- if (error.code === 'RuleSetDoesNotExist' || error.statusCode === 400) {
883
- return false
884
- }
885
- throw error
886
- }
887
- }
888
-
889
- /**
890
- * Get the active receipt rule set
891
- */
892
- async getActiveReceiptRuleSet(): Promise<{
893
- Metadata?: { Name?: string, CreatedTimestamp?: string }
894
- Rules?: Array<{
895
- Name?: string
896
- Enabled?: boolean
897
- Recipients?: string[]
898
- Actions?: Array<{
899
- S3Action?: { BucketName?: string, ObjectKeyPrefix?: string }
900
- LambdaAction?: { FunctionArn?: string, InvocationType?: string }
901
- SNSAction?: { TopicArn?: string }
902
- }>
903
- }>
904
- } | null> {
905
- const result = await this.client.request({
906
- service: 'ses',
907
- region: this.region,
908
- method: 'POST',
909
- path: '/',
910
- headers: {
911
- 'Content-Type': 'application/x-www-form-urlencoded',
912
- },
913
- body: this.buildFormBody({
914
- Action: 'DescribeActiveReceiptRuleSet',
915
- Version: '2010-12-01',
916
- }),
917
- })
918
-
919
- // Handle response format
920
- const response = result?.DescribeActiveReceiptRuleSetResponse?.DescribeActiveReceiptRuleSetResult
921
- || result?.DescribeActiveReceiptRuleSetResult
922
-
923
- if (!response?.Metadata) {
924
- return null // No active rule set
925
- }
926
-
927
- const rules = response?.Rules?.member
928
- return {
929
- Metadata: response?.Metadata,
930
- Rules: Array.isArray(rules) ? rules : rules ? [rules] : [],
931
- }
932
- }
933
-
934
- /**
935
- * Update a receipt rule
936
- */
937
- async updateReceiptRule(params: {
938
- RuleSetName: string
939
- Rule: {
940
- Name: string
941
- Enabled?: boolean
942
- TlsPolicy?: 'Require' | 'Optional'
943
- Recipients?: string[]
944
- ScanEnabled?: boolean
945
- Actions: Array<{
946
- S3Action?: {
947
- BucketName: string
948
- ObjectKeyPrefix?: string
949
- KmsKeyArn?: string
950
- }
951
- LambdaAction?: {
952
- FunctionArn: string
953
- InvocationType?: 'Event' | 'RequestResponse'
954
- }
955
- SNSAction?: {
956
- TopicArn: string
957
- Encoding?: 'UTF-8' | 'Base64'
958
- }
959
- StopAction?: {
960
- Scope: 'RuleSet'
961
- TopicArn?: string
962
- }
963
- }>
964
- }
965
- }): Promise<void> {
966
- const formParams: Record<string, string | undefined> = {
967
- Action: 'UpdateReceiptRule',
968
- Version: '2010-12-01',
969
- RuleSetName: params.RuleSetName,
970
- 'Rule.Name': params.Rule.Name,
971
- }
972
-
973
- if (params.Rule.Enabled !== undefined) {
974
- formParams['Rule.Enabled'] = params.Rule.Enabled ? 'true' : 'false'
975
- }
976
-
977
- if (params.Rule.TlsPolicy) {
978
- formParams['Rule.TlsPolicy'] = params.Rule.TlsPolicy
979
- }
980
-
981
- if (params.Rule.ScanEnabled !== undefined) {
982
- formParams['Rule.ScanEnabled'] = params.Rule.ScanEnabled ? 'true' : 'false'
983
- }
984
-
985
- // Add recipients
986
- if (params.Rule.Recipients) {
987
- params.Rule.Recipients.forEach((recipient, index) => {
988
- formParams[`Rule.Recipients.member.${index + 1}`] = recipient
989
- })
990
- }
991
-
992
- // Add actions
993
- params.Rule.Actions.forEach((action, index) => {
994
- const actionNum = index + 1
995
-
996
- if (action.S3Action) {
997
- formParams[`Rule.Actions.member.${actionNum}.S3Action.BucketName`] = action.S3Action.BucketName
998
- if (action.S3Action.ObjectKeyPrefix) {
999
- formParams[`Rule.Actions.member.${actionNum}.S3Action.ObjectKeyPrefix`] = action.S3Action.ObjectKeyPrefix
1000
- }
1001
- if (action.S3Action.KmsKeyArn) {
1002
- formParams[`Rule.Actions.member.${actionNum}.S3Action.KmsKeyArn`] = action.S3Action.KmsKeyArn
1003
- }
1004
- }
1005
-
1006
- if (action.LambdaAction) {
1007
- formParams[`Rule.Actions.member.${actionNum}.LambdaAction.FunctionArn`] = action.LambdaAction.FunctionArn
1008
- formParams[`Rule.Actions.member.${actionNum}.LambdaAction.InvocationType`] = action.LambdaAction.InvocationType || 'Event'
1009
- }
1010
-
1011
- if (action.SNSAction) {
1012
- formParams[`Rule.Actions.member.${actionNum}.SNSAction.TopicArn`] = action.SNSAction.TopicArn
1013
- if (action.SNSAction.Encoding) {
1014
- formParams[`Rule.Actions.member.${actionNum}.SNSAction.Encoding`] = action.SNSAction.Encoding
1015
- }
1016
- }
1017
-
1018
- if (action.StopAction) {
1019
- formParams[`Rule.Actions.member.${actionNum}.StopAction.Scope`] = action.StopAction.Scope
1020
- if (action.StopAction.TopicArn) {
1021
- formParams[`Rule.Actions.member.${actionNum}.StopAction.TopicArn`] = action.StopAction.TopicArn
1022
- }
1023
- }
1024
- })
1025
-
1026
- await this.client.request({
1027
- service: 'ses',
1028
- region: this.region,
1029
- method: 'POST',
1030
- path: '/',
1031
- headers: {
1032
- 'Content-Type': 'application/x-www-form-urlencoded',
1033
- },
1034
- body: this.buildFormBody(formParams),
1035
- })
1036
- }
1037
-
1038
- /**
1039
- * Send raw email (for SMTP relay)
1040
- * Uses SES v1 API SendRawEmail action
1041
- */
1042
- async sendRawEmail(params: {
1043
- source: string
1044
- destinations: string[]
1045
- rawMessage: string
1046
- }): Promise<{ MessageId?: string }> {
1047
- // Encode the raw message as base64
1048
- const rawMessageBase64 = Buffer.from(params.rawMessage).toString('base64')
1049
-
1050
- const formParams: Record<string, string | undefined> = {
1051
- Action: 'SendRawEmail',
1052
- Version: '2010-12-01',
1053
- Source: params.source,
1054
- 'RawMessage.Data': rawMessageBase64,
1055
- }
1056
-
1057
- // Add destinations
1058
- params.destinations.forEach((dest, index) => {
1059
- formParams[`Destinations.member.${index + 1}`] = dest
1060
- })
1061
-
1062
- const result = await this.client.request({
1063
- service: 'ses',
1064
- region: this.region,
1065
- method: 'POST',
1066
- path: '/',
1067
- headers: {
1068
- 'Content-Type': 'application/x-www-form-urlencoded',
1069
- },
1070
- body: this.buildFormBody(formParams),
1071
- })
1072
-
1073
- // Handle response format
1074
- const response = result?.SendRawEmailResponse?.SendRawEmailResult
1075
- || result?.SendRawEmailResult
1076
-
1077
- return {
1078
- MessageId: response?.MessageId,
1079
- }
1080
- }
1081
- }