@stacksjs/ts-cloud 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aws/index.js +1 -269
- package/dist/bin/chunk-00kg80qg.js +1 -0
- package/dist/bin/chunk-09nwf2gy.js +34 -0
- package/dist/bin/chunk-1k5kszjp.js +111 -0
- package/dist/bin/chunk-21e0mavm.js +1 -0
- package/dist/bin/chunk-271gk1n2.js +6 -0
- package/dist/bin/chunk-2empps47.js +2 -0
- package/dist/bin/chunk-38pq971s.js +2 -0
- package/dist/bin/chunk-3gykfyq4.js +37 -0
- package/dist/bin/chunk-3vqfexc4.js +70 -0
- package/dist/bin/chunk-4vrqm9h0.js +2 -0
- package/dist/bin/chunk-598yf4bs.js +1 -0
- package/dist/bin/chunk-5ectjq0b.js +1 -0
- package/dist/bin/chunk-5erkxpt7.js +512 -0
- package/dist/bin/chunk-5mrtzemj.js +1 -0
- package/dist/bin/chunk-5n9fmabb.js +1 -0
- package/dist/bin/chunk-9knpg30y.js +1 -0
- package/dist/bin/chunk-9pvsff8g.js +1 -0
- package/dist/bin/chunk-ax9mr6wm.js +44 -0
- package/dist/bin/chunk-axhnkn5g.js +2 -0
- package/dist/bin/chunk-c1vcdgvr.js +1 -0
- package/dist/bin/chunk-ctd2vg9w.js +2 -0
- package/dist/bin/chunk-dbgffky8.js +1 -0
- package/dist/bin/chunk-ddk4rt4j.js +6 -0
- package/dist/bin/chunk-dwr30vbv.js +1 -0
- package/dist/bin/chunk-e0rkrq70.js +1 -0
- package/dist/bin/chunk-e3xrwh9z.js +1 -0
- package/dist/bin/chunk-etrb03mt.js +1507 -0
- package/dist/bin/chunk-fhc6ntvd.js +2 -0
- package/dist/bin/chunk-fpm59y25.js +6 -0
- package/dist/bin/chunk-fvbxvq6b.js +1 -0
- package/dist/bin/chunk-fy8j3y8p.js +92 -0
- package/dist/bin/chunk-fz21b57w.js +1 -0
- package/dist/bin/chunk-gavvf0pg.js +141 -0
- package/dist/bin/chunk-ggn7ax8p.js +4 -0
- package/dist/bin/chunk-gpe2prkm.js +1 -0
- package/dist/bin/chunk-h5pa5men.js +2 -0
- package/dist/bin/chunk-hm08xdxf.js +2 -0
- package/dist/bin/chunk-hzgz13nf.js +1 -0
- package/dist/bin/chunk-j703btc5.js +50 -0
- package/dist/bin/chunk-k9t9wvms.js +1 -0
- package/dist/bin/chunk-m669wtgr.js +1 -0
- package/dist/bin/chunk-m7dgskt1.js +1 -0
- package/dist/bin/chunk-mh0kdzqp.js +2 -0
- package/dist/bin/chunk-mr0atd2s.js +2 -0
- package/dist/bin/chunk-mz0wbbsj.js +3 -0
- package/dist/bin/chunk-ngcyftm2.js +1 -0
- package/dist/bin/chunk-p66ptpmr.js +2 -0
- package/dist/bin/chunk-qk9qgepa.js +1 -0
- package/dist/bin/chunk-rxcvf10f.js +7364 -0
- package/dist/bin/chunk-rytk89az.js +60 -0
- package/dist/bin/chunk-tga3hhwk.js +6 -0
- package/dist/bin/chunk-tx0tqq2k.js +8 -0
- package/dist/bin/chunk-vek8a0w6.js +1 -0
- package/dist/bin/chunk-vm3q5gf2.js +3 -0
- package/dist/bin/chunk-y7s5r8y6.js +3 -0
- package/dist/bin/chunk-yv9sth30.js +1 -0
- package/dist/bin/chunk-zmegvjp8.js +581 -0
- package/dist/bin/cli.js +417 -10597
- package/dist/bin/dashboard-server.js +1 -6998
- package/dist/chunk-0ccta6z6.js +6 -0
- package/dist/chunk-0k1cs6pp.js +1 -0
- package/dist/chunk-1egjn203.js +704 -0
- package/dist/chunk-2wx29qga.js +5 -0
- package/dist/chunk-5m5rqmv7.js +1 -0
- package/dist/chunk-8ea5022g.js +114 -0
- package/dist/chunk-8xqn3c0w.js +2 -0
- package/dist/chunk-b4esxhmw.js +2 -0
- package/dist/chunk-b8e5wzwn.js +44 -0
- package/dist/chunk-bggt4n6e.js +2 -0
- package/dist/chunk-cwkg37rs.js +37 -0
- package/dist/chunk-dskvqt67.js +7355 -0
- package/dist/chunk-gahsdmxf.js +1617 -0
- package/dist/chunk-gnv3r2jg.js +1 -0
- package/dist/chunk-hg3c48cp.js +34 -0
- package/dist/chunk-m5azeva3.js +2 -0
- package/dist/chunk-r3qf56b3.js +92 -0
- package/dist/chunk-sdqa9ghv.js +141 -0
- package/dist/chunk-svrvvcm7.js +1 -0
- package/dist/chunk-v0p3hpc3.js +60 -0
- package/dist/chunk-wdzjbecg.js +50 -0
- package/dist/chunk-ww8k3g7j.js +1 -0
- package/dist/chunk-xmqfc62w.js +1 -0
- package/dist/chunk-xrebj679.js +435 -0
- package/dist/chunk-xt3s24vr.js +2 -0
- package/dist/chunk-y21zk0pn.js +4 -0
- package/dist/deploy/attach-credentials.d.ts +57 -0
- package/dist/deploy/index.js +1 -168
- package/dist/deploy/site-ports.d.ts +151 -0
- package/dist/deploy/site-target.d.ts +24 -1
- package/dist/dns/index.js +1 -41
- package/dist/drivers/index.js +1 -154
- package/dist/index.js +100 -6129
- package/dist/protection/index.js +1 -89
- package/dist/push/index.js +1 -509
- package/dist/spend/index.js +1 -173
- package/dist/ui/404.html +16 -548
- package/dist/ui/_stx/chunk.5ddb5087.js +90 -0
- package/dist/ui/_stx/chunk.9fd39d5b.js +86 -0
- package/dist/ui/_stx/chunk.d5301f79.js +119 -0
- package/dist/ui/_stx/crosswind.222ed683.css +1 -0
- package/dist/ui/_stx/crosswind.616c25f3.css +1 -0
- package/dist/ui/_stx/crosswind.80baa894.css +320 -0
- package/dist/ui/_stx/crosswind.906ee17c.css +1 -0
- package/dist/ui/_stx/crosswind.996ed49e.css +1 -0
- package/dist/ui/_stx/crosswind.b7a99a5c.css +1 -0
- package/dist/ui/_stx/router.fa5bc4dc.js +4 -0
- package/dist/ui/_stx/runtime.c696d17a.js +1 -0
- package/dist/ui/_stx/style.448ab192.css +1 -0
- package/dist/ui/accept-invitation.html +2 -1133
- package/dist/ui/access-denied.html +7 -1130
- package/dist/ui/account/automation.html +12 -1134
- package/dist/ui/account/security.html +13 -1136
- package/dist/ui/applications/compose.html +12 -1134
- package/dist/ui/applications/new.html +13 -1137
- package/dist/ui/data/backups.html +91 -1136
- package/dist/ui/data/services.html +89 -1136
- package/dist/ui/data/volumes.html +61 -1136
- package/dist/ui/index.html +60 -1136
- package/dist/ui/infrastructure/topology.html +128 -1135
- package/dist/ui/integrations.html +13 -1138
- package/dist/ui/operations/alerts.html +59 -1136
- package/dist/ui/operations/configuration.html +13 -1135
- package/dist/ui/operations/jobs.html +87 -1136
- package/dist/ui/operations/maintenance.html +12 -1134
- package/dist/ui/operations/observability.html +93 -1136
- package/dist/ui/operations/previews.html +12 -1134
- package/dist/ui/operations/queue.html +12 -1134
- package/dist/ui/operations/regions.html +12 -1134
- package/dist/ui/operations/releases.html +12 -1134
- package/dist/ui/operations/spend.html +65 -1136
- package/dist/ui/operations/workloads.html +115 -1136
- package/dist/ui/robots.txt +2 -0
- package/dist/ui/security.html +24 -1136
- package/dist/ui/server/actions.html +67 -1138
- package/dist/ui/server/activity.html +7 -1130
- package/dist/ui/server/capacity.html +12 -1134
- package/dist/ui/server/database.html +166 -1135
- package/dist/ui/server/deployments.html +60 -1136
- package/dist/ui/server/diagnostics.html +7 -1130
- package/dist/ui/server/firewall.html +286 -1212
- package/dist/ui/server/fleet.html +45 -1136
- package/dist/ui/server/logs.html +34 -1135
- package/dist/ui/server/metrics.html +124 -1140
- package/dist/ui/server/security.html +7 -1130
- package/dist/ui/server/services.html +46 -1133
- package/dist/ui/server/sites.html +287 -1137
- package/dist/ui/server/ssh-keys.html +62 -1135
- package/dist/ui/server/team.html +155 -1136
- package/dist/ui/server/terminal.html +97 -1183
- package/dist/ui/serverless/alarms.html +62 -1135
- package/dist/ui/serverless/assets.html +47 -1132
- package/dist/ui/serverless/cost.html +7 -1130
- package/dist/ui/serverless/data.html +46 -1135
- package/dist/ui/serverless/deployments.html +47 -1132
- package/dist/ui/serverless/firewall.html +7 -1130
- package/dist/ui/serverless/functions.html +50 -1136
- package/dist/ui/serverless/logs.html +34 -1135
- package/dist/ui/serverless/metrics.html +7 -1130
- package/dist/ui/serverless/queues.html +58 -1135
- package/dist/ui/serverless/secrets.html +62 -1136
- package/dist/ui/serverless/traces.html +12 -1134
- package/dist/ui/serverless.html +64 -1137
- package/dist/ui-src/pages/server/firewall.stx +14 -14
- package/package.json +3 -3
- package/dist/chunk-01d86gt1.js +0 -1324
- package/dist/chunk-050r7ycy.js +0 -46516
- package/dist/chunk-29rse4p1.js +0 -12203
- package/dist/chunk-32e7ya18.js +0 -642
- package/dist/chunk-4cjrg98a.js +0 -597
- package/dist/chunk-50jpda9q.js +0 -371
- package/dist/chunk-6a1t7fnq.js +0 -12121
- package/dist/chunk-728jvrr0.js +0 -1701
- package/dist/chunk-7m60qnc8.js +0 -1762
- package/dist/chunk-aa2dkn7b.js +0 -205
- package/dist/chunk-d48vtdj4.js +0 -433
- package/dist/chunk-f55nkpvb.js +0 -8
- package/dist/chunk-fgk8cqew.js +0 -152
- package/dist/chunk-he9a874b.js +0 -769
- package/dist/chunk-hg7rhrgd.js +0 -7274
- package/dist/chunk-k2yyatfw.js +0 -10
- package/dist/chunk-k4px0bnv.js +0 -23
- package/dist/chunk-nsgqsmrh.js +0 -1779
- package/dist/chunk-qr803fye.js +0 -2122
- package/dist/chunk-rds0sy87.js +0 -1771
- package/dist/chunk-rxgchb08.js +0 -42033
- package/dist/chunk-ttz2ra5j.js +0 -12
- package/dist/chunk-v0bahtg2.js +0 -4
- package/dist/chunk-va2yd85b.js +0 -200
- package/dist/chunk-x9s0cqfx.js +0 -13
- package/dist/chunk-zqtpg06c.js +0 -1752
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{Th as V}from"./chunk-0ccta6z6.js";class Y{client;region;constructor(q="us-east-1"){this.region=q,this.client=new V}async describeInstances(q){let z={Action:"DescribeInstances",Version:"2016-11-15"};if(q?.InstanceIds)q.InstanceIds.forEach((J,K)=>{z[`InstanceId.${K+1}`]=J});if(q?.Filters)q.Filters.forEach((J,K)=>{z[`Filter.${K+1}.Name`]=J.Name,J.Values.forEach((L,M)=>{z[`Filter.${K+1}.Value.${M+1}`]=L})});if(q?.MaxResults)z.MaxResults=String(q.MaxResults);if(q?.NextToken)z.NextToken=q.NextToken;let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=H.DescribeInstancesResponse||H;return{Reservations:this.parseReservations(G.reservationSet?.item),NextToken:G.nextToken}}async getInstance(q){return(await this.describeInstances({InstanceIds:[q]})).Reservations?.[0]?.Instances?.[0]}async getConsoleOutput(q,z){let H={Action:"GetConsoleOutput",Version:"2016-11-15",InstanceId:q};if(z)H.Latest="true";let G=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()}),J=G.GetConsoleOutputResponse||G;return{InstanceId:J.instanceId,Output:J.output,Timestamp:J.timestamp}}async getConsoleOutputDecoded(q,z){let H=await this.getConsoleOutput(q,z?.latest);if(!H.Output)return"No console output available yet";let G=Buffer.from(H.Output,"base64").toString("utf-8");if(z?.tailLines)return G.split(`
|
|
2
|
+
`).slice(-z.tailLines).join(`
|
|
3
|
+
`);return G}async describeInstanceStatus(q){let z={Action:"DescribeInstanceStatus",Version:"2016-11-15"};if(q?.InstanceIds)q.InstanceIds.forEach((G,J)=>{z[`InstanceId.${J+1}`]=G});if(q?.IncludeAllInstances)z.IncludeAllInstances="true";if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{InstanceStatuses:this.parseArray(H.instanceStatusSet?.item).map((G)=>({InstanceId:G.instanceId,InstanceState:G.instanceState?{Code:Number.parseInt(G.instanceState.code),Name:G.instanceState.name}:void 0,InstanceStatus:G.instanceStatus?{Status:G.instanceStatus.status,Details:this.parseArray(G.instanceStatus.details?.item).map((J)=>({Name:J.name,Status:J.status}))}:void 0,SystemStatus:G.systemStatus?{Status:G.systemStatus.status,Details:this.parseArray(G.systemStatus.details?.item).map((J)=>({Name:J.name,Status:J.status}))}:void 0}))}}async startInstances(q){let z={Action:"StartInstances",Version:"2016-11-15"};q.forEach((G,J)=>{z[`InstanceId.${J+1}`]=G});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{StartingInstances:this.parseArray(H.instancesSet?.item).map((G)=>({InstanceId:G.instanceId,CurrentState:G.currentState?{Name:G.currentState.name}:void 0,PreviousState:G.previousState?{Name:G.previousState.name}:void 0}))}}async stopInstances(q,z){let H={Action:"StopInstances",Version:"2016-11-15"};if(q.forEach((J,K)=>{H[`InstanceId.${K+1}`]=J}),z)H.Force="true";let G=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()});return{StoppingInstances:this.parseArray(G.instancesSet?.item).map((J)=>({InstanceId:J.instanceId,CurrentState:J.currentState?{Name:J.currentState.name}:void 0,PreviousState:J.previousState?{Name:J.previousState.name}:void 0}))}}async rebootInstances(q){let z={Action:"RebootInstances",Version:"2016-11-15"};q.forEach((H,G)=>{z[`InstanceId.${G+1}`]=H}),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async terminateInstances(q){let z={Action:"TerminateInstances",Version:"2016-11-15"};q.forEach((G,J)=>{z[`InstanceId.${J+1}`]=G});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{TerminatingInstances:this.parseArray(H.instancesSet?.item).map((G)=>({InstanceId:G.instanceId,CurrentState:G.currentState?{Name:G.currentState.name}:void 0,PreviousState:G.previousState?{Name:G.previousState.name}:void 0}))}}async createImage(q){let z={Action:"CreateImage",Version:"2016-11-15",InstanceId:q.InstanceId,Name:q.Name};if(q.Description)z.Description=q.Description;if(q.NoReboot!==void 0)z.NoReboot=String(q.NoReboot);if(q.TagSpecifications)q.TagSpecifications.forEach((J,K)=>{z[`TagSpecification.${K+1}.ResourceType`]=J.ResourceType,J.Tags.forEach((L,M)=>{z[`TagSpecification.${K+1}.Tag.${M+1}.Key`]=L.Key,z[`TagSpecification.${K+1}.Tag.${M+1}.Value`]=L.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{ImageId:(H.CreateImageResponse||H).imageId}}async deregisterImage(q){await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({Action:"DeregisterImage",Version:"2016-11-15",ImageId:q}).toString()})}async describeVpcs(q){let z={Action:"DescribeVpcs",Version:"2016-11-15"};if(q?.VpcIds)q.VpcIds.forEach((G,J)=>{z[`VpcId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Vpcs:this.parseArray(H.vpcSet?.item).map((G)=>({VpcId:G.vpcId,CidrBlock:G.cidrBlock,State:G.state,DhcpOptionsId:G.dhcpOptionsId,InstanceTenancy:G.instanceTenancy,IsDefault:G.isDefault==="true",Tags:this.parseTags(G.tagSet?.item)}))}}async describeSubnets(q){let z={Action:"DescribeSubnets",Version:"2016-11-15"};if(q?.SubnetIds)q.SubnetIds.forEach((G,J)=>{z[`SubnetId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Subnets:this.parseArray(H.subnetSet?.item).map((G)=>({SubnetId:G.subnetId,VpcId:G.vpcId,CidrBlock:G.cidrBlock,AvailabilityZone:G.availabilityZone,AvailableIpAddressCount:Number.parseInt(G.availableIpAddressCount),State:G.state,MapPublicIpOnLaunch:G.mapPublicIpOnLaunch==="true",Tags:this.parseTags(G.tagSet?.item)}))}}async describeSecurityGroups(q){let z={Action:"DescribeSecurityGroups",Version:"2016-11-15"};if(q?.GroupIds)q.GroupIds.forEach((G,J)=>{z[`GroupId.${J+1}`]=G});if(q?.GroupNames)q.GroupNames.forEach((G,J)=>{z[`GroupName.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{SecurityGroups:this.parseArray(H.securityGroupInfo?.item).map((G)=>({GroupId:G.groupId,GroupName:G.groupName,Description:G.groupDescription,VpcId:G.vpcId,IpPermissions:this.parseIpPermissions(G.ipPermissions?.item),IpPermissionsEgress:this.parseIpPermissions(G.ipPermissionsEgress?.item),Tags:this.parseTags(G.tagSet?.item)}))}}async describeInternetGateways(q){let z={Action:"DescribeInternetGateways",Version:"2016-11-15"};if(q?.InternetGatewayIds)q.InternetGatewayIds.forEach((G,J)=>{z[`InternetGatewayId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{InternetGateways:this.parseArray(H.internetGatewaySet?.item).map((G)=>({InternetGatewayId:G.internetGatewayId,Attachments:this.parseArray(G.attachmentSet?.item).map((J)=>({VpcId:J.vpcId,State:J.state})),Tags:this.parseTags(G.tagSet?.item)}))}}async describeAddresses(q){let z={Action:"DescribeAddresses",Version:"2016-11-15"};if(q?.AllocationIds)q.AllocationIds.forEach((G,J)=>{z[`AllocationId.${J+1}`]=G});if(q?.PublicIps)q.PublicIps.forEach((G,J)=>{z[`PublicIp.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Addresses:this.parseArray(H.addressesSet?.item).map((G)=>({PublicIp:G.publicIp,AllocationId:G.allocationId,AssociationId:G.associationId,InstanceId:G.instanceId,NetworkInterfaceId:G.networkInterfaceId,PrivateIpAddress:G.privateIpAddress,Domain:G.domain,Tags:this.parseTags(G.tagSet?.item)}))}}async allocateAddress(q){let z={Action:"AllocateAddress",Version:"2016-11-15"};if(q?.Domain)z.Domain=q.Domain;if(q?.TagSpecifications)q.TagSpecifications.forEach((G,J)=>{z[`TagSpecification.${J+1}.ResourceType`]=G.ResourceType,G.Tags.forEach((K,L)=>{z[`TagSpecification.${J+1}.Tag.${L+1}.Key`]=K.Key,z[`TagSpecification.${J+1}.Tag.${L+1}.Value`]=K.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{AllocationId:H.allocationId,PublicIp:H.publicIp,Domain:H.domain}}async associateAddress(q){let z={Action:"AssociateAddress",Version:"2016-11-15"};if(q.AllocationId)z.AllocationId=q.AllocationId;if(q.PublicIp)z.PublicIp=q.PublicIp;if(q.InstanceId)z.InstanceId=q.InstanceId;if(q.NetworkInterfaceId)z.NetworkInterfaceId=q.NetworkInterfaceId;if(q.PrivateIpAddress)z.PrivateIpAddress=q.PrivateIpAddress;if(q.AllowReassociation)z.AllowReassociation="true";return{AssociationId:(await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})).associationId}}async createTags(q){let z={Action:"CreateTags",Version:"2016-11-15"};q.Resources.forEach((H,G)=>{z[`ResourceId.${G+1}`]=H}),q.Tags.forEach((H,G)=>{z[`Tag.${G+1}.Key`]=H.Key,z[`Tag.${G+1}.Value`]=H.Value}),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async waitForInstanceState(q,z,H){let G=H?.maxWaitMs||300000,J=H?.pollIntervalMs||5000,K=Date.now();while(Date.now()-K<G){let L;try{L=await this.getInstance(q)}catch{L=void 0}if(L?.State?.Name===z)return L;await new Promise((M)=>setTimeout(M,J))}return}async createVpc(q){let z={Action:"CreateVpc",Version:"2016-11-15",CidrBlock:q.CidrBlock};if(q.InstanceTenancy)z.InstanceTenancy=q.InstanceTenancy;if(q.TagSpecifications)q.TagSpecifications.forEach((K,L)=>{z[`TagSpecification.${L+1}.ResourceType`]=K.ResourceType,K.Tags.forEach((M,O)=>{z[`TagSpecification.${L+1}.Tag.${O+1}.Key`]=M.Key,z[`TagSpecification.${L+1}.Tag.${O+1}.Value`]=M.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),J=(H.CreateVpcResponse||H).vpc;return{Vpc:J?{VpcId:J.vpcId,CidrBlock:J.cidrBlock,State:J.state,DhcpOptionsId:J.dhcpOptionsId,InstanceTenancy:J.instanceTenancy,IsDefault:J.isDefault==="true",Tags:this.parseTags(J.tagSet?.item)}:void 0}}async createSubnet(q){let z={Action:"CreateSubnet",Version:"2016-11-15",VpcId:q.VpcId,CidrBlock:q.CidrBlock};if(q.AvailabilityZone)z.AvailabilityZone=q.AvailabilityZone;if(q.TagSpecifications)q.TagSpecifications.forEach((K,L)=>{z[`TagSpecification.${L+1}.ResourceType`]=K.ResourceType,K.Tags.forEach((M,O)=>{z[`TagSpecification.${L+1}.Tag.${O+1}.Key`]=M.Key,z[`TagSpecification.${L+1}.Tag.${O+1}.Value`]=M.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),J=(H.CreateSubnetResponse||H).subnet;return{Subnet:J?{SubnetId:J.subnetId,VpcId:J.vpcId,CidrBlock:J.cidrBlock,AvailabilityZone:J.availabilityZone,AvailableIpAddressCount:J.availableIpAddressCount?Number.parseInt(J.availableIpAddressCount):void 0,State:J.state,MapPublicIpOnLaunch:J.mapPublicIpOnLaunch==="true",Tags:this.parseTags(J.tagSet?.item)}:void 0}}async modifySubnetAttribute(q){let z={Action:"ModifySubnetAttribute",Version:"2016-11-15",SubnetId:q.SubnetId};if(q.MapPublicIpOnLaunch!==void 0)z["MapPublicIpOnLaunch.Value"]=String(q.MapPublicIpOnLaunch.Value);await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async createSecurityGroup(q){let z={Action:"CreateSecurityGroup",Version:"2016-11-15",GroupName:q.GroupName,GroupDescription:q.Description};if(q.VpcId)z.VpcId=q.VpcId;if(q.TagSpecifications)q.TagSpecifications.forEach((J,K)=>{z[`TagSpecification.${K+1}.ResourceType`]=J.ResourceType,J.Tags.forEach((L,M)=>{z[`TagSpecification.${K+1}.Tag.${M+1}.Key`]=L.Key,z[`TagSpecification.${K+1}.Tag.${M+1}.Value`]=L.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{GroupId:(H.CreateSecurityGroupResponse||H).groupId}}async authorizeSecurityGroupIngress(q){let z={Action:"AuthorizeSecurityGroupIngress",Version:"2016-11-15",GroupId:q.GroupId};this.encodeIpPermissions(z,q.IpPermissions),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async authorizeSecurityGroupEgress(q){let z={Action:"AuthorizeSecurityGroupEgress",Version:"2016-11-15",GroupId:q.GroupId};this.encodeIpPermissions(z,q.IpPermissions),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async describeRouteTables(q){let z={Action:"DescribeRouteTables",Version:"2016-11-15"};if(q?.RouteTableIds)q.RouteTableIds.forEach((J,K)=>{z[`RouteTableId.${K+1}`]=J});if(q?.Filters)q.Filters.forEach((J,K)=>{z[`Filter.${K+1}.Name`]=J.Name,J.Values.forEach((L,M)=>{z[`Filter.${K+1}.Value.${M+1}`]=L})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=H.DescribeRouteTablesResponse||H;return{RouteTables:this.parseArray(G.routeTableSet?.item).map((J)=>({RouteTableId:J.routeTableId,VpcId:J.vpcId,Routes:this.parseArray(J.routeSet?.item).map((K)=>({DestinationCidrBlock:K.destinationCidrBlock,GatewayId:K.gatewayId,NatGatewayId:K.natGatewayId,State:K.state})),Associations:this.parseArray(J.associationSet?.item).map((K)=>({RouteTableAssociationId:K.routeTableAssociationId,SubnetId:K.subnetId,Main:K.main==="true"||K.main===!0})),Tags:this.parseTags(J.tagSet?.item)}))}}async deleteVpc(q){let z={Action:"DeleteVpc",Version:"2016-11-15",VpcId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async deleteSubnet(q){let z={Action:"DeleteSubnet",Version:"2016-11-15",SubnetId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async deleteSecurityGroup(q){await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({Action:"DeleteSecurityGroup",Version:"2016-11-15",GroupId:q}).toString()})}async describeNetworkInterfaces(q){let z={Action:"DescribeNetworkInterfaces",Version:"2016-11-15"};if(q?.NetworkInterfaceIds)q.NetworkInterfaceIds.forEach((J,K)=>{z[`NetworkInterfaceId.${K+1}`]=J});if(q?.Filters)q.Filters.forEach((J,K)=>{z[`Filter.${K+1}.Name`]=J.Name,J.Values.forEach((L,M)=>{z[`Filter.${K+1}.Value.${M+1}`]=L})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=H.DescribeNetworkInterfacesResponse||H;return{NetworkInterfaces:this.parseArray(G.networkInterfaceSet?.item).map((J)=>({NetworkInterfaceId:J.networkInterfaceId,SubnetId:J.subnetId,VpcId:J.vpcId,Status:J.status,Attachment:J.attachment?{AttachmentId:J.attachment.attachmentId,InstanceId:J.attachment.instanceId,Status:J.attachment.status}:void 0}))}}async detachNetworkInterface(q,z){let H={Action:"DetachNetworkInterface",Version:"2016-11-15",AttachmentId:q};if(z)H.Force="true";await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()})}async deleteNetworkInterface(q){let z={Action:"DeleteNetworkInterface",Version:"2016-11-15",NetworkInterfaceId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async describeRegions(){let q={Action:"DescribeRegions",Version:"2016-11-15"},z=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(q).toString()}),H=z.DescribeRegionsResponse||z;return{Regions:this.parseArray(H.regionInfo?.item).map((G)=>({RegionName:G.regionName,Endpoint:G.regionEndpoint}))}}async runInstances(q){let z={Action:"RunInstances",Version:"2016-11-15",ImageId:q.ImageId,InstanceType:q.InstanceType,MinCount:String(q.MinCount),MaxCount:String(q.MaxCount)};if(q.SecurityGroupIds)q.SecurityGroupIds.forEach((J,K)=>{z[`SecurityGroupId.${K+1}`]=J});if(q.SubnetId)z.SubnetId=q.SubnetId;if(q.UserData)z.UserData=q.UserData;if(q.IamInstanceProfile){if(q.IamInstanceProfile.Name)z["IamInstanceProfile.Name"]=q.IamInstanceProfile.Name;if(q.IamInstanceProfile.Arn)z["IamInstanceProfile.Arn"]=q.IamInstanceProfile.Arn}if(q.TagSpecifications)q.TagSpecifications.forEach((J,K)=>{z[`TagSpecification.${K+1}.ResourceType`]=J.ResourceType,J.Tags.forEach((L,M)=>{z[`TagSpecification.${K+1}.Tag.${M+1}.Key`]=L.Key,z[`TagSpecification.${K+1}.Tag.${M+1}.Value`]=L.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=H.RunInstancesResponse||H;return{Instances:this.parseInstances(G.instancesSet?.item||G.instancesSet)}}encodeIpPermissions(q,z){z.forEach((H,G)=>{let J=`IpPermissions.${G+1}`;if(H.IpProtocol!==void 0)q[`${J}.IpProtocol`]=H.IpProtocol;if(H.FromPort!==void 0)q[`${J}.FromPort`]=String(H.FromPort);if(H.ToPort!==void 0)q[`${J}.ToPort`]=String(H.ToPort);if(H.IpRanges)H.IpRanges.forEach((K,L)=>{if(K.CidrIp)q[`${J}.IpRanges.${L+1}.CidrIp`]=K.CidrIp;if(K.Description)q[`${J}.IpRanges.${L+1}.Description`]=K.Description});if(H.Ipv6Ranges)H.Ipv6Ranges.forEach((K,L)=>{if(K.CidrIpv6)q[`${J}.Ipv6Ranges.${L+1}.CidrIpv6`]=K.CidrIpv6;if(K.Description)q[`${J}.Ipv6Ranges.${L+1}.Description`]=K.Description});if(H.UserIdGroupPairs)H.UserIdGroupPairs.forEach((K,L)=>{if(K.GroupId)q[`${J}.Groups.${L+1}.GroupId`]=K.GroupId;if(K.UserId)q[`${J}.Groups.${L+1}.UserId`]=K.UserId;if(K.Description)q[`${J}.Groups.${L+1}.Description`]=K.Description})})}parseArray(q){if(!q)return[];return Array.isArray(q)?q:[q]}parseFirstIpv6Address(q){for(let z of this.parseArray(q))for(let H of this.parseArray(z?.ipv6AddressesSet?.item))if(H?.ipv6Address)return H.ipv6Address;return}parseTags(q){return this.parseArray(q).map((z)=>({Key:z.key,Value:z.value}))}parseReservations(q){return this.parseArray(q).map((z)=>({ReservationId:z.reservationId,Instances:this.parseInstances(z.instancesSet?.item||z.instancesSet)}))}parseInstances(q){return this.parseArray(q).map((z)=>({InstanceId:z.instanceId,ImageId:z.imageId,InstanceType:z.instanceType,State:z.instanceState?{Code:Number.parseInt(z.instanceState.code),Name:z.instanceState.name}:void 0,PrivateIpAddress:z.privateIpAddress,PublicIpAddress:z.ipAddress,Ipv6Address:this.parseFirstIpv6Address(z.networkInterfaceSet?.item),SubnetId:z.subnetId,VpcId:z.vpcId,SecurityGroups:this.parseArray(z.groupSet?.item).map((H)=>({GroupId:H.groupId,GroupName:H.groupName})),Tags:this.parseTags(z.tagSet?.item),LaunchTime:z.launchTime,Placement:z.placement?{AvailabilityZone:z.placement.availabilityZone,Tenancy:z.placement.tenancy}:void 0,Architecture:z.architecture,RootDeviceType:z.rootDeviceType,RootDeviceName:z.rootDeviceName,BlockDeviceMappings:this.parseArray(z.blockDeviceMapping?.item).map((H)=>({DeviceName:H.deviceName,Ebs:H.ebs?{VolumeId:H.ebs.volumeId,Status:H.ebs.status,AttachTime:H.ebs.attachTime,DeleteOnTermination:H.ebs.deleteOnTermination==="true"}:void 0})),IamInstanceProfile:z.iamInstanceProfile?{Arn:z.iamInstanceProfile.arn,Id:z.iamInstanceProfile.id}:void 0}))}parseIpPermissions(q){return this.parseArray(q).map((z)=>({IpProtocol:z.ipProtocol,FromPort:z.fromPort?Number.parseInt(z.fromPort):void 0,ToPort:z.toPort?Number.parseInt(z.toPort):void 0,IpRanges:this.parseArray(z.ipRanges?.item).map((H)=>({CidrIp:H.cidrIp,Description:H.description})),Ipv6Ranges:this.parseArray(z.ipv6Ranges?.item).map((H)=>({CidrIpv6:H.cidrIpv6,Description:H.description})),UserIdGroupPairs:this.parseArray(z.groups?.item).map((H)=>({GroupId:H.groupId,UserId:H.userId,Description:H.description}))}))}}class Z{client;region;constructor(q="us-east-1",z){this.region=q,this.client=new V}async putParameter(q){let z={Name:q.Name,Value:q.Value};if(q.Type)z.Type=q.Type;if(q.Description)z.Description=q.Description;if(q.KeyId)z.KeyId=q.KeyId;if(q.Overwrite!==void 0)z.Overwrite=q.Overwrite;if(q.AllowedPattern)z.AllowedPattern=q.AllowedPattern;if(q.Tags&&q.Tags.length>0)z.Tags=q.Tags;if(q.Tier)z.Tier=q.Tier;if(q.DataType)z.DataType=q.DataType;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.PutParameter","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{Version:H.Version,Tier:H.Tier}}async getParameter(q){let z={Name:q.Name};if(q.WithDecryption!==void 0)z.WithDecryption=q.WithDecryption;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.GetParameter","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{Parameter:H.Parameter?this.parseParameter(H.Parameter):void 0}}async getParameters(q){let z={Names:q.Names};if(q.WithDecryption!==void 0)z.WithDecryption=q.WithDecryption;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.GetParameters","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{Parameters:H.Parameters?.map((G)=>this.parseParameter(G)),InvalidParameters:H.InvalidParameters}}async getParametersByPath(q){let z={Path:q.Path};if(q.Recursive!==void 0)z.Recursive=q.Recursive;if(q.WithDecryption!==void 0)z.WithDecryption=q.WithDecryption;if(q.MaxResults)z.MaxResults=q.MaxResults;if(q.NextToken)z.NextToken=q.NextToken;if(q.ParameterFilters&&q.ParameterFilters.length>0)z.ParameterFilters=q.ParameterFilters;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.GetParametersByPath","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{Parameters:H.Parameters?.map((G)=>this.parseParameter(G)),NextToken:H.NextToken}}async deleteParameter(q){let z={Name:q.Name};await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.DeleteParameter","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)})}async deleteParameters(q){let z={Names:q},H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.DeleteParameters","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{DeletedParameters:H.DeletedParameters,InvalidParameters:H.InvalidParameters}}async describeParameters(q){let z={};if(q?.Filters&&q.Filters.length>0)z.Filters=q.Filters;if(q?.ParameterFilters&&q.ParameterFilters.length>0)z.ParameterFilters=q.ParameterFilters;if(q?.MaxResults)z.MaxResults=q.MaxResults;if(q?.NextToken)z.NextToken=q.NextToken;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.DescribeParameters","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{Parameters:H.Parameters?.map((G)=>this.parseParameter(G)),NextToken:H.NextToken}}async getParameterHistory(q){let z={Name:q.Name};if(q.WithDecryption!==void 0)z.WithDecryption=q.WithDecryption;if(q.MaxResults)z.MaxResults=q.MaxResults;if(q.NextToken)z.NextToken=q.NextToken;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.GetParameterHistory","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{Parameters:H.Parameters?.map((G)=>({Name:G.Name,Type:G.Type,KeyId:G.KeyId,LastModifiedDate:G.LastModifiedDate,LastModifiedUser:G.LastModifiedUser,Description:G.Description,Value:G.Value,Version:G.Version,Labels:G.Labels,Tier:G.Tier})),NextToken:H.NextToken}}async labelParameterVersion(q){let z={Name:q.Name,Labels:q.Labels};if(q.ParameterVersion!==void 0)z.ParameterVersion=q.ParameterVersion;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.LabelParameterVersion","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{InvalidLabels:H.InvalidLabels,ParameterVersion:H.ParameterVersion}}async addTagsToResource(q){let z={ResourceType:q.ResourceType,ResourceId:q.ResourceId,Tags:q.Tags};await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.AddTagsToResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)})}async removeTagsFromResource(q){let z={ResourceType:q.ResourceType,ResourceId:q.ResourceId,TagKeys:q.TagKeys};await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.RemoveTagsFromResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)})}async listTagsForResource(q){let z={ResourceType:q.ResourceType,ResourceId:q.ResourceId};return{TagList:(await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.ListTagsForResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)})).TagList}}async setString(q,z,H){return this.putParameter({Name:q,Value:z,Type:"String",Description:H?.description,Overwrite:H?.overwrite??!0,Tags:H?.tags})}async setSecureString(q,z,H){return this.putParameter({Name:q,Value:z,Type:"SecureString",Description:H?.description,Overwrite:H?.overwrite??!0,KeyId:H?.kmsKeyId,Tags:H?.tags})}async getValue(q){return(await this.getParameter({Name:q,WithDecryption:!0})).Parameter?.Value}async getAllByPath(q,z=!0){let H=[],G;do{let J=await this.getParametersByPath({Path:q,Recursive:z,WithDecryption:!0,NextToken:G});if(J.Parameters)H.push(...J.Parameters);G=J.NextToken}while(G);return H}parseParameter(q){return{Name:q.Name,Type:q.Type,Value:q.Value,Version:q.Version,LastModifiedDate:q.LastModifiedDate,ARN:q.ARN,DataType:q.DataType,Description:q.Description,AllowedPattern:q.AllowedPattern,KeyId:q.KeyId,Tier:q.Tier}}async sendCommand(q){if(!q.InstanceIds&&!q.Targets)throw Error("SendCommand requires either InstanceIds or Targets");let z={DocumentName:q.DocumentName};if(q.InstanceIds)z.InstanceIds=q.InstanceIds;if(q.Targets)z.Targets=q.Targets;if(q.Parameters)z.Parameters=q.Parameters;if(q.TimeoutSeconds)z.TimeoutSeconds=q.TimeoutSeconds;if(q.Comment)z.Comment=q.Comment;if(q.OutputS3BucketName)z.OutputS3BucketName=q.OutputS3BucketName;if(q.OutputS3KeyPrefix)z.OutputS3KeyPrefix=q.OutputS3KeyPrefix;let H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.SendCommand","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{CommandId:H.Command?.CommandId,Status:H.Command?.Status,StatusDetails:H.Command?.StatusDetails}}async getCommandInvocation(q){let z={CommandId:q.CommandId,InstanceId:q.InstanceId},H=await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.GetCommandInvocation","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)});return{Status:H.Status,StatusDetails:H.StatusDetails,StandardOutputContent:H.StandardOutputContent,StandardErrorContent:H.StandardErrorContent,ResponseCode:H.ResponseCode}}async runShellCommand(q,z,H){let G=await this.sendCommand({InstanceIds:[q],DocumentName:"AWS-RunShellScript",Parameters:{commands:z},TimeoutSeconds:H?.timeoutSeconds||600});if(!G.CommandId)return{success:!1,error:"Failed to send command"};if(H?.waitForCompletion===!1)return{success:!0,status:"Pending"};let J=H?.pollIntervalMs||2000,K=H?.maxWaitMs||300000,L=Date.now();while(Date.now()-L<K){await new Promise((M)=>setTimeout(M,J));try{let M=await this.getCommandInvocation({CommandId:G.CommandId,InstanceId:q});if(M.Status==="Success")return{success:!0,output:M.StandardOutputContent,error:M.StandardErrorContent,status:M.Status};if(M.Status==="Failed"||M.Status==="Cancelled"||M.Status==="TimedOut")return{success:!1,output:M.StandardOutputContent,error:M.StandardErrorContent||M.StatusDetails,status:M.Status}}catch(M){if(!M.message?.includes("InvocationDoesNotExist"))return{success:!1,error:M.message}}}return{success:!1,error:"Command timed out waiting for completion"}}async listCommandInvocations(q){let z={CommandId:q.CommandId};if(q.Details)z.Details=!0;return((await this.client.request({service:"ssm",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonSSM.ListCommandInvocations","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(z)})).CommandInvocations||[]).map((J)=>({InstanceId:J.InstanceId,Status:J.Status,StatusDetails:J.StatusDetails,StandardOutputContent:J.CommandPlugins?.[0]?.Output,StandardErrorContent:J.CommandPlugins?.[0]?.StandardErrorUrl}))}async sendCommandByTags(q){let z=Object.entries(q.tags).map(([O,U])=>({Key:`tag:${O}`,Values:[U]})),H=await this.sendCommand({Targets:z,DocumentName:"AWS-RunShellScript",Parameters:{commands:q.commands},TimeoutSeconds:q.timeoutSeconds||600,Comment:q.comment});if(!H.CommandId)return{success:!1,instanceCount:0,perInstance:[],error:"Failed to send command"};let G=q.pollIntervalMs||3000,J=q.maxWaitMs||600000,K=Date.now(),L=new Set(["Success","Failed","Cancelled","TimedOut"]),M=[];while(Date.now()-K<J){await new Promise((O)=>setTimeout(O,G));try{if(M=await this.listCommandInvocations({CommandId:H.CommandId,Details:!0}),M.length===0)continue;if(M.every((U)=>L.has(U.Status||""))){let U=M.map((Q)=>({instanceId:Q.InstanceId,status:Q.Status||"Unknown",output:Q.StandardOutputContent,error:Q.StandardErrorContent||Q.StatusDetails})),X=M.every((Q)=>Q.Status==="Success");return{success:X,instanceCount:M.length,perInstance:U,error:X?void 0:"One or more instances reported a non-success status"}}}catch(O){if(!O.message?.includes("InvocationDoesNotExist"))return{success:!1,instanceCount:0,perInstance:[],error:O.message}}}return{success:!1,instanceCount:M.length,perInstance:M.map((O)=>({instanceId:O.InstanceId,status:O.Status||"Unknown"})),error:"Command timed out waiting for all instances to complete"}}}
|
|
4
|
+
export{Y as Nh,Z as Oh};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The minimum a driver has to produce for a server to be attributed.
|
|
3
|
+
*
|
|
4
|
+
* Structural rather than a provider type so a Hetzner server satisfies it as-is
|
|
5
|
+
* and another driver can satisfy it without importing anything.
|
|
6
|
+
*/
|
|
7
|
+
export interface ReachableServer {
|
|
8
|
+
name: string;
|
|
9
|
+
labels?: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export interface CredentialReach {
|
|
12
|
+
/** Every server the credential enumerated. */
|
|
13
|
+
total: number;
|
|
14
|
+
/** Servers belonging to the project being attached TO. Expected reach. */
|
|
15
|
+
owner: string[];
|
|
16
|
+
/** Servers belonging to the attaching project itself, if it has any. */
|
|
17
|
+
self: string[];
|
|
18
|
+
/** Servers owned by unrelated ts-cloud projects, keyed by project slug. */
|
|
19
|
+
others: Map<string, string[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Servers carrying no ts-cloud project label.
|
|
22
|
+
*
|
|
23
|
+
* Counted separately because they are the reach most likely to surprise: not
|
|
24
|
+
* managed by ts-cloud at all, and so not visible in any ts-cloud config, yet
|
|
25
|
+
* just as writable by the token.
|
|
26
|
+
*/
|
|
27
|
+
unmanaged: string[];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Attribute every server the credential can see to a project.
|
|
31
|
+
*
|
|
32
|
+
* `ownerSlug` is what `cloud.attachTo` names; `selfSlug` is the deploying
|
|
33
|
+
* project. Splitting those two out of `others` is the point: reach over the owner
|
|
34
|
+
* is the reach being asked for, reach over anything else is the reach nobody
|
|
35
|
+
* asked for, and only the second number is an argument against attaching.
|
|
36
|
+
*/
|
|
37
|
+
export declare function describeCredentialReach(servers: ReachableServer[], options: {
|
|
38
|
+
ownerSlug: string;
|
|
39
|
+
selfSlug?: string;
|
|
40
|
+
}): CredentialReach;
|
|
41
|
+
/** Servers the credential reaches that neither project being joined owns. */
|
|
42
|
+
export declare function unrelatedReachCount(reach: CredentialReach): number;
|
|
43
|
+
/**
|
|
44
|
+
* The credential radius as plan lines, ready to print.
|
|
45
|
+
*
|
|
46
|
+
* Returns lines rather than printing so the caller owns the output stream and
|
|
47
|
+
* this stays testable. Sorted, because a plan that reorders itself between runs
|
|
48
|
+
* is a plan nobody diffs.
|
|
49
|
+
*
|
|
50
|
+
* When the reach is exactly the owner's box and this project's own, there is
|
|
51
|
+
* nothing to warn about and the summary says so in one line - a warning that
|
|
52
|
+
* fires every time is a warning that gets skipped.
|
|
53
|
+
*/
|
|
54
|
+
export declare function formatCredentialReach(reach: CredentialReach, options: {
|
|
55
|
+
ownerSlug: string;
|
|
56
|
+
selfSlug?: string;
|
|
57
|
+
}): string[];
|
package/dist/deploy/index.js
CHANGED
|
@@ -1,168 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildAndPushContainerImage,
|
|
3
|
-
buildFunctionEnv,
|
|
4
|
-
buildServerTopology,
|
|
5
|
-
buildServerlessTopology,
|
|
6
|
-
buildTopology,
|
|
7
|
-
collectEgressMetrics,
|
|
8
|
-
createContainerImageDependencies,
|
|
9
|
-
createExistingStaticFullStackDependencies,
|
|
10
|
-
createStaticApiOriginDependencies,
|
|
11
|
-
dashboardActions,
|
|
12
|
-
dashboardPageRoutes,
|
|
13
|
-
deployExistingStaticFullStack,
|
|
14
|
-
deployServerlessApp,
|
|
15
|
-
deploySite,
|
|
16
|
-
deployStaticApiOrigin,
|
|
17
|
-
egressReportMetrics,
|
|
18
|
-
ensureDashboardActor,
|
|
19
|
-
estimateExistingStaticFullStackMonthlyCost,
|
|
20
|
-
estimateStaticApiOriginMonthlyCost,
|
|
21
|
-
fetchEgressReport,
|
|
22
|
-
generateExistingStaticFullStackTemplate,
|
|
23
|
-
hashContainerContext,
|
|
24
|
-
infraEnvFromOutputs,
|
|
25
|
-
initializeDashboardControlPlane,
|
|
26
|
-
redeployServerlessApp,
|
|
27
|
-
resolveDashboardAction,
|
|
28
|
-
resolveDashboardData,
|
|
29
|
-
resolveLegacyDashboardRoute,
|
|
30
|
-
rollbackServerlessApp,
|
|
31
|
-
routesForDashboard,
|
|
32
|
-
runRemoteCommand,
|
|
33
|
-
sanitizeCloudConfig,
|
|
34
|
-
setMaintenance,
|
|
35
|
-
startLocalDashboardServer,
|
|
36
|
-
synchronizeDashboardUsers,
|
|
37
|
-
trackDashboardOperation,
|
|
38
|
-
verifyStaticApiOrigin
|
|
39
|
-
} from "../chunk-rxgchb08.js";
|
|
40
|
-
import {
|
|
41
|
-
deleteStaticSite,
|
|
42
|
-
deployStaticSite,
|
|
43
|
-
deployStaticSiteFull,
|
|
44
|
-
deployStaticSiteWithExternalDns,
|
|
45
|
-
deployStaticSiteWithExternalDnsFull,
|
|
46
|
-
generateExternalDnsStaticSiteTemplate,
|
|
47
|
-
generateStaticSiteTemplate,
|
|
48
|
-
invalidateCache,
|
|
49
|
-
uploadStaticFiles
|
|
50
|
-
} from "../chunk-728jvrr0.js";
|
|
51
|
-
import {
|
|
52
|
-
buildAndPushServerlessImage
|
|
53
|
-
} from "../chunk-fgk8cqew.js";
|
|
54
|
-
import"../chunk-6a1t7fnq.js";
|
|
55
|
-
import"../chunk-nsgqsmrh.js";
|
|
56
|
-
import"../chunk-01d86gt1.js";
|
|
57
|
-
import"../chunk-50jpda9q.js";
|
|
58
|
-
import"../chunk-he9a874b.js";
|
|
59
|
-
import"../chunk-qr803fye.js";
|
|
60
|
-
import"../chunk-32e7ya18.js";
|
|
61
|
-
import {
|
|
62
|
-
IPV6_EXCLUDED_HOST_LABELS,
|
|
63
|
-
MANAGEMENT_DASHBOARD_SITE,
|
|
64
|
-
buildManagementDashboardArtifact,
|
|
65
|
-
collectServerDnsDomains,
|
|
66
|
-
dashboardCredentialsFile,
|
|
67
|
-
deployShipsFiles,
|
|
68
|
-
ensureManagementDashboard,
|
|
69
|
-
hasComputeConfigured,
|
|
70
|
-
hasProxyUpstream,
|
|
71
|
-
hostAcceptsIpv6,
|
|
72
|
-
isPhpSite,
|
|
73
|
-
normalizePublicIpv6,
|
|
74
|
-
reconcileAddressRecords,
|
|
75
|
-
removeStaleServerAddressRecords,
|
|
76
|
-
resolveDashboardAuth,
|
|
77
|
-
resolveProxyUpstreams,
|
|
78
|
-
resolveSiteDeployTarget,
|
|
79
|
-
resolveSiteKind,
|
|
80
|
-
resolveUiSource,
|
|
81
|
-
shipsARelease,
|
|
82
|
-
shipsToBucket,
|
|
83
|
-
siteInstallBase,
|
|
84
|
-
validateDeploymentConfig,
|
|
85
|
-
verifyAddressRecord
|
|
86
|
-
} from "../chunk-hg7rhrgd.js";
|
|
87
|
-
import"../chunk-7m60qnc8.js";
|
|
88
|
-
import"../chunk-4cjrg98a.js";
|
|
89
|
-
import"../chunk-rds0sy87.js";
|
|
90
|
-
import"../chunk-zqtpg06c.js";
|
|
91
|
-
import"../chunk-29rse4p1.js";
|
|
92
|
-
import"../chunk-va2yd85b.js";
|
|
93
|
-
import"../chunk-aa2dkn7b.js";
|
|
94
|
-
import"../chunk-050r7ycy.js";
|
|
95
|
-
import"../chunk-v0bahtg2.js";
|
|
96
|
-
export {
|
|
97
|
-
verifyStaticApiOrigin,
|
|
98
|
-
verifyAddressRecord,
|
|
99
|
-
validateDeploymentConfig,
|
|
100
|
-
uploadStaticFiles,
|
|
101
|
-
trackDashboardOperation,
|
|
102
|
-
synchronizeDashboardUsers,
|
|
103
|
-
startLocalDashboardServer,
|
|
104
|
-
siteInstallBase,
|
|
105
|
-
shipsToBucket,
|
|
106
|
-
shipsARelease,
|
|
107
|
-
setMaintenance,
|
|
108
|
-
sanitizeCloudConfig,
|
|
109
|
-
runRemoteCommand,
|
|
110
|
-
routesForDashboard,
|
|
111
|
-
rollbackServerlessApp,
|
|
112
|
-
resolveUiSource,
|
|
113
|
-
resolveSiteKind,
|
|
114
|
-
resolveSiteDeployTarget,
|
|
115
|
-
resolveProxyUpstreams,
|
|
116
|
-
resolveLegacyDashboardRoute,
|
|
117
|
-
resolveDashboardData,
|
|
118
|
-
resolveDashboardAuth,
|
|
119
|
-
resolveDashboardAction,
|
|
120
|
-
removeStaleServerAddressRecords,
|
|
121
|
-
redeployServerlessApp,
|
|
122
|
-
reconcileAddressRecords,
|
|
123
|
-
normalizePublicIpv6,
|
|
124
|
-
isPhpSite,
|
|
125
|
-
invalidateCache,
|
|
126
|
-
initializeDashboardControlPlane,
|
|
127
|
-
infraEnvFromOutputs,
|
|
128
|
-
hostAcceptsIpv6,
|
|
129
|
-
hashContainerContext,
|
|
130
|
-
hasProxyUpstream,
|
|
131
|
-
hasComputeConfigured,
|
|
132
|
-
generateStaticSiteTemplate,
|
|
133
|
-
generateExternalDnsStaticSiteTemplate,
|
|
134
|
-
generateExistingStaticFullStackTemplate,
|
|
135
|
-
fetchEgressReport,
|
|
136
|
-
estimateStaticApiOriginMonthlyCost,
|
|
137
|
-
estimateExistingStaticFullStackMonthlyCost,
|
|
138
|
-
ensureManagementDashboard,
|
|
139
|
-
ensureDashboardActor,
|
|
140
|
-
egressReportMetrics,
|
|
141
|
-
deployStaticSiteWithExternalDnsFull,
|
|
142
|
-
deployStaticSiteWithExternalDns,
|
|
143
|
-
deployStaticSiteFull,
|
|
144
|
-
deployStaticSite,
|
|
145
|
-
deployStaticApiOrigin,
|
|
146
|
-
deploySite,
|
|
147
|
-
deployShipsFiles,
|
|
148
|
-
deployServerlessApp,
|
|
149
|
-
deployExistingStaticFullStack,
|
|
150
|
-
deleteStaticSite,
|
|
151
|
-
dashboardPageRoutes,
|
|
152
|
-
dashboardCredentialsFile,
|
|
153
|
-
dashboardActions,
|
|
154
|
-
createStaticApiOriginDependencies,
|
|
155
|
-
createExistingStaticFullStackDependencies,
|
|
156
|
-
createContainerImageDependencies,
|
|
157
|
-
collectServerDnsDomains,
|
|
158
|
-
collectEgressMetrics,
|
|
159
|
-
buildTopology,
|
|
160
|
-
buildServerlessTopology,
|
|
161
|
-
buildServerTopology,
|
|
162
|
-
buildManagementDashboardArtifact,
|
|
163
|
-
buildFunctionEnv,
|
|
164
|
-
buildAndPushServerlessImage,
|
|
165
|
-
buildAndPushContainerImage,
|
|
166
|
-
MANAGEMENT_DASHBOARD_SITE,
|
|
167
|
-
IPV6_EXCLUDED_HOST_LABELS
|
|
168
|
-
};
|
|
1
|
+
import{Ac as Z,Bc as $,Cc as aa,Dc as ba,Ec as ca,Fc as da,Gc as ea,Hc as fa,Ic as ga,Jc as ha,Kc as ia,Lc as ja,Mc as ka,Nc as la,Oc as ma,ic as y,jc as z,kc as A,lc as B,mc as C,nc as D,oc as E,od as na,pc as O,pd as oa,qc as P,qd as pa,rc as Q,rd as qa,sc as R,tc as S,uc as T,vc as U,wc as V,xc as W,yc as X,zc as Y}from"../chunk-1egjn203.js";import{Ad as N,sd as F,td as G,ud as H,vd as I,wd as J,xd as K,yd as L,zd as M}from"../chunk-v0p3hpc3.js";import{Id as _}from"../chunk-2wx29qga.js";import"../chunk-8ea5022g.js";import"../chunk-hg3c48cp.js";import"../chunk-sdqa9ghv.js";import"../chunk-bggt4n6e.js";import"../chunk-m5azeva3.js";import"../chunk-8xqn3c0w.js";import"../chunk-wdzjbecg.js";import{Ah as u,Bh as v,Ch as w,Dh as x,Qf as a,Rf as b,Sf as c,Tf as d,Uf as e,Vf as f,Wf as g,bg as h,cg as i,dg as j,eg as k,fg as l,gg as m,hg as n,ig as o,jg as p,kg as q,lg as r,yh as s,zh as t}from"../chunk-xrebj679.js";import"../chunk-y21zk0pn.js";import"../chunk-b4esxhmw.js";import"../chunk-r3qf56b3.js";import"../chunk-0ccta6z6.js";import"../chunk-gahsdmxf.js";import"../chunk-cwkg37rs.js";import"../chunk-b8e5wzwn.js";import"../chunk-dskvqt67.js";import"../chunk-xt3s24vr.js";export{R as verifyStaticApiOrigin,g as verifyAddressRecord,o as validateDeploymentConfig,K as uploadStaticFiles,B as trackDashboardOperation,A as synchronizeDashboardUsers,qa as startLocalDashboardServer,h as siteInstallBase,q as shipsToBucket,p as shipsARelease,ea as setMaintenance,na as sanitizeCloudConfig,fa as runRemoteCommand,E as routesForDashboard,da as rollbackServerlessApp,v as resolveUiSource,m as resolveSiteKind,l as resolveSiteDeployTarget,j as resolveProxyUpstreams,D as resolveLegacyDashboardRoute,ja as resolveDashboardData,u as resolveDashboardAuth,pa as resolveDashboardAction,b as removeStaleServerAddressRecords,ca as redeployServerlessApp,f as reconcileAddressRecords,c as normalizePublicIpv6,i as isPhpSite,L as invalidateCache,z as initializeDashboardControlPlane,$ as infraEnvFromOutputs,e as hostAcceptsIpv6,X as hashContainerContext,k as hasProxyUpstream,n as hasComputeConfigured,I as generateStaticSiteTemplate,F as generateExternalDnsStaticSiteTemplate,U as generateExistingStaticFullStackTemplate,la as fetchEgressReport,S as estimateStaticApiOriginMonthlyCost,W as estimateExistingStaticFullStackMonthlyCost,w as ensureManagementDashboard,y as ensureDashboardActor,ka as egressReportMetrics,H as deployStaticSiteWithExternalDnsFull,G as deployStaticSiteWithExternalDns,N as deployStaticSiteFull,J as deployStaticSite,Q as deployStaticApiOrigin,O as deploySite,r as deployShipsFiles,ba as deployServerlessApp,V as deployExistingStaticFullStack,M as deleteStaticSite,C as dashboardPageRoutes,t as dashboardCredentialsFile,oa as dashboardActions,P as createStaticApiOriginDependencies,T as createExistingStaticFullStackDependencies,Y as createContainerImageDependencies,a as collectServerDnsDomains,ma as collectEgressMetrics,ia as buildTopology,ha as buildServerlessTopology,ga as buildServerTopology,x as buildManagementDashboardArtifact,aa as buildFunctionEnv,_ as buildAndPushServerlessImage,Z as buildAndPushContainerImage,s as MANAGEMENT_DASHBOARD_SITE,d as IPV6_EXCLUDED_HOST_LABELS};
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { CloudConfig } from '@ts-cloud/core';
|
|
2
|
+
/**
|
|
3
|
+
* Port ownership across the projects sharing one box.
|
|
4
|
+
*
|
|
5
|
+
* A box can host several independent projects: each one's deploy writes its own
|
|
6
|
+
* rpx registry fragment and the assembler merges them (see `RPX_SITES_DIR`).
|
|
7
|
+
* That composes cleanly for ROUTES, because routes are keyed by host. It does
|
|
8
|
+
* not compose for PORTS, because every app generated from the same template
|
|
9
|
+
* declares the same loopback ports, and `validateDeploymentConfig` only ever
|
|
10
|
+
* sees one project's `sites`.
|
|
11
|
+
*
|
|
12
|
+
* The second attach therefore passes validation, and then does something worse
|
|
13
|
+
* than failing: ts-cloud's units do not set exclusive binding, so both listeners
|
|
14
|
+
* bind and the kernel load-balances between them. Nothing errors, both services
|
|
15
|
+
* look healthy, and each domain answers with the other project's site for about
|
|
16
|
+
* half its requests. That is not hypothetical - it is what happened to
|
|
17
|
+
* predicthq.org when a storefront picked a port by reading other projects'
|
|
18
|
+
* config files rather than the box (see `assertPortsAreFree` in stacks).
|
|
19
|
+
*
|
|
20
|
+
* `assertPortsAreFree` catches this late, from the deploying box over SSH, by
|
|
21
|
+
* comparing wanted ports against live listeners. That is the better evidence and
|
|
22
|
+
* it stays the last line of defence. What it cannot do is avoid the clash: it
|
|
23
|
+
* exits and tells the operator to go pick free ports by hand. This module is the
|
|
24
|
+
* other half - deciding the ports before anything is shipped, from data a plan
|
|
25
|
+
* already has.
|
|
26
|
+
*
|
|
27
|
+
* The fix does not need new bookkeeping on the box. The fragments already record
|
|
28
|
+
* every upstream a project serves, so the host is its own port registry - it was
|
|
29
|
+
* simply never read. This module turns those fragments into a port -> owner map,
|
|
30
|
+
* finds the collisions, and allocates around them.
|
|
31
|
+
*
|
|
32
|
+
* Everything here is pure. The one thing that must touch the box, reading the
|
|
33
|
+
* fragments, is split into a script builder and a parser so both halves are
|
|
34
|
+
* testable without a server.
|
|
35
|
+
*
|
|
36
|
+
* @see https://github.com/stacksjs/ts-cloud/issues/168
|
|
37
|
+
*/
|
|
38
|
+
/**
|
|
39
|
+
* Where the rpx gateway keeps one registry fragment per project.
|
|
40
|
+
*
|
|
41
|
+
* Deliberately duplicated from `RPX_SITES_DIR` rather than imported:
|
|
42
|
+
* `rpx-gateway.ts` imports `site-target.ts`, and this module imports it too, so
|
|
43
|
+
* importing the constant from there would close a cycle. `site-ports.test.ts`
|
|
44
|
+
* asserts the two stay equal, so the duplicate cannot drift silently.
|
|
45
|
+
*/
|
|
46
|
+
export declare const HOST_SITES_DIR = "/etc/rpx/sites.d";
|
|
47
|
+
export interface SitePortRange {
|
|
48
|
+
/** Lowest port the allocator may hand out, inclusive. */
|
|
49
|
+
start: number;
|
|
50
|
+
/** Highest port the allocator may hand out, inclusive. */
|
|
51
|
+
end: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The window the allocator searches.
|
|
55
|
+
*
|
|
56
|
+
* Chosen to contain the template's own defaults (3022/3023) so that an app which
|
|
57
|
+
* has never thought about ports keeps the ports it already had whenever they are
|
|
58
|
+
* free - see {@link allocateSitePorts}, which only moves a site that actually
|
|
59
|
+
* collides.
|
|
60
|
+
*/
|
|
61
|
+
export declare const DEFAULT_SITE_PORT_RANGE: SitePortRange;
|
|
62
|
+
/**
|
|
63
|
+
* One project's registry fragment, as written by the deploy:
|
|
64
|
+
* `JSON.stringify({ slug, ...RpxGatewayConfig })`.
|
|
65
|
+
*
|
|
66
|
+
* Only the fields this module reads are declared. A fragment written by an older
|
|
67
|
+
* ts-cloud may be missing `slug`, which the writer defaults to `'app'`.
|
|
68
|
+
*/
|
|
69
|
+
export interface HostSiteFragment {
|
|
70
|
+
slug?: string;
|
|
71
|
+
proxies?: Array<{
|
|
72
|
+
from?: string | string[];
|
|
73
|
+
}>;
|
|
74
|
+
}
|
|
75
|
+
/** Port -> the slug of the project that already serves it on this box. */
|
|
76
|
+
export type PortOwners = Map<number, string>;
|
|
77
|
+
/**
|
|
78
|
+
* The port from an rpx upstream (`host:port`).
|
|
79
|
+
*
|
|
80
|
+
* Splits on the LAST colon so a bracketed IPv6 literal (`[::1]:3022`) parses as
|
|
81
|
+
* port 3022 rather than as part of the address. Returns `undefined` for anything
|
|
82
|
+
* that is not a valid TCP port, so a malformed fragment narrows the map instead
|
|
83
|
+
* of poisoning it with NaN.
|
|
84
|
+
*/
|
|
85
|
+
export declare function parseUpstreamPort(upstream: string): number | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* Every port the box already serves, mapped to the project that owns it.
|
|
88
|
+
*
|
|
89
|
+
* `ignoreSlug` must be set to the deploying project's own slug. Its fragment is
|
|
90
|
+
* already on the box from the previous deploy, so without that the second deploy
|
|
91
|
+
* of an attached app reports a conflict with itself and can never succeed.
|
|
92
|
+
*
|
|
93
|
+
* First writer wins for a given port, which keeps the result deterministic when
|
|
94
|
+
* two fragments disagree - a state that is itself the bug being reported, so the
|
|
95
|
+
* caller sees one stable owner rather than an order-dependent one.
|
|
96
|
+
*/
|
|
97
|
+
export declare function occupiedHostPorts(fragments: HostSiteFragment[], options?: {
|
|
98
|
+
ignoreSlug?: string;
|
|
99
|
+
}): PortOwners;
|
|
100
|
+
/**
|
|
101
|
+
* A shell snippet that dumps every registry fragment on the box, one
|
|
102
|
+
* base64-encoded JSON document per line.
|
|
103
|
+
*
|
|
104
|
+
* base64 rather than raw `cat`, because the fragments are pretty-printed and so
|
|
105
|
+
* span many lines; encoding makes the output unambiguously one record per line
|
|
106
|
+
* without depending on a JSON tool being installed. Only POSIX utilities plus
|
|
107
|
+
* `base64` are used, both present on the provisioned image - the same reason
|
|
108
|
+
* `resize-remote.ts` enumerates these files with plain `find`.
|
|
109
|
+
*
|
|
110
|
+
* A missing directory is not an error: a box with no fragments yet prints
|
|
111
|
+
* nothing, and {@link parseHostSiteFragments} reads that as "no co-tenants".
|
|
112
|
+
*/
|
|
113
|
+
export declare function buildHostSitePortsScript(sitesDir?: string): string;
|
|
114
|
+
/**
|
|
115
|
+
* Parse the output of {@link buildHostSitePortsScript}.
|
|
116
|
+
*
|
|
117
|
+
* A fragment that will not decode or parse is skipped rather than thrown, which
|
|
118
|
+
* matches how the box's own assembler treats a corrupt fragment: one bad file
|
|
119
|
+
* must not take the operation down. The cost is that its ports are invisible to
|
|
120
|
+
* the collision check, which is strictly better than today, where every
|
|
121
|
+
* project's ports are.
|
|
122
|
+
*/
|
|
123
|
+
export declare function parseHostSiteFragments(stdout: string): HostSiteFragment[];
|
|
124
|
+
export interface SitePortAllocation {
|
|
125
|
+
/** Site name within the deploying project's `sites`. */
|
|
126
|
+
site: string;
|
|
127
|
+
/** The port the site should bind after allocation. */
|
|
128
|
+
port: number;
|
|
129
|
+
/** What the config asked for, when it asked for anything. */
|
|
130
|
+
declared?: number;
|
|
131
|
+
/** Did the allocation have to move the site off its declared port? */
|
|
132
|
+
moved: boolean;
|
|
133
|
+
}
|
|
134
|
+
export interface SitePortAllocationResult {
|
|
135
|
+
allocations: SitePortAllocation[];
|
|
136
|
+
errors: string[];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Assign a free port to every server-app site, preferring the one it declared.
|
|
140
|
+
*
|
|
141
|
+
* The declared port is kept whenever it is free, so allocation is a no-op on a
|
|
142
|
+
* box with no co-tenants and an app's ports stay stable across deploys. A site
|
|
143
|
+
* whose port is taken walks upward to the next free one, which keeps the result
|
|
144
|
+
* deterministic and close to what the author wrote - a template app landing on
|
|
145
|
+
* 3024 rather than an arbitrary high port.
|
|
146
|
+
*
|
|
147
|
+
* Only `server-app` sites are considered. A bucket, static, redirect or proxy
|
|
148
|
+
* site binds nothing, and `validateDeploymentConfig` already warns when one of
|
|
149
|
+
* those declares a port.
|
|
150
|
+
*/
|
|
151
|
+
export declare function allocateSitePorts(config: CloudConfig, occupied: ReadonlyMap<number, string>, range?: SitePortRange): SitePortAllocationResult;
|
|
@@ -72,6 +72,29 @@ export interface DeploymentValidationResult {
|
|
|
72
72
|
errors: string[];
|
|
73
73
|
warnings: string[];
|
|
74
74
|
}
|
|
75
|
+
export interface ValidateDeploymentOptions {
|
|
76
|
+
/**
|
|
77
|
+
* Ports this box already serves for OTHER projects, as port -> owning slug.
|
|
78
|
+
*
|
|
79
|
+
* Validation is otherwise blind to co-tenants: it only ever sees one project's
|
|
80
|
+
* `sites`, so two apps attached to the same server can both declare the
|
|
81
|
+
* template's default port and both pass. The box does not reject the second
|
|
82
|
+
* one either - ts-cloud's units do not set exclusive binding, so both bind and
|
|
83
|
+
* the kernel load-balances, leaving each domain serving the other project's
|
|
84
|
+
* site about half the time with nothing logged as an error. Supplying this
|
|
85
|
+
* turns that into a plan-time error naming the project holding the port.
|
|
86
|
+
*
|
|
87
|
+
* Build it with `occupiedHostPorts()` from `./site-ports`, passing the
|
|
88
|
+
* deploying project's own slug as `ignoreSlug` - its fragment is already on the
|
|
89
|
+
* box from the last deploy, and counting it would make every redeploy conflict
|
|
90
|
+
* with itself.
|
|
91
|
+
*
|
|
92
|
+
* Omitted means "no co-tenant information", which validates exactly as before.
|
|
93
|
+
*
|
|
94
|
+
* @see https://github.com/stacksjs/ts-cloud/issues/168
|
|
95
|
+
*/
|
|
96
|
+
occupiedPorts?: ReadonlyMap<number, string>;
|
|
97
|
+
}
|
|
75
98
|
/**
|
|
76
99
|
* Validate the per-site deployment configuration up front, turning what used to
|
|
77
100
|
* be silent runtime failures (e.g. a `start` site with no compute server) into
|
|
@@ -80,7 +103,7 @@ export interface DeploymentValidationResult {
|
|
|
80
103
|
* Never throws — returns structured `{ errors, warnings }`. Callers should abort
|
|
81
104
|
* on any error and print warnings while continuing.
|
|
82
105
|
*/
|
|
83
|
-
export declare function validateDeploymentConfig(config: CloudConfig): DeploymentValidationResult;
|
|
106
|
+
export declare function validateDeploymentConfig(config: CloudConfig, options?: ValidateDeploymentOptions): DeploymentValidationResult;
|
|
84
107
|
/**
|
|
85
108
|
* Does this site produce a release the compute deploy has to build, package and
|
|
86
109
|
* ship?
|
package/dist/dns/index.js
CHANGED
|
@@ -1,41 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CloudflareProvider,
|
|
3
|
-
DnsProviderFactory,
|
|
4
|
-
GoDaddyProvider,
|
|
5
|
-
PROXIABLE_RECORD_TYPES,
|
|
6
|
-
PorkbunProvider,
|
|
7
|
-
Route53Provider,
|
|
8
|
-
UnifiedDnsValidator,
|
|
9
|
-
createDnsProvider,
|
|
10
|
-
createGoDaddyValidator,
|
|
11
|
-
createPorkbunValidator,
|
|
12
|
-
createRoute53Validator,
|
|
13
|
-
detectDnsProvider,
|
|
14
|
-
dnsProviders,
|
|
15
|
-
policyTag,
|
|
16
|
-
qualifyName,
|
|
17
|
-
reconcileDeclaredRecords,
|
|
18
|
-
resolveDeclaredRecords
|
|
19
|
-
} from "../chunk-qr803fye.js";
|
|
20
|
-
import"../chunk-32e7ya18.js";
|
|
21
|
-
import"../chunk-zqtpg06c.js";
|
|
22
|
-
import"../chunk-v0bahtg2.js";
|
|
23
|
-
export {
|
|
24
|
-
resolveDeclaredRecords,
|
|
25
|
-
reconcileDeclaredRecords,
|
|
26
|
-
qualifyName,
|
|
27
|
-
policyTag,
|
|
28
|
-
dnsProviders,
|
|
29
|
-
detectDnsProvider,
|
|
30
|
-
createRoute53Validator,
|
|
31
|
-
createPorkbunValidator,
|
|
32
|
-
createGoDaddyValidator,
|
|
33
|
-
createDnsProvider,
|
|
34
|
-
UnifiedDnsValidator,
|
|
35
|
-
Route53Provider,
|
|
36
|
-
PorkbunProvider,
|
|
37
|
-
PROXIABLE_RECORD_TYPES,
|
|
38
|
-
GoDaddyProvider,
|
|
39
|
-
DnsProviderFactory,
|
|
40
|
-
CloudflareProvider
|
|
41
|
-
};
|
|
1
|
+
import{Af as e,Bf as f,Cf as g,Df as h,Ef as i,Ff as j,Gf as k,Hf as l,If as m,Jf as n,Kf as o,Lf as p,Mf as q,vf as a,wf as b,xf as c,zf as d}from"../chunk-8xqn3c0w.js";import"../chunk-wdzjbecg.js";import"../chunk-0ccta6z6.js";import"../chunk-xt3s24vr.js";export{g as resolveDeclaredRecords,h as reconcileDeclaredRecords,f as qualifyName,e as policyTag,q as dnsProviders,o as detectDnsProvider,m as createRoute53Validator,k as createPorkbunValidator,l as createGoDaddyValidator,n as createDnsProvider,j as UnifiedDnsValidator,i as Route53Provider,b as PorkbunProvider,a as PROXIABLE_RECORD_TYPES,c as GoDaddyProvider,p as DnsProviderFactory,d as CloudflareProvider};
|