@stacksjs/ts-cloud 0.16.32 → 0.16.33

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 (184) hide show
  1. package/dist/aws/index.js +1 -1
  2. package/dist/bin/chunk-0e7bcz1c.js +3 -0
  3. package/dist/bin/{chunk-6wz04wnk.js → chunk-0wtnhxdt.js} +1 -1
  4. package/dist/bin/{chunk-zhkbdsfs.js → chunk-1ye6ky7s.js} +1 -1
  5. package/dist/bin/chunk-2njcbs0c.js +1 -0
  6. package/dist/bin/chunk-35ct309x.js +1 -0
  7. package/dist/bin/{chunk-mpq5ct10.js → chunk-3kyny1x7.js} +4 -4
  8. package/dist/bin/chunk-3ybxaehy.js +1 -0
  9. package/dist/bin/{chunk-zk3nm0td.js → chunk-47q37egd.js} +3 -3
  10. package/dist/bin/{chunk-yccdr4be.js → chunk-49y286vw.js} +1 -1
  11. package/dist/bin/{chunk-py8cvqvx.js → chunk-4c4s5yph.js} +1 -1
  12. package/dist/bin/{chunk-x56s9b7f.js → chunk-4vbnagyd.js} +1 -1
  13. package/dist/bin/{chunk-kqf19j9m.js → chunk-59f6mqkj.js} +1 -1
  14. package/dist/bin/chunk-5p9jnpg2.js +1 -0
  15. package/dist/bin/{chunk-573red0g.js → chunk-5tfxp3d9.js} +6 -6
  16. package/dist/bin/{chunk-q6z8wvvb.js → chunk-66g6jdgy.js} +3 -3
  17. package/dist/bin/{chunk-tg45thhb.js → chunk-70w9nss5.js} +1 -1
  18. package/dist/bin/{chunk-jzby2kzy.js → chunk-7k52s3qm.js} +2 -2
  19. package/dist/bin/{chunk-6yr12f64.js → chunk-7kjy2hng.js} +5 -5
  20. package/dist/bin/{chunk-9e62z9je.js → chunk-7x727gt5.js} +2 -2
  21. package/dist/bin/{chunk-f7dtn45y.js → chunk-8ba9t3hv.js} +3 -3
  22. package/dist/bin/chunk-9aram0sm.js +1 -0
  23. package/dist/bin/{chunk-tgwx5haz.js → chunk-a1zagtx1.js} +2 -2
  24. package/dist/bin/chunk-axwpxssn.js +1 -0
  25. package/dist/bin/chunk-c5qbz7ym.js +1 -0
  26. package/dist/bin/chunk-cqc4pc2h.js +1 -0
  27. package/dist/bin/chunk-d0xz1vh3.js +1 -0
  28. package/dist/bin/chunk-d2wm1zy3.js +1 -0
  29. package/dist/bin/{chunk-gcm9n6ww.js → chunk-dgad3hwh.js} +9 -9
  30. package/dist/bin/{chunk-81mt497w.js → chunk-hbrb314y.js} +1 -1
  31. package/dist/bin/chunk-hnwdjkrt.js +1 -0
  32. package/dist/bin/{chunk-kgtzvh2k.js → chunk-hpzbvc4a.js} +1 -1
  33. package/dist/bin/chunk-hrvfz72e.js +1 -0
  34. package/dist/bin/{chunk-sdy79wz7.js → chunk-hs5a6dhm.js} +4 -4
  35. package/dist/bin/chunk-j4d7h8rh.js +1 -0
  36. package/dist/bin/{chunk-yqkdyf0w.js → chunk-jsncf48k.js} +2 -2
  37. package/dist/bin/chunk-k178k5re.js +1 -0
  38. package/dist/bin/chunk-k5h2a7a8.js +1 -0
  39. package/dist/bin/{chunk-b9psp74n.js → chunk-kzh4csxz.js} +19 -19
  40. package/dist/bin/{chunk-0sht4yfg.js → chunk-mb2fh91q.js} +2 -2
  41. package/dist/bin/chunk-mzzrnkk5.js +9 -0
  42. package/dist/bin/{chunk-8mgwqpmx.js → chunk-nnxkw5pn.js} +2 -2
  43. package/dist/bin/{chunk-6k5g8b1w.js → chunk-nw8wmbmq.js} +2 -2
  44. package/dist/bin/chunk-prz0w9pq.js +1 -0
  45. package/dist/bin/chunk-rhjjdhhq.js +1 -0
  46. package/dist/bin/{chunk-fpxb97q5.js → chunk-rkd3x7fw.js} +1 -1
  47. package/dist/bin/chunk-rv7epkg1.js +1 -0
  48. package/dist/bin/{chunk-79sd00d1.js → chunk-s38txg38.js} +1 -1
  49. package/dist/bin/{chunk-qe56mnjc.js → chunk-s6qnx8a8.js} +2 -2
  50. package/dist/bin/{chunk-nnawqw34.js → chunk-sfb9q18c.js} +102 -102
  51. package/dist/bin/{chunk-8d8tdhtx.js → chunk-szpqbbyr.js} +4 -4
  52. package/dist/bin/chunk-tftcv9rt.js +1 -0
  53. package/dist/bin/{chunk-jhp53qsd.js → chunk-v0va4547.js} +2 -2
  54. package/dist/bin/{chunk-efbmb8rw.js → chunk-wc5swv1a.js} +1 -1
  55. package/dist/bin/{chunk-985ev3ns.js → chunk-wef81maa.js} +1 -1
  56. package/dist/bin/{chunk-vhz2wmb8.js → chunk-wq4hkbgj.js} +64 -64
  57. package/dist/bin/chunk-yd2155bj.js +1 -0
  58. package/dist/bin/chunk-yqefsck4.js +1 -0
  59. package/dist/bin/chunk-yzyt35ys.js +1 -0
  60. package/dist/bin/cli.js +45 -45
  61. package/dist/bin/dashboard-server.js +1 -1
  62. package/dist/{chunk-r45340yc.js → chunk-0pe1dfy0.js} +80 -80
  63. package/dist/{chunk-peeqkk92.js → chunk-29dcfx1g.js} +73 -73
  64. package/dist/{chunk-57fhsqzb.js → chunk-444h366b.js} +2 -2
  65. package/dist/{chunk-qrs912nk.js → chunk-45116tdd.js} +1 -1
  66. package/dist/chunk-4nfjkggt.js +1 -0
  67. package/dist/{chunk-kavwrxm8.js → chunk-6n72pe9x.js} +2 -2
  68. package/dist/{chunk-3harnmd6.js → chunk-7r2qc39k.js} +2 -2
  69. package/dist/chunk-8nafnyax.js +1 -0
  70. package/dist/{chunk-nq51dyxz.js → chunk-9r32w840.js} +12 -12
  71. package/dist/{chunk-xbh2vr95.js → chunk-c4kferxw.js} +95 -95
  72. package/dist/{chunk-ffxcn7mw.js → chunk-c6nw88s3.js} +1 -1
  73. package/dist/{chunk-10asqy6j.js → chunk-e08h4q50.js} +2 -2
  74. package/dist/chunk-e3831mvy.js +1 -0
  75. package/dist/{chunk-m93g67j0.js → chunk-g3f3ccdw.js} +2 -2
  76. package/dist/{chunk-9g8as6sa.js → chunk-jp57js5y.js} +1 -1
  77. package/dist/{chunk-efssa93f.js → chunk-k3azr9e3.js} +3 -3
  78. package/dist/{chunk-4hdp9ms2.js → chunk-m1jp1abp.js} +1 -1
  79. package/dist/{chunk-qjxdhb8x.js → chunk-n4gkyye3.js} +1 -1
  80. package/dist/{chunk-2mw7bjhn.js → chunk-nmm287ym.js} +3 -3
  81. package/dist/{chunk-s909414m.js → chunk-pkpmz35j.js} +1 -1
  82. package/dist/{chunk-t1gts5j9.js → chunk-qad1mjmc.js} +6 -6
  83. package/dist/{chunk-m5vwh9tb.js → chunk-s958jt49.js} +1 -1
  84. package/dist/{chunk-89rs2afj.js → chunk-tzvtq055.js} +1 -1
  85. package/dist/{chunk-wbabf3hg.js → chunk-v1wqxgra.js} +1 -1
  86. package/dist/{chunk-zesd879q.js → chunk-v9t4751b.js} +2 -2
  87. package/dist/{chunk-dm4vt53n.js → chunk-wctam3r1.js} +1 -1
  88. package/dist/chunk-xask9f1n.js +1 -0
  89. package/dist/chunk-xrr334m5.js +1 -0
  90. package/dist/{chunk-jh38v9zp.js → chunk-y3dj8xwk.js} +1 -1
  91. package/dist/{chunk-4jgy95bv.js → chunk-y3h0ybmn.js} +19 -19
  92. package/dist/deploy/index.js +1 -1
  93. package/dist/dns/index.js +1 -1
  94. package/dist/drivers/index.js +1 -1
  95. package/dist/drivers/shared/compute-ops.d.ts +1 -0
  96. package/dist/drivers/shared/releases.d.ts +43 -16
  97. package/dist/index.js +5 -5
  98. package/dist/operations/index.js +1 -1
  99. package/dist/protection/index.js +1 -1
  100. package/dist/spend/index.js +1 -1
  101. package/dist/ui/404.html +1 -1
  102. package/dist/ui/accept-invitation.html +1 -1
  103. package/dist/ui/access-denied.html +1 -1
  104. package/dist/ui/account/automation.html +6 -6
  105. package/dist/ui/account/security.html +2 -2
  106. package/dist/ui/applications/compose.html +6 -6
  107. package/dist/ui/applications/new.html +2 -2
  108. package/dist/ui/data/backups.html +6 -6
  109. package/dist/ui/data/services.html +6 -6
  110. package/dist/ui/data/volumes.html +6 -6
  111. package/dist/ui/index.html +6 -6
  112. package/dist/ui/infrastructure/topology.html +6 -6
  113. package/dist/ui/integrations.html +2 -2
  114. package/dist/ui/operations/alerts.html +6 -6
  115. package/dist/ui/operations/configuration.html +6 -6
  116. package/dist/ui/operations/jobs.html +6 -6
  117. package/dist/ui/operations/maintenance.html +6 -6
  118. package/dist/ui/operations/observability.html +6 -6
  119. package/dist/ui/operations/previews.html +6 -6
  120. package/dist/ui/operations/queue.html +5 -5
  121. package/dist/ui/operations/regions.html +6 -6
  122. package/dist/ui/operations/releases.html +6 -6
  123. package/dist/ui/operations/spend.html +6 -6
  124. package/dist/ui/operations/workloads.html +5 -5
  125. package/dist/ui/security.html +2 -2
  126. package/dist/ui/server/actions.html +6 -6
  127. package/dist/ui/server/activity.html +1 -1
  128. package/dist/ui/server/capacity.html +6 -6
  129. package/dist/ui/server/database.html +5 -5
  130. package/dist/ui/server/deployments.html +5 -5
  131. package/dist/ui/server/diagnostics.html +1 -1
  132. package/dist/ui/server/firewall.html +5 -5
  133. package/dist/ui/server/fleet.html +5 -5
  134. package/dist/ui/server/logs.html +6 -6
  135. package/dist/ui/server/metrics.html +5 -5
  136. package/dist/ui/server/security.html +1 -1
  137. package/dist/ui/server/services.html +2 -2
  138. package/dist/ui/server/sites.html +5 -5
  139. package/dist/ui/server/ssh-keys.html +6 -6
  140. package/dist/ui/server/team.html +6 -6
  141. package/dist/ui/server/terminal.html +2 -2
  142. package/dist/ui/serverless/alarms.html +6 -6
  143. package/dist/ui/serverless/assets.html +2 -2
  144. package/dist/ui/serverless/cost.html +2 -2
  145. package/dist/ui/serverless/data.html +6 -6
  146. package/dist/ui/serverless/deployments.html +2 -2
  147. package/dist/ui/serverless/firewall.html +1 -1
  148. package/dist/ui/serverless/functions.html +6 -6
  149. package/dist/ui/serverless/logs.html +6 -6
  150. package/dist/ui/serverless/metrics.html +2 -2
  151. package/dist/ui/serverless/queues.html +6 -6
  152. package/dist/ui/serverless/secrets.html +5 -5
  153. package/dist/ui/serverless/traces.html +6 -6
  154. package/dist/ui/serverless.html +5 -5
  155. package/package.json +3 -3
  156. package/dist/bin/chunk-12j17qm5.js +0 -1
  157. package/dist/bin/chunk-24473jks.js +0 -1
  158. package/dist/bin/chunk-3932p1z3.js +0 -1
  159. package/dist/bin/chunk-3eztnxgw.js +0 -1
  160. package/dist/bin/chunk-4182gadf.js +0 -1
  161. package/dist/bin/chunk-4er4ktcs.js +0 -1
  162. package/dist/bin/chunk-9eq18gds.js +0 -1
  163. package/dist/bin/chunk-9zhp2z0s.js +0 -1
  164. package/dist/bin/chunk-bmmr5mq6.js +0 -1
  165. package/dist/bin/chunk-cr56pxpt.js +0 -1
  166. package/dist/bin/chunk-dvv2z19r.js +0 -1
  167. package/dist/bin/chunk-eyrmv6c4.js +0 -1
  168. package/dist/bin/chunk-fnnv0t66.js +0 -1
  169. package/dist/bin/chunk-fwmje99n.js +0 -1
  170. package/dist/bin/chunk-gzxpkk0c.js +0 -3
  171. package/dist/bin/chunk-n775dk3f.js +0 -1
  172. package/dist/bin/chunk-ppj604c9.js +0 -1
  173. package/dist/bin/chunk-prq5gw4j.js +0 -1
  174. package/dist/bin/chunk-pt71fyem.js +0 -1
  175. package/dist/bin/chunk-qvj454fy.js +0 -1
  176. package/dist/bin/chunk-smj97rs5.js +0 -1
  177. package/dist/bin/chunk-wt7wjgcr.js +0 -9
  178. package/dist/bin/chunk-yf3zys06.js +0 -1
  179. package/dist/bin/chunk-zmjm7bmm.js +0 -1
  180. package/dist/chunk-05bmq0z1.js +0 -1
  181. package/dist/chunk-0qdgw73b.js +0 -1
  182. package/dist/chunk-983txhkg.js +0 -1
  183. package/dist/chunk-gv2m8yyg.js +0 -1
  184. package/dist/chunk-pf6sanwe.js +0 -1
