@stacksjs/ts-cloud-core 0.1.2 → 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.
- package/README.md +98 -13
- package/package.json +12 -3
- package/src/advanced-features.test.ts +0 -465
- package/src/aws/cloudformation.ts +0 -421
- package/src/aws/cloudfront.ts +0 -158
- package/src/aws/credentials.test.ts +0 -132
- package/src/aws/credentials.ts +0 -545
- package/src/aws/index.ts +0 -87
- package/src/aws/s3.test.ts +0 -188
- package/src/aws/s3.ts +0 -1088
- package/src/aws/signature.test.ts +0 -670
- package/src/aws/signature.ts +0 -1155
- package/src/backup/disaster-recovery.test.ts +0 -726
- package/src/backup/disaster-recovery.ts +0 -500
- package/src/backup/index.ts +0 -34
- package/src/backup/manager.test.ts +0 -498
- package/src/backup/manager.ts +0 -432
- package/src/cicd/circleci.ts +0 -430
- package/src/cicd/github-actions.ts +0 -424
- package/src/cicd/gitlab-ci.ts +0 -255
- package/src/cicd/index.ts +0 -8
- package/src/cli/history.ts +0 -396
- package/src/cli/index.ts +0 -10
- package/src/cli/progress.ts +0 -458
- package/src/cli/repl.ts +0 -454
- package/src/cli/suggestions.ts +0 -327
- package/src/cli/table.test.ts +0 -319
- package/src/cli/table.ts +0 -332
- package/src/cloudformation/builder.test.ts +0 -327
- package/src/cloudformation/builder.ts +0 -378
- package/src/cloudformation/builders/api-gateway.ts +0 -449
- package/src/cloudformation/builders/cache.ts +0 -334
- package/src/cloudformation/builders/cdn.ts +0 -278
- package/src/cloudformation/builders/compute.ts +0 -485
- package/src/cloudformation/builders/database.ts +0 -392
- package/src/cloudformation/builders/functions.ts +0 -343
- package/src/cloudformation/builders/messaging.ts +0 -140
- package/src/cloudformation/builders/monitoring.ts +0 -300
- package/src/cloudformation/builders/network.ts +0 -264
- package/src/cloudformation/builders/queue.ts +0 -147
- package/src/cloudformation/builders/security.ts +0 -399
- package/src/cloudformation/builders/storage.ts +0 -285
- package/src/cloudformation/index.ts +0 -30
- package/src/cloudformation/types.ts +0 -173
- package/src/compliance/aws-config.ts +0 -543
- package/src/compliance/cloudtrail.ts +0 -376
- package/src/compliance/compliance.test.ts +0 -423
- package/src/compliance/guardduty.ts +0 -446
- package/src/compliance/index.ts +0 -66
- package/src/compliance/security-hub.ts +0 -456
- package/src/containers/build-optimization.ts +0 -416
- package/src/containers/containers.test.ts +0 -508
- package/src/containers/image-scanning.ts +0 -360
- package/src/containers/index.ts +0 -9
- package/src/containers/registry.ts +0 -293
- package/src/containers/service-mesh.ts +0 -520
- package/src/database/database.test.ts +0 -762
- package/src/database/index.ts +0 -9
- package/src/database/migrations.ts +0 -444
- package/src/database/performance.ts +0 -528
- package/src/database/replicas.ts +0 -534
- package/src/database/users.ts +0 -494
- package/src/dependency-graph.ts +0 -143
- package/src/deployment/ab-testing.ts +0 -582
- package/src/deployment/blue-green.ts +0 -452
- package/src/deployment/canary.ts +0 -500
- package/src/deployment/deployment.test.ts +0 -526
- package/src/deployment/index.ts +0 -61
- package/src/deployment/progressive.ts +0 -62
- package/src/dns/dns.test.ts +0 -641
- package/src/dns/dnssec.ts +0 -315
- package/src/dns/index.ts +0 -8
- package/src/dns/resolver.ts +0 -496
- package/src/dns/routing.ts +0 -593
- package/src/email/advanced/analytics.ts +0 -445
- package/src/email/advanced/index.ts +0 -11
- package/src/email/advanced/rules.ts +0 -465
- package/src/email/advanced/scheduling.ts +0 -352
- package/src/email/advanced/search.ts +0 -412
- package/src/email/advanced/shared-mailboxes.ts +0 -404
- package/src/email/advanced/templates.ts +0 -455
- package/src/email/advanced/threading.ts +0 -281
- package/src/email/analytics.ts +0 -467
- package/src/email/bounce-handling.ts +0 -425
- package/src/email/email.test.ts +0 -431
- package/src/email/handlers/__tests__/inbound.test.ts +0 -38
- package/src/email/handlers/__tests__/outbound.test.ts +0 -37
- package/src/email/handlers/converter.ts +0 -227
- package/src/email/handlers/feedback.ts +0 -228
- package/src/email/handlers/inbound.ts +0 -169
- package/src/email/handlers/outbound.ts +0 -178
- package/src/email/index.ts +0 -15
- package/src/email/reputation.ts +0 -303
- package/src/email/templates.ts +0 -352
- package/src/errors/index.test.ts +0 -434
- package/src/errors/index.ts +0 -416
- package/src/health-checks/index.ts +0 -40
- package/src/index.ts +0 -360
- package/src/intrinsic-functions.ts +0 -118
- package/src/lambda/concurrency.ts +0 -330
- package/src/lambda/destinations.ts +0 -345
- package/src/lambda/dlq.ts +0 -425
- package/src/lambda/index.ts +0 -11
- package/src/lambda/lambda.test.ts +0 -840
- package/src/lambda/layers.ts +0 -263
- package/src/lambda/versions.ts +0 -376
- package/src/lambda/vpc.ts +0 -399
- package/src/local/config.ts +0 -114
- package/src/local/index.ts +0 -6
- package/src/local/mock-aws.ts +0 -351
- package/src/modules/ai.ts +0 -340
- package/src/modules/api.ts +0 -478
- package/src/modules/auth.ts +0 -805
- package/src/modules/cache.ts +0 -417
- package/src/modules/cdn.ts +0 -1062
- package/src/modules/communication.ts +0 -1094
- package/src/modules/compute.ts +0 -3348
- package/src/modules/database.ts +0 -554
- package/src/modules/deployment.ts +0 -1079
- package/src/modules/dns.ts +0 -337
- package/src/modules/email.ts +0 -1538
- package/src/modules/filesystem.ts +0 -515
- package/src/modules/index.ts +0 -32
- package/src/modules/messaging.ts +0 -486
- package/src/modules/monitoring.ts +0 -2086
- package/src/modules/network.ts +0 -664
- package/src/modules/parameter-store.ts +0 -325
- package/src/modules/permissions.ts +0 -1081
- package/src/modules/phone.ts +0 -494
- package/src/modules/queue.ts +0 -1260
- package/src/modules/redirects.ts +0 -464
- package/src/modules/registry.ts +0 -699
- package/src/modules/search.ts +0 -401
- package/src/modules/secrets.ts +0 -416
- package/src/modules/security.ts +0 -731
- package/src/modules/sms.ts +0 -389
- package/src/modules/storage.ts +0 -1120
- package/src/modules/workflow.ts +0 -680
- package/src/multi-account/config.ts +0 -521
- package/src/multi-account/index.ts +0 -7
- package/src/multi-account/manager.ts +0 -427
- package/src/multi-region/cross-region.ts +0 -410
- package/src/multi-region/index.ts +0 -8
- package/src/multi-region/manager.ts +0 -483
- package/src/multi-region/regions.ts +0 -435
- package/src/network-security/index.ts +0 -48
- package/src/observability/index.ts +0 -9
- package/src/observability/logs.ts +0 -522
- package/src/observability/metrics.ts +0 -460
- package/src/observability/observability.test.ts +0 -782
- package/src/observability/synthetics.ts +0 -568
- package/src/observability/xray.ts +0 -358
- package/src/phone/advanced/analytics.ts +0 -349
- package/src/phone/advanced/callbacks.ts +0 -428
- package/src/phone/advanced/index.ts +0 -8
- package/src/phone/advanced/ivr-builder.ts +0 -504
- package/src/phone/advanced/recording.ts +0 -310
- package/src/phone/handlers/__tests__/incoming-call.test.ts +0 -40
- package/src/phone/handlers/incoming-call.ts +0 -117
- package/src/phone/handlers/missed-call.ts +0 -116
- package/src/phone/handlers/voicemail.ts +0 -179
- package/src/phone/index.ts +0 -9
- package/src/presets/api-backend.ts +0 -134
- package/src/presets/data-pipeline.ts +0 -204
- package/src/presets/extend.test.ts +0 -295
- package/src/presets/extend.ts +0 -297
- package/src/presets/fullstack-app.ts +0 -144
- package/src/presets/index.ts +0 -27
- package/src/presets/jamstack.ts +0 -135
- package/src/presets/microservices.ts +0 -167
- package/src/presets/ml-api.ts +0 -208
- package/src/presets/nodejs-server.ts +0 -104
- package/src/presets/nodejs-serverless.ts +0 -114
- package/src/presets/realtime-app.ts +0 -184
- package/src/presets/static-site.ts +0 -64
- package/src/presets/traditional-web-app.ts +0 -339
- package/src/presets/wordpress.ts +0 -138
- package/src/preview/github.test.ts +0 -249
- package/src/preview/github.ts +0 -297
- package/src/preview/index.ts +0 -37
- package/src/preview/manager.test.ts +0 -440
- package/src/preview/manager.ts +0 -326
- package/src/preview/notifications.test.ts +0 -582
- package/src/preview/notifications.ts +0 -341
- package/src/queue/batch-processing.ts +0 -402
- package/src/queue/dlq-monitoring.ts +0 -402
- package/src/queue/fifo.ts +0 -342
- package/src/queue/index.ts +0 -9
- package/src/queue/management.ts +0 -428
- package/src/queue/queue.test.ts +0 -429
- package/src/resource-mgmt/index.ts +0 -39
- package/src/resource-naming.ts +0 -62
- package/src/s3/index.ts +0 -523
- package/src/schema/cloud-config.schema.json +0 -554
- package/src/schema/index.ts +0 -68
- package/src/security/certificate-manager.ts +0 -492
- package/src/security/index.ts +0 -9
- package/src/security/scanning.ts +0 -545
- package/src/security/secrets-manager.ts +0 -476
- package/src/security/secrets-rotation.ts +0 -456
- package/src/security/security.test.ts +0 -738
- package/src/sms/advanced/ab-testing.ts +0 -389
- package/src/sms/advanced/analytics.ts +0 -336
- package/src/sms/advanced/campaigns.ts +0 -523
- package/src/sms/advanced/chatbot.ts +0 -224
- package/src/sms/advanced/index.ts +0 -10
- package/src/sms/advanced/link-tracking.ts +0 -248
- package/src/sms/advanced/mms.ts +0 -308
- package/src/sms/handlers/__tests__/send.test.ts +0 -40
- package/src/sms/handlers/delivery-status.ts +0 -133
- package/src/sms/handlers/receive.ts +0 -162
- package/src/sms/handlers/send.ts +0 -174
- package/src/sms/index.ts +0 -9
- package/src/stack-diff.ts +0 -389
- package/src/static-site/index.ts +0 -85
- package/src/template-builder.ts +0 -110
- package/src/template-validator.ts +0 -574
- package/src/utils/cache.ts +0 -291
- package/src/utils/diff.ts +0 -269
- package/src/utils/hash.ts +0 -227
- package/src/utils/index.ts +0 -8
- package/src/utils/parallel.ts +0 -294
- package/src/validators/credentials.test.ts +0 -274
- package/src/validators/credentials.ts +0 -233
- package/src/validators/quotas.test.ts +0 -434
- package/src/validators/quotas.ts +0 -217
- package/test/ai.test.ts +0 -327
- package/test/api.test.ts +0 -511
- package/test/auth.test.ts +0 -632
- package/test/cache.test.ts +0 -406
- package/test/cdn.test.ts +0 -247
- package/test/compute.test.ts +0 -861
- package/test/database.test.ts +0 -523
- package/test/deployment.test.ts +0 -499
- package/test/dns.test.ts +0 -270
- package/test/email.test.ts +0 -439
- package/test/filesystem.test.ts +0 -382
- package/test/integration.test.ts +0 -350
- package/test/messaging.test.ts +0 -514
- package/test/monitoring.test.ts +0 -634
- package/test/network.test.ts +0 -425
- package/test/permissions.test.ts +0 -488
- package/test/queue.test.ts +0 -484
- package/test/registry.test.ts +0 -306
- package/test/security.test.ts +0 -462
- package/test/storage.test.ts +0 -463
- package/test/template-validator.test.ts +0 -559
- package/test/workflow.test.ts +0 -592
- package/tsconfig.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Voicemail Lambda Handler
|
|
3
|
-
*
|
|
4
|
-
* Processes voicemail recordings:
|
|
5
|
-
* - Processes voicemail recordings from S3
|
|
6
|
-
* - Transcribes using Amazon Transcribe
|
|
7
|
-
* - Sends notification with transcription
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export const handler = `
|
|
11
|
-
const { S3Client, GetObjectCommand, PutObjectCommand } = require('@aws-sdk/client-s3');
|
|
12
|
-
const { TranscribeClient, StartTranscriptionJobCommand, GetTranscriptionJobCommand } = require('@aws-sdk/client-transcribe');
|
|
13
|
-
const { SNSClient, PublishCommand } = require('@aws-sdk/client-sns');
|
|
14
|
-
const { DynamoDBClient, UpdateItemCommand } = require('@aws-sdk/client-dynamodb');
|
|
15
|
-
|
|
16
|
-
const s3 = new S3Client({});
|
|
17
|
-
const transcribe = new TranscribeClient({});
|
|
18
|
-
const sns = new SNSClient({});
|
|
19
|
-
const dynamodb = new DynamoDBClient({});
|
|
20
|
-
|
|
21
|
-
exports.handler = async (event) => {
|
|
22
|
-
console.log('Voicemail event:', JSON.stringify(event, null, 2));
|
|
23
|
-
|
|
24
|
-
const notificationTopicArn = process.env.NOTIFICATION_TOPIC_ARN;
|
|
25
|
-
const voicemailBucket = process.env.VOICEMAIL_BUCKET;
|
|
26
|
-
const callLogTable = process.env.CALL_LOG_TABLE;
|
|
27
|
-
const transcriptionEnabled = process.env.TRANSCRIPTION_ENABLED === 'true';
|
|
28
|
-
|
|
29
|
-
for (const record of event.Records) {
|
|
30
|
-
try {
|
|
31
|
-
const s3Event = record.s3 || {};
|
|
32
|
-
const bucket = s3Event.bucket?.name || voicemailBucket;
|
|
33
|
-
const key = decodeURIComponent(s3Event.object?.key?.replace(/\\+/g, ' ') || '');
|
|
34
|
-
|
|
35
|
-
if (!key.includes('voicemail') || !key.endsWith('.wav')) {
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
console.log(\`Processing voicemail: \${key}\`);
|
|
40
|
-
|
|
41
|
-
// Extract metadata from key (format: voicemails/{contactId}/{timestamp}.wav)
|
|
42
|
-
const parts = key.split('/');
|
|
43
|
-
const contactId = parts[1] || 'unknown';
|
|
44
|
-
const filename = parts[parts.length - 1];
|
|
45
|
-
const timestamp = filename.replace('.wav', '');
|
|
46
|
-
|
|
47
|
-
// Get voicemail metadata if exists
|
|
48
|
-
let metadata = {};
|
|
49
|
-
try {
|
|
50
|
-
const metaResult = await s3.send(new GetObjectCommand({
|
|
51
|
-
Bucket: bucket,
|
|
52
|
-
Key: key.replace('.wav', '.json'),
|
|
53
|
-
}));
|
|
54
|
-
metadata = JSON.parse(await metaResult.Body.transformToString());
|
|
55
|
-
} catch {
|
|
56
|
-
// No metadata file
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let transcription = null;
|
|
60
|
-
|
|
61
|
-
// Start transcription if enabled
|
|
62
|
-
if (transcriptionEnabled) {
|
|
63
|
-
const jobName = \`voicemail-\${contactId}-\${Date.now()}\`;
|
|
64
|
-
|
|
65
|
-
await transcribe.send(new StartTranscriptionJobCommand({
|
|
66
|
-
TranscriptionJobName: jobName,
|
|
67
|
-
LanguageCode: 'en-US',
|
|
68
|
-
MediaFormat: 'wav',
|
|
69
|
-
Media: {
|
|
70
|
-
MediaFileUri: \`s3://\${bucket}/\${key}\`,
|
|
71
|
-
},
|
|
72
|
-
OutputBucketName: bucket,
|
|
73
|
-
OutputKey: key.replace('.wav', '-transcript.json'),
|
|
74
|
-
}));
|
|
75
|
-
|
|
76
|
-
// Wait for transcription (with timeout)
|
|
77
|
-
let attempts = 0;
|
|
78
|
-
const maxAttempts = 30; // 5 minutes max
|
|
79
|
-
|
|
80
|
-
while (attempts < maxAttempts) {
|
|
81
|
-
await new Promise(resolve => setTimeout(resolve, 10000)); // 10 seconds
|
|
82
|
-
|
|
83
|
-
const jobResult = await transcribe.send(new GetTranscriptionJobCommand({
|
|
84
|
-
TranscriptionJobName: jobName,
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
const status = jobResult.TranscriptionJob?.TranscriptionJobStatus;
|
|
88
|
-
|
|
89
|
-
if (status === 'COMPLETED') {
|
|
90
|
-
// Get transcription result
|
|
91
|
-
try {
|
|
92
|
-
const transcriptResult = await s3.send(new GetObjectCommand({
|
|
93
|
-
Bucket: bucket,
|
|
94
|
-
Key: key.replace('.wav', '-transcript.json'),
|
|
95
|
-
}));
|
|
96
|
-
const transcriptData = JSON.parse(await transcriptResult.Body.transformToString());
|
|
97
|
-
transcription = transcriptData.results?.transcripts?.[0]?.transcript || '';
|
|
98
|
-
} catch (err) {
|
|
99
|
-
console.error('Error getting transcription:', err.message);
|
|
100
|
-
}
|
|
101
|
-
break;
|
|
102
|
-
} else if (status === 'FAILED') {
|
|
103
|
-
console.error('Transcription failed');
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
attempts++;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Update call log
|
|
112
|
-
if (callLogTable && contactId !== 'unknown') {
|
|
113
|
-
await dynamodb.send(new UpdateItemCommand({
|
|
114
|
-
TableName: callLogTable,
|
|
115
|
-
Key: {
|
|
116
|
-
contactId: { S: contactId },
|
|
117
|
-
},
|
|
118
|
-
UpdateExpression: 'SET voicemailKey = :key, voicemailTranscript = :transcript, voicemailAt = :at',
|
|
119
|
-
ExpressionAttributeValues: {
|
|
120
|
-
':key': { S: key },
|
|
121
|
-
':transcript': { S: transcription || '' },
|
|
122
|
-
':at': { S: new Date().toISOString() },
|
|
123
|
-
},
|
|
124
|
-
}));
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
// Save voicemail metadata
|
|
128
|
-
await s3.send(new PutObjectCommand({
|
|
129
|
-
Bucket: bucket,
|
|
130
|
-
Key: key.replace('.wav', '-metadata.json'),
|
|
131
|
-
Body: JSON.stringify({
|
|
132
|
-
contactId,
|
|
133
|
-
callerNumber: metadata.callerNumber || 'unknown',
|
|
134
|
-
calledNumber: metadata.calledNumber || 'unknown',
|
|
135
|
-
duration: metadata.duration || 0,
|
|
136
|
-
recordedAt: timestamp,
|
|
137
|
-
processedAt: new Date().toISOString(),
|
|
138
|
-
transcription,
|
|
139
|
-
audioKey: key,
|
|
140
|
-
}, null, 2),
|
|
141
|
-
ContentType: 'application/json',
|
|
142
|
-
}));
|
|
143
|
-
|
|
144
|
-
// Send notification
|
|
145
|
-
if (notificationTopicArn) {
|
|
146
|
-
await sns.send(new PublishCommand({
|
|
147
|
-
TopicArn: notificationTopicArn,
|
|
148
|
-
Subject: 'New Voicemail',
|
|
149
|
-
Message: JSON.stringify({
|
|
150
|
-
type: 'voicemail',
|
|
151
|
-
contactId,
|
|
152
|
-
from: metadata.callerNumber || 'unknown',
|
|
153
|
-
to: metadata.calledNumber || 'unknown',
|
|
154
|
-
duration: metadata.duration || 0,
|
|
155
|
-
transcription: transcription || '(transcription not available)',
|
|
156
|
-
audioUrl: \`s3://\${bucket}/\${key}\`,
|
|
157
|
-
timestamp: new Date().toISOString(),
|
|
158
|
-
}, null, 2),
|
|
159
|
-
MessageAttributes: {
|
|
160
|
-
eventType: {
|
|
161
|
-
DataType: 'String',
|
|
162
|
-
StringValue: 'voicemail',
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
}));
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
console.log(\`Processed voicemail: \${contactId}\`);
|
|
169
|
-
|
|
170
|
-
} catch (error) {
|
|
171
|
-
console.error('Error processing voicemail:', error);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
return { statusCode: 200, body: 'OK' };
|
|
176
|
-
};
|
|
177
|
-
`
|
|
178
|
-
|
|
179
|
-
export default handler
|
package/src/phone/index.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import type { CloudConfig } from '@stacksjs/ts-cloud-types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* API-Only Backend Preset
|
|
5
|
-
* Perfect for: REST APIs, GraphQL APIs, mobile backends
|
|
6
|
-
* Includes: API Gateway + Lambda functions + DynamoDB
|
|
7
|
-
*/
|
|
8
|
-
export function createApiBackendPreset(options: {
|
|
9
|
-
name: string
|
|
10
|
-
slug: string
|
|
11
|
-
domain?: string
|
|
12
|
-
}): Partial<CloudConfig> {
|
|
13
|
-
const { name, slug, domain } = options
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
project: {
|
|
17
|
-
name,
|
|
18
|
-
slug,
|
|
19
|
-
region: 'us-east-1',
|
|
20
|
-
},
|
|
21
|
-
mode: 'serverless',
|
|
22
|
-
environments: {
|
|
23
|
-
production: {
|
|
24
|
-
type: 'production',
|
|
25
|
-
domain,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
infrastructure: {
|
|
29
|
-
apiGateway: {
|
|
30
|
-
type: 'HTTP', // HTTP API is cheaper and simpler
|
|
31
|
-
cors: {
|
|
32
|
-
allowOrigins: ['*'],
|
|
33
|
-
allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'],
|
|
34
|
-
allowHeaders: ['Content-Type', 'Authorization'],
|
|
35
|
-
maxAge: 3600,
|
|
36
|
-
},
|
|
37
|
-
customDomain: domain ? {
|
|
38
|
-
domain,
|
|
39
|
-
certificateArn: 'TO_BE_GENERATED',
|
|
40
|
-
} : undefined,
|
|
41
|
-
throttling: {
|
|
42
|
-
rateLimit: 10000,
|
|
43
|
-
burstLimit: 5000,
|
|
44
|
-
},
|
|
45
|
-
authorizer: {
|
|
46
|
-
type: 'JWT',
|
|
47
|
-
identitySource: '$request.header.Authorization',
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
functions: {
|
|
51
|
-
users: {
|
|
52
|
-
runtime: 'nodejs20.x',
|
|
53
|
-
handler: 'dist/api/users.handler',
|
|
54
|
-
memory: 512,
|
|
55
|
-
timeout: 30,
|
|
56
|
-
events: [{
|
|
57
|
-
type: 'http',
|
|
58
|
-
path: '/users',
|
|
59
|
-
method: 'GET',
|
|
60
|
-
}, {
|
|
61
|
-
type: 'http',
|
|
62
|
-
path: '/users',
|
|
63
|
-
method: 'POST',
|
|
64
|
-
}],
|
|
65
|
-
},
|
|
66
|
-
products: {
|
|
67
|
-
runtime: 'nodejs20.x',
|
|
68
|
-
handler: 'dist/api/products.handler',
|
|
69
|
-
memory: 512,
|
|
70
|
-
timeout: 30,
|
|
71
|
-
events: [{
|
|
72
|
-
type: 'http',
|
|
73
|
-
path: '/products',
|
|
74
|
-
method: 'GET',
|
|
75
|
-
}],
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
databases: {
|
|
79
|
-
dynamodb: {
|
|
80
|
-
tables: {
|
|
81
|
-
[`${slug}-users`]: {
|
|
82
|
-
partitionKey: { name: 'userId', type: 'S' },
|
|
83
|
-
billingMode: 'PAY_PER_REQUEST',
|
|
84
|
-
streamEnabled: true,
|
|
85
|
-
pointInTimeRecovery: true,
|
|
86
|
-
globalSecondaryIndexes: [{
|
|
87
|
-
name: 'EmailIndex',
|
|
88
|
-
partitionKey: { name: 'email', type: 'S' },
|
|
89
|
-
projection: 'ALL',
|
|
90
|
-
}],
|
|
91
|
-
},
|
|
92
|
-
[`${slug}-products`]: {
|
|
93
|
-
partitionKey: { name: 'productId', type: 'S' },
|
|
94
|
-
sortKey: { name: 'category', type: 'S' },
|
|
95
|
-
billingMode: 'PAY_PER_REQUEST',
|
|
96
|
-
streamEnabled: false,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
cache: {
|
|
102
|
-
elasticache: {
|
|
103
|
-
nodeType: 'cache.t3.micro',
|
|
104
|
-
numCacheNodes: 1,
|
|
105
|
-
engine: 'redis',
|
|
106
|
-
engineVersion: '7.0',
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
security: {
|
|
110
|
-
certificate: domain ? {
|
|
111
|
-
domain,
|
|
112
|
-
validationMethod: 'DNS',
|
|
113
|
-
} : undefined,
|
|
114
|
-
waf: {
|
|
115
|
-
enabled: true,
|
|
116
|
-
rules: ['rateLimit', 'sqlInjection'],
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
monitoring: {
|
|
120
|
-
alarms: [{
|
|
121
|
-
metric: 'Errors',
|
|
122
|
-
threshold: 10,
|
|
123
|
-
period: 300,
|
|
124
|
-
evaluationPeriods: 1,
|
|
125
|
-
}, {
|
|
126
|
-
metric: 'Duration',
|
|
127
|
-
threshold: 3000, // 3 seconds
|
|
128
|
-
period: 300,
|
|
129
|
-
evaluationPeriods: 2,
|
|
130
|
-
}],
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
}
|
|
134
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import type { CloudConfig } from '@stacksjs/ts-cloud-types'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Data Pipeline Preset
|
|
5
|
-
* Perfect for: ETL pipelines, data processing, analytics workflows
|
|
6
|
-
* Includes: Kinesis + Lambda + S3 + Athena + Glue
|
|
7
|
-
*/
|
|
8
|
-
export function createDataPipelinePreset(options: {
|
|
9
|
-
name: string
|
|
10
|
-
slug: string
|
|
11
|
-
retentionDays?: number
|
|
12
|
-
}): Partial<CloudConfig> {
|
|
13
|
-
const {
|
|
14
|
-
name,
|
|
15
|
-
slug,
|
|
16
|
-
retentionDays = 7,
|
|
17
|
-
} = options
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
project: {
|
|
21
|
-
name,
|
|
22
|
-
slug,
|
|
23
|
-
region: 'us-east-1',
|
|
24
|
-
},
|
|
25
|
-
mode: 'serverless',
|
|
26
|
-
infrastructure: {
|
|
27
|
-
streaming: {
|
|
28
|
-
dataStream: {
|
|
29
|
-
name: `${slug}-stream`,
|
|
30
|
-
shardCount: 2,
|
|
31
|
-
retentionPeriod: retentionDays * 24, // Convert to hours
|
|
32
|
-
encryption: true,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
storage: {
|
|
36
|
-
raw: {
|
|
37
|
-
public: false,
|
|
38
|
-
versioning: true,
|
|
39
|
-
encryption: true,
|
|
40
|
-
intelligentTiering: true,
|
|
41
|
-
lifecycleRules: [{
|
|
42
|
-
id: 'ArchiveOldData',
|
|
43
|
-
enabled: true,
|
|
44
|
-
transitions: [{
|
|
45
|
-
days: 30,
|
|
46
|
-
storageClass: 'GLACIER',
|
|
47
|
-
}, {
|
|
48
|
-
days: 90,
|
|
49
|
-
storageClass: 'DEEP_ARCHIVE',
|
|
50
|
-
}],
|
|
51
|
-
}],
|
|
52
|
-
},
|
|
53
|
-
processed: {
|
|
54
|
-
public: false,
|
|
55
|
-
versioning: true,
|
|
56
|
-
encryption: true,
|
|
57
|
-
intelligentTiering: true,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
functions: {
|
|
61
|
-
'stream-processor': {
|
|
62
|
-
runtime: 'nodejs20.x',
|
|
63
|
-
handler: 'dist/processors/stream.handler',
|
|
64
|
-
memory: 2048,
|
|
65
|
-
timeout: 300, // 5 minutes for batch processing
|
|
66
|
-
events: [{
|
|
67
|
-
type: 'kinesis',
|
|
68
|
-
streamName: `${slug}-stream`,
|
|
69
|
-
batchSize: 1000,
|
|
70
|
-
startingPosition: 'LATEST',
|
|
71
|
-
parallelizationFactor: 10,
|
|
72
|
-
}],
|
|
73
|
-
},
|
|
74
|
-
transformer: {
|
|
75
|
-
runtime: 'nodejs20.x',
|
|
76
|
-
handler: 'dist/processors/transform.handler',
|
|
77
|
-
memory: 3008,
|
|
78
|
-
timeout: 900, // 15 minutes
|
|
79
|
-
events: [{
|
|
80
|
-
type: 's3',
|
|
81
|
-
bucket: `${slug}-raw`,
|
|
82
|
-
prefix: 'incoming/',
|
|
83
|
-
}],
|
|
84
|
-
},
|
|
85
|
-
aggregator: {
|
|
86
|
-
runtime: 'nodejs20.x',
|
|
87
|
-
handler: 'dist/processors/aggregate.handler',
|
|
88
|
-
memory: 2048,
|
|
89
|
-
timeout: 600, // 10 minutes
|
|
90
|
-
events: [{
|
|
91
|
-
type: 'schedule',
|
|
92
|
-
expression: 'cron(0 * * * ? *)', // Every hour
|
|
93
|
-
}],
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
analytics: {
|
|
97
|
-
athena: {
|
|
98
|
-
database: `${slug}_analytics`,
|
|
99
|
-
workgroup: `${slug}-workgroup`,
|
|
100
|
-
outputBucket: `${slug}-query-results`,
|
|
101
|
-
tables: [{
|
|
102
|
-
name: 'raw_events',
|
|
103
|
-
location: `s3://${slug}-raw/events/`,
|
|
104
|
-
format: 'parquet',
|
|
105
|
-
partitionKeys: ['year', 'month', 'day'],
|
|
106
|
-
}, {
|
|
107
|
-
name: 'processed_events',
|
|
108
|
-
location: `s3://${slug}-processed/events/`,
|
|
109
|
-
format: 'parquet',
|
|
110
|
-
partitionKeys: ['year', 'month', 'day'],
|
|
111
|
-
}],
|
|
112
|
-
},
|
|
113
|
-
glue: {
|
|
114
|
-
crawlers: [{
|
|
115
|
-
name: `${slug}-crawler`,
|
|
116
|
-
databaseName: `${slug}_analytics`,
|
|
117
|
-
s3Targets: [
|
|
118
|
-
`s3://${slug}-raw/`,
|
|
119
|
-
`s3://${slug}-processed/`,
|
|
120
|
-
],
|
|
121
|
-
schedule: 'cron(0 2 * * ? *)', // Daily at 2 AM
|
|
122
|
-
}],
|
|
123
|
-
jobs: [{
|
|
124
|
-
name: `${slug}-etl-job`,
|
|
125
|
-
scriptLocation: `s3://${slug}-scripts/etl.py`,
|
|
126
|
-
role: `${slug}-glue-role`,
|
|
127
|
-
maxCapacity: 10,
|
|
128
|
-
timeout: 120, // 2 hours
|
|
129
|
-
}],
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
databases: {
|
|
133
|
-
dynamodb: {
|
|
134
|
-
tables: {
|
|
135
|
-
[`${slug}-metadata`]: {
|
|
136
|
-
partitionKey: { name: 'pipelineId', type: 'S' },
|
|
137
|
-
sortKey: { name: 'timestamp', type: 'S' },
|
|
138
|
-
billingMode: 'PAY_PER_REQUEST',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
queues: {
|
|
144
|
-
failedJobs: {
|
|
145
|
-
fifo: false,
|
|
146
|
-
visibilityTimeout: 900, // 15 minutes
|
|
147
|
-
messageRetentionPeriod: 1209600, // 14 days
|
|
148
|
-
deadLetterQueue: true,
|
|
149
|
-
maxReceiveCount: 3,
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
workflow: {
|
|
153
|
-
pipelines: [{
|
|
154
|
-
name: `${slug}-daily-pipeline`,
|
|
155
|
-
type: 'stepFunctions',
|
|
156
|
-
definition: {
|
|
157
|
-
StartAt: 'ExtractData',
|
|
158
|
-
States: {
|
|
159
|
-
ExtractData: {
|
|
160
|
-
Type: 'Task',
|
|
161
|
-
Resource: 'arn:aws:states:::lambda:invoke',
|
|
162
|
-
Next: 'TransformData',
|
|
163
|
-
},
|
|
164
|
-
TransformData: {
|
|
165
|
-
Type: 'Task',
|
|
166
|
-
Resource: 'arn:aws:states:::lambda:invoke',
|
|
167
|
-
Next: 'LoadData',
|
|
168
|
-
},
|
|
169
|
-
LoadData: {
|
|
170
|
-
Type: 'Task',
|
|
171
|
-
Resource: 'arn:aws:states:::lambda:invoke',
|
|
172
|
-
End: true,
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
},
|
|
176
|
-
schedule: 'cron(0 0 * * ? *)', // Daily at midnight
|
|
177
|
-
}],
|
|
178
|
-
},
|
|
179
|
-
monitoring: {
|
|
180
|
-
dashboard: {
|
|
181
|
-
name: `${slug}-pipeline`,
|
|
182
|
-
widgets: [{
|
|
183
|
-
type: 'metric',
|
|
184
|
-
metrics: [
|
|
185
|
-
'KinesisIncomingRecords',
|
|
186
|
-
'LambdaInvocations',
|
|
187
|
-
'S3ObjectsCreated',
|
|
188
|
-
'GlueJobsSucceeded',
|
|
189
|
-
],
|
|
190
|
-
}],
|
|
191
|
-
},
|
|
192
|
-
alarms: [{
|
|
193
|
-
metric: 'LambdaErrors',
|
|
194
|
-
threshold: 10,
|
|
195
|
-
evaluationPeriods: 1,
|
|
196
|
-
}, {
|
|
197
|
-
metric: 'KinesisIteratorAge',
|
|
198
|
-
threshold: 60000, // 1 minute
|
|
199
|
-
evaluationPeriods: 2,
|
|
200
|
-
}],
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
}
|
|
204
|
-
}
|