@stacksjs/ts-cloud 0.5.6 → 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
@@ -26471,7 +26471,10 @@ function composeServerlessAppTemplate(opts) {
26471
26471
  DatabaseName: "app",
26472
26472
  MasterUsername: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:username}}"),
26473
26473
  MasterUserPassword: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:password}}"),
26474
- ServerlessV2ScalingConfiguration: { MinCapacity: 0.5, MaxCapacity: 4 },
26474
+ ServerlessV2ScalingConfiguration: {
26475
+ MinCapacity: app.database?.minCapacity ?? 0.5,
26476
+ MaxCapacity: app.database?.maxCapacity ?? 4
26477
+ },
26475
26478
  DBSubnetGroupName: Fn2.ref("DbSubnetGroup"),
26476
26479
  VpcSecurityGroupIds: [Fn2.getAtt("DataSecurityGroup", "GroupId")]
26477
26480
  }
@@ -55715,405 +55718,1001 @@ var init_email = __esm(() => {
55715
55718
  email = new EmailClient;
55716
55719
  });
55717
55720
 
55718
- // src/deploy/static-site-external-dns.ts
55719
- function generateExternalDnsStaticSiteTemplate(config6) {
55720
- const {
55721
- bucketName,
55722
- domain,
55723
- aliases,
55724
- certificateArn,
55725
- defaultRootObject = "index.html",
55726
- errorDocument = "404.html",
55727
- passthroughUrls = false,
55728
- singlePageApp = false,
55729
- dynamicApp = false,
55730
- computeOriginDomain,
55731
- computeOriginPort = 3008,
55732
- computeOriginId = "app-compute",
55733
- retainOnStackDelete = false
55734
- } = config6;
55735
- const retainPolicy = retainOnStackDelete ? { DeletionPolicy: "Retain", UpdateReplacePolicy: "Retain" } : {};
55736
- const useComputeOrigin = dynamicApp && !!computeOriginDomain;
55737
- const defaultAllowedMethods = useComputeOrigin ? ["GET", "HEAD", "OPTIONS", "PUT", "POST", "PATCH", "DELETE"] : ["GET", "HEAD"];
55738
- const defaultCachedMethods = useComputeOrigin ? ["GET", "HEAD"] : ["GET", "HEAD"];
55739
- const resources = {};
55740
- const outputs = {};
55741
- resources.S3Bucket = {
55742
- Type: "AWS::S3::Bucket",
55743
- ...retainPolicy,
55744
- Properties: {
55745
- BucketName: bucketName,
55746
- PublicAccessBlockConfiguration: {
55747
- BlockPublicAcls: true,
55748
- BlockPublicPolicy: false,
55749
- IgnorePublicAcls: true,
55750
- RestrictPublicBuckets: false
55751
- },
55752
- WebsiteConfiguration: {
55753
- IndexDocument: defaultRootObject,
55754
- ErrorDocument: errorDocument
55755
- }
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;
55756
55736
  }
55757
- };
55758
- outputs.BucketName = {
55759
- Description: "S3 Bucket Name",
55760
- Value: { Ref: "S3Bucket" }
55761
- };
55762
- outputs.BucketArn = {
55763
- Description: "S3 Bucket ARN",
55764
- Value: { "Fn::GetAtt": ["S3Bucket", "Arn"] }
55765
- };
55766
- resources.CloudFrontOAC = {
55767
- Type: "AWS::CloudFront::OriginAccessControl",
55768
- ...retainPolicy,
55769
- Properties: {
55770
- OriginAccessControlConfig: {
55771
- Name: `OAC-${bucketName}`,
55772
- Description: `OAC for ${bucketName}`,
55773
- OriginAccessControlOriginType: "s3",
55774
- SigningBehavior: "always",
55775
- SigningProtocol: "sigv4"
55776
- }
55737
+ if (options?.MaxRecords) {
55738
+ params.MaxRecords = options.MaxRecords;
55777
55739
  }
55778
- };
55779
- let installRootRedirectLogicalId;
55780
- if (passthroughUrls && useComputeOrigin) {
55781
- installRootRedirectLogicalId = "InstallRootRedirectFunction";
55782
- resources[installRootRedirectLogicalId] = {
55783
- Type: "AWS::CloudFront::Function",
55784
- Properties: {
55785
- Name: { "Fn::Sub": "${AWS::StackName}-install-root-redirect" },
55786
- AutoPublish: true,
55787
- FunctionConfig: {
55788
- Comment: "Redirect curl pantry.dev | bash (GET /) to /install.sh on S3",
55789
- Runtime: "cloudfront-js-2.0"
55790
- },
55791
- FunctionCode: `function handler(event) {
55792
- var request = event.request;
55793
- if (request.uri === '/' || request.uri === '') {
55794
- return {
55795
- statusCode: 302,
55796
- 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: "/",
55797
55757
  headers: {
55798
- location: { value: 'https://' + request.headers.host.value + '/install.sh' }
55799
- }
55800
- };
55801
- }
55802
- return request;
55803
- }`
55804
- }
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
55805
55770
  };
55806
55771
  }
55807
- if (!passthroughUrls) {
55808
- resources.UrlRewriteFunction = {
55809
- Type: "AWS::CloudFront::Function",
55810
- Properties: {
55811
- Name: { "Fn::Sub": "${AWS::StackName}-url-rewrite" },
55812
- AutoPublish: true,
55813
- FunctionConfig: {
55814
- Comment: "Append .html extension to URLs without extensions",
55815
- Runtime: "cloudfront-js-2.0"
55816
- },
55817
- FunctionCode: `function handler(event) {
55818
- const request = event.request;
55819
- var uri = request.uri;
55820
-
55821
- // If URI ends with /, serve index.html
55822
- if (uri.endsWith('/')) {
55823
- request.uri = uri + 'index.html';
55824
- }
55825
- // If URI doesn't have an extension, append .html
55826
- else if (!uri.includes('.')) {
55827
- request.uri = uri + '.html';
55772
+ async describeDBInstance(dbInstanceIdentifier) {
55773
+ const result = await this.describeDBInstances({ DBInstanceIdentifier: dbInstanceIdentifier });
55774
+ return result.DBInstances?.[0];
55828
55775
  }
55829
-
55830
- return request;
55831
- }`
55832
- }
55776
+ async describeDBClusters(options) {
55777
+ const params = {
55778
+ Action: "DescribeDBClusters",
55779
+ Version: "2014-10-31"
55833
55780
  };
55834
- }
55835
- const s3Origin = {
55836
- Id: `S3-${bucketName}`,
55837
- DomainName: { "Fn::GetAtt": ["S3Bucket", "RegionalDomainName"] },
55838
- S3OriginConfig: {
55839
- OriginAccessIdentity: ""
55840
- },
55841
- OriginAccessControlId: { "Fn::GetAtt": ["CloudFrontOAC", "Id"] }
55842
- };
55843
- const computeOrigin = useComputeOrigin ? {
55844
- Id: computeOriginId,
55845
- DomainName: computeOriginDomain,
55846
- CustomOriginConfig: {
55847
- HTTPPort: computeOriginPort,
55848
- HTTPSPort: 443,
55849
- OriginProtocolPolicy: "http-only",
55850
- OriginSSLProtocols: ["TLSv1.2"]
55781
+ if (options?.DBClusterIdentifier) {
55782
+ params.DBClusterIdentifier = options.DBClusterIdentifier;
55851
55783
  }
55852
- } : null;
55853
- const defaultTargetOriginId = useComputeOrigin ? computeOriginId : `S3-${bucketName}`;
55854
- const distributionConfig = {
55855
- Enabled: true,
55856
- DefaultRootObject: defaultRootObject,
55857
- HttpVersion: "http2and3",
55858
- IPV6Enabled: true,
55859
- PriceClass: "PriceClass_100",
55860
- Origins: computeOrigin ? [computeOrigin, s3Origin] : [s3Origin],
55861
- DefaultCacheBehavior: {
55862
- TargetOriginId: defaultTargetOriginId,
55863
- ViewerProtocolPolicy: "redirect-to-https",
55864
- AllowedMethods: defaultAllowedMethods,
55865
- CachedMethods: defaultCachedMethods,
55866
- Compress: true,
55867
- ...useComputeOrigin ? {
55868
- CachePolicyId: "4135ea2d-6df8-44a3-9df3-4b5a84be39ad",
55869
- OriginRequestPolicyId: "b689b0a8-53d0-40ab-baf2-68738e2966ac",
55870
- ...passthroughUrls && installRootRedirectLogicalId ? {
55871
- FunctionAssociations: [{
55872
- EventType: "viewer-request",
55873
- FunctionARN: { "Fn::GetAtt": [installRootRedirectLogicalId, "FunctionARN"] }
55874
- }]
55875
- } : {}
55876
- } : {
55877
- CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6",
55878
- ...!passthroughUrls && {
55879
- FunctionAssociations: [
55880
- {
55881
- EventType: "viewer-request",
55882
- FunctionARN: { "Fn::GetAtt": ["UrlRewriteFunction", "FunctionARN"] }
55883
- }
55884
- ]
55885
- }
55886
- }
55887
- },
55888
- ...useComputeOrigin && passthroughUrls ? {
55889
- CacheBehaviors: [
55890
- {
55891
- PathPattern: "/install.sh",
55892
- TargetOriginId: `S3-${bucketName}`,
55893
- ViewerProtocolPolicy: "redirect-to-https",
55894
- AllowedMethods: ["GET", "HEAD", "OPTIONS"],
55895
- CachedMethods: ["GET", "HEAD", "OPTIONS"],
55896
- Compress: true,
55897
- CachePolicyId: "658327ea-f89d-4fab-a63d-7e88639e58f6"
55898
- }
55899
- ]
55900
- } : {},
55901
- CustomErrorResponses: singlePageApp ? [
55902
- {
55903
- ErrorCode: 403,
55904
- ResponseCode: 200,
55905
- ResponsePagePath: `/${defaultRootObject}`,
55906
- ErrorCachingMinTTL: 300
55907
- },
55908
- {
55909
- ErrorCode: 404,
55910
- ResponseCode: 200,
55911
- ResponsePagePath: `/${defaultRootObject}`,
55912
- ErrorCachingMinTTL: 300
55913
- }
55914
- ] : [
55915
- {
55916
- ErrorCode: 403,
55917
- ResponseCode: 404,
55918
- ResponsePagePath: `/${errorDocument}`,
55919
- 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"
55920
55806
  },
55921
- {
55922
- ErrorCode: 404,
55923
- ResponseCode: 404,
55924
- ResponsePagePath: `/${errorDocument}`,
55925
- ErrorCachingMinTTL: 300
55926
- }
55927
- ]
55928
- };
55929
- if (domain && certificateArn) {
55930
- distributionConfig.Aliases = aliases && aliases.length > 0 ? aliases : [domain];
55931
- distributionConfig.ViewerCertificate = {
55932
- AcmCertificateArn: certificateArn,
55933
- SslSupportMethod: "sni-only",
55934
- MinimumProtocolVersion: "TLSv1.2_2021"
55935
- };
55936
- } else {
55937
- distributionConfig.ViewerCertificate = {
55938
- 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
55939
55817
  };
55940
55818
  }
55941
- resources.CloudFrontDistribution = {
55942
- Type: "AWS::CloudFront::Distribution",
55943
- ...retainPolicy,
55944
- DependsOn: [
55945
- "S3Bucket",
55946
- "CloudFrontOAC",
55947
- ...passthroughUrls && useComputeOrigin && installRootRedirectLogicalId ? [installRootRedirectLogicalId] : [],
55948
- ...!passthroughUrls ? ["UrlRewriteFunction"] : []
55949
- ],
55950
- Properties: {
55951
- 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;
55952
55826
  }
55953
- };
55954
- outputs.DistributionId = {
55955
- Description: "CloudFront Distribution ID",
55956
- Value: { Ref: "CloudFrontDistribution" }
55957
- };
55958
- outputs.DistributionDomain = {
55959
- Description: "CloudFront Distribution Domain",
55960
- Value: { "Fn::GetAtt": ["CloudFrontDistribution", "DomainName"] }
55961
- };
55962
- resources.S3BucketPolicy = {
55963
- Type: "AWS::S3::BucketPolicy",
55964
- ...retainPolicy,
55965
- DependsOn: ["S3Bucket", "CloudFrontDistribution"],
55966
- Properties: {
55967
- Bucket: { Ref: "S3Bucket" },
55968
- PolicyDocument: {
55969
- Version: "2012-10-17",
55970
- Statement: [
55971
- {
55972
- Sid: "AllowCloudFrontServicePrincipal",
55973
- Effect: "Allow",
55974
- Principal: {
55975
- Service: "cloudfront.amazonaws.com"
55976
- },
55977
- Action: "s3:GetObject",
55978
- Resource: { "Fn::Sub": "arn:aws:s3:::${S3Bucket}/*" },
55979
- Condition: {
55980
- StringEquals: {
55981
- "AWS:SourceArn": {
55982
- "Fn::Sub": "arn:aws:cloudfront::${AWS::AccountId}:distribution/${CloudFrontDistribution}"
55983
- }
55984
- }
55985
- }
55986
- }
55987
- ]
55988
- }
55827
+ if (options?.DBSnapshotIdentifier) {
55828
+ params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
55989
55829
  }
55990
- };
55991
- outputs.SiteUrl = {
55992
- Description: "Site URL",
55993
- Value: domain ? `https://${domain}` : { "Fn::Sub": "https://${CloudFrontDistribution.DomainName}" }
55994
- };
55995
- return {
55996
- AWSTemplateFormatVersion: "2010-09-09",
55997
- Description: `Static site infrastructure for ${domain || bucketName} (External DNS)`,
55998
- Resources: resources,
55999
- Outputs: outputs
56000
- };
56001
- }
56002
- async function deployStaticSiteWithExternalDns(config6) {
56003
- const region = config6.region || "us-east-1";
56004
- const cfRegion = "us-east-1";
56005
- const domain = config6.domain;
56006
- const bucket = config6.bucket || domain.replace(/\./g, "-");
56007
- const stackName = config6.stackName || `${config6.siteName}-static-site`;
56008
- const cf = new CloudFormationClient(cfRegion);
56009
- const acm2 = new ACMClient("us-east-1");
56010
- let dnsProvider = null;
56011
- if (!config6.skipDnsVerification) {
56012
- dnsProvider = createDnsProvider(config6.dnsProvider);
56013
- console.log(`Verifying DNS provider can manage ${domain}...`);
56014
- const verify = await dnsProvider.listRecords(domain);
56015
- if (!verify.success) {
56016
- const reason = verify.message || "unknown error — check API credentials and domain ownership";
56017
- return {
56018
- success: false,
56019
- stackName,
56020
- bucket,
56021
- message: `DNS provider '${dnsProvider.name}' cannot manage domain ${domain}: ${reason}`
56022
- };
55830
+ if (options?.SnapshotType) {
55831
+ params.SnapshotType = options.SnapshotType;
56023
55832
  }
56024
- console.log(`DNS provider '${dnsProvider.name}' verified for ${domain}`);
56025
- } else {
56026
- console.log(`Skipping DNS verification for ${domain}`);
56027
- }
56028
- let certificateArn = config6.certificateArn;
56029
- const domainParts = domain.split(".");
56030
- const isApexDomain = domainParts.length === 2;
56031
- const wwwDomain = isApexDomain ? `www.${domain}` : undefined;
56032
- if (!certificateArn) {
56033
- console.log(`Checking for existing SSL certificate for ${domain}...`);
56034
- const existingCert = await acm2.findCertificateByDomain(domain);
56035
- let existingCertCoversWww = false;
56036
- if (existingCert && existingCert.Status === "ISSUED") {
56037
- if (wwwDomain && existingCert.SubjectAlternativeNames) {
56038
- existingCertCoversWww = existingCert.SubjectAlternativeNames.includes(wwwDomain) || existingCert.SubjectAlternativeNames.some((san) => san === `*.${domain}`);
56039
- } else {
56040
- existingCertCoversWww = true;
56041
- }
56042
- if (existingCertCoversWww) {
56043
- certificateArn = existingCert.CertificateArn;
56044
- console.log(`Found existing certificate with www coverage: ${certificateArn}`);
56045
- } else {
56046
- console.log(`Existing certificate doesn't cover ${wwwDomain}, requesting new one...`);
56047
- }
55833
+ if (options?.MaxRecords) {
55834
+ params.MaxRecords = options.MaxRecords;
56048
55835
  }
56049
- if (!certificateArn) {
56050
- if (!dnsProvider) {
56051
- return {
56052
- success: false,
56053
- stackName,
56054
- bucket,
56055
- message: `No DNS provider available to validate SSL certificate for ${domain}. Provide a certificateArn or enable DNS verification.`
56056
- };
56057
- }
56058
- console.log(`Requesting new SSL certificate for ${domain}${wwwDomain ? ` (including ${wwwDomain})` : ""}...`);
56059
- const validator = new UnifiedDnsValidator(dnsProvider, "us-east-1");
56060
- const certResult = await validator.findOrCreateCertificate({
56061
- domainName: domain,
56062
- subjectAlternativeNames: wwwDomain ? [wwwDomain] : undefined,
56063
- waitForValidation: true,
56064
- maxWaitMinutes: 10
56065
- });
56066
- if (certResult.status !== "issued") {
56067
- return {
56068
- success: false,
56069
- stackName,
56070
- bucket,
56071
- message: `SSL certificate validation failed. Status: ${certResult.status}`
56072
- };
56073
- }
56074
- certificateArn = certResult.certificateArn;
56075
- 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] : [];
56076
55854
  }
55855
+ return {
55856
+ DBSnapshots: snapshots,
55857
+ Marker: response.Marker
55858
+ };
56077
55859
  }
56078
- let stackExists = false;
56079
- let existingBucketName;
56080
- try {
56081
- const existingStacks = await cf.describeStacks({ stackName });
56082
- if (existingStacks.Stacks.length > 0) {
56083
- const stack = existingStacks.Stacks[0];
56084
- const stackStatus = stack.StackStatus;
56085
- if (stackStatus === "DELETE_IN_PROGRESS") {
56086
- console.log("Previous stack is still being deleted, waiting...");
56087
- await cf.waitForStack(stackName, "stack-delete-complete");
56088
- stackExists = false;
56089
- } else if (stackStatus === "DELETE_COMPLETE") {
56090
- stackExists = false;
56091
- } else {
56092
- stackExists = true;
56093
- const outputs2 = stack.Outputs || [];
56094
- existingBucketName = outputs2.find((o) => o.OutputKey === "BucketName")?.OutputValue;
56095
- }
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;
56096
55867
  }
56097
- } catch (err) {
56098
- if (err.message?.includes("does not exist") || err.code === "ValidationError") {
56099
- stackExists = false;
56100
- } else {
56101
- throw err;
55868
+ if (options?.MaxRecords) {
55869
+ params.MaxRecords = options.MaxRecords;
56102
55870
  }
56103
- }
56104
- let finalBucket = existingBucketName || bucket;
56105
- if (!stackExists) {
56106
- const s32 = new S3Client2(region);
56107
- const cloudfront2 = new CloudFrontClient;
56108
- let hasExistingDistribution = false;
56109
- if (domain) {
56110
- try {
56111
- console.log(`Checking for existing CloudFront distributions with alias ${domain}...`);
56112
- const distributions = await cloudfront2.listDistributions();
56113
- for (const dist of distributions) {
56114
- let aliases2 = [];
56115
- if (dist.Aliases?.Items) {
56116
- if (Array.isArray(dist.Aliases.Items)) {
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) {
56713
+ let aliases2 = [];
56714
+ if (dist.Aliases?.Items) {
56715
+ if (Array.isArray(dist.Aliases.Items)) {
56117
56716
  aliases2 = dist.Aliases.Items;
56118
56717
  } else if (typeof dist.Aliases.Items === "object") {
56119
56718
  const cname = dist.Aliases.Items.CNAME;
@@ -73620,6 +74219,38 @@ class LambdaClient {
73620
74219
  });
73621
74220
  return result;
73622
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
+ }
73623
74254
  async waitForFunctionActive(functionName, maxWaitSeconds = 60) {
73624
74255
  const startTime = Date.now();
73625
74256
  const maxWaitMs = maxWaitSeconds * 1000;
@@ -73740,1863 +74371,1329 @@ class LambdaClient {
73740
74371
  queryParams.CompatibleArchitecture = params.CompatibleArchitecture;
73741
74372
  if (params?.MaxItems)
73742
74373
  queryParams.MaxItems = String(params.MaxItems);
73743
- if (params?.Marker)
73744
- queryParams.Marker = params.Marker;
73745
- const result = await this.client.request({
73746
- service: "lambda",
73747
- region: this.region,
73748
- method: "GET",
73749
- path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions`,
73750
- queryParams: Object.keys(queryParams).length > 0 ? queryParams : undefined,
73751
- headers: {
73752
- "Content-Type": "application/json"
73753
- }
73754
- });
73755
- return result;
73756
- }
73757
- async getLayerVersion(layerName, versionNumber) {
73758
- const result = await this.client.request({
73759
- service: "lambda",
73760
- region: this.region,
73761
- method: "GET",
73762
- path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
73763
- headers: {
73764
- "Content-Type": "application/json"
73765
- }
73766
- });
73767
- return result;
73768
- }
73769
- async addLayerVersionPermission(params) {
73770
- const { LayerName, VersionNumber, ...rest } = params;
73771
- const result = await this.client.request({
73772
- service: "lambda",
73773
- region: this.region,
73774
- method: "POST",
73775
- path: `/2018-10-31/layers/${encodeURIComponent(LayerName)}/versions/${VersionNumber}/policy`,
73776
- headers: {
73777
- "Content-Type": "application/json"
73778
- },
73779
- body: JSON.stringify(rest)
73780
- });
73781
- return result;
73782
- }
73783
- async deleteLayerVersion(layerName, versionNumber) {
73784
- await this.client.request({
73785
- service: "lambda",
73786
- region: this.region,
73787
- method: "DELETE",
73788
- path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
73789
- headers: {
73790
- "Content-Type": "application/json"
73791
- }
73792
- });
73793
- }
73794
- }
73795
- // src/aws/cloudwatch-logs.ts
73796
- init_client();
73797
-
73798
- class CloudWatchLogsClient {
73799
- client;
73800
- region;
73801
- constructor(region = "us-east-1", profile) {
73802
- this.region = region;
73803
- this.client = new AWSClient;
73804
- }
73805
- async describeLogStreams(options) {
73806
- const params = {
73807
- logGroupName: options.logGroupName
73808
- };
73809
- if (options.logStreamNamePrefix)
73810
- params.logStreamNamePrefix = options.logStreamNamePrefix;
73811
- if (options.orderBy)
73812
- params.orderBy = options.orderBy;
73813
- if (options.descending !== undefined)
73814
- params.descending = options.descending;
73815
- if (options.limit)
73816
- params.limit = options.limit;
73817
- const result = await this.client.request({
73818
- service: "logs",
73819
- region: this.region,
73820
- method: "POST",
73821
- path: "/",
73822
- headers: {
73823
- "X-Amz-Target": "Logs_20140328.DescribeLogStreams",
73824
- "Content-Type": "application/x-amz-json-1.1"
73825
- },
73826
- body: JSON.stringify(params)
73827
- });
73828
- return result;
73829
- }
73830
- async getLogEvents(options) {
73831
- const params = {
73832
- logGroupName: options.logGroupName,
73833
- logStreamName: options.logStreamName
73834
- };
73835
- if (options.startTime)
73836
- params.startTime = options.startTime;
73837
- if (options.endTime)
73838
- params.endTime = options.endTime;
73839
- if (options.limit)
73840
- params.limit = options.limit;
73841
- if (options.startFromHead !== undefined)
73842
- params.startFromHead = options.startFromHead;
73843
- const result = await this.client.request({
73844
- service: "logs",
73845
- region: this.region,
73846
- method: "POST",
73847
- path: "/",
73848
- headers: {
73849
- "X-Amz-Target": "Logs_20140328.GetLogEvents",
73850
- "Content-Type": "application/x-amz-json-1.1"
73851
- },
73852
- body: JSON.stringify(params)
73853
- });
73854
- return result;
73855
- }
73856
- async describeLogGroups(options) {
73857
- const params = {};
73858
- if (options?.logGroupNamePrefix)
73859
- params.logGroupNamePrefix = options.logGroupNamePrefix;
73860
- if (options?.limit)
73861
- params.limit = options.limit;
73862
- const result = await this.client.request({
73863
- service: "logs",
73864
- region: this.region,
73865
- method: "POST",
73866
- path: "/",
73867
- headers: {
73868
- "X-Amz-Target": "Logs_20140328.DescribeLogGroups",
73869
- "Content-Type": "application/x-amz-json-1.1"
73870
- },
73871
- body: JSON.stringify(params)
73872
- });
73873
- return result;
73874
- }
73875
- async deleteLogGroup(logGroupName) {
73876
- await this.client.request({
73877
- service: "logs",
73878
- region: this.region,
73879
- method: "POST",
73880
- path: "/",
73881
- headers: {
73882
- "X-Amz-Target": "Logs_20140328.DeleteLogGroup",
73883
- "Content-Type": "application/x-amz-json-1.1"
73884
- },
73885
- body: JSON.stringify({ logGroupName })
73886
- });
73887
- }
73888
- async filterLogEvents(options) {
73889
- const params = {
73890
- logGroupName: options.logGroupName
73891
- };
73892
- if (options.logStreamNames)
73893
- params.logStreamNames = options.logStreamNames;
73894
- if (options.startTime)
73895
- params.startTime = options.startTime;
73896
- if (options.endTime)
73897
- params.endTime = options.endTime;
73898
- if (options.filterPattern)
73899
- params.filterPattern = options.filterPattern;
73900
- if (options.limit)
73901
- params.limit = options.limit;
73902
- const result = await this.client.request({
73903
- service: "logs",
73904
- region: this.region,
73905
- method: "POST",
73906
- path: "/",
73907
- headers: {
73908
- "X-Amz-Target": "Logs_20140328.FilterLogEvents",
73909
- "Content-Type": "application/x-amz-json-1.1"
73910
- },
73911
- body: JSON.stringify(params)
73912
- });
73913
- return result;
73914
- }
73915
- }
73916
- // src/aws/connect.ts
73917
- init_client();
73918
-
73919
- class ConnectClient {
73920
- client;
73921
- region;
73922
- constructor(region = "us-east-1") {
73923
- this.region = region;
73924
- this.client = new AWSClient;
73925
- }
73926
- async createInstance(params) {
73927
- const body = {
73928
- InstanceAlias: params.InstanceAlias,
73929
- IdentityManagementType: params.IdentityManagementType || "CONNECT_MANAGED",
73930
- InboundCallsEnabled: params.InboundCallsEnabled ?? true,
73931
- OutboundCallsEnabled: params.OutboundCallsEnabled ?? true
73932
- };
73933
- if (params.DirectoryId)
73934
- body.DirectoryId = params.DirectoryId;
73935
- if (params.ClientToken)
73936
- body.ClientToken = params.ClientToken;
73937
- if (params.Tags)
73938
- body.Tags = params.Tags;
73939
- const result = await this.client.request({
73940
- service: "connect",
73941
- region: this.region,
73942
- method: "PUT",
73943
- path: "/instance",
73944
- headers: {
73945
- "Content-Type": "application/json"
73946
- },
73947
- body: JSON.stringify(body)
73948
- });
73949
- return result;
73950
- }
73951
- async deleteInstance(instanceId) {
73952
- await this.client.request({
73953
- service: "connect",
73954
- region: this.region,
73955
- method: "DELETE",
73956
- path: `/instance/${instanceId}`
73957
- });
73958
- }
73959
- async describeInstance(instanceId) {
73960
- const result = await this.client.request({
73961
- service: "connect",
73962
- region: this.region,
73963
- method: "GET",
73964
- path: `/instance/${instanceId}`
73965
- });
73966
- return result.Instance || result;
73967
- }
73968
- async listInstances(params) {
73969
- const queryParams = {};
73970
- if (params?.MaxResults)
73971
- queryParams.maxResults = String(params.MaxResults);
73972
- if (params?.NextToken)
73973
- queryParams.nextToken = params.NextToken;
73974
- const result = await this.client.request({
73975
- service: "connect",
73976
- region: this.region,
73977
- method: "GET",
73978
- path: "/instance",
73979
- queryParams
73980
- });
73981
- return result;
73982
- }
73983
- async searchAvailablePhoneNumbers(params) {
73984
- const body = {
73985
- TargetArn: params.TargetArn,
73986
- PhoneNumberCountryCode: params.PhoneNumberCountryCode,
73987
- PhoneNumberType: params.PhoneNumberType
73988
- };
73989
- if (params.PhoneNumberPrefix)
73990
- body.PhoneNumberPrefix = params.PhoneNumberPrefix;
73991
- if (params.MaxResults)
73992
- body.MaxResults = params.MaxResults;
73993
- if (params.NextToken)
73994
- body.NextToken = params.NextToken;
73995
- const result = await this.client.request({
73996
- service: "connect",
73997
- region: this.region,
73998
- method: "POST",
73999
- path: "/phone-number/search-available",
74000
- headers: {
74001
- "Content-Type": "application/json"
74002
- },
74003
- body: JSON.stringify(body)
74004
- });
74005
- return result;
74006
- }
74007
- async claimPhoneNumber(params) {
74008
- const body = {
74009
- TargetArn: params.TargetArn,
74010
- PhoneNumber: params.PhoneNumber
74011
- };
74012
- if (params.PhoneNumberDescription)
74013
- body.PhoneNumberDescription = params.PhoneNumberDescription;
74014
- if (params.Tags)
74015
- body.Tags = params.Tags;
74016
- if (params.ClientToken)
74017
- body.ClientToken = params.ClientToken;
74018
- const result = await this.client.request({
74019
- service: "connect",
74020
- region: this.region,
74021
- method: "POST",
74022
- path: "/phone-number/claim",
74023
- headers: {
74024
- "Content-Type": "application/json"
74025
- },
74026
- body: JSON.stringify(body)
74027
- });
74028
- return result;
74029
- }
74030
- async releasePhoneNumber(phoneNumberId, clientToken) {
74031
- const queryParams = {};
74032
- if (clientToken)
74033
- queryParams.clientToken = clientToken;
74034
- await this.client.request({
74035
- service: "connect",
74036
- region: this.region,
74037
- method: "DELETE",
74038
- path: `/phone-number/${phoneNumberId}`,
74039
- queryParams
74040
- });
74041
- }
74042
- async listPhoneNumbers(params) {
74043
- const body = {};
74044
- if (params.TargetArn)
74045
- body.TargetArn = params.TargetArn;
74046
- if (params.InstanceId)
74047
- body.InstanceId = params.InstanceId;
74048
- if (params.PhoneNumberTypes)
74049
- body.PhoneNumberTypes = params.PhoneNumberTypes;
74050
- if (params.PhoneNumberCountryCodes)
74051
- body.PhoneNumberCountryCodes = params.PhoneNumberCountryCodes;
74052
- if (params.MaxResults)
74053
- body.MaxResults = params.MaxResults;
74054
- if (params.NextToken)
74055
- body.NextToken = params.NextToken;
74056
- const result = await this.client.request({
74057
- service: "connect",
74058
- region: this.region,
74059
- method: "POST",
74060
- path: "/phone-number/list",
74061
- headers: {
74062
- "Content-Type": "application/json"
74063
- },
74064
- body: JSON.stringify(body)
74065
- });
74066
- return result;
74067
- }
74068
- async createContactFlow(params) {
74069
- const body = {
74070
- Name: params.Name,
74071
- Type: params.Type,
74072
- Content: params.Content
74073
- };
74074
- if (params.Description)
74075
- body.Description = params.Description;
74076
- if (params.Tags)
74077
- body.Tags = params.Tags;
74078
- const result = await this.client.request({
74079
- service: "connect",
74080
- region: this.region,
74081
- method: "PUT",
74082
- path: `/contact-flows/${params.InstanceId}`,
74083
- headers: {
74084
- "Content-Type": "application/json"
74085
- },
74086
- body: JSON.stringify(body)
74087
- });
74088
- return result;
74089
- }
74090
- async updateContactFlowContent(params) {
74091
- await this.client.request({
74092
- service: "connect",
74093
- region: this.region,
74094
- method: "POST",
74095
- path: `/contact-flows/${params.InstanceId}/${params.ContactFlowId}/content`,
74096
- headers: {
74097
- "Content-Type": "application/json"
74098
- },
74099
- body: JSON.stringify({ Content: params.Content })
74100
- });
74101
- }
74102
- async listContactFlows(params) {
74103
- const queryParams = {};
74104
- if (params.ContactFlowTypes)
74105
- queryParams.contactFlowTypes = params.ContactFlowTypes.join(",");
74106
- if (params.MaxResults)
74107
- queryParams.maxResults = String(params.MaxResults);
74108
- if (params.NextToken)
74109
- queryParams.nextToken = params.NextToken;
74374
+ if (params?.Marker)
74375
+ queryParams.Marker = params.Marker;
74110
74376
  const result = await this.client.request({
74111
- service: "connect",
74377
+ service: "lambda",
74112
74378
  region: this.region,
74113
74379
  method: "GET",
74114
- path: `/contact-flows-summary/${params.InstanceId}`,
74115
- 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
+ }
74116
74385
  });
74117
74386
  return result;
74118
74387
  }
74119
- async createQueue(params) {
74120
- const body = {
74121
- Name: params.Name,
74122
- HoursOfOperationId: params.HoursOfOperationId
74123
- };
74124
- if (params.Description)
74125
- body.Description = params.Description;
74126
- if (params.MaxContacts)
74127
- body.MaxContacts = params.MaxContacts;
74128
- if (params.OutboundCallerConfig)
74129
- body.OutboundCallerConfig = params.OutboundCallerConfig;
74130
- if (params.Tags)
74131
- body.Tags = params.Tags;
74388
+ async getLayerVersion(layerName, versionNumber) {
74132
74389
  const result = await this.client.request({
74133
- service: "connect",
74390
+ service: "lambda",
74134
74391
  region: this.region,
74135
- method: "PUT",
74136
- path: `/queues/${params.InstanceId}`,
74392
+ method: "GET",
74393
+ path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
74137
74394
  headers: {
74138
74395
  "Content-Type": "application/json"
74139
- },
74140
- body: JSON.stringify(body)
74396
+ }
74141
74397
  });
74142
74398
  return result;
74143
74399
  }
74144
- async createHoursOfOperation(params) {
74145
- const body = {
74146
- Name: params.Name,
74147
- TimeZone: params.TimeZone,
74148
- Config: params.Config
74149
- };
74150
- if (params.Description)
74151
- body.Description = params.Description;
74152
- if (params.Tags)
74153
- body.Tags = params.Tags;
74400
+ async addLayerVersionPermission(params) {
74401
+ const { LayerName, VersionNumber, ...rest } = params;
74154
74402
  const result = await this.client.request({
74155
- service: "connect",
74403
+ service: "lambda",
74156
74404
  region: this.region,
74157
- method: "PUT",
74158
- path: `/hours-of-operations/${params.InstanceId}`,
74405
+ method: "POST",
74406
+ path: `/2018-10-31/layers/${encodeURIComponent(LayerName)}/versions/${VersionNumber}/policy`,
74159
74407
  headers: {
74160
74408
  "Content-Type": "application/json"
74161
74409
  },
74162
- body: JSON.stringify(body)
74410
+ body: JSON.stringify(rest)
74163
74411
  });
74164
74412
  return result;
74165
74413
  }
74166
- async associatePhoneNumberContactFlow(params) {
74414
+ async deleteLayerVersion(layerName, versionNumber) {
74167
74415
  await this.client.request({
74168
- service: "connect",
74416
+ service: "lambda",
74169
74417
  region: this.region,
74170
- method: "PUT",
74171
- path: `/phone-number/${params.PhoneNumberId}/contact-flow`,
74418
+ method: "DELETE",
74419
+ path: `/2018-10-31/layers/${encodeURIComponent(layerName)}/versions/${versionNumber}`,
74172
74420
  headers: {
74173
74421
  "Content-Type": "application/json"
74174
- },
74175
- body: JSON.stringify({
74176
- InstanceId: params.InstanceId,
74177
- ContactFlowId: params.ContactFlowId
74178
- })
74422
+ }
74179
74423
  });
74180
74424
  }
74181
- async createRoutingProfile(params) {
74182
- const body = {
74183
- Name: params.Name,
74184
- DefaultOutboundQueueId: params.DefaultOutboundQueueId,
74185
- 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
74186
74439
  };
74187
- if (params.Description)
74188
- body.Description = params.Description;
74189
- if (params.QueueConfigs)
74190
- body.QueueConfigs = params.QueueConfigs;
74191
- if (params.Tags)
74192
- 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;
74193
74448
  const result = await this.client.request({
74194
- service: "connect",
74449
+ service: "logs",
74195
74450
  region: this.region,
74196
- method: "PUT",
74197
- path: `/routing-profiles/${params.InstanceId}`,
74451
+ method: "POST",
74452
+ path: "/",
74198
74453
  headers: {
74199
- "Content-Type": "application/json"
74454
+ "X-Amz-Target": "Logs_20140328.DescribeLogStreams",
74455
+ "Content-Type": "application/x-amz-json-1.1"
74200
74456
  },
74201
- body: JSON.stringify(body)
74457
+ body: JSON.stringify(params)
74202
74458
  });
74203
74459
  return result;
74204
74460
  }
74205
- async instanceExists(instanceAlias) {
74206
- try {
74207
- const result = await this.listInstances({ MaxResults: 100 });
74208
- return result.InstanceSummaryList?.some((instance) => instance.InstanceAlias === instanceAlias) || false;
74209
- } catch {
74210
- return false;
74211
- }
74212
- }
74213
- async startOutboundVoiceContact(params) {
74214
- const body = {
74215
- ContactFlowId: params.ContactFlowId,
74216
- DestinationPhoneNumber: params.DestinationPhoneNumber
74461
+ async getLogEvents(options) {
74462
+ const params = {
74463
+ logGroupName: options.logGroupName,
74464
+ logStreamName: options.logStreamName
74217
74465
  };
74218
- if (params.SourcePhoneNumber)
74219
- body.SourcePhoneNumber = params.SourcePhoneNumber;
74220
- if (params.QueueId)
74221
- body.QueueId = params.QueueId;
74222
- if (params.Attributes)
74223
- body.Attributes = params.Attributes;
74224
- if (params.AnswerMachineDetectionConfig)
74225
- body.AnswerMachineDetectionConfig = params.AnswerMachineDetectionConfig;
74226
- if (params.CampaignId)
74227
- body.CampaignId = params.CampaignId;
74228
- if (params.TrafficType)
74229
- body.TrafficType = params.TrafficType;
74230
- if (params.ClientToken)
74231
- 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;
74232
74474
  const result = await this.client.request({
74233
- service: "connect",
74475
+ service: "logs",
74234
74476
  region: this.region,
74235
- method: "PUT",
74236
- path: `/contact/outbound-voice/${params.InstanceId}`,
74477
+ method: "POST",
74478
+ path: "/",
74237
74479
  headers: {
74238
- "Content-Type": "application/json"
74480
+ "X-Amz-Target": "Logs_20140328.GetLogEvents",
74481
+ "Content-Type": "application/x-amz-json-1.1"
74239
74482
  },
74240
- body: JSON.stringify(body)
74483
+ body: JSON.stringify(params)
74241
74484
  });
74242
74485
  return result;
74243
74486
  }
74244
- async makeCall(params) {
74245
- return this.startOutboundVoiceContact({
74246
- InstanceId: params.instanceId,
74247
- ContactFlowId: params.contactFlowId,
74248
- DestinationPhoneNumber: params.to,
74249
- SourcePhoneNumber: params.from,
74250
- Attributes: params.attributes
74251
- });
74252
- }
74253
- async stopContact(params) {
74254
- await this.client.request({
74255
- 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",
74256
74495
  region: this.region,
74257
74496
  method: "POST",
74258
- 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)
74259
74503
  });
74504
+ return result;
74260
74505
  }
74261
- async describeContact(params) {
74262
- return this.client.request({
74263
- service: "connect",
74506
+ async deleteLogGroup(logGroupName) {
74507
+ await this.client.request({
74508
+ service: "logs",
74264
74509
  region: this.region,
74265
- method: "GET",
74266
- 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 })
74267
74517
  });
74268
74518
  }
74269
- async updateContactAttributes(params) {
74270
- await this.client.request({
74271
- 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",
74272
74535
  region: this.region,
74273
74536
  method: "POST",
74274
- path: `/contact/attributes/${params.InstanceId}`,
74537
+ path: "/",
74275
74538
  headers: {
74276
- "Content-Type": "application/json"
74539
+ "X-Amz-Target": "Logs_20140328.FilterLogEvents",
74540
+ "Content-Type": "application/x-amz-json-1.1"
74277
74541
  },
74278
- body: JSON.stringify({
74279
- InitialContactId: params.InitialContactId,
74280
- Attributes: params.Attributes
74281
- })
74542
+ body: JSON.stringify(params)
74282
74543
  });
74544
+ return result;
74283
74545
  }
74284
- 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) {
74285
74558
  const body = {
74286
- Username: params.Username,
74287
- PhoneConfig: params.PhoneConfig,
74288
- SecurityProfileIds: params.SecurityProfileIds,
74289
- RoutingProfileId: params.RoutingProfileId
74559
+ InstanceAlias: params.InstanceAlias,
74560
+ IdentityManagementType: params.IdentityManagementType || "CONNECT_MANAGED",
74561
+ InboundCallsEnabled: params.InboundCallsEnabled ?? true,
74562
+ OutboundCallsEnabled: params.OutboundCallsEnabled ?? true
74290
74563
  };
74291
- if (params.Password)
74292
- body.Password = params.Password;
74293
- if (params.IdentityInfo)
74294
- body.IdentityInfo = params.IdentityInfo;
74295
- if (params.DirectoryUserId)
74296
- body.DirectoryUserId = params.DirectoryUserId;
74297
- if (params.HierarchyGroupId)
74298
- body.HierarchyGroupId = params.HierarchyGroupId;
74564
+ if (params.DirectoryId)
74565
+ body.DirectoryId = params.DirectoryId;
74566
+ if (params.ClientToken)
74567
+ body.ClientToken = params.ClientToken;
74299
74568
  if (params.Tags)
74300
74569
  body.Tags = params.Tags;
74301
- return this.client.request({
74570
+ const result = await this.client.request({
74302
74571
  service: "connect",
74303
74572
  region: this.region,
74304
74573
  method: "PUT",
74305
- path: `/users/${params.InstanceId}`,
74574
+ path: "/instance",
74306
74575
  headers: {
74307
74576
  "Content-Type": "application/json"
74308
74577
  },
74309
74578
  body: JSON.stringify(body)
74310
74579
  });
74580
+ return result;
74311
74581
  }
74312
- async deleteUser(params) {
74582
+ async deleteInstance(instanceId) {
74313
74583
  await this.client.request({
74314
74584
  service: "connect",
74315
74585
  region: this.region,
74316
74586
  method: "DELETE",
74317
- path: `/users/${params.InstanceId}/${params.UserId}`
74587
+ path: `/instance/${instanceId}`
74318
74588
  });
74319
74589
  }
74320
- async listUsers(params) {
74321
- const queryParams = {};
74322
- if (params.NextToken)
74323
- queryParams.nextToken = params.NextToken;
74324
- if (params.MaxResults)
74325
- queryParams.maxResults = String(params.MaxResults);
74326
- return this.client.request({
74590
+ async describeInstance(instanceId) {
74591
+ const result = await this.client.request({
74327
74592
  service: "connect",
74328
74593
  region: this.region,
74329
74594
  method: "GET",
74330
- path: `/users-summary/${params.InstanceId}`,
74331
- queryParams
74332
- });
74333
- }
74334
- async createPrompt(params) {
74335
- const body = {
74336
- Name: params.Name,
74337
- S3Uri: params.S3Uri
74338
- };
74339
- if (params.Description)
74340
- body.Description = params.Description;
74341
- if (params.Tags)
74342
- body.Tags = params.Tags;
74343
- return this.client.request({
74344
- service: "connect",
74345
- region: this.region,
74346
- method: "PUT",
74347
- path: `/prompts/${params.InstanceId}`,
74348
- headers: {
74349
- "Content-Type": "application/json"
74350
- },
74351
- body: JSON.stringify(body)
74595
+ path: `/instance/${instanceId}`
74352
74596
  });
74597
+ return result.Instance || result;
74353
74598
  }
74354
- async listPrompts(params) {
74599
+ async listInstances(params) {
74355
74600
  const queryParams = {};
74356
- if (params.NextToken)
74357
- queryParams.nextToken = params.NextToken;
74358
- if (params.MaxResults)
74601
+ if (params?.MaxResults)
74359
74602
  queryParams.maxResults = String(params.MaxResults);
74360
- return this.client.request({
74603
+ if (params?.NextToken)
74604
+ queryParams.nextToken = params.NextToken;
74605
+ const result = await this.client.request({
74361
74606
  service: "connect",
74362
74607
  region: this.region,
74363
74608
  method: "GET",
74364
- path: `/prompts-summary/${params.InstanceId}`,
74609
+ path: "/instance",
74365
74610
  queryParams
74366
74611
  });
74612
+ return result;
74367
74613
  }
74368
- async createQuickConnect(params) {
74614
+ async searchAvailablePhoneNumbers(params) {
74369
74615
  const body = {
74370
- Name: params.Name,
74371
- QuickConnectConfig: params.QuickConnectConfig
74616
+ TargetArn: params.TargetArn,
74617
+ PhoneNumberCountryCode: params.PhoneNumberCountryCode,
74618
+ PhoneNumberType: params.PhoneNumberType
74372
74619
  };
74373
- if (params.Description)
74374
- body.Description = params.Description;
74375
- if (params.Tags)
74376
- body.Tags = params.Tags;
74377
- return this.client.request({
74378
- service: "connect",
74379
- region: this.region,
74380
- method: "PUT",
74381
- path: `/quick-connects/${params.InstanceId}`,
74382
- headers: {
74383
- "Content-Type": "application/json"
74384
- },
74385
- body: JSON.stringify(body)
74386
- });
74387
- }
74388
- async startChatContact(params) {
74389
- return this.client.request({
74390
- service: "connect",
74391
- region: this.region,
74392
- method: "PUT",
74393
- path: `/contact/chat/${params.InstanceId}`,
74394
- headers: {
74395
- "Content-Type": "application/json"
74396
- },
74397
- body: JSON.stringify(params)
74398
- });
74399
- }
74400
- async startTaskContact(params) {
74401
- return this.client.request({
74402
- service: "connect",
74403
- region: this.region,
74404
- method: "PUT",
74405
- path: `/contact/task/${params.InstanceId}`,
74406
- headers: {
74407
- "Content-Type": "application/json"
74408
- },
74409
- body: JSON.stringify(params)
74410
- });
74411
- }
74412
- createOutboundIvrFlow(params) {
74413
- const voiceId = params.voiceId || "Joanna";
74414
- return JSON.stringify({
74415
- Version: "2019-10-30",
74416
- StartAction: "play-prompt",
74417
- Actions: {
74418
- "play-prompt": {
74419
- Type: "MessageParticipant",
74420
- Parameters: {
74421
- Text: params.message,
74422
- TextToSpeechVoice: voiceId,
74423
- TextToSpeechEngine: "neural"
74424
- },
74425
- Transitions: {
74426
- NextAction: "disconnect",
74427
- Errors: [
74428
- { NextAction: "disconnect", ErrorType: "NoMatchingError" }
74429
- ]
74430
- }
74431
- },
74432
- disconnect: {
74433
- Type: "DisconnectParticipant",
74434
- Parameters: {},
74435
- Transitions: {}
74436
- }
74437
- }
74438
- });
74439
- }
74440
- createInputCollectionFlow(params) {
74441
- const voiceId = params.voiceId || "Joanna";
74442
- const timeout = params.inputTimeout || 5;
74443
- const maxDigits = params.maxDigits || 1;
74444
- return JSON.stringify({
74445
- Version: "2019-10-30",
74446
- StartAction: "get-input",
74447
- Actions: {
74448
- "get-input": {
74449
- Type: "GetParticipantInput",
74450
- Parameters: {
74451
- Text: params.promptMessage,
74452
- TextToSpeechVoice: voiceId,
74453
- TextToSpeechEngine: "neural",
74454
- InputTimeLimitSeconds: String(timeout),
74455
- MaxDigits: maxDigits,
74456
- EncryptEntry: false
74457
- },
74458
- Transitions: {
74459
- NextAction: params.successNextAction || "disconnect",
74460
- Conditions: [],
74461
- Errors: [
74462
- { NextAction: "disconnect", ErrorType: "NoMatchingCondition" },
74463
- { NextAction: "disconnect", ErrorType: "NoMatchingError" }
74464
- ]
74465
- }
74466
- },
74467
- disconnect: {
74468
- Type: "DisconnectParticipant",
74469
- Parameters: {},
74470
- Transitions: {}
74471
- }
74472
- }
74473
- });
74474
- }
74475
- async getCurrentMetricData(params) {
74476
- return this.client.request({
74477
- service: "connect",
74478
- region: this.region,
74479
- method: "POST",
74480
- path: `/metrics/current/${params.InstanceId}`,
74481
- headers: {
74482
- "Content-Type": "application/json"
74483
- },
74484
- body: JSON.stringify(params)
74485
- });
74486
- }
74487
- }
74488
- // src/aws/elbv2.ts
74489
- init_client();
74490
-
74491
- class ELBv2Client {
74492
- client;
74493
- region;
74494
- constructor(region = "us-east-1") {
74495
- this.region = region;
74496
- this.client = new AWSClient;
74497
- }
74498
- async describeLoadBalancers(options) {
74499
- const params = {};
74500
- if (options?.LoadBalancerArns) {
74501
- options.LoadBalancerArns.forEach((arn, index) => {
74502
- params[`LoadBalancerArns.member.${index + 1}`] = arn;
74503
- });
74504
- }
74505
- if (options?.Names) {
74506
- options.Names.forEach((name, index) => {
74507
- params[`Names.member.${index + 1}`] = name;
74508
- });
74509
- }
74510
- if (options?.Marker) {
74511
- params.Marker = options.Marker;
74512
- }
74513
- if (options?.PageSize) {
74514
- params.PageSize = options.PageSize;
74515
- }
74516
- const result = await this.client.request({
74517
- service: "elasticloadbalancing",
74518
- region: this.region,
74519
- method: "POST",
74520
- path: "/",
74521
- headers: {
74522
- "Content-Type": "application/x-www-form-urlencoded"
74523
- },
74524
- body: this.buildFormBody("DescribeLoadBalancers", params)
74525
- });
74526
- return this.normalizeResult(result, "DescribeLoadBalancersResult");
74527
- }
74528
- async describeTargetGroups(options) {
74529
- const params = {};
74530
- if (options?.LoadBalancerArn) {
74531
- params.LoadBalancerArn = options.LoadBalancerArn;
74532
- }
74533
- if (options?.TargetGroupArns) {
74534
- options.TargetGroupArns.forEach((arn, index) => {
74535
- params[`TargetGroupArns.member.${index + 1}`] = arn;
74536
- });
74537
- }
74538
- if (options?.Names) {
74539
- options.Names.forEach((name, index) => {
74540
- params[`Names.member.${index + 1}`] = name;
74541
- });
74542
- }
74543
- if (options?.Marker) {
74544
- params.Marker = options.Marker;
74545
- }
74546
- if (options?.PageSize) {
74547
- params.PageSize = options.PageSize;
74548
- }
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;
74549
74626
  const result = await this.client.request({
74550
- service: "elasticloadbalancing",
74627
+ service: "connect",
74551
74628
  region: this.region,
74552
74629
  method: "POST",
74553
- path: "/",
74630
+ path: "/phone-number/search-available",
74554
74631
  headers: {
74555
- "Content-Type": "application/x-www-form-urlencoded"
74632
+ "Content-Type": "application/json"
74556
74633
  },
74557
- body: this.buildFormBody("DescribeTargetGroups", params)
74634
+ body: JSON.stringify(body)
74558
74635
  });
74559
- return this.normalizeResult(result, "DescribeTargetGroupsResult");
74636
+ return result;
74560
74637
  }
74561
- async describeTargetHealth(options) {
74562
- const params = {
74563
- TargetGroupArn: options.TargetGroupArn
74638
+ async claimPhoneNumber(params) {
74639
+ const body = {
74640
+ TargetArn: params.TargetArn,
74641
+ PhoneNumber: params.PhoneNumber
74564
74642
  };
74565
- if (options.Targets) {
74566
- options.Targets.forEach((target, index) => {
74567
- params[`Targets.member.${index + 1}.Id`] = target.Id;
74568
- if (target.Port) {
74569
- params[`Targets.member.${index + 1}.Port`] = target.Port;
74570
- }
74571
- if (target.AvailabilityZone) {
74572
- params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
74573
- }
74574
- });
74575
- }
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;
74576
74649
  const result = await this.client.request({
74577
- service: "elasticloadbalancing",
74650
+ service: "connect",
74578
74651
  region: this.region,
74579
74652
  method: "POST",
74580
- path: "/",
74653
+ path: "/phone-number/claim",
74581
74654
  headers: {
74582
- "Content-Type": "application/x-www-form-urlencoded"
74655
+ "Content-Type": "application/json"
74583
74656
  },
74584
- body: this.buildFormBody("DescribeTargetHealth", params)
74657
+ body: JSON.stringify(body)
74585
74658
  });
74586
- return this.normalizeResult(result, "DescribeTargetHealthResult");
74659
+ return result;
74587
74660
  }
74588
- async describeListeners(options) {
74589
- const params = {};
74590
- if (options?.LoadBalancerArn) {
74591
- params.LoadBalancerArn = options.LoadBalancerArn;
74592
- }
74593
- if (options?.ListenerArns) {
74594
- options.ListenerArns.forEach((arn, index) => {
74595
- params[`ListenerArns.member.${index + 1}`] = arn;
74596
- });
74597
- }
74598
- if (options?.Marker) {
74599
- params.Marker = options.Marker;
74600
- }
74601
- if (options?.PageSize) {
74602
- params.PageSize = options.PageSize;
74603
- }
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;
74604
74687
  const result = await this.client.request({
74605
- service: "elasticloadbalancing",
74688
+ service: "connect",
74606
74689
  region: this.region,
74607
74690
  method: "POST",
74608
- path: "/",
74691
+ path: "/phone-number/list",
74609
74692
  headers: {
74610
- "Content-Type": "application/x-www-form-urlencoded"
74693
+ "Content-Type": "application/json"
74611
74694
  },
74612
- body: this.buildFormBody("DescribeListeners", params)
74695
+ body: JSON.stringify(body)
74613
74696
  });
74614
- return this.normalizeResult(result, "DescribeListenersResult");
74697
+ return result;
74615
74698
  }
74616
- async describeRules(options) {
74617
- const params = {};
74618
- if (options?.ListenerArn) {
74619
- params.ListenerArn = options.ListenerArn;
74620
- }
74621
- if (options?.RuleArns) {
74622
- options.RuleArns.forEach((arn, index) => {
74623
- params[`RuleArns.member.${index + 1}`] = arn;
74624
- });
74625
- }
74626
- if (options?.Marker) {
74627
- params.Marker = options.Marker;
74628
- }
74629
- if (options?.PageSize) {
74630
- params.PageSize = options.PageSize;
74631
- }
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;
74632
74709
  const result = await this.client.request({
74633
- service: "elasticloadbalancing",
74710
+ service: "connect",
74634
74711
  region: this.region,
74635
- method: "POST",
74636
- path: "/",
74712
+ method: "PUT",
74713
+ path: `/contact-flows/${params.InstanceId}`,
74637
74714
  headers: {
74638
- "Content-Type": "application/x-www-form-urlencoded"
74715
+ "Content-Type": "application/json"
74639
74716
  },
74640
- body: this.buildFormBody("DescribeRules", params)
74717
+ body: JSON.stringify(body)
74641
74718
  });
74642
- return this.normalizeResult(result, "DescribeRulesResult");
74719
+ return result;
74643
74720
  }
74644
- async describeLoadBalancerAttributes(loadBalancerArn) {
74645
- const params = {
74646
- LoadBalancerArn: loadBalancerArn
74647
- };
74648
- const result = await this.client.request({
74649
- service: "elasticloadbalancing",
74721
+ async updateContactFlowContent(params) {
74722
+ await this.client.request({
74723
+ service: "connect",
74650
74724
  region: this.region,
74651
74725
  method: "POST",
74652
- path: "/",
74726
+ path: `/contact-flows/${params.InstanceId}/${params.ContactFlowId}/content`,
74653
74727
  headers: {
74654
- "Content-Type": "application/x-www-form-urlencoded"
74728
+ "Content-Type": "application/json"
74655
74729
  },
74656
- body: this.buildFormBody("DescribeLoadBalancerAttributes", params)
74730
+ body: JSON.stringify({ Content: params.Content })
74657
74731
  });
74658
- return this.normalizeResult(result, "DescribeLoadBalancerAttributesResult");
74659
74732
  }
74660
- async describeTargetGroupAttributes(targetGroupArn) {
74661
- const params = {
74662
- 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
74663
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;
74664
74763
  const result = await this.client.request({
74665
- service: "elasticloadbalancing",
74764
+ service: "connect",
74666
74765
  region: this.region,
74667
- method: "POST",
74668
- path: "/",
74766
+ method: "PUT",
74767
+ path: `/queues/${params.InstanceId}`,
74669
74768
  headers: {
74670
- "Content-Type": "application/x-www-form-urlencoded"
74769
+ "Content-Type": "application/json"
74671
74770
  },
74672
- body: this.buildFormBody("DescribeTargetGroupAttributes", params)
74771
+ body: JSON.stringify(body)
74673
74772
  });
74674
- return this.normalizeResult(result, "DescribeTargetGroupAttributesResult");
74773
+ return result;
74675
74774
  }
74676
- async createLoadBalancer(options) {
74677
- const params = {
74678
- Name: options.Name
74775
+ async createHoursOfOperation(params) {
74776
+ const body = {
74777
+ Name: params.Name,
74778
+ TimeZone: params.TimeZone,
74779
+ Config: params.Config
74679
74780
  };
74680
- if (options.Subnets) {
74681
- options.Subnets.forEach((subnet, index) => {
74682
- params[`Subnets.member.${index + 1}`] = subnet;
74683
- });
74684
- }
74685
- if (options.SubnetMappings) {
74686
- options.SubnetMappings.forEach((mapping, index) => {
74687
- params[`SubnetMappings.member.${index + 1}.SubnetId`] = mapping.SubnetId;
74688
- if (mapping.AllocationId) {
74689
- params[`SubnetMappings.member.${index + 1}.AllocationId`] = mapping.AllocationId;
74690
- }
74691
- if (mapping.PrivateIPv4Address) {
74692
- params[`SubnetMappings.member.${index + 1}.PrivateIPv4Address`] = mapping.PrivateIPv4Address;
74693
- }
74694
- if (mapping.IPv6Address) {
74695
- params[`SubnetMappings.member.${index + 1}.IPv6Address`] = mapping.IPv6Address;
74696
- }
74697
- });
74698
- }
74699
- if (options.SecurityGroups) {
74700
- options.SecurityGroups.forEach((sg, index) => {
74701
- params[`SecurityGroups.member.${index + 1}`] = sg;
74702
- });
74703
- }
74704
- if (options.Scheme) {
74705
- params.Scheme = options.Scheme;
74706
- }
74707
- if (options.Type) {
74708
- params.Type = options.Type;
74709
- }
74710
- if (options.IpAddressType) {
74711
- params.IpAddressType = options.IpAddressType;
74712
- }
74713
- if (options.Tags) {
74714
- options.Tags.forEach((tag, index) => {
74715
- params[`Tags.member.${index + 1}.Key`] = tag.Key;
74716
- params[`Tags.member.${index + 1}.Value`] = tag.Value;
74717
- });
74718
- }
74781
+ if (params.Description)
74782
+ body.Description = params.Description;
74783
+ if (params.Tags)
74784
+ body.Tags = params.Tags;
74719
74785
  const result = await this.client.request({
74720
- service: "elasticloadbalancing",
74786
+ service: "connect",
74721
74787
  region: this.region,
74722
- method: "POST",
74723
- path: "/",
74788
+ method: "PUT",
74789
+ path: `/hours-of-operations/${params.InstanceId}`,
74724
74790
  headers: {
74725
- "Content-Type": "application/x-www-form-urlencoded"
74791
+ "Content-Type": "application/json"
74726
74792
  },
74727
- body: this.buildFormBody("CreateLoadBalancer", params)
74793
+ body: JSON.stringify(body)
74728
74794
  });
74729
- return this.normalizeResult(result, "CreateLoadBalancerResult");
74795
+ return result;
74730
74796
  }
74731
- async deleteLoadBalancer(loadBalancerArn) {
74732
- const params = {
74733
- LoadBalancerArn: loadBalancerArn
74734
- };
74797
+ async associatePhoneNumberContactFlow(params) {
74735
74798
  await this.client.request({
74736
- service: "elasticloadbalancing",
74799
+ service: "connect",
74737
74800
  region: this.region,
74738
- method: "POST",
74739
- path: "/",
74801
+ method: "PUT",
74802
+ path: `/phone-number/${params.PhoneNumberId}/contact-flow`,
74740
74803
  headers: {
74741
- "Content-Type": "application/x-www-form-urlencoded"
74804
+ "Content-Type": "application/json"
74742
74805
  },
74743
- body: this.buildFormBody("DeleteLoadBalancer", params)
74806
+ body: JSON.stringify({
74807
+ InstanceId: params.InstanceId,
74808
+ ContactFlowId: params.ContactFlowId
74809
+ })
74744
74810
  });
74745
74811
  }
74746
- async createTargetGroup(options) {
74747
- const params = {
74748
- Name: options.Name
74812
+ async createRoutingProfile(params) {
74813
+ const body = {
74814
+ Name: params.Name,
74815
+ DefaultOutboundQueueId: params.DefaultOutboundQueueId,
74816
+ MediaConcurrencies: params.MediaConcurrencies
74749
74817
  };
74750
- if (options.Protocol)
74751
- params.Protocol = options.Protocol;
74752
- if (options.ProtocolVersion)
74753
- params.ProtocolVersion = options.ProtocolVersion;
74754
- if (options.Port)
74755
- params.Port = options.Port;
74756
- if (options.VpcId)
74757
- params.VpcId = options.VpcId;
74758
- if (options.HealthCheckProtocol)
74759
- params.HealthCheckProtocol = options.HealthCheckProtocol;
74760
- if (options.HealthCheckPort)
74761
- params.HealthCheckPort = options.HealthCheckPort;
74762
- if (options.HealthCheckEnabled !== undefined)
74763
- params.HealthCheckEnabled = options.HealthCheckEnabled;
74764
- if (options.HealthCheckPath)
74765
- params.HealthCheckPath = options.HealthCheckPath;
74766
- if (options.HealthCheckIntervalSeconds)
74767
- params.HealthCheckIntervalSeconds = options.HealthCheckIntervalSeconds;
74768
- if (options.HealthCheckTimeoutSeconds)
74769
- params.HealthCheckTimeoutSeconds = options.HealthCheckTimeoutSeconds;
74770
- if (options.HealthyThresholdCount)
74771
- params.HealthyThresholdCount = options.HealthyThresholdCount;
74772
- if (options.UnhealthyThresholdCount)
74773
- params.UnhealthyThresholdCount = options.UnhealthyThresholdCount;
74774
- if (options.TargetType)
74775
- params.TargetType = options.TargetType;
74776
- if (options.IpAddressType)
74777
- params.IpAddressType = options.IpAddressType;
74778
- if (options.Matcher) {
74779
- if (options.Matcher.HttpCode)
74780
- params["Matcher.HttpCode"] = options.Matcher.HttpCode;
74781
- if (options.Matcher.GrpcCode)
74782
- params["Matcher.GrpcCode"] = options.Matcher.GrpcCode;
74783
- }
74784
- if (options.Tags) {
74785
- options.Tags.forEach((tag, index) => {
74786
- params[`Tags.member.${index + 1}.Key`] = tag.Key;
74787
- params[`Tags.member.${index + 1}.Value`] = tag.Value;
74788
- });
74789
- }
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;
74790
74824
  const result = await this.client.request({
74791
- service: "elasticloadbalancing",
74825
+ service: "connect",
74792
74826
  region: this.region,
74793
- method: "POST",
74794
- path: "/",
74827
+ method: "PUT",
74828
+ path: `/routing-profiles/${params.InstanceId}`,
74795
74829
  headers: {
74796
- "Content-Type": "application/x-www-form-urlencoded"
74830
+ "Content-Type": "application/json"
74797
74831
  },
74798
- body: this.buildFormBody("CreateTargetGroup", params)
74832
+ body: JSON.stringify(body)
74799
74833
  });
74800
- return this.normalizeResult(result, "CreateTargetGroupResult");
74834
+ return result;
74801
74835
  }
74802
- async deleteTargetGroup(targetGroupArn) {
74803
- const params = {
74804
- 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
74805
74848
  };
74806
- await this.client.request({
74807
- 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",
74808
74865
  region: this.region,
74809
- method: "POST",
74810
- path: "/",
74866
+ method: "PUT",
74867
+ path: `/contact/outbound-voice/${params.InstanceId}`,
74811
74868
  headers: {
74812
- "Content-Type": "application/x-www-form-urlencoded"
74869
+ "Content-Type": "application/json"
74813
74870
  },
74814
- body: this.buildFormBody("DeleteTargetGroup", params)
74871
+ body: JSON.stringify(body)
74815
74872
  });
74873
+ return result;
74816
74874
  }
74817
- async registerTargets(options) {
74818
- const params = {
74819
- TargetGroupArn: options.TargetGroupArn
74820
- };
74821
- options.Targets.forEach((target, index) => {
74822
- params[`Targets.member.${index + 1}.Id`] = target.Id;
74823
- if (target.Port) {
74824
- params[`Targets.member.${index + 1}.Port`] = target.Port;
74825
- }
74826
- if (target.AvailabilityZone) {
74827
- params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
74828
- }
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
74829
74882
  });
74883
+ }
74884
+ async stopContact(params) {
74830
74885
  await this.client.request({
74831
- service: "elasticloadbalancing",
74886
+ service: "connect",
74832
74887
  region: this.region,
74833
74888
  method: "POST",
74834
- path: "/",
74835
- headers: {
74836
- "Content-Type": "application/x-www-form-urlencoded"
74837
- },
74838
- body: this.buildFormBody("RegisterTargets", params)
74889
+ path: `/contact/stop/${params.InstanceId}/${params.ContactId}`
74839
74890
  });
74840
74891
  }
74841
- async deregisterTargets(options) {
74842
- const params = {
74843
- TargetGroupArn: options.TargetGroupArn
74844
- };
74845
- options.Targets.forEach((target, index) => {
74846
- params[`Targets.member.${index + 1}.Id`] = target.Id;
74847
- if (target.Port) {
74848
- params[`Targets.member.${index + 1}.Port`] = target.Port;
74849
- }
74850
- if (target.AvailabilityZone) {
74851
- params[`Targets.member.${index + 1}.AvailabilityZone`] = target.AvailabilityZone;
74852
- }
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}`
74853
74898
  });
74899
+ }
74900
+ async updateContactAttributes(params) {
74854
74901
  await this.client.request({
74855
- service: "elasticloadbalancing",
74902
+ service: "connect",
74856
74903
  region: this.region,
74857
74904
  method: "POST",
74858
- path: "/",
74905
+ path: `/contact/attributes/${params.InstanceId}`,
74859
74906
  headers: {
74860
- "Content-Type": "application/x-www-form-urlencoded"
74907
+ "Content-Type": "application/json"
74861
74908
  },
74862
- body: this.buildFormBody("DeregisterTargets", params)
74909
+ body: JSON.stringify({
74910
+ InitialContactId: params.InitialContactId,
74911
+ Attributes: params.Attributes
74912
+ })
74863
74913
  });
74864
74914
  }
74865
- async createListener(options) {
74866
- const params = {
74867
- LoadBalancerArn: options.LoadBalancerArn,
74868
- 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
74869
74921
  };
74870
- if (options.Protocol)
74871
- params.Protocol = options.Protocol;
74872
- if (options.SslPolicy)
74873
- params.SslPolicy = options.SslPolicy;
74874
- if (options.Certificates) {
74875
- options.Certificates.forEach((cert, index) => {
74876
- params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
74877
- });
74878
- }
74879
- options.DefaultActions.forEach((action, index) => {
74880
- params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
74881
- if (action.TargetGroupArn) {
74882
- params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
74883
- }
74884
- if (action.Order !== undefined) {
74885
- params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
74886
- }
74887
- if (action.RedirectConfig) {
74888
- const rc = action.RedirectConfig;
74889
- if (rc.Protocol)
74890
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Protocol`] = rc.Protocol;
74891
- if (rc.Port)
74892
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Port`] = rc.Port;
74893
- if (rc.Host)
74894
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Host`] = rc.Host;
74895
- if (rc.Path)
74896
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Path`] = rc.Path;
74897
- if (rc.Query)
74898
- params[`DefaultActions.member.${index + 1}.RedirectConfig.Query`] = rc.Query;
74899
- params[`DefaultActions.member.${index + 1}.RedirectConfig.StatusCode`] = rc.StatusCode;
74900
- }
74901
- if (action.FixedResponseConfig) {
74902
- const fr = action.FixedResponseConfig;
74903
- if (fr.MessageBody)
74904
- params[`DefaultActions.member.${index + 1}.FixedResponseConfig.MessageBody`] = fr.MessageBody;
74905
- params[`DefaultActions.member.${index + 1}.FixedResponseConfig.StatusCode`] = fr.StatusCode;
74906
- if (fr.ContentType)
74907
- params[`DefaultActions.member.${index + 1}.FixedResponseConfig.ContentType`] = fr.ContentType;
74908
- }
74909
- });
74910
- if (options.AlpnPolicy) {
74911
- options.AlpnPolicy.forEach((policy, index) => {
74912
- params[`AlpnPolicy.member.${index + 1}`] = policy;
74913
- });
74914
- }
74915
- if (options.Tags) {
74916
- options.Tags.forEach((tag, index) => {
74917
- params[`Tags.member.${index + 1}.Key`] = tag.Key;
74918
- params[`Tags.member.${index + 1}.Value`] = tag.Value;
74919
- });
74920
- }
74921
- const result = await this.client.request({
74922
- 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",
74923
74934
  region: this.region,
74924
- method: "POST",
74925
- path: "/",
74935
+ method: "PUT",
74936
+ path: `/users/${params.InstanceId}`,
74926
74937
  headers: {
74927
- "Content-Type": "application/x-www-form-urlencoded"
74938
+ "Content-Type": "application/json"
74928
74939
  },
74929
- body: this.buildFormBody("CreateListener", params)
74940
+ body: JSON.stringify(body)
74930
74941
  });
74931
- return this.normalizeResult(result, "CreateListenerResult");
74932
74942
  }
74933
- async deleteListener(listenerArn) {
74934
- const params = {
74935
- ListenerArn: listenerArn
74936
- };
74943
+ async deleteUser(params) {
74937
74944
  await this.client.request({
74938
- service: "elasticloadbalancing",
74945
+ service: "connect",
74939
74946
  region: this.region,
74940
- method: "POST",
74941
- 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}`,
74942
74979
  headers: {
74943
- "Content-Type": "application/x-www-form-urlencoded"
74980
+ "Content-Type": "application/json"
74944
74981
  },
74945
- body: this.buildFormBody("DeleteListener", params)
74982
+ body: JSON.stringify(body)
74946
74983
  });
74947
74984
  }
74948
- async modifyListener(options) {
74949
- const params = {
74950
- 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
74951
75003
  };
74952
- if (options.Port)
74953
- params.Port = options.Port;
74954
- if (options.Protocol)
74955
- params.Protocol = options.Protocol;
74956
- if (options.SslPolicy)
74957
- params.SslPolicy = options.SslPolicy;
74958
- if (options.Certificates) {
74959
- options.Certificates.forEach((cert, index) => {
74960
- params[`Certificates.member.${index + 1}.CertificateArn`] = cert.CertificateArn;
74961
- });
74962
- }
74963
- if (options.DefaultActions) {
74964
- options.DefaultActions.forEach((action, index) => {
74965
- if (action.Type)
74966
- params[`DefaultActions.member.${index + 1}.Type`] = action.Type;
74967
- if (action.TargetGroupArn)
74968
- params[`DefaultActions.member.${index + 1}.TargetGroupArn`] = action.TargetGroupArn;
74969
- if (action.Order !== undefined)
74970
- params[`DefaultActions.member.${index + 1}.Order`] = action.Order;
74971
- });
74972
- }
74973
- if (options.AlpnPolicy) {
74974
- options.AlpnPolicy.forEach((policy, index) => {
74975
- params[`AlpnPolicy.member.${index + 1}`] = policy;
74976
- });
74977
- }
74978
- const result = await this.client.request({
74979
- 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",
74980
75010
  region: this.region,
74981
- method: "POST",
74982
- path: "/",
75011
+ method: "PUT",
75012
+ path: `/quick-connects/${params.InstanceId}`,
74983
75013
  headers: {
74984
- "Content-Type": "application/x-www-form-urlencoded"
75014
+ "Content-Type": "application/json"
74985
75015
  },
74986
- body: this.buildFormBody("ModifyListener", params)
75016
+ body: JSON.stringify(body)
74987
75017
  });
74988
- return this.normalizeResult(result, "ModifyListenerResult");
74989
75018
  }
74990
- buildFormBody(action, params) {
74991
- const formParams = {
74992
- Action: action,
74993
- Version: "2015-12-01"
74994
- };
74995
- for (const [key, value] of Object.entries(params)) {
74996
- if (value !== undefined && value !== null) {
74997
- formParams[key] = String(value);
74998
- }
74999
- }
75000
- 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
+ });
75001
75030
  }
75002
- normalizeResult(parsed, resultKey) {
75003
- if (parsed && parsed[resultKey]) {
75004
- return this.normalizeArrays(parsed[resultKey]);
75005
- }
75006
- const responseKey = resultKey.replace("Result", "Response");
75007
- if (parsed && parsed[responseKey] && parsed[responseKey][resultKey]) {
75008
- return this.normalizeArrays(parsed[responseKey][resultKey]);
75009
- }
75010
- 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
+ });
75011
75042
  }
75012
- normalizeArrays(obj) {
75013
- if (!obj || typeof obj !== "object") {
75014
- return obj;
75015
- }
75016
- if (Array.isArray(obj)) {
75017
- return obj.map((item) => this.normalizeArrays(item));
75018
- }
75019
- const result = {};
75020
- for (const [key, value] of Object.entries(obj)) {
75021
- const arrayFields = [
75022
- "LoadBalancers",
75023
- "TargetGroups",
75024
- "Listeners",
75025
- "Rules",
75026
- "TargetHealthDescriptions",
75027
- "Attributes",
75028
- "SecurityGroups",
75029
- "AvailabilityZones",
75030
- "Certificates",
75031
- "DefaultActions",
75032
- "Conditions",
75033
- "Actions",
75034
- "member"
75035
- ];
75036
- if (key === "member") {
75037
- if (Array.isArray(value)) {
75038
- 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: {}
75039
75067
  }
75040
- return [this.normalizeArrays(value)];
75041
75068
  }
75042
- if (arrayFields.includes(key)) {
75043
- if (value && typeof value === "object" && "member" in value) {
75044
- const memberValue = value.member;
75045
- result[key] = Array.isArray(memberValue) ? memberValue.map((item) => this.normalizeArrays(item)) : [this.normalizeArrays(memberValue)];
75046
- } else if (Array.isArray(value)) {
75047
- result[key] = value.map((item) => this.normalizeArrays(item));
75048
- } else if (value) {
75049
- result[key] = [this.normalizeArrays(value)];
75050
- } else {
75051
- 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: {}
75052
75102
  }
75053
- } else if (typeof value === "object") {
75054
- result[key] = this.normalizeArrays(value);
75055
- } else {
75056
- result[key] = value;
75057
75103
  }
75058
- }
75059
- 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
+ });
75060
75117
  }
75061
75118
  }
75062
- // src/aws/rds.ts
75119
+ // src/aws/elbv2.ts
75063
75120
  init_client();
75064
75121
 
75065
- class RDSClient {
75122
+ class ELBv2Client {
75066
75123
  client;
75067
75124
  region;
75068
75125
  constructor(region = "us-east-1") {
75069
75126
  this.region = region;
75070
75127
  this.client = new AWSClient;
75071
75128
  }
75072
- async describeDBInstances(options) {
75073
- const params = {
75074
- Action: "DescribeDBInstances",
75075
- Version: "2014-10-31"
75076
- };
75077
- if (options?.DBInstanceIdentifier) {
75078
- 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
+ });
75079
75135
  }
75080
- if (options?.MaxRecords) {
75081
- params.MaxRecords = options.MaxRecords;
75136
+ if (options?.Names) {
75137
+ options.Names.forEach((name, index) => {
75138
+ params[`Names.member.${index + 1}`] = name;
75139
+ });
75082
75140
  }
75083
75141
  if (options?.Marker) {
75084
75142
  params.Marker = options.Marker;
75085
75143
  }
75086
- if (options?.Filters) {
75087
- options.Filters.forEach((filter, i) => {
75088
- params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
75089
- filter.Values.forEach((value, j) => {
75090
- params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
75091
- });
75092
- });
75144
+ if (options?.PageSize) {
75145
+ params.PageSize = options.PageSize;
75093
75146
  }
75094
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75095
75147
  const result = await this.client.request({
75096
- service: "rds",
75148
+ service: "elasticloadbalancing",
75097
75149
  region: this.region,
75098
75150
  method: "POST",
75099
75151
  path: "/",
75100
75152
  headers: {
75101
75153
  "Content-Type": "application/x-www-form-urlencoded"
75102
75154
  },
75103
- body: queryString
75155
+ body: this.buildFormBody("DescribeLoadBalancers", params)
75104
75156
  });
75105
- const response = result.DescribeDBInstancesResult || result;
75106
- let instances = response.DBInstances?.DBInstance || [];
75107
- if (!Array.isArray(instances)) {
75108
- instances = instances ? [instances] : [];
75109
- }
75110
- return {
75111
- DBInstances: instances,
75112
- Marker: response.Marker
75113
- };
75114
- }
75115
- async describeDBInstance(dbInstanceIdentifier) {
75116
- const result = await this.describeDBInstances({ DBInstanceIdentifier: dbInstanceIdentifier });
75117
- return result.DBInstances?.[0];
75157
+ return this.normalizeResult(result, "DescribeLoadBalancersResult");
75118
75158
  }
75119
- async describeDBClusters(options) {
75120
- const params = {
75121
- Action: "DescribeDBClusters",
75122
- Version: "2014-10-31"
75123
- };
75124
- if (options?.DBClusterIdentifier) {
75125
- params.DBClusterIdentifier = options.DBClusterIdentifier;
75159
+ async describeTargetGroups(options) {
75160
+ const params = {};
75161
+ if (options?.LoadBalancerArn) {
75162
+ params.LoadBalancerArn = options.LoadBalancerArn;
75126
75163
  }
75127
- if (options?.MaxRecords) {
75128
- 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
+ });
75129
75173
  }
75130
75174
  if (options?.Marker) {
75131
75175
  params.Marker = options.Marker;
75132
75176
  }
75133
- if (options?.Filters) {
75134
- options.Filters.forEach((filter, i) => {
75135
- params[`Filters.Filter.${i + 1}.Name`] = filter.Name;
75136
- filter.Values.forEach((value, j) => {
75137
- params[`Filters.Filter.${i + 1}.Values.Value.${j + 1}`] = value;
75138
- });
75139
- });
75177
+ if (options?.PageSize) {
75178
+ params.PageSize = options.PageSize;
75140
75179
  }
75141
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75142
75180
  const result = await this.client.request({
75143
- service: "rds",
75181
+ service: "elasticloadbalancing",
75144
75182
  region: this.region,
75145
75183
  method: "POST",
75146
75184
  path: "/",
75147
75185
  headers: {
75148
75186
  "Content-Type": "application/x-www-form-urlencoded"
75149
75187
  },
75150
- body: queryString
75188
+ body: this.buildFormBody("DescribeTargetGroups", params)
75151
75189
  });
75152
- const response = result.DescribeDBClustersResult || result;
75153
- let clusters = response.DBClusters?.DBCluster || [];
75154
- if (!Array.isArray(clusters)) {
75155
- clusters = clusters ? [clusters] : [];
75156
- }
75157
- return {
75158
- DBClusters: clusters,
75159
- Marker: response.Marker
75160
- };
75190
+ return this.normalizeResult(result, "DescribeTargetGroupsResult");
75161
75191
  }
75162
- async describeDBSnapshots(options) {
75192
+ async describeTargetHealth(options) {
75163
75193
  const params = {
75164
- Action: "DescribeDBSnapshots",
75165
- Version: "2014-10-31"
75194
+ TargetGroupArn: options.TargetGroupArn
75166
75195
  };
75167
- if (options?.DBInstanceIdentifier) {
75168
- params.DBInstanceIdentifier = options.DBInstanceIdentifier;
75169
- }
75170
- if (options?.DBSnapshotIdentifier) {
75171
- params.DBSnapshotIdentifier = options.DBSnapshotIdentifier;
75172
- }
75173
- if (options?.SnapshotType) {
75174
- params.SnapshotType = options.SnapshotType;
75175
- }
75176
- if (options?.MaxRecords) {
75177
- params.MaxRecords = options.MaxRecords;
75178
- }
75179
- if (options?.Marker) {
75180
- 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
+ });
75181
75206
  }
75182
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75183
75207
  const result = await this.client.request({
75184
- service: "rds",
75208
+ service: "elasticloadbalancing",
75185
75209
  region: this.region,
75186
75210
  method: "POST",
75187
75211
  path: "/",
75188
75212
  headers: {
75189
75213
  "Content-Type": "application/x-www-form-urlencoded"
75190
75214
  },
75191
- body: queryString
75215
+ body: this.buildFormBody("DescribeTargetHealth", params)
75192
75216
  });
75193
- const response = result.DescribeDBSnapshotsResult || result;
75194
- let snapshots = response.DBSnapshots?.DBSnapshot || [];
75195
- if (!Array.isArray(snapshots)) {
75196
- snapshots = snapshots ? [snapshots] : [];
75197
- }
75198
- return {
75199
- DBSnapshots: snapshots,
75200
- Marker: response.Marker
75201
- };
75217
+ return this.normalizeResult(result, "DescribeTargetHealthResult");
75202
75218
  }
75203
- async describeDBSubnetGroups(options) {
75204
- const params = {
75205
- Action: "DescribeDBSubnetGroups",
75206
- Version: "2014-10-31"
75207
- };
75208
- if (options?.DBSubnetGroupName) {
75209
- params.DBSubnetGroupName = options.DBSubnetGroupName;
75219
+ async describeListeners(options) {
75220
+ const params = {};
75221
+ if (options?.LoadBalancerArn) {
75222
+ params.LoadBalancerArn = options.LoadBalancerArn;
75210
75223
  }
75211
- if (options?.MaxRecords) {
75212
- params.MaxRecords = options.MaxRecords;
75224
+ if (options?.ListenerArns) {
75225
+ options.ListenerArns.forEach((arn, index) => {
75226
+ params[`ListenerArns.member.${index + 1}`] = arn;
75227
+ });
75213
75228
  }
75214
75229
  if (options?.Marker) {
75215
75230
  params.Marker = options.Marker;
75216
75231
  }
75217
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75232
+ if (options?.PageSize) {
75233
+ params.PageSize = options.PageSize;
75234
+ }
75218
75235
  const result = await this.client.request({
75219
- service: "rds",
75236
+ service: "elasticloadbalancing",
75220
75237
  region: this.region,
75221
75238
  method: "POST",
75222
75239
  path: "/",
75223
75240
  headers: {
75224
75241
  "Content-Type": "application/x-www-form-urlencoded"
75225
75242
  },
75226
- body: queryString
75243
+ body: this.buildFormBody("DescribeListeners", params)
75227
75244
  });
75228
- const response = result.DescribeDBSubnetGroupsResult || result;
75229
- let groups = response.DBSubnetGroups?.DBSubnetGroup || [];
75230
- if (!Array.isArray(groups)) {
75231
- groups = groups ? [groups] : [];
75232
- }
75233
- return {
75234
- DBSubnetGroups: groups,
75235
- Marker: response.Marker
75236
- };
75245
+ return this.normalizeResult(result, "DescribeListenersResult");
75237
75246
  }
75238
- async createDBInstance(options) {
75239
- const params = {
75240
- Action: "CreateDBInstance",
75241
- Version: "2014-10-31",
75242
- DBInstanceIdentifier: options.DBInstanceIdentifier,
75243
- DBInstanceClass: options.DBInstanceClass,
75244
- Engine: options.Engine
75245
- };
75246
- if (options.MasterUsername)
75247
- params.MasterUsername = options.MasterUsername;
75248
- if (options.MasterUserPassword)
75249
- params.MasterUserPassword = options.MasterUserPassword;
75250
- if (options.DBName)
75251
- params.DBName = options.DBName;
75252
- if (options.AllocatedStorage)
75253
- params.AllocatedStorage = options.AllocatedStorage;
75254
- if (options.DBSubnetGroupName)
75255
- params.DBSubnetGroupName = options.DBSubnetGroupName;
75256
- if (options.AvailabilityZone)
75257
- params.AvailabilityZone = options.AvailabilityZone;
75258
- if (options.PreferredMaintenanceWindow)
75259
- params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
75260
- if (options.PreferredBackupWindow)
75261
- params.PreferredBackupWindow = options.PreferredBackupWindow;
75262
- if (options.BackupRetentionPeriod !== undefined)
75263
- params.BackupRetentionPeriod = options.BackupRetentionPeriod;
75264
- if (options.MultiAZ !== undefined)
75265
- params.MultiAZ = options.MultiAZ;
75266
- if (options.EngineVersion)
75267
- params.EngineVersion = options.EngineVersion;
75268
- if (options.AutoMinorVersionUpgrade !== undefined)
75269
- params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
75270
- if (options.LicenseModel)
75271
- params.LicenseModel = options.LicenseModel;
75272
- if (options.PubliclyAccessible !== undefined)
75273
- params.PubliclyAccessible = options.PubliclyAccessible;
75274
- if (options.StorageType)
75275
- params.StorageType = options.StorageType;
75276
- if (options.StorageEncrypted !== undefined)
75277
- params.StorageEncrypted = options.StorageEncrypted;
75278
- if (options.KmsKeyId)
75279
- params.KmsKeyId = options.KmsKeyId;
75280
- if (options.DeletionProtection !== undefined)
75281
- params.DeletionProtection = options.DeletionProtection;
75282
- if (options.VpcSecurityGroupIds) {
75283
- options.VpcSecurityGroupIds.forEach((id, i) => {
75284
- params[`VpcSecurityGroupIds.VpcSecurityGroupId.${i + 1}`] = id;
75285
- });
75247
+ async describeRules(options) {
75248
+ const params = {};
75249
+ if (options?.ListenerArn) {
75250
+ params.ListenerArn = options.ListenerArn;
75286
75251
  }
75287
- if (options.Tags) {
75288
- options.Tags.forEach((tag, i) => {
75289
- params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
75290
- 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;
75291
75255
  });
75292
75256
  }
75293
- 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
+ }
75294
75263
  const result = await this.client.request({
75295
- service: "rds",
75264
+ service: "elasticloadbalancing",
75296
75265
  region: this.region,
75297
75266
  method: "POST",
75298
75267
  path: "/",
75299
75268
  headers: {
75300
75269
  "Content-Type": "application/x-www-form-urlencoded"
75301
75270
  },
75302
- body: queryString
75271
+ body: this.buildFormBody("DescribeRules", params)
75303
75272
  });
75304
- const response = result.CreateDBInstanceResult || result;
75305
- return {
75306
- DBInstance: response.DBInstance
75307
- };
75273
+ return this.normalizeResult(result, "DescribeRulesResult");
75308
75274
  }
75309
- async deleteDBInstance(options) {
75275
+ async describeLoadBalancerAttributes(loadBalancerArn) {
75310
75276
  const params = {
75311
- Action: "DeleteDBInstance",
75312
- Version: "2014-10-31",
75313
- DBInstanceIdentifier: options.DBInstanceIdentifier
75277
+ LoadBalancerArn: loadBalancerArn
75314
75278
  };
75315
- if (options.SkipFinalSnapshot !== undefined) {
75316
- params.SkipFinalSnapshot = options.SkipFinalSnapshot;
75317
- }
75318
- if (options.FinalDBSnapshotIdentifier) {
75319
- params.FinalDBSnapshotIdentifier = options.FinalDBSnapshotIdentifier;
75320
- }
75321
- if (options.DeleteAutomatedBackups !== undefined) {
75322
- params.DeleteAutomatedBackups = options.DeleteAutomatedBackups;
75323
- }
75324
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75325
75279
  const result = await this.client.request({
75326
- service: "rds",
75280
+ service: "elasticloadbalancing",
75327
75281
  region: this.region,
75328
75282
  method: "POST",
75329
75283
  path: "/",
75330
75284
  headers: {
75331
75285
  "Content-Type": "application/x-www-form-urlencoded"
75332
75286
  },
75333
- body: queryString
75287
+ body: this.buildFormBody("DescribeLoadBalancerAttributes", params)
75334
75288
  });
75335
- const response = result.DeleteDBInstanceResult || result;
75336
- return {
75337
- DBInstance: response.DBInstance
75289
+ return this.normalizeResult(result, "DescribeLoadBalancerAttributesResult");
75290
+ }
75291
+ async describeTargetGroupAttributes(targetGroupArn) {
75292
+ const params = {
75293
+ TargetGroupArn: targetGroupArn
75338
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");
75339
75306
  }
75340
- async modifyDBInstance(options) {
75307
+ async createLoadBalancer(options) {
75341
75308
  const params = {
75342
- Action: "ModifyDBInstance",
75343
- Version: "2014-10-31",
75344
- DBInstanceIdentifier: options.DBInstanceIdentifier
75309
+ Name: options.Name
75345
75310
  };
75346
- if (options.DBInstanceClass)
75347
- params.DBInstanceClass = options.DBInstanceClass;
75348
- if (options.AllocatedStorage)
75349
- params.AllocatedStorage = options.AllocatedStorage;
75350
- if (options.MasterUserPassword)
75351
- params.MasterUserPassword = options.MasterUserPassword;
75352
- if (options.BackupRetentionPeriod !== undefined)
75353
- params.BackupRetentionPeriod = options.BackupRetentionPeriod;
75354
- if (options.PreferredBackupWindow)
75355
- params.PreferredBackupWindow = options.PreferredBackupWindow;
75356
- if (options.PreferredMaintenanceWindow)
75357
- params.PreferredMaintenanceWindow = options.PreferredMaintenanceWindow;
75358
- if (options.MultiAZ !== undefined)
75359
- params.MultiAZ = options.MultiAZ;
75360
- if (options.EngineVersion)
75361
- params.EngineVersion = options.EngineVersion;
75362
- if (options.AutoMinorVersionUpgrade !== undefined)
75363
- params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
75364
- if (options.PubliclyAccessible !== undefined)
75365
- params.PubliclyAccessible = options.PubliclyAccessible;
75366
- if (options.ApplyImmediately !== undefined)
75367
- params.ApplyImmediately = options.ApplyImmediately;
75368
- if (options.StorageType)
75369
- params.StorageType = options.StorageType;
75370
- if (options.DeletionProtection !== undefined)
75371
- params.DeletionProtection = options.DeletionProtection;
75372
- if (options.VpcSecurityGroupIds) {
75373
- options.VpcSecurityGroupIds.forEach((id, i) => {
75374
- 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;
75375
75348
  });
75376
75349
  }
75377
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75378
75350
  const result = await this.client.request({
75379
- service: "rds",
75351
+ service: "elasticloadbalancing",
75380
75352
  region: this.region,
75381
75353
  method: "POST",
75382
75354
  path: "/",
75383
75355
  headers: {
75384
75356
  "Content-Type": "application/x-www-form-urlencoded"
75385
75357
  },
75386
- body: queryString
75358
+ body: this.buildFormBody("CreateLoadBalancer", params)
75387
75359
  });
75388
- const response = result.ModifyDBInstanceResult || result;
75389
- return {
75390
- DBInstance: response.DBInstance
75391
- };
75360
+ return this.normalizeResult(result, "CreateLoadBalancerResult");
75392
75361
  }
75393
- async startDBInstance(dbInstanceIdentifier) {
75362
+ async deleteLoadBalancer(loadBalancerArn) {
75394
75363
  const params = {
75395
- Action: "StartDBInstance",
75396
- Version: "2014-10-31",
75397
- DBInstanceIdentifier: dbInstanceIdentifier
75364
+ LoadBalancerArn: loadBalancerArn
75398
75365
  };
75399
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75400
- const result = await this.client.request({
75401
- service: "rds",
75366
+ await this.client.request({
75367
+ service: "elasticloadbalancing",
75402
75368
  region: this.region,
75403
75369
  method: "POST",
75404
75370
  path: "/",
75405
75371
  headers: {
75406
75372
  "Content-Type": "application/x-www-form-urlencoded"
75407
75373
  },
75408
- body: queryString
75374
+ body: this.buildFormBody("DeleteLoadBalancer", params)
75409
75375
  });
75410
- const response = result.StartDBInstanceResult || result;
75411
- return {
75412
- DBInstance: response.DBInstance
75413
- };
75414
75376
  }
75415
- async stopDBInstance(options) {
75377
+ async createTargetGroup(options) {
75416
75378
  const params = {
75417
- Action: "StopDBInstance",
75418
- Version: "2014-10-31",
75419
- DBInstanceIdentifier: options.DBInstanceIdentifier
75379
+ Name: options.Name
75420
75380
  };
75421
- if (options.DBSnapshotIdentifier) {
75422
- 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
+ });
75423
75420
  }
75424
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75425
75421
  const result = await this.client.request({
75426
- service: "rds",
75422
+ service: "elasticloadbalancing",
75427
75423
  region: this.region,
75428
75424
  method: "POST",
75429
75425
  path: "/",
75430
75426
  headers: {
75431
75427
  "Content-Type": "application/x-www-form-urlencoded"
75432
75428
  },
75433
- body: queryString
75429
+ body: this.buildFormBody("CreateTargetGroup", params)
75434
75430
  });
75435
- const response = result.StopDBInstanceResult || result;
75436
- return {
75437
- DBInstance: response.DBInstance
75431
+ return this.normalizeResult(result, "CreateTargetGroupResult");
75432
+ }
75433
+ async deleteTargetGroup(targetGroupArn) {
75434
+ const params = {
75435
+ TargetGroupArn: targetGroupArn
75438
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
+ });
75439
75447
  }
75440
- async rebootDBInstance(options) {
75448
+ async registerTargets(options) {
75441
75449
  const params = {
75442
- Action: "RebootDBInstance",
75443
- Version: "2014-10-31",
75444
- DBInstanceIdentifier: options.DBInstanceIdentifier
75450
+ TargetGroupArn: options.TargetGroupArn
75445
75451
  };
75446
- if (options.ForceFailover !== undefined) {
75447
- params.ForceFailover = options.ForceFailover;
75448
- }
75449
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75450
- const result = await this.client.request({
75451
- 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",
75452
75463
  region: this.region,
75453
75464
  method: "POST",
75454
75465
  path: "/",
75455
75466
  headers: {
75456
75467
  "Content-Type": "application/x-www-form-urlencoded"
75457
75468
  },
75458
- body: queryString
75469
+ body: this.buildFormBody("RegisterTargets", params)
75459
75470
  });
75460
- const response = result.RebootDBInstanceResult || result;
75461
- return {
75462
- DBInstance: response.DBInstance
75471
+ }
75472
+ async deregisterTargets(options) {
75473
+ const params = {
75474
+ TargetGroupArn: options.TargetGroupArn
75463
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
+ });
75464
75495
  }
75465
- async createDBSnapshot(options) {
75496
+ async createListener(options) {
75466
75497
  const params = {
75467
- Action: "CreateDBSnapshot",
75468
- Version: "2014-10-31",
75469
- DBInstanceIdentifier: options.DBInstanceIdentifier,
75470
- DBSnapshotIdentifier: options.DBSnapshotIdentifier
75498
+ LoadBalancerArn: options.LoadBalancerArn,
75499
+ Port: options.Port
75471
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
+ }
75472
75546
  if (options.Tags) {
75473
- options.Tags.forEach((tag, i) => {
75474
- params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
75475
- 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;
75476
75550
  });
75477
75551
  }
75478
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75479
75552
  const result = await this.client.request({
75480
- service: "rds",
75553
+ service: "elasticloadbalancing",
75481
75554
  region: this.region,
75482
75555
  method: "POST",
75483
75556
  path: "/",
75484
75557
  headers: {
75485
75558
  "Content-Type": "application/x-www-form-urlencoded"
75486
75559
  },
75487
- body: queryString
75560
+ body: this.buildFormBody("CreateListener", params)
75488
75561
  });
75489
- const response = result.CreateDBSnapshotResult || result;
75490
- return {
75491
- DBSnapshot: response.DBSnapshot
75492
- };
75562
+ return this.normalizeResult(result, "CreateListenerResult");
75493
75563
  }
75494
- async deleteDBSnapshot(dbSnapshotIdentifier) {
75564
+ async deleteListener(listenerArn) {
75495
75565
  const params = {
75496
- Action: "DeleteDBSnapshot",
75497
- Version: "2014-10-31",
75498
- DBSnapshotIdentifier: dbSnapshotIdentifier
75566
+ ListenerArn: listenerArn
75499
75567
  };
75500
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75501
- const result = await this.client.request({
75502
- service: "rds",
75568
+ await this.client.request({
75569
+ service: "elasticloadbalancing",
75503
75570
  region: this.region,
75504
75571
  method: "POST",
75505
75572
  path: "/",
75506
75573
  headers: {
75507
75574
  "Content-Type": "application/x-www-form-urlencoded"
75508
75575
  },
75509
- body: queryString
75576
+ body: this.buildFormBody("DeleteListener", params)
75510
75577
  });
75511
- const response = result.DeleteDBSnapshotResult || result;
75512
- return {
75513
- DBSnapshot: response.DBSnapshot
75514
- };
75515
75578
  }
75516
- async restoreDBInstanceFromDBSnapshot(options) {
75579
+ async modifyListener(options) {
75517
75580
  const params = {
75518
- Action: "RestoreDBInstanceFromDBSnapshot",
75519
- Version: "2014-10-31",
75520
- DBInstanceIdentifier: options.DBInstanceIdentifier,
75521
- DBSnapshotIdentifier: options.DBSnapshotIdentifier
75581
+ ListenerArn: options.ListenerArn
75522
75582
  };
75523
- if (options.DBInstanceClass)
75524
- params.DBInstanceClass = options.DBInstanceClass;
75525
75583
  if (options.Port)
75526
75584
  params.Port = options.Port;
75527
- if (options.AvailabilityZone)
75528
- params.AvailabilityZone = options.AvailabilityZone;
75529
- if (options.DBSubnetGroupName)
75530
- params.DBSubnetGroupName = options.DBSubnetGroupName;
75531
- if (options.MultiAZ !== undefined)
75532
- params.MultiAZ = options.MultiAZ;
75533
- if (options.PubliclyAccessible !== undefined)
75534
- params.PubliclyAccessible = options.PubliclyAccessible;
75535
- if (options.AutoMinorVersionUpgrade !== undefined)
75536
- params.AutoMinorVersionUpgrade = options.AutoMinorVersionUpgrade;
75537
- if (options.StorageType)
75538
- params.StorageType = options.StorageType;
75539
- if (options.DeletionProtection !== undefined)
75540
- params.DeletionProtection = options.DeletionProtection;
75541
- if (options.VpcSecurityGroupIds) {
75542
- options.VpcSecurityGroupIds.forEach((id, i) => {
75543
- 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;
75544
75592
  });
75545
75593
  }
75546
- if (options.Tags) {
75547
- options.Tags.forEach((tag, i) => {
75548
- params[`Tags.Tag.${i + 1}.Key`] = tag.Key;
75549
- 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;
75550
75607
  });
75551
75608
  }
75552
- const queryString = new URLSearchParams(buildQueryParams(params)).toString();
75553
75609
  const result = await this.client.request({
75554
- service: "rds",
75610
+ service: "elasticloadbalancing",
75555
75611
  region: this.region,
75556
75612
  method: "POST",
75557
75613
  path: "/",
75558
75614
  headers: {
75559
75615
  "Content-Type": "application/x-www-form-urlencoded"
75560
75616
  },
75561
- body: queryString
75617
+ body: this.buildFormBody("ModifyListener", params)
75562
75618
  });
75563
- const response = result.RestoreDBInstanceFromDBSnapshotResult || result;
75564
- return {
75565
- DBInstance: response.DBInstance
75566
- };
75619
+ return this.normalizeResult(result, "ModifyListenerResult");
75567
75620
  }
75568
- async waitForDBInstanceAvailable(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
75569
- for (let i = 0;i < maxAttempts; i++) {
75570
- const instance = await this.describeDBInstance(dbInstanceIdentifier);
75571
- if (instance?.DBInstanceStatus === "available") {
75572
- return instance;
75573
- }
75574
- if (["deleted", "failed", "incompatible-restore", "incompatible-parameters"].includes(instance?.DBInstanceStatus || "")) {
75575
- 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);
75576
75629
  }
75577
- await new Promise((resolve14) => setTimeout(resolve14, delayMs));
75578
75630
  }
75579
- 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("&");
75580
75632
  }
75581
- async waitForDBInstanceDeleted(dbInstanceIdentifier, maxAttempts = 60, delayMs = 30000) {
75582
- for (let i = 0;i < maxAttempts; i++) {
75583
- try {
75584
- const instance = await this.describeDBInstance(dbInstanceIdentifier);
75585
- if (instance?.DBInstanceStatus === "deleting") {
75586
- await new Promise((resolve14) => setTimeout(resolve14, delayMs));
75587
- 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));
75588
75670
  }
75589
- throw new Error(`DB instance ${dbInstanceIdentifier} is in state: ${instance?.DBInstanceStatus}`);
75590
- } catch (error) {
75591
- if (error.code === "DBInstanceNotFound" || error.code === "DBInstanceNotFoundFault") {
75592
- 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] = [];
75593
75683
  }
75594
- throw error;
75684
+ } else if (typeof value === "object") {
75685
+ result[key] = this.normalizeArrays(value);
75686
+ } else {
75687
+ result[key] = value;
75595
75688
  }
75596
75689
  }
75597
- throw new Error(`Timeout waiting for DB instance ${dbInstanceIdentifier} to be deleted`);
75690
+ return result;
75598
75691
  }
75599
75692
  }
75693
+
75694
+ // src/aws/index.ts
75695
+ init_rds();
75696
+
75600
75697
  // src/aws/dynamodb.ts
75601
75698
  init_client();
75602
75699