@stacksjs/ts-cloud 0.12.1 → 0.12.3

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 (234) hide show
  1. package/dist/aws/index.js +1 -1
  2. package/dist/bin/chunk-0zwknfwp.js +1 -0
  3. package/dist/bin/chunk-3aph4c1w.js +2 -0
  4. package/dist/bin/{chunk-5bhx3bsa.js → chunk-4q6tad44.js} +121 -121
  5. package/dist/bin/chunk-5nkqza92.js +1 -0
  6. package/dist/bin/chunk-64vczwwt.js +1 -0
  7. package/dist/bin/chunk-6tfwm33r.js +6 -0
  8. package/dist/bin/chunk-71t1gmsq.js +1 -0
  9. package/dist/bin/chunk-7g2ahkse.js +1 -0
  10. package/dist/bin/chunk-7zhgmp1s.js +3 -0
  11. package/dist/bin/chunk-82mj52xr.js +141 -0
  12. package/dist/bin/chunk-8ewncfce.js +37 -0
  13. package/dist/bin/chunk-9a88fp00.js +2 -0
  14. package/dist/bin/chunk-9kf0np8j.js +44 -0
  15. package/dist/bin/chunk-9rb23kz9.js +1 -0
  16. package/dist/bin/chunk-a7w13qfm.js +2 -0
  17. package/dist/bin/chunk-b4wt9jcg.js +60 -0
  18. package/dist/bin/chunk-btsyjhk7.js +92 -0
  19. package/dist/bin/chunk-c0bdafbx.js +2 -0
  20. package/dist/bin/chunk-cd0ps58j.js +1 -0
  21. package/dist/bin/chunk-cxt74wsj.js +1 -0
  22. package/dist/bin/chunk-d7ke90zt.js +2 -0
  23. package/dist/bin/chunk-djg4zyqk.js +1 -0
  24. package/dist/bin/chunk-dkaz333b.js +1 -0
  25. package/dist/bin/chunk-dkf4qsp2.js +1 -0
  26. package/dist/bin/{chunk-scqmd4qv.js → chunk-dz1ec589.js} +30 -30
  27. package/dist/bin/chunk-e2bybahr.js +3 -0
  28. package/dist/bin/chunk-e5ab5twy.js +50 -0
  29. package/dist/bin/chunk-edvvx3hg.js +1 -0
  30. package/dist/bin/chunk-ehc63fvs.js +2 -0
  31. package/dist/bin/chunk-f06c5np9.js +1 -0
  32. package/dist/bin/chunk-gq8794k6.js +1 -0
  33. package/dist/bin/chunk-hq9x489e.js +70 -0
  34. package/dist/bin/chunk-ja1vjdn1.js +6 -0
  35. package/dist/bin/chunk-k3120rx6.js +1 -0
  36. package/dist/bin/chunk-kg61p5hw.js +3 -0
  37. package/dist/bin/chunk-mcr0r4at.js +2 -0
  38. package/dist/bin/chunk-mfrf9q4b.js +2 -0
  39. package/dist/bin/chunk-my3ewh3a.js +34 -0
  40. package/dist/bin/chunk-nw3d4k52.js +1 -0
  41. package/dist/bin/chunk-p70bc9yr.js +1 -0
  42. package/dist/bin/chunk-pp2m8q55.js +512 -0
  43. package/dist/bin/chunk-q5cmfpzt.js +1 -0
  44. package/dist/bin/chunk-rtecnmts.js +4 -0
  45. package/dist/bin/chunk-s2grgcpy.js +590 -0
  46. package/dist/bin/chunk-s4yzes15.js +2 -0
  47. package/dist/bin/chunk-sj5csg49.js +2 -0
  48. package/dist/bin/chunk-tfbs8k8v.js +111 -0
  49. package/dist/bin/chunk-tvz9c388.js +1 -0
  50. package/dist/bin/{chunk-9vdc7adf.js → chunk-w32xv8n4.js} +6 -6
  51. package/dist/bin/chunk-x6f61g36.js +9 -0
  52. package/dist/bin/chunk-xhwqpgwq.js +2 -0
  53. package/dist/bin/chunk-xk08030d.js +6 -0
  54. package/dist/bin/chunk-xkfrqqcs.js +1 -0
  55. package/dist/bin/chunk-y1h63vpm.js +1 -0
  56. package/dist/bin/chunk-zdt2rjk6.js +1 -0
  57. package/dist/bin/chunk-zh2d4704.js +1 -0
  58. package/dist/bin/chunk-zpe64t4r.js +1 -0
  59. package/dist/bin/cli.js +435 -444
  60. package/dist/bin/dashboard-server.js +1 -1
  61. package/dist/{chunk-rr1yaj55.js → chunk-13qjvbqh.js} +1 -1
  62. package/dist/chunk-152he7m3.js +92 -0
  63. package/dist/chunk-1qdne0bf.js +1 -0
  64. package/dist/chunk-3mgj3hrh.js +5 -0
  65. package/dist/chunk-3nmm7cap.js +704 -0
  66. package/dist/chunk-6kpbveb8.js +5 -0
  67. package/dist/chunk-73ztr55z.js +2 -0
  68. package/dist/{chunk-y1dh3znq.js → chunk-86ss83s2.js} +52 -52
  69. package/dist/chunk-a84gmpyh.js +1 -0
  70. package/dist/chunk-aj025v2s.js +4 -0
  71. package/dist/chunk-by2bwzk6.js +141 -0
  72. package/dist/chunk-h42zck7h.js +60 -0
  73. package/dist/chunk-hn40z11p.js +37 -0
  74. package/dist/{chunk-6xcbfs2r.js → chunk-jm5mg890.js} +111 -111
  75. package/dist/chunk-m8fs0233.js +34 -0
  76. package/dist/chunk-mz0dk78z.js +6 -0
  77. package/dist/chunk-n514hj0z.js +450 -0
  78. package/dist/chunk-nms5q44e.js +1 -0
  79. package/dist/chunk-qm32ytbr.js +1 -0
  80. package/dist/chunk-t0xgmhd6.js +114 -0
  81. package/dist/chunk-t3t9ymec.js +1 -0
  82. package/dist/chunk-tz9myq9a.js +2 -0
  83. package/dist/chunk-wavjkdb8.js +2 -0
  84. package/dist/chunk-x3hay61c.js +44 -0
  85. package/dist/chunk-xcj8zfmg.js +2 -0
  86. package/dist/chunk-y2v22hkv.js +1 -0
  87. package/dist/chunk-y4xkj2f1.js +50 -0
  88. package/dist/deploy/index.js +1 -1
  89. package/dist/dns/index.js +1 -1
  90. package/dist/drivers/index.js +1 -1
  91. package/dist/drivers/shared/deploy-script.d.ts +85 -0
  92. package/dist/index.js +90 -90
  93. package/dist/protection/index.js +1 -1
  94. package/dist/push/index.js +1 -1
  95. package/dist/spend/index.js +1 -1
  96. package/dist/ui/404.html +2 -2
  97. package/dist/ui/_stx/{router.fa5bc4dc.js → router.229f89ab.js} +1 -1
  98. package/dist/ui/_stx/runtime.dbee66d1.js +1 -0
  99. package/dist/ui/accept-invitation.html +2 -2
  100. package/dist/ui/access-denied.html +1 -1
  101. package/dist/ui/account/automation.html +6 -6
  102. package/dist/ui/account/security.html +2 -2
  103. package/dist/ui/applications/compose.html +6 -6
  104. package/dist/ui/applications/new.html +2 -2
  105. package/dist/ui/data/backups.html +80 -80
  106. package/dist/ui/data/services.html +78 -78
  107. package/dist/ui/data/volumes.html +50 -50
  108. package/dist/ui/index.html +50 -50
  109. package/dist/ui/infrastructure/topology.html +118 -118
  110. package/dist/ui/integrations.html +1 -1
  111. package/dist/ui/operations/alerts.html +48 -48
  112. package/dist/ui/operations/configuration.html +5 -5
  113. package/dist/ui/operations/jobs.html +75 -75
  114. package/dist/ui/operations/maintenance.html +6 -6
  115. package/dist/ui/operations/observability.html +82 -82
  116. package/dist/ui/operations/previews.html +6 -6
  117. package/dist/ui/operations/queue.html +6 -6
  118. package/dist/ui/operations/regions.html +6 -6
  119. package/dist/ui/operations/releases.html +6 -6
  120. package/dist/ui/operations/spend.html +54 -54
  121. package/dist/ui/operations/workloads.html +104 -104
  122. package/dist/ui/security.html +1 -1
  123. package/dist/ui/server/actions.html +56 -56
  124. package/dist/ui/server/activity.html +2 -2
  125. package/dist/ui/server/capacity.html +6 -6
  126. package/dist/ui/server/database.html +105 -105
  127. package/dist/ui/server/deployments.html +50 -50
  128. package/dist/ui/server/diagnostics.html +2 -2
  129. package/dist/ui/server/firewall.html +76 -76
  130. package/dist/ui/server/fleet.html +34 -34
  131. package/dist/ui/server/logs.html +24 -24
  132. package/dist/ui/server/metrics.html +112 -112
  133. package/dist/ui/server/security.html +2 -2
  134. package/dist/ui/server/services.html +27 -27
  135. package/dist/ui/server/sites.html +120 -120
  136. package/dist/ui/server/ssh-keys.html +52 -52
  137. package/dist/ui/server/team.html +144 -144
  138. package/dist/ui/server/terminal.html +15 -15
  139. package/dist/ui/serverless/alarms.html +52 -52
  140. package/dist/ui/serverless/assets.html +28 -28
  141. package/dist/ui/serverless/cost.html +2 -2
  142. package/dist/ui/serverless/data.html +36 -36
  143. package/dist/ui/serverless/deployments.html +28 -28
  144. package/dist/ui/serverless/firewall.html +2 -2
  145. package/dist/ui/serverless/functions.html +40 -40
  146. package/dist/ui/serverless/logs.html +23 -23
  147. package/dist/ui/serverless/metrics.html +2 -2
  148. package/dist/ui/serverless/queues.html +48 -48
  149. package/dist/ui/serverless/secrets.html +52 -52
  150. package/dist/ui/serverless/traces.html +6 -6
  151. package/dist/ui/serverless.html +53 -53
  152. package/dist/ui-src/src/charts.ts +4644 -16118
  153. package/dist/ui-src/src/topology.ts +2 -2
  154. package/package.json +6 -6
  155. package/dist/bin/chunk-0rtn6q5x.js +0 -3
  156. package/dist/bin/chunk-258ehp9s.js +0 -1
  157. package/dist/bin/chunk-2yctv06c.js +0 -1
  158. package/dist/bin/chunk-3276rveh.js +0 -37
  159. package/dist/bin/chunk-3m665jwp.js +0 -70
  160. package/dist/bin/chunk-3s2p9vxj.js +0 -1
  161. package/dist/bin/chunk-4esma5m9.js +0 -1
  162. package/dist/bin/chunk-4n0j3n3b.js +0 -2
  163. package/dist/bin/chunk-54bqchag.js +0 -92
  164. package/dist/bin/chunk-5zagqd20.js +0 -1
  165. package/dist/bin/chunk-7hw2js5h.js +0 -512
  166. package/dist/bin/chunk-8h1qr6x4.js +0 -50
  167. package/dist/bin/chunk-a1dd6sby.js +0 -1
  168. package/dist/bin/chunk-a4dw35gs.js +0 -1
  169. package/dist/bin/chunk-a9d55ker.js +0 -1
  170. package/dist/bin/chunk-awa1qade.js +0 -9
  171. package/dist/bin/chunk-b6by94pk.js +0 -2
  172. package/dist/bin/chunk-c8sypnbe.js +0 -2
  173. package/dist/bin/chunk-cx4e3d4w.js +0 -1
  174. package/dist/bin/chunk-d5a3vheh.js +0 -2
  175. package/dist/bin/chunk-e1fym2bd.js +0 -1
  176. package/dist/bin/chunk-ej4h0q2y.js +0 -1
  177. package/dist/bin/chunk-ett305ym.js +0 -4
  178. package/dist/bin/chunk-f11xf3n6.js +0 -2
  179. package/dist/bin/chunk-fq7ktvgy.js +0 -3
  180. package/dist/bin/chunk-fyq4th2m.js +0 -1
  181. package/dist/bin/chunk-g67qr8yf.js +0 -1
  182. package/dist/bin/chunk-gc82cx4h.js +0 -1
  183. package/dist/bin/chunk-hchtvpr9.js +0 -1
  184. package/dist/bin/chunk-hpe4jjce.js +0 -1
  185. package/dist/bin/chunk-k5vprsef.js +0 -6
  186. package/dist/bin/chunk-m22krd4z.js +0 -3
  187. package/dist/bin/chunk-mkppcwz8.js +0 -1
  188. package/dist/bin/chunk-mpjg0kc7.js +0 -2
  189. package/dist/bin/chunk-mrm4m4dk.js +0 -2
  190. package/dist/bin/chunk-nff46rxd.js +0 -1
  191. package/dist/bin/chunk-np1z3bgt.js +0 -1
  192. package/dist/bin/chunk-nskxkk6r.js +0 -1
  193. package/dist/bin/chunk-pez932b1.js +0 -111
  194. package/dist/bin/chunk-qsdf5kzk.js +0 -2
  195. package/dist/bin/chunk-r61qmhv1.js +0 -2
  196. package/dist/bin/chunk-r6gdcz5c.js +0 -1
  197. package/dist/bin/chunk-satwnr42.js +0 -2
  198. package/dist/bin/chunk-smbycpt5.js +0 -44
  199. package/dist/bin/chunk-sn7e0sn7.js +0 -2
  200. package/dist/bin/chunk-ss574pka.js +0 -1
  201. package/dist/bin/chunk-tj0xb2d8.js +0 -585
  202. package/dist/bin/chunk-v3rzf9d0.js +0 -141
  203. package/dist/bin/chunk-wnpma6t3.js +0 -34
  204. package/dist/bin/chunk-xan0e052.js +0 -5
  205. package/dist/bin/chunk-xbk2y43r.js +0 -60
  206. package/dist/bin/chunk-xjp3v95e.js +0 -6
  207. package/dist/bin/chunk-xyt490vp.js +0 -6
  208. package/dist/bin/chunk-yn9r02gy.js +0 -1
  209. package/dist/bin/chunk-zhkhn9cc.js +0 -1
  210. package/dist/chunk-0zf72ngj.js +0 -1
  211. package/dist/chunk-2hpjte1d.js +0 -704
  212. package/dist/chunk-4m6gwhwr.js +0 -5
  213. package/dist/chunk-5m29dhke.js +0 -34
  214. package/dist/chunk-6fzeemcs.js +0 -114
  215. package/dist/chunk-bpnhqb70.js +0 -6
  216. package/dist/chunk-ead1nkbr.js +0 -60
  217. package/dist/chunk-fea461tj.js +0 -141
  218. package/dist/chunk-fvjczc73.js +0 -1
  219. package/dist/chunk-gearw6rk.js +0 -4
  220. package/dist/chunk-j60hesb3.js +0 -2
  221. package/dist/chunk-pmgtmt3d.js +0 -1
  222. package/dist/chunk-prf2pkvq.js +0 -5
  223. package/dist/chunk-q0wffgw5.js +0 -37
  224. package/dist/chunk-qcemnt35.js +0 -50
  225. package/dist/chunk-qvbwsaay.js +0 -1
  226. package/dist/chunk-r2pbqcnz.js +0 -2
  227. package/dist/chunk-r6110zv2.js +0 -1
  228. package/dist/chunk-wcrj06cg.js +0 -44
  229. package/dist/chunk-wte9mh18.js +0 -92
  230. package/dist/chunk-y6e86wjs.js +0 -445
  231. package/dist/chunk-y8b7ht4v.js +0 -1
  232. package/dist/chunk-yf487g6e.js +0 -2
  233. package/dist/chunk-zmmc9j5f.js +0 -2
  234. package/dist/ui/_stx/runtime.c696d17a.js +0 -1
