@ts-cloud/core 0.2.3 → 0.2.4
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.
- package/dist/advanced-features.test.d.ts +1 -0
- package/dist/aws/cloudformation.d.ts +136 -0
- package/dist/aws/cloudfront.d.ts +45 -0
- package/dist/aws/credentials.d.ts +77 -0
- package/dist/aws/credentials.test.d.ts +4 -0
- package/dist/aws/index.d.ts +10 -0
- package/dist/aws/s3.d.ts +256 -0
- package/dist/aws/s3.test.d.ts +4 -0
- package/dist/aws/signature.d.ts +142 -0
- package/dist/aws/signature.test.d.ts +4 -0
- package/dist/backup/disaster-recovery.d.ts +140 -0
- package/dist/backup/disaster-recovery.test.d.ts +1 -0
- package/dist/backup/index.d.ts +8 -0
- package/dist/backup/manager.d.ts +172 -0
- package/dist/backup/manager.test.d.ts +1 -0
- package/dist/cicd/circleci.d.ts +50 -0
- package/dist/cicd/github-actions.d.ts +62 -0
- package/dist/cicd/gitlab-ci.d.ts +50 -0
- package/dist/cicd/index.d.ts +7 -0
- package/dist/cli/history.d.ts +137 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/progress.d.ts +193 -0
- package/dist/cli/repl.d.ts +148 -0
- package/dist/cli/suggestions.d.ts +74 -0
- package/dist/cli/table.d.ts +73 -0
- package/dist/cli/table.test.d.ts +1 -0
- package/dist/cloudformation/builder.d.ts +93 -0
- package/dist/cloudformation/builder.test.d.ts +4 -0
- package/dist/cloudformation/builders/api-gateway.d.ts +30 -0
- package/dist/cloudformation/builders/cache.d.ts +35 -0
- package/dist/cloudformation/builders/cdn.d.ts +34 -0
- package/dist/cloudformation/builders/compute.d.ts +68 -0
- package/dist/cloudformation/builders/database.d.ts +61 -0
- package/dist/cloudformation/builders/functions.d.ts +32 -0
- package/dist/cloudformation/builders/messaging.d.ts +17 -0
- package/dist/cloudformation/builders/monitoring.d.ts +39 -0
- package/dist/cloudformation/builders/network.d.ts +14 -0
- package/dist/cloudformation/builders/queue.d.ts +16 -0
- package/dist/cloudformation/builders/security.d.ts +31 -0
- package/dist/cloudformation/builders/storage.d.ts +36 -0
- package/dist/cloudformation/index.d.ts +10 -0
- package/dist/cloudformation/types.d.ts +200 -0
- package/dist/compliance/aws-config.d.ts +175 -0
- package/dist/compliance/cloudtrail.d.ts +132 -0
- package/dist/compliance/compliance.test.d.ts +1 -0
- package/dist/compliance/guardduty.d.ts +176 -0
- package/dist/compliance/index.d.ts +12 -0
- package/dist/compliance/security-hub.d.ts +178 -0
- package/dist/containers/build-optimization.d.ts +155 -0
- package/dist/containers/containers.test.d.ts +1 -0
- package/dist/containers/image-scanning.d.ts +144 -0
- package/dist/containers/index.d.ts +8 -0
- package/dist/containers/registry.d.ts +129 -0
- package/dist/containers/service-mesh.d.ts +254 -0
- package/dist/database/database.test.d.ts +1 -0
- package/dist/database/index.d.ts +8 -0
- package/dist/database/migrations.d.ts +153 -0
- package/dist/database/performance.d.ts +219 -0
- package/dist/database/replicas.d.ts +218 -0
- package/dist/database/users.d.ts +165 -0
- package/dist/dependency-graph.d.ts +37 -0
- package/dist/deployment/ab-testing.d.ts +165 -0
- package/dist/deployment/blue-green.d.ts +140 -0
- package/dist/deployment/canary.d.ts +165 -0
- package/dist/deployment/deployment.test.d.ts +1 -0
- package/dist/deployment/index.d.ts +12 -0
- package/dist/deployment/progressive.d.ts +50 -0
- package/dist/dns/dns.test.d.ts +1 -0
- package/dist/dns/dnssec.d.ts +120 -0
- package/dist/dns/index.d.ts +7 -0
- package/dist/dns/resolver.d.ts +216 -0
- package/dist/dns/routing.d.ts +277 -0
- package/dist/email/advanced/analytics.d.ts +107 -0
- package/dist/email/advanced/index.d.ts +10 -0
- package/dist/email/advanced/rules.d.ts +131 -0
- package/dist/email/advanced/scheduling.d.ts +81 -0
- package/dist/email/advanced/search.d.ts +91 -0
- package/dist/email/advanced/shared-mailboxes.d.ts +109 -0
- package/dist/email/advanced/templates.d.ts +95 -0
- package/dist/email/advanced/threading.d.ts +65 -0
- package/dist/email/analytics.d.ts +189 -0
- package/dist/email/bounce-handling.d.ts +171 -0
- package/dist/email/email.test.d.ts +1 -0
- package/dist/email/handlers/__tests__/inbound.test.d.ts +1 -0
- package/dist/email/handlers/__tests__/outbound.test.d.ts +1 -0
- package/dist/email/handlers/converter.d.ts +11 -0
- package/dist/email/handlers/feedback.d.ts +11 -0
- package/dist/email/handlers/inbound.d.ts +13 -0
- package/dist/email/handlers/outbound.d.ts +13 -0
- package/dist/email/index.d.ts +10 -0
- package/dist/email/reputation.d.ts +133 -0
- package/dist/email/templates.d.ts +124 -0
- package/dist/errors/index.d.ts +177 -0
- package/dist/errors/index.test.d.ts +4 -0
- package/dist/health-checks/index.d.ts +35 -0
- package/dist/index.d.ts +15 -256
- package/dist/index.js +228 -80
- package/dist/intrinsic-functions.d.ts +77 -0
- package/dist/lambda/concurrency.d.ts +146 -0
- package/dist/lambda/destinations.d.ts +141 -0
- package/dist/lambda/dlq.d.ts +160 -0
- package/dist/lambda/index.d.ts +10 -0
- package/dist/lambda/lambda.test.d.ts +1 -0
- package/dist/lambda/layers.d.ts +117 -0
- package/dist/lambda/versions.d.ts +145 -0
- package/dist/lambda/vpc.d.ts +164 -0
- package/dist/local/config.d.ts +44 -0
- package/dist/local/index.d.ts +5 -0
- package/dist/local/mock-aws.d.ts +69 -0
- package/dist/modules/ai.d.ts +108 -0
- package/dist/modules/api.d.ts +157 -0
- package/dist/modules/auth.d.ts +262 -0
- package/dist/modules/cache.d.ts +108 -0
- package/dist/modules/cdn.d.ts +305 -0
- package/dist/modules/communication.d.ts +117 -0
- package/dist/modules/compute.d.ts +1376 -0
- package/dist/modules/database.d.ts +144 -0
- package/dist/modules/deployment.d.ts +372 -0
- package/dist/modules/dns.d.ts +143 -0
- package/dist/modules/email.d.ts +314 -0
- package/dist/modules/filesystem.d.ts +132 -0
- package/dist/modules/index.d.ts +31 -0
- package/dist/modules/messaging.d.ts +210 -0
- package/dist/modules/monitoring.d.ts +574 -0
- package/dist/modules/network.d.ts +148 -0
- package/dist/modules/parameter-store.d.ts +143 -0
- package/dist/modules/permissions.d.ts +245 -0
- package/dist/modules/phone.d.ts +125 -0
- package/dist/modules/queue.d.ts +411 -0
- package/dist/modules/redirects.d.ts +140 -0
- package/dist/modules/registry.d.ts +189 -0
- package/dist/modules/search.d.ts +135 -0
- package/dist/modules/secrets.d.ts +149 -0
- package/dist/modules/security.d.ts +219 -0
- package/dist/modules/sms.d.ts +130 -0
- package/dist/modules/storage.d.ts +344 -0
- package/dist/modules/workflow.d.ts +288 -0
- package/dist/multi-account/config.d.ts +166 -0
- package/dist/multi-account/index.d.ts +6 -0
- package/dist/multi-account/manager.d.ts +181 -0
- package/dist/multi-region/cross-region.d.ts +204 -0
- package/dist/multi-region/index.d.ts +7 -0
- package/dist/multi-region/manager.d.ts +136 -0
- package/dist/multi-region/regions.d.ts +98 -0
- package/dist/network-security/index.d.ts +55 -0
- package/dist/observability/index.d.ts +8 -0
- package/dist/observability/logs.d.ts +213 -0
- package/dist/observability/metrics.d.ts +187 -0
- package/dist/observability/observability.test.d.ts +1 -0
- package/dist/observability/synthetics.d.ts +189 -0
- package/dist/observability/xray.d.ts +193 -0
- package/dist/phone/advanced/analytics.d.ts +83 -0
- package/dist/phone/advanced/callbacks.d.ts +67 -0
- package/dist/phone/advanced/index.d.ts +7 -0
- package/dist/phone/advanced/ivr-builder.d.ts +130 -0
- package/dist/phone/advanced/recording.d.ts +62 -0
- package/dist/phone/handlers/__tests__/incoming-call.test.d.ts +1 -0
- package/dist/phone/handlers/incoming-call.d.ts +10 -0
- package/dist/phone/handlers/missed-call.d.ts +9 -0
- package/dist/phone/handlers/voicemail.d.ts +10 -0
- package/dist/phone/index.d.ts +5 -0
- package/dist/presets/api-backend.d.ts +11 -0
- package/dist/presets/data-pipeline.d.ts +11 -0
- package/dist/presets/extend.d.ts +194 -0
- package/dist/presets/extend.test.d.ts +4 -0
- package/dist/presets/fullstack-app.d.ts +12 -0
- package/dist/presets/index.d.ts +13 -0
- package/dist/presets/jamstack.d.ts +12 -0
- package/dist/presets/microservices.d.ts +18 -0
- package/dist/presets/ml-api.d.ts +13 -0
- package/dist/presets/nodejs-server.d.ts +14 -0
- package/dist/presets/nodejs-serverless.d.ts +14 -0
- package/dist/presets/realtime-app.d.ts +11 -0
- package/dist/presets/static-site.d.ts +12 -0
- package/dist/presets/traditional-web-app.d.ts +16 -0
- package/dist/presets/wordpress.d.ts +12 -0
- package/dist/preview/github.d.ts +32 -0
- package/dist/preview/github.test.d.ts +1 -0
- package/dist/preview/index.d.ts +10 -0
- package/dist/preview/manager.d.ts +101 -0
- package/dist/preview/manager.test.d.ts +1 -0
- package/dist/preview/notifications.d.ts +89 -0
- package/dist/preview/notifications.test.d.ts +1 -0
- package/dist/queue/batch-processing.d.ts +138 -0
- package/dist/queue/dlq-monitoring.d.ts +143 -0
- package/dist/queue/fifo.d.ts +131 -0
- package/dist/queue/index.d.ts +8 -0
- package/dist/queue/management.d.ts +162 -0
- package/dist/queue/queue.test.d.ts +1 -0
- package/dist/resource-mgmt/index.d.ts +44 -0
- package/dist/resource-naming.d.ts +26 -0
- package/dist/s3/index.d.ts +227 -0
- package/dist/schema/index.d.ts +12 -0
- package/dist/security/certificate-manager.d.ts +184 -0
- package/dist/security/index.d.ts +8 -0
- package/dist/security/scanning.d.ts +196 -0
- package/dist/security/secrets-manager.d.ts +204 -0
- package/dist/security/secrets-rotation.d.ts +167 -0
- package/dist/security/security.test.d.ts +1 -0
- package/dist/sms/advanced/ab-testing.d.ts +74 -0
- package/dist/sms/advanced/analytics.d.ts +75 -0
- package/dist/sms/advanced/campaigns.d.ts +96 -0
- package/dist/sms/advanced/chatbot.d.ts +67 -0
- package/dist/sms/advanced/index.d.ts +9 -0
- package/dist/sms/advanced/link-tracking.d.ts +60 -0
- package/dist/sms/advanced/mms.d.ts +60 -0
- package/dist/sms/handlers/__tests__/send.test.d.ts +1 -0
- package/dist/sms/handlers/delivery-status.d.ts +10 -0
- package/dist/sms/handlers/receive.d.ts +10 -0
- package/dist/sms/handlers/send.d.ts +10 -0
- package/dist/sms/index.d.ts +5 -0
- package/dist/stack-diff.d.ts +38 -0
- package/dist/static-site/index.d.ts +49 -0
- package/dist/template-builder.d.ts +42 -0
- package/dist/template-validator.d.ts +28 -0
- package/dist/types.d.ts +2514 -0
- package/dist/utils/cache.d.ts +117 -0
- package/dist/utils/diff.d.ts +52 -0
- package/dist/utils/hash.d.ts +73 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/parallel.d.ts +78 -0
- package/dist/validators/credentials.d.ts +30 -0
- package/dist/validators/credentials.test.d.ts +4 -0
- package/dist/validators/quotas.d.ts +64 -0
- package/dist/validators/quotas.test.d.ts +4 -0
- package/package.json +2 -2
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Link Shortening and Tracking
|
|
3
|
+
*
|
|
4
|
+
* Provides URL shortening and click tracking for SMS
|
|
5
|
+
*/
|
|
6
|
+
export interface ShortenedLink {
|
|
7
|
+
id: string;
|
|
8
|
+
originalUrl: string;
|
|
9
|
+
shortUrl: string;
|
|
10
|
+
campaignId?: string;
|
|
11
|
+
messageId?: string;
|
|
12
|
+
clicks: number;
|
|
13
|
+
uniqueClicks: number;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
expiresAt?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface LinkClick {
|
|
18
|
+
linkId: string;
|
|
19
|
+
clickedAt: string;
|
|
20
|
+
userAgent?: string;
|
|
21
|
+
ipAddress?: string;
|
|
22
|
+
country?: string;
|
|
23
|
+
device?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Link Tracking Module
|
|
27
|
+
*/
|
|
28
|
+
export declare class LinkTracking {
|
|
29
|
+
/**
|
|
30
|
+
* Lambda code for link shortening
|
|
31
|
+
*/
|
|
32
|
+
static LinkShortenerCode: string;
|
|
33
|
+
/**
|
|
34
|
+
* Create links DynamoDB table
|
|
35
|
+
*/
|
|
36
|
+
static createLinksTable(config: {
|
|
37
|
+
slug: string;
|
|
38
|
+
}): Record<string, any>;
|
|
39
|
+
/**
|
|
40
|
+
* Create link shortener Lambda
|
|
41
|
+
*/
|
|
42
|
+
static createLinkShortenerLambda(config: {
|
|
43
|
+
slug: string;
|
|
44
|
+
roleArn: string;
|
|
45
|
+
linksTable: string;
|
|
46
|
+
shortDomain?: string;
|
|
47
|
+
}): Record<string, any>;
|
|
48
|
+
/**
|
|
49
|
+
* Shorten URLs in message text
|
|
50
|
+
*/
|
|
51
|
+
static shortenUrlsInMessage(message: string, shortDomain: string, linkIdPrefix: string): {
|
|
52
|
+
message: string;
|
|
53
|
+
links: Array<{
|
|
54
|
+
original: string;
|
|
55
|
+
short: string;
|
|
56
|
+
id: string;
|
|
57
|
+
}>;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export default LinkTracking;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MMS Support (Images, Media)
|
|
3
|
+
*
|
|
4
|
+
* Provides multimedia messaging capabilities
|
|
5
|
+
*/
|
|
6
|
+
export interface MmsMessage {
|
|
7
|
+
to: string;
|
|
8
|
+
body?: string;
|
|
9
|
+
mediaUrls: string[];
|
|
10
|
+
mediaType?: 'image' | 'video' | 'audio' | 'document';
|
|
11
|
+
fallbackSms?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface MmsMedia {
|
|
14
|
+
url: string;
|
|
15
|
+
contentType: string;
|
|
16
|
+
size: number;
|
|
17
|
+
filename?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* MMS Module
|
|
21
|
+
*/
|
|
22
|
+
export declare class MmsSupport {
|
|
23
|
+
/**
|
|
24
|
+
* Lambda code for MMS sending
|
|
25
|
+
*/
|
|
26
|
+
static MmsSenderCode: string;
|
|
27
|
+
/**
|
|
28
|
+
* Create media storage bucket
|
|
29
|
+
*/
|
|
30
|
+
static createMediaBucket(config: {
|
|
31
|
+
slug: string;
|
|
32
|
+
}): Record<string, any>;
|
|
33
|
+
/**
|
|
34
|
+
* Create MMS sender Lambda
|
|
35
|
+
*/
|
|
36
|
+
static createMmsSenderLambda(config: {
|
|
37
|
+
slug: string;
|
|
38
|
+
roleArn: string;
|
|
39
|
+
mediaBucket: string;
|
|
40
|
+
messageLogTable: string;
|
|
41
|
+
originationNumber?: string;
|
|
42
|
+
}): Record<string, any>;
|
|
43
|
+
/**
|
|
44
|
+
* Supported media types
|
|
45
|
+
*/
|
|
46
|
+
static readonly SupportedMediaTypes: {
|
|
47
|
+
readonly image: readonly ["image/jpeg", "image/png", "image/gif"];
|
|
48
|
+
readonly video: readonly ["video/mp4", "video/3gpp"];
|
|
49
|
+
readonly audio: readonly ["audio/mpeg", "audio/wav"];
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Media size limits (in bytes)
|
|
53
|
+
*/
|
|
54
|
+
static readonly MediaSizeLimits: {
|
|
55
|
+
image: number;
|
|
56
|
+
video: number;
|
|
57
|
+
audio: number;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export default MmsSupport;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMS Delivery Status Lambda Handler
|
|
3
|
+
*
|
|
4
|
+
* Processes delivery status updates:
|
|
5
|
+
* - Process delivery receipts
|
|
6
|
+
* - Update message status
|
|
7
|
+
* - Handle failures
|
|
8
|
+
*/
|
|
9
|
+
export declare const handler = "\nconst { DynamoDBClient, UpdateItemCommand } = require('@aws-sdk/client-dynamodb');\nconst { SNSClient, PublishCommand } = require('@aws-sdk/client-sns');\n\nconst dynamodb = new DynamoDBClient({});\nconst sns = new SNSClient({});\n\nexports.handler = async (event) => {\n console.log('SMS delivery status event:', JSON.stringify(event, null, 2));\n\n const messageLogTable = process.env.MESSAGE_LOG_TABLE;\n const notificationTopicArn = process.env.NOTIFICATION_TOPIC_ARN;\n const webhookUrl = process.env.WEBHOOK_URL;\n\n for (const record of event.Records) {\n try {\n // Parse delivery status from SNS/Pinpoint\n const message = JSON.parse(record.Sns?.Message || record.body || '{}');\n\n const {\n eventType,\n messageId,\n destinationPhoneNumber,\n messageStatus,\n messageStatusDescription,\n isoCountryCode,\n mcc,\n mnc,\n priceInMillicentsUSD,\n } = message;\n\n if (!messageId) {\n console.log('No messageId in delivery status');\n continue;\n }\n\n const timestamp = new Date().toISOString();\n const status = messageStatus || eventType || 'UNKNOWN';\n\n console.log(`Delivery status for ${messageId}: ${status}`);\n\n // Update message log\n if (messageLogTable) {\n await dynamodb.send(new UpdateItemCommand({\n TableName: messageLogTable,\n Key: {\n messageId: { S: messageId },\n },\n UpdateExpression: 'SET deliveryStatus = :status, statusDescription = :desc, deliveredAt = :at, priceMillicents = :price, countryCode = :country',\n ExpressionAttributeValues: {\n ':status': { S: status },\n ':desc': { S: messageStatusDescription || '' },\n ':at': { S: timestamp },\n ':price': { N: String(priceInMillicentsUSD || 0) },\n ':country': { S: isoCountryCode || '' },\n },\n }));\n }\n\n // Handle failures - notify admin\n const isFailure = ['FAILED', 'UNREACHABLE', 'UNKNOWN', 'CARRIER_UNREACHABLE', 'BLOCKED', 'CARRIER_BLOCKED', 'INVALID', 'INVALID_MESSAGE', 'OPTED_OUT'].includes(status);\n\n if (isFailure) {\n console.log(`SMS delivery failed: ${status} - ${messageStatusDescription}`);\n\n // Send failure notification\n if (notificationTopicArn) {\n await sns.send(new PublishCommand({\n TopicArn: notificationTopicArn,\n Subject: `SMS Delivery Failed: ${status}`,\n Message: JSON.stringify({\n type: 'sms_delivery_failed',\n messageId,\n to: destinationPhoneNumber,\n status,\n description: messageStatusDescription,\n countryCode: isoCountryCode,\n timestamp,\n }, null, 2),\n MessageAttributes: {\n eventType: {\n DataType: 'String',\n StringValue: 'sms_delivery_failed',\n },\n },\n }));\n }\n }\n\n // Forward to webhook for all status updates\n if (webhookUrl) {\n try {\n await fetch(webhookUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n event: 'sms_delivery_status',\n data: {\n messageId,\n to: destinationPhoneNumber,\n status,\n description: messageStatusDescription,\n countryCode: isoCountryCode,\n carrier: { mcc, mnc },\n priceMillicents: priceInMillicentsUSD,\n timestamp,\n },\n }),\n });\n }\ncatch (err) {\n console.error('Webhook failed:', err.message);\n }\n }\n\n }\ncatch (error) {\n console.error('Error processing delivery status:', error);\n }\n }\n\n return { statusCode: 200, body: 'OK' };\n};\n";
|
|
10
|
+
export default handler;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMS Receive Lambda Handler
|
|
3
|
+
*
|
|
4
|
+
* Processes inbound SMS messages:
|
|
5
|
+
* - Process inbound SMS (two-way)
|
|
6
|
+
* - Handle opt-out keywords
|
|
7
|
+
* - Forward to webhook
|
|
8
|
+
*/
|
|
9
|
+
export declare const handler = "\nconst { DynamoDBClient, PutItemCommand, DeleteItemCommand } = require('@aws-sdk/client-dynamodb');\nconst { SNSClient, PublishCommand } = require('@aws-sdk/client-sns');\n\nconst dynamodb = new DynamoDBClient({});\nconst sns = new SNSClient({});\n\nconst OPT_OUT_KEYWORDS = ['STOP', 'UNSUBSCRIBE', 'CANCEL', 'END', 'QUIT', 'OPTOUT', 'OPT OUT'];\nconst OPT_IN_KEYWORDS = ['START', 'SUBSCRIBE', 'OPTIN', 'OPT IN', 'YES'];\n\nexports.handler = async (event) => {\n console.log('SMS receive event:', JSON.stringify(event, null, 2));\n\n const optOutTable = process.env.OPT_OUT_TABLE;\n const messageLogTable = process.env.MESSAGE_LOG_TABLE;\n const notificationTopicArn = process.env.NOTIFICATION_TOPIC_ARN;\n const webhookUrl = process.env.WEBHOOK_URL;\n\n for (const record of event.Records) {\n try {\n // Parse SNS message from Pinpoint\n const message = JSON.parse(record.Sns?.Message || record.body || '{}');\n\n const {\n originationNumber,\n destinationNumber,\n messageBody,\n messageKeyword,\n inboundMessageId,\n } = message;\n\n if (!originationNumber || !messageBody) {\n console.log('Missing required fields');\n continue;\n }\n\n const timestamp = new Date().toISOString();\n const normalizedBody = messageBody.trim().toUpperCase();\n\n // Check for opt-out keywords\n if (OPT_OUT_KEYWORDS.some(kw => normalizedBody === kw || normalizedBody.startsWith(kw + ' '))) {\n console.log(`Opt-out request from ${originationNumber}`);\n\n if (optOutTable) {\n await dynamodb.send(new PutItemCommand({\n TableName: optOutTable,\n Item: {\n phoneNumber: { S: originationNumber },\n optedOutAt: { S: timestamp },\n keyword: { S: normalizedBody.split(' ')[0] },\n originalMessage: { S: messageBody },\n },\n }));\n }\n\n // Send confirmation (optional - check carrier requirements)\n // await sendOptOutConfirmation(originationNumber, destinationNumber);\n\n continue;\n }\n\n // Check for opt-in keywords\n if (OPT_IN_KEYWORDS.some(kw => normalizedBody === kw || normalizedBody.startsWith(kw + ' '))) {\n console.log(`Opt-in request from ${originationNumber}`);\n\n if (optOutTable) {\n await dynamodb.send(new DeleteItemCommand({\n TableName: optOutTable,\n Key: {\n phoneNumber: { S: originationNumber },\n },\n }));\n }\n\n continue;\n }\n\n // Log inbound message\n if (messageLogTable) {\n await dynamodb.send(new PutItemCommand({\n TableName: messageLogTable,\n Item: {\n messageId: { S: inboundMessageId || `inbound-${Date.now()}` },\n direction: { S: 'inbound' },\n from: { S: originationNumber },\n to: { S: destinationNumber },\n body: { S: messageBody },\n keyword: { S: messageKeyword || '' },\n receivedAt: { S: timestamp },\n ttl: { N: String(Math.floor(Date.now() / 1000) + 90 * 24 * 60 * 60) },\n },\n }));\n }\n\n // Send SNS notification\n if (notificationTopicArn) {\n await sns.send(new PublishCommand({\n TopicArn: notificationTopicArn,\n Subject: 'Inbound SMS',\n Message: JSON.stringify({\n type: 'inbound_sms',\n from: originationNumber,\n to: destinationNumber,\n body: messageBody,\n keyword: messageKeyword,\n timestamp,\n }, null, 2),\n MessageAttributes: {\n eventType: {\n DataType: 'String',\n StringValue: 'inbound_sms',\n },\n },\n }));\n }\n\n // Forward to webhook\n if (webhookUrl) {\n try {\n const response = await fetch(webhookUrl, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n event: 'inbound_sms',\n data: {\n from: originationNumber,\n to: destinationNumber,\n body: messageBody,\n keyword: messageKeyword,\n messageId: inboundMessageId,\n timestamp,\n },\n }),\n });\n\n console.log(`Webhook response: ${response.status}`);\n }\ncatch (err) {\n console.error('Webhook failed:', err.message);\n }\n }\n\n console.log(`Processed inbound SMS from ${originationNumber}`);\n\n }\ncatch (error) {\n console.error('Error processing inbound SMS:', error);\n }\n }\n\n return { statusCode: 200, body: 'OK' };\n};\n";
|
|
10
|
+
export default handler;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMS Send Lambda Handler
|
|
3
|
+
*
|
|
4
|
+
* Sends SMS messages:
|
|
5
|
+
* - Send SMS via Pinpoint/SNS
|
|
6
|
+
* - Handle templated messages
|
|
7
|
+
* - Track delivery status
|
|
8
|
+
*/
|
|
9
|
+
export declare const handler = "\nconst { PinpointClient, SendMessagesCommand } = require('@aws-sdk/client-pinpoint');\nconst { SNSClient, PublishCommand } = require('@aws-sdk/client-sns');\nconst { DynamoDBClient, PutItemCommand } = require('@aws-sdk/client-dynamodb');\n\nconst pinpoint = new PinpointClient({});\nconst sns = new SNSClient({});\nconst dynamodb = new DynamoDBClient({});\n\nexports.handler = async (event) => {\n console.log('SMS send event:', JSON.stringify(event, null, 2));\n\n const applicationId = process.env.PINPOINT_APP_ID;\n const messageLogTable = process.env.MESSAGE_LOG_TABLE;\n const senderId = process.env.SMS_SENDER_ID;\n const originationNumber = process.env.SMS_ORIGINATION_NUMBER;\n\n // Handle both direct invocation and SQS/SNS events\n const messages = event.Records\n ? event.Records.map(r => JSON.parse(r.body || r.Sns?.Message || '{}'))\n : [event];\n\n const results = [];\n\n for (const message of messages) {\n try {\n const {\n to,\n body,\n template,\n templateData,\n messageType = 'TRANSACTIONAL',\n } = message;\n\n if (!to || (!body && !template)) {\n console.log('Missing required fields (to, body/template)');\n continue;\n }\n\n // Resolve template if provided\n let messageBody = body;\n if (template && templateData) {\n messageBody = resolveTemplate(template, templateData);\n }\n\n const messageId = `sms-${Date.now()}-${Math.random().toString(36).substr(2)}`;\n\n // Send via Pinpoint if app ID is configured\n if (applicationId) {\n const sendResult = await pinpoint.send(new SendMessagesCommand({\n ApplicationId: applicationId,\n MessageRequest: {\n Addresses: {\n [to]: {\n ChannelType: 'SMS',\n },\n },\n MessageConfiguration: {\n SMSMessage: {\n Body: messageBody,\n MessageType: messageType,\n SenderId: senderId,\n OriginationNumber: originationNumber,\n },\n },\n },\n }));\n\n const result = sendResult.MessageResponse?.Result?.[to] || {};\n\n // Log message\n if (messageLogTable) {\n await dynamodb.send(new PutItemCommand({\n TableName: messageLogTable,\n Item: {\n messageId: { S: result.MessageId || messageId },\n to: { S: to },\n body: { S: messageBody },\n messageType: { S: messageType },\n deliveryStatus: { S: result.DeliveryStatus || 'UNKNOWN' },\n statusCode: { N: String(result.StatusCode || 0) },\n statusMessage: { S: result.StatusMessage || '' },\n sentAt: { S: new Date().toISOString() },\n ttl: { N: String(Math.floor(Date.now() / 1000) + 90 * 24 * 60 * 60) },\n },\n }));\n }\n\n results.push({\n to,\n messageId: result.MessageId || messageId,\n status: result.DeliveryStatus,\n statusCode: result.StatusCode,\n });\n\n }\nelse {\n // Fallback to SNS\n const snsResult = await sns.send(new PublishCommand({\n PhoneNumber: to,\n Message: messageBody,\n MessageAttributes: {\n 'AWS.SNS.SMS.SMSType': {\n DataType: 'String',\n StringValue: messageType === 'PROMOTIONAL' ? 'Promotional' : 'Transactional',\n },\n ...(senderId && {\n 'AWS.SNS.SMS.SenderID': {\n DataType: 'String',\n StringValue: senderId,\n },\n }),\n },\n }));\n\n // Log message\n if (messageLogTable) {\n await dynamodb.send(new PutItemCommand({\n TableName: messageLogTable,\n Item: {\n messageId: { S: snsResult.MessageId || messageId },\n to: { S: to },\n body: { S: messageBody },\n messageType: { S: messageType },\n deliveryStatus: { S: 'SENT' },\n sentAt: { S: new Date().toISOString() },\n ttl: { N: String(Math.floor(Date.now() / 1000) + 90 * 24 * 60 * 60) },\n },\n }));\n }\n\n results.push({\n to,\n messageId: snsResult.MessageId || messageId,\n status: 'SENT',\n });\n }\n\n console.log(`SMS sent to ${to}: ${results[results.length - 1].status}`);\n\n }\ncatch (error) {\n console.error('Error sending SMS:', error);\n results.push({\n to: message.to,\n error: error.message,\n status: 'FAILED',\n });\n }\n }\n\n return {\n statusCode: 200,\n body: JSON.stringify({ results }),\n };\n};\n\nfunction resolveTemplate(template, data) {\n let result = template;\n for (const [key, value] of Object.entries(data)) {\n result = result.replace(new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'), value);\n }\n return result;\n}\n";
|
|
10
|
+
export default handler;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stack Diff Analyzer
|
|
3
|
+
* Analyzes differences between CloudFormation templates for stack updates
|
|
4
|
+
*/
|
|
5
|
+
import type { CloudFormationTemplate } from '@ts-cloud/aws-types';
|
|
6
|
+
export interface ResourceDiff {
|
|
7
|
+
logicalId: string;
|
|
8
|
+
action: 'add' | 'remove' | 'update' | 'replace';
|
|
9
|
+
resourceType: string;
|
|
10
|
+
changes?: PropertyChange[];
|
|
11
|
+
reason?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PropertyChange {
|
|
14
|
+
path: string;
|
|
15
|
+
oldValue: any;
|
|
16
|
+
newValue: any;
|
|
17
|
+
requiresReplacement?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface StackDiff {
|
|
20
|
+
added: ResourceDiff[];
|
|
21
|
+
removed: ResourceDiff[];
|
|
22
|
+
updated: ResourceDiff[];
|
|
23
|
+
replaced: ResourceDiff[];
|
|
24
|
+
unchanged: string[];
|
|
25
|
+
summary: {
|
|
26
|
+
totalChanges: number;
|
|
27
|
+
requiresReplacement: boolean;
|
|
28
|
+
dangerousChanges: string[];
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Analyze differences between two CloudFormation templates
|
|
33
|
+
*/
|
|
34
|
+
export declare function analyzeStackDiff(oldTemplate: CloudFormationTemplate, newTemplate: CloudFormationTemplate): StackDiff;
|
|
35
|
+
/**
|
|
36
|
+
* Format diff for display
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatDiff(diff: StackDiff): string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static Site Advanced Features
|
|
3
|
+
* Asset optimization, image optimization, SSG support, and prerendering
|
|
4
|
+
*/
|
|
5
|
+
export interface AssetOptimization {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
minify: boolean;
|
|
9
|
+
compress: boolean;
|
|
10
|
+
compressionType: 'gzip' | 'brotli' | 'both';
|
|
11
|
+
sourceMaps: boolean;
|
|
12
|
+
cacheControl: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ImageOptimization {
|
|
15
|
+
id: string;
|
|
16
|
+
formats: Array<'webp' | 'avif' | 'jpeg' | 'png'>;
|
|
17
|
+
quality: number;
|
|
18
|
+
responsive: boolean;
|
|
19
|
+
lazy: boolean;
|
|
20
|
+
sizes: number[];
|
|
21
|
+
}
|
|
22
|
+
export interface SSGConfig {
|
|
23
|
+
id: string;
|
|
24
|
+
framework: 'next' | 'gatsby' | 'astro' | 'hugo' | 'eleventy';
|
|
25
|
+
outputDir: string;
|
|
26
|
+
buildCommand: string;
|
|
27
|
+
routes: string[];
|
|
28
|
+
}
|
|
29
|
+
export interface PrerenderConfig {
|
|
30
|
+
id: string;
|
|
31
|
+
routes: string[];
|
|
32
|
+
fallback: 'blocking' | 'static' | false;
|
|
33
|
+
revalidate?: number;
|
|
34
|
+
}
|
|
35
|
+
export declare class StaticSiteManager {
|
|
36
|
+
private optimizations;
|
|
37
|
+
private imageConfigs;
|
|
38
|
+
private ssgConfigs;
|
|
39
|
+
private prerenderConfigs;
|
|
40
|
+
private counter;
|
|
41
|
+
createAssetOptimization(config: Omit<AssetOptimization, 'id'>): AssetOptimization;
|
|
42
|
+
createImageOptimization(config: Omit<ImageOptimization, 'id'>): ImageOptimization;
|
|
43
|
+
createSSGConfig(config: Omit<SSGConfig, 'id'>): SSGConfig;
|
|
44
|
+
createPrerenderConfig(config: Omit<PrerenderConfig, 'id'>): PrerenderConfig;
|
|
45
|
+
listOptimizations(): AssetOptimization[];
|
|
46
|
+
listImageConfigs(): ImageOptimization[];
|
|
47
|
+
clear(): void;
|
|
48
|
+
}
|
|
49
|
+
export declare const staticSiteManager: StaticSiteManager;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CloudFormationResource, CloudFormationTemplate } from '@ts-cloud/aws-types';
|
|
2
|
+
export declare class TemplateBuilder {
|
|
3
|
+
private template;
|
|
4
|
+
constructor(description?: string);
|
|
5
|
+
/**
|
|
6
|
+
* Add a resource to the template
|
|
7
|
+
*/
|
|
8
|
+
addResource(logicalId: string, resource: CloudFormationResource): this;
|
|
9
|
+
/**
|
|
10
|
+
* Add multiple resources to the template
|
|
11
|
+
*/
|
|
12
|
+
addResources(resources: Record<string, CloudFormationResource>): this;
|
|
13
|
+
/**
|
|
14
|
+
* Add a parameter to the template
|
|
15
|
+
*/
|
|
16
|
+
addParameter(name: string, parameter: NonNullable<CloudFormationTemplate['Parameters']>[string]): this;
|
|
17
|
+
/**
|
|
18
|
+
* Add an output to the template
|
|
19
|
+
*/
|
|
20
|
+
addOutput(name: string, output: NonNullable<CloudFormationTemplate['Outputs']>[string]): this;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a resource already exists in the template
|
|
23
|
+
*/
|
|
24
|
+
hasResource(logicalId: string): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Get resources from the template
|
|
27
|
+
*/
|
|
28
|
+
getResources(): Record<string, CloudFormationResource>;
|
|
29
|
+
/**
|
|
30
|
+
* Build and return the CloudFormation template
|
|
31
|
+
*/
|
|
32
|
+
build(): CloudFormationTemplate;
|
|
33
|
+
/**
|
|
34
|
+
* Convert template to JSON string
|
|
35
|
+
*/
|
|
36
|
+
toJSON(pretty?: boolean): string;
|
|
37
|
+
/**
|
|
38
|
+
* Convert template to YAML string (simple implementation)
|
|
39
|
+
*/
|
|
40
|
+
toYAML(): string;
|
|
41
|
+
private convertToYAML;
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CloudFormation Template Validator
|
|
3
|
+
* Validates CloudFormation templates for correctness and best practices
|
|
4
|
+
*/
|
|
5
|
+
import type { CloudFormationTemplate } from '@ts-cloud/aws-types';
|
|
6
|
+
export interface ValidationError {
|
|
7
|
+
path: string;
|
|
8
|
+
message: string;
|
|
9
|
+
severity: 'error' | 'warning' | 'info';
|
|
10
|
+
}
|
|
11
|
+
export interface ValidationResult {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
errors: ValidationError[];
|
|
14
|
+
warnings: ValidationError[];
|
|
15
|
+
info: ValidationError[];
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validate a CloudFormation template
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateTemplate(template: CloudFormationTemplate): ValidationResult;
|
|
21
|
+
/**
|
|
22
|
+
* Validate template size
|
|
23
|
+
*/
|
|
24
|
+
export declare function validateTemplateSize(templateJson: string): ValidationResult;
|
|
25
|
+
/**
|
|
26
|
+
* Validate resource limits
|
|
27
|
+
*/
|
|
28
|
+
export declare function validateResourceLimits(template: CloudFormationTemplate): ValidationResult;
|