@stacksjs/ts-cloud 0.12.0 → 0.12.1
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/aws/index.js +1 -1
- package/dist/bin/chunk-0rtn6q5x.js +3 -0
- package/dist/bin/chunk-258ehp9s.js +1 -0
- package/dist/bin/chunk-2yctv06c.js +1 -0
- package/dist/bin/chunk-3276rveh.js +37 -0
- package/dist/bin/chunk-3m665jwp.js +70 -0
- package/dist/bin/chunk-3s2p9vxj.js +1 -0
- package/dist/bin/chunk-4esma5m9.js +1 -0
- package/dist/bin/chunk-4n0j3n3b.js +2 -0
- package/dist/bin/chunk-54bqchag.js +92 -0
- package/dist/bin/{chunk-4q6tad44.js → chunk-5bhx3bsa.js} +121 -121
- package/dist/bin/chunk-5zagqd20.js +1 -0
- package/dist/bin/chunk-7hw2js5h.js +512 -0
- package/dist/bin/chunk-8h1qr6x4.js +50 -0
- package/dist/bin/{chunk-w32xv8n4.js → chunk-9vdc7adf.js} +6 -6
- package/dist/bin/chunk-a1dd6sby.js +1 -0
- package/dist/bin/chunk-a4dw35gs.js +1 -0
- package/dist/bin/chunk-a9d55ker.js +1 -0
- package/dist/bin/chunk-awa1qade.js +9 -0
- package/dist/bin/chunk-b6by94pk.js +2 -0
- package/dist/bin/chunk-c8sypnbe.js +2 -0
- package/dist/bin/chunk-cx4e3d4w.js +1 -0
- package/dist/bin/chunk-d5a3vheh.js +2 -0
- package/dist/bin/chunk-e1fym2bd.js +1 -0
- package/dist/bin/chunk-ej4h0q2y.js +1 -0
- package/dist/bin/chunk-ett305ym.js +4 -0
- package/dist/bin/chunk-f11xf3n6.js +2 -0
- package/dist/bin/chunk-fq7ktvgy.js +3 -0
- package/dist/bin/chunk-fyq4th2m.js +1 -0
- package/dist/bin/chunk-g67qr8yf.js +1 -0
- package/dist/bin/chunk-gc82cx4h.js +1 -0
- package/dist/bin/chunk-hchtvpr9.js +1 -0
- package/dist/bin/chunk-hpe4jjce.js +1 -0
- package/dist/bin/chunk-k5vprsef.js +6 -0
- package/dist/bin/chunk-m22krd4z.js +3 -0
- package/dist/bin/chunk-mkppcwz8.js +1 -0
- package/dist/bin/chunk-mpjg0kc7.js +2 -0
- package/dist/bin/chunk-mrm4m4dk.js +2 -0
- package/dist/bin/chunk-nff46rxd.js +1 -0
- package/dist/bin/chunk-np1z3bgt.js +1 -0
- package/dist/bin/chunk-nskxkk6r.js +1 -0
- package/dist/bin/chunk-pez932b1.js +111 -0
- package/dist/bin/chunk-qsdf5kzk.js +2 -0
- package/dist/bin/chunk-r61qmhv1.js +2 -0
- package/dist/bin/chunk-r6gdcz5c.js +1 -0
- package/dist/bin/chunk-satwnr42.js +2 -0
- package/dist/bin/{chunk-dz1ec589.js → chunk-scqmd4qv.js} +30 -30
- package/dist/bin/chunk-smbycpt5.js +44 -0
- package/dist/bin/chunk-sn7e0sn7.js +2 -0
- package/dist/bin/chunk-ss574pka.js +1 -0
- package/dist/bin/chunk-tj0xb2d8.js +585 -0
- package/dist/bin/chunk-v3rzf9d0.js +141 -0
- package/dist/bin/chunk-wnpma6t3.js +34 -0
- package/dist/bin/chunk-xan0e052.js +5 -0
- package/dist/bin/chunk-xbk2y43r.js +60 -0
- package/dist/bin/chunk-xjp3v95e.js +6 -0
- package/dist/bin/chunk-xyt490vp.js +6 -0
- package/dist/bin/chunk-yn9r02gy.js +1 -0
- package/dist/bin/chunk-zhkhn9cc.js +1 -0
- package/dist/bin/cli.js +444 -435
- package/dist/bin/dashboard-server.js +1 -1
- package/dist/chunk-0zf72ngj.js +1 -0
- package/dist/chunk-2hpjte1d.js +704 -0
- package/dist/chunk-4m6gwhwr.js +5 -0
- package/dist/chunk-5m29dhke.js +34 -0
- package/dist/chunk-6fzeemcs.js +114 -0
- package/dist/{chunk-jm5mg890.js → chunk-6xcbfs2r.js} +111 -111
- package/dist/chunk-bpnhqb70.js +6 -0
- package/dist/chunk-ead1nkbr.js +60 -0
- package/dist/chunk-fea461tj.js +141 -0
- package/dist/chunk-fvjczc73.js +1 -0
- package/dist/chunk-gearw6rk.js +4 -0
- package/dist/chunk-j60hesb3.js +2 -0
- package/dist/chunk-pmgtmt3d.js +1 -0
- package/dist/chunk-prf2pkvq.js +5 -0
- package/dist/chunk-q0wffgw5.js +37 -0
- package/dist/chunk-qcemnt35.js +50 -0
- package/dist/chunk-qvbwsaay.js +1 -0
- package/dist/chunk-r2pbqcnz.js +2 -0
- package/dist/chunk-r6110zv2.js +1 -0
- package/dist/{chunk-13qjvbqh.js → chunk-rr1yaj55.js} +1 -1
- package/dist/chunk-wcrj06cg.js +44 -0
- package/dist/chunk-wte9mh18.js +92 -0
- package/dist/{chunk-86ss83s2.js → chunk-y1dh3znq.js} +52 -52
- package/dist/chunk-y6e86wjs.js +445 -0
- package/dist/chunk-y8b7ht4v.js +1 -0
- package/dist/chunk-yf487g6e.js +2 -0
- package/dist/chunk-zmmc9j5f.js +2 -0
- package/dist/deploy/index.js +1 -1
- package/dist/dns/index.js +1 -1
- package/dist/drivers/index.js +1 -1
- package/dist/index.js +91 -91
- package/dist/pages/cloudflare-pages.d.ts +13 -0
- package/dist/protection/index.js +1 -1
- package/dist/push/index.js +1 -1
- package/dist/spend/index.js +1 -1
- package/dist/ui/404.html +1 -1
- package/dist/ui/accept-invitation.html +1 -1
- package/dist/ui/access-denied.html +1 -1
- package/dist/ui/account/automation.html +6 -6
- package/dist/ui/account/security.html +2 -2
- package/dist/ui/applications/compose.html +6 -6
- package/dist/ui/applications/new.html +2 -2
- package/dist/ui/data/backups.html +80 -80
- package/dist/ui/data/services.html +78 -78
- package/dist/ui/data/volumes.html +50 -50
- package/dist/ui/index.html +50 -50
- package/dist/ui/infrastructure/topology.html +118 -118
- package/dist/ui/integrations.html +2 -2
- package/dist/ui/operations/alerts.html +48 -48
- package/dist/ui/operations/configuration.html +6 -6
- package/dist/ui/operations/jobs.html +76 -76
- package/dist/ui/operations/maintenance.html +6 -6
- package/dist/ui/operations/observability.html +81 -81
- package/dist/ui/operations/previews.html +6 -6
- package/dist/ui/operations/queue.html +6 -6
- package/dist/ui/operations/regions.html +6 -6
- package/dist/ui/operations/releases.html +6 -6
- package/dist/ui/operations/spend.html +54 -54
- package/dist/ui/operations/workloads.html +104 -104
- package/dist/ui/security.html +2 -2
- package/dist/ui/server/actions.html +56 -56
- package/dist/ui/server/activity.html +2 -2
- package/dist/ui/server/capacity.html +6 -6
- package/dist/ui/server/database.html +106 -106
- package/dist/ui/server/deployments.html +50 -50
- package/dist/ui/server/diagnostics.html +1 -1
- package/dist/ui/server/firewall.html +76 -76
- package/dist/ui/server/fleet.html +33 -33
- package/dist/ui/server/logs.html +24 -24
- package/dist/ui/server/metrics.html +112 -112
- package/dist/ui/server/security.html +2 -2
- package/dist/ui/server/services.html +26 -26
- package/dist/ui/server/sites.html +119 -119
- package/dist/ui/server/ssh-keys.html +52 -52
- package/dist/ui/server/team.html +144 -144
- package/dist/ui/server/terminal.html +15 -15
- package/dist/ui/serverless/alarms.html +52 -52
- package/dist/ui/serverless/assets.html +27 -27
- package/dist/ui/serverless/cost.html +2 -2
- package/dist/ui/serverless/data.html +35 -35
- package/dist/ui/serverless/deployments.html +27 -27
- package/dist/ui/serverless/firewall.html +1 -1
- package/dist/ui/serverless/functions.html +39 -39
- package/dist/ui/serverless/logs.html +24 -24
- package/dist/ui/serverless/metrics.html +2 -2
- package/dist/ui/serverless/queues.html +48 -48
- package/dist/ui/serverless/secrets.html +52 -52
- package/dist/ui/serverless/traces.html +6 -6
- package/dist/ui/serverless.html +54 -54
- package/dist/ui-src/src/charts.ts +8721 -13558
- package/dist/ui-src/src/topology.ts +2 -2
- package/package.json +3 -3
- package/dist/bin/chunk-0zwknfwp.js +0 -1
- package/dist/bin/chunk-3aph4c1w.js +0 -2
- package/dist/bin/chunk-5nkqza92.js +0 -1
- package/dist/bin/chunk-64vczwwt.js +0 -1
- package/dist/bin/chunk-6tfwm33r.js +0 -6
- package/dist/bin/chunk-71t1gmsq.js +0 -1
- package/dist/bin/chunk-7g2ahkse.js +0 -1
- package/dist/bin/chunk-7zhgmp1s.js +0 -3
- package/dist/bin/chunk-82mj52xr.js +0 -141
- package/dist/bin/chunk-8ewncfce.js +0 -37
- package/dist/bin/chunk-9a88fp00.js +0 -2
- package/dist/bin/chunk-9kf0np8j.js +0 -44
- package/dist/bin/chunk-a7w13qfm.js +0 -2
- package/dist/bin/chunk-b4wt9jcg.js +0 -60
- package/dist/bin/chunk-btsyjhk7.js +0 -92
- package/dist/bin/chunk-c0bdafbx.js +0 -2
- package/dist/bin/chunk-cd0ps58j.js +0 -1
- package/dist/bin/chunk-cxt74wsj.js +0 -1
- package/dist/bin/chunk-d7ke90zt.js +0 -2
- package/dist/bin/chunk-djg4zyqk.js +0 -1
- package/dist/bin/chunk-dkaz333b.js +0 -1
- package/dist/bin/chunk-dkf4qsp2.js +0 -1
- package/dist/bin/chunk-e2bybahr.js +0 -3
- package/dist/bin/chunk-e5ab5twy.js +0 -50
- package/dist/bin/chunk-edvvx3hg.js +0 -1
- package/dist/bin/chunk-ehc63fvs.js +0 -2
- package/dist/bin/chunk-f06c5np9.js +0 -1
- package/dist/bin/chunk-g6baf9c5.js +0 -512
- package/dist/bin/chunk-gq8794k6.js +0 -1
- package/dist/bin/chunk-hq9x489e.js +0 -70
- package/dist/bin/chunk-ja1vjdn1.js +0 -6
- package/dist/bin/chunk-k3120rx6.js +0 -1
- package/dist/bin/chunk-kg61p5hw.js +0 -3
- package/dist/bin/chunk-mcr0r4at.js +0 -2
- package/dist/bin/chunk-mfrf9q4b.js +0 -2
- package/dist/bin/chunk-my3ewh3a.js +0 -34
- package/dist/bin/chunk-nw3d4k52.js +0 -1
- package/dist/bin/chunk-p70bc9yr.js +0 -1
- package/dist/bin/chunk-q5cmfpzt.js +0 -1
- package/dist/bin/chunk-rtecnmts.js +0 -4
- package/dist/bin/chunk-rv18092e.js +0 -585
- package/dist/bin/chunk-s4yzes15.js +0 -2
- package/dist/bin/chunk-sj5csg49.js +0 -2
- package/dist/bin/chunk-ta7sh0cc.js +0 -1
- package/dist/bin/chunk-tfbs8k8v.js +0 -111
- package/dist/bin/chunk-tvz9c388.js +0 -1
- package/dist/bin/chunk-x6f61g36.js +0 -9
- package/dist/bin/chunk-xhwqpgwq.js +0 -2
- package/dist/bin/chunk-xk08030d.js +0 -6
- package/dist/bin/chunk-xkfrqqcs.js +0 -1
- package/dist/bin/chunk-y1h63vpm.js +0 -1
- package/dist/bin/chunk-zdt2rjk6.js +0 -1
- package/dist/bin/chunk-zh2d4704.js +0 -1
- package/dist/bin/chunk-zpe64t4r.js +0 -1
- package/dist/chunk-152he7m3.js +0 -92
- package/dist/chunk-1qdne0bf.js +0 -1
- package/dist/chunk-3mgj3hrh.js +0 -5
- package/dist/chunk-6kpbveb8.js +0 -5
- package/dist/chunk-73ztr55z.js +0 -2
- package/dist/chunk-a84gmpyh.js +0 -1
- package/dist/chunk-aj025v2s.js +0 -4
- package/dist/chunk-b087qsyf.js +0 -704
- package/dist/chunk-by2bwzk6.js +0 -141
- package/dist/chunk-h42zck7h.js +0 -60
- package/dist/chunk-hn40z11p.js +0 -37
- package/dist/chunk-m8fs0233.js +0 -34
- package/dist/chunk-mz0dk78z.js +0 -6
- package/dist/chunk-nms5q44e.js +0 -1
- package/dist/chunk-nzqxdkch.js +0 -445
- package/dist/chunk-qm32ytbr.js +0 -1
- package/dist/chunk-t0xgmhd6.js +0 -114
- package/dist/chunk-t3t9ymec.js +0 -1
- package/dist/chunk-tz9myq9a.js +0 -2
- package/dist/chunk-wavjkdb8.js +0 -2
- package/dist/chunk-x3hay61c.js +0 -44
- package/dist/chunk-xcj8zfmg.js +0 -2
- package/dist/chunk-y2v22hkv.js +0 -1
- package/dist/chunk-y4xkj2f1.js +0 -50
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import{md as Z,rd as L,sd as Y,td as _,ud as K}from"./chunk-mfrf9q4b.js";import{wd as U}from"./chunk-82mj52xr.js";import{jg as W}from"./chunk-a7w13qfm.js";import{og as M}from"./chunk-e5ab5twy.js";import{qg as B}from"./chunk-btsyjhk7.js";import{op as j}from"./chunk-ehc63fvs.js";function J(t){let{bucketName:s,domain:l,aliases:e,certificateArn:m,defaultRootObject:i="index.html",errorDocument:r="404.html",passthroughUrls:a=!1,singlePageApp:d=!1,dynamicApp:b=!1,computeOriginDomain:k,computeOriginPort:R=3008,computeOriginId:P="app-compute",retainOnStackDelete:x=!1}=t,A=x?{DeletionPolicy:"Retain",UpdateReplacePolicy:"Retain"}:{},y=b&&!!k,T=y?["GET","HEAD","OPTIONS","PUT","POST","PATCH","DELETE"]:["GET","HEAD"],F=y?["GET","HEAD"]:["GET","HEAD"],N={},O={};N.S3Bucket={Type:"AWS::S3::Bucket",...A,Properties:{BucketName:s,PublicAccessBlockConfiguration:{BlockPublicAcls:!0,BlockPublicPolicy:!1,IgnorePublicAcls:!0,RestrictPublicBuckets:!1},WebsiteConfiguration:{IndexDocument:i,ErrorDocument:r}}},O.BucketName={Description:"S3 Bucket Name",Value:{Ref:"S3Bucket"}},O.BucketArn={Description:"S3 Bucket ARN",Value:{"Fn::GetAtt":["S3Bucket","Arn"]}},N.CloudFrontOAC={Type:"AWS::CloudFront::OriginAccessControl",...A,Properties:{OriginAccessControlConfig:{Name:`OAC-${s}`,Description:`OAC for ${s}`,OriginAccessControlOriginType:"s3",SigningBehavior:"always",SigningProtocol:"sigv4"}}};let D;if(a&&y)D="InstallRootRedirectFunction",N[D]={Type:"AWS::CloudFront::Function",Properties:{Name:{"Fn::Sub":"${AWS::StackName}-install-root-redirect"},AutoPublish:!0,FunctionConfig:{Comment:"Redirect curl pantry.dev | bash (GET /) to /install.sh on S3",Runtime:"cloudfront-js-2.0"},FunctionCode:`function handler(event) {
|
|
2
|
-
var request = event.request;
|
|
3
|
-
if (request.uri === '/' || request.uri === '') {
|
|
4
|
-
return {
|
|
5
|
-
statusCode: 302,
|
|
6
|
-
statusDescription: 'Found',
|
|
7
|
-
headers: {
|
|
8
|
-
location: { value: 'https://' + request.headers.host.value + '/install.sh' }
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
return request;
|
|
13
|
-
}`}};if(!a)N.UrlRewriteFunction={Type:"AWS::CloudFront::Function",Properties:{Name:{"Fn::Sub":"${AWS::StackName}-url-rewrite"},AutoPublish:!0,FunctionConfig:{Comment:"Append .html extension to URLs without extensions",Runtime:"cloudfront-js-2.0"},FunctionCode:`function handler(event) {
|
|
14
|
-
const request = event.request;
|
|
15
|
-
var uri = request.uri;
|
|
16
|
-
|
|
17
|
-
// If URI ends with /, serve index.html
|
|
18
|
-
if (uri.endsWith('/')) {
|
|
19
|
-
request.uri = uri + 'index.html';
|
|
20
|
-
}
|
|
21
|
-
// If URI doesn't have an extension, append .html
|
|
22
|
-
else if (!uri.includes('.')) {
|
|
23
|
-
request.uri = uri + '.html';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return request;
|
|
27
|
-
}`}};let w={Id:`S3-${s}`,DomainName:{"Fn::GetAtt":["S3Bucket","RegionalDomainName"]},S3OriginConfig:{OriginAccessIdentity:""},OriginAccessControlId:{"Fn::GetAtt":["CloudFrontOAC","Id"]}},u=y?{Id:P,DomainName:k,CustomOriginConfig:{HTTPPort:R,HTTPSPort:443,OriginProtocolPolicy:"http-only",OriginSSLProtocols:["TLSv1.2"]}}:null,C=y?P:`S3-${s}`,f={Enabled:!0,DefaultRootObject:i,HttpVersion:"http2and3",IPV6Enabled:!0,PriceClass:"PriceClass_100",Origins:u?[u,w]:[w],DefaultCacheBehavior:{TargetOriginId:C,ViewerProtocolPolicy:"redirect-to-https",AllowedMethods:T,CachedMethods:F,Compress:!0,...y?{CachePolicyId:"4135ea2d-6df8-44a3-9df3-4b5a84be39ad",OriginRequestPolicyId:"b689b0a8-53d0-40ab-baf2-68738e2966ac",...a&&D?{FunctionAssociations:[{EventType:"viewer-request",FunctionARN:{"Fn::GetAtt":[D,"FunctionARN"]}}]}:{}}:{CachePolicyId:"658327ea-f89d-4fab-a63d-7e88639e58f6",...!a&&{FunctionAssociations:[{EventType:"viewer-request",FunctionARN:{"Fn::GetAtt":["UrlRewriteFunction","FunctionARN"]}}]}}},...y&&a?{CacheBehaviors:[{PathPattern:"/install.sh",TargetOriginId:`S3-${s}`,ViewerProtocolPolicy:"redirect-to-https",AllowedMethods:["GET","HEAD","OPTIONS"],CachedMethods:["GET","HEAD","OPTIONS"],Compress:!0,CachePolicyId:"658327ea-f89d-4fab-a63d-7e88639e58f6"}]}:{},CustomErrorResponses:d?[{ErrorCode:403,ResponseCode:200,ResponsePagePath:`/${i}`,ErrorCachingMinTTL:300},{ErrorCode:404,ResponseCode:200,ResponsePagePath:`/${i}`,ErrorCachingMinTTL:300}]:[{ErrorCode:403,ResponseCode:404,ResponsePagePath:`/${r}`,ErrorCachingMinTTL:300},{ErrorCode:404,ResponseCode:404,ResponsePagePath:`/${r}`,ErrorCachingMinTTL:300}]};if(l&&m)f.Aliases=e&&e.length>0?e:[l],f.ViewerCertificate={AcmCertificateArn:m,SslSupportMethod:"sni-only",MinimumProtocolVersion:"TLSv1.2_2021"};else f.ViewerCertificate={CloudFrontDefaultCertificate:!0};return N.CloudFrontDistribution={Type:"AWS::CloudFront::Distribution",...A,DependsOn:["S3Bucket","CloudFrontOAC",...a&&y&&D?[D]:[],...!a?["UrlRewriteFunction"]:[]],Properties:{DistributionConfig:f}},O.DistributionId={Description:"CloudFront Distribution ID",Value:{Ref:"CloudFrontDistribution"}},O.DistributionDomain={Description:"CloudFront Distribution Domain",Value:{"Fn::GetAtt":["CloudFrontDistribution","DomainName"]}},N.S3BucketPolicy={Type:"AWS::S3::BucketPolicy",...A,DependsOn:["S3Bucket","CloudFrontDistribution"],Properties:{Bucket:{Ref:"S3Bucket"},PolicyDocument:{Version:"2012-10-17",Statement:[{Sid:"AllowCloudFrontServicePrincipal",Effect:"Allow",Principal:{Service:"cloudfront.amazonaws.com"},Action:"s3:GetObject",Resource:{"Fn::Sub":"arn:aws:s3:::${S3Bucket}/*"},Condition:{StringEquals:{"AWS:SourceArn":{"Fn::Sub":"arn:aws:cloudfront::${AWS::AccountId}:distribution/${CloudFrontDistribution}"}}}}]}}},O.SiteUrl={Description:"Site URL",Value:l?`https://${l}`:{"Fn::Sub":"https://${CloudFrontDistribution.DomainName}"}},{AWSTemplateFormatVersion:"2010-09-09",Description:`Static site infrastructure for ${l||s} (External DNS)`,Resources:N,Outputs:O}}async function G(t){let s=t.region||"us-east-1",l="us-east-1",e=t.domain,m=t.bucket||e.replace(/\./g,"-"),i=t.stackName||`${t.siteName}-static-site`,r=new W("us-east-1"),a=new L("us-east-1"),d=null;if(!t.skipDnsVerification){d=K(t.dnsProvider),console.log(`Verifying DNS provider can manage ${e}...`);let o=await d.listRecords(e);if(!o.success){let n=o.message||"unknown error — check API credentials and domain ownership";return{success:!1,stackName:i,bucket:m,message:`DNS provider '${d.name}' cannot manage domain ${e}: ${n}`}}console.log(`DNS provider '${d.name}' verified for ${e}`)}else console.log(`Skipping DNS verification for ${e}`);let b=t.certificateArn,P=e.split(".").length===2?`www.${e}`:void 0;if(!b){console.log(`Checking for existing SSL certificate for ${e}...`);let o=await a.findCertificateByDomain(e),n=!1;if(o&&o.Status==="ISSUED"){if(P&&o.SubjectAlternativeNames)n=o.SubjectAlternativeNames.includes(P)||o.SubjectAlternativeNames.some((g)=>g===`*.${e}`);else n=!0;if(n)b=o.CertificateArn,console.log(`Found existing certificate with www coverage: ${b}`);else console.log(`Existing certificate doesn't cover ${P}, requesting new one...`)}if(!b){if(!d)return{success:!1,stackName:i,bucket:m,message:`No DNS provider available to validate SSL certificate for ${e}. Provide a certificateArn or enable DNS verification.`};console.log(`Requesting new SSL certificate for ${e}${P?` (including ${P})`:""}...`);let p=await new _(d,"us-east-1").findOrCreateCertificate({domainName:e,subjectAlternativeNames:P?[P]:void 0,waitForValidation:!0,maxWaitMinutes:10});if(p.status!=="issued")return{success:!1,stackName:i,bucket:m,message:`SSL certificate validation failed. Status: ${p.status}`};b=p.certificateArn,console.log(`Certificate issued: ${b}`)}}let x=!1,A;try{let o=await r.describeStacks({stackName:i});if(o.Stacks.length>0){let n=o.Stacks[0],g=n.StackStatus;if(g==="DELETE_IN_PROGRESS")console.log("Previous stack is still being deleted, waiting..."),await r.waitForStack(i,"stack-delete-complete"),x=!1;else if(g==="DELETE_COMPLETE")x=!1;else x=!0,A=(n.Outputs||[]).find((c)=>c.OutputKey==="BucketName")?.OutputValue}}catch(o){if(o.message?.includes("does not exist")||o.code==="ValidationError")x=!1;else throw o}let y=A||m;if(!x){let o=new B(s),n=new U,g=!1;if(e)try{console.log(`Checking for existing CloudFront distributions with alias ${e}...`);let p=await n.listDistributions();for(let c of p){let S=[];if(c.Aliases?.Items){if(Array.isArray(c.Aliases.Items))S=c.Aliases.Items;else if(typeof c.Aliases.Items==="object"){let I=c.Aliases.Items.CNAME;if(typeof I==="string")S=[I];else if(Array.isArray(I))S=I}}if(S.includes(e)){g=!0,console.log(`Found existing CloudFront distribution ${c.Id} with alias ${e}`),console.log("Reusing existing infrastructure for updates...");let h=(await n.getDistributionConfig(c.Id)).DistributionConfig?.Origins?.Items,v;if(h){let E=[];if(Array.isArray(h))E=h;else if(h.Origin)E=Array.isArray(h.Origin)?h.Origin:[h.Origin];else E=[h];for(let H of E){let V=(H.DomainName||"").match(/^([^.]+)\.s3[\.-]/);if(V){v=V[1];break}}}if(v)return console.log(`Using existing S3 bucket: ${v}`),{success:!0,stackName:`existing-${c.Id}`,bucket:v,distributionId:c.Id,distributionDomain:c.DomainName,domain:e,certificateArn:b,message:"Using existing CloudFront distribution",_existingInfrastructure:!0}}}}catch{}if(!g)try{if((await o.headBucket(m)).exists){console.log(`Found orphaned S3 bucket ${m}, cleaning up...`);try{let c=o.emptyBucket(m).then(()=>o.deleteBucket(m)),S=new Promise((I,h)=>setTimeout(()=>h(Error("Bucket cleanup timeout")),30000));await Promise.race([c,S]),console.log(`Deleted orphaned S3 bucket ${m}`)}catch(c){console.log(`Note: Could not clean up S3 bucket: ${c.message}`);let S=Date.now().toString(36);y=`${m}-${S}`,console.log(`Using alternative bucket name: ${y}`)}}}catch{}}let F=J({bucketName:y,domain:e,aliases:P?[e,P]:[e],certificateArn:b,defaultRootObject:t.defaultRootObject,errorDocument:t.errorDocument,passthroughUrls:t.passthroughUrls,singlePageApp:t.singlePageApp,dynamicApp:t.dynamicApp,computeOriginDomain:t.computeOriginDomain,computeOriginPort:t.computeOriginPort,computeOriginId:t.computeOriginId}),N=Object.entries(t.tags||{}).map(([o,n])=>({Key:o,Value:n}));if(N.push({Key:"ManagedBy",Value:"ts-cloud"}),N.push({Key:"Application",Value:t.siteName}),d)N.push({Key:"DnsProvider",Value:d.name});let O,D=!1;if(x){D=!0,console.log(`Updating CloudFormation stack: ${i}`);try{O=(await r.updateStack({stackName:i,templateBody:JSON.stringify(F),capabilities:["CAPABILITY_IAM"],tags:N})).StackId,console.log(`Update initiated, stack ID: ${O}`)}catch(o){if(o.message?.includes("No updates are to be performed")){let n=await r.describeStacks({stackName:i});O=n.Stacks[0].StackId;let g=n.Stacks[0]?.Outputs||[],p=(S)=>g.find((I)=>I.OutputKey===S)?.OutputValue,c=p("DistributionDomain");if(c)await q(d,e,c);return{success:!0,stackId:O,stackName:i,bucket:p("BucketName")||y,distributionId:p("DistributionId"),distributionDomain:c,domain:e,certificateArn:b,message:"Static site infrastructure is already up to date"}}else throw o}}else console.log(`Creating CloudFormation stack: ${i}`),console.log(`Bucket name: ${y}`),console.log(`Domain: ${e}`),console.log(`Certificate ARN: ${b}`),O=(await r.createStack({stackName:i,templateBody:JSON.stringify(F),capabilities:["CAPABILITY_IAM"],tags:N,onFailure:"DELETE"})).StackId,console.log(`Create initiated, stack ID: ${O}`);console.log(`Waiting for stack to reach ${D?"stack-update-complete":"stack-create-complete"}...`);try{await r.waitForStack(i,D?"stack-update-complete":"stack-create-complete"),console.log("Stack operation completed successfully!")}catch(o){if(o.message?.includes("must be verified")||o.message?.includes("Access denied for operation")){console.log("CloudFront account verification required - checking for existing infrastructure...");try{let g=new U,p=await g.listDistributions();for(let c of p){let S=[];if(c.Aliases?.Items){if(Array.isArray(c.Aliases.Items))S=c.Aliases.Items;else if(typeof c.Aliases.Items==="object"){let I=c.Aliases.Items.CNAME;if(typeof I==="string")S=[I];else if(Array.isArray(I))S=I}}if(S.includes(e)){console.log(`Found existing CloudFront distribution ${c.Id} with alias ${e}`),console.log("Using existing infrastructure despite account verification requirement...");let h=(await g.getDistributionConfig(c.Id)).DistributionConfig?.Origins?.Items,v;if(h){let E=[];if(Array.isArray(h))E=h;else if(h.Origin)E=Array.isArray(h.Origin)?h.Origin:[h.Origin];else E=[h];for(let H of E){let V=(H.DomainName||"").match(/^([^.]+)\.s3[\.-]/);if(V){v=V[1];break}}}if(v){console.log(`Using existing S3 bucket: ${v}`);let E=c.DomainName;if(E)await q(d,e,E);return{success:!0,stackName:`existing-${c.Id}`,bucket:v,distributionId:c.Id,distributionDomain:c.DomainName,domain:e,certificateArn:b,message:"Using existing CloudFront distribution (account verification pending for new distributions)"}}}}}catch{}return console.log(`
|
|
28
|
-
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
29
|
-
│ AWS ACCOUNT VERIFICATION REQUIRED │
|
|
30
|
-
├─────────────────────────────────────────────────────────────────────────────┤
|
|
31
|
-
│ Your AWS account must be verified before you can create CloudFront │
|
|
32
|
-
│ distributions. This is a one-time requirement for new AWS accounts. │
|
|
33
|
-
│ │
|
|
34
|
-
│ To verify your account: │
|
|
35
|
-
│ │
|
|
36
|
-
│ 1. Go to: https://console.aws.amazon.com/support/home#/ │
|
|
37
|
-
│ 2. Click "Create case" │
|
|
38
|
-
│ 3. Select "Service limit increase" │
|
|
39
|
-
│ 4. For Service: Select "CloudFront" │
|
|
40
|
-
│ 5. For Request: "Please verify my account for CloudFront access" │
|
|
41
|
-
│ 6. Submit the case │
|
|
42
|
-
│ │
|
|
43
|
-
│ Verification typically takes 1-2 business days. │
|
|
44
|
-
│ After verification, re-run: bunx bunpress deploy │
|
|
45
|
-
└─────────────────────────────────────────────────────────────────────────────┘`),{success:!1,stackId:O,stackName:i,bucket:y,message:"CloudFront account verification required. Please contact AWS Support."}}return{success:!1,stackId:O,stackName:i,bucket:y,message:`Stack deployment failed: ${o.message}`}}let u=(await r.describeStacks({stackName:i})).Stacks[0]?.Outputs||[],C=(o)=>u.find((n)=>n.OutputKey===o)?.OutputValue,f=C("DistributionDomain");if(f&&d)console.log(`Creating DNS records via ${d.name}...`),await q(d,e,f);else if(f&&!d)console.log("Skipping DNS record creation (DNS verification was skipped)");return{success:!0,stackId:O,stackName:i,bucket:C("BucketName")||y,distributionId:C("DistributionId"),distributionDomain:f,domain:e,certificateArn:b,message:"Static site infrastructure deployed successfully with external DNS"}}async function q(t,s,l){if(!t){console.log("Skipping DNS record creation (DNS verification was skipped)");return}if(s.split(".").length===2)if(t instanceof Z){console.log(`Creating Route53 alias record for apex domain ${s} -> ${l}`);let i=await t.createCloudFrontAlias({domain:s,name:s,cloudFrontDomainName:l});if(!i.success)console.warn(`Warning: Could not create Route53 alias record: ${i.message}`),console.warn("Please manually create an A-record alias in Route53:"),console.warn(` ${s} -> ${l}`);else console.log(`Created Route53 alias record: ${s} -> ${l}`);let r=`www.${s}`;console.log(`Creating Route53 alias record for ${r} -> ${l}`);let a=await t.createCloudFrontAlias({domain:s,name:r,cloudFrontDomainName:l});if(!a.success)console.warn(`Warning: Could not create www Route53 alias: ${a.message}`),console.warn("Please manually create an A-record alias in Route53:"),console.warn(` ${r} -> ${l}`);else console.log(`Created Route53 alias record: ${r} -> ${l}`)}else{try{let d=await t.listRecords(s,"A");if(d.success)for(let b of d.records){let k=b.name.replace(/\.$/,"");if(k===s||k==="")console.log(`Removing existing root A record (${b.content}) to make room for ALIAS...`),await t.deleteRecord(s,{name:s,type:"A",content:b.content})}}catch(d){console.log(`Note: Could not check for conflicting A records: ${d instanceof Error?d.message:d}`)}console.log(`Creating ALIAS record for apex domain ${s} -> ${l}`);let i=await t.upsertRecord(s,{name:s,type:"ALIAS",content:l,ttl:600});if(!i.success)console.warn(`Warning: Could not create ALIAS record: ${i.message}`),console.warn("Please manually create an ALIAS record in your DNS provider:"),console.warn(` ${s} -> ${l}`);else console.log(`Created ALIAS record: ${s} -> ${l}`);let r=`www.${s}`;console.log(`Creating CNAME record for ${r} -> ${l}`);let a=await t.upsertRecord(s,{name:r,type:"CNAME",content:l,ttl:600});if(!a.success)console.warn(`Warning: Could not create www DNS record: ${a.message}`),console.warn("Please manually create a CNAME record:"),console.warn(` ${r} -> ${l}`);else console.log(`Created CNAME record: ${r} -> ${l}`)}else{console.log(`Creating CNAME record for ${s} -> ${l}`);let i=await t.upsertRecord(s,{name:s,type:"CNAME",content:l,ttl:600});if(!i.success)console.warn(`Warning: Could not create DNS record: ${i.message}`),console.warn("Please manually create a CNAME record:"),console.warn(` ${s} -> ${l}`);else console.log(`Created CNAME record: ${s} -> ${l}`)}}async function le(t){let{sourceDir:s,cleanBucket:l=!1,onProgress:e,...m}=t;e?.("infrastructure","Deploying CloudFormation stack...");let i=await G(m);if(!i.success)return i;if(l){e?.("clean","Cleaning old files from S3...");try{await new B(m.region||"us-east-1").emptyBucket(i.bucket)}catch(b){console.log(`Note: Could not clean bucket: ${b.message}`)}}e?.("upload","Uploading files to S3...");let{uploadStaticFiles:r}=await import("./chunk-zdt2rjk6.js"),a=await r({sourceDir:s,bucket:i.bucket,region:m.region||"us-east-1",cacheControl:m.cacheControl,onProgress:(b,k,R)=>{e?.("upload",`${b}/${k}: ${R}`)}});if(a.errors.length>0)return{...i,success:!1,message:`Upload errors: ${a.errors.join(", ")}`,filesUploaded:a.uploaded};if(i.distributionId&&a.uploaded>0){e?.("invalidate","Invalidating CloudFront cache...");let{invalidateCache:b}=await import("./chunk-zdt2rjk6.js");await b(i.distributionId)}e?.("complete","Deployment complete!");let d=a.skipped>0?`Deployed ${a.uploaded} files (${a.skipped} unchanged) with external DNS`:`Deployed ${a.uploaded} files successfully with external DNS`;return{...i,filesUploaded:a.uploaded,filesSkipped:a.skipped,message:d}}function Q(t){let{bucketName:s,domain:l,certificateArn:e,hostedZoneId:m,defaultRootObject:i="index.html",errorDocument:r="404.html"}=t,a={},d={};a.S3Bucket={Type:"AWS::S3::Bucket",Properties:{BucketName:s,PublicAccessBlockConfiguration:{BlockPublicAcls:!0,BlockPublicPolicy:!1,IgnorePublicAcls:!0,RestrictPublicBuckets:!1},WebsiteConfiguration:{IndexDocument:i,ErrorDocument:r}}},d.BucketName={Description:"S3 Bucket Name",Value:{Ref:"S3Bucket"}},d.BucketArn={Description:"S3 Bucket ARN",Value:{"Fn::GetAtt":["S3Bucket","Arn"]}},a.CloudFrontOAC={Type:"AWS::CloudFront::OriginAccessControl",Properties:{OriginAccessControlConfig:{Name:`OAC-${s}`,Description:`OAC for ${s}`,OriginAccessControlOriginType:"s3",SigningBehavior:"always",SigningProtocol:"sigv4"}}},a.UrlRewriteFunction={Type:"AWS::CloudFront::Function",Properties:{Name:{"Fn::Sub":"${AWS::StackName}-url-rewrite"},AutoPublish:!0,FunctionConfig:{Comment:"Append .html extension to URLs without extensions",Runtime:"cloudfront-js-2.0"},FunctionCode:`function handler(event) {
|
|
46
|
-
const request = event.request;
|
|
47
|
-
var uri = request.uri;
|
|
48
|
-
|
|
49
|
-
// If URI ends with /, serve index.html
|
|
50
|
-
if (uri.endsWith('/')) {
|
|
51
|
-
request.uri = uri + 'index.html';
|
|
52
|
-
}
|
|
53
|
-
// If URI doesn't have an extension, append .html
|
|
54
|
-
else if (!uri.includes('.')) {
|
|
55
|
-
request.uri = uri + '.html';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return request;
|
|
59
|
-
}`}};let b={Enabled:!0,DefaultRootObject:i,HttpVersion:"http2and3",IPV6Enabled:!0,PriceClass:"PriceClass_100",Origins:[{Id:`S3-${s}`,DomainName:{"Fn::GetAtt":["S3Bucket","RegionalDomainName"]},S3OriginConfig:{OriginAccessIdentity:""},OriginAccessControlId:{"Fn::GetAtt":["CloudFrontOAC","Id"]}}],DefaultCacheBehavior:{TargetOriginId:`S3-${s}`,ViewerProtocolPolicy:"redirect-to-https",AllowedMethods:["GET","HEAD"],CachedMethods:["GET","HEAD"],Compress:!0,CachePolicyId:"658327ea-f89d-4fab-a63d-7e88639e58f6",FunctionAssociations:[{EventType:"viewer-request",FunctionARN:{"Fn::GetAtt":["UrlRewriteFunction","FunctionARN"]}}]},CustomErrorResponses:[{ErrorCode:403,ResponseCode:200,ResponsePagePath:`/${i}`,ErrorCachingMinTTL:300},{ErrorCode:404,ResponseCode:404,ResponsePagePath:`/${r}`,ErrorCachingMinTTL:300}]};if(l&&e)b.Aliases=[l],b.ViewerCertificate={AcmCertificateArn:e,SslSupportMethod:"sni-only",MinimumProtocolVersion:"TLSv1.2_2021"};else b.ViewerCertificate={CloudFrontDefaultCertificate:!0};if(a.CloudFrontDistribution={Type:"AWS::CloudFront::Distribution",DependsOn:["S3Bucket","CloudFrontOAC","UrlRewriteFunction"],Properties:{DistributionConfig:b}},d.DistributionId={Description:"CloudFront Distribution ID",Value:{Ref:"CloudFrontDistribution"}},d.DistributionDomain={Description:"CloudFront Distribution Domain",Value:{"Fn::GetAtt":["CloudFrontDistribution","DomainName"]}},a.S3BucketPolicy={Type:"AWS::S3::BucketPolicy",DependsOn:["S3Bucket","CloudFrontDistribution"],Properties:{Bucket:{Ref:"S3Bucket"},PolicyDocument:{Version:"2012-10-17",Statement:[{Sid:"AllowCloudFrontServicePrincipal",Effect:"Allow",Principal:{Service:"cloudfront.amazonaws.com"},Action:"s3:GetObject",Resource:{"Fn::Sub":"arn:aws:s3:::${S3Bucket}/*"},Condition:{StringEquals:{"AWS:SourceArn":{"Fn::Sub":"arn:aws:cloudfront::${AWS::AccountId}:distribution/${CloudFrontDistribution}"}}}}]}}},l&&m)a.DNSRecord={Type:"AWS::Route53::RecordSet",DependsOn:"CloudFrontDistribution",Properties:{HostedZoneId:m,Name:l,Type:"A",AliasTarget:{DNSName:{"Fn::GetAtt":["CloudFrontDistribution","DomainName"]},HostedZoneId:"Z2FDTNDATAQYW2",EvaluateTargetHealth:!1}}},a.DNSRecordIPv6={Type:"AWS::Route53::RecordSet",DependsOn:"CloudFrontDistribution",Properties:{HostedZoneId:m,Name:l,Type:"AAAA",AliasTarget:{DNSName:{"Fn::GetAtt":["CloudFrontDistribution","DomainName"]},HostedZoneId:"Z2FDTNDATAQYW2",EvaluateTargetHealth:!1}}},d.SiteUrl={Description:"Site URL",Value:{"Fn::Sub":"https://${DNSRecord}"}};return{AWSTemplateFormatVersion:"2010-09-09",Description:`Static site infrastructure for ${l||s}`,Resources:a,Outputs:d}}async function X(t){if(t.dnsProvider&&t.dnsProvider.provider!=="route53"){let u=t.domain||(t.subdomain&&t.baseDomain?`${t.subdomain}.${t.baseDomain}`:void 0);if(!u)return{success:!1,stackName:t.stackName||`${t.siteName}-static-site`,bucket:t.bucket||`${t.siteName}-${Date.now()}`,message:"Domain is required when using external DNS provider"};return G({siteName:t.siteName,region:t.region,domain:u,bucket:t.bucket,certificateArn:t.certificateArn,stackName:t.stackName,defaultRootObject:t.defaultRootObject,errorDocument:t.errorDocument,cacheControl:t.cacheControl,tags:t.tags,dnsProvider:t.dnsProvider})}let s=t.region||"us-east-1",l="us-east-1",e;if(t.domain)e=t.domain;else if(t.subdomain&&t.baseDomain)e=`${t.subdomain}.${t.baseDomain}`;let m=t.bucket||(e?e.replace(/\./g,"-"):`${t.siteName}-${Date.now()}`),i=t.stackName||`${t.siteName}-static-site`,r=new W(l),a=new M,d=new L("us-east-1"),b=new Y("us-east-1"),k=t.hostedZoneId,R=t.certificateArn;if(e&&!k){let u=await a.findHostedZoneForDomain(e);if(u)k=u.Id.replace("/hostedzone/","");else return{success:!1,stackName:i,bucket:m,message:`No Route53 hosted zone found for ${t.baseDomain||e}. Please create one first.`}}if(e&&!R&&k){let u=await d.findCertificateByDomain(e);if(u&&u.Status==="ISSUED")R=u.CertificateArn;else R=(await b.requestAndValidate({domainName:e,hostedZoneId:k,waitForValidation:!0,maxWaitMinutes:10})).certificateArn}let P=!1,x;try{let u=await r.describeStacks({stackName:i});if(u.Stacks.length>0){let C=u.Stacks[0],f=C.StackStatus;if(f==="DELETE_IN_PROGRESS")console.log("Previous stack is still being deleted, waiting..."),await r.waitForStack(i,"stack-delete-complete"),P=!1;else if(f==="DELETE_COMPLETE")P=!1;else P=!0,x=(C.Outputs||[]).find((n)=>n.OutputKey==="BucketName")?.OutputValue}}catch(u){if(u.message?.includes("does not exist")||u.code==="ValidationError")P=!1;else throw u}let A=x||m;if(!P){let u=new B(s),C=new U,f=!1;if(e){try{console.log(`Checking for existing CloudFront distribution for ${e}...`);let o=await C.listDistributions();for(let n of o){let g=[];if(n.Aliases?.Items){if(Array.isArray(n.Aliases.Items))g=n.Aliases.Items;else if(typeof n.Aliases.Items==="object"){let p=n.Aliases.Items.CNAME;if(typeof p==="string")g=[p];else if(Array.isArray(p))g=p}}if(g.includes(e)){f=!0,console.log(`Found existing CloudFront distribution ${n.Id} for ${e}`);let c=(await C.getDistributionConfig(n.Id)).DistributionConfig?.Origins?.Items,S;if(c){let I=[];if(Array.isArray(c))I=c;else if(c.Origin)I=Array.isArray(c.Origin)?c.Origin:[c.Origin];else I=[c];for(let h of I){let E=(h.DomainName||"").match(/^([^.]+)\.s3[\.-]/);if(E){S=E[1];break}}}if(S){let I=e.replace(/\./g,"-");if(!S.startsWith(I)&&!S.includes(t.siteName)){console.log(`Warning: Found distribution with mismatched bucket ${S}, skipping...`);continue}if(console.log(`Using existing S3 bucket: ${S}`),k&&n.DomainName)try{console.log(`Ensuring Route53 records exist for ${e}...`),await a.createAliasRecord({HostedZoneId:k,Name:e,Type:"A",TargetHostedZoneId:M.CloudFrontHostedZoneId,TargetDNSName:n.DomainName,EvaluateTargetHealth:!1}),await a.createAliasRecord({HostedZoneId:k,Name:e,Type:"AAAA",TargetHostedZoneId:M.CloudFrontHostedZoneId,TargetDNSName:n.DomainName,EvaluateTargetHealth:!1}),console.log(`Route53 records ensured for ${e}`)}catch(h){console.log(`Note: Could not update Route53 records: ${h.message}`)}return{success:!0,stackName:`existing-${n.Id}`,bucket:S,distributionId:n.Id,distributionDomain:n.DomainName,domain:e,certificateArn:R,message:"Using existing CloudFront distribution"}}}}}catch{}if(k)try{let n=(await a.listResourceRecordSets({HostedZoneId:k})).ResourceRecordSets||[];for(let g of n)if(g.Name===`${e}.`&&(g.Type==="A"||g.Type==="AAAA")){if(g.AliasTarget){console.log(`Found orphaned Route53 ${g.Type} record for ${e}, cleaning up...`);try{await a.deleteRecord({HostedZoneId:k,RecordSet:g}),console.log(`Deleted orphaned Route53 ${g.Type} record for ${e}`)}catch(p){console.log(`Note: Could not delete Route53 record: ${p.message}`)}}}}catch{}}if(!f)try{if((await u.headBucket(m)).exists){console.log(`Found orphaned S3 bucket ${m}, cleaning up...`);try{let n=u.emptyBucket(m).then(()=>u.deleteBucket(m)),g=new Promise((p,c)=>setTimeout(()=>c(Error("Bucket cleanup timeout")),30000));await Promise.race([n,g]),console.log(`Deleted orphaned S3 bucket ${m}`)}catch(n){console.log(`Note: Could not clean up S3 bucket: ${n.message}`);let g=Date.now().toString(36);A=`${m}-${g}`,console.log(`Using alternative bucket name: ${A}`)}}}catch{}}let y=Q({bucketName:A,domain:e,certificateArn:R,hostedZoneId:k,defaultRootObject:t.defaultRootObject,errorDocument:t.errorDocument}),T=Object.entries(t.tags||{}).map(([u,C])=>({Key:u,Value:C}));T.push({Key:"ManagedBy",Value:"ts-cloud"}),T.push({Key:"Application",Value:t.siteName});let F,N=!1;if(P){N=!0,console.log(`Updating CloudFormation stack: ${i}`),console.log(`Using existing bucket: ${A}`),console.log(`Domain: ${e||"not specified"}`),console.log(`Certificate ARN: ${R||"not specified"}`);try{F=(await r.updateStack({stackName:i,templateBody:JSON.stringify(y),capabilities:["CAPABILITY_IAM"],tags:T})).StackId,console.log(`Update initiated, stack ID: ${F}`)}catch(u){if(u.message?.includes("No updates are to be performed")){let C=await r.describeStacks({stackName:i});F=C.Stacks[0].StackId;let f=C.Stacks[0]?.Outputs||[],o=(n)=>f.find((g)=>g.OutputKey===n)?.OutputValue;return{success:!0,stackId:F,stackName:i,bucket:o("BucketName")||A,distributionId:o("DistributionId"),distributionDomain:o("DistributionDomain"),domain:e,certificateArn:R,message:"Static site infrastructure is already up to date"}}else throw u}}else console.log(`Creating CloudFormation stack: ${i}`),console.log(`Bucket name: ${A}`),console.log(`Domain: ${e||"not specified"}`),console.log(`Certificate ARN: ${R||"not specified"}`),console.log("Stack does not exist, creating..."),F=(await r.createStack({stackName:i,templateBody:JSON.stringify(y),capabilities:["CAPABILITY_IAM"],tags:T,onFailure:"DELETE"})).StackId,console.log(`Create initiated, stack ID: ${F}`);console.log(`Waiting for stack to reach ${N?"stack-update-complete":"stack-create-complete"}...`);try{await r.waitForStack(i,N?"stack-update-complete":"stack-create-complete"),console.log("Stack operation completed successfully!")}catch(u){if(u.message?.includes("must be verified")||u.message?.includes("Access denied for operation")||u.message?.includes("failed")){console.log("CloudFormation deployment failed, trying direct API creation...");let C=new U;if(e)try{let f=await C.listDistributions();for(let o of f){let n=[];if(o.Aliases?.Items){if(Array.isArray(o.Aliases.Items))n=o.Aliases.Items;else if(typeof o.Aliases.Items==="object"){let g=o.Aliases.Items.CNAME;if(typeof g==="string")n=[g];else if(Array.isArray(g))n=g}}if(n.includes(e)){console.log(`Found existing CloudFront distribution ${o.Id} with alias ${e}`);let p=(await C.getDistributionConfig(o.Id)).DistributionConfig?.Origins?.Items,c;if(p){let S=[];if(Array.isArray(p))S=p;else if(p.Origin)S=Array.isArray(p.Origin)?p.Origin:[p.Origin];else S=[p];for(let I of S){let v=(I.DomainName||"").match(/^([^.]+)\.s3[\.-]/);if(v){c=v[1];break}}}if(c)return console.log(`Using existing S3 bucket: ${c}`),{success:!0,stackName:`existing-${o.Id}`,bucket:c,distributionId:o.Id,distributionDomain:o.DomainName,domain:e,certificateArn:R,message:"Using existing CloudFront distribution (account verification pending for new distributions)"}}}}catch{}console.log("No existing infrastructure found, creating via direct API calls...");try{let f=new B(s);if((await f.headBucket(A)).exists)console.log(`Using existing S3 bucket: ${A}`);else console.log(`Creating S3 bucket: ${A}...`),await f.createBucket(A);await f.putBucketWebsite(A,{IndexDocument:t.defaultRootObject||"index.html",ErrorDocument:t.errorDocument||"404.html"}),await f.putPublicAccessBlock(A,{BlockPublicAcls:!0,IgnorePublicAcls:!0,BlockPublicPolicy:!1,RestrictPublicBuckets:!1}),console.log(`S3 bucket ${A} configured`);let n=`OAC-${A}`;console.log(`Creating Origin Access Control: ${n}...`);let g=await C.findOrCreateOriginAccessControl(n);console.log(`Origin Access Control ${g.Id} ready`),console.log("Creating CloudFront distribution...");let p=await C.createDistributionForS3({bucketName:A,bucketRegion:s,originAccessControlId:g.Id,aliases:e?[e]:[],certificateArn:R,defaultRootObject:t.defaultRootObject||"index.html",comment:`Distribution for ${e||A}`});console.log(`CloudFront distribution ${p.Id} created`),console.log("Updating S3 bucket policy...");let c=U.getS3BucketPolicyForCloudFront(A,p.ARN);if(await f.putBucketPolicy(A,c),console.log("S3 bucket policy updated"),e&&k){console.log(`Creating Route53 records for ${e}...`);try{await a.createAliasRecord({HostedZoneId:k,Name:e,Type:"A",TargetHostedZoneId:M.CloudFrontHostedZoneId,TargetDNSName:p.DomainName,EvaluateTargetHealth:!1}),await a.createAliasRecord({HostedZoneId:k,Name:e,Type:"AAAA",TargetHostedZoneId:M.CloudFrontHostedZoneId,TargetDNSName:p.DomainName,EvaluateTargetHealth:!1}),console.log(`Route53 records created for ${e}`)}catch(S){console.log(`Note: Could not create Route53 records: ${S.message}`)}}return{success:!0,stackName:`direct-${p.Id}`,bucket:A,distributionId:p.Id,distributionDomain:p.DomainName,domain:e,certificateArn:R,message:"Static site infrastructure created via direct API calls"}}catch(f){return console.log(`Direct API creation failed: ${f.message}`),{success:!1,stackId:F,stackName:i,bucket:A,message:`Deployment failed: ${f.message}`}}}return{success:!1,stackId:F,stackName:i,bucket:A,message:`Stack deployment failed: ${u.message}`}}let D=(await r.describeStacks({stackName:i})).Stacks[0]?.Outputs||[],w=(u)=>D.find((C)=>C.OutputKey===u)?.OutputValue;return{success:!0,stackId:F,stackName:i,bucket:w("BucketName")||A,distributionId:w("DistributionId"),distributionDomain:w("DistributionDomain"),domain:e,certificateArn:R,message:"Static site infrastructure deployed successfully"}}async function ee(t){let{sourceDir:s,bucket:l,region:e,cacheControl:m="max-age=31536000, public",onProgress:i}=t,r=new B(e),{readdir:a}=await import("node:fs/promises"),{join:d,relative:b}=await import("node:path"),{createHash:k}=await import("node:crypto");async function R(D){let w=[],u=await a(D,{withFileTypes:!0});for(let C of u){let f=d(D,C.name);if(C.isDirectory())w.push(...await R(f));else w.push(f)}return w}function P(D){let w=D.split(".").pop()?.toLowerCase();return{html:"text/html; charset=utf-8",css:"text/css; charset=utf-8",js:"application/javascript; charset=utf-8",json:"application/json; charset=utf-8",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",ico:"image/x-icon",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",ttf:"font/ttf",xml:"application/xml",txt:"text/plain; charset=utf-8",sh:"text/plain; charset=utf-8",bash:"text/plain; charset=utf-8",ps1:"text/plain; charset=utf-8"}[w||""]||"application/octet-stream"}function x(D){return k("md5").update(D).digest("hex")}async function A(){let D=new Map,w;do{let u=await r.listObjects({bucket:l,maxKeys:1000,continuationToken:w});for(let C of u.objects){let f=C.ETag?.replace(/"/g,"")||"";D.set(C.Key,f)}w=u.nextContinuationToken}while(w);return D}let y=await R(s),T=[],F=0,N=0,O=await A();for(let D of y){let w=b(s,D),u=P(D),C=D.endsWith(".html")?"max-age=3600, public":m;try{let f=Buffer.from(await Bun.file(D).arrayBuffer()),o=x(f),n=O.get(w);if(n&&n===o){N++,i?.(F+N,y.length,w);continue}await r.putObject({bucket:l,key:w,body:f,contentType:u,cacheControl:C}),F++,i?.(F+N,y.length,w)}catch(f){T.push(`Failed to upload ${w}: ${f.message}`)}}return{uploaded:F,skipped:N,errors:T}}async function te(t){return{invalidationId:(await new U().invalidateAll(t)).Id}}async function Ae(t,s="us-east-1"){let l=new W(s);try{let r=((await l.describeStacks({stackName:t})).Stacks[0]?.Outputs||[]).find((a)=>a.OutputKey==="BucketName")?.OutputValue;if(r)await new B(s).emptyBucket(r)}catch{}await l.deleteStack(t);let e=await l.waitForStackComplete(t,60,1e4);return{success:e.success||e.status==="DELETE_COMPLETE",message:e.success?"Static site deleted successfully":`Deletion failed: ${e.status}`}}async function Ce(t){let{sourceDir:s,cleanBucket:l=!1,onProgress:e,...m}=t;e?.("infrastructure","Deploying CloudFormation stack...");let i=await X(m);if(!i.success)return i;if(l){e?.("clean","Cleaning old files from S3...");try{await new B(m.region||"us-east-1").emptyBucket(i.bucket)}catch(d){console.log(`Note: Could not clean bucket: ${d.message}`)}}e?.("upload","Uploading files to S3...");let r=await ee({sourceDir:s,bucket:i.bucket,region:m.region||"us-east-1",cacheControl:m.cacheControl,onProgress:(d,b,k)=>{e?.("upload",`${d}/${b}: ${k}`)}});if(r.errors.length>0)return{...i,success:!1,message:`Upload errors: ${r.errors.join(", ")}`,filesUploaded:r.uploaded};if(i.distributionId&&r.uploaded>0)e?.("invalidate","Invalidating CloudFront cache..."),await te(i.distributionId);e?.("complete","Deployment complete!");let a=r.skipped>0?`Deployed ${r.uploaded} files (${r.skipped} unchanged)`:`Deployed ${r.uploaded} files successfully`;return{...i,filesUploaded:r.uploaded,filesSkipped:r.skipped,message:a}}
|
|
60
|
-
export{Q as p,X as q,ee as r,te as s,Ae as t,Ce as u,le as v};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import{ch as U,dh as L}from"./chunk-ja1vjdn1.js";import{op as K}from"./chunk-ehc63fvs.js";import*as c from"node:crypto";import{readFileSync as D}from"node:fs";import{readdir as z}from"node:fs/promises";import{join as M}from"node:path";function R(e){if(e){let r=O(e);if(!r)throw Error(`AWS profile '${e}' not found in ~/.aws/credentials`);return r}let t=process.env.AWS_ACCESS_KEY_ID,s=process.env.AWS_SECRET_ACCESS_KEY;if(t&&s)return{accessKeyId:t,secretAccessKey:s,sessionToken:process.env.AWS_SESSION_TOKEN};return O(process.env.AWS_PROFILE||"default")??{accessKeyId:"",secretAccessKey:""}}function O(e){let{existsSync:t,readFileSync:s}=K("node:fs"),{homedir:r}=K("node:os"),{join:n}=K("node:path"),i=process.env.AWS_SHARED_CREDENTIALS_FILE||n(r(),".aws","credentials");if(!t(i))return null;let o=s(i,"utf-8"),a=null,g,l,u;for(let d of o.split(`
|
|
2
|
-
`)){let y=d.trim();if(!y||y.startsWith("#")||y.startsWith(";"))continue;let h=y.match(/^\[([^\]]+)\]$/);if(h){if(a===e&&g&&l)return{accessKeyId:g,secretAccessKey:l,sessionToken:u};a=h[1],g=void 0,l=void 0,u=void 0;continue}if(a===e){let[S,...m]=y.split("="),p=m.join("=").trim();switch(S.trim().toLowerCase()){case"aws_access_key_id":g=p;break;case"aws_secret_access_key":l=p;break;case"aws_session_token":u=p;break}}}if(a===e&&g&&l)return{accessKeyId:g,secretAccessKey:l,sessionToken:u};return null}function B(e){let{buffer:t,byteOffset:s,byteLength:r}=e;if(t instanceof ArrayBuffer)return t.slice(s,s+r);let n=new ArrayBuffer(r);return new Uint8Array(n).set(new Uint8Array(e)),n}class V{client;region;explicitProfile;endpoint;endpointProtocol="https";forcePathStyle;explicitCredentials;constructor(e="us-east-1",t,s){let r=typeof e==="string"?s:e,n=typeof e==="string"?e:e.region??"us-east-1",i=typeof e==="string"?t:e.profile,o=r?.endpoint?U({region:n,path:"/",endpoint:r.endpoint}):void 0;this.region=n,this.explicitProfile=i,this.endpoint=o?.host,this.endpointProtocol=o?.protocol??"https",this.forcePathStyle=r?.forcePathStyle,this.explicitCredentials=r?.credentials,this.client=new L(r?.credentials,{profile:i,endpoint:r?.endpoint,forcePathStyle:r?.forcePathStyle})}getCredentials(){if(this.explicitCredentials?.accessKeyId&&this.explicitCredentials.secretAccessKey)return this.explicitCredentials;let e=R(this.explicitProfile);if(e.accessKeyId&&e.secretAccessKey)return e;throw Error("S3 credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (or pass explicit credentials/profile), or configure ~/.aws/credentials.")}s3BaseHost(){return this.endpoint||`s3.${this.region}.amazonaws.com`}s3VirtualHost(e){return this.forcePathStyle?this.s3BaseHost():`${e}.${this.s3BaseHost()}`}objectPath(e,t){return this.forcePathStyle?`/${e}/${t}`:`/${t}`}objectUrl(e,t){return`${this.endpointProtocol}://${this.s3VirtualHost(e)}${this.objectPath(e,t)}`}async listBuckets(){let e=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/"}),t=[],r=(e?.ListAllMyBucketsResult??e)?.Buckets?.Bucket;if(r){let n=Array.isArray(r)?r:[r];for(let i of n)t.push({Name:i.Name,CreationDate:i.CreationDate})}return{Buckets:t}}async createBucket(e,t){let s={};if(t?.acl)s["x-amz-acl"]=t.acl;let r;if(this.region!=="us-east-1"&&!this.endpoint)r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
3
|
-
<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
4
|
-
<LocationConstraint>${this.region}</LocationConstraint>
|
|
5
|
-
</CreateBucketConfiguration>`,s["Content-Type"]="application/xml";await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,headers:s,body:r})}async deleteBucket(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`})}async emptyAndDeleteBucket(e){let t=!0;while(t){let s=await this.listAllObjects({bucket:e});if(s.length===0){t=!1;break}let r=s.map((n)=>n.Key);for(let n=0;n<r.length;n+=1000){let i=r.slice(n,n+1000);await this.deleteObjects(e,i)}}await this.deleteBucket(e)}async listAllObjects(e){let t=[],s;do{let r={"list-type":"2","max-keys":"1000"};if(e.prefix)r.prefix=e.prefix;if(s)r["continuation-token"]=s;let n=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e.bucket}`,queryParams:r}),i=n?.ListBucketResult??n,o=i?.Contents;if(o){let g=Array.isArray(o)?o:[o];for(let l of g)t.push({Key:l.Key,LastModified:l.LastModified||"",Size:Number.parseInt(l.Size||"0"),ETag:l.ETag})}let a=i?.IsTruncated;s=a==="true"||a===!0?i?.NextContinuationToken:void 0}while(s);return t}async list(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e.bucket}`}),s=[],n=(t?.ListBucketResult??t)?.Contents;if(n){let i=Array.isArray(n)?n:[n];for(let o of i){if(e.prefix&&!o.Key?.startsWith(e.prefix))continue;if(s.push({Key:o.Key||"",LastModified:o.LastModified||"",Size:Number.parseInt(o.Size||"0"),ETag:o.ETag}),e.maxKeys&&s.length>=e.maxKeys)break}}return s}async putObject(e){let t={};if(e.acl)t["x-amz-acl"]=e.acl;if(e.cacheControl)t["Cache-Control"]=e.cacheControl;if(e.contentType)t["Content-Type"]=e.contentType;if(e.metadata)for(let[n,i]of Object.entries(e.metadata))t[`x-amz-meta-${n}`]=i;let s=e.key.split("/").map((n)=>encodeURIComponent(n)).join("/"),r=e.body instanceof Uint8Array&&!Buffer.isBuffer(e.body)?Buffer.from(e.body):e.body;if(Buffer.isBuffer(r)||r instanceof Uint8Array){let n=Buffer.isBuffer(r)?r:Buffer.from(r),{accessKeyId:i,secretAccessKey:o,sessionToken:a}=this.getCredentials(),g=this.s3VirtualHost(e.bucket),l=this.objectPath(e.bucket,s),u=this.objectUrl(e.bucket,s),d=new Date,y=d.toISOString().replace(/[:-]|\.\d{3}/g,""),h=d.toISOString().slice(0,10).replace(/-/g,""),S=c.createHash("sha256").update(n).digest("hex"),m={host:g,"x-amz-date":y,"x-amz-content-sha256":S,...t};if(a)m["x-amz-security-token"]=a;let p=Object.keys(m).sort().map((f)=>`${f.toLowerCase()}:${m[f].trim()}
|
|
6
|
-
`).join(""),C=Object.keys(m).sort().map((f)=>f.toLowerCase()).join(";"),P=["PUT",l,"",p,C,S].join(`
|
|
7
|
-
`),k="AWS4-HMAC-SHA256",b=`${h}/${this.region}/s3/aws4_request`,v=[k,y,b,c.createHash("sha256").update(P).digest("hex")].join(`
|
|
8
|
-
`),q=c.createHmac("sha256",`AWS4${o}`).update(h).digest(),H=c.createHmac("sha256",q).update(this.region).digest(),E=c.createHmac("sha256",H).update("s3").digest(),w=c.createHmac("sha256",E).update("aws4_request").digest(),x=c.createHmac("sha256",w).update(v).digest("hex"),T=`${k} Credential=${i}/${b}, SignedHeaders=${C}, Signature=${x}`,A=await fetch(u,{method:"PUT",headers:{...m,Authorization:T},body:B(n)});if(!A.ok){let f=await A.text();throw Error(`S3 PUT failed: ${A.status} ${f}`)}return}await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${s}`,bucket:e.bucket,headers:t,body:e.body})}async getObject(e,t){let s=t.split("/").map((n)=>encodeURIComponent(n)).join("/");return await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${s}`,bucket:e,rawResponse:!0})}async getObjectBytes(e,t){let{accessKeyId:s,secretAccessKey:r,sessionToken:n}=this.getCredentials(),i=this.s3VirtualHost(e),o=t.split("/").map((f)=>encodeURIComponent(f)).join("/"),a=this.objectPath(e,o),g=this.objectUrl(e,o),l=new Date,u=l.toISOString().replace(/[:-]|\.\d{3}/g,""),d=l.toISOString().slice(0,10).replace(/-/g,""),y=c.createHash("sha256").update("").digest("hex"),h={host:i,"x-amz-date":u,"x-amz-content-sha256":y};if(n)h["x-amz-security-token"]=n;let S=Object.keys(h).sort().map((f)=>`${f.toLowerCase()}:${h[f].trim()}
|
|
9
|
-
`).join(""),m=Object.keys(h).sort().map((f)=>f.toLowerCase()).join(";"),p=["GET",a,"",S,m,y].join(`
|
|
10
|
-
`),C="AWS4-HMAC-SHA256",P=`${d}/${this.region}/s3/aws4_request`,k=[C,u,P,c.createHash("sha256").update(p).digest("hex")].join(`
|
|
11
|
-
`),b=c.createHmac("sha256",`AWS4${r}`).update(d).digest(),v=c.createHmac("sha256",b).update(this.region).digest(),q=c.createHmac("sha256",v).update("s3").digest(),H=c.createHmac("sha256",q).update("aws4_request").digest(),E=c.createHmac("sha256",H).update(k).digest("hex"),w=`${C} Credential=${s}/${P}, SignedHeaders=${m}, Signature=${E}`,x=await fetch(g,{method:"GET",headers:{...h,Authorization:w}});if(!x.ok){let f=await x.text();throw Error(`S3 GET failed: ${x.status} ${f}`)}let T=await x.arrayBuffer(),A=x.headers.get("content-length");return{body:new Uint8Array(T),contentType:x.headers.get("content-type")??void 0,contentLength:A?Number.parseInt(A,10):void 0}}async copyObject(e){let t={"x-amz-copy-source":`/${e.sourceBucket}/${e.sourceKey}`};if(e.metadataDirective)t["x-amz-metadata-directive"]=e.metadataDirective;if(e.contentType)t["Content-Type"]=e.contentType;if(e.metadata)for(let[s,r]of Object.entries(e.metadata))t[`x-amz-meta-${s}`]=r;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e.destinationBucket}/${e.destinationKey}`,headers:t})}async deleteObject(e,t){let s=t.split("/").map((r)=>encodeURIComponent(r)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${s}`,bucket:e})}async deleteObjects(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
|
|
12
|
-
<Delete>
|
|
13
|
-
${t.map((n)=>`<Object><Key>${n}</Key></Object>`).join(`
|
|
14
|
-
`)}
|
|
15
|
-
</Delete>`,r=c.createHash("md5").update(s).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}`,queryParams:{delete:""},body:s,headers:{"Content-Type":"application/xml","Content-MD5":r}})}async bucketExists(e){try{return await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${e}`}),!0}catch{return!1}}async copy(e){let t=D(e.source);await this.putObject({bucket:e.bucket,key:e.key,body:t,acl:e.acl,cacheControl:e.cacheControl,contentType:e.contentType,metadata:e.metadata})}async sync(e){let t=await this.listFilesRecursive(e.source);for(let s of t){if(e.exclude&&e.exclude.some((i)=>s.includes(i)))continue;if(e.include&&!e.include.some((i)=>s.includes(i)))continue;let r=s.substring(e.source.length+1),n=e.prefix?`${e.prefix}/${r}`:r;if(!e.dryRun){let i=D(s);await this.putObject({bucket:e.bucket,key:n,body:i,acl:e.acl,cacheControl:e.cacheControl,contentType:e.contentType,metadata:e.metadata})}}}async delete(e,t){await this.deleteObject(e,t)}async deletePrefix(e,t){let r=(await this.list({bucket:e,prefix:t})).map((n)=>n.Key);if(r.length>0)await this.deleteObjects(e,r)}async getBucketSize(e,t){return(await this.list({bucket:e,prefix:t})).reduce((r,n)=>r+n.Size,0)}async listFilesRecursive(e){let t=[],s=await z(e,{withFileTypes:!0});for(let r of s){let n=M(e,r.name);if(r.isDirectory()){let i=await this.listFilesRecursive(n);t.push(...i)}else t.push(n)}return t}async putBucketPolicy(e,t){let{accessKeyId:s,secretAccessKey:r,sessionToken:n}=this.getCredentials(),i=this.s3BaseHost(),o=typeof t==="string"?t:JSON.stringify(t),a=new Date,g=a.toISOString().replace(/[:-]|\.\d{3}/g,""),l=a.toISOString().slice(0,10).replace(/-/g,""),u=c.createHash("sha256").update(o).digest("hex"),d="/"+e,y="policy=",h={host:i,"x-amz-date":g,"x-amz-content-sha256":u,"content-type":"application/json"};if(n)h["x-amz-security-token"]=n;let S=Object.keys(h).sort().map((A)=>`${A.toLowerCase()}:${h[A].trim()}
|
|
16
|
-
`).join(""),m=Object.keys(h).sort().map((A)=>A.toLowerCase()).join(";"),p=["PUT",d,"policy=",S,m,u].join(`
|
|
17
|
-
`),C="AWS4-HMAC-SHA256",P=`${l}/${this.region}/s3/aws4_request`,k=[C,g,P,c.createHash("sha256").update(p).digest("hex")].join(`
|
|
18
|
-
`),b=c.createHmac("sha256","AWS4"+r).update(l).digest(),v=c.createHmac("sha256",b).update(this.region).digest(),q=c.createHmac("sha256",v).update("s3").digest(),H=c.createHmac("sha256",q).update("aws4_request").digest(),E=c.createHmac("sha256",H).update(k).digest("hex"),w=`${C} Credential=${s}/${P}, SignedHeaders=${m}, Signature=${E}`,x=`${this.endpointProtocol}://${i}${d}?policy=`,T=await fetch(x,{method:"PUT",headers:{...h,Authorization:w},body:o});if(!T.ok){let A=await T.text();throw Error(`Failed to put bucket policy: ${T.status} ${A}`)}}async getBucketPolicy(e){let{accessKeyId:t,secretAccessKey:s,sessionToken:r}=this.getCredentials(),n=this.s3BaseHost(),i=new Date,o=i.toISOString().replace(/[:-]|\.\d{3}/g,""),a=i.toISOString().slice(0,10).replace(/-/g,""),g=c.createHash("sha256").update("").digest("hex"),l="/"+e,u="policy=",d={host:n,"x-amz-date":o,"x-amz-content-sha256":g};if(r)d["x-amz-security-token"]=r;let y=Object.keys(d).sort().map((T)=>`${T.toLowerCase()}:${d[T].trim()}
|
|
19
|
-
`).join(""),h=Object.keys(d).sort().map((T)=>T.toLowerCase()).join(";"),S=["GET",l,"policy=",y,h,g].join(`
|
|
20
|
-
`),m="AWS4-HMAC-SHA256",p=`${a}/${this.region}/s3/aws4_request`,C=[m,o,p,c.createHash("sha256").update(S).digest("hex")].join(`
|
|
21
|
-
`),P=c.createHmac("sha256","AWS4"+s).update(a).digest(),k=c.createHmac("sha256",P).update(this.region).digest(),b=c.createHmac("sha256",k).update("s3").digest(),v=c.createHmac("sha256",b).update("aws4_request").digest(),q=c.createHmac("sha256",v).update(C).digest("hex"),H=`${m} Credential=${t}/${p}, SignedHeaders=${h}, Signature=${q}`,E=`${this.endpointProtocol}://${n}${l}?policy=`,w=await fetch(E,{method:"GET",headers:{...d,Authorization:H}});if(w.status===404)return null;if(!w.ok){let T=await w.text();throw Error(`Failed to get bucket policy: ${w.status} ${T}`)}let x=await w.text();return JSON.parse(x)}async deleteBucketPolicy(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{policy:""}})}async headBucket(e){try{return{exists:!0,region:(await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${e}`,returnHeaders:!0}))?.headers?.["x-amz-bucket-region"]}}catch(t){if(t.statusCode===404)return{exists:!1};throw t}}async headObject(e,t){try{let s=await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${e}/${t}`,returnHeaders:!0});return{ContentLength:s?.headers?.["content-length"]?parseInt(s.headers["content-length"]):void 0,ContentType:s?.headers?.["content-type"],ETag:s?.headers?.etag,LastModified:s?.headers?.["last-modified"]}}catch(s){if(s.statusCode===404)return null;throw s}}async getObjectBuffer(e,t){let s=await this.getObject(e,t);return Buffer.from(s)}async getObjectJson(e,t){let s=await this.getObject(e,t);return JSON.parse(s)}async putObjectJson(e,t,s,r){await this.putObject({bucket:e,key:t,body:JSON.stringify(s),contentType:"application/json",...r})}async getBucketVersioning(e){return{Status:(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{versioning:""}}))?.VersioningConfiguration?.Status}}async putBucketVersioning(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
|
|
22
|
-
<VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
23
|
-
<Status>${t}</Status>
|
|
24
|
-
</VersioningConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{versioning:""},headers:{"Content-Type":"application/xml"},body:s})}async getBucketLifecycleConfiguration(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{lifecycle:""}}))?.LifecycleConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketLifecycleConfiguration(e,t){let r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
25
|
-
<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
26
|
-
${t.map((n)=>{let i=`<Rule><ID>${n.ID}</ID><Status>${n.Status}</Status>`;if(n.Filter)i+=`<Filter><Prefix>${n.Filter.Prefix||""}</Prefix></Filter>`;else i+="<Filter><Prefix></Prefix></Filter>";if(n.Expiration){if(n.Expiration.Days)i+=`<Expiration><Days>${n.Expiration.Days}</Days></Expiration>`;else if(n.Expiration.Date)i+=`<Expiration><Date>${n.Expiration.Date}</Date></Expiration>`}if(n.Transitions)for(let o of n.Transitions)i+=`<Transition><Days>${o.Days}</Days><StorageClass>${o.StorageClass}</StorageClass></Transition>`;if(n.NoncurrentVersionExpiration)i+=`<NoncurrentVersionExpiration><NoncurrentDays>${n.NoncurrentVersionExpiration.NoncurrentDays}</NoncurrentDays></NoncurrentVersionExpiration>`;return i+="</Rule>",i}).join("")}
|
|
27
|
-
</LifecycleConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{lifecycle:""},headers:{"Content-Type":"application/xml"},body:r})}async deleteBucketLifecycleConfiguration(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{lifecycle:""}})}async getBucketCors(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{cors:""}}))?.CORSConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketCors(e,t){let r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
28
|
-
<CORSConfiguration>
|
|
29
|
-
${t.map((n)=>{let i="<CORSRule>";for(let o of n.AllowedOrigins)i+=`<AllowedOrigin>${o}</AllowedOrigin>`;for(let o of n.AllowedMethods)i+=`<AllowedMethod>${o}</AllowedMethod>`;if(n.AllowedHeaders)for(let o of n.AllowedHeaders)i+=`<AllowedHeader>${o}</AllowedHeader>`;if(n.ExposeHeaders)for(let o of n.ExposeHeaders)i+=`<ExposeHeader>${o}</ExposeHeader>`;if(n.MaxAgeSeconds)i+=`<MaxAgeSeconds>${n.MaxAgeSeconds}</MaxAgeSeconds>`;return i+="</CORSRule>",i}).join("")}
|
|
30
|
-
</CORSConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{cors:""},headers:{"Content-Type":"application/xml"},body:r})}async deleteBucketCors(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{cors:""}})}async getBucketEncryption(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{encryption:""}}))?.ServerSideEncryptionConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketEncryption(e,t,s){let r=`<ApplyServerSideEncryptionByDefault><SSEAlgorithm>${t}</SSEAlgorithm>`;if(s)r+=`<KMSMasterKeyID>${s}</KMSMasterKeyID>`;r+="</ApplyServerSideEncryptionByDefault>";let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
31
|
-
<ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
32
|
-
<Rule>${r}</Rule>
|
|
33
|
-
</ServerSideEncryptionConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{encryption:""},headers:{"Content-Type":"application/xml"},body:n})}async deleteBucketEncryption(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{encryption:""}})}async getBucketTagging(e){try{let s=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!s)return[];return Array.isArray(s)?s:[s]}catch(t){if(t.statusCode===404)return[];throw t}}async putBucketTagging(e,t){let r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
34
|
-
<Tagging>
|
|
35
|
-
<TagSet>${t.map((n)=>`<Tag><Key>${n.Key}</Key><Value>${n.Value}</Value></Tag>`).join("")}</TagSet>
|
|
36
|
-
</Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:r})}async deleteBucketTagging(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{tagging:""}})}async getObjectTagging(e,t){try{let r=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}/${t}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!r)return[];return Array.isArray(r)?r:[r]}catch(s){if(s.statusCode===404)return[];throw s}}async putObjectTagging(e,t,s){let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
37
|
-
<Tagging>
|
|
38
|
-
<TagSet>${s.map((i)=>`<Tag><Key>${i.Key}</Key><Value>${i.Value}</Value></Tag>`).join("")}</TagSet>
|
|
39
|
-
</Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}/${t}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:n})}async deleteObjectTagging(e,t){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}/${t}`,queryParams:{tagging:""}})}async getBucketAcl(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putBucketAcl(e,t){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{acl:""},headers:{"x-amz-acl":t}})}async getObjectAcl(e,t){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}/${t}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putObjectAcl(e,t,s){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}/${t}`,queryParams:{acl:""},headers:{"x-amz-acl":s}})}async getBucketLocation(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{location:""}}))?.LocationConstraint||"us-east-1"}async getBucketLogging(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{logging:""}}))?.BucketLoggingStatus}async putBucketLogging(e,t,s){let r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
40
|
-
<BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
41
|
-
<LoggingEnabled>
|
|
42
|
-
<TargetBucket>${t}</TargetBucket>
|
|
43
|
-
<TargetPrefix>${s}</TargetPrefix>
|
|
44
|
-
</LoggingEnabled>
|
|
45
|
-
</BucketLoggingStatus>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{logging:""},headers:{"Content-Type":"application/xml"},body:r})}async getBucketNotificationConfiguration(e){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{notification:""}}))?.NotificationConfiguration}async putBucketNotificationConfiguration(e,t){let s="";if(t.LambdaFunctionConfigurations)for(let n of t.LambdaFunctionConfigurations){if(s+="<CloudFunctionConfiguration>",n.Id)s+=`<Id>${n.Id}</Id>`;s+=`<CloudFunction>${n.LambdaFunctionArn}</CloudFunction>`;for(let i of n.Events)s+=`<Event>${i}</Event>`;if(n.Filter?.Key?.FilterRules){s+="<Filter><S3Key>";for(let i of n.Filter.Key.FilterRules)s+=`<FilterRule><Name>${i.Name}</Name><Value>${i.Value}</Value></FilterRule>`;s+="</S3Key></Filter>"}s+="</CloudFunctionConfiguration>"}if(t.TopicConfigurations)for(let n of t.TopicConfigurations){if(s+="<TopicConfiguration>",n.Id)s+=`<Id>${n.Id}</Id>`;s+=`<Topic>${n.TopicArn}</Topic>`;for(let i of n.Events)s+=`<Event>${i}</Event>`;s+="</TopicConfiguration>"}if(t.QueueConfigurations)for(let n of t.QueueConfigurations){if(s+="<QueueConfiguration>",n.Id)s+=`<Id>${n.Id}</Id>`;s+=`<Queue>${n.QueueArn}</Queue>`;for(let i of n.Events)s+=`<Event>${i}</Event>`;s+="</QueueConfiguration>"}let r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
46
|
-
<NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
47
|
-
${s}
|
|
48
|
-
</NotificationConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{notification:""},headers:{"Content-Type":"application/xml"},body:r})}async getBucketWebsite(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{website:""}}))?.WebsiteConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketWebsite(e,t){let s="";if(t.RedirectAllRequestsTo)s=`<RedirectAllRequestsTo>
|
|
49
|
-
<HostName>${t.RedirectAllRequestsTo.HostName}</HostName>
|
|
50
|
-
${t.RedirectAllRequestsTo.Protocol?`<Protocol>${t.RedirectAllRequestsTo.Protocol}</Protocol>`:""}
|
|
51
|
-
</RedirectAllRequestsTo>`;else if(s=`<IndexDocument><Suffix>${t.IndexDocument}</Suffix></IndexDocument>`,t.ErrorDocument)s+=`<ErrorDocument><Key>${t.ErrorDocument}</Key></ErrorDocument>`;let r=`<?xml version="1.0" encoding="UTF-8"?>
|
|
52
|
-
<WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
53
|
-
${s}
|
|
54
|
-
</WebsiteConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{website:""},headers:{"Content-Type":"application/xml"},body:r})}async deleteBucketWebsite(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{website:""}})}async getBucketReplication(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{replication:""}}))?.ReplicationConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async deleteBucketReplication(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{replication:""}})}async getPublicAccessBlock(e){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{publicAccessBlock:""}}))?.PublicAccessBlockConfiguration}catch(t){if(t.statusCode===404)return null;throw t}}async putPublicAccessBlock(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
|
|
55
|
-
<PublicAccessBlockConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
|
|
56
|
-
<BlockPublicAcls>${t.BlockPublicAcls??!0}</BlockPublicAcls>
|
|
57
|
-
<IgnorePublicAcls>${t.IgnorePublicAcls??!0}</IgnorePublicAcls>
|
|
58
|
-
<BlockPublicPolicy>${t.BlockPublicPolicy??!0}</BlockPublicPolicy>
|
|
59
|
-
<RestrictPublicBuckets>${t.RestrictPublicBuckets??!0}</RestrictPublicBuckets>
|
|
60
|
-
</PublicAccessBlockConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{publicAccessBlock:""},headers:{"Content-Type":"application/xml"},body:s})}async deletePublicAccessBlock(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{publicAccessBlock:""}})}generatePresignedGetUrl(e,t,s=3600){let{accessKeyId:r,secretAccessKey:n}=this.getCredentials(),i=this.s3VirtualHost(e),o=new Date,a=o.toISOString().replace(/[:-]|\.\d{3}/g,""),g=o.toISOString().slice(0,10).replace(/-/g,""),l=`${g}/${this.region}/s3/aws4_request`,u=`${r}/${l}`,d=t.split("/").map((b)=>encodeURIComponent(b)).join("/"),y=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":u,"X-Amz-Date":a,"X-Amz-Expires":s.toString(),"X-Amz-SignedHeaders":"host"}),h=["GET",this.objectPath(e,d),y.toString(),`host:${i}
|
|
61
|
-
`,"host","UNSIGNED-PAYLOAD"].join(`
|
|
62
|
-
`),S=["AWS4-HMAC-SHA256",a,l,c.createHash("sha256").update(h).digest("hex")].join(`
|
|
63
|
-
`),m=c.createHmac("sha256",`AWS4${n}`).update(g).digest(),p=c.createHmac("sha256",m).update(this.region).digest(),C=c.createHmac("sha256",p).update("s3").digest(),P=c.createHmac("sha256",C).update("aws4_request").digest(),k=c.createHmac("sha256",P).update(S).digest("hex");return y.append("X-Amz-Signature",k),`${this.endpointProtocol}://${i}${this.objectPath(e,d)}?${y.toString()}`}generatePresignedPutUrl(e,t,s,r=3600){let{accessKeyId:n,secretAccessKey:i}=this.getCredentials(),o=this.s3VirtualHost(e),a=new Date,g=a.toISOString().replace(/[:-]|\.\d{3}/g,""),l=a.toISOString().slice(0,10).replace(/-/g,""),u=`${l}/${this.region}/s3/aws4_request`,d=`${n}/${u}`,y=t.split("/").map((v)=>encodeURIComponent(v)).join("/"),h=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":d,"X-Amz-Date":g,"X-Amz-Expires":r.toString(),"X-Amz-SignedHeaders":"content-type;host"}),S=["PUT",this.objectPath(e,y),h.toString(),`content-type:${s}
|
|
64
|
-
host:${o}
|
|
65
|
-
`,"content-type;host","UNSIGNED-PAYLOAD"].join(`
|
|
66
|
-
`),m=["AWS4-HMAC-SHA256",g,u,c.createHash("sha256").update(S).digest("hex")].join(`
|
|
67
|
-
`),p=c.createHmac("sha256",`AWS4${i}`).update(l).digest(),C=c.createHmac("sha256",p).update(this.region).digest(),P=c.createHmac("sha256",C).update("s3").digest(),k=c.createHmac("sha256",P).update("aws4_request").digest(),b=c.createHmac("sha256",k).update(m).digest("hex");return h.append("X-Amz-Signature",b),`${this.endpointProtocol}://${o}${this.objectPath(e,y)}?${h.toString()}`}async createMultipartUpload(e,t,s){let r={};if(s?.contentType)r["Content-Type"]=s.contentType;if(s?.metadata)for(let[a,g]of Object.entries(s.metadata))r[`x-amz-meta-${a}`]=g;let n=t.split("/").map((a)=>encodeURIComponent(a)).join("/"),i=await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${n}`,bucket:e,queryParams:{uploads:""},headers:r});return{UploadId:(i?.InitiateMultipartUploadResult??i)?.UploadId}}async uploadPart(e,t,s,r,n){let{accessKeyId:i,secretAccessKey:o,sessionToken:a}=this.getCredentials(),g=this.s3VirtualHost(e),l=t.split("/").map((j)=>encodeURIComponent(j)).join("/"),u=this.objectPath(e,l),d=`${this.objectUrl(e,l)}?partNumber=${r}&uploadId=${encodeURIComponent(s)}`,y=new Date,h=y.toISOString().replace(/[:-]|\.\d{3}/g,""),S=y.toISOString().slice(0,10).replace(/-/g,""),m=c.createHash("sha256").update(n).digest("hex"),p={host:g,"x-amz-date":h,"x-amz-content-sha256":m};if(a)p["x-amz-security-token"]=a;let C=Object.keys(p).sort().map((j)=>`${j.toLowerCase()}:${p[j].trim()}
|
|
68
|
-
`).join(""),P=Object.keys(p).sort().map((j)=>j.toLowerCase()).join(";"),k=["PUT",u,`partNumber=${r}&uploadId=${encodeURIComponent(s)}`,C,P,m].join(`
|
|
69
|
-
`),b="AWS4-HMAC-SHA256",v=`${S}/${this.region}/s3/aws4_request`,q=[b,h,v,c.createHash("sha256").update(k).digest("hex")].join(`
|
|
70
|
-
`),H=c.createHmac("sha256",`AWS4${o}`).update(S).digest(),E=c.createHmac("sha256",H).update(this.region).digest(),w=c.createHmac("sha256",E).update("s3").digest(),x=c.createHmac("sha256",w).update("aws4_request").digest(),T=c.createHmac("sha256",x).update(q).digest("hex"),A=`${b} Credential=${i}/${v}, SignedHeaders=${P}, Signature=${T}`,f=await fetch(d,{method:"PUT",headers:{...p,Authorization:A},body:B(n)});if(!f.ok){let j=await f.text();throw Error(`Upload part failed: ${f.status} ${j}`)}return{ETag:f.headers.get("etag")||""}}async completeMultipartUpload(e,t,s,r){let n=t.split("/").map((a)=>encodeURIComponent(a)).join("/"),o=`<?xml version="1.0" encoding="UTF-8"?>
|
|
71
|
-
<CompleteMultipartUpload>${r.sort((a,g)=>a.PartNumber-g.PartNumber).map((a)=>`<Part><PartNumber>${a.PartNumber}</PartNumber><ETag>${a.ETag}</ETag></Part>`).join("")}</CompleteMultipartUpload>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${n}`,bucket:e,queryParams:{uploadId:s},headers:{"Content-Type":"application/xml"},body:o})}async abortMultipartUpload(e,t,s){let r=t.split("/").map((n)=>encodeURIComponent(n)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${r}`,bucket:e,queryParams:{uploadId:s}})}async listMultipartUploads(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/",bucket:e,queryParams:{uploads:""}}),s=(t?.ListMultipartUploadsResult??t)?.Upload;if(!s)return[];return(Array.isArray(s)?s:[s]).map((n)=>({Key:n.Key,UploadId:n.UploadId,Initiated:n.Initiated}))}async restoreObject(e,t,s,r="Standard"){let n=`<?xml version="1.0" encoding="UTF-8"?>
|
|
72
|
-
<RestoreRequest>
|
|
73
|
-
<Days>${s}</Days>
|
|
74
|
-
<GlacierJobParameters>
|
|
75
|
-
<Tier>${r}</Tier>
|
|
76
|
-
</GlacierJobParameters>
|
|
77
|
-
</RestoreRequest>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}/${t}`,queryParams:{restore:""},headers:{"Content-Type":"application/xml"},body:n})}async selectObjectContent(e,t,s,r,n="JSON"){let i="";if(r==="CSV")i="<CSV><FileHeaderInfo>USE</FileHeaderInfo></CSV>";else if(r==="JSON")i="<JSON><Type>DOCUMENT</Type></JSON>";else i="<Parquet/>";let o="";if(n==="CSV")o="<CSV/>";else o="<JSON/>";let a=`<?xml version="1.0" encoding="UTF-8"?>
|
|
78
|
-
<SelectObjectContentRequest>
|
|
79
|
-
<Expression>${s}</Expression>
|
|
80
|
-
<ExpressionType>SQL</ExpressionType>
|
|
81
|
-
<InputSerialization>${i}</InputSerialization>
|
|
82
|
-
<OutputSerialization>${o}</OutputSerialization>
|
|
83
|
-
</SelectObjectContentRequest>`;return await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}/${t}`,queryParams:{select:"","select-type":"2"},headers:{"Content-Type":"application/xml"},body:a,rawResponse:!0})}async getSignedUrl(e){let{bucket:t,key:s,expiresIn:r=3600,operation:n="getObject"}=e,{accessKeyId:i,secretAccessKey:o,sessionToken:a}=this.getCredentials(),g=new Date,l=g.toISOString().replace(/[:-]|\.\d{3}/g,""),u=g.toISOString().slice(0,10).replace(/-/g,""),d=this.s3VirtualHost(t),y=n==="putObject"?"PUT":"GET",h="AWS4-HMAC-SHA256",S=`${u}/${this.region}/s3/aws4_request`,p={"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":`${i}/${S}`,"X-Amz-Date":l,"X-Amz-Expires":r.toString(),"X-Amz-SignedHeaders":"host"};if(a)p["X-Amz-Security-Token"]=a;let P=Object.keys(p).sort().map((I)=>`${encodeURIComponent(I)}=${encodeURIComponent(p[I])}`).join("&"),k=s.split("/").map((I)=>encodeURIComponent(I)).join("/"),b=this.objectPath(t,k),v=`host:${d}
|
|
84
|
-
`,E=[y,b,P,v,"host","UNSIGNED-PAYLOAD"].join(`
|
|
85
|
-
`),w=["AWS4-HMAC-SHA256",l,S,c.createHash("sha256").update(E).digest("hex")].join(`
|
|
86
|
-
`),x=c.createHmac("sha256",`AWS4${o}`).update(u).digest(),T=c.createHmac("sha256",x).update(this.region).digest(),A=c.createHmac("sha256",T).update("s3").digest(),f=c.createHmac("sha256",A).update("aws4_request").digest(),j=c.createHmac("sha256",f).update(w).digest("hex");return`${this.endpointProtocol}://${d}${b}?${P}&X-Amz-Signature=${j}`}async listObjects(e){let{bucket:t,prefix:s,maxKeys:r=1000,continuationToken:n}=e,i={"list-type":"2","max-keys":r.toString()};if(s)i.prefix=s;if(n)i["continuation-token"]=n;let o=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:i}),a=[],g=o?.ListBucketResult??o;if(g?.Contents){let l=Array.isArray(g.Contents)?g.Contents:[g.Contents];for(let u of l)a.push({Key:u.Key||"",LastModified:u.LastModified||"",Size:Number.parseInt(u.Size||"0"),ETag:u.ETag})}return{objects:a,nextContinuationToken:g?.NextContinuationToken}}async emptyBucket(e){let t=0,s=await this.listAllObjects({bucket:e});if(s.length>0)for(let r=0;r<s.length;r+=1000){let i=s.slice(r,r+1000).map((o)=>o.Key);await this.deleteObjects(e,i),t+=i.length}try{let r,n;do{let i=await this.listObjectVersions({bucket:e,keyMarker:r,versionIdMarker:n,maxKeys:1000}),o=[];if(i.versions)for(let a of i.versions)o.push({Key:a.Key,VersionId:a.VersionId});if(i.deleteMarkers)for(let a of i.deleteMarkers)o.push({Key:a.Key,VersionId:a.VersionId});if(o.length>0)await this.deleteObjectVersions(e,o),t+=o.length;r=i.nextKeyMarker,n=i.nextVersionIdMarker}while(r)}catch{}return{deletedCount:t}}async listObjectVersions(e){let{bucket:t,prefix:s,keyMarker:r,versionIdMarker:n,maxKeys:i=1000}=e,o={versions:"","max-keys":i.toString()};if(s)o.prefix=s;if(r)o["key-marker"]=r;if(n)o["version-id-marker"]=n;let a=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:o}),g=[],l=[];if(a.Version){let u=Array.isArray(a.Version)?a.Version:[a.Version];for(let d of u)g.push({Key:d.Key,VersionId:d.VersionId,IsLatest:d.IsLatest==="true"})}if(a.DeleteMarker){let u=Array.isArray(a.DeleteMarker)?a.DeleteMarker:[a.DeleteMarker];for(let d of u)l.push({Key:d.Key,VersionId:d.VersionId,IsLatest:d.IsLatest==="true"})}return{versions:g,deleteMarkers:l,nextKeyMarker:a.NextKeyMarker,nextVersionIdMarker:a.NextVersionIdMarker}}async deleteObjectVersions(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
|
|
87
|
-
<Delete>
|
|
88
|
-
<Quiet>true</Quiet>
|
|
89
|
-
${t.map((n)=>`<Object><Key>${n.Key}</Key>${n.VersionId?`<VersionId>${n.VersionId}</VersionId>`:""}</Object>`).join(`
|
|
90
|
-
`)}
|
|
91
|
-
</Delete>`,r=c.createHash("md5").update(s).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${e}`,queryParams:{delete:""},body:s,headers:{"Content-Type":"application/xml","Content-MD5":r}})}}
|
|
92
|
-
export{R as pg,V as qg};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{dh as d}from"./chunk-ja1vjdn1.js";import{deflateRawSync as y}from"zlib";function m(n,e){let t=typeof e==="string"?Buffer.from(e,"utf-8"):e,i=y(t),r=f(t),s=new Date,g=(s.getHours()<<11|s.getMinutes()<<5|s.getSeconds()>>1)&65535,c=(s.getFullYear()-1980<<9|s.getMonth()+1<<5|s.getDate())&65535,l=Buffer.from(n,"utf-8"),a=Buffer.alloc(30+l.length);a.writeUInt32LE(67324752,0),a.writeUInt16LE(20,4),a.writeUInt16LE(0,6),a.writeUInt16LE(8,8),a.writeUInt16LE(g,10),a.writeUInt16LE(c,12),a.writeUInt32LE(r,14),a.writeUInt32LE(i.length,18),a.writeUInt32LE(t.length,22),a.writeUInt16LE(l.length,26),a.writeUInt16LE(0,28),l.copy(a,30);let o=Buffer.alloc(46+l.length);o.writeUInt32LE(33639248,0),o.writeUInt16LE(20,4),o.writeUInt16LE(20,6),o.writeUInt16LE(0,8),o.writeUInt16LE(8,10),o.writeUInt16LE(g,12),o.writeUInt16LE(c,14),o.writeUInt32LE(r,16),o.writeUInt32LE(i.length,20),o.writeUInt32LE(t.length,24),o.writeUInt16LE(l.length,28),o.writeUInt16LE(0,30),o.writeUInt16LE(0,32),o.writeUInt16LE(0,34),o.writeUInt16LE(0,36),o.writeUInt32LE(0,38),o.writeUInt32LE(0,42),l.copy(o,46);let p=a.length+i.length,h=o.length,u=Buffer.alloc(22);return u.writeUInt32LE(101010256,0),u.writeUInt16LE(0,4),u.writeUInt16LE(0,6),u.writeUInt16LE(1,8),u.writeUInt16LE(1,10),u.writeUInt32LE(h,12),u.writeUInt32LE(p,16),u.writeUInt16LE(0,20),Buffer.concat([a,i,o,u])}function f(n){let e=[];for(let i=0;i<256;i++){let r=i;for(let s=0;s<8;s++)r=r&1?3988292384^r>>>1:r>>>1;e[i]=r}let t=4294967295;for(let i=0;i<n.length;i++)t=e[(t^n[i])&255]^t>>>8;return(t^4294967295)>>>0}class C{client;region;constructor(n="us-east-1",e){this.region=n,this.client=new d(void 0,{profile:e})}async createFunction(n){return await this.client.request({service:"lambda",region:this.region,method:"POST",path:"/2015-03-31/functions",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async getFunction(n){return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2015-03-31/functions/${encodeURIComponent(n)}`,headers:{"Content-Type":"application/json"}})}async updateFunctionCode(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/code`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateFunctionCodeInline(n,e,t="index.js"){let i=m(t,e);return this.updateFunctionCode({FunctionName:n,ZipFile:i.toString("base64")})}async updateFunctionConfiguration(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/configuration`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async deleteFunction(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2015-03-31/functions/${encodeURIComponent(n)}`,headers:{"Content-Type":"application/json"}})}async invoke(n){let{FunctionName:e,InvocationType:t="RequestResponse",Payload:i,LogType:r}=n,s={"Content-Type":"application/json","X-Amz-Invocation-Type":t};if(r)s["X-Amz-Log-Type"]=r;let g=i?typeof i==="string"?i:JSON.stringify(i):void 0,c=await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/invocations`,headers:s,body:g,returnHeaders:!0});return{StatusCode:c.statusCode||200,FunctionError:c.headers?.["x-amz-function-error"],LogResult:c.headers?.["x-amz-log-result"],Payload:typeof c.body==="string"?c.body:JSON.stringify(c.body),ExecutedVersion:c.headers?.["x-amz-executed-version"]}}async listFunctions(n){let e={};if(n?.MaxItems)e.MaxItems=String(n.MaxItems);if(n?.Marker)e.Marker=n.Marker;if(n?.FunctionVersion)e.FunctionVersion=n.FunctionVersion;return await this.client.request({service:"lambda",region:this.region,method:"GET",path:"/2015-03-31/functions",queryParams:Object.keys(e).length>0?e:void 0,headers:{"Content-Type":"application/json"}})}async addPermission(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/policy`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async removePermission(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2015-03-31/functions/${encodeURIComponent(n)}/policy/${encodeURIComponent(e)}`,headers:{"Content-Type":"application/json"}})}async publishVersion(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/versions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async createAlias(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2015-03-31/functions/${encodeURIComponent(e)}/aliases`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async updateAlias(n){let{FunctionName:e,Name:t,...i}=n;return this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2015-03-31/functions/${encodeURIComponent(e)}/aliases/${encodeURIComponent(t)}`,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async getAlias(n,e){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2015-03-31/functions/${encodeURIComponent(n)}/aliases/${encodeURIComponent(e)}`})}catch(t){if(/ResourceNotFound/i.test(String(t?.message)))return null;throw t}}async getProvisionedConcurrencyConfig(n,e){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2019-09-30/functions/${encodeURIComponent(n)}/provisioned-concurrency`,queryParams:{Qualifier:e}})}catch(t){if(/ProvisionedConcurrencyConfigNotFound|ResourceNotFound/i.test(String(t?.message)))return null;throw t}}async putProvisionedConcurrencyConfig(n){let{FunctionName:e,Qualifier:t,ProvisionedConcurrentExecutions:i}=n;return this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2019-09-30/functions/${encodeURIComponent(e)}/provisioned-concurrency`,queryParams:{Qualifier:t},headers:{"Content-Type":"application/json"},body:JSON.stringify({ProvisionedConcurrentExecutions:i})})}async getFunctionConcurrency(n){try{return(await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`}))?.ReservedConcurrentExecutions??null}catch(e){if(/ResourceNotFound|ProvisionedConcurrencyConfigNotFound/i.test(String(e?.message)))return null;throw e}}async putFunctionConcurrency(n,e){await this.client.request({service:"lambda",region:this.region,method:"PUT",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`,headers:{"Content-Type":"application/json"},body:JSON.stringify({ReservedConcurrentExecutions:e})})}async deleteFunctionConcurrency(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2019-10-31/functions/${encodeURIComponent(n)}/concurrency`})}async deleteProvisionedConcurrencyConfig(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2019-09-30/functions/${encodeURIComponent(n)}/provisioned-concurrency`,queryParams:{Qualifier:e}})}async waitForFunctionActive(n,e=60){let t=Date.now(),i=e*1000;while(Date.now()-t<i)try{let r=await this.getFunction(n),s=r.Configuration?.State;if(s==="Active")return r.Configuration;if(s==="Failed")throw Error(`Function ${n} failed: ${r.Configuration?.StateReason}`);await new Promise((g)=>setTimeout(g,2000))}catch(r){if(r.code==="ResourceNotFoundException"){await new Promise((s)=>setTimeout(s,2000));continue}throw r}throw Error(`Timeout waiting for function ${n} to become active`)}async functionExists(n){try{return await this.getFunction(n),!0}catch(e){if(e.code==="ResourceNotFoundException"||e.statusCode===404)return!1;throw e}}async createFunctionUrl(n){let{FunctionName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2021-10-31/functions/${encodeURIComponent(e)}/url`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async getFunctionUrl(n){try{return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2021-10-31/functions/${encodeURIComponent(n)}/url`,headers:{"Content-Type":"application/json"}})}catch(e){if(e.statusCode===404)return null;throw e}}async deleteFunctionUrl(n){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2021-10-31/functions/${encodeURIComponent(n)}/url`,headers:{"Content-Type":"application/json"}})}async createFunctionWithCode(n){let{Code:e,Filename:t="index.js",...i}=n,r=m(t,e);return this.createFunction({...i,Code:{ZipFile:r.toString("base64")}})}async addFunctionUrlPermission(n){return this.addPermission({FunctionName:n,StatementId:"FunctionURLAllowPublicAccess",Action:"lambda:InvokeFunctionUrl",Principal:"*",FunctionUrlAuthType:"NONE"})}async publishLayerVersion(n){let{LayerName:e,...t}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2018-10-31/layers/${encodeURIComponent(e)}/versions`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async listLayerVersions(n,e){let t={};if(e?.CompatibleRuntime)t.CompatibleRuntime=e.CompatibleRuntime;if(e?.CompatibleArchitecture)t.CompatibleArchitecture=e.CompatibleArchitecture;if(e?.MaxItems)t.MaxItems=String(e.MaxItems);if(e?.Marker)t.Marker=e.Marker;return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions`,queryParams:Object.keys(t).length>0?t:void 0,headers:{"Content-Type":"application/json"}})}async getLayerVersion(n,e){return await this.client.request({service:"lambda",region:this.region,method:"GET",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions/${e}`,headers:{"Content-Type":"application/json"}})}async addLayerVersionPermission(n){let{LayerName:e,VersionNumber:t,...i}=n;return await this.client.request({service:"lambda",region:this.region,method:"POST",path:`/2018-10-31/layers/${encodeURIComponent(e)}/versions/${t}/policy`,headers:{"Content-Type":"application/json"},body:JSON.stringify(i)})}async deleteLayerVersion(n,e){await this.client.request({service:"lambda",region:this.region,method:"DELETE",path:`/2018-10-31/layers/${encodeURIComponent(n)}/versions/${e}`,headers:{"Content-Type":"application/json"}})}}
|
|
2
|
-
export{C as _d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{rg as a,sg as b,tg as c,ug as d,vg as e,wg as f,xg as g,yg as h,zg as i}from"./chunk-w32xv8n4.js";import"./chunk-dz1ec589.js";import"./chunk-4q6tad44.js";import"./chunk-ehc63fvs.js";export{e as AwsSecretsManagerConfigurationBackend,f as AwsSsmConfigurationBackend,h as ConfigurationService,a as ConfigurationStore,g as ExternalConfigurationBackend,d as LocalEncryptedConfigurationBackend,b as parseDotenv,c as serializeDotenv,i as synchronizeConfiguredConfiguration};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ye as a}from"./chunk-rtecnmts.js";import"./chunk-ja1vjdn1.js";import"./chunk-ehc63fvs.js";export{a as EC2Client};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{dh as u}from"./chunk-ja1vjdn1.js";class d{client;region;constructor(e="us-east-1",i){this.region=e,this.client=new u}async createQueue(e){let t={Action:"CreateQueue",QueueName:e.fifo&&!e.queueName.endsWith(".fifo")?`${e.queueName}.fifo`:e.queueName,Version:"2012-11-05"},s=1;if(e.visibilityTimeout!==void 0)t[`Attribute.${s}.Name`]="VisibilityTimeout",t[`Attribute.${s}.Value`]=e.visibilityTimeout.toString(),s++;if(e.messageRetentionPeriod!==void 0)t[`Attribute.${s}.Name`]="MessageRetentionPeriod",t[`Attribute.${s}.Value`]=e.messageRetentionPeriod.toString(),s++;if(e.delaySeconds!==void 0)t[`Attribute.${s}.Name`]="DelaySeconds",t[`Attribute.${s}.Value`]=e.delaySeconds.toString(),s++;if(e.maxMessageSize!==void 0)t[`Attribute.${s}.Name`]="MaximumMessageSize",t[`Attribute.${s}.Value`]=e.maxMessageSize.toString(),s++;if(e.receiveMessageWaitTime!==void 0)t[`Attribute.${s}.Name`]="ReceiveMessageWaitTimeSeconds",t[`Attribute.${s}.Value`]=e.receiveMessageWaitTime.toString(),s++;if(e.fifo){if(t[`Attribute.${s}.Name`]="FifoQueue",t[`Attribute.${s}.Value`]="true",s++,e.contentBasedDeduplication)t[`Attribute.${s}.Name`]="ContentBasedDeduplication",t[`Attribute.${s}.Value`]="true",s++}if(e.deadLetterTargetArn&&e.maxReceiveCount)t[`Attribute.${s}.Name`]="RedrivePolicy",t[`Attribute.${s}.Value`]=JSON.stringify({deadLetterTargetArn:e.deadLetterTargetArn,maxReceiveCount:e.maxReceiveCount}),s++;if(e.tags&&Object.keys(e.tags).length>0){let a=1;for(let[n,g]of Object.entries(e.tags))t[`Tag.${a}.Key`]=n,t[`Tag.${a}.Value`]=g,a++}let r=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{QueueUrl:r.QueueUrl||r.CreateQueueResult?.QueueUrl}}async listQueues(e){let i={Action:"ListQueues",Version:"2012-11-05"};if(e)i.QueueNamePrefix=e;let t=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(i).toString()}),s=[];if(t.QueueUrl)s.push(t.QueueUrl);else if(t.ListQueuesResult?.QueueUrl)if(Array.isArray(t.ListQueuesResult.QueueUrl))s.push(...t.ListQueuesResult.QueueUrl);else s.push(t.ListQueuesResult.QueueUrl);return{QueueUrls:s}}async getQueueAttributes(e){let i={Action:"GetQueueAttributes",QueueUrl:e,Version:"2012-11-05","AttributeName.1":"All"},t=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(i).toString()});return{Attributes:t.Attributes||t.GetQueueAttributesResult?.Attributes||{}}}async getQueueUrl(e){let i={Action:"GetQueueUrl",QueueName:e,Version:"2012-11-05"},t=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(i).toString()});return{QueueUrl:t.QueueUrl||t.GetQueueUrlResult?.QueueUrl}}async deleteQueue(e){let i={Action:"DeleteQueue",QueueUrl:e,Version:"2012-11-05"};await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(i).toString()})}async purgeQueue(e){let i={Action:"PurgeQueue",QueueUrl:e,Version:"2012-11-05"};await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(i).toString()})}async sendMessage(e){let i={Action:"SendMessage",QueueUrl:e.queueUrl,MessageBody:e.messageBody,Version:"2012-11-05"};if(e.delaySeconds!==void 0)i.DelaySeconds=e.delaySeconds;if(e.messageGroupId)i.MessageGroupId=e.messageGroupId;if(e.messageDeduplicationId)i.MessageDeduplicationId=e.messageDeduplicationId;let t=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(i).toString()});return{MessageId:t.MessageId||t.SendMessageResult?.MessageId}}async receiveMessages(e){let i={Action:"ReceiveMessage",QueueUrl:e.queueUrl,Version:"2012-11-05"};if(e.maxMessages!==void 0)i.MaxNumberOfMessages=e.maxMessages;if(e.visibilityTimeout!==void 0)i.VisibilityTimeout=e.visibilityTimeout;if(e.waitTimeSeconds!==void 0)i.WaitTimeSeconds=e.waitTimeSeconds;let t=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(i).toString()}),s=[],r=t.Message||t.ReceiveMessageResult?.Message;if(r)if(Array.isArray(r))s.push(...r.map((a)=>({MessageId:a.MessageId,ReceiptHandle:a.ReceiptHandle,Body:a.Body})));else s.push({MessageId:r.MessageId,ReceiptHandle:r.ReceiptHandle,Body:r.Body});return{Messages:s}}async deleteMessage(e,i){let t={Action:"DeleteMessage",QueueUrl:e,ReceiptHandle:i,Version:"2012-11-05"};await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()})}}
|
|
2
|
-
export{d as Hd};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Xa as a}from"./chunk-sj5csg49.js";import"./chunk-ehc63fvs.js";export{a as encodeDashboardPayload};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{_d as a}from"./chunk-c0bdafbx.js";import"./chunk-ja1vjdn1.js";import"./chunk-ehc63fvs.js";export{a as LambdaClient};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Ad as d,xd as a,yd as b,zd as c}from"./chunk-7zhgmp1s.js";import"./chunk-x6f61g36.js";import"./chunk-4q6tad44.js";import"./chunk-ehc63fvs.js";export{b as getComputeDeployHistory,d as restoreDatabaseBackup,a as rollbackComputeSite,c as runComputeRecipe};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{Hd as he}from"./chunk-d7ke90zt.js";import{Sd as ge,Xd as pe}from"./chunk-kg61p5hw.js";import{_d as de}from"./chunk-c0bdafbx.js";import{ig as ye}from"./chunk-xhwqpgwq.js";import{jg as le}from"./chunk-a7w13qfm.js";import{pg as V,qg as Z}from"./chunk-btsyjhk7.js";import{dh as N,eh as te}from"./chunk-ja1vjdn1.js";import{$h as ce,no as ue}from"./chunk-4q6tad44.js";class j{client;region;constructor(e="us-east-1",t){this.region=e,this.client=new N(V(t))}async query(e){let t=new URLSearchParams(te({Version:"2010-08-01",...e})).toString();return this.client.request({service:"monitoring",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t})}async getMetricStatistics(e){let t={Action:"GetMetricStatistics",Namespace:e.Namespace,MetricName:e.MetricName,StartTime:e.StartTime.toISOString(),EndTime:e.EndTime.toISOString(),Period:e.Period};(e.Statistics??[]).forEach((o,h)=>{t[`Statistics.member.${h+1}`]=o}),(e.ExtendedStatistics??[]).forEach((o,h)=>{t[`ExtendedStatistics.member.${h+1}`]=o}),(e.Dimensions??[]).forEach((o,h)=>{t[`Dimensions.member.${h+1}.Name`]=o.Name,t[`Dimensions.member.${h+1}.Value`]=o.Value});let r=await this.query(t),s=(r.GetMetricStatisticsResult||r)?.Datapoints?.member??[];if(!Array.isArray(s))s=s?[s]:[];return s.map((o)=>{let h={},m=o.ExtendedStatistics?.entry;if(m){if(!Array.isArray(m))m=[m];for(let d of m)if(d?.key!=null)h[d.key]=Number(d.value)}return{Timestamp:o.Timestamp,Sum:o.Sum!=null?Number(o.Sum):void 0,Average:o.Average!=null?Number(o.Average):void 0,Maximum:o.Maximum!=null?Number(o.Maximum):void 0,Minimum:o.Minimum!=null?Number(o.Minimum):void 0,Percentiles:Object.keys(h).length?h:void 0,Unit:o.Unit}})}async getMetricSeries(e){let t=/^p\d/.test(e.Stat);return(await this.getMetricStatistics({Namespace:e.Namespace,MetricName:e.MetricName,Dimensions:e.Dimensions,StartTime:e.StartTime,EndTime:e.EndTime,Period:e.Period,Statistics:t?[]:[e.Stat],ExtendedStatistics:t?[e.Stat]:[]})).slice().sort((a,s)=>new Date(a.Timestamp??0).getTime()-new Date(s.Timestamp??0).getTime()).map((a)=>t?a.Percentiles?.[e.Stat]??0:a[e.Stat]??0)}async describeAlarms(e){let t={Action:"DescribeAlarms"};if(e?.AlarmNamePrefix)t.AlarmNamePrefix=e.AlarmNamePrefix;if(e?.MaxRecords)t.MaxRecords=e.MaxRecords;let r=await this.query(t),s=(r.DescribeAlarmsResult||r)?.MetricAlarms?.member??[];if(!Array.isArray(s))s=s?[s]:[];return s.map((o)=>({AlarmName:o.AlarmName,StateValue:o.StateValue,MetricName:o.MetricName,ComparisonOperator:o.ComparisonOperator,Threshold:o.Threshold!=null?Number(o.Threshold):void 0,Namespace:o.Namespace}))}async putMetricAlarm(e){let t={Action:"PutMetricAlarm",AlarmName:e.AlarmName,Namespace:e.Namespace,MetricName:e.MetricName,ComparisonOperator:e.ComparisonOperator,Threshold:e.Threshold,EvaluationPeriods:e.EvaluationPeriods,Period:e.Period,Statistic:e.Statistic};if(e.AlarmDescription)t.AlarmDescription=e.AlarmDescription;(e.Dimensions??[]).forEach((r,a)=>{t[`Dimensions.member.${a+1}.Name`]=r.Name,t[`Dimensions.member.${a+1}.Value`]=r.Value}),(e.AlarmActions??[]).forEach((r,a)=>{t[`AlarmActions.member.${a+1}`]=r}),await this.query(t)}async deleteAlarms(e){if(!e.length)return;let t={Action:"DeleteAlarms"};e.forEach((r,a)=>{t[`AlarmNames.member.${a+1}`]=r}),await this.query(t)}}class K{client;region;constructor(e="us-east-1",t){this.region=e,this.client=new N(void 0,{profile:t})}async createLogGroup(e,t){await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.CreateLogGroup","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({logGroupName:e,...t?{tags:t}:{}})})}async putRetentionPolicy(e,t){if(![1,3,5,7,14,30,60,90,120,150,180,365,400,545,731,1096,1827,2192,2557,2922,3288,3653].includes(t))throw Error("Unsupported CloudWatch Logs retention period");await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.PutRetentionPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({logGroupName:e,retentionInDays:t})})}async describeLogStreams(e){let t={logGroupName:e.logGroupName};if(e.logStreamNamePrefix)t.logStreamNamePrefix=e.logStreamNamePrefix;if(e.orderBy)t.orderBy=e.orderBy;if(e.descending!==void 0)t.descending=e.descending;if(e.limit)t.limit=e.limit;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.DescribeLogStreams","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(t)})}async getLogEvents(e){let t={logGroupName:e.logGroupName,logStreamName:e.logStreamName};if(e.startTime)t.startTime=e.startTime;if(e.endTime)t.endTime=e.endTime;if(e.limit)t.limit=e.limit;if(e.startFromHead!==void 0)t.startFromHead=e.startFromHead;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.GetLogEvents","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(t)})}async describeLogGroups(e){let t={};if(e?.logGroupNamePrefix)t.logGroupNamePrefix=e.logGroupNamePrefix;if(e?.limit)t.limit=e.limit;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.DescribeLogGroups","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(t)})}async deleteLogGroup(e){await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.DeleteLogGroup","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({logGroupName:e})})}async filterLogEvents(e){let t={logGroupName:e.logGroupName};if(e.logStreamNames)t.logStreamNames=e.logStreamNames;if(e.startTime)t.startTime=e.startTime;if(e.endTime)t.endTime=e.endTime;if(e.filterPattern)t.filterPattern=e.filterPattern;if(e.limit)t.limit=e.limit;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.FilterLogEvents","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(t)})}}import{createHash as fe}from"node:crypto";import{existsSync as re,mkdirSync as Se,readdirSync as Ce,readFileSync as Te,rmSync as be,writeFileSync as Ne}from"node:fs";import{homedir as Ae}from"node:os";import{join as I}from"node:path";var se=1,ie=3600000,Me=24*ie,ve=ie,xe=30*Me;function H(){let e=process.env.XDG_CACHE_HOME;return I(e&&e.trim()?e:I(Ae(),".cache"),"ts-cloud","cost-explorer")}function B(e){return I(H(),e??"__default__")}function ae(e){let t={s:e.start,e:e.end,g:e.granularity,m:[...e.metrics].sort(),gb:[...e.groupBy].map((r)=>`${r.Type}:${r.Key}`).sort(),f:e.filter??null};return fe("sha256").update(JSON.stringify(t)).digest("hex").slice(0,24)}function De(e,t){let r=Date.parse(`${t}T00:00:00Z`);if(Number.isNaN(r))return!1;let a=new Date,s=Date.UTC(a.getUTCFullYear(),a.getUTCMonth(),1);return r<=s}function Pe(e){return De(e.start,e.end)?xe:ve}function ne(e,t){let r=I(B(e),`${ae(t)}.json`);if(!re(r))return null;let a;try{a=JSON.parse(Te(r,"utf-8"))}catch{return null}if(a.schema!==se)return null;let s=Date.now()-a.savedAt;if(s<0||s>Pe(t))return null;return{response:a.response,ageSeconds:Math.floor(s/1000)}}function oe(e,t,r){let a=B(e);Se(a,{recursive:!0});let s={schema:se,savedAt:Date.now(),key:t,response:r};Ne(I(a,`${ae(t)}.json`),JSON.stringify(s))}function We(e){let t=e===void 0?H():B(e);if(!re(t))return{deletedFiles:0,scope:e??"all profiles"};let r=0;function a(s){for(let o of Ce(s,{withFileTypes:!0})){let h=I(s,o.name);if(o.isDirectory())a(h);else if(o.isFile()&&o.name.endsWith(".json"))r++}}return a(t),be(t,{recursive:!0,force:!0}),{deletedFiles:r,scope:e??"all profiles"}}function Ge(e){return e===void 0?H():B(e)}class Y{client;profile;useCache;lastCacheAgeSeconds=null;constructor(e,t){this.profile=e,this.useCache=t?.useCache??!0,this.client=new N(V(e))}async getCostByService(e){return(await this.getCostByDimension({...e,dimension:"SERVICE"})).map((r)=>({service:r.key,amount:r.amount,unit:r.unit}))}async getCostByDimension(e){let{start:t,end:r,dimension:a,granularity:s="MONTHLY",filter:o}=e,h=["UnblendedCost"],m=[{Type:"DIMENSION",Key:a}],d={start:t,end:r,granularity:s,metrics:h,groupBy:m,filter:o};if(this.useCache){let C=ne(this.profile,d);if(C)return this.lastCacheAgeSeconds=C.ageSeconds,C.response}this.lastCacheAgeSeconds=null;let p=new Map,i;do{let C={TimePeriod:{Start:t,End:r},Granularity:s,Metrics:h,GroupBy:m};if(o)C.Filter=o;if(i)C.NextPageToken=i;let D=await this.client.request({service:"ce",region:"us-east-1",method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"AWSInsightsIndexService.GetCostAndUsage"},body:JSON.stringify(C)});for(let G of D?.ResultsByTime??[])for(let T of G?.Groups??[]){let O=T.Keys?.[0]??"Unknown",_=Number.parseFloat(T.Metrics?.UnblendedCost?.Amount??"0"),q=T.Metrics?.UnblendedCost?.Unit??"USD",P=p.get(O);p.set(O,{key:O,amount:(P?.amount??0)+_,unit:q})}i=D?.NextPageToken||void 0}while(i);let E=[...p.values()].filter((C)=>C.amount>0).sort((C,D)=>D.amount-C.amount);if(this.useCache)oe(this.profile,d,E);return E}async getDailyTotals(e){return((await this.client.request({service:"ce",region:"us-east-1",method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"AWSInsightsIndexService.GetCostAndUsage"},body:JSON.stringify({TimePeriod:{Start:e.start,End:e.end},Granularity:"DAILY",Metrics:["UnblendedCost"]})}))?.ResultsByTime??[]).map((a)=>Number.parseFloat(a.Total?.UnblendedCost?.Amount??"0"))}}class J{client;region;constructor(e="us-east-1"){this.region=e,this.client=new N}async describeFileSystems(e){let t=[];if(e?.FileSystemId)t.push(`FileSystemId=${encodeURIComponent(e.FileSystemId)}`);if(e?.CreationToken)t.push(`CreationToken=${encodeURIComponent(e.CreationToken)}`);let r=`/2015-02-01/file-systems${t.length>0?`?${t.join("&")}`:""}`;return{FileSystems:((await this.client.request({service:"elasticfilesystem",region:this.region,method:"GET",path:r,headers:{"Content-Type":"application/json"}})).FileSystems||[]).map((s)=>({FileSystemId:s.FileSystemId,Name:s.Name,CreationTime:s.CreationTime,LifeCycleState:s.LifeCycleState,NumberOfMountTargets:s.NumberOfMountTargets,SizeInBytes:s.SizeInBytes?{Value:s.SizeInBytes.Value,Timestamp:s.SizeInBytes.Timestamp}:void 0,PerformanceMode:s.PerformanceMode,Encrypted:s.Encrypted,ThroughputMode:s.ThroughputMode,Tags:s.Tags}))}}}class Q{client;region;constructor(e="us-east-1"){this.region=e,this.client=new N}async call(e,t){return this.client.request({service:"wafv2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":`AWSWAF_20190729.${e}`},body:JSON.stringify(t)})}async listWebACLs(e="REGIONAL"){return(await this.call("ListWebACLs",{Scope:e,Limit:100}))?.WebACLs??[]}async getWebACLRules(e,t,r="REGIONAL"){return((await this.call("GetWebACL",{Name:e,Id:t,Scope:r}))?.WebACL?.Rules??[]).map((o)=>({Name:o.Name,Priority:o.Priority,Action:o.Action?Object.keys(o.Action)[0]:o.OverrideAction?Object.keys(o.OverrideAction)[0]:"count"}))}}function me(e){return String(e).padStart(2,"0")}function F(e){return`${e.getUTCFullYear()}-${me(e.getUTCMonth()+1)}-${me(e.getUTCDate())}`}function we(e){let t=Math.max(0,Math.round((Date.now()-e)/1000));if(t<60)return`${t}s ago`;let r=Math.round(t/60);if(r<60)return`${r}m ago`;let a=Math.round(r/60);if(a<48)return`${a}h ago`;return`${Math.round(a/24)}d ago`}async function k(e,t,r,a,s,o){let h=await e.getMetricStatistics({Namespace:"AWS/Lambda",MetricName:r,Dimensions:[{Name:"FunctionName",Value:t}],StartTime:s,EndTime:o,Period:86400,Statistics:[a]}).catch(()=>[]);if(!h.length)return 0;if(a==="Sum")return h.reduce((m,d)=>m+(d.Sum??0),0);if(a==="Maximum")return Math.max(...h.map((m)=>m.Maximum??0));return h.reduce((m,d)=>m+(d.Average??0),0)/h.length}async function W(e,t,r,a,s,o,h){let m=await e.getMetricStatistics({Namespace:t,MetricName:r,Dimensions:a,StartTime:o,EndTime:h,Period:86400,Statistics:[s]}).catch(()=>[]);if(!m.length)return 0;if(s==="Sum")return m.reduce((d,p)=>d+(p.Sum??0),0);if(s==="Maximum")return Math.max(...m.map((d)=>d.Maximum??0));return m.reduce((d,p)=>d+(p.Average??0),0)/m.length}async function X(e,t,r,a,s){let o=await e.getMetricStatistics({Namespace:"AWS/Lambda",MetricName:"Duration",Dimensions:[{Name:"FunctionName",Value:t}],StartTime:a,EndTime:s,Period:86400,ExtendedStatistics:[r]}).catch(()=>[]);return Math.round(o.reduce((h,m)=>h+(m.Percentiles?.[r]??0),0))}async function mt(e,t){let r=await pe(e,t),a=r.region,s=new j(a),o=new de(a),h=new K(a),m=new Date,d=new Date(m.getTime()-86400000),p=e.environments?.[t]?.app,i={};i.app={name:r.slug,env:t,region:a,runtime:p?.kind==="php"?`php-${p?.phpVersion??"8.3"} (fpm)`:p?.kind??"node",url:r.endpoint??"",build:r.lastRelease?.sha?.slice(0,7)??"—",deployedAt:r.lastRelease?.timestamp??"—"},i.maintenance={enabled:!1},i.scheduler={enabled:r.scheduler!=="off",expression:r.scheduler==="sub-minute"?"rate(1 minute) · sub-minute":"rate(1 minute)",lastRun:"—"};let E=0,C=0,D=0,G=[],T=[],O=[];for(let n of r.functions){let[u,l,c,f,g,S,b,A,w]=await Promise.all([k(s,n.name,"Invocations","Sum",d,m),k(s,n.name,"Errors","Sum",d,m),k(s,n.name,"Throttles","Sum",d,m),k(s,n.name,"Duration","Average",d,m),o.getFunction(n.name).catch(()=>null),X(s,n.name,"p50",d,m),X(s,n.name,"p95",d,m),X(s,n.name,"p99",d,m),s.getMetricSeries({Namespace:"AWS/Lambda",MetricName:"Invocations",Dimensions:[{Name:"FunctionName",Value:n.name}],StartTime:new Date(m.getTime()-43200000),EndTime:m,Period:3600,Stat:"Sum"}).catch(()=>[])]);E+=u,C+=l,D=Math.max(D,f);let R=g?.Configuration?.MemorySize??0,M=Object.keys(g?.Configuration?.Environment?.Variables??{}),U=[],y=0;try{let{events:z=[]}=await h.filterLogEvents({logGroupName:`/aws/lambda/${n.name}`,startTime:d.getTime(),limit:120});for(let x of z){let L=(x.message??"").trim(),ee=/Max Memory Used:\s*(\d+)\s*MB/.exec(L);if(ee)y=Math.max(y,Number(ee[1]));if(L&&!/^(?:START|END|REPORT|INIT_START)/.test(L))O.push({source:n.mode||n.name,timestamp:new Date(x.timestamp??0).toISOString(),when:we(x.timestamp??0),message:L.slice(0,400),level:/error|exception|fatal|panic|traceback/i.test(L)?"error":/warn|warning|timeout|retr(?:y|ies)|throttl/i.test(L)?"warn":"info"})}U=z.filter((x)=>!/^(?:START|END|REPORT|INIT_START)/.test((x.message??"").trim())).slice(-6).map((x)=>({ts:new Date(x.timestamp??0).toISOString().slice(11,19),msg:(x.message??"").trim().slice(0,120),err:/error|exception|fatal/i.test(x.message??"")}))}catch{}let v=Math.max(1,...w);G.push({key:n.mode,name:n.name,version:n.version,memory:R,timeout:g?.Configuration?.Timeout??0,runtime:g?.Configuration?.Runtime??"provided.al2023",invocations:Math.round(u),errors:Math.round(l),p95:b||Math.round(f),status:"active",provisioned:n.provisioned?`${n.provisioned.allocated}/${n.provisioned.requested}`:void 0}),T.push({key:n.mode,name:n.name,runtime:g?.Configuration?.Runtime??"provided.al2023",arch:g?.Configuration?.Architectures?.[0]??"x86_64",memory:R,timeout:g?.Configuration?.Timeout??0,ephemeral:g?.Configuration?.EphemeralStorage?.Size??512,version:n.version,concurrency:p?.concurrency??"—",invocations:Math.round(u),errors:Math.round(l),throttles:Math.round(c),p50:S||Math.round(f),p95:b||Math.round(f),p99:A||Math.round(f),maxMem:y,spark:w.length?w.map((z)=>Math.round(z/v*100)):[0],env:M.length?M:["(none)"],recent:U.length?U:[{ts:"—",msg:"no recent events",err:!1}]})}i.functions=G,i.functionsDetail=T,i.serverlessLogs=O.sort((n,u)=>String(u.timestamp).localeCompare(String(n.timestamp))).slice(0,600),i.serverlessLogsEmptyReason=O.length?void 0:"No recent function logs were found in CloudWatch for this environment.";let _=E?Number((C/E*100).toFixed(2)):0,q=Math.round(await k(s,r.functions[0]?.name??"","ConcurrentExecutions","Maximum",d,m));i.metrics={invocations:Math.round(E),errorRatePct:_,p95Ms:Math.round(D),coldStartPct:void 0,concurrency:q,estCostUsd:void 0};try{let n=new he(a),u=[],l=[],c=0;try{let{QueueUrl:g}=await n.getQueueUrl(`${r.slug}-${t}-dlq`),{Attributes:S}=await n.getQueueAttributes(g);c=Number(S.ApproximateNumberOfMessages??0)}catch{}let f=p?ue(p,r.slug,t):[];for(let g of f){let S=g.name.replace(`${r.slug}-${t}-`,""),b=0,A=0;try{let{QueueUrl:R}=await n.getQueueUrl(g.name),{Attributes:M}=await n.getQueueAttributes(R);b=Number(M.ApproximateNumberOfMessages??0),A=Number(M.ApproximateNumberOfMessagesNotVisible??0)}catch{}let w=Math.round(await W(s,"AWS/SQS","NumberOfMessagesDeleted",[{Name:"QueueName",Value:g.name}],"Sum",d,m));u.push({name:S,visible:b,inFlight:A,processed:w,dlq:c}),l.push({name:g.name,short:S,visible:b,inFlight:A,delayed:0,processed:w,oldestSec:0,concurrency:g.concurrency??p?.queueConcurrency??"—",tries:p?.queueTries??3,visTimeout:(p?.queueTimeout??120)*6,dlq:c})}if(u.length)i.queues=u;if(l.length)i.queuesDetail=l;i.dlqItems=[]}catch{}try{let n=new le(a),{Stacks:u}=await n.describeStacks({stackName:ce(e,t)}),l={};for(let c of u?.[0]?.Outputs??[])if(c.OutputKey)l[c.OutputKey]=c.OutputValue??"";if(p?.database?.connection==="aurora-serverless"){let c=`${r.slug}-${t}-db`,f=[{Name:"DBClusterIdentifier",Value:c}],[g,S]=await Promise.all([W(s,"AWS/RDS","ServerlessDatabaseCapacity",f,"Average",d,m),W(s,"AWS/RDS","DatabaseConnections",f,"Maximum",d,m)]);if(i.aurora={id:c,engine:"aurora-mysql",minAcu:p?.database?.minCapacity??0.5,maxAcu:p?.database?.maxCapacity??4,currentAcu:g?Number(g.toFixed(1)):p?.database?.minCapacity??0.5,database:"app",connections:Math.round(S),status:l.DbEndpoint?"available":"creating"},p?.rdsProxy)i.proxy={name:`${r.slug}-${t}-proxy`,endpoint:l.DbProxyEndpoint??"—",pooledConns:Math.round(S),status:"available"}}if(p?.cache?.driver==="elasticache"){let c=`${r.slug}-${t}-cache`,f=[{Name:"CacheClusterId",Value:`${c}-001`}],[g,S]=await Promise.all([W(s,"AWS/ElastiCache","CacheHits",f,"Sum",d,m),W(s,"AWS/ElastiCache","CacheMisses",f,"Sum",d,m)]),b=g+S>0?Number((g/(g+S)*100).toFixed(1)):0;i.redis={id:c,node:"cache.t4g.micro",engine:"redis",hitRate:b,status:l.CacheEndpoint?"available":"creating"}}if(p?.efs){let c=0;try{if(l.EfsFileSystemId){let f=new J(a),{FileSystems:g}=await f.describeFileSystems({FileSystemId:l.EfsFileSystemId});c=Number(((g?.[0]?.SizeInBytes?.Value??0)/1048576).toFixed(1))}}catch{}i.efs={id:l.EfsFileSystemId??"efs",mount:"/mnt/local",sizeMb:c,status:"available"}}i.assetsInfo=l.AssetsCdnDomain?{bucket:l.AssetsBucketName??`${r.slug}-${t}-assets`,cdn:l.AssetsCdnDomain,customDomain:p?.assetDomain??"—",assetUrl:r.assetUrl??"—",files:0,sizeMb:0,cacheHitPct:0,build:i.app.build}:void 0}catch{}if(i.assetsInfo)try{let u=await new Z(a).list({bucket:i.assetsInfo.bucket,maxKeys:1000});i.assetsInfo.files=u.length,i.assetsInfo.sizeMb=Number((u.reduce((l,c)=>l+(c.Size??0),0)/1048576).toFixed(1)),i.assetsRecent=u.slice(0,8).map((l)=>({path:`/${l.Key}`,size:`${Math.max(1,Math.round((l.Size??0)/1024))} KB`,type:l.Key.split(".").pop()??""}))}catch{}try{if(p?.secrets){let n=Array.isArray(p.secrets)?p.secrets.map((u)=>({key:u.split("/").pop().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),source:u})):Object.entries(p.secrets).map(([u,l])=>({key:u,source:String(l)}));i.secretsList=n.map((u)=>({...u,updated:"—"}))}}catch{}try{let n=new Z(a),u=`${r.slug}-${t}-deployments`,l=await n.getObjectJson(u,`deployments/${r.slug}/${t}/history.json`).catch(()=>null);if(l?.records?.length)i.deploymentsDetail=l.records.slice(-12).reverse().map((c)=>({sha:(c.sha??"").slice(0,7),status:c.status??"success",when:c.timestamp??"—",took:c.took??"—",by:c.by??"—",version:c.version??"—",hooks:c.hooks??[]}))}catch{}i.metricsTotals={invocations:i.metrics.invocations,errors:Math.round(C),errorRatePct:_,p95Ms:i.metrics.p95Ms,throttles:T.reduce((n,u)=>n+u.throttles,0),coldStartPct:void 0,estCostUsd:void 0,concurrency:q},i.metricsPerFn=T.map((n)=>({key:n.key,invocations:n.invocations,errors:n.errors,throttles:n.throttles,avgMs:n.p50,maxMs:n.p99,costUsd:void 0}));try{i.invSpark=await s.getMetricSeries({Namespace:"AWS/Lambda",MetricName:"Invocations",Dimensions:[{Name:"FunctionName",Value:r.functions.find((n)=>n.mode==="http")?.name??""}],StartTime:new Date(m.getTime()-86400000),EndTime:m,Period:3600,Stat:"Sum"})}catch{}try{let n=new Y,u=m,l=new Date(Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),1)),c=new Date(Date.UTC(u.getUTCFullYear(),u.getUTCMonth()-1,1)),[f,g]=await Promise.all([n.getCostByService({start:F(l),end:F(u),granularity:"MONTHLY"}).catch(()=>[]),n.getCostByService({start:F(c),end:F(l),granularity:"MONTHLY"}).catch(()=>[])]);if(f.length){let S=f.reduce((y,v)=>y+v.amount,0),b=g.reduce((y,v)=>y+v.amount,0),A=u.getUTCDate(),w=new Date(Date.UTC(u.getUTCFullYear(),u.getUTCMonth()+1,0)).getUTCDate();i.costSummary={monthToDateUsd:Number(S.toFixed(2)),projectedUsd:Number((S/A*w).toFixed(2)),lastMonthUsd:Number(b.toFixed(2)),dailyAvgUsd:Number((S/A).toFixed(2))},i.costServices=f.filter((y)=>y.amount>0).sort((y,v)=>v.amount-y.amount).slice(0,12).map((y)=>({name:y.service,usd:Number(y.amount.toFixed(2)),note:""})),i.metrics.estCostUsd=Number((S/A).toFixed(2)),i.metricsTotals.estCostUsd=i.metrics.estCostUsd,i.costTrend=await n.getDailyTotals({start:F(l),end:F(u)}).catch(()=>[]);let R=f.find((y)=>/lambda/i.test(y.service))?.amount??0,M=(y)=>y.invocations*(y.p50/1000)*(y.memory/1024),U=T.reduce((y,v)=>y+M(v),0)||1;i.costPerFn=T.map((y)=>({key:y.key,requests:y.invocations,gbSec:Math.round(M(y)),usd:Number((R*(M(y)/U)).toFixed(2))}))}}catch{}if(p?.firewall)try{let n=await s.getMetricStatistics({Namespace:"AWS/WAFV2",MetricName:"BlockedRequests",StartTime:d,EndTime:m,Period:86400,Statistics:["Sum"]}).catch(()=>[]),u=await s.getMetricStatistics({Namespace:"AWS/WAFV2",MetricName:"AllowedRequests",StartTime:d,EndTime:m,Period:86400,Statistics:["Sum"]}).catch(()=>[]);i.waf={enabled:!0,scope:"REGIONAL",acl:`${r.slug}-${t}-waf`,allowed24h:Math.round(u.reduce((l,c)=>l+(c.Sum??0),0)),blocked24h:Math.round(n.reduce((l,c)=>l+(c.Sum??0),0))};try{let l=new Q(a),c=await l.listWebACLs("REGIONAL"),f=c.find((g)=>g.Name?.includes(`${r.slug}-${t}`))??c[0];if(f?.Name&&f.Id){i.waf.acl=f.Name;let g=await l.getWebACLRules(f.Name,f.Id,"REGIONAL");if(g.length)i.wafRules=g.map((S)=>({name:S.Name??"—",detail:`priority ${S.Priority??0}`,action:S.Action??"count",blocked24h:0}))}}catch{}}catch{}let P=[];if(i.aurora)P.push({name:"Aurora Serverless v2",detail:`${i.aurora.id} · ${i.aurora.minAcu}-${i.aurora.maxAcu} ACU`,status:i.aurora.status});if(i.proxy)P.push({name:"RDS Proxy",detail:i.proxy.name,status:i.proxy.status});if(i.redis)P.push({name:`ElastiCache (${i.redis.engine})`,detail:`${i.redis.node} · ${i.redis.hitRate}% hit rate`,status:i.redis.status});if(i.efs)P.push({name:"EFS",detail:`${i.efs.mount} · ${i.efs.sizeMb} MB`,status:i.efs.status});if(P.length)i.dataServices=P;if(r.scheduler!=="off"&&p?.kind==="php")try{let n=await ge(e,t,"schedule:list"),u=[];for(let l of(n||"").split(`
|
|
2
|
-
`)){let c=/^\s*([\d*/,\-\s]+?)\s{2,}(.+?)(?:\s{2,}Next Due.*)?$/.exec(l);if(c&&/[*\d]/.test(c[1])&&c[1].trim().split(/\s+/).length===5)u.push({command:c[2].trim().replace(/^php artisan /,""),cron:c[1].trim(),desc:"",lastRun:"—",lastStatus:"ok"})}if(u.length)i.schedulerTasks=u}catch{}return i.topology=ye(i,{project:e.project.name,environment:t}),i}
|
|
3
|
-
export{K as Bd,j as Cd,We as Dd,Ge as Ed,Y as Fd,mt as Gd};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import{dh as a}from"./chunk-ja1vjdn1.js";class d{client;region;constructor(e="us-east-1"){this.region=e,this.client=new a}async createHostedZone(e){let t=e.CallerReference||`${Date.now()}-${Math.random().toString(36).slice(2)}`,o=`<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
|
|
3
|
-
<Name>${e.Name}</Name>
|
|
4
|
-
<CallerReference>${t}</CallerReference>`;if(e.HostedZoneConfig){if(o+=`
|
|
5
|
-
<HostedZoneConfig>`,e.HostedZoneConfig.Comment)o+=`
|
|
6
|
-
<Comment>${e.HostedZoneConfig.Comment}</Comment>`;if(e.HostedZoneConfig.PrivateZone!==void 0)o+=`
|
|
7
|
-
<PrivateZone>${e.HostedZoneConfig.PrivateZone}</PrivateZone>`;o+=`
|
|
8
|
-
</HostedZoneConfig>`}if(e.VPC)o+=`
|
|
9
|
-
<VPC>
|
|
10
|
-
<VPCRegion>${e.VPC.VPCRegion}</VPCRegion>
|
|
11
|
-
<VPCId>${e.VPC.VPCId}</VPCId>
|
|
12
|
-
</VPC>`;if(e.DelegationSetId)o+=`
|
|
13
|
-
<DelegationSetId>${e.DelegationSetId}</DelegationSetId>`;o+=`
|
|
14
|
-
</CreateHostedZoneRequest>`;let n=await this.client.request({service:"route53",region:this.region,method:"POST",path:"/2013-04-01/hostedzone",headers:{"content-type":"application/xml"},body:o});return this.parseCreateHostedZoneResponse(n)}async listHostedZones(e){let t={};if(e?.Marker)t.marker=e.Marker;if(e?.MaxItems)t.maxitems=e.MaxItems;let o=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzone",queryParams:Object.keys(t).length>0?t:void 0});return this.parseListHostedZonesResponse(o)}async listHostedZonesByName(e){let t={};if(e?.DNSName)t.dnsname=e.DNSName;if(e?.HostedZoneId)t.hostedzoneid=e.HostedZoneId;if(e?.MaxItems)t.maxitems=e.MaxItems;let o=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzonesbyname",queryParams:Object.keys(t).length>0?t:void 0});return this.parseListHostedZonesResponse(o)}async getHostedZone(e){let t=e.Id.replace("/hostedzone/",""),o=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${t}`});return this.parseGetHostedZoneResponse(o)}async deleteHostedZone(e){let t=e.Id.replace("/hostedzone/","");await this.client.request({service:"route53",region:this.region,method:"DELETE",path:`/2013-04-01/hostedzone/${t}`})}async listResourceRecordSets(e){let t=e.HostedZoneId.replace("/hostedzone/",""),o={};if(e.StartRecordName)o.name=e.StartRecordName;if(e.StartRecordType)o.type=e.StartRecordType;if(e.StartRecordIdentifier)o.identifier=e.StartRecordIdentifier;if(e.MaxItems)o.maxitems=e.MaxItems;let n=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${t}/rrset`,queryParams:Object.keys(o).length>0?o:void 0});return this.parseListResourceRecordSetsResponse(n)}async changeResourceRecordSets(e){let t=e.HostedZoneId.replace("/hostedzone/",""),o=`<?xml version="1.0" encoding="UTF-8"?>
|
|
15
|
-
<ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
|
|
16
|
-
<ChangeBatch>`;if(e.ChangeBatch.Comment)o+=`
|
|
17
|
-
<Comment>${this.escapeXml(e.ChangeBatch.Comment)}</Comment>`;o+=`
|
|
18
|
-
<Changes>`;for(let s of e.ChangeBatch.Changes){if(o+=`
|
|
19
|
-
<Change>
|
|
20
|
-
<Action>${s.Action}</Action>
|
|
21
|
-
<ResourceRecordSet>
|
|
22
|
-
<Name>${s.ResourceRecordSet.Name}</Name>
|
|
23
|
-
<Type>${s.ResourceRecordSet.Type}</Type>`,s.ResourceRecordSet.TTL!==void 0)o+=`
|
|
24
|
-
<TTL>${s.ResourceRecordSet.TTL}</TTL>`;if(s.ResourceRecordSet.SetIdentifier)o+=`
|
|
25
|
-
<SetIdentifier>${s.ResourceRecordSet.SetIdentifier}</SetIdentifier>`;if(s.ResourceRecordSet.Weight!==void 0)o+=`
|
|
26
|
-
<Weight>${s.ResourceRecordSet.Weight}</Weight>`;if(s.ResourceRecordSet.Region)o+=`
|
|
27
|
-
<Region>${s.ResourceRecordSet.Region}</Region>`;if(s.ResourceRecordSet.Failover)o+=`
|
|
28
|
-
<Failover>${s.ResourceRecordSet.Failover}</Failover>`;if(s.ResourceRecordSet.HealthCheckId)o+=`
|
|
29
|
-
<HealthCheckId>${s.ResourceRecordSet.HealthCheckId}</HealthCheckId>`;if(s.ResourceRecordSet.ResourceRecords&&s.ResourceRecordSet.ResourceRecords.length>0){o+=`
|
|
30
|
-
<ResourceRecords>`;for(let r of s.ResourceRecordSet.ResourceRecords)o+=`
|
|
31
|
-
<ResourceRecord>
|
|
32
|
-
<Value>${this.escapeXml(r.Value)}</Value>
|
|
33
|
-
</ResourceRecord>`;o+=`
|
|
34
|
-
</ResourceRecords>`}if(s.ResourceRecordSet.AliasTarget)o+=`
|
|
35
|
-
<AliasTarget>
|
|
36
|
-
<HostedZoneId>${s.ResourceRecordSet.AliasTarget.HostedZoneId}</HostedZoneId>
|
|
37
|
-
<DNSName>${s.ResourceRecordSet.AliasTarget.DNSName}</DNSName>
|
|
38
|
-
<EvaluateTargetHealth>${s.ResourceRecordSet.AliasTarget.EvaluateTargetHealth}</EvaluateTargetHealth>
|
|
39
|
-
</AliasTarget>`;if(s.ResourceRecordSet.GeoLocation){if(o+=`
|
|
40
|
-
<GeoLocation>`,s.ResourceRecordSet.GeoLocation.ContinentCode)o+=`
|
|
41
|
-
<ContinentCode>${s.ResourceRecordSet.GeoLocation.ContinentCode}</ContinentCode>`;if(s.ResourceRecordSet.GeoLocation.CountryCode)o+=`
|
|
42
|
-
<CountryCode>${s.ResourceRecordSet.GeoLocation.CountryCode}</CountryCode>`;if(s.ResourceRecordSet.GeoLocation.SubdivisionCode)o+=`
|
|
43
|
-
<SubdivisionCode>${s.ResourceRecordSet.GeoLocation.SubdivisionCode}</SubdivisionCode>`;o+=`
|
|
44
|
-
</GeoLocation>`}o+=`
|
|
45
|
-
</ResourceRecordSet>
|
|
46
|
-
</Change>`}o+=`
|
|
47
|
-
</Changes>
|
|
48
|
-
</ChangeBatch>
|
|
49
|
-
</ChangeResourceRecordSetsRequest>`;let n=await this.client.request({service:"route53",region:this.region,method:"POST",path:`/2013-04-01/hostedzone/${t}/rrset`,headers:{"content-type":"application/xml"},body:o});return this.parseChangeResourceRecordSetsResponse(n)}escapeXml(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}parseCreateHostedZoneResponse(e){let t=e.CreateHostedZoneResponse||e;return{HostedZone:this.parseHostedZone(t.HostedZone),ChangeInfo:{Id:t.ChangeInfo?.Id||"",Status:t.ChangeInfo?.Status||"",SubmittedAt:t.ChangeInfo?.SubmittedAt||""},DelegationSet:this.parseDelegationSet(t.DelegationSet),Location:t.Location||""}}parseListHostedZonesResponse(e){let t=e.ListHostedZonesResponse||e.ListHostedZonesByNameResponse||e,o=t.HostedZones?.HostedZone||t.HostedZones||[];if(!Array.isArray(o))o=o?[o]:[];return{HostedZones:o.map((n)=>this.parseHostedZone(n)),IsTruncated:t.IsTruncated==="true"||t.IsTruncated===!0,MaxItems:t.MaxItems||"100",Marker:t.Marker,NextMarker:t.NextMarker}}parseGetHostedZoneResponse(e){let t=e.GetHostedZoneResponse||e;return{HostedZone:this.parseHostedZone(t.HostedZone),DelegationSet:this.parseDelegationSet(t.DelegationSet),VPCs:t.VPCs?.VPC?Array.isArray(t.VPCs.VPC)?t.VPCs.VPC:[t.VPCs.VPC]:void 0}}parseListResourceRecordSetsResponse(e){let t=e.ListResourceRecordSetsResponse||e,o=t.ResourceRecordSets?.ResourceRecordSet||t.ResourceRecordSets||[];if(!Array.isArray(o))o=o?[o]:[];return{ResourceRecordSets:o.map((n)=>this.parseResourceRecordSet(n)),IsTruncated:t.IsTruncated==="true"||t.IsTruncated===!0,MaxItems:t.MaxItems||"100",NextRecordName:t.NextRecordName,NextRecordType:t.NextRecordType,NextRecordIdentifier:t.NextRecordIdentifier}}parseChangeResourceRecordSetsResponse(e){let t=e.ChangeResourceRecordSetsResponse||e;return{ChangeInfo:{Id:t.ChangeInfo?.Id||"",Status:t.ChangeInfo?.Status||"",SubmittedAt:t.ChangeInfo?.SubmittedAt||"",Comment:t.ChangeInfo?.Comment}}}parseHostedZone(e){if(!e)return{Id:"",Name:""};return{Id:e.Id||"",Name:e.Name||"",CallerReference:e.CallerReference,Config:e.Config?{Comment:e.Config.Comment,PrivateZone:e.Config.PrivateZone==="true"||e.Config.PrivateZone===!0}:void 0,ResourceRecordSetCount:e.ResourceRecordSetCount?Number(e.ResourceRecordSetCount):void 0}}parseDelegationSet(e){if(!e)return{NameServers:[]};let t=e.NameServers?.NameServer||e.NameServers||[];if(!Array.isArray(t))t=t?[t]:[];return{Id:e.Id,CallerReference:e.CallerReference,NameServers:t}}parseResourceRecordSet(e){if(!e)return{Name:"",Type:""};let t=e.ResourceRecords?.ResourceRecord||e.ResourceRecords||[];if(!Array.isArray(t))t=t?[t]:[];return{Name:e.Name||"",Type:e.Type||"",TTL:e.TTL?Number(e.TTL):void 0,ResourceRecords:t.map((o)=>({Value:o.Value||o})),AliasTarget:e.AliasTarget?{HostedZoneId:e.AliasTarget.HostedZoneId,DNSName:e.AliasTarget.DNSName,EvaluateTargetHealth:e.AliasTarget.EvaluateTargetHealth==="true"||e.AliasTarget.EvaluateTargetHealth===!0}:void 0,SetIdentifier:e.SetIdentifier,Weight:e.Weight?Number(e.Weight):void 0,Region:e.Region,GeoLocation:e.GeoLocation,Failover:e.Failover,HealthCheckId:e.HealthCheckId}}async findHostedZoneByName(e){let t=e.endsWith(".")?e:`${e}.`;return(await this.listHostedZonesByName({DNSName:t})).HostedZones.find((s)=>s.Name===t)||null}async createARecord(e){let t=Array.isArray(e.Value)?e.Value:[e.Value];return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"A",TTL:e.TTL||300,ResourceRecords:t.map((o)=>({Value:o}))}}]}})}async createCnameRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"CNAME",TTL:e.TTL||300,ResourceRecords:[{Value:e.Value}]}}]}})}async createAliasRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:e.Type||"A",AliasTarget:{HostedZoneId:e.TargetHostedZoneId,DNSName:e.TargetDNSName,EvaluateTargetHealth:e.EvaluateTargetHealth??!1}}}]}})}async createTxtRecord(e){let o=(Array.isArray(e.Value)?e.Value:[e.Value]).map((n)=>{if(!n.startsWith('"'))return`"${n}"`;return n});return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"TXT",TTL:e.TTL||300,ResourceRecords:o.map((n)=>({Value:n}))}}]}})}async createMxRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"MX",TTL:e.TTL||300,ResourceRecords:e.Values.map((t)=>({Value:`${t.priority} ${t.mailServer}`}))}}]}})}async deleteRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"DELETE",ResourceRecordSet:e.RecordSet}]}})}async waitForChange(e,t=60,o=5000){let n=e.replace("/change/","");for(let s=0;s<t;s++){let r=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/change/${n}`});if((r.GetChangeResponse?.ChangeInfo?.Status||r.ChangeInfo?.Status)==="INSYNC")return!0;await new Promise((i)=>setTimeout(i,o))}return!1}async findOrCreateHostedZone(e){let t=e.domainName.endsWith(".")?e.domainName:`${e.domainName}.`,o=await this.findHostedZoneByName(t);if(o){let s=await this.getHostedZone({Id:o.Id});return{hostedZone:o,nameServers:s.DelegationSet.NameServers,isNew:!1}}let n=await this.createHostedZone({Name:t,HostedZoneConfig:{Comment:e.comment||`Hosted zone for ${e.domainName}`,PrivateZone:e.privateZone},VPC:e.vpc});return{hostedZone:n.HostedZone,nameServers:n.DelegationSet.NameServers,isNew:!0}}static getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length<=2)return e;return t.slice(-2).join(".")}async findHostedZoneForDomain(e){let o=e.replace(/\.$/,"").split(".");for(let n=0;n<o.length-1;n++){let s=o.slice(n).join("."),r=await this.findHostedZoneByName(s);if(r)return r}return null}async ensureHostedZone(e){let t=await this.findOrCreateHostedZone({domainName:e.domainName,comment:e.comment});return{hostedZoneId:t.hostedZone.Id.replace("/hostedzone/",""),nameServers:t.nameServers,isNew:t.isNew,action:t.isNew?"created":"found"}}async setupDomainDns(e){let{domain:t,createIfNotExists:o=!0}=e,n=await this.findHostedZoneByName(t);if(n){let r=await this.getHostedZone({Id:n.Id});return{success:!0,hostedZoneId:n.Id.replace("/hostedzone/",""),nameServers:r.DelegationSet.NameServers,isNew:!1,message:`Found existing hosted zone for ${t}`}}if(!o)return{success:!1,hostedZoneId:null,nameServers:[],isNew:!1,message:`No hosted zone found for ${t} and createIfNotExists is false`};let s=await this.createHostedZone({Name:t,HostedZoneConfig:{Comment:`Created automatically by ts-cloud for ${t}`}});return{success:!0,hostedZoneId:s.HostedZone.Id.replace("/hostedzone/",""),nameServers:s.DelegationSet.NameServers,isNew:!0,message:`Created new hosted zone for ${t}. Please update your domain registrar with these name servers: ${s.DelegationSet.NameServers.join(", ")}`}}static CloudFrontHostedZoneId="Z2FDTNDATAQYW2";static S3WebsiteHostedZoneIds={"us-east-1":"Z3AQBSTGFYJSTF","us-east-2":"Z2O1EMRO9K5GLX","us-west-1":"Z2F56UZL2M1ACD","us-west-2":"Z3BJ6K6RIION7M","ap-east-1":"ZNB98KWMFR0R6","ap-south-1":"Z11RGJOFQNVJUP","ap-northeast-1":"Z2M4EHUR26P7ZW","ap-northeast-2":"Z3W03O7B5YMIYP","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"Z3O0J2DXBE1FTB","ap-southeast-2":"Z1WCIGYICN2BYD","ca-central-1":"Z1QDHH18159H29","eu-central-1":"Z21DNDUVLTQW6Q","eu-west-1":"Z1BKCTXD74EZPE","eu-west-2":"Z3GKZC51ZF0DB4","eu-west-3":"Z3R1K369G5AVDG","eu-north-1":"Z3BAZG2TWCNX0D","sa-east-1":"Z7KQH4QJS55SO"};static ALBHostedZoneIds={"us-east-1":"Z35SXDOTRQ7X7K","us-east-2":"Z3AADJGX6KTTL2","us-west-1":"Z368ELLRRE2KJ0","us-west-2":"Z1H1FL5HABSF5","ap-east-1":"Z3DQVH9N71FHZ0","ap-south-1":"ZP97RAFLXTNZK","ap-northeast-1":"Z14GRHDCWA56QT","ap-northeast-2":"ZWKZPGTI48KDX","ap-northeast-3":"Z5LXEBD8Y73MNV","ap-southeast-1":"Z1LMS91P8CMLE5","ap-southeast-2":"Z1GM3OXH4ZPM65","ca-central-1":"ZQSVJUPU6J1EY","eu-central-1":"Z215JYRZR1TBD5","eu-west-1":"Z32O12XQLNTSW2","eu-west-2":"ZHURV8PSTC4K8","eu-west-3":"Z3Q77PNBQS71R4","eu-north-1":"Z23TAZ6LKFMNIO","sa-east-1":"Z2P70J7HTTTPLU"};static APIGatewayHostedZoneIds={"us-east-1":"Z1UJRXOUMOOFQ8","us-east-2":"ZOJJZC49E0EPZ","us-west-1":"Z2MUQ32089INYE","us-west-2":"Z2OJLYMUO9EFXC","ap-east-1":"Z3FD1VL90ND7K5","ap-south-1":"Z3VO1THU9YC4UR","ap-northeast-1":"Z1YSHQZHG15GKL","ap-northeast-2":"Z20JF4UZKIW1U8","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"ZL327KTPIQFUL","ap-southeast-2":"Z2RPCDW04V8134","ca-central-1":"Z19DQILCV0OWEC","eu-central-1":"Z1U9ULNL0V5AJ3","eu-west-1":"ZLY8HYME6SFDD","eu-west-2":"ZJ5UAJN8Y3Z2Q","eu-west-3":"Z3KY65QIEKYHQQ","eu-north-1":"Z3UWIKFBOOGXPP","sa-east-1":"ZCMLWB8V5SYIT"}}
|
|
50
|
-
export{d as og};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ch as a,dh as b,eh as c,fh as d}from"./chunk-ja1vjdn1.js";import"./chunk-ehc63fvs.js";export{b as AWSClient,c as buildQueryParams,d as detectCredentialSource,a as resolveS3Endpoint};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Gd as a}from"./chunk-e2bybahr.js";import"./chunk-d7ke90zt.js";import"./chunk-kg61p5hw.js";import"./chunk-c0bdafbx.js";import"./chunk-xhwqpgwq.js";import"./chunk-a7w13qfm.js";import"./chunk-btsyjhk7.js";import"./chunk-6tfwm33r.js";import"./chunk-ja1vjdn1.js";import"./chunk-4q6tad44.js";import"./chunk-ehc63fvs.js";export{a as resolveDashboardData};
|