@stacksjs/ts-cloud 0.5.5 → 0.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -25845,16 +25845,21 @@ function resolveServerlessRuntime(app) {
25845
25845
  layerEnvVar: "TSCLOUD_NODE_LAYER_ARN"
25846
25846
  };
25847
25847
  }
25848
- function resolveQueueNames(app, slug, env) {
25848
+ function resolveQueues(app, slug, env) {
25849
25849
  if (app.queues === false)
25850
25850
  return [];
25851
25851
  if (app.queues === undefined || app.queues === true)
25852
- return [`${slug}-${env}-default`];
25852
+ return [{ name: `${slug}-${env}-default` }];
25853
25853
  return app.queues.map((q) => {
25854
- const name = typeof q === "string" ? q : Object.keys(q)[0];
25855
- return `${slug}-${env}-${name}`;
25854
+ if (typeof q === "string")
25855
+ return { name: `${slug}-${env}-${q}` };
25856
+ const [name, concurrency] = Object.entries(q)[0];
25857
+ return { name: `${slug}-${env}-${name}`, concurrency };
25856
25858
  });
25857
25859
  }
25860
+ function resolveQueueNames(app, slug, env) {
25861
+ return resolveQueues(app, slug, env).map((q) => q.name);
25862
+ }
25858
25863
  function composeServerlessAppTemplate(opts) {
25859
25864
  const { app, environment, handlers } = opts;
25860
25865
  const slug = opts.config.project.slug;
@@ -25866,8 +25871,12 @@ function composeServerlessAppTemplate(opts) {
25866
25871
  queue: `${slug}-${environment}-queue`,
25867
25872
  cli: `${slug}-${environment}-cli`
25868
25873
  };
25869
- const queueNames = resolveQueueNames(app, slug, environment);
25874
+ if (app.gatewayVersion === 1)
25875
+ throw new Error("serverless app: `gatewayVersion: 1` (REST API) is not supported — ts-cloud uses API Gateway HTTP API (v2). Remove `gatewayVersion` or set it to 2.");
25876
+ const queues = resolveQueues(app, slug, environment);
25877
+ const queueNames = queues.map((q) => q.name);
25870
25878
  const hasQueue = queueNames.length > 0;
25879
+ const logRetention = app.logRetention ?? 14;
25871
25880
  const imageMode = app.packaging === "image";
25872
25881
  const schedulerEnabled = (app.scheduler ?? "on") !== "off";
25873
25882
  const cacheEnabled = (app.cache?.driver ?? "dynamodb") === "dynamodb";
@@ -25983,7 +25992,7 @@ function composeServerlessAppTemplate(opts) {
25983
25992
  function addFunction(logicalId, name, handler8, mode, memory, timeout, reservedConcurrency, tmp = tmpStorage) {
25984
25993
  resources[`${logicalId}LogGroup`] = {
25985
25994
  Type: "AWS::Logs::LogGroup",
25986
- Properties: { LogGroupName: `/aws/lambda/${name}`, RetentionInDays: 14 }
25995
+ Properties: { LogGroupName: `/aws/lambda/${name}`, RetentionInDays: logRetention }
25987
25996
  };
25988
25997
  const codeProps = imageMode ? {
25989
25998
  PackageType: "Image",
@@ -26124,19 +26133,21 @@ function composeServerlessAppTemplate(opts) {
26124
26133
  MessageRetentionPeriod: 1209600
26125
26134
  }
26126
26135
  };
26127
- queueNames.forEach((qName, i) => {
26136
+ queues.forEach((q, i) => {
26128
26137
  const qId = `AppQueue${i}`;
26138
+ const fnTimeout = app.queueTimeout ?? 120;
26129
26139
  resources[qId] = {
26130
26140
  Type: "AWS::SQS::Queue",
26131
26141
  Properties: {
26132
- QueueName: qName,
26133
- VisibilityTimeout: Math.max(app.queueTimeout ?? 120, app.queueTimeout ?? 120),
26142
+ QueueName: q.name,
26143
+ VisibilityTimeout: Math.min(43200, fnTimeout * 6),
26134
26144
  RedrivePolicy: {
26135
26145
  deadLetterTargetArn: Fn2.getAtt("AppQueueDlq", "Arn"),
26136
26146
  maxReceiveCount: app.queueTries ?? 3
26137
26147
  }
26138
26148
  }
26139
26149
  };
26150
+ const concurrency = q.concurrency ?? app.queueConcurrency;
26140
26151
  resources[`${qId}Mapping`] = {
26141
26152
  Type: "AWS::Lambda::EventSourceMapping",
26142
26153
  Properties: {
@@ -26144,10 +26155,10 @@ function composeServerlessAppTemplate(opts) {
26144
26155
  FunctionName: Fn2.ref("QueueFunction"),
26145
26156
  BatchSize: 1,
26146
26157
  FunctionResponseTypes: ["ReportBatchItemFailures"],
26147
- ...app.queueConcurrency ? { ScalingConfig: { MaximumConcurrency: Math.max(2, app.queueConcurrency) } } : {}
26158
+ ...concurrency ? { ScalingConfig: { MaximumConcurrency: Math.max(2, concurrency) } } : {}
26148
26159
  }
26149
26160
  };
26150
- outputs[`QueueUrl${i}`] = { Description: `Queue URL: ${qName}`, Value: Fn2.ref(qId) };
26161
+ outputs[`QueueUrl${i}`] = { Description: `Queue URL: ${q.name}`, Value: Fn2.ref(qId) };
26151
26162
  });
26152
26163
  }
26153
26164
  if (schedulerEnabled) {
@@ -26460,7 +26471,10 @@ function composeServerlessAppTemplate(opts) {
26460
26471
  DatabaseName: "app",
26461
26472
  MasterUsername: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:username}}"),
26462
26473
  MasterUserPassword: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:password}}"),
26463
- ServerlessV2ScalingConfiguration: { MinCapacity: 0.5, MaxCapacity: 4 },
26474
+ ServerlessV2ScalingConfiguration: {
26475
+ MinCapacity: app.database?.minCapacity ?? 0.5,
26476
+ MaxCapacity: app.database?.maxCapacity ?? 4
26477
+ },
26464
26478
  DBSubnetGroupName: Fn2.ref("DbSubnetGroup"),
26465
26479
  VpcSecurityGroupIds: [Fn2.getAtt("DataSecurityGroup", "GroupId")]
26466
26480
  }
@@ -55704,402 +55718,998 @@ var init_email = __esm(() => {
55704
55718
  email = new EmailClient;
55705
55719
  });
55706
55720
 
55707
- // src/deploy/static-site-external-dns.ts
55708
- function generateExternalDnsStaticSiteTemplate(config6) {
55709
- const {
55710
- bucketName,
55711
- domain,
55712
- aliases,
55713
- certificateArn,
55714
- defaultRootObject = "index.html",
55715
- errorDocument = "404.html",
55716
- passthroughUrls = false,
55717
- singlePageApp = false,
55718
- dynamicApp = false,
55719
- computeOriginDomain,
55720
- computeOriginPort = 3008,
55721
- computeOriginId = "app-compute",
55722
- retainOnStackDelete = false
55723
- } = config6;
55724
- const retainPolicy = retainOnStackDelete ? { DeletionPolicy: "Retain", UpdateReplacePolicy: "Retain" } : {};
55725
- const useComputeOrigin = dynamicApp && !!computeOriginDomain;
55726
- const defaultAllowedMethods = useComputeOrigin ? ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"] : ["GET", "HEAD"];
55727
- const defaultCachedMethods = useComputeOrigin ? ["GET", "HEAD"] : ["GET", "HEAD"];
55728
- const resources = {};
55729
- const outputs = {};
55730
- resources.S3Bucket = {
55731
- Type: "AWS::S3::Bucket",
55732
- ...retainPolicy,
55733
- Properties: {
55734
- BucketName: bucketName,
55735
- PublicAccessBlockConfiguration: {
55736
- BlockPublicAcls: true,
55737
- BlockPublicPolicy: false,
55738
- IgnorePublicAcls: true,
55739
- RestrictPublicBuckets: false
55740
- },
55741
- WebsiteConfiguration: {
55742
- IndexDocument: defaultRootObject,
55743
- ErrorDocument: errorDocument
55744
- }
55721
+ // src/aws/rds.ts
55722
+ class RDSClient {
55723
+ client;
55724
+ region;
55725
+ constructor(region = "us-east-1") {
55726
+ this.region = region;
55727
+ this.client = new AWSClient;
55728
+ }
55729
+ async describeDBInstances(options) {
55730
+ const params = {
55731
+ Action: "DescribeDBInstances",
55732
+ Version: "2014-10-31"
55733
+ };
55734
+ if (options?.DBInstanceIdentifier) {
55735
+ params.DBInstanceIdentifier = options.DBInstanceIdentifier;
55745
55736
  }
55746
- };
55747
- outputs.BucketName = {
55748
- Description: "S3 Bucket Name",
55749
- Value: { Ref: "S3Bucket" }
55750
- };
55751
- outputs.BucketArn = {
55752
- Description: "S3 Bucket ARN",
55753
- Value: { "Fn::GetAtt": ["S3Bucket", "Arn"] }
55754
- };
55755
- resources.CloudFrontOAC = {
55756
- Type: "AWS::CloudFront::OriginAccessControl",
55757
- ...retainPolicy,
55758
- Properties: {
55759
- OriginAccessControlConfig: {
55760
- Name: `OAC-${bucketName}`,
55761
- Description: `OAC for ${bucketName}`,
55762
- OriginAccessControlOriginType: "s3",
55763
- SigningBehavior: "always",
55764
- SigningProtocol: "sigv4"
55765
- }
55737
+ if (options?.MaxRecords) {
55738
+ params.MaxRecords = options.MaxRecords;
55766
55739
  }
55767
- };
55768
- let installRootRedirectLogicalId;
55769
- if (passthroughUrls && useComputeOrigin) {
55770
- installRootRedirectLogicalId = "InstallRootRedirectFunction";
55771
- resources[installRootRedirectLogicalId] = {
55772
- Type: "AWS::CloudFront::Function",
55773
- Properties: {
55774
- Name: { "Fn::Sub": "${AWS::StackName}-install-root-redirect" },
55775
- AutoPublish: true,
55776
- FunctionConfig: {
55777
- Comment: "Redirect curl pantry.dev | bash (GET /) to /install.sh on S3",
55778
- Runtime: "cloudfront-js-2.0"
55779
- },
55780
- FunctionCode: `function handler(event) {
55781
- var request = event.request;
55782
- if (request.uri === '/' || request.uri === '') {
55783
- return {
55784
- statusCode: 302,
55785
- statusDescription: 'Found',
55740
+ if (options?.Marker) {
55741
+ params.Marker = options.Marker;
55742
+ }
55743
+ if (options?.Filters) {
55744
+ options.Filters.forEach((filter, i) => {
55745
+ params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
55746
+ filter.Values.forEach((value, j) => {
55747
+ params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
55748
+ });
55749
+ });
55750
+ }
55751
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
55752
+ const result = await this.client.request({
55753
+ service: "rds",
55754
+ region: this.region,
55755
+ method: "POST",
55756
+ path: "/",
55786
55757
  headers: {
55787
- location: { value: 'https://' + request.headers.host.value + '/install.sh' }
55788
- }
55789
- };
55790
- }
55791
- return request;
55792
- }`
55793
- }
55758
+ "Content-Type": "application/x-www-form-urlencoded"
55759
+ },
55760
+ body: queryString
55761
+ });
55762
+ const response = result.DescribeDBInstancesResult || result;
55763
+ let instances = response.DBInstances?.DBInstance || [];
55764
+ if (!Array.isArray(instances)) {
55765
+ instances = instances ? [instances] : [];
55766
+ }
55767
+ return {
55768
+ DBInstances: instances,
55769
+ Marker: response.Marker
55794
55770
  };
55795
55771
  }
55796
- if (!passthroughUrls) {
55797
- resources.UrlRewriteFunction = {
55798
- Type: "AWS::CloudFront::Function",
55799
- Properties: {
55800
- Name: { "Fn::Sub": "${AWS::StackName}-url-rewrite" },
55801
- AutoPublish: true,
55802
- FunctionConfig: {
55803
- Comment: "Append .html extension to URLs without extensions",
55804
- Runtime: "cloudfront-js-2.0"
55805
- },
55806
- FunctionCode: `function handler(event) {
55807
- const request = event.request;
55808
- var uri = request.uri;
55809
-
55810
- // If URI ends with /, serve index.html
55811
- if (uri.endsWith('/')) {
55812
- request.uri = uri + 'index.html';
55813
- }
55814
- // If URI doesn't have an extension, append .html
55815
- else if (!uri.includes('.')) {
55816
- request.uri = uri + '.html';
55772
+ async describeDBInstance(dbInstanceIdentifier) {
55773
+ const result = await this.describeDBInstances({ DBInstanceIdentifier: dbInstanceIdentifier });
55774
+ return result.DBInstances?.[0];
55817
55775
  }
55818
-
55819
- return request;
55820
- }`
55821
- }
55776
+ async describeDBClusters(options) {
55777
+ const params = {
55778
+ Action: "DescribeDBClusters",
55779
+ Version: "2014-10-31"
55822
55780
  };
55823
- }
55824
- const s3Origin = {
55825
- Id: `S3-${bucketName}`,
55826
- DomainName: { "Fn::GetAtt": ["S3Bucket", "RegionalDomainName"] },
55827
- S3OriginConfig: {
55828
- OriginAccessIdentity: ""
55829
- },
55830
- OriginAccessControlId: { "Fn::GetAtt": ["CloudFrontOAC", "Id"] }
55831
- };
55832
- const computeOrigin = useComputeOrigin ? {
55833
- Id: computeOriginId,
55834
- DomainName: computeOriginDomain,
55835
- CustomOriginConfig: {
55836
- HTTPPort: computeOriginPort,
55837
- HTTPSPort: 443,
55838
- OriginProtocolPolicy: "http-only",
55839
- OriginSSLProtocols: ["TLSv1.2"]
55781
+ if (options?.DBClusterIdentifier) {
55782
+ params.DBClusterIdentifier = options.DBClusterIdentifier;
55840
55783
  }
55841
- } : null;
55842
- const defaultTargetOriginId = useComputeOrigin ? computeOriginId : `S3-${bucketName}`;
55843
- const distributionConfig = {
55844
- Enabled: true,
55845
- DefaultRootObject: defaultRootObject,
55846
- HttpVersion: "http2and3",
55847
- IPV6Enabled: true,
55848
- PriceClass: "PriceClass_100",
55849
- Origins: computeOrigin ? [computeOrigin, s3Origin] : [s3Origin],
55850
- DefaultCacheBehavior: {
55851
- TargetOriginId: defaultTargetOriginId,
55852
- ViewerProtocolPolicy: "redirect-to-https",
55853
- AllowedMethods: defaultAllowedMethods,
55854
- CachedMethods: defaultCachedMethods,
55855
- Compress: true,
55856
- ...useComputeOrigin ? {
55857
- CachePolicyId: "4135ea2d-6df8-44a3-9df3-4b5a84be39ad",
55858
- OriginRequestPolicyId: "b689b0a8-53d0-40ab-baf2-68738e2966ac",
55859
- ...passthroughUrls && installRootRedirectLogicalId ? {
55860
- FunctionAssociations: [{
55861
- EventType: "viewer-request",
55862
- FunctionARN: { "Fn::GetAtt": [installRootRedirectLogicalId, "FunctionARN"] }
55863
- }]
55864
- } : {}
55865
- } : {
55866
- CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6",
55867
- ...!passthroughUrls && {
55868
- FunctionAssociations: [
55869
- {
55870
- EventType: "viewer-request",
55871
- FunctionARN: { "Fn::GetAtt": ["UrlRewriteFunction", "FunctionARN"] }
55872
- }
55873
- ]
55874
- }
55875
- }
55876
- },
55877
- ...useComputeOrigin && passthroughUrls ? {
55878
- CacheBehaviors: [
55879
- {
55880
- PathPattern: "/install.sh",
55881
- TargetOriginId: `S3-${bucketName}`,
55882
- ViewerProtocolPolicy: "redirect-to-https",
55883
- AllowedMethods: ["GET", "HEAD", "OPTIONS"],
55884
- CachedMethods: ["GET", "HEAD", "OPTIONS"],
55885
- Compress: true,
55886
- CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6"
55887
- }
55888
- ]
55889
- } : {},
55890
- CustomErrorResponses: singlePageApp ? [
55891
- {
55892
- ErrorCode: 403,
55893
- ResponseCode: 200,
55894
- ResponsePagePath: `/${defaultRootObject}`,
55895
- ErrorCachingMinTTL: 300
55896
- },
55897
- {
55898
- ErrorCode: 404,
55899
- ResponseCode: 200,
55900
- ResponsePagePath: `/${defaultRootObject}`,
55901
- ErrorCachingMinTTL: 300
55902
- }
55903
- ] : [
55904
- {
55905
- ErrorCode: 403,
55906
- ResponseCode: 404,
55907
- ResponsePagePath: `/${errorDocument}`,
55908
- ErrorCachingMinTTL: 300
55784
+ if (options?.MaxRecords) {
55785
+ params.MaxRecords = options.MaxRecords;
55786
+ }
55787
+ if (options?.Marker) {
55788
+ params.Marker = options.Marker;
55789
+ }
55790
+ if (options?.Filters) {
55791
+ options.Filters.forEach((filter, i) => {
55792
+ params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
55793
+ filter.Values.forEach((value, j) => {
55794
+ params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
55795
+ });
55796
+ });
55797
+ }
55798
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
55799
+ const result = await this.client.request({
55800
+ service: "rds",
55801
+ region: this.region,
55802
+ method: "POST",
55803
+ path: "/",
55804
+ headers: {
55805
+ "Content-Type": "application/x-www-form-urlencoded"
55909
55806
  },
55910
- {
55911
- ErrorCode: 404,
55912
- ResponseCode: 404,
55913
- ResponsePagePath: `/${errorDocument}`,
55914
- ErrorCachingMinTTL: 300
55915
- }
55916
- ]
55917
- };
55918
- if (domain && certificateArn) {
55919
- distributionConfig.Aliases = aliases && aliases.length > 0 ? aliases : [domain];
55920
- distributionConfig.ViewerCertificate = {
55921
- AcmCertificateArn: certificateArn,
55922
- SslSupportMethod: "sni-only",
55923
- MinimumProtocolVersion: "TLSv1.2_2021"
55924
- };
55925
- } else {
55926
- distributionConfig.ViewerCertificate = {
55927
- CloudFrontDefaultCertificate: true
55807
+ body: queryString
55808
+ });
55809
+ const response = result.DescribeDBClustersResult || result;
55810
+ let clusters = response.DBClusters?.DBCluster || [];
55811
+ if (!Array.isArray(clusters)) {
55812
+ clusters = clusters ? [clusters] : [];
55813
+ }
55814
+ return {
55815
+ DBClusters: clusters,
55816
+ Marker: response.Marker
55928
55817
  };
55929
55818
  }
55930
- resources.CloudFrontDistribution = {
55931
- Type: "AWS::CloudFront::Distribution",
55932
- ...retainPolicy,
55933
- DependsOn: [
55934
- "S3Bucket",
55935
- "CloudFrontOAC",
55936
- ...passthroughUrls && useComputeOrigin && installRootRedirectLogicalId ? [installRootRedirectLogicalId] : [],
55937
- ...!passthroughUrls ? ["UrlRewriteFunction"] : []
55938
- ],
55939
- Properties: {
55940
- DistributionConfig: distributionConfig
55819
+ async describeDBSnapshots(options) {
55820
+ const params = {
55821
+ Action: "DescribeDBSnapshots",
55822
+ Version: "2014-10-31"
55823
+ };
55824
+ if (options?.DBInstanceIdentifier) {
55825
+ params.DBInstanceIdentifier = options.DBInstanceIdentifier;
55941
55826
  }
55942
- };
55943
- outputs.DistributionId = {
55944
- Description: "CloudFront Distribution ID",
55945
- Value: { Ref: "CloudFrontDistribution" }
55946
- };
55947
- outputs.DistributionDomain = {
55948
- Description: "CloudFront Distribution Domain",
55949
- Value: { "Fn::GetAtt": ["CloudFrontDistribution", "DomainName"] }
55950
- };
55951
- resources.S3BucketPolicy = {
55952
- Type: "AWS::S3::BucketPolicy",
55953
- ...retainPolicy,
55954
- DependsOn: ["S3Bucket", "CloudFrontDistribution"],
55955
- Properties: {
55956
- Bucket: { Ref: "S3Bucket" },
55957
- PolicyDocument: {
55958
- Version: "2012-10-17",
55959
- Statement: [
55960
- {
55961
- Sid: "AllowCloudFrontServicePrincipal",
55962
- Effect: "Allow",
55963
- Principal: {
55964
- Service: "cloudfront.amazonaws.com"
55965
- },
55966
- Action: "s3:GetObject",
55967
- Resource: { "Fn::Sub": "arn:aws:s3:::${S3Bucket}/*" },
55968
- Condition: {
55969
- StringEquals: {
55970
- "AWS:SourceArn": {
55971
- "Fn::Sub": "arn:aws:cloudfront::${AWS::AccountId}:distribution/${CloudFrontDistribution}"
55972
- }
55973
- }
55974
- }
55975
- }
55976
- ]
55977
- }
55827
+ if (options?.DBSnapshotIdentifier) {
55828
+ params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
55978
55829
  }
55979
- };
55980
- outputs.SiteUrl = {
55981
- Description: "Site URL",
55982
- Value: domain ? `https://${domain}` : { "Fn::Sub": "https://${CloudFrontDistribution.DomainName}" }
55983
- };
55984
- return {
55985
- AWSTemplateFormatVersion: "2010-09-09",
55986
- Description: `Static site infrastructure for ${domain || bucketName} (External DNS)`,
55987
- Resources: resources,
55988
- Outputs: outputs
55989
- };
55990
- }
55991
- async function deployStaticSiteWithExternalDns(config6) {
55992
- const region = config6.region || "us-east-1";
55993
- const cfRegion = "us-east-1";
55994
- const domain = config6.domain;
55995
- const bucket = config6.bucket || domain.replace(/\./g, "-");
55996
- const stackName = config6.stackName || `${config6.siteName}-static-site`;
55997
- const cf = new CloudFormationClient(cfRegion);
55998
- const acm2 = new ACMClient("us-east-1");
55999
- let dnsProvider = null;
56000
- if (!config6.skipDnsVerification) {
56001
- dnsProvider = createDnsProvider(config6.dnsProvider);
56002
- console.log(`Verifying DNS provider can manage ${domain}...`);
56003
- const verify = await dnsProvider.listRecords(domain);
56004
- if (!verify.success) {
56005
- const reason = verify.message || "unknown error — check API credentials and domain ownership";
56006
- return {
56007
- success: false,
56008
- stackName,
56009
- bucket,
56010
- message: `DNS provider '${dnsProvider.name}' cannot manage domain ${domain}: ${reason}`
56011
- };
55830
+ if (options?.SnapshotType) {
55831
+ params.SnapshotType = options.SnapshotType;
56012
55832
  }
56013
- console.log(`DNS provider '${dnsProvider.name}' verified for ${domain}`);
56014
- } else {
56015
- console.log(`Skipping DNS verification for ${domain}`);
56016
- }
56017
- let certificateArn = config6.certificateArn;
56018
- const domainParts = domain.split(".");
56019
- const isApexDomain = domainParts.length === 2;
56020
- const wwwDomain = isApexDomain ? `www.${domain}` : undefined;
56021
- if (!certificateArn) {
56022
- console.log(`Checking for existing SSL certificate for ${domain}...`);
56023
- const existingCert = await acm2.findCertificateByDomain(domain);
56024
- let existingCertCoversWww = false;
56025
- if (existingCert && existingCert.Status === "ISSUED") {
56026
- if (wwwDomain && existingCert.SubjectAlternativeNames) {
56027
- existingCertCoversWww = existingCert.SubjectAlternativeNames.includes(wwwDomain) || existingCert.SubjectAlternativeNames.some((san) => san === `*.${domain}`);
56028
- } else {
56029
- existingCertCoversWww = true;
56030
- }
56031
- if (existingCertCoversWww) {
56032
- certificateArn = existingCert.CertificateArn;
56033
- console.log(`Found existing certificate with www coverage: ${certificateArn}`);
56034
- } else {
56035
- console.log(`Existing certificate doesn't cover ${wwwDomain}, requesting new one...`);
56036
- }
55833
+ if (options?.MaxRecords) {
55834
+ params.MaxRecords = options.MaxRecords;
56037
55835
  }
56038
- if (!certificateArn) {
56039
- if (!dnsProvider) {
56040
- return {
56041
- success: false,
56042
- stackName,
56043
- bucket,
56044
- message: `No DNS provider available to validate SSL certificate for ${domain}. Provide a certificateArn or enable DNS verification.`
56045
- };
56046
- }
56047
- console.log(`Requesting new SSL certificate for ${domain}${wwwDomain ? ` (including ${wwwDomain})` : ""}...`);
56048
- const validator = new UnifiedDnsValidator(dnsProvider, "us-east-1");
56049
- const certResult = await validator.findOrCreateCertificate({
56050
- domainName: domain,
56051
- subjectAlternativeNames: wwwDomain ? [wwwDomain] : undefined,
56052
- waitForValidation: true,
56053
- maxWaitMinutes: 10
56054
- });
56055
- if (certResult.status !== "issued") {
56056
- return {
56057
- success: false,
56058
- stackName,
56059
- bucket,
56060
- message: `SSL certificate validation failed. Status: ${certResult.status}`
56061
- };
56062
- }
56063
- certificateArn = certResult.certificateArn;
56064
- console.log(`Certificate issued: ${certificateArn}`);
55836
+ if (options?.Marker) {
55837
+ params.Marker = options.Marker;
55838
+ }
55839
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
55840
+ const result = await this.client.request({
55841
+ service: "rds",
55842
+ region: this.region,
55843
+ method: "POST",
55844
+ path: "/",
55845
+ headers: {
55846
+ "Content-Type": "application/x-www-form-urlencoded"
55847
+ },
55848
+ body: queryString
55849
+ });
55850
+ const response = result.DescribeDBSnapshotsResult || result;
55851
+ let snapshots = response.DBSnapshots?.DBSnapshot || [];
55852
+ if (!Array.isArray(snapshots)) {
55853
+ snapshots = snapshots ? [snapshots] : [];
56065
55854
  }
55855
+ return {
55856
+ DBSnapshots: snapshots,
55857
+ Marker: response.Marker
55858
+ };
56066
55859
  }
56067
- let stackExists = false;
56068
- let existingBucketName;
56069
- try {
56070
- const existingStacks = await cf.describeStacks({ stackName });
56071
- if (existingStacks.Stacks.length > 0) {
56072
- const stack = existingStacks.Stacks[0];
56073
- const stackStatus = stack.StackStatus;
56074
- if (stackStatus === "DELETE_IN_PROGRESS") {
56075
- console.log("Previous stack is still being deleted, waiting...");
56076
- await cf.waitForStack(stackName, "stack-delete-complete");
56077
- stackExists = false;
56078
- } else if (stackStatus === "DELETE_COMPLETE") {
56079
- stackExists = false;
56080
- } else {
56081
- stackExists = true;
56082
- const outputs2 = stack.Outputs || [];
56083
- existingBucketName = outputs2.find((o) => o.OutputKey === "BucketName")?.OutputValue;
56084
- }
55860
+ async describeDBSubnetGroups(options) {
55861
+ const params = {
55862
+ Action: "DescribeDBSubnetGroups",
55863
+ Version: "2014-10-31"
55864
+ };
55865
+ if (options?.DBSubnetGroupName) {
55866
+ params.DBSubnetGroupName = options.DBSubnetGroupName;
56085
55867
  }
56086
- } catch (err) {
56087
- if (err.message?.includes("does not exist") || err.code === "ValidationError") {
56088
- stackExists = false;
56089
- } else {
56090
- throw err;
55868
+ if (options?.MaxRecords) {
55869
+ params.MaxRecords = options.MaxRecords;
56091
55870
  }
56092
- }
56093
- let finalBucket = existingBucketName || bucket;
56094
- if (!stackExists) {
56095
- const s32 = new S3Client2(region);
56096
- const cloudfront2 = new CloudFrontClient;
56097
- let hasExistingDistribution = false;
56098
- if (domain) {
56099
- try {
56100
- console.log(`Checking for existing CloudFront distributions with alias ${domain}...`);
56101
- const distributions = await cloudfront2.listDistributions();
56102
- for (const dist of distributions) {
55871
+ if (options?.Marker) {
55872
+ params.Marker = options.Marker;
55873
+ }
55874
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
55875
+ const result = await this.client.request({
55876
+ service: "rds",
55877
+ region: this.region,
55878
+ method: "POST",
55879
+ path: "/",
55880
+ headers: {
55881
+ "Content-Type": "application/x-www-form-urlencoded"
55882
+ },
55883
+ body: queryString
55884
+ });
55885
+ const response = result.DescribeDBSubnetGroupsResult || result;
55886
+ let groups = response.DBSubnetGroups?.DBSubnetGroup || [];
55887
+ if (!Array.isArray(groups)) {
55888
+ groups = groups ? [groups] : [];
55889
+ }
55890
+ return {
55891
+ DBSubnetGroups: groups,
55892
+ Marker: response.Marker
55893
+ };
55894
+ }
55895
+ async createDBInstance(options) {
55896
+ const params = {
55897
+ Action: "CreateDBInstance",
55898
+ Version: "2014-10-31",
55899
+ DBInstanceIdentifier: options.DBInstanceIdentifier,
55900
+ DBInstanceClass: options.DBInstanceClass,
55901
+ Engine: options.Engine
55902
+ };
55903
+ if (options.MasterUsername)
55904
+ params.MasterUsername = options.MasterUsername;
55905
+ if (options.MasterUserPassword)
55906
+ params.MasterUserPassword = options.MasterUserPassword;
55907
+ if (options.DBName)
55908
+ params.DBName = options.DBName;
55909
+ if (options.AllocatedStorage)
55910
+ params.AllocatedStorage = options.AllocatedStorage;
55911
+ if (options.DBSubnetGroupName)
55912
+ params.DBSubnetGroupName = options.DBSubnetGroupName;
55913
+ if (options.AvailabilityZone)
55914
+ params.AvailabilityZone = options.AvailabilityZone;
55915
+ if (options.PreferredMaintenanceWindow)
55916
+ params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
55917
+ if (options.PreferredBackupWindow)
55918
+ params.PreferredBackupWindow = options.PreferredBackupWindow;
55919
+ if (options.BackupRetentionPeriod !== undefined)
55920
+ params.BackupRetentionPeriod = options.BackupRetentionPeriod;
55921
+ if (options.MultiAZ !== undefined)
55922
+ params.MultiAZ = options.MultiAZ;
55923
+ if (options.EngineVersion)
55924
+ params.EngineVersion = options.EngineVersion;
55925
+ if (options.AutoMinorVersionUpgrade !== undefined)
55926
+ params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
55927
+ if (options.LicenseModel)
55928
+ params.LicenseModel = options.LicenseModel;
55929
+ if (options.PubliclyAccessible !== undefined)
55930
+ params.PubliclyAccessible = options.PubliclyAccessible;
55931
+ if (options.StorageType)
55932
+ params.StorageType = options.StorageType;
55933
+ if (options.StorageEncrypted !== undefined)
55934
+ params.StorageEncrypted = options.StorageEncrypted;
55935
+ if (options.KmsKeyId)
55936
+ params.KmsKeyId = options.KmsKeyId;
55937
+ if (options.DeletionProtection !== undefined)
55938
+ params.DeletionProtection = options.DeletionProtection;
55939
+ if (options.VpcSecurityGroupIds) {
55940
+ options.VpcSecurityGroupIds.forEach((id, i) => {
55941
+ params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
55942
+ });
55943
+ }
55944
+ if (options.Tags) {
55945
+ options.Tags.forEach((tag, i) => {
55946
+ params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
55947
+ params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
55948
+ });
55949
+ }
55950
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
55951
+ const result = await this.client.request({
55952
+ service: "rds",
55953
+ region: this.region,
55954
+ method: "POST",
55955
+ path: "/",
55956
+ headers: {
55957
+ "Content-Type": "application/x-www-form-urlencoded"
55958
+ },
55959
+ body: queryString
55960
+ });
55961
+ const response = result.CreateDBInstanceResult || result;
55962
+ return {
55963
+ DBInstance: response.DBInstance
55964
+ };
55965
+ }
55966
+ async deleteDBInstance(options) {
55967
+ const params = {
55968
+ Action: "DeleteDBInstance",
55969
+ Version: "2014-10-31",
55970
+ DBInstanceIdentifier: options.DBInstanceIdentifier
55971
+ };
55972
+ if (options.SkipFinalSnapshot !== undefined) {
55973
+ params.SkipFinalSnapshot = options.SkipFinalSnapshot;
55974
+ }
55975
+ if (options.FinalDBSnapshotIdentifier) {
55976
+ params.FinalDBSnapshotIdentifier = options.FinalDBSnapshotIdentifier;
55977
+ }
55978
+ if (options.DeleteAutomatedBackups !== undefined) {
55979
+ params.DeleteAutomatedBackups = options.DeleteAutomatedBackups;
55980
+ }
55981
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
55982
+ const result = await this.client.request({
55983
+ service: "rds",
55984
+ region: this.region,
55985
+ method: "POST",
55986
+ path: "/",
55987
+ headers: {
55988
+ "Content-Type": "application/x-www-form-urlencoded"
55989
+ },
55990
+ body: queryString
55991
+ });
55992
+ const response = result.DeleteDBInstanceResult || result;
55993
+ return {
55994
+ DBInstance: response.DBInstance
55995
+ };
55996
+ }
55997
+ async modifyDBInstance(options) {
55998
+ const params = {
55999
+ Action: "ModifyDBInstance",
56000
+ Version: "2014-10-31",
56001
+ DBInstanceIdentifier: options.DBInstanceIdentifier
56002
+ };
56003
+ if (options.DBInstanceClass)
56004
+ params.DBInstanceClass = options.DBInstanceClass;
56005
+ if (options.AllocatedStorage)
56006
+ params.AllocatedStorage = options.AllocatedStorage;
56007
+ if (options.MasterUserPassword)
56008
+ params.MasterUserPassword = options.MasterUserPassword;
56009
+ if (options.BackupRetentionPeriod !== undefined)
56010
+ params.BackupRetentionPeriod = options.BackupRetentionPeriod;
56011
+ if (options.PreferredBackupWindow)
56012
+ params.PreferredBackupWindow = options.PreferredBackupWindow;
56013
+ if (options.PreferredMaintenanceWindow)
56014
+ params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
56015
+ if (options.MultiAZ !== undefined)
56016
+ params.MultiAZ = options.MultiAZ;
56017
+ if (options.EngineVersion)
56018
+ params.EngineVersion = options.EngineVersion;
56019
+ if (options.AutoMinorVersionUpgrade !== undefined)
56020
+ params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
56021
+ if (options.PubliclyAccessible !== undefined)
56022
+ params.PubliclyAccessible = options.PubliclyAccessible;
56023
+ if (options.ApplyImmediately !== undefined)
56024
+ params.ApplyImmediately = options.ApplyImmediately;
56025
+ if (options.StorageType)
56026
+ params.StorageType = options.StorageType;
56027
+ if (options.DeletionProtection !== undefined)
56028
+ params.DeletionProtection = options.DeletionProtection;
56029
+ if (options.VpcSecurityGroupIds) {
56030
+ options.VpcSecurityGroupIds.forEach((id, i) => {
56031
+ params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
56032
+ });
56033
+ }
56034
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56035
+ const result = await this.client.request({
56036
+ service: "rds",
56037
+ region: this.region,
56038
+ method: "POST",
56039
+ path: "/",
56040
+ headers: {
56041
+ "Content-Type": "application/x-www-form-urlencoded"
56042
+ },
56043
+ body: queryString
56044
+ });
56045
+ const response = result.ModifyDBInstanceResult || result;
56046
+ return {
56047
+ DBInstance: response.DBInstance
56048
+ };
56049
+ }
56050
+ async modifyDBCluster(options) {
56051
+ const params = {
56052
+ Action: "ModifyDBCluster",
56053
+ Version: "2014-10-31",
56054
+ DBClusterIdentifier: options.DBClusterIdentifier
56055
+ };
56056
+ if (options.ServerlessV2ScalingConfiguration) {
56057
+ params["ServerlessV2ScalingConfiguration.MinCapacity"] = options.ServerlessV2ScalingConfiguration.MinCapacity;
56058
+ params["ServerlessV2ScalingConfiguration.MaxCapacity"] = options.ServerlessV2ScalingConfiguration.MaxCapacity;
56059
+ }
56060
+ if (options.BackupRetentionPeriod !== undefined)
56061
+ params.BackupRetentionPeriod = options.BackupRetentionPeriod;
56062
+ if (options.ApplyImmediately !== undefined)
56063
+ params.ApplyImmediately = options.ApplyImmediately;
56064
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56065
+ const result = await this.client.request({
56066
+ service: "rds",
56067
+ region: this.region,
56068
+ method: "POST",
56069
+ path: "/",
56070
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
56071
+ body: queryString
56072
+ });
56073
+ const response = result.ModifyDBClusterResult || result;
56074
+ return { DBCluster: response.DBCluster };
56075
+ }
56076
+ async restoreDBClusterToPointInTime(options) {
56077
+ const params = {
56078
+ Action: "RestoreDBClusterToPointInTime",
56079
+ Version: "2014-10-31",
56080
+ DBClusterIdentifier: options.DBClusterIdentifier,
56081
+ SourceDBClusterIdentifier: options.SourceDBClusterIdentifier
56082
+ };
56083
+ if (options.RestoreToTime)
56084
+ params.RestoreToTime = options.RestoreToTime.toISOString();
56085
+ if (options.UseLatestRestorableTime)
56086
+ params.UseLatestRestorableTime = true;
56087
+ if (options.DBSubnetGroupName)
56088
+ params.DBSubnetGroupName = options.DBSubnetGroupName;
56089
+ if (options.VpcSecurityGroupIds) {
56090
+ options.VpcSecurityGroupIds.forEach((id, i) => {
56091
+ params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
56092
+ });
56093
+ }
56094
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56095
+ const result = await this.client.request({
56096
+ service: "rds",
56097
+ region: this.region,
56098
+ method: "POST",
56099
+ path: "/",
56100
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
56101
+ body: queryString
56102
+ });
56103
+ const response = result.RestoreDBClusterToPointInTimeResult || result;
56104
+ return { DBCluster: response.DBCluster };
56105
+ }
56106
+ async startDBInstance(dbInstanceIdentifier) {
56107
+ const params = {
56108
+ Action: "StartDBInstance",
56109
+ Version: "2014-10-31",
56110
+ DBInstanceIdentifier: dbInstanceIdentifier
56111
+ };
56112
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56113
+ const result = await this.client.request({
56114
+ service: "rds",
56115
+ region: this.region,
56116
+ method: "POST",
56117
+ path: "/",
56118
+ headers: {
56119
+ "Content-Type": "application/x-www-form-urlencoded"
56120
+ },
56121
+ body: queryString
56122
+ });
56123
+ const response = result.StartDBInstanceResult || result;
56124
+ return {
56125
+ DBInstance: response.DBInstance
56126
+ };
56127
+ }
56128
+ async stopDBInstance(options) {
56129
+ const params = {
56130
+ Action: "StopDBInstance",
56131
+ Version: "2014-10-31",
56132
+ DBInstanceIdentifier: options.DBInstanceIdentifier
56133
+ };
56134
+ if (options.DBSnapshotIdentifier) {
56135
+ params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
56136
+ }
56137
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56138
+ const result = await this.client.request({
56139
+ service: "rds",
56140
+ region: this.region,
56141
+ method: "POST",
56142
+ path: "/",
56143
+ headers: {
56144
+ "Content-Type": "application/x-www-form-urlencoded"
56145
+ },
56146
+ body: queryString
56147
+ });
56148
+ const response = result.StopDBInstanceResult || result;
56149
+ return {
56150
+ DBInstance: response.DBInstance
56151
+ };
56152
+ }
56153
+ async rebootDBInstance(options) {
56154
+ const params = {
56155
+ Action: "RebootDBInstance",
56156
+ Version: "2014-10-31",
56157
+ DBInstanceIdentifier: options.DBInstanceIdentifier
56158
+ };
56159
+ if (options.ForceFailover !== undefined) {
56160
+ params.ForceFailover = options.ForceFailover;
56161
+ }
56162
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56163
+ const result = await this.client.request({
56164
+ service: "rds",
56165
+ region: this.region,
56166
+ method: "POST",
56167
+ path: "/",
56168
+ headers: {
56169
+ "Content-Type": "application/x-www-form-urlencoded"
56170
+ },
56171
+ body: queryString
56172
+ });
56173
+ const response = result.RebootDBInstanceResult || result;
56174
+ return {
56175
+ DBInstance: response.DBInstance
56176
+ };
56177
+ }
56178
+ async createDBSnapshot(options) {
56179
+ const params = {
56180
+ Action: "CreateDBSnapshot",
56181
+ Version: "2014-10-31",
56182
+ DBInstanceIdentifier: options.DBInstanceIdentifier,
56183
+ DBSnapshotIdentifier: options.DBSnapshotIdentifier
56184
+ };
56185
+ if (options.Tags) {
56186
+ options.Tags.forEach((tag, i) => {
56187
+ params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
56188
+ params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
56189
+ });
56190
+ }
56191
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56192
+ const result = await this.client.request({
56193
+ service: "rds",
56194
+ region: this.region,
56195
+ method: "POST",
56196
+ path: "/",
56197
+ headers: {
56198
+ "Content-Type": "application/x-www-form-urlencoded"
56199
+ },
56200
+ body: queryString
56201
+ });
56202
+ const response = result.CreateDBSnapshotResult || result;
56203
+ return {
56204
+ DBSnapshot: response.DBSnapshot
56205
+ };
56206
+ }
56207
+ async deleteDBSnapshot(dbSnapshotIdentifier) {
56208
+ const params = {
56209
+ Action: "DeleteDBSnapshot",
56210
+ Version: "2014-10-31",
56211
+ DBSnapshotIdentifier: dbSnapshotIdentifier
56212
+ };
56213
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56214
+ const result = await this.client.request({
56215
+ service: "rds",
56216
+ region: this.region,
56217
+ method: "POST",
56218
+ path: "/",
56219
+ headers: {
56220
+ "Content-Type": "application/x-www-form-urlencoded"
56221
+ },
56222
+ body: queryString
56223
+ });
56224
+ const response = result.DeleteDBSnapshotResult || result;
56225
+ return {
56226
+ DBSnapshot: response.DBSnapshot
56227
+ };
56228
+ }
56229
+ async restoreDBInstanceFromDBSnapshot(options) {
56230
+ const params = {
56231
+ Action: "RestoreDBInstanceFromDBSnapshot",
56232
+ Version: "2014-10-31",
56233
+ DBInstanceIdentifier: options.DBInstanceIdentifier,
56234
+ DBSnapshotIdentifier: options.DBSnapshotIdentifier
56235
+ };
56236
+ if (options.DBInstanceClass)
56237
+ params.DBInstanceClass = options.DBInstanceClass;
56238
+ if (options.Port)
56239
+ params.Port = options.Port;
56240
+ if (options.AvailabilityZone)
56241
+ params.AvailabilityZone = options.AvailabilityZone;
56242
+ if (options.DBSubnetGroupName)
56243
+ params.DBSubnetGroupName = options.DBSubnetGroupName;
56244
+ if (options.MultiAZ !== undefined)
56245
+ params.MultiAZ = options.MultiAZ;
56246
+ if (options.PubliclyAccessible !== undefined)
56247
+ params.PubliclyAccessible = options.PubliclyAccessible;
56248
+ if (options.AutoMinorVersionUpgrade !== undefined)
56249
+ params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
56250
+ if (options.StorageType)
56251
+ params.StorageType = options.StorageType;
56252
+ if (options.DeletionProtection !== undefined)
56253
+ params.DeletionProtection = options.DeletionProtection;
56254
+ if (options.VpcSecurityGroupIds) {
56255
+ options.VpcSecurityGroupIds.forEach((id, i) => {
56256
+ params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
56257
+ });
56258
+ }
56259
+ if (options.Tags) {
56260
+ options.Tags.forEach((tag, i) => {
56261
+ params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
56262
+ params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
56263
+ });
56264
+ }
56265
+ const queryString = new URLSearchParams(buildQueryParams(params)).toString();
56266
+ const result = await this.client.request({
56267
+ service: "rds",
56268
+ region: this.region,
56269
+ method: "POST",
56270
+ path: "/",
56271
+ headers: {
56272
+ "Content-Type": "application/x-www-form-urlencoded"
56273
+ },
56274
+ body: queryString
56275
+ });
56276
+ const response = result.RestoreDBInstanceFromDBSnapshotResult || result;
56277
+ return {
56278
+ DBInstance: response.DBInstance
56279
+ };
56280
+ }
56281
+ async waitForDBInstanceAvailable(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
56282
+ for (let i = 0;i < maxAttempts; i++) {
56283
+ const instance = await this.describeDBInstance(dbInstanceIdentifier);
56284
+ if (instance?.DBInstanceStatus === "available") {
56285
+ return instance;
56286
+ }
56287
+ if (["deleted", "failed", "incompatible-restore", "incompatible-parameters"].includes(instance?.DBInstanceStatus || "")) {
56288
+ throw new Error(`DB instance ${dbInstanceIdentifier} is in terminal state: ${instance?.DBInstanceStatus}`);
56289
+ }
56290
+ await new Promise((resolve14) => setTimeout(resolve14, delayMs));
56291
+ }
56292
+ throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to become available`);
56293
+ }
56294
+ async waitForDBInstanceDeleted(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
56295
+ for (let i = 0;i < maxAttempts; i++) {
56296
+ try {
56297
+ const instance = await this.describeDBInstance(dbInstanceIdentifier);
56298
+ if (instance?.DBInstanceStatus === "deleting") {
56299
+ await new Promise((resolve14) => setTimeout(resolve14, delayMs));
56300
+ continue;
56301
+ }
56302
+ throw new Error(`DB instance ${dbInstanceIdentifier} is in state: ${instance?.DBInstanceStatus}`);
56303
+ } catch (error) {
56304
+ if (error.code === "DBInstanceNotFound" || error.code === "DBInstanceNotFoundFault") {
56305
+ return;
56306
+ }
56307
+ throw error;
56308
+ }
56309
+ }
56310
+ throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to be deleted`);
56311
+ }
56312
+ }
56313
+ var init_rds = __esm(() => {
56314
+ init_client();
56315
+ });
56316
+
56317
+ // src/deploy/static-site-external-dns.ts
56318
+ function generateExternalDnsStaticSiteTemplate(config6) {
56319
+ const {
56320
+ bucketName,
56321
+ domain,
56322
+ aliases,
56323
+ certificateArn,
56324
+ defaultRootObject = "index.html",
56325
+ errorDocument = "404.html",
56326
+ passthroughUrls = false,
56327
+ singlePageApp = false,
56328
+ dynamicApp = false,
56329
+ computeOriginDomain,
56330
+ computeOriginPort = 3008,
56331
+ computeOriginId = "app-compute",
56332
+ retainOnStackDelete = false
56333
+ } = config6;
56334
+ const retainPolicy = retainOnStackDelete ? { DeletionPolicy: "Retain", UpdateReplacePolicy: "Retain" } : {};
56335
+ const useComputeOrigin = dynamicApp && !!computeOriginDomain;
56336
+ const defaultAllowedMethods = useComputeOrigin ? ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"] : ["GET", "HEAD"];
56337
+ const defaultCachedMethods = useComputeOrigin ? ["GET", "HEAD"] : ["GET", "HEAD"];
56338
+ const resources = {};
56339
+ const outputs = {};
56340
+ resources.S3Bucket = {
56341
+ Type: "AWS::S3::Bucket",
56342
+ ...retainPolicy,
56343
+ Properties: {
56344
+ BucketName: bucketName,
56345
+ PublicAccessBlockConfiguration: {
56346
+ BlockPublicAcls: true,
56347
+ BlockPublicPolicy: false,
56348
+ IgnorePublicAcls: true,
56349
+ RestrictPublicBuckets: false
56350
+ },
56351
+ WebsiteConfiguration: {
56352
+ IndexDocument: defaultRootObject,
56353
+ ErrorDocument: errorDocument
56354
+ }
56355
+ }
56356
+ };
56357
+ outputs.BucketName = {
56358
+ Description: "S3 Bucket Name",
56359
+ Value: { Ref: "S3Bucket" }
56360
+ };
56361
+ outputs.BucketArn = {
56362
+ Description: "S3 Bucket ARN",
56363
+ Value: { "Fn::GetAtt": ["S3Bucket", "Arn"] }
56364
+ };
56365
+ resources.CloudFrontOAC = {
56366
+ Type: "AWS::CloudFront::OriginAccessControl",
56367
+ ...retainPolicy,
56368
+ Properties: {
56369
+ OriginAccessControlConfig: {
56370
+ Name: `OAC-${bucketName}`,
56371
+ Description: `OAC for ${bucketName}`,
56372
+ OriginAccessControlOriginType: "s3",
56373
+ SigningBehavior: "always",
56374
+ SigningProtocol: "sigv4"
56375
+ }
56376
+ }
56377
+ };
56378
+ let installRootRedirectLogicalId;
56379
+ if (passthroughUrls && useComputeOrigin) {
56380
+ installRootRedirectLogicalId = "InstallRootRedirectFunction";
56381
+ resources[installRootRedirectLogicalId] = {
56382
+ Type: "AWS::CloudFront::Function",
56383
+ Properties: {
56384
+ Name: { "Fn::Sub": "${AWS::StackName}-install-root-redirect" },
56385
+ AutoPublish: true,
56386
+ FunctionConfig: {
56387
+ Comment: "Redirect curl pantry.dev | bash (GET /) to /install.sh on S3",
56388
+ Runtime: "cloudfront-js-2.0"
56389
+ },
56390
+ FunctionCode: `function handler(event) {
56391
+ var request = event.request;
56392
+ if (request.uri === '/' || request.uri === '') {
56393
+ return {
56394
+ statusCode: 302,
56395
+ statusDescription: 'Found',
56396
+ headers: {
56397
+ location: { value: 'https://' + request.headers.host.value + '/install.sh' }
56398
+ }
56399
+ };
56400
+ }
56401
+ return request;
56402
+ }`
56403
+ }
56404
+ };
56405
+ }
56406
+ if (!passthroughUrls) {
56407
+ resources.UrlRewriteFunction = {
56408
+ Type: "AWS::CloudFront::Function",
56409
+ Properties: {
56410
+ Name: { "Fn::Sub": "${AWS::StackName}-url-rewrite" },
56411
+ AutoPublish: true,
56412
+ FunctionConfig: {
56413
+ Comment: "Append .html extension to URLs without extensions",
56414
+ Runtime: "cloudfront-js-2.0"
56415
+ },
56416
+ FunctionCode: `function handler(event) {
56417
+ const request = event.request;
56418
+ var uri = request.uri;
56419
+
56420
+ // If URI ends with /, serve index.html
56421
+ if (uri.endsWith('/')) {
56422
+ request.uri = uri + 'index.html';
56423
+ }
56424
+ // If URI doesn't have an extension, append .html
56425
+ else if (!uri.includes('.')) {
56426
+ request.uri = uri + '.html';
56427
+ }
56428
+
56429
+ return request;
56430
+ }`
56431
+ }
56432
+ };
56433
+ }
56434
+ const s3Origin = {
56435
+ Id: `S3-${bucketName}`,
56436
+ DomainName: { "Fn::GetAtt": ["S3Bucket", "RegionalDomainName"] },
56437
+ S3OriginConfig: {
56438
+ OriginAccessIdentity: ""
56439
+ },
56440
+ OriginAccessControlId: { "Fn::GetAtt": ["CloudFrontOAC", "Id"] }
56441
+ };
56442
+ const computeOrigin = useComputeOrigin ? {
56443
+ Id: computeOriginId,
56444
+ DomainName: computeOriginDomain,
56445
+ CustomOriginConfig: {
56446
+ HTTPPort: computeOriginPort,
56447
+ HTTPSPort: 443,
56448
+ OriginProtocolPolicy: "http-only",
56449
+ OriginSSLProtocols: ["TLSv1.2"]
56450
+ }
56451
+ } : null;
56452
+ const defaultTargetOriginId = useComputeOrigin ? computeOriginId : `S3-${bucketName}`;
56453
+ const distributionConfig = {
56454
+ Enabled: true,
56455
+ DefaultRootObject: defaultRootObject,
56456
+ HttpVersion: "http2and3",
56457
+ IPV6Enabled: true,
56458
+ PriceClass: "PriceClass_100",
56459
+ Origins: computeOrigin ? [computeOrigin, s3Origin] : [s3Origin],
56460
+ DefaultCacheBehavior: {
56461
+ TargetOriginId: defaultTargetOriginId,
56462
+ ViewerProtocolPolicy: "redirect-to-https",
56463
+ AllowedMethods: defaultAllowedMethods,
56464
+ CachedMethods: defaultCachedMethods,
56465
+ Compress: true,
56466
+ ...useComputeOrigin ? {
56467
+ CachePolicyId: "4135ea2d-6df8-44a3-9df3-4b5a84be39ad",
56468
+ OriginRequestPolicyId: "b689b0a8-53d0-40ab-baf2-68738e2966ac",
56469
+ ...passthroughUrls && installRootRedirectLogicalId ? {
56470
+ FunctionAssociations: [{
56471
+ EventType: "viewer-request",
56472
+ FunctionARN: { "Fn::GetAtt": [installRootRedirectLogicalId, "FunctionARN"] }
56473
+ }]
56474
+ } : {}
56475
+ } : {
56476
+ CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6",
56477
+ ...!passthroughUrls && {
56478
+ FunctionAssociations: [
56479
+ {
56480
+ EventType: "viewer-request",
56481
+ FunctionARN: { "Fn::GetAtt": ["UrlRewriteFunction", "FunctionARN"] }
56482
+ }
56483
+ ]
56484
+ }
56485
+ }
56486
+ },
56487
+ ...useComputeOrigin && passthroughUrls ? {
56488
+ CacheBehaviors: [
56489
+ {
56490
+ PathPattern: "/install.sh",
56491
+ TargetOriginId: `S3-${bucketName}`,
56492
+ ViewerProtocolPolicy: "redirect-to-https",
56493
+ AllowedMethods: ["GET", "HEAD", "OPTIONS"],
56494
+ CachedMethods: ["GET", "HEAD", "OPTIONS"],
56495
+ Compress: true,
56496
+ CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6"
56497
+ }
56498
+ ]
56499
+ } : {},
56500
+ CustomErrorResponses: singlePageApp ? [
56501
+ {
56502
+ ErrorCode: 403,
56503
+ ResponseCode: 200,
56504
+ ResponsePagePath: `/${defaultRootObject}`,
56505
+ ErrorCachingMinTTL: 300
56506
+ },
56507
+ {
56508
+ ErrorCode: 404,
56509
+ ResponseCode: 200,
56510
+ ResponsePagePath: `/${defaultRootObject}`,
56511
+ ErrorCachingMinTTL: 300
56512
+ }
56513
+ ] : [
56514
+ {
56515
+ ErrorCode: 403,
56516
+ ResponseCode: 404,
56517
+ ResponsePagePath: `/${errorDocument}`,
56518
+ ErrorCachingMinTTL: 300
56519
+ },
56520
+ {
56521
+ ErrorCode: 404,
56522
+ ResponseCode: 404,
56523
+ ResponsePagePath: `/${errorDocument}`,
56524
+ ErrorCachingMinTTL: 300
56525
+ }
56526
+ ]
56527
+ };
56528
+ if (domain && certificateArn) {
56529
+ distributionConfig.Aliases = aliases && aliases.length > 0 ? aliases : [domain];
56530
+ distributionConfig.ViewerCertificate = {
56531
+ AcmCertificateArn: certificateArn,
56532
+ SslSupportMethod: "sni-only",
56533
+ MinimumProtocolVersion: "TLSv1.2_2021"
56534
+ };
56535
+ } else {
56536
+ distributionConfig.ViewerCertificate = {
56537
+ CloudFrontDefaultCertificate: true
56538
+ };
56539
+ }
56540
+ resources.CloudFrontDistribution = {
56541
+ Type: "AWS::CloudFront::Distribution",
56542
+ ...retainPolicy,
56543
+ DependsOn: [
56544
+ "S3Bucket",
56545
+ "CloudFrontOAC",
56546
+ ...passthroughUrls && useComputeOrigin && installRootRedirectLogicalId ? [installRootRedirectLogicalId] : [],
56547
+ ...!passthroughUrls ? ["UrlRewriteFunction"] : []
56548
+ ],
56549
+ Properties: {
56550
+ DistributionConfig: distributionConfig
56551
+ }
56552
+ };
56553
+ outputs.DistributionId = {
56554
+ Description: "CloudFront Distribution ID",
56555
+ Value: { Ref: "CloudFrontDistribution" }
56556
+ };
56557
+ outputs.DistributionDomain = {
56558
+ Description: "CloudFront Distribution Domain",
56559
+ Value: { "Fn::GetAtt": ["CloudFrontDistribution", "DomainName"] }
56560
+ };
56561
+ resources.S3BucketPolicy = {
56562
+ Type: "AWS::S3::BucketPolicy",
56563
+ ...retainPolicy,
56564
+ DependsOn: ["S3Bucket", "CloudFrontDistribution"],
56565
+ Properties: {
56566
+ Bucket: { Ref: "S3Bucket" },
56567
+ PolicyDocument: {
56568
+ Version: "2012-10-17",
56569
+ Statement: [
56570
+ {
56571
+ Sid: "AllowCloudFrontServicePrincipal",
56572
+ Effect: "Allow",
56573
+ Principal: {
56574
+ Service: "cloudfront.amazonaws.com"
56575
+ },
56576
+ Action: "s3:GetObject",
56577
+ Resource: { "Fn::Sub": "arn:aws:s3:::${S3Bucket}/*" },
56578
+ Condition: {
56579
+ StringEquals: {
56580
+ "AWS:SourceArn": {
56581
+ "Fn::Sub": "arn:aws:cloudfront::${AWS::AccountId}:distribution/${CloudFrontDistribution}"
56582
+ }
56583
+ }
56584
+ }
56585
+ }
56586
+ ]
56587
+ }
56588
+ }
56589
+ };
56590
+ outputs.SiteUrl = {
56591
+ Description: "Site URL",
56592
+ Value: domain ? `https://${domain}` : { "Fn::Sub": "https://${CloudFrontDistribution.DomainName}" }
56593
+ };
56594
+ return {
56595
+ AWSTemplateFormatVersion: "2010-09-09",
56596
+ Description: `Static site infrastructure for ${domain || bucketName} (External DNS)`,
56597
+ Resources: resources,
56598
+ Outputs: outputs
56599
+ };
56600
+ }
56601
+ async function deployStaticSiteWithExternalDns(config6) {
56602
+ const region = config6.region || "us-east-1";
56603
+ const cfRegion = "us-east-1";
56604
+ const domain = config6.domain;
56605
+ const bucket = config6.bucket || domain.replace(/\./g, "-");
56606
+ const stackName = config6.stackName || `${config6.siteName}-static-site`;
56607
+ const cf = new CloudFormationClient(cfRegion);
56608
+ const acm2 = new ACMClient("us-east-1");
56609
+ let dnsProvider = null;
56610
+ if (!config6.skipDnsVerification) {
56611
+ dnsProvider = createDnsProvider(config6.dnsProvider);
56612
+ console.log(`Verifying DNS provider can manage ${domain}...`);
56613
+ const verify = await dnsProvider.listRecords(domain);
56614
+ if (!verify.success) {
56615
+ const reason = verify.message || "unknown error — check API credentials and domain ownership";
56616
+ return {
56617
+ success: false,
56618
+ stackName,
56619
+ bucket,
56620
+ message: `DNS provider '${dnsProvider.name}' cannot manage domain ${domain}: ${reason}`
56621
+ };
56622
+ }
56623
+ console.log(`DNS provider '${dnsProvider.name}' verified for ${domain}`);
56624
+ } else {
56625
+ console.log(`Skipping DNS verification for ${domain}`);
56626
+ }
56627
+ let certificateArn = config6.certificateArn;
56628
+ const domainParts = domain.split(".");
56629
+ const isApexDomain = domainParts.length === 2;
56630
+ const wwwDomain = isApexDomain ? `www.${domain}` : undefined;
56631
+ if (!certificateArn) {
56632
+ console.log(`Checking for existing SSL certificate for ${domain}...`);
56633
+ const existingCert = await acm2.findCertificateByDomain(domain);
56634
+ let existingCertCoversWww = false;
56635
+ if (existingCert && existingCert.Status === "ISSUED") {
56636
+ if (wwwDomain && existingCert.SubjectAlternativeNames) {
56637
+ existingCertCoversWww = existingCert.SubjectAlternativeNames.includes(wwwDomain) || existingCert.SubjectAlternativeNames.some((san) => san === `*.${domain}`);
56638
+ } else {
56639
+ existingCertCoversWww = true;
56640
+ }
56641
+ if (existingCertCoversWww) {
56642
+ certificateArn = existingCert.CertificateArn;
56643
+ console.log(`Found existing certificate with www coverage: ${certificateArn}`);
56644
+ } else {
56645
+ console.log(`Existing certificate doesn't cover ${wwwDomain}, requesting new one...`);
56646
+ }
56647
+ }
56648
+ if (!certificateArn) {
56649
+ if (!dnsProvider) {
56650
+ return {
56651
+ success: false,
56652
+ stackName,
56653
+ bucket,
56654
+ message: `No DNS provider available to validate SSL certificate for ${domain}. Provide a certificateArn or enable DNS verification.`
56655
+ };
56656
+ }
56657
+ console.log(`Requesting new SSL certificate for ${domain}${wwwDomain ? ` (including ${wwwDomain})` : ""}...`);
56658
+ const validator = new UnifiedDnsValidator(dnsProvider, "us-east-1");
56659
+ const certResult = await validator.findOrCreateCertificate({
56660
+ domainName: domain,
56661
+ subjectAlternativeNames: wwwDomain ? [wwwDomain] : undefined,
56662
+ waitForValidation: true,
56663
+ maxWaitMinutes: 10
56664
+ });
56665
+ if (certResult.status !== "issued") {
56666
+ return {
56667
+ success: false,
56668
+ stackName,
56669
+ bucket,
56670
+ message: `SSL certificate validation failed. Status: ${certResult.status}`
56671
+ };
56672
+ }
56673
+ certificateArn = certResult.certificateArn;
56674
+ console.log(`Certificate issued: ${certificateArn}`);
56675
+ }
56676
+ }
56677
+ let stackExists = false;
56678
+ let existingBucketName;
56679
+ try {
56680
+ const existingStacks = await cf.describeStacks({ stackName });
56681
+ if (existingStacks.Stacks.length > 0) {
56682
+ const stack = existingStacks.Stacks[0];
56683
+ const stackStatus = stack.StackStatus;
56684
+ if (stackStatus === "DELETE_IN_PROGRESS") {
56685
+ console.log("Previous stack is still being deleted, waiting...");
56686
+ await cf.waitForStack(stackName, "stack-delete-complete");
56687
+ stackExists = false;
56688
+ } else if (stackStatus === "DELETE_COMPLETE") {
56689
+ stackExists = false;
56690
+ } else {
56691
+ stackExists = true;
56692
+ const outputs2 = stack.Outputs || [];
56693
+ existingBucketName = outputs2.find((o) => o.OutputKey === "BucketName")?.OutputValue;
56694
+ }
56695
+ }
56696
+ } catch (err) {
56697
+ if (err.message?.includes("does not exist") || err.code === "ValidationError") {
56698
+ stackExists = false;
56699
+ } else {
56700
+ throw err;
56701
+ }
56702
+ }
56703
+ let finalBucket = existingBucketName || bucket;
56704
+ if (!stackExists) {
56705
+ const s32 = new S3Client2(region);
56706
+ const cloudfront2 = new CloudFrontClient;
56707
+ let hasExistingDistribution = false;
56708
+ if (domain) {
56709
+ try {
56710
+ console.log(`Checking for existing CloudFront distributions with alias ${domain}...`);
56711
+ const distributions = await cloudfront2.listDistributions();
56712
+ for (const dist of distributions) {
56103
56713
  let aliases2 = [];
56104
56714
  if (dist.Aliases?.Items) {
56105
56715
  if (Array.isArray(dist.Aliases.Items)) {
@@ -73609,6 +74219,38 @@ class LambdaClient {
73609
74219
  });
73610
74220
  return result;
73611
74221
  }
74222
+ async updateAlias(params) {
74223
+ const { FunctionName, Name, ...rest } = params;
74224
+ return this.client.request({
74225
+ service: "lambda",
74226
+ region: this.region,
74227
+ method: "PUT",
74228
+ path: `/2015-03-31/functions/${encodeURIComponent(FunctionName)}/aliases/${encodeURIComponent(Name)}`,
74229
+ headers: { "Content-Type": "application/json" },
74230
+ body: JSON.stringify(rest)
74231
+ });
74232
+ }
74233
+ async putProvisionedConcurrencyConfig(params) {
74234
+ const { FunctionName, Qualifier, ProvisionedConcurrentExecutions } = params;
74235
+ return this.client.request({
74236
+ service: "lambda",
74237
+ region: this.region,
74238
+ method: "PUT",
74239
+ path: `/2019-09-30/functions/${encodeURIComponent(FunctionName)}/provisioned-concurrency`,
74240
+ queryParams: { Qualifier },
74241
+ headers: { "Content-Type": "application/json" },
74242
+ body: JSON.stringify({ ProvisionedConcurrentExecutions })
74243
+ });
74244
+ }
74245
+ async deleteProvisionedConcurrencyConfig(functionName, qualifier) {
74246
+ await this.client.request({
74247
+ service: "lambda",
74248
+ region: this.region,
74249
+ method: "DELETE",
74250
+ path: `/2019-09-30/functions/${encodeURIComponent(functionName)}/provisioned-concurrency`,
74251
+ queryParams: { Qualifier: qualifier }
74252
+ });
74253
+ }
73612
74254
  async waitForFunctionActive(functionName, maxWaitSeconds = 60) {
73613
74255
  const startTime = Date.now();
73614
74256
  const maxWaitMs = maxWaitSeconds * 1000;
@@ -73732,1860 +74374,1326 @@ class LambdaClient {
73732
74374
  if (params?.Marker)
73733
74375
  queryParams.Marker = params.Marker;
73734
74376
  const result = await this.client.request({
73735
- service: "lambda",
73736
- region: this.region,
73737
- method: "GET",
73738
- path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions`,
73739
- queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
73740
- headers: {
73741
- "Content-Type": "application/json"
73742
- }
73743
- });
73744
- return result;
73745
- }
73746
- async getLayerVersion(layerName, versionNumber) {
73747
- const result = await this.client.request({
73748
- service: "lambda",
73749
- region: this.region,
73750
- method: "GET",
73751
- path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
73752
- headers: {
73753
- "Content-Type": "application/json"
73754
- }
73755
- });
73756
- return result;
73757
- }
73758
- async addLayerVersionPermission(params) {
73759
- const { LayerName, VersionNumber, ...rest } = params;
73760
- const result = await this.client.request({
73761
- service: "lambda",
73762
- region: this.region,
73763
- method: "POST",
73764
- path: `/2018-10-31/layers/${encodeURIComponent(LayerName)}/versions/${VersionNumber}/policy`,
73765
- headers: {
73766
- "Content-Type": "application/json"
73767
- },
73768
- body: JSON.stringify(rest)
73769
- });
73770
- return result;
73771
- }
73772
- async deleteLayerVersion(layerName, versionNumber) {
73773
- await this.client.request({
73774
- service: "lambda",
73775
- region: this.region,
73776
- method: "DELETE",
73777
- path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
73778
- headers: {
73779
- "Content-Type": "application/json"
73780
- }
73781
- });
73782
- }
73783
- }
73784
- // src/aws/cloudwatch-logs.ts
73785
- init_client();
73786
-
73787
- class CloudWatchLogsClient {
73788
- client;
73789
- region;
73790
- constructor(region = "us-east-1", profile) {
73791
- this.region = region;
73792
- this.client = new AWSClient;
73793
- }
73794
- async describeLogStreams(options) {
73795
- const params = {
73796
- logGroupName: options.logGroupName
73797
- };
73798
- if (options.logStreamNamePrefix)
73799
- params.logStreamNamePrefix = options.logStreamNamePrefix;
73800
- if (options.orderBy)
73801
- params.orderBy = options.orderBy;
73802
- if (options.descending !== undefined)
73803
- params.descending = options.descending;
73804
- if (options.limit)
73805
- params.limit = options.limit;
73806
- const result = await this.client.request({
73807
- service: "logs",
73808
- region: this.region,
73809
- method: "POST",
73810
- path: "/",
73811
- headers: {
73812
- "X-Amz-Target": "Logs_20140328.DescribeLogStreams",
73813
- "Content-Type": "application/x-amz-json-1.1"
73814
- },
73815
- body: JSON.stringify(params)
73816
- });
73817
- return result;
73818
- }
73819
- async getLogEvents(options) {
73820
- const params = {
73821
- logGroupName: options.logGroupName,
73822
- logStreamName: options.logStreamName
73823
- };
73824
- if (options.startTime)
73825
- params.startTime = options.startTime;
73826
- if (options.endTime)
73827
- params.endTime = options.endTime;
73828
- if (options.limit)
73829
- params.limit = options.limit;
73830
- if (options.startFromHead !== undefined)
73831
- params.startFromHead = options.startFromHead;
73832
- const result = await this.client.request({
73833
- service: "logs",
73834
- region: this.region,
73835
- method: "POST",
73836
- path: "/",
73837
- headers: {
73838
- "X-Amz-Target": "Logs_20140328.GetLogEvents",
73839
- "Content-Type": "application/x-amz-json-1.1"
73840
- },
73841
- body: JSON.stringify(params)
73842
- });
73843
- return result;
73844
- }
73845
- async describeLogGroups(options) {
73846
- const params = {};
73847
- if (options?.logGroupNamePrefix)
73848
- params.logGroupNamePrefix = options.logGroupNamePrefix;
73849
- if (options?.limit)
73850
- params.limit = options.limit;
73851
- const result = await this.client.request({
73852
- service: "logs",
73853
- region: this.region,
73854
- method: "POST",
73855
- path: "/",
73856
- headers: {
73857
- "X-Amz-Target": "Logs_20140328.DescribeLogGroups",
73858
- "Content-Type": "application/x-amz-json-1.1"
73859
- },
73860
- body: JSON.stringify(params)
73861
- });
73862
- return result;
73863
- }
73864
- async deleteLogGroup(logGroupName) {
73865
- await this.client.request({
73866
- service: "logs",
73867
- region: this.region,
73868
- method: "POST",
73869
- path: "/",
73870
- headers: {
73871
- "X-Amz-Target": "Logs_20140328.DeleteLogGroup",
73872
- "Content-Type": "application/x-amz-json-1.1"
73873
- },
73874
- body: JSON.stringify({ logGroupName })
73875
- });
73876
- }
73877
- async filterLogEvents(options) {
73878
- const params = {
73879
- logGroupName: options.logGroupName
73880
- };
73881
- if (options.logStreamNames)
73882
- params.logStreamNames = options.logStreamNames;
73883
- if (options.startTime)
73884
- params.startTime = options.startTime;
73885
- if (options.endTime)
73886
- params.endTime = options.endTime;
73887
- if (options.filterPattern)
73888
- params.filterPattern = options.filterPattern;
73889
- if (options.limit)
73890
- params.limit = options.limit;
73891
- const result = await this.client.request({
73892
- service: "logs",
73893
- region: this.region,
73894
- method: "POST",
73895
- path: "/",
73896
- headers: {
73897
- "X-Amz-Target": "Logs_20140328.FilterLogEvents",
73898
- "Content-Type": "application/x-amz-json-1.1"
73899
- },
73900
- body: JSON.stringify(params)
73901
- });
73902
- return result;
73903
- }
73904
- }
73905
- // src/aws/connect.ts
73906
- init_client();
73907
-
73908
- class ConnectClient {
73909
- client;
73910
- region;
73911
- constructor(region = "us-east-1") {
73912
- this.region = region;
73913
- this.client = new AWSClient;
73914
- }
73915
- async createInstance(params) {
73916
- const body = {
73917
- InstanceAlias: params.InstanceAlias,
73918
- IdentityManagementType: params.IdentityManagementType || "CONNECT_MANAGED",
73919
- InboundCallsEnabled: params.InboundCallsEnabled ?? true,
73920
- OutboundCallsEnabled: params.OutboundCallsEnabled ?? true
73921
- };
73922
- if (params.DirectoryId)
73923
- body.DirectoryId = params.DirectoryId;
73924
- if (params.ClientToken)
73925
- body.ClientToken = params.ClientToken;
73926
- if (params.Tags)
73927
- body.Tags = params.Tags;
73928
- const result = await this.client.request({
73929
- service: "connect",
73930
- region: this.region,
73931
- method: "PUT",
73932
- path: "/instance",
73933
- headers: {
73934
- "Content-Type": "application/json"
73935
- },
73936
- body: JSON.stringify(body)
73937
- });
73938
- return result;
73939
- }
73940
- async deleteInstance(instanceId) {
73941
- await this.client.request({
73942
- service: "connect",
73943
- region: this.region,
73944
- method: "DELETE",
73945
- path: `/instance/${instanceId}`
73946
- });
73947
- }
73948
- async describeInstance(instanceId) {
73949
- const result = await this.client.request({
73950
- service: "connect",
73951
- region: this.region,
73952
- method: "GET",
73953
- path: `/instance/${instanceId}`
73954
- });
73955
- return result.Instance || result;
73956
- }
73957
- async listInstances(params) {
73958
- const queryParams = {};
73959
- if (params?.MaxResults)
73960
- queryParams.maxResults = String(params.MaxResults);
73961
- if (params?.NextToken)
73962
- queryParams.nextToken = params.NextToken;
73963
- const result = await this.client.request({
73964
- service: "connect",
73965
- region: this.region,
73966
- method: "GET",
73967
- path: "/instance",
73968
- queryParams
73969
- });
73970
- return result;
73971
- }
73972
- async searchAvailablePhoneNumbers(params) {
73973
- const body = {
73974
- TargetArn: params.TargetArn,
73975
- PhoneNumberCountryCode: params.PhoneNumberCountryCode,
73976
- PhoneNumberType: params.PhoneNumberType
73977
- };
73978
- if (params.PhoneNumberPrefix)
73979
- body.PhoneNumberPrefix = params.PhoneNumberPrefix;
73980
- if (params.MaxResults)
73981
- body.MaxResults = params.MaxResults;
73982
- if (params.NextToken)
73983
- body.NextToken = params.NextToken;
73984
- const result = await this.client.request({
73985
- service: "connect",
73986
- region: this.region,
73987
- method: "POST",
73988
- path: "/phone-number/search-available",
73989
- headers: {
73990
- "Content-Type": "application/json"
73991
- },
73992
- body: JSON.stringify(body)
73993
- });
73994
- return result;
73995
- }
73996
- async claimPhoneNumber(params) {
73997
- const body = {
73998
- TargetArn: params.TargetArn,
73999
- PhoneNumber: params.PhoneNumber
74000
- };
74001
- if (params.PhoneNumberDescription)
74002
- body.PhoneNumberDescription = params.PhoneNumberDescription;
74003
- if (params.Tags)
74004
- body.Tags = params.Tags;
74005
- if (params.ClientToken)
74006
- body.ClientToken = params.ClientToken;
74007
- const result = await this.client.request({
74008
- service: "connect",
74009
- region: this.region,
74010
- method: "POST",
74011
- path: "/phone-number/claim",
74012
- headers: {
74013
- "Content-Type": "application/json"
74014
- },
74015
- body: JSON.stringify(body)
74016
- });
74017
- return result;
74018
- }
74019
- async releasePhoneNumber(phoneNumberId, clientToken) {
74020
- const queryParams = {};
74021
- if (clientToken)
74022
- queryParams.clientToken = clientToken;
74023
- await this.client.request({
74024
- service: "connect",
74025
- region: this.region,
74026
- method: "DELETE",
74027
- path: `/phone-number/${phoneNumberId}`,
74028
- queryParams
74029
- });
74030
- }
74031
- async listPhoneNumbers(params) {
74032
- const body = {};
74033
- if (params.TargetArn)
74034
- body.TargetArn = params.TargetArn;
74035
- if (params.InstanceId)
74036
- body.InstanceId = params.InstanceId;
74037
- if (params.PhoneNumberTypes)
74038
- body.PhoneNumberTypes = params.PhoneNumberTypes;
74039
- if (params.PhoneNumberCountryCodes)
74040
- body.PhoneNumberCountryCodes = params.PhoneNumberCountryCodes;
74041
- if (params.MaxResults)
74042
- body.MaxResults = params.MaxResults;
74043
- if (params.NextToken)
74044
- body.NextToken = params.NextToken;
74045
- const result = await this.client.request({
74046
- service: "connect",
74047
- region: this.region,
74048
- method: "POST",
74049
- path: "/phone-number/list",
74050
- headers: {
74051
- "Content-Type": "application/json"
74052
- },
74053
- body: JSON.stringify(body)
74054
- });
74055
- return result;
74056
- }
74057
- async createContactFlow(params) {
74058
- const body = {
74059
- Name: params.Name,
74060
- Type: params.Type,
74061
- Content: params.Content
74062
- };
74063
- if (params.Description)
74064
- body.Description = params.Description;
74065
- if (params.Tags)
74066
- body.Tags = params.Tags;
74067
- const result = await this.client.request({
74068
- service: "connect",
74069
- region: this.region,
74070
- method: "PUT",
74071
- path: `/contact-flows/${params.InstanceId}`,
74072
- headers: {
74073
- "Content-Type": "application/json"
74074
- },
74075
- body: JSON.stringify(body)
74076
- });
74077
- return result;
74078
- }
74079
- async updateContactFlowContent(params) {
74080
- await this.client.request({
74081
- service: "connect",
74082
- region: this.region,
74083
- method: "POST",
74084
- path: `/contact-flows/${params.InstanceId}/${params.ContactFlowId}/content`,
74085
- headers: {
74086
- "Content-Type": "application/json"
74087
- },
74088
- body: JSON.stringify({ Content: params.Content })
74089
- });
74090
- }
74091
- async listContactFlows(params) {
74092
- const queryParams = {};
74093
- if (params.ContactFlowTypes)
74094
- queryParams.contactFlowTypes = params.ContactFlowTypes.join(",");
74095
- if (params.MaxResults)
74096
- queryParams.maxResults = String(params.MaxResults);
74097
- if (params.NextToken)
74098
- queryParams.nextToken = params.NextToken;
74099
- const result = await this.client.request({
74100
- service: "connect",
74377
+ service: "lambda",
74101
74378
  region: this.region,
74102
74379
  method: "GET",
74103
- path: `/contact-flows-summary/${params.InstanceId}`,
74104
- queryParams
74380
+ path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions`,
74381
+ queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
74382
+ headers: {
74383
+ "Content-Type": "application/json"
74384
+ }
74105
74385
  });
74106
74386
  return result;
74107
74387
  }
74108
- async createQueue(params) {
74109
- const body = {
74110
- Name: params.Name,
74111
- HoursOfOperationId: params.HoursOfOperationId
74112
- };
74113
- if (params.Description)
74114
- body.Description = params.Description;
74115
- if (params.MaxContacts)
74116
- body.MaxContacts = params.MaxContacts;
74117
- if (params.OutboundCallerConfig)
74118
- body.OutboundCallerConfig = params.OutboundCallerConfig;
74119
- if (params.Tags)
74120
- body.Tags = params.Tags;
74388
+ async getLayerVersion(layerName, versionNumber) {
74121
74389
  const result = await this.client.request({
74122
- service: "connect",
74390
+ service: "lambda",
74123
74391
  region: this.region,
74124
- method: "PUT",
74125
- path: `/queues/${params.InstanceId}`,
74392
+ method: "GET",
74393
+ path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
74126
74394
  headers: {
74127
74395
  "Content-Type": "application/json"
74128
- },
74129
- body: JSON.stringify(body)
74396
+ }
74130
74397
  });
74131
74398
  return result;
74132
74399
  }
74133
- async createHoursOfOperation(params) {
74134
- const body = {
74135
- Name: params.Name,
74136
- TimeZone: params.TimeZone,
74137
- Config: params.Config
74138
- };
74139
- if (params.Description)
74140
- body.Description = params.Description;
74141
- if (params.Tags)
74142
- body.Tags = params.Tags;
74400
+ async addLayerVersionPermission(params) {
74401
+ const { LayerName, VersionNumber, ...rest } = params;
74143
74402
  const result = await this.client.request({
74144
- service: "connect",
74403
+ service: "lambda",
74145
74404
  region: this.region,
74146
- method: "PUT",
74147
- path: `/hours-of-operations/${params.InstanceId}`,
74405
+ method: "POST",
74406
+ path: `/2018-10-31/layers/${encodeURIComponent(LayerName)}/versions/${VersionNumber}/policy`,
74148
74407
  headers: {
74149
74408
  "Content-Type": "application/json"
74150
74409
  },
74151
- body: JSON.stringify(body)
74410
+ body: JSON.stringify(rest)
74152
74411
  });
74153
74412
  return result;
74154
74413
  }
74155
- async associatePhoneNumberContactFlow(params) {
74414
+ async deleteLayerVersion(layerName, versionNumber) {
74156
74415
  await this.client.request({
74157
- service: "connect",
74416
+ service: "lambda",
74158
74417
  region: this.region,
74159
- method: "PUT",
74160
- path: `/phone-number/${params.PhoneNumberId}/contact-flow`,
74418
+ method: "DELETE",
74419
+ path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
74161
74420
  headers: {
74162
74421
  "Content-Type": "application/json"
74163
- },
74164
- body: JSON.stringify({
74165
- InstanceId: params.InstanceId,
74166
- ContactFlowId: params.ContactFlowId
74167
- })
74422
+ }
74168
74423
  });
74169
74424
  }
74170
- async createRoutingProfile(params) {
74171
- const body = {
74172
- Name: params.Name,
74173
- DefaultOutboundQueueId: params.DefaultOutboundQueueId,
74174
- MediaConcurrencies: params.MediaConcurrencies
74425
+ }
74426
+ // src/aws/cloudwatch-logs.ts
74427
+ init_client();
74428
+
74429
+ class CloudWatchLogsClient {
74430
+ client;
74431
+ region;
74432
+ constructor(region = "us-east-1", profile) {
74433
+ this.region = region;
74434
+ this.client = new AWSClient;
74435
+ }
74436
+ async describeLogStreams(options) {
74437
+ const params = {
74438
+ logGroupName: options.logGroupName
74175
74439
  };
74176
- if (params.Description)
74177
- body.Description = params.Description;
74178
- if (params.QueueConfigs)
74179
- body.QueueConfigs = params.QueueConfigs;
74180
- if (params.Tags)
74181
- body.Tags = params.Tags;
74440
+ if (options.logStreamNamePrefix)
74441
+ params.logStreamNamePrefix = options.logStreamNamePrefix;
74442
+ if (options.orderBy)
74443
+ params.orderBy = options.orderBy;
74444
+ if (options.descending !== undefined)
74445
+ params.descending = options.descending;
74446
+ if (options.limit)
74447
+ params.limit = options.limit;
74182
74448
  const result = await this.client.request({
74183
- service: "connect",
74449
+ service: "logs",
74184
74450
  region: this.region,
74185
- method: "PUT",
74186
- path: `/routing-profiles/${params.InstanceId}`,
74451
+ method: "POST",
74452
+ path: "/",
74187
74453
  headers: {
74188
- "Content-Type": "application/json"
74454
+ "X-Amz-Target": "Logs_20140328.DescribeLogStreams",
74455
+ "Content-Type": "application/x-amz-json-1.1"
74189
74456
  },
74190
- body: JSON.stringify(body)
74457
+ body: JSON.stringify(params)
74191
74458
  });
74192
74459
  return result;
74193
74460
  }
74194
- async instanceExists(instanceAlias) {
74195
- try {
74196
- const result = await this.listInstances({ MaxResults: 100 });
74197
- return result.InstanceSummaryList?.some((instance) => instance.InstanceAlias === instanceAlias) || false;
74198
- } catch {
74199
- return false;
74200
- }
74201
- }
74202
- async startOutboundVoiceContact(params) {
74203
- const body = {
74204
- ContactFlowId: params.ContactFlowId,
74205
- DestinationPhoneNumber: params.DestinationPhoneNumber
74461
+ async getLogEvents(options) {
74462
+ const params = {
74463
+ logGroupName: options.logGroupName,
74464
+ logStreamName: options.logStreamName
74206
74465
  };
74207
- if (params.SourcePhoneNumber)
74208
- body.SourcePhoneNumber = params.SourcePhoneNumber;
74209
- if (params.QueueId)
74210
- body.QueueId = params.QueueId;
74211
- if (params.Attributes)
74212
- body.Attributes = params.Attributes;
74213
- if (params.AnswerMachineDetectionConfig)
74214
- body.AnswerMachineDetectionConfig = params.AnswerMachineDetectionConfig;
74215
- if (params.CampaignId)
74216
- body.CampaignId = params.CampaignId;
74217
- if (params.TrafficType)
74218
- body.TrafficType = params.TrafficType;
74219
- if (params.ClientToken)
74220
- body.ClientToken = params.ClientToken;
74466
+ if (options.startTime)
74467
+ params.startTime = options.startTime;
74468
+ if (options.endTime)
74469
+ params.endTime = options.endTime;
74470
+ if (options.limit)
74471
+ params.limit = options.limit;
74472
+ if (options.startFromHead !== undefined)
74473
+ params.startFromHead = options.startFromHead;
74221
74474
  const result = await this.client.request({
74222
- service: "connect",
74475
+ service: "logs",
74223
74476
  region: this.region,
74224
- method: "PUT",
74225
- path: `/contact/outbound-voice/${params.InstanceId}`,
74477
+ method: "POST",
74478
+ path: "/",
74226
74479
  headers: {
74227
- "Content-Type": "application/json"
74480
+ "X-Amz-Target": "Logs_20140328.GetLogEvents",
74481
+ "Content-Type": "application/x-amz-json-1.1"
74228
74482
  },
74229
- body: JSON.stringify(body)
74483
+ body: JSON.stringify(params)
74230
74484
  });
74231
74485
  return result;
74232
74486
  }
74233
- async makeCall(params) {
74234
- return this.startOutboundVoiceContact({
74235
- InstanceId: params.instanceId,
74236
- ContactFlowId: params.contactFlowId,
74237
- DestinationPhoneNumber: params.to,
74238
- SourcePhoneNumber: params.from,
74239
- Attributes: params.attributes
74240
- });
74241
- }
74242
- async stopContact(params) {
74243
- await this.client.request({
74244
- service: "connect",
74487
+ async describeLogGroups(options) {
74488
+ const params = {};
74489
+ if (options?.logGroupNamePrefix)
74490
+ params.logGroupNamePrefix = options.logGroupNamePrefix;
74491
+ if (options?.limit)
74492
+ params.limit = options.limit;
74493
+ const result = await this.client.request({
74494
+ service: "logs",
74245
74495
  region: this.region,
74246
74496
  method: "POST",
74247
- path: `/contact/stop/${params.InstanceId}/${params.ContactId}`
74497
+ path: "/",
74498
+ headers: {
74499
+ "X-Amz-Target": "Logs_20140328.DescribeLogGroups",
74500
+ "Content-Type": "application/x-amz-json-1.1"
74501
+ },
74502
+ body: JSON.stringify(params)
74248
74503
  });
74504
+ return result;
74249
74505
  }
74250
- async describeContact(params) {
74251
- return this.client.request({
74252
- service: "connect",
74506
+ async deleteLogGroup(logGroupName) {
74507
+ await this.client.request({
74508
+ service: "logs",
74253
74509
  region: this.region,
74254
- method: "GET",
74255
- path: `/contacts/${params.InstanceId}/${params.ContactId}`
74510
+ method: "POST",
74511
+ path: "/",
74512
+ headers: {
74513
+ "X-Amz-Target": "Logs_20140328.DeleteLogGroup",
74514
+ "Content-Type": "application/x-amz-json-1.1"
74515
+ },
74516
+ body: JSON.stringify({ logGroupName })
74256
74517
  });
74257
74518
  }
74258
- async updateContactAttributes(params) {
74259
- await this.client.request({
74260
- service: "connect",
74519
+ async filterLogEvents(options) {
74520
+ const params = {
74521
+ logGroupName: options.logGroupName
74522
+ };
74523
+ if (options.logStreamNames)
74524
+ params.logStreamNames = options.logStreamNames;
74525
+ if (options.startTime)
74526
+ params.startTime = options.startTime;
74527
+ if (options.endTime)
74528
+ params.endTime = options.endTime;
74529
+ if (options.filterPattern)
74530
+ params.filterPattern = options.filterPattern;
74531
+ if (options.limit)
74532
+ params.limit = options.limit;
74533
+ const result = await this.client.request({
74534
+ service: "logs",
74261
74535
  region: this.region,
74262
74536
  method: "POST",
74263
- path: `/contact/attributes/${params.InstanceId}`,
74537
+ path: "/",
74264
74538
  headers: {
74265
- "Content-Type": "application/json"
74539
+ "X-Amz-Target": "Logs_20140328.FilterLogEvents",
74540
+ "Content-Type": "application/x-amz-json-1.1"
74266
74541
  },
74267
- body: JSON.stringify({
74268
- InitialContactId: params.InitialContactId,
74269
- Attributes: params.Attributes
74270
- })
74542
+ body: JSON.stringify(params)
74271
74543
  });
74544
+ return result;
74272
74545
  }
74273
- async createUser(params) {
74546
+ }
74547
+ // src/aws/connect.ts
74548
+ init_client();
74549
+
74550
+ class ConnectClient {
74551
+ client;
74552
+ region;
74553
+ constructor(region = "us-east-1") {
74554
+ this.region = region;
74555
+ this.client = new AWSClient;
74556
+ }
74557
+ async createInstance(params) {
74274
74558
  const body = {
74275
- Username: params.Username,
74276
- PhoneConfig: params.PhoneConfig,
74277
- SecurityProfileIds: params.SecurityProfileIds,
74278
- RoutingProfileId: params.RoutingProfileId
74559
+ InstanceAlias: params.InstanceAlias,
74560
+ IdentityManagementType: params.IdentityManagementType || "CONNECT_MANAGED",
74561
+ InboundCallsEnabled: params.InboundCallsEnabled ?? true,
74562
+ OutboundCallsEnabled: params.OutboundCallsEnabled ?? true
74279
74563
  };
74280
- if (params.Password)
74281
- body.Password = params.Password;
74282
- if (params.IdentityInfo)
74283
- body.IdentityInfo = params.IdentityInfo;
74284
- if (params.DirectoryUserId)
74285
- body.DirectoryUserId = params.DirectoryUserId;
74286
- if (params.HierarchyGroupId)
74287
- body.HierarchyGroupId = params.HierarchyGroupId;
74564
+ if (params.DirectoryId)
74565
+ body.DirectoryId = params.DirectoryId;
74566
+ if (params.ClientToken)
74567
+ body.ClientToken = params.ClientToken;
74288
74568
  if (params.Tags)
74289
74569
  body.Tags = params.Tags;
74290
- return this.client.request({
74570
+ const result = await this.client.request({
74291
74571
  service: "connect",
74292
74572
  region: this.region,
74293
74573
  method: "PUT",
74294
- path: `/users/${params.InstanceId}`,
74574
+ path: "/instance",
74295
74575
  headers: {
74296
74576
  "Content-Type": "application/json"
74297
74577
  },
74298
74578
  body: JSON.stringify(body)
74299
74579
  });
74580
+ return result;
74300
74581
  }
74301
- async deleteUser(params) {
74582
+ async deleteInstance(instanceId) {
74302
74583
  await this.client.request({
74303
74584
  service: "connect",
74304
74585
  region: this.region,
74305
74586
  method: "DELETE",
74306
- path: `/users/${params.InstanceId}/${params.UserId}`
74587
+ path: `/instance/${instanceId}`
74307
74588
  });
74308
74589
  }
74309
- async listUsers(params) {
74310
- const queryParams = {};
74311
- if (params.NextToken)
74312
- queryParams.nextToken = params.NextToken;
74313
- if (params.MaxResults)
74314
- queryParams.maxResults = String(params.MaxResults);
74315
- return this.client.request({
74590
+ async describeInstance(instanceId) {
74591
+ const result = await this.client.request({
74316
74592
  service: "connect",
74317
74593
  region: this.region,
74318
74594
  method: "GET",
74319
- path: `/users-summary/${params.InstanceId}`,
74320
- queryParams
74321
- });
74322
- }
74323
- async createPrompt(params) {
74324
- const body = {
74325
- Name: params.Name,
74326
- S3Uri: params.S3Uri
74327
- };
74328
- if (params.Description)
74329
- body.Description = params.Description;
74330
- if (params.Tags)
74331
- body.Tags = params.Tags;
74332
- return this.client.request({
74333
- service: "connect",
74334
- region: this.region,
74335
- method: "PUT",
74336
- path: `/prompts/${params.InstanceId}`,
74337
- headers: {
74338
- "Content-Type": "application/json"
74339
- },
74340
- body: JSON.stringify(body)
74595
+ path: `/instance/${instanceId}`
74341
74596
  });
74597
+ return result.Instance || result;
74342
74598
  }
74343
- async listPrompts(params) {
74599
+ async listInstances(params) {
74344
74600
  const queryParams = {};
74345
- if (params.NextToken)
74346
- queryParams.nextToken = params.NextToken;
74347
- if (params.MaxResults)
74601
+ if (params?.MaxResults)
74348
74602
  queryParams.maxResults = String(params.MaxResults);
74349
- return this.client.request({
74603
+ if (params?.NextToken)
74604
+ queryParams.nextToken = params.NextToken;
74605
+ const result = await this.client.request({
74350
74606
  service: "connect",
74351
74607
  region: this.region,
74352
74608
  method: "GET",
74353
- path: `/prompts-summary/${params.InstanceId}`,
74609
+ path: "/instance",
74354
74610
  queryParams
74355
74611
  });
74612
+ return result;
74356
74613
  }
74357
- async createQuickConnect(params) {
74614
+ async searchAvailablePhoneNumbers(params) {
74358
74615
  const body = {
74359
- Name: params.Name,
74360
- QuickConnectConfig: params.QuickConnectConfig
74616
+ TargetArn: params.TargetArn,
74617
+ PhoneNumberCountryCode: params.PhoneNumberCountryCode,
74618
+ PhoneNumberType: params.PhoneNumberType
74361
74619
  };
74362
- if (params.Description)
74363
- body.Description = params.Description;
74364
- if (params.Tags)
74365
- body.Tags = params.Tags;
74366
- return this.client.request({
74367
- service: "connect",
74368
- region: this.region,
74369
- method: "PUT",
74370
- path: `/quick-connects/${params.InstanceId}`,
74371
- headers: {
74372
- "Content-Type": "application/json"
74373
- },
74374
- body: JSON.stringify(body)
74375
- });
74376
- }
74377
- async startChatContact(params) {
74378
- return this.client.request({
74379
- service: "connect",
74380
- region: this.region,
74381
- method: "PUT",
74382
- path: `/contact/chat/${params.InstanceId}`,
74383
- headers: {
74384
- "Content-Type": "application/json"
74385
- },
74386
- body: JSON.stringify(params)
74387
- });
74388
- }
74389
- async startTaskContact(params) {
74390
- return this.client.request({
74391
- service: "connect",
74392
- region: this.region,
74393
- method: "PUT",
74394
- path: `/contact/task/${params.InstanceId}`,
74395
- headers: {
74396
- "Content-Type": "application/json"
74397
- },
74398
- body: JSON.stringify(params)
74399
- });
74400
- }
74401
- createOutboundIvrFlow(params) {
74402
- const voiceId = params.voiceId || "Joanna";
74403
- return JSON.stringify({
74404
- Version: "2019-10-30",
74405
- StartAction: "play-prompt",
74406
- Actions: {
74407
- "play-prompt": {
74408
- Type: "MessageParticipant",
74409
- Parameters: {
74410
- Text: params.message,
74411
- TextToSpeechVoice: voiceId,
74412
- TextToSpeechEngine: "neural"
74413
- },
74414
- Transitions: {
74415
- NextAction: "disconnect",
74416
- Errors: [
74417
- { NextAction: "disconnect", ErrorType: "NoMatchingError" }
74418
- ]
74419
- }
74420
- },
74421
- disconnect: {
74422
- Type: "DisconnectParticipant",
74423
- Parameters: {},
74424
- Transitions: {}
74425
- }
74426
- }
74427
- });
74428
- }
74429
- createInputCollectionFlow(params) {
74430
- const voiceId = params.voiceId || "Joanna";
74431
- const timeout = params.inputTimeout || 5;
74432
- const maxDigits = params.maxDigits || 1;
74433
- return JSON.stringify({
74434
- Version: "2019-10-30",
74435
- StartAction: "get-input",
74436
- Actions: {
74437
- "get-input": {
74438
- Type: "GetParticipantInput",
74439
- Parameters: {
74440
- Text: params.promptMessage,
74441
- TextToSpeechVoice: voiceId,
74442
- TextToSpeechEngine: "neural",
74443
- InputTimeLimitSeconds: String(timeout),
74444
- MaxDigits: maxDigits,
74445
- EncryptEntry: false
74446
- },
74447
- Transitions: {
74448
- NextAction: params.successNextAction || "disconnect",
74449
- Conditions: [],
74450
- Errors: [
74451
- { NextAction: "disconnect", ErrorType: "NoMatchingCondition" },
74452
- { NextAction: "disconnect", ErrorType: "NoMatchingError" }
74453
- ]
74454
- }
74455
- },
74456
- disconnect: {
74457
- Type: "DisconnectParticipant",
74458
- Parameters: {},
74459
- Transitions: {}
74460
- }
74461
- }
74462
- });
74463
- }
74464
- async getCurrentMetricData(params) {
74465
- return this.client.request({
74466
- service: "connect",
74467
- region: this.region,
74468
- method: "POST",
74469
- path: `/metrics/current/${params.InstanceId}`,
74470
- headers: {
74471
- "Content-Type": "application/json"
74472
- },
74473
- body: JSON.stringify(params)
74474
- });
74475
- }
74476
- }
74477
- // src/aws/elbv2.ts
74478
- init_client();
74479
-
74480
- class ELBv2Client {
74481
- client;
74482
- region;
74483
- constructor(region = "us-east-1") {
74484
- this.region = region;
74485
- this.client = new AWSClient;
74486
- }
74487
- async describeLoadBalancers(options) {
74488
- const params = {};
74489
- if (options?.LoadBalancerArns) {
74490
- options.LoadBalancerArns.forEach((arn, index) => {
74491
- params[`LoadBalancerArns.member.${index + 1}`] = arn;
74492
- });
74493
- }
74494
- if (options?.Names) {
74495
- options.Names.forEach((name, index) => {
74496
- params[`Names.member.${index + 1}`] = name;
74497
- });
74498
- }
74499
- if (options?.Marker) {
74500
- params.Marker = options.Marker;
74501
- }
74502
- if (options?.PageSize) {
74503
- params.PageSize = options.PageSize;
74504
- }
74505
- const result = await this.client.request({
74506
- service: "elasticloadbalancing",
74507
- region: this.region,
74508
- method: "POST",
74509
- path: "/",
74510
- headers: {
74511
- "Content-Type": "application/x-www-form-urlencoded"
74512
- },
74513
- body: this.buildFormBody("DescribeLoadBalancers", params)
74514
- });
74515
- return this.normalizeResult(result, "DescribeLoadBalancersResult");
74516
- }
74517
- async describeTargetGroups(options) {
74518
- const params = {};
74519
- if (options?.LoadBalancerArn) {
74520
- params.LoadBalancerArn = options.LoadBalancerArn;
74521
- }
74522
- if (options?.TargetGroupArns) {
74523
- options.TargetGroupArns.forEach((arn, index) => {
74524
- params[`TargetGroupArns.member.${index + 1}`] = arn;
74525
- });
74526
- }
74527
- if (options?.Names) {
74528
- options.Names.forEach((name, index) => {
74529
- params[`Names.member.${index + 1}`] = name;
74530
- });
74531
- }
74532
- if (options?.Marker) {
74533
- params.Marker = options.Marker;
74534
- }
74535
- if (options?.PageSize) {
74536
- params.PageSize = options.PageSize;
74537
- }
74620
+ if (params.PhoneNumberPrefix)
74621
+ body.PhoneNumberPrefix = params.PhoneNumberPrefix;
74622
+ if (params.MaxResults)
74623
+ body.MaxResults = params.MaxResults;
74624
+ if (params.NextToken)
74625
+ body.NextToken = params.NextToken;
74538
74626
  const result = await this.client.request({
74539
- service: "elasticloadbalancing",
74627
+ service: "connect",
74540
74628
  region: this.region,
74541
74629
  method: "POST",
74542
- path: "/",
74630
+ path: "/phone-number/search-available",
74543
74631
  headers: {
74544
- "Content-Type": "application/x-www-form-urlencoded"
74632
+ "Content-Type": "application/json"
74545
74633
  },
74546
- body: this.buildFormBody("DescribeTargetGroups", params)
74634
+ body: JSON.stringify(body)
74547
74635
  });
74548
- return this.normalizeResult(result, "DescribeTargetGroupsResult");
74636
+ return result;
74549
74637
  }
74550
- async describeTargetHealth(options) {
74551
- const params = {
74552
- TargetGroupArn: options.TargetGroupArn
74638
+ async claimPhoneNumber(params) {
74639
+ const body = {
74640
+ TargetArn: params.TargetArn,
74641
+ PhoneNumber: params.PhoneNumber
74553
74642
  };
74554
- if (options.Targets) {
74555
- options.Targets.forEach((target, index) => {
74556
- params[`Targets.member.${index + 1}.Id`] = target.Id;
74557
- if (target.Port) {
74558
- params[`Targets.member.${index + 1}.Port`] = target.Port;
74559
- }
74560
- if (target.AvailabilityZone) {
74561
- params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
74562
- }
74563
- });
74564
- }
74643
+ if (params.PhoneNumberDescription)
74644
+ body.PhoneNumberDescription = params.PhoneNumberDescription;
74645
+ if (params.Tags)
74646
+ body.Tags = params.Tags;
74647
+ if (params.ClientToken)
74648
+ body.ClientToken = params.ClientToken;
74565
74649
  const result = await this.client.request({
74566
- service: "elasticloadbalancing",
74650
+ service: "connect",
74567
74651
  region: this.region,
74568
74652
  method: "POST",
74569
- path: "/",
74653
+ path: "/phone-number/claim",
74570
74654
  headers: {
74571
- "Content-Type": "application/x-www-form-urlencoded"
74655
+ "Content-Type": "application/json"
74572
74656
  },
74573
- body: this.buildFormBody("DescribeTargetHealth", params)
74657
+ body: JSON.stringify(body)
74574
74658
  });
74575
- return this.normalizeResult(result, "DescribeTargetHealthResult");
74659
+ return result;
74576
74660
  }
74577
- async describeListeners(options) {
74578
- const params = {};
74579
- if (options?.LoadBalancerArn) {
74580
- params.LoadBalancerArn = options.LoadBalancerArn;
74581
- }
74582
- if (options?.ListenerArns) {
74583
- options.ListenerArns.forEach((arn, index) => {
74584
- params[`ListenerArns.member.${index + 1}`] = arn;
74585
- });
74586
- }
74587
- if (options?.Marker) {
74588
- params.Marker = options.Marker;
74589
- }
74590
- if (options?.PageSize) {
74591
- params.PageSize = options.PageSize;
74592
- }
74661
+ async releasePhoneNumber(phoneNumberId, clientToken) {
74662
+ const queryParams = {};
74663
+ if (clientToken)
74664
+ queryParams.clientToken = clientToken;
74665
+ await this.client.request({
74666
+ service: "connect",
74667
+ region: this.region,
74668
+ method: "DELETE",
74669
+ path: `/phone-number/${phoneNumberId}`,
74670
+ queryParams
74671
+ });
74672
+ }
74673
+ async listPhoneNumbers(params) {
74674
+ const body = {};
74675
+ if (params.TargetArn)
74676
+ body.TargetArn = params.TargetArn;
74677
+ if (params.InstanceId)
74678
+ body.InstanceId = params.InstanceId;
74679
+ if (params.PhoneNumberTypes)
74680
+ body.PhoneNumberTypes = params.PhoneNumberTypes;
74681
+ if (params.PhoneNumberCountryCodes)
74682
+ body.PhoneNumberCountryCodes = params.PhoneNumberCountryCodes;
74683
+ if (params.MaxResults)
74684
+ body.MaxResults = params.MaxResults;
74685
+ if (params.NextToken)
74686
+ body.NextToken = params.NextToken;
74593
74687
  const result = await this.client.request({
74594
- service: "elasticloadbalancing",
74688
+ service: "connect",
74595
74689
  region: this.region,
74596
74690
  method: "POST",
74597
- path: "/",
74691
+ path: "/phone-number/list",
74598
74692
  headers: {
74599
- "Content-Type": "application/x-www-form-urlencoded"
74693
+ "Content-Type": "application/json"
74600
74694
  },
74601
- body: this.buildFormBody("DescribeListeners", params)
74695
+ body: JSON.stringify(body)
74602
74696
  });
74603
- return this.normalizeResult(result, "DescribeListenersResult");
74697
+ return result;
74604
74698
  }
74605
- async describeRules(options) {
74606
- const params = {};
74607
- if (options?.ListenerArn) {
74608
- params.ListenerArn = options.ListenerArn;
74609
- }
74610
- if (options?.RuleArns) {
74611
- options.RuleArns.forEach((arn, index) => {
74612
- params[`RuleArns.member.${index + 1}`] = arn;
74613
- });
74614
- }
74615
- if (options?.Marker) {
74616
- params.Marker = options.Marker;
74617
- }
74618
- if (options?.PageSize) {
74619
- params.PageSize = options.PageSize;
74620
- }
74699
+ async createContactFlow(params) {
74700
+ const body = {
74701
+ Name: params.Name,
74702
+ Type: params.Type,
74703
+ Content: params.Content
74704
+ };
74705
+ if (params.Description)
74706
+ body.Description = params.Description;
74707
+ if (params.Tags)
74708
+ body.Tags = params.Tags;
74621
74709
  const result = await this.client.request({
74622
- service: "elasticloadbalancing",
74710
+ service: "connect",
74623
74711
  region: this.region,
74624
- method: "POST",
74625
- path: "/",
74712
+ method: "PUT",
74713
+ path: `/contact-flows/${params.InstanceId}`,
74626
74714
  headers: {
74627
- "Content-Type": "application/x-www-form-urlencoded"
74715
+ "Content-Type": "application/json"
74628
74716
  },
74629
- body: this.buildFormBody("DescribeRules", params)
74717
+ body: JSON.stringify(body)
74630
74718
  });
74631
- return this.normalizeResult(result, "DescribeRulesResult");
74719
+ return result;
74632
74720
  }
74633
- async describeLoadBalancerAttributes(loadBalancerArn) {
74634
- const params = {
74635
- LoadBalancerArn: loadBalancerArn
74636
- };
74637
- const result = await this.client.request({
74638
- service: "elasticloadbalancing",
74721
+ async updateContactFlowContent(params) {
74722
+ await this.client.request({
74723
+ service: "connect",
74639
74724
  region: this.region,
74640
74725
  method: "POST",
74641
- path: "/",
74726
+ path: `/contact-flows/${params.InstanceId}/${params.ContactFlowId}/content`,
74642
74727
  headers: {
74643
- "Content-Type": "application/x-www-form-urlencoded"
74728
+ "Content-Type": "application/json"
74644
74729
  },
74645
- body: this.buildFormBody("DescribeLoadBalancerAttributes", params)
74730
+ body: JSON.stringify({ Content: params.Content })
74646
74731
  });
74647
- return this.normalizeResult(result, "DescribeLoadBalancerAttributesResult");
74648
74732
  }
74649
- async describeTargetGroupAttributes(targetGroupArn) {
74650
- const params = {
74651
- TargetGroupArn: targetGroupArn
74733
+ async listContactFlows(params) {
74734
+ const queryParams = {};
74735
+ if (params.ContactFlowTypes)
74736
+ queryParams.contactFlowTypes = params.ContactFlowTypes.join(",");
74737
+ if (params.MaxResults)
74738
+ queryParams.maxResults = String(params.MaxResults);
74739
+ if (params.NextToken)
74740
+ queryParams.nextToken = params.NextToken;
74741
+ const result = await this.client.request({
74742
+ service: "connect",
74743
+ region: this.region,
74744
+ method: "GET",
74745
+ path: `/contact-flows-summary/${params.InstanceId}`,
74746
+ queryParams
74747
+ });
74748
+ return result;
74749
+ }
74750
+ async createQueue(params) {
74751
+ const body = {
74752
+ Name: params.Name,
74753
+ HoursOfOperationId: params.HoursOfOperationId
74652
74754
  };
74755
+ if (params.Description)
74756
+ body.Description = params.Description;
74757
+ if (params.MaxContacts)
74758
+ body.MaxContacts = params.MaxContacts;
74759
+ if (params.OutboundCallerConfig)
74760
+ body.OutboundCallerConfig = params.OutboundCallerConfig;
74761
+ if (params.Tags)
74762
+ body.Tags = params.Tags;
74653
74763
  const result = await this.client.request({
74654
- service: "elasticloadbalancing",
74764
+ service: "connect",
74655
74765
  region: this.region,
74656
- method: "POST",
74657
- path: "/",
74766
+ method: "PUT",
74767
+ path: `/queues/${params.InstanceId}`,
74658
74768
  headers: {
74659
- "Content-Type": "application/x-www-form-urlencoded"
74769
+ "Content-Type": "application/json"
74660
74770
  },
74661
- body: this.buildFormBody("DescribeTargetGroupAttributes", params)
74771
+ body: JSON.stringify(body)
74662
74772
  });
74663
- return this.normalizeResult(result, "DescribeTargetGroupAttributesResult");
74773
+ return result;
74664
74774
  }
74665
- async createLoadBalancer(options) {
74666
- const params = {
74667
- Name: options.Name
74775
+ async createHoursOfOperation(params) {
74776
+ const body = {
74777
+ Name: params.Name,
74778
+ TimeZone: params.TimeZone,
74779
+ Config: params.Config
74668
74780
  };
74669
- if (options.Subnets) {
74670
- options.Subnets.forEach((subnet, index) => {
74671
- params[`Subnets.member.${index + 1}`] = subnet;
74672
- });
74673
- }
74674
- if (options.SubnetMappings) {
74675
- options.SubnetMappings.forEach((mapping, index) => {
74676
- params[`SubnetMappings.member.${index + 1}.SubnetId`] = mapping.SubnetId;
74677
- if (mapping.AllocationId) {
74678
- params[`SubnetMappings.member.${index + 1}.AllocationId`] = mapping.AllocationId;
74679
- }
74680
- if (mapping.PrivateIPv4Address) {
74681
- params[`SubnetMappings.member.${index + 1}.PrivateIPv4Address`] = mapping.PrivateIPv4Address;
74682
- }
74683
- if (mapping.IPv6Address) {
74684
- params[`SubnetMappings.member.${index + 1}.IPv6Address`] = mapping.IPv6Address;
74685
- }
74686
- });
74687
- }
74688
- if (options.SecurityGroups) {
74689
- options.SecurityGroups.forEach((sg, index) => {
74690
- params[`SecurityGroups.member.${index + 1}`] = sg;
74691
- });
74692
- }
74693
- if (options.Scheme) {
74694
- params.Scheme = options.Scheme;
74695
- }
74696
- if (options.Type) {
74697
- params.Type = options.Type;
74698
- }
74699
- if (options.IpAddressType) {
74700
- params.IpAddressType = options.IpAddressType;
74701
- }
74702
- if (options.Tags) {
74703
- options.Tags.forEach((tag, index) => {
74704
- params[`Tags.member.${index + 1}.Key`] = tag.Key;
74705
- params[`Tags.member.${index + 1}.Value`] = tag.Value;
74706
- });
74707
- }
74781
+ if (params.Description)
74782
+ body.Description = params.Description;
74783
+ if (params.Tags)
74784
+ body.Tags = params.Tags;
74708
74785
  const result = await this.client.request({
74709
- service: "elasticloadbalancing",
74786
+ service: "connect",
74710
74787
  region: this.region,
74711
- method: "POST",
74712
- path: "/",
74788
+ method: "PUT",
74789
+ path: `/hours-of-operations/${params.InstanceId}`,
74713
74790
  headers: {
74714
- "Content-Type": "application/x-www-form-urlencoded"
74791
+ "Content-Type": "application/json"
74715
74792
  },
74716
- body: this.buildFormBody("CreateLoadBalancer", params)
74793
+ body: JSON.stringify(body)
74717
74794
  });
74718
- return this.normalizeResult(result, "CreateLoadBalancerResult");
74795
+ return result;
74719
74796
  }
74720
- async deleteLoadBalancer(loadBalancerArn) {
74721
- const params = {
74722
- LoadBalancerArn: loadBalancerArn
74723
- };
74797
+ async associatePhoneNumberContactFlow(params) {
74724
74798
  await this.client.request({
74725
- service: "elasticloadbalancing",
74799
+ service: "connect",
74726
74800
  region: this.region,
74727
- method: "POST",
74728
- path: "/",
74801
+ method: "PUT",
74802
+ path: `/phone-number/${params.PhoneNumberId}/contact-flow`,
74729
74803
  headers: {
74730
- "Content-Type": "application/x-www-form-urlencoded"
74804
+ "Content-Type": "application/json"
74731
74805
  },
74732
- body: this.buildFormBody("DeleteLoadBalancer", params)
74806
+ body: JSON.stringify({
74807
+ InstanceId: params.InstanceId,
74808
+ ContactFlowId: params.ContactFlowId
74809
+ })
74733
74810
  });
74734
74811
  }
74735
- async createTargetGroup(options) {
74736
- const params = {
74737
- Name: options.Name
74812
+ async createRoutingProfile(params) {
74813
+ const body = {
74814
+ Name: params.Name,
74815
+ DefaultOutboundQueueId: params.DefaultOutboundQueueId,
74816
+ MediaConcurrencies: params.MediaConcurrencies
74738
74817
  };
74739
- if (options.Protocol)
74740
- params.Protocol = options.Protocol;
74741
- if (options.ProtocolVersion)
74742
- params.ProtocolVersion = options.ProtocolVersion;
74743
- if (options.Port)
74744
- params.Port = options.Port;
74745
- if (options.VpcId)
74746
- params.VpcId = options.VpcId;
74747
- if (options.HealthCheckProtocol)
74748
- params.HealthCheckProtocol = options.HealthCheckProtocol;
74749
- if (options.HealthCheckPort)
74750
- params.HealthCheckPort = options.HealthCheckPort;
74751
- if (options.HealthCheckEnabled !== undefined)
74752
- params.HealthCheckEnabled = options.HealthCheckEnabled;
74753
- if (options.HealthCheckPath)
74754
- params.HealthCheckPath = options.HealthCheckPath;
74755
- if (options.HealthCheckIntervalSeconds)
74756
- params.HealthCheckIntervalSeconds = options.HealthCheckIntervalSeconds;
74757
- if (options.HealthCheckTimeoutSeconds)
74758
- params.HealthCheckTimeoutSeconds = options.HealthCheckTimeoutSeconds;
74759
- if (options.HealthyThresholdCount)
74760
- params.HealthyThresholdCount = options.HealthyThresholdCount;
74761
- if (options.UnhealthyThresholdCount)
74762
- params.UnhealthyThresholdCount = options.UnhealthyThresholdCount;
74763
- if (options.TargetType)
74764
- params.TargetType = options.TargetType;
74765
- if (options.IpAddressType)
74766
- params.IpAddressType = options.IpAddressType;
74767
- if (options.Matcher) {
74768
- if (options.Matcher.HttpCode)
74769
- params["Matcher.HttpCode"] = options.Matcher.HttpCode;
74770
- if (options.Matcher.GrpcCode)
74771
- params["Matcher.GrpcCode"] = options.Matcher.GrpcCode;
74772
- }
74773
- if (options.Tags) {
74774
- options.Tags.forEach((tag, index) => {
74775
- params[`Tags.member.${index + 1}.Key`] = tag.Key;
74776
- params[`Tags.member.${index + 1}.Value`] = tag.Value;
74777
- });
74778
- }
74818
+ if (params.Description)
74819
+ body.Description = params.Description;
74820
+ if (params.QueueConfigs)
74821
+ body.QueueConfigs = params.QueueConfigs;
74822
+ if (params.Tags)
74823
+ body.Tags = params.Tags;
74779
74824
  const result = await this.client.request({
74780
- service: "elasticloadbalancing",
74825
+ service: "connect",
74781
74826
  region: this.region,
74782
- method: "POST",
74783
- path: "/",
74827
+ method: "PUT",
74828
+ path: `/routing-profiles/${params.InstanceId}`,
74784
74829
  headers: {
74785
- "Content-Type": "application/x-www-form-urlencoded"
74830
+ "Content-Type": "application/json"
74786
74831
  },
74787
- body: this.buildFormBody("CreateTargetGroup", params)
74832
+ body: JSON.stringify(body)
74788
74833
  });
74789
- return this.normalizeResult(result, "CreateTargetGroupResult");
74834
+ return result;
74790
74835
  }
74791
- async deleteTargetGroup(targetGroupArn) {
74792
- const params = {
74793
- TargetGroupArn: targetGroupArn
74836
+ async instanceExists(instanceAlias) {
74837
+ try {
74838
+ const result = await this.listInstances({ MaxResults: 100 });
74839
+ return result.InstanceSummaryList?.some((instance) => instance.InstanceAlias === instanceAlias) || false;
74840
+ } catch {
74841
+ return false;
74842
+ }
74843
+ }
74844
+ async startOutboundVoiceContact(params) {
74845
+ const body = {
74846
+ ContactFlowId: params.ContactFlowId,
74847
+ DestinationPhoneNumber: params.DestinationPhoneNumber
74794
74848
  };
74795
- await this.client.request({
74796
- service: "elasticloadbalancing",
74849
+ if (params.SourcePhoneNumber)
74850
+ body.SourcePhoneNumber = params.SourcePhoneNumber;
74851
+ if (params.QueueId)
74852
+ body.QueueId = params.QueueId;
74853
+ if (params.Attributes)
74854
+ body.Attributes = params.Attributes;
74855
+ if (params.AnswerMachineDetectionConfig)
74856
+ body.AnswerMachineDetectionConfig = params.AnswerMachineDetectionConfig;
74857
+ if (params.CampaignId)
74858
+ body.CampaignId = params.CampaignId;
74859
+ if (params.TrafficType)
74860
+ body.TrafficType = params.TrafficType;
74861
+ if (params.ClientToken)
74862
+ body.ClientToken = params.ClientToken;
74863
+ const result = await this.client.request({
74864
+ service: "connect",
74797
74865
  region: this.region,
74798
- method: "POST",
74799
- path: "/",
74866
+ method: "PUT",
74867
+ path: `/contact/outbound-voice/${params.InstanceId}`,
74800
74868
  headers: {
74801
- "Content-Type": "application/x-www-form-urlencoded"
74869
+ "Content-Type": "application/json"
74802
74870
  },
74803
- body: this.buildFormBody("DeleteTargetGroup", params)
74871
+ body: JSON.stringify(body)
74804
74872
  });
74873
+ return result;
74805
74874
  }
74806
- async registerTargets(options) {
74807
- const params = {
74808
- TargetGroupArn: options.TargetGroupArn
74809
- };
74810
- options.Targets.forEach((target, index) => {
74811
- params[`Targets.member.${index + 1}.Id`] = target.Id;
74812
- if (target.Port) {
74813
- params[`Targets.member.${index + 1}.Port`] = target.Port;
74814
- }
74815
- if (target.AvailabilityZone) {
74816
- params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
74817
- }
74875
+ async makeCall(params) {
74876
+ return this.startOutboundVoiceContact({
74877
+ InstanceId: params.instanceId,
74878
+ ContactFlowId: params.contactFlowId,
74879
+ DestinationPhoneNumber: params.to,
74880
+ SourcePhoneNumber: params.from,
74881
+ Attributes: params.attributes
74818
74882
  });
74883
+ }
74884
+ async stopContact(params) {
74819
74885
  await this.client.request({
74820
- service: "elasticloadbalancing",
74886
+ service: "connect",
74821
74887
  region: this.region,
74822
74888
  method: "POST",
74823
- path: "/",
74824
- headers: {
74825
- "Content-Type": "application/x-www-form-urlencoded"
74826
- },
74827
- body: this.buildFormBody("RegisterTargets", params)
74889
+ path: `/contact/stop/${params.InstanceId}/${params.ContactId}`
74828
74890
  });
74829
74891
  }
74830
- async deregisterTargets(options) {
74831
- const params = {
74832
- TargetGroupArn: options.TargetGroupArn
74833
- };
74834
- options.Targets.forEach((target, index) => {
74835
- params[`Targets.member.${index + 1}.Id`] = target.Id;
74836
- if (target.Port) {
74837
- params[`Targets.member.${index + 1}.Port`] = target.Port;
74838
- }
74839
- if (target.AvailabilityZone) {
74840
- params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
74841
- }
74892
+ async describeContact(params) {
74893
+ return this.client.request({
74894
+ service: "connect",
74895
+ region: this.region,
74896
+ method: "GET",
74897
+ path: `/contacts/${params.InstanceId}/${params.ContactId}`
74842
74898
  });
74899
+ }
74900
+ async updateContactAttributes(params) {
74843
74901
  await this.client.request({
74844
- service: "elasticloadbalancing",
74902
+ service: "connect",
74845
74903
  region: this.region,
74846
74904
  method: "POST",
74847
- path: "/",
74905
+ path: `/contact/attributes/${params.InstanceId}`,
74848
74906
  headers: {
74849
- "Content-Type": "application/x-www-form-urlencoded"
74907
+ "Content-Type": "application/json"
74850
74908
  },
74851
- body: this.buildFormBody("DeregisterTargets", params)
74909
+ body: JSON.stringify({
74910
+ InitialContactId: params.InitialContactId,
74911
+ Attributes: params.Attributes
74912
+ })
74852
74913
  });
74853
74914
  }
74854
- async createListener(options) {
74855
- const params = {
74856
- LoadBalancerArn: options.LoadBalancerArn,
74857
- Port: options.Port
74915
+ async createUser(params) {
74916
+ const body = {
74917
+ Username: params.Username,
74918
+ PhoneConfig: params.PhoneConfig,
74919
+ SecurityProfileIds: params.SecurityProfileIds,
74920
+ RoutingProfileId: params.RoutingProfileId
74858
74921
  };
74859
- if (options.Protocol)
74860
- params.Protocol = options.Protocol;
74861
- if (options.SslPolicy)
74862
- params.SslPolicy = options.SslPolicy;
74863
- if (options.Certificates) {
74864
- options.Certificates.forEach((cert, index) => {
74865
- params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
74866
- });
74867
- }
74868
- options.DefaultActions.forEach((action, index) => {
74869
- params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
74870
- if (action.TargetGroupArn) {
74871
- params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
74872
- }
74873
- if (action.Order !== undefined) {
74874
- params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
74875
- }
74876
- if (action.RedirectConfig) {
74877
- const rc = action.RedirectConfig;
74878
- if (rc.Protocol)
74879
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Protocol`] = rc.Protocol;
74880
- if (rc.Port)
74881
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Port`] = rc.Port;
74882
- if (rc.Host)
74883
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Host`] = rc.Host;
74884
- if (rc.Path)
74885
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Path`] = rc.Path;
74886
- if (rc.Query)
74887
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Query`] = rc.Query;
74888
- params[`DefaultActions.member.${index + 1}.RedirectConfig.StatusCode`] = rc.StatusCode;
74889
- }
74890
- if (action.FixedResponseConfig) {
74891
- const fr = action.FixedResponseConfig;
74892
- if (fr.MessageBody)
74893
- params[`DefaultActions.member.${index + 1}.FixedResponseConfig.MessageBody`] = fr.MessageBody;
74894
- params[`DefaultActions.member.${index + 1}.FixedResponseConfig.StatusCode`] = fr.StatusCode;
74895
- if (fr.ContentType)
74896
- params[`DefaultActions.member.${index + 1}.FixedResponseConfig.ContentType`] = fr.ContentType;
74897
- }
74898
- });
74899
- if (options.AlpnPolicy) {
74900
- options.AlpnPolicy.forEach((policy, index) => {
74901
- params[`AlpnPolicy.member.${index + 1}`] = policy;
74902
- });
74903
- }
74904
- if (options.Tags) {
74905
- options.Tags.forEach((tag, index) => {
74906
- params[`Tags.member.${index + 1}.Key`] = tag.Key;
74907
- params[`Tags.member.${index + 1}.Value`] = tag.Value;
74908
- });
74909
- }
74910
- const result = await this.client.request({
74911
- service: "elasticloadbalancing",
74922
+ if (params.Password)
74923
+ body.Password = params.Password;
74924
+ if (params.IdentityInfo)
74925
+ body.IdentityInfo = params.IdentityInfo;
74926
+ if (params.DirectoryUserId)
74927
+ body.DirectoryUserId = params.DirectoryUserId;
74928
+ if (params.HierarchyGroupId)
74929
+ body.HierarchyGroupId = params.HierarchyGroupId;
74930
+ if (params.Tags)
74931
+ body.Tags = params.Tags;
74932
+ return this.client.request({
74933
+ service: "connect",
74912
74934
  region: this.region,
74913
- method: "POST",
74914
- path: "/",
74935
+ method: "PUT",
74936
+ path: `/users/${params.InstanceId}`,
74915
74937
  headers: {
74916
- "Content-Type": "application/x-www-form-urlencoded"
74938
+ "Content-Type": "application/json"
74917
74939
  },
74918
- body: this.buildFormBody("CreateListener", params)
74940
+ body: JSON.stringify(body)
74919
74941
  });
74920
- return this.normalizeResult(result, "CreateListenerResult");
74921
74942
  }
74922
- async deleteListener(listenerArn) {
74923
- const params = {
74924
- ListenerArn: listenerArn
74925
- };
74943
+ async deleteUser(params) {
74926
74944
  await this.client.request({
74927
- service: "elasticloadbalancing",
74945
+ service: "connect",
74928
74946
  region: this.region,
74929
- method: "POST",
74930
- path: "/",
74947
+ method: "DELETE",
74948
+ path: `/users/${params.InstanceId}/${params.UserId}`
74949
+ });
74950
+ }
74951
+ async listUsers(params) {
74952
+ const queryParams = {};
74953
+ if (params.NextToken)
74954
+ queryParams.nextToken = params.NextToken;
74955
+ if (params.MaxResults)
74956
+ queryParams.maxResults = String(params.MaxResults);
74957
+ return this.client.request({
74958
+ service: "connect",
74959
+ region: this.region,
74960
+ method: "GET",
74961
+ path: `/users-summary/${params.InstanceId}`,
74962
+ queryParams
74963
+ });
74964
+ }
74965
+ async createPrompt(params) {
74966
+ const body = {
74967
+ Name: params.Name,
74968
+ S3Uri: params.S3Uri
74969
+ };
74970
+ if (params.Description)
74971
+ body.Description = params.Description;
74972
+ if (params.Tags)
74973
+ body.Tags = params.Tags;
74974
+ return this.client.request({
74975
+ service: "connect",
74976
+ region: this.region,
74977
+ method: "PUT",
74978
+ path: `/prompts/${params.InstanceId}`,
74931
74979
  headers: {
74932
- "Content-Type": "application/x-www-form-urlencoded"
74980
+ "Content-Type": "application/json"
74933
74981
  },
74934
- body: this.buildFormBody("DeleteListener", params)
74982
+ body: JSON.stringify(body)
74935
74983
  });
74936
74984
  }
74937
- async modifyListener(options) {
74938
- const params = {
74939
- ListenerArn: options.ListenerArn
74985
+ async listPrompts(params) {
74986
+ const queryParams = {};
74987
+ if (params.NextToken)
74988
+ queryParams.nextToken = params.NextToken;
74989
+ if (params.MaxResults)
74990
+ queryParams.maxResults = String(params.MaxResults);
74991
+ return this.client.request({
74992
+ service: "connect",
74993
+ region: this.region,
74994
+ method: "GET",
74995
+ path: `/prompts-summary/${params.InstanceId}`,
74996
+ queryParams
74997
+ });
74998
+ }
74999
+ async createQuickConnect(params) {
75000
+ const body = {
75001
+ Name: params.Name,
75002
+ QuickConnectConfig: params.QuickConnectConfig
74940
75003
  };
74941
- if (options.Port)
74942
- params.Port = options.Port;
74943
- if (options.Protocol)
74944
- params.Protocol = options.Protocol;
74945
- if (options.SslPolicy)
74946
- params.SslPolicy = options.SslPolicy;
74947
- if (options.Certificates) {
74948
- options.Certificates.forEach((cert, index) => {
74949
- params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
74950
- });
74951
- }
74952
- if (options.DefaultActions) {
74953
- options.DefaultActions.forEach((action, index) => {
74954
- if (action.Type)
74955
- params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
74956
- if (action.TargetGroupArn)
74957
- params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
74958
- if (action.Order !== undefined)
74959
- params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
74960
- });
74961
- }
74962
- if (options.AlpnPolicy) {
74963
- options.AlpnPolicy.forEach((policy, index) => {
74964
- params[`AlpnPolicy.member.${index + 1}`] = policy;
74965
- });
74966
- }
74967
- const result = await this.client.request({
74968
- service: "elasticloadbalancing",
75004
+ if (params.Description)
75005
+ body.Description = params.Description;
75006
+ if (params.Tags)
75007
+ body.Tags = params.Tags;
75008
+ return this.client.request({
75009
+ service: "connect",
74969
75010
  region: this.region,
74970
- method: "POST",
74971
- path: "/",
75011
+ method: "PUT",
75012
+ path: `/quick-connects/${params.InstanceId}`,
74972
75013
  headers: {
74973
- "Content-Type": "application/x-www-form-urlencoded"
75014
+ "Content-Type": "application/json"
74974
75015
  },
74975
- body: this.buildFormBody("ModifyListener", params)
75016
+ body: JSON.stringify(body)
74976
75017
  });
74977
- return this.normalizeResult(result, "ModifyListenerResult");
74978
75018
  }
74979
- buildFormBody(action, params) {
74980
- const formParams = {
74981
- Action: action,
74982
- Version: "2015-12-01"
74983
- };
74984
- for (const [key, value] of Object.entries(params)) {
74985
- if (value !== undefined && value !== null) {
74986
- formParams[key] = String(value);
74987
- }
74988
- }
74989
- return Object.entries(formParams).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
75019
+ async startChatContact(params) {
75020
+ return this.client.request({
75021
+ service: "connect",
75022
+ region: this.region,
75023
+ method: "PUT",
75024
+ path: `/contact/chat/${params.InstanceId}`,
75025
+ headers: {
75026
+ "Content-Type": "application/json"
75027
+ },
75028
+ body: JSON.stringify(params)
75029
+ });
74990
75030
  }
74991
- normalizeResult(parsed, resultKey) {
74992
- if (parsed && parsed[resultKey]) {
74993
- return this.normalizeArrays(parsed[resultKey]);
74994
- }
74995
- const responseKey = resultKey.replace("Result", "Response");
74996
- if (parsed && parsed[responseKey] && parsed[responseKey][resultKey]) {
74997
- return this.normalizeArrays(parsed[responseKey][resultKey]);
74998
- }
74999
- return this.normalizeArrays(parsed);
75031
+ async startTaskContact(params) {
75032
+ return this.client.request({
75033
+ service: "connect",
75034
+ region: this.region,
75035
+ method: "PUT",
75036
+ path: `/contact/task/${params.InstanceId}`,
75037
+ headers: {
75038
+ "Content-Type": "application/json"
75039
+ },
75040
+ body: JSON.stringify(params)
75041
+ });
75000
75042
  }
75001
- normalizeArrays(obj) {
75002
- if (!obj || typeof obj !== "object") {
75003
- return obj;
75004
- }
75005
- if (Array.isArray(obj)) {
75006
- return obj.map((item) => this.normalizeArrays(item));
75007
- }
75008
- const result = {};
75009
- for (const [key, value] of Object.entries(obj)) {
75010
- const arrayFields = [
75011
- "LoadBalancers",
75012
- "TargetGroups",
75013
- "Listeners",
75014
- "Rules",
75015
- "TargetHealthDescriptions",
75016
- "Attributes",
75017
- "SecurityGroups",
75018
- "AvailabilityZones",
75019
- "Certificates",
75020
- "DefaultActions",
75021
- "Conditions",
75022
- "Actions",
75023
- "member"
75024
- ];
75025
- if (key === "member") {
75026
- if (Array.isArray(value)) {
75027
- return value.map((item) => this.normalizeArrays(item));
75043
+ createOutboundIvrFlow(params) {
75044
+ const voiceId = params.voiceId || "Joanna";
75045
+ return JSON.stringify({
75046
+ Version: "2019-10-30",
75047
+ StartAction: "play-prompt",
75048
+ Actions: {
75049
+ "play-prompt": {
75050
+ Type: "MessageParticipant",
75051
+ Parameters: {
75052
+ Text: params.message,
75053
+ TextToSpeechVoice: voiceId,
75054
+ TextToSpeechEngine: "neural"
75055
+ },
75056
+ Transitions: {
75057
+ NextAction: "disconnect",
75058
+ Errors: [
75059
+ { NextAction: "disconnect", ErrorType: "NoMatchingError" }
75060
+ ]
75061
+ }
75062
+ },
75063
+ disconnect: {
75064
+ Type: "DisconnectParticipant",
75065
+ Parameters: {},
75066
+ Transitions: {}
75028
75067
  }
75029
- return [this.normalizeArrays(value)];
75030
75068
  }
75031
- if (arrayFields.includes(key)) {
75032
- if (value && typeof value === "object" && "member" in value) {
75033
- const memberValue = value.member;
75034
- result[key] = Array.isArray(memberValue) ? memberValue.map((item) => this.normalizeArrays(item)) : [this.normalizeArrays(memberValue)];
75035
- } else if (Array.isArray(value)) {
75036
- result[key] = value.map((item) => this.normalizeArrays(item));
75037
- } else if (value) {
75038
- result[key] = [this.normalizeArrays(value)];
75039
- } else {
75040
- result[key] = [];
75069
+ });
75070
+ }
75071
+ createInputCollectionFlow(params) {
75072
+ const voiceId = params.voiceId || "Joanna";
75073
+ const timeout = params.inputTimeout || 5;
75074
+ const maxDigits = params.maxDigits || 1;
75075
+ return JSON.stringify({
75076
+ Version: "2019-10-30",
75077
+ StartAction: "get-input",
75078
+ Actions: {
75079
+ "get-input": {
75080
+ Type: "GetParticipantInput",
75081
+ Parameters: {
75082
+ Text: params.promptMessage,
75083
+ TextToSpeechVoice: voiceId,
75084
+ TextToSpeechEngine: "neural",
75085
+ InputTimeLimitSeconds: String(timeout),
75086
+ MaxDigits: maxDigits,
75087
+ EncryptEntry: false
75088
+ },
75089
+ Transitions: {
75090
+ NextAction: params.successNextAction || "disconnect",
75091
+ Conditions: [],
75092
+ Errors: [
75093
+ { NextAction: "disconnect", ErrorType: "NoMatchingCondition" },
75094
+ { NextAction: "disconnect", ErrorType: "NoMatchingError" }
75095
+ ]
75096
+ }
75097
+ },
75098
+ disconnect: {
75099
+ Type: "DisconnectParticipant",
75100
+ Parameters: {},
75101
+ Transitions: {}
75041
75102
  }
75042
- } else if (typeof value === "object") {
75043
- result[key] = this.normalizeArrays(value);
75044
- } else {
75045
- result[key] = value;
75046
75103
  }
75047
- }
75048
- return result;
75104
+ });
75105
+ }
75106
+ async getCurrentMetricData(params) {
75107
+ return this.client.request({
75108
+ service: "connect",
75109
+ region: this.region,
75110
+ method: "POST",
75111
+ path: `/metrics/current/${params.InstanceId}`,
75112
+ headers: {
75113
+ "Content-Type": "application/json"
75114
+ },
75115
+ body: JSON.stringify(params)
75116
+ });
75049
75117
  }
75050
75118
  }
75051
- // src/aws/rds.ts
75119
+ // src/aws/elbv2.ts
75052
75120
  init_client();
75053
75121
 
75054
- class RDSClient {
75122
+ class ELBv2Client {
75055
75123
  client;
75056
75124
  region;
75057
75125
  constructor(region = "us-east-1") {
75058
75126
  this.region = region;
75059
75127
  this.client = new AWSClient;
75060
75128
  }
75061
- async describeDBInstances(options) {
75062
- const params = {
75063
- Action: "DescribeDBInstances",
75064
- Version: "2014-10-31"
75065
- };
75066
- if (options?.DBInstanceIdentifier) {
75067
- params.DBInstanceIdentifier = options.DBInstanceIdentifier;
75129
+ async describeLoadBalancers(options) {
75130
+ const params = {};
75131
+ if (options?.LoadBalancerArns) {
75132
+ options.LoadBalancerArns.forEach((arn, index) => {
75133
+ params[`LoadBalancerArns.member.${index + 1}`] = arn;
75134
+ });
75068
75135
  }
75069
- if (options?.MaxRecords) {
75070
- params.MaxRecords = options.MaxRecords;
75136
+ if (options?.Names) {
75137
+ options.Names.forEach((name, index) => {
75138
+ params[`Names.member.${index + 1}`] = name;
75139
+ });
75071
75140
  }
75072
75141
  if (options?.Marker) {
75073
75142
  params.Marker = options.Marker;
75074
75143
  }
75075
- if (options?.Filters) {
75076
- options.Filters.forEach((filter, i) => {
75077
- params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
75078
- filter.Values.forEach((value, j) => {
75079
- params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
75080
- });
75081
- });
75144
+ if (options?.PageSize) {
75145
+ params.PageSize = options.PageSize;
75082
75146
  }
75083
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75084
75147
  const result = await this.client.request({
75085
- service: "rds",
75148
+ service: "elasticloadbalancing",
75086
75149
  region: this.region,
75087
75150
  method: "POST",
75088
75151
  path: "/",
75089
75152
  headers: {
75090
75153
  "Content-Type": "application/x-www-form-urlencoded"
75091
75154
  },
75092
- body: queryString
75155
+ body: this.buildFormBody("DescribeLoadBalancers", params)
75093
75156
  });
75094
- const response = result.DescribeDBInstancesResult || result;
75095
- let instances = response.DBInstances?.DBInstance || [];
75096
- if (!Array.isArray(instances)) {
75097
- instances = instances ? [instances] : [];
75098
- }
75099
- return {
75100
- DBInstances: instances,
75101
- Marker: response.Marker
75102
- };
75103
- }
75104
- async describeDBInstance(dbInstanceIdentifier) {
75105
- const result = await this.describeDBInstances({ DBInstanceIdentifier: dbInstanceIdentifier });
75106
- return result.DBInstances?.[0];
75157
+ return this.normalizeResult(result, "DescribeLoadBalancersResult");
75107
75158
  }
75108
- async describeDBClusters(options) {
75109
- const params = {
75110
- Action: "DescribeDBClusters",
75111
- Version: "2014-10-31"
75112
- };
75113
- if (options?.DBClusterIdentifier) {
75114
- params.DBClusterIdentifier = options.DBClusterIdentifier;
75159
+ async describeTargetGroups(options) {
75160
+ const params = {};
75161
+ if (options?.LoadBalancerArn) {
75162
+ params.LoadBalancerArn = options.LoadBalancerArn;
75115
75163
  }
75116
- if (options?.MaxRecords) {
75117
- params.MaxRecords = options.MaxRecords;
75164
+ if (options?.TargetGroupArns) {
75165
+ options.TargetGroupArns.forEach((arn, index) => {
75166
+ params[`TargetGroupArns.member.${index + 1}`] = arn;
75167
+ });
75168
+ }
75169
+ if (options?.Names) {
75170
+ options.Names.forEach((name, index) => {
75171
+ params[`Names.member.${index + 1}`] = name;
75172
+ });
75118
75173
  }
75119
75174
  if (options?.Marker) {
75120
75175
  params.Marker = options.Marker;
75121
75176
  }
75122
- if (options?.Filters) {
75123
- options.Filters.forEach((filter, i) => {
75124
- params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
75125
- filter.Values.forEach((value, j) => {
75126
- params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
75127
- });
75128
- });
75177
+ if (options?.PageSize) {
75178
+ params.PageSize = options.PageSize;
75129
75179
  }
75130
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75131
75180
  const result = await this.client.request({
75132
- service: "rds",
75181
+ service: "elasticloadbalancing",
75133
75182
  region: this.region,
75134
75183
  method: "POST",
75135
75184
  path: "/",
75136
75185
  headers: {
75137
75186
  "Content-Type": "application/x-www-form-urlencoded"
75138
75187
  },
75139
- body: queryString
75188
+ body: this.buildFormBody("DescribeTargetGroups", params)
75140
75189
  });
75141
- const response = result.DescribeDBClustersResult || result;
75142
- let clusters = response.DBClusters?.DBCluster || [];
75143
- if (!Array.isArray(clusters)) {
75144
- clusters = clusters ? [clusters] : [];
75145
- }
75146
- return {
75147
- DBClusters: clusters,
75148
- Marker: response.Marker
75149
- };
75190
+ return this.normalizeResult(result, "DescribeTargetGroupsResult");
75150
75191
  }
75151
- async describeDBSnapshots(options) {
75192
+ async describeTargetHealth(options) {
75152
75193
  const params = {
75153
- Action: "DescribeDBSnapshots",
75154
- Version: "2014-10-31"
75194
+ TargetGroupArn: options.TargetGroupArn
75155
75195
  };
75156
- if (options?.DBInstanceIdentifier) {
75157
- params.DBInstanceIdentifier = options.DBInstanceIdentifier;
75158
- }
75159
- if (options?.DBSnapshotIdentifier) {
75160
- params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
75161
- }
75162
- if (options?.SnapshotType) {
75163
- params.SnapshotType = options.SnapshotType;
75164
- }
75165
- if (options?.MaxRecords) {
75166
- params.MaxRecords = options.MaxRecords;
75167
- }
75168
- if (options?.Marker) {
75169
- params.Marker = options.Marker;
75196
+ if (options.Targets) {
75197
+ options.Targets.forEach((target, index) => {
75198
+ params[`Targets.member.${index + 1}.Id`] = target.Id;
75199
+ if (target.Port) {
75200
+ params[`Targets.member.${index + 1}.Port`] = target.Port;
75201
+ }
75202
+ if (target.AvailabilityZone) {
75203
+ params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
75204
+ }
75205
+ });
75170
75206
  }
75171
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75172
75207
  const result = await this.client.request({
75173
- service: "rds",
75208
+ service: "elasticloadbalancing",
75174
75209
  region: this.region,
75175
75210
  method: "POST",
75176
75211
  path: "/",
75177
75212
  headers: {
75178
75213
  "Content-Type": "application/x-www-form-urlencoded"
75179
75214
  },
75180
- body: queryString
75215
+ body: this.buildFormBody("DescribeTargetHealth", params)
75181
75216
  });
75182
- const response = result.DescribeDBSnapshotsResult || result;
75183
- let snapshots = response.DBSnapshots?.DBSnapshot || [];
75184
- if (!Array.isArray(snapshots)) {
75185
- snapshots = snapshots ? [snapshots] : [];
75186
- }
75187
- return {
75188
- DBSnapshots: snapshots,
75189
- Marker: response.Marker
75190
- };
75217
+ return this.normalizeResult(result, "DescribeTargetHealthResult");
75191
75218
  }
75192
- async describeDBSubnetGroups(options) {
75193
- const params = {
75194
- Action: "DescribeDBSubnetGroups",
75195
- Version: "2014-10-31"
75196
- };
75197
- if (options?.DBSubnetGroupName) {
75198
- params.DBSubnetGroupName = options.DBSubnetGroupName;
75219
+ async describeListeners(options) {
75220
+ const params = {};
75221
+ if (options?.LoadBalancerArn) {
75222
+ params.LoadBalancerArn = options.LoadBalancerArn;
75199
75223
  }
75200
- if (options?.MaxRecords) {
75201
- params.MaxRecords = options.MaxRecords;
75224
+ if (options?.ListenerArns) {
75225
+ options.ListenerArns.forEach((arn, index) => {
75226
+ params[`ListenerArns.member.${index + 1}`] = arn;
75227
+ });
75202
75228
  }
75203
75229
  if (options?.Marker) {
75204
75230
  params.Marker = options.Marker;
75205
75231
  }
75206
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75232
+ if (options?.PageSize) {
75233
+ params.PageSize = options.PageSize;
75234
+ }
75207
75235
  const result = await this.client.request({
75208
- service: "rds",
75236
+ service: "elasticloadbalancing",
75209
75237
  region: this.region,
75210
75238
  method: "POST",
75211
75239
  path: "/",
75212
75240
  headers: {
75213
75241
  "Content-Type": "application/x-www-form-urlencoded"
75214
75242
  },
75215
- body: queryString
75243
+ body: this.buildFormBody("DescribeListeners", params)
75216
75244
  });
75217
- const response = result.DescribeDBSubnetGroupsResult || result;
75218
- let groups = response.DBSubnetGroups?.DBSubnetGroup || [];
75219
- if (!Array.isArray(groups)) {
75220
- groups = groups ? [groups] : [];
75221
- }
75222
- return {
75223
- DBSubnetGroups: groups,
75224
- Marker: response.Marker
75225
- };
75245
+ return this.normalizeResult(result, "DescribeListenersResult");
75226
75246
  }
75227
- async createDBInstance(options) {
75228
- const params = {
75229
- Action: "CreateDBInstance",
75230
- Version: "2014-10-31",
75231
- DBInstanceIdentifier: options.DBInstanceIdentifier,
75232
- DBInstanceClass: options.DBInstanceClass,
75233
- Engine: options.Engine
75234
- };
75235
- if (options.MasterUsername)
75236
- params.MasterUsername = options.MasterUsername;
75237
- if (options.MasterUserPassword)
75238
- params.MasterUserPassword = options.MasterUserPassword;
75239
- if (options.DBName)
75240
- params.DBName = options.DBName;
75241
- if (options.AllocatedStorage)
75242
- params.AllocatedStorage = options.AllocatedStorage;
75243
- if (options.DBSubnetGroupName)
75244
- params.DBSubnetGroupName = options.DBSubnetGroupName;
75245
- if (options.AvailabilityZone)
75246
- params.AvailabilityZone = options.AvailabilityZone;
75247
- if (options.PreferredMaintenanceWindow)
75248
- params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
75249
- if (options.PreferredBackupWindow)
75250
- params.PreferredBackupWindow = options.PreferredBackupWindow;
75251
- if (options.BackupRetentionPeriod !== undefined)
75252
- params.BackupRetentionPeriod = options.BackupRetentionPeriod;
75253
- if (options.MultiAZ !== undefined)
75254
- params.MultiAZ = options.MultiAZ;
75255
- if (options.EngineVersion)
75256
- params.EngineVersion = options.EngineVersion;
75257
- if (options.AutoMinorVersionUpgrade !== undefined)
75258
- params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
75259
- if (options.LicenseModel)
75260
- params.LicenseModel = options.LicenseModel;
75261
- if (options.PubliclyAccessible !== undefined)
75262
- params.PubliclyAccessible = options.PubliclyAccessible;
75263
- if (options.StorageType)
75264
- params.StorageType = options.StorageType;
75265
- if (options.StorageEncrypted !== undefined)
75266
- params.StorageEncrypted = options.StorageEncrypted;
75267
- if (options.KmsKeyId)
75268
- params.KmsKeyId = options.KmsKeyId;
75269
- if (options.DeletionProtection !== undefined)
75270
- params.DeletionProtection = options.DeletionProtection;
75271
- if (options.VpcSecurityGroupIds) {
75272
- options.VpcSecurityGroupIds.forEach((id, i) => {
75273
- params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
75274
- });
75247
+ async describeRules(options) {
75248
+ const params = {};
75249
+ if (options?.ListenerArn) {
75250
+ params.ListenerArn = options.ListenerArn;
75275
75251
  }
75276
- if (options.Tags) {
75277
- options.Tags.forEach((tag, i) => {
75278
- params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
75279
- params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
75252
+ if (options?.RuleArns) {
75253
+ options.RuleArns.forEach((arn, index) => {
75254
+ params[`RuleArns.member.${index + 1}`] = arn;
75280
75255
  });
75281
75256
  }
75282
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75257
+ if (options?.Marker) {
75258
+ params.Marker = options.Marker;
75259
+ }
75260
+ if (options?.PageSize) {
75261
+ params.PageSize = options.PageSize;
75262
+ }
75283
75263
  const result = await this.client.request({
75284
- service: "rds",
75264
+ service: "elasticloadbalancing",
75285
75265
  region: this.region,
75286
75266
  method: "POST",
75287
75267
  path: "/",
75288
75268
  headers: {
75289
75269
  "Content-Type": "application/x-www-form-urlencoded"
75290
75270
  },
75291
- body: queryString
75271
+ body: this.buildFormBody("DescribeRules", params)
75292
75272
  });
75293
- const response = result.CreateDBInstanceResult || result;
75294
- return {
75295
- DBInstance: response.DBInstance
75296
- };
75273
+ return this.normalizeResult(result, "DescribeRulesResult");
75297
75274
  }
75298
- async deleteDBInstance(options) {
75275
+ async describeLoadBalancerAttributes(loadBalancerArn) {
75299
75276
  const params = {
75300
- Action: "DeleteDBInstance",
75301
- Version: "2014-10-31",
75302
- DBInstanceIdentifier: options.DBInstanceIdentifier
75277
+ LoadBalancerArn: loadBalancerArn
75303
75278
  };
75304
- if (options.SkipFinalSnapshot !== undefined) {
75305
- params.SkipFinalSnapshot = options.SkipFinalSnapshot;
75306
- }
75307
- if (options.FinalDBSnapshotIdentifier) {
75308
- params.FinalDBSnapshotIdentifier = options.FinalDBSnapshotIdentifier;
75309
- }
75310
- if (options.DeleteAutomatedBackups !== undefined) {
75311
- params.DeleteAutomatedBackups = options.DeleteAutomatedBackups;
75312
- }
75313
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75314
75279
  const result = await this.client.request({
75315
- service: "rds",
75280
+ service: "elasticloadbalancing",
75316
75281
  region: this.region,
75317
75282
  method: "POST",
75318
75283
  path: "/",
75319
75284
  headers: {
75320
75285
  "Content-Type": "application/x-www-form-urlencoded"
75321
75286
  },
75322
- body: queryString
75287
+ body: this.buildFormBody("DescribeLoadBalancerAttributes", params)
75323
75288
  });
75324
- const response = result.DeleteDBInstanceResult || result;
75325
- return {
75326
- DBInstance: response.DBInstance
75289
+ return this.normalizeResult(result, "DescribeLoadBalancerAttributesResult");
75290
+ }
75291
+ async describeTargetGroupAttributes(targetGroupArn) {
75292
+ const params = {
75293
+ TargetGroupArn: targetGroupArn
75327
75294
  };
75295
+ const result = await this.client.request({
75296
+ service: "elasticloadbalancing",
75297
+ region: this.region,
75298
+ method: "POST",
75299
+ path: "/",
75300
+ headers: {
75301
+ "Content-Type": "application/x-www-form-urlencoded"
75302
+ },
75303
+ body: this.buildFormBody("DescribeTargetGroupAttributes", params)
75304
+ });
75305
+ return this.normalizeResult(result, "DescribeTargetGroupAttributesResult");
75328
75306
  }
75329
- async modifyDBInstance(options) {
75307
+ async createLoadBalancer(options) {
75330
75308
  const params = {
75331
- Action: "ModifyDBInstance",
75332
- Version: "2014-10-31",
75333
- DBInstanceIdentifier: options.DBInstanceIdentifier
75309
+ Name: options.Name
75334
75310
  };
75335
- if (options.DBInstanceClass)
75336
- params.DBInstanceClass = options.DBInstanceClass;
75337
- if (options.AllocatedStorage)
75338
- params.AllocatedStorage = options.AllocatedStorage;
75339
- if (options.MasterUserPassword)
75340
- params.MasterUserPassword = options.MasterUserPassword;
75341
- if (options.BackupRetentionPeriod !== undefined)
75342
- params.BackupRetentionPeriod = options.BackupRetentionPeriod;
75343
- if (options.PreferredBackupWindow)
75344
- params.PreferredBackupWindow = options.PreferredBackupWindow;
75345
- if (options.PreferredMaintenanceWindow)
75346
- params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
75347
- if (options.MultiAZ !== undefined)
75348
- params.MultiAZ = options.MultiAZ;
75349
- if (options.EngineVersion)
75350
- params.EngineVersion = options.EngineVersion;
75351
- if (options.AutoMinorVersionUpgrade !== undefined)
75352
- params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
75353
- if (options.PubliclyAccessible !== undefined)
75354
- params.PubliclyAccessible = options.PubliclyAccessible;
75355
- if (options.ApplyImmediately !== undefined)
75356
- params.ApplyImmediately = options.ApplyImmediately;
75357
- if (options.StorageType)
75358
- params.StorageType = options.StorageType;
75359
- if (options.DeletionProtection !== undefined)
75360
- params.DeletionProtection = options.DeletionProtection;
75361
- if (options.VpcSecurityGroupIds) {
75362
- options.VpcSecurityGroupIds.forEach((id, i) => {
75363
- params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
75311
+ if (options.Subnets) {
75312
+ options.Subnets.forEach((subnet, index) => {
75313
+ params[`Subnets.member.${index + 1}`] = subnet;
75314
+ });
75315
+ }
75316
+ if (options.SubnetMappings) {
75317
+ options.SubnetMappings.forEach((mapping, index) => {
75318
+ params[`SubnetMappings.member.${index + 1}.SubnetId`] = mapping.SubnetId;
75319
+ if (mapping.AllocationId) {
75320
+ params[`SubnetMappings.member.${index + 1}.AllocationId`] = mapping.AllocationId;
75321
+ }
75322
+ if (mapping.PrivateIPv4Address) {
75323
+ params[`SubnetMappings.member.${index + 1}.PrivateIPv4Address`] = mapping.PrivateIPv4Address;
75324
+ }
75325
+ if (mapping.IPv6Address) {
75326
+ params[`SubnetMappings.member.${index + 1}.IPv6Address`] = mapping.IPv6Address;
75327
+ }
75328
+ });
75329
+ }
75330
+ if (options.SecurityGroups) {
75331
+ options.SecurityGroups.forEach((sg, index) => {
75332
+ params[`SecurityGroups.member.${index + 1}`] = sg;
75333
+ });
75334
+ }
75335
+ if (options.Scheme) {
75336
+ params.Scheme = options.Scheme;
75337
+ }
75338
+ if (options.Type) {
75339
+ params.Type = options.Type;
75340
+ }
75341
+ if (options.IpAddressType) {
75342
+ params.IpAddressType = options.IpAddressType;
75343
+ }
75344
+ if (options.Tags) {
75345
+ options.Tags.forEach((tag, index) => {
75346
+ params[`Tags.member.${index + 1}.Key`] = tag.Key;
75347
+ params[`Tags.member.${index + 1}.Value`] = tag.Value;
75364
75348
  });
75365
75349
  }
75366
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75367
75350
  const result = await this.client.request({
75368
- service: "rds",
75351
+ service: "elasticloadbalancing",
75369
75352
  region: this.region,
75370
75353
  method: "POST",
75371
75354
  path: "/",
75372
75355
  headers: {
75373
75356
  "Content-Type": "application/x-www-form-urlencoded"
75374
75357
  },
75375
- body: queryString
75358
+ body: this.buildFormBody("CreateLoadBalancer", params)
75376
75359
  });
75377
- const response = result.ModifyDBInstanceResult || result;
75378
- return {
75379
- DBInstance: response.DBInstance
75380
- };
75360
+ return this.normalizeResult(result, "CreateLoadBalancerResult");
75381
75361
  }
75382
- async startDBInstance(dbInstanceIdentifier) {
75362
+ async deleteLoadBalancer(loadBalancerArn) {
75383
75363
  const params = {
75384
- Action: "StartDBInstance",
75385
- Version: "2014-10-31",
75386
- DBInstanceIdentifier: dbInstanceIdentifier
75364
+ LoadBalancerArn: loadBalancerArn
75387
75365
  };
75388
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75389
- const result = await this.client.request({
75390
- service: "rds",
75366
+ await this.client.request({
75367
+ service: "elasticloadbalancing",
75391
75368
  region: this.region,
75392
75369
  method: "POST",
75393
75370
  path: "/",
75394
75371
  headers: {
75395
75372
  "Content-Type": "application/x-www-form-urlencoded"
75396
75373
  },
75397
- body: queryString
75374
+ body: this.buildFormBody("DeleteLoadBalancer", params)
75398
75375
  });
75399
- const response = result.StartDBInstanceResult || result;
75400
- return {
75401
- DBInstance: response.DBInstance
75402
- };
75403
75376
  }
75404
- async stopDBInstance(options) {
75377
+ async createTargetGroup(options) {
75405
75378
  const params = {
75406
- Action: "StopDBInstance",
75407
- Version: "2014-10-31",
75408
- DBInstanceIdentifier: options.DBInstanceIdentifier
75379
+ Name: options.Name
75409
75380
  };
75410
- if (options.DBSnapshotIdentifier) {
75411
- params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
75381
+ if (options.Protocol)
75382
+ params.Protocol = options.Protocol;
75383
+ if (options.ProtocolVersion)
75384
+ params.ProtocolVersion = options.ProtocolVersion;
75385
+ if (options.Port)
75386
+ params.Port = options.Port;
75387
+ if (options.VpcId)
75388
+ params.VpcId = options.VpcId;
75389
+ if (options.HealthCheckProtocol)
75390
+ params.HealthCheckProtocol = options.HealthCheckProtocol;
75391
+ if (options.HealthCheckPort)
75392
+ params.HealthCheckPort = options.HealthCheckPort;
75393
+ if (options.HealthCheckEnabled !== undefined)
75394
+ params.HealthCheckEnabled = options.HealthCheckEnabled;
75395
+ if (options.HealthCheckPath)
75396
+ params.HealthCheckPath = options.HealthCheckPath;
75397
+ if (options.HealthCheckIntervalSeconds)
75398
+ params.HealthCheckIntervalSeconds = options.HealthCheckIntervalSeconds;
75399
+ if (options.HealthCheckTimeoutSeconds)
75400
+ params.HealthCheckTimeoutSeconds = options.HealthCheckTimeoutSeconds;
75401
+ if (options.HealthyThresholdCount)
75402
+ params.HealthyThresholdCount = options.HealthyThresholdCount;
75403
+ if (options.UnhealthyThresholdCount)
75404
+ params.UnhealthyThresholdCount = options.UnhealthyThresholdCount;
75405
+ if (options.TargetType)
75406
+ params.TargetType = options.TargetType;
75407
+ if (options.IpAddressType)
75408
+ params.IpAddressType = options.IpAddressType;
75409
+ if (options.Matcher) {
75410
+ if (options.Matcher.HttpCode)
75411
+ params["Matcher.HttpCode"] = options.Matcher.HttpCode;
75412
+ if (options.Matcher.GrpcCode)
75413
+ params["Matcher.GrpcCode"] = options.Matcher.GrpcCode;
75414
+ }
75415
+ if (options.Tags) {
75416
+ options.Tags.forEach((tag, index) => {
75417
+ params[`Tags.member.${index + 1}.Key`] = tag.Key;
75418
+ params[`Tags.member.${index + 1}.Value`] = tag.Value;
75419
+ });
75412
75420
  }
75413
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75414
75421
  const result = await this.client.request({
75415
- service: "rds",
75422
+ service: "elasticloadbalancing",
75416
75423
  region: this.region,
75417
75424
  method: "POST",
75418
75425
  path: "/",
75419
75426
  headers: {
75420
75427
  "Content-Type": "application/x-www-form-urlencoded"
75421
75428
  },
75422
- body: queryString
75429
+ body: this.buildFormBody("CreateTargetGroup", params)
75423
75430
  });
75424
- const response = result.StopDBInstanceResult || result;
75425
- return {
75426
- DBInstance: response.DBInstance
75431
+ return this.normalizeResult(result, "CreateTargetGroupResult");
75432
+ }
75433
+ async deleteTargetGroup(targetGroupArn) {
75434
+ const params = {
75435
+ TargetGroupArn: targetGroupArn
75427
75436
  };
75437
+ await this.client.request({
75438
+ service: "elasticloadbalancing",
75439
+ region: this.region,
75440
+ method: "POST",
75441
+ path: "/",
75442
+ headers: {
75443
+ "Content-Type": "application/x-www-form-urlencoded"
75444
+ },
75445
+ body: this.buildFormBody("DeleteTargetGroup", params)
75446
+ });
75428
75447
  }
75429
- async rebootDBInstance(options) {
75448
+ async registerTargets(options) {
75430
75449
  const params = {
75431
- Action: "RebootDBInstance",
75432
- Version: "2014-10-31",
75433
- DBInstanceIdentifier: options.DBInstanceIdentifier
75450
+ TargetGroupArn: options.TargetGroupArn
75434
75451
  };
75435
- if (options.ForceFailover !== undefined) {
75436
- params.ForceFailover = options.ForceFailover;
75437
- }
75438
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75439
- const result = await this.client.request({
75440
- service: "rds",
75452
+ options.Targets.forEach((target, index) => {
75453
+ params[`Targets.member.${index + 1}.Id`] = target.Id;
75454
+ if (target.Port) {
75455
+ params[`Targets.member.${index + 1}.Port`] = target.Port;
75456
+ }
75457
+ if (target.AvailabilityZone) {
75458
+ params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
75459
+ }
75460
+ });
75461
+ await this.client.request({
75462
+ service: "elasticloadbalancing",
75441
75463
  region: this.region,
75442
75464
  method: "POST",
75443
75465
  path: "/",
75444
75466
  headers: {
75445
75467
  "Content-Type": "application/x-www-form-urlencoded"
75446
75468
  },
75447
- body: queryString
75469
+ body: this.buildFormBody("RegisterTargets", params)
75448
75470
  });
75449
- const response = result.RebootDBInstanceResult || result;
75450
- return {
75451
- DBInstance: response.DBInstance
75471
+ }
75472
+ async deregisterTargets(options) {
75473
+ const params = {
75474
+ TargetGroupArn: options.TargetGroupArn
75452
75475
  };
75476
+ options.Targets.forEach((target, index) => {
75477
+ params[`Targets.member.${index + 1}.Id`] = target.Id;
75478
+ if (target.Port) {
75479
+ params[`Targets.member.${index + 1}.Port`] = target.Port;
75480
+ }
75481
+ if (target.AvailabilityZone) {
75482
+ params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
75483
+ }
75484
+ });
75485
+ await this.client.request({
75486
+ service: "elasticloadbalancing",
75487
+ region: this.region,
75488
+ method: "POST",
75489
+ path: "/",
75490
+ headers: {
75491
+ "Content-Type": "application/x-www-form-urlencoded"
75492
+ },
75493
+ body: this.buildFormBody("DeregisterTargets", params)
75494
+ });
75453
75495
  }
75454
- async createDBSnapshot(options) {
75496
+ async createListener(options) {
75455
75497
  const params = {
75456
- Action: "CreateDBSnapshot",
75457
- Version: "2014-10-31",
75458
- DBInstanceIdentifier: options.DBInstanceIdentifier,
75459
- DBSnapshotIdentifier: options.DBSnapshotIdentifier
75498
+ LoadBalancerArn: options.LoadBalancerArn,
75499
+ Port: options.Port
75460
75500
  };
75501
+ if (options.Protocol)
75502
+ params.Protocol = options.Protocol;
75503
+ if (options.SslPolicy)
75504
+ params.SslPolicy = options.SslPolicy;
75505
+ if (options.Certificates) {
75506
+ options.Certificates.forEach((cert, index) => {
75507
+ params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
75508
+ });
75509
+ }
75510
+ options.DefaultActions.forEach((action, index) => {
75511
+ params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
75512
+ if (action.TargetGroupArn) {
75513
+ params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
75514
+ }
75515
+ if (action.Order !== undefined) {
75516
+ params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
75517
+ }
75518
+ if (action.RedirectConfig) {
75519
+ const rc = action.RedirectConfig;
75520
+ if (rc.Protocol)
75521
+ params[`DefaultActions.member.${index + 1}.RedirectConfig.Protocol`] = rc.Protocol;
75522
+ if (rc.Port)
75523
+ params[`DefaultActions.member.${index + 1}.RedirectConfig.Port`] = rc.Port;
75524
+ if (rc.Host)
75525
+ params[`DefaultActions.member.${index + 1}.RedirectConfig.Host`] = rc.Host;
75526
+ if (rc.Path)
75527
+ params[`DefaultActions.member.${index + 1}.RedirectConfig.Path`] = rc.Path;
75528
+ if (rc.Query)
75529
+ params[`DefaultActions.member.${index + 1}.RedirectConfig.Query`] = rc.Query;
75530
+ params[`DefaultActions.member.${index + 1}.RedirectConfig.StatusCode`] = rc.StatusCode;
75531
+ }
75532
+ if (action.FixedResponseConfig) {
75533
+ const fr = action.FixedResponseConfig;
75534
+ if (fr.MessageBody)
75535
+ params[`DefaultActions.member.${index + 1}.FixedResponseConfig.MessageBody`] = fr.MessageBody;
75536
+ params[`DefaultActions.member.${index + 1}.FixedResponseConfig.StatusCode`] = fr.StatusCode;
75537
+ if (fr.ContentType)
75538
+ params[`DefaultActions.member.${index + 1}.FixedResponseConfig.ContentType`] = fr.ContentType;
75539
+ }
75540
+ });
75541
+ if (options.AlpnPolicy) {
75542
+ options.AlpnPolicy.forEach((policy, index) => {
75543
+ params[`AlpnPolicy.member.${index + 1}`] = policy;
75544
+ });
75545
+ }
75461
75546
  if (options.Tags) {
75462
- options.Tags.forEach((tag, i) => {
75463
- params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
75464
- params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
75547
+ options.Tags.forEach((tag, index) => {
75548
+ params[`Tags.member.${index + 1}.Key`] = tag.Key;
75549
+ params[`Tags.member.${index + 1}.Value`] = tag.Value;
75465
75550
  });
75466
75551
  }
75467
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75468
75552
  const result = await this.client.request({
75469
- service: "rds",
75553
+ service: "elasticloadbalancing",
75470
75554
  region: this.region,
75471
75555
  method: "POST",
75472
75556
  path: "/",
75473
75557
  headers: {
75474
75558
  "Content-Type": "application/x-www-form-urlencoded"
75475
75559
  },
75476
- body: queryString
75560
+ body: this.buildFormBody("CreateListener", params)
75477
75561
  });
75478
- const response = result.CreateDBSnapshotResult || result;
75479
- return {
75480
- DBSnapshot: response.DBSnapshot
75481
- };
75562
+ return this.normalizeResult(result, "CreateListenerResult");
75482
75563
  }
75483
- async deleteDBSnapshot(dbSnapshotIdentifier) {
75564
+ async deleteListener(listenerArn) {
75484
75565
  const params = {
75485
- Action: "DeleteDBSnapshot",
75486
- Version: "2014-10-31",
75487
- DBSnapshotIdentifier: dbSnapshotIdentifier
75566
+ ListenerArn: listenerArn
75488
75567
  };
75489
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75490
- const result = await this.client.request({
75491
- service: "rds",
75568
+ await this.client.request({
75569
+ service: "elasticloadbalancing",
75492
75570
  region: this.region,
75493
75571
  method: "POST",
75494
75572
  path: "/",
75495
75573
  headers: {
75496
75574
  "Content-Type": "application/x-www-form-urlencoded"
75497
75575
  },
75498
- body: queryString
75576
+ body: this.buildFormBody("DeleteListener", params)
75499
75577
  });
75500
- const response = result.DeleteDBSnapshotResult || result;
75501
- return {
75502
- DBSnapshot: response.DBSnapshot
75503
- };
75504
75578
  }
75505
- async restoreDBInstanceFromDBSnapshot(options) {
75579
+ async modifyListener(options) {
75506
75580
  const params = {
75507
- Action: "RestoreDBInstanceFromDBSnapshot",
75508
- Version: "2014-10-31",
75509
- DBInstanceIdentifier: options.DBInstanceIdentifier,
75510
- DBSnapshotIdentifier: options.DBSnapshotIdentifier
75581
+ ListenerArn: options.ListenerArn
75511
75582
  };
75512
- if (options.DBInstanceClass)
75513
- params.DBInstanceClass = options.DBInstanceClass;
75514
75583
  if (options.Port)
75515
75584
  params.Port = options.Port;
75516
- if (options.AvailabilityZone)
75517
- params.AvailabilityZone = options.AvailabilityZone;
75518
- if (options.DBSubnetGroupName)
75519
- params.DBSubnetGroupName = options.DBSubnetGroupName;
75520
- if (options.MultiAZ !== undefined)
75521
- params.MultiAZ = options.MultiAZ;
75522
- if (options.PubliclyAccessible !== undefined)
75523
- params.PubliclyAccessible = options.PubliclyAccessible;
75524
- if (options.AutoMinorVersionUpgrade !== undefined)
75525
- params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
75526
- if (options.StorageType)
75527
- params.StorageType = options.StorageType;
75528
- if (options.DeletionProtection !== undefined)
75529
- params.DeletionProtection = options.DeletionProtection;
75530
- if (options.VpcSecurityGroupIds) {
75531
- options.VpcSecurityGroupIds.forEach((id, i) => {
75532
- params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
75585
+ if (options.Protocol)
75586
+ params.Protocol = options.Protocol;
75587
+ if (options.SslPolicy)
75588
+ params.SslPolicy = options.SslPolicy;
75589
+ if (options.Certificates) {
75590
+ options.Certificates.forEach((cert, index) => {
75591
+ params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
75533
75592
  });
75534
75593
  }
75535
- if (options.Tags) {
75536
- options.Tags.forEach((tag, i) => {
75537
- params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
75538
- params[`Tags.Tag.${i + 1}.Value`] = tag.Value;
75594
+ if (options.DefaultActions) {
75595
+ options.DefaultActions.forEach((action, index) => {
75596
+ if (action.Type)
75597
+ params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
75598
+ if (action.TargetGroupArn)
75599
+ params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
75600
+ if (action.Order !== undefined)
75601
+ params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
75602
+ });
75603
+ }
75604
+ if (options.AlpnPolicy) {
75605
+ options.AlpnPolicy.forEach((policy, index) => {
75606
+ params[`AlpnPolicy.member.${index + 1}`] = policy;
75539
75607
  });
75540
75608
  }
75541
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75542
75609
  const result = await this.client.request({
75543
- service: "rds",
75610
+ service: "elasticloadbalancing",
75544
75611
  region: this.region,
75545
75612
  method: "POST",
75546
75613
  path: "/",
75547
75614
  headers: {
75548
75615
  "Content-Type": "application/x-www-form-urlencoded"
75549
75616
  },
75550
- body: queryString
75617
+ body: this.buildFormBody("ModifyListener", params)
75551
75618
  });
75552
- const response = result.RestoreDBInstanceFromDBSnapshotResult || result;
75553
- return {
75554
- DBInstance: response.DBInstance
75555
- };
75619
+ return this.normalizeResult(result, "ModifyListenerResult");
75556
75620
  }
75557
- async waitForDBInstanceAvailable(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
75558
- for (let i = 0;i < maxAttempts; i++) {
75559
- const instance = await this.describeDBInstance(dbInstanceIdentifier);
75560
- if (instance?.DBInstanceStatus === "available") {
75561
- return instance;
75562
- }
75563
- if (["deleted", "failed", "incompatible-restore", "incompatible-parameters"].includes(instance?.DBInstanceStatus || "")) {
75564
- throw new Error(`DB instance ${dbInstanceIdentifier} is in terminal state: ${instance?.DBInstanceStatus}`);
75621
+ buildFormBody(action, params) {
75622
+ const formParams = {
75623
+ Action: action,
75624
+ Version: "2015-12-01"
75625
+ };
75626
+ for (const [key, value] of Object.entries(params)) {
75627
+ if (value !== undefined && value !== null) {
75628
+ formParams[key] = String(value);
75565
75629
  }
75566
- await new Promise((resolve14) => setTimeout(resolve14, delayMs));
75567
75630
  }
75568
- throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to become available`);
75631
+ return Object.entries(formParams).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&");
75569
75632
  }
75570
- async waitForDBInstanceDeleted(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
75571
- for (let i = 0;i < maxAttempts; i++) {
75572
- try {
75573
- const instance = await this.describeDBInstance(dbInstanceIdentifier);
75574
- if (instance?.DBInstanceStatus === "deleting") {
75575
- await new Promise((resolve14) => setTimeout(resolve14, delayMs));
75576
- continue;
75633
+ normalizeResult(parsed, resultKey) {
75634
+ if (parsed && parsed[resultKey]) {
75635
+ return this.normalizeArrays(parsed[resultKey]);
75636
+ }
75637
+ const responseKey = resultKey.replace("Result", "Response");
75638
+ if (parsed && parsed[responseKey] && parsed[responseKey][resultKey]) {
75639
+ return this.normalizeArrays(parsed[responseKey][resultKey]);
75640
+ }
75641
+ return this.normalizeArrays(parsed);
75642
+ }
75643
+ normalizeArrays(obj) {
75644
+ if (!obj || typeof obj !== "object") {
75645
+ return obj;
75646
+ }
75647
+ if (Array.isArray(obj)) {
75648
+ return obj.map((item) => this.normalizeArrays(item));
75649
+ }
75650
+ const result = {};
75651
+ for (const [key, value] of Object.entries(obj)) {
75652
+ const arrayFields = [
75653
+ "LoadBalancers",
75654
+ "TargetGroups",
75655
+ "Listeners",
75656
+ "Rules",
75657
+ "TargetHealthDescriptions",
75658
+ "Attributes",
75659
+ "SecurityGroups",
75660
+ "AvailabilityZones",
75661
+ "Certificates",
75662
+ "DefaultActions",
75663
+ "Conditions",
75664
+ "Actions",
75665
+ "member"
75666
+ ];
75667
+ if (key === "member") {
75668
+ if (Array.isArray(value)) {
75669
+ return value.map((item) => this.normalizeArrays(item));
75577
75670
  }
75578
- throw new Error(`DB instance ${dbInstanceIdentifier} is in state: ${instance?.DBInstanceStatus}`);
75579
- } catch (error) {
75580
- if (error.code === "DBInstanceNotFound" || error.code === "DBInstanceNotFoundFault") {
75581
- return;
75671
+ return [this.normalizeArrays(value)];
75672
+ }
75673
+ if (arrayFields.includes(key)) {
75674
+ if (value && typeof value === "object" && "member" in value) {
75675
+ const memberValue = value.member;
75676
+ result[key] = Array.isArray(memberValue) ? memberValue.map((item) => this.normalizeArrays(item)) : [this.normalizeArrays(memberValue)];
75677
+ } else if (Array.isArray(value)) {
75678
+ result[key] = value.map((item) => this.normalizeArrays(item));
75679
+ } else if (value) {
75680
+ result[key] = [this.normalizeArrays(value)];
75681
+ } else {
75682
+ result[key] = [];
75582
75683
  }
75583
- throw error;
75684
+ } else if (typeof value === "object") {
75685
+ result[key] = this.normalizeArrays(value);
75686
+ } else {
75687
+ result[key] = value;
75584
75688
  }
75585
75689
  }
75586
- throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to be deleted`);
75690
+ return result;
75587
75691
  }
75588
75692
  }
75693
+
75694
+ // src/aws/index.ts
75695
+ init_rds();
75696
+
75589
75697
  // src/aws/dynamodb.ts
75590
75698
  init_client();
75591
75699
 
@@ -83294,7 +83402,15 @@ async function uploadAssets(s32, bucket, dir, prefix, includeDotfiles = false) {
83294
83402
  }
83295
83403
  return count;
83296
83404
  }
83405
+ function assertEnvWithinLimit(name, env2) {
83406
+ const bytes = Object.entries(env2).reduce((n, [k, v]) => n + Buffer.byteLength(`${k}=${v}`, "utf8"), 0);
83407
+ if (bytes > 4096) {
83408
+ const biggest = Object.entries(env2).map(([k, v]) => [k, Buffer.byteLength(`${k}=${v}`, "utf8")]).sort((a, b) => b[1] - a[1]).slice(0, 5).map(([k, n]) => `${k} (${n}B)`).join(", ");
83409
+ throw new Error(`${name}: environment variables total ${bytes}B, over AWS's 4096B limit (${bytes - 4096}B too large). ` + `Largest: ${biggest}. Move large/secret values out of env — store them in Secrets Manager and fetch at cold start.`);
83410
+ }
83411
+ }
83297
83412
  async function applyFunction(lambda2, name, env2, code) {
83413
+ assertEnvWithinLimit(name, env2);
83298
83414
  await withConflictRetry(() => lambda2.updateFunctionConfiguration({ FunctionName: name, Environment: { Variables: env2 } }));
83299
83415
  await lambda2.waitForFunctionActive(name, 120);
83300
83416
  const codeParams = code.kind === "image" ? { FunctionName: name, ImageUri: code.imageUri } : { FunctionName: name, S3Bucket: code.bucket, S3Key: code.key };
@@ -83449,6 +83565,7 @@ async function deployServerlessApp(config6, environment, opts = {}) {
83449
83565
  code: codeSource,
83450
83566
  previousSha: prior?.sha,
83451
83567
  previousCode: prior?.code,
83568
+ previousFunctionEnv: prior?.functionEnv,
83452
83569
  functionEnv,
83453
83570
  functionNames: {
83454
83571
  http: composed.functionNames.http,
@@ -83520,14 +83637,17 @@ async function rollbackServerlessApp(config6, environment) {
83520
83637
  if (!name)
83521
83638
  continue;
83522
83639
  step(`Restoring ${mode} (${name})`);
83523
- await applyFunction(lambda2, name, release.functionEnv[mode] ?? {}, release.previousCode);
83640
+ const env2 = release.previousFunctionEnv?.[mode] ?? release.functionEnv[mode] ?? {};
83641
+ await applyFunction(lambda2, name, env2, release.previousCode);
83524
83642
  }
83525
83643
  await writeRelease(s32, ctx.artifactBucket, ctx.slug, environment, {
83526
83644
  ...release,
83527
83645
  sha: release.previousSha ?? release.sha,
83528
83646
  code: release.previousCode,
83647
+ functionEnv: release.previousFunctionEnv ?? release.functionEnv,
83529
83648
  previousSha: undefined,
83530
83649
  previousCode: undefined,
83650
+ previousFunctionEnv: undefined,
83531
83651
  timestamp: new Date().toISOString()
83532
83652
  });
83533
83653
  success("Rollback complete");
@@ -86732,6 +86852,7 @@ export {
86732
86852
  resolveServerlessArtifactBucketName,
86733
86853
  resolveServerlessAppStackName,
86734
86854
  resolveRegion,
86855
+ resolveQueues,
86735
86856
  resolveQueueNames,
86736
86857
  resolveProjectStackName,
86737
86858
  resolveObjectStorage,