@stacksjs/ts-cloud 0.16.20 → 0.16.22

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.
Files changed (196) hide show
  1. package/dist/aws/index.js +1 -1
  2. package/dist/aws/secrets-manager.d.ts +1 -0
  3. package/dist/aws/xml-result.d.ts +20 -0
  4. package/dist/{chunk-g6g33pt9.js → bin/chunk-09d5qe73.js} +7 -7
  5. package/dist/bin/chunk-0cefbrxg.js +1 -0
  6. package/dist/bin/{chunk-ys5n5c84.js → chunk-12q8xrct.js} +5 -5
  7. package/dist/bin/chunk-1srmd473.js +1 -0
  8. package/dist/bin/{chunk-mxvekmdx.js → chunk-24njmb7d.js} +114 -114
  9. package/dist/bin/chunk-27ka240w.js +1 -0
  10. package/dist/bin/{chunk-ngyqqy6d.js → chunk-2gd8kqzq.js} +5 -5
  11. package/dist/bin/{chunk-djjj62c0.js → chunk-330kytpm.js} +2 -2
  12. package/dist/bin/{chunk-h1rb8qvt.js → chunk-3425j97b.js} +2 -2
  13. package/dist/bin/chunk-3bq69jqk.js +1 -0
  14. package/dist/bin/chunk-4pysr1ky.js +1 -0
  15. package/dist/bin/chunk-56zfvf7e.js +1 -0
  16. package/dist/bin/chunk-59nav625.js +1 -0
  17. package/dist/bin/{chunk-6kx50dyc.js → chunk-5bsknbr7.js} +1 -1
  18. package/dist/bin/{chunk-t10e32an.js → chunk-636jsmnz.js} +6 -6
  19. package/dist/bin/chunk-7kj8f72p.js +2 -0
  20. package/dist/bin/{chunk-e55fdn0r.js → chunk-7xr71hnt.js} +3 -3
  21. package/dist/bin/chunk-87f5d9qj.js +2 -0
  22. package/dist/bin/chunk-8agf66wn.js +3 -0
  23. package/dist/bin/chunk-8fjzcr2w.js +1 -0
  24. package/dist/bin/{chunk-apnhhfkj.js → chunk-8wnkx3jf.js} +2 -2
  25. package/dist/bin/{chunk-z1dtdw3j.js → chunk-95v6ry1x.js} +5 -5
  26. package/dist/bin/chunk-9fq0bezb.js +1 -0
  27. package/dist/bin/chunk-9wpy7r9f.js +1 -0
  28. package/dist/bin/{chunk-5a7sxtwn.js → chunk-a0me5fed.js} +2 -2
  29. package/dist/bin/{chunk-148x1zq8.js → chunk-and7khsv.js} +2 -2
  30. package/dist/bin/{chunk-7zfydgfz.js → chunk-ardzx4dw.js} +130 -130
  31. package/dist/bin/{chunk-0trtkv9g.js → chunk-c04dygzg.js} +6 -6
  32. package/dist/bin/chunk-eetz9jgy.js +1 -0
  33. package/dist/bin/chunk-eg6156wp.js +1 -0
  34. package/dist/bin/chunk-ezpz96kp.js +1 -0
  35. package/dist/bin/chunk-f2qpsrrj.js +1 -0
  36. package/dist/bin/chunk-f3sbq7pw.js +2 -0
  37. package/dist/bin/chunk-gmabk4qn.js +1 -0
  38. package/dist/bin/{chunk-9vmtm7nq.js → chunk-hmnaen1z.js} +2 -2
  39. package/dist/bin/{chunk-x63yz8xg.js → chunk-jp23ed1q.js} +1 -1
  40. package/dist/bin/{chunk-0f1qpmd6.js → chunk-k6apknm8.js} +5 -5
  41. package/dist/bin/{chunk-2mv692y4.js → chunk-k97ms0bs.js} +5 -5
  42. package/dist/bin/chunk-kr51h4gk.js +1 -0
  43. package/dist/bin/{chunk-48x0wc2g.js → chunk-m51vpvr6.js} +3 -3
  44. package/dist/bin/{chunk-mx9ppkmn.js → chunk-mbqwrs7a.js} +4 -4
  45. package/dist/bin/{chunk-rbtt23vx.js → chunk-mz2jbtcs.js} +3 -3
  46. package/dist/bin/{chunk-dyh0vndw.js → chunk-n7hmjzgd.js} +4 -4
  47. package/dist/bin/{chunk-dmdg23a5.js → chunk-n8dsby4k.js} +2 -2
  48. package/dist/bin/chunk-nx8gpr90.js +34 -0
  49. package/dist/bin/chunk-q62ggp3g.js +1 -0
  50. package/dist/bin/chunk-q957s44c.js +1 -0
  51. package/dist/bin/{chunk-k7wh1wr5.js → chunk-qqqx70g6.js} +2 -2
  52. package/dist/bin/{chunk-gfr2215x.js → chunk-rm59bcnw.js} +60 -60
  53. package/dist/bin/chunk-rm6qnyce.js +2 -0
  54. package/dist/bin/chunk-rxehseyz.js +1 -0
  55. package/dist/bin/chunk-tfz7djw9.js +1 -0
  56. package/dist/bin/chunk-tr8901hb.js +1 -0
  57. package/dist/bin/{chunk-3n733cgx.js → chunk-v5bjbyve.js} +2 -2
  58. package/dist/bin/{chunk-90102shh.js → chunk-v980gs11.js} +2 -2
  59. package/dist/bin/chunk-vqb80dyg.js +1 -0
  60. package/dist/bin/{chunk-1j8b1d58.js → chunk-vskhr9qy.js} +2 -2
  61. package/dist/bin/{chunk-e24bscb0.js → chunk-wqydambz.js} +17 -17
  62. package/dist/bin/chunk-wysyyysg.js +1 -0
  63. package/dist/bin/chunk-xfs7rscr.js +1 -0
  64. package/dist/bin/cli.js +356 -356
  65. package/dist/bin/dashboard-server.js +1 -1
  66. package/dist/chunk-2ap78e1s.js +5 -0
  67. package/dist/{chunk-k53agv2m.js → chunk-2dextjqf.js} +2 -2
  68. package/dist/chunk-2fa9cdyf.js +1 -0
  69. package/dist/{chunk-z3wynefj.js → chunk-3jkc3s8c.js} +19 -19
  70. package/dist/chunk-3zzm5f28.js +92 -0
  71. package/dist/{chunk-e8e1h2h9.js → chunk-5dz6bzdj.js} +2 -2
  72. package/dist/chunk-6d5e10md.js +1 -0
  73. package/dist/chunk-9gypn8w9.js +1 -0
  74. package/dist/{chunk-hyeeqga9.js → chunk-9p89msvs.js} +6 -6
  75. package/dist/{chunk-31tvc877.js → chunk-9s24pbbc.js} +18 -18
  76. package/dist/chunk-badb5mf3.js +34 -0
  77. package/dist/{chunk-w9jhyy09.js → chunk-cfrv8110.js} +4 -4
  78. package/dist/{bin/chunk-8jbkphmg.js → chunk-dv1jkay7.js} +6 -6
  79. package/dist/{chunk-e52me1c6.js → chunk-ezgpamw6.js} +1 -1
  80. package/dist/chunk-j6a577hr.js +1 -0
  81. package/dist/chunk-jt49qs0f.js +2 -0
  82. package/dist/{chunk-aw1tp3p3.js → chunk-khatwx29.js} +99 -99
  83. package/dist/{chunk-v2p7c7s4.js → chunk-kpyhx96m.js} +133 -133
  84. package/dist/{chunk-0j2tpr8d.js → chunk-kw852q5m.js} +164 -164
  85. package/dist/{chunk-3m9ghthh.js → chunk-mgg0psgc.js} +2 -2
  86. package/dist/{chunk-9wmer0zx.js → chunk-ms4dnha2.js} +2 -2
  87. package/dist/{chunk-qcaqc5b8.js → chunk-np8vgbv0.js} +3 -3
  88. package/dist/chunk-p0b08g9f.js +114 -0
  89. package/dist/{chunk-srrscggm.js → chunk-pcns0kz4.js} +5 -5
  90. package/dist/{chunk-kczzc599.js → chunk-pffebjr8.js} +31 -31
  91. package/dist/{chunk-vs0qrm09.js → chunk-pwywwdq2.js} +1 -1
  92. package/dist/{chunk-5far81q7.js → chunk-w4s3rswa.js} +2 -2
  93. package/dist/chunk-whdbz3h8.js +1 -0
  94. package/dist/{chunk-bxrzsth8.js → chunk-x60w04y3.js} +2 -2
  95. package/dist/{chunk-zx8ecz8b.js → chunk-y6k0vwfn.js} +4 -4
  96. package/dist/deploy/index.js +1 -1
  97. package/dist/dns/index.js +1 -1
  98. package/dist/drivers/index.js +1 -1
  99. package/dist/index.js +85 -85
  100. package/dist/operations/index.js +1 -1
  101. package/dist/protection/index.js +1 -1
  102. package/dist/spend/index.js +1 -1
  103. package/dist/ui/404.html +1 -1
  104. package/dist/ui/accept-invitation.html +1 -1
  105. package/dist/ui/access-denied.html +1 -1
  106. package/dist/ui/account/automation.html +6 -6
  107. package/dist/ui/account/security.html +2 -2
  108. package/dist/ui/applications/compose.html +6 -6
  109. package/dist/ui/applications/new.html +2 -2
  110. package/dist/ui/data/backups.html +6 -6
  111. package/dist/ui/data/services.html +6 -6
  112. package/dist/ui/data/volumes.html +6 -6
  113. package/dist/ui/index.html +6 -6
  114. package/dist/ui/infrastructure/topology.html +6 -6
  115. package/dist/ui/integrations.html +2 -2
  116. package/dist/ui/operations/alerts.html +6 -6
  117. package/dist/ui/operations/configuration.html +6 -6
  118. package/dist/ui/operations/jobs.html +5 -5
  119. package/dist/ui/operations/maintenance.html +5 -5
  120. package/dist/ui/operations/observability.html +6 -6
  121. package/dist/ui/operations/previews.html +6 -6
  122. package/dist/ui/operations/queue.html +5 -5
  123. package/dist/ui/operations/regions.html +5 -5
  124. package/dist/ui/operations/releases.html +6 -6
  125. package/dist/ui/operations/spend.html +6 -6
  126. package/dist/ui/operations/workloads.html +6 -6
  127. package/dist/ui/security.html +2 -2
  128. package/dist/ui/server/actions.html +6 -6
  129. package/dist/ui/server/activity.html +1 -1
  130. package/dist/ui/server/capacity.html +5 -5
  131. package/dist/ui/server/database.html +5 -5
  132. package/dist/ui/server/deployments.html +5 -5
  133. package/dist/ui/server/diagnostics.html +1 -1
  134. package/dist/ui/server/firewall.html +5 -5
  135. package/dist/ui/server/fleet.html +5 -5
  136. package/dist/ui/server/logs.html +6 -6
  137. package/dist/ui/server/metrics.html +5 -5
  138. package/dist/ui/server/security.html +2 -2
  139. package/dist/ui/server/services.html +1 -1
  140. package/dist/ui/server/sites.html +6 -6
  141. package/dist/ui/server/ssh-keys.html +6 -6
  142. package/dist/ui/server/team.html +6 -6
  143. package/dist/ui/server/terminal.html +2 -2
  144. package/dist/ui/serverless/alarms.html +6 -6
  145. package/dist/ui/serverless/assets.html +2 -2
  146. package/dist/ui/serverless/cost.html +1 -1
  147. package/dist/ui/serverless/data.html +6 -6
  148. package/dist/ui/serverless/deployments.html +2 -2
  149. package/dist/ui/serverless/firewall.html +1 -1
  150. package/dist/ui/serverless/functions.html +5 -5
  151. package/dist/ui/serverless/logs.html +5 -5
  152. package/dist/ui/serverless/metrics.html +2 -2
  153. package/dist/ui/serverless/queues.html +6 -6
  154. package/dist/ui/serverless/secrets.html +6 -6
  155. package/dist/ui/serverless/traces.html +6 -6
  156. package/dist/ui/serverless.html +5 -5
  157. package/package.json +3 -3
  158. package/dist/bin/chunk-0h6cggyt.js +0 -1
  159. package/dist/bin/chunk-28ztnqjk.js +0 -1
  160. package/dist/bin/chunk-2g2zrtjs.js +0 -2
  161. package/dist/bin/chunk-4cs098d1.js +0 -1
  162. package/dist/bin/chunk-52fhq35h.js +0 -1
  163. package/dist/bin/chunk-6se7ygxa.js +0 -1
  164. package/dist/bin/chunk-72g1hr4z.js +0 -1
  165. package/dist/bin/chunk-840arz58.js +0 -34
  166. package/dist/bin/chunk-c7vxdwth.js +0 -1
  167. package/dist/bin/chunk-e0c3agf2.js +0 -1
  168. package/dist/bin/chunk-egn33pr9.js +0 -2
  169. package/dist/bin/chunk-gf7yavs5.js +0 -1
  170. package/dist/bin/chunk-gp5w7e4c.js +0 -1
  171. package/dist/bin/chunk-gt7g41js.js +0 -1
  172. package/dist/bin/chunk-hagakkgm.js +0 -1
  173. package/dist/bin/chunk-hr3vbg6y.js +0 -1
  174. package/dist/bin/chunk-hyb5v8wr.js +0 -1
  175. package/dist/bin/chunk-ndddd2ft.js +0 -3
  176. package/dist/bin/chunk-nqb1faqj.js +0 -1
  177. package/dist/bin/chunk-p831sptd.js +0 -1
  178. package/dist/bin/chunk-qxx1a51w.js +0 -1
  179. package/dist/bin/chunk-sh248v2y.js +0 -1
  180. package/dist/bin/chunk-swfmx4f8.js +0 -1
  181. package/dist/bin/chunk-vjkyj3xy.js +0 -2
  182. package/dist/bin/chunk-w8k1gyzr.js +0 -1
  183. package/dist/bin/chunk-wagzxm7z.js +0 -1
  184. package/dist/bin/chunk-xdxk6baf.js +0 -1
  185. package/dist/bin/chunk-y286zhty.js +0 -1
  186. package/dist/bin/chunk-ysv52qcc.js +0 -1
  187. package/dist/chunk-07rjctzz.js +0 -1
  188. package/dist/chunk-49vvjfrd.js +0 -1
  189. package/dist/chunk-6kcmbymp.js +0 -1
  190. package/dist/chunk-7xnwa0s8.js +0 -5
  191. package/dist/chunk-9asn5fpt.js +0 -92
  192. package/dist/chunk-d46p0h6t.js +0 -34
  193. package/dist/chunk-dak9hfrd.js +0 -1
  194. package/dist/chunk-ptq9v346.js +0 -2
  195. package/dist/chunk-wgf1ndgq.js +0 -114
  196. package/dist/chunk-z4xzd43p.js +0 -1
