@stacksjs/ts-cloud 0.12.1 → 0.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/dist/aws/index.js +1 -1
  2. package/dist/bin/chunk-0zwknfwp.js +1 -0
  3. package/dist/bin/chunk-33ct22z0.js +1 -0
  4. package/dist/bin/chunk-3aph4c1w.js +2 -0
  5. package/dist/bin/{chunk-5bhx3bsa.js → chunk-4q6tad44.js} +121 -121
  6. package/dist/bin/chunk-5nkqza92.js +1 -0
  7. package/dist/bin/chunk-64vczwwt.js +1 -0
  8. package/dist/bin/chunk-6tfwm33r.js +6 -0
  9. package/dist/bin/chunk-71t1gmsq.js +1 -0
  10. package/dist/bin/chunk-7g2ahkse.js +1 -0
  11. package/dist/bin/chunk-7zhgmp1s.js +3 -0
  12. package/dist/bin/chunk-82mj52xr.js +141 -0
  13. package/dist/bin/chunk-8ewncfce.js +37 -0
  14. package/dist/bin/chunk-9a88fp00.js +2 -0
  15. package/dist/bin/chunk-9kf0np8j.js +44 -0
  16. package/dist/bin/chunk-a7w13qfm.js +2 -0
  17. package/dist/bin/chunk-anx2a852.js +585 -0
  18. package/dist/bin/chunk-b4wt9jcg.js +60 -0
  19. package/dist/bin/chunk-btdq3w81.js +512 -0
  20. package/dist/bin/chunk-btsyjhk7.js +92 -0
  21. package/dist/bin/chunk-c0bdafbx.js +2 -0
  22. package/dist/bin/chunk-cd0ps58j.js +1 -0
  23. package/dist/bin/chunk-cxt74wsj.js +1 -0
  24. package/dist/bin/chunk-d7ke90zt.js +2 -0
  25. package/dist/bin/chunk-djg4zyqk.js +1 -0
  26. package/dist/bin/chunk-dkaz333b.js +1 -0
  27. package/dist/bin/chunk-dkf4qsp2.js +1 -0
  28. package/dist/bin/{chunk-scqmd4qv.js → chunk-dz1ec589.js} +30 -30
  29. package/dist/bin/chunk-e2bybahr.js +3 -0
  30. package/dist/bin/chunk-e5ab5twy.js +50 -0
  31. package/dist/bin/chunk-edvvx3hg.js +1 -0
  32. package/dist/bin/chunk-ehc63fvs.js +2 -0
  33. package/dist/bin/chunk-f06c5np9.js +1 -0
  34. package/dist/bin/chunk-gq8794k6.js +1 -0
  35. package/dist/bin/chunk-hq9x489e.js +70 -0
  36. package/dist/bin/chunk-ja1vjdn1.js +6 -0
  37. package/dist/bin/chunk-k3120rx6.js +1 -0
  38. package/dist/bin/chunk-kg61p5hw.js +3 -0
  39. package/dist/bin/chunk-mcr0r4at.js +2 -0
  40. package/dist/bin/chunk-mfrf9q4b.js +2 -0
  41. package/dist/bin/chunk-my3ewh3a.js +34 -0
  42. package/dist/bin/chunk-nw3d4k52.js +1 -0
  43. package/dist/bin/chunk-p70bc9yr.js +1 -0
  44. package/dist/bin/chunk-q5cmfpzt.js +1 -0
  45. package/dist/bin/chunk-rtecnmts.js +4 -0
  46. package/dist/bin/chunk-s4yzes15.js +2 -0
  47. package/dist/bin/chunk-sj5csg49.js +2 -0
  48. package/dist/bin/chunk-tfbs8k8v.js +111 -0
  49. package/dist/bin/chunk-tvz9c388.js +1 -0
  50. package/dist/bin/{chunk-9vdc7adf.js → chunk-w32xv8n4.js} +6 -6
  51. package/dist/bin/chunk-x6f61g36.js +9 -0
  52. package/dist/bin/chunk-xhwqpgwq.js +2 -0
  53. package/dist/bin/chunk-xk08030d.js +6 -0
  54. package/dist/bin/chunk-xkfrqqcs.js +1 -0
  55. package/dist/bin/chunk-y1h63vpm.js +1 -0
  56. package/dist/bin/chunk-zdt2rjk6.js +1 -0
  57. package/dist/bin/chunk-zh2d4704.js +1 -0
  58. package/dist/bin/chunk-zpe64t4r.js +1 -0
  59. package/dist/bin/cli.js +435 -444
  60. package/dist/bin/dashboard-server.js +1 -1
  61. package/dist/{chunk-rr1yaj55.js → chunk-13qjvbqh.js} +1 -1
  62. package/dist/chunk-152he7m3.js +92 -0
  63. package/dist/chunk-1qdne0bf.js +1 -0
  64. package/dist/chunk-3mgj3hrh.js +5 -0
  65. package/dist/chunk-6kpbveb8.js +5 -0
  66. package/dist/chunk-73ztr55z.js +2 -0
  67. package/dist/{chunk-y1dh3znq.js → chunk-86ss83s2.js} +52 -52
  68. package/dist/chunk-a84gmpyh.js +1 -0
  69. package/dist/chunk-aj025v2s.js +4 -0
  70. package/dist/chunk-by2bwzk6.js +141 -0
  71. package/dist/chunk-h42zck7h.js +60 -0
  72. package/dist/chunk-hn40z11p.js +37 -0
  73. package/dist/chunk-hvwbgcs7.js +704 -0
  74. package/dist/{chunk-6xcbfs2r.js → chunk-jm5mg890.js} +111 -111
  75. package/dist/chunk-kqnpprnh.js +445 -0
  76. package/dist/chunk-m8fs0233.js +34 -0
  77. package/dist/chunk-mz0dk78z.js +6 -0
  78. package/dist/chunk-nms5q44e.js +1 -0
  79. package/dist/chunk-qm32ytbr.js +1 -0
  80. package/dist/chunk-t0xgmhd6.js +114 -0
  81. package/dist/chunk-t3t9ymec.js +1 -0
  82. package/dist/chunk-tz9myq9a.js +2 -0
  83. package/dist/chunk-wavjkdb8.js +2 -0
  84. package/dist/chunk-x3hay61c.js +44 -0
  85. package/dist/chunk-xcj8zfmg.js +2 -0
  86. package/dist/chunk-y2v22hkv.js +1 -0
  87. package/dist/chunk-y4xkj2f1.js +50 -0
  88. package/dist/deploy/index.js +1 -1
  89. package/dist/dns/index.js +1 -1
  90. package/dist/drivers/index.js +1 -1
  91. package/dist/drivers/shared/deploy-script.d.ts +46 -0
  92. package/dist/index.js +90 -90
  93. package/dist/protection/index.js +1 -1
  94. package/dist/push/index.js +1 -1
  95. package/dist/spend/index.js +1 -1
  96. package/dist/ui/404.html +2 -2
  97. package/dist/ui/_stx/{router.fa5bc4dc.js → router.229f89ab.js} +1 -1
  98. package/dist/ui/_stx/runtime.dbee66d1.js +1 -0
  99. package/dist/ui/accept-invitation.html +2 -2
  100. package/dist/ui/access-denied.html +1 -1
  101. package/dist/ui/account/automation.html +6 -6
  102. package/dist/ui/account/security.html +2 -2
  103. package/dist/ui/applications/compose.html +6 -6
  104. package/dist/ui/applications/new.html +2 -2
  105. package/dist/ui/data/backups.html +80 -80
  106. package/dist/ui/data/services.html +77 -77
  107. package/dist/ui/data/volumes.html +50 -50
  108. package/dist/ui/index.html +50 -50
  109. package/dist/ui/infrastructure/topology.html +118 -118
  110. package/dist/ui/integrations.html +1 -1
  111. package/dist/ui/operations/alerts.html +47 -47
  112. package/dist/ui/operations/configuration.html +6 -6
  113. package/dist/ui/operations/jobs.html +75 -75
  114. package/dist/ui/operations/maintenance.html +6 -6
  115. package/dist/ui/operations/observability.html +82 -82
  116. package/dist/ui/operations/previews.html +6 -6
  117. package/dist/ui/operations/queue.html +6 -6
  118. package/dist/ui/operations/regions.html +6 -6
  119. package/dist/ui/operations/releases.html +6 -6
  120. package/dist/ui/operations/spend.html +54 -54
  121. package/dist/ui/operations/workloads.html +104 -104
  122. package/dist/ui/security.html +2 -2
  123. package/dist/ui/server/actions.html +56 -56
  124. package/dist/ui/server/activity.html +2 -2
  125. package/dist/ui/server/capacity.html +6 -6
  126. package/dist/ui/server/database.html +106 -106
  127. package/dist/ui/server/deployments.html +50 -50
  128. package/dist/ui/server/diagnostics.html +2 -2
  129. package/dist/ui/server/firewall.html +75 -75
  130. package/dist/ui/server/fleet.html +34 -34
  131. package/dist/ui/server/logs.html +24 -24
  132. package/dist/ui/server/metrics.html +112 -112
  133. package/dist/ui/server/security.html +1 -1
  134. package/dist/ui/server/services.html +27 -27
  135. package/dist/ui/server/sites.html +120 -120
  136. package/dist/ui/server/ssh-keys.html +52 -52
  137. package/dist/ui/server/team.html +144 -144
  138. package/dist/ui/server/terminal.html +16 -16
  139. package/dist/ui/serverless/alarms.html +52 -52
  140. package/dist/ui/serverless/assets.html +28 -28
  141. package/dist/ui/serverless/cost.html +2 -2
  142. package/dist/ui/serverless/data.html +36 -36
  143. package/dist/ui/serverless/deployments.html +28 -28
  144. package/dist/ui/serverless/firewall.html +2 -2
  145. package/dist/ui/serverless/functions.html +39 -39
  146. package/dist/ui/serverless/logs.html +24 -24
  147. package/dist/ui/serverless/metrics.html +2 -2
  148. package/dist/ui/serverless/queues.html +48 -48
  149. package/dist/ui/serverless/secrets.html +52 -52
  150. package/dist/ui/serverless/traces.html +6 -6
  151. package/dist/ui/serverless.html +54 -54
  152. package/dist/ui-src/src/charts.ts +4644 -16118
  153. package/dist/ui-src/src/topology.ts +2 -2
  154. package/package.json +6 -6
  155. package/dist/bin/chunk-0rtn6q5x.js +0 -3
  156. package/dist/bin/chunk-258ehp9s.js +0 -1
  157. package/dist/bin/chunk-2yctv06c.js +0 -1
  158. package/dist/bin/chunk-3276rveh.js +0 -37
  159. package/dist/bin/chunk-3m665jwp.js +0 -70
  160. package/dist/bin/chunk-3s2p9vxj.js +0 -1
  161. package/dist/bin/chunk-4esma5m9.js +0 -1
  162. package/dist/bin/chunk-4n0j3n3b.js +0 -2
  163. package/dist/bin/chunk-54bqchag.js +0 -92
  164. package/dist/bin/chunk-5zagqd20.js +0 -1
  165. package/dist/bin/chunk-7hw2js5h.js +0 -512
  166. package/dist/bin/chunk-8h1qr6x4.js +0 -50
  167. package/dist/bin/chunk-a1dd6sby.js +0 -1
  168. package/dist/bin/chunk-a4dw35gs.js +0 -1
  169. package/dist/bin/chunk-a9d55ker.js +0 -1
  170. package/dist/bin/chunk-awa1qade.js +0 -9
  171. package/dist/bin/chunk-b6by94pk.js +0 -2
  172. package/dist/bin/chunk-c8sypnbe.js +0 -2
  173. package/dist/bin/chunk-cx4e3d4w.js +0 -1
  174. package/dist/bin/chunk-d5a3vheh.js +0 -2
  175. package/dist/bin/chunk-e1fym2bd.js +0 -1
  176. package/dist/bin/chunk-ej4h0q2y.js +0 -1
  177. package/dist/bin/chunk-ett305ym.js +0 -4
  178. package/dist/bin/chunk-f11xf3n6.js +0 -2
  179. package/dist/bin/chunk-fq7ktvgy.js +0 -3
  180. package/dist/bin/chunk-fyq4th2m.js +0 -1
  181. package/dist/bin/chunk-g67qr8yf.js +0 -1
  182. package/dist/bin/chunk-gc82cx4h.js +0 -1
  183. package/dist/bin/chunk-hchtvpr9.js +0 -1
  184. package/dist/bin/chunk-hpe4jjce.js +0 -1
  185. package/dist/bin/chunk-k5vprsef.js +0 -6
  186. package/dist/bin/chunk-m22krd4z.js +0 -3
  187. package/dist/bin/chunk-mkppcwz8.js +0 -1
  188. package/dist/bin/chunk-mpjg0kc7.js +0 -2
  189. package/dist/bin/chunk-mrm4m4dk.js +0 -2
  190. package/dist/bin/chunk-nff46rxd.js +0 -1
  191. package/dist/bin/chunk-np1z3bgt.js +0 -1
  192. package/dist/bin/chunk-nskxkk6r.js +0 -1
  193. package/dist/bin/chunk-pez932b1.js +0 -111
  194. package/dist/bin/chunk-qsdf5kzk.js +0 -2
  195. package/dist/bin/chunk-r61qmhv1.js +0 -2
  196. package/dist/bin/chunk-r6gdcz5c.js +0 -1
  197. package/dist/bin/chunk-satwnr42.js +0 -2
  198. package/dist/bin/chunk-smbycpt5.js +0 -44
  199. package/dist/bin/chunk-sn7e0sn7.js +0 -2
  200. package/dist/bin/chunk-ss574pka.js +0 -1
  201. package/dist/bin/chunk-tj0xb2d8.js +0 -585
  202. package/dist/bin/chunk-v3rzf9d0.js +0 -141
  203. package/dist/bin/chunk-wnpma6t3.js +0 -34
  204. package/dist/bin/chunk-xan0e052.js +0 -5
  205. package/dist/bin/chunk-xbk2y43r.js +0 -60
  206. package/dist/bin/chunk-xjp3v95e.js +0 -6
  207. package/dist/bin/chunk-xyt490vp.js +0 -6
  208. package/dist/bin/chunk-yn9r02gy.js +0 -1
  209. package/dist/bin/chunk-zhkhn9cc.js +0 -1
  210. package/dist/chunk-0zf72ngj.js +0 -1
  211. package/dist/chunk-2hpjte1d.js +0 -704
  212. package/dist/chunk-4m6gwhwr.js +0 -5
  213. package/dist/chunk-5m29dhke.js +0 -34
  214. package/dist/chunk-6fzeemcs.js +0 -114
  215. package/dist/chunk-bpnhqb70.js +0 -6
  216. package/dist/chunk-ead1nkbr.js +0 -60
  217. package/dist/chunk-fea461tj.js +0 -141
  218. package/dist/chunk-fvjczc73.js +0 -1
  219. package/dist/chunk-gearw6rk.js +0 -4
  220. package/dist/chunk-j60hesb3.js +0 -2
  221. package/dist/chunk-pmgtmt3d.js +0 -1
  222. package/dist/chunk-prf2pkvq.js +0 -5
  223. package/dist/chunk-q0wffgw5.js +0 -37
  224. package/dist/chunk-qcemnt35.js +0 -50
  225. package/dist/chunk-qvbwsaay.js +0 -1
  226. package/dist/chunk-r2pbqcnz.js +0 -2
  227. package/dist/chunk-r6110zv2.js +0 -1
  228. package/dist/chunk-wcrj06cg.js +0 -44
  229. package/dist/chunk-wte9mh18.js +0 -92
  230. package/dist/chunk-y6e86wjs.js +0 -445
  231. package/dist/chunk-y8b7ht4v.js +0 -1
  232. package/dist/chunk-yf487g6e.js +0 -2
  233. package/dist/chunk-zmmc9j5f.js +0 -2
  234. package/dist/ui/_stx/runtime.c696d17a.js +0 -1
