@stacksjs/ts-cloud 0.9.2 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/dist/aws/index.js +1 -269
  2. package/dist/bin/chunk-00kg80qg.js +1 -0
  3. package/dist/bin/chunk-09nwf2gy.js +34 -0
  4. package/dist/bin/chunk-1k5kszjp.js +111 -0
  5. package/dist/bin/chunk-21e0mavm.js +1 -0
  6. package/dist/bin/chunk-271gk1n2.js +6 -0
  7. package/dist/bin/chunk-2empps47.js +2 -0
  8. package/dist/bin/chunk-38pq971s.js +2 -0
  9. package/dist/bin/chunk-3gykfyq4.js +37 -0
  10. package/dist/bin/chunk-3vqfexc4.js +70 -0
  11. package/dist/bin/chunk-4vrqm9h0.js +2 -0
  12. package/dist/bin/chunk-598yf4bs.js +1 -0
  13. package/dist/bin/chunk-5ectjq0b.js +1 -0
  14. package/dist/bin/chunk-5erkxpt7.js +512 -0
  15. package/dist/bin/chunk-5mrtzemj.js +1 -0
  16. package/dist/bin/chunk-5n9fmabb.js +1 -0
  17. package/dist/bin/chunk-9knpg30y.js +1 -0
  18. package/dist/bin/chunk-9pvsff8g.js +1 -0
  19. package/dist/bin/chunk-ax9mr6wm.js +44 -0
  20. package/dist/bin/chunk-axhnkn5g.js +2 -0
  21. package/dist/bin/chunk-c1vcdgvr.js +1 -0
  22. package/dist/bin/chunk-ctd2vg9w.js +2 -0
  23. package/dist/bin/chunk-dbgffky8.js +1 -0
  24. package/dist/bin/chunk-ddk4rt4j.js +6 -0
  25. package/dist/bin/chunk-dwr30vbv.js +1 -0
  26. package/dist/bin/chunk-e0rkrq70.js +1 -0
  27. package/dist/bin/chunk-e3xrwh9z.js +1 -0
  28. package/dist/bin/chunk-etrb03mt.js +1507 -0
  29. package/dist/bin/chunk-fhc6ntvd.js +2 -0
  30. package/dist/bin/chunk-fpm59y25.js +6 -0
  31. package/dist/bin/chunk-fvbxvq6b.js +1 -0
  32. package/dist/bin/chunk-fy8j3y8p.js +92 -0
  33. package/dist/bin/chunk-fz21b57w.js +1 -0
  34. package/dist/bin/chunk-gavvf0pg.js +141 -0
  35. package/dist/bin/chunk-ggn7ax8p.js +4 -0
  36. package/dist/bin/chunk-gpe2prkm.js +1 -0
  37. package/dist/bin/chunk-h5pa5men.js +2 -0
  38. package/dist/bin/chunk-hm08xdxf.js +2 -0
  39. package/dist/bin/chunk-hzgz13nf.js +1 -0
  40. package/dist/bin/chunk-j703btc5.js +50 -0
  41. package/dist/bin/chunk-k9t9wvms.js +1 -0
  42. package/dist/bin/chunk-m669wtgr.js +1 -0
  43. package/dist/bin/chunk-m7dgskt1.js +1 -0
  44. package/dist/bin/chunk-mh0kdzqp.js +2 -0
  45. package/dist/bin/chunk-mr0atd2s.js +2 -0
  46. package/dist/bin/chunk-mz0wbbsj.js +3 -0
  47. package/dist/bin/chunk-ngcyftm2.js +1 -0
  48. package/dist/bin/chunk-p66ptpmr.js +2 -0
  49. package/dist/bin/chunk-qk9qgepa.js +1 -0
  50. package/dist/bin/chunk-rxcvf10f.js +7364 -0
  51. package/dist/bin/chunk-rytk89az.js +60 -0
  52. package/dist/bin/chunk-tga3hhwk.js +6 -0
  53. package/dist/bin/chunk-tx0tqq2k.js +8 -0
  54. package/dist/bin/chunk-vek8a0w6.js +1 -0
  55. package/dist/bin/chunk-vm3q5gf2.js +3 -0
  56. package/dist/bin/chunk-y7s5r8y6.js +3 -0
  57. package/dist/bin/chunk-yv9sth30.js +1 -0
  58. package/dist/bin/chunk-zmegvjp8.js +581 -0
  59. package/dist/bin/cli.js +417 -10597
  60. package/dist/bin/dashboard-server.js +1 -6998
  61. package/dist/chunk-0ccta6z6.js +6 -0
  62. package/dist/chunk-0k1cs6pp.js +1 -0
  63. package/dist/chunk-1egjn203.js +704 -0
  64. package/dist/chunk-2wx29qga.js +5 -0
  65. package/dist/chunk-5m5rqmv7.js +1 -0
  66. package/dist/chunk-8ea5022g.js +114 -0
  67. package/dist/chunk-8xqn3c0w.js +2 -0
  68. package/dist/chunk-b4esxhmw.js +2 -0
  69. package/dist/chunk-b8e5wzwn.js +44 -0
  70. package/dist/chunk-bggt4n6e.js +2 -0
  71. package/dist/chunk-cwkg37rs.js +37 -0
  72. package/dist/chunk-dskvqt67.js +7355 -0
  73. package/dist/chunk-gahsdmxf.js +1617 -0
  74. package/dist/chunk-gnv3r2jg.js +1 -0
  75. package/dist/chunk-hg3c48cp.js +34 -0
  76. package/dist/chunk-m5azeva3.js +2 -0
  77. package/dist/chunk-r3qf56b3.js +92 -0
  78. package/dist/chunk-sdqa9ghv.js +141 -0
  79. package/dist/chunk-svrvvcm7.js +1 -0
  80. package/dist/chunk-v0p3hpc3.js +60 -0
  81. package/dist/chunk-wdzjbecg.js +50 -0
  82. package/dist/chunk-ww8k3g7j.js +1 -0
  83. package/dist/chunk-xmqfc62w.js +1 -0
  84. package/dist/chunk-xrebj679.js +435 -0
  85. package/dist/chunk-xt3s24vr.js +2 -0
  86. package/dist/chunk-y21zk0pn.js +4 -0
  87. package/dist/deploy/attach-credentials.d.ts +57 -0
  88. package/dist/deploy/index.js +1 -168
  89. package/dist/deploy/site-ports.d.ts +151 -0
  90. package/dist/deploy/site-target.d.ts +24 -1
  91. package/dist/dns/index.js +1 -41
  92. package/dist/drivers/index.js +1 -154
  93. package/dist/index.js +100 -6129
  94. package/dist/protection/index.js +1 -89
  95. package/dist/push/index.js +1 -509
  96. package/dist/spend/index.js +1 -173
  97. package/dist/ui/404.html +16 -548
  98. package/dist/ui/_stx/chunk.5ddb5087.js +90 -0
  99. package/dist/ui/_stx/chunk.9fd39d5b.js +86 -0
  100. package/dist/ui/_stx/chunk.d5301f79.js +119 -0
  101. package/dist/ui/_stx/crosswind.222ed683.css +1 -0
  102. package/dist/ui/_stx/crosswind.616c25f3.css +1 -0
  103. package/dist/ui/_stx/crosswind.80baa894.css +320 -0
  104. package/dist/ui/_stx/crosswind.906ee17c.css +1 -0
  105. package/dist/ui/_stx/crosswind.996ed49e.css +1 -0
  106. package/dist/ui/_stx/crosswind.b7a99a5c.css +1 -0
  107. package/dist/ui/_stx/router.fa5bc4dc.js +4 -0
  108. package/dist/ui/_stx/runtime.c696d17a.js +1 -0
  109. package/dist/ui/_stx/style.448ab192.css +1 -0
  110. package/dist/ui/accept-invitation.html +2 -1133
  111. package/dist/ui/access-denied.html +7 -1130
  112. package/dist/ui/account/automation.html +12 -1134
  113. package/dist/ui/account/security.html +13 -1136
  114. package/dist/ui/applications/compose.html +12 -1134
  115. package/dist/ui/applications/new.html +13 -1137
  116. package/dist/ui/data/backups.html +91 -1136
  117. package/dist/ui/data/services.html +89 -1136
  118. package/dist/ui/data/volumes.html +61 -1136
  119. package/dist/ui/index.html +60 -1136
  120. package/dist/ui/infrastructure/topology.html +128 -1135
  121. package/dist/ui/integrations.html +13 -1138
  122. package/dist/ui/operations/alerts.html +59 -1136
  123. package/dist/ui/operations/configuration.html +13 -1135
  124. package/dist/ui/operations/jobs.html +87 -1136
  125. package/dist/ui/operations/maintenance.html +12 -1134
  126. package/dist/ui/operations/observability.html +93 -1136
  127. package/dist/ui/operations/previews.html +12 -1134
  128. package/dist/ui/operations/queue.html +12 -1134
  129. package/dist/ui/operations/regions.html +12 -1134
  130. package/dist/ui/operations/releases.html +12 -1134
  131. package/dist/ui/operations/spend.html +65 -1136
  132. package/dist/ui/operations/workloads.html +115 -1136
  133. package/dist/ui/robots.txt +2 -0
  134. package/dist/ui/security.html +24 -1136
  135. package/dist/ui/server/actions.html +67 -1138
  136. package/dist/ui/server/activity.html +7 -1130
  137. package/dist/ui/server/capacity.html +12 -1134
  138. package/dist/ui/server/database.html +166 -1135
  139. package/dist/ui/server/deployments.html +60 -1136
  140. package/dist/ui/server/diagnostics.html +7 -1130
  141. package/dist/ui/server/firewall.html +286 -1212
  142. package/dist/ui/server/fleet.html +45 -1136
  143. package/dist/ui/server/logs.html +34 -1135
  144. package/dist/ui/server/metrics.html +124 -1140
  145. package/dist/ui/server/security.html +7 -1130
  146. package/dist/ui/server/services.html +46 -1133
  147. package/dist/ui/server/sites.html +287 -1137
  148. package/dist/ui/server/ssh-keys.html +62 -1135
  149. package/dist/ui/server/team.html +155 -1136
  150. package/dist/ui/server/terminal.html +97 -1183
  151. package/dist/ui/serverless/alarms.html +62 -1135
  152. package/dist/ui/serverless/assets.html +47 -1132
  153. package/dist/ui/serverless/cost.html +7 -1130
  154. package/dist/ui/serverless/data.html +46 -1135
  155. package/dist/ui/serverless/deployments.html +47 -1132
  156. package/dist/ui/serverless/firewall.html +7 -1130
  157. package/dist/ui/serverless/functions.html +50 -1136
  158. package/dist/ui/serverless/logs.html +34 -1135
  159. package/dist/ui/serverless/metrics.html +7 -1130
  160. package/dist/ui/serverless/queues.html +58 -1135
  161. package/dist/ui/serverless/secrets.html +62 -1136
  162. package/dist/ui/serverless/traces.html +12 -1134
  163. package/dist/ui/serverless.html +64 -1137
  164. package/dist/ui-src/pages/server/firewall.stx +14 -14
  165. package/package.json +3 -3
  166. package/dist/chunk-01d86gt1.js +0 -1324
  167. package/dist/chunk-050r7ycy.js +0 -46516
  168. package/dist/chunk-29rse4p1.js +0 -12203
  169. package/dist/chunk-32e7ya18.js +0 -642
  170. package/dist/chunk-4cjrg98a.js +0 -597
  171. package/dist/chunk-50jpda9q.js +0 -371
  172. package/dist/chunk-6a1t7fnq.js +0 -12121
  173. package/dist/chunk-728jvrr0.js +0 -1701
  174. package/dist/chunk-7m60qnc8.js +0 -1762
  175. package/dist/chunk-aa2dkn7b.js +0 -205
  176. package/dist/chunk-d48vtdj4.js +0 -433
  177. package/dist/chunk-f55nkpvb.js +0 -8
  178. package/dist/chunk-fgk8cqew.js +0 -152
  179. package/dist/chunk-he9a874b.js +0 -769
  180. package/dist/chunk-hg7rhrgd.js +0 -7274
  181. package/dist/chunk-k2yyatfw.js +0 -10
  182. package/dist/chunk-k4px0bnv.js +0 -23
  183. package/dist/chunk-nsgqsmrh.js +0 -1779
  184. package/dist/chunk-qr803fye.js +0 -2122
  185. package/dist/chunk-rds0sy87.js +0 -1771
  186. package/dist/chunk-rxgchb08.js +0 -42033
  187. package/dist/chunk-ttz2ra5j.js +0 -12
  188. package/dist/chunk-v0bahtg2.js +0 -4
  189. package/dist/chunk-va2yd85b.js +0 -200
  190. package/dist/chunk-x9s0cqfx.js +0 -13
  191. package/dist/chunk-zqtpg06c.js +0 -1752