@@ -0,0 +1 @@
1
+ import{uf as a}from"./chunk-xcj8zfmg.js";import"./chunk-mz0dk78z.js";import"./chunk-13qjvbqh.js";export{a as RDSClient};
@@ -0,0 +1,2 @@
1
+ import{Tf as y}from"./chunk-y4xkj2f1.js";import{$h as Z}from"./chunk-mz0dk78z.js";var E=new Set(["A","AAAA","CNAME"]);function x(e,t=""){return e===408||e===409||e===425||e===429||e>=500||/rate limit|temporar|timed? ?out|try again/i.test(t)}async function S(e,t){let r=t?.headers.get("retry-after"),n=r===null||r===void 0?void 0:Number(r)*1000,s=Number.isFinite(n)?Math.max(0,n):Math.min(1000*2**(e-1),30000);await new Promise((o)=>setTimeout(o,s))}class R{name="porkbun";apiKey;secretKey;requestTimeoutMs;constructor(e,t,r=15000){this.apiKey=e,this.secretKey=t,this.requestTimeoutMs=r}async request(e,t={}){let r;for(let n=1;n<=8;n+=1){let s,o=new AbortController,i=setTimeout(()=>{o.abort(Error(`Porkbun API request timed out after ${this.requestTimeoutMs}ms`))},this.requestTimeoutMs);try{s=await fetch(`https://api.porkbun.com/api/json/v3${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apikey:this.apiKey,secretapikey:this.secretKey,...t}),signal:o.signal})}catch(c){if(r=c,n===8)throw c;await S(n);continue}finally{clearTimeout(i)}if(!s.ok){if(r=Error(`Porkbun API error: ${s.status} ${s.statusText}`),!x(s.status)||n===8)throw r;await S(n,s);continue}let a=await s.json();if(a.status==="ERROR"){if(r=Error(`Porkbun API error: ${a.message||"Unknown error"}`),!x(0,a.message)||n===8)throw r;await S(n,s);continue}return a}throw r}getSubdomain(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(r===n)return"";if(r.endsWith(`.${n}`))return r.slice(0,-(n.length+1));return r}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}static ADDRESS_TYPES=new Set(["A","AAAA"]);async clearConflictingAliases(e,t){if(!R.ADDRESS_TYPES.has(t.type))return[];let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),s=await this.listRecords(e);if(!s.success)return[`could not list records to clear ALIAS/CNAME conflicts: ${s.message??"unknown provider error"}`];let o=[];for(let i of s.records){if(i.type!=="ALIAS"&&i.type!=="CNAME")continue;if(this.getSubdomain(i.name,r)!==n)continue;let a=await this.deleteRecord(e,i);if(!a.success)o.push(`could not remove conflicting ${i.type} on ${i.name}: ${a.message??"unknown provider error"}`)}return o}async addressRecordExists(e,t){let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),s=await this.listRecords(e);if(!s.success)return!0;return s.records.some((o)=>o.type===t.type&&this.getSubdomain(o.name,r)===n&&o.content===t.content)}async createRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),s={type:t.type,content:t.content,ttl:String(t.ttl||600)};if(n)s.name=n;if((t.type==="MX"||t.type==="SRV")&&t.priority!==void 0)s.prio=String(t.priority);if(t.type==="SRV"&&t.weight!==void 0&&t.port!==void 0)s.content=`${t.weight} ${t.port} ${t.content}`;let o=await this.clearConflictingAliases(e,t),i=await this.request(`/dns/create/${r}`,s);if(R.ADDRESS_TYPES.has(t.type)&&!await this.addressRecordExists(e,t))return{success:!1,message:`Porkbun reported success but no ${t.type} record for ${t.name} exists${o.length>0?` (${o.join("; ")})`:""}. A conflicting ALIAS/CNAME on the same name silently voids the write.`};return{success:!0,id:i.id?.toString(),message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),s=await this.listRecords(e,t.type);if(s.success){let o=s.records.find((i)=>this.getSubdomain(i.name,r)===n&&i.type===t.type);if(o?.id){let i={type:t.type,content:t.content,ttl:String(t.ttl||600)};if(n)i.name=n;if((t.type==="MX"||t.type==="SRV")&&t.priority!==void 0)i.prio=String(t.priority);if(t.type==="SRV"&&t.weight!==void 0&&t.port!==void 0)i.content=`${t.weight} ${t.port} ${t.content}`;return await this.request(`/dns/edit/${r}/${o.id}`,i),{success:!0,id:o.id,message:"Record updated successfully"}}}return this.createRecord(e,t)}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=this.getRootDomain(e);if("id"in t&&t.id)return await this.request(`/dns/delete/${r}/${t.id}`),{success:!0,message:"Record deleted successfully"};let n=this.getSubdomain(t.name,r),s=await this.listRecords(e);if(!s.success)return{success:!1,message:"Failed to list records"};let o=s.records.find((i)=>this.getSubdomain(i.name,r)===n&&i.type===t.type&&i.content===t.content);if(!o?.id)return{success:!1,message:"Record not found"};return await this.request(`/dns/delete/${r}/${o.id}`),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=this.getRootDomain(e),n=`/dns/retrieve/${r}`;if(t)n=`/dns/retrieveByNameType/${r}/${t}`;return{success:!0,records:((await this.request(n)).records||[]).map((i)=>({id:i.id,name:i.name||r,type:i.type,content:i.content,ttl:Number.parseInt(i.ttl,10),priority:i.prio?Number.parseInt(i.prio,10):void 0}))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{let t=this.getRootDomain(e);return await this.request(`/dns/retrieve/${t}`),!0}catch{return!1}}async listDomains(){try{return((await this.request("/domain/listAll")).domains||[]).map((t)=>t.domain)}catch{return[]}}async getNameServers(e){try{let t=this.getRootDomain(e);return(await this.request(`/dns/getNS/${t}`)).ns||[]}catch{return[]}}async updateNameServers(e,t){try{let r=this.getRootDomain(e);return await this.request(`/dns/updateNS/${r}`,{ns:t}),!0}catch{return!1}}}class w{name="godaddy";apiKey;apiSecret;baseUrl;constructor(e,t="",r="production"){this.apiKey=e,this.apiSecret=t,this.baseUrl=r==="ote"?"https://api.ote-godaddy.com":"https://api.godaddy.com"}authorization(){if(!this.apiSecret||this.apiKey.startsWith("gd_pat_"))return`Bearer ${this.apiKey}`;return`sso-key ${this.apiKey}:${this.apiSecret}`}async request(e,t,r){let n=`${this.baseUrl}${t}`,s={Authorization:this.authorization(),"Content-Type":"application/json",Accept:"application/json"},o={method:e,headers:s};if(r)o.body=JSON.stringify(r);let i=await fetch(n,o);if(i.status===204)return{};if(i.ok){let c=await i.text();if(c)return JSON.parse(c);return{}}let a=`GoDaddy API error: ${i.status} ${i.statusText}`;try{let c=await i.json();if(c.message)a=`GoDaddy API error: ${c.message}`;if(c.fields)a+=` - Fields: ${JSON.stringify(c.fields)}`}catch{}throw Error(a)}getSubdomain(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(r===n)return"@";if(r.endsWith(`.${n}`))return r.slice(0,-(n.length+1));return r}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}toGoDaddyRecord(e,t){let r=this.getRootDomain(t),n=this.getSubdomain(e.name,r),s={type:e.type,name:n,data:e.content,ttl:e.ttl||600};if(e.type==="MX"&&e.priority!==void 0)s.priority=e.priority;return s}fromGoDaddyRecord(e,t){let r=this.getRootDomain(t),n=e.name;if(n==="@")n=r;else if(!n.endsWith(r))n=`${n}.${r}`;return{name:n,type:e.type,content:e.data,ttl:e.ttl,priority:e.priority}}async createRecord(e,t){try{let r=this.getRootDomain(e),n=this.toGoDaddyRecord(t,e);return await this.request("PATCH",`/v1/domains/${r}/records`,[n]),{success:!0,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=this.getRootDomain(e),n=this.toGoDaddyRecord(t,e);return await this.request("PUT",`/v1/domains/${r}/records/${t.type}/${n.name}`,[n]),{success:!0,message:"Record upserted successfully"}}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=this.getRootDomain(e),n=this.getSubdomain(t.name,r),s=await this.request("GET",`/v1/domains/${r}/records/${t.type}/${n}`),o=s.filter((i)=>i.data!==t.content);if(o.length===s.length)return{success:!1,message:"Record not found"};if(o.length===0)try{await this.request("DELETE",`/v1/domains/${r}/records/${t.type}/${n}`)}catch{}else await this.request("PUT",`/v1/domains/${r}/records/${t.type}/${n}`,o);return{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=this.getRootDomain(e),n=`/v1/domains/${r}/records`;if(t)n=`/v1/domains/${r}/records/${t}`;return{success:!0,records:(await this.request("GET",n)).map((o)=>this.fromGoDaddyRecord(o,e))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{let t=this.getRootDomain(e);return await this.request("GET",`/v1/domains/${t}`),!0}catch{return!1}}async listDomains(){try{return(await this.request("GET","/v1/domains")).map((t)=>t.domain)}catch{return[]}}async getDomainDetails(e){try{let t=this.getRootDomain(e),r=await this.request("GET",`/v1/domains/${t}`);return{domain:r.domain,status:r.status,nameServers:r.nameServers,expires:r.expires}}catch{return null}}async getNameServers(e){return(await this.getDomainDetails(e))?.nameServers??[]}async updateNameServers(e,t){try{let r=this.getRootDomain(e);return await this.request("PATCH",`/v1/domains/${r}`,{nameServers:t}),!0}catch{return!1}}async checkDomainAvailability(e){try{let t=await this.request("GET",`/v1/domains/available?domain=${encodeURIComponent(e)}`);return{available:t.available,price:t.price,currency:t.currency}}catch{return{available:!1}}}}var O="https://api.cloudflare.com/client/v4",T="[ts-cloud]";class v{name="cloudflare";apiToken;zoneCache=new Map;configuredZoneId;accountId;configuredZoneName;constructor(e,t={}){this.apiToken=e,this.configuredZoneId=t.zoneId,this.accountId=t.accountId}async request(e,t,r){let n=`${O}${t}`,s={Authorization:`Bearer ${this.apiToken}`,"Content-Type":"application/json"},o={method:e,headers:s};if(r)o.body=JSON.stringify(r);let a=await(await fetch(n,o)).json();if(!a.success){let c=a.errors.map((d)=>d.message).join(", ");throw Error(`Cloudflare API error: ${c}`)}return a}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}async resolveZone(e){let t=e.replace(/\.$/,"").toLowerCase();if(this.configuredZoneId){let i=await this.resolveConfiguredZoneName();if(i&&(t===i||t.endsWith(`.${i}`)))return{id:this.configuredZoneId,name:i}}let r=this.getRootDomain(t),n=this.zoneCache.get(r);if(n)return{id:n,name:r};let s=await this.request("GET",`/zones?name=${encodeURIComponent(r)}`);if(!s.result||s.result.length===0)throw Error(`Zone not found for domain: ${r}. `+"If the API token is scoped to a single zone, set its zone id (CLOUDFLARE_ZONE_ID) — "+"zone lookup by name needs account-wide Zone:Read.");let o=s.result[0].id;return this.zoneCache.set(r,o),{id:o,name:s.result[0].name||r}}async resolveConfiguredZoneName(){if(!this.configuredZoneId)return;if(this.configuredZoneName)return this.configuredZoneName;try{let t=(await this.request("GET",`/zones/${this.configuredZoneId}`)).result?.name?.toLowerCase();if(!t)return;return this.configuredZoneName=t,this.zoneCache.set(t,this.configuredZoneId),t}catch{return}}async getZoneId(e){return(await this.resolveZone(e)).id}getFullRecordName(e,t){let r=e.replace(/\.$/,"");if(!r||r===t||r==="@")return t;if(r.endsWith(`.${t}`))return r;return`${r}.${t}`}toCloudflareRecord(e,t,r){let n={type:e.type,name:this.getFullRecordName(e.name,t),content:e.content||e.value||"",ttl:e.ttl||1},s=r??e.proxied;if(s!==void 0&&E.has(e.type)){if(n.proxied=s,s)n.ttl=1}if(e.type==="MX"&&e.priority!==void 0)n.priority=e.priority;if(e.type==="SRV"){let o=z(e);if(o)n.data=o,delete n.content,delete n.priority;else if(e.priority!==void 0)n.priority=e.priority}return n}fromCloudflareRecord(e){return{id:e.id,name:e.name,type:e.type,content:e.content,ttl:e.ttl,priority:e.priority,proxied:e.proxied}}async createRecord(e,t){try{let r=await this.resolveZone(e),n=this.toCloudflareRecord(t,r.name);return{success:!0,id:(await this.request("POST",`/zones/${r.id}/dns_records`,n)).result.id,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=await this.resolveZone(e),n=this.getFullRecordName(t.name,r.name),o=(await this.request("GET",`/zones/${r.id}/dns_records?type=${t.type}&name=${encodeURIComponent(n)}`)).result?.[0],i=t.proxied??o?.proxied,a=this.toCloudflareRecord(t,r.name,i);if(o)return{success:!0,id:(await this.request("PUT",`/zones/${r.id}/dns_records/${o.id}`,a)).result.id,message:"Record updated successfully"};return{success:!0,id:(await this.request("POST",`/zones/${r.id}/dns_records`,a)).result.id,message:"Record created successfully"}}catch(r){return this.createRecord(e,t)}}async deleteRecord(e,t){try{let r=await this.resolveZone(e),n=r.id,s=this.getFullRecordName(t.name,r.name),o=await this.request("GET",`/zones/${n}/dns_records?type=${t.type}&name=${encodeURIComponent(s)}`);if(!o.result||o.result.length===0)return{success:!1,message:"Record not found"};let i=o.result.find((a)=>a.content===t.content);if(!i)return{success:!1,message:"Record with matching content not found"};return await this.request("DELETE",`/zones/${n}/dns_records/${i.id}`),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let n=`/zones/${await this.getZoneId(e)}/dns_records?per_page=100`;if(t)n+=`&type=${t}`;let s=[],o=1,i=!0;while(i){let a=await this.request("GET",`${n}&page=${o}`);if(s.push(...a.result||[]),a.result_info)i=o<a.result_info.total_pages,o++;else i=!1}return{success:!0,records:s.map((a)=>this.fromCloudflareRecord(a))}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){try{return await this.getZoneId(e),!0}catch{return!1}}async listDomains(){try{let e=[],t=1,r=!0;while(r){let n=await this.request("GET",`/zones?per_page=50&page=${t}`);if(e.push(...n.result||[]),n.result_info)r=t<n.result_info.total_pages,t++;else r=!1}return e.map((n)=>n.name)}catch{return[]}}async createZone(e,t={}){let r=e.replace(/\.$/,"").toLowerCase(),n=t.accountId??this.accountId;if(!n)throw Error(`Cannot create zone ${r}: no Cloudflare account id. Set CLOUDFLARE_ACCOUNT_ID, or pass accountId.`);let s=await this.getZoneDetails(r);if(s)return{...s,created:!1};try{let i=(await this.request("POST","/zones",{name:r,account:{id:n},jump_start:t.jumpStart??!1})).result;return this.zoneCache.set(i.name,i.id),{id:i.id,name:i.name,status:i.status,nameServers:i.name_servers??[],created:!0}}catch(o){let i=o instanceof Error?o.message:String(o);if(!/already exists|1061/i.test(i))throw o;let a=await this.getZoneDetails(r);if(!a)throw o;return{...a,created:!1}}}async getZoneDetails(e){try{let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}`);return{id:r.result.id,name:r.result.name,status:r.result.status,nameServers:r.result.name_servers,paused:r.result.paused}}catch{return null}}async listEdgeCertificateHosts(e){try{let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/ssl/certificate_packs?per_page=50`),n=new Set;for(let s of r.result||[]){if(s.status!=="active")continue;for(let o of s.hosts||[])n.add(o.toLowerCase())}return[...n]}catch{return null}}async purgeCache(e,t){try{let r=await this.getZoneId(e),n={};if(t?.purgeEverything)n.purge_everything=!0;else{if(t?.files)n.files=t.files;if(t?.tags)n.tags=t.tags;if(t?.hosts)n.hosts=t.hosts}if(Object.keys(n).length===0)n.purge_everything=!0;return await this.request("POST",`/zones/${r}/purge_cache`,n),!0}catch{return!1}}async getRecordProxyStatus(e,t){try{let r=await this.resolveZone(e),n=r.id,s=this.getFullRecordName(t.name,r.name),o=await this.request("GET",`/zones/${n}/dns_records?type=${t.type}&name=${encodeURIComponent(s)}`);if(o.result&&o.result.length>0)return o.result.find((a)=>a.content===t.content)?.proxied??null;return null}catch{return null}}async setRecordProxyStatus(e,t,r){try{let n=await this.resolveZone(e),s=n.id,o=this.getFullRecordName(t.name,n.name),i=await this.request("GET",`/zones/${s}/dns_records?type=${t.type}&name=${encodeURIComponent(o)}`);if(!i.result||i.result.length===0)return!1;let a=i.result.find((c)=>c.content===t.content);if(!a)return!1;return await this.request("PATCH",`/zones/${s}/dns_records/${a.id}`,{proxied:r}),!0}catch{return!1}}async zoneIdFor(e){return this.getZoneId(e)}get account(){return this.accountId}async getZoneSettings(e){let t=await this.getZoneId(e),r=await this.request("GET",`/zones/${t}/settings`),n={};for(let s of r.result||[])n[s.id]=s.value;return n}async applyZoneSettings(e,t){let r=await this.getZoneId(e),n=await this.getZoneSettings(e).catch(()=>({})),s=[],o=[];for(let[i,a]of Object.entries(t)){if(a===void 0)continue;let c=n[i];if(c!==void 0&&b(c,a))continue;try{await this.request("PATCH",`/zones/${r}/settings/${i}`,{value:a}),s.push({id:i,from:c,to:a})}catch(d){o.push({id:i,error:d instanceof Error?d.message:String(d)})}}return{changed:s,failed:o}}async getPhaseRules(e,t){let r=await this.getZoneId(e);try{return(await this.request("GET",`/zones/${r}/rulesets/phases/${t}/entrypoint`)).result?.rules||[]}catch{return[]}}async putManagedPhaseRules(e,t,r){try{let n=await this.getZoneId(e),o=(await this.getPhaseRules(e,t)).filter((c)=>!(c.description||"").startsWith(T)),i=r.map((c)=>({...c,description:c.description?.startsWith(T)?c.description:`${T} ${c.description||t}`})),a=[...o,...i].map(({id:c,...d})=>d);return await this.request("PUT",`/zones/${n}/rulesets/phases/${t}/entrypoint`,{rules:a}),{success:!0}}catch(n){return{success:!1,message:n instanceof Error?n.message:String(n)}}}}function b(e,t){if(e===t)return!0;if(typeof e!==typeof t||e===null||t===null)return!1;if(typeof e!=="object")return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;return e.every((s,o)=>b(s,t[o]))}let r=e,n=t;return Object.keys(n).every((s)=>b(r[s],n[s]))}function z(e){let t=(e.content||e.value||"").trim();if(e.weight!==void 0&&e.port!==void 0&&e.priority!==void 0&&t)return{priority:e.priority,weight:e.weight,port:e.port,target:V(t)};let r=t.split(/\s+/);if(r.length<4)return null;let[n,s,o]=r.slice(0,3).map(Number);if(![n,s,o].every(Number.isFinite))return null;return{priority:n,weight:s,port:o,target:V(r.slice(3).join(" "))}}function V(e){return e.replace(/\.$/,"")}var L=new Set(["A","AAAA","CNAME","ALIAS"]);function A(e){let t=e.trim().replace(/^"|"$/g,"").toLowerCase();if(t.startsWith("v=spf1"))return"v=spf1";if(t.startsWith("v=dmarc1"))return"v=dmarc1";return}function p(e){return e.trim().replace(/^"(.*)"$/s,"$1")}function h(e){return e.replace(/\.$/,"").toLowerCase()}function M(e,t){let r=h(t),n=(e??"@").trim();if(!n||n==="@")return r;let s=h(n);if(s===r||s.endsWith(`.${r}`))return s;return`${s}.${r}`}function U(e,t){return e.map((r)=>({...r,name:M(r.name,t),proxied:r.proxied??!1}))}function q(e,t){if(e.type!==t.type)return!1;if(h(e.name)!==h(t.name))return!1;if(L.has(t.type))return!0;if(t.type==="TXT"){let r=A(t.content);if(r)return A(p(e.content))===r;return p(e.content)===p(t.content)}return p(e.content)===p(t.content)}function j(e,t){if(p(e.content)!==p(t.content))return!1;if(t.priority!==void 0&&e.priority!==t.priority)return!1;if(t.proxied!==void 0&&e.proxied!==void 0&&e.proxied!==t.proxied)return!1;return!0}async function F(e){let{provider:t,zone:r,records:n}=e,s={outcomes:[],warnings:[]};if(n.length===0)return s;let o=await t.listRecords(r);if(!o.success)return s.warnings.push(`could not list ${r}: ${o.message||"unknown provider error"} — records not reconciled`),s;let i=o.records;for(let a of n){let c=i.filter((u)=>q(u,a));if(c.length>0&&c.every((u)=>j(u,a))){s.outcomes.push({record:a,action:"unchanged"});continue}let d={name:a.name,type:a.type,content:a.content,ttl:a.ttl??3600,...a.priority!==void 0?{priority:a.priority}:{},...a.proxied!==void 0?{proxied:a.proxied}:{}},m=a.type==="TXT"&&A(a.content)!==void 0;if(m)for(let u of c){let I=await t.deleteRecord(r,{name:u.name,type:u.type,content:u.content});if(!I.success)s.warnings.push(`could not remove superseded ${u.type} at ${u.name}: ${I.message||"unknown error"}`)}let g=m||c.length===0?await t.createRecord(r,d):await t.upsertRecord(r,d);if(g.success)s.outcomes.push({record:a,action:c.length>0?"updated":"created"});else s.outcomes.push({record:a,action:"failed",message:g.message})}for(let a of["MX"]){let c=new Set(n.filter((d)=>d.type===a).map((d)=>h(d.name)));for(let d of c){let m=new Set(n.filter((u)=>u.type===a&&h(u.name)===d).map((u)=>p(u.content).toLowerCase())),g=i.filter((u)=>u.type===a&&h(u.name)===d&&!m.has(p(u.content).toLowerCase()));for(let u of g)s.warnings.push(`${d} has an undeclared ${a} record (${u.content}) alongside the declared one — mail will be split between them. Remove it at the provider if it is stale.`)}}return s}class C{name="route53";client;hostedZoneCache=new Map;providedHostedZoneId;constructor(e="us-east-1",t){this.client=new y(e),this.providedHostedZoneId=t}getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length>=2)return t.slice(-2).join(".");return e}async getHostedZoneId(e){if(this.providedHostedZoneId)return this.providedHostedZoneId;let t=this.getRootDomain(e),r=this.hostedZoneCache.get(t);if(r)return r;let n=await this.client.findHostedZoneForDomain(e);if(n){let s=n.Id.replace("/hostedzone/","");return this.hostedZoneCache.set(t,s),s}return null}normalizeName(e,t){let r=e.replace(/\.$/,""),n=t.replace(/\.$/,"");if(!n||n==="@")return`${r}.`;if(n===r||n.endsWith(`.${r}`))return`${n}.`;return`${n}.${r}.`}async createRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),s=t.content;if(t.type==="TXT"&&!s.startsWith('"'))s=`"${s}"`;if(t.type==="MX"&&t.priority!==void 0)s=`${t.priority} ${s}`;return{success:!0,id:(await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Created by ts-cloud DNS provider",Changes:[{Action:"CREATE",ResourceRecordSet:{Name:n,Type:t.type,TTL:t.ttl||300,ResourceRecords:[{Value:s}]}}]}})).ChangeInfo?.Id,message:"Record created successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async upsertRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),s=t.content;if(t.type==="TXT"&&!s.startsWith('"'))s=`"${s}"`;if(t.type==="MX"&&t.priority!==void 0)s=`${t.priority} ${s}`;return{success:!0,id:(await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Upserted by ts-cloud DNS provider",Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:n,Type:t.type,TTL:t.ttl||300,ResourceRecords:[{Value:s}]}}]}})).ChangeInfo?.Id,message:"Record upserted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async deleteRecord(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,message:`No hosted zone found for domain: ${e}`};let n=this.normalizeName(e,t.name),s=t.content;if(t.type==="TXT"&&!s.startsWith('"'))s=`"${s}"`;if(t.type==="MX"&&t.priority!==void 0)s=`${t.priority} ${s}`;return await this.client.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:"Deleted by ts-cloud DNS provider",Changes:[{Action:"DELETE",ResourceRecordSet:{Name:n,Type:t.type,TTL:t.ttl||300,ResourceRecords:[{Value:s}]}}]}}),{success:!0,message:"Record deleted successfully"}}catch(r){return{success:!1,message:r instanceof Error?r.message:"Unknown error"}}}async listRecords(e,t){try{let r=await this.getHostedZoneId(e);if(!r)return{success:!1,records:[],message:`No hosted zone found for domain: ${e}`};let n=await this.client.listResourceRecordSets({HostedZoneId:r,StartRecordType:t}),s=[];for(let o of n.ResourceRecordSets){if(t&&o.Type!==t)continue;if(o.AliasTarget)continue;for(let i of o.ResourceRecords||[]){let a=i.Value,c;if(o.Type==="MX"){let d=a.split(" ");if(d.length>=2)c=Number.parseInt(d[0],10),a=d.slice(1).join(" ")}if(o.Type==="TXT"&&a.startsWith('"')&&a.endsWith('"'))a=a.slice(1,-1);s.push({name:o.Name.replace(/\.$/,""),type:o.Type,content:a,ttl:o.TTL,priority:c})}}return{success:!0,records:s}}catch(r){return{success:!1,records:[],message:r instanceof Error?r.message:"Unknown error"}}}async canManageDomain(e){return await this.getHostedZoneId(e)!==null}async listDomains(){try{return(await this.client.listHostedZones()).HostedZones.map((t)=>t.Name.replace(/\.$/,""))}catch{return[]}}getRoute53Client(){return this.client}async createAliasRecord(e){try{let t=await this.getHostedZoneId(e.domain);if(!t)return{success:!1,message:`No hosted zone found for domain: ${e.domain}`};return{success:!0,id:(await this.client.createAliasRecord({HostedZoneId:t,Name:this.normalizeName(e.domain,e.name),TargetHostedZoneId:e.targetHostedZoneId,TargetDNSName:e.targetDnsName,EvaluateTargetHealth:e.evaluateTargetHealth,Type:e.type})).ChangeInfo?.Id,message:"Alias record created successfully"}}catch(t){return{success:!1,message:t instanceof Error?t.message:"Unknown error"}}}async createCloudFrontAlias(e){return this.createAliasRecord({domain:e.domain,name:e.name,targetHostedZoneId:y.CloudFrontHostedZoneId,targetDnsName:e.cloudFrontDomainName,evaluateTargetHealth:!1})}async createAlbAlias(e){let t=y.ALBHostedZoneIds[e.region];if(!t)return{success:!1,message:`Unknown region for ALB: ${e.region}`};return this.createAliasRecord({domain:e.domain,name:e.name,targetHostedZoneId:t,targetDnsName:e.albDnsName,evaluateTargetHealth:!0})}}async function G(e,t){let r=[],n,s;for(;;){let o=await e.listResourceRecordSets({HostedZoneId:t,StartRecordName:n,StartRecordType:s,MaxItems:"100"});if(r.push(...o.ResourceRecordSets),!o.IsTruncated)break;if(n=o.NextRecordName,s=o.NextRecordType,!n)break}return r}function l(e){return e.replace(/\.$/,"").toLowerCase()}function _(e){return e.replace(/\.$/,"")}function P(e){if(e.type==="SRV"&&e.weight!==void 0&&e.port!==void 0)return`${e.weight} ${e.port} ${_(e.content)}`;return _(e.content)}function W(e){let t=e.match(/"(?:[^"\\]|\\.)*"/g);if(!t)return e;return t.map((r)=>r.slice(1,-1).replace(/\\(.)/g,"$1")).join("")}function H(e,t){let r=l(t),n=[],s=[],o=[],i=new Set;for(let a of e){let c=l(a.Name),d=a.Type;if(d==="SOA"||d==="NS"&&c===r){s.push({name:c,type:d,reason:"owned by the destination provider"});continue}if(a.SetIdentifier){s.push({name:c,type:d,reason:`routing policy record (SetIdentifier=${a.SetIdentifier}) has no equivalent — recreate by hand`}),o.push(`${d} ${c} is part of a Route53 routing policy and was NOT migrated`);continue}if(a.AliasTarget){if(i.has(c))continue;i.add(c);let m=l(a.AliasTarget.DNSName);if(n.push({name:c,type:"CNAME",content:m,ttl:300,translatedFrom:`${d} ALIAS → ${m}`}),a.AliasTarget.EvaluateTargetHealth)o.push(`${c} was an ALIAS with health evaluation enabled; the CNAME that replaces it has no health check`);continue}for(let m of a.ResourceRecords||[]){let g=K(c,d,m.Value,a.TTL);if("reason"in g){s.push({name:c,type:d,reason:g.reason}),o.push(`${d} ${c}: ${g.reason}`);continue}n.push(g)}}return{zone:r,records:n,skipped:s,warnings:o}}function K(e,t,r,n){let s={name:e,ttl:n};switch(t){case"A":case"AAAA":case"CNAME":case"PTR":return{...s,type:t==="PTR"?"CNAME":t,content:l(r)};case"TXT":return{...s,type:"TXT",content:W(r)};case"MX":{let[o,...i]=r.trim().split(/\s+/);if(!i.length)return{reason:`malformed MX value "${r}"`};return{...s,type:"MX",content:l(i.join(" ")),priority:Number(o)}}case"SRV":{let o=r.trim().split(/\s+/);if(o.length<4)return{reason:`malformed SRV value "${r}"`};let[i,a,c]=o.slice(0,3).map(Number);return{...s,type:"SRV",content:l(o.slice(3).join(" ")),priority:i,weight:a,port:c}}case"NS":return{...s,type:"NS",content:l(r)};case"CAA":return{...s,type:"CAA",content:r.trim()};default:return{reason:`unsupported record type ${t}`}}}var X=new Set(["TXT","MX","SRV","NS","CAA"]);async function B(e,t){let r=[],n=[],s=new Set;try{let o=await e.listRecords(t.zone);for(let i of o.records||[])s.add(`${l(i.name)}|${i.type}|${P(i)}`)}catch{}for(let o of t.records){let i={...o,proxied:!1},a=`${l(o.name)}|${o.type}|${P(o)}`;if(!X.has(o.type)){let d=await e.upsertRecord(t.zone,i);if(d.success)r.push(o);else n.push({record:o,message:d.message||"unknown provider error"});continue}if(s.has(a)){r.push(o);continue}let c=await e.createRecord(t.zone,i);if(c.success)s.add(a),r.push(o);else n.push({record:o,message:c.message||"unknown provider error"})}return{applied:r,failed:n}}async function Y(e,t){let r=await e.listRecords(t.zone),n=[],s=[],o=new Map;for(let i of r.records||[]){let a=`${l(i.name)}|${i.type}`,c=o.get(a)??[];c.push(P(i)),o.set(a,c)}for(let i of t.records){let a=o.get(`${l(i.name)}|${i.type}`),c=P(i);if(a?.some((d)=>d===c))n.push(i);else s.push({record:i,found:a?.join(", ")})}return{matched:n,missing:s,ok:s.length===0}}class N{client;region;constructor(e="us-east-1"){this.client=new Z,this.region=e}async requestCertificate(e){let t={DomainName:e.DomainName,ValidationMethod:e.ValidationMethod||"DNS"};if(e.SubjectAlternativeNames)t.SubjectAlternativeNames=e.SubjectAlternativeNames;return{CertificateArn:(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.RequestCertificate"},body:JSON.stringify(t)})).CertificateArn||""}}async describeCertificate(e){let r=(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.DescribeCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})).Certificate||{};return{CertificateArn:r.CertificateArn||"",DomainName:r.DomainName||"",SubjectAlternativeNames:r.SubjectAlternativeNames,Status:r.Status||"PENDING_VALIDATION",Type:r.Type,DomainValidationOptions:r.DomainValidationOptions?.map((n)=>({DomainName:n.DomainName,ValidationDomain:n.ValidationDomain,ValidationStatus:n.ValidationStatus,ResourceRecord:n.ResourceRecord?{Name:n.ResourceRecord.Name,Type:n.ResourceRecord.Type,Value:n.ResourceRecord.Value}:void 0,ValidationMethod:n.ValidationMethod})),CreatedAt:r.CreatedAt,IssuedAt:r.IssuedAt,NotBefore:r.NotBefore,NotAfter:r.NotAfter}}async listCertificates(e){let t={};if(e?.CertificateStatuses)t.CertificateStatuses=e.CertificateStatuses;if(e?.MaxItems)t.MaxItems=e.MaxItems;if(e?.NextToken)t.NextToken=e.NextToken;let r=await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ListCertificates"},body:JSON.stringify(t)});return{CertificateSummaryList:(r.CertificateSummaryList||[]).map((n)=>({CertificateArn:n.CertificateArn,DomainName:n.DomainName})),NextToken:r.NextToken}}async deleteCertificate(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.DeleteCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})}async listTagsForCertificate(e){return{Tags:(await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ListTagsForCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn})})).Tags||[]}}async addTagsToCertificate(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.AddTagsToCertificate"},body:JSON.stringify({CertificateArn:e.CertificateArn,Tags:e.Tags})})}async resendValidationEmail(e){await this.client.request({service:"acm",region:this.region,method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"CertificateManager.ResendValidationEmail"},body:JSON.stringify({CertificateArn:e.CertificateArn,Domain:e.Domain,ValidationDomain:e.ValidationDomain})})}async findCertificateByDomain(e){let r=(await this.listCertificates({CertificateStatuses:["ISSUED"]})).CertificateSummaryList.find((n)=>n.DomainName===e||n.DomainName===`*.${e.split(".").slice(1).join(".")}`);if(!r)return null;return this.describeCertificate({CertificateArn:r.CertificateArn})}async waitForCertificateValidation(e,t=60,r=30000){for(let n=0;n<t;n++){let s=await this.describeCertificate({CertificateArn:e});if(s.Status==="ISSUED")return s;if(s.Status==="FAILED"||s.Status==="VALIDATION_TIMED_OUT")return null;await new Promise((o)=>setTimeout(o,r))}return null}async getDnsValidationRecords(e){let t=await this.describeCertificate({CertificateArn:e});if(!t.DomainValidationOptions)return[];return t.DomainValidationOptions.filter((r)=>r.ResourceRecord&&r.ValidationMethod==="DNS").map((r)=>({domainName:r.DomainName,recordName:r.ResourceRecord.Name,recordType:r.ResourceRecord.Type,recordValue:r.ResourceRecord.Value}))}async requestCertificateWithSans(e){let t=new Set;if(t.add(e.DomainName),e.IncludeWww!==!1)t.add(`www.${e.DomainName}`);if(e.IncludeWildcard)t.add(`*.${e.DomainName}`);if(e.AdditionalSans)for(let r of e.AdditionalSans)t.add(r);return this.requestCertificate({DomainName:e.DomainName,SubjectAlternativeNames:Array.from(t),ValidationMethod:"DNS"})}async isCertificateValidForDomain(e,t){let r=await this.describeCertificate({CertificateArn:e});if(r.Status!=="ISSUED")return!1;if(r.DomainName===t)return!0;if(r.DomainName?.startsWith("*.")){let n=r.DomainName.slice(2),s=t.split("."),o=n.split(".");if(s.slice(-o.length).join(".")===n)return!0}if(r.SubjectAlternativeNames)for(let n of r.SubjectAlternativeNames){if(n===t)return!0;if(n.startsWith("*.")){let s=n.slice(2),o=t.split("."),i=s.split(".");if(o.slice(-i.length).join(".")===s)return!0}}return!1}}class J{acm;route53;dnsProvider;constructor(e="us-east-1",t){if(this.acm=new N(e),this.route53=new y,t&&t.provider!=="route53")this.dnsProvider=f(t)}async requestAndValidate(e){let{domainName:t,hostedZoneId:r,subjectAlternativeNames:n=[],waitForValidation:s=!1,maxWaitMinutes:o=30}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let{CertificateArn:i}=await this.acm.requestCertificate({DomainName:t,SubjectAlternativeNames:n.length>0?[t,...n]:void 0,ValidationMethod:"DNS"});await this.waitForValidationOptions(i);let a=await this.acm.getDnsValidationRecords(i);if(this.dnsProvider)for(let c of a){let d=await this.dnsProvider.upsertRecord(t,{name:c.recordName,type:c.recordType,content:c.recordValue,ttl:300});if(!d.success)console.warn(`Failed to create validation record for ${c.domainName}: ${d.message}`)}else if(r)for(let c of a)await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`ACM DNS validation for ${c.domainName}`,Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:c.recordName,Type:c.recordType,TTL:300,ResourceRecords:[{Value:c.recordValue}]}}]}});if(s){if(!await this.acm.waitForCertificateValidation(i,o*2,30000))throw Error(`Certificate validation timed out after ${o} minutes`)}return{certificateArn:i,validationRecords:a}}async waitForValidationOptions(e,t=30){for(let r=0;r<t;r++){let n=await this.acm.describeCertificate({CertificateArn:e});if(n.DomainValidationOptions&&n.DomainValidationOptions.length>0&&n.DomainValidationOptions[0].ResourceRecord)return;await new Promise((s)=>setTimeout(s,2000))}throw Error("Timeout waiting for DNS validation options")}async createValidationRecords(e){let{certificateArn:t,hostedZoneId:r,domain:n}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let s=await this.acm.getDnsValidationRecords(t),o=[];if(this.dnsProvider){let i=n||s[0]?.domainName;for(let a of s){let c=await this.dnsProvider.upsertRecord(i,{name:a.recordName,type:a.recordType,content:a.recordValue,ttl:300});o.push({...a,changeId:c.success?c.id:void 0})}}else if(r)for(let i of s){let a=await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`ACM DNS validation for ${i.domainName}`,Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:i.recordName,Type:i.recordType,TTL:300,ResourceRecords:[{Value:i.recordValue}]}}]}});o.push({...i,changeId:a.ChangeInfo?.Id})}return o}async deleteValidationRecords(e){let{certificateArn:t,hostedZoneId:r,domain:n}=e,s=await this.acm.getDnsValidationRecords(t);if(this.dnsProvider){let o=n||s[0]?.domainName;for(let i of s)try{await this.dnsProvider.deleteRecord(o,{name:i.recordName,type:i.recordType,content:i.recordValue})}catch{}}else if(r)for(let o of s)try{await this.route53.changeResourceRecordSets({HostedZoneId:r,ChangeBatch:{Comment:`Cleanup ACM DNS validation for ${o.domainName}`,Changes:[{Action:"DELETE",ResourceRecordSet:{Name:o.recordName,Type:o.recordType,TTL:300,ResourceRecords:[{Value:o.recordValue}]}}]}})}catch{}}async findOrCreateCertificate(e){let{domainName:t,hostedZoneId:r,subjectAlternativeNames:n,waitForValidation:s=!0}=e;if(!this.dnsProvider&&!r)throw Error("Either hostedZoneId or external DNS provider configuration is required");let o=await this.acm.findCertificateByDomain(t);if(o&&o.Status==="ISSUED")return{certificateArn:o.CertificateArn,isNew:!1};let{certificateArn:i}=await this.requestAndValidate({domainName:t,hostedZoneId:r,subjectAlternativeNames:n,waitForValidation:s});return{certificateArn:i,isNew:!0}}hasExternalDnsProvider(){return this.dnsProvider!==void 0}getDnsProviderName(){return this.dnsProvider?.name||"route53"}}class D{acm;dnsProvider;constructor(e,t="us-east-1"){if(this.acm=new N(t),"provider"in e)this.dnsProvider=f(e);else this.dnsProvider=e}getProvider(){return this.dnsProvider}async requestAndValidate(e){let{domainName:t,subjectAlternativeNames:r=[],waitForValidation:n=!1,maxWaitMinutes:s=30}=e,{CertificateArn:o}=await this.acm.requestCertificate({DomainName:t,SubjectAlternativeNames:r.length>0?[t,...r]:void 0,ValidationMethod:"DNS"});await this.waitForValidationOptions(o);let i=await this.acm.getDnsValidationRecords(o);for(let c of i){let d=await this.dnsProvider.upsertRecord(t,{name:c.recordName,type:c.recordType,content:c.recordValue,ttl:300});if(!d.success)console.warn(`Failed to create validation record for ${c.domainName}: ${d.message}`)}let a="pending";if(n)a=(await this.acm.waitForCertificateValidation(o,s*2,30000))?.Status==="ISSUED"?"issued":"failed";return{certificateArn:o,validationRecords:i.map((c)=>({domainName:c.domainName,recordName:c.recordName,recordType:c.recordType,recordValue:c.recordValue})),isNew:!0,status:a}}async createValidationRecords(e){let{certificateArn:t,domain:r}=e,n=[],s=await this.acm.getDnsValidationRecords(t);for(let o of s){let i=await this.dnsProvider.upsertRecord(r,{name:o.recordName,type:o.recordType,content:o.recordValue,ttl:300});if(!i.success)n.push(`Failed to create record for ${o.domainName}: ${i.message}`)}return{success:n.length===0,records:s.map((o)=>({domainName:o.domainName,recordName:o.recordName,recordType:o.recordType,recordValue:o.recordValue})),errors:n}}async deleteValidationRecords(e){let{certificateArn:t,domain:r}=e,n=[],s=await this.acm.getDnsValidationRecords(t);for(let o of s){let i=await this.dnsProvider.deleteRecord(r,{name:o.recordName,type:o.recordType,content:o.recordValue});if(!i.success)n.push(`Failed to delete record for ${o.domainName}: ${i.message}`)}return{success:n.length===0,errors:n}}async findOrCreateCertificate(e){let{domainName:t,subjectAlternativeNames:r=[],waitForValidation:n=!0,maxWaitMinutes:s}=e,o=await this.acm.findCertificateByDomain(t);if(o&&o.Status==="ISSUED"){let i=o.SubjectAlternativeNames||[o.DomainName],a=i.some((d)=>d===`*.${t}`);if(r.every((d)=>i.includes(d)||a))return{certificateArn:o.CertificateArn,validationRecords:[],isNew:!1,status:"issued"};console.log("Existing certificate doesn't cover all required SANs, requesting new certificate...")}return this.requestAndValidate({domainName:t,subjectAlternativeNames:r,waitForValidation:n,maxWaitMinutes:s})}async requestCertificateWithCommonSans(e){let{domainName:t,includeWww:r=!0,includeWildcard:n=!1,additionalSans:s=[],waitForValidation:o=!1}=e,i=[];if(r)i.push(`www.${t}`);if(n)i.push(`*.${t}`);return i.push(...s),this.requestAndValidate({domainName:t,subjectAlternativeNames:i,waitForValidation:o})}async waitForValidationOptions(e,t=30){for(let r=0;r<t;r++){let n=await this.acm.describeCertificate({CertificateArn:e});if(n.DomainValidationOptions&&n.DomainValidationOptions.length>0&&n.DomainValidationOptions[0].ResourceRecord)return;await new Promise((s)=>setTimeout(s,2000))}throw Error("Timeout waiting for DNS validation options")}async getCertificateStatus(e){let t=await this.acm.describeCertificate({CertificateArn:e});return{status:t.Status,domainValidations:(t.DomainValidationOptions||[]).map((r)=>({domain:r.DomainName,status:r.ValidationStatus||"UNKNOWN"}))}}}function Q(e,t,r){return new D({provider:"porkbun",apiKey:e,secretKey:t},r)}function ee(e,t,r,n){return new D({provider:"godaddy",apiKey:e,apiSecret:t,environment:n},r)}function te(e,t,r){return new D({provider:"route53",region:e,hostedZoneId:t},r||e)}function f(e){switch(e.provider){case"route53":return new C(e.region,e.hostedZoneId);case"porkbun":return new R(e.apiKey,e.secretKey);case"godaddy":return new w(e.apiKey,e.apiSecret,e.environment);case"cloudflare":return new v(e.apiToken,{zoneId:e.zoneId,accountId:e.accountId});default:throw Error(`Unknown DNS provider: ${e.provider}`)}}async function Ae(e,t){for(let r of t){let n=f(r);if(await n.canManageDomain(e))return n}return null}class k{providers=new Map;configs=[];addConfig(e){return this.configs.push(e),this}addRoute53(e,t){return this.configs.push({provider:"route53",region:e,hostedZoneId:t}),this}addPorkbun(e,t){return this.configs.push({provider:"porkbun",apiKey:e,secretKey:t}),this}addGoDaddy(e,t,r){return this.configs.push({provider:"godaddy",apiKey:e,apiSecret:t,environment:r}),this}addCloudflare(e,t={}){return this.configs.push({provider:"cloudflare",apiToken:e,zoneId:t.zoneId,accountId:t.accountId}),this}loadFromEnv(){if(process.env.AWS_ACCESS_KEY_ID||process.env.AWS_REGION)this.addRoute53(process.env.AWS_REGION);let e=process.env.PORKBUN_API_KEY,t=process.env.PORKBUN_SECRET_KEY;if(e&&t)this.addPorkbun(e,t);let r=process.env.GODADDY_API_KEY,n=process.env.GODADDY_API_SECRET;if(r&&n){let o=process.env.GODADDY_ENVIRONMENT;this.addGoDaddy(r,n,o)}let s=process.env.CLOUDFLARE_API_TOKEN;if(s)this.addCloudflare(s,{zoneId:process.env.CLOUDFLARE_ZONE_ID,accountId:process.env.CLOUDFLARE_ACCOUNT_ID});return this}getProvider(e){let t=this.providers.get(e);if(t)return t;let r=this.configs.find((s)=>s.provider===e);if(!r)return null;let n=f(r);return this.providers.set(e,n),n}async getProviderForDomain(e){for(let t of this.configs){let r=f(t);if(await r.canManageDomain(e))return r}return null}getAllProviders(){return this.configs.map((e)=>f(e))}}var Ce=new k;
2
+ export{E as vf,R as wf,w as xf,T as yf,v as zf,A as Af,M as Bf,U as Cf,F as Df,C as Ef,G as Ff,H as Gf,B as Hf,Y as If,D as Jf,Q as Kf,ee as Lf,te as Mf,f as Nf,Ae as Of,k as Pf,Ce as Qf,N as Rf,J as Sf};
@@ -0,0 +1,2 @@
1
+ import{$h as g}from"./chunk-mz0dk78z.js";class p{client;region;constructor(e="us-east-1",t){this.region=e,this.client=new g(void 0,{profile:t})}async createStack(e){let t={Action:"CreateStack",StackName:e.stackName,Version:"2010-05-15"};if(e.templateBody)t.TemplateBody=e.templateBody;else if(e.templateUrl)t.TemplateURL=e.templateUrl;else throw Error("Either templateBody or templateUrl must be provided");if(e.parameters)e.parameters.forEach((a,r)=>{t[`Parameters.member.${r+1}.ParameterKey`]=a.ParameterKey,t[`Parameters.member.${r+1}.ParameterValue`]=a.ParameterValue});if(e.capabilities)e.capabilities.forEach((a,r)=>{t[`Capabilities.member.${r+1}`]=a});if(e.roleArn)t.RoleARN=e.roleArn;if(e.tags)e.tags.forEach((a,r)=>{t[`Tags.member.${r+1}.Key`]=a.Key,t[`Tags.member.${r+1}.Value`]=a.Value});if(e.timeoutInMinutes)t.TimeoutInMinutes=e.timeoutInMinutes;if(e.onFailure)t.OnFailure=e.onFailure;let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{StackId:s.StackId||s.CreateStackResult?.StackId}}async updateStack(e){let t={Action:"UpdateStack",StackName:e.stackName,Version:"2010-05-15"};if(e.templateBody)t.TemplateBody=e.templateBody;else if(e.templateUrl)t.TemplateURL=e.templateUrl;if(e.parameters)e.parameters.forEach((a,r)=>{if(t[`Parameters.member.${r+1}.ParameterKey`]=a.ParameterKey,a.UsePreviousValue)t[`Parameters.member.${r+1}.UsePreviousValue`]="true";else t[`Parameters.member.${r+1}.ParameterValue`]=a.ParameterValue});if(e.capabilities)e.capabilities.forEach((a,r)=>{t[`Capabilities.member.${r+1}`]=a});if(e.roleArn)t.RoleARN=e.roleArn;if(e.tags)e.tags.forEach((a,r)=>{t[`Tags.member.${r+1}.Key`]=a.Key,t[`Tags.member.${r+1}.Value`]=a.Value});let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{StackId:s.StackId||s.UpdateStackResult?.StackId}}async deleteStack(e,t,s){let a={Action:"DeleteStack",StackName:e,Version:"2010-05-15"};if(t)a.RoleARN=t;if(s&&s.length>0)s.forEach((r,m)=>{a[`RetainResources.member.${m+1}`]=r});await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(a).toString()})}async describeStacks(e={}){let t={Action:"DescribeStacks",Version:"2010-05-15"};if(e.stackName)t.StackName=e.stackName;let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{Stacks:this.parseStacksResponse(s)}}async describeStackEvents(e){let t={Action:"DescribeStackEvents",StackName:e,Version:"2010-05-15"},s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{StackEvents:this.parseStackEvents(s)}}async listStackResources(e){let t={Action:"ListStackResources",StackName:e,Version:"2010-05-15"},a=(await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()}))?.ListStackResourcesResult?.StackResourceSummaries?.member,r=[];if(a)r=Array.isArray(a)?a:[a];return{StackResourceSummaries:r}}async waitForStack(e,t){let s={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},a=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],r=s[t],m=360,i=0;while(i<360)try{let c=await this.describeStacks({stackName:e});if(c.Stacks.length===0){if(t==="stack-delete-complete")return;if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Stack not visible yet`);await new Promise((o)=>setTimeout(o,2000)),i++;continue}let n=c.Stacks[0];if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Status = ${n.StackStatus}${n.StackStatusReason?` (${n.StackStatusReason})`:""}`);if(r.includes(n.StackStatus))return;if((t==="stack-create-complete"||t==="stack-update-complete")&&(n.StackStatus==="DELETE_IN_PROGRESS"||n.StackStatus==="DELETE_COMPLETE")){console.log("[waitForStack] Stack is being deleted (creation/update failed)");let o="";try{let u=await this.describeStackEvents(e);console.log("[waitForStack] Stack events (most recent first):");for(let l of u.StackEvents.slice(0,15))if(l.ResourceStatus.includes("FAILED")||l.ResourceStatusReason){if(console.log(` ${l.LogicalResourceId}: ${l.ResourceStatus} - ${l.ResourceStatusReason||"No reason provided"}`),l.ResourceStatus.includes("FAILED")&&l.ResourceStatusReason&&!o)o=l.ResourceStatusReason}}catch{}let S=o||n.StackStatusReason||"Check CloudFormation console for details.";throw Error(`Stack creation/update failed - stack is being deleted. Reason: ${S}`)}if(n.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let o=Error("Stack deletion failed - may have resources that need to be retained");throw o.code="DELETE_FAILED",o.stackStatus=n.StackStatus,o.statusReason=n.StackStatusReason,o}if(a.includes(n.StackStatus))throw Error(`Stack reached failure status: ${n.StackStatus}`);await new Promise((o)=>setTimeout(o,5000)),i++}catch(c){if(t==="stack-delete-complete"&&c.message?.includes("does not exist"))return;if(t==="stack-create-complete"&&c.message?.includes("does not exist")){if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Stack does not exist (error), retrying...`);await new Promise((n)=>setTimeout(n,2000)),i++;continue}throw console.log(`[waitForStack] Unexpected error: ${c.message}`),c}throw console.log(`[waitForStack] Timeout after ${i} attempts`),Error(`Timeout waiting for stack to reach ${t}`)}async validateTemplate(e){let t={Action:"ValidateTemplate",TemplateBody:e,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()})}async listStacks(e){let t={Action:"ListStacks",Version:"2010-05-15"};if(e)e.forEach((c,n)=>{t[`StackStatusFilter.member.${n+1}`]=c});let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()}),a=s.ListStacksResponse||s,r=a.ListStacksResult||a,m=r.StackSummaries?.member||r.StackSummaries||[];return{StackSummaries:(Array.isArray(m)?m:m?[m]:[]).map((c)=>({StackId:c.StackId||"",StackName:c.StackName||"",TemplateDescription:c.TemplateDescription,CreationTime:c.CreationTime||"",LastUpdatedTime:c.LastUpdatedTime,DeletionTime:c.DeletionTime,StackStatus:c.StackStatus||""}))}}async createChangeSet(e){let t={Action:"CreateChangeSet",StackName:e.stackName,ChangeSetName:e.changeSetName,Version:"2010-05-15"};if(e.templateBody)t.TemplateBody=e.templateBody;else if(e.templateUrl)t.TemplateURL=e.templateUrl;if(e.parameters)e.parameters.forEach((a,r)=>{t[`Parameters.member.${r+1}.ParameterKey`]=a.ParameterKey,t[`Parameters.member.${r+1}.ParameterValue`]=a.ParameterValue});if(e.capabilities)e.capabilities.forEach((a,r)=>{t[`Capabilities.member.${r+1}`]=a});if(e.changeSetType)t.ChangeSetType=e.changeSetType;let s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{Id:s.Id,StackId:s.StackId}}async describeChangeSet(e,t){let s={Action:"DescribeChangeSet",StackName:e,ChangeSetName:t,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(s).toString()})}async executeChangeSet(e,t){let s={Action:"ExecuteChangeSet",StackName:e,ChangeSetName:t,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(s).toString()})}async deleteChangeSet(e,t){let s={Action:"DeleteChangeSet",StackName:e,ChangeSetName:t,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(s).toString()})}async getStackOutputs(e){let t=await this.describeStacks({stackName:e});if(!t.Stacks||t.Stacks.length===0)throw Error(`Stack ${e} not found`);let s=t.Stacks[0],a={};if(s.Outputs)for(let r of s.Outputs)a[r.OutputKey]=r.OutputValue;return a}async getTemplate(e){let t={Action:"GetTemplate",StackName:e,Version:"2010-05-15"},s=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(t).toString()});return{TemplateBody:s?.GetTemplateResult?.TemplateBody||s?.TemplateBody||""}}parseStacksResponse(e){let t=[],s=e?.DescribeStacksResult?.Stacks?.member||e?.Stacks?.member||e?.Stacks||e;if(s&&!Array.isArray(s))s=[s];if(Array.isArray(s)){for(let a of s)if(a.StackId||a.StackName){let r;if(a.Outputs?.member)r=(Array.isArray(a.Outputs.member)?a.Outputs.member:[a.Outputs.member]).map((i)=>({OutputKey:i.OutputKey,OutputValue:i.OutputValue,Description:i.Description,ExportName:i.ExportName}));t.push({StackId:a.StackId,StackName:a.StackName,StackStatus:a.StackStatus,CreationTime:a.CreationTime,LastUpdatedTime:a.LastUpdatedTime,StackStatusReason:a.StackStatusReason,Outputs:r})}}else if(e.StackId)t.push({StackId:e.StackId,StackName:e.StackName,StackStatus:e.StackStatus,CreationTime:e.CreationTime,LastUpdatedTime:e.LastUpdatedTime});return t}parseStackEvents(e){let t=[],s=e?.DescribeStackEventsResult?.StackEvents?.member||e?.StackEvents?.member||e?.StackEvents||[];if(s&&!Array.isArray(s))s=[s];for(let a of s)if(a.LogicalResourceId)t.push({Timestamp:a.Timestamp,ResourceType:a.ResourceType,LogicalResourceId:a.LogicalResourceId,ResourceStatus:a.ResourceStatus,ResourceStatusReason:a.ResourceStatusReason});return t}async waitForStackWithProgress(e,t,s){let a={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},r=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],m=a[t],i=360,c=0,n=new Set;while(c<360)try{if(s)try{let l=[...(await this.describeStackEvents(e)).StackEvents||[]].reverse();for(let k of l){let d=`${k.LogicalResourceId}-${k.ResourceStatus}-${k.Timestamp}`;if(!n.has(d))n.add(d),s({resourceId:k.LogicalResourceId,resourceType:k.ResourceType,status:k.ResourceStatus,reason:k.ResourceStatusReason,timestamp:k.Timestamp})}}catch{}let o=await this.describeStacks({stackName:e});if(o.Stacks.length===0){if(t==="stack-delete-complete")return;await new Promise((u)=>setTimeout(u,2000)),c++;continue}let S=o.Stacks[0];if(m.includes(S.StackStatus))return;if(S.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let u=Error("Stack deletion failed - may have resources that need to be retained");throw u.code="DELETE_FAILED",u.stackStatus=S.StackStatus,u.statusReason=S.StackStatusReason,u}if(r.includes(S.StackStatus))throw Error(`Stack reached failure status: ${S.StackStatus}`);await new Promise((u)=>setTimeout(u,3000)),c++}catch(o){if(t==="stack-delete-complete"&&o.message?.includes("does not exist"))return;if(t==="stack-create-complete"&&o.message?.includes("does not exist")){await new Promise((S)=>setTimeout(S,2000)),c++;continue}throw o}throw Error(`Timeout waiting for stack to reach ${t}`)}async waitForStackComplete(e,t=120,s=5000){let a=["CREATE_COMPLETE","UPDATE_COMPLETE","DELETE_COMPLETE"],r=["CREATE_FAILED","UPDATE_FAILED","DELETE_FAILED","ROLLBACK_COMPLETE","ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED"];for(let m=0;m<t;m++)try{let i=await this.describeStacks({stackName:e});if(i.Stacks.length===0)return{success:!0,status:"DELETE_COMPLETE"};let c=i.Stacks[0],n=c.StackStatus;if(a.includes(n))return{success:!0,status:n};if(r.includes(n))return{success:!1,status:n,reason:c.StackStatusReason};await new Promise((o)=>setTimeout(o,s))}catch(i){if(i.message?.includes("does not exist"))return{success:!0,status:"DELETE_COMPLETE"};throw i}return{success:!1,status:"TIMEOUT",reason:"Timeout waiting for stack operation"}}}
2
+ export{p as Xh};
@@ -0,0 +1,44 @@
1
+ var _={newConnectionsPerSecond:50,concurrentPerSource:100,synPerSecond:2000,burst:100,icmpPerSecond:5,banSeconds:600};function h(e){return{..._,...e.thresholds}}var y=/^(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,2})?$|^[0-9a-f:]+(?:\/\d{1,3})?$/i;function S(e){if(!y.test(e))return!1;let[t,n]=e.split("/");if(t.includes(":"))return n==null||Number(n)>=0&&Number(n)<=128;let s=t.split(".");if(s.length!==4||s.some((a)=>Number(a)>255||a===""))return!1;return n==null||Number(n)>=0&&Number(n)<=32}function f(e){return[...new Set((e??[]).map((t)=>t.trim()).filter(S))]}function w(e){let t=(e??[80,443]).filter((n)=>Number.isInteger(n)&&n>=1&&n<=65535);return[...new Set(t)].sort((n,s)=>n-s)}function k(e={}){let t=h(e);return{"net.ipv4.tcp_syncookies":"1","net.ipv4.tcp_max_syn_backlog":String(Math.max(4096,t.synPerSecond*4)),"net.ipv4.tcp_synack_retries":"2","net.ipv4.tcp_abort_on_overflow":"1","net.ipv4.tcp_fin_timeout":"15","net.ipv4.tcp_keepalive_time":"300","net.ipv4.tcp_keepalive_intvl":"30","net.ipv4.tcp_keepalive_probes":"3","net.core.somaxconn":"4096","net.core.netdev_max_backlog":"16384","net.ipv4.conf.all.rp_filter":"1","net.ipv4.conf.default.rp_filter":"1","net.ipv4.conf.all.accept_source_route":"0","net.ipv4.conf.all.accept_redirects":"0","net.ipv4.conf.all.send_redirects":"0","net.ipv6.conf.all.accept_redirects":"0","net.ipv6.conf.all.accept_source_route":"0","net.ipv4.icmp_echo_ignore_broadcasts":"1","net.ipv4.icmp_ignore_bogus_error_responses":"1","net.netfilter.nf_conntrack_max":"262144","net.netfilter.nf_conntrack_tcp_timeout_established":"3600"}}function x(e={}){let t=["# Managed by ts-cloud. Edits are overwritten on the next deploy.","# Network hardening against L3/L4 floods.",""];for(let[n,s]of Object.entries(k(e)))t.push(`${n} = ${s}`);return`${t.join(`
2
+ `)}
3
+ `}function P(e={}){let t=h(e),n=w(e.ports),s=f(e.allowlist),a=f(e.blocklist),l=e.monitorOnly?"counter":"counter drop",i=e.originProtection?.enabled?f(e.originProtection.cdnRanges):[],c=s.filter((r)=>!r.includes(":")),p=s.filter((r)=>r.includes(":")),u=a.filter((r)=>!r.includes(":")),o=["#!/usr/sbin/nft -f","# Managed by ts-cloud. Edits are overwritten on the next deploy.","","table inet ts_cloud_ddos","delete table inet ts_cloud_ddos","","table inet ts_cloud_ddos {"," # Sources that tripped a limit, with a timeout so a ban self-expires.",` set banned4 { type ipv4_addr; flags timeout; timeout ${t.banSeconds}s; }`,` set banned6 { type ipv6_addr; flags timeout; timeout ${t.banSeconds}s; }`];if(c.length>0)o.push(` set allow4 { type ipv4_addr; flags interval; elements = { ${c.join(", ")} } }`);if(p.length>0)o.push(` set allow6 { type ipv6_addr; flags interval; elements = { ${p.join(", ")} } }`);if(u.length>0)o.push(` set block4 { type ipv4_addr; flags interval; elements = { ${u.join(", ")} } }`);if(i.length>0)o.push(` set cdn4 { type ipv4_addr; flags interval; elements = { ${i.filter((r)=>!r.includes(":")).join(", ")} } }`);if(o.push(""," chain input {"," type filter hook input priority -150; policy accept;",""," # Established traffic is already paid for; never re-inspect it."," ct state established,related accept"," iif lo accept",""," # Invalid packets are never legitimate and are cheap to drop early."," ct state invalid counter drop"),c.length>0)o.push(" ip saddr @allow4 accept");if(p.length>0)o.push(" ip6 saddr @allow6 accept");if(u.length>0)o.push(" ip saddr @block4 counter drop");if(o.push(" ip saddr @banned4 counter drop"," ip6 saddr @banned6 counter drop",""),o.push(" # Nonsense TCP flag combinations: scanners and stack fingerprinting."," tcp flags & (fin|syn) == (fin|syn) counter drop"," tcp flags & (syn|rst) == (syn|rst) counter drop"," tcp flags & (fin|rst) == (fin|rst) counter drop"," tcp flags & (fin|ack) == fin counter drop"," tcp flags & (syn|fin|ack|rst|psh|urg) == 0x0 counter drop",""," # Ping stays usable, ping floods do not.",` ip protocol icmp icmp type echo-request limit rate ${t.icmpPerSecond}/second burst ${t.burst} packets accept`," ip protocol icmp icmp type echo-request counter drop",""),n.length>0){let r=n.join(", ");if(o.push(" # Platform-wide SYN ceiling. Above it the kernel falls back to cookies.",` tcp dport { ${r} } ct state new limit rate ${t.synPerSecond}/second burst ${t.burst} packets accept`,""," # Per-source new-connection rate. This is what stops one host hammering.",` tcp dport { ${r} } ct state new meter conn_rate4 { ip saddr limit rate over ${t.newConnectionsPerSecond}/second burst ${t.burst} packets } add @banned4 { ip saddr } ${l}`,` tcp dport { ${r} } ct state new meter conn_rate6 { ip6 saddr limit rate over ${t.newConnectionsPerSecond}/second burst ${t.burst} packets } add @banned6 { ip6 saddr } ${l}`,""," # Concurrency ceiling per source: the slow-loris defence.",` tcp dport { ${r} } ct state new meter conn_count4 { ip saddr ct count over ${t.concurrentPerSource} } ${l}`,` tcp dport { ${r} } ct state new meter conn_count6 { ip6 saddr ct count over ${t.concurrentPerSource} } ${l}`,""),i.length>0)o.push(" # Origin protection: reject traffic that skipped the CDN and came"," # straight to the box, which is how an attacker bypasses the edge.",` tcp dport { ${r} } ip saddr != @cdn4 counter drop`,"")}return o.push(" }","}",""),o.join(`
4
+ `)}function C(e={}){return`#!/usr/bin/env bash
5
+ # Managed by ts-cloud. Installs L3/L4 flood mitigation.
6
+ set -euo pipefail
7
+
8
+ if ! command -v nft >/dev/null 2>&1; then
9
+ export DEBIAN_FRONTEND=noninteractive
10
+ apt-get update -qq
11
+ apt-get install -y -qq nftables
12
+ fi
13
+
14
+ install -d -m 0755 /etc/ts-cloud /etc/nftables.d
15
+ cat > /etc/sysctl.d/90-ts-cloud-ddos.conf <<'SYSCTL_EOF'
16
+ ${x(e)}SYSCTL_EOF
17
+ sysctl --system >/dev/null
18
+
19
+ cat > /etc/nftables.d/ts-cloud-ddos.nft.new <<'NFT_EOF'
20
+ ${P(e)}NFT_EOF
21
+
22
+ # Syntax-check before applying: a bad ruleset would leave the box unprotected.
23
+ if ! nft -c -f /etc/nftables.d/ts-cloud-ddos.nft.new; then
24
+ echo "ts-cloud: generated nftables ruleset failed validation, keeping the previous one" >&2
25
+ rm -f /etc/nftables.d/ts-cloud-ddos.nft.new
26
+ exit 1
27
+ fi
28
+
29
+ mv /etc/nftables.d/ts-cloud-ddos.nft.new /etc/nftables.d/ts-cloud-ddos.nft
30
+ nft -f /etc/nftables.d/ts-cloud-ddos.nft
31
+
32
+ # Applying the ruleset does not survive a reboot on its own: nftables.service
33
+ # loads /etc/nftables.conf, so the file has to be included from there or the box
34
+ # comes back up unprotected and nothing says so.
35
+ touch /etc/nftables.conf
36
+ if ! grep -q 'ts-cloud-ddos.nft' /etc/nftables.conf; then
37
+ printf '
38
+ include "/etc/nftables.d/ts-cloud-ddos.nft"
39
+ ' >> /etc/nftables.conf
40
+ fi
41
+ systemctl enable nftables >/dev/null 2>&1 || true
42
+ echo "ts-cloud: L3/L4 mitigation active"
43
+ `}var b=["off","monitor","rate_limit","challenge","lockdown"];function D(e,t=[]){let n=[],s=Math.max(1,e.baselineRequestsPerSecond),a=e.requestsPerSecond/s,l=0,i=(g,v)=>{n.push(v),l=Math.max(l,b.indexOf(g))},c=a>=3;if(c)i("monitor",`Traffic is ${a.toFixed(1)}x the baseline.`);let p=e.topSourceShare>=0.25,u=e.errorRate>=0.25,o=(e.suspiciousAgentShare??0)>=0.5,r=e.uniqueSources>0&&e.requestsPerSecond/e.uniqueSources>=50;if(c&&p)i("rate_limit",`One source accounts for ${(e.topSourceShare*100).toFixed(0)}% of traffic.`);if(c&&r)i("rate_limit","Request rate per unique source is far above what a browser produces.");if(c&&u)i("challenge",`Error rate is ${(e.errorRate*100).toFixed(0)}% under load.`);if(c&&o)i("challenge","Most requests carry no recognisable browser agent.");if(a>=20&&(p||u||o||r))i("lockdown",`Traffic is ${a.toFixed(0)}x the baseline with attack-shaped characteristics.`);if(!c&&e.topSourceShare>=0.6&&e.requestsPerSecond>s)i("rate_limit","A single source dominates traffic without an overall surge.");let d=b[l],m={off:1,monitor:1,rate_limit:0.5,challenge:0.25,lockdown:0.1}[d];return{level:d,reasons:n,rateLimitFactor:m,challengeEnabled:d==="challenge"||d==="lockdown",staticOnly:d==="lockdown",banCandidates:d==="off"||d==="monitor"?[]:f(t)}}function T(e,t){return Math.max(1,Math.floor(e*t.rateLimitFactor))}
44
+ export{_ as tl,S as ul,k as vl,x as wl,P as xl,C as yl,D as zl,T as Al};
@@ -0,0 +1,2 @@
1
+ import{$h as l,ai as a}from"./chunk-mz0dk78z.js";class g{client;region;constructor(e="us-east-1"){this.region=e,this.client=new l}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 t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t}),i=n.DescribeDBInstancesResult||n,s=i.DBInstances?.DBInstance||[];if(!Array.isArray(s))s=s?[s]:[];return{DBInstances:s,Marker:i.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 t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t}),i=n.DescribeDBClustersResult||n,s=i.DBClusters?.DBCluster||[];if(!Array.isArray(s))s=s?[s]:[];return{DBClusters:s,Marker:i.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 t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t}),i=n.DescribeDBSnapshotsResult||n,s=i.DBSnapshots?.DBSnapshot||[];if(!Array.isArray(s))s=s?[s]:[];return{DBSnapshots:s,Marker:i.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 t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t}),i=n.DescribeDBSubnetGroupsResult||n,s=i.DBSubnetGroups?.DBSubnetGroup||[];if(!Array.isArray(s))s=s?[s]:[];return{DBSubnetGroups:s,Marker:i.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((s,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=s});if(e.Tags)e.Tags.forEach((s,o)=>{r[`Tags.Tag.${o+1}.Key`]=s.Key,r[`Tags.Tag.${o+1}.Value`]=s.Value});let t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBInstance:(n.CreateDBInstanceResult||n).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((i,s)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${s+1}`]=i});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(a(r)).toString()});return{DBCluster:(t.CreateDBClusterResult||t).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 t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBInstance:(n.DeleteDBInstanceResult||n).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((s,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=s});let t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBInstance:(n.ModifyDBInstanceResult||n).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 t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBCluster:(n.ModifyDBClusterResult||n).DBCluster}}async rebootDBCluster(e){let r={Action:"FailoverDBCluster",Version:"2014-10-31",DBClusterIdentifier:e},t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(a(r)).toString()});return{DBCluster:(t.FailoverDBClusterResult||t).DBCluster}}async createDBClusterSnapshot(e,r){let t={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(a(t)).toString()})}async describeDBClusterSnapshots(e={}){let r={Action:"DescribeDBClusterSnapshots",Version:"2014-10-31",...e},t=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(a(r)).toString()}),n=t.DescribeDBClusterSnapshotsResult||t,i=n.DBClusterSnapshots?.DBClusterSnapshot??n.DBClusterSnapshots??[];return{DBClusterSnapshots:Array.isArray(i)?i:[i]}}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(a({Action:"DeleteDBClusterSnapshot",Version:"2014-10-31",DBClusterSnapshotIdentifier:e})).toString()})}async deleteDBCluster(e,r){let t={Action:"DeleteDBCluster",Version:"2014-10-31",DBClusterIdentifier:e,SkipFinalSnapshot:!r};if(r)t.FinalDBSnapshotIdentifier=r;let n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(a(t)).toString()});return{DBCluster:(n.DeleteDBClusterResult||n).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((s,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=s});let t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBCluster:(n.RestoreDBClusterToPointInTimeResult||n).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((i,s)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${s+1}`]=i}),e.ServerlessV2ScalingConfiguration)r["ServerlessV2ScalingConfiguration.MinCapacity"]=e.ServerlessV2ScalingConfiguration.MinCapacity,r["ServerlessV2ScalingConfiguration.MaxCapacity"]=e.ServerlessV2ScalingConfiguration.MaxCapacity;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(a(r)).toString()});return{DBCluster:(t.RestoreDBClusterFromSnapshotResult||t).DBCluster}}async startDBInstance(e){let t=new URLSearchParams(a({Action:"StartDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e})).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBInstance:(n.StartDBInstanceResult||n).DBInstance}}async stopDBInstance(e){let r={Action:"StopDBInstance",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier};if(e.DBSnapshotIdentifier)r.DBSnapshotIdentifier=e.DBSnapshotIdentifier;let t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBInstance:(n.StopDBInstanceResult||n).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 t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBInstance:(n.RebootDBInstanceResult||n).DBInstance}}async createDBSnapshot(e){let r={Action:"CreateDBSnapshot",Version:"2014-10-31",DBInstanceIdentifier:e.DBInstanceIdentifier,DBSnapshotIdentifier:e.DBSnapshotIdentifier};if(e.Tags)e.Tags.forEach((s,o)=>{r[`Tags.Tag.${o+1}.Key`]=s.Key,r[`Tags.Tag.${o+1}.Value`]=s.Value});let t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBSnapshot:(n.CreateDBSnapshotResult||n).DBSnapshot}}async deleteDBSnapshot(e){let t=new URLSearchParams(a({Action:"DeleteDBSnapshot",Version:"2014-10-31",DBSnapshotIdentifier:e})).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBSnapshot:(n.DeleteDBSnapshotResult||n).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((s,o)=>{r[`VpcSecurityGroupIds.VpcSecurityGroupId.${o+1}`]=s});if(e.Tags)e.Tags.forEach((s,o)=>{r[`Tags.Tag.${o+1}.Key`]=s.Key,r[`Tags.Tag.${o+1}.Value`]=s.Value});let t=new URLSearchParams(a(r)).toString(),n=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:t});return{DBInstance:(n.RestoreDBInstanceFromDBSnapshotResult||n).DBInstance}}async waitForDBInstanceAvailable(e,r=60,t=30000){for(let n=0;n<r;n++){let i=await this.describeDBInstance(e);if(i?.DBInstanceStatus==="available")return i;if(["deleted","failed","incompatible-restore","incompatible-parameters"].includes(i?.DBInstanceStatus||""))throw Error(`DB instance ${e} is in terminal state: ${i?.DBInstanceStatus}`);await new Promise((s)=>setTimeout(s,t))}throw Error(`Timeout waiting for DB instance ${e} to become available`)}async waitForDBInstanceDeleted(e,r=60,t=30000){for(let n=0;n<r;n++)try{let i=await this.describeDBInstance(e);if(i?.DBInstanceStatus==="deleting"){await new Promise((s)=>setTimeout(s,t));continue}throw Error(`DB instance ${e} is in state: ${i?.DBInstanceStatus}`)}catch(i){if(i.code==="DBInstanceNotFound"||i.code==="DBInstanceNotFoundFault")return;throw i}throw Error(`Timeout waiting for DB instance ${e} to be deleted`)}}
2
+ export{g as uf};
@@ -0,0 +1 @@
1
+ import{$h as b,_h as a,ai as c,bi as d}from"./chunk-mz0dk78z.js";import"./chunk-13qjvbqh.js";export{b as AWSClient,c as buildQueryParams,d as detectCredentialSource,a as resolveS3Endpoint};
@@ -0,0 +1,50 @@
1
+ import{$h as a}from"./chunk-mz0dk78z.js";class d{client;region;constructor(e="us-east-1"){this.region=e,this.client=new a}async createHostedZone(e){let t=e.CallerReference||`${Date.now()}-${Math.random().toString(36).slice(2)}`,o=`<?xml version="1.0" encoding="UTF-8"?>
2
+ <CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
3
+ <Name>${e.Name}</Name>
4
+ <CallerReference>${t}</CallerReference>`;if(e.HostedZoneConfig){if(o+=`
5
+ <HostedZoneConfig>`,e.HostedZoneConfig.Comment)o+=`
6
+ <Comment>${e.HostedZoneConfig.Comment}</Comment>`;if(e.HostedZoneConfig.PrivateZone!==void 0)o+=`
7
+ <PrivateZone>${e.HostedZoneConfig.PrivateZone}</PrivateZone>`;o+=`
8
+ </HostedZoneConfig>`}if(e.VPC)o+=`
9
+ <VPC>
10
+ <VPCRegion>${e.VPC.VPCRegion}</VPCRegion>
11
+ <VPCId>${e.VPC.VPCId}</VPCId>
12
+ </VPC>`;if(e.DelegationSetId)o+=`
13
+ <DelegationSetId>${e.DelegationSetId}</DelegationSetId>`;o+=`
14
+ </CreateHostedZoneRequest>`;let n=await this.client.request({service:"route53",region:this.region,method:"POST",path:"/2013-04-01/hostedzone",headers:{"content-type":"application/xml"},body:o});return this.parseCreateHostedZoneResponse(n)}async listHostedZones(e){let t={};if(e?.Marker)t.marker=e.Marker;if(e?.MaxItems)t.maxitems=e.MaxItems;let o=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzone",queryParams:Object.keys(t).length>0?t:void 0});return this.parseListHostedZonesResponse(o)}async listHostedZonesByName(e){let t={};if(e?.DNSName)t.dnsname=e.DNSName;if(e?.HostedZoneId)t.hostedzoneid=e.HostedZoneId;if(e?.MaxItems)t.maxitems=e.MaxItems;let o=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzonesbyname",queryParams:Object.keys(t).length>0?t:void 0});return this.parseListHostedZonesResponse(o)}async getHostedZone(e){let t=e.Id.replace("/hostedzone/",""),o=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${t}`});return this.parseGetHostedZoneResponse(o)}async deleteHostedZone(e){let t=e.Id.replace("/hostedzone/","");await this.client.request({service:"route53",region:this.region,method:"DELETE",path:`/2013-04-01/hostedzone/${t}`})}async listResourceRecordSets(e){let t=e.HostedZoneId.replace("/hostedzone/",""),o={};if(e.StartRecordName)o.name=e.StartRecordName;if(e.StartRecordType)o.type=e.StartRecordType;if(e.StartRecordIdentifier)o.identifier=e.StartRecordIdentifier;if(e.MaxItems)o.maxitems=e.MaxItems;let n=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${t}/rrset`,queryParams:Object.keys(o).length>0?o:void 0});return this.parseListResourceRecordSetsResponse(n)}async changeResourceRecordSets(e){let t=e.HostedZoneId.replace("/hostedzone/",""),o=`<?xml version="1.0" encoding="UTF-8"?>
15
+ <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
16
+ <ChangeBatch>`;if(e.ChangeBatch.Comment)o+=`
17
+ <Comment>${this.escapeXml(e.ChangeBatch.Comment)}</Comment>`;o+=`
18
+ <Changes>`;for(let s of e.ChangeBatch.Changes){if(o+=`
19
+ <Change>
20
+ <Action>${s.Action}</Action>
21
+ <ResourceRecordSet>
22
+ <Name>${s.ResourceRecordSet.Name}</Name>
23
+ <Type>${s.ResourceRecordSet.Type}</Type>`,s.ResourceRecordSet.TTL!==void 0)o+=`
24
+ <TTL>${s.ResourceRecordSet.TTL}</TTL>`;if(s.ResourceRecordSet.SetIdentifier)o+=`
25
+ <SetIdentifier>${s.ResourceRecordSet.SetIdentifier}</SetIdentifier>`;if(s.ResourceRecordSet.Weight!==void 0)o+=`
26
+ <Weight>${s.ResourceRecordSet.Weight}</Weight>`;if(s.ResourceRecordSet.Region)o+=`
27
+ <Region>${s.ResourceRecordSet.Region}</Region>`;if(s.ResourceRecordSet.Failover)o+=`
28
+ <Failover>${s.ResourceRecordSet.Failover}</Failover>`;if(s.ResourceRecordSet.HealthCheckId)o+=`
29
+ <HealthCheckId>${s.ResourceRecordSet.HealthCheckId}</HealthCheckId>`;if(s.ResourceRecordSet.ResourceRecords&&s.ResourceRecordSet.ResourceRecords.length>0){o+=`
30
+ <ResourceRecords>`;for(let r of s.ResourceRecordSet.ResourceRecords)o+=`
31
+ <ResourceRecord>
32
+ <Value>${this.escapeXml(r.Value)}</Value>
33
+ </ResourceRecord>`;o+=`
34
+ </ResourceRecords>`}if(s.ResourceRecordSet.AliasTarget)o+=`
35
+ <AliasTarget>
36
+ <HostedZoneId>${s.ResourceRecordSet.AliasTarget.HostedZoneId}</HostedZoneId>
37
+ <DNSName>${s.ResourceRecordSet.AliasTarget.DNSName}</DNSName>
38
+ <EvaluateTargetHealth>${s.ResourceRecordSet.AliasTarget.EvaluateTargetHealth}</EvaluateTargetHealth>
39
+ </AliasTarget>`;if(s.ResourceRecordSet.GeoLocation){if(o+=`
40
+ <GeoLocation>`,s.ResourceRecordSet.GeoLocation.ContinentCode)o+=`
41
+ <ContinentCode>${s.ResourceRecordSet.GeoLocation.ContinentCode}</ContinentCode>`;if(s.ResourceRecordSet.GeoLocation.CountryCode)o+=`
42
+ <CountryCode>${s.ResourceRecordSet.GeoLocation.CountryCode}</CountryCode>`;if(s.ResourceRecordSet.GeoLocation.SubdivisionCode)o+=`
43
+ <SubdivisionCode>${s.ResourceRecordSet.GeoLocation.SubdivisionCode}</SubdivisionCode>`;o+=`
44
+ </GeoLocation>`}o+=`
45
+ </ResourceRecordSet>
46
+ </Change>`}o+=`
47
+ </Changes>
48
+ </ChangeBatch>
49
+ </ChangeResourceRecordSetsRequest>`;let n=await this.client.request({service:"route53",region:this.region,method:"POST",path:`/2013-04-01/hostedzone/${t}/rrset`,headers:{"content-type":"application/xml"},body:o});return this.parseChangeResourceRecordSetsResponse(n)}escapeXml(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}parseCreateHostedZoneResponse(e){let t=e.CreateHostedZoneResponse||e;return{HostedZone:this.parseHostedZone(t.HostedZone),ChangeInfo:{Id:t.ChangeInfo?.Id||"",Status:t.ChangeInfo?.Status||"",SubmittedAt:t.ChangeInfo?.SubmittedAt||""},DelegationSet:this.parseDelegationSet(t.DelegationSet),Location:t.Location||""}}parseListHostedZonesResponse(e){let t=e.ListHostedZonesResponse||e.ListHostedZonesByNameResponse||e,o=t.HostedZones?.HostedZone||t.HostedZones||[];if(!Array.isArray(o))o=o?[o]:[];return{HostedZones:o.map((n)=>this.parseHostedZone(n)),IsTruncated:t.IsTruncated==="true"||t.IsTruncated===!0,MaxItems:t.MaxItems||"100",Marker:t.Marker,NextMarker:t.NextMarker}}parseGetHostedZoneResponse(e){let t=e.GetHostedZoneResponse||e;return{HostedZone:this.parseHostedZone(t.HostedZone),DelegationSet:this.parseDelegationSet(t.DelegationSet),VPCs:t.VPCs?.VPC?Array.isArray(t.VPCs.VPC)?t.VPCs.VPC:[t.VPCs.VPC]:void 0}}parseListResourceRecordSetsResponse(e){let t=e.ListResourceRecordSetsResponse||e,o=t.ResourceRecordSets?.ResourceRecordSet||t.ResourceRecordSets||[];if(!Array.isArray(o))o=o?[o]:[];return{ResourceRecordSets:o.map((n)=>this.parseResourceRecordSet(n)),IsTruncated:t.IsTruncated==="true"||t.IsTruncated===!0,MaxItems:t.MaxItems||"100",NextRecordName:t.NextRecordName,NextRecordType:t.NextRecordType,NextRecordIdentifier:t.NextRecordIdentifier}}parseChangeResourceRecordSetsResponse(e){let t=e.ChangeResourceRecordSetsResponse||e;return{ChangeInfo:{Id:t.ChangeInfo?.Id||"",Status:t.ChangeInfo?.Status||"",SubmittedAt:t.ChangeInfo?.SubmittedAt||"",Comment:t.ChangeInfo?.Comment}}}parseHostedZone(e){if(!e)return{Id:"",Name:""};return{Id:e.Id||"",Name:e.Name||"",CallerReference:e.CallerReference,Config:e.Config?{Comment:e.Config.Comment,PrivateZone:e.Config.PrivateZone==="true"||e.Config.PrivateZone===!0}:void 0,ResourceRecordSetCount:e.ResourceRecordSetCount?Number(e.ResourceRecordSetCount):void 0}}parseDelegationSet(e){if(!e)return{NameServers:[]};let t=e.NameServers?.NameServer||e.NameServers||[];if(!Array.isArray(t))t=t?[t]:[];return{Id:e.Id,CallerReference:e.CallerReference,NameServers:t}}parseResourceRecordSet(e){if(!e)return{Name:"",Type:""};let t=e.ResourceRecords?.ResourceRecord||e.ResourceRecords||[];if(!Array.isArray(t))t=t?[t]:[];return{Name:e.Name||"",Type:e.Type||"",TTL:e.TTL?Number(e.TTL):void 0,ResourceRecords:t.map((o)=>({Value:o.Value||o})),AliasTarget:e.AliasTarget?{HostedZoneId:e.AliasTarget.HostedZoneId,DNSName:e.AliasTarget.DNSName,EvaluateTargetHealth:e.AliasTarget.EvaluateTargetHealth==="true"||e.AliasTarget.EvaluateTargetHealth===!0}:void 0,SetIdentifier:e.SetIdentifier,Weight:e.Weight?Number(e.Weight):void 0,Region:e.Region,GeoLocation:e.GeoLocation,Failover:e.Failover,HealthCheckId:e.HealthCheckId}}async findHostedZoneByName(e){let t=e.endsWith(".")?e:`${e}.`;return(await this.listHostedZonesByName({DNSName:t})).HostedZones.find((s)=>s.Name===t)||null}async createARecord(e){let t=Array.isArray(e.Value)?e.Value:[e.Value];return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"A",TTL:e.TTL||300,ResourceRecords:t.map((o)=>({Value:o}))}}]}})}async createCnameRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"CNAME",TTL:e.TTL||300,ResourceRecords:[{Value:e.Value}]}}]}})}async createAliasRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:e.Type||"A",AliasTarget:{HostedZoneId:e.TargetHostedZoneId,DNSName:e.TargetDNSName,EvaluateTargetHealth:e.EvaluateTargetHealth??!1}}}]}})}async createTxtRecord(e){let o=(Array.isArray(e.Value)?e.Value:[e.Value]).map((n)=>{if(!n.startsWith('"'))return`"${n}"`;return n});return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"TXT",TTL:e.TTL||300,ResourceRecords:o.map((n)=>({Value:n}))}}]}})}async createMxRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:e.Name,Type:"MX",TTL:e.TTL||300,ResourceRecords:e.Values.map((t)=>({Value:`${t.priority} ${t.mailServer}`}))}}]}})}async deleteRecord(e){return this.changeResourceRecordSets({HostedZoneId:e.HostedZoneId,ChangeBatch:{Changes:[{Action:"DELETE",ResourceRecordSet:e.RecordSet}]}})}async waitForChange(e,t=60,o=5000){let n=e.replace("/change/","");for(let s=0;s<t;s++){let r=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/change/${n}`});if((r.GetChangeResponse?.ChangeInfo?.Status||r.ChangeInfo?.Status)==="INSYNC")return!0;await new Promise((i)=>setTimeout(i,o))}return!1}async findOrCreateHostedZone(e){let t=e.domainName.endsWith(".")?e.domainName:`${e.domainName}.`,o=await this.findHostedZoneByName(t);if(o){let s=await this.getHostedZone({Id:o.Id});return{hostedZone:o,nameServers:s.DelegationSet.NameServers,isNew:!1}}let n=await this.createHostedZone({Name:t,HostedZoneConfig:{Comment:e.comment||`Hosted zone for ${e.domainName}`,PrivateZone:e.privateZone},VPC:e.vpc});return{hostedZone:n.HostedZone,nameServers:n.DelegationSet.NameServers,isNew:!0}}static getRootDomain(e){let t=e.replace(/\.$/,"").split(".");if(t.length<=2)return e;return t.slice(-2).join(".")}async findHostedZoneForDomain(e){let o=e.replace(/\.$/,"").split(".");for(let n=0;n<o.length-1;n++){let s=o.slice(n).join("."),r=await this.findHostedZoneByName(s);if(r)return r}return null}async ensureHostedZone(e){let t=await this.findOrCreateHostedZone({domainName:e.domainName,comment:e.comment});return{hostedZoneId:t.hostedZone.Id.replace("/hostedzone/",""),nameServers:t.nameServers,isNew:t.isNew,action:t.isNew?"created":"found"}}async setupDomainDns(e){let{domain:t,createIfNotExists:o=!0}=e,n=await this.findHostedZoneByName(t);if(n){let r=await this.getHostedZone({Id:n.Id});return{success:!0,hostedZoneId:n.Id.replace("/hostedzone/",""),nameServers:r.DelegationSet.NameServers,isNew:!1,message:`Found existing hosted zone for ${t}`}}if(!o)return{success:!1,hostedZoneId:null,nameServers:[],isNew:!1,message:`No hosted zone found for ${t} and createIfNotExists is false`};let s=await this.createHostedZone({Name:t,HostedZoneConfig:{Comment:`Created automatically by ts-cloud for ${t}`}});return{success:!0,hostedZoneId:s.HostedZone.Id.replace("/hostedzone/",""),nameServers:s.DelegationSet.NameServers,isNew:!0,message:`Created new hosted zone for ${t}. Please update your domain registrar with these name servers: ${s.DelegationSet.NameServers.join(", ")}`}}static CloudFrontHostedZoneId="Z2FDTNDATAQYW2";static S3WebsiteHostedZoneIds={"us-east-1":"Z3AQBSTGFYJSTF","us-east-2":"Z2O1EMRO9K5GLX","us-west-1":"Z2F56UZL2M1ACD","us-west-2":"Z3BJ6K6RIION7M","ap-east-1":"ZNB98KWMFR0R6","ap-south-1":"Z11RGJOFQNVJUP","ap-northeast-1":"Z2M4EHUR26P7ZW","ap-northeast-2":"Z3W03O7B5YMIYP","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"Z3O0J2DXBE1FTB","ap-southeast-2":"Z1WCIGYICN2BYD","ca-central-1":"Z1QDHH18159H29","eu-central-1":"Z21DNDUVLTQW6Q","eu-west-1":"Z1BKCTXD74EZPE","eu-west-2":"Z3GKZC51ZF0DB4","eu-west-3":"Z3R1K369G5AVDG","eu-north-1":"Z3BAZG2TWCNX0D","sa-east-1":"Z7KQH4QJS55SO"};static ALBHostedZoneIds={"us-east-1":"Z35SXDOTRQ7X7K","us-east-2":"Z3AADJGX6KTTL2","us-west-1":"Z368ELLRRE2KJ0","us-west-2":"Z1H1FL5HABSF5","ap-east-1":"Z3DQVH9N71FHZ0","ap-south-1":"ZP97RAFLXTNZK","ap-northeast-1":"Z14GRHDCWA56QT","ap-northeast-2":"ZWKZPGTI48KDX","ap-northeast-3":"Z5LXEBD8Y73MNV","ap-southeast-1":"Z1LMS91P8CMLE5","ap-southeast-2":"Z1GM3OXH4ZPM65","ca-central-1":"ZQSVJUPU6J1EY","eu-central-1":"Z215JYRZR1TBD5","eu-west-1":"Z32O12XQLNTSW2","eu-west-2":"ZHURV8PSTC4K8","eu-west-3":"Z3Q77PNBQS71R4","eu-north-1":"Z23TAZ6LKFMNIO","sa-east-1":"Z2P70J7HTTTPLU"};static APIGatewayHostedZoneIds={"us-east-1":"Z1UJRXOUMOOFQ8","us-east-2":"ZOJJZC49E0EPZ","us-west-1":"Z2MUQ32089INYE","us-west-2":"Z2OJLYMUO9EFXC","ap-east-1":"Z3FD1VL90ND7K5","ap-south-1":"Z3VO1THU9YC4UR","ap-northeast-1":"Z1YSHQZHG15GKL","ap-northeast-2":"Z20JF4UZKIW1U8","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"ZL327KTPIQFUL","ap-southeast-2":"Z2RPCDW04V8134","ca-central-1":"Z19DQILCV0OWEC","eu-central-1":"Z1U9ULNL0V5AJ3","eu-west-1":"ZLY8HYME6SFDD","eu-west-2":"ZJ5UAJN8Y3Z2Q","eu-west-3":"Z3KY65QIEKYHQQ","eu-north-1":"Z3UWIKFBOOGXPP","sa-east-1":"ZCMLWB8V5SYIT"}}
50
+ export{d as Tf};
@@ -1 +1 @@
1
- import{Ac as Z,Bc as $,Cc as aa,Dc as ba,Ec as ca,Fc as da,Gc as ea,Hc as fa,Ic as ga,Jc as ha,Kc as ia,Lc as ja,Mc as ka,Nc as la,Oc as ma,ic as y,jc as z,kc as A,lc as B,mc as C,nc as D,oc as E,od as na,pc as O,pd as oa,qc as P,qd as pa,rc as Q,rd as qa,sc as R,tc as S,uc as T,vc as U,wc as V,xc as W,yc as X,zc as Y}from"../chunk-2hpjte1d.js";import{Ad as N,sd as F,td as G,ud as H,vd as I,wd as J,xd as K,yd as L,zd as M}from"../chunk-ead1nkbr.js";import{Id as _}from"../chunk-prf2pkvq.js";import"../chunk-6fzeemcs.js";import"../chunk-5m29dhke.js";import"../chunk-fea461tj.js";import"../chunk-zmmc9j5f.js";import"../chunk-j60hesb3.js";import"../chunk-yf487g6e.js";import"../chunk-qcemnt35.js";import{Gh as s,Hh as t,Ih as u,Jh as v,Kh as w,Lh as x,Uf as a,Vf as b,Wf as c,Xf as d,Yf as e,Zf as f,_f as g,jg as h,kg as i,lg as j,mg as k,ng as l,og as m,pg as n,qg as o,rg as p,sg as q,tg as r}from"../chunk-y6e86wjs.js";import"../chunk-gearw6rk.js";import"../chunk-r2pbqcnz.js";import"../chunk-wte9mh18.js";import"../chunk-bpnhqb70.js";import"../chunk-y1dh3znq.js";import"../chunk-q0wffgw5.js";import"../chunk-wcrj06cg.js";import"../chunk-6xcbfs2r.js";import"../chunk-rr1yaj55.js";export{R as verifyStaticApiOrigin,g as verifyAddressRecord,o as validateDeploymentConfig,K as uploadStaticFiles,B as trackDashboardOperation,A as synchronizeDashboardUsers,qa as startLocalDashboardServer,h as siteInstallBase,q as shipsToBucket,p as shipsARelease,ea as setMaintenance,na as sanitizeCloudConfig,fa as runRemoteCommand,E as routesForDashboard,da as rollbackServerlessApp,v as resolveUiSource,m as resolveSiteKind,l as resolveSiteDeployTarget,j as resolveProxyUpstreams,D as resolveLegacyDashboardRoute,ja as resolveDashboardData,u as resolveDashboardAuth,pa as resolveDashboardAction,b as removeStaleServerAddressRecords,ca as redeployServerlessApp,f as reconcileAddressRecords,c as normalizePublicIpv6,i as isPhpSite,L as invalidateCache,z as initializeDashboardControlPlane,$ as infraEnvFromOutputs,e as hostAcceptsIpv6,X as hashContainerContext,k as hasProxyUpstream,n as hasComputeConfigured,I as generateStaticSiteTemplate,F as generateExternalDnsStaticSiteTemplate,U as generateExistingStaticFullStackTemplate,la as fetchEgressReport,S as estimateStaticApiOriginMonthlyCost,W as estimateExistingStaticFullStackMonthlyCost,w as ensureManagementDashboard,y as ensureDashboardActor,ka as egressReportMetrics,H as deployStaticSiteWithExternalDnsFull,G as deployStaticSiteWithExternalDns,N as deployStaticSiteFull,J as deployStaticSite,Q as deployStaticApiOrigin,O as deploySite,r as deployShipsFiles,ba as deployServerlessApp,V as deployExistingStaticFullStack,M as deleteStaticSite,C as dashboardPageRoutes,t as dashboardCredentialsFile,oa as dashboardActions,P as createStaticApiOriginDependencies,T as createExistingStaticFullStackDependencies,Y as createContainerImageDependencies,a as collectServerDnsDomains,ma as collectEgressMetrics,ia as buildTopology,ha as buildServerlessTopology,ga as buildServerTopology,x as buildManagementDashboardArtifact,aa as buildFunctionEnv,_ as buildAndPushServerlessImage,Z as buildAndPushContainerImage,s as MANAGEMENT_DASHBOARD_SITE,d as IPV6_EXCLUDED_HOST_LABELS};
1
+ import{Ac as Z,Bc as aa,Cc as ba,Dc as ca,Ec as da,Fc as ea,Gc as fa,Hc as ga,Ic as ha,Jc as ia,Kc as ja,Lc as ka,Mc as la,Nc as ma,Oc as na,ic as y,jc as z,kc as A,lc as B,mc as C,nc as D,oc as E,od as oa,pc as O,pd as pa,qc as P,qd as qa,rc as Q,rd as ra,sc as R,tc as S,uc as T,vc as U,wc as V,xc as W,yc as X,zc as Y}from"../chunk-3nmm7cap.js";import{Ad as N,sd as F,td as G,ud as H,vd as I,wd as J,xd as K,yd as L,zd as M}from"../chunk-h42zck7h.js";import{Id as _}from"../chunk-3mgj3hrh.js";import"../chunk-t0xgmhd6.js";import"../chunk-m8fs0233.js";import"../chunk-by2bwzk6.js";import"../chunk-73ztr55z.js";import"../chunk-xcj8zfmg.js";import"../chunk-tz9myq9a.js";import"../chunk-y4xkj2f1.js";import{Gh as s,Hh as t,Ih as u,Jh as v,Kh as w,Lh as x,Uf as a,Vf as b,Wf as c,Xf as d,Yf as e,Zf as f,_f as g,jg as h,kg as i,lg as j,mg as k,ng as l,og as m,pg as n,qg as o,rg as p,sg as q,tg as r}from"../chunk-n514hj0z.js";import"../chunk-aj025v2s.js";import"../chunk-wavjkdb8.js";import"../chunk-152he7m3.js";import"../chunk-mz0dk78z.js";import"../chunk-86ss83s2.js";import"../chunk-hn40z11p.js";import"../chunk-x3hay61c.js";import"../chunk-jm5mg890.js";import"../chunk-13qjvbqh.js";export{d as IPV6_EXCLUDED_HOST_LABELS,s as MANAGEMENT_DASHBOARD_SITE,Z as buildAndPushContainerImage,_ as buildAndPushServerlessImage,ba as buildFunctionEnv,x as buildManagementDashboardArtifact,ha as buildServerTopology,ia as buildServerlessTopology,ja as buildTopology,na as collectEgressMetrics,a as collectServerDnsDomains,Y as createContainerImageDependencies,T as createExistingStaticFullStackDependencies,P as createStaticApiOriginDependencies,pa as dashboardActions,t as dashboardCredentialsFile,C as dashboardPageRoutes,M as deleteStaticSite,V as deployExistingStaticFullStack,ca as deployServerlessApp,r as deployShipsFiles,O as deploySite,Q as deployStaticApiOrigin,J as deployStaticSite,N as deployStaticSiteFull,G as deployStaticSiteWithExternalDns,H as deployStaticSiteWithExternalDnsFull,la as egressReportMetrics,y as ensureDashboardActor,w as ensureManagementDashboard,W as estimateExistingStaticFullStackMonthlyCost,S as estimateStaticApiOriginMonthlyCost,ma as fetchEgressReport,U as generateExistingStaticFullStackTemplate,F as generateExternalDnsStaticSiteTemplate,I as generateStaticSiteTemplate,n as hasComputeConfigured,k as hasProxyUpstream,X as hashContainerContext,e as hostAcceptsIpv6,aa as infraEnvFromOutputs,z as initializeDashboardControlPlane,L as invalidateCache,i as isPhpSite,c as normalizePublicIpv6,f as reconcileAddressRecords,da as redeployServerlessApp,b as removeStaleServerAddressRecords,qa as resolveDashboardAction,u as resolveDashboardAuth,ka as resolveDashboardData,D as resolveLegacyDashboardRoute,j as resolveProxyUpstreams,l as resolveSiteDeployTarget,m as resolveSiteKind,v as resolveUiSource,ea as rollbackServerlessApp,E as routesForDashboard,ga as runRemoteCommand,oa as sanitizeCloudConfig,fa as setMaintenance,p as shipsARelease,q as shipsToBucket,h as siteInstallBase,ra as startLocalDashboardServer,A as synchronizeDashboardUsers,B as trackDashboardOperation,K as uploadStaticFiles,o as validateDeploymentConfig,g as verifyAddressRecord,R as verifyStaticApiOrigin};
package/dist/dns/index.js CHANGED
@@ -1 +1 @@
1
- import{Af as e,Bf as f,Cf as g,Df as h,Ef as i,Ff as j,Gf as k,Hf as l,If as m,Jf as n,Kf as o,Lf as p,Mf as q,Nf as r,Of as s,Pf as t,Qf as u,vf as a,wf as b,xf as c,zf as d}from"../chunk-yf487g6e.js";import"../chunk-qcemnt35.js";import"../chunk-bpnhqb70.js";import"../chunk-rr1yaj55.js";export{m as verifyZoneParity,g as resolveDeclaredRecords,h as reconcileDeclaredRecords,f as qualifyName,e as policyTag,k as planZoneMigration,j as exportRoute53Zone,u as dnsProviders,s as detectDnsProvider,q as createRoute53Validator,o as createPorkbunValidator,p as createGoDaddyValidator,r as createDnsProvider,l as applyZoneMigration,n as UnifiedDnsValidator,i as Route53Provider,b as PorkbunProvider,a as PROXIABLE_RECORD_TYPES,c as GoDaddyProvider,t as DnsProviderFactory,d as CloudflareProvider};
1
+ import{Af as e,Bf as f,Cf as g,Df as h,Ef as i,Ff as j,Gf as k,Hf as l,If as m,Jf as n,Kf as o,Lf as p,Mf as q,Nf as r,Of as s,Pf as t,Qf as u,vf as a,wf as b,xf as c,zf as d}from"../chunk-tz9myq9a.js";import"../chunk-y4xkj2f1.js";import"../chunk-mz0dk78z.js";import"../chunk-13qjvbqh.js";export{d as CloudflareProvider,t as DnsProviderFactory,c as GoDaddyProvider,a as PROXIABLE_RECORD_TYPES,b as PorkbunProvider,i as Route53Provider,n as UnifiedDnsValidator,l as applyZoneMigration,r as createDnsProvider,p as createGoDaddyValidator,o as createPorkbunValidator,q as createRoute53Validator,s as detectDnsProvider,u as dnsProviders,j as exportRoute53Zone,k as planZoneMigration,e as policyTag,f as qualifyName,h as reconcileDeclaredRecords,g as resolveDeclaredRecords,m as verifyZoneParity};
@@ -1 +1 @@
1
- import{$g as G,Ag as g,Ah as da,Bg as h,Bh as ea,Cg as i,Ch as fa,Dg as j,Dh as ga,Eg as k,Eh as ha,Fg as l,Fh as ia,Gg as m,Hg as n,Ig as o,Kg as p,Lg as q,Mg as r,Ng as s,Nh as ja,Og as t,Oh as ka,Pg as u,Ph as la,Qg as v,Qh as ma,Rg as w,Rh as na,Sg as x,Sh as oa,Tg as y,Th as pa,Ug as z,Uh as qa,Vg as A,Wg as B,Xg as C,Yg as D,Zg as E,_g as F,ah as H,bh as I,ch as J,dh as K,eh as L,fh as M,gh as N,hh as O,ih as P,jh as Q,kh as R,lh as S,mh as T,nh as U,oh as V,ph as W,qh as X,rh as Y,sh as Z,th as _,ug as a,uh as $,vg as b,vh as aa,wg as c,wh as ba,xg as d,yg as e,zg as f,zh as ca}from"../chunk-y6e86wjs.js";import"../chunk-gearw6rk.js";import"../chunk-r2pbqcnz.js";import"../chunk-wte9mh18.js";import"../chunk-bpnhqb70.js";import"../chunk-q0wffgw5.js";import"../chunk-wcrj06cg.js";import"../chunk-6xcbfs2r.js";import"../chunk-rr1yaj55.js";export{T as writeResizeCheckpoint,s as wrapCloudInitUserData,G as waitForSsh,H as waitForCloudInit,K as verifyHetznerResize,P as verifyHetznerHostOptimization,E as sshExecOrThrow,D as sshExec,Y as serverPublicIpv4,F as scpUpload,L as resolveHetznerHostOptimizationPlan,q as resolveHetznerApiToken,ca as resolveExecStart,R as resizeLockPath,Q as resizeCheckpointPath,ma as renewRpxCertificates,h as renderRpxLauncher,la as reloadRpxGateway,fa as releaseTarballTmpPath,S as readResizeCheckpoint,J as prepareHetznerResize,z as planHetznerServerResize,r as normalizeSshPublicKey,d as normalizeRoutePath,A as isHetznerCapacityError,v as isBoxMode,b as hasAutoWwwVariant,n as generateUbuntuAppCloudInit,c as gatewayHostnames,B as executeHetznerServerResize,V as ensureSshKey,X as ensureServer,W as ensureFirewall,e as deriveRouteId,ja as deploySiteRelease,ka as deployAllComputeSites,w as createCloudDriver,ba as createBoxProvisioner,I as collectHetznerResizeManifest,O as collectHetznerHostOptimizationReport,y as cloudDrivers,ea as buildStaticSiteDeployScript,C as buildSshArgs,da as buildSiteDeployScript,l as buildRpxProvisionScript,g as buildRpxLbConfig,m as buildRpxFragmentRefreshScript,f as buildRpxConfig,ha as buildLocalArtifactFetch,ia as buildHostCleanupScript,M as buildHetznerHostOptimizationScript,qa as buildCloudFrontOriginConfig,_ as buildBoxUserData,ga as buildAwsArtifactFetch,N as applyHetznerHostOptimization,U as acquireResizeLock,Z as UBUNTU_2404_AMI_PARAM,k as RPX_SERVICE_NAME,j as RPX_LAUNCHER_PATH,i as RPX_DIR,pa as MANAGED_ORIGIN_REQUEST_POLICY_ALL_VIEWER,na as MANAGED_CACHE_POLICY_OPTIMIZED,oa as MANAGED_CACHE_POLICY_DISABLED,u as LocalBoxDriver,t as HetznerDriver,p as HetznerClient,$ as HetznerBoxProvisioner,a as DEFAULT_RPX_CERTS_DIR,x as CloudDriverFactory,o as AwsDriver,aa as AwsBoxProvisioner};
1
+ import{$g as G,Ag as g,Ah as ea,Bg as h,Bh as fa,Cg as i,Ch as ga,Dg as j,Dh as ha,Eg as k,Eh as ia,Fg as l,Fh as ja,Gg as m,Hg as n,Ig as o,Kg as p,Lg as q,Mg as r,Ng as s,Nh as ka,Og as t,Oh as la,Pg as u,Ph as ma,Qg as v,Qh as na,Rg as w,Rh as oa,Sg as x,Sh as pa,Tg as y,Th as qa,Ug as z,Uh as ra,Vg as A,Wg as B,Xg as C,Yg as D,Zg as E,_g as F,ah as H,bh as I,ch as J,dh as K,eh as L,fh as M,gh as N,hh as O,ih as P,jh as Q,kh as R,lh as S,mh as T,nh as U,oh as V,ph as W,qh as X,rh as Y,sh as Z,th as _,ug as a,uh as aa,vg as b,vh as ba,wg as c,wh as ca,xg as d,yg as e,zg as f,zh as da}from"../chunk-n514hj0z.js";import"../chunk-aj025v2s.js";import"../chunk-wavjkdb8.js";import"../chunk-152he7m3.js";import"../chunk-mz0dk78z.js";import"../chunk-hn40z11p.js";import"../chunk-x3hay61c.js";import"../chunk-jm5mg890.js";import"../chunk-13qjvbqh.js";export{ba as AwsBoxProvisioner,o as AwsDriver,x as CloudDriverFactory,a as DEFAULT_RPX_CERTS_DIR,aa as HetznerBoxProvisioner,p as HetznerClient,t as HetznerDriver,u as LocalBoxDriver,pa as MANAGED_CACHE_POLICY_DISABLED,oa as MANAGED_CACHE_POLICY_OPTIMIZED,qa as MANAGED_ORIGIN_REQUEST_POLICY_ALL_VIEWER,i as RPX_DIR,j as RPX_LAUNCHER_PATH,k as RPX_SERVICE_NAME,Z as UBUNTU_2404_AMI_PARAM,U as acquireResizeLock,N as applyHetznerHostOptimization,ha as buildAwsArtifactFetch,_ as buildBoxUserData,ra as buildCloudFrontOriginConfig,M as buildHetznerHostOptimizationScript,ja as buildHostCleanupScript,ia as buildLocalArtifactFetch,f as buildRpxConfig,m as buildRpxFragmentRefreshScript,g as buildRpxLbConfig,l as buildRpxProvisionScript,ea as buildSiteDeployScript,C as buildSshArgs,fa as buildStaticSiteDeployScript,y as cloudDrivers,O as collectHetznerHostOptimizationReport,I as collectHetznerResizeManifest,ca as createBoxProvisioner,w as createCloudDriver,la as deployAllComputeSites,ka as deploySiteRelease,e as deriveRouteId,W as ensureFirewall,X as ensureServer,V as ensureSshKey,B as executeHetznerServerResize,c as gatewayHostnames,n as generateUbuntuAppCloudInit,b as hasAutoWwwVariant,v as isBoxMode,A as isHetznerCapacityError,d as normalizeRoutePath,r as normalizeSshPublicKey,z as planHetznerServerResize,J as prepareHetznerResize,S as readResizeCheckpoint,ga as releaseTarballTmpPath,ma as reloadRpxGateway,h as renderRpxLauncher,na as renewRpxCertificates,Q as resizeCheckpointPath,R as resizeLockPath,da as resolveExecStart,q as resolveHetznerApiToken,L as resolveHetznerHostOptimizationPlan,F as scpUpload,Y as serverPublicIpv4,D as sshExec,E as sshExecOrThrow,P as verifyHetznerHostOptimization,K as verifyHetznerResize,H as waitForCloudInit,G as waitForSsh,s as wrapCloudInitUserData,T as writeResizeCheckpoint};
@@ -31,6 +31,91 @@ export declare function resolveExecStart(start: string, runtime: 'bun' | 'node'
31
31
  * single slow moment cannot bounce a healthy service; the counter resets on the
32
32
  * first good response. flock keeps two ticks from overlapping.
33
33
  */
34
+ /**
35
+ * Stop the implicit per-template slice from silently capping the service.
36
+ *
37
+ * systemd puts an instantiated unit into a slice derived from its template
38
+ * name: `acme-web@sha.service` lands in `system-acme\x2dweb.slice`, with no
39
+ * `Slice=` anywhere in the unit and nothing in this file asking for it. The
40
+ * memory ceilings that ARE in this file go on the service. Nothing ever wrote
41
+ * to the slice, so whatever it happened to be holding was never reconciled.
42
+ *
43
+ * Two ways that bites, and both were observed on one shared box:
44
+ *
45
+ * 1. **Stale values outlive the config that set them.** A limit put on the
46
+ * slice once - by hand during an incident, or by an older release of this
47
+ * tool - stays there forever. The kernel enforces the MINIMUM down the
48
+ * hierarchy, so a slice holding 512M silently caps a service whose unit
49
+ * says 2G. Four tenants on that box were pinned that way, each reading
50
+ * `MemoryHigh=2G` in its own unit while actually living under 512M, and
51
+ * nothing in any repo said so.
52
+ *
53
+ * 2. **The cutover overlap doubles the tenant's footprint.** The whole point
54
+ * of the templated layout is that the old and new instances run at once on
55
+ * a SO_REUSEPORT socket. They share this slice. So a slice limit equal to
56
+ * the per-instance limit is guaranteed to be breached by every successful
57
+ * deploy - and a cgroup over `memory.high` is throttled in
58
+ * `mem_cgroup_handle_over_high`, which is uninterruptible sleep. A process
59
+ * there answers no requests AND no SIGTERM, so systemd waits out
60
+ * `TimeoutStopSec` while the replacement starts into the same over-budget
61
+ * slice and wedges in turn. That is an outage that repeats on every deploy
62
+ * and needs a SIGKILL by hand to clear.
63
+ *
64
+ * So the slice is reset to unlimited on every deploy and the service keeps the
65
+ * only ceiling. That is the honest arrangement: `memoryHigh` in config means a
66
+ * bound on one instance, one authority, visible in the repo. It also makes the
67
+ * fix self-healing - a box carrying stale slice caps is corrected by its next
68
+ * deploy rather than needing someone to find them.
69
+ *
70
+ * The slice name is read back from systemd rather than derived here, because
71
+ * deriving it means reimplementing systemd's escaping (`-` becomes `\x2d`)
72
+ * and being wrong about a name is how you reset the wrong cgroup. Units that
73
+ * are not templated report `system.slice`, which is shared with every other
74
+ * service on the box and is skipped explicitly.
75
+ *
76
+ * Both stores are written: a `--runtime` property in /run outranks the
77
+ * persistent one in /etc, so setting only one leaves the other free to win.
78
+ */
79
+ /**
80
+ * Resolve `memoryHigh: 'auto'` against the box the deploy is landing on.
81
+ *
82
+ * The ceiling exists to contain ONE runaway, not to ration memory between
83
+ * tenants, and those want different numbers. A fair share - RAM divided by the
84
+ * number of units - sounds principled and is wrong: this box carries 43 units
85
+ * on 15 GB, so an even split is 290 MB and would throttle healthy apps that
86
+ * legitimately sit at 800 MB. The ceiling has to sit well ABOVE normal usage
87
+ * and still be low enough that one leak cannot take the machine.
88
+ *
89
+ * So it is a fraction of the box: an eighth, floored at 512 MB and capped at
90
+ * 4 GB. On the 15 GB host this was written for that resolves to ~1.9 GB, which
91
+ * is what the old hard-coded 2G was doing - the point is that a 4 GB box now
92
+ * gets 512 MB instead of a ceiling larger than the machine, and a 64 GB box
93
+ * gets 4 GB instead of being pinned to a number chosen for someone else's
94
+ * hardware.
95
+ *
96
+ * Computed on the target rather than at config time because that is the only
97
+ * place the answer is known. An explicit `memoryHigh` always wins - this is a
98
+ * default, not a policy - and it is written as a drop-in so the unit file
99
+ * itself stays byte-identical across deploys and stays diffable.
100
+ *
101
+ * The report at the end is the other half. 43 units on that box declared 76 GB
102
+ * of ceilings against 15 GB of RAM, 502 per cent committed, and nothing
103
+ * anywhere said so: every unit looked reasonable on its own. Ceilings that sum
104
+ * past the machine are not protection, they are arithmetic nobody did, so the
105
+ * deploy now does it out loud.
106
+ */
107
+ export declare function buildAutoMemoryHigh(unitFile: string): string[];
108
+ /**
109
+ * Say what the box has now been promised, so oversubscription is visible.
110
+ *
111
+ * Sums `memory.high` across every service cgroup and compares it to RAM. It
112
+ * only ever prints - refusing a deploy over a number this crude would be worse
113
+ * than the problem, since a soft ceiling is a guard rather than a reservation
114
+ * and being committed past 100 per cent is normal and fine. What is not fine
115
+ * is being at 500 per cent and nobody knowing.
116
+ */
117
+ export declare function buildCommitmentReport(): string[];
118
+ export declare function buildSliceReconcile(instance: string): string[];
34
119
  export declare function buildLivenessUnits(options: {
35
120
  unitBase: string;
36
121
  /** systemd unit to restart. A `<base>@*.service` glob resolves at run time. */