@@ -1,50 +0,0 @@
1
- import{dh as L}from"./chunk-xyt490vp.js";class Q{client;region;constructor(j="us-east-1"){this.region=j,this.client=new L}async createHostedZone(j){let k=j.CallerReference||`${Date.now()}-${Math.random().toString(36).slice(2)}`,F=`<?xml version="1.0" encoding="UTF-8"?>
2
- <CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
3
- <Name>${j.Name}</Name>
4
- <CallerReference>${k}</CallerReference>`;if(j.HostedZoneConfig){if(F+=`
5
- <HostedZoneConfig>`,j.HostedZoneConfig.Comment)F+=`
6
- <Comment>${j.HostedZoneConfig.Comment}</Comment>`;if(j.HostedZoneConfig.PrivateZone!==void 0)F+=`
7
- <PrivateZone>${j.HostedZoneConfig.PrivateZone}</PrivateZone>`;F+=`
8
- </HostedZoneConfig>`}if(j.VPC)F+=`
9
- <VPC>
10
- <VPCRegion>${j.VPC.VPCRegion}</VPCRegion>
11
- <VPCId>${j.VPC.VPCId}</VPCId>
12
- </VPC>`;if(j.DelegationSetId)F+=`
13
- <DelegationSetId>${j.DelegationSetId}</DelegationSetId>`;F+=`
14
- </CreateHostedZoneRequest>`;let J=await this.client.request({service:"route53",region:this.region,method:"POST",path:"/2013-04-01/hostedzone",headers:{"content-type":"application/xml"},body:F});return this.parseCreateHostedZoneResponse(J)}async listHostedZones(j){let k={};if(j?.Marker)k.marker=j.Marker;if(j?.MaxItems)k.maxitems=j.MaxItems;let F=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzone",queryParams:Object.keys(k).length>0?k:void 0});return this.parseListHostedZonesResponse(F)}async listHostedZonesByName(j){let k={};if(j?.DNSName)k.dnsname=j.DNSName;if(j?.HostedZoneId)k.hostedzoneid=j.HostedZoneId;if(j?.MaxItems)k.maxitems=j.MaxItems;let F=await this.client.request({service:"route53",region:this.region,method:"GET",path:"/2013-04-01/hostedzonesbyname",queryParams:Object.keys(k).length>0?k:void 0});return this.parseListHostedZonesResponse(F)}async getHostedZone(j){let k=j.Id.replace("/hostedzone/",""),F=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${k}`});return this.parseGetHostedZoneResponse(F)}async deleteHostedZone(j){let k=j.Id.replace("/hostedzone/","");await this.client.request({service:"route53",region:this.region,method:"DELETE",path:`/2013-04-01/hostedzone/${k}`})}async listResourceRecordSets(j){let k=j.HostedZoneId.replace("/hostedzone/",""),F={};if(j.StartRecordName)F.name=j.StartRecordName;if(j.StartRecordType)F.type=j.StartRecordType;if(j.StartRecordIdentifier)F.identifier=j.StartRecordIdentifier;if(j.MaxItems)F.maxitems=j.MaxItems;let J=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/hostedzone/${k}/rrset`,queryParams:Object.keys(F).length>0?F:void 0});return this.parseListResourceRecordSetsResponse(J)}async changeResourceRecordSets(j){let k=j.HostedZoneId.replace("/hostedzone/",""),F=`<?xml version="1.0" encoding="UTF-8"?>
15
- <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
16
- <ChangeBatch>`;if(j.ChangeBatch.Comment)F+=`
17
- <Comment>${this.escapeXml(j.ChangeBatch.Comment)}</Comment>`;F+=`
18
- <Changes>`;for(let H of j.ChangeBatch.Changes){if(F+=`
19
- <Change>
20
- <Action>${H.Action}</Action>
21
- <ResourceRecordSet>
22
- <Name>${H.ResourceRecordSet.Name}</Name>
23
- <Type>${H.ResourceRecordSet.Type}</Type>`,H.ResourceRecordSet.TTL!==void 0)F+=`
24
- <TTL>${H.ResourceRecordSet.TTL}</TTL>`;if(H.ResourceRecordSet.SetIdentifier)F+=`
25
- <SetIdentifier>${H.ResourceRecordSet.SetIdentifier}</SetIdentifier>`;if(H.ResourceRecordSet.Weight!==void 0)F+=`
26
- <Weight>${H.ResourceRecordSet.Weight}</Weight>`;if(H.ResourceRecordSet.Region)F+=`
27
- <Region>${H.ResourceRecordSet.Region}</Region>`;if(H.ResourceRecordSet.Failover)F+=`
28
- <Failover>${H.ResourceRecordSet.Failover}</Failover>`;if(H.ResourceRecordSet.HealthCheckId)F+=`
29
- <HealthCheckId>${H.ResourceRecordSet.HealthCheckId}</HealthCheckId>`;if(H.ResourceRecordSet.ResourceRecords&&H.ResourceRecordSet.ResourceRecords.length>0){F+=`
30
- <ResourceRecords>`;for(let K of H.ResourceRecordSet.ResourceRecords)F+=`
31
- <ResourceRecord>
32
- <Value>${this.escapeXml(K.Value)}</Value>
33
- </ResourceRecord>`;F+=`
34
- </ResourceRecords>`}if(H.ResourceRecordSet.AliasTarget)F+=`
35
- <AliasTarget>
36
- <HostedZoneId>${H.ResourceRecordSet.AliasTarget.HostedZoneId}</HostedZoneId>
37
- <DNSName>${H.ResourceRecordSet.AliasTarget.DNSName}</DNSName>
38
- <EvaluateTargetHealth>${H.ResourceRecordSet.AliasTarget.EvaluateTargetHealth}</EvaluateTargetHealth>
39
- </AliasTarget>`;if(H.ResourceRecordSet.GeoLocation){if(F+=`
40
- <GeoLocation>`,H.ResourceRecordSet.GeoLocation.ContinentCode)F+=`
41
- <ContinentCode>${H.ResourceRecordSet.GeoLocation.ContinentCode}</ContinentCode>`;if(H.ResourceRecordSet.GeoLocation.CountryCode)F+=`
42
- <CountryCode>${H.ResourceRecordSet.GeoLocation.CountryCode}</CountryCode>`;if(H.ResourceRecordSet.GeoLocation.SubdivisionCode)F+=`
43
- <SubdivisionCode>${H.ResourceRecordSet.GeoLocation.SubdivisionCode}</SubdivisionCode>`;F+=`
44
- </GeoLocation>`}F+=`
45
- </ResourceRecordSet>
46
- </Change>`}F+=`
47
- </Changes>
48
- </ChangeBatch>
49
- </ChangeResourceRecordSetsRequest>`;let J=await this.client.request({service:"route53",region:this.region,method:"POST",path:`/2013-04-01/hostedzone/${k}/rrset`,headers:{"content-type":"application/xml"},body:F});return this.parseChangeResourceRecordSetsResponse(J)}escapeXml(j){return j.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}parseCreateHostedZoneResponse(j){let k=j.CreateHostedZoneResponse||j;return{HostedZone:this.parseHostedZone(k.HostedZone),ChangeInfo:{Id:k.ChangeInfo?.Id||"",Status:k.ChangeInfo?.Status||"",SubmittedAt:k.ChangeInfo?.SubmittedAt||""},DelegationSet:this.parseDelegationSet(k.DelegationSet),Location:k.Location||""}}parseListHostedZonesResponse(j){let k=j.ListHostedZonesResponse||j.ListHostedZonesByNameResponse||j,F=k.HostedZones?.HostedZone||k.HostedZones||[];if(!Array.isArray(F))F=F?[F]:[];return{HostedZones:F.map((J)=>this.parseHostedZone(J)),IsTruncated:k.IsTruncated==="true"||k.IsTruncated===!0,MaxItems:k.MaxItems||"100",Marker:k.Marker,NextMarker:k.NextMarker}}parseGetHostedZoneResponse(j){let k=j.GetHostedZoneResponse||j;return{HostedZone:this.parseHostedZone(k.HostedZone),DelegationSet:this.parseDelegationSet(k.DelegationSet),VPCs:k.VPCs?.VPC?Array.isArray(k.VPCs.VPC)?k.VPCs.VPC:[k.VPCs.VPC]:void 0}}parseListResourceRecordSetsResponse(j){let k=j.ListResourceRecordSetsResponse||j,F=k.ResourceRecordSets?.ResourceRecordSet||k.ResourceRecordSets||[];if(!Array.isArray(F))F=F?[F]:[];return{ResourceRecordSets:F.map((J)=>this.parseResourceRecordSet(J)),IsTruncated:k.IsTruncated==="true"||k.IsTruncated===!0,MaxItems:k.MaxItems||"100",NextRecordName:k.NextRecordName,NextRecordType:k.NextRecordType,NextRecordIdentifier:k.NextRecordIdentifier}}parseChangeResourceRecordSetsResponse(j){let k=j.ChangeResourceRecordSetsResponse||j;return{ChangeInfo:{Id:k.ChangeInfo?.Id||"",Status:k.ChangeInfo?.Status||"",SubmittedAt:k.ChangeInfo?.SubmittedAt||"",Comment:k.ChangeInfo?.Comment}}}parseHostedZone(j){if(!j)return{Id:"",Name:""};return{Id:j.Id||"",Name:j.Name||"",CallerReference:j.CallerReference,Config:j.Config?{Comment:j.Config.Comment,PrivateZone:j.Config.PrivateZone==="true"||j.Config.PrivateZone===!0}:void 0,ResourceRecordSetCount:j.ResourceRecordSetCount?Number(j.ResourceRecordSetCount):void 0}}parseDelegationSet(j){if(!j)return{NameServers:[]};let k=j.NameServers?.NameServer||j.NameServers||[];if(!Array.isArray(k))k=k?[k]:[];return{Id:j.Id,CallerReference:j.CallerReference,NameServers:k}}parseResourceRecordSet(j){if(!j)return{Name:"",Type:""};let k=j.ResourceRecords?.ResourceRecord||j.ResourceRecords||[];if(!Array.isArray(k))k=k?[k]:[];return{Name:j.Name||"",Type:j.Type||"",TTL:j.TTL?Number(j.TTL):void 0,ResourceRecords:k.map((F)=>({Value:F.Value||F})),AliasTarget:j.AliasTarget?{HostedZoneId:j.AliasTarget.HostedZoneId,DNSName:j.AliasTarget.DNSName,EvaluateTargetHealth:j.AliasTarget.EvaluateTargetHealth==="true"||j.AliasTarget.EvaluateTargetHealth===!0}:void 0,SetIdentifier:j.SetIdentifier,Weight:j.Weight?Number(j.Weight):void 0,Region:j.Region,GeoLocation:j.GeoLocation,Failover:j.Failover,HealthCheckId:j.HealthCheckId}}async findHostedZoneByName(j){let k=j.endsWith(".")?j:`${j}.`;return(await this.listHostedZonesByName({DNSName:k})).HostedZones.find((H)=>H.Name===k)||null}async createARecord(j){let k=Array.isArray(j.Value)?j.Value:[j.Value];return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"A",TTL:j.TTL||300,ResourceRecords:k.map((F)=>({Value:F}))}}]}})}async createCnameRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"CNAME",TTL:j.TTL||300,ResourceRecords:[{Value:j.Value}]}}]}})}async createAliasRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:j.Type||"A",AliasTarget:{HostedZoneId:j.TargetHostedZoneId,DNSName:j.TargetDNSName,EvaluateTargetHealth:j.EvaluateTargetHealth??!1}}}]}})}async createTxtRecord(j){let F=(Array.isArray(j.Value)?j.Value:[j.Value]).map((J)=>{if(!J.startsWith('"'))return`"${J}"`;return J});return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"TXT",TTL:j.TTL||300,ResourceRecords:F.map((J)=>({Value:J}))}}]}})}async createMxRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:j.Name,Type:"MX",TTL:j.TTL||300,ResourceRecords:j.Values.map((k)=>({Value:`${k.priority} ${k.mailServer}`}))}}]}})}async deleteRecord(j){return this.changeResourceRecordSets({HostedZoneId:j.HostedZoneId,ChangeBatch:{Changes:[{Action:"DELETE",ResourceRecordSet:j.RecordSet}]}})}async waitForChange(j,k=60,F=5000){let J=j.replace("/change/","");for(let H=0;H<k;H++){let K=await this.client.request({service:"route53",region:this.region,method:"GET",path:`/2013-04-01/change/${J}`});if((K.GetChangeResponse?.ChangeInfo?.Status||K.ChangeInfo?.Status)==="INSYNC")return!0;await new Promise((O)=>setTimeout(O,F))}return!1}async findOrCreateHostedZone(j){let k=j.domainName.endsWith(".")?j.domainName:`${j.domainName}.`,F=await this.findHostedZoneByName(k);if(F){let H=await this.getHostedZone({Id:F.Id});return{hostedZone:F,nameServers:H.DelegationSet.NameServers,isNew:!1}}let J=await this.createHostedZone({Name:k,HostedZoneConfig:{Comment:j.comment||`Hosted zone for ${j.domainName}`,PrivateZone:j.privateZone},VPC:j.vpc});return{hostedZone:J.HostedZone,nameServers:J.DelegationSet.NameServers,isNew:!0}}static getRootDomain(j){let k=j.replace(/\.$/,"").split(".");if(k.length<=2)return j;return k.slice(-2).join(".")}async findHostedZoneForDomain(j){let F=j.replace(/\.$/,"").split(".");for(let J=0;J<F.length-1;J++){let H=F.slice(J).join("."),K=await this.findHostedZoneByName(H);if(K)return K}return null}async ensureHostedZone(j){let k=await this.findOrCreateHostedZone({domainName:j.domainName,comment:j.comment});return{hostedZoneId:k.hostedZone.Id.replace("/hostedzone/",""),nameServers:k.nameServers,isNew:k.isNew,action:k.isNew?"created":"found"}}async setupDomainDns(j){let{domain:k,createIfNotExists:F=!0}=j,J=await this.findHostedZoneByName(k);if(J){let K=await this.getHostedZone({Id:J.Id});return{success:!0,hostedZoneId:J.Id.replace("/hostedzone/",""),nameServers:K.DelegationSet.NameServers,isNew:!1,message:`Found existing hosted zone for ${k}`}}if(!F)return{success:!1,hostedZoneId:null,nameServers:[],isNew:!1,message:`No hosted zone found for ${k} and createIfNotExists is false`};let H=await this.createHostedZone({Name:k,HostedZoneConfig:{Comment:`Created automatically by ts-cloud for ${k}`}});return{success:!0,hostedZoneId:H.HostedZone.Id.replace("/hostedzone/",""),nameServers:H.DelegationSet.NameServers,isNew:!0,message:`Created new hosted zone for ${k}. Please update your domain registrar with these name servers: ${H.DelegationSet.NameServers.join(", ")}`}}static CloudFrontHostedZoneId="Z2FDTNDATAQYW2";static S3WebsiteHostedZoneIds={"us-east-1":"Z3AQBSTGFYJSTF","us-east-2":"Z2O1EMRO9K5GLX","us-west-1":"Z2F56UZL2M1ACD","us-west-2":"Z3BJ6K6RIION7M","ap-east-1":"ZNB98KWMFR0R6","ap-south-1":"Z11RGJOFQNVJUP","ap-northeast-1":"Z2M4EHUR26P7ZW","ap-northeast-2":"Z3W03O7B5YMIYP","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"Z3O0J2DXBE1FTB","ap-southeast-2":"Z1WCIGYICN2BYD","ca-central-1":"Z1QDHH18159H29","eu-central-1":"Z21DNDUVLTQW6Q","eu-west-1":"Z1BKCTXD74EZPE","eu-west-2":"Z3GKZC51ZF0DB4","eu-west-3":"Z3R1K369G5AVDG","eu-north-1":"Z3BAZG2TWCNX0D","sa-east-1":"Z7KQH4QJS55SO"};static ALBHostedZoneIds={"us-east-1":"Z35SXDOTRQ7X7K","us-east-2":"Z3AADJGX6KTTL2","us-west-1":"Z368ELLRRE2KJ0","us-west-2":"Z1H1FL5HABSF5","ap-east-1":"Z3DQVH9N71FHZ0","ap-south-1":"ZP97RAFLXTNZK","ap-northeast-1":"Z14GRHDCWA56QT","ap-northeast-2":"ZWKZPGTI48KDX","ap-northeast-3":"Z5LXEBD8Y73MNV","ap-southeast-1":"Z1LMS91P8CMLE5","ap-southeast-2":"Z1GM3OXH4ZPM65","ca-central-1":"ZQSVJUPU6J1EY","eu-central-1":"Z215JYRZR1TBD5","eu-west-1":"Z32O12XQLNTSW2","eu-west-2":"ZHURV8PSTC4K8","eu-west-3":"Z3Q77PNBQS71R4","eu-north-1":"Z23TAZ6LKFMNIO","sa-east-1":"Z2P70J7HTTTPLU"};static APIGatewayHostedZoneIds={"us-east-1":"Z1UJRXOUMOOFQ8","us-east-2":"ZOJJZC49E0EPZ","us-west-1":"Z2MUQ32089INYE","us-west-2":"Z2OJLYMUO9EFXC","ap-east-1":"Z3FD1VL90ND7K5","ap-south-1":"Z3VO1THU9YC4UR","ap-northeast-1":"Z1YSHQZHG15GKL","ap-northeast-2":"Z20JF4UZKIW1U8","ap-northeast-3":"Z2YQB5RD63NC85","ap-southeast-1":"ZL327KTPIQFUL","ap-southeast-2":"Z2RPCDW04V8134","ca-central-1":"Z19DQILCV0OWEC","eu-central-1":"Z1U9ULNL0V5AJ3","eu-west-1":"ZLY8HYME6SFDD","eu-west-2":"ZJ5UAJN8Y3Z2Q","eu-west-3":"Z3KY65QIEKYHQQ","eu-north-1":"Z3UWIKFBOOGXPP","sa-east-1":"ZCMLWB8V5SYIT"}}
50
- export{Q as og};
@@ -1 +0,0 @@
1
- import{Oe as a,Pe as b,Qe as c,Re as d,Se as e,Te as f,Ue as g,Ve as h,We as i,Xe as j}from"./chunk-tj0xb2d8.js";import"./chunk-ett305ym.js";import"./chunk-3276rveh.js";import"./chunk-smbycpt5.js";import"./chunk-k5vprsef.js";import"./chunk-awa1qade.js";import"./chunk-4n0j3n3b.js";import"./chunk-f11xf3n6.js";import"./chunk-54bqchag.js";import"./chunk-xyt490vp.js";import"./chunk-5bhx3bsa.js";import"./chunk-c8sypnbe.js";export{a as sharedBoxProbeScript,e as serverLogSources,j as resolveServerDashboardData,i as resolveConfigOnlyServerDashboardData,g as parseServerSecurity,f as parseServerLogs,h as parseDeployHistory,c as parseBlock,b as metricsScript,d as mergeDiscoveredSites};
@@ -1 +0,0 @@
1
- import{fd as a}from"./chunk-mrm4m4dk.js";import"./chunk-xyt490vp.js";import"./chunk-c8sypnbe.js";export{a as STSClient};
@@ -1 +0,0 @@
1
- import{Hd as a}from"./chunk-b6by94pk.js";import"./chunk-xyt490vp.js";import"./chunk-c8sypnbe.js";export{a as SQSClient};
@@ -1,9 +0,0 @@
1
- import{Eh as Zj,Fh as $j}from"./chunk-5bhx3bsa.js";function XZ(j,Z){return`/var/www/${j}-${Z}`}var Lj=new Set(["laravel","php","statamic","wordpress"]);function zj(j){return j.type!=null&&Lj.has(j.type)}function Nj(j){let Z=j.proxyTo;if(Z==null)return[];return(Array.isArray(Z)?Z:[Z]).map((z)=>String(z).trim()).filter((z)=>z.length>0)}function Uj(j){return Nj(j).length>0}function Wj(j){if(j.deploy)return j.deploy;if(zj(j))return"server";if(j.start)return"server";return"bucket"}function _(j){if(j.redirect)return"redirect";if(Uj(j))return"proxy";if(zj(j))return"server-php";if(Wj(j)==="bucket")return"bucket";return j.start?"server-app":"server-static"}function kj(j){return j.infrastructure?.compute!=null||Boolean(j.cloud?.attachTo?.trim())}function JZ(j,Z={}){let $=[],z=[],J=j.sites||{},W=kj(j),q=$j(j);if(q)$.push(q);let w=new Map;for(let[x,X]of Object.entries(J)){if(!X)continue;let F=Wj(X),L=_(X);if(L==="redirect"){if(!X.domain)$.push(`Site '${x}' is a redirect site but has no \`domain\` to redirect from.`);if(!(typeof X.redirect==="string"?X.redirect:X.redirect?.to))$.push(`Site '${x}' is a redirect site but has no redirect target (\`redirect\` / \`redirect.to\`).`);if(!W)$.push(`Site '${x}' is a redirect site but no \`infrastructure.compute\` is configured to host the gateway that serves the redirect.`);let Q=[];if(X.start)Q.push("start");if(X.root)Q.push("root");if(X.proxyTo)Q.push("proxyTo");if(Q.length>0)z.push(`Site '${x}' is a redirect site but also sets ${Q.join(", ")}. These are ignored.`);continue}if(L==="proxy"){if(!X.domain)$.push(`Site '${x}' is a proxy site but has no \`domain\` to route from.`);if(!W)$.push(`Site '${x}' is a proxy site but no \`infrastructure.compute\` is configured to host the gateway that forwards it.`);let H=[];if(X.start)H.push("start");if(X.root)H.push("root");if(typeof X.port==="number")H.push("port");if(X.build)H.push("build");if(X.preStart&&X.preStart.length>0)H.push("preStart");if(H.length>0)z.push(`Site '${x}' sets \`proxyTo\`, so ts-cloud ships and supervises nothing for it. ${H.join(", ")} ${H.length===1?"is":"are"} ignored — remove ${H.length===1?"it":"them"}, or drop \`proxyTo\` to let ts-cloud own the service.`);continue}if(F==="server"&&!X.start&&!X.root){$.push(`Site '${x}' sets deploy:'server' but declares neither \`start\` (dynamic app) nor \`root\` (static site to serve). Add one.`);continue}if(L==="server-php"){if(!W)$.push(`Site '${x}' is a PHP site (type:'${X.type}') but no \`infrastructure.compute\` is configured. Add a server (infrastructure.compute) with PHP provisioning.`);if(!X.repository?.url)$.push(`Site '${x}' is a PHP site (type:'${X.type}') but has no \`repository.url\` to clone. PHP sites deploy via git.`)}else if(L==="server-app"){if(!W)$.push(`Site '${x}' deploys to a server (deploy:'server'${X.deploy?"":" inferred from `start`"}) but no \`infrastructure.compute\` is configured. Set deploy:'bucket' or add a server (infrastructure.compute).`);if(typeof X.port==="number"){let H=Z.occupiedPorts?.get(X.port);if(H)$.push(`Site '${x}' wants port ${X.port}, which project '${H}' already serves on this box. Attached projects share one port namespace. Give '${x}' a free port, or let the attach allocate one.`);let Q=w.get(X.port);if(Q)$.push(`Sites '${Q}' and '${x}' both use port ${X.port}. Server apps sharing a box must use distinct ports.`);else w.set(X.port,x)}}else if(L==="server-static"){if(!X.root)$.push(`Site '${x}' is a server static site (deploy:'server', no \`start\`) but has no \`root\` directory to serve.`);if(!W)$.push(`Site '${x}' deploys to a server (deploy:'server') but no \`infrastructure.compute\` is configured. Set deploy:'bucket' or add a server (infrastructure.compute).`)}else{if(!X.root)$.push(`Site '${x}' deploys to a bucket but has no \`root\` directory to upload.`);let H=[];if(X.start)H.push("start");if(typeof X.port==="number")H.push("port");if(X.preStart&&X.preStart.length>0)H.push("preStart");if(H.length>0)z.push(`Site '${x}' deploys to a bucket but sets server-only field(s): ${H.join(", ")}. These are ignored. Set deploy:'server' to use them.`)}}return{errors:$,warnings:z}}function QZ(j){let Z=_(j);return Z!=="bucket"&&Z!=="redirect"&&Z!=="proxy"}function qZ(j){return _(j)==="bucket"}function xZ(j,Z){if(Zj(j)==="serverless")return!0;let $=Object.entries(j.sites??{}).filter(([,J])=>J!=null),z=Z?$.filter(([J])=>J===Z):$;if(z.length===0)return!0;return!z.every(([,J])=>{let W=_(J);return W==="redirect"||W==="proxy"})}var P={php:"php.net",nginx:"nginx.org",composer:"getcomposer.org",mysql:"mysql.com",mariadb:"mariadb.com/server",postgres:"postgresql.org",vitess:"vitess.io",etcd:"etcd.io",redis:"redis.io",memcached:"memcached.org",meilisearch:"meilisearch.com",mail:"github.com/mail-os/mail",git:"git-scm.com",certbot:"certbot.eff.org",bun:"bun.sh",node:"nodejs.org",deno:"deno.land"};var f="/opt/pantry";function b(j){return`'${j.split("'").join("'\\''")}'`}function KZ(j={}){return["export DEBIAN_FRONTEND=noninteractive","export PANTRY_SERVICE_SCOPE=system","export PANTRY_INSTALL_DIR=/usr/local/bin",j.version?`export PANTRY_VERSION=${b(j.version)}`:'export PANTRY_VERSION="${PANTRY_VERSION:-latest}"',"command -v curl >/dev/null 2>&1 || (apt-get update -y && apt-get install -y curl ca-certificates)","command -v unzip >/dev/null 2>&1 || (apt-get update -y && apt-get install -y unzip)",'OS=$(uname -s | tr \'[:upper:]\' \'[:lower:]\'); ARCH=$(uname -m); case "$ARCH" in x86_64|amd64) ARCH=x64 ;; arm64|aarch64) ARCH=arm64 ;; esac; ZIP="pantry-${OS}-${ARCH}.zip"; if [ "${PANTRY_VERSION:-latest}" = latest ]; then REL=\'latest/download\'; else REL="download/v${PANTRY_VERSION}"; fi; TMP=$(mktemp -d); curl -fsSL -o "${TMP}/${ZIP}" "https://github.com/pantry-pm/pantry/releases/${REL}/${ZIP}"; unzip -o "${TMP}/${ZIP}" -d /usr/local/bin; chmod +x /usr/local/bin/pantry; rm -rf "${TMP}"','export PATH="/usr/local/bin:$PATH"',"mkdir -p /opt/pantry"]}function c(){return'eval "$(cd /opt/pantry && pantry env 2>/dev/null)" || true'}function A(j){if(j.length===0)return[];return[`(cd /opt/pantry && pantry install ${[...new Set(j)].map(b).join(" ")})`]}function Xj(j){return[...new Set(j)].flatMap((Z)=>[`(cd /opt/pantry && pantry start ${b(Z)})`,`(cd /opt/pantry && pantry enable ${b(Z)})`])}var M="/etc/mail",V="mail-server",d="mail",p=`${f}/pantry/.bin`;function D(j){return`'${String(j).split("'").join("'\\''")}'`}function N(j){return`"${j.replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}"`}function fj(j){return[j.version?`${P.mail}@${j.version}`:P.mail]}function r(j,Z){return`${M}/dkim/${Z}.${j.dkim.selector}.pem`}function Aj(j){let Z=["# Generated by ts-cloud. Edits are overwritten on the next deploy —","# change `services.mail` in the cloud config instead.","","[server]",`host = ${N(j.bindAddress)}`,`port = ${j.ports.smtp}`,`hostname = ${N(j.hostname)}`];if(j.domains.length>0)Z.push(`local_domains = ${N(j.domains.join(", "))}`);if(j.mode==="catcher")Z.push("catch_all = true");if(Z.push(`max_message_size = ${j.maxMessageSize}`,"","[tls]",`enabled = ${j.tls.enabled}`),j.tls.certPath)Z.push(`cert_path = ${N(j.tls.certPath)}`);if(j.tls.keyPath)Z.push(`key_path = ${N(j.tls.keyPath)}`);if(Z.push("","[auth]",`enabled = ${j.mode==="server"}`,"","[antispam]",`dnsbl = ${j.spam.dnsbl}`,`greylist = ${j.spam.greylist}`,`spam_filter = ${j.spam.enabled}`,`junk_score = ${j.spam.junkScore}`,`reject_score = ${j.spam.rejectScore}`,"","[dkim]",`rotation_enabled = ${j.dkim.enabled&&j.dkim.rotate}`,`rotation_interval_days = ${j.dkim.rotateIntervalDays}`,"","[acme]",`enabled = ${j.tls.acme}`),j.tls.acmeEmail)Z.push(`email = ${N(j.tls.acmeEmail)}`);if(Z.push("","[webhook]",`enabled = ${!!j.webhookUrl}`),j.webhookUrl)Z.push(`url = ${N(j.webhookUrl)}`);return Z.push(""),Z.join(`
2
- `)}function vj(j){let Z=["# Generated by ts-cloud. See /etc/mail/config.toml for the rest.",`SMTP_DB_PATH=${j.storagePath}/mail.db`,`SMTP_DELIVERY_METHOD=${j.delivery==="ses"?"ses":"direct"}`];if(j.delivery==="ses")Z.push(`SMTP_SES_REGION=${j.sesRegion}`);if(j.ports.submission)Z.push(`SUBMISSION_PORT=${j.ports.submission}`);if(j.ports.submissions)Z.push(`SMTPS_PORT=${j.ports.submissions}`);if(j.ports.imap)Z.push("IMAP_ENABLED=1",`IMAP_PORT=${j.ports.imap}`);if(j.webmail.enabled)Z.push("SMTP_ENABLE_WEBMAIL=true",`SMTP_WEBMAIL_PORT=${j.webmail.port}`,`SMTP_WEBMAIL_SECURE_COOKIES=${j.tls.enabled}`);if(j.tls.requireForAuth)Z.push("SMTP_REQUIRE_TLS_FOR_AUTH=true");if(j.dkim.enabled&&j.domains.length>0){let[$,...z]=j.domains;if(Z.push(`DKIM_DOMAIN=${$}`,`DKIM_SELECTOR=${j.dkim.selector}`,`DKIM_PRIVATE_KEY_PATH=${r(j,$)}`),z.length>0){let J=z.map((W)=>`${W}:${j.dkim.selector}:${r(j,W)}`);Z.push(`DKIM_EXTRA_KEYS=${J.join(",")}`)}}return Z.push(""),Z.join(`
3
- `)}function Rj(j){let Z=[j.ports.smtp,j.ports.submission,j.ports.submissions,j.ports.imap,j.ports.imaps].some(($)=>typeof $==="number"&&$<1024);return["[Unit]","Description=Mail server (SMTP/IMAP + webmail)","After=network-online.target","Wants=network-online.target","","[Service]","Type=simple",`User=${V}`,`Group=${V}`,`WorkingDirectory=${j.storagePath}`,`EnvironmentFile=${M}/mail.env`,`Environment="PATH=${p}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"`,`ExecStart=${p}/mail serve --config ${M}/config.toml`,"Restart=always","RestartSec=5","LimitNOFILE=65536",...Z?["AmbientCapabilities=CAP_NET_BIND_SERVICE","CapabilityBoundingSet=CAP_NET_BIND_SERVICE"]:[],"NoNewPrivileges=true","PrivateTmp=true","ProtectSystem=strict","ProtectHome=true","ProtectKernelTunables=true","ProtectKernelModules=true","ProtectControlGroups=true",`ReadWritePaths=${j.storagePath} ${M}`,"","[Install]","WantedBy=multi-user.target",""].join(`
4
- `)}function Ej(j){if(!j.dkim.enabled||j.domains.length===0)return[];let Z=[`mkdir -p ${M}/dkim`];for(let $ of j.domains){let z=r(j,$);Z.push(`if [ ! -f ${D(z)} ]; then openssl genrsa -out ${D(z)} 2048; fi`,`chmod 0600 ${D(z)}`,`echo "DKIM ${j.dkim.selector}._domainkey.${$} IN TXT v=DKIM1; k=rsa; p=$(openssl rsa -in ${D(z)} -pubout -outform PEM 2>/dev/null | grep -v '^-----' | tr -d '\\n')"`)}return Z.push(`chown -R ${V}:${V} ${M}/dkim`),Z}function Pj(j){if(j.accounts.length===0)return[];let Z=($)=>`runuser -u ${V} -- env SMTP_DB_PATH=${D(`${j.storagePath}/mail.db`)} ${p}/mail user:local ${$} || true`;return j.accounts.flatMap(($)=>[Z(`create ${D($.address)} ${D($.password)} ${D($.address)}`),Z(`change-password ${D($.address)} ${D($.password)}`)])}function Jj(j){if(!j.enabled)return[];return[...A(fj(j)),`id -u ${V} >/dev/null 2>&1 || useradd --system --no-create-home --shell /usr/sbin/nologin ${V}`,`mkdir -p ${j.storagePath} ${M}`,`chown -R ${V}:${V} ${j.storagePath}`,`cat > ${M}/config.toml <<'TS_CLOUD_MAIL_CONF_EOF'`,Aj(j),"TS_CLOUD_MAIL_CONF_EOF",`cat > ${M}/mail.env <<'TS_CLOUD_MAIL_ENV_EOF'`,vj(j),"TS_CLOUD_MAIL_ENV_EOF",`chmod 0640 ${M}/mail.env`,`chown root:${V} ${M}/mail.env`,...Ej(j),`cat > /etc/systemd/system/${d}.service <<'TS_CLOUD_MAIL_UNIT_EOF'`,Rj(j),"TS_CLOUD_MAIL_UNIT_EOF","systemctl daemon-reload",`systemctl enable ${d}`,`systemctl restart ${d}`,...Pj(j)]}var B=`${f}/pantry/.bin`,n=15306,l=15991,u=15999,Qj=16101,g=2379,C="/var/lib/vitess",t=100;function yj(j){return j===!0||typeof j==="object"&&j!==null}function Ij(j){return typeof j==="object"&&j!==null?j:{}}function Y(j){return`'${String(j).split("'").join("'\\''")}'`}function Sj(j){let $=[j.version?`vitess.io@${j.version}`:"vitess.io"];if(j.mode!=="combo"&&!j.etcdEndpoint)$.push("etcd.io");return $.push("mysql.com@8.0.43"),$}var G="vitess",Tj=`${B}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`,Kj="/usr/local/lib/vitess",i=new Map;function o(j){return`${Kj}/${j}.sh`}function v(j,Z){return i.set(j,_j(Z)),`/bin/sh ${o(j)}`}function qj(){let j=[`mkdir -p ${Kj}`];for(let[Z,$]of i)j.push(`cat > ${o(Z)} <<'TS_CLOUD_VITESS_LAUNCHER_EOF'`,$,"TS_CLOUD_VITESS_LAUNCHER_EOF",`chmod 0755 ${o(Z)}`);return j}function _j(j){return["#!/bin/sh","set -e",`cd ${f}`,`PANTRY_ENV="$(pantry env 2>/dev/null | grep -E '^(export [A-Za-z_]|[A-Za-z_][A-Za-z0-9_]*=)' || true)"`,'if [ -n "$PANTRY_ENV" ]; then eval "$PANTRY_ENV"; fi',`VT_MYSQL_ROOT="$(dirname "$(dirname "$(readlink -f ${B}/mysqld 2>/dev/null)")")"`,`VTROOT="$(dirname "$(dirname "$(readlink -f ${B}/mysqlctld 2>/dev/null)")")"`,"export VT_MYSQL_ROOT VTROOT",'LD_LIBRARY_PATH="$VT_MYSQL_ROOT/lib:$VTROOT/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"',"export LD_LIBRARY_PATH",`exec ${j.join(" ")}`].join(`
5
- `)}function R(j){let Z=["[Unit]",`Description=${j.description}`,`After=network.target${j.after?.length?` ${j.after.join(" ")}`:""}`];if(j.requires?.length)Z.push(`Requires=${j.requires.join(" ")}`);return Z.push("","[Service]","Type=simple",`User=${G}`,`Group=${G}`,`Environment="PATH=${Tj}"`,`Environment="VTDATAROOT=${C}"`,...Object.entries(j.environment??{}).map(([$,z])=>`Environment="${$}=${z}"`),...(j.execStartPre??[]).map(($)=>`ExecStartPre=${$}`),`ExecStart=${j.execStart}`,"Restart=always","RestartSec=5","LimitNOFILE=65535","","[Install]","WantedBy=multi-user.target"),Z.join(`
6
- `)}function xj(j,Z){return[`cat > /etc/systemd/system/${j}.service <<'TS_CLOUD_VITESS_UNIT_EOF'`,Z,"TS_CLOUD_VITESS_UNIT_EOF"]}function bj(j){let Z=j.cell??"zone1",$=j.vtgatePort??n,J=`${((j.keyspaces?.length)?j.keyspaces:[{name:"app"}]).map((W)=>{let q=(W.sharded?["-80","80-"]:["0"]).map((w)=>`shards:{name:"${w}"}`).join(" ");return`keyspaces:{name:"${W.name}" ${q}}`}).join(" ")} cells:"${Z}"`;return R({description:"Vitess (vtcombo, single-process development stack)",execStart:v("vtcombo",[`${B}/vtcombo`,`--cell ${Z}`,`--proto-topo ${Y(J)}`,`--mysql-server-port ${$}`,"--mysql-server-bind-address 127.0.0.1","--mysql-auth-server-impl none","--start-mysql",`--port ${l}`,`--grpc-port ${u}`])})}function uj(){return R({description:"etcd (Vitess topology store)",execStart:v("etcd",[`${B}/etcd`,`--data-dir ${C}/etcd`,`--listen-client-urls http://127.0.0.1:${g}`,`--advertise-client-urls http://127.0.0.1:${g}`]),execStartPre:[`+/bin/mkdir -p ${C}/etcd`,`+/bin/chown ${G}:${G} ${C}/etcd`]})}function s(j){return["--topo-implementation etcd2",`--topo-global-server-address ${j.etcdEndpoint??`http://127.0.0.1:${g}`}`,"--topo-global-root /vitess/global"]}function gj(j){let Z=!j.etcdEndpoint;return R({description:"Vitess vtctld (control plane)",after:Z?["vitess-etcd.service"]:[],requires:Z?["vitess-etcd.service"]:[],execStart:v("vtctld",[`${B}/vtctld`,...s(j),`--cell ${j.cell??"zone1"}`,"--service-map grpc-vtctl,grpc-vtctld",`--grpc-port ${u}`,`--port ${u+1}`])})}function hj(j,Z,$){let z=j.cell??"zone1";return R({description:`Vitess vttablet (${Z}/${$})`,after:["vitess-vtctld.service","vitess-mysqlctld.service"],requires:["vitess-mysqlctld.service"],execStart:v("vttablet",[`${B}/vttablet`,...s(j),`--tablet-path ${z}-${String(t).padStart(10,"0")}`,`--init-keyspace ${Z}`,`--init-shard ${$}`,"--init-tablet-type replica",`--service-map ${Y("grpc-queryservice,grpc-tabletmanager,grpc-updatestream")}`,`--port ${Qj}`,`--grpc-port ${Qj+1}`,`--db-port ${j.mysqlPort??3306}`,`--mycnf-mysql-port ${j.mysqlPort??3306}`])})}function mj(j){return R({description:"Vitess mysqlctld (managed mysqld)",execStart:v("mysqlctld",[`${B}/mysqlctld`,`--tablet-uid ${t}`,`--mysql-port ${j.mysqlPort??3306}`,'--init-db-sql-file "$VTROOT/config/init_db.sql"',"--wait-time 2m"]),execStartPre:[`+/bin/mkdir -p ${C}`,`+/bin/chown ${G}:${G} ${C}`]})}var wj="/etc/vitess/auth.json",y="/var/lib/vitess/vtgate-auth.sha256";function cj(j){let Z=j.username??"vitess",$=j.password??"";return["mkdir -p /etc/vitess",'VTESS_AUTH_TMP="$(mktemp)"',`cat > "$VTESS_AUTH_TMP" <<'TS_CLOUD_VITESS_AUTH_EOF'`,JSON.stringify({[Z]:[{Password:$,UserData:Z}]}),"TS_CLOUD_VITESS_AUTH_EOF",`VTESS_VTGATE_AUTH_SHA="$(sha256sum "$VTESS_AUTH_TMP" | awk '{print $1}')"`,"VTESS_VTGATE_AUTH_CHANGED=1",`if [ -f ${y} ] && [ "$(cat ${y})" = "$VTESS_VTGATE_AUTH_SHA" ]; then VTESS_VTGATE_AUTH_CHANGED=0; fi`,`install -o ${G} -g ${G} -m 0600 "$VTESS_AUTH_TMP" ${wj}`,'rm -f "$VTESS_AUTH_TMP"']}function dj(j){let Z=j.cell??"zone1";return R({description:"Vitess vtgate (query router)",after:["vitess-vtctld.service"],execStart:v("vtgate",[`${B}/vtgate`,...s(j),`--cell ${Z}`,`--cells-to-watch ${Z}`,"--tablet-types-to-wait PRIMARY,REPLICA",`--service-map ${Y("grpc-vtgateservice")}`,`--mysql-server-port ${j.vtgatePort??n}`,`--mysql-server-bind-address ${j.bindAddress??"127.0.0.1"}`,"--mysql-auth-server-impl static",`--mysql-auth-server-static-file ${wj}`,`--port ${l}`,`--grpc-port ${l+1}`])})}function pj(j){let Z=j.cell??"zone1",$=j.etcdEndpoint??`http://127.0.0.1:${g}`,z=`${B}/vtctldclient --server 127.0.0.1:${u}`,J=[`for i in $(seq 1 30); do ${z} GetCellInfoNames >/dev/null 2>&1 && break; sleep 2; done`,`if ! ${z} GetCellInfoNames 2>/dev/null | grep -qx ${Y(Z)}; then`,` ${z} AddCellInfo --root ${Y(`/vitess/${Z}`)} --server-address ${Y($)} ${Y(Z)}`,"fi"];for(let W of j.keyspaces??[]){let q=W.sharded?" --sharded":"";J.push(`if ! ${z} GetKeyspace ${Y(W.name)} >/dev/null 2>&1; then`,` ${z} CreateKeyspace${q} ${Y(W.name)}`,"fi");let w=`${Z}-${String(t).padStart(10,"0")}`;for(let x of W.sharded?["-80","80-"]:["0"]){let X=`${W.name}/${x}`;J.push("for i in $(seq 1 90); do",` if ${z} GetShard ${Y(X)} 2>/dev/null | grep -q '"is_primary_serving": *true'; then break; fi`,` ${z} PlannedReparentShard ${Y(X)} --new-primary ${Y(w)} >/dev/null 2>&1 && break`,` ${z} InitShardPrimary --force ${Y(X)} ${Y(w)} >/dev/null 2>&1 && break`," sleep 2","done",`if ! ${z} GetShard ${Y(X)} 2>/dev/null | grep -q '"is_primary_serving": *true'; then`,` echo "no primary could be elected for ${X}" >&2; exit 1`,"fi")}J.push(`${z} RebuildKeyspaceGraph ${Y(W.name)} >/dev/null`)}return J}function Hj(j){let Z=j.vtgatePort??n;return["for i in $(seq 1 60); do",` if (cd ${f} && eval "$(pantry env 2>/dev/null)"; MYSQL_PWD=${Y(j.password??"")} ${B}/mysql -h 127.0.0.1 -P ${Z} -u ${Y(j.username??"vitess")} --connect-timeout=2 -e 'SHOW KEYSPACES') >/dev/null 2>&1; then`,` echo "vtgate is serving on ${Z}"; exit 0`," fi"," sleep 2","done",`echo "vtgate did not become ready on port ${Z}" >&2`,"exit 1"]}function Yj(j){if(!yj(j))return[];let Z=Ij(j),$=Z.mode==="combo";i.clear();let z=[...A(Sj(Z)),`VT_MYSQL_LIB="$(dirname "$(dirname "$(readlink -f ${B}/mysqld)")")/lib"`,'if [ -d "$VT_MYSQL_LIB" ]; then',` printf '%s\\n' "$VT_MYSQL_LIB" > /etc/ld.so.conf.d/vitess-mysql.conf`," ldconfig","else",' echo "mysqld library directory not found under $VT_MYSQL_LIB" >&2; exit 1',"fi",`id -u ${G} >/dev/null 2>&1 || useradd --system --home-dir ${C} --shell /usr/sbin/nologin ${G}`,`mkdir -p ${C}`,`chown -R ${G}:${G} ${C}`];if($)return z.push(...xj("vitess-vtcombo",bj(Z)),...qj(),"systemctl daemon-reload","systemctl enable --now vitess-vtcombo.service",...Hj(Z)),z;z.push(...cj(Z));let J=[];if(!Z.etcdEndpoint)J.push(["vitess-etcd",uj()]);J.push(["vitess-vtctld",gj(Z)],["vitess-mysqlctld",mj(Z)],["vitess-vtgate",dj(Z)]);for(let W of Z.keyspaces??[])for(let q of W.sharded?["-80","80-"]:["0"])J.push([`vitess-vttablet-${W.name}-${q.replace(/-/g,"x")}`,hj(Z,W.name,q)]);for(let[W,q]of J)z.push(...xj(W,q));z.push(...qj()),z.push("systemctl daemon-reload");for(let[W]of J)z.push(`systemctl enable --now ${W}.service`);return z.push(`if [ "$VTESS_VTGATE_AUTH_CHANGED" = 1 ]; then systemctl restart vitess-vtgate.service; printf '%s\\n' "$VTESS_VTGATE_AUTH_SHA" > ${y}; chown ${G}:${G} ${y}; chmod 0600 ${y}; fi`,...pj(Z),...Hj(Z)),z}var rj=new Set(["singlestore","vitess"]);function Gj(j){if(j?.engine&&rj.has(j.engine))return!1;return!j?.host||j.host==="127.0.0.1"||j.host==="localhost"}function e(j,Z="psql"){let $=j?.port??5432;if(Gj(j))return`${Z} -p ${$} -U postgres`;let z=j?.username||"postgres";return`${j?.password?`PGPASSWORD='${j.password.replace(/'/g,"'\\''")}' `:""}${Z} -h ${j.host} -p ${$} -U ${z} -w`}function O(j){return j===!0||typeof j==="object"&&j!=null}function lj(j){let Z=[],$=[];if(O(j.mysql))Z.push(typeof j.mysql==="object"&&j.mysql.version?`mysql.com@${j.mysql.version}`:"mysql.com@8.0.43"),$.push("mysql");else if(O(j.mariadb))Z.push(P.mariadb),$.push("mariadb");if(O(j.postgres))Z.push("postgresql.org"),$.push("postgres");if(O(j.redis))Z.push("redis.io"),$.push("redis");if(O(j.memcached))Z.push("memcached.org"),$.push("memcached");if(O(j.meilisearch))Z.push("meilisearch.com"),$.push("meilisearch");return{packages:Z,services:$}}function NZ(j={},Z={}){let $=lj(j),z=Yj(j.vitess),J=Z.mail?Jj(Z.mail):[];if($.packages.length===0)return[...z,...J];return[...A($.packages),...Xj($.services),...z,...J]}function UZ(j,Z={}){if(!j?.name)return[];if(!Gj(j))return[];let $=j.name,z=j.username||$,J=j.password||"",W=O(Z.postgres)||j.engine==="postgres",q=O(Z.mariadb)||j.engine==="mariadb",w=O(Z.mysql)||j.engine==="mysql";if(W&&!w&&!q){let Q=(K)=>`"${K.replace(/"/g,'""')}"`,k=(K)=>`'${K.replace(/'/g,"''")}'`,E=(K,T)=>["DO $$ BEGIN",` IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = ${k(K)}) THEN`,` CREATE ROLE ${Q(K)} LOGIN PASSWORD ${k(T)};`," ELSE",` ALTER ROLE ${Q(K)} LOGIN PASSWORD ${k(T)};`," END IF;","END $$;"],I=(K)=>{let T=K.databases&&K.databases.length>0?K.databases:[$],h=[];for(let m of T)if(K.access==="readonly")h.push(`GRANT CONNECT ON DATABASE ${Q(m)} TO ${Q(K.username)};`,`\\connect ${Q(m)}`,`GRANT USAGE ON SCHEMA public TO ${Q(K.username)};`,`GRANT SELECT ON ALL TABLES IN SCHEMA public TO ${Q(K.username)};`,`ALTER DEFAULT PRIVILEGES FOR ROLE ${Q(z)} IN SCHEMA public GRANT SELECT ON TABLES TO ${Q(K.username)};`,"\\connect postgres");else h.push(`GRANT ALL PRIVILEGES ON DATABASE ${Q(m)} TO ${Q(K.username)};`);return h},S=j.users||[],Oj=j.port??5432;return[c(),`for i in $(seq 1 30); do pg_isready -p ${Oj} -q && break; sleep 2; done`,`${e(j)} <<'TS_CLOUD_PG_EOF'`,...E(z,J),`SELECT 'CREATE DATABASE ${Q($)} OWNER ${Q(z)}' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = ${k($)})\\gexec`,...S.flatMap((K)=>[...E(K.username,K.password),...I(K)]),"TS_CLOUD_PG_EOF"]}let x=q?"/var/lib/pantry/mariadb/mariadbd.sock":"/var/lib/pantry/mysql/mysqld.sock",X=(Q)=>Q.replace(/`/g,"``"),F=(Q)=>Q.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),L=(Q)=>{let k=Q.databases&&Q.databases.length>0?Q.databases:[$],E=Q.access==="readonly"?"SELECT":"ALL PRIVILEGES",I=[`CREATE USER IF NOT EXISTS '${F(Q.username)}'@'%' IDENTIFIED BY '${F(Q.password)}';`,`CREATE USER IF NOT EXISTS '${F(Q.username)}'@'localhost' IDENTIFIED BY '${F(Q.password)}';`,`ALTER USER '${F(Q.username)}'@'%' IDENTIFIED BY '${F(Q.password)}';`,`ALTER USER '${F(Q.username)}'@'localhost' IDENTIFIED BY '${F(Q.password)}';`];for(let S of k)I.push(`GRANT ${E} ON \`${X(S)}\`.* TO '${F(Q.username)}'@'%';`,`GRANT ${E} ON \`${X(S)}\`.* TO '${F(Q.username)}'@'localhost';`);return I},H=j.users||[];return[c(),`for i in $(seq 1 30); do mysqladmin --socket=${x} -u root ping 2>/dev/null | grep -q alive && break; sleep 2; done`,`mysql --socket=${x} -u root <<'TS_CLOUD_SQL_EOF'`,`CREATE DATABASE IF NOT EXISTS \`${X($)}\` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`,...L({username:z,password:J}),...H.flatMap(L),"FLUSH PRIVILEGES;","TS_CLOUD_SQL_EOF"]}function kZ(j){if(!j?.name)return{};let Z=j.engine==="singlestore",$=j.engine==="vitess",z=j.engine==="postgres"?"pgsql":Z?"singlestore":$?"vitess":"mysql",J=j.port??(j.engine==="postgres"?5432:$?15306:3306),W={DB_CONNECTION:z,DB_HOST:j.host||"127.0.0.1",DB_PORT:String(J),DB_DATABASE:j.name};if(j.username)W.DB_USERNAME=j.username;if(j.password)W.DB_PASSWORD=j.password;if((Z||$)&&j.ssl!==!1)W.DB_SSL="true";return W}var jj="/var/backups/ts-cloud",oj="/etc/ts-cloud/backups.config.ts",Fj="/etc/cron.d/ts-cloud-backups",a="/usr/local/bin/ts-cloud-backup.sh";function nj(j){if(!j.name)return null;let Z=j.host||"127.0.0.1",$=j.engine==="postgres",z=$?"postgresql":"mysql",J=j.port??($?5432:3306),W=(q)=>q.replace(/\\/g,"\\\\").replace(/'/g,"\\'");return[" {",` type: '${z}',`,` name: '${W(j.name)}',`," connection: {",` hostname: '${W(Z)}',`,` port: ${J},`,` database: '${W(j.name)}',`,` username: '${W(j.username||j.name)}',`,` password: '${W(j.password||"")}',`," ssl: false,"," },"," includeSchema: true,"," includeData: true,"," },"].join(`
7
- `)}function tj(j,Z){let $=j?nj(j):null,z=Z.bucket?[" destinations: ["," {"," type: 's3',",` bucket: '${Z.bucket}',`," prefix: 'db-backups',",...Z.endpoint?[` endpoint: '${Z.endpoint}',`]:[]," optional: false,"," },"," ],"]:[];return["import type { BackupConfig } from 'ts-backups'","","const config: BackupConfig = {"," verbose: true,",` outputPath: '${jj}',`," retention: {",` count: ${Z.retentionCount??5},`,` maxAge: ${Z.retentionDays??30},`," },"," databases: [",...$?[$]:[]," ],",...z,"}","","export default config",""].join(`
8
- `)}function vZ(j){let{database:Z,backups:$}=j;if(!$.enabled)return[];let z=$.schedule||"0 2 * * *",J=tj(Z,$);return["export DEBIAN_FRONTEND=noninteractive",`mkdir -p /etc/ts-cloud ${jj}`,"command -v bun >/dev/null 2>&1 || (curl -fsSL https://bun.sh/install | bash && ln -sf /root/.bun/bin/bun /usr/local/bin/bun)","bun add -g ts-backups || true",`cat > ${oj} <<'TS_CLOUD_BACKUP_CFG_EOF'`,J.replace(/\n$/,""),"TS_CLOUD_BACKUP_CFG_EOF",`cat > ${a} <<'TS_CLOUD_BACKUP_RUN_EOF'`,"#!/bin/bash","set -uo pipefail",'export PATH="/root/.bun/bin:/usr/local/bin:$PATH"','notify() { [ -x /usr/local/bin/ts-cloud-notify ] && /usr/local/bin/ts-cloud-notify "$1" || true; }',"cd /etc/ts-cloud",'if ! ts-backups backup --config /etc/ts-cloud/backups.config.ts; then notify "❌ ts-cloud backup failed"; exit 1; fi',"TS_CLOUD_BACKUP_RUN_EOF",`chmod +x ${a}`,`cat > ${Fj} <<'TS_CLOUD_BACKUP_CRON_EOF'`,`${z} root ${a} >> /var/log/ts-cloud-backup.log 2>&1`,"TS_CLOUD_BACKUP_CRON_EOF",`chmod 644 ${Fj}`]}function ij(j){return j==="mariadb"?"/var/lib/pantry/mariadb/mariadbd.sock":"/var/lib/pantry/mysql/mysqld.sock"}function RZ(j,Z={}){if(!j?.name)return[];let $=j.name,z=j.engine==="postgres",J=Z.from?`TS_CLOUD_DUMP="${Z.from}"`:`TS_CLOUD_DUMP="$(find ${jj} -type f -name '*${$}*.sql' -o -type f -name '*${$}*.sql.gz' 2>/dev/null | xargs -r ls -1t 2>/dev/null | head -1)"`,W=z?`${e(j)} -d "${$}"`:`mysql --socket=${ij(j.engine)} -u root "${$}"`;return["set -uo pipefail",'eval "$(cd /opt/pantry && pantry env 2>/dev/null)" || true',J,'[ -n "$TS_CLOUD_DUMP" ] && [ -f "$TS_CLOUD_DUMP" ] || { echo "no backup dump found to restore" >&2; exit 1; }','echo "[ts-cloud] restoring '+$+' from $TS_CLOUD_DUMP"',`case "$TS_CLOUD_DUMP" in *.gz) gunzip -c "$TS_CLOUD_DUMP" ;; *) cat "$TS_CLOUD_DUMP" ;; esac | ${W}`,'echo "restore complete"']}var Mj=["storage",".env"],PZ=4;function U(j){return`${j.replace(/\/+$/,"")}/.ts-cloud`}function sj(j){return`${U(j)}/deploy-history.log`}function ej(j,Z){return`${U(j)}/deploys/${Z}.log`}function Dj(j){return`${U(j)}/shared-paths`}function yZ(j,Z){let $=j.replace(/\/+$/,"");return{base:$,releases:`${$}/releases`,shared:`${$}/shared`,current:`${$}/current`,release:`${$}/releases/${Z}`}}function Vj(j){let Z=j.split("/").pop()||j;if(Z===".env"||Z.startsWith(".env."))return!0;return/\.[a-z0-9]+$/i.test(Z)}function aj(j){return typeof j==="string"?j:j.path}function IZ(j){let Z=new Map;for(let $ of j)Z.set(aj($),$);return[...Z.values()]}function Cj(j,Z){if(typeof Z==="string")return{path:Z,target:`${j.shared}/${Z}`,seed:!0};return{path:Z.path,target:Z.target??`${j.shared}/${Z.path}`,seed:Z.seed!==!1}}function jZ(j){return["ts_cloud_adopt_shared() {",' TS_CLOUD_SP="$1"',' TS_CLOUD_DST="$2"',` TS_CLOUD_SRC="${j.current}/$TS_CLOUD_SP"`,' if [ -e "$TS_CLOUD_DST" ]; then return 0; fi',' if [ -L "$TS_CLOUD_SRC" ] || [ ! -e "$TS_CLOUD_SRC" ]; then return 0; fi',' mkdir -p "$(dirname "$TS_CLOUD_DST")"',' cp -a "$TS_CLOUD_SRC" "$TS_CLOUD_DST"'," for TS_CLOUD_SIDECAR in -wal -shm; do",' if [ -f "$TS_CLOUD_SRC$TS_CLOUD_SIDECAR" ]; then cp -a "$TS_CLOUD_SRC$TS_CLOUD_SIDECAR" "$TS_CLOUD_DST$TS_CLOUD_SIDECAR"; fi'," done",' echo "[ts-cloud] adopted $TS_CLOUD_SP from the live release into shared/ — it now survives deploys"'," return 0","}"]}function SZ(j,Z=Mj){let $=[`mkdir -p ${j.releases} ${j.shared}`,...jZ(j)],z=Z.map((W)=>Cj(j,W));for(let{path:W,target:q,seed:w}of z){if(!w)continue;if($.push(`ts_cloud_adopt_shared '${W}' '${q}'`),Vj(W))$.push(`mkdir -p "$(dirname ${q})"`,`touch ${q}`);else if(W==="storage")$.push(`mkdir -p ${q}/app/public`,`mkdir -p ${q}/framework/cache/data`,`mkdir -p ${q}/framework/sessions`,`mkdir -p ${q}/framework/testing`,`mkdir -p ${q}/framework/views`,`mkdir -p ${q}/logs`);else $.push(`mkdir -p ${q}`)}let J=Dj(j.base);return $.push(`mkdir -p ${U(j.base)}`,`cat > ${J} <<'TS_CLOUD_SHARED_PATHS_EOF'`,...z.map((W)=>`${W.path} ${W.target}`),"TS_CLOUD_SHARED_PATHS_EOF"),$}function TZ(j,Z=900){let $=`${U(j.base)}/deploy.lock`;return[`mkdir -p "$(dirname ${$})"`,`exec 9>${$}`,`flock -w ${Z} 9 || { echo "[ts-cloud] another deploy of this site has held the lock for ${Z}s — refusing to race it" >&2; exit 1; }`]}function _Z(j){let Z=`${j.release}.incoming`;return[`rm -rf ${Z}`,`mkdir -p ${Z}`,...ZZ(j),'if [ "$TS_CLOUD_IS_LIVE" = "yes" ]; then',` TS_CLOUD_STAGED=${Z}`,"else",` rm -rf ${j.release}`,` mkdir -p ${j.release}`,` rmdir ${Z}`,` TS_CLOUD_STAGED=${j.release}`,"fi"]}function bZ(j){let Z=`TS_CLOUD_TRAP_LIVE="$(readlink -f ${j.current} 2>/dev/null || true)"`,$=`TS_CLOUD_TRAP_TARGET="$(readlink -f ${j.release} 2>/dev/null || echo ${j.release})"`;return`trap '${`if [ $? -ne 0 ]; then ${Z}; ${$}; [ "$TS_CLOUD_TRAP_LIVE" = "$TS_CLOUD_TRAP_TARGET" ] || rm -rf ${j.release}; fi`}' EXIT`}function ZZ(j){return[`TS_CLOUD_LIVE_PATH="$(readlink -f ${j.current} 2>/dev/null || true)"`,`TS_CLOUD_RELEASE_PATH="$(readlink -f ${j.release} 2>/dev/null || echo ${j.release})"`,'if [ -n "$TS_CLOUD_LIVE_PATH" ] && [ "$TS_CLOUD_LIVE_PATH" = "$TS_CLOUD_RELEASE_PATH" ]; then TS_CLOUD_IS_LIVE=yes; else TS_CLOUD_IS_LIVE=no; fi']}function uZ(j){let Z=`${j.release}.incoming`;return[`if [ "$TS_CLOUD_STAGED" = "${Z}" ]; then`,` rm -rf ${j.release}.previous`,` mv ${j.release} ${j.release}.previous`,` mv ${Z} ${j.release}`,` rm -rf ${j.release}.previous`,"fi"]}function $Z(j,Z){return[`if [ -f ${j} ] && [ ! -L ${j} ] && [ -s ${j} ] && [ ! -s ${Z} ]; then`,` cp -a ${j} ${Z}`,` echo "[ts-cloud] seeded shared/ from the release's own copy of the file"`,"fi"]}function gZ(j,Z=Mj){let $=[];for(let z of Z){let{path:J,target:W,seed:q}=Cj(j,z),w=`${j.release}/${J}`,x=[`rm -rf ${w}`,`mkdir -p "$(dirname ${w})"`,`ln -sfn ${W} ${w}`];if(q){if(J!==".env"&&Vj(J))$.push(...$Z(w,W));$.push(...x);continue}$.push(`if [ -e ${W} ]; then`,...x.map((X)=>` ${X}`),"fi")}return $}function Bj(j,Z){let $=Dj(j.base);return[`if [ -f ${$} ]; then`,' while IFS="\t" read -r TS_CLOUD_SP TS_CLOUD_TGT; do',' [ -n "$TS_CLOUD_SP" ] || continue',` [ -n "$TS_CLOUD_TGT" ] || TS_CLOUD_TGT="${j.shared}/$TS_CLOUD_SP"`,' [ -e "$TS_CLOUD_TGT" ] || continue',` rm -rf ${Z}/"$TS_CLOUD_SP"`,` mkdir -p "$(dirname ${Z}/"$TS_CLOUD_SP")"`,` ln -sfn "$TS_CLOUD_TGT" ${Z}/"$TS_CLOUD_SP"`,` done < ${$}`,"fi"]}function hZ(j){return[`ln -sfn ${j.release} ${j.current}.tmp`,`mv -Tf ${j.current}.tmp ${j.current}`]}function mZ(j,Z={}){let $=Z.to?[`[ -d ${j.releases}/${Z.to} ] || { echo "rollback target ${j.releases}/${Z.to} not found" >&2; exit 1; }`,...Bj(j,`${j.releases}/${Z.to}`),`ln -sfn ${j.releases}/${Z.to} ${j.current}.tmp`,`mv -Tf ${j.current}.tmp ${j.current}`]:[`TS_CLOUD_CURRENT=$(readlink -f ${j.current} 2>/dev/null || true)`,`TS_CLOUD_PREV=$(ls -1dt ${j.releases}/*/ 2>/dev/null | sed 's#/$##' | while read -r r; do [ "$(readlink -f "$r")" != "$TS_CLOUD_CURRENT" ] && { echo "$r"; break; }; done)`,'[ -n "$TS_CLOUD_PREV" ] || { echo "no previous release to roll back to" >&2; exit 1; }',...Bj(j,'"$TS_CLOUD_PREV"'),`ln -sfn "$TS_CLOUD_PREV" ${j.current}.tmp`,`mv -Tf ${j.current}.tmp ${j.current}`,'echo "rolled back to $TS_CLOUD_PREV"'];if(!Z.unitBase)return $;let z=Z.unitBase;return[...$,`TS_CLOUD_RB_ID=$(basename "$(readlink -f ${j.current})")`,`if [ -f /etc/systemd/system/${z}@.service ]; then systemctl start "${z}@\${TS_CLOUD_RB_ID}.service"; sleep 2; systemctl is-active --quiet "${z}@\${TS_CLOUD_RB_ID}.service" || { echo "rolled-back release failed to start" >&2; exit 1; }; systemctl enable "${z}@\${TS_CLOUD_RB_ID}.service" 2>/dev/null || true; systemctl list-units --plain --no-legend --type=service "${z}@*.service" 2>/dev/null | awk '{print $1}' | { grep -v "^${z}@\${TS_CLOUD_RB_ID}.service$" || true; } | while read -r TS_CLOUD_U; do systemctl stop "$TS_CLOUD_U" 2>/dev/null || true; systemctl disable "$TS_CLOUD_U" 2>/dev/null || true; done; elif [ -f /etc/systemd/system/${z}.service ]; then systemctl restart ${z}.service; fi`]}function cZ(j,Z=4){let $=Math.max(1,Z);return[`TS_CLOUD_CURRENT=$(readlink -f ${j.current} 2>/dev/null || true)`,`ls -1dt ${j.releases}/*/ 2>/dev/null | sed 's#/$##' | tail -n +${$+1} | while read -r TS_CLOUD_OLD; do`,' [ "$(readlink -f "$TS_CLOUD_OLD")" = "$TS_CLOUD_CURRENT" ] || rm -rf "$TS_CLOUD_OLD"',"done"]}function zZ(j){return`${U(j)}/owner`}function dZ(j,Z){let $=zZ(j);return[`if [ -f "${$}" ]; then`,` TS_CLOUD_OWNER=$(cat "${$}")`,` if [ "$TS_CLOUD_OWNER" != "${Z}" ]; then`,` echo "[ts-cloud] REFUSING deploy: ${j} belongs to project '$TS_CLOUD_OWNER', not '${Z}'. Another project on this box derives the same site key — give one of them a distinct site name/domain, or remove ${$} to transfer ownership." >&2`," exit 1"," fi","else",` mkdir -p "$(dirname "${$}")"`,` printf '%s\\n' "${Z}" > "${$}"`,"fi"]}function pZ(j,Z){let $=U(j),z=ej(j,Z.releaseId),J=sj(j),W=Math.max(1,Z.keepLogs??20),q=Z.commit||"",w=Z.branch||"";return[`mkdir -p ${$}/deploys`,`exec > >(tee -a ${z}) 2>&1`,`echo "[ts-cloud] deploy ${Z.releaseId} commit=${q} branch=${w} starting $(date -u +%Y-%m-%dT%H:%M:%SZ)"`,"ts_cloud_record_deploy() {"," TS_CLOUD_RC=$?",' if [ "$TS_CLOUD_RC" -eq 0 ]; then TS_CLOUD_ST=success; else TS_CLOUD_ST=failed; fi',` printf '%s\\t%s\\t%s\\t%s\\trc=%s\\n' "$(date -u +%Y-%m-%dT%H:%M:%SZ)" "${Z.releaseId}" "${q}" "$TS_CLOUD_ST" "$TS_CLOUD_RC" >> ${J}`,"}","trap ts_cloud_record_deploy EXIT",`ls -1t ${$}/deploys/*.log 2>/dev/null | tail -n +${W+1} | while read -r TS_CLOUD_OLDLOG; do rm -f "$TS_CLOUD_OLDLOG"; done`]}
9
- export{XZ as vf,zj as wf,Nj as xf,_ as yf,kj as zf,JZ as Af,QZ as Bf,qZ as Cf,xZ as Df,f as Ef,KZ as Ff,c as Gf,A as Hf,Xj as If,Yj as Jf,Gj as Kf,e as Lf,NZ as Mf,UZ as Nf,kZ as Of,a as Pf,vZ as Qf,RZ as Rf,Mj as Sf,PZ as Tf,sj as Uf,yZ as Vf,aj as Wf,IZ as Xf,SZ as Yf,TZ as Zf,_Z as _f,bZ as $f,uZ as ag,gZ as bg,hZ as cg,mZ as dg,cZ as eg,dZ as fg,pZ as gg};
@@ -1,2 +0,0 @@
1
- import{dh as E}from"./chunk-xyt490vp.js";class J{client;region;constructor(b="us-east-1",w){this.region=b,this.client=new E}async createQueue(b){let h={Action:"CreateQueue",QueueName:b.fifo&&!b.queueName.endsWith(".fifo")?`${b.queueName}.fifo`:b.queueName,Version:"2012-11-05"},j=1;if(b.visibilityTimeout!==void 0)h[`Attribute.${j}.Name`]="VisibilityTimeout",h[`Attribute.${j}.Value`]=b.visibilityTimeout.toString(),j++;if(b.messageRetentionPeriod!==void 0)h[`Attribute.${j}.Name`]="MessageRetentionPeriod",h[`Attribute.${j}.Value`]=b.messageRetentionPeriod.toString(),j++;if(b.delaySeconds!==void 0)h[`Attribute.${j}.Name`]="DelaySeconds",h[`Attribute.${j}.Value`]=b.delaySeconds.toString(),j++;if(b.maxMessageSize!==void 0)h[`Attribute.${j}.Name`]="MaximumMessageSize",h[`Attribute.${j}.Value`]=b.maxMessageSize.toString(),j++;if(b.receiveMessageWaitTime!==void 0)h[`Attribute.${j}.Name`]="ReceiveMessageWaitTimeSeconds",h[`Attribute.${j}.Value`]=b.receiveMessageWaitTime.toString(),j++;if(b.fifo){if(h[`Attribute.${j}.Name`]="FifoQueue",h[`Attribute.${j}.Value`]="true",j++,b.contentBasedDeduplication)h[`Attribute.${j}.Name`]="ContentBasedDeduplication",h[`Attribute.${j}.Value`]="true",j++}if(b.deadLetterTargetArn&&b.maxReceiveCount)h[`Attribute.${j}.Name`]="RedrivePolicy",h[`Attribute.${j}.Value`]=JSON.stringify({deadLetterTargetArn:b.deadLetterTargetArn,maxReceiveCount:b.maxReceiveCount}),j++;if(b.tags&&Object.keys(b.tags).length>0){let B=1;for(let[F,G]of Object.entries(b.tags))h[`Tag.${B}.Key`]=F,h[`Tag.${B}.Value`]=G,B++}let z=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(h).toString()});return{QueueUrl:z.QueueUrl||z.CreateQueueResult?.QueueUrl}}async listQueues(b){let w={Action:"ListQueues",Version:"2012-11-05"};if(b)w.QueueNamePrefix=b;let h=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(w).toString()}),j=[];if(h.QueueUrl)j.push(h.QueueUrl);else if(h.ListQueuesResult?.QueueUrl)if(Array.isArray(h.ListQueuesResult.QueueUrl))j.push(...h.ListQueuesResult.QueueUrl);else j.push(h.ListQueuesResult.QueueUrl);return{QueueUrls:j}}async getQueueAttributes(b){let w={Action:"GetQueueAttributes",QueueUrl:b,Version:"2012-11-05","AttributeName.1":"All"},h=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(w).toString()});return{Attributes:h.Attributes||h.GetQueueAttributesResult?.Attributes||{}}}async getQueueUrl(b){let w={Action:"GetQueueUrl",QueueName:b,Version:"2012-11-05"},h=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(w).toString()});return{QueueUrl:h.QueueUrl||h.GetQueueUrlResult?.QueueUrl}}async deleteQueue(b){let w={Action:"DeleteQueue",QueueUrl:b,Version:"2012-11-05"};await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(w).toString()})}async purgeQueue(b){let w={Action:"PurgeQueue",QueueUrl:b,Version:"2012-11-05"};await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(w).toString()})}async sendMessage(b){let w={Action:"SendMessage",QueueUrl:b.queueUrl,MessageBody:b.messageBody,Version:"2012-11-05"};if(b.delaySeconds!==void 0)w.DelaySeconds=b.delaySeconds;if(b.messageGroupId)w.MessageGroupId=b.messageGroupId;if(b.messageDeduplicationId)w.MessageDeduplicationId=b.messageDeduplicationId;let h=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(w).toString()});return{MessageId:h.MessageId||h.SendMessageResult?.MessageId}}async receiveMessages(b){let w={Action:"ReceiveMessage",QueueUrl:b.queueUrl,Version:"2012-11-05"};if(b.maxMessages!==void 0)w.MaxNumberOfMessages=b.maxMessages;if(b.visibilityTimeout!==void 0)w.VisibilityTimeout=b.visibilityTimeout;if(b.waitTimeSeconds!==void 0)w.WaitTimeSeconds=b.waitTimeSeconds;let h=await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(w).toString()}),j=[],z=h.Message||h.ReceiveMessageResult?.Message;if(z)if(Array.isArray(z))j.push(...z.map((B)=>({MessageId:B.MessageId,ReceiptHandle:B.ReceiptHandle,Body:B.Body})));else j.push({MessageId:z.MessageId,ReceiptHandle:z.ReceiptHandle,Body:z.Body});return{Messages:j}}async deleteMessage(b,w){let h={Action:"DeleteMessage",QueueUrl:b,ReceiptHandle:w,Version:"2012-11-05"};await this.client.request({service:"sqs",region:this.region,method:"POST",path:"/",body:new URLSearchParams(h).toString()})}}
2
- export{J as Hd};
@@ -1,2 +0,0 @@
1
- import{createRequire as g}from"node:module";var d=Object.defineProperty;var h=(b,a)=>()=>(a||b((a={exports:{}}).exports,a),a.exports);var e=(b)=>b;function f(b,a){this[b]=e.bind(null,a)}var i=(b,a)=>{for(var c in a)d(b,c,{get:a[c],enumerable:!0,configurable:!0,set:f.bind(a,c)})};var k=g(import.meta.url);
2
- export{h as np,i as op,k as pp};
@@ -1 +0,0 @@
1
- import{p as a,q as b,r as c,s as d,t as e,u as f}from"./chunk-xbk2y43r.js";import"./chunk-mpjg0kc7.js";import"./chunk-v3rzf9d0.js";import"./chunk-f11xf3n6.js";import"./chunk-8h1qr6x4.js";import"./chunk-54bqchag.js";import"./chunk-xyt490vp.js";import"./chunk-c8sypnbe.js";export{c as uploadStaticFiles,d as invalidateCache,a as generateStaticSiteTemplate,f as deployStaticSiteFull,b as deployStaticSite,e as deleteStaticSite};
@@ -1,2 +0,0 @@
1
- import{Ig as w}from"./chunk-qsdf5kzk.js";import{Pg as E}from"./chunk-xjp3v95e.js";import{Xo as u,ap as D,bp as F,io as H,ko as C,uo as R}from"./chunk-5bhx3bsa.js";import{execFileSync as P}from"node:child_process";import{mkdirSync as _,mkdtempSync as k,rmSync as S,writeFileSync as Z}from"node:fs";import{tmpdir as m}from"node:os";import{dirname as h,join as J}from"node:path";function A(M,q){for(let z of q){let V=J(M,z.name);_(h(V),{recursive:!0}),Z(V,z.data,z.mode?{mode:z.mode}:void 0)}}async function p(M){let{app:q,projectRoot:z,region:V,repository:W}=M,b=q.architecture??"x86_64",f=b==="arm64"?"linux/arm64":"linux/amd64",U=q.kind==="php",K=M.onStep??(()=>{}),N=k(J(m(),"tscloud-img-"));try{let $=J(N,"app");_($,{recursive:!0});let v,B;if(U){D({projectRoot:z,app:q,skipBuild:M.skipBuild,onStep:K}),K("staging application tree");let G=F(z);A($,G),A(J(N,"runtime"),u().map((T)=>({name:T.path,data:T.contents,mode:T.mode})));let O=q.handlers?.http??"public/index.php";v={http:O,queue:q.handlers?.queue??O,cli:q.handlers?.cli??O},B=H(G.map((T)=>`${T.name}:${T.data.length}`).join("|"))}else{K("bundling application");let G=await C({projectRoot:z,app:q,skipBuild:M.skipBuild,onStep:K});Z(J($,"index.mjs"),G.bundle),v=G.handlers,B=G.sha256}let x=B.slice(0,16);Z(J(N,"Dockerfile"),R({kind:q.kind??"node",phpVersion:q.phpVersion,architecture:b}));let I=new w(V),Q;try{Q=(await I.describeRepositories({repositoryNames:[W]})).repositories?.[0]?.repositoryUri??""}catch{Q=""}if(!Q)K(`creating ECR repository ${W}`),Q=(await I.createRepository({repositoryName:W,imageScanningConfiguration:{scanOnPush:!0}})).repository?.repositoryUri??"";if(!Q)throw Error(`could not resolve ECR repository URI for ${W}`);let X=`${Q}:${x}`;K("docker build"),P("docker",["build","--platform",f,"--provenance=false","--sbom=false","-t",X,N],{stdio:"inherit"}),K("ecr auth + push");let Y=(await I.getAuthorizationToken()).authorizationData?.[0];if(!Y?.authorizationToken||!Y.proxyEndpoint)throw Error("failed to get an ECR authorization token");let j=Y.proxyEndpoint.replace(/^https?:\/\//,""),L=J(N,".docker");return _(L,{recursive:!0}),Z(J(L,"config.json"),JSON.stringify({auths:{[j]:{auth:Y.authorizationToken}}})),P("docker",["push",X],{stdio:"inherit",env:{...process.env,DOCKER_CONFIG:L}}),E(`Image: ${X}`),{imageUri:X,tag:x,handlers:v}}finally{S(N,{recursive:!0,force:!0})}}
2
- export{p as Hg};
@@ -1 +0,0 @@
1
- import{rg as a,sg as b,tg as c,ug as d,vg as e,wg as f,xg as g,yg as h,zg as i}from"./chunk-9vdc7adf.js";import"./chunk-scqmd4qv.js";import"./chunk-5bhx3bsa.js";import"./chunk-c8sypnbe.js";export{i as synchronizeConfiguredConfiguration,c as serializeDotenv,b as parseDotenv,d as LocalEncryptedConfigurationBackend,g as ExternalConfigurationBackend,a as ConfigurationStore,h as ConfigurationService,f as AwsSsmConfigurationBackend,e as AwsSecretsManagerConfigurationBackend};
@@ -1 +0,0 @@
1
- import{_d as a}from"./chunk-r61qmhv1.js";import"./chunk-xyt490vp.js";import"./chunk-c8sypnbe.js";export{a as LambdaClient};
@@ -1,4 +0,0 @@
1
- import{dh as O}from"./chunk-xyt490vp.js";class Q{client;region;constructor(q="us-east-1"){this.region=q,this.client=new O}async describeInstances(q){let z={Action:"DescribeInstances",Version:"2016-11-15"};if(q?.InstanceIds)q.InstanceIds.forEach((G,J)=>{z[`InstanceId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});if(q?.MaxResults)z.MaxResults=String(q.MaxResults);if(q?.NextToken)z.NextToken=q.NextToken;let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.DescribeInstancesResponse||H;return{Reservations:this.parseReservations(B.reservationSet?.item),NextToken:B.nextToken}}async getInstance(q){return(await this.describeInstances({InstanceIds:[q]})).Reservations?.[0]?.Instances?.[0]}async getConsoleOutput(q,z){let H={Action:"GetConsoleOutput",Version:"2016-11-15",InstanceId:q};if(z)H.Latest="true";let B=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()}),G=B.GetConsoleOutputResponse||B;return{InstanceId:G.instanceId,Output:G.output,Timestamp:G.timestamp}}async getConsoleOutputDecoded(q,z){let H=await this.getConsoleOutput(q,z?.latest);if(!H.Output)return"No console output available yet";let B=Buffer.from(H.Output,"base64").toString("utf-8");if(z?.tailLines)return B.split(`
2
- `).slice(-z.tailLines).join(`
3
- `);return B}async describeInstanceStatus(q){let z={Action:"DescribeInstanceStatus",Version:"2016-11-15"};if(q?.InstanceIds)q.InstanceIds.forEach((B,G)=>{z[`InstanceId.${G+1}`]=B});if(q?.IncludeAllInstances)z.IncludeAllInstances="true";if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{InstanceStatuses:this.parseArray(H.instanceStatusSet?.item).map((B)=>({InstanceId:B.instanceId,InstanceState:B.instanceState?{Code:Number.parseInt(B.instanceState.code),Name:B.instanceState.name}:void 0,InstanceStatus:B.instanceStatus?{Status:B.instanceStatus.status,Details:this.parseArray(B.instanceStatus.details?.item).map((G)=>({Name:G.name,Status:G.status}))}:void 0,SystemStatus:B.systemStatus?{Status:B.systemStatus.status,Details:this.parseArray(B.systemStatus.details?.item).map((G)=>({Name:G.name,Status:G.status}))}:void 0}))}}async startInstances(q){let z={Action:"StartInstances",Version:"2016-11-15"};q.forEach((B,G)=>{z[`InstanceId.${G+1}`]=B});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{StartingInstances:this.parseArray(H.instancesSet?.item).map((B)=>({InstanceId:B.instanceId,CurrentState:B.currentState?{Name:B.currentState.name}:void 0,PreviousState:B.previousState?{Name:B.previousState.name}:void 0}))}}async stopInstances(q,z){let H={Action:"StopInstances",Version:"2016-11-15"};if(q.forEach((G,J)=>{H[`InstanceId.${J+1}`]=G}),z)H.Force="true";let B=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()});return{StoppingInstances:this.parseArray(B.instancesSet?.item).map((G)=>({InstanceId:G.instanceId,CurrentState:G.currentState?{Name:G.currentState.name}:void 0,PreviousState:G.previousState?{Name:G.previousState.name}:void 0}))}}async rebootInstances(q){let z={Action:"RebootInstances",Version:"2016-11-15"};q.forEach((H,B)=>{z[`InstanceId.${B+1}`]=H}),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async terminateInstances(q){let z={Action:"TerminateInstances",Version:"2016-11-15"};q.forEach((B,G)=>{z[`InstanceId.${G+1}`]=B});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{TerminatingInstances:this.parseArray(H.instancesSet?.item).map((B)=>({InstanceId:B.instanceId,CurrentState:B.currentState?{Name:B.currentState.name}:void 0,PreviousState:B.previousState?{Name:B.previousState.name}:void 0}))}}async createImage(q){let z={Action:"CreateImage",Version:"2016-11-15",InstanceId:q.InstanceId,Name:q.Name};if(q.Description)z.Description=q.Description;if(q.NoReboot!==void 0)z.NoReboot=String(q.NoReboot);if(q.TagSpecifications)q.TagSpecifications.forEach((G,J)=>{z[`TagSpecification.${J+1}.ResourceType`]=G.ResourceType,G.Tags.forEach((K,L)=>{z[`TagSpecification.${J+1}.Tag.${L+1}.Key`]=K.Key,z[`TagSpecification.${J+1}.Tag.${L+1}.Value`]=K.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{ImageId:(H.CreateImageResponse||H).imageId}}async deregisterImage(q){await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({Action:"DeregisterImage",Version:"2016-11-15",ImageId:q}).toString()})}async describeVpcs(q){let z={Action:"DescribeVpcs",Version:"2016-11-15"};if(q?.VpcIds)q.VpcIds.forEach((B,G)=>{z[`VpcId.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Vpcs:this.parseArray(H.vpcSet?.item).map((B)=>({VpcId:B.vpcId,CidrBlock:B.cidrBlock,State:B.state,DhcpOptionsId:B.dhcpOptionsId,InstanceTenancy:B.instanceTenancy,IsDefault:B.isDefault==="true",Tags:this.parseTags(B.tagSet?.item)}))}}async describeSubnets(q){let z={Action:"DescribeSubnets",Version:"2016-11-15"};if(q?.SubnetIds)q.SubnetIds.forEach((B,G)=>{z[`SubnetId.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Subnets:this.parseArray(H.subnetSet?.item).map((B)=>({SubnetId:B.subnetId,VpcId:B.vpcId,CidrBlock:B.cidrBlock,AvailabilityZone:B.availabilityZone,AvailableIpAddressCount:Number.parseInt(B.availableIpAddressCount),State:B.state,MapPublicIpOnLaunch:B.mapPublicIpOnLaunch==="true",Tags:this.parseTags(B.tagSet?.item)}))}}async describeSecurityGroups(q){let z={Action:"DescribeSecurityGroups",Version:"2016-11-15"};if(q?.GroupIds)q.GroupIds.forEach((B,G)=>{z[`GroupId.${G+1}`]=B});if(q?.GroupNames)q.GroupNames.forEach((B,G)=>{z[`GroupName.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{SecurityGroups:this.parseArray(H.securityGroupInfo?.item).map((B)=>({GroupId:B.groupId,GroupName:B.groupName,Description:B.groupDescription,VpcId:B.vpcId,IpPermissions:this.parseIpPermissions(B.ipPermissions?.item),IpPermissionsEgress:this.parseIpPermissions(B.ipPermissionsEgress?.item),Tags:this.parseTags(B.tagSet?.item)}))}}async describeInternetGateways(q){let z={Action:"DescribeInternetGateways",Version:"2016-11-15"};if(q?.InternetGatewayIds)q.InternetGatewayIds.forEach((B,G)=>{z[`InternetGatewayId.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{InternetGateways:this.parseArray(H.internetGatewaySet?.item).map((B)=>({InternetGatewayId:B.internetGatewayId,Attachments:this.parseArray(B.attachmentSet?.item).map((G)=>({VpcId:G.vpcId,State:G.state})),Tags:this.parseTags(B.tagSet?.item)}))}}async describeAddresses(q){let z={Action:"DescribeAddresses",Version:"2016-11-15"};if(q?.AllocationIds)q.AllocationIds.forEach((B,G)=>{z[`AllocationId.${G+1}`]=B});if(q?.PublicIps)q.PublicIps.forEach((B,G)=>{z[`PublicIp.${G+1}`]=B});if(q?.Filters)q.Filters.forEach((B,G)=>{z[`Filter.${G+1}.Name`]=B.Name,B.Values.forEach((J,K)=>{z[`Filter.${G+1}.Value.${K+1}`]=J})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{Addresses:this.parseArray(H.addressesSet?.item).map((B)=>({PublicIp:B.publicIp,AllocationId:B.allocationId,AssociationId:B.associationId,InstanceId:B.instanceId,NetworkInterfaceId:B.networkInterfaceId,PrivateIpAddress:B.privateIpAddress,Domain:B.domain,Tags:this.parseTags(B.tagSet?.item)}))}}async allocateAddress(q){let z={Action:"AllocateAddress",Version:"2016-11-15"};if(q?.Domain)z.Domain=q.Domain;if(q?.TagSpecifications)q.TagSpecifications.forEach((B,G)=>{z[`TagSpecification.${G+1}.ResourceType`]=B.ResourceType,B.Tags.forEach((J,K)=>{z[`TagSpecification.${G+1}.Tag.${K+1}.Key`]=J.Key,z[`TagSpecification.${G+1}.Tag.${K+1}.Value`]=J.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{AllocationId:H.allocationId,PublicIp:H.publicIp,Domain:H.domain}}async associateAddress(q){let z={Action:"AssociateAddress",Version:"2016-11-15"};if(q.AllocationId)z.AllocationId=q.AllocationId;if(q.PublicIp)z.PublicIp=q.PublicIp;if(q.InstanceId)z.InstanceId=q.InstanceId;if(q.NetworkInterfaceId)z.NetworkInterfaceId=q.NetworkInterfaceId;if(q.PrivateIpAddress)z.PrivateIpAddress=q.PrivateIpAddress;if(q.AllowReassociation)z.AllowReassociation="true";return{AssociationId:(await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})).associationId}}async createTags(q){let z={Action:"CreateTags",Version:"2016-11-15"};q.Resources.forEach((H,B)=>{z[`ResourceId.${B+1}`]=H}),q.Tags.forEach((H,B)=>{z[`Tag.${B+1}.Key`]=H.Key,z[`Tag.${B+1}.Value`]=H.Value}),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async waitForInstanceState(q,z,H){let B=H?.maxWaitMs||300000,G=H?.pollIntervalMs||5000,J=Date.now();while(Date.now()-J<B){let K;try{K=await this.getInstance(q)}catch{K=void 0}if(K?.State?.Name===z)return K;await new Promise((L)=>setTimeout(L,G))}return}async createVpc(q){let z={Action:"CreateVpc",Version:"2016-11-15",CidrBlock:q.CidrBlock};if(q.InstanceTenancy)z.InstanceTenancy=q.InstanceTenancy;if(q.TagSpecifications)q.TagSpecifications.forEach((J,K)=>{z[`TagSpecification.${K+1}.ResourceType`]=J.ResourceType,J.Tags.forEach((L,M)=>{z[`TagSpecification.${K+1}.Tag.${M+1}.Key`]=L.Key,z[`TagSpecification.${K+1}.Tag.${M+1}.Value`]=L.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=(H.CreateVpcResponse||H).vpc;return{Vpc:G?{VpcId:G.vpcId,CidrBlock:G.cidrBlock,State:G.state,DhcpOptionsId:G.dhcpOptionsId,InstanceTenancy:G.instanceTenancy,IsDefault:G.isDefault==="true",Tags:this.parseTags(G.tagSet?.item)}:void 0}}async createSubnet(q){let z={Action:"CreateSubnet",Version:"2016-11-15",VpcId:q.VpcId,CidrBlock:q.CidrBlock};if(q.AvailabilityZone)z.AvailabilityZone=q.AvailabilityZone;if(q.TagSpecifications)q.TagSpecifications.forEach((J,K)=>{z[`TagSpecification.${K+1}.ResourceType`]=J.ResourceType,J.Tags.forEach((L,M)=>{z[`TagSpecification.${K+1}.Tag.${M+1}.Key`]=L.Key,z[`TagSpecification.${K+1}.Tag.${M+1}.Value`]=L.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),G=(H.CreateSubnetResponse||H).subnet;return{Subnet:G?{SubnetId:G.subnetId,VpcId:G.vpcId,CidrBlock:G.cidrBlock,AvailabilityZone:G.availabilityZone,AvailableIpAddressCount:G.availableIpAddressCount?Number.parseInt(G.availableIpAddressCount):void 0,State:G.state,MapPublicIpOnLaunch:G.mapPublicIpOnLaunch==="true",Tags:this.parseTags(G.tagSet?.item)}:void 0}}async modifySubnetAttribute(q){let z={Action:"ModifySubnetAttribute",Version:"2016-11-15",SubnetId:q.SubnetId};if(q.MapPublicIpOnLaunch!==void 0)z["MapPublicIpOnLaunch.Value"]=String(q.MapPublicIpOnLaunch.Value);await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async createSecurityGroup(q){let z={Action:"CreateSecurityGroup",Version:"2016-11-15",GroupName:q.GroupName,GroupDescription:q.Description};if(q.VpcId)z.VpcId=q.VpcId;if(q.TagSpecifications)q.TagSpecifications.forEach((G,J)=>{z[`TagSpecification.${J+1}.ResourceType`]=G.ResourceType,G.Tags.forEach((K,L)=>{z[`TagSpecification.${J+1}.Tag.${L+1}.Key`]=K.Key,z[`TagSpecification.${J+1}.Tag.${L+1}.Value`]=K.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()});return{GroupId:(H.CreateSecurityGroupResponse||H).groupId}}async authorizeSecurityGroupIngress(q){let z={Action:"AuthorizeSecurityGroupIngress",Version:"2016-11-15",GroupId:q.GroupId};this.encodeIpPermissions(z,q.IpPermissions),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async authorizeSecurityGroupEgress(q){let z={Action:"AuthorizeSecurityGroupEgress",Version:"2016-11-15",GroupId:q.GroupId};this.encodeIpPermissions(z,q.IpPermissions),await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async describeRouteTables(q){let z={Action:"DescribeRouteTables",Version:"2016-11-15"};if(q?.RouteTableIds)q.RouteTableIds.forEach((G,J)=>{z[`RouteTableId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.DescribeRouteTablesResponse||H;return{RouteTables:this.parseArray(B.routeTableSet?.item).map((G)=>({RouteTableId:G.routeTableId,VpcId:G.vpcId,Routes:this.parseArray(G.routeSet?.item).map((J)=>({DestinationCidrBlock:J.destinationCidrBlock,GatewayId:J.gatewayId,NatGatewayId:J.natGatewayId,State:J.state})),Associations:this.parseArray(G.associationSet?.item).map((J)=>({RouteTableAssociationId:J.routeTableAssociationId,SubnetId:J.subnetId,Main:J.main==="true"||J.main===!0})),Tags:this.parseTags(G.tagSet?.item)}))}}async deleteVpc(q){let z={Action:"DeleteVpc",Version:"2016-11-15",VpcId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async deleteSubnet(q){let z={Action:"DeleteSubnet",Version:"2016-11-15",SubnetId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async deleteSecurityGroup(q){await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({Action:"DeleteSecurityGroup",Version:"2016-11-15",GroupId:q}).toString()})}async describeNetworkInterfaces(q){let z={Action:"DescribeNetworkInterfaces",Version:"2016-11-15"};if(q?.NetworkInterfaceIds)q.NetworkInterfaceIds.forEach((G,J)=>{z[`NetworkInterfaceId.${J+1}`]=G});if(q?.Filters)q.Filters.forEach((G,J)=>{z[`Filter.${J+1}.Name`]=G.Name,G.Values.forEach((K,L)=>{z[`Filter.${J+1}.Value.${L+1}`]=K})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.DescribeNetworkInterfacesResponse||H;return{NetworkInterfaces:this.parseArray(B.networkInterfaceSet?.item).map((G)=>({NetworkInterfaceId:G.networkInterfaceId,SubnetId:G.subnetId,VpcId:G.vpcId,Status:G.status,Attachment:G.attachment?{AttachmentId:G.attachment.attachmentId,InstanceId:G.attachment.instanceId,Status:G.attachment.status}:void 0}))}}async detachNetworkInterface(q,z){let H={Action:"DetachNetworkInterface",Version:"2016-11-15",AttachmentId:q};if(z)H.Force="true";await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(H).toString()})}async deleteNetworkInterface(q){let z={Action:"DeleteNetworkInterface",Version:"2016-11-15",NetworkInterfaceId:q};await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()})}async describeRegions(){let q={Action:"DescribeRegions",Version:"2016-11-15"},z=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(q).toString()}),H=z.DescribeRegionsResponse||z;return{Regions:this.parseArray(H.regionInfo?.item).map((B)=>({RegionName:B.regionName,Endpoint:B.regionEndpoint}))}}async runInstances(q){let z={Action:"RunInstances",Version:"2016-11-15",ImageId:q.ImageId,InstanceType:q.InstanceType,MinCount:String(q.MinCount),MaxCount:String(q.MaxCount)};if(q.SecurityGroupIds)q.SecurityGroupIds.forEach((G,J)=>{z[`SecurityGroupId.${J+1}`]=G});if(q.SubnetId)z.SubnetId=q.SubnetId;if(q.UserData)z.UserData=q.UserData;if(q.IamInstanceProfile){if(q.IamInstanceProfile.Name)z["IamInstanceProfile.Name"]=q.IamInstanceProfile.Name;if(q.IamInstanceProfile.Arn)z["IamInstanceProfile.Arn"]=q.IamInstanceProfile.Arn}if(q.TagSpecifications)q.TagSpecifications.forEach((G,J)=>{z[`TagSpecification.${J+1}.ResourceType`]=G.ResourceType,G.Tags.forEach((K,L)=>{z[`TagSpecification.${J+1}.Tag.${L+1}.Key`]=K.Key,z[`TagSpecification.${J+1}.Tag.${L+1}.Value`]=K.Value})});let H=await this.client.request({service:"ec2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(z).toString()}),B=H.RunInstancesResponse||H;return{Instances:this.parseInstances(B.instancesSet?.item||B.instancesSet)}}encodeIpPermissions(q,z){z.forEach((H,B)=>{let G=`IpPermissions.${B+1}`;if(H.IpProtocol!==void 0)q[`${G}.IpProtocol`]=H.IpProtocol;if(H.FromPort!==void 0)q[`${G}.FromPort`]=String(H.FromPort);if(H.ToPort!==void 0)q[`${G}.ToPort`]=String(H.ToPort);if(H.IpRanges)H.IpRanges.forEach((J,K)=>{if(J.CidrIp)q[`${G}.IpRanges.${K+1}.CidrIp`]=J.CidrIp;if(J.Description)q[`${G}.IpRanges.${K+1}.Description`]=J.Description});if(H.Ipv6Ranges)H.Ipv6Ranges.forEach((J,K)=>{if(J.CidrIpv6)q[`${G}.Ipv6Ranges.${K+1}.CidrIpv6`]=J.CidrIpv6;if(J.Description)q[`${G}.Ipv6Ranges.${K+1}.Description`]=J.Description});if(H.UserIdGroupPairs)H.UserIdGroupPairs.forEach((J,K)=>{if(J.GroupId)q[`${G}.Groups.${K+1}.GroupId`]=J.GroupId;if(J.UserId)q[`${G}.Groups.${K+1}.UserId`]=J.UserId;if(J.Description)q[`${G}.Groups.${K+1}.Description`]=J.Description})})}parseArray(q){if(!q)return[];return Array.isArray(q)?q:[q]}parseFirstIpv6Address(q){for(let z of this.parseArray(q))for(let H of this.parseArray(z?.ipv6AddressesSet?.item))if(H?.ipv6Address)return H.ipv6Address;return}parseTags(q){return this.parseArray(q).map((z)=>({Key:z.key,Value:z.value}))}parseReservations(q){return this.parseArray(q).map((z)=>({ReservationId:z.reservationId,Instances:this.parseInstances(z.instancesSet?.item||z.instancesSet)}))}parseInstances(q){return this.parseArray(q).map((z)=>({InstanceId:z.instanceId,ImageId:z.imageId,InstanceType:z.instanceType,State:z.instanceState?{Code:Number.parseInt(z.instanceState.code),Name:z.instanceState.name}:void 0,PrivateIpAddress:z.privateIpAddress,PublicIpAddress:z.ipAddress,Ipv6Address:this.parseFirstIpv6Address(z.networkInterfaceSet?.item),SubnetId:z.subnetId,VpcId:z.vpcId,SecurityGroups:this.parseArray(z.groupSet?.item).map((H)=>({GroupId:H.groupId,GroupName:H.groupName})),Tags:this.parseTags(z.tagSet?.item),LaunchTime:z.launchTime,Placement:z.placement?{AvailabilityZone:z.placement.availabilityZone,Tenancy:z.placement.tenancy}:void 0,Architecture:z.architecture,RootDeviceType:z.rootDeviceType,RootDeviceName:z.rootDeviceName,BlockDeviceMappings:this.parseArray(z.blockDeviceMapping?.item).map((H)=>({DeviceName:H.deviceName,Ebs:H.ebs?{VolumeId:H.ebs.volumeId,Status:H.ebs.status,AttachTime:H.ebs.attachTime,DeleteOnTermination:H.ebs.deleteOnTermination==="true"}:void 0})),IamInstanceProfile:z.iamInstanceProfile?{Arn:z.iamInstanceProfile.arn,Id:z.iamInstanceProfile.id}:void 0}))}parseIpPermissions(q){return this.parseArray(q).map((z)=>({IpProtocol:z.ipProtocol,FromPort:z.fromPort?Number.parseInt(z.fromPort):void 0,ToPort:z.toPort?Number.parseInt(z.toPort):void 0,IpRanges:this.parseArray(z.ipRanges?.item).map((H)=>({CidrIp:H.cidrIp,Description:H.description})),Ipv6Ranges:this.parseArray(z.ipv6Ranges?.item).map((H)=>({CidrIpv6:H.cidrIpv6,Description:H.description})),UserIdGroupPairs:this.parseArray(z.groups?.item).map((H)=>({GroupId:H.groupId,UserId:H.userId,Description:H.description}))}))}}
4
- export{Q as Ye};
@@ -1,2 +0,0 @@
1
- import{dh as _}from"./chunk-xyt490vp.js";class ${client;region;constructor(j="us-east-1",q){this.region=j,this.client=new _(void 0,{profile:q})}async createStack(j){let q={Action:"CreateStack",StackName:j.stackName,Version:"2010-05-15"};if(j.templateBody)q.TemplateBody=j.templateBody;else if(j.templateUrl)q.TemplateURL=j.templateUrl;else throw Error("Either templateBody or templateUrl must be provided");if(j.parameters)j.parameters.forEach((z,H)=>{q[`Parameters.member.${H+1}.ParameterKey`]=z.ParameterKey,q[`Parameters.member.${H+1}.ParameterValue`]=z.ParameterValue});if(j.capabilities)j.capabilities.forEach((z,H)=>{q[`Capabilities.member.${H+1}`]=z});if(j.roleArn)q.RoleARN=j.roleArn;if(j.tags)j.tags.forEach((z,H)=>{q[`Tags.member.${H+1}.Key`]=z.Key,q[`Tags.member.${H+1}.Value`]=z.Value});if(j.timeoutInMinutes)q.TimeoutInMinutes=j.timeoutInMinutes;if(j.onFailure)q.OnFailure=j.onFailure;let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{StackId:G.StackId||G.CreateStackResult?.StackId}}async updateStack(j){let q={Action:"UpdateStack",StackName:j.stackName,Version:"2010-05-15"};if(j.templateBody)q.TemplateBody=j.templateBody;else if(j.templateUrl)q.TemplateURL=j.templateUrl;if(j.parameters)j.parameters.forEach((z,H)=>{if(q[`Parameters.member.${H+1}.ParameterKey`]=z.ParameterKey,z.UsePreviousValue)q[`Parameters.member.${H+1}.UsePreviousValue`]="true";else q[`Parameters.member.${H+1}.ParameterValue`]=z.ParameterValue});if(j.capabilities)j.capabilities.forEach((z,H)=>{q[`Capabilities.member.${H+1}`]=z});if(j.roleArn)q.RoleARN=j.roleArn;if(j.tags)j.tags.forEach((z,H)=>{q[`Tags.member.${H+1}.Key`]=z.Key,q[`Tags.member.${H+1}.Value`]=z.Value});let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{StackId:G.StackId||G.UpdateStackResult?.StackId}}async deleteStack(j,q,G){let z={Action:"DeleteStack",StackName:j,Version:"2010-05-15"};if(q)z.RoleARN=q;if(G&&G.length>0)G.forEach((H,Q)=>{z[`RetainResources.member.${Q+1}`]=H});await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(z).toString()})}async describeStacks(j={}){let q={Action:"DescribeStacks",Version:"2010-05-15"};if(j.stackName)q.StackName=j.stackName;let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{Stacks:this.parseStacksResponse(G)}}async describeStackEvents(j){let q={Action:"DescribeStackEvents",StackName:j,Version:"2010-05-15"},G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{StackEvents:this.parseStackEvents(G)}}async listStackResources(j){let q={Action:"ListStackResources",StackName:j,Version:"2010-05-15"},z=(await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()}))?.ListStackResourcesResult?.StackResourceSummaries?.member,H=[];if(z)H=Array.isArray(z)?z:[z];return{StackResourceSummaries:H}}async waitForStack(j,q){let G={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},z=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],H=G[q],Q=360,J=0;while(J<360)try{let I=await this.describeStacks({stackName:j});if(I.Stacks.length===0){if(q==="stack-delete-complete")return;if(J%10===0)console.log(`[waitForStack] Attempt ${J}: Stack not visible yet`);await new Promise((O)=>setTimeout(O,2000)),J++;continue}let L=I.Stacks[0];if(J%10===0)console.log(`[waitForStack] Attempt ${J}: Status = ${L.StackStatus}${L.StackStatusReason?` (${L.StackStatusReason})`:""}`);if(H.includes(L.StackStatus))return;if((q==="stack-create-complete"||q==="stack-update-complete")&&(L.StackStatus==="DELETE_IN_PROGRESS"||L.StackStatus==="DELETE_COMPLETE")){console.log("[waitForStack] Stack is being deleted (creation/update failed)");let O="";try{let U=await this.describeStackEvents(j);console.log("[waitForStack] Stack events (most recent first):");for(let X of U.StackEvents.slice(0,15))if(X.ResourceStatus.includes("FAILED")||X.ResourceStatusReason){if(console.log(` ${X.LogicalResourceId}: ${X.ResourceStatus} - ${X.ResourceStatusReason||"No reason provided"}`),X.ResourceStatus.includes("FAILED")&&X.ResourceStatusReason&&!O)O=X.ResourceStatusReason}}catch{}let V=O||L.StackStatusReason||"Check CloudFormation console for details.";throw Error(`Stack creation/update failed - stack is being deleted. Reason: ${V}`)}if(L.StackStatus==="DELETE_FAILED"&&q==="stack-delete-complete"){let O=Error("Stack deletion failed - may have resources that need to be retained");throw O.code="DELETE_FAILED",O.stackStatus=L.StackStatus,O.statusReason=L.StackStatusReason,O}if(z.includes(L.StackStatus))throw Error(`Stack reached failure status: ${L.StackStatus}`);await new Promise((O)=>setTimeout(O,5000)),J++}catch(I){if(q==="stack-delete-complete"&&I.message?.includes("does not exist"))return;if(q==="stack-create-complete"&&I.message?.includes("does not exist")){if(J%10===0)console.log(`[waitForStack] Attempt ${J}: Stack does not exist (error), retrying...`);await new Promise((L)=>setTimeout(L,2000)),J++;continue}throw console.log(`[waitForStack] Unexpected error: ${I.message}`),I}throw console.log(`[waitForStack] Timeout after ${J} attempts`),Error(`Timeout waiting for stack to reach ${q}`)}async validateTemplate(j){let q={Action:"ValidateTemplate",TemplateBody:j,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()})}async listStacks(j){let q={Action:"ListStacks",Version:"2010-05-15"};if(j)j.forEach((I,L)=>{q[`StackStatusFilter.member.${L+1}`]=I});let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()}),z=G.ListStacksResponse||G,H=z.ListStacksResult||z,Q=H.StackSummaries?.member||H.StackSummaries||[];return{StackSummaries:(Array.isArray(Q)?Q:Q?[Q]:[]).map((I)=>({StackId:I.StackId||"",StackName:I.StackName||"",TemplateDescription:I.TemplateDescription,CreationTime:I.CreationTime||"",LastUpdatedTime:I.LastUpdatedTime,DeletionTime:I.DeletionTime,StackStatus:I.StackStatus||""}))}}async createChangeSet(j){let q={Action:"CreateChangeSet",StackName:j.stackName,ChangeSetName:j.changeSetName,Version:"2010-05-15"};if(j.templateBody)q.TemplateBody=j.templateBody;else if(j.templateUrl)q.TemplateURL=j.templateUrl;if(j.parameters)j.parameters.forEach((z,H)=>{q[`Parameters.member.${H+1}.ParameterKey`]=z.ParameterKey,q[`Parameters.member.${H+1}.ParameterValue`]=z.ParameterValue});if(j.capabilities)j.capabilities.forEach((z,H)=>{q[`Capabilities.member.${H+1}`]=z});if(j.changeSetType)q.ChangeSetType=j.changeSetType;let G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{Id:G.Id,StackId:G.StackId}}async describeChangeSet(j,q){let G={Action:"DescribeChangeSet",StackName:j,ChangeSetName:q,Version:"2010-05-15"};return await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(G).toString()})}async executeChangeSet(j,q){let G={Action:"ExecuteChangeSet",StackName:j,ChangeSetName:q,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(G).toString()})}async deleteChangeSet(j,q){let G={Action:"DeleteChangeSet",StackName:j,ChangeSetName:q,Version:"2010-05-15"};await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(G).toString()})}async getStackOutputs(j){let q=await this.describeStacks({stackName:j});if(!q.Stacks||q.Stacks.length===0)throw Error(`Stack ${j} not found`);let G=q.Stacks[0],z={};if(G.Outputs)for(let H of G.Outputs)z[H.OutputKey]=H.OutputValue;return z}async getTemplate(j){let q={Action:"GetTemplate",StackName:j,Version:"2010-05-15"},G=await this.client.request({service:"cloudformation",region:this.region,method:"POST",path:"/",body:new URLSearchParams(q).toString()});return{TemplateBody:G?.GetTemplateResult?.TemplateBody||G?.TemplateBody||""}}parseStacksResponse(j){let q=[],G=j?.DescribeStacksResult?.Stacks?.member||j?.Stacks?.member||j?.Stacks||j;if(G&&!Array.isArray(G))G=[G];if(Array.isArray(G)){for(let z of G)if(z.StackId||z.StackName){let H;if(z.Outputs?.member)H=(Array.isArray(z.Outputs.member)?z.Outputs.member:[z.Outputs.member]).map((J)=>({OutputKey:J.OutputKey,OutputValue:J.OutputValue,Description:J.Description,ExportName:J.ExportName}));q.push({StackId:z.StackId,StackName:z.StackName,StackStatus:z.StackStatus,CreationTime:z.CreationTime,LastUpdatedTime:z.LastUpdatedTime,StackStatusReason:z.StackStatusReason,Outputs:H})}}else if(j.StackId)q.push({StackId:j.StackId,StackName:j.StackName,StackStatus:j.StackStatus,CreationTime:j.CreationTime,LastUpdatedTime:j.LastUpdatedTime});return q}parseStackEvents(j){let q=[],G=j?.DescribeStackEventsResult?.StackEvents?.member||j?.StackEvents?.member||j?.StackEvents||[];if(G&&!Array.isArray(G))G=[G];for(let z of G)if(z.LogicalResourceId)q.push({Timestamp:z.Timestamp,ResourceType:z.ResourceType,LogicalResourceId:z.LogicalResourceId,ResourceStatus:z.ResourceStatus,ResourceStatusReason:z.ResourceStatusReason});return q}async waitForStackWithProgress(j,q,G){let z={"stack-create-complete":["CREATE_COMPLETE"],"stack-update-complete":["UPDATE_COMPLETE"],"stack-delete-complete":["DELETE_COMPLETE"]},H=["CREATE_FAILED","ROLLBACK_FAILED","ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE"],Q=z[q],J=360,I=0,L=new Set;while(I<360)try{if(G)try{let X=[...(await this.describeStackEvents(j)).StackEvents||[]].reverse();for(let Y of X){let Z=`${Y.LogicalResourceId}-${Y.ResourceStatus}-${Y.Timestamp}`;if(!L.has(Z))L.add(Z),G({resourceId:Y.LogicalResourceId,resourceType:Y.ResourceType,status:Y.ResourceStatus,reason:Y.ResourceStatusReason,timestamp:Y.Timestamp})}}catch{}let O=await this.describeStacks({stackName:j});if(O.Stacks.length===0){if(q==="stack-delete-complete")return;await new Promise((U)=>setTimeout(U,2000)),I++;continue}let V=O.Stacks[0];if(Q.includes(V.StackStatus))return;if(V.StackStatus==="DELETE_FAILED"&&q==="stack-delete-complete"){let U=Error("Stack deletion failed - may have resources that need to be retained");throw U.code="DELETE_FAILED",U.stackStatus=V.StackStatus,U.statusReason=V.StackStatusReason,U}if(H.includes(V.StackStatus))throw Error(`Stack reached failure status: ${V.StackStatus}`);await new Promise((U)=>setTimeout(U,3000)),I++}catch(O){if(q==="stack-delete-complete"&&O.message?.includes("does not exist"))return;if(q==="stack-create-complete"&&O.message?.includes("does not exist")){await new Promise((V)=>setTimeout(V,2000)),I++;continue}throw O}throw Error(`Timeout waiting for stack to reach ${q}`)}async waitForStackComplete(j,q=120,G=5000){let z=["CREATE_COMPLETE","UPDATE_COMPLETE","DELETE_COMPLETE"],H=["CREATE_FAILED","UPDATE_FAILED","DELETE_FAILED","ROLLBACK_COMPLETE","ROLLBACK_FAILED","UPDATE_ROLLBACK_COMPLETE","UPDATE_ROLLBACK_FAILED"];for(let Q=0;Q<q;Q++)try{let J=await this.describeStacks({stackName:j});if(J.Stacks.length===0)return{success:!0,status:"DELETE_COMPLETE"};let I=J.Stacks[0],L=I.StackStatus;if(z.includes(L))return{success:!0,status:L};if(H.includes(L))return{success:!1,status:L,reason:I.StackStatusReason};await new Promise((O)=>setTimeout(O,G))}catch(J){if(J.message?.includes("does not exist"))return{success:!0,status:"DELETE_COMPLETE"};throw J}return{success:!1,status:"TIMEOUT",reason:"Timeout waiting for stack operation"}}}
2
- export{$ as jg};
@@ -1,3 +0,0 @@
1
- import{_d as E}from"./chunk-r61qmhv1.js";import{jg as n}from"./chunk-f11xf3n6.js";import{qg as C}from"./chunk-54bqchag.js";import{Lg as k,Mg as Xz,Ng as l,Pg as F,Qg as Y,Rg as m,Yg as Zz}from"./chunk-xjp3v95e.js";import{dh as Jz}from"./chunk-xyt490vp.js";import{$h as $z,Yo as Yz,ai as Wz,bi as Mz,cp as Hz,jo as Oz,ko as _z,mo as Kz,oo as Qz,po as jz}from"./chunk-5bhx3bsa.js";import{pp as t}from"./chunk-c8sypnbe.js";import{existsSync as Lz,readdirSync as Uz,readFileSync as Bz,statSync as Ez}from"node:fs";import{join as Pz,relative as Rz}from"node:path";class d{client;region;constructor(z="us-east-1",G){this.region=z,this.client=new Jz}async createSecret(z){let G={Name:z.Name};if(z.Description)G.Description=z.Description;if(z.KmsKeyId)G.KmsKeyId=z.KmsKeyId;if(z.SecretBinary)G.SecretBinary=z.SecretBinary;if(z.SecretString)G.SecretString=z.SecretString;if(z.Tags&&z.Tags.length>0)G.Tags=z.Tags;if(z.AddReplicaRegions&&z.AddReplicaRegions.length>0)G.AddReplicaRegions=z.AddReplicaRegions;if(z.ForceOverwriteReplicaSecret!==void 0)G.ForceOverwriteReplicaSecret=z.ForceOverwriteReplicaSecret;G.ClientRequestToken=z.ClientRequestToken||crypto.randomUUID();let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.CreateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name,VersionId:J.VersionId,ReplicationStatus:J.ReplicationStatus}}async updateSecret(z){let G={SecretId:z.SecretId};if(z.Description)G.Description=z.Description;if(z.KmsKeyId)G.KmsKeyId=z.KmsKeyId;if(z.SecretBinary)G.SecretBinary=z.SecretBinary;if(z.SecretString)G.SecretString=z.SecretString;let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.UpdateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name,VersionId:J.VersionId}}async putSecretValue(z){let G={SecretId:z.SecretId};if(z.SecretBinary)G.SecretBinary=z.SecretBinary;if(z.SecretString)G.SecretString=z.SecretString;if(z.VersionStages&&z.VersionStages.length>0)G.VersionStages=z.VersionStages;if(z.ClientRequestToken)G.ClientRequestToken=z.ClientRequestToken;let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.PutSecretValue","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name,VersionId:J.VersionId,VersionStages:J.VersionStages}}async getSecretValue(z){let G={SecretId:z.SecretId};if(z.VersionId)G.VersionId=z.VersionId;if(z.VersionStage)G.VersionStage=z.VersionStage;let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.GetSecretValue","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name,VersionId:J.VersionId,SecretBinary:J.SecretBinary,SecretString:J.SecretString,VersionStages:J.VersionStages,CreatedDate:J.CreatedDate}}async describeSecret(z){let G={SecretId:z},J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DescribeSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return this.parseSecret(J)}async listSecrets(z){let G={};if(z?.MaxResults)G.MaxResults=z.MaxResults;if(z?.NextToken)G.NextToken=z.NextToken;if(z?.Filters&&z.Filters.length>0)G.Filters=z.Filters;if(z?.SortOrder)G.SortOrder=z.SortOrder;let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.ListSecrets","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{SecretList:J.SecretList?.map((X)=>this.parseSecret(X)),NextToken:J.NextToken}}async deleteSecret(z){let G={SecretId:z.SecretId};if(z.RecoveryWindowInDays!==void 0)G.RecoveryWindowInDays=z.RecoveryWindowInDays;if(z.ForceDeleteWithoutRecovery!==void 0)G.ForceDeleteWithoutRecovery=z.ForceDeleteWithoutRecovery;let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DeleteSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name,DeletionDate:J.DeletionDate}}async restoreSecret(z){let G={SecretId:z},J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.RestoreSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name}}async rotateSecret(z){let G={SecretId:z.SecretId};if(z.ClientRequestToken)G.ClientRequestToken=z.ClientRequestToken;if(z.RotationLambdaARN)G.RotationLambdaARN=z.RotationLambdaARN;if(z.RotationRules)G.RotationRules=z.RotationRules;if(z.RotateImmediately!==void 0)G.RotateImmediately=z.RotateImmediately;let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.RotateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name,VersionId:J.VersionId}}async cancelRotateSecret(z){let G={SecretId:z},J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.CancelRotateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name}}async getResourcePolicy(z){let G={SecretId:z},J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.GetResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name,ResourcePolicy:J.ResourcePolicy}}async putResourcePolicy(z){let G={SecretId:z.SecretId,ResourcePolicy:z.ResourcePolicy};if(z.BlockPublicPolicy!==void 0)G.BlockPublicPolicy=z.BlockPublicPolicy;let J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.PutResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name}}async deleteResourcePolicy(z){let G={SecretId:z},J=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DeleteResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)});return{ARN:J.ARN,Name:J.Name}}async tagResource(z){let G={SecretId:z.SecretId,Tags:z.Tags};await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.TagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)})}async untagResource(z){let G={SecretId:z.SecretId,TagKeys:z.TagKeys};await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.UntagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(G)})}async setString(z,G,J){try{let X=await this.putSecretValue({SecretId:z,SecretString:G});return{ARN:X.ARN,VersionId:X.VersionId}}catch(X){if(X.code==="ResourceNotFoundException"){let Z=await this.createSecret({Name:z,SecretString:G,Description:J?.description,KmsKeyId:J?.kmsKeyId,Tags:J?.tags});return{ARN:Z.ARN,VersionId:Z.VersionId}}throw X}}async setJson(z,G,J){return this.setString(z,JSON.stringify(G),J)}async getString(z){return(await this.getSecretValue({SecretId:z})).SecretString}async getJson(z){let G=await this.getString(z);if(G)return JSON.parse(G);return}async listAll(){let z=[],G;do{let J=await this.listSecrets({NextToken:G});if(J.SecretList)z.push(...J.SecretList);G=J.NextToken}while(G);return z}parseSecret(z){return{ARN:z.ARN,Name:z.Name,Description:z.Description,KmsKeyId:z.KmsKeyId,RotationEnabled:z.RotationEnabled,RotationLambdaARN:z.RotationLambdaARN,RotationRules:z.RotationRules,LastRotatedDate:z.LastRotatedDate,LastChangedDate:z.LastChangedDate,LastAccessedDate:z.LastAccessedDate,DeletedDate:z.DeletedDate,NextRotationDate:z.NextRotationDate,Tags:z.Tags,SecretVersionsToStages:z.SecretVersionsToStages,CreatedDate:z.CreatedDate,PrimaryRegion:z.PrimaryRegion}}}function q(z,G){let J=z.environments?.[G]?.app;if(!J)throw Error(`No serverless app configured for environment '${G}'. Add environments.${G}.app to your config.`);let X=z.project.slug,Z=z.environments?.[G]?.region||z.project.region||"us-east-1";return{app:J,slug:X,region:Z,stackName:$z(z,G),artifactBucket:Wz(X,G),assetsBucket:Mz(X,G)}}function iz(z,G){let J=q(z,G),X=`${J.slug}-${G}`;return{region:J.region,slug:J.slug,stackName:J.stackName,functions:{http:`${X}-http`,queue:`${X}-queue`,cli:`${X}-cli`}}}async function N(z,G=8){let J;for(let X=0;X<G;X++)try{return await z()}catch(Z){let $=Z?.code||Z?.name||"",W=String(Z?.message||"");if($==="ResourceConflictException"||/update is in progress|currently in the following state/i.test(W)){J=Z,await new Promise((M)=>setTimeout(M,3000));continue}throw Z}throw J}var Tz=(z,G)=>`releases/${z}/${G}/current.json`;async function p(z,G,J,X){try{return await z.getObjectJson(G,Tz(J,X))}catch{return null}}async function Vz(z,G,J,X,Z){await z.putObjectJson(G,Tz(J,X),Z)}async function hz(z,G){if(!z.secrets)return{};let J=new d(G),X={},Z=Array.isArray(z.secrets)?z.secrets.map(($)=>({envName:$.split("/").pop().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),secretId:$})):Object.entries(z.secrets).map(([$,W])=>({envName:$,secretId:W}));if(Array.isArray(z.secrets)){let $=new Map;for(let{envName:M,secretId:O}of Z)$.set(M,[...$.get(M)??[],O]);let W=[...$.entries()].filter(([,M])=>M.length>1);if(W.length){let M=W.map(([O,K])=>`${O} ← ${K.join(", ")}`).join("; ");throw Error(`serverless secrets: multiple secrets map to the same env var (${M}). Use the map form { ENV_NAME: 'secret/id' } to disambiguate.`)}}for(let{envName:$,secretId:W}of Z){let O=(await J.getSecretValue({SecretId:W})).SecretString??"";try{let K=JSON.parse(O);if(K&&typeof K==="object"&&!Array.isArray(K)){for(let[H,j]of Object.entries(K))X[H]=String(j);continue}}catch{}X[$]=O}return X}function Iz(z,G){let J={},X=G.DbProxyEndpoint||G.DbEndpoint;if(X)J.DB_CONNECTION="mysql",J.DB_HOST=X,J.DB_PORT="3306",J.DB_DATABASE=J.DB_DATABASE||"app";if(G.CacheEndpoint){if(J.REDIS_HOST=G.CacheEndpoint,J.REDIS_PORT="6379",z.cache?.driver==="elasticache")J.CACHE_STORE="redis",J.CACHE_DRIVER="redis",J.SESSION_DRIVER="redis"}return J}function o(z,G,J,X,Z,$,W,M={}){let O=z.kind==="php"?Yz({cacheDriver:z.cache?.driver==="elasticache"?"redis":"dynamodb"}):{};return{TSCLOUD_LAMBDA_MODE:X,TSCLOUD_ENV:J,MAINTENANCE_MODE:"0",...z.octane?{TSCLOUD_OCTANE:"1"}:{},...z.serveAssets?{TSCLOUD_SERVE_ASSETS:"1"}:{},...z.redirectRobotsTxt===!1?{TSCLOUD_REDIRECT_ROBOTS_TXT:"0"}:{},...O,...M,...G.app.cache?.driver!=="elasticache"?{TSCLOUD_CACHE_TABLE:`${G.slug}-${J}-cache`}:{},...W?{TSCLOUD_QUEUE:W,SQS_QUEUE:W}:{},...$?{ASSET_URL:$}:{},...z.env??{},...Z}}function Nz(z){let G=z.slice(z.lastIndexOf(".")).toLowerCase();return{".html":"text/html",".css":"text/css",".js":"text/javascript",".mjs":"text/javascript",".json":"application/json",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".txt":"text/plain",".map":"application/json"}[G]??"application/octet-stream"}function*Fz(z){for(let G of Uz(z)){let J=Pz(z,G);if(Ez(J).isDirectory())yield*Fz(J);else yield J}}async function Cz(z,G,J,X,Z=!1){let $=0;for(let W of Fz(J)){let M=Rz(J,W).replace(/\\/g,"/");if(!Z&&M.split("/").some((O)=>O.startsWith(".")))continue;await z.putObject({bucket:G,key:`${X}/${M}`,body:Bz(W),contentType:Nz(W),cacheControl:"public, max-age=31536000, immutable"}),$++}return $}function Sz(z,G){let J=Object.entries(G).reduce((X,[Z,$])=>X+Buffer.byteLength(`${Z}=${$}`,"utf8"),0);if(J>4096){let X=Object.entries(G).map(([Z,$])=>[Z,Buffer.byteLength(`${Z}=${$}`,"utf8")]).sort((Z,$)=>$[1]-Z[1]).slice(0,5).map(([Z,$])=>`${Z} (${$}B)`).join(", ");throw Error(`${z}: environment variables total ${J}B, over AWS's 4096B limit (${J-4096}B too large). Largest: ${X}. Move large/secret values out of env — store them in Secrets Manager and fetch at cold start.`)}}async function b(z,G,J,X){Sz(G,J),await N(()=>z.updateFunctionConfiguration({FunctionName:G,Environment:{Variables:J}})),await z.waitForFunctionActive(G,120);let Z=X.kind==="image"?{FunctionName:G,ImageUri:X.imageUri}:{FunctionName:G,S3Bucket:X.bucket,S3Key:X.key};await N(()=>z.updateFunctionCode(Z)),await z.waitForFunctionActive(G,120)}async function c(z,G){let X=(await N(()=>z.publishVersion({FunctionName:G}))).Version;if(!X)throw Error(`publishVersion returned no version for ${G}`);return await N(()=>z.updateAlias({FunctionName:G,Name:"live",FunctionVersion:X})),X}async function rz(z,G,J={}){let X=q(z,G),{app:Z,slug:$,region:W,stackName:M,artifactBucket:O}=X,K=J.projectRoot??process.cwd();m(`Deploying serverless app: ${$} (${G})`),F(`Stack: ${M}`),F(`Region: ${W}`);let H=new C(W),j=new n(W),V=new E(W),L=Z.kind==="php",U=Z.packaging==="image",Q=Kz(Z),R,A,w,i,g=[];if(U&&Q.usesLayer&&Q.layerKind!=="php")throw Error(`packaging: 'image' currently supports PHP and managed Node runtimes. ${Q.kind}${Q.kind==="node"?` ${Q.version}`:""} uses a custom runtime — `+"use the default zip packaging (the runtime layer is built + attached automatically).");if(U){Y("Building + pushing container image");let{buildAndPushServerlessImage:_}=await import("./chunk-r6gdcz5c.js"),P=await _({app:Z,projectRoot:K,region:W,repository:`${$}-${G}`,skipBuild:J.skipBuild,onStep:(D)=>F(` ${D}`)});R=P.handlers,A={kind:"image",imageUri:P.imageUri},w=P.tag,g.push({ParameterKey:"ImageUri",ParameterValue:P.imageUri})}else{Y("Packaging application");let _=L?Hz({projectRoot:K,app:Z,skipBuild:J.skipBuild,onStep:(B)=>F(` ${B}`)}):await _z({projectRoot:K,app:Z,skipBuild:J.skipBuild,onStep:(B)=>F(` ${B}`)}),P=Oz($,G,_.sha256);if(F(`Artifact: ${_.sha256.slice(0,12)} (${(_.zip.length/1024).toFixed(0)} KB)`),R=_.handlers,w=_.sha256,Q.usesLayer){let B=Q.layerEnvVar?process.env[Q.layerEnvVar]:void 0;if(i=Z.layers??(B?[B]:void 0),!i?.length){let Dz=Q.layerKind==="php"?"serverless:build-php-layer":Q.layerKind==="bun"?"serverless:build-bun-layer":"serverless:build-node-layer";throw Error(`${Q.kind} apps on provided.al2023 need a runtime layer. Set environments.<env>.app.layers or the ${Q.layerEnvVar} env var (build one with \`cloud ${Dz}\`)${Q.kind==="node"?", or use a managed Node version (18/20/22)":""}.`)}}if(!await H.bucketExists(O))Y(`Creating artifact bucket ${O}`),await H.createBucket(O);if(await H.headObject(O,P).then((B)=>B!==null).catch(()=>!1))F("Artifact already uploaded — reusing");else Y("Uploading artifact"),await H.putObject({bucket:O,key:P,body:_.zip,contentType:"application/zip"});A={kind:"zip",bucket:O,key:P},g.push({ParameterKey:"ArtifactBucket",ParameterValue:O},{ParameterKey:"ArtifactKey",ParameterValue:P})}let T=jz({config:z,environment:G,app:Z,handlers:R,runtimeLayers:i}),e=JSON.stringify(T.template),zz=["CAPABILITY_NAMED_IAM"],S=await j.describeStacks({stackName:M}).then((_)=>_.Stacks[0]?.StackStatus).catch(()=>{return}),f=S!==void 0;if(S&&/DELETE_IN_PROGRESS/.test(S))Y("Waiting for an in-progress stack delete to finish"),await j.waitForStack(M,"stack-delete-complete").catch(()=>{}),f=!1;else if(S&&/(?:ROLLBACK_COMPLETE|REVIEW_IN_PROGRESS|CREATE_FAILED)/.test(S))Y(`Deleting unusable stack (status ${S}) before recreate`),await j.deleteStack(M),await j.waitForStack(M,"stack-delete-complete").catch(()=>{}),f=!1;Y(f?"Updating infrastructure stack":"Creating infrastructure stack");try{if(f)await j.updateStack({stackName:M,templateBody:e,parameters:g,capabilities:zz}),await j.waitForStack(M,"stack-update-complete");else await j.createStack({stackName:M,templateBody:e,parameters:g,capabilities:zz,onFailure:"DELETE"}),await j.waitForStack(M,"stack-create-complete")}catch(_){if(/No updates are to be performed/i.test(String(_?.message)))F("No infrastructure changes");else throw _}let r=await j.getStackOutputs(M).catch(()=>({})),h;if(Z.assets){let _=Pz(K,Z.assets);if(Lz(_)){let P=Z.assetDomain||r.AssetsCdnDomain;h=P?`https://${P}/${w}`:void 0,Y(`Syncing assets from ${Z.assets}`);let D=await Cz(H,X.assetsBucket,_,w,Z.dotFilesAsAssets);F(`Uploaded ${D} asset(s)${h?` → ${h}`:""}`)}else l(`Assets directory not found: ${_}`)}Y("Resolving secrets");let x=await hz(Z,W);if(Z.database?.connection==="aurora-serverless")try{let P=await new d(W).getSecretValue({SecretId:`${$}/${G}/db`}),D=JSON.parse(P.SecretString??"{}");if(D.username)x.DB_USERNAME=D.username;if(D.password)x.DB_PASSWORD=D.password}catch(_){l(`Could not resolve Aurora DB credentials: ${_.message}`)}if(!await H.bucketExists(O))await H.createBucket(O);let v=await p(H,O,$,G),I={},a=T.queueNames[0],s=Iz(Z,r);if(Y("Activating functions"),I.http=o(Z,X,G,"http",x,h,a,s),await b(V,T.functionNames.http,I.http,A),I.cli=o(Z,X,G,"cli",x,h,a,s),await b(V,T.functionNames.cli,I.cli,A),T.queueNames.length)I.queue=o(Z,X,G,"queue",x,h,a,s),await b(V,T.functionNames.queue,I.queue,A);let Gz=(Z.provisionedConcurrency??0)>0,u={};if(Gz){if(Y("Publishing versions + flipping live alias"),u.http=await c(V,T.functionNames.http),u.cli=await c(V,T.functionNames.cli),T.queueNames.length)u.queue=await c(V,T.functionNames.queue)}if(await Vz(H,O,$,G,{sha:w,code:A,previousSha:v?.sha,previousCode:v?.code,previousFunctionEnv:v?.functionEnv,...Gz?{functionVersions:u,previousFunctionVersions:v?.functionVersions}:{},functionEnv:I,functionNames:{http:T.functionNames.http,cli:T.functionNames.cli,...T.queueNames.length?{queue:T.functionNames.queue}:{}},assetUrl:h,timestamp:new Date().toISOString()}),!J.skipDeployHooks&&Z.deploy?.length){Y("Running deploy hooks");for(let _ of Z.deploy){F(` deploy: ${_}`);let P=await V.invoke({FunctionName:T.functionNames.cli,InvocationType:"RequestResponse",Payload:{command:_},LogType:"Tail"});if(P.FunctionError)throw Xz("Deploy hook failed — the new build is ALREADY LIVE."),F(` Roll back with: cloud serverless:rollback --env ${G}`),Error(`Deploy hook failed (${_}): ${P.Payload}`)}}let y=r.HttpApiEndpoint;if(!J.skipHealthCheck&&y){Y("Health check");try{let _=await fetch(y,{method:"GET"});F(`GET ${y} → ${_.status}`)}catch(_){l(`Health check could not reach ${y}: ${_.message}`)}}Zz(["Serverless deploy complete","",y?`URL: ${y}`:"",`Stack: ${M}`,`Build: ${w.slice(0,12)}`].filter(Boolean).join(`
2
- `),"green")}async function az(z,G){let J=q(z,G),X=new C(J.region),Z=new E(J.region),$=await p(X,J.artifactBucket,J.slug,G);if(!$)throw Error("No previous release to redeploy. Run a full deploy first.");m(`Redeploying ${J.slug} (${G}) — build ${$.sha.slice(0,12)}`);for(let[W,M]of Object.entries($.functionNames)){if(!M)continue;Y(`Re-activating ${W} (${M})`),await b(Z,M,$.functionEnv[W]??{},$.code);let O=$.functionVersions?.[W];if(O)await N(()=>Z.updateAlias({FunctionName:M,Name:"live",FunctionVersion:O}))}k("Redeploy complete")}async function sz(z,G){let J=q(z,G),X=new C(J.region),Z=new E(J.region),$=await p(X,J.artifactBucket,J.slug,G);if(!$?.previousCode)throw Error("No previous release to roll back to.");m(`Rolling back ${J.slug} (${G}) → ${$.previousSha?.slice(0,12)}`);for(let[W,M]of Object.entries($.functionNames)){if(!M)continue;Y(`Restoring ${W} (${M})`);let O=$.previousFunctionEnv?.[W]??$.functionEnv[W]??{};await b(Z,M,O,$.previousCode);let K=$.previousFunctionVersions?.[W];if(K)await N(()=>Z.updateAlias({FunctionName:M,Name:"live",FunctionVersion:K}))}await Vz(X,J.artifactBucket,J.slug,G,{...$,sha:$.previousSha??$.sha,code:$.previousCode,functionEnv:$.previousFunctionEnv??$.functionEnv,functionVersions:$.previousFunctionVersions??$.functionVersions,previousSha:void 0,previousCode:void 0,previousFunctionEnv:void 0,previousFunctionVersions:void 0,timestamp:new Date().toISOString()}),k("Rollback complete")}async function oz(z,G,J,X){let Z=q(z,G),$=new E(Z.region),W=`${Z.slug}-${G}-http`,O={...(await $.getFunction(W)).Configuration?.Environment?.Variables??{}};if(O.MAINTENANCE_MODE=J?"1":"0",J&&X)O.MAINTENANCE_BYPASS_SECRET=X;if(!J)delete O.MAINTENANCE_BYPASS_SECRET;if(await N(()=>$.updateFunctionConfiguration({FunctionName:W,Environment:{Variables:O}})),(Z.app.provisionedConcurrency??0)>0)await $.waitForFunctionActive(W,120),await c($,W);k(J?"Application is now in maintenance mode (503)":"Application is live")}async function yz(z,G,J){let X=q(z,G),Z=new E(X.region),$=`${X.slug}-${G}-cli`,W=await Z.invoke({FunctionName:$,InvocationType:"RequestResponse",Payload:{command:J},LogType:"Tail"});if(W.FunctionError)throw Error(`Command failed: ${W.Payload}`);return W.Payload??""}var wz=(z,G)=>`commands/${z}/${G}/history.json`,kz=50;async function qz(z,G,J,X){try{return(await z.getObjectJson(G,wz(J,X)))?.records??[]}catch{return[]}}async function tz(z,G,J){let X=q(z,G),Z=new E(X.region),$=`${X.slug}-${G}-cli`,W=await Z.invoke({FunctionName:$,InvocationType:"RequestResponse",Payload:{command:J},LogType:"Tail"}),M=W.Payload??"",O=W.FunctionError?"error":"ok",K=-1;try{let H=new C(X.region);if(await H.bucketExists(X.artifactBucket)){let j=await qz(H,X.artifactBucket,X.slug,G);K=j.reduce((V,L)=>Math.max(V,L.id),0)+1,j.push({id:K,command:J,timestamp:new Date().toISOString(),status:O,output:M.slice(0,4000)}),await H.putObjectJson(X.artifactBucket,wz(X.slug,G),{records:j.slice(-kz)})}}catch{}if(W.FunctionError)throw Error(`Command failed${K>0?` (#${K})`:""}: ${M}`);return{id:K,status:O,output:M}}async function xz(z,G){let J=q(z,G),X=new C(J.region);return qz(X,J.artifactBucket,J.slug,G)}async function nz(z,G,J){let X=await xz(z,G);if(!X.length)return;return J==null?X[X.length-1]:X.find((Z)=>Z.id===J)}async function ez(z,G,J){let X=Buffer.from(J,"utf-8").toString("base64");return yz(z,G,`tscloud:db-query --sql-base64=${X}`)}async function zG(z,G){let J=q(z,G),X=new n(J.region),Z=new E(J.region),$=new C(J.region),W="not deployed",M={};try{let{Stacks:U}=await X.describeStacks({stackName:J.stackName});W=U?.[0]?.StackStatus??W;for(let Q of U?.[0]?.Outputs??[])if(Q.OutputKey)M[Q.OutputKey]=Q.OutputValue??""}catch{}let O=Qz(J.app,J.slug,G),K=J.app.provisionedConcurrency??0,H=["http","cli",...O.length?["queue"]:[]],j=`${J.slug}-${G}`,V=[];for(let U of H){let Q=`${j}-${U}`,R={mode:U,name:Q,version:"$LATEST"};if(K>0){let A=await Z.getAlias(Q,"live").catch(()=>null);if(A?.FunctionVersion){R.version=A.FunctionVersion;let w=await Z.getProvisionedConcurrencyConfig(Q,"live").catch(()=>null);if(w)R.provisioned={status:w.Status??"-",allocated:w.AllocatedProvisionedConcurrentExecutions??0,requested:w.RequestedProvisionedConcurrentExecutions??0}}}V.push(R)}let L=await p($,J.artifactBucket,J.slug,G).catch(()=>null);return{slug:J.slug,environment:G,region:J.region,stackStatus:W,endpoint:M.HttpApiEndpoint,assetUrl:L?.assetUrl,scheduler:J.app.scheduler??"on",queues:O,provisionedConcurrency:K,functions:V,lastRelease:L?{sha:L.sha,timestamp:L.timestamp}:void 0}}function Az(z,G){return`${z}-${G}-db`}async function GG(z,G,J,X){let Z=q(z,G);if(Z.app.database?.connection!=="aurora-serverless")throw Error("No Aurora Serverless v2 database is configured for this environment.");let{RDSClient:$}=await import("./chunk-4esma5m9.js"),W=new $(Z.region),M=Az(Z.slug,G);Y(`Scaling ${M} → ${J}–${X} ACUs`),await W.modifyDBCluster({DBClusterIdentifier:M,ServerlessV2ScalingConfiguration:{MinCapacity:J,MaxCapacity:X},ApplyImmediately:!0}),k(`Scaling applied to ${M} (takes effect shortly).`)}async function JG(z,G,J){let X=q(z,G);if(X.app.database?.connection!=="aurora-serverless")throw Error("No Aurora Serverless v2 database is configured for this environment.");if(!J.toTime&&!J.latest)throw Error("Specify a restore point: --to <ISO timestamp> or --latest.");let{RDSClient:Z}=await import("./chunk-4esma5m9.js"),$=new Z(X.region),W=Az(X.slug,G),M=J.latest?"latest":J.toTime.toISOString().replace(/[^0-9]/g,"").slice(0,14),O=J.target??`${W}-restore-${M}`;Y(`Restoring ${W} → new cluster ${O} (${J.latest?"latest restorable time":J.toTime.toISOString()})`),await $.restoreDBClusterToPointInTime({DBClusterIdentifier:O,SourceDBClusterIdentifier:W,RestoreToTime:J.toTime,UseLatestRestorableTime:J.latest}),Y("Waiting for the restored cluster to be ready");for(let K=0;K<120;K++){let{DBClusters:H}=await $.describeDBClusters({DBClusterIdentifier:O}),j=H?.[0]?.Status;if(j&&j!=="creating")break;await new Promise((V)=>setTimeout(V,15000))}return Y("Adding a writer instance"),await $.createDBInstance({DBInstanceIdentifier:`${O}-1`,DBClusterIdentifier:O,Engine:"aurora-mysql",DBInstanceClass:"db.serverless"}),k(`Restore complete → cluster ${O} with writer ${O}-1. Point an env's database at it once available.`),O}
3
- export{d as Id,iz as Jd,hz as Kd,Iz as Ld,o as Md,Sz as Nd,rz as Od,az as Pd,sz as Qd,oz as Rd,yz as Sd,tz as Td,xz as Ud,nz as Vd,ez as Wd,zG as Xd,GG as Yd,JG as Zd};
@@ -1 +0,0 @@
1
- import{Gd as a}from"./chunk-m22krd4z.js";import"./chunk-b6by94pk.js";import"./chunk-fq7ktvgy.js";import"./chunk-r61qmhv1.js";import"./chunk-4n0j3n3b.js";import"./chunk-f11xf3n6.js";import"./chunk-54bqchag.js";import"./chunk-xjp3v95e.js";import"./chunk-xyt490vp.js";import"./chunk-5bhx3bsa.js";import"./chunk-c8sypnbe.js";export{a as resolveDashboardData};
@@ -1 +0,0 @@
1
- import{Ye as a}from"./chunk-ett305ym.js";import"./chunk-xyt490vp.js";import"./chunk-c8sypnbe.js";export{a as EC2Client};
@@ -1 +0,0 @@
1
- import{ch as a,dh as b,eh as c,fh as d}from"./chunk-xyt490vp.js";import"./chunk-c8sypnbe.js";export{a as resolveS3Endpoint,d as detectCredentialSource,c as buildQueryParams,b as AWSClient};
@@ -1 +0,0 @@
1
- import{$h as V,$i as Va,$j as Vb,$k as Vc,$l as Vd,$m as Ve,$n as Wf,$o as Wg,Ah as u,Ai as ua,Aj as ub,Ak as uc,Al as ud,Am as ue,An as vf,Ao as vg,Bh as v,Bi as va,Bj as vb,Bk as vc,Bl as vd,Bm as ve,Bn as wf,Bo as wg,Ch as w,Ci as wa,Cj as wb,Ck as wc,Cl as wd,Cm as we,Cn as xf,Co as xg,Dh as x,Di as xa,Dj as xb,Dk as xc,Dl as xd,Dm as xe,Dn as yf,Do as yg,Eh as y,Ei as ya,Ej as yb,Ek as yc,El as yd,Em as ye,En as zf,Eo as zg,Fh as z,Fi as za,Fj as zb,Fk as zc,Fl as zd,Fm as ze,Fn as Af,Fo as Ag,Gh as A,Gi as Aa,Gj as Ab,Gk as Ac,Gl as Ad,Gm as Ae,Gn as Bf,Go as Bg,Hh as B,Hi as Ba,Hj as Bb,Hk as Bc,Hl as Bd,Hm as Be,Hn as Cf,Ho as Cg,Ih as C,Ii as Ca,Ij as Cb,Ik as Cc,Il as Cd,Im as Ce,In as Df,Io as Dg,Jh as D,Ji as Da,Jj as Db,Jk as Dc,Jl as Dd,Jm as De,Jn as Ef,Jo as Eg,Kh as E,Ki as Ea,Kj as Eb,Kk as Ec,Kl as Ed,Km as Ee,Kn as Ff,Ko as Fg,Lh as F,Li as Fa,Lj as Fb,Lk as Fc,Ll as Fd,Lm as Fe,Ln as Gf,Lo as Gg,Mh as G,Mi as Ga,Mj as Gb,Mk as Gc,Ml as Gd,Mm as Ge,Mn as Hf,Mo as Hg,Nh as H,Ni as Ha,Nj as Hb,Nk as Hc,Nl as Hd,Nm as He,Nn as If,No as Ig,Oh as I,Oi as Ia,Oj as Ib,Ok as Ic,Ol as Id,Om as Ie,On as Jf,Oo as Jg,Ph as J,Pi as Ja,Pj as Jb,Pk as Jc,Pl as Jd,Pm as Je,Pn as Kf,Po as Kg,Qh as K,Qi as Ka,Qj as Kb,Qk as Kc,Ql as Kd,Qm as Ke,Qn as Lf,Qo as Lg,Rh as L,Ri as La,Rj as Lb,Rk as Lc,Rl as Ld,Rm as Le,Rn as Mf,Ro as Mg,Sh as M,Si as Ma,Sj as Mb,Sk as Mc,Sl as Md,Sm as Me,Sn as Nf,So as Ng,Th as N,Ti as Na,Tj as Nb,Tk as Nc,Tl as Nd,Tm as Ne,Tn as Of,To as Og,Uh as O,Ui as Oa,Uj as Ob,Uk as Oc,Ul as Od,Um as Oe,Un as Pf,Uo as Pg,Vh as P,Vi as Pa,Vj as Pb,Vk as Pc,Vl as Pd,Vm as Pe,Vn as Qf,Vo as Qg,Wh as Q,Wi as Qa,Wj as Qb,Wk as Qc,Wl as Qd,Wm as Qe,Wn as Rf,Wo as Rg,Xh as R,Xi as Ra,Xj as Rb,Xk as Rc,Xl as Rd,Xm as Re,Xn as Sf,Xo as Sg,Yh as S,Yi as Sa,Yj as Sb,Yk as Sc,Yl as Sd,Ym as Se,Yn as Tf,Yo as Tg,Zh as T,Zi as Ta,Zj as Tb,Zk as Tc,Zl as Td,Zm as Te,Zn as Uf,Zo as Ug,_h as U,_i as Ua,_j as Ub,_k as Uc,_l as Ud,_m as Ue,_n as Vf,_o as Vg,ai as W,aj as Wa,ak as Wb,al as Wc,am as Wd,an as We,ao as Xf,ap as Xg,bi as X,bj as Xa,bk as Xb,bl as Xc,bm as Xd,bn as Xe,bo as Yf,bp as Yg,ci as Y,cj as Ya,ck as Yb,cl as Yc,cm as Yd,cn as Ye,co as Zf,cp as Zg,di as Z,dj as Za,dk as Zb,dl as Zc,dm as Zd,dn as Ze,do as _f,dp as _g,ei as _,ej as _a,ek as _b,el as _c,em as _d,en as _e,eo as $f,ep as $g,fi as $,fj as $a,fk as $b,fl as $c,fm as $d,fn as $e,fo as ag,fp as ah,gh as a,gi as aa,gj as ab,gk as ac,gl as ad,gm as ae,gn as af,go as bg,gp as bh,hh as b,hi as ba,hj as bb,hk as bc,hl as bd,hm as be,hn as bf,ho as cg,hp as ch,ih as c,ii as ca,ij as cb,ik as cc,il as cd,im as ce,in as cf,io as dg,ip as dh,jh as d,ji as da,jj as db,jk as dc,jl as dd,jm as de,jn as df,jo as eg,jp as eh,kh as e,ki as ea,kj as eb,kk as ec,kl as ed,km as ee,kn as ef,ko as fg,kp as fh,lh as f,li as fa,lj as fb,lk as fc,ll as fd,lm as fe,ln as ff,lo as gg,lp as gh,mh as g,mi as ga,mj as gb,mk as gc,ml as gd,mm as ge,mn as gf,mo as hg,mp as hh,nh as h,ni as ha,nj as hb,nk as hc,nl as hd,nm as he,nn as hf,no as ig,oh as i,oi as ia,oj as ib,ok as ic,ol as id,om as ie,on as jf,oo as jg,ph as j,pi as ja,pj as jb,pk as jc,pl as jd,pm as je,pn as kf,po as kg,qh as k,qi as ka,qj as kb,qk as kc,ql as kd,qm as ke,qn as lf,qo as lg,rh as l,ri as la,rj as lb,rk as lc,rl as ld,rm as le,rn as mf,ro as mg,sh as m,si as ma,sj as mb,sk as mc,sl as md,sm as me,sn as nf,so as ng,th as n,ti as na,tj as nb,tk as nc,tl as nd,tm as ne,tn as of,to as og,uh as o,ui as oa,uj as ob,uk as oc,ul as od,um as oe,un as pf,uo as pg,vh as p,vi as pa,vj as pb,vk as pc,vl as pd,vm as pe,vn as qf,vo as qg,wh as q,wi as qa,wj as qb,wk as qc,wl as qd,wm as qe,wn as rf,wo as rg,xh as r,xi as ra,xj as rb,xk as rc,xl as rd,xm as re,xn as sf,xo as sg,yh as s,yi as sa,yj as sb,yk as sc,yl as sd,ym as se,yn as tf,yo as tg,zh as t,zi as ta,zj as tb,zk as tc,zl as td,zm as te,zn as uf,zo as ug}from"./chunk-5bhx3bsa.js";import"./chunk-c8sypnbe.js";export{Me as xrayManager,uc as withTimeout,sb as withSecurity,wb as withQueue,rb as withMonitoring,Jg as withInvocation,tb as withDatabase,ub as withCache,vb as withCDN,I as validateTemplateSize,H as validateTemplate,J as validateResourceLimits,Yb as validateCredentials,Wb as validateConfiguration,pd as validateCommand,Fc as validateAgainstSchema,ae as validateAccountStructure,gc as templateCache,Se as syntheticsManager,Od as suggestRegions,Pd as suggestRegionPairs,dc as suggestQuotaIncrease,$b as suggestIAMPolicy,md as suggestFlags,gd as suggestCommand,bh as storageAdvancedManager,$g as staticSiteManager,u as statePath,t as stateDir,Fd as stackDependencyManager,c as signRequestAsync,b as signRequest,qg as sharedRuntimeLoop,Gg as sharedRecursionGuard,dg as sha256,s as setStateDir,pf as serviceMeshManager,tc as sequence,Nf as senderReputationManager,gf as securityScanningManager,Ce as securityHubManager,af as secretsRotationManager,cf as secretsManager,kd as searchCommands,O as sanitizeName,Xg as runPhpBuildHooks,cg as runBuildHooks,Df as route53RoutingManager,Hf as route53ResolverManager,Mg as responseToResult,hh as resourceManagementManager,T as resolveStorageBucketName,v as resolveStatePath,Q as resolveSiteStackName,R as resolveSiteResourceName,S as resolveSiteBucketName,hg as resolveServerlessRuntime,X as resolveServerlessAssetBucketName,W as resolveServerlessArtifactBucketName,V as resolveServerlessAppStackName,Fb as resolveRegion,Eg as resolveRecursionConfig,ig as resolveQueues,jg as resolveQueueNames,P as resolveProjectStackName,lb as resolveManagementDashboardSites,mb as resolveManagementDashboardSite,C as resolveMailService,y as resolveDeploymentMode,U as resolveDeployBucketName,gb as resolveDashboardDomains,fb as resolveDashboardDomain,Eb as resolveCredentials,F as resolveCloudProvider,A as resolveAppDatabase,Kg as resolveApp,Hg as resetRecursionRuntime,Ac as requiresReplacement,We as replicaManager,Ed as regionPairManager,Cg as recursionBlockedResponse,mc as quickHash,$f as queueManagementManager,Bg as propagationHeaders,Ke as progressiveDeploymentManager,xc as processInChunks,Wc as previewNotifications,Rc as previewManager,Sg as phpRuntimeLayerAssets,mg as phpLayerPackages,ng as phpLayerBuildStage,Ye as performanceManager,i as parseXMLResponse,j as parseJSONResponse,yg as parseChain,sc as parallelWithRetry,rc as parallelMap,pc as parallel,fg as packageServerlessApp,Zg as packagePhpApp,Wd as organizationManager,fh as networkSecurityManager,xd as multiRegionManager,Vd as multiAccountManager,Ue as migrationManager,Oe as metricsManager,qb as mergeInfrastructure,jb as managementDashboardSiteName,g as makeAWSRequestOnce,h as makeAWSRequestAsync,f as makeAWSRequest,D as mailFirewallPorts,B as mailEnabled,Qe as logsManager,Tg as laravelServerlessEnvDefaults,tf as lambdaVersionsManager,zf as lambdaVPCManager,rf as lambdaLayersManager,xf as lambdaDestinationsManager,Bf as lambdaDLQManager,vf as lambdaConcurrencyManager,n as isWebCryptoAvailable,Md as isValidRegion,w as isStatePath,m as isNodeCryptoAvailable,kb as isManagementDashboardSiteName,Ic as isLocalDevelopment,id as isLikelyTypo,Dg as invocationContext,Fg as installRecursionFetch,zg as inspectInvocation,jf as imageScanningManager,dh as healthCheckManager,ic as hashString,lc as hashManifest,hc as hashFile,kc as hashDirectory,jc as hashBuffer,hb as hasManagementDashboardSite,Ae as guardDutyManager,Dd as globalResourceManager,N as getTimestamp,l as getSigningKeyCacheSize,_b as getRequiredPermissions,Ld as getRegionsByPricingTier,Jd as getRegionsByLocation,Kd as getRegionsByCompliance,Sd as getRegionStats,Hd as getRegion,_d as getRecommendedStructure,cc as getQuotaUsageSummary,Lc as getLocalEnvVars,Jc as getLocalEndpoint,Kc as getLocalCredentials,Hc as getLocalConfig,Tb as getErrorDetails,zc as getDiffSummary,Dc as getDiffStats,Cc as getDeploymentStrategy,Cb as getCredentials,jd as getContextualHelp,od as getCommandUsage,Nd as getClosestRegion,Id as getAllRegions,Gb as getAccountId,fe as generateScheduledWorkflow,ke as generateScheduledPipeline,oe as generateScheduledConfig,L as generateResourceName,Sc as generatePreviewWorkflow,je as generatePreviewPipeline,og as generatePhpLayerDockerfile,Rg as generatePhpFpmConfig,qe as generateParallelConfig,ee as generatePRPreviewWorkflow,de as generateMultiEnvWorkflow,ie as generateMultiEnvPipeline,ne as generateMultiEnvConfig,ge as generateMatrixWorkflow,le as generateManualPipeline,M as generateLogicalId,ce as generateDeploymentWorkflow,he as generateDeploymentPipeline,me as generateDeploymentConfig,$d as generateCrossAccountRoleCF,Uc as generateCostReportWorkflow,Tc as generateCleanupWorkflow,bg as generateBootstrap,pe as generateApprovalConfig,pg as generateAppImageDockerfile,wg as functionFingerprint,Bb as fromWebIdentity,yb as fromSharedCredentials,xb as fromEnvironment,Ab as fromECSMetadata,zb as fromEC2Metadata,Yc as formatTree,Xc as formatTable,hd as formatSuggestion,Rd as formatRegionList,Qd as formatRegion,Zc as formatProgressBar,ad as formatList,bd as formatKeyValue,vd as formatHistoryStats,ud as formatHistory,nd as formatFlagSuggestions,$c as formatDuration,_ as formatDiff,_c as formatBytes,be as formatAccountStructure,nc as findChangedFiles,Vf as fifoQueueManager,nb as extendPreset,Lg as eventToRequest,Pf as emailTemplateManager,Lf as emailAnalyticsManager,ue as drManager,Ff as dnssecManager,Xf as dlqMonitoringManager,yc as diffTemplates,a as detectServiceRegion,Xb as detectMisconfigurations,x as detectDeploymentTargets,eb as deriveManagementDashboardPort,z as deploymentCoexistenceError,Gc as defaultLocalConfig,_e as databaseUserManager,Cd as crossRegionReferenceManager,ag as createZip,Sa as createWordPressPreset,Ya as createTraditionalWebAppPreset,La as createStaticSitePreset,Oa as createServerlessNodePreset,_a as createServerlessLaravelPreset,Kb as createS3Client,Va as createRealtimeAppPreset,Og as createQueueHandler,e as createPresignedUrlAsync,d as createPresignedUrl,pb as createPreset,Na as createNodeJsServerlessPreset,Ma as createNodeJsServerPreset,Pc as createMockAWS,Ua as createMicroservicesPreset,Xa as createMLApiPreset,Za as createLaravelPreset,Ta as createJamstackPreset,Ng as createHttpHandler,Qg as createHandlers,Qa as createFullStackAppPreset,Pa as createExistingStaticFullStackPreset,Ub as createError,Wa as createDataPipelinePreset,$a as createDashboardSite,Db as createCredentialProvider,Pg as createCliHandler,Ra as createApiBackendPreset,nf as containerRegistryManager,kg as composeServerlessAppTemplate,ob as composePresets,Yg as collectPhpAppEntries,ye as cloudTrailManager,Ec as cloudConfigSchema,k as clearSigningKeyCache,wc as chunk,bc as checkServiceQuotas,Ig as checkInvocation,Zb as checkIAMPermissions,ef as certificateManager,Bc as categorizeChanges,Ge as canaryManager,Vg as buildPhpRuntimeLayerZip,lf as buildOptimizationManager,rg as buildNodeRuntimeLayerZip,E as buildMailEnv,Ka as buildCloudFormationTemplate,sg as buildBunRuntimeLayerZip,Jf as bounceComplaintHandler,Ee as blueGreenManager,Zf as batchProcessingManager,qc as batch,se as backupManager,we as awsConfigManager,ld as autocomplete,eg as artifactKey,Z as analyzeStackDiff,Ie as abTestManager,Le as XRayManager,wa as Workflow,Qb as ValidationError,fc as TemplateCache,G as TemplateBuilder,fd as TaskList,vg as TRACE_HEADER,Re as SyntheticsManager,ah as StorageAdvancedManager,$ as Storage,_g as StaticSiteManager,ma as StacksIntegration,Bd as StackDependencyManager,ed as Spinner,na as SmsHandlers,Tf as SmsAdvanced,pa as Sftp,of as ServiceMeshManager,Mf as SenderReputationManager,ff as SecurityScanningManager,Be as SecurityHubManager,da as Security,$e as SecretsRotationManager,bf as SecretsManager,Ba as Secrets,Da as Search,r as STATE_DIR_ENV_VAR,oa as SMS,Jb as S3Error,Ib as S3Client,Cf as Route53RoutingManager,Gf as Route53ResolverManager,gh as ResourceManagementManager,Ve as ReplicaManager,aa as Registry,Ad as RegionPairManager,Ea as Redirects,Ag as RecursionGuard,p as RealtimePresets,vc as RateLimiter,rd as REPLContext,sd as REPLCommandBuilder,qd as REPL,Yd as RECOMMENDED_SCPS,Xd as RECOMMENDED_ACCOUNT_STRUCTURES,o as QueuePresets,_f as QueueManagementManager,ka as Queue,K as Pseudo,Je as ProgressiveDeploymentManager,cd as ProgressBar,Vc as PreviewNotificationService,Qc as PreviewEnvironmentManager,ia as PhoneHandlers,Sf as PhoneAdvanced,ja as Phone,ta as Permissions,Xe as PerformanceManager,Ca as ParameterStore,lg as PHP_LAYER_EXTENSIONS,Wg as PHP_DEFAULT_EXCLUDES,Ud as OrganizationManager,eh as NetworkSecurityManager,fa as Network,dd as MultiStepProgress,wd as MultiRegionManager,Td as MultiAccountManager,xa as Monitoring,Nc as MockS3,Oc as MockDynamoDB,Mc as MockCloudFormation,Te as MigrationManager,Ne as MetricsManager,va as Messaging,ib as MANAGEMENT_DASHBOARD_SITE_PREFIX,gg as MANAGED_NODE_VERSIONS,Pe as LogsManager,sf as LambdaVersionsManager,yf as LambdaVPCManager,qf as LambdaLayersManager,wf as LambdaDestinationsManager,Af as LambdaDLQManager,uf as LambdaConcurrencyManager,Ug as LARAVEL_SERVERLESS_BUILD_STEPS,la as JobLoader,hf as ImageScanningManager,ch as HealthCheckManager,oc as HashCache,ze as GuardDutyManager,zd as GlobalResourceManager,Ga as Fn,ga as FileSystem,ec as FileCache,Uf as FIFOQueueManager,Sb as ErrorCodes,Of as EmailTemplateManager,Rf as EmailHandlers,Kf as EmailAnalyticsManager,Qf as EmailAdvanced,ha as Email,te as DisasterRecoveryManager,Pb as DeploymentError,za as Deployment,Y as DependencyGraph,Vb as DebugLogger,Ze as DatabaseUserManager,ra as Database,Ef as DNSSECManager,ca as DNS,Wf as DLQMonitoringManager,tg as DEPTH_HEADER,q as DEFAULT_STATE_DIR,ac as DEFAULT_SERVICE_LIMITS,xg as DEFAULT_RECURSION_LIMITS,ab as DASHBOARD_STATE_DIR,db as DASHBOARD_PORT_SPAN,cb as DASHBOARD_PORT_BASE,bb as DASHBOARD_ENTRY,yd as CrossRegionReferenceManager,Ob as CredentialError,mf as ContainerRegistryManager,Nb as ConfigurationError,ea as Compute,Fa as Communication,td as CommandHistory,xe as CloudTrailManager,Lb as CloudFrontClient,Hb as CloudFormationClient,Ja as CloudFormationBuilder,Mb as CloudError,df as CertificateManager,Fe as CanaryManager,sa as Cache,Zd as COMMON_CROSS_ACCOUNT_ROLES,ug as CHAIN_HEADER,ba as CDN,kf as BuildOptimizationManager,If as BounceComplaintHandler,De as BlueGreenManager,Yf as BatchProcessingManager,re as BackupManager,ya as Auth,Aa as AssetHasher,Ha as Arn,ua as ApiGateway,Gd as AWS_REGIONS,Ia as AWS_PSEUDO_PARAMETERS,ve as AWSConfigManager,Rb as AWSAPIError,qa as AI,He as ABTestManager};
@@ -1 +0,0 @@
1
- import{lf as a,mf as b,nf as c,of as d,pf as e,qf as f,rf as g,sf as h,tf as i,uf as j}from"./chunk-k5vprsef.js";import"./chunk-5bhx3bsa.js";import"./chunk-c8sypnbe.js";export{f as stageLiveDashboardRoot,g as resolveUiSource,e as resolveDashboardVersion,c as resolveDashboardAuth,i as managementDashboardSiteNames,d as liveStageDir,h as ensureManagementDashboard,b as dashboardCredentialsFile,j as buildManagementDashboardArtifact,a as MANAGEMENT_DASHBOARD_SITE};
@@ -1,6 +0,0 @@
1
- import{Ah as L,Bh as T,nj as P,qj as F,rj as _}from"./chunk-5bhx3bsa.js";import{execSync as R}from"node:child_process";import{randomBytes as p}from"node:crypto";import{chmodSync as u,copyFileSync as h,existsSync as G,mkdirSync as x,readFileSync as D,statSync as f,writeFileSync as B}from"node:fs";import{tmpdir as l}from"node:os";import{basename as d,dirname as U,isAbsolute as j,join as Z,resolve as g}from"node:path";import{fileURLToPath as k}from"node:url";function I(J){if(!J||typeof J!=="object")return J;return Object.fromEntries(Object.keys(J).map((K)=>[K,""]))}function y(J){let K=JSON.parse(JSON.stringify(J??{}));if(K.hetzner)delete K.hetzner.apiToken;delete K.aws,delete K.stateDir;for(let Q of Object.values(K.sites??{})){if(Q?.env)Q.env=I(Q.env);if(Q?.environment)Q.environment=I(Q.environment)}for(let Q of Object.values(K.environments??{}))if(Q?.variables)Q.variables=I(Q.variables);for(let Q of Object.values(K.infrastructure?.databases??{}))if(Q?.password)Q.password="";if(K.infrastructure?.appDatabase?.password)K.infrastructure.appDatabase.password="";if(K.infrastructure?.compute?.database?.password)K.infrastructure.compute.database.password="";if(K.infrastructure?.compute?.managedServices?.vitess?.password)K.infrastructure.compute.managedServices.vitess.password="";return K}function A(J){let K=y(J);return["// Generated by ts-cloud for the management dashboard — do not edit.","//","// This is the project's resolved cloud config, inlined so it needs no","// imports on the box. Credentials are deliberately absent.",`export default ${JSON.stringify(K,null,2)}`,""].join(`
2
- `)}var c="dashboard";function w(){return L("dashboard-credentials.json")}function a(){return p(24).toString("base64url")}function t(J,K,Q){let X=process.env.TS_CLOUD_UI_PASSWORD?.trim();if(X)return{password:X,source:"env"};if(N(process.env.TS_CLOUD_UI_PUBLIC))return{password:void 0,source:"public"};let W=w(),$=T(J,"dashboard-credentials.json");try{if(G($)){let Y=JSON.parse(D($,"utf8"));if(Y?.password)return{password:Y.password,source:"generated"}}}catch{}let z=a();try{x(U($),{recursive:!0}),B($,`${JSON.stringify({username:K,password:z,generatedAt:new Date().toISOString()},null,2)}
3
- `),u($,384),Q.info(`Management dashboard: generated a password for '${K}' and saved it to ${W} (read it there — it is not printed). Set TS_CLOUD_UI_PASSWORD to pin your own, or TS_CLOUD_UI_PUBLIC=1 to serve without auth.`)}catch(Y){Q.warn(`Management dashboard: could not persist the generated password (${Y?.message??Y}). Using it for this deploy only — pass: ${z}
4
- This password is now in your deploy log. Set TS_CLOUD_UI_PASSWORD to a value of your own and redeploy once ${W} is writable.`)}return{password:z,source:"generated"}}var S={info:()=>{},warn:()=>{}};function N(J){return J!=null&&J!==""&&J!=="0"&&J.toLowerCase()!=="false"}function r(){return L("dashboard-release")}function v(){let J=U(k(import.meta.url));for(let K of[Z(J,"..","..","package.json"),Z(J,"..","package.json")])try{let Q=JSON.parse(D(K,"utf8"));if(Q.name==="@stacksjs/ts-cloud"&&Q.version)return`^${Q.version}`}catch{}return"latest"}function s(){return process.env.TS_CLOUD_UI_VERSION?.trim()||v()}function n(J,K,Q){if(!J?.project?.slug)return Q.warn("Management dashboard: the cloud config has no project slug — skipping the live dashboard."),null;let X=T(K,"dashboard-release");try{x(X,{recursive:!0}),B(Z(X,"cloud.config.ts"),A(J));let W=s();if(W.startsWith("file:")){let z=W.slice(5),Y=j(z)?z:g(K,z);if(!G(Y)||!f(Y).isFile())W=v(),Q.warn(`Management dashboard: TS_CLOUD_UI_VERSION points to a missing package file (${Y}); using the deploying ts-cloud version ${W} instead.`);else{let H=d(Y),O=Z(X,H);if(Y!==O)h(Y,O);W=`file:./${H}`}}let $={name:"ts-cloud-dashboard",private:!0,type:"module",dependencies:{"@stacksjs/ts-cloud":W}};return B(Z(X,"package.json"),`${JSON.stringify($,null,2)}
5
- `),r()}catch(W){return Q.warn(`Management dashboard: could not stage the live release (${W?.message??W}) — skipping.`),null}}function i(J){if(G(Z(J,"packages","ui","pages"))||G(Z(J,"packages","ui","package.json")))return{uiRoot:"packages/ui/dist",build:"cd packages/ui && bun install && bun run build"};let K=U(k(import.meta.url)),Q=[Z(K,"ui"),Z(K,"..","ui"),Z(K,"..","..","ui"),Z(K,"..","dist","ui")];for(let X of Q)if(G(Z(X,"index.html"))||G(Z(X,"serverless.html")))return{uiRoot:X,build:!1};return null}function $J(J,K={}){let Q=K.logger??S,X=K.cwd??process.cwd();if(N(process.env.TS_CLOUD_UI_DISABLE))return Q.info("Management dashboard: skipped (TS_CLOUD_UI_DISABLE set)."),J;if(J.cloud?.attachTo)return Q.info(`Management dashboard: ${J.project.slug} is attached to ${J.cloud.attachTo}; the server owner's dashboard monitors every attached project.`),J;if(P(J))return J;let W=J.environments&&Object.keys(J.environments)[0],$=process.env.TS_CLOUD_UI_DOMAIN?.trim()||void 0,z=Number(process.env.TS_CLOUD_UI_PORT)||void 0,Y={...J.sites??{}};if(!N(process.env.TS_CLOUD_UI_STATIC)){let C=n(J,X,Q);if(!C)return J;let q=_(J,W??"production",{uiRoot:C,build:!1,domain:$,port:z,live:!0});if(q.length===0)return Q.info("Management dashboard: no domain resolved (set TS_CLOUD_UI_DOMAIN or configure a site domain) — skipping."),J;for(let{name:b,site:V}of q)Y[b]=V,Q.info(`Management dashboard → https://${V.domain} (sign in with your ts-cloud account; the first deploy prints an admin password once)`);return J.sites=Y,J}let H=i(X);if(!H)return Q.info("Management dashboard: UI not found (no local ui/ or packaged dist/ui) — skipping auto-deploy."),J;let O=process.env.TS_CLOUD_UI_USERNAME?.trim()||"admin",E=t(X,O,Q),M=_(J,W??"production",{uiRoot:H.uiRoot,build:H.build,domain:$,username:O,password:E.password,realm:process.env.TS_CLOUD_UI_REALM?.trim()||void 0,live:!1,port:z});if(M.length===0)return Q.info("Management dashboard: no domain resolved (set TS_CLOUD_UI_DOMAIN or configure a site domain) — skipping."),J;let m=E.source==="public"?"NO AUTH — TS_CLOUD_UI_PUBLIC is set (dashboard is publicly reachable)":E.source==="env"?"htpasswd-protected (TS_CLOUD_UI_PASSWORD)":`htpasswd-protected (auto-generated — see ${w()})`;Q.warn("Management dashboard: static mode — one shared password, and no per-site collaborators. Unset TS_CLOUD_UI_STATIC for the live dashboard.");for(let{name:C,site:q}of M)Y[C]=q,Q.info(`Management dashboard → https://${q.domain} (${m})`);return J.sites=Y,J}function zJ(J){return Object.keys(J.sites??{}).filter(F)}function GJ(J,K){if(!J?.root)return null;let Q=K.cwd??process.cwd(),X=K.logger??S;try{if(typeof J.build==="string"&&J.build.trim())X.info(`Management dashboard: building UI (${J.build})`),R(J.build,{cwd:Q,stdio:"inherit"});let W=j(J.root)?J.root:Z(Q,J.root);if(!G(W))return X.warn(`Management dashboard: build output not found at ${W} — skipping dashboard artifact.`),null;let $=Z(l(),`${K.slug}-${K.siteName??c}-${K.sha}.tar.gz`);return R(`tar czf "${$}" -C "${W}" .`,{stdio:"inherit"}),$}catch(W){return X.warn(`Management dashboard: failed to build artifact — ${W?.message??W}. Skipping dashboard deploy.`),null}}
6
- export{c as lf,w as mf,t as nf,r as of,s as pf,n as qf,i as rf,$J as sf,zJ as tf,GJ as uf};
@@ -1,3 +0,0 @@
1
- import{Hd as Wg}from"./chunk-b6by94pk.js";import{Sd as Zg,Xd as $g}from"./chunk-fq7ktvgy.js";import{_d as xg}from"./chunk-r61qmhv1.js";import{ig as Yg}from"./chunk-4n0j3n3b.js";import{jg as Og}from"./chunk-f11xf3n6.js";import{pg as c,qg as s}from"./chunk-54bqchag.js";import{dh as Q,eh as gg}from"./chunk-xyt490vp.js";import{$h as Xg,no as Bg}from"./chunk-5bhx3bsa.js";class r{client;region;constructor(g="us-east-1",T){this.region=g,this.client=new Q(c(T))}async query(g){let T=new URLSearchParams(gg({Version:"2010-08-01",...g})).toString();return this.client.request({service:"monitoring",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:T})}async getMetricStatistics(g){let T={Action:"GetMetricStatistics",Namespace:g.Namespace,MetricName:g.MetricName,StartTime:g.StartTime.toISOString(),EndTime:g.EndTime.toISOString(),Period:g.Period};(g.Statistics??[]).forEach((P,Y)=>{T[`Statistics.member.${Y+1}`]=P}),(g.ExtendedStatistics??[]).forEach((P,Y)=>{T[`ExtendedStatistics.member.${Y+1}`]=P}),(g.Dimensions??[]).forEach((P,Y)=>{T[`Dimensions.member.${Y+1}.Name`]=P.Name,T[`Dimensions.member.${Y+1}.Value`]=P.Value});let N=await this.query(T),L=(N.GetMetricStatisticsResult||N)?.Datapoints?.member??[];if(!Array.isArray(L))L=L?[L]:[];return L.map((P)=>{let Y={},X=P.ExtendedStatistics?.entry;if(X){if(!Array.isArray(X))X=[X];for(let Z of X)if(Z?.key!=null)Y[Z.key]=Number(Z.value)}return{Timestamp:P.Timestamp,Sum:P.Sum!=null?Number(P.Sum):void 0,Average:P.Average!=null?Number(P.Average):void 0,Maximum:P.Maximum!=null?Number(P.Maximum):void 0,Minimum:P.Minimum!=null?Number(P.Minimum):void 0,Percentiles:Object.keys(Y).length?Y:void 0,Unit:P.Unit}})}async getMetricSeries(g){let T=/^p\d/.test(g.Stat);return(await this.getMetricStatistics({Namespace:g.Namespace,MetricName:g.MetricName,Dimensions:g.Dimensions,StartTime:g.StartTime,EndTime:g.EndTime,Period:g.Period,Statistics:T?[]:[g.Stat],ExtendedStatistics:T?[g.Stat]:[]})).slice().sort((z,L)=>new Date(z.Timestamp??0).getTime()-new Date(L.Timestamp??0).getTime()).map((z)=>T?z.Percentiles?.[g.Stat]??0:z[g.Stat]??0)}async describeAlarms(g){let T={Action:"DescribeAlarms"};if(g?.AlarmNamePrefix)T.AlarmNamePrefix=g.AlarmNamePrefix;if(g?.MaxRecords)T.MaxRecords=g.MaxRecords;let N=await this.query(T),L=(N.DescribeAlarmsResult||N)?.MetricAlarms?.member??[];if(!Array.isArray(L))L=L?[L]:[];return L.map((P)=>({AlarmName:P.AlarmName,StateValue:P.StateValue,MetricName:P.MetricName,ComparisonOperator:P.ComparisonOperator,Threshold:P.Threshold!=null?Number(P.Threshold):void 0,Namespace:P.Namespace}))}async putMetricAlarm(g){let T={Action:"PutMetricAlarm",AlarmName:g.AlarmName,Namespace:g.Namespace,MetricName:g.MetricName,ComparisonOperator:g.ComparisonOperator,Threshold:g.Threshold,EvaluationPeriods:g.EvaluationPeriods,Period:g.Period,Statistic:g.Statistic};if(g.AlarmDescription)T.AlarmDescription=g.AlarmDescription;(g.Dimensions??[]).forEach((N,z)=>{T[`Dimensions.member.${z+1}.Name`]=N.Name,T[`Dimensions.member.${z+1}.Value`]=N.Value}),(g.AlarmActions??[]).forEach((N,z)=>{T[`AlarmActions.member.${z+1}`]=N}),await this.query(T)}async deleteAlarms(g){if(!g.length)return;let T={Action:"DeleteAlarms"};g.forEach((N,z)=>{T[`AlarmNames.member.${z+1}`]=N}),await this.query(T)}}class a{client;region;constructor(g="us-east-1",T){this.region=g,this.client=new Q(void 0,{profile:T})}async createLogGroup(g,T){await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.CreateLogGroup","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({logGroupName:g,...T?{tags:T}:{}})})}async putRetentionPolicy(g,T){if(![1,3,5,7,14,30,60,90,120,150,180,365,400,545,731,1096,1827,2192,2557,2922,3288,3653].includes(T))throw Error("Unsupported CloudWatch Logs retention period");await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.PutRetentionPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({logGroupName:g,retentionInDays:T})})}async describeLogStreams(g){let T={logGroupName:g.logGroupName};if(g.logStreamNamePrefix)T.logStreamNamePrefix=g.logStreamNamePrefix;if(g.orderBy)T.orderBy=g.orderBy;if(g.descending!==void 0)T.descending=g.descending;if(g.limit)T.limit=g.limit;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.DescribeLogStreams","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(T)})}async getLogEvents(g){let T={logGroupName:g.logGroupName,logStreamName:g.logStreamName};if(g.startTime)T.startTime=g.startTime;if(g.endTime)T.endTime=g.endTime;if(g.limit)T.limit=g.limit;if(g.startFromHead!==void 0)T.startFromHead=g.startFromHead;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.GetLogEvents","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(T)})}async describeLogGroups(g){let T={};if(g?.logGroupNamePrefix)T.logGroupNamePrefix=g.logGroupNamePrefix;if(g?.limit)T.limit=g.limit;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.DescribeLogGroups","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(T)})}async deleteLogGroup(g){await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.DeleteLogGroup","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify({logGroupName:g})})}async filterLogEvents(g){let T={logGroupName:g.logGroupName};if(g.logStreamNames)T.logStreamNames=g.logStreamNames;if(g.startTime)T.startTime=g.startTime;if(g.endTime)T.endTime=g.endTime;if(g.filterPattern)T.filterPattern=g.filterPattern;if(g.limit)T.limit=g.limit;return await this.client.request({service:"logs",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"Logs_20140328.FilterLogEvents","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(T)})}}import{createHash as jg}from"node:crypto";import{existsSync as Tg,mkdirSync as Vg,readdirSync as Hg,readFileSync as Ug,rmSync as Kg,writeFileSync as Eg}from"node:fs";import{homedir as Qg}from"node:os";import{join as m}from"node:path";var Ng=1,Lg=3600000,Rg=24*Lg,Fg=Lg,qg=30*Rg;function i(){let g=process.env.XDG_CACHE_HOME;return m(g&&g.trim()?g:m(Qg(),".cache"),"ts-cloud","cost-explorer")}function f(g){return m(i(),g??"__default__")}function Gg(g){let T={s:g.start,e:g.end,g:g.granularity,m:[...g.metrics].sort(),gb:[...g.groupBy].map((N)=>`${N.Type}:${N.Key}`).sort(),f:g.filter??null};return jg("sha256").update(JSON.stringify(T)).digest("hex").slice(0,24)}function Ag(g,T){let N=Date.parse(`${T}T00:00:00Z`);if(Number.isNaN(N))return!1;let z=new Date,L=Date.UTC(z.getUTCFullYear(),z.getUTCMonth(),1);return N<=L}function Sg(g){return Ag(g.start,g.end)?qg:Fg}function zg(g,T){let N=m(f(g),`${Gg(T)}.json`);if(!Tg(N))return null;let z;try{z=JSON.parse(Ug(N,"utf-8"))}catch{return null}if(z.schema!==Ng)return null;let L=Date.now()-z.savedAt;if(L<0||L>Sg(T))return null;return{response:z.response,ageSeconds:Math.floor(L/1000)}}function Jg(g,T,N){let z=f(g);Vg(z,{recursive:!0});let L={schema:Ng,savedAt:Date.now(),key:T,response:N};Eg(m(z,`${Gg(T)}.json`),JSON.stringify(L))}function wg(g){let T=g===void 0?i():f(g);if(!Tg(T))return{deletedFiles:0,scope:g??"all profiles"};let N=0;function z(L){for(let P of Hg(L,{withFileTypes:!0})){let Y=m(L,P.name);if(P.isDirectory())z(Y);else if(P.isFile()&&P.name.endsWith(".json"))N++}}return z(T),Kg(T,{recursive:!0,force:!0}),{deletedFiles:N,scope:g??"all profiles"}}function vg(g){return g===void 0?i():f(g)}class e{client;profile;useCache;lastCacheAgeSeconds=null;constructor(g,T){this.profile=g,this.useCache=T?.useCache??!0,this.client=new Q(c(g))}async getCostByService(g){return(await this.getCostByDimension({...g,dimension:"SERVICE"})).map((N)=>({service:N.key,amount:N.amount,unit:N.unit}))}async getCostByDimension(g){let{start:T,end:N,dimension:z,granularity:L="MONTHLY",filter:P}=g,Y=["UnblendedCost"],X=[{Type:"DIMENSION",Key:z}],Z={start:T,end:N,granularity:L,metrics:Y,groupBy:X,filter:P};if(this.useCache){let U=zg(this.profile,Z);if(U)return this.lastCacheAgeSeconds=U.ageSeconds,U.response}this.lastCacheAgeSeconds=null;let W=new Map,G;do{let U={TimePeriod:{Start:T,End:N},Granularity:L,Metrics:Y,GroupBy:X};if(P)U.Filter=P;if(G)U.NextPageToken=G;let S=await this.client.request({service:"ce",region:"us-east-1",method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"AWSInsightsIndexService.GetCostAndUsage"},body:JSON.stringify(U)});for(let v of S?.ResultsByTime??[])for(let K of v?.Groups??[]){let C=K.Keys?.[0]??"Unknown",u=Number.parseFloat(K.Metrics?.UnblendedCost?.Amount??"0"),l=K.Metrics?.UnblendedCost?.Unit??"USD",_=W.get(C);W.set(C,{key:C,amount:(_?.amount??0)+u,unit:l})}G=S?.NextPageToken||void 0}while(G);let b=[...W.values()].filter((U)=>U.amount>0).sort((U,S)=>S.amount-U.amount);if(this.useCache)Jg(this.profile,Z,b);return b}async getDailyTotals(g){return((await this.client.request({service:"ce",region:"us-east-1",method:"POST",path:"/",headers:{"content-type":"application/x-amz-json-1.1","x-amz-target":"AWSInsightsIndexService.GetCostAndUsage"},body:JSON.stringify({TimePeriod:{Start:g.start,End:g.end},Granularity:"DAILY",Metrics:["UnblendedCost"]})}))?.ResultsByTime??[]).map((z)=>Number.parseFloat(z.Total?.UnblendedCost?.Amount??"0"))}}class p{client;region;constructor(g="us-east-1"){this.region=g,this.client=new Q}async describeFileSystems(g){let T=[];if(g?.FileSystemId)T.push(`FileSystemId=${encodeURIComponent(g.FileSystemId)}`);if(g?.CreationToken)T.push(`CreationToken=${encodeURIComponent(g.CreationToken)}`);let N=`/2015-02-01/file-systems${T.length>0?`?${T.join("&")}`:""}`;return{FileSystems:((await this.client.request({service:"elasticfilesystem",region:this.region,method:"GET",path:N,headers:{"Content-Type":"application/json"}})).FileSystems||[]).map((L)=>({FileSystemId:L.FileSystemId,Name:L.Name,CreationTime:L.CreationTime,LifeCycleState:L.LifeCycleState,NumberOfMountTargets:L.NumberOfMountTargets,SizeInBytes:L.SizeInBytes?{Value:L.SizeInBytes.Value,Timestamp:L.SizeInBytes.Timestamp}:void 0,PerformanceMode:L.PerformanceMode,Encrypted:L.Encrypted,ThroughputMode:L.ThroughputMode,Tags:L.Tags}))}}}class t{client;region;constructor(g="us-east-1"){this.region=g,this.client=new Q}async call(g,T){return this.client.request({service:"wafv2",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":`AWSWAF_20190729.${g}`},body:JSON.stringify(T)})}async listWebACLs(g="REGIONAL"){return(await this.call("ListWebACLs",{Scope:g,Limit:100}))?.WebACLs??[]}async getWebACLRules(g,T,N="REGIONAL"){return((await this.call("GetWebACL",{Name:g,Id:T,Scope:N}))?.WebACL?.Rules??[]).map((P)=>({Name:P.Name,Priority:P.Priority,Action:P.Action?Object.keys(P.Action)[0]:P.OverrideAction?Object.keys(P.OverrideAction)[0]:"count"}))}}function Pg(g){return String(g).padStart(2,"0")}function y(g){return`${g.getUTCFullYear()}-${Pg(g.getUTCMonth()+1)}-${Pg(g.getUTCDate())}`}function _g(g){let T=Math.max(0,Math.round((Date.now()-g)/1000));if(T<60)return`${T}s ago`;let N=Math.round(T/60);if(N<60)return`${N}m ago`;let z=Math.round(N/60);if(z<48)return`${z}h ago`;return`${Math.round(z/24)}d ago`}async function k(g,T,N,z,L,P){let Y=await g.getMetricStatistics({Namespace:"AWS/Lambda",MetricName:N,Dimensions:[{Name:"FunctionName",Value:T}],StartTime:L,EndTime:P,Period:86400,Statistics:[z]}).catch(()=>[]);if(!Y.length)return 0;if(z==="Sum")return Y.reduce((X,Z)=>X+(Z.Sum??0),0);if(z==="Maximum")return Math.max(...Y.map((X)=>X.Maximum??0));return Y.reduce((X,Z)=>X+(Z.Average??0),0)/Y.length}async function w(g,T,N,z,L,P,Y){let X=await g.getMetricStatistics({Namespace:T,MetricName:N,Dimensions:z,StartTime:P,EndTime:Y,Period:86400,Statistics:[L]}).catch(()=>[]);if(!X.length)return 0;if(L==="Sum")return X.reduce((Z,W)=>Z+(W.Sum??0),0);if(L==="Maximum")return Math.max(...X.map((Z)=>Z.Maximum??0));return X.reduce((Z,W)=>Z+(W.Average??0),0)/X.length}async function n(g,T,N,z,L){let P=await g.getMetricStatistics({Namespace:"AWS/Lambda",MetricName:"Duration",Dimensions:[{Name:"FunctionName",Value:T}],StartTime:z,EndTime:L,Period:86400,ExtendedStatistics:[N]}).catch(()=>[]);return Math.round(P.reduce((Y,X)=>Y+(X.Percentiles?.[N]??0),0))}async function PT(g,T){let N=await $g(g,T),z=N.region,L=new r(z),P=new xg(z),Y=new a(z),X=new Date,Z=new Date(X.getTime()-86400000),W=g.environments?.[T]?.app,G={};G.app={name:N.slug,env:T,region:z,runtime:W?.kind==="php"?`php-${W?.phpVersion??"8.3"} (fpm)`:W?.kind??"node",url:N.endpoint??"",build:N.lastRelease?.sha?.slice(0,7)??"—",deployedAt:N.lastRelease?.timestamp??"—"},G.maintenance={enabled:!1},G.scheduler={enabled:N.scheduler!=="off",expression:N.scheduler==="sub-minute"?"rate(1 minute) · sub-minute":"rate(1 minute)",lastRun:"—"};let b=0,U=0,S=0,v=[],K=[],C=[];for(let J of N.functions){let[O,x,B,V,$,H,E,R,I]=await Promise.all([k(L,J.name,"Invocations","Sum",Z,X),k(L,J.name,"Errors","Sum",Z,X),k(L,J.name,"Throttles","Sum",Z,X),k(L,J.name,"Duration","Average",Z,X),P.getFunction(J.name).catch(()=>null),n(L,J.name,"p50",Z,X),n(L,J.name,"p95",Z,X),n(L,J.name,"p99",Z,X),L.getMetricSeries({Namespace:"AWS/Lambda",MetricName:"Invocations",Dimensions:[{Name:"FunctionName",Value:J.name}],StartTime:new Date(X.getTime()-43200000),EndTime:X,Period:3600,Stat:"Sum"}).catch(()=>[])]);b+=O,U+=x,S=Math.max(S,V);let D=$?.Configuration?.MemorySize??0,F=Object.keys($?.Configuration?.Environment?.Variables??{}),M=[],j=0;try{let{events:d=[]}=await Y.filterLogEvents({logGroupName:`/aws/lambda/${J.name}`,startTime:Z.getTime(),limit:120});for(let A of d){let h=(A.message??"").trim(),o=/Max Memory Used:\s*(\d+)\s*MB/.exec(h);if(o)j=Math.max(j,Number(o[1]));if(h&&!/^(?:START|END|REPORT|INIT_START)/.test(h))C.push({source:J.mode||J.name,timestamp:new Date(A.timestamp??0).toISOString(),when:_g(A.timestamp??0),message:h.slice(0,400),level:/error|exception|fatal|panic|traceback/i.test(h)?"error":/warn|warning|timeout|retr(?:y|ies)|throttl/i.test(h)?"warn":"info"})}M=d.filter((A)=>!/^(?:START|END|REPORT|INIT_START)/.test((A.message??"").trim())).slice(-6).map((A)=>({ts:new Date(A.timestamp??0).toISOString().slice(11,19),msg:(A.message??"").trim().slice(0,120),err:/error|exception|fatal/i.test(A.message??"")}))}catch{}let q=Math.max(1,...I);v.push({key:J.mode,name:J.name,version:J.version,memory:D,timeout:$?.Configuration?.Timeout??0,runtime:$?.Configuration?.Runtime??"provided.al2023",invocations:Math.round(O),errors:Math.round(x),p95:E||Math.round(V),status:"active",provisioned:J.provisioned?`${J.provisioned.allocated}/${J.provisioned.requested}`:void 0}),K.push({key:J.mode,name:J.name,runtime:$?.Configuration?.Runtime??"provided.al2023",arch:$?.Configuration?.Architectures?.[0]??"x86_64",memory:D,timeout:$?.Configuration?.Timeout??0,ephemeral:$?.Configuration?.EphemeralStorage?.Size??512,version:J.version,concurrency:W?.concurrency??"—",invocations:Math.round(O),errors:Math.round(x),throttles:Math.round(B),p50:H||Math.round(V),p95:E||Math.round(V),p99:R||Math.round(V),maxMem:j,spark:I.length?I.map((d)=>Math.round(d/q*100)):[0],env:F.length?F:["(none)"],recent:M.length?M:[{ts:"—",msg:"no recent events",err:!1}]})}G.functions=v,G.functionsDetail=K,G.serverlessLogs=C.sort((J,O)=>String(O.timestamp).localeCompare(String(J.timestamp))).slice(0,600),G.serverlessLogsEmptyReason=C.length?void 0:"No recent function logs were found in CloudWatch for this environment.";let u=b?Number((U/b*100).toFixed(2)):0,l=Math.round(await k(L,N.functions[0]?.name??"","ConcurrentExecutions","Maximum",Z,X));G.metrics={invocations:Math.round(b),errorRatePct:u,p95Ms:Math.round(S),coldStartPct:void 0,concurrency:l,estCostUsd:void 0};try{let J=new Wg(z),O=[],x=[],B=0;try{let{QueueUrl:$}=await J.getQueueUrl(`${N.slug}-${T}-dlq`),{Attributes:H}=await J.getQueueAttributes($);B=Number(H.ApproximateNumberOfMessages??0)}catch{}let V=W?Bg(W,N.slug,T):[];for(let $ of V){let H=$.name.replace(`${N.slug}-${T}-`,""),E=0,R=0;try{let{QueueUrl:D}=await J.getQueueUrl($.name),{Attributes:F}=await J.getQueueAttributes(D);E=Number(F.ApproximateNumberOfMessages??0),R=Number(F.ApproximateNumberOfMessagesNotVisible??0)}catch{}let I=Math.round(await w(L,"AWS/SQS","NumberOfMessagesDeleted",[{Name:"QueueName",Value:$.name}],"Sum",Z,X));O.push({name:H,visible:E,inFlight:R,processed:I,dlq:B}),x.push({name:$.name,short:H,visible:E,inFlight:R,delayed:0,processed:I,oldestSec:0,concurrency:$.concurrency??W?.queueConcurrency??"—",tries:W?.queueTries??3,visTimeout:(W?.queueTimeout??120)*6,dlq:B})}if(O.length)G.queues=O;if(x.length)G.queuesDetail=x;G.dlqItems=[]}catch{}try{let J=new Og(z),{Stacks:O}=await J.describeStacks({stackName:Xg(g,T)}),x={};for(let B of O?.[0]?.Outputs??[])if(B.OutputKey)x[B.OutputKey]=B.OutputValue??"";if(W?.database?.connection==="aurora-serverless"){let B=`${N.slug}-${T}-db`,V=[{Name:"DBClusterIdentifier",Value:B}],[$,H]=await Promise.all([w(L,"AWS/RDS","ServerlessDatabaseCapacity",V,"Average",Z,X),w(L,"AWS/RDS","DatabaseConnections",V,"Maximum",Z,X)]);if(G.aurora={id:B,engine:"aurora-mysql",minAcu:W?.database?.minCapacity??0.5,maxAcu:W?.database?.maxCapacity??4,currentAcu:$?Number($.toFixed(1)):W?.database?.minCapacity??0.5,database:"app",connections:Math.round(H),status:x.DbEndpoint?"available":"creating"},W?.rdsProxy)G.proxy={name:`${N.slug}-${T}-proxy`,endpoint:x.DbProxyEndpoint??"—",pooledConns:Math.round(H),status:"available"}}if(W?.cache?.driver==="elasticache"){let B=`${N.slug}-${T}-cache`,V=[{Name:"CacheClusterId",Value:`${B}-001`}],[$,H]=await Promise.all([w(L,"AWS/ElastiCache","CacheHits",V,"Sum",Z,X),w(L,"AWS/ElastiCache","CacheMisses",V,"Sum",Z,X)]),E=$+H>0?Number(($/($+H)*100).toFixed(1)):0;G.redis={id:B,node:"cache.t4g.micro",engine:"redis",hitRate:E,status:x.CacheEndpoint?"available":"creating"}}if(W?.efs){let B=0;try{if(x.EfsFileSystemId){let V=new p(z),{FileSystems:$}=await V.describeFileSystems({FileSystemId:x.EfsFileSystemId});B=Number((($?.[0]?.SizeInBytes?.Value??0)/1048576).toFixed(1))}}catch{}G.efs={id:x.EfsFileSystemId??"efs",mount:"/mnt/local",sizeMb:B,status:"available"}}G.assetsInfo=x.AssetsCdnDomain?{bucket:x.AssetsBucketName??`${N.slug}-${T}-assets`,cdn:x.AssetsCdnDomain,customDomain:W?.assetDomain??"—",assetUrl:N.assetUrl??"—",files:0,sizeMb:0,cacheHitPct:0,build:G.app.build}:void 0}catch{}if(G.assetsInfo)try{let O=await new s(z).list({bucket:G.assetsInfo.bucket,maxKeys:1000});G.assetsInfo.files=O.length,G.assetsInfo.sizeMb=Number((O.reduce((x,B)=>x+(B.Size??0),0)/1048576).toFixed(1)),G.assetsRecent=O.slice(0,8).map((x)=>({path:`/${x.Key}`,size:`${Math.max(1,Math.round((x.Size??0)/1024))} KB`,type:x.Key.split(".").pop()??""}))}catch{}try{if(W?.secrets){let J=Array.isArray(W.secrets)?W.secrets.map((O)=>({key:O.split("/").pop().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),source:O})):Object.entries(W.secrets).map(([O,x])=>({key:O,source:String(x)}));G.secretsList=J.map((O)=>({...O,updated:"—"}))}}catch{}try{let J=new s(z),O=`${N.slug}-${T}-deployments`,x=await J.getObjectJson(O,`deployments/${N.slug}/${T}/history.json`).catch(()=>null);if(x?.records?.length)G.deploymentsDetail=x.records.slice(-12).reverse().map((B)=>({sha:(B.sha??"").slice(0,7),status:B.status??"success",when:B.timestamp??"—",took:B.took??"—",by:B.by??"—",version:B.version??"—",hooks:B.hooks??[]}))}catch{}G.metricsTotals={invocations:G.metrics.invocations,errors:Math.round(U),errorRatePct:u,p95Ms:G.metrics.p95Ms,throttles:K.reduce((J,O)=>J+O.throttles,0),coldStartPct:void 0,estCostUsd:void 0,concurrency:l},G.metricsPerFn=K.map((J)=>({key:J.key,invocations:J.invocations,errors:J.errors,throttles:J.throttles,avgMs:J.p50,maxMs:J.p99,costUsd:void 0}));try{G.invSpark=await L.getMetricSeries({Namespace:"AWS/Lambda",MetricName:"Invocations",Dimensions:[{Name:"FunctionName",Value:N.functions.find((J)=>J.mode==="http")?.name??""}],StartTime:new Date(X.getTime()-86400000),EndTime:X,Period:3600,Stat:"Sum"})}catch{}try{let J=new e,O=X,x=new Date(Date.UTC(O.getUTCFullYear(),O.getUTCMonth(),1)),B=new Date(Date.UTC(O.getUTCFullYear(),O.getUTCMonth()-1,1)),[V,$]=await Promise.all([J.getCostByService({start:y(x),end:y(O),granularity:"MONTHLY"}).catch(()=>[]),J.getCostByService({start:y(B),end:y(x),granularity:"MONTHLY"}).catch(()=>[])]);if(V.length){let H=V.reduce((j,q)=>j+q.amount,0),E=$.reduce((j,q)=>j+q.amount,0),R=O.getUTCDate(),I=new Date(Date.UTC(O.getUTCFullYear(),O.getUTCMonth()+1,0)).getUTCDate();G.costSummary={monthToDateUsd:Number(H.toFixed(2)),projectedUsd:Number((H/R*I).toFixed(2)),lastMonthUsd:Number(E.toFixed(2)),dailyAvgUsd:Number((H/R).toFixed(2))},G.costServices=V.filter((j)=>j.amount>0).sort((j,q)=>q.amount-j.amount).slice(0,12).map((j)=>({name:j.service,usd:Number(j.amount.toFixed(2)),note:""})),G.metrics.estCostUsd=Number((H/R).toFixed(2)),G.metricsTotals.estCostUsd=G.metrics.estCostUsd,G.costTrend=await J.getDailyTotals({start:y(x),end:y(O)}).catch(()=>[]);let D=V.find((j)=>/lambda/i.test(j.service))?.amount??0,F=(j)=>j.invocations*(j.p50/1000)*(j.memory/1024),M=K.reduce((j,q)=>j+F(q),0)||1;G.costPerFn=K.map((j)=>({key:j.key,requests:j.invocations,gbSec:Math.round(F(j)),usd:Number((D*(F(j)/M)).toFixed(2))}))}}catch{}if(W?.firewall)try{let J=await L.getMetricStatistics({Namespace:"AWS/WAFV2",MetricName:"BlockedRequests",StartTime:Z,EndTime:X,Period:86400,Statistics:["Sum"]}).catch(()=>[]),O=await L.getMetricStatistics({Namespace:"AWS/WAFV2",MetricName:"AllowedRequests",StartTime:Z,EndTime:X,Period:86400,Statistics:["Sum"]}).catch(()=>[]);G.waf={enabled:!0,scope:"REGIONAL",acl:`${N.slug}-${T}-waf`,allowed24h:Math.round(O.reduce((x,B)=>x+(B.Sum??0),0)),blocked24h:Math.round(J.reduce((x,B)=>x+(B.Sum??0),0))};try{let x=new t(z),B=await x.listWebACLs("REGIONAL"),V=B.find(($)=>$.Name?.includes(`${N.slug}-${T}`))??B[0];if(V?.Name&&V.Id){G.waf.acl=V.Name;let $=await x.getWebACLRules(V.Name,V.Id,"REGIONAL");if($.length)G.wafRules=$.map((H)=>({name:H.Name??"—",detail:`priority ${H.Priority??0}`,action:H.Action??"count",blocked24h:0}))}}catch{}}catch{}let _=[];if(G.aurora)_.push({name:"Aurora Serverless v2",detail:`${G.aurora.id} · ${G.aurora.minAcu}-${G.aurora.maxAcu} ACU`,status:G.aurora.status});if(G.proxy)_.push({name:"RDS Proxy",detail:G.proxy.name,status:G.proxy.status});if(G.redis)_.push({name:`ElastiCache (${G.redis.engine})`,detail:`${G.redis.node} · ${G.redis.hitRate}% hit rate`,status:G.redis.status});if(G.efs)_.push({name:"EFS",detail:`${G.efs.mount} · ${G.efs.sizeMb} MB`,status:G.efs.status});if(_.length)G.dataServices=_;if(N.scheduler!=="off"&&W?.kind==="php")try{let J=await Zg(g,T,"schedule:list"),O=[];for(let x of(J||"").split(`
2
- `)){let B=/^\s*([\d*/,\-\s]+?)\s{2,}(.+?)(?:\s{2,}Next Due.*)?$/.exec(x);if(B&&/[*\d]/.test(B[1])&&B[1].trim().split(/\s+/).length===5)O.push({command:B[2].trim().replace(/^php artisan /,""),cron:B[1].trim(),desc:"",lastRun:"—",lastStatus:"ok"})}if(O.length)G.schedulerTasks=O}catch{}return G.topology=Yg(G,{project:g.project.name,environment:T}),G}
3
- export{a as Bd,r as Cd,wg as Dd,vg as Ed,e as Fd,PT as Gd};
@@ -1 +0,0 @@
1
- import{Xa as a}from"./chunk-satwnr42.js";import"./chunk-c8sypnbe.js";export{a as encodeDashboardPayload};