@@ -0,0 +1,2 @@
1
+ import{Og as T,Pg as J}from"./chunk-fpm59y25.js";class U{client;region;constructor(k="us-east-1"){this.region=k,this.client=new T}async describeDBInstances(k){let w={Action:"DescribeDBInstances",Version:"2014-10-31"};if(k?.DBInstanceIdentifier)w.DBInstanceIdentifier=k.DBInstanceIdentifier;if(k?.MaxRecords)w.MaxRecords=k.MaxRecords;if(k?.Marker)w.Marker=k.Marker;if(k?.Filters)k.Filters.forEach((K,L)=>{w[`Filters.Filter.${L+1}.Name`]=K.Name,K.Values.forEach((O,R)=>{w[`Filters.Filter.${L+1}.Values.Value.${R+1}`]=O})});let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E}),H=z.DescribeDBInstancesResult||z,G=H.DBInstances?.DBInstance||[];if(!Array.isArray(G))G=G?[G]:[];return{DBInstances:G,Marker:H.Marker}}async describeDBInstance(k){return(await this.describeDBInstances({DBInstanceIdentifier:k})).DBInstances?.[0]}async describeDBClusters(k){let w={Action:"DescribeDBClusters",Version:"2014-10-31"};if(k?.DBClusterIdentifier)w.DBClusterIdentifier=k.DBClusterIdentifier;if(k?.MaxRecords)w.MaxRecords=k.MaxRecords;if(k?.Marker)w.Marker=k.Marker;if(k?.Filters)k.Filters.forEach((K,L)=>{w[`Filters.Filter.${L+1}.Name`]=K.Name,K.Values.forEach((O,R)=>{w[`Filters.Filter.${L+1}.Values.Value.${R+1}`]=O})});let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E}),H=z.DescribeDBClustersResult||z,G=H.DBClusters?.DBCluster||[];if(!Array.isArray(G))G=G?[G]:[];return{DBClusters:G,Marker:H.Marker}}async describeDBSnapshots(k){let w={Action:"DescribeDBSnapshots",Version:"2014-10-31"};if(k?.DBInstanceIdentifier)w.DBInstanceIdentifier=k.DBInstanceIdentifier;if(k?.DBSnapshotIdentifier)w.DBSnapshotIdentifier=k.DBSnapshotIdentifier;if(k?.SnapshotType)w.SnapshotType=k.SnapshotType;if(k?.MaxRecords)w.MaxRecords=k.MaxRecords;if(k?.Marker)w.Marker=k.Marker;let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E}),H=z.DescribeDBSnapshotsResult||z,G=H.DBSnapshots?.DBSnapshot||[];if(!Array.isArray(G))G=G?[G]:[];return{DBSnapshots:G,Marker:H.Marker}}async describeDBSubnetGroups(k){let w={Action:"DescribeDBSubnetGroups",Version:"2014-10-31"};if(k?.DBSubnetGroupName)w.DBSubnetGroupName=k.DBSubnetGroupName;if(k?.MaxRecords)w.MaxRecords=k.MaxRecords;if(k?.Marker)w.Marker=k.Marker;let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E}),H=z.DescribeDBSubnetGroupsResult||z,G=H.DBSubnetGroups?.DBSubnetGroup||[];if(!Array.isArray(G))G=G?[G]:[];return{DBSubnetGroups:G,Marker:H.Marker}}async createDBInstance(k){let w={Action:"CreateDBInstance",Version:"2014-10-31",DBInstanceIdentifier:k.DBInstanceIdentifier,DBInstanceClass:k.DBInstanceClass,Engine:k.Engine};if(k.DBClusterIdentifier)w.DBClusterIdentifier=k.DBClusterIdentifier;if(k.MasterUsername)w.MasterUsername=k.MasterUsername;if(k.MasterUserPassword)w.MasterUserPassword=k.MasterUserPassword;if(k.DBName)w.DBName=k.DBName;if(k.AllocatedStorage)w.AllocatedStorage=k.AllocatedStorage;if(k.DBSubnetGroupName)w.DBSubnetGroupName=k.DBSubnetGroupName;if(k.AvailabilityZone)w.AvailabilityZone=k.AvailabilityZone;if(k.PreferredMaintenanceWindow)w.PreferredMaintenanceWindow=k.PreferredMaintenanceWindow;if(k.PreferredBackupWindow)w.PreferredBackupWindow=k.PreferredBackupWindow;if(k.BackupRetentionPeriod!==void 0)w.BackupRetentionPeriod=k.BackupRetentionPeriod;if(k.MultiAZ!==void 0)w.MultiAZ=k.MultiAZ;if(k.EngineVersion)w.EngineVersion=k.EngineVersion;if(k.AutoMinorVersionUpgrade!==void 0)w.AutoMinorVersionUpgrade=k.AutoMinorVersionUpgrade;if(k.LicenseModel)w.LicenseModel=k.LicenseModel;if(k.PubliclyAccessible!==void 0)w.PubliclyAccessible=k.PubliclyAccessible;if(k.StorageType)w.StorageType=k.StorageType;if(k.StorageEncrypted!==void 0)w.StorageEncrypted=k.StorageEncrypted;if(k.KmsKeyId)w.KmsKeyId=k.KmsKeyId;if(k.DeletionProtection!==void 0)w.DeletionProtection=k.DeletionProtection;if(k.VpcSecurityGroupIds)k.VpcSecurityGroupIds.forEach((G,K)=>{w[`VpcSecurityGroupIds.VpcSecurityGroupId.${K+1}`]=G});if(k.Tags)k.Tags.forEach((G,K)=>{w[`Tags.Tag.${K+1}.Key`]=G.Key,w[`Tags.Tag.${K+1}.Value`]=G.Value});let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBInstance:(z.CreateDBInstanceResult||z).DBInstance}}async createDBCluster(k){let w={Action:"CreateDBCluster",Version:"2014-10-31",DBClusterIdentifier:k.DBClusterIdentifier,Engine:k.Engine};if(k.EngineVersion)w.EngineVersion=k.EngineVersion;if(k.MasterUsername)w.MasterUsername=k.MasterUsername;if(k.MasterUserPassword)w.MasterUserPassword=k.MasterUserPassword;if(k.DatabaseName)w.DatabaseName=k.DatabaseName;if(k.DBSubnetGroupName)w.DBSubnetGroupName=k.DBSubnetGroupName;if(k.BackupRetentionPeriod!==void 0)w.BackupRetentionPeriod=k.BackupRetentionPeriod;if(k.StorageEncrypted!==void 0)w.StorageEncrypted=k.StorageEncrypted;if(k.KmsKeyId)w.KmsKeyId=k.KmsKeyId;if(k.DeletionProtection!==void 0)w.DeletionProtection=k.DeletionProtection;if(k.ServerlessV2ScalingConfiguration)w["ServerlessV2ScalingConfiguration.MinCapacity"]=k.ServerlessV2ScalingConfiguration.MinCapacity,w["ServerlessV2ScalingConfiguration.MaxCapacity"]=k.ServerlessV2ScalingConfiguration.MaxCapacity;k.VpcSecurityGroupIds?.forEach((H,G)=>{w[`VpcSecurityGroupIds.VpcSecurityGroupId.${G+1}`]=H});let E=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(J(w)).toString()});return{DBCluster:(E.CreateDBClusterResult||E).DBCluster}}async deleteDBInstance(k){let w={Action:"DeleteDBInstance",Version:"2014-10-31",DBInstanceIdentifier:k.DBInstanceIdentifier};if(k.SkipFinalSnapshot!==void 0)w.SkipFinalSnapshot=k.SkipFinalSnapshot;if(k.FinalDBSnapshotIdentifier)w.FinalDBSnapshotIdentifier=k.FinalDBSnapshotIdentifier;if(k.DeleteAutomatedBackups!==void 0)w.DeleteAutomatedBackups=k.DeleteAutomatedBackups;let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBInstance:(z.DeleteDBInstanceResult||z).DBInstance}}async modifyDBInstance(k){let w={Action:"ModifyDBInstance",Version:"2014-10-31",DBInstanceIdentifier:k.DBInstanceIdentifier};if(k.DBInstanceClass)w.DBInstanceClass=k.DBInstanceClass;if(k.AllocatedStorage)w.AllocatedStorage=k.AllocatedStorage;if(k.MasterUserPassword)w.MasterUserPassword=k.MasterUserPassword;if(k.BackupRetentionPeriod!==void 0)w.BackupRetentionPeriod=k.BackupRetentionPeriod;if(k.PreferredBackupWindow)w.PreferredBackupWindow=k.PreferredBackupWindow;if(k.PreferredMaintenanceWindow)w.PreferredMaintenanceWindow=k.PreferredMaintenanceWindow;if(k.MultiAZ!==void 0)w.MultiAZ=k.MultiAZ;if(k.EngineVersion)w.EngineVersion=k.EngineVersion;if(k.AutoMinorVersionUpgrade!==void 0)w.AutoMinorVersionUpgrade=k.AutoMinorVersionUpgrade;if(k.PubliclyAccessible!==void 0)w.PubliclyAccessible=k.PubliclyAccessible;if(k.ApplyImmediately!==void 0)w.ApplyImmediately=k.ApplyImmediately;if(k.StorageType)w.StorageType=k.StorageType;if(k.DeletionProtection!==void 0)w.DeletionProtection=k.DeletionProtection;if(k.VpcSecurityGroupIds)k.VpcSecurityGroupIds.forEach((G,K)=>{w[`VpcSecurityGroupIds.VpcSecurityGroupId.${K+1}`]=G});let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBInstance:(z.ModifyDBInstanceResult||z).DBInstance}}async modifyDBCluster(k){let w={Action:"ModifyDBCluster",Version:"2014-10-31",DBClusterIdentifier:k.DBClusterIdentifier};if(k.ServerlessV2ScalingConfiguration)w["ServerlessV2ScalingConfiguration.MinCapacity"]=k.ServerlessV2ScalingConfiguration.MinCapacity,w["ServerlessV2ScalingConfiguration.MaxCapacity"]=k.ServerlessV2ScalingConfiguration.MaxCapacity;if(k.BackupRetentionPeriod!==void 0)w.BackupRetentionPeriod=k.BackupRetentionPeriod;if(k.EngineVersion)w.EngineVersion=k.EngineVersion;if(k.MasterUserPassword)w.MasterUserPassword=k.MasterUserPassword;if(k.DeletionProtection!==void 0)w.DeletionProtection=k.DeletionProtection;if(k.ApplyImmediately!==void 0)w.ApplyImmediately=k.ApplyImmediately;let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBCluster:(z.ModifyDBClusterResult||z).DBCluster}}async rebootDBCluster(k){let w={Action:"FailoverDBCluster",Version:"2014-10-31",DBClusterIdentifier:k},E=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(J(w)).toString()});return{DBCluster:(E.FailoverDBClusterResult||E).DBCluster}}async createDBClusterSnapshot(k,w){let E={Action:"CreateDBClusterSnapshot",Version:"2014-10-31",DBClusterIdentifier:k,DBClusterSnapshotIdentifier:w};return this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(J(E)).toString()})}async describeDBClusterSnapshots(k={}){let w={Action:"DescribeDBClusterSnapshots",Version:"2014-10-31",...k},E=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(J(w)).toString()}),z=E.DescribeDBClusterSnapshotsResult||E,H=z.DBClusterSnapshots?.DBClusterSnapshot??z.DBClusterSnapshots??[];return{DBClusterSnapshots:Array.isArray(H)?H:[H]}}async deleteDBClusterSnapshot(k){await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(J({Action:"DeleteDBClusterSnapshot",Version:"2014-10-31",DBClusterSnapshotIdentifier:k})).toString()})}async deleteDBCluster(k,w){let E={Action:"DeleteDBCluster",Version:"2014-10-31",DBClusterIdentifier:k,SkipFinalSnapshot:!w};if(w)E.FinalDBSnapshotIdentifier=w;let z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(J(E)).toString()});return{DBCluster:(z.DeleteDBClusterResult||z).DBCluster}}async restoreDBClusterToPointInTime(k){let w={Action:"RestoreDBClusterToPointInTime",Version:"2014-10-31",DBClusterIdentifier:k.DBClusterIdentifier,SourceDBClusterIdentifier:k.SourceDBClusterIdentifier};if(k.RestoreToTime)w.RestoreToTime=k.RestoreToTime.toISOString();if(k.UseLatestRestorableTime)w.UseLatestRestorableTime=!0;if(k.DBSubnetGroupName)w.DBSubnetGroupName=k.DBSubnetGroupName;if(k.VpcSecurityGroupIds)k.VpcSecurityGroupIds.forEach((G,K)=>{w[`VpcSecurityGroupIds.VpcSecurityGroupId.${K+1}`]=G});let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBCluster:(z.RestoreDBClusterToPointInTimeResult||z).DBCluster}}async restoreDBClusterFromSnapshot(k){let w={Action:"RestoreDBClusterFromSnapshot",Version:"2014-10-31",DBClusterIdentifier:k.DBClusterIdentifier,SnapshotIdentifier:k.SnapshotIdentifier,Engine:k.Engine};if(k.EngineVersion)w.EngineVersion=k.EngineVersion;if(k.DBSubnetGroupName)w.DBSubnetGroupName=k.DBSubnetGroupName;if(k.DeletionProtection!==void 0)w.DeletionProtection=k.DeletionProtection;if(k.VpcSecurityGroupIds?.forEach((H,G)=>{w[`VpcSecurityGroupIds.VpcSecurityGroupId.${G+1}`]=H}),k.ServerlessV2ScalingConfiguration)w["ServerlessV2ScalingConfiguration.MinCapacity"]=k.ServerlessV2ScalingConfiguration.MinCapacity,w["ServerlessV2ScalingConfiguration.MaxCapacity"]=k.ServerlessV2ScalingConfiguration.MaxCapacity;let E=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(J(w)).toString()});return{DBCluster:(E.RestoreDBClusterFromSnapshotResult||E).DBCluster}}async startDBInstance(k){let E=new URLSearchParams(J({Action:"StartDBInstance",Version:"2014-10-31",DBInstanceIdentifier:k})).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBInstance:(z.StartDBInstanceResult||z).DBInstance}}async stopDBInstance(k){let w={Action:"StopDBInstance",Version:"2014-10-31",DBInstanceIdentifier:k.DBInstanceIdentifier};if(k.DBSnapshotIdentifier)w.DBSnapshotIdentifier=k.DBSnapshotIdentifier;let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBInstance:(z.StopDBInstanceResult||z).DBInstance}}async rebootDBInstance(k){let w={Action:"RebootDBInstance",Version:"2014-10-31",DBInstanceIdentifier:k.DBInstanceIdentifier};if(k.ForceFailover!==void 0)w.ForceFailover=k.ForceFailover;let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBInstance:(z.RebootDBInstanceResult||z).DBInstance}}async createDBSnapshot(k){let w={Action:"CreateDBSnapshot",Version:"2014-10-31",DBInstanceIdentifier:k.DBInstanceIdentifier,DBSnapshotIdentifier:k.DBSnapshotIdentifier};if(k.Tags)k.Tags.forEach((G,K)=>{w[`Tags.Tag.${K+1}.Key`]=G.Key,w[`Tags.Tag.${K+1}.Value`]=G.Value});let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBSnapshot:(z.CreateDBSnapshotResult||z).DBSnapshot}}async deleteDBSnapshot(k){let E=new URLSearchParams(J({Action:"DeleteDBSnapshot",Version:"2014-10-31",DBSnapshotIdentifier:k})).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBSnapshot:(z.DeleteDBSnapshotResult||z).DBSnapshot}}async restoreDBInstanceFromDBSnapshot(k){let w={Action:"RestoreDBInstanceFromDBSnapshot",Version:"2014-10-31",DBInstanceIdentifier:k.DBInstanceIdentifier,DBSnapshotIdentifier:k.DBSnapshotIdentifier};if(k.DBInstanceClass)w.DBInstanceClass=k.DBInstanceClass;if(k.Port)w.Port=k.Port;if(k.AvailabilityZone)w.AvailabilityZone=k.AvailabilityZone;if(k.DBSubnetGroupName)w.DBSubnetGroupName=k.DBSubnetGroupName;if(k.MultiAZ!==void 0)w.MultiAZ=k.MultiAZ;if(k.PubliclyAccessible!==void 0)w.PubliclyAccessible=k.PubliclyAccessible;if(k.AutoMinorVersionUpgrade!==void 0)w.AutoMinorVersionUpgrade=k.AutoMinorVersionUpgrade;if(k.StorageType)w.StorageType=k.StorageType;if(k.DeletionProtection!==void 0)w.DeletionProtection=k.DeletionProtection;if(k.VpcSecurityGroupIds)k.VpcSecurityGroupIds.forEach((G,K)=>{w[`VpcSecurityGroupIds.VpcSecurityGroupId.${K+1}`]=G});if(k.Tags)k.Tags.forEach((G,K)=>{w[`Tags.Tag.${K+1}.Key`]=G.Key,w[`Tags.Tag.${K+1}.Value`]=G.Value});let E=new URLSearchParams(J(w)).toString(),z=await this.client.request({service:"rds",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:E});return{DBInstance:(z.RestoreDBInstanceFromDBSnapshotResult||z).DBInstance}}async waitForDBInstanceAvailable(k,w=60,E=30000){for(let z=0;z<w;z++){let H=await this.describeDBInstance(k);if(H?.DBInstanceStatus==="available")return H;if(["deleted","failed","incompatible-restore","incompatible-parameters"].includes(H?.DBInstanceStatus||""))throw Error(`DB instance ${k} is in terminal state: ${H?.DBInstanceStatus}`);await new Promise((G)=>setTimeout(G,E))}throw Error(`Timeout waiting for DB instance ${k} to become available`)}async waitForDBInstanceDeleted(k,w=60,E=30000){for(let z=0;z<w;z++)try{let H=await this.describeDBInstance(k);if(H?.DBInstanceStatus==="deleting"){await new Promise((G)=>setTimeout(G,E));continue}throw Error(`DB instance ${k} is in state: ${H?.DBInstanceStatus}`)}catch(H){if(H.code==="DBInstanceNotFound"||H.code==="DBInstanceNotFoundFault")return;throw H}throw Error(`Timeout waiting for DB instance ${k} to be deleted`)}}
2
+ export{U as dd};
@@ -0,0 +1,6 @@
1
+ import*as O from"node:crypto";import{existsSync as U,readFileSync as Q}from"node:fs";import{homedir as G}from"node:os";import{join as y}from"node:path";var W={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"},L={nbsp:" ",copy:"©",reg:"®",trade:"™",euro:"€",pound:"£",yen:"¥",cent:"¢",deg:"°",micro:"µ",middot:"·",bull:"•",hellip:"…",prime:"′",Prime:"″",laquo:"«",raquo:"»",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",ndash:"–",mdash:"—",iexcl:"¡",iquest:"¿",sect:"§",para:"¶",dagger:"†",Dagger:"‡",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",times:"×",divide:"÷",plusmn:"±",ne:"≠",le:"≤",ge:"≥",infin:"∞",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",equiv:"≡",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜"};class ${customEntities={};useHtmlEntities;constructor(e=!1){this.useHtmlEntities=e}addEntity(e,t){this.customEntities[e]=t}decodeEntities(e){let t=e.indexOf("&");if(t===-1)return e;let i=e.length,n="",r=0;while(t!==-1&&t<i){if(t>r)n+=e.substring(r,t);let s=e.indexOf(";",t+1);if(s===-1||s-t>32){n+="&",r=t+1,t=e.indexOf("&",r);continue}let u=e.substring(t+1,s);if(u.charCodeAt(0)===35){let a=u.length,c=0,A=!1;if(a>2&&(u.charCodeAt(1)===120||u.charCodeAt(1)===88)){A=!0;for(let g=2;g<a;g++){let h=u.charCodeAt(g);if(h>=48&&h<=57)c=c<<4|h-48;else if(h>=65&&h<=70)c=c<<4|h-55;else if(h>=97&&h<=102)c=c<<4|h-87;else{A=!1;break}}}else if(a>1){A=!0;for(let g=1;g<a;g++){let h=u.charCodeAt(g);if(h>=48&&h<=57)c=c*10+(h-48);else{A=!1;break}}}if(A)n+=String.fromCodePoint(c);else n+=e.substring(t,s+1)}else{let a=this.customEntities[u];if(a===void 0){let c=u.length;if(c>=2&&c<=4){let A=u.charCodeAt(0);if(A===108&&c===2&&u.charCodeAt(1)===116)a="<";else if(A===103&&c===2&&u.charCodeAt(1)===116)a=">";else if(A===97&&c===3&&u.charCodeAt(1)===109&&u.charCodeAt(2)===112)a="&";else if(A===113&&c===4)a=u==="quot"?'"':void 0;else if(A===97&&c===4)a=u==="apos"?"'":void 0}if(a===void 0)a=W[u]??(this.useHtmlEntities?L[u]:void 0)}if(a!==void 0)n+=a;else n+=e.substring(t,s+1)}r=s+1,t=e.indexOf("&",r)}if(r<i)n+=e.substring(r);return n}}var p=[];p[38]="&amp;";p[60]="&lt;";p[62]="&gt;";p[34]="&quot;";p[39]="&apos;";var Y={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,alwaysCreateTextNode:!1,trimValues:!0,parseTagValue:!0,parseAttributeValue:!1,processEntities:!0,htmlEntities:!1,commentPropName:!1,cdataPropName:!1,piPropName:!1,preserveOrder:!1,stopNodes:[],unpairedTags:[],isArray:void 0,tagValueProcessor:void 0,attributeValueProcessor:void 0,updateTag:void 0,numberParseOptions:{hex:!0,leadingZeros:!0,scientific:!0},ignorePiTags:!1,transformAttributeName:void 0,transformTagName:void 0,ignoreDeclaration:!1};function P(e){return e===32||e===9||e===10||e===13}function V(e){return e>=65&&e<=90||e>=97&&e<=122||e===95||e===58||e>=192&&e<=214||e>=216&&e<=246||e>=248&&e<=767||e>=880&&e<=893||e>=895&&e<=8191||e>=8204&&e<=8205||e>=8304&&e<=8591||e>=11264&&e<=12271||e>=12289&&e<=55295||e>=63744&&e<=64975||e>=65008&&e<=65533}function x(e){return V(e)||e===45||e===46||e>=48&&e<=57||e===183||e>=768&&e<=879||e>=8255&&e<=8256}var z=/^0x[\da-fA-F]+$/,Z=/^[+-]?\d+(\.\d+)?[eE][+-]?\d+$/,j=/^[+-]?(\d+\.?\d*|\.\d+)$/;function I(e,t){return e.charCodeAt(t)===91&&e.charCodeAt(t+1)===67&&e.charCodeAt(t+2)===68&&e.charCodeAt(t+3)===65&&e.charCodeAt(t+4)===84&&e.charCodeAt(t+5)===65&&e.charCodeAt(t+6)===91}function D(e,t){let i=e.charCodeAt(t),n=e.charCodeAt(t+1),r=e.charCodeAt(t+2),s=e.charCodeAt(t+3),u=e.charCodeAt(t+4),a=e.charCodeAt(t+5),c=e.charCodeAt(t+6);return(i===68||i===100)&&(n===79||n===111)&&(r===67||r===99)&&(s===84||s===116)&&(u===89||u===121)&&(a===80||a===112)&&(c===69||c===101)}function M(e,t,i){if(t>=i||!V(e.charCodeAt(t)))return t;t++;while(t<i&&x(e.charCodeAt(t)))t++;return t}class B{options;entityDecoder;unpairedSet;exactStopNodes;wildcardStopSuffixes;needsJPath;_ignoreAttributes=!0;_textNodeName="#text";_commentPropName=!1;_cdataPropName=!1;_piPropName=!1;_alwaysCreateTextNode=!1;_trimValues=!0;_processEntities=!0;_parseTagValue=!0;_parseAttributeValue=!1;_removeNSPrefix=!1;_attrPrefix="@_";_attrsGroupName=!1;_ignorePiTags=!1;_ignoreDeclaration=!1;constructor(e){this.options={...Y,...e},this.entityDecoder=new $(this.options.htmlEntities),this.unpairedSet=new Set(this.options.unpairedTags),this.exactStopNodes=new Set,this.wildcardStopSuffixes=[];for(let t of this.options.stopNodes)if(t.startsWith("*."))this.wildcardStopSuffixes.push(t.substring(2));else this.exactStopNodes.add(t);this._ignoreAttributes=this.options.ignoreAttributes,this._textNodeName=this.options.textNodeName,this._commentPropName=this.options.commentPropName,this._cdataPropName=this.options.cdataPropName,this._piPropName=this.options.piPropName,this._alwaysCreateTextNode=this.options.alwaysCreateTextNode,this._trimValues=this.options.trimValues,this._processEntities=this.options.processEntities,this._parseTagValue=this.options.parseTagValue,this._parseAttributeValue=this.options.parseAttributeValue,this._removeNSPrefix=this.options.removeNSPrefix,this._attrPrefix=this.options.attributeNamePrefix,this._attrsGroupName=this.options.attributesGroupName,this._ignorePiTags=this.options.ignorePiTags,this._ignoreDeclaration=this.options.ignoreDeclaration,this.needsJPath=this.options.stopNodes.length>0||this.options.isArray!==void 0||this.options.updateTag!==void 0||this.options.tagValueProcessor!==void 0||this.options.attributeValueProcessor!==void 0}addEntity(e,t){this.entityDecoder.addEntity(e,t)}parse(e){if(e instanceof Uint8Array)e=new TextDecoder().decode(e);let t=e;if(this.options.preserveOrder)return this.parseOrdered(t);return this.parseUnordered(t)}parseUnordered(e){let t={},i=e.length,n=0;if(i>0&&e.charCodeAt(0)===65279)n=1;return n=this.parseChildren(e,n,i,t,"",[]),t}parseOrdered(e){let t=e.length,i=0;if(t>0&&e.charCodeAt(0)===65279)i=1;let n=[];return this.parseChildrenOrdered(e,i,t,n,""),n}readTagName(e,t,i){return M(e,t,i)}extractTagName(e,t,i){let n=e.substring(t,i);if(this._removeNSPrefix){let r=n.indexOf(":");if(r!==-1)n=n.substring(r+1)}if(this.options.transformTagName)n=this.options.transformTagName(n);return n}parseAttributes(e,t,i,n,r){let s=0,u=this._removeNSPrefix,a=this.options.transformAttributeName,c=this._trimValues,A=this._processEntities,g=this.options.attributeValueProcessor;while(t<i){let h=e.charCodeAt(t);while(h===32||h===9||h===10||h===13){if(t++,t>=i)break;h=e.charCodeAt(t)}if(t>=i)break;if(h===62||h===47)break;let N=t;if(!V(h))break;t++;while(t<i&&x(e.charCodeAt(t)))t++;let d=e.substring(N,t);if(u){let C=d.indexOf(":");if(C!==-1)d=d.substring(C+1)}if(a)d=a(d);while(t<i&&P(e.charCodeAt(t)))t++;if(t<i&&e.charCodeAt(t)===61){t++;while(t<i&&P(e.charCodeAt(t)))t++;if(t>=i)break;let C=e.charCodeAt(t);if(C===34||C===39){t++;let _=t;while(t<i&&e.charCodeAt(t)!==C)t++;let f=e.substring(_,t);if(c&&f.length>0){let o=f.charCodeAt(0),l=f.charCodeAt(f.length-1);if(o<=32||l<=32)f=f.trim()}if(A)f=this.entityDecoder.decodeEntities(f);if(g)f=g(d,f,n)??f;if(r[d]=f,s++,t<i)t++}}else r[d]="true",s++}return s>0?-t-1:t}processTagValue(e,t,i,n,r){if(this._trimValues){let s=e.length;if(s>0){let u=e.charCodeAt(0),a=e.charCodeAt(s-1);if(u<=32||a<=32)e=e.trim()}}if(this._processEntities)e=this.entityDecoder.decodeEntities(e);if(this.options.tagValueProcessor){let s=this.options.tagValueProcessor(t,e,i,n,r);if(s!==void 0)e=s}if(!e)return e;if(this._parseTagValue)return this.parseValue(e);return e}parseValue(e){if(e==="true")return!0;if(e==="false")return!1;if(!e)return e;let t=e.charCodeAt(0);if(!(t>=48&&t<=57||t===43||t===45||t===46))return e;let n=this.options.numberParseOptions;if(n.skipLike?.test(e))return e;if(n.hex&&t===48&&z.test(e))return Number.parseInt(e,16);if(e.length>1&&t===48&&e.charCodeAt(1)!==46){if(n.leadingZeros)return e}if(n.scientific&&Z.test(e)){let r=Number(e);if(!Number.isNaN(r))return r}if(j.test(e)){let r=Number(e);if(!Number.isNaN(r))return r}return e}parseAttributeValue(e){if(!this._parseAttributeValue)return e;return this.parseValue(e)}isStopNode(e){if(this.exactStopNodes.has(e))return!0;for(let t of this.wildcardStopSuffixes)if(e.endsWith(`.${t}`)||e===t)return!0;return!1}readStopNodeContent(e,t,i,n){let r=`</${n}`,s=e.indexOf(r,t);if(s===-1)return{content:e.substring(t),pos:i};let u=e.substring(t,s),a=s+r.length;while(a<i&&e.charCodeAt(a)!==62)a++;if(a<i)a++;return{content:u,pos:a}}addToObj(e,t,i,n,r,s){let u=e[t];if(u!==void 0)if(!Array.isArray(u))e[t]=[u,i];else u.push(i);else if(this.options.isArray?.(t,n,r,s))e[t]=[i];else e[t]=i}flushText(e,t,i,n){if(!e&&!t)return;let r=this._textNodeName;if(t){let s=e;if(s&&this._processEntities)s=this.entityDecoder.decodeEntities(s);let u=t+s;if(this._trimValues&&u.length>0){let a=u.charCodeAt(0),c=u.charCodeAt(u.length-1);if(a<=32||c<=32)u=u.trim()}if(this.options.tagValueProcessor){let a=this.options.tagValueProcessor(r,u,i,!1,!0);if(a!==void 0)u=a}if(u){let a=this._parseTagValue?this.parseValue(u):u;if(a!==void 0&&a!=="")this.addToObj(n,r,a,i,!0,!1)}}else{let s=this.processTagValue(e,r,i,!1,!0);if(s!==void 0&&s!=="")this.addToObj(n,r,s,i,!0,!1)}}parseChildren(e,t,i,n,r,s){let u="",a="",c=this.needsJPath;while(t<i){if(e.charCodeAt(t)!==60){let o=t;t++;while(t<i&&e.charCodeAt(t)!==60)t++;if(!u)u=e.substring(o,t);else u+=e.substring(o,t);continue}if(t+1>=i)break;let g=e.charCodeAt(t+1);if(g===33&&t+3<i&&e.charCodeAt(t+2)===45&&e.charCodeAt(t+3)===45){if(u||a)this.flushText(u,a,r,n),u="",a="";t+=4;let o=e.indexOf("-->",t);if(o===-1){t=i;break}if(this._commentPropName){let l=e.substring(t,o);this.addToObj(n,this._commentPropName,l,r,!0,!1)}t=o+3;continue}if(g===33&&t+8<i&&I(e,t+2)){t+=9;let o=e.indexOf("]]>",t);if(o===-1){t=i;break}let l=e.substring(t,o);if(this._cdataPropName)this.flushText(u,a,r,n),u="",a="",this.addToObj(n,this._cdataPropName,l,r,!0,!1);else{if(u){let b=u;if(this._processEntities)b=this.entityDecoder.decodeEntities(b);a+=b,u=""}a+=l}t=o+3;continue}if(g===33&&t+9<i&&D(e,t+2)){t+=9;let o=1;while(t<i&&o>0){let l=e.charCodeAt(t);if(l===60)o++;else if(l===62)o--;t++}continue}if(g===63){t+=2;let o=t;while(t<i&&!P(e.charCodeAt(t))&&e.charCodeAt(t)!==63)t++;let l=e.substring(o,t),b=e.indexOf("?>",t);if(b===-1){t=i;break}let m=e.substring(t,b).trim();if(l==="xml"){if(!this._ignoreDeclaration&&this._piPropName){let T=this.parsePiAttributes(m);this.addToObj(n,this._piPropName,{[l]:T},r,!0,!1)}}else if(!this._ignorePiTags&&this._piPropName)this.addToObj(n,this._piPropName,{[l]:m},r,!0,!1);t=b+2;continue}if(g===47){if(u||a)this.flushText(u,a,r,n),u="",a="";t+=2;let o=t,l=this.readTagName(e,t,i),b=this.extractTagName(e,o,l);t=l;while(t<i&&P(e.charCodeAt(t)))t++;if(t<i&&e.charCodeAt(t)===62)t++;if(s.length>0&&s[s.length-1]===b){s.pop();continue}return t}if(u||a)this.flushText(u,a,r,n),u="",a="";t++;let h=t,N=this.readTagName(e,t,i),d=this.extractTagName(e,h,N);if(!d){t=N+1;continue}t=N;let C=c?r?`${r}.${d}`:d:"",_={},f=!1;if(!this._ignoreAttributes){let o=this.parseAttributes(e,t,i,C,_);if(o<0)t=-o-1,f=!0;else t=o}else while(t<i){let o=e.charCodeAt(t);if(o===62||o===47)break;if(o===34||o===39){t++;while(t<i&&e.charCodeAt(t)!==o)t++}t++}if(this.options.updateTag){if(this.options.updateTag(d,C,_)===!1){while(t<i&&P(e.charCodeAt(t)))t++;if(t<i&&e.charCodeAt(t)===47)t+=2;else if(t<i&&e.charCodeAt(t)===62){t++;let l=`</${d}>`,b=e.indexOf(l,t);if(b!==-1)t=b+l.length}continue}}while(t<i&&P(e.charCodeAt(t)))t++;if(t<i&&e.charCodeAt(t)===47){if(t+=2,f||this._alwaysCreateTextNode){let o={};if(f)this.applyAttributes(o,_,C);if(this._alwaysCreateTextNode)o[this._textNodeName]="";this.addToObj(n,d,o,C,!0,!1)}else this.addToObj(n,d,"",C,!0,!1);continue}if(t<i&&e.charCodeAt(t)===62){if(t++,this.unpairedSet.has(d)){if(f){let m={};this.applyAttributes(m,_,C),this.addToObj(n,d,m,C,!0,!1)}else this.addToObj(n,d,"",C,!0,!1);s.push(d);continue}if(this.exactStopNodes.size>0||this.wildcardStopSuffixes.length>0){if(this.isStopNode(C)){let m=this.readStopNodeContent(e,t,i,d),T={};if(f)this.applyAttributes(T,_,C);if(m.content)T[this._textNodeName]=m.content;this.addToObj(n,d,T,C,!0,!1),t=m.pos;continue}}let o={};if(f)this.applyAttributes(o,_,C);t=this.parseChildren(e,t,i,o,C,s);let l=this._textNodeName,b=o[l];if(!f&&!this._alwaysCreateTextNode){let m=!0;for(let T in o)if(T!==l){m=!1;break}if(m){this.addToObj(n,d,b!==void 0?b:"",C,!0,!1);continue}}this.addToObj(n,d,o,C,!1,!1)}}if(u||a)this.flushText(u,a,r,n);return t}parseChildrenOrdered(e,t,i,n,r){let s="",u=this.needsJPath;while(t<i){if(e.charCodeAt(t)!==60){let f=t;t++;while(t<i&&e.charCodeAt(t)!==60)t++;if(!s)s=e.substring(f,t);else s+=e.substring(f,t);continue}if(t+1>=i)break;let c=e.charCodeAt(t+1);if(c===33&&t+3<i&&e.charCodeAt(t+2)===45&&e.charCodeAt(t+3)===45){if(s){let o=this.processTagValue(s,this._textNodeName,r,!1,!0);if(o!==void 0&&o!=="")n.push({[this._textNodeName]:o});s=""}t+=4;let f=e.indexOf("-->",t);if(f===-1){t=i;break}if(this._commentPropName)n.push({[this._commentPropName]:[{[this._textNodeName]:e.substring(t,f)}]});t=f+3;continue}if(c===33&&t+8<i&&I(e,t+2)){t+=9;let f=e.indexOf("]]>",t);if(f===-1){t=i;break}let o=e.substring(t,f);if(this._cdataPropName){if(s){let l=this.processTagValue(s,this._textNodeName,r,!1,!0);if(l!==void 0&&l!=="")n.push({[this._textNodeName]:l});s=""}n.push({[this._cdataPropName]:[{[this._textNodeName]:o}]})}else s+=o;t=f+3;continue}if(c===33&&t+9<i&&D(e,t+2)){t+=9;let f=1;while(t<i&&f>0){let o=e.charCodeAt(t);if(o===60)f++;else if(o===62)f--;t++}continue}if(c===63){t+=2;let f=e.indexOf("?>",t);if(f===-1){t=i;break}t=f+2;continue}if(c===47){if(s){let o=this.processTagValue(s,this._textNodeName,r,!1,!0);if(o!==void 0&&o!=="")n.push({[this._textNodeName]:o});s=""}t+=2,t=this.readTagName(e,t,i);while(t<i&&P(e.charCodeAt(t)))t++;if(t<i&&e.charCodeAt(t)===62)t++;return t}if(s){let f=this.processTagValue(s,this._textNodeName,r,!1,!0);if(f!==void 0&&f!=="")n.push({[this._textNodeName]:f});s=""}t++;let A=t,g=this.readTagName(e,t,i),h=this.extractTagName(e,A,g);if(!h){t=g+1;continue}t=g;let N=u?r?`${r}.${h}`:h:"",d={},C=!1;if(!this._ignoreAttributes){let f=this.parseAttributes(e,t,i,N,d);if(f<0)t=-f-1,C=!0;else t=f}else while(t<i){let f=e.charCodeAt(t);if(f===62||f===47)break;if(f===34||f===39){t++;while(t<i&&e.charCodeAt(t)!==f)t++}t++}while(t<i&&P(e.charCodeAt(t)))t++;let _={[h]:[]};if(C){_[":@"]={};for(let o in d)_[":@"][this._attrPrefix+o]=this.parseAttributeValue(d[o])}if(t<i&&e.charCodeAt(t)===47){t+=2,n.push(_);continue}if(t<i&&e.charCodeAt(t)===62)t++,t=this.parseChildrenOrdered(e,t,i,_[h],N),n.push(_)}if(s){let a=this.processTagValue(s,this._textNodeName,r,!1,!0);if(a!==void 0&&a!=="")n.push({[this._textNodeName]:a})}return t}applyAttributes(e,t,i){let n=this._attrPrefix;if(this._attrsGroupName){let r={};for(let s in t)r[n+s]=this.parseAttributeValue(t[s]);e[this._attrsGroupName]=r}else for(let r in t)e[n+r]=this.parseAttributeValue(t[r])}parsePiAttributes(e){let t={},i=0,n=e.length;while(i<n){while(i<n&&P(e.charCodeAt(i)))i++;if(i>=n)break;let r=i;while(i<n&&!P(e.charCodeAt(i))&&e.charCodeAt(i)!==61)i++;let s=e.substring(r,i);if(!s)break;while(i<n&&P(e.charCodeAt(i)))i++;if(i<n&&e.charCodeAt(i)===61){i++;while(i<n&&P(e.charCodeAt(i)))i++;if(i<n){let u=e.charCodeAt(i);if(u===34||u===39){i++;let a=i;while(i<n&&e.charCodeAt(i)!==u)i++;if(t[s]=e.substring(a,i),i<n)i++}}}}return t}}function F(e){let t=e.endpoint||`s3.${e.region}.amazonaws.com`,i=new URL(/^https?:\/\//i.test(t)?t:`https://${t}`);if(i.protocol!=="http:"&&i.protocol!=="https:"||i.pathname!=="/"&&i.pathname!==""||i.search||i.hash||i.username||i.password)throw Error("S3 endpoint must be an HTTP(S) origin without a path");let n=i.protocol.slice(0,-1),r=i.host;if(!e.bucket)return{protocol:n,host:r,path:e.path};if(e.forcePathStyle){let s=e.path==="/"?`/${e.bucket}`:`/${e.bucket}${e.path}`;return{protocol:n,host:r,path:s}}return{protocol:n,host:`${e.bucket}.${r}`,path:e.path}}class H{credentials;config;cache;xmlParser;constructor(e,t){this.config={maxRetries:3,retryDelay:1000,cacheEnabled:!0,defaultCacheTTL:60000,...t},this.credentials=e||this.loadCredentials(),this.cache=new Map,this.xmlParser=new B({ignoreAttributes:!1,attributeNamePrefix:"@_",textNodeName:"#text",parseAttributeValue:!0,trimValues:!0})}loadCredentials(){let e=process.env.AWS_ACCESS_KEY_ID,t=process.env.AWS_SECRET_ACCESS_KEY,i=process.env.AWS_SESSION_TOKEN;if(e&&t)return{accessKeyId:e,secretAccessKey:t,sessionToken:i};let n=this.loadCredentialsFromFile();if(n)return n;return{accessKeyId:"",secretAccessKey:""}}loadCredentialsFromFile(){let e=this.config?.profile||process.env.AWS_PROFILE||"default",t=process.env.AWS_SHARED_CREDENTIALS_FILE||y(G(),".aws","credentials");if(!U(t))return null;try{let i=Q(t,"utf-8"),n=this.parseCredentialsFile(i,e);if(n.accessKeyId&&n.secretAccessKey)return n}catch{}return null}parseCredentialsFile(e,t){let i=e.split(`
2
+ `),n="",r="",s="",u;for(let a of i){let c=a.trim();if(!c||c.startsWith("#"))continue;let A=c.match(/^\[([^\]]+)\]$/);if(A){n=A[1];continue}if(n===t){let[g,...h]=c.split("="),N=h.join("=").trim();if(g.trim()==="aws_access_key_id")r=N;else if(g.trim()==="aws_secret_access_key")s=N;else if(g.trim()==="aws_session_token")u=N}}return{accessKeyId:r,secretAccessKey:s,sessionToken:u}}ec2CredentialsCache;async getCredentials(){let e=process.env.AWS_ACCESS_KEY_ID,t=process.env.AWS_SECRET_ACCESS_KEY;if(e&&t)return{accessKeyId:e,secretAccessKey:t,sessionToken:process.env.AWS_SESSION_TOKEN};let i=this.loadCredentialsFromFile();if(i)return i;if(this.ec2CredentialsCache){let n=Date.now();if(this.ec2CredentialsCache.expiration>n+300000)return this.ec2CredentialsCache.credentials}try{let r=await(await fetch("http://169.254.169.254/latest/api/token",{method:"PUT",headers:{"X-aws-ec2-metadata-token-ttl-seconds":"21600"}})).text(),u=await(await fetch("http://169.254.169.254/latest/meta-data/iam/security-credentials/",{headers:{"X-aws-ec2-metadata-token":r}})).text(),c=await(await fetch(`http://169.254.169.254/latest/meta-data/iam/security-credentials/${u}`,{headers:{"X-aws-ec2-metadata-token":r}})).json(),A={accessKeyId:c.AccessKeyId,secretAccessKey:c.SecretAccessKey,sessionToken:c.Token};return this.ec2CredentialsCache={credentials:A,expiration:new Date(c.Expiration).getTime()},A}catch(n){throw Error("AWS credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables, or run on an EC2 instance with an IAM role.")}}async request(e){if(e.method==="GET"&&this.config.cacheEnabled&&e.cacheKey){let n=this.getFromCache(e.cacheKey);if(n!==null)return n}let t=e.retries??this.config.maxRetries??3,i=null;for(let n=0;n<=t;n++)try{let r=await this.makeRequest(e);if(e.method==="GET"&&this.config.cacheEnabled&&e.cacheKey)this.setInCache(e.cacheKey,r,e.cacheTTL??this.config.defaultCacheTTL??60000);return r}catch(r){if(i=r,!this.shouldRetry(r))throw r;if(n===t)throw r;let u=this.calculateRetryDelay(n);await this.sleep(u)}throw i||Error("Request failed after retries")}async makeRequest(e){let t=e.credentials||(this.credentials?.accessKeyId?this.credentials:await this.getCredentials());if(!t||!t.accessKeyId||!t.secretAccessKey)throw Error("AWS credentials not provided");let i=this.buildUrl(e),n=this.signRequest(e,t),r=await fetch(i,{method:e.method,headers:n,body:e.body}),s=await r.text();if(!r.ok)throw this.parseError(s,r.status,r.headers);if(!s||s.trim()===""){if(e.returnHeaders)return{body:null,headers:this.headersToObject(r.headers)};return null}if(e.rawResponse){if(e.returnHeaders)return{body:s,headers:this.headersToObject(r.headers)};return s}let u;if(s.startsWith("<"))u=this.parseXmlResponse(s);else try{u=JSON.parse(s)}catch{u=s}if(e.returnHeaders)return{body:u,headers:this.headersToObject(r.headers)};return u}headersToObject(e){let t={};return e.forEach((i,n)=>{t[n]=i}),t}buildUrl(e){let{service:t,region:i,queryParams:n}=e,{path:r}=e,s,u="https";if(t==="s3"){let c=F({region:i,path:r,bucket:e.bucket,endpoint:this.config.endpoint,forcePathStyle:this.config.forcePathStyle});u=c.protocol,s=c.host,r=c.path}else if(t==="cloudfront")s="cloudfront.amazonaws.com";else if(t==="iam")s="iam.amazonaws.com";else if(t==="route53")s="route53.amazonaws.com";else if(t==="route53domains")s="route53domains.us-east-1.amazonaws.com";else if(t==="ecr")s=`api.ecr.${i}.amazonaws.com`;else if(t==="ses")s=`email.${i}.amazonaws.com`;else s=`${t}.${i}.amazonaws.com`;let a=`${u}://${s}${r}`;if(n&&Object.keys(n).length>0){let c=Object.keys(n).map((A)=>`${this.uriEncode(A)}=${this.uriEncode(n[A])}`).join("&");a+=`?${c}`}return a}signRequest(e,t){let{service:i,region:n,method:r,queryParams:s,body:u}=e,{path:a}=e,c=new Date,A=this.getAmzDate(c),g=this.getDateStamp(c),h;if(i==="s3"){let E=F({region:n,path:a,bucket:e.bucket,endpoint:this.config.endpoint,forcePathStyle:this.config.forcePathStyle});h=E.host,a=E.path}else if(i==="cloudfront")h="cloudfront.amazonaws.com";else if(i==="iam")h="iam.amazonaws.com";else if(i==="route53")h="route53.amazonaws.com";else if(i==="route53domains")h="route53domains.us-east-1.amazonaws.com";else if(i==="ecr")h=`api.ecr.${n}.amazonaws.com`;else if(i==="ses")h=`email.${n}.amazonaws.com`;else h=`${i}.${n}.amazonaws.com`;let N={host:h,"x-amz-date":A,...e.headers||{}};if(t.sessionToken)N["x-amz-security-token"]=t.sessionToken;if(u){if(!Object.keys(N).some((w)=>w.toLowerCase()==="content-type"))N["content-type"]="application/x-www-form-urlencoded";N["content-length"]=Buffer.byteLength(u).toString()}let d=this.sha256(u||"");N["x-amz-content-sha256"]=d;let C=a,_=s?Object.keys(s).sort().map((E)=>`${this.uriEncode(E)}=${this.uriEncode(s[E])}`).join("&"):"",f=Object.keys(N).sort((E,w)=>E.toLowerCase().localeCompare(w.toLowerCase())),o=f.map((E)=>`${E.toLowerCase()}:${N[E].trim()}
3
+ `).join(""),l=f.map((E)=>E.toLowerCase()).join(";"),b=[r,C,_,o,l,d].join(`
4
+ `),m="AWS4-HMAC-SHA256",T=i;if(i==="email")T="ses";let S=`${g}/${n}/${T}/aws4_request`,X=[m,A,S,this.sha256(b)].join(`
5
+ `),R=this.getSignatureKey(t.secretAccessKey,g,n,T),q=this.hmac(R,X),J=`${m} Credential=${t.accessKeyId}/${S}, SignedHeaders=${l}, Signature=${q}`;return{...N,Authorization:J}}getAmzDate(e){return e.toISOString().replace(/[:-]|\.\d{3}/g,"")}getDateStamp(e){return e.toISOString().slice(0,10).replace(/-/g,"")}uriEncode(e){return encodeURIComponent(e).replace(/[!'()*]/g,(t)=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}sha256(e){return O.createHash("sha256").update(e,"utf8").digest("hex")}hmac(e,t){return O.createHmac("sha256",e).update(t,"utf8").digest("hex")}getSignatureKey(e,t,i,n){let r=O.createHmac("sha256",`AWS4${e}`).update(t).digest(),s=O.createHmac("sha256",r).update(i).digest(),u=O.createHmac("sha256",s).update(n).digest();return O.createHmac("sha256",u).update("aws4_request").digest()}parseXmlResponse(e){try{let t=this.xmlParser.parse(e);if(t.ErrorResponse)throw this.createErrorFromXml(t.ErrorResponse.Error);let i=Object.keys(t);if(i.length===1)return t[i[0]];return t}catch(t){if(t.code||t.statusCode)throw t;return{}}}parseError(e,t,i){let n=Error();if(n.statusCode=t,n.requestId=i.get("x-amzn-requestid")||i.get("x-amz-request-id")||void 0,e.startsWith("<"))try{let r=this.xmlParser.parse(e);if(r.ErrorResponse?.Error){let s=r.ErrorResponse.Error;return n.code=s.Code,n.message=`AWS Error [${s.Code}]: ${s.Message||"Unknown error"}`,n.type=s.Type,n}if(r.Error)return n.code=r.Error.Code,n.message=`AWS Error [${r.Error.Code}]: ${r.Error.Message||"Unknown error"}`,n}catch{}try{let r=JSON.parse(e);if(r.__type||r.code)return n.code=r.__type||r.code,n.message=`AWS Error [${n.code}]: ${r.message||r.Message||"Unknown error"}`,n}catch{}return n.message=`AWS API Error (${t}): ${e}`,n}createErrorFromXml(e){let t=Error();return t.code=e.Code,t.message=`AWS Error [${e.Code}]: ${e.Message||"Unknown error"}`,t.type=e.Type,t}isRetryableError(e){return["RequestTimeout","RequestTimeoutException","PriorRequestNotComplete","ConnectionError","ThrottlingException","Throttling","TooManyRequestsException","ProvisionedThroughputExceededException","RequestLimitExceeded","BandwidthLimitExceeded","SlowDown","ServiceUnavailable","ServiceUnavailableException","InternalError","InternalFailure","InternalServerError","InternalServiceException","TransientError","TransientFailure","IDPCommunicationErrorException","NetworkError","ConnectionRefusedException","EC2ThrottledException","503 Slow Down","500 InternalError"].includes(e)}isRetryableStatusCode(e){return e>=500||e===429}shouldRetry(e){if(e.name==="FetchError"||e.name==="TypeError"||e.code==="ECONNRESET")return!0;if(e.code&&this.isRetryableError(e.code))return!0;if(e.statusCode&&this.isRetryableStatusCode(e.statusCode))return!0;if(e.statusCode&&e.statusCode>=400&&e.statusCode<500&&e.statusCode!==429)return!1;if(e.statusCode)return!1;return!0}calculateRetryDelay(e){let t=this.config.retryDelay??1000,i=30000,n=Math.min(t*2**e,30000),r=Math.random()*0.3*n;return n+r}sleep(e){return new Promise((t)=>setTimeout(t,e))}getFromCache(e){let t=this.cache.get(e);if(!t)return null;if(Date.now()>t.expires)return this.cache.delete(e),null;return t.data}setInCache(e,t,i){this.cache.set(e,{data:t,expires:Date.now()+i})}clearCache(){this.cache.clear()}clearExpiredCache(){let e=Date.now();for(let[t,i]of this.cache.entries())if(e>i.expires)this.cache.delete(t)}}function it(e){let t={};for(let[i,n]of Object.entries(e)){if(n===void 0||n===null)continue;if(Array.isArray(n))n.forEach((r,s)=>{t[`${i}.${s+1}`]=String(r)});else if(typeof n==="object")for(let[r,s]of Object.entries(n))t[`${i}.${r}`]=String(s);else t[i]=String(n)}return t}function nt(){let e=process.env.AWS_ACCESS_KEY_ID,t=process.env.AWS_SECRET_ACCESS_KEY,i=e==="",n=t==="";if(e&&t)return{source:"env",emptyEnvKey:i,emptyEnvSecret:n,description:"environment variables (AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY)"};let r=process.env.AWS_PROFILE||"default",s=process.env.AWS_SHARED_CREDENTIALS_FILE||y(G(),".aws","credentials");if(U(s))return{source:"file",profile:r,emptyEnvKey:i,emptyEnvSecret:n,description:`~/.aws/credentials (profile: ${r})`};return{source:"ec2",emptyEnvKey:i,emptyEnvSecret:n,description:"EC2 instance metadata service (IMDSv2)"}}
6
+ export{F as Ng,H as Og,it as Pg,nt as Qg};
@@ -0,0 +1 @@
1
+ import{yd as a}from"./chunk-4vrqm9h0.js";import"./chunk-fpm59y25.js";import"./chunk-mh0kdzqp.js";export{a as SQSClient};
@@ -0,0 +1,92 @@
1
+ import{Ng as y,Og as b}from"./chunk-fpm59y25.js";import{Vo as H}from"./chunk-mh0kdzqp.js";import*as J from"node:crypto";import{readFileSync as m}from"node:fs";import{readdir as d}from"node:fs/promises";import{join as p}from"node:path";function f(_){if(_){let C=h(_);if(!C)throw Error(`AWS profile '${_}' not found in ~/.aws/credentials`);return C}let E=process.env.AWS_ACCESS_KEY_ID,W=process.env.AWS_SECRET_ACCESS_KEY;if(E&&W)return{accessKeyId:E,secretAccessKey:W,sessionToken:process.env.AWS_SESSION_TOKEN};return h(process.env.AWS_PROFILE||"default")??{accessKeyId:"",secretAccessKey:""}}function h(_){let{existsSync:E,readFileSync:W}=H("node:fs"),{homedir:C}=H("node:os"),{join:A}=H("node:path"),Y=process.env.AWS_SHARED_CREDENTIALS_FILE||A(C(),".aws","credentials");if(!E(Y))return null;let $=W(Y,"utf-8"),G=null,V,Z,Q;for(let N of $.split(`
2
+ `)){let L=N.trim();if(!L||L.startsWith("#")||L.startsWith(";"))continue;let w=L.match(/^\[([^\]]+)\]$/);if(w){if(G===_&&V&&Z)return{accessKeyId:V,secretAccessKey:Z,sessionToken:Q};G=w[1],V=void 0,Z=void 0,Q=void 0;continue}if(G===_){let[M,...U]=L.split("="),F=U.join("=").trim();switch(M.trim().toLowerCase()){case"aws_access_key_id":V=F;break;case"aws_secret_access_key":Z=F;break;case"aws_session_token":Q=F;break}}}if(G===_&&V&&Z)return{accessKeyId:V,secretAccessKey:Z,sessionToken:Q};return null}function g(_){let{buffer:E,byteOffset:W,byteLength:C}=_;if(E instanceof ArrayBuffer)return E.slice(W,W+C);let A=new ArrayBuffer(C);return new Uint8Array(A).set(new Uint8Array(_)),A}class l{client;region;explicitProfile;endpoint;endpointProtocol="https";forcePathStyle;explicitCredentials;constructor(_="us-east-1",E,W){let C=typeof _==="string"?W:_,A=typeof _==="string"?_:_.region??"us-east-1",Y=typeof _==="string"?E:_.profile,$=C?.endpoint?y({region:A,path:"/",endpoint:C.endpoint}):void 0;this.region=A,this.explicitProfile=Y,this.endpoint=$?.host,this.endpointProtocol=$?.protocol??"https",this.forcePathStyle=C?.forcePathStyle,this.explicitCredentials=C?.credentials,this.client=new b(C?.credentials,{profile:Y,endpoint:C?.endpoint,forcePathStyle:C?.forcePathStyle})}getCredentials(){if(this.explicitCredentials?.accessKeyId&&this.explicitCredentials.secretAccessKey)return this.explicitCredentials;let _=f(this.explicitProfile);if(_.accessKeyId&&_.secretAccessKey)return _;throw Error("S3 credentials not found. Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (or pass explicit credentials/profile), or configure ~/.aws/credentials.")}s3BaseHost(){return this.endpoint||`s3.${this.region}.amazonaws.com`}s3VirtualHost(_){return this.forcePathStyle?this.s3BaseHost():`${_}.${this.s3BaseHost()}`}objectPath(_,E){return this.forcePathStyle?`/${_}/${E}`:`/${E}`}objectUrl(_,E){return`${this.endpointProtocol}://${this.s3VirtualHost(_)}${this.objectPath(_,E)}`}async listBuckets(){let _=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/"}),E=[],C=(_?.ListAllMyBucketsResult??_)?.Buckets?.Bucket;if(C){let A=Array.isArray(C)?C:[C];for(let Y of A)E.push({Name:Y.Name,CreationDate:Y.CreationDate})}return{Buckets:E}}async createBucket(_,E){let W={};if(E?.acl)W["x-amz-acl"]=E.acl;let C;if(this.region!=="us-east-1"&&!this.endpoint)C=`<?xml version="1.0" encoding="UTF-8"?>
3
+ <CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
4
+ <LocationConstraint>${this.region}</LocationConstraint>
5
+ </CreateBucketConfiguration>`,W["Content-Type"]="application/xml";await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,headers:W,body:C})}async deleteBucket(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`})}async emptyAndDeleteBucket(_){let E=!0;while(E){let W=await this.listAllObjects({bucket:_});if(W.length===0){E=!1;break}let C=W.map((A)=>A.Key);for(let A=0;A<C.length;A+=1000){let Y=C.slice(A,A+1000);await this.deleteObjects(_,Y)}}await this.deleteBucket(_)}async listAllObjects(_){let E=[],W;do{let C={"list-type":"2","max-keys":"1000"};if(_.prefix)C.prefix=_.prefix;if(W)C["continuation-token"]=W;let A=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_.bucket}`,queryParams:C}),Y=A?.ListBucketResult??A,$=Y?.Contents;if($){let V=Array.isArray($)?$:[$];for(let Z of V)E.push({Key:Z.Key,LastModified:Z.LastModified||"",Size:Number.parseInt(Z.Size||"0"),ETag:Z.ETag})}let G=Y?.IsTruncated;W=G==="true"||G===!0?Y?.NextContinuationToken:void 0}while(W);return E}async list(_){let E=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_.bucket}`}),W=[],A=(E?.ListBucketResult??E)?.Contents;if(A){let Y=Array.isArray(A)?A:[A];for(let $ of Y){if(_.prefix&&!$.Key?.startsWith(_.prefix))continue;if(W.push({Key:$.Key||"",LastModified:$.LastModified||"",Size:Number.parseInt($.Size||"0"),ETag:$.ETag}),_.maxKeys&&W.length>=_.maxKeys)break}}return W}async putObject(_){let E={};if(_.acl)E["x-amz-acl"]=_.acl;if(_.cacheControl)E["Cache-Control"]=_.cacheControl;if(_.contentType)E["Content-Type"]=_.contentType;if(_.metadata)for(let[A,Y]of Object.entries(_.metadata))E[`x-amz-meta-${A}`]=Y;let W=_.key.split("/").map((A)=>encodeURIComponent(A)).join("/"),C=_.body instanceof Uint8Array&&!Buffer.isBuffer(_.body)?Buffer.from(_.body):_.body;if(Buffer.isBuffer(C)||C instanceof Uint8Array){let A=Buffer.isBuffer(C)?C:Buffer.from(C),{accessKeyId:Y,secretAccessKey:$,sessionToken:G}=this.getCredentials(),V=this.s3VirtualHost(_.bucket),Z=this.objectPath(_.bucket,W),Q=this.objectUrl(_.bucket,W),N=new Date,L=N.toISOString().replace(/[:-]|\.\d{3}/g,""),w=N.toISOString().slice(0,10).replace(/-/g,""),M=J.createHash("sha256").update(A).digest("hex"),U={host:V,"x-amz-date":L,"x-amz-content-sha256":M,...E};if(G)U["x-amz-security-token"]=G;let F=Object.keys(U).sort().map((B)=>`${B.toLowerCase()}:${U[B].trim()}
6
+ `).join(""),x=Object.keys(U).sort().map((B)=>B.toLowerCase()).join(";"),I=["PUT",Z,"",F,x,M].join(`
7
+ `),z="AWS4-HMAC-SHA256",P=`${w}/${this.region}/s3/aws4_request`,K=[z,L,P,J.createHash("sha256").update(I).digest("hex")].join(`
8
+ `),v=J.createHmac("sha256",`AWS4${$}`).update(w).digest(),X=J.createHmac("sha256",v).update(this.region).digest(),O=J.createHmac("sha256",X).update("s3").digest(),j=J.createHmac("sha256",O).update("aws4_request").digest(),T=J.createHmac("sha256",j).update(K).digest("hex"),R=`${z} Credential=${Y}/${P}, SignedHeaders=${x}, Signature=${T}`,D=await fetch(Q,{method:"PUT",headers:{...U,Authorization:R},body:g(A)});if(!D.ok){let B=await D.text();throw Error(`S3 PUT failed: ${D.status} ${B}`)}return}await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${W}`,bucket:_.bucket,headers:E,body:_.body})}async getObject(_,E){let W=E.split("/").map((A)=>encodeURIComponent(A)).join("/");return await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${W}`,bucket:_,rawResponse:!0})}async getObjectBytes(_,E){let{accessKeyId:W,secretAccessKey:C,sessionToken:A}=this.getCredentials(),Y=this.s3VirtualHost(_),$=E.split("/").map((B)=>encodeURIComponent(B)).join("/"),G=this.objectPath(_,$),V=this.objectUrl(_,$),Z=new Date,Q=Z.toISOString().replace(/[:-]|\.\d{3}/g,""),N=Z.toISOString().slice(0,10).replace(/-/g,""),L=J.createHash("sha256").update("").digest("hex"),w={host:Y,"x-amz-date":Q,"x-amz-content-sha256":L};if(A)w["x-amz-security-token"]=A;let M=Object.keys(w).sort().map((B)=>`${B.toLowerCase()}:${w[B].trim()}
9
+ `).join(""),U=Object.keys(w).sort().map((B)=>B.toLowerCase()).join(";"),F=["GET",G,"",M,U,L].join(`
10
+ `),x="AWS4-HMAC-SHA256",I=`${N}/${this.region}/s3/aws4_request`,z=[x,Q,I,J.createHash("sha256").update(F).digest("hex")].join(`
11
+ `),P=J.createHmac("sha256",`AWS4${C}`).update(N).digest(),K=J.createHmac("sha256",P).update(this.region).digest(),v=J.createHmac("sha256",K).update("s3").digest(),X=J.createHmac("sha256",v).update("aws4_request").digest(),O=J.createHmac("sha256",X).update(z).digest("hex"),j=`${x} Credential=${W}/${I}, SignedHeaders=${U}, Signature=${O}`,T=await fetch(V,{method:"GET",headers:{...w,Authorization:j}});if(!T.ok){let B=await T.text();throw Error(`S3 GET failed: ${T.status} ${B}`)}let R=await T.arrayBuffer(),D=T.headers.get("content-length");return{body:new Uint8Array(R),contentType:T.headers.get("content-type")??void 0,contentLength:D?Number.parseInt(D,10):void 0}}async copyObject(_){let E={"x-amz-copy-source":`/${_.sourceBucket}/${_.sourceKey}`};if(_.metadataDirective)E["x-amz-metadata-directive"]=_.metadataDirective;if(_.contentType)E["Content-Type"]=_.contentType;if(_.metadata)for(let[W,C]of Object.entries(_.metadata))E[`x-amz-meta-${W}`]=C;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_.destinationBucket}/${_.destinationKey}`,headers:E})}async deleteObject(_,E){let W=E.split("/").map((C)=>encodeURIComponent(C)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${W}`,bucket:_})}async deleteObjects(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
12
+ <Delete>
13
+ ${E.map((A)=>`<Object><Key>${A}</Key></Object>`).join(`
14
+ `)}
15
+ </Delete>`,C=J.createHash("md5").update(W).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}`,queryParams:{delete:""},body:W,headers:{"Content-Type":"application/xml","Content-MD5":C}})}async bucketExists(_){try{return await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${_}`}),!0}catch{return!1}}async copy(_){let E=m(_.source);await this.putObject({bucket:_.bucket,key:_.key,body:E,acl:_.acl,cacheControl:_.cacheControl,contentType:_.contentType,metadata:_.metadata})}async sync(_){let E=await this.listFilesRecursive(_.source);for(let W of E){if(_.exclude&&_.exclude.some((Y)=>W.includes(Y)))continue;if(_.include&&!_.include.some((Y)=>W.includes(Y)))continue;let C=W.substring(_.source.length+1),A=_.prefix?`${_.prefix}/${C}`:C;if(!_.dryRun){let Y=m(W);await this.putObject({bucket:_.bucket,key:A,body:Y,acl:_.acl,cacheControl:_.cacheControl,contentType:_.contentType,metadata:_.metadata})}}}async delete(_,E){await this.deleteObject(_,E)}async deletePrefix(_,E){let C=(await this.list({bucket:_,prefix:E})).map((A)=>A.Key);if(C.length>0)await this.deleteObjects(_,C)}async getBucketSize(_,E){return(await this.list({bucket:_,prefix:E})).reduce((C,A)=>C+A.Size,0)}async listFilesRecursive(_){let E=[],W=await d(_,{withFileTypes:!0});for(let C of W){let A=p(_,C.name);if(C.isDirectory()){let Y=await this.listFilesRecursive(A);E.push(...Y)}else E.push(A)}return E}async putBucketPolicy(_,E){let{accessKeyId:W,secretAccessKey:C,sessionToken:A}=this.getCredentials(),Y=this.s3BaseHost(),$=typeof E==="string"?E:JSON.stringify(E),G=new Date,V=G.toISOString().replace(/[:-]|\.\d{3}/g,""),Z=G.toISOString().slice(0,10).replace(/-/g,""),Q=J.createHash("sha256").update($).digest("hex"),N="/"+_,L="policy=",w={host:Y,"x-amz-date":V,"x-amz-content-sha256":Q,"content-type":"application/json"};if(A)w["x-amz-security-token"]=A;let M=Object.keys(w).sort().map((D)=>`${D.toLowerCase()}:${w[D].trim()}
16
+ `).join(""),U=Object.keys(w).sort().map((D)=>D.toLowerCase()).join(";"),F=["PUT",N,"policy=",M,U,Q].join(`
17
+ `),x="AWS4-HMAC-SHA256",I=`${Z}/${this.region}/s3/aws4_request`,z=[x,V,I,J.createHash("sha256").update(F).digest("hex")].join(`
18
+ `),P=J.createHmac("sha256","AWS4"+C).update(Z).digest(),K=J.createHmac("sha256",P).update(this.region).digest(),v=J.createHmac("sha256",K).update("s3").digest(),X=J.createHmac("sha256",v).update("aws4_request").digest(),O=J.createHmac("sha256",X).update(z).digest("hex"),j=`${x} Credential=${W}/${I}, SignedHeaders=${U}, Signature=${O}`,T=`${this.endpointProtocol}://${Y}${N}?policy=`,R=await fetch(T,{method:"PUT",headers:{...w,Authorization:j},body:$});if(!R.ok){let D=await R.text();throw Error(`Failed to put bucket policy: ${R.status} ${D}`)}}async getBucketPolicy(_){let{accessKeyId:E,secretAccessKey:W,sessionToken:C}=this.getCredentials(),A=this.s3BaseHost(),Y=new Date,$=Y.toISOString().replace(/[:-]|\.\d{3}/g,""),G=Y.toISOString().slice(0,10).replace(/-/g,""),V=J.createHash("sha256").update("").digest("hex"),Z="/"+_,Q="policy=",N={host:A,"x-amz-date":$,"x-amz-content-sha256":V};if(C)N["x-amz-security-token"]=C;let L=Object.keys(N).sort().map((R)=>`${R.toLowerCase()}:${N[R].trim()}
19
+ `).join(""),w=Object.keys(N).sort().map((R)=>R.toLowerCase()).join(";"),M=["GET",Z,"policy=",L,w,V].join(`
20
+ `),U="AWS4-HMAC-SHA256",F=`${G}/${this.region}/s3/aws4_request`,x=[U,$,F,J.createHash("sha256").update(M).digest("hex")].join(`
21
+ `),I=J.createHmac("sha256","AWS4"+W).update(G).digest(),z=J.createHmac("sha256",I).update(this.region).digest(),P=J.createHmac("sha256",z).update("s3").digest(),K=J.createHmac("sha256",P).update("aws4_request").digest(),v=J.createHmac("sha256",K).update(x).digest("hex"),X=`${U} Credential=${E}/${F}, SignedHeaders=${w}, Signature=${v}`,O=`${this.endpointProtocol}://${A}${Z}?policy=`,j=await fetch(O,{method:"GET",headers:{...N,Authorization:X}});if(j.status===404)return null;if(!j.ok){let R=await j.text();throw Error(`Failed to get bucket policy: ${j.status} ${R}`)}let T=await j.text();return JSON.parse(T)}async deleteBucketPolicy(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{policy:""}})}async headBucket(_){try{return{exists:!0,region:(await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${_}`,returnHeaders:!0}))?.headers?.["x-amz-bucket-region"]}}catch(E){if(E.statusCode===404)return{exists:!1};throw E}}async headObject(_,E){try{let W=await this.client.request({service:"s3",region:this.region,method:"HEAD",path:`/${_}/${E}`,returnHeaders:!0});return{ContentLength:W?.headers?.["content-length"]?parseInt(W.headers["content-length"]):void 0,ContentType:W?.headers?.["content-type"],ETag:W?.headers?.etag,LastModified:W?.headers?.["last-modified"]}}catch(W){if(W.statusCode===404)return null;throw W}}async getObjectBuffer(_,E){let W=await this.getObject(_,E);return Buffer.from(W)}async getObjectJson(_,E){let W=await this.getObject(_,E);return JSON.parse(W)}async putObjectJson(_,E,W,C){await this.putObject({bucket:_,key:E,body:JSON.stringify(W),contentType:"application/json",...C})}async getBucketVersioning(_){return{Status:(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{versioning:""}}))?.VersioningConfiguration?.Status}}async putBucketVersioning(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
22
+ <VersioningConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
23
+ <Status>${E}</Status>
24
+ </VersioningConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{versioning:""},headers:{"Content-Type":"application/xml"},body:W})}async getBucketLifecycleConfiguration(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{lifecycle:""}}))?.LifecycleConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketLifecycleConfiguration(_,E){let C=`<?xml version="1.0" encoding="UTF-8"?>
25
+ <LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
26
+ ${E.map((A)=>{let Y=`<Rule><ID>${A.ID}</ID><Status>${A.Status}</Status>`;if(A.Filter)Y+=`<Filter><Prefix>${A.Filter.Prefix||""}</Prefix></Filter>`;else Y+="<Filter><Prefix></Prefix></Filter>";if(A.Expiration){if(A.Expiration.Days)Y+=`<Expiration><Days>${A.Expiration.Days}</Days></Expiration>`;else if(A.Expiration.Date)Y+=`<Expiration><Date>${A.Expiration.Date}</Date></Expiration>`}if(A.Transitions)for(let $ of A.Transitions)Y+=`<Transition><Days>${$.Days}</Days><StorageClass>${$.StorageClass}</StorageClass></Transition>`;if(A.NoncurrentVersionExpiration)Y+=`<NoncurrentVersionExpiration><NoncurrentDays>${A.NoncurrentVersionExpiration.NoncurrentDays}</NoncurrentDays></NoncurrentVersionExpiration>`;return Y+="</Rule>",Y}).join("")}
27
+ </LifecycleConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{lifecycle:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketLifecycleConfiguration(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{lifecycle:""}})}async getBucketCors(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{cors:""}}))?.CORSConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketCors(_,E){let C=`<?xml version="1.0" encoding="UTF-8"?>
28
+ <CORSConfiguration>
29
+ ${E.map((A)=>{let Y="<CORSRule>";for(let $ of A.AllowedOrigins)Y+=`<AllowedOrigin>${$}</AllowedOrigin>`;for(let $ of A.AllowedMethods)Y+=`<AllowedMethod>${$}</AllowedMethod>`;if(A.AllowedHeaders)for(let $ of A.AllowedHeaders)Y+=`<AllowedHeader>${$}</AllowedHeader>`;if(A.ExposeHeaders)for(let $ of A.ExposeHeaders)Y+=`<ExposeHeader>${$}</ExposeHeader>`;if(A.MaxAgeSeconds)Y+=`<MaxAgeSeconds>${A.MaxAgeSeconds}</MaxAgeSeconds>`;return Y+="</CORSRule>",Y}).join("")}
30
+ </CORSConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{cors:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketCors(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{cors:""}})}async getBucketEncryption(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{encryption:""}}))?.ServerSideEncryptionConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketEncryption(_,E,W){let C=`<ApplyServerSideEncryptionByDefault><SSEAlgorithm>${E}</SSEAlgorithm>`;if(W)C+=`<KMSMasterKeyID>${W}</KMSMasterKeyID>`;C+="</ApplyServerSideEncryptionByDefault>";let A=`<?xml version="1.0" encoding="UTF-8"?>
31
+ <ServerSideEncryptionConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
32
+ <Rule>${C}</Rule>
33
+ </ServerSideEncryptionConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{encryption:""},headers:{"Content-Type":"application/xml"},body:A})}async deleteBucketEncryption(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{encryption:""}})}async getBucketTagging(_){try{let W=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!W)return[];return Array.isArray(W)?W:[W]}catch(E){if(E.statusCode===404)return[];throw E}}async putBucketTagging(_,E){let C=`<?xml version="1.0" encoding="UTF-8"?>
34
+ <Tagging>
35
+ <TagSet>${E.map((A)=>`<Tag><Key>${A.Key}</Key><Value>${A.Value}</Value></Tag>`).join("")}</TagSet>
36
+ </Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketTagging(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{tagging:""}})}async getObjectTagging(_,E){try{let C=(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}/${E}`,queryParams:{tagging:""}}))?.Tagging?.TagSet?.Tag;if(!C)return[];return Array.isArray(C)?C:[C]}catch(W){if(W.statusCode===404)return[];throw W}}async putObjectTagging(_,E,W){let A=`<?xml version="1.0" encoding="UTF-8"?>
37
+ <Tagging>
38
+ <TagSet>${W.map((Y)=>`<Tag><Key>${Y.Key}</Key><Value>${Y.Value}</Value></Tag>`).join("")}</TagSet>
39
+ </Tagging>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}/${E}`,queryParams:{tagging:""},headers:{"Content-Type":"application/xml"},body:A})}async deleteObjectTagging(_,E){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}/${E}`,queryParams:{tagging:""}})}async getBucketAcl(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putBucketAcl(_,E){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{acl:""},headers:{"x-amz-acl":E}})}async getObjectAcl(_,E){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}/${E}`,queryParams:{acl:""}}))?.AccessControlPolicy}async putObjectAcl(_,E,W){await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}/${E}`,queryParams:{acl:""},headers:{"x-amz-acl":W}})}async getBucketLocation(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{location:""}}))?.LocationConstraint||"us-east-1"}async getBucketLogging(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{logging:""}}))?.BucketLoggingStatus}async putBucketLogging(_,E,W){let C=`<?xml version="1.0" encoding="UTF-8"?>
40
+ <BucketLoggingStatus xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
41
+ <LoggingEnabled>
42
+ <TargetBucket>${E}</TargetBucket>
43
+ <TargetPrefix>${W}</TargetPrefix>
44
+ </LoggingEnabled>
45
+ </BucketLoggingStatus>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{logging:""},headers:{"Content-Type":"application/xml"},body:C})}async getBucketNotificationConfiguration(_){return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{notification:""}}))?.NotificationConfiguration}async putBucketNotificationConfiguration(_,E){let W="";if(E.LambdaFunctionConfigurations)for(let A of E.LambdaFunctionConfigurations){if(W+="<CloudFunctionConfiguration>",A.Id)W+=`<Id>${A.Id}</Id>`;W+=`<CloudFunction>${A.LambdaFunctionArn}</CloudFunction>`;for(let Y of A.Events)W+=`<Event>${Y}</Event>`;if(A.Filter?.Key?.FilterRules){W+="<Filter><S3Key>";for(let Y of A.Filter.Key.FilterRules)W+=`<FilterRule><Name>${Y.Name}</Name><Value>${Y.Value}</Value></FilterRule>`;W+="</S3Key></Filter>"}W+="</CloudFunctionConfiguration>"}if(E.TopicConfigurations)for(let A of E.TopicConfigurations){if(W+="<TopicConfiguration>",A.Id)W+=`<Id>${A.Id}</Id>`;W+=`<Topic>${A.TopicArn}</Topic>`;for(let Y of A.Events)W+=`<Event>${Y}</Event>`;W+="</TopicConfiguration>"}if(E.QueueConfigurations)for(let A of E.QueueConfigurations){if(W+="<QueueConfiguration>",A.Id)W+=`<Id>${A.Id}</Id>`;W+=`<Queue>${A.QueueArn}</Queue>`;for(let Y of A.Events)W+=`<Event>${Y}</Event>`;W+="</QueueConfiguration>"}let C=`<?xml version="1.0" encoding="UTF-8"?>
46
+ <NotificationConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
47
+ ${W}
48
+ </NotificationConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{notification:""},headers:{"Content-Type":"application/xml"},body:C})}async getBucketWebsite(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{website:""}}))?.WebsiteConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putBucketWebsite(_,E){let W="";if(E.RedirectAllRequestsTo)W=`<RedirectAllRequestsTo>
49
+ <HostName>${E.RedirectAllRequestsTo.HostName}</HostName>
50
+ ${E.RedirectAllRequestsTo.Protocol?`<Protocol>${E.RedirectAllRequestsTo.Protocol}</Protocol>`:""}
51
+ </RedirectAllRequestsTo>`;else if(W=`<IndexDocument><Suffix>${E.IndexDocument}</Suffix></IndexDocument>`,E.ErrorDocument)W+=`<ErrorDocument><Key>${E.ErrorDocument}</Key></ErrorDocument>`;let C=`<?xml version="1.0" encoding="UTF-8"?>
52
+ <WebsiteConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
53
+ ${W}
54
+ </WebsiteConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{website:""},headers:{"Content-Type":"application/xml"},body:C})}async deleteBucketWebsite(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{website:""}})}async getBucketReplication(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{replication:""}}))?.ReplicationConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async deleteBucketReplication(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{replication:""}})}async getPublicAccessBlock(_){try{return(await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${_}`,queryParams:{publicAccessBlock:""}}))?.PublicAccessBlockConfiguration}catch(E){if(E.statusCode===404)return null;throw E}}async putPublicAccessBlock(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
55
+ <PublicAccessBlockConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
56
+ <BlockPublicAcls>${E.BlockPublicAcls??!0}</BlockPublicAcls>
57
+ <IgnorePublicAcls>${E.IgnorePublicAcls??!0}</IgnorePublicAcls>
58
+ <BlockPublicPolicy>${E.BlockPublicPolicy??!0}</BlockPublicPolicy>
59
+ <RestrictPublicBuckets>${E.RestrictPublicBuckets??!0}</RestrictPublicBuckets>
60
+ </PublicAccessBlockConfiguration>`;await this.client.request({service:"s3",region:this.region,method:"PUT",path:`/${_}`,queryParams:{publicAccessBlock:""},headers:{"Content-Type":"application/xml"},body:W})}async deletePublicAccessBlock(_){await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${_}`,queryParams:{publicAccessBlock:""}})}generatePresignedGetUrl(_,E,W=3600){let{accessKeyId:C,secretAccessKey:A}=this.getCredentials(),Y=this.s3VirtualHost(_),$=new Date,G=$.toISOString().replace(/[:-]|\.\d{3}/g,""),V=$.toISOString().slice(0,10).replace(/-/g,""),Z=`${V}/${this.region}/s3/aws4_request`,Q=`${C}/${Z}`,N=E.split("/").map((P)=>encodeURIComponent(P)).join("/"),L=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":Q,"X-Amz-Date":G,"X-Amz-Expires":W.toString(),"X-Amz-SignedHeaders":"host"}),w=["GET",this.objectPath(_,N),L.toString(),`host:${Y}
61
+ `,"host","UNSIGNED-PAYLOAD"].join(`
62
+ `),M=["AWS4-HMAC-SHA256",G,Z,J.createHash("sha256").update(w).digest("hex")].join(`
63
+ `),U=J.createHmac("sha256",`AWS4${A}`).update(V).digest(),F=J.createHmac("sha256",U).update(this.region).digest(),x=J.createHmac("sha256",F).update("s3").digest(),I=J.createHmac("sha256",x).update("aws4_request").digest(),z=J.createHmac("sha256",I).update(M).digest("hex");return L.append("X-Amz-Signature",z),`${this.endpointProtocol}://${Y}${this.objectPath(_,N)}?${L.toString()}`}generatePresignedPutUrl(_,E,W,C=3600){let{accessKeyId:A,secretAccessKey:Y}=this.getCredentials(),$=this.s3VirtualHost(_),G=new Date,V=G.toISOString().replace(/[:-]|\.\d{3}/g,""),Z=G.toISOString().slice(0,10).replace(/-/g,""),Q=`${Z}/${this.region}/s3/aws4_request`,N=`${A}/${Q}`,L=E.split("/").map((K)=>encodeURIComponent(K)).join("/"),w=new URLSearchParams({"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":N,"X-Amz-Date":V,"X-Amz-Expires":C.toString(),"X-Amz-SignedHeaders":"content-type;host"}),M=["PUT",this.objectPath(_,L),w.toString(),`content-type:${W}
64
+ host:${$}
65
+ `,"content-type;host","UNSIGNED-PAYLOAD"].join(`
66
+ `),U=["AWS4-HMAC-SHA256",V,Q,J.createHash("sha256").update(M).digest("hex")].join(`
67
+ `),F=J.createHmac("sha256",`AWS4${Y}`).update(Z).digest(),x=J.createHmac("sha256",F).update(this.region).digest(),I=J.createHmac("sha256",x).update("s3").digest(),z=J.createHmac("sha256",I).update("aws4_request").digest(),P=J.createHmac("sha256",z).update(U).digest("hex");return w.append("X-Amz-Signature",P),`${this.endpointProtocol}://${$}${this.objectPath(_,L)}?${w.toString()}`}async createMultipartUpload(_,E,W){let C={};if(W?.contentType)C["Content-Type"]=W.contentType;if(W?.metadata)for(let[G,V]of Object.entries(W.metadata))C[`x-amz-meta-${G}`]=V;let A=E.split("/").map((G)=>encodeURIComponent(G)).join("/"),Y=await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${A}`,bucket:_,queryParams:{uploads:""},headers:C});return{UploadId:(Y?.InitiateMultipartUploadResult??Y)?.UploadId}}async uploadPart(_,E,W,C,A){let{accessKeyId:Y,secretAccessKey:$,sessionToken:G}=this.getCredentials(),V=this.s3VirtualHost(_),Z=E.split("/").map((q)=>encodeURIComponent(q)).join("/"),Q=this.objectPath(_,Z),N=`${this.objectUrl(_,Z)}?partNumber=${C}&uploadId=${encodeURIComponent(W)}`,L=new Date,w=L.toISOString().replace(/[:-]|\.\d{3}/g,""),M=L.toISOString().slice(0,10).replace(/-/g,""),U=J.createHash("sha256").update(A).digest("hex"),F={host:V,"x-amz-date":w,"x-amz-content-sha256":U};if(G)F["x-amz-security-token"]=G;let x=Object.keys(F).sort().map((q)=>`${q.toLowerCase()}:${F[q].trim()}
68
+ `).join(""),I=Object.keys(F).sort().map((q)=>q.toLowerCase()).join(";"),z=["PUT",Q,`partNumber=${C}&uploadId=${encodeURIComponent(W)}`,x,I,U].join(`
69
+ `),P="AWS4-HMAC-SHA256",K=`${M}/${this.region}/s3/aws4_request`,v=[P,w,K,J.createHash("sha256").update(z).digest("hex")].join(`
70
+ `),X=J.createHmac("sha256",`AWS4${$}`).update(M).digest(),O=J.createHmac("sha256",X).update(this.region).digest(),j=J.createHmac("sha256",O).update("s3").digest(),T=J.createHmac("sha256",j).update("aws4_request").digest(),R=J.createHmac("sha256",T).update(v).digest("hex"),D=`${P} Credential=${Y}/${K}, SignedHeaders=${I}, Signature=${R}`,B=await fetch(N,{method:"PUT",headers:{...F,Authorization:D},body:g(A)});if(!B.ok){let q=await B.text();throw Error(`Upload part failed: ${B.status} ${q}`)}return{ETag:B.headers.get("etag")||""}}async completeMultipartUpload(_,E,W,C){let A=E.split("/").map((G)=>encodeURIComponent(G)).join("/"),$=`<?xml version="1.0" encoding="UTF-8"?>
71
+ <CompleteMultipartUpload>${C.sort((G,V)=>G.PartNumber-V.PartNumber).map((G)=>`<Part><PartNumber>${G.PartNumber}</PartNumber><ETag>${G.ETag}</ETag></Part>`).join("")}</CompleteMultipartUpload>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${A}`,bucket:_,queryParams:{uploadId:W},headers:{"Content-Type":"application/xml"},body:$})}async abortMultipartUpload(_,E,W){let C=E.split("/").map((A)=>encodeURIComponent(A)).join("/");await this.client.request({service:"s3",region:this.region,method:"DELETE",path:`/${C}`,bucket:_,queryParams:{uploadId:W}})}async listMultipartUploads(_){let E=await this.client.request({service:"s3",region:this.region,method:"GET",path:"/",bucket:_,queryParams:{uploads:""}}),W=(E?.ListMultipartUploadsResult??E)?.Upload;if(!W)return[];return(Array.isArray(W)?W:[W]).map((A)=>({Key:A.Key,UploadId:A.UploadId,Initiated:A.Initiated}))}async restoreObject(_,E,W,C="Standard"){let A=`<?xml version="1.0" encoding="UTF-8"?>
72
+ <RestoreRequest>
73
+ <Days>${W}</Days>
74
+ <GlacierJobParameters>
75
+ <Tier>${C}</Tier>
76
+ </GlacierJobParameters>
77
+ </RestoreRequest>`;await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}/${E}`,queryParams:{restore:""},headers:{"Content-Type":"application/xml"},body:A})}async selectObjectContent(_,E,W,C,A="JSON"){let Y="";if(C==="CSV")Y="<CSV><FileHeaderInfo>USE</FileHeaderInfo></CSV>";else if(C==="JSON")Y="<JSON><Type>DOCUMENT</Type></JSON>";else Y="<Parquet/>";let $="";if(A==="CSV")$="<CSV/>";else $="<JSON/>";let G=`<?xml version="1.0" encoding="UTF-8"?>
78
+ <SelectObjectContentRequest>
79
+ <Expression>${W}</Expression>
80
+ <ExpressionType>SQL</ExpressionType>
81
+ <InputSerialization>${Y}</InputSerialization>
82
+ <OutputSerialization>${$}</OutputSerialization>
83
+ </SelectObjectContentRequest>`;return await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}/${E}`,queryParams:{select:"","select-type":"2"},headers:{"Content-Type":"application/xml"},body:G,rawResponse:!0})}async getSignedUrl(_){let{bucket:E,key:W,expiresIn:C=3600,operation:A="getObject"}=_,{accessKeyId:Y,secretAccessKey:$,sessionToken:G}=this.getCredentials(),V=new Date,Z=V.toISOString().replace(/[:-]|\.\d{3}/g,""),Q=V.toISOString().slice(0,10).replace(/-/g,""),N=this.s3VirtualHost(E),L=A==="putObject"?"PUT":"GET",w="AWS4-HMAC-SHA256",M=`${Q}/${this.region}/s3/aws4_request`,F={"X-Amz-Algorithm":"AWS4-HMAC-SHA256","X-Amz-Credential":`${Y}/${M}`,"X-Amz-Date":Z,"X-Amz-Expires":C.toString(),"X-Amz-SignedHeaders":"host"};if(G)F["X-Amz-Security-Token"]=G;let I=Object.keys(F).sort().map((S)=>`${encodeURIComponent(S)}=${encodeURIComponent(F[S])}`).join("&"),z=W.split("/").map((S)=>encodeURIComponent(S)).join("/"),P=this.objectPath(E,z),K=`host:${N}
84
+ `,O=[L,P,I,K,"host","UNSIGNED-PAYLOAD"].join(`
85
+ `),j=["AWS4-HMAC-SHA256",Z,M,J.createHash("sha256").update(O).digest("hex")].join(`
86
+ `),T=J.createHmac("sha256",`AWS4${$}`).update(Q).digest(),R=J.createHmac("sha256",T).update(this.region).digest(),D=J.createHmac("sha256",R).update("s3").digest(),B=J.createHmac("sha256",D).update("aws4_request").digest(),q=J.createHmac("sha256",B).update(j).digest("hex");return`${this.endpointProtocol}://${N}${P}?${I}&X-Amz-Signature=${q}`}async listObjects(_){let{bucket:E,prefix:W,maxKeys:C=1000,continuationToken:A}=_,Y={"list-type":"2","max-keys":C.toString()};if(W)Y.prefix=W;if(A)Y["continuation-token"]=A;let $=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${E}`,queryParams:Y}),G=[],V=$?.ListBucketResult??$;if(V?.Contents){let Z=Array.isArray(V.Contents)?V.Contents:[V.Contents];for(let Q of Z)G.push({Key:Q.Key||"",LastModified:Q.LastModified||"",Size:Number.parseInt(Q.Size||"0"),ETag:Q.ETag})}return{objects:G,nextContinuationToken:V?.NextContinuationToken}}async emptyBucket(_){let E=0,W=await this.listAllObjects({bucket:_});if(W.length>0)for(let C=0;C<W.length;C+=1000){let Y=W.slice(C,C+1000).map(($)=>$.Key);await this.deleteObjects(_,Y),E+=Y.length}try{let C,A;do{let Y=await this.listObjectVersions({bucket:_,keyMarker:C,versionIdMarker:A,maxKeys:1000}),$=[];if(Y.versions)for(let G of Y.versions)$.push({Key:G.Key,VersionId:G.VersionId});if(Y.deleteMarkers)for(let G of Y.deleteMarkers)$.push({Key:G.Key,VersionId:G.VersionId});if($.length>0)await this.deleteObjectVersions(_,$),E+=$.length;C=Y.nextKeyMarker,A=Y.nextVersionIdMarker}while(C)}catch{}return{deletedCount:E}}async listObjectVersions(_){let{bucket:E,prefix:W,keyMarker:C,versionIdMarker:A,maxKeys:Y=1000}=_,$={versions:"","max-keys":Y.toString()};if(W)$.prefix=W;if(C)$["key-marker"]=C;if(A)$["version-id-marker"]=A;let G=await this.client.request({service:"s3",region:this.region,method:"GET",path:`/${E}`,queryParams:$}),V=[],Z=[];if(G.Version){let Q=Array.isArray(G.Version)?G.Version:[G.Version];for(let N of Q)V.push({Key:N.Key,VersionId:N.VersionId,IsLatest:N.IsLatest==="true"})}if(G.DeleteMarker){let Q=Array.isArray(G.DeleteMarker)?G.DeleteMarker:[G.DeleteMarker];for(let N of Q)Z.push({Key:N.Key,VersionId:N.VersionId,IsLatest:N.IsLatest==="true"})}return{versions:V,deleteMarkers:Z,nextKeyMarker:G.NextKeyMarker,nextVersionIdMarker:G.NextVersionIdMarker}}async deleteObjectVersions(_,E){let W=`<?xml version="1.0" encoding="UTF-8"?>
87
+ <Delete>
88
+ <Quiet>true</Quiet>
89
+ ${E.map((A)=>`<Object><Key>${A.Key}</Key>${A.VersionId?`<VersionId>${A.VersionId}</VersionId>`:""}</Object>`).join(`
90
+ `)}
91
+ </Delete>`,C=J.createHash("md5").update(W).digest("base64");await this.client.request({service:"s3",region:this.region,method:"POST",path:`/${_}`,queryParams:{delete:""},body:W,headers:{"Content-Type":"application/xml","Content-MD5":C}})}}
92
+ export{f as _f,l as $f};
@@ -0,0 +1 @@
1
+ import{Ua as a}from"./chunk-38pq971s.js";import"./chunk-mh0kdzqp.js";export{a as encodeDashboardPayload};
@@ -0,0 +1,141 @@
1
+ import{Og as A}from"./chunk-fpm59y25.js";class N{client;constructor(J,Q){this.client=Q??new A(void 0,{profile:J})}collectionItems(J,Q){let z=J?.Items??J?.[Q];if(!z)return[];if(Array.isArray(z))return z;let Y=z[Q]??z.Item;if(Y===void 0)return typeof z==="object"&&(z.Id||z.PathPattern)?[z]:[];return Array.isArray(Y)?Y:[Y]}validateExistingOriginInput(J,Q){if(!/^[A-Z0-9]{8,32}$/.test(J))throw Error("CloudFront distribution ID is invalid");if(!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(Q.id))throw Error("CloudFront origin ID is invalid");if(!/^(?=.{1,253}$)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\.)+[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?$/.test(Q.domainName))throw Error("CloudFront origin must be a hostname without a scheme or path");let z=Q.pathPattern.startsWith("/")?Q.pathPattern:`/${Q.pathPattern}`;if(z==="/"||z==="/*"||!/^\/[A-Za-z0-9_.*?~!$&'()+,;=:@%/-]{1,255}$/.test(z))throw Error("CloudFront path pattern must be a non-default absolute pattern");if(Q.originPath&&(!Q.originPath.startsWith("/")||Q.originPath.includes("..")))throw Error("CloudFront origin path must be absolute and traversal-free");if(Object.entries(Q.customHeaders??{}).some(([Y,_])=>!/^[A-Za-z0-9-]{1,64}$/.test(Y)||!_||_.length>1024))throw Error("CloudFront custom origin headers are invalid");return{...Q,pathPattern:z}}async upsertExistingDistributionOrigin(J,Q){let z=this.validateExistingOriginInput(J,Q),Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),_=Y.headers?.etag||Y.headers?.ETag||Y.ETag||"",Z=Y.body?.DistributionConfig||Y.DistributionConfig||Y.body;if(!Z||Z.Enabled===void 0||!_)throw Error("Failed to read an ETag-protected CloudFront distribution config");let $=this.collectionItems(Z.Origins,"Origin"),j=this.collectionItems(Z.CacheBehaviors,"CacheBehavior"),L=$.find((H)=>String(H.Id)===z.id),q=j.find((H)=>String(H.PathPattern)===z.pathPattern);if(L&&String(L.DomainName)!==z.domainName&&!z.replaceExisting)throw Error(`Origin ${z.id} already targets ${L.DomainName}; pass replaceExisting only after reviewing the live config`);if(q&&String(q.TargetOriginId)!==z.id&&!z.replaceExisting)throw Error(`Path ${z.pathPattern} already targets ${q.TargetOriginId}; pass replaceExisting only after reviewing the live config`);let W={Id:z.id,DomainName:z.domainName,OriginPath:z.originPath??"",CustomHeaders:{Quantity:Object.keys(z.customHeaders??{}).length,...Object.keys(z.customHeaders??{}).length?{Items:{OriginCustomHeader:Object.entries(z.customHeaders).map(([H,K])=>({HeaderName:H,HeaderValue:K}))}}:{}},CustomOriginConfig:{HTTPPort:80,HTTPSPort:443,OriginProtocolPolicy:z.protocolPolicy??"https-only",OriginSslProtocols:{Quantity:1,Items:{SslProtocol:["TLSv1.2"]}},OriginReadTimeout:30,OriginKeepaliveTimeout:5},ConnectionAttempts:3,ConnectionTimeout:10,...z.originAccessControlId?{OriginAccessControlId:z.originAccessControlId}:{}},F=["GET","HEAD","OPTIONS","PUT","POST","PATCH","DELETE"],D={PathPattern:z.pathPattern,TargetOriginId:z.id,ViewerProtocolPolicy:"redirect-to-https",Compress:!0,CachePolicyId:"4135ea2d-6df8-44a3-9df3-4b5a84be39ad",OriginRequestPolicyId:"b689b0a8-53d0-40ab-baf2-68738e2966ac",AllowedMethods:{Quantity:F.length,Items:{Method:F},CachedMethods:{Quantity:2,Items:{Method:["GET","HEAD"]}}},SmoothStreaming:!1,FieldLevelEncryptionId:"",TrustedSigners:{Enabled:!1,Quantity:0},TrustedKeyGroups:{Enabled:!1,Quantity:0},LambdaFunctionAssociations:{Quantity:0},FunctionAssociations:{Quantity:0}},G=L?$.map((H)=>String(H.Id)===z.id?W:H):[...$,W],S=q?j.map((H)=>String(H.PathPattern)===z.pathPattern?D:H):[...j,D],U=JSON.stringify($)!==JSON.stringify(G)||JSON.stringify(j)!==JSON.stringify(S);if(!U||z.dryRun)return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:U,applied:!1,etag:_};Z.Origins={Quantity:G.length,Items:{Origin:G}},Z.CacheBehaviors={Quantity:S.length,...S.length?{Items:{CacheBehavior:S}}:{}};let M=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:this.buildDistributionConfigXml(Z),headers:{"Content-Type":"application/xml","If-Match":_}});return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!0,applied:!0,etag:M.ETag||M.headers?.etag||""}}async removeExistingDistributionOrigin(J,Q){let z=this.validateExistingOriginInput(J,Q),Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),_=Y.headers?.etag||Y.headers?.ETag||Y.ETag||"",Z=Y.body?.DistributionConfig||Y.DistributionConfig||Y.body;if(!Z||Z.Enabled===void 0||!_)throw Error("Failed to read an ETag-protected CloudFront distribution config");let $=this.collectionItems(Z.Origins,"Origin"),j=this.collectionItems(Z.CacheBehaviors,"CacheBehavior"),L=$.find((S)=>String(S.Id)===z.id),q=j.find((S)=>String(S.PathPattern)===z.pathPattern);if(L&&String(L.DomainName)!==z.domainName)throw Error(`Origin ${z.id} no longer targets ${z.domainName}; refusing ambiguous removal`);if(q&&String(q.TargetOriginId)!==z.id)throw Error(`Path ${z.pathPattern} no longer targets ${z.id}; refusing ambiguous removal`);if(!q)return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!1,applied:!1,originRemoved:!1,etag:_};let W=j.filter((S)=>String(S.PathPattern)!==z.pathPattern),F=String(Z.DefaultCacheBehavior?.TargetOriginId)===z.id||W.some((S)=>String(S.TargetOriginId)===z.id),D=F?$:$.filter((S)=>String(S.Id)!==z.id);if(z.dryRun)return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!0,applied:!1,originRemoved:!F&&!!L,etag:_};Z.Origins={Quantity:D.length,Items:{Origin:D}},Z.CacheBehaviors={Quantity:W.length,...W.length?{Items:{CacheBehavior:W}}:{}};let G=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:this.buildDistributionConfigXml(Z),headers:{"Content-Type":"application/xml","If-Match":_}});return{distributionId:J,originId:z.id,domainName:z.domainName,pathPattern:z.pathPattern,changed:!0,applied:!0,originRemoved:!F&&!!L,etag:G.ETag||G.headers?.etag||""}}async createInvalidation(J){let Q=J.callerReference||Date.now().toString(),z=`<?xml version="1.0" encoding="UTF-8"?>
2
+ <InvalidationBatch>
3
+ <Paths>
4
+ <Quantity>${J.paths.length}</Quantity>
5
+ <Items>
6
+ ${J.paths.map((_)=>`<Path>${_}</Path>`).join(`
7
+ `)}
8
+ </Items>
9
+ </Paths>
10
+ <CallerReference>${Q}</CallerReference>
11
+ </InvalidationBatch>`,Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:`/2020-05-31/distribution/${J.distributionId}/invalidation`,body:z,headers:{"Content-Type":"application/xml"}});return{Id:Y.Id||Y.Invalidation?.Id,Status:Y.Status||Y.Invalidation?.Status||"InProgress",CreateTime:Y.CreateTime||Y.Invalidation?.CreateTime||new Date().toISOString()}}async getInvalidation(J,Q){let z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/invalidation/${Q}`});return{Id:z.Id||z.Invalidation?.Id,Status:z.Status||z.Invalidation?.Status,CreateTime:z.CreateTime||z.Invalidation?.CreateTime}}async listInvalidations(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/invalidation`}),z=[];if(Q.InvalidationSummary){let Y=Array.isArray(Q.InvalidationSummary)?Q.InvalidationSummary:[Q.InvalidationSummary];z.push(...Y.map((_)=>({Id:_.Id,Status:_.Status,CreateTime:_.CreateTime})))}return z}async waitForInvalidation(J,Q){let Y=0;while(Y<60){if((await this.getInvalidation(J,Q)).Status==="Completed")return;await new Promise((Z)=>setTimeout(Z,5000)),Y++}throw Error(`Timeout waiting for invalidation ${Q} to complete`)}async listDistributions(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/distribution"}),Q=[],Y=(J.DistributionList||J).Items,_=[];if(Array.isArray(Y))_=Y;else if(Y?.DistributionSummary)_=Array.isArray(Y.DistributionSummary)?Y.DistributionSummary:[Y.DistributionSummary];return Q.push(..._.map((Z)=>({Id:Z.Id,ARN:Z.ARN,Status:Z.Status,DomainName:Z.DomainName,Aliases:Z.Aliases||void 0,Enabled:Z.Enabled==="true"||Z.Enabled===!0}))),Q}async getDistribution(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}`}),z=Q.Distribution||Q;return{Id:z.Id,ARN:z.ARN,Status:z.Status,DomainName:z.DomainName,Aliases:z.DistributionConfig?.Aliases?.Items||z.Aliases?.Items||[],Enabled:z.DistributionConfig?.Enabled==="true"||z.DistributionConfig?.Enabled===!0}}async getDistributionConfig(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`});return{ETag:Q.ETag||"",DistributionConfig:Q.DistributionConfig||Q}}async invalidateAll(J){return this.createInvalidation({distributionId:J,paths:["/*"]})}async invalidatePaths(J,Q){let z=Q.map((Y)=>Y.startsWith("/")?Y:`/${Y}`);return this.createInvalidation({distributionId:J,paths:z})}async invalidatePattern(J,Q){let z=Q.startsWith("/")?Q:`/${Q}`;return this.createInvalidation({distributionId:J,paths:[z]})}async invalidateAfterDeployment(J){let{distributionId:Q,changedPaths:z,invalidateAll:Y=!1,wait:_=!1}=J,Z;if(Y||!z||z.length===0)Z=await this.invalidateAll(Q);else Z=await this.invalidatePaths(Q,z);if(_)await this.waitForInvalidation(Q,Z.Id);return{invalidationId:Z.Id,status:Z.Status}}async findDistributionByDomain(J){return(await this.listDistributions()).find((Y)=>{if(Y.DomainName===J)return!0;if(Y.Aliases?.Items&&Y.Aliases.Items.includes(J))return!0;return!1})||null}async batchInvalidate(J,Q=["/*"]){return await Promise.all(J.map(async(Y)=>{let _=await this.createInvalidation({distributionId:Y,paths:Q});return{distributionId:Y,invalidationId:_.Id,status:_.Status}}))}async updateCustomErrorResponses(J){let{distributionId:Q,customErrorResponses:z}=J,Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${Q}/config`,returnHeaders:!0}),_=Y.headers?.etag||Y.headers?.ETag||"",Z=Y.body?.DistributionConfig||(Y.body?.Enabled!==void 0?Y.body:void 0)||Y.DistributionConfig;if(!Z||Z.Enabled===void 0)throw Error("Failed to get current distribution config");if(z.length===0)Z.CustomErrorResponses={Quantity:0};else Z.CustomErrorResponses={Quantity:z.length,Items:{CustomErrorResponse:z.map((q)=>({ErrorCode:q.errorCode,...q.responsePagePath&&{ResponsePagePath:q.responsePagePath},...q.responseCode&&{ResponseCode:q.responseCode},...q.errorCachingMinTTL!==void 0&&{ErrorCachingMinTTL:q.errorCachingMinTTL}}))}};let $=this.buildDistributionConfigXml(Z),j=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${Q}/config`,body:$,headers:{"Content-Type":"application/xml","If-Match":_}}),L=j.Distribution||j;return{Distribution:{Id:L.Id,ARN:L.ARN,Status:L.Status,DomainName:L.DomainName,Aliases:L.DistributionConfig?.Aliases?.Items||[],Enabled:L.DistributionConfig?.Enabled==="true"||L.DistributionConfig?.Enabled===!0},ETag:j.ETag||""}}async removeCustomErrorResponses(J){return this.updateCustomErrorResponses({distributionId:J,customErrorResponses:[]})}async updateDistribution(J){let{distributionId:Q,aliases:z,certificateArn:Y,comment:_}=J,Z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${Q}/config`,returnHeaders:!0}),$=Z.headers?.etag||Z.headers?.ETag||"",j=Z.body?.DistributionConfig||(Z.body?.Enabled!==void 0?Z.body:void 0)||Z.DistributionConfig;if(!j||j.Enabled===void 0)throw Error("Failed to get current distribution config");if(z&&z.length>0)j.Aliases={Quantity:z.length,Items:{Item:z}};if(Y)j.ViewerCertificate={ACMCertificateArn:Y,SSLSupportMethod:"sni-only",MinimumProtocolVersion:"TLSv1.2_2021",CertificateSource:"acm"};if(_)j.Comment=_;let L=this.buildDistributionConfigXml(j),q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${Q}/config`,body:L,headers:{"Content-Type":"application/xml","If-Match":$}}),W=q.Distribution||q;return{Distribution:{Id:W.Id,ARN:W.ARN,Status:W.Status,DomainName:W.DomainName,Aliases:z?{Quantity:z.length,Items:z}:{Quantity:0,Items:[]},Enabled:W.DistributionConfig?.Enabled==="true"||W.DistributionConfig?.Enabled===!0},ETag:q.ETag||""}}buildDistributionConfigXml(J){let Q=(Z)=>{return Z.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")},z={Items:"",Methods:"Method",Headers:"Name",Cookies:"Name",QueryStringCacheKeys:"Name",TrustedKeyGroups:"KeyGroup",TrustedSigners:"AwsAccountNumber",LambdaFunctionAssociations:"LambdaFunctionAssociation",FunctionAssociations:"FunctionAssociation",CacheBehaviors:"CacheBehavior",CustomErrorResponses:"CustomErrorResponse",GeoRestriction:"Location"},Y={Origins:"Origin",Aliases:"CNAME",AllowedMethods:"Method",CachedMethods:"Method",CustomErrorResponses:"CustomErrorResponse",CacheBehaviors:"CacheBehavior"},_=(Z,$,j="",L="")=>{if($===null||$===void 0)return"";if(Z.startsWith("@_")||Z==="?xml")return"";if(typeof $==="boolean")return`${j}<${Z}>${$}</${Z}>
12
+ `;if(typeof $==="number"||typeof $==="string")return`${j}<${Z}>${Q(String($))}</${Z}>
13
+ `;if(Array.isArray($)){let q=z[Z]||Z.replace(/s$/,"");return $.map((W)=>_(q,W,j,Z)).join("")}if(typeof $==="object"){if(Z==="Items"){let W=Y[L]||"",F=Object.keys($).filter((D)=>!D.startsWith("@_"));if(F.length===1&&!Array.isArray($[F[0]])){let D=F[0],G=$[D];if(typeof G==="string")return`${j}<Items>
14
+ ${j} <${D}>${Q(G)}</${D}>
15
+ ${j}</Items>
16
+ `;else if(typeof G==="object"&&!Array.isArray(G))return`${j}<Items>
17
+ ${_(D,G,j+" ",Z)}${j}</Items>
18
+ `}if(F.length===1&&Array.isArray($[F[0]])){let D=F[0],G=$[D],S="";for(let U of G)if(typeof U==="string")S+=`${j} <${D}>${Q(U)}</${D}>
19
+ `;else S+=_(D,U,j+" ",Z);return`${j}<Items>
20
+ ${S}${j}</Items>
21
+ `}if(Array.isArray($)){let D="",G=W||"Item";for(let S of $)if(typeof S==="string")D+=`${j} <${G}>${Q(S)}</${G}>
22
+ `;else D+=_(G,S,j+" ",Z);return`${j}<Items>
23
+ ${D}${j}</Items>
24
+ `}}let q="";for(let[W,F]of Object.entries($))if(!W.startsWith("@_"))q+=_(W,F,j+" ",Z);if(q==="")return`${j}<${Z}/>
25
+ `;return`${j}<${Z}>
26
+ ${q}${j}</${Z}>
27
+ `}return""};return`<?xml version="1.0" encoding="UTF-8"?>
28
+ <DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
29
+ ${Object.entries(J).filter(([Z])=>!Z.startsWith("@_")).map(([Z,$])=>_(Z,$," ","DistributionConfig")).join("")}</DistributionConfig>`}async ensureDynamicHttpMethods(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),z=Q.headers?.etag||Q.headers?.ETag||"",Y=Q.body?.DistributionConfig||Q.DistributionConfig||Q.body;if(!Y)throw Error("Failed to get current distribution config");let _=!1,Z=["GET","HEAD","OPTIONS","PUT","POST","PATCH","DELETE"],$=(q)=>{if(!q)return[];let W=q.Items;if(!W)return[];if(Array.isArray(W))return W.map(String);if(typeof W==="object"&&W.Method){let F=W.Method;return Array.isArray(F)?F.map(String):[String(F)]}if(W.Item)return Array.isArray(W.Item)?W.Item.map(String):[String(W.Item)];return[]},j=Y.DefaultCacheBehavior;if(j){if(!$(j.AllowedMethods).includes("POST"))j.AllowedMethods={Quantity:Z.length,Items:{Method:Z},CachedMethods:{Quantity:2,Items:{Method:["GET","HEAD"]}}},_=!0}if(!_)return!1;let L=this.buildDistributionConfigXml(Y);return await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:L,headers:{"Content-Type":"application/xml","If-Match":z}}),!0}async addAliases(J,Q,z){return this.updateDistribution({distributionId:J,aliases:Q,certificateArn:z})}async createFunction(J){let{name:Q,code:z,comment:Y="",runtime:_="cloudfront-js-2.0"}=J,Z=`<?xml version="1.0" encoding="UTF-8"?>
30
+ <CreateFunctionRequest xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
31
+ <Name>${Q}</Name>
32
+ <FunctionConfig>
33
+ <Comment>${Y}</Comment>
34
+ <Runtime>${_}</Runtime>
35
+ </FunctionConfig>
36
+ <FunctionCode>${Buffer.from(z).toString("base64")}</FunctionCode>
37
+ </CreateFunctionRequest>`,$=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/function",body:Z,headers:{"Content-Type":"application/xml"}}),j=$.FunctionSummary||$;return{FunctionARN:j.FunctionMetadata?.FunctionARN||j.FunctionARN,Name:j.Name||Q,Stage:j.FunctionMetadata?.Stage||"DEVELOPMENT",ETag:$.ETag||""}}async listFunctions(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/function"}),Q=[],z=J.FunctionList?.Items?.FunctionSummary;if(z){let Y=Array.isArray(z)?z:[z];for(let _ of Y)Q.push({Name:_.Name,FunctionARN:_.FunctionMetadata?.FunctionARN,Stage:_.FunctionMetadata?.Stage,CreatedTime:_.FunctionMetadata?.CreatedTime,LastModifiedTime:_.FunctionMetadata?.LastModifiedTime})}return Q}async getFunction(J,Q="LIVE"){try{let z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/function/${J}`,queryParams:{Stage:Q},returnHeaders:!0}),Y=z.body?.FunctionSummary||z.FunctionSummary||z.body||z;return{FunctionARN:Y.FunctionMetadata?.FunctionARN,Name:Y.Name||J,Stage:Y.FunctionMetadata?.Stage||Q,ETag:z.headers?.etag||z.ETag||"",FunctionCode:Y.FunctionCode}}catch(z){if(z.message?.includes("404")||z.message?.includes("NoSuchFunctionExists"))return null;throw z}}async publishFunction(J,Q){let z,Y;if(typeof J==="object")z=J.Name,Y=J.IfMatch;else z=J,Y=Q;if(!Y){let $=await this.getFunction(z,"DEVELOPMENT");if(!$)throw Error(`Function ${z} not found`);Y=$.ETag}let _=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:`/2020-05-31/function/${z}/publish`,headers:{"If-Match":Y}}),Z=_.FunctionSummary||_;return{FunctionARN:Z.FunctionMetadata?.FunctionARN,Stage:Z.FunctionMetadata?.Stage||"LIVE",FunctionSummary:Z}}async describeFunction(J){let{Name:Q,Stage:z="DEVELOPMENT"}=J,Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/function/${Q}/describe`,queryParams:{Stage:z},returnHeaders:!0});return{ETag:Y.headers?.etag||Y.ETag||"",FunctionSummary:Y.body?.FunctionSummary||Y.FunctionSummary||Y.body||Y}}async updateFunction(J){let{Name:Q,FunctionCode:z,FunctionConfig:Y,IfMatch:_}=J,Z=`<?xml version="1.0" encoding="UTF-8"?>
38
+ <UpdateFunctionRequest xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
39
+ <FunctionConfig>
40
+ <Comment>${Y.Comment}</Comment>
41
+ <Runtime>${Y.Runtime}</Runtime>
42
+ </FunctionConfig>
43
+ <FunctionCode>${Buffer.from(z).toString("base64")}</FunctionCode>
44
+ </UpdateFunctionRequest>`,$=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/function/${Q}`,body:Z,headers:{"Content-Type":"application/xml","If-Match":_},returnHeaders:!0});return{ETag:$.headers?.etag||$.ETag||"",FunctionSummary:$.body?.FunctionSummary||$.FunctionSummary||$.body||$}}async deleteFunction(J,Q){let z=Q;if(!z){let Y=await this.getFunction(J,"DEVELOPMENT");if(!Y)return;z=Y.ETag}await this.client.request({service:"cloudfront",region:"us-east-1",method:"DELETE",path:`/2020-05-31/function/${J}`,headers:{"If-Match":z}})}async createIndexRewriteFunction(J){return this.createFunction({name:J,code:`function handler(event) {
45
+ const request = event.request;
46
+ var uri = request.uri;
47
+
48
+ // Check if the request is for a directory (ends with /)
49
+ if (uri.endsWith('/')) {
50
+ request.uri += 'index.html';
51
+ }
52
+ // Check if the request doesn't have a file extension
53
+ else if (!uri.includes('.')) {
54
+ // Add trailing slash to redirect to directory
55
+ request.uri += '/index.html';
56
+ }
57
+
58
+ return request;
59
+ }`,comment:"Rewrite directory requests to index.html for S3 static sites",runtime:"cloudfront-js-2.0"})}async listOriginAccessControls(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/origin-access-control"}),Q=[];if(J.OriginAccessControlList?.Items?.OriginAccessControlSummary){let z=Array.isArray(J.OriginAccessControlList.Items.OriginAccessControlSummary)?J.OriginAccessControlList.Items.OriginAccessControlSummary:[J.OriginAccessControlList.Items.OriginAccessControlSummary];Q.push(...z.map((Y)=>({Id:Y.Id,Name:Y.Name,Description:Y.Description,SigningProtocol:Y.SigningProtocol,SigningBehavior:Y.SigningBehavior,OriginAccessControlOriginType:Y.OriginAccessControlOriginType})))}return Q}async createOriginAccessControl(J){let{name:Q,description:z=`OAC for ${Q}`,signingProtocol:Y="sigv4",signingBehavior:_="always",originType:Z="s3"}=J,$=`<?xml version="1.0" encoding="UTF-8"?>
60
+ <OriginAccessControlConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
61
+ <Name>${Q}</Name>
62
+ <Description>${z}</Description>
63
+ <SigningProtocol>${Y}</SigningProtocol>
64
+ <SigningBehavior>${_}</SigningBehavior>
65
+ <OriginAccessControlOriginType>${Z}</OriginAccessControlOriginType>
66
+ </OriginAccessControlConfig>`,j=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/origin-access-control",body:$,headers:{"Content-Type":"application/xml"},returnHeaders:!0}),L=j.body?.OriginAccessControl||j.OriginAccessControl||j.body||j;return{Id:L.Id,Name:L.OriginAccessControlConfig?.Name||Q,Description:L.OriginAccessControlConfig?.Description||z,SigningProtocol:L.OriginAccessControlConfig?.SigningProtocol||Y,SigningBehavior:L.OriginAccessControlConfig?.SigningBehavior||_,OriginAccessControlOriginType:L.OriginAccessControlConfig?.OriginAccessControlOriginType||Z,ETag:j.headers?.etag||j.ETag||""}}async findOrCreateOriginAccessControl(J,Q="s3"){let Y=(await this.listOriginAccessControls()).find((Z)=>Z.Name===J&&Z.OriginAccessControlOriginType===Q);if(Y)return{Id:Y.Id,Name:Y.Name,isNew:!1};let _=await this.createOriginAccessControl({name:J,originType:Q});return{Id:_.Id,Name:_.Name,isNew:!0}}async createDistributionForS3(J){let{bucketName:Q,bucketRegion:z,originAccessControlId:Y,aliases:_=[],certificateArn:Z,defaultRootObject:$="index.html",comment:j=`Distribution for ${Q}`,priceClass:L="PriceClass_100",enabled:q=!0,trustedKeyGroupIds:W=[],mediaDelivery:F=!1}=J,D=`S3-${Q}`,G=`${Q}.s3.${z}.amazonaws.com`,S=`${Date.now()}-${Math.random().toString(36).slice(2)}`,U=W.length>0?`<TrustedKeyGroups>
67
+ <Enabled>true</Enabled>
68
+ <Quantity>${W.length}</Quantity>
69
+ <Items>${W.map((w)=>`<KeyGroup>${w}</KeyGroup>`).join("")}</Items>
70
+ </TrustedKeyGroups>`:"<TrustedKeyGroups><Enabled>false</Enabled><Quantity>0</Quantity></TrustedKeyGroups>",M="<Aliases><Quantity>0</Quantity></Aliases>";if(_.length>0)M=`<Aliases>
71
+ <Quantity>${_.length}</Quantity>
72
+ <Items>
73
+ ${_.map((w)=>`<CNAME>${w}</CNAME>`).join(`
74
+ `)}
75
+ </Items>
76
+ </Aliases>`;let H=`<ViewerCertificate>
77
+ <CloudFrontDefaultCertificate>true</CloudFrontDefaultCertificate>
78
+ </ViewerCertificate>`;if(Z&&_.length>0)H=`<ViewerCertificate>
79
+ <ACMCertificateArn>${Z}</ACMCertificateArn>
80
+ <SSLSupportMethod>sni-only</SSLSupportMethod>
81
+ <MinimumProtocolVersion>TLSv1.2_2021</MinimumProtocolVersion>
82
+ <CertificateSource>acm</CertificateSource>
83
+ </ViewerCertificate>`;let K=`<?xml version="1.0" encoding="UTF-8"?>
84
+ <DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
85
+ <CallerReference>${S}</CallerReference>
86
+ <Comment>${j}</Comment>
87
+ <DefaultRootObject>${$}</DefaultRootObject>
88
+ <Origins>
89
+ <Quantity>1</Quantity>
90
+ <Items>
91
+ <Origin>
92
+ <Id>${D}</Id>
93
+ <DomainName>${G}</DomainName>
94
+ <OriginPath></OriginPath>
95
+ <S3OriginConfig>
96
+ <OriginAccessIdentity></OriginAccessIdentity>
97
+ </S3OriginConfig>
98
+ <OriginAccessControlId>${Y}</OriginAccessControlId>
99
+ </Origin>
100
+ </Items>
101
+ </Origins>
102
+ <DefaultCacheBehavior>
103
+ <TargetOriginId>${D}</TargetOriginId>
104
+ <ViewerProtocolPolicy>redirect-to-https</ViewerProtocolPolicy>
105
+ <AllowedMethods>
106
+ <Quantity>2</Quantity>
107
+ <Items>
108
+ <Method>GET</Method>
109
+ <Method>HEAD</Method>
110
+ </Items>
111
+ <CachedMethods>
112
+ <Quantity>2</Quantity>
113
+ <Items>
114
+ <Method>GET</Method>
115
+ <Method>HEAD</Method>
116
+ </Items>
117
+ </CachedMethods>
118
+ </AllowedMethods>
119
+ <Compress>true</Compress>
120
+ <CachePolicyId>658327ea-f89d-4fab-a63d-7e88639e58f6</CachePolicyId>
121
+ ${U}
122
+ </DefaultCacheBehavior>
123
+ ${M}
124
+ ${H}
125
+ <PriceClass>${L}</PriceClass>
126
+ <Enabled>${q}</Enabled>
127
+ <HttpVersion>http2and3</HttpVersion>
128
+ <IsIPV6Enabled>true</IsIPV6Enabled>
129
+ ${F?"<CustomErrorResponses><Quantity>0</Quantity></CustomErrorResponses>":`<CustomErrorResponses>
130
+ <Quantity>1</Quantity>
131
+ <Items>
132
+ <CustomErrorResponse>
133
+ <ErrorCode>403</ErrorCode>
134
+ <ResponsePagePath>/index.html</ResponsePagePath>
135
+ <ResponseCode>200</ResponseCode>
136
+ <ErrorCachingMinTTL>300</ErrorCachingMinTTL>
137
+ </CustomErrorResponse>
138
+ </Items>
139
+ </CustomErrorResponses>`}
140
+ </DistributionConfig>`,V=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/distribution",body:K,headers:{"Content-Type":"application/xml"},returnHeaders:!0}),P=V.body?.Distribution||V.Distribution||V.body||V;return{Id:P.Id,ARN:P.ARN,DomainName:P.DomainName,Status:P.Status,ETag:V.headers?.etag||V.ETag||""}}async createMediaDistributionForS3(J){return this.createDistributionForS3({...J,defaultRootObject:"",mediaDelivery:!0,comment:J.comment??`Media distribution for ${J.bucketName}`})}async listPublicKeys(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/public-key"});return this.collectionItems(J.PublicKeyList??J,"PublicKeySummary").map((z)=>({Id:String(z.Id),Name:String(z.Name),Comment:z.Comment?String(z.Comment):void 0}))}async createPublicKey(J){if(!/^[A-Za-z0-9_-]{1,128}$/.test(J.name))throw TypeError("CloudFront public key name is invalid");if(!J.encodedKey.includes("BEGIN PUBLIC KEY"))throw TypeError("CloudFront public key must be PEM encoded");let Q=(_)=>_.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/public-key",headers:{"Content-Type":"application/xml"},body:`<PublicKeyConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><CallerReference>${Q(J.callerReference??`${Date.now()}-${J.name}`)}</CallerReference><Name>${Q(J.name)}</Name><EncodedKey>${Q(J.encodedKey)}</EncodedKey><Comment>${Q(J.comment??"")}</Comment></PublicKeyConfig>`}),Y=z.PublicKey??z;return{Id:String(Y.Id),Name:String(Y.PublicKeyConfig?.Name??J.name),EncodedKey:String(Y.PublicKeyConfig?.EncodedKey??J.encodedKey),Comment:String(Y.PublicKeyConfig?.Comment??J.comment??"")}}async listKeyGroups(){let J=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:"/2020-05-31/key-group"});return this.collectionItems(J.KeyGroupList??J,"KeyGroupSummary").map((z)=>({Id:String(z.KeyGroup?.Id??z.Id),Name:String(z.KeyGroup?.KeyGroupConfig?.Name??z.KeyGroupConfig?.Name??z.Name),Items:this.collectionItems(z.KeyGroup?.KeyGroupConfig?.Items??z.KeyGroupConfig?.Items??z.Items,"Item").map(String),Comment:z.KeyGroup?.KeyGroupConfig?.Comment??z.KeyGroupConfig?.Comment??z.Comment}))}async createKeyGroup(J){if(!/^[A-Za-z0-9_-]{1,128}$/.test(J.name))throw TypeError("CloudFront key group name is invalid");let Q=[...new Set(J.publicKeyIds)];if(Q.length===0)throw TypeError("CloudFront key group requires at least one public key");let z=($)=>$.replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;"),Y=Q.map(($)=>`<Item>${z($)}</Item>`).join(""),_=await this.client.request({service:"cloudfront",region:"us-east-1",method:"POST",path:"/2020-05-31/key-group",headers:{"Content-Type":"application/xml"},body:`<KeyGroupConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/"><Name>${z(J.name)}</Name><Items>${Y}</Items><Comment>${z(J.comment??"")}</Comment></KeyGroupConfig>`}),Z=_.KeyGroup??_;return{Id:String(Z.Id),Name:String(Z.KeyGroupConfig?.Name??J.name),Items:Q,Comment:String(Z.KeyGroupConfig?.Comment??J.comment??"")}}static getS3BucketPolicyForCloudFront(J,Q){return{Version:"2012-10-17",Statement:[{Sid:"AllowCloudFrontServicePrincipal",Effect:"Allow",Principal:{Service:"cloudfront.amazonaws.com"},Action:"s3:GetObject",Resource:`arn:aws:s3:::${J}/*`,Condition:{StringEquals:{"AWS:SourceArn":Q}}}]}}async waitForDistributionDeployed(J,Q=60){for(let z=0;z<Q;z++){if((await this.getDistribution(J)).Status==="Deployed")return!0;await new Promise((_)=>setTimeout(_,30000))}return!1}async disableDistribution(J){let Q=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),z=Q.headers?.etag||Q.headers?.ETag||"",Y=Q.body?.DistributionConfig||(Q.body?.Enabled!==void 0?Q.body:void 0)||Q.DistributionConfig;if(!Y||Y.Enabled===void 0)throw Error("Failed to get current distribution config");Y.Enabled=!1;let _=this.buildDistributionConfigXml(Y),Z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:_,headers:{"Content-Type":"application/xml","If-Match":z},returnHeaders:!0});return{ETag:Z.headers?.etag||Z.headers?.ETag||Z.ETag||""}}async deleteDistribution(J,Q){let z=Q||"";if(!z){let Y=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}`,returnHeaders:!0});z=Y.headers?.etag||Y.headers?.ETag||""}await this.client.request({service:"cloudfront",region:"us-east-1",method:"DELETE",path:`/2020-05-31/distribution/${J}`,headers:{"If-Match":z}})}async waitForDistributionDisabled(J,Q=60){for(let z=0;z<Q;z++){let Y=await this.getDistribution(J);if(Y.Status==="Deployed"&&!Y.Enabled)return!0;await new Promise((_)=>setTimeout(_,30000))}return!1}async removeAlias(J,Q){let z=await this.client.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${J}/config`,returnHeaders:!0}),Y=z.headers?.etag||z.headers?.ETag||"",_=z.body?.DistributionConfig||(z.body?.Enabled!==void 0?z.body:void 0)||z.DistributionConfig;if(!_||_.Enabled===void 0)throw Error("Failed to get current distribution config");let Z=[];if(_.Aliases?.Items){if(Array.isArray(_.Aliases.Items))Z=_.Aliases.Items;else if(typeof _.Aliases.Items==="object"){let q=_.Aliases.Items.CNAME;if(typeof q==="string")Z=[q];else if(Array.isArray(q))Z=q}}if(Z.length===0)throw Error("Distribution has no aliases to remove");let $=Z.filter((q)=>q!==Q);if($.length===Z.length)throw Error(`Alias ${Q} not found in distribution`);if(_.Aliases.Quantity=$.length,_.Aliases.Items=$.length>0?$:void 0,$.length===0)_.ViewerCertificate={CloudFrontDefaultCertificate:!0,MinimumProtocolVersion:"TLSv1.2_2021"};let j=this.buildDistributionConfigXml(_),L=await this.client.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${J}/config`,body:j,headers:{"Content-Type":"application/xml","If-Match":Y},returnHeaders:!0});return{ETag:L.headers?.etag||L.headers?.ETag||L.ETag||""}}}
141
+ export{N as nd};
@@ -0,0 +1,4 @@
1
+ import{Og as O}from"./chunk-fpm59y25.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 Xe};
@@ -0,0 +1 @@
1
+ import{cd as a}from"./chunk-hm08xdxf.js";import"./chunk-fpm59y25.js";import"./chunk-mh0kdzqp.js";export{a as STSClient};