@@ -1 +1 @@
1
- import"./chunk-mxvekmdx.js";import"./chunk-0trtkv9g.js";import"./chunk-e24bscb0.js";import{tr}from"./chunk-7zfydgfz.js";import"./chunk-mx9ppkmn.js";import"./chunk-k7wh1wr5.js";import"./chunk-e55fdn0r.js";import"./chunk-z1dtdw3j.js";import"./chunk-gfr2215x.js";import"./chunk-vjkyj3xy.js";import"./chunk-48x0wc2g.js";import"./chunk-90102shh.js";import"./chunk-dyh0vndw.js";import"./chunk-148x1zq8.js";import"./chunk-5a7sxtwn.js";import"./chunk-840arz58.js";import"./chunk-egn33pr9.js";import"./chunk-6kx50dyc.js";import"./chunk-t10e32an.js";import"./chunk-ys5n5c84.js";import"./chunk-2mv692y4.js";import"./chunk-ndddd2ft.js";import"./chunk-rbtt23vx.js";import"./chunk-h1rb8qvt.js";import"./chunk-1j8b1d58.js";import"./chunk-9vmtm7nq.js";import n from"node:process";function r(o){let e=n.argv.indexOf(o);return e===-1?void 0:n.argv[e+1]}function t(o){return n.argv.includes(o)}async function i(){let o=await tr({host:r("--host")??"127.0.0.1",port:Number(r("--port")??7676),environment:r("--env"),box:t("--box"),verbose:t("--verbose")});console.log("ts-cloud Local Dashboard"),console.log(`Serving ${o.url}`),await new Promise((e)=>{let s=()=>{o.server.stop(!0),e()};n.once("SIGINT",s),n.once("SIGTERM",s)})}i();
1
+ import"./chunk-24njmb7d.js";import"./chunk-c04dygzg.js";import"./chunk-wqydambz.js";import{nr}from"./chunk-ardzx4dw.js";import"./chunk-mbqwrs7a.js";import"./chunk-qqqx70g6.js";import"./chunk-7xr71hnt.js";import"./chunk-95v6ry1x.js";import"./chunk-rm59bcnw.js";import"./chunk-87f5d9qj.js";import"./chunk-m51vpvr6.js";import"./chunk-v980gs11.js";import"./chunk-n7hmjzgd.js";import"./chunk-and7khsv.js";import"./chunk-a0me5fed.js";import"./chunk-nx8gpr90.js";import"./chunk-7kj8f72p.js";import"./chunk-5bsknbr7.js";import"./chunk-636jsmnz.js";import"./chunk-12q8xrct.js";import"./chunk-k97ms0bs.js";import"./chunk-8agf66wn.js";import"./chunk-mz2jbtcs.js";import"./chunk-3425j97b.js";import"./chunk-vskhr9qy.js";import"./chunk-hmnaen1z.js";import n from"node:process";function r(o){let e=n.argv.indexOf(o);return e===-1?void 0:n.argv[e+1]}function t(o){return n.argv.includes(o)}async function i(){let o=await nr({host:r("--host")??"127.0.0.1",port:Number(r("--port")??7676),environment:r("--env"),box:t("--box"),verbose:t("--verbose")});console.log("ts-cloud Local Dashboard"),console.log(`Serving ${o.url}`),await new Promise((e)=>{let s=()=>{o.server.stop(!0),e()};n.once("SIGINT",s),n.once("SIGTERM",s)})}i();
@@ -0,0 +1,5 @@
1
+ import{fo,jr,Ud,ki,Eo,bo}from"./chunk-kpyhx96m.js";import{xe}from"./chunk-w4s3rswa.js";import{execFileSync as k}from"node:child_process";import{mkdirSync as I,mkdtempSync as M,rmSync as U,writeFileSync as d}from"node:fs";import{tmpdir as L}from"node:os";import{dirname as O,join as s}from"node:path";var r={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"};function b(t,e){return`${r[e]}${t}${r.reset}`}function mn(t){console.log(`${r.green}✓${r.reset} ${t}`)}function yu(t){console.error(`${r.red}✗${r.reset} ${t}`)}function ss(t){console.warn(`${r.yellow}⚠${r.reset} ${t}`)}function N(t){console.log(`${r.blue}ℹ${r.reset} ${t}`)}function T(t){console.log(`${r.cyan}→${r.reset} ${t}`)}function os(t){console.log(`
2
+ ${r.bright}${r.cyan}${t}${r.reset}
3
+ `)}var D=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);function Iu(t,e="cyan"){let n=t.split(`
4
+ `),i=Math.max(...n.map((l)=>l.length)),a="─".repeat(i+2);console.log(b(`┌${a}┐`,e)),n.forEach((l)=>{console.log(b(`│ ${l.padEnd(i)} │`,e))}),console.log(b(`└${a}┘`,e))}function C(t,e){for(let n of e){let i=s(t,n.name);I(O(i),{recursive:!0}),d(i,n.data,n.mode?{mode:n.mode}:void 0)}}async function $a(t){let{app:e,projectRoot:n,region:i,repository:a}=t,l=e.architecture??"x86_64",A=l==="arm64"?"linux/arm64":"linux/amd64",R=e.kind==="php",c=t.onStep??(()=>{}),p=M(s(L(),"tscloud-img-"));try{let f=s(p,"app");I(f,{recursive:!0});let y,w;if(R){Eo({projectRoot:n,app:e,skipBuild:t.skipBuild,onStep:c}),c("staging application tree");let o=bo(n);C(f,o),C(s(p,"runtime"),ki().map((g)=>({name:g.path,data:g.contents,mode:g.mode})));let B=e.handlers?.http??"public/index.php";y={http:B,queue:e.handlers?.queue??B,cli:e.handlers?.cli??B},w=fo(o.map((g)=>`${g.name}:${g.data.length}`).join("|"))}else{c("bundling application");let o=await jr({projectRoot:n,app:e,skipBuild:t.skipBuild,onStep:c});d(s(f,"index.mjs"),o.bundle),y=o.handlers,w=o.sha256}let S=w.slice(0,16);d(s(p,"Dockerfile"),Ud({kind:e.kind??"node",phpVersion:e.phpVersion,architecture:l}));let v=new xe(i),u;try{u=(await v.describeRepositories({repositoryNames:[a]})).repositories?.[0]?.repositoryUri??""}catch{u=""}if(!u)c(`creating ECR repository ${a}`),u=(await v.createRepository({repositoryName:a,imageScanningConfiguration:{scanOnPush:!0}})).repository?.repositoryUri??"";if(!u)throw Error(`could not resolve ECR repository URI for ${a}`);let m=`${u}:${S}`;c("docker build"),k("docker",["build","--platform",A,"--provenance=false","--sbom=false","-t",m,p],{stdio:"inherit"}),c("ecr auth + push");let h=(await v.getAuthorizationToken()).authorizationData?.[0];if(!h?.authorizationToken||!h.proxyEndpoint)throw Error("failed to get an ECR authorization token");let P=h.proxyEndpoint.replace(/^https?:\/\//,""),x=s(p,".docker");return I(x,{recursive:!0}),d(s(x,"config.json"),JSON.stringify({auths:{[P]:{auth:h.authorizationToken}}})),k("docker",["push",m],{stdio:"inherit",env:{...process.env,DOCKER_CONFIG:x}}),N(`Image: ${m}`),{imageUri:m,tag:S,handlers:y}}finally{U(p,{recursive:!0,force:!0})}}
5
+ export{mn,yu,ss,N,T,os,Iu,$a};
@@ -1,2 +1,2 @@
1
- import{n,l}from"./chunk-zx8ecz8b.js";class j{client;region;constructor(e="us-east-1"){this.region=e,this.client=new n}async describeDBInstances(e){let r={Action:"DescribeDBInstances",Version:"2014-10-31"};if(e?.DBInstanceIdentifier)r.DBInstanceIdentifier=e.DBInstanceIdentifier;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;if(e?.Filters)e.Filters.forEach((o,c)=>{r[`Filters.Filter.${c+1}.Name`]=o.Name,o.Values.forEach((u,d)=>{r[`Filters.Filter.${c+1}.Values.Value.${d+1}`]=u})});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBInstancesResult||t,i=a.DBInstances?.DBInstance||[];if(!Array.isArray(i))i=i?[i]:[];return{DBInstances:i,Marker:a.Marker}}async describeDBInstance(e){return(await this.describeDBInstances({DBInstanceIdentifier:e})).DBInstances?.[0]}async describeDBClusters(e){let r={Action:"DescribeDBClusters",Version:"2014-10-31"};if(e?.DBClusterIdentifier)r.DBClusterIdentifier=e.DBClusterIdentifier;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;if(e?.Filters)e.Filters.forEach((o,c)=>{r[`Filters.Filter.${c+1}.Name`]=o.Name,o.Values.forEach((u,d)=>{r[`Filters.Filter.${c+1}.Values.Value.${d+1}`]=u})});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBClustersResult||t,i=a.DBClusters?.DBCluster||[];if(!Array.isArray(i))i=i?[i]:[];return{DBClusters:i,Marker:a.Marker}}async describeDBSnapshots(e){let r={Action:"DescribeDBSnapshots",Version:"2014-10-31"};if(e?.DBInstanceIdentifier)r.DBInstanceIdentifier=e.DBInstanceIdentifier;if(e?.DBSnapshotIdentifier)r.DBSnapshotIdentifier=e.DBSnapshotIdentifier;if(e?.SnapshotType)r.SnapshotType=e.SnapshotType;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBSnapshotsResult||t,i=a.DBSnapshots?.DBSnapshot||[];if(!Array.isArray(i))i=i?[i]:[];return{DBSnapshots:i,Marker:a.Marker}}async describeDBSubnetGroups(e){let r={Action:"DescribeDBSubnetGroups",Version:"2014-10-31"};if(e?.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBSubnetGroupsResult||t,i=a.DBSubnetGroups?.DBSubnetGroup||[];if(!Array.isArray(i))i=i?[i]:[];return{DBSubnetGroups:i,Marker:a.Marker}}async createDBInstance(e){let r={Action:"CreateDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier,DBInstanceClass:e.DBInstanceClass,Engine:e.Engine};if(e.DBClusterIdentifier)r.DBClusterIdentifier=e.DBClusterIdentifier;if(e.MasterUsername)r.MasterUsername=e.MasterUsername;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.DBName)r.DBName=e.DBName;if(e.AllocatedStorage)r.AllocatedStorage=e.AllocatedStorage;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.AvailabilityZone)r.AvailabilityZone=e.AvailabilityZone;if(e.PreferredMaintenanceWindow)r.PreferredMaintenanceWindow=e.PreferredMaintenanceWindow;if(e.PreferredBackupWindow)r.PreferredBackupWindow=e.PreferredBackupWindow;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.MultiAZ!==void 0)r.MultiAZ=e.MultiAZ;if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.AutoMinorVersionUpgrade!==void 0)r.AutoMinorVersionUpgrade=e.AutoMinorVersionUpgrade;if(e.LicenseModel)r.LicenseModel=e.LicenseModel;if(e.PubliclyAccessible!==void 0)r.PubliclyAccessible=e.PubliclyAccessible;if(e.StorageType)r.StorageType=e.StorageType;if(e.StorageEncrypted!==void 0)r.StorageEncrypted=e.StorageEncrypted;if(e.KmsKeyId)r.KmsKeyId=e.KmsKeyId;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});if(e.Tags)e.Tags.forEach((i,o)=>{r[`Tags.Tag.${o+1}.Key`]=i.Key,r[`Tags.Tag.${o+1}.Value`]=i.Value});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.CreateDBInstanceResult||t).DBInstance}}async createDBCluster(e){let r={Action:"CreateDBCluster",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier,Engine:e.Engine};if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.MasterUsername)r.MasterUsername=e.MasterUsername;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.DatabaseName)r.DatabaseName=e.DatabaseName;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.StorageEncrypted!==void 0)r.StorageEncrypted=e.StorageEncrypted;if(e.KmsKeyId)r.KmsKeyId=e.KmsKeyId;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.ServerlessV2ScalingConfiguration)r["ServerlessV2ScalingConfiguration.MinCapacity"]=e.ServerlessV2ScalingConfiguration.MinCapacity,r["ServerlessV2ScalingConfiguration.MaxCapacity"]=e.ServerlessV2ScalingConfiguration.MaxCapacity;e.VpcSecurityGroupIds?.forEach((a,i)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${i+1}`]=a});let s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()});return{DBCluster:(s.CreateDBClusterResult||s).DBCluster}}async deleteDBInstance(e){let r={Action:"DeleteDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.SkipFinalSnapshot!==void 0)r.SkipFinalSnapshot=e.SkipFinalSnapshot;if(e.FinalDBSnapshotIdentifier)r.FinalDBSnapshotIdentifier=e.FinalDBSnapshotIdentifier;if(e.DeleteAutomatedBackups!==void 0)r.DeleteAutomatedBackups=e.DeleteAutomatedBackups;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.DeleteDBInstanceResult||t).DBInstance}}async modifyDBInstance(e){let r={Action:"ModifyDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.DBInstanceClass)r.DBInstanceClass=e.DBInstanceClass;if(e.AllocatedStorage)r.AllocatedStorage=e.AllocatedStorage;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.PreferredBackupWindow)r.PreferredBackupWindow=e.PreferredBackupWindow;if(e.PreferredMaintenanceWindow)r.PreferredMaintenanceWindow=e.PreferredMaintenanceWindow;if(e.MultiAZ!==void 0)r.MultiAZ=e.MultiAZ;if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.AutoMinorVersionUpgrade!==void 0)r.AutoMinorVersionUpgrade=e.AutoMinorVersionUpgrade;if(e.PubliclyAccessible!==void 0)r.PubliclyAccessible=e.PubliclyAccessible;if(e.ApplyImmediately!==void 0)r.ApplyImmediately=e.ApplyImmediately;if(e.StorageType)r.StorageType=e.StorageType;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.ModifyDBInstanceResult||t).DBInstance}}async modifyDBCluster(e){let r={Action:"ModifyDBCluster",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier};if(e.ServerlessV2ScalingConfiguration)r["ServerlessV2ScalingConfiguration.MinCapacity"]=e.ServerlessV2ScalingConfiguration.MinCapacity,r["ServerlessV2ScalingConfiguration.MaxCapacity"]=e.ServerlessV2ScalingConfiguration.MaxCapacity;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.ApplyImmediately!==void 0)r.ApplyImmediately=e.ApplyImmediately;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBCluster:(t.ModifyDBClusterResult||t).DBCluster}}async rebootDBCluster(e){let r={Action:"FailoverDBCluster",Version:"2014-10-31",DBClusterIdentifier:e},s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()});return{DBCluster:(s.FailoverDBClusterResult||s).DBCluster}}async createDBClusterSnapshot(e,r){let s={Action:"CreateDBClusterSnapshot",Version:"2014-10-31",DBClusterIdentifier:e,DBClusterSnapshotIdentifier:r};return this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(s)).toString()})}async describeDBClusterSnapshots(e={}){let r={Action:"DescribeDBClusterSnapshots",Version:"2014-10-31",...e},s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()}),t=s.DescribeDBClusterSnapshotsResult||s,a=t.DBClusterSnapshots?.DBClusterSnapshot??t.DBClusterSnapshots??[];return{DBClusterSnapshots:Array.isArray(a)?a:[a]}}async deleteDBClusterSnapshot(e){await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l({Action:"DeleteDBClusterSnapshot",Version:"2014-10-31",DBClusterSnapshotIdentifier:e})).toString()})}async deleteDBCluster(e,r){let s={Action:"DeleteDBCluster",Version:"2014-10-31",DBClusterIdentifier:e,SkipFinalSnapshot:!r};if(r)s.FinalDBSnapshotIdentifier=r;let t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(s)).toString()});return{DBCluster:(t.DeleteDBClusterResult||t).DBCluster}}async restoreDBClusterToPointInTime(e){let r={Action:"RestoreDBClusterToPointInTime",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier,SourceDBClusterIdentifier:e.SourceDBClusterIdentifier};if(e.RestoreToTime)r.RestoreToTime=e.RestoreToTime.toISOString();if(e.UseLatestRestorableTime)r.UseLatestRestorableTime=!0;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBCluster:(t.RestoreDBClusterToPointInTimeResult||t).DBCluster}}async restoreDBClusterFromSnapshot(e){let r={Action:"RestoreDBClusterFromSnapshot",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier,SnapshotIdentifier:e.SnapshotIdentifier,Engine:e.Engine};if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds?.forEach((a,i)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${i+1}`]=a}),e.ServerlessV2ScalingConfiguration)r["ServerlessV2ScalingConfiguration.MinCapacity"]=e.ServerlessV2ScalingConfiguration.MinCapacity,r["ServerlessV2ScalingConfiguration.MaxCapacity"]=e.ServerlessV2ScalingConfiguration.MaxCapacity;let s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()});return{DBCluster:(s.RestoreDBClusterFromSnapshotResult||s).DBCluster}}async startDBInstance(e){let s=new URLSearchParams(l({Action:"StartDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e})).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.StartDBInstanceResult||t).DBInstance}}async stopDBInstance(e){let r={Action:"StopDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.DBSnapshotIdentifier)r.DBSnapshotIdentifier=e.DBSnapshotIdentifier;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.StopDBInstanceResult||t).DBInstance}}async rebootDBInstance(e){let r={Action:"RebootDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.ForceFailover!==void 0)r.ForceFailover=e.ForceFailover;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.RebootDBInstanceResult||t).DBInstance}}async createDBSnapshot(e){let r={Action:"CreateDBSnapshot",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier,DBSnapshotIdentifier:e.DBSnapshotIdentifier};if(e.Tags)e.Tags.forEach((i,o)=>{r[`Tags.Tag.${o+1}.Key`]=i.Key,r[`Tags.Tag.${o+1}.Value`]=i.Value});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBSnapshot:(t.CreateDBSnapshotResult||t).DBSnapshot}}async deleteDBSnapshot(e){let s=new URLSearchParams(l({Action:"DeleteDBSnapshot",Version:"2014-10-31",DBSnapshotIdentifier:e})).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBSnapshot:(t.DeleteDBSnapshotResult||t).DBSnapshot}}async restoreDBInstanceFromDBSnapshot(e){let r={Action:"RestoreDBInstanceFromDBSnapshot",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier,DBSnapshotIdentifier:e.DBSnapshotIdentifier};if(e.DBInstanceClass)r.DBInstanceClass=e.DBInstanceClass;if(e.Port)r.Port=e.Port;if(e.AvailabilityZone)r.AvailabilityZone=e.AvailabilityZone;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.MultiAZ!==void 0)r.MultiAZ=e.MultiAZ;if(e.PubliclyAccessible!==void 0)r.PubliclyAccessible=e.PubliclyAccessible;if(e.AutoMinorVersionUpgrade!==void 0)r.AutoMinorVersionUpgrade=e.AutoMinorVersionUpgrade;if(e.StorageType)r.StorageType=e.StorageType;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});if(e.Tags)e.Tags.forEach((i,o)=>{r[`Tags.Tag.${o+1}.Key`]=i.Key,r[`Tags.Tag.${o+1}.Value`]=i.Value});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.RestoreDBInstanceFromDBSnapshotResult||t).DBInstance}}async waitForDBInstanceAvailable(e,r=60,s=30000){for(let t=0;t<r;t++){let a=await this.describeDBInstance(e);if(a?.DBInstanceStatus==="available")return a;if(["deleted","failed","incompatible-restore","incompatible-parameters"].includes(a?.DBInstanceStatus||""))throw Error(`DB instance ${e} is in terminal state: ${a?.DBInstanceStatus}`);await new Promise((i)=>setTimeout(i,s))}throw Error(`Timeout waiting for DB instance ${e} to become available`)}async waitForDBInstanceDeleted(e,r=60,s=30000){for(let t=0;t<r;t++)try{let a=await this.describeDBInstance(e);if(a?.DBInstanceStatus==="deleting"){await new Promise((i)=>setTimeout(i,s));continue}throw Error(`DB instance ${e} is in state: ${a?.DBInstanceStatus}`)}catch(a){if(a.code==="DBInstanceNotFound"||a.code==="DBInstanceNotFoundFault")return;throw a}throw Error(`Timeout waiting for DB instance ${e} to be deleted`)}}
2
- export{j};
1
+ import{n,l}from"./chunk-y6k0vwfn.js";class z{client;region;constructor(e="us-east-1"){this.region=e,this.client=new n}async describeDBInstances(e){let r={Action:"DescribeDBInstances",Version:"2014-10-31"};if(e?.DBInstanceIdentifier)r.DBInstanceIdentifier=e.DBInstanceIdentifier;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;if(e?.Filters)e.Filters.forEach((o,c)=>{r[`Filters.Filter.${c+1}.Name`]=o.Name,o.Values.forEach((u,d)=>{r[`Filters.Filter.${c+1}.Values.Value.${d+1}`]=u})});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBInstancesResult||t,i=a.DBInstances?.DBInstance||[];if(!Array.isArray(i))i=i?[i]:[];return{DBInstances:i,Marker:a.Marker}}async describeDBInstance(e){return(await this.describeDBInstances({DBInstanceIdentifier:e})).DBInstances?.[0]}async describeDBClusters(e){let r={Action:"DescribeDBClusters",Version:"2014-10-31"};if(e?.DBClusterIdentifier)r.DBClusterIdentifier=e.DBClusterIdentifier;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;if(e?.Filters)e.Filters.forEach((o,c)=>{r[`Filters.Filter.${c+1}.Name`]=o.Name,o.Values.forEach((u,d)=>{r[`Filters.Filter.${c+1}.Values.Value.${d+1}`]=u})});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBClustersResult||t,i=a.DBClusters?.DBCluster||[];if(!Array.isArray(i))i=i?[i]:[];return{DBClusters:i,Marker:a.Marker}}async describeDBSnapshots(e){let r={Action:"DescribeDBSnapshots",Version:"2014-10-31"};if(e?.DBInstanceIdentifier)r.DBInstanceIdentifier=e.DBInstanceIdentifier;if(e?.DBSnapshotIdentifier)r.DBSnapshotIdentifier=e.DBSnapshotIdentifier;if(e?.SnapshotType)r.SnapshotType=e.SnapshotType;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBSnapshotsResult||t,i=a.DBSnapshots?.DBSnapshot||[];if(!Array.isArray(i))i=i?[i]:[];return{DBSnapshots:i,Marker:a.Marker}}async describeDBSubnetGroups(e){let r={Action:"DescribeDBSubnetGroups",Version:"2014-10-31"};if(e?.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e?.MaxRecords)r.MaxRecords=e.MaxRecords;if(e?.Marker)r.Marker=e.Marker;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s}),a=t.DescribeDBSubnetGroupsResult||t,i=a.DBSubnetGroups?.DBSubnetGroup||[];if(!Array.isArray(i))i=i?[i]:[];return{DBSubnetGroups:i,Marker:a.Marker}}async createDBInstance(e){let r={Action:"CreateDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier,DBInstanceClass:e.DBInstanceClass,Engine:e.Engine};if(e.DBClusterIdentifier)r.DBClusterIdentifier=e.DBClusterIdentifier;if(e.MasterUsername)r.MasterUsername=e.MasterUsername;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.DBName)r.DBName=e.DBName;if(e.AllocatedStorage)r.AllocatedStorage=e.AllocatedStorage;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.AvailabilityZone)r.AvailabilityZone=e.AvailabilityZone;if(e.PreferredMaintenanceWindow)r.PreferredMaintenanceWindow=e.PreferredMaintenanceWindow;if(e.PreferredBackupWindow)r.PreferredBackupWindow=e.PreferredBackupWindow;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.MultiAZ!==void 0)r.MultiAZ=e.MultiAZ;if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.AutoMinorVersionUpgrade!==void 0)r.AutoMinorVersionUpgrade=e.AutoMinorVersionUpgrade;if(e.LicenseModel)r.LicenseModel=e.LicenseModel;if(e.PubliclyAccessible!==void 0)r.PubliclyAccessible=e.PubliclyAccessible;if(e.StorageType)r.StorageType=e.StorageType;if(e.StorageEncrypted!==void 0)r.StorageEncrypted=e.StorageEncrypted;if(e.KmsKeyId)r.KmsKeyId=e.KmsKeyId;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});if(e.Tags)e.Tags.forEach((i,o)=>{r[`Tags.Tag.${o+1}.Key`]=i.Key,r[`Tags.Tag.${o+1}.Value`]=i.Value});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.CreateDBInstanceResult||t).DBInstance}}async createDBCluster(e){let r={Action:"CreateDBCluster",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier,Engine:e.Engine};if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.MasterUsername)r.MasterUsername=e.MasterUsername;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.DatabaseName)r.DatabaseName=e.DatabaseName;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.StorageEncrypted!==void 0)r.StorageEncrypted=e.StorageEncrypted;if(e.KmsKeyId)r.KmsKeyId=e.KmsKeyId;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.ServerlessV2ScalingConfiguration)r["ServerlessV2ScalingConfiguration.MinCapacity"]=e.ServerlessV2ScalingConfiguration.MinCapacity,r["ServerlessV2ScalingConfiguration.MaxCapacity"]=e.ServerlessV2ScalingConfiguration.MaxCapacity;e.VpcSecurityGroupIds?.forEach((a,i)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${i+1}`]=a});let s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()});return{DBCluster:(s.CreateDBClusterResult||s).DBCluster}}async deleteDBInstance(e){let r={Action:"DeleteDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.SkipFinalSnapshot!==void 0)r.SkipFinalSnapshot=e.SkipFinalSnapshot;if(e.FinalDBSnapshotIdentifier)r.FinalDBSnapshotIdentifier=e.FinalDBSnapshotIdentifier;if(e.DeleteAutomatedBackups!==void 0)r.DeleteAutomatedBackups=e.DeleteAutomatedBackups;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.DeleteDBInstanceResult||t).DBInstance}}async modifyDBInstance(e){let r={Action:"ModifyDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.DBInstanceClass)r.DBInstanceClass=e.DBInstanceClass;if(e.AllocatedStorage)r.AllocatedStorage=e.AllocatedStorage;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.PreferredBackupWindow)r.PreferredBackupWindow=e.PreferredBackupWindow;if(e.PreferredMaintenanceWindow)r.PreferredMaintenanceWindow=e.PreferredMaintenanceWindow;if(e.MultiAZ!==void 0)r.MultiAZ=e.MultiAZ;if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.AutoMinorVersionUpgrade!==void 0)r.AutoMinorVersionUpgrade=e.AutoMinorVersionUpgrade;if(e.PubliclyAccessible!==void 0)r.PubliclyAccessible=e.PubliclyAccessible;if(e.ApplyImmediately!==void 0)r.ApplyImmediately=e.ApplyImmediately;if(e.StorageType)r.StorageType=e.StorageType;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.ModifyDBInstanceResult||t).DBInstance}}async modifyDBCluster(e){let r={Action:"ModifyDBCluster",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier};if(e.ServerlessV2ScalingConfiguration)r["ServerlessV2ScalingConfiguration.MinCapacity"]=e.ServerlessV2ScalingConfiguration.MinCapacity,r["ServerlessV2ScalingConfiguration.MaxCapacity"]=e.ServerlessV2ScalingConfiguration.MaxCapacity;if(e.BackupRetentionPeriod!==void 0)r.BackupRetentionPeriod=e.BackupRetentionPeriod;if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.MasterUserPassword)r.MasterUserPassword=e.MasterUserPassword;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.ApplyImmediately!==void 0)r.ApplyImmediately=e.ApplyImmediately;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBCluster:(t.ModifyDBClusterResult||t).DBCluster}}async rebootDBCluster(e){let r={Action:"FailoverDBCluster",Version:"2014-10-31",DBClusterIdentifier:e},s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()});return{DBCluster:(s.FailoverDBClusterResult||s).DBCluster}}async createDBClusterSnapshot(e,r){let s={Action:"CreateDBClusterSnapshot",Version:"2014-10-31",DBClusterIdentifier:e,DBClusterSnapshotIdentifier:r};return this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(s)).toString()})}async describeDBClusterSnapshots(e={}){let r={Action:"DescribeDBClusterSnapshots",Version:"2014-10-31",...e},s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()}),t=s.DescribeDBClusterSnapshotsResult||s,a=t.DBClusterSnapshots?.DBClusterSnapshot??t.DBClusterSnapshots??[];return{DBClusterSnapshots:Array.isArray(a)?a:[a]}}async deleteDBClusterSnapshot(e){await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l({Action:"DeleteDBClusterSnapshot",Version:"2014-10-31",DBClusterSnapshotIdentifier:e})).toString()})}async deleteDBCluster(e,r){let s={Action:"DeleteDBCluster",Version:"2014-10-31",DBClusterIdentifier:e,SkipFinalSnapshot:!r};if(r)s.FinalDBSnapshotIdentifier=r;let t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(s)).toString()});return{DBCluster:(t.DeleteDBClusterResult||t).DBCluster}}async restoreDBClusterToPointInTime(e){let r={Action:"RestoreDBClusterToPointInTime",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier,SourceDBClusterIdentifier:e.SourceDBClusterIdentifier};if(e.RestoreToTime)r.RestoreToTime=e.RestoreToTime.toISOString();if(e.UseLatestRestorableTime)r.UseLatestRestorableTime=!0;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBCluster:(t.RestoreDBClusterToPointInTimeResult||t).DBCluster}}async restoreDBClusterFromSnapshot(e){let r={Action:"RestoreDBClusterFromSnapshot",Version:"2014-10-31",DBClusterIdentifier:e.DBClusterIdentifier,SnapshotIdentifier:e.SnapshotIdentifier,Engine:e.Engine};if(e.EngineVersion)r.EngineVersion=e.EngineVersion;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds?.forEach((a,i)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${i+1}`]=a}),e.ServerlessV2ScalingConfiguration)r["ServerlessV2ScalingConfiguration.MinCapacity"]=e.ServerlessV2ScalingConfiguration.MinCapacity,r["ServerlessV2ScalingConfiguration.MaxCapacity"]=e.ServerlessV2ScalingConfiguration.MaxCapacity;let s=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(l(r)).toString()});return{DBCluster:(s.RestoreDBClusterFromSnapshotResult||s).DBCluster}}async startDBInstance(e){let s=new URLSearchParams(l({Action:"StartDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e})).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.StartDBInstanceResult||t).DBInstance}}async stopDBInstance(e){let r={Action:"StopDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.DBSnapshotIdentifier)r.DBSnapshotIdentifier=e.DBSnapshotIdentifier;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.StopDBInstanceResult||t).DBInstance}}async rebootDBInstance(e){let r={Action:"RebootDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.ForceFailover!==void 0)r.ForceFailover=e.ForceFailover;let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.RebootDBInstanceResult||t).DBInstance}}async createDBSnapshot(e){let r={Action:"CreateDBSnapshot",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier,DBSnapshotIdentifier:e.DBSnapshotIdentifier};if(e.Tags)e.Tags.forEach((i,o)=>{r[`Tags.Tag.${o+1}.Key`]=i.Key,r[`Tags.Tag.${o+1}.Value`]=i.Value});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBSnapshot:(t.CreateDBSnapshotResult||t).DBSnapshot}}async deleteDBSnapshot(e){let s=new URLSearchParams(l({Action:"DeleteDBSnapshot",Version:"2014-10-31",DBSnapshotIdentifier:e})).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBSnapshot:(t.DeleteDBSnapshotResult||t).DBSnapshot}}async restoreDBInstanceFromDBSnapshot(e){let r={Action:"RestoreDBInstanceFromDBSnapshot",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier,DBSnapshotIdentifier:e.DBSnapshotIdentifier};if(e.DBInstanceClass)r.DBInstanceClass=e.DBInstanceClass;if(e.Port)r.Port=e.Port;if(e.AvailabilityZone)r.AvailabilityZone=e.AvailabilityZone;if(e.DBSubnetGroupName)r.DBSubnetGroupName=e.DBSubnetGroupName;if(e.MultiAZ!==void 0)r.MultiAZ=e.MultiAZ;if(e.PubliclyAccessible!==void 0)r.PubliclyAccessible=e.PubliclyAccessible;if(e.AutoMinorVersionUpgrade!==void 0)r.AutoMinorVersionUpgrade=e.AutoMinorVersionUpgrade;if(e.StorageType)r.StorageType=e.StorageType;if(e.DeletionProtection!==void 0)r.DeletionProtection=e.DeletionProtection;if(e.VpcSecurityGroupIds)e.VpcSecurityGroupIds.forEach((i,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=i});if(e.Tags)e.Tags.forEach((i,o)=>{r[`Tags.Tag.${o+1}.Key`]=i.Key,r[`Tags.Tag.${o+1}.Value`]=i.Value});let s=new URLSearchParams(l(r)).toString(),t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:s});return{DBInstance:(t.RestoreDBInstanceFromDBSnapshotResult||t).DBInstance}}async waitForDBInstanceAvailable(e,r=60,s=30000){for(let t=0;t<r;t++){let a=await this.describeDBInstance(e);if(a?.DBInstanceStatus==="available")return a;if(["deleted","failed","incompatible-restore","incompatible-parameters"].includes(a?.DBInstanceStatus||""))throw Error(`DB instance ${e} is in terminal state: ${a?.DBInstanceStatus}`);await new Promise((i)=>setTimeout(i,s))}throw Error(`Timeout waiting for DB instance ${e} to become available`)}async waitForDBInstanceDeleted(e,r=60,s=30000){for(let t=0;t<r;t++)try{let a=await this.describeDBInstance(e);if(a?.DBInstanceStatus==="deleting"){await new Promise((i)=>setTimeout(i,s));continue}throw Error(`DB instance ${e} is in state: ${a?.DBInstanceStatus}`)}catch(a){if(a.code==="DBInstanceNotFound"||a.code==="DBInstanceNotFoundFault")return;throw a}throw Error(`Timeout waiting for DB instance ${e} to be deleted`)}}
2
+ export{z};
@@ -0,0 +1 @@
1
+ import{En,kh}from"./chunk-badb5mf3.js";import"./chunk-ms4dnha2.js";import"./chunk-3zzm5f28.js";import"./chunk-y6k0vwfn.js";export{En as EmailClient,kh as email};
@@ -1,22 +1,22 @@
1
- import{at,oi,ai,ci}from"./chunk-w9jhyy09.js";function S(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Jh(t,e="/var/www"){let n=`${e}/${t}-`;return["set -u",`for TS_CLOUD_DIR in ${n}*; do`,' [ -d "$TS_CLOUD_DIR" ] || continue',' [ -d "$TS_CLOUD_DIR/releases" ] || continue',` TS_CLOUD_SITE="\${TS_CLOUD_DIR#${n}}"`," TS_CLOUD_ACTIVE=no",` for TS_CLOUD_UNIT in $(ls /etc/systemd/system/ 2>/dev/null | grep -E "^${S(t)}-$TS_CLOUD_SITE[-@.]" || true); do`,' systemctl is-active "$TS_CLOUD_UNIT" >/dev/null 2>&1 && TS_CLOUD_ACTIVE=yes'," done",' TS_CLOUD_SIZE="$(du -sh "$TS_CLOUD_DIR" 2>/dev/null | cut -f1)"',' echo "site:$TS_CLOUD_SITE:$TS_CLOUD_ACTIVE:${TS_CLOUD_SIZE:-?}"',"done","exit 0"]}function Xh(t){if(!t)return[];let e=[];for(let n of t.split(`
2
- `)){let r=n.trim();if(!r.startsWith("site:"))continue;let[,s,o,i]=r.split(":");if(!s||o!=="no")continue;e.push({name:s,size:i||"?"})}return e}function Yh(t,e,n){let r=t.map((o)=>` ${e}-${o.name} (${o.size})`).join(`
1
+ import{dt,ci,di,li}from"./chunk-cfrv8110.js";function S(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Zh(t,e="/var/www"){let n=`${e}/${t}-`;return["set -u",`for TS_CLOUD_DIR in ${n}*; do`,' [ -d "$TS_CLOUD_DIR" ] || continue',' [ -d "$TS_CLOUD_DIR/releases" ] || continue',` TS_CLOUD_SITE="\${TS_CLOUD_DIR#${n}}"`," TS_CLOUD_ACTIVE=no",` for TS_CLOUD_UNIT in $(ls /etc/systemd/system/ 2>/dev/null | grep -E "^${S(t)}-$TS_CLOUD_SITE[-@.]" || true); do`,' systemctl is-active "$TS_CLOUD_UNIT" >/dev/null 2>&1 && TS_CLOUD_ACTIVE=yes'," done",' TS_CLOUD_SIZE="$(du -sh "$TS_CLOUD_DIR" 2>/dev/null | cut -f1)"',' echo "site:$TS_CLOUD_SITE:$TS_CLOUD_ACTIVE:${TS_CLOUD_SIZE:-?}"',"done","exit 0"]}function ef(t){if(!t)return[];let e=[];for(let n of t.split(`
2
+ `)){let r=n.trim();if(!r.startsWith("site:"))continue;let[,s,o,i]=r.split(":");if(!s||o!=="no")continue;e.push({name:s,size:i||"?"})}return e}function tf(t,e,n){let r=t.map((o)=>` ${e}-${o.name} (${o.size})`).join(`
3
3
  `),s=t.length===1?"it":"them";return`This server still holds ${t.length} site tree${t.length===1?"":"s"} with nothing running for ${s}:
4
4
  ${r}
5
5
  `+"A site moved off this box keeps its files here on purpose — they are the rollback, and they are what makes "+`the move reversible until this server is destroyed. Destroying it now discards that.
6
- Verify the site is serving from its new home first, then re-run with ${n} to destroy it anyway.`}var lp="ts-cloud/project",up="ts-cloud/environment",pp="ts-cloud/role";function d(t){return typeof t==="string"&&t.trim()?t.trim():void 0}function h(t){if(typeof t==="string")return d(t);if(t&&typeof t==="object")return d(t.name);return}function Zh(t){let e={};for(let[n,r]of Object.entries(t?.labels??{}))if(typeof r==="string")e[n]=r;return{id:String(t?.id??""),name:d(t?.name)??"(unnamed)",status:d(t?.status)??"unknown",ipv4:d(t?.public_net?.ipv4?.ip)??d(t?.ipv4),ipv6:d(t?.public_net?.ipv6?.ip)??d(t?.ipv6),type:d(t?.server_type?.name)??d(t?.type),location:h(t?.location)??h(t?.datacenter?.location)??h(t?.datacenter),labels:e,project:d(e[lp]),environment:d(e[up]),role:d(e[pp])}}function w(t){return t.slug?.trim()||"app"}function gp(t){let e=[];for(let n of t){let r=w(n);for(let s of n.proxies??[]){let o=d(s?.to);if(!o)continue;e.push({slug:r,host:o,path:d(s?.path)??"/",...x(s)})}}return e.sort((n,r)=>n.slug.localeCompare(r.slug)||n.host.localeCompare(r.host)||n.path.localeCompare(r.path))}function x(t){let e=t?.from;if(typeof e==="string"&&e.trim())return{target:e.trim(),kind:"app"};if(Array.isArray(e)&&e.length>0)return{target:e.filter((s)=>typeof s==="string").join(", "),kind:"app"};let n=t?.static;if(typeof n==="string"&&n.trim())return{target:n.trim(),kind:"static"};if(n&&typeof n==="object"&&d(n.dir))return{target:d(n.dir),kind:"static"};let r=typeof t?.redirect==="string"?d(t.redirect):d(t?.redirect?.to);if(r)return{target:r,kind:"redirect"};return{target:"(no upstream)",kind:"unknown"}}function mp(t){let e=new Map;for(let n of t){let r=e.get(n.slug);if(r)r.push(n);else e.set(n.slug,[n])}return[...e.entries()].map(([n,r])=>({slug:n,routes:r})).sort((n,r)=>r.routes.length-n.routes.length||n.slug.localeCompare(r.slug))}async function ef(t,e,n=at){if(!t.ipv4)return{server:t.name,routes:[],unavailable:"no public IPv4 address to reach it on"};if(t.status!=="running")return{server:t.name,ip:t.ipv4,routes:[],unavailable:`server is ${t.status}`};try{let r=await e(t.ipv4,ai(n));if(r.code!==0){let s=r.stderr.trim().split(`
7
- `)[0]||`remote command exited ${r.code}`;return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}return{server:t.name,ip:t.ipv4,routes:gp(ci(r.stdout))}}catch(r){let s=r instanceof Error?r.message.split(`
8
- `)[0]:String(r);return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}}function u(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function tf(t,e,n){let r=new Set(e.filter((a)=>a.slug===n).map((a)=>u(a.host,a.path))),s=[],o=[],i=[];for(let a of t)if(a.loopbackOnly)i.push(a);else if(a.domain&&r.has(u(a.domain,a.path)))s.push(a);else o.push(a);return{present:s,absent:o,loopback:i,foreign:e.filter((a)=>a.slug!==n)}}function hp(t,e,n){let r=new Set;for(let s of e)for(let o of s.routes)if(o.slug===n)r.add(u(o.host,o.path));return t.filter((s)=>!s.loopbackOnly&&s.domain!==void 0&&!r.has(u(s.domain,s.path)))}function rf(t){let{slug:e,servers:n,probes:r,declared:s}=t,o=[];if(o.push(n.length===0?"No servers found.":`${n.length} server${n.length===1?"":"s"}:`),n.length>0)o.push("");let i=new Map(r.map((a)=>[a.server,a]));for(let a of n){let p=[a.ipv4,a.type,a.location,a.status].filter(Boolean);o.push(` ${a.name} ${p.join(" ")}`),o.push(` ${k(a)}`);let c=i.get(a.name);if(!c)o.push(" not probed, so co-tenants on this box are not listed");else if(c.unavailable)o.push(` could not read ${at}: ${c.unavailable}`);else o.push(...P(c,e));o.push("")}return o.push(...C(t)),o}function k(t){if(!t.project)return"no ts-cloud labels: provisioned outside ts-cloud, or by a version that did not label boxes";let e=[t.environment,t.role&&`role ${t.role}`].filter(Boolean).join(", ");return`owned by '${t.project}'${e?` (${e})`:""}`}function P(t,e){let n=mp(t.routes);if(n.length===0)return[` serves nothing: ${at} is empty or absent`];let r=[` serves ${t.routes.length} route${t.routes.length===1?"":"s"} for ${n.length} project${n.length===1?"":"s"}:`];for(let s of n){r.push(` ${s.slug}${s.slug===e?" (this project)":""}`);for(let o of s.routes)r.push(` ${o.host}${o.path==="/"?"/":o.path} -> ${O(o)}`)}return r}function O(t){if(t.kind==="redirect")return`redirect to ${t.target}`;if(t.kind==="static")return`static ${t.target}`;return t.target}function C(t){let{slug:e,declared:n,probes:r,servers:s}=t;if(n.length===0)return[`This project ('${e}') declares no sites.`];let o=[`This project ('${e}') declares ${n.length} site${n.length===1?"":"s"}: `+n.map((c)=>c.name).join(", ")],i=n.filter((c)=>c.loopbackOnly);if(i.length>0)o.push(` ${i.length} with no domain, so the gateway never routes ${i.length===1?"it":"them"} (reached through another site's proxy): ${i.map((c)=>c.name).join(", ")}`);let a=r.filter((c)=>!c.unavailable);if(a.length===0)return o.push(" Nothing to reconcile them against: no box reported what it serves."),o;let p=hp(n,a,e);if(o.push(` ${n.length-i.length-p.length} routed by a box above`),p.length>0){o.push(` ${p.length} not routed by any box above: ${p.map((b)=>b.name).join(", ")}`);let c=r.length-a.length,g=s.length-r.length;if(c>0)o.push(` Either they were never deployed, or they are on one of the ${c} server${c===1?"":"s"} that could not be read.`);else if(g>0)o.push(` Either they were never deployed, or they are on one of the ${g} server${g===1?"":"s"} this run did not probe.`);else o.push(" Either they were never deployed, or they are on a server this listing did not cover.")}return o}async function nf(t){let e=[];for(let n of t.steps)try{e.push({step:n,state:await n.satisfied()?"satisfied":"pending"})}catch(r){e.push({step:n,state:"unknown",reason:r instanceof Error?r.message:String(r)})}return e}function Rc(t){return t.filter((e)=>e.state!=="satisfied")}function fp(t){return Rc(t).some((e)=>e.step.destructive===!0)}function sf(t,e){let n=Rc(e),r=[`${t.operation} ${t.target}`];if(n.length===0)return r.push(" Nothing to do — every step is already satisfied."),r;for(let{step:o,state:i,reason:a}of e){let p=i==="satisfied"?"ok ":i==="unknown"?"? ":"→ ",c=[o.destructive?"DESTRUCTIVE":"",i==="satisfied"?"already done":""].filter(Boolean);if(r.push(` ${p}${o.title}${c.length>0?` [${c.join(", ")}]`:""}`),o.change)r.push(` ${o.change.from} → ${o.change.to}`);if(a)r.push(` could not check: ${a}`)}let s=n.filter((o)=>o.step.destructive).length;return r.push(` ${n.length} step(s) would run`+(s>0?`, ${s} irreversible — re-run with --confirm ${t.target}`:"")),r}async function of(t,e,n={}){let r={operation:t.operation,target:t.target,steps:[],success:!0};if(fp(e)&&n.confirm!==t.target)throw Error(`${t.operation} includes an irreversible step. Re-run with --confirm ${t.target} to authorize it.`);for(let{step:s,state:o}of e){if(o==="satisfied"){r.steps.push({id:s.id,title:s.title,state:"skipped"}),n.log?.(`skip ${s.title} (already done)`);continue}n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"started"});try{await s.apply(),r.steps.push({id:s.id,title:s.title,state:"applied"}),n.log?.(`done ${s.title}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"applied"})}catch(i){let a=i instanceof Error?i.message:String(i);return r.steps.push({id:s.id,title:s.title,state:"failed",error:a}),r.success=!1,n.log?.(`FAIL ${s.title}: ${a}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"failed",error:a}),r}}return r}function Ap(t){if(t.length===0)throw Error("A server name cannot be empty.");if(t.length>253)throw Error(`'${t}' is longer than the 253 characters a hostname allows.`);for(let e of t.split(".")){if(e.length===0)throw Error(`'${t}' has an empty label — a hostname cannot contain '..'.`);if(e.length>63)throw Error(`'${e}' is longer than the 63 characters a hostname label allows.`);if(!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e))throw Error(`'${e}' is not a valid hostname label. Use letters, digits and hyphens, not starting or ending with a hyphen.`)}}async function af(t,e,n){if(Ap(e),t===e)throw Error(`'${t}' is already named that.`);if((await n.takenNames()).some((o)=>o===e&&o!==t))throw Error(`'${e}' is already taken. Server names have to be unique within a provider project.`);let s=[];if(n.providerName&&n.renameProvider){let{providerName:o,renameProvider:i}=n;s.push({id:"provider",title:"Rename the server at the provider",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}if(n.stateName&&n.writeStateName){let{stateName:o,writeStateName:i}=n;s.push({id:"state-pin",title:"Update the recorded name in the local driver state",change:{from:t,to:e},satisfied:async()=>{let a=await o();return a===void 0||a===e},apply:()=>i(e)})}if(n.remoteHostname&&n.setRemoteHostname){let{remoteHostname:o,setRemoteHostname:i}=n;s.push({id:"hostname",title:"Set the hostname on the box",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}return s.push({id:"inventory",title:"Rename the fleet inventory record",change:{from:t,to:e},satisfied:async()=>n.inventoryName()===e,apply:async()=>{await n.renameInventory(e)}}),{operation:"server:rename",target:t,steps:s}}function cf(t){let e=`'${t.replace(/'/g,`'"'"'`)}'`;return["set -eu",'TS_CLOUD_OLD="$(hostname)"',`hostnamectl set-hostname ${e} 2>/dev/null || { echo ${e} > /etc/hostname && hostname ${e}; }`,'if grep -q "^127.0.1.1" /etc/hosts; then',` TS_CLOUD_HOSTS="$(sed -E "s/^127\\.0\\.1\\.1.*/127.0.1.1\\t${t}/" /etc/hosts)"`,` printf '%s\\n' "$TS_CLOUD_HOSTS" > /etc/hosts`,"else",` printf '127.0.1.1\\t%s\\n' ${e} >> /etc/hosts`,"fi",'printf "%s -> %s\\n" "$TS_CLOUD_OLD" "$(hostname)"'].join(`
9
- `)}function df(t,e,n){let r=e.trim();if(!r)return{problem:"No server named."};let[s,...o]=t.filter((c)=>c.name===r);if(s&&o.length===0)return{server:s};let i=t.filter((c)=>c.project===r);if(i.length>1&&n)i=i.filter((c)=>!c.environment||c.environment===n);let[a,...p]=i;if(a&&p.length===0)return{server:a};if(i.length>1)return{problem:`'${r}' owns ${i.length} servers (${i.map((c)=>c.name).join(", ")}). Name one of them, or narrow it by environment.`};return{problem:`No server matched '${r}'. Nothing is named that, and no box carries the label ts-cloud/project=${r}.`}}function lf(t,e){let n=[];if(!e.project)n.push(`'${e.name}' carries no ts-cloud/project label, so it is not a box ts-cloud provisioned. Attaching to it would deploy into a host nothing manages.`);else if(e.project===t)n.push(`This project's slug is '${t}', which is also the slug that owns '${e.name}'. A tenant deploy owns the gateway fragment named after its slug, so attaching would overwrite '${e.project}'s own fragment and take its sites down. Change this project's slug first.`);if(e.status!=="running")n.push(`'${e.name}' is ${e.status}, so what it serves could not be read.`);if(!e.ipv4)n.push(`'${e.name}' has no public IPv4 address, so it cannot be reached to check what it serves.`);return n}function f(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function uf(t,e,n){let r=[],s=oi(n.filter((i)=>i.kind==="app").map((i)=>({slug:i.slug,proxies:[{from:i.target.split(",").map((a)=>a.trim())}]})),{ignoreSlug:t}),o=new Map;for(let i of n)if(i.slug!==t)o.set(f(i.host,i.path),i.slug);for(let i of e){if(i.port!==void 0){let a=s.get(i.port);if(a)r.push({kind:"port",site:i.name,detail:`port ${i.port}`,heldBy:a})}if(i.domain){let a=o.get(f(i.domain,i.path));if(a)r.push({kind:"route",site:i.name,detail:`${i.domain}${i.path==="/"?"/":i.path}`,heldBy:a})}}return r}function pf(t){return t.registryRead&&t.conflicts.length===0}function gf(t){let{slug:e,owner:n,server:r,declared:s,conflicts:o}=t,i=[];i.push(`Attach '${e}' to '${r.name}' (${r.ipv4??"no IPv4"}), owned by '${n}'.`,""),i.push(` ${s.length} site${s.length===1?"":"s"} would deploy onto this box:`);for(let a of s){let p=a.loopbackOnly?`loopback only${a.port?` on :${a.port}`:""}`:`${a.domain}${a.path==="/"?"/":a.path}${a.port?` on :${a.port}`:""}`;i.push(` ${a.name} ${p} -> ${a.installBase??"(install path unresolved)"}`)}if(i.push(""),!t.registryRead)i.push(` Could not read what '${r.name}' already serves: ${t.registryProblem??"unknown reason"}`),i.push(" So this attach is UNCHECKED: a port or hostname already taken by another"),i.push(" project would not error, it would serve that project's site from your domain.");else if(o.length>0){i.push(` ${o.length} conflict${o.length===1?"":"s"} with what the box already serves:`);for(let a of o)i.push(` site '${a.site}' wants ${a.detail}, held by '${a.heldBy}'`);i.push(""),i.push(" Two services on one port do not error: the kernel load-balances, and each"),i.push(" domain serves the other's site about half the time. Pick free ports and"),i.push(" hostnames, then re-run.")}else i.push(` No conflicts with what '${r.name}' already serves.`);return i}function si(t,e){return`/tmp/ts-cloud-move-${t}-${e}.tar.gz`}function Dc(t,e){return`${t}-${e}*.service`}function l(t){return`'${t.split("'").join("'\\''")}'`}function yp(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(m(t,e))} || true); do`,' systemctl stop "$unit" 2>/dev/null || true',"done"].join(`
10
- `)}function m(t,e){return`^${t}-${e}-((queue|daemon)-.*|scheduler)\\.service$`}function Ip(t,e){return y(m(t,e))}function y(t){return[`ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(t)} | while read -r unit; do`,' systemctl is-active "$unit" >/dev/null 2>&1 && echo "active:$unit" || true',"done"].join(`
11
- `)}function Sp(t){return!t.split(`
12
- `).some((e)=>e.trim().startsWith("active:"))}function Cp(t,e,n){let r=si(t,e);return["set -eu",`test -d ${l(n)} || { echo "no site tree at ${n}" >&2; exit 1; }`,`rm -f ${l(r)}`,`tar czf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})" -C /etc/systemd/system $(cd /etc/systemd/system && ls ${Dc(t,e)} 2>/dev/null | tr '\\n' ' ')`,`sha256sum ${l(r)} | cut -d' ' -f1`].join(`
13
- `)}function Ep(t,e,n){let r=si(t,e);return["set -eu",`test -f ${l(r)} || { echo "archive not staged at ${r}" >&2; exit 1; }`,`mkdir -p "$(dirname ${l(n)})"`,`tar xzf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})"`,`tar xzf ${l(r)} -C /etc/systemd/system --wildcards ${l(Dc(t,e))} 2>/dev/null || true`,"systemctl daemon-reload",`systemctl enable ${t}-${e}.service 2>/dev/null || true`,`systemctl restart ${t}-${e}.service`,`rm -f ${l(r)}`].join(`
14
- `)}function bp(t,e,n){return[`test -d ${l(n)} && echo tree:present || echo tree:absent`,`systemctl is-active ${t}-${e}.service >/dev/null 2>&1 && echo unit:active || echo unit:inactive`].join(`
15
- `)}function vp(t){return t.includes("tree:present")&&t.includes("unit:active")}function Tp(t,e="/",n=10){let r=`http://127.0.0.1:${t}${e.startsWith("/")?e:`/${e}`}`;return["set -eu",`for i in $(seq 1 ${n}); do`,` if curl -fsS -o /dev/null --max-time 5 ${l(r)}; then echo healthy; exit 0; fi`," sleep 3","done",`echo "no healthy response from ${r}" >&2`,"exit 1"].join(`
16
- `)}function wp(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(v(t,e))} || true); do`,' systemctl disable --now "$unit" 2>/dev/null || true',"done",`rm -f /etc/rpx/sites.d/${t}.json 2>/dev/null || true`,"systemctl reload rpx-gateway.service 2>/dev/null || systemctl restart rpx-gateway.service 2>/dev/null || true"].join(`
17
- `)}function v(t,e){return`^${t}-${e}[-@.]`}function Rp(t,e){return y(v(t,e))}function Dp(t){return!t.split(`
18
- `).some((e)=>e.trim().startsWith("active:"))}function mf(t,e){return`/tmp/ts-cloud-move-${t}-${e}-certs.tar.gz`}function hf(t,e){return["set -u",...e.map((n)=>`if [ -s ${l(`${t}/${n}.crt`)} ]; then echo "cert:${n}:$(sha256sum ${l(`${t}/${n}.crt`)} | cut -d' ' -f1)"; else echo "cert:${n}:absent"; fi`)].join(`
19
- `)}function ff(t){let e=new Map;for(let n of t.split(`
20
- `)){let r=n.trim();if(!r.startsWith("cert:"))continue;let[,s,o]=r.split(":");if(s&&o)e.set(s,o)}return e}function Af(t,e){for(let[n,r]of t){if(r==="absent")continue;if(e.get(n)!==r)return!1}return!0}function yf(t,e,n){let r=e.flatMap((s)=>[`${s}.crt`,`${s}.key`]);return["set -eu",`rm -f ${l(n)}`,`cd ${l(t)} 2>/dev/null || { echo "no certs dir at ${t}" >&2; exit 0; }`,`TS_CLOUD_CERTS="$(ls ${r.map(l).join(" ")} 2>/dev/null | tr '\\n' ' ' || true)"`,'[ -n "$TS_CLOUD_CERTS" ] || { echo "no certificates to carry"; exit 0; }',`tar czf ${l(n)} $TS_CLOUD_CERTS`].join(`
21
- `)}function If(t,e){return["set -eu",`[ -s ${l(e)} ] || { echo "no certificate archive staged"; exit 0; }`,`mkdir -p ${l(t)}`,`tar xzf ${l(e)} -C ${l(t)}`,`chmod 600 ${l(t)}/*.key 2>/dev/null || true`,`rm -f ${l(e)}`].join(`
22
- `)}async function Sf(t,e){let{slug:n,siteName:r,appBase:s,from:o,to:i,targetAddress:a}=t;if(o===i)throw Error(`'${r}' is already on ${i}.`);if(t.database&&!e.database)throw Error(`'${r}' uses the on-box database '${t.database.name}', which lives in the engine's own data directory rather than in the site tree, and this move has no way to carry it. Moving the site without it would cut traffic over to an empty database.`);if(t.database&&e.database&&await e.database.targetHasData())throw Error(`${i} already has a database named '${t.database.name}' with tables in it. Restoring this site's dump over it would destroy that data. Rename or drop it on the target first, or point this project at a different database name.`);let p=[{id:"pause-workers",title:`Stop background work on ${o} so the snapshot is consistent`,satisfied:async()=>Sp(await e.runOnSource(Ip(n,r))),apply:async()=>{await e.runOnSource(yp(n,r))}},...e.database?[{id:"database-dump",title:`Dump the '${t.database?.name}' database on ${o}`,satisfied:async()=>!1,apply:()=>e.database.dump()}]:[],{id:"snapshot",title:`Archive the site's tree and units on ${o}`,change:{from:`${o}:${s}`,to:si(n,r)},satisfied:async()=>!1,apply:async()=>{await e.runOnSource(Cp(n,r,s))}},{id:"transfer",title:`Carry the archive to ${i}`,change:{from:o,to:i},satisfied:()=>e.archiveStaged(),apply:()=>e.transferArchive()},...e.database?[{id:"database-transfer",title:`Carry the database dump to ${i}`,change:{from:o,to:i},satisfied:()=>e.database.dumpStaged(),apply:()=>e.database.transferDump()},{id:"database-restore",title:`Create and load '${t.database?.name}' on ${i}`,satisfied:async()=>!1,apply:()=>e.database.restore()}]:[],{id:"restore",title:`Unpack the site on ${i} and start it`,change:{from:si(n,r),to:`${i}:${s}`},satisfied:async()=>vp(await e.runOnTarget(bp(n,r,s))),apply:async()=>{await e.runOnTarget(Ep(n,r,s))}}];if(t.port!=null){let{port:c}=t;p.push({id:"health",title:`Wait for the site to answer on ${i} (127.0.0.1:${c})`,satisfied:async()=>!1,apply:async()=>{await e.runOnTarget(Tp(c,t.healthCheckPath??"/"))}})}return p.push(...e.certificates?[{id:"certificates",title:`Carry the site's TLS material to ${i}`,satisfied:()=>e.certificates.inPlace(),apply:()=>e.certificates.carry()}]:[],{id:"gateway",title:`Route the site on ${i}`,satisfied:()=>e.targetRoutesSite(),apply:()=>e.refreshTargetGateway()},{id:"dns",title:`Point DNS at ${i}`,change:{from:`${o}`,to:a},satisfied:async()=>await e.publishedAddress()===a,apply:async()=>{let c=await e.cutoverDns();if(c.length>0)throw Error(c.join("; "))}},{id:"drain-source",title:`Stop the site on ${o}, leaving its files in place`,satisfied:async()=>Dp(await e.runOnSource(Rp(n,r))),apply:async()=>{await e.runOnSource(wp(n,r))}}),{operation:"site:move",target:r,steps:p}}export{Jh,Xh,Yh,lp,up,pp,Zh,gp,mp,ef,tf,hp,rf,nf,Rc,fp,sf,of,Ap,af,cf,df,lf,uf,pf,gf,si,Dc,yp,Ip,Sp,Cp,Ep,bp,vp,Tp,wp,Rp,Dp,mf,hf,ff,Af,yf,If,Sf};
6
+ Verify the site is serving from its new home first, then re-run with ${n} to destroy it anyway.`}var gp="ts-cloud/project",mp="ts-cloud/environment",hp="ts-cloud/role";function d(t){return typeof t==="string"&&t.trim()?t.trim():void 0}function h(t){if(typeof t==="string")return d(t);if(t&&typeof t==="object")return d(t.name);return}function rf(t){let e={};for(let[n,r]of Object.entries(t?.labels??{}))if(typeof r==="string")e[n]=r;return{id:String(t?.id??""),name:d(t?.name)??"(unnamed)",status:d(t?.status)??"unknown",ipv4:d(t?.public_net?.ipv4?.ip)??d(t?.ipv4),ipv6:d(t?.public_net?.ipv6?.ip)??d(t?.ipv6),type:d(t?.server_type?.name)??d(t?.type),location:h(t?.location)??h(t?.datacenter?.location)??h(t?.datacenter),labels:e,project:d(e[gp]),environment:d(e[mp]),role:d(e[hp])}}function w(t){return t.slug?.trim()||"app"}function fp(t){let e=[];for(let n of t){let r=w(n);for(let s of n.proxies??[]){let o=d(s?.to);if(!o)continue;e.push({slug:r,host:o,path:d(s?.path)??"/",...x(s)})}}return e.sort((n,r)=>n.slug.localeCompare(r.slug)||n.host.localeCompare(r.host)||n.path.localeCompare(r.path))}function x(t){let e=t?.from;if(typeof e==="string"&&e.trim())return{target:e.trim(),kind:"app"};if(Array.isArray(e)&&e.length>0)return{target:e.filter((s)=>typeof s==="string").join(", "),kind:"app"};let n=t?.static;if(typeof n==="string"&&n.trim())return{target:n.trim(),kind:"static"};if(n&&typeof n==="object"&&d(n.dir))return{target:d(n.dir),kind:"static"};let r=typeof t?.redirect==="string"?d(t.redirect):d(t?.redirect?.to);if(r)return{target:r,kind:"redirect"};return{target:"(no upstream)",kind:"unknown"}}function Ap(t){let e=new Map;for(let n of t){let r=e.get(n.slug);if(r)r.push(n);else e.set(n.slug,[n])}return[...e.entries()].map(([n,r])=>({slug:n,routes:r})).sort((n,r)=>r.routes.length-n.routes.length||n.slug.localeCompare(r.slug))}async function nf(t,e,n=dt){if(!t.ipv4)return{server:t.name,routes:[],unavailable:"no public IPv4 address to reach it on"};if(t.status!=="running")return{server:t.name,ip:t.ipv4,routes:[],unavailable:`server is ${t.status}`};try{let r=await e(t.ipv4,di(n));if(r.code!==0){let s=r.stderr.trim().split(`
7
+ `)[0]||`remote command exited ${r.code}`;return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}return{server:t.name,ip:t.ipv4,routes:fp(li(r.stdout))}}catch(r){let s=r instanceof Error?r.message.split(`
8
+ `)[0]:String(r);return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}}function u(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function sf(t,e,n){let r=new Set(e.filter((a)=>a.slug===n).map((a)=>u(a.host,a.path))),s=[],o=[],i=[];for(let a of t)if(a.loopbackOnly)i.push(a);else if(a.domain&&r.has(u(a.domain,a.path)))s.push(a);else o.push(a);return{present:s,absent:o,loopback:i,foreign:e.filter((a)=>a.slug!==n)}}function yp(t,e,n){let r=new Set;for(let s of e)for(let o of s.routes)if(o.slug===n)r.add(u(o.host,o.path));return t.filter((s)=>!s.loopbackOnly&&s.domain!==void 0&&!r.has(u(s.domain,s.path)))}function of(t){let{slug:e,servers:n,probes:r,declared:s}=t,o=[];if(o.push(n.length===0?"No servers found.":`${n.length} server${n.length===1?"":"s"}:`),n.length>0)o.push("");let i=new Map(r.map((a)=>[a.server,a]));for(let a of n){let p=[a.ipv4,a.type,a.location,a.status].filter(Boolean);o.push(` ${a.name} ${p.join(" ")}`),o.push(` ${k(a)}`);let c=i.get(a.name);if(!c)o.push(" not probed, so co-tenants on this box are not listed");else if(c.unavailable)o.push(` could not read ${dt}: ${c.unavailable}`);else o.push(...P(c,e));o.push("")}return o.push(...C(t)),o}function k(t){if(!t.project)return"no ts-cloud labels: provisioned outside ts-cloud, or by a version that did not label boxes";let e=[t.environment,t.role&&`role ${t.role}`].filter(Boolean).join(", ");return`owned by '${t.project}'${e?` (${e})`:""}`}function P(t,e){let n=Ap(t.routes);if(n.length===0)return[` serves nothing: ${dt} is empty or absent`];let r=[` serves ${t.routes.length} route${t.routes.length===1?"":"s"} for ${n.length} project${n.length===1?"":"s"}:`];for(let s of n){r.push(` ${s.slug}${s.slug===e?" (this project)":""}`);for(let o of s.routes)r.push(` ${o.host}${o.path==="/"?"/":o.path} -> ${O(o)}`)}return r}function O(t){if(t.kind==="redirect")return`redirect to ${t.target}`;if(t.kind==="static")return`static ${t.target}`;return t.target}function C(t){let{slug:e,declared:n,probes:r,servers:s}=t;if(n.length===0)return[`This project ('${e}') declares no sites.`];let o=[`This project ('${e}') declares ${n.length} site${n.length===1?"":"s"}: `+n.map((c)=>c.name).join(", ")],i=n.filter((c)=>c.loopbackOnly);if(i.length>0)o.push(` ${i.length} with no domain, so the gateway never routes ${i.length===1?"it":"them"} (reached through another site's proxy): ${i.map((c)=>c.name).join(", ")}`);let a=r.filter((c)=>!c.unavailable);if(a.length===0)return o.push(" Nothing to reconcile them against: no box reported what it serves."),o;let p=yp(n,a,e);if(o.push(` ${n.length-i.length-p.length} routed by a box above`),p.length>0){o.push(` ${p.length} not routed by any box above: ${p.map((b)=>b.name).join(", ")}`);let c=r.length-a.length,g=s.length-r.length;if(c>0)o.push(` Either they were never deployed, or they are on one of the ${c} server${c===1?"":"s"} that could not be read.`);else if(g>0)o.push(` Either they were never deployed, or they are on one of the ${g} server${g===1?"":"s"} this run did not probe.`);else o.push(" Either they were never deployed, or they are on a server this listing did not cover.")}return o}async function af(t){let e=[];for(let n of t.steps)try{e.push({step:n,state:await n.satisfied()?"satisfied":"pending"})}catch(r){e.push({step:n,state:"unknown",reason:r instanceof Error?r.message:String(r)})}return e}function Nc(t){return t.filter((e)=>e.state!=="satisfied")}function Ip(t){return Nc(t).some((e)=>e.step.destructive===!0)}function cf(t,e){let n=Nc(e),r=[`${t.operation} ${t.target}`];if(n.length===0)return r.push(" Nothing to do — every step is already satisfied."),r;for(let{step:o,state:i,reason:a}of e){let p=i==="satisfied"?"ok ":i==="unknown"?"? ":"→ ",c=[o.destructive?"DESTRUCTIVE":"",i==="satisfied"?"already done":""].filter(Boolean);if(r.push(` ${p}${o.title}${c.length>0?` [${c.join(", ")}]`:""}`),o.change)r.push(` ${o.change.from} → ${o.change.to}`);if(a)r.push(` could not check: ${a}`)}let s=n.filter((o)=>o.step.destructive).length;return r.push(` ${n.length} step(s) would run`+(s>0?`, ${s} irreversible — re-run with --confirm ${t.target}`:"")),r}async function df(t,e,n={}){let r={operation:t.operation,target:t.target,steps:[],success:!0};if(Ip(e)&&n.confirm!==t.target)throw Error(`${t.operation} includes an irreversible step. Re-run with --confirm ${t.target} to authorize it.`);for(let{step:s,state:o}of e){if(o==="satisfied"){r.steps.push({id:s.id,title:s.title,state:"skipped"}),n.log?.(`skip ${s.title} (already done)`);continue}n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"started"});try{await s.apply(),r.steps.push({id:s.id,title:s.title,state:"applied"}),n.log?.(`done ${s.title}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"applied"})}catch(i){let a=i instanceof Error?i.message:String(i);return r.steps.push({id:s.id,title:s.title,state:"failed",error:a}),r.success=!1,n.log?.(`FAIL ${s.title}: ${a}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"failed",error:a}),r}}return r}function Sp(t){if(t.length===0)throw Error("A server name cannot be empty.");if(t.length>253)throw Error(`'${t}' is longer than the 253 characters a hostname allows.`);for(let e of t.split(".")){if(e.length===0)throw Error(`'${t}' has an empty label — a hostname cannot contain '..'.`);if(e.length>63)throw Error(`'${e}' is longer than the 63 characters a hostname label allows.`);if(!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e))throw Error(`'${e}' is not a valid hostname label. Use letters, digits and hyphens, not starting or ending with a hyphen.`)}}async function lf(t,e,n){if(Sp(e),t===e)throw Error(`'${t}' is already named that.`);if((await n.takenNames()).some((o)=>o===e&&o!==t))throw Error(`'${e}' is already taken. Server names have to be unique within a provider project.`);let s=[];if(n.providerName&&n.renameProvider){let{providerName:o,renameProvider:i}=n;s.push({id:"provider",title:"Rename the server at the provider",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}if(n.stateName&&n.writeStateName){let{stateName:o,writeStateName:i}=n;s.push({id:"state-pin",title:"Update the recorded name in the local driver state",change:{from:t,to:e},satisfied:async()=>{let a=await o();return a===void 0||a===e},apply:()=>i(e)})}if(n.remoteHostname&&n.setRemoteHostname){let{remoteHostname:o,setRemoteHostname:i}=n;s.push({id:"hostname",title:"Set the hostname on the box",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}return s.push({id:"inventory",title:"Rename the fleet inventory record",change:{from:t,to:e},satisfied:async()=>n.inventoryName()===e,apply:async()=>{await n.renameInventory(e)}}),{operation:"server:rename",target:t,steps:s}}function uf(t){let e=`'${t.replace(/'/g,`'"'"'`)}'`;return["set -eu",'TS_CLOUD_OLD="$(hostname)"',`hostnamectl set-hostname ${e} 2>/dev/null || { echo ${e} > /etc/hostname && hostname ${e}; }`,'if grep -q "^127.0.1.1" /etc/hosts; then',` TS_CLOUD_HOSTS="$(sed -E "s/^127\\.0\\.1\\.1.*/127.0.1.1\\t${t}/" /etc/hosts)"`,` printf '%s\\n' "$TS_CLOUD_HOSTS" > /etc/hosts`,"else",` printf '127.0.1.1\\t%s\\n' ${e} >> /etc/hosts`,"fi",'printf "%s -> %s\\n" "$TS_CLOUD_OLD" "$(hostname)"'].join(`
9
+ `)}function pf(t,e,n){let r=e.trim();if(!r)return{problem:"No server named."};let[s,...o]=t.filter((c)=>c.name===r);if(s&&o.length===0)return{server:s};let i=t.filter((c)=>c.project===r);if(i.length>1&&n)i=i.filter((c)=>!c.environment||c.environment===n);let[a,...p]=i;if(a&&p.length===0)return{server:a};if(i.length>1)return{problem:`'${r}' owns ${i.length} servers (${i.map((c)=>c.name).join(", ")}). Name one of them, or narrow it by environment.`};return{problem:`No server matched '${r}'. Nothing is named that, and no box carries the label ts-cloud/project=${r}.`}}function gf(t,e){let n=[];if(!e.project)n.push(`'${e.name}' carries no ts-cloud/project label, so it is not a box ts-cloud provisioned. Attaching to it would deploy into a host nothing manages.`);else if(e.project===t)n.push(`This project's slug is '${t}', which is also the slug that owns '${e.name}'. A tenant deploy owns the gateway fragment named after its slug, so attaching would overwrite '${e.project}'s own fragment and take its sites down. Change this project's slug first.`);if(e.status!=="running")n.push(`'${e.name}' is ${e.status}, so what it serves could not be read.`);if(!e.ipv4)n.push(`'${e.name}' has no public IPv4 address, so it cannot be reached to check what it serves.`);return n}function f(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function mf(t,e,n){let r=[],s=ci(n.filter((i)=>i.kind==="app").map((i)=>({slug:i.slug,proxies:[{from:i.target.split(",").map((a)=>a.trim())}]})),{ignoreSlug:t}),o=new Map;for(let i of n)if(i.slug!==t)o.set(f(i.host,i.path),i.slug);for(let i of e){if(i.port!==void 0){let a=s.get(i.port);if(a)r.push({kind:"port",site:i.name,detail:`port ${i.port}`,heldBy:a})}if(i.domain){let a=o.get(f(i.domain,i.path));if(a)r.push({kind:"route",site:i.name,detail:`${i.domain}${i.path==="/"?"/":i.path}`,heldBy:a})}}return r}function hf(t){return t.registryRead&&t.conflicts.length===0}function ff(t){let{slug:e,owner:n,server:r,declared:s,conflicts:o}=t,i=[];i.push(`Attach '${e}' to '${r.name}' (${r.ipv4??"no IPv4"}), owned by '${n}'.`,""),i.push(` ${s.length} site${s.length===1?"":"s"} would deploy onto this box:`);for(let a of s){let p=a.loopbackOnly?`loopback only${a.port?` on :${a.port}`:""}`:`${a.domain}${a.path==="/"?"/":a.path}${a.port?` on :${a.port}`:""}`;i.push(` ${a.name} ${p} -> ${a.installBase??"(install path unresolved)"}`)}if(i.push(""),!t.registryRead)i.push(` Could not read what '${r.name}' already serves: ${t.registryProblem??"unknown reason"}`),i.push(" So this attach is UNCHECKED: a port or hostname already taken by another"),i.push(" project would not error, it would serve that project's site from your domain.");else if(o.length>0){i.push(` ${o.length} conflict${o.length===1?"":"s"} with what the box already serves:`);for(let a of o)i.push(` site '${a.site}' wants ${a.detail}, held by '${a.heldBy}'`);i.push(""),i.push(" Two services on one port do not error: the kernel load-balances, and each"),i.push(" domain serves the other's site about half the time. Pick free ports and"),i.push(" hostnames, then re-run.")}else i.push(` No conflicts with what '${r.name}' already serves.`);return i}function ai(t,e){return`/tmp/ts-cloud-move-${t}-${e}.tar.gz`}function kc(t,e){return`${t}-${e}*.service`}function l(t){return`'${t.split("'").join("'\\''")}'`}function Cp(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(m(t,e))} || true); do`,' systemctl stop "$unit" 2>/dev/null || true',"done"].join(`
10
+ `)}function m(t,e){return`^${t}-${e}-((queue|daemon)-.*|scheduler)\\.service$`}function Ep(t,e){return y(m(t,e))}function y(t){return[`ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(t)} | while read -r unit; do`,' systemctl is-active "$unit" >/dev/null 2>&1 && echo "active:$unit" || true',"done"].join(`
11
+ `)}function bp(t){return!t.split(`
12
+ `).some((e)=>e.trim().startsWith("active:"))}function vp(t,e,n){let r=ai(t,e);return["set -eu",`test -d ${l(n)} || { echo "no site tree at ${n}" >&2; exit 1; }`,`rm -f ${l(r)}`,`tar czf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})" -C /etc/systemd/system $(cd /etc/systemd/system && ls ${kc(t,e)} 2>/dev/null | tr '\\n' ' ')`,`sha256sum ${l(r)} | cut -d' ' -f1`].join(`
13
+ `)}function Tp(t,e,n){let r=ai(t,e);return["set -eu",`test -f ${l(r)} || { echo "archive not staged at ${r}" >&2; exit 1; }`,`mkdir -p "$(dirname ${l(n)})"`,`tar xzf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})"`,`tar xzf ${l(r)} -C /etc/systemd/system --wildcards ${l(kc(t,e))} 2>/dev/null || true`,"systemctl daemon-reload",`systemctl enable ${t}-${e}.service 2>/dev/null || true`,`systemctl restart ${t}-${e}.service`,`rm -f ${l(r)}`].join(`
14
+ `)}function wp(t,e,n){return[`test -d ${l(n)} && echo tree:present || echo tree:absent`,`systemctl is-active ${t}-${e}.service >/dev/null 2>&1 && echo unit:active || echo unit:inactive`].join(`
15
+ `)}function Rp(t){return t.includes("tree:present")&&t.includes("unit:active")}function Dp(t,e="/",n=10){let r=`http://127.0.0.1:${t}${e.startsWith("/")?e:`/${e}`}`;return["set -eu",`for i in $(seq 1 ${n}); do`,` if curl -fsS -o /dev/null --max-time 5 ${l(r)}; then echo healthy; exit 0; fi`," sleep 3","done",`echo "no healthy response from ${r}" >&2`,"exit 1"].join(`
16
+ `)}function Pp(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(v(t,e))} || true); do`,' systemctl disable --now "$unit" 2>/dev/null || true',"done",`rm -f /etc/rpx/sites.d/${t}.json 2>/dev/null || true`,"systemctl reload rpx-gateway.service 2>/dev/null || systemctl restart rpx-gateway.service 2>/dev/null || true"].join(`
17
+ `)}function v(t,e){return`^${t}-${e}[-@.]`}function Np(t,e){return y(v(t,e))}function kp(t){return!t.split(`
18
+ `).some((e)=>e.trim().startsWith("active:"))}function Af(t,e){return`/tmp/ts-cloud-move-${t}-${e}-certs.tar.gz`}function yf(t,e){return["set -u",...e.map((n)=>`if [ -s ${l(`${t}/${n}.crt`)} ]; then echo "cert:${n}:$(sha256sum ${l(`${t}/${n}.crt`)} | cut -d' ' -f1)"; else echo "cert:${n}:absent"; fi`)].join(`
19
+ `)}function If(t){let e=new Map;for(let n of t.split(`
20
+ `)){let r=n.trim();if(!r.startsWith("cert:"))continue;let[,s,o]=r.split(":");if(s&&o)e.set(s,o)}return e}function Sf(t,e){for(let[n,r]of t){if(r==="absent")continue;if(e.get(n)!==r)return!1}return!0}function Cf(t,e,n){let r=e.flatMap((s)=>[`${s}.crt`,`${s}.key`]);return["set -eu",`rm -f ${l(n)}`,`cd ${l(t)} 2>/dev/null || { echo "no certs dir at ${t}" >&2; exit 0; }`,`TS_CLOUD_CERTS="$(ls ${r.map(l).join(" ")} 2>/dev/null | tr '\\n' ' ' || true)"`,'[ -n "$TS_CLOUD_CERTS" ] || { echo "no certificates to carry"; exit 0; }',`tar czf ${l(n)} $TS_CLOUD_CERTS`].join(`
21
+ `)}function Ef(t,e){return["set -eu",`[ -s ${l(e)} ] || { echo "no certificate archive staged"; exit 0; }`,`mkdir -p ${l(t)}`,`tar xzf ${l(e)} -C ${l(t)}`,`chmod 600 ${l(t)}/*.key 2>/dev/null || true`,`rm -f ${l(e)}`].join(`
22
+ `)}async function bf(t,e){let{slug:n,siteName:r,appBase:s,from:o,to:i,targetAddress:a}=t;if(o===i)throw Error(`'${r}' is already on ${i}.`);if(t.database&&!e.database)throw Error(`'${r}' uses the on-box database '${t.database.name}', which lives in the engine's own data directory rather than in the site tree, and this move has no way to carry it. Moving the site without it would cut traffic over to an empty database.`);if(t.database&&e.database&&await e.database.targetHasData())throw Error(`${i} already has a database named '${t.database.name}' with tables in it. Restoring this site's dump over it would destroy that data. Rename or drop it on the target first, or point this project at a different database name.`);let p=[{id:"pause-workers",title:`Stop background work on ${o} so the snapshot is consistent`,satisfied:async()=>bp(await e.runOnSource(Ep(n,r))),apply:async()=>{await e.runOnSource(Cp(n,r))}},...e.database?[{id:"database-dump",title:`Dump the '${t.database?.name}' database on ${o}`,satisfied:async()=>!1,apply:()=>e.database.dump()}]:[],{id:"snapshot",title:`Archive the site's tree and units on ${o}`,change:{from:`${o}:${s}`,to:ai(n,r)},satisfied:async()=>!1,apply:async()=>{await e.runOnSource(vp(n,r,s))}},{id:"transfer",title:`Carry the archive to ${i}`,change:{from:o,to:i},satisfied:()=>e.archiveStaged(),apply:()=>e.transferArchive()},...e.database?[{id:"database-transfer",title:`Carry the database dump to ${i}`,change:{from:o,to:i},satisfied:()=>e.database.dumpStaged(),apply:()=>e.database.transferDump()},{id:"database-restore",title:`Create and load '${t.database?.name}' on ${i}`,satisfied:async()=>!1,apply:()=>e.database.restore()}]:[],{id:"restore",title:`Unpack the site on ${i} and start it`,change:{from:ai(n,r),to:`${i}:${s}`},satisfied:async()=>Rp(await e.runOnTarget(wp(n,r,s))),apply:async()=>{await e.runOnTarget(Tp(n,r,s))}}];if(t.port!=null){let{port:c}=t;p.push({id:"health",title:`Wait for the site to answer on ${i} (127.0.0.1:${c})`,satisfied:async()=>!1,apply:async()=>{await e.runOnTarget(Dp(c,t.healthCheckPath??"/"))}})}return p.push(...e.certificates?[{id:"certificates",title:`Carry the site's TLS material to ${i}`,satisfied:()=>e.certificates.inPlace(),apply:()=>e.certificates.carry()}]:[],{id:"gateway",title:`Route the site on ${i}`,satisfied:()=>e.targetRoutesSite(),apply:()=>e.refreshTargetGateway()},{id:"dns",title:`Point DNS at ${i}`,change:{from:`${o}`,to:a},satisfied:async()=>await e.publishedAddress()===a,apply:async()=>{let c=await e.cutoverDns();if(c.length>0)throw Error(c.join("; "))}},{id:"drain-source",title:`Stop the site on ${o}, leaving its files in place`,satisfied:async()=>kp(await e.runOnSource(Np(n,r))),apply:async()=>{await e.runOnSource(Pp(n,r))}}),{operation:"site:move",target:r,steps:p}}export{Zh,ef,tf,gp,mp,hp,rf,fp,Ap,nf,sf,yp,of,af,Nc,Ip,cf,df,Sp,lf,uf,pf,gf,mf,hf,ff,ai,kc,Cp,Ep,bp,vp,Tp,wp,Rp,Dp,Pp,Np,kp,Af,yf,If,Sf,Cf,Ef,bf};
@@ -0,0 +1,92 @@
1
+ import{Tr,n}from"./chunk-y6k0vwfn.js";import{Ue}from"./chunk-x60w04y3.js";import*as d from"node:crypto";import{readFileSync as U}from"node:fs";import{readdir as z}from"node:fs/promises";import{join as M}from"node:path";function xt(e){if(e){let i=B(e);if(!i)throw Error(`AWS profile '${e}' not found in ~/.aws/credentials`);return i}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 B(process.env.AWS_PROFILE||"default")??{accessKeyId:"",secretAccessKey:""}}function B(e){let{existsSync:t,readFileSync:s}=Ue("node:fs"),{homedir:i}=Ue("node:os"),{join:r}=Ue("node:path"),a=process.env.AWS_SHARED_CREDENTIALS_FILE||r(i(),".aws","credentials");if(!t(a))return null;let c=s(a,"utf-8"),g=null,l,u,y;for(let h of c.split(`
2
+ `)){let m=h.trim();if(!m||m.startsWith("#")||m.startsWith(";"))continue;let p=m.match(/^\[([^\]]+)\]$/);if(p){if(g===e&&l&&u)return{accessKeyId:l,secretAccessKey:u,sessionToken:y};g=p[1],l=void 0,u=void 0,y=void 0;continue}if(g===e){let[T,...P]=m.split("="),S=P.join("=").trim();switch(T.trim().toLowerCase()){case"aws_access_key_id":l=S;break;case"aws_secret_access_key":u=S;break;case"aws_session_token":y=S;break}}}if(g===e&&l&&u)return{accessKeyId:l,secretAccessKey:u,sessionToken:y};return null}function L(e){let{buffer:t,byteOffset:s,byteLength:i}=e;if(t instanceof ArrayBuffer)return t.slice(s,s+i);let r=new ArrayBuffer(i);return new Uint8Array(r).set(new Uint8Array(e)),r}function I(e,t){let s=e?.[t]??e;if(s===null||typeof s!=="object"||Array.isArray(s))return s;let i={...s};return delete i["@_xmlns"],i}class o{client;region;explicitProfile;endpoint;endpointProtocol="https";forcePathStyle;explicitCredentials;constructor(e="us-east-1",t,s){let i=typeof e==="string"?s:e,r=typeof e==="string"?e:e.region??"us-east-1",a=typeof e==="string"?t:e.profile,c=i?.endpoint?Tr({region:r,path:"/",endpoint:i.endpoint}):void 0;this.region=r,this.explicitProfile=a,this.endpoint=c?.host,this.endpointProtocol=c?.protocol??"https",this.forcePathStyle=i?.forcePathStyle,this.explicitCredentials=i?.credentials,this.client=new n(i?.credentials,{profile:a,endpoint:i?.endpoint,forcePathStyle:i?.forcePathStyle})}getCredentials(){if(this.explicitCredentials?.accessKeyId&&this.explicitCredentials.secretAccessKey)return this.explicitCredentials;let e=xt(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=[],i=(e?.ListAllMyBucketsResult??e)?.Buckets?.Bucket;if(i){let r=Array.isArray(i)?i:[i];for(let a of r)t.push({Name:a.Name,CreationDate:a.CreationDate})}return{Buckets:t}}async createBucket(e,t){let s={};if(t?.acl)s["x-amz-acl"]=t.acl;let i;if(this.region!=="us-east-1"&&!this.endpoint)i=`<?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:i})}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 i=s.map((r)=>r.Key);for(let r=0;r<i.length;r+=1000){let a=i.slice(r,r+1000);await this.deleteObjects(e,a)}}await this.deleteBucket(e)}async listAllObjects(e){let t=[],s;do{let i={"list-type":"2","max-keys":"1000"};if(e.prefix)i.prefix=e.prefix;if(s)i["continuation-token"]=s;let r=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e.bucket}`,queryParams:i}),a=r?.ListBucketResult??r,c=a?.Contents;if(c){let l=Array.isArray(c)?c:[c];for(let u of l)t.push({Key:u.Key,LastModified:u.LastModified||"",Size:Number.parseInt(u.Size||"0"),ETag:u.ETag})}let g=a?.IsTruncated;s=g==="true"||g===!0?a?.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=[],r=(t?.ListBucketResult??t)?.Contents;if(r){let a=Array.isArray(r)?r:[r];for(let c of a){if(e.prefix&&!c.Key?.startsWith(e.prefix))continue;if(s.push({Key:c.Key||"",LastModified:c.LastModified||"",Size:Number.parseInt(c.Size||"0"),ETag:c.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[r,a]of Object.entries(e.metadata))t[`x-amz-meta-${r}`]=a;let s=e.key.split("/").map((r)=>encodeURIComponent(r)).join("/"),i=e.body instanceof Uint8Array&&!Buffer.isBuffer(e.body)?Buffer.from(e.body):e.body;if(Buffer.isBuffer(i)||i instanceof Uint8Array){let r=Buffer.isBuffer(i)?i:Buffer.from(i),{accessKeyId:a,secretAccessKey:c,sessionToken:g}=this.getCredentials(),l=this.s3VirtualHost(e.bucket),u=this.objectPath(e.bucket,s),y=this.objectUrl(e.bucket,s),h=new Date,m=h.toISOString().replace(/[:-]|\.\d{3}/g,""),p=h.toISOString().slice(0,10).replace(/-/g,""),T=d.createHash("sha256").update(r).digest("hex"),P={host:l,"x-amz-date":m,"x-amz-content-sha256":T,...t};if(g)P["x-amz-security-token"]=g;let S=Object.keys(P).sort().map((b)=>`${b.toLowerCase()}:${P[b].trim()}
6
+ `).join(""),x=Object.keys(P).sort().map((b)=>b.toLowerCase()).join(";"),A=["PUT",u,"",S,x,T].join(`
7
+ `),v="AWS4-HMAC-SHA256",C=`${p}/${this.region}/s3/aws4_request`,H=[v,m,C,d.createHash("sha256").update(A).digest("hex")].join(`
8
+ `),R=d.createHmac("sha256",`AWS4${c}`).update(p).digest(),K=d.createHmac("sha256",R).update(this.region).digest(),j=d.createHmac("sha256",K).update("s3").digest(),q=d.createHmac("sha256",j).update("aws4_request").digest(),E=d.createHmac("sha256",q).update(H).digest("hex"),k=`${v} Credential=${a}/${C}, SignedHeaders=${x}, Signature=${E}`,w=await fetch(y,{method:"PUT",headers:{...P,Authorization:k},body:L(r)});if(!w.ok){let b=await w.text();throw Error(`S3 PUT failed: ${w.status} ${b}`)}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((r)=>encodeURIComponent(r)).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:i,sessionToken:r}=this.getCredentials(),a=this.s3VirtualHost(e),c=t.split("/").map((b)=>encodeURIComponent(b)).join("/"),g=this.objectPath(e,c),l=this.objectUrl(e,c),u=new Date,y=u.toISOString().replace(/[:-]|\.\d{3}/g,""),h=u.toISOString().slice(0,10).replace(/-/g,""),m=d.createHash("sha256").update("").digest("hex"),p={host:a,"x-amz-date":y,"x-amz-content-sha256":m};if(r)p["x-amz-security-token"]=r;let T=Object.keys(p).sort().map((b)=>`${b.toLowerCase()}:${p[b].trim()}
9
+ `).join(""),P=Object.keys(p).sort().map((b)=>b.toLowerCase()).join(";"),S=["GET",g,"",T,P,m].join(`
10
+ `),x="AWS4-HMAC-SHA256",A=`${h}/${this.region}/s3/aws4_request`,v=[x,y,A,d.createHash("sha256").update(S).digest("hex")].join(`
11
+ `),C=d.createHmac("sha256",`AWS4${i}`).update(h).digest(),H=d.createHmac("sha256",C).update(this.region).digest(),R=d.createHmac("sha256",H).update("s3").digest(),K=d.createHmac("sha256",R).update("aws4_request").digest(),j=d.createHmac("sha256",K).update(v).digest("hex"),q=`${x} Credential=${s}/${A}, SignedHeaders=${P}, Signature=${j}`,E=await fetch(l,{method:"GET",headers:{...p,Authorization:q}});if(!E.ok){let b=await E.text();throw Error(`S3 GET failed: ${E.status} ${b}`)}let k=await E.arrayBuffer(),w=E.headers.get("content-length");return{body:new Uint8Array(k),contentType:E.headers.get("content-type")??void 0,contentLength:w?Number.parseInt(w,10):void 0}}async copyObject(e){let t=(i)=>i.split("/").map((r)=>encodeURIComponent(r)).join("/"),s={"x-amz-copy-source":`/${e.sourceBucket}/${t(e.sourceKey)}`};if(e.metadataDirective)s["x-amz-metadata-directive"]=e.metadataDirective;if(e.contentType)s["Content-Type"]=e.contentType;if(e.metadata)for(let[i,r]of Object.entries(e.metadata))s[`x-amz-meta-${i}`]=r;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e.destinationBucket}/${t(e.destinationKey)}`,headers:s})}async deleteObject(e,t){let s=t.split("/").map((i)=>encodeURIComponent(i)).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((r)=>`<Object><Key>${r}</Key></Object>`).join(`
14
+ `)}
15
+ </Delete>`,i=d.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":i}})}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=U(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((a)=>s.includes(a)))continue;if(e.include&&!e.include.some((a)=>s.includes(a)))continue;let i=s.substring(e.source.length+1),r=e.prefix?`${e.prefix}/${i}`:i;if(!e.dryRun){let a=U(s);await this.putObject({bucket:e.bucket,key:r,body:a,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 i=(await this.list({bucket:e,prefix:t})).map((r)=>r.Key);if(i.length>0)await this.deleteObjects(e,i)}async getBucketSize(e,t){return(await this.list({bucket:e,prefix:t})).reduce((i,r)=>i+r.Size,0)}async listFilesRecursive(e){let t=[],s=await z(e,{withFileTypes:!0});for(let i of s){let r=M(e,i.name);if(i.isDirectory()){let a=await this.listFilesRecursive(r);t.push(...a)}else t.push(r)}return t}async putBucketPolicy(e,t){let{accessKeyId:s,secretAccessKey:i,sessionToken:r}=this.getCredentials(),a=this.s3BaseHost(),c=typeof t==="string"?t:JSON.stringify(t),g=new Date,l=g.toISOString().replace(/[:-]|\.\d{3}/g,""),u=g.toISOString().slice(0,10).replace(/-/g,""),y=d.createHash("sha256").update(c).digest("hex"),h="/"+e,m="policy=",p={host:a,"x-amz-date":l,"x-amz-content-sha256":y,"content-type":"application/json"};if(r)p["x-amz-security-token"]=r;let T=Object.keys(p).sort().map((w)=>`${w.toLowerCase()}:${p[w].trim()}
16
+ `).join(""),P=Object.keys(p).sort().map((w)=>w.toLowerCase()).join(";"),S=["PUT",h,"policy=",T,P,y].join(`
17
+ `),x="AWS4-HMAC-SHA256",A=`${u}/${this.region}/s3/aws4_request`,v=[x,l,A,d.createHash("sha256").update(S).digest("hex")].join(`
18
+ `),C=d.createHmac("sha256","AWS4"+i).update(u).digest(),H=d.createHmac("sha256",C).update(this.region).digest(),R=d.createHmac("sha256",H).update("s3").digest(),K=d.createHmac("sha256",R).update("aws4_request").digest(),j=d.createHmac("sha256",K).update(v).digest("hex"),q=`${x} Credential=${s}/${A}, SignedHeaders=${P}, Signature=${j}`,E=`${this.endpointProtocol}://${a}${h}?policy=`,k=await fetch(E,{method:"PUT",headers:{...p,Authorization:q},body:c});if(!k.ok){let w=await k.text();throw Error(`Failed to put bucket policy: ${k.status} ${w}`)}}async getBucketPolicy(e){let{accessKeyId:t,secretAccessKey:s,sessionToken:i}=this.getCredentials(),r=this.s3BaseHost(),a=new Date,c=a.toISOString().replace(/[:-]|\.\d{3}/g,""),g=a.toISOString().slice(0,10).replace(/-/g,""),l=d.createHash("sha256").update("").digest("hex"),u="/"+e,y="policy=",h={host:r,"x-amz-date":c,"x-amz-content-sha256":l};if(i)h["x-amz-security-token"]=i;let m=Object.keys(h).sort().map((k)=>`${k.toLowerCase()}:${h[k].trim()}
19
+ `).join(""),p=Object.keys(h).sort().map((k)=>k.toLowerCase()).join(";"),T=["GET",u,"policy=",m,p,l].join(`
20
+ `),P="AWS4-HMAC-SHA256",S=`${g}/${this.region}/s3/aws4_request`,x=[P,c,S,d.createHash("sha256").update(T).digest("hex")].join(`
21
+ `),A=d.createHmac("sha256","AWS4"+s).update(g).digest(),v=d.createHmac("sha256",A).update(this.region).digest(),C=d.createHmac("sha256",v).update("s3").digest(),H=d.createHmac("sha256",C).update("aws4_request").digest(),R=d.createHmac("sha256",H).update(x).digest("hex"),K=`${P} Credential=${t}/${S}, SignedHeaders=${p}, Signature=${R}`,j=`${this.endpointProtocol}://${r}${u}?policy=`,q=await fetch(j,{method:"GET",headers:{...h,Authorization:K}});if(q.status===404)return null;if(!q.ok){let k=await q.text();throw Error(`Failed to get bucket policy: ${q.status} ${k}`)}let E=await q.text();return JSON.parse(E)}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,i){await this.putObject({bucket:e,key:t,body:JSON.stringify(s),contentType:"application/json",...i})}async getBucketVersioning(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{versioning:""}});return{Status:(t?.VersioningConfiguration??t)?.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{let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{lifecycle:""}});return I(t,"LifecycleConfiguration")}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketLifecycleConfiguration(e,t){let i=`<?xml version="1.0" encoding="UTF-8"?>
25
+ <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
26
+ ${t.map((r)=>{let a=`<Rule><ID>${r.ID}</ID><Status>${r.Status}</Status>`;if(r.Filter)a+=`<Filter><Prefix>${r.Filter.Prefix||""}</Prefix></Filter>`;else a+="<Filter><Prefix></Prefix></Filter>";if(r.Expiration){if(r.Expiration.Days)a+=`<Expiration><Days>${r.Expiration.Days}</Days></Expiration>`;else if(r.Expiration.Date)a+=`<Expiration><Date>${r.Expiration.Date}</Date></Expiration>`}if(r.Transitions)for(let c of r.Transitions)a+=`<Transition><Days>${c.Days}</Days><StorageClass>${c.StorageClass}</StorageClass></Transition>`;if(r.NoncurrentVersionExpiration)a+=`<NoncurrentVersionExpiration><NoncurrentDays>${r.NoncurrentVersionExpiration.NoncurrentDays}</NoncurrentDays></NoncurrentVersionExpiration>`;return a+="</Rule>",a}).join("")}
27
+ </LifecycleConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{lifecycle:""},headers:{"Content-Type":"application/xml"},body:i})}async deleteBucketLifecycleConfiguration(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{lifecycle:""}})}async getBucketCors(e){try{let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{cors:""}});return I(t,"CORSConfiguration")}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketCors(e,t){let i=`<?xml version="1.0" encoding="UTF-8"?>
28
+ <CORSConfiguration>
29
+ ${t.map((r)=>{let a="<CORSRule>";for(let c of r.AllowedOrigins)a+=`<AllowedOrigin>${c}</AllowedOrigin>`;for(let c of r.AllowedMethods)a+=`<AllowedMethod>${c}</AllowedMethod>`;if(r.AllowedHeaders)for(let c of r.AllowedHeaders)a+=`<AllowedHeader>${c}</AllowedHeader>`;if(r.ExposeHeaders)for(let c of r.ExposeHeaders)a+=`<ExposeHeader>${c}</ExposeHeader>`;if(r.MaxAgeSeconds)a+=`<MaxAgeSeconds>${r.MaxAgeSeconds}</MaxAgeSeconds>`;return a+="</CORSRule>",a}).join("")}
30
+ </CORSConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{cors:""},headers:{"Content-Type":"application/xml"},body:i})}async deleteBucketCors(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{cors:""}})}async getBucketEncryption(e){try{let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{encryption:""}});return I(t,"ServerSideEncryptionConfiguration")}catch(t){if(t.statusCode===404)return null;throw t}}async putBucketEncryption(e,t,s){let i=`<ApplyServerSideEncryptionByDefault><SSEAlgorithm>${t}</SSEAlgorithm>`;if(s)i+=`<KMSMasterKeyID>${s}</KMSMasterKeyID>`;i+="</ApplyServerSideEncryptionByDefault>";let r=`<?xml version="1.0" encoding="UTF-8"?>
31
+ <ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
32
+ <Rule>${i}</Rule>
33
+ </ServerSideEncryptionConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${e}`,queryParams:{encryption:""},headers:{"Content-Type":"application/xml"},body:r})}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 i=`<?xml version="1.0" encoding="UTF-8"?>
34
+ <Tagging>
35
+ <TagSet>${t.map((r)=>`<Tag><Key>${r.Key}</Key><Value>${r.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:i})}async deleteBucketTagging(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{tagging:""}})}async getObjectTagging(e,t){try{let i=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}/${t}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!i)return[];return Array.isArray(i)?i:[i]}catch(s){if(s.statusCode===404)return[];throw s}}async putObjectTagging(e,t,s){let r=`<?xml version="1.0" encoding="UTF-8"?>
37
+ <Tagging>
38
+ <TagSet>${s.map((a)=>`<Tag><Key>${a.Key}</Key><Value>${a.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:r})}async deleteObjectTagging(e,t){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}/${t}`,queryParams:{tagging:""}})}async getBucketAcl(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{acl:""}});return I(t,"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){let s=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}/${t}`,queryParams:{acl:""}});return I(s,"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){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{location:""}}),s=I(t,"LocationConstraint");return(typeof s==="string"?s:s?.["#text"])||"us-east-1"}async getBucketLogging(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{logging:""}});return I(t,"BucketLoggingStatus")}async putBucketLogging(e,t,s){let i=`<?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:i})}async getBucketNotificationConfiguration(e){let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{notification:""}});return I(t,"NotificationConfiguration")}async putBucketNotificationConfiguration(e,t){let s="";if(t.LambdaFunctionConfigurations)for(let r of t.LambdaFunctionConfigurations){if(s+="<CloudFunctionConfiguration>",r.Id)s+=`<Id>${r.Id}</Id>`;s+=`<CloudFunction>${r.LambdaFunctionArn}</CloudFunction>`;for(let a of r.Events)s+=`<Event>${a}</Event>`;if(r.Filter?.Key?.FilterRules){s+="<Filter><S3Key>";for(let a of r.Filter.Key.FilterRules)s+=`<FilterRule><Name>${a.Name}</Name><Value>${a.Value}</Value></FilterRule>`;s+="</S3Key></Filter>"}s+="</CloudFunctionConfiguration>"}if(t.TopicConfigurations)for(let r of t.TopicConfigurations){if(s+="<TopicConfiguration>",r.Id)s+=`<Id>${r.Id}</Id>`;s+=`<Topic>${r.TopicArn}</Topic>`;for(let a of r.Events)s+=`<Event>${a}</Event>`;s+="</TopicConfiguration>"}if(t.QueueConfigurations)for(let r of t.QueueConfigurations){if(s+="<QueueConfiguration>",r.Id)s+=`<Id>${r.Id}</Id>`;s+=`<Queue>${r.QueueArn}</Queue>`;for(let a of r.Events)s+=`<Event>${a}</Event>`;s+="</QueueConfiguration>"}let i=`<?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:i})}async getBucketWebsite(e){try{let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{website:""}});return I(t,"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 i=`<?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:i})}async deleteBucketWebsite(e){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${e}`,queryParams:{website:""}})}async getBucketReplication(e){try{let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{replication:""}});return I(t,"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{let t=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${e}`,queryParams:{publicAccessBlock:""}});return I(t,"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:i,secretAccessKey:r}=this.getCredentials(),a=this.s3VirtualHost(e),c=new Date,g=c.toISOString().replace(/[:-]|\.\d{3}/g,""),l=c.toISOString().slice(0,10).replace(/-/g,""),u=`${l}/${this.region}/s3/aws4_request`,y=`${i}/${u}`,h=t.split("/").map((C)=>encodeURIComponent(C)).join("/"),m=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":y,"X-Amz-Date":g,"X-Amz-Expires":s.toString(),"X-Amz-SignedHeaders":"host"}),p=["GET",this.objectPath(e,h),m.toString(),`host:${a}
61
+ `,"host","UNSIGNED-PAYLOAD"].join(`
62
+ `),T=["AWS4-HMAC-SHA256",g,u,d.createHash("sha256").update(p).digest("hex")].join(`
63
+ `),P=d.createHmac("sha256",`AWS4${r}`).update(l).digest(),S=d.createHmac("sha256",P).update(this.region).digest(),x=d.createHmac("sha256",S).update("s3").digest(),A=d.createHmac("sha256",x).update("aws4_request").digest(),v=d.createHmac("sha256",A).update(T).digest("hex");return m.append("X-Amz-Signature",v),`${this.endpointProtocol}://${a}${this.objectPath(e,h)}?${m.toString()}`}generatePresignedPutUrl(e,t,s,i=3600){let{accessKeyId:r,secretAccessKey:a}=this.getCredentials(),c=this.s3VirtualHost(e),g=new Date,l=g.toISOString().replace(/[:-]|\.\d{3}/g,""),u=g.toISOString().slice(0,10).replace(/-/g,""),y=`${u}/${this.region}/s3/aws4_request`,h=`${r}/${y}`,m=t.split("/").map((H)=>encodeURIComponent(H)).join("/"),p=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":h,"X-Amz-Date":l,"X-Amz-Expires":i.toString(),"X-Amz-SignedHeaders":"content-type;host"}),T=["PUT",this.objectPath(e,m),p.toString(),`content-type:${s}
64
+ host:${c}
65
+ `,"content-type;host","UNSIGNED-PAYLOAD"].join(`
66
+ `),P=["AWS4-HMAC-SHA256",l,y,d.createHash("sha256").update(T).digest("hex")].join(`
67
+ `),S=d.createHmac("sha256",`AWS4${a}`).update(u).digest(),x=d.createHmac("sha256",S).update(this.region).digest(),A=d.createHmac("sha256",x).update("s3").digest(),v=d.createHmac("sha256",A).update("aws4_request").digest(),C=d.createHmac("sha256",v).update(P).digest("hex");return p.append("X-Amz-Signature",C),`${this.endpointProtocol}://${c}${this.objectPath(e,m)}?${p.toString()}`}async createMultipartUpload(e,t,s){let i={};if(s?.contentType)i["Content-Type"]=s.contentType;if(s?.metadata)for(let[g,l]of Object.entries(s.metadata))i[`x-amz-meta-${g}`]=l;let r=t.split("/").map((g)=>encodeURIComponent(g)).join("/"),a=await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${r}`,bucket:e,queryParams:{uploads:""},headers:i});return{UploadId:(a?.InitiateMultipartUploadResult??a)?.UploadId}}async uploadPart(e,t,s,i,r){let{accessKeyId:a,secretAccessKey:c,sessionToken:g}=this.getCredentials(),l=this.s3VirtualHost(e),u=t.split("/").map((O)=>encodeURIComponent(O)).join("/"),y=this.objectPath(e,u),h=`${this.objectUrl(e,u)}?partNumber=${i}&uploadId=${encodeURIComponent(s)}`,m=new Date,p=m.toISOString().replace(/[:-]|\.\d{3}/g,""),T=m.toISOString().slice(0,10).replace(/-/g,""),P=d.createHash("sha256").update(r).digest("hex"),S={host:l,"x-amz-date":p,"x-amz-content-sha256":P};if(g)S["x-amz-security-token"]=g;let x=Object.keys(S).sort().map((O)=>`${O.toLowerCase()}:${S[O].trim()}
68
+ `).join(""),A=Object.keys(S).sort().map((O)=>O.toLowerCase()).join(";"),v=["PUT",y,`partNumber=${i}&uploadId=${encodeURIComponent(s)}`,x,A,P].join(`
69
+ `),C="AWS4-HMAC-SHA256",H=`${T}/${this.region}/s3/aws4_request`,R=[C,p,H,d.createHash("sha256").update(v).digest("hex")].join(`
70
+ `),K=d.createHmac("sha256",`AWS4${c}`).update(T).digest(),j=d.createHmac("sha256",K).update(this.region).digest(),q=d.createHmac("sha256",j).update("s3").digest(),E=d.createHmac("sha256",q).update("aws4_request").digest(),k=d.createHmac("sha256",E).update(R).digest("hex"),w=`${C} Credential=${a}/${H}, SignedHeaders=${A}, Signature=${k}`,b=await fetch(h,{method:"PUT",headers:{...S,Authorization:w},body:L(r)});if(!b.ok){let O=await b.text();throw Error(`Upload part failed: ${b.status} ${O}`)}return{ETag:b.headers.get("etag")||""}}async completeMultipartUpload(e,t,s,i){let r=t.split("/").map((g)=>encodeURIComponent(g)).join("/"),c=`<?xml version="1.0" encoding="UTF-8"?>
71
+ <CompleteMultipartUpload>${i.sort((g,l)=>g.PartNumber-l.PartNumber).map((g)=>`<Part><PartNumber>${g.PartNumber}</PartNumber><ETag>${g.ETag}</ETag></Part>`).join("")}</CompleteMultipartUpload>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${r}`,bucket:e,queryParams:{uploadId:s},headers:{"Content-Type":"application/xml"},body:c})}async abortMultipartUpload(e,t,s){let i=t.split("/").map((r)=>encodeURIComponent(r)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${i}`,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((r)=>({Key:r.Key,UploadId:r.UploadId,Initiated:r.Initiated}))}async restoreObject(e,t,s,i="Standard"){let r=`<?xml version="1.0" encoding="UTF-8"?>
72
+ <RestoreRequest>
73
+ <Days>${s}</Days>
74
+ <GlacierJobParameters>
75
+ <Tier>${i}</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:r})}async selectObjectContent(e,t,s,i,r="JSON"){let a="";if(i==="CSV")a="<CSV><FileHeaderInfo>USE</FileHeaderInfo></CSV>";else if(i==="JSON")a="<JSON><Type>DOCUMENT</Type></JSON>";else a="<Parquet/>";let c="";if(r==="CSV")c="<CSV/>";else c="<JSON/>";let g=`<?xml version="1.0" encoding="UTF-8"?>
78
+ <SelectObjectContentRequest>
79
+ <Expression>${s}</Expression>
80
+ <ExpressionType>SQL</ExpressionType>
81
+ <InputSerialization>${a}</InputSerialization>
82
+ <OutputSerialization>${c}</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:g,rawResponse:!0})}async getSignedUrl(e){let{bucket:t,key:s,expiresIn:i=3600,operation:r="getObject"}=e,{accessKeyId:a,secretAccessKey:c,sessionToken:g}=this.getCredentials(),l=new Date,u=l.toISOString().replace(/[:-]|\.\d{3}/g,""),y=l.toISOString().slice(0,10).replace(/-/g,""),h=this.s3VirtualHost(t),m=r==="putObject"?"PUT":"GET",p="AWS4-HMAC-SHA256",T=`${y}/${this.region}/s3/aws4_request`,S={"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":`${a}/${T}`,"X-Amz-Date":u,"X-Amz-Expires":i.toString(),"X-Amz-SignedHeaders":"host"};if(g)S["X-Amz-Security-Token"]=g;let A=Object.keys(S).sort().map((D)=>`${encodeURIComponent(D)}=${encodeURIComponent(S[D])}`).join("&"),v=s.split("/").map((D)=>encodeURIComponent(D)).join("/"),C=this.objectPath(t,v),H=`host:${h}
84
+ `,j=[m,C,A,H,"host","UNSIGNED-PAYLOAD"].join(`
85
+ `),q=["AWS4-HMAC-SHA256",u,T,d.createHash("sha256").update(j).digest("hex")].join(`
86
+ `),E=d.createHmac("sha256",`AWS4${c}`).update(y).digest(),k=d.createHmac("sha256",E).update(this.region).digest(),w=d.createHmac("sha256",k).update("s3").digest(),b=d.createHmac("sha256",w).update("aws4_request").digest(),O=d.createHmac("sha256",b).update(q).digest("hex");return`${this.endpointProtocol}://${h}${C}?${A}&X-Amz-Signature=${O}`}async listObjects(e){let{bucket:t,prefix:s,maxKeys:i=1000,continuationToken:r}=e,a={"list-type":"2","max-keys":i.toString()};if(s)a.prefix=s;if(r)a["continuation-token"]=r;let c=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:a}),g=[],l=c?.ListBucketResult??c;if(l?.Contents){let u=Array.isArray(l.Contents)?l.Contents:[l.Contents];for(let y of u)g.push({Key:y.Key||"",LastModified:y.LastModified||"",Size:Number.parseInt(y.Size||"0"),ETag:y.ETag})}return{objects:g,nextContinuationToken:l?.NextContinuationToken}}async emptyBucket(e){let t=0,s=await this.listAllObjects({bucket:e});if(s.length>0)for(let i=0;i<s.length;i+=1000){let a=s.slice(i,i+1000).map((c)=>c.Key);await this.deleteObjects(e,a),t+=a.length}try{let i,r;do{let a=await this.listObjectVersions({bucket:e,keyMarker:i,versionIdMarker:r,maxKeys:1000}),c=[];if(a.versions)for(let g of a.versions)c.push({Key:g.Key,VersionId:g.VersionId});if(a.deleteMarkers)for(let g of a.deleteMarkers)c.push({Key:g.Key,VersionId:g.VersionId});if(c.length>0)await this.deleteObjectVersions(e,c),t+=c.length;i=a.nextKeyMarker,r=a.nextVersionIdMarker}while(i)}catch{}return{deletedCount:t}}async listObjectVersions(e){let{bucket:t,prefix:s,keyMarker:i,versionIdMarker:r,maxKeys:a=1000}=e,c={versions:"","max-keys":a.toString()};if(s)c.prefix=s;if(i)c["key-marker"]=i;if(r)c["version-id-marker"]=r;let g=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${t}`,queryParams:c}),l=[],u=[];if(g.Version){let y=Array.isArray(g.Version)?g.Version:[g.Version];for(let h of y)l.push({Key:h.Key,VersionId:h.VersionId,IsLatest:h.IsLatest==="true"})}if(g.DeleteMarker){let y=Array.isArray(g.DeleteMarker)?g.DeleteMarker:[g.DeleteMarker];for(let h of y)u.push({Key:h.Key,VersionId:h.VersionId,IsLatest:h.IsLatest==="true"})}return{versions:l,deleteMarkers:u,nextKeyMarker:g.NextKeyMarker,nextVersionIdMarker:g.NextVersionIdMarker}}async deleteObjectVersions(e,t){let s=`<?xml version="1.0" encoding="UTF-8"?>
87
+ <Delete>
88
+ <Quiet>true</Quiet>
89
+ ${t.map((r)=>`<Object><Key>${r.Key}</Key>${r.VersionId?`<VersionId>${r.VersionId}</VersionId>`:""}</Object>`).join(`
90
+ `)}
91
+ </Delete>`,i=d.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":i}})}}function f(e,t){return(e?.[`${t}Response`]??e)?.[`${t}Result`]}function ct(e){if(e===void 0||e===null||e==="")return[];return Array.isArray(e)?e:[e]}function Pc(e){return e===!0||e==="true"}
92
+ export{xt,o,f,ct,Pc};