@@ -1,4 +1,4 @@
1
- import{rf}from"./chunk-3harnmd6.js";var wQ=rf(function(qA,nI){/*!
1
+ import{nf}from"./chunk-7r2qc39k.js";var wQ=nf(function(qA,nI){/*!
2
2
  * hash-wasm (https://www.npmjs.com/package/hash-wasm)
3
3
  * (c) Dani Biro
4
4
  * @license MIT
@@ -1 +1 @@
1
- import{Hr}from"./chunk-10asqy6j.js";var Zd="\x00";function Do(t,i){if(t==="*"||t==="**")return!0;let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\x01").replace(/\*/g,"[^/]*").replace(/\u0001/g,".*");return new RegExp(`^${e}$`).test(i)}function f(t,i){if(t.startsWith("*.")){let e=t.slice(1);return i.endsWith(e)&&i.length>e.length}return t===i}function Li(t,i){if(t.enabled===!1)return!1;if(t.methods?.length&&!t.methods.some((e)=>e.toUpperCase()===i.method.toUpperCase()))return!1;if(t.path&&!Do(t.path,i.path))return!1;if(t.host&&!f(t.host,i.host??""))return!1;return!0}function $i(t,i){let e=t.key??{source:"ip"},o=e.fallbackToIp!==!1,r;if(e.source==="ip")r=i.ip;else if(e.source==="global")r="global";else if(e.source==="host")r=i.host??"";else if(e.source==="path")r=i.path;else if(e.source==="header")r=e.name?i.headers?.[e.name.toLowerCase()]:void 0;else if(e.source==="cookie")r=e.name?i.cookies?.[e.name]:void 0;if(!r&&e.source!=="global")r=o?i.ip:"__missing__";return`${t.id}\x00${r}`}class Po{clock;maxTrackedKeys;buckets=new Map;windows=new Map;rules;constructor(t,i=()=>Date.now(),e=1e5){this.clock=i;this.maxTrackedKeys=e;this.rules=[...t].sort((o,r)=>(o.priority??0)-(r.priority??0))}check(t){let i=this.clock(),e=this.rules.filter((n)=>Li(n,t)),o;for(let n of e){let s=this.test(n,t,i);if(s.allowed)continue;if(!o||d(s.action)>d(o.action))o=s}if(o)return o;let r={action:"allow",allowed:!0};for(let n of e){let s=this.consume(n,t,i);if(s.remaining!=null&&(r.remaining??1/0)>s.remaining)r=s}return r}test(t,i,e){let o=$i(t,i);if((t.algorithm??"token_bucket")==="token_bucket"){let n=t.burst??t.limit,s=this.buckets.get(o),a=s?Math.min(n,s.tokens+this.refill(t,e-s.updatedAt)):n;if(a>=1)return{action:"allow",allowed:!0};return this.blocked(t,o,0,this.msPerToken(t)*(1-a),e)}let r=(this.windows.get(o)?.hits??[]).filter((n)=>n>e-t.windowMs);if(r.length<t.limit)return{action:"allow",allowed:!0};return this.blocked(t,o,0,r[0]+t.windowMs-e,e)}peek(t){let i=this.clock();for(let e of this.rules){if(!Li(e,t))continue;let o=this.test(e,t,i);if(!o.allowed)return o}return{action:"allow",allowed:!0}}msPerToken(t){return t.windowMs/Math.max(1,t.limit)}refill(t,i){return Math.max(0,i)/this.msPerToken(t)}blocked(t,i,e,o,r){let n=t.action??"deny";return{action:n,allowed:n==="allow"||n==="log",ruleId:t.id,limit:t.limit,remaining:e,retryAfterMs:Math.max(0,Math.ceil(o)),resetAt:r+Math.max(0,o),key:i}}consume(t,i,e){let o=$i(t,i);if((t.algorithm??"token_bucket")==="token_bucket"){let l=t.burst??t.limit,u=this.buckets.get(o)??{tokens:l,updatedAt:e},c=Math.min(l,u.tokens+this.refill(t,e-u.updatedAt));if(c<1)return this.buckets.set(o,{tokens:c,updatedAt:e}),this.blocked(t,o,0,this.msPerToken(t)*(1-c),e);return this.evictIfNeeded(this.buckets),this.buckets.set(o,{tokens:c-1,updatedAt:e}),{action:"allow",allowed:!0,ruleId:t.id,limit:l,remaining:Math.floor(c-1),resetAt:e+this.msPerToken(t)*(l-(c-1)),key:o}}let n=this.windows.get(o)??{hits:[]},s=e-t.windowMs,a=n.hits.filter((l)=>l>s);if(a.length>=t.limit)return this.windows.set(o,{hits:a}),this.blocked(t,o,0,a[0]+t.windowMs-e,e);return a.push(e),this.evictIfNeeded(this.windows),this.windows.set(o,{hits:a}),{action:"allow",allowed:!0,ruleId:t.id,limit:t.limit,remaining:t.limit-a.length,resetAt:a[0]+t.windowMs,key:o}}evictIfNeeded(t){if(t.size<this.maxTrackedKeys)return;let i=t.size-this.maxTrackedKeys+1,e=0;for(let o of t.keys())if(t.delete(o),++e>=i)break}sweep(){let t=this.clock(),i=0;for(let[e,o]of this.windows){let r=e.split("\x00")[0],n=this.rules.find((s)=>s.id===r);if(!n){this.windows.delete(e),i++;continue}if(o.hits.every((s)=>s<=t-n.windowMs))this.windows.delete(e),i++}for(let[e,o]of this.buckets){let r=e.split("\x00")[0],n=this.rules.find((s)=>s.id===r);if(!n||t-o.updatedAt>n.windowMs*2)this.buckets.delete(e),i++}return i}get trackedKeys(){return this.buckets.size+this.windows.size}}function d(t){return{allow:0,log:1,throttle:2,challenge:3,deny:4}[t]}function el(t){let i={};if(t.limit!=null)i["ratelimit-limit"]=String(t.limit);if(t.remaining!=null)i["ratelimit-remaining"]=String(t.remaining);if(t.resetAt!=null)i["ratelimit-reset"]=String(Math.max(0,Math.ceil((t.resetAt-Date.now())/1000)));if(!t.allowed&&t.retryAfterMs!=null)i["retry-after"]=String(Math.max(1,Math.ceil(t.retryAfterMs/1000)));return i}function tl(){return[{id:"global-ip",limit:600,windowMs:60000,burst:100,key:{source:"ip"},action:"deny",priority:100},{id:"api-ip",limit:120,windowMs:60000,burst:30,path:"/api/**",key:{source:"ip"},action:"deny",priority:50},{id:"auth-ip",limit:10,windowMs:60000,algorithm:"sliding_window",path:"/auth/**",methods:["POST"],key:{source:"ip"},action:"challenge",priority:10}]}var rl="protection.controls",Mi=24,No=4,g={ipRules:{allow:[],block:[]}};function m(t,i){if(!t?.enabled)return;return new Date(t.expiresAt).getTime()>i.getTime()?t:void 0}function p(t,i){let e=Number.isFinite(t)?Number(t):i;return Math.min(Mi,Math.max(0.25,e))}var h=500;class ko{controlPlane;options;constructor(t,i={}){this.controlPlane=t;this.options=i}now(){return this.options.now?.()??new Date}read(){let t=this.controlPlane.getSetting(rl);if(!t||typeof t!=="object"||Array.isArray(t))return{...g,ipRules:{allow:[],block:[]}};let i=t;return{attackMode:i.attackMode,mitigationPause:i.mitigationPause,ipRules:{allow:Array.isArray(i.ipRules?.allow)?i.ipRules.allow:[],block:Array.isArray(i.ipRules?.block)?i.ipRules.block:[]},updatedAt:i.updatedAt}}write(t){let i={...t,updatedAt:this.now().toISOString()};return this.controlPlane.setSetting(rl,i),i}raw(){return this.read()}current(){let t=this.now(),i=this.read();return{attackMode:m(i.attackMode,t),mitigationPause:m(i.mitigationPause,t),ipRules:i.ipRules}}enableAttackMode(t){let i=this.now(),e={enabled:!0,startedAt:i.toISOString(),expiresAt:new Date(i.getTime()+p(t.hours,No)*3600000).toISOString(),reason:t.reason.trim()||"Attack mode enabled by an operator.",actorId:t.actorId};return this.write({...this.read(),attackMode:e}),e}disableAttackMode(){let t=this.read();if(!t.attackMode?.enabled)return!1;return this.write({...t,attackMode:{...t.attackMode,enabled:!1}}),!0}pauseMitigations(t){let i=t.reason.trim();if(!i)throw Error("Pausing mitigations requires a reason: you are liable for the traffic it admits.");let e=this.now(),o={enabled:!0,startedAt:e.toISOString(),expiresAt:new Date(e.getTime()+p(t.hours,Mi)*3600000).toISOString(),reason:i,actorId:t.actorId};return this.write({...this.read(),mitigationPause:o}),o}resumeMitigations(){let t=this.read();if(!t.mitigationPause?.enabled)return!1;return this.write({...t,mitigationPause:{...t.mitigationPause,enabled:!1}}),!0}addIpRule(t,i){let e=i.trim();if(!Hr(e))throw Error(`Not a valid IP or CIDR: ${i}`);let o=this.read(),r={...o.ipRules,[t]:[...new Set([...o.ipRules[t],e])]};if(r[t].length>h)throw Error(`At most ${h} ${t} rules are supported.`);let n=t==="allow"?"block":"allow";return r[n]=r[n].filter((s)=>s!==e),this.write({...o,ipRules:r}),r}removeIpRule(t,i){let e=this.read(),o={...e.ipRules,[t]:e.ipRules[t].filter((r)=>r!==i.trim())};return this.write({...e,ipRules:o}),o}}function nl(t){if(t.mitigationPause)return{attackMode:!!t.attackMode,mitigationPaused:!0,summary:`Automatic mitigation is paused until ${t.mitigationPause.expiresAt}. All traffic is being served and billed.`,expiresAt:t.mitigationPause.expiresAt};if(t.attackMode)return{attackMode:!0,mitigationPaused:!1,summary:`Attack mode is on until ${t.attackMode.expiresAt}. Every visitor is being challenged.`,expiresAt:t.attackMode.expiresAt};return{attackMode:!1,mitigationPaused:!1,summary:"Protection is in its normal posture."}}function il(t,i){if(i.mitigationPause)return t.map((e)=>({...e,enabled:!1}));if(!i.attackMode)return[...t];return t.map((e)=>({...e,action:e.action==="deny"?"deny":"challenge",burst:Math.max(1,Math.min(e.burst??e.limit,5))}))}function Bo(t,i){let e=[...new Set([...t.allowlist??[],...i.ipRules.allow])],o=[...new Set([...t.blocklist??[],...i.ipRules.block])];if(i.mitigationPause)return{...t,allowlist:e,blocklist:o,monitorOnly:!0};if(!i.attackMode)return{...t,allowlist:e,blocklist:o};let r=t.thresholds??{};return{...t,allowlist:e,blocklist:o,thresholds:{...r,newConnectionsPerSecond:Math.max(1,Math.floor((r.newConnectionsPerSecond??50)/5)),concurrentPerSource:Math.max(1,Math.floor((r.concurrentPerSource??100)/5))}}}function my(t,i){let e=t?.infrastructure?.compute;if(!e||e.ddos===!1)return t;let o=typeof e.ddos==="object"&&e.ddos!==null?e.ddos:{};return{...t,infrastructure:{...t.infrastructure,compute:{...e,ddos:Bo(o,i)}}}}export{Zd,Do,Li,$i,Po,el,tl,rl,Mi,No,ko,nl,il,Bo,my};
1
+ import{Hr}from"./chunk-e08h4q50.js";var Zd="\x00";function Do(t,i){if(t==="*"||t==="**")return!0;let e=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\x01").replace(/\*/g,"[^/]*").replace(/\u0001/g,".*");return new RegExp(`^${e}$`).test(i)}function f(t,i){if(t.startsWith("*.")){let e=t.slice(1);return i.endsWith(e)&&i.length>e.length}return t===i}function Li(t,i){if(t.enabled===!1)return!1;if(t.methods?.length&&!t.methods.some((e)=>e.toUpperCase()===i.method.toUpperCase()))return!1;if(t.path&&!Do(t.path,i.path))return!1;if(t.host&&!f(t.host,i.host??""))return!1;return!0}function $i(t,i){let e=t.key??{source:"ip"},o=e.fallbackToIp!==!1,r;if(e.source==="ip")r=i.ip;else if(e.source==="global")r="global";else if(e.source==="host")r=i.host??"";else if(e.source==="path")r=i.path;else if(e.source==="header")r=e.name?i.headers?.[e.name.toLowerCase()]:void 0;else if(e.source==="cookie")r=e.name?i.cookies?.[e.name]:void 0;if(!r&&e.source!=="global")r=o?i.ip:"__missing__";return`${t.id}\x00${r}`}class Po{clock;maxTrackedKeys;buckets=new Map;windows=new Map;rules;constructor(t,i=()=>Date.now(),e=1e5){this.clock=i;this.maxTrackedKeys=e;this.rules=[...t].sort((o,r)=>(o.priority??0)-(r.priority??0))}check(t){let i=this.clock(),e=this.rules.filter((n)=>Li(n,t)),o;for(let n of e){let s=this.test(n,t,i);if(s.allowed)continue;if(!o||d(s.action)>d(o.action))o=s}if(o)return o;let r={action:"allow",allowed:!0};for(let n of e){let s=this.consume(n,t,i);if(s.remaining!=null&&(r.remaining??1/0)>s.remaining)r=s}return r}test(t,i,e){let o=$i(t,i);if((t.algorithm??"token_bucket")==="token_bucket"){let n=t.burst??t.limit,s=this.buckets.get(o),a=s?Math.min(n,s.tokens+this.refill(t,e-s.updatedAt)):n;if(a>=1)return{action:"allow",allowed:!0};return this.blocked(t,o,0,this.msPerToken(t)*(1-a),e)}let r=(this.windows.get(o)?.hits??[]).filter((n)=>n>e-t.windowMs);if(r.length<t.limit)return{action:"allow",allowed:!0};return this.blocked(t,o,0,r[0]+t.windowMs-e,e)}peek(t){let i=this.clock();for(let e of this.rules){if(!Li(e,t))continue;let o=this.test(e,t,i);if(!o.allowed)return o}return{action:"allow",allowed:!0}}msPerToken(t){return t.windowMs/Math.max(1,t.limit)}refill(t,i){return Math.max(0,i)/this.msPerToken(t)}blocked(t,i,e,o,r){let n=t.action??"deny";return{action:n,allowed:n==="allow"||n==="log",ruleId:t.id,limit:t.limit,remaining:e,retryAfterMs:Math.max(0,Math.ceil(o)),resetAt:r+Math.max(0,o),key:i}}consume(t,i,e){let o=$i(t,i);if((t.algorithm??"token_bucket")==="token_bucket"){let l=t.burst??t.limit,u=this.buckets.get(o)??{tokens:l,updatedAt:e},c=Math.min(l,u.tokens+this.refill(t,e-u.updatedAt));if(c<1)return this.buckets.set(o,{tokens:c,updatedAt:e}),this.blocked(t,o,0,this.msPerToken(t)*(1-c),e);return this.evictIfNeeded(this.buckets),this.buckets.set(o,{tokens:c-1,updatedAt:e}),{action:"allow",allowed:!0,ruleId:t.id,limit:l,remaining:Math.floor(c-1),resetAt:e+this.msPerToken(t)*(l-(c-1)),key:o}}let n=this.windows.get(o)??{hits:[]},s=e-t.windowMs,a=n.hits.filter((l)=>l>s);if(a.length>=t.limit)return this.windows.set(o,{hits:a}),this.blocked(t,o,0,a[0]+t.windowMs-e,e);return a.push(e),this.evictIfNeeded(this.windows),this.windows.set(o,{hits:a}),{action:"allow",allowed:!0,ruleId:t.id,limit:t.limit,remaining:t.limit-a.length,resetAt:a[0]+t.windowMs,key:o}}evictIfNeeded(t){if(t.size<this.maxTrackedKeys)return;let i=t.size-this.maxTrackedKeys+1,e=0;for(let o of t.keys())if(t.delete(o),++e>=i)break}sweep(){let t=this.clock(),i=0;for(let[e,o]of this.windows){let r=e.split("\x00")[0],n=this.rules.find((s)=>s.id===r);if(!n){this.windows.delete(e),i++;continue}if(o.hits.every((s)=>s<=t-n.windowMs))this.windows.delete(e),i++}for(let[e,o]of this.buckets){let r=e.split("\x00")[0],n=this.rules.find((s)=>s.id===r);if(!n||t-o.updatedAt>n.windowMs*2)this.buckets.delete(e),i++}return i}get trackedKeys(){return this.buckets.size+this.windows.size}}function d(t){return{allow:0,log:1,throttle:2,challenge:3,deny:4}[t]}function el(t){let i={};if(t.limit!=null)i["ratelimit-limit"]=String(t.limit);if(t.remaining!=null)i["ratelimit-remaining"]=String(t.remaining);if(t.resetAt!=null)i["ratelimit-reset"]=String(Math.max(0,Math.ceil((t.resetAt-Date.now())/1000)));if(!t.allowed&&t.retryAfterMs!=null)i["retry-after"]=String(Math.max(1,Math.ceil(t.retryAfterMs/1000)));return i}function tl(){return[{id:"global-ip",limit:600,windowMs:60000,burst:100,key:{source:"ip"},action:"deny",priority:100},{id:"api-ip",limit:120,windowMs:60000,burst:30,path:"/api/**",key:{source:"ip"},action:"deny",priority:50},{id:"auth-ip",limit:10,windowMs:60000,algorithm:"sliding_window",path:"/auth/**",methods:["POST"],key:{source:"ip"},action:"challenge",priority:10}]}var rl="protection.controls",Mi=24,No=4,g={ipRules:{allow:[],block:[]}};function m(t,i){if(!t?.enabled)return;return new Date(t.expiresAt).getTime()>i.getTime()?t:void 0}function p(t,i){let e=Number.isFinite(t)?Number(t):i;return Math.min(Mi,Math.max(0.25,e))}var h=500;class ko{controlPlane;options;constructor(t,i={}){this.controlPlane=t;this.options=i}now(){return this.options.now?.()??new Date}read(){let t=this.controlPlane.getSetting(rl);if(!t||typeof t!=="object"||Array.isArray(t))return{...g,ipRules:{allow:[],block:[]}};let i=t;return{attackMode:i.attackMode,mitigationPause:i.mitigationPause,ipRules:{allow:Array.isArray(i.ipRules?.allow)?i.ipRules.allow:[],block:Array.isArray(i.ipRules?.block)?i.ipRules.block:[]},updatedAt:i.updatedAt}}write(t){let i={...t,updatedAt:this.now().toISOString()};return this.controlPlane.setSetting(rl,i),i}raw(){return this.read()}current(){let t=this.now(),i=this.read();return{attackMode:m(i.attackMode,t),mitigationPause:m(i.mitigationPause,t),ipRules:i.ipRules}}enableAttackMode(t){let i=this.now(),e={enabled:!0,startedAt:i.toISOString(),expiresAt:new Date(i.getTime()+p(t.hours,No)*3600000).toISOString(),reason:t.reason.trim()||"Attack mode enabled by an operator.",actorId:t.actorId};return this.write({...this.read(),attackMode:e}),e}disableAttackMode(){let t=this.read();if(!t.attackMode?.enabled)return!1;return this.write({...t,attackMode:{...t.attackMode,enabled:!1}}),!0}pauseMitigations(t){let i=t.reason.trim();if(!i)throw Error("Pausing mitigations requires a reason: you are liable for the traffic it admits.");let e=this.now(),o={enabled:!0,startedAt:e.toISOString(),expiresAt:new Date(e.getTime()+p(t.hours,Mi)*3600000).toISOString(),reason:i,actorId:t.actorId};return this.write({...this.read(),mitigationPause:o}),o}resumeMitigations(){let t=this.read();if(!t.mitigationPause?.enabled)return!1;return this.write({...t,mitigationPause:{...t.mitigationPause,enabled:!1}}),!0}addIpRule(t,i){let e=i.trim();if(!Hr(e))throw Error(`Not a valid IP or CIDR: ${i}`);let o=this.read(),r={...o.ipRules,[t]:[...new Set([...o.ipRules[t],e])]};if(r[t].length>h)throw Error(`At most ${h} ${t} rules are supported.`);let n=t==="allow"?"block":"allow";return r[n]=r[n].filter((s)=>s!==e),this.write({...o,ipRules:r}),r}removeIpRule(t,i){let e=this.read(),o={...e.ipRules,[t]:e.ipRules[t].filter((r)=>r!==i.trim())};return this.write({...e,ipRules:o}),o}}function nl(t){if(t.mitigationPause)return{attackMode:!!t.attackMode,mitigationPaused:!0,summary:`Automatic mitigation is paused until ${t.mitigationPause.expiresAt}. All traffic is being served and billed.`,expiresAt:t.mitigationPause.expiresAt};if(t.attackMode)return{attackMode:!0,mitigationPaused:!1,summary:`Attack mode is on until ${t.attackMode.expiresAt}. Every visitor is being challenged.`,expiresAt:t.attackMode.expiresAt};return{attackMode:!1,mitigationPaused:!1,summary:"Protection is in its normal posture."}}function il(t,i){if(i.mitigationPause)return t.map((e)=>({...e,enabled:!1}));if(!i.attackMode)return[...t];return t.map((e)=>({...e,action:e.action==="deny"?"deny":"challenge",burst:Math.max(1,Math.min(e.burst??e.limit,5))}))}function Bo(t,i){let e=[...new Set([...t.allowlist??[],...i.ipRules.allow])],o=[...new Set([...t.blocklist??[],...i.ipRules.block])];if(i.mitigationPause)return{...t,allowlist:e,blocklist:o,monitorOnly:!0};if(!i.attackMode)return{...t,allowlist:e,blocklist:o};let r=t.thresholds??{};return{...t,allowlist:e,blocklist:o,thresholds:{...r,newConnectionsPerSecond:Math.max(1,Math.floor((r.newConnectionsPerSecond??50)/5)),concurrentPerSource:Math.max(1,Math.floor((r.concurrentPerSource??100)/5))}}}function hy(t,i){let e=t?.infrastructure?.compute;if(!e||e.ddos===!1)return t;let o=typeof e.ddos==="object"&&e.ddos!==null?e.ddos:{};return{...t,infrastructure:{...t.infrastructure,compute:{...e,ddos:Bo(o,i)}}}}export{Zd,Do,Li,$i,Po,el,tl,rl,Mi,No,ko,nl,il,Bo,hy};
@@ -1,2 +1,2 @@
1
- import{n}from"./chunk-m93g67j0.js";import{h}from"./chunk-rqe0sfqw.js";class f{client;region;constructor(e="us-east-1",t){this.region=e,this.client=new n(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,u)=>{a[`RetainResources.member.${u+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],u=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((m)=>setTimeout(m,2000)),i++;continue}let o=c.Stacks[0];if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Status = ${o.StackStatus}${o.StackStatusReason?` (${o.StackStatusReason})`:""}`);if(r.includes(o.StackStatus))return;if((t==="stack-create-complete"||t==="stack-update-complete")&&(o.StackStatus==="DELETE_IN_PROGRESS"||o.StackStatus==="DELETE_COMPLETE")){console.log("[waitForStack] Stack is being deleted (creation/update failed)");let m="";try{let S=await this.describeStackEvents(e);console.log("[waitForStack] Stack events (most recent first):");for(let k of S.StackEvents.slice(0,15))if(k.ResourceStatus.includes("FAILED")||k.ResourceStatusReason){if(console.log(` ${k.LogicalResourceId}: ${k.ResourceStatus} - ${k.ResourceStatusReason||"No reason provided"}`),k.ResourceStatus.includes("FAILED")&&k.ResourceStatusReason&&!m)m=k.ResourceStatusReason}}catch{}let l=m||o.StackStatusReason||"Check CloudFormation console for details.";throw Error(`Stack creation/update failed - stack is being deleted. Reason: ${l}`)}if(o.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let m=Error("Stack deletion failed - may have resources that need to be retained");throw m.code="DELETE_FAILED",m.stackStatus=o.StackStatus,m.statusReason=o.StackStatusReason,m}if(a.includes(o.StackStatus))throw Error(`Stack reached failure status: ${o.StackStatus}`);await new Promise((m)=>setTimeout(m,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((o)=>setTimeout(o,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,o)=>{t[`StackStatusFilter.member.${o+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,u=r.StackSummaries?.member||r.StackSummaries||[];return{StackSummaries:(Array.isArray(u)?u:u?[u]:[]).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((r,u)=>{t[`Parameters.member.${u+1}.ParameterKey`]=r.ParameterKey,t[`Parameters.member.${u+1}.ParameterValue`]=r.ParameterValue});if(e.capabilities)e.capabilities.forEach((r,u)=>{t[`Capabilities.member.${u+1}`]=r});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()}),a=h(s,"CreateChangeSet");return{Id:a?.Id,StackId:a?.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"],u=a[t],i=360,c=0,o=new Set;while(c<360)try{if(s)try{let k=[...(await this.describeStackEvents(e)).StackEvents||[]].reverse();for(let d of k){let g=`${d.LogicalResourceId}-${d.ResourceStatus}-${d.Timestamp}`;if(!o.has(g))o.add(g),s({resourceId:d.LogicalResourceId,resourceType:d.ResourceType,status:d.ResourceStatus,reason:d.ResourceStatusReason,timestamp:d.Timestamp})}}catch{}let m=await this.describeStacks({stackName:e});if(m.Stacks.length===0){if(t==="stack-delete-complete")return;await new Promise((S)=>setTimeout(S,2000)),c++;continue}let l=m.Stacks[0];if(u.includes(l.StackStatus))return;if(l.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let S=Error("Stack deletion failed - may have resources that need to be retained");throw S.code="DELETE_FAILED",S.stackStatus=l.StackStatus,S.statusReason=l.StackStatusReason,S}if(r.includes(l.StackStatus))throw Error(`Stack reached failure status: ${l.StackStatus}`);await new Promise((S)=>setTimeout(S,3000)),c++}catch(m){if(t==="stack-delete-complete"&&m.message?.includes("does not exist"))return;if(t==="stack-create-complete"&&m.message?.includes("does not exist")){await new Promise((l)=>setTimeout(l,2000)),c++;continue}throw m}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 u=0;u<t;u++)try{let i=await this.describeStacks({stackName:e});if(i.Stacks.length===0)return{success:!0,status:"DELETE_COMPLETE"};let c=i.Stacks[0],o=c.StackStatus;if(a.includes(o))return{success:!0,status:o};if(r.includes(o))return{success:!1,status:o,reason:c.StackStatusReason};await new Promise((m)=>setTimeout(m,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"}}}
1
+ import{n}from"./chunk-g3f3ccdw.js";import{h}from"./chunk-rqe0sfqw.js";class f{client;region;constructor(e="us-east-1",t){this.region=e,this.client=new n(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,u)=>{a[`RetainResources.member.${u+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],u=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((m)=>setTimeout(m,2000)),i++;continue}let o=c.Stacks[0];if(i%10===0)console.log(`[waitForStack] Attempt ${i}: Status = ${o.StackStatus}${o.StackStatusReason?` (${o.StackStatusReason})`:""}`);if(r.includes(o.StackStatus))return;if((t==="stack-create-complete"||t==="stack-update-complete")&&(o.StackStatus==="DELETE_IN_PROGRESS"||o.StackStatus==="DELETE_COMPLETE")){console.log("[waitForStack] Stack is being deleted (creation/update failed)");let m="";try{let S=await this.describeStackEvents(e);console.log("[waitForStack] Stack events (most recent first):");for(let k of S.StackEvents.slice(0,15))if(k.ResourceStatus.includes("FAILED")||k.ResourceStatusReason){if(console.log(` ${k.LogicalResourceId}: ${k.ResourceStatus} - ${k.ResourceStatusReason||"No reason provided"}`),k.ResourceStatus.includes("FAILED")&&k.ResourceStatusReason&&!m)m=k.ResourceStatusReason}}catch{}let l=m||o.StackStatusReason||"Check CloudFormation console for details.";throw Error(`Stack creation/update failed - stack is being deleted. Reason: ${l}`)}if(o.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let m=Error("Stack deletion failed - may have resources that need to be retained");throw m.code="DELETE_FAILED",m.stackStatus=o.StackStatus,m.statusReason=o.StackStatusReason,m}if(a.includes(o.StackStatus))throw Error(`Stack reached failure status: ${o.StackStatus}`);await new Promise((m)=>setTimeout(m,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((o)=>setTimeout(o,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,o)=>{t[`StackStatusFilter.member.${o+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,u=r.StackSummaries?.member||r.StackSummaries||[];return{StackSummaries:(Array.isArray(u)?u:u?[u]:[]).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((r,u)=>{t[`Parameters.member.${u+1}.ParameterKey`]=r.ParameterKey,t[`Parameters.member.${u+1}.ParameterValue`]=r.ParameterValue});if(e.capabilities)e.capabilities.forEach((r,u)=>{t[`Capabilities.member.${u+1}`]=r});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()}),a=h(s,"CreateChangeSet");return{Id:a?.Id,StackId:a?.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"],u=a[t],i=360,c=0,o=new Set;while(c<360)try{if(s)try{let k=[...(await this.describeStackEvents(e)).StackEvents||[]].reverse();for(let d of k){let g=`${d.LogicalResourceId}-${d.ResourceStatus}-${d.Timestamp}`;if(!o.has(g))o.add(g),s({resourceId:d.LogicalResourceId,resourceType:d.ResourceType,status:d.ResourceStatus,reason:d.ResourceStatusReason,timestamp:d.Timestamp})}}catch{}let m=await this.describeStacks({stackName:e});if(m.Stacks.length===0){if(t==="stack-delete-complete")return;await new Promise((S)=>setTimeout(S,2000)),c++;continue}let l=m.Stacks[0];if(u.includes(l.StackStatus))return;if(l.StackStatus==="DELETE_FAILED"&&t==="stack-delete-complete"){let S=Error("Stack deletion failed - may have resources that need to be retained");throw S.code="DELETE_FAILED",S.stackStatus=l.StackStatus,S.statusReason=l.StackStatusReason,S}if(r.includes(l.StackStatus))throw Error(`Stack reached failure status: ${l.StackStatus}`);await new Promise((S)=>setTimeout(S,3000)),c++}catch(m){if(t==="stack-delete-complete"&&m.message?.includes("does not exist"))return;if(t==="stack-create-complete"&&m.message?.includes("does not exist")){await new Promise((l)=>setTimeout(l,2000)),c++;continue}throw m}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 u=0;u<t;u++)try{let i=await this.describeStacks({stackName:e});if(i.Stacks.length===0)return{success:!0,status:"DELETE_COMPLETE"};let c=i.Stacks[0],o=c.StackStatus;if(a.includes(o))return{success:!0,status:o};if(r.includes(o))return{success:!1,status:o,reason:c.StackStatusReason};await new Promise((m)=>setTimeout(m,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
2
  export{f};
@@ -33,5 +33,5 @@ fi
33
33
 
34
34
  mv "${s}.new" "${s}"
35
35
  echo "ts-cloud: WAF config installed (mode: ${n.mode})"
36
- `}function Ap(e,r){return e.map((t)=>({projectId:r.projectId,environmentId:r.environmentId,resourceId:r.resourceId,kind:"event",source:"zig-waf",name:t.action==="blocked"?"waf.blocked":"waf.matched",timestamp:t.timestamp,value:1,host:t.host,pathTemplate:t.path,method:t.method,attributes:{ruleId:t.ruleId??null,anomalyScore:t.anomalyScore,action:t.action,messages:t.messages.slice(0,5)}}))}
37
- export{Y,ci,Ms,_c,di,Ap};
36
+ `}function yp(e,r){return e.map((t)=>({projectId:r.projectId,environmentId:r.environmentId,resourceId:r.resourceId,kind:"event",source:"zig-waf",name:t.action==="blocked"?"waf.blocked":"waf.matched",timestamp:t.timestamp,value:1,host:t.host,pathTemplate:t.path,method:t.method,attributes:{ruleId:t.ruleId??null,anomalyScore:t.anomalyScore,action:t.action,messages:t.messages.slice(0,5)}}))}
37
+ export{Y,ci,Ms,_c,di,yp};
@@ -1,2 +1,2 @@
1
- import{n}from"./chunk-m93g67j0.js";class $e{client;region;constructor(e="us-east-1",r){this.region=e,this.client=new n(void 0,{profile:r})}async createRepository(e){let r={repositoryName:e.repositoryName};if(e.imageTagMutability)r.imageTagMutability=e.imageTagMutability;if(e.imageScanningConfiguration)r.imageScanningConfiguration=e.imageScanningConfiguration;if(e.encryptionConfiguration)r.encryptionConfiguration=e.encryptionConfiguration;if(e.tags&&e.tags.length>0)r.tags=e.tags;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.CreateRepository","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repository:t.repository?this.parseRepository(t.repository):void 0}}async describeRepositories(e){let r={};if(e?.repositoryNames&&e.repositoryNames.length>0)r.repositoryNames=e.repositoryNames;if(e?.registryId)r.registryId=e.registryId;if(e?.maxResults)r.maxResults=e.maxResults;if(e?.nextToken)r.nextToken=e.nextToken;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DescribeRepositories","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repositories:t.repositories?.map((i)=>this.parseRepository(i)),nextToken:t.nextToken}}async getAuthorizationToken(e){let r={};if(e&&e.length>0)r.registryIds=e;return{authorizationData:(await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})).authorizationData?.map((i)=>({authorizationToken:i.authorizationToken,expiresAt:i.expiresAt,proxyEndpoint:i.proxyEndpoint}))}}async deleteRepository(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;if(e.force!==void 0)r.force=e.force;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DeleteRepository","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repository:t.repository?this.parseRepository(t.repository):void 0}}async describeImages(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;if(e.imageIds&&e.imageIds.length>0)r.imageIds=e.imageIds;if(e.filter)r.filter=e.filter;if(e.maxResults)r.maxResults=e.maxResults;if(e.nextToken)r.nextToken=e.nextToken;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DescribeImages","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{imageDetails:t.imageDetails?.map((i)=>this.parseImageDetail(i)),nextToken:t.nextToken}}async batchDeleteImage(e){let r={repositoryName:e.repositoryName,imageIds:e.imageIds};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.BatchDeleteImage","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{imageIds:t.imageIds,failures:t.failures}}async putLifecyclePolicy(e){let r={repositoryName:e.repositoryName,lifecyclePolicyText:e.lifecyclePolicyText};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.PutLifecyclePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,lifecyclePolicyText:t.lifecyclePolicyText}}async getLifecyclePolicy(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetLifecyclePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,lifecyclePolicyText:t.lifecyclePolicyText,lastEvaluatedAt:t.lastEvaluatedAt}}async setRepositoryPolicy(e){let r={repositoryName:e.repositoryName,policyText:e.policyText};if(e.registryId)r.registryId=e.registryId;if(e.force!==void 0)r.force=e.force;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.SetRepositoryPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,policyText:t.policyText}}async getRepositoryPolicy(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetRepositoryPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,policyText:t.policyText}}async tagResource(e){let r={resourceArn:e.resourceArn,tags:e.tags};await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.TagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})}async listTagsForResource(e){let r={resourceArn:e};return{tags:(await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.ListTagsForResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})).tags}}createLifecyclePolicyText(e){return JSON.stringify({rules:e.map((r)=>({rulePriority:r.rulePriority,description:r.description,selection:r.selection,action:r.action}))})}async getDockerLoginCommand(){let e=await this.getAuthorizationToken();if(!e.authorizationData?.[0])throw Error("Failed to get authorization token");let r=e.authorizationData[0],t=r.authorizationToken||"",i=r.proxyEndpoint||"";return`echo "${Buffer.from(t,"base64").toString("utf8").split(":")[1]}" | docker login --username AWS --password-stdin ${i}`}getRegistryUri(e){return`${e}.dkr.ecr.${this.region}.amazonaws.com`}parseRepository(e){return{repositoryArn:e.repositoryArn,registryId:e.registryId,repositoryName:e.repositoryName,repositoryUri:e.repositoryUri,createdAt:e.createdAt,imageTagMutability:e.imageTagMutability,imageScanningConfiguration:e.imageScanningConfiguration,encryptionConfiguration:e.encryptionConfiguration}}parseImageDetail(e){return{registryId:e.registryId,repositoryName:e.repositoryName,imageDigest:e.imageDigest,imageTags:e.imageTags,imageSizeInBytes:e.imageSizeInBytes,imagePushedAt:e.imagePushedAt,imageScanStatus:e.imageScanStatus,imageScanFindingsSummary:e.imageScanFindingsSummary}}}
1
+ import{n}from"./chunk-g3f3ccdw.js";class $e{client;region;constructor(e="us-east-1",r){this.region=e,this.client=new n(void 0,{profile:r})}async createRepository(e){let r={repositoryName:e.repositoryName};if(e.imageTagMutability)r.imageTagMutability=e.imageTagMutability;if(e.imageScanningConfiguration)r.imageScanningConfiguration=e.imageScanningConfiguration;if(e.encryptionConfiguration)r.encryptionConfiguration=e.encryptionConfiguration;if(e.tags&&e.tags.length>0)r.tags=e.tags;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.CreateRepository","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repository:t.repository?this.parseRepository(t.repository):void 0}}async describeRepositories(e){let r={};if(e?.repositoryNames&&e.repositoryNames.length>0)r.repositoryNames=e.repositoryNames;if(e?.registryId)r.registryId=e.registryId;if(e?.maxResults)r.maxResults=e.maxResults;if(e?.nextToken)r.nextToken=e.nextToken;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DescribeRepositories","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repositories:t.repositories?.map((i)=>this.parseRepository(i)),nextToken:t.nextToken}}async getAuthorizationToken(e){let r={};if(e&&e.length>0)r.registryIds=e;return{authorizationData:(await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})).authorizationData?.map((i)=>({authorizationToken:i.authorizationToken,expiresAt:i.expiresAt,proxyEndpoint:i.proxyEndpoint}))}}async deleteRepository(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;if(e.force!==void 0)r.force=e.force;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DeleteRepository","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repository:t.repository?this.parseRepository(t.repository):void 0}}async describeImages(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;if(e.imageIds&&e.imageIds.length>0)r.imageIds=e.imageIds;if(e.filter)r.filter=e.filter;if(e.maxResults)r.maxResults=e.maxResults;if(e.nextToken)r.nextToken=e.nextToken;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DescribeImages","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{imageDetails:t.imageDetails?.map((i)=>this.parseImageDetail(i)),nextToken:t.nextToken}}async batchDeleteImage(e){let r={repositoryName:e.repositoryName,imageIds:e.imageIds};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.BatchDeleteImage","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{imageIds:t.imageIds,failures:t.failures}}async putLifecyclePolicy(e){let r={repositoryName:e.repositoryName,lifecyclePolicyText:e.lifecyclePolicyText};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.PutLifecyclePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,lifecyclePolicyText:t.lifecyclePolicyText}}async getLifecyclePolicy(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetLifecyclePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,lifecyclePolicyText:t.lifecyclePolicyText,lastEvaluatedAt:t.lastEvaluatedAt}}async setRepositoryPolicy(e){let r={repositoryName:e.repositoryName,policyText:e.policyText};if(e.registryId)r.registryId=e.registryId;if(e.force!==void 0)r.force=e.force;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.SetRepositoryPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,policyText:t.policyText}}async getRepositoryPolicy(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetRepositoryPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,policyText:t.policyText}}async tagResource(e){let r={resourceArn:e.resourceArn,tags:e.tags};await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.TagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})}async listTagsForResource(e){let r={resourceArn:e};return{tags:(await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.ListTagsForResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})).tags}}createLifecyclePolicyText(e){return JSON.stringify({rules:e.map((r)=>({rulePriority:r.rulePriority,description:r.description,selection:r.selection,action:r.action}))})}async getDockerLoginCommand(){let e=await this.getAuthorizationToken();if(!e.authorizationData?.[0])throw Error("Failed to get authorization token");let r=e.authorizationData[0],t=r.authorizationToken||"",i=r.proxyEndpoint||"";return`echo "${Buffer.from(t,"base64").toString("utf8").split(":")[1]}" | docker login --username AWS --password-stdin ${i}`}getRegistryUri(e){return`${e}.dkr.ecr.${this.region}.amazonaws.com`}parseRepository(e){return{repositoryArn:e.repositoryArn,registryId:e.registryId,repositoryName:e.repositoryName,repositoryUri:e.repositoryUri,createdAt:e.createdAt,imageTagMutability:e.imageTagMutability,imageScanningConfiguration:e.imageScanningConfiguration,encryptionConfiguration:e.encryptionConfiguration}}parseImageDetail(e){return{registryId:e.registryId,repositoryName:e.repositoryName,imageDigest:e.imageDigest,imageTags:e.imageTags,imageSizeInBytes:e.imageSizeInBytes,imagePushedAt:e.imagePushedAt,imageScanStatus:e.imageScanStatus,imageScanFindingsSummary:e.imageScanFindingsSummary}}}
2
2
  export{$e};
@@ -0,0 +1 @@
1
+ import{K}from"./chunk-m1jp1abp.js";import"./chunk-g3f3ccdw.js";export{K as RDSClient};
@@ -0,0 +1 @@
1
+ import{ss,os,as,cs,Fa,Ua}from"./chunk-444h366b.js";import"./chunk-pkpmz35j.js";import"./chunk-n4gkyye3.js";import"./chunk-c6nw88s3.js";import"./chunk-v1wqxgra.js";import"./chunk-45116tdd.js";import"./chunk-g3f3ccdw.js";export{Fa as deleteStaticSite,os as deployStaticSite,Ua as deployStaticSiteFull,ss as generateStaticSiteTemplate,cs as invalidateCache,as as uploadStaticFiles};
@@ -1,4 +1,4 @@
1
- import{So,Wr,Vd,xi,wo,Ro}from"./chunk-r45340yc.js";import{$e}from"./chunk-dm4vt53n.js";import{execFileSync as A}from"node:child_process";import{mkdirSync as S,mkdtempSync as U,rmSync as L,writeFileSync as d}from"node:fs";import{tmpdir as O}from"node:os";import{dirname as j,join as s}from"node:path";var r={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"};function I(t,e){return`${r[e]}${t}${r.reset}`}function An(t){console.log(`${r.green}✓${r.reset} ${t}`)}function bu(t){console.error(`${r.red}✗${r.reset} ${t}`)}function ds(t){console.warn(`${r.yellow}⚠${r.reset} ${t}`)}function k(t){console.log(`${r.blue}ℹ${r.reset} ${t}`)}function w(t){console.log(`${r.cyan}→${r.reset} ${t}`)}function ls(t){console.log(`
1
+ import{So,Wr,Vd,xi,wo,Ro}from"./chunk-0pe1dfy0.js";import{$e}from"./chunk-wctam3r1.js";import{execFileSync as A}from"node:child_process";import{mkdirSync as S,mkdtempSync as U,rmSync as L,writeFileSync as d}from"node:fs";import{tmpdir as O}from"node:os";import{dirname as j,join as s}from"node:path";var r={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m"};function I(t,e){return`${r[e]}${t}${r.reset}`}function An(t){console.log(`${r.green}✓${r.reset} ${t}`)}function bu(t){console.error(`${r.red}✗${r.reset} ${t}`)}function ds(t){console.warn(`${r.yellow}⚠${r.reset} ${t}`)}function k(t){console.log(`${r.blue}ℹ${r.reset} ${t}`)}function w(t){console.log(`${r.cyan}→${r.reset} ${t}`)}function ls(t){console.log(`
2
2
  ${r.bright}${r.cyan}${t}${r.reset}
3
3
  `)}var F=!!(process.env.CI||process.env.GITHUB_ACTIONS||process.env.BUILDKITE||process.env.CIRCLECI||process.env.GITLAB_CI);function vu(t,e="cyan"){let n=t.split(`
4
4
  `),i=Math.max(...n.map((l)=>l.length)),a="─".repeat(i+2);console.log(I(`┌${a}┐`,e)),n.forEach((l)=>{console.log(I(`│ ${l.padEnd(i)} │`,e))}),console.log(I(`└${a}┘`,e))}function R(t,e){for(let n of e){let i=s(t,n.name);S(j(i),{recursive:!0}),d(i,n.data,n.mode?{mode:n.mode}:void 0)}}async function Qa(t){let{app:e,projectRoot:n,region:i,repository:a}=t,l=e.architecture??"x86_64",P=l==="arm64"?"linux/arm64":"linux/amd64",E=e.kind==="php",c=t.onStep??(()=>{}),p=U(s(O(),"tscloud-img-"));try{let f=s(p,"app");S(f,{recursive:!0});let y,v;if(E){wo({projectRoot:n,app:e,skipBuild:t.skipBuild,onStep:c}),c("staging application tree");let o=Ro(n);R(f,o),R(s(p,"runtime"),xi().map((g)=>({name:g.path,data:g.contents,mode:g.mode})));let b=e.handlers?.http??"public/index.php";y={http:b,queue:e.handlers?.queue??b,cli:e.handlers?.cli??b},v=So(o.map((g)=>`${g.name}:${g.data.length}`).join("|"))}else{c("bundling application");let o=await Wr({projectRoot:n,app:e,skipBuild:t.skipBuild,onStep:c});d(s(f,"index.mjs"),o.bundle),y=o.handlers,v=o.sha256}let C=v.slice(0,16);d(s(p,"Dockerfile"),Vd({kind:e.kind??"node",phpVersion:e.phpVersion,architecture:l}));let x=new $e(i),u;try{u=(await x.describeRepositories({repositoryNames:[a]})).repositories?.[0]?.repositoryUri??""}catch{u=""}if(!u)c(`creating ECR repository ${a}`),u=(await x.createRepository({repositoryName:a,imageScanningConfiguration:{scanOnPush:!0}})).repository?.repositoryUri??"";if(!u)throw Error(`could not resolve ECR repository URI for ${a}`);let m=`${u}:${C}`;c("docker build"),A("docker",["build","--platform",P,"--provenance=false","--sbom=false","-t",m,p],{stdio:"inherit"}),c("ecr auth + push");let h=(await x.getAuthorizationToken()).authorizationData?.[0];if(!h?.authorizationToken||!h.proxyEndpoint)throw Error("failed to get an ECR authorization token");let T=h.proxyEndpoint.replace(/^https?:\/\//,""),B=s(p,".docker");return S(B,{recursive:!0}),d(s(B,"config.json"),JSON.stringify({auths:{[T]:{auth:h.authorizationToken}}})),A("docker",["push",m],{stdio:"inherit",env:{...process.env,DOCKER_CONFIG:B}}),k(`Image: ${m}`),{imageUri:m,tag:C,handlers:y}}finally{L(p,{recursive:!0,force:!0})}}
@@ -1,22 +1,22 @@
1
- import{pt,pi,gi,mi}from"./chunk-2mw7bjhn.js";function S(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function sf(t,e="/var/www"){let n=`${e}/${t}-`;return["set -u",`for TS_CLOUD_DIR in ${n}*; do`,' [ -d "$TS_CLOUD_DIR" ] || continue',' [ -d "$TS_CLOUD_DIR/releases" ] || continue',` TS_CLOUD_SITE="\${TS_CLOUD_DIR#${n}}"`," TS_CLOUD_ACTIVE=no",` for TS_CLOUD_UNIT in $(ls /etc/systemd/system/ 2>/dev/null | grep -E "^${S(t)}-$TS_CLOUD_SITE[-@.]" || true); do`,' systemctl is-active "$TS_CLOUD_UNIT" >/dev/null 2>&1 && TS_CLOUD_ACTIVE=yes'," done",' TS_CLOUD_SIZE="$(du -sh "$TS_CLOUD_DIR" 2>/dev/null | cut -f1)"',' echo "site:$TS_CLOUD_SITE:$TS_CLOUD_ACTIVE:${TS_CLOUD_SIZE:-?}"',"done","exit 0"]}function of(t){if(!t)return[];let e=[];for(let n of t.split(`
2
- `)){let r=n.trim();if(!r.startsWith("site:"))continue;let[,s,o,i]=r.split(":");if(!s||o!=="no")continue;e.push({name:s,size:i||"?"})}return e}function af(t,e,n){let r=t.map((o)=>` ${e}-${o.name} (${o.size})`).join(`
1
+ import{pt,pi,gi,mi}from"./chunk-nmm287ym.js";function S(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function of(t,e="/var/www"){let n=`${e}/${t}-`;return["set -u",`for TS_CLOUD_DIR in ${n}*; do`,' [ -d "$TS_CLOUD_DIR" ] || continue',' [ -d "$TS_CLOUD_DIR/releases" ] || continue',` TS_CLOUD_SITE="\${TS_CLOUD_DIR#${n}}"`," TS_CLOUD_ACTIVE=no",` for TS_CLOUD_UNIT in $(ls /etc/systemd/system/ 2>/dev/null | grep -E "^${S(t)}-$TS_CLOUD_SITE[-@.]" || true); do`,' systemctl is-active "$TS_CLOUD_UNIT" >/dev/null 2>&1 && TS_CLOUD_ACTIVE=yes'," done",' TS_CLOUD_SIZE="$(du -sh "$TS_CLOUD_DIR" 2>/dev/null | cut -f1)"',' echo "site:$TS_CLOUD_SITE:$TS_CLOUD_ACTIVE:${TS_CLOUD_SIZE:-?}"',"done","exit 0"]}function af(t){if(!t)return[];let e=[];for(let n of t.split(`
2
+ `)){let r=n.trim();if(!r.startsWith("site:"))continue;let[,s,o,i]=r.split(":");if(!s||o!=="no")continue;e.push({name:s,size:i||"?"})}return e}function cf(t,e,n){let r=t.map((o)=>` ${e}-${o.name} (${o.size})`).join(`
3
3
  `),s=t.length===1?"it":"them";return`This server still holds ${t.length} site tree${t.length===1?"":"s"} with nothing running for ${s}:
4
4
  ${r}
5
5
  `+"A site moved off this box keeps its files here on purpose — they are the rollback, and they are what makes "+`the move reversible until this server is destroyed. Destroying it now discards that.
6
- Verify the site is serving from its new home first, then re-run with ${n} to destroy it anyway.`}var yp="ts-cloud/project",Ip="ts-cloud/environment",Sp="ts-cloud/role";function d(t){return typeof t==="string"&&t.trim()?t.trim():void 0}function h(t){if(typeof t==="string")return d(t);if(t&&typeof t==="object")return d(t.name);return}function cf(t){let e={};for(let[n,r]of Object.entries(t?.labels??{}))if(typeof r==="string")e[n]=r;return{id:String(t?.id??""),name:d(t?.name)??"(unnamed)",status:d(t?.status)??"unknown",ipv4:d(t?.public_net?.ipv4?.ip)??d(t?.ipv4),ipv6:d(t?.public_net?.ipv6?.ip)??d(t?.ipv6),type:d(t?.server_type?.name)??d(t?.type),location:h(t?.location)??h(t?.datacenter?.location)??h(t?.datacenter),labels:e,project:d(e[yp]),environment:d(e[Ip]),role:d(e[Sp])}}function w(t){return t.slug?.trim()||"app"}function Cp(t){let e=[];for(let n of t){let r=w(n);for(let s of n.proxies??[]){let o=d(s?.to);if(!o)continue;e.push({slug:r,host:o,path:d(s?.path)??"/",...x(s)})}}return e.sort((n,r)=>n.slug.localeCompare(r.slug)||n.host.localeCompare(r.host)||n.path.localeCompare(r.path))}function x(t){let e=t?.from;if(typeof e==="string"&&e.trim())return{target:e.trim(),kind:"app"};if(Array.isArray(e)&&e.length>0)return{target:e.filter((s)=>typeof s==="string").join(", "),kind:"app"};let n=t?.static;if(typeof n==="string"&&n.trim())return{target:n.trim(),kind:"static"};if(n&&typeof n==="object"&&d(n.dir))return{target:d(n.dir),kind:"static"};let r=typeof t?.redirect==="string"?d(t.redirect):d(t?.redirect?.to);if(r)return{target:r,kind:"redirect"};return{target:"(no upstream)",kind:"unknown"}}function Ep(t){let e=new Map;for(let n of t){let r=e.get(n.slug);if(r)r.push(n);else e.set(n.slug,[n])}return[...e.entries()].map(([n,r])=>({slug:n,routes:r})).sort((n,r)=>r.routes.length-n.routes.length||n.slug.localeCompare(r.slug))}async function df(t,e,n=pt){if(!t.ipv4)return{server:t.name,routes:[],unavailable:"no public IPv4 address to reach it on"};if(t.status!=="running")return{server:t.name,ip:t.ipv4,routes:[],unavailable:`server is ${t.status}`};try{let r=await e(t.ipv4,gi(n));if(r.code!==0){let s=r.stderr.trim().split(`
7
- `)[0]||`remote command exited ${r.code}`;return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}return{server:t.name,ip:t.ipv4,routes:Cp(mi(r.stdout))}}catch(r){let s=r instanceof Error?r.message.split(`
8
- `)[0]:String(r);return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}}function u(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function lf(t,e,n){let r=new Set(e.filter((a)=>a.slug===n).map((a)=>u(a.host,a.path))),s=[],o=[],i=[];for(let a of t)if(a.loopbackOnly)i.push(a);else if(a.domain&&r.has(u(a.domain,a.path)))s.push(a);else o.push(a);return{present:s,absent:o,loopback:i,foreign:e.filter((a)=>a.slug!==n)}}function bp(t,e,n){let r=new Set;for(let s of e)for(let o of s.routes)if(o.slug===n)r.add(u(o.host,o.path));return t.filter((s)=>!s.loopbackOnly&&s.domain!==void 0&&!r.has(u(s.domain,s.path)))}function uf(t){let{slug:e,servers:n,probes:r,declared:s}=t,o=[];if(o.push(n.length===0?"No servers found.":`${n.length} server${n.length===1?"":"s"}:`),n.length>0)o.push("");let i=new Map(r.map((a)=>[a.server,a]));for(let a of n){let p=[a.ipv4,a.type,a.location,a.status].filter(Boolean);o.push(` ${a.name} ${p.join(" ")}`),o.push(` ${k(a)}`);let c=i.get(a.name);if(!c)o.push(" not probed, so co-tenants on this box are not listed");else if(c.unavailable)o.push(` could not read ${pt}: ${c.unavailable}`);else o.push(...P(c,e));o.push("")}return o.push(...C(t)),o}function k(t){if(!t.project)return"no ts-cloud labels: provisioned outside ts-cloud, or by a version that did not label boxes";let e=[t.environment,t.role&&`role ${t.role}`].filter(Boolean).join(", ");return`owned by '${t.project}'${e?` (${e})`:""}`}function P(t,e){let n=Ep(t.routes);if(n.length===0)return[` serves nothing: ${pt} is empty or absent`];let r=[` serves ${t.routes.length} route${t.routes.length===1?"":"s"} for ${n.length} project${n.length===1?"":"s"}:`];for(let s of n){r.push(` ${s.slug}${s.slug===e?" (this project)":""}`);for(let o of s.routes)r.push(` ${o.host}${o.path==="/"?"/":o.path} -> ${O(o)}`)}return r}function O(t){if(t.kind==="redirect")return`redirect to ${t.target}`;if(t.kind==="static")return`static ${t.target}`;return t.target}function C(t){let{slug:e,declared:n,probes:r,servers:s}=t;if(n.length===0)return[`This project ('${e}') declares no sites.`];let o=[`This project ('${e}') declares ${n.length} site${n.length===1?"":"s"}: `+n.map((c)=>c.name).join(", ")],i=n.filter((c)=>c.loopbackOnly);if(i.length>0)o.push(` ${i.length} with no domain, so the gateway never routes ${i.length===1?"it":"them"} (reached through another site's proxy): ${i.map((c)=>c.name).join(", ")}`);let a=r.filter((c)=>!c.unavailable);if(a.length===0)return o.push(" Nothing to reconcile them against: no box reported what it serves."),o;let p=bp(n,a,e);if(o.push(` ${n.length-i.length-p.length} routed by a box above`),p.length>0){o.push(` ${p.length} not routed by any box above: ${p.map((b)=>b.name).join(", ")}`);let c=r.length-a.length,g=s.length-r.length;if(c>0)o.push(` Either they were never deployed, or they are on one of the ${c} server${c===1?"":"s"} that could not be read.`);else if(g>0)o.push(` Either they were never deployed, or they are on one of the ${g} server${g===1?"":"s"} this run did not probe.`);else o.push(" Either they were never deployed, or they are on a server this listing did not cover.")}return o}async function pf(t){let e=[];for(let n of t.steps)try{e.push({step:n,state:await n.satisfied()?"satisfied":"pending"})}catch(r){e.push({step:n,state:"unknown",reason:r instanceof Error?r.message:String(r)})}return e}function xc(t){return t.filter((e)=>e.state!=="satisfied")}function vp(t){return xc(t).some((e)=>e.step.destructive===!0)}function gf(t,e){let n=xc(e),r=[`${t.operation} ${t.target}`];if(n.length===0)return r.push(" Nothing to do — every step is already satisfied."),r;for(let{step:o,state:i,reason:a}of e){let p=i==="satisfied"?"ok ":i==="unknown"?"? ":"→ ",c=[o.destructive?"DESTRUCTIVE":"",i==="satisfied"?"already done":""].filter(Boolean);if(r.push(` ${p}${o.title}${c.length>0?` [${c.join(", ")}]`:""}`),o.change)r.push(` ${o.change.from} → ${o.change.to}`);if(a)r.push(` could not check: ${a}`)}let s=n.filter((o)=>o.step.destructive).length;return r.push(` ${n.length} step(s) would run`+(s>0?`, ${s} irreversible — re-run with --confirm ${t.target}`:"")),r}async function mf(t,e,n={}){let r={operation:t.operation,target:t.target,steps:[],success:!0};if(vp(e)&&n.confirm!==t.target)throw Error(`${t.operation} includes an irreversible step. Re-run with --confirm ${t.target} to authorize it.`);for(let{step:s,state:o}of e){if(o==="satisfied"){r.steps.push({id:s.id,title:s.title,state:"skipped"}),n.log?.(`skip ${s.title} (already done)`);continue}n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"started"});try{await s.apply(),r.steps.push({id:s.id,title:s.title,state:"applied"}),n.log?.(`done ${s.title}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"applied"})}catch(i){let a=i instanceof Error?i.message:String(i);return r.steps.push({id:s.id,title:s.title,state:"failed",error:a}),r.success=!1,n.log?.(`FAIL ${s.title}: ${a}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"failed",error:a}),r}}return r}function Tp(t){if(t.length===0)throw Error("A server name cannot be empty.");if(t.length>253)throw Error(`'${t}' is longer than the 253 characters a hostname allows.`);for(let e of t.split(".")){if(e.length===0)throw Error(`'${t}' has an empty label — a hostname cannot contain '..'.`);if(e.length>63)throw Error(`'${e}' is longer than the 63 characters a hostname label allows.`);if(!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e))throw Error(`'${e}' is not a valid hostname label. Use letters, digits and hyphens, not starting or ending with a hyphen.`)}}async function hf(t,e,n){if(Tp(e),t===e)throw Error(`'${t}' is already named that.`);if((await n.takenNames()).some((o)=>o===e&&o!==t))throw Error(`'${e}' is already taken. Server names have to be unique within a provider project.`);let s=[];if(n.providerName&&n.renameProvider){let{providerName:o,renameProvider:i}=n;s.push({id:"provider",title:"Rename the server at the provider",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}if(n.stateName&&n.writeStateName){let{stateName:o,writeStateName:i}=n;s.push({id:"state-pin",title:"Update the recorded name in the local driver state",change:{from:t,to:e},satisfied:async()=>{let a=await o();return a===void 0||a===e},apply:()=>i(e)})}if(n.remoteHostname&&n.setRemoteHostname){let{remoteHostname:o,setRemoteHostname:i}=n;s.push({id:"hostname",title:"Set the hostname on the box",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}return s.push({id:"inventory",title:"Rename the fleet inventory record",change:{from:t,to:e},satisfied:async()=>n.inventoryName()===e,apply:async()=>{await n.renameInventory(e)}}),{operation:"server:rename",target:t,steps:s}}function ff(t){let e=`'${t.replace(/'/g,`'"'"'`)}'`;return["set -eu",'TS_CLOUD_OLD="$(hostname)"',`hostnamectl set-hostname ${e} 2>/dev/null || { echo ${e} > /etc/hostname && hostname ${e}; }`,'if grep -q "^127.0.1.1" /etc/hosts; then',` TS_CLOUD_HOSTS="$(sed -E "s/^127\\.0\\.1\\.1.*/127.0.1.1\\t${t}/" /etc/hosts)"`,` printf '%s\\n' "$TS_CLOUD_HOSTS" > /etc/hosts`,"else",` printf '127.0.1.1\\t%s\\n' ${e} >> /etc/hosts`,"fi",'printf "%s -> %s\\n" "$TS_CLOUD_OLD" "$(hostname)"'].join(`
9
- `)}function Af(t,e,n){let r=e.trim();if(!r)return{problem:"No server named."};let[s,...o]=t.filter((c)=>c.name===r);if(s&&o.length===0)return{server:s};let i=t.filter((c)=>c.project===r);if(i.length>1&&n)i=i.filter((c)=>!c.environment||c.environment===n);let[a,...p]=i;if(a&&p.length===0)return{server:a};if(i.length>1)return{problem:`'${r}' owns ${i.length} servers (${i.map((c)=>c.name).join(", ")}). Name one of them, or narrow it by environment.`};return{problem:`No server matched '${r}'. Nothing is named that, and no box carries the label ts-cloud/project=${r}.`}}function yf(t,e){let n=[];if(!e.project)n.push(`'${e.name}' carries no ts-cloud/project label, so it is not a box ts-cloud provisioned. Attaching to it would deploy into a host nothing manages.`);else if(e.project===t)n.push(`This project's slug is '${t}', which is also the slug that owns '${e.name}'. A tenant deploy owns the gateway fragment named after its slug, so attaching would overwrite '${e.project}'s own fragment and take its sites down. Change this project's slug first.`);if(e.status!=="running")n.push(`'${e.name}' is ${e.status}, so what it serves could not be read.`);if(!e.ipv4)n.push(`'${e.name}' has no public IPv4 address, so it cannot be reached to check what it serves.`);return n}function f(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function If(t,e,n){let r=[],s=pi(n.filter((i)=>i.kind==="app").map((i)=>({slug:i.slug,proxies:[{from:i.target.split(",").map((a)=>a.trim())}]})),{ignoreSlug:t}),o=new Map;for(let i of n)if(i.slug!==t)o.set(f(i.host,i.path),i.slug);for(let i of e){if(i.port!==void 0){let a=s.get(i.port);if(a)r.push({kind:"port",site:i.name,detail:`port ${i.port}`,heldBy:a})}if(i.domain){let a=o.get(f(i.domain,i.path));if(a)r.push({kind:"route",site:i.name,detail:`${i.domain}${i.path==="/"?"/":i.path}`,heldBy:a})}}return r}function Sf(t){return t.registryRead&&t.conflicts.length===0}function Cf(t){let{slug:e,owner:n,server:r,declared:s,conflicts:o}=t,i=[];i.push(`Attach '${e}' to '${r.name}' (${r.ipv4??"no IPv4"}), owned by '${n}'.`,""),i.push(` ${s.length} site${s.length===1?"":"s"} would deploy onto this box:`);for(let a of s){let p=a.loopbackOnly?`loopback only${a.port?` on :${a.port}`:""}`:`${a.domain}${a.path==="/"?"/":a.path}${a.port?` on :${a.port}`:""}`;i.push(` ${a.name} ${p} -> ${a.installBase??"(install path unresolved)"}`)}if(i.push(""),!t.registryRead)i.push(` Could not read what '${r.name}' already serves: ${t.registryProblem??"unknown reason"}`),i.push(" So this attach is UNCHECKED: a port or hostname already taken by another"),i.push(" project would not error, it would serve that project's site from your domain.");else if(o.length>0){i.push(` ${o.length} conflict${o.length===1?"":"s"} with what the box already serves:`);for(let a of o)i.push(` site '${a.site}' wants ${a.detail}, held by '${a.heldBy}'`);i.push(""),i.push(" Two services on one port do not error: the kernel load-balances, and each"),i.push(" domain serves the other's site about half the time. Pick free ports and"),i.push(" hostnames, then re-run.")}else i.push(` No conflicts with what '${r.name}' already serves.`);return i}function ui(t,e){return`/tmp/ts-cloud-move-${t}-${e}.tar.gz`}function Lc(t,e){return`${t}-${e}*.service`}function l(t){return`'${t.split("'").join("'\\''")}'`}function wp(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(m(t,e))} || true); do`,' systemctl stop "$unit" 2>/dev/null || true',"done"].join(`
10
- `)}function m(t,e){return`^${t}-${e}-((queue|daemon)-.*|scheduler)\\.service$`}function Rp(t,e){return y(m(t,e))}function y(t){return[`ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(t)} | while read -r unit; do`,' systemctl is-active "$unit" >/dev/null 2>&1 && echo "active:$unit" || true',"done"].join(`
11
- `)}function Dp(t){return!t.split(`
12
- `).some((e)=>e.trim().startsWith("active:"))}function Pp(t,e,n){let r=ui(t,e);return["set -eu",`test -d ${l(n)} || { echo "no site tree at ${n}" >&2; exit 1; }`,`rm -f ${l(r)}`,`tar czf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})" -C /etc/systemd/system $(cd /etc/systemd/system && ls ${Lc(t,e)} 2>/dev/null | tr '\\n' ' ')`,`sha256sum ${l(r)} | cut -d' ' -f1`].join(`
13
- `)}function Np(t,e,n){let r=ui(t,e);return["set -eu",`test -f ${l(r)} || { echo "archive not staged at ${r}" >&2; exit 1; }`,`mkdir -p "$(dirname ${l(n)})"`,`tar xzf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})"`,`tar xzf ${l(r)} -C /etc/systemd/system --wildcards ${l(Lc(t,e))} 2>/dev/null || true`,"systemctl daemon-reload",`systemctl enable ${t}-${e}.service 2>/dev/null || true`,`systemctl restart ${t}-${e}.service`,`rm -f ${l(r)}`].join(`
14
- `)}function kp(t,e,n){return[`test -d ${l(n)} && echo tree:present || echo tree:absent`,`systemctl is-active ${t}-${e}.service >/dev/null 2>&1 && echo unit:active || echo unit:inactive`].join(`
15
- `)}function Bp(t){return t.includes("tree:present")&&t.includes("unit:active")}function _p(t,e="/",n=10){let r=`http://127.0.0.1:${t}${e.startsWith("/")?e:`/${e}`}`;return["set -eu",`for i in $(seq 1 ${n}); do`,` if curl -fsS -o /dev/null --max-time 5 ${l(r)}; then echo healthy; exit 0; fi`," sleep 3","done",`echo "no healthy response from ${r}" >&2`,"exit 1"].join(`
16
- `)}function Op(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(v(t,e))} || true); do`,' systemctl disable --now "$unit" 2>/dev/null || true',"done",`rm -f /etc/rpx/sites.d/${t}.json 2>/dev/null || true`,"systemctl reload rpx-gateway.service 2>/dev/null || systemctl restart rpx-gateway.service 2>/dev/null || true"].join(`
17
- `)}function v(t,e){return`^${t}-${e}[-@.]`}function xp(t,e){return y(v(t,e))}function Lp(t){return!t.split(`
18
- `).some((e)=>e.trim().startsWith("active:"))}function Ef(t,e){return`/tmp/ts-cloud-move-${t}-${e}-certs.tar.gz`}function bf(t,e){return["set -u",...e.map((n)=>`if [ -s ${l(`${t}/${n}.crt`)} ]; then echo "cert:${n}:$(sha256sum ${l(`${t}/${n}.crt`)} | cut -d' ' -f1)"; else echo "cert:${n}:absent"; fi`)].join(`
19
- `)}function vf(t){let e=new Map;for(let n of t.split(`
20
- `)){let r=n.trim();if(!r.startsWith("cert:"))continue;let[,s,o]=r.split(":");if(s&&o)e.set(s,o)}return e}function Tf(t,e){for(let[n,r]of t){if(r==="absent")continue;if(e.get(n)!==r)return!1}return!0}function wf(t,e,n){let r=e.flatMap((s)=>[`${s}.crt`,`${s}.key`]);return["set -eu",`rm -f ${l(n)}`,`cd ${l(t)} 2>/dev/null || { echo "no certs dir at ${t}" >&2; exit 0; }`,`TS_CLOUD_CERTS="$(ls ${r.map(l).join(" ")} 2>/dev/null | tr '\\n' ' ' || true)"`,'[ -n "$TS_CLOUD_CERTS" ] || { echo "no certificates to carry"; exit 0; }',`tar czf ${l(n)} $TS_CLOUD_CERTS`].join(`
21
- `)}function Rf(t,e){return["set -eu",`[ -s ${l(e)} ] || { echo "no certificate archive staged"; exit 0; }`,`mkdir -p ${l(t)}`,`tar xzf ${l(e)} -C ${l(t)}`,`chmod 600 ${l(t)}/*.key 2>/dev/null || true`,`rm -f ${l(e)}`].join(`
22
- `)}async function Df(t,e){let{slug:n,siteName:r,appBase:s,from:o,to:i,targetAddress:a}=t;if(o===i)throw Error(`'${r}' is already on ${i}.`);if(t.database&&!e.database)throw Error(`'${r}' uses the on-box database '${t.database.name}', which lives in the engine's own data directory rather than in the site tree, and this move has no way to carry it. Moving the site without it would cut traffic over to an empty database.`);if(t.database&&e.database&&await e.database.targetHasData())throw Error(`${i} already has a database named '${t.database.name}' with tables in it. Restoring this site's dump over it would destroy that data. Rename or drop it on the target first, or point this project at a different database name.`);let p=[{id:"pause-workers",title:`Stop background work on ${o} so the snapshot is consistent`,satisfied:async()=>Dp(await e.runOnSource(Rp(n,r))),apply:async()=>{await e.runOnSource(wp(n,r))}},...e.database?[{id:"database-dump",title:`Dump the '${t.database?.name}' database on ${o}`,satisfied:async()=>!1,apply:()=>e.database.dump()}]:[],{id:"snapshot",title:`Archive the site's tree and units on ${o}`,change:{from:`${o}:${s}`,to:ui(n,r)},satisfied:async()=>!1,apply:async()=>{await e.runOnSource(Pp(n,r,s))}},{id:"transfer",title:`Carry the archive to ${i}`,change:{from:o,to:i},satisfied:()=>e.archiveStaged(),apply:()=>e.transferArchive()},...e.database?[{id:"database-transfer",title:`Carry the database dump to ${i}`,change:{from:o,to:i},satisfied:()=>e.database.dumpStaged(),apply:()=>e.database.transferDump()},{id:"database-restore",title:`Create and load '${t.database?.name}' on ${i}`,satisfied:async()=>!1,apply:()=>e.database.restore()}]:[],{id:"restore",title:`Unpack the site on ${i} and start it`,change:{from:ui(n,r),to:`${i}:${s}`},satisfied:async()=>Bp(await e.runOnTarget(kp(n,r,s))),apply:async()=>{await e.runOnTarget(Np(n,r,s))}}];if(t.port!=null){let{port:c}=t;p.push({id:"health",title:`Wait for the site to answer on ${i} (127.0.0.1:${c})`,satisfied:async()=>!1,apply:async()=>{await e.runOnTarget(_p(c,t.healthCheckPath??"/"))}})}return p.push(...e.certificates?[{id:"certificates",title:`Carry the site's TLS material to ${i}`,satisfied:()=>e.certificates.inPlace(),apply:()=>e.certificates.carry()}]:[],{id:"gateway",title:`Route the site on ${i}`,satisfied:()=>e.targetRoutesSite(),apply:()=>e.refreshTargetGateway()},{id:"dns",title:`Point DNS at ${i}`,change:{from:`${o}`,to:a},satisfied:async()=>await e.publishedAddress()===a,apply:async()=>{let c=await e.cutoverDns();if(c.length>0)throw Error(c.join("; "))}},{id:"drain-source",title:`Stop the site on ${o}, leaving its files in place`,satisfied:async()=>Lp(await e.runOnSource(xp(n,r))),apply:async()=>{await e.runOnSource(Op(n,r))}}),{operation:"site:move",target:r,steps:p}}export{sf,of,af,yp,Ip,Sp,cf,Cp,Ep,df,lf,bp,uf,pf,xc,vp,gf,mf,Tp,hf,ff,Af,yf,If,Sf,Cf,ui,Lc,wp,Rp,Dp,Pp,Np,kp,Bp,_p,Op,xp,Lp,Ef,bf,vf,Tf,wf,Rf,Df};
6
+ Verify the site is serving from its new home first, then re-run with ${n} to destroy it anyway.`}var Ip="ts-cloud/project",Sp="ts-cloud/environment",Cp="ts-cloud/role";function d(t){return typeof t==="string"&&t.trim()?t.trim():void 0}function h(t){if(typeof t==="string")return d(t);if(t&&typeof t==="object")return d(t.name);return}function df(t){let e={};for(let[n,r]of Object.entries(t?.labels??{}))if(typeof r==="string")e[n]=r;return{id:String(t?.id??""),name:d(t?.name)??"(unnamed)",status:d(t?.status)??"unknown",ipv4:d(t?.public_net?.ipv4?.ip)??d(t?.ipv4),ipv6:d(t?.public_net?.ipv6?.ip)??d(t?.ipv6),type:d(t?.server_type?.name)??d(t?.type),location:h(t?.location)??h(t?.datacenter?.location)??h(t?.datacenter),labels:e,project:d(e[Ip]),environment:d(e[Sp]),role:d(e[Cp])}}function w(t){return t.slug?.trim()||"app"}function Ep(t){let e=[];for(let n of t){let r=w(n);for(let s of n.proxies??[]){let o=d(s?.to);if(!o)continue;e.push({slug:r,host:o,path:d(s?.path)??"/",...x(s)})}}return e.sort((n,r)=>n.slug.localeCompare(r.slug)||n.host.localeCompare(r.host)||n.path.localeCompare(r.path))}function x(t){let e=t?.from;if(typeof e==="string"&&e.trim())return{target:e.trim(),kind:"app"};if(Array.isArray(e)&&e.length>0)return{target:e.filter((s)=>typeof s==="string").join(", "),kind:"app"};let n=t?.static;if(typeof n==="string"&&n.trim())return{target:n.trim(),kind:"static"};if(n&&typeof n==="object"&&d(n.dir))return{target:d(n.dir),kind:"static"};let r=typeof t?.redirect==="string"?d(t.redirect):d(t?.redirect?.to);if(r)return{target:r,kind:"redirect"};return{target:"(no upstream)",kind:"unknown"}}function bp(t){let e=new Map;for(let n of t){let r=e.get(n.slug);if(r)r.push(n);else e.set(n.slug,[n])}return[...e.entries()].map(([n,r])=>({slug:n,routes:r})).sort((n,r)=>r.routes.length-n.routes.length||n.slug.localeCompare(r.slug))}async function lf(t,e,n=pt){if(!t.ipv4)return{server:t.name,routes:[],unavailable:"no public IPv4 address to reach it on"};if(t.status!=="running")return{server:t.name,ip:t.ipv4,routes:[],unavailable:`server is ${t.status}`};try{let r=await e(t.ipv4,gi(n));if(r.code!==0){let s=r.stderr.trim().split(`
7
+ `)[0]||`remote command exited ${r.code}`;return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}return{server:t.name,ip:t.ipv4,routes:Ep(mi(r.stdout))}}catch(r){let s=r instanceof Error?r.message.split(`
8
+ `)[0]:String(r);return{server:t.name,ip:t.ipv4,routes:[],unavailable:s}}}function u(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function uf(t,e,n){let r=new Set(e.filter((a)=>a.slug===n).map((a)=>u(a.host,a.path))),s=[],o=[],i=[];for(let a of t)if(a.loopbackOnly)i.push(a);else if(a.domain&&r.has(u(a.domain,a.path)))s.push(a);else o.push(a);return{present:s,absent:o,loopback:i,foreign:e.filter((a)=>a.slug!==n)}}function vp(t,e,n){let r=new Set;for(let s of e)for(let o of s.routes)if(o.slug===n)r.add(u(o.host,o.path));return t.filter((s)=>!s.loopbackOnly&&s.domain!==void 0&&!r.has(u(s.domain,s.path)))}function pf(t){let{slug:e,servers:n,probes:r,declared:s}=t,o=[];if(o.push(n.length===0?"No servers found.":`${n.length} server${n.length===1?"":"s"}:`),n.length>0)o.push("");let i=new Map(r.map((a)=>[a.server,a]));for(let a of n){let p=[a.ipv4,a.type,a.location,a.status].filter(Boolean);o.push(` ${a.name} ${p.join(" ")}`),o.push(` ${k(a)}`);let c=i.get(a.name);if(!c)o.push(" not probed, so co-tenants on this box are not listed");else if(c.unavailable)o.push(` could not read ${pt}: ${c.unavailable}`);else o.push(...P(c,e));o.push("")}return o.push(...C(t)),o}function k(t){if(!t.project)return"no ts-cloud labels: provisioned outside ts-cloud, or by a version that did not label boxes";let e=[t.environment,t.role&&`role ${t.role}`].filter(Boolean).join(", ");return`owned by '${t.project}'${e?` (${e})`:""}`}function P(t,e){let n=bp(t.routes);if(n.length===0)return[` serves nothing: ${pt} is empty or absent`];let r=[` serves ${t.routes.length} route${t.routes.length===1?"":"s"} for ${n.length} project${n.length===1?"":"s"}:`];for(let s of n){r.push(` ${s.slug}${s.slug===e?" (this project)":""}`);for(let o of s.routes)r.push(` ${o.host}${o.path==="/"?"/":o.path} -> ${O(o)}`)}return r}function O(t){if(t.kind==="redirect")return`redirect to ${t.target}`;if(t.kind==="static")return`static ${t.target}`;return t.target}function C(t){let{slug:e,declared:n,probes:r,servers:s}=t;if(n.length===0)return[`This project ('${e}') declares no sites.`];let o=[`This project ('${e}') declares ${n.length} site${n.length===1?"":"s"}: `+n.map((c)=>c.name).join(", ")],i=n.filter((c)=>c.loopbackOnly);if(i.length>0)o.push(` ${i.length} with no domain, so the gateway never routes ${i.length===1?"it":"them"} (reached through another site's proxy): ${i.map((c)=>c.name).join(", ")}`);let a=r.filter((c)=>!c.unavailable);if(a.length===0)return o.push(" Nothing to reconcile them against: no box reported what it serves."),o;let p=vp(n,a,e);if(o.push(` ${n.length-i.length-p.length} routed by a box above`),p.length>0){o.push(` ${p.length} not routed by any box above: ${p.map((b)=>b.name).join(", ")}`);let c=r.length-a.length,g=s.length-r.length;if(c>0)o.push(` Either they were never deployed, or they are on one of the ${c} server${c===1?"":"s"} that could not be read.`);else if(g>0)o.push(` Either they were never deployed, or they are on one of the ${g} server${g===1?"":"s"} this run did not probe.`);else o.push(" Either they were never deployed, or they are on a server this listing did not cover.")}return o}async function gf(t){let e=[];for(let n of t.steps)try{e.push({step:n,state:await n.satisfied()?"satisfied":"pending"})}catch(r){e.push({step:n,state:"unknown",reason:r instanceof Error?r.message:String(r)})}return e}function xc(t){return t.filter((e)=>e.state!=="satisfied")}function Tp(t){return xc(t).some((e)=>e.step.destructive===!0)}function mf(t,e){let n=xc(e),r=[`${t.operation} ${t.target}`];if(n.length===0)return r.push(" Nothing to do — every step is already satisfied."),r;for(let{step:o,state:i,reason:a}of e){let p=i==="satisfied"?"ok ":i==="unknown"?"? ":"→ ",c=[o.destructive?"DESTRUCTIVE":"",i==="satisfied"?"already done":""].filter(Boolean);if(r.push(` ${p}${o.title}${c.length>0?` [${c.join(", ")}]`:""}`),o.change)r.push(` ${o.change.from} → ${o.change.to}`);if(a)r.push(` could not check: ${a}`)}let s=n.filter((o)=>o.step.destructive).length;return r.push(` ${n.length} step(s) would run`+(s>0?`, ${s} irreversible — re-run with --confirm ${t.target}`:"")),r}async function hf(t,e,n={}){let r={operation:t.operation,target:t.target,steps:[],success:!0};if(Tp(e)&&n.confirm!==t.target)throw Error(`${t.operation} includes an irreversible step. Re-run with --confirm ${t.target} to authorize it.`);for(let{step:s,state:o}of e){if(o==="satisfied"){r.steps.push({id:s.id,title:s.title,state:"skipped"}),n.log?.(`skip ${s.title} (already done)`);continue}n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"started"});try{await s.apply(),r.steps.push({id:s.id,title:s.title,state:"applied"}),n.log?.(`done ${s.title}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"applied"})}catch(i){let a=i instanceof Error?i.message:String(i);return r.steps.push({id:s.id,title:s.title,state:"failed",error:a}),r.success=!1,n.log?.(`FAIL ${s.title}: ${a}`),n.audit?.({operation:t.operation,target:t.target,step:s.id,state:"failed",error:a}),r}}return r}function wp(t){if(t.length===0)throw Error("A server name cannot be empty.");if(t.length>253)throw Error(`'${t}' is longer than the 253 characters a hostname allows.`);for(let e of t.split(".")){if(e.length===0)throw Error(`'${t}' has an empty label — a hostname cannot contain '..'.`);if(e.length>63)throw Error(`'${e}' is longer than the 63 characters a hostname label allows.`);if(!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(e))throw Error(`'${e}' is not a valid hostname label. Use letters, digits and hyphens, not starting or ending with a hyphen.`)}}async function ff(t,e,n){if(wp(e),t===e)throw Error(`'${t}' is already named that.`);if((await n.takenNames()).some((o)=>o===e&&o!==t))throw Error(`'${e}' is already taken. Server names have to be unique within a provider project.`);let s=[];if(n.providerName&&n.renameProvider){let{providerName:o,renameProvider:i}=n;s.push({id:"provider",title:"Rename the server at the provider",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}if(n.stateName&&n.writeStateName){let{stateName:o,writeStateName:i}=n;s.push({id:"state-pin",title:"Update the recorded name in the local driver state",change:{from:t,to:e},satisfied:async()=>{let a=await o();return a===void 0||a===e},apply:()=>i(e)})}if(n.remoteHostname&&n.setRemoteHostname){let{remoteHostname:o,setRemoteHostname:i}=n;s.push({id:"hostname",title:"Set the hostname on the box",change:{from:t,to:e},satisfied:async()=>await o()===e,apply:()=>i(e)})}return s.push({id:"inventory",title:"Rename the fleet inventory record",change:{from:t,to:e},satisfied:async()=>n.inventoryName()===e,apply:async()=>{await n.renameInventory(e)}}),{operation:"server:rename",target:t,steps:s}}function Af(t){let e=`'${t.replace(/'/g,`'"'"'`)}'`;return["set -eu",'TS_CLOUD_OLD="$(hostname)"',`hostnamectl set-hostname ${e} 2>/dev/null || { echo ${e} > /etc/hostname && hostname ${e}; }`,'if grep -q "^127.0.1.1" /etc/hosts; then',` TS_CLOUD_HOSTS="$(sed -E "s/^127\\.0\\.1\\.1.*/127.0.1.1\\t${t}/" /etc/hosts)"`,` printf '%s\\n' "$TS_CLOUD_HOSTS" > /etc/hosts`,"else",` printf '127.0.1.1\\t%s\\n' ${e} >> /etc/hosts`,"fi",'printf "%s -> %s\\n" "$TS_CLOUD_OLD" "$(hostname)"'].join(`
9
+ `)}function yf(t,e,n){let r=e.trim();if(!r)return{problem:"No server named."};let[s,...o]=t.filter((c)=>c.name===r);if(s&&o.length===0)return{server:s};let i=t.filter((c)=>c.project===r);if(i.length>1&&n)i=i.filter((c)=>!c.environment||c.environment===n);let[a,...p]=i;if(a&&p.length===0)return{server:a};if(i.length>1)return{problem:`'${r}' owns ${i.length} servers (${i.map((c)=>c.name).join(", ")}). Name one of them, or narrow it by environment.`};return{problem:`No server matched '${r}'. Nothing is named that, and no box carries the label ts-cloud/project=${r}.`}}function If(t,e){let n=[];if(!e.project)n.push(`'${e.name}' carries no ts-cloud/project label, so it is not a box ts-cloud provisioned. Attaching to it would deploy into a host nothing manages.`);else if(e.project===t)n.push(`This project's slug is '${t}', which is also the slug that owns '${e.name}'. A tenant deploy owns the gateway fragment named after its slug, so attaching would overwrite '${e.project}'s own fragment and take its sites down. Change this project's slug first.`);if(e.status!=="running")n.push(`'${e.name}' is ${e.status}, so what it serves could not be read.`);if(!e.ipv4)n.push(`'${e.name}' has no public IPv4 address, so it cannot be reached to check what it serves.`);return n}function f(t,e){let n=e==="/"?"/":e.replace(/\/+$/,"");return`${t.toLowerCase()}${n||"/"}`}function Sf(t,e,n){let r=[],s=pi(n.filter((i)=>i.kind==="app").map((i)=>({slug:i.slug,proxies:[{from:i.target.split(",").map((a)=>a.trim())}]})),{ignoreSlug:t}),o=new Map;for(let i of n)if(i.slug!==t)o.set(f(i.host,i.path),i.slug);for(let i of e){if(i.port!==void 0){let a=s.get(i.port);if(a)r.push({kind:"port",site:i.name,detail:`port ${i.port}`,heldBy:a})}if(i.domain){let a=o.get(f(i.domain,i.path));if(a)r.push({kind:"route",site:i.name,detail:`${i.domain}${i.path==="/"?"/":i.path}`,heldBy:a})}}return r}function Cf(t){return t.registryRead&&t.conflicts.length===0}function Ef(t){let{slug:e,owner:n,server:r,declared:s,conflicts:o}=t,i=[];i.push(`Attach '${e}' to '${r.name}' (${r.ipv4??"no IPv4"}), owned by '${n}'.`,""),i.push(` ${s.length} site${s.length===1?"":"s"} would deploy onto this box:`);for(let a of s){let p=a.loopbackOnly?`loopback only${a.port?` on :${a.port}`:""}`:`${a.domain}${a.path==="/"?"/":a.path}${a.port?` on :${a.port}`:""}`;i.push(` ${a.name} ${p} -> ${a.installBase??"(install path unresolved)"}`)}if(i.push(""),!t.registryRead)i.push(` Could not read what '${r.name}' already serves: ${t.registryProblem??"unknown reason"}`),i.push(" So this attach is UNCHECKED: a port or hostname already taken by another"),i.push(" project would not error, it would serve that project's site from your domain.");else if(o.length>0){i.push(` ${o.length} conflict${o.length===1?"":"s"} with what the box already serves:`);for(let a of o)i.push(` site '${a.site}' wants ${a.detail}, held by '${a.heldBy}'`);i.push(""),i.push(" Two services on one port do not error: the kernel load-balances, and each"),i.push(" domain serves the other's site about half the time. Pick free ports and"),i.push(" hostnames, then re-run.")}else i.push(` No conflicts with what '${r.name}' already serves.`);return i}function ui(t,e){return`/tmp/ts-cloud-move-${t}-${e}.tar.gz`}function Lc(t,e){return`${t}-${e}*.service`}function l(t){return`'${t.split("'").join("'\\''")}'`}function Rp(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(m(t,e))} || true); do`,' systemctl stop "$unit" 2>/dev/null || true',"done"].join(`
10
+ `)}function m(t,e){return`^${t}-${e}-((queue|daemon)-.*|scheduler)\\.service$`}function Dp(t,e){return y(m(t,e))}function y(t){return[`ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(t)} | while read -r unit; do`,' systemctl is-active "$unit" >/dev/null 2>&1 && echo "active:$unit" || true',"done"].join(`
11
+ `)}function Pp(t){return!t.split(`
12
+ `).some((e)=>e.trim().startsWith("active:"))}function Np(t,e,n){let r=ui(t,e);return["set -eu",`test -d ${l(n)} || { echo "no site tree at ${n}" >&2; exit 1; }`,`rm -f ${l(r)}`,`tar czf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})" -C /etc/systemd/system $(cd /etc/systemd/system && ls ${Lc(t,e)} 2>/dev/null | tr '\\n' ' ')`,`sha256sum ${l(r)} | cut -d' ' -f1`].join(`
13
+ `)}function kp(t,e,n){let r=ui(t,e);return["set -eu",`test -f ${l(r)} || { echo "archive not staged at ${r}" >&2; exit 1; }`,`mkdir -p "$(dirname ${l(n)})"`,`tar xzf ${l(r)} -C "$(dirname ${l(n)})" "$(basename ${l(n)})"`,`tar xzf ${l(r)} -C /etc/systemd/system --wildcards ${l(Lc(t,e))} 2>/dev/null || true`,"systemctl daemon-reload",`systemctl enable ${t}-${e}.service 2>/dev/null || true`,`systemctl restart ${t}-${e}.service`,`rm -f ${l(r)}`].join(`
14
+ `)}function Bp(t,e,n){return[`test -d ${l(n)} && echo tree:present || echo tree:absent`,`systemctl is-active ${t}-${e}.service >/dev/null 2>&1 && echo unit:active || echo unit:inactive`].join(`
15
+ `)}function _p(t){return t.includes("tree:present")&&t.includes("unit:active")}function Op(t,e="/",n=10){let r=`http://127.0.0.1:${t}${e.startsWith("/")?e:`/${e}`}`;return["set -eu",`for i in $(seq 1 ${n}); do`,` if curl -fsS -o /dev/null --max-time 5 ${l(r)}; then echo healthy; exit 0; fi`," sleep 3","done",`echo "no healthy response from ${r}" >&2`,"exit 1"].join(`
16
+ `)}function xp(t,e){return["set -eu",`for unit in $(ls /etc/systemd/system/ 2>/dev/null | grep -E ${l(v(t,e))} || true); do`,' systemctl disable --now "$unit" 2>/dev/null || true',"done",`rm -f /etc/rpx/sites.d/${t}.json 2>/dev/null || true`,"systemctl reload rpx-gateway.service 2>/dev/null || systemctl restart rpx-gateway.service 2>/dev/null || true"].join(`
17
+ `)}function v(t,e){return`^${t}-${e}[-@.]`}function Lp(t,e){return y(v(t,e))}function $p(t){return!t.split(`
18
+ `).some((e)=>e.trim().startsWith("active:"))}function bf(t,e){return`/tmp/ts-cloud-move-${t}-${e}-certs.tar.gz`}function vf(t,e){return["set -u",...e.map((n)=>`if [ -s ${l(`${t}/${n}.crt`)} ]; then echo "cert:${n}:$(sha256sum ${l(`${t}/${n}.crt`)} | cut -d' ' -f1)"; else echo "cert:${n}:absent"; fi`)].join(`
19
+ `)}function Tf(t){let e=new Map;for(let n of t.split(`
20
+ `)){let r=n.trim();if(!r.startsWith("cert:"))continue;let[,s,o]=r.split(":");if(s&&o)e.set(s,o)}return e}function wf(t,e){for(let[n,r]of t){if(r==="absent")continue;if(e.get(n)!==r)return!1}return!0}function Rf(t,e,n){let r=e.flatMap((s)=>[`${s}.crt`,`${s}.key`]);return["set -eu",`rm -f ${l(n)}`,`cd ${l(t)} 2>/dev/null || { echo "no certs dir at ${t}" >&2; exit 0; }`,`TS_CLOUD_CERTS="$(ls ${r.map(l).join(" ")} 2>/dev/null | tr '\\n' ' ' || true)"`,'[ -n "$TS_CLOUD_CERTS" ] || { echo "no certificates to carry"; exit 0; }',`tar czf ${l(n)} $TS_CLOUD_CERTS`].join(`
21
+ `)}function Df(t,e){return["set -eu",`[ -s ${l(e)} ] || { echo "no certificate archive staged"; exit 0; }`,`mkdir -p ${l(t)}`,`tar xzf ${l(e)} -C ${l(t)}`,`chmod 600 ${l(t)}/*.key 2>/dev/null || true`,`rm -f ${l(e)}`].join(`
22
+ `)}async function Pf(t,e){let{slug:n,siteName:r,appBase:s,from:o,to:i,targetAddress:a}=t;if(o===i)throw Error(`'${r}' is already on ${i}.`);if(t.database&&!e.database)throw Error(`'${r}' uses the on-box database '${t.database.name}', which lives in the engine's own data directory rather than in the site tree, and this move has no way to carry it. Moving the site without it would cut traffic over to an empty database.`);if(t.database&&e.database&&await e.database.targetHasData())throw Error(`${i} already has a database named '${t.database.name}' with tables in it. Restoring this site's dump over it would destroy that data. Rename or drop it on the target first, or point this project at a different database name.`);let p=[{id:"pause-workers",title:`Stop background work on ${o} so the snapshot is consistent`,satisfied:async()=>Pp(await e.runOnSource(Dp(n,r))),apply:async()=>{await e.runOnSource(Rp(n,r))}},...e.database?[{id:"database-dump",title:`Dump the '${t.database?.name}' database on ${o}`,satisfied:async()=>!1,apply:()=>e.database.dump()}]:[],{id:"snapshot",title:`Archive the site's tree and units on ${o}`,change:{from:`${o}:${s}`,to:ui(n,r)},satisfied:async()=>!1,apply:async()=>{await e.runOnSource(Np(n,r,s))}},{id:"transfer",title:`Carry the archive to ${i}`,change:{from:o,to:i},satisfied:()=>e.archiveStaged(),apply:()=>e.transferArchive()},...e.database?[{id:"database-transfer",title:`Carry the database dump to ${i}`,change:{from:o,to:i},satisfied:()=>e.database.dumpStaged(),apply:()=>e.database.transferDump()},{id:"database-restore",title:`Create and load '${t.database?.name}' on ${i}`,satisfied:async()=>!1,apply:()=>e.database.restore()}]:[],{id:"restore",title:`Unpack the site on ${i} and start it`,change:{from:ui(n,r),to:`${i}:${s}`},satisfied:async()=>_p(await e.runOnTarget(Bp(n,r,s))),apply:async()=>{await e.runOnTarget(kp(n,r,s))}}];if(t.port!=null){let{port:c}=t;p.push({id:"health",title:`Wait for the site to answer on ${i} (127.0.0.1:${c})`,satisfied:async()=>!1,apply:async()=>{await e.runOnTarget(Op(c,t.healthCheckPath??"/"))}})}return p.push(...e.certificates?[{id:"certificates",title:`Carry the site's TLS material to ${i}`,satisfied:()=>e.certificates.inPlace(),apply:()=>e.certificates.carry()}]:[],{id:"gateway",title:`Route the site on ${i}`,satisfied:()=>e.targetRoutesSite(),apply:()=>e.refreshTargetGateway()},{id:"dns",title:`Point DNS at ${i}`,change:{from:`${o}`,to:a},satisfied:async()=>await e.publishedAddress()===a,apply:async()=>{let c=await e.cutoverDns();if(c.length>0)throw Error(c.join("; "))}},{id:"drain-source",title:`Stop the site on ${o}, leaving its files in place`,satisfied:async()=>$p(await e.runOnSource(Lp(n,r))),apply:async()=>{await e.runOnSource(xp(n,r))}}),{operation:"site:move",target:r,steps:p}}export{of,af,cf,Ip,Sp,Cp,df,Ep,bp,lf,uf,vp,pf,gf,xc,Tp,mf,hf,wp,ff,Af,yf,If,Sf,Cf,Ef,ui,Lc,Rp,Dp,Pp,Np,kp,Bp,_p,Op,xp,Lp,$p,bf,vf,Tf,wf,Rf,Df,Pf};
@@ -1 +1 @@
1
- import{cn,dn,Zl,Yi,eu,tu,ru,Ca,nu,iu,fh,su,E,ou,Zi,_e,au,cu,Ty,du,lu,uu,pu,gu,Ah,wy,Ry,Dy,yh,Ih,Py,Ny,Sh,Ch,ky,es,rr,Ea,ln,un,nr,tt,Tt,ts,Eh,pn,mu,hu,ba,ns,mn,is,$a}from"../chunk-xbh2vr95.js";import{Ma,hn,fn,ss,os,as,cs,Fa,Ua}from"../chunk-57fhsqzb.js";import{Qa}from"../chunk-jh38v9zp.js";import"../chunk-t1gts5j9.js";import"../chunk-efssa93f.js";import"../chunk-s909414m.js";import"../chunk-dm4vt53n.js";import"../chunk-4hdp9ms2.js";import"../chunk-qjxdhb8x.js";import"../chunk-ffxcn7mw.js";import{Bu,ic,Ce,sc,Nn,_u,oc,Pc,xs,Nc,Lt,oi,Ls}from"../chunk-peeqkk92.js";import"../chunk-9g8as6sa.js";import"../chunk-wbabf3hg.js";import"../chunk-qrs912nk.js";import"../chunk-m93g67j0.js";import{pt,Pf,$c,pi,gi,mi,$p}from"../chunk-2mw7bjhn.js";import{O,Pr,Nr,Mc,Fs,u,Nf,Mp,Fp,cI,dI}from"../chunk-kavwrxm8.js";import"../chunk-nq51dyxz.js";import"../chunk-r45340yc.js";export{Pf as DEFAULT_SITE_PORT_RANGE,pt as HOST_SITES_DIR,sc as IPV6_EXCLUDED_HOST_LABELS,Pc as MANAGEMENT_DASHBOARD_SITE,cn as addSiteToCloudConfig,$p as allocateSitePorts,ky as buildAndPushContainerImage,Qa as buildAndPushServerlessImage,rr as buildFunctionEnv,gi as buildHostSitePortsScript,Ls as buildManagementDashboardArtifact,Tt as buildServerTopology,ts as buildServerlessTopology,Eh as buildTopology,ba as collectEgressMetrics,Bu as collectServerDnsDomains,Ch as createContainerImageDependencies,yh as createExistingStaticFullStackDependencies,Ah as createStaticApiOriginDependencies,mn as dashboardActions,xs as dashboardCredentialsFile,au as dashboardPageRoutes,pu as deleteFailoverReplicaBuckets,Fa as deleteStaticSite,Py as deployExistingStaticFullStack,Ea as deployServerlessApp,dI as deployShipsFiles,gu as deploySite,wy as deployStaticApiOrigin,os as deployStaticSite,Ua as deployStaticSiteFull,hn as deployStaticSiteWithExternalDns,fn as deployStaticSiteWithExternalDnsFull,mu as egressReportMetrics,E as ensureDashboardActor,du as ensureFailoverReplicaBuckets,oi as ensureManagementDashboard,Ny as estimateExistingStaticFullStackMonthlyCost,Dy as estimateStaticApiOriginMonthlyCost,hu as fetchEgressReport,Ih as generateExistingStaticFullStackTemplate,Ma as generateExternalDnsStaticSiteTemplate,ss as generateStaticSiteTemplate,lu as grantFailoverReplicaAccess,Nf as hasComputeConfigured,Mc as hasProxyUpstream,Sh as hashContainerContext,Nn as hostAcceptsIpv6,es as infraEnvFromOutputs,ou as initializeDashboardControlPlane,cs as invalidateCache,Pr as isPhpSite,Ca as isValidHostname,Ce as normalizePublicIpv6,pi as occupiedHostPorts,mi as parseHostSiteFragments,$c as parseUpstreamPort,_u as reconcileAddressRecords,ln as redeployServerlessApp,dn as removeSiteFromCloudConfig,ic as removeStaleServerAddressRecords,nu as renderAliasesValue,ru as renderEnvValue,iu as renderRedirectsValue,fh as renderSiteSnippet,eu as renderSslValue,tu as renderStringValue,is as resolveDashboardAction,Nc as resolveDashboardAuth,pn as resolveDashboardData,cu as resolveLegacyDashboardRoute,Nr as resolveProxyUpstreams,Fs as resolveSiteDeployTarget,u as resolveSiteKind,Lt as resolveUiSource,un as rollbackServerlessApp,Ty as routesForDashboard,tt as runRemoteCommand,ns as sanitizeCloudConfig,uu as seedFailoverReplicas,su as setAttachToInCloudConfig,nr as setMaintenance,Yi as setSitePropertyInCloudConfig,Fp as shipsARelease,cI as shipsToBucket,O as siteInstallBase,$a as startLocalDashboardServer,Zi as synchronizeDashboardUsers,_e as trackDashboardOperation,Zl as updateSiteInCloudConfig,as as uploadStaticFiles,Mp as validateDeploymentConfig,oc as verifyAddressRecord,Ry as verifyStaticApiOrigin};
1
+ import{cn,dn,Zl,Yi,eu,tu,ru,Ca,nu,iu,Ah,su,E,ou,Zi,_e,au,cu,wy,du,lu,uu,pu,gu,yh,Ry,Dy,Py,Ih,Sh,Ny,ky,Ch,Eh,By,es,rr,Ea,ln,un,nr,tt,Tt,ts,bh,pn,mu,hu,ba,ns,mn,is,$a}from"../chunk-c4kferxw.js";import{Ma,hn,fn,ss,os,as,cs,Fa,Ua}from"../chunk-444h366b.js";import{Qa}from"../chunk-y3dj8xwk.js";import"../chunk-qad1mjmc.js";import"../chunk-k3azr9e3.js";import"../chunk-pkpmz35j.js";import"../chunk-wctam3r1.js";import"../chunk-m1jp1abp.js";import"../chunk-n4gkyye3.js";import"../chunk-c6nw88s3.js";import{Bu,ic,Ce,sc,Nn,_u,oc,Pc,xs,Nc,Lt,oi,Ls}from"../chunk-29dcfx1g.js";import"../chunk-jp57js5y.js";import"../chunk-v1wqxgra.js";import"../chunk-45116tdd.js";import"../chunk-g3f3ccdw.js";import{pt,Nf,$c,pi,gi,mi,Mp}from"../chunk-nmm287ym.js";import{O,Pr,Nr,Mc,Fs,u,kf,Fp,Up,dI,lI}from"../chunk-6n72pe9x.js";import"../chunk-9r32w840.js";import"../chunk-0pe1dfy0.js";export{Nf as DEFAULT_SITE_PORT_RANGE,pt as HOST_SITES_DIR,sc as IPV6_EXCLUDED_HOST_LABELS,Pc as MANAGEMENT_DASHBOARD_SITE,cn as addSiteToCloudConfig,Mp as allocateSitePorts,By as buildAndPushContainerImage,Qa as buildAndPushServerlessImage,rr as buildFunctionEnv,gi as buildHostSitePortsScript,Ls as buildManagementDashboardArtifact,Tt as buildServerTopology,ts as buildServerlessTopology,bh as buildTopology,ba as collectEgressMetrics,Bu as collectServerDnsDomains,Eh as createContainerImageDependencies,Ih as createExistingStaticFullStackDependencies,yh as createStaticApiOriginDependencies,mn as dashboardActions,xs as dashboardCredentialsFile,au as dashboardPageRoutes,pu as deleteFailoverReplicaBuckets,Fa as deleteStaticSite,Ny as deployExistingStaticFullStack,Ea as deployServerlessApp,lI as deployShipsFiles,gu as deploySite,Ry as deployStaticApiOrigin,os as deployStaticSite,Ua as deployStaticSiteFull,hn as deployStaticSiteWithExternalDns,fn as deployStaticSiteWithExternalDnsFull,mu as egressReportMetrics,E as ensureDashboardActor,du as ensureFailoverReplicaBuckets,oi as ensureManagementDashboard,ky as estimateExistingStaticFullStackMonthlyCost,Py as estimateStaticApiOriginMonthlyCost,hu as fetchEgressReport,Sh as generateExistingStaticFullStackTemplate,Ma as generateExternalDnsStaticSiteTemplate,ss as generateStaticSiteTemplate,lu as grantFailoverReplicaAccess,kf as hasComputeConfigured,Mc as hasProxyUpstream,Ch as hashContainerContext,Nn as hostAcceptsIpv6,es as infraEnvFromOutputs,ou as initializeDashboardControlPlane,cs as invalidateCache,Pr as isPhpSite,Ca as isValidHostname,Ce as normalizePublicIpv6,pi as occupiedHostPorts,mi as parseHostSiteFragments,$c as parseUpstreamPort,_u as reconcileAddressRecords,ln as redeployServerlessApp,dn as removeSiteFromCloudConfig,ic as removeStaleServerAddressRecords,nu as renderAliasesValue,ru as renderEnvValue,iu as renderRedirectsValue,Ah as renderSiteSnippet,eu as renderSslValue,tu as renderStringValue,is as resolveDashboardAction,Nc as resolveDashboardAuth,pn as resolveDashboardData,cu as resolveLegacyDashboardRoute,Nr as resolveProxyUpstreams,Fs as resolveSiteDeployTarget,u as resolveSiteKind,Lt as resolveUiSource,un as rollbackServerlessApp,wy as routesForDashboard,tt as runRemoteCommand,ns as sanitizeCloudConfig,uu as seedFailoverReplicas,su as setAttachToInCloudConfig,nr as setMaintenance,Yi as setSitePropertyInCloudConfig,Up as shipsARelease,dI as shipsToBucket,O as siteInstallBase,$a as startLocalDashboardServer,Zi as synchronizeDashboardUsers,_e as trackDashboardOperation,Zl as updateSiteInCloudConfig,as as uploadStaticFiles,Fp as validateDeploymentConfig,oc as verifyAddressRecord,Dy as verifyStaticApiOrigin};
package/dist/dns/index.js CHANGED
@@ -1 +1 @@
1
- import{ot,ce,Me,Se,kt,Rn,fs,As,lr,ur,Dn,pr,ys,Is,Ss,Cs,W,Es,bs,vs,Ts,de,ws,Rs,Ds,R,rc,Pn,nc}from"../chunk-qjxdhb8x.js";import"../chunk-ffxcn7mw.js";import"../chunk-m93g67j0.js";export{Se as CloudflareProvider,Pn as DnsProviderFactory,Me as GoDaddyProvider,ot as PROXIABLE_RECORD_TYPES,ce as PorkbunProvider,W as Route53Provider,de as UnifiedDnsValidator,Ss as applyDeclaredZoneSettings,vs as applyZoneMigration,R as createDnsProvider,Rs as createGoDaddyValidator,ws as createPorkbunValidator,Ds as createRoute53Validator,pr as delegateZone,ys as delegateZoneFromConfig,Is as describeDelegation,Cs as describeZoneSettings,rc as detectDnsProvider,nc as dnsProviders,Es as exportRoute53Zone,lr as isNameserverRegistrar,ur as isZoneHost,bs as planZoneMigration,kt as policyTag,Rn as qualifyName,As as reconcileDeclaredRecords,fs as resolveDeclaredRecords,Dn as sameNameservers,Ts as verifyZoneParity};
1
+ import{ot,ce,Me,Se,kt,Rn,fs,As,lr,ur,Dn,pr,ys,Is,Ss,Cs,W,Es,bs,vs,Ts,de,ws,Rs,Ds,R,rc,Pn,nc}from"../chunk-n4gkyye3.js";import"../chunk-c6nw88s3.js";import"../chunk-g3f3ccdw.js";export{Se as CloudflareProvider,Pn as DnsProviderFactory,Me as GoDaddyProvider,ot as PROXIABLE_RECORD_TYPES,ce as PorkbunProvider,W as Route53Provider,de as UnifiedDnsValidator,Ss as applyDeclaredZoneSettings,vs as applyZoneMigration,R as createDnsProvider,Rs as createGoDaddyValidator,ws as createPorkbunValidator,Ds as createRoute53Validator,pr as delegateZone,ys as delegateZoneFromConfig,Is as describeDelegation,Cs as describeZoneSettings,rc as detectDnsProvider,nc as dnsProviders,Es as exportRoute53Zone,lr as isNameserverRegistrar,ur as isZoneHost,bs as planZoneMigration,kt as policyTag,Rn as qualifyName,As as reconcileDeclaredRecords,fs as resolveDeclaredRecords,Dn as sameNameservers,Ts as verifyZoneParity};
@@ -1 +1 @@
1
- import{kn,Bt,mr,_t,Bn,_n,On,xn,$u,ac,J,Ar,Mh,Ln,cc,Ee,be,Fe,B,yr,$n,Ir,ue,dc,Mn,lc,Un,uc,Sr,Fh,Uh,Fu,Uu,Qh,Hh,Gh,Cr,Qn,Qu,ks,Hn,Gn,qn,Vn,jn,pc,gc,Er,hc,Ue,X,fc,at,Qe,He,ct,ve,Bs,Ac,Hu,Gu,yc,qu,dt,zn,Ic,Vu,ju,Sc,br,Te,Cc,zu,Ku,_s,Kn,lt,Wu,Ju,Xu,Yu,Zu,ep,tp,rp,np,Wn,Jn,Xn,Yn,Zn,ei,ti,ip,sp,vr,_,Os,op,ap,cp,Ec,dp,lp,qh,bc,Vh,jh,up,pp,zh,Kh,Wh,vc,gp,Jh,Xh,Yh,ri,ni,ii,si,Tc,wc,Rc,Dc,Zh,$s,kc,ai,Bc,mp,hp,fp,ef}from"../chunk-peeqkk92.js";import"../chunk-9g8as6sa.js";import"../chunk-wbabf3hg.js";import"../chunk-qrs912nk.js";import"../chunk-m93g67j0.js";import"../chunk-kavwrxm8.js";import"../chunk-r45340yc.js";export{Dc as AwsBoxProvisioner,yr as AwsDriver,cp as BOOT_PARTITION_LABEL,Os as CloudDriverFactory,Uu as DEFAULT_HOST_CLEANUP_ESCALATED,Hh as DEFAULT_HOST_CLEANUP_HIGH_WATER_PERCENT,Qh as DEFAULT_HOST_CLEANUP_LOW_WATER_PERCENT,Fu as DEFAULT_HOST_CLEANUP_RETENTION,Gh as DEFAULT_HOST_CLEANUP_SCHEDULE,_n as DEFAULT_RPX_CERTS_DIR,ap as FIRST_BOOT_SCRIPT_PATH,Sr as HOST_ARTIFACT_CACHE_DIR,Fh as HOST_CLEANUP_SCRIPT_PATH,Uh as HOST_CLEANUP_UNIT,Rc as HetznerBoxProvisioner,Er as HetznerClient,ve as HetznerDriver,fc as LEGACY_DRIVER_STATE_DIR,Bs as LocalBoxDriver,hp as MANAGED_CACHE_POLICY_DISABLED,mp as MANAGED_CACHE_POLICY_OPTIMIZED,fp as MANAGED_ORIGIN_REQUEST_POLICY_ALL_VIEWER,Ku as RASPBERRY_PI_DEFAULT_SWAP_GB,uc as REMOTE_SCRIPT_RUNNER,Ln as RPX_DIR,cc as RPX_LAUNCHER_PATH,Ee as RPX_SERVICE_NAME,Cc as SSH_BOOTSTRAP_MARKER_DIR,Te as SSH_BOOTSTRAP_VERSION,lt as SSH_DEFAULTS,ti as SSH_DEPLOY_STORAGE_PATH,Hu as SSH_INSECURE_HOST_KEY_OPTS,Gu as SSH_KEEPALIVE_OPTS,Jn as SSH_PREFLIGHT_SCRIPT,ip as SSH_SKIP_BOOTSTRAP_ENV,vr as SshDriver,br as SystemSshTransport,Tc as UBUNTU_2404_AMI_PARAM,Yh as acquireResizeLock,zh as applyHetznerHostOptimization,_s as assertArchSupported,sp as assertSshComputeConfig,pc as buildAwsArtifactFetch,wc as buildBoxUserData,ef as buildCloudFrontOriginConfig,Ec as buildCloudInitFirstBoot,pp as buildHetznerHostOptimizationScript,Hn as buildHostCleanupDeployScript,Qu as buildHostCleanupExecutable,ks as buildHostCleanupInstallScript,Qn as buildHostCleanupScript,gc as buildLocalArtifactFetch,J as buildRpxConfig,Fe as buildRpxFragmentRefreshScript,Ar as buildRpxLbConfig,be as buildRpxProvisionScript,qu as buildScpArgsFor,qn as buildSiteDeployScript,$n as buildSshArgs,yc as buildSshArgsFor,Kn as buildSshBootstrapScript,Vn as buildStaticSiteDeployScript,op as cloudDrivers,Kh as collectHetznerHostOptimizationReport,bc as collectHetznerResizeManifest,Zh as createBoxProvisioner,_ as createCloudDriver,kc as deployAllComputeSites,$s as deploySiteRelease,ac as deriveRouteId,kn as describeScriptSyntaxError,at as driverStateDir,Qe as driverStatePath,ni as ensureFirewall,ii as ensureServer,ri as ensureSshKey,Yn as evaluatePreflight,qh as executeHetznerServerResize,ju as findKnownHostKey,ei as formatPreflightFindings,Bt as formatSshFailure,xn as gatewayHostnames,B as generateUbuntuAppCloudInit,On as hasAutoWwwVariant,Ac as isBoxMode,lp as isHetznerCapacityError,Bn as isLocalDatabase,Vu as knownHostsLine,Ic as knownHostsToken,$u as normalizeRoutePath,Ue as normalizeSshPublicKey,Xn as parsePreflightFacts,dp as planHetznerServerResize,Zn as preflightFailed,Vh as prepareHetznerResize,He as readDriverState,Jh as readResizeCheckpoint,jn as releaseTarballTmpPath,ai as reloadRpxGateway,Un as remoteScriptRunner,Mh as renderRpxLauncher,Bc as renewRpxCertificates,vc as resizeCheckpointPath,gp as resizeLockPath,Gn as resolveExecStart,hc as resolveHetznerApiToken,up as resolveHetznerHostOptimizationPlan,Cr as resolveHostCleanupConfig,Zu as resolveSshHostKeyPolicy,Wu as resolveSshHosts,np as resolveSshLan,Xu as resolveSshPort,Yu as resolveSshPrivateKeyPath,tp as resolveSshProfile,rp as resolveSshPublicIp,Wn as resolveSshSettings,ep as resolveSshSudo,Ju as resolveSshUser,zn as scanHostKey,dc as scpUpload,si as serverPublicIpv4,zu as sshBootstrapMarkerPath,Ir as sshExec,ue as sshExecOrThrow,dt as sshHostKeyFingerprint,Sc as sshKnownHostsPath,_t as summarizeRemoteFailures,mr as surfaceRemoteNotices,Wh as verifyHetznerHostOptimization,jh as verifyHetznerResize,lc as waitForCloudInit,Mn as waitForSsh,X as wrapCloudInitUserData,ct as writeDriverState,Xh as writeResizeCheckpoint};
1
+ import{kn,Bt,mr,_t,Bn,_n,On,xn,$u,ac,J,Ar,Fh,Ln,cc,Ee,be,Fe,B,yr,$n,Ir,ue,dc,Mn,lc,Un,uc,Sr,Uh,Qh,Uu,Qu,Hh,Gh,qh,Cr,Qn,Hu,ks,Hn,Gn,qn,Vn,jn,pc,gc,Er,hc,Ue,X,fc,at,Qe,He,ct,ve,Bs,Ac,Gu,qu,yc,Vu,dt,zn,Ic,ju,zu,Sc,br,Te,Cc,Ku,Wu,_s,Kn,lt,Ju,Xu,Yu,Zu,ep,tp,rp,np,ip,Wn,Jn,Xn,Yn,Zn,ei,ti,sp,op,vr,_,Os,ap,cp,dp,Ec,lp,up,Vh,bc,jh,zh,pp,gp,Kh,Wh,Jh,vc,mp,Xh,Yh,Zh,ri,ni,ii,si,Tc,wc,Rc,Dc,ef,$s,kc,ai,Bc,hp,fp,Ap,tf}from"../chunk-29dcfx1g.js";import"../chunk-jp57js5y.js";import"../chunk-v1wqxgra.js";import"../chunk-45116tdd.js";import"../chunk-g3f3ccdw.js";import"../chunk-6n72pe9x.js";import"../chunk-0pe1dfy0.js";export{Dc as AwsBoxProvisioner,yr as AwsDriver,dp as BOOT_PARTITION_LABEL,Os as CloudDriverFactory,Qu as DEFAULT_HOST_CLEANUP_ESCALATED,Gh as DEFAULT_HOST_CLEANUP_HIGH_WATER_PERCENT,Hh as DEFAULT_HOST_CLEANUP_LOW_WATER_PERCENT,Uu as DEFAULT_HOST_CLEANUP_RETENTION,qh as DEFAULT_HOST_CLEANUP_SCHEDULE,_n as DEFAULT_RPX_CERTS_DIR,cp as FIRST_BOOT_SCRIPT_PATH,Sr as HOST_ARTIFACT_CACHE_DIR,Uh as HOST_CLEANUP_SCRIPT_PATH,Qh as HOST_CLEANUP_UNIT,Rc as HetznerBoxProvisioner,Er as HetznerClient,ve as HetznerDriver,fc as LEGACY_DRIVER_STATE_DIR,Bs as LocalBoxDriver,fp as MANAGED_CACHE_POLICY_DISABLED,hp as MANAGED_CACHE_POLICY_OPTIMIZED,Ap as MANAGED_ORIGIN_REQUEST_POLICY_ALL_VIEWER,Wu as RASPBERRY_PI_DEFAULT_SWAP_GB,uc as REMOTE_SCRIPT_RUNNER,Ln as RPX_DIR,cc as RPX_LAUNCHER_PATH,Ee as RPX_SERVICE_NAME,Cc as SSH_BOOTSTRAP_MARKER_DIR,Te as SSH_BOOTSTRAP_VERSION,lt as SSH_DEFAULTS,ti as SSH_DEPLOY_STORAGE_PATH,Gu as SSH_INSECURE_HOST_KEY_OPTS,qu as SSH_KEEPALIVE_OPTS,Jn as SSH_PREFLIGHT_SCRIPT,sp as SSH_SKIP_BOOTSTRAP_ENV,vr as SshDriver,br as SystemSshTransport,Tc as UBUNTU_2404_AMI_PARAM,Zh as acquireResizeLock,Kh as applyHetznerHostOptimization,_s as assertArchSupported,op as assertSshComputeConfig,pc as buildAwsArtifactFetch,wc as buildBoxUserData,tf as buildCloudFrontOriginConfig,Ec as buildCloudInitFirstBoot,gp as buildHetznerHostOptimizationScript,Hn as buildHostCleanupDeployScript,Hu as buildHostCleanupExecutable,ks as buildHostCleanupInstallScript,Qn as buildHostCleanupScript,gc as buildLocalArtifactFetch,J as buildRpxConfig,Fe as buildRpxFragmentRefreshScript,Ar as buildRpxLbConfig,be as buildRpxProvisionScript,Vu as buildScpArgsFor,qn as buildSiteDeployScript,$n as buildSshArgs,yc as buildSshArgsFor,Kn as buildSshBootstrapScript,Vn as buildStaticSiteDeployScript,ap as cloudDrivers,Wh as collectHetznerHostOptimizationReport,bc as collectHetznerResizeManifest,ef as createBoxProvisioner,_ as createCloudDriver,kc as deployAllComputeSites,$s as deploySiteRelease,ac as deriveRouteId,kn as describeScriptSyntaxError,at as driverStateDir,Qe as driverStatePath,ni as ensureFirewall,ii as ensureServer,ri as ensureSshKey,Yn as evaluatePreflight,Vh as executeHetznerServerResize,zu as findKnownHostKey,ei as formatPreflightFindings,Bt as formatSshFailure,xn as gatewayHostnames,B as generateUbuntuAppCloudInit,On as hasAutoWwwVariant,Ac as isBoxMode,up as isHetznerCapacityError,Bn as isLocalDatabase,ju as knownHostsLine,Ic as knownHostsToken,$u as normalizeRoutePath,Ue as normalizeSshPublicKey,Xn as parsePreflightFacts,lp as planHetznerServerResize,Zn as preflightFailed,jh as prepareHetznerResize,He as readDriverState,Xh as readResizeCheckpoint,jn as releaseTarballTmpPath,ai as reloadRpxGateway,Un as remoteScriptRunner,Fh as renderRpxLauncher,Bc as renewRpxCertificates,vc as resizeCheckpointPath,mp as resizeLockPath,Gn as resolveExecStart,hc as resolveHetznerApiToken,pp as resolveHetznerHostOptimizationPlan,Cr as resolveHostCleanupConfig,ep as resolveSshHostKeyPolicy,Ju as resolveSshHosts,ip as resolveSshLan,Yu as resolveSshPort,Zu as resolveSshPrivateKeyPath,rp as resolveSshProfile,np as resolveSshPublicIp,Wn as resolveSshSettings,tp as resolveSshSudo,Xu as resolveSshUser,zn as scanHostKey,dc as scpUpload,si as serverPublicIpv4,Ku as sshBootstrapMarkerPath,Ir as sshExec,ue as sshExecOrThrow,dt as sshHostKeyFingerprint,Sc as sshKnownHostsPath,_t as summarizeRemoteFailures,mr as surfaceRemoteNotices,Jh as verifyHetznerHostOptimization,zh as verifyHetznerResize,lc as waitForCloudInit,Mn as waitForSsh,X as wrapCloudInitUserData,ct as writeDriverState,Yh as writeResizeCheckpoint};
@@ -37,6 +37,7 @@ export interface ComputeOpsResult {
37
37
  export declare function rollbackComputeSite(ctx: ComputeOpsContext, options: {
38
38
  siteName: string;
39
39
  to?: string;
40
+ dryRun?: boolean;
40
41
  }): Promise<ComputeOpsResult>;
41
42
  /**
42
43
  * Read a site's on-box deployment history (the log written by
@@ -151,30 +151,57 @@ export declare function buildRelinkSharedPaths(paths: ReleasePaths, releaseExpr:
151
151
  * `mv -T`s it over `current` so there is no window where `current` is missing.
152
152
  */
153
153
  export declare function buildActivateRelease(paths: ReleasePaths): string[];
154
+ /**
155
+ * Where a deploy writes the id of the release it replaced.
156
+ *
157
+ * "The previous release" used to be inferred from directory mtimes: the
158
+ * newest release dir that is not current. That is usually right and not
159
+ * always, because anything that creates or removes an entry in an old release
160
+ * dir moves its mtime, and a rollback triggered by a failed deploy needs the
161
+ * release that was actually serving a minute ago, not the most recently
162
+ * touched one. The deploy knows exactly which that was, so it says so.
163
+ */
164
+ export declare function previousReleasePath(base: string): string;
165
+ /**
166
+ * Record the release `prevVar` (a shell variable holding the old `current`
167
+ * link target) as the one this deploy replaced. Nothing is written when there
168
+ * was none, or when it is the release being activated (a redeploy).
169
+ */
170
+ export declare function buildRecordPreviousRelease(paths: ReleasePaths, prevVar?: string): string[];
171
+ /**
172
+ * Say what a rollback would do, and do nothing. `buddy deploy:rollback
173
+ * --dry-run` is answered by this.
174
+ */
175
+ export declare function buildRollbackPlanScript(paths: ReleasePaths, options?: {
176
+ to?: string;
177
+ }): string[];
154
178
  /**
155
179
  * Roll the active release back to a previous one (Forge-style rollback). With
156
- * `to` set, points `current` at `releases/<to>`; otherwise picks the most recent
157
- * release that isn't the one `current` resolves to. Atomic (temp symlink + `mv
158
- * -T`), and a no-op-safe guard fails loudly if the target is missing rather than
159
- * leaving `current` dangling.
180
+ * `to` set, goes to `releases/<to>`; otherwise to the release the last deploy
181
+ * recorded replacing ({@link previousReleasePath}), falling back to the newest
182
+ * release that is not current.
160
183
  *
161
- * Before the flip, every shared path recorded on the box is relinked into the
162
- * target release ({@link buildRelinkSharedPaths}) so a rollback moves the CODE
163
- * back without moving the DATA back — a release cut before a path became shared
164
- * still carries its own copy, and going live with it would silently swap the
165
- * database for a stale snapshot.
184
+ * Before anything goes live, every shared path recorded on the box is
185
+ * relinked into the target release ({@link buildRelinkSharedPaths}) so a
186
+ * rollback moves the CODE back without moving the DATA back — a release cut
187
+ * before a path became shared still carries its own copy, and going live with
188
+ * it would silently swap the database for a stale snapshot.
166
189
  *
167
- * With `unitBase` set (e.g. `myapp-api`), the script also swaps the running
168
- * systemd release instance for sites deployed zero-downtime style (templated
169
- * `<unitBase>@<releaseId>` units pinned to their release dirs): it starts the
170
- * instance for the rolled-back release — overlapping on the SO_REUSEPORT port —
171
- * then stops the newer one, so even the rollback itself is zero-downtime. Sites
172
- * on the legacy single unit just get a restart. The caller appends any engine
173
- * reload (php-fpm/queues) — see {@link import('./laravel-deploy')}.
190
+ * With `unitBase` set (e.g. `myapp-api`), sites deployed zero-downtime style
191
+ * (templated `<unitBase>@<releaseId>` units) get the cutover in the same order
192
+ * a deploy uses: the rolled-back release's instance starts beside the running
193
+ * one on the SO_REUSEPORT port and must stay up for the gate window before
194
+ * `current` flips and the newer instance is retired. It used to flip first and
195
+ * check for two seconds, so a rollback target that would not start left
196
+ * `current` naming it while the newer release kept serving. Sites on the
197
+ * legacy single unit flip and restart. The caller appends any engine reload
198
+ * (php-fpm/queues) — see {@link import('./laravel-deploy')}.
174
199
  */
175
200
  export declare function buildRollbackScript(paths: ReleasePaths, options?: {
176
201
  to?: string;
177
202
  unitBase?: string;
203
+ gateSeconds?: number;
204
+ systemdDir?: string;
178
205
  }): string[];
179
206
  /**
180
207
  * Remove all but the newest `keep` releases (by mtime). `